2018-01-08 17:51:12 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2018 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkSGImage_DEFINED
|
|
|
|
#define SkSGImage_DEFINED
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "modules/sksg/include/SkSGRenderNode.h"
|
2018-01-08 17:51:12 +00:00
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkFilterQuality.h"
|
2018-01-08 17:51:12 +00:00
|
|
|
|
|
|
|
class SkImage;
|
|
|
|
|
|
|
|
namespace sksg {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Concrete rendering node, wrapping an SkImage.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class Image final : public RenderNode {
|
|
|
|
public:
|
|
|
|
static sk_sp<Image> Make(sk_sp<SkImage> image) {
|
2018-10-03 18:39:56 +00:00
|
|
|
return sk_sp<Image>(new Image(std::move(image)));
|
2018-01-08 17:51:12 +00:00
|
|
|
}
|
|
|
|
|
2018-10-03 18:39:56 +00:00
|
|
|
SG_ATTRIBUTE(Image, sk_sp<SkImage> , fImage )
|
2018-01-08 17:51:12 +00:00
|
|
|
SG_ATTRIBUTE(Quality , SkFilterQuality, fQuality )
|
|
|
|
SG_ATTRIBUTE(AntiAlias, bool , fAntiAlias)
|
|
|
|
|
|
|
|
protected:
|
|
|
|
explicit Image(sk_sp<SkImage>);
|
|
|
|
|
2018-08-09 11:40:01 +00:00
|
|
|
void onRender(SkCanvas*, const RenderContext*) const override;
|
2019-02-12 14:33:21 +00:00
|
|
|
const RenderNode* onNodeAt(const SkPoint&) const override;
|
2018-01-08 17:51:12 +00:00
|
|
|
|
|
|
|
SkRect onRevalidate(InvalidationController*, const SkMatrix&) override;
|
|
|
|
|
|
|
|
private:
|
2018-10-03 18:39:56 +00:00
|
|
|
sk_sp<SkImage> fImage;
|
2019-03-13 14:36:21 +00:00
|
|
|
SkFilterQuality fQuality = kNone_SkFilterQuality;
|
2018-10-03 18:39:56 +00:00
|
|
|
bool fAntiAlias = true;
|
2018-01-08 17:51:12 +00:00
|
|
|
|
|
|
|
typedef RenderNode INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace sksg
|
|
|
|
|
|
|
|
#endif // SkSGImage_DEFINED
|