Chromium Code Reviews| Index: tests/GLProgramsTest.cpp |
| diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp |
| index c643bd567ac4ee393c351a7f32008ebcd17c7b7d..71dc7ba58cc402baf4859515adec05701ae5d1f9 100644 |
| --- a/tests/GLProgramsTest.cpp |
| +++ b/tests/GLProgramsTest.cpp |
| @@ -373,19 +373,20 @@ static void set_random_stencil(GrGpuGL* gpu, SkRandom* random) { |
| } |
| } |
| -bool GrGpuGL::programUnitTest(int maxStages) { |
| +bool GrDrawTarget::programUnitTest(int maxStages) { |
| + GrGpuGL* gpu = static_cast<GrGpuGL*>(fContext->getGpu()); |
|
bsalomon
2014/11/05 19:13:43
Does this have to be the GL subclass?
joshualitt
2014/11/05 19:55:47
Otherwise we can't build the GL program and we nee
bsalomon
2014/11/05 20:00:22
Gotcha, seems like we're pretty close to making th
|
| // setup dummy textures |
| GrSurfaceDesc dummyDesc; |
| dummyDesc.fFlags = kRenderTarget_GrSurfaceFlag; |
| dummyDesc.fConfig = kSkia8888_GrPixelConfig; |
| dummyDesc.fWidth = 34; |
| dummyDesc.fHeight = 18; |
| - SkAutoTUnref<GrTexture> dummyTexture1(this->createTexture(dummyDesc, NULL, 0)); |
| + SkAutoTUnref<GrTexture> dummyTexture1(gpu->createTexture(dummyDesc, NULL, 0)); |
| dummyDesc.fFlags = kNone_GrSurfaceFlags; |
| dummyDesc.fConfig = kAlpha_8_GrPixelConfig; |
| dummyDesc.fWidth = 16; |
| dummyDesc.fHeight = 22; |
| - SkAutoTUnref<GrTexture> dummyTexture2(this->createTexture(dummyDesc, NULL, 0)); |
| + SkAutoTUnref<GrTexture> dummyTexture2(gpu->createTexture(dummyDesc, NULL, 0)); |
| if (!dummyTexture1 || ! dummyTexture2) { |
| SkDebugf("Could not allocate dummy textures"); |
| @@ -418,7 +419,7 @@ bool GrGpuGL::programUnitTest(int maxStages) { |
| static const int NUM_TESTS = 512; |
| for (int t = 0; t < NUM_TESTS;) { |
| // setup random render target(can fail) |
| - SkAutoTUnref<GrRenderTarget> rt(random_render_target(this, glProgramsCacheID, &random)); |
| + SkAutoTUnref<GrRenderTarget> rt(random_render_target(gpu, glProgramsCacheID, &random)); |
| if (!rt) { |
| SkDebugf("Could not allocate render target"); |
| return false; |
| @@ -428,7 +429,7 @@ bool GrGpuGL::programUnitTest(int maxStages) { |
| ds->setRenderTarget(rt.get()); |
| // if path rendering we have to setup a couple of things like the draw type |
| - bool usePathRendering = this->glCaps().pathRenderingSupport() && random.nextBool(); |
| + bool usePathRendering = gpu->glCaps().pathRenderingSupport() && random.nextBool(); |
| GrGpu::DrawType drawType = usePathRendering ? GrGpu::kDrawPath_DrawType : |
| GrGpu::kDrawPoints_DrawType; |
| @@ -436,16 +437,16 @@ bool GrGpuGL::programUnitTest(int maxStages) { |
| // twiddle drawstate knobs randomly |
| bool hasGeometryProcessor = usePathRendering ? false : random.nextBool(); |
| if (hasGeometryProcessor) { |
| - set_random_gp(this, &random, dummyTextures); |
| + set_random_gp(gpu, &random, dummyTextures); |
| } |
| - set_random_color_coverage_stages(this, maxStages - hasGeometryProcessor, usePathRendering, |
| + set_random_color_coverage_stages(gpu, maxStages - hasGeometryProcessor, usePathRendering, |
| &random, dummyTextures); |
| - set_random_color(this, &random); |
| - set_random_coverage(this, &random); |
| - set_random_hints(this, &random); |
| - set_random_state(this, &random); |
| - set_random_blend_func(this, &random); |
| - set_random_stencil(this, &random); |
| + set_random_color(gpu, &random); |
| + set_random_coverage(gpu, &random); |
| + set_random_hints(gpu, &random); |
| + set_random_state(gpu, &random); |
| + set_random_blend_func(gpu, &random); |
| + set_random_stencil(gpu, &random); |
| GrDeviceCoordTexture dstCopy; |
| @@ -456,15 +457,15 @@ bool GrGpuGL::programUnitTest(int maxStages) { |
| // create optimized draw state, setup readDst texture if required, and build a descriptor |
| // and program. ODS creation can fail, so we have to check |
| - SkAutoTUnref<GrOptDrawState> ods(GrOptDrawState::Create(this->getDrawState(), |
| - this, |
| + SkAutoTUnref<GrOptDrawState> ods(GrOptDrawState::Create(gpu->getDrawState(), |
| + gpu, |
| &dstCopy, |
| drawType)); |
| if (!ods.get()) { |
| ds->reset(); |
| continue; |
| } |
| - SkAutoTUnref<GrGLProgram> program(GrGLProgramBuilder::CreateProgram(*ods, drawType, this)); |
| + SkAutoTUnref<GrGLProgram> program(GrGLProgramBuilder::CreateProgram(*ods, drawType, gpu)); |
| if (NULL == program.get()) { |
| SkDebugf("Failed to create program!"); |
| return false; |
| @@ -507,7 +508,8 @@ DEF_GPUTEST(GLPrograms, reporter, factory) { |
| maxStages = 3; |
| } |
| #endif |
| - REPORTER_ASSERT(reporter, gpu->programUnitTest(maxStages)); |
| + GrDrawTarget* dt = static_cast<GrDrawTarget*>(context->getDrawTarget()); |
| + REPORTER_ASSERT(reporter, dt->programUnitTest(maxStages)); |
| } |
| } |
| } |