namespace ImageSampler
{
-namespace
-{
-
-// @todo MESH_REWORK Remove file after image removal
-
-// Adjust these shift sizes if the FilterMode enum grows
-const int MINIFY_BIT_SHIFT = 0; // Room for 16
-const int MAGNIFY_BIT_SHIFT = 4;
-const int UWRAP_BIT_SHIFT = 8;
-const int VWRAP_BIT_SHIFT = 12;
-
-const int MASK_MINIFY_FILTER = 0x0000000F;
-const int MASK_MAGNIFY_FILTER = 0x000000F0;
-const int MASK_UWRAP_MODE = 0x00000F00;
-const int MASK_VWRAP_MODE = 0x0000F000;
-
-} // namespace
-
/**
* Utility to store one of the sampling parameters values.
* @param[out] options A bitmask used to store the FilterMode values.
*/
namespace ImageSampler
{
+ /**
+ * Bitshift values
+ */
+ enum
+ {
+ MINIFY_BIT_SHIFT = 0,
+ MAGNIFY_BIT_SHIFT = 4,
+ UWRAP_BIT_SHIFT = 8,
+ VWRAP_BIT_SHIFT = 12
+ };
+
+ /**
+ * Mask values
+ */
+ enum
+ {
+ MASK_MINIFY_FILTER = 0x000F,
+ MASK_MAGNIFY_FILTER = 0x00F0,
+ MASK_UWRAP_MODE = 0x0F00,
+ MASK_VWRAP_MODE = 0xF000,
+ };
+
+ /**
+ * Precalculate default sampler bitfield
+ */
+ enum
+ {
+ DEFAULT_BITFIELD = (Dali::FilterMode::DEFAULT<<MINIFY_BIT_SHIFT) | (Dali::FilterMode::DEFAULT<<MAGNIFY_BIT_SHIFT) | (Dali::WrapMode::DEFAULT<<UWRAP_BIT_SHIFT) | (Dali::WrapMode::DEFAULT<<VWRAP_BIT_SHIFT)
+ };
+
/**
* @brief Pack the filter mode into a bitfield.
*
SceneGraph::TextureCache& textureCache,
Program& program )
{
- // @todo MESH_REWORK Write a cache of texture units to commonly used sampler textures
int textureUnit = 0;
const std::vector<Render::Texture>& textures( mRenderDataProvider->GetTextures());
}
else
{
- samplerBitfield = ImageSampler::PackBitfield(FilterMode::DEFAULT, FilterMode::DEFAULT, WrapMode::DEFAULT, WrapMode::DEFAULT);
+ samplerBitfield = ImageSampler::DEFAULT_BITFIELD;
}
texture->ApplySampler( (TextureUnit)textureUnit, samplerBitfield );
* Constructor
*/
Sampler()
- : mMinFilter( Dali::FilterMode::DEFAULT),
+ : mMinFilter( Dali::FilterMode::DEFAULT ),
mMagFilter( Dali::FilterMode::DEFAULT ),
mUWrapMode( Dali::WrapMode::DEFAULT ),
mVWrapMode( Dali::WrapMode::DEFAULT )
/**
* Destructor
*/
- virtual ~Sampler(){}
+ ~Sampler()
+ {}
/**
* Set the filter modes for minify and magnify filters
* Get the filter mode
* @return The minify filter mode
*/
- virtual FilterMode GetMinifyFilterMode() const
+ FilterMode GetMinifyFilterMode() const
{
return mMinFilter;
}
* Get the filter mode
* @return The magnify filter mode
*/
- virtual FilterMode GetMagnifyFilterMode() const
+ FilterMode GetMagnifyFilterMode() const
{
return mMagFilter;
}
* Get the horizontal wrap mode
* @return The horizontal wrap mode
*/
- virtual WrapMode GetUWrapMode() const
+ WrapMode GetUWrapMode() const
{
return mUWrapMode;
}
* Get the vertical wrap mode
* @return The vertical wrap mode
*/
- virtual WrapMode GetVWrapMode() const
+ WrapMode GetVWrapMode() const
{
return mVWrapMode;
}
FilterMode mMagFilter; ///< The magnify filter
WrapMode mUWrapMode; ///< The horizontal wrap mode
WrapMode mVWrapMode; ///< The vertical wrap mode
+
};
} // namespace Render
-
-
} // namespace Internal
+
} // namespace Dali
* Constructor
*/
Texture()
- :mUniformName(""),
- mTextureId(Integration::InvalidResourceId),
- mSampler(0)
+ :mUniformName(),
+ mSampler(0),
+ mTextureId(Integration::InvalidResourceId)
{}
/**
* Constructor
*/
- Texture( const char* samplerName, Integration::ResourceId textureId, Render::Sampler* sampler )
- :mUniformName(samplerName),
- mTextureId( textureId),
- mSampler(sampler)
+ Texture( const std::string& samplerName, Integration::ResourceId textureId, Render::Sampler* sampler )
+ :mUniformName( samplerName ),
+ mSampler( sampler ),
+ mTextureId( textureId)
{}
/**
return mSampler;
}
-public: // SamplerDataProvider interface - called from RenderThread
+public: // called from RenderThread
+
/**
* Get the texture unit uniform name
* @return the name of the texture unit uniform
}
private:
- std::string mUniformName;
- Integration::ResourceId mTextureId;
- Render::Sampler* mSampler;
+ std::string mUniformName;
+ Render::Sampler* mSampler;
+ Integration::ResourceId mTextureId;
};
} // namespace SceneGraph
* @param[in] index The index of the texture in the textures array
* @return the uniform name
*/
- const char* GetTextureUniformName( size_t index )
+ const std::string& GetTextureUniformName( size_t index )
{
- return mUniformName[index].c_str();
+ return mUniformName[index];
}
/**
*/
enum Type
{
- NONE = 0, ///< Use GL system defaults (minification NEAREST_MIPMAP_LINEAR, magnification LINEAR)
- DEFAULT, ///< Use dali defaults (minification LINEAR, magnification LINEAR)
+ NONE = 0, ///< Use GL defaults (minification NEAREST_MIPMAP_LINEAR, magnification LINEAR)
+ DEFAULT, ///< Use Dali defaults (minification LINEAR, magnification LINEAR)
NEAREST, ///< Filter nearest
LINEAR ///< Filter linear
};