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 "modules/sksg/include/SkSGRenderNode.h" 12 13 #include "include/core/SkSamplingOptions.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: Make(sk_sp<SkImage> image)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(SamplingOptions, SkSamplingOptions, fSamplingOptions) 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 SkSamplingOptions fSamplingOptions; 43 sk_sp<SkImage> fImage; 44 bool fAntiAlias = true; 45 46 using INHERITED = RenderNode; 47 }; 48 49 } // namespace sksg 50 51 #endif // SkSGImage_DEFINED 52