blob: dd524c376c75a7c2731427083668a2fc1d90ae32 [file] [log] [blame]
Florin Malita49328072018-01-08 12:51:12 -05001/*
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
15class SkImage;
16
17namespace sksg {
18
19/**
20 * Concrete rendering node, wrapping an SkImage.
21 *
22 */
23class Image final : public RenderNode {
24public:
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
32protected:
33 explicit Image(sk_sp<SkImage>);
34
Florin Malitac0132ff2018-08-09 07:40:01 -040035 void onRender(SkCanvas*, const RenderContext*) const override;
Florin Malita49328072018-01-08 12:51:12 -050036
37 SkRect onRevalidate(InvalidationController*, const SkMatrix&) override;
38
39private:
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