OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 // This is a GPU-backend specific test. It relies on static intializers to work | 8 // This is a GPU-backend specific test. It relies on static intializers to work |
9 | 9 |
10 #include "SkTypes.h" | 10 #include "SkTypes.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 static const int kRenderTargetHeight = 1; | 147 static const int kRenderTargetHeight = 1; |
148 static const int kRenderTargetWidth = 1; | 148 static const int kRenderTargetWidth = 1; |
149 | 149 |
150 static sk_sp<GrDrawContext> random_draw_context(GrContext* context, | 150 static sk_sp<GrDrawContext> random_draw_context(GrContext* context, |
151 SkRandom* random, | 151 SkRandom* random, |
152 const GrCaps* caps) { | 152 const GrCaps* caps) { |
153 GrSurfaceOrigin origin = random->nextBool() ? kTopLeft_GrSurfaceOrigin | 153 GrSurfaceOrigin origin = random->nextBool() ? kTopLeft_GrSurfaceOrigin |
154 : kBottomLeft_GrSurfaceOrigin; | 154 : kBottomLeft_GrSurfaceOrigin; |
155 int sampleCnt = random->nextBool() ? SkTMin(4, caps->maxSampleCount()) : 0; | 155 int sampleCnt = random->nextBool() ? SkTMin(4, caps->maxSampleCount()) : 0; |
156 | 156 |
157 GrUniqueKey key; | |
bsalomon
2016/07/19 15:04:29
I presume this keying was preserved from pre-DC da
| |
158 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); | |
159 GrUniqueKey::Builder builder(&key, kDomain, 2); | |
160 builder[0] = origin; | |
161 builder[1] = sampleCnt; | |
162 builder.finish(); | |
163 | |
164 sk_sp<GrTexture> texture(context->textureProvider()->findAndRefTextureByUniq ueKey(key)); | |
165 if (texture) { | |
166 sk_sp<GrRenderTarget> rt(sk_ref_sp(texture->asRenderTarget())); | |
167 return context->drawContext(std::move(rt)); | |
168 } | |
169 | |
170 sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kExac t, | 157 sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kExac t, |
171 kRenderTargetWidth, | 158 kRenderTargetWidth, |
172 kRenderTargetHeight , | 159 kRenderTargetHeight , |
173 kRGBA_8888_GrPixelC onfig, | 160 kRGBA_8888_GrPixelC onfig, |
174 sampleCnt, | 161 sampleCnt, |
175 origin)); | 162 origin)); |
176 if (!drawContext) { | |
177 return nullptr; | |
178 } | |
179 | |
180 // TODO: need a real way to do this via the drawContext | |
181 texture = drawContext->asTexture(); | |
182 context->textureProvider()->assignUniqueKeyToTexture(key, texture.get()); | |
183 | |
184 return drawContext; | 163 return drawContext; |
185 } | 164 } |
186 | 165 |
187 static void set_random_xpf(GrPaint* paint, GrProcessorTestData* d) { | 166 static void set_random_xpf(GrPaint* paint, GrProcessorTestData* d) { |
188 sk_sp<GrXPFactory> xpf(GrProcessorTestFactory<GrXPFactory>::Make(d)); | 167 sk_sp<GrXPFactory> xpf(GrProcessorTestFactory<GrXPFactory>::Make(d)); |
189 SkASSERT(xpf); | 168 SkASSERT(xpf); |
190 paint->setXPFactory(std::move(xpf)); | 169 paint->setXPFactory(std::move(xpf)); |
191 } | 170 } |
192 | 171 |
193 static sk_sp<GrFragmentProcessor> create_random_proc_tree(GrProcessorTestData* d , | 172 static sk_sp<GrFragmentProcessor> create_random_proc_tree(GrProcessorTestData* d , |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
461 GrContextOptions opts; | 440 GrContextOptions opts; |
462 opts.fSuppressPrints = true; | 441 opts.fSuppressPrints = true; |
463 sk_gpu_test::GrContextFactory debugFactory(opts); | 442 sk_gpu_test::GrContextFactory debugFactory(opts); |
464 skiatest::RunWithGPUTestContexts(test_glprograms_native, &is_native_gl_conte xt_type, | 443 skiatest::RunWithGPUTestContexts(test_glprograms_native, &is_native_gl_conte xt_type, |
465 reporter, &debugFactory); | 444 reporter, &debugFactory); |
466 skiatest::RunWithGPUTestContexts(test_glprograms_other_contexts, | 445 skiatest::RunWithGPUTestContexts(test_glprograms_other_contexts, |
467 &is_other_rendering_gl_context_type, report er, &debugFactory); | 446 &is_other_rendering_gl_context_type, report er, &debugFactory); |
468 } | 447 } |
469 | 448 |
470 #endif | 449 #endif |
OLD | NEW |