KWin
Loading...
Searching...
No Matches
Public Types | Signals | Public Member Functions | Public Attributes | List of all members
KWin::OffscreenQuickView Class Reference

The KwinQuickView class provides a convenient API for exporting QtQuick scenes as buffers that can be composited in any other fashion. More...

#include <offscreenquickview.h>

Inheritance diagram for KWin::OffscreenQuickView:
KWin::OffscreenQuickScene KWin::QuickSceneView KWin::EffectFrameQuickScene

Public Types

enum class  ExportMode { Texture , Image }
 

Signals

void repaintNeeded ()
 
void geometryChanged (const QRect &oldGeometry, const QRect &newGeometry)
 
void renderRequested ()
 
void sceneChanged ()
 

Public Member Functions

void releaseResources ()
 
void updateTouchState (Qt::TouchPointState state, qint32 id, const QPointF &pos)
 
 OffscreenQuickView (ExportMode exportMode=ExportMode::Texture, bool alpha=true)
 
 ~OffscreenQuickView ()
 
QSize size () const
 
void setGeometry (const QRect &rect)
 
QRect geometry () const
 
void setOpacity (qreal opacity)
 
qreal opacity () const
 
bool hasAlphaChannel () const
 
void update ()
 
QQuickItem * contentItem () const
 
QQuickWindow * window () const
 
void setVisible (bool visible)
 Marks the window as visible/invisible This can be used to release resources used by the window The default is true.
 
bool isVisible () const
 
void show ()
 
void hide ()
 
bool automaticRepaint () const
 
void setAutomaticRepaint (bool set)
 
GLTexturebufferAsTexture ()
 
QImage bufferAsImage () const
 
void forwardMouseEvent (QEvent *mouseEvent)
 
void forwardKeyEvent (QKeyEvent *keyEvent)
 
bool forwardTouchDown (qint32 id, const QPointF &pos, std::chrono::microseconds time)
 
bool forwardTouchMotion (qint32 id, const QPointF &pos, std::chrono::microseconds time)
 
bool forwardTouchUp (qint32 id, std::chrono::microseconds time)
 

Public Attributes

std::unique_ptr< QQuickWindow > m_view
 
std::unique_ptr< QQuickRenderControl > m_renderControl
 
std::unique_ptr< QOffscreenSurface > m_offscreenSurface
 
std::unique_ptr< QOpenGLContext > m_glcontext
 
std::unique_ptr< QOpenGLFramebufferObject > m_fbo
 
std::unique_ptr< QTimer > m_repaintTimer
 
QImage m_image
 
std::unique_ptr< GLTexturem_textureExport
 
bool m_useBlit = false
 
bool m_visible = true
 
bool m_hasAlphaChannel = true
 
bool m_automaticRepaint = true
 
QList< QEventPoint > touchPoints
 
QPointingDevice * touchDevice
 
ulong lastMousePressTime = 0
 
Qt::MouseButton lastMousePressButton = Qt::NoButton
 

Detailed Description

The KwinQuickView class provides a convenient API for exporting QtQuick scenes as buffers that can be composited in any other fashion.

Contents can be fetched as a GL Texture or as a QImage If data is to be fetched as an image, it should be specified upfront as blitting is performed when we update our FBO to keep kwin's render loop as fast as possible.

Definition at line 37 of file offscreenquickview.cpp.

Member Enumeration Documentation

◆ ExportMode

Enumerator
Texture 

The contents will be available as a texture in the shared contexts. Image will be blank

Image 

The contents will be blit during the update into a QImage buffer.

Definition at line 50 of file offscreenquickview.h.

Constructor & Destructor Documentation

◆ OffscreenQuickView()

KWin::OffscreenQuickView::OffscreenQuickView ( ExportMode exportMode = ExportMode::Texture,
bool alpha = true )
explicit

Construct a new KWinQuickView explicitly stating an export mode. alpha indicates whether the view is translucent or not.

Definition at line 78 of file offscreenquickview.cpp.

◆ ~OffscreenQuickView()

KWin::OffscreenQuickView::~OffscreenQuickView ( )

Note that this may change the current GL Context

Definition at line 152 of file offscreenquickview.cpp.

Member Function Documentation

◆ automaticRepaint()

bool KWin::OffscreenQuickView::automaticRepaint ( ) const

Definition at line 166 of file offscreenquickview.cpp.

◆ bufferAsImage()

QImage KWin::OffscreenQuickView::bufferAsImage ( ) const

Returns the current output of the scene graph

Definition at line 442 of file offscreenquickview.cpp.

◆ bufferAsTexture()

GLTexture * KWin::OffscreenQuickView::bufferAsTexture ( )

Returns the current output of the scene graph

Note
The render context must valid at the time of calling

Definition at line 427 of file offscreenquickview.cpp.

◆ contentItem()

QQuickItem * KWin::OffscreenQuickView::contentItem ( ) const

The invisble root item of the window

Definition at line 385 of file offscreenquickview.cpp.

◆ forwardKeyEvent()

void KWin::OffscreenQuickView::forwardKeyEvent ( QKeyEvent * keyEvent)

Inject a key event into the window. If it is handled the event will be accepted

Definition at line 321 of file offscreenquickview.cpp.

◆ forwardMouseEvent()

void KWin::OffscreenQuickView::forwardMouseEvent ( QEvent * mouseEvent)

Inject any mouse event into the QQuickWindow. Local co-ordinates are transformed If it is handled the event will be accepted

Definition at line 264 of file offscreenquickview.cpp.

◆ forwardTouchDown()

bool KWin::OffscreenQuickView::forwardTouchDown ( qint32 id,
const QPointF & pos,
std::chrono::microseconds time )

Definition at line 329 of file offscreenquickview.cpp.

◆ forwardTouchMotion()

bool KWin::OffscreenQuickView::forwardTouchMotion ( qint32 id,
const QPointF & pos,
std::chrono::microseconds time )

Definition at line 341 of file offscreenquickview.cpp.

◆ forwardTouchUp()

bool KWin::OffscreenQuickView::forwardTouchUp ( qint32 id,
std::chrono::microseconds time )

Definition at line 353 of file offscreenquickview.cpp.

◆ geometry()

QRect KWin::OffscreenQuickView::geometry ( ) const

Definition at line 365 of file offscreenquickview.cpp.

◆ geometryChanged

void KWin::OffscreenQuickView::geometryChanged ( const QRect & oldGeometry,
const QRect & newGeometry )
signal

◆ hasAlphaChannel()

bool KWin::OffscreenQuickView::hasAlphaChannel ( ) const

Definition at line 380 of file offscreenquickview.cpp.

◆ hide()

void KWin::OffscreenQuickView::hide ( )

Definition at line 422 of file offscreenquickview.cpp.

◆ isVisible()

bool KWin::OffscreenQuickView::isVisible ( ) const

Definition at line 412 of file offscreenquickview.cpp.

◆ opacity()

qreal KWin::OffscreenQuickView::opacity ( ) const

Definition at line 375 of file offscreenquickview.cpp.

◆ releaseResources()

void KWin::OffscreenQuickView::releaseResources ( )

◆ renderRequested

void KWin::OffscreenQuickView::renderRequested ( )
signal

◆ repaintNeeded

void KWin::OffscreenQuickView::repaintNeeded ( )
signal

The frame buffer has changed, contents need re-rendering on screen

◆ sceneChanged

void KWin::OffscreenQuickView::sceneChanged ( )
signal

◆ setAutomaticRepaint()

void KWin::OffscreenQuickView::setAutomaticRepaint ( bool set)

Definition at line 171 of file offscreenquickview.cpp.

◆ setGeometry()

void KWin::OffscreenQuickView::setGeometry ( const QRect & rect)

The geometry of the current view This may be out of sync with the current buffer size if an update is pending

Definition at line 452 of file offscreenquickview.cpp.

◆ setOpacity()

void KWin::OffscreenQuickView::setOpacity ( qreal opacity)

Definition at line 370 of file offscreenquickview.cpp.

◆ setVisible()

void KWin::OffscreenQuickView::setVisible ( bool visible)

Marks the window as visible/invisible This can be used to release resources used by the window The default is true.

Definition at line 395 of file offscreenquickview.cpp.

◆ show()

void KWin::OffscreenQuickView::show ( )

Definition at line 417 of file offscreenquickview.cpp.

◆ size()

QSize KWin::OffscreenQuickView::size ( ) const

Definition at line 447 of file offscreenquickview.cpp.

◆ update()

void KWin::OffscreenQuickView::update ( )

Render the current scene graph into the FBO. This is typically done automatically when the scene changes albeit deffered by a timer

It can be manually invoked to update the contents immediately. Note this will change the GL context

Definition at line 199 of file offscreenquickview.cpp.

◆ updateTouchState()

void KWin::OffscreenQuickView::updateTouchState ( Qt::TouchPointState state,
qint32 id,
const QPointF & pos )

◆ window()

QQuickWindow * KWin::OffscreenQuickView::window ( ) const

Definition at line 390 of file offscreenquickview.cpp.

Member Data Documentation

◆ lastMousePressButton

Qt::MouseButton KWin::OffscreenQuickView::lastMousePressButton = Qt::NoButton

Definition at line 60 of file offscreenquickview.cpp.

◆ lastMousePressTime

ulong KWin::OffscreenQuickView::lastMousePressTime = 0

Definition at line 59 of file offscreenquickview.cpp.

◆ m_automaticRepaint

bool KWin::OffscreenQuickView::m_automaticRepaint = true

Definition at line 54 of file offscreenquickview.cpp.

◆ m_fbo

std::unique_ptr<QOpenGLFramebufferObject> KWin::OffscreenQuickView::m_fbo

Definition at line 44 of file offscreenquickview.cpp.

◆ m_glcontext

std::unique_ptr<QOpenGLContext> KWin::OffscreenQuickView::m_glcontext

Definition at line 43 of file offscreenquickview.cpp.

◆ m_hasAlphaChannel

bool KWin::OffscreenQuickView::m_hasAlphaChannel = true

Definition at line 53 of file offscreenquickview.cpp.

◆ m_image

QImage KWin::OffscreenQuickView::m_image

Definition at line 47 of file offscreenquickview.cpp.

◆ m_offscreenSurface

std::unique_ptr<QOffscreenSurface> KWin::OffscreenQuickView::m_offscreenSurface

Definition at line 42 of file offscreenquickview.cpp.

◆ m_renderControl

std::unique_ptr<QQuickRenderControl> KWin::OffscreenQuickView::m_renderControl

Definition at line 41 of file offscreenquickview.cpp.

◆ m_repaintTimer

std::unique_ptr<QTimer> KWin::OffscreenQuickView::m_repaintTimer

Definition at line 46 of file offscreenquickview.cpp.

◆ m_textureExport

std::unique_ptr<GLTexture> KWin::OffscreenQuickView::m_textureExport

Definition at line 48 of file offscreenquickview.cpp.

◆ m_useBlit

bool KWin::OffscreenQuickView::m_useBlit = false

Definition at line 51 of file offscreenquickview.cpp.

◆ m_view

std::unique_ptr<QQuickWindow> KWin::OffscreenQuickView::m_view

Definition at line 40 of file offscreenquickview.cpp.

◆ m_visible

bool KWin::OffscreenQuickView::m_visible = true

Definition at line 52 of file offscreenquickview.cpp.

◆ touchDevice

QPointingDevice* KWin::OffscreenQuickView::touchDevice

Definition at line 57 of file offscreenquickview.cpp.

◆ touchPoints

QList<QEventPoint> KWin::OffscreenQuickView::touchPoints

Definition at line 56 of file offscreenquickview.cpp.


The documentation for this class was generated from the following files: