blob: 5492a424ea70f8ea107fbf0ce0d358dcff80530f [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
Robert Phillips57e08282017-11-16 14:59:48 -050025extern GrBackendTexture backEndTexture;
26extern GrBackendRenderTarget backEndRenderTarget;
27extern GrBackendTexture backEndTextureRenderTarget;
halcanarydecb21e2015-12-10 07:52:45 -080028extern SkBitmap source;
halcanary7b8b2372016-04-18 08:17:56 -070029extern sk_sp<SkImage> image;
Joe Gregorio1e735c02017-04-19 14:05:14 -040030extern double duration; // The total duration of the animation in seconds.
31extern double frame; // A value in [0, 1] of where we are in the animation.
halcanarydecb21e2015-12-10 07:52:45 -080032
33struct DrawOptions {
Robert Phillipsc34aa9d2017-11-17 14:59:43 -050034 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)
halcanarydecb21e2015-12-10 07:52:45 -080041 : size(SkISize::Make(w, h))
42 , raster(r)
43 , gpu(g)
44 , pdf(p)
45 , skp(k)
Matt Saretta2f71262016-11-29 17:14:58 -050046 , srgb(srgb)
47 , f16(f16)
Joe Gregorio1fd18232017-02-13 11:39:43 -050048 , textOnly(textOnly)
Matt Saretta2f71262016-11-29 17:14:58 -050049 , source(s)
Robert Phillipsc34aa9d2017-11-17 14:59:43 -050050 , fMipMapping(mipMapping)
51 , fOffScreenWidth(offScreenWidth)
52 , fOffScreenHeight(offScreenHeight)
53 , fOffScreenSampleCount(offScreenSampleCount)
54 , fOffScreenMipMapping(offScreenMipMapping) {
Matt Saretta2f71262016-11-29 17:14:58 -050055 // F16 mode is only valid for color correct backends.
56 SkASSERT(srgb || !f16);
57 }
halcanarydecb21e2015-12-10 07:52:45 -080058 SkISize size;
59 bool raster;
60 bool gpu;
61 bool pdf;
62 bool skp;
Matt Saretta2f71262016-11-29 17:14:58 -050063 bool srgb;
64 bool f16;
Joe Gregorio1fd18232017-02-13 11:39:43 -050065 bool textOnly;
halcanarydecb21e2015-12-10 07:52:45 -080066 const char* source;
Robert Phillipsc34aa9d2017-11-17 14:59:43 -050067
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
halcanarydecb21e2015-12-10 07:52:45 -080081};
82
83extern DrawOptions GetDrawOptions();
Joe Gregorio1fd18232017-02-13 11:39:43 -050084extern void SkDebugf(const char * format, ...);
halcanarydecb21e2015-12-10 07:52:45 -080085extern void draw(SkCanvas*);
86
Joe Gregorioa8fabd32017-05-31 09:45:19 -040087// There are different implementations of create_grcontext() for EGL, Mesa,
88// and a fallback to a null context.
Joe Gregorio97b10ac2017-06-01 13:24:11 -040089extern sk_sp<GrContext> create_grcontext(std::ostringstream &driverinfo);
Joe Gregorioa8fabd32017-05-31 09:45:19 -040090
halcanarydecb21e2015-12-10 07:52:45 -080091#endif // fiddle_main_DEFINED