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 #include "SkPixelRef.h" | 8 #include "SkPixelRef.h" |
9 #include "SkFlattenableBuffers.h" | 9 #include "SkFlattenableBuffers.h" |
10 #include "SkThread.h" | 10 #include "SkThread.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 fLockCount = 0; | 115 fLockCount = 0; |
116 this->needsNewGenID(); | 116 this->needsNewGenID(); |
117 fIsImmutable = false; | 117 fIsImmutable = false; |
118 fPreLocked = false; | 118 fPreLocked = false; |
119 } | 119 } |
120 #endif | 120 #endif |
121 | 121 |
122 SkPixelRef::SkPixelRef(SkFlattenableReadBuffer& buffer, SkBaseMutex* mutex) | 122 SkPixelRef::SkPixelRef(SkFlattenableReadBuffer& buffer, SkBaseMutex* mutex) |
123 : INHERITED(buffer) { | 123 : INHERITED(buffer) { |
124 this->setMutex(mutex); | 124 this->setMutex(mutex); |
| 125 fInfo.unflatten(buffer); |
125 fPixels = NULL; | 126 fPixels = NULL; |
126 fColorTable = NULL; // we do not track ownership of this | 127 fColorTable = NULL; // we do not track ownership of this |
127 fLockCount = 0; | 128 fLockCount = 0; |
128 fIsImmutable = buffer.readBool(); | 129 fIsImmutable = buffer.readBool(); |
129 fGenerationID = buffer.readUInt(); | 130 fGenerationID = buffer.readUInt(); |
130 fUniqueGenerationID = false; // Conservatively assuming the original still
exists. | 131 fUniqueGenerationID = false; // Conservatively assuming the original still
exists. |
131 fPreLocked = false; | 132 fPreLocked = false; |
132 } | 133 } |
133 | 134 |
134 SkPixelRef::~SkPixelRef() { | 135 SkPixelRef::~SkPixelRef() { |
(...skipping 18 matching lines...) Expand all Loading... |
153 // out of sync. | 154 // out of sync. |
154 fPixels = pixels; | 155 fPixels = pixels; |
155 fColorTable = ctable; | 156 fColorTable = ctable; |
156 fLockCount = SKPIXELREF_PRELOCKED_LOCKCOUNT; | 157 fLockCount = SKPIXELREF_PRELOCKED_LOCKCOUNT; |
157 fPreLocked = true; | 158 fPreLocked = true; |
158 #endif | 159 #endif |
159 } | 160 } |
160 | 161 |
161 void SkPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const { | 162 void SkPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const { |
162 this->INHERITED::flatten(buffer); | 163 this->INHERITED::flatten(buffer); |
| 164 fInfo.flatten(buffer); |
163 buffer.writeBool(fIsImmutable); | 165 buffer.writeBool(fIsImmutable); |
164 // We write the gen ID into the picture for within-process recording. This | 166 // We write the gen ID into the picture for within-process recording. This |
165 // is safe since the same genID will never refer to two different sets of | 167 // is safe since the same genID will never refer to two different sets of |
166 // pixels (barring overflow). However, each process has its own "namespace" | 168 // pixels (barring overflow). However, each process has its own "namespace" |
167 // of genIDs. So for cross-process recording we write a zero which will | 169 // of genIDs. So for cross-process recording we write a zero which will |
168 // trigger assignment of a new genID in playback. | 170 // trigger assignment of a new genID in playback. |
169 if (buffer.isCrossProcess()) { | 171 if (buffer.isCrossProcess()) { |
170 buffer.writeUInt(0); | 172 buffer.writeUInt(0); |
171 } else { | 173 } else { |
172 buffer.writeUInt(fGenerationID); | 174 buffer.writeUInt(fGenerationID); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 | 290 |
289 #ifdef SK_BUILD_FOR_ANDROID | 291 #ifdef SK_BUILD_FOR_ANDROID |
290 void SkPixelRef::globalRef(void* data) { | 292 void SkPixelRef::globalRef(void* data) { |
291 this->ref(); | 293 this->ref(); |
292 } | 294 } |
293 | 295 |
294 void SkPixelRef::globalUnref() { | 296 void SkPixelRef::globalUnref() { |
295 this->unref(); | 297 this->unref(); |
296 } | 298 } |
297 #endif | 299 #endif |
OLD | NEW |