diff options
author | Brian Salomon <bsalomon@google.com> | 2017-05-17 13:49:59 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-05-17 18:17:50 +0000 |
commit | bb5711a5e4b9c83f0fc49f2d4ee19ca1e4592e14 (patch) | |
tree | e743c265e75a1dad32c1425bf3b9ed88abad2c52 /include | |
parent | 9f1c403362d8de6038328c7238b6ac56be552324 (diff) |
Remove GrSurfaceDesc member from GrSurfaceProxy.
Stores the config, origin, and dimensions in GrSurfaceProxy, sample count in GrRenderTargetProxy, and "was constructed with mip maps" in GrTextureProxy.
Change-Id: Iee058674dce49107a991cca9d083cd33e3572809
Reviewed-on: https://skia-review.googlesource.com/17209
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/gpu/GrSurface.h | 2 | ||||
-rw-r--r-- | include/private/GrRenderTargetProxy.h | 30 | ||||
-rw-r--r-- | include/private/GrSurfaceProxy.h | 54 | ||||
-rw-r--r-- | include/private/GrTextureProxy.h | 14 |
4 files changed, 65 insertions, 35 deletions
diff --git a/include/gpu/GrSurface.h b/include/gpu/GrSurface.h index dd37c18008..668838b2d5 100644 --- a/include/gpu/GrSurface.h +++ b/include/gpu/GrSurface.h @@ -71,7 +71,7 @@ public: inline const GrSurfacePriv surfacePriv() const; static size_t WorstCaseSize(const GrSurfaceDesc& desc, bool useNextPow2 = false); - static size_t ComputeSize(const GrSurfaceDesc& desc, int colorSamplesPerPixel, + static size_t ComputeSize(GrPixelConfig config, int width, int height, int colorSamplesPerPixel, bool hasMIPMaps, bool useNextPow2 = false); protected: diff --git a/include/private/GrRenderTargetProxy.h b/include/private/GrRenderTargetProxy.h index dd28b0f86d..6d8b000d7c 100644 --- a/include/private/GrRenderTargetProxy.h +++ b/include/private/GrRenderTargetProxy.h @@ -24,15 +24,16 @@ public: const GrRenderTargetProxy* asRenderTargetProxy() const override { return this; } // Actually instantiate the backing rendertarget, if necessary. - GrRenderTarget* instantiate(GrResourceProvider* resourceProvider); - - /** - * Returns the number of samples/pixel in the stencil buffer (Zero if non-MSAA). - */ - int numStencilSamples() const { return fDesc.fSampleCnt; } + GrSurface* instantiate(GrResourceProvider* resourceProvider) override; + GrRenderTarget* instantiateRenderTarget(GrResourceProvider* resourceProvider) { + if (auto surf = this->instantiate(resourceProvider)) { + return surf->asRenderTarget(); + } + return nullptr; + } GrFSAAType fsaaType() const { - if (!fDesc.fSampleCnt) { + if (!fSampleCnt) { SkASSERT(!(fRenderTargetFlags & GrRenderTarget::Flags::kMixedSampled)); return GrFSAAType::kNone; } @@ -40,13 +41,23 @@ public: ? GrFSAAType::kMixedSamples : GrFSAAType::kUnifiedMSAA; } + + /** + * Returns the number of samples/pixel in the stencil buffer (Zero if non-MSAA). + */ + int numStencilSamples() const { return fSampleCnt; } + /** * Returns the number of samples/pixel in the color buffer (Zero if non-MSAA or mixed sampled). */ int numColorSamples() const { - return GrFSAAType::kMixedSamples == this->fsaaType() ? 0 : fDesc.fSampleCnt; + return GrFSAAType::kMixedSamples == this->fsaaType() ? 0 : fSampleCnt; } + int worstCaseWidth() const; + + int worstCaseHeight() const; + int maxWindowRectangles(const GrCaps& caps) const; GrRenderTarget::Flags testingOnly_getFlags() const; @@ -65,8 +76,9 @@ protected: GrRenderTargetProxy(sk_sp<GrSurface>); private: - size_t onGpuMemorySize() const override; + size_t onUninstantiatedGpuMemorySize() const override; + int fSampleCnt; // For wrapped render targets the actual GrRenderTarget is stored in the GrIORefProxy class. // For deferred proxies that pointer is filled in when we need to instantiate the // deferred resource. diff --git a/include/private/GrSurfaceProxy.h b/include/private/GrSurfaceProxy.h index 8b3779c4e9..bf668fcb2d 100644 --- a/include/private/GrSurfaceProxy.h +++ b/include/private/GrSurfaceProxy.h @@ -189,14 +189,12 @@ public: static sk_sp<GrTextureProxy> MakeWrappedBackend(GrContext*, GrBackendTexture&, GrSurfaceOrigin); GrSurfaceOrigin origin() const { - SkASSERT(kTopLeft_GrSurfaceOrigin == fDesc.fOrigin || - kBottomLeft_GrSurfaceOrigin == fDesc.fOrigin); - return fDesc.fOrigin; + SkASSERT(kTopLeft_GrSurfaceOrigin == fOrigin || kBottomLeft_GrSurfaceOrigin == fOrigin); + return fOrigin; } - int width() const { return fDesc.fWidth; } - int height() const { return fDesc.fHeight; } - GrPixelConfig config() const { return fDesc.fConfig; } - bool isMipMapped() const { return fDesc.fIsMipMapped; } + int width() const { return fWidth; } + int height() const { return fHeight; } + GrPixelConfig config() const { return fConfig; } class UniqueID { public: @@ -244,16 +242,13 @@ public: */ UniqueID uniqueID() const { return fUniqueID; } - GrSurface* instantiate(GrResourceProvider* resourceProvider); + virtual GrSurface* instantiate(GrResourceProvider* resourceProvider) = 0; /** * Helper that gets the width and height of the surface as a bounding rectangle. */ SkRect getBoundsRect() const { return SkRect::MakeIWH(this->width(), this->height()); } - int worstCaseWidth(const GrCaps& caps) const; - int worstCaseHeight(const GrCaps& caps) const; - /** * @return the texture proxy associated with the surface proxy, may be NULL. */ @@ -285,8 +280,11 @@ public: * @return the amount of GPU memory used in bytes */ size_t gpuMemorySize() const { + if (fTarget) { + return fTarget->gpuMemorySize(); + } if (kInvalidGpuMemorySize == fGpuMemorySize) { - fGpuMemorySize = this->onGpuMemorySize(); + fGpuMemorySize = this->onUninstantiatedGpuMemorySize(); SkASSERT(kInvalidGpuMemorySize != fGpuMemorySize); } return fGpuMemorySize; @@ -318,14 +316,17 @@ public: protected: // Deferred version GrSurfaceProxy(const GrSurfaceDesc& desc, SkBackingFit fit, SkBudgeted budgeted, uint32_t flags) - : fDesc(desc) - , fFit(fit) - , fBudgeted(budgeted) - , fFlags(flags) - // fMipColorMode is only valid for texturable proxies - , fMipColorMode(SkDestinationSurfaceColorMode::kLegacy) - , fGpuMemorySize(kInvalidGpuMemorySize) - , fLastOpList(nullptr) { + : fConfig(desc.fConfig) + , fWidth(desc.fWidth) + , fHeight(desc.fHeight) + , fOrigin(desc.fOrigin) + , fFit(fit) + , fBudgeted(budgeted) + , fFlags(flags) + // fMipColorMode is only valid for texturable proxies + , fMipColorMode(SkDestinationSurfaceColorMode::kLegacy) + , fGpuMemorySize(kInvalidGpuMemorySize) + , fLastOpList(nullptr) { // Note: this ctor pulls a new uniqueID from the same pool at the GrGpuResources } @@ -345,8 +346,15 @@ protected: return this->internalHasPendingWrite(); } - // For wrapped resources, 'fDesc' will always be filled in from the wrapped resource. - GrSurfaceDesc fDesc; + GrSurface* instantiateImpl(GrResourceProvider* resourceProvider, int sampleCnt, + GrSurfaceFlags flags, bool isMipMapped); + + // For wrapped resources, 'fConfig', 'fWidth', 'fHeight', and 'fOrigin; will always be filled in + // from the wrapped resource. + GrPixelConfig fConfig; + int fWidth; + int fHeight; + GrSurfaceOrigin fOrigin; SkBackingFit fFit; // always exact for wrapped resources mutable SkBudgeted fBudgeted; // set from the backing resource for wrapped resources // mutable bc of SkSurface/SkImage wishy-washiness @@ -360,7 +368,7 @@ protected: SkDEBUGCODE(size_t getRawGpuMemorySize_debugOnly() const { return fGpuMemorySize; }) private: - virtual size_t onGpuMemorySize() const = 0; + virtual size_t onUninstantiatedGpuMemorySize() const = 0; // This entry is lazily evaluated so, when the proxy wraps a resource, the resource // will be called but, when the proxy is deferred, it will compute the answer itself. diff --git a/include/private/GrTextureProxy.h b/include/private/GrTextureProxy.h index e14e285d87..342e920682 100644 --- a/include/private/GrTextureProxy.h +++ b/include/private/GrTextureProxy.h @@ -22,7 +22,13 @@ public: const GrTextureProxy* asTextureProxy() const override { return this; } // Actually instantiate the backing texture, if necessary - GrTexture* instantiate(GrResourceProvider*); + GrSurface* instantiate(GrResourceProvider*) override; + GrTexture* instantiateTexture(GrResourceProvider* resourceProvider) { + if (auto surf = this->instantiate(resourceProvider)) { + return surf->asTexture(); + } + return nullptr; + } void setMipColorMode(SkDestinationSurfaceColorMode colorMode); @@ -36,6 +42,8 @@ public: } } + bool isMipMapped() const { return fIsMipMapped; } + protected: friend class GrSurfaceProxy; // for ctors @@ -46,7 +54,9 @@ protected: GrTextureProxy(sk_sp<GrSurface>); private: - size_t onGpuMemorySize() const override; + bool fIsMipMapped; + + size_t onUninstantiatedGpuMemorySize() const override; // For wrapped proxies the GrTexture pointer is stored in GrIORefProxy. // For deferred proxies that pointer will be filled in when we need to instantiate |