Remove create function in proxyProvider that takes a raster SkImage.
Instead in proxyProvider we just have a create a bitmap call which
does no special fallback or logic. All the callers now go through
GrBitmapTextureMaker which handles and special fallbacks or caching
support that we need.
Change-Id: I71bb896cc78f64f9d6d54b54af2490d48e0f5af5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/266842
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/ops/GrShadowRRectOp.cpp b/src/gpu/ops/GrShadowRRectOp.cpp
index 1ae8b44..e9fab08 100644
--- a/src/gpu/ops/GrShadowRRectOp.cpp
+++ b/src/gpu/ops/GrShadowRRectOp.cpp
@@ -9,6 +9,7 @@
#include "include/private/GrRecordingContext.h"
#include "src/core/SkRRectPriv.h"
+#include "src/gpu/GrBitmapTextureMaker.h"
#include "src/gpu/GrDrawOpTest.h"
#include "src/gpu/GrMemoryPool.h"
#include "src/gpu/GrOpFlushState.h"
@@ -637,12 +638,14 @@
namespace GrShadowRRectOp {
-static sk_sp<GrTextureProxy> create_falloff_texture(GrProxyProvider* proxyProvider) {
+static sk_sp<GrTextureProxy> create_falloff_texture(GrRecordingContext* context) {
static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
GrUniqueKey key;
GrUniqueKey::Builder builder(&key, kDomain, 0, "Shadow Gaussian Falloff");
builder.finish();
+ GrProxyProvider* proxyProvider = context->priv().proxyProvider();
+
sk_sp<GrTextureProxy> falloffTexture = proxyProvider->findOrCreateProxyByUniqueKey(
key, GrColorType::kAlpha_8, kTopLeft_GrSurfaceOrigin);
if (!falloffTexture) {
@@ -650,23 +653,19 @@
static const size_t kRowBytes = kWidth*GrColorTypeBytesPerPixel(GrColorType::kAlpha_8);
SkImageInfo ii = SkImageInfo::MakeA8(kWidth, 1);
- sk_sp<SkData> data = SkData::MakeUninitialized(kRowBytes);
- if (!data) {
- return nullptr;
- }
- unsigned char* values = (unsigned char*) data->writable_data();
+ SkBitmap bitmap;
+ bitmap.allocPixels(ii, kRowBytes);
+
+ unsigned char* values = (unsigned char*) bitmap.getPixels();
for (int i = 0; i < 128; ++i) {
SkScalar d = SK_Scalar1 - i/SkIntToScalar(127);
values[i] = SkScalarRoundToInt((SkScalarExp(-4*d*d) - 0.018f)*255);
}
+ bitmap.setImmutable();
- sk_sp<SkImage> img = SkImage::MakeRasterData(ii, std::move(data), kRowBytes);
- if (!img) {
- return nullptr;
- }
+ GrBitmapTextureMaker maker(context, bitmap);
+ std::tie(falloffTexture, std::ignore) = maker.refTextureProxy(GrMipMapped::kNo);
- falloffTexture = proxyProvider->createTextureProxy(std::move(img), 1, SkBudgeted::kYes,
- SkBackingFit::kExact);
if (!falloffTexture) {
return nullptr;
}
@@ -688,7 +687,7 @@
// Shadow rrect ops only handle simple circular rrects.
SkASSERT(viewMatrix.isSimilarity() && SkRRectPriv::EqualRadii(rrect));
- sk_sp<GrTextureProxy> falloffTexture = create_falloff_texture(context->priv().proxyProvider());
+ sk_sp<GrTextureProxy> falloffTexture = create_falloff_texture(context);
if (!falloffTexture) {
return nullptr;
}