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/effects/GrCircleBlurFragmentProcessor.fp b/src/gpu/effects/GrCircleBlurFragmentProcessor.fp
index a710b2d..d71e9d6 100644
--- a/src/gpu/effects/GrCircleBlurFragmentProcessor.fp
+++ b/src/gpu/effects/GrCircleBlurFragmentProcessor.fp
@@ -21,7 +21,7 @@
}
@make {
- static std::unique_ptr<GrFragmentProcessor> Make(GrProxyProvider*,
+ static std::unique_ptr<GrFragmentProcessor> Make(GrRecordingContext*,
const SkRect& circle, float sigma);
}
@@ -31,7 +31,11 @@
}
@cpp {
+ #include "include/gpu/GrContext.h"
+ #include "include/private/GrRecordingContext.h"
+ #include "src/gpu/GrBitmapTextureMaker.h"
#include "src/gpu/GrProxyProvider.h"
+ #include "src/gpu/GrRecordingContextPriv.h"
// Computes an unnormalized half kernel (right side). Returns the summation of all the half
// kernel values.
@@ -184,7 +188,7 @@
profile[profileWidth - 1] = 0;
}
- static sk_sp<GrTextureProxy> create_profile_texture(GrProxyProvider* proxyProvider,
+ static sk_sp<GrTextureProxy> create_profile_texture(GrRecordingContext* context,
const SkRect& circle,
float sigma,
float* solidRadius, float* textureRadius) {
@@ -226,6 +230,7 @@
builder[0] = sigmaToCircleRRatioFixed;
builder.finish();
+ GrProxyProvider* proxyProvider = context->priv().proxyProvider();
sk_sp<GrTextureProxy> blurProfile = proxyProvider->findOrCreateProxyByUniqueKey(
key, GrColorType::kAlpha_8, kTopLeft_GrSurfaceOrigin);
if (!blurProfile) {
@@ -246,10 +251,9 @@
}
bm.setImmutable();
- sk_sp<SkImage> image = SkImage::MakeFromBitmap(bm);
- blurProfile = proxyProvider->createTextureProxy(std::move(image), 1,
- SkBudgeted::kYes, SkBackingFit::kExact);
+ GrBitmapTextureMaker maker(context, bm);
+ std::tie(blurProfile, std::ignore) = maker.refTextureProxy(GrMipMapped::kNo);
if (!blurProfile) {
return nullptr;
}
@@ -260,10 +264,10 @@
}
std::unique_ptr<GrFragmentProcessor> GrCircleBlurFragmentProcessor::Make(
- GrProxyProvider* proxyProvider, const SkRect& circle, float sigma) {
+ GrRecordingContext* context, const SkRect& circle, float sigma) {
float solidRadius;
float textureRadius;
- sk_sp<GrTextureProxy> profile(create_profile_texture(proxyProvider, circle, sigma,
+ sk_sp<GrTextureProxy> profile(create_profile_texture(context, circle, sigma,
&solidRadius, &textureRadius));
if (!profile) {
return nullptr;
@@ -286,5 +290,5 @@
SkScalar wh = testData->fRandom->nextRangeScalar(100.f, 1000.f);
SkScalar sigma = testData->fRandom->nextRangeF(1.f,10.f);
SkRect circle = SkRect::MakeWH(wh, wh);
- return GrCircleBlurFragmentProcessor::Make(testData->proxyProvider(), circle, sigma);
+ return GrCircleBlurFragmentProcessor::Make(testData->context(), circle, sigma);
}
diff --git a/src/gpu/effects/GrConfigConversionEffect.fp b/src/gpu/effects/GrConfigConversionEffect.fp
index 0ff5b2d..ae4c26c 100644
--- a/src/gpu/effects/GrConfigConversionEffect.fp
+++ b/src/gpu/effects/GrConfigConversionEffect.fp
@@ -7,10 +7,10 @@
@header {
#include "include/gpu/GrContext.h"
+ #include "src/gpu/GrBitmapTextureMaker.h"
#include "src/gpu/GrClip.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrImageInfo.h"
- #include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrRenderTargetContext.h"
}
@@ -52,18 +52,16 @@
// draw
readRTC->discard();
- GrProxyProvider* proxyProvider = context->priv().proxyProvider();
-
- SkPixmap pixmap(ii, srcData, 4 * kSize);
-
// This function is only ever called if we are in a GrContext that has a GrGpu since we are
// calling read pixels here. Thus the pixel data will be uploaded immediately and we don't
// need to keep the pixel data alive in the proxy. Therefore the ReleaseProc is nullptr.
- sk_sp<SkImage> image = SkImage::MakeFromRaster(pixmap, nullptr, nullptr);
- sk_sp<GrTextureProxy> dataProxy = proxyProvider->createTextureProxy(std::move(image),
- 1,
- SkBudgeted::kYes,
- SkBackingFit::kExact);
+ SkBitmap bitmap;
+ bitmap.installPixels(ii, srcData, 4 * kSize);
+ bitmap.setImmutable();
+
+ GrBitmapTextureMaker maker(context, bitmap);
+ auto [dataProxy, ct] = maker.refTextureProxy(GrMipMapped::kNo);
+
if (!dataProxy) {
return false;
}
diff --git a/src/gpu/effects/GrRectBlurEffect.fp b/src/gpu/effects/GrRectBlurEffect.fp
index 8cf364b..34f7112 100644
--- a/src/gpu/effects/GrRectBlurEffect.fp
+++ b/src/gpu/effects/GrRectBlurEffect.fp
@@ -9,9 +9,13 @@
#include <cmath>
#include "include/core/SkRect.h"
#include "include/core/SkScalar.h"
+#include "include/gpu/GrContext.h"
+#include "include/private/GrRecordingContext.h"
#include "src/core/SkBlurMask.h"
#include "src/core/SkMathPriv.h"
+#include "src/gpu/GrBitmapTextureMaker.h"
#include "src/gpu/GrProxyProvider.h"
+#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrShaderCaps.h"
}
@@ -42,7 +46,7 @@
samplerParams
}
@class {
-static sk_sp<GrTextureProxy> CreateIntegralTexture(GrProxyProvider* proxyProvider,
+static sk_sp<GrTextureProxy> CreateIntegralTexture(GrRecordingContext* context,
float sixSigma) {
// The texture we're producing represents the integral of a normal distribution over a six-sigma
// range centered at zero. We want enough resolution so that the linear interpolation done in
@@ -58,6 +62,7 @@
builder[0] = width;
builder.finish();
+ GrProxyProvider* proxyProvider = context->priv().proxyProvider();
sk_sp<GrTextureProxy> proxy(proxyProvider->findOrCreateProxyByUniqueKey(
key, GrColorType::kAlpha_8, kTopLeft_GrSurfaceOrigin));
if (!proxy) {
@@ -75,10 +80,9 @@
}
*bitmap.getAddr8(width - 1, 0) = 0;
bitmap.setImmutable();
- // We directly call the proxyProvider instead of going through GrBitmapTextureMaker. This
- // means we won't fall back to RGBA_8888. But we should have support for a single channel
- // unorm format so we shouldn't need the fallback.
- proxy = proxyProvider->createProxyFromBitmap(bitmap, GrMipMapped::kNo);
+
+ GrBitmapTextureMaker maker(context, bitmap);
+ std::tie(proxy, std::ignore) = maker.refTextureProxy(GrMipMapped::kNo);
if (!proxy) {
return nullptr;
}
@@ -90,7 +94,7 @@
}
@make {
- static std::unique_ptr<GrFragmentProcessor> Make(GrProxyProvider* proxyProvider,
+ static std::unique_ptr<GrFragmentProcessor> Make(GrRecordingContext* context,
const GrShaderCaps& caps,
const SkRect& rect, float sigma) {
SkASSERT(rect.isSorted());
@@ -105,7 +109,7 @@
}
const float sixSigma = 6 * sigma;
- auto integral = CreateIntegralTexture(proxyProvider, sixSigma);
+ auto integral = CreateIntegralTexture(context, sixSigma);
if (!integral) {
return nullptr;
}
@@ -203,6 +207,6 @@
float sigma = data->fRandom->nextRangeF(3,8);
float width = data->fRandom->nextRangeF(200,300);
float height = data->fRandom->nextRangeF(200,300);
- return GrRectBlurEffect::Make(data->proxyProvider(), *data->caps()->shaderCaps(),
+ return GrRectBlurEffect::Make(data->context(), *data->caps()->shaderCaps(),
SkRect::MakeWH(width, height), sigma);
}
diff --git a/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp b/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp
index 863e88f..a9e477c 100644
--- a/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp
+++ b/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp
@@ -10,7 +10,11 @@
**************************************************************************************************/
#include "GrCircleBlurFragmentProcessor.h"
+#include "include/gpu/GrContext.h"
+#include "include/private/GrRecordingContext.h"
+#include "src/gpu/GrBitmapTextureMaker.h"
#include "src/gpu/GrProxyProvider.h"
+#include "src/gpu/GrRecordingContextPriv.h"
// Computes an unnormalized half kernel (right side). Returns the summation of all the half
// kernel values.
@@ -162,7 +166,7 @@
profile[profileWidth - 1] = 0;
}
-static sk_sp<GrTextureProxy> create_profile_texture(GrProxyProvider* proxyProvider,
+static sk_sp<GrTextureProxy> create_profile_texture(GrRecordingContext* context,
const SkRect& circle, float sigma,
float* solidRadius, float* textureRadius) {
float circleR = circle.width() / 2.0f;
@@ -203,6 +207,7 @@
builder[0] = sigmaToCircleRRatioFixed;
builder.finish();
+ GrProxyProvider* proxyProvider = context->priv().proxyProvider();
sk_sp<GrTextureProxy> blurProfile = proxyProvider->findOrCreateProxyByUniqueKey(
key, GrColorType::kAlpha_8, kTopLeft_GrSurfaceOrigin);
if (!blurProfile) {
@@ -223,10 +228,9 @@
}
bm.setImmutable();
- sk_sp<SkImage> image = SkImage::MakeFromBitmap(bm);
- blurProfile = proxyProvider->createTextureProxy(std::move(image), 1, SkBudgeted::kYes,
- SkBackingFit::kExact);
+ GrBitmapTextureMaker maker(context, bm);
+ std::tie(blurProfile, std::ignore) = maker.refTextureProxy(GrMipMapped::kNo);
if (!blurProfile) {
return nullptr;
}
@@ -237,11 +241,11 @@
}
std::unique_ptr<GrFragmentProcessor> GrCircleBlurFragmentProcessor::Make(
- GrProxyProvider* proxyProvider, const SkRect& circle, float sigma) {
+ GrRecordingContext* context, const SkRect& circle, float sigma) {
float solidRadius;
float textureRadius;
sk_sp<GrTextureProxy> profile(
- create_profile_texture(proxyProvider, circle, sigma, &solidRadius, &textureRadius));
+ create_profile_texture(context, circle, sigma, &solidRadius, &textureRadius));
if (!profile) {
return nullptr;
}
@@ -346,6 +350,6 @@
SkScalar wh = testData->fRandom->nextRangeScalar(100.f, 1000.f);
SkScalar sigma = testData->fRandom->nextRangeF(1.f, 10.f);
SkRect circle = SkRect::MakeWH(wh, wh);
- return GrCircleBlurFragmentProcessor::Make(testData->proxyProvider(), circle, sigma);
+ return GrCircleBlurFragmentProcessor::Make(testData->context(), circle, sigma);
}
#endif
diff --git a/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.h b/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.h
index a18e756..a0e0396 100644
--- a/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.h
+++ b/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.h
@@ -17,7 +17,7 @@
#include "src/gpu/GrFragmentProcessor.h"
class GrCircleBlurFragmentProcessor : public GrFragmentProcessor {
public:
- static std::unique_ptr<GrFragmentProcessor> Make(GrProxyProvider*, const SkRect& circle,
+ static std::unique_ptr<GrFragmentProcessor> Make(GrRecordingContext*, const SkRect& circle,
float sigma);
GrCircleBlurFragmentProcessor(const GrCircleBlurFragmentProcessor& src);
std::unique_ptr<GrFragmentProcessor> clone() const override;
diff --git a/src/gpu/effects/generated/GrConfigConversionEffect.h b/src/gpu/effects/generated/GrConfigConversionEffect.h
index e892712..51045bc 100644
--- a/src/gpu/effects/generated/GrConfigConversionEffect.h
+++ b/src/gpu/effects/generated/GrConfigConversionEffect.h
@@ -14,10 +14,10 @@
#include "include/private/SkM44.h"
#include "include/gpu/GrContext.h"
+#include "src/gpu/GrBitmapTextureMaker.h"
#include "src/gpu/GrClip.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrImageInfo.h"
-#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrRenderTargetContext.h"
#include "src/gpu/GrCoordTransform.h"
@@ -61,16 +61,16 @@
// draw
readRTC->discard();
- GrProxyProvider* proxyProvider = context->priv().proxyProvider();
-
- SkPixmap pixmap(ii, srcData, 4 * kSize);
-
// This function is only ever called if we are in a GrContext that has a GrGpu since we are
// calling read pixels here. Thus the pixel data will be uploaded immediately and we don't
// need to keep the pixel data alive in the proxy. Therefore the ReleaseProc is nullptr.
- sk_sp<SkImage> image = SkImage::MakeFromRaster(pixmap, nullptr, nullptr);
- sk_sp<GrTextureProxy> dataProxy = proxyProvider->createTextureProxy(
- std::move(image), 1, SkBudgeted::kYes, SkBackingFit::kExact);
+ SkBitmap bitmap;
+ bitmap.installPixels(ii, srcData, 4 * kSize);
+ bitmap.setImmutable();
+
+ GrBitmapTextureMaker maker(context, bitmap);
+ auto[dataProxy, ct] = maker.refTextureProxy(GrMipMapped::kNo);
+
if (!dataProxy) {
return false;
}
diff --git a/src/gpu/effects/generated/GrRectBlurEffect.cpp b/src/gpu/effects/generated/GrRectBlurEffect.cpp
index 8ba9506..9cc89b7 100644
--- a/src/gpu/effects/generated/GrRectBlurEffect.cpp
+++ b/src/gpu/effects/generated/GrRectBlurEffect.cpp
@@ -188,7 +188,7 @@
float sigma = data->fRandom->nextRangeF(3, 8);
float width = data->fRandom->nextRangeF(200, 300);
float height = data->fRandom->nextRangeF(200, 300);
- return GrRectBlurEffect::Make(data->proxyProvider(), *data->caps()->shaderCaps(),
+ return GrRectBlurEffect::Make(data->context(), *data->caps()->shaderCaps(),
SkRect::MakeWH(width, height), sigma);
}
#endif
diff --git a/src/gpu/effects/generated/GrRectBlurEffect.h b/src/gpu/effects/generated/GrRectBlurEffect.h
index 9b680a0..4ed6526 100644
--- a/src/gpu/effects/generated/GrRectBlurEffect.h
+++ b/src/gpu/effects/generated/GrRectBlurEffect.h
@@ -16,16 +16,20 @@
#include <cmath>
#include "include/core/SkRect.h"
#include "include/core/SkScalar.h"
+#include "include/gpu/GrContext.h"
+#include "include/private/GrRecordingContext.h"
#include "src/core/SkBlurMask.h"
#include "src/core/SkMathPriv.h"
+#include "src/gpu/GrBitmapTextureMaker.h"
#include "src/gpu/GrProxyProvider.h"
+#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrShaderCaps.h"
#include "src/gpu/GrCoordTransform.h"
#include "src/gpu/GrFragmentProcessor.h"
class GrRectBlurEffect : public GrFragmentProcessor {
public:
- static sk_sp<GrTextureProxy> CreateIntegralTexture(GrProxyProvider* proxyProvider,
+ static sk_sp<GrTextureProxy> CreateIntegralTexture(GrRecordingContext* context,
float sixSigma) {
// The texture we're producing represents the integral of a normal distribution over a
// six-sigma range centered at zero. We want enough resolution so that the linear
@@ -41,6 +45,7 @@
builder[0] = width;
builder.finish();
+ GrProxyProvider* proxyProvider = context->priv().proxyProvider();
sk_sp<GrTextureProxy> proxy(proxyProvider->findOrCreateProxyByUniqueKey(
key, GrColorType::kAlpha_8, kTopLeft_GrSurfaceOrigin));
if (!proxy) {
@@ -58,10 +63,9 @@
}
*bitmap.getAddr8(width - 1, 0) = 0;
bitmap.setImmutable();
- // We directly call the proxyProvider instead of going through GrBitmapTextureMaker.
- // This means we won't fall back to RGBA_8888. But we should have support for a single
- // channel unorm format so we shouldn't need the fallback.
- proxy = proxyProvider->createProxyFromBitmap(bitmap, GrMipMapped::kNo);
+
+ GrBitmapTextureMaker maker(context, bitmap);
+ std::tie(proxy, std::ignore) = maker.refTextureProxy(GrMipMapped::kNo);
if (!proxy) {
return nullptr;
}
@@ -71,7 +75,7 @@
return proxy;
}
- static std::unique_ptr<GrFragmentProcessor> Make(GrProxyProvider* proxyProvider,
+ static std::unique_ptr<GrFragmentProcessor> Make(GrRecordingContext* context,
const GrShaderCaps& caps, const SkRect& rect,
float sigma) {
SkASSERT(rect.isSorted());
@@ -86,7 +90,7 @@
}
const float sixSigma = 6 * sigma;
- auto integral = CreateIntegralTexture(proxyProvider, sixSigma);
+ auto integral = CreateIntegralTexture(context, sixSigma);
if (!integral) {
return nullptr;
}