const GrEffectStage* colorStages[],
const GrEffectStage* coverageStages[]) {
SkAutoTDelete<GrGLProgramBuilder> builder;
- if (!desc.getHeader().fRequiresVertexShader &&
- gpu->glCaps().pathRenderingSupport() &&
- gpu->glPathRendering()->texturingMode() == GrGLPathRendering::FixedFunction_TexturingMode) {
+ if (desc.getHeader().fUseFragShaderOnly) {
+ SkASSERT(gpu->glCaps().pathRenderingSupport());
+ SkASSERT(gpu->glPathRendering()->texturingMode() ==
+ GrGLPathRendering::FixedFunction_TexturingMode);
SkASSERT(NULL == geometryProcessor);
builder.reset(SkNEW_ARGS(GrGLFragmentOnlyProgramBuilder, (gpu, desc)));
} else {
GrGpu::DrawType drawType,
GrBlendCoeff srcCoeff,
GrBlendCoeff dstCoeff,
- const GrGpuGL* gpu,
+ GrGpuGL* gpu,
const GrDeviceCoordTexture* dstCopy,
const GrEffectStage** geometryProcessor,
SkTArray<const GrEffectStage*, true>* colorStages,
// Because header is a pointer into the dynamic array, we can't push any new data into the key
// below here.
- // We will only require a vertex shader if we have more than just the position VA attrib.
- // If we have a geom processor we must us a vertex shader and we should not have a geometry
- // processor if we are doing path rendering.
- SkASSERT(!GrGpu::IsPathRenderingDrawType(drawType) || !optState.requiresVertexShader());
- header->fRequiresVertexShader = optState.requiresVertexShader() ||
- !GrGpu::IsPathRenderingDrawType(drawType);
+ header->fUseFragShaderOnly = gpu->caps()->pathRenderingSupport() &&
+ GrGpu::IsPathRenderingDrawType(drawType) &&
+ gpu->glPathRendering()->texturingMode() == GrGLPathRendering::FixedFunction_TexturingMode;
+ SkASSERT(!header->fUseFragShaderOnly || !optState.hasGeometryProcessor());
+
header->fEmitsPointSize = GrGpu::kDrawPoints_DrawType == drawType;
// Currently the experimental GS will only work with triangle prims (and it doesn't do anything
header->fExperimentalGS = false;
#endif
#endif
- bool defaultToUniformInputs = GR_GL_NO_CONSTANT_ATTRIBUTES || gpu->caps()->pathRenderingSupport();
+ bool defaultToUniformInputs = GR_GL_NO_CONSTANT_ATTRIBUTES || header->fUseFragShaderOnly;
if (!inputColorIsUsed) {
header->fColorInput = kAllOnes_ColorInput;
header->fColorInput = kUniform_ColorInput;
} else {
header->fColorInput = kAttribute_ColorInput;
- header->fRequiresVertexShader = true;
+ header->fUseFragShaderOnly = false;
}
bool covIsSolidWhite = !requiresCoverageAttrib && 0xffffffff == optState.getCoverageColor();
header->fCoverageInput = kUniform_ColorInput;
} else {
header->fCoverageInput = kAttribute_ColorInput;
- header->fRequiresVertexShader = true;
+ header->fUseFragShaderOnly = false;
}
if (optState.readsDst()) {
// For unit testing.
bool setRandom(SkRandom*,
- const GrGpuGL* gpu,
+ GrGpuGL* gpu,
const GrRenderTarget* dummyDstRenderTarget,
const GrTexture* dummyDstCopyTexture,
const GrEffectStage* geometryProcessor,
const GrEffectStage* stages[],
int numColorStages,
int numCoverageStages,
- int currAttribIndex);
+ int currAttribIndex,
+ GrGpu::DrawType);
/**
* Builds a program descriptor from a GrOptDrawState. Whether the primitive type is points, and
GrGpu::DrawType drawType,
GrBlendCoeff srcCoeff,
GrBlendCoeff dstCoeff,
- const GrGpuGL* gpu,
+ GrGpuGL* gpu,
const GrDeviceCoordTexture* dstCopy,
const GrEffectStage** outGeometryProcessor,
SkTArray<const GrEffectStage*, true>* outColorStages,
ColorInput fCoverageInput : 8;
CoverageOutput fCoverageOutput : 8;
- SkBool8 fRequiresVertexShader;
+ SkBool8 fUseFragShaderOnly;
SkBool8 fEmitsPointSize;
// To enable experimental geometry shader code (not for use in
GrGLFragmentOnlyProgramBuilder::GrGLFragmentOnlyProgramBuilder(GrGpuGL* gpu,
const GrGLProgramDesc& desc)
: INHERITED(gpu, desc) {
- SkASSERT(!desc.getHeader().fRequiresVertexShader);
+ SkASSERT(desc.getHeader().fUseFragShaderOnly);
SkASSERT(gpu->glCaps().pathRenderingSupport());
SkASSERT(GrGLProgramDesc::kAttribute_ColorInput != desc.getHeader().fColorInput);
SkASSERT(GrGLProgramDesc::kAttribute_ColorInput != desc.getHeader().fCoverageInput);
GrGLProgramBuilder::GrGLProgramBuilder(GrGpuGL* gpu,
const GrGLProgramDesc& desc)
- : fFragOnly(!desc.getHeader().fRequiresVertexShader &&
- gpu->glCaps().pathRenderingSupport() &&
- gpu->glPathRendering()->texturingMode() == GrGLPathRendering::FixedFunction_TexturingMode)
+ : fFragOnly(SkToBool(desc.getHeader().fUseFragShaderOnly))
, fTexCoordSetCnt(0)
, fProgramID(0)
, fFS(this, desc)
}
bool GrGLProgramDesc::setRandom(SkRandom* random,
- const GrGpuGL* gpu,
+ GrGpuGL* gpu,
const GrRenderTarget* dstRenderTarget,
const GrTexture* dstCopyTexture,
const GrEffectStage* geometryProcessor,
const GrEffectStage* stages[],
int numColorStages,
int numCoverageStages,
- int currAttribIndex) {
- bool useLocalCoords = random->nextBool() && currAttribIndex < GrDrawState::kMaxVertexAttribCnt;
+ int currAttribIndex,
+ GrGpu::DrawType drawType) {
+ bool isPathRendering = GrGpu::IsPathRenderingDrawType(drawType);
+ bool useLocalCoords = !isPathRendering &&
+ random->nextBool() &&
+ currAttribIndex < GrDrawState::kMaxVertexAttribCnt;
int numStages = numColorStages + numCoverageStages;
fKey.reset();
// if the effects have used up all off the available attributes,
// don't try to use color or coverage attributes as input
do {
- uint32_t colorRand = random->nextULessThan(2);
- header->fColorInput = (0 == colorRand) ? GrGLProgramDesc::kAttribute_ColorInput :
- GrGLProgramDesc::kUniform_ColorInput;
- } while (GrDrawState::kMaxVertexAttribCnt <= currAttribIndex &&
+ header->fColorInput = static_cast<GrGLProgramDesc::ColorInput>(
+ random->nextULessThan(kColorInputCnt));
+ } while ((GrDrawState::kMaxVertexAttribCnt <= currAttribIndex || isPathRendering) &&
kAttribute_ColorInput == header->fColorInput);
-
header->fColorAttributeIndex = (header->fColorInput == kAttribute_ColorInput) ?
currAttribIndex++ :
-1;
do {
header->fCoverageInput = static_cast<GrGLProgramDesc::ColorInput>(
random->nextULessThan(kColorInputCnt));
- } while (GrDrawState::kMaxVertexAttribCnt <= currAttribIndex &&
+ } while ((GrDrawState::kMaxVertexAttribCnt <= currAttribIndex || isPathRendering) &&
kAttribute_ColorInput == header->fCoverageInput);
header->fCoverageAttributeIndex = (header->fCoverageInput == kAttribute_ColorInput) ?
currAttribIndex++ :
header->fFragPosKey = 0;
}
- header->fRequiresVertexShader = vertexShader ||
- useLocalCoords ||
- kAttribute_ColorInput == header->fColorInput ||
- kAttribute_ColorInput == header->fCoverageInput;
+ header->fUseFragShaderOnly = isPathRendering && gpu->glPathRendering()->texturingMode() ==
+ GrGLPathRendering::FixedFunction_TexturingMode;
header->fHasGeometryProcessor = vertexShader;
CoverageOutput coverageOutput;
SkAutoSTMalloc<8, const GrEffectStage*> stages(numStages);
- bool useFixedFunctionPathRendering = this->glCaps().pathRenderingSupport() &&
- this->glPathRendering()->texturingMode() == GrGLPathRendering::FixedFunction_TexturingMode &&
- random.nextBool();
+ bool usePathRendering = this->glCaps().pathRenderingSupport() && random.nextBool();
+
+ GrGpu::DrawType drawType = usePathRendering ? GrGpu::kDrawPath_DrawType :
+ GrGpu::kDrawPoints_DrawType;
SkAutoTDelete<GrEffectStage> geometryProcessor;
- bool hasGeometryProcessor = useFixedFunctionPathRendering ? false : random.nextBool();
+ bool hasGeometryProcessor = usePathRendering ? false : random.nextBool();
if (hasGeometryProcessor) {
while (true) {
SkAutoTUnref<const GrEffect> effect(GrEffectTestFactory::CreateStage(
// If adding this effect would exceed the max texture coord set count then generate a
// new random effect.
- if (useFixedFunctionPathRendering) {
+ if (usePathRendering && this->glPathRendering()->texturingMode() ==
+ GrGLPathRendering::FixedFunction_TexturingMode) {;
int numTransforms = effect->numTransforms();
if (currTextureCoordSet + numTransforms > this->glCaps().maxFixedFunctionTextureCoords()) {
continue;
stages.get(),
numColorStages,
numCoverageStages,
- currAttribIndex)) {
+ currAttribIndex,
+ drawType)) {
return false;
}