Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Image_isLazyGenerated_a.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=a8b8bd4bfe968e2c63085f867665227f
5REG_FIDDLE(Image_isLazyGenerated_a, 256, 80, false, 0) {
7public:
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
#define REG_FIDDLE(NAME, W, H, TEXT, I)
Definition examples.h:60
double y
double x
SK_API sk_sp< SkImage > DeferredFromGenerator(std::unique_ptr< SkImageGenerator > imageGenerator)
Definition gen.py:1
static SkImageInfo MakeN32Premul(int width, int height)