scroggo@google.com | 72c9672 | 2012-06-06 21:07:10 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "SkBitmap.h" |
| 9 | #include "SkGPipe.h" |
| 10 | |
| 11 | class SkCanvas; |
scroggo@google.com | b073d92 | 2012-06-08 15:35:03 +0000 | [diff] [blame] | 12 | class SkMatrix; |
scroggo@google.com | 72c9672 | 2012-06-06 21:07:10 +0000 | [diff] [blame] | 13 | |
| 14 | class PipeController : public SkGPipeController { |
| 15 | public: |
| 16 | PipeController(SkCanvas* target); |
| 17 | virtual ~PipeController(); |
| 18 | virtual void* requestBlock(size_t minRequest, size_t* actual) SK_OVERRIDE; |
| 19 | virtual void notifyWritten(size_t bytes) SK_OVERRIDE; |
| 20 | protected: |
| 21 | const void* getData() { return (const char*) fBlock + fBytesWritten; } |
| 22 | SkGPipeReader fReader; |
| 23 | private: |
| 24 | void* fBlock; |
| 25 | size_t fBlockSize; |
| 26 | size_t fBytesWritten; |
| 27 | SkGPipeReader::Status fStatus; |
| 28 | }; |
| 29 | |
| 30 | //////////////////////////////////////////////////////////////////////////////// |
| 31 | |
| 32 | class TiledPipeController : public PipeController { |
| 33 | public: |
scroggo@google.com | b073d92 | 2012-06-08 15:35:03 +0000 | [diff] [blame] | 34 | TiledPipeController(const SkBitmap&, const SkMatrix* initialMatrix = NULL); |
scroggo@google.com | 72c9672 | 2012-06-06 21:07:10 +0000 | [diff] [blame] | 35 | virtual ~TiledPipeController() {}; |
| 36 | virtual void notifyWritten(size_t bytes) SK_OVERRIDE; |
scroggo@google.com | 284bf50 | 2012-07-17 16:10:34 +0000 | [diff] [blame^] | 37 | virtual int numberOfReaders() const SK_OVERRIDE { return NumberOfTiles; } |
scroggo@google.com | 72c9672 | 2012-06-06 21:07:10 +0000 | [diff] [blame] | 38 | private: |
| 39 | enum { |
| 40 | NumberOfTiles = 10 |
| 41 | }; |
| 42 | SkGPipeReader fReaders[NumberOfTiles - 1]; |
| 43 | SkBitmap fBitmaps[NumberOfTiles]; |
| 44 | typedef PipeController INHERITED; |
| 45 | }; |