Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Image_refEncodedData.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.
4// HASH=80856fe921ce36f8d5a32d8672bccbfc
5REG_FIDDLE(Image_refEncodedData, 256, 256, false, 3) {
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
#define REG_FIDDLE(NAME, W, H, TEXT, I)
Definition examples.h:60
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)