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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 6 | #include "tools/Registry.h" |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 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; |
Hal Canary | 8800042 | 2020-01-15 11:51:12 -0500 | [diff] [blame^] | 19 | double fAnimationDuration; |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 20 | bool fText; |
| 21 | bool fSRGB; |
| 22 | bool fF16; |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 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 | |
Hal Canary | 8800042 | 2020-01-15 11:51:12 -0500 | [diff] [blame^] | 35 | #define REG_FIDDLE_ANIMATED(NAME, W, H, TEXT, I, DURATION) \ |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 36 | namespace example_##NAME { void draw(SkCanvas*); } \ |
| 37 | sk_tools::Registry<fiddle::Example> reg_##NAME( \ |
Hal Canary | 8800042 | 2020-01-15 11:51:12 -0500 | [diff] [blame^] | 38 | fiddle::Example{&example_##NAME::draw, #NAME, I, W, H, DURATION, TEXT, \ |
| 39 | false, false, false}); \ |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 40 | namespace example_##NAME |
| 41 | |
Hal Canary | 8800042 | 2020-01-15 11:51:12 -0500 | [diff] [blame^] | 42 | #define REG_FIDDLE(NAME, W, H, TEXT, I) \ |
| 43 | REG_FIDDLE_ANIMATED(NAME, W, H, TEXT, I, 0) |
| 44 | |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 45 | #endif // examples_DEFINED |