From 60dd8c746428fb6218fff5f437b1b7c5256bba13 Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Mon, 30 Jul 2018 10:24:13 -0400 Subject: Introduce enum class for texture type. This represents the GL texture "target" but at the API-neutral level. It will be needed here because proxy's that wrap imported texture's need to know about sampling restrictions. Change-Id: Ie811a6f6d04ba1b04faa6908422dca64e8e447c8 Reviewed-on: https://skia-review.googlesource.com/144304 Reviewed-by: Greg Daniel Commit-Queue: Brian Salomon --- include/gpu/GrTexture.h | 6 +++--- include/private/GrTypesPriv.h | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/gpu/GrTexture.h b/include/gpu/GrTexture.h index 215cda1e94..2776567ae8 100644 --- a/include/gpu/GrTexture.h +++ b/include/gpu/GrTexture.h @@ -65,8 +65,8 @@ public: inline const GrTexturePriv texturePriv() const; protected: - GrTexture(GrGpu*, const GrSurfaceDesc&, GrSLType samplerType, - GrSamplerState::Filter highestFilterMode, GrMipMapsStatus); + GrTexture(GrGpu*, const GrSurfaceDesc&, GrTextureType, GrSamplerState::Filter highestFilterMode, + GrMipMapsStatus); virtual bool onStealBackendTexture(GrBackendTexture*, SkImage::BackendTextureReleaseProc*) = 0; @@ -76,7 +76,7 @@ private: void markMipMapsDirty(); void markMipMapsClean(); - GrSLType fSamplerType; + GrTextureType fTextureType; GrSamplerState::Filter fHighestFilterMode; GrMipMapsStatus fMipMapsStatus; int fMaxMipMapLevel; diff --git a/include/private/GrTypesPriv.h b/include/private/GrTypesPriv.h index ecd95574f2..db25236e3d 100644 --- a/include/private/GrTypesPriv.h +++ b/include/private/GrTypesPriv.h @@ -330,6 +330,17 @@ enum GrSLType { kTexture2DRectSampler_GrSLType, }; +/** + * The type of texture. Backends other than GL currently only use the 2D value but the type must + * still be known at the API-neutral layer as it used to determine whether MIP maps, renderability, + * and sampling parameters are legal for proxies that will be instantiated with wrapped textures. + */ +enum class GrTextureType { + k2D, + kRectangle, + kExternal +}; + enum GrShaderType { kVertex_GrShaderType, kGeometry_GrShaderType, @@ -479,6 +490,19 @@ static inline int GrSLTypeVecLength(GrSLType type) { return -1; } +static inline GrSLType GrSLCombinedSamplerTypeForTextureType(GrTextureType type) { + switch (type) { + case GrTextureType::k2D: + return kTexture2DSampler_GrSLType; + case GrTextureType::kRectangle: + return kTexture2DRectSampler_GrSLType; + case GrTextureType::kExternal: + return kTextureExternalSampler_GrSLType; + } + SK_ABORT("Unexpected texture type"); + return kTexture2DSampler_GrSLType; +} + static inline bool GrSLTypeIsCombinedSamplerType(GrSLType type) { switch (type) { case kTexture2DSampler_GrSLType: -- cgit v1.2.3