Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Unified Diff: src/core/SkPicture.cpp

Issue 1130123006: Perform SkPicture analysis lazily. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkPicture.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPicture.cpp
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp
index c0148793542a7f84c8aff65175bcb345a5d6f9aa..0145cbe5d7adab19f0b8602a1a5e0bb69c297c0f 100644
--- a/src/core/SkPicture.cpp
+++ b/src/core/SkPicture.cpp
@@ -137,7 +137,7 @@ struct SkPicture::PathCounter {
// Recurse into nested pictures.
void operator()(const SkRecords::DrawPicture& op) {
- const SkPicture::Analysis& analysis = op.picture->fAnalysis;
+ const SkPicture::Analysis& analysis = op.picture->analysis();
fNumSlowPathsAndDashEffects += analysis.fNumSlowPathsAndDashEffects;
}
@@ -438,14 +438,19 @@ void SkPicture::flatten(SkWriteBuffer& buffer) const {
}
}
+const SkPicture::Analysis& SkPicture::analysis() const {
+ auto create = [&](){ return SkNEW_ARGS(Analysis, (*fRecord)); };
+ return *fAnalysis.get(create);
+}
+
#if SK_SUPPORT_GPU
bool SkPicture::suitableForGpuRasterization(GrContext*, const char **reason) const {
- return fAnalysis.suitableForGpuRasterization(reason, 0);
+ return this->analysis().suitableForGpuRasterization(reason, 0);
}
#endif
-bool SkPicture::hasText() const { return fAnalysis.fHasText; }
-bool SkPicture::willPlayBackBitmaps() const { return fAnalysis.fWillPlaybackBitmaps; }
+bool SkPicture::hasText() const { return this->analysis().fHasText; }
+bool SkPicture::willPlayBackBitmaps() const { return this->analysis().fWillPlaybackBitmaps; }
int SkPicture::approximateOpCount() const { return fRecord->count(); }
SkPicture::SkPicture(const SkRect& cullRect,
@@ -461,7 +466,6 @@ SkPicture::SkPicture(const SkRect& cullRect,
, fBBH(bbh) // Take ownership of caller's ref.
, fAccelData(accelData) // Take ownership of caller's ref.
, fApproxBytesUsedBySubPictures(approxBytesUsedBySubPictures)
- , fAnalysis(*fRecord)
{}
« no previous file with comments | « include/core/SkPicture.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698