blob: ca41998cbafb34e7b0eedfe152ebc87a6da5741e [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 Gregorio8e9810c2018-05-29 13:56:27 -040023#include <memory>
Joe Gregorio97b10ac2017-06-01 13:24:11 -040024#include <sstream>
25
Robert Phillips57e08282017-11-16 14:59:48 -050026extern GrBackendTexture backEndTexture;
27extern GrBackendRenderTarget backEndRenderTarget;
28extern GrBackendTexture backEndTextureRenderTarget;
halcanarydecb21e2015-12-10 07:52:45 -080029extern SkBitmap source;
halcanary7b8b2372016-04-18 08:17:56 -070030extern sk_sp<SkImage> image;
Joe Gregorio1e735c02017-04-19 14:05:14 -040031extern double duration; // The total duration of the animation in seconds.
32extern double frame; // A value in [0, 1] of where we are in the animation.
halcanarydecb21e2015-12-10 07:52:45 -080033
Joe Gregorio8e9810c2018-05-29 13:56:27 -040034namespace sk_gpu_test {
35class GLTestContext;
36}
37
halcanarydecb21e2015-12-10 07:52:45 -080038struct DrawOptions {
Robert Phillipsc34aa9d2017-11-17 14:59:43 -050039 DrawOptions(int w, int h, bool r, bool g, bool p, bool k, bool srgb, bool f16,
40 bool textOnly, const char* s,
41 GrMipMapped mipMapping,
42 int offScreenWidth,
43 int offScreenHeight,
44 int offScreenSampleCount,
45 GrMipMapped offScreenMipMapping)
halcanarydecb21e2015-12-10 07:52:45 -080046 : size(SkISize::Make(w, h))
47 , raster(r)
48 , gpu(g)
49 , pdf(p)
50 , skp(k)
Matt Saretta2f71262016-11-29 17:14:58 -050051 , srgb(srgb)
52 , f16(f16)
Joe Gregorio1fd18232017-02-13 11:39:43 -050053 , textOnly(textOnly)
Matt Saretta2f71262016-11-29 17:14:58 -050054 , source(s)
Robert Phillipsc34aa9d2017-11-17 14:59:43 -050055 , fMipMapping(mipMapping)
56 , fOffScreenWidth(offScreenWidth)
57 , fOffScreenHeight(offScreenHeight)
58 , fOffScreenSampleCount(offScreenSampleCount)
59 , fOffScreenMipMapping(offScreenMipMapping) {
Matt Saretta2f71262016-11-29 17:14:58 -050060 // F16 mode is only valid for color correct backends.
61 SkASSERT(srgb || !f16);
62 }
halcanarydecb21e2015-12-10 07:52:45 -080063 SkISize size;
64 bool raster;
65 bool gpu;
66 bool pdf;
67 bool skp;
Matt Saretta2f71262016-11-29 17:14:58 -050068 bool srgb;
69 bool f16;
Joe Gregorio1fd18232017-02-13 11:39:43 -050070 bool textOnly;
halcanarydecb21e2015-12-10 07:52:45 -080071 const char* source;
Robert Phillipsc34aa9d2017-11-17 14:59:43 -050072
73 // This flag is used when a GPU texture resource is created and exposed as a GrBackendTexture.
74 // In this case the resource is created with extra room to accomodate mipmaps.
75 // TODO: The SkImage::makeTextureImage API would need to be widened to allow this to be true
76 // for the non-backend gpu SkImages.
77 GrMipMapped fMipMapping;
78
79 // Parameters for an GPU offscreen resource exposed as a GrBackendRenderTarget
80 int fOffScreenWidth;
81 int fOffScreenHeight;
82 int fOffScreenSampleCount;
83 // TODO: should we also expose stencilBits here? How about the config?
84
85 GrMipMapped fOffScreenMipMapping; // only applicable if the offscreen is also textureable
halcanarydecb21e2015-12-10 07:52:45 -080086};
87
88extern DrawOptions GetDrawOptions();
Joe Gregorio1fd18232017-02-13 11:39:43 -050089extern void SkDebugf(const char * format, ...);
halcanarydecb21e2015-12-10 07:52:45 -080090extern void draw(SkCanvas*);
91
Joe Gregorioa8fabd32017-05-31 09:45:19 -040092// There are different implementations of create_grcontext() for EGL, Mesa,
93// and a fallback to a null context.
Joe Gregorio8e9810c2018-05-29 13:56:27 -040094extern sk_sp<GrContext> create_grcontext(std::ostringstream& driverinfo,
95 std::unique_ptr<sk_gpu_test::GLTestContext>* glContext);
Joe Gregorioa8fabd32017-05-31 09:45:19 -040096
halcanarydecb21e2015-12-10 07:52:45 -080097#endif // fiddle_main_DEFINED