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

Unified Diff: src/core/SkPicture.cpp

Issue 494683003: Implement SkPicture::hasText() for SkRecord backend. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: always fill fHasText Created 6 years, 4 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') | src/core/SkRecords.h » ('j') | 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 13964065402aa022443ebe49e165d4eeca965da0..f99dfbf462322494419806a0bc74a2ca73760ba0 100644
--- a/src/core/SkPicture.cpp
+++ b/src/core/SkPicture.cpp
@@ -171,10 +171,17 @@ struct PathCounter {
int numAAHairlineConcavePaths;
};
-} // namespace
+// SkRecord visitor to find recorded text.
+struct TextHunter {
+ // All ops with text have that text as a char array member named "text".
+ SK_CREATE_MEMBER_DETECTOR(text);
+ template <typename T> SK_WHEN(HasMember_text<T>, bool) operator()(const T&) { return true; }
+ template <typename T> SK_WHEN(!HasMember_text<T>, bool) operator()(const T&) { return false; }
+};
-void SkPicture::Analysis::init(const SkRecord& record) {
+} // namespace
+SkPicture::Analysis::Analysis(const SkRecord& record) {
fWillPlaybackBitmaps = WillPlaybackBitmaps(record);
PathCounter counter;
@@ -182,9 +189,18 @@ void SkPicture::Analysis::init(const SkRecord& record) {
record.visit<void>(i, counter);
}
fNumPaintWithPathEffectUses = counter.numPaintWithPathEffectUses;
- fNumFastPathDashEffects = counter.numFastPathDashEffects;
- fNumAAConcavePaths = counter.numAAConcavePaths;
- fNumAAHairlineConcavePaths = counter.numAAHairlineConcavePaths;
+ fNumFastPathDashEffects = counter.numFastPathDashEffects;
+ fNumAAConcavePaths = counter.numAAConcavePaths;
+ fNumAAHairlineConcavePaths = counter.numAAHairlineConcavePaths;
+
+ fHasText = false;
+ TextHunter text;
+ for (unsigned i = 0; i < record.count(); i++) {
+ if (record.visit<bool>(i, text)) {
+ fHasText = true;
+ break;
+ }
+ }
}
bool SkPicture::Analysis::suitableForGpuRasterization(const char** reason,
@@ -575,9 +591,16 @@ bool SkPicture::suitableForGpuRasterization(GrContext* context, const char **rea
}
#endif
-// fRecord TODO
+// fRecord OK
bool SkPicture::hasText() const {
- return fData.get() && fData->hasText();
+ if (fRecord.get()) {
+ return fAnalysis.fHasText;
+ }
+ if (fData.get()) {
+ return fData->hasText();
+ }
+ SkFAIL("Unreachable");
+ return false;
}
// fRecord OK
@@ -585,10 +608,11 @@ bool SkPicture::willPlayBackBitmaps() const {
if (fRecord.get()) {
return fAnalysis.fWillPlaybackBitmaps;
}
- if (!fData.get()) {
- return false;
+ if (fData.get()) {
+ return fData->containsBitmaps();
}
- return fData->containsBitmaps();
+ SkFAIL("Unreachable");
+ return false;
}
// fRecord OK
@@ -617,10 +641,8 @@ SkPicture::SkPicture(int width, int height, SkRecord* record, SkBBoxHierarchy* b
, fHeight(height)
, fRecord(record)
, fBBH(SkSafeRef(bbh))
- , fAnalysis() {
+ , fAnalysis(*record) {
// TODO: delay as much of this work until just before first playback?
-
- const_cast<Analysis*>(&fAnalysis)->init(*record);
if (fBBH.get()) {
SkRecordFillBounds(*record, fBBH.get());
}
« no previous file with comments | « include/core/SkPicture.h ('k') | src/core/SkRecords.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698