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

Unified Diff: src/core/SkPicturePlayback.cpp

Issue 324293004: Remove picture pre-allocation from SkPictureRecorder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix initializer list order Created 6 years, 6 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 | « src/core/SkPicturePlayback.h ('k') | src/core/SkPictureRecord.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPicturePlayback.cpp
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index 3f83b6a9cccc7080ba3dd36555141e164e7b0bbd..aa2b021928a7ea3828eb3098e11282f6b95725f7 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -99,26 +99,16 @@ SkPicturePlayback::SkPicturePlayback(const SkPicture* picture,
record.dumpPaints();
#endif
- record.validate(record.writeStream().bytesWritten(), 0);
- const SkWriter32& writer = record.writeStream();
this->init();
- SkASSERT(!fOpData);
- if (writer.bytesWritten() == 0) {
- fOpData = SkData::NewEmpty();
- return;
- }
- if (deepCopyOps) {
- // Don't try to do anything clever w.r.t. copy on write
- fOpData = SkData::NewWithCopy(writer.contiguousArray(), writer.bytesWritten());
- } else {
- fOpData = writer.snapshotAsData();
- }
+
+ fOpData = record.opData(deepCopyOps);
fBoundingHierarchy = record.fBoundingHierarchy;
fStateTree = record.fStateTree;
SkSafeRef(fBoundingHierarchy);
SkSafeRef(fStateTree);
+ fContentInfo.set(record.fContentInfo);
if (NULL != fBoundingHierarchy) {
fBoundingHierarchy->flushDeferredInserts();
@@ -166,7 +156,8 @@ SkPicturePlayback::SkPicturePlayback(const SkPicture* picture,
#endif
}
-SkPicturePlayback::SkPicturePlayback(const SkPicture* picture, const SkPicturePlayback& src,
+SkPicturePlayback::SkPicturePlayback(const SkPicture* picture,
+ const SkPicturePlayback& src,
SkPictCopyInfo* deepCopyInfo)
: fPicture(picture)
, fInfo(src.fInfo) {
@@ -178,6 +169,7 @@ SkPicturePlayback::SkPicturePlayback(const SkPicture* picture, const SkPicturePl
fBoundingHierarchy = src.fBoundingHierarchy;
fStateTree = src.fStateTree;
+ fContentInfo.set(src.fContentInfo);
SkSafeRef(fBoundingHierarchy);
SkSafeRef(fStateTree);
@@ -1335,6 +1327,30 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
// this->dumpSize();
}
+
+#if SK_SUPPORT_GPU
+bool SkPicturePlayback::suitableForGpuRasterization(GrContext* context, const char **reason) const {
+ // TODO: the heuristic used here needs to be refined
+ static const int kNumPaintWithPathEffectUsesTol = 1;
+ static const int kNumAAConcavePaths = 5;
+
+ SkASSERT(fContentInfo.numAAHairlineConcavePaths() <= fContentInfo.numAAConcavePaths());
+
+ bool ret = fContentInfo.numPaintWithPathEffectUses() < kNumPaintWithPathEffectUsesTol &&
+ (fContentInfo.numAAConcavePaths() - fContentInfo.numAAHairlineConcavePaths())
+ < kNumAAConcavePaths;
+ if (!ret && NULL != reason) {
+ if (fContentInfo.numPaintWithPathEffectUses() >= kNumPaintWithPathEffectUsesTol)
+ *reason = "Too many path effects.";
+ else if ((fContentInfo.numAAConcavePaths() - fContentInfo.numAAHairlineConcavePaths())
+ >= kNumAAConcavePaths)
+ *reason = "Too many anti-aliased concave paths.";
+ else
+ *reason = "Unknown reason for GPU unsuitability.";
+ }
+ return ret;
+}
+#endif
///////////////////////////////////////////////////////////////////////////////
#ifdef SK_DEBUG_SIZE
« no previous file with comments | « src/core/SkPicturePlayback.h ('k') | src/core/SkPictureRecord.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698