Skip to content
Merged
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
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ jobs:
# keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key
- name: git clone
uses: myci-actions/checkout@main
with:
submodules: true
- name: prepare debian package
run: myci-deb-prepare.sh
- name: install deps
Expand Down Expand Up @@ -110,6 +112,8 @@ jobs:
apt install --assume-yes devscripts equivs
- name: git clone
uses: myci-actions/checkout@main
with:
submodules: true
- name: prepare debian package
run: myci-deb-prepare.sh
- name: install deps
Expand All @@ -136,6 +140,8 @@ jobs:
install: myci locales git devscripts equivs
- name: git clone
uses: myci-actions/checkout@main
with:
submodules: true
- name: prepare debian package
run: myci-deb-prepare.sh
- name: install deps
Expand Down Expand Up @@ -194,6 +200,8 @@ jobs:
install: myci git devscripts equivs
- name: git clone
uses: myci-actions/checkout@main
with:
submodules: true
- name: set PACKAGE_VERSION
uses: myci-actions/export-env-var@main
with: {name: PACKAGE_VERSION, value: $(myci-deb-version.sh)}
Expand Down Expand Up @@ -225,6 +233,8 @@ jobs:
rm -rf /usr/local/bin/python3*-config
- name: git clone
uses: myci-actions/checkout@main
with:
submodules: true
- name: install clang-tidy and clang-format
run: |
brew install llvm
Expand Down Expand Up @@ -267,6 +277,8 @@ jobs:
steps:
- name: git clone
uses: myci-actions/checkout@main
with:
submodules: true
- name: add cppfw deb repo
uses: myci-actions/add-deb-repo@main
with:
Expand Down Expand Up @@ -325,6 +337,8 @@ jobs:
key-server: https://gagis.hopto.org/repo/cppfw/pubkey.gpg
- name: git clone
uses: myci-actions/checkout@main
with:
submodules: true
- name: prepare pacman package
run: myci-apply-version.sh build/msys2/PKGBUILD.in
- name: build
Expand Down Expand Up @@ -563,6 +577,8 @@ jobs:
sed -i -E "s/compiler.cppstd=.*$/compiler.cppstd=20/g" ~/.conan2/profiles/default
- name: git clone
uses: myci-actions/checkout@main
with:
submodules: true
- name: set PACKAGE_VERSION
uses: myci-actions/export-env-var@main
with: {name: PACKAGE_VERSION, value: $(myci-deb-version.sh)}
Expand Down Expand Up @@ -606,6 +622,8 @@ jobs:
ln -s "$(brew --prefix llvm)/bin/clang-apply-replacements" "/usr/local/bin/clang-apply-replacements"
- name: git clone
uses: myci-actions/checkout@main
with:
submodules: true
- name: add cppfw tap
run: |
brew tap cppfw/tap
Expand Down
8 changes: 4 additions & 4 deletions src/ruis/font/texture_font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ texture_font::glyph texture_font::load_glyph(char32_t c) const
g.top_left = ftg.vertices[0];
g.bottom_right = ftg.vertices[2];

auto& rc = this->rendering_context.get();
auto& rc = this->factory.get();

// clang-format off
g.vao = rc.make_vertex_array(
Expand All @@ -201,13 +201,13 @@ texture_font::glyph texture_font::load_glyph(char32_t c) const
}

texture_font::texture_font(
utki::shared_ref<const ruis::render::context> rendering_context, //
utki::shared_ref<const ruis::render::factory> factory, //
utki::shared_ref<const ruis::render::renderer::objects> common_rendering_objects,
utki::shared_ref<const freetype_face> face,
unsigned font_size,
unsigned max_cached
) :
rendering_context(std::move(rendering_context)),
factory(std::move(factory)),
common_rendering_objects(std::move(common_rendering_objects)),
font_size(font_size),
face(std::move(face)),
Expand Down Expand Up @@ -358,7 +358,7 @@ font::render_result texture_font::render_internal(
return ret;
}

renderer.rendering_context.get().set_simple_alpha_blending();
renderer.ctx().set_simple_alpha_blending();

ruis::mat4 matr(matrix);

Expand Down
6 changes: 3 additions & 3 deletions src/ruis/font/texture_font.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public:
*/
class texture_font : public font
{
const utki::shared_ref<const ruis::render::context> rendering_context;
const utki::shared_ref<const ruis::render::factory> factory;
const utki::shared_ref<const ruis::render::renderer::objects> common_rendering_objects;

const unsigned font_size;
Expand Down Expand Up @@ -137,13 +137,13 @@ class texture_font : public font
public:
/**
* @brief Constructor.
* @param renderer - ruis renderer.
* @param factory - render factory to create the glyph textures and vertex arrays in.
* @param face - freetype font.
* @param font_size - size of the font in pixels.
* @param max_cached - maximum number of glyphs to cache.
*/
texture_font(
utki::shared_ref<const ruis::render::context> rendering_context, //
utki::shared_ref<const ruis::render::factory> factory, //
utki::shared_ref<const ruis::render::renderer::objects> common_rendering_objects,
utki::shared_ref<const freetype_face> face,
unsigned font_size,
Expand Down
6 changes: 3 additions & 3 deletions src/ruis/font/texture_font_face.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
using namespace ruis;

texture_font_face::texture_font_face(
utki::shared_ref<const ruis::render::context> rendering_context, //
utki::shared_ref<const ruis::render::factory> factory, //
utki::shared_ref<const ruis::render::renderer::objects> common_rendering_objects,
utki::shared_ref<const freetype_face> face,
unsigned max_cached
) :
rendering_context(std::move(rendering_context)),
factory(std::move(factory)),
common_rendering_objects(std::move(common_rendering_objects)),
face(std::move(face)),
max_cached(max_cached)
Expand All @@ -38,7 +38,7 @@ texture_font_face::texture_font_face(
utki::shared_ref<const font> texture_font_face::create(real size) const
{
return utki::make_shared<texture_font>(
this->rendering_context, //
this->factory, //
this->common_rendering_objects,
this->face,
unsigned(size),
Expand Down
4 changes: 2 additions & 2 deletions src/ruis/font/texture_font_face.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ namespace ruis {

class texture_font_face : public font_face
{
const utki::shared_ref<const ruis::render::context> rendering_context;
const utki::shared_ref<const ruis::render::factory> factory;
const utki::shared_ref<const ruis::render::renderer::objects> common_rendering_objects;

const utki::shared_ref<const freetype_face> face;
const unsigned max_cached;

public:
texture_font_face(
utki::shared_ref<const ruis::render::context> rendering_context, //
utki::shared_ref<const ruis::render::factory> factory, //
utki::shared_ref<const ruis::render::renderer::objects> common_rendering_objects,
utki::shared_ref<const freetype_face> face,
unsigned max_cached
Expand Down
6 changes: 3 additions & 3 deletions src/ruis/paint/ellipse_vao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ std::map<
ellipse_vao::cache;

ellipse_vao::ellipse_vao(
utki::shared_ref<const ruis::render::context> ctx,
utki::shared_ref<const ruis::render::factory> factory,
vec2 diameters, //
real stroke_width
) :
ctx(std::move(ctx))
factory(std::move(factory))
{
this->set(
diameters, //
Expand Down Expand Up @@ -117,7 +117,7 @@ void ellipse_vao::update_texture()

// TODO: convert to greyscale image

this->tex = this->ctx.get().make_texture_2d(
this->tex = this->factory.get().make_texture_2d(
make_ellipse_texture_image(this->diameters, this->stroke_width), //
{}
);
Expand Down
10 changes: 5 additions & 5 deletions src/ruis/paint/ellipse_vao.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ namespace ruis::paint {
*/
class ellipse_vao
{
// the context in which the ellipse texture is created; it must outlive this
// VAO, so use the shared resource-loader context
utki::shared_ref<const ruis::render::context> ctx;
// the shared render factory in which the ellipse texture is created; it is
// retained so that set() can create a new texture when the parameters change
utki::shared_ref<const ruis::render::factory> factory;

vec2 diameters = 0;

Expand All @@ -44,12 +44,12 @@ class ellipse_vao
public:
/**
* @brief Constructor.
* @param ctx - context to create the ellipse texture in (must outlive this VAO).
* @param factory - render factory to create the ellipse texture in.
* @param diameters - ellipse diameters.
* @param stroke_width - ellipse border width. Non-positive value means filled ellipse.
*/
ellipse_vao(
utki::shared_ref<const ruis::render::context> ctx,
utki::shared_ref<const ruis::render::factory> factory,
vec2 diameters = 0, //
real stroke_width = 0 //
);
Expand Down
31 changes: 18 additions & 13 deletions src/ruis/paint/path_vao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,51 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

using namespace ruis::paint;

// NOLINTNEXTLINE(modernize-pass-by-value)
path_vao::path_vao(utki::shared_ref<const ruis::render::renderer> r) :
renderer(std::move(r)),
core(this->renderer.get().obj().empty_vertex_array),
border(this->renderer.get().obj().empty_vertex_array)
path_vao::path_vao(
utki::shared_ref<const ruis::render::factory> factory, //
const ruis::render::renderer::objects& objects
) :
factory(std::move(factory)),
core(objects.empty_vertex_array),
border(objects.empty_vertex_array)
{}

void path_vao::set(const path::vertices& path)
{
auto core_buf = this->renderer.get().rendering_context.get().make_vertex_buffer(path.pos);
auto& f = this->factory.get();

this->core = this->renderer.get().rendering_context.get().make_vertex_array(
auto core_buf = f.make_vertex_buffer(path.pos);

this->core = f.make_vertex_array(
{
core_buf,
},
this->renderer.get().rendering_context.get().make_index_buffer(path.in_indices),
f.make_index_buffer(path.in_indices),
ruis::render::vertex_array::mode::triangle_strip
);
this->border = this->renderer.get().rendering_context.get().make_vertex_array(
this->border = f.make_vertex_array(
{
core_buf,
this->renderer.get().rendering_context.get().make_vertex_buffer(path.alpha),
f.make_vertex_buffer(path.alpha),
},
this->renderer.get().rendering_context.get().make_index_buffer(path.out_indices),
f.make_index_buffer(path.out_indices),
ruis::render::vertex_array::mode::triangle_strip
);
}

void path_vao::render(
const ruis::render::renderer& renderer, //
const ruis::mat4& matrix, //
ruis::color color
) const
{
this->renderer.get().shaders().color_pos->render(
renderer.shaders().color_pos->render(
matrix, //
this->core.get(),
color
);

this->renderer.get().shaders().color_pos_lum->render(
renderer.shaders().color_pos_lum->render(
matrix, //
this->border.get(),
color
Expand Down
13 changes: 10 additions & 3 deletions src/ruis/paint/path_vao.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,22 @@ namespace ruis::paint {
*/
class path_vao
{
utki::shared_ref<const ruis::render::renderer> renderer;
// the shared render factory in which the path vertex arrays are created
utki::shared_ref<const ruis::render::factory> factory;

utki::shared_ref<const ruis::render::vertex_array> core;
utki::shared_ref<const ruis::render::vertex_array> border;

public:
/**
* @brief Constructor.
* @param r - renderer to use.
* @param factory - render factory to create the path vertex arrays in.
* @param objects - shared objects used to initialise the (empty) vertex arrays.
*/
path_vao(utki::shared_ref<const ruis::render::renderer> r);
path_vao(
utki::shared_ref<const ruis::render::factory> factory, //
const ruis::render::renderer::objects& objects
);

path_vao(const path_vao&) = delete;
path_vao& operator=(const path_vao&) = delete;
Expand All @@ -69,10 +74,12 @@ class path_vao

/**
* @brief Render the path.
* @param renderer - renderer to draw with.
* @param matrix - model-view-projection matrix.
* @param color - color to render the path with.
*/
void render(
const ruis::render::renderer& renderer, //
const ruis::mat4& matrix, //
ruis::color color
) const;
Expand Down
Loading
Loading