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