From 44801cac9a7a83711e1b04b14e90364e02a6de49 Mon Sep 17 00:00:00 2001 From: Hal Canary Date: Wed, 15 Mar 2017 11:39:06 -0400 Subject: [PATCH] FuzzCanvas: NativeGLCanvas Change-Id: I7e032d19a5d464e0c46e76acac399786dd79b735 Reviewed-on: https://skia-review.googlesource.com/9721 Reviewed-by: Kevin Lubick Commit-Queue: Hal Canary --- BUILD.gn | 1 + fuzz/FuzzCanvas.cpp | 28 ++++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index a4e4a2e..4d1e4ef 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1313,6 +1313,7 @@ if (skia_enable_tools) { ] deps = [ ":flags", + ":gpu_tool_utils", ":skia", ":tool_utils", ] diff --git a/fuzz/FuzzCanvas.cpp b/fuzz/FuzzCanvas.cpp index bfc90f5..64a818b 100644 --- a/fuzz/FuzzCanvas.cpp +++ b/fuzz/FuzzCanvas.cpp @@ -60,12 +60,17 @@ // SRC #include "SkUtils.h" +#if SK_SUPPORT_GPU +#include "GrContextFactory.h" +#endif + // MISC #include // TODO: // SkTextBlob with Unicode +// SkImage: more types template inline void fuzz_enum_range(Fuzz* fuzz, T* value, Min rmin, Max rmax) { @@ -1755,12 +1760,26 @@ DEF_FUZZ(NullCanvas, fuzz) { fuzz_canvas(fuzz, SkMakeNullCanvas().get()); } +// 8.5x11 letter paper at 72ppi. +constexpr SkISize kCanvasSize = {612, 792}; + DEF_FUZZ(RasterN32Canvas, fuzz) { - fuzz_canvas(fuzz, SkMakeNullCanvas().get()); - auto surface = SkSurface::MakeRasterN32Premul(612, 792); + auto surface = SkSurface::MakeRasterN32Premul(kCanvasSize.width(), kCanvasSize.height()); + SkASSERT(surface && surface->getCanvas()); + fuzz_canvas(fuzz, surface->getCanvas()); +} + +#if SK_SUPPORT_GPU +DEF_FUZZ(NativeGLCanvas, fuzz) { + auto surface = SkSurface::MakeRenderTarget( + sk_gpu_test::GrContextFactory().get( + sk_gpu_test::GrContextFactory::kNativeGL_ContextType), + SkBudgeted::kNo, + SkImageInfo::Make(kCanvasSize.width(), kCanvasSize.height(), kRGBA_8888_SkColorType, kPremul_SkAlphaType)); SkASSERT(surface && surface->getCanvas()); fuzz_canvas(fuzz, surface->getCanvas()); } +#endif DEF_FUZZ(PDFCanvas, fuzz) { struct final : public SkWStream { @@ -1769,12 +1788,13 @@ DEF_FUZZ(PDFCanvas, fuzz) { size_t fN = 0; } stream; auto doc = SkDocument::MakePDF(&stream); - fuzz_canvas(fuzz, doc->beginPage(612.0f, 792.0f)); + fuzz_canvas(fuzz, doc->beginPage(SkIntToScalar(kCanvasSize.width()), + SkIntToScalar(kCanvasSize.height()))); } // not a "real" thing to fuzz, used to debug errors found while fuzzing. DEF_FUZZ(_DumpCanvas, fuzz) { - SkDebugCanvas debugCanvas(612, 792); + SkDebugCanvas debugCanvas(kCanvasSize.width(), kCanvasSize.height()); fuzz_canvas(fuzz, &debugCanvas); std::unique_ptr nullCanvas = SkMakeNullCanvas(); UrlDataManager dataManager(SkString("data")); -- 2.7.4