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

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

Issue 789343002: Revert of Create xfer processor backend. (Closed) Base URL: https://skia.googlesource.com/skia.git@xferBlendSolo
Patch Set: Created 6 years 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/GrGLProgram.h ('k') | src/gpu/gl/GrGLProgramDesc.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 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"
11 #include "GrProcessor.h" 11 #include "GrProcessor.h"
12 #include "GrCoordTransform.h" 12 #include "GrCoordTransform.h"
13 #include "GrGLGeometryProcessor.h" 13 #include "GrGLGeometryProcessor.h"
14 #include "GrGLProcessor.h" 14 #include "GrGLProcessor.h"
15 #include "GrGLXferProcessor.h"
16 #include "GrGpuGL.h" 15 #include "GrGpuGL.h"
17 #include "GrGLPathRendering.h" 16 #include "GrGLPathRendering.h"
18 #include "GrGLShaderVar.h" 17 #include "GrGLShaderVar.h"
19 #include "GrGLSL.h" 18 #include "GrGLSL.h"
20 #include "GrOptDrawState.h" 19 #include "GrOptDrawState.h"
21 #include "GrXferProcessor.h"
22 #include "SkXfermode.h" 20 #include "SkXfermode.h"
23 21
24 #define GL_CALL(X) GR_GL_CALL(fGpu->glInterface(), X) 22 #define GL_CALL(X) GR_GL_CALL(fGpu->glInterface(), X)
25 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fGpu->glInterface(), R, X) 23 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fGpu->glInterface(), R, X)
26 24
27 /** 25 /**
28 * Retrieves the final matrix that a transform needs to apply to its source coor ds. 26 * Retrieves the final matrix that a transform needs to apply to its source coor ds.
29 */ 27 */
30 static SkMatrix get_transform_matrix(const GrPendingFragmentStage& stage, int tr ansformIdx) { 28 static SkMatrix get_transform_matrix(const GrPendingFragmentStage& stage, int tr ansformIdx) {
31 const GrCoordTransform& coordTransform = stage.getProcessor()->coordTransfor m(transformIdx); 29 const GrCoordTransform& coordTransform = stage.getProcessor()->coordTransfor m(transformIdx);
(...skipping 20 matching lines...) Expand all
52 } 50 }
53 51
54 //////////////////////////////////////////////////////////////////////////////// /////////////////// 52 //////////////////////////////////////////////////////////////////////////////// ///////////////////
55 53
56 GrGLProgram::GrGLProgram(GrGpuGL* gpu, 54 GrGLProgram::GrGLProgram(GrGpuGL* gpu,
57 const GrProgramDesc& desc, 55 const GrProgramDesc& desc,
58 const BuiltinUniformHandles& builtinUniforms, 56 const BuiltinUniformHandles& builtinUniforms,
59 GrGLuint programID, 57 GrGLuint programID,
60 const UniformInfoArray& uniforms, 58 const UniformInfoArray& uniforms,
61 GrGLInstalledGeoProc* geometryProcessor, 59 GrGLInstalledGeoProc* geometryProcessor,
62 GrGLInstalledXferProc* xferProcessor,
63 GrGLInstalledFragProcs* fragmentProcessors) 60 GrGLInstalledFragProcs* fragmentProcessors)
64 : fColor(GrColor_ILLEGAL) 61 : fColor(GrColor_ILLEGAL)
65 , fCoverage(0) 62 , fCoverage(0)
66 , fDstCopyTexUnit(-1) 63 , fDstCopyTexUnit(-1)
67 , fBuiltinUniformHandles(builtinUniforms) 64 , fBuiltinUniformHandles(builtinUniforms)
68 , fProgramID(programID) 65 , fProgramID(programID)
69 , fGeometryProcessor(geometryProcessor) 66 , fGeometryProcessor(geometryProcessor)
70 , fXferProcessor(xferProcessor)
71 , fFragmentProcessors(SkRef(fragmentProcessors)) 67 , fFragmentProcessors(SkRef(fragmentProcessors))
72 , fDesc(desc) 68 , fDesc(desc)
73 , fGpu(gpu) 69 , fGpu(gpu)
74 , fProgramDataManager(gpu, uniforms) { 70 , fProgramDataManager(gpu, uniforms) {
75 this->initSamplerUniforms(); 71 this->initSamplerUniforms();
76 } 72 }
77 73
78 GrGLProgram::~GrGLProgram() { 74 GrGLProgram::~GrGLProgram() {
79 if (fProgramID) { 75 if (fProgramID) {
80 GL_CALL(DeleteProgram(fProgramID)); 76 GL_CALL(DeleteProgram(fProgramID));
81 } 77 }
82 } 78 }
83 79
84 void GrGLProgram::abandon() { 80 void GrGLProgram::abandon() {
85 fProgramID = 0; 81 fProgramID = 0;
86 } 82 }
87 83
88 void GrGLProgram::initSamplerUniforms() { 84 void GrGLProgram::initSamplerUniforms() {
89 GL_CALL(UseProgram(fProgramID)); 85 GL_CALL(UseProgram(fProgramID));
90 GrGLint texUnitIdx = 0; 86 GrGLint texUnitIdx = 0;
91 if (fBuiltinUniformHandles.fDstCopySamplerUni.isValid()) { 87 if (fBuiltinUniformHandles.fDstCopySamplerUni.isValid()) {
92 fProgramDataManager.setSampler(fBuiltinUniformHandles.fDstCopySamplerUni , texUnitIdx); 88 fProgramDataManager.setSampler(fBuiltinUniformHandles.fDstCopySamplerUni , texUnitIdx);
93 fDstCopyTexUnit = texUnitIdx++; 89 fDstCopyTexUnit = texUnitIdx++;
94 } 90 }
95 if (fGeometryProcessor.get()) { 91 if (fGeometryProcessor.get()) {
96 this->initSamplers(fGeometryProcessor.get(), &texUnitIdx); 92 this->initSamplers(fGeometryProcessor.get(), &texUnitIdx);
97 } 93 }
98 if (fXferProcessor.get()) {
99 this->initSamplers(fXferProcessor.get(), &texUnitIdx);
100 }
101 int numProcs = fFragmentProcessors->fProcs.count(); 94 int numProcs = fFragmentProcessors->fProcs.count();
102 for (int i = 0; i < numProcs; i++) { 95 for (int i = 0; i < numProcs; i++) {
103 this->initSamplers(fFragmentProcessors->fProcs[i], &texUnitIdx); 96 this->initSamplers(fFragmentProcessors->fProcs[i], &texUnitIdx);
104 } 97 }
105 } 98 }
106 99
107 void GrGLProgram::initSamplers(GrGLInstalledProc* ip, int* texUnitIdx) { 100 void GrGLProgram::initSamplers(GrGLInstalledProc* ip, int* texUnitIdx) {
108 SkTArray<GrGLInstalledProc::Sampler, true>& samplers = ip->fSamplers; 101 SkTArray<GrGLInstalledProc::Sampler, true>& samplers = ip->fSamplers;
109 int numSamplers = samplers.count(); 102 int numSamplers = samplers.count();
110 for (int s = 0; s < numSamplers; ++s) { 103 for (int s = 0; s < numSamplers; ++s) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 155
163 // we set the textures, and uniforms for installed processors in a generic w ay, but subclasses 156 // we set the textures, and uniforms for installed processors in a generic w ay, but subclasses
164 // of GLProgram determine how to set coord transforms 157 // of GLProgram determine how to set coord transforms
165 if (fGeometryProcessor.get()) { 158 if (fGeometryProcessor.get()) {
166 SkASSERT(optState.hasGeometryProcessor()); 159 SkASSERT(optState.hasGeometryProcessor());
167 const GrGeometryProcessor& gp = *optState.getGeometryProcessor(); 160 const GrGeometryProcessor& gp = *optState.getGeometryProcessor();
168 const GrBatchTracker& bt = optState.getBatchTracker(); 161 const GrBatchTracker& bt = optState.getBatchTracker();
169 fGeometryProcessor->fGLProc->setData(fProgramDataManager, gp, bt); 162 fGeometryProcessor->fGLProc->setData(fProgramDataManager, gp, bt);
170 this->bindTextures(fGeometryProcessor, gp); 163 this->bindTextures(fGeometryProcessor, gp);
171 } 164 }
172 if (fXferProcessor.get()) {
173 const GrXferProcessor& xp = *optState.getXferProcessor();
174 fXferProcessor->fGLProc->setData(fProgramDataManager, xp);
175 this->bindTextures(fXferProcessor, xp);
176 }
177 this->setFragmentData(optState); 165 this->setFragmentData(optState);
178 166
179 // Some of GrGLProgram subclasses need to update state here 167 // Some of GrGLProgram subclasses need to update state here
180 this->didSetData(optState.drawType()); 168 this->didSetData(optState.drawType());
181 } 169 }
182 170
183 void GrGLProgram::setFragmentData(const GrOptDrawState& optState) { 171 void GrGLProgram::setFragmentData(const GrOptDrawState& optState) {
184 int numProcessors = fFragmentProcessors->fProcs.count(); 172 int numProcessors = fFragmentProcessors->fProcs.count();
185 for (int e = 0; e < numProcessors; ++e) { 173 for (int e = 0; e < numProcessors; ++e) {
186 const GrPendingFragmentStage& stage = optState.getFragmentStage(e); 174 const GrPendingFragmentStage& stage = optState.getFragmentStage(e);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 } 277 }
290 } 278 }
291 279
292 //////////////////////////////////////////////////////////////////////////////// ///////// 280 //////////////////////////////////////////////////////////////////////////////// /////////
293 281
294 GrGLNvprProgramBase::GrGLNvprProgramBase(GrGpuGL* gpu, 282 GrGLNvprProgramBase::GrGLNvprProgramBase(GrGpuGL* gpu,
295 const GrProgramDesc& desc, 283 const GrProgramDesc& desc,
296 const BuiltinUniformHandles& builtinUni forms, 284 const BuiltinUniformHandles& builtinUni forms,
297 GrGLuint programID, 285 GrGLuint programID,
298 const UniformInfoArray& uniforms, 286 const UniformInfoArray& uniforms,
299 GrGLInstalledXferProc* xferProcessor,
300 GrGLInstalledFragProcs* fragmentProcess ors) 287 GrGLInstalledFragProcs* fragmentProcess ors)
301 : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, NULL, 288 : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, NULL, fragmentP rocessors) {
302 xferProcessor, fragmentProcessors) {
303 } 289 }
304 290
305 void GrGLNvprProgramBase::onSetMatrixAndRenderTargetHeight(const GrOptDrawState& optState) { 291 void GrGLNvprProgramBase::onSetMatrixAndRenderTargetHeight(const GrOptDrawState& optState) {
306 SkASSERT(GrGpu::IsPathRenderingDrawType(optState.drawType())); 292 SkASSERT(GrGpu::IsPathRenderingDrawType(optState.drawType()));
307 const GrRenderTarget* rt = optState.getRenderTarget(); 293 const GrRenderTarget* rt = optState.getRenderTarget();
308 SkISize size; 294 SkISize size;
309 size.set(rt->width(), rt->height()); 295 size.set(rt->width(), rt->height());
310 fGpu->glPathRendering()->setProjectionMatrix(optState.getViewMatrix(), size, rt->origin()); 296 fGpu->glPathRendering()->setProjectionMatrix(optState.getViewMatrix(), size, rt->origin());
311 } 297 }
312 298
313 //////////////////////////////////////////////////////////////////////////////// ///////// 299 //////////////////////////////////////////////////////////////////////////////// /////////
314 300
315 GrGLNvprProgram::GrGLNvprProgram(GrGpuGL* gpu, 301 GrGLNvprProgram::GrGLNvprProgram(GrGpuGL* gpu,
316 const GrProgramDesc& desc, 302 const GrProgramDesc& desc,
317 const BuiltinUniformHandles& builtinUniforms, 303 const BuiltinUniformHandles& builtinUniforms,
318 GrGLuint programID, 304 GrGLuint programID,
319 const UniformInfoArray& uniforms, 305 const UniformInfoArray& uniforms,
320 GrGLInstalledXferProc* xferProcessor,
321 GrGLInstalledFragProcs* fragmentProcessors, 306 GrGLInstalledFragProcs* fragmentProcessors,
322 const SeparableVaryingInfoArray& separableVaryi ngs) 307 const SeparableVaryingInfoArray& separableVaryi ngs)
323 : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, 308 : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, fragmentProcess ors) {
324 xferProcessor, fragmentProcessors) {
325 int count = separableVaryings.count(); 309 int count = separableVaryings.count();
326 fVaryings.push_back_n(count); 310 fVaryings.push_back_n(count);
327 for (int i = 0; i < count; i++) { 311 for (int i = 0; i < count; i++) {
328 Varying& varying = fVaryings[i]; 312 Varying& varying = fVaryings[i];
329 const SeparableVaryingInfo& builderVarying = separableVaryings[i]; 313 const SeparableVaryingInfo& builderVarying = separableVaryings[i];
330 SkASSERT(GrGLShaderVar::kNonArray == builderVarying.fVariable.getArrayCo unt()); 314 SkASSERT(GrGLShaderVar::kNonArray == builderVarying.fVariable.getArrayCo unt());
331 SkDEBUGCODE( 315 SkDEBUGCODE(
332 varying.fType = builderVarying.fVariable.getType(); 316 varying.fType = builderVarying.fVariable.getType();
333 ); 317 );
334 varying.fLocation = builderVarying.fLocation; 318 varying.fLocation = builderVarying.fLocation;
(...skipping 27 matching lines...) Expand all
362 } 346 }
363 } 347 }
364 348
365 //////////////////////////////////////////////////////////////////////////////// ////// 349 //////////////////////////////////////////////////////////////////////////////// //////
366 350
367 GrGLLegacyNvprProgram::GrGLLegacyNvprProgram(GrGpuGL* gpu, 351 GrGLLegacyNvprProgram::GrGLLegacyNvprProgram(GrGpuGL* gpu,
368 const GrProgramDesc& desc, 352 const GrProgramDesc& desc,
369 const BuiltinUniformHandles& builti nUniforms, 353 const BuiltinUniformHandles& builti nUniforms,
370 GrGLuint programID, 354 GrGLuint programID,
371 const UniformInfoArray& uniforms, 355 const UniformInfoArray& uniforms,
372 GrGLInstalledXferProc* xp,
373 GrGLInstalledFragProcs* fps, 356 GrGLInstalledFragProcs* fps,
374 int texCoordSetCnt) 357 int texCoordSetCnt)
375 : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, xp, fps) 358 : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, fps)
376 , fTexCoordSetCnt(texCoordSetCnt) { 359 , fTexCoordSetCnt(texCoordSetCnt) {
377 } 360 }
378 361
379 void GrGLLegacyNvprProgram::didSetData(GrGpu::DrawType drawType) { 362 void GrGLLegacyNvprProgram::didSetData(GrGpu::DrawType drawType) {
380 SkASSERT(GrGpu::IsPathRenderingDrawType(drawType)); 363 SkASSERT(GrGpu::IsPathRenderingDrawType(drawType));
381 fGpu->glPathRendering()->flushPathTexGenSettings(fTexCoordSetCnt); 364 fGpu->glPathRendering()->flushPathTexGenSettings(fTexCoordSetCnt);
382 } 365 }
383 366
384 void 367 void
385 GrGLLegacyNvprProgram::setTransformData(const GrPendingFragmentStage& proc, 368 GrGLLegacyNvprProgram::setTransformData(const GrPendingFragmentStage& proc,
386 GrGLInstalledFragProc* ip) { 369 GrGLInstalledFragProc* ip) {
387 // We've hidden the texcoord index in the first entry of the transforms arra y for each effect 370 // We've hidden the texcoord index in the first entry of the transforms arra y for each effect
388 int texCoordIndex = ip->fTransforms[0].fHandle.handle(); 371 int texCoordIndex = ip->fTransforms[0].fHandle.handle();
389 int numTransforms = proc.getProcessor()->numTransforms(); 372 int numTransforms = proc.getProcessor()->numTransforms();
390 for (int t = 0; t < numTransforms; ++t) { 373 for (int t = 0; t < numTransforms; ++t) {
391 const SkMatrix& transform = get_transform_matrix(proc, t); 374 const SkMatrix& transform = get_transform_matrix(proc, t);
392 GrGLPathRendering::PathTexGenComponents components = 375 GrGLPathRendering::PathTexGenComponents components =
393 GrGLPathRendering::kST_PathTexGenComponents; 376 GrGLPathRendering::kST_PathTexGenComponents;
394 if (proc.isPerspectiveCoordTransform(t)) { 377 if (proc.isPerspectiveCoordTransform(t)) {
395 components = GrGLPathRendering::kSTR_PathTexGenComponents; 378 components = GrGLPathRendering::kSTR_PathTexGenComponents;
396 } 379 }
397 fGpu->glPathRendering()->enablePathTexGen(texCoordIndex++, components, t ransform); 380 fGpu->glPathRendering()->enablePathTexGen(texCoordIndex++, components, t ransform);
398 } 381 }
399 } 382 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLProgram.h ('k') | src/gpu/gl/GrGLProgramDesc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698