Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 1 | // Copyright 2019 Google LLC. |
| 2 | // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. |
| 3 | #ifndef examples_DEFINED |
| 4 | #define examples_DEFINED |
| 5 | |
| 6 | #include "Registry.h" |
| 7 | #include "skia.h" |
| 8 | |
| 9 | #include <cmath> |
| 10 | #include <string> |
| 11 | |
| 12 | namespace fiddle { |
| 13 | struct Example { |
| 14 | void (*fFunc)(SkCanvas*); |
| 15 | const char* fName; |
| 16 | int fImageIndex; |
| 17 | int fWidth; |
| 18 | int fHeight; |
| 19 | bool fText; |
| 20 | bool fSRGB; |
| 21 | bool fF16; |
| 22 | bool fAnimation; |
| 23 | bool fOffscreen; |
| 24 | }; |
| 25 | } |
| 26 | |
| 27 | extern GrBackendTexture backEndTexture; |
| 28 | extern GrBackendRenderTarget backEndRenderTarget; |
| 29 | extern GrBackendTexture backEndTextureRenderTarget; |
| 30 | extern SkBitmap source; |
| 31 | extern sk_sp<SkImage> image; |
| 32 | extern double duration; // The total duration of the animation in seconds. |
| 33 | extern double frame; // A value in [0, 1] of where we are in the animation. |
| 34 | |
| 35 | #define REG_FIDDLE(NAME, W, H, TEXT, I) \ |
| 36 | namespace example_##NAME { void draw(SkCanvas*); } \ |
| 37 | sk_tools::Registry<fiddle::Example> reg_##NAME( \ |
| 38 | fiddle::Example{&example_##NAME::draw, #NAME, I, W, H, TEXT, false, false, false, false}); \ |
| 39 | namespace example_##NAME |
| 40 | |
| 41 | #endif // examples_DEFINED |