Make gl interface pointer use case with DALI_LIKELY 24/323224/2
authorEunki, Hong <eunkiki.hong@samsung.com>
Thu, 24 Apr 2025 08:44:03 +0000 (17:44 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Mon, 28 Apr 2025 01:33:00 +0000 (10:33 +0900)
Since most of cases will use valid gl objects.
So let we ensure the gl validation by DALI_LIKELY markers.

Change-Id: Ieb7e9b8734ab0ac353b8b33422b776dd88007972
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
13 files changed:
dali/internal/graphics/gles-impl/egl-graphics-controller.cpp
dali/internal/graphics/gles-impl/gles-context.cpp
dali/internal/graphics/gles-impl/gles-graphics-buffer.cpp
dali/internal/graphics/gles-impl/gles-graphics-framebuffer.cpp
dali/internal/graphics/gles-impl/gles-graphics-pipeline.cpp
dali/internal/graphics/gles-impl/gles-graphics-program.cpp
dali/internal/graphics/gles-impl/gles-graphics-reflection.cpp
dali/internal/graphics/gles-impl/gles-graphics-shader.cpp
dali/internal/graphics/gles-impl/gles-graphics-texture.cpp
dali/internal/graphics/gles-impl/gles-sync-object.cpp
dali/internal/graphics/gles-impl/gles-sync-pool.cpp
dali/internal/graphics/gles-impl/gles2-graphics-memory.cpp
dali/internal/graphics/gles-impl/gles3-graphics-memory.cpp

index fc5030ca248aa56fe58c345e933491c7f257e465..30b649c66debd1c7a71e234506d626d3ba05bcc9 100644 (file)
@@ -478,8 +478,8 @@ MemoryRequirements EglGraphicsController::GetBufferMemoryRequirements(Buffer& bu
 {
   MemoryRequirements requirements{};
 
-  auto gl = GetGL();
-  if(gl)
+  auto* gl = GetGL();
+  if(DALI_LIKELY(gl))
   {
     GLint align;
     gl->GetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &align);
index 0301d02f9eb695c9c7584c213d0f942ee8e293e9..481ae03606c27fc37f662e52389dc4eee8ff5148 100644 (file)
@@ -144,7 +144,7 @@ struct Context::Impl
   void InitializeGlState()
   {
     auto* gl = GetGL();
-    if(gl)
+    if(DALI_LIKELY(gl))
     {
       mGlStateCache.mClearColorSet        = false;
       mGlStateCache.mColorMask            = true;
@@ -193,7 +193,7 @@ struct Context::Impl
   void FlushVertexAttributeLocations()
   {
     auto* gl = GetGL();
-    if(gl)
+    if(DALI_LIKELY(gl))
     {
       for(unsigned int i = 0; i < MAX_ATTRIBUTE_CACHE_SIZE; ++i)
       {
@@ -225,7 +225,7 @@ struct Context::Impl
   void SetVertexAttributeLocation(unsigned int location, bool state)
   {
     auto* gl = GetGL();
-    if(gl)
+    if(DALI_LIKELY(gl))
     {
       if(location >= MAX_ATTRIBUTE_CACHE_SIZE)
       {
@@ -971,7 +971,7 @@ void Context::EndRenderPass(GLES::TextureDependencyChecker& dependencyChecker)
   {
     GLES::Framebuffer* framebuffer = mImpl->mCurrentRenderTarget->GetFramebuffer();
     auto*              gl          = mImpl->GetGL();
-    if(framebuffer && gl)
+    if(DALI_LIKELY(gl) && framebuffer)
     {
       /* @todo Full dependency checking would need to store textures in Begin, and create
        * fence objects here; but we're going to draw all fbos on shared context in serial,
@@ -1015,7 +1015,7 @@ void Context::ReadPixels(uint8_t* buffer)
   {
     GLES::Framebuffer* framebuffer = mImpl->mCurrentRenderTarget->GetFramebuffer();
     auto*              gl          = mImpl->GetGL();
-    if(framebuffer && gl)
+    if(DALI_LIKELY(gl) && framebuffer)
     {
       gl->Finish(); // To guarantee ReadPixels.
       gl->ReadPixels(0, 0, framebuffer->GetCreateInfo().size.width, framebuffer->GetCreateInfo().size.height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
@@ -1052,7 +1052,7 @@ void Context::ClearUniformBufferCache()
 void Context::ColorMask(bool enabled)
 {
   auto* gl = mImpl->GetGL();
-  if(gl && enabled != mImpl->mGlStateCache.mColorMask)
+  if(DALI_LIKELY(gl) && enabled != mImpl->mGlStateCache.mColorMask)
   {
     mImpl->mGlStateCache.mColorMask = enabled;
     gl->ColorMask(enabled, enabled, enabled, enabled);
@@ -1073,7 +1073,7 @@ void Context::ClearBuffer(uint32_t mask, bool forceClear)
 {
   mask     = mImpl->mGlStateCache.mFrameBufferStateCache.GetClearMask(mask, forceClear, mImpl->mGlStateCache.mScissorTestEnabled);
   auto* gl = mImpl->GetGL();
-  if(mask > 0 && gl)
+  if(DALI_LIKELY(gl) && mask > 0)
   {
     gl->Clear(mask);
   }
@@ -1082,7 +1082,8 @@ void Context::ClearBuffer(uint32_t mask, bool forceClear)
 void Context::InvalidateDepthStencilBuffers()
 {
 #ifndef DALI_PROFILE_TV
-  if(auto* gl = mImpl->GetGL())
+  auto* gl = mImpl->GetGL();
+  if(DALI_LIKELY(gl))
   {
     GLenum attachments[] = {GL_DEPTH, GL_STENCIL};
     gl->InvalidateFramebuffer(GL_FRAMEBUFFER, 2, attachments);
@@ -1095,7 +1096,7 @@ void Context::InvalidateDepthStencilBuffers()
 void Context::SetScissorTestEnabled(bool scissorEnabled)
 {
   auto* gl = mImpl->GetGL();
-  if(gl && mImpl->mGlStateCache.mScissorTestEnabled != scissorEnabled)
+  if(DALI_LIKELY(gl) && mImpl->mGlStateCache.mScissorTestEnabled != scissorEnabled)
   {
     mImpl->mGlStateCache.mScissorTestEnabled = scissorEnabled;
 
@@ -1113,7 +1114,7 @@ void Context::SetScissorTestEnabled(bool scissorEnabled)
 void Context::SetStencilTestEnable(bool stencilEnable)
 {
   auto* gl = mImpl->GetGL();
-  if(gl && stencilEnable != mImpl->mGlStateCache.mStencilBufferEnabled)
+  if(DALI_LIKELY(gl) && stencilEnable != mImpl->mGlStateCache.mStencilBufferEnabled)
   {
     mImpl->mGlStateCache.mStencilBufferEnabled = stencilEnable;
 
@@ -1131,7 +1132,7 @@ void Context::SetStencilTestEnable(bool stencilEnable)
 void Context::StencilMask(uint32_t writeMask)
 {
   auto* gl = mImpl->GetGL();
-  if(gl && writeMask != mImpl->mGlStateCache.mStencilMask)
+  if(DALI_LIKELY(gl) && writeMask != mImpl->mGlStateCache.mStencilMask)
   {
     mImpl->mGlStateCache.mStencilMask = writeMask;
 
@@ -1144,7 +1145,7 @@ void Context::StencilFunc(Graphics::CompareOp compareOp,
                           uint32_t            compareMask)
 {
   auto* gl = mImpl->GetGL();
-  if(gl &&
+  if(DALI_LIKELY(gl) &&
      (compareOp != mImpl->mGlStateCache.mStencilFunc ||
       reference != mImpl->mGlStateCache.mStencilFuncRef ||
       compareMask != mImpl->mGlStateCache.mStencilFuncMask))
@@ -1162,7 +1163,7 @@ void Context::StencilOp(Graphics::StencilOp failOp,
                         Graphics::StencilOp passOp)
 {
   auto* gl = mImpl->GetGL();
-  if(gl &&
+  if(DALI_LIKELY(gl) &&
      (failOp != mImpl->mGlStateCache.mStencilOpFail ||
       depthFailOp != mImpl->mGlStateCache.mStencilOpDepthFail ||
       passOp != mImpl->mGlStateCache.mStencilOpDepthPass))
@@ -1178,7 +1179,7 @@ void Context::StencilOp(Graphics::StencilOp failOp,
 void Context::SetDepthCompareOp(Graphics::CompareOp compareOp)
 {
   auto* gl = mImpl->GetGL();
-  if(gl && compareOp != mImpl->mGlStateCache.mDepthFunction)
+  if(DALI_LIKELY(gl) && compareOp != mImpl->mGlStateCache.mDepthFunction)
   {
     mImpl->mGlStateCache.mDepthFunction = compareOp;
 
@@ -1189,7 +1190,7 @@ void Context::SetDepthCompareOp(Graphics::CompareOp compareOp)
 void Context::SetDepthTestEnable(bool depthTestEnable)
 {
   auto* gl = mImpl->GetGL();
-  if(gl && depthTestEnable != mImpl->mGlStateCache.mDepthBufferEnabled)
+  if(DALI_LIKELY(gl) && depthTestEnable != mImpl->mGlStateCache.mDepthBufferEnabled)
   {
     mImpl->mGlStateCache.mDepthBufferEnabled = depthTestEnable;
 
@@ -1207,7 +1208,7 @@ void Context::SetDepthTestEnable(bool depthTestEnable)
 void Context::SetDepthWriteEnable(bool depthWriteEnable)
 {
   auto* gl = mImpl->GetGL();
-  if(gl && depthWriteEnable != mImpl->mGlStateCache.mDepthMaskEnabled)
+  if(DALI_LIKELY(gl) && depthWriteEnable != mImpl->mGlStateCache.mDepthMaskEnabled)
   {
     mImpl->mGlStateCache.mDepthMaskEnabled = depthWriteEnable;
 
@@ -1218,7 +1219,7 @@ void Context::SetDepthWriteEnable(bool depthWriteEnable)
 void Context::ActiveTexture(uint32_t textureBindingIndex)
 {
   auto* gl = mImpl->GetGL();
-  if(gl && mImpl->mGlStateCache.mActiveTextureUnit != textureBindingIndex)
+  if(DALI_LIKELY(gl) && mImpl->mGlStateCache.mActiveTextureUnit != textureBindingIndex)
   {
     mImpl->mGlStateCache.mActiveTextureUnit = textureBindingIndex;
 
@@ -1230,7 +1231,7 @@ void Context::BindTexture(GLenum target, BoundTextureType textureTypeId, uint32_
 {
   uint32_t typeId = static_cast<uint32_t>(textureTypeId);
   auto*    gl     = mImpl->GetGL();
-  if(gl && mImpl->mGlStateCache.mBoundTextureId[mImpl->mGlStateCache.mActiveTextureUnit][typeId] != textureId)
+  if(DALI_LIKELY(gl) && mImpl->mGlStateCache.mBoundTextureId[mImpl->mGlStateCache.mActiveTextureUnit][typeId] != textureId)
   {
     mImpl->mGlStateCache.mBoundTextureId[mImpl->mGlStateCache.mActiveTextureUnit][typeId] = textureId;
 
@@ -1240,7 +1241,8 @@ void Context::BindTexture(GLenum target, BoundTextureType textureTypeId, uint32_
 
 void Context::GenerateMipmap(GLenum target)
 {
-  if(auto* gl = mImpl->GetGL())
+  auto* gl = mImpl->GetGL();
+  if(DALI_LIKELY(gl))
   {
     gl->GenerateMipmap(target);
   }
@@ -1248,7 +1250,8 @@ void Context::GenerateMipmap(GLenum target)
 
 bool Context::BindBuffer(GLenum target, uint32_t bufferId)
 {
-  if(auto* gl = mImpl->GetGL())
+  auto* gl = mImpl->GetGL();
+  if(DALI_LIKELY(gl))
   {
     switch(target)
     {
@@ -1310,7 +1313,7 @@ void Context::InvalidateCachedPipeline(GLES::Pipeline* pipeline)
 
   // Remove cached VAO map
   auto* gl = mImpl->GetGL();
-  if(gl)
+  if(DALI_LIKELY(gl))
   {
     const auto* program = pipeline->GetCreateInfo().programState->program;
     if(program)
index 5abfcdb86c69075e2e2316853c993de2a401d046..d33082e35a0ded881f3e88129ad25da1f26350cf 100644 (file)
@@ -156,9 +156,9 @@ void Buffer::InitializeGPUBuffer()
     return;
   }
 
-  auto context = mController.GetCurrentContext();
-  auto gl      = mController.GetGL();
-  if(!gl || !context)
+  auto* context = mController.GetCurrentContext();
+  auto* gl      = mController.GetGL();
+  if(DALI_UNLIKELY(!gl || !context))
   {
     return;
   }
@@ -193,8 +193,8 @@ void Buffer::DestroyResource()
   {
     if(DALI_LIKELY(!EglGraphicsController::IsShuttingDown()))
     {
-      auto gl = mController.GetGL();
-      if(gl)
+      auto* gl = mController.GetGL();
+      if(DALI_LIKELY(gl))
       {
         gl->DeleteBuffers(1, &mBufferId);
       }
@@ -209,9 +209,9 @@ void Buffer::DiscardResource()
 
 void Buffer::Bind(Graphics::BufferUsage bindingTarget) const
 {
-  auto context = mController.GetCurrentContext();
-  auto gl      = mController.GetGL();
-  if(!gl || !context)
+  auto* context = mController.GetCurrentContext();
+  auto* gl      = mController.GetGL();
+  if(DALI_UNLIKELY(!gl || !context))
   {
     return;
   }
index c1e7e114bd181fd83320e2c214a4a9eb7481274a..343f70986724abdd05a271d369374a3686c8df25 100644 (file)
@@ -106,8 +106,8 @@ Framebuffer::~Framebuffer() = default;
 
 bool Framebuffer::InitializeResource()
 {
-  auto gl = mController.GetGL();
-  if(gl && mSharedContext && !mInitialized)
+  auto* gl = mController.GetGL();
+  if(DALI_LIKELY(gl) && mSharedContext && !mInitialized)
   {
     DALI_ASSERT_DEBUG(mSharedContext == mController.GetCurrentContext() && "Framebuffer is create at another context!");
     mInitialized = true;
@@ -202,8 +202,8 @@ void Framebuffer::DestroyResource()
 {
   if(DALI_LIKELY(!EglGraphicsController::IsShuttingDown()))
   {
-    auto gl = mController.GetGL();
-    if(gl && mInitialized)
+    auto* gl = mController.GetGL();
+    if(DALI_LIKELY(gl) && mInitialized)
     {
       if(mDepthBufferId)
       {
@@ -239,8 +239,8 @@ void Framebuffer::DiscardResource()
 
 void Framebuffer::Bind() const
 {
-  auto gl = mController.GetGL();
-  if(gl && mSharedContext)
+  auto* gl = mController.GetGL();
+  if(DALI_LIKELY(gl) && mSharedContext)
   {
     DALI_ASSERT_DEBUG(mSharedContext == mController.GetCurrentContext() && "Framebuffer is bound to another context!");
     gl->BindFramebuffer(GL_FRAMEBUFFER, mFramebufferId);
@@ -253,8 +253,8 @@ void Framebuffer::Bind() const
 
 void Framebuffer::AttachTexture(const Graphics::Texture* texture, uint32_t attachmentId, uint32_t layerId, uint32_t levelId)
 {
-  auto gl = mController.GetGL();
-  if(gl)
+  auto* gl = mController.GetGL();
+  if(DALI_LIKELY(gl))
   {
     auto graphicsTexture = static_cast<const GLES::Texture*>(texture);
     auto textarget       = (graphicsTexture->GetCreateInfo().textureType == Graphics::TextureType::TEXTURE_2D) ? graphicsTexture->GetGlTarget() : GL_TEXTURE_CUBE_MAP_POSITIVE_X + layerId;
index 19d9a7dca3467659d0fd280f24bf2186ae86cfe7..d3818434f6e4cd843bfa9a70c197a23e6f3036e3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
@@ -96,7 +96,8 @@ void PipelineImpl::Bind(const uint32_t glProgram) const
     return; // Early out if shutting down
   }
 
-  if(auto gl = GetController().GetGL())
+  auto* gl = GetController().GetGL();
+  if(DALI_LIKELY(gl))
   {
     gl->UseProgram(glProgram);
   }
index 848986befbf50576e455280f13cc40856c0295d3..842974deb8fd1743a607075d4c2689b6077c8168 100644 (file)
@@ -151,13 +151,12 @@ bool ProgramImpl::Destroy()
 
   if(mImpl->glProgram)
   {
-    auto gl = mImpl->controller.GetGL();
-    if(!gl)
+    auto* gl = mImpl->controller.GetGL();
+    if(DALI_LIKELY(gl))
     {
-      return false;
+      gl->DeleteProgram(mImpl->glProgram);
+      return true;
     }
-    gl->DeleteProgram(mImpl->glProgram);
-    return true;
   }
   return false;
 }
@@ -165,7 +164,7 @@ bool ProgramImpl::Destroy()
 void ProgramImpl::Preprocess()
 {
   auto* gl               = mImpl->controller.GetGL();
-  bool  advancedBlending = !gl ? false : gl->IsAdvancedBlendEquationSupported();
+  bool  advancedBlending = DALI_LIKELY(gl) ? gl->IsAdvancedBlendEquationSupported() : false;
   // For now only Vertex and Fragment shader stages supported
   // and one per stage
   std::string  vertexString;
@@ -256,8 +255,8 @@ void ProgramImpl::Preprocess()
 bool ProgramImpl::Create()
 {
   // Create and link new program
-  auto gl = mImpl->controller.GetGL();
-  if(!gl)
+  auto* gl = mImpl->controller.GetGL();
+  if(DALI_UNLIKELY(!gl))
   {
     // Do nothing during shutdown
     return false;
@@ -415,7 +414,7 @@ void ProgramImpl::UpdateStandaloneUniformBlock(const char* ptr)
   }
 
   auto* gl = GetController().GetGL();
-  if(!gl)
+  if(DALI_UNLIKELY(!gl))
   {
     return; // Early out if no GL found
   }
@@ -597,8 +596,8 @@ bool ProgramImpl::LoadProgramBinary()
       return false;
     }
 
-    auto gl = mImpl->controller.GetGL();
-    if(!gl)
+    auto* gl = mImpl->controller.GetGL();
+    if(DALI_UNLIKELY(!gl))
     {
       DALI_LOG_ERROR("Can't Get GL \n");
       return false;
@@ -646,8 +645,8 @@ void ProgramImpl::SaveProgramBinary()
   GLint  binaryLength{0u};
   GLint  binarySize{0u};
   GLenum format;
-  auto   gl = mImpl->controller.GetGL();
-  if(!gl)
+  auto*  gl = mImpl->controller.GetGL();
+  if(DALI_UNLIKELY(!gl))
   {
     DALI_LOG_ERROR("Can't Get GL \n");
     return;
index a56bfe0bb5130afb40214d0bb5e59aa0be41fdba..34a920419e34bdf12ff99f5a38effd86442ce690 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
@@ -238,8 +238,8 @@ void Reflection::BuildVertexAttributeReflection()
   GLenum type;
   char*  name;
 
-  auto gl = mController.GetGL();
-  if(!gl)
+  auto* gl = mController.GetGL();
+  if(DALI_UNLIKELY(!gl))
   {
     // Do nothing during shutdown
     return;
@@ -283,17 +283,17 @@ void Reflection::BuildVertexAttributeReflection()
 
 void Reflection::BuildUniformBlockReflection()
 {
-  auto  gl        = mController.GetGL();
-  auto  glProgram = mProgram.GetGlProgram();
-  char* name;
-  int   numUniformBlocks = 0;
-
-  if(!gl)
+  auto* gl = mController.GetGL();
+  if(DALI_UNLIKELY(!gl))
   {
     // Do nothing during shutdown
     return;
   }
 
+  auto  glProgram = mProgram.GetGlProgram();
+  char* name;
+  int   numUniformBlocks = 0;
+
   DALI_LOG_INFO(gGraphicsReflectionLogFilter, Debug::General, "Build uniform block reflection for glProgram : %u\n", glProgram);
 
   int   maxUniformNameLength;
@@ -660,8 +660,8 @@ Graphics::ShaderLanguage Reflection::GetLanguage() const
 {
   auto version = Graphics::ShaderLanguage::GLSL_3_2;
 
-  auto gl = mController.GetGL();
-  if(!gl)
+  auto* gl = mController.GetGL();
+  if(DALI_UNLIKELY(!gl))
   {
     // Do nothing during shutdown
     return version;
index 069d9f8af7d59e7b02395cf9bea7cdf8188b6d31..18a7f6d033bf343c355fd6bf196a31c94f20ad55 100644 (file)
@@ -54,9 +54,9 @@ struct ShaderImpl::Impl
 
   bool Compile()
   {
-    auto gl = controller.GetGL();
+    auto* gl = controller.GetGL();
 
-    if(!gl)
+    if(DALI_UNLIKELY(!gl))
     {
       return false;
     }
@@ -142,9 +142,9 @@ struct ShaderImpl::Impl
 
   void Destroy()
   {
-    auto gl = controller.GetGL();
+    auto* gl = controller.GetGL();
 
-    if(gl && glShader)
+    if(DALI_LIKELY(gl) && glShader)
     {
       gl->DeleteShader(glShader);
       glShader = 0;
index 9c82d0c9eb7840136d3560fc07dda780f6768468..97d6cf9d45462e15d0a4436326683e1d79dde0c7 100644 (file)
@@ -128,11 +128,11 @@ bool Texture::InitializeResource()
 
 bool Texture::InitializeNativeImage()
 {
-  auto   context = mController.GetCurrentContext();
-  auto   gl      = mController.GetGL();
+  auto*  context = mController.GetCurrentContext();
+  auto*  gl      = mController.GetGL();
   GLuint texture{0};
 
-  if(!gl || !context)
+  if(DALI_UNLIKELY(!gl || !context))
   {
     // Do nothing during shutdown
     return false;
@@ -177,9 +177,9 @@ bool Texture::InitializeNativeImage()
 
 bool Texture::InitializeTexture()
 {
-  auto context = mController.GetCurrentContext();
-  auto gl      = mController.GetGL();
-  if(!gl || !context)
+  auto* context = mController.GetCurrentContext();
+  auto* gl      = mController.GetGL();
+  if(DALI_UNLIKELY(!gl || !context))
   {
     // Do nothing during shutdown
     return false;
@@ -312,8 +312,8 @@ void Texture::DestroyResource()
 {
   if(DALI_LIKELY(!EglGraphicsController::IsShuttingDown()))
   {
-    auto gl = mController.GetGL();
-    if(!gl)
+    auto* gl = mController.GetGL();
+    if(DALI_UNLIKELY(!gl))
     {
       return;
     }
@@ -340,9 +340,9 @@ void Texture::DiscardResource()
 
 void Texture::Bind(const TextureBinding& binding) const
 {
-  auto context = mController.GetCurrentContext();
-  auto gl      = mController.GetGL();
-  if(!gl || !context)
+  auto* context = mController.GetCurrentContext();
+  auto* gl      = mController.GetGL();
+  if(DALI_UNLIKELY(!gl || !context))
   {
     // Do nothing during shutdown
     return;
@@ -431,8 +431,8 @@ bool Texture::TryConvertPixelData(const void* pData, Graphics::Format srcFormat,
 
 void Texture::SetSamplerParameter(uint32_t param, uint32_t& cacheValue, uint32_t value) const
 {
-  auto gl = mController.GetGL();
-  if(gl && cacheValue != value)
+  auto* gl = mController.GetGL();
+  if(DALI_LIKELY(gl) && cacheValue != value)
   {
     gl->TexParameteri(mGlTarget, param, value);
     cacheValue = value;
index 3e29a791f1c44a6f3c5eda645b0d4bfceb08d5a2..ac4ee91f1f9f9a880b091095440e72309b082551 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
@@ -38,8 +38,8 @@ void SyncObject::DestroyResource()
 {
   if(DALI_LIKELY(!EglGraphicsController::IsShuttingDown()))
   {
-    auto gl = mController.GetGL();
-    if(gl)
+    auto* gl = mController.GetGL();
+    if(DALI_LIKELY(gl))
     {
       gl->DeleteSync(mGlSyncObject);
     }
@@ -50,8 +50,8 @@ void SyncObject::DestroyResource()
 bool SyncObject::InitializeResource()
 {
   // Initialized not from a resource queue, but from a command.
-  auto gl = mController.GetGL();
-  if(gl)
+  auto* gl = mController.GetGL();
+  if(DALI_LIKELY(gl))
   {
     mGlSyncObject = gl->FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
   }
@@ -66,8 +66,8 @@ void SyncObject::DiscardResource()
 
 bool SyncObject::IsSynced()
 {
-  auto gl = mController.GetGL();
-  if(gl && mGlSyncObject)
+  auto* gl = mController.GetGL();
+  if(DALI_LIKELY(gl) && mGlSyncObject)
   {
     GLenum result = gl->ClientWaitSync(mGlSyncObject, 0, 0ull);
     return result == GL_ALREADY_SIGNALED || result == GL_CONDITION_SATISFIED;
index 13a480eeb9d734616b13eb43be413b7a67dcd86f..540abbcc394bab1fc83abef415de13f2f0f3d962 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
@@ -42,8 +42,8 @@ SyncPool::AgingSyncObject::AgingSyncObject(Graphics::EglGraphicsController& cont
   }
   else
   {
-    auto gl = controller.GetGL();
-    if(gl)
+    auto* gl = controller.GetGL();
+    if(DALI_LIKELY(gl))
     {
       glSyncObject = gl->FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
     }
@@ -61,8 +61,8 @@ SyncPool::AgingSyncObject::~AgingSyncObject()
     }
     else
     {
-      auto gl = controller.GetGL();
-      if(gl && glSyncObject != nullptr)
+      auto* gl = controller.GetGL();
+      if(DALI_LIKELY(gl) && glSyncObject != nullptr)
       {
         gl->DeleteSync(glSyncObject);
       }
@@ -83,8 +83,8 @@ bool SyncPool::AgingSyncObject::IsSynced()
   }
   else
   {
-    auto gl = controller.GetGL();
-    if(gl && glSyncObject)
+    auto* gl = controller.GetGL();
+    if(DALI_LIKELY(gl) && glSyncObject)
     {
       DALI_LOG_INFO(gLogSyncFilter, Debug::Verbose, "AgingSyncObject::IsSynced(); glClientWaitSync 0ms\n");
       const GLuint64 TIMEOUT = 0; //0ms!
@@ -111,8 +111,8 @@ bool SyncPool::AgingSyncObject::ClientWait()
   }
   else
   {
-    auto gl = controller.GetGL();
-    if(gl && glSyncObject)
+    auto* gl = controller.GetGL();
+    if(DALI_LIKELY(gl) && glSyncObject)
     {
       DALI_LOG_INFO(gLogSyncFilter, Debug::Verbose, "AgingSyncObject::ClientWait(); glClientWaitSync 1ms\n");
       const GLuint64 TIMEOUT = 1000000; //1ms!
@@ -137,8 +137,8 @@ void SyncPool::AgingSyncObject::Wait()
   }
   else
   {
-    auto gl = controller.GetGL();
-    if(gl && glSyncObject)
+    auto* gl = controller.GetGL();
+    if(DALI_LIKELY(gl) && glSyncObject)
     {
       DALI_LOG_INFO(gLogSyncFilter, Debug::Verbose, "AgingSyncObject::Wait(); glWaitSync\n");
       gl->WaitSync(glSyncObject, 0, 0ull);
index 6d3f1492b766780fdd3ebec4b0149c63aa719053..25b3819ca093bd00bda27d9f039466bb1fbc2eb0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
@@ -80,7 +80,8 @@ void Memory2::Unlock(bool flush)
 {
   if(DALI_LIKELY(!EglGraphicsController::IsShuttingDown()))
   {
-    if(auto gl = mController.GetGL())
+    auto* gl = mController.GetGL();
+    if(DALI_LIKELY(gl))
     {
       // for buffer...
       if(mMapObjectType == MapObjectType::BUFFER && mMappedPointer)
index c0aec279bbc3707dd7674216ddbe250c0812f093..df5065d35aee5ccddfb1da3e31e0d57c3b7cf3e5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
@@ -51,7 +51,8 @@ void* Memory3::LockRegion(uint32_t offset, uint32_t size)
 {
   if(DALI_LIKELY(!EglGraphicsController::IsShuttingDown()))
   {
-    if(auto gl = mController.GetGL())
+    auto* gl = mController.GetGL();
+    if(DALI_LIKELY(gl))
     {
       if(mMapObjectType == MapObjectType::BUFFER)
       {
@@ -80,7 +81,8 @@ void Memory3::Unlock(bool flush)
 {
   if(DALI_LIKELY(!EglGraphicsController::IsShuttingDown()))
   {
-    if(auto gl = mController.GetGL())
+    auto* gl = mController.GetGL();
+    if(DALI_LIKELY(gl))
     {
       if(mMapObjectType == MapObjectType::BUFFER && mMappedPointer)
       {