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. 4#include "tools/fiddle/examples.h" 5// HASH=a8b8bd4bfe968e2c63085f867665227f 6REG_FIDDLE(Image_isLazyGenerated_a, 256, 80, false, 0) { 7class 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. 36