X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fgraphics%2Fgles-impl%2Fgles3-graphics-memory.cpp;h=18e78616a7f19669b3ff21f32746ecc7d4295ba2;hb=11f95cf0350543da87ad0c2bf040156c017d1ae9;hp=9dd9f5104f0afcf58c81784f2053972e2eaa0622;hpb=67cbe20c6441a01ca9ba9bcdfd1ed83b38cf5c34;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/graphics/gles-impl/gles3-graphics-memory.cpp b/dali/internal/graphics/gles-impl/gles3-graphics-memory.cpp index 9dd9f51..18e7861 100644 --- a/dali/internal/graphics/gles-impl/gles3-graphics-memory.cpp +++ b/dali/internal/graphics/gles-impl/gles3-graphics-memory.cpp @@ -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(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(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(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(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()