Browse Source

Explicit instantiation of Image types.

De-inlined setData() functions, as they were too heavy for inlining.
pull/279/head
Vladimír Vondruš 14 years ago
parent
commit
caadb242b3
  1. 31
      src/BufferedImage.cpp
  2. 13
      src/BufferedImage.h
  3. 2
      src/CMakeLists.txt
  4. 32
      src/Image.cpp
  5. 14
      src/Image.h

31
src/BufferedImage.cpp

@ -0,0 +1,31 @@
/*
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz>
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<size_t imageDimensions> void BufferedImage<imageDimensions>::setData(const Math::Vector<Dimensions, GLsizei>& 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>;
}

13
src/BufferedImage.h

@ -99,18 +99,19 @@ template<size_t imageDimensions> class BufferedImage: public AbstractImage {
*
* @see Buffer::setData()
*/
void setData(const Math::Vector<Dimensions, GLsizei>& 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, GLsizei>& dimensions, Components components, ComponentType type, const GLvoid* data, Buffer::Usage usage);
protected:
Math::Vector<Dimensions, GLsizei> _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;

2
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

32
src/Image.cpp

@ -0,0 +1,32 @@
/*
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz>
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<size_t imageDimensions> void Image<imageDimensions>::setData(const Math::Vector<Dimensions, GLsizei>& dimensions, Components components, ComponentType type, GLvoid* data) {
delete[] _data;
_components = components;
_type = type;
_dimensions = dimensions;
_data = reinterpret_cast<char*>(data);
}
template class Image<1>;
template class Image<2>;
template class Image<3>;
}

14
src/Image.h

@ -105,19 +105,19 @@ template<size_t imageDimensions> 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, GLsizei>& dimensions, Components components, ComponentType type, GLvoid* data) {
delete[] _data;
_components = components;
_type = type;
_dimensions = dimensions;
_data = reinterpret_cast<char*>(data);
}
void setData(const Math::Vector<Dimensions, GLsizei>& dimensions, Components components, ComponentType type, GLvoid* data);
protected:
Math::Vector<Dimensions, GLsizei> _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;

Loading…
Cancel
Save