| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2007 The Android Open Source Project | 2 * Copyright 2007 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 | 8 |
| 9 #include "SkPictureFlat.h" | 9 #include "SkPictureFlat.h" |
| 10 #include "SkPictureData.h" | 10 #include "SkPictureData.h" |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 this->checkPaint(AsPtr(op.paint)); | 183 this->checkPaint(AsPtr(op.paint)); |
| 184 } | 184 } |
| 185 | 185 |
| 186 template <typename T> | 186 template <typename T> |
| 187 SK_WHEN(!HasMember_paint<T>, void) operator()(const T& op) { /* do nothing *
/ } | 187 SK_WHEN(!HasMember_paint<T>, void) operator()(const T& op) { /* do nothing *
/ } |
| 188 | 188 |
| 189 int fNumSlowPathsAndDashEffects; | 189 int fNumSlowPathsAndDashEffects; |
| 190 }; | 190 }; |
| 191 | 191 |
| 192 SkPicture::Analysis::Analysis(const SkRecord& record) { | 192 SkPicture::Analysis::Analysis(const SkRecord& record) { |
| 193 fIsAnalyzed = false; |
| 194 } |
| 195 |
| 196 void SkPicture::Analysis::performAnalysis(const SkRecord& record) { |
| 197 SkASSERT(!fIsAnalyzed); |
| 198 |
| 193 fWillPlaybackBitmaps = WillPlaybackBitmaps(record); | 199 fWillPlaybackBitmaps = WillPlaybackBitmaps(record); |
| 194 | 200 |
| 195 PathCounter counter; | 201 PathCounter counter; |
| 196 for (unsigned i = 0; i < record.count(); i++) { | 202 for (unsigned i = 0; i < record.count(); i++) { |
| 197 record.visit<void>(i, counter); | 203 record.visit<void>(i, counter); |
| 198 } | 204 } |
| 199 fNumSlowPathsAndDashEffects = SkTMin<int>(counter.fNumSlowPathsAndDashEffect
s, 255); | 205 fNumSlowPathsAndDashEffects = SkTMin<int>(counter.fNumSlowPathsAndDashEffect
s, 255); |
| 200 | 206 |
| 201 fHasText = false; | 207 fHasText = false; |
| 202 TextHunter text; | 208 TextHunter text; |
| 203 for (unsigned i = 0; i < record.count(); i++) { | 209 for (unsigned i = 0; i < record.count(); i++) { |
| 204 if (record.visit<bool>(i, text)) { | 210 if (record.visit<bool>(i, text)) { |
| 205 fHasText = true; | 211 fHasText = true; |
| 206 break; | 212 break; |
| 207 } | 213 } |
| 208 } | 214 } |
| 215 fIsAnalyzed = true; |
| 209 } | 216 } |
| 210 | 217 |
| 211 bool SkPicture::Analysis::suitableForGpuRasterization(const char** reason, | 218 bool SkPicture::Analysis::suitableForGpuRasterization(const char** reason, |
| 212 int sampleCount) const { | 219 int sampleCount) const { |
| 213 // TODO: the heuristic used here needs to be refined | 220 // TODO: the heuristic used here needs to be refined |
| 214 static const int kNumSlowPathsTol = 6; | 221 static const int kNumSlowPathsTol = 6; |
| 215 | 222 |
| 216 bool ret = fNumSlowPathsAndDashEffects < kNumSlowPathsTol; | 223 bool ret = fNumSlowPathsAndDashEffects < kNumSlowPathsTol; |
| 217 | 224 |
| 218 if (!ret && reason) { | 225 if (!ret && reason) { |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 buffer.writeUInt(info.fFlags); | 439 buffer.writeUInt(info.fFlags); |
| 433 if (data) { | 440 if (data) { |
| 434 buffer.writeBool(true); | 441 buffer.writeBool(true); |
| 435 data->flatten(buffer); | 442 data->flatten(buffer); |
| 436 } else { | 443 } else { |
| 437 buffer.writeBool(false); | 444 buffer.writeBool(false); |
| 438 } | 445 } |
| 439 } | 446 } |
| 440 | 447 |
| 441 #if SK_SUPPORT_GPU | 448 #if SK_SUPPORT_GPU |
| 442 bool SkPicture::suitableForGpuRasterization(GrContext*, const char **reason) con
st { | 449 bool SkPicture::suitableForGpuRasterization(GrContext*, const char **reason) { |
| 450 if (!fAnalysis.isAnalyzed()) |
| 451 fAnalysis.performAnalysis(*fRecord); |
| 443 return fAnalysis.suitableForGpuRasterization(reason, 0); | 452 return fAnalysis.suitableForGpuRasterization(reason, 0); |
| 444 } | 453 } |
| 445 #endif | 454 #endif |
| 446 | 455 |
| 447 bool SkPicture::hasText() const { return fAnalysis.fHasText; } | 456 bool SkPicture::hasText() const { return fAnalysis.fHasText; } |
| 448 bool SkPicture::willPlayBackBitmaps() const { return fAnalysis.fWillPlaybackBitm
aps; } | 457 bool SkPicture::willPlayBackBitmaps() const { return fAnalysis.fWillPlaybackBitm
aps; } |
| 449 int SkPicture::approximateOpCount() const { return fRecord->count(); } | 458 int SkPicture::approximateOpCount() const { return fRecord->count(); } |
| 450 | 459 |
| 451 SkPicture::SkPicture(const SkRect& cullRect, | 460 SkPicture::SkPicture(const SkRect& cullRect, |
| 452 SkRecord* record, | 461 SkRecord* record, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 473 if (sk_atomic_compare_exchange(&fUniqueID, &id, next, | 482 if (sk_atomic_compare_exchange(&fUniqueID, &id, next, |
| 474 sk_memory_order_relaxed, | 483 sk_memory_order_relaxed, |
| 475 sk_memory_order_relaxed)) { | 484 sk_memory_order_relaxed)) { |
| 476 id = next; | 485 id = next; |
| 477 } else { | 486 } else { |
| 478 // sk_atomic_compare_exchange replaced id with the current value of
fUniqueID. | 487 // sk_atomic_compare_exchange replaced id with the current value of
fUniqueID. |
| 479 } | 488 } |
| 480 } | 489 } |
| 481 return id; | 490 return id; |
| 482 } | 491 } |
| OLD | NEW |