GeometryBoxShadow.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #pragma once
  2. #include "../../Include/RmlUi/Core/DecorationTypes.h"
  3. #include "../../Include/RmlUi/Core/RenderBox.h"
  4. #include "../../Include/RmlUi/Core/Types.h"
  5. namespace Rml {
  6. using RenderBoxList = Vector<RenderBox>;
  7. struct BoxShadowGeometryInfo {
  8. ColourbPremultiplied background_color;
  9. Array<ColourbPremultiplied, 4> border_colors;
  10. CornerSizes border_radius;
  11. Vector2i texture_dimensions;
  12. Vector2f element_offset_in_texture;
  13. RenderBoxList padding_render_boxes;
  14. RenderBoxList border_render_boxes;
  15. BoxShadowList shadow_list;
  16. float opacity;
  17. };
  18. inline bool operator==(const BoxShadowGeometryInfo& a, const BoxShadowGeometryInfo& b)
  19. {
  20. return a.background_color == b.background_color && a.border_colors == b.border_colors && a.border_radius == b.border_radius &&
  21. a.texture_dimensions == b.texture_dimensions && a.element_offset_in_texture == b.element_offset_in_texture &&
  22. a.padding_render_boxes == b.padding_render_boxes && a.border_render_boxes == b.border_render_boxes && a.shadow_list == b.shadow_list &&
  23. a.opacity == b.opacity;
  24. }
  25. inline bool operator!=(const BoxShadowGeometryInfo& a, const BoxShadowGeometryInfo& b)
  26. {
  27. return !(a == b);
  28. }
  29. class Geometry;
  30. class CallbackTexture;
  31. class RenderManager;
  32. class GeometryBoxShadow {
  33. public:
  34. /// Resolve the element's properties into its box geometry info.
  35. /// @param[in] element The element to resolve.
  36. /// @param[in] border_radius The border radius of the element.
  37. /// @param[in] background_color The background colour of the element.
  38. /// @param[in] border_colors The border colours of the element.
  39. /// @param[in] opacity The computed opacity of the element.
  40. static BoxShadowGeometryInfo Resolve(Element* element, const CornerSizes& border_radius, ColourbPremultiplied background_color,
  41. const Array<ColourbPremultiplied, 4>& border_colors, float opacity);
  42. /// Generate the texture and geometry for a box shadow and including the element's background and border.
  43. /// @param[out] out_shadow_texture The target texture, assumes pointer stability during the lifetime of the shadow geometry.
  44. /// @param[out] out_background_border_geometry The generated geometry for the element's background and border.
  45. /// @param[in] render_manager The render manager to generate the shadow for.
  46. /// @param[in] shadow_geometry_info The resolved box shadow geometry of a given element.
  47. /// @see GeometryBoxShadow::Resolve()
  48. static void GenerateTexture(CallbackTexture& out_shadow_texture, Geometry& out_background_border_geometry, RenderManager& render_manager,
  49. const BoxShadowGeometryInfo& shadow_geometry_info);
  50. };
  51. } // namespace Rml