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

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

Issue 367643004: Implement NVPR on GLES (Closed) Base URL: https://skia.googlesource.com/skia.git@02-path-program-fragment
Patch Set: Created 6 years, 5 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 2011 Google Inc. 2 * Copyright 2011 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 "GrGLProgram.h" 8 #include "GrGLProgram.h"
9 9
10 #include "GrAllocator.h" 10 #include "GrAllocator.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 if (fBuilderOutput.fUniformHandles.fDstCopySamplerUni.isValid()) { 86 if (fBuilderOutput.fUniformHandles.fDstCopySamplerUni.isValid()) {
87 fUniformManager->setSampler(fBuilderOutput.fUniformHandles.fDstCopySampl erUni, texUnitIdx); 87 fUniformManager->setSampler(fBuilderOutput.fUniformHandles.fDstCopySampl erUni, texUnitIdx);
88 fDstCopyTexUnit = texUnitIdx++; 88 fDstCopyTexUnit = texUnitIdx++;
89 } 89 }
90 fBuilderOutput.fColorEffects->initSamplers(*fUniformManager, &texUnitIdx); 90 fBuilderOutput.fColorEffects->initSamplers(*fUniformManager, &texUnitIdx);
91 fBuilderOutput.fCoverageEffects->initSamplers(*fUniformManager, &texUnitIdx) ; 91 fBuilderOutput.fCoverageEffects->initSamplers(*fUniformManager, &texUnitIdx) ;
92 } 92 }
93 93
94 /////////////////////////////////////////////////////////////////////////////// 94 ///////////////////////////////////////////////////////////////////////////////
95 95
96 void GrGLProgram::setData(GrDrawState::BlendOptFlags blendOpts, 96 void GrGLProgram::setData(GrGpu::DrawType drawType,
97 GrDrawState::BlendOptFlags blendOpts,
97 const GrEffectStage* colorStages[], 98 const GrEffectStage* colorStages[],
98 const GrEffectStage* coverageStages[], 99 const GrEffectStage* coverageStages[],
99 const GrDeviceCoordTexture* dstCopy, 100 const GrDeviceCoordTexture* dstCopy,
100 SharedGLState* sharedState) { 101 SharedGLState* sharedState) {
101 const GrDrawState& drawState = fGpu->getDrawState(); 102 const GrDrawState& drawState = fGpu->getDrawState();
102 103
103 GrColor color; 104 GrColor color;
104 GrColor coverage; 105 GrColor coverage;
105 if (blendOpts & GrDrawState::kEmitTransBlack_BlendOptFlag) { 106 if (blendOpts & GrDrawState::kEmitTransBlack_BlendOptFlag) {
106 color = 0; 107 color = 0;
107 coverage = 0; 108 coverage = 0;
108 } else if (blendOpts & GrDrawState::kEmitCoverage_BlendOptFlag) { 109 } else if (blendOpts & GrDrawState::kEmitCoverage_BlendOptFlag) {
109 color = 0xffffffff; 110 color = 0xffffffff;
110 coverage = drawState.getCoverageColor(); 111 coverage = drawState.getCoverageColor();
111 } else { 112 } else {
112 color = drawState.getColor(); 113 color = drawState.getColor();
113 coverage = drawState.getCoverageColor(); 114 coverage = drawState.getCoverageColor();
114 } 115 }
115 116
116 this->setColor(drawState, color, sharedState); 117 this->setColor(drawState, color, sharedState);
117 this->setCoverage(drawState, coverage, sharedState); 118 this->setCoverage(drawState, coverage, sharedState);
118 this->setMatrixAndRenderTargetHeight(drawState); 119 this->setMatrixAndRenderTargetHeight(drawType, drawState);
119 120
120 if (NULL != dstCopy) { 121 if (NULL != dstCopy) {
121 if (fBuilderOutput.fUniformHandles.fDstCopyTopLeftUni.isValid()) { 122 if (fBuilderOutput.fUniformHandles.fDstCopyTopLeftUni.isValid()) {
122 fUniformManager->set2f(fBuilderOutput.fUniformHandles.fDstCopyTopLef tUni, 123 fUniformManager->set2f(fBuilderOutput.fUniformHandles.fDstCopyTopLef tUni,
123 static_cast<GrGLfloat>(dstCopy->offset().fX), 124 static_cast<GrGLfloat>(dstCopy->offset().fX),
124 static_cast<GrGLfloat>(dstCopy->offset().fY)) ; 125 static_cast<GrGLfloat>(dstCopy->offset().fY)) ;
125 fUniformManager->set2f(fBuilderOutput.fUniformHandles.fDstCopyScaleU ni, 126 fUniformManager->set2f(fBuilderOutput.fUniformHandles.fDstCopyScaleU ni,
126 1.f / dstCopy->texture()->width(), 127 1.f / dstCopy->texture()->width(),
127 1.f / dstCopy->texture()->height()); 128 1.f / dstCopy->texture()->height());
128 GrGLTexture* texture = static_cast<GrGLTexture*>(dstCopy->texture()) ; 129 GrGLTexture* texture = static_cast<GrGLTexture*>(dstCopy->texture()) ;
129 static GrTextureParams kParams; // the default is clamp, nearest fil tering. 130 static GrTextureParams kParams; // the default is clamp, nearest fil tering.
130 fGpu->bindTexture(fDstCopyTexUnit, kParams, texture); 131 fGpu->bindTexture(fDstCopyTexUnit, kParams, texture);
131 } else { 132 } else {
132 SkASSERT(!fBuilderOutput.fUniformHandles.fDstCopyScaleUni.isValid()) ; 133 SkASSERT(!fBuilderOutput.fUniformHandles.fDstCopyScaleUni.isValid()) ;
133 SkASSERT(!fBuilderOutput.fUniformHandles.fDstCopySamplerUni.isValid( )); 134 SkASSERT(!fBuilderOutput.fUniformHandles.fDstCopySamplerUni.isValid( ));
134 } 135 }
135 } else { 136 } else {
136 SkASSERT(!fBuilderOutput.fUniformHandles.fDstCopyTopLeftUni.isValid()); 137 SkASSERT(!fBuilderOutput.fUniformHandles.fDstCopyTopLeftUni.isValid());
137 SkASSERT(!fBuilderOutput.fUniformHandles.fDstCopyScaleUni.isValid()); 138 SkASSERT(!fBuilderOutput.fUniformHandles.fDstCopyScaleUni.isValid());
138 SkASSERT(!fBuilderOutput.fUniformHandles.fDstCopySamplerUni.isValid()); 139 SkASSERT(!fBuilderOutput.fUniformHandles.fDstCopySamplerUni.isValid());
139 } 140 }
140 141
141 fBuilderOutput.fColorEffects->setData(fGpu, *fUniformManager, colorStages); 142 fBuilderOutput.fColorEffects->setData(fGpu, drawType, *fUniformManager, colo rStages);
142 fBuilderOutput.fCoverageEffects->setData(fGpu, *fUniformManager, coverageSta ges); 143 fBuilderOutput.fCoverageEffects->setData(fGpu, drawType, *fUniformManager, c overageStages);
143 144
144 145
145 // PathTexGen state applies to the the fixed function vertex shader. For 146 // PathTexGen state applies to the the fixed function vertex shader. For
146 // custom shaders, it's ignored, so we don't need to change the texgen 147 // custom shaders, it's ignored, so we don't need to change the texgen
147 // settings in that case. 148 // settings in that case.
148 if (!fBuilderOutput.fHasVertexShader) { 149 if (!fBuilderOutput.fHasVertexShader) {
149 fGpu->flushPathTexGenSettings(fBuilderOutput.fTexCoordSetCnt); 150 fGpu->flushPathTexGenSettings(fBuilderOutput.fTexCoordSetCnt);
150 } 151 }
151 } 152 }
152 153
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 sharedState->fConstAttribCoverageIndex = -1; 223 sharedState->fConstAttribCoverageIndex = -1;
223 break; 224 break;
224 default: 225 default:
225 SkFAIL("Unknown coverage type."); 226 SkFAIL("Unknown coverage type.");
226 } 227 }
227 } else { 228 } else {
228 sharedState->fConstAttribCoverageIndex = -1; 229 sharedState->fConstAttribCoverageIndex = -1;
229 } 230 }
230 } 231 }
231 232
232 void GrGLProgram::setMatrixAndRenderTargetHeight(const GrDrawState& drawState) { 233 void GrGLProgram::setMatrixAndRenderTargetHeight(GrGpu::DrawType drawType,
234 const GrDrawState& drawState) {
233 const GrRenderTarget* rt = drawState.getRenderTarget(); 235 const GrRenderTarget* rt = drawState.getRenderTarget();
234 SkISize size; 236 SkISize size;
235 size.set(rt->width(), rt->height()); 237 size.set(rt->width(), rt->height());
236 238
237 // Load the RT height uniform if it is needed to y-flip gl_FragCoord. 239 // Load the RT height uniform if it is needed to y-flip gl_FragCoord.
238 if (fBuilderOutput.fUniformHandles.fRTHeightUni.isValid() && 240 if (fBuilderOutput.fUniformHandles.fRTHeightUni.isValid() &&
239 fMatrixState.fRenderTargetSize.fHeight != size.fHeight) { 241 fMatrixState.fRenderTargetSize.fHeight != size.fHeight) {
240 fUniformManager->set1f(fBuilderOutput.fUniformHandles.fRTHeightUni, 242 fUniformManager->set1f(fBuilderOutput.fUniformHandles.fRTHeightUni,
241 SkIntToScalar(size.fHeight)); 243 SkIntToScalar(size.fHeight));
242 } 244 }
243 245
244 if (!fBuilderOutput.fHasVertexShader) { 246 if (GrGpu::IsPathRenderingDrawType(drawType)) {
245 SkASSERT(!fBuilderOutput.fUniformHandles.fViewMatrixUni.isValid());
246 SkASSERT(!fBuilderOutput.fUniformHandles.fRTAdjustmentUni.isValid());
247 fGpu->setProjectionMatrix(drawState.getViewMatrix(), size, rt->origin()) ; 247 fGpu->setProjectionMatrix(drawState.getViewMatrix(), size, rt->origin()) ;
248 } else if (fMatrixState.fRenderTargetOrigin != rt->origin() || 248 } else if (fMatrixState.fRenderTargetOrigin != rt->origin() ||
249 fMatrixState.fRenderTargetSize != size || 249 fMatrixState.fRenderTargetSize != size ||
250 !fMatrixState.fViewMatrix.cheapEqualTo(drawState.getViewMatrix()) ) { 250 !fMatrixState.fViewMatrix.cheapEqualTo(drawState.getViewMatrix()) ) {
251 SkASSERT(fBuilderOutput.fUniformHandles.fViewMatrixUni.isValid()); 251 SkASSERT(fBuilderOutput.fUniformHandles.fViewMatrixUni.isValid());
252 252
253 fMatrixState.fViewMatrix = drawState.getViewMatrix(); 253 fMatrixState.fViewMatrix = drawState.getViewMatrix();
254 fMatrixState.fRenderTargetSize = size; 254 fMatrixState.fRenderTargetSize = size;
255 fMatrixState.fRenderTargetOrigin = rt->origin(); 255 fMatrixState.fRenderTargetOrigin = rt->origin();
256 256
257 GrGLfloat viewMatrix[3 * 3]; 257 GrGLfloat viewMatrix[3 * 3];
258 fMatrixState.getGLMatrix<3>(viewMatrix); 258 fMatrixState.getGLMatrix<3>(viewMatrix);
259 fUniformManager->setMatrix3f(fBuilderOutput.fUniformHandles.fViewMatrixU ni, viewMatrix); 259 fUniformManager->setMatrix3f(fBuilderOutput.fUniformHandles.fViewMatrixU ni, viewMatrix);
260 260
261 GrGLfloat rtAdjustmentVec[4]; 261 GrGLfloat rtAdjustmentVec[4];
262 fMatrixState.getRTAdjustmentVec(rtAdjustmentVec); 262 fMatrixState.getRTAdjustmentVec(rtAdjustmentVec);
263 fUniformManager->set4fv(fBuilderOutput.fUniformHandles.fRTAdjustmentUni, 1, rtAdjustmentVec); 263 fUniformManager->set4fv(fBuilderOutput.fUniformHandles.fRTAdjustmentUni, 1, rtAdjustmentVec);
264 } 264 }
265 } 265 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698