first test of internal double buffer ==> display is bad...

This commit is contained in:
Edouard Dupin 2011-09-20 18:27:11 +02:00
parent 74cfca4516
commit 3dad4f219b
4 changed files with 88 additions and 30 deletions

View File

@ -65,6 +65,9 @@ CodeView::CodeView(void) : MsgBroadcast("Code View", EDN_CAT_WORK_AREA)
# elif defined( USE_GTK_VERSION_2_0 )
GTK_WIDGET_SET_FLAGS(m_widget, GTK_CAN_FOCUS);
# endif
// Remove double-buffering ==> in the current case we can not get the previous display...
gtk_widget_set_double_buffered(m_widget, false);
// Focus Event
g_signal_connect( G_OBJECT(m_widget), "focus_in_event", G_CALLBACK(CB_focusGet), this);
g_signal_connect( G_OBJECT(m_widget), "focus_out_event", G_CALLBACK(CB_focusLost), this);
@ -189,8 +192,6 @@ void CodeView::OnMessage(int32_t id, int32_t dataID)
break;
}
// Force redraw of the widget
// gtk_widget_queue_draw(m_widget);
gtk_widget_queue_draw_area(m_widget, 0, 0, m_shawableAreaX, m_shawableAreaY);
}
@ -237,6 +238,12 @@ gboolean CodeView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpo
DrawerManager monDrawer(widget, self->m_shawableAreaX, self->m_shawableAreaY);
Buffer * tmpBuf = self->m_bufferManager->Get(self->m_bufferID);
// set cursor :
/*
GdkCursor plop;
plop.GSEAL = GDK_PENCIL;
gdk_window_set_cursor(gtk_widget_get_window(self->m_widget), &plop);
*/
#ifdef COUNT_TIME
GTimeVal timeStart;
g_get_current_time(&timeStart);

View File

@ -54,6 +54,7 @@ class CodeView : public MsgBroadcast
private:
// main windows widget :
GtkWidget * m_widget;
DrawerManager * m_Drawer;
int32_t m_displayUniqueId;
//position_ts m_displayStart; //!< position where the display is starting
//position_ts m_displaySize; //!< number of char displayable in the screan

View File

@ -127,6 +127,7 @@ cairo_font_face_t * Display::GetFont(bool bold, bool italic)
#undef __class__
#define __class__ "DrawerManager"
#define megaplop mlkjmlk
/**
* @brief DrawerManager constructor : generate a memoryDC where we can draw everything...
*
@ -141,26 +142,67 @@ cairo_font_face_t * Display::GetFont(bool bold, bool italic)
*/
DrawerManager::DrawerManager(GtkWidget * widget, int32_t x, int32_t y)
{
m_size.x = x;
m_size.y = y;
m_haveWork = false;
// Create the Cairo Element
# if USE_GTK_VERSION_3_0
m_cairo = gdk_cairo_create(gtk_widget_get_window(widget));
m_windows = gtk_widget_get_window(widget);
# elif USE_GTK_VERSION_2_0
m_cairo = gdk_cairo_create(widget->window);
m_windows = widget->window;
# endif
//cairo_translate(m_cairo, 0, 7);
cairo_set_source_rgb(m_cairo, 0, 0, 0);
#ifdef megaplop
m_cairoWindows = gdk_cairo_create(m_windows);
// create internal surface :
m_imageSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, x, y);
m_cairo = cairo_create(m_imageSurface);
// copy current windows :
cairo_surface_t * drawable_surface = cairo_get_target(m_cairoWindows);
cairo_set_source_surface(m_cairo, drawable_surface, 0, 0);
cairo_paint(m_cairo);
// for Test only : this remove slowly the old line that is not rewritten
cairo_set_source_rgb(m_cairo, 0, 0, 0);
cairo_set_source_rgba(m_cairo, 1, 1, 1, 0.3);
cairo_paint(m_cairo);
cairo_set_font_size(m_cairo, POLICE_SIZE);
m_dataToDisplay[0] = '\0';
cairo_scale(m_cairo, 1.0, 1.0);
cairo_scale(m_cairoWindows, 1.0, 1.0);
#else
// start painting : we not use the automatic double buffered for internal optimisation, then we nee to work with this :
/*
GdkRectangle myRect = {0, 0, 300, 300};
gdk_window_begin_paint_rect(m_windows, &myRect);
*/
// Create the Cairo Element
m_cairo = gdk_cairo_create(m_windows);
//cairo_translate(m_cairo, 0, 7);
// for Test only : this remove slowly the old line that is not rewritten
cairo_set_source_rgb(m_cairo, 0, 0, 0);
cairo_set_source_rgba(m_cairo, 1, 1, 1, 0.3);
cairo_paint(m_cairo);
cairo_set_font_size(m_cairo, POLICE_SIZE);
m_dataToDisplay[0] = '\0';
cairo_scale(m_cairo, 1.0, 1.0);
#endif
m_nbElement = 0;
// http://cairographics.org/FAQ/#clear_a_surface
// http://gtk.developpez.com/faq/?page=gtkwidget#GTK_WIDGET_transparent
//cairo_set_source_rgba(m_cairo, 1, 1, 1, 0);
@ -168,10 +210,6 @@ DrawerManager::DrawerManager(GtkWidget * widget, int32_t x, int32_t y)
//cairo_paint(m_cairo);
//cairo_fill(m_cairo);
//cairo_stroke (m_cairo);
}
@ -187,7 +225,16 @@ DrawerManager::DrawerManager(GtkWidget * widget, int32_t x, int32_t y)
*/
DrawerManager::~DrawerManager()
{
#ifdef megaplop
cairo_set_source_surface(m_cairoWindows, m_imageSurface, 0, 0);
cairo_paint(m_cairoWindows);
cairo_destroy(m_cairo);
cairo_destroy(m_cairoWindows);
#else
// fill the diplayed buffer ...
//gdk_window_end_paint(m_windows);
cairo_destroy(m_cairo);
#endif
}
@ -432,6 +479,7 @@ void DrawerManager::Cursor(int32_t x, int32_t y)
cairo_rel_line_to(m_cairo, 0, -letterHeight);
}
cairo_stroke(m_cairo);
//cairo_set_fill_rule(m_cairo, CAIRO_FILL_RULE_EVEN_ODD);
cairo_fill(m_cairo);
}

View File

@ -85,7 +85,9 @@ class DrawerManager {
position_ts m_size; //!< Total size
cairo_t * m_cairo; //!< Cairo Layout pointer
GdkWindow * m_windows; //!< remember the current widget ==> for some internal problems
cairo_t * m_cairoWindows; //!< Cairo context
cairo_surface_t *m_imageSurface;
};