Change GrContext::copyTexture to go through GrDrawTarget
BUG=crbug.com/415100
R=bsalomon@google.com, robertphillips@google.com
Author: junov@chromium.org
Review URL: https://codereview.chromium.org/607993002
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 42b884b..ad1b4c4 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -1576,16 +1576,6 @@
}
ASSERT_OWNED_RESOURCE(src);
-
- if (src->hasPendingWrite() || dst->hasPendingIO()) {
- this->flush();
- }
-
- GrDrawTarget::AutoStateRestore asr(fGpu, GrDrawTarget::kReset_ASRInit);
- GrDrawState* drawState = fGpu->drawState();
- drawState->setRenderTarget(dst);
- SkMatrix sampleM;
- sampleM.setIDiv(src->width(), src->height());
SkIRect srcRect = SkIRect::MakeWH(dst->width(), dst->height());
if (topLeft) {
srcRect.offset(*topLeft);
@@ -1594,10 +1584,14 @@
if (!srcRect.intersect(srcBounds)) {
return;
}
- sampleM.preTranslate(SkIntToScalar(srcRect.fLeft), SkIntToScalar(srcRect.fTop));
- drawState->addColorTextureProcessor(src, sampleM);
- SkRect dstR = SkRect::MakeWH(SkIntToScalar(srcRect.width()), SkIntToScalar(srcRect.height()));
- fGpu->drawSimpleRect(dstR);
+
+ GrDrawTarget* target = this->prepareToDraw(NULL, BUFFERED_DRAW, NULL, NULL);
+ if (NULL == target) {
+ return;
+ }
+ SkIPoint dstPoint;
+ dstPoint.setZero();
+ target->copySurface(dst, src, srcRect, dstPoint);
}
bool GrContext::writeRenderTargetPixels(GrRenderTarget* target,