7#include "shadowedtexture.h"
10#include <QSGRectangleNode>
11#include <QSGRendererInterface>
13#include "scenegraph/shadowedtexturenode.h"
15ShadowedTexture::ShadowedTexture(
QQuickItem *parentItem)
20ShadowedTexture::~ShadowedTexture()
29void ShadowedTexture::setSource(
QQuickItem *newSource)
31 if (newSource == m_source) {
36 m_sourceChanged =
true;
37 if (m_source && !m_source->parentItem()) {
38 m_source->setParentItem(
this);
41 if (!isSoftwareRendering()) {
47QSGNode *ShadowedTexture::updatePaintNode(
QSGNode *node, QQuickItem::UpdatePaintNodeData *data)
56 auto shadowNode =
static_cast<ShadowedRectangleNode *
>(node);
58 if (!shadowNode || m_sourceChanged) {
59 m_sourceChanged =
false;
62 shadowNode =
new ShadowedTextureNode{};
64 shadowNode =
new ShadowedRectangleNode{};
67 if (qEnvironmentVariableIsSet(
"KIRIGAMI_LOWPOWER_HARDWARE")) {
68 shadowNode->setShaderType(ShadowedRectangleMaterial::ShaderType::LowPower);
72 shadowNode->setBorderEnabled(border()->
isEnabled());
74 shadowNode->setSize(shadow()->
size());
75 shadowNode->setRadius(corners()->toVector4D(radius()));
76 shadowNode->setOffset(QVector2D{float(shadow()->xOffset()), float(shadow()->yOffset())});
77 shadowNode->setColor(color());
78 shadowNode->setShadowColor(shadow()->color());
79 shadowNode->setBorderWidth(border()->
width());
80 shadowNode->setBorderColor(border()->color());
83 static_cast<ShadowedTextureNode *
>(shadowNode)->setTextureSource(m_source->textureProvider());
86 shadowNode->updateGeometry();
90#include "moc_shadowedtexture.cpp"
QML_ELEMENTQQuickItem * source
This property holds the source item that will get rendered with the shadow.
virtual QRectF boundingRect() const const
bool isEnabled() const const
QSizeF size() const const