aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-05-08 13:41:35 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-08 18:07:07 +0000
commit49081d13bacbea0631351dc5031d98e3fbb3ec45 (patch)
tree3945cf8223112e86864a19661b2c6b6757e2c025 /src
parent26368c33007191205669bb227d6e7b915ba06f9e (diff)
Expand GrTextureProxy to handle highestFilterMode
Once TextureProxies aren't instantiated in the TextureSamplers, the they will need to be able to supply this information. split out of: https://skia-review.googlesource.com/c/10484/ (Omnibus: Push instantiation of GrTextures later (post TextureSampler)) Change-Id: I66555c0746131f565862f7a30d54ff1d458d2062 Reviewed-on: https://skia-review.googlesource.com/15819 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrProcessor.cpp7
-rw-r--r--src/gpu/GrTextureProxy.cpp17
-rw-r--r--src/gpu/vk/GrVkTexture.cpp15
3 files changed, 33 insertions, 6 deletions
diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp
index c5ccc3fbc9..57a8008dae 100644
--- a/src/gpu/GrProcessor.cpp
+++ b/src/gpu/GrProcessor.cpp
@@ -245,8 +245,8 @@ void GrResourceIOProcessor::TextureSampler::reset(GrResourceProvider* resourcePr
GrTexture* texture = proxy->instantiate(resourceProvider);
if (texture) {
fTexture.set(SkRef(texture), kRead_GrIOType);
- fParams.setFilterMode(SkTMin(params.filterMode(),
- texture->texturePriv().highestFilterMode()));
+ SkASSERT(texture->texturePriv().highestFilterMode() == proxy->highestFilterMode());
+ fParams.setFilterMode(SkTMin(params.filterMode(), proxy->highestFilterMode()));
}
fVisibility = visibility;
@@ -262,7 +262,8 @@ void GrResourceIOProcessor::TextureSampler::reset(GrResourceProvider* resourcePr
GrTexture* texture = proxy->instantiate(resourceProvider);
if (texture) {
fTexture.set(SkRef(texture), kRead_GrIOType);
- filterMode = SkTMin(filterMode, texture->texturePriv().highestFilterMode());
+ SkASSERT(texture->texturePriv().highestFilterMode() == proxy->highestFilterMode());
+ filterMode = SkTMin(filterMode, proxy->highestFilterMode());
}
fParams.reset(tileXAndY, filterMode);
diff --git a/src/gpu/GrTextureProxy.cpp b/src/gpu/GrTextureProxy.cpp
index ce7770d8ec..7557712c12 100644
--- a/src/gpu/GrTextureProxy.cpp
+++ b/src/gpu/GrTextureProxy.cpp
@@ -39,6 +39,23 @@ void GrTextureProxy::setMipColorMode(SkDestinationSurfaceColorMode colorMode) {
fMipColorMode = colorMode;
}
+// This method parallels the highest_filter_mode functions in GrGLTexture & GrVkTexture.
+GrSamplerParams::FilterMode GrTextureProxy::highestFilterMode() const {
+ if (fTarget) {
+ return fTarget->asTexture()->texturePriv().highestFilterMode();
+ }
+
+ if (GrPixelConfigIsSint(this->config())) {
+ // We only ever want to nearest-neighbor sample signed int textures.
+ return GrSamplerParams::kNone_FilterMode;
+ }
+
+ // In OpenGL, GR_GL_TEXTURE_RECTANGLE and GR_GL_TEXTURE_EXTERNAL (which have a highest filter
+ // mode of bilerp) can only be created via wrapping.
+
+ return GrSamplerParams::kMipMap_FilterMode;
+}
+
size_t GrTextureProxy::onGpuMemorySize() const {
if (fTarget) {
return fTarget->gpuMemorySize();
diff --git a/src/gpu/vk/GrVkTexture.cpp b/src/gpu/vk/GrVkTexture.cpp
index fb6b94fbc9..defbe139c5 100644
--- a/src/gpu/vk/GrVkTexture.cpp
+++ b/src/gpu/vk/GrVkTexture.cpp
@@ -16,6 +16,15 @@
#define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X)
+// This method parallels GrTextureProxy::highestFilterMode
+static inline GrSamplerParams::FilterMode highest_filter_mode(GrPixelConfig config) {
+ if (GrPixelConfigIsSint(config)) {
+ // We only ever want to nearest-neighbor sample signed int textures.
+ return GrSamplerParams::kNone_FilterMode;
+ }
+ return GrSamplerParams::kMipMap_FilterMode;
+}
+
// Because this class is virtually derived from GrSurface we must explicitly call its constructor.
GrVkTexture::GrVkTexture(GrVkGpu* gpu,
SkBudgeted budgeted,
@@ -24,7 +33,7 @@ GrVkTexture::GrVkTexture(GrVkGpu* gpu,
const GrVkImageView* view)
: GrSurface(gpu, desc)
, GrVkImage(info, GrVkImage::kNot_Wrapped)
- , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, GrSamplerParams::kMipMap_FilterMode,
+ , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, highest_filter_mode(desc.fConfig),
desc.fIsMipMapped)
, fTextureView(view)
, fLinearTextureView(nullptr) {
@@ -39,7 +48,7 @@ GrVkTexture::GrVkTexture(GrVkGpu* gpu,
GrVkImage::Wrapped wrapped)
: GrSurface(gpu, desc)
, GrVkImage(info, wrapped)
- , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, GrSamplerParams::kMipMap_FilterMode,
+ , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, highest_filter_mode(desc.fConfig),
desc.fIsMipMapped)
, fTextureView(view)
, fLinearTextureView(nullptr) {
@@ -54,7 +63,7 @@ GrVkTexture::GrVkTexture(GrVkGpu* gpu,
GrVkImage::Wrapped wrapped)
: GrSurface(gpu, desc)
, GrVkImage(info, wrapped)
- , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, GrSamplerParams::kMipMap_FilterMode,
+ , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, highest_filter_mode(desc.fConfig),
desc.fIsMipMapped)
, fTextureView(view)
, fLinearTextureView(nullptr) {