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

Side by Side Diff: src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp

Issue 1037123003: Implement support for KHR_blend_equation_advanced (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_zzz2_barriers
Patch Set: Compiler warning Created 5 years, 7 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 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 "GrGLFragmentShaderBuilder.h" 8 #include "GrGLFragmentShaderBuilder.h"
9 #include "GrGLProgramBuilder.h" 9 #include "GrGLProgramBuilder.h"
10 #include "../GrGLGpu.h" 10 #include "../GrGLGpu.h"
(...skipping 18 matching lines...) Expand all
29 break; 29 break;
30 case kLow_GrSLPrecision: 30 case kLow_GrSLPrecision:
31 str->append("precision lowp float;\n"); 31 str->append("precision lowp float;\n");
32 break; 32 break;
33 default: 33 default:
34 SkFAIL("Unknown precision value."); 34 SkFAIL("Unknown precision value.");
35 } 35 }
36 } 36 }
37 } 37 }
38 38
39 static const char* specific_layout_qualifier_name(GrBlendEquation equation) {
40 SkASSERT(GrBlendEquationIsAdvanced(equation));
41
42 static const char* kLayoutQualifierNames[] = {
43 "blend_support_screen",
44 "blend_support_overlay",
45 "blend_support_darken",
46 "blend_support_lighten",
47 "blend_support_colordodge",
48 "blend_support_colorburn",
49 "blend_support_hardlight",
50 "blend_support_softlight",
51 "blend_support_difference",
52 "blend_support_exclusion",
53 "blend_support_multiply",
54 "blend_support_hsl_hue",
55 "blend_support_hsl_saturation",
56 "blend_support_hsl_color",
57 "blend_support_hsl_luminosity"
58 };
59 return kLayoutQualifierNames[equation - kFirstAdvancedGrBlendEquation];
60
61 GR_STATIC_ASSERT(0 == kScreen_GrBlendEquation - kFirstAdvancedGrBlendEquatio n);
62 GR_STATIC_ASSERT(1 == kOverlay_GrBlendEquation - kFirstAdvancedGrBlendEquati on);
63 GR_STATIC_ASSERT(2 == kDarken_GrBlendEquation - kFirstAdvancedGrBlendEquatio n);
64 GR_STATIC_ASSERT(3 == kLighten_GrBlendEquation - kFirstAdvancedGrBlendEquati on);
65 GR_STATIC_ASSERT(4 == kColorDodge_GrBlendEquation - kFirstAdvancedGrBlendEqu ation);
66 GR_STATIC_ASSERT(5 == kColorBurn_GrBlendEquation - kFirstAdvancedGrBlendEqua tion);
67 GR_STATIC_ASSERT(6 == kHardLight_GrBlendEquation - kFirstAdvancedGrBlendEqua tion);
68 GR_STATIC_ASSERT(7 == kSoftLight_GrBlendEquation - kFirstAdvancedGrBlendEqua tion);
69 GR_STATIC_ASSERT(8 == kDifference_GrBlendEquation - kFirstAdvancedGrBlendEqu ation);
70 GR_STATIC_ASSERT(9 == kExclusion_GrBlendEquation - kFirstAdvancedGrBlendEqua tion);
71 GR_STATIC_ASSERT(10 == kMultiply_GrBlendEquation - kFirstAdvancedGrBlendEqua tion);
72 GR_STATIC_ASSERT(11 == kHSLHue_GrBlendEquation - kFirstAdvancedGrBlendEquati on);
73 GR_STATIC_ASSERT(12 == kHSLSaturation_GrBlendEquation - kFirstAdvancedGrBlen dEquation);
74 GR_STATIC_ASSERT(13 == kHSLColor_GrBlendEquation - kFirstAdvancedGrBlendEqua tion);
75 GR_STATIC_ASSERT(14 == kHSLLuminosity_GrBlendEquation - kFirstAdvancedGrBlen dEquation);
76 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kLayoutQualifierNames) ==
77 kTotalGrBlendEquationCount - kFirstAdvancedGrBlendEquation) ;
78 }
79
39 GrGLFragmentShaderBuilder::DstReadKey 80 GrGLFragmentShaderBuilder::DstReadKey
40 GrGLFragmentShaderBuilder::KeyForDstRead(const GrTexture* dstCopy, const GrGLCap s& caps) { 81 GrGLFragmentShaderBuilder::KeyForDstRead(const GrTexture* dstCopy, const GrGLCap s& caps) {
41 uint32_t key = kYesDstRead_DstReadKeyBit; 82 uint32_t key = kYesDstRead_DstReadKeyBit;
42 if (caps.glslCaps()->fbFetchSupport()) { 83 if (caps.glslCaps()->fbFetchSupport()) {
43 return key; 84 return key;
44 } 85 }
45 SkASSERT(dstCopy); 86 SkASSERT(dstCopy);
46 if (!caps.textureSwizzleSupport() && GrPixelConfigIsAlphaOnly(dstCopy->confi g())) { 87 if (!caps.textureSwizzleSupport() && GrPixelConfigIsAlphaOnly(dstCopy->confi g())) {
47 // The fact that the config is alpha-only must be considered when genera ting code. 88 // The fact that the config is alpha-only must be considered when genera ting code.
48 key |= kUseAlphaConfig_DstReadKeyBit; 89 key |= kUseAlphaConfig_DstReadKeyBit;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 this->enableCustomOutput(); 217 this->enableCustomOutput();
177 fOutputs[fCustomColorOutputIndex].setTypeModifier(GrShaderVar::kInOu t_TypeModifier); 218 fOutputs[fCustomColorOutputIndex].setTypeModifier(GrShaderVar::kInOu t_TypeModifier);
178 fbFetchColorName = declared_color_output_name(); 219 fbFetchColorName = declared_color_output_name();
179 } 220 }
180 return fbFetchColorName; 221 return fbFetchColorName;
181 } else { 222 } else {
182 return kDstCopyColorName; 223 return kDstCopyColorName;
183 } 224 }
184 } 225 }
185 226
227 void GrGLFragmentShaderBuilder::enableAdvancedBlendEquationIfNeeded(GrBlendEquat ion equation) {
228 SkASSERT(GrBlendEquationIsAdvanced(equation));
229
230 const GrGLSLCaps& caps = *fProgramBuilder->gpu()->glCaps().glslCaps();
231 if (!caps.mustEnableAdvBlendEqs()) {
232 return;
233 }
234
235 this->addFeature(1 << kBlendEquationAdvanced_GLSLPrivateFeature,
236 "GL_KHR_blend_equation_advanced");
237 if (caps.mustEnableSpecificAdvBlendEqs()) {
238 this->addLayoutQualifier(specific_layout_qualifier_name(equation), kOut_ InterfaceQualifier);
239 } else {
240 this->addLayoutQualifier("blend_support_all_equations", kOut_InterfaceQu alifier);
241 }
242 }
243
186 void GrGLFragmentShaderBuilder::enableCustomOutput() { 244 void GrGLFragmentShaderBuilder::enableCustomOutput() {
187 if (!fHasCustomColorOutput) { 245 if (!fHasCustomColorOutput) {
188 fHasCustomColorOutput = true; 246 fHasCustomColorOutput = true;
189 fCustomColorOutputIndex = fOutputs.count(); 247 fCustomColorOutputIndex = fOutputs.count();
190 fOutputs.push_back().set(kVec4f_GrSLType, 248 fOutputs.push_back().set(kVec4f_GrSLType,
191 GrGLShaderVar::kOut_TypeModifier, 249 GrGLShaderVar::kOut_TypeModifier,
192 declared_color_output_name()); 250 declared_color_output_name());
193 } 251 }
194 } 252 }
195 253
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } 294 }
237 } 295 }
238 296
239 void GrGLFragmentShaderBuilder::addVarying(GrGLVarying* v, GrSLPrecision fsPrec) { 297 void GrGLFragmentShaderBuilder::addVarying(GrGLVarying* v, GrSLPrecision fsPrec) {
240 v->fFsIn = v->fVsOut; 298 v->fFsIn = v->fVsOut;
241 if (v->fGsOut) { 299 if (v->fGsOut) {
242 v->fFsIn = v->fGsOut; 300 v->fFsIn = v->fGsOut;
243 } 301 }
244 fInputs.push_back().set(v->fType, GrGLShaderVar::kVaryingIn_TypeModifier, v- >fFsIn, fsPrec); 302 fInputs.push_back().set(v->fType, GrGLShaderVar::kVaryingIn_TypeModifier, v- >fFsIn, fsPrec);
245 } 303 }
OLDNEW
« no previous file with comments | « src/gpu/gl/builders/GrGLFragmentShaderBuilder.h ('k') | src/gpu/gl/builders/GrGLShaderBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698