Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
383 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ | |
|
||
## SkGui | ||
|
||
- Create WDeclarativeTexture. | ||
|
||
- Create WDeclarativeItemPaint. | ||
|
||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "../../src/SkGui/src/declarative/WDeclarativeTexture.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "../../src/SkGui/src/declarative/WDeclarativeTexture.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "../../../src/SkGui/src/declarative/WDeclarativeTexture_p.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "../../../src/SkGui/src/declarative/WDeclarativeTexture_p.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,245 @@ | ||
//================================================================================================= | ||
/* | ||
Copyright (C) 2015-2017 Sky kit authors united with omega. <http://omega.gg/about> | ||
Author: Benjamin Arnaud. <http://bunjee.me> <bunjee@omega.gg> | ||
This file is part of the SkGui module of Sky kit. | ||
- GNU General Public License Usage: | ||
This file may be used under the terms of the GNU General Public License version 3 as published | ||
by the Free Software Foundation and appearing in the LICENSE.md file included in the packaging | ||
of this file. Please review the following information to ensure the GNU General Public License | ||
requirements will be met: https://www.gnu.org/licenses/gpl.html. | ||
*/ | ||
//================================================================================================= | ||
|
||
#include "WDeclarativeTexture.h" | ||
|
||
#ifndef SK_NO_DECLARATIVETEXTURE | ||
|
||
// Sk includes | ||
#include <WView> | ||
|
||
// Private includes | ||
#include <private/qquickwindow_p.h> | ||
#include <private/qsgadaptationlayer_p.h> | ||
|
||
//------------------------------------------------------------------------------------------------- | ||
// Private | ||
//------------------------------------------------------------------------------------------------- | ||
|
||
#include "WDeclarativeTexture_p.h" | ||
|
||
WDeclarativeTexturePrivate::WDeclarativeTexturePrivate(WDeclarativeTexture * p) | ||
: WDeclarativeItemPrivate(p) {} | ||
|
||
/* virtual */ WDeclarativeTexturePrivate::~WDeclarativeTexturePrivate() | ||
{ | ||
if (texture) texture->deleteLater(); | ||
} | ||
|
||
//------------------------------------------------------------------------------------------------- | ||
|
||
void WDeclarativeTexturePrivate::init() | ||
{ | ||
Q_Q(WDeclarativeTexture); | ||
|
||
context = NULL; | ||
texture = NULL; | ||
|
||
updateTexture = false; | ||
updateGeometry = false; | ||
updateMipmap = false; | ||
|
||
mipmap = false; | ||
|
||
q->setFlag(QQuickItem::ItemHasContents); | ||
} | ||
|
||
//------------------------------------------------------------------------------------------------- | ||
// Private functions | ||
//------------------------------------------------------------------------------------------------- | ||
|
||
void WDeclarativeTexturePrivate::applyMipmap(QSGInternalImageNode * node) | ||
{ | ||
updateMipmap = false; | ||
|
||
if (mipmap) | ||
{ | ||
node->setMipmapFiltering(QSGTexture::Linear); | ||
} | ||
else node->setMipmapFiltering(QSGTexture::None); | ||
} | ||
|
||
//------------------------------------------------------------------------------------------------- | ||
// Ctor / dtor | ||
//------------------------------------------------------------------------------------------------- | ||
|
||
/* explicit */ WDeclarativeTexture::WDeclarativeTexture(QQuickItem * parent) | ||
: WDeclarativeItem(new WDeclarativeTexturePrivate(this), parent) | ||
{ | ||
Q_D(WDeclarativeTexture); d->init(); | ||
} | ||
|
||
//------------------------------------------------------------------------------------------------- | ||
// Protected | ||
|
||
WDeclarativeTexture::WDeclarativeTexture(WDeclarativeTexturePrivate * p, QQuickItem * parent) | ||
: WDeclarativeItem(p, parent) | ||
{ | ||
Q_D(WDeclarativeTexture); d->init(); | ||
} | ||
|
||
//------------------------------------------------------------------------------------------------- | ||
// QQuickItem reimplementation | ||
//------------------------------------------------------------------------------------------------- | ||
|
||
/* virtual */ QSGNode * WDeclarativeTexture::updatePaintNode(QSGNode * oldNode, | ||
UpdatePaintNodeData *) | ||
{ | ||
const QPixmap & pixmap = getPixmap(); | ||
|
||
if (pixmap.isNull() || width() < 1 || height() < 1) | ||
{ | ||
if (oldNode) | ||
{ | ||
Q_D(WDeclarativeTexture); | ||
|
||
delete oldNode; | ||
|
||
delete d->texture; | ||
|
||
d->texture = NULL; | ||
} | ||
|
||
return NULL; | ||
} | ||
|
||
Q_D(WDeclarativeTexture); | ||
|
||
QSGInternalImageNode * node; | ||
|
||
if (oldNode) | ||
{ | ||
node = static_cast<QSGInternalImageNode *> (oldNode); | ||
|
||
if (d->updateTexture) | ||
{ | ||
if (d->updateMipmap) d->applyMipmap(node); | ||
|
||
d->updateTexture = false; | ||
d->updateGeometry = false; | ||
|
||
if (d->texture) delete d->texture; | ||
|
||
d->texture = d->view->createTextureFromImage(pixmap.toImage()); | ||
|
||
node->setTexture(d->texture); | ||
|
||
applyGeometry(node, pixmap); | ||
|
||
node->update(); | ||
} | ||
else if (d->updateGeometry) | ||
{ | ||
if (d->updateMipmap) d->applyMipmap(node); | ||
|
||
d->updateGeometry = false; | ||
|
||
applyGeometry(node, pixmap); | ||
|
||
node->update(); | ||
} | ||
else if (d->updateMipmap) | ||
{ | ||
d->applyMipmap(node); | ||
|
||
node->update(); | ||
} | ||
} | ||
else | ||
{ | ||
node = d->context->createInternalImageNode(); | ||
|
||
node->setFiltering(QSGTexture::Linear); | ||
|
||
d->applyMipmap(node); | ||
|
||
d->updateTexture = false; | ||
d->updateGeometry = false; | ||
|
||
d->texture = d->view->createTextureFromImage(pixmap.toImage()); | ||
|
||
node->setTexture(d->texture); | ||
|
||
applyGeometry(node, pixmap); | ||
|
||
node->update(); | ||
} | ||
|
||
return node; | ||
} | ||
|
||
//------------------------------------------------------------------------------------------------- | ||
// Protected virtual functions | ||
//------------------------------------------------------------------------------------------------- | ||
|
||
/* virtual */ void WDeclarativeTexture::applyGeometry(QSGInternalImageNode * node, const QPixmap &) | ||
{ | ||
QRectF rect = boundingRect(); | ||
|
||
node->setTargetRect (rect); | ||
node->setInnerTargetRect(rect); | ||
} | ||
|
||
//------------------------------------------------------------------------------------------------- | ||
// Protected QQuickItem reimplementation | ||
//------------------------------------------------------------------------------------------------- | ||
|
||
/* virtual */ void WDeclarativeTexture::itemChange(ItemChange change, const ItemChangeData & value) | ||
{ | ||
if (change == ItemSceneChange) | ||
{ | ||
Q_D(WDeclarativeTexture); | ||
|
||
QQuickWindow * window = value.window; | ||
|
||
if (window) | ||
{ | ||
QQuickWindowPrivate * p | ||
= static_cast<QQuickWindowPrivate *> (QObjectPrivate::get(window)); | ||
|
||
d->context = p->context->sceneGraphContext(); | ||
} | ||
else d->context = NULL; | ||
} | ||
|
||
WDeclarativeItem::itemChange(change, value); | ||
} | ||
|
||
//------------------------------------------------------------------------------------------------- | ||
// Properties | ||
//------------------------------------------------------------------------------------------------- | ||
|
||
bool WDeclarativeTexture::mipmap() const | ||
{ | ||
Q_D(const WDeclarativeTexture); return d->mipmap; | ||
} | ||
|
||
void WDeclarativeTexture::setMipmap(bool enabled) | ||
{ | ||
Q_D(WDeclarativeTexture); | ||
|
||
if (d->mipmap == enabled) return; | ||
|
||
d->mipmap = enabled; | ||
|
||
d->updateMipmap = true; | ||
|
||
update(); | ||
|
||
emit mipmapChanged(); | ||
} | ||
|
||
#endif // SK_NO_DECLARATIVETEXTURE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
//================================================================================================= | ||
/* | ||
Copyright (C) 2015-2017 Sky kit authors united with omega. <http://omega.gg/about> | ||
Author: Benjamin Arnaud. <http://bunjee.me> <bunjee@omega.gg> | ||
This file is part of the SkGui module of Sky kit. | ||
- GNU General Public License Usage: | ||
This file may be used under the terms of the GNU General Public License version 3 as published | ||
by the Free Software Foundation and appearing in the LICENSE.md file included in the packaging | ||
of this file. Please review the following information to ensure the GNU General Public License | ||
requirements will be met: https://www.gnu.org/licenses/gpl.html. | ||
*/ | ||
//================================================================================================= | ||
|
||
#ifndef WDECLARATIVETEXTURE_H | ||
#define WDECLARATIVETEXTURE_H | ||
|
||
// Sk includes | ||
#include <WDeclarativeItem> | ||
|
||
#ifndef SK_NO_DECLARATIVETEXTURE | ||
|
||
// Forward declarations | ||
class QSGInternalImageNode; | ||
class WDeclarativeTexturePrivate; | ||
|
||
class SK_GUI_EXPORT WDeclarativeTexture : public WDeclarativeItem | ||
{ | ||
Q_OBJECT | ||
|
||
Q_PROPERTY(bool mipmap READ mipmap WRITE setMipmap NOTIFY mipmapChanged) | ||
|
||
public: | ||
explicit WDeclarativeTexture(QQuickItem * parent = NULL); | ||
protected: | ||
WDeclarativeTexture(WDeclarativeTexturePrivate * p, QQuickItem * parent = NULL); | ||
|
||
public: // QQuickItem reimplementation | ||
/* virtual */ QSGNode * updatePaintNode(QSGNode * oldNode, UpdatePaintNodeData * data); | ||
|
||
protected: // Abstract functions | ||
virtual const QPixmap & getPixmap() = 0; | ||
|
||
protected: // Virtual functions | ||
virtual void applyGeometry(QSGInternalImageNode * node, const QPixmap & pixmap); | ||
|
||
protected: // QQuickItem reimplementation | ||
/* virtual */ void itemChange(ItemChange change, const ItemChangeData & value); | ||
|
||
signals: | ||
void mipmapChanged(); | ||
|
||
public: // Properties | ||
bool mipmap() const; | ||
void setMipmap(bool enabled); | ||
|
||
private: | ||
W_DECLARE_PRIVATE(WDeclarativeTexture) | ||
}; | ||
|
||
#endif // SK_NO_DECLARATIVETEXTURE | ||
#endif // WDECLARATIVETEXTURE_H |
Oops, something went wrong.