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 image ? sk_sp<Image>(new Image(std::move(image))) : nullptr; 27 } 28 29 SG_ATTRIBUTE(Quality , SkFilterQuality, fQuality ) 30 SG_ATTRIBUTE(AntiAlias, bool , fAntiAlias) 31 32 protected: 33 explicit Image(sk_sp<SkImage>); 34 35 void onRender(SkCanvas*) const override; 36 37 SkRect onRevalidate(InvalidationController*, const SkMatrix&) override; 38 39 private: 40 const sk_sp<SkImage> fImage; 41 SkFilterQuality fQuality = kLow_SkFilterQuality; 42 bool fAntiAlias = true; 43 44 typedef RenderNode INHERITED; 45 }; 46 47 } // namespace sksg 48 49 #endif // SkSGImage_DEFINED 50