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

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: 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 6119c4ff2f9b771eb267a9812c6a60faef7a5048..13d1f7d7aa8467e78471e1c9f3b2cdba23913ea9 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1148,40 +1148,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,
@@ -1303,12 +1287,14 @@ void SkCanvas::internalSaveLayer(const SaveLayerRec& rec, SaveLayerStrategy stra
}
device->setOrigin(ir.fLeft, ir.fTop);
+ DeviceCM* layer = new DeviceCM(device, paint, this, fConservativeRasterClip,
+ forceSpriteOnRestore, stashedMatrix);
+
if (rec.fBackdrop) {
- draw_filter_into_device(fMCRec->fTopLayer->fDevice, rec.fBackdrop, device, fMCRec->fMatrix);
+ DrawDeviceWithFilter(this->getTopDevice(), rec.fBackdrop, device,
+ fMCRec->fMatrix, this->getClipStack());
}
- DeviceCM* layer = new DeviceCM(device, paint, this, fConservativeRasterClip,
- forceSpriteOnRestore, stashedMatrix);
device->unref();
layer->fNext = fMCRec->fTopLayer;
« 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