Create Fl_Cairo_Graphics_Driver::handle_dummy_cairo(cairo_t *cr).
This commit is contained in:
parent
8e21120f75
commit
285e8e843a
@ -41,10 +41,11 @@ class FL_EXPORT Fl_Cairo_Graphics_Driver : public Fl_Graphics_Driver {
|
||||
private:
|
||||
bool *needs_commit_tag_; // NULL or points to whether cairo surface was drawn to
|
||||
protected:
|
||||
PangoLayout *dummy_pango_layout_; // used to measure text width before showing a window
|
||||
cairo_t *dummy_cairo_; // used to measure text width before showing a window
|
||||
cairo_t *cairo_;
|
||||
PangoLayout *pango_layout_;
|
||||
int linestyle_;
|
||||
void handle_dummy_cairo(cairo_t *);
|
||||
public:
|
||||
Fl_Cairo_Graphics_Driver();
|
||||
virtual ~Fl_Cairo_Graphics_Driver();
|
||||
|
@ -69,7 +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;
|
||||
dummy_pango_layout_ = NULL;
|
||||
dummy_cairo_ = NULL;
|
||||
linestyle_ = FL_SOLID;
|
||||
clip_ = NULL;
|
||||
scale_x = scale_y = 1;
|
||||
@ -85,6 +85,15 @@ 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::rectf(int x, int y, int w, int h) {
|
||||
cairo_rectangle(cairo_, x-0.5, y-0.5, w, h);
|
||||
cairo_fill(cairo_);
|
||||
@ -1078,8 +1087,10 @@ void Fl_Cairo_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize s) {
|
||||
cairo_surface_t *surf = cairo_image_surface_create(Fl_Cairo_Graphics_Driver::cairo_format, 100, 100);
|
||||
cairo_ = cairo_create(surf);
|
||||
}
|
||||
pango_layout_ = pango_cairo_create_layout(cairo_);
|
||||
if (needs_dummy) dummy_pango_layout_ = pango_layout_;
|
||||
pango_layout_ = pango_cairo_create_layout(cairo_); // 1.10
|
||||
if (needs_dummy) {
|
||||
dummy_cairo_ = cairo_;
|
||||
}
|
||||
}
|
||||
if (s == 0) return;
|
||||
if (font() == fnum && size() == s) return;
|
||||
|
@ -143,14 +143,7 @@ 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_pango_layout_) {
|
||||
cairo_surface_t *surf = cairo_get_target(cairo_);
|
||||
cairo_destroy(cairo_);
|
||||
cairo_surface_destroy(surf);
|
||||
g_object_unref(dummy_pango_layout_);
|
||||
dummy_pango_layout_ = NULL;
|
||||
pango_layout_ = NULL;
|
||||
}
|
||||
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_);
|
||||
|
@ -47,6 +47,7 @@ Fl_Wayland_Image_Surface_Driver::Fl_Wayland_Image_Surface_Driver(int w, int h, i
|
||||
|
||||
Fl_Wayland_Image_Surface_Driver::~Fl_Wayland_Image_Surface_Driver() {
|
||||
if (offscreen && !external_offscreen) {
|
||||
cairo_destroy(offscreen->cairo_);
|
||||
free(offscreen->draw_buffer);
|
||||
free(offscreen);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user