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

Side by Side Diff: src/gpu/SkGr.cpp

Issue 973593002: change colorfilter to return an array of frag processors (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update gm Created 5 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright 2010 Google Inc. 2 * Copyright 2010 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 "SkGr.h" 8 #include "SkGr.h"
9 9
10 #include "GrXferProcessor.h" 10 #include "GrXferProcessor.h"
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 grPaint->setColor(paintColor); 655 grPaint->setColor(paintColor);
656 656
657 SkColorFilter* colorFilter = skPaint.getColorFilter(); 657 SkColorFilter* colorFilter = skPaint.getColorFilter();
658 if (colorFilter) { 658 if (colorFilter) {
659 // if the source color is a constant then apply the filter here once rat her than per pixel 659 // if the source color is a constant then apply the filter here once rat her than per pixel
660 // in a shader. 660 // in a shader.
661 if (constantColor) { 661 if (constantColor) {
662 SkColor filtered = colorFilter->filterColor(skPaint.getColor()); 662 SkColor filtered = colorFilter->filterColor(skPaint.getColor());
663 grPaint->setColor(SkColor2GrColor(filtered)); 663 grPaint->setColor(SkColor2GrColor(filtered));
664 } else { 664 } else {
665 SkAutoTUnref<GrFragmentProcessor> fp(colorFilter->asFragmentProcesso r(context)); 665 SkTDArray<GrFragmentProcessor*> array;
666 if (fp.get()) { 666 if (colorFilter->asFragmentProcessors(context, &array)) {
667 grPaint->addColorProcessor(fp); 667 for (int i = 0; i < array.count(); ++i) {
668 grPaint->addColorProcessor(array[i]);
669 array[i]->unref();
670 }
668 } 671 }
669 } 672 }
670 } 673 }
671 674
672 #ifndef SK_IGNORE_GPU_DITHER 675 #ifndef SK_IGNORE_GPU_DITHER
673 // If the dither flag is set, then we need to see if the underlying context 676 // If the dither flag is set, then we need to see if the underlying context
674 // supports it. If not, then install a dither effect. 677 // supports it. If not, then install a dither effect.
675 if (skPaint.isDither() && grPaint->numColorStages() > 0) { 678 if (skPaint.isDither() && grPaint->numColorStages() > 0) {
676 // What are we rendering into? 679 // What are we rendering into?
677 SkASSERT(rt); 680 SkASSERT(rt);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 if (shader->asFragmentProcessor(context, skPaint, viewM, NULL, &paintCol or, &fp) && fp) { 716 if (shader->asFragmentProcessor(context, skPaint, viewM, NULL, &paintCol or, &fp) && fp) {
714 grPaint->addColorProcessor(fp)->unref(); 717 grPaint->addColorProcessor(fp)->unref();
715 constantColor = false; 718 constantColor = false;
716 } 719 }
717 } 720 }
718 721
719 // The grcolor is automatically set when calling asFragmentProcessor. 722 // The grcolor is automatically set when calling asFragmentProcessor.
720 // If the shader can be seen as an effect it returns true and adds its effec t to the grpaint. 723 // If the shader can be seen as an effect it returns true and adds its effec t to the grpaint.
721 SkPaint2GrPaintNoShader(context, rt, skPaint, paintColor, constantColor, grP aint); 724 SkPaint2GrPaintNoShader(context, rt, skPaint, paintColor, constantColor, grP aint);
722 } 725 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698