aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrDrawTarget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/GrDrawTarget.cpp')
-rw-r--r--src/gpu/GrDrawTarget.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index bbf3eca05b..9ac2d6a3b9 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);
}
///////////////////////////////////////////////////////////////////////////////