diff options
author | robertphillips <robertphillips@google.com> | 2014-09-18 08:01:23 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-18 08:01:23 -0700 |
commit | a0537deca24abc2713e72f61e9cec14bdcc703d0 (patch) | |
tree | 49d3dc40f0a246b62c1fb75d915181078dd9061d /src | |
parent | 53d2562006ee371222963750009a706cfd1a94f7 (diff) |
Copy layer-hoisting related SkPaints
This is intended to disconnect the lifetimes of the optimization data, cached layers and replacement objects.
Note that the optimization data already makes a copy of the paint in the SkPicture. Additionally the replacement object will probably go away at some point.
R=bsalomon@google.com
Author: robertphillips@google.com
Review URL: https://codereview.chromium.org/579843002
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrLayerCache.h | 5 | ||||
-rw-r--r-- | src/gpu/GrRecordReplaceDraw.cpp | 1 | ||||
-rw-r--r-- | src/gpu/GrRecordReplaceDraw.h | 2 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 5 |
4 files changed, 7 insertions, 6 deletions
diff --git a/src/gpu/GrLayerCache.h b/src/gpu/GrLayerCache.h index 1fb4c1001c..38d4d9b500 100644 --- a/src/gpu/GrLayerCache.h +++ b/src/gpu/GrLayerCache.h @@ -101,7 +101,7 @@ public: const SkIPoint& offset, const SkMatrix& ctm, const SkPaint* paint) : fKey(pictureID, start, stop, offset, ctm) - , fPaint(paint) + , fPaint(paint ? SkNEW_ARGS(SkPaint, (*paint)) : NULL) , fTexture(NULL) , fRect(GrIRect16::MakeEmpty()) , fPlot(NULL) @@ -111,6 +111,7 @@ public: ~GrCachedLayer() { SkSafeUnref(fTexture); + SkDELETE(fPaint); } uint32_t pictureID() const { return fKey.pictureID(); } @@ -145,7 +146,7 @@ private: const Key fKey; // The paint used when dropping the layer down into the owning canvas. - // Can be NULL. + // Can be NULL. This class makes a copy for itself. const SkPaint* fPaint; // fTexture is a ref on the atlasing texture for atlased layers and a diff --git a/src/gpu/GrRecordReplaceDraw.cpp b/src/gpu/GrRecordReplaceDraw.cpp index b53f003904..932e5be6c4 100644 --- a/src/gpu/GrRecordReplaceDraw.cpp +++ b/src/gpu/GrRecordReplaceDraw.cpp @@ -17,6 +17,7 @@ GrReplacements::ReplacementInfo* GrReplacements::push() { void GrReplacements::freeAll() { for (int i = 0; i < fReplacements.count(); ++i) { fReplacements[i].fImage->unref(); + SkDELETE(fReplacements[i].fPaint); } fReplacements.reset(); } diff --git a/src/gpu/GrRecordReplaceDraw.h b/src/gpu/GrRecordReplaceDraw.h index f59e44883e..3ba43dc2f0 100644 --- a/src/gpu/GrRecordReplaceDraw.h +++ b/src/gpu/GrRecordReplaceDraw.h @@ -30,7 +30,7 @@ public: unsigned fStop; SkIPoint fPos; SkImage* fImage; // Owns a ref - const SkPaint* fPaint; // Note: this object doesn't own the paint + const SkPaint* fPaint; // Owned by this object SkIRect fSrcRect; }; diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 14643adbdb..25ab12243d 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -170,7 +170,7 @@ SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo SkColorType ct = origInfo.colorType(); SkAlphaType at = origInfo.alphaType(); - // TODO: perhas we can loosen this check now that colortype is more detailed + // TODO: perhaps we can loosen this check now that colortype is more detailed // e.g. can we support both RGBA and BGRA here? if (kRGB_565_SkColorType == ct) { at = kOpaque_SkAlphaType; // force this setting @@ -1860,8 +1860,7 @@ static void convert_layers_to_replacements(const SkTDArray<GrCachedLayer*>& laye &bm); layerInfo->fImage = SkImage::NewTexture(bm); - // TODO: copy this? - layerInfo->fPaint = layers[i]->paint(); + layerInfo->fPaint = layers[i]->paint() ? SkNEW_ARGS(SkPaint, (*layers[i]->paint())) : NULL; layerInfo->fSrcRect = SkIRect::MakeXYWH(layers[i]->rect().fLeft, layers[i]->rect().fTop, |