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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 87 |
88 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 88 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
89 | 89 |
90 typedef GrFragmentProcessor INHERITED; | 90 typedef GrFragmentProcessor INHERITED; |
91 }; | 91 }; |
92 | 92 |
93 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(BigKeyProcessor); | 93 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(BigKeyProcessor); |
94 | 94 |
95 GrFragmentProcessor* BigKeyProcessor::TestCreate(SkRandom*, | 95 GrFragmentProcessor* BigKeyProcessor::TestCreate(SkRandom*, |
96 GrContext*, | 96 GrContext*, |
97 const GrDrawTargetCaps&, | 97 const GrCaps&, |
98 GrTexture*[]) { | 98 GrTexture*[]) { |
99 return BigKeyProcessor::Create(); | 99 return BigKeyProcessor::Create(); |
100 } | 100 } |
101 | 101 |
102 /* | 102 /* |
103 * Begin test code | 103 * Begin test code |
104 */ | 104 */ |
105 static const int kRenderTargetHeight = 1; | 105 static const int kRenderTargetHeight = 1; |
106 static const int kRenderTargetWidth = 1; | 106 static const int kRenderTargetWidth = 1; |
107 | 107 |
108 static GrRenderTarget* random_render_target(GrContext* context, SkRandom* random
, | 108 static GrRenderTarget* random_render_target(GrContext* context, SkRandom* random
, |
109 const GrDrawTargetCaps* caps) { | 109 const GrCaps* caps) { |
110 // setup render target | 110 // setup render target |
111 GrTextureParams params; | 111 GrTextureParams params; |
112 GrSurfaceDesc texDesc; | 112 GrSurfaceDesc texDesc; |
113 texDesc.fWidth = kRenderTargetWidth; | 113 texDesc.fWidth = kRenderTargetWidth; |
114 texDesc.fHeight = kRenderTargetHeight; | 114 texDesc.fHeight = kRenderTargetHeight; |
115 texDesc.fFlags = kRenderTarget_GrSurfaceFlag; | 115 texDesc.fFlags = kRenderTarget_GrSurfaceFlag; |
116 texDesc.fConfig = kRGBA_8888_GrPixelConfig; | 116 texDesc.fConfig = kRGBA_8888_GrPixelConfig; |
117 texDesc.fOrigin = random->nextBool() == true ? kTopLeft_GrSurfaceOrigin : | 117 texDesc.fOrigin = random->nextBool() == true ? kTopLeft_GrSurfaceOrigin : |
118 kBottomLeft_GrSurfaceOrigin; | 118 kBottomLeft_GrSurfaceOrigin; |
119 texDesc.fSampleCnt = random->nextBool() == true ? SkTMin(4, caps->maxSampleC
ount()) : 0; | 119 texDesc.fSampleCnt = random->nextBool() == true ? SkTMin(4, caps->maxSampleC
ount()) : 0; |
120 | 120 |
121 GrUniqueKey key; | 121 GrUniqueKey key; |
122 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); | 122 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); |
123 GrUniqueKey::Builder builder(&key, kDomain, 2); | 123 GrUniqueKey::Builder builder(&key, kDomain, 2); |
124 builder[0] = texDesc.fOrigin; | 124 builder[0] = texDesc.fOrigin; |
125 builder[1] = texDesc.fSampleCnt; | 125 builder[1] = texDesc.fSampleCnt; |
126 builder.finish(); | 126 builder.finish(); |
127 | 127 |
128 GrTexture* texture = context->textureProvider()->findAndRefTextureByUniqueKe
y(key); | 128 GrTexture* texture = context->textureProvider()->findAndRefTextureByUniqueKe
y(key); |
129 if (!texture) { | 129 if (!texture) { |
130 texture = context->textureProvider()->createTexture(texDesc, true); | 130 texture = context->textureProvider()->createTexture(texDesc, true); |
131 if (texture) { | 131 if (texture) { |
132 context->textureProvider()->assignUniqueKeyToTexture(key, texture); | 132 context->textureProvider()->assignUniqueKeyToTexture(key, texture); |
133 } | 133 } |
134 } | 134 } |
135 return texture ? texture->asRenderTarget() : NULL; | 135 return texture ? texture->asRenderTarget() : NULL; |
136 } | 136 } |
137 | 137 |
138 static void set_random_xpf(GrContext* context, const GrDrawTargetCaps& caps, | 138 static void set_random_xpf(GrContext* context, const GrCaps& caps, |
139 GrPipelineBuilder* pipelineBuilder, SkRandom* random, | 139 GrPipelineBuilder* pipelineBuilder, SkRandom* random, |
140 GrTexture* dummyTextures[]) { | 140 GrTexture* dummyTextures[]) { |
141 SkAutoTUnref<const GrXPFactory> xpf( | 141 SkAutoTUnref<const GrXPFactory> xpf( |
142 GrProcessorTestFactory<GrXPFactory>::CreateStage(random, context, caps,
dummyTextures)); | 142 GrProcessorTestFactory<GrXPFactory>::CreateStage(random, context, caps,
dummyTextures)); |
143 SkASSERT(xpf); | 143 SkASSERT(xpf); |
144 pipelineBuilder->setXPFactory(xpf.get()); | 144 pipelineBuilder->setXPFactory(xpf.get()); |
145 } | 145 } |
146 | 146 |
147 static void set_random_color_coverage_stages(GrGLGpu* gpu, | 147 static void set_random_color_coverage_stages(GrGLGpu* gpu, |
148 GrPipelineBuilder* pipelineBuilder, | 148 GrPipelineBuilder* pipelineBuilder, |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 } | 313 } |
314 #endif | 314 #endif |
315 GrTestTarget target; | 315 GrTestTarget target; |
316 context->getTestTarget(&target); | 316 context->getTestTarget(&target); |
317 REPORTER_ASSERT(reporter, target.target()->programUnitTest(maxStages
)); | 317 REPORTER_ASSERT(reporter, target.target()->programUnitTest(maxStages
)); |
318 } | 318 } |
319 } | 319 } |
320 } | 320 } |
321 | 321 |
322 #endif | 322 #endif |
OLD | NEW |