From 081e0e6a32244a7945ddd40c2003fd312673c586 Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Wed, 17 May 2017 14:27:58 -0400 Subject: [PATCH] Move MIP color mode from GrSurfaceProxy to GrTextureProxy Change-Id: I76bc7f551ea4052fc611cf01e0ce81102c9c3395 Reviewed-on: https://skia-review.googlesource.com/17263 Reviewed-by: Robert Phillips Commit-Queue: Brian Salomon --- include/private/GrSurfaceProxy.h | 6 ++---- include/private/GrTextureProxy.h | 3 +++ src/gpu/GrRenderTargetProxy.cpp | 3 ++- src/gpu/GrSurfaceProxy.cpp | 5 +++-- src/gpu/GrTextureProxy.cpp | 9 ++++++--- src/gpu/GrTextureRenderTargetProxy.cpp | 2 +- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/include/private/GrSurfaceProxy.h b/include/private/GrSurfaceProxy.h index bf668fc..1b7950c 100644 --- a/include/private/GrSurfaceProxy.h +++ b/include/private/GrSurfaceProxy.h @@ -323,8 +323,6 @@ protected: , 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 @@ -347,7 +345,8 @@ protected: } GrSurface* instantiateImpl(GrResourceProvider* resourceProvider, int sampleCnt, - GrSurfaceFlags flags, bool isMipMapped); + GrSurfaceFlags flags, bool isMipMapped, + SkDestinationSurfaceColorMode mipColorMode); // For wrapped resources, 'fConfig', 'fWidth', 'fHeight', and 'fOrigin; will always be filled in // from the wrapped resource. @@ -360,7 +359,6 @@ protected: // mutable bc of SkSurface/SkImage wishy-washiness const uint32_t fFlags; - SkDestinationSurfaceColorMode fMipColorMode; const UniqueID fUniqueID; // set from the backing resource for wrapped resources diff --git a/include/private/GrTextureProxy.h b/include/private/GrTextureProxy.h index 342e920..d40b2e1 100644 --- a/include/private/GrTextureProxy.h +++ b/include/private/GrTextureProxy.h @@ -53,8 +53,11 @@ protected: // Wrapped version GrTextureProxy(sk_sp); + SkDestinationSurfaceColorMode mipColorMode() const { return fMipColorMode; } + private: bool fIsMipMapped; + SkDestinationSurfaceColorMode fMipColorMode; size_t onUninstantiatedGpuMemorySize() const override; diff --git a/src/gpu/GrRenderTargetProxy.cpp b/src/gpu/GrRenderTargetProxy.cpp index 099f7e5..7cc51df 100644 --- a/src/gpu/GrRenderTargetProxy.cpp +++ b/src/gpu/GrRenderTargetProxy.cpp @@ -49,7 +49,8 @@ GrSurface* GrRenderTargetProxy::instantiate(GrResourceProvider* resourceProvider static constexpr GrSurfaceFlags kFlags = kRenderTarget_GrSurfaceFlag; GrSurface* surf = this->instantiateImpl(resourceProvider, fSampleCnt, kFlags, - /* isMipped = */ false); + /* isMipped = */ false, + SkDestinationSurfaceColorMode::kLegacy); if (!surf) { return nullptr; } diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp index a9abb16..b22d0aa 100644 --- a/src/gpu/GrSurfaceProxy.cpp +++ b/src/gpu/GrSurfaceProxy.cpp @@ -40,7 +40,8 @@ GrSurfaceProxy::~GrSurfaceProxy() { } GrSurface* GrSurfaceProxy::instantiateImpl(GrResourceProvider* resourceProvider, int sampleCnt, - GrSurfaceFlags flags, bool isMipMapped) { + GrSurfaceFlags flags, bool isMipMapped, + SkDestinationSurfaceColorMode mipColorMode) { if (fTarget) { return fTarget; } @@ -62,7 +63,7 @@ GrSurface* GrSurfaceProxy::instantiateImpl(GrResourceProvider* resourceProvider, return nullptr; } - fTarget->asTexture()->texturePriv().setMipColorMode(fMipColorMode); + fTarget->asTexture()->texturePriv().setMipColorMode(mipColorMode); this->INHERITED::transferRefs(); #ifdef SK_DEBUG diff --git a/src/gpu/GrTextureProxy.cpp b/src/gpu/GrTextureProxy.cpp index 7ecd50b..7928164 100644 --- a/src/gpu/GrTextureProxy.cpp +++ b/src/gpu/GrTextureProxy.cpp @@ -13,17 +13,20 @@ GrTextureProxy::GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit fit, SkBudgeted budgeted, const void* srcData, size_t /*rowBytes*/, uint32_t flags) : INHERITED(srcDesc, fit, budgeted, flags) - , fIsMipMapped(srcDesc.fIsMipMapped) { + , fIsMipMapped(srcDesc.fIsMipMapped) + , fMipColorMode(SkDestinationSurfaceColorMode::kLegacy) { SkASSERT(!srcData); // currently handled in Make() } GrTextureProxy::GrTextureProxy(sk_sp surf) : INHERITED(std::move(surf), SkBackingFit::kExact) - , fIsMipMapped(fTarget->asTexture()->texturePriv().hasMipMaps()) {} + , fIsMipMapped(fTarget->asTexture()->texturePriv().hasMipMaps()) + , fMipColorMode(fTarget->asTexture()->texturePriv().mipColorMode()) {} GrSurface* GrTextureProxy::instantiate(GrResourceProvider* resourceProvider) { GrSurface* surf = - this->instantiateImpl(resourceProvider, 0, kNone_GrSurfaceFlags, fIsMipMapped); + this->instantiateImpl(resourceProvider, 0, kNone_GrSurfaceFlags, fIsMipMapped, + fMipColorMode); if (!surf) { return nullptr; } diff --git a/src/gpu/GrTextureRenderTargetProxy.cpp b/src/gpu/GrTextureRenderTargetProxy.cpp index 4f1c420..7058c83 100644 --- a/src/gpu/GrTextureRenderTargetProxy.cpp +++ b/src/gpu/GrTextureRenderTargetProxy.cpp @@ -48,7 +48,7 @@ GrSurface* GrTextureRenderTargetProxy::instantiate(GrResourceProvider* resourceP static constexpr GrSurfaceFlags kFlags = kRenderTarget_GrSurfaceFlag; GrSurface* surf = this->instantiateImpl(resourceProvider, this->numStencilSamples(), kFlags, - this->isMipMapped()); + this->isMipMapped(), this->mipColorMode()); if (!surf) { return nullptr; } -- 2.7.4