From caadb242b32b44b13702e0dfd317b8c06a825803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 30 Sep 2012 02:19:26 +0200 Subject: [PATCH] Explicit instantiation of Image types. De-inlined setData() functions, as they were too heavy for inlining. --- src/BufferedImage.cpp | 31 +++++++++++++++++++++++++++++++ src/BufferedImage.h | 13 +++++++------ src/CMakeLists.txt | 2 ++ src/Image.cpp | 32 ++++++++++++++++++++++++++++++++ src/Image.h | 14 +++++++------- 5 files changed, 79 insertions(+), 13 deletions(-) create mode 100644 src/BufferedImage.cpp create mode 100644 src/Image.cpp diff --git a/src/BufferedImage.cpp b/src/BufferedImage.cpp new file mode 100644 index 000000000..94907a60c --- /dev/null +++ b/src/BufferedImage.cpp @@ -0,0 +1,31 @@ +/* + Copyright © 2010, 2011, 2012 Vladimír Vondruš + + This file is part of Magnum. + + Magnum is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + Magnum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details. +*/ + +#include "BufferedImage.h" + +namespace Magnum { + +template void BufferedImage::setData(const Math::Vector& dimensions, Components components, ComponentType type, const GLvoid* data, Buffer::Usage usage) { + _components = components; + _type = type; + _dimensions = dimensions; + _buffer.setData(Buffer::Target::PixelPack, pixelSize(_components, _type)*dimensions.product(), data, usage); +} + +template class BufferedImage<1>; +template class BufferedImage<2>; +template class BufferedImage<3>; + +} diff --git a/src/BufferedImage.h b/src/BufferedImage.h index 0de313b24..528284f8b 100644 --- a/src/BufferedImage.h +++ b/src/BufferedImage.h @@ -99,18 +99,19 @@ template class BufferedImage: public AbstractImage { * * @see Buffer::setData() */ - void setData(const Math::Vector& dimensions, Components components, ComponentType type, const GLvoid* data, Buffer::Usage usage) { - _components = components; - _type = type; - _dimensions = dimensions; - _buffer.setData(Buffer::Target::PixelPack, pixelSize(_components, _type)*dimensions.product(), data, usage); - } + void setData(const Math::Vector& dimensions, Components components, ComponentType type, const GLvoid* data, Buffer::Usage usage); protected: Math::Vector _dimensions; /**< @brief %Image dimensions */ Buffer _buffer; /**< @brief %Image buffer */ }; +#ifndef DOXYGEN_GENERATING_OUTPUT +extern template class BufferedImage<1>; +extern template class BufferedImage<2>; +extern template class BufferedImage<3>; +#endif + /** @brief One-dimensional buffered image */ typedef BufferedImage<1> BufferedImage1D; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index debd4c69e..061399b1f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,9 +21,11 @@ set(Magnum_SRCS AbstractImage.cpp AbstractTexture.cpp AbstractShaderProgram.cpp + BufferedImage.cpp BufferedTexture.cpp Context.cpp Framebuffer.cpp + Image.cpp IndexedMesh.cpp Mesh.cpp Profiler.cpp diff --git a/src/Image.cpp b/src/Image.cpp new file mode 100644 index 000000000..2172837cd --- /dev/null +++ b/src/Image.cpp @@ -0,0 +1,32 @@ +/* + Copyright © 2010, 2011, 2012 Vladimír Vondruš + + This file is part of Magnum. + + Magnum is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + Magnum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details. +*/ + +#include "Image.h" + +namespace Magnum { + +template void Image::setData(const Math::Vector& dimensions, Components components, ComponentType type, GLvoid* data) { + delete[] _data; + _components = components; + _type = type; + _dimensions = dimensions; + _data = reinterpret_cast(data); +} + +template class Image<1>; +template class Image<2>; +template class Image<3>; + +} diff --git a/src/Image.h b/src/Image.h index 467bd24a8..a9268db34 100644 --- a/src/Image.h +++ b/src/Image.h @@ -105,19 +105,19 @@ template class Image: public AbstractImage { * Deletes previous data and replaces them with new. Note that the * data are not copied, but they are deleted on destruction. */ - void setData(const Math::Vector& dimensions, Components components, ComponentType type, GLvoid* data) { - delete[] _data; - _components = components; - _type = type; - _dimensions = dimensions; - _data = reinterpret_cast(data); - } + void setData(const Math::Vector& dimensions, Components components, ComponentType type, GLvoid* data); protected: Math::Vector _dimensions; /**< @brief %Image dimensions */ char* _data; /**< @brief %Image data */ }; +#ifndef DOXYGEN_GENERATING_OUTPUT +extern template class Image<1>; +extern template class Image<2>; +extern template class Image<3>; +#endif + /** @brief One-dimensional image */ typedef Image<1> Image1D;