diff options
author | Andrzej Hunt <andrzej.hunt@collabora.com> | 2014-05-16 09:08:41 +0100 |
---|---|---|
committer | Andrzej Hunt <andrzej.hunt@collabora.com> | 2014-06-25 13:04:28 +0100 |
commit | d6ee2be0ae0081d277133e3f86b4a7882a7d7d9f (patch) | |
tree | 5c4a61a924cb4d69e761bed001e1f80c4650e9d8 /desktop | |
parent | 0434043aed646ef853eb60dcb01909745caec87e (diff) |
Use bitmap buffers in the gtktiledviewer.
Looks pretty decent now -- however the vertical flipping isn't ideal.
Change-Id: I6ffa9d2b8fced142308781e06e8f161228f1db26
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/qa/gtktiledviewer/gtktiledviewer.cxx | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx index 6b66810ae3fd..fcaac63aa6f1 100644 --- a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx @@ -31,30 +31,24 @@ static int help() return 1; } +static GtkWidget* ourCanvas; -bool drawCallback(GtkWidget* pCanvas, void* /* cairo_t* cr */, gpointer pData) +bool drawCallback(GtkWidget* /* The eventbox */, void* /* cairo_t* cr */, gpointer pData) { fprintf(stderr, "attempting to draw tile"); Document* pDocument = static_cast< Document* >( pData ); - // This is UNX only for now, we need to get the appropriate equivalents - // for windows/mac (see SystemGraphicsData for what we need) - SystemGraphicsData aSystemGraphicsData; - aSystemGraphicsData.pDisplay = GDK_WINDOW_XDISPLAY( pCanvas->window ); - aSystemGraphicsData.hDrawable = GDK_WINDOW_XWINDOW( pCanvas->window ); - aSystemGraphicsData.pVisual = GDK_VISUAL_XVISUAL( gtk_widget_get_visual( pCanvas ) ); - aSystemGraphicsData.nScreen = GDK_SCREEN_XNUMBER( gtk_widget_get_screen( pCanvas ) ); - aSystemGraphicsData.nDepth = gdk_visual_get_depth( gtk_widget_get_visual( pCanvas ) ); - aSystemGraphicsData.aColormap = GDK_COLORMAP_XCOLORMAP( - gdk_screen_get_default_colormap( - gtk_widget_get_screen( pCanvas ) ) ); - aSystemGraphicsData.pXRenderFormat = XRenderFindVisualFormat( - GDK_WINDOW_XDISPLAY( pCanvas->window ), - GDK_VISUAL_XVISUAL( gtk_widget_get_visual( pCanvas ) ) ); - // Hardcoded tile just to see whether or not we get any sort of output. - pDocument->paintTile( 256, 256, 0, 0, 5000, 5000 ); + unsigned char* pBuffer = pDocument->paintTile( 1000, 1000, 0, 0, 10000, 10000 ); + + GdkPixbuf* pBixBuf = gdk_pixbuf_new_from_data( pBuffer, GDK_COLORSPACE_RGB, + false, 8, 1000, 1000, 3*1000, + 0, 0 ); + pBixBuf = gdk_pixbuf_flip( pBixBuf, false ); + gtk_image_set_from_pixbuf( GTK_IMAGE(ourCanvas), pBixBuf ); + + // TODO: we need to keep track of and cleanup these buffers etc. return true; } @@ -91,16 +85,22 @@ int main( int argc, char* argv[] ) GtkWidget* pScroller = gtk_scrolled_window_new( 0, 0 ); gtk_container_add( GTK_CONTAINER(pWindow), pScroller ); - GtkWidget* pCanvas = gtk_drawing_area_new(); - gtk_widget_set_size_request( pCanvas, 1000, 1000 ); - gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(pScroller), pCanvas ); + GtkWidget* pEventBox = gtk_event_box_new(); + gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(pScroller), pEventBox ); + + GtkWidget* pCanvas = gtk_image_new(); + ourCanvas = pCanvas; + gtk_container_add( GTK_CONTAINER( pEventBox ), pCanvas ); + - g_signal_connect( G_OBJECT(pCanvas), "expose_event", G_CALLBACK(drawCallback), pDocument); + g_signal_connect( G_OBJECT(pEventBox), "button-press-event", G_CALLBACK(drawCallback), pDocument); gtk_widget_show( pCanvas ); + gtk_widget_show( pEventBox ); gtk_widget_show( pScroller ); gtk_widget_show( pWindow ); + drawCallback( pCanvas, 0, pDocument ); gtk_main(); |