Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 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 SkFlattenableBuffers_DEFINED | 9 #ifndef SkFlattenableBuffers_DEFINED |
| 10 #define SkFlattenableBuffers_DEFINED | 10 #define SkFlattenableBuffers_DEFINED |
| 11 | 11 |
| 12 #include "SkColor.h" | 12 #include "SkColor.h" |
| 13 #include "SkData.h" | |
| 13 #include "SkPaint.h" | 14 #include "SkPaint.h" |
| 14 #include "SkPoint.h" | 15 #include "SkPoint.h" |
| 15 | 16 |
| 16 class SkBitmap; | 17 class SkBitmap; |
| 17 class SkFlattenable; | 18 class SkFlattenable; |
| 18 struct SkIRect; | 19 struct SkIRect; |
| 19 class SkMatrix; | 20 class SkMatrix; |
| 20 class SkOrderedReadBuffer; | 21 class SkOrderedReadBuffer; |
| 21 class SkOrderedWriteBuffer; | 22 class SkOrderedWriteBuffer; |
| 22 class SkPath; | 23 class SkPath; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 | 91 |
| 91 virtual void readBitmap(SkBitmap* bitmap) = 0; | 92 virtual void readBitmap(SkBitmap* bitmap) = 0; |
| 92 virtual SkTypeface* readTypeface() = 0; | 93 virtual SkTypeface* readTypeface() = 0; |
| 93 | 94 |
| 94 // helper function for classes with const SkPoint members | 95 // helper function for classes with const SkPoint members |
| 95 SkPoint readPoint() { | 96 SkPoint readPoint() { |
| 96 SkPoint point; | 97 SkPoint point; |
| 97 this->readPoint(&point); | 98 this->readPoint(&point); |
| 98 return point; | 99 return point; |
| 99 } | 100 } |
| 101 | |
| 102 SkData* readByteArrayAsData() { | |
|
mtklein
2013/10/10 21:32:03
Mentioning byte array here seems weird to me. rea
sugoi
2013/10/11 12:03:35
Shouldn't it be pure virtual and defined in SkOrde
sugoi
2013/10/11 12:03:35
+1
reed1
2013/10/14 13:32:14
I think there is no value-added to storing SkData
| |
| 103 size_t len = this->getArrayCount(); | |
| 104 void* buffer = sk_malloc_throw(len); | |
| 105 (void)this->readByteArray(buffer); | |
| 106 return SkData::NewFromMalloc(buffer, len); | |
| 107 } | |
| 100 | 108 |
| 101 template <typename T> T* readFlattenableT() { | 109 template <typename T> T* readFlattenableT() { |
| 102 return static_cast<T*>(this->readFlattenable()); | 110 return static_cast<T*>(this->readFlattenable()); |
| 103 } | 111 } |
| 104 | 112 |
| 105 private: | 113 private: |
| 106 uint32_t fFlags; | 114 uint32_t fFlags; |
| 107 }; | 115 }; |
| 108 | 116 |
| 109 /////////////////////////////////////////////////////////////////////////////// | 117 /////////////////////////////////////////////////////////////////////////////// |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 | 166 |
| 159 uint32_t getFlags() const { return fFlags; } | 167 uint32_t getFlags() const { return fFlags; } |
| 160 void setFlags(uint32_t flags) { fFlags = flags; } | 168 void setFlags(uint32_t flags) { fFlags = flags; } |
| 161 | 169 |
| 162 bool isCrossProcess() const { | 170 bool isCrossProcess() const { |
| 163 return SkToBool(fFlags & kCrossProcess_Flag); | 171 return SkToBool(fFlags & kCrossProcess_Flag); |
| 164 } | 172 } |
| 165 | 173 |
| 166 bool persistTypeface() const { return (fFlags & kCrossProcess_Flag) != 0; } | 174 bool persistTypeface() const { return (fFlags & kCrossProcess_Flag) != 0; } |
| 167 | 175 |
| 176 void writeDataAsByteArray(SkData* data) { | |
| 177 this->writeByteArray(data->data(), data->size()); | |
| 178 } | |
| 179 | |
| 168 protected: | 180 protected: |
| 169 // A helper function so that each subclass does not have to be a friend of S kFlattenable | 181 // A helper function so that each subclass does not have to be a friend of S kFlattenable |
| 170 void flattenObject(SkFlattenable* obj, SkFlattenableWriteBuffer& buffer); | 182 void flattenObject(SkFlattenable* obj, SkFlattenableWriteBuffer& buffer); |
| 171 | 183 |
| 172 uint32_t fFlags; | 184 uint32_t fFlags; |
| 173 }; | 185 }; |
| 174 | 186 |
| 175 #endif | 187 #endif |
| OLD | NEW |