Home | History | Annotate | Download | only in include
      1 /*
      2  * Copyright 2018 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 
      8 #ifndef SkSGImage_DEFINED
      9 #define SkSGImage_DEFINED
     10 
     11 #include "SkSGRenderNode.h"
     12 
     13 #include "SkFilterQuality.h"
     14 
     15 class SkImage;
     16 
     17 namespace sksg {
     18 
     19 /**
     20  * Concrete rendering node, wrapping an SkImage.
     21  *
     22  */
     23 class Image final : public RenderNode {
     24 public:
     25     static sk_sp<Image> Make(sk_sp<SkImage> image) {
     26         return sk_sp<Image>(new Image(std::move(image)));
     27     }
     28 
     29     SG_ATTRIBUTE(Image,     sk_sp<SkImage> , fImage    )
     30     SG_ATTRIBUTE(Quality  , SkFilterQuality, fQuality  )
     31     SG_ATTRIBUTE(AntiAlias, bool           , fAntiAlias)
     32 
     33 protected:
     34     explicit Image(sk_sp<SkImage>);
     35 
     36     void onRender(SkCanvas*, const RenderContext*) const override;
     37     const RenderNode* onNodeAt(const SkPoint&)     const override;
     38 
     39     SkRect onRevalidate(InvalidationController*, const SkMatrix&) override;
     40 
     41 private:
     42     sk_sp<SkImage>  fImage;
     43     SkFilterQuality fQuality   = kLow_SkFilterQuality;
     44     bool            fAntiAlias = true;
     45 
     46     typedef RenderNode INHERITED;
     47 };
     48 
     49 } // namespace sksg
     50 
     51 #endif // SkSGImage_DEFINED
     52