| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #ifndef SkWriteBuffer_DEFINED | 9 #ifndef SkWriteBuffer_DEFINED |
| 10 #define SkWriteBuffer_DEFINED | 10 #define SkWriteBuffer_DEFINED |
| 11 | 11 |
| 12 #include "SkBitmapHeap.h" | 12 #include "SkBitmapHeap.h" |
| 13 #include "SkData.h" | 13 #include "SkData.h" |
| 14 #include "SkPath.h" | 14 #include "SkPath.h" |
| 15 #include "SkPicture.h" | 15 #include "SkPicture.h" |
| 16 #include "SkRefCnt.h" | 16 #include "SkRefCnt.h" |
| 17 #include "SkWriter32.h" | 17 #include "SkWriter32.h" |
| 18 | 18 |
| 19 class SkBitmap; | 19 class SkBitmap; |
| 20 class SkFactorySet; | 20 class SkFactorySet; |
| 21 class SkFlattenable; | 21 class SkFlattenable; |
| 22 class SkNamedFactorySet; | 22 class SkNamedFactorySet; |
| 23 class SkRefCntSet; | 23 class SkRefCntSet; |
| 24 | 24 |
| 25 class SkWriteBuffer { | 25 class SkWriteBuffer { |
| 26 public: | 26 public: |
| 27 SkWriteBuffer(); | |
| 28 SkWriteBuffer(void* initialStorage, size_t storageSize); | |
| 29 ~SkWriteBuffer(); | |
| 30 | |
| 31 enum Flags { | 27 enum Flags { |
| 32 kCrossProcess_Flag = 1 << 0, | 28 kCrossProcess_Flag = 1 << 0, |
| 33 kValidation_Flag = 1 << 1, | 29 kValidation_Flag = 1 << 1, |
| 34 }; | 30 }; |
| 35 void setFlags(uint32_t flags) { fFlags = flags; } | |
| 36 uint32_t getFlags() const { return fFlags; } | |
| 37 | 31 |
| 38 bool isValidating() const { return SkToBool(fFlags & kValidation_Flag); } | 32 SkWriteBuffer(uint32_t flags = 0); |
| 33 SkWriteBuffer(void* initialStorage, size_t storageSize, uint32_t flags = 0); |
| 34 ~SkWriteBuffer(); |
| 35 |
| 39 bool isCrossProcess() const { | 36 bool isCrossProcess() const { |
| 40 return this->isValidating() || SkToBool(fFlags & kCrossProcess_Flag); | 37 return this->isValidating() || SkToBool(fFlags & kCrossProcess_Flag); |
| 41 } | 38 } |
| 42 | 39 |
| 43 SkWriter32* getWriter32() { return &fWriter; } | 40 SkWriter32* getWriter32() { return &fWriter; } |
| 44 void reset(void* storage = NULL, size_t storageSize = 0) { | 41 void reset(void* storage = NULL, size_t storageSize = 0) { |
| 45 fWriter.reset(storage, storageSize); | 42 fWriter.reset(storage, storageSize); |
| 46 } | 43 } |
| 47 | 44 |
| 48 uint32_t* reserve(size_t size) { return fWriter.reserve(size); } | 45 uint32_t* reserve(size_t size) { return fWriter.reserve(size); } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 * bitmapEncoder to store the SkBitmap. If the reader does not provide a fun
ction to decode, it | 97 * bitmapEncoder to store the SkBitmap. If the reader does not provide a fun
ction to decode, it |
| 101 * will not be able to restore SkBitmaps, but will still be able to read the
rest of the stream. | 98 * will not be able to restore SkBitmaps, but will still be able to read the
rest of the stream. |
| 102 * bitmapEncoder will never be called with a NULL pixelRefOffset. | 99 * bitmapEncoder will never be called with a NULL pixelRefOffset. |
| 103 * | 100 * |
| 104 * Incompatible with the SkBitmapHeap. If an encoder is set fBitmapHeap will
be set to NULL in | 101 * Incompatible with the SkBitmapHeap. If an encoder is set fBitmapHeap will
be set to NULL in |
| 105 * release and crash in debug. | 102 * release and crash in debug. |
| 106 */ | 103 */ |
| 107 void setBitmapEncoder(SkPicture::EncodeBitmap bitmapEncoder); | 104 void setBitmapEncoder(SkPicture::EncodeBitmap bitmapEncoder); |
| 108 | 105 |
| 109 private: | 106 private: |
| 110 uint32_t fFlags; | 107 bool isValidating() const { return SkToBool(fFlags & kValidation_Flag); } |
| 108 |
| 109 const uint32_t fFlags; |
| 111 SkFactorySet* fFactorySet; | 110 SkFactorySet* fFactorySet; |
| 112 SkNamedFactorySet* fNamedFactorySet; | 111 SkNamedFactorySet* fNamedFactorySet; |
| 113 SkWriter32 fWriter; | 112 SkWriter32 fWriter; |
| 114 | 113 |
| 115 SkBitmapHeap* fBitmapHeap; | 114 SkBitmapHeap* fBitmapHeap; |
| 116 SkRefCntSet* fTFSet; | 115 SkRefCntSet* fTFSet; |
| 117 | 116 |
| 118 SkPicture::EncodeBitmap fBitmapEncoder; | 117 SkPicture::EncodeBitmap fBitmapEncoder; |
| 119 }; | 118 }; |
| 120 | 119 |
| 121 #endif // SkWriteBuffer_DEFINED | 120 #endif // SkWriteBuffer_DEFINED |
| OLD | NEW |