Flutter Engine
The Flutter Engine
draw.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8// This is an example of the translation unit that needs to be
9// assembled by the fiddler program to compile into a fiddle: an
10// implementation of the GetDrawOptions() and draw() functions.
11
15
17 // path *should* be absolute.
18 static const char path[] = "resources/images/color_wheel.png";
19 return DrawOptions(256,
20 256,
21 true,
22 true,
23 true,
24 true,
25 true,
26 false,
27 false,
28 path,
30 64,
31 64,
32 0,
34}
35void draw(SkCanvas* canvas) {
36 canvas->clear(SK_ColorWHITE);
38 matrix.setScale(0.75f, 0.75f);
39 matrix.preRotate(frame * 30.0f * duration); // If an animation, rotate at 30 deg/s.
43 canvas->drawPaint(paint);
44 SkDebugf("This is text output: %d", 2);
45
46 if (auto dContext = GrAsDirectContext(canvas->recordingContext())) {
52 nullptr);
53
54 constexpr int kSampleCnt = 0;
58 kSampleCnt,
60 nullptr,
61 nullptr);
62
63 // Note: this surface should only be renderable (i.e., not textureable)
68 nullptr,
69 nullptr);
70 }
71}
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
@ kTopLeft_GrSurfaceOrigin
Definition: GrTypes.h:148
@ kOpaque_SkAlphaType
pixel is opaque
Definition: SkAlphaType.h:28
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
virtual GrRecordingContext * recordingContext() const
Definition: SkCanvas.cpp:1637
void drawPaint(const SkPaint &paint)
Definition: SkCanvas.cpp:1668
void clear(SkColor color)
Definition: SkCanvas.h:1199
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition: SkImage.cpp:179
const Paint & paint
Definition: color_source.cc:38
DrawOptions GetDrawOptions()
Definition: draw.cpp:16
void draw(SkCanvas *canvas)
Definition: draw.cpp:35
GrBackendTexture backEndTextureRenderTarget
Definition: examples.cpp:27
GrBackendRenderTarget backEndRenderTarget
Definition: examples.cpp:26
GrBackendTexture backEndTexture
Definition: examples.cpp:25
double duration
Definition: examples.cpp:30
double frame
Definition: examples.cpp:31
SK_API sk_sp< SkImage > BorrowTextureFrom(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, SkColorType colorType, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
sk_sp< const SkImage > image
Definition: SkRecords.h:269
SK_API sk_sp< SkSurface > WrapBackendRenderTarget(GrRecordingContext *context, const GrBackendRenderTarget &backendRenderTarget, GrSurfaceOrigin origin, SkColorType colorType, sk_sp< SkColorSpace > colorSpace, const SkSurfaceProps *surfaceProps, RenderTargetReleaseProc releaseProc=nullptr, ReleaseContext releaseContext=nullptr)
SK_API sk_sp< SkSurface > WrapBackendTexture(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, int sampleCnt, SkColorType colorType, sk_sp< SkColorSpace > colorSpace, const SkSurfaceProps *surfaceProps, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57