Rebased ref, commits from common ancestor: commit f6cb31b92951534711ffa501baba7b13e8f496bd Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Tue Jul 8 09:53:42 2014 +0200
gtktiledviewer: allow selecting between normal and quad-tile view. Change-Id: I85b22b93fe4ce2ffb62df8766ceea7a1bd8961ee diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index bc4ad09..3a232e8 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -14,6 +14,7 @@ #include <gtk/gtk.h> #include <LibreOfficeKit/LibreOfficeKitGtk.h> +#include "../lokdocview_quad/lokdocview_quad.h" static int help() { @@ -22,6 +23,10 @@ static int help() } static GtkWidget* pDocView; +static GtkWidget* pDocViewQuad; +static GtkWidget* pVBox; +static LibreOfficeKit* pOffice; +static char* pFileName; const float fZooms[] = { 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 3.0, 5.0 }; @@ -30,7 +35,17 @@ void changeZoom( GtkWidget* pButton, gpointer /* pItem */ ) const char *sName = gtk_tool_button_get_stock_id( GTK_TOOL_BUTTON(pButton) ); float fZoom = 0; - const float fCurrentZoom = lok_docview_get_zoom( LOK_DOCVIEW(pDocView) ); + float fCurrentZoom; + + if ( pDocView ) + { + fCurrentZoom = lok_docview_get_zoom( LOK_DOCVIEW(pDocView) ); + } + else if ( pDocViewQuad ) + { + fCurrentZoom = lok_docview_quad_get_zoom( LOK_DOCVIEW_QUAD(pDocView) ); + } + if ( strcmp(sName, "gtk-zoom-in") == 0) { for ( unsigned int i = 0; i < sizeof( fZooms ) / sizeof( fZooms[0] ); i++ ) @@ -63,10 +78,46 @@ void changeZoom( GtkWidget* pButton, gpointer /* pItem */ ) if ( fZoom != 0 ) { - lok_docview_set_zoom( LOK_DOCVIEW(pDocView), fZoom ); + if ( pDocView ) + { + lok_docview_set_zoom( LOK_DOCVIEW(pDocView), fZoom ); + } + else if ( pDocViewQuad ) + { + lok_docview_quad_set_zoom( LOK_DOCVIEW_QUAD(pDocViewQuad), fZoom ); + } } } +void changeQuadView( GtkWidget* /*pButton*/, gpointer /* pItem */ ) +{ + if ( pDocView ) + { + const float fCurrentZoom = lok_docview_get_zoom( LOK_DOCVIEW(pDocView) ); + gtk_widget_destroy( pDocView ); + pDocView = 0; + pDocViewQuad = lok_docview_quad_new( pOffice ); + gtk_container_add( GTK_CONTAINER(pVBox), pDocViewQuad ); + gtk_widget_show( pDocViewQuad ); + + lok_docview_quad_set_zoom( LOK_DOCVIEW_QUAD(pDocViewQuad), fCurrentZoom ); + lok_docview_quad_open_document( LOK_DOCVIEW_QUAD(pDocViewQuad), pFileName ); + } + else if ( pDocViewQuad ) + { + const float fCurrentZoom = lok_docview_quad_get_zoom( LOK_DOCVIEW_QUAD(pDocViewQuad) ); + gtk_widget_destroy( pDocViewQuad ); + pDocViewQuad = 0; + pDocView = lok_docview_new( pOffice ); + gtk_container_add( GTK_CONTAINER(pVBox), pDocView ); + gtk_widget_show( pDocView ); + + lok_docview_set_zoom( LOK_DOCVIEW(pDocView), fCurrentZoom ); + lok_docview_open_document( LOK_DOCVIEW(pDocView), pFileName ); + } +} + + int main( int argc, char* argv[] ) { if( argc < 2 || @@ -79,7 +130,7 @@ int main( int argc, char* argv[] ) return 1; } - LibreOfficeKit* pOffice = lok_init( argv[1] ); + pOffice = lok_init( argv[1] ); gtk_init( &argc, &argv ); @@ -88,7 +139,7 @@ int main( int argc, char* argv[] ) gtk_window_set_default_size(GTK_WINDOW(pWindow), 800, 600); g_signal_connect( pWindow, "destroy", G_CALLBACK(gtk_main_quit), NULL ); - GtkWidget* pVBox = gtk_vbox_new( FALSE, 0 ); + pVBox = gtk_vbox_new( FALSE, 0 ); gtk_container_add( GTK_CONTAINER(pWindow), pVBox ); // Toolbar @@ -111,17 +162,27 @@ int main( int argc, char* argv[] ) gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pZoomOut, -1); g_signal_connect( G_OBJECT(pZoomOut), "clicked", G_CALLBACK(changeZoom), NULL ); + GtkToolItem* pSeparator1 = gtk_separator_tool_item_new(); + gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pSeparator1, -1); + + GtkToolItem* pEnableQuadView = gtk_toggle_tool_button_new(); + gtk_tool_button_set_label( GTK_TOOL_BUTTON(pEnableQuadView), "Use Quad View" ); + gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pEnableQuadView, -1 ); + g_signal_connect( G_OBJECT(pEnableQuadView), "toggled", G_CALLBACK(changeQuadView), NULL ); + gtk_box_pack_start( GTK_BOX(pVBox), pToolbar, FALSE, FALSE, 0 ); // Adds to top. // Docview pDocView = lok_docview_new( pOffice ); + pDocViewQuad = 0; gtk_container_add( GTK_CONTAINER(pVBox), pDocView ); gtk_widget_show_all( pWindow ); + pFileName = argv[2]; lok_docview_open_document( LOK_DOCVIEW(pDocView), argv[2] ); gtk_main(); return 0; -} \ No newline at end of file +} commit be938f8ccac5332a719ed67d39f751b009d7d099 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Tue Jul 8 09:44:40 2014 +0200 Quad Docview: only rerender on zoom if we have a document open. Same as "LOK DocView: only rerender on zoom if we have a document open." but for our quad-tiled test widget. Change-Id: I6c1b946cc9d576d1dcc4687048339d9f0b3e6eff diff --git a/libreofficekit/qa/lokdocview_quad/lokdocview_quad.c b/libreofficekit/qa/lokdocview_quad/lokdocview_quad.c index cbff885..c920f1f 100644 --- a/libreofficekit/qa/lokdocview_quad/lokdocview_quad.c +++ b/libreofficekit/qa/lokdocview_quad/lokdocview_quad.c @@ -241,7 +241,10 @@ SAL_DLLPUBLIC_EXPORT gboolean lok_docview_quad_open_document( LOKDocViewQuad* pD SAL_DLLPUBLIC_EXPORT void lok_docview_quad_set_zoom ( LOKDocViewQuad* pDocView, float fZoom ) { pDocView->fZoom = fZoom; - renderDocument( pDocView ); + if ( pDocView->pDocument ) + { + renderDocument( pDocView ); + } // TODO: maybe remember and reset positiong? } commit 670419023852623fa49c098a8d1a673f9819e7ed Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Tue Jul 8 09:43:09 2014 +0200 LOK DocView: only rerender on zoom if we have a document open. Otherwise we would segfault, and it's perfectly valid to set a zoom level _before_ opening a document (as that would e.g. save the document first being rendered on opening if the client wants to immediately render at a non-standard zoom level). Change-Id: Ide261b09f4aab8dc3b552f6c3bf55f78ffd7870c diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c index f813e68..12b004e08 100644 --- a/libreofficekit/source/gtk/lokdocview.c +++ b/libreofficekit/source/gtk/lokdocview.c @@ -161,7 +161,11 @@ SAL_DLLPUBLIC_EXPORT gboolean lok_docview_open_document( LOKDocView* pDocView, c SAL_DLLPUBLIC_EXPORT void lok_docview_set_zoom ( LOKDocView* pDocView, float fZoom ) { pDocView->fZoom = fZoom; - renderDocument( pDocView ); + + if ( pDocView->pDocument ) + { + renderDocument( pDocView ); + } // TODO: maybe remember and reset positiong? } commit 140a186f2f93233a6830580346b3873e8bcd0e51 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Tue Jul 8 08:54:13 2014 +0200 Implement a (qa-only) quad-tiled viewer. I.e. we subdivide the document into 4 tiles: one at 100% scaling, one at 200%, one at 50%, one at 25% -- these are then post-scaled in gdk) and assembled to show as one document again. This is specifically a test only widget, primarily to be able to quickly spot any tile positioning/border-transition issues. We could theoretically make this widget inherit from the original widget, however that would mean having to introduce virtual methods etc., which is not something that we'd want in production -- in the longer run that widget will hopefully be extended to have proper tile composition etc., which would then break this widget too if it were inheriting from there. Change-Id: Ib880a1614f89724135e753013cf91aec25973e39 diff --git a/libreofficekit/Executable_gtktiledviewer.mk b/libreofficekit/Executable_gtktiledviewer.mk index 0ce9222..d4ef643 100644 --- a/libreofficekit/Executable_gtktiledviewer.mk +++ b/libreofficekit/Executable_gtktiledviewer.mk @@ -42,6 +42,10 @@ $(eval $(call gb_Executable_add_libs,gtktiledviewer,\ )) endif +$(eval $(call gb_Executable_add_cobjects,gtktiledviewer,\ + libreofficekit/qa/lokdocview_quad/lokdocview_quad \ +)) + $(eval $(call gb_Executable_add_exception_objects,gtktiledviewer,\ libreofficekit/qa/gtktiledviewer/gtktiledviewer \ )) diff --git a/libreofficekit/qa/lokdocview_quad/lokdocview_quad.c b/libreofficekit/qa/lokdocview_quad/lokdocview_quad.c new file mode 100644 index 0000000..cbff885 --- /dev/null +++ b/libreofficekit/qa/lokdocview_quad/lokdocview_quad.c @@ -0,0 +1,253 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <sal/types.h> + +#define LOK_USE_UNSTABLE_API +#include <LibreOfficeKit/LibreOfficeKit.h> + +#include "lokdocview_quad.h" + +static void lok_docview_quad_class_init( LOKDocViewQuadClass* pClass ); +static void lok_docview_quad_init( LOKDocViewQuad* pDocView ); + +// We specifically need to destroy the document when closing in order to ensure +// that lock files etc. are cleaned up. +void lcl_onDestroy( LOKDocViewQuad* pDocView, gpointer pData ) +{ + (void) pData; + if ( pDocView->pDocument ) + pDocView->pDocument->pClass->destroy( pDocView->pDocument ); + pDocView->pDocument = NULL; +} + +SAL_DLLPUBLIC_EXPORT guint lok_docview_quad_get_type() +{ + static guint lok_docview_quad_type = 0; + + if (!lok_docview_quad_type) + { + GtkTypeInfo lok_docview_quad_info = + { + "LokDocViewQuad", + sizeof( LOKDocViewQuad ), + sizeof( LOKDocViewQuadClass ), + (GtkClassInitFunc) lok_docview_quad_class_init, + (GtkObjectInitFunc) lok_docview_quad_init, + NULL, + NULL, + (GtkClassInitFunc) NULL + }; + + lok_docview_quad_type = gtk_type_unique( gtk_scrolled_window_get_type(), &lok_docview_quad_info ); + } + return lok_docview_quad_type; +} + +static void lok_docview_quad_class_init( LOKDocViewQuadClass* pClass ) +{ + pClass->lok_docview_quad = NULL; +} + +static void lok_docview_quad_init( LOKDocViewQuad* pDocView ) +{ + int x, y; + + // Gtk ScrolledWindow is apparently not fully initialised yet, we specifically + // have to set the [hv]adjustment to prevent GTK assertions from firing, see + // https://bugzilla.gnome.org/show_bug.cgi?id=438114 for more info. + gtk_scrolled_window_set_hadjustment( GTK_SCROLLED_WINDOW( pDocView ), NULL ); + gtk_scrolled_window_set_vadjustment( GTK_SCROLLED_WINDOW( pDocView ), NULL ); + + pDocView->pEventBox = gtk_event_box_new(); + gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(pDocView), + pDocView->pEventBox ); + + pDocView->pGrid = gtk_table_new( 2, 2, TRUE ); + gtk_container_add( GTK_CONTAINER( pDocView->pEventBox ), pDocView->pGrid ); + + for ( x = 0; x < 2; x++ ) + { + for ( y = 0; y < 2; y++ ) + { + pDocView->pCanvas[x][y] = gtk_image_new(); + gtk_table_attach_defaults( GTK_TABLE( pDocView->pGrid ), pDocView->pCanvas[x][y], x, x+1, y, y+1 ); + //gtk_container_add( GTK_CONTAINER( pDocView->pEventBox ), pDocView->pCanvas ); + gtk_widget_show( pDocView->pCanvas[x][y] ); + + pDocView->pPixBuf[x][y] = 0; + } + } + + gtk_widget_show( pDocView->pGrid ); + gtk_widget_show( pDocView->pEventBox ); + + // TODO: figure out a clever view of getting paths set up. + pDocView->pOffice = 0; + pDocView->pDocument = 0; + + pDocView->fZoom = 1; + + gtk_signal_connect( GTK_OBJECT(pDocView), "destroy", + GTK_SIGNAL_FUNC(lcl_onDestroy), NULL ); +} + +SAL_DLLPUBLIC_EXPORT GtkWidget* lok_docview_quad_new( LibreOfficeKit* pOffice ) +{ + LOKDocViewQuad* pDocView = gtk_type_new( lok_docview_quad_get_type() ); + pDocView->pOffice = pOffice; + return GTK_WIDGET( pDocView ); +} + +void renderDocument( LOKDocViewQuad* pDocView ) +{ + long nWidth, nHeight; + int nRenderWidth, nRenderHeight; + int nRowStride; + int x, y; + GdkPixbuf* pTempBuf; + + g_assert( pDocView->pDocument ); + + for ( x = 0; x < 2; x++ ) + { + for ( y = 0; y < 2; y++ ) + { + if ( pDocView->pPixBuf[x][y] ) + { + g_object_unref( G_OBJECT( pDocView->pPixBuf[x][y] ) ); + } + } + } + + pDocView->pDocument->pClass->getDocumentSize( pDocView->pDocument, &nWidth, &nHeight ); + + // Draw the whole document at once (for now) + + // TODO: we really should scale by screen DPI here -- 10 seems to be a vaguely + // correct factor for my screen at least. + nRenderWidth = nWidth * pDocView->fZoom / 10; + nRenderHeight = nHeight * pDocView->fZoom / 10; + + // TOP-LEFT: standard + // TOP-RIGHT: 2x resolution rendered (post-scaled to 50%) + // BOTTOM-LEFT: 1/2 resolution rendered (post-scaled 200%) + // BOTTOM-RIGHT: 1/2 resolution rendered (post-scaled 400%) + pDocView->pPixBuf[0][0] = gdk_pixbuf_new( GDK_COLORSPACE_RGB, + TRUE, 8, + nRenderWidth / 2, nRenderHeight / 2 ); + pDocView->pDocument->pClass->paintTile( pDocView->pDocument, + gdk_pixbuf_get_pixels( pDocView->pPixBuf[0][0] ), + nRenderWidth / 2, nRenderHeight / 2, + &nRowStride, + 0, 0, // origin + nWidth / 2, nHeight / 2 ); + + pDocView->pPixBuf[1][0] = gdk_pixbuf_new( GDK_COLORSPACE_RGB, + TRUE, 8, + nRenderWidth, nRenderHeight ); + pDocView->pDocument->pClass->paintTile( pDocView->pDocument, + gdk_pixbuf_get_pixels( pDocView->pPixBuf[1][0] ), + nRenderWidth, nRenderHeight, + &nRowStride, + nWidth / 2, 0, + nWidth / 2, nHeight / 2 ); + pTempBuf = gdk_pixbuf_scale_simple( GDK_PIXBUF( pDocView->pPixBuf[1][0] ), + nRenderWidth / 2, + nRenderHeight / 2, + GDK_INTERP_BILINEAR ); + g_object_unref( G_OBJECT( pDocView->pPixBuf[1][0] ) ); + pDocView->pPixBuf[1][0] = pTempBuf; + + + pDocView->pPixBuf[0][1] = gdk_pixbuf_new( GDK_COLORSPACE_RGB, + TRUE, 8, + nRenderWidth / 4, nRenderHeight / 4 ); + pDocView->pDocument->pClass->paintTile( pDocView->pDocument, + gdk_pixbuf_get_pixels( pDocView->pPixBuf[0][1] ), + nRenderWidth / 4, nRenderHeight / 4, + &nRowStride, + 0, nHeight / 2, + nWidth / 2, nHeight / 2 ); + pTempBuf = gdk_pixbuf_scale_simple( GDK_PIXBUF( pDocView->pPixBuf[0][1] ), + nRenderWidth / 2, + nRenderHeight / 2, + GDK_INTERP_BILINEAR ); + g_object_unref( G_OBJECT( pDocView->pPixBuf[0][1] ) ); + pDocView->pPixBuf[0][1] = pTempBuf; + + pDocView->pPixBuf[1][1] = gdk_pixbuf_new( GDK_COLORSPACE_RGB, + TRUE, 8, + nRenderWidth / 8, nRenderHeight / 8 ); + pDocView->pDocument->pClass->paintTile( pDocView->pDocument, + gdk_pixbuf_get_pixels( pDocView->pPixBuf[1][1] ), + nRenderWidth / 8, nRenderHeight / 8, + &nRowStride, + nWidth / 2, nHeight / 2, + nWidth / 2, nHeight / 2 ); + pTempBuf = gdk_pixbuf_scale_simple( GDK_PIXBUF( pDocView->pPixBuf[1][1] ), + nRenderWidth / 2, + nRenderHeight / 2, + GDK_INTERP_BILINEAR ); + g_object_unref( G_OBJECT( pDocView->pPixBuf[1][1] ) ); + pDocView->pPixBuf[1][1] = pTempBuf; + + + + // TODO: double check that the rowstride really matches what we expected, + // although presumably we'd already be crashing by now if things were + // wrong. + (void) nRowStride; + + // gtk_image_set_from_pixbuf( GTK_IMAGE( pDocView->pCanvas ), pDocView->pPixBuf ); + for ( x = 0; x < 2; x++ ) + { + for ( y = 0; y < 2; y++ ) + { + gtk_image_set_from_pixbuf( GTK_IMAGE( pDocView->pCanvas[x][y] ), pDocView->pPixBuf[x][y] ); + } + } +} + +SAL_DLLPUBLIC_EXPORT gboolean lok_docview_quad_open_document( LOKDocViewQuad* pDocView, char* pPath ) +{ + if ( pDocView->pDocument ) + { + pDocView->pDocument->pClass->destroy( pDocView->pDocument ); + pDocView->pDocument = NULL; + } + + pDocView->pDocument = pDocView->pOffice->pClass->documentLoad( pDocView->pOffice, + pPath ); + if ( !pDocView->pDocument ) + { + // FIXME: should have a GError parameter and populate it. + char *pError = pDocView->pOffice->pClass->getError( pDocView->pOffice ); + fprintf( stderr, "Error opening document '%s'\n", pError ); + return FALSE; + } + else + renderDocument( pDocView ); + + return TRUE; +} + +SAL_DLLPUBLIC_EXPORT void lok_docview_quad_set_zoom ( LOKDocViewQuad* pDocView, float fZoom ) +{ + pDocView->fZoom = fZoom; + renderDocument( pDocView ); + // TODO: maybe remember and reset positiong? +} + +SAL_DLLPUBLIC_EXPORT float lok_docview_quad_get_zoom ( LOKDocViewQuad* pDocView ) +{ + return pDocView->fZoom; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/libreofficekit/qa/lokdocview_quad/lokdocview_quad.h b/libreofficekit/qa/lokdocview_quad/lokdocview_quad.h new file mode 100644 index 0000000..3124e5f --- /dev/null +++ b/libreofficekit/qa/lokdocview_quad/lokdocview_quad.h @@ -0,0 +1,66 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_LOK_QA_INC_LIBREOFFICEKITGTK_H +#define INCLUDED_LOK_QA_INC_LIBREOFFICEKITGTK_H + +#include <gtk/gtk.h> +#include <gdk/gdk.h> + +#define LOK_USE_UNSTABLE_API +#include <LibreOfficeKit/LibreOfficeKit.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define LOK_DOCVIEW_QUAD(obj) GTK_CHECK_CAST (obj, lok_docview_quad_get_type(), LOKDocViewQuad) +#define LOK_DOCVIEW_QUAD_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, lok_docview_quad_get_type(), LOKDocViewQuadClass) +#define IS_LOK_DOCVIEW_QUAD(obj) GTK_CHECK_TYPE (obj, lok_docview_quad_get_type()) + + +typedef struct _LOKDocViewQuad LOKDocViewQuad; +typedef struct _LOKDocViewQuadClass LOKDocViewQuadClass; + +struct _LOKDocViewQuad +{ + GtkScrolledWindow scrollWindow; + + GtkWidget* pEventBox; + GtkWidget* pGrid; + GtkWidget* pCanvas[2][2]; + GdkPixbuf* pPixBuf[2][2]; + + float fZoom; + + LibreOfficeKit* pOffice; + LibreOfficeKitDocument* pDocument; +}; + +struct _LOKDocViewQuadClass +{ + GtkScrolledWindowClass parent_class; + + void (*lok_docview_quad) (LOKDocViewQuad* pDocView); +}; + +guint lok_docview_quad_get_type (void); +GtkWidget* lok_docview_quad_new ( LibreOfficeKit* pOffice ); +gboolean lok_docview_quad_open_document (LOKDocViewQuad* pDocView, + char* pPath); +void lok_docview_quad_set_zoom (LOKDocViewQuad* pDocView, + float fZoom); +float lok_docview_quad_get_zoom (LOKDocViewQuad* pDocView); + +#ifdef __cplusplus +} +#endif + +#endif commit 590884355e47f302f139e24bdac08d9b5dcaa33f Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Mon Jul 7 10:10:17 2014 +0200 Rectangle width doesn't map to B2IBox. Previously the clip region would end up being 1 pixel smaller in both directions than the requested area -- B2IBox considers the bottom-right point to NOT be included in its area, whereas Rectangle considers the bottom-right point to be the last point WITHIN its area. (This is equivalent to the Rectangle's getWidth/GetWidth differentiation.) This is noticeable e.g. with tiled rendering, where images spanning a tile boundary are clipped to paint only the region within a given tile -- however previously they would be clipped by an additional pixel in each direciton, resulting in an empty border along the bottom-right edge. Change-Id: I0ef3098959defc5c82719155c130aa904c04b6b1 diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index de7d3ad..35c582d 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -301,7 +301,7 @@ bool SvpSalGraphics::setClipRegion( const Region& i_rClip ) const Rectangle& aBoundRect = aRectangles[0]; m_aDevice = basebmp::subsetBitmapDevice( m_aOrigDevice, - basegfx::B2IBox(aBoundRect.Left(),aBoundRect.Top(),aBoundRect.Right(),aBoundRect.Bottom()) ); + basegfx::B2IBox(aBoundRect.Left(),aBoundRect.Top(),aBoundRect.Right() + 1,aBoundRect.Bottom() + 1) ); m_bClipSetup = true; } commit 8c84f4988ef16d0936d89ebd8abaae5b9c8d4761 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Thu Jul 3 14:47:15 2014 +0200 Iterate from origin to tile area to ensure correct positioning. Change-Id: I29e881f9e67b84e208a198d2aad06db382d14698 diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 34e085b..028c114 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -341,8 +341,16 @@ void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev ) bIsInPaint = true; - SCCOL nX1 = pViewData->GetPosX(eHWhich); - SCROW nY1 = pViewData->GetPosY(eVWhich); + // If we're doing tiled rendering we'll have a different output device here, + // and we could really be at a completely random position, hence we + // iterate from 0. + SCCOL nX1 = 0; + SCROW nY1 = 0; + if ( pOutDev == this ) + { + nX1 = pViewData->GetPosX(eHWhich); + nY1 = pViewData->GetPosY(eVWhich); + } SCTAB nTab = pViewData->GetTabNo(); @@ -381,6 +389,14 @@ void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev ) nScrY += pDoc->GetRowHeight( nY2, nTab ); } + // Bit hacky -- but Draw starts drawing with nX1/nY1 being at + // the output devices origin, so we make sure we start drawing + // with cell A1 at the origin etc. + if ( pOutDev != this ) + { + nX1 = 0; + nY1 = 0; + } // We specifically need to set the visible range here -- by default it is // set in UpdateVisibleRange which however uses the viewdata, which is // completely irrelevant for tiled rendering. commit e6e0634ed6a2c61412f167d0a8507abf03b26cd4 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Thu Jul 3 14:46:32 2014 +0200 Use logic units for visible-cells determination. This eliminates a bunch of LogicToPixel conversions, and also means that tiles starting other than the origin are correctly processed (as LogicToPixel run on a rectangle will also move that rectangle depending on the origin set in the output device). Change-Id: I42903fe23ad5f6baa1d5276d5dcc7ee038bd27cf diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index e752559..34e085b 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -341,46 +341,44 @@ void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev ) bIsInPaint = true; - Rectangle aPixRect = pOutDev->LogicToPixel( rRect ); - SCCOL nX1 = pViewData->GetPosX(eHWhich); SCROW nY1 = pViewData->GetPosY(eVWhich); SCTAB nTab = pViewData->GetTabNo(); - Rectangle aMirroredPixel = aPixRect; + Rectangle aMirroredRect = rRect; if ( pDoc->IsLayoutRTL( nTab ) ) { // mirror and swap - long nWidth = GetSizePixel().Width(); - aMirroredPixel.Left() = nWidth - 1 - aPixRect.Right(); - aMirroredPixel.Right() = nWidth - 1 - aPixRect.Left(); + long nWidth = PixelToLogic(GetSizePixel()).Width(); + aMirroredRect.Left() = nWidth - 1 - rRect.Right(); + aMirroredRect.Right() = nWidth - 1 - rRect.Left(); } - long nScrX = pOutDev->LogicToPixel( Point( pDoc->GetColWidth( nX1, nTab ), 0 ) ).getX();/*ScViewData::ToPixel( pDoc->GetColWidth( nX1, nTab ), nPPTX );*/ - while ( nScrX <= aMirroredPixel.Left() && nX1 < MAXCOL ) + long nScrX = pDoc->GetColWidth( nX1, nTab ); + while ( nScrX <= aMirroredRect.Left() && nX1 < MAXCOL ) { ++nX1; - nScrX += pOutDev->LogicToPixel( Point( pDoc->GetColWidth( nX1, nTab ), 0 ) ).getX(); + nScrX += pDoc->GetColWidth( nX1, nTab ); } SCCOL nX2 = nX1; - while ( nScrX <= aMirroredPixel.Right() && nX2 < MAXCOL ) + while ( nScrX <= aMirroredRect.Right() && nX2 < MAXCOL ) { ++nX2; - nScrX += pOutDev->LogicToPixel( Point( pDoc->GetColWidth( nX2, nTab ), 0 ) ).getX(); + nScrX += pDoc->GetColWidth( nX2, nTab ); } long nScrY = 0; - while ( nScrY < aPixRect.Top() && nY1 < MAXROW ) + while ( nScrY < rRect.Top() && nY1 < MAXROW ) { ++nY1; - nScrY += pOutDev->LogicToPixel( Point( 0, pDoc->GetRowHeight( nY1, nTab ) ) ).getY(); + nScrY += pDoc->GetRowHeight( nY1, nTab ); } SCROW nY2 = nY1; - while ( nScrY <= aPixRect.Bottom() && nY2 < MAXROW ) + while ( nScrY <= rRect.Bottom() && nY2 < MAXROW ) { ++nY2; - nScrY += pOutDev->LogicToPixel( Point( 0, pDoc->GetRowHeight( nY2, nTab ) ) ).getY(); + nScrY += pDoc->GetRowHeight( nY2, nTab ); } // We specifically need to set the visible range here -- by default it is commit 67c0410b69ccdc33eda670d0e627874ecf975871 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Thu Jul 3 14:43:28 2014 +0200 Scale the origin for the Draw Layer (Calc Tiled Rendering). Since we're changing units, we also need to scale the origin by the correct amount. Change-Id: Ie0563376e8fa56f20c30da4fe3cc50546f18e84f diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index a0ba523..e752559 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -623,7 +623,9 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod // define drawing layer map mode and paint rectangle MapMode aDrawMode = pOutDev->GetMapMode(); + Point aOrigin = aDrawMode.GetOrigin(); aDrawMode.SetMapUnit( MAP_100TH_MM ); + aDrawMode.SetOrigin( (aOrigin * 2540l) / 1440l ); Rectangle aDrawingRectLogic; { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits