summaryrefslogtreecommitdiff
path: root/canvas/source/directx
diff options
context:
space:
mode:
Diffstat (limited to 'canvas/source/directx')
-rw-r--r--canvas/source/directx/dx_9rm.cxx138
-rw-r--r--canvas/source/directx/dx_bitmap.cxx26
-rw-r--r--canvas/source/directx/dx_bitmap.hxx15
-rw-r--r--canvas/source/directx/dx_bitmapcanvashelper.cxx7
-rw-r--r--canvas/source/directx/dx_bitmapcanvashelper.hxx5
-rw-r--r--canvas/source/directx/dx_bitmapprovider.hxx15
-rw-r--r--canvas/source/directx/dx_canvas.cxx29
-rw-r--r--canvas/source/directx/dx_canvas.hxx5
-rw-r--r--canvas/source/directx/dx_canvasbitmap.cxx59
-rw-r--r--canvas/source/directx/dx_canvasbitmap.hxx5
-rw-r--r--canvas/source/directx/dx_canvascustomsprite.cxx6
-rw-r--r--canvas/source/directx/dx_canvascustomsprite.hxx5
-rw-r--r--canvas/source/directx/dx_canvasfont.hxx5
-rw-r--r--canvas/source/directx/dx_canvashelper.cxx46
-rw-r--r--canvas/source/directx/dx_canvashelper.hxx7
-rw-r--r--canvas/source/directx/dx_canvashelper_texturefill.cxx9
-rw-r--r--canvas/source/directx/dx_config.cxx14
-rw-r--r--canvas/source/directx/dx_config.hxx5
-rw-r--r--canvas/source/directx/dx_devicehelper.cxx29
-rw-r--r--canvas/source/directx/dx_devicehelper.hxx5
-rw-r--r--canvas/source/directx/dx_gdiplususer.hxx5
-rw-r--r--canvas/source/directx/dx_graphicsprovider.hxx5
-rw-r--r--canvas/source/directx/dx_ibitmap.hxx8
-rw-r--r--canvas/source/directx/dx_impltools.cxx28
-rw-r--r--canvas/source/directx/dx_impltools.hxx11
-rw-r--r--canvas/source/directx/dx_linepolypolygon.hxx5
-rw-r--r--canvas/source/directx/dx_rendermodule.hxx9
-rw-r--r--canvas/source/directx/dx_sprite.hxx5
-rw-r--r--canvas/source/directx/dx_spritecanvas.cxx13
-rw-r--r--canvas/source/directx/dx_spritecanvas.hxx5
-rw-r--r--canvas/source/directx/dx_spritecanvashelper.cxx2
-rw-r--r--canvas/source/directx/dx_spritecanvashelper.hxx5
-rw-r--r--canvas/source/directx/dx_spritedevicehelper.cxx6
-rw-r--r--canvas/source/directx/dx_spritedevicehelper.hxx5
-rw-r--r--canvas/source/directx/dx_spritehelper.cxx10
-rw-r--r--canvas/source/directx/dx_spritehelper.hxx5
-rw-r--r--canvas/source/directx/dx_surfacebitmap.cxx72
-rw-r--r--canvas/source/directx/dx_surfacebitmap.hxx17
-rw-r--r--canvas/source/directx/dx_surfacegraphics.cxx8
-rw-r--r--canvas/source/directx/dx_surfacegraphics.hxx19
-rw-r--r--canvas/source/directx/dx_textlayout.cxx27
-rw-r--r--canvas/source/directx/dx_textlayout.hxx8
-rw-r--r--canvas/source/directx/dx_textlayout_drawhelper.cxx28
-rw-r--r--canvas/source/directx/dx_textlayout_drawhelper.hxx10
-rw-r--r--canvas/source/directx/dx_vcltools.cxx273
-rw-r--r--canvas/source/directx/dx_vcltools.hxx12
-rw-r--r--canvas/source/directx/dx_winstuff.hxx91
47 files changed, 400 insertions, 727 deletions
diff --git a/canvas/source/directx/dx_9rm.cxx b/canvas/source/directx/dx_9rm.cxx
index 0c8667c5f7ea..93738b3455cf 100644
--- a/canvas/source/directx/dx_9rm.cxx
+++ b/canvas/source/directx/dx_9rm.cxx
@@ -31,7 +31,7 @@
#include <com/sun/star/lang/NoSupportException.hpp>
#include <osl/thread.hxx>
#include <osl/time.h>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <vcl/syschild.hxx>
#include <vcl/sysdata.hxx>
#include <vcl/window.hxx>
@@ -92,7 +92,7 @@ namespace dxcanvas
virtual bool update( const ::basegfx::B2IPoint& rDestPos,
const ::basegfx::B2IRange& rSourceRect,
::canvas::IColorBuffer& rSource ) override;
- virtual ::basegfx::B2IVector getSize();
+ virtual ::basegfx::B2ISize getSize();
private:
/// Guard local methods against concurrent access to RenderModule
@@ -111,9 +111,9 @@ namespace dxcanvas
};
DXRenderModule& mrRenderModule;
- COMReference<IDirect3DTexture9> mpTexture;
+ sal::systools::COMReference<IDirect3DTexture9> mpTexture;
- ::basegfx::B2IVector maSize;
+ ::basegfx::B2ISize maSize;
};
@@ -130,8 +130,8 @@ namespace dxcanvas
virtual void lock() const override { maMutex.acquire(); }
virtual void unlock() const override { maMutex.release(); }
- virtual COMReference<IDirect3DSurface9>
- createSystemMemorySurface( const ::basegfx::B2IVector& rSize ) override;
+ virtual sal::systools::COMReference<IDirect3DSurface9>
+ createSystemMemorySurface(const ::basegfx::B2ISize& rSize) override;
virtual void disposing() override;
virtual HWND getHWND() const override { return mhWnd; }
virtual void screenShot() override;
@@ -147,7 +147,7 @@ namespace dxcanvas
virtual void pushVertex( const ::canvas::Vertex& vertex ) override;
virtual bool isError() override;
- COMReference<IDirect3DDevice9> getDevice() { return mpDevice; }
+ sal::systools::COMReference<IDirect3DDevice9> getDevice() { return mpDevice; }
void flushVertexCache();
void commitVertexCache();
@@ -166,13 +166,13 @@ namespace dxcanvas
static ::osl::Mutex maMutex;
HWND mhWnd;
- COMReference<IDirect3DDevice9> mpDevice;
- COMReference<IDirect3D9> mpDirect3D9;
- COMReference<IDirect3DSwapChain9> mpSwapChain;
- COMReference<IDirect3DVertexBuffer9> mpVertexBuffer;
+ sal::systools::COMReference<IDirect3DDevice9> mpDevice;
+ sal::systools::COMReference<IDirect3D9> mpDirect3D9;
+ sal::systools::COMReference<IDirect3DSwapChain9> mpSwapChain;
+ sal::systools::COMReference<IDirect3DVertexBuffer9> mpVertexBuffer;
std::shared_ptr<canvas::ISurface> mpTexture;
VclPtr<SystemChildWindow> mpWindow;
- ::basegfx::B2IVector maSize;
+ ::basegfx::B2ISize maSize;
typedef std::vector<canvas::Vertex> vertexCache_t;
vertexCache_t maVertexCache;
std::size_t mnCount;
@@ -225,8 +225,7 @@ namespace dxcanvas
DXSurface::DXSurface( DXRenderModule& rRenderModule,
const ::basegfx::B2ISize& rSize ) :
mrRenderModule(rRenderModule),
- mpTexture(nullptr),
- maSize()
+ mpTexture(nullptr)
{
ImplRenderModuleGuard aGuard( mrRenderModule );
@@ -237,27 +236,27 @@ namespace dxcanvas
#endif
#ifdef FAKE_MAX_TEXTURE_SIZE
- if(rSize.getX() > FAKE_MAX_TEXTURE_SIZE)
+ if(rSize.getWidth() > FAKE_MAX_TEXTURE_SIZE)
return;
- if(rSize.getY() > FAKE_MAX_TEXTURE_SIZE)
+ if(rSize.getHeight() > FAKE_MAX_TEXTURE_SIZE)
return;
#endif
- ENSURE_ARG_OR_THROW(rSize.getX() > 0 && rSize.getY() > 0,
+ ENSURE_ARG_OR_THROW(rSize.getWidth() > 0 && rSize.getHeight() > 0,
"DXSurface::DXSurface(): request for zero-sized surface");
- COMReference<IDirect3DDevice9> pDevice(rRenderModule.getDevice());
+ sal::systools::COMReference<IDirect3DDevice9> pDevice(rRenderModule.getDevice());
IDirect3DTexture9 *pTexture(nullptr);
if(FAILED(pDevice->CreateTexture(
- rSize.getX(),
- rSize.getY(),
+ rSize.getWidth(),
+ rSize.getHeight(),
1,0,D3DFMT_A8R8G8B8,
D3DPOOL_MANAGED,
&pTexture,nullptr)))
return;
- mpTexture=COMReference<IDirect3DTexture9>(pTexture);
+ mpTexture = sal::systools::COMReference<IDirect3DTexture9>(pTexture, false);
maSize = rSize;
}
@@ -282,7 +281,7 @@ namespace dxcanvas
{
ImplRenderModuleGuard aGuard( mrRenderModule );
mrRenderModule.flushVertexCache();
- COMReference<IDirect3DDevice9> pDevice(mrRenderModule.getDevice());
+ sal::systools::COMReference<IDirect3DDevice9> pDevice(mrRenderModule.getDevice());
if( FAILED(pDevice->SetTexture(0,mpTexture.get())) )
return false;
@@ -325,12 +324,12 @@ namespace dxcanvas
// to avoid interpolation artifacts from other textures,
// the surface manager allocates one pixel gap between
// them. Clear that to transparent.
- rect.right = std::min(maSize.getX(),
+ rect.right = std::min(maSize.getWidth(),
rect.left + sal_Int32(rSourceRect.getWidth()+1));
- rect.bottom = std::min(maSize.getY(),
+ rect.bottom = std::min(maSize.getHeight(),
rect.top + sal_Int32(rSourceRect.getHeight()+1));
- const bool bClearRightColumn( rect.right < maSize.getX() );
- const bool bClearBottomRow( rect.bottom < maSize.getY() );
+ const bool bClearRightColumn( rect.right < maSize.getWidth() );
+ const bool bClearBottomRow( rect.bottom < maSize.getHeight() );
if(SUCCEEDED(mpTexture->LockRect(0,&aLockedRect,&rect,D3DLOCK_NOSYSLOCK)))
{
@@ -427,18 +426,11 @@ namespace dxcanvas
return true;
}
-
- // DXSurface::getSize
-
-
- ::basegfx::B2IVector DXSurface::getSize()
+ ::basegfx::B2ISize DXSurface::getSize()
{
return maSize;
}
- // DXRenderModule::DXRenderModule
-
-
DXRenderModule::DXRenderModule( const vcl::Window& rWindow ) :
mhWnd(nullptr),
mpDevice(),
@@ -446,14 +438,12 @@ namespace dxcanvas
mpSwapChain(),
mpVertexBuffer(),
mpTexture(),
- maSize(),
maVertexCache(),
mnCount(0),
mnBeginSceneCount(0),
mbCanUseDynamicTextures(false),
mbError( false ),
meType( PrimitiveType::Unknown ),
- maPageSize(),
mad3dpp(),
maNumVertices( VERTEX_BUFFER_SIZE ),
maWriteIndex(0),
@@ -469,10 +459,10 @@ namespace dxcanvas
// allocate a single texture surface which can be used later.
// we also use this to calibrate the page size.
- ::basegfx::B2IVector aPageSize(maPageSize);
+ basegfx::B2IVector aPageSize(maPageSize);
while(true)
{
- mpTexture = std::make_shared<DXSurface>(*this,aPageSize);
+ mpTexture = std::make_shared<DXSurface>(*this, basegfx::B2ISize(aPageSize.getX(), aPageSize.getY()));
if(mpTexture->isValid())
break;
@@ -499,7 +489,7 @@ namespace dxcanvas
"Could not create DirectX device - out of memory!" );
}
- mpVertexBuffer=COMReference<IDirect3DVertexBuffer9>(pVB);
+ mpVertexBuffer = sal::systools::COMReference<IDirect3DVertexBuffer9>(pVB, false);
}
@@ -542,8 +532,8 @@ namespace dxcanvas
// TODO(F2): since we would like to share precious hardware
// resources, the direct3d9 object should be global. each new
// request for a canvas should only create a new swapchain.
- mpDirect3D9 = COMReference<IDirect3D9>(
- Direct3DCreate9(D3D_SDK_VERSION));
+ mpDirect3D9 = sal::systools::COMReference<IDirect3D9>(
+ Direct3DCreate9(D3D_SDK_VERSION), false);
if(!mpDirect3D9.is())
return false;
@@ -569,7 +559,7 @@ namespace dxcanvas
const HWND hwnd(reinterpret_cast<HWND>(pData->hWnd));
mhWnd = hwnd;
- ENSURE_OR_THROW( IsWindow( reinterpret_cast<HWND>(mhWnd) ),
+ ENSURE_OR_THROW( IsWindow( mhWnd ),
"DXRenderModule::create() No valid HWND given." );
// retrieve position and size of the parent window
@@ -577,11 +567,11 @@ namespace dxcanvas
// remember the size of the parent window, since we
// need to use this for our child window.
- maSize.setX(static_cast<sal_Int32>(rSizePixel.Width()));
- maSize.setY(static_cast<sal_Int32>(rSizePixel.Height()));
+ maSize.setWidth(sal_Int32(rSizePixel.Width()));
+ maSize.setHeight(sal_Int32(rSizePixel.Height()));
// let the child window cover the same size as the parent window.
- mpWindow->setPosSizePixel(0,0,maSize.getX(),maSize.getY());
+ mpWindow->setPosSizePixel(0, 0, maSize.getWidth(),maSize.getHeight());
// create a device from the direct3d9 object.
if(!(createDevice()))
@@ -697,10 +687,8 @@ namespace dxcanvas
// a back buffer, and no way of falling back to a
// different canvas implementation.
ZeroMemory( &mad3dpp, sizeof(mad3dpp) );
- mad3dpp.BackBufferWidth = std::max(maSize.getX(),
- sal_Int32(d3ddm.Width));
- mad3dpp.BackBufferHeight = std::max(maSize.getY(),
- sal_Int32(d3ddm.Height));
+ mad3dpp.BackBufferWidth = std::max(maSize.getWidth(), sal_Int32(d3ddm.Width));
+ mad3dpp.BackBufferHeight = std::max(maSize.getHeight(), sal_Int32(d3ddm.Height));
mad3dpp.BackBufferCount = 1;
mad3dpp.Windowed = TRUE;
mad3dpp.SwapEffect = D3DSWAPEFFECT_COPY;
@@ -730,12 +718,12 @@ namespace dxcanvas
return false;
// got it, store it in a safe place...
- mpDevice=COMReference<IDirect3DDevice9>(pDevice);
+ mpDevice = sal::systools::COMReference<IDirect3DDevice9>(pDevice, false);
// After CreateDevice, the first swap chain already exists, so just get it...
IDirect3DSwapChain9 *pSwapChain(nullptr);
pDevice->GetSwapChain(0,&pSwapChain);
- mpSwapChain=COMReference<IDirect3DSwapChain9>(pSwapChain);
+ mpSwapChain = sal::systools::COMReference<IDirect3DSwapChain9>(pSwapChain, false);
if( !mpSwapChain.is() )
return false;
@@ -757,18 +745,18 @@ namespace dxcanvas
// DXRenderModule::createSystemMemorySurface
- COMReference<IDirect3DSurface9> DXRenderModule::createSystemMemorySurface( const ::basegfx::B2IVector& rSize )
+ sal::systools::COMReference<IDirect3DSurface9> DXRenderModule::createSystemMemorySurface(const ::basegfx::B2ISize& rSize)
{
if(isDisposed())
- return COMReference<IDirect3DSurface9>(nullptr);
+ return sal::systools::COMReference<IDirect3DSurface9>(nullptr);
// please note that D3DFMT_X8R8G8B8 is the only format we're
// able to choose here, since GetDC() doesn't support any
// other 32bit-format.
IDirect3DSurface9 *pSurface(nullptr);
if( FAILED(mpDevice->CreateOffscreenPlainSurface(
- rSize.getX(),
- rSize.getY(),
+ rSize.getWidth(),
+ rSize.getHeight(),
D3DFMT_X8R8G8B8,
D3DPOOL_SYSTEMMEM,
&pSurface,
@@ -778,7 +766,7 @@ namespace dxcanvas
"Could not create offscreen surface - out of mem!" );
}
- return COMReference<IDirect3DSurface9>(pSurface);
+ return sal::systools::COMReference<IDirect3DSurface9>(pSurface, false);
}
@@ -815,7 +803,7 @@ namespace dxcanvas
// DX was kind enough to really reset the device...
do
{
- mpVertexBuffer.reset();
+ mpVertexBuffer.clear();
hr = mpDevice->Reset(&mad3dpp);
if(SUCCEEDED(hr))
{
@@ -830,7 +818,7 @@ namespace dxcanvas
throw lang::NoSupportException(
"Could not create DirectX device - out of memory!" );
}
- mpVertexBuffer=COMReference<IDirect3DVertexBuffer9>(pVB);
+ mpVertexBuffer = sal::systools::COMReference<IDirect3DVertexBuffer9>(pVB, false);
// retry after the restore
if(SUCCEEDED(mpSwapChain->Present(&aRect,&aRect,nullptr,nullptr,0)))
@@ -868,41 +856,41 @@ namespace dxcanvas
return;
// don't do anything if the size didn't change.
- if(maSize.getX() == static_cast<sal_Int32>(rect.getWidth()) &&
- maSize.getY() == static_cast<sal_Int32>(rect.getHeight()))
+ if(maSize.getWidth() == static_cast<sal_Int32>(rect.getWidth()) &&
+ maSize.getHeight() == static_cast<sal_Int32>(rect.getHeight()))
return;
// TODO(Q2): use numeric cast to prevent overflow
- maSize.setX(static_cast<sal_Int32>(rect.getWidth()));
- maSize.setY(static_cast<sal_Int32>(rect.getHeight()));
+ maSize.setWidth(sal_Int32(rect.getWidth()));
+ maSize.setHeight(sal_Int32(rect.getHeight()));
- mpWindow->setPosSizePixel(0,0,maSize.getX(),maSize.getY());
+ mpWindow->setPosSizePixel(0, 0, maSize.getWidth(), maSize.getHeight());
// resize back buffer, if necessary
// don't attempt to create anything if the
// requested size is NULL.
- if(!(maSize.getX()))
+ if(!(maSize.getWidth()))
return;
- if(!(maSize.getY()))
+ if(!(maSize.getHeight()))
return;
// backbuffer too small (might happen, if window is
// maximized across multiple monitors)
- if( sal_Int32(mad3dpp.BackBufferWidth) < maSize.getX() ||
- sal_Int32(mad3dpp.BackBufferHeight) < maSize.getY() )
+ if( sal_Int32(mad3dpp.BackBufferWidth) < maSize.getWidth() ||
+ sal_Int32(mad3dpp.BackBufferHeight) < maSize.getHeight() )
{
- mad3dpp.BackBufferWidth = maSize.getX();
- mad3dpp.BackBufferHeight = maSize.getY();
+ mad3dpp.BackBufferWidth = maSize.getWidth();
+ mad3dpp.BackBufferHeight = maSize.getHeight();
// clear before, save resources
- mpSwapChain.reset();
+ mpSwapChain.clear();
IDirect3DSwapChain9 *pSwapChain(nullptr);
if(FAILED(mpDevice->CreateAdditionalSwapChain(&mad3dpp,&pSwapChain)))
return;
- mpSwapChain=COMReference<IDirect3DSwapChain9>(pSwapChain);
+ mpSwapChain = sal::systools::COMReference<IDirect3DSwapChain9>(pSwapChain, false);
// clear the render target [which is the backbuffer in this case].
// we are forced to do this once, and furthermore right now.
@@ -942,10 +930,10 @@ namespace dxcanvas
const ::basegfx::B2IVector& rPageSize( getPageSize() );
::basegfx::B2ISize aSize(surfaceSize);
- if(!(aSize.getX()))
- aSize.setX(rPageSize.getX());
- if(!(aSize.getY()))
- aSize.setY(rPageSize.getY());
+ if(!(aSize.getWidth()))
+ aSize.setWidth(rPageSize.getX());
+ if(!(aSize.getHeight()))
+ aSize.setHeight(rPageSize.getY());
if(mpTexture.use_count() == 1)
return mpTexture;
diff --git a/canvas/source/directx/dx_bitmap.cxx b/canvas/source/directx/dx_bitmap.cxx
index 524e3a6fdd2d..9e5f2348fa4f 100644
--- a/canvas/source/directx/dx_bitmap.cxx
+++ b/canvas/source/directx/dx_bitmap.cxx
@@ -23,7 +23,7 @@
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/range/b2irange.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include "dx_bitmap.hxx"
#include "dx_graphicsprovider.hxx"
@@ -47,8 +47,8 @@ namespace dxcanvas
{
}
- DXBitmap::DXBitmap( const ::basegfx::B2IVector& rSize,
- bool bWithAlpha ) :
+ DXBitmap::DXBitmap( const ::basegfx::B2ISize& rSize,
+ bool bWithAlpha ) :
mpGdiPlusUser( GDIPlusUser::createInstance() ),
maSize(rSize),
mpBitmap(),
@@ -59,19 +59,19 @@ namespace dxcanvas
if(mbAlpha)
{
mpBitmap = std::make_shared<Gdiplus::Bitmap>(
- maSize.getX(),
- maSize.getY(),
+ maSize.getWidth(),
+ maSize.getHeight(),
PixelFormat32bppARGB);
}
else
{
mpBitmap = std::make_shared<Gdiplus::Bitmap>(
- maSize.getX(),
- maSize.getY(),
+ maSize.getWidth(),
+ maSize.getHeight(),
PixelFormat24bppRGB);
}
- mpGraphics.reset( tools::createGraphicsFromBitmap(mpBitmap) );
+ mpGraphics = tools::createGraphicsFromBitmap(mpBitmap);
}
BitmapSharedPtr DXBitmap::getBitmap() const
@@ -84,7 +84,7 @@ namespace dxcanvas
return mpGraphics;
}
- ::basegfx::B2IVector DXBitmap::getSize() const
+ ::basegfx::B2ISize DXBitmap::getSize() const
{
return maSize;
}
@@ -154,7 +154,7 @@ namespace dxcanvas
// getMemoryLayout
&aBmpData ) )
{
- throw uno::RuntimeException();
+ throw uno::RuntimeException("Internal error while writing BitmapData into Bitmap");
}
// commit data to bitmap
@@ -165,7 +165,7 @@ namespace dxcanvas
const rendering::IntegerBitmapLayout& /*bitmapLayout*/,
const geometry::IntegerPoint2D& pos )
{
- const geometry::IntegerSize2D aSize( maSize.getX(),maSize.getY() );
+ const geometry::IntegerSize2D aSize( maSize.getWidth(),maSize.getHeight() );
ENSURE_ARG_OR_THROW( pos.X >= 0 && pos.X < aSize.Width,
"CanvasHelper::setPixel: X coordinate out of bounds" );
@@ -177,14 +177,14 @@ namespace dxcanvas
if( Gdiplus::Ok != mpBitmap->SetPixel( pos.X, pos.Y,
Gdiplus::Color( tools::sequenceToArgb( color ))))
{
- throw uno::RuntimeException();
+ throw uno::RuntimeException("SetPixel called with invalid x,y points or color");
}
}
uno::Sequence< sal_Int8 > DXBitmap::getPixel( rendering::IntegerBitmapLayout& /*bitmapLayout*/,
const geometry::IntegerPoint2D& pos )
{
- const geometry::IntegerSize2D aSize( maSize.getX(),maSize.getY() );
+ const geometry::IntegerSize2D aSize( maSize.getWidth(),maSize.getHeight() );
ENSURE_ARG_OR_THROW( pos.X >= 0 && pos.X < aSize.Width,
"CanvasHelper::getPixel: X coordinate out of bounds" );
diff --git a/canvas/source/directx/dx_bitmap.hxx b/canvas/source/directx/dx_bitmap.hxx
index f9e3470f0d5f..b27da5cfa683 100644
--- a/canvas/source/directx/dx_bitmap.hxx
+++ b/canvas/source/directx/dx_bitmap.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_BITMAP_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_BITMAP_HXX
+#pragma once
#include <com/sun/star/rendering/XCanvas.hpp>
#include <com/sun/star/rendering/XIntegerBitmap.hpp>
@@ -36,15 +35,13 @@ namespace dxcanvas
class DXBitmap : public IBitmap
{
public:
- DXBitmap( const BitmapSharedPtr& rBitmap,
- bool bWithAlpha );
- DXBitmap( const ::basegfx::B2IVector& rSize,
- bool bWithAlpha );
+ DXBitmap( const BitmapSharedPtr& rBitmap, bool bWithAlpha );
+ DXBitmap( const ::basegfx::B2ISize& rSize, bool bWithAlpha );
virtual GraphicsSharedPtr getGraphics() override;
virtual BitmapSharedPtr getBitmap() const override;
- virtual ::basegfx::B2IVector getSize() const override;
+ virtual ::basegfx::B2ISize getSize() const override;
virtual bool hasAlpha() const override;
css::uno::Sequence< sal_Int8 > getData(
@@ -70,7 +67,7 @@ namespace dxcanvas
GDIPlusUserSharedPtr mpGdiPlusUser;
// size of this image in pixels [integral unit]
- ::basegfx::B2IVector maSize;
+ ::basegfx::B2ISize maSize;
BitmapSharedPtr mpBitmap;
GraphicsSharedPtr mpGraphics;
@@ -82,6 +79,4 @@ namespace dxcanvas
typedef std::shared_ptr< DXBitmap > DXBitmapSharedPtr;
}
-#endif
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_bitmapcanvashelper.cxx b/canvas/source/directx/dx_bitmapcanvashelper.cxx
index b6d08fbbf8df..f82fa0ac3ad3 100644
--- a/canvas/source/directx/dx_bitmapcanvashelper.cxx
+++ b/canvas/source/directx/dx_bitmapcanvashelper.cxx
@@ -31,7 +31,7 @@
#include <com/sun/star/rendering/RepaintResult.hpp>
#include <com/sun/star/rendering/TexturingMode.hpp>
#include <rtl/math.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <canvas/canvastools.hxx>
@@ -60,7 +60,7 @@ namespace dxcanvas
{
ENSURE_OR_THROW( rTarget,
"BitmapCanvasHelper::setTarget(): Invalid target" );
- ENSURE_OR_THROW( !mpTarget.get(),
+ ENSURE_OR_THROW( !mpTarget,
"BitmapCanvasHelper::setTarget(): target set, old target would be overwritten" );
mpTarget = rTarget;
@@ -72,7 +72,7 @@ namespace dxcanvas
{
ENSURE_OR_THROW( rTarget,
"BitmapCanvasHelper::setTarget(): invalid target" );
- ENSURE_OR_THROW( !mpTarget.get(),
+ ENSURE_OR_THROW( !mpTarget,
"BitmapCanvasHelper::setTarget(): target set, old target would be overwritten" );
mpTarget = rTarget;
@@ -141,7 +141,6 @@ namespace dxcanvas
{
if( !mpTarget )
return geometry::IntegerSize2D(1, 1);
-
return basegfx::unotools::integerSize2DFromB2ISize(mpTarget->getSize());
}
diff --git a/canvas/source/directx/dx_bitmapcanvashelper.hxx b/canvas/source/directx/dx_bitmapcanvashelper.hxx
index 8a5ecca64c27..46f970493f8e 100644
--- a/canvas/source/directx/dx_bitmapcanvashelper.hxx
+++ b/canvas/source/directx/dx_bitmapcanvashelper.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_BITMAPCANVASHELPER_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_BITMAPCANVASHELPER_HXX
+#pragma once
#include <com/sun/star/rendering/XCanvas.hpp>
#include <com/sun/star/rendering/XBitmapCanvas.hpp>
@@ -124,6 +123,4 @@ namespace dxcanvas
};
}
-#endif // INCLUDED_CANVAS_SOURCE_DIRECTX_DX_BITMAPCANVASHELPER_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_bitmapprovider.hxx b/canvas/source/directx/dx_bitmapprovider.hxx
index 3003f6ef34c4..ad83abee0ffb 100644
--- a/canvas/source/directx/dx_bitmapprovider.hxx
+++ b/canvas/source/directx/dx_bitmapprovider.hxx
@@ -17,21 +17,18 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_BITMAPPROVIDER_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_BITMAPPROVIDER_HXX
+#pragma once
#include "dx_ibitmap.hxx"
#include <memory>
namespace dxcanvas
{
- struct BitmapProvider
- {
- virtual ~BitmapProvider() {}
- virtual IBitmapSharedPtr getBitmap() const = 0;
- };
+struct BitmapProvider
+{
+ virtual ~BitmapProvider() {}
+ virtual IBitmapSharedPtr getBitmap() const = 0;
+};
}
-#endif
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_canvas.cxx b/canvas/source/directx/dx_canvas.cxx
index cb7a3199e126..c2ef4d311f10 100644
--- a/canvas/source/directx/dx_canvas.cxx
+++ b/canvas/source/directx/dx_canvas.cxx
@@ -20,6 +20,7 @@
#include <sal/config.h>
#include <memory>
+#include <utility>
#include <sal/log.hxx>
@@ -35,10 +36,10 @@
#include <com/sun/star/uno/XComponentContext.hpp>
#include <cppuhelper/supportsservice.hxx>
#include <osl/mutex.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <vcl/sysdata.hxx>
-#include <vcl/opengl/OpenGLWrapper.hxx>
#include <vcl/skia/SkiaHelper.hxx>
+#include <vcl/window.hxx>
#include <canvas/canvastools.hxx>
@@ -57,7 +58,7 @@ namespace dxcanvas
{
GraphicsSharedPtr mpGraphics;
public:
- explicit GraphicsProviderImpl( Gdiplus::Graphics* pGraphics ) : mpGraphics( pGraphics ) {}
+ explicit GraphicsProviderImpl( GraphicsSharedPtr && pGraphics ) : mpGraphics( std::move(pGraphics) ) {}
virtual GraphicsSharedPtr getGraphics() override { return mpGraphics; }
};
@@ -76,8 +77,6 @@ namespace dxcanvas
if( maArguments.getLength() == 0 )
return;
- // tdf#93870 - force VCL canvas in OpenGL mode for now.
- assert( !OpenGLWrapper::isVCLOpenGLEnabled() );
assert( !SkiaHelper::isVCLSkiaEnabled() );
SAL_INFO("canvas.directx", "Canvas::initialize called" );
@@ -106,7 +105,7 @@ namespace dxcanvas
maCanvasHelper.setDevice( *this );
maCanvasHelper.setTarget(
std::make_shared<GraphicsProviderImpl>(
- Gdiplus::Graphics::FromHDC(pSysData->hDC)));
+ GraphicsSharedPtr(Gdiplus::Graphics::FromHDC(pSysData->hDC))));
maArguments.realloc(0);
}
@@ -123,17 +122,17 @@ namespace dxcanvas
OUString SAL_CALL Canvas::getServiceName( )
{
- return "com.sun.star.rendering.Canvas.GDI+";
+ return u"com.sun.star.rendering.Canvas.GDI+"_ustr;
}
// XServiceInfo
css::uno::Sequence<OUString> Canvas::getSupportedServiceNames( )
{
- return { "com.sun.star.rendering.Canvas.GDI+" };
+ return { u"com.sun.star.rendering.Canvas.GDI+"_ustr };
}
OUString Canvas::getImplementationName( )
{
- return "com.sun.star.comp.rendering.Canvas.GDI+";
+ return u"com.sun.star.comp.rendering.Canvas.GDI+"_ustr;
}
sal_Bool Canvas::supportsService( const OUString& sServiceName )
{
@@ -213,17 +212,17 @@ namespace dxcanvas
OUString SAL_CALL BitmapCanvas::getServiceName( )
{
- return "com.sun.star.rendering.BitmapCanvas.GDI+";
+ return u"com.sun.star.rendering.BitmapCanvas.GDI+"_ustr;
}
// XServiceInfo
css::uno::Sequence<OUString> BitmapCanvas::getSupportedServiceNames( )
{
- return { "com.sun.star.rendering.BitmapCanvas.GDI+" };
+ return { u"com.sun.star.rendering.BitmapCanvas.GDI+"_ustr };
}
OUString BitmapCanvas::getImplementationName( )
{
- return "com.sun.star.comp.rendering.BitmapCanvas.GDI+";
+ return u"com.sun.star.comp.rendering.BitmapCanvas.GDI+"_ustr;
}
sal_Bool BitmapCanvas::supportsService( const OUString& sServiceName )
{
@@ -241,8 +240,7 @@ namespace dxcanvas
{
rtl::Reference<Canvas> xCanvas(new Canvas(args, context));
xCanvas->initialize();
- xCanvas->acquire();
- return static_cast<cppu::OWeakObject*>(xCanvas.get());
+ return cppu::acquire(xCanvas.get());
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
@@ -251,8 +249,7 @@ namespace dxcanvas
{
rtl::Reference<BitmapCanvas> xCanvas(new BitmapCanvas(args, context));
xCanvas->initialize();
- xCanvas->acquire();
- return static_cast<cppu::OWeakObject*>(xCanvas.get());
+ return cppu::acquire(xCanvas.get());
}
}
diff --git a/canvas/source/directx/dx_canvas.hxx b/canvas/source/directx/dx_canvas.hxx
index acea85c762c5..5a00e07fa462 100644
--- a/canvas/source/directx/dx_canvas.hxx
+++ b/canvas/source/directx/dx_canvas.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_CANVAS_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_CANVAS_HXX
+#pragma once
#include <rtl/ref.hxx>
@@ -171,6 +170,4 @@ namespace dxcanvas
};
}
-#endif
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_canvasbitmap.cxx b/canvas/source/directx/dx_canvasbitmap.cxx
index b02ff2796813..cfef86a536ec 100644
--- a/canvas/source/directx/dx_canvasbitmap.cxx
+++ b/canvas/source/directx/dx_canvasbitmap.cxx
@@ -22,7 +22,7 @@
#include <memory>
#include <cppuhelper/supportsservice.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <vcl/bitmapex.hxx>
#include <canvas/canvastools.hxx>
@@ -97,9 +97,7 @@ namespace dxcanvas
HBITMAP aHBmp;
mpBitmap->getBitmap()->GetHBITMAP(Gdiplus::Color(), &aHBmp );
- uno::Sequence< uno::Any > args(1);
- args[0] <<= sal_Int64(aHBmp);
-
+ uno::Sequence< uno::Any > args{ uno::Any(reinterpret_cast<sal_Int64>(aHBmp)) };
aRes <<= args;
}
else
@@ -107,18 +105,18 @@ namespace dxcanvas
// need to copy&convert the bitmap, since dx
// canvas uses inline alpha channel
HDC hScreenDC=GetDC(nullptr);
- const basegfx::B2IVector aSize(mpBitmap->getSize());
+ const basegfx::B2ISize aSize = mpBitmap->getSize();
HBITMAP hBmpBitmap = CreateCompatibleBitmap( hScreenDC,
- aSize.getX(),
- aSize.getY() );
+ aSize.getWidth(),
+ aSize.getHeight() );
if( !hBmpBitmap )
return aRes;
BITMAPINFOHEADER aBIH;
aBIH.biSize = sizeof( BITMAPINFOHEADER );
- aBIH.biWidth = aSize.getX();
- aBIH.biHeight = -aSize.getY();
+ aBIH.biWidth = aSize.getWidth();
+ aBIH.biHeight = -aSize.getHeight();
aBIH.biPlanes = 1;
aBIH.biBitCount = 32;
aBIH.biCompression = BI_RGB; // expects pixel in
@@ -131,12 +129,12 @@ namespace dxcanvas
aBIH.biClrImportant = 0;
Gdiplus::BitmapData aBmpData;
- aBmpData.Width = aSize.getX();
- aBmpData.Height = aSize.getY();
+ aBmpData.Width = aSize.getWidth();
+ aBmpData.Height = aSize.getHeight();
aBmpData.Stride = 4*aBmpData.Width;
aBmpData.PixelFormat = PixelFormat32bppARGB;
aBmpData.Scan0 = nullptr;
- const Gdiplus::Rect aRect( 0,0,aSize.getX(),aSize.getY() );
+ const Gdiplus::Rect aRect( 0,0,aSize.getWidth(),aSize.getHeight() );
BitmapSharedPtr pGDIPlusBitmap=mpBitmap->getBitmap();
if( Gdiplus::Ok != pGDIPlusBitmap->LockBits( &aRect,
Gdiplus::ImageLockModeRead,
@@ -149,13 +147,11 @@ namespace dxcanvas
// now aBmpData.Scan0 contains our bits - push
// them into HBITMAP, ignoring alpha
- SetDIBits( hScreenDC, hBmpBitmap, 0, aSize.getY(), aBmpData.Scan0, reinterpret_cast<PBITMAPINFO>(&aBIH), DIB_RGB_COLORS );
+ SetDIBits( hScreenDC, hBmpBitmap, 0, aSize.getHeight(), aBmpData.Scan0, reinterpret_cast<PBITMAPINFO>(&aBIH), DIB_RGB_COLORS );
pGDIPlusBitmap->UnlockBits( &aBmpData );
- uno::Sequence< uno::Any > args(1);
- args[0] <<= sal_Int64(hBmpBitmap);
-
+ uno::Sequence< uno::Any > args{ uno::Any(reinterpret_cast<sal_Int64>(hBmpBitmap)) };
aRes <<= args;
}
}
@@ -174,14 +170,14 @@ namespace dxcanvas
// need to copy&convert the bitmap, since dx
// canvas uses inline alpha channel
HDC hScreenDC=GetDC(nullptr);
- const basegfx::B2IVector aSize(mpBitmap->getSize());
- HBITMAP hBmpBitmap = CreateCompatibleBitmap( hScreenDC, aSize.getX(), aSize.getY() );
+ const basegfx::B2ISize aSize = mpBitmap->getSize();
+ HBITMAP hBmpBitmap = CreateCompatibleBitmap( hScreenDC, aSize.getWidth(), aSize.getHeight() );
if( !hBmpBitmap )
return aRes;
aDIB.bmiHeader.biSize = sizeof( BITMAPINFOHEADER );
- aDIB.bmiHeader.biWidth = aSize.getX();
- aDIB.bmiHeader.biHeight = -aSize.getY();
+ aDIB.bmiHeader.biWidth = aSize.getWidth();
+ aDIB.bmiHeader.biHeight = -aSize.getHeight();
aDIB.bmiHeader.biPlanes = 1;
aDIB.bmiHeader.biBitCount = 8;
aDIB.bmiHeader.biCompression = BI_RGB;
@@ -192,12 +188,12 @@ namespace dxcanvas
aDIB.bmiHeader.biClrImportant = 0;
Gdiplus::BitmapData aBmpData;
- aBmpData.Width = aSize.getX();
- aBmpData.Height = aSize.getY();
+ aBmpData.Width = aSize.getWidth();
+ aBmpData.Height = aSize.getHeight();
aBmpData.Stride = 4*aBmpData.Width;
aBmpData.PixelFormat = PixelFormat32bppARGB;
aBmpData.Scan0 = nullptr;
- const Gdiplus::Rect aRect( 0,0,aSize.getX(),aSize.getY() );
+ const Gdiplus::Rect aRect( 0,0,aSize.getWidth(),aSize.getHeight() );
BitmapSharedPtr pGDIPlusBitmap=mpBitmap->getBitmap();
if( Gdiplus::Ok != pGDIPlusBitmap->LockBits( &aRect,
Gdiplus::ImageLockModeRead,
@@ -209,16 +205,17 @@ namespace dxcanvas
}
// copy only alpha channel to pAlphaBits
- const sal_Int32 nScanWidth((aSize.getX() + 3) & ~3);
- std::unique_ptr<sal_uInt8[]> pAlphaBits( new sal_uInt8[nScanWidth*aSize.getY()] );
+ const sal_Int32 nScanWidth((aSize.getWidth() + 3) & ~3);
+ std::unique_ptr<sal_uInt8[]> pAlphaBits( new sal_uInt8[nScanWidth*aSize.getHeight()] );
const sal_uInt8* pInBits=static_cast<sal_uInt8*>(aBmpData.Scan0);
+ assert(pInBits);
pInBits+=3;
- for( sal_Int32 y=0; y<aSize.getY(); ++y )
+ for( sal_Int32 y=0; y<aSize.getHeight(); ++y )
{
sal_uInt8* pOutBits=pAlphaBits.get()+y*nScanWidth;
- for( sal_Int32 x=0; x<aSize.getX(); ++x )
+ for( sal_Int32 x=0; x<aSize.getWidth(); ++x )
{
- *pOutBits++ = 255-*pInBits;
+ *pOutBits++ = *pInBits;
pInBits += 4;
}
}
@@ -227,12 +224,10 @@ namespace dxcanvas
// set bits to newly create HBITMAP
SetDIBits( hScreenDC, hBmpBitmap, 0,
- aSize.getY(), pAlphaBits.get(),
+ aSize.getHeight(), pAlphaBits.get(),
reinterpret_cast<PBITMAPINFO>(&aDIB), DIB_RGB_COLORS );
- uno::Sequence< uno::Any > args(1);
- args[0] <<= sal_Int64(hBmpBitmap);
-
+ uno::Sequence< uno::Any > args{ uno::Any(reinterpret_cast<sal_Int64>(hBmpBitmap)) };
aRes <<= args;
}
}
diff --git a/canvas/source/directx/dx_canvasbitmap.hxx b/canvas/source/directx/dx_canvasbitmap.hxx
index 756791d1526d..b1725b447dec 100644
--- a/canvas/source/directx/dx_canvasbitmap.hxx
+++ b/canvas/source/directx/dx_canvasbitmap.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_CANVASBITMAP_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_CANVASBITMAP_HXX
+#pragma once
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/rendering/XBitmapCanvas.hpp>
@@ -89,6 +88,4 @@ namespace dxcanvas
};
}
-#endif // INCLUDED_CANVAS_SOURCE_DIRECTX_DX_CANVASBITMAP_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_canvascustomsprite.cxx b/canvas/source/directx/dx_canvascustomsprite.cxx
index f850342919b5..b9e79fdc0654 100644
--- a/canvas/source/directx/dx_canvascustomsprite.cxx
+++ b/canvas/source/directx/dx_canvascustomsprite.cxx
@@ -25,7 +25,7 @@
#include <basegfx/point/b2dpoint.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <rtl/math.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <canvas/canvastools.hxx>
@@ -45,11 +45,11 @@ namespace dxcanvas
mpSpriteCanvas( rRefDevice ),
mpSurface()
{
- ENSURE_OR_THROW( rRefDevice.get(),
+ ENSURE_OR_THROW( rRefDevice,
"CanvasCustomSprite::CanvasCustomSprite(): Invalid sprite canvas" );
mpSurface = std::make_shared<DXSurfaceBitmap>(
- ::basegfx::B2IVector(
+ ::basegfx::B2ISize(
::canvas::tools::roundUp( rSpriteSize.Width ),
::canvas::tools::roundUp( rSpriteSize.Height )),
rSurfaceProxy,
diff --git a/canvas/source/directx/dx_canvascustomsprite.hxx b/canvas/source/directx/dx_canvascustomsprite.hxx
index 53886f636db3..2411a1527323 100644
--- a/canvas/source/directx/dx_canvascustomsprite.hxx
+++ b/canvas/source/directx/dx_canvascustomsprite.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_CANVASCUSTOMSPRITE_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_CANVASCUSTOMSPRITE_HXX
+#pragma once
#include <cppuhelper/compbase.hxx>
#include <comphelper/uno3.hxx>
@@ -128,6 +127,4 @@ namespace dxcanvas
};
}
-#endif // INCLUDED_CANVAS_SOURCE_DIRECTX_DX_CANVASCUSTOMSPRITE_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_canvasfont.hxx b/canvas/source/directx/dx_canvasfont.hxx
index 15b2fa8eef03..c5f369d00f5e 100644
--- a/canvas/source/directx/dx_canvasfont.hxx
+++ b/canvas/source/directx/dx_canvasfont.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_CANVASFONT_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_CANVASFONT_HXX
+#pragma once
#include <cppuhelper/compbase.hxx>
#include <cppuhelper/basemutex.hxx>
@@ -90,6 +89,4 @@ namespace dxcanvas
}
-#endif // INCLUDED_CANVAS_SOURCE_DIRECTX_DX_CANVASFONT_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_canvashelper.cxx b/canvas/source/directx/dx_canvashelper.cxx
index 927f838244ab..bd3523a134b9 100644
--- a/canvas/source/directx/dx_canvashelper.cxx
+++ b/canvas/source/directx/dx_canvashelper.cxx
@@ -34,7 +34,7 @@
#include <comphelper/sequence.hxx>
#include <o3tl/char16_t2wchar_t.hxx>
#include <rtl/math.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <canvas/canvastools.hxx>
@@ -51,7 +51,7 @@ namespace dxcanvas
{
namespace
{
- Gdiplus::LineCap gdiCapFromCap( sal_Int8 nCapType )
+ Gdiplus::LineCap gdiLineCapFromCap( sal_Int8 nCapType )
{
switch( nCapType )
{
@@ -66,12 +66,35 @@ namespace dxcanvas
default:
ENSURE_OR_THROW( false,
- "gdiCapFromCap(): Unexpected cap type" );
+ "gdiLineCapFromCap(): Unexpected cap type" );
}
return Gdiplus::LineCapFlat;
}
+ Gdiplus::DashCap gdiDashCapFromCap( sal_Int8 nCapType )
+ {
+ switch( nCapType )
+ {
+ case rendering::PathCapType::BUTT:
+ return Gdiplus::DashCapFlat;
+
+ case rendering::PathCapType::ROUND:
+ return Gdiplus::DashCapRound;
+
+ // Gdiplus does not know square, using flat would make short
+ // dashes disappear, so use triangle as the closest one.
+ case rendering::PathCapType::SQUARE:
+ return Gdiplus::DashCapTriangle;
+
+ default:
+ ENSURE_OR_THROW( false,
+ "gdiDashCapFromCap(): Unexpected cap type" );
+ }
+
+ return Gdiplus::DashCapFlat;
+ }
+
Gdiplus::LineJoin gdiJoinFromJoin( sal_Int8 nJoinType )
{
switch( nJoinType )
@@ -124,7 +147,7 @@ namespace dxcanvas
{
ENSURE_OR_THROW( rTarget,
"CanvasHelper::setTarget(): Invalid target" );
- ENSURE_OR_THROW( !mpGraphicsProvider.get(),
+ ENSURE_OR_THROW( !mpGraphicsProvider,
"CanvasHelper::setTarget(): target set, old target would be overwritten" );
mpGraphicsProvider = rTarget;
@@ -135,7 +158,7 @@ namespace dxcanvas
{
ENSURE_OR_THROW( rTarget,
"CanvasHelper::setTarget(): invalid target" );
- ENSURE_OR_THROW( !mpGraphicsProvider.get(),
+ ENSURE_OR_THROW( !mpGraphicsProvider,
"CanvasHelper::setTarget(): target set, old target would be overwritten" );
mpGraphicsProvider = rTarget;
@@ -368,9 +391,9 @@ namespace dxcanvas
aPen.SetDashPattern( rDashArray.data(),
rDashArray.size() );
}
- aPen.SetLineCap( gdiCapFromCap(strokeAttributes.StartCapType),
- gdiCapFromCap(strokeAttributes.EndCapType),
- Gdiplus::DashCapFlat );
+ aPen.SetLineCap( gdiLineCapFromCap(strokeAttributes.StartCapType),
+ gdiLineCapFromCap(strokeAttributes.EndCapType),
+ gdiDashCapFromCap(strokeAttributes.StartCapType));
if(!bIsNone)
aPen.SetLineJoin( gdiJoinFromJoin(strokeAttributes.JoinType) );
@@ -705,14 +728,13 @@ namespace dxcanvas
"CanvasHelper::setupGraphicsState: reference device invalid" );
// setup view transform first. Clipping e.g. depends on it
- ::basegfx::B2DHomMatrix aTransform;
- ::canvas::tools::getViewStateTransform(aTransform, viewState);
+ ::basegfx::B2DHomMatrix aTransform = ::canvas::tools::getViewStateTransform(viewState);
// add output offset
if( !maOutputOffset.equalZero() )
{
const basegfx::B2DHomMatrix aOutputOffset(basegfx::utils::createTranslateB2DHomMatrix(
- maOutputOffset.getX(), maOutputOffset.getY()));
+ maOutputOffset.getWidth(), maOutputOffset.getHeight()));
aTransform = aOutputOffset * aTransform;
}
@@ -751,7 +773,7 @@ namespace dxcanvas
if( !maOutputOffset.equalZero() )
{
const basegfx::B2DHomMatrix aOutputOffset(basegfx::utils::createTranslateB2DHomMatrix(
- maOutputOffset.getX(), maOutputOffset.getY()));
+ maOutputOffset.getWidth(), maOutputOffset.getHeight()));
aTransform = aOutputOffset * aTransform;
}
diff --git a/canvas/source/directx/dx_canvashelper.hxx b/canvas/source/directx/dx_canvashelper.hxx
index 483033fd7c49..54731a08eb44 100644
--- a/canvas/source/directx/dx_canvashelper.hxx
+++ b/canvas/source/directx/dx_canvashelper.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_CANVASHELPER_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_CANVASHELPER_HXX
+#pragma once
#include <com/sun/star/rendering/XCanvas.hpp>
#include <com/sun/star/rendering/XBitmapCanvas.hpp>
@@ -236,7 +235,7 @@ namespace dxcanvas
/// Provides the Gdiplus::Graphics to render into
GraphicsProviderSharedPtr mpGraphicsProvider;
- bool needOutput() const { return mpGraphicsProvider.get() != nullptr; };
+ bool needOutput() const { return bool(mpGraphicsProvider); };
// returns transparency of color
void setupGraphicsState( GraphicsSharedPtr const & rGraphics,
@@ -250,6 +249,4 @@ namespace dxcanvas
};
}
-#endif // INCLUDED_CANVAS_SOURCE_DIRECTX_DX_CANVASHELPER_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_canvashelper_texturefill.cxx b/canvas/source/directx/dx_canvashelper_texturefill.cxx
index f60dffb3b870..c64773539e9d 100644
--- a/canvas/source/directx/dx_canvashelper_texturefill.cxx
+++ b/canvas/source/directx/dx_canvashelper_texturefill.cxx
@@ -19,6 +19,7 @@
#include <sal/config.h>
+#include <cstdlib>
#include <memory>
#include <tuple>
@@ -34,7 +35,7 @@
#include <basegfx/utils/tools.hxx>
#include <com/sun/star/rendering/TexturingMode.hpp>
#include <rtl/math.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <parametricpolypolygon.hxx>
@@ -188,10 +189,10 @@ namespace dxcanvas
int numColorSteps( const Gdiplus::Color& rColor1, const Gdiplus::Color& rColor2 )
{
return std::max(
- labs( rColor1.GetRed() - rColor2.GetRed() ),
+ std::abs( rColor1.GetRed() - rColor2.GetRed() ),
std::max(
- labs( rColor1.GetGreen() - rColor2.GetGreen() ),
- labs( rColor1.GetBlue() - rColor2.GetBlue() ) ) );
+ std::abs( rColor1.GetGreen() - rColor2.GetGreen() ),
+ std::abs( rColor1.GetBlue() - rColor2.GetBlue() ) ) );
}
bool fillPolygonalGradient( const ::canvas::ParametricPolyPolygon::Values& rValues,
diff --git a/canvas/source/directx/dx_config.cxx b/canvas/source/directx/dx_config.cxx
index 48609d8c500e..643877659edd 100644
--- a/canvas/source/directx/dx_config.cxx
+++ b/canvas/source/directx/dx_config.cxx
@@ -26,7 +26,7 @@
#include <comphelper/anytostring.hxx>
#include <cppuhelper/exc_hlp.hxx>
#include <osl/diagnose.h>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include "dx_config.hxx"
@@ -45,12 +45,10 @@ namespace dxcanvas
{
try
{
- uno::Sequence< OUString > aName { "DeviceDenylist" };
-
- uno::Sequence< uno::Any > aProps( GetProperties( aName ));
+ uno::Sequence< uno::Any > aProps( GetProperties( { "DeviceDenylist" } ));
uno::Sequence< sal_Int32 > aValues;
- if( aProps.getLength() > 0 &&
+ if (aProps.hasElements() &&
(aProps[0] >>= aValues) )
{
const sal_Int32* pValues = aValues.getConstArray();
@@ -70,13 +68,11 @@ namespace dxcanvas
}
}
- aName[0] = "DenylistCurrentDevice";
- aProps = GetProperties( aName );
+ aProps = GetProperties( { "DenylistCurrentDevice" } );
if( aProps.getLength() > 0 )
aProps[0] >>= mbDenylistCurrentDevice;
- aName[0] = "MaxTextureSize";
- aProps = GetProperties( aName );
+ aProps = GetProperties( { "MaxTextureSize" } );
if( aProps.getLength() > 0 )
maMaxTextureSize = aProps[0].get<sal_Int32>();
else
diff --git a/canvas/source/directx/dx_config.hxx b/canvas/source/directx/dx_config.hxx
index 496652b30197..14a77d19da78 100644
--- a/canvas/source/directx/dx_config.hxx
+++ b/canvas/source/directx/dx_config.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_CONFIG_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_CONFIG_HXX
+#pragma once
#include <unotools/configitem.hxx>
#include <optional>
@@ -78,6 +77,4 @@ namespace dxcanvas
};
}
-#endif // INCLUDED_CANVAS_SOURCE_DIRECTX_DX_CONFIG_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_devicehelper.cxx b/canvas/source/directx/dx_devicehelper.cxx
index 1c724bca5513..3ead660b4ab6 100644
--- a/canvas/source/directx/dx_devicehelper.cxx
+++ b/canvas/source/directx/dx_devicehelper.cxx
@@ -23,11 +23,10 @@
#include <basegfx/utils/canvastools.hxx>
#include <com/sun/star/lang/NoSupportException.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <vcl/canvastools.hxx>
#include <vcl/outdev.hxx>
#include <vcl/sysdata.hxx>
-#include <vcl/window.hxx>
#include <canvas/canvastools.hxx>
@@ -77,13 +76,12 @@ namespace dxcanvas
ENSURE_OR_THROW( hDC,
"DeviceHelper::getPhysicalResolution(): cannot retrieve HDC from window" );
- const int nHorzRes( GetDeviceCaps( hDC,
- LOGPIXELSX ) );
- const int nVertRes( GetDeviceCaps( hDC,
- LOGPIXELSY ) );
+ const double nHorzRes(GetDeviceCaps(hDC, LOGPIXELSX));
+ const double nVertRes(GetDeviceCaps(hDC, LOGPIXELSY));
- return geometry::RealSize2D( nHorzRes*25.4,
- nVertRes*25.4 );
+ // Converted units are in the denominator in px/in -> px/mm => conversion is inverted
+ return geometry::RealSize2D(o3tl::convert(nHorzRes, o3tl::Length::mm, o3tl::Length::in),
+ o3tl::convert(nVertRes, o3tl::Length::mm, o3tl::Length::in));
}
geometry::RealSize2D DeviceHelper::getPhysicalSize()
@@ -189,22 +187,11 @@ namespace dxcanvas
return uno::Any();
}
- namespace
- {
- struct DeviceColorSpace: public rtl::StaticWithInit<uno::Reference<rendering::XColorSpace>,
- DeviceColorSpace>
- {
- uno::Reference<rendering::XColorSpace> operator()()
- {
- return vcl::unotools::createStandardColorSpace();
- }
- };
- }
-
uno::Reference<rendering::XColorSpace> DeviceHelper::getColorSpace() const
{
// always the same
- return DeviceColorSpace::get();
+ static uno::Reference<rendering::XColorSpace> theSpace = vcl::unotools::createStandardColorSpace();
+ return theSpace;
}
}
diff --git a/canvas/source/directx/dx_devicehelper.hxx b/canvas/source/directx/dx_devicehelper.hxx
index ac52c127a0d5..d5fa62b07c54 100644
--- a/canvas/source/directx/dx_devicehelper.hxx
+++ b/canvas/source/directx/dx_devicehelper.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_DEVICEHELPER_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_DEVICEHELPER_HXX
+#pragma once
#include <com/sun/star/awt/Rectangle.hpp>
#include <com/sun/star/rendering/XGraphicDevice.hpp>
@@ -112,6 +111,4 @@ namespace dxcanvas
typedef ::rtl::Reference< css::rendering::XGraphicDevice > DeviceRef;
}
-#endif // INCLUDED_CANVAS_SOURCE_DIRECTX_DX_DEVICEHELPER_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_gdiplususer.hxx b/canvas/source/directx/dx_gdiplususer.hxx
index a050d24fb389..4b0a0f52aa93 100644
--- a/canvas/source/directx/dx_gdiplususer.hxx
+++ b/canvas/source/directx/dx_gdiplususer.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_GDIPLUSUSER_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_GDIPLUSUSER_HXX
+#pragma once
#include <sal/config.h>
#include <memory>
@@ -43,6 +42,4 @@ namespace dxcanvas
}
-#endif // INCLUDED_CANVAS_SOURCE_DIRECTX_DX_GDIPLUSUSER_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_graphicsprovider.hxx b/canvas/source/directx/dx_graphicsprovider.hxx
index 2d7c3d894465..2d6d6188424a 100644
--- a/canvas/source/directx/dx_graphicsprovider.hxx
+++ b/canvas/source/directx/dx_graphicsprovider.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_GRAPHICSPROVIDER_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_GRAPHICSPROVIDER_HXX
+#pragma once
#include "dx_winstuff.hxx"
#include <memory>
@@ -44,6 +43,4 @@ namespace dxcanvas
typedef std::shared_ptr< GraphicsProvider > GraphicsProviderSharedPtr;
}
-#endif // INCLUDED_CANVAS_SOURCE_DIRECTX_DX_GRAPHICSPROVIDER_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_ibitmap.hxx b/canvas/source/directx/dx_ibitmap.hxx
index c16faaf5f60b..9669f6767495 100644
--- a/canvas/source/directx/dx_ibitmap.hxx
+++ b/canvas/source/directx/dx_ibitmap.hxx
@@ -17,11 +17,11 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_IBITMAP_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_IBITMAP_HXX
+#pragma once
#include <com/sun/star/rendering/XCanvas.hpp>
#include <com/sun/star/rendering/XIntegerBitmap.hpp>
+#include <basegfx/vector/b2isize.hxx>
#include <basegfx/vector/b2ivector.hxx>
#include <basegfx/point/b2dpoint.hxx>
#include <basegfx/range/b2drange.hxx>
@@ -34,7 +34,7 @@ namespace dxcanvas
struct IBitmap : public GraphicsProvider
{
virtual BitmapSharedPtr getBitmap() const = 0;
- virtual ::basegfx::B2IVector getSize() const = 0;
+ virtual ::basegfx::B2ISize getSize() const = 0;
virtual bool hasAlpha() const = 0;
virtual css::uno::Sequence< sal_Int8 > getData(
@@ -59,6 +59,4 @@ namespace dxcanvas
typedef std::shared_ptr<IBitmap> IBitmapSharedPtr;
}
-#endif
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_impltools.cxx b/canvas/source/directx/dx_impltools.cxx
index 21778b4843fb..0364ebcbdd52 100644
--- a/canvas/source/directx/dx_impltools.cxx
+++ b/canvas/source/directx/dx_impltools.cxx
@@ -35,7 +35,7 @@
#include <com/sun/star/geometry/RealPoint2D.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <canvas/canvastools.hxx>
#include <verifyinput.hxx>
@@ -52,10 +52,8 @@
using namespace ::com::sun::star;
-namespace dxcanvas
+namespace dxcanvas::tools
{
- namespace tools
- {
::basegfx::B2DPolyPolygon polyPolygonFromXPolyPolygon2D( const uno::Reference< rendering::XPolyPolygon2D >& xPoly )
{
LinePolyPolygon* pPolyImpl = dynamic_cast< LinePolyPolygon* >( xPoly.get() );
@@ -134,9 +132,9 @@ namespace dxcanvas
return pRet;
}
- Gdiplus::Graphics* createGraphicsFromBitmap(const BitmapSharedPtr& rBitmap)
+ GraphicsSharedPtr createGraphicsFromBitmap(const BitmapSharedPtr& rBitmap)
{
- Gdiplus::Graphics* pRet = Gdiplus::Graphics::FromImage(rBitmap.get());
+ GraphicsSharedPtr pRet(Gdiplus::Graphics::FromImage(rBitmap.get()));
if( pRet )
setupGraphics( *pRet );
return pRet;
@@ -351,14 +349,13 @@ namespace dxcanvas
uno::Sequence< sal_Int8 > argbToIntSequence( Gdiplus::ARGB rColor )
{
// TODO(F1): handle color space conversions, when defined on canvas/graphicDevice
- uno::Sequence< sal_Int8 > aRet(4);
-
- aRet[0] = static_cast<sal_Int8>((rColor >> 16) & 0xFF); // red
- aRet[1] = static_cast<sal_Int8>((rColor >> 8) & 0xFF); // green
- aRet[2] = static_cast<sal_Int8>(rColor & 0xFF); // blue
- aRet[3] = static_cast<sal_Int8>((rColor >> 24) & 0xFF); // alpha
-
- return aRet;
+ return
+ {
+ static_cast<sal_Int8>((rColor >> 16) & 0xFF), // red
+ static_cast<sal_Int8>((rColor >> 8) & 0xFF), // green
+ static_cast<sal_Int8>(rColor & 0xFF), // blue
+ static_cast<sal_Int8>((rColor >> 24) & 0xFF) // alpha
+ };
}
Gdiplus::ARGB sequenceToArgb( const uno::Sequence< sal_Int8 >& rColor )
@@ -627,7 +624,6 @@ namespace dxcanvas
o_rAttr.SetColorMatrix( &aColorMatrix );
}
- } // namespace tools
-} // namespace dxcanvas
+} // namespace dxcanvas::tools
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_impltools.hxx b/canvas/source/directx/dx_impltools.hxx
index 4fab5a9e596b..2c6b85ce83ff 100644
--- a/canvas/source/directx/dx_impltools.hxx
+++ b/canvas/source/directx/dx_impltools.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_IMPLTOOLS_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_IMPLTOOLS_HXX
+#pragma once
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/Sequence.hxx>
@@ -54,17 +53,15 @@ namespace com::sun::star::rendering
}
-namespace dxcanvas
+namespace dxcanvas::tools
{
- namespace tools
- {
struct RawRGBABitmap;
::basegfx::B2DPolyPolygon
polyPolygonFromXPolyPolygon2D( const css::uno::Reference< css::rendering::XPolyPolygon2D >& );
Gdiplus::Graphics* createGraphicsFromHDC(HDC);
- Gdiplus::Graphics* createGraphicsFromBitmap(const BitmapSharedPtr&);
+ GraphicsSharedPtr createGraphicsFromBitmap(const BitmapSharedPtr&);
void setupGraphics( Gdiplus::Graphics& rGraphics );
@@ -121,9 +118,7 @@ namespace dxcanvas
double nGreenModulation,
double nBlueModulation,
double nAlphaModulation );
- }
}
-#endif // INCLUDED_CANVAS_SOURCE_DIRECTX_DX_IMPLTOOLS_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_linepolypolygon.hxx b/canvas/source/directx/dx_linepolypolygon.hxx
index 87311136a46f..eaec483a024d 100644
--- a/canvas/source/directx/dx_linepolypolygon.hxx
+++ b/canvas/source/directx/dx_linepolypolygon.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_LINEPOLYPOLYGON_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_LINEPOLYPOLYGON_HXX
+#pragma once
#include <canvas/canvastools.hxx>
#include <basegfx/utils/unopolypolygon.hxx>
@@ -45,6 +44,4 @@ namespace dxcanvas
};
}
-#endif // INCLUDED_CANVAS_SOURCE_DIRECTX_DX_LINEPOLYPOLYGON_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_rendermodule.hxx b/canvas/source/directx/dx_rendermodule.hxx
index 0ab154182543..4b13937967a2 100644
--- a/canvas/source/directx/dx_rendermodule.hxx
+++ b/canvas/source/directx/dx_rendermodule.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_RENDERMODULE_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_RENDERMODULE_HXX
+#pragma once
#include <basegfx/vector/b2ivector.hxx>
#include <basegfx/range/b2irectangle.hxx>
@@ -61,9 +60,9 @@ namespace dxcanvas
/// Write a snapshot of the screen to disk
virtual void screenShot() = 0;
- virtual COMReference<surface_type>
+ virtual sal::systools::COMReference<surface_type>
createSystemMemorySurface(
- const ::basegfx::B2IVector& rSize ) = 0;
+ const ::basegfx::B2ISize& rSize) = 0;
virtual void disposing() = 0;
virtual HWND getHWND() const = 0;
@@ -78,6 +77,4 @@ namespace dxcanvas
IDXRenderModuleSharedPtr createRenderModule( const vcl::Window& rParent );
}
-#endif
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_sprite.hxx b/canvas/source/directx/dx_sprite.hxx
index 82c43fbde8b9..c1f75e1b1e98 100644
--- a/canvas/source/directx/dx_sprite.hxx
+++ b/canvas/source/directx/dx_sprite.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_SPRITE_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_SPRITE_HXX
+#pragma once
#include <base/sprite.hxx>
@@ -43,6 +42,4 @@ namespace dxcanvas
};
}
-#endif // INCLUDED_CANVAS_SOURCE_DIRECTX_DX_SPRITE_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_spritecanvas.cxx b/canvas/source/directx/dx_spritecanvas.cxx
index eb589dfa9344..f4fe39203f4b 100644
--- a/canvas/source/directx/dx_spritecanvas.cxx
+++ b/canvas/source/directx/dx_spritecanvas.cxx
@@ -31,8 +31,7 @@
#include <cppuhelper/supportsservice.hxx>
#include <osl/mutex.hxx>
#include <toolkit/helper/vclunohelper.hxx>
-#include <tools/diagnose_ex.h>
-#include <vcl/window.hxx>
+#include <comphelper/diagnose_ex.hxx>
#include <canvas/canvastools.hxx>
@@ -178,21 +177,13 @@ namespace dxcanvas
return maDeviceHelper.getBackBuffer();
}
- static uno::Reference<uno::XInterface> initCanvas( SpriteCanvas* pCanvas )
- {
- uno::Reference<uno::XInterface> xRet(static_cast<cppu::OWeakObject*>(pCanvas));
- pCanvas->initialize();
- return xRet;
- }
-
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
canvas_directx9_SpriteCanvas_get_implementation(
css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& args)
{
rtl::Reference<SpriteCanvas> xCanvas(new SpriteCanvas(args, context));
xCanvas->initialize();
- xCanvas->acquire();
- return static_cast<cppu::OWeakObject*>(xCanvas.get());
+ return cppu::acquire(xCanvas.get());
}
}
diff --git a/canvas/source/directx/dx_spritecanvas.hxx b/canvas/source/directx/dx_spritecanvas.hxx
index 26f62f4e68ba..081337f72cfc 100644
--- a/canvas/source/directx/dx_spritecanvas.hxx
+++ b/canvas/source/directx/dx_spritecanvas.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_SPRITECANVAS_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_SPRITECANVAS_HXX
+#pragma once
#include <rtl/ref.hxx>
@@ -153,6 +152,4 @@ namespace dxcanvas
typedef ::rtl::Reference< SpriteCanvas > SpriteCanvasRef;
}
-#endif
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_spritecanvashelper.cxx b/canvas/source/directx/dx_spritecanvashelper.cxx
index 416c66ba5fca..d676fa2a802f 100644
--- a/canvas/source/directx/dx_spritecanvashelper.cxx
+++ b/canvas/source/directx/dx_spritecanvashelper.cxx
@@ -24,7 +24,7 @@
#include <basegfx/range/b2drectangle.hxx>
#include <basegfx/utils/canvastools.hxx>
#include <comphelper/scopeguard.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <canvas/canvastools.hxx>
diff --git a/canvas/source/directx/dx_spritecanvashelper.hxx b/canvas/source/directx/dx_spritecanvashelper.hxx
index 9e99489cd75a..5c2d98ba818e 100644
--- a/canvas/source/directx/dx_spritecanvashelper.hxx
+++ b/canvas/source/directx/dx_spritecanvashelper.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_SPRITECANVASHELPER_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_SPRITECANVASHELPER_HXX
+#pragma once
#include <com/sun/star/rendering/XSpriteCanvas.hpp>
#include <com/sun/star/rendering/XIntegerBitmap.hpp>
@@ -150,6 +149,4 @@ namespace dxcanvas
};
}
-#endif // INCLUDED_CANVAS_SOURCE_DIRECTX_DX_SPRITECANVASHELPER_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_spritedevicehelper.cxx b/canvas/source/directx/dx_spritedevicehelper.cxx
index ee339c8af0ee..622246bc2adc 100644
--- a/canvas/source/directx/dx_spritedevicehelper.cxx
+++ b/canvas/source/directx/dx_spritedevicehelper.cxx
@@ -27,7 +27,7 @@
#include <canvas/canvastools.hxx>
#include <com/sun/star/lang/NoSupportException.hpp>
#include <toolkit/helper/vclunohelper.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <vcl/sysdata.hxx>
#include <vcl/window.hxx>
@@ -80,7 +80,7 @@ namespace dxcanvas
catch (...) {
throw lang::NoSupportException( "Could not create DirectX device!",
- static_cast< ::cppu::OWeakObject* >(&rSpriteCanvas) );
+ rSpriteCanvas.getXWeak() );
}
// create the surfaceproxy manager
@@ -88,7 +88,7 @@ namespace dxcanvas
// #i60490# ensure backbuffer has sensible minimal size
mpBackBuffer = std::make_shared<DXSurfaceBitmap>(
- ::basegfx::B2ISize(w,h),
+ basegfx::B2ISize(w,h),
mpSurfaceProxyManager,
mpRenderModule,
false);
diff --git a/canvas/source/directx/dx_spritedevicehelper.hxx b/canvas/source/directx/dx_spritedevicehelper.hxx
index 1e77a66fca97..ad7417770667 100644
--- a/canvas/source/directx/dx_spritedevicehelper.hxx
+++ b/canvas/source/directx/dx_spritedevicehelper.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_SPRITEDEVICEHELPER_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_SPRITEDEVICEHELPER_HXX
+#pragma once
#include <com/sun/star/awt/Rectangle.hpp>
#include <com/sun/star/rendering/XGraphicDevice.hpp>
@@ -96,6 +95,4 @@ namespace dxcanvas
};
}
-#endif // INCLUDED_CANVAS_SOURCE_DIRECTX_DX_SPRITEDEVICEHELPER_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_spritehelper.cxx b/canvas/source/directx/dx_spritehelper.cxx
index af4f340a5437..3cb211886a3c 100644
--- a/canvas/source/directx/dx_spritehelper.cxx
+++ b/canvas/source/directx/dx_spritehelper.cxx
@@ -29,7 +29,7 @@
#include <basegfx/polygon/b2dpolypolygontools.hxx>
#include <basegfx/utils/canvastools.hxx>
#include <rtl/math.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <canvas/canvastools.hxx>
@@ -55,7 +55,7 @@ namespace dxcanvas
const DXSurfaceBitmapSharedPtr& rBitmap,
bool bShowSpriteBounds )
{
- ENSURE_OR_THROW( rSpriteCanvas.get() &&
+ ENSURE_OR_THROW( rSpriteCanvas &&
rRenderModule &&
rBitmap,
"SpriteHelper::init(): Invalid device, sprite canvas or surface" );
@@ -67,7 +67,7 @@ namespace dxcanvas
// also init base class
CanvasCustomSpriteHelper::init( rSpriteSize,
- rSpriteCanvas.get() );
+ rSpriteCanvas );
}
void SpriteHelper::disposing()
@@ -87,7 +87,7 @@ namespace dxcanvas
bool SpriteHelper::needRedraw() const
{
if( !mpBitmap ||
- !mpSpriteCanvas.get() )
+ !mpSpriteCanvas )
{
return false; // we're disposed, no redraw necessary
}
@@ -104,7 +104,7 @@ namespace dxcanvas
void SpriteHelper::redraw( bool& io_bSurfaceDirty ) const
{
if( !mpBitmap ||
- !mpSpriteCanvas.get() )
+ !mpSpriteCanvas )
{
return; // we're disposed
}
diff --git a/canvas/source/directx/dx_spritehelper.hxx b/canvas/source/directx/dx_spritehelper.hxx
index bc559c60127b..86e6dbaf6c12 100644
--- a/canvas/source/directx/dx_spritehelper.hxx
+++ b/canvas/source/directx/dx_spritehelper.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_SPRITEHELPER_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_SPRITEHELPER_HXX
+#pragma once
#include <com/sun/star/rendering/XCustomSprite.hpp>
@@ -100,6 +99,4 @@ namespace dxcanvas
};
}
-#endif // INCLUDED_CANVAS_SOURCE_DIRECTX_DX_SPRITEHELPER_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_surfacebitmap.cxx b/canvas/source/directx/dx_surfacebitmap.cxx
index 52c83de26829..c425af2911ce 100644
--- a/canvas/source/directx/dx_surfacebitmap.cxx
+++ b/canvas/source/directx/dx_surfacebitmap.cxx
@@ -26,7 +26,7 @@
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/range/b2irange.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <rendering/icolorbuffer.hxx>
#include "dx_graphicsprovider.hxx"
@@ -47,8 +47,8 @@ namespace dxcanvas
struct DXColorBuffer : public canvas::IColorBuffer
{
public:
- DXColorBuffer( const COMReference<surface_type>& rSurface,
- const ::basegfx::B2IVector& rSize )
+ DXColorBuffer( const sal::systools::COMReference<surface_type>& rSurface,
+ const ::basegfx::B2ISize& rSize )
: maSize(rSize)
, maLockedRect{}
, mpSurface(rSurface)
@@ -67,9 +67,9 @@ namespace dxcanvas
private:
- ::basegfx::B2IVector maSize;
+ ::basegfx::B2ISize maSize;
mutable D3DLOCKED_RECT maLockedRect;
- mutable COMReference<surface_type> mpSurface;
+ sal::systools::COMReference<surface_type> mpSurface;
};
sal_uInt8* DXColorBuffer::lock() const
@@ -86,12 +86,12 @@ namespace dxcanvas
sal_uInt32 DXColorBuffer::getWidth() const
{
- return maSize.getX();
+ return maSize.getWidth();
}
sal_uInt32 DXColorBuffer::getHeight() const
{
- return maSize.getY();
+ return maSize.getHeight();
}
sal_uInt32 DXColorBuffer::getStride() const
@@ -113,7 +113,7 @@ namespace dxcanvas
public:
GDIColorBuffer( const BitmapSharedPtr& rSurface,
- const ::basegfx::B2IVector& rSize )
+ const ::basegfx::B2ISize& rSize )
: maSize(rSize)
, aBmpData{}
, mpGDIPlusBitmap(rSurface)
@@ -132,15 +132,15 @@ namespace dxcanvas
private:
- ::basegfx::B2IVector maSize;
+ ::basegfx::B2ISize maSize;
mutable Gdiplus::BitmapData aBmpData;
BitmapSharedPtr mpGDIPlusBitmap;
};
sal_uInt8* GDIColorBuffer::lock() const
{
- aBmpData.Width = maSize.getX();
- aBmpData.Height = maSize.getY();
+ aBmpData.Width = maSize.getWidth();
+ aBmpData.Height = maSize.getHeight();
aBmpData.Stride = 4*aBmpData.Width;
aBmpData.PixelFormat = PixelFormat32bppARGB;
aBmpData.Scan0 = nullptr;
@@ -163,12 +163,12 @@ namespace dxcanvas
sal_uInt32 GDIColorBuffer::getWidth() const
{
- return maSize.getX();
+ return maSize.getWidth();
}
sal_uInt32 GDIColorBuffer::getHeight() const
{
- return maSize.getY();
+ return maSize.getHeight();
}
sal_uInt32 GDIColorBuffer::getStride() const
@@ -186,10 +186,10 @@ namespace dxcanvas
// DXSurfaceBitmap::DXSurfaceBitmap
- DXSurfaceBitmap::DXSurfaceBitmap( const ::basegfx::B2IVector& rSize,
+ DXSurfaceBitmap::DXSurfaceBitmap( const ::basegfx::B2ISize& rSize,
const std::shared_ptr<canvas::ISurfaceProxyManager>& rMgr,
- const IDXRenderModuleSharedPtr& rRenderModule,
- bool bWithAlpha ) :
+ const IDXRenderModuleSharedPtr& rRenderModule,
+ bool bWithAlpha ) :
mpGdiPlusUser( GDIPlusUser::createInstance() ),
maSize(rSize),
mpRenderModule(rRenderModule),
@@ -209,7 +209,7 @@ namespace dxcanvas
// DXSurfaceBitmap::getSize
- ::basegfx::B2IVector DXSurfaceBitmap::getSize() const
+ ::basegfx::B2ISize DXSurfaceBitmap::getSize() const
{
return maSize;
}
@@ -224,17 +224,17 @@ namespace dxcanvas
if(mbAlpha)
{
mpGDIPlusBitmap = std::make_shared<Gdiplus::Bitmap>(
- maSize.getX(),
- maSize.getY(),
+ maSize.getWidth(),
+ maSize.getHeight(),
PixelFormat32bppARGB
);
- mpGraphics.reset( tools::createGraphicsFromBitmap(mpGDIPlusBitmap) );
+ mpGraphics = tools::createGraphicsFromBitmap(mpGDIPlusBitmap);
// create the colorbuffer object, which is basically a simple
// wrapper around the directx surface. the colorbuffer is the
// interface which is used by the surfaceproxy to support any
// kind of underlying structure for the pixel data container.
- mpColorBuffer = std::make_shared<GDIColorBuffer>(mpGDIPlusBitmap,maSize);
+ mpColorBuffer = std::make_shared<GDIColorBuffer>(mpGDIPlusBitmap, maSize);
}
else
{
@@ -244,7 +244,7 @@ namespace dxcanvas
// wrapper around the directx surface. the colorbuffer is the
// interface which is used by the surfaceproxy to support any
// kind of underlying structure for the pixel data container.
- mpColorBuffer = std::make_shared<DXColorBuffer>(mpSurface,maSize);
+ mpColorBuffer = std::make_shared<DXColorBuffer>(mpSurface, maSize);
}
// create a (possibly hardware accelerated) mirror surface.
@@ -255,7 +255,7 @@ namespace dxcanvas
// DXSurfaceBitmap::resize
- bool DXSurfaceBitmap::resize( const ::basegfx::B2IVector& rSize )
+ bool DXSurfaceBitmap::resize(const ::basegfx::B2ISize& rSize)
{
if(maSize != rSize)
{
@@ -324,7 +324,7 @@ namespace dxcanvas
Gdiplus::PixelFormat nFormat = hasAlpha() ? PixelFormat32bppARGB : PixelFormat32bppRGB;
// construct a gdi+ bitmap from the raw pixel data.
- pResult = std::make_shared<Gdiplus::Bitmap>( maSize.getX(),maSize.getY(),
+ pResult = std::make_shared<Gdiplus::Bitmap>(maSize.getWidth(), maSize.getHeight(),
aLockedRect.Pitch,
nFormat,
static_cast<BYTE *>(aLockedRect.pBits) );
@@ -526,7 +526,7 @@ namespace dxcanvas
// getMemoryLayout
&aBmpData ) )
{
- throw uno::RuntimeException();
+ throw uno::RuntimeException("GDIPlus method call was unsuccessful, problem with locking bitmap aRect object");
}
// commit data to bitmap
@@ -540,9 +540,9 @@ namespace dxcanvas
// lock the directx surface to receive the pointer to the surface memory.
D3DLOCKED_RECT aLockedRect;
if(FAILED(mpSurface->LockRect(&aLockedRect,nullptr,D3DLOCK_NOSYSLOCK|D3DLOCK_READONLY)))
- throw uno::RuntimeException();
+ throw uno::RuntimeException("failed to lock directx surface to surface memory");
- sal_uInt8 const *pSrc = reinterpret_cast<sal_uInt8 const *>(data.getConstArray());
+ auto* pSrc = data.getConstArray();
sal_uInt8 *pDst = (static_cast<BYTE *>(aLockedRect.pBits)+(rect.Y1*aLockedRect.Pitch))+rect.X1;
sal_uInt32 nSegmentSizeInBytes = nWidth<<4;
for(sal_uInt32 y=0; y<nHeight; ++y)
@@ -568,7 +568,7 @@ namespace dxcanvas
{
if(hasAlpha())
{
- const geometry::IntegerSize2D aSize( maSize.getX(),maSize.getY() );
+ const geometry::IntegerSize2D aSize( maSize.getWidth(), maSize.getHeight() );
ENSURE_ARG_OR_THROW( pos.X >= 0 && pos.X < aSize.Width,
"CanvasHelper::setPixel: X coordinate out of bounds" );
@@ -580,14 +580,14 @@ namespace dxcanvas
if( Gdiplus::Ok != mpGDIPlusBitmap->SetPixel( pos.X, pos.Y,
Gdiplus::Color( tools::sequenceToArgb( color ))))
{
- throw uno::RuntimeException();
+ throw uno::RuntimeException("Problem with setting the color of bitmap object");
}
}
else
{
- ENSURE_ARG_OR_THROW( pos.X >= 0 && pos.X < maSize.getX(),
+ ENSURE_ARG_OR_THROW( pos.X >= 0 && pos.X < maSize.getWidth(),
"CanvasHelper::setPixel: X coordinate out of bounds" );
- ENSURE_ARG_OR_THROW( pos.Y >= 0 && pos.Y < maSize.getY(),
+ ENSURE_ARG_OR_THROW( pos.Y >= 0 && pos.Y < maSize.getHeight(),
"CanvasHelper::setPixel: Y coordinate out of bounds" );
ENSURE_ARG_OR_THROW( color.getLength() > 3,
"CanvasHelper::setPixel: not enough color components" );
@@ -597,7 +597,7 @@ namespace dxcanvas
// lock the directx surface to receive the pointer to the surface memory.
D3DLOCKED_RECT aLockedRect;
if(FAILED(mpSurface->LockRect(&aLockedRect,nullptr,D3DLOCK_NOSYSLOCK|D3DLOCK_READONLY)))
- throw uno::RuntimeException();
+ throw uno::RuntimeException("cannot lock the directx surface to surface memory");
sal_uInt32 *pDst = reinterpret_cast<sal_uInt32 *>((static_cast<BYTE *>(aLockedRect.pBits)+(pos.Y*aLockedRect.Pitch))+pos.X);
*pDst = aColor.GetValue();
@@ -616,7 +616,7 @@ namespace dxcanvas
{
if(hasAlpha())
{
- const geometry::IntegerSize2D aSize( maSize.getX(),maSize.getY() );
+ const geometry::IntegerSize2D aSize(maSize.getWidth(), maSize.getHeight());
ENSURE_ARG_OR_THROW( pos.X >= 0 && pos.X < aSize.Width,
"CanvasHelper::getPixel: X coordinate out of bounds" );
@@ -632,15 +632,15 @@ namespace dxcanvas
}
else
{
- ENSURE_ARG_OR_THROW( pos.X >= 0 && pos.X < maSize.getX(),
+ ENSURE_ARG_OR_THROW( pos.X >= 0 && pos.X < maSize.getWidth(),
"CanvasHelper::getPixel: X coordinate out of bounds" );
- ENSURE_ARG_OR_THROW( pos.Y >= 0 && pos.Y < maSize.getY(),
+ ENSURE_ARG_OR_THROW( pos.Y >= 0 && pos.Y < maSize.getHeight(),
"CanvasHelper::getPixel: Y coordinate out of bounds" );
// lock the directx surface to receive the pointer to the surface memory.
D3DLOCKED_RECT aLockedRect;
if(FAILED(mpSurface->LockRect(&aLockedRect,nullptr,D3DLOCK_NOSYSLOCK|D3DLOCK_READONLY)))
- throw uno::RuntimeException();
+ throw uno::RuntimeException("failed to lock directX surface to surface memory");
sal_uInt32 *pDst = reinterpret_cast<sal_uInt32 *>((static_cast<BYTE *>(aLockedRect.pBits)+(pos.Y*aLockedRect.Pitch))+pos.X);
Gdiplus::Color aColor(*pDst);
diff --git a/canvas/source/directx/dx_surfacebitmap.hxx b/canvas/source/directx/dx_surfacebitmap.hxx
index 75cd630c6b6a..f39ebb5b9727 100644
--- a/canvas/source/directx/dx_surfacebitmap.hxx
+++ b/canvas/source/directx/dx_surfacebitmap.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_SURFACEBITMAP_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_SURFACEBITMAP_HXX
+#pragma once
#include <rendering/isurfaceproxy.hxx>
#include <rendering/isurfaceproxymanager.hxx>
@@ -32,21 +31,21 @@ namespace dxcanvas
class DXSurfaceBitmap : public IBitmap
{
public:
- DXSurfaceBitmap( const ::basegfx::B2IVector& rSize,
+ DXSurfaceBitmap( const ::basegfx::B2ISize& rSize,
const std::shared_ptr<canvas::ISurfaceProxyManager>& rMgr,
const IDXRenderModuleSharedPtr& rRenderModule,
bool bWithAlpha );
- bool resize( const ::basegfx::B2IVector& rSize );
+ bool resize(const ::basegfx::B2ISize& rSize);
void clear();
virtual GraphicsSharedPtr getGraphics() override;
virtual BitmapSharedPtr getBitmap() const override;
- virtual ::basegfx::B2IVector getSize() const override;
+ virtual ::basegfx::B2ISize getSize() const override;
virtual bool hasAlpha() const override;
- COMReference<surface_type> getSurface() const { return mpSurface; }
+ sal::systools::COMReference<surface_type> getSurface() const { return mpSurface; }
bool draw( double fAlpha,
const ::basegfx::B2DPoint& rPos,
@@ -89,7 +88,7 @@ namespace dxcanvas
GDIPlusUserSharedPtr mpGdiPlusUser;
// size of this image in pixels [integral unit]
- ::basegfx::B2IVector maSize;
+ ::basegfx::B2ISize maSize;
// pointer to the rendermodule, needed to create surfaces
// which are used as container for the actual pixel data.
@@ -108,7 +107,7 @@ namespace dxcanvas
// container for pixel data, we need to use a directx
// surface since GDI+ sucks...
- COMReference<surface_type> mpSurface;
+ sal::systools::COMReference<surface_type> mpSurface;
// since GDI+ does not work correctly in case we
// run on a 16bit display [don't ask me why] we need
@@ -133,6 +132,4 @@ namespace dxcanvas
typedef std::shared_ptr< DXSurfaceBitmap > DXSurfaceBitmapSharedPtr;
}
-#endif
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_surfacegraphics.cxx b/canvas/source/directx/dx_surfacegraphics.cxx
index c4f03e9db6ec..075f2fc15341 100644
--- a/canvas/source/directx/dx_surfacegraphics.cxx
+++ b/canvas/source/directx/dx_surfacegraphics.cxx
@@ -30,10 +30,10 @@ namespace dxcanvas
{
struct GraphicsDeleter
{
- COMReference<surface_type> mpSurface;
+ sal::systools::COMReference<surface_type> mpSurface;
HDC maHDC;
- GraphicsDeleter(const COMReference<surface_type>& rSurface, HDC hdc) :
+ GraphicsDeleter(const sal::systools::COMReference<surface_type>& rSurface, HDC hdc) :
mpSurface(rSurface),
maHDC(hdc)
{}
@@ -52,7 +52,7 @@ namespace dxcanvas
};
}
- GraphicsSharedPtr createSurfaceGraphics(const COMReference<surface_type>& rSurface )
+ GraphicsSharedPtr createSurfaceGraphics(const sal::systools::COMReference<surface_type>& rSurface )
{
GraphicsSharedPtr pRet;
HDC aHDC;
@@ -70,7 +70,7 @@ namespace dxcanvas
rSurface->ReleaseDC( aHDC );
}
- throw uno::RuntimeException();
+ throw uno::RuntimeException("could not get the DC to rSurface");
}
}
diff --git a/canvas/source/directx/dx_surfacegraphics.hxx b/canvas/source/directx/dx_surfacegraphics.hxx
index 930add339333..4260383e2ed8 100644
--- a/canvas/source/directx/dx_surfacegraphics.hxx
+++ b/canvas/source/directx/dx_surfacegraphics.hxx
@@ -17,23 +17,20 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_SURFACEGRAPHICS_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_SURFACEGRAPHICS_HXX
+#pragma once
#include "dx_graphicsprovider.hxx"
namespace dxcanvas
{
- /** Container providing a Gdiplus::Graphics for a Surface
+/** Container providing a Gdiplus::Graphics for a Surface
- This wrapper class transparently handles allocation and
- release of surface resources the RAII way (the
- GraphicsSharedPtr returned has a deleter that does all the
- necessary DX cleanup work).
- */
- GraphicsSharedPtr createSurfaceGraphics(const COMReference<surface_type>& rSurface );
+ This wrapper class transparently handles allocation and
+ release of surface resources the RAII way (the
+ GraphicsSharedPtr returned has a deleter that does all the
+ necessary DX cleanup work).
+*/
+GraphicsSharedPtr createSurfaceGraphics(const sal::systools::COMReference<surface_type>& rSurface);
}
-#endif // INCLUDED_CANVAS_SOURCE_DIRECTX_DX_SURFACEGRAPHICS_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_textlayout.cxx b/canvas/source/directx/dx_textlayout.cxx
index 5e69f70df624..e64dde596693 100644
--- a/canvas/source/directx/dx_textlayout.cxx
+++ b/canvas/source/directx/dx_textlayout.cxx
@@ -93,6 +93,26 @@ namespace dxcanvas
maLogicalAdvancements = aAdvancements;
}
+ uno::Sequence< sal_Bool > SAL_CALL TextLayout::queryKashidaPositions( )
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return maKashidaPositions;
+ }
+
+ void SAL_CALL TextLayout::applyKashidaPositions( const uno::Sequence< sal_Bool >& aPositions )
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if( aPositions.hasElements() && aPositions.getLength() != maText.Length )
+ {
+ SAL_WARN("canvas.directx", "TextLayout::applyKashidaPositions(): mismatching number of positions" );
+ throw lang::IllegalArgumentException("mismatching number of positions", getXWeak(), 1);
+ }
+
+ maKashidaPositions = aPositions;
+ }
+
geometry::RealRectangle2D SAL_CALL TextLayout::queryTextBounds( )
{
::osl::MutexGuard aGuard( m_aMutex );
@@ -105,7 +125,7 @@ namespace dxcanvas
aDrawHelper.queryTextBounds(
maText,
maLogicalAdvancements,
- mpFont.get(),
+ mpFont,
mpFont->getFontMatrix()));
return aBounds;
@@ -176,7 +196,7 @@ namespace dxcanvas
{
::osl::MutexGuard aGuard( m_aMutex );
- return mpFont.get();
+ return mpFont;
}
rendering::StringContext SAL_CALL TextLayout::getText( )
@@ -205,7 +225,8 @@ namespace dxcanvas
rOutputOffset,
maText,
maLogicalAdvancements,
- mpFont.get(),
+ maKashidaPositions,
+ mpFont,
mpFont->getFontMatrix(),
bAlphaSurface,
mnTextDirection != 0);
diff --git a/canvas/source/directx/dx_textlayout.hxx b/canvas/source/directx/dx_textlayout.hxx
index b24a1c8f00dc..f0ae523e7b6a 100644
--- a/canvas/source/directx/dx_textlayout.hxx
+++ b/canvas/source/directx/dx_textlayout.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_TEXTLAYOUT_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_TEXTLAYOUT_HXX
+#pragma once
#include <cppuhelper/compbase.hxx>
#include <cppuhelper/basemutex.hxx>
@@ -62,6 +61,8 @@ namespace dxcanvas
virtual css::uno::Sequence< css::geometry::RealRectangle2D > SAL_CALL queryMeasures( ) override;
virtual css::uno::Sequence< double > SAL_CALL queryLogicalAdvancements( ) override;
virtual void SAL_CALL applyLogicalAdvancements( const css::uno::Sequence< double >& aAdvancements ) override;
+ virtual css::uno::Sequence< sal_Bool > SAL_CALL queryKashidaPositions( ) override;
+ virtual void SAL_CALL applyKashidaPositions( const css::uno::Sequence< sal_Bool >& aPositions ) override;
virtual css::geometry::RealRectangle2D SAL_CALL queryTextBounds( ) override;
virtual double SAL_CALL justify( double nSize ) override;
virtual double SAL_CALL combinedJustify( const css::uno::Sequence< css::uno::Reference< css::rendering::XTextLayout > >& aNextLayouts, double nSize ) override;
@@ -96,12 +97,11 @@ namespace dxcanvas
css::rendering::StringContext maText;
css::uno::Sequence< double > maLogicalAdvancements;
+ css::uno::Sequence< sal_Bool > maKashidaPositions;
CanvasFont::ImplRef mpFont;
sal_Int8 mnTextDirection;
};
}
-#endif // INCLUDED_CANVAS_SOURCE_DIRECTX_DX_TEXTLAYOUT_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_textlayout_drawhelper.cxx b/canvas/source/directx/dx_textlayout_drawhelper.cxx
index ea628079e7ff..cc72436ccf50 100644
--- a/canvas/source/directx/dx_textlayout_drawhelper.cxx
+++ b/canvas/source/directx/dx_textlayout_drawhelper.cxx
@@ -21,6 +21,7 @@
#include <memory>
+#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/polygon/b2dpolypolygon.hxx>
#include <basegfx/utils/canvastools.hxx>
#include <com/sun/star/rendering/FontRequest.hpp>
@@ -30,9 +31,10 @@
#include <i18nlangtag/languagetag.hxx>
#include <rtl/math.hxx>
#include <tools/color.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <tools/poly.hxx>
#include <vcl/canvastools.hxx>
+#include <vcl/kernarray.hxx>
#include <vcl/metric.hxx>
#include <vcl/sysdata.hxx>
#include <vcl/virdev.hxx>
@@ -66,6 +68,7 @@ namespace dxcanvas
const ::basegfx::B2ISize& rOutputOffset,
const css::rendering::StringContext& rText,
const css::uno::Sequence< double >& rLogicalAdvancements,
+ const css::uno::Sequence< sal_Bool >& rKashidaPositions,
const css::uno::Reference<
css::rendering::XCanvasFont >& rCanvasFont,
const css::geometry::Matrix2D& rFontMatrix,
@@ -81,7 +84,7 @@ namespace dxcanvas
SystemGraphicsData aSystemGraphicsData;
aSystemGraphicsData.nSize = sizeof(SystemGraphicsData);
aSystemGraphicsData.hDC = reinterpret_cast< ::HDC >(hdc);
- ScopedVclPtrInstance<VirtualDevice> xVirtualDevice(aSystemGraphicsData, Size(1, 1), DeviceFormat::DEFAULT);
+ ScopedVclPtrInstance<VirtualDevice> xVirtualDevice(aSystemGraphicsData, Size(1, 1), DeviceFormat::WITHOUT_ALPHA);
// disable font antialiasing - GDI does not handle alpha
// surfaces properly.
@@ -101,7 +104,7 @@ namespace dxcanvas
aColor = vcl::unotools::doubleSequenceToColor(
rRenderState.DeviceColor,
mxGraphicDevice->getDeviceColorSpace());
- aColor.SetTransparency(0);
+ aColor.SetAlpha(255);
xVirtualDevice->SetTextColor(aColor);
// create the font
@@ -109,7 +112,7 @@ namespace dxcanvas
vcl::Font aFont(
rFontRequest.FontDescription.FamilyName,
rFontRequest.FontDescription.StyleName,
- Size( 0, ::basegfx::fround(rFontRequest.CellSize)));
+ Size( 0, ::basegfx::fround<::tools::Long>(rFontRequest.CellSize)));
aFont.SetAlignment( ALIGN_BASELINE );
aFont.SetCharSet( (rFontRequest.FontDescription.IsSymbolFont==css::util::TriState_YES) ? RTL_TEXTENCODING_SYMBOL : RTL_TEXTENCODING_UNICODE );
@@ -154,7 +157,7 @@ namespace dxcanvas
if(!rOutputOffset.equalZero())
{
- aWorldTransform.translate(rOutputOffset.getX(), rOutputOffset.getY());
+ aWorldTransform.translate(rOutputOffset.getWidth(), rOutputOffset.getHeight());
}
// set ViewState clipping
@@ -166,7 +169,7 @@ namespace dxcanvas
if(!rOutputOffset.equalZero())
{
- aMatrix.translate(rOutputOffset.getX(), rOutputOffset.getY());
+ aMatrix.translate(rOutputOffset.getWidth(), rOutputOffset.getHeight());
}
aClipPoly.transform(aMatrix);
@@ -205,15 +208,14 @@ namespace dxcanvas
if( rLogicalAdvancements.getLength() )
{
// create the DXArray
- const sal_Int32 nLen( rLogicalAdvancements.getLength() );
- std::unique_ptr<sal_Int32[]> pDXArray( new sal_Int32[nLen] );
- for( sal_Int32 i=0; i<nLen; ++i )
- pDXArray[i] = basegfx::fround( rLogicalAdvancements[i] );
+ KernArraySpan DXArray( rLogicalAdvancements.getConstArray(), rLogicalAdvancements.getLength() );
+ std::span<const sal_Bool> aKashidaArray(rKashidaPositions.getConstArray(), rKashidaPositions.getLength());
// draw the String
xVirtualDevice->DrawTextArray( aEmptyPoint,
aText,
- pDXArray.get(),
+ DXArray,
+ aKashidaArray,
rText.StartPosition,
rText.Length,
bIsRTL ? SalLayoutFlags::BiDiRtl : SalLayoutFlags::NONE);
@@ -242,14 +244,14 @@ namespace dxcanvas
SystemGraphicsData aSystemGraphicsData;
aSystemGraphicsData.nSize = sizeof(SystemGraphicsData);
aSystemGraphicsData.hDC = reinterpret_cast< ::HDC >(GetDC( nullptr ));
- ScopedVclPtrInstance<VirtualDevice> xVirtualDevice(aSystemGraphicsData, Size(1, 1), DeviceFormat::DEFAULT);
+ ScopedVclPtrInstance<VirtualDevice> xVirtualDevice(aSystemGraphicsData, Size(1, 1), DeviceFormat::WITHOUT_ALPHA);
// create the font
const css::rendering::FontRequest& rFontRequest = rCanvasFont->getFontRequest();
vcl::Font aFont(
rFontRequest.FontDescription.FamilyName,
rFontRequest.FontDescription.StyleName,
- Size( 0, ::basegfx::fround(rFontRequest.CellSize)));
+ Size( 0, ::basegfx::fround<::tools::Long>(rFontRequest.CellSize)));
aFont.SetAlignment( ALIGN_BASELINE );
aFont.SetCharSet( (rFontRequest.FontDescription.IsSymbolFont==css::util::TriState_YES) ? RTL_TEXTENCODING_SYMBOL : RTL_TEXTENCODING_UNICODE );
diff --git a/canvas/source/directx/dx_textlayout_drawhelper.hxx b/canvas/source/directx/dx_textlayout_drawhelper.hxx
index 0448c39aa8d0..1c88c1987aff 100644
--- a/canvas/source/directx/dx_textlayout_drawhelper.hxx
+++ b/canvas/source/directx/dx_textlayout_drawhelper.hxx
@@ -17,8 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_TEXTLAYOUT_DRAWHELPER_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_TEXTLAYOUT_DRAWHELPER_HXX
+#pragma once
#include <memory>
@@ -27,8 +26,9 @@
#include <com/sun/star/rendering/XCanvasFont.hpp>
#include <com/sun/star/geometry/Matrix2D.hpp>
#include <com/sun/star/rendering/XGraphicDevice.hpp>
+#include <com/sun/star/rendering/ViewState.hpp>
+#include <com/sun/star/rendering/RenderState.hpp>
-#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/vector/b2isize.hxx>
namespace com::sun::star::rendering { class XCanvasFont; }
@@ -37,7 +37,6 @@ namespace Gdiplus { class Graphics; }
namespace dxcanvas
{
- struct Bitmap;
class TextLayoutDrawHelper
{
public:
@@ -52,6 +51,7 @@ namespace dxcanvas
const ::basegfx::B2ISize& rOutputOffset,
const css::rendering::StringContext& rText,
const css::uno::Sequence< double >& rLogicalAdvancements,
+ const css::uno::Sequence< sal_Bool >& rKashidaPositions,
const css::uno::Reference<
css::rendering::XCanvasFont >& rCanvasFont,
const css::geometry::Matrix2D& rFontMatrix,
@@ -74,6 +74,4 @@ namespace dxcanvas
};
}
-#endif // INCLUDED_CANVAS_SOURCE_DIRECTX_DX_TEXTLAYOUT_DRAWHELPER_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_vcltools.cxx b/canvas/source/directx/dx_vcltools.cxx
index 287ed7beda54..8e1201ae692f 100644
--- a/canvas/source/directx/dx_vcltools.cxx
+++ b/canvas/source/directx/dx_vcltools.cxx
@@ -22,10 +22,10 @@
#include <basegfx/numeric/ftools.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/rendering/XIntegerBitmap.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <vcl/bitmap.hxx>
#include <vcl/bitmapex.hxx>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <vcl/canvastools.hxx>
#include "dx_impltools.hxx"
@@ -33,10 +33,8 @@
using namespace ::com::sun::star;
-namespace dxcanvas
+namespace dxcanvas::tools
{
- namespace tools
- {
namespace
{
/// Calc number of colors in given BitmapInfoHeader
@@ -65,12 +63,11 @@ namespace dxcanvas
/// Draw DI bits to given Graphics
bool drawDIBits( const std::shared_ptr< Gdiplus::Graphics >& rGraphics,
- const void* hDIB )
+ void* pDIB )
{
bool bRet( false );
- BitmapSharedPtr pBitmap;
- const BITMAPINFO* pBI = static_cast<BITMAPINFO*>(GlobalLock( const_cast<void *>(hDIB) ));
+ const BITMAPINFO* pBI = static_cast<BITMAPINFO*>(pDIB);
if( pBI )
{
@@ -80,8 +77,6 @@ namespace dxcanvas
// forward to outsourced GDI+ rendering method
// (header clashes)
bRet = tools::drawDIBits( rGraphics, *pBI, pBits );
-
- GlobalUnlock( const_cast<void *>(hDIB) );
}
return bRet;
@@ -103,7 +98,7 @@ namespace dxcanvas
{
// first of all, ensure that Bitmap contains a DIB, by
// acquiring a read access
- BitmapReadAccess* pReadAcc = rBmp.AcquireReadAccess();
+ BitmapScopedReadAccess pReadAcc(rBmp);
// TODO(P2): Acquiring a read access can actually
// force a read from VRAM, thus, avoiding this
@@ -119,8 +114,6 @@ namespace dxcanvas
return drawDIBits( rGraphics,
aBmpSysData.pDIB );
}
-
- Bitmap::ReleaseAccess( pReadAcc );
}
}
else
@@ -133,7 +126,7 @@ namespace dxcanvas
return false;
}
- /** Create a chunk of raw RGBA data GDI+ Bitmap from VCL BbitmapEX
+ /** Create a chunk of raw RGBA data GDI+ Bitmap from VCL BitmapEx
*/
RawRGBABitmap bitmapFromVCLBitmapEx( const ::BitmapEx& rBmpEx )
{
@@ -143,9 +136,9 @@ namespace dxcanvas
// make the local bitmap copy unique, effectively
// duplicating the memory used)
- ENSURE_OR_THROW( rBmpEx.IsTransparent(),
+ ENSURE_OR_THROW( rBmpEx.IsAlpha(),
"::dxcanvas::tools::bitmapFromVCLBitmapEx(): "
- "BmpEx not transparent" );
+ "BmpEx has no alpha" );
// convert transparent bitmap to 32bit RGBA
// ========================================
@@ -159,7 +152,7 @@ namespace dxcanvas
Bitmap aBitmap( rBmpEx.GetBitmap() );
- Bitmap::ScopedReadAccess pReadAccess( aBitmap );
+ BitmapScopedReadAccess pReadAccess( aBitmap );
const sal_Int32 nWidth( aBmpSize.Width() );
const sal_Int32 nHeight( aBmpSize.Height() );
@@ -168,45 +161,40 @@ namespace dxcanvas
"::dxcanvas::tools::bitmapFromVCLBitmapEx(): "
"Unable to acquire read access to bitmap" );
- if( rBmpEx.IsAlpha() || rBmpEx.GetMask().GetBitCount() == 8 )
- {
- Bitmap aAlpha( rBmpEx.IsAlpha() ? rBmpEx.GetAlpha().GetBitmap() : rBmpEx.GetMask());
+ Bitmap aAlpha( rBmpEx.GetAlphaMask().GetBitmap() );
- Bitmap::ScopedReadAccess pAlphaReadAccess( aAlpha );
+ BitmapScopedReadAccess pAlphaReadAccess( aAlpha );
- // By convention, the access buffer always has
- // one of the following formats:
+ // By convention, the access buffer always has
+ // one of the following formats:
- // ScanlineFormat::N1BitMsbPal
- // ScanlineFormat::N4BitMsnPal
- // ScanlineFormat::N8BitPal
- // ScanlineFormat::N24BitTcBgr
- // ScanlineFormat::N32BitTcMask
+ // ScanlineFormat::N1BitMsbPal
+ // ScanlineFormat::N8BitPal
+ // ScanlineFormat::N24BitTcBgr
- // and is always ScanlineFormat::BottomUp
+ // and is always ScanlineFormat::BottomUp
- // This is the way
- // WinSalBitmap::AcquireBuffer() sets up the
- // buffer
+ // This is the way
+ // WinSalBitmap::AcquireBuffer() sets up the
+ // buffer
- ENSURE_OR_THROW( pAlphaReadAccess.get() != nullptr,
- "::dxcanvas::tools::bitmapFromVCLBitmapEx(): "
- "Unable to acquire read access to alpha" );
+ ENSURE_OR_THROW( pAlphaReadAccess.get() != nullptr,
+ "::dxcanvas::tools::bitmapFromVCLBitmapEx(): "
+ "Unable to acquire read access to alpha" );
- ENSURE_OR_THROW( pAlphaReadAccess->GetScanlineFormat() == ScanlineFormat::N8BitPal ||
- pAlphaReadAccess->GetScanlineFormat() == ScanlineFormat::N8BitTcMask,
- "::dxcanvas::tools::bitmapFromVCLBitmapEx(): "
- "Unsupported alpha scanline format" );
+ ENSURE_OR_THROW( pAlphaReadAccess->GetScanlineFormat() == ScanlineFormat::N8BitPal,
+ "::dxcanvas::tools::bitmapFromVCLBitmapEx(): "
+ "Unsupported alpha scanline format" );
- BitmapColor aCol;
- sal_uInt8* pCurrOutput(aBmpData.maBitmapData.data());
- int x, y;
+ BitmapColor aCol;
+ sal_uInt8* pCurrOutput(aBmpData.maBitmapData.data());
+ int x, y;
- for( y=0; y<nHeight; ++y )
+ for( y=0; y<nHeight; ++y )
+ {
+ switch( pReadAccess->GetScanlineFormat() )
{
- switch( pReadAccess->GetScanlineFormat() )
- {
- case ScanlineFormat::N8BitPal:
+ case ScanlineFormat::N8BitPal:
{
Scanline pScan = pReadAccess->GetScanline( y );
Scanline pAScan = pAlphaReadAccess->GetScanline( y );
@@ -218,16 +206,12 @@ namespace dxcanvas
*pCurrOutput++ = aCol.GetBlue();
*pCurrOutput++ = aCol.GetGreen();
*pCurrOutput++ = aCol.GetRed();
-
- // out notion of alpha is
- // different from the rest
- // of the world's
- *pCurrOutput++ = 255 - static_cast<BYTE>(*pAScan++);
+ *pCurrOutput++ = static_cast<BYTE>(*pAScan++);
}
}
break;
- case ScanlineFormat::N24BitTcBgr:
+ case ScanlineFormat::N24BitTcBgr:
{
Scanline pScan = pReadAccess->GetScanline( y );
Scanline pAScan = pAlphaReadAccess->GetScanline( y );
@@ -238,11 +222,7 @@ namespace dxcanvas
*pCurrOutput++ = *pScan++;
*pCurrOutput++ = *pScan++;
*pCurrOutput++ = *pScan++;
-
- // out notion of alpha is
- // different from the rest
- // of the world's
- *pCurrOutput++ = 255 - static_cast<BYTE>(*pAScan++);
+ *pCurrOutput++ = static_cast<BYTE>(*pAScan++);
}
}
break;
@@ -250,9 +230,7 @@ namespace dxcanvas
// TODO(P2): Might be advantageous
// to hand-formulate the following
// formats, too.
- case ScanlineFormat::N1BitMsbPal:
- case ScanlineFormat::N4BitMsnPal:
- case ScanlineFormat::N32BitTcMask:
+ case ScanlineFormat::N1BitMsbPal:
{
Scanline pAScan = pAlphaReadAccess->GetScanline( y );
@@ -266,164 +244,25 @@ namespace dxcanvas
*pCurrOutput++ = aCol.GetBlue();
*pCurrOutput++ = aCol.GetGreen();
*pCurrOutput++ = aCol.GetRed();
-
- // out notion of alpha is
- // different from the rest
- // of the world's
- *pCurrOutput++ = 255 - static_cast<BYTE>(*pAScan++);
- }
- }
- break;
-
- case ScanlineFormat::N1BitLsbPal:
- case ScanlineFormat::N4BitLsnPal:
- case ScanlineFormat::N8BitTcMask:
- case ScanlineFormat::N24BitTcRgb:
- case ScanlineFormat::N32BitTcAbgr:
- case ScanlineFormat::N32BitTcArgb:
- case ScanlineFormat::N32BitTcBgra:
- case ScanlineFormat::N32BitTcRgba:
- default:
- ENSURE_OR_THROW( false,
- "::dxcanvas::tools::bitmapFromVCLBitmapEx(): "
- "Unexpected scanline format - has "
- "WinSalBitmap::AcquireBuffer() changed?" );
- }
- }
- }
- else
- {
- Bitmap aMask( rBmpEx.GetMask() );
-
- Bitmap::ScopedReadAccess pMaskReadAccess( aMask );
-
- // By convention, the access buffer always has
- // one of the following formats:
-
- // ScanlineFormat::N1BitMsbPal
- // ScanlineFormat::N4BitMsnPal
- // ScanlineFormat::N8BitPal
- // ScanlineFormat::N24BitTcBgr
- // ScanlineFormat::N32BitTcMask
-
- // and is always ScanlineFormat::BottomUp
-
- // This is the way
- // WinSalBitmap::AcquireBuffer() sets up the
- // buffer
-
- ENSURE_OR_THROW( pMaskReadAccess.get() != nullptr,
- "::dxcanvas::tools::bitmapFromVCLBitmapEx(): "
- "Unable to acquire read access to mask" );
-
- ENSURE_OR_THROW( pMaskReadAccess->GetScanlineFormat() == ScanlineFormat::N1BitMsbPal,
- "::dxcanvas::tools::bitmapFromVCLBitmapEx(): "
- "Unsupported mask scanline format" );
-
- BitmapColor aCol;
- int nCurrBit;
- const int nMask( 1 );
- const int nInitialBit(7);
- sal_uInt8* pCurrOutput(aBmpData.maBitmapData.data());
- int x, y;
-
- // mapping table, to get from mask index color to
- // alpha value (which depends on the mask's palette)
- sal_uInt8 aColorMap[2];
-
- const BitmapColor& rCol0( pMaskReadAccess->GetPaletteColor( 0 ) );
- const BitmapColor& rCol1( pMaskReadAccess->GetPaletteColor( 1 ) );
-
- // shortcut for true luminance calculation
- // (assumes that palette is grey-level). Note the
- // swapped the indices here, to account for the
- // fact that VCL's notion of alpha is inverted to
- // the rest of the world's.
- aColorMap[0] = rCol1.GetRed();
- aColorMap[1] = rCol0.GetRed();
-
- for( y=0; y<nHeight; ++y )
- {
- switch( pReadAccess->GetScanlineFormat() )
- {
- case ScanlineFormat::N8BitPal:
- {
- Scanline pScan = pReadAccess->GetScanline( y );
- Scanline pMScan = pMaskReadAccess->GetScanline( y );
-
- for( x=0, nCurrBit=nInitialBit; x<nWidth; ++x )
- {
- aCol = pReadAccess->GetPaletteColor( *pScan++ );
-
- *pCurrOutput++ = aCol.GetBlue();
- *pCurrOutput++ = aCol.GetGreen();
- *pCurrOutput++ = aCol.GetRed();
-
- *pCurrOutput++ = aColorMap[ (pMScan[ (x & ~7) >> 3 ] >> nCurrBit ) & nMask ];
- nCurrBit = ((nCurrBit - 1) % 8) & 7;
- }
- }
- break;
-
- case ScanlineFormat::N24BitTcBgr:
- {
- Scanline pScan = pReadAccess->GetScanline( y );
- Scanline pMScan = pMaskReadAccess->GetScanline( y );
-
- for( x=0, nCurrBit=nInitialBit; x<nWidth; ++x )
- {
- // store as RGBA
- *pCurrOutput++ = *pScan++;
- *pCurrOutput++ = *pScan++;
- *pCurrOutput++ = *pScan++;
-
- *pCurrOutput++ = aColorMap[ (pMScan[ (x & ~7) >> 3 ] >> nCurrBit ) & nMask ];
- nCurrBit = ((nCurrBit - 1) % 8) & 7;
- }
- }
- break;
-
- // TODO(P2): Might be advantageous
- // to hand-formulate the following
- // formats, too.
- case ScanlineFormat::N1BitMsbPal:
- case ScanlineFormat::N4BitMsnPal:
- case ScanlineFormat::N32BitTcMask:
- {
- Scanline pMScan = pMaskReadAccess->GetScanline( y );
-
- // using fallback for those
- // seldom formats
- for( x=0, nCurrBit=nInitialBit; x<nWidth; ++x )
- {
- // yes. x and y are swapped on Get/SetPixel
- aCol = pReadAccess->GetColor(y,x);
-
- // store as RGBA
- *pCurrOutput++ = aCol.GetBlue();
- *pCurrOutput++ = aCol.GetGreen();
- *pCurrOutput++ = aCol.GetRed();
-
- *pCurrOutput++ = aColorMap[ (pMScan[ (x & ~7) >> 3 ] >> nCurrBit ) & nMask ];
- nCurrBit = ((nCurrBit - 1) % 8) & 7;
+ *pCurrOutput++ = static_cast<BYTE>(*pAScan++);
}
}
break;
- case ScanlineFormat::N1BitLsbPal:
- case ScanlineFormat::N4BitLsnPal:
- case ScanlineFormat::N8BitTcMask:
- case ScanlineFormat::N24BitTcRgb:
- case ScanlineFormat::N32BitTcAbgr:
- case ScanlineFormat::N32BitTcArgb:
- case ScanlineFormat::N32BitTcBgra:
- case ScanlineFormat::N32BitTcRgba:
- default:
- ENSURE_OR_THROW( false,
- "::dxcanvas::tools::bitmapFromVCLBitmapEx(): "
- "Unexpected scanline format - has "
- "WinSalBitmap::AcquireBuffer() changed?" );
- }
+ case ScanlineFormat::N24BitTcRgb:
+ case ScanlineFormat::N32BitTcAbgr:
+ case ScanlineFormat::N32BitTcArgb:
+ case ScanlineFormat::N32BitTcBgra:
+ case ScanlineFormat::N32BitTcRgba:
+ case ScanlineFormat::N32BitTcXbgr:
+ case ScanlineFormat::N32BitTcXrgb:
+ case ScanlineFormat::N32BitTcBgrx:
+ case ScanlineFormat::N32BitTcRgbx:
+ default:
+ ENSURE_OR_THROW( false,
+ "::dxcanvas::tools::bitmapFromVCLBitmapEx(): "
+ "Unexpected scanline format - has "
+ "WinSalBitmap::AcquireBuffer() changed?" );
}
}
@@ -433,7 +272,7 @@ namespace dxcanvas
bool drawVCLBitmapEx( const std::shared_ptr< Gdiplus::Graphics >& rGraphics,
const ::BitmapEx& rBmpEx )
{
- if( !rBmpEx.IsTransparent() )
+ if( !rBmpEx.IsAlpha() )
{
Bitmap aBmp( rBmpEx.GetBitmap() );
return drawVCLBitmap( rGraphics, aBmp );
@@ -457,12 +296,12 @@ namespace dxcanvas
return false;
::BitmapEx aBmpEx = vcl::unotools::bitmapExFromXBitmap( xIntBmp );
- if( !aBmpEx )
+ if( aBmpEx.IsEmpty() )
return false;
return drawVCLBitmapEx( rGraphics, aBmpEx );
}
- }
}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_vcltools.hxx b/canvas/source/directx/dx_vcltools.hxx
index 8eb5ea90b2a4..433afa618eb7 100644
--- a/canvas/source/directx/dx_vcltools.hxx
+++ b/canvas/source/directx/dx_vcltools.hxx
@@ -17,19 +17,17 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_VCLTOOLS_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_VCLTOOLS_HXX
+#pragma once
#include <com/sun/star/uno/Reference.hxx>
-#include <com/sun/star/util/TriState.hpp>
+#include <com/sun/star/rendering/XBitmap.hpp>
#include <memory>
+#include <vector>
namespace Gdiplus { class Graphics; }
-namespace dxcanvas
+namespace dxcanvas::tools
{
- namespace tools
- {
/** Raw RGBA bitmap data,
contiguous in memory
*/
@@ -43,9 +41,7 @@ namespace dxcanvas
bool drawVCLBitmapFromXBitmap( const std::shared_ptr< Gdiplus::Graphics >& rGraphics,
const css::uno::Reference<
css::rendering::XBitmap >& xBitmap );
- }
}
-#endif // INCLUDED_CANVAS_SOURCE_DIRECTX_DX_VCLTOOLS_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_winstuff.hxx b/canvas/source/directx/dx_winstuff.hxx
index c585071796e7..4cd0007fa955 100644
--- a/canvas/source/directx/dx_winstuff.hxx
+++ b/canvas/source/directx/dx_winstuff.hxx
@@ -17,16 +17,13 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_WINSTUFF_HXX
-#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_WINSTUFF_HXX
+#pragma once
#include <algorithm>
#include <memory>
#include <basegfx/numeric/ftools.hxx>
-
-#define WIN32_LEAN_AND_MEAN
#include <prewin.h>
// Enabling Direct3D Debug Information Further more, with registry key
@@ -63,92 +60,12 @@ namespace dxcanvas
typedef std::shared_ptr< Gdiplus::Bitmap > BitmapSharedPtr;
typedef std::shared_ptr< Gdiplus::Font > FontSharedPtr;
typedef std::shared_ptr< Gdiplus::TextureBrush > TextureBrushSharedPtr;
-
- /** COM object RAII wrapper
-
- This template wraps a Windows COM object, transparently
- handling lifetime issues the C++ way (i.e. releasing the
- reference when the object is destroyed)
- */
- template< typename T > class COMReference
- {
- public:
- typedef T Wrappee;
-
- COMReference() :
- mp( nullptr )
- {
- }
-
- /** Create from raw pointer
-
- @attention This constructor assumes the interface is
- already acquired (unless p is NULL), no additional AddRef
- is called here.
-
- This caters e.g. for all DirectX factory methods, which
- return the created interfaces pre-acquired, into a raw
- pointer. Simply pass the pointer to this class, but don't
- call Release manually on it!
-
- @example IDirectDrawSurface* pSurface;
- pDD->CreateSurface(&aSurfaceDesc, &pSurface, NULL);
- mpSurface = COMReference< IDirectDrawSurface >(pSurface);
-
- */
- explicit COMReference( T* p ) :
- mp( p )
- {
- }
-
- COMReference( const COMReference& rNew ) :
- mp( nullptr )
- {
- if( rNew.mp == nullptr )
- return;
-
- rNew.mp->AddRef(); // do that _before_ assigning the
- // pointer. Just in case...
- mp = rNew.mp;
- }
-
- COMReference& operator=( const COMReference& rRHS )
- {
- COMReference aTmp(rRHS);
- std::swap( mp, aTmp.mp );
-
- return *this;
- }
-
- ~COMReference()
- {
- reset();
- }
-
- int reset()
- {
- int refcount = 0;
- if( mp )
- refcount = mp->Release();
-
- mp = nullptr;
- return refcount;
- }
-
- bool is() const { return mp != nullptr; }
- T* get() const { return mp; }
- T* operator->() const { return mp; }
- T& operator*() const { return *mp; }
-
- private:
- T* mp;
- };
-
}
+#include <systools/win32/comtools.hxx> // for COMReference; must be inside prewin...postwin
+// Attention! All DirectX factory methods return the created interfaces pre-acquired, into a raw
+// pointer. Do not call AddRef on them when constructing COMReference!
#include <postwin.h>
-#endif // INCLUDED_CANVAS_SOURCE_DIRECTX_DX_WINSTUFF_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */