reed@google.com | bb6992a | 2011-04-26 17:41:56 +0000 | [diff] [blame^] | 1 | /* |
| 2 | Copyright 2011 Google Inc. |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | |
| 18 | #ifndef SkGPipe_DEFINED |
| 19 | #define SkGPipe_DEFINED |
| 20 | |
| 21 | #include "SkWriter32.h" |
| 22 | |
| 23 | class SkCanvas; |
| 24 | |
| 25 | class SkGPipeReader { |
| 26 | public: |
| 27 | SkGPipeReader(SkCanvas* target); |
| 28 | ~SkGPipeReader(); |
| 29 | |
| 30 | enum Status { |
| 31 | kDone_Status, //!< no more data expected from reader |
| 32 | kEOF_Status, //!< need more data from reader |
| 33 | kError_Status //!< encountered error |
| 34 | }; |
| 35 | |
| 36 | Status playback(const void* data, size_t length); |
| 37 | |
| 38 | private: |
| 39 | SkCanvas* fCanvas; |
| 40 | class SkGPipeState* fState; |
| 41 | }; |
| 42 | |
| 43 | /////////////////////////////////////////////////////////////////////////////// |
| 44 | |
| 45 | class SkGPipeWriter { |
| 46 | public: |
| 47 | SkGPipeWriter(); |
| 48 | ~SkGPipeWriter(); |
| 49 | |
| 50 | bool isRecording() const { return NULL != fCanvas; } |
| 51 | SkCanvas* startRecording(); |
| 52 | void endRecording(); |
| 53 | |
| 54 | size_t flatten(void* buffer); |
| 55 | |
| 56 | private: |
| 57 | class SkGPipeCanvas* fCanvas; |
| 58 | SkWriter32 fWriter; |
| 59 | }; |
| 60 | |
| 61 | #endif |