#define DALI_EGL_GRAPHICS_CONTROLLER_H
/*
- * Copyright (c) 2021 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.
// Final flush
Flush();
+ ClearTextureUpdateQueue();
+
+ // Remove all create queue and command queue.
+ // Note that all memory are already deallocated at Final flush.
+ mCreateTextureQueue = {};
+ mCreateBufferQueue = {};
+ mCreateFramebufferQueue = {};
+ mTextureMipmapGenerationRequests = {};
+ mCommandQueue = {};
+
if(mContext)
{
mContext->GlContextDestroyed();
}
/**
+ * @brief Clears the texture update queue
+ */
+ void ClearTextureUpdateQueue()
+ {
+ // Remove remained CPU-allocated texture memory
+ while(!mTextureUpdateRequests.empty())
+ {
+ auto& request = mTextureUpdateRequests.front();
+ auto& source = request.second;
+
+ if(source.sourceType == Graphics::TextureUpdateSourceInfo::Type::MEMORY)
+ {
+ // free staging memory
+ free(source.memorySource.memory);
+ }
+ mTextureUpdateRequests.pop();
+ }
+ }
+
+ /**
* @brief Flushes all pending updates
*
* Function flushes all pending resource constructions,
*/
void Flush()
{
- if(!mCreateTextureQueue.empty() ||
- !mCreateBufferQueue.empty() ||
- !mCreateFramebufferQueue.empty() ||
- !mTextureUpdateRequests.empty() ||
- !mTextureMipmapGenerationRequests.empty())
+ if(DALI_LIKELY(!mIsShuttingDown))
{
- mGraphics->ActivateResourceContext();
- }
+ if(!mCreateTextureQueue.empty() ||
+ !mCreateBufferQueue.empty() ||
+ !mCreateFramebufferQueue.empty() ||
+ !mTextureUpdateRequests.empty() ||
+ !mTextureMipmapGenerationRequests.empty())
+ {
+ mGraphics->ActivateResourceContext();
+ }
- // Process creations
- ProcessCreateQueues();
+ // Process creations
+ ProcessCreateQueues();
- // Process updates
- ProcessTextureUpdateQueue();
+ // Process updates
+ ProcessTextureUpdateQueue();
- // Process texture mipmap generation requests
- ProcessTextureMipmapGenerationQueue();
+ // Process texture mipmap generation requests
+ ProcessTextureMipmapGenerationQueue();
- // Process main command queue
- ProcessCommandQueues();
+ // Process main command queue
+ ProcessCommandQueues();
+ }
// Reset texture cache in the contexts while destroying textures
ResetTextureCache();
return mCurrentContext;
}
+ /**
+ * @brief Returns EGL shared context
+ *
+ * @return valid EGL shared context
+ */
+ void* GetSharedContext() const
+ {
+ return mSharedContext;
+ }
+
private:
Integration::GlAbstraction* mGlAbstraction{nullptr};
Integration::GlContextHelperAbstraction* mGlContextHelperAbstraction{nullptr};
bool mIsShuttingDown{false}; ///< Indicates whether the controller is shutting down
std::queue<const GLES::CommandBuffer*> mPresentationCommandBuffers{}; ///< Queue of reusable command buffers used by presentation engine
+
+ void* mSharedContext{nullptr}; ///< Shared EGL context
};
} // namespace Graphics