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

Unified Diff: src/gpu/GrDrawTarget.cpp

Issue 749903003: some cleanup around GrGpu/GrDrawTarget copySurface (Closed) Base URL: https://skia.googlesource.com/skia.git@isSameAs
Patch Set: fix regression Created 6 years, 1 month 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 | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrGpu.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDrawTarget.cpp
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index bbf3eca05b4366b1de8727cf5a1b4963dc9f7556..9ac2d6a3b93e9d39123933760e74cbd0b19d0906 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -921,17 +921,20 @@ bool GrDrawTarget::copySurface(GrSurface* dst,
dstPoint,
&clippedSrcRect,
&clippedDstPoint)) {
- SkASSERT(GrDrawTarget::canCopySurface(dst, src, srcRect, dstPoint));
return true;
}
- if (!GrDrawTarget::canCopySurface(dst, src, clippedSrcRect, clippedDstPoint)) {
- return false;
+ if (this->onCopySurface(dst, src, clippedSrcRect, clippedDstPoint)) {
+ return true;
}
GrRenderTarget* rt = dst->asRenderTarget();
GrTexture* tex = src->asTexture();
+ if ((dst == src) || !rt || !tex) {
+ return false;
+ }
+
GrDrawState drawState;
drawState.setRenderTarget(rt);
SkMatrix matrix;
@@ -965,7 +968,13 @@ bool GrDrawTarget::canCopySurface(const GrSurface* dst,
&clippedDstPoint)) {
return true;
}
+ return this->internalCanCopySurface(dst, src, clippedSrcRect, clippedDstPoint);
+}
+bool GrDrawTarget::internalCanCopySurface(const GrSurface* dst,
+ const GrSurface* src,
+ const SkIRect& clippedSrcRect,
+ const SkIPoint& clippedDstPoint) {
// Check that the read/write rects are contained within the src/dst bounds.
SkASSERT(!clippedSrcRect.isEmpty());
SkASSERT(SkIRect::MakeWH(src->width(), src->height()).contains(clippedSrcRect));
@@ -973,14 +982,9 @@ bool GrDrawTarget::canCopySurface(const GrSurface* dst,
SkASSERT(clippedDstPoint.fX + clippedSrcRect.width() <= dst->width() &&
clippedDstPoint.fY + clippedSrcRect.height() <= dst->height());
- return (dst != src) && dst->asRenderTarget() && src->asTexture();
-}
-
-void GrDrawTarget::initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) {
- // Make the dst of the copy be a render target because the default copySurface draws to the dst.
- desc->fOrigin = kDefault_GrSurfaceOrigin;
- desc->fFlags = kRenderTarget_GrSurfaceFlag | kNoStencil_GrSurfaceFlag;
- desc->fConfig = src->config();
+ // The base class can do it as a draw or the subclass may be able to handle it.
+ return ((dst != src) && dst->asRenderTarget() && src->asTexture()) ||
+ this->onCanCopySurface(dst, src, clippedSrcRect, clippedDstPoint);
}
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrGpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698