From 1bf303e566bdbac6efe505c497588e2ca55d8f72 Mon Sep 17 00:00:00 2001 From: Marcel Pursche Date: Mon, 20 Mar 2017 16:31:09 +0100 Subject: [PATCH 1/2] Improved cpack configuration for building debian packages: * Added configurable maintainer * Added configurable dependencies and conflicts per package * Added post install script to run ldconfig after package is installed * Updated name of readme file in cpack configuration --- CMakeModules/OsgCPack.cmake | 84 +++++++++++++++++++++++++++- CMakeModules/OsgCPackConfig.cmake.in | 14 ++++- CMakeModules/OsgMacroUtils.cmake | 17 ++++++ debian_scripts/postinst | 1 + 4 files changed, 111 insertions(+), 5 deletions(-) create mode 100755 debian_scripts/postinst diff --git a/CMakeModules/OsgCPack.cmake b/CMakeModules/OsgCPack.cmake index 706487231..4bd2c2e76 100644 --- a/CMakeModules/OsgCPack.cmake +++ b/CMakeModules/OsgCPack.cmake @@ -57,7 +57,7 @@ ENDIF() SET(CPACK_SOURCE_GENERATOR "TGZ") -# for ms visual studio we use it's internally defined variable to get the configuration (debug,release, ...) +# for ms visual studio we use it's internally defined variable to get the configuration (debug,release, ...) IF(MSVC_IDE) SET(OSG_CPACK_CONFIGURATION "$(OutDir)") SET(PACKAGE_TARGET_PREFIX "Package ") @@ -84,9 +84,87 @@ ENDIF() SET(PACKAGE_ALL_TARGETNAME "${PACKAGE_TARGET_PREFIX}ALL") ADD_CUSTOM_TARGET(${PACKAGE_ALL_TARGETNAME}) + # cpack configuration for debian packages +IF(${CPACK_GENERATOR} STREQUAL "DEB") + SET(OPENSCENEGRAPH_PACKAGE_MAINTAINER + "" + CACHE STRING + "Name and email address of the package maintainer, e.g., 'Jon Doe '" + ) + SET(CPACK_LIBOPENSCENEGRAPH_DEPENDENCIES + "libopenthreads" + CACHE STRING + "Dependend packages for the openscenegraph library package (uses deb dependecy format), e.g., 'libc6, libcurl3-gnutls, libgif4, libjpeg8, libpng12-0'" + ) + SET(CPACK_LIBOPENSCENEGRAPH-DEV_DEPENDENCIES + "libopenscenegraph" + CACHE STRING + "Dependend packages for the openscenegraph development package (uses deb dependecy format), e.g., 'libc6, libcurl3-gnutls, libgif4, libjpeg8, libpng12-0'" + ) + SET(CPACK_LIBOPENTHREADS_DEPENDENCIES + "" + CACHE STRING + "Dependend packages for the openthreads library package (uses deb dependecy format), e.g., 'libc6, libcurl3-gnutls, libgif4, libjpeg8, libpng12-0'" + ) + SET(CPACK_LIBOPENTHREADS-DEV_DEPENDENCIES + "libopenthreads" + CACHE STRING + "Dependend packages for the openthreads development package (uses deb dependecy format), e.g., 'libc6, libcurl3-gnutls, libgif4, libjpeg8, libpng12-0'" + ) + SET(CPACK_OPENSCENEGRAPH_DEPENDENCIES + "libopenscenegraph" + CACHE STRING + "Dependend packages for the openscenegraph main package (uses deb dependecy format), e.g., 'libc6, libcurl3-gnutls, libgif4, libjpeg8, libpng12-0'" + ) + SET(CPACK_OPENSCENEGRAPH-ALL_DEPENDENCIES + "" + CACHE STRING + "Dependend packages for the openscenegraph package with all components (uses deb dependecy format), e.g., 'libc6, libcurl3-gnutls, libgif4, libjpeg8, libpng12-0'" + ) + + SET(CPACK_LIBOPENSCENEGRAPH_CONFLICTS + "" + CACHE STRING + "Conflicting packages for the openscenegraph library package (uses deb dependecy format), e.g., 'libc6, libcurl3-gnutls, libgif4, libjpeg8, libpng12-0'" + ) + SET(CPACK_LIBOPENSCENEGRAPH-DEV_CONFLICTS + "" + CACHE STRING + "Conflicting packages for the openscenegraph development package (uses deb dependecy format), e.g., 'libc6, libcurl3-gnutls, libgif4, libjpeg8, libpng12-0'" + ) + SET(CPACK_LIBOPENTHREADS_CONFLICTS + "" + CACHE STRING + "Conflicting packages for the openthreads library package (uses deb dependecy format), e.g., 'libc6, libcurl3-gnutls, libgif4, libjpeg8, libpng12-0'" + ) + SET(CPACK_LIBOPENTHREADS-DEV_CONFLICTS + "" + CACHE STRING + "Conflicting packages for the openthreads development package (uses deb dependecy format), e.g., 'libc6, libcurl3-gnutls, libgif4, libjpeg8, libpng12-0'" + ) + SET(CPACK_OPENSCENEGRAPH_CONFLICTS + "" + CACHE STRING + "Conflicting packages for the openscenegraph main package (uses deb dependecy format), e.g., 'libc6, libcurl3-gnutls, libgif4, libjpeg8, libpng12-0'" + ) + SET(CPACK_OPENSCENEGRAPH-ALL_CONFLICTS + "" + CACHE STRING + "Conflicting packages for the openscenegraph package with all components (uses deb dependecy format), e.g., 'libc6, libcurl3-gnutls, libgif4, libjpeg8, libpng12-0'" + ) +ENDIF() + MACRO(GENERATE_PACKAGING_TARGET package_name) SET(CPACK_PACKAGE_NAME ${package_name}) + # set debian dependencies AND conflicts + IF(${CPACK_GENERATOR} STREQUAL "DEB") + STRING(TOUPPER CPACK_${package_name}_DEPENDENCIES DEPENDENCIES_VAR) + STRING(TOUPPER CPACK_${package_name}_CONFLICTS CONFLICTS_VAR) + SET(OSG_PACKAGE_DEPENDS "${${DEPENDENCIES_VAR}}") + SET(OSG_PACKAGE_CONFLICTS "${${CONFLICTS_VAR}}") + ENDIF() + # the doc packages don't need a system-arch specification IF(${package} MATCHES -doc) SET(OSG_PACKAGE_FILE_NAME ${package_name}-${OPENSCENEGRAPH_VERSION}) @@ -114,7 +192,7 @@ MACRO(GENERATE_PACKAGING_TARGET package_name) ELSE() SET(ARCHIVE_EXT "tar.gz") ENDIF() - + # Create a target that creates the current package # and rename the package to give it proper filename ADD_CUSTOM_TARGET(${PACKAGE_TARGETNAME}) @@ -124,7 +202,7 @@ MACRO(GENERATE_PACKAGING_TARGET package_name) COMMAND ${CMAKE_CPACK_COMMAND} -C ${OSG_CPACK_CONFIGURATION} --config ${OpenSceneGraph_BINARY_DIR}/CPackConfig-${package_name}.cmake COMMENT "Run CPack packaging for ${package_name}..." ) - # Add the exact same custom command to the all package generating target. + # Add the exact same custom command to the all package generating target. # I can't use add_dependencies to do this because it would allow parallell building of packages so am going brute here ADD_CUSTOM_COMMAND(TARGET ${PACKAGE_ALL_TARGETNAME} COMMAND ${CMAKE_CPACK_COMMAND} -C ${OSG_CPACK_CONFIGURATION} --config ${OpenSceneGraph_BINARY_DIR}/CPackConfig-${package_name}.cmake diff --git a/CMakeModules/OsgCPackConfig.cmake.in b/CMakeModules/OsgCPackConfig.cmake.in index 0ab151d09..376b4d6d9 100644 --- a/CMakeModules/OsgCPackConfig.cmake.in +++ b/CMakeModules/OsgCPackConfig.cmake.in @@ -53,7 +53,7 @@ SET(CPACK_NSIS_INSTALLER_ICON_CODE "") SET(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "") SET(CPACK_OUTPUT_CONFIG_FILE "${PROJECT_BINARY_DIR}/CPackConfig-${OSG_CPACK_COMPONENT}.cmake") SET(CPACK_PACKAGE_DEFAULT_LOCATION "/") -SET(CPACK_PACKAGE_DESCRIPTION_FILE "${OpenSceneGraph_SOURCE_DIR}/README.txt") +SET(CPACK_PACKAGE_DESCRIPTION_FILE "${OpenSceneGraph_SOURCE_DIR}/README.md") SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The OpenSceneGraph is an open source high performance 3d graphics toolkit") SET(CPACK_PACKAGE_FILE_NAME "${OSG_PACKAGE_FILE_NAME}") SET(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_INSTALL_DIRECTORY}") @@ -66,6 +66,16 @@ SET(CPACK_PACKAGE_VERSION_MAJOR "${OPENSCENEGRAPH_MAJOR_VERSION}") SET(CPACK_PACKAGE_VERSION_MINOR "${OPENSCENEGRAPH_MINOR_VERSION}") SET(CPACK_PACKAGE_VERSION_PATCH "${OPENSCENEGRAPH_PATCH_VERSION}") SET(CPACK_RESOURCE_FILE_LICENSE "${OpenSceneGraph_SOURCE_DIR}/LICENSE.txt") -SET(CPACK_RESOURCE_FILE_README "${OpenSceneGraph_SOURCE_DIR}/README.txt") +SET(CPACK_RESOURCE_FILE_README "${OpenSceneGraph_SOURCE_DIR}/README.md") SET(CPACK_RESOURCE_FILE_WELCOME "${OpenSceneGraph_SOURCE_DIR}/NEWS.txt") SET(CPACK_STRIP_FILES "ON") + +# DEBIAN OPTIONS +IF(${CPACK_GENERATOR} STREQUAL "DEB") + SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "${OPENSCENEGRAPH_PACKAGE_MAINTAINER}") + SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://www.openscenegraph.org") + SET(CPACK_DEBIAN_PACKAGE_SECTION "Development") + SET(CPACK_DEBIAN_PACKAGE_DEPENDS "${OSG_PACKAGE_DEPENDS}") + SET(CPACK_DEBIAN_PACKAGE_CONFLICTS "${OSG_PACKAGE_CONFLICTS}") + SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${OpenSceneGraph_SOURCE_DIR}/debian_scripts/postinst;") +ENDIF() diff --git a/CMakeModules/OsgMacroUtils.cmake b/CMakeModules/OsgMacroUtils.cmake index 21f7560f2..8c7967cb5 100644 --- a/CMakeModules/OsgMacroUtils.cmake +++ b/CMakeModules/OsgMacroUtils.cmake @@ -266,6 +266,23 @@ MACRO(SETUP_PLUGIN PLUGIN_NAME) ## plugins gets put in libopenscenegraph by default IF(${ARGC} GREATER 1) SET(PACKAGE_COMPONENT libopenscenegraph-${ARGV1}) + + # add cpack config variables for plugin with own package + IF(BUILD_OSG_PACKAGES) + IF(${CPACK_GENERATOR} STREQUAL "DEB") + STRING(TOUPPER ${PACKAGE_COMPONENT} UPPER_PACKAGE_COMPONENT) + SET(CPACK_${UPPER_PACKAGE_COMPONENT}_DEPENDENCIES + "libopenscenegraph" + CACHE STRING + "Dependend packages for the ${PACKAGE_COMPONENT} package with all components (uses deb dependecy format), e.g., 'libc6, libcurl3-gnutls, libgif4, libjpeg8, libpng12-0'" + ) + SET(CPACK_${UPPER_PACKAGE_COMPONENT}_CONFLICTS + "" + CACHE STRING + "Conflicting packages for the ${PACKAGE_COMPONENT} package (uses deb dependecy format), e.g., 'libc6, libcurl3-gnutls, libgif4, libjpeg8, libpng12-0'" + ) + ENDIF() + ENDIF() ELSE(${ARGC} GREATER 1) SET(PACKAGE_COMPONENT libopenscenegraph) ENDIF(${ARGC} GREATER 1) diff --git a/debian_scripts/postinst b/debian_scripts/postinst new file mode 100755 index 000000000..762f47445 --- /dev/null +++ b/debian_scripts/postinst @@ -0,0 +1 @@ +ldconfig From a74872c6bf3aa449462e73a7fe55b012811de2b7 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 21 Mar 2017 13:10:45 +0000 Subject: [PATCH 2/2] Refactored GlyphTexture so that it utlizes standard osg::Texture2D/osg::Image combinations rather than locally implemented per glyph subloading. --- include/osgText/Glyph | 2 - src/osgText/Font.cpp | 3 - src/osgText/Glyph.cpp | 318 +++--------------------------------------- 3 files changed, 17 insertions(+), 306 deletions(-) diff --git a/include/osgText/Glyph b/include/osgText/Glyph index 7cd079b86..f08686841 100644 --- a/include/osgText/Glyph +++ b/include/osgText/Glyph @@ -264,8 +264,6 @@ public: void addGlyph(Glyph* glyph,int posX, int posY); - virtual void apply(osg::State& state) const; - /** Set whether to use a mutex to ensure ref() and unref() are thread safe.*/ virtual void setThreadSafeRefUnref(bool threadSafe); diff --git a/src/osgText/Font.cpp b/src/osgText/Font.cpp index 2a7415fdf..5223691f2 100644 --- a/src/osgText/Font.cpp +++ b/src/osgText/Font.cpp @@ -32,13 +32,10 @@ using namespace osgText; using namespace std; -static osg::ApplicationUsageProxy Font_e0(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_TEXT_INCREMENTAL_SUBLOADING ","ON | OFF"); - #define FIXED_FUNCTION defined(OSG_GL_FIXED_FUNCTION_AVAILABLE) #define SHADERS_GL3 (defined(OSG_GL3_AVAILABLE)) #define SHADERS_GL2 !FIXED_FUNCTION && !SHADERS_GL3 - #if SHADERS_GL3 static const char* gl3_TextVertexShader = { "#version 330 core\n" diff --git a/src/osgText/Glyph.cpp b/src/osgText/Glyph.cpp index 068ce1fb0..3bc346c8f 100644 --- a/src/osgText/Glyph.cpp +++ b/src/osgText/Glyph.cpp @@ -103,11 +103,9 @@ void GlyphTexture::addGlyph(Glyph* glyph, int posX, int posY) { OpenThreads::ScopedLock lock(_mutex); + if (!_image.valid()) createImage(); + _glyphs.push_back(glyph); - for(unsigned int i=0;i<_glyphsToSubload.size();++i) - { - _glyphsToSubload[i].push_back(glyph); - } // set up the details of where to place glyph's image in the texture. glyph->setTexture(this); @@ -117,294 +115,9 @@ void GlyphTexture::addGlyph(Glyph* glyph, int posX, int posY) static_cast(posY)/static_cast(getTextureHeight()) ) ); glyph->setMaxTexCoord( osg::Vec2( static_cast(posX+glyph->s())/static_cast(getTextureWidth()), static_cast(posY+glyph->t())/static_cast(getTextureHeight()) ) ); -} - -void GlyphTexture::apply(osg::State& state) const -{ - // get the contextID (user defined ID of 0 upwards) for the - // current OpenGL context. - const unsigned int contextID = state.getContextID(); - - if (contextID>=_glyphsToSubload.size()) - { - OpenThreads::ScopedLock lock(_mutex); - - // graphics context is beyond the number of glyphsToSubloads, so - // we must now copy the glyph list across, this is a potential - // threading issue though is multiple applies are happening the - // same time on this object - to avoid this condition number of - // graphics contexts should be set before create text. - for(unsigned int i=_glyphsToSubload.size();i<=contextID;++i) - { - GlyphPtrList& glyphPtrs = _glyphsToSubload[i]; - for(GlyphRefList::const_iterator itr=_glyphs.begin(); - itr!=_glyphs.end(); - ++itr) - { - glyphPtrs.push_back(itr->get()); - } - } - } - - - const osg::GLExtensions* extensions = state.get(); - bool generateMipMapSupported = extensions->isGenerateMipMapSupported; - - // get the texture object for the current contextID. - TextureObject* textureObject = getTextureObject(contextID); - - bool newTextureObject = (textureObject == 0); - - #if defined(OSG_GLES2_AVAILABLE) - bool requiresGenerateMipmapCall = false; - - // need to look to see generate mip map call is required. - switch(_min_filter) - { - case NEAREST_MIPMAP_NEAREST: - case NEAREST_MIPMAP_LINEAR: - case LINEAR_MIPMAP_NEAREST: - case LINEAR_MIPMAP_LINEAR: - requiresGenerateMipmapCall = generateMipMapSupported; - break; - default: - break; - } - #endif - - if (newTextureObject) - { - GLint maxTextureSize = 256; - glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); - if (maxTextureSize < getTextureWidth() || maxTextureSize < getTextureHeight()) - { - OSG_WARN<<"Warning: osgText::Font texture size of ("<bind(); - - - applyTexParameters(GL_TEXTURE_2D,state); - - // need to look at generate mip map extension if mip mapping required. - switch(_min_filter) - { - case NEAREST_MIPMAP_NEAREST: - case NEAREST_MIPMAP_LINEAR: - case LINEAR_MIPMAP_NEAREST: - case LINEAR_MIPMAP_LINEAR: - if (generateMipMapSupported) - { - #if !defined(OSG_GLES2_AVAILABLE) - glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE); - #endif - } - else glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, LINEAR); - break; - default: - // not mip mapping so no problems. - break; - } - - unsigned int imageDataSize = getTextureHeight()*getTextureWidth(); - unsigned char* imageData = new unsigned char[imageDataSize]; - for(unsigned int i=0; ibind(); - - if (getTextureParameterDirty(contextID)) - { - applyTexParameters(GL_TEXTURE_2D,state); - } - - - } - - static const GLubyte* s_renderer = 0; - static bool s_subloadAllGlyphsTogether = false; - if (!s_renderer) - { - OpenThreads::ScopedLock lock(_mutex); - - s_renderer = glGetString(GL_RENDERER); - OSG_INFO<<"glGetString(GL_RENDERER)=="< lock(_mutex); - - bool subloadAllGlyphsTogether = s_subloadAllGlyphsTogether; - - #if defined(OSG_GLES2_AVAILABLE) - if (requiresGenerateMipmapCall) subloadAllGlyphsTogether = true; - #endif - - if (!subloadAllGlyphsTogether) - { - if (newTextureObject) - { - for(GlyphRefList::const_iterator itr=_glyphs.begin(); - itr!=_glyphs.end(); - ++itr) - { - (*itr)->subload(); - } - } - else // just subload the new entries. - { - // default way of subloading as required. - //std::cout<<"subloading"<subload(); - } - } - - // clear the list since we have now subloaded them. - glyphsWereSubloading.clear(); - - } - else - { - OSG_INFO<<"osgText::Font loading all glyphs as a single subload."<subload(); - - // Rather than subloading to graphics, we'll write the values - // of the glyphs into some intermediate data and subload the - // whole thing at the end - for( int t = 0; t < (*itr)->t(); t++ ) - { - for( int s = 0; s < (*itr)->s(); s++ ) - { - int sindex = (t*(*itr)->s()+s); - int dindex = - ((((*itr)->getTexturePositionY()+t) * getTextureWidth()) + - ((*itr)->getTexturePositionX()+s)); - - const unsigned char *sptr = &(*itr)->data()[sindex]; - unsigned char *dptr = &local_data[dindex]; - - (*dptr) = (*sptr); - } - } - } - - // clear the list since we have now subloaded them. - glyphsWereSubloading.clear(); - - glPixelStorei(GL_UNPACK_ALIGNMENT,1); - - #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) - glPixelStorei(GL_UNPACK_ROW_LENGTH,getTextureWidth()); - #endif - - // Subload the image once - glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, - getTextureWidth(), - getTextureHeight(), - OSGTEXT_GLYPH_FORMAT, GL_UNSIGNED_BYTE, local_data); - - #if defined(OSG_GLES2_AVAILABLE) - if (requiresGenerateMipmapCall) glGenerateMipmap(GL_TEXTURE_2D); - #endif - - delete [] local_data; - - } - } - else - { -// OSG_INFO << "no need to subload "<copySubImage(glyph->getTexturePositionX(), glyph->getTexturePositionY(), 0, glyph); + _image->dirty(); } void GlyphTexture::setThreadSafeRefUnref(bool threadSafe) @@ -432,19 +145,22 @@ void GlyphTexture::resizeGLObjectBuffers(unsigned int maxSize) osg::Image* GlyphTexture::createImage() { - osg::ref_ptr image = new osg::Image; - image->allocateImage(getTextureWidth(), getTextureHeight(), 1, OSGTEXT_GLYPH_FORMAT, GL_UNSIGNED_BYTE); - memset(image->data(), 0, image->getTotalSizeInBytes()); - - for(GlyphRefList::iterator itr = _glyphs.begin(); - itr != _glyphs.end(); - ++itr) + if (!_image) { - Glyph* glyph = itr->get(); - image->copySubImage(glyph->getTexturePositionX(), glyph->getTexturePositionY(), 0, glyph); + _image = new osg::Image; + _image->allocateImage(getTextureWidth(), getTextureHeight(), 1, OSGTEXT_GLYPH_FORMAT, GL_UNSIGNED_BYTE); + memset(_image->data(), 0, _image->getTotalSizeInBytes()); + + for(GlyphRefList::iterator itr = _glyphs.begin(); + itr != _glyphs.end(); + ++itr) + { + Glyph* glyph = itr->get(); + _image->copySubImage(glyph->getTexturePositionX(), glyph->getTexturePositionY(), 0, glyph); + } } - return image.release(); + return _image.get(); } // all the methods in Font::Glyph have been made non inline because VisualStudio6.0 is STUPID, STUPID, STUPID PILE OF JUNK.