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,
     27                                             bool willNeedMipMaps) override;
     28 #endif
     29 
     30 private:
     31     SkPictureImageGenerator(const SkImageInfo& info, sk_sp<SkPicture>, const SkMatrix*,
     32                             const SkPaint*);
     33 
     34     sk_sp<SkPicture>    fPicture;
     35     SkMatrix            fMatrix;
     36     SkTLazy<SkPaint>    fPaint;
     37 
     38     typedef SkImageGenerator INHERITED;
     39 };
     40 #endif  // SkPictureImageGenerator_DEFINED
     41