Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions inc/Graphics/Pass/HTMLDrawerPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <Graphics/Render/HTMLRenderer.h>

namespace SR_GRAPH_NS {
#ifdef SR_COMMON_LITEHTML
class HTMLDrawerPass : public BasePass {
SR_REGISTER_LOGICAL_NODE(HTMLDrawerPass, HTML Drawer Pass, { "Passes" })
using Super = BasePass;
Expand Down Expand Up @@ -40,6 +41,7 @@ namespace SR_GRAPH_NS {
std::atomic<uint16_t> m_needReloadPage = false;

};
#endif
}

#endif //SR_ENGINE_HTML_DRAWER_PASS_H
4 changes: 3 additions & 1 deletion inc/Graphics/Render/HTMLRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

namespace SR_GRAPH_NS {
class TextBuilder;


#ifdef SR_COMMON_LITEHTML
class HTMLRenderContainer : public SR_UTILS_NS::Web::HTMLContainerInterface {
using Super = SR_UTILS_NS::Web::HTMLContainerInterface;
struct ShaderInfo {
Expand Down Expand Up @@ -91,6 +92,7 @@ namespace SR_GRAPH_NS {
std::map<SR_UTILS_NS::StringAtom, ShaderInfo> m_shaders;
std::vector<TextAtlas> m_textAtlases;
};
#endif // SR_COMMON_LITEHTML
}

#endif //SR_ENGINE_GRAPHICS_HTML_RENDERER_H
6 changes: 6 additions & 0 deletions src/Graphics/Pass/HTMLDrawerPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
#include <Utils/Web/HTML/HTMLParser.h>

namespace SR_GRAPH_NS {
#ifdef SR_COMMON_LITEHTML
SR_REGISTER_RENDER_PASS(HTMLDrawerPass)
HTMLDrawerPass::~HTMLDrawerPass() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Дубликат

SRAssert2(m_fileWatchers.empty(), "Watchers are not empty!");
SRAssert2(!m_pPage, "Page is not empty!");
}

HTMLDrawerPass::~HTMLDrawerPass() {
SRAssert2(m_fileWatchers.empty(), "Watchers are not empty!");
Expand Down Expand Up @@ -173,4 +178,5 @@ namespace SR_GRAPH_NS {

m_pPage->GetDocument()->render(static_cast<int32_t>(size.x));
}
#endif //SR_COMMON_LITEHTML
}
8 changes: 4 additions & 4 deletions src/Graphics/Render/HTML/HTMLDrawableElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ namespace SR_GRAPH_NS {
position.y = -position.y - context.size.y;
position = SR_MATH_NS::FVector2(-1, 1) + (position / context.resolution);

m_pShader->SetVec2("position"_atom_hash_cexpr, position);
m_pShader->SetVec2("size"_atom_hash_cexpr, context.size / context.resolution);
m_pShader->SetVec2("position"_atom_hash, position);
m_pShader->SetVec2("size"_atom_hash, context.size / context.resolution);

if (style.backgroundColor.colorType == SR_UTILS_NS::Web::CSSColor::ColorType::RGBA) {
m_pShader->SetVec4("backgroundColor"_atom_hash_cexpr, style.backgroundColor.color.ToFColor());
//m_pShader->SetVec4("backgroundColor"_atom_hash_cexpr, SR_MATH_NS::FColor::Cyan());
m_pShader->SetVec4("backgroundColor"_atom_hash, style.backgroundColor.color.ToFColor());
//m_pShader->SetVec4("backgroundColor"_atom_hash, SR_MATH_NS::FColor::Cyan());
}

SR_MAYBE_UNUSED_VAR m_pShader->Flush();
Expand Down
36 changes: 30 additions & 6 deletions src/Graphics/Render/HTMLRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ namespace SR_GRAPH_NS {
SR_UTILS_NS::StringAtom SR_SOLID_FILL_SHADER = "solid-fill"_atom;
SR_UTILS_NS::StringAtom SR_TEXT_SHADER = "text"_atom;


std::vector<SR_UTILS_NS::StringAtom> SR_HTML_SHADERS = {
SR_SOLID_FILL_SHADER, SR_TEXT_SHADER
};

#ifdef SR_COMMON_LITEHTML
HTMLRenderContainer::HTMLRenderContainer()
: Super()
, m_uboManager(SR_GRAPH_NS::Memory::UBOManager::Instance())
Expand Down Expand Up @@ -122,6 +124,7 @@ namespace SR_GRAPH_NS {
m_pipeline->SetDirty(true);
}


if (SR_UTILS_NS::Input::Instance().GetKey(SR_UTILS_NS::KeyCode::RightArrow)) {
m_scroll.x -= 10;
m_pipeline->SetDirty(true);
Expand All @@ -132,6 +135,7 @@ namespace SR_GRAPH_NS {
continue;
}


if (shaderInfo.pShader->BeginSharedUBO()) {
if (m_pCamera) {
shaderInfo.pShader->SetMat4(SHADER_ORTHOGONAL_MATRIX, m_pCamera->GetOrthogonal());
Expand Down Expand Up @@ -167,9 +171,11 @@ namespace SR_GRAPH_NS {
void HTMLRenderContainer::get_client_rect(litehtml::position& client) const {
SR_TRACY_ZONE;


client.x = 0;
client.y = 0;


if (m_pCamera) {
client.width = m_pCamera->GetSize().Cast<int32_t>().x;
client.height = m_pCamera->GetSize().Cast<int32_t>().y;
Expand Down Expand Up @@ -285,9 +291,11 @@ namespace SR_GRAPH_NS {
position.x = position.x + box.width;
position.y = -position.y - box.height;

pShader->SetVec2("position"_atom_hash_cexpr, SR_MATH_NS::FVector2(-1, 1) + position / m_viewSize);
pShader->SetVec2("size"_atom_hash_cexpr, SR_MATH_NS::FVector2(box.width, box.height) / m_viewSize);
pShader->SetVec4("color"_atom_hash_cexpr, SR_MATH_NS::FColor(color.red, color.green, color.blue, color.alpha) / 255.f);

pShader->SetVec2("position"_atom_hash, SR_MATH_NS::FVector2(-1, 1) + position / m_viewSize);
pShader->SetVec2("size"_atom_hash, SR_MATH_NS::FVector2(box.width, box.height) / m_viewSize);
pShader->SetVec4("color"_atom_hash, SR_MATH_NS::FColor(color.red, color.green, color.blue, color.alpha) / 255.f);

DrawElement(shaderInfo);
UpdateElement(shaderInfo);
EndElement(shaderInfo);
Expand All @@ -307,6 +315,12 @@ namespace SR_GRAPH_NS {
}
ShaderInfo& shaderInfo = pIt->second;

auto&& pTextAtlas = GetTextAtlas(text, reinterpret_cast<TextBuilder*>(hFont));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Дубликат

if (!pTextAtlas) {
return;
}
ShaderInfo& shaderInfo = pIt->second;

auto&& pTextAtlas = GetTextAtlas(text, reinterpret_cast<TextBuilder*>(hFont));
if (!pTextAtlas) {
return;
Expand All @@ -318,16 +332,25 @@ namespace SR_GRAPH_NS {

auto&& pShader = m_pipeline->GetCurrentShader();

if (!BeginElement(shaderInfo)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лишнее

return;
}

auto&& pShader = m_pipeline->GetCurrentShader();


litehtml::position box = pos;
box.height += pTextAtlas->pTextBuilderRef->GetHeight();

SR_MATH_NS::FVector2 position = SR_MATH_NS::FVector2(box.x, box.y) * 2.f;
position.x = position.x + box.width;
position.y = -position.y - box.height;

pShader->SetVec2("position"_atom_hash_cexpr, SR_MATH_NS::FVector2(-1, 1) + position / m_viewSize);
pShader->SetVec2("size"_atom_hash_cexpr, SR_MATH_NS::FVector2(box.width, box.height) / m_viewSize);
pShader->SetVec4("color"_atom_hash_cexpr, SR_MATH_NS::FColor(color.red, color.green, color.blue, color.alpha) / 255.f);

pShader->SetVec2("position"_atom_hash, SR_MATH_NS::FVector2(-1, 1) + position / m_viewSize);
pShader->SetVec2("size"_atom_hash, SR_MATH_NS::FVector2(box.width, box.height) / m_viewSize);
pShader->SetVec4("color"_atom_hash, SR_MATH_NS::FColor(color.red, color.green, color.blue, color.alpha) / 255.f);

pShader->SetSampler2D("textAtlas", pTextAtlas->id);

DrawElement(shaderInfo);
Expand Down Expand Up @@ -451,4 +474,5 @@ namespace SR_GRAPH_NS {
m_pipeline->Draw(4);
}
}
#endif //SR_COMMON_LITEHTML
}