aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrTextureContext.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2016-12-13 09:01:40 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-12-13 17:57:13 +0000
commit4431de6af930a8638c194b072558ea3a4b79d908 (patch)
tree49a3f17bb0abc6fcb43d8c7ce58061e0bb9822a7 /src/gpu/GrTextureContext.cpp
parent36aa176d0d32f9cea3d1998fac3c295d31e1d596 (diff)
Add a deferred copy surface
This CL forces all GrSurface copies to go through a GrSurfaceContext (rather than GrContext). There is a bit of goofiness going on here until read/writePixels is also consolidated in GrSurfaceContext and a proxy-backed SkImage/SkSurface is added. Change-Id: Iab1867668d8146a766201158a251b9174438ee2b Reviewed-on: https://skia-review.googlesource.com/5773 Reviewed-by: Brian Osman <brianosman@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrTextureContext.cpp')
-rw-r--r--src/gpu/GrTextureContext.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/gpu/GrTextureContext.cpp b/src/gpu/GrTextureContext.cpp
index 22620fed0f..28240f8a79 100644
--- a/src/gpu/GrTextureContext.cpp
+++ b/src/gpu/GrTextureContext.cpp
@@ -24,8 +24,7 @@ GrTextureContext::GrTextureContext(GrContext* context,
: GrSurfaceContext(context, auditTrail, singleOwner)
, fDrawingManager(drawingMgr)
, fTextureProxy(std::move(textureProxy))
- , fOpList(SkSafeRef(fTextureProxy->getLastTextureOpList()))
-{
+ , fOpList(SkSafeRef(fTextureProxy->getLastTextureOpList())) {
SkDEBUGCODE(this->validate();)
}
@@ -56,12 +55,26 @@ GrTextureOpList* GrTextureContext::getOpList() {
return fOpList;
}
-bool GrTextureContext::copySurface(GrSurface* src, const SkIRect& srcRect,
- const SkIPoint& dstPoint) {
+// TODO: move this (and GrRenderTargetContext::copy) to GrSurfaceContext?
+bool GrTextureContext::onCopy(GrSurfaceProxy* srcProxy,
+ const SkIRect& srcRect,
+ const SkIPoint& dstPoint) {
ASSERT_SINGLE_OWNER
RETURN_FALSE_IF_ABANDONED
SkDEBUGCODE(this->validate();)
- GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrTextureContext::copySurface");
+ GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrTextureContext::copy");
+
+ // TODO: defer instantiation until flush time
+ sk_sp<GrSurface> src(sk_ref_sp(srcProxy->instantiate(fContext->textureProvider())));
+ if (!src) {
+ return false;
+ }
+
+#ifndef ENABLE_MDB
+ // We can't yet fully defer copies to textures, so GrTextureContext::copySurface will
+ // execute the copy immediately. Ensure the data is ready.
+ src->flushWrites();
+#endif
// TODO: this needs to be fixed up since it ends the deferrable of the GrTexture
sk_sp<GrTexture> tex(sk_ref_sp(fTextureProxy->instantiate(fContext->textureProvider())));
@@ -70,7 +83,7 @@ bool GrTextureContext::copySurface(GrSurface* src, const SkIRect& srcRect,
}
GrTextureOpList* opList = this->getOpList();
- bool result = opList->copySurface(tex.get(), src, srcRect, dstPoint);
+ bool result = opList->copySurface(tex.get(), src.get(), srcRect, dstPoint);
#ifndef ENABLE_MDB
GrOpFlushState flushState(fContext->getGpu(), nullptr);