| 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 "SkData.h" | 12 #include "SkData.h" |
| 13 #include "SkImage.h" | 13 #include "SkImage.h" |
| 14 #include "SkPath.h" | 14 #include "SkPath.h" |
| 15 #include "SkPicture.h" | 15 #include "SkPicture.h" |
| 16 #include "SkPixelSerializer.h" | 16 #include "SkPixelSerializer.h" |
| 17 #include "SkRefCnt.h" | 17 #include "SkRefCnt.h" |
| 18 #include "SkWriter32.h" | 18 #include "SkWriter32.h" |
| 19 #include "../private/SkTHash.h" |
| 19 | 20 |
| 20 class SkBitmap; | 21 class SkBitmap; |
| 21 class SkBitmapHeap; | 22 class SkBitmapHeap; |
| 22 class SkFactorySet; | 23 class SkFactorySet; |
| 23 class SkFlattenable; | 24 class SkFlattenable; |
| 24 class SkRefCntSet; | 25 class SkRefCntSet; |
| 25 | 26 |
| 26 class SkWriteBuffer { | 27 class SkWriteBuffer { |
| 27 public: | 28 public: |
| 28 enum Flags { | 29 enum Flags { |
| 29 kCrossProcess_Flag = 1 << 0, | 30 kCrossProcess_Flag = 1 << 0, |
| 30 kValidation_Flag = 1 << 1, | |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 SkWriteBuffer(uint32_t flags = 0); | 33 SkWriteBuffer(uint32_t flags = 0); |
| 34 SkWriteBuffer(void* initialStorage, size_t storageSize, uint32_t flags = 0); | 34 SkWriteBuffer(void* initialStorage, size_t storageSize, uint32_t flags = 0); |
| 35 ~SkWriteBuffer(); | 35 ~SkWriteBuffer(); |
| 36 | 36 |
| 37 bool isCrossProcess() const { | 37 bool isCrossProcess() const { |
| 38 return this->isValidating() || SkToBool(fFlags & kCrossProcess_Flag); | 38 return SkToBool(fFlags & kCrossProcess_Flag); |
| 39 } | 39 } |
| 40 | 40 |
| 41 SkWriter32* getWriter32() { return &fWriter; } | 41 SkWriter32* getWriter32() { return &fWriter; } |
| 42 void reset(void* storage = NULL, size_t storageSize = 0) { | 42 void reset(void* storage = NULL, size_t storageSize = 0) { |
| 43 fWriter.reset(storage, storageSize); | 43 fWriter.reset(storage, storageSize); |
| 44 } | 44 } |
| 45 | 45 |
| 46 uint32_t* reserve(size_t size) { return fWriter.reserve(size); } | 46 uint32_t* reserve(size_t size) { return fWriter.reserve(size); } |
| 47 | 47 |
| 48 size_t bytesWritten() const { return fWriter.bytesWritten(); } | 48 size_t bytesWritten() const { return fWriter.bytesWritten(); } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 * | 101 * |
| 102 * TODO: Encode SkImage pixels as well. | 102 * TODO: Encode SkImage pixels as well. |
| 103 * | 103 * |
| 104 * Incompatible with the SkBitmapHeap. If an encoder is set fBitmapHeap will | 104 * Incompatible with the SkBitmapHeap. If an encoder is set fBitmapHeap will |
| 105 * be set to NULL in release and crash in debug. | 105 * be set to NULL in release and crash in debug. |
| 106 */ | 106 */ |
| 107 void setPixelSerializer(SkPixelSerializer*); | 107 void setPixelSerializer(SkPixelSerializer*); |
| 108 SkPixelSerializer* getPixelSerializer() const { return fPixelSerializer; } | 108 SkPixelSerializer* getPixelSerializer() const { return fPixelSerializer; } |
| 109 | 109 |
| 110 private: | 110 private: |
| 111 bool isValidating() const { return SkToBool(fFlags & kValidation_Flag); } | |
| 112 | |
| 113 const uint32_t fFlags; | 111 const uint32_t fFlags; |
| 114 SkFactorySet* fFactorySet; | 112 SkFactorySet* fFactorySet; |
| 115 SkWriter32 fWriter; | 113 SkWriter32 fWriter; |
| 116 | 114 |
| 117 SkBitmapHeap* fBitmapHeap; | 115 SkBitmapHeap* fBitmapHeap; |
| 118 SkRefCntSet* fTFSet; | 116 SkRefCntSet* fTFSet; |
| 119 | 117 |
| 120 SkAutoTUnref<SkPixelSerializer> fPixelSerializer; | 118 SkAutoTUnref<SkPixelSerializer> fPixelSerializer; |
| 119 |
| 120 // Only used if we do not have an fFactorySet |
| 121 SkTHashMap<SkString, uint32_t> fFlattenableDict; |
| 121 }; | 122 }; |
| 122 | 123 |
| 123 #endif // SkWriteBuffer_DEFINED | 124 #endif // SkWriteBuffer_DEFINED |
| OLD | NEW |