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 "SkReadBuffer.h" | 9 #include "SkReadBuffer.h" |
10 #include "SkWriteBuffer.h" | 10 #include "SkWriteBuffer.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 const_cast<SkAlphaType*>(&fInfo.
fAlphaType))); | 101 const_cast<SkAlphaType*>(&fInfo.
fAlphaType))); |
102 | 102 |
103 this->setMutex(mutex); | 103 this->setMutex(mutex); |
104 fRec.zero(); | 104 fRec.zero(); |
105 fLockCount = 0; | 105 fLockCount = 0; |
106 this->needsNewGenID(); | 106 this->needsNewGenID(); |
107 fIsImmutable = false; | 107 fIsImmutable = false; |
108 fPreLocked = false; | 108 fPreLocked = false; |
109 } | 109 } |
110 | 110 |
111 #ifdef SK_SUPPORT_LEGACY_PIXELREF_UNFLATTENABLE | |
112 static SkImageInfo read_info(SkReadBuffer& buffer) { | |
113 SkImageInfo info; | |
114 info.unflatten(buffer); | |
115 return info; | |
116 } | |
117 | |
118 SkPixelRef::SkPixelRef(SkReadBuffer& buffer, SkBaseMutex* mutex) | |
119 : INHERITED(buffer) | |
120 , fInfo(read_info(buffer)) | |
121 { | |
122 SkDEBUGCODE(SkAlphaType alphaType;) | |
123 SkASSERT(SkColorTypeValidateAlphaType(fInfo.colorType(), fInfo.alphaType(),
&alphaType)); | |
124 SkASSERT(fInfo.fAlphaType == alphaType); | |
125 | |
126 this->setMutex(mutex); | |
127 fRec.zero(); | |
128 fLockCount = 0; | |
129 fIsImmutable = buffer.readBool(); | |
130 fGenerationID = buffer.readUInt(); | |
131 fUniqueGenerationID = false; // Conservatively assuming the original still
exists. | |
132 fPreLocked = false; | |
133 } | |
134 #endif | |
135 | |
136 SkPixelRef::~SkPixelRef() { | 111 SkPixelRef::~SkPixelRef() { |
137 this->callGenIDChangeListeners(); | 112 this->callGenIDChangeListeners(); |
138 } | 113 } |
139 | 114 |
140 void SkPixelRef::needsNewGenID() { | 115 void SkPixelRef::needsNewGenID() { |
141 fGenerationID = 0; | 116 fGenerationID = 0; |
142 fUniqueGenerationID = false; | 117 fUniqueGenerationID = false; |
143 } | 118 } |
144 | 119 |
145 void SkPixelRef::cloneGenID(const SkPixelRef& that) { | 120 void SkPixelRef::cloneGenID(const SkPixelRef& that) { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 | 263 |
289 #ifdef SK_BUILD_FOR_ANDROID | 264 #ifdef SK_BUILD_FOR_ANDROID |
290 void SkPixelRef::globalRef(void* data) { | 265 void SkPixelRef::globalRef(void* data) { |
291 this->ref(); | 266 this->ref(); |
292 } | 267 } |
293 | 268 |
294 void SkPixelRef::globalUnref() { | 269 void SkPixelRef::globalUnref() { |
295 this->unref(); | 270 this->unref(); |
296 } | 271 } |
297 #endif | 272 #endif |
OLD | NEW |