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

Go to the source code of this file.

Functions

 REG_FIDDLE (Image_refEncodedData, 256, 256, false, 3)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( Image_refEncodedData  ,
256  ,
256  ,
false  ,
 
)

Definition at line 4 of file Image_refEncodedData.cpp.

4 {
5void draw(SkCanvas* canvas) {
6 auto dContext = GrAsDirectContext(canvas->recordingContext());
7 if (!dContext) {
8 return;
9 }
10
11 struct {
12 const char* name;
14 } tests[] = {{"image", image},
15 {"bitmap", source.asImage()},
16 {"texture",
22 nullptr)}};
23 SkString string;
25 SkFont font = SkFont(fontMgr->matchFamilyStyle(nullptr, {}));
26
27 for (const auto& test : tests ) {
28 if (!test.image) {
29 string.printf("no %s", test.name);
30 } else {
31 string.printf("%s" "encoded %s", test.image->refEncodedData() ? "" : "no ", test.name);
32 }
33 canvas->drawString(string, 10, 20, font, paint);
34 canvas->translate(0, 20);
35 }
36}
37} // END FIDDLE
static BlurTest tests[]
Definition: BlurTest.cpp:84
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
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
sk_sp< SkImage > asImage() const
Definition: SkBitmap.cpp:645
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
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
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
SkBitmap source
Definition: examples.cpp:28
GrBackendTexture backEndTexture
Definition: examples.cpp:25
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_sp< const SkImage > image
Definition: SkRecords.h:269
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
font
Font Metadata and Metrics.