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

Unified Diff: src/core/SkCanvas.cpp

Issue 1523053003: add backdrop option to SaveLayerRec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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
« samplecode/SampleLayers.cpp ('K') | « samplecode/SampleLayers.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkCanvas.cpp
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 1d37e584193e83fa0979117b964cc6195ba15d77..f35ebf3230dc781b63b8a6278d773d723d4ea4d1 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -480,7 +480,7 @@ public:
rawBounds = &apply_paint_to_bounds_sans_imagefilter(*fPaint, *rawBounds, &storage);
}
(void)canvas->internalSaveLayer(rawBounds, &tmp, SkCanvas::kARGB_ClipLayer_SaveFlag,
- SkCanvas::kFullLayer_SaveLayerStrategy);
+ SkCanvas::kFullLayer_SaveLayerStrategy, nullptr);
fTempLayerForImageFilter = true;
// we remove the imagefilter/xfermode inside doNext()
}
@@ -1121,12 +1121,18 @@ bool SkCanvas::clipRectBounds(const SkRect* bounds, SaveFlags flags,
}
int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint) {
+ return this->saveLayerWithPickup(bounds, paint, nullptr);
+}
+
+int SkCanvas::saveLayerWithPickup(const SkRect* bounds, const SkPaint* paint,
+ SkImageFilter* pickup) {
if (gIgnoreSaveLayerBounds) {
bounds = nullptr;
}
- SaveLayerStrategy strategy = this->willSaveLayer(bounds, paint, kARGB_ClipLayer_SaveFlag);
+ SaveFlags flags = kARGB_ClipLayer_SaveFlag;
+ SaveLayerStrategy strategy = this->willSaveLayer(bounds, paint, flags);
fSaveCount += 1;
- this->internalSaveLayer(bounds, paint, kARGB_ClipLayer_SaveFlag, strategy);
+ this->internalSaveLayer(bounds, paint, flags, strategy, pickup);
return this->getSaveCount() - 1;
}
@@ -1136,7 +1142,7 @@ int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags fl
}
SaveLayerStrategy strategy = this->willSaveLayer(bounds, paint, flags);
fSaveCount += 1;
- this->internalSaveLayer(bounds, paint, flags, strategy);
+ this->internalSaveLayer(bounds, paint, flags, strategy, nullptr);
return this->getSaveCount() - 1;
}
@@ -1145,9 +1151,17 @@ int SkCanvas::saveLayerPreserveLCDTextRequests(const SkRect* bounds, const SkPai
return this->saveLayer(bounds, paint, (SaveFlags)flags);
}
+static void draw_filter_into_device(SkBaseDevice* src, SkImageFilter* filter, SkBaseDevice* dst) {
+ SkCanvas c(dst);
+
+ const SkBitmap& srcBM = src->accessBitmap(false);
+ SkPaint p;
+ p.setImageFilter(filter);
+ c.drawBitmap(srcBM, 0, 0, &p);
+}
void SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags flags,
- SaveLayerStrategy strategy) {
+ SaveLayerStrategy strategy, SkImageFilter* pickup) {
#ifndef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
flags |= kClipToLayer_SaveFlag;
#endif
@@ -1208,8 +1222,12 @@ void SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, Sav
}
device = newDev;
}
-
device->setOrigin(ir.fLeft, ir.fTop);
+
+ if (pickup) {
+ draw_filter_into_device(fMCRec->fTopLayer->fDevice, pickup, device);
+ }
+
DeviceCM* layer =
new DeviceCM(device, paint, this, fConservativeRasterClip, forceSpriteOnRestore);
device->unref();
« samplecode/SampleLayers.cpp ('K') | « samplecode/SampleLayers.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698