Move MIP color mode from GrSurfaceProxy to GrTextureProxy

Change-Id: I76bc7f551ea4052fc611cf01e0ce81102c9c3395
Reviewed-on: https://skia-review.googlesource.com/17263
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Salomon 2017-05-17 14:27:58 -04:00 committed by Skia Commit-Bot
parent c96da1e51e
commit 081e0e6a32
6 changed files with 17 additions and 11 deletions

View File

@ -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

View File

@ -53,8 +53,11 @@ protected:
// Wrapped version
GrTextureProxy(sk_sp<GrSurface>);
SkDestinationSurfaceColorMode mipColorMode() const { return fMipColorMode; }
private:
bool fIsMipMapped;
SkDestinationSurfaceColorMode fMipColorMode;
size_t onUninstantiatedGpuMemorySize() const override;

View File

@ -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;
}

View File

@ -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

View File

@ -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<GrSurface> 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;
}

View File

@ -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;
}