2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2006 Lubos Lunak <l.lunak@kde.org>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#ifndef KWIN_SCENE_H
|
|
|
|
#define KWIN_SCENE_H
|
|
|
|
|
|
|
|
#include "toplevel.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "kwineffects.h"
|
|
|
|
|
2013-04-26 09:27:30 +00:00
|
|
|
#include <QElapsedTimer>
|
2015-11-26 15:12:12 +00:00
|
|
|
#include <QMatrix4x4>
|
2013-04-26 09:27:30 +00:00
|
|
|
|
2015-08-18 12:40:26 +00:00
|
|
|
class QOpenGLFramebufferObject;
|
|
|
|
|
2020-04-29 15:18:41 +00:00
|
|
|
namespace KWaylandServer
|
2015-02-09 17:56:05 +00:00
|
|
|
{
|
|
|
|
class BufferInterface;
|
2016-03-21 15:37:45 +00:00
|
|
|
class SubSurfaceInterface;
|
2015-02-09 17:56:05 +00:00
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2014-07-22 11:11:19 +00:00
|
|
|
namespace Decoration
|
|
|
|
{
|
|
|
|
class DecoratedClientImpl;
|
|
|
|
class Renderer;
|
|
|
|
}
|
|
|
|
|
2012-03-29 18:17:57 +00:00
|
|
|
class AbstractThumbnailItem;
|
2007-04-29 17:35:43 +00:00
|
|
|
class Deleted;
|
2010-07-18 16:32:37 +00:00
|
|
|
class EffectFrameImpl;
|
2007-04-29 17:35:43 +00:00
|
|
|
class EffectWindowImpl;
|
2011-07-06 09:58:23 +00:00
|
|
|
class OverlayWindow;
|
2011-04-03 09:31:33 +00:00
|
|
|
class Shadow;
|
2013-05-10 10:07:56 +00:00
|
|
|
class WindowPixmap;
|
2020-07-22 17:22:36 +00:00
|
|
|
class GLTexture;
|
|
|
|
class AbstractOutput;
|
2020-11-03 11:18:09 +00:00
|
|
|
class SubSurfaceMonitor;
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// The base class for compositing backends.
|
2016-06-29 17:22:41 +00:00
|
|
|
class KWIN_EXPORT Scene : public QObject
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2011-06-15 16:35:00 +00:00
|
|
|
Q_OBJECT
|
2011-01-30 14:34:42 +00:00
|
|
|
public:
|
2015-02-23 13:41:45 +00:00
|
|
|
explicit Scene(QObject *parent = nullptr);
|
Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.
The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.
Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.
A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!
The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.
The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, apol, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 16:52:26 +00:00
|
|
|
~Scene() override = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
class EffectFrame;
|
|
|
|
class Window;
|
|
|
|
|
|
|
|
// Returns true if the ctor failed to properly initialize.
|
|
|
|
virtual bool initFailed() const = 0;
|
|
|
|
virtual CompositingType compositingType() const = 0;
|
2012-08-23 14:51:40 +00:00
|
|
|
|
|
|
|
virtual bool hasPendingFlush() const { return false; }
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
// Repaints the given screen areas, windows provides the stacking order.
|
|
|
|
// The entry point for the main part of the painting pass.
|
2012-03-29 20:11:28 +00:00
|
|
|
// returns the time since the last vblank signal - if there's one
|
|
|
|
// ie. "what of this frame is lost to painting"
|
Provide expected presentation time to effects
Effects are given the interval between two consecutive frames. The main
flaw of this approach is that if the Compositor transitions from the idle
state to "active" state, i.e. when there is something to repaint,
effects may see a very large interval between the last painted frame and
the current. In order to address this issue, the Scene invalidates the
timer that is used to measure time between consecutive frames before the
Compositor is about to become idle.
While this works perfectly fine with Xinerama-style rendering, with per
screen rendering, determining whether the compositor is about to idle is
rather a tedious task mostly because a single output can't be used for
the test.
Furthermore, since the Compositor schedules pointless repaints just to
ensure that it's idle, it might take several attempts to figure out
whether the scene timer must be invalidated if you use (true) per screen
rendering.
Ideally, all effects should use a timeline helper that is aware of the
underlying render loop and its timings. However, this option is off the
table because it will involve a lot of work to implement it.
Alternative and much simpler option is to pass the expected presentation
time to effects rather than time between consecutive frames. This means
that effects are responsible for determining how much animation timelines
have to be advanced. Typically, an effect would have to store the
presentation timestamp provided in either prePaint{Screen,Window} and
use it in the subsequent prePaint{Screen,Window} call to estimate the
amount of time passed between the next and the last frames.
Unfortunately, this is an API incompatible change. However, it shouldn't
take a lot of work to port third-party binary effects, which don't use the
AnimationEffect class, to the new API. On the bright side, we no longer
need to be concerned about the Compositor getting idle.
We do still try to determine whether the Compositor is about to idle,
primarily, because the OpenGL render backend swaps buffers on present,
but that will change with the ongoing compositing timing rework.
2020-11-20 15:44:04 +00:00
|
|
|
virtual void paint(int screenId, const QRegion &damage, const QList<Toplevel *> &windows,
|
|
|
|
std::chrono::milliseconds presentTime) = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2019-01-11 18:55:17 +00:00
|
|
|
/**
|
|
|
|
* Adds the Toplevel to the Scene.
|
|
|
|
*
|
|
|
|
* If the toplevel gets deleted, then the scene will try automatically
|
|
|
|
* to re-bind an underlying scene window to the corresponding Deleted.
|
|
|
|
*
|
|
|
|
* @param toplevel The window to be added.
|
|
|
|
* @note You can add a toplevel to scene only once.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-01-11 18:55:17 +00:00
|
|
|
void addToplevel(Toplevel *toplevel);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes the Toplevel from the Scene.
|
|
|
|
*
|
|
|
|
* @param toplevel The window to be removed.
|
|
|
|
* @note You can remove a toplevel from the scene only once.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-01-11 18:55:17 +00:00
|
|
|
void removeToplevel(Toplevel *toplevel);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2013-06-24 06:49:24 +00:00
|
|
|
/**
|
|
|
|
* @brief Creates the Scene backend of an EffectFrame.
|
|
|
|
*
|
|
|
|
* @param frame The EffectFrame this Scene::EffectFrame belongs to.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2013-06-24 06:49:24 +00:00
|
|
|
virtual Scene::EffectFrame *createEffectFrame(EffectFrameImpl *frame) = 0;
|
2013-06-24 07:06:50 +00:00
|
|
|
/**
|
|
|
|
* @brief Creates the Scene specific Shadow subclass.
|
|
|
|
*
|
|
|
|
* An implementing class has to create a proper instance. It is not allowed to
|
|
|
|
* return @c null.
|
|
|
|
*
|
|
|
|
* @param toplevel The Toplevel for which the Shadow needs to be created.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2013-06-24 07:06:50 +00:00
|
|
|
virtual Shadow *createShadow(Toplevel *toplevel) = 0;
|
2011-11-26 15:15:46 +00:00
|
|
|
/**
|
|
|
|
* Method invoked when the screen geometry is changed.
|
|
|
|
* Reimplementing classes should also invoke the parent method
|
|
|
|
* as it takes care of resizing the overlay window.
|
|
|
|
* @param size The new screen geometry size
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2011-11-26 15:15:46 +00:00
|
|
|
virtual void screenGeometryChanged(const QSize &size);
|
2011-01-30 14:34:42 +00:00
|
|
|
// Flags controlling how painting is done.
|
|
|
|
enum {
|
|
|
|
// Window (or at least part of it) will be painted opaque.
|
|
|
|
PAINT_WINDOW_OPAQUE = 1 << 0,
|
|
|
|
// Window (or at least part of it) will be painted translucent.
|
|
|
|
PAINT_WINDOW_TRANSLUCENT = 1 << 1,
|
|
|
|
// Window will be painted with transformed geometry.
|
|
|
|
PAINT_WINDOW_TRANSFORMED = 1 << 2,
|
|
|
|
// Paint only a region of the screen (can be optimized, cannot
|
|
|
|
// be used together with TRANSFORMED flags).
|
|
|
|
PAINT_SCREEN_REGION = 1 << 3,
|
|
|
|
// Whole screen will be painted with transformed geometry.
|
|
|
|
PAINT_SCREEN_TRANSFORMED = 1 << 4,
|
|
|
|
// At least one window will be painted with transformed geometry.
|
|
|
|
PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS = 1 << 5,
|
|
|
|
// Clear whole background as the very first step, without optimizing it
|
|
|
|
PAINT_SCREEN_BACKGROUND_FIRST = 1 << 6,
|
2012-01-10 17:56:14 +00:00
|
|
|
// PAINT_DECORATION_ONLY = 1 << 7 has been removed
|
2011-01-30 14:34:42 +00:00
|
|
|
// Window will be painted with a lanczos filter.
|
2012-03-02 13:03:05 +00:00
|
|
|
PAINT_WINDOW_LANCZOS = 1 << 8
|
2012-01-29 16:25:20 +00:00
|
|
|
// PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_WITHOUT_FULL_REPAINTS = 1 << 9 has been removed
|
2007-04-29 17:35:43 +00:00
|
|
|
};
|
2011-01-30 14:34:42 +00:00
|
|
|
// types of filtering available
|
|
|
|
enum ImageFilterType { ImageFilterFast, ImageFilterGood };
|
|
|
|
// there's nothing to paint (adjust time_diff later)
|
2012-03-29 20:11:28 +00:00
|
|
|
virtual void idle();
|
2020-01-09 17:06:14 +00:00
|
|
|
virtual bool blocksForRetrace() const;
|
2020-01-09 17:18:22 +00:00
|
|
|
virtual bool syncsToVBlank() const;
|
2019-08-07 17:33:20 +00:00
|
|
|
virtual OverlayWindow* overlayWindow() const = 0;
|
Better handling for making the compositing OpenGL context current
With QtQuick2 it's possible that the scene graph rendering context either
lives in an own thread or uses the main GUI thread. In the latter case
it's the same thread as our compositing OpenGL context lives in. This
means our basic assumption that between two rendering passes the context
stays current does not hold.
The code already ensured that before we start a rendering pass the
context is made current, but there are many more possible cases. If we
use OpenGL in areas not triggered by the rendering loop but in response
to other events the context needs to be made current. This includes the
loading and unloading of effects (some effects use OpenGL in the static
effect check, in the ctor and dtor), background loading of texture data,
lazy loading after first usage invoked by shortcut, etc. etc.
To properly handle these cases new methods are added to EffectsHandler
to make the compositing OpenGL context current. These calls delegate down
into the scene. On non-OpenGL scenes they are noop, but on OpenGL they go
into the backend and make the context current. In addition they ensure
that Qt doesn't think that it's QOpenGLContext is current by calling
doneCurrent() on the QOpenGLContext::currentContext(). This unfortunately
causes an additional call to makeCurrent with a null context, but there
is no other way to tell Qt - it doesn't notice when a different context
is made current with low level API calls. In the multi-threaded
architecture this doesn't matter as ::currentContext() returns null.
A short evaluation showed that a transition to QOpenGLContext doesn't
seem feasible. Qt only supports either GLX or EGL while KWin supports
both and when entering the transition phase for Wayland, it would become
extremely tricky if our native platform is X11, but we want a Wayland
EGL context. A future solution might be to have a "KWin-QPA plugin" which
uses either xcb or Wayland and hides everything from Qt.
The API documentation is extended to describe when the effects-framework
ensures that an OpenGL context is current. The effects are changed to
make the context current in cases where it's not guaranteed. This has
been done by looking for creation or deletion of GLTextures and Shaders.
If there are other OpenGL usages outside the rendering loop, ctor/dtor
this needs to be changed, too.
2013-11-22 14:05:36 +00:00
|
|
|
|
|
|
|
virtual bool makeOpenGLContextCurrent();
|
|
|
|
virtual void doneOpenGLContextCurrent();
|
2020-10-12 06:45:05 +00:00
|
|
|
virtual bool supportsSurfacelessContext() const;
|
2020-10-15 09:27:00 +00:00
|
|
|
virtual bool supportsNativeFence() const;
|
Better handling for making the compositing OpenGL context current
With QtQuick2 it's possible that the scene graph rendering context either
lives in an own thread or uses the main GUI thread. In the latter case
it's the same thread as our compositing OpenGL context lives in. This
means our basic assumption that between two rendering passes the context
stays current does not hold.
The code already ensured that before we start a rendering pass the
context is made current, but there are many more possible cases. If we
use OpenGL in areas not triggered by the rendering loop but in response
to other events the context needs to be made current. This includes the
loading and unloading of effects (some effects use OpenGL in the static
effect check, in the ctor and dtor), background loading of texture data,
lazy loading after first usage invoked by shortcut, etc. etc.
To properly handle these cases new methods are added to EffectsHandler
to make the compositing OpenGL context current. These calls delegate down
into the scene. On non-OpenGL scenes they are noop, but on OpenGL they go
into the backend and make the context current. In addition they ensure
that Qt doesn't think that it's QOpenGLContext is current by calling
doneCurrent() on the QOpenGLContext::currentContext(). This unfortunately
causes an additional call to makeCurrent with a null context, but there
is no other way to tell Qt - it doesn't notice when a different context
is made current with low level API calls. In the multi-threaded
architecture this doesn't matter as ::currentContext() returns null.
A short evaluation showed that a transition to QOpenGLContext doesn't
seem feasible. Qt only supports either GLX or EGL while KWin supports
both and when entering the transition phase for Wayland, it would become
extremely tricky if our native platform is X11, but we want a Wayland
EGL context. A future solution might be to have a "KWin-QPA plugin" which
uses either xcb or Wayland and hides everything from Qt.
The API documentation is extended to describe when the effects-framework
ensures that an OpenGL context is current. The effects are changed to
make the context current in cases where it's not guaranteed. This has
been done by looking for creation or deletion of GLTextures and Shaders.
If there are other OpenGL usages outside the rendering loop, ctor/dtor
this needs to be changed, too.
2013-11-22 14:05:36 +00:00
|
|
|
|
2015-11-30 13:35:12 +00:00
|
|
|
virtual QMatrix4x4 screenProjectionMatrix() const;
|
|
|
|
|
2013-06-19 10:26:34 +00:00
|
|
|
/**
|
|
|
|
* Whether the Scene uses an X11 overlay window to perform compositing.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2013-06-19 10:26:34 +00:00
|
|
|
virtual bool usesOverlayWindow() const = 0;
|
2013-06-19 09:12:57 +00:00
|
|
|
|
2014-09-03 16:43:38 +00:00
|
|
|
virtual void triggerFence();
|
2013-06-19 09:12:57 +00:00
|
|
|
|
2014-07-22 11:11:19 +00:00
|
|
|
virtual Decoration::Renderer *createDecorationRenderer(Decoration::DecoratedClientImpl *) = 0;
|
|
|
|
|
2016-08-10 07:24:53 +00:00
|
|
|
/**
|
|
|
|
* Whether the Scene is able to drive animations.
|
|
|
|
* This is used as a hint to the effects system which effects can be supported.
|
|
|
|
* If the Scene performs software rendering it is supposed to return @c false,
|
|
|
|
* if rendering is hardware accelerated it should return @c true.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-08-10 07:24:53 +00:00
|
|
|
virtual bool animationsSupported() const = 0;
|
|
|
|
|
2017-08-08 15:13:59 +00:00
|
|
|
/**
|
|
|
|
* The render buffer used by an XRender based compositor scene.
|
|
|
|
* Default implementation returns XCB_RENDER_PICTURE_NONE
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2017-08-08 15:13:59 +00:00
|
|
|
virtual xcb_render_picture_t xrenderBufferPicture() const;
|
|
|
|
|
2017-08-09 04:56:23 +00:00
|
|
|
/**
|
|
|
|
* The QPainter used by a QPainter based compositor scene.
|
|
|
|
* Default implementation returns @c nullptr;
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2017-08-09 04:56:23 +00:00
|
|
|
virtual QPainter *scenePainter() const;
|
|
|
|
|
2017-08-11 12:59:09 +00:00
|
|
|
/**
|
|
|
|
* The render buffer used by a QPainter based compositor.
|
|
|
|
* Default implementation returns @c nullptr.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2020-11-09 13:39:36 +00:00
|
|
|
virtual QImage *qpainterRenderBuffer(int screenId) const;
|
2017-08-11 12:59:09 +00:00
|
|
|
|
2017-09-08 13:49:52 +00:00
|
|
|
/**
|
|
|
|
* The backend specific extensions (e.g. EGL/GLX extensions).
|
|
|
|
*
|
|
|
|
* Not the OpenGL (ES) extension!
|
|
|
|
*
|
|
|
|
* Default implementation returns empty list
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2017-09-08 13:49:52 +00:00
|
|
|
virtual QVector<QByteArray> openGLPlatformInterfaceExtensions() const;
|
|
|
|
|
2020-07-22 17:22:36 +00:00
|
|
|
virtual QSharedPointer<GLTexture> textureForOutput(AbstractOutput *output) const {
|
|
|
|
Q_UNUSED(output);
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2016-06-29 17:22:41 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
void frameRendered();
|
2017-09-08 20:30:18 +00:00
|
|
|
void resetCompositing();
|
2016-06-29 17:22:41 +00:00
|
|
|
|
2011-06-19 20:18:21 +00:00
|
|
|
public Q_SLOTS:
|
2011-06-21 10:30:42 +00:00
|
|
|
// a window has been closed
|
2013-06-24 07:53:11 +00:00
|
|
|
void windowClosed(KWin::Toplevel* c, KWin::Deleted* deleted);
|
2011-01-30 14:34:42 +00:00
|
|
|
protected:
|
2013-06-24 07:53:11 +00:00
|
|
|
virtual Window *createWindow(Toplevel *toplevel) = 0;
|
2020-03-13 16:41:56 +00:00
|
|
|
void createStackingOrder(const QList<Toplevel *> &toplevels);
|
2013-06-24 07:53:11 +00:00
|
|
|
void clearStackingOrder();
|
2011-01-30 14:34:42 +00:00
|
|
|
// shared implementation, starts painting the screen
|
2013-11-21 09:44:06 +00:00
|
|
|
void paintScreen(int *mask, const QRegion &damage, const QRegion &repaint,
|
Provide expected presentation time to effects
Effects are given the interval between two consecutive frames. The main
flaw of this approach is that if the Compositor transitions from the idle
state to "active" state, i.e. when there is something to repaint,
effects may see a very large interval between the last painted frame and
the current. In order to address this issue, the Scene invalidates the
timer that is used to measure time between consecutive frames before the
Compositor is about to become idle.
While this works perfectly fine with Xinerama-style rendering, with per
screen rendering, determining whether the compositor is about to idle is
rather a tedious task mostly because a single output can't be used for
the test.
Furthermore, since the Compositor schedules pointless repaints just to
ensure that it's idle, it might take several attempts to figure out
whether the scene timer must be invalidated if you use (true) per screen
rendering.
Ideally, all effects should use a timeline helper that is aware of the
underlying render loop and its timings. However, this option is off the
table because it will involve a lot of work to implement it.
Alternative and much simpler option is to pass the expected presentation
time to effects rather than time between consecutive frames. This means
that effects are responsible for determining how much animation timelines
have to be advanced. Typically, an effect would have to store the
presentation timestamp provided in either prePaint{Screen,Window} and
use it in the subsequent prePaint{Screen,Window} call to estimate the
amount of time passed between the next and the last frames.
Unfortunately, this is an API incompatible change. However, it shouldn't
take a lot of work to port third-party binary effects, which don't use the
AnimationEffect class, to the new API. On the bright side, we no longer
need to be concerned about the Compositor getting idle.
We do still try to determine whether the Compositor is about to idle,
primarily, because the OpenGL render backend swaps buffers on present,
but that will change with the ongoing compositing timing rework.
2020-11-20 15:44:04 +00:00
|
|
|
QRegion *updateRegion, QRegion *validRegion,
|
|
|
|
std::chrono::milliseconds presentTime,
|
|
|
|
const QMatrix4x4 &projection = QMatrix4x4(),
|
|
|
|
const QRect &outputGeometry = QRect(), qreal screenScale = 1.0);
|
2017-06-12 20:28:39 +00:00
|
|
|
// Render cursor texture in case hardware cursor is disabled/non-applicable
|
2020-10-26 07:39:55 +00:00
|
|
|
virtual void paintCursor(const QRegion ®ion) = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
friend class EffectsHandlerImpl;
|
|
|
|
// called after all effects had their paintScreen() called
|
2020-03-13 16:41:56 +00:00
|
|
|
void finalPaintScreen(int mask, const QRegion ®ion, ScreenPaintData& data);
|
2011-01-30 14:34:42 +00:00
|
|
|
// shared implementation of painting the screen in the generic
|
|
|
|
// (unoptimized) way
|
2020-03-13 16:41:56 +00:00
|
|
|
virtual void paintGenericScreen(int mask, const ScreenPaintData &data);
|
2011-01-30 14:34:42 +00:00
|
|
|
// shared implementation of painting the screen in an optimized way
|
2020-03-13 16:41:56 +00:00
|
|
|
virtual void paintSimpleScreen(int mask, const QRegion ®ion);
|
2011-01-30 14:34:42 +00:00
|
|
|
// paint the background (not the desktop background - the whole background)
|
2020-03-13 16:41:56 +00:00
|
|
|
virtual void paintBackground(const QRegion ®ion) = 0;
|
2020-04-24 17:11:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Notifies about starting to paint.
|
|
|
|
*
|
|
|
|
* @p damage contains the reported damage as suggested by windows and effects on prepaint calls.
|
|
|
|
*/
|
2020-10-30 07:39:17 +00:00
|
|
|
virtual void aboutToStartPainting(int screenId, const QRegion &damage);
|
2011-01-30 14:34:42 +00:00
|
|
|
// called after all effects had their paintWindow() called
|
2020-03-13 16:41:56 +00:00
|
|
|
void finalPaintWindow(EffectWindowImpl* w, int mask, const QRegion ®ion, WindowPaintData& data);
|
2011-01-30 14:34:42 +00:00
|
|
|
// shared implementation, starts painting the window
|
2020-03-13 16:41:56 +00:00
|
|
|
virtual void paintWindow(Window* w, int mask, const QRegion ®ion, const WindowQuadList &quads);
|
2011-01-30 14:34:42 +00:00
|
|
|
// called after all effects had their drawWindow() called
|
2020-03-13 16:41:56 +00:00
|
|
|
virtual void finalDrawWindow(EffectWindowImpl* w, int mask, const QRegion ®ion, WindowPaintData& data);
|
2013-02-18 22:17:46 +00:00
|
|
|
// let the scene decide whether it's better to paint more of the screen, eg. in order to allow a buffer swap
|
|
|
|
// the default is NOOP
|
|
|
|
virtual void extendPaintRegion(QRegion ®ion, bool opaqueFullscreen);
|
2012-03-29 18:17:57 +00:00
|
|
|
virtual void paintDesktop(int desktop, int mask, const QRegion ®ion, ScreenPaintData &data);
|
[libkwineffects] Introduce API to easily show a QtQuick scene in an effect
Summary:
EffectQuickView/Scene is a convenient class to render a QtQuick
scenegraph into an effect.
Current methods (such as present windows) involve creating an underlying
platform window which is expensive, causes a headache to filter out
again in the rest of the code, and only works as an overlay.
The new class exposes things more natively to an effect where we don't
mess with real windows, we can perform the painting anywhere in the view
and we don't have issues with hiding/closing.
QtQuick has both software and hardware accelerated modes, and kwin also
has 3 render backends. Every combination is supported.
* When used in OpenGL mode for both, we render into an FBO export the
texture ID then it's up to the effect to render that into a scene.
* When using software QtQuick rendering we blit into an image, upload
that into a KWinGLTexture which serves as an abstraction layer and
render that into the scene.
* When using GL for QtQuick and XRender/QPainter in kwin everything is
rendered into the internal FBO, blit and exported as an image.
* When using software rendering for both an image gets passed directly.
Mouse and keyboard events can be forwarded, only if the effect
intercepts them.
The class is meant to be generic enough that we can remove all the
QtQuick code from Aurorae.
The intention is also to replace EffectFrameImpl using this backend and
we can kill all of the EffectFrame code throughout the scenes.
The close button in present windows will also be ported to this,
simplifiying that code base.
Classes that handle the rendering and handling QML are intentionally
split so that in the future we can have a declarative effects API create
overlays from within the same context. Similar to how one can
instantiate windows from a typical QML scene.
Notes:
I don't like how I pass the kwin GL context from the backends into the
effect, but I need something that works with the library separation. It
also currently has wayland problem if I create a QOpenGLContext before
the QPA is set up with a scene - but I don't have anything better?
I know for the EffectFrame we need an API to push things through the
effects stack to handle blur/invert etc. Will deal with that when we
port the EffectFrame.
Test Plan: Used in an effect
Reviewers: #kwin, zzag
Reviewed By: #kwin, zzag
Subscribers: zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D24215
2019-09-27 15:06:37 +00:00
|
|
|
|
|
|
|
virtual void paintEffectQuickView(EffectQuickView *w) = 0;
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
// saved data for 2nd pass of optimized screen painting
|
|
|
|
struct Phase2Data {
|
2019-01-12 12:39:28 +00:00
|
|
|
Window *window = nullptr;
|
2011-01-30 14:34:42 +00:00
|
|
|
QRegion region;
|
|
|
|
QRegion clip;
|
2019-01-12 12:39:28 +00:00
|
|
|
int mask = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
WindowQuadList quads;
|
|
|
|
};
|
|
|
|
// The region which actually has been painted by paintScreen() and should be
|
|
|
|
// copied from the buffer to the screen. I.e. the region returned from Scene::paintScreen().
|
|
|
|
// Since prePaintWindow() can extend areas to paint, these changes would have to propagate
|
|
|
|
// up all the way from paintSimpleScreen() up to paintScreen(), so save them here rather
|
|
|
|
// than propagate them up in arguments.
|
|
|
|
QRegion painted_region;
|
2013-11-21 09:44:06 +00:00
|
|
|
// Additional damage that needs to be repaired to bring a reused back buffer up to date
|
|
|
|
QRegion repaint_region;
|
|
|
|
// The dirty region before it was unioned with repaint_region
|
|
|
|
QRegion damaged_region;
|
2020-10-29 18:25:39 +00:00
|
|
|
// The screen that is being currently painted
|
|
|
|
int painted_screen = -1;
|
2012-03-29 18:17:57 +00:00
|
|
|
private:
|
2020-03-13 16:41:56 +00:00
|
|
|
void paintWindowThumbnails(Scene::Window *w, const QRegion ®ion, qreal opacity, qreal brightness, qreal saturation);
|
2012-03-29 18:17:57 +00:00
|
|
|
void paintDesktopThumbnails(Scene::Window *w);
|
Provide expected presentation time to effects
Effects are given the interval between two consecutive frames. The main
flaw of this approach is that if the Compositor transitions from the idle
state to "active" state, i.e. when there is something to repaint,
effects may see a very large interval between the last painted frame and
the current. In order to address this issue, the Scene invalidates the
timer that is used to measure time between consecutive frames before the
Compositor is about to become idle.
While this works perfectly fine with Xinerama-style rendering, with per
screen rendering, determining whether the compositor is about to idle is
rather a tedious task mostly because a single output can't be used for
the test.
Furthermore, since the Compositor schedules pointless repaints just to
ensure that it's idle, it might take several attempts to figure out
whether the scene timer must be invalidated if you use (true) per screen
rendering.
Ideally, all effects should use a timeline helper that is aware of the
underlying render loop and its timings. However, this option is off the
table because it will involve a lot of work to implement it.
Alternative and much simpler option is to pass the expected presentation
time to effects rather than time between consecutive frames. This means
that effects are responsible for determining how much animation timelines
have to be advanced. Typically, an effect would have to store the
presentation timestamp provided in either prePaint{Screen,Window} and
use it in the subsequent prePaint{Screen,Window} call to estimate the
amount of time passed between the next and the last frames.
Unfortunately, this is an API incompatible change. However, it shouldn't
take a lot of work to port third-party binary effects, which don't use the
AnimationEffect class, to the new API. On the bright side, we no longer
need to be concerned about the Compositor getting idle.
We do still try to determine whether the Compositor is about to idle,
primarily, because the OpenGL render backend swaps buffers on present,
but that will change with the ongoing compositing timing rework.
2020-11-20 15:44:04 +00:00
|
|
|
std::chrono::milliseconds m_expectedPresentTimestamp = std::chrono::milliseconds::zero();
|
2013-06-24 07:53:11 +00:00
|
|
|
QHash< Toplevel*, Window* > m_windows;
|
|
|
|
// windows in their stacking order
|
|
|
|
QVector< Window* > stacking_order;
|
2020-04-24 17:11:41 +00:00
|
|
|
// how many times finalPaintScreen() has been called
|
|
|
|
int m_paintScreenCount = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
};
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2017-08-10 16:13:42 +00:00
|
|
|
/**
|
|
|
|
* Factory class to create a Scene. Needs to be implemented by the plugins.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2017-08-10 16:13:42 +00:00
|
|
|
class KWIN_EXPORT SceneFactory : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.
The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.
Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.
A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!
The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.
The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, apol, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 16:52:26 +00:00
|
|
|
~SceneFactory() override;
|
2017-08-10 16:13:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns The created Scene, may be @c nullptr.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2017-08-10 16:13:42 +00:00
|
|
|
virtual Scene *create(QObject *parent = nullptr) const = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
explicit SceneFactory(QObject *parent);
|
|
|
|
};
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
// The base class for windows representations in composite backends
|
2020-06-10 06:13:35 +00:00
|
|
|
class Scene::Window : public QObject
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2020-06-10 06:13:35 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
public:
|
2020-06-10 06:13:35 +00:00
|
|
|
explicit Window(Toplevel *client, QObject *parent = nullptr);
|
|
|
|
~Window() override;
|
2011-01-30 14:34:42 +00:00
|
|
|
// perform the actual painting of the window
|
2020-03-13 16:41:56 +00:00
|
|
|
virtual void performPaint(int mask, const QRegion ®ion, const WindowPaintData &data) = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
// do any cleanup needed when the window's composite pixmap is discarded
|
[x11] Fix visual artifacts during interactive resize
Summary:
When a window is being interactively resized, its contents may jump. The
reason why that happens is because KWin renders partially resized client
window. Composite extension spec says that a window will get a new pixmap
each time it is resized or mapped. This applies to the frame window, but
not to the client window itself. If the client window is resized,
off-screen storage for the frame window won't be reallocated. Therefore,
KWin may render partially resized client window if the client doesn't
attempt to be in sync with our rendering loop. Currently, the only way
to do that is to use extended frame counters, which are not supported by
KWin.
So, in order to fix visual artifacts during interactive resize, we need
somehow forcefully re-allocate off-screen storage for the frame window.
Unfortunately, Composite extension doesn't provide any request to do
that, so the only option we have is to resize the frame window.
BUG: 415839
FIXED-IN: 5.18.0
Reviewers: #kwin
Subscribers: davidedmundson, ngraham, alexde, fredrik, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D26914
2020-02-03 11:29:43 +00:00
|
|
|
void discardPixmap();
|
|
|
|
void updatePixmap();
|
2011-01-30 14:34:42 +00:00
|
|
|
int x() const;
|
|
|
|
int y() const;
|
|
|
|
int width() const;
|
|
|
|
int height() const;
|
|
|
|
QRect geometry() const;
|
|
|
|
QPoint pos() const;
|
|
|
|
QSize size() const;
|
|
|
|
QRect rect() const;
|
|
|
|
// access to the internal window class
|
|
|
|
// TODO eventually get rid of this
|
2016-04-01 07:17:27 +00:00
|
|
|
Toplevel* window() const;
|
2011-01-30 14:34:42 +00:00
|
|
|
// should the window be painted
|
|
|
|
bool isPaintingEnabled() const;
|
|
|
|
void resetPaintingEnabled();
|
|
|
|
// Flags explaining why painting should be disabled
|
|
|
|
enum {
|
|
|
|
// Window will not be painted
|
|
|
|
PAINT_DISABLED = 1 << 0,
|
|
|
|
// Window will not be painted because it is deleted
|
|
|
|
PAINT_DISABLED_BY_DELETE = 1 << 1,
|
|
|
|
// Window will not be painted because of which desktop it's on
|
|
|
|
PAINT_DISABLED_BY_DESKTOP = 1 << 2,
|
|
|
|
// Window will not be painted because it is minimized
|
|
|
|
PAINT_DISABLED_BY_MINIMIZE = 1 << 3,
|
|
|
|
// Window will not be painted because it's not on the current activity
|
|
|
|
PAINT_DISABLED_BY_ACTIVITY = 1 << 5
|
2007-04-29 17:35:43 +00:00
|
|
|
};
|
2011-01-30 14:34:42 +00:00
|
|
|
void enablePainting(int reason);
|
|
|
|
void disablePainting(int reason);
|
|
|
|
// is the window visible at all
|
|
|
|
bool isVisible() const;
|
|
|
|
// is the window fully opaque
|
|
|
|
bool isOpaque() const;
|
2020-04-21 10:22:41 +00:00
|
|
|
// is the window shaded
|
|
|
|
bool isShaded() const;
|
2011-01-30 14:34:42 +00:00
|
|
|
// shape of the window
|
2019-09-27 10:33:42 +00:00
|
|
|
QRegion bufferShape() const;
|
2011-01-30 14:34:42 +00:00
|
|
|
QRegion clientShape() const;
|
2019-09-27 10:33:42 +00:00
|
|
|
QRegion decorationShape() const;
|
|
|
|
QPoint bufferOffset() const;
|
2011-01-30 14:34:42 +00:00
|
|
|
void discardShape();
|
2020-11-03 11:18:09 +00:00
|
|
|
void updateToplevel(Deleted *deleted);
|
2011-01-30 14:34:42 +00:00
|
|
|
// creates initial quad list for the window
|
|
|
|
virtual WindowQuadList buildQuads(bool force = false) const;
|
2011-04-03 09:31:33 +00:00
|
|
|
void updateShadow(Shadow* shadow);
|
|
|
|
const Shadow* shadow() const;
|
|
|
|
Shadow* shadow();
|
2013-05-10 10:07:56 +00:00
|
|
|
void referencePreviousPixmap();
|
|
|
|
void unreferencePreviousPixmap();
|
2020-06-10 06:18:32 +00:00
|
|
|
void discardQuads();
|
2020-04-21 08:55:51 +00:00
|
|
|
void preprocess();
|
2020-10-29 18:25:39 +00:00
|
|
|
void addRepaint(const QRegion ®ion);
|
|
|
|
void addLayerRepaint(const QRegion ®ion);
|
|
|
|
QRegion repaints(int screen) const;
|
|
|
|
void resetRepaints(int screen);
|
|
|
|
bool wantsRepaint() const;
|
2020-07-22 17:22:36 +00:00
|
|
|
|
|
|
|
virtual QSharedPointer<GLTexture> windowTexture() {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2013-05-10 10:07:56 +00:00
|
|
|
/**
|
|
|
|
* @brief Returns the WindowPixmap for this Window.
|
|
|
|
*
|
2019-01-11 13:36:17 +00:00
|
|
|
* If the WindowPixmap does not yet exist, this method will invoke createWindowPixmap.
|
2013-05-10 10:07:56 +00:00
|
|
|
* If the WindowPixmap is not valid it tries to create it, in case this succeeds the WindowPixmap is
|
|
|
|
* returned. In case it fails, the previous (and still valid) WindowPixmap is returned.
|
|
|
|
*
|
2019-01-11 13:36:17 +00:00
|
|
|
* @note This method can return @c NULL as there might neither be a valid previous nor current WindowPixmap
|
2013-05-10 10:07:56 +00:00
|
|
|
* around.
|
|
|
|
*
|
|
|
|
* The WindowPixmap gets casted to the type passed in as a template parameter. That way this class does not
|
|
|
|
* need to know the actual WindowPixmap subclass used by the concrete Scene implementations.
|
|
|
|
*
|
|
|
|
* @return The WindowPixmap casted to T* or @c NULL if there is no valid window pixmap.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2020-04-21 08:55:51 +00:00
|
|
|
template<typename T> T *windowPixmap() const;
|
|
|
|
template<typename T> T *previousWindowPixmap() const;
|
2020-09-08 14:27:14 +00:00
|
|
|
|
|
|
|
protected:
|
2020-11-04 11:00:07 +00:00
|
|
|
WindowQuadList makeDecorationQuads(const QRect *rects, const QRegion ®ion) const;
|
2020-09-08 14:27:14 +00:00
|
|
|
WindowQuadList makeContentsQuads() const;
|
2013-05-10 10:07:56 +00:00
|
|
|
/**
|
|
|
|
* @brief Factory method to create a WindowPixmap.
|
|
|
|
*
|
|
|
|
* The inheriting classes need to implement this method to create a new instance of their WindowPixmap subclass.
|
2019-01-11 13:36:17 +00:00
|
|
|
* @note Do not use WindowPixmap::create on the created instance. The Scene will take care of that.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2013-05-10 10:07:56 +00:00
|
|
|
virtual WindowPixmap *createWindowPixmap() = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
Toplevel* toplevel;
|
|
|
|
ImageFilterType filter;
|
2011-04-03 09:31:33 +00:00
|
|
|
Shadow *m_shadow;
|
2011-01-30 14:34:42 +00:00
|
|
|
private:
|
2020-10-29 18:25:39 +00:00
|
|
|
void reallocRepaints();
|
|
|
|
|
2013-05-10 10:07:56 +00:00
|
|
|
QScopedPointer<WindowPixmap> m_currentPixmap;
|
|
|
|
QScopedPointer<WindowPixmap> m_previousPixmap;
|
2020-10-29 18:25:39 +00:00
|
|
|
QVector<QRegion> m_repaints;
|
|
|
|
QVector<QRegion> m_layerRepaints;
|
2020-11-03 11:18:09 +00:00
|
|
|
SubSurfaceMonitor *m_subsurfaceMonitor = nullptr;
|
2013-05-10 10:07:56 +00:00
|
|
|
int m_referencePixmapCounter;
|
2011-01-30 14:34:42 +00:00
|
|
|
int disable_painting;
|
2019-09-27 10:33:42 +00:00
|
|
|
mutable QRegion m_bufferShape;
|
|
|
|
mutable bool m_bufferShapeIsValid = false;
|
2016-02-01 20:41:48 +00:00
|
|
|
mutable QScopedPointer<WindowQuadList> cached_quad_list;
|
2011-01-30 14:34:42 +00:00
|
|
|
Q_DISABLE_COPY(Window)
|
|
|
|
};
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-05-10 10:07:56 +00:00
|
|
|
/**
|
2019-01-12 10:31:32 +00:00
|
|
|
* @brief Wrapper for a pixmap of the Scene::Window.
|
2013-05-10 10:07:56 +00:00
|
|
|
*
|
|
|
|
* This class encapsulates the functionality to get the pixmap for a window. When initialized the pixmap is not yet
|
2019-01-12 10:31:32 +00:00
|
|
|
* mapped to the window and isValid will return @c false. The pixmap mapping to the window can be established
|
|
|
|
* through @ref create. If it succeeds isValid will return @c true, otherwise it will keep in the non valid
|
2013-05-10 10:07:56 +00:00
|
|
|
* state and it can be tried to create the pixmap mapping again (e.g. in the next frame).
|
|
|
|
*
|
|
|
|
* This class is not intended to be updated when the pixmap is no longer valid due to e.g. resizing the window.
|
|
|
|
* Instead a new instance of this class should be instantiated. The idea behind this is that a valid pixmap does not
|
|
|
|
* get destroyed, but can continue to be used. To indicate that a newer pixmap should in generally be around, one can
|
2019-01-12 10:31:32 +00:00
|
|
|
* use markAsDiscarded.
|
2013-05-10 10:07:56 +00:00
|
|
|
*
|
|
|
|
* This class is intended to be inherited for the needs of the compositor backends which need further mapping from
|
|
|
|
* the native pixmap to the respective rendering format.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2020-09-18 22:40:57 +00:00
|
|
|
class KWIN_EXPORT WindowPixmap : public QObject
|
2013-05-10 10:07:56 +00:00
|
|
|
{
|
2020-09-18 22:40:57 +00:00
|
|
|
Q_OBJECT
|
2013-05-10 10:07:56 +00:00
|
|
|
public:
|
|
|
|
virtual ~WindowPixmap();
|
|
|
|
/**
|
|
|
|
* @brief Tries to create the mapping between the Window and the pixmap.
|
|
|
|
*
|
2019-01-12 10:31:32 +00:00
|
|
|
* In case this method succeeds in creating the pixmap for the window, isValid will return @c true otherwise
|
2013-05-10 10:07:56 +00:00
|
|
|
* @c false.
|
|
|
|
*
|
|
|
|
* Inheriting classes should re-implement this method in case they need to add further functionality for mapping the
|
|
|
|
* native pixmap to the rendering format.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2013-05-10 10:07:56 +00:00
|
|
|
virtual void create();
|
2020-04-21 08:55:51 +00:00
|
|
|
/**
|
|
|
|
* @brief Recursively updates the mapping between the WindowPixmap and the buffer.
|
|
|
|
*/
|
|
|
|
virtual void update();
|
2013-05-10 10:07:56 +00:00
|
|
|
/**
|
|
|
|
* @return @c true if the pixmap has been created and is valid, @c false otherwise
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-09-09 07:41:05 +00:00
|
|
|
virtual bool isValid() const;
|
2020-04-21 09:11:41 +00:00
|
|
|
/**
|
|
|
|
* Returns @c true if this is the root window pixmap; otherwise returns @c false.
|
|
|
|
*/
|
|
|
|
bool isRoot() const;
|
2013-05-10 10:07:56 +00:00
|
|
|
/**
|
|
|
|
* @return The native X11 pixmap handle
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2013-05-10 10:07:56 +00:00
|
|
|
xcb_pixmap_t pixmap() const;
|
2015-02-09 17:56:05 +00:00
|
|
|
/**
|
|
|
|
* @return The Wayland BufferInterface for this WindowPixmap.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2020-09-18 22:40:57 +00:00
|
|
|
KWaylandServer::BufferInterface *buffer() const;
|
2015-08-18 12:40:26 +00:00
|
|
|
const QSharedPointer<QOpenGLFramebufferObject> &fbo() const;
|
2019-08-26 07:44:04 +00:00
|
|
|
QImage internalImage() const;
|
2013-05-10 10:07:56 +00:00
|
|
|
/**
|
|
|
|
* @brief Whether this WindowPixmap is considered as discarded. This means the window has changed in a way that a new
|
|
|
|
* WindowPixmap should have been created already.
|
|
|
|
*
|
|
|
|
* @return @c true if this WindowPixmap is considered as discarded, @c false otherwise.
|
|
|
|
* @see markAsDiscarded
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2013-05-10 10:07:56 +00:00
|
|
|
bool isDiscarded() const;
|
|
|
|
/**
|
2019-01-12 10:31:32 +00:00
|
|
|
* @brief Marks this WindowPixmap as discarded. From now on isDiscarded will return @c true. This method should
|
2013-05-10 10:07:56 +00:00
|
|
|
* only be used by the Window when it changes in a way that a new pixmap is required.
|
|
|
|
*
|
|
|
|
* @see isDiscarded
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2013-05-10 10:07:56 +00:00
|
|
|
void markAsDiscarded();
|
2020-04-21 10:22:41 +00:00
|
|
|
/**
|
|
|
|
* Returns the position of the WindowPixmap relative to the upper left corner of the parent.
|
|
|
|
*
|
|
|
|
* This method returns the position of the WindowPixmap relative to the upper left corner
|
|
|
|
* of the window pixmap if parent() is @c null.
|
|
|
|
*
|
|
|
|
* The upper left corner of the parent window pixmap corresponds to (0, 0).
|
|
|
|
*/
|
|
|
|
QPoint position() const;
|
|
|
|
/**
|
|
|
|
* Returns the position of the WindowPixmap relative to the upper left corner of the window
|
|
|
|
* frame. Note that position() returns the position relative to the parent WindowPixmap.
|
|
|
|
*
|
|
|
|
* The upper left corner of the window frame corresponds to (0, 0).
|
|
|
|
*/
|
|
|
|
QPoint framePosition() const;
|
2013-05-13 06:17:28 +00:00
|
|
|
/**
|
|
|
|
* The size of the pixmap.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2013-05-13 06:17:28 +00:00
|
|
|
const QSize &size() const;
|
2020-04-21 10:22:41 +00:00
|
|
|
/**
|
|
|
|
* Returns the device pixel ratio for the attached buffer. This is the ratio between device
|
|
|
|
* pixels and logical pixels.
|
|
|
|
*/
|
|
|
|
qreal scale() const;
|
|
|
|
/**
|
|
|
|
* Returns the region that specifies the area inside the attached buffer with the actual
|
|
|
|
* client's contents.
|
|
|
|
*
|
|
|
|
* The upper left corner of the attached buffer corresponds to (0, 0).
|
|
|
|
*/
|
|
|
|
QRegion shape() const;
|
2020-09-08 14:27:14 +00:00
|
|
|
/**
|
|
|
|
* Returns the region that specifies the opaque area inside the attached buffer.
|
|
|
|
*
|
|
|
|
* The upper left corner of the attached buffer corresponds to (0, 0).
|
|
|
|
*/
|
|
|
|
QRegion opaque() const;
|
2019-12-02 17:36:13 +00:00
|
|
|
/**
|
|
|
|
* The geometry of the Client's content inside the pixmap. In case of a decorated Client the
|
|
|
|
* pixmap also contains the decoration which is not rendered into this pixmap, though. This
|
|
|
|
* contentsRect tells where inside the complete pixmap the real content is.
|
|
|
|
*/
|
|
|
|
const QRect &contentsRect() const;
|
2013-05-10 10:07:56 +00:00
|
|
|
/**
|
|
|
|
* @brief Returns the Toplevel this WindowPixmap belongs to.
|
|
|
|
* Note: the Toplevel can change over the lifetime of the WindowPixmap in case the Toplevel is copied to Deleted.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-04-01 07:17:27 +00:00
|
|
|
Toplevel *toplevel() const;
|
2020-04-21 10:22:41 +00:00
|
|
|
/**
|
|
|
|
* Returns @c true if the attached buffer has an alpha channel; otherwise returns @c false.
|
|
|
|
*/
|
|
|
|
bool hasAlphaChannel() const;
|
2020-05-23 15:07:54 +00:00
|
|
|
/**
|
|
|
|
* Maps the specified @a point from the window pixmap coordinates to the window local coordinates.
|
|
|
|
*/
|
|
|
|
QPointF mapToWindow(const QPointF &point) const;
|
|
|
|
/**
|
|
|
|
* Maps the specified @a point from the window pixmap coordinates to the buffer pixel coordinates.
|
|
|
|
*/
|
|
|
|
QPointF mapToBuffer(const QPointF &point) const;
|
2020-09-08 14:27:14 +00:00
|
|
|
/**
|
|
|
|
* Maps the specified @a region from the window pixmap coordinates to the global screen coordinates.
|
|
|
|
*/
|
|
|
|
QRegion mapToGlobal(const QRegion ®ion) const;
|
2015-02-11 10:00:12 +00:00
|
|
|
|
2016-03-21 15:37:45 +00:00
|
|
|
/**
|
|
|
|
* @returns the parent WindowPixmap in the sub-surface tree
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-03-21 15:37:45 +00:00
|
|
|
WindowPixmap *parent() const {
|
|
|
|
return m_parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns the current sub-surface tree
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-03-21 15:37:45 +00:00
|
|
|
QVector<WindowPixmap*> children() const {
|
|
|
|
return m_children;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns the subsurface this WindowPixmap is for if it is not for a root window
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2020-10-31 15:09:34 +00:00
|
|
|
KWaylandServer::SubSurfaceInterface *subSurface() const;
|
2016-03-21 15:37:45 +00:00
|
|
|
|
2016-04-01 07:19:00 +00:00
|
|
|
/**
|
|
|
|
* @returns the surface this WindowPixmap references, might be @c null.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2020-04-29 15:18:41 +00:00
|
|
|
KWaylandServer::SurfaceInterface *surface() const;
|
2016-04-01 07:19:00 +00:00
|
|
|
|
2015-02-11 10:00:12 +00:00
|
|
|
protected:
|
|
|
|
explicit WindowPixmap(Scene::Window *window);
|
2020-10-31 15:09:34 +00:00
|
|
|
explicit WindowPixmap(KWaylandServer::SubSurfaceInterface *subSurface, WindowPixmap *parent);
|
|
|
|
virtual WindowPixmap *createChild(KWaylandServer::SubSurfaceInterface *subSurface);
|
2013-05-10 10:07:56 +00:00
|
|
|
/**
|
|
|
|
* @return The Window this WindowPixmap belongs to
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2013-05-10 10:07:56 +00:00
|
|
|
Scene::Window *window();
|
2015-02-09 17:56:05 +00:00
|
|
|
|
2016-03-21 15:37:45 +00:00
|
|
|
/**
|
|
|
|
* Sets the sub-surface tree to @p children.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-03-21 15:37:45 +00:00
|
|
|
void setChildren(const QVector<WindowPixmap*> &children) {
|
|
|
|
m_children = children;
|
|
|
|
}
|
|
|
|
|
2013-05-10 10:07:56 +00:00
|
|
|
private:
|
2020-09-18 22:40:57 +00:00
|
|
|
void setBuffer(KWaylandServer::BufferInterface *buffer);
|
|
|
|
void clear();
|
|
|
|
|
2013-05-10 10:07:56 +00:00
|
|
|
Scene::Window *m_window;
|
|
|
|
xcb_pixmap_t m_pixmap;
|
|
|
|
QSize m_pixmapSize;
|
|
|
|
bool m_discarded;
|
2019-12-02 17:36:13 +00:00
|
|
|
QRect m_contentsRect;
|
2020-09-18 22:40:57 +00:00
|
|
|
KWaylandServer::BufferInterface *m_buffer = nullptr;
|
2015-08-18 12:40:26 +00:00
|
|
|
QSharedPointer<QOpenGLFramebufferObject> m_fbo;
|
2019-08-26 07:44:04 +00:00
|
|
|
QImage m_internalImage;
|
2016-03-21 15:37:45 +00:00
|
|
|
WindowPixmap *m_parent = nullptr;
|
|
|
|
QVector<WindowPixmap*> m_children;
|
2020-04-29 15:18:41 +00:00
|
|
|
QPointer<KWaylandServer::SubSurfaceInterface> m_subSurface;
|
2013-05-10 10:07:56 +00:00
|
|
|
};
|
|
|
|
|
2010-07-18 16:32:37 +00:00
|
|
|
class Scene::EffectFrame
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
EffectFrame(EffectFrameImpl* frame);
|
|
|
|
virtual ~EffectFrame();
|
2020-03-13 16:41:56 +00:00
|
|
|
virtual void render(const QRegion ®ion, double opacity, double frameOpacity) = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
virtual void free() = 0;
|
|
|
|
virtual void freeIconFrame() = 0;
|
|
|
|
virtual void freeTextFrame() = 0;
|
|
|
|
virtual void freeSelection() = 0;
|
|
|
|
virtual void crossFadeIcon() = 0;
|
|
|
|
virtual void crossFadeText() = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
EffectFrameImpl* m_effectFrame;
|
|
|
|
};
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
inline
|
|
|
|
int Scene::Window::x() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->x();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
inline
|
|
|
|
int Scene::Window::y() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->y();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
inline
|
|
|
|
int Scene::Window::width() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->width();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
inline
|
|
|
|
int Scene::Window::height() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->height();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
inline
|
|
|
|
QRect Scene::Window::geometry() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2019-09-27 10:01:10 +00:00
|
|
|
return toplevel->frameGeometry();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
inline
|
|
|
|
QSize Scene::Window::size() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->size();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
inline
|
|
|
|
QPoint Scene::Window::pos() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->pos();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
inline
|
|
|
|
QRect Scene::Window::rect() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->rect();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
inline
|
2016-04-01 07:17:27 +00:00
|
|
|
Toplevel* Scene::Window::window() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-04-03 09:31:33 +00:00
|
|
|
inline
|
|
|
|
const Shadow* Scene::Window::shadow() const
|
|
|
|
{
|
|
|
|
return m_shadow;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
Shadow* Scene::Window::shadow()
|
|
|
|
{
|
|
|
|
return m_shadow;
|
|
|
|
}
|
|
|
|
|
2013-05-10 10:07:56 +00:00
|
|
|
inline
|
2020-09-18 22:40:57 +00:00
|
|
|
KWaylandServer::BufferInterface *WindowPixmap::buffer() const
|
2013-05-10 10:07:56 +00:00
|
|
|
{
|
2015-02-09 17:56:05 +00:00
|
|
|
return m_buffer;
|
2013-05-10 10:07:56 +00:00
|
|
|
}
|
|
|
|
|
2015-08-18 12:40:26 +00:00
|
|
|
inline
|
|
|
|
const QSharedPointer<QOpenGLFramebufferObject> &WindowPixmap::fbo() const
|
|
|
|
{
|
|
|
|
return m_fbo;
|
|
|
|
}
|
|
|
|
|
2019-08-26 07:44:04 +00:00
|
|
|
inline
|
|
|
|
QImage WindowPixmap::internalImage() const
|
|
|
|
{
|
|
|
|
return m_internalImage;
|
|
|
|
}
|
|
|
|
|
2013-05-10 10:07:56 +00:00
|
|
|
template <typename T>
|
|
|
|
inline
|
2020-04-21 08:55:51 +00:00
|
|
|
T *Scene::Window::windowPixmap() const
|
2013-05-10 10:07:56 +00:00
|
|
|
{
|
2020-06-02 07:54:55 +00:00
|
|
|
if (m_currentPixmap && m_currentPixmap->isValid()) {
|
2013-05-10 10:07:56 +00:00
|
|
|
return static_cast<T*>(m_currentPixmap.data());
|
2020-06-02 07:54:55 +00:00
|
|
|
}
|
|
|
|
if (m_previousPixmap && m_previousPixmap->isValid()) {
|
2013-05-10 10:07:56 +00:00
|
|
|
return static_cast<T*>(m_previousPixmap.data());
|
|
|
|
}
|
2020-06-02 07:54:55 +00:00
|
|
|
return nullptr;
|
2013-05-10 10:07:56 +00:00
|
|
|
}
|
|
|
|
|
2013-05-13 06:17:28 +00:00
|
|
|
template <typename T>
|
|
|
|
inline
|
2020-04-21 08:55:51 +00:00
|
|
|
T *Scene::Window::previousWindowPixmap() const
|
2013-05-13 06:17:28 +00:00
|
|
|
{
|
|
|
|
return static_cast<T*>(m_previousPixmap.data());
|
|
|
|
}
|
|
|
|
|
2013-05-10 10:07:56 +00:00
|
|
|
inline
|
2016-04-01 07:17:27 +00:00
|
|
|
Toplevel* WindowPixmap::toplevel() const
|
2013-05-10 10:07:56 +00:00
|
|
|
{
|
|
|
|
return m_window->window();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
xcb_pixmap_t WindowPixmap::pixmap() const
|
|
|
|
{
|
|
|
|
return m_pixmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
bool WindowPixmap::isDiscarded() const
|
|
|
|
{
|
|
|
|
return m_discarded;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
void WindowPixmap::markAsDiscarded()
|
|
|
|
{
|
|
|
|
m_discarded = true;
|
|
|
|
m_window->referencePreviousPixmap();
|
|
|
|
}
|
|
|
|
|
2019-12-02 17:36:13 +00:00
|
|
|
inline
|
|
|
|
const QRect &WindowPixmap::contentsRect() const
|
|
|
|
{
|
|
|
|
return m_contentsRect;
|
|
|
|
}
|
|
|
|
|
2013-05-13 06:17:28 +00:00
|
|
|
inline
|
|
|
|
const QSize &WindowPixmap::size() const
|
|
|
|
{
|
|
|
|
return m_pixmapSize;
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
} // namespace
|
|
|
|
|
2017-08-10 16:13:42 +00:00
|
|
|
Q_DECLARE_INTERFACE(KWin::SceneFactory, "org.kde.kwin.Scene")
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
#endif
|