Make CreateSolidColorTexture upload pixel data 85/295085/2
authorEunki, Hong <eunkiki.hong@samsung.com>
Mon, 3 Jul 2023 01:01:37 +0000 (10:01 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Mon, 3 Jul 2023 01:10:00 +0000 (10:10 +0900)
To avoid case when we skip rendering for non-upload texture, make sure
that we upload texture.

Change-Id: Ieea21bf09d84ff43fbff6673ba7dfc8e299cdf45
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
automated-tests/src/dali-toolkit/utc-Dali-BubbleEmitter.cpp

index 48d4a09..41e8236 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -76,6 +76,21 @@ static int Wait(ToolkitTestApplication& application, int duration = 0)
 static Texture CreateSolidColorTexture(ToolkitTestApplication& application, const Vector4& color, unsigned int width, unsigned int height)
 {
   Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+
+  int      bufferSize = width * height * GetBytesPerPixel(Pixel::RGBA8888);
+  uint8_t* buffer     = reinterpret_cast<uint8_t*>(malloc(bufferSize));
+
+  for(uint32_t i = 0; i < width * height; ++i)
+  {
+    buffer[i * 4 + 0] = static_cast<uint8_t>(color.r * 255.0f);
+    buffer[i * 4 + 1] = static_cast<uint8_t>(color.g * 255.0f);
+    buffer[i * 4 + 2] = static_cast<uint8_t>(color.b * 255.0f);
+    buffer[i * 4 + 3] = static_cast<uint8_t>(color.a * 255.0f);
+  }
+
+  PixelData pixelData = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE);
+  texture.Upload(pixelData, 0u, 0u, 0u, 0u, width, height);
+
   return texture;
 }
 } //namespace