Commit Graph

642 Commits (2c7b1cf76206541fbebeeb19ab22a928895f1819)

Author SHA1 Message Date
Martin Gräßlin 3be6ff9f12 [kwineffects] Pass screen projection matrix to WindowPaintData
The screen projection matrix is needed if an effect wants to customize
the modelview projection matrix while rendering a window and keeping
the currently applied screen projection and transformation.
2016-01-25 14:11:54 +01:00
Martin Gräßlin f284ef814c Pass projection matrix to ScreenPaintData
With this change a new ctor overload is added to ScreenPaintData
which allows passing a projection matrix through the effects. This
allows effects to put up custom shaders with a shared projection matrix
and without having to calculate it themselves.

The projection matrix is a read-only information for the effects. There
is no way to change or overwrite it.
2016-01-25 14:11:54 +01:00
Martin Gräßlin 778a7fd1a0 [kwinglutils] Add a ShaderTraits variant to ShaderBinder
Simplifies binding a Shader with traits.
2016-01-25 14:11:54 +01:00
Thomas Lübking c7aefc6b6b skip SWAP_BEHAVIOR_PRESERVED for supportsBufferAge
pointless and unsupported on latter MESA/DRI3
http://lists.freedesktop.org/archives/mesa-dev/2015-November/100869.html

Thanks to Uriy Zhuravlev for reporting and investigation

BUG: 356992
CCBUG: 356882
FIXED-IN: 5.5.4
REVIEW: 126783
2016-01-18 22:32:10 +01:00
Michael Pyne bcc36b87fb Avoid undefined behavior in nearestPowerOfTwo.
The way nearestPowerOfTwo is currently defined allows for the possibility of
left-shifting an int by 32 bits or more, which is undefined behavior on
platforms where int is 32 bits, and is something that can happen here if `s`
is equal to 31 by the end of the loop. Noted by Coverity as CID 1291191.

This patch takes an algorithm to perform the same operation from Hank Warren
Jr.'s book "Hacker's Delight", which should avoid UB.

REVIEW:126540
2015-12-28 17:08:15 -05:00
Martin Gräßlin 416d8060cf Don't query for GL_CONTEXT_FLAGS if not at least OpenGL 3.0
Patch by Thomas Lübking.

BUG: 355522
2015-11-19 11:20:33 +01:00
Martin Gräßlin 01451eea36 Revert "Handle conflicts between epoxy and manually resolved function pointers"
This reverts commit ac1dbac8b1.
2015-11-17 14:58:59 +01:00
Martin Gräßlin 1d75cd26fb Verify that context is robust before resolving robust functions
The extensions specify that you are only allwoed to use the robust
functions if the context is robust. Given that we need to query
whether the robust is context and fall back to our workaround if
the context is not robust.

REVIEW: 126051
2015-11-16 09:08:14 +01:00
Martin Gräßlin bcf76c0d2f [libkwinglutils] Fix regression in OpenGL version parsing
QByteArray seems to not like a truncate or left with -1.

Reviewed-By: Rohan Garg
2015-11-12 17:14:36 +01:00
Martin Gräßlin ac1dbac8b1 Handle conflicts between epoxy and manually resolved function pointers
For the functions from GL_FOO_robustness we want to resolve it by
ourselves in order to add a custom implementation if it's not available.
Unfortunately once epoxy.h is included this breaks as epoxy defines the
names and so through the preprocessor epoxy always wins.

So we need different names: all functions from robustness get a "kwin"
prefix and the usage is changed everywhere in kwin source code.

REVIEW: 125883
2015-11-11 08:04:29 +01:00
Nick Shaforostoff 3a8d7d866a optimize string operations
-use qstringliteral only when necessary (i.e. not in concat or comparison)
-use qbytearray instead of qstring when dealing with latin1 input and output (glplatform)
-use qstringref to extract numbers from strings (glplatform)
-define qt_use_qstringbuilder to optimize all string concatenations
-anidata: use ctor init lists, add windowType member initialization

REVIEW: 125933
2015-11-05 14:14:06 +00:00
Martin Gräßlin aa43852301 Remove build checks for gles or gl
Also removes the building of the kwinglesutils, there's only
kwinglutils now.

REVIEW: 125865
2015-11-03 09:29:37 +01:00
Martin Gräßlin d5a5725db1 Remove remaining compile time checks for OpenGLES 2015-11-03 09:29:31 +01:00
Martin Gräßlin 03231942bb Bind building of glx support on whether epoxy has a glx header
So far it was bound to whether we build for GLES. But this is
semantically wrong. It might be possible that even on desktop gl
epoxy is built without GLX support, thus we need to reflect this.

This change ensures that epoxy/glx.h is only included if available,
that relevant code is bound to it and that checks are in place to
enforce EGL if not build with glx support.

In addtion the glxbackend.cpp is now only included in the build set
if available.
2015-11-03 09:29:31 +01:00
Martin Gräßlin 9919627106 [kwineffects] Runtime checks for GLES in ColorCorrection 2015-11-03 09:29:31 +01:00
Martin Gräßlin 49d8502567 [kwineffects] Runtime depend on gles in GLPlatform 2015-11-03 09:29:31 +01:00
Martin Gräßlin fc2805d218 Turn compile time checks to runtime check in kwinglutils.cpp
Only those which truly are different are kept as compile time checks.
In addition the index buffer is made available to GLES as in principle
all required functionality is available on gles.

REVIEW: 125865
2015-11-03 09:29:31 +01:00
Martin Gräßlin 99ddcfbac0 [glplatform] Ensure glsl is supported with OpenGLES
No matter what our checks say on OpenGLES we have shaders.
2015-11-03 09:29:31 +01:00
Martin Gräßlin 1170303fc6 [kwineffects] Runtime detect whether we are on GLES in GLPlatform
We detect from OpenGL version string whether we are on OpenGL ES
instead of using a compile time check.
2015-11-03 09:29:31 +01:00
Martin Gräßlin 5d37ccfce0 Drop PreventScreenLocking electric border
It was broken on so many ways, it's unbelievable:
* action was read but did nothing
* config was saved into a different file than read from

REVIEW: 125701
CCBUG: 331841
2015-10-21 08:14:50 +02:00
Martin Gräßlin c408e9ccec Drop remaning code for ShowDashboard
Removes the ElectricAction for ShowDashboard and the relevant code
in screenedges and the KCM.

Also a leftover in the glide effect.

REVIEW: 125700
BUG: 353928
2015-10-21 08:12:01 +02:00
Martin Gräßlin 0c448f2ed2 Merge branch 'Plasma/5.4' 2015-09-14 16:52:06 +02:00
Marco Martin 5a55727056 support the slide protocol
take and apply thhe informations from the wayland slide
protocol in the sliding popups effect

REVIEW:125120
2015-09-14 16:39:39 +02:00
Martin Gräßlin 5fb67414d2 [libkwineffects] Proper no-size check in WindowQuadList::splitAt(X|Y)
A quad might have a null size in case it has a null width or null height.
Not just one dimension.

BUG: 236353
BUG: 210467
FIXED-IN: 5.4.2
REVIEW: 125131
2015-09-10 10:43:06 +02:00
Marco Martin 3f5bf65a9e Use the kwayland blur protocol in the blur effect
use the new blur protocol to fetch information about the
region of blur behind to apply to windows like Plasma::Dialog
REVIEW:125017
2015-09-02 14:43:44 +02:00
Martin Gräßlin c24e315a9b Drop build option KWIN_BUILD_EGL
It doesn't make much sense any more as we do no longer link EGL since the
switch to epoxy. And epoxy pulls it in at runtime if needed.
Even more on Wayland it's just plain stupid to have EGL disabled. So
removing the option just simplifies our code base without any
disadvantages.

REVIEW: 124695
2015-08-11 11:15:25 +02:00
Martin Gräßlin 57c521c214 [libkwineffects] Introduce logging categories for libkwineffects 2015-07-31 12:16:15 +02:00
Aleix Pol 6f345f4915 Clean debug output
Removes endl in the end of qDebug.
Removes the \n in the end of opengl output.

REVIEW: 124320
2015-07-20 13:36:27 +02:00
Martin Gräßlin c31bb6d46f Drop KF5::Service dependency where it's no longer needed 2015-07-07 09:53:48 +02:00
Nerdopolis Turfwalker 924b66c4d5 Check whether it's platform xcb before calling QX11Info::display()
Internally QX11Info::display() calls into QPA native interface and
tries to resolve the nativeResourceForIntegration for "display".
Unfortunately this key also exists in other QPA plugins, e.g. in
QtWayland.

Calling without a check on platform results on wayland qpa in
wl_display* being casted into Display*.

REVIEW: 124203
2015-06-29 13:56:56 +02:00
Martin Gräßlin 59a6c9ddf9 [libkwineffects] OpenGL ES 3.0 supports glBlitFramebuffer 2015-06-24 09:39:02 +02:00
David Edmundson 42768d515a Add missing include
Reviewed-by: Martin G
2015-05-12 14:26:48 +01:00
Martin Gräßlin 4bf479aca2 [libkwineffects] GL_NONE instead of None in GLTexture
It's about GL not about Xlib, so use GL_NONE instead of None.
Additional bonus: it compiles if the file does not include Xlib.
2015-05-11 16:25:00 +02:00
Martin Gräßlin 713c6b25dc [kwinglutils] Init glVersion on gles
The glVersion was not set at all for gles causing any code doing a
hasGLVersion check to fail which means that the compositor doesn't
start at all, because it has a hasGLVersion(2, 0) check.

The complete ifdef is no longer needed. The used additional glGetStringi
is also available in gles 3.0, thus epoxy can handle it quite well
without a need for ifdef.

Unfortunately the version string can be "strange" on GLES. On desktop
it looks like: "3.0 some driver foo", on GLES it could also be:
"OpenGL ES 3.0 some driver bar". Thus to make the logic work we are
first removing any leading "OpenGL ES " and hope that then the version
is encoded just like on GL.
2015-05-08 08:53:34 +02:00
Thomas Lübking c5bb84469d make window elevation scriptable 2015-04-07 23:59:17 +02:00
Thomas Lübking 4a9b56d950 forward showingDesktop signal to effects 2015-04-07 23:59:17 +02:00
Martin Gräßlin f1f87c7a7d Guard access to Display in GLPlatform::getXServerVersion
On wayland OpenGL might get initialized before we have a connection
to the XServer and we might only have an xcb connection. So let's
guard the access.
2015-03-17 10:20:19 +01:00
Martin Gräßlin 8c15da99ae Use property for x11AppScreen in KWin::Application
Already provided by KWin::Application so let's use it instead of
QX11Info::appScreen.

REVIEW: 122683
2015-03-17 09:44:53 +01:00
Martin Gräßlin 0d51952d78 Provide x11Connection as a property on the KWin::Application
KWin::connection() uses the property to resolve the value instead of
using QX11Info. In practice this doesn't change anything at the moment,
but allows kwin_wayland to provide an xcb connection without depending
on QX11Info.

As we cannot make xcb_connection_t* available as a metatype, the
property's type is set to void*.
2015-03-17 09:44:53 +01:00
Martin Gräßlin fe9873e4b1 Provide x11RootWindow as a property on the KWin::Application
KWin::rootWindow() uses the property to resolve the value instead of
using QX11Info. In practice this doesn't change anything at the moment,
but allows kwin_wayland to provide a root window without depending on
QX11Info.
2015-03-17 09:44:53 +01:00
Martin Gräßlin d95ab94f0a Migrate away from QX11Info::appTime
The porting to Qt5 broke the timestamp handling in many areas. A deeper
look into Qt's xcb plugin shows that the appTime handling is not
sufficient for KWin's need. E.g. the time is only updated in response to
a property notify event if it's for a Qt created window, which is hardly
ever the case in KWin. Another example is that key press/release events
never updated the appTime.

As the functionality in Qt is rather trivial we can do the timestamp
handling ourselves. We filter all events anyway and it is slightly faster
as we don't have to go through the QPA interface any more.

REVIEW: 122636
2015-02-23 11:02:59 +01:00
Martin Gräßlin caf99f83d5 Require Qt 5.4
REVIEW: 122617
2015-02-19 10:56:50 +01:00
Martin Gräßlin 230f8dea24 Merge branch 'Plasma/5.2' 2015-02-19 10:56:37 +01:00
Martin Gräßlin 7bbb68aad6 Check GL version and/or extension for using texture format GL_R8
BUG: 344301
FIXED-IN: 5.2.1
REVIEW: 122615
2015-02-18 09:09:50 +01:00
Martin Gräßlin 5c4f1dffa3 Merge branch 'Plasma/5.2' 2015-02-11 15:32:28 +01:00
Martin Gräßlin d344b6cc3d Fix glPixelStore in GLTexture::update
Resetting glPixelStore is bound to the variable useUnpack, but setting
was only bound to a subset of the checks going into useUnpack variable.
This could cause an assert if one updated with a QImage not in format
ARGB32_Premultiplied.

REVIEW: 122521
2015-02-11 15:31:51 +01:00
Thomas Lübking 31cfd02756 forward cursorshape changes to effectshandler
CCBUG: 322088
REVIEW: 122468
2015-02-10 21:41:39 +01:00
Kai Uwe Broulik e814a60045 Add isOnScreenDisplay to EffectWindow 2015-01-31 19:45:47 +01:00
Tobias C. Berner ef3f0f753b Add <array> include where needed, to make it build on FreeBSD.
REVIEW: 122090
2015-01-17 15:22:11 +02:00
Martin Gräßlin 6b0ae95b80 Increase so-version for kwineffect libraries
Known ABI changes in at least GLTexture, probably more places.
2015-01-09 16:03:23 +01:00
Thomas Lübking f61d3ade84 shortcut rendering textures for empty an rect
it makes no sense and there's a good chance
that in this case m_vbo is still nullptr and
it will not be created since d->m_cachedSize
will be an empty size as well
-> nullptr access -> crash

BUG: 337090
FIXED-IN: 5.2
2015-01-08 00:29:04 +01:00
Fredrik Höglund 35110d72c6 Avoid converting images in GLTexture when possible
Don't convert the QImage when the image format can be specified as
a format/type combination to glTex(Sub)Image().
2014-12-30 21:22:00 +01:00
Fredrik Höglund 7fd4cf0227 Add GLTexture::setSwizzle()
This method allows the caller to specify which component of a texel
is placed in each respective component of the vector returned to the
shader.
2014-12-30 21:19:49 +01:00
Fredrik Höglund 4d738b86ea Add an internalFormat parameter to the GLTexture ctor
This parameter is ignored on GLES.
2014-12-30 21:19:49 +01:00
Fredrik Höglund 74b65fcd00 Add support for GL_ARB_texture_storage
Use glTexStorage2D() to allocate storage for the texture. The structure
of the resulting texture becomes immutable and the texture is always
mipmap complete.  This allows the driver to skip the mipmap consistency
checks when validating the texture at draw time.
2014-12-14 18:33:52 +01:00
Fredrik Höglund 450be6a378 Add a levels parameter to the GLTexture ctor
Prior to this commit we didn't know if mipmaps were going to be used
when we created the GL texture, which meant that we couldn't tell the
driver whether to allocate storage for mipmaps or not.

This resulted in one of two things happening depending on the driver;
either it would allocate storage for mipmaps that in most cases would
never be used, or it wouldn't and would later be forced to reallocate
the texture when mipmaps were added.

By adding this parameter we can now explicitly tell the driver how
many mipmap levels will be used.

The parameter is only added to the non-image constructor for now. The
image constructor is changed to only allocate a single level, which
matches how textures created from images are used in kwin. This may
need to be revisited in the future.
2014-12-14 18:33:52 +01:00
Fredrik Höglund ccf1bad426 Make mipmap filters other than GL_LINEAR_MIPMAP_LINEAR work
GLTexture would set both the minification and magnification filters
to GL_NEAREST if the texture filter was set to any mipmap filter other
than GL_LINEAR_MIPMAP_LINEAR.
2014-12-14 18:33:52 +01:00
Fredrik Höglund aefadfaa6a Don't generate mipmaps in GLTexture::bind()
This code is broken in a number of different ways; firstly by assuming
that the mipmaps need to be regenerated when the texture filter has
changed. Secondly by preventing mipmaps from being specified by other
means.

This commit removes the code from bind() and adds a generateMipmaps()
method instead.
2014-12-14 18:33:52 +01:00
Fredrik Höglund f8d1a0868a Test the generated shaders on startup
Compile and bind each shader in turn and render a textured quad.
2014-12-04 19:19:30 +01:00
Fredrik Höglund d2cb9f9bf6 Add a model-view and a projection matrix in WindowPaintData
Effects currently modify the matrices by reading back the uniform
values from the shader they assume will be used to paint the window,
set new values for the uniforms, call paintWindow(), and then restore
the uniforms to their previous values.

This is both slow and unreliable, and will not work with dynamically
generated shaders.

This patch solves the problem by putting the matrices in
WindowPaintData and making it the responsibility of the paintWindow()
implementation to set the uniforms.
2014-12-04 19:19:30 +01:00
Fredrik Höglund 05c309da67 Add a ModelViewProjectionMatrix uniform 2014-12-04 19:19:29 +01:00
Fredrik Höglund afcc8337de Add support for generating shaders at runtime
This adds new API in ShaderManager that makes it possible to request a
shader based on a set of traits. ShaderManager generates these shaders
on demand and caches them in a hash table.
2014-12-04 19:19:22 +01:00
Fredrik Höglund 90dfb3ca8b Grow the persistently mapped VBO as needed
Reallocate the buffer when the average frame size is greater than half
the size of the buffer.
2014-12-03 19:50:59 +01:00
Fredrik Höglund 4b3fabbfc9 Add support for GL_ARB_buffer_storage
Use a persistently mapped buffer object for the vertex streaming buffer
when GL_ARB_buffer_storage is supported.
2014-12-03 19:50:59 +01:00
Martin Gräßlin bf4ba54647 Remove displayWidth and displayHeight from the compositor
Instead of getting size from displayWidth() and displayHeight() use
the information we have from Screens. This means there is only one
place to have the information and by that we can ensure that all
components use the same data to rely on. displayWidth/displayHeight
seem to provide the wrong information when unplugging an output
without disabling the output. This results in rendering artefacts.
But KWin::Screens has the correct information available.
2014-11-27 09:00:19 +01:00
Fredrik Höglund 9d01ed16be Remove GLTexturePrivate::bind()/unbind()
These virtual methods are not reimplemented anywhere.
2014-11-26 22:01:54 +01:00
Fredrik Höglund 4b9448db5e Inline GLTexture::load(QImage) in the constructor
This is the only place where it is called.

There was also no need for this function to be virtual since it's not
reimplemented anywhere.

This also fixes the GLTexturePrivate being created only to be
immediately deleted and replaced by a new GLTexturePrivate when the
GLTexture(QImage) constructor was used.

With this change the structure of the GLTexture effectively becomes
immutable to the outside world; the contents of the texture images can
change, but the texture images themselves cannot be reallocated.
2014-11-26 22:01:54 +01:00
Fredrik Höglund 9c7720abca Remove GLTexture::load(QPixmap) and load(QString)
These methods are only called from the GLTexture constructors,
so inline them there.
2014-11-26 22:01:54 +01:00
Fredrik Höglund 383a5ac319 Remove GLTexturePrivate::convertToGLFormat()
QImage::Format_RGBA8888_Premultiplied is the equivalent of
GL_RGBA/GL_UNSIGNED_BYTE, so use QImage::convertToFormat()
instead.

This commit also makes the texture upload code work correctly
on big-endian systems.
2014-11-26 22:01:23 +01:00
Fredrik Höglund 6ac7371113 Remove most calls to checkGLError()
...and rely on KHR_debug/GL_ARB_debug_output instead.
2014-11-25 21:57:57 +01:00
Fredrik Höglund cb39eb0cc5 Use consistent names for the static members in GLTexturePrivate 2014-11-23 20:20:16 +01:00
Fredrik Höglund 854f66c164 Make s_supportsUnpack a static member of GLTexturePrivate 2014-11-23 20:16:02 +01:00
Fredrik Höglund edb0751cba Remove the NPOT texture support checks
We require OpenGL 2.0 which always supports NPOT textures.
2014-11-22 15:53:15 +01:00
Fredrik Höglund 181afc85fe Remove the saturation support checks
We no longer use texture environment parameters to control saturation.
2014-11-22 15:14:07 +01:00
Fredrik Höglund 978a5e10f3 Remove the #ifdefs for GLES in GLTexture
...and replace them with runtime checks.

Reviewed-by: Jeremy Whiting <jpwhiting@kde.org>
2014-11-22 15:11:47 +01:00
Volker Krause 5db2d5a556 Make constants const, saves a few symbols in the .data section. 2014-09-27 20:30:49 +02:00
Fredrik Höglund 3a47b1c1c0 Add XRenderUtils::findPictFormat() and findPictFormatInfo()
These methods look up the render pictformat that correspond to an
X visual, and the format description respectively.
2014-09-01 17:45:58 +02:00
Fredrik Höglund 0aff9830df Remove the decoration opacity property
It has been broken since cross-fading was introduced, and no one has
filed any bug reports about it.
2014-08-25 17:25:04 +02:00
Jonathan Riddell dc554ed256 use standard way to version applications in Plasma 2014-08-20 15:43:27 +02:00
Martin Gräßlin f9a7b94ee7 Create dedicated kwin_x11 and kwin_wayland binaries
All of kwin except the main function goes into a new (private) library
called kwin. Two new kdeinit_executables are created:
* kwin_x11
* kwin_wayland

Both only use a dedicated main_x11.cpp and main_wayland.cpp with the
main function and a KWin::Application subclass and linking the new
kwin library.

The main idea behind this is to be able to perform more sane sanity
checks. E.g. on Wayland we don't need to first test whether we can
create an X11 connection. Instead we should abort if we cannot connect
to the Wayland display. Also the multi-head checks are not needed on
Wayland, etc. etc. As most of that code is in the main function to
simplify it's better to split.

This will also make it easier to diverge more easily in future. The
Wayland variant can introduce more suited command line arguments for
example. This already started by having the --replace option only
available in X11 variant. The Wayland backend is still a window manager,
but doesn't claim the manager selection.
2014-08-18 08:50:44 +02:00
Martin Gräßlin 1e9b02411e Merge branch 'Plasma/5.0' 2014-07-22 13:22:48 +02:00
Martin Gräßlin 7f3b349ab3 Recommend OpenGL2 compositor for virtualbox and vmware
This ensures that those compositors are not forced to XRender.

BUG: 337560
FIXED-IN: 5.0.1
2014-07-22 13:21:23 +02:00
Fredrik Höglund aa7f9f26f6 Fix the GLES build 2014-07-22 13:07:48 +02:00
Fredrik Höglund b1586daab4 Remove the GL_QUADS_KWIN definition
GL_QUADS is always defined now that we're using libepoxy.
2014-07-22 12:56:32 +02:00
Fredrik Höglund aae08b16e9 Add a WindowQuadShadow
And use this type for all the shadow quads in the OpenGL scene.
2014-07-22 12:28:20 +02:00
Fredrik Höglund 6ad4c775d7 Use a single texture atlas for the decoration
The left and right border images are rotated 90° before they are
uploaded into the atlas texture. The images are separated by a row
of transparent texels to minimize artifacts from oversampling.

With this change kwin renders the whole decoration with a single
call to glDrawArrays().
2014-07-17 09:39:17 +02:00
Fredrik Höglund b7592ec6f0 Add a uvAxisSwapped property in WindowQuad
When this property is true, it indicates that the +U axis corresponds
to the +Y axis, and the +V axis corresponds to the +X axis.

This property is taken into account in WindowQuad::makeSubQuad().
2014-07-17 09:17:31 +02:00
Fredrik Höglund d9c4b77f0f Make the GL extension list a QList<QByteArray>
It doesn't make sense to convert the extension names to QStrings.

This also replaces the QString parameter in hasGLExtension() with
a QByteArray and adjusts all callers.
2014-07-14 12:04:37 +02:00
Fredrik Höglund 3b8b1455a6 Use libepoxy to resolve GL functions
Remove the manually written GL dispatch code, and use libepoxy
to resolve functions.

The only exceptions are GLX_MESA_swap_control, which is not in
the XML API registry, and GL_ARB_robustness/GL_EXT_robustness.
For the latter we want to resolve the functions to the same names
on both GLES and desktop GL, and plug in our own implementations
when the extension is not supported.
2014-07-14 12:04:37 +02:00
Martin Gräßlin e8241313fc [libkwineffects] Require strict binding for intel driver
According to driver devs it's a "buggy micro-optimisation", see
https://bugs.freedesktop.org/show_bug.cgi?id=80349#c1

BUG: 336589
REVIEW: 118893
2014-06-24 09:26:46 +02:00
Martin Gräßlin b09dd0d7f1 [kwinglutils] Add ::platformInterface() to GLPlatform
The used platform interface is passed to the ::detect method as an
argument. The value is now cached in the GLPlatform instance so that
there is an easy way to figure out which platform interface is currently
used.
2014-05-13 09:23:03 +02:00
Martin Gräßlin a3ca68ddbe [libkwineffects] Add proper version and soversion to libs
Uses ecm to generate version information.

REVIEW: 118034
2014-05-08 14:41:03 +02:00
Martin Gräßlin 88d55997f7 Port away from DefaultScreen(display())
The screen number is provided through QX11Info.
2014-05-05 08:09:09 +02:00
Martin Gräßlin f247a41396 [glutils] Forward declare void KWin::cleanupGL() in kwinglplatform.h
Fixes build with clang.
2014-04-17 08:04:53 +02:00
Martin Gräßlin 4230a0d331 [effects] Get xcb_connection_t* and rootWindow through EffectsHandler API
So far the effects could just use the connection() and rootWindow()
provided by kwinglobals. Thus an internal detail from KWin core is
accessed directly.

To be more consistent with the rest of the API it's wrapped through the
EffectsHandler and with a convenient method in Effect.

The connection() is provided as xcbConnection() to free the very generic
name connection which could create confusion once we provide a wayland
connection to the Effects.

The rootWindow() is provided as x11RootWindow() to indicate that it is
for the X11 world.

REVIEW: 117597
2014-04-16 16:05:05 +02:00
Martin Gräßlin b8cc10ffab [kwinglutils] Improve cleanup handling
* add static cleanup handlers to GLTexturePrivate and GLRenderTarget
* revert the runtime resolved features (e.g. RenderTargets are not
  supported once we run the cleanup code)
* clear the extension lists
* reset the version variables

REVIEW: 117484
2014-04-14 08:33:19 +02:00
Martin Gräßlin c837ffddf4 Add a cleanup() method to GLPlatform
Adds a cleanup() method to GLPLatform which deletes the static instance.
It gets invoked from cleanupGL() in kwinglutils on tear-down of the
OpenGL backend. Thus the backend doesn't leave incorrect GL info around.

E.g. if KWin starts with llvmpipe the recommended compositor is XRender.
So the backend and the platform is created. Now KWin starts the XRender
Compositor and the GLPlatform is still valid and when trying to load the
Blur or Contrast effect this will succeed as the GLPlatform data would
allow it. But on first try to use the Effect it will fail due to no
valid OpenGL context and even crash.

REVIEW: 117480
2014-04-14 08:31:39 +02:00
Alex Merry 4d88fcdff6 [kwin] Adapt to KPluginFactory change
KPluginFactory's constructor no longer takes arguments, since plugin
root objects are not passed any arguments.
2014-03-28 19:50:46 +00:00
Martin Gräßlin b0e892e359 [kwin] Add a new EffectLoader
The EffectLoader is a subclass of AbstractEffectLoader delegating all
methods to instances of:
* BuiltInEffectLoader
* ScriptedEffectLoader
* PluginEffectLoader

It's used by the EffectsHandlerImpl and replaces the complete Effect
loading mechanism we so far found in it. This also means that KLibrary
is no longer needed to load the Effects as the PluginEffectLoader uses
the KPluginTrader, which removes lots of deprecated functionality.

REVIEW: 117054
2014-03-28 14:04:55 +01:00
Martin Gräßlin e68d5c6315 [kwin] Add a KPluginFactory subclass for loading binary Effects
A KWin::EffectPluginFactory is introduced which provides a specialized
create method and methods for the supported and enabledByDefault checks.

A set of KWIN_EFFECT_FACTORY macros are added which create a subclass
of this EffectPluginFactory following the approach from the
KPluginFactory macros. The macros only support json metadata thus the
QPluginTrader needs to be used.

The KWIN_EFFECT macros are removed as they are no longer needed.

KWin Core's loader is not yet adjusted to this change. This is a
preparation step for introducing a PluginEffectLoader.
2014-03-28 14:04:54 +01:00
Martin Gräßlin 3bbc9436db [kwin] Add a virtual Effect::requestedEffectChainPosition
This method replaces the X-KDE-ORDERING property in the Effect's desktop
files. This change is a preparation step for integrating the new Effect
Loader which doesn't read the ordering information. Thus it needs to be
provided by the Effect itself so that the EffectsHandler can properly
insert it into the chain.

Also for the built-in Effects on the long run it doesn't make much sense
to install the desktop files. And binary plugin effects will migrate to
json metadata which also doesn't have the KService::Ptr. Thus overall it
simplifies to read this information directly from the Effect.
2014-03-28 14:04:54 +01:00
Bhushan Shah 27deaa2d46 Try using OpenGL2 compositor on the Intel i915 and newer chipsets.
If it causes problem it can be still reverted

REVIEW: 117053
2014-03-28 22:25:10 +05:30
Martin Gräßlin dcfc5582ec [kwin] Generate export header for kwinxrenderutils 2014-03-26 14:02:16 +01:00
Martin Gräßlin e3179841f3 [kwin] Create an own library for kwinxrenderutils
XRenderUtils are split out of kwineffects and are an own library just
like kwinglutils is an own library.

The library gets always build and is linked in KWin core unconditionally
(as it's used in outline) and conditionally in kwineffects (PaintClipper)
and the built in effects depending on XRender build option.
2014-03-26 14:02:16 +01:00
Martin Gräßlin 6c1bad551b [kwin] Remove dependency on kwinglobals in kwinxrenderutils
XRenderUtils used connection() and rootWindow() provided by kwinglobals.
Those are now kept as static variables in the implementation set through
an init() method from Workspace prior to the first possible usage of any
functionality provided by XRenderUtils.

In order to make the xcb_connection_t* and the root window completely
internal the inline methods which used those are moved to the
implementation.
2014-03-26 14:01:08 +01:00
Martin Gräßlin a2aab537d6 [kwin/effects] Use generated dbus interface to reconfigure effects
Instead of using EffectsHandler::sendReloadMessage we generate the dbus
interface in each plugin and call the reconfigure slot directly. That way
it's more type safe and we don't need to link kwineffects from the
configs.

REVIEW: 116875
2014-03-25 15:49:19 +01:00
Martin Gräßlin f9e0a8b597 [kwin] Create one plugin per effect configuration
There are no advantages for the effects KCM to have all the effect
config modules in one plugin.

By having a plugin per effect we can use the KPluginTrader to easily
find the configuration plugin for a given effect and load it.

To make this possible the following changes are done:
* config_builtins.cpp is deleted
* add_subdirectory is used for all effects which have a config module
* toplevel CMakeLists.txt contains the sources again for the effects
  which have a config module, but effects which don't have a config
  module are still included and thus the macro is still used
* plugin created for the config module, name pattern is:
   kwin_effectname_config
* plugin installed to ${PLUGIN_INSTALL_DIR}/kwin/effects/configs
* desktop file adjusted to new plugin name and keyword removed
* desktop file converted to json as meta data and no longer installed
* Uses K_PLUGIN_FACTORY_WITH_JSON
* Macros for config are dropped from kwineffects.h

REVIEW: 116854
2014-03-25 15:37:35 +01:00
Martin Gräßlin 2d4d14b1b7 Export Pointer Axis shortcuts to the effect system 2014-03-19 14:14:57 +01:00
Martin Gräßlin 89c2f2bf02 Support for global pointer axis activation
Just as pointer buttons...
2014-03-19 14:14:56 +01:00
Martin Gräßlin 5ea990a740 Export global pointer shortcuts to effect system and use it for cube
Used in cube effect as an example with hard coded ctrl+alt+left click.

BUG: 163121
2014-03-19 14:14:56 +01:00
Martin Gräßlin b57885a1bf Add registerGlobalShortcut method to kwineffects
Implemented in KWin core to forward to new global shortcut system. This
method should be extended/changed once we go to Qt5/KF5 to make the usage
easier (no more KAction).

Each global shortcut in the effects makes use of this new method.
2014-03-19 14:14:56 +01:00
Aleix Pol df58c38b7c Stop including KDE4_INCLUDES globally
Depend on libraries specifically instead.
2014-03-18 18:02:03 +01:00
Aleix Pol e5bffd744b Stop using deprecated headers
Most things were already ported away, only that nobody realized they
weren't used.
2014-03-18 18:02:02 +01:00
Martin Gräßlin 23e6fbbb71 [kwin] Add missing target link libraries
Missing libs caused compile error if built standalone.
2014-03-18 14:38:00 +01:00
Martin Gräßlin 18a37d7ee8 [kwin] Fix includes of kde4support headers
* drop unused headers
* use QExplicitlySharedDataPointer instead of KSharedPointer
* drop KDE/ from includes
2014-03-18 14:34:36 +01:00
Aleix Pol c72e519d9c Remove KDE/ prefix in include directories
It's unneeded and deprecated since KF5.
2014-03-17 16:24:10 +01:00
Martin Gräßlin 89c2688f74 [kwin] Drop direct rendering detection from GLPlatform
It's no longer needed as the OpenGLBackend has a direct rendering
detection and the remaining OpenGL2 backend aborts if the backend
uses indirect rendering. Thus the GLPlatform must always have a
direct rendering context.

REVIEW: 116829
2014-03-17 10:58:59 +01:00
Martin Gräßlin c7d986c7fe [kwin] Remove the legacy OpenGL 1 compositing backend
KWin already has a de facto OpenGL 2 dependency through QML. Combined
with the fact that the OpenGL 1 backend is basically unmaintained and
also unused, it's better to remove it for the new major release.

This change includes:
 * Removal of cmake option KWIN_BUILD_OPENGL_1_COMPOSITING
 * Removal of KWIN_HAVE_OPENGL_1 compile option and all code
   ifdef'ed with it (partially removal of if-else constructs)
 * Removal of CompositingType::OpenGL1Compositing (flags are kept
   as a core flag should get introduced)
 * Driver recommendation for OpenGL1Compositing changed to XRender
   (should be evaluated whether the drivers can provide GL2)
 * Removal of configuration option "GLLegacy"
 * Removal of fooMatrix function in kwinglutils
 * Removal of ARBBlurShader
 * Removal of legacy code path in GLVertexBuffer
 * Removal of GLShaderManager::disable
 * if-blocks with ShaderManager::instance()->isValid() removed

REVIEW: 116042
2014-03-10 08:59:11 +01:00
Martin Gräßlin 0d6dfd83a1 Drop workaround for QTBUG-34898
Fixed as of 91e2c5d749e38eed93e91b14151faa549e70080f in
qtdeclarative module. Part of at 5.2.1.
2014-03-08 14:41:12 +01:00
Martin Gräßlin 3f0ff9b8d5 Migrate effects from displayWidth()/displayHeight() to virtualScreenSize()/virtualScreenGeometry()
Rational behind this change is that displayWidth and displayHeight are
X specific API calls in kwinglobals. For the future it's easier to only
rely on functionality which goes through the EffectsHandler API which
allows easier adjustments in KWin core.

displayWidth() and displayHeight() are only used to get the size or the
complete rect of all screens. This is also provided by:

effects->virtualScreenGeometry() or
effects->virtualScreenSize()

REVIEW: 116021
2014-03-07 08:01:44 +01:00
Martin Gräßlin 6b1f0b1fca [kwin] Introduce Screens::size and Screens::geometry
Screens provides a size which is constructed from the size of
the bounding geometry of all screens and provides an overload taking
an int to return the size of a specified screen. For geometry() a new
ovload is added without an argument, which is just a convenient wrapper
for QRect(QPoint(0, 0), size()).

Both new methods are exported to effects and scripting as new
properties there called virtualScreenSize and virtualScreenGeometry.

The (virtual) size gets cached in screens and is updated whenever the
count or geometry changes.

Construction of Screens is slightly changed by moving the init code
from ctor into a virtual method init(). Reason is that we ended in
a loop with accessing the singleton pointer before it was set.

REVIEW: 116114
2014-03-05 13:03:33 +01:00
Martin Gräßlin a60d10bedd [kwin] Fix generate export header for kwinglesutils
If we build kwinglesutils we need to adjust the name of the generated
export macros to still be called kwinglutils.
2014-03-05 11:35:18 +01:00
Martin Gräßlin 4586767db8 [kwin] Use imported targets for all XCB libs
Requires 04f78489265b6e52cabd2980dfc417abeee3a695 from ECM
2014-02-25 15:48:39 +01:00
Martin Gräßlin 2c7d702b5a [kwin] Use FindEgl for finding egl instead of FindOpenGLES
Requires a2ada35b5c768e8efe9b51a41f84ec6e18ea805c from ECM!
2014-02-25 13:50:10 +01:00
Martin Gräßlin 5a521c149f Add GLTexture(const QSize &) ctor
Thanks to delegating ctors that's quite easy to do without boilerplate
code any more.
2014-02-24 16:08:59 +01:00
Martin Gräßlin 014cdf9267 [kwin] Mark unused variables as unused
--warnings
2014-02-03 11:36:21 +01:00
Martin Gräßlin 2fbc8414a7 Allow windows to specify that they should not get animated on window close
By setting the X property _KDE_NET_WM_SKIP_CLOSE_ANIMATION to 1 a window
can request to be excluded from any close animation. This property is
read in Toplevel, so that it is available to both Client and Unmanaged.

If the window has this property set the Scene suppresses the paintWindow
loop of the Deleted. Thus no effect needs to be adjusted. But an effect
using drawWindow directly would still be able to render the Deleted as
there is no suppression.

Furthermore the property is passed to the EffectWindow so that an
Effect can make use of this functionality and not start the animation
in the first place.

REVIEW: 115288
2014-01-28 07:43:35 +01:00
Marco Martin 4036f179fc one single pass, get rid of cached version
* this effect is way cheaper than blur, don't cache it
* use its own atom
* also pass the matrix in the x property
* remove remnants of the cache
* do just a single pass
* get rid of config ui remnants
2014-01-23 14:44:49 +01:00
Thomas Lübking 4bb88df714 Merge branch 'KDE/4.11' 2014-01-14 22:51:24 +01:00
Thomas Lübking c378bf4f7c emit desktopPresenceChanged from Client:setDesktop
and forward it to scripted effects

CCBUG: 326903
REVIEW: 114080
2014-01-14 22:23:49 +01:00
Martin Gräßlin dec41bbad8 Make Scene's QPainter available to effects
Effects can access the QPainter used by SceneQPainter to directly render
into the back buffer.

Obviously only available in Compositing Type QPainterCompositing.
2014-01-09 13:29:40 +01:00
Martin Gräßlin 0c559c163d New QPainter based compositor called SceneQPainter
This compositor uses only the QPainter API to perform rendering. The
window's X Pixmap is mapped to a QImage using XShm. As rendering backend
a QImage is used.

The new compositing type "QPainterCompositing" is introduced. Effects
need to be adjusted to explicitly check the compositing type and no
longer assume the compositing type is XRender if it's not OpenGL.

This compositor can be selected with using "Q" as the value for
KWIN_COMPOSE env variable or setting the config value to "QPainter".
The GUI is not yet adjusted to select this compositor.

The QPainter scene provides currently the following features:
* 2D transformations (translation and scalation)
* opacity modifications
* rendering of decorations (new PaintRedirector sub class)
* rendering of shadows
* rendering of effect frames
* rendering to a Wayland surface

The following features are currently not provided:
* saturation changes
* brightness changes
* 3D transformations
* rendering to X Overlay window
* offscreen rendering (e.g. needed for screen shot effect)
* custom rendering in the effects to the current back buffer
2014-01-09 13:29:40 +01:00
Matteo De Carlo 59bb857c7b Replace NULL with nullptr in libkwineffects
Completing the task of replacing all NULL to nullptr in all the files in
libkwineffects folder.
(also substituting some "0" used as nullptr with nullptr)

REVIEW: 114823
2014-01-08 11:55:49 +01:00
Martin Gräßlin afbc5222e1 Merge branch 'KDE/4.11' into master
Conflicts:
	CMakeLists.txt
	doc/kcontrol/screensaver/index.docbook
	kcontrol/krdb/krdb.cpp
	kscreensaver/kblank_screensaver/kblank.desktop
	kscreensaver/krandom_screensaver/krandom.desktop
	kscreensaver/libkscreensaver/main.cpp
	ksplash/ksplashqml/SplashApp.cpp
	kstyles/oxygen/config/main.cpp
	kstyles/oxygen/demo/main.cpp
	kstyles/oxygen/oxygenstylehelper.cpp
	kwin/clients/oxygen/config/oxygenexceptiondialog.cpp
	kwin/clients/oxygen/config/ui/oxygenconfigurationui.ui
	kwin/clients/oxygen/config/ui/oxygenexceptiondialog.ui
	kwin/clients/oxygen/demo/main.cpp
	kwin/clients/oxygen/oxygenconfigdata.kcfg
	kwin/egl_wayland_backend.cpp
	kwin/eglonxbackend.h
	kwin/glxbackend.cpp
	kwin/glxbackend.h
	kwin/kcmkwin/kwinoptions/kwinactions.desktop
	kwin/scene_opengl.cpp
	kwin/scene_opengl.h
	plasma/desktop/applets/pager/pager.cpp
	plasma/desktop/shell/activitymanager/activitymanager.cpp
	plasma/desktop/shell/activitymanager/activitymanager.h
	plasma/desktop/shell/controllerwindow.cpp
	plasma/desktop/shell/data/plasma-desktop.desktop
	plasma/generic/dataengines/geolocation/geolocation.cpp
	plasma/generic/dataengines/nowplaying/plasma-dataengine-nowplaying.desktop
	plasma/generic/wallpapers/color/plasma-wallpaper-color.desktop
	plasma/generic/wallpapers/image/image.cpp
	plasma/generic/wallpapers/image/image.h
2014-01-07 09:36:11 +01:00
Fredrik Höglund eeb309c149 kwin: Add support for EXT_buffer_age
This patch adds support for GLX_EXT_buffer_age, and
EGL_EXT_buffer_age on X11.
2013-12-12 01:36:46 +01:00
Martin Klapetek 54bc491c46 Port to KF5 renaming changes 2013-12-11 21:41:47 +01:00
Martin Gräßlin 73054577df [libkwineffects] Add a signal for screen count changed
Used in PresentWindows effect instead of QDesktopWidget.
2013-12-10 12:20:43 +01:00
Martin Gräßlin e4be8c34b8 [libkwineffects] Remove unused forward declaration 2013-12-10 11:03:08 +01:00
Martin Gräßlin 2372e02752 [kwin] Use a QIcon in Client for the icons instead of Pixmaps
Client used to have dedicated methods for different icon sizes instead
of combining all pixmaps into one QIcon. This resulted in various parts
of KWin having different access to the icons:
* effects only got one pixmap of size 32x32
* decorations only got the 16x16 and 32x32 pixmaps combined into a QIcon
* tabbox could request all icon sizes, but only as pixmap

Now all sizes are available in one QIcon allowing to easily access the
best fitting icon in a given UI.
2013-12-06 14:41:23 +01:00
Martin Gräßlin e92d02ab61 [kwin] Remove include of kdemacros.h from kwinglobals
Instead we generate an export header for kdeinit_kwin and use it
to declare the KWIN_EXPORT. With this change our libs don't include
any KDE4Support headers any more. One step closer to no KDE4Support.
2013-12-06 08:37:16 +01:00
Egor Matirov 05c2849fee Added export header through cmake for libkwinglutils
REVIEW: 114265
2013-12-03 14:37:29 +01:00
Martin Gräßlin f7bc2775d1 Remove kwineffects.h include from kwingltexture.cpp
Nothing from kwineffects.h used in this file.
2013-12-02 08:13:08 +01:00
Martin Gräßlin 416898ecfa Remove kwinglobals.h include where not needed any more
Most headers only included kwinglobals.h just for the KWIN_EXPORT
macro. As that's not used any more, we don't need that include any
more.
2013-12-02 07:56:16 +01:00
Jacob Logan 0c4518cca9 added export header through cmake for kwineffects
REVIEW: 114233
2013-12-02 07:43:26 +01:00
Jacob Logan ac72e9fb73 Changed debug statements in kwin/effects from qDebug() to qCDebug(KWINEFFECTS)
A new .cpp file is added containing the declaration of the logging
category and compiled into the effects lib.

REVIEW: 114194
2013-11-29 08:47:56 +01:00
Martin Gräßlin 1ea1fb4fbd Unit test for WindowQuadList::makeGrid and ::makeRegularGrid 2013-11-25 09:27:31 +01:00
Thomas Lübking 26febda4a0 Merge branch 'KDE/4.11'
Conflicts:
	ksmserver/screenlocker/greeter/greeterapp.cpp
	ksmserver/screenlocker/greeter/greeterapp.h
	ksmserver/screenlocker/greeter/themes/org.kde.passworddialog/contents/ui/main.qml
	kwin/libkwineffects/kwineffects.cpp
	kwin/useractions.cpp
	plasma/desktop/applets/window-list/metadata.desktop
	plasma/desktop/containments/panel/plasma-containment-panel.desktop
	plasma/desktop/toolboxes/plasma-toolbox-paneltoolbox.desktop
	plasma/generic/wallpapers/color/plasma-wallpaper-color.desktop
2013-11-24 15:35:17 +01:00
Martin Gräßlin 2e3eb5402b Fallback to XRender if scene-graph uses GUI thread for OpenGL rendering
This is a workaround fo QTBUG-34898 and affects the VirtualBox driver
and SandyBridge Mobile. OpenGL compositing is just not possible and
crashes as soon as there is anything rendered with QtQuick. This change
should be reverted once the Qt bug is fixed.

To nevertheless use OpenGL one can as always use the KWIN_COMPOSE env
variable, though this will result in crashes. An alternative is to set
QT_OPENGL_NO_SANITY_CHECK which forces Qt into using the threaded
rendering. At least for Sandybridge this seems to be a workable solution
as it's only causing flickering in fullscreen and KWin doesn't use any
fullscreen QtQuick elements.
2013-11-23 10:54:41 +01:00
Martin Gräßlin b7be3cb621 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-23 10:54:41 +01:00
Fredrik Höglund 76adeb6a13 kwin: Optimize WindowQuadList::makeGrid()
This is the same optimization that was done in makeRegularGrid()
in 45782d387ab894c682b4ccc220e596c8b72c4167.
2013-11-21 23:38:43 +01:00