aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-07-21 15:37:19 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-24 13:05:29 +0000
commite44ef10ebbc7f64b627a9ac3a562bd87b3001b0c (patch)
treec18b1b3d41f1ef0c6a2133a45d3b697e0071eba8
parent40e7e655341c5bf56e398cd2f5902dda79d702a0 (diff)
Second small fragment from "Reduce dependence on GrSurface's origin field"
TBR=bsalomon@google.com Change-Id: Ifcfe56b1117b64821b2bfc34ba36d120227d15fa Reviewed-on: https://skia-review.googlesource.com/25802 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
-rw-r--r--gm/image_pict.cpp3
-rw-r--r--gm/texturedomaineffect.cpp1
-rw-r--r--src/core/SkColorSpaceXformImageGenerator.cpp3
-rw-r--r--src/core/SkPictureImageGenerator.cpp3
-rw-r--r--src/gpu/GrResourceProvider.h2
-rw-r--r--src/gpu/GrSoftwarePathRenderer.cpp1
-rw-r--r--src/gpu/GrTextureProducer.cpp3
-rw-r--r--src/gpu/GrYUVProvider.cpp9
-rw-r--r--src/gpu/ccpr/GrCCPRPathProcessor.cpp6
-rw-r--r--src/gpu/ccpr/GrCCPRPathProcessor.h1
-rw-r--r--src/gpu/effects/GrTextureStripAtlas.cpp12
-rw-r--r--tests/ImageFilterCacheTest.cpp3
-rw-r--r--tests/ProcessorTest.cpp3
-rw-r--r--tests/ProxyRefTest.cpp1
-rw-r--r--tests/ReadWriteAlphaTest.cpp2
-rw-r--r--tests/ResourceCacheTest.cpp2
-rw-r--r--tests/SRGBMipMapTest.cpp1
-rw-r--r--tests/SpecialImageTest.cpp3
-rw-r--r--tests/SurfaceTest.cpp6
19 files changed, 43 insertions, 22 deletions
diff --git a/gm/image_pict.cpp b/gm/image_pict.cpp
index 4a77797061..7b8adf1d45 100644
--- a/gm/image_pict.cpp
+++ b/gm/image_pict.cpp
@@ -152,7 +152,8 @@ public:
: SkImageGenerator(info)
, fCtx(SkRef(ctx)) {
- sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info));
+ sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info, 0,
+ kTopLeft_GrSurfaceOrigin, nullptr));
if (surface) {
surface->getCanvas()->clear(0);
surface->getCanvas()->translate(-100, -100);
diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp
index 3fa835bd65..68260dee0f 100644
--- a/gm/texturedomaineffect.cpp
+++ b/gm/texturedomaineffect.cpp
@@ -86,6 +86,7 @@ protected:
}
GrSurfaceDesc desc;
+ desc.fOrigin = kTopLeft_GrSurfaceOrigin;
desc.fWidth = fBmp.width();
desc.fHeight = fBmp.height();
desc.fConfig = SkImageInfo2GrPixelConfig(fBmp.info(), *context->caps());
diff --git a/src/core/SkColorSpaceXformImageGenerator.cpp b/src/core/SkColorSpaceXformImageGenerator.cpp
index 707de08b72..5cd1d1d0f2 100644
--- a/src/core/SkColorSpaceXformImageGenerator.cpp
+++ b/src/core/SkColorSpaceXformImageGenerator.cpp
@@ -86,7 +86,8 @@ sk_sp<GrTextureProxy> SkColorSpaceXformImageGenerator::onGenerateTexture(
}
sk_sp<GrRenderTargetContext> renderTargetContext = ctx->makeDeferredRenderTargetContext(
- SkBackingFit::kExact, fSrc.width(), fSrc.height(), kRGBA_8888_GrPixelConfig, nullptr);
+ SkBackingFit::kExact, fSrc.width(), fSrc.height(), kRGBA_8888_GrPixelConfig, nullptr,
+ 0, kTopLeft_GrSurfaceOrigin);
if (!renderTargetContext) {
return nullptr;
}
diff --git a/src/core/SkPictureImageGenerator.cpp b/src/core/SkPictureImageGenerator.cpp
index 1f60380b8d..75861329d6 100644
--- a/src/core/SkPictureImageGenerator.cpp
+++ b/src/core/SkPictureImageGenerator.cpp
@@ -110,7 +110,8 @@ sk_sp<GrTextureProxy> SkPictureImageGenerator::onGenerateTexture(
// TODO: respect the usage, by possibly creating a different (pow2) surface
//
SkImageInfo surfaceInfo = useXformCanvas ? info.makeColorSpace(nullptr) : info;
- sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kYes, surfaceInfo));
+ sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kYes, surfaceInfo,
+ 0, kTopLeft_GrSurfaceOrigin, nullptr));
if (!surface) {
return nullptr;
}
diff --git a/src/gpu/GrResourceProvider.h b/src/gpu/GrResourceProvider.h
index 44155a834f..b553cc4a98 100644
--- a/src/gpu/GrResourceProvider.h
+++ b/src/gpu/GrResourceProvider.h
@@ -53,6 +53,8 @@ public:
void assignUniqueKeyToProxy(const GrUniqueKey& key, GrTextureProxy*);
/** Finds a texture by unique key. If the texture is found it is ref'ed and returned. */
+ // MDB TODO (caching): If this were actually caching proxies (rather than shallowly
+ // wrapping GrSurface caching) we would not need the origin parameter.
sk_sp<GrTextureProxy> findProxyByUniqueKey(const GrUniqueKey& key);
/**
diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp
index e171b78b4a..2199529739 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/GrSoftwarePathRenderer.cpp
@@ -217,6 +217,7 @@ bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
return false;
}
if (useCache) {
+ SkASSERT(proxy->origin() == kTopLeft_GrSurfaceOrigin);
fResourceProvider->assignUniqueKeyToProxy(maskKey, proxy.get());
}
}
diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp
index 276dc10f02..78d143b435 100644
--- a/src/gpu/GrTextureProducer.cpp
+++ b/src/gpu/GrTextureProducer.cpp
@@ -24,7 +24,8 @@ sk_sp<GrTextureProxy> GrTextureProducer::CopyOnGpu(GrContext* context,
const SkRect dstRect = SkRect::MakeIWH(copyParams.fWidth, copyParams.fHeight);
sk_sp<GrRenderTargetContext> copyRTC = context->makeDeferredRenderTargetContextWithFallback(
- SkBackingFit::kExact, dstRect.width(), dstRect.height(), inputProxy->config(), nullptr);
+ SkBackingFit::kExact, dstRect.width(), dstRect.height(), inputProxy->config(), nullptr,
+ 0, inputProxy->origin());
if (!copyRTC) {
return nullptr;
}
diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp
index 341b711fbf..12390aaab0 100644
--- a/src/gpu/GrYUVProvider.cpp
+++ b/src/gpu/GrYUVProvider.cpp
@@ -124,10 +124,11 @@ sk_sp<GrTextureProxy> GrYUVProvider::refAsTextureProxy(GrContext* ctx, const GrS
// We never want to perform color-space conversion during the decode
sk_sp<GrRenderTargetContext> renderTargetContext(ctx->makeDeferredRenderTargetContext(
- SkBackingFit::kExact,
- desc.fWidth, desc.fHeight,
- desc.fConfig, nullptr,
- desc.fSampleCnt));
+ SkBackingFit::kExact,
+ desc.fWidth, desc.fHeight,
+ desc.fConfig, nullptr,
+ desc.fSampleCnt,
+ kTopLeft_GrSurfaceOrigin));
if (!renderTargetContext) {
return nullptr;
}
diff --git a/src/gpu/ccpr/GrCCPRPathProcessor.cpp b/src/gpu/ccpr/GrCCPRPathProcessor.cpp
index bc2e45cb24..6efaecf9f9 100644
--- a/src/gpu/ccpr/GrCCPRPathProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPRPathProcessor.cpp
@@ -86,7 +86,7 @@ GrCCPRPathProcessor::GrCCPRPathProcessor(GrResourceProvider* rp, sk_sp<GrTexture
}
void GrCCPRPathProcessor::getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder* b) const {
- b->add32((fFillType << 16) | this->atlas()->origin());
+ b->add32((fFillType << 16) | this->atlasProxy()->origin());
}
class GLSLPathProcessor : public GrGLSLGeometryProcessor {
@@ -161,10 +161,10 @@ void GLSLPathProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
// Convert to atlas coordinates in order to do our texture lookup.
v->codeAppendf("highp vec2 atlascoord = octocoord + vec2(%s);",
proc.getInstanceAttrib(InstanceAttribs::kAtlasOffset).fName);
- if (kTopLeft_GrSurfaceOrigin == proc.atlas()->origin()) {
+ if (kTopLeft_GrSurfaceOrigin == proc.atlasProxy()->origin()) {
v->codeAppendf("%s = atlascoord * %s;", texcoord.vsOut(), atlasAdjust);
} else {
- SkASSERT(kBottomLeft_GrSurfaceOrigin == proc.atlas()->origin());
+ SkASSERT(kBottomLeft_GrSurfaceOrigin == proc.atlasProxy()->origin());
v->codeAppendf("%s = vec2(atlascoord.x * %s.x, 1 - atlascoord.y * %s.y);",
texcoord.vsOut(), atlasAdjust, atlasAdjust);
}
diff --git a/src/gpu/ccpr/GrCCPRPathProcessor.h b/src/gpu/ccpr/GrCCPRPathProcessor.h
index a74455bc8e..dbc1e5847e 100644
--- a/src/gpu/ccpr/GrCCPRPathProcessor.h
+++ b/src/gpu/ccpr/GrCCPRPathProcessor.h
@@ -58,6 +58,7 @@ public:
const GrShaderCaps&);
const char* name() const override { return "GrCCPRPathProcessor"; }
+ const GrSurfaceProxy* atlasProxy() const { return fAtlasAccess.proxy(); }
const GrTexture* atlas() const { return fAtlasAccess.peekTexture(); }
SkPath::FillType fillType() const { return fFillType; }
const Attribute& getInstanceAttrib(InstanceAttribs attribID) const {
diff --git a/src/gpu/effects/GrTextureStripAtlas.cpp b/src/gpu/effects/GrTextureStripAtlas.cpp
index 72817b2133..d0c6e47e1c 100644
--- a/src/gpu/effects/GrTextureStripAtlas.cpp
+++ b/src/gpu/effects/GrTextureStripAtlas.cpp
@@ -193,11 +193,6 @@ GrTextureStripAtlas::AtlasRow* GrTextureStripAtlas::getLRU() {
}
void GrTextureStripAtlas::lockTexture() {
- GrSurfaceDesc texDesc;
- texDesc.fOrigin = kTopLeft_GrSurfaceOrigin;
- texDesc.fWidth = fDesc.fWidth;
- texDesc.fHeight = fDesc.fHeight;
- texDesc.fConfig = fDesc.fConfig;
static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
GrUniqueKey key;
@@ -207,6 +202,12 @@ void GrTextureStripAtlas::lockTexture() {
sk_sp<GrTextureProxy> proxy = fDesc.fContext->resourceProvider()->findProxyByUniqueKey(key);
if (!proxy) {
+ GrSurfaceDesc texDesc;
+ texDesc.fOrigin = kTopLeft_GrSurfaceOrigin;
+ texDesc.fWidth = fDesc.fWidth;
+ texDesc.fHeight = fDesc.fHeight;
+ texDesc.fConfig = fDesc.fConfig;
+
proxy = GrSurfaceProxy::MakeDeferred(fDesc.fContext->resourceProvider(),
texDesc, SkBackingFit::kExact,
SkBudgeted::kYes,
@@ -215,6 +216,7 @@ void GrTextureStripAtlas::lockTexture() {
return;
}
+ SkASSERT(proxy->origin() == kTopLeft_GrSurfaceOrigin);
fDesc.fContext->resourceProvider()->assignUniqueKeyToProxy(key, proxy.get());
// This is a new texture, so all of our cache info is now invalid
this->initLRU();
diff --git a/tests/ImageFilterCacheTest.cpp b/tests/ImageFilterCacheTest.cpp
index d718181758..86ecb15f6e 100644
--- a/tests/ImageFilterCacheTest.cpp
+++ b/tests/ImageFilterCacheTest.cpp
@@ -190,8 +190,9 @@ static sk_sp<GrTextureProxy> create_proxy(GrResourceProvider* resourceProvider)
SkBitmap srcBM = create_bm();
GrSurfaceDesc desc;
- desc.fConfig = kRGBA_8888_GrPixelConfig;
desc.fFlags = kNone_GrSurfaceFlags;
+ desc.fOrigin = kTopLeft_GrSurfaceOrigin;
+ desc.fConfig = kRGBA_8888_GrPixelConfig;
desc.fWidth = kFullSize;
desc.fHeight = kFullSize;
diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp
index fd025a0cb4..eac6aab274 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -302,9 +302,10 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor
sk_sp<GrRenderTargetContext> rtc = context->makeDeferredRenderTargetContext(
SkBackingFit::kExact, 256, 256, kRGBA_8888_GrPixelConfig, nullptr);
GrSurfaceDesc desc;
+ desc.fFlags = kRenderTarget_GrSurfaceFlag;
+ desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
desc.fWidth = 256;
desc.fHeight = 256;
- desc.fFlags = kRenderTarget_GrSurfaceFlag;
desc.fConfig = kRGBA_8888_GrPixelConfig;
sk_sp<GrTextureProxy> proxies[2];
diff --git a/tests/ProxyRefTest.cpp b/tests/ProxyRefTest.cpp
index 04510b3e7f..a30766b838 100644
--- a/tests/ProxyRefTest.cpp
+++ b/tests/ProxyRefTest.cpp
@@ -80,6 +80,7 @@ static sk_sp<GrTextureProxy> make_deferred(GrContext* context) {
static sk_sp<GrTextureProxy> make_wrapped(GrContext* context) {
GrSurfaceDesc desc;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
+ desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
desc.fWidth = kWidthHeight;
desc.fHeight = kWidthHeight;
desc.fConfig = kRGBA_8888_GrPixelConfig;
diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp
index 344400cca7..2e5a1dc12d 100644
--- a/tests/ReadWriteAlphaTest.cpp
+++ b/tests/ReadWriteAlphaTest.cpp
@@ -50,6 +50,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
{
GrSurfaceDesc desc;
desc.fFlags = kNone_GrSurfaceFlags;
+ desc.fOrigin = kTopLeft_GrSurfaceOrigin;
desc.fConfig = kAlpha_8_GrPixelConfig; // it is a single channel texture
desc.fWidth = X_SIZE;
desc.fHeight = Y_SIZE;
@@ -153,6 +154,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
for (int rt = 0; rt < 2; ++rt) {
GrSurfaceDesc desc;
desc.fFlags = rt ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlags;
+ desc.fOrigin = rt ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOrigin;
desc.fConfig = config;
desc.fWidth = X_SIZE;
desc.fHeight = Y_SIZE;
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index b018b8f33a..b27aaea9f7 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -1673,6 +1673,8 @@ static sk_sp<GrTextureProxy> make_mipmap_proxy(GrResourceProvider* provider,
GrSurfaceDesc desc;
desc.fFlags = flags;
+ desc.fOrigin = (flags & kRenderTarget_GrSurfaceFlag) ? kBottomLeft_GrSurfaceOrigin
+ : kTopLeft_GrSurfaceOrigin;
desc.fWidth = width;
desc.fHeight = height;
desc.fConfig = kRGBA_8888_GrPixelConfig;
diff --git a/tests/SRGBMipMapTest.cpp b/tests/SRGBMipMapTest.cpp
index 8d035e1589..07332e4282 100644
--- a/tests/SRGBMipMapTest.cpp
+++ b/tests/SRGBMipMapTest.cpp
@@ -124,6 +124,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SRGBMipMaps, reporter, ctxInfo) {
// Create our test texture
GrSurfaceDesc desc;
desc.fFlags = kNone_GrSurfaceFlags;
+ desc.fOrigin = kTopLeft_GrSurfaceOrigin;
desc.fConfig = kSRGBA_8888_GrPixelConfig;
desc.fWidth = texS;
desc.fHeight = texS;
diff --git a/tests/SpecialImageTest.cpp b/tests/SpecialImageTest.cpp
index 70d6fd4b38..3574f38129 100644
--- a/tests/SpecialImageTest.cpp
+++ b/tests/SpecialImageTest.cpp
@@ -301,8 +301,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_DeferredGpu, reporter, ctxInfo)
SkBitmap bm = create_bm();
GrSurfaceDesc desc;
- desc.fConfig = kSkia8888_GrPixelConfig;
desc.fFlags = kNone_GrSurfaceFlags;
+ desc.fOrigin = kTopLeft_GrSurfaceOrigin;
+ desc.fConfig = kSkia8888_GrPixelConfig;
desc.fWidth = kFullSize;
desc.fHeight = kFullSize;
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index 5249b3d562..797750f3b1 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -599,7 +599,7 @@ static sk_sp<SkSurface> create_gpu_surface_backend_texture(
backendHandle);
sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTexture(context, backendTex,
- kDefault_GrSurfaceOrigin, sampleCnt,
+ kTopLeft_GrSurfaceOrigin, sampleCnt,
nullptr, nullptr);
if (!surface) {
context->getGpu()->deleteTestingOnlyBackendTexture(backendHandle);
@@ -625,7 +625,7 @@ static sk_sp<SkSurface> create_gpu_surface_backend_texture_as_render_target(
kRGBA_8888_GrPixelConfig,
backendHandle);
sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTextureAsRenderTarget(
- context, backendTex, kDefault_GrSurfaceOrigin, sampleCnt, nullptr, nullptr);
+ context, backendTex, kTopLeft_GrSurfaceOrigin, sampleCnt, nullptr, nullptr);
if (!surface) {
context->getGpu()->deleteTestingOnlyBackendTexture(backendHandle);
@@ -907,7 +907,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCreationWithColorSpace_Gpu, reporter,
backendHandle);
return SkSurface::MakeFromBackendTexture(context, backendTex,
- kDefault_GrSurfaceOrigin, 0,
+ kTopLeft_GrSurfaceOrigin, 0,
sk_ref_sp(info.colorSpace()), nullptr);
};