| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2007 The Android Open Source Project | 3 * Copyright 2007 The Android Open Source Project |
| 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 | 9 |
| 10 #include "SkPictureFlat.h" | 10 #include "SkPictureFlat.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 fHeight = src.fHeight; | 133 fHeight = src.fHeight; |
| 134 fRecord = NULL; | 134 fRecord = NULL; |
| 135 | 135 |
| 136 /* We want to copy the src's playback. However, if that hasn't been built | 136 /* We want to copy the src's playback. However, if that hasn't been built |
| 137 yet, we need to fake a call to endRecording() without actually calling | 137 yet, we need to fake a call to endRecording() without actually calling |
| 138 it (since it is destructive, and we don't want to change src). | 138 it (since it is destructive, and we don't want to change src). |
| 139 */ | 139 */ |
| 140 if (src.fPlayback) { | 140 if (src.fPlayback) { |
| 141 fPlayback = SkNEW_ARGS(SkPicturePlayback, (*src.fPlayback)); | 141 fPlayback = SkNEW_ARGS(SkPicturePlayback, (*src.fPlayback)); |
| 142 SkASSERT(NULL == src.fRecord); | 142 SkASSERT(NULL == src.fRecord); |
| 143 fGenerationID = src.getGenerationID(); // need to call method to ens
ure != 0 | 143 fUniqueID = src.uniqueID(); // need to call method to ensure != 0 |
| 144 } else if (src.fRecord) { | 144 } else if (src.fRecord) { |
| 145 SkPictInfo info; | 145 SkPictInfo info; |
| 146 this->createHeader(&info); | 146 this->createHeader(&info); |
| 147 // here we do a fake src.endRecording() | 147 // here we do a fake src.endRecording() |
| 148 fPlayback = SkNEW_ARGS(SkPicturePlayback, (*src.fRecord, info)); | 148 fPlayback = SkNEW_ARGS(SkPicturePlayback, (*src.fRecord, info)); |
| 149 } else { | 149 } else { |
| 150 fPlayback = NULL; | 150 fPlayback = NULL; |
| 151 } | 151 } |
| 152 } | 152 } |
| 153 | 153 |
| 154 SkPicture::~SkPicture() { | 154 SkPicture::~SkPicture() { |
| 155 SkSafeUnref(fRecord); | 155 SkSafeUnref(fRecord); |
| 156 SkDELETE(fPlayback); | 156 SkDELETE(fPlayback); |
| 157 SkSafeUnref(fAccelData); | 157 SkSafeUnref(fAccelData); |
| 158 } | 158 } |
| 159 | 159 |
| 160 void SkPicture::internalOnly_EnableOpts(bool enableOpts) { | 160 void SkPicture::internalOnly_EnableOpts(bool enableOpts) { |
| 161 if (NULL != fRecord) { | 161 if (NULL != fRecord) { |
| 162 fRecord->internalOnly_EnableOpts(enableOpts); | 162 fRecord->internalOnly_EnableOpts(enableOpts); |
| 163 } | 163 } |
| 164 } | 164 } |
| 165 | 165 |
| 166 void SkPicture::swap(SkPicture& other) { | 166 void SkPicture::swap(SkPicture& other) { |
| 167 SkTSwap(fGenerationID, other.fGenerationID); | 167 SkTSwap(fUniqueID, other.fUniqueID); |
| 168 SkTSwap(fRecord, other.fRecord); | 168 SkTSwap(fRecord, other.fRecord); |
| 169 SkTSwap(fPlayback, other.fPlayback); | 169 SkTSwap(fPlayback, other.fPlayback); |
| 170 SkTSwap(fAccelData, other.fAccelData); | 170 SkTSwap(fAccelData, other.fAccelData); |
| 171 SkTSwap(fWidth, other.fWidth); | 171 SkTSwap(fWidth, other.fWidth); |
| 172 SkTSwap(fHeight, other.fHeight); | 172 SkTSwap(fHeight, other.fHeight); |
| 173 } | 173 } |
| 174 | 174 |
| 175 SkPicture* SkPicture::clone() const { | 175 SkPicture* SkPicture::clone() const { |
| 176 SkPicture* clonedPicture = SkNEW(SkPicture); | 176 SkPicture* clonedPicture = SkNEW(SkPicture); |
| 177 this->clone(clonedPicture, 1); | 177 this->clone(clonedPicture, 1); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 192 SkSafeSetNull(clone->fRecord); | 192 SkSafeSetNull(clone->fRecord); |
| 193 SkDELETE(clone->fPlayback); | 193 SkDELETE(clone->fPlayback); |
| 194 | 194 |
| 195 /* We want to copy the src's playback. However, if that hasn't been bui
lt | 195 /* We want to copy the src's playback. However, if that hasn't been bui
lt |
| 196 yet, we need to fake a call to endRecording() without actually calli
ng | 196 yet, we need to fake a call to endRecording() without actually calli
ng |
| 197 it (since it is destructive, and we don't want to change src). | 197 it (since it is destructive, and we don't want to change src). |
| 198 */ | 198 */ |
| 199 if (fPlayback) { | 199 if (fPlayback) { |
| 200 clone->fPlayback = SkNEW_ARGS(SkPicturePlayback, (*fPlayback, ©I
nfo)); | 200 clone->fPlayback = SkNEW_ARGS(SkPicturePlayback, (*fPlayback, ©I
nfo)); |
| 201 SkASSERT(NULL == fRecord); | 201 SkASSERT(NULL == fRecord); |
| 202 clone->fGenerationID = this->getGenerationID(); // need to call meth
od to ensure != 0 | 202 clone->fUniqueID = this->uniqueID(); // need to call method to ensur
e != 0 |
| 203 } else if (fRecord) { | 203 } else if (fRecord) { |
| 204 // here we do a fake src.endRecording() | 204 // here we do a fake src.endRecording() |
| 205 clone->fPlayback = SkNEW_ARGS(SkPicturePlayback, (*fRecord, info, tr
ue)); | 205 clone->fPlayback = SkNEW_ARGS(SkPicturePlayback, (*fRecord, info, tr
ue)); |
| 206 } else { | 206 } else { |
| 207 clone->fPlayback = NULL; | 207 clone->fPlayback = NULL; |
| 208 } | 208 } |
| 209 } | 209 } |
| 210 } | 210 } |
| 211 | 211 |
| 212 SkPicture::AccelData::Domain SkPicture::AccelData::GenerateDomain() { | 212 SkPicture::AccelData::Domain SkPicture::AccelData::GenerateDomain() { |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 } | 499 } |
| 500 #endif | 500 #endif |
| 501 | 501 |
| 502 static int32_t next_picture_generation_id() { | 502 static int32_t next_picture_generation_id() { |
| 503 static int32_t gPictureGenerationID = 0; | 503 static int32_t gPictureGenerationID = 0; |
| 504 // do a loop in case our global wraps around, as we never want to | 504 // do a loop in case our global wraps around, as we never want to |
| 505 // return a 0 | 505 // return a 0 |
| 506 int32_t genID; | 506 int32_t genID; |
| 507 do { | 507 do { |
| 508 genID = sk_atomic_inc(&gPictureGenerationID) + 1; | 508 genID = sk_atomic_inc(&gPictureGenerationID) + 1; |
| 509 } while (((int32_t)SkPicture::kInvalidGenID) == genID); | 509 } while (SK_InvalidGenID == genID); |
| 510 return genID; | 510 return genID; |
| 511 } | 511 } |
| 512 | 512 |
| 513 uint32_t SkPicture::getGenerationID() const { | 513 uint32_t SkPicture::uniqueID() const { |
| 514 if (NULL != fRecord) { | 514 if (NULL != fRecord) { |
| 515 SkASSERT(NULL == fPlayback); | 515 SkASSERT(NULL == fPlayback); |
| 516 return kInvalidGenID; | 516 return SK_InvalidGenID; |
| 517 } | 517 } |
| 518 | 518 |
| 519 if (kInvalidGenID == fGenerationID) { | 519 if (SK_InvalidGenID == fUniqueID) { |
| 520 fGenerationID = next_picture_generation_id(); | 520 fUniqueID = next_picture_generation_id(); |
| 521 } | 521 } |
| 522 return fGenerationID; | 522 return fUniqueID; |
| 523 } | 523 } |
| OLD | NEW |