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 "GrBackendEffectFactory.h" | 15 #include "GrBackendEffectFactory.h" |
16 #include "GrContextFactory.h" | 16 #include "GrContextFactory.h" |
| 17 #include "GrOptDrawState.h" |
17 #include "effects/GrConfigConversionEffect.h" | 18 #include "effects/GrConfigConversionEffect.h" |
18 #include "gl/GrGLPathRendering.h" | 19 #include "gl/GrGLPathRendering.h" |
19 #include "gl/GrGpuGL.h" | 20 #include "gl/GrGpuGL.h" |
20 #include "SkChecksum.h" | 21 #include "SkChecksum.h" |
21 #include "SkRandom.h" | 22 #include "SkRandom.h" |
22 #include "Test.h" | 23 #include "Test.h" |
23 | 24 |
24 static void get_stage_stats(const GrEffectStage stage, bool* readsDst, | 25 static void get_stage_stats(const GrEffectStage stage, bool* readsDst, |
25 bool* readsFragPosition, bool* requiresVertexShader)
{ | 26 bool* readsFragPosition, bool* requiresVertexShader)
{ |
26 if (stage.getEffect()->willReadDstColor()) { | 27 if (stage.getEffect()->willReadDstColor()) { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 header->fFragPosKey = SkToU8(GrGLFragmentShaderBuilder::KeyForFragmentPo
sition(dstRenderTarget, | 153 header->fFragPosKey = SkToU8(GrGLFragmentShaderBuilder::KeyForFragmentPo
sition(dstRenderTarget, |
153 g
pu->glCaps())); | 154 g
pu->glCaps())); |
154 } else { | 155 } else { |
155 header->fFragPosKey = 0; | 156 header->fFragPosKey = 0; |
156 } | 157 } |
157 | 158 |
158 header->fUseFragShaderOnly = isPathRendering && gpu->glPathRendering()->text
uringMode() == | 159 header->fUseFragShaderOnly = isPathRendering && gpu->glPathRendering()->text
uringMode() == |
159 GrGLPathRendering::FixedFunc
tion_TexturingMode; | 160 GrGLPathRendering::FixedFunc
tion_TexturingMode; |
160 header->fHasGeometryProcessor = vertexShader; | 161 header->fHasGeometryProcessor = vertexShader; |
161 | 162 |
162 CoverageOutput coverageOutput; | 163 GrOptDrawState::PrimaryOutputType primaryOutput; |
163 bool illegalCoverageOutput; | 164 GrOptDrawState::SecondaryOutputType secondaryOutput; |
164 do { | 165 if (!dstRead) { |
165 coverageOutput = static_cast<CoverageOutput>(random->nextULessThan(kCove
rageOutputCnt)); | 166 primaryOutput = GrOptDrawState::kModulate_PrimaryOutputType; |
166 illegalCoverageOutput = (!gpu->caps()->dualSourceBlendingSupport() && | 167 } else { |
167 CoverageOutputUsesSecondaryOutput(coverageOutpu
t)) || | 168 primaryOutput = static_cast<GrOptDrawState::PrimaryOutputType>( |
168 (!dstRead && kCombineWithDst_CoverageOutput == c
overageOutput); | 169 random->nextULessThan(GrOptDrawState::kPrimaryOutputTypeCnt)); |
169 } while (illegalCoverageOutput); | 170 } |
170 | 171 |
171 header->fCoverageOutput = coverageOutput; | 172 if (GrOptDrawState::kCombineWithDst_PrimaryOutputType == primaryOutput || |
| 173 !gpu->caps()->dualSourceBlendingSupport()) { |
| 174 secondaryOutput = GrOptDrawState::kNone_SecondaryOutputType; |
| 175 } else { |
| 176 secondaryOutput = static_cast<GrOptDrawState::SecondaryOutputType>( |
| 177 random->nextULessThan(GrOptDrawState::kSecondaryOutputTypeCnt)); |
| 178 } |
| 179 |
| 180 header->fPrimaryOutputType = primaryOutput; |
| 181 header->fSecondaryOutputType = secondaryOutput; |
172 | 182 |
173 this->finalize(); | 183 this->finalize(); |
174 return true; | 184 return true; |
175 } | 185 } |
176 | 186 |
177 // TODO clean this up, we have to do this to test geometry processors but there
has got to be | 187 // TODO clean this up, we have to do this to test geometry processors but there
has got to be |
178 // a better way. In the mean time, we actually fill out these generic vertex at
tribs below with | 188 // a better way. In the mean time, we actually fill out these generic vertex at
tribs below with |
179 // the correct vertex attribs from the GP. We have to ensure, however, we don't
try to add more | 189 // the correct vertex attribs from the GP. We have to ensure, however, we don't
try to add more |
180 // than two attributes. | 190 // than two attributes. |
181 GrVertexAttrib genericVertexAttribs[] = { | 191 GrVertexAttrib genericVertexAttribs[] = { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 int currTextureCoordSet = 0; | 252 int currTextureCoordSet = 0; |
243 GrTexture* dummyTextures[] = {dummyTexture1.get(), dummyTexture2.get()}; | 253 GrTexture* dummyTextures[] = {dummyTexture1.get(), dummyTexture2.get()}; |
244 | 254 |
245 int numStages = random.nextULessThan(maxStages + 1); | 255 int numStages = random.nextULessThan(maxStages + 1); |
246 int numColorStages = random.nextULessThan(numStages + 1); | 256 int numColorStages = random.nextULessThan(numStages + 1); |
247 int numCoverageStages = numStages - numColorStages; | 257 int numCoverageStages = numStages - numColorStages; |
248 | 258 |
249 SkAutoSTMalloc<8, const GrEffectStage*> stages(numStages); | 259 SkAutoSTMalloc<8, const GrEffectStage*> stages(numStages); |
250 | 260 |
251 bool usePathRendering = this->glCaps().pathRenderingSupport() && random.
nextBool(); | 261 bool usePathRendering = this->glCaps().pathRenderingSupport() && random.
nextBool(); |
252 | 262 |
253 GrGpu::DrawType drawType = usePathRendering ? GrGpu::kDrawPath_DrawType
: | 263 GrGpu::DrawType drawType = usePathRendering ? GrGpu::kDrawPath_DrawType
: |
254 GrGpu::kDrawPoints_DrawTyp
e; | 264 GrGpu::kDrawPoints_DrawTyp
e; |
255 | 265 |
256 SkAutoTDelete<GrEffectStage> geometryProcessor; | 266 SkAutoTDelete<GrEffectStage> geometryProcessor; |
257 bool hasGeometryProcessor = usePathRendering ? false : random.nextBool()
; | 267 bool hasGeometryProcessor = usePathRendering ? false : random.nextBool()
; |
258 if (hasGeometryProcessor) { | 268 if (hasGeometryProcessor) { |
259 while (true) { | 269 while (true) { |
260 SkAutoTUnref<const GrEffect> effect(GrEffectTestFactory::CreateS
tage( | 270 SkAutoTUnref<const GrEffect> effect(GrEffectTestFactory::CreateS
tage( |
261
&random, | 271
&random, |
262
this->getContext(), | 272
this->getContext(), |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1)); | 398 SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1)); |
389 GrConfigConversionEffect::Create(NULL, | 399 GrConfigConversionEffect::Create(NULL, |
390 false, | 400 false, |
391 GrConfigConversionEffect::kNone_PMConversio
n, | 401 GrConfigConversionEffect::kNone_PMConversio
n, |
392 SkMatrix::I()); | 402 SkMatrix::I()); |
393 SkScalar matrix[20]; | 403 SkScalar matrix[20]; |
394 SkAutoTUnref<SkColorMatrixFilter> cmf(SkColorMatrixFilter::Create(matrix)); | 404 SkAutoTUnref<SkColorMatrixFilter> cmf(SkColorMatrixFilter::Create(matrix)); |
395 } | 405 } |
396 | 406 |
397 #endif | 407 #endif |
OLD | NEW |