Funnel most proxy creation through GrProxyProvider
This is to provide a choke point for DDL to create Lazy Proxies.
Change-Id: If178da13bc6447b31b7601810236d34502d9efbd
Reviewed-on: https://skia-review.googlesource.com/93303
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp
index d6d3635..e675335 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -14,6 +14,7 @@
#include "GrContext.h"
#include "GrContextPriv.h"
#include "GrGpuResource.h"
+#include "GrProxyProvider.h"
#include "GrRenderTargetContext.h"
#include "GrRenderTargetContextPriv.h"
#include "GrResourceProvider.h"
@@ -171,22 +172,14 @@
kRGBA_8888_GrPixelConfig, nullptr));
{
bool texelBufferSupport = context->caps()->shaderCaps()->texelBufferSupport();
- sk_sp<GrTextureProxy> proxy1(
- GrSurfaceProxy::MakeDeferred(proxyProvider,
- desc, SkBackingFit::kExact,
- SkBudgeted::kYes));
- sk_sp<GrTextureProxy> proxy2
- (GrSurfaceProxy::MakeDeferred(proxyProvider,
- desc, SkBackingFit::kExact,
- SkBudgeted::kYes));
- sk_sp<GrTextureProxy> proxy3(
- GrSurfaceProxy::MakeDeferred(proxyProvider,
- desc, SkBackingFit::kExact,
- SkBudgeted::kYes));
- sk_sp<GrTextureProxy> proxy4(
- GrSurfaceProxy::MakeDeferred(proxyProvider,
- desc, SkBackingFit::kExact,
- SkBudgeted::kYes));
+ sk_sp<GrTextureProxy> proxy1 =
+ proxyProvider->createProxy(desc, SkBackingFit::kExact, SkBudgeted::kYes);
+ sk_sp<GrTextureProxy> proxy2 =
+ proxyProvider->createProxy(desc, SkBackingFit::kExact, SkBudgeted::kYes);
+ sk_sp<GrTextureProxy> proxy3 =
+ proxyProvider->createProxy(desc, SkBackingFit::kExact, SkBudgeted::kYes);
+ sk_sp<GrTextureProxy> proxy4 =
+ proxyProvider->createProxy(desc, SkBackingFit::kExact, SkBudgeted::kYes);
sk_sp<GrBuffer> buffer(texelBufferSupport
? context->resourceProvider()->createBuffer(
1024, GrBufferType::kTexel_GrBufferType,
@@ -296,9 +289,8 @@
}
/** Initializes the two test texture proxies that are available to the FP test factories. */
-bool init_test_textures(GrContext* context, SkRandom* random, sk_sp<GrTextureProxy> proxies[2]) {
- GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
-
+bool init_test_textures(GrProxyProvider* proxyProvider, SkRandom* random,
+ sk_sp<GrTextureProxy> proxies[2]) {
static const int kTestTextureSize = 256;
GrSurfaceDesc desc;
desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
@@ -306,36 +298,41 @@
desc.fHeight = kTestTextureSize;
desc.fConfig = kRGBA_8888_GrPixelConfig;
- // Put premul data into the RGBA texture that the test FPs can optionally use.
- std::unique_ptr<GrColor[]> rgbaData(new GrColor[kTestTextureSize * kTestTextureSize]);
- for (int y = 0; y < kTestTextureSize; ++y) {
- for (int x = 0; x < kTestTextureSize; ++x) {
- rgbaData[kTestTextureSize * y + x] =
- input_texel_color(random->nextULessThan(256), random->nextULessThan(256));
+ {
+ // Put premul data into the RGBA texture that the test FPs can optionally use.
+ std::unique_ptr<GrColor[]> rgbaData(new GrColor[kTestTextureSize * kTestTextureSize]);
+ for (int y = 0; y < kTestTextureSize; ++y) {
+ for (int x = 0; x < kTestTextureSize; ++x) {
+ rgbaData[kTestTextureSize * y + x] =
+ input_texel_color(random->nextULessThan(256), random->nextULessThan(256));
+ }
}
- }
- proxies[0] = GrSurfaceProxy::MakeDeferred(proxyProvider, desc, SkBudgeted::kYes,
- rgbaData.get(), kTestTextureSize * sizeof(GrColor));
- // Put random values into the alpha texture that the test FPs can optionally use.
- desc.fConfig = kAlpha_8_GrPixelConfig;
- std::unique_ptr<uint8_t[]> alphaData(new uint8_t[kTestTextureSize * kTestTextureSize]);
- for (int y = 0; y < kTestTextureSize; ++y) {
- for (int x = 0; x < kTestTextureSize; ++x) {
- alphaData[kTestTextureSize * y + x] = random->nextULessThan(256);
- }
+ proxies[0] = proxyProvider->createTextureProxy(desc, SkBudgeted::kYes,
+ rgbaData.get(),
+ kTestTextureSize * sizeof(GrColor));
}
- proxies[1] = GrSurfaceProxy::MakeDeferred(proxyProvider, desc, SkBudgeted::kYes,
- alphaData.get(), kTestTextureSize);
+
+ {
+ // Put random values into the alpha texture that the test FPs can optionally use.
+ desc.fConfig = kAlpha_8_GrPixelConfig;
+ std::unique_ptr<uint8_t[]> alphaData(new uint8_t[kTestTextureSize * kTestTextureSize]);
+ for (int y = 0; y < kTestTextureSize; ++y) {
+ for (int x = 0; x < kTestTextureSize; ++x) {
+ alphaData[kTestTextureSize * y + x] = random->nextULessThan(256);
+ }
+ }
+
+ proxies[1] = proxyProvider->createTextureProxy(desc, SkBudgeted::kYes,
+ alphaData.get(), kTestTextureSize);
+ }
return proxies[0] && proxies[1];
}
// Creates a texture of premul colors used as the output of the fragment processor that precedes
// the fragment processor under test. Color values are those provided by input_texel_color().
-sk_sp<GrTextureProxy> make_input_texture(GrContext* context, int width, int height) {
- GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
-
+sk_sp<GrTextureProxy> make_input_texture(GrProxyProvider* proxyProvider, int width, int height) {
std::unique_ptr<GrColor[]> data(new GrColor[width * height]);
for (int y = 0; y < width; ++y) {
for (int x = 0; x < height; ++x) {
@@ -347,11 +344,14 @@
desc.fWidth = width;
desc.fHeight = height;
desc.fConfig = kRGBA_8888_GrPixelConfig;
- return GrSurfaceProxy::MakeDeferred(proxyProvider, desc, SkBudgeted::kYes,
- data.get(), width * sizeof(GrColor));
+
+ return proxyProvider->createTextureProxy(desc, SkBudgeted::kYes,
+ data.get(), width * sizeof(GrColor));
}
+
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
+ GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
using FPFactory = GrFragmentProcessorTestFactory;
uint32_t seed = 0;
@@ -369,13 +369,13 @@
SkBackingFit::kExact, kRenderSize, kRenderSize, kRGBA_8888_GrPixelConfig, nullptr);
sk_sp<GrTextureProxy> proxies[2];
- if (!init_test_textures(context, &random, proxies)) {
+ if (!init_test_textures(proxyProvider, &random, proxies)) {
ERRORF(reporter, "Could not create test textures");
return;
}
GrProcessorTestData testData(&random, context, rtc.get(), proxies);
- auto inputTexture = make_input_texture(context, kRenderSize, kRenderSize);
+ auto inputTexture = make_input_texture(proxyProvider, kRenderSize, kRenderSize);
std::unique_ptr<GrColor[]> readData(new GrColor[kRenderSize * kRenderSize]);
// Because processor factories configure themselves in random ways, this is not exhaustive.
@@ -489,6 +489,7 @@
// progenitors.
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorCloneTest, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
+ GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
SkRandom random;
@@ -498,13 +499,13 @@
SkBackingFit::kExact, kRenderSize, kRenderSize, kRGBA_8888_GrPixelConfig, nullptr);
sk_sp<GrTextureProxy> proxies[2];
- if (!init_test_textures(context, &random, proxies)) {
+ if (!init_test_textures(proxyProvider, &random, proxies)) {
ERRORF(reporter, "Could not create test textures");
return;
}
GrProcessorTestData testData(&random, context, rtc.get(), proxies);
- auto inputTexture = make_input_texture(context, kRenderSize, kRenderSize);
+ auto inputTexture = make_input_texture(proxyProvider, kRenderSize, kRenderSize);
std::unique_ptr<GrColor[]> readData1(new GrColor[kRenderSize * kRenderSize]);
std::unique_ptr<GrColor[]> readData2(new GrColor[kRenderSize * kRenderSize]);
auto readInfo = SkImageInfo::Make(kRenderSize, kRenderSize, kRGBA_8888_SkColorType,