blob: 304f01926d783ad704cfcff20882a3fe50a90009 [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
Mike Kleinc0bd9f92019-04-23 12:05:21 -05006#include "tools/Registry.h"
Hal Canary87515122019-03-15 14:22:51 -04007#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;
Hal Canary88000422020-01-15 11:51:12 -050019 double fAnimationDuration;
Hal Canary87515122019-03-15 14:22:51 -040020 bool fText;
21 bool fSRGB;
22 bool fF16;
Hal Canary87515122019-03-15 14:22:51 -040023 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
Hal Canary88000422020-01-15 11:51:12 -050035#define REG_FIDDLE_ANIMATED(NAME, W, H, TEXT, I, DURATION) \
Hal Canary87515122019-03-15 14:22:51 -040036 namespace example_##NAME { void draw(SkCanvas*); } \
37 sk_tools::Registry<fiddle::Example> reg_##NAME( \
Hal Canary88000422020-01-15 11:51:12 -050038 fiddle::Example{&example_##NAME::draw, #NAME, I, W, H, DURATION, TEXT, \
39 false, false, false}); \
Hal Canary87515122019-03-15 14:22:51 -040040 namespace example_##NAME
41
Hal Canary88000422020-01-15 11:51:12 -050042#define REG_FIDDLE(NAME, W, H, TEXT, I) \
43 REG_FIDDLE_ANIMATED(NAME, W, H, TEXT, I, 0)
44
Hal Canary87515122019-03-15 14:22:51 -040045#endif // examples_DEFINED