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

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

Issue 648463003: FPs now use the correct builder types(just a rename) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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 | « src/effects/SkColorFilters.cpp ('k') | src/effects/SkDisplacementMapEffect.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SkColorMatrixFilter.h" 8 #include "SkColorMatrixFilter.h"
9 #include "SkColorMatrix.h" 9 #include "SkColorMatrix.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 class GLProcessor : public GrGLFragmentProcessor { 354 class GLProcessor : public GrGLFragmentProcessor {
355 public: 355 public:
356 // this class always generates the same code. 356 // this class always generates the same code.
357 static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBu ilder* b) {} 357 static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBu ilder* b) {}
358 358
359 GLProcessor(const GrBackendProcessorFactory& factory, 359 GLProcessor(const GrBackendProcessorFactory& factory,
360 const GrProcessor&) 360 const GrProcessor&)
361 : INHERITED(factory) { 361 : INHERITED(factory) {
362 } 362 }
363 363
364 virtual void emitCode(GrGLProgramBuilder* builder, 364 virtual void emitCode(GrGLFPBuilder* builder,
365 const GrFragmentProcessor&, 365 const GrFragmentProcessor&,
366 const GrProcessorKey&, 366 const GrProcessorKey&,
367 const char* outputColor, 367 const char* outputColor,
368 const char* inputColor, 368 const char* inputColor,
369 const TransformedCoordsArray&, 369 const TransformedCoordsArray&,
370 const TextureSamplerArray&) SK_OVERRIDE { 370 const TextureSamplerArray&) SK_OVERRIDE {
371 fMatrixHandle = builder->addUniform(GrGLProgramBuilder::kFragment_Vi sibility, 371 fMatrixHandle = builder->addUniform(GrGLProgramBuilder::kFragment_Vi sibility,
372 kMat44f_GrSLType, 372 kMat44f_GrSLType,
373 "ColorMatrix"); 373 "ColorMatrix");
374 fVectorHandle = builder->addUniform(GrGLProgramBuilder::kFragment_Vi sibility, 374 fVectorHandle = builder->addUniform(GrGLProgramBuilder::kFragment_Vi sibility,
375 kVec4f_GrSLType, 375 kVec4f_GrSLType,
376 "ColorMatrixVector"); 376 "ColorMatrixVector");
377 377
378 if (NULL == inputColor) { 378 if (NULL == inputColor) {
379 // could optimize this case, but we aren't for now. 379 // could optimize this case, but we aren't for now.
380 inputColor = "vec4(1)"; 380 inputColor = "vec4(1)";
381 } 381 }
382 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBui lder(); 382 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder ();
383 // The max() is to guard against 0 / 0 during unpremul when the inco ming color is 383 // The max() is to guard against 0 / 0 during unpremul when the inco ming color is
384 // transparent black. 384 // transparent black.
385 fsBuilder->codeAppendf("\tfloat nonZeroAlpha = max(%s.a, 0.00001);\n ", inputColor); 385 fsBuilder->codeAppendf("\tfloat nonZeroAlpha = max(%s.a, 0.00001);\n ", inputColor);
386 fsBuilder->codeAppendf("\t%s = %s * vec4(%s.rgb / nonZeroAlpha, nonZ eroAlpha) + %s;\n", 386 fsBuilder->codeAppendf("\t%s = %s * vec4(%s.rgb / nonZeroAlpha, nonZ eroAlpha) + %s;\n",
387 outputColor, 387 outputColor,
388 builder->getUniformCStr(fMatrixHandle), 388 builder->getUniformCStr(fMatrixHandle),
389 inputColor, 389 inputColor,
390 builder->getUniformCStr(fVectorHandle)); 390 builder->getUniformCStr(fVectorHandle));
391 fsBuilder->codeAppendf("\t%s = clamp(%s, 0.0, 1.0);\n", outputColor, outputColor); 391 fsBuilder->codeAppendf("\t%s = clamp(%s, 0.0, 1.0);\n", outputColor, outputColor);
392 fsBuilder->codeAppendf("\t%s.rgb *= %s.a;\n", outputColor, outputCol or); 392 fsBuilder->codeAppendf("\t%s.rgb *= %s.a;\n", outputColor, outputCol or);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 str->append("matrix: ("); 502 str->append("matrix: (");
503 for (int i = 0; i < 20; ++i) { 503 for (int i = 0; i < 20; ++i) {
504 str->appendScalar(fMatrix.fMat[i]); 504 str->appendScalar(fMatrix.fMat[i]);
505 if (i < 19) { 505 if (i < 19) {
506 str->append(", "); 506 str->append(", ");
507 } 507 }
508 } 508 }
509 str->append(")"); 509 str->append(")");
510 } 510 }
511 #endif 511 #endif
OLDNEW
« no previous file with comments | « src/effects/SkColorFilters.cpp ('k') | src/effects/SkDisplacementMapEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698