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

Side by Side Diff: src/gpu/gl/GrGLShaderBuilder.cpp

Issue 163913007: Implement support for CHROMIUM_NV_path_rendering pseudo extension (Closed) Base URL: https://skia.googlesource.com/skia.git@nv-pr-00-use-attribs
Patch Set: rebase Created 6 years, 8 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/gl/GrGLShaderBuilder.h ('k') | src/gpu/gl/GrGpuGL_program.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 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 "gl/GrGLShaderBuilder.h" 8 #include "gl/GrGLShaderBuilder.h"
9 #include "gl/GrGLProgram.h" 9 #include "gl/GrGLProgram.h"
10 #include "gl/GrGLUniformHandle.h" 10 #include "gl/GrGLUniformHandle.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 switch (feature) { 179 switch (feature) {
180 case kStandardDerivatives_GLSLFeature: 180 case kStandardDerivatives_GLSLFeature:
181 if (!fGpu->glCaps().shaderDerivativeSupport()) { 181 if (!fGpu->glCaps().shaderDerivativeSupport()) {
182 return false; 182 return false;
183 } 183 }
184 if (kGLES_GrGLStandard == fGpu->glStandard()) { 184 if (kGLES_GrGLStandard == fGpu->glStandard()) {
185 this->addFSFeature(1 << kStandardDerivatives_GLSLFeature, 185 this->addFSFeature(1 << kStandardDerivatives_GLSLFeature,
186 "GL_OES_standard_derivatives"); 186 "GL_OES_standard_derivatives");
187 } 187 }
188 return true; 188 return true;
189 case kTexCoordSupport_GLSLFeature:
190 if (!fGpu->glCaps().pathRenderingSupport()) {
191 return false;
192 }
193 if (kGLES_GrGLStandard == fGpu->glStandard()) {
194 this->addFSFeature(1 << kTexCoordSupport_GLSLFeature,
195 "GL_CHROMIUM_path_rendering");
196 }
197 return true;
189 default: 198 default:
190 GrCrash("Unexpected GLSLFeature requested."); 199 GrCrash("Unexpected GLSLFeature requested.");
191 return false; 200 return false;
192 } 201 }
193 } 202 }
194 203
195 bool GrGLShaderBuilder::enablePrivateFeature(GLSLPrivateFeature feature) { 204 bool GrGLShaderBuilder::enablePrivateFeature(GLSLPrivateFeature feature) {
196 switch (feature) { 205 switch (feature) {
197 case kFragCoordConventions_GLSLPrivateFeature: 206 case kFragCoordConventions_GLSLPrivateFeature:
198 if (!fGpu->glCaps().fragCoordConventionsSupport()) { 207 if (!fGpu->glCaps().fragCoordConventionsSupport()) {
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 : INHERITED(gpu, uniformManager, desc) 978 : INHERITED(gpu, uniformManager, desc)
970 , fNumTexCoordSets(0) { 979 , fNumTexCoordSets(0) {
971 980
972 SkASSERT(!desc.getHeader().fHasVertexCode); 981 SkASSERT(!desc.getHeader().fHasVertexCode);
973 SkASSERT(gpu->glCaps().pathRenderingSupport()); 982 SkASSERT(gpu->glCaps().pathRenderingSupport());
974 SkASSERT(GrGLProgramDesc::kAttribute_ColorInput != desc.getHeader().fColorIn put); 983 SkASSERT(GrGLProgramDesc::kAttribute_ColorInput != desc.getHeader().fColorIn put);
975 SkASSERT(GrGLProgramDesc::kAttribute_ColorInput != desc.getHeader().fCoverag eInput); 984 SkASSERT(GrGLProgramDesc::kAttribute_ColorInput != desc.getHeader().fCoverag eInput);
976 } 985 }
977 986
978 int GrGLFragmentOnlyShaderBuilder::addTexCoordSets(int count) { 987 int GrGLFragmentOnlyShaderBuilder::addTexCoordSets(int count) {
988 SkAssertResult(this->enableFeature(kTexCoordSupport_GLSLFeature));
979 int firstFreeCoordSet = fNumTexCoordSets; 989 int firstFreeCoordSet = fNumTexCoordSets;
980 fNumTexCoordSets += count; 990 fNumTexCoordSets += count;
981 SkASSERT(gpu()->glCaps().maxFixedFunctionTextureCoords() >= fNumTexCoordSets ); 991 SkASSERT(gpu()->glCaps().maxFixedFunctionTextureCoords() >= fNumTexCoordSets );
982 return firstFreeCoordSet; 992 return firstFreeCoordSet;
983 } 993 }
984 994
985 GrGLProgramEffects* GrGLFragmentOnlyShaderBuilder::createAndEmitEffects( 995 GrGLProgramEffects* GrGLFragmentOnlyShaderBuilder::createAndEmitEffects(
986 const GrEffectStage* effectStages[], 996 const GrEffectStage* effectStages[],
987 const EffectKey effectKeys[], 997 const EffectKey effectKeys[],
988 int effectCnt, 998 int effectCnt,
989 GrGLSLExpr4* inOutFSColor) { 999 GrGLSLExpr4* inOutFSColor) {
990 1000
991 GrGLPathTexGenProgramEffectsBuilder pathTexGenEffectsBuilder(this, 1001 GrGLPathTexGenProgramEffectsBuilder pathTexGenEffectsBuilder(this,
992 effectCnt); 1002 effectCnt);
993 this->INHERITED::createAndEmitEffects(&pathTexGenEffectsBuilder, 1003 this->INHERITED::createAndEmitEffects(&pathTexGenEffectsBuilder,
994 effectStages, 1004 effectStages,
995 effectKeys, 1005 effectKeys,
996 effectCnt, 1006 effectCnt,
997 inOutFSColor); 1007 inOutFSColor);
998 return pathTexGenEffectsBuilder.finish(); 1008 return pathTexGenEffectsBuilder.finish();
999 } 1009 }
1010
1011 bool GrGLFragmentOnlyShaderBuilder::compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>* shaderIds) const {
1012 // Command buffer does not support vertexshader-less programs.
1013 // Use a dummy shader.
1014 const GrGLContext& glCtx = this->gpu()->glContext();
1015 SkString vertShaderSrc(GrGetGLSLVersionDecl(this->ctxInfo()));
1016 vertShaderSrc.append("void main() {\n");
1017 vertShaderSrc.append("gl_Position = vec4(1);");
1018 vertShaderSrc.append("}\n");
1019 GrGLuint vertShaderId = attach_shader(glCtx, programId, GR_GL_VERTEX_SHADER, vertShaderSrc);
1020 if (!vertShaderId) {
1021 return false;
1022 }
1023 *shaderIds->append() = vertShaderId;
1024
1025 return this->INHERITED::compileAndAttachShaders(programId, shaderIds);
1026 }
1027
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLShaderBuilder.h ('k') | src/gpu/gl/GrGpuGL_program.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698