Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(376)

Unified Diff: src/gpu/GrContext.cpp

Issue 1684313002: Make copySurface work for texture dsts, return a bool, & add unit test. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: try again Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/gpu/GrDrawContext.h ('k') | src/gpu/GrDrawContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « include/gpu/GrDrawContext.h ('k') | src/gpu/GrDrawContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698