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

Side by Side Diff: src/gpu/effects/GrCustomXfermode.cpp

Issue 1166513002: Re-enable advanced blend with a blacklist (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix msvc Created 5 years, 6 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/gpu/GrCaps.cpp ('k') | src/gpu/gl/GrGLCaps.h » ('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 2015 Google Inc. 2 * Copyright 2015 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 "effects/GrCustomXfermode.h" 8 #include "effects/GrCustomXfermode.h"
9 #include "effects/GrCustomXfermodePriv.h" 9 #include "effects/GrCustomXfermodePriv.h"
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 GR_STATIC_ASSERT(kDifference_GrBlendEquation == SkXfermode::kDifference_Mode + kOffset); 44 GR_STATIC_ASSERT(kDifference_GrBlendEquation == SkXfermode::kDifference_Mode + kOffset);
45 GR_STATIC_ASSERT(kExclusion_GrBlendEquation == SkXfermode::kExclusion_Mode + kOffset); 45 GR_STATIC_ASSERT(kExclusion_GrBlendEquation == SkXfermode::kExclusion_Mode + kOffset);
46 GR_STATIC_ASSERT(kMultiply_GrBlendEquation == SkXfermode::kMultiply_Mode + k Offset); 46 GR_STATIC_ASSERT(kMultiply_GrBlendEquation == SkXfermode::kMultiply_Mode + k Offset);
47 GR_STATIC_ASSERT(kHSLHue_GrBlendEquation == SkXfermode::kHue_Mode + kOffset) ; 47 GR_STATIC_ASSERT(kHSLHue_GrBlendEquation == SkXfermode::kHue_Mode + kOffset) ;
48 GR_STATIC_ASSERT(kHSLSaturation_GrBlendEquation == SkXfermode::kSaturation_M ode + kOffset); 48 GR_STATIC_ASSERT(kHSLSaturation_GrBlendEquation == SkXfermode::kSaturation_M ode + kOffset);
49 GR_STATIC_ASSERT(kHSLColor_GrBlendEquation == SkXfermode::kColor_Mode + kOff set); 49 GR_STATIC_ASSERT(kHSLColor_GrBlendEquation == SkXfermode::kColor_Mode + kOff set);
50 GR_STATIC_ASSERT(kHSLLuminosity_GrBlendEquation == SkXfermode::kLuminosity_M ode + kOffset); 50 GR_STATIC_ASSERT(kHSLLuminosity_GrBlendEquation == SkXfermode::kLuminosity_M ode + kOffset);
51 GR_STATIC_ASSERT(kGrBlendEquationCnt == SkXfermode::kLastMode + 1 + kOffset) ; 51 GR_STATIC_ASSERT(kGrBlendEquationCnt == SkXfermode::kLastMode + 1 + kOffset) ;
52 } 52 }
53 53
54 static bool can_use_hw_blend_equation(const GrProcOptInfo& coveragePOI, const Gr Caps& caps) { 54 static bool can_use_hw_blend_equation(GrBlendEquation equation,
55 const GrProcOptInfo& coveragePOI,
56 const GrCaps& caps) {
55 if (!caps.advancedBlendEquationSupport()) { 57 if (!caps.advancedBlendEquationSupport()) {
56 return false; 58 return false;
57 } 59 }
58 if (coveragePOI.isFourChannelOutput()) { 60 if (coveragePOI.isFourChannelOutput()) {
59 return false; // LCD coverage must be applied after the blend equation. 61 return false; // LCD coverage must be applied after the blend equation.
60 } 62 }
63 if (caps.canUseAdvancedBlendEquation(equation)) {
64 return false;
65 }
61 return true; 66 return true;
62 } 67 }
63 68
64 static void hard_light(GrGLFragmentBuilder* fsBuilder, 69 static void hard_light(GrGLFragmentBuilder* fsBuilder,
65 const char* final, 70 const char* final,
66 const char* src, 71 const char* src,
67 const char* dst) { 72 const char* dst) {
68 static const char kComponents[] = {'r', 'g', 'b'}; 73 static const char kComponents[] = {'r', 'g', 'b'};
69 for (size_t i = 0; i < SK_ARRAY_COUNT(kComponents); ++i) { 74 for (size_t i = 0; i < SK_ARRAY_COUNT(kComponents); ++i) {
70 char component = kComponents[i]; 75 char component = kComponents[i];
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 SkASSERT(GrCustomXfermode::IsSupportedMode(fMode)); 786 SkASSERT(GrCustomXfermode::IsSupportedMode(fMode));
782 this->initClassID<GrCustomXPFactory>(); 787 this->initClassID<GrCustomXPFactory>();
783 } 788 }
784 789
785 GrXferProcessor* 790 GrXferProcessor*
786 GrCustomXPFactory::onCreateXferProcessor(const GrCaps& caps, 791 GrCustomXPFactory::onCreateXferProcessor(const GrCaps& caps,
787 const GrProcOptInfo& colorPOI, 792 const GrProcOptInfo& colorPOI,
788 const GrProcOptInfo& coveragePOI, 793 const GrProcOptInfo& coveragePOI,
789 bool hasMixedSamples, 794 bool hasMixedSamples,
790 const DstTexture* dstTexture) const { 795 const DstTexture* dstTexture) const {
791 if (can_use_hw_blend_equation(coveragePOI, caps)) { 796 if (can_use_hw_blend_equation(fHWBlendEquation, coveragePOI, caps)) {
792 SkASSERT(!dstTexture || !dstTexture->texture()); 797 SkASSERT(!dstTexture || !dstTexture->texture());
793 return SkNEW_ARGS(CustomXP, (fMode, fHWBlendEquation)); 798 return SkNEW_ARGS(CustomXP, (fMode, fHWBlendEquation));
794 } 799 }
795 return SkNEW_ARGS(CustomXP, (dstTexture, hasMixedSamples, fMode)); 800 return SkNEW_ARGS(CustomXP, (dstTexture, hasMixedSamples, fMode));
796 } 801 }
797 802
798 bool GrCustomXPFactory::willReadDstColor(const GrCaps& caps, 803 bool GrCustomXPFactory::willReadDstColor(const GrCaps& caps,
799 const GrProcOptInfo& colorPOI, 804 const GrProcOptInfo& colorPOI,
800 const GrProcOptInfo& coveragePOI, 805 const GrProcOptInfo& coveragePOI,
801 bool hasMixedSamples) const { 806 bool hasMixedSamples) const {
802 return !can_use_hw_blend_equation(coveragePOI, caps); 807 return !can_use_hw_blend_equation(fHWBlendEquation, coveragePOI, caps);
803 } 808 }
804 809
805 void GrCustomXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorPOI, 810 void GrCustomXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
806 InvariantBlendedColor* blendedC olor) const { 811 InvariantBlendedColor* blendedC olor) const {
807 blendedColor->fWillBlendWithDst = true; 812 blendedColor->fWillBlendWithDst = true;
808 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; 813 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags;
809 } 814 }
810 815
811 GR_DEFINE_XP_FACTORY_TEST(GrCustomXPFactory); 816 GR_DEFINE_XP_FACTORY_TEST(GrCustomXPFactory);
812 GrXPFactory* GrCustomXPFactory::TestCreate(SkRandom* rand, 817 GrXPFactory* GrCustomXPFactory::TestCreate(SkRandom* rand,
813 GrContext*, 818 GrContext*,
814 const GrCaps&, 819 const GrCaps&,
815 GrTexture*[]) { 820 GrTexture*[]) {
816 int mode = rand->nextRangeU(SkXfermode::kLastCoeffMode + 1, SkXfermode::kLas tSeparableMode); 821 int mode = rand->nextRangeU(SkXfermode::kLastCoeffMode + 1, SkXfermode::kLas tSeparableMode);
817 822
818 return SkNEW_ARGS(GrCustomXPFactory, (static_cast<SkXfermode::Mode>(mode))); 823 return SkNEW_ARGS(GrCustomXPFactory, (static_cast<SkXfermode::Mode>(mode)));
819 } 824 }
820 825
OLDNEW
« no previous file with comments | « src/gpu/GrCaps.cpp ('k') | src/gpu/gl/GrGLCaps.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698