halcanary | decb21e | 2015-12-10 07:52:45 -0800 | [diff] [blame] | 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 | |
halcanary | f0da138 | 2016-04-18 11:50:07 -0700 | [diff] [blame] | 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 |
halcanary | decb21e | 2015-12-10 07:52:45 -0800 | [diff] [blame] | 22 | |
Joe Gregorio | 8e9810c | 2018-05-29 13:56:27 -0400 | [diff] [blame] | 23 | #include <memory> |
Joe Gregorio | 97b10ac | 2017-06-01 13:24:11 -0400 | [diff] [blame] | 24 | #include <sstream> |
| 25 | |
Robert Phillips | 57e0828 | 2017-11-16 14:59:48 -0500 | [diff] [blame] | 26 | extern GrBackendTexture backEndTexture; |
| 27 | extern GrBackendRenderTarget backEndRenderTarget; |
| 28 | extern GrBackendTexture backEndTextureRenderTarget; |
halcanary | decb21e | 2015-12-10 07:52:45 -0800 | [diff] [blame] | 29 | extern SkBitmap source; |
halcanary | 7b8b237 | 2016-04-18 08:17:56 -0700 | [diff] [blame] | 30 | extern sk_sp<SkImage> image; |
Joe Gregorio | 1e735c0 | 2017-04-19 14:05:14 -0400 | [diff] [blame] | 31 | extern double duration; // The total duration of the animation in seconds. |
| 32 | extern double frame; // A value in [0, 1] of where we are in the animation. |
halcanary | decb21e | 2015-12-10 07:52:45 -0800 | [diff] [blame] | 33 | |
Joe Gregorio | 8e9810c | 2018-05-29 13:56:27 -0400 | [diff] [blame] | 34 | namespace sk_gpu_test { |
| 35 | class GLTestContext; |
| 36 | } |
| 37 | |
halcanary | decb21e | 2015-12-10 07:52:45 -0800 | [diff] [blame] | 38 | struct DrawOptions { |
Robert Phillips | c34aa9d | 2017-11-17 14:59:43 -0500 | [diff] [blame] | 39 | 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) |
halcanary | decb21e | 2015-12-10 07:52:45 -0800 | [diff] [blame] | 46 | : size(SkISize::Make(w, h)) |
| 47 | , raster(r) |
| 48 | , gpu(g) |
| 49 | , pdf(p) |
| 50 | , skp(k) |
Matt Sarett | a2f7126 | 2016-11-29 17:14:58 -0500 | [diff] [blame] | 51 | , srgb(srgb) |
| 52 | , f16(f16) |
Joe Gregorio | 1fd1823 | 2017-02-13 11:39:43 -0500 | [diff] [blame] | 53 | , textOnly(textOnly) |
Matt Sarett | a2f7126 | 2016-11-29 17:14:58 -0500 | [diff] [blame] | 54 | , source(s) |
Robert Phillips | c34aa9d | 2017-11-17 14:59:43 -0500 | [diff] [blame] | 55 | , fMipMapping(mipMapping) |
| 56 | , fOffScreenWidth(offScreenWidth) |
| 57 | , fOffScreenHeight(offScreenHeight) |
| 58 | , fOffScreenSampleCount(offScreenSampleCount) |
| 59 | , fOffScreenMipMapping(offScreenMipMapping) { |
Matt Sarett | a2f7126 | 2016-11-29 17:14:58 -0500 | [diff] [blame] | 60 | // F16 mode is only valid for color correct backends. |
| 61 | SkASSERT(srgb || !f16); |
| 62 | } |
halcanary | decb21e | 2015-12-10 07:52:45 -0800 | [diff] [blame] | 63 | SkISize size; |
| 64 | bool raster; |
| 65 | bool gpu; |
| 66 | bool pdf; |
| 67 | bool skp; |
Matt Sarett | a2f7126 | 2016-11-29 17:14:58 -0500 | [diff] [blame] | 68 | bool srgb; |
| 69 | bool f16; |
Joe Gregorio | 1fd1823 | 2017-02-13 11:39:43 -0500 | [diff] [blame] | 70 | bool textOnly; |
halcanary | decb21e | 2015-12-10 07:52:45 -0800 | [diff] [blame] | 71 | const char* source; |
Robert Phillips | c34aa9d | 2017-11-17 14:59:43 -0500 | [diff] [blame] | 72 | |
| 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 |
halcanary | decb21e | 2015-12-10 07:52:45 -0800 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | extern DrawOptions GetDrawOptions(); |
Joe Gregorio | 1fd1823 | 2017-02-13 11:39:43 -0500 | [diff] [blame] | 89 | extern void SkDebugf(const char * format, ...); |
halcanary | decb21e | 2015-12-10 07:52:45 -0800 | [diff] [blame] | 90 | extern void draw(SkCanvas*); |
| 91 | |
Joe Gregorio | a8fabd3 | 2017-05-31 09:45:19 -0400 | [diff] [blame] | 92 | // There are different implementations of create_grcontext() for EGL, Mesa, |
| 93 | // and a fallback to a null context. |
Joe Gregorio | 8e9810c | 2018-05-29 13:56:27 -0400 | [diff] [blame] | 94 | extern sk_sp<GrContext> create_grcontext(std::ostringstream& driverinfo, |
| 95 | std::unique_ptr<sk_gpu_test::GLTestContext>* glContext); |
Joe Gregorio | a8fabd3 | 2017-05-31 09:45:19 -0400 | [diff] [blame] | 96 | |
halcanary | decb21e | 2015-12-10 07:52:45 -0800 | [diff] [blame] | 97 | #endif // fiddle_main_DEFINED |