Home | History | Annotate | Download | only in core
      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  */
      7 #ifndef SkPictureImageGenerator_DEFINED
      8 #define SkPictureImageGenerator_DEFINED
      9 
     10 #include "SkImageGenerator.h"
     11 #include "SkTLazy.h"
     12 
     13 class SkPictureImageGenerator : public SkImageGenerator {
     14 public:
     15     static std::unique_ptr<SkImageGenerator> Make(const SkISize&, sk_sp<SkPicture>, const SkMatrix*,
     16                                                   const SkPaint*, SkImage::BitDepth,
     17                                                   sk_sp<SkColorSpace>);
     18 
     19 protected:
     20     bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options& opts)
     21                      override;
     22 
     23 #if SK_SUPPORT_GPU
     24     TexGenType onCanGenerateTexture() const override { return TexGenType::kExpensive; }
     25     sk_sp<GrTextureProxy> onGenerateTexture(GrContext*, const SkImageInfo&, const SkIPoint&,
     26                                             SkTransferFunctionBehavior) override;
     27 #endif
     28 
     29 private:
     30     SkPictureImageGenerator(const SkImageInfo& info, sk_sp<SkPicture>, const SkMatrix*,
     31                             const SkPaint*);
     32 
     33     sk_sp<SkPicture>    fPicture;
     34     SkMatrix            fMatrix;
     35     SkTLazy<SkPaint>    fPaint;
     36 
     37     typedef SkImageGenerator INHERITED;
     38 };
     39 #endif  // SkPictureImageGenerator_DEFINED
     40