Matt Sarett | 9df70bb | 2017-02-14 13:50:43 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
Hal Canary | 08f14bd | 2017-02-14 16:57:42 -0500 | [diff] [blame] | 7 | #ifndef SkPictureImageGenerator_DEFINED |
| 8 | #define SkPictureImageGenerator_DEFINED |
Matt Sarett | 9df70bb | 2017-02-14 13:50:43 -0500 | [diff] [blame] | 9 | |
| 10 | #include "SkImageGenerator.h" |
| 11 | #include "SkTLazy.h" |
| 12 | |
Mike Reed | 185130c | 2017-02-15 15:14:16 -0500 | [diff] [blame] | 13 | class SkPictureImageGenerator : public SkImageGenerator { |
Matt Sarett | 9df70bb | 2017-02-14 13:50:43 -0500 | [diff] [blame] | 14 | public: |
Mike Reed | 185130c | 2017-02-15 15:14:16 -0500 | [diff] [blame] | 15 | static std::unique_ptr<SkImageGenerator> Make(const SkISize&, sk_sp<SkPicture>, const SkMatrix*, |
| 16 | const SkPaint*, SkImage::BitDepth, |
| 17 | sk_sp<SkColorSpace>); |
Matt Sarett | 9df70bb | 2017-02-14 13:50:43 -0500 | [diff] [blame] | 18 | |
| 19 | protected: |
Matt Sarett | 71f9df2 | 2017-04-21 11:42:00 -0400 | [diff] [blame] | 20 | bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options& opts) |
| 21 | override; |
Matt Sarett | 9df70bb | 2017-02-14 13:50:43 -0500 | [diff] [blame] | 22 | |
| 23 | #if SK_SUPPORT_GPU |
Stan Iliev | ba81af2 | 2017-06-08 15:16:53 -0400 | [diff] [blame] | 24 | TexGenType onCanGenerateTexture() const override { return TexGenType::kExpensive; } |
Christopher Cameron | 77e9666 | 2017-07-08 01:47:47 -0700 | [diff] [blame] | 25 | sk_sp<GrTextureProxy> onGenerateTexture(GrContext*, const SkImageInfo&, const SkIPoint&, |
| 26 | SkTransferFunctionBehavior) override; |
Matt Sarett | 9df70bb | 2017-02-14 13:50:43 -0500 | [diff] [blame] | 27 | #endif |
| 28 | |
| 29 | private: |
Mike Reed | 185130c | 2017-02-15 15:14:16 -0500 | [diff] [blame] | 30 | SkPictureImageGenerator(const SkImageInfo& info, sk_sp<SkPicture>, const SkMatrix*, |
Matt Sarett | 9df70bb | 2017-02-14 13:50:43 -0500 | [diff] [blame] | 31 | const SkPaint*); |
| 32 | |
Mike Reed | 185130c | 2017-02-15 15:14:16 -0500 | [diff] [blame] | 33 | sk_sp<SkPicture> fPicture; |
| 34 | SkMatrix fMatrix; |
| 35 | SkTLazy<SkPaint> fPaint; |
Matt Sarett | 9df70bb | 2017-02-14 13:50:43 -0500 | [diff] [blame] | 36 | |
| 37 | typedef SkImageGenerator INHERITED; |
| 38 | }; |
Hal Canary | 08f14bd | 2017-02-14 16:57:42 -0500 | [diff] [blame] | 39 | #endif // SkPictureImageGenerator_DEFINED |