diff options
author | Robert Phillips <robertphillips@google.com> | 2018-02-13 11:13:51 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-02-13 21:25:53 +0000 |
commit | ce5209a8a5711fde34f28c740f5cd74bdb560e21 (patch) | |
tree | 772f3427bf4f1a73d2c7db727b3750b7c56b65d0 /src/gpu | |
parent | 6a46fb210b810553b2a03a5f316109ccd9710ebc (diff) |
Make fully lazy proxies possess an origin
Change-Id: Icd3d68bce78568562aa12167a58b6d6e5064b124
Reviewed-on: https://skia-review.googlesource.com/106901
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrBackendTextureImageGenerator.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrProxyProvider.cpp | 9 | ||||
-rw-r--r-- | src/gpu/GrProxyProvider.h | 9 | ||||
-rw-r--r-- | src/gpu/GrSurfaceProxy.cpp | 18 | ||||
-rw-r--r-- | src/gpu/ccpr/GrCCAtlas.cpp | 2 | ||||
-rw-r--r-- | src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp | 11 |
6 files changed, 21 insertions, 30 deletions
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) { |