aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-03-15 13:02:45 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-15 18:34:32 +0000
commita4c41b3e83bc684b3535d36590519d6fb676742d (patch)
tree47384e6b64cf3ddec64b98fe973a2c287d9cc7a1
parent2229d443d19ea8a733e5eaf314e06dafb073536f (diff)
Push setMipColorMode calls further down-stack & add to GrTextureProxy
setMipColorMode seems like an odd call. Change-Id: I24a1ac3883d52499f3be27282d006144d15b26f1 Reviewed-on: https://skia-review.googlesource.com/9725 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
-rw-r--r--include/private/GrSurfaceProxy.h5
-rw-r--r--include/private/GrTextureProxy.h4
-rw-r--r--src/gpu/GrResourceProvider.cpp10
-rw-r--r--src/gpu/GrResourceProvider.h4
-rw-r--r--src/gpu/GrSurfaceProxy.cpp2
-rw-r--r--src/gpu/GrTextureProxy.cpp11
-rw-r--r--src/gpu/SkGr.cpp21
-rw-r--r--src/gpu/SkGr.h2
-rw-r--r--src/image/SkImage_Gpu.cpp3
9 files changed, 42 insertions, 20 deletions
diff --git a/include/private/GrSurfaceProxy.h b/include/private/GrSurfaceProxy.h
index 25430cefcb..454916ef17 100644
--- a/include/private/GrSurfaceProxy.h
+++ b/include/private/GrSurfaceProxy.h
@@ -307,6 +307,8 @@ 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
@@ -330,6 +332,9 @@ protected:
mutable SkBudgeted fBudgeted; // set from the backing resource for wrapped resources
// mutable bc of SkSurface/SkImage wishy-washiness
const uint32_t fFlags;
+
+ SkDestinationSurfaceColorMode fMipColorMode;
+
const UniqueID fUniqueID; // set from the backing resource for wrapped resources
static const size_t kInvalidGpuMemorySize = ~static_cast<size_t>(0);
diff --git a/include/private/GrTextureProxy.h b/include/private/GrTextureProxy.h
index 9383ec7fac..ee954dcede 100644
--- a/include/private/GrTextureProxy.h
+++ b/include/private/GrTextureProxy.h
@@ -24,6 +24,8 @@ public:
// Actually instantiate the backing texture, if necessary
GrTexture* instantiate(GrResourceProvider*);
+ void setMipColorMode(SkDestinationSurfaceColorMode colorMode);
+
protected:
friend class GrSurfaceProxy; // for ctors
@@ -37,7 +39,7 @@ private:
size_t onGpuMemorySize() const override;
// For wrapped proxies the GrTexture pointer is stored in GrIORefProxy.
- // For deferred proxies that pointer will be filled n when we need to instantiate
+ // For deferred proxies that pointer will be filled in when we need to instantiate
// the deferred resource
typedef GrSurfaceProxy INHERITED;
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index 1a04951283..67fa6a6810 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -49,7 +49,8 @@ bool GrResourceProvider::IsFunctionallyExact(GrTextureProxy* proxy) {
GrTexture* GrResourceProvider::createMipMappedTexture(const GrSurfaceDesc& desc,
SkBudgeted budgeted, const GrMipLevel* texels,
- int mipLevelCount, uint32_t flags) {
+ int mipLevelCount, uint32_t flags,
+ SkDestinationSurfaceColorMode mipColorMode) {
ASSERT_SINGLE_OWNER
if (this->isAbandoned()) {
@@ -80,6 +81,7 @@ GrTexture* GrResourceProvider::createMipMappedTexture(const GrSurfaceDesc& desc,
if (SkBudgeted::kNo == budgeted) {
texture->resourcePriv().makeUnbudgeted();
}
+ texture->texturePriv().setMipColorMode(mipColorMode);
return texture;
}
texture->unref();
@@ -91,7 +93,11 @@ GrTexture* GrResourceProvider::createMipMappedTexture(const GrSurfaceDesc& desc,
for (int i = 0; i < mipLevelCount; ++i) {
texelsShallowCopy.push_back(texels[i]);
}
- return fGpu->createTexture(desc, budgeted, texelsShallowCopy);
+ GrTexture* texture = fGpu->createTexture(desc, budgeted, texelsShallowCopy);
+ if (texture) {
+ texture->texturePriv().setMipColorMode(mipColorMode);
+ }
+ return texture;
}
GrTexture* GrResourceProvider::createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
diff --git a/src/gpu/GrResourceProvider.h b/src/gpu/GrResourceProvider.h
index 948979805c..0cf02677bd 100644
--- a/src/gpu/GrResourceProvider.h
+++ b/src/gpu/GrResourceProvider.h
@@ -49,7 +49,9 @@ public:
*/
GrTexture* createMipMappedTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
const GrMipLevel* texels, int mipLevelCount,
- uint32_t flags = 0);
+ uint32_t flags = 0,
+ SkDestinationSurfaceColorMode mipColorMode =
+ SkDestinationSurfaceColorMode::kLegacy);
/**
* This function is a shim which creates a SkTArray<GrMipLevel> of size 1.
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index a5cb057be4..727bcb51aa 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -15,6 +15,7 @@
#include "GrOpList.h"
#include "GrResourceProvider.h"
#include "GrSurfaceContext.h"
+#include "GrTexturePriv.h"
#include "GrTextureRenderTargetProxy.h"
#include "SkMathPriv.h"
@@ -51,6 +52,7 @@ GrSurface* GrSurfaceProxy::instantiate(GrResourceProvider* resourceProvider) {
return nullptr;
}
+ fTarget->asTexture()->texturePriv().setMipColorMode(fMipColorMode);
this->INHERITED::transferRefs();
#ifdef SK_DEBUG
diff --git a/src/gpu/GrTextureProxy.cpp b/src/gpu/GrTextureProxy.cpp
index 0b3430926c..ce7770d8ec 100644
--- a/src/gpu/GrTextureProxy.cpp
+++ b/src/gpu/GrTextureProxy.cpp
@@ -8,6 +8,7 @@
#include "GrTextureProxy.h"
#include "GrResourceProvider.h"
+#include "GrTexturePriv.h"
GrTextureProxy::GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit fit, SkBudgeted budgeted,
const void* srcData, size_t /*rowBytes*/, uint32_t flags)
@@ -28,6 +29,16 @@ GrTexture* GrTextureProxy::instantiate(GrResourceProvider* resourceProvider) {
return fTarget->asTexture();
}
+void GrTextureProxy::setMipColorMode(SkDestinationSurfaceColorMode colorMode) {
+ SkASSERT(fTarget || fTarget->asTexture());
+
+ if (fTarget) {
+ fTarget->asTexture()->texturePriv().setMipColorMode(colorMode);
+ }
+
+ fMipColorMode = colorMode;
+}
+
size_t GrTextureProxy::onGpuMemorySize() const {
if (fTarget) {
return fTarget->gpuMemorySize();
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index b030469967..82a6e1c59c 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -13,7 +13,6 @@
#include "GrGpuResourcePriv.h"
#include "GrRenderTargetContext.h"
#include "GrResourceProvider.h"
-#include "GrTexturePriv.h"
#include "GrTextureProxy.h"
#include "GrTypes.h"
#include "GrXferProcessor.h"
@@ -283,20 +282,16 @@ GrTexture* GrGenerateMipMapsAndUploadToTexture(GrContext* ctx, const SkBitmap& b
texels[i].fRowBytes = generatedMipLevel.fPixmap.rowBytes();
}
- {
- GrTexture* texture = ctx->resourceProvider()->createMipMappedTexture(desc,
- SkBudgeted::kYes,
- texels.get(),
- mipLevelCount);
- if (texture) {
- texture->texturePriv().setMipColorMode(colorMode);
- }
- return texture;
- }
+ return ctx->resourceProvider()->createMipMappedTexture(desc,
+ SkBudgeted::kYes,
+ texels.get(),
+ mipLevelCount,
+ 0, colorMode);
}
GrTexture* GrUploadMipMapToTexture(GrContext* ctx, const SkImageInfo& info,
- const GrMipLevel* texels, int mipLevelCount) {
+ const GrMipLevel* texels, int mipLevelCount,
+ SkDestinationSurfaceColorMode colorMode) {
if (!SkImageInfoIsValid(info)) {
return nullptr;
}
@@ -304,7 +299,7 @@ GrTexture* GrUploadMipMapToTexture(GrContext* ctx, const SkImageInfo& info,
const GrCaps* caps = ctx->caps();
return ctx->resourceProvider()->createMipMappedTexture(GrImageInfoToSurfaceDesc(info, *caps),
SkBudgeted::kYes, texels,
- mipLevelCount);
+ mipLevelCount, 0, colorMode);
}
GrTexture* GrRefCachedBitmapTexture(GrContext* ctx, const SkBitmap& bitmap,
diff --git a/src/gpu/SkGr.h b/src/gpu/SkGr.h
index e1874a6799..573b74d63b 100644
--- a/src/gpu/SkGr.h
+++ b/src/gpu/SkGr.h
@@ -231,7 +231,7 @@ sk_sp<GrTextureProxy> GrUploadPixmapToTextureProxy(GrResourceProvider*,
* Creates a new texture populated with the mipmap levels.
*/
GrTexture* GrUploadMipMapToTexture(GrContext*, const SkImageInfo&, const GrMipLevel* texels,
- int mipLevelCount);
+ int mipLevelCount, SkDestinationSurfaceColorMode colorMode);
sk_sp<GrTexture> GrMakeCachedBitmapTexture(GrContext*, const SkBitmap&,
const GrSamplerParams&, SkScalar scaleAdjust[2]);
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index cb92942954..44d793842e 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -838,11 +838,10 @@ sk_sp<SkImage> SkImage::MakeTextureFromMipMap(GrContext* ctx, const SkImageInfo&
if (!ctx) {
return nullptr;
}
- sk_sp<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, mipLevelCount));
+ sk_sp<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, mipLevelCount, colorMode));
if (!texture) {
return nullptr;
}
- texture->texturePriv().setMipColorMode(colorMode);
return sk_make_sp<SkImage_Gpu>(kNeedNewImageUniqueID,
info.alphaType(), std::move(texture),
sk_ref_sp(info.colorSpace()), budgeted);