| 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 "GrTypesPriv.h" | 12 #include "SkTArray.h" |
| 13 #include "SkString.h" | 13 #include "glsl/GrGLSLProgramDataManager.h" |
| 14 | 14 |
| 15 class GrGLSLSampler { | 15 class GrGLSLSampler { |
| 16 public: | 16 public: |
| 17 virtual ~GrGLSLSampler() {} | 17 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; |
| 18 typedef SkTArray<GrGLSLSampler> SamplerArray; |
| 18 | 19 |
| 19 explicit GrGLSLSampler(uint32_t visibility, GrPixelConfig config) | 20 GrGLSLSampler(UniformHandle uniform, GrPixelConfig config) |
| 20 : fVisibility(visibility) | 21 : fSamplerUniform(uniform) |
| 21 , fConfig(config) { | 22 , fConfig(config) { |
| 22 SkASSERT(kUnknown_GrPixelConfig != fConfig); | 23 SkASSERT(kUnknown_GrPixelConfig != fConfig); |
| 23 } | 24 } |
| 24 | 25 |
| 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; | |
| 38 | 27 |
| 39 private: | 28 private: |
| 40 virtual const char* onGetSamplerNameForTexture2D() const = 0; | 29 UniformHandle fSamplerUniform; |
| 41 uint32_t fVisibility; | |
| 42 GrPixelConfig fConfig; | 30 GrPixelConfig fConfig; |
| 31 |
| 32 friend class GrGLSLShaderBuilder; |
| 43 }; | 33 }; |
| 44 | 34 |
| 45 #endif | 35 #endif |
| OLD | NEW |