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

5 {
7public:
8 TestImageGenerator() : SkImageGenerator(SkImageInfo::MakeN32Premul(10, 10)) {}
9 ~TestImageGenerator() override {}
10protected:
11 bool onGetPixels(const SkImageInfo& info, void* pixelPtr, size_t rowBytes,
12 const Options& options) override {
13 SkPMColor* pixels = static_cast<SkPMColor*>(pixelPtr);
14 for (int y = 0; y < info.height(); ++y) {
15 for (int x = 0; x < info.width(); ++x) {
16 pixels[y * info.width() + x] = 0xff223344 + y * 0x000C0811;
17 }
18 }
19 return true;
20 }
21};
22
23void draw(SkCanvas* canvas) {
24 auto gen = std::unique_ptr<TestImageGenerator>(new TestImageGenerator());
26 SkString lazy(image->isLazyGenerated() ? "is lazy" : "not lazy");
27 canvas->scale(8, 8);
28 canvas->drawImage(image, 0, 0);
29 SkFont font = SkFont(fontMgr->matchFamilyStyle(nullptr, {}), 4);
31 canvas->drawString(lazy, 2, 5, font, paint);
32}
33} // 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)
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
virtual bool isLazyGenerated() const =0
bool onGetPixels(const SkImageInfo &info, void *pixels, size_t rowBytes, const Options &options) override
const Paint & paint
sk_sp< SkFontMgr > fontMgr
Definition examples.cpp:32
sk_sp< SkImage > image
Definition examples.cpp:29
double y
double x
SK_API sk_sp< SkImage > DeferredFromGenerator(std::unique_ptr< SkImageGenerator > imageGenerator)
font
Font Metadata and Metrics.
Definition gen.py:1