• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
10 #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
22 
23 #include <sstream>
24 
25 extern SkBitmap source;
26 extern sk_sp<SkImage> image;
27 extern double duration; // The total duration of the animation in seconds.
28 extern double frame;    // A value in [0, 1] of where we are in the animation.
29 
30 struct DrawOptions {
DrawOptionsDrawOptions31     DrawOptions(int w, int h, bool r, bool g, bool p, bool k, bool srgb, bool f16, bool textOnly, const char* s)
32         : size(SkISize::Make(w, h))
33         , raster(r)
34         , gpu(g)
35         , pdf(p)
36         , skp(k)
37         , srgb(srgb)
38         , f16(f16)
39         , textOnly(textOnly)
40         , source(s)
41     {
42         // F16 mode is only valid for color correct backends.
43         SkASSERT(srgb || !f16);
44     }
45     SkISize size;
46     bool raster;
47     bool gpu;
48     bool pdf;
49     bool skp;
50     bool srgb;
51     bool f16;
52     bool textOnly;
53     const char* source;
54 };
55 
56 extern DrawOptions GetDrawOptions();
57 extern void SkDebugf(const char * format, ...);
58 extern void draw(SkCanvas*);
59 
60 // There are different implementations of create_grcontext() for EGL, Mesa,
61 // and a fallback to a null context.
62 extern sk_sp<GrContext> create_grcontext(std::ostringstream &driverinfo);
63 
64 #endif  // fiddle_main_DEFINED
65