Skip to content

Commit

Permalink
Merge branch 'blur'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikke89 committed Dec 4, 2019
2 parents 680e7e9 + 48092cf commit 0b53977
Show file tree
Hide file tree
Showing 26 changed files with 970 additions and 266 deletions.
10 changes: 6 additions & 4 deletions CMake/FileList.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,18 @@ set(Core_HDR_FILES
${PROJECT_SOURCE_DIR}/Source/Core/EventIterators.h
${PROJECT_SOURCE_DIR}/Source/Core/EventSpecification.h
${PROJECT_SOURCE_DIR}/Source/Core/FileInterfaceDefault.h
${PROJECT_SOURCE_DIR}/Source/Core/FontEffectBlur.h
${PROJECT_SOURCE_DIR}/Source/Core/FontEffectGlow.h
${PROJECT_SOURCE_DIR}/Source/Core/FontEffectOutline.h
${PROJECT_SOURCE_DIR}/Source/Core/FontEffectOutlineInstancer.h
${PROJECT_SOURCE_DIR}/Source/Core/FontEffectShadow.h
${PROJECT_SOURCE_DIR}/Source/Core/FontEffectShadowInstancer.h
${PROJECT_SOURCE_DIR}/Source/Core/IdNameMap.h
${PROJECT_SOURCE_DIR}/Source/Core/LayoutBlockBox.h
${PROJECT_SOURCE_DIR}/Source/Core/LayoutBlockBoxSpace.h
${PROJECT_SOURCE_DIR}/Source/Core/LayoutEngine.h
${PROJECT_SOURCE_DIR}/Source/Core/LayoutInlineBox.h
${PROJECT_SOURCE_DIR}/Source/Core/LayoutInlineBoxText.h
${PROJECT_SOURCE_DIR}/Source/Core/LayoutLineBox.h
${PROJECT_SOURCE_DIR}/Source/Core/Memory.h
${PROJECT_SOURCE_DIR}/Source/Core/PluginRegistry.h
${PROJECT_SOURCE_DIR}/Source/Core/Pool.h
${PROJECT_SOURCE_DIR}/Source/Core/precompiled.h
Expand Down Expand Up @@ -231,11 +232,11 @@ set(Core_SRC_FILES
${PROJECT_SOURCE_DIR}/Source/Core/FileInterface.cpp
${PROJECT_SOURCE_DIR}/Source/Core/FileInterfaceDefault.cpp
${PROJECT_SOURCE_DIR}/Source/Core/FontEffect.cpp
${PROJECT_SOURCE_DIR}/Source/Core/FontEffectBlur.cpp
${PROJECT_SOURCE_DIR}/Source/Core/FontEffectGlow.cpp
${PROJECT_SOURCE_DIR}/Source/Core/FontEffectInstancer.cpp
${PROJECT_SOURCE_DIR}/Source/Core/FontEffectOutline.cpp
${PROJECT_SOURCE_DIR}/Source/Core/FontEffectOutlineInstancer.cpp
${PROJECT_SOURCE_DIR}/Source/Core/FontEffectShadow.cpp
${PROJECT_SOURCE_DIR}/Source/Core/FontEffectShadowInstancer.cpp
${PROJECT_SOURCE_DIR}/Source/Core/FontEngineInterface.cpp
${PROJECT_SOURCE_DIR}/Source/Core/Geometry.cpp
${PROJECT_SOURCE_DIR}/Source/Core/GeometryUtilities.cpp
Expand All @@ -247,6 +248,7 @@ set(Core_SRC_FILES
${PROJECT_SOURCE_DIR}/Source/Core/LayoutLineBox.cpp
${PROJECT_SOURCE_DIR}/Source/Core/Log.cpp
${PROJECT_SOURCE_DIR}/Source/Core/Math.cpp
${PROJECT_SOURCE_DIR}/Source/Core/Memory.cpp
${PROJECT_SOURCE_DIR}/Source/Core/ObserverPtr.cpp
${PROJECT_SOURCE_DIR}/Source/Core/Plugin.cpp
${PROJECT_SOURCE_DIR}/Source/Core/PluginRegistry.cpp
Expand Down
49 changes: 29 additions & 20 deletions Include/RmlUi/Core/ConvolutionFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,55 +32,64 @@
namespace Rml {
namespace Core {

enum class FilterOperation {
// The result is the sum of all the filtered pixels.
Sum,
// The result is the largest value of all filtered pixels.
Dilation,
// The result is the smallest value of all the filtered pixels.
Erosion
};

enum class ColorFormat {
RGBA8,
A8
};


/**
A programmable convolution filter, designed to aid in the generation of texture data by custom
FontEffect types.
@author Peter Curry
*/

class ConvolutionFilter
class RMLUICORE_API ConvolutionFilter
{
public:
enum FilterOperation
{
// The result is the median value of all the filtered pixels.
MEDIAN,
// The result is the smallest value of all filtered pixels.
DILATION,
// The result is the largest value of all the filtered pixels.
EROSION
};

ConvolutionFilter();
~ConvolutionFilter();

/// Initialises a square kernel filter with the given radius.
bool Initialise(int kernel_radius, FilterOperation operation);

/// Initialises the filter. A filter must be initialised and populated with values before use.
/// @param[in] kernel_size The size of the filter's kernel each side of the origin. So, for example, a filter initialised with a size of 1 will store 9 values.
/// @param[in] kernel_radii The size of the filter's kernel on each side of the origin along both axes. So, for example, a filter initialised with radii (1,1) will store 9 values.
/// @param[in] operation The operation the filter conducts to determine the result.
bool Initialise(int kernel_size, FilterOperation operation = MEDIAN);
bool Initialise(Vector2i kernel_radii, FilterOperation operation);

/// Returns a reference to one of the rows of the filter kernel.
/// @param[in] index The index of the desired row.
/// @return The row of kernel values.
float* operator[](int index);
/// @param[in] kernel_y_index The index of the desired row.
/// @return Pointer to the first value in the kernel row.
float* operator[](int kernel_y_index);

/// Runs the convolution filter. The filter will operate on each pixel in the destination
/// surface, setting its opacity to the result the filter on the source opacity values. The
/// colour values will remain unchanged.
/// @param[in] destination The RGBA-encoded destination buffer.
/// @param[in] destination_dimensions The size of the destination region (in pixels).
/// @param[in] destination_stride The stride (in bytes) of the destination region.
/// @param[in] destination_color_format Determines the representation of the bytes in the destination texture, only the alpha channel will be written to.
/// @param[in] source The opacity information for the source buffer.
/// @param[in] source_dimensions The size of the source region (in pixels). The stride is assumed to be equivalent to the horizontal width.
/// @param[in] source_offset The offset of the source region from the destination region. This is usually the same as the kernel size.
void Run(byte* destination, const Vector2i& destination_dimensions, int destination_stride, const byte* source, const Vector2i& source_dimensions, const Vector2i& source_offset) const;
void Run(byte* destination, Vector2i destination_dimensions, int destination_stride, ColorFormat destination_color_format, const byte* source, Vector2i source_dimensions, Vector2i source_offset) const;

private:
int kernel_size;
float* kernel;
Vector2i kernel_size;
UniquePtr<float[]> kernel;

FilterOperation operation;
FilterOperation operation = FilterOperation::Sum;
};

}
Expand Down
13 changes: 5 additions & 8 deletions Include/RmlUi/Core/FontEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ namespace Core {
@author Peter Curry
*/

class FontEffect
class RMLUICORE_API FontEffect
{
public:
// Behind or in front of main text
// Behind or in front of the main text.
enum class Layer { Back, Front };

FontEffect();
Expand All @@ -59,19 +59,16 @@ class FontEffect
/// @return False if the effect is not providing support for the glyph, true otherwise.
virtual bool GetGlyphMetrics(Vector2i& origin, Vector2i& dimensions, const FontGlyph& glyph) const;

/// Requests the effect to generate the texture data for a single glyph's bitmap. The default implementation does
/// nothing.
/// @param[out] destination_data The top-left corner of the glyph's 32-bit, RGBA-ordered, destination texture. Note that they glyph shares its texture with other glyphs.
/// Requests the effect to generate the texture data for a single glyph's bitmap. The default implementation does nothing.
/// @param[out] destination_data The top-left corner of the glyph's 32-bit, RGBA-ordered, destination texture. Note that the glyph shares its texture with other glyphs.
/// @param[in] destination_dimensions The dimensions of the glyph's area on its texture.
/// @param[in] destination_stride The stride of the glyph's texture.
/// @param[in] glyph The glyph the effect is being asked to generate an effect texture for.
virtual void GenerateGlyphTexture(byte* destination_data, const Vector2i& destination_dimensions, int destination_stride, const FontGlyph& glyph) const;
virtual void GenerateGlyphTexture(byte* destination_data, Vector2i destination_dimensions, int destination_stride, const FontGlyph& glyph) const;

/// Sets the colour of the effect's geometry.
/// @param[in] colour The effect's colour.
void SetColour(const Colourb& colour);
/// Returns the effect's colour.
/// @return The colour of the effect.
const Colourb& GetColour() const;

Layer GetLayer() const;
Expand Down
2 changes: 1 addition & 1 deletion Include/RmlUi/Core/FontEffectInstancer.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class FontEffect;
/**
A font effect instancer provides a method for allocating and deallocating font effects.
It is important at the same instancer that allocated a font effect releases it. This ensures there are no issues
It is important that the same instancer that allocated a font effect releases it. This ensures there are no issues
with memory from different DLLs getting mixed up.
@author Peter Curry
Expand Down
2 changes: 1 addition & 1 deletion Include/RmlUi/Core/FontGlyph.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace Core {
@author Peter Curry
*/

class FontGlyph
class RMLUICORE_API FontGlyph
{
public:
FontGlyph() : dimensions(0,0), bearing(0,0), advance(0), bitmap_data(nullptr), bitmap_dimensions(0,0)
Expand Down
2 changes: 1 addition & 1 deletion Include/RmlUi/Core/Vector2.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Vector2
public:
/// Initialising constructor.
/// @param[in] v Initial value of each element in the vector.
inline Vector2(Type v = Type{ 0 });
explicit inline Vector2(Type v = Type{ 0 });
/// Initialising constructor.
/// @param[in] x Initial x-value of the vector.
/// @param[in] y Initial y-value of the vector.
Expand Down
2 changes: 1 addition & 1 deletion Include/RmlUi/Core/Vector3.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Vector3
public:
/// Initialising constructor.
/// @param[in] v Initial value of each element in the vector.
inline Vector3(Type v = Type{ 0 });
explicit inline Vector3(Type v = Type{ 0 });
/// Initialising constructor.
/// @param[in] x Initial x-value of the vector.
/// @param[in] y Initial y-value of the vector.
Expand Down
2 changes: 1 addition & 1 deletion Include/RmlUi/Core/Vector4.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Vector4
public:
/// Initialising constructor.
/// @param[in] v Initial value of each element in the vector.
inline Vector4(Type v = Type{ 0 });
explicit inline Vector4(Type v = Type{ 0 });
/// Initialising constructor.
/// @param[in] x Initial x-value of the vector.
/// @param[in] y Initial y-value of the vector.
Expand Down
2 changes: 1 addition & 1 deletion Samples/assets/invader.rcss
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ div#title_bar span
font-size: 22px;
font-weight: bold;

font-effect: outline(1px black);
font-effect: glow(1px black);

decorator: tiled-horizontal( title-bar-l, title-bar-c, title-bar-r );
}
Expand Down
93 changes: 86 additions & 7 deletions Samples/basic/demo/data/demo.rml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ body.window
{
width: 1300px;
height: 750px;
min-width: 940px;
min-width: 1090px;
min-height: 300px;
max-width: -1px;
max-height: -1px;
Expand All @@ -52,6 +52,7 @@ div#title_bar div#icon
div#content
{
position: relative;
/* background-color: #bbb; */
}
tabset
{
Expand All @@ -61,21 +62,17 @@ tabs
{
display: block;
position: fixed;
width: 100%;
clip: none;
pointer-events: none;
text-align: right;
padding-left: 200px;
padding-right: 10px;
top: -47px;
}
tab
{
position: relative;
width: 100px;
pointer-events: auto;
padding: 0px 20px;
line-height: 40px;
top: -47px;
z-index: 2;

font-size: 16px;
color: #ddd;
Expand Down Expand Up @@ -115,6 +112,7 @@ p.title
{
font-size: 35px;
color: #b33;
font-effect: glow(2px #ed5);
}
.center {
text-align: center;
Expand Down Expand Up @@ -222,6 +220,68 @@ p.title
.orientation-rotate { decorator: image( icon-invader rotate-180 scale-none ); }


/*** Font effects ***/

#font_effects div
{
display: inline-block;
width: 150px;
margin: 0px 30px 30px;
text-align: center;
font-size: 35px;
color: #b33;
}
#font_effects h1
{
margin: 15px 0 10px 0;
}
#font_effects .glow
{
font-effect: glow(3px #ed5);
}
#font_effects .glow_sharper
{
font-effect: glow(3px 1px #ed5);
}
#font_effects .glow_blurry
{
font-effect: glow(2px 7px #ed5);
}
#font_effects .glow_shadow
{
color: #ed5;
font-effect: glow(2px 4px 2px 3px #644);
}
#font_effects .outline_small
{
font-effect: outline(2px #ed5);
}
#font_effects .outline_big
{
font-effect: outline(4px #ed5);
}
#font_effects .blur_small
{
color: transparent;
font-effect: blur(3px #ed5);
}
#font_effects .blur_big
{
color: transparent;
font-effect: blur(10px #ed5);
}
#font_effects .shadow_up
{
font-weight: bold;
font-effect: shadow(3px -3px #ed5);
}
#font_effects .shadow_down
{
font-weight: bold;
font-effect: shadow(0px 2px #333);
}


/*** Animations ***/

#tweening_area
Expand Down Expand Up @@ -574,6 +634,25 @@ form h2
<img src="../../../assets/invader.tga" rect="0 0 500 300" style="margin-top: 10px; margin-bottom: 10px;"/>
<p>is used to render most sprites in this demo. Sprites can be used in decorators and image elements as if they were separate images.</p>
</panel>
<tab>Font effects</tab>
<panel id="font_effects">
<h1>None</h1>
<div class="original">RmlUi 😍</div>
<h1>Glow</h1>
<div class="glow">RmlUi 😍</div>
<div class="glow_sharper">RmlUi 😍</div>
<div class="glow_blurry">RmlUi 😍</div>
<div class="glow_shadow">RmlUi 😍</div>
<h1>Outline</h1>
<div class="outline_small">RmlUi 😍</div>
<div class="outline_big">RmlUi 😍</div>
<h1>Shadow</h1>
<div class="shadow_up">RmlUi 😍</div>
<div class="shadow_down">RmlUi 😍</div>
<h1>Blur</h1>
<div class="blur_small">RmlUi 😍</div>
<div class="blur_big">RmlUi 😍</div>
</panel>
<tab>Animations</tab>
<panel id="animations">

Expand Down
Loading

0 comments on commit 0b53977

Please sign in to comment.