Merge "(Partial Update) Mark as not rendered if the node is transparent or culled...
[platform/core/uifw/dali-core.git] / dali / internal / render / renderers / render-texture.cpp
index 013a380..0fb1cec 100644 (file)
@@ -107,10 +107,10 @@ constexpr Graphics::Format ConvertPixelFormat(Pixel::Format format)
       return Graphics::Format::ETC2_R8G8B8A1_SRGB_BLOCK; // no 'punchthrough' format
 
     case Pixel::COMPRESSED_RGBA8_ETC2_EAC:
-      return Graphics::Format::ETC2_R8G8B8_UNORM_BLOCK; // doesn't seem to map onto any format
+      return Graphics::Format::ETC2_R8G8B8A8_UNORM_BLOCK;
 
     case Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
-      return Graphics::Format::ETC2_R8G8B8A8_SRGB_BLOCK; // doesn't seem to map onto any format
+      return Graphics::Format::ETC2_R8G8B8A8_SRGB_BLOCK;
 
     case Pixel::COMPRESSED_RGB8_ETC1:
       return Graphics::Format::ETC2_R8G8B8_UNORM_BLOCK; // doesn't seem to be supported at all
@@ -180,6 +180,8 @@ constexpr Graphics::Format ConvertPixelFormat(Pixel::Format format)
       return Graphics::Format::R16G16B16_SFLOAT;
     case Pixel::RGB32F:
       return Graphics::Format::R32G32B32_SFLOAT;
+    case Pixel::R11G11B10F:
+      return Graphics::Format::R11G11B10_UFLOAT_PACK32;
   }
   return Graphics::Format::UNDEFINED;
 }
@@ -206,7 +208,6 @@ Texture::Texture(Type type, Pixel::Format format, ImageDimensions size)
   mPixelFormat(format),
   mWidth(size.GetWidth()),
   mHeight(size.GetHeight()),
-  mMaxMipMapLevel(0),
   mType(type),
   mHasAlpha(HasAlpha(format))
 {
@@ -220,7 +221,6 @@ Texture::Texture(NativeImageInterfacePtr nativeImageInterface)
   mPixelFormat(Pixel::RGBA8888),
   mWidth(static_cast<uint16_t>(nativeImageInterface->GetWidth())),   // ignoring overflow, not happening in practice
   mHeight(static_cast<uint16_t>(nativeImageInterface->GetHeight())), // ignoring overflow, not happening in practice
-  mMaxMipMapLevel(0),
   mType(TextureType::TEXTURE_2D),
   mHasAlpha(nativeImageInterface->RequiresBlending())
 {
@@ -273,7 +273,7 @@ void Texture::CreateWithData(Graphics::TextureUsageFlags usage, uint8_t* data, u
 
 void Texture::Upload(PixelDataPtr pixelData, const Internal::Texture::UploadParams& params)
 {
-  DALI_ASSERT_ALWAYS(mNativeImage == nullptr);
+  DALI_ASSERT_ALWAYS(!mNativeImage);
 
   if(!mGraphicsTexture)
   {
@@ -289,6 +289,7 @@ void Texture::Upload(PixelDataPtr pixelData, const Internal::Texture::UploadPara
   info.srcExtent2D  = {params.width, params.height};
   info.srcOffset    = 0;
   info.srcSize      = pixelData->GetBufferSize();
+  info.srcFormat    = ConvertPixelFormat(pixelData->GetPixelFormat());
 
   Graphics::TextureUpdateSourceInfo updateSourceInfo{};
   updateSourceInfo.sourceType          = Graphics::TextureUpdateSourceInfo::Type::MEMORY;
@@ -309,9 +310,12 @@ bool Texture::HasAlphaChannel() const
 
 void Texture::GenerateMipmaps()
 {
-  mMaxMipMapLevel = 0;
-  DALI_LOG_ERROR("FIXME: GRAPHICS");
-  //@todo Implement with Graphics API
+  if(!mGraphicsTexture)
+  {
+    Create(static_cast<Graphics::TextureUsageFlags>(Graphics::TextureUsageFlagBits::SAMPLE));
+  }
+
+  mGraphicsController->GenerateTextureMipmaps(*mGraphicsTexture.get());
 }
 
 } // namespace Render