aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/image_pict.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-03-03 11:10:18 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-03 17:40:52 +0000
commit4447b64a88ea141161fca772c2fec28b6141bbc3 (patch)
treefce75d30623892dfe7271acdd671623240302e10 /gm/image_pict.cpp
parent3c6d5b0daa8c9ff1137bb2ef9b00a712bb3a47c2 (diff)
Switch SkImageGenerator over to generating GrTextureProxies
It does not seem irrational for generateTexture to always receive a valid GrContext. lockAsBitmap can do as it pleases. This is split out of: https://skia-review.googlesource.com/c/8823/ (Remove GrFragmentProcessor-derived class' GrTexture-based ctors) Change-Id: I8aebc813a8a3a7d694b7369c2c9810e2164fe16e Reviewed-on: https://skia-review.googlesource.com/9191 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'gm/image_pict.cpp')
-rw-r--r--gm/image_pict.cpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/gm/image_pict.cpp b/gm/image_pict.cpp
index 387ceb8d41..1f273dc615 100644
--- a/gm/image_pict.cpp
+++ b/gm/image_pict.cpp
@@ -231,11 +231,10 @@ public:
}
}
protected:
- GrTexture* onGenerateTexture(GrContext* ctx, const SkImageInfo& info,
- const SkIPoint& origin) override {
- if (ctx) {
- SkASSERT(ctx == fCtx.get());
- }
+ sk_sp<GrTextureProxy> onGenerateTexture(GrContext* ctx, const SkImageInfo& info,
+ const SkIPoint& origin) override {
+ SkASSERT(ctx);
+ SkASSERT(ctx == fCtx.get());
if (!fProxy) {
return nullptr;
@@ -243,7 +242,7 @@ protected:
if (origin.fX == 0 && origin.fY == 0 &&
info.width() == fProxy->width() && info.height() == fProxy->height()) {
- return SkSafeRef(fProxy->instantiate(fCtx->textureProvider())->asTexture());
+ return fProxy;
}
// need to copy the subset into a new texture
@@ -266,17 +265,14 @@ protected:
return nullptr;
}
- GrSurface* dstSurf = dstContext->asSurfaceProxy()->instantiate(fCtx->textureProvider());
- if (!dstSurf) {
- return nullptr;
- }
-
- return SkRef(dstSurf->asTexture());
+ return dstContext->asTextureProxyRef();
}
+
private:
sk_sp<GrContext> fCtx;
- sk_sp<GrSurfaceProxy> fProxy;
+ sk_sp<GrTextureProxy> fProxy;
};
+
static std::unique_ptr<SkImageGenerator> make_tex_generator(GrContext* ctx, sk_sp<SkPicture> pic) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
@@ -340,7 +336,8 @@ protected:
static void draw_as_bitmap(SkCanvas* canvas, SkImageCacherator* cache, SkScalar x, SkScalar y) {
SkBitmap bitmap;
- cache->lockAsBitmap(&bitmap, nullptr, canvas->imageInfo().colorSpace());
+ cache->lockAsBitmap(canvas->getGrContext(), &bitmap, nullptr,
+ canvas->imageInfo().colorSpace());
canvas->drawBitmap(bitmap, x, y);
}