Flutter Engine
The Flutter Engine
Surface_MakeRenderTarget_2.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.
4REG_FIDDLE(Surface_MakeRenderTarget_2, 256, 256, false, 0) {
5void draw(SkCanvas* canvas) {
6 auto test_draw = [](SkCanvas* surfaceCanvas) -> void {
7 SkFont font(fontMgr->matchFamilyStyle(nullptr, {}), 32);
8
10 paint.setAntiAlias(true);
11 // TODO: where did this setting go?
12 //paint.setLCDRenderText(true);
13 paint.setColor(0xFFBBBBBB);
14
15 surfaceCanvas->drawRect(SkRect::MakeWH(128, 64), paint);
16 paint.setColor(SK_ColorWHITE);
17 surfaceCanvas->drawString("Text", 0, 25, font, paint);
18 };
19 auto context = canvas->recordingContext();
21 int y = 0;
22 for (auto geometry : { kRGB_H_SkPixelGeometry, kBGR_H_SkPixelGeometry,
24 SkSurfaceProps props(0, geometry);
26 context ? SkSurfaces::RenderTarget(context, skgpu::Budgeted::kNo, info, 0, &props)
27 : SkSurfaces::Raster(info, &props);
28 test_draw(surface->getCanvas());
29 surface->draw(canvas, 0, y);
30 sk_sp<SkImage> image(surface->makeImageSnapshot());
31 SkAutoCanvasRestore acr(canvas, true);
32 canvas->scale(8, 8);
33 canvas->drawImage(image, 12, y / 8);
34 y += 64;
35 }
36}
37} // 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
@ kRGB_V_SkPixelGeometry
@ kBGR_H_SkPixelGeometry
@ kRGB_H_SkPixelGeometry
@ kBGR_V_SkPixelGeometry
REG_FIDDLE(Surface_MakeRenderTarget_2, 256, 256, false, 0)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
virtual GrRecordingContext * recordingContext() const
Definition: SkCanvas.cpp:1637
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
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
VkSurfaceKHR surface
Definition: main.cc:49
sk_sp< SkFontMgr > fontMgr
Definition: examples.cpp:32
double y
sk_sp< const SkImage > image
Definition: SkRecords.h:269
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
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)
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609
static void test_draw(SkCanvas *canvas, const char label[])
Definition: surface.cpp:72