Move MIP color mode from GrSurfaceProxy to GrTextureProxy
authorBrian Salomon <bsalomon@google.com>
Wed, 17 May 2017 18:27:58 +0000 (14:27 -0400)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Thu, 18 May 2017 14:38:03 +0000 (14:38 +0000)
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>

include/private/GrSurfaceProxy.h
include/private/GrTextureProxy.h
src/gpu/GrRenderTargetProxy.cpp
src/gpu/GrSurfaceProxy.cpp
src/gpu/GrTextureProxy.cpp
src/gpu/GrTextureRenderTargetProxy.cpp

index bf668fc..1b7950c 100644 (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
 
index 342e920..d40b2e1 100644 (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;
 
index 099f7e5..7cc51df 100644 (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;
     }
index a9abb16..b22d0aa 100644 (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
index 7ecd50b..7928164 100644 (file)
 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;
     }
index 4f1c420..7058c83 100644 (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;
     }