-
Notifications
You must be signed in to change notification settings - Fork 380
Working on caching box shadows #802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ZilverBlade
wants to merge
13
commits into
mikke89:master
Choose a base branch
from
ZilverBlade:799-box-shadow-caching
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
eb1a0e1
initial work on caching box shadows
f39fc20
hash function for the BoxShadowGeometryInfo and passing the mesh data…
cf9e163
fixed several compiler errors, using shared pointers, added cleanup f…
0bd3d6b
replaced HashCombine with existing implementation, and fixed build er…
ZilverBlade ec8990e
fixed global quantifier errors
ZilverBlade efe47a5
Comment cleanup and fixed resource leak error
efddb5c
refactored the box shadow cache (Currently broken!) to be more simila…
ZilverBlade 646de5a
Implemented cache, added BoxShadowCache.cpp to the cmakelists.txt and…
ZilverBlade b9fb7bc
fixed some compiler errors and added missing initialisation and destr…
ZilverBlade 5abfb48
Merge branch 'mikke89:master' into 799-box-shadow-caching
ZilverBlade 9500871
fixed compile errors and fixed missing opacity and texture offset in …
ZilverBlade 8eb1d8a
Fixed missing background border geometry cache
ZilverBlade 360d109
fixed some compiler errors
ZilverBlade File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,83 +38,6 @@ | |
| #include "Types.h" | ||
| #include "Utilities.h" | ||
|
||
|
|
||
| namespace Rml { | ||
| using RenderBoxList = Vector<RenderBox>; | ||
| struct BoxShadowGeometryInfo { | ||
| ColourbPremultiplied background_color; | ||
| Array<ColourbPremultiplied, 4> border_colors; | ||
| CornerSizes border_radius; | ||
| Vector2i texture_dimensions; | ||
| Vector2f element_offset_in_texture; | ||
| RenderBoxList padding_render_boxes; | ||
| RenderBoxList border_render_boxes; | ||
| BoxShadowList shadow_list; | ||
| }; | ||
| inline bool operator==(const BoxShadowGeometryInfo& a, const BoxShadowGeometryInfo& b) | ||
| { | ||
| return a.background_color == b.background_color && a.border_colors == b.border_colors && a.border_radius == b.border_radius && a.texture_dimensions == b.texture_dimensions && | ||
| a.element_offset_in_texture == b.element_offset_in_texture && a.padding_render_boxes == b.padding_render_boxes && a.border_render_boxes == b.border_render_boxes && a.shadow_list == b.shadow_list; | ||
| } | ||
| inline bool operator!=(const BoxShadowGeometryInfo& a, const BoxShadowGeometryInfo& b) | ||
| { | ||
| return !(a == b); | ||
| } | ||
| } | ||
|
|
||
| template<> struct std::hash<Rml::BoxShadowGeometryInfo> { | ||
| std::size_t operator()(const Rml::BoxShadowGeometryInfo& in) const noexcept { | ||
| using namespace Rml; | ||
| using namespace Rml::Utilities; | ||
| using namespace std; | ||
| size_t result = size_t(849128392); | ||
|
|
||
| HashCombine(result, reinterpret_cast<const uint32_t&>(in.background_color)); | ||
| for (const auto& v : in.border_colors) { | ||
| HashCombine(result, reinterpret_cast<const uint32_t&>(v)); | ||
| } | ||
|
|
||
| for (const auto& v : in.border_radius) { | ||
| HashCombine(result, v); | ||
| } | ||
| HashCombine(result, in.texture_dimensions.x); | ||
| HashCombine(result, in.texture_dimensions.y); | ||
| HashCombine(result, in.element_offset_in_texture.x); | ||
| HashCombine(result, in.element_offset_in_texture.y); | ||
|
|
||
| static const auto fn_hash_render_box = [](size_t& result, const RenderBox& v) { | ||
| HashCombine(result, v.GetFillSize().x); | ||
| HashCombine(result, v.GetFillSize().y); | ||
| HashCombine(result, v.GetBorderOffset().x); | ||
| HashCombine(result, v.GetBorderOffset().y); | ||
| for (const auto& w : v.GetBorderRadius()) { | ||
| HashCombine(result, w); | ||
| } | ||
| for (const auto& w : v.GetBorderWidths()) { | ||
| HashCombine(result, w); | ||
| } | ||
| }; | ||
| for (const auto& v : in.padding_render_boxes) { | ||
| fn_hash_render_box(result, v); | ||
| } | ||
| for (const auto& v : in.border_render_boxes) { | ||
| fn_hash_render_box(result, v); | ||
| } | ||
| for (const auto& v : in.shadow_list) { | ||
| HashCombine(result, v.blur_radius.number); | ||
| HashCombine(result, v.blur_radius.unit); | ||
| HashCombine(result, reinterpret_cast<const uint32_t&>(v.color)); | ||
| HashCombine(result, v.inset); | ||
| HashCombine(result, v.offset_x.number); | ||
| HashCombine(result, v.offset_x.unit); | ||
| HashCombine(result, v.offset_y.number); | ||
| HashCombine(result, v.offset_y.unit); | ||
| HashCombine(result, v.spread_distance.number); | ||
| HashCombine(result, v.spread_distance.unit); | ||
| } | ||
| return result; | ||
| } | ||
| }; | ||
|
|
||
| namespace Rml { | ||
| class Geometry; | ||
| class CompiledFilter; | ||
|
|
@@ -180,8 +103,6 @@ class RMLUICORE_API RenderManager : NonCopyMoveable { | |
| Texture LoadTexture(const String& source, const String& document_path = String()); | ||
| CallbackTexture MakeCallbackTexture(CallbackTextureFunction callback); | ||
|
|
||
| SharedPtr<CallbackTexture> FindOrMakeBoxShadowCallbackTexture(const BoxShadowGeometryInfo& geometry_info, CallbackTextureFunction callback); | ||
|
|
||
| CompiledFilter CompileFilter(const String& name, const Dictionary& parameters); | ||
| CompiledShader CompileShader(const String& name, const Dictionary& parameters); | ||
|
|
||
|
|
@@ -214,11 +135,6 @@ class RMLUICORE_API RenderManager : NonCopyMoveable { | |
| void ReleaseResource(const CompiledFilter& filter); | ||
| void ReleaseResource(const CompiledShader& shader); | ||
|
|
||
| // TODO: better way to autonomously release the box shadow cache? | ||
| // References are needed to texture, and we need to be able to ref count it. | ||
| // Another possibility is making a custom SharedPtr<> class and allow us to manually reduce ref counts. | ||
| void CleanupDeadBoxShadowCache(); | ||
|
|
||
| struct GeometryData { | ||
| Mesh mesh; | ||
| CompiledGeometryHandle handle = {}; | ||
|
|
@@ -229,8 +145,6 @@ class RMLUICORE_API RenderManager : NonCopyMoveable { | |
| StableVector<GeometryData> geometry_list; | ||
| UniquePtr<TextureDatabase> texture_database; | ||
|
|
||
| UnorderedMap<BoxShadowGeometryInfo, SharedPtr<CallbackTexture>> box_shadow_cache; | ||
|
|
||
| int compiled_filter_count = 0; | ||
| int compiled_shader_count = 0; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.