| 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 "GrDrawEffect.h" | 17 #include "GrDrawEffect.h" |
| 18 #include "effects/GrConfigConversionEffect.h" | 18 #include "effects/GrConfigConversionEffect.h" |
| 19 #include "gl/GrGLPathRendering.h" |
| 19 #include "gl/GrGpuGL.h" | 20 #include "gl/GrGpuGL.h" |
| 20 | |
| 21 #include "SkChecksum.h" | 21 #include "SkChecksum.h" |
| 22 #include "SkRandom.h" | 22 #include "SkRandom.h" |
| 23 #include "Test.h" | 23 #include "Test.h" |
| 24 | 24 |
| 25 bool GrGLProgramDesc::setRandom(SkRandom* random, | 25 bool GrGLProgramDesc::setRandom(SkRandom* random, |
| 26 const GrGpuGL* gpu, | 26 const GrGpuGL* gpu, |
| 27 const GrRenderTarget* dstRenderTarget, | 27 const GrRenderTarget* dstRenderTarget, |
| 28 const GrTexture* dstCopyTexture, | 28 const GrTexture* dstCopyTexture, |
| 29 const GrEffectStage* stages[], | 29 const GrEffectStage* stages[], |
| 30 int numColorStages, | 30 int numColorStages, |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 int currTextureCoordSet = 0; | 171 int currTextureCoordSet = 0; |
| 172 int attribIndices[2] = { 0, 0 }; | 172 int attribIndices[2] = { 0, 0 }; |
| 173 GrTexture* dummyTextures[] = {dummyTexture1.get(), dummyTexture2.get()}; | 173 GrTexture* dummyTextures[] = {dummyTexture1.get(), dummyTexture2.get()}; |
| 174 | 174 |
| 175 int numStages = random.nextULessThan(maxStages + 1); | 175 int numStages = random.nextULessThan(maxStages + 1); |
| 176 int numColorStages = random.nextULessThan(numStages + 1); | 176 int numColorStages = random.nextULessThan(numStages + 1); |
| 177 int numCoverageStages = numStages - numColorStages; | 177 int numCoverageStages = numStages - numColorStages; |
| 178 | 178 |
| 179 SkAutoSTMalloc<8, const GrEffectStage*> stages(numStages); | 179 SkAutoSTMalloc<8, const GrEffectStage*> stages(numStages); |
| 180 | 180 |
| 181 bool useFixedFunctionTexturing = this->shouldUseFixedFunctionTexturing()
; | 181 bool useFixedFunctionPathRendering = this->glCaps().pathRenderingSupport
() && |
| 182 !this->pathRendering()->caps().fragmentInputGenSupport; |
| 182 | 183 |
| 183 for (int s = 0; s < numStages;) { | 184 for (int s = 0; s < numStages;) { |
| 184 SkAutoTUnref<const GrEffect> effect(GrEffectTestFactory::CreateStage
( | 185 SkAutoTUnref<const GrEffect> effect(GrEffectTestFactory::CreateStage
( |
| 185 &ran
dom, | 186 &ran
dom, |
| 186 this
->getContext(), | 187 this
->getContext(), |
| 187 *thi
s->caps(), | 188 *thi
s->caps(), |
| 188 dumm
yTextures)); | 189 dumm
yTextures)); |
| 189 SkASSERT(effect); | 190 SkASSERT(effect); |
| 190 int numAttribs = effect->numVertexAttribs(); | 191 int numAttribs = effect->numVertexAttribs(); |
| 191 | 192 |
| 192 // If adding this effect would exceed the max attrib count then gene
rate a | 193 // If adding this effect would exceed the max attrib count then gene
rate a |
| 193 // new random effect. | 194 // new random effect. |
| 194 if (currAttribIndex + numAttribs > GrDrawState::kMaxVertexAttribCnt)
{ | 195 if (currAttribIndex + numAttribs > GrDrawState::kMaxVertexAttribCnt)
{ |
| 195 continue; | 196 continue; |
| 196 } | 197 } |
| 197 | 198 |
| 198 | 199 |
| 199 // If adding this effect would exceed the max texture coord set coun
t then generate a | 200 // If adding this effect would exceed the max texture coord set coun
t then generate a |
| 200 // new random effect. | 201 // new random effect. |
| 201 if (useFixedFunctionTexturing && !effect->hasVertexCode()) { | 202 if (useFixedFunctionPathRendering && !effect->hasVertexCode()) { |
| 202 int numTransforms = effect->numTransforms(); | 203 int numTransforms = effect->numTransforms(); |
| 203 if (currTextureCoordSet + numTransforms > this->glCaps().maxFixe
dFunctionTextureCoords()) { | 204 if (currTextureCoordSet + numTransforms > this->glCaps().maxFixe
dFunctionTextureCoords()) { |
| 204 continue; | 205 continue; |
| 205 } | 206 } |
| 206 currTextureCoordSet += numTransforms; | 207 currTextureCoordSet += numTransforms; |
| 207 } | 208 } |
| 208 | 209 |
| 209 useFixedFunctionTexturing = useFixedFunctionTexturing && !effect->ha
sVertexCode(); | 210 useFixedFunctionPathRendering = useFixedFunctionPathRendering && !ef
fect->hasVertexCode(); |
| 210 | 211 |
| 211 for (int i = 0; i < numAttribs; ++i) { | 212 for (int i = 0; i < numAttribs; ++i) { |
| 212 attribIndices[i] = currAttribIndex++; | 213 attribIndices[i] = currAttribIndex++; |
| 213 } | 214 } |
| 214 GrEffectStage* stage = SkNEW_ARGS(GrEffectStage, | 215 GrEffectStage* stage = SkNEW_ARGS(GrEffectStage, |
| 215 (effect.get(), attribIndices[0], a
ttribIndices[1])); | 216 (effect.get(), attribIndices[0], a
ttribIndices[1])); |
| 216 stages[s] = stage; | 217 stages[s] = stage; |
| 217 ++s; | 218 ++s; |
| 218 } | 219 } |
| 219 const GrTexture* dstTexture = random.nextBool() ? dummyTextures[0] : dum
myTextures[1]; | 220 const GrTexture* dstTexture = random.nextBool() ? dummyTextures[0] : dum
myTextures[1]; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1)); | 279 SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1)); |
| 279 GrConfigConversionEffect::Create(NULL, | 280 GrConfigConversionEffect::Create(NULL, |
| 280 false, | 281 false, |
| 281 GrConfigConversionEffect::kNone_PMConversio
n, | 282 GrConfigConversionEffect::kNone_PMConversio
n, |
| 282 SkMatrix::I()); | 283 SkMatrix::I()); |
| 283 SkScalar matrix[20]; | 284 SkScalar matrix[20]; |
| 284 SkAutoTUnref<SkColorMatrixFilter> cmf(SkColorMatrixFilter::Create(matrix)); | 285 SkAutoTUnref<SkColorMatrixFilter> cmf(SkColorMatrixFilter::Create(matrix)); |
| 285 } | 286 } |
| 286 | 287 |
| 287 #endif | 288 #endif |
| OLD | NEW |