From faef51451a81dccffcba50b58d9a323bdd9f150c Mon Sep 17 00:00:00 2001 From: Kevin Lubick Date: Thu, 7 Jun 2018 10:33:11 -0400 Subject: More libfuzzer cleanups from GPU switchover This was breaking the oss-fuzz build as is. Bug: oss-fuzz:8701 Change-Id: I23ad21816a293356c91cd3bbc6276b2ed3ceafe6 Reviewed-on: https://skia-review.googlesource.com/132822 Commit-Queue: Kevin Lubick Auto-Submit: Kevin Lubick Reviewed-by: Mike Klein --- fuzz/FuzzCanvas.cpp | 26 +++++++++++++++++++++++--- fuzz/FuzzCommon.h | 24 ------------------------ fuzz/fuzz.cpp | 1 - 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/fuzz/FuzzCanvas.cpp b/fuzz/FuzzCanvas.cpp index b66e5187dd..7ca14d2223 100644 --- a/fuzz/FuzzCanvas.cpp +++ b/fuzz/FuzzCanvas.cpp @@ -61,16 +61,23 @@ #include "SkXfermodeImageFilter.h" // SRC +#include "SkCommandLineFlags.h" #include "SkUtils.h" #if SK_SUPPORT_GPU #include "GrContextFactory.h" +#include "GrContextPriv.h" +#include "gl/GrGLFunctions.h" +#include "gl/GrGLGpu.h" +#include "gl/GrGLUtil.h" #endif // MISC #include +DEFINE_bool2(gpuInfo, g, false, "Display GPU information on relevant targets."); + // TODO: // SkTextBlob with Unicode // SkImage: more types @@ -1801,6 +1808,21 @@ DEF_FUZZ(SerializedImageFilter, fuzz) { } #if SK_SUPPORT_GPU + +static void dump_GPU_info(GrContext* context) { + const GrGLInterface* gl = static_cast(context->contextPriv().getGpu()) + ->glInterface(); + const GrGLubyte* output; + GR_GL_CALL_RET(gl, output, GetString(GR_GL_RENDERER)); + SkDebugf("GL_RENDERER %s\n", (const char*) output); + + GR_GL_CALL_RET(gl, output, GetString(GR_GL_VENDOR)); + SkDebugf("GL_VENDOR %s\n", (const char*) output); + + GR_GL_CALL_RET(gl, output, GetString(GR_GL_VERSION)); + SkDebugf("GL_VERSION %s\n", (const char*) output); +} + static void fuzz_ganesh(Fuzz* fuzz, GrContext* context) { SkASSERT(context); auto surface = SkSurface::MakeRenderTarget( @@ -1811,8 +1833,6 @@ static void fuzz_ganesh(Fuzz* fuzz, GrContext* context) { fuzz_canvas(fuzz, surface->getCanvas()); } -extern bool FLAGS_gpuInfo; - DEF_FUZZ(NativeGLCanvas, fuzz) { sk_gpu_test::GrContextFactory f; GrContext* context = f.get(sk_gpu_test::GrContextFactory::kGL_ContextType); @@ -1820,7 +1840,7 @@ DEF_FUZZ(NativeGLCanvas, fuzz) { context = f.get(sk_gpu_test::GrContextFactory::kGLES_ContextType); } if (FLAGS_gpuInfo) { - dumpGPUInfo(context); + dump_GPU_info(context); } fuzz_ganesh(fuzz, context); } diff --git a/fuzz/FuzzCommon.h b/fuzz/FuzzCommon.h index 9435b43552..98fab259ec 100644 --- a/fuzz/FuzzCommon.h +++ b/fuzz/FuzzCommon.h @@ -12,30 +12,6 @@ #include "SkPath.h" #include "SkRegion.h" - -#if SK_SUPPORT_GPU -#include "GrContextFactory.h" -#include "gl/GrGLFunctions.h" -#include "gl/GrGLGpu.h" -#include "gl/GrGLUtil.h" -#include "GrContextPriv.h" - -inline void dumpGPUInfo(GrContext* context) { - const GrGLInterface* gl = static_cast(context->contextPriv().getGpu()) - ->glInterface(); - const GrGLubyte* output; - GR_GL_CALL_RET(gl, output, GetString(GR_GL_RENDERER)); - SkDebugf("GL_RENDERER %s\n", (const char*) output); - - GR_GL_CALL_RET(gl, output, GetString(GR_GL_VENDOR)); - SkDebugf("GL_VENDOR %s\n", (const char*) output); - - GR_GL_CALL_RET(gl, output, GetString(GR_GL_VERSION)); - SkDebugf("GL_VERSION %s\n", (const char*) output); -} - -#endif - // We don't always want to test NaNs and infinities. static inline void fuzz_nice_float(Fuzz* fuzz, float* f) { float v; diff --git a/fuzz/fuzz.cpp b/fuzz/fuzz.cpp index 7bf03f1adf..0917747790 100644 --- a/fuzz/fuzz.cpp +++ b/fuzz/fuzz.cpp @@ -46,7 +46,6 @@ DEFINE_string2(bytes, b, "", "A path to a file or a directory. If a file, the " DEFINE_string2(name, n, "", "If --type is 'api', fuzz the API with this name."); DEFINE_string2(dump, d, "", "If not empty, dump 'image*' or 'skp' types as a " "PNG with this name."); -DEFINE_bool2(gpuInfo, g, false, "Display GPU information on relevant targets."); DEFINE_bool2(verbose, v, false, "Print more information while fuzzing."); DEFINE_string2(type, t, "", "How to interpret --bytes, one of:\n" "animated_image_decode\n" -- cgit v1.2.3