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

Go to the source code of this file.

Functions

 REG_FIDDLE (Image_isLazyGenerated_a, 256, 80, false, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( Image_isLazyGenerated_a  ,
256  ,
80  ,
false  ,
 
)

Definition at line 4 of file Image_isLazyGenerated_a.cpp.

4 {
6public:
7 TestImageGenerator() : SkImageGenerator(SkImageInfo::MakeN32Premul(10, 10)) {}
8 ~TestImageGenerator() override {}
9protected:
10 bool onGetPixels(const SkImageInfo& info, void* pixelPtr, size_t rowBytes,
11 const Options& options) override {
12 SkPMColor* pixels = static_cast<SkPMColor*>(pixelPtr);
13 for (int y = 0; y < info.height(); ++y) {
14 for (int x = 0; x < info.width(); ++x) {
15 pixels[y * info.width() + x] = 0xff223344 + y * 0x000C0811;
16 }
17 }
18 return true;
19 }
20};
21
22void draw(SkCanvas* canvas) {
23 auto gen = std::unique_ptr<TestImageGenerator>(new TestImageGenerator());
25 SkString lazy(image->isLazyGenerated() ? "is lazy" : "not lazy");
26 canvas->scale(8, 8);
27 canvas->drawImage(image, 0, 0);
28 SkFont font = SkFont(fontMgr->matchFamilyStyle(nullptr, {}), 4);
30 canvas->drawString(lazy, 2, 5, font, paint);
31}
32} // END FIDDLE
const char * options
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
uint32_t SkPMColor
Definition: SkColor.h:205
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
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
virtual bool isLazyGenerated() const =0
TestImageGenerator(TestType type, skiatest::Reporter *reporter, SkColorType colorType=kN32_SkColorType)
bool onGetPixels(const SkImageInfo &info, void *pixels, size_t rowBytes, const Options &options) override
const Paint & paint
Definition: color_source.cc:38
sk_sp< SkFontMgr > fontMgr
Definition: examples.cpp:32
double y
double x
SK_API sk_sp< SkImage > DeferredFromGenerator(std::unique_ptr< SkImageGenerator > imageGenerator)
sk_sp< const SkImage > image
Definition: SkRecords.h:269
font
Font Metadata and Metrics.
Definition: gen.py:1