OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #include "SkColorCubeFilter.h" | 8 #include "SkColorCubeFilter.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkOnce.h" | 10 #include "SkOnce.h" |
11 #include "SkOpts.h" | 11 #include "SkOpts.h" |
12 #include "SkReadBuffer.h" | 12 #include "SkReadBuffer.h" |
13 #include "SkUnPreMultiply.h" | 13 #include "SkUnPreMultiply.h" |
14 #include "SkWriteBuffer.h" | 14 #include "SkWriteBuffer.h" |
15 #if SK_SUPPORT_GPU | 15 #if SK_SUPPORT_GPU |
16 #include "GrContext.h" | 16 #include "GrContext.h" |
17 #include "GrCoordTransform.h" | 17 #include "GrCoordTransform.h" |
18 #include "GrInvariantOutput.h" | 18 #include "GrInvariantOutput.h" |
19 #include "GrTexturePriv.h" | 19 #include "GrTexturePriv.h" |
20 #include "SkGr.h" | 20 #include "SkGr.h" |
21 #include "gl/GrGLFragmentProcessor.h" | 21 #include "glsl/GrGLSLFragmentProcessor.h" |
22 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 22 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
23 #include "glsl/GrGLSLProgramBuilder.h" | 23 #include "glsl/GrGLSLProgramBuilder.h" |
24 #include "glsl/GrGLSLProgramDataManager.h" | 24 #include "glsl/GrGLSLProgramDataManager.h" |
25 #endif | 25 #endif |
26 | 26 |
27 /////////////////////////////////////////////////////////////////////////////// | 27 /////////////////////////////////////////////////////////////////////////////// |
28 namespace { | 28 namespace { |
29 | 29 |
30 int32_t SkNextColorCubeUniqueID() { | 30 int32_t SkNextColorCubeUniqueID() { |
31 static int32_t gColorCubeUniqueID; | 31 static int32_t gColorCubeUniqueID; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 168 |
169 virtual ~GrColorCubeEffect(); | 169 virtual ~GrColorCubeEffect(); |
170 | 170 |
171 const char* name() const override { return "ColorCube"; } | 171 const char* name() const override { return "ColorCube"; } |
172 | 172 |
173 int colorCubeSize() const { return fColorCubeAccess.getTexture()->width(); } | 173 int colorCubeSize() const { return fColorCubeAccess.getTexture()->width(); } |
174 | 174 |
175 | 175 |
176 void onComputeInvariantOutput(GrInvariantOutput*) const override; | 176 void onComputeInvariantOutput(GrInvariantOutput*) const override; |
177 | 177 |
178 class GLProcessor : public GrGLFragmentProcessor { | 178 class GLProcessor : public GrGLSLFragmentProcessor { |
179 public: | 179 public: |
180 GLProcessor(const GrProcessor&); | 180 GLProcessor(const GrProcessor&); |
181 virtual ~GLProcessor(); | 181 virtual ~GLProcessor(); |
182 | 182 |
183 virtual void emitCode(EmitArgs&) override; | 183 virtual void emitCode(EmitArgs&) override; |
184 | 184 |
185 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProce
ssorKeyBuilder*); | 185 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProce
ssorKeyBuilder*); |
186 | 186 |
187 protected: | 187 protected: |
188 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) over
ride; | 188 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) over
ride; |
189 | 189 |
190 private: | 190 private: |
191 GrGLSLProgramDataManager::UniformHandle fColorCubeSizeUni; | 191 GrGLSLProgramDataManager::UniformHandle fColorCubeSizeUni; |
192 GrGLSLProgramDataManager::UniformHandle fColorCubeInvSizeUni; | 192 GrGLSLProgramDataManager::UniformHandle fColorCubeInvSizeUni; |
193 | 193 |
194 typedef GrGLFragmentProcessor INHERITED; | 194 typedef GrGLSLFragmentProcessor INHERITED; |
195 }; | 195 }; |
196 | 196 |
197 private: | 197 private: |
198 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, | 198 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, |
199 GrProcessorKeyBuilder* b) const override; | 199 GrProcessorKeyBuilder* b) const override; |
200 | 200 |
201 GrGLFragmentProcessor* onCreateGLInstance() const override; | 201 GrGLSLFragmentProcessor* onCreateGLInstance() const override; |
202 | 202 |
203 bool onIsEqual(const GrFragmentProcessor&) const override { return true; } | 203 bool onIsEqual(const GrFragmentProcessor&) const override { return true; } |
204 | 204 |
205 GrColorCubeEffect(GrTexture* colorCube); | 205 GrColorCubeEffect(GrTexture* colorCube); |
206 | 206 |
207 GrTextureAccess fColorCubeAccess; | 207 GrTextureAccess fColorCubeAccess; |
208 | 208 |
209 typedef GrFragmentProcessor INHERITED; | 209 typedef GrFragmentProcessor INHERITED; |
210 }; | 210 }; |
211 | 211 |
212 /////////////////////////////////////////////////////////////////////////////// | 212 /////////////////////////////////////////////////////////////////////////////// |
213 | 213 |
214 GrColorCubeEffect::GrColorCubeEffect(GrTexture* colorCube) | 214 GrColorCubeEffect::GrColorCubeEffect(GrTexture* colorCube) |
215 : fColorCubeAccess(colorCube, "bgra", GrTextureParams::kBilerp_FilterMode) { | 215 : fColorCubeAccess(colorCube, "bgra", GrTextureParams::kBilerp_FilterMode) { |
216 this->initClassID<GrColorCubeEffect>(); | 216 this->initClassID<GrColorCubeEffect>(); |
217 this->addTextureAccess(&fColorCubeAccess); | 217 this->addTextureAccess(&fColorCubeAccess); |
218 } | 218 } |
219 | 219 |
220 GrColorCubeEffect::~GrColorCubeEffect() { | 220 GrColorCubeEffect::~GrColorCubeEffect() { |
221 } | 221 } |
222 | 222 |
223 void GrColorCubeEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorK
eyBuilder* b) const { | 223 void GrColorCubeEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorK
eyBuilder* b) const { |
224 GLProcessor::GenKey(*this, caps, b); | 224 GLProcessor::GenKey(*this, caps, b); |
225 } | 225 } |
226 | 226 |
227 GrGLFragmentProcessor* GrColorCubeEffect::onCreateGLInstance() const { | 227 GrGLSLFragmentProcessor* GrColorCubeEffect::onCreateGLInstance() const { |
228 return new GLProcessor(*this); | 228 return new GLProcessor(*this); |
229 } | 229 } |
230 | 230 |
231 void GrColorCubeEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
{ | 231 void GrColorCubeEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
{ |
232 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); | 232 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); |
233 } | 233 } |
234 | 234 |
235 /////////////////////////////////////////////////////////////////////////////// | 235 /////////////////////////////////////////////////////////////////////////////// |
236 | 236 |
237 GrColorCubeEffect::GLProcessor::GLProcessor(const GrProcessor&) { | 237 GrColorCubeEffect::GLProcessor::GLProcessor(const GrProcessor&) { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 if (textureCube) { | 326 if (textureCube) { |
327 context->textureProvider()->assignUniqueKeyToTexture(key, textureCub
e); | 327 context->textureProvider()->assignUniqueKeyToTexture(key, textureCub
e); |
328 } else { | 328 } else { |
329 return nullptr; | 329 return nullptr; |
330 } | 330 } |
331 } | 331 } |
332 | 332 |
333 return GrColorCubeEffect::Create(textureCube); | 333 return GrColorCubeEffect::Create(textureCube); |
334 } | 334 } |
335 #endif | 335 #endif |
OLD | NEW |