Commit 53cb4207 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

scenes/opengl: Use std::array to store lanczos kernel data

This fixes a compiler warning (-Wclass-memaccess) and makes code a bit
cleaner.
parent e14a0111
...@@ -151,7 +151,7 @@ void LanczosFilter::createKernel(float delta, int *size) ...@@ -151,7 +151,7 @@ void LanczosFilter::createKernel(float delta, int *size)
values[i] = val; values[i] = val;
} }
memset(m_kernel, 0, 16 * sizeof(QVector4D)); m_kernel.fill(QVector4D());
// Normalize the kernel // Normalize the kernel
for (int i = 0; i < kernelSize; i++) { for (int i = 0; i < kernelSize; i++) {
...@@ -164,7 +164,7 @@ void LanczosFilter::createKernel(float delta, int *size) ...@@ -164,7 +164,7 @@ void LanczosFilter::createKernel(float delta, int *size)
void LanczosFilter::createOffsets(int count, float width, Qt::Orientation direction) void LanczosFilter::createOffsets(int count, float width, Qt::Orientation direction)
{ {
memset(m_offsets, 0, 16 * sizeof(QVector2D)); m_offsets.fill(QVector2D());
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
m_offsets[i] = (direction == Qt::Horizontal) ? m_offsets[i] = (direction == Qt::Horizontal) ?
QVector2D(i / width, 0) : QVector2D(0, i / width); QVector2D(i / width, 0) : QVector2D(0, i / width);
...@@ -406,8 +406,8 @@ void LanczosFilter::discardCacheTexture(EffectWindow *w) ...@@ -406,8 +406,8 @@ void LanczosFilter::discardCacheTexture(EffectWindow *w)
void LanczosFilter::setUniforms() void LanczosFilter::setUniforms()
{ {
glUniform2fv(m_uOffsets, 16, (const GLfloat*)m_offsets); glUniform2fv(m_uOffsets, m_offsets.size(), (const GLfloat*)m_offsets.data());
glUniform4fv(m_uKernel, 16, (const GLfloat*)m_kernel); glUniform4fv(m_uKernel, m_kernel.size(), (const GLfloat*)m_kernel.data());
} }
} // namespace } // namespace
......
...@@ -54,8 +54,8 @@ private: ...@@ -54,8 +54,8 @@ private:
QScopedPointer<GLShader> m_shader; QScopedPointer<GLShader> m_shader;
int m_uOffsets; int m_uOffsets;
int m_uKernel; int m_uKernel;
QVector2D m_offsets[16]; std::array<QVector2D, 16> m_offsets;
QVector4D m_kernel[16]; std::array<QVector4D, 16> m_kernel;
Scene *m_scene; Scene *m_scene;
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment