| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #include "SkTypes.h" | |
| 9 #if SK_SUPPORT_GPU | |
| 10 #include "GrContextFactory.h" | |
| 11 #endif | |
| 12 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 13 #include "SkImage.h" | 9 #include "SkImage.h" |
| 14 #include "SkShader.h" | 10 #include "SkShader.h" |
| 15 #include "SkSurface.h" | 11 #include "SkSurface.h" |
| 12 #include "SkTypes.h" |
| 13 #include "Test.h" |
| 16 | 14 |
| 17 #include "Test.h" | 15 #if SK_SUPPORT_GPU |
| 16 #include "GrContext.h" |
| 17 #endif |
| 18 | 18 |
| 19 void testBitmapEquality(skiatest::Reporter* reporter, SkBitmap& bm1, SkBitmap& b
m2) { | 19 void testBitmapEquality(skiatest::Reporter* reporter, SkBitmap& bm1, SkBitmap& b
m2) { |
| 20 SkAutoLockPixels lockBm1(bm1); | 20 SkAutoLockPixels lockBm1(bm1); |
| 21 SkAutoLockPixels lockBm2(bm2); | 21 SkAutoLockPixels lockBm2(bm2); |
| 22 | 22 |
| 23 REPORTER_ASSERT(reporter, bm1.getSize() == bm2.getSize()); | 23 REPORTER_ASSERT(reporter, bm1.getSize() == bm2.getSize()); |
| 24 REPORTER_ASSERT(reporter, 0 == memcmp(bm1.getPixels(), bm2.getPixels(), bm1.
getSize())); | 24 REPORTER_ASSERT(reporter, 0 == memcmp(bm1.getPixels(), bm2.getPixels(), bm1.
getSize())); |
| 25 } | 25 } |
| 26 | 26 |
| 27 void paintSource(SkSurface* sourceSurface) { | 27 void paintSource(SkSurface* sourceSurface) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 void rasterToGpu(skiatest::Reporter* reporter, GrContext* context) { | 136 void rasterToGpu(skiatest::Reporter* reporter, GrContext* context) { |
| 137 SkImageInfo info = SkImageInfo::MakeN32Premul(5, 5); | 137 SkImageInfo info = SkImageInfo::MakeN32Premul(5, 5); |
| 138 | 138 |
| 139 SkAutoTUnref<SkSurface> sourceSurface(SkSurface::NewRaster(info)); | 139 SkAutoTUnref<SkSurface> sourceSurface(SkSurface::NewRaster(info)); |
| 140 SkAutoTUnref<SkSurface> destinationSurface(SkSurface::NewRenderTarget(contex
t, | 140 SkAutoTUnref<SkSurface> destinationSurface(SkSurface::NewRenderTarget(contex
t, |
| 141 SkSurface::kNo_Budgeted, info)); | 141 SkSurface::kNo_Budgeted, info)); |
| 142 | 142 |
| 143 runShaderTest(reporter, sourceSurface.get(), destinationSurface.get(), info)
; | 143 runShaderTest(reporter, sourceSurface.get(), destinationSurface.get(), info)
; |
| 144 } | 144 } |
| 145 | 145 |
| 146 DEF_GPUTEST(ImageNewShader_GPU, reporter, factory) { | 146 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageNewShader_GPU, reporter, context) { |
| 147 for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) { | 147 // GPU -> GPU |
| 148 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContext
Type) i; | 148 gpuToGpu(reporter, context); |
| 149 | 149 |
| 150 if (!GrContextFactory::IsRenderingGLContext(glCtxType)) { | 150 // GPU -> RASTER |
| 151 continue; | 151 gpuToRaster(reporter, context); |
| 152 } | |
| 153 | 152 |
| 154 GrContext* context = factory->get(glCtxType); | 153 // RASTER -> GPU |
| 155 | 154 rasterToGpu(reporter, context); |
| 156 if (nullptr == context) { | |
| 157 continue; | |
| 158 } | |
| 159 | |
| 160 // GPU -> GPU | |
| 161 gpuToGpu(reporter, context); | |
| 162 | |
| 163 // GPU -> RASTER | |
| 164 gpuToRaster(reporter, context); | |
| 165 | |
| 166 // RASTER -> GPU | |
| 167 rasterToGpu(reporter, context); | |
| 168 } | |
| 169 } | 155 } |
| 170 | 156 |
| 171 #endif | 157 #endif |
| OLD | NEW |