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/GrGLPathRendering.h" |
20 #include "gl/GrGpuGL.h" | 20 #include "gl/GrGpuGL.h" |
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 static void get_stage_stats(const GrEffectStage stage, bool* readsDst, |
| 26 bool* readsFragPosition, bool* requiresVertexShader)
{ |
| 27 if (stage.getEffect()->willReadDstColor()) { |
| 28 *readsDst = true; |
| 29 } |
| 30 if (stage.getEffect()->willReadFragmentPosition()) { |
| 31 *readsFragPosition = true; |
| 32 } |
| 33 if (stage.getEffect()->requiresVertexShader()) { |
| 34 *requiresVertexShader = true; |
| 35 } |
| 36 } |
| 37 |
25 bool GrGLProgramDesc::setRandom(SkRandom* random, | 38 bool GrGLProgramDesc::setRandom(SkRandom* random, |
26 const GrGpuGL* gpu, | 39 const GrGpuGL* gpu, |
27 const GrRenderTarget* dstRenderTarget, | 40 const GrRenderTarget* dstRenderTarget, |
28 const GrTexture* dstCopyTexture, | 41 const GrTexture* dstCopyTexture, |
29 const GrEffectStage* stages[], | 42 const GrEffectStage* stages[], |
30 int numColorStages, | 43 int numColorStages, |
31 int numCoverageStages, | 44 int numCoverageStages, |
32 int currAttribIndex) { | 45 int currAttribIndex) { |
33 bool useLocalCoords = random->nextBool() && currAttribIndex < GrDrawState::k
MaxVertexAttribCnt; | 46 bool useLocalCoords = random->nextBool() && currAttribIndex < GrDrawState::k
MaxVertexAttribCnt; |
34 | 47 |
(...skipping 13 matching lines...) Expand all Loading... |
48 kEffectKeyOffsetsA
ndLengthOffset + | 61 kEffectKeyOffsetsA
ndLengthOffset + |
49 s * 2 * sizeof(uin
t16_t)); | 62 s * 2 * sizeof(uin
t16_t)); |
50 uint32_t effectKeyOffset = fKey.count(); | 63 uint32_t effectKeyOffset = fKey.count(); |
51 if (effectKeyOffset > SK_MaxU16) { | 64 if (effectKeyOffset > SK_MaxU16) { |
52 fKey.reset(); | 65 fKey.reset(); |
53 return false; | 66 return false; |
54 } | 67 } |
55 GrDrawEffect drawEffect(*stages[s], useLocalCoords); | 68 GrDrawEffect drawEffect(*stages[s], useLocalCoords); |
56 GrEffectKeyBuilder b(&fKey); | 69 GrEffectKeyBuilder b(&fKey); |
57 uint16_t effectKeySize; | 70 uint16_t effectKeySize; |
58 if (!GetEffectKeyAndUpdateStats(*stages[s], gpu->glCaps(), useLocalCoord
s, &b, | 71 if (!GetEffectKey(*stages[s], gpu->glCaps(), useLocalCoords, &b, &effect
KeySize)) { |
59 &effectKeySize, &dstRead, &fragPos, &ver
texShader)) { | |
60 fKey.reset(); | 72 fKey.reset(); |
61 return false; | 73 return false; |
62 } | 74 } |
| 75 get_stage_stats(*stages[s], &dstRead, &fragPos, &vertexShader); |
63 offsetAndSize[0] = effectKeyOffset; | 76 offsetAndSize[0] = effectKeyOffset; |
64 offsetAndSize[1] = effectKeySize; | 77 offsetAndSize[1] = effectKeySize; |
65 } | 78 } |
66 | 79 |
67 KeyHeader* header = this->header(); | 80 KeyHeader* header = this->header(); |
68 memset(header, 0, kHeaderSize); | 81 memset(header, 0, kHeaderSize); |
69 header->fEmitsPointSize = random->nextBool(); | 82 header->fEmitsPointSize = random->nextBool(); |
70 | 83 |
71 header->fPositionAttributeIndex = 0; | 84 header->fPositionAttributeIndex = 0; |
72 | 85 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1)); | 292 SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1)); |
280 GrConfigConversionEffect::Create(NULL, | 293 GrConfigConversionEffect::Create(NULL, |
281 false, | 294 false, |
282 GrConfigConversionEffect::kNone_PMConversio
n, | 295 GrConfigConversionEffect::kNone_PMConversio
n, |
283 SkMatrix::I()); | 296 SkMatrix::I()); |
284 SkScalar matrix[20]; | 297 SkScalar matrix[20]; |
285 SkAutoTUnref<SkColorMatrixFilter> cmf(SkColorMatrixFilter::Create(matrix)); | 298 SkAutoTUnref<SkColorMatrixFilter> cmf(SkColorMatrixFilter::Create(matrix)); |
286 } | 299 } |
287 | 300 |
288 #endif | 301 #endif |
OLD | NEW |