Commit 507ac286 authored by Christian Persch's avatar Christian Persch

draw: Move custom drawing code into its own class

parent 42ea29e9
......@@ -109,6 +109,8 @@ libvte_common_sources = debug_sources + glib_glue_sources + libc_glue_sources +
'gobject-glue.hh',
'keymap.cc',
'keymap.h',
'minifont.cc',
'minifont.hh',
'missing.cc',
'missing.hh',
'reaper.cc',
......
This diff is collapsed.
/*
* Copyright (C) 2003,2008 Red Hat, Inc.
* Copyright © 2019, 2020 Christian Persch
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <cstdint>
#include "fwd.hh"
#include "vtetypes.hh"
#include "vteunistr.h"
namespace vte {
namespace view {
class Minifont {
public:
/* Check if a unicode character is actually a graphic character we draw
* ourselves to handle cases where fonts don't have glyphs for them.
*/
static inline constexpr bool
unistr_is_local_graphic(vteunistr const c) noexcept
{
/* Box Drawing & Block Elements */
return ((c >= 0x2500 && c <= 0x259f) ||
(c >= 0x25e2 && c <= 0x25e5) ||
(c >= 0x1fb00 && c <= 0x1fbaf));
}
/* Draw the graphic representation of a line-drawing or special graphics
* character.
*/
void draw_graphic(DrawingContext const& context,
vteunistr c,
uint32_t const attr,
vte::color::rgb const* fg,
int x,
int y,
int font_width,
int columns,
int font_height);
}; // class Minifont
} // namespace view
} // namespace vte
This diff is collapsed.
......@@ -28,6 +28,8 @@
#include "vteunistr.h"
#include "vtetypes.hh"
#include "minifont.hh"
#define VTE_DRAW_OPAQUE (1.0)
#define VTE_DRAW_NORMAL 0
......@@ -66,6 +68,7 @@ public:
DrawingContext& operator=(DrawingContext&&) = delete;
void set_cairo(cairo_t* cr) noexcept;
auto cairo() const noexcept { return m_cr; }
void clip(cairo_rectangle_int_t const* rect);
void unclip();
......@@ -133,6 +136,9 @@ public:
vte::color::rgb const* color,
double alpha);
auto cell_width() const noexcept { return m_cell_width; }
auto cell_height() const noexcept { return m_cell_height; }
private:
void set_source_color_alpha (vte::color::rgb const* color,
double alpha);
......@@ -159,6 +165,8 @@ private:
cairo_t *m_cr{nullptr}; // unowned
Minifont m_minifont{};
/* Cache the undercurl's rendered look. */
std::unique_ptr<cairo_surface_t, decltype(&cairo_surface_destroy)> m_undercurl_surface{nullptr, nullptr};
}; // class DrawingContext
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment