[fuzz] Make mock gpu fuzzer compatible with Vulkan

Change-Id: I857da21674db669d7f2766132e9909ccbcdc1c55
Bug: oss-fuzz:44132
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/502536
Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Kevin Lubick 2022-02-01 09:03:41 -05:00
parent 07d229c795
commit 94303e8dbd
2 changed files with 24 additions and 20 deletions

View File

@ -3177,7 +3177,7 @@ if (skia_enable_tools) {
deps = []
}
if (skia_use_gl) {
if (skia_enable_gpu) {
libfuzzer_app("api_mock_gpu_canvas") {
include_dirs = [
"tools",

View File

@ -50,13 +50,16 @@
#include "src/utils/SkUTF.h"
#include "tools/flags/CommandLineFlags.h"
#ifdef SK_GL
#if SK_SUPPORT_GPU
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/gl/GrGLFunctions.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "tools/gpu/GrContextFactory.h"
#endif
#ifdef SK_GL
#include "include/gpu/gl/GrGLFunctions.h"
#include "src/gpu/gl/GrGLGpu.h"
#include "src/gpu/gl/GrGLUtil.h"
#include "tools/gpu/GrContextFactory.h"
#endif
// MISC
@ -1620,8 +1623,24 @@ DEF_FUZZ(SerializedImageFilter, fuzz) {
canvas.restore();
}
#ifdef SK_GL
#if SK_SUPPORT_GPU
static void fuzz_ganesh(Fuzz* fuzz, GrDirectContext* context) {
SkASSERT(context);
auto surface = SkSurface::MakeRenderTarget(
context,
SkBudgeted::kNo,
SkImageInfo::Make(kCanvasSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType));
SkASSERT(surface && surface->getCanvas());
fuzz_canvas(fuzz, surface->getCanvas());
}
DEF_FUZZ(MockGPUCanvas, fuzz) {
sk_gpu_test::GrContextFactory f;
fuzz_ganesh(fuzz, f.get(sk_gpu_test::GrContextFactory::kMock_ContextType));
}
#endif
#ifdef SK_GL
static void dump_GPU_info(GrDirectContext* context) {
const GrGLInterface* gl = static_cast<GrGLGpu*>(context->priv().getGpu())
->glInterface();
@ -1636,16 +1655,6 @@ static void dump_GPU_info(GrDirectContext* context) {
SkDebugf("GL_VERSION %s\n", (const char*) output);
}
static void fuzz_ganesh(Fuzz* fuzz, GrDirectContext* context) {
SkASSERT(context);
auto surface = SkSurface::MakeRenderTarget(
context,
SkBudgeted::kNo,
SkImageInfo::Make(kCanvasSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType));
SkASSERT(surface && surface->getCanvas());
fuzz_canvas(fuzz, surface->getCanvas());
}
DEF_FUZZ(NativeGLCanvas, fuzz) {
sk_gpu_test::GrContextFactory f;
auto context = f.get(sk_gpu_test::GrContextFactory::kGL_ContextType);
@ -1657,11 +1666,6 @@ DEF_FUZZ(NativeGLCanvas, fuzz) {
}
fuzz_ganesh(fuzz, context);
}
DEF_FUZZ(MockGPUCanvas, fuzz) {
sk_gpu_test::GrContextFactory f;
fuzz_ganesh(fuzz, f.get(sk_gpu_test::GrContextFactory::kMock_ContextType));
}
#endif
DEF_FUZZ(PDFCanvas, fuzz) {