Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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,
29 skgpu::Mipmapped::kYes,
30 64,
31 64,
32 0,
33 skgpu::Mipmapped::kYes);
34}
35void draw(SkCanvas* canvas) {
36 canvas->clear(SK_ColorWHITE);
37 SkMatrix matrix;
38 matrix.setScale(0.75f, 0.75f);
39 matrix.preRotate(frame * 30.0f * duration); // If an animation, rotate at 30 deg/s.
42 SkSamplingOptions(), matrix));
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
void drawPaint(const SkPaint &paint)
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
DrawOptions GetDrawOptions()
Definition draw.cpp:16
void draw(SkCanvas *canvas)
Definition draw.cpp:35
GrBackendTexture backEndTextureRenderTarget
Definition examples.cpp:27
sk_sp< SkImage > image
Definition examples.cpp:29
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)
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)