| 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 #include "../private/SkTHash.h" |
| 20 | 20 |
| 21 class SkBitmap; | 21 class SkBitmap; |
| 22 class SkBitmapHeap; | |
| 23 class SkFactorySet; | 22 class SkFactorySet; |
| 24 class SkFlattenable; | 23 class SkFlattenable; |
| 25 class SkRefCntSet; | 24 class SkRefCntSet; |
| 26 | 25 |
| 27 class SkWriteBuffer { | 26 class SkWriteBuffer { |
| 28 public: | 27 public: |
| 29 enum Flags { | 28 enum Flags { |
| 30 kCrossProcess_Flag = 1 << 0, | 29 kCrossProcess_Flag = 1 << 0, |
| 31 }; | 30 }; |
| 32 | 31 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 72 |
| 74 bool writeToStream(SkWStream*); | 73 bool writeToStream(SkWStream*); |
| 75 void writeToMemory(void* dst) { fWriter.flatten(dst); } | 74 void writeToMemory(void* dst) { fWriter.flatten(dst); } |
| 76 | 75 |
| 77 SkFactorySet* setFactoryRecorder(SkFactorySet*); | 76 SkFactorySet* setFactoryRecorder(SkFactorySet*); |
| 78 | 77 |
| 79 SkRefCntSet* getTypefaceRecorder() const { return fTFSet; } | 78 SkRefCntSet* getTypefaceRecorder() const { return fTFSet; } |
| 80 SkRefCntSet* setTypefaceRecorder(SkRefCntSet*); | 79 SkRefCntSet* setTypefaceRecorder(SkRefCntSet*); |
| 81 | 80 |
| 82 /** | 81 /** |
| 83 * Set an SkBitmapHeap to store bitmaps rather than flattening. | |
| 84 * | |
| 85 * Incompatible with an SkPixelSerializer. If an SkPixelSerializer is set, | |
| 86 * setting an SkBitmapHeap will set the SkPixelSerializer to NULL in release | |
| 87 * and crash in debug. | |
| 88 */ | |
| 89 void setBitmapHeap(SkBitmapHeap*); | |
| 90 | |
| 91 /** | |
| 92 * Set an SkPixelSerializer to store an encoded representation of pixels, | 82 * Set an SkPixelSerializer to store an encoded representation of pixels, |
| 93 * e.g. SkBitmaps. | 83 * e.g. SkBitmaps. |
| 94 * | 84 * |
| 95 * Calls ref() on the serializer. | 85 * Calls ref() on the serializer. |
| 96 * | 86 * |
| 97 * TODO: Encode SkImage pixels as well. | 87 * TODO: Encode SkImage pixels as well. |
| 98 * | |
| 99 * Incompatible with the SkBitmapHeap. If an encoder is set fBitmapHeap will | |
| 100 * be set to NULL in release and crash in debug. | |
| 101 */ | 88 */ |
| 102 void setPixelSerializer(SkPixelSerializer*); | 89 void setPixelSerializer(SkPixelSerializer*); |
| 103 SkPixelSerializer* getPixelSerializer() const { return fPixelSerializer; } | 90 SkPixelSerializer* getPixelSerializer() const { return fPixelSerializer; } |
| 104 | 91 |
| 105 private: | 92 private: |
| 106 const uint32_t fFlags; | 93 const uint32_t fFlags; |
| 107 SkFactorySet* fFactorySet; | 94 SkFactorySet* fFactorySet; |
| 108 SkWriter32 fWriter; | 95 SkWriter32 fWriter; |
| 109 | 96 |
| 110 SkBitmapHeap* fBitmapHeap; | |
| 111 SkRefCntSet* fTFSet; | 97 SkRefCntSet* fTFSet; |
| 112 | 98 |
| 113 SkAutoTUnref<SkPixelSerializer> fPixelSerializer; | 99 SkAutoTUnref<SkPixelSerializer> fPixelSerializer; |
| 114 | 100 |
| 115 // Only used if we do not have an fFactorySet | 101 // Only used if we do not have an fFactorySet |
| 116 SkTHashMap<SkString, uint32_t> fFlattenableDict; | 102 SkTHashMap<SkString, uint32_t> fFlattenableDict; |
| 117 }; | 103 }; |
| 118 | 104 |
| 119 #endif // SkWriteBuffer_DEFINED | 105 #endif // SkWriteBuffer_DEFINED |
| OLD | NEW |