Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 5 of file Image_refEncodedData.cpp.

5 {
6void draw(SkCanvas* canvas) {
7 auto dContext = GrAsDirectContext(canvas->recordingContext());
8 if (!dContext) {
9 return;
10 }
11
12 struct {
13 const char* name;
15 } tests[] = {{"image", image},
16 {"bitmap", source.asImage()},
17 {"texture",
23 nullptr)}};
24 SkString string;
26 SkFont font = SkFont(fontMgr->matchFamilyStyle(nullptr, {}));
27
28 for (const auto& test : tests ) {
29 if (!test.image) {
30 string.printf("no %s", test.name);
31 } else {
32 string.printf("%s" "encoded %s", test.image->refEncodedData() ? "" : "no ", test.name);
33 }
34 canvas->drawString(string, 10, 20, font, paint);
35 canvas->translate(0, 20);
36 }
37}
38} // 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)
virtual GrRecordingContext * recordingContext() const
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
const Paint & paint
sk_sp< SkFontMgr > fontMgr
Definition examples.cpp:32
sk_sp< SkImage > image
Definition examples.cpp:29
SkBitmap source
Definition examples.cpp:28
GrBackendTexture backEndTexture
Definition examples.cpp:25
const char * name
Definition fuchsia.cc:50
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)
font
Font Metadata and Metrics.