aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrContext.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2016-12-13 15:29:42 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-12-13 22:01:58 +0000
commit398487a850431cf495330d4023607df5305a311f (patch)
tree7ab227c99eaab21554428f7a94e0c2df67be009a /src/gpu/GrContext.cpp
parent24f19780d1e76595c049d8cad4352de839cfc6b5 (diff)
Add a deferred copy surface (take 2)
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. This is a reland of https://skia-review.googlesource.com/c/5773/ (Add a deferred copy surface) Change-Id: Ide560f569aede5e622420dc2f30eef76357d69f4 Reviewed-on: https://skia-review.googlesource.com/5939 Reviewed-by: Brian Osman <brianosman@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrContext.cpp')
-rw-r--r--src/gpu/GrContext.cpp67
1 files changed, 29 insertions, 38 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index ff5b0266e6..2e66c0c404 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -541,43 +541,6 @@ void GrContext::prepareSurfaceForExternalIO(GrSurface* surface) {
fDrawingManager->prepareSurfaceForExternalIO(surface);
}
-bool GrContext::copySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRect,
- const SkIPoint& dstPoint) {
- ASSERT_SINGLE_OWNER
- RETURN_FALSE_IF_ABANDONED
- GR_AUDIT_TRAIL_AUTO_FRAME(&fAuditTrail, "GrContext::copySurface");
-
- if (!src || !dst) {
- return false;
- }
- ASSERT_OWNED_RESOURCE(src);
- ASSERT_OWNED_RESOURCE(dst);
-
- // We don't allow conversion between integer configs and float/fixed configs.
- if (GrPixelConfigIsSint(dst->config()) != GrPixelConfigIsSint(src->config())) {
- 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
-
- sk_sp<GrSurfaceContext> surfaceContext(
- this->contextPriv().makeWrappedSurfaceContext(sk_ref_sp(dst)));
-
- if (!surfaceContext) {
- return false;
- }
-
- if (!surfaceContext->copySurface(src, srcRect, dstPoint)) {
- return false;
- }
-
- return true;
-}
-
void GrContext::flushSurfaceWrites(GrSurface* surface) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
@@ -639,8 +602,36 @@ sk_sp<GrSurfaceContext> GrContextPriv::makeWrappedSurfaceContext(sk_sp<GrSurface
}
}
+sk_sp<GrSurfaceContext> GrContextPriv::makeDeferredSurfaceContext(const GrSurfaceDesc& dstDesc,
+ SkBudgeted isDstBudgeted) {
+
+ sk_sp<GrSurfaceProxy> proxy = GrSurfaceProxy::MakeDeferred(*fContext->caps(), dstDesc,
+ SkBackingFit::kExact, isDstBudgeted);
+
+ if (proxy->asRenderTargetProxy()) {
+ return this->drawingManager()->makeRenderTargetContext(std::move(proxy), nullptr, nullptr);
+ } else {
+ SkASSERT(proxy->asTextureProxy());
+ return this->drawingManager()->makeTextureContext(std::move(proxy));
+ }
+
+ return nullptr;
+}
+
+sk_sp<GrSurfaceContext> GrContextPriv::makeTestSurfaceContext(sk_sp<GrSurfaceProxy> proxy) {
+
+ if (proxy->asRenderTargetProxy()) {
+ return this->drawingManager()->makeRenderTargetContext(std::move(proxy), nullptr, nullptr);
+ } else {
+ SkASSERT(proxy->asTextureProxy());
+ return this->drawingManager()->makeTextureContext(std::move(proxy));
+ }
+
+ return nullptr;
+}
+
sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendTextureRenderTargetContext(
- const GrBackendTextureDesc& desc,
+ const GrBackendTextureDesc& desc,
sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps* props,
GrWrapOwnership ownership) {