Skip to content

Commit

Permalink
Merge branch 'master' into fractional_element_dimensions_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mwl4 authored Aug 24, 2023
2 parents 6656940 + cda1db7 commit 7b6dbc0
Show file tree
Hide file tree
Showing 21 changed files with 1,486 additions and 1,002 deletions.
4 changes: 4 additions & 0 deletions Backends/RmlUi_Backend_SDL_GL3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <RmlUi/Core/Context.h>
#include <RmlUi/Core/Core.h>
#include <RmlUi/Core/FileInterface.h>
#include <RmlUi/Core/Profiling.h>
#include <SDL.h>
#include <SDL_image.h>

Expand Down Expand Up @@ -321,4 +322,7 @@ void Backend::PresentFrame()

data->render_interface.EndFrame();
SDL_GL_SwapWindow(data->window);

// Optional, used to mark frames during performance profiling.
RMLUI_FrameMark;
}
4 changes: 2 additions & 2 deletions Backends/RmlUi_Renderer_GL2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ bool RenderInterface_GL2::GenerateTexture(Rml::TextureHandle& texture_handle, co
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

texture_handle = (Rml::TextureHandle)texture_id;

Expand Down
4 changes: 2 additions & 2 deletions Backends/RmlUi_Renderer_GL3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,8 +731,8 @@ bool RenderInterface_GL3::GenerateTexture(Rml::TextureHandle& texture_handle, co
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

texture_handle = (Rml::TextureHandle)texture_id;

Expand Down
2 changes: 1 addition & 1 deletion CMake/Modules/FindTracy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

set(TRACY_DIR "" CACHE PATH "Parent directory of Tracy library")

find_path(TRACY_INCLUDE_DIR Tracy.hpp PATHS ${TRACY_DIR} $ENV{TRACY_DIR} PATH_SUFFIXES tracy)
find_path(TRACY_INCLUDE_DIR TracyClient.cpp PATHS ${TRACY_DIR} $ENV{TRACY_DIR} PATH_SUFFIXES tracy public tracy/public)

set(TRACY_FOUND "NO")
if(TRACY_INCLUDE_DIR)
Expand Down
2 changes: 1 addition & 1 deletion Include/RmlUi/Core/Profiling.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#ifdef RMLUI_ENABLE_PROFILING

#define TRACY_ENABLE
#include <Tracy.hpp>
#include <tracy/Tracy.hpp>

#define RMLUI_ZoneNamed(varname, active) ZoneNamed(varname, active)
#define RMLUI_ZoneNamedN(varname, name, active) ZoneNamedN(varname, name, active)
Expand Down
Binary file added Samples/assets/alien_small.tga
Binary file not shown.
11 changes: 11 additions & 0 deletions Samples/basic/demo/data/demo.rml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ p.title
border: 1dp #777;
font-effect: shadow( 1dp 1dp #333 );
}
.image-mode.repeat > div {
height: 120dp;
}
#decorators .image-mode > div > p
{
margin: -2em 0 0 0;
Expand All @@ -223,6 +226,9 @@ p.title
.fit-cover { decorator: image( icon-invader cover ); }
.fit-scale-none { decorator: image( icon-invader scale-none ); }
.fit-scale-down { decorator: image( icon-invader scale-down ); }
.fit-repeat { decorator: image( /assets/alien_small.tga repeat ); }
.fit-repeat-x { decorator: image( /assets/alien_small.tga repeat-x ); }
.fit-repeat-y { decorator: image( /assets/alien_small.tga repeat-y ); }
.orientation-vertical { decorator: image( icon-invader flip-vertical scale-none ); }
.orientation-horizontal { decorator: image( icon-invader flip-horizontal scale-none ); }
.orientation-rotate { decorator: image( icon-invader rotate-180 scale-none ); }
Expand Down Expand Up @@ -709,6 +715,11 @@ progress {
<div class="fit-scale-none"></div>
<div class="fit-scale-down"></div>
</div>
<div class="image-mode repeat">
<div class="fit-repeat"><p>repeat</p></div>
<div class="fit-repeat-x"><p>repeat-x</p></div>
<div class="fit-repeat-y"><p>repeat-y</p></div>
</div>
<h1>Image decorator alignment modes</h1>
<div class="image-mode">
<div class="align-default"><p style="font-style: italic;">default</p></div>
Expand Down
18 changes: 18 additions & 0 deletions Source/Core/DecoratorTiled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ void DecoratorTiled::Tile::GenerateGeometry(Vector<Vertex>& vertices, Vector<int

Vector2f final_tile_dimensions;
bool offset_and_clip_tile = false;
Vector2f repeat_factor = Vector2f(1);

switch (fit_mode)
{
Expand Down Expand Up @@ -165,6 +166,20 @@ void DecoratorTiled::Tile::GenerateGeometry(Vector<Vertex>& vertices, Vector<int
offset_and_clip_tile = true;
}
break;
case REPEAT:
final_tile_dimensions = surface_dimensions;
repeat_factor = surface_dimensions / tile_dimensions;
break;
case REPEAT_X:
final_tile_dimensions = Vector2f(surface_dimensions.x, tile_dimensions.y);
repeat_factor.x = surface_dimensions.x / tile_dimensions.x;
offset_and_clip_tile = true;
break;
case REPEAT_Y:
final_tile_dimensions = Vector2f(tile_dimensions.x, surface_dimensions.y);
repeat_factor.y = surface_dimensions.y / tile_dimensions.y;
offset_and_clip_tile = true;
break;
}

Vector2f tile_offset(0, 0);
Expand Down Expand Up @@ -206,6 +221,9 @@ void DecoratorTiled::Tile::GenerateGeometry(Vector<Vertex>& vertices, Vector<int
}
}

scaled_texcoords[0] *= repeat_factor;
scaled_texcoords[1] *= repeat_factor;

// Resize the vertex and index arrays to fit the new geometry.
int index_offset = (int)vertices.size();
vertices.resize(vertices.size() + 4);
Expand Down
3 changes: 3 additions & 0 deletions Source/Core/DecoratorTiled.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ class DecoratorTiled : public Decorator {
COVER, // Tile is stretched to cover the boundaries, keeping aspect ratio fixed.
SCALE_NONE, // Tile is never scaled.
SCALE_DOWN, // Tile acts like 'scale-none' if smaller than boundaries, or like 'contain' otherwise.
REPEAT, // Tile is repeated on both x and y axis
REPEAT_X, // Tile is repeated on the x axis
REPEAT_Y, // Tile is repeated on the y axis
};

/**
Expand Down
13 changes: 11 additions & 2 deletions Source/Core/DecoratorTiledInstancer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void DecoratorTiledInstancer::RegisterTileProperty(const String& name, bool regi
if (register_fit_modes)
{
String fit_name = CreateString(32, "%s-fit", name.c_str());
ids.fit = RegisterProperty(fit_name, "fill").AddParser("keyword", "fill, contain, cover, scale-none, scale-down").GetId();
ids.fit = RegisterProperty(fit_name, "fill").AddParser("keyword", "fill, contain, cover, scale-none, scale-down, repeat, repeat-x, repeat-y").GetId();

String align_x_name = CreateString(32, "%s-align-x", name.c_str());
ids.align_x = RegisterProperty(align_x_name, "center").AddParser("keyword", "left, center, right").AddParser("length_percent").GetId();
Expand Down Expand Up @@ -99,8 +99,9 @@ bool DecoratorTiledInstancer::GetTileProperties(DecoratorTiled::Tile* tiles, Tex
DecoratorTiled::Tile& tile = tiles[i];
Texture& texture = textures[i];

const Sprite* sprite = instancer_interface.GetSprite(texture_name);
// A tile is always either a sprite or an image.
if (const Sprite* sprite = instancer_interface.GetSprite(texture_name))
if (sprite)
{
tile.position = sprite->rectangle.Position();
tile.size = sprite->rectangle.Size();
Expand Down Expand Up @@ -134,6 +135,14 @@ bool DecoratorTiledInstancer::GetTileProperties(DecoratorTiled::Tile* tiles, Tex
const Property& fit_property = *properties.GetProperty(ids.fit);
tile.fit_mode = (DecoratorTiled::TileFitMode)fit_property.value.Get<int>();

if (sprite && (tile.fit_mode == DecoratorTiled::TileFitMode::REPEAT ||
tile.fit_mode == DecoratorTiled::TileFitMode::REPEAT_X ||
tile.fit_mode == DecoratorTiled::TileFitMode::REPEAT_Y)) {
Log::Message(Log::LT_WARNING, "Decorator fit value is '%s', which is incompatible with a spritesheet",
fit_property.ToString().c_str());
return false;
}

const Property* align_properties[2] = {properties.GetProperty(ids.align_x), properties.GetProperty(ids.align_y)};

for (int dimension = 0; dimension < 2; dimension++)
Expand Down
3 changes: 3 additions & 0 deletions Source/Core/FontEngineDefault/FontFaceHandleDefault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/

#include "FontFaceHandleDefault.h"
#include "../../../Include/RmlUi/Core/Profiling.h"
#include "../../../Include/RmlUi/Core/StringUtilities.h"
#include "../TextureLayout.h"
#include "FontFaceLayer.h"
Expand Down Expand Up @@ -83,6 +84,8 @@ const FontGlyphMap& FontFaceHandleDefault::GetGlyphs() const

int FontFaceHandleDefault::GetStringWidth(const String& string, float letter_spacing, Character prior_character)
{
RMLUI_ZoneScoped;

int width = 0;
for (auto it_string = StringIteratorU8(string); it_string; ++it_string)
{
Expand Down
7 changes: 5 additions & 2 deletions Source/Core/Layout/FlexFormattingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "../../../Include/RmlUi/Core/ComputedValues.h"
#include "../../../Include/RmlUi/Core/Element.h"
#include "../../../Include/RmlUi/Core/ElementScroll.h"
#include "../../../Include/RmlUi/Core/Profiling.h"
#include "../../../Include/RmlUi/Core/Types.h"
#include "ContainerBox.h"
#include "LayoutDetails.h"
Expand All @@ -42,6 +43,7 @@ namespace Rml {

UniquePtr<LayoutBox> FlexFormattingContext::Format(ContainerBox* parent_container, Element* element, const Box* override_initial_box)
{
RMLUI_ZoneScopedC(0xAFAF4F);
auto flex_container_box = MakeUnique<FlexContainer>(element, parent_container);

ElementScroll* element_scroll = element->GetElementScroll();
Expand Down Expand Up @@ -133,7 +135,7 @@ struct FlexItem {
Size cross;
float flex_shrink_factor;
float flex_grow_factor;
Style::AlignSelf align_self; // 'Auto' is replaced by container's 'align-items' value
Style::AlignSelf align_self; // 'Auto' is replaced by container's 'align-items' value

float inner_flex_base_size; // Inner size
float flex_base_size; // Outer size
Expand Down Expand Up @@ -232,9 +234,10 @@ void FlexFormattingContext::Format(Vector2f& flex_resulting_content_size, Vector
const float cross_size_base_value = (cross_available_size < 0.0f ? 0.0f : cross_available_size);

// -- Build a list of all flex items with base size information --
const int num_flex_children = element_flex->GetNumChildren();
Vector<FlexItem> items;
items.reserve(num_flex_children);

const int num_flex_children = element_flex->GetNumChildren();
for (int i = 0; i < num_flex_children; i++)
{
Element* element = element_flex->GetChild(i);
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/Layout/FormattingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "FormattingContext.h"
#include "../../../Include/RmlUi/Core/ComputedValues.h"
#include "../../../Include/RmlUi/Core/Element.h"
#include "../../../Include/RmlUi/Core/Profiling.h"
#include "BlockFormattingContext.h"
#include "FlexFormattingContext.h"
#include "LayoutBox.h"
Expand All @@ -40,6 +41,7 @@ namespace Rml {
UniquePtr<LayoutBox> FormattingContext::FormatIndependent(ContainerBox* parent_container, Element* element, const Box* override_initial_box,
FormattingContextType backup_context)
{
RMLUI_ZoneScopedC(0xAFAFAF);
using namespace Style;

if (element->IsReplaced())
Expand Down
7 changes: 6 additions & 1 deletion Tests/Dependencies/doctest/cmake/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
add_compiler_flags(-Wnoexcept)
endif()

if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
add_compiler_flags(-Wno-missing-field-initializers)
endif()

# no way to silence it in the expression decomposition macros: _Pragma() in macros doesn't work for the c++ front-end of g++
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55578
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69543
Expand Down Expand Up @@ -179,7 +183,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compiler_flags(-Wno-c++98-compat-pedantic)
add_compiler_flags(-Wno-c++98-compat-bind-to-temporary-copy)
add_compiler_flags(-Wno-c++98-compat-local-type-template-args)
add_compiler_flags(-Qunused-arguments -fcolor-diagnostics) # needed for ccache integration on travis
add_compiler_flags(-Qunused-arguments -fcolor-diagnostics) # needed for ccache integration
endif()

if(MSVC)
Expand All @@ -191,6 +195,7 @@ if(MSVC)
add_compiler_flags(
/wd4514 # unreferenced inline function has been removed
/wd4571 # SEH related
/wd5264 # const variable is not used
/wd4710 # function not inlined
/wd4711 # function 'x' selected for automatic inline expansion

Expand Down
18 changes: 16 additions & 2 deletions Tests/Dependencies/doctest/cmake/doctest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ same as the doctest name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``.
[TEST_PREFIX prefix]
[TEST_SUFFIX suffix]
[PROPERTIES name1 value1...]
[ADD_LABELS value]
[TEST_LIST var]
[JUNIT_OUTPUT_DIR dir]
)

``doctest_discover_tests`` sets up a post-build command on the test executable
Expand Down Expand Up @@ -84,21 +86,31 @@ same as the doctest name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``.
Specifies additional properties to be set on all tests discovered by this
invocation of ``doctest_discover_tests``.

``ADD_LABELS value``
Specifies if the test labels should be set automatically.

``TEST_LIST var``
Make the list of tests available in the variable ``var``, rather than the
default ``<target>_TESTS``. This can be useful when the same test
executable is being used in multiple calls to ``doctest_discover_tests()``.
Note that this variable is only available in CTest.

``JUNIT_OUTPUT_DIR dir``
If specified, the parameter is passed along with ``--reporters=junit``
and ``--out=`` to the test executable. The actual file name is the same
as the test target, including prefix and suffix. This should be used
instead of EXTRA_ARGS to avoid race conditions writing the XML result
output when using parallel test execution.

#]=======================================================================]

#------------------------------------------------------------------------------
function(doctest_discover_tests TARGET)
cmake_parse_arguments(
""
""
"TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST"
"TEST_SPEC;EXTRA_ARGS;PROPERTIES"
"TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST;JUNIT_OUTPUT_DIR"
"TEST_SPEC;EXTRA_ARGS;PROPERTIES;ADD_LABELS"
${ARGN}
)

Expand Down Expand Up @@ -131,9 +143,11 @@ function(doctest_discover_tests TARGET)
-D "TEST_SPEC=${_TEST_SPEC}"
-D "TEST_EXTRA_ARGS=${_EXTRA_ARGS}"
-D "TEST_PROPERTIES=${_PROPERTIES}"
-D "TEST_ADD_LABELS=${_ADD_LABELS}"
-D "TEST_PREFIX=${_TEST_PREFIX}"
-D "TEST_SUFFIX=${_TEST_SUFFIX}"
-D "TEST_LIST=${_TEST_LIST}"
-D "TEST_JUNIT_OUTPUT_DIR=${_JUNIT_OUTPUT_DIR}"
-D "CTEST_FILE=${ctest_tests_file}"
-P "${_DOCTEST_DISCOVER_TESTS_SCRIPT}"
VERBATIM
Expand Down
Loading

0 comments on commit 7b6dbc0

Please sign in to comment.