Have GrProcessorTestData hold views instead of proxies.
Bug: skia:9556
Change-Id: I2e51331eaca74a6c355872cd19b725f7b3ab551e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/270199
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/effects/imagefilters/SkDisplacementMapEffect.cpp b/src/effects/imagefilters/SkDisplacementMapEffect.cpp
index f921358..2b68324 100644
--- a/src/effects/imagefilters/SkDisplacementMapEffect.cpp
+++ b/src/effects/imagefilters/SkDisplacementMapEffect.cpp
@@ -536,8 +536,8 @@
#if GR_TEST_UTILS
std::unique_ptr<GrFragmentProcessor> GrDisplacementMapEffect::TestCreate(GrProcessorTestData* d) {
- auto [dispProxy, ct1, at1] = d->randomProxy();
- auto [colorProxy, ct2, at2] = d->randomProxy();
+ auto [dispView, ct1, at1] = d->randomView();
+ auto [colorView, ct2, at2] = d->randomView();
static const int kMaxComponent = static_cast<int>(SkColorChannel::kLastEnum);
SkColorChannel xChannelSelector =
static_cast<SkColorChannel>(d->fRandom->nextRangeU(1, kMaxComponent));
@@ -546,17 +546,9 @@
SkVector scale = SkVector::Make(d->fRandom->nextRangeScalar(0, 100.0f),
d->fRandom->nextRangeScalar(0, 100.0f));
SkISize colorDimensions;
- colorDimensions.fWidth = d->fRandom->nextRangeU(0, colorProxy->width());
- colorDimensions.fHeight = d->fRandom->nextRangeU(0, colorProxy->height());
- SkIRect dispRect = SkIRect::MakeSize(dispProxy->dimensions());
-
- GrSurfaceOrigin origin = dispProxy->origin();
- GrSwizzle swizzle = dispProxy->textureSwizzle();
- GrSurfaceProxyView dispView(std::move(dispProxy), origin, swizzle);
-
- origin = colorProxy->origin();
- swizzle = colorProxy->textureSwizzle();
- GrSurfaceProxyView colorView(std::move(colorProxy), origin, swizzle);
+ colorDimensions.fWidth = d->fRandom->nextRangeU(0, colorView.width());
+ colorDimensions.fHeight = d->fRandom->nextRangeU(0, colorView.height());
+ SkIRect dispRect = SkIRect::MakeSize(dispView.dimensions());
return GrDisplacementMapEffect::Make(xChannelSelector, yChannelSelector, scale,
std::move(dispView),
diff --git a/src/effects/imagefilters/SkLightingImageFilter.cpp b/src/effects/imagefilters/SkLightingImageFilter.cpp
index 7d95eaa..8765e7c 100644
--- a/src/effects/imagefilters/SkLightingImageFilter.cpp
+++ b/src/effects/imagefilters/SkLightingImageFilter.cpp
@@ -1705,7 +1705,7 @@
}
std::unique_ptr<GrFragmentProcessor> GrDiffuseLightingEffect::TestCreate(GrProcessorTestData* d) {
- auto [proxy, ct, at] = d->randomProxy();
+ auto [view, ct, at] = d->randomView();
SkScalar surfaceScale = d->fRandom->nextSScalar1();
SkScalar kd = d->fRandom->nextUScalar1();
sk_sp<SkImageFilterLight> light(create_random_light(d->fRandom));
@@ -1713,15 +1713,13 @@
for (int i = 0; i < 9; i++) {
matrix[i] = d->fRandom->nextUScalar1();
}
- SkIRect srcBounds = SkIRect::MakeXYWH(d->fRandom->nextRangeU(0, proxy->width()),
- d->fRandom->nextRangeU(0, proxy->height()),
- d->fRandom->nextRangeU(0, proxy->width()),
- d->fRandom->nextRangeU(0, proxy->height()));
- BoundaryMode mode = static_cast<BoundaryMode>(d->fRandom->nextU() % kBoundaryModeCount);
- GrSurfaceOrigin origin = proxy->origin();
- GrSwizzle swizzle = proxy->textureSwizzle();
- GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
+ uint32_t boundsX = d->fRandom->nextRangeU(0, view.width());
+ uint32_t boundsY = d->fRandom->nextRangeU(0, view.height());
+ uint32_t boundsW = d->fRandom->nextRangeU(0, view.width());
+ uint32_t boundsH = d->fRandom->nextRangeU(0, view.height());
+ SkIRect srcBounds = SkIRect::MakeXYWH(boundsX, boundsY, boundsW, boundsH);
+ BoundaryMode mode = static_cast<BoundaryMode>(d->fRandom->nextU() % kBoundaryModeCount);
return GrDiffuseLightingEffect::Make(std::move(view), std::move(light), surfaceScale, matrix,
kd, mode, &srcBounds);
@@ -1926,7 +1924,7 @@
#if GR_TEST_UTILS
std::unique_ptr<GrFragmentProcessor> GrSpecularLightingEffect::TestCreate(GrProcessorTestData* d) {
- auto [proxy, ct, at] = d->randomProxy();
+ auto [view, ct, at] = d->randomView();
SkScalar surfaceScale = d->fRandom->nextSScalar1();
SkScalar ks = d->fRandom->nextUScalar1();
SkScalar shininess = d->fRandom->nextUScalar1();
@@ -1936,14 +1934,12 @@
matrix[i] = d->fRandom->nextUScalar1();
}
BoundaryMode mode = static_cast<BoundaryMode>(d->fRandom->nextU() % kBoundaryModeCount);
- SkIRect srcBounds = SkIRect::MakeXYWH(d->fRandom->nextRangeU(0, proxy->width()),
- d->fRandom->nextRangeU(0, proxy->height()),
- d->fRandom->nextRangeU(0, proxy->width()),
- d->fRandom->nextRangeU(0, proxy->height()));
- GrSurfaceOrigin origin = proxy->origin();
- GrSwizzle swizzle = proxy->textureSwizzle();
- GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
+ uint32_t boundsX = d->fRandom->nextRangeU(0, view.width());
+ uint32_t boundsY = d->fRandom->nextRangeU(0, view.height());
+ uint32_t boundsW = d->fRandom->nextRangeU(0, view.width());
+ uint32_t boundsH = d->fRandom->nextRangeU(0, view.height());
+ SkIRect srcBounds = SkIRect::MakeXYWH(boundsX, boundsY, boundsW, boundsH);
return GrSpecularLightingEffect::Make(std::move(view), std::move(light), surfaceScale, matrix,
ks, shininess, mode, &srcBounds);
diff --git a/src/effects/imagefilters/SkMorphologyImageFilter.cpp b/src/effects/imagefilters/SkMorphologyImageFilter.cpp
index 909d27a..113c763 100644
--- a/src/effects/imagefilters/SkMorphologyImageFilter.cpp
+++ b/src/effects/imagefilters/SkMorphologyImageFilter.cpp
@@ -455,11 +455,7 @@
#if GR_TEST_UTILS
std::unique_ptr<GrFragmentProcessor> GrMorphologyEffect::TestCreate(GrProcessorTestData* d) {
- auto [proxy, ct, at] = d->randomProxy();
-
- GrSurfaceOrigin origin = proxy->origin();
- GrSwizzle swizzle = proxy->textureSwizzle();
- GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
+ auto [view, ct, at] = d->randomView();
MorphDirection dir = d->fRandom->nextBool() ? MorphDirection::kX : MorphDirection::kY;
static const int kMaxRadius = 10;
diff --git a/src/gpu/GrProcessorUnitTest.cpp b/src/gpu/GrProcessorUnitTest.cpp
index 21f282b..ed98ada 100644
--- a/src/gpu/GrProcessorUnitTest.cpp
+++ b/src/gpu/GrProcessorUnitTest.cpp
@@ -15,10 +15,10 @@
GrProcessorTestData::GrProcessorTestData(SkRandom* random,
GrContext* context,
- int numProxies,
- const ProxyInfo proxies[])
+ int numViews,
+ const ViewInfo views[])
: fRandom(random), fContext(context) {
- fProxies.reset(proxies, numProxies);
+ fViews.reset(views, numViews);
fArena = std::unique_ptr<SkArenaAlloc>(new SkArenaAlloc(1000));
}
@@ -30,23 +30,23 @@
const GrCaps* GrProcessorTestData::caps() { return fContext->priv().caps(); }
-GrProcessorTestData::ProxyInfo GrProcessorTestData::randomProxy() {
- SkASSERT(!fProxies.empty());
- return fProxies[fRandom->nextULessThan(fProxies.count())];
+GrProcessorTestData::ViewInfo GrProcessorTestData::randomView() {
+ SkASSERT(!fViews.empty());
+ return fViews[fRandom->nextULessThan(fViews.count())];
}
-GrProcessorTestData::ProxyInfo GrProcessorTestData::randomAlphaOnlyProxy() {
+GrProcessorTestData::ViewInfo GrProcessorTestData::randomAlphaOnlyView() {
int numAlphaOnly = 0;
- for (const auto& [p, ct, at] : fProxies) {
+ for (const auto& [v, ct, at] : fViews) {
if (GrColorTypeIsAlphaOnly(ct)) {
++numAlphaOnly;
}
}
SkASSERT(numAlphaOnly);
int idx = fRandom->nextULessThan(numAlphaOnly);
- for (const auto& [p, ct, at] : fProxies) {
+ for (const auto& [v, ct, at] : fViews) {
if (GrColorTypeIsAlphaOnly(ct) && !idx--) {
- return {p, ct, at};
+ return {v, ct, at};
}
}
SkUNREACHABLE;
diff --git a/src/gpu/GrProcessorUnitTest.h b/src/gpu/GrProcessorUnitTest.h
index 5d7443b..5086028 100644
--- a/src/gpu/GrProcessorUnitTest.h
+++ b/src/gpu/GrProcessorUnitTest.h
@@ -52,8 +52,8 @@
*/
class GrProcessorTestData {
public:
- using ProxyInfo = std::tuple<sk_sp<GrTextureProxy>, GrColorType, SkAlphaType>;
- GrProcessorTestData(SkRandom* random, GrContext* context, int numProxies, const ProxyInfo[]);
+ using ViewInfo = std::tuple<GrSurfaceProxyView, GrColorType, SkAlphaType>;
+ GrProcessorTestData(SkRandom* random, GrContext* context, int numProxies, const ViewInfo[]);
GrContext* context() { return fContext; }
GrResourceProvider* resourceProvider();
@@ -61,14 +61,14 @@
const GrCaps* caps();
SkArenaAlloc* allocator() { return fArena.get(); }
- ProxyInfo randomProxy();
- ProxyInfo randomAlphaOnlyProxy();
+ ViewInfo randomView();
+ ViewInfo randomAlphaOnlyView();
SkRandom* fRandom;
private:
GrContext* fContext;
- SkTArray<ProxyInfo> fProxies;
+ SkTArray<ViewInfo> fViews;
std::unique_ptr<SkArenaAlloc> fArena;
};
diff --git a/src/gpu/GrSurfaceProxyView.h b/src/gpu/GrSurfaceProxyView.h
index 6fe016f..5195d75 100644
--- a/src/gpu/GrSurfaceProxyView.h
+++ b/src/gpu/GrSurfaceProxyView.h
@@ -41,6 +41,10 @@
}
bool operator!=(const GrSurfaceProxyView& other) const { return !(*this == other); }
+ int width() const { return this->proxy()->width(); }
+ int height() const { return this->proxy()->height(); }
+ SkISize dimensions() const { return this->proxy()->dimensions(); }
+
GrSurfaceProxy* proxy() const { return fProxy.get(); }
sk_sp<GrSurfaceProxy> refProxy() const { return fProxy; }
diff --git a/src/gpu/effects/GrAlphaThresholdFragmentProcessor.fp b/src/gpu/effects/GrAlphaThresholdFragmentProcessor.fp
index 9013d4e..4eb3a4e 100644
--- a/src/gpu/effects/GrAlphaThresholdFragmentProcessor.fp
+++ b/src/gpu/effects/GrAlphaThresholdFragmentProcessor.fp
@@ -61,7 +61,7 @@
}
@test(testData) {
- auto [maskProxy, ct, at] = testData->randomAlphaOnlyProxy();
+ auto [maskView, ct, at] = testData->randomAlphaOnlyView();
// Make the inner and outer thresholds be in (0, 1) exclusive and be sorted correctly.
float innerThresh = testData->fRandom->nextUScalar1() * .99f + 0.005f;
float outerThresh = testData->fRandom->nextUScalar1() * .99f + 0.005f;
@@ -73,10 +73,6 @@
uint32_t y = testData->fRandom->nextULessThan(kMaxHeight - height);
SkIRect bounds = SkIRect::MakeXYWH(x, y, width, height);
- GrSurfaceOrigin origin = maskProxy->origin();
- GrSwizzle swizzle = maskProxy->textureSwizzle();
- GrSurfaceProxyView view(std::move(maskProxy), origin, swizzle);
-
- return GrAlphaThresholdFragmentProcessor::Make(std::move(view), innerThresh, outerThresh,
+ return GrAlphaThresholdFragmentProcessor::Make(std::move(maskView), innerThresh, outerThresh,
bounds);
}
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp
index 1845ac6..2855d79 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -222,11 +222,7 @@
direction = Direction::kXY;
break;
}
- auto [proxy, ct, at] = d->randomProxy();
-
- GrSurfaceOrigin origin = proxy->origin();
- GrSwizzle swizzle = proxy->textureSwizzle();
- GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
+ auto [view, ct, at] = d->randomView();
return GrBicubicEffect::Make(std::move(view), SkMatrix::I(), kClampClamp, direction, at);
}
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp
index 864e74c..3b0dcd1 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.cpp
+++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp
@@ -201,7 +201,7 @@
#if GR_TEST_UTILS
GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(GrProcessorTestData* d) {
- auto [proxy, ct, at] = d->randomProxy();
+ auto [view, ct, at] = d->randomView();
GrSamplerState::WrapMode wrapModes[2];
GrTest::TestWrapModes(d->fRandom, wrapModes);
@@ -222,9 +222,6 @@
format = kARGB_GrMaskFormat;
break;
}
- GrSurfaceOrigin origin = proxy->origin();
- const GrSwizzle& swizzle = proxy->textureSwizzle();
- GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
return GrBitmapTextGeoProc::Make(d->allocator(), *d->caps()->shaderCaps(),
SkPMColor4f::FromBytes_RGBA(GrRandomColor(d->fRandom)),
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
index 8eb7733..4378638 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
@@ -288,7 +288,7 @@
#if GR_TEST_UTILS
GrGeometryProcessor* GrDistanceFieldA8TextGeoProc::TestCreate(GrProcessorTestData* d) {
- auto [proxy, ct, at] = d->randomAlphaOnlyProxy();
+ auto [view, ct, at] = d->randomAlphaOnlyView();
GrSamplerState::WrapMode wrapModes[2];
GrTest::TestWrapModes(d->fRandom, wrapModes);
@@ -305,10 +305,6 @@
#ifdef SK_GAMMA_APPLY_TO_A8
float lum = d->fRandom->nextF();
#endif
- GrSurfaceOrigin origin = proxy->origin();
- const GrSwizzle& swizzle = proxy->textureSwizzle();
- GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
-
return GrDistanceFieldA8TextGeoProc::Make(d->allocator(), *d->caps()->shaderCaps(),
&view, 1,
samplerState,
@@ -582,7 +578,7 @@
#if GR_TEST_UTILS
GrGeometryProcessor* GrDistanceFieldPathGeoProc::TestCreate(GrProcessorTestData* d) {
- auto [proxy, ct, at] = d->randomAlphaOnlyProxy();
+ auto [view, ct, at] = d->randomAlphaOnlyView();
GrSamplerState::WrapMode wrapModes[2];
GrTest::TestWrapModes(d->fRandom, wrapModes);
@@ -595,9 +591,6 @@
if (flags & kSimilarity_DistanceFieldEffectFlag) {
flags |= d->fRandom->nextBool() ? kScaleOnly_DistanceFieldEffectFlag : 0;
}
- GrSurfaceOrigin origin = proxy->origin();
- const GrSwizzle& swizzle = proxy->textureSwizzle();
- GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
return GrDistanceFieldPathGeoProc::Make(d->allocator(), *d->caps()->shaderCaps(),
GrTest::TestMatrix(d->fRandom),
@@ -905,7 +898,7 @@
#if GR_TEST_UTILS
GrGeometryProcessor* GrDistanceFieldLCDTextGeoProc::TestCreate(GrProcessorTestData* d) {
- auto [proxy, ct, at] = d->randomProxy();
+ auto [view, ct, at] = d->randomView();
GrSamplerState::WrapMode wrapModes[2];
GrTest::TestWrapModes(d->fRandom, wrapModes);
@@ -921,10 +914,6 @@
flags |= d->fRandom->nextBool() ? kBGR_DistanceFieldEffectFlag : 0;
SkMatrix localMatrix = GrTest::TestMatrix(d->fRandom);
- GrSurfaceOrigin origin = proxy->origin();
- const GrSwizzle& swizzle = proxy->textureSwizzle();
- GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
-
return GrDistanceFieldLCDTextGeoProc::Make(d->allocator(), *d->caps()->shaderCaps(), &view,
1, samplerState, wa, flags, localMatrix);
}
diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
index a318025..9eb4d97 100644
--- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
+++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
@@ -314,7 +314,7 @@
#if GR_TEST_UTILS
std::unique_ptr<GrFragmentProcessor> GrGaussianConvolutionFragmentProcessor::TestCreate(
GrProcessorTestData* d) {
- auto [proxy, ct, at] = d->randomProxy();
+ auto [view, ct, at] = d->randomView();
int bounds[2];
int modeIdx = d->fRandom->nextRangeU(0, GrTextureDomain::kModeCount-1);
@@ -322,21 +322,17 @@
Direction dir;
if (d->fRandom->nextBool()) {
dir = Direction::kX;
- bounds[0] = d->fRandom->nextRangeU(0, proxy->width()-2);
- bounds[1] = d->fRandom->nextRangeU(bounds[0]+1, proxy->width()-1);
+ bounds[0] = d->fRandom->nextRangeU(0, view.width()-2);
+ bounds[1] = d->fRandom->nextRangeU(bounds[0]+1, view.width()-1);
} else {
dir = Direction::kY;
- bounds[0] = d->fRandom->nextRangeU(0, proxy->height()-2);
- bounds[1] = d->fRandom->nextRangeU(bounds[0]+1, proxy->height()-1);
+ bounds[0] = d->fRandom->nextRangeU(0, view.height()-2);
+ bounds[1] = d->fRandom->nextRangeU(bounds[0]+1, view.height()-1);
}
int radius = d->fRandom->nextRangeU(1, kMaxKernelRadius);
float sigma = radius / 3.f;
- GrSurfaceOrigin origin = proxy->origin();
- GrSwizzle swizzle = proxy->textureSwizzle();
- GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
-
return GrGaussianConvolutionFragmentProcessor::Make(std::move(view), at, dir, radius, sigma,
static_cast<GrTextureDomain::Mode>(modeIdx),
bounds);
diff --git a/src/gpu/effects/GrMagnifierEffect.fp b/src/gpu/effects/GrMagnifierEffect.fp
index e862edd..582fc4b 100644
--- a/src/gpu/effects/GrMagnifierEffect.fp
+++ b/src/gpu/effects/GrMagnifierEffect.fp
@@ -71,7 +71,7 @@
}
@test(d) {
- auto [proxy, ct, at] = d->randomProxy();
+ auto [view, ct, at] = d->randomView();
const int kMaxWidth = 200;
const int kMaxHeight = 200;
const SkScalar kMaxInset = 20.0f;
@@ -82,10 +82,6 @@
SkIRect bounds = SkIRect::MakeWH(SkIntToScalar(kMaxWidth), SkIntToScalar(kMaxHeight));
SkRect srcRect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
- GrSurfaceOrigin origin = proxy->origin();
- GrSwizzle swizzle = proxy->textureSwizzle();
- GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
-
auto effect = GrMagnifierEffect::Make(std::move(view),
bounds,
srcRect,
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
index fafd35e..236c5d3 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
@@ -324,7 +324,7 @@
#if GR_TEST_UTILS
std::unique_ptr<GrFragmentProcessor> GrMatrixConvolutionEffect::TestCreate(GrProcessorTestData* d) {
- auto [proxy, ct, at] = d->randomProxy();
+ auto [view, ct, at] = d->randomView();
int width = d->fRandom->nextRangeU(1, MAX_KERNEL_SIZE);
int height = d->fRandom->nextRangeU(1, MAX_KERNEL_SIZE / width);
@@ -335,20 +335,21 @@
}
SkScalar gain = d->fRandom->nextSScalar1();
SkScalar bias = d->fRandom->nextSScalar1();
- SkIPoint kernelOffset = SkIPoint::Make(d->fRandom->nextRangeU(0, kernelSize.width()),
- d->fRandom->nextRangeU(0, kernelSize.height()));
- SkIRect bounds = SkIRect::MakeXYWH(d->fRandom->nextRangeU(0, proxy->width()),
- d->fRandom->nextRangeU(0, proxy->height()),
- d->fRandom->nextRangeU(0, proxy->width()),
- d->fRandom->nextRangeU(0, proxy->height()));
+
+ uint32_t kernalOffsetX = d->fRandom->nextRangeU(0, kernelSize.width());
+ uint32_t kernalOffsetY = d->fRandom->nextRangeU(0, kernelSize.height());
+ SkIPoint kernelOffset = SkIPoint::Make(kernalOffsetX, kernalOffsetY);
+
+ uint32_t boundsX = d->fRandom->nextRangeU(0, view.width());
+ uint32_t boundsY = d->fRandom->nextRangeU(0, view.height());
+ uint32_t boundsW = d->fRandom->nextRangeU(0, view.width());
+ uint32_t boundsH = d->fRandom->nextRangeU(0, view.height());
+ SkIRect bounds = SkIRect::MakeXYWH(boundsX, boundsY, boundsW, boundsH);
+
GrTextureDomain::Mode tileMode =
static_cast<GrTextureDomain::Mode>(d->fRandom->nextRangeU(0, 2));
bool convolveAlpha = d->fRandom->nextBool();
- GrSurfaceOrigin origin = proxy->origin();
- GrSwizzle swizzle = proxy->textureSwizzle();
- GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
-
return GrMatrixConvolutionEffect::Make(std::move(view),
bounds,
kernelSize,
diff --git a/src/gpu/effects/GrShadowGeoProc.cpp b/src/gpu/effects/GrShadowGeoProc.cpp
index c2124c7..de6db26 100644
--- a/src/gpu/effects/GrShadowGeoProc.cpp
+++ b/src/gpu/effects/GrShadowGeoProc.cpp
@@ -85,10 +85,7 @@
#if GR_TEST_UTILS
GrGeometryProcessor* GrRRectShadowGeoProc::TestCreate(GrProcessorTestData* d) {
- auto [proxy, ct, at] = d->randomAlphaOnlyProxy();
- GrSurfaceOrigin origin = proxy->origin();
- const GrSwizzle& swizzle = proxy->textureSwizzle();
- GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
+ auto [view, ct, at] = d->randomAlphaOnlyView();
return GrRRectShadowGeoProc::Make(d->allocator(), view);
}
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index 96472e0..59c3dfa 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -421,20 +421,16 @@
#if GR_TEST_UTILS
std::unique_ptr<GrFragmentProcessor> GrDeviceSpaceTextureDecalFragmentProcessor::TestCreate(
GrProcessorTestData* d) {
- auto [proxy, at, ct] = d->randomProxy();
+ auto [view, at, ct] = d->randomView();
SkIRect subset;
- subset.fLeft = d->fRandom->nextULessThan(proxy->width() - 1);
- subset.fRight = d->fRandom->nextRangeU(subset.fLeft, proxy->width());
- subset.fTop = d->fRandom->nextULessThan(proxy->height() - 1);
- subset.fBottom = d->fRandom->nextRangeU(subset.fTop, proxy->height());
+ subset.fLeft = d->fRandom->nextULessThan(view.width() - 1);
+ subset.fRight = d->fRandom->nextRangeU(subset.fLeft, view.width());
+ subset.fTop = d->fRandom->nextULessThan(view.height() - 1);
+ subset.fBottom = d->fRandom->nextRangeU(subset.fTop, view.height());
SkIPoint pt;
pt.fX = d->fRandom->nextULessThan(2048);
pt.fY = d->fRandom->nextULessThan(2048);
- GrSurfaceOrigin origin = proxy->origin();
- GrSwizzle swizzle = proxy->textureSwizzle();
- GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
-
return GrDeviceSpaceTextureDecalFragmentProcessor::Make(std::move(view), subset, pt);
}
#endif
diff --git a/src/gpu/effects/GrTextureEffect.cpp b/src/gpu/effects/GrTextureEffect.cpp
index 298cf47..cbfe3ce 100644
--- a/src/gpu/effects/GrTextureEffect.cpp
+++ b/src/gpu/effects/GrTextureEffect.cpp
@@ -460,7 +460,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrTextureEffect);
#if GR_TEST_UTILS
std::unique_ptr<GrFragmentProcessor> GrTextureEffect::TestCreate(GrProcessorTestData* testData) {
- auto [proxy, ct, at] = testData->randomProxy();
+ auto [view, ct, at] = testData->randomView();
GrSamplerState::WrapMode wrapModes[2];
GrTest::TestWrapModes(testData->fRandom, wrapModes);
if (!testData->caps()->npotTextureTileSupport()) {
@@ -475,9 +475,6 @@
: GrSamplerState::Filter::kNearest);
const SkMatrix& matrix = GrTest::TestMatrix(testData->fRandom);
- GrSurfaceOrigin origin = proxy->origin();
- GrSwizzle swizzle = proxy->textureSwizzle();
- GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
return GrTextureEffect::Make(std::move(view), at, matrix, params, *testData->caps());
}
#endif
diff --git a/src/gpu/effects/generated/GrAlphaThresholdFragmentProcessor.cpp b/src/gpu/effects/generated/GrAlphaThresholdFragmentProcessor.cpp
index 03141a9..8332c54 100644
--- a/src/gpu/effects/generated/GrAlphaThresholdFragmentProcessor.cpp
+++ b/src/gpu/effects/generated/GrAlphaThresholdFragmentProcessor.cpp
@@ -111,7 +111,7 @@
#if GR_TEST_UTILS
std::unique_ptr<GrFragmentProcessor> GrAlphaThresholdFragmentProcessor::TestCreate(
GrProcessorTestData* testData) {
- auto[maskProxy, ct, at] = testData->randomAlphaOnlyProxy();
+ auto[maskView, ct, at] = testData->randomAlphaOnlyView();
// Make the inner and outer thresholds be in (0, 1) exclusive and be sorted correctly.
float innerThresh = testData->fRandom->nextUScalar1() * .99f + 0.005f;
float outerThresh = testData->fRandom->nextUScalar1() * .99f + 0.005f;
@@ -123,11 +123,7 @@
uint32_t y = testData->fRandom->nextULessThan(kMaxHeight - height);
SkIRect bounds = SkIRect::MakeXYWH(x, y, width, height);
- GrSurfaceOrigin origin = maskProxy->origin();
- GrSwizzle swizzle = maskProxy->textureSwizzle();
- GrSurfaceProxyView view(std::move(maskProxy), origin, swizzle);
-
- return GrAlphaThresholdFragmentProcessor::Make(std::move(view), innerThresh, outerThresh,
+ return GrAlphaThresholdFragmentProcessor::Make(std::move(maskView), innerThresh, outerThresh,
bounds);
}
#endif
diff --git a/src/gpu/effects/generated/GrMagnifierEffect.cpp b/src/gpu/effects/generated/GrMagnifierEffect.cpp
index 8c85810..e7ae02b 100644
--- a/src/gpu/effects/generated/GrMagnifierEffect.cpp
+++ b/src/gpu/effects/generated/GrMagnifierEffect.cpp
@@ -178,7 +178,7 @@
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMagnifierEffect);
#if GR_TEST_UTILS
std::unique_ptr<GrFragmentProcessor> GrMagnifierEffect::TestCreate(GrProcessorTestData* d) {
- auto[proxy, ct, at] = d->randomProxy();
+ auto[view, ct, at] = d->randomView();
const int kMaxWidth = 200;
const int kMaxHeight = 200;
const SkScalar kMaxInset = 20.0f;
@@ -189,10 +189,6 @@
SkIRect bounds = SkIRect::MakeWH(SkIntToScalar(kMaxWidth), SkIntToScalar(kMaxHeight));
SkRect srcRect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
- GrSurfaceOrigin origin = proxy->origin();
- GrSwizzle swizzle = proxy->textureSwizzle();
- GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
-
auto effect = GrMagnifierEffect::Make(std::move(view),
bounds,
srcRect,
diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp
index d6a876c..7ed9fe9 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -81,9 +81,9 @@
static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> child) {
return std::unique_ptr<GrFragmentProcessor>(new TestFP(std::move(child)));
}
- static std::unique_ptr<GrFragmentProcessor> Make(const SkTArray<sk_sp<GrTextureProxy>>& proxies,
+ static std::unique_ptr<GrFragmentProcessor> Make(const SkTArray<GrSurfaceProxyView>& views,
const SkTArray<sk_sp<GrGpuBuffer>>& buffers) {
- return std::unique_ptr<GrFragmentProcessor>(new TestFP(proxies, buffers));
+ return std::unique_ptr<GrFragmentProcessor>(new TestFP(views, buffers));
}
const char* name() const override { return "test"; }
@@ -98,11 +98,11 @@
}
private:
- TestFP(const SkTArray<sk_sp<GrTextureProxy>>& proxies,
+ TestFP(const SkTArray<GrSurfaceProxyView>& views,
const SkTArray<sk_sp<GrGpuBuffer>>& buffers)
: INHERITED(kTestFP_ClassID, kNone_OptimizationFlags), fSamplers(4) {
- for (const auto& proxy : proxies) {
- fSamplers.emplace_back(proxy);
+ for (const auto& view : views) {
+ fSamplers.emplace_back(view);
}
this->setTextureSamplerCnt(fSamplers.count());
}
@@ -166,10 +166,10 @@
GrMipMapped::kNo, SkBackingFit::kExact, SkBudgeted::kYes, GrProtected::kNo);
{
- SkTArray<sk_sp<GrTextureProxy>> proxies;
+ SkTArray<GrSurfaceProxyView> views;
SkTArray<sk_sp<GrGpuBuffer>> buffers;
- proxies.push_back(proxy);
- auto fp = TestFP::Make(std::move(proxies), std::move(buffers));
+ views.push_back({proxy, kTopLeft_GrSurfaceOrigin, swizzle});
+ auto fp = TestFP::Make(std::move(views), std::move(buffers));
for (int i = 0; i < parentCnt; ++i) {
fp = TestFP::Make(std::move(fp));
}
@@ -261,7 +261,7 @@
bool init_test_textures(GrResourceProvider* resourceProvider,
GrRecordingContext* context,
SkRandom* random,
- GrProcessorTestData::ProxyInfo proxies[2]) {
+ GrProcessorTestData::ViewInfo views[2]) {
static const int kTestTextureSize = 256;
{
@@ -285,7 +285,7 @@
if (!view.proxy() || !view.proxy()->instantiate(resourceProvider)) {
return false;
}
- proxies[0] = {view.asTextureProxyRef(), GrColorType::kRGBA_8888, kPremul_SkAlphaType};
+ views[0] = {view, GrColorType::kRGBA_8888, kPremul_SkAlphaType};
}
{
@@ -308,7 +308,7 @@
if (!view.proxy() || !view.proxy()->instantiate(resourceProvider)) {
return false;
}
- proxies[1] = {view.asTextureProxyRef(), GrColorType::kAlpha_8, kPremul_SkAlphaType};
+ views[1] = {view, GrColorType::kAlpha_8, kPremul_SkAlphaType};
}
return true;
@@ -496,12 +496,12 @@
context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact,
{kRenderSize, kRenderSize});
- GrProcessorTestData::ProxyInfo proxies[2];
- if (!init_test_textures(resourceProvider, context, &random, proxies)) {
+ GrProcessorTestData::ViewInfo views[2];
+ if (!init_test_textures(resourceProvider, context, &random, views)) {
ERRORF(reporter, "Could not create test textures");
return;
}
- GrProcessorTestData testData(&random, context, 2, proxies);
+ GrProcessorTestData testData(&random, context, 2, views);
// Coverage optimization uses three frames with a linearly transformed input texture. The first
// frame has no offset, second frames add .2 and .4, which should then be present as a fixed
@@ -730,12 +730,12 @@
context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact,
{kRenderSize, kRenderSize});
- GrProcessorTestData::ProxyInfo proxies[2];
- if (!init_test_textures(resourceProvider, context, &random, proxies)) {
+ GrProcessorTestData::ViewInfo views[2];
+ if (!init_test_textures(resourceProvider, context, &random, views)) {
ERRORF(reporter, "Could not create test textures");
return;
}
- GrProcessorTestData testData(&random, context, 2, proxies);
+ GrProcessorTestData testData(&random, context, 2, views);
auto inputTexture = make_input_texture(context, kRenderSize, kRenderSize, 0.0f);
std::unique_ptr<GrColor[]> readData1(new GrColor[kRenderSize * kRenderSize]);
diff --git a/tests/ProgramsTest.cpp b/tests/ProgramsTest.cpp
index e462407..b12ec52 100644
--- a/tests/ProgramsTest.cpp
+++ b/tests/ProgramsTest.cpp
@@ -257,7 +257,7 @@
GrDrawingManager* drawingManager = context->priv().drawingManager();
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
- GrProcessorTestData::ProxyInfo proxies[2];
+ GrProcessorTestData::ViewInfo views[2];
// setup dummy textures
GrMipMapped mipMapped = GrMipMapped(context->priv().caps()->mipMapSupport());
@@ -267,11 +267,12 @@
context->priv().caps()->getDefaultBackendFormat(GrColorType::kRGBA_8888,
GrRenderable::kYes);
GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(format, GrColorType::kRGBA_8888);
- proxies[0] = {proxyProvider->createProxy(format, kDummyDims, swizzle, GrRenderable::kYes, 1,
- kBottomLeft_GrSurfaceOrigin, mipMapped,
- SkBackingFit::kExact, SkBudgeted::kNo,
- GrProtected::kNo, GrInternalSurfaceFlags::kNone),
- GrColorType::kRGBA_8888, kPremul_SkAlphaType};
+ auto proxy = proxyProvider->createProxy(format, kDummyDims, swizzle, GrRenderable::kYes, 1,
+ kBottomLeft_GrSurfaceOrigin, mipMapped,
+ SkBackingFit::kExact, SkBudgeted::kNo,
+ GrProtected::kNo, GrInternalSurfaceFlags::kNone);
+ views[0] = {{std::move(proxy), kBottomLeft_GrSurfaceOrigin, swizzle},
+ GrColorType::kRGBA_8888, kPremul_SkAlphaType};
}
{
static constexpr SkISize kDummyDims = {16, 22};
@@ -279,14 +280,15 @@
context->priv().caps()->getDefaultBackendFormat(GrColorType::kAlpha_8,
GrRenderable::kNo);
GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(format, GrColorType::kAlpha_8);
- proxies[1] = {proxyProvider->createProxy(format, kDummyDims, swizzle, GrRenderable::kNo, 1,
- kTopLeft_GrSurfaceOrigin, mipMapped,
- SkBackingFit::kExact, SkBudgeted::kNo,
- GrProtected::kNo, GrInternalSurfaceFlags::kNone),
+ auto proxy = proxyProvider->createProxy(format, kDummyDims, swizzle, GrRenderable::kNo, 1,
+ kTopLeft_GrSurfaceOrigin, mipMapped,
+ SkBackingFit::kExact, SkBudgeted::kNo,
+ GrProtected::kNo, GrInternalSurfaceFlags::kNone);
+ views[1] = {{std::move(proxy), kTopLeft_GrSurfaceOrigin, swizzle},
GrColorType::kAlpha_8, kPremul_SkAlphaType};
}
- if (!std::get<0>(proxies[0]) || !std::get<0>(proxies[1])) {
+ if (!std::get<0>(views[0]) || !std::get<0>(views[1])) {
SkDebugf("Could not allocate dummy textures");
return false;
}
@@ -303,7 +305,7 @@
}
GrPaint paint;
- GrProcessorTestData ptd(&random, context, 2, proxies);
+ GrProcessorTestData ptd(&random, context, 2, views);
set_random_color_coverage_stages(&paint, &ptd, maxStages, maxLevels);
set_random_xpf(&paint, &ptd);
GrDrawRandomOp(&random, renderTargetContext.get(), std::move(paint));
@@ -325,7 +327,7 @@
for (int i = 0; i < fpFactoryCnt; ++i) {
// Since FP factories internally randomize, call each 10 times.
for (int j = 0; j < 10; ++j) {
- GrProcessorTestData ptd(&random, context, 2, proxies);
+ GrProcessorTestData ptd(&random, context, 2, views);
GrPaint paint;
paint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));