diff --git a/Changes.md b/Changes.md index 4b0304db1bd..5ac3c361ece 100644 --- a/Changes.md +++ b/Changes.md @@ -9,11 +9,23 @@ Fixes - Fixed hangs and crashes when using non-default session modes such as SVM shading. - Fixed failure to render background light in batch renders (#5234). - Fixed failure to update when reverting a background shader to previous values. +- GafferUI : + - Fixed `Color space 'sRGB' could not be found` errors when running with certain custom OCIO configs (#5695). + - Fixed icon colours when running with an ACES OCIO config. Breaking Changes ---------------- - CyclesOptions : Changed `hairShape` default value to "ribbon", to match Cycles' and Blender's own defaults. +- Pointer : + - Removed `Pointer( const ImagePrimitive * )` constructor. + - Removed `image()` method. + +API +--- + +- ImageGadget : Removed `textureLoader()` method. +- Pointer : Added `fileName()` method. [^1]: To be omitted from final release notes for 1.4.0.0. diff --git a/SConstruct b/SConstruct index 506658f748c..02f07ea06f6 100644 --- a/SConstruct +++ b/SConstruct @@ -1058,7 +1058,7 @@ libraries = { "GafferUI" : { "envAppends" : { ## \todo Stop linking against `Iex`. It is only necessary on Windows Imath 2 builds. - "LIBS" : [ "Gaffer", "Iex$IMATH_LIB_SUFFIX", "IECoreGL$CORTEX_LIB_SUFFIX", "IECoreImage$CORTEX_LIB_SUFFIX", "IECoreScene$CORTEX_LIB_SUFFIX" ], + "LIBS" : [ "Gaffer", "Iex$IMATH_LIB_SUFFIX", "IECoreGL$CORTEX_LIB_SUFFIX", "IECoreImage$CORTEX_LIB_SUFFIX", "IECoreScene$CORTEX_LIB_SUFFIX", "OpenImageIO$OIIO_LIB_SUFFIX", "OpenImageIO_Util$OIIO_LIB_SUFFIX" ], }, "pythonEnvAppends" : { "LIBS" : [ "IECoreImage$CORTEX_LIB_SUFFIX", "IECoreScene$CORTEX_LIB_SUFFIX", "IECoreGL$CORTEX_LIB_SUFFIX", "GafferUI", "GafferBindings" ], diff --git a/include/GafferUI/ImageGadget.h b/include/GafferUI/ImageGadget.h index 234cf3bb7e0..4e4dda26dbb 100644 --- a/include/GafferUI/ImageGadget.h +++ b/include/GafferUI/ImageGadget.h @@ -53,6 +53,9 @@ IE_CORE_FORWARDDECLARE( Texture ) namespace GafferUI { +/// Gadget suitable for displaying icons and the like. For +/// high-performance display of images generated by ImageNode, +/// see `GafferImageUI::ImageGadget`. class GAFFERUI_API ImageGadget : public Gadget { @@ -62,7 +65,7 @@ class GAFFERUI_API ImageGadget : public Gadget /// the GAFFERUI_IMAGE_PATHS environment variable. /// Throws if the file cannot be loaded. explicit ImageGadget( const std::string &fileName ); - /// A copy of the image is taken. + /// \deprecated ImageGadget( const IECoreImage::ConstImagePrimitivePtr image ); ~ImageGadget() override; @@ -70,14 +73,21 @@ class GAFFERUI_API ImageGadget : public Gadget Imath::Box3f bound() const override; - /// Returns the texture loader used for converting images - /// on disk into textures for rendering. This is exposed - /// publicly so that other code can share the same texture - /// cache. - static IECoreGL::TextureLoader *textureLoader(); - /// Loads a texture using the `textureLoader()` and applies - /// the default ImageGadget texture parameters. - static IECoreGL::ConstTexturePtr loadTexture( const std::string &fileName ); + struct GAFFERUI_API TextureParameters + { + GLint minFilter = GL_LINEAR_MIPMAP_LINEAR; + GLint magFilter = GL_LINEAR; + float lodBias = -1.0; + GLint wrapS = GL_CLAMP_TO_BORDER; + GLint wrapT = GL_CLAMP_TO_BORDER; + static TextureParameters defaultParameters() { return {}; } + }; + + /// Loads a texture suitable for rendering with `StandardStyle::renderImage()`, + /// searching for it on the paths defined by the `GAFFERUI_IMAGE_PATHS` environment + /// variable. Throws if the file cannot be loaded. Uses an internal cache, so the + /// returned texture may be shared with other code, and is therefore const. + static IECoreGL::ConstTexturePtr loadTexture( const std::string &fileName, const TextureParameters ¶meters = TextureParameters::defaultParameters() ); protected : diff --git a/include/GafferUI/Pointer.h b/include/GafferUI/Pointer.h index 57c9efb8ecb..cf91589477c 100644 --- a/include/GafferUI/Pointer.h +++ b/include/GafferUI/Pointer.h @@ -56,13 +56,11 @@ class GAFFERUI_API Pointer : public IECore::RefCounted IE_CORE_DECLAREMEMBERPTR( Pointer ) - /// A copy of the image is taken. - explicit Pointer( const IECoreImage::ImagePrimitive *image, const Imath::V2i &hotspot = Imath::V2i( -1 ) ); /// Images are loaded from the paths specified by the /// GAFFERUI_IMAGE_PATHS environment variable. Pointer( const std::string &fileName, const Imath::V2i &hotspot = Imath::V2i( -1 ) ); - const IECoreImage::ImagePrimitive *image() const; + const std::string &fileName() const; const Imath::V2i &hotspot() const; /// Sets the current pointer. Passing null resets the @@ -83,7 +81,7 @@ class GAFFERUI_API Pointer : public IECore::RefCounted private : - IECoreImage::ConstImagePrimitivePtr m_image; + std::string m_fileName; Imath::V2i m_hotspot; }; diff --git a/python/GafferUI/Image.py b/python/GafferUI/Image.py index edcab71a8f2..e7beeeaa30b 100644 --- a/python/GafferUI/Image.py +++ b/python/GafferUI/Image.py @@ -171,6 +171,10 @@ def _qtIcon( self, highlighted = False ) : icon.addPixmap( self._qtPixmapDisabled(), QtGui.QIcon.Disabled ) return icon + ## \todo Deprecate and remove - we want to phase out ImagePrimitive. + # Although we don't use this function or the `Image( ImagePrimitive )` + # constructor in Gaffer itself, we can't do this immediately because some + # external code currently depends on it. @staticmethod def _qtPixmapFromImagePrimitive( image ) : @@ -238,14 +242,7 @@ def __cacheGetter( cls, fileName ) : if not resolvedFileName : raise Exception( "Unable to find file \"%s\"" % fileName ) - reader = IECore.Reader.create( resolvedFileName ) - - image = reader.read() - if not isinstance( image, IECoreImage.ImagePrimitive ) : - raise Exception( "File \"%s\" is not an image file" % resolvedFileName ) - - result = cls._qtPixmapFromImagePrimitive( image ) - + result = QtGui.QPixmap( resolvedFileName ) cost = result.width() * result.height() * ( 4 if result.hasAlpha() else 3 ) return ( result, cost ) diff --git a/python/GafferUI/_Pointer.py b/python/GafferUI/_Pointer.py index 01368834993..58b89d4af9d 100644 --- a/python/GafferUI/_Pointer.py +++ b/python/GafferUI/_Pointer.py @@ -55,7 +55,7 @@ def __pointerChanged() : application.restoreOverrideCursor() __cursorOverridden = False else : - pixmap = GafferUI.Image._qtPixmapFromImagePrimitive( pointer.image() ) + pixmap = GafferUI.Image._qtPixmapFromFile( pointer.fileName() ) cursor = QtGui.QCursor( pixmap, pointer.hotspot().x, pointer.hotspot().y ) if __cursorOverridden : application.changeOverrideCursor( cursor ) diff --git a/python/GafferUITest/ImageGadgetTest.py b/python/GafferUITest/ImageGadgetTest.py index f7b46f01d94..69f9b06f0bc 100644 --- a/python/GafferUITest/ImageGadgetTest.py +++ b/python/GafferUITest/ImageGadgetTest.py @@ -35,6 +35,7 @@ ########################################################################## import os +import pathlib import unittest import imath @@ -64,16 +65,19 @@ def testMissingFiles( self ) : self.assertRaises( Exception, GafferUI.ImageGadget, "iDonNotExist" ) - def testTextureLoader( self ) : + def testAllImages( self ) : - # must access an attribute from IECoreGL to force import - # before calling textureLoader(), because it is imported - # lazily by GafferUI. - import IECoreGL - IECoreGL.TextureLoader + with GafferUI.Window() as window : + gadgetWidget = GafferUI.GadgetWidget() - l = GafferUI.ImageGadget.textureLoader() - self.assertTrue( isinstance( l, IECoreGL.TextureLoader ) ) + window.setVisible( True ) + + for path in IECore.SearchPath( os.environ["GAFFERUI_IMAGE_PATHS"] ).paths : + for image in pathlib.Path( path ).glob( "*.png" ) : + imageGadget = GafferUI.ImageGadget( str( image ) ) + gadgetWidget.getViewportGadget().setPrimaryChild( imageGadget ) + gadgetWidget.getViewportGadget().frame( imageGadget.bound() ) + self.waitForIdle( 100 ) if __name__ == "__main__": unittest.main() diff --git a/src/GafferUI/AnnotationsGadget.cpp b/src/GafferUI/AnnotationsGadget.cpp index d69cc9730e3..c3c71192917 100644 --- a/src/GafferUI/AnnotationsGadget.cpp +++ b/src/GafferUI/AnnotationsGadget.cpp @@ -74,37 +74,15 @@ Box2f nodeFrame( const NodeGadget *nodeGadget ) } -IECoreGL::Texture *bookmarkTexture() +const IECoreGL::Texture *bookmarkTexture() { - static IECoreGL::TexturePtr bookmarkTexture; - - if( !bookmarkTexture ) - { - bookmarkTexture = ImageGadget::textureLoader()->load( "bookmarkStar2.png" ); - - IECoreGL::Texture::ScopedBinding binding( *bookmarkTexture ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER ); - } + static IECoreGL::ConstTexturePtr bookmarkTexture = ImageGadget::loadTexture( "bookmarkStar2.png" ); return bookmarkTexture.get(); } -IECoreGL::Texture *numericBookmarkTexture() +const IECoreGL::Texture *numericBookmarkTexture() { - static IECoreGL::TexturePtr numericBookmarkTexture; - - if( !numericBookmarkTexture ) - { - numericBookmarkTexture = ImageGadget::textureLoader()->load( "bookmarkStar.png" ); - - IECoreGL::Texture::ScopedBinding binding( *numericBookmarkTexture ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER ); - } + static IECoreGL::ConstTexturePtr numericBookmarkTexture = ImageGadget::loadTexture( "bookmarkStar.png" ); return numericBookmarkTexture.get(); } diff --git a/src/GafferUI/ImageGadget.cpp b/src/GafferUI/ImageGadget.cpp index e5591e61c74..26e8a396ad7 100644 --- a/src/GafferUI/ImageGadget.cpp +++ b/src/GafferUI/ImageGadget.cpp @@ -48,6 +48,10 @@ #include "IECore/Exception.h" #include "IECore/SearchPath.h" +#include "OpenImageIO/color.h" +#include "OpenImageIO/imagebuf.h" +#include "OpenImageIO/imagebufalgo.h" + #include "fmt/format.h" using namespace Imath; @@ -63,7 +67,7 @@ using namespace GafferUI; namespace { -Box3f boundGetter( const std::string &fileName, size_t &cost, const IECore::Canceller *canceller ) +std::string resolvedFileName( const std::string &fileName ) { const char *s = getenv( "GAFFERUI_IMAGE_PATHS" ); IECore::SearchPath sp( s ? s : "" ); @@ -74,32 +78,110 @@ Box3f boundGetter( const std::string &fileName, size_t &cost, const IECore::Canc throw Exception( "Could not find file '" + fileName + "'" ); } - ReaderPtr reader = Reader::create( path.generic_string() ); - if( !reader ) - { - throw Exception( "Could not create reader for '" + path.generic_string() + "'" ); - } + return path.generic_string(); +} - ImageReaderPtr imageReader = IECore::runTimeCast( reader ); - if( !imageReader ) +Box3f boundGetter( const std::string &fileName, size_t &cost, const IECore::Canceller *canceller ) +{ + OIIO::ImageBuf imageBuf( resolvedFileName( fileName ) ); + if( imageBuf.has_error() ) { - throw IECore::Exception( fmt::format( "File \"{}\" does not contain an image.", fileName ) ); + throw Exception( imageBuf.geterror() ); } cost = 1; - V2i pixelSize = imageReader->displayWindow().size() + V2i( 1 ); + const V2i pixelSize( imageBuf.spec().full_width, imageBuf.spec().full_height ); V3f size( pixelSize.x, pixelSize.y, 0.0f ); return Box3f( -size/2.0f, size/2.0f ); } -void applyTextureParameters( IECoreGL::Texture *texture ) +void applyTextureParameters( IECoreGL::Texture *texture, const ImageGadget::TextureParameters ¶meters ) { IECoreGL::Texture::ScopedBinding binding( *texture ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, -1.0 ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, parameters.minFilter ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, parameters.magFilter ); + glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, parameters.lodBias ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, parameters.wrapS ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, parameters.wrapT ); +} + +struct TextureCacheKey +{ + std::string fileName; + ImageGadget::TextureParameters parameters; + bool operator==( const TextureCacheKey &other ) const + { + return + fileName == other.fileName && + parameters.minFilter == other.parameters.minFilter && + parameters.magFilter == other.parameters.magFilter && + parameters.lodBias == other.parameters.lodBias && + parameters.wrapS == other.parameters.wrapS && + parameters.wrapT == other.parameters.wrapT + ; + } +}; + +size_t hash_value( const TextureCacheKey &key ) +{ + size_t result = 0; + boost::hash_combine( result, key.fileName ); + boost::hash_combine( result, key.parameters.minFilter ); + boost::hash_combine( result, key.parameters.magFilter ); + boost::hash_combine( result, key.parameters.lodBias ); + boost::hash_combine( result, key.parameters.wrapS ); + boost::hash_combine( result, key.parameters.wrapT ); + return result; +} + +using TextureCache = IECorePreview::LRUCache; + +IECoreGL::ConstTexturePtr textureGetter( const TextureCacheKey &key, size_t &cost, const IECore::Canceller *canceller ) +{ + const OIIO::ImageSpec config( OIIO::TypeDesc::UCHAR ); + OIIO::ImageBuf imageBuf( resolvedFileName( key.fileName ), /* subimage = */ 0, /* miplevel = */ 0, /* imagecache = */ nullptr, &config ); + imageBuf = OIIO::ImageBufAlgo::flip( imageBuf ); + if( imageBuf.has_error() ) + { + throw Exception( imageBuf.geterror() ); + } + + static const OIIO::ColorConfig colorConfig( "ocio://default" ); + static const OIIO::ColorProcessorHandle colorProcessor = colorConfig.createColorProcessor( + "sRGB - Texture", "Linear Rec.709 (sRGB)" + ); + + imageBuf = OIIO::ImageBufAlgo::colorconvert( imageBuf, colorProcessor.get(), true ); + + GLint pixelFormat; + switch( imageBuf.nchannels() ) + { + case 1 : + pixelFormat = GL_RED; + break; + case 3 : + pixelFormat = GL_RGB; + break; + case 4 : + pixelFormat = GL_RGBA; + break; + default : + throw IECore::Exception( fmt::format( "Unsupported number of channels ({}) in \"{}\"", imageBuf.nchannels(), imageBuf.name() ) ); + } + + GLuint id; + glGenTextures( 1, &id ); + TexturePtr texture = new Texture( id ); + Texture::ScopedBinding binding( *texture ); + + glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); + glTexImage2D( GL_TEXTURE_2D, /* level = */ 0, pixelFormat, imageBuf.spec().width, imageBuf.spec().height, /* border = */ 0, pixelFormat, GL_UNSIGNED_BYTE, imageBuf.localpixels() ); + glGenerateMipmap( GL_TEXTURE_2D ); + + applyTextureParameters( texture.get(), key.parameters ); + + cost = 0; // Never evict + return texture; } const IECoreGL::Texture *loadTexture( IECore::ConstRunTimeTypedPtr &imageOrTextureOrFileName ) @@ -109,22 +191,21 @@ const IECoreGL::Texture *loadTexture( IECore::ConstRunTimeTypedPtr &imageOrTextu return texture; } - TexturePtr texture; + ConstTexturePtr texture; if( const StringData *filename = runTimeCast( imageOrTextureOrFileName.get() ) ) { // Load texture from file - texture = ImageGadget::textureLoader()->load( filename->readable() ); + texture = ImageGadget::loadTexture( filename->readable() ); } else if( const ImagePrimitive *image = runTimeCast( imageOrTextureOrFileName.get() ) ) { // Convert image to texture ToGLTextureConverterPtr converter = new ToGLTextureConverter( image ); - texture = boost::static_pointer_cast( converter->convert() ); - } - - if( texture ) - { - applyTextureParameters( texture.get() ); + if( auto converted = boost::static_pointer_cast( converter->convert() ) ) + { + applyTextureParameters( converted.get(), ImageGadget::TextureParameters() ); + texture = converted; + } } imageOrTextureOrFileName = texture; @@ -166,26 +247,10 @@ ImageGadget::~ImageGadget() { } -IECoreGL::TextureLoader *ImageGadget::textureLoader() -{ - static TextureLoaderPtr loader = nullptr; - if( !loader ) - { - const char *s = getenv( "GAFFERUI_IMAGE_PATHS" ); - IECore::SearchPath sp( s ? s : "" ); - loader = new TextureLoader( sp ); - } - return loader.get(); -} - -IECoreGL::ConstTexturePtr ImageGadget::loadTexture( const std::string &fileName ) +IECoreGL::ConstTexturePtr ImageGadget::loadTexture( const std::string &fileName, const TextureParameters ¶meters ) { - TexturePtr texture = textureLoader()->load( fileName ); - if( texture ) - { - applyTextureParameters( texture.get() ); - } - return texture; + static TextureCache g_textureCache( textureGetter, 10000 ); + return g_textureCache.get( { fileName, parameters } ); } void ImageGadget::renderLayer( Layer layer, const Style *style, RenderReason reason ) const diff --git a/src/GafferUI/PlugAdder.cpp b/src/GafferUI/PlugAdder.cpp index 1343aa224f9..ea8d045bfe8 100644 --- a/src/GafferUI/PlugAdder.cpp +++ b/src/GafferUI/PlugAdder.cpp @@ -67,23 +67,11 @@ using namespace GafferUI; namespace { -IECoreGL::Texture *texture( Style::State state ) +const IECoreGL::Texture *texture( Style::State state ) { - static IECoreGL::TexturePtr normalTexture; - static IECoreGL::TexturePtr highlightedTexture; - - IECoreGL::TexturePtr &texture = state == Style::HighlightedState ? highlightedTexture : normalTexture; - if( !texture ) - { - texture = ImageGadget::textureLoader()->load( - state == Style::HighlightedState ? "plugAdderHighlighted.png" : "plugAdder.png" - ); - - IECoreGL::Texture::ScopedBinding binding( *texture ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); - } - return texture.get(); + static IECoreGL::ConstTexturePtr normalTexture = ImageGadget::loadTexture( "plugAdder.png" ); + static IECoreGL::ConstTexturePtr highlightedTexture = ImageGadget::loadTexture( "plugAdderHighlighted.png" ); + return state == Style::HighlightedState ? highlightedTexture.get() : normalTexture.get(); } V3f tangent( const PlugAdder *g ) diff --git a/src/GafferUI/Pointer.cpp b/src/GafferUI/Pointer.cpp index f587f050d72..2985114104f 100644 --- a/src/GafferUI/Pointer.cpp +++ b/src/GafferUI/Pointer.cpp @@ -42,6 +42,9 @@ using namespace GafferUI; +namespace +{ + static ConstPointerPtr g_current; using Registry = std::map; @@ -77,34 +80,16 @@ static Registry ®istry() return r; } -Pointer::Pointer( const IECoreImage::ImagePrimitive *image, const Imath::V2i &hotspot ) - : m_image( image->copy() ), m_hotspot( hotspot ) -{ -} +} // namespace Pointer::Pointer( const std::string &fileName, const Imath::V2i &hotspot ) - : m_image( nullptr ), m_hotspot( hotspot ) + : m_fileName( fileName ), m_hotspot( hotspot ) { - static IECore::CachedReaderPtr g_reader; - if( !g_reader ) - { - const char *sp = getenv( "GAFFERUI_IMAGE_PATHS" ); - sp = sp ? sp : ""; - g_reader = new IECore::CachedReader( IECore::SearchPath( sp ) ); - } - - m_image = IECore::runTimeCast( g_reader->read( fileName ) ); - if( !m_image ) - { - throw IECore::Exception( - fmt::format( "File \"{}\" does not contain an image.", fileName ) - ); - } } -const IECoreImage::ImagePrimitive *Pointer::image() const +const std::string &Pointer::fileName() const { - return m_image.get(); + return m_fileName; } const Imath::V2i &Pointer::hotspot() const @@ -120,7 +105,7 @@ void Pointer::setCurrent( ConstPointerPtr pointer ) } if( pointer && g_current && - pointer->image()->isEqualTo( g_current->image() ) && + pointer->fileName() == g_current->fileName() && pointer->hotspot() == g_current->hotspot() ) { diff --git a/src/GafferUI/StandardNodeGadget.cpp b/src/GafferUI/StandardNodeGadget.cpp index 1593e8c3c84..f626432e6d5 100644 --- a/src/GafferUI/StandardNodeGadget.cpp +++ b/src/GafferUI/StandardNodeGadget.cpp @@ -86,26 +86,16 @@ namespace { const float g_borderWidth = 0.5f; const float g_maxFocusWidth = 2.0f; -IECoreGL::Texture *focusIconTexture( bool focus, bool hover ) +const IECoreGL::Texture *focusIconTexture( bool focus, bool hover ) { - static IECoreGL::TexturePtr focusIconTextures[4] = {}; + static IECoreGL::ConstTexturePtr focusIconTextures[4] = {}; if( !focusIconTextures[0] ) { - focusIconTextures[0] = ImageGadget::textureLoader()->load( "focusOff.png" ); - focusIconTextures[1] = ImageGadget::textureLoader()->load( "focusOn.png" ); - focusIconTextures[2] = ImageGadget::textureLoader()->load( "focusOffHover.png" ); - focusIconTextures[3] = ImageGadget::textureLoader()->load( "focusOnHover.png" ); - - for( int i = 0; i < 4; i++ ) - { - IECoreGL::Texture::ScopedBinding binding( *focusIconTextures[i] ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, -1.0 ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER ); - } + focusIconTextures[0] = ImageGadget::loadTexture( "focusOff.png" ); + focusIconTextures[1] = ImageGadget::loadTexture( "focusOn.png" ); + focusIconTextures[2] = ImageGadget::loadTexture( "focusOffHover.png" ); + focusIconTextures[3] = ImageGadget::loadTexture( "focusOnHover.png" ); } return focusIconTextures[focus + 2 * hover].get(); } diff --git a/src/GafferUIModule/ImageGadgetBinding.cpp b/src/GafferUIModule/ImageGadgetBinding.cpp index 971d7c96ed3..6b268843d9a 100644 --- a/src/GafferUIModule/ImageGadgetBinding.cpp +++ b/src/GafferUIModule/ImageGadgetBinding.cpp @@ -52,7 +52,5 @@ void GafferUIModule::bindImageGadget() GadgetClass() .def( init() ) .def( init() ) - .def( "textureLoader", &ImageGadget::textureLoader, return_value_policy() ) - .staticmethod( "textureLoader" ) ; } diff --git a/src/GafferUIModule/PointerBinding.cpp b/src/GafferUIModule/PointerBinding.cpp index 2dedcb706d0..4a9f366119d 100644 --- a/src/GafferUIModule/PointerBinding.cpp +++ b/src/GafferUIModule/PointerBinding.cpp @@ -51,11 +51,6 @@ using namespace GafferUI; namespace { -IECoreImage::ImagePrimitivePtr image( Pointer *pointer ) -{ - return const_cast( pointer->image() ); -} - PointerPtr getCurrent() { return const_cast( Pointer::getCurrent() ); @@ -66,9 +61,8 @@ PointerPtr getCurrent() void GafferUIModule::bindPointer() { scope s = IECorePython::RefCountedClass( "Pointer" ) - .def( init( ( arg( "image" ), arg( "hotspot" ) = Imath::V2i( -1 ) ) ) ) .def( init( ( arg( "fileName" ), arg( "hotspot" ) = Imath::V2i( -1 ) ) ) ) - .def( "image", &image ) + .def( "fileName", &Pointer::fileName, return_value_policy() ) .def( "hotspot", &Pointer::hotspot, return_value_policy() ) .def( "setCurrent", (void (*)( ConstPointerPtr ))&Pointer::setCurrent ) .def( "setCurrent", (void (*)( const std::string & ))&Pointer::setCurrent )