| 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 /* | 8 /* |
| 9 * Code for the "gm" (Golden Master) rendering comparison tool. | 9 * Code for the "gm" (Golden Master) rendering comparison tool. |
| 10 * | 10 * |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 kTileGrid_BbhType, | 144 kTileGrid_BbhType, |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 enum ConfigFlags { | 147 enum ConfigFlags { |
| 148 kNone_ConfigFlag = 0x0, | 148 kNone_ConfigFlag = 0x0, |
| 149 /* Write GM images if a write path is provided. */ | 149 /* Write GM images if a write path is provided. */ |
| 150 kWrite_ConfigFlag = 0x1, | 150 kWrite_ConfigFlag = 0x1, |
| 151 /* Read reference GM images if a read path is provided. */ | 151 /* Read reference GM images if a read path is provided. */ |
| 152 kRead_ConfigFlag = 0x2, | 152 kRead_ConfigFlag = 0x2, |
| 153 kRW_ConfigFlag = (kWrite_ConfigFlag | kRead_ConfigFlag), | 153 kRW_ConfigFlag = (kWrite_ConfigFlag | kRead_ConfigFlag), |
| 154 /* Use distance fields for rendering text */ | |
| 155 kDFText_ConfigFlag = 0x4, | |
| 156 kRWDFT_ConfigFlag = (kRW_ConfigFlag | kDFText_ConfigFlag), | |
| 157 }; | 154 }; |
| 158 | 155 |
| 159 struct ConfigData { | 156 struct ConfigData { |
| 160 SkColorType fColorType; | 157 SkColorType fColorType; |
| 161 Backend fBackend; | 158 Backend fBackend; |
| 162 GLContextType fGLContextType; // GPU backend only | 159 GLContextType fGLContextType; // GPU backend only |
| 163 int fSampleCnt; // GPU backend only | 160 int fSampleCnt; // GPU backend only |
| 164 ConfigFlags fFlags; | 161 ConfigFlags fFlags; |
| 165 const char* fName; | 162 const char* fName; |
| 166 bool fRunByDefault; | 163 bool fRunByDefault; |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 if (deferred) { | 577 if (deferred) { |
| 581 canvas.reset(SkDeferredCanvas::Create(surface)); | 578 canvas.reset(SkDeferredCanvas::Create(surface)); |
| 582 } else { | 579 } else { |
| 583 canvas.reset(SkRef(surface->getCanvas())); | 580 canvas.reset(SkRef(surface->getCanvas())); |
| 584 } | 581 } |
| 585 invokeGM(gm, canvas, false, deferred); | 582 invokeGM(gm, canvas, false, deferred); |
| 586 canvas->flush(); | 583 canvas->flush(); |
| 587 } | 584 } |
| 588 #if SK_SUPPORT_GPU | 585 #if SK_SUPPORT_GPU |
| 589 else { // GPU | 586 else { // GPU |
| 590 uint32_t flags = (gRec.fFlags & kDFText_ConfigFlag) ? | 587 surface.reset(SkSurface::NewRenderTargetDirect(gpuTarget->asRenderTa
rget())); |
| 591 SkSurfaceProps::kUseDistanceFieldFonts_Flag : 0; | |
| 592 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType
); | |
| 593 surface.reset(SkSurface::NewRenderTargetDirect(gpuTarget->asRenderTa
rget(), &props)); | |
| 594 if (deferred) { | 588 if (deferred) { |
| 595 canvas.reset(SkDeferredCanvas::Create(surface)); | 589 canvas.reset(SkDeferredCanvas::Create(surface)); |
| 596 } else { | 590 } else { |
| 597 canvas.reset(SkRef(surface->getCanvas())); | 591 canvas.reset(SkRef(surface->getCanvas())); |
| 598 } | 592 } |
| 599 invokeGM(gm, canvas, false, deferred); | 593 invokeGM(gm, canvas, false, deferred); |
| 600 // the device is as large as the current rendertarget, so | 594 // the device is as large as the current rendertarget, so |
| 601 // we explicitly only readback the amount we expect (in | 595 // we explicitly only readback the amount we expect (in |
| 602 // size) overwrite our previous allocation | 596 // size) overwrite our previous allocation |
| 603 bitmap->setInfo(SkImageInfo::MakeN32Premul(size.fWidth, size.fHeight
)); | 597 bitmap->setInfo(SkImageInfo::MakeN32Premul(size.fWidth, size.fHeight
)); |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1290 | 1284 |
| 1291 static const ConfigData gRec[] = { | 1285 static const ConfigData gRec[] = { |
| 1292 { kN32_SkColorType, kRaster_Backend, kDontCare_GLContextType,
0, kRW_ConfigFlag, "8888", true }, | 1286 { kN32_SkColorType, kRaster_Backend, kDontCare_GLContextType,
0, kRW_ConfigFlag, "8888", true }, |
| 1293 { kRGB_565_SkColorType, kRaster_Backend, kDontCare_GLContextType,
0, kRW_ConfigFlag, "565", true }, | 1287 { kRGB_565_SkColorType, kRaster_Backend, kDontCare_GLContextType,
0, kRW_ConfigFlag, "565", true }, |
| 1294 #if SK_SUPPORT_GPU | 1288 #if SK_SUPPORT_GPU |
| 1295 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kNative_GLContextType
, 0, kRW_ConfigFlag, "gpu", true }, | 1289 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kNative_GLContextType
, 0, kRW_ConfigFlag, "gpu", true }, |
| 1296 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kNative_GLContextType
, 16, kRW_ConfigFlag, "msaa16", false}, | 1290 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kNative_GLContextType
, 16, kRW_ConfigFlag, "msaa16", false}, |
| 1297 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kNative_GLContextType
, 4, kRW_ConfigFlag, "msaa4", false}, | 1291 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kNative_GLContextType
, 4, kRW_ConfigFlag, "msaa4", false}, |
| 1298 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kNVPR_GLContextType,
4, kRW_ConfigFlag, "nvprmsaa4", true }, | 1292 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kNVPR_GLContextType,
4, kRW_ConfigFlag, "nvprmsaa4", true }, |
| 1299 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kNVPR_GLContextType,
16, kRW_ConfigFlag, "nvprmsaa16", false}, | 1293 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kNVPR_GLContextType,
16, kRW_ConfigFlag, "nvprmsaa16", false}, |
| 1300 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kNative_GLContextType
, 0, kRWDFT_ConfigFlag, "gpudft", true }, | |
| 1301 /* The gpudebug context does not generate meaningful images, so don't record | 1294 /* The gpudebug context does not generate meaningful images, so don't record |
| 1302 * the images it generates! We only run it to look for asserts. */ | 1295 * the images it generates! We only run it to look for asserts. */ |
| 1303 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kDebug_GLContextType,
0, kNone_ConfigFlag, "gpudebug", kDebugOnly}, | 1296 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kDebug_GLContextType,
0, kNone_ConfigFlag, "gpudebug", kDebugOnly}, |
| 1304 /* The gpunull context does the least amount of work possible and doesn't | 1297 /* The gpunull context does the least amount of work possible and doesn't |
| 1305 generate meaninful images, so don't record them!. It can be run to | 1298 generate meaninful images, so don't record them!. It can be run to |
| 1306 isolate the CPU-side processing expense from the GPU-side. | 1299 isolate the CPU-side processing expense from the GPU-side. |
| 1307 */ | 1300 */ |
| 1308 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kNull_GLContextType,
0, kNone_ConfigFlag, "gpunull", kDebugOnly}, | 1301 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kNull_GLContextType,
0, kNone_ConfigFlag, "gpunull", kDebugOnly}, |
| 1309 #if SK_ANGLE | 1302 #if SK_ANGLE |
| 1310 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kANGLE_GLContextType,
0, kRW_ConfigFlag, "angle", true }, | 1303 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kANGLE_GLContextType,
0, kRW_ConfigFlag, "angle", true }, |
| (...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2490 if (FLAGS_forceBWtext) { | 2483 if (FLAGS_forceBWtext) { |
| 2491 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 2484 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
| 2492 } | 2485 } |
| 2493 } | 2486 } |
| 2494 | 2487 |
| 2495 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 2488 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 2496 int main(int argc, char * const argv[]) { | 2489 int main(int argc, char * const argv[]) { |
| 2497 return tool_main(argc, (char**) argv); | 2490 return tool_main(argc, (char**) argv); |
| 2498 } | 2491 } |
| 2499 #endif | 2492 #endif |
| OLD | NEW |