Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: tests/GLProgramsTest.cpp

Issue 12531015: Adds local coords to GrEffect system. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gpu/gl/GrGLShaderBuilder.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "gl/GrGpuGL.h" 15 #include "gl/GrGpuGL.h"
16 #include "GrBackendEffectFactory.h" 16 #include "GrBackendEffectFactory.h"
17 #include "GrContextFactory.h" 17 #include "GrContextFactory.h"
18 #include "GrDrawEffect.h"
18 #include "effects/GrConfigConversionEffect.h" 19 #include "effects/GrConfigConversionEffect.h"
19 20
20 #include "SkRandom.h" 21 #include "SkRandom.h"
21 #include "Test.h" 22 #include "Test.h"
22 23
23 void GrGLProgram::Desc::setRandom(SkMWCRandom* random, 24 void GrGLProgram::Desc::setRandom(SkMWCRandom* random,
24 const GrGpuGL* gpu, 25 const GrGpuGL* gpu,
25 const GrEffectStage stages[GrDrawState::kNumSt ages]) { 26 const GrEffectStage stages[GrDrawState::kNumSt ages]) {
26 fAttribBindings = 0; 27 fAttribBindings = 0;
27 fEmitsPointSize = random->nextBool(); 28 fEmitsPointSize = random->nextBool();
(...skipping 22 matching lines...) Expand all
50 fDiscardIfOutsideEdge = false; 51 fDiscardIfOutsideEdge = false;
51 } 52 }
52 } 53 }
53 54
54 if (gpu->getCaps().dualSourceBlendingSupport()) { 55 if (gpu->getCaps().dualSourceBlendingSupport()) {
55 fDualSrcOutput = random->nextULessThan(kDualSrcOutputCnt); 56 fDualSrcOutput = random->nextULessThan(kDualSrcOutputCnt);
56 } else { 57 } else {
57 fDualSrcOutput = kNone_DualSrcOutput; 58 fDualSrcOutput = kNone_DualSrcOutput;
58 } 59 }
59 60
60 bool useOnce = false; 61 // use separate tex coords?
62 if (random->nextBool()) {
63 fAttribBindings |= GrDrawState::kLocalCoords_AttribBindingsBit;
64 }
65
61 for (int s = 0; s < GrDrawState::kNumStages; ++s) { 66 for (int s = 0; s < GrDrawState::kNumStages; ++s) {
62 if (NULL != stages[s].getEffect()) { 67 if (NULL != stages[s].getEffect()) {
63 const GrBackendEffectFactory& factory = (*stages[s].getEffect())->ge tFactory(); 68 const GrBackendEffectFactory& factory = (*stages[s].getEffect())->ge tFactory();
64 fEffectKeys[s] = factory.glEffectKey(stages[s], gpu->glCaps()); 69 bool explicitLocalCoords = (fAttribBindings &
65 // use separate tex coords? 70 GrDrawState::kLocalCoords_AttribBindings Bit);
66 if (!useOnce && random->nextBool()) { 71 GrDrawEffect drawEffect(stages[s], explicitLocalCoords);
67 fAttribBindings |= GrDrawState::ExplicitTexCoordAttribBindingsBi t(s); 72 fEffectKeys[s] = factory.glEffectKey(drawEffect, gpu->glCaps());
68 useOnce = true;
69 }
70 } 73 }
71 } 74 }
72 75
73 int attributeIndex = 0; 76 int attributeIndex = 0;
74 fPositionAttributeIndex = attributeIndex; 77 fPositionAttributeIndex = attributeIndex;
75 ++attributeIndex; 78 ++attributeIndex;
76 if (fColorInput || (fAttribBindings & GrDrawState::kColor_AttribBindingsBit) ) { 79 if (fColorInput || (fAttribBindings & GrDrawState::kColor_AttribBindingsBit) ) {
77 fColorAttributeIndex = attributeIndex; 80 fColorAttributeIndex = attributeIndex;
78 ++attributeIndex; 81 ++attributeIndex;
79 } 82 }
80 if (fCoverageInput || (fAttribBindings & GrDrawState::kCoverage_AttribBindin gsBit)) { 83 if (fCoverageInput || (fAttribBindings & GrDrawState::kCoverage_AttribBindin gsBit)) {
81 fCoverageAttributeIndex = attributeIndex; 84 fCoverageAttributeIndex = attributeIndex;
82 ++attributeIndex; 85 ++attributeIndex;
83 } 86 }
84 if (fAttribBindings & GrDrawState::kEdge_AttribBindingsBit) { 87 if (fAttribBindings & GrDrawState::kEdge_AttribBindingsBit) {
85 fEdgeAttributeIndex = attributeIndex; 88 fEdgeAttributeIndex = attributeIndex;
86 ++attributeIndex; 89 ++attributeIndex;
87 } 90 }
88 if (GrDrawState::AttributesBindExplicitTexCoords(fAttribBindings)) { 91 if (fAttribBindings & GrDrawState::kLocalCoords_AttribBindingsBit) {
89 fTexCoordAttributeIndex = attributeIndex; 92 fLocalCoordsAttributeIndex = attributeIndex;
90 ++attributeIndex; 93 ++attributeIndex;
91 } 94 }
92 } 95 }
93 96
94 bool GrGpuGL::programUnitTest(int maxStages) { 97 bool GrGpuGL::programUnitTest(int maxStages) {
95 98
96 maxStages = GrMin(maxStages, (int)GrDrawState::kNumStages); 99 maxStages = GrMin(maxStages, (int)GrDrawState::kNumStages);
97 100
98 GrTextureDesc dummyDesc; 101 GrTextureDesc dummyDesc;
99 dummyDesc.fConfig = kSkia8888_GrPixelConfig; 102 dummyDesc.fConfig = kSkia8888_GrPixelConfig;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 SkMagnifierImageFilter mag(SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar 1); 192 SkMagnifierImageFilter mag(SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar 1);
190 GrConfigConversionEffect::Create(NULL, 193 GrConfigConversionEffect::Create(NULL,
191 false, 194 false,
192 GrConfigConversionEffect::kNone_PMConversio n, 195 GrConfigConversionEffect::kNone_PMConversio n,
193 SkMatrix::I()); 196 SkMatrix::I());
194 SkScalar matrix[20]; 197 SkScalar matrix[20];
195 SkColorMatrixFilter cmf(matrix); 198 SkColorMatrixFilter cmf(matrix);
196 } 199 }
197 200
198 #endif 201 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLShaderBuilder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698