| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrGLSLSampler_DEFINED | 8 #ifndef GrGLSLSampler_DEFINED |
| 9 #define GrGLSLSampler_DEFINED | 9 #define GrGLSLSampler_DEFINED |
| 10 | 10 |
| 11 #include "GrTypes.h" | 11 #include "GrTypes.h" |
| 12 #include "SkTArray.h" | 12 #include "GrTypesPriv.h" |
| 13 #include "glsl/GrGLSLProgramDataManager.h" | 13 #include "SkString.h" |
| 14 | 14 |
| 15 class GrGLSLSampler { | 15 class GrGLSLSampler { |
| 16 public: | 16 public: |
| 17 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; | 17 virtual ~GrGLSLSampler() {} |
| 18 typedef SkTArray<GrGLSLSampler> SamplerArray; | |
| 19 | 18 |
| 20 GrGLSLSampler(UniformHandle uniform, GrPixelConfig config) | 19 explicit GrGLSLSampler(uint32_t visibility, GrPixelConfig config) |
| 21 : fSamplerUniform(uniform) | 20 : fVisibility(visibility) |
| 22 , fConfig(config) { | 21 , fConfig(config) { |
| 23 SkASSERT(kUnknown_GrPixelConfig != fConfig); | 22 SkASSERT(kUnknown_GrPixelConfig != fConfig); |
| 24 } | 23 } |
| 25 | 24 |
| 25 uint32_t visibility() const { return fVisibility; } |
| 26 GrPixelConfig config() const { return fConfig; } | 26 GrPixelConfig config() const { return fConfig; } |
| 27 virtual GrSLType type() const = 0; |
| 28 |
| 29 // Returns the string to be used for the sampler in glsl 2D texture function
s (texture, |
| 30 // texture2D, etc.) |
| 31 const char* getSamplerNameForTexture2D() const { |
| 32 SkASSERT(GrSLTypeIs2DTextureType(this->type())); |
| 33 return this->onGetSamplerNameForTexture2D(); |
| 34 } |
| 35 |
| 36 // Returns the string to be used for the sampler in glsl texelFetch. |
| 37 virtual const char* getSamplerNameForTexelFetch() const = 0; |
| 27 | 38 |
| 28 private: | 39 private: |
| 29 UniformHandle fSamplerUniform; | 40 virtual const char* onGetSamplerNameForTexture2D() const = 0; |
| 41 uint32_t fVisibility; |
| 30 GrPixelConfig fConfig; | 42 GrPixelConfig fConfig; |
| 31 | |
| 32 friend class GrGLSLShaderBuilder; | |
| 33 }; | 43 }; |
| 34 | 44 |
| 35 #endif | 45 #endif |
| OLD | NEW |