Flutter Engine
The Flutter Engine
Functions
Surface_MakeRenderTarget_3.cpp File Reference
#include "tools/fiddle/examples.h"

Go to the source code of this file.

Functions

 REG_FIDDLE (Surface_MakeRenderTarget_3, 256, 256, false, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( Surface_MakeRenderTarget_3  ,
256  ,
256  ,
false  ,
 
)

Definition at line 4 of file Surface_MakeRenderTarget_3.cpp.

4 {
5void draw(SkCanvas* canvas) {
6 SkFont font(fontMgr->matchFamilyStyle(nullptr, {}), 32);
8 auto context = canvas->recordingContext();
9 if (!context) {
10 canvas->drawString("GPU only!", 20, 40, font, paint);
11 return;
12 }
14 auto gpuSurface(SkSurfaces::RenderTarget(context, skgpu::Budgeted::kNo, info));
15 auto surfaceCanvas = gpuSurface->getCanvas();
16 surfaceCanvas->clear(SK_ColorWHITE);
17 surfaceCanvas->drawString("GPU rocks!", 20, 40, font, paint);
18 sk_sp<SkImage> image(gpuSurface->makeImageSnapshot());
19 canvas->drawImage(image, 0, 0);
20}
21} // END FIDDLE
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
@ kOpaque_SkAlphaType
pixel is opaque
Definition: SkAlphaType.h:28
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
virtual GrRecordingContext * recordingContext() const
Definition: SkCanvas.cpp:1637
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition: SkCanvas.h:1803
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
sk_sp< SkTypeface > matchFamilyStyle(const char familyName[], const SkFontStyle &) const
Definition: SkFontMgr.cpp:109
Definition: SkFont.h:35
const Paint & paint
Definition: color_source.cc:38
sk_sp< SkFontMgr > fontMgr
Definition: examples.cpp:32
sk_sp< const SkImage > image
Definition: SkRecords.h:269
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
font
Font Metadata and Metrics.
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)