1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
24 #include <basegfx/utils/canvastools.hxx>
25 #include <com/sun/star/lang/NoSupportException.hpp>
26 #include <comphelper/diagnose_ex.hxx>
27 #include <vcl/canvastools.hxx>
28 #include <vcl/outdev.hxx>
29 #include <vcl/sysdata.hxx>
31 #include <canvas/canvastools.hxx>
33 #include "dx_canvasbitmap.hxx"
34 #include "dx_devicehelper.hxx"
35 #include "dx_linepolypolygon.hxx"
36 #include "dx_spritecanvas.hxx"
37 #include "dx_winstuff.hxx"
39 using namespace ::com::sun::star
;
43 DeviceHelper::DeviceHelper() :
50 DeviceHelper::~DeviceHelper()
54 void DeviceHelper::init( HDC hdc
, OutputDevice
* pOutDev
,
55 rendering::XGraphicDevice
& rDevice
)
62 void DeviceHelper::disposing()
64 // release all references
70 geometry::RealSize2D
DeviceHelper::getPhysicalResolution()
73 return ::canvas::tools::createInfiniteSize2D(); // we're disposed
77 "DeviceHelper::getPhysicalResolution(): cannot retrieve HDC from window" );
79 const int nHorzRes( GetDeviceCaps( hDC
,
81 const int nVertRes( GetDeviceCaps( hDC
,
84 return geometry::RealSize2D( nHorzRes
*25.4,
88 geometry::RealSize2D
DeviceHelper::getPhysicalSize()
91 return ::canvas::tools::createInfiniteSize2D(); // we're disposed
95 "DeviceHelper::getPhysicalSize(): cannot retrieve HDC from window" );
97 const int nHorzSize( GetDeviceCaps( hDC
,
99 const int nVertSize( GetDeviceCaps( hDC
,
102 return geometry::RealSize2D( nHorzSize
,
106 uno::Reference
< rendering::XLinePolyPolygon2D
> DeviceHelper::createCompatibleLinePolyPolygon(
107 const uno::Reference
< rendering::XGraphicDevice
>& /*rDevice*/,
108 const uno::Sequence
< uno::Sequence
< geometry::RealPoint2D
> >& points
)
111 return uno::Reference
< rendering::XLinePolyPolygon2D
>(); // we're disposed
113 return uno::Reference
< rendering::XLinePolyPolygon2D
>(
115 ::basegfx::unotools::polyPolygonFromPoint2DSequenceSequence( points
) ) );
118 uno::Reference
< rendering::XBezierPolyPolygon2D
> DeviceHelper::createCompatibleBezierPolyPolygon(
119 const uno::Reference
< rendering::XGraphicDevice
>& /*rDevice*/,
120 const uno::Sequence
< uno::Sequence
< geometry::RealBezierSegment2D
> >& points
)
123 return uno::Reference
< rendering::XBezierPolyPolygon2D
>(); // we're disposed
125 return uno::Reference
< rendering::XBezierPolyPolygon2D
>(
127 ::basegfx::unotools::polyPolygonFromBezier2DSequenceSequence( points
) ) );
130 uno::Reference
< rendering::XBitmap
> DeviceHelper::createCompatibleBitmap(
131 const uno::Reference
< rendering::XGraphicDevice
>& /*rDevice*/,
132 const geometry::IntegerSize2D
& size
)
135 return uno::Reference
< rendering::XBitmap
>(); // we're disposed
137 DXBitmapSharedPtr pBitmap
= std::make_shared
<DXBitmap
>(
138 ::basegfx::unotools::b2ISizeFromIntegerSize2D(size
),
141 // create a 24bit RGB system memory surface
142 return uno::Reference
< rendering::XBitmap
>(new CanvasBitmap(pBitmap
,mpDevice
));
145 uno::Reference
< rendering::XVolatileBitmap
> DeviceHelper::createVolatileBitmap(
146 const uno::Reference
< rendering::XGraphicDevice
>& /*rDevice*/,
147 const geometry::IntegerSize2D
& /*size*/ )
149 return uno::Reference
< rendering::XVolatileBitmap
>();
152 uno::Reference
< rendering::XBitmap
> DeviceHelper::createCompatibleAlphaBitmap(
153 const uno::Reference
< rendering::XGraphicDevice
>& /*rDevice*/,
154 const geometry::IntegerSize2D
& size
)
157 return uno::Reference
< rendering::XBitmap
>(); // we're disposed
159 DXBitmapSharedPtr pBitmap
= std::make_shared
<DXBitmap
>(
160 ::basegfx::unotools::b2ISizeFromIntegerSize2D(size
),
163 // create a 32bit ARGB system memory surface
164 return uno::Reference
< rendering::XBitmap
>(new CanvasBitmap(pBitmap
,mpDevice
));
167 uno::Reference
< rendering::XVolatileBitmap
> DeviceHelper::createVolatileAlphaBitmap(
168 const uno::Reference
< rendering::XGraphicDevice
>& /*rDevice*/,
169 const geometry::IntegerSize2D
& /*size*/ )
171 return uno::Reference
< rendering::XVolatileBitmap
>();
174 uno::Any
DeviceHelper::isAccelerated() const
176 return css::uno::Any(false);
179 uno::Any
DeviceHelper::getDeviceHandle() const
181 return uno::Any( reinterpret_cast< sal_Int64
>(mpOutDev
.get()) );
184 uno::Any
DeviceHelper::getSurfaceHandle() const
186 // TODO(F1): expose DirectDraw object
187 //return mpBackBuffer->getBitmap().get();
191 uno::Reference
<rendering::XColorSpace
> DeviceHelper::getColorSpace() const
194 static uno::Reference
<rendering::XColorSpace
> theSpace
= vcl::unotools::createStandardColorSpace();
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */