aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrDrawTarget.cpp
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2014-11-03 14:16:35 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-03 14:16:35 -0800
commita702415d9e80f5631181143c293498de924e8ae4 (patch)
treeb5e85c1f6744caddb9a7ea62f02ba3a77520d5d9 /src/gpu/GrDrawTarget.cpp
parentada68ef2dc986478288a8b8ad867fd3aca431162 (diff)
Temporary fix to remove drawrect call from GpuGL
Diffstat (limited to 'src/gpu/GrDrawTarget.cpp')
-rw-r--r--src/gpu/GrDrawTarget.cpp67
1 files changed, 26 insertions, 41 deletions
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 2f25272e31..cd422ea525 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -916,13 +916,30 @@ bool GrDrawTarget::copySurface(GrSurface* dst,
dstPoint,
&clippedSrcRect,
&clippedDstPoint)) {
- SkASSERT(this->canCopySurface(dst, src, srcRect, dstPoint));
+ SkASSERT(GrDrawTarget::canCopySurface(dst, src, srcRect, dstPoint));
return true;
}
- bool result = this->onCopySurface(dst, src, clippedSrcRect, clippedDstPoint);
- SkASSERT(result == this->canCopySurface(dst, src, clippedSrcRect, clippedDstPoint));
- return result;
+ if (!GrDrawTarget::canCopySurface(dst, src, clippedSrcRect, clippedDstPoint)) {
+ return false;
+ }
+
+ GrRenderTarget* rt = dst->asRenderTarget();
+ GrTexture* tex = src->asTexture();
+
+ GrDrawTarget::AutoStateRestore asr(this, kReset_ASRInit);
+ this->drawState()->setRenderTarget(rt);
+ SkMatrix matrix;
+ matrix.setTranslate(SkIntToScalar(clippedSrcRect.fLeft - clippedDstPoint.fX),
+ SkIntToScalar(clippedSrcRect.fTop - clippedDstPoint.fY));
+ matrix.postIDiv(tex->width(), tex->height());
+ this->drawState()->addColorTextureProcessor(tex, matrix);
+ SkIRect dstRect = SkIRect::MakeXYWH(clippedDstPoint.fX,
+ clippedDstPoint.fY,
+ clippedSrcRect.width(),
+ clippedSrcRect.height());
+ this->drawSimpleRect(dstRect);
+ return true;
}
bool GrDrawTarget::canCopySurface(GrSurface* dst,
@@ -943,49 +960,17 @@ bool GrDrawTarget::canCopySurface(GrSurface* dst,
&clippedDstPoint)) {
return true;
}
- return this->onCanCopySurface(dst, src, clippedSrcRect, clippedDstPoint);
-}
-bool GrDrawTarget::onCanCopySurface(GrSurface* dst,
- GrSurface* src,
- const SkIRect& srcRect,
- const SkIPoint& dstPoint) {
// Check that the read/write rects are contained within the src/dst bounds.
- SkASSERT(!srcRect.isEmpty());
- SkASSERT(SkIRect::MakeWH(src->width(), src->height()).contains(srcRect));
- SkASSERT(dstPoint.fX >= 0 && dstPoint.fY >= 0);
- SkASSERT(dstPoint.fX + srcRect.width() <= dst->width() &&
- dstPoint.fY + srcRect.height() <= dst->height());
+ SkASSERT(!clippedSrcRect.isEmpty());
+ SkASSERT(SkIRect::MakeWH(src->width(), src->height()).contains(clippedSrcRect));
+ SkASSERT(clippedDstPoint.fX >= 0 && clippedDstPoint.fY >= 0);
+ SkASSERT(clippedDstPoint.fX + clippedSrcRect.width() <= dst->width() &&
+ clippedDstPoint.fY + clippedSrcRect.height() <= dst->height());
return !dst->surfacePriv().isSameAs(src) && dst->asRenderTarget() && src->asTexture();
}
-bool GrDrawTarget::onCopySurface(GrSurface* dst,
- GrSurface* src,
- const SkIRect& srcRect,
- const SkIPoint& dstPoint) {
- if (!GrDrawTarget::onCanCopySurface(dst, src, srcRect, dstPoint)) {
- return false;
- }
-
- GrRenderTarget* rt = dst->asRenderTarget();
- GrTexture* tex = src->asTexture();
-
- GrDrawTarget::AutoStateRestore asr(this, kReset_ASRInit);
- this->drawState()->setRenderTarget(rt);
- SkMatrix matrix;
- matrix.setTranslate(SkIntToScalar(srcRect.fLeft - dstPoint.fX),
- SkIntToScalar(srcRect.fTop - dstPoint.fY));
- matrix.postIDiv(tex->width(), tex->height());
- this->drawState()->addColorTextureProcessor(tex, matrix);
- SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX,
- dstPoint.fY,
- srcRect.width(),
- srcRect.height());
- this->drawSimpleRect(dstRect);
- return true;
-}
-
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;