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 .
22 #include <vcl/window.hxx>
23 #include <vcl/canvastools.hxx>
24 #include <canvas/debug.hxx>
25 #include <canvas/verbosetrace.hxx>
26 #include <canvas/canvastools.hxx>
27 #include <tools/diagnose_ex.h>
29 #include <osl/mutex.hxx>
30 #include <cppuhelper/compbase1.hxx>
32 #include <com/sun/star/lang/NoSupportException.hpp>
33 #include <toolkit/helper/vclunohelper.hxx>
34 #include <basegfx/tools/canvastools.hxx>
35 #include "dx_linepolypolygon.hxx"
36 #include "dx_spritecanvas.hxx"
37 #include "dx_canvasbitmap.hxx"
38 #include "dx_devicehelper.hxx"
39 #include "dx_winstuff.hxx"
41 #include <vcl/sysdata.hxx>
42 #include <vcl/outdev.hxx>
44 using namespace ::com::sun::star
;
48 DeviceHelper::DeviceHelper() :
55 DeviceHelper::~DeviceHelper()
59 void DeviceHelper::init( HDC hdc
, OutputDevice
* pOutDev
,
60 rendering::XGraphicDevice
& rDevice
)
67 void DeviceHelper::disposing()
69 // release all references
75 geometry::RealSize2D
DeviceHelper::getPhysicalResolution()
78 return ::canvas::tools::createInfiniteSize2D(); // we're disposed
82 "DeviceHelper::getPhysicalResolution(): cannot retrieve HDC from window" );
84 const int nHorzRes( GetDeviceCaps( hDC
,
86 const int nVertRes( GetDeviceCaps( hDC
,
89 return geometry::RealSize2D( nHorzRes
*25.4,
93 geometry::RealSize2D
DeviceHelper::getPhysicalSize()
96 return ::canvas::tools::createInfiniteSize2D(); // we're disposed
100 "DeviceHelper::getPhysicalSize(): cannot retrieve HDC from window" );
102 const int nHorzSize( GetDeviceCaps( hDC
,
104 const int nVertSize( GetDeviceCaps( hDC
,
107 return geometry::RealSize2D( nHorzSize
,
111 uno::Reference
< rendering::XLinePolyPolygon2D
> DeviceHelper::createCompatibleLinePolyPolygon(
112 const uno::Reference
< rendering::XGraphicDevice
>& /*rDevice*/,
113 const uno::Sequence
< uno::Sequence
< geometry::RealPoint2D
> >& points
)
116 return uno::Reference
< rendering::XLinePolyPolygon2D
>(); // we're disposed
118 return uno::Reference
< rendering::XLinePolyPolygon2D
>(
120 ::basegfx::unotools::polyPolygonFromPoint2DSequenceSequence( points
) ) );
123 uno::Reference
< rendering::XBezierPolyPolygon2D
> DeviceHelper::createCompatibleBezierPolyPolygon(
124 const uno::Reference
< rendering::XGraphicDevice
>& /*rDevice*/,
125 const uno::Sequence
< uno::Sequence
< geometry::RealBezierSegment2D
> >& points
)
128 return uno::Reference
< rendering::XBezierPolyPolygon2D
>(); // we're disposed
130 return uno::Reference
< rendering::XBezierPolyPolygon2D
>(
132 ::basegfx::unotools::polyPolygonFromBezier2DSequenceSequence( points
) ) );
135 uno::Reference
< rendering::XBitmap
> DeviceHelper::createCompatibleBitmap(
136 const uno::Reference
< rendering::XGraphicDevice
>& /*rDevice*/,
137 const geometry::IntegerSize2D
& size
)
140 return uno::Reference
< rendering::XBitmap
>(); // we're disposed
142 DXBitmapSharedPtr
pBitmap(
144 ::basegfx::unotools::b2ISizeFromIntegerSize2D(size
),
147 // create a 24bit RGB system memory surface
148 return uno::Reference
< rendering::XBitmap
>(new CanvasBitmap(pBitmap
,mpDevice
));
151 uno::Reference
< rendering::XVolatileBitmap
> DeviceHelper::createVolatileBitmap(
152 const uno::Reference
< rendering::XGraphicDevice
>& /*rDevice*/,
153 const geometry::IntegerSize2D
& /*size*/ )
155 return uno::Reference
< rendering::XVolatileBitmap
>();
158 uno::Reference
< rendering::XBitmap
> DeviceHelper::createCompatibleAlphaBitmap(
159 const uno::Reference
< rendering::XGraphicDevice
>& /*rDevice*/,
160 const geometry::IntegerSize2D
& size
)
163 return uno::Reference
< rendering::XBitmap
>(); // we're disposed
165 DXBitmapSharedPtr
pBitmap(
167 ::basegfx::unotools::b2ISizeFromIntegerSize2D(size
),
170 // create a 32bit ARGB system memory surface
171 return uno::Reference
< rendering::XBitmap
>(new CanvasBitmap(pBitmap
,mpDevice
));
174 uno::Reference
< rendering::XVolatileBitmap
> DeviceHelper::createVolatileAlphaBitmap(
175 const uno::Reference
< rendering::XGraphicDevice
>& /*rDevice*/,
176 const geometry::IntegerSize2D
& /*size*/ )
178 return uno::Reference
< rendering::XVolatileBitmap
>();
181 bool DeviceHelper::hasFullScreenMode()
186 bool DeviceHelper::enterFullScreenMode( bool /*bEnter*/ )
191 uno::Any
DeviceHelper::isAccelerated() const
193 return ::com::sun::star::uno::makeAny(false);
196 uno::Any
DeviceHelper::getDeviceHandle() const
198 return uno::makeAny( reinterpret_cast< sal_Int64
>(mpOutDev
.get()) );
201 uno::Any
DeviceHelper::getSurfaceHandle() const
203 // TODO(F1): expose DirectDraw object
204 //return mpBackBuffer->getBitmap().get();
210 struct DeviceColorSpace
: public rtl::StaticWithInit
<uno::Reference
<rendering::XColorSpace
>,
213 uno::Reference
<rendering::XColorSpace
> operator()()
215 return vcl::unotools::createStandardColorSpace();
220 uno::Reference
<rendering::XColorSpace
> DeviceHelper::getColorSpace() const
223 return DeviceColorSpace::get();
227 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */