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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 void SkPixelRef::setMutex(SkBaseMutex* mutex) { | 75 void SkPixelRef::setMutex(SkBaseMutex* mutex) { |
76 if (NULL == mutex) { | 76 if (NULL == mutex) { |
77 mutex = get_default_mutex(); | 77 mutex = get_default_mutex(); |
78 } | 78 } |
79 fMutex = mutex; | 79 fMutex = mutex; |
80 } | 80 } |
81 | 81 |
82 // just need a > 0 value, so pick a funny one to aid in debugging | 82 // just need a > 0 value, so pick a funny one to aid in debugging |
83 #define SKPIXELREF_PRELOCKED_LOCKCOUNT 123456789 | 83 #define SKPIXELREF_PRELOCKED_LOCKCOUNT 123456789 |
84 | 84 |
85 SkPixelRef::SkPixelRef(const SkImageInfo& info, SkBaseMutex* mutex) { | 85 SkPixelRef::SkPixelRef(const SkImageInfo& info, SkBaseMutex* mutex) : fInfo(info ) { |
hal.canary
2014/01/02 17:39:31
Bikeshed: I prefer this syntax:
SkPixelRef::SkPix
| |
86 this->setMutex(mutex); | 86 this->setMutex(mutex); |
87 fInfo = info; | |
88 fPixels = NULL; | 87 fPixels = NULL; |
89 fColorTable = NULL; // we do not track ownership of this | 88 fColorTable = NULL; // we do not track ownership of this |
90 fLockCount = 0; | 89 fLockCount = 0; |
91 this->needsNewGenID(); | 90 this->needsNewGenID(); |
92 fIsImmutable = false; | 91 fIsImmutable = false; |
93 fPreLocked = false; | 92 fPreLocked = false; |
94 } | 93 } |
95 | 94 |
96 SkPixelRef::SkPixelRef(const SkImageInfo& info) { | 95 SkPixelRef::SkPixelRef(const SkImageInfo& info) : fInfo(info) { |
97 this->setMutex(NULL); | 96 this->setMutex(NULL); |
98 fInfo = info; | |
99 fPixels = NULL; | 97 fPixels = NULL; |
100 fColorTable = NULL; // we do not track ownership of this | 98 fColorTable = NULL; // we do not track ownership of this |
101 fLockCount = 0; | 99 fLockCount = 0; |
102 this->needsNewGenID(); | 100 this->needsNewGenID(); |
103 fIsImmutable = false; | 101 fIsImmutable = false; |
104 fPreLocked = false; | 102 fPreLocked = false; |
105 } | 103 } |
106 | 104 |
107 #ifdef SK_SUPPORT_LEGACY_PIXELREF_CONSTRUCTOR | 105 static SkImageInfo read_info(SkFlattenableReadBuffer& buffer) { |
108 // THIS GUY IS DEPRECATED -- don't use me! | 106 SkImageInfo info; |
109 SkPixelRef::SkPixelRef(SkBaseMutex* mutex) { | 107 info.unflatten(buffer); |
108 return info; | |
109 } | |
110 | |
111 SkPixelRef::SkPixelRef(SkFlattenableReadBuffer& buffer, SkBaseMutex* mutex) | |
112 : INHERITED(buffer) | |
113 , fInfo(read_info(buffer)) | |
114 { | |
110 this->setMutex(mutex); | 115 this->setMutex(mutex); |
111 // Fill with dummy values. | |
112 sk_bzero(&fInfo, sizeof(fInfo)); | |
113 fPixels = NULL; | 116 fPixels = NULL; |
114 fColorTable = NULL; // we do not track ownership of this | 117 fColorTable = NULL; // we do not track ownership of this |
115 fLockCount = 0; | 118 fLockCount = 0; |
116 this->needsNewGenID(); | |
117 fIsImmutable = false; | |
118 fPreLocked = false; | |
119 } | |
120 #endif | |
121 | |
122 SkPixelRef::SkPixelRef(SkFlattenableReadBuffer& buffer, SkBaseMutex* mutex) | |
123 : INHERITED(buffer) { | |
124 this->setMutex(mutex); | |
125 fInfo.unflatten(buffer); | |
126 fPixels = NULL; | |
127 fColorTable = NULL; // we do not track ownership of this | |
128 fLockCount = 0; | |
129 fIsImmutable = buffer.readBool(); | 119 fIsImmutable = buffer.readBool(); |
130 fGenerationID = buffer.readUInt(); | 120 fGenerationID = buffer.readUInt(); |
131 fUniqueGenerationID = false; // Conservatively assuming the original still exists. | 121 fUniqueGenerationID = false; // Conservatively assuming the original still exists. |
132 fPreLocked = false; | 122 fPreLocked = false; |
133 } | 123 } |
134 | 124 |
135 SkPixelRef::~SkPixelRef() { | 125 SkPixelRef::~SkPixelRef() { |
136 this->callGenIDChangeListeners(); | 126 this->callGenIDChangeListeners(); |
137 } | 127 } |
138 | 128 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
290 | 280 |
291 #ifdef SK_BUILD_FOR_ANDROID | 281 #ifdef SK_BUILD_FOR_ANDROID |
292 void SkPixelRef::globalRef(void* data) { | 282 void SkPixelRef::globalRef(void* data) { |
293 this->ref(); | 283 this->ref(); |
294 } | 284 } |
295 | 285 |
296 void SkPixelRef::globalUnref() { | 286 void SkPixelRef::globalUnref() { |
297 this->unref(); | 287 this->unref(); |
298 } | 288 } |
299 #endif | 289 #endif |
OLD | NEW |