From 293d696fcfb9f1c83019c4b15c4864cd6649ed78 Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Tue, 13 Dec 2016 18:48:08 +0000 Subject: Revert "Add a deferred copy surface" This reverts commit 4431de6af930a8638c194b072558ea3a4b79d908. Reason for revert: ANGLE errors (at the very least) Original change's description: > 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 > Reviewed-by: Robert Phillips > Commit-Queue: Robert Phillips > TBR=bsalomon@google.com,robertphillips@google.com,brianosman@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I61408d9e306b9b1ab32f93ab086e95184e12857f Reviewed-on: https://skia-review.googlesource.com/5938 Commit-Queue: Robert Phillips Reviewed-by: Robert Phillips --- gm/image_pict.cpp | 45 +++++++++++---------------------------------- 1 file changed, 11 insertions(+), 34 deletions(-) (limited to 'gm/image_pict.cpp') diff --git a/gm/image_pict.cpp b/gm/image_pict.cpp index aa28249939..3a84905a9b 100644 --- a/gm/image_pict.cpp +++ b/gm/image_pict.cpp @@ -14,11 +14,7 @@ #if SK_SUPPORT_GPU #include "GrContext.h" -#include "GrContextPriv.h" -#include "GrSurfaceContext.h" -#include "GrSurfaceProxy.h" #include "GrTexture.h" -#include "GrTextureProxy.h" #include "../src/image/SkImage_Gpu.h" #endif @@ -213,15 +209,15 @@ class TextureGenerator : public SkImageGenerator { public: TextureGenerator(GrContext* ctx, const SkImageInfo& info, SkPicture* pic) : SkImageGenerator(info) - , fCtx(SkRef(ctx)) { - - sk_sp surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info)); + , fCtx(SkRef(ctx)) + { + auto surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info)); if (surface) { surface->getCanvas()->clear(0); surface->getCanvas()->translate(-100, -100); surface->getCanvas()->drawPicture(pic); sk_sp image(surface->makeImageSnapshot()); - fProxy = GrSurfaceProxy::MakeWrapped(sk_ref_sp(as_IB(image)->peekTexture())); + fTexture.reset(SkRef(as_IB(image)->peekTexture())); } } protected: @@ -230,41 +226,22 @@ protected: SkASSERT(ctx == fCtx.get()); } - if (!fProxy) { + if (!fTexture) { return nullptr; } - if (subset.fLeft == 0 && subset.fTop == 0 && - subset.fRight == fProxy->width() && subset.fBottom == fProxy->height()) { - return SkSafeRef(fProxy->instantiate(fCtx->textureProvider())->asTexture()); - } - // need to copy the subset into a new texture - GrSurfaceDesc desc = fProxy->desc(); + GrSurfaceDesc desc = fTexture->desc(); desc.fWidth = subset.width(); desc.fHeight = subset.height(); - sk_sp dstContext(fCtx->contextPriv().makeDeferredSurfaceContext( - desc, - SkBudgeted::kNo)); - if (!dstContext) { - return nullptr; - } - - if (!dstContext->copy(fProxy.get(), subset, SkIPoint::Make(0, 0))) { - return nullptr; - } - - GrSurface* dstSurf = dstContext->asDeferredSurface()->instantiate(fCtx->textureProvider()); - if (!dstSurf) { - return nullptr; - } - - return SkRef(dstSurf->asTexture()); + GrTexture* dst = fCtx->textureProvider()->createTexture(desc, SkBudgeted::kNo); + fCtx->copySurface(dst, fTexture.get(), subset, SkIPoint::Make(0, 0)); + return dst; } private: - sk_sp fCtx; - sk_sp fProxy; + sk_sp fCtx; + sk_sp fTexture; }; static SkImageGenerator* make_tex_generator(GrContext* ctx, SkPicture* pic) { const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); -- cgit v1.2.3