Return a bitmap buffer for tiled rendering from LibLO.
We still need some way of managing the buffers properly rather than just keeping a static reference to the last buffer that was rendered. Change-Id: I17940c758948aa9418f4e0216ecd253d128cd04f
This commit is contained in:
@@ -15,6 +15,7 @@ $(eval $(call gb_Library_set_include,sofficeapp,\
|
|||||||
-I$(SRCDIR)/desktop/source/inc \
|
-I$(SRCDIR)/desktop/source/inc \
|
||||||
-I$(SRCDIR)/desktop/source/deployment/inc \
|
-I$(SRCDIR)/desktop/source/deployment/inc \
|
||||||
-I$(SRCDIR)/sw/inc \
|
-I$(SRCDIR)/sw/inc \
|
||||||
|
-I$(SRCDIR)/vcl/inc \
|
||||||
))
|
))
|
||||||
|
|
||||||
$(eval $(call gb_Library_use_external,sofficeapp,boost_headers))
|
$(eval $(call gb_Library_use_external,sofficeapp,boost_headers))
|
||||||
@@ -35,6 +36,7 @@ $(eval $(call gb_Library_add_defs,sofficeapp,\
|
|||||||
$(eval $(call gb_Library_set_precompiled_header,sofficeapp,$(SRCDIR)/desktop/inc/pch/precompiled_sofficeapp))
|
$(eval $(call gb_Library_set_precompiled_header,sofficeapp,$(SRCDIR)/desktop/inc/pch/precompiled_sofficeapp))
|
||||||
|
|
||||||
$(eval $(call gb_Library_use_libraries,sofficeapp,\
|
$(eval $(call gb_Library_use_libraries,sofficeapp,\
|
||||||
|
basebmp \
|
||||||
comphelper \
|
comphelper \
|
||||||
cppu \
|
cppu \
|
||||||
cppuhelper \
|
cppuhelper \
|
||||||
|
@@ -54,7 +54,7 @@ bool drawCallback(GtkWidget* pCanvas, void* /* cairo_t* cr */, gpointer pData)
|
|||||||
GDK_VISUAL_XVISUAL( gtk_widget_get_visual( pCanvas ) ) );
|
GDK_VISUAL_XVISUAL( gtk_widget_get_visual( pCanvas ) ) );
|
||||||
|
|
||||||
// Hardcoded tile just to see whether or not we get any sort of output.
|
// Hardcoded tile just to see whether or not we get any sort of output.
|
||||||
pDocument->paintTile( &aSystemGraphicsData, 256, 256, 0, 0, 5000, 5000 );
|
pDocument->paintTile( 256, 256, 0, 0, 5000, 5000 );
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -53,6 +53,11 @@
|
|||||||
#include <unotxdoc.hxx>
|
#include <unotxdoc.hxx>
|
||||||
#include <viewsh.hxx>
|
#include <viewsh.hxx>
|
||||||
|
|
||||||
|
// And let's also grab the SvpSalVirtualDevice
|
||||||
|
#include <headless/svpvd.hxx>
|
||||||
|
|
||||||
|
#include <basebmp/bitmapdevice.hxx>
|
||||||
|
|
||||||
using namespace css;
|
using namespace css;
|
||||||
using namespace utl;
|
using namespace utl;
|
||||||
|
|
||||||
@@ -167,7 +172,7 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* pUrl, const ch
|
|||||||
static LibreOfficeKitDocumentType doc_getDocumentType(LibreOfficeKitDocument* pThis);
|
static LibreOfficeKitDocumentType doc_getDocumentType(LibreOfficeKitDocument* pThis);
|
||||||
static int doc_getNumberOfParts(LibreOfficeKitDocument* pThis);
|
static int doc_getNumberOfParts(LibreOfficeKitDocument* pThis);
|
||||||
static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart);
|
static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart);
|
||||||
static void doc_paintTile(LibreOfficeKitDocument* pThis, void* pCanvas,
|
static unsigned char* doc_paintTile(LibreOfficeKitDocument* pThis,
|
||||||
const int nCanvasWidth, const int nCanvasHeight,
|
const int nCanvasWidth, const int nCanvasHeight,
|
||||||
const int nTilePosX, const int nTilePosY,
|
const int nTilePosX, const int nTilePosY,
|
||||||
const int nTileWidth, const int nTileHeight);
|
const int nTileWidth, const int nTileHeight);
|
||||||
@@ -378,27 +383,39 @@ static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart)
|
|||||||
(void) nPart;
|
(void) nPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doc_paintTile (LibreOfficeKitDocument* pThis, void* pCanvas,
|
// 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.
|
||||||
|
// 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.
|
||||||
|
static unsigned char* doc_paintTile (LibreOfficeKitDocument* pThis,
|
||||||
const int nCanvasWidth, const int nCanvasHeight,
|
const int nCanvasWidth, const int nCanvasHeight,
|
||||||
const int nTilePosX, const int nTilePosY,
|
const int nTilePosX, const int nTilePosY,
|
||||||
const int nTileWidth, const int nTileHeight)
|
const int nTileWidth, const int nTileHeight)
|
||||||
{
|
{
|
||||||
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
|
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
|
||||||
|
|
||||||
// We can't use this on anything but Linux for now, so the following is
|
unsigned char* pRet = 0;
|
||||||
// likely unusable for now.
|
|
||||||
SystemGraphicsData aSystemGraphicsData;
|
|
||||||
#if defined( WNT )
|
|
||||||
aSystemGraphicsData.hDC = *static_cast< HDC* >(pCanvas);
|
|
||||||
#elif defined( MACOSX )
|
|
||||||
aSystemGraphicsData.rCGContext = *static_cast< CGContextRef* >(pCanvas);
|
|
||||||
#elif defined( ANDROID )
|
|
||||||
assert(false); // We can't use tiled rendering on Android in any case yet...
|
|
||||||
#elif defined( IOS )
|
|
||||||
aSystemGraphicsData.rCGContext = *static_cast< CGContextRef* >(pCanvas);
|
|
||||||
#elif defined( UNX )
|
|
||||||
aSystemGraphicsData = *static_cast< SystemGraphicsData*> (pCanvas);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Application::AcquireSolarMutex(1);
|
Application::AcquireSolarMutex(1);
|
||||||
{
|
{
|
||||||
@@ -407,11 +424,21 @@ static void doc_paintTile (LibreOfficeKitDocument* pThis, void* pCanvas,
|
|||||||
SwDoc* pDoc = pDocShell->GetDoc();
|
SwDoc* pDoc = pDocShell->GetDoc();
|
||||||
SwViewShell* pViewShell = pDoc->GetCurrentViewShell();
|
SwViewShell* pViewShell = pDoc->GetCurrentViewShell();
|
||||||
|
|
||||||
VirtualDevice aDevice(&aSystemGraphicsData, (sal_uInt16)0);
|
VirtualDevice aDevice(0, (sal_uInt16)0);
|
||||||
|
|
||||||
pViewShell->PaintTile(aDevice, nCanvasWidth, nCanvasHeight,
|
pViewShell->PaintTile(aDevice, nCanvasWidth, nCanvasHeight,
|
||||||
nTilePosX, nTilePosY, nTileWidth, nTileHeight);
|
nTilePosX, nTilePosY, nTileWidth, nTileHeight);
|
||||||
|
|
||||||
|
SvpSalVirtualDevice* pSalDev = static_cast< SvpSalVirtualDevice* >(aDevice.getSalVirtualDevice());
|
||||||
|
basebmp::BitmapDeviceSharedPtr pBmpDev = pSalDev->getBitmapDevice();
|
||||||
|
|
||||||
|
ourBuffer = pBmpDev->getBuffer();
|
||||||
|
|
||||||
|
pRet = ourBuffer.get();
|
||||||
}
|
}
|
||||||
Application::ReleaseSolarMutex();
|
Application::ReleaseSolarMutex();
|
||||||
|
|
||||||
|
return pRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char* lo_getError (LibreOfficeKit *pThis)
|
static char* lo_getError (LibreOfficeKit *pThis)
|
||||||
|
@@ -85,16 +85,8 @@ struct _LibreOfficeKitDocumentClass
|
|||||||
void (*setPart) (LibreOfficeKitDocument* pThis,
|
void (*setPart) (LibreOfficeKitDocument* pThis,
|
||||||
int nPart);
|
int nPart);
|
||||||
|
|
||||||
// pCanvas is a pointer to the appropriate type of graphics object:
|
// Get a pointer to a raw array, of size 3*nCanvasWidth*nCanvasHeight
|
||||||
// Windows: HDC
|
unsigned char* (*paintTile) (LibreOfficeKitDocument* pThis,
|
||||||
// iOS/OSX: CGContextRef
|
|
||||||
// Unx: A full SystemGraphicsData
|
|
||||||
// (This is as we need multiple pieces of data on Unx -- in the future
|
|
||||||
// it would potentially be best to define our own simple equivalent
|
|
||||||
// structure here which can then be copied into a SystemGraphicsData
|
|
||||||
// within the paintTile implementation.)
|
|
||||||
void (*paintTile) (LibreOfficeKitDocument* pThis,
|
|
||||||
void* Canvas,
|
|
||||||
const int nCanvasWidth,
|
const int nCanvasWidth,
|
||||||
const int nCanvasHeight,
|
const int nCanvasHeight,
|
||||||
const int nTilePosX,
|
const int nTilePosX,
|
||||||
|
@@ -59,16 +59,15 @@ public:
|
|||||||
mpDoc->pClass->setPart(mpDoc, nPart);
|
mpDoc->pClass->setPart(mpDoc, nPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void paintTile(void* pHandle,
|
inline unsigned char* paintTile(const int nCanvasWidth,
|
||||||
const int nCanvasWidth,
|
|
||||||
const int nCanvasHeight,
|
const int nCanvasHeight,
|
||||||
const int nTilePosX,
|
const int nTilePosX,
|
||||||
const int nTilePosY,
|
const int nTilePosY,
|
||||||
const int nTileWidth,
|
const int nTileWidth,
|
||||||
const int nTileHeight)
|
const int nTileHeight)
|
||||||
{
|
{
|
||||||
mpDoc->pClass->paintTile(mpDoc, pHandle, nCanvasWidth, nCanvasHeight,
|
return mpDoc->pClass->paintTile(mpDoc, nCanvasWidth, nCanvasHeight,
|
||||||
nTilePosX, nTilePosY, nTileWidth, nTileHeight);
|
nTilePosX, nTilePosY, nTileWidth, nTileHeight);
|
||||||
}
|
}
|
||||||
#endif // LOK_USE_UNSTABLE_API
|
#endif // LOK_USE_UNSTABLE_API
|
||||||
};
|
};
|
||||||
|
@@ -66,6 +66,8 @@ protected:
|
|||||||
virtual void ReleaseGraphics( bool bRelease = true ) SAL_OVERRIDE;
|
virtual void ReleaseGraphics( bool bRelease = true ) SAL_OVERRIDE;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
SalVirtualDevice* getSalVirtualDevice() { return mpVirDev; }
|
||||||
|
|
||||||
/** Create a virtual device of size 1x1
|
/** Create a virtual device of size 1x1
|
||||||
|
|
||||||
@param nBitCount
|
@param nBitCount
|
||||||
|
@@ -47,6 +47,8 @@ public:
|
|||||||
virtual bool SetSize( long nNewDX, long nNewDY ) 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 ) SAL_OVERRIDE;
|
||||||
virtual void GetSize( long& rWidth, long& rHeight ) SAL_OVERRIDE;
|
virtual void GetSize( long& rWidth, long& rHeight ) SAL_OVERRIDE;
|
||||||
|
|
||||||
|
basebmp::BitmapDeviceSharedPtr getBitmapDevice() { return m_aDevice; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INCLUDED_VCL_INC_HEADLESS_SVPVD_HXX
|
#endif // INCLUDED_VCL_INC_HEADLESS_SVPVD_HXX
|
||||||
|
Reference in New Issue
Block a user