some optimizations and compilation changes

* speedup render of widget images on low end devices using mipmaps
* changes in CMakeLists.txt to allow usage of distcc and crosscompiling
This commit is contained in:
Eduardo Bart 2012-02-20 11:10:54 -02:00
parent ba24e7ce39
commit 27b83fa722
4 changed files with 17 additions and 11 deletions

View File

@ -37,15 +37,15 @@ FIND_PACKAGE(ZLIB REQUIRED)
# setup compiler options # setup compiler options
IF(CMAKE_COMPILER_IS_GNUCXX) IF(CMAKE_COMPILER_IS_GNUCXX)
SET(CXX_WARNS "-Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-but-set-variable") SET(CXX_WARNS "-Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-but-set-variable")
SET(CMAKE_CXX_FLAGS "-std=gnu++0x -pipe ${CXX_WARNS}") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_WARNS} -std=gnu++0x -pipe")
SET(CMAKE_C_FLAGS "-pipe ${CXX_WARNS}") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CXX_WARNS} -pipe")
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -ggdb") SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -ggdb")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -ggdb") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -ggdb")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O1 -g -ggdb") SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O1 -g -ggdb")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O1 -g -ggdb") SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O1 -g -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "-O2") SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
SET(CMAKE_C_FLAGS_RELEASE "-O2") SET(CMAKE_C_FLAGS_RELEASE "-O2")
SET(CMAKE_CXX_LINK_FLAGS "-static-libgcc -static-libstdc++ -Wl,--as-needed") SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -static-libgcc -static-libstdc++ -Wl,--as-needed")
ENDIF(CMAKE_COMPILER_IS_GNUCXX) ENDIF(CMAKE_COMPILER_IS_GNUCXX)
IF(CMAKE_BUILD_TYPE STREQUAL "Debug") IF(CMAKE_BUILD_TYPE STREQUAL "Debug")

View File

@ -98,8 +98,8 @@ void Texture::generateMipmaps()
{ {
bind(); bind();
if(!m_useMipmaps) { if(!m_hasMipmaps) {
m_useMipmaps = true; m_hasMipmaps = true;
setupFilters(); setupFilters();
} }
@ -141,8 +141,8 @@ void Texture::generateBilinearMipmaps(std::vector<uint8> inPixels)
{ {
bind(); bind();
if(!m_useMipmaps) { if(!m_hasMipmaps) {
m_useMipmaps = true; m_hasMipmaps = true;
setupFilters(); setupFilters();
} }
@ -204,10 +204,10 @@ void Texture::setupFilters()
GLint minFilter; GLint minFilter;
GLint magFilter; GLint magFilter;
if(m_smooth) { if(m_smooth) {
minFilter = m_useMipmaps ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR; minFilter = m_hasMipmaps ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR;
magFilter = GL_LINEAR; magFilter = GL_LINEAR;
} else { } else {
minFilter = m_useMipmaps ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST; minFilter = m_hasMipmaps ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST;
magFilter = GL_NEAREST; magFilter = GL_NEAREST;
} }
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter);

View File

@ -48,7 +48,8 @@ public:
int getHeight() { return m_size.height(); } int getHeight() { return m_size.height(); }
const Size& getSize() { return m_size; } const Size& getSize() { return m_size; }
bool isEmpty() const { return m_textureId == 0; } bool isEmpty() { return m_textureId == 0; }
bool hasMipmaps() { return m_hasMipmaps; }
protected: protected:
void setupFilters(); void setupFilters();
@ -56,7 +57,7 @@ protected:
GLuint m_textureId; GLuint m_textureId;
Size m_size; Size m_size;
Boolean<false> m_useMipmaps; Boolean<false> m_hasMipmaps;
Boolean<false> m_smooth; Boolean<false> m_smooth;
}; };

View File

@ -160,6 +160,11 @@ void UIWidget::drawImage(const Rect& screenCoords)
} }
m_imageTexture->setSmooth(m_imageSmooth); m_imageTexture->setSmooth(m_imageSmooth);
// this will increase fps when rendering larger images, like the background, and improve image quality
if(m_imageSmooth && !m_imageTexture->hasMipmaps())
m_imageTexture->generateMipmaps();
g_painter.setColor(m_imageColor); g_painter.setColor(m_imageColor);
g_painter.drawTextureCoords(m_imageCoordsBuffer, m_imageTexture); g_painter.drawTextureCoords(m_imageCoordsBuffer, m_imageTexture);
} }