blob: f2ebc809c945b961d2c23ea6ec1df118679850cf [file] [log] [blame]
Matt Sarett9df70bb2017-02-14 13:50:43 -05001/*
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 Canary08f14bd2017-02-14 16:57:42 -05007#ifndef SkPictureImageGenerator_DEFINED
8#define SkPictureImageGenerator_DEFINED
Matt Sarett9df70bb2017-02-14 13:50:43 -05009
10#include "SkImageGenerator.h"
11#include "SkTLazy.h"
12
Mike Reed185130c2017-02-15 15:14:16 -050013class SkPictureImageGenerator : public SkImageGenerator {
Matt Sarett9df70bb2017-02-14 13:50:43 -050014public:
Mike Reed185130c2017-02-15 15:14:16 -050015 static std::unique_ptr<SkImageGenerator> Make(const SkISize&, sk_sp<SkPicture>, const SkMatrix*,
16 const SkPaint*, SkImage::BitDepth,
17 sk_sp<SkColorSpace>);
Matt Sarett9df70bb2017-02-14 13:50:43 -050018
19protected:
Matt Sarett71f9df22017-04-21 11:42:00 -040020 bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options& opts)
21 override;
Matt Sarett9df70bb2017-02-14 13:50:43 -050022
23#if SK_SUPPORT_GPU
Stan Ilievba81af22017-06-08 15:16:53 -040024 TexGenType onCanGenerateTexture() const override { return TexGenType::kExpensive; }
Christopher Cameron77e96662017-07-08 01:47:47 -070025 sk_sp<GrTextureProxy> onGenerateTexture(GrContext*, const SkImageInfo&, const SkIPoint&,
26 SkTransferFunctionBehavior) override;
Matt Sarett9df70bb2017-02-14 13:50:43 -050027#endif
28
29private:
Mike Reed185130c2017-02-15 15:14:16 -050030 SkPictureImageGenerator(const SkImageInfo& info, sk_sp<SkPicture>, const SkMatrix*,
Matt Sarett9df70bb2017-02-14 13:50:43 -050031 const SkPaint*);
32
Mike Reed185130c2017-02-15 15:14:16 -050033 sk_sp<SkPicture> fPicture;
34 SkMatrix fMatrix;
35 SkTLazy<SkPaint> fPaint;
Matt Sarett9df70bb2017-02-14 13:50:43 -050036
37 typedef SkImageGenerator INHERITED;
38};
Hal Canary08f14bd2017-02-14 16:57:42 -050039#endif // SkPictureImageGenerator_DEFINED