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

Unified Diff: src/core/SkPicture.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/SkBBoxRecord.h ('k') | src/core/SkPicturePlayback.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 7120f611791d1632b7dc2ccb2c800d44da868756..9b7177870dad9a2beb8a9c61a0640966a34e9ddd 100644
--- a/src/core/SkPicture.cpp
+++ b/src/core/SkPicture.cpp
@@ -130,26 +130,24 @@ SkPicture::SkPicture()
fWidth = fHeight = 0;
}
-// This method makes a SkPicturePlayback object from an in-progress recording.
-// Unfortunately, it does not include the restoreToCount of a real endRecording
-// call.
-SkPicturePlayback* SkPicture::FakeEndRecording(const SkPicture* resourceSrc,
- const SkPictureRecord& record) {
- SkPictInfo info;
- resourceSrc->createHeader(&info);
+SkPicture::SkPicture(int width, int height,
+ SkPictureRecord& record,
+ bool deepCopyOps)
+ : fWidth(width)
+ , fHeight(height)
+ , fAccelData(NULL) {
+ this->needsNewGenID();
+
+ fPathHeap.reset(SkSafeRef(record.pathHeap()));
- // FakeEndRecording is only called from partialReplay. For that use case
- // we cannot be certain that the next call to SkWriter32::overwriteTAt
- // will be preceded by an append (i.e., that the required copy on write
- // will occur). In this case just force a deep copy of the operations.
- const bool deepCopyOps = true;
- return SkNEW_ARGS(SkPicturePlayback, (resourceSrc, record, info, deepCopyOps));
+ SkPictInfo info;
+ this->createHeader(&info);
+ fPlayback = SkNEW_ARGS(SkPicturePlayback, (this, record, info, deepCopyOps));
}
SkPicture::SkPicture(const SkPicture& src)
: INHERITED()
- , fAccelData(NULL)
- , fContentInfo(src.fContentInfo) {
+ , fAccelData(NULL) {
this->needsNewGenID();
fWidth = src.fWidth;
fHeight = src.fHeight;
@@ -209,7 +207,6 @@ void SkPicture::swap(SkPicture& other) {
SkTSwap(fWidth, other.fWidth);
SkTSwap(fHeight, other.fHeight);
fPathHeap.swap(&other.fPathHeap);
- fContentInfo.swap(&other.fContentInfo);
}
SkPicture* SkPicture::clone() const {
@@ -228,7 +225,6 @@ void SkPicture::clone(SkPicture* pictures, int count) const {
clone->fWidth = fWidth;
clone->fHeight = fHeight;
SkDELETE(clone->fPlayback);
- clone->fContentInfo.set(fContentInfo);
/* We want to copy the src's playback. However, if that hasn't been built
yet, we need to fake a call to endRecording() without actually calling
@@ -524,23 +520,14 @@ void SkPicture::flatten(SkWriteBuffer& buffer) const {
#if SK_SUPPORT_GPU
bool SkPicture::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(this->numAAHairlineConcavePaths() <= this->numAAConcavePaths());
-
- bool ret = this->numPaintWithPathEffectUses() < kNumPaintWithPathEffectUsesTol &&
- (this->numAAConcavePaths()-this->numAAHairlineConcavePaths()) < kNumAAConcavePaths;
- if (!ret && reason) {
- if (this->numPaintWithPathEffectUses() >= kNumPaintWithPathEffectUsesTol)
- *reason = "Too many path effects.";
- else if ((this->numAAConcavePaths()-this->numAAHairlineConcavePaths()) >= kNumAAConcavePaths)
- *reason = "Too many anti-aliased concave paths.";
- else
- *reason = "Unknown reason for GPU unsuitability.";
+ if (NULL == fPlayback) {
+ if (NULL != reason) {
+ *reason = "Missing playback object.";
+ }
+ return false;
}
- return ret;
+
+ return fPlayback->suitableForGpuRasterization(context, reason);
}
#endif
« no previous file with comments | « src/core/SkBBoxRecord.h ('k') | src/core/SkPicturePlayback.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698