X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fgraphics%2Fgles-impl%2Fgles-graphics-pipeline.h;h=57c490e53f3b5633780c36c8207abf47a7491086;hb=17bf836806d3ae9365002d8d1d4bc281a3e0bc9d;hp=64dad5a41801ed096a3e5b3a8fe2ef739ef2fdc5;hpb=2e7122ef23f46cbad120c5d1e248429db6650627;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/graphics/gles-impl/gles-graphics-pipeline.h b/dali/internal/graphics/gles-impl/gles-graphics-pipeline.h index 64dad5a..57c490e 100644 --- a/dali/internal/graphics/gles-impl/gles-graphics-pipeline.h +++ b/dali/internal/graphics/gles-impl/gles-graphics-pipeline.h @@ -24,15 +24,21 @@ #include // INTERNAL INCLUDES +#include "gles-graphics-reflection.h" #include "gles-graphics-resource.h" namespace Dali::Graphics::GLES { -using PipelineResource = Resource; +class PipelineCache; +class Program; /** - * @brief PipelineWrapper is the object - * returned to the client-side + * @brief PipelineImpl is the implementation of Pipeline + * + * PipelineImpl is owned by the pipeline cache. The client-side + * will receive Graphics::Pipeline objects which are only + * wrappers for this implementation. The lifecycle of + * PipelineImpl is managed by the PipelineCache. */ class PipelineImpl { @@ -41,8 +47,9 @@ public: * @brief Constructor * @param[in] createInfo valid TextureCreateInfo structure * @param[in] controller Reference to the Controller + * @param[in] pipelineCache Reference to valid pipeline cache */ - PipelineImpl(const Graphics::PipelineCreateInfo& createInfo, Graphics::EglGraphicsController& controller); + PipelineImpl(const Graphics::PipelineCreateInfo& createInfo, Graphics::EglGraphicsController& controller, PipelineCache& pipelineCache); /** * @brief Destructor @@ -50,68 +57,42 @@ public: ~PipelineImpl(); /** - * @brief Destroys all the low-level resources used by the class + * @brief Binds pipeline + * + * Binds Pipeline by binding GL program and flushing state. + * + * @param[in] glProgram The GL program to be bound */ - void DestroyResource(); + void Bind(const uint32_t glProgram) const; /** - * @brief Initializes low-level resources - * - * @return Tron success + * @brief Increases ref count */ - bool InitializeResource(); + void Retain(); /** - * @brief Discards object + * @brief Decreases ref count */ - void DiscardResource(); + void Release(); /** - * @brief returns GL program id - * @return GL program id + * @brief Retrieves ref count + * @return Refcount value */ - [[nodiscard]] uint32_t GetGLProgram() const; + [[nodiscard]] uint32_t GetRefCount() const; /** - * @brief Binds pipeline - * - * Binds Pipeline by binding GL program and flushing state. - * - * If previous pipeline specified, it will be used in order to - * avoid redundant state swiches. + * @brief Returns PipelineCreateInfo structure * - * @param[in] prevPipeline previous pipeline + * @return PipelineCreateInfo structure */ - void Bind(GLES::PipelineImpl* prevPipeline); + [[nodiscard]] const PipelineCreateInfo& GetCreateInfo() const; /** - * Executes state change function if condition met + * @brief Returns controller + * + * @return Reference to the Controller */ - template - void ExecuteStateChange(FUNC& func, const STATE* prevPipelineState, const STATE* thisPipelineState) - { - if(!prevPipelineState) - { - func(); - } - else - { - // binary test and execute when different - if(memcmp(prevPipelineState, thisPipelineState, sizeof(STATE)) != 0) - { - func(); - } - } - } - - void Retain(); - - void Release(); - - [[nodiscard]] uint32_t GetRefCount() const; - - [[nodiscard]] const PipelineCreateInfo& GetCreateInfo() const; - [[nodiscard]] auto& GetController() const; private: @@ -143,28 +124,29 @@ private: } } - // Pipeline state is stored as a copy of create info - // data. + // Pipeline state is store locally so any assigned pointers on a + // client-side may go safely out of scope. struct PipelineState; std::unique_ptr mPipelineState; EglGraphicsController& mController; PipelineCreateInfo mCreateInfo; - uint32_t mGlProgram{0u}; - uint32_t mRefCount{0u}; }; /** - * @brief Pipeline class wraps a unique pipeline object - * + * @brief Pipeline class wraps the PipelineImpl */ class Pipeline : public Graphics::Pipeline { public: Pipeline() = delete; + /** + * @brief Constructor + * @param pipeline Pipeline implementation + */ explicit Pipeline(GLES::PipelineImpl& pipeline) : mPipeline(pipeline) { @@ -172,21 +154,57 @@ public: mPipeline.Retain(); } - ~Pipeline() override - { - // decrease refcount - mPipeline.Release(); - } + /** + * @brief Destructor + */ + ~Pipeline() override; + /** + * @brief Returns pipeline implementation + * + * @return Valid pipeline implementation + */ [[nodiscard]] auto& GetPipeline() const { return mPipeline; } + /** + * @brief Returns create info structure + * + * @return Valid create info structure + */ [[nodiscard]] const PipelineCreateInfo& GetCreateInfo() const; + /** + * @brief Returns controller + * + * @return reference to Controller + */ [[nodiscard]] EglGraphicsController& GetController() const; + bool operator==(const PipelineImpl* impl) const + { + return &mPipeline == impl; + } + + /** + * @brief Run by UniquePtr to discard resource + */ + void DiscardResource(); + + /** + * @brief Destroy resource + * + * Despite this class doesn't inherit Resource it must provide + * (so it won't duplicate same data) same set of functions + * so it can work with resource management functions of Controller. + */ + void DestroyResource() + { + // Nothing to do here + } + private: GLES::PipelineImpl& mPipeline; };