Fix SVACE errors in various files 68/305768/1
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 7 Feb 2024 12:02:08 +0000 (12:02 +0000)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 7 Feb 2024 12:02:08 +0000 (12:02 +0000)
Change-Id: Id61fd85f7f03e4650fa3746f412b70d248618b80

dali/internal/graphics/gles-impl/gles-graphics-pipeline.cpp
dali/internal/graphics/gles-impl/gles2-graphics-memory.cpp
dali/internal/graphics/gles-impl/gles3-graphics-memory.cpp

index 5454c84..a927fad 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -91,8 +91,10 @@ auto& PipelineImpl::GetController() const
 
 void PipelineImpl::Bind(const uint32_t glProgram) const
 {
-  auto& gl = *GetController().GetGL();
-  gl.UseProgram(glProgram);
+  if(auto gl = GetController().GetGL())
+  {
+    gl->UseProgram(glProgram);
+  }
 }
 
 void PipelineImpl::Retain()
index 038410a..92b4ef0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -74,28 +74,29 @@ void* Memory2::LockRegion(uint32_t offset, uint32_t size)
 
 void Memory2::Unlock(bool flush)
 {
-  auto gl = mController.GetGL();
-
-  // for buffer...
-  if(mMapObjectType == MapObjectType::BUFFER && mMappedPointer)
+  if(auto gl = mController.GetGL())
   {
-    auto buffer = static_cast<GLES::Buffer*>(mMapBufferInfo.buffer);
-    if(!buffer->IsCPUAllocated())
+    // for buffer...
+    if(mMapObjectType == MapObjectType::BUFFER && mMappedPointer)
     {
-      buffer->Bind(BufferUsage::VERTEX_BUFFER);
-      gl->BufferSubData(GL_ARRAY_BUFFER, GLintptr(mMapBufferInfo.offset), GLsizeiptr(mMapBufferInfo.size), mMappedPointer);
+      auto buffer = static_cast<GLES::Buffer*>(mMapBufferInfo.buffer);
+      if(!buffer->IsCPUAllocated())
+      {
+        buffer->Bind(BufferUsage::VERTEX_BUFFER);
+        gl->BufferSubData(GL_ARRAY_BUFFER, GLintptr(mMapBufferInfo.offset), GLsizeiptr(mMapBufferInfo.size), mMappedPointer);
+      }
     }
-  }
 
-  if(mIsAllocatedLocally)
-  {
-    free(mMappedPointer);
-    mMappedPointer = nullptr;
-  }
+    if(mIsAllocatedLocally)
+    {
+      free(mMappedPointer);
+      mMappedPointer = nullptr;
+    }
 
-  if(flush)
-  {
-    Flush();
+    if(flush)
+    {
+      Flush();
+    }
   }
 }
 
index 9dd9f51..18e7861 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -49,50 +49,51 @@ Memory3::~Memory3()
 
 void* Memory3::LockRegion(uint32_t offset, uint32_t size)
 {
-  auto gl = mController.GetGL();
-
-  if(mMapObjectType == MapObjectType::BUFFER)
+  if(auto gl = mController.GetGL())
   {
-    auto buffer = static_cast<GLES::Buffer*>(mMapBufferInfo.buffer);
-
-    if(buffer->IsCPUAllocated())
-    {
-      using Ptr      = char*;
-      mMappedPointer = Ptr(buffer->GetCPUAllocatedAddress()) + offset;
-    }
-    else
+    if(mMapObjectType == MapObjectType::BUFFER)
     {
-      gl->BindBuffer(GL_COPY_WRITE_BUFFER, buffer->GetGLBuffer());
-      void* ptr      = nullptr;
-      ptr            = gl->MapBufferRange(GL_COPY_WRITE_BUFFER, GLintptr(mMapBufferInfo.offset), GLsizeiptr(mMapBufferInfo.size), GL_MAP_WRITE_BIT);
-      mMappedPointer = ptr;
+      auto buffer = static_cast<GLES::Buffer*>(mMapBufferInfo.buffer);
+
+      if(buffer->IsCPUAllocated())
+      {
+        using Ptr      = char*;
+        mMappedPointer = Ptr(buffer->GetCPUAllocatedAddress()) + offset;
+      }
+      else
+      {
+        gl->BindBuffer(GL_COPY_WRITE_BUFFER, buffer->GetGLBuffer());
+        void* ptr      = nullptr;
+        ptr            = gl->MapBufferRange(GL_COPY_WRITE_BUFFER, GLintptr(mMapBufferInfo.offset), GLsizeiptr(mMapBufferInfo.size), GL_MAP_WRITE_BIT);
+        mMappedPointer = ptr;
+      }
+      return mMappedPointer;
     }
-    return mMappedPointer;
   }
-
   return nullptr;
 }
 
 void Memory3::Unlock(bool flush)
 {
-  auto gl = mController.GetGL();
-
-  if(mMapObjectType == MapObjectType::BUFFER && mMappedPointer)
+  if(auto gl = mController.GetGL())
   {
-    auto buffer = static_cast<GLES::Buffer*>(mMapBufferInfo.buffer);
-    if(!buffer->IsCPUAllocated())
+    if(mMapObjectType == MapObjectType::BUFFER && mMappedPointer)
     {
-      gl->BindBuffer(GL_COPY_WRITE_BUFFER, buffer->GetGLBuffer());
-      gl->UnmapBuffer(GL_COPY_WRITE_BUFFER);
+      auto buffer = static_cast<GLES::Buffer*>(mMapBufferInfo.buffer);
+      if(!buffer->IsCPUAllocated())
+      {
+        gl->BindBuffer(GL_COPY_WRITE_BUFFER, buffer->GetGLBuffer());
+        gl->UnmapBuffer(GL_COPY_WRITE_BUFFER);
+      }
     }
-  }
 
-  if(flush)
-  {
-    Flush();
-  }
+    if(flush)
+    {
+      Flush();
+    }
 
-  mMappedPointer = nullptr;
+    mMappedPointer = nullptr;
+  }
 }
 
 void Memory3::Flush()