aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2016-12-14 12:04:46 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-12-14 12:05:06 +0000
commitd316e77c1e1967b439a9a6c11146c54e367bff71 (patch)
treefbf7d3740c39507cdb2aad0267c2d96cd3d98bec /gm
parent2e018f548d76b0688f9873c683cffc681fec40ec (diff)
Revert "Add a deferred copy surface (take 2)"
This reverts commit 398487a850431cf495330d4023607df5305a311f. Reason for revert: See if this is causing the roll failure Original change's description: > 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> > TBR=bsalomon@google.com,robertphillips@google.com,brianosman@google.com,reviews@skia.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I1ef40f0d5fb0bca62031f94f10eb18acd753e913 Reviewed-on: https://skia-review.googlesource.com/6024 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'gm')
-rw-r--r--gm/image_pict.cpp45
1 files changed, 11 insertions, 34 deletions
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<SkSurface> 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<SkImage> 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<GrSurfaceContext> 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<GrContext> fCtx;
- sk_sp<GrSurfaceProxy> fProxy;
+ sk_sp<GrContext> fCtx;
+ sk_sp<GrTexture> fTexture;
};
static SkImageGenerator* make_tex_generator(GrContext* ctx, SkPicture* pic) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);