| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 // This is a GPU-backend specific test. It relies on static intializers to work | 9 // This is a GPU-backend specific test. It relies on static intializers to work |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 } | 35 } |
| 36 | 36 |
| 37 bool GrGLProgramDesc::setRandom(SkRandom* random, | 37 bool GrGLProgramDesc::setRandom(SkRandom* random, |
| 38 const GrGpuGL* gpu, | 38 const GrGpuGL* gpu, |
| 39 const GrRenderTarget* dstRenderTarget, | 39 const GrRenderTarget* dstRenderTarget, |
| 40 const GrTexture* dstCopyTexture, | 40 const GrTexture* dstCopyTexture, |
| 41 const GrEffectStage* geometryProcessor, | 41 const GrEffectStage* geometryProcessor, |
| 42 const GrEffectStage* stages[], | 42 const GrEffectStage* stages[], |
| 43 int numColorStages, | 43 int numColorStages, |
| 44 int numCoverageStages, | 44 int numCoverageStages, |
| 45 int currAttribIndex) { | 45 int currAttribIndex, |
| 46 bool useLocalCoords = random->nextBool() && currAttribIndex < GrDrawState::k
MaxVertexAttribCnt; | 46 GrGpu::DrawType drawType) { |
| 47 bool isPathRendering = GrGpu::IsPathRenderingDrawType(drawType); |
| 48 bool useLocalCoords = !isPathRendering && |
| 49 random->nextBool() && |
| 50 currAttribIndex < GrDrawState::kMaxVertexAttribCnt; |
| 47 | 51 |
| 48 int numStages = numColorStages + numCoverageStages; | 52 int numStages = numColorStages + numCoverageStages; |
| 49 fKey.reset(); | 53 fKey.reset(); |
| 50 | 54 |
| 51 GR_STATIC_ASSERT(0 == kEffectKeyOffsetsAndLengthOffset % sizeof(uint32_t)); | 55 GR_STATIC_ASSERT(0 == kEffectKeyOffsetsAndLengthOffset % sizeof(uint32_t)); |
| 52 | 56 |
| 53 // Make room for everything up to and including the array of offsets to effe
ct keys. | 57 // Make room for everything up to and including the array of offsets to effe
ct keys. |
| 54 fKey.push_back_n(kEffectKeyOffsetsAndLengthOffset + 2 * sizeof(uint16_t) * (
numStages + | 58 fKey.push_back_n(kEffectKeyOffsetsAndLengthOffset + 2 * sizeof(uint16_t) * (
numStages + |
| 55 (geometryProcessor ? 1 : 0))); | 59 (geometryProcessor ? 1 : 0))); |
| 56 | 60 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 107 |
| 104 KeyHeader* header = this->header(); | 108 KeyHeader* header = this->header(); |
| 105 memset(header, 0, kHeaderSize); | 109 memset(header, 0, kHeaderSize); |
| 106 header->fEmitsPointSize = random->nextBool(); | 110 header->fEmitsPointSize = random->nextBool(); |
| 107 | 111 |
| 108 header->fPositionAttributeIndex = 0; | 112 header->fPositionAttributeIndex = 0; |
| 109 | 113 |
| 110 // if the effects have used up all off the available attributes, | 114 // if the effects have used up all off the available attributes, |
| 111 // don't try to use color or coverage attributes as input | 115 // don't try to use color or coverage attributes as input |
| 112 do { | 116 do { |
| 113 uint32_t colorRand = random->nextULessThan(2); | 117 header->fColorInput = static_cast<GrGLProgramDesc::ColorInput>( |
| 114 header->fColorInput = (0 == colorRand) ? GrGLProgramDesc::kAttribute_Col
orInput : | 118 random->nextULessThan(kColorInputCnt)); |
| 115 GrGLProgramDesc::kUniform_Color
Input; | 119 } while ((GrDrawState::kMaxVertexAttribCnt <= currAttribIndex || isPathRende
ring) && |
| 116 } while (GrDrawState::kMaxVertexAttribCnt <= currAttribIndex && | |
| 117 kAttribute_ColorInput == header->fColorInput); | 120 kAttribute_ColorInput == header->fColorInput); |
| 118 | |
| 119 header->fColorAttributeIndex = (header->fColorInput == kAttribute_ColorInput
) ? | 121 header->fColorAttributeIndex = (header->fColorInput == kAttribute_ColorInput
) ? |
| 120 currAttribIndex++ : | 122 currAttribIndex++ : |
| 121 -1; | 123 -1; |
| 122 | 124 |
| 123 do { | 125 do { |
| 124 header->fCoverageInput = static_cast<GrGLProgramDesc::ColorInput>( | 126 header->fCoverageInput = static_cast<GrGLProgramDesc::ColorInput>( |
| 125 random->nextULessThan(kColorInputCnt)); | 127 random->nextULessThan(kColorInputCnt)); |
| 126 } while (GrDrawState::kMaxVertexAttribCnt <= currAttribIndex && | 128 } while ((GrDrawState::kMaxVertexAttribCnt <= currAttribIndex || isPathRende
ring) && |
| 127 kAttribute_ColorInput == header->fCoverageInput); | 129 kAttribute_ColorInput == header->fCoverageInput); |
| 128 header->fCoverageAttributeIndex = (header->fCoverageInput == kAttribute_Colo
rInput) ? | 130 header->fCoverageAttributeIndex = (header->fCoverageInput == kAttribute_Colo
rInput) ? |
| 129 currAttribIndex++ : | 131 currAttribIndex++ : |
| 130 -1; | 132 -1; |
| 131 | 133 |
| 132 #if GR_GL_EXPERIMENTAL_GS | 134 #if GR_GL_EXPERIMENTAL_GS |
| 133 header->fExperimentalGS = gpu->caps()->geometryShaderSupport() && random->ne
xtBool(); | 135 header->fExperimentalGS = gpu->caps()->geometryShaderSupport() && random->ne
xtBool(); |
| 134 #endif | 136 #endif |
| 135 | 137 |
| 136 header->fLocalCoordAttributeIndex = useLocalCoords ? currAttribIndex++ : -1; | 138 header->fLocalCoordAttributeIndex = useLocalCoords ? currAttribIndex++ : -1; |
| 137 | 139 |
| 138 header->fColorEffectCnt = numColorStages; | 140 header->fColorEffectCnt = numColorStages; |
| 139 header->fCoverageEffectCnt = numCoverageStages; | 141 header->fCoverageEffectCnt = numCoverageStages; |
| 140 | 142 |
| 141 if (dstRead) { | 143 if (dstRead) { |
| 142 header->fDstReadKey = SkToU8(GrGLFragmentShaderBuilder::KeyForDstRead(ds
tCopyTexture, | 144 header->fDstReadKey = SkToU8(GrGLFragmentShaderBuilder::KeyForDstRead(ds
tCopyTexture, |
| 143 gpu->glCap
s())); | 145 gpu->glCap
s())); |
| 144 } else { | 146 } else { |
| 145 header->fDstReadKey = 0; | 147 header->fDstReadKey = 0; |
| 146 } | 148 } |
| 147 if (fragPos) { | 149 if (fragPos) { |
| 148 header->fFragPosKey = SkToU8(GrGLFragmentShaderBuilder::KeyForFragmentPo
sition(dstRenderTarget, | 150 header->fFragPosKey = SkToU8(GrGLFragmentShaderBuilder::KeyForFragmentPo
sition(dstRenderTarget, |
| 149 g
pu->glCaps())); | 151 g
pu->glCaps())); |
| 150 } else { | 152 } else { |
| 151 header->fFragPosKey = 0; | 153 header->fFragPosKey = 0; |
| 152 } | 154 } |
| 153 | 155 |
| 154 header->fRequiresVertexShader = vertexShader || | 156 header->fDoPathRendering = isPathRendering; |
| 155 useLocalCoords || | |
| 156 kAttribute_ColorInput == header->fColorInput
|| | |
| 157 kAttribute_ColorInput == header->fCoverageIn
put; | |
| 158 header->fHasGeometryProcessor = vertexShader; | 157 header->fHasGeometryProcessor = vertexShader; |
| 159 | 158 |
| 160 CoverageOutput coverageOutput; | 159 CoverageOutput coverageOutput; |
| 161 bool illegalCoverageOutput; | 160 bool illegalCoverageOutput; |
| 162 do { | 161 do { |
| 163 coverageOutput = static_cast<CoverageOutput>(random->nextULessThan(kCove
rageOutputCnt)); | 162 coverageOutput = static_cast<CoverageOutput>(random->nextULessThan(kCove
rageOutputCnt)); |
| 164 illegalCoverageOutput = (!gpu->caps()->dualSourceBlendingSupport() && | 163 illegalCoverageOutput = (!gpu->caps()->dualSourceBlendingSupport() && |
| 165 CoverageOutputUsesSecondaryOutput(coverageOutpu
t)) || | 164 CoverageOutputUsesSecondaryOutput(coverageOutpu
t)) || |
| 166 (!dstRead && kCombineWithDst_CoverageOutput == c
overageOutput); | 165 (!dstRead && kCombineWithDst_CoverageOutput == c
overageOutput); |
| 167 } while (illegalCoverageOutput); | 166 } while (illegalCoverageOutput); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 int currTextureCoordSet = 0; | 239 int currTextureCoordSet = 0; |
| 241 GrTexture* dummyTextures[] = {dummyTexture1.get(), dummyTexture2.get()}; | 240 GrTexture* dummyTextures[] = {dummyTexture1.get(), dummyTexture2.get()}; |
| 242 | 241 |
| 243 int numStages = random.nextULessThan(maxStages + 1); | 242 int numStages = random.nextULessThan(maxStages + 1); |
| 244 int numColorStages = random.nextULessThan(numStages + 1); | 243 int numColorStages = random.nextULessThan(numStages + 1); |
| 245 int numCoverageStages = numStages - numColorStages; | 244 int numCoverageStages = numStages - numColorStages; |
| 246 | 245 |
| 247 SkAutoSTMalloc<8, const GrEffectStage*> stages(numStages); | 246 SkAutoSTMalloc<8, const GrEffectStage*> stages(numStages); |
| 248 | 247 |
| 249 bool useFixedFunctionPathRendering = this->glCaps().pathRenderingSupport
() && | 248 bool useFixedFunctionPathRendering = this->glCaps().pathRenderingSupport
() && |
| 250 this->glPathRendering()->texturingMode() == GrGLPathRendering::Fixed
Function_TexturingMode && | 249 this->glPathRendering()->texturingMode() == GrGLPathRendering::Fixed
Function_TexturingMode; |
| 251 random.nextBool(); | 250 bool usePathRenderingDrawType = useFixedFunctionPathRendering && random.
nextBool(); |
| 251 |
| 252 GrGpu::DrawType drawType = usePathRenderingDrawType ? GrGpu::kDrawPath_D
rawType : |
| 253 GrGpu::kDrawPoints
_DrawType; |
| 252 | 254 |
| 253 SkAutoTDelete<GrEffectStage> geometryProcessor; | 255 SkAutoTDelete<GrEffectStage> geometryProcessor; |
| 254 bool hasGeometryProcessor = useFixedFunctionPathRendering ? false : rand
om.nextBool(); | 256 bool hasGeometryProcessor = useFixedFunctionPathRendering ? false : rand
om.nextBool(); |
| 255 if (hasGeometryProcessor) { | 257 if (hasGeometryProcessor) { |
| 256 while (true) { | 258 while (true) { |
| 257 SkAutoTUnref<const GrEffect> effect(GrEffectTestFactory::CreateS
tage( | 259 SkAutoTUnref<const GrEffect> effect(GrEffectTestFactory::CreateS
tage( |
| 258
&random, | 260
&random, |
| 259
this->getContext(), | 261
this->getContext(), |
| 260
*this->caps(), | 262
*this->caps(), |
| 261
dummyTextures)); | 263
dummyTextures)); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 } | 320 } |
| 319 const GrTexture* dstTexture = random.nextBool() ? dummyTextures[0] : dum
myTextures[1]; | 321 const GrTexture* dstTexture = random.nextBool() ? dummyTextures[0] : dum
myTextures[1]; |
| 320 if (!pdesc.setRandom(&random, | 322 if (!pdesc.setRandom(&random, |
| 321 this, | 323 this, |
| 322 dummyTextures[0]->asRenderTarget(), | 324 dummyTextures[0]->asRenderTarget(), |
| 323 dstTexture, | 325 dstTexture, |
| 324 geometryProcessor.get(), | 326 geometryProcessor.get(), |
| 325 stages.get(), | 327 stages.get(), |
| 326 numColorStages, | 328 numColorStages, |
| 327 numCoverageStages, | 329 numCoverageStages, |
| 328 currAttribIndex)) { | 330 currAttribIndex, |
| 331 drawType)) { |
| 329 return false; | 332 return false; |
| 330 } | 333 } |
| 331 | 334 |
| 332 SkAutoTUnref<GrGLProgram> program(GrGLProgram::Create(this, | 335 SkAutoTUnref<GrGLProgram> program(GrGLProgram::Create(this, |
| 333 pdesc, | 336 pdesc, |
| 334 geometryProcessor.
get(), | 337 geometryProcessor.
get(), |
| 335 stages, | 338 stages, |
| 336 stages + numColorS
tages)); | 339 stages + numColorS
tages)); |
| 337 for (int s = 0; s < numStages; ++s) { | 340 for (int s = 0; s < numStages; ++s) { |
| 338 SkDELETE(stages[s]); | 341 SkDELETE(stages[s]); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1)); | 386 SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1)); |
| 384 GrConfigConversionEffect::Create(NULL, | 387 GrConfigConversionEffect::Create(NULL, |
| 385 false, | 388 false, |
| 386 GrConfigConversionEffect::kNone_PMConversio
n, | 389 GrConfigConversionEffect::kNone_PMConversio
n, |
| 387 SkMatrix::I()); | 390 SkMatrix::I()); |
| 388 SkScalar matrix[20]; | 391 SkScalar matrix[20]; |
| 389 SkAutoTUnref<SkColorMatrixFilter> cmf(SkColorMatrixFilter::Create(matrix)); | 392 SkAutoTUnref<SkColorMatrixFilter> cmf(SkColorMatrixFilter::Create(matrix)); |
| 390 } | 393 } |
| 391 | 394 |
| 392 #endif | 395 #endif |
| OLD | NEW |