internal doubleBuffer with re-copy ==> OK

This commit is contained in:
2011-09-22 15:01:49 +02:00
parent 3dad4f219b
commit d3efb637ab
4 changed files with 349 additions and 69 deletions

View File

@@ -127,7 +127,7 @@ cairo_font_face_t * Display::GetFont(bool bold, bool italic)
#undef __class__
#define __class__ "DrawerManager"
#define megaplop mlkjmlk
//#define megaplop mlkjmlk
/**
* @brief DrawerManager constructor : generate a memoryDC where we can draw everything...
*
@@ -151,42 +151,25 @@ DrawerManager::DrawerManager(GtkWidget * widget, int32_t x, int32_t y)
m_windows = widget->window;
# endif
#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';
// Double buffer with previous copy management :
{
// Create the Cairo context from the current windows
cairo_t * cairoWindows = gdk_cairo_create(m_windows);
// inform that we nee a double buffer
GdkRectangle myRect = {0, 0, x, y};
gdk_window_begin_paint_rect(m_windows, &myRect);
// Create the Cairo context from the double Buffer just created
m_cairo = gdk_cairo_create(m_windows);
// Copy the previous display data from the current display to the double buffer area:
cairo_surface_t * drawableSurface = cairo_get_target(cairoWindows);
cairo_set_source_surface(m_cairo, drawableSurface, 0, 0);
cairo_paint(m_cairo);
//cairo_surface_destroy(drawableSurface);
cairo_destroy(cairoWindows);
}
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);
@@ -195,14 +178,8 @@ DrawerManager::DrawerManager(GtkWidget * widget, int32_t x, int32_t y)
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);
@@ -225,16 +202,10 @@ 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);
// call the painting of the double buffer in the displayed current buffer
gdk_window_end_paint(m_windows);
// Destroy cairo context
cairo_destroy(m_cairo);
cairo_destroy(m_cairoWindows);
#else
// fill the diplayed buffer ...
//gdk_window_end_paint(m_windows);
cairo_destroy(m_cairo);
#endif
}

View File

@@ -86,8 +86,6 @@ 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;
};