| 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);
|
| }
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|