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 17 matching lines...) Expand all Loading... |
28 const GrTexture* dstCopyTexture, | 28 const GrTexture* dstCopyTexture, |
29 const GrEffectStage* stages[], | 29 const GrEffectStage* stages[], |
30 int numColorStages, | 30 int numColorStages, |
31 int numCoverageStages, | 31 int numCoverageStages, |
32 int currAttribIndex) { | 32 int currAttribIndex) { |
33 bool useLocalCoords = random->nextBool() && currAttribIndex < GrDrawState::k
MaxVertexAttribCnt; | 33 bool useLocalCoords = random->nextBool() && currAttribIndex < GrDrawState::k
MaxVertexAttribCnt; |
34 | 34 |
35 int numStages = numColorStages + numCoverageStages; | 35 int numStages = numColorStages + numCoverageStages; |
36 fKey.reset(); | 36 fKey.reset(); |
37 | 37 |
38 GR_STATIC_ASSERT(0 == kEffectKeyLengthsOffset % sizeof(uint32_t)); | 38 GR_STATIC_ASSERT(0 == kEffectKeyOffsetsAndLengthOffset % sizeof(uint32_t)); |
39 | 39 |
40 // Make room for everything up to and including the array of offsets to effe
ct keys. | 40 // Make room for everything up to and including the array of offsets to effe
ct keys. |
41 fKey.push_back_n(kEffectKeyLengthsOffset + sizeof(uint32_t) * numStages); | 41 fKey.push_back_n(kEffectKeyOffsetsAndLengthOffset + 2 * sizeof(uint16_t) * n
umStages); |
42 | |
43 size_t offset = fKey.count(); | |
44 int offsetIndex = 0; | |
45 | 42 |
46 bool dstRead = false; | 43 bool dstRead = false; |
47 bool fragPos = false; | 44 bool fragPos = false; |
48 bool vertexCode = false; | 45 bool vertexCode = false; |
49 for (int s = 0; s < numStages; ++s) { | 46 for (int s = 0; s < numStages; ++s) { |
50 uint32_t* offsetLocation = reinterpret_cast<uint32_t*>(fKey.begin() + | 47 uint16_t* offsetAndSize = reinterpret_cast<uint16_t*>(fKey.begin() + |
51 kEffectKeyLengths
Offset + | 48 kEffectKeyOffsetsA
ndLengthOffset + |
52 offsetIndex * siz
eof(uint32_t)); | 49 s * 2 * sizeof(uin
t16_t)); |
53 *offsetLocation = offset; | 50 uint32_t effectKeyOffset = fKey.count(); |
54 ++offsetIndex; | 51 if (effectKeyOffset > SK_MaxU16) { |
55 | |
56 const GrBackendEffectFactory& factory = stages[s]->getEffect()->getFacto
ry(); | |
57 GrDrawEffect drawEffect(*stages[s], useLocalCoords); | |
58 GrEffectKeyBuilder b(&fKey); | |
59 if (!factory.getGLEffectKey(drawEffect, gpu->glCaps(), &b)) { | |
60 fKey.reset(); | 52 fKey.reset(); |
61 return false; | 53 return false; |
62 } | 54 } |
63 if (stages[s]->getEffect()->willReadDstColor()) { | 55 GrDrawEffect drawEffect(*stages[s], useLocalCoords); |
64 dstRead = true; | 56 GrEffectKeyBuilder b(&fKey); |
| 57 uint16_t effectKeySize; |
| 58 if (!GetEffectKeyAndUpdateStats(*stages[s], gpu->glCaps(), useLocalCoord
s, &b, |
| 59 &effectKeySize, &dstRead, &fragPos, &ver
texCode)) { |
| 60 fKey.reset(); |
| 61 return false; |
65 } | 62 } |
66 if (stages[s]->getEffect()->willReadFragmentPosition()) { | 63 offsetAndSize[0] = effectKeyOffset; |
67 fragPos = true; | 64 offsetAndSize[1] = effectKeySize; |
68 } | |
69 if (stages[s]->getEffect()->hasVertexCode()) { | |
70 vertexCode = true; | |
71 } | |
72 | |
73 offset += b.size(); | |
74 } | 65 } |
75 | 66 |
76 KeyHeader* header = this->header(); | 67 KeyHeader* header = this->header(); |
77 memset(header, 0, kHeaderSize); | 68 memset(header, 0, kHeaderSize); |
78 header->fEmitsPointSize = random->nextBool(); | 69 header->fEmitsPointSize = random->nextBool(); |
79 | 70 |
80 header->fPositionAttributeIndex = 0; | 71 header->fPositionAttributeIndex = 0; |
81 | 72 |
82 // if the effects have used up all off the available attributes, | 73 // if the effects have used up all off the available attributes, |
83 // don't try to use color or coverage attributes as input | 74 // don't try to use color or coverage attributes as input |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1)); | 273 SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1)); |
283 GrConfigConversionEffect::Create(NULL, | 274 GrConfigConversionEffect::Create(NULL, |
284 false, | 275 false, |
285 GrConfigConversionEffect::kNone_PMConversio
n, | 276 GrConfigConversionEffect::kNone_PMConversio
n, |
286 SkMatrix::I()); | 277 SkMatrix::I()); |
287 SkScalar matrix[20]; | 278 SkScalar matrix[20]; |
288 SkAutoTUnref<SkColorMatrixFilter> cmf(SkColorMatrixFilter::Create(matrix)); | 279 SkAutoTUnref<SkColorMatrixFilter> cmf(SkColorMatrixFilter::Create(matrix)); |
289 } | 280 } |
290 | 281 |
291 #endif | 282 #endif |
OLD | NEW |