aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/private/GrSurfaceProxy.h3
-rw-r--r--src/gpu/GrBackendTextureImageGenerator.cpp2
-rw-r--r--src/gpu/GrProxyProvider.cpp9
-rw-r--r--src/gpu/GrProxyProvider.h9
-rw-r--r--src/gpu/GrSurfaceProxy.cpp18
-rw-r--r--src/gpu/ccpr/GrCCAtlas.cpp2
-rw-r--r--src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp11
-rw-r--r--tests/LazyProxyTest.cpp35
8 files changed, 39 insertions, 50 deletions
diff --git a/include/private/GrSurfaceProxy.h b/include/private/GrSurfaceProxy.h
index daff54798f..34dfcd00c6 100644
--- a/include/private/GrSurfaceProxy.h
+++ b/include/private/GrSurfaceProxy.h
@@ -361,8 +361,7 @@ protected:
// Note: this ctor pulls a new uniqueID from the same pool at the GrGpuResources
}
- using LazyInstantiateCallback = std::function<sk_sp<GrSurface>(GrResourceProvider*,
- GrSurfaceOrigin* outOrigin)>;
+ using LazyInstantiateCallback = std::function<sk_sp<GrSurface>(GrResourceProvider*)>;
// Lazy-callback version
GrSurfaceProxy(LazyInstantiateCallback&& callback, LazyInstantiationType lazyType,
diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp
index b8d2474f7e..90f006ae3f 100644
--- a/src/gpu/GrBackendTextureImageGenerator.cpp
+++ b/src/gpu/GrBackendTextureImageGenerator.cpp
@@ -136,7 +136,7 @@ sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture(
sk_sp<GrTextureProxy> proxy = proxyProvider->createLazyProxy(
[refHelper, releaseProcHelper, semaphore, backendTexture]
- (GrResourceProvider* resourceProvider, GrSurfaceOrigin* /*outOrigin*/) {
+ (GrResourceProvider* resourceProvider) {
if (!resourceProvider) {
return sk_sp<GrTexture>();
}
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index e000dd4979..d051bfdc13 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -221,7 +221,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::createTextureProxy(sk_sp<SkImage> srcImag
sk_sp<GrTextureProxy> proxy = this->createLazyProxy(
[desc, budgeted, srcImage, fit]
- (GrResourceProvider* resourceProvider, GrSurfaceOrigin* /*outOrigin*/) {
+ (GrResourceProvider* resourceProvider) {
if (!resourceProvider) {
// Nothing to clean up here. Once the proxy (and thus lambda) is deleted the ref
// on srcImage will be released.
@@ -322,7 +322,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxyFromBitmap(const SkBitma
sk_sp<GrTextureProxy> proxy = this->createLazyProxy(
[desc, baseLevel, mipmaps, mipColorMode]
- (GrResourceProvider* resourceProvider, GrSurfaceOrigin* /*outOrigin*/) {
+ (GrResourceProvider* resourceProvider) {
if (!resourceProvider) {
return sk_sp<GrTexture>();
}
@@ -409,7 +409,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::createWrappedTextureProxy(
sk_sp<GrTextureProxy> proxy = this->createLazyProxy(
[backendTex, ownership, releaseHelper]
- (GrResourceProvider* resourceProvider, GrSurfaceOrigin* /*outOrigin*/) {
+ (GrResourceProvider* resourceProvider) {
if (!resourceProvider) {
// If this had a releaseHelper it will get unrefed when we delete this lambda
// and will call the release proc so that the client knows they can free the
@@ -540,12 +540,13 @@ sk_sp<GrRenderTargetProxy> GrProxyProvider::createLazyRenderTargetProxy(
sk_sp<GrTextureProxy> GrProxyProvider::createFullyLazyProxy(LazyInstantiateCallback&& callback,
Renderable renderable,
+ GrSurfaceOrigin origin,
GrPixelConfig config) {
GrSurfaceDesc desc;
if (Renderable::kYes == renderable) {
desc.fFlags = kRenderTarget_GrSurfaceFlag;
}
- desc.fOrigin = kTopLeft_GrSurfaceOrigin;
+ desc.fOrigin = origin;
desc.fWidth = -1;
desc.fHeight = -1;
desc.fConfig = config;
diff --git a/src/gpu/GrProxyProvider.h b/src/gpu/GrProxyProvider.h
index 48037584c5..7e7f852d91 100644
--- a/src/gpu/GrProxyProvider.h
+++ b/src/gpu/GrProxyProvider.h
@@ -141,8 +141,7 @@ public:
GrSurfaceOrigin origin,
int sampleCnt);
- using LazyInstantiateCallback = std::function<sk_sp<GrSurface>(GrResourceProvider*,
- GrSurfaceOrigin* outOrigin)>;
+ using LazyInstantiateCallback = std::function<sk_sp<GrSurface>(GrResourceProvider*)>;
enum class Textureable : bool {
kNo = false,
kYes = true
@@ -166,8 +165,12 @@ public:
sk_sp<GrTextureProxy> createLazyProxy(LazyInstantiateCallback&&, const GrSurfaceDesc&,
GrMipMapped, SkBackingFit, SkBudgeted);
+ /**
+ * Fully lazy proxies have unspecified width and height. Methods that rely on those values
+ * (e.g., width, height, getBoundsRect) should be avoided.
+ */
sk_sp<GrTextureProxy> createFullyLazyProxy(LazyInstantiateCallback&&,
- Renderable, GrPixelConfig);
+ Renderable, GrSurfaceOrigin, GrPixelConfig);
sk_sp<GrRenderTargetProxy> createLazyRenderTargetProxy(LazyInstantiateCallback&&,
const GrSurfaceDesc&, Textureable,
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index 6c81fc0bec..48d4be1c8a 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -87,7 +87,7 @@ GrSurfaceProxy::~GrSurfaceProxy() {
if (fLazyInstantiateCallback) {
// We call the callback with a null GrResourceProvider to signal that the lambda should
// clean itself up if it is holding onto any captured objects.
- this->fLazyInstantiateCallback(nullptr, nullptr);
+ this->fLazyInstantiateCallback(nullptr);
}
// For this to be deleted the opList that held a ref on it (if there was one) must have been
// deleted. Which would have cleared out this back pointer.
@@ -353,26 +353,14 @@ void GrSurfaceProxyPriv::exactify() {
bool GrSurfaceProxyPriv::doLazyInstantiation(GrResourceProvider* resourceProvider) {
SkASSERT(GrSurfaceProxy::LazyState::kNot != fProxy->lazyInstantiationState());
- GrSurfaceOrigin* outOrigin;
- if (GrSurfaceProxy::LazyState::kPartially == fProxy->lazyInstantiationState()) {
- // In the partially instantiated case, we set the origin on the SurfaceProxy at creation
- // time (via a GrSurfaceDesc). In the lambda, the creation of the texture never needs to
- // know the origin, and it also can't change or have any effect on it. Thus we just pass in
- // nullptr in this case since it should never be set.
- outOrigin = nullptr;
- } else {
- outOrigin = &fProxy->fOrigin;
- }
-
- sk_sp<GrSurface> surface = fProxy->fLazyInstantiateCallback(resourceProvider, outOrigin);
+ sk_sp<GrSurface> surface = fProxy->fLazyInstantiateCallback(resourceProvider);
if (GrSurfaceProxy::LazyInstantiationType::kSingleUse == fProxy->fLazyInstantiationType) {
- fProxy->fLazyInstantiateCallback(nullptr, nullptr);
+ fProxy->fLazyInstantiateCallback(nullptr);
fProxy->fLazyInstantiateCallback = nullptr;
}
if (!surface) {
fProxy->fWidth = 0;
fProxy->fHeight = 0;
- fProxy->fOrigin = kTopLeft_GrSurfaceOrigin;
return false;
}
diff --git a/src/gpu/ccpr/GrCCAtlas.cpp b/src/gpu/ccpr/GrCCAtlas.cpp
index 5ef39f85cb..97b28fb480 100644
--- a/src/gpu/ccpr/GrCCAtlas.cpp
+++ b/src/gpu/ccpr/GrCCAtlas.cpp
@@ -138,6 +138,8 @@ sk_sp<GrRenderTargetContext> GrCCAtlas::finalize(GrOnFlushResourceProvider* onFl
SkASSERT(!fTextureProxy);
GrSurfaceDesc desc;
+ desc.fFlags = kRenderTarget_GrSurfaceFlag;
+ desc.fOrigin = kTopLeft_GrSurfaceOrigin;
desc.fWidth = fWidth;
desc.fHeight = fHeight;
desc.fConfig = kAlpha_half_GrPixelConfig;
diff --git a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
index da6991745f..ec3681dfcf 100644
--- a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
+++ b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
@@ -229,7 +229,7 @@ void CCPR::ClipPath::init(GrProxyProvider* proxyProvider,
SkASSERT(this->isUninitialized());
fAtlasLazyProxy = proxyProvider->createFullyLazyProxy(
- [this](GrResourceProvider* resourceProvider, GrSurfaceOrigin* outOrigin) {
+ [this](GrResourceProvider* resourceProvider) {
if (!resourceProvider) {
return sk_sp<GrTexture>();
}
@@ -243,19 +243,16 @@ void CCPR::ClipPath::init(GrProxyProvider* proxyProvider,
return sk_sp<GrTexture>();
}
+ SkASSERT(kTopLeft_GrSurfaceOrigin == textureProxy->origin());
+
fAtlasScale = {1.f / textureProxy->width(), 1.f / textureProxy->height()};
fAtlasTranslate = {fAtlasOffsetX * fAtlasScale.x(),
fAtlasOffsetY * fAtlasScale.y()};
- if (kBottomLeft_GrSurfaceOrigin == textureProxy->origin()) {
- fAtlasScale.fY = -fAtlasScale.y();
- fAtlasTranslate.fY = 1 - fAtlasTranslate.y();
- }
SkDEBUGCODE(fHasAtlasTransform = true);
- *outOrigin = textureProxy->origin();
return sk_ref_sp(textureProxy->priv().peekTexture());
},
- GrProxyProvider::Renderable::kYes, kAlpha_half_GrPixelConfig);
+ GrProxyProvider::Renderable::kYes, kTopLeft_GrSurfaceOrigin, kAlpha_half_GrPixelConfig);
const SkRect& pathDevBounds = deviceSpacePath.getBounds();
if (SkTMax(pathDevBounds.height(), pathDevBounds.width()) > kPathCropThreshold) {
diff --git a/tests/LazyProxyTest.cpp b/tests/LazyProxyTest.cpp
index 5a0211d717..aca9b56e13 100644
--- a/tests/LazyProxyTest.cpp
+++ b/tests/LazyProxyTest.cpp
@@ -58,13 +58,12 @@ public:
Op(GrProxyProvider* proxyProvider, LazyProxyTest* test, bool nullTexture)
: GrDrawOp(ClassID()), fTest(test) {
fProxy = proxyProvider->createFullyLazyProxy([this, nullTexture](
- GrResourceProvider* rp, GrSurfaceOrigin* origin) {
+ GrResourceProvider* rp) {
if (!rp) {
return sk_sp<GrTexture>();
}
REPORTER_ASSERT(fTest->fReporter, !fTest->fHasOpTexture);
fTest->fHasOpTexture = true;
- *origin = kTopLeft_GrSurfaceOrigin;
if (nullTexture) {
return sk_sp<GrTexture>();
} else {
@@ -77,7 +76,7 @@ public:
REPORTER_ASSERT(fTest->fReporter, texture);
return texture;
}
- }, GrProxyProvider::Renderable::kNo, kRGB_565_GrPixelConfig);
+ }, GrProxyProvider::Renderable::kNo, kTopLeft_GrSurfaceOrigin, kRGB_565_GrPixelConfig);
this->setBounds(SkRectPriv::MakeLargest(), GrOp::HasAABloat::kNo, GrOp::IsZeroArea::kNo);
}
@@ -112,17 +111,19 @@ public:
, fProxyProvider(proxyProvider)
, fTest(test)
, fAtlas(atlas) {
- fLazyProxy = proxyProvider->createFullyLazyProxy([this](GrResourceProvider* rp,
- GrSurfaceOrigin* origin) {
- if (!rp) {
- return sk_sp<GrTexture>();
- }
- REPORTER_ASSERT(fTest->fReporter, !fTest->fHasClipTexture);
- fTest->fHasClipTexture = true;
- *origin = kBottomLeft_GrSurfaceOrigin;
- fAtlas->instantiate(rp);
- return sk_ref_sp(fAtlas->priv().peekTexture());
- }, GrProxyProvider::Renderable::kYes, kAlpha_half_GrPixelConfig);
+ fLazyProxy = proxyProvider->createFullyLazyProxy(
+ [this](GrResourceProvider* rp) {
+ if (!rp) {
+ return sk_sp<GrTexture>();
+ }
+ REPORTER_ASSERT(fTest->fReporter, !fTest->fHasClipTexture);
+ fTest->fHasClipTexture = true;
+ fAtlas->instantiate(rp);
+ return sk_ref_sp(fAtlas->priv().peekTexture());
+ },
+ GrProxyProvider::Renderable::kYes,
+ kBottomLeft_GrSurfaceOrigin,
+ kAlpha_half_GrPixelConfig);
fAccess.reset(fLazyProxy, GrSamplerState::Filter::kNearest,
GrSamplerState::WrapMode::kClamp, kFragment_GrShaderFlag);
this->addTextureSampler(&fAccess);
@@ -220,8 +221,7 @@ DEF_GPUTEST(LazyProxyReleaseTest, reporter, /* options */) {
int testCount = 0;
int* testCountPtr = &testCount;
sk_sp<GrTextureProxy> proxy = proxyProvider->createLazyProxy(
- [testCountPtr](GrResourceProvider* resourceProvider,
- GrSurfaceOrigin* /*outOrigin*/) {
+ [testCountPtr](GrResourceProvider* resourceProvider) {
if (!resourceProvider) {
*testCountPtr = -1;
return sk_sp<GrTexture>();
@@ -267,8 +267,7 @@ public:
desc.fConfig = kRGBA_8888_GrPixelConfig;
fLazyProxy = proxyProvider->createLazyProxy(
- [testExecuteValue, shouldFailInstantiation, desc] (
- GrResourceProvider* rp, GrSurfaceOrigin* /*origin*/) {
+ [testExecuteValue, shouldFailInstantiation, desc] (GrResourceProvider* rp) {
if (!rp) {
return sk_sp<GrTexture>();
}