Browse Source

Log warnings when SVG or Lottie files cannot be rendered, see #687

Michael Ragazzon 1 year ago
parent
commit
90e090315c
2 changed files with 9 additions and 0 deletions
  1. 3 0
      Source/Lottie/ElementLottie.cpp
  2. 6 0
      Source/SVG/ElementSVG.cpp

+ 3 - 0
Source/Lottie/ElementLottie.cpp

@@ -239,7 +239,10 @@ void ElementLottie::UpdateTexture()
 		}
 
 		if (!texture_interface.GenerateTexture({p_data, total_bytes}, render_dimensions))
+		{
+			Log::Message(Rml::Log::Type::LT_WARNING, "Could not generate texture for lottie animation: %s", GetAttribute<String>("src", "").c_str());
 			return false;
+		}
 		return true;
 	};
 

+ 6 - 0
Source/SVG/ElementSVG.cpp

@@ -187,7 +187,10 @@ void ElementSVG::UpdateTexture()
 		RMLUI_ASSERT(svg_document);
 		lunasvg::Bitmap bitmap = svg_document->renderToBitmap(render_dimensions.x, render_dimensions.y);
 		if (!bitmap.valid() || !bitmap.data())
+		{
+			Log::Message(Rml::Log::Type::LT_WARNING, "Could not render SVG to bitmap: %s", GetAttribute<String>("src", "").c_str());
 			return false;
+		}
 
 		// Swap red and blue channels, assuming LunaSVG v2.3.2 or newer, to convert to RmlUi's expected RGBA-ordering.
 		const size_t bitmap_byte_size = bitmap.width() * bitmap.height() * 4;
@@ -196,7 +199,10 @@ void ElementSVG::UpdateTexture()
 			std::swap(bitmap_data[i], bitmap_data[i + 2]);
 
 		if (!texture_interface.GenerateTexture({reinterpret_cast<const Rml::byte*>(bitmap.data()), bitmap_byte_size}, render_dimensions))
+		{
+			Log::Message(Rml::Log::Type::LT_WARNING, "Could not generate texture for SVG: %s", GetAttribute<String>("src", "").c_str());
 			return false;
+		}
 		return true;
 	};