[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kwin/fredrik/vulkan] /: Move align() to utils.h
From: Fredrik_Höglund <null () kde ! org>
Date: 2018-02-16 17:01:48
Message-ID: E1emjOO-0004Yx-3w () code ! kde ! org
[Download RAW message or body]
Git commit 6b80a34ca8747f4c052c83c283aa9c405dc274cb by Fredrik Höglund.
Committed on 16/02/2018 at 16:57.
Pushed by fredrik into branch 'fredrik/vulkan'.
Move align() to utils.h
M +1 -6 libkwineffects/kwinglutils.cpp
M +0 -5 plugins/scenes/opengl/scene_opengl.cpp
M +13 -0 utils.h
https://commits.kde.org/kwin/6b80a34ca8747f4c052c83c283aa9c405dc274cb
diff --git a/libkwineffects/kwinglutils.cpp b/libkwineffects/kwinglutils.cpp
index 24a14de09..f65956571 100644
--- a/libkwineffects/kwinglutils.cpp
+++ b/libkwineffects/kwinglutils.cpp
@@ -27,6 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "kwineffects.h"
#include "kwinglplatform.h"
#include "logging_p.h"
+#include "../utils.h"
#include <QPixmap>
@@ -1519,12 +1520,6 @@ static const uint16_t indices[] = {
2041, 2040, 2043, 2043, 2042, 2041, 2045, 2044, 2047, 2047, 2046, 2045
};
-template <typename T>
-T align(T value, int bytes)
-{
- return (value + bytes - 1) & ~T(bytes - 1);
-}
-
class IndexBuffer
{
public:
diff --git a/plugins/scenes/opengl/scene_opengl.cpp b/plugins/scenes/opengl/scene_opengl.cpp
index d225b8e66..22817f644 100644
--- a/plugins/scenes/opengl/scene_opengl.cpp
+++ b/plugins/scenes/opengl/scene_opengl.cpp
@@ -2398,11 +2398,6 @@ void SceneOpenGLDecorationRenderer::render()
renderPart(bottom.intersected(geometry), bottom, QPoint(0, top.height() + 1));
}
-static int align(int value, int align)
-{
- return (value + align - 1) & ~(align - 1);
-}
-
void SceneOpenGLDecorationRenderer::resizeTexture()
{
QRect left, top, right, bottom;
diff --git a/utils.h b/utils.h
index e4224192a..9654ece29 100644
--- a/utils.h
+++ b/utils.h
@@ -38,6 +38,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QProcess>
// system
#include <limits.h>
+#include <assert.h>
+
Q_DECLARE_LOGGING_CATEGORY(KWIN_CORE)
namespace KWin
{
@@ -192,6 +194,17 @@ Qt::MouseButton KWIN_EXPORT x11ToQtMouseButton(int button);
Qt::MouseButtons KWIN_EXPORT x11ToQtMouseButtons(int state);
Qt::KeyboardModifiers KWIN_EXPORT x11ToQtKeyboardModifiers(int state);
+/**
+ * Aligns the given value to alignment.
+ * Note that alignment must be a power-of-two.
+ */
+template <typename T>
+constexpr T align(T value, unsigned int alignment)
+{
+ assert(alignment != 0 && alignment == (alignment & -alignment));
+ return (value + alignment - 1) & ~T(alignment - 1);
+}
+
/**
* Separate the concept of an unet QPoint and 0,0
*/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic