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

Unified Diff: src/core/SkCanvas.cpp

Issue 1531493002: Avoid pixel GPU readback in saveLayerWithPickup (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Quiet compiler complaints 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
« no previous file with comments | « no previous file | src/gpu/gl/GrGLDefines.h » ('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 1d37e584193e83fa0979117b964cc6195ba15d77..814375687a743b7a897a88a2a6ce2f1682075359 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -37,7 +37,9 @@
#include <new>
#if SK_SUPPORT_GPU
+#include "GrContext.h"
#include "GrRenderTarget.h"
+#include "SkGr.h"
#endif
/*
@@ -1145,6 +1147,35 @@ 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) {
+
+ SkBitmap srcBM;
+
+#if SK_SUPPORT_GPU
+ 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(), true));
+
+ context->copySurface(tex, srcRT);
+
+ GrWrapTextureInBitmap(tex, src->width(), src->height(), src->isOpaque(), &srcBM);
+ } else
+#endif
+ {
+ srcBM = src->accessBitmap(false);
+ }
+
+ SkCanvas c(dst);
+
+ SkPaint p;
+ p.setImageFilter(filter);
+ c.drawBitmap(srcBM, 0, 0, &p);
+}
void SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags flags,
SaveLayerStrategy strategy) {
@@ -1210,6 +1241,11 @@ void SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, Sav
}
device->setOrigin(ir.fLeft, ir.fTop);
+
+ if (0) {
+ draw_filter_into_device(fMCRec->fTopLayer->fDevice, nullptr, device);
+ }
+
DeviceCM* layer =
new DeviceCM(device, paint, this, fConservativeRasterClip, forceSpriteOnRestore);
device->unref();
« no previous file with comments | « no previous file | src/gpu/gl/GrGLDefines.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698