Remove all remaining uses of origin getter on proxy.
Bug: skia:9556
Change-Id: Id8a1ba9e46f4df9bb181d6b0e9248fe4bfc5b5a0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/270716
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrBitmapTextureMaker.cpp b/src/gpu/GrBitmapTextureMaker.cpp
index 0fb2e05..67a3281 100644
--- a/src/gpu/GrBitmapTextureMaker.cpp
+++ b/src/gpu/GrBitmapTextureMaker.cpp
@@ -81,7 +81,6 @@
swizzle = this->context()->priv().caps()->getReadSwizzle(proxy->backendFormat(),
this->colorType());
SkASSERT(!willBeMipped || GrMipMapped::kYes == proxy->mipMapped());
- SkASSERT(proxy->origin() == kTopLeft_GrSurfaceOrigin);
if (fOriginalKey.isValid()) {
proxyProvider->assignUniqueKeyToProxy(fOriginalKey, proxy.get());
GrInstallBitmapUniqueKeyInvalidator(
diff --git a/src/gpu/GrPathRendering.h b/src/gpu/GrPathRendering.h
index 3e143e4..839cb3d 100644
--- a/src/gpu/GrPathRendering.h
+++ b/src/gpu/GrPathRendering.h
@@ -94,17 +94,20 @@
struct StencilPathArgs {
StencilPathArgs(bool useHWAA,
GrRenderTargetProxy* proxy,
+ GrSurfaceOrigin origin,
const SkMatrix* viewMatrix,
const GrScissorState* scissor,
const GrStencilSettings* stencil)
: fUseHWAA(useHWAA)
, fProxy(proxy)
+ , fOrigin(origin)
, fViewMatrix(viewMatrix)
, fScissor(scissor)
, fStencil(stencil) {
}
bool fUseHWAA;
GrRenderTargetProxy* fProxy;
+ GrSurfaceOrigin fOrigin;
const SkMatrix* fViewMatrix;
const GrScissorState* fScissor;
const GrStencilSettings* fStencil;
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index ee301f9..a2c896c 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -105,7 +105,6 @@
GrTextureProxy* proxy = fUniquelyKeyedProxies.find(key);
if (proxy) {
- SkASSERT(proxy->origin() == origin);
return sk_ref_sp(proxy);
}
return nullptr;
diff --git a/src/gpu/GrProxyProvider.h b/src/gpu/GrProxyProvider.h
index 3ff5471..e89a373 100644
--- a/src/gpu/GrProxyProvider.h
+++ b/src/gpu/GrProxyProvider.h
@@ -65,6 +65,7 @@
/*
* Creates a new texture proxy for the bitmap, optionally with mip levels generated by the cpu.
+ * The bitmap is uploaded to the texture proxy assuming a kTopLeft_GrSurfaceOrigin.
*/
sk_sp<GrTextureProxy> createProxyFromBitmap(const SkBitmap& bitmap, GrMipMapped,
SkBackingFit fit);
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index 6a08e46..720e770 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -336,7 +336,6 @@
return nullptr;
}
- SkASSERT(proxy->origin() == kTopLeft_GrSurfaceOrigin);
return GrRenderTargetContext::Make(context, SkColorTypeToGrColorType(imageInfo.colorType()),
imageInfo.refColorSpace(), std::move(proxy),
kTopLeft_GrSurfaceOrigin, props);
diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp
index 5c4e04a..e5a1143 100644
--- a/src/gpu/GrSurfaceContext.cpp
+++ b/src/gpu/GrSurfaceContext.cpp
@@ -240,7 +240,7 @@
return tempCtx->readPixels(dstInfo, dst, rowBytes, {0, 0}, direct);
}
- bool flip = srcProxy->origin() == kBottomLeft_GrSurfaceOrigin;
+ bool flip = this->origin() == kBottomLeft_GrSurfaceOrigin;
auto supportedRead = caps->supportedReadPixelsColorType(
this->colorInfo().colorType(), srcProxy->backendFormat(), dstInfo.colorType());
@@ -378,7 +378,7 @@
// we can use a draw instead which doesn't have this origin restriction. Thus for render
// targets we will use top left and otherwise we will make the origins match.
GrSurfaceOrigin tempOrigin =
- this->asRenderTargetContext() ? kTopLeft_GrSurfaceOrigin : dstProxy->origin();
+ this->asRenderTargetContext() ? kTopLeft_GrSurfaceOrigin : this->origin();
auto tempProxy = direct->priv().proxyProvider()->createProxy(
format, srcInfo.dimensions(), tempReadSwizzle, GrRenderable::kNo, 1, tempOrigin,
GrMipMapped::kNo, SkBackingFit::kApprox, SkBudgeted::kYes, GrProtected::kNo);
@@ -436,7 +436,7 @@
caps->supportedWritePixelsColorType(this->colorInfo().colorType(),
dstProxy->backendFormat(),
srcInfo.colorType()).fColorType;
- bool flip = dstProxy->origin() == kBottomLeft_GrSurfaceOrigin;
+ bool flip = this->origin() == kBottomLeft_GrSurfaceOrigin;
bool makeTight = !caps->writePixelsRowBytesSupport() && rowBytes != tightRowBytes;
bool convert = premul || unpremul || needColorConversion || makeTight ||
(srcInfo.colorType() != allowedColorType) || flip;
@@ -709,7 +709,7 @@
return {};
}
auto srcRect = rect;
- bool flip = proxy->origin() == kBottomLeft_GrSurfaceOrigin;
+ bool flip = this->origin() == kBottomLeft_GrSurfaceOrigin;
if (flip) {
srcRect = SkIRect::MakeLTRB(rect.fLeft, this->height() - rect.fBottom, rect.fRight,
this->height() - rect.fTop);
diff --git a/src/gpu/GrSurfaceProxy.h b/src/gpu/GrSurfaceProxy.h
index 5ee5ba8..495e3e8 100644
--- a/src/gpu/GrSurfaceProxy.h
+++ b/src/gpu/GrSurfaceProxy.h
@@ -133,11 +133,6 @@
return SkRect::Make(this->backingStoreDimensions());
}
- GrSurfaceOrigin origin() const {
- SkASSERT(kTopLeft_GrSurfaceOrigin == fOrigin || kBottomLeft_GrSurfaceOrigin == fOrigin);
- return fOrigin;
- }
-
// Do not call this. It will shortly be removed and is just needed for a couple cases where we
// are getting a proxy from the cache and cannot be certain what the GrColorType of the proxy.
const GrSwizzle& textureSwizzleDoNotUse() const { return fTextureSwizzle; }
diff --git a/src/gpu/ccpr/GrCCClipPath.cpp b/src/gpu/ccpr/GrCCClipPath.cpp
index fc4f1f3..b01bda1 100644
--- a/src/gpu/ccpr/GrCCClipPath.cpp
+++ b/src/gpu/ccpr/GrCCClipPath.cpp
@@ -36,7 +36,6 @@
SkASSERT(texture);
SkASSERT(texture->backendFormat() == format);
SkASSERT(texture->asRenderTarget()->numSamples() == sampleCount);
- SkASSERT(textureProxy->origin() == kTopLeft_GrSurfaceOrigin);
fAtlasScale = {1.f / texture->width(), 1.f / texture->height()};
fAtlasTranslate.set(fDevToAtlasOffset.fX * fAtlasScale.x(),
diff --git a/src/gpu/gl/GrGLPathRendering.cpp b/src/gpu/gl/GrGLPathRendering.cpp
index af5e215..7d93a11 100644
--- a/src/gpu/gl/GrGLPathRendering.cpp
+++ b/src/gpu/gl/GrGLPathRendering.cpp
@@ -90,8 +90,8 @@
GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(args.fProxy->peekRenderTarget());
SkISize dimensions = rt->dimensions();
- this->setProjectionMatrix(*args.fViewMatrix, dimensions, args.fProxy->origin());
- gpu->flushScissor(*args.fScissor, rt->width(), rt->height(), args.fProxy->origin());
+ this->setProjectionMatrix(*args.fViewMatrix, dimensions, args.fOrigin);
+ gpu->flushScissor(*args.fScissor, rt->width(), rt->height(), args.fOrigin);
gpu->flushHWAAState(rt, args.fUseHWAA);
gpu->flushRenderTarget(rt);
diff --git a/src/gpu/ops/GrStencilPathOp.cpp b/src/gpu/ops/GrStencilPathOp.cpp
index 18fb37c..50baf5d 100644
--- a/src/gpu/ops/GrStencilPathOp.cpp
+++ b/src/gpu/ops/GrStencilPathOp.cpp
@@ -35,6 +35,7 @@
fHasStencilClip, numStencilBits);
GrPathRendering::StencilPathArgs args(fUseHWAA, state->drawOpArgs().proxy(),
+ state->drawOpArgs().origin(),
&fViewMatrix, &fScissor, &stencil);
state->gpu()->pathRendering()->stencilPath(args, fPath.get());
}
diff --git a/src/gpu/tessellate/GrDrawAtlasPathOp.cpp b/src/gpu/tessellate/GrDrawAtlasPathOp.cpp
index 5f6e88a..1b2aa8a 100644
--- a/src/gpu/tessellate/GrDrawAtlasPathOp.cpp
+++ b/src/gpu/tessellate/GrDrawAtlasPathOp.cpp
@@ -180,7 +180,7 @@
SkASSERT(shader.instanceStride() == Instance::Stride(fUsesLocalCoords));
GrProgramInfo programInfo(state->proxy()->numSamples(), state->proxy()->numStencilSamples(),
- state->proxy()->backendFormat(), state->proxy()->origin(), &pipeline,
+ state->proxy()->backendFormat(), state->view()->origin(), &pipeline,
&shader, &fixedDynamicState, nullptr, 0,
GrPrimitiveType::kTriangleStrip);
diff --git a/src/gpu/tessellate/GrDrawAtlasPathOp.h b/src/gpu/tessellate/GrDrawAtlasPathOp.h
index ab4e7cb..bb37cf7 100644
--- a/src/gpu/tessellate/GrDrawAtlasPathOp.h
+++ b/src/gpu/tessellate/GrDrawAtlasPathOp.h
@@ -22,7 +22,6 @@
, fAtlasProxy(std::move(atlasProxy))
, fInstanceList(devIBounds, devToAtlasOffset, paint.getColor4f(), viewMatrix)
, fProcessors(std::move(paint)) {
- SkASSERT(kTopLeft_GrSurfaceOrigin == fAtlasProxy->origin());
this->setBounds(SkRect::Make(devIBounds), HasAABloat::kYes, IsHairline::kNo);
}
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 18728a4..aae109cb 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -248,8 +248,6 @@
if (!proxy) {
return nullptr;
}
- // TODO: remove asserts when proxy doesn't hold origin or swizzle
- SkASSERT(proxy->origin() == kTopLeft_GrSurfaceOrigin);
GrSurfaceProxyView view(std::move(proxy));
SkColorType colorType = GrCompressionTypeToSkColorType(type);
diff --git a/src/image/SkImage_GpuBase.cpp b/src/image/SkImage_GpuBase.cpp
index 563d290..d757a64 100644
--- a/src/image/SkImage_GpuBase.cpp
+++ b/src/image/SkImage_GpuBase.cpp
@@ -224,7 +224,7 @@
direct->priv().flushSurface(proxy);
}
if (origin) {
- *origin = proxy->origin();
+ *origin = view->origin();
}
return texture->getBackendTexture();
}
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp
index 462b6d0..29b7c29 100644
--- a/tests/GrSurfaceTest.cpp
+++ b/tests/GrSurfaceTest.cpp
@@ -813,9 +813,9 @@
auto rt = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info, 0, nullptr);
auto rtc = rt->getCanvas()->internal_private_accessTopLayerRenderTargetContext();
auto proxy = context->priv().proxyProvider()->testingOnly_createWrapped(
- std::move(idleTexture), GrColorType::kRGBA_8888, rtc->asSurfaceProxy()->origin());
+ std::move(idleTexture), GrColorType::kRGBA_8888, rtc->origin());
context->flush();
- SkAssertResult(rtc->testCopy(proxy.get(), rtc->asSurfaceProxy()->origin()));
+ SkAssertResult(rtc->testCopy(proxy.get(), rtc->origin()));
proxy.reset();
REPORTER_ASSERT(reporter, flags == 0);
diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp
index 4d3e663..368961c 100644
--- a/tests/ProxyTest.cpp
+++ b/tests/ProxyTest.cpp
@@ -28,10 +28,8 @@
// Check that the surface proxy's member vars are set as expected
static void check_surface(skiatest::Reporter* reporter,
GrSurfaceProxy* proxy,
- GrSurfaceOrigin origin,
int width, int height,
SkBudgeted budgeted) {
- REPORTER_ASSERT(reporter, proxy->origin() == origin);
REPORTER_ASSERT(reporter, proxy->width() == width);
REPORTER_ASSERT(reporter, proxy->height() == height);
REPORTER_ASSERT(reporter, !proxy->uniqueID().isInvalid());
@@ -156,8 +154,8 @@
// pre-instantiation size then the check is skipped.
proxy->gpuMemorySize(caps);
- check_surface(reporter, proxy.get(), origin,
- widthHeight, widthHeight, budgeted);
+ check_surface(reporter, proxy.get(), widthHeight, widthHeight,
+ budgeted);
int supportedSamples =
caps.getRenderTargetSampleCount(numSamples, format);
check_rendertarget(reporter, caps, resourceProvider,
@@ -192,8 +190,8 @@
// pre-instantiation size then the check is skipped.
proxy->gpuMemorySize(caps);
- check_surface(reporter, proxy.get(), origin,
- widthHeight, widthHeight, budgeted);
+ check_surface(reporter, proxy.get(), widthHeight, widthHeight,
+ budgeted);
check_texture(reporter, resourceProvider,
proxy->asTextureProxy(), fit);
}
@@ -232,8 +230,7 @@
sk_sp<GrSurfaceProxy> sProxy(
proxyProvider->wrapBackendRenderTarget(backendRT, grColorType,
origin, nullptr, nullptr));
- check_surface(reporter, sProxy.get(), origin, kWidthHeight, kWidthHeight,
- SkBudgeted::kNo);
+ check_surface(reporter, sProxy.get(), kWidthHeight, kWidthHeight, SkBudgeted::kNo);
static constexpr int kExpectedNumSamples = 1;
check_rendertarget(reporter, caps, resourceProvider, sProxy->asRenderTargetProxy(),
kExpectedNumSamples, SkBackingFit::kExact,
@@ -262,8 +259,8 @@
sk_sp<GrSurfaceProxy> sProxy(
proxyProvider->wrapBackendRenderTarget(backendRT, grColorType,
origin, nullptr, nullptr));
- check_surface(reporter, sProxy.get(), origin,
- kWidthHeight, kWidthHeight, SkBudgeted::kNo);
+ check_surface(reporter, sProxy.get(), kWidthHeight, kWidthHeight,
+ SkBudgeted::kNo);
check_rendertarget(reporter, caps, resourceProvider,
sProxy->asRenderTargetProxy(),
supportedNumSamples, SkBackingFit::kExact, 0);
@@ -286,8 +283,8 @@
continue; // This can fail on Mesa
}
- check_surface(reporter, sProxy.get(), origin,
- kWidthHeight, kWidthHeight, SkBudgeted::kNo);
+ check_surface(reporter, sProxy.get(), kWidthHeight, kWidthHeight,
+ SkBudgeted::kNo);
check_rendertarget(reporter, caps, resourceProvider,
sProxy->asRenderTargetProxy(),
supportedNumSamples, SkBackingFit::kExact,
@@ -315,8 +312,8 @@
continue; // This can fail on Mesa
}
- check_surface(reporter, sProxy.get(), origin,
- kWidthHeight, kWidthHeight, SkBudgeted::kNo);
+ check_surface(reporter, sProxy.get(), kWidthHeight, kWidthHeight,
+ SkBudgeted::kNo);
check_rendertarget(reporter, caps, resourceProvider,
sProxy->asRenderTargetProxy(),
supportedNumSamples, SkBackingFit::kExact,
@@ -344,8 +341,8 @@
continue;
}
- check_surface(reporter, sProxy.get(), origin,
- kWidthHeight, kWidthHeight, SkBudgeted::kNo);
+ check_surface(reporter, sProxy.get(), kWidthHeight, kWidthHeight,
+ SkBudgeted::kNo);
check_texture(reporter, resourceProvider, sProxy->asTextureProxy(),
SkBackingFit::kExact);
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index 845bee8..2070d53 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -108,7 +108,7 @@
}
for (auto renderable : {GrRenderable::kNo, GrRenderable::kYes}) {
- auto origin = dstContext->asSurfaceProxy()->origin();
+ auto origin = dstContext->origin();
auto src = sk_gpu_test::MakeTextureProxyFromData(
context, renderable, origin,
{GrColorType::kRGBA_8888, kPremul_SkAlphaType, nullptr, dstContext->width(),