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:
parent
ba24e7ce39
commit
27b83fa722
|
@ -37,15 +37,15 @@ FIND_PACKAGE(ZLIB REQUIRED)
|
|||
# setup compiler options
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
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_C_FLAGS "-pipe ${CXX_WARNS}")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_WARNS} -std=gnu++0x -pipe")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CXX_WARNS} -pipe")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -ggdb")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -ggdb")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O1 -g -ggdb")
|
||||
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O1 -g -ggdb")
|
||||
SET(CMAKE_CXX_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)
|
||||
|
||||
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
|
|
|
@ -98,8 +98,8 @@ void Texture::generateMipmaps()
|
|||
{
|
||||
bind();
|
||||
|
||||
if(!m_useMipmaps) {
|
||||
m_useMipmaps = true;
|
||||
if(!m_hasMipmaps) {
|
||||
m_hasMipmaps = true;
|
||||
setupFilters();
|
||||
}
|
||||
|
||||
|
@ -141,8 +141,8 @@ void Texture::generateBilinearMipmaps(std::vector<uint8> inPixels)
|
|||
{
|
||||
bind();
|
||||
|
||||
if(!m_useMipmaps) {
|
||||
m_useMipmaps = true;
|
||||
if(!m_hasMipmaps) {
|
||||
m_hasMipmaps = true;
|
||||
setupFilters();
|
||||
}
|
||||
|
||||
|
@ -204,10 +204,10 @@ void Texture::setupFilters()
|
|||
GLint minFilter;
|
||||
GLint magFilter;
|
||||
if(m_smooth) {
|
||||
minFilter = m_useMipmaps ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR;
|
||||
minFilter = m_hasMipmaps ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR;
|
||||
magFilter = GL_LINEAR;
|
||||
} else {
|
||||
minFilter = m_useMipmaps ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST;
|
||||
minFilter = m_hasMipmaps ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST;
|
||||
magFilter = GL_NEAREST;
|
||||
}
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter);
|
||||
|
|
|
@ -48,7 +48,8 @@ public:
|
|||
int getHeight() { return m_size.height(); }
|
||||
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:
|
||||
void setupFilters();
|
||||
|
@ -56,7 +57,7 @@ protected:
|
|||
|
||||
GLuint m_textureId;
|
||||
Size m_size;
|
||||
Boolean<false> m_useMipmaps;
|
||||
Boolean<false> m_hasMipmaps;
|
||||
Boolean<false> m_smooth;
|
||||
};
|
||||
|
||||
|
|
|
@ -160,6 +160,11 @@ void UIWidget::drawImage(const Rect& screenCoords)
|
|||
}
|
||||
|
||||
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.drawTextureCoords(m_imageCoordsBuffer, m_imageTexture);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue