X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftexture-manager%2Ftexture-manager-type.h;h=74057fc6e12e9409c1d6db9cf53c6e0eaeeb15c3;hb=d4378fd369c6dc647f829baa717b5686ca454b0d;hp=5f07c1fee6d509c42a09930bc0ef5862e2e36202;hpb=3a1be394aa3551032f262fc329bf3b1b95c8bd24;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/texture-manager/texture-manager-type.h b/dali-toolkit/internal/texture-manager/texture-manager-type.h index 5f07c1f..74057fc 100644 --- a/dali-toolkit/internal/texture-manager/texture-manager-type.h +++ b/dali-toolkit/internal/texture-manager/texture-manager-type.h @@ -38,18 +38,123 @@ namespace Internal */ namespace TextureManagerType { +// Enum! + +enum TextureCacheIndexType +{ + TEXTURE_CACHE_INDEX_FREE_LIST = 0, ///< Only for FreeList. We should not use this for TextureCacheIndex. + TEXTURE_CACHE_INDEX_TYPE_LOCAL = 1, + TEXTURE_CACHE_INDEX_TYPE_TEXTURE, + TEXTURE_CACHE_INDEX_TYPE_BUFFER, + TEXTURE_CACHE_INDEX_TYPE_MASKING, ///< Not implemented yet. + TEXTURE_CACHE_INDEX_TYPE_MAX = 7, ///< Maximum number of cache type we can use. +}; + +// Union! + +/** + * @brief standard union type of texture index. + * Due to the FreeList can only use for uint32_t and we need to seperate + * each index per container type, we can only hold maximum 2^28 textures + * at the same time. + * 0 ~ 2^28 - 1 : index of FreeList. TextureCacheManager will not use it. + * 2^28 ~ 2*2^28 - 1 : index of mTextureInfoContainer, the main texture container. + * 2*2^28 ~ 3*2^28 - 1 : index of mExternalTextures. + * 3*2^28 ~ 4*2^28 - 1 : index of mEncodedBufferTextures. + */ +union TextureCacheIndexData +{ + TextureCacheIndexData() = default; + constexpr TextureCacheIndexData(const std::uint32_t& index) + : indexValue(index) + { + } + constexpr explicit TextureCacheIndexData(const std::int32_t& index) + : indexValue(static_cast(index)) + { + } + constexpr TextureCacheIndexData(const TextureCacheIndexType& type, const std::uint32_t& index) + : detailValue{index, type} + { + } + constexpr TextureCacheIndexData(const TextureCacheIndexData& indexData) + : indexValue(indexData.indexValue) + { + } + constexpr TextureCacheIndexData(TextureCacheIndexData&& indexData) + : indexValue(indexData.indexValue) + { + } + + TextureCacheIndexData& operator=(const std::uint32_t& index) + { + indexValue = index; + return *this; + } + TextureCacheIndexData& operator=(const TextureCacheIndexData& rhs) + { + indexValue = rhs.indexValue; + return *this; + } + TextureCacheIndexData& operator=(TextureCacheIndexData&& rhs) + { + indexValue = rhs.indexValue; + return *this; + } + + constexpr operator std::uint32_t() const + { + return indexValue; + } + constexpr operator std::uint32_t() + { + return indexValue; + } + constexpr explicit operator std::int32_t() const + { + return static_cast(indexValue); + } + constexpr explicit operator std::int32_t() + { + return static_cast(indexValue); + } + + // Return detailValue.index. - the real index of datailValue.type container + constexpr inline std::uint32_t GetIndex() const + { + return detailValue.index; + } + + inline constexpr bool operator==(const TextureCacheIndexData& rhs) + { + return indexValue == rhs.indexValue; + } + inline constexpr bool operator<(const TextureCacheIndexData& rhs) + { + return indexValue < rhs.indexValue; + } + + // Data area + std::uint32_t indexValue; + struct + { + unsigned int index : 28; + TextureCacheIndexType type : 4; + } detailValue; +}; + // Typedef: -typedef std::int32_t TextureId; ///< The TextureId type. This is used as a handle to refer to a particular Texture. -typedef std::int32_t TextureCacheIndex; ///< The TextureCacheIndex type. This is used as a handles to refer to a particular Texture in TextureCacheManager. - /// Note : For the same Texture, TextureId will not be changed. But TextureCacheIndex can be chaged when TextureCacheManager - /// Internal container informations changed by Append or Remove. -typedef std::size_t TextureHash; ///< The type used to store the hash used for Texture caching. +typedef std::int32_t TextureId; ///< The TextureId type. This is used as a handle to refer to a particular Texture. +typedef TextureCacheIndexData TextureCacheIndex; ///< The TextureCacheIndex type. This is used as a handles to refer to a particular Texture in TextureCacheManager. + /// Note : For the same Texture, TextureId will not be changed. But TextureCacheIndex can be chaged when TextureCacheManager + /// Internal container informations changed by Append or Remove. +typedef std::size_t TextureHash; ///< The type used to store the hash used for Texture caching. // Constant values: static constexpr TextureId INVALID_TEXTURE_ID = -1; ///< Used to represent a null TextureId or error -static constexpr TextureCacheIndex INVALID_CACHE_INDEX = -1; ///< Used to represent a null TextureCacheIndex or error +static constexpr TextureCacheIndex INVALID_CACHE_INDEX = 0; ///< Used to represent a null TextureCacheIndex or error // Enum classes: @@ -70,6 +175,7 @@ enum class StorageType KEEP_PIXEL_BUFFER, ///< Keep loaded pixel buffer inside of texture manager without making texture. This could be used for inside pixel process like mask image. RETURN_PIXEL_BUFFER, ///< Return loaded pixel buffer without making texture. /// Because a pixel buffer cannot be used multiple texture, this pixel buffer only cached during loading, and is removed after loading is finished. + KEEP_TEXTURE, ///< Keep loaded texture inside of texture manager. This could be used for pixel processing like GPU masking. UPLOAD_TO_TEXTURE ///< Loaded image will be uploaded to texture and the texture will be returned. }; @@ -95,6 +201,7 @@ enum class LoadState MASK_APPLIED, ///< Loading has finished, Mask is applyied by GPU UPLOADED, ///< Uploaded and ready. (For GPU upload only) CANCELLED, ///< Removed before loading completed + MASK_CANCELLED, ///< Removed before mask applying completed LOAD_FAILED ///< Async loading failed, e.g. connection problem }; @@ -137,7 +244,8 @@ struct TextureInfo const bool& orientationCorrection, const bool& preMultiplyOnLoad, const Dali::AnimatedImageLoading& animatedImageLoading, - const std::uint32_t& frameIndex) + const std::uint32_t& frameIndex, + const bool& loadYuvPlanes) : url(url), desiredSize(desiredSize), useSize(desiredSize), @@ -153,13 +261,17 @@ struct TextureInfo storageType(StorageType::UPLOAD_TO_TEXTURE), animatedImageLoading(animatedImageLoading), frameIndex(frameIndex), + frameCount(0u), + frameInterval(0u), useAtlas(useAtlas), loadSynchronously(loadSynchronously), cropToMask(cropToMask), orientationCorrection(true), preMultiplyOnLoad(preMultiplyOnLoad), - preMultiplied(false) + preMultiplied(false), + loadYuvPlanes(loadYuvPlanes) { + isAnimatedImageFormat = (animatedImageLoading) ? true : false; } /** @@ -170,7 +282,7 @@ struct TextureInfo ObserverListType observerList; ///< Container used to store all observer clients of this Texture Dali::Toolkit::ImageAtlas atlas; ///< The atlas this Texture lays within (if any) Dali::Devel::PixelBuffer pixelBuffer; ///< The PixelBuffer holding the image data (May be empty after upload) - Dali::TextureSet textureSet; ///< The TextureSet holding the Texture + std::vector textures; ///< The Textures VisualUrl url; ///< The URL of the image Dali::ImageDimensions desiredSize; ///< The size requested Dali::ImageDimensions useSize; ///< The size used @@ -185,7 +297,9 @@ struct TextureInfo Dali::SamplingMode::Type samplingMode : 3; ///< The requested SamplingMode StorageType storageType; ///< CPU storage / GPU upload; Dali::AnimatedImageLoading animatedImageLoading; ///< AnimatedImageLoading that contains animated image information. - std::uint32_t frameIndex; ///< frame index that be loaded, in case of animated image + uint32_t frameIndex; ///< Frame index that be loaded, in case of animated image + uint32_t frameCount; ///< Total frame count of input animated image. If this variable is not 0, this textureInfo is for animated image file format. + uint32_t frameInterval; ///< Time interval between this frame and next frame of animated image. UseAtlas useAtlas; ///< USE_ATLAS if an atlas was requested. bool loadSynchronously : 1; ///< True if synchronous loading was requested @@ -193,6 +307,8 @@ struct TextureInfo bool orientationCorrection : 1; ///< True if the image should be rotated to match exif orientation data bool preMultiplyOnLoad : 1; ///< True if the image's color should be multiplied by it's alpha bool preMultiplied : 1; ///< True if the image's color was multiplied by it's alpha + bool isAnimatedImageFormat : 1; ///< true if the image is requested from animated image visual. + bool loadYuvPlanes : 1; ///< true if the image should be loaded as yuv planes }; } // namespace TextureManagerType