| 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 |
| 11 #include "SkTypes.h" | 11 #include "SkTypes.h" |
| 12 | 12 |
| 13 #if SK_SUPPORT_GPU && SK_ALLOW_STATIC_GLOBAL_INITIALIZERS | 13 #if SK_SUPPORT_GPU && SK_ALLOW_STATIC_GLOBAL_INITIALIZERS |
| 14 | 14 |
| 15 #include "GrBackendProcessorFactory.h" | 15 #include "GrBackendProcessorFactory.h" |
| 16 #include "GrContextFactory.h" | 16 #include "GrContextFactory.h" |
| 17 #include "GrOptDrawState.h" | 17 #include "GrOptDrawState.h" |
| 18 #include "effects/GrConfigConversionEffect.h" | 18 #include "effects/GrConfigConversionEffect.h" |
| 19 #include "gl/builders/GrGLProgramBuilder.h" |
| 19 #include "gl/GrGLPathRendering.h" | 20 #include "gl/GrGLPathRendering.h" |
| 20 #include "gl/GrGpuGL.h" | 21 #include "gl/GrGpuGL.h" |
| 21 #include "SkChecksum.h" | 22 #include "SkChecksum.h" |
| 22 #include "SkRandom.h" | 23 #include "SkRandom.h" |
| 23 #include "Test.h" | 24 #include "Test.h" |
| 24 | 25 |
| 25 static void get_stage_stats(const GrFragmentStage stage, bool* readsDst, | 26 static void get_stage_stats(const GrFragmentStage stage, bool* readsDst, |
| 26 bool* readsFragPosition, bool* requiresVertexShader)
{ | 27 bool* readsFragPosition, bool* requiresVertexShader)
{ |
| 27 if (stage.getFragmentProcessor()->willReadDstColor()) { | 28 if (stage.getProcessor()->willReadDstColor()) { |
| 28 *readsDst = true; | 29 *readsDst = true; |
| 29 } | 30 } |
| 30 if (stage.getProcessor()->willReadFragmentPosition()) { | 31 if (stage.getProcessor()->willReadFragmentPosition()) { |
| 31 *readsFragPosition = true; | 32 *readsFragPosition = true; |
| 32 } | 33 } |
| 33 } | 34 } |
| 34 | 35 |
| 35 bool GrGLProgramDesc::setRandom(SkRandom* random, | 36 bool GrGLProgramDesc::setRandom(SkRandom* random, |
| 36 GrGpuGL* gpu, | 37 GrGpuGL* gpu, |
| 37 const GrRenderTarget* dstRenderTarget, | 38 const GrRenderTarget* dstRenderTarget, |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 (void) useGS; | 137 (void) useGS; |
| 137 #endif | 138 #endif |
| 138 | 139 |
| 139 header->fLocalCoordAttributeIndex = useLocalCoords ? currAttribIndex++ : -1; | 140 header->fLocalCoordAttributeIndex = useLocalCoords ? currAttribIndex++ : -1; |
| 140 | 141 |
| 141 header->fColorEffectCnt = numColorStages; | 142 header->fColorEffectCnt = numColorStages; |
| 142 header->fCoverageEffectCnt = numCoverageStages; | 143 header->fCoverageEffectCnt = numCoverageStages; |
| 143 | 144 |
| 144 if (dstRead) { | 145 if (dstRead) { |
| 145 header->fDstReadKey = SkToU8(GrGLFragmentShaderBuilder::KeyForDstRead(ds
tCopyTexture, | 146 header->fDstReadKey = SkToU8(GrGLFragmentShaderBuilder::KeyForDstRead(ds
tCopyTexture, |
| 146 gpu->glCap
s())); | 147 gp
u->glCaps())); |
| 147 } else { | 148 } else { |
| 148 header->fDstReadKey = 0; | 149 header->fDstReadKey = 0; |
| 149 } | 150 } |
| 150 if (fragPos) { | 151 if (fragPos) { |
| 151 header->fFragPosKey = SkToU8(GrGLFragmentShaderBuilder::KeyForFragmentPo
sition(dstRenderTarget, | 152 header->fFragPosKey = |
| 152 g
pu->glCaps())); | 153 SkToU8(GrGLFragmentShaderBuilder::KeyForFragmentPosition(dstRend
erTarget, |
| 154 gpu->gl
Caps())); |
| 153 } else { | 155 } else { |
| 154 header->fFragPosKey = 0; | 156 header->fFragPosKey = 0; |
| 155 } | 157 } |
| 156 | 158 |
| 157 header->fUseFragShaderOnly = isPathRendering && gpu->glPathRendering()->text
uringMode() == | 159 header->fUseFragShaderOnly = isPathRendering && gpu->glPathRendering()->text
uringMode() == |
| 158 GrGLPathRendering::FixedFunc
tion_TexturingMode; | 160 GrGLPathRendering::FixedFunc
tion_TexturingMode; |
| 159 header->fHasGeometryProcessor = vertexShader; | 161 header->fHasGeometryProcessor = vertexShader; |
| 160 | 162 |
| 161 GrOptDrawState::PrimaryOutputType primaryOutput; | 163 GrOptDrawState::PrimaryOutputType primaryOutput; |
| 162 GrOptDrawState::SecondaryOutputType secondaryOutput; | 164 GrOptDrawState::SecondaryOutputType secondaryOutput; |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 dstTexture, | 327 dstTexture, |
| 326 geometryProcessor.get(), | 328 geometryProcessor.get(), |
| 327 stages.get(), | 329 stages.get(), |
| 328 numColorStages, | 330 numColorStages, |
| 329 numCoverageStages, | 331 numCoverageStages, |
| 330 currAttribIndex, | 332 currAttribIndex, |
| 331 drawType)) { | 333 drawType)) { |
| 332 return false; | 334 return false; |
| 333 } | 335 } |
| 334 | 336 |
| 335 SkAutoTUnref<GrGLProgram> program(GrGLProgram::Create(this, | 337 SkAutoTUnref<GrGLProgram> program( |
| 336 pdesc, | 338 GrGLProgramBuilder::CreateProgram(pdesc, |
| 337 geometryProcessor.
get(), | 339 drawType, |
| 338 stages, | 340 geometryProcessor.get(), |
| 339 stages + numColorS
tages)); | 341 stages.get(), |
| 342 stages.get() + numColorStages, |
| 343 this)); |
| 340 for (int s = 0; s < numStages; ++s) { | 344 for (int s = 0; s < numStages; ++s) { |
| 341 SkDELETE(stages[s]); | 345 SkDELETE(stages[s]); |
| 342 } | 346 } |
| 343 if (NULL == program.get()) { | 347 if (NULL == program.get()) { |
| 344 return false; | 348 return false; |
| 345 } | 349 } |
| 346 | 350 |
| 347 // We have to reset the drawstate because we might have added a gp | 351 // We have to reset the drawstate because we might have added a gp |
| 348 this->drawState()->reset(); | 352 this->drawState()->reset(); |
| 349 } | 353 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1)); | 390 SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1)); |
| 387 GrConfigConversionEffect::Create(NULL, | 391 GrConfigConversionEffect::Create(NULL, |
| 388 false, | 392 false, |
| 389 GrConfigConversionEffect::kNone_PMConversio
n, | 393 GrConfigConversionEffect::kNone_PMConversio
n, |
| 390 SkMatrix::I()); | 394 SkMatrix::I()); |
| 391 SkScalar matrix[20]; | 395 SkScalar matrix[20]; |
| 392 SkAutoTUnref<SkColorMatrixFilter> cmf(SkColorMatrixFilter::Create(matrix)); | 396 SkAutoTUnref<SkColorMatrixFilter> cmf(SkColorMatrixFilter::Create(matrix)); |
| 393 } | 397 } |
| 394 | 398 |
| 395 #endif | 399 #endif |
| OLD | NEW |