Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(341)

Side by Side Diff: src/effects/SkColorCubeFilter.cpp

Issue 1569393002: Revert of Add a class representing texture swizzle. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/gpu/GrTypesPriv.h ('k') | src/effects/SkTableColorFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, 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::onGetGLSLProcessorKey(const GrGLSLCaps& caps, 223 void GrColorCubeEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
224 GrProcessorKeyBuilder* b) const { 224 GrProcessorKeyBuilder* b) const {
225 GLSLProcessor::GenKey(*this, caps, b); 225 GLSLProcessor::GenKey(*this, caps, b);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 280
281 // Compute y coord for for texture fetches. 281 // Compute y coord for for texture fetches.
282 fragBuilder->codeAppendf("vec2 %s = vec2(%s.r, (floor(%s.b) + %s.g) * %s);\n ", 282 fragBuilder->codeAppendf("vec2 %s = vec2(%s.r, (floor(%s.b) + %s.g) * %s);\n ",
283 cCoords1, cubeIdx, cubeIdx, cubeIdx, colorCubeInvSi zeUni); 283 cCoords1, cubeIdx, cubeIdx, cubeIdx, colorCubeInvSi zeUni);
284 fragBuilder->codeAppendf("vec2 %s = vec2(%s.r, (ceil(%s.b) + %s.g) * %s);\n" , 284 fragBuilder->codeAppendf("vec2 %s = vec2(%s.r, (ceil(%s.b) + %s.g) * %s);\n" ,
285 cCoords2, cubeIdx, cubeIdx, cubeIdx, colorCubeInvSi zeUni); 285 cCoords2, cubeIdx, cubeIdx, cubeIdx, colorCubeInvSi zeUni);
286 286
287 // Apply the cube. 287 // Apply the cube.
288 fragBuilder->codeAppendf("%s = vec4(mix(", args.fOutputColor); 288 fragBuilder->codeAppendf("%s = vec4(mix(", args.fOutputColor);
289 fragBuilder->appendTextureLookup(args.fSamplers[0], cCoords1); 289 fragBuilder->appendTextureLookup(args.fSamplers[0], cCoords1);
290 fragBuilder->codeAppend(".bgr, "); 290 fragBuilder->codeAppend(".rgb, ");
291 fragBuilder->appendTextureLookup(args.fSamplers[0], cCoords2); 291 fragBuilder->appendTextureLookup(args.fSamplers[0], cCoords2);
292 292
293 // Premultiply color by alpha. Note that the input alpha is not modified by this shader. 293 // Premultiply color by alpha. Note that the input alpha is not modified by this shader.
294 fragBuilder->codeAppendf(".bgr, fract(%s.b)) * vec3(%s), %s.a);\n", 294 fragBuilder->codeAppendf(".rgb, fract(%s.b)) * vec3(%s), %s.a);\n",
295 cubeIdx, nonZeroAlpha, args.fInputColor); 295 cubeIdx, nonZeroAlpha, args.fInputColor);
296 } 296 }
297 297
298 void GrColorCubeEffect::GLSLProcessor::onSetData(const GrGLSLProgramDataManager& pdman, 298 void GrColorCubeEffect::GLSLProcessor::onSetData(const GrGLSLProgramDataManager& pdman,
299 const GrProcessor& proc) { 299 const GrProcessor& proc) {
300 const GrColorCubeEffect& colorCube = proc.cast<GrColorCubeEffect>(); 300 const GrColorCubeEffect& colorCube = proc.cast<GrColorCubeEffect>();
301 SkScalar size = SkIntToScalar(colorCube.colorCubeSize()); 301 SkScalar size = SkIntToScalar(colorCube.colorCubeSize());
302 pdman.set1f(fColorCubeSizeUni, SkScalarToFloat(size)); 302 pdman.set1f(fColorCubeSizeUni, SkScalarToFloat(size));
303 pdman.set1f(fColorCubeInvSizeUni, SkScalarToFloat(SkScalarInvert(size))); 303 pdman.set1f(fColorCubeInvSizeUni, SkScalarToFloat(SkScalarInvert(size)));
304 } 304 }
(...skipping 23 matching lines...) Expand all
328 if (textureCube) { 328 if (textureCube) {
329 context->textureProvider()->assignUniqueKeyToTexture(key, textureCub e); 329 context->textureProvider()->assignUniqueKeyToTexture(key, textureCub e);
330 } else { 330 } else {
331 return nullptr; 331 return nullptr;
332 } 332 }
333 } 333 }
334 334
335 return GrColorCubeEffect::Create(textureCube); 335 return GrColorCubeEffect::Create(textureCube);
336 } 336 }
337 #endif 337 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrTypesPriv.h ('k') | src/effects/SkTableColorFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698