Create member function Fl_Cairo_Graphics_Driver::set_cairo().
This commit is contained in:
parent
1ae95fddd9
commit
8808d11578
@ -43,9 +43,9 @@ private:
|
||||
protected:
|
||||
cairo_t *dummy_cairo_; // used to measure text width before showing a window
|
||||
cairo_t *cairo_;
|
||||
cairo_t *pango_layout_cairo_;
|
||||
PangoLayout *pango_layout_;
|
||||
int linestyle_;
|
||||
void handle_dummy_cairo(cairo_t *);
|
||||
public:
|
||||
Fl_Cairo_Graphics_Driver();
|
||||
virtual ~Fl_Cairo_Graphics_Driver();
|
||||
@ -61,6 +61,7 @@ public:
|
||||
int gap_;
|
||||
cairo_t *cr() { return cairo_; }
|
||||
PangoLayout *pango_layout() {return pango_layout_;}
|
||||
void set_cairo(cairo_t *c, float f = 0);
|
||||
|
||||
void check_status(void);
|
||||
|
||||
|
@ -69,6 +69,7 @@ static void draw_image_cb(void *data, int x, int y, int w, uchar *buf) {
|
||||
Fl_Cairo_Graphics_Driver::Fl_Cairo_Graphics_Driver() : Fl_Graphics_Driver() {
|
||||
cairo_ = NULL;
|
||||
pango_layout_ = NULL;
|
||||
pango_layout_cairo_ = NULL;
|
||||
dummy_cairo_ = NULL;
|
||||
linestyle_ = FL_SOLID;
|
||||
clip_ = NULL;
|
||||
@ -85,12 +86,22 @@ Fl_Cairo_Graphics_Driver::~Fl_Cairo_Graphics_Driver() {
|
||||
const cairo_format_t Fl_Cairo_Graphics_Driver::cairo_format = CAIRO_FORMAT_ARGB32;
|
||||
|
||||
|
||||
void Fl_Cairo_Graphics_Driver::handle_dummy_cairo(cairo_t *cr) {
|
||||
pango_cairo_update_layout(cr, pango_layout_); // 1.10
|
||||
cairo_surface_t *surf = cairo_get_target(dummy_cairo_);
|
||||
cairo_destroy(dummy_cairo_);
|
||||
cairo_surface_destroy(surf);
|
||||
dummy_cairo_ = NULL;
|
||||
void Fl_Cairo_Graphics_Driver::set_cairo(cairo_t *cr, float s) {
|
||||
if (dummy_cairo_) {
|
||||
g_object_unref(pango_layout_);
|
||||
pango_layout_ = NULL;
|
||||
cairo_surface_t *surf = cairo_get_target(dummy_cairo_);
|
||||
cairo_destroy(dummy_cairo_);
|
||||
cairo_surface_destroy(surf);
|
||||
dummy_cairo_ = NULL;
|
||||
}
|
||||
cairo_ = cr;
|
||||
cairo_restore(cairo_);
|
||||
line_style(0);
|
||||
cairo_save(cairo_);
|
||||
if (s == 0) s = scale();
|
||||
cairo_scale(cairo_, s, s);
|
||||
cairo_translate(cairo_, 0.5, 0.5);
|
||||
}
|
||||
|
||||
|
||||
@ -1088,9 +1099,13 @@ void Fl_Cairo_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize s) {
|
||||
cairo_ = cairo_create(surf);
|
||||
}
|
||||
pango_layout_ = pango_cairo_create_layout(cairo_); // 1.10
|
||||
pango_layout_cairo_ = cairo_;
|
||||
if (needs_dummy) {
|
||||
dummy_cairo_ = cairo_;
|
||||
}
|
||||
} else if (pango_layout_cairo_ != cairo_) {
|
||||
pango_cairo_update_layout(cairo_, pango_layout_);
|
||||
pango_layout_cairo_ = cairo_;
|
||||
}
|
||||
if (s == 0) return;
|
||||
if (font() == fnum && size() == s) return;
|
||||
|
@ -43,7 +43,7 @@ Fl_Wayland_Copy_Surface_Driver::~Fl_Wayland_Copy_Surface_Driver() {
|
||||
|
||||
void Fl_Wayland_Copy_Surface_Driver::set_current() {
|
||||
Fl_Surface_Device::set_current();
|
||||
((Fl_Wayland_Graphics_Driver*)driver())->activate(img_surf->offscreen(), driver()->scale());
|
||||
((Fl_Wayland_Graphics_Driver*)driver())->set_buffer(img_surf->offscreen());
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,7 +65,6 @@ struct fl_wld_buffer {
|
||||
struct wl_callback *cb;
|
||||
bool draw_buffer_needs_commit;
|
||||
cairo_t *cairo_;
|
||||
PangoLayout *pango_layout_;
|
||||
};
|
||||
struct wld_window;
|
||||
|
||||
@ -76,7 +75,7 @@ private:
|
||||
public:
|
||||
Fl_Wayland_Graphics_Driver();
|
||||
static const uint32_t wld_format;
|
||||
void activate(struct fl_wld_buffer *buffer, float scale);
|
||||
void set_buffer(struct fl_wld_buffer *buffer, float scale = 0);
|
||||
void set_color(Fl_Color i, unsigned c);
|
||||
void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen osrc, int srcx, int srcy);
|
||||
static struct fl_wld_buffer *create_shm_buffer(int width, int height);
|
||||
|
@ -113,7 +113,7 @@ void Fl_Wayland_Graphics_Driver::cairo_init(struct fl_wld_buffer *buffer, int wi
|
||||
cairo_set_source_rgba(buffer->cairo_, 1.0, 1.0, 1.0, 0.);
|
||||
cairo_paint(buffer->cairo_);
|
||||
cairo_set_source_rgba(buffer->cairo_, .0, .0, .0, 1.0); // Black default color
|
||||
buffer->pango_layout_ = pango_cairo_create_layout(buffer->cairo_);
|
||||
//buffer->pango_layout_ = pango_cairo_create_layout(buffer->cairo_);
|
||||
cairo_save(buffer->cairo_);
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ void Fl_Wayland_Graphics_Driver::buffer_release(struct wld_window *window)
|
||||
cairo_surface_t *surf = cairo_get_target(window->buffer->cairo_);
|
||||
cairo_destroy(window->buffer->cairo_);
|
||||
cairo_surface_destroy(surf);
|
||||
g_object_unref(window->buffer->pango_layout_);
|
||||
//g_object_unref(window->buffer->pango_layout_);
|
||||
free(window->buffer);
|
||||
window->buffer = NULL;
|
||||
}
|
||||
@ -142,21 +142,9 @@ Fl_Wayland_Graphics_Driver::Fl_Wayland_Graphics_Driver () : Fl_Cairo_Graphics_Dr
|
||||
}
|
||||
|
||||
|
||||
void Fl_Wayland_Graphics_Driver::activate(struct fl_wld_buffer *buffer, float scale) {
|
||||
if (dummy_cairo_) handle_dummy_cairo(buffer->cairo_);
|
||||
cairo_ = buffer->cairo_;
|
||||
if (pango_layout_ != buffer->pango_layout_) {
|
||||
if (pango_layout_) g_object_unref(pango_layout_);
|
||||
pango_layout_ = buffer->pango_layout_;
|
||||
g_object_ref(pango_layout_);
|
||||
Fl_Graphics_Driver::font(-1, -1); // signal that no font is current yet
|
||||
}
|
||||
void Fl_Wayland_Graphics_Driver::set_buffer(struct fl_wld_buffer *buffer, float scale) {
|
||||
this->buffer_ = buffer;
|
||||
cairo_restore(cairo_);
|
||||
cairo_save(cairo_);
|
||||
cairo_scale(cairo_, scale, scale);
|
||||
cairo_translate(cairo_, 0.5, 0.5);
|
||||
line_style(0);
|
||||
set_cairo(buffer->cairo_, scale);
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,7 +56,7 @@ Fl_Wayland_Image_Surface_Driver::~Fl_Wayland_Image_Surface_Driver() {
|
||||
|
||||
void Fl_Wayland_Image_Surface_Driver::set_current() {
|
||||
Fl_Surface_Device::set_current();
|
||||
((Fl_Wayland_Graphics_Driver*)fl_graphics_driver)->activate(offscreen, driver()->scale());
|
||||
((Fl_Wayland_Graphics_Driver*)fl_graphics_driver)->set_buffer(offscreen);
|
||||
pre_window = Fl_Wayland_Window_Driver::wld_window;
|
||||
fl_window = Fl_Wayland_Window_Driver::wld_window = NULL;
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ void Fl_Wayland_Window_Driver::make_current() {
|
||||
((Fl_Cairo_Graphics_Driver*)fl_graphics_driver)->needs_commit_tag(
|
||||
&window->buffer->draw_buffer_needs_commit);
|
||||
}
|
||||
((Fl_Wayland_Graphics_Driver*)fl_graphics_driver)->activate(window->buffer, scale);
|
||||
((Fl_Wayland_Graphics_Driver*)fl_graphics_driver)->set_buffer(window->buffer, scale);
|
||||
|
||||
#ifdef FLTK_HAVE_CAIROEXT
|
||||
// update the cairo_t context
|
||||
|
Loading…
Reference in New Issue
Block a user