Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
examples.cpp
Go to the documentation of this file.
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
5
7
8// These globals are needed by fiddles:
14double duration = 1.0;
15double frame = 1.0;
16
17int main() {
18 constexpr int kImgCount = 7;
19 sk_sp<SkImage> images[kImgCount];
20 SkBitmap bitmaps[kImgCount];
21 for (int i = 1; i < kImgCount; ++i) {
22 SkString path = SkStringPrintf("resources/images/example_%d.png", i);
24 SkAssertResult(images[i] && images[i]->asLegacyBitmap(&bitmaps[i]));
25 }
27 SkASSERT((unsigned)example.fImageIndex < (unsigned)kImgCount);
28 image = images[example.fImageIndex];
29 source = bitmaps[example.fImageIndex];
30 SkBitmap bmp;
31 bmp.allocN32Pixels(example.fWidth, example.fHeight);
33 SkCanvas canvas(bmp);
34 SkDebugf("==> %s\n", example.fName);
35 example.fFunc(&canvas);
36 }
37}
#define SkAssertResult(cond)
Definition: SkAssert.h:107
#define SkASSERT(cond)
Definition: SkAssert.h:100
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
SkString static SkString SkStringPrintf()
Definition: SkString.h:287
void allocN32Pixels(int width, int height, bool isOpaque=false)
Definition: SkBitmap.cpp:226
void eraseColor(SkColor4f) const
Definition: SkBitmap.cpp:436
static sk_sp< SkData > MakeFromFileName(const char path[])
Definition: SkData.cpp:148
GrBackendTexture backEndTextureRenderTarget
Definition: examples.cpp:11
sk_sp< SkImage > image
Definition: examples.cpp:13
SkBitmap source
Definition: examples.cpp:12
GrBackendRenderTarget backEndRenderTarget
Definition: examples.cpp:10
GrBackendTexture backEndTexture
Definition: examples.cpp:9
double duration
Definition: examples.cpp:14
int main()
Definition: examples.cpp:17
double frame
Definition: examples.cpp:15
SK_API sk_sp< SkImage > DeferredFromEncodedData(sk_sp< SkData > encoded, std::optional< SkAlphaType > alphaType=std::nullopt)