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

Unified Diff: src/core/SkCanvas.cpp

Issue 2145343005: Recast draw_filter_into_device as drawDevice (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix bug Created 4 years, 5 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/SkCanvas.h ('k') | src/gpu/SkGpuDevice.cpp » ('j') | 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 1999f3109fb8c907509518dfe6fd6b8062b92ac7..b434c5863e6dec8ce3448111477a3aed41cf99a9 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1146,40 +1146,24 @@ int SkCanvas::saveLayer(const SaveLayerRec& origRec) {
return this->getSaveCount() - 1;
}
-static void draw_filter_into_device(SkBaseDevice* src, const SkImageFilter* filter,
- SkBaseDevice* dst, const SkMatrix& ctm) {
-
- SkBitmap srcBM;
-
-#if SK_SUPPORT_GPU
- // TODO: remove this virtual usage of accessRenderTarget! It is preventing
- // removal of the virtual on SkBaseDevice.
- GrRenderTarget* srcRT = src->accessRenderTarget();
- if (srcRT && !srcRT->asTexture() && dst->accessRenderTarget()) {
- // When both the src & the dst are on the gpu but the src doesn't have a texture,
- // we create a temporary texture for the draw.
- // TODO: we should actually only copy the portion of the source needed to apply the image
- // filter
- GrContext* context = srcRT->getContext();
- SkAutoTUnref<GrTexture> tex(context->textureProvider()->createTexture(srcRT->desc(),
- SkBudgeted::kYes));
-
- context->copySurface(tex, srcRT);
-
- GrWrapTextureInBitmap(tex, src->width(), src->height(), src->isOpaque(), &srcBM);
- } else
-#endif
- {
- srcBM = src->accessBitmap(false);
- }
-
- SkCanvas c(dst);
+void SkCanvas::DrawDeviceWithFilter(SkBaseDevice* src, const SkImageFilter* filter,
+ SkBaseDevice* dst, const SkMatrix& ctm,
+ const SkClipStack* clipStack) {
+ SkDraw draw;
+ SkRasterClip rc;
+ rc.setRect(SkIRect::MakeWH(dst->width(), dst->height()));
+ draw.fMatrix = &SkMatrix::I();
+ draw.fRC = &rc;
+ draw.fClipStack = clipStack;
+ draw.fDevice = dst;
SkPaint p;
p.setImageFilter(filter->makeWithLocalMatrix(ctm));
- const SkScalar x = SkIntToScalar(src->getOrigin().x());
- const SkScalar y = SkIntToScalar(src->getOrigin().y());
- c.drawBitmap(srcBM, x, y, &p);
+
+ dst->drawDevice(draw, src,
+ src->getOrigin().x() - dst->getOrigin().x(),
+ src->getOrigin().y() - dst->getOrigin().y(),
+ p);
}
static SkImageInfo make_layer_info(const SkImageInfo& prev, int w, int h, bool isOpaque,
@@ -1294,15 +1278,16 @@ void SkCanvas::internalSaveLayer(const SaveLayerRec& rec, SaveLayerStrategy stra
}
newDevice->setOrigin(ir.fLeft, ir.fTop);
- if (rec.fBackdrop) {
- draw_filter_into_device(priorDevice, rec.fBackdrop, newDevice, fMCRec->fMatrix);
- }
-
DeviceCM* layer = new DeviceCM(newDevice, paint, this, fConservativeRasterClip, stashedMatrix);
layer->fNext = fMCRec->fTopLayer;
fMCRec->fLayer = layer;
fMCRec->fTopLayer = layer; // this field is NOT an owner of layer
+
+ if (rec.fBackdrop) {
+ DrawDeviceWithFilter(priorDevice, rec.fBackdrop, newDevice,
+ fMCRec->fMatrix, this->getClipStack());
+ }
}
int SkCanvas::saveLayerAlpha(const SkRect* bounds, U8CPU alpha) {
« no previous file with comments | « include/core/SkCanvas.h ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698