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) { |