blob: fb9d40948287317541ea8df2c8dc75f582511445 [file] [log] [blame]
halcanarydecb21e2015-12-10 07:52:45 -08001/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7#ifndef fiddle_main_DEFINED
8#define fiddle_main_DEFINED
9
halcanaryf0da1382016-04-18 11:50:07 -070010#ifdef FIDDLE_BUILD_TEST
11 #include "GrContext.h"
12 #include "SkCanvas.h"
13 #include "SkDocument.h"
14 #include "SkPictureRecorder.h"
15 #include "SkStream.h"
16 #include "SkSurface.h"
17 #include "gl/GrGLAssembleInterface.h"
18 #include "gl/GrGLInterface.h"
19#else
20 #include "skia.h"
21#endif
halcanarydecb21e2015-12-10 07:52:45 -080022
Joe Gregorio97b10ac2017-06-01 13:24:11 -040023#include <sstream>
24
halcanarydecb21e2015-12-10 07:52:45 -080025extern SkBitmap source;
halcanary7b8b2372016-04-18 08:17:56 -070026extern sk_sp<SkImage> image;
Joe Gregorio1e735c02017-04-19 14:05:14 -040027extern double duration; // The total duration of the animation in seconds.
28extern double frame; // A value in [0, 1] of where we are in the animation.
halcanarydecb21e2015-12-10 07:52:45 -080029
30struct DrawOptions {
Joe Gregorio1fd18232017-02-13 11:39:43 -050031 DrawOptions(int w, int h, bool r, bool g, bool p, bool k, bool srgb, bool f16, bool textOnly, const char* s)
halcanarydecb21e2015-12-10 07:52:45 -080032 : size(SkISize::Make(w, h))
33 , raster(r)
34 , gpu(g)
35 , pdf(p)
36 , skp(k)
Matt Saretta2f71262016-11-29 17:14:58 -050037 , srgb(srgb)
38 , f16(f16)
Joe Gregorio1fd18232017-02-13 11:39:43 -050039 , textOnly(textOnly)
Matt Saretta2f71262016-11-29 17:14:58 -050040 , source(s)
41 {
42 // F16 mode is only valid for color correct backends.
43 SkASSERT(srgb || !f16);
44 }
halcanarydecb21e2015-12-10 07:52:45 -080045 SkISize size;
46 bool raster;
47 bool gpu;
48 bool pdf;
49 bool skp;
Matt Saretta2f71262016-11-29 17:14:58 -050050 bool srgb;
51 bool f16;
Joe Gregorio1fd18232017-02-13 11:39:43 -050052 bool textOnly;
halcanarydecb21e2015-12-10 07:52:45 -080053 const char* source;
54};
55
56extern DrawOptions GetDrawOptions();
Joe Gregorio1fd18232017-02-13 11:39:43 -050057extern void SkDebugf(const char * format, ...);
halcanarydecb21e2015-12-10 07:52:45 -080058extern void draw(SkCanvas*);
59
Joe Gregorioa8fabd32017-05-31 09:45:19 -040060// There are different implementations of create_grcontext() for EGL, Mesa,
61// and a fallback to a null context.
Joe Gregorio97b10ac2017-06-01 13:24:11 -040062extern sk_sp<GrContext> create_grcontext(std::ostringstream &driverinfo);
Joe Gregorioa8fabd32017-05-31 09:45:19 -040063
halcanarydecb21e2015-12-10 07:52:45 -080064#endif // fiddle_main_DEFINED