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

Unified Diff: src/gpu/gl/GrGLProgram.cpp

Issue 647183002: Revert of Opt state takes a GP instead of a GeometryStage (Closed) Base URL: https://skia.googlesource.com/skia.git@builder_cleanup
Patch Set: Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/GrGLProgram.h ('k') | src/gpu/gl/GrGLProgramDesc.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLProgram.cpp
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index 2216fb1c5a82b9a04f51184a089e6cbaf5f7df9d..e0d4939323b0f2438944fcaad78712d7b6120d63 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -10,7 +10,6 @@
#include "GrAllocator.h"
#include "GrProcessor.h"
#include "GrCoordTransform.h"
-#include "GrGLGeometryProcessor.h"
#include "GrGLProcessor.h"
#include "GrGpuGL.h"
#include "GrGLPathRendering.h"
@@ -25,7 +24,7 @@
/**
* Retrieves the final matrix that a transform needs to apply to its source coords.
*/
-static SkMatrix get_transform_matrix(const GrFragmentStage& processorStage,
+static SkMatrix get_transform_matrix(const GrProcessorStage& processorStage,
bool useExplicitLocalCoords,
int transformIdx) {
const GrCoordTransform& coordTransform =
@@ -60,15 +59,17 @@
const BuiltinUniformHandles& builtinUniforms,
GrGLuint programID,
const UniformInfoArray& uniforms,
- GrGLInstalledGeoProc* geometryProcessor,
- GrGLInstalledFragProcs* fragmentProcessors)
+ GrGLInstalledProcessors* geometryProcessor,
+ GrGLInstalledProcessors* colorProcessors,
+ GrGLInstalledProcessors* coverageProcessors)
: fColor(GrColor_ILLEGAL)
, fCoverage(GrColor_ILLEGAL)
, fDstCopyTexUnit(-1)
, fBuiltinUniformHandles(builtinUniforms)
, fProgramID(programID)
- , fGeometryProcessor(geometryProcessor)
- , fFragmentProcessors(SkRef(fragmentProcessors))
+ , fGeometryProcessor(SkSafeRef(geometryProcessor))
+ , fColorEffects(SkRef(colorProcessors))
+ , fCoverageEffects(SkRef(coverageProcessors))
, fDesc(desc)
, fGpu(gpu)
, fProgramDataManager(gpu, uniforms) {
@@ -95,24 +96,28 @@
if (fGeometryProcessor.get()) {
this->initSamplers(fGeometryProcessor.get(), &texUnitIdx);
}
- int numProcs = fFragmentProcessors->fProcs.count();
- for (int i = 0; i < numProcs; i++) {
- this->initSamplers(fFragmentProcessors->fProcs[i], &texUnitIdx);
- }
-}
-
-void GrGLProgram::initSamplers(GrGLInstalledProc* ip, int* texUnitIdx) {
- SkTArray<GrGLInstalledProc::Sampler, true>& samplers = ip->fSamplers;
- int numSamplers = samplers.count();
- for (int s = 0; s < numSamplers; ++s) {
- SkASSERT(samplers[s].fUniform.isValid());
- fProgramDataManager.setSampler(samplers[s].fUniform, *texUnitIdx);
- samplers[s].fTextureUnit = (*texUnitIdx)++;
- }
-}
-
-void GrGLProgram::bindTextures(const GrGLInstalledProc* ip, const GrProcessor& processor) {
- const SkTArray<GrGLInstalledProc::Sampler, true>& samplers = ip->fSamplers;
+ this->initSamplers(fColorEffects.get(), &texUnitIdx);
+ this->initSamplers(fCoverageEffects.get(), &texUnitIdx);
+}
+
+void GrGLProgram::initSamplers(GrGLInstalledProcessors* ip, int* texUnitIdx) {
+ int numEffects = ip->fGLProcessors.count();
+ SkASSERT(numEffects == ip->fSamplers.count());
+ for (int e = 0; e < numEffects; ++e) {
+ SkTArray<GrGLInstalledProcessors::Sampler, true>& samplers = ip->fSamplers[e];
+ int numSamplers = samplers.count();
+ for (int s = 0; s < numSamplers; ++s) {
+ SkASSERT(samplers[s].fUniform.isValid());
+ fProgramDataManager.setSampler(samplers[s].fUniform, *texUnitIdx);
+ samplers[s].fTextureUnit = (*texUnitIdx)++;
+ }
+ }
+}
+
+void GrGLProgram::bindTextures(const GrGLInstalledProcessors* ip,
+ const GrProcessor& processor,
+ int effectIdx) {
+ const SkTArray<GrGLInstalledProcessors::Sampler, true>& samplers = ip->fSamplers[effectIdx];
int numSamplers = samplers.count();
SkASSERT(numSamplers == processor.numTextures());
for (int s = 0; s < numSamplers; ++s) {
@@ -129,6 +134,9 @@
void GrGLProgram::setData(const GrOptDrawState& optState,
GrGpu::DrawType drawType,
+ const GrGeometryStage* geometryProcessor,
+ const GrFragmentStage* colorStages[],
+ const GrFragmentStage* coverageStages[],
const GrDeviceCoordTexture* dstCopy,
SharedGLState* sharedState) {
GrColor color = optState.getColor();
@@ -162,34 +170,25 @@
// we set the textures, and uniforms for installed processors in a generic way, but subclasses
// of GLProgram determine how to set coord transforms
if (fGeometryProcessor.get()) {
- SkASSERT(optState.hasGeometryProcessor());
- const GrGeometryProcessor& gp = *optState.getGeometryProcessor();
- fGeometryProcessor->fGLProc->setData(fProgramDataManager, gp);
- this->bindTextures(fGeometryProcessor, gp);
- }
- this->setFragmentData(optState);
+ SkASSERT(geometryProcessor);
+ this->setData<GrGeometryStage>(&geometryProcessor, fGeometryProcessor.get());
+ }
+ this->setData<GrFragmentStage>(colorStages, fColorEffects.get());
+ this->setData<GrFragmentStage>(coverageStages, fCoverageEffects.get());
// Some of GrGLProgram subclasses need to update state here
this->didSetData(drawType);
}
-void GrGLProgram::setFragmentData(const GrOptDrawState& optState) {
- int numProcessors = fFragmentProcessors->fProcs.count();
- for (int e = 0; e < numProcessors; ++e) {
- const GrFragmentStage& stage = optState.getFragmentStage(e);
- const GrProcessor& processor = *stage.getProcessor();
- fFragmentProcessors->fProcs[e]->fGLProc->setData(fProgramDataManager, processor);
- this->setTransformData(stage, fFragmentProcessors->fProcs[e]);
- this->bindTextures(fFragmentProcessors->fProcs[e], processor);
- }
-}
-void GrGLProgram::setTransformData(const GrFragmentStage& processor, GrGLInstalledFragProc* ip) {
- SkTArray<GrGLInstalledFragProc::Transform, true>& transforms = ip->fTransforms;
+void GrGLProgram::setTransformData(const GrProcessorStage& processor,
+ int effectIdx,
+ GrGLInstalledProcessors* ip) {
+ SkTArray<GrGLInstalledProcessors::Transform, true>& transforms = ip->fTransforms[effectIdx];
int numTransforms = transforms.count();
SkASSERT(numTransforms == processor.getProcessor()->numTransforms());
for (int t = 0; t < numTransforms; ++t) {
SkASSERT(transforms[t].fHandle.isValid());
- const SkMatrix& matrix = get_transform_matrix(processor, ip->fLocalCoordAttrib, t);
+ const SkMatrix& matrix = get_transform_matrix(processor, ip->fHasExplicitLocalCoords, t);
if (!transforms[t].fCurrentValue.cheapEqualTo(matrix)) {
fProgramDataManager.setSkMatrix(transforms[t].fHandle.convertToUniformHandle(), matrix);
transforms[t].fCurrentValue = matrix;
@@ -322,8 +321,10 @@
const BuiltinUniformHandles& builtinUniforms,
GrGLuint programID,
const UniformInfoArray& uniforms,
- GrGLInstalledFragProcs* fragmentProcessors)
- : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, NULL, fragmentProcessors) {
+ GrGLInstalledProcessors* colorProcessors,
+ GrGLInstalledProcessors* coverageProcessors)
+ : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, NULL, colorProcessors,
+ coverageProcessors) {
}
void GrGLNvprProgramBase::onSetMatrixAndRenderTargetHeight(GrGpu::DrawType drawType,
@@ -342,9 +343,11 @@
const BuiltinUniformHandles& builtinUniforms,
GrGLuint programID,
const UniformInfoArray& uniforms,
- GrGLInstalledFragProcs* fragmentProcessors,
+ GrGLInstalledProcessors* colorProcessors,
+ GrGLInstalledProcessors* coverageProcessors,
const SeparableVaryingInfoArray& separableVaryings)
- : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, fragmentProcessors) {
+ : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, colorProcessors,
+ coverageProcessors) {
int count = separableVaryings.count();
fVaryings.push_back_n(count);
for (int i = 0; i < count; i++) {
@@ -362,13 +365,15 @@
SkASSERT(GrGpu::IsPathRenderingDrawType(drawType));
}
-void GrGLNvprProgram::setTransformData(const GrFragmentStage& proc, GrGLInstalledFragProc* ip) {
- SkTArray<GrGLInstalledFragProc::Transform, true>& transforms = ip->fTransforms;
+void GrGLNvprProgram::setTransformData(const GrProcessorStage& processor,
+ int effectIdx,
+ GrGLInstalledProcessors* ip) {
+ SkTArray<GrGLInstalledProcessors::Transform, true>& transforms = ip->fTransforms[effectIdx];
int numTransforms = transforms.count();
- SkASSERT(numTransforms == proc.getProcessor()->numTransforms());
+ SkASSERT(numTransforms == processor.getProcessor()->numTransforms());
for (int t = 0; t < numTransforms; ++t) {
SkASSERT(transforms[t].fHandle.isValid());
- const SkMatrix& transform = get_transform_matrix(proc, ip->fLocalCoordAttrib, t);
+ const SkMatrix& transform = get_transform_matrix(processor, ip->fHasExplicitLocalCoords, t);
if (transforms[t].fCurrentValue.cheapEqualTo(transform)) {
continue;
}
@@ -387,13 +392,15 @@
//////////////////////////////////////////////////////////////////////////////////////
GrGLLegacyNvprProgram::GrGLLegacyNvprProgram(GrGpuGL* gpu,
- const GrGLProgramDesc& desc,
- const BuiltinUniformHandles& builtinUniforms,
- GrGLuint programID,
- const UniformInfoArray& uniforms,
- GrGLInstalledFragProcs* fps,
- int texCoordSetCnt)
- : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, fps)
+ const GrGLProgramDesc& desc,
+ const BuiltinUniformHandles& builtinUniforms,
+ GrGLuint programID,
+ const UniformInfoArray& uniforms,
+ GrGLInstalledProcessors* colorProcessors,
+ GrGLInstalledProcessors* coverageProcessors,
+ int texCoordSetCnt)
+ : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, colorProcessors,
+ coverageProcessors)
, fTexCoordSetCnt(texCoordSetCnt) {
}
@@ -402,16 +409,17 @@
fGpu->glPathRendering()->flushPathTexGenSettings(fTexCoordSetCnt);
}
-void
-GrGLLegacyNvprProgram::setTransformData(const GrFragmentStage& proc, GrGLInstalledFragProc* ip) {
+void GrGLLegacyNvprProgram::setTransformData(const GrProcessorStage& processorStage,
+ int effectIdx,
+ GrGLInstalledProcessors* ip) {
// We've hidden the texcoord index in the first entry of the transforms array for each effect
- int texCoordIndex = ip->fTransforms[0].fHandle.handle();
- int numTransforms = proc.getProcessor()->numTransforms();
+ int texCoordIndex = ip->fTransforms[effectIdx][0].fHandle.handle();
+ int numTransforms = processorStage.getProcessor()->numTransforms();
for (int t = 0; t < numTransforms; ++t) {
- const SkMatrix& transform = get_transform_matrix(proc, false, t);
+ const SkMatrix& transform = get_transform_matrix(processorStage, false, t);
GrGLPathRendering::PathTexGenComponents components =
GrGLPathRendering::kST_PathTexGenComponents;
- if (proc.isPerspectiveCoordTransform(t, false)) {
+ if (processorStage.isPerspectiveCoordTransform(t, false)) {
components = GrGLPathRendering::kSTR_PathTexGenComponents;
}
fGpu->glPathRendering()->enablePathTexGen(texCoordIndex++, components, transform);
« no previous file with comments | « src/gpu/gl/GrGLProgram.h ('k') | src/gpu/gl/GrGLProgramDesc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698