Adopt QuickAddons in plasma-framework

Removes the code that was moved to QuickAddons

REVIEW: 120596
This commit is contained in:
Aleix Pol 2014-10-15 13:22:27 +02:00
parent b65201b735
commit 7a4998046e
7 changed files with 19 additions and 86 deletions

View File

@ -44,7 +44,9 @@ target_link_libraries(corebindingsplugin
KF5::Service #for kplugininfo.h
KF5::WindowSystem
KF5::Plasma
KF5::PlasmaQuick)
KF5::PlasmaQuick
KF5::QuickAddons
)
if(HAVE_X11)
target_link_libraries(corebindingsplugin ${X11_LIBRARIES} ${XCB_XCB_LIBRARY} )

View File

@ -30,33 +30,15 @@
#include <plasma/private/framesvg_p.h>
#include <plasma/private/framesvg_helpers.h>
#include "svgtexturenode.h"
#include <QuickAddons/ManagedTextureNode>
#include <QuickAddons/ImageTexturesCache>
#include <cmath> //floor()
namespace Plasma
{
typedef QHash<qint64, QHash<QWindow*, QWeakPointer<QSGTexture> > > TexturesCache;
Q_GLOBAL_STATIC(TexturesCache, s_cache)
QSharedPointer<QSGTexture> loadTexture(QQuickWindow *window, const QImage &image)
{
qint64 id = image.cacheKey();
QSharedPointer<QSGTexture> texture = s_cache->value(id).value(window).toStrongRef();
if (!texture) {
auto cleanAndDelete = [window, id](QSGTexture* texture) {
QHash<QWindow*, QWeakPointer<QSGTexture> >& textures = (*s_cache)[id];
textures.remove(window);
if (textures.isEmpty())
s_cache->remove(id);
delete texture;
};
texture = QSharedPointer<QSGTexture>(window->createTextureFromImage(image), cleanAndDelete);
(*s_cache)[id][window] = texture.toWeakRef();
}
return texture;
}
Q_GLOBAL_STATIC(ImageTexturesCache, s_cache)
class FrameNode : public QSGNode
{
@ -92,7 +74,7 @@ private:
int bottomHeight;
};
class FrameItemNode : public SVGTextureNode
class FrameItemNode : public ManagedTextureNode
{
public:
enum FitMode {
@ -104,7 +86,7 @@ public:
};
FrameItemNode(FrameSvgItem* frameSvg, FrameSvg::EnabledBorders borders, FitMode fitMode, QSGNode* parent)
: SVGTextureNode()
: ManagedTextureNode()
, m_frameSvg(frameSvg)
, m_border(borders)
, m_lastParent(parent)
@ -139,7 +121,7 @@ public:
void updateTexture(const QSize &size, const QString &elementId)
{
setTexture(loadTexture(m_frameSvg->window(), m_frameSvg->frameSvg()->image(size, elementId)));
setTexture(s_cache->loadTexture(m_frameSvg->window(), m_frameSvg->frameSvg()->image(size, elementId)));
}
void reposition(const QRect& frameGeometry, QSize& fullSize)
@ -460,10 +442,10 @@ QSGNode *FrameSvgItem::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaint
m_sizeChanged = false;
}
} else {
SVGTextureNode *textureNode = dynamic_cast<SVGTextureNode *>(oldNode);
ManagedTextureNode *textureNode = dynamic_cast<ManagedTextureNode *>(oldNode);
if (!textureNode) {
delete oldNode;
textureNode = new SVGTextureNode;
textureNode = new ManagedTextureNode;
textureNode->setFiltering(QSGTexture::Nearest);
m_textureChanged = true; //force updating the texture on our newly created node
oldNode = textureNode;
@ -471,7 +453,7 @@ QSGNode *FrameSvgItem::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaint
if ((m_textureChanged || m_sizeChanged) || textureNode->texture()->textureSize() != m_frameSvg->size()) {
QImage image = m_frameSvg->framePixmap().toImage();
textureNode->setTexture(loadTexture(window(), image));
textureNode->setTexture(s_cache->loadTexture(window(), image));
textureNode->setRect(0, 0, width(), height());
m_textureChanged = false;

View File

@ -31,7 +31,6 @@ namespace Plasma
{
class FrameSvg;
class SVGTextureNode;
/**
* @class FrameSvgItemMargins

View File

@ -33,7 +33,7 @@
#include <kiconeffect.h>
#include "fadingnode_p.h"
#include "svgtexturenode.h"
#include <QuickAddons/ManagedTextureNode>
#include "units.h"
IconItem::IconItem(QQuickItem *parent)
@ -249,11 +249,11 @@ QSGNode* IconItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *update
return animatingNode;
} else {
Plasma::SVGTextureNode *textureNode = dynamic_cast<Plasma::SVGTextureNode*>(oldNode);
ManagedTextureNode *textureNode = dynamic_cast<ManagedTextureNode*>(oldNode);
if (!textureNode || m_textureChanged) {
delete oldNode;
textureNode = new Plasma::SVGTextureNode;
textureNode = new ManagedTextureNode;
textureNode->setTexture(QSharedPointer<QSGTexture>(window()->createTextureFromImage(m_iconPixmap.toImage())));
m_sizeChanged = true;
m_textureChanged = false;

View File

@ -27,7 +27,7 @@
#include "plasma/svg.h"
#include "svgtexturenode.h"
#include <QuickAddons/ManagedTextureNode>
#include <cmath> //floor()
@ -144,9 +144,9 @@ QSGNode *SvgItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updateP
return Q_NULLPTR;
}
SVGTextureNode *textureNode = static_cast<SVGTextureNode *>(oldNode);
ManagedTextureNode *textureNode = static_cast<ManagedTextureNode *>(oldNode);
if (!textureNode) {
textureNode = new SVGTextureNode;
textureNode = new ManagedTextureNode;
textureNode->setFiltering(QSGTexture::Linear);
m_textureChanged = true;
}

View File

@ -1,51 +0,0 @@
/***************************************************************************
* Copyright 2014 David Edmundson <davidedmundson@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#ifndef SVGTEXTURENODE_H
#define SVGTEXTURENODE_H
#include <QSGSimpleTextureNode>
namespace Plasma
{
/**
* This class wraps QSGSimpleTextureNode
* and manages the lifespan on the texture
*/
class SVGTextureNode : public QSGSimpleTextureNode
{
public:
SVGTextureNode() {}
/**
* Set the current texture
* the object takes ownership of the texture
*/
void setTexture(QSharedPointer<QSGTexture> texture)
{
m_texture = texture;
QSGSimpleTextureNode::setTexture(texture.data());
}
private:
QSharedPointer<QSGTexture> m_texture;
};
}
#endif // SVGTextureNode

View File

@ -49,6 +49,7 @@ target_link_libraries(KF5PlasmaQuick
KF5::CoreAddons
KF5::XmlGui
KF5::Declarative
KF5::QuickAddons
)
if(HAVE_X11)