Index: src/gpu/GrContext.cpp |
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp |
index 187a3ca37a7a1e416f83c0846c421c0ec49f3fe6..296dfb9e702736dab7e17bdf00f23d277f40e086 100644 |
--- a/src/gpu/GrContext.cpp |
+++ b/src/gpu/GrContext.cpp |
@@ -18,6 +18,7 @@ |
#include "SkConfig8888.h" |
#include "SkGrPriv.h" |
+#include "batches/GrCopySurfaceBatch.h" |
#include "effects/GrConfigConversionEffect.h" |
#include "text/GrTextBlobCache.h" |
@@ -509,34 +510,42 @@ void GrContext::prepareSurfaceForExternalIO(GrSurface* surface) { |
} |
} |
-void GrContext::copySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRect, |
- const SkIPoint& dstPoint, uint32_t pixelOpsFlags) { |
+bool GrContext::copySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRect, |
+ const SkIPoint& dstPoint) { |
ASSERT_SINGLE_OWNER |
- RETURN_IF_ABANDONED |
+ RETURN_FALSE_IF_ABANDONED |
GR_AUDIT_TRAIL_AUTO_FRAME(&fAuditTrail, "GrContext::copySurface"); |
if (!src || !dst) { |
- return; |
+ return false; |
} |
ASSERT_OWNED_RESOURCE(src); |
ASSERT_OWNED_RESOURCE(dst); |
- // Since we're going to the draw target and not GPU, no need to check kNoFlush |
- // here. |
if (!dst->asRenderTarget()) { |
- return; |
+ SkIRect clippedSrcRect; |
+ SkIPoint clippedDstPoint; |
+ if (!GrCopySurfaceBatch::ClipSrcRectAndDstPoint(dst, src, srcRect, dstPoint, |
+ &clippedSrcRect, &clippedDstPoint)) { |
+ return false; |
+ } |
+ // If we don't have an RT for the dst then we won't have a GrDrawContext to insert the |
+ // the copy surface into. In the future we plan to have a more limited Context type |
+ // (GrCopyContext?) that has the subset of GrDrawContext operations that should be |
+ // allowed on textures that aren't render targets. |
+ // For now we just flush any writes to the src and issue an immediate copy to the dst. |
+ src->flushWrites(); |
+ return fGpu->copySurface(dst, src, clippedSrcRect, clippedDstPoint); |
} |
- |
SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(dst->asRenderTarget())); |
if (!drawContext) { |
- return; |
+ return false; |
} |
- drawContext->copySurface(src, srcRect, dstPoint); |
- |
- if (kFlushWrites_PixelOp & pixelOpsFlags) { |
- this->flush(); |
+ if (!drawContext->copySurface(src, srcRect, dstPoint)) { |
+ return false; |
} |
+ return true; |
} |
void GrContext::flushSurfaceWrites(GrSurface* surface) { |