Commit Graph

65 Commits (master)

Author SHA1 Message Date
Vlad Zahorodnii 4ce853e8e4 Prettify license headers 2020-08-07 19:57:56 +00:00
Vlad Zahorodnii 1fb9f6f13a Switch to SPDX license markers
The main advantage of SPDX license identifiers over the traditional
license headers is that it's more difficult to overlook inappropriate
licenses for kwin, for example GPL 3. We also don't have to copy a
lot of boilerplate text.

In order to create this change, I ran licensedigger -r -c from the
toplevel source directory.
2020-08-07 19:57:56 +00:00
Aleix Pol 29a2b2a355 Make it possible to specify KWin::GLTexture mutability
Some features will rely on it and complain that GLTexture decided to use
glTexStorage
2020-07-23 13:14:22 +02:00
Aleix Pol ff65bec92c Introduce a GLTexture::toImage helper class 2020-07-23 13:14:22 +02:00
Aleix Pol e459c8bf54 No need to recalculate the matrix if yInverted doesn't change 2020-06-23 14:58:48 +02:00
Vlad Zahorodnii 639441f10b Merge branch 'Plasma/5.17' 2019-11-18 12:27:17 +02:00
Vlad Zahorodnii 270009ed6a Merge branch 'Plasma/5.12' into Plasma/5.17 2019-11-18 12:26:21 +02:00
Vlad Zahorodnii 1d362d38fd [libkwineffects] Restore GL_DRAW_FRAMEBUFFER binding in GLTexture::clear
Summary:
If an effect renders a window into an offscreen texture, it's very important
that the window ends up in the offscreen render target rather than the default
framebuffer object. However, that might be not the case if the OpenGL
decoration renderer needs to create a texture atlas since the renderer calls
GLTexture::clear() method, which might clobber the current GL_DRAW_FRAMEBUFFER
binding.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D25365
2019-11-18 12:25:14 +02:00
Albert Astals Cid e144748c7a Add some const &
Summary:
Won't make things go much faster since everything that was
being passed by value is refcounted but still const & is a bit faster
than refcounting

For shared pointers instead of adding const & we move them into the
destination variable saving some cpu usage but at the same time making
clear the pointer is being stored by not being const &

Reviewers: zzag

Reviewed By: zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D25022
2019-10-30 19:23:01 +01:00
David Edmundson d78fda30ef KWin::GLTexture support external textures
Summary:
Currently KWin::GLTexture is a nice wrapper for creating a GL texture
and performing various operations including rendering.

In a pending patch I want to render the FBO from a QQuickScene directly,
where we have an underlying texture already, but it makes sense to
re-use this class for the rendering. A similar need is in haagch's kwin
VR patchset.

This patch adds a constructor to GLTexture that takes an externally
managed texture and provides the relevant useful KWin features.

Test Plan: Used in patch series

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D24206
2019-09-25 14:28:19 +01:00
Vlad Zagorodniy 4a3104bf27 don't override m_canUseMipmaps
Summary:
Seems like this override/assignment was introduced in edb0751cba.

Following that commit, 450be6a378 introduced `levels` param
so we could tell whether mipmaps are going to be used. And it seems like this assignment
hadn't been deleted in that commit.

Reviewers: #kwin, fredrik

Reviewed By: fredrik

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D11301
2018-03-14 04:37:44 +02:00
Alex Nemeth 627b11ce49 Added missing image format
Summary:
`QImage::Format_ARGB6666_Premultiplied` was missing from the image format table.
This might have caused some bugs later on.
See: http://doc.qt.io/qt-5/qimage.html#Format-enum

Reviewers: fredrik, #kwin

Reviewed By: fredrik

Subscribers: cfeck, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D10497
2018-02-14 23:23:19 +01:00
Alex Nemeth cc0325af41 Added noise blur effect
Summary:
Added the option to turn on noise behind the blurred area.
The lowest strength value disables it completely, so it is optional and is disabled by default.

Test Plan:
Edit: this new screenshot shows the updated noise generation.
Edit2: separated the screenshots so you can flick through them to clearly see the differences

{F5694024}

{F5694031}

{F5694025}

{F5694028}

Reviewers: #kwin, #vdg, fredrik

Reviewed By: #vdg, fredrik

Subscribers: davidedmundson, matheusm, romangg, ivan, zzag, ngraham, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D10281
2018-02-14 00:13:08 +01:00
Martin Gräßlin ef7f7b0179 [kwinglutils] Don't setup old shader API for rendering a texture
Old shader API no longer in use, so we don't need to setup the texture
rendering.
2016-01-25 14:11:54 +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 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 caf99f83d5 Require Qt 5.4
REVIEW: 122617
2015-02-19 10:56:50 +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 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 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 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 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
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 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 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
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 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 969e6b85e7 Merge branch 'master' into frameworks-scratch
Conflicts:
	CMakeLists.txt
	kwin/client.cpp
	kwin/effects/highlightwindow/highlightwindow.cpp
	kwin/libkwineffects/kwingltexture.cpp
	kwin/libkwineffects/kwinxrenderutils.cpp
	kwin/scene_opengl.cpp
	kwin/workspace.cpp
	plasma/desktop/applets/kickoff/CMakeLists.txt
	plasma/desktop/applets/taskmanager/package/contents/code/tools.js
	plasma/desktop/applets/taskmanager/package/contents/ui/Task.qml
	plasma/desktop/applets/taskmanager/package/contents/ui/main.qml
	plasma/desktop/applets/taskmanager/package/metadata.desktop
	plasma/desktop/applets/taskmanager/plugin/textlabel.h
	plasma/desktop/applets/tasks/CMakeLists.txt
	plasma/desktop/applets/tasks/package/metadata.desktop
	plasma/desktop/applets/tasks/tasks.cpp
	plasma/desktop/toolboxes/plasma-toolbox-desktoptoolbox.desktop
	plasma/generic/applets/activitybar/activitybar.cpp
	plasma/generic/wallpapers/color/plasma-wallpaper-color.desktop
	plasma/generic/wallpapers/image/plasma-wallpaper-image.desktop
2013-09-24 11:28:38 +02:00
Thomas Lübking 3f5ef10c8e introduce GLTexture::clear and use it from paintredirector
also work around broken fbo texture clearing on fglrx

so far supports FBO/glClear and resorts to glTexSubImage2D

if the fbo cannot be created or is (in case of fglrx)
known to break, resort to glTexImage2D loading of an
argb array of zeros

BUG: 323065
FIXED-IN: 4.11.2
REVIEW: 112526
2013-09-24 00:50:55 +02:00
Martin Gräßlin 330d40f425 Fix no cast to/from ASCII intrduced issues
* "" needs to be wrapped in QStringLiteral
* QString::fromUtf8 needed for const char* and QByteArray
* QByteArray::constData() needed to get to the const char*
2013-07-24 09:58:33 +02:00
Fredrik Höglund 2fc2004119 kwin: Reset the dirty flags in GLTexture
m_wrapModeChanged and m_filterChanged were never set to false,
causing the sampler parameters to be set every time a texture was bound.
2013-06-13 18:46:34 +02:00
Fredrik Höglund 7a99b8c0ef kwin: Add GLTexture::matrix()
This method returns a matrix that transforms normalized or un-normalized
texture coordinates, taking the texture target and y-inversion flag into
account.
2013-05-28 16:35:36 +02:00
Martin Gräßlin 9206f530ce Adding support for GL_EXT_texture_format_BGRA8888 in GLES
If extension is present texture format BGRA_EXT is used for loading
textures from QImages.

REVIEW: 109090
2013-03-11 11:21:14 +01:00