blob: e3cf9cd5fcd9fd3a4a5a475138496c930efec3c8 [file] [log] [blame]
Hal Canary87515122019-03-15 14:22:51 -04001#if 0 // Disabled until updated to use current API.
2// Copyright 2019 Google LLC.
3// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Mike Kleinc0bd9f92019-04-23 12:05:21 -05004#include "tools/fiddle/examples.h"
Hal Canary87515122019-03-15 14:22:51 -04005// HASH=a8b8bd4bfe968e2c63085f867665227f
Hal Canarya7181e7c2019-03-18 16:06:34 -04006REG_FIDDLE(Image_isLazyGenerated_a, 256, 80, false, 0) {
Hal Canary87515122019-03-15 14:22:51 -04007class TestImageGenerator : public SkImageGenerator {
8public:
9 TestImageGenerator() : SkImageGenerator(SkImageInfo::MakeN32Premul(10, 10)) {}
10 ~TestImageGenerator() override {}
11protected:
12 bool onGetPixels(const SkImageInfo& info, void* pixelPtr, size_t rowBytes,
13 const Options& options) override {
14 SkPMColor* pixels = static_cast<SkPMColor*>(pixelPtr);
15 for (int y = 0; y < info.height(); ++y) {
16 for (int x = 0; x < info.width(); ++x) {
17 pixels[y * info.width() + x] = 0xff223344 + y * 0x000C0811;
18 }
19 }
20 return true;
21 }
22};
23
24void draw(SkCanvas* canvas) {
25 auto gen = std::unique_ptr<TestImageGenerator>(new TestImageGenerator());
26 sk_sp<SkImage> image(SkImage::MakeFromGenerator(std::move(gen)));
27 SkString lazy(image->isLazyGenerated() ? "is lazy" : "not lazy");
28 canvas->scale(8, 8);
29 canvas->drawImage(image, 0, 0, nullptr);
30 SkPaint paint;
31 paint.setTextSize(4);
32 canvas->drawString(lazy, 2, 5, paint);
33}
34} // END FIDDLE
35#endif // Disabled until updated to use current API.