Fix memory leak issue when we convert pixelData 04/306704/1
authorEunki, Hong <eunkiki.hong@samsung.com>
Mon, 26 Feb 2024 10:27:03 +0000 (19:27 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Mon, 26 Feb 2024 10:32:34 +0000 (19:32 +0900)
If we convert buffer CPU side, we might not release sourceBuffer memory.
To avoid this kind of memory leak, let we change the logic of glTexImage2D.

Change-Id: Ib1725c5ca8e6653dd1605311e4e021b09be2d387
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali/internal/graphics/gles-impl/egl-graphics-controller.cpp

index 1200699..a3eb62f 100644 (file)
@@ -802,12 +802,14 @@ void EglGraphicsController::ProcessTextureUpdateQueue()
           auto                 sourceStride = info.srcStride;
           std::vector<uint8_t> tempBuffer;
 
           auto                 sourceStride = info.srcStride;
           std::vector<uint8_t> tempBuffer;
 
+          uint8_t* srcBuffer = sourceBuffer;
+
           if(mGlAbstraction->TextureRequiresConverting(srcFormat, destFormat, isSubImage))
           {
             // Convert RGB to RGBA if necessary.
             if(texture->TryConvertPixelData(sourceBuffer, info.srcFormat, createInfo.format, info.srcSize, info.srcStride, info.srcExtent2D.width, info.srcExtent2D.height, tempBuffer))
             {
           if(mGlAbstraction->TextureRequiresConverting(srcFormat, destFormat, isSubImage))
           {
             // Convert RGB to RGBA if necessary.
             if(texture->TryConvertPixelData(sourceBuffer, info.srcFormat, createInfo.format, info.srcSize, info.srcStride, info.srcExtent2D.width, info.srcExtent2D.height, tempBuffer))
             {
-              sourceBuffer = &tempBuffer[0];
+              srcBuffer    = &tempBuffer[0];
               sourceStride = 0u; // Converted buffer compacted. make stride as 0.
               srcFormat    = destFormat;
               srcType      = GLES::GLTextureFormatType(createInfo.format).type;
               sourceStride = 0u; // Converted buffer compacted. make stride as 0.
               srcFormat    = destFormat;
               srcType      = GLES::GLTextureFormatType(createInfo.format).type;
@@ -843,7 +845,7 @@ void EglGraphicsController::ProcessTextureUpdateQueue()
                                          0,
                                          srcFormat,
                                          srcType,
                                          0,
                                          srcFormat,
                                          srcType,
-                                         sourceBuffer);
+                                         srcBuffer);
             }
             else
             {
             }
             else
             {
@@ -854,7 +856,7 @@ void EglGraphicsController::ProcessTextureUpdateQueue()
                                                    info.srcExtent2D.height,
                                                    0,
                                                    info.srcSize,
                                                    info.srcExtent2D.height,
                                                    0,
                                                    info.srcSize,
-                                                   sourceBuffer);
+                                                   srcBuffer);
             }
           }
           else
             }
           }
           else
@@ -869,7 +871,7 @@ void EglGraphicsController::ProcessTextureUpdateQueue()
                                             info.srcExtent2D.height,
                                             srcFormat,
                                             srcType,
                                             info.srcExtent2D.height,
                                             srcFormat,
                                             srcType,
-                                            sourceBuffer);
+                                            srcBuffer);
             }
             else
             {
             }
             else
             {
@@ -881,7 +883,7 @@ void EglGraphicsController::ProcessTextureUpdateQueue()
                                                       info.srcExtent2D.height,
                                                       srcFormat,
                                                       info.srcSize,
                                                       info.srcExtent2D.height,
                                                       srcFormat,
                                                       info.srcSize,
-                                                      sourceBuffer);
+                                                      srcBuffer);
             }
           }
         }
             }
           }
         }