Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ int main(int argc, char *argv[])
QGuiApplication::setQuitOnLastWindowClosed(false);

QGuiApplication app(argc, argv);
qRegisterMetaType<QW_NAMESPACE::qw_buffer*>("qw_buffer*");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

用 Q_DECLARE_METATYPE 代替可以吗?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我实验了一下,不行 qw_buffer和qw_buffer*都试过不行

modified   qwlroots/src/types/qwbuffer.h
@@ -57,3 +57,4 @@ public:
 };
 
 QW_END_NAMESPACE
+Q_DECLARE_METATYPE(QW_NAMESPACE::qw_buffer)   **qw_buffer和qw_buffer*都试过不行**
modified   src/main.cpp
@@ -29,7 +29,7 @@ int main(int argc, char *argv[])
     QGuiApplication::setQuitOnLastWindowClosed(false);
 
     QGuiApplication app(argc, argv);
-    qRegisterMetaType<QW_NAMESPACE::qw_buffer*>("qw_buffer*");
+    //qRegisterMetaType<QW_NAMESPACE::qw_buffer*>("qw_buffer*");
 
     app.setOrganizationName("deepin");
     app.setApplicationName("treeland");
modified   src/modules/prelaunch-splash/prelaunchsplash.h
@@ -22,7 +22,7 @@ QW_BEGIN_NAMESPACE
 class qw_display;
 class qw_buffer;
 QW_END_NAMESPACE
-Q_DECLARE_OPAQUE_POINTER(QW_NAMESPACE::qw_buffer*)
+//Q_DECLARE_OPAQUE_POINTER(QW_NAMESPACE::qw_buffer*)  **这里不注释会和Q_DECLARE_METATYPE产生冲突**
 
 class PrelaunchSplashPrivate;
 struct wl_global;


app.setOrganizationName("deepin");
app.setApplicationName("treeland");
Expand Down
22 changes: 14 additions & 8 deletions waylib/src/server/qtquick/wbufferitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,28 @@ WOutputRenderWindow *WBufferItem::outputRenderWindow() const
return qobject_cast<WOutputRenderWindow*>(window());
}

QW_NAMESPACE::qw_buffer *WBufferItem::buffer() const
QObject *WBufferItem::buffer() const
{
W_DC(WBufferItem);
return d->buffer.get();
}

void WBufferItem::setBuffer(QW_NAMESPACE::qw_buffer *buffer)
void WBufferItem::setBuffer(QObject *buffer)
{
W_D(WBufferItem);

if (d->buffer.get() == buffer)
QW_NAMESPACE::qw_buffer *ibuffer = qobject_cast<QW_NAMESPACE::qw_buffer*>(buffer);
if (buffer != nullptr && ibuffer == nullptr) {
qCWarning(waylibBufferItem) << "Reject expects a qw_buffer; ignoring incompatible object" << buffer;
return;
}

if (d->buffer.get() == ibuffer)
return;

// Validate buffer basic attributes before locking to avoid holding unusable buffers.
if (buffer) {
auto *h = buffer->handle();
if (ibuffer) {
auto *h = ibuffer->handle();
if (!h || h->width <= 0 || h->height <= 0) {
qCWarning(waylibBufferItem) << "Reject buffer with invalid size or handle"
<< buffer << "w" << (h ? h->width : -1)
Expand All @@ -113,10 +119,10 @@ void WBufferItem::setBuffer(QW_NAMESPACE::qw_buffer *buffer)
}
}

if (buffer)
buffer->lock();
if (ibuffer)
ibuffer->lock();

d->buffer.reset(buffer);
d->buffer.reset(ibuffer);

if (d->textureProvider)
d->textureProvider->setBuffer(d->buffer.get());
Expand Down
6 changes: 3 additions & 3 deletions waylib/src/server/qtquick/wbufferitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ class WAYLIB_SERVER_EXPORT WBufferItem : public QQuickItem, public virtual WText
{
Q_OBJECT
Q_DECLARE_PRIVATE(WBufferItem)
Q_PROPERTY(QW_NAMESPACE::qw_buffer* buffer READ buffer WRITE setBuffer NOTIFY bufferChanged FINAL)
Q_PROPERTY(QObject* buffer READ buffer WRITE setBuffer NOTIFY bufferChanged FINAL)
QML_NAMED_ELEMENT(BufferItem)

public:
explicit WBufferItem(QQuickItem *parent = nullptr);
~WBufferItem() override;

QW_NAMESPACE::qw_buffer *buffer() const;
void setBuffer(QW_NAMESPACE::qw_buffer *buffer);
QObject *buffer() const;
void setBuffer(QObject *buffer);

bool isTextureProvider() const override;
QSGTextureProvider *textureProvider() const override;
Expand Down