blob: 70927b8f87752ee59e004c682de9682a89684ff5 [file] [log] [blame]
Hal Canary87515122019-03-15 14:22:51 -04001// 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
12namespace fiddle {
13struct 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
27extern GrBackendTexture backEndTexture;
28extern GrBackendRenderTarget backEndRenderTarget;
29extern GrBackendTexture backEndTextureRenderTarget;
30extern SkBitmap source;
31extern sk_sp<SkImage> image;
32extern double duration; // The total duration of the animation in seconds.
33extern 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