[Libreoffice-commits] core.git: Branch 'feature/gtkbmptiledviewer2' - 237 commits - accessibility/source avmedia/Library_avmedia.mk avmedia/source basctl/source basic/source bin/distro-install-desktop-integration chart2/qa chart2/source comphelper/source compilerplugins/clang config_host/config_features.h.in configure.ac connectivity/source cppcanvas/CppunitTest_cppcanvas_emfplus.mk cppcanvas/CppunitTest_cppcanvas_test.mk cui/source dbaccess/source desktop/Library_sofficeapp.mk desktop/source desktop/uiconfig desktop/UIConfig_deployment.mk drawinglayer/source editeng/source extensions/AllLangResTarget_scn.mk extensions/Module_extensions.mk extensions/source extensions/uiconfig extensions/UIConfig_scanner.mk external/collada2gltf external/libgltf extras/source filter/source forms/source formula/source fpicker/source framework/source helpcontent2 i18nlangtag/source i18npool/source idl/source include/avmedia include/basebmp include/editeng include/formula include/LibreOfficeKit include/sfx2 include/ svl include/svx include/vcl l10ntools/inc l10ntools/source libreofficekit/Executable_gtktiledviewer.mk libreofficekit/Library_libreofficekitgtk.mk libreofficekit/Library_libreofficekit.mk libreofficekit/Module_libreofficekit.mk libreofficekit/qa libreofficekit/source libreofficekit/StaticLibrary_libreofficekit.mk lotuswordpro/source officecfg/CustomTarget_registry.mk oovbaapi/ooo oox/source postprocess/CppunitTest_services.mk postprocess/Module_postprocess.mk postprocess/qa readlicense_oo/license reportdesign/source Repository.mk sal/osl sal/qa sax/source sc/inc scp2/AutoInstall.mk scp2/source sc/qa sc/source sc/uiconfig sdext/source sd/inc sd/qa sd/source sfx2/source slideshow/source smoketest/libtest.cxx solenv/gbuild starmath/source store/source svgio/source svl/source svtools/source svx/source sw/inc sw/qa sw/source sw/uiconfig sw/UIConfig_swriter.mk sysui/desktop test/Library_subsequenttest.mk test/Library_test.mk toolkit/source ucb/source unotest/source uui/source vcl/generic vcl/headless vcl/inc vcl/osx vcl/source vcl/unx writerfilter/CustomTarget_source.mk writerfilter/source xmloff/CppunitTest_xmloff_uxmloff.mk xmloff/Library_xo.mk xmloff/source
Andrzej Hunt
andrzej.hunt at collabora.com
Sat Jun 14 03:21:10 PDT 2014
Rebased ref, commits from common ancestor:
commit 4a57eb42f86f1fead35f0c1a984c836d004d65a6
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 13 17:32:44 2014 +0100
Use ITiledRenderable for LIBLOK.
Means that no changes should be required here once calc/impress/draw
support tiled rendering.
Change-Id: I0987d94303f39ba37e29b9ae7b2276e82dc0ccbf
diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk
index 671ff12..8a592cc 100644
--- a/desktop/Library_sofficeapp.mk
+++ b/desktop/Library_sofficeapp.mk
@@ -14,7 +14,6 @@ $(eval $(call gb_Library_set_include,sofficeapp,\
-I$(SRCDIR)/desktop/inc \
-I$(SRCDIR)/desktop/source/inc \
-I$(SRCDIR)/desktop/source/deployment/inc \
- -I$(SRCDIR)/sw/inc \
-I$(SRCDIR)/vcl/inc \
))
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 6c26400..ad446fc 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -39,16 +39,10 @@
#include <vcl/graphicfilter.hxx>
#include <vcl/sysdata.hxx>
#include <vcl/virdev.hxx>
+#include <vcl/ITiledRenderable.hxx>
#include <unotools/syslocaleoptions.hxx>
#include <unotools/mediadescriptor.hxx>
-// Dirty hack -- we go directly into sw -- ideally we need some sort of
-// layer to get the writer shell for tiled rendering
-#include <doc.hxx>
-#include <docsh.hxx>
-#include <unotxdoc.hxx>
-#include <viewsh.hxx>
-
#include <salinst.hxx>
// And let's also grab the SvpSalInstance and SvpSalVirtualDevice
@@ -428,38 +422,32 @@ void doc_paintTile (LibreOfficeKitDocument* pThis,
{
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
+ ::vcl::ITiledRenderable* pDoc = dynamic_cast< ::vcl::ITiledRenderable* >( pDocument->mxComponent.get() );
+ if (!pDoc)
+ {
+ gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+ return;
+ }
Application::AcquireSolarMutex(1);
- switch (doc_getDocumentType(pThis))
{
- case LOK_DOCTYPE_TEXT:
- {
- SwXTextDocument* pTxtDoc = dynamic_cast< SwXTextDocument* >( pDocument->mxComponent.get() );
- SwDocShell* pDocShell = pTxtDoc->GetDocShell();
- SwDoc* pDoc = pDocShell->GetDoc();
- SwViewShell* pViewShell = pDoc->GetCurrentViewShell();
-
- ImplSVData* pSVData = ImplGetSVData();
- SvpSalInstance* pSalInstance = static_cast< SvpSalInstance* >(pSVData->mpDefInst);
- pSalInstance->setBitCountFormatMapping( 32, ::basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA );
+ ImplSVData* pSVData = ImplGetSVData();
+ SvpSalInstance* pSalInstance = static_cast< SvpSalInstance* >(pSVData->mpDefInst);
+ pSalInstance->setBitCountFormatMapping( 32, ::basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA );
- VirtualDevice aDevice(0, (sal_uInt16)32);
- boost::shared_array< sal_uInt8 > aBuffer( pBuffer, NoDelete< sal_uInt8 >() );
- aDevice.SetOutputSizePixelScaleOffsetAndBuffer(
- Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
- aBuffer, true );
+ VirtualDevice aDevice(0, (sal_uInt16)32);
+ boost::shared_array< sal_uInt8 > aBuffer( pBuffer, NoDelete< sal_uInt8 >() );
+ aDevice.SetOutputSizePixelScaleOffsetAndBuffer(
+ Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
+ aBuffer, true );
- pViewShell->PaintTile(aDevice, nCanvasWidth, nCanvasHeight,
- nTilePosX, nTilePosY, nTileWidth, nTileHeight);
+ pDoc->paintTile(aDevice, nCanvasWidth, nCanvasHeight,
+ nTilePosX, nTilePosY, nTileWidth, nTileHeight);
- SvpSalVirtualDevice* pSalDev = static_cast< SvpSalVirtualDevice* >(aDevice.getSalVirtualDevice());
- basebmp::BitmapDeviceSharedPtr pBmpDev = pSalDev->getBitmapDevice();
+ SvpSalVirtualDevice* pSalDev = static_cast< SvpSalVirtualDevice* >(aDevice.getSalVirtualDevice());
+ basebmp::BitmapDeviceSharedPtr pBmpDev = pSalDev->getBitmapDevice();
- *pRowStride = pBmpDev->getScanlineStride();
- }
- break;
- default:
- break;
+ *pRowStride = pBmpDev->getScanlineStride();
}
Application::ReleaseSolarMutex();
}
@@ -470,20 +458,16 @@ static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
{
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
- if (doc_getDocumentType(pThis) == LOK_DOCTYPE_TEXT)
+ ::vcl::ITiledRenderable* pDoc = dynamic_cast< ::vcl::ITiledRenderable* >( pDocument->mxComponent.get() );
+ if (pDoc)
{
- SwXTextDocument* pTxtDoc = dynamic_cast< SwXTextDocument* >( pDocument->mxComponent.get() );
- SwDocShell* pDocShell = pTxtDoc->GetDocShell();
- SwDoc* pDoc = pDocShell->GetDoc();
- SwViewShell* pViewShell = pDoc->GetCurrentViewShell();
- Size aDocumentSize = pViewShell->GetDocSize();
+ Size aDocumentSize = pDoc->getDocumentSize();
*pWidth = aDocumentSize.Width();
*pHeight = aDocumentSize.Height();
}
else
{
- pWidth = 0;
- pHeight = 0;
+ gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
}
}
commit 0bffd4132f7a96b514dc45adc0087e1e13c5c888
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 13 17:31:42 2014 +0100
Add ITiledRenderable.
We want to have a simple interface that allows access to tiled
rendering without digging into the internals of writer
(and in the future calc/impress/draw).
Change-Id: Ia9c278a48c919333186e5361ff25bb1ab603b846
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
new file mode 100644
index 0000000..fecfd6c
--- /dev/null
+++ b/include/vcl/ITiledRenderable.hxx
@@ -0,0 +1,48 @@
+/* -*- 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_VCL_ITILEDRENDERABLE_HXX
+#define INCLUDED_VCL_ITILEDRENDERABLE_HXX
+
+#include <tools/gen.hxx>
+#include <vcl/virdev.hxx>
+
+namespace vcl
+{
+
+class VCL_DLLPUBLIC ITiledRenderable
+{
+public:
+ virtual ~ITiledRenderable() {};
+
+ /**
+ * Paint a tile to a given VirtualDevice.
+ *
+ * Output parameters are measured in pixels, tile parameters are in
+ * twips.
+ */
+ virtual void paintTile( VirtualDevice &rDevice,
+ int nOutputWidth,
+ int nOutputHeight,
+ int nTilePosX,
+ int nTilePosY,
+ long nTileWidth,
+ long nTileHeight ) = 0;
+
+ /**
+ * Get the document size in twips.
+ */
+ virtual Size getDocumentSize() = 0;
+
+};
+
+} // namespace vcl
+
+#endif // INCLUDED_VCL_ITILEDRENDERABLE_HXX
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index e43ea2b..a48a8f3 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -67,6 +67,7 @@
#include <cppuhelper/weak.hxx>
#include <cppuhelper/implbase2.hxx>
#include <cppuhelper/implbase4.hxx>
+#include <vcl/ITiledRenderable.hxx>
#include <unobaseclass.hxx>
#include <viewopt.hxx>
@@ -161,7 +162,8 @@ SwXTextDocumentBaseClass;
class SW_DLLPUBLIC SwXTextDocument : public SwXTextDocumentBaseClass,
public SvxFmMSFactory,
- public SfxBaseModel
+ public SfxBaseModel,
+ public ::vcl::ITiledRenderable
{
private:
class Impl;
@@ -428,6 +430,16 @@ public:
// ::com::sun::star::util::XCloneable
virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ // ITiledRenderable
+ virtual void paintTile( VirtualDevice &rDevice,
+ int nOutputWidth,
+ int nOutputHeight,
+ int nTilePosX,
+ int nTilePosY,
+ long nTileWidth,
+ long nTileHeight ) SAL_OVERRIDE;
+ virtual Size getDocumentSize() SAL_OVERRIDE;
+
void Invalidate();
void Reactivate(SwDocShell* pNewDocShell);
SwXDocumentPropertyHelper * GetPropertyHelper ();
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index c020b75..25e83d7 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3120,6 +3120,24 @@ uno::Reference< util::XCloneable > SwXTextDocument::createClone( ) throw (uno::
return uno::Reference< util::XCloneable >( xNewModel, UNO_QUERY );
}
+void SwXTextDocument::paintTile( VirtualDevice &rDevice,
+ int nOutputWidth, int nOutputHeight,
+ int nTilePosX, int nTilePosY,
+ long nTileWidth, long nTileHeight )
+{
+ SwDoc* pDoc = pDocShell->GetDoc();
+ SwViewShell* pViewShell = pDoc->GetCurrentViewShell();
+ pViewShell->PaintTile(rDevice, nOutputWidth, nOutputHeight,
+ nTilePosX, nTilePosY, nTileWidth, nTileHeight);
+}
+
+Size SwXTextDocument::getDocumentSize()
+{
+ SwDoc* pDoc = pDocShell->GetDoc();
+ SwViewShell* pViewShell = pDoc->GetCurrentViewShell();
+ return pViewShell->GetDocSize();
+}
+
void * SAL_CALL SwXTextDocument::operator new( size_t t) throw()
{
return SwXTextDocumentBaseClass::operator new(t);
commit 1f415b47fee3815fafb7c4fb09d48e3911f36324
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 13 15:00:42 2014 +0100
LIBLOK: implement getDocumentType, make doctypes unique.
Change-Id: I6cf810af55284cb6ddd9e0bfd879fd19508d127a
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 6634c52..6c26400 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -290,31 +290,23 @@ static int doc_saveAsWithOptions(LibreOfficeKitDocument* pThis, const char* sUrl
try
{
- uno::Reference<frame::XModel> xDocument(pDocument->mxComponent, uno::UNO_QUERY_THROW);
- uno::Sequence<beans::PropertyValue> aSequence = xDocument->getArgs();
-
- MediaDescriptor aMediaDescriptor(aSequence);
- OUString sPropertyName = MediaDescriptor::PROP_DOCUMENTSERVICE();
- OUString aDocumentService = aMediaDescriptor.getUnpackedValueOrDefault(sPropertyName, OUString());
+ const ExtensionMap* pMap;
- if (aDocumentService.isEmpty())
+ switch (doc_getDocumentType(pThis))
{
- gImpl->maLastExceptionMsg = "unknown document type";
- return false;
- }
-
- const ExtensionMap* pMap;
- if (aDocumentService == "com.sun.star.sheet.SpreadsheetDocument")
+ case LOK_DOCTYPE_SPREADSHEET:
pMap = (const ExtensionMap*) aCalcExtensionMap;
- else if (aDocumentService == "com.sun.star.presentation.PresentationDocument")
+ break;
+ case LOK_DOCTYPE_PRESENTATION:
pMap = (const ExtensionMap*) aImpressExtensionMap;
- else if (aDocumentService == "com.sun.star.drawing.DrawingDocument")
+ break;
+ case LOK_DOCTYPE_DRAWING:
pMap = (const ExtensionMap*) aDrawExtensionMap;
- else if (aDocumentService == "com.sun.star.text.TextDocument")
+ break;
+ case LOK_DOCTYPE_TEXT:
pMap = (const ExtensionMap*) aWriterExtensionMap;
- else
- {
- gImpl->maLastExceptionMsg = "unknown document mapping";
+ break;
+ case LOK_DOCTYPE_OTHER:
return false;
}
@@ -369,8 +361,49 @@ static int doc_saveAsWithOptions(LibreOfficeKitDocument* pThis, const char* sUrl
static LibreOfficeKitDocumentType doc_getDocumentType (LibreOfficeKitDocument* pThis)
{
- (void) pThis;
- return WRITER;
+ LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
+
+ try
+ {
+ uno::Reference<frame::XModel> xDocument(pDocument->mxComponent, uno::UNO_QUERY_THROW);
+ uno::Sequence<beans::PropertyValue> aSequence = xDocument->getArgs();
+
+ MediaDescriptor aMediaDescriptor(aSequence);
+ OUString sPropertyName = MediaDescriptor::PROP_DOCUMENTSERVICE();
+ OUString aDocumentService = aMediaDescriptor.getUnpackedValueOrDefault(sPropertyName, OUString());
+
+ if (aDocumentService.isEmpty())
+ {
+ gImpl->maLastExceptionMsg = "unknown document type";
+ return LOK_DOCTYPE_OTHER;
+ }
+
+ if (aDocumentService == "com.sun.star.sheet.SpreadsheetDocument")
+ {
+ return LOK_DOCTYPE_SPREADSHEET;
+ }
+ else if (aDocumentService == "com.sun.star.presentation.PresentationDocument")
+ {
+ return LOK_DOCTYPE_PRESENTATION;
+ }
+ else if (aDocumentService == "com.sun.star.drawing.DrawingDocument")
+ {
+ return LOK_DOCTYPE_DRAWING;
+ }
+ else if (aDocumentService == "com.sun.star.text.TextDocument")
+ {
+ return LOK_DOCTYPE_TEXT;
+ }
+ else
+ {
+ gImpl->maLastExceptionMsg = "unknown document mapping";
+ }
+ }
+ catch (const uno::Exception& exception)
+ {
+ gImpl->maLastExceptionMsg = "exception: " + exception.Message;
+ }
+ return LOK_DOCTYPE_OTHER;
}
static int doc_getNumberOfParts (LibreOfficeKitDocument* pThis)
@@ -395,30 +428,38 @@ void doc_paintTile (LibreOfficeKitDocument* pThis,
{
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
+
Application::AcquireSolarMutex(1);
+ switch (doc_getDocumentType(pThis))
{
- SwXTextDocument* pTxtDoc = dynamic_cast< SwXTextDocument* >( pDocument->mxComponent.get() );
- SwDocShell* pDocShell = pTxtDoc->GetDocShell();
- SwDoc* pDoc = pDocShell->GetDoc();
- SwViewShell* pViewShell = pDoc->GetCurrentViewShell();
+ case LOK_DOCTYPE_TEXT:
+ {
+ SwXTextDocument* pTxtDoc = dynamic_cast< SwXTextDocument* >( pDocument->mxComponent.get() );
+ SwDocShell* pDocShell = pTxtDoc->GetDocShell();
+ SwDoc* pDoc = pDocShell->GetDoc();
+ SwViewShell* pViewShell = pDoc->GetCurrentViewShell();
- ImplSVData* pSVData = ImplGetSVData();
- SvpSalInstance* pSalInstance = static_cast< SvpSalInstance* >(pSVData->mpDefInst);
- pSalInstance->setBitCountFormatMapping( 32, ::basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA );
+ ImplSVData* pSVData = ImplGetSVData();
+ SvpSalInstance* pSalInstance = static_cast< SvpSalInstance* >(pSVData->mpDefInst);
+ pSalInstance->setBitCountFormatMapping( 32, ::basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA );
- VirtualDevice aDevice(0, (sal_uInt16)32);
- boost::shared_array< sal_uInt8 > aBuffer( pBuffer, NoDelete< sal_uInt8 >() );
- aDevice.SetOutputSizePixelScaleOffsetAndBuffer(
- Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
- aBuffer, true );
+ VirtualDevice aDevice(0, (sal_uInt16)32);
+ boost::shared_array< sal_uInt8 > aBuffer( pBuffer, NoDelete< sal_uInt8 >() );
+ aDevice.SetOutputSizePixelScaleOffsetAndBuffer(
+ Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
+ aBuffer, true );
- pViewShell->PaintTile(aDevice, nCanvasWidth, nCanvasHeight,
- nTilePosX, nTilePosY, nTileWidth, nTileHeight);
+ pViewShell->PaintTile(aDevice, nCanvasWidth, nCanvasHeight,
+ nTilePosX, nTilePosY, nTileWidth, nTileHeight);
- SvpSalVirtualDevice* pSalDev = static_cast< SvpSalVirtualDevice* >(aDevice.getSalVirtualDevice());
- basebmp::BitmapDeviceSharedPtr pBmpDev = pSalDev->getBitmapDevice();
+ SvpSalVirtualDevice* pSalDev = static_cast< SvpSalVirtualDevice* >(aDevice.getSalVirtualDevice());
+ basebmp::BitmapDeviceSharedPtr pBmpDev = pSalDev->getBitmapDevice();
- *pRowStride = pBmpDev->getScanlineStride();
+ *pRowStride = pBmpDev->getScanlineStride();
+ }
+ break;
+ default:
+ break;
}
Application::ReleaseSolarMutex();
}
@@ -429,7 +470,7 @@ static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
{
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
- if (true) // TODO: test that we have a writer document here (vs calc/impress/etc.)
+ if (doc_getDocumentType(pThis) == LOK_DOCTYPE_TEXT)
{
SwXTextDocument* pTxtDoc = dynamic_cast< SwXTextDocument* >( pDocument->mxComponent.get() );
SwDocShell* pDocShell = pTxtDoc->GetDocShell();
@@ -439,6 +480,11 @@ static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
*pWidth = aDocumentSize.Width();
*pHeight = aDocumentSize.Height();
}
+ else
+ {
+ pWidth = 0;
+ pHeight = 0;
+ }
}
static char* lo_getError (LibreOfficeKit *pThis)
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 9895631..4a8dd63 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -30,10 +30,11 @@ typedef struct _LibreOfficeKitDocument LibreOfficeKitDocument;
#ifdef LOK_USE_UNSTABLE_API
typedef enum
{
- WRITER,
- SPREADSHEET,
- PRESENTATION,
- OTHER
+ LOK_DOCTYPE_TEXT,
+ LOK_DOCTYPE_SPREADSHEET,
+ LOK_DOCTYPE_PRESENTATION,
+ LOK_DOCTYPE_DRAWING,
+ LOK_DOCTYPE_OTHER
}
LibreOfficeKitDocumentType;
#endif // LOK_USE_UNSTABLE_API
commit ad41fb8e4a751229c8d0856815b4b71989974fc1
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 13 11:21:38 2014 +0100
Prevent GTK assertions due to scrolled window not being initialised.
Seems to be a gtk bug which we need to work around. The assertions
don't actually seem to cause any harm (they just print a bunch of
"Gtk-CRITICAL **: IA__gtk_range_get_adjustment: assertion `GTK_IS_RANGE (range)' failed"
but probably best to avoid them.
Change-Id: I5d1bb20bd5c0569c6d023a6148123208a15b9de2
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index 47967fc..2c56c81 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -47,6 +47,12 @@ static void lok_docview_class_init( LOKDocViewClass* pClass )
static void lok_docview_init( LOKDocView* pDocView )
{
+ // 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 );
commit 3941fe36b4356db8d384486efba113d6ec6f66b4
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 13 11:20:15 2014 +0100
Move gtktiledviewer into libreofficekit.
desktop is no longer the right place for it now that
libreofficekit has its own directory.
Change-Id: I207f1d642e7e35c460ff85bb57aa142cb98023c8
diff --git a/desktop/Module_desktop.mk b/desktop/Module_desktop.mk
index 04b71f7..cfaf0d9 100644
--- a/desktop/Module_desktop.mk
+++ b/desktop/Module_desktop.mk
@@ -29,14 +29,6 @@ $(eval $(call gb_Module_add_l10n_targets,desktop,\
UIConfig_deployment \
))
-ifeq ($(OS),LINUX)
-ifneq ($(ENABLE_GTK),)
-$(eval $(call gb_Module_add_targets,desktop,\
- Executable_gtktiledviewer \
-))
-endif
-endif
-
ifneq (,$(filter DESKTOP,$(BUILD_TYPE)))
$(eval $(call gb_Module_add_targets,desktop,\
Executable_soffice_bin \
diff --git a/desktop/Executable_gtktiledviewer.mk b/libreofficekit/Executable_gtktiledviewer.mk
similarity index 95%
rename from desktop/Executable_gtktiledviewer.mk
rename to libreofficekit/Executable_gtktiledviewer.mk
index a0bf8ea..0ce9222 100644
--- a/desktop/Executable_gtktiledviewer.mk
+++ b/libreofficekit/Executable_gtktiledviewer.mk
@@ -43,7 +43,7 @@ $(eval $(call gb_Executable_add_libs,gtktiledviewer,\
endif
$(eval $(call gb_Executable_add_exception_objects,gtktiledviewer,\
- desktop/qa/gtktiledviewer/gtktiledviewer \
+ libreofficekit/qa/gtktiledviewer/gtktiledviewer \
))
# vim: set noet sw=4 ts=4:
diff --git a/libreofficekit/Module_libreofficekit.mk b/libreofficekit/Module_libreofficekit.mk
index 0412a33..55136a4 100644
--- a/libreofficekit/Module_libreofficekit.mk
+++ b/libreofficekit/Module_libreofficekit.mk
@@ -10,10 +10,18 @@
$(eval $(call gb_Module_Module,libreofficekit))
ifeq ($(OS),LINUX)
+
$(eval $(call gb_Module_add_targets,libreofficekit,\
StaticLibrary_libreofficekit \
Library_libreofficekitgtk \
))
-endif
+
+ifneq ($(ENABLE_GTK),)
+$(eval $(call gb_Module_add_targets,libreofficekit,\
+ Executable_gtktiledviewer \
+))
+endif # ($(ENABLE_GTK),)
+
+endif # ($(OS),LINUX)
# vim: set ts=4 sw=4 et:
diff --git a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
similarity index 100%
rename from desktop/qa/gtktiledviewer/gtktiledviewer.cxx
rename to libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
commit a3f3f94e53e46d39c1b1a35081a1472209a558bd
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 13 10:43:07 2014 +0100
Tiled Rendering: ensure rendered area is visible.
MakeVisible only scrolls the view, so parts of the tile to be rendered
might be outside the SwView's visible area, and therefore not painted.
This however makes the background window (shown for the tilederendering
app) unuseable (but that window is invisible for all practical uses
of tiled rendering, and hence probably not a problem).
Change-Id: I6c3c2846906163b362f7cff6d8c7ba308a58a7ad
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 766a8ac..79bda49 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -1783,8 +1783,14 @@ void SwViewShell::PaintTile(VirtualDevice &rDevice, int contextWidth, int contex
Imp()->GetDrawView()->AddWindowToPaintView(&rDevice);
}
- // scroll the requested area into view if necessary
- MakeVisible(SwRect(Point(tilePosX, tilePosY), rDevice.PixelToLogic(Size(contextWidth, contextHeight))));
+ // Make the requested area visible -- we can't use MakeVisible as that will
+ // only scroll the contents, but won't zoom/resize if needed.
+ // Without this, items/text that are outside the visible area (in the SwView)
+ // won't be painted when rendering tiles (at least when using either the
+ // tiledrendering app, or the gtktiledviewer) -- although ultimately we
+ // probably want to fix things so that the SwView's area doesn't affect
+ // tiled rendering?
+ mpDoc->GetDocShell()->SetVisArea(Rectangle(Point(tilePosX, tilePosY), rDevice.PixelToLogic(Size(contextWidth, contextHeight))));
// draw - works in logic coordinates
Paint(Rectangle(Point(tilePosX, tilePosY), rDevice.PixelToLogic(Size(contextWidth, contextHeight))));
commit 393c47824f993d59c7f08650f19d40b1bec22986
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Thu Jun 12 17:38:27 2014 +0100
Upgrade gtktiledviewer to use the LOK viewer widget.
Change-Id: Ied397f617d1cad1f3bd095e8af1ffa741916ecca
diff --git a/desktop/Executable_gtktiledviewer.mk b/desktop/Executable_gtktiledviewer.mk
index 6295f5e..a0bf8ea 100644
--- a/desktop/Executable_gtktiledviewer.mk
+++ b/desktop/Executable_gtktiledviewer.mk
@@ -18,6 +18,10 @@ $(eval $(call gb_Executable_use_externals,gtktiledviewer,\
gtk \
))
+$(eval $(call gb_Executable_use_libraries,gtktiledviewer,\
+ libreofficekitgtk \
+))
+
$(eval $(call gb_Executable_use_static_libraries,gtktiledviewer,\
libreofficekit \
))
diff --git a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
index d8781b2..c0a9b9f 100644
--- a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -13,10 +13,7 @@
#include <gdk/gdk.h>
#include <gtk/gtk.h>
-#define LOK_USE_UNSTABLE_API
-#include <LibreOfficeKit/LibreOfficeKit.hxx>
-
-using namespace ::lok;
+#include <LibreOfficeKit/LibreOfficeKitGtk.h>
static int help()
{
@@ -24,56 +21,6 @@ static int help()
return 1;
}
-static GtkWidget* ourCanvas;
-static GdkPixbuf* ourPixBuf = 0;
-
-bool drawCallback(GtkWidget* /* The eventbox */, void* /* cairo_t* cr */, gpointer pData)
-{
- fprintf(stderr, "attempting to draw tile");
-
- Document* pDocument = static_cast< Document* >( pData );
-
- long nWidth, nHeight;
- pDocument->getDocumentSize( &nWidth, &nHeight );
-
- // Draw the whole document at once (for now)
- int nRenderWidth = nWidth / 10;
- int nRenderHeight = nHeight / 10;
- int nRowStride;
-
- if ( ourPixBuf &&
- (gdk_pixbuf_get_width( ourPixBuf ) != nRenderWidth ||
- gdk_pixbuf_get_height( ourPixBuf ) != nRenderHeight ) )
- {
- g_object_unref( G_OBJECT( ourPixBuf ) );
- ourPixBuf = 0;
-
- }
- if (!ourPixBuf)
- {
- ourPixBuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB,
- true, 8,
- nRenderWidth, nRenderHeight);
- }
-
- unsigned char* pBuffer = gdk_pixbuf_get_pixels( ourPixBuf );
-
- pDocument->paintTile( pBuffer,
- nRenderWidth, nRenderHeight,
- &nRowStride,
- 0, 0, // origin
- nWidth, nHeight );
- // 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( ourCanvas ), ourPixBuf );
-
- return true;
-
-}
-
int main( int argc, char* argv[] )
{
if( argc < 2 ||
@@ -86,7 +33,7 @@ int main( int argc, char* argv[] )
return 1;
}
- ::lok::Office *pOffice = ::lok::lok_cpp_init( argv[1] );
+ LibreOfficeKit* pOffice = lok_init( argv[1] );
if( !pOffice )
{
fprintf( stderr, "Failed to initialize\n" );
@@ -94,14 +41,12 @@ int main( int argc, char* argv[] )
}
// "This separate init is lame I think."
- if( !pOffice->initialize( argv[1] ) )
+ if( !pOffice->initialize( pOffice, argv[1] ) )
{
fprintf( stderr, "failed to initialize\n" );
return -1;
}
- ::lok::Document* pDocument = pOffice->documentLoad( argv[2] );
-
gtk_init( &argc, &argv );
GtkWidget *pWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL );
@@ -110,25 +55,14 @@ int main( int argc, char* argv[] )
g_signal_connect( pWindow, "destroy", G_CALLBACK(gtk_main_quit), NULL );
- GtkWidget* pScroller = gtk_scrolled_window_new( 0, 0 );
- gtk_container_add( GTK_CONTAINER(pWindow), pScroller );
-
- GtkWidget* pEventBox = gtk_event_box_new();
- gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(pScroller), pEventBox );
+ GtkWidget* pDocView = lok_docview_new( pOffice );
+ gtk_container_add( GTK_CONTAINER(pWindow), pDocView );
- GtkWidget* pCanvas = gtk_image_new();
- ourCanvas = pCanvas;
- gtk_container_add( GTK_CONTAINER( pEventBox ), pCanvas );
+ lok_docview_open_document( LOK_DOCVIEW(pDocView), argv[2] );
- 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( pDocView );
gtk_widget_show( pWindow );
- drawCallback( pCanvas, 0, pDocument );
-
gtk_main();
return 0;
commit 6804c0041610cbf9931f210e509096e72b673df3
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Thu Jun 12 17:38:10 2014 +0100
Implement LibreOfficeKit gtk+ viewer widget.
Very basic, but works.
Change-Id: I0c521e833b53e13065e0be48e6fa767e44b29787
diff --git a/Repository.mk b/Repository.mk
index 8210aba..1c4298b 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -524,6 +524,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,PLAINLIBS_OOO,ooo, \
i18nlangtag \
i18nutil \
index_data \
+ $(if $(and $(ENABLE_GTK), $(filter LINUX,$(OS))), libreofficekitgtk) \
localedata_en \
localedata_es \
localedata_euro \
diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
new file mode 100644
index 0000000..2435fc2
--- /dev/null
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -0,0 +1,60 @@
+/* -*- 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_DESKTOP_INC_LIBREOFFICEKITGTK_H
+#define INCLUDED_DESKTOP_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(obj) GTK_CHECK_CAST (obj, lok_docview_get_type(), LOKDocView)
+#define LOK_DOCVIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, lok_docview_get_type(), LOKDocViewClass)
+#define IS_LOK_DOCVIEW(obj) GTK_CHECK_TYPE (obj, lok_docview_get_type())
+
+
+typedef struct _LOKDocView LOKDocView;
+typedef struct _LOKDocViewClass LOKDocViewClass;
+
+struct _LOKDocView
+{
+ GtkScrolledWindow scrollWindow;
+
+ GtkWidget* pEventBox;
+ GtkWidget* pCanvas;
+ GdkPixbuf* pPixBuf;
+
+ LibreOfficeKit* pOffice;
+ LibreOfficeKitDocument* pDocument;
+};
+
+struct _LOKDocViewClass
+{
+ GtkScrolledWindowClass parent_class;
+
+ void (*lok_docview) (LOKDocView* pDocView);
+};
+
+guint lok_docview_get_type (void);
+GtkWidget* lok_docview_new ( LibreOfficeKit* pOffice );
+gboolean lok_docview_open_document (LOKDocView* pDocView,
+ char* pPath);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
\ No newline at end of file
diff --git a/libreofficekit/Library_libreofficekitgtk.mk b/libreofficekit/Library_libreofficekitgtk.mk
new file mode 100644
index 0000000..be485cd
--- /dev/null
+++ b/libreofficekit/Library_libreofficekitgtk.mk
@@ -0,0 +1,31 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_Library_Library,libreofficekitgtk))
+
+
+$(eval $(call gb_Library_use_externals,libreofficekitgtk,\
+ gtk \
+))
+
+$(eval $(call gb_Library_use_static_libraries,libreofficekitgtk,\
+ libreofficekit \
+))
+
+$(eval $(call gb_Library_add_cobjects,libreofficekitgtk,\
+ libreofficekit/source/gtk/lokdocview \
+))
+
+ifeq ($(OS),LINUX)
+$(eval $(call gb_Library_add_libs,libreofficekitgtk,\
+ -ldl \
+))
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/libreofficekit/Module_libreofficekit.mk b/libreofficekit/Module_libreofficekit.mk
index 1d65d45..0412a33 100644
--- a/libreofficekit/Module_libreofficekit.mk
+++ b/libreofficekit/Module_libreofficekit.mk
@@ -12,6 +12,7 @@ $(eval $(call gb_Module_Module,libreofficekit))
ifeq ($(OS),LINUX)
$(eval $(call gb_Module_add_targets,libreofficekit,\
StaticLibrary_libreofficekit \
+ Library_libreofficekitgtk \
))
endif
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
new file mode 100644
index 0000000..47967fc
--- /dev/null
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -0,0 +1,120 @@
+/* -*- 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 <LibreOfficeKit/LibreOfficeKitGtk.h>
+
+static void lok_docview_class_init( LOKDocViewClass* pClass );
+static void lok_docview_init( LOKDocView* pDocView );
+
+SAL_DLLPUBLIC_EXPORT guint lok_docview_get_type()
+{
+ static guint lok_docview_type = 0;
+
+ if (!lok_docview_type)
+ {
+ GtkTypeInfo lok_docview_info =
+ {
+ "LokDocView",
+ sizeof( LOKDocView ),
+ sizeof( LOKDocViewClass ),
+ (GtkClassInitFunc) lok_docview_class_init,
+ (GtkObjectInitFunc) lok_docview_init,
+ NULL,
+ NULL,
+ (GtkClassInitFunc) NULL
+ };
+
+ lok_docview_type = gtk_type_unique( gtk_scrolled_window_get_type(), &lok_docview_info );
+ }
+ return lok_docview_type;
+}
+
+static void lok_docview_class_init( LOKDocViewClass* pClass )
+{
+ pClass->lok_docview = NULL;
+}
+
+static void lok_docview_init( LOKDocView* pDocView )
+{
+ pDocView->pEventBox = gtk_event_box_new();
+ gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(pDocView),
+ pDocView->pEventBox );
+
+ pDocView->pCanvas = gtk_image_new();
+ gtk_container_add( GTK_CONTAINER( pDocView->pEventBox ), pDocView->pCanvas );
+
+ gtk_widget_show( pDocView->pCanvas );
+ gtk_widget_show( pDocView->pEventBox );
+
+ pDocView->pPixBuf = 0;
+
+ // TODO: figure out a clever view of getting paths set up.
+ pDocView->pOffice = 0;
+ pDocView->pDocument = 0;
+}
+
+SAL_DLLPUBLIC_EXPORT GtkWidget* lok_docview_new( LibreOfficeKit* pOffice )
+{
+ LOKDocView* pDocView = gtk_type_new( lok_docview_get_type() );
+ pDocView->pOffice = pOffice;
+ return GTK_WIDGET( pDocView );
+}
+
+SAL_DLLPUBLIC_EXPORT gboolean lok_docview_open_document( LOKDocView* pDocView, char* pPath )
+{
+ if ( pDocView->pDocument )
+ {
+ pDocView->pDocument->destroy( pDocView->pDocument );
+ pDocView->pDocument = 0;
+ }
+
+ pDocView->pDocument = pDocView->pOffice->documentLoad( pDocView->pOffice,
+ pPath );
+ if ( pDocView->pPixBuf )
+ {
+ g_object_unref( G_OBJECT( pDocView->pPixBuf ) );
+ }
+
+ long nWidth, nHeight;
+ pDocView->pDocument->getDocumentSize( pDocView->pDocument, &nWidth, &nHeight );
+
+ // Draw the whole document at once (for now)
+ int nRenderWidth = nWidth / 10;
+ int nRenderHeight = nHeight / 10;
+
+ pDocView->pPixBuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB,
+ TRUE, 8,
+ nRenderWidth, nRenderHeight);
+
+
+ // TODO: move the rendering into it's own function etc.
+ unsigned char* pBuffer = gdk_pixbuf_get_pixels( pDocView->pPixBuf );
+ int nRowStride;
+ pDocView->pDocument->paintTile( pDocView->pDocument,
+ pBuffer,
+ nRenderWidth, nRenderHeight,
+ &nRowStride,
+ 0, 0, // origin
+ nWidth, nHeight );
+ // 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 );
+
+ return FALSE;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 6165ff85eac7870685fa78cee584027a6f00ccaa
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Thu Jun 12 15:14:58 2014 +0100
Remove outdated includes.
These were needed for the X11 "context" rendering which is no longer used.
Change-Id: Ib60c8fff9dad06b1f8f489eed66c3b3c3597e1ee
diff --git a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
index cff237c..d8781b2 100644
--- a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -11,15 +11,8 @@
#include <string.h>
#include <gdk/gdk.h>
-#include <gdk/gdkx.h>
#include <gtk/gtk.h>
-#include <X11/extensions/Xrender.h>
-
-// Only for the SystemGraphicsData struct, and hopefully we can find some better
-// replacement for that at some point.
-#include <vcl/sysdata.hxx>
-
#define LOK_USE_UNSTABLE_API
#include <LibreOfficeKit/LibreOfficeKit.hxx>
commit 7b8814d5a28e130f8f5c23e7cc456b388217ff68
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Wed Jun 11 13:54:49 2014 +0100
Kill gtktiledviewer's alpha channel hack.
basebmp and vcl now set the alpha channel appropriately, so no need
to do so in the viewer now.
However it would perhaps make more sense to just use RGB instead
of RGBA, seeing as the alpha channel is permanently set to be opaque.
Change-Id: I86ad758c6a8bee21b265730727a76605e5850c0c
diff --git a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
index 18506a7..cff237c 100644
--- a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -75,11 +75,6 @@ bool drawCallback(GtkWidget* /* The eventbox */, void* /* cairo_t* cr */, gpoint
// wrong.
(void) nRowStride;
- for (int i = 3; i < nRowStride*nRenderHeight; i += 4)
- {
- pBuffer[i] = 0xFF;
- }
-
gtk_image_set_from_pixbuf( GTK_IMAGE( ourCanvas ), ourPixBuf );
return true;
commit aa6f940a6e1ca60b13bb82c9b6077b39fffc8054
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Wed Jun 11 13:39:56 2014 +0100
Fill the alpha channel by default for vcl 32-bit bitmaps too.
Otherwise the alpha channel for bitmaps created directly is empty,
indicating a transparent bitmap (although we don't actually handle
transparency). This complements hardcoding of the alpha channel
in basebmp. VCL bitmaps can be copied bit-for-bit directly into
a basebmp bitmap, hence it's important to make sure we fill the
alpha channel in vcl too.
Conflicts:
include/vcl/salbtype.hxx
Change-Id: Icb2fa417db6625a6ffa6bd82eb5773ff75be5a3c
diff --git a/include/vcl/salbtype.hxx b/include/vcl/salbtype.hxx
index ccdbfbe..92258c5 100644
--- a/include/vcl/salbtype.hxx
+++ b/include/vcl/salbtype.hxx
@@ -84,13 +84,14 @@ d_Col = BitmapColor( (sal_uInt8) ( _def_cR | ( ( _def_cR & mnROr ) >> mnROrShift
-#define COLOR_TO_MASK( d_rCol, d_RM, d_GM, d_BM, d_RS, d_GS, d_BS ) \
+#define COLOR_TO_MASK( d_rCol, d_RM, d_GM, d_BM, d_RS, d_GS, d_BS, d_ALPHA ) \
( ( ( ( d_RS < 0L ) ? ( (sal_uInt32) (d_rCol).GetRed() >> -d_RS ) : \
( (sal_uInt32) (d_rCol).GetRed() << d_RS ) ) & d_RM ) | \
( ( ( d_GS < 0L ) ? ( (sal_uInt32) (d_rCol).GetGreen() >> -d_GS ) : \
( (sal_uInt32) (d_rCol).GetGreen() << d_GS ) ) & d_GM ) | \
( ( ( d_BS < 0L ) ? ( (sal_uInt32) (d_rCol).GetBlue() >> -d_BS ) : \
- ( (sal_uInt32) (d_rCol).GetBlue() << d_BS ) ) & d_BM ) )
+ ( (sal_uInt32) (d_rCol).GetBlue() << d_BS ) ) & d_BM ) | \
+ d_ALPHA )
// - BitmapColor -
@@ -215,12 +216,16 @@ class VCL_DLLPUBLIC ColorMask
sal_uLong mnROr;
sal_uLong mnGOr;
sal_uLong mnBOr;
+ sal_uLong mnAlphaChannel;
SAL_DLLPRIVATE inline long ImplCalcMaskShift( sal_uLong nMask, sal_uLong& rOr, sal_uLong& rOrShift ) const;
public:
- inline ColorMask( sal_uLong nRedMask = 0UL, sal_uLong nGreenMask = 0UL, sal_uLong nBlueMask = 0UL );
+ inline ColorMask( sal_uLong nRedMask = 0UL,
+ sal_uLong nGreenMask = 0UL,
+ sal_uLong nBlueMask = 0UL,
+ sal_uLong nAlphaChannel = 0UL );
inline ~ColorMask() {}
inline sal_uLong GetRedMask() const;
@@ -698,7 +703,10 @@ inline sal_uInt16 BitmapPalette::GetBestIndex( const BitmapColor& rCol ) const
-inline ColorMask::ColorMask( sal_uLong nRedMask, sal_uLong nGreenMask, sal_uLong nBlueMask ) :
+inline ColorMask::ColorMask( sal_uLong nRedMask,
+ sal_uLong nGreenMask,
+ sal_uLong nBlueMask,
+ sal_uLong nAlphaChannel ) :
mnRMask( nRedMask ),
mnGMask( nGreenMask ),
mnBMask( nBlueMask ),
@@ -707,7 +715,8 @@ inline ColorMask::ColorMask( sal_uLong nRedMask, sal_uLong nGreenMask, sal_uLong
mnBOrShift( 0L ),
mnROr( 0L ),
mnGOr( 0L ),
- mnBOr( 0L )
+ mnBOr( 0L ),
+ mnAlphaChannel( nAlphaChannel )
{
mnRShift = ( mnRMask ? ImplCalcMaskShift( mnRMask, mnROr, mnROrShift ) : 0L );
mnGShift = ( mnGMask ? ImplCalcMaskShift( mnGMask, mnGOr, mnGOrShift ) : 0L );
@@ -774,7 +783,7 @@ inline void ColorMask::GetColorFor8Bit( BitmapColor& rColor, ConstHPBYTE pPixel
inline void ColorMask::SetColorFor8Bit( const BitmapColor& rColor, HPBYTE pPixel ) const
{
- *pPixel = (sal_uInt8) COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift );
+ *pPixel = (sal_uInt8) COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, mnAlphaChannel );
}
@@ -790,7 +799,7 @@ inline void ColorMask::GetColorFor16BitMSB( BitmapColor& rColor, ConstHPBYTE pPi
inline void ColorMask::SetColorFor16BitMSB( const BitmapColor& rColor, HPBYTE pPixel ) const
{
- const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift );
+ const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, mnAlphaChannel );
pPixel[ 0 ] = (sal_uInt8)(nVal >> 8U);
pPixel[ 1 ] = (sal_uInt8) nVal;
@@ -809,7 +818,7 @@ inline void ColorMask::GetColorFor16BitLSB( BitmapColor& rColor, ConstHPBYTE pPi
inline void ColorMask::SetColorFor16BitLSB( const BitmapColor& rColor, HPBYTE pPixel ) const
{
- const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift );
+ const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, mnAlphaChannel );
pPixel[ 0 ] = (sal_uInt8) nVal;
pPixel[ 1 ] = (sal_uInt8)(nVal >> 8U);
@@ -828,7 +837,7 @@ inline void ColorMask::GetColorFor24Bit( BitmapColor& rColor, ConstHPBYTE pPixel
inline void ColorMask::SetColorFor24Bit( const BitmapColor& rColor, HPBYTE pPixel ) const
{
- const sal_uInt32 nVal = COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift );
+ const sal_uInt32 nVal = COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, mnAlphaChannel );
pPixel[ 0 ] = (sal_uInt8) nVal; pPixel[ 1 ] = (sal_uInt8) ( nVal >> 8UL ); pPixel[ 2 ] = (sal_uInt8) ( nVal >> 16UL );
}
@@ -857,7 +866,7 @@ inline void ColorMask::GetColorAndAlphaFor32Bit( BitmapColor& rColor, sal_uInt8&
inline void ColorMask::SetColorFor32Bit( const BitmapColor& rColor, HPBYTE pPixel ) const
{
- const sal_uInt32 nVal = COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift );
+ const sal_uInt32 nVal = COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, mnAlphaChannel );
pPixel[ 0 ] = (sal_uInt8) nVal; pPixel[ 1 ] = (sal_uInt8) ( nVal >> 8UL );
pPixel[ 2 ] = (sal_uInt8) ( nVal >> 16UL ); pPixel[ 3 ] = (sal_uInt8) ( nVal >> 24UL );
}
diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx
index 0a81fdc..3920aea 100644
--- a/vcl/headless/svpbmp.cxx
+++ b/vcl/headless/svpbmp.cxx
@@ -188,36 +188,36 @@ BitmapBuffer* SvpSalBitmap::AcquireBuffer( bool )
nBitCount = 32;
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
#ifdef OSL_BIGENDIAN
- pBuf->maColorMask = ColorMask( 0x0000ff00, 0x00ff0000, 0xff000000 );
+ pBuf->maColorMask = ColorMask( 0x0000ff00, 0x00ff0000, 0xff000000, 0x000000ff );
#else
- pBuf->maColorMask = ColorMask( 0x00ff0000, 0x0000ff00, 0x000000ff );
+ pBuf->maColorMask = ColorMask( 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 );
#endif
break;
case FORMAT_THIRTYTWO_BIT_TC_MASK_ARGB:
nBitCount = 32;
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
#ifdef OSL_BIGENDIAN
- pBuf->maColorMask = ColorMask( 0x00ff0000, 0x0000ff00, 0x000000ff );
+ pBuf->maColorMask = ColorMask( 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 );
#else
- pBuf->maColorMask = ColorMask( 0x0000ff00, 0x00ff0000, 0xff000000 );
+ pBuf->maColorMask = ColorMask( 0x0000ff00, 0x00ff0000, 0xff000000, 0x000000ff );
#endif
break;
case FORMAT_THIRTYTWO_BIT_TC_MASK_ABGR:
nBitCount = 32;
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
#ifdef OSL_BIGENDIAN
- pBuf->maColorMask = ColorMask( 0x000000ff, 0x0000ff00, 0x00ff0000 );
+ pBuf->maColorMask = ColorMask( 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 );
#else
- pBuf->maColorMask = ColorMask( 0xff000000, 0x00ff0000, 0x0000ff00 );
+ pBuf->maColorMask = ColorMask( 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff );
#endif
break;
case FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA:
nBitCount = 32;
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
#ifdef OSL_BIGENDIAN
- pBuf->maColorMask = ColorMask( 0xff000000, 0x00ff0000, 0x0000ff00 );
+ pBuf->maColorMask = ColorMask( 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff );
#else
- pBuf->maColorMask = ColorMask( 0x000000ff, 0x0000ff00, 0x00ff0000 );
+ pBuf->maColorMask = ColorMask( 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 );
#endif
break;
diff --git a/vcl/source/gdi/bmpacc2.cxx b/vcl/source/gdi/bmpacc2.cxx
index bf1d540..12b0c1d 100644
--- a/vcl/source/gdi/bmpacc2.cxx
+++ b/vcl/source/gdi/bmpacc2.cxx
@@ -179,7 +179,7 @@ IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_ABGR )
IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_ABGR )
{
- *( pScanline = pScanline + ( nX << 2 ) )++ = 0;
+ *( pScanline = pScanline + ( nX << 2 ) )++ = 0xFF;
*pScanline++ = rBitmapColor.GetBlue();
*pScanline++ = rBitmapColor.GetGreen();
*pScanline = rBitmapColor.GetRed();
@@ -198,7 +198,7 @@ IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_ARGB )
IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_ARGB )
{
- *( pScanline = pScanline + ( nX << 2 ) )++ = 0;
+ *( pScanline = pScanline + ( nX << 2 ) )++ = 0xFF;
*pScanline++ = rBitmapColor.GetRed();
*pScanline++ = rBitmapColor.GetGreen();
*pScanline = rBitmapColor.GetBlue();
@@ -220,7 +220,7 @@ IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_BGRA )
*( pScanline = pScanline + ( nX << 2 ) )++ = rBitmapColor.GetBlue();
*pScanline++ = rBitmapColor.GetGreen();
*pScanline++ = rBitmapColor.GetRed();
- *pScanline = 0;
+ *pScanline = 0xFF;
}
IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_RGBA )
@@ -239,7 +239,7 @@ IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_RGBA )
*( pScanline = pScanline + ( nX << 2 ) )++ = rBitmapColor.GetRed();
*pScanline++ = rBitmapColor.GetGreen();
*pScanline++ = rBitmapColor.GetBlue();
- *pScanline = 0;
+ *pScanline = 0xFF;
}
IMPL_FORMAT_GETPIXEL( _32BIT_TC_MASK )
commit 78546921bd195ff39dcc4a829e1a0e621b7b9ddd
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Tue Jun 10 17:15:49 2014 +0100
Add base value to set alpha channel for 32 bit colourspaces.
Currently the alpha channel is completely ignored by basebmp.
However this results in completely "transparent" output, meaning
the client has to manually overwrite the alpha channel -- instead
we now set it automatically when writing colourdata.
Unfortunately this doesn't quite work -- it seems that drawing
a non-opaque bitmap/image on top of the existing bitmap can
erase the alpha channel information (i.e. these areas will
once again be transparent -- for example document borders seem
to have a transition effect overlayed onto them): presumably
there is some method that bypasses our RGBMaskSetter (probably
some form of direct manipulation of raw values?).
manipulation in basebmp
Change-Id: Ia4be6a748cc30191a4422121f9ec347d9198b225
diff --git a/include/basebmp/rgbmaskpixelformats.hxx b/include/basebmp/rgbmaskpixelformats.hxx
index d1d9b84..696f35a 100644
--- a/include/basebmp/rgbmaskpixelformats.hxx
+++ b/include/basebmp/rgbmaskpixelformats.hxx
@@ -148,6 +148,7 @@ template< typename PixelType,
template< typename PixelType,
typename ColorType,
+ unsigned int BaseValue,
unsigned int RedMask,
unsigned int GreenMask,
unsigned int BlueMask,
@@ -174,6 +175,7 @@ template< typename PixelType,
const typename base_type::unsigned_pixel_type blue (c.getBlue());
typename base_type::unsigned_pixel_type res(
+ BaseValue |
(shiftLeft(red,
base_type::red_shift-8*
(signed)sizeof(typename base_type::component_type)+
@@ -194,6 +196,7 @@ template< typename PixelType,
template< typename PixelType,
+ unsigned int BaseValue,
unsigned int RedMask,
unsigned int GreenMask,
unsigned int BlueMask,
@@ -209,6 +212,7 @@ template< typename PixelType,
SwapBytes> getter_type;
typedef RGBMaskSetter<pixel_type,
Color,
+ BaseValue,
RedMask,
GreenMask,
BlueMask,
@@ -256,6 +260,7 @@ template< typename PixelType,
// 16bpp MSB RGB
typedef PixelFormatTraitsTemplate_RGBMask<
sal_uInt16,
+ 0,
0xF800,
0x07E0,
0x001F,
@@ -266,6 +271,7 @@ BASEBMP_SPECIALIZE_ACCESSORTRAITS(PixelFormatTraits_RGB16_565_MSB::getter_type,
// 16bpp LSB RGB
typedef PixelFormatTraitsTemplate_RGBMask<
sal_uInt16,
+ 0,
0xF800,
0x07E0,
0x001F,
@@ -286,6 +292,7 @@ BASEBMP_SPECIALIZE_ACCESSORTRAITS(PixelFormatTraits_RGB16_565_LSB::getter_type,
typedef PixelFormatTraitsTemplate_RGBMask<
sal_uInt32,
+ 0xFF000000,
0x00FF0000,
0x0000FF00,
0x000000FF,
@@ -297,6 +304,7 @@ BASEBMP_SPECIALIZE_ACCESSORTRAITS(PixelFormatTraits_BGRX32_8888::getter_type,
typedef PixelFormatTraitsTemplate_RGBMask<
sal_uInt32,
+ 0xFF000000,
0x00FF0000,
0x0000FF00,
0x000000FF,
@@ -308,6 +316,7 @@ BASEBMP_SPECIALIZE_ACCESSORTRAITS(PixelFormatTraits_XRGB32_8888::getter_type,
typedef PixelFormatTraitsTemplate_RGBMask<
sal_uInt32,
+ 0x000000FF,
0xFF000000,
0x00FF0000,
0x0000FF00,
@@ -317,6 +326,7 @@ BASEBMP_SPECIALIZE_ACCESSORTRAITS(PixelFormatTraits_XBGR32_8888::getter_type,
typedef PixelFormatTraitsTemplate_RGBMask<
sal_uInt32,
+ 0x000000FF,
0xFF000000,
0x00FF0000,
0x0000FF00,
commit b7b645244ec60ab1d566a712cf67567220057fad
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Sun May 25 18:30:00 2014 +0100
Get rid of outdated comments.
We can now set the colourspace as desired, and we return the rowstride too.
Change-Id: Idf1e55a67b9e9ab58e82d7ed0be2813b682ec2ff
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 372771e..6634c52 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -386,29 +386,12 @@ static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart)
(void) nPart;
}
-// TODO: Not 100% sure about the bitmap buffer format yet -- it appears
-// to just be RGB, 8 bits per sample, and vertically mirrored compared
-// to what gtk expects.
-// The BitmapDevice actually supports various formats, as detailed in
-// basebmp/scanlineformat.hxx -- for svp SVP_DEFAULT_BITMAP_FORMAT is seemingly used
-// (see creation in svpvd.cxx) -- which is simply FORMAT_TWENTYFOUR_BIT_TC_MASK
-// for now -- we could probably adjust this as necessary to get whatever
-// format is presumably most useful, or maybe even allow that as a parameter.
-//
-// It's actually possible to set the depth in the creation of a VirtualDevice,
-// however that only allows 0, 1 or 8 -- and we can't select the full range of formats
-// as above, so we'd need to add a way of setting the format entirely from scratch
-// should that be deemed necessary.
-//
-// We probably also want to use getScanlineStride() -- I'm guessing that
-// this is where we are actually just returning a sub-portion of a larger buffer
-// which /shouldn't/ apply in our case, but better to be safe here.
void doc_paintTile (LibreOfficeKitDocument* pThis,
unsigned char* pBuffer,
- const int nCanvasWidth, const int nCanvasHeight,
- int* pRowStride,
- const int nTilePosX, const int nTilePosY,
- const int nTileWidth, const int nTileHeight)
+ const int nCanvasWidth, const int nCanvasHeight,
+ int* pRowStride,
+ const int nTilePosX, const int nTilePosY,
+ const int nTileWidth, const int nTileHeight)
{
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
commit 7453090d34a427ea7a76590a1c327e4965d6dbdd
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Sun May 25 16:42:17 2014 +0100
Upgrade gtktiledviewer to use its own buffer.
Change-Id: I3f567ff19ee0d5b0d54aeef9b163b78567d72946
diff --git a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
index fb8b276..18506a7 100644
--- a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -32,6 +32,7 @@ static int help()
}
static GtkWidget* ourCanvas;
+static GdkPixbuf* ourPixBuf = 0;
bool drawCallback(GtkWidget* /* The eventbox */, void* /* cairo_t* cr */, gpointer pData)
{
@@ -46,25 +47,41 @@ bool drawCallback(GtkWidget* /* The eventbox */, void* /* cairo_t* cr */, gpoint
int nRenderWidth = nWidth / 10;
int nRenderHeight = nHeight / 10;
int nRowStride;
- unsigned char* pBuffer = pDocument->paintTile( nRenderWidth, nRenderHeight,
- &nRowStride,
- 0, 0, // origin
- nWidth, nHeight );
+
+ if ( ourPixBuf &&
+ (gdk_pixbuf_get_width( ourPixBuf ) != nRenderWidth ||
+ gdk_pixbuf_get_height( ourPixBuf ) != nRenderHeight ) )
+ {
+ g_object_unref( G_OBJECT( ourPixBuf ) );
+ ourPixBuf = 0;
+
+ }
+ if (!ourPixBuf)
+ {
+ ourPixBuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB,
+ true, 8,
+ nRenderWidth, nRenderHeight);
+ }
+
+ unsigned char* pBuffer = gdk_pixbuf_get_pixels( ourPixBuf );
+
+ pDocument->paintTile( pBuffer,
+ nRenderWidth, nRenderHeight,
+ &nRowStride,
+ 0, 0, // origin
+ nWidth, nHeight );
+ // 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;
for (int i = 3; i < nRowStride*nRenderHeight; i += 4)
{
pBuffer[i] = 0xFF;
}
- GdkPixbuf* pBixBuf = gdk_pixbuf_new_from_data( pBuffer, GDK_COLORSPACE_RGB,
- true, 8,
- nRenderWidth, nRenderHeight,
- nRowStride,
- 0, 0 );
- pBixBuf = gdk_pixbuf_flip( pBixBuf, false );
- gtk_image_set_from_pixbuf( GTK_IMAGE(ourCanvas), pBixBuf );
+ gtk_image_set_from_pixbuf( GTK_IMAGE( ourCanvas ), ourPixBuf );
- // TODO: we need to keep track of and cleanup these buffers etc.
return true;
}
@@ -115,7 +132,6 @@ int main( int argc, char* argv[] )
ourCanvas = pCanvas;
gtk_container_add( GTK_CONTAINER( pEventBox ), pCanvas );
-
g_signal_connect( G_OBJECT(pEventBox), "button-press-event", G_CALLBACK(drawCallback), pDocument);
gtk_widget_show( pCanvas );
commit 267e01248ce51cd8b4cc5a857a71841c0f9fe6d5
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Wed Jun 11 16:24:33 2014 +0100
Use external buffer for LibLO tiled rendering.
Means we can get rid of hackily storing a reference to the last
buffer we created.
Change-Id: I8092a7d87bc391301f75651a59b37fbd73ac64fd
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index a9a2d08..372771e 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -71,6 +71,17 @@ typedef struct
const char *filterName;
} ExtensionMap;
+// We need a shared_array for passing into the BitmapDevice (via
+// VirtualDevice.SetOutputSizePixelScaleOffsetAndBuffer which goes via the
+// SvpVirtualDevice, ending up in the basebmp BitmapDevice. However as we're
+// given the array externally we can't delete it, and hence need to override
+// shared_array's default of deleting its pointer.
+template<typename T>
+struct NoDelete
+{
+ void operator()(T* /* p */) {}
+};
+
static const ExtensionMap aWriterExtensionMap[] =
{
{ "doc", "MS Word 97" },
@@ -168,12 +179,13 @@ static int doc_saveAsWithOptions(LibreOfficeKitDocument* pThis, const char* pUr
static LibreOfficeKitDocumentType doc_getDocumentType(LibreOfficeKitDocument* pThis);
static int doc_getNumberOfParts(LibreOfficeKitDocument* pThis);
static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart);
-static unsigned char* doc_paintTile(LibreOfficeKitDocument* pThis,
+void doc_paintTile(LibreOfficeKitDocument* pThis,
+ unsigned char* pBuffer,
const int nCanvasWidth, const int nCanvasHeight,
int* pRowStride,
const int nTilePosX, const int nTilePosY,
const int nTileWidth, const int nTileHeight);
-static void doc_getDocumentSize(LibreOfficeDocument* pThis,
+static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
long* pWidth,
long* pHeight);
@@ -374,14 +386,6 @@ static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart)
(void) nPart;
}
-// TODO: Temporary hack -- we need to keep the buffer alive while we paint it
-// in the gtk tiled viewer -- we can't pass out the shared_array through
-// the C interface, so maybe we want some sort of wrapper where we can return
-// a handle which we then associate with a given shared_array within LibLO
-// (where the client then has to tell us when they are finished with using
-// the buffer).
-boost::shared_array< sal_uInt8 > ourBuffer;
-
// TODO: Not 100% sure about the bitmap buffer format yet -- it appears
// to just be RGB, 8 bits per sample, and vertically mirrored compared
// to what gtk expects.
@@ -399,7 +403,8 @@ boost::shared_array< sal_uInt8 > ourBuffer;
// We probably also want to use getScanlineStride() -- I'm guessing that
// this is where we are actually just returning a sub-portion of a larger buffer
// which /shouldn't/ apply in our case, but better to be safe here.
-static unsigned char* doc_paintTile (LibreOfficeKitDocument* pThis,
+void doc_paintTile (LibreOfficeKitDocument* pThis,
+ unsigned char* pBuffer,
const int nCanvasWidth, const int nCanvasHeight,
int* pRowStride,
const int nTilePosX, const int nTilePosY,
@@ -407,8 +412,6 @@ static unsigned char* doc_paintTile (LibreOfficeKitDocument* pThis,
{
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
- unsigned char* pRet = 0;
-
Application::AcquireSolarMutex(1);
{
SwXTextDocument* pTxtDoc = dynamic_cast< SwXTextDocument* >( pDocument->mxComponent.get() );
@@ -421,6 +424,10 @@ static unsigned char* doc_paintTile (LibreOfficeKitDocument* pThis,
pSalInstance->setBitCountFormatMapping( 32, ::basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA );
VirtualDevice aDevice(0, (sal_uInt16)32);
+ boost::shared_array< sal_uInt8 > aBuffer( pBuffer, NoDelete< sal_uInt8 >() );
+ aDevice.SetOutputSizePixelScaleOffsetAndBuffer(
+ Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
+ aBuffer, true );
pViewShell->PaintTile(aDevice, nCanvasWidth, nCanvasHeight,
nTilePosX, nTilePosY, nTileWidth, nTileHeight);
@@ -429,16 +436,11 @@ static unsigned char* doc_paintTile (LibreOfficeKitDocument* pThis,
basebmp::BitmapDeviceSharedPtr pBmpDev = pSalDev->getBitmapDevice();
*pRowStride = pBmpDev->getScanlineStride();
- ourBuffer = pBmpDev->getBuffer();
-
- pRet = ourBuffer.get();
}
Application::ReleaseSolarMutex();
-
- return pRet;
}
-static void doc_getDocumentSize(LibreOfficeDocument* pThis,
+static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
long* pWidth,
long* pHeight)
{
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 95bf673..9895631 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -77,7 +77,8 @@ struct _LibreOfficeKitDocument
// for its internal buffer, i.e. the rowstride for the buffer may be larger
// than the desired width, hence we need to be able to return the
// rowstride too.
- unsigned char* (*paintTile) (LibreOfficeKitDocument* pThis,
+ void (*paintTile) (LibreOfficeKitDocument* pThis,
+ unsigned char* pBuffer,
const int nCanvasWidth,
const int nCanvasHeight,
int* pRowStride,
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index fb16758..9a17392 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -69,7 +69,9 @@ public:
mpDoc->setPart(mpDoc, nPart);
}
- inline unsigned char* paintTile(const int nCanvasWidth,
+ inline void paintTile(
+ unsigned char* pBuffer,
+ const int nCanvasWidth,
const int nCanvasHeight,
int* pRowStride,
const int nTilePosX,
@@ -77,7 +79,7 @@ public:
const int nTileWidth,
const int nTileHeight)
{
- return mpDoc->paintTile(mpDoc, nCanvasWidth, nCanvasHeight, pRowStride,
+ return mpDoc->paintTile(mpDoc, pBuffer, nCanvasWidth, nCanvasHeight, pRowStride,
nTilePosX, nTilePosY, nTileWidth, nTileHeight);
}
commit a6f51ef304d46f1a244c43c8802d9e9a787d419b
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Sun May 25 16:40:47 2014 +0100
Allow passing in external buffers to svp's VirtualDevice.
We also want to be able to set whether or not the buffers
should be painted to top down, so add that parameter
as necessary (default seems to be false, however e.g. gtk
requires this to be true, i.e. needed for tiled rendering).
Change-Id: Id98882e4c7f62508ae5a976c0d8df743460a4ab2
diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx
index 74a6174..8c36f52 100644
--- a/include/vcl/virdev.hxx
+++ b/include/vcl/virdev.hxx
@@ -43,8 +43,12 @@ private:
sal_uInt8 meRefDevMode;
SAL_DLLPRIVATE void ImplInitVirDev( const OutputDevice* pOutDev, long nDX, long nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData = NULL );
- SAL_DLLPRIVATE bool InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase, const basebmp::RawMemorySharedArray &pBuffer );
- SAL_DLLPRIVATE bool ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, const basebmp::RawMemorySharedArray &pBuffer );
+ SAL_DLLPRIVATE bool InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
+ const basebmp::RawMemorySharedArray &pBuffer,
+ const bool bTopDown );
+ SAL_DLLPRIVATE bool ImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
+ const basebmp::RawMemorySharedArray &pBuffer,
+ const bool bTopDown );
// Copy assignment is forbidden and not implemented.
VirtualDevice (const VirtualDevice &);
@@ -119,7 +123,11 @@ public:
virtual void EnableRTL( bool bEnable = true ) SAL_OVERRIDE;
bool SetOutputSizePixel( const Size& rNewSize, bool bErase = true );
- bool SetOutputSizePixelScaleOffsetAndBuffer( const Size& rNewSize, const Fraction& rScale, const Point& rNewOffset, const basebmp::RawMemorySharedArray &pBuffer );
+ bool SetOutputSizePixelScaleOffsetAndBuffer( const Size& rNewSize,
+ const Fraction& rScale,
+ const Point& rNewOffset,
+ const basebmp::RawMemorySharedArray &pBuffer,
+ const bool bTopDown = false );
bool SetOutputSize( const Size& rNewSize, bool bErase = true )
{ return SetOutputSizePixel( LogicToPixel( rNewSize ), bErase ); }
diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx
index d85cd8c..dc280db 100644
--- a/vcl/headless/svpvd.cxx
+++ b/vcl/headless/svpvd.cxx
@@ -52,10 +52,12 @@ void SvpSalVirtualDevice::ReleaseGraphics( SalGraphics* pGraphics )
bool SvpSalVirtualDevice::SetSize( long nNewDX, long nNewDY )
{
- return SetSizeUsingBuffer( nNewDX, nNewDY, basebmp::RawMemorySharedArray() );
+ return SetSizeUsingBuffer( nNewDX, nNewDY, basebmp::RawMemorySharedArray(), false );
}
-bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY, const basebmp::RawMemorySharedArray &pBuffer )
+bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY,
+ const basebmp::RawMemorySharedArray &pBuffer,
+ const bool bTopDown )
{
B2IVector aDevSize( nNewDX, nNewDY );
if( aDevSize.getX() == 0 )
@@ -73,13 +75,13 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY, const ba
std::vector< basebmp::Color > aDevPal(2);
aDevPal.push_back( basebmp::Color( 0, 0, 0 ) );
aDevPal.push_back( basebmp::Color( 0xff, 0xff, 0xff ) );
- m_aDevice = createBitmapDevice( aDevSize, false, nFormat, PaletteMemorySharedVector( new std::vector< basebmp::Color >(aDevPal) ) );
+ m_aDevice = createBitmapDevice( aDevSize, bTopDown, nFormat, PaletteMemorySharedVector( new std::vector< basebmp::Color >(aDevPal) ) );
}
else
{
m_aDevice = pBuffer ?
- createBitmapDevice( aDevSize, false, nFormat, pBuffer, PaletteMemorySharedVector() )
- : createBitmapDevice( aDevSize, false, nFormat );
+ createBitmapDevice( aDevSize, bTopDown, nFormat, pBuffer, PaletteMemorySharedVector() )
+ : createBitmapDevice( aDevSize, bTopDown, nFormat );
}
// update device in existing graphics
diff --git a/vcl/inc/headless/svpvd.hxx b/vcl/inc/headless/svpvd.hxx
index e4d37fc..f6a9cc5 100644
--- a/vcl/inc/headless/svpvd.hxx
+++ b/vcl/inc/headless/svpvd.hxx
@@ -45,7 +45,10 @@ public:
virtual void ReleaseGraphics( SalGraphics* pGraphics ) SAL_OVERRIDE;
virtual bool SetSize( long nNewDX, long nNewDY ) SAL_OVERRIDE;
- virtual bool SetSizeUsingBuffer( long nNewDX, long nNewDY, const basebmp::RawMemorySharedArray &pBuffer ) SAL_OVERRIDE;
+ virtual bool SetSizeUsingBuffer( long nNewDX, long nNewDY,
+ const basebmp::RawMemorySharedArray &pBuffer,
+ const bool bTopDown
+ ) SAL_OVERRIDE;
virtual void GetSize( long& rWidth, long& rHeight ) SAL_OVERRIDE;
basebmp::BitmapDeviceSharedPtr getBitmapDevice() { return m_aDevice; }
diff --git a/vcl/inc/salvd.hxx b/vcl/inc/salvd.hxx
index 842429f..0cac639 100644
--- a/vcl/inc/salvd.hxx
+++ b/vcl/inc/salvd.hxx
@@ -40,9 +40,13 @@ public:
virtual bool SetSize( long nNewDX, long nNewDY ) = 0;
// Set new size using a buffer at the given address
- virtual bool SetSizeUsingBuffer( long nNewDX, long nNewDY, const basebmp::RawMemorySharedArray & /* pBuffer */ )
+ virtual bool SetSizeUsingBuffer( long nNewDX, long nNewDY,
+ const basebmp::RawMemorySharedArray & /* pBuffer */,
+ const bool /* bTopDown */
+ )
{
- // Only the headless virtual device has an implementation that uses pBuffer.
+ // Only the headless virtual device has an implementation that uses
+ // pBuffer (and bTopDown).
return SetSize( nNewDX, nNewDY );
}
diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx
index 6378785..54cd376 100644
--- a/vcl/source/gdi/virdev.cxx
+++ b/vcl/source/gdi/virdev.cxx
@@ -267,7 +267,9 @@ VirtualDevice::~VirtualDevice()
pSVData->maGDIData.mpLastVirDev = mpPrev;
}
-bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase, const basebmp::RawMemorySharedArray &pBuffer )
+bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
+ const basebmp::RawMemorySharedArray &pBuffer,
+ const bool bTopDown )
{
SAL_INFO( "vcl.gdi",
"VirtualDevice::InnerImplSetOutputSizePixel( " << rNewSize.Width() << ", "
@@ -296,7 +298,7 @@ bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, bool bEra
if ( bErase )
{
if ( pBuffer )
- bRet = mpVirDev->SetSizeUsingBuffer( nNewWidth, nNewHeight, pBuffer );
+ bRet = mpVirDev->SetSizeUsingBuffer( nNewWidth, nNewHeight, pBuffer, bTopDown );
else
bRet = mpVirDev->SetSize( nNewWidth, nNewHeight );
@@ -381,9 +383,11 @@ void VirtualDevice::ImplFillOpaqueRectangle( const Rectangle& rRect )
Pop();
}
-bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, const basebmp::RawMemorySharedArray &pBuffer )
+bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
+ const basebmp::RawMemorySharedArray &pBuffer,
+ const bool bTopDown )
{
- if( InnerImplSetOutputSizePixel(rNewSize, bErase, pBuffer) )
+ if( InnerImplSetOutputSizePixel(rNewSize, bErase, pBuffer, bTopDown) )
{
if( mnAlphaDepth != -1 )
{
@@ -397,7 +401,9 @@ bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, c
if( !mpAlphaVDev )
{
mpAlphaVDev = new VirtualDevice( *this, mnAlphaDepth );
- mpAlphaVDev->InnerImplSetOutputSizePixel(rNewSize, bErase, basebmp::RawMemorySharedArray() );
+ mpAlphaVDev->InnerImplSetOutputSizePixel(rNewSize, bErase,
+ basebmp::RawMemorySharedArray(),
+ bTopDown );
}
// TODO: copy full outdev state to new one, here. Also needed in outdev2.cxx:DrawOutDev
@@ -430,10 +436,12 @@ void VirtualDevice::EnableRTL( bool bEnable )
bool VirtualDevice::SetOutputSizePixel( const Size& rNewSize, bool bErase )
{
- return ImplSetOutputSizePixel( rNewSize, bErase, basebmp::RawMemorySharedArray() );
+ return ImplSetOutputSizePixel( rNewSize, bErase, basebmp::RawMemorySharedArray(), false );
}
-bool VirtualDevice::SetOutputSizePixelScaleOffsetAndBuffer( const Size& rNewSize, const Fraction& rScale, const Point& rNewOffset, const basebmp::RawMemorySharedArray &pBuffer )
+bool VirtualDevice::SetOutputSizePixelScaleOffsetAndBuffer(
+ const Size& rNewSize, const Fraction& rScale, const Point& rNewOffset,
+ const basebmp::RawMemorySharedArray &pBuffer, const bool bTopDown )
{
if (pBuffer) {
MapMode mm = GetMapMode();
@@ -442,7 +450,7 @@ bool VirtualDevice::SetOutputSizePixelScaleOffsetAndBuffer( const Size& rNewSize
mm.SetScaleY( rScale );
SetMapMode( mm );
}
- return ImplSetOutputSizePixel( rNewSize, true, pBuffer);
+ return ImplSetOutputSizePixel( rNewSize, true, pBuffer, bTopDown );
}
void VirtualDevice::SetReferenceDevice( RefDevMode i_eRefDevMode )
commit cc00ccf604415680f1d2642a087ded0341fa2093
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri May 23 20:02:05 2014 +0100
Upgrade gtktiledviewer to RGBA.
The Alpha channel seems to be set incorrectly by LO, hence
we need to manually set it here for now.
Change-Id: I1f9091b8b6f88c1dba6653dfb7bf51f9fe14b3fc
diff --git a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
index e462e8d..fb8b276 100644
--- a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -51,9 +51,13 @@ bool drawCallback(GtkWidget* /* The eventbox */, void* /* cairo_t* cr */, gpoint
0, 0, // origin
nWidth, nHeight );
+ for (int i = 3; i < nRowStride*nRenderHeight; i += 4)
+ {
+ pBuffer[i] = 0xFF;
+ }
GdkPixbuf* pBixBuf = gdk_pixbuf_new_from_data( pBuffer, GDK_COLORSPACE_RGB,
- false, 8,
+ true, 8,
nRenderWidth, nRenderHeight,
nRowStride,
0, 0 );
commit e9878a22be125abe8ce9d0f830e6190a73dd1e4a
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri May 23 20:00:58 2014 +0100
Upgrade LibLO tiled rendering to RGBA.
This is the expected format for gtk+ pixbufs which is currently
the primary target. We could potentially allow the user to choose
the format via LibLO -- but we want to eventually allow passing
in a buffer (rather than passing out an LO owned buffer) anyway, so
should add that then.
Change-Id: I8427925a94366917fa82fb8ea28e7dbb3fa1840d
diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk
index 06527bb..671ff12 100644
--- a/desktop/Library_sofficeapp.mk
+++ b/desktop/Library_sofficeapp.mk
@@ -54,6 +54,7 @@ $(eval $(call gb_Library_use_libraries,sofficeapp,\
ucbhelper \
utl \
vcl \
+ vclplug_svp \
$(gb_UWINAPI) \
))
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index c102a67..a9a2d08 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -49,7 +49,10 @@
#include <unotxdoc.hxx>
#include <viewsh.hxx>
-// And let's also grab the SvpSalVirtualDevice
+#include <salinst.hxx>
+
+// And let's also grab the SvpSalInstance and SvpSalVirtualDevice
+#include <headless/svpinst.hxx>
#include <headless/svpvd.hxx>
#include <basebmp/bitmapdevice.hxx>
@@ -413,7 +416,11 @@ static unsigned char* doc_paintTile (LibreOfficeKitDocument* pThis,
SwDoc* pDoc = pDocShell->GetDoc();
SwViewShell* pViewShell = pDoc->GetCurrentViewShell();
- VirtualDevice aDevice(0, (sal_uInt16)0);
+ ImplSVData* pSVData = ImplGetSVData();
+ SvpSalInstance* pSalInstance = static_cast< SvpSalInstance* >(pSVData->mpDefInst);
+ pSalInstance->setBitCountFormatMapping( 32, ::basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA );
+
+ VirtualDevice aDevice(0, (sal_uInt16)32);
pViewShell->PaintTile(aDevice, nCanvasWidth, nCanvasHeight,
nTilePosX, nTilePosY, nTileWidth, nTileHeight);
commit f508746dbd49e2dad49116cab027c119c6655d3e
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri May 23 19:59:03 2014 +0100
svp: deduplicate bitcount->colourspace mapping and allow overriding.
Although svp defaults to BGR, we might want to use alternative
formats (e.g. for tiled rendering to bitmap buffers which are
to be used in e.g. gtk), it is probably safest to keep the current
defaults but allow the user to change to whatever format they may
require. (This currently only makes sense for the 32-bit
RGBA/ARGB/etc. formats. However the 23 bit formats could potentially
be expanded to allow a similar RGB/BGR choice.)
Change-Id: I70bd3d6e7d297faef163b910f576655efee4cb3f
diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx
index 3e08e90..0a81fdc 100644
--- a/vcl/headless/svpbmp.cxx
+++ b/vcl/headless/svpbmp.cxx
@@ -20,6 +20,7 @@
#ifndef IOS
#include "headless/svpbmp.hxx"
+#include "headless/svpinst.hxx"
#include <basegfx/vector/b2ivector.hxx>
#include <basegfx/range/b2ibox.hxx>
@@ -40,25 +41,12 @@ bool SvpSalBitmap::Create( const Size& rSize,
sal_uInt16 nBitCount,
const BitmapPalette& rPalette )
{
- basebmp::Format nFormat = SVP_DEFAULT_BITMAP_FORMAT;
SAL_INFO( "vcl.headless", "SvpSalBitmap::Create(" << rSize.Width() << "," << rSize.Height() << "," << nBitCount << ")" );
- switch( nBitCount )
- {
- case 1: nFormat = FORMAT_ONE_BIT_MSB_PAL; break;
- case 4: nFormat = FORMAT_FOUR_BIT_MSB_PAL; break;
- case 8: nFormat = FORMAT_EIGHT_BIT_PAL; break;
-#ifdef OSL_BIGENDIAN
- case 16: nFormat = FORMAT_SIXTEEN_BIT_MSB_TC_MASK; break;
-#else
- case 16: nFormat = FORMAT_SIXTEEN_BIT_LSB_TC_MASK; break;
-#endif
- case 24: nFormat = FORMAT_TWENTYFOUR_BIT_TC_MASK; break;
-#ifdef ANDROID
- case 32: nFormat = FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA; break;
-#else
- case 32: nFormat = FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA; break;
-#endif
- }
+
+ SvpSalInstance* pInst = SvpSalInstance::s_pDefaultInstance;
+ assert( pInst );
+ basebmp::Format nFormat = pInst->getFormatForBitCount( nBitCount );
+
B2IVector aSize( rSize.Width(), rSize.Height() );
if( aSize.getX() == 0 )
aSize.setX( 1 );
diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx
index 2ce2a01..3fa2226 100644
--- a/vcl/headless/svpinst.cxx
+++ b/vcl/headless/svpinst.cxx
@@ -45,6 +45,8 @@
// FIXME: remove when we re-work the svp mainloop
#include <unx/salunxtime.h>
+using namespace basebmp;
+
bool SvpSalInstance::isFrameAlive( const SalFrame* pFrame ) const
{
for( std::list< SalFrame* >::const_iterator it = m_aFrames.begin();
@@ -405,4 +407,47 @@ void SvpSalTimer::Start( sal_uLong nMS )
m_pInstance->StartTimer( nMS );
}
+void SvpSalInstance::setBitCountFormatMapping( sal_uInt16 nBitCount,
+ Format aFormat )
+{
+ m_aBitCountFormatMap[nBitCount] = aFormat;
+}
+
+Format SvpSalInstance::getFormatForBitCount( sal_uInt16 nBitCount )
+{
+ BitCountFormatMap::iterator aIt;
+ if ( (aIt = m_aBitCountFormatMap.find( nBitCount )) != m_aBitCountFormatMap.end() )
+ {
+ return aIt->second;
+ }
+
+ switch( nBitCount )
+ {
+ case 1:
+ return FORMAT_ONE_BIT_MSB_PAL;
+ case 4:
+ return FORMAT_FOUR_BIT_MSB_PAL;
+ case 8:
+ return FORMAT_EIGHT_BIT_PAL;
+ case 16:
+#ifdef OSL_BIGENDIAN
+ return FORMAT_SIXTEEN_BIT_MSB_TC_MASK;
+#else
+ return FORMAT_SIXTEEN_BIT_LSB_TC_MASK;
+#endif
+ case 24:
+ return FORMAT_TWENTYFOUR_BIT_TC_MASK;
+ case 32:
+ return FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA;
+ case 0:
+#ifdef ANDROID
+ return FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA;
+#else
+ return FORMAT_TWENTYFOUR_BIT_TC_MASK;
+#endif
+ default:
+ return SVP_DEFAULT_BITMAP_FORMAT;
+ }
+
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx
index e5a20b5..d85cd8c 100644
--- a/vcl/headless/svpvd.cxx
+++ b/vcl/headless/svpvd.cxx
@@ -20,6 +20,7 @@
#ifndef IOS
#include "headless/svpbmp.hxx"
+#include "headless/svpinst.hxx"
#include "headless/svpvd.hxx"
#include "headless/svpgdi.hxx"
@@ -63,36 +64,23 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY, const ba
aDevSize.setY( 1 );
if( ! m_aDevice.get() || m_aDevice->getSize() != aDevSize )
{
- basebmp::Format nFormat = SVP_DEFAULT_BITMAP_FORMAT;
- std::vector< basebmp::Color > aDevPal;
- switch( m_nBitCount )
+ SvpSalInstance* pInst = SvpSalInstance::s_pDefaultInstance;
+ assert( pInst );
+ basebmp::Format nFormat = pInst->getFormatForBitCount( m_nBitCount );
+
+ if ( m_nBitCount == 1 )
{
- case 1: nFormat = FORMAT_ONE_BIT_MSB_PAL;
- aDevPal.reserve(2);
- aDevPal.push_back( basebmp::Color( 0, 0, 0 ) );
- aDevPal.push_back( basebmp::Color( 0xff, 0xff, 0xff ) );
- break;
- case 4: nFormat = FORMAT_FOUR_BIT_MSB_PAL; break;
- case 8: nFormat = FORMAT_EIGHT_BIT_PAL; break;
-#ifdef OSL_BIGENDIAN
- case 16: nFormat = FORMAT_SIXTEEN_BIT_MSB_TC_MASK; break;
-#else
- case 16: nFormat = FORMAT_SIXTEEN_BIT_LSB_TC_MASK; break;
-#endif
- case 24: nFormat = FORMAT_TWENTYFOUR_BIT_TC_MASK; break;
- case 32: nFormat = FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA; break;
-#ifdef ANDROID
- case 0: nFormat = FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA; break;
-#else
- case 0: nFormat = FORMAT_TWENTYFOUR_BIT_TC_MASK; break;
-#endif
+ std::vector< basebmp::Color > aDevPal(2);
+ aDevPal.push_back( basebmp::Color( 0, 0, 0 ) );
+ aDevPal.push_back( basebmp::Color( 0xff, 0xff, 0xff ) );
+ m_aDevice = createBitmapDevice( aDevSize, false, nFormat, PaletteMemorySharedVector( new std::vector< basebmp::Color >(aDevPal) ) );
+ }
+ else
+ {
+ m_aDevice = pBuffer ?
+ createBitmapDevice( aDevSize, false, nFormat, pBuffer, PaletteMemorySharedVector() )
+ : createBitmapDevice( aDevSize, false, nFormat );
}
- m_aDevice = aDevPal.empty()
- ? ( pBuffer
- ? createBitmapDevice( aDevSize, false, nFormat, pBuffer, PaletteMemorySharedVector() )
- : createBitmapDevice( aDevSize, false, nFormat )
- )
- : createBitmapDevice( aDevSize, false, nFormat, PaletteMemorySharedVector( new std::vector< basebmp::Color >(aDevPal) ) );
// update device in existing graphics
for( std::list< SvpSalGraphics* >::iterator it = m_aGraphics.begin();
diff --git a/vcl/inc/headless/svpinst.hxx b/vcl/inc/headless/svpinst.hxx
index dd557d1..0bf542f 100644
--- a/vcl/inc/headless/svpinst.hxx
+++ b/vcl/inc/headless/svpinst.hxx
@@ -27,6 +27,7 @@
#include <saltimer.hxx>
#include <generic/geninst.h>
#include <generic/genprn.h>
+#include <basebmp/scanlineformats.hxx>
#include <list>
@@ -84,6 +85,9 @@ class SvpSalInstance : public SalGenericInstance
void DoReleaseYield( int nTimeoutMS );
+ typedef std::map< sal_uInt16, ::basebmp::Format > BitCountFormatMap;
+ BitCountFormatMap m_aBitCountFormatMap;
+
public:
static SvpSalInstance* s_pDefaultInstance;
@@ -161,6 +165,14 @@ public:
virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) SAL_OVERRIDE;
virtual GenPspGraphics *CreatePrintGraphics() SAL_OVERRIDE;
+
+ // We want to be able to select colourspace, i.e. ARGB vs RGBA vs BGRA etc.
+ // -- as the rest of vcl always uses bit depths, it is perhaps simplest
+ // to let us simply change the mapping of bitcount to format (which was
+ // previously unchangeable).
+ SAL_DLLPUBLIC_EXPORT void setBitCountFormatMapping( sal_uInt16 nBitCount, ::basebmp::Format aFormat );
+
+ SAL_DLLPUBLIC_EXPORT ::basebmp::Format getFormatForBitCount( sal_uInt16 );
};
#endif // INCLUDED_VCL_INC_HEADLESS_SVPINST_HXX
commit de0818168dcd0a1c420073ac0423997c91ab6b78
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Sun May 18 08:37:13 2014 +0100
Draw the whole image for our gtk tiled viewer.
We just draw one huge tile, it doesn't seem to work too well
for larger documents though where the latter portions can appear
empty.
Change-Id: Ic527aec377bf2f82a528a04392186d3d8b752762
diff --git a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
index 55216fc..e462e8d 100644
--- a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -39,11 +39,23 @@ bool drawCallback(GtkWidget* /* The eventbox */, void* /* cairo_t* cr */, gpoint
Document* pDocument = static_cast< Document* >( pData );
- // Hardcoded tile just to see whether or not we get any sort of output.
- unsigned char* pBuffer = pDocument->paintTile( 1000, 1000, 0, 0, 10000, 10000 );
+ long nWidth, nHeight;
+ pDocument->getDocumentSize( &nWidth, &nHeight );
+
+ // Draw the whole document at once (for now)
+ int nRenderWidth = nWidth / 10;
+ int nRenderHeight = nHeight / 10;
+ int nRowStride;
+ unsigned char* pBuffer = pDocument->paintTile( nRenderWidth, nRenderHeight,
+ &nRowStride,
+ 0, 0, // origin
+ nWidth, nHeight );
+
GdkPixbuf* pBixBuf = gdk_pixbuf_new_from_data( pBuffer, GDK_COLORSPACE_RGB,
- false, 8, 1000, 1000, 3*1000,
+ false, 8,
+ nRenderWidth, nRenderHeight,
+ nRowStride,
0, 0 );
pBixBuf = gdk_pixbuf_flip( pBixBuf, false );
gtk_image_set_from_pixbuf( GTK_IMAGE(ourCanvas), pBixBuf );
commit 9cc0a903ed21dab659ab655afc731f024db703f5
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Sun May 18 08:36:16 2014 +0100
Implement document size retrieval for LibLO.
Change-Id: Ibd69f8e766fd421b05d2305f967179a969bc5b56
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index d3b36c9..c102a67 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -170,6 +170,9 @@ static unsigned char* doc_paintTile(LibreOfficeKitDocument* pThis,
int* pRowStride,
const int nTilePosX, const int nTilePosY,
const int nTileWidth, const int nTileHeight);
+static void doc_getDocumentSize(LibreOfficeDocument* pThis,
+ long* pWidth,
+ long* pHeight);
struct LibLODocument_Impl : public _LibreOfficeKitDocument
{
@@ -187,6 +190,7 @@ struct LibLODocument_Impl : public _LibreOfficeKitDocument
getNumberOfParts = doc_getNumberOfParts;
setPart = doc_setPart;
paintTile = doc_paintTile;
+ getDocumentSize = doc_getDocumentSize;
}
~LibLODocument_Impl()
@@ -427,6 +431,24 @@ static unsigned char* doc_paintTile (LibreOfficeKitDocument* pThis,
return pRet;
}
+static void doc_getDocumentSize(LibreOfficeDocument* pThis,
+ long* pWidth,
+ long* pHeight)
+{
+ LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
+
+ if (true) // TODO: test that we have a writer document here (vs calc/impress/etc.)
+ {
+ SwXTextDocument* pTxtDoc = dynamic_cast< SwXTextDocument* >( pDocument->mxComponent.get() );
+ SwDocShell* pDocShell = pTxtDoc->GetDocShell();
+ SwDoc* pDoc = pDocShell->GetDoc();
+ SwViewShell* pViewShell = pDoc->GetCurrentViewShell();
+ Size aDocumentSize = pViewShell->GetDocSize();
+ *pWidth = aDocumentSize.Width();
+ *pHeight = aDocumentSize.Height();
+ }
+}
+
static char* lo_getError (LibreOfficeKit *pThis)
{
LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 2afcf83..95bf673 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -85,6 +85,11 @@ struct _LibreOfficeKitDocument
const int nTilePosY,
const int nTileWidth,
const int nTileHeight);
+
+ // Get the document sizes in twips.
+ void (*getDocumentSize) (LibreOfficeKitDocument* pThis,
+ long* pWidth,
+ long* pHeight);
#endif // LOK_USE_UNSTABLE_API
};
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index ef2793d..fb16758 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -80,6 +80,11 @@ public:
return mpDoc->paintTile(mpDoc, nCanvasWidth, nCanvasHeight, pRowStride,
nTilePosX, nTilePosY, nTileWidth, nTileHeight);
}
+
+ inline void getDocumentSize(long* pWidth, long* pHeight)
+ {
+ mpDoc->getDocumentSize(mpDoc, pWidth, pHeight);
+ }
#endif // LOK_USE_UNSTABLE_API
};
commit 4c0eb3585d2a498a6a8951ba5621bf47d145cbe4
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Sun May 18 08:30:15 2014 +0100
Add rowstride to tiled rendering via LibLO.
The buffer width could be larger than the desired rendering
width, hence we need to give the client access to the rowstride.
Change-Id: Ic63c1f455c89960164e076ed2528d43e64e81a40
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index d51861f..d3b36c9 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -167,6 +167,7 @@ static int doc_getNumberOfParts(LibreOfficeKitDocument* pThis);
static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart);
static unsigned char* doc_paintTile(LibreOfficeKitDocument* pThis,
const int nCanvasWidth, const int nCanvasHeight,
+ int* pRowStride,
const int nTilePosX, const int nTilePosY,
const int nTileWidth, const int nTileHeight);
@@ -393,6 +394,7 @@ boost::shared_array< sal_uInt8 > ourBuffer;
// which /shouldn't/ apply in our case, but better to be safe here.
static unsigned char* doc_paintTile (LibreOfficeKitDocument* pThis,
const int nCanvasWidth, const int nCanvasHeight,
+ int* pRowStride,
const int nTilePosX, const int nTilePosY,
const int nTileWidth, const int nTileHeight)
{
@@ -415,6 +417,7 @@ static unsigned char* doc_paintTile (LibreOfficeKitDocument* pThis,
SvpSalVirtualDevice* pSalDev = static_cast< SvpSalVirtualDevice* >(aDevice.getSalVirtualDevice());
basebmp::BitmapDeviceSharedPtr pBmpDev = pSalDev->getBitmapDevice();
+ *pRowStride = pBmpDev->getScanlineStride();
ourBuffer = pBmpDev->getBuffer();
pRet = ourBuffer.get();
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 34b53f8..2afcf83 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -73,9 +73,14 @@ struct _LibreOfficeKitDocument
int nPart);
// Get a pointer to a raw array, of size 3*nCanvasWidth*nCanvasHeight
+ // Basebmp's bitmap device seems to round the width up if needed
+ // for its internal buffer, i.e. the rowstride for the buffer may be larger
+ // than the desired width, hence we need to be able to return the
+ // rowstride too.
unsigned char* (*paintTile) (LibreOfficeKitDocument* pThis,
const int nCanvasWidth,
const int nCanvasHeight,
+ int* pRowStride,
const int nTilePosX,
const int nTilePosY,
const int nTileWidth,
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 7c07e1c..ef2793d 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -71,12 +71,13 @@ public:
inline unsigned char* paintTile(const int nCanvasWidth,
const int nCanvasHeight,
+ int* pRowStride,
const int nTilePosX,
const int nTilePosY,
const int nTileWidth,
const int nTileHeight)
{
- return mpDoc->paintTile(mpDoc, nCanvasWidth, nCanvasHeight,
+ return mpDoc->paintTile(mpDoc, nCanvasWidth, nCanvasHeight, pRowStride,
nTilePosX, nTilePosY, nTileWidth, nTileHeight);
}
#endif // LOK_USE_UNSTABLE_API
commit ae3408105c0bfd22bcf5804e7bb7a2d4ead7a49e
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri May 16 09:08:41 2014 +0100
Use bitmap buffers in the gtktiledviewer.
Looks pretty decent now -- however the vertical flipping isn't ideal.
Change-Id: I6ffa9d2b8fced142308781e06e8f161228f1db26
diff --git a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
index a4c23bb..55216fc 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;
}
@@ -98,16 +92,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);
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list