X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fvisual-factory-cache.h;h=6d9f28cb71c9aad43b11d6d4590a1008f6dcf752;hp=f22fb86fc81672eba6df996a5ab4088af7057319;hb=35a7fe4e9b45558b58e365c637e704e2a51a5212;hpb=26bda9f87801f70dc4cc6f9b0a33fef0a7f02199 diff --git a/dali-toolkit/internal/visuals/visual-factory-cache.h b/dali-toolkit/internal/visuals/visual-factory-cache.h index f22fb86..6d9f28c 100644 --- a/dali-toolkit/internal/visuals/visual-factory-cache.h +++ b/dali-toolkit/internal/visuals/visual-factory-cache.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_VISUAL_FACTORY_CACHE_H /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,40 +18,39 @@ */ // EXTERNAL INCLUDES +#include #include #include #include #include -#include // INTERNAL INCLUDES +#include #include #include -#include -#include +#include namespace Dali { +class Texture; namespace Toolkit { - namespace Internal { class ImageAtlasManager; class NPatchLoader; class TextureManager; +class VectorAnimationManager; typedef IntrusivePtr ImageAtlasManagerPtr; - /** * Caches shaders and geometries. Owned by VisualFactory. */ class VisualFactoryCache { public: - /** * Type of shader for caching. */ @@ -59,21 +58,50 @@ public: { COLOR_SHADER, COLOR_SHADER_ROUNDED_CORNER, + COLOR_SHADER_BORDERLINE, + COLOR_SHADER_ROUNDED_BORDERLINE, COLOR_SHADER_BLUR_EDGE, + COLOR_SHADER_ROUNDED_CORNER_BLUR_EDGE, BORDER_SHADER, BORDER_SHADER_ANTI_ALIASING, - GRADIENT_SHADER_LINEAR_USER_SPACE, GRADIENT_SHADER_LINEAR_BOUNDING_BOX, - GRADIENT_SHADER_RADIAL_USER_SPACE, - GRADIENT_SHADER_RADIAL_BOUNDING_BOX, - GRADIENT_SHADER_LINEAR_USER_SPACE_ROUNDED_CORNER, GRADIENT_SHADER_LINEAR_BOUNDING_BOX_ROUNDED_CORNER, - GRADIENT_SHADER_RADIAL_USER_SPACE_ROUNDED_CORNER, + GRADIENT_SHADER_LINEAR_BOUNDING_BOX_BORDERLINE, + GRADIENT_SHADER_LINEAR_BOUNDING_BOX_ROUNDED_BORDERLINE, + GRADIENT_SHADER_LINEAR_USER_SPACE, + GRADIENT_SHADER_LINEAR_USER_SPACE_ROUNDED_CORNER, + GRADIENT_SHADER_LINEAR_USER_SPACE_BORDERLINE, + GRADIENT_SHADER_LINEAR_USER_SPACE_ROUNDED_BORDERLINE, + GRADIENT_SHADER_RADIAL_BOUNDING_BOX, GRADIENT_SHADER_RADIAL_BOUNDING_BOX_ROUNDED_CORNER, + GRADIENT_SHADER_RADIAL_BOUNDING_BOX_BORDERLINE, + GRADIENT_SHADER_RADIAL_BOUNDING_BOX_ROUNDED_BORDERLINE, + GRADIENT_SHADER_RADIAL_USER_SPACE, + GRADIENT_SHADER_RADIAL_USER_SPACE_ROUNDED_CORNER, + GRADIENT_SHADER_RADIAL_USER_SPACE_BORDERLINE, + GRADIENT_SHADER_RADIAL_USER_SPACE_ROUNDED_BORDERLINE, IMAGE_SHADER, + IMAGE_SHADER_ROUNDED_CORNER, + IMAGE_SHADER_BORDERLINE, + IMAGE_SHADER_ROUNDED_BORDERLINE, + IMAGE_SHADER_MASKING, + IMAGE_SHADER_ROUNDED_CORNER_MASKING, + IMAGE_SHADER_BORDERLINE_MASKING, + IMAGE_SHADER_ROUNDED_BORDERLINE_MASKING, IMAGE_SHADER_ATLAS_DEFAULT_WRAP, IMAGE_SHADER_ATLAS_CUSTOM_WRAP, - IMAGE_SHADER_ROUNDED_CORNER, + IMAGE_SHADER_YUV_TO_RGB, + IMAGE_SHADER_ROUNDED_CORNER_YUV_TO_RGB, + IMAGE_SHADER_BORDERLINE_YUV_TO_RGB, + IMAGE_SHADER_ROUNDED_BORDERLINE_YUV_TO_RGB, + NATIVE_IMAGE_SHADER, + NATIVE_IMAGE_SHADER_ROUNDED_CORNER, + NATIVE_IMAGE_SHADER_BORDERLINE, + NATIVE_IMAGE_SHADER_ROUNDED_BORDERLINE, + NATIVE_IMAGE_SHADER_MASKING, + NATIVE_IMAGE_SHADER_ROUNDED_CORNER_MASKING, + NATIVE_IMAGE_SHADER_BORDERLINE_MASKING, + NATIVE_IMAGE_SHADER_ROUNDED_BORDERLINE_MASKING, NINE_PATCH_SHADER, NINE_PATCH_MASK_SHADER, TEXT_SHADER_MULTI_COLOR_TEXT, @@ -114,13 +142,12 @@ public: }; public: - /** * @brief Constructor * * @param[in] preMultiplyOnLoad True if image visuals should pre-multiply alpha on image load. */ - VisualFactoryCache( bool preMultiplyOnLoad ); + VisualFactoryCache(bool preMultiplyOnLoad); /** * @brief Destructor @@ -131,27 +158,27 @@ public: * Request geometry of the given type. * @return The geometry of the required type if it exist in the cache. Otherwise, an empty handle is returned. */ - Geometry GetGeometry( GeometryType type ); + Geometry GetGeometry(GeometryType type); /** * Cache the geometry of the give type. * @param[in] type The geometry type. * @param[in] geometry The geometry for caching. */ - void SaveGeometry( GeometryType type, Geometry geometry); + void SaveGeometry(GeometryType type, Geometry geometry); /** * Request shader of the given type. * @return The shader of the required type if it exist in the cache. Otherwise, an empty handle is returned. */ - Shader GetShader( ShaderType type ); + Shader GetShader(ShaderType type); /** * Cache the geometry of the give type. * @param[in] type The geometry type. * @param[in] geometry The geometry for caching. */ - void SaveShader( ShaderType type, Shader shader ); + void SaveShader(ShaderType type, Shader shader); /* * Greate the quad geometry. @@ -164,18 +191,12 @@ public: * @param[in] gridSize The size of the grid. * @return The created grid geometry. */ - static Geometry CreateGridGeometry( Uint16Pair gridSize ); - - /** - * @brief Returns an image to be used when a visual has failed to correctly render - * @return The broken image handle. - */ - Image GetBrokenVisualImage(); + static Geometry CreateGridGeometry(Uint16Pair gridSize); /** * @copydoc Toolkit::VisualFactory::SetPreMultiplyOnLoad() */ - void SetPreMultiplyOnLoad( bool preMultiply ); + void SetPreMultiplyOnLoad(bool preMultiply); /** * @copydoc Toolkit::VisualFactory::GetPreMultiplyOnLoad() @@ -184,9 +205,19 @@ public: /** * @brief Set an image to be used when a visual has failed to correctly render - * @param[in] brokenImageUrl The broken image url. + * @param[in] brokenImageUrlList The broken image url list + */ + void SetBrokenImageUrl(std::string& defaultBrokenUrl, const std::vector& brokenImageUrlList); + + /** + * @brief Update the broken image Renderer object + * @param[in,out] renderer renderer for broken image + * @param[in] size the size of actor + * @param[in] rendererIsImage True if input renderer use image shader already. + * If true, we don't need to create new renderer when broken image is single image. + * Most of user experience use normal images. So It can reduce runtime. */ - void SetBrokenImageUrl(const std::string& brokenImageUrl); + void UpdateBrokenImageRenderer(Renderer& renderer, const Vector2& size, const bool& rendererIsImage = true); public: /** @@ -208,26 +239,18 @@ public: NPatchLoader& GetNPatchLoader(); /** - * Get the SVG rasterization thread. - * @return A raw pointer pointing to the SVG rasterization thread. + * Get the SVG rasterization manager. + * @return A raw pointer pointing to the SVG rasterization manager. */ - SvgRasterizeThread* GetSVGRasterizationThread(); + SvgRasterizeManager* GetSVGRasterizationManager(); /** - * Get the vector animation thread. - * @return A raw pointer pointing to the vector animation thread. + * Get the vector animation manager. + * @return A reference to the vector animation manager. */ - VectorAnimationThread& GetVectorAnimationThread(); - -private: // for svg rasterization thread - - /** - * Applies the rasterized image to material - */ - void ApplyRasterizedSVGToSampler(); + VectorAnimationManager& GetVectorAnimationManager(); protected: - /** * Undefined copy constructor. */ @@ -239,16 +262,92 @@ protected: VisualFactoryCache& operator=(const VisualFactoryCache& rhs); private: - Geometry mGeometry[GEOMETRY_TYPE_MAX+1]; - Shader mShader[SHADER_TYPE_MAX+1]; - - ImageAtlasManagerPtr mAtlasManager; - TextureManager mTextureManager; - NPatchLoader mNPatchLoader; - SvgRasterizeThread* mSvgRasterizeThread; - std::unique_ptr< VectorAnimationThread > mVectorAnimationThread; - std::string mBrokenImageUrl; - bool mPreMultiplyOnLoad; + /** + * @brief Returns a cached Texture to use when a visual has failed to correctly render + * @param[in] brokenIndex The index of broken image + * + * @return The broken image texture. + */ + Texture GetBrokenVisualImage(uint32_t brokenIndex); + + /** + * @brief Gets the Proper broken image index + * @param[in] size The size of actor + * + * @return The index of broken image + */ + int32_t GetProperBrokenImageIndex(const Vector2& size); + + /** + * @brief Apply a texture and uniforms + * + * @param[in,out] renderer The renderer for broken image + * @param[in] index The index of broken image + */ + void ApplyTextureAndUniforms(Renderer& renderer, int index); + + /** + * @brief Gets a geometry for npatch image + * + * @param[in] index the index of broken image + * @return The Geometry for NPatch + */ + Geometry GetNPatchGeometry(int index); + + /** + * @brief Gets the Npatch Shader object + * + * @param[in] index The index of broken image + * @return The Shader for NPatch + */ + Shader GetNPatchShader(int index); + + /** + * @brief Returns a broken image type + * @param[in] index BrokenImage index + * @return The broken image type. + */ + VisualUrl::Type GetBrokenImageVisualType(int index); + +private: + struct BrokenImageInfo + { + BrokenImageInfo() + : visualType(), + url(""), + npatchId(NPatchData::INVALID_NPATCH_DATA_ID), + texture(), + width(0), + height(0) + { + } + + ~BrokenImageInfo() + { + } + + // Data + VisualUrl::Type visualType; + std::string url; + NPatchData::NPatchDataId npatchId; + Texture texture; + uint32_t width; + uint32_t height; + }; + + Geometry mGeometry[GEOMETRY_TYPE_MAX + 1]; + Shader mShader[SHADER_TYPE_MAX + 1]; + + ImageAtlasManagerPtr mAtlasManager; + TextureManager mTextureManager; + NPatchLoader mNPatchLoader; + + std::unique_ptr mSvgRasterizeManager; + std::unique_ptr mVectorAnimationManager; + bool mPreMultiplyOnLoad; + std::vector mBrokenImageInfoContainer; + std::string mDefaultBrokenImageUrl; + bool mUseDefaultBrokenImageOnly; }; } // namespace Internal