• 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 GrBackendTexture backEndTexture;
26 extern GrBackendRenderTarget backEndRenderTarget;
27 extern GrBackendTexture backEndTextureRenderTarget;
28 extern SkBitmap source;
29 extern sk_sp<SkImage> image;
30 extern double duration; // The total duration of the animation in seconds.
31 extern double frame;    // A value in [0, 1] of where we are in the animation.
32 
33 struct DrawOptions {
DrawOptionsDrawOptions34     DrawOptions(int w, int h, bool r, bool g, bool p, bool k, bool srgb, bool f16,
35                 bool textOnly, const char* s,
36                 GrMipMapped mipMapping,
37                 int offScreenWidth,
38                 int offScreenHeight,
39                 int offScreenSampleCount,
40                 GrMipMapped offScreenMipMapping)
41         : size(SkISize::Make(w, h))
42         , raster(r)
43         , gpu(g)
44         , pdf(p)
45         , skp(k)
46         , srgb(srgb)
47         , f16(f16)
48         , textOnly(textOnly)
49         , source(s)
50         , fMipMapping(mipMapping)
51         , fOffScreenWidth(offScreenWidth)
52         , fOffScreenHeight(offScreenHeight)
53         , fOffScreenSampleCount(offScreenSampleCount)
54         , fOffScreenMipMapping(offScreenMipMapping) {
55         // F16 mode is only valid for color correct backends.
56         SkASSERT(srgb || !f16);
57     }
58     SkISize size;
59     bool raster;
60     bool gpu;
61     bool pdf;
62     bool skp;
63     bool srgb;
64     bool f16;
65     bool textOnly;
66     const char* source;
67 
68     // This flag is used when a GPU texture resource is created and exposed as a GrBackendTexture.
69     // In this case the resource is created with extra room to accomodate mipmaps.
70     // TODO: The SkImage::makeTextureImage API would need to be widened to allow this to be true
71     // for the non-backend gpu SkImages.
72     GrMipMapped fMipMapping;
73 
74     // Parameters for an GPU offscreen resource exposed as a GrBackendRenderTarget
75     int         fOffScreenWidth;
76     int         fOffScreenHeight;
77     int         fOffScreenSampleCount;
78     // TODO: should we also expose stencilBits here? How about the config?
79 
80     GrMipMapped fOffScreenMipMapping; // only applicable if the offscreen is also textureable
81 };
82 
83 extern DrawOptions GetDrawOptions();
84 extern void SkDebugf(const char * format, ...);
85 extern void draw(SkCanvas*);
86 
87 // There are different implementations of create_grcontext() for EGL, Mesa,
88 // and a fallback to a null context.
89 extern sk_sp<GrContext> create_grcontext(std::ostringstream &driverinfo);
90 
91 #endif  // fiddle_main_DEFINED
92