OLD | NEW |
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 "GrCaps.h" | 10 #include "GrCaps.h" |
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 SkColorFilter* colorFilter = skPaint.getColorFilter(); | 713 SkColorFilter* colorFilter = skPaint.getColorFilter(); |
714 if (colorFilter) { | 714 if (colorFilter) { |
715 // if the source color is a constant then apply the filter here once rat
her than per pixel | 715 // if the source color is a constant then apply the filter here once rat
her than per pixel |
716 // in a shader. | 716 // in a shader. |
717 if (constantColor) { | 717 if (constantColor) { |
718 SkColor filtered = colorFilter->filterColor(skPaint.getColor()); | 718 SkColor filtered = colorFilter->filterColor(skPaint.getColor()); |
719 grPaint->setColor(SkColor2GrColor(filtered)); | 719 grPaint->setColor(SkColor2GrColor(filtered)); |
720 } else { | 720 } else { |
721 SkTDArray<GrFragmentProcessor*> array; | 721 SkTDArray<GrFragmentProcessor*> array; |
722 // return false if failed? | 722 // return false if failed? |
723 if (colorFilter->asFragmentProcessors(context, grPaint->getShaderDat
aManager(), | 723 if (colorFilter->asFragmentProcessors(context, grPaint->getProcessor
DataManager(), |
724 &array)) { | 724 &array)) { |
725 for (int i = 0; i < array.count(); ++i) { | 725 for (int i = 0; i < array.count(); ++i) { |
726 grPaint->addColorProcessor(array[i]); | 726 grPaint->addColorProcessor(array[i]); |
727 array[i]->unref(); | 727 array[i]->unref(); |
728 } | 728 } |
729 } | 729 } |
730 } | 730 } |
731 } | 731 } |
732 | 732 |
733 #ifndef SK_IGNORE_GPU_DITHER | 733 #ifndef SK_IGNORE_GPU_DITHER |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 GrColor paintColor = SkColor2GrColor(skPaint.getColor()); | 765 GrColor paintColor = SkColor2GrColor(skPaint.getColor()); |
766 | 766 |
767 // Start a new block here in order to preserve our context state after calli
ng | 767 // Start a new block here in order to preserve our context state after calli
ng |
768 // asFragmentProcessor(). Since these calls get passed back to the client, w
e don't really | 768 // asFragmentProcessor(). Since these calls get passed back to the client, w
e don't really |
769 // want them messing around with the context. | 769 // want them messing around with the context. |
770 { | 770 { |
771 // Allow the shader to modify paintColor and also create an effect to be
installed as | 771 // Allow the shader to modify paintColor and also create an effect to be
installed as |
772 // the first color effect on the GrPaint. | 772 // the first color effect on the GrPaint. |
773 GrFragmentProcessor* fp = NULL; | 773 GrFragmentProcessor* fp = NULL; |
774 if (!shader->asFragmentProcessor(context, skPaint, viewM, NULL, &paintCo
lor, | 774 if (!shader->asFragmentProcessor(context, skPaint, viewM, NULL, &paintCo
lor, |
775 grPaint->getShaderDataManager(), &fp))
{ | 775 grPaint->getProcessorDataManager(), &fp
)) { |
776 return false; | 776 return false; |
777 } | 777 } |
778 if (fp) { | 778 if (fp) { |
779 grPaint->addColorProcessor(fp)->unref(); | 779 grPaint->addColorProcessor(fp)->unref(); |
780 constantColor = false; | 780 constantColor = false; |
781 } | 781 } |
782 } | 782 } |
783 | 783 |
784 // The grcolor is automatically set when calling asFragmentProcessor. | 784 // The grcolor is automatically set when calling asFragmentProcessor. |
785 // If the shader can be seen as an effect it returns true and adds its effec
t to the grpaint. | 785 // If the shader can be seen as an effect it returns true and adds its effec
t to the grpaint. |
(...skipping 14 matching lines...) Expand all Loading... |
800 } | 800 } |
801 return SkImageInfo::Make(w, h, ct, at); | 801 return SkImageInfo::Make(w, h, ct, at); |
802 } | 802 } |
803 | 803 |
804 | 804 |
805 void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, SkBitmap
* dst) { | 805 void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, SkBitmap
* dst) { |
806 const SkImageInfo info = GrMakeInfoFromTexture(src, w, h, isOpaque); | 806 const SkImageInfo info = GrMakeInfoFromTexture(src, w, h, isOpaque); |
807 dst->setInfo(info); | 807 dst->setInfo(info); |
808 dst->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, src)))->unref(); | 808 dst->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, src)))->unref(); |
809 } | 809 } |
OLD | NEW |