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
|
|
|
|
|
|
|
|
#include "SkSGRenderNode.h"
|
|
|
|
|
|
|
|
#include "SkFilterQuality.h"
|
|
|
|
|
|
|
|
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;
|
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;
|
|
|
|
SkFilterQuality fQuality = kLow_SkFilterQuality;
|
|
|
|
bool fAntiAlias = true;
|
2018-01-08 17:51:12 +00:00
|
|
|
|
|
|
|
typedef RenderNode INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace sksg
|
|
|
|
|
|
|
|
#endif // SkSGImage_DEFINED
|