Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 1 | #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 Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 4 | #include "tools/fiddle/examples.h" |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 5 | // HASH=a8b8bd4bfe968e2c63085f867665227f |
Hal Canary | a7181e7c | 2019-03-18 16:06:34 -0400 | [diff] [blame] | 6 | REG_FIDDLE(Image_isLazyGenerated_a, 256, 80, false, 0) { |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 7 | class TestImageGenerator : public SkImageGenerator { |
| 8 | public: |
| 9 | TestImageGenerator() : SkImageGenerator(SkImageInfo::MakeN32Premul(10, 10)) {} |
| 10 | ~TestImageGenerator() override {} |
| 11 | protected: |
| 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 | |
| 24 | void 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. |