diff options
author | Robert Phillips <robertphillips@google.com> | 2017-01-30 08:06:27 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-01-30 13:40:15 +0000 |
commit | 40fd7c94c24bb30d888c3d85a79cbb96c7fbf800 (patch) | |
tree | 075e886c01de864ba982910f1854f47ba1ae95d8 /gm/texturedomaineffect.cpp | |
parent | 55b72530fedeb58154635531751a8730982fbf2a (diff) |
Push GrTextureProxy down to more effects
Change-Id: Ie3f32a88f25af082c25bc6daf3fe24e303e80f9e
Reviewed-on: https://skia-review.googlesource.com/7616
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'gm/texturedomaineffect.cpp')
-rw-r--r-- | gm/texturedomaineffect.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp index 0bebd8c97d..d5d98d556a 100644 --- a/gm/texturedomaineffect.cpp +++ b/gm/texturedomaineffect.cpp @@ -43,7 +43,10 @@ protected: } void onOnceBeforeDraw() override { - fBmp.allocN32Pixels(kTargetWidth, kTargetHeight); + // TODO: do this with surfaces & images and gpu backend + SkImageInfo ii = SkImageInfo::Make(kTargetWidth, kTargetHeight, kN32_SkColorType, + kPremul_SkAlphaType); + fBmp.allocPixels(ii); SkCanvas canvas(fBmp); canvas.clear(0x00000000); SkPaint paint; @@ -82,9 +85,17 @@ protected: return; } - sk_sp<GrTexture> texture( - GrRefCachedBitmapTexture(context, fBmp, GrSamplerParams::ClampNoFilter(), nullptr)); - if (!texture) { + GrSurfaceDesc desc; + desc.fWidth = fBmp.width(); + desc.fHeight = fBmp.height(); + desc.fConfig = SkImageInfo2GrPixelConfig(fBmp.info(), *context->caps()); + + sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeDeferred(*context->caps(), + context->textureProvider(), + desc, SkBudgeted::kYes, + fBmp.getPixels(), + fBmp.rowBytes())); + if (!proxy || !proxy->asTextureProxy()) { return; } @@ -92,14 +103,12 @@ protected: textureMatrices.push_back() = SkMatrix::I(); textureMatrices.push_back() = SkMatrix::MakeScale(1.5f, 0.85f); textureMatrices.push_back(); - textureMatrices.back().setRotate(45.f, texture->width() / 2.f, texture->height() / 2.f); + textureMatrices.back().setRotate(45.f, proxy->width() / 2.f, proxy->height() / 2.f); const SkIRect texelDomains[] = { fBmp.bounds(), - SkIRect::MakeXYWH(fBmp.width() / 4, - fBmp.height() / 4, - fBmp.width() / 2, - fBmp.height() / 2), + SkIRect::MakeXYWH(fBmp.width() / 4, fBmp.height() / 4, + fBmp.width() / 2, fBmp.height() / 2), }; SkRect renderRect = SkRect::Make(fBmp.bounds()); @@ -115,7 +124,8 @@ protected: grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc)); sk_sp<GrFragmentProcessor> fp( GrTextureDomainEffect::Make( - texture.get(), nullptr, textureMatrices[tm], + context, sk_ref_sp(proxy->asTextureProxy()), + nullptr, textureMatrices[tm], GrTextureDomain::MakeTexelDomainForMode(texelDomains[d], mode), mode, GrSamplerParams::kNone_FilterMode)); |