Flutter Engine
The Flutter Engine
Surface_MakeFromBackendTexture.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_WrapBackendTexture, 256, 256, false, 3) {
5 void draw(SkCanvas * canvas) {
6 SkFont font(fontMgr->matchFamilyStyle(nullptr, {}), 32);
8
9 GrRecordingContext* context = canvas->recordingContext();
10 if (!context) {
11 canvas->drawString("GPU only!", 20, 40, font, paint);
12 return;
13 }
14 GrDirectContext* direct = context->asDirectContext();
15 if (!direct) {
16 canvas->drawString("Direct Context only!", 20, 40, font, paint);
17 return;
18 }
19
23 0,
25 nullptr,
26 nullptr,
27 nullptr);
28 auto surfaceCanvas = gpuSurface->getCanvas();
29 surfaceCanvas->drawString("GPU rocks!", 20, 40, font, paint);
31 canvas->drawImage(image, 0, 0);
32 }
33} // END FIDDLE
@ kTopLeft_GrSurfaceOrigin
Definition: GrTypes.h:148
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
REG_FIDDLE(Surface_WrapBackendTexture, 256, 256, false, 3)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
virtual GrDirectContext * asDirectContext()
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
SkCanvas * getCanvas()
Definition: SkSurface.cpp:82
sk_sp< SkImage > makeImageSnapshot()
Definition: SkSurface.cpp:90
const Paint & paint
Definition: color_source.cc:38
sk_sp< SkFontMgr > fontMgr
Definition: examples.cpp:32
GrBackendTexture backEndTexture
Definition: examples.cpp:25
sk_sp< const SkImage > image
Definition: SkRecords.h:269
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)
font
Font Metadata and Metrics.