diff options
author | Andrzej Hunt <andrzej.hunt@collabora.com> | 2014-06-11 16:24:33 +0100 |
---|---|---|
committer | Andrzej Hunt <andrzej.hunt@collabora.com> | 2014-06-25 13:04:30 +0100 |
commit | 67d7bad694928e8a5d7416de21c612822e14dadc (patch) | |
tree | 830d4242b51bdab71f39f7d18dc4901535234012 /desktop | |
parent | 56fea375b915bb96012b36012634523b9806040a (diff) |
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
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/lib/init.cxx | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 8f3bda47e410..e44e55225452 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -79,6 +79,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" }, @@ -175,12 +186,13 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* pUrl, const ch 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); @@ -391,14 +403,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. @@ -416,7 +420,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, @@ -424,8 +429,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() ); @@ -438,6 +441,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); @@ -446,16 +453,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) { |