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/.
10 #ifndef INCLUDED_CANVAS_SOURCE_OPENGL_OGL_SPRITEDEVICEHELPER_HXX
11 #define INCLUDED_CANVAS_SOURCE_OPENGL_OGL_SPRITEDEVICEHELPER_HXX
13 #include <vcl/opengl/OpenGLContext.hxx>
15 #include <rtl/ref.hxx>
16 #include <canvas/elapsedtime.hxx>
17 #include <com/sun/star/rendering/XGraphicDevice.hpp>
18 #include <boost/utility.hpp>
19 #include <boost/shared_ptr.hpp>
21 #include "ogl_buffercontext.hxx"
25 namespace vcl
{ class Window
; }
26 class SystemChildWindow
;
27 namespace basegfx
{ class B2IVector
; class B2DHomMatrix
; }
28 namespace com
{ namespace sun
{ namespace star
{
29 namespace awt
{ struct Rectangle
; }
30 namespace geometry
{ struct AffineMatrix2D
; }
37 class CanvasCustomSprite
;
40 class SpriteDeviceHelper
: private ::boost::noncopyable
44 ~SpriteDeviceHelper();
46 void init( vcl::Window
& rWindow
,
47 SpriteCanvas
& rSpriteCanvas
,
48 const ::com::sun::star::awt::Rectangle
& rViewArea
);
50 /// Dispose all internal references
53 // XWindowGraphicDevice
54 ::com::sun::star::geometry::RealSize2D
getPhysicalResolution();
55 ::com::sun::star::geometry::RealSize2D
getPhysicalSize();
56 ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XLinePolyPolygon2D
> createCompatibleLinePolyPolygon(
57 const ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XGraphicDevice
>& rDevice
,
58 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Sequence
< ::com::sun::star::geometry::RealPoint2D
> >& points
);
59 ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XBezierPolyPolygon2D
> createCompatibleBezierPolyPolygon(
60 const ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XGraphicDevice
>& rDevice
,
61 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Sequence
< ::com::sun::star::geometry::RealBezierSegment2D
> >& points
);
62 ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XBitmap
> createCompatibleBitmap(
63 const ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XGraphicDevice
>& rDevice
,
64 const ::com::sun::star::geometry::IntegerSize2D
& size
);
65 ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XVolatileBitmap
> createVolatileBitmap(
66 const ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XGraphicDevice
>& rDevice
,
67 const ::com::sun::star::geometry::IntegerSize2D
& size
);
68 ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XBitmap
> createCompatibleAlphaBitmap(
69 const ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XGraphicDevice
>& rDevice
,
70 const ::com::sun::star::geometry::IntegerSize2D
& size
);
71 ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XVolatileBitmap
> createVolatileAlphaBitmap(
72 const ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XGraphicDevice
>& rDevice
,
73 const ::com::sun::star::geometry::IntegerSize2D
& size
);
75 bool showBuffer( bool bIsVisible
, bool bUpdateAll
);
76 bool switchBuffer( bool bIsVisible
, bool bUpdateAll
);
78 ::com::sun::star::uno::Any
isAccelerated() const;
79 ::com::sun::star::uno::Any
getDeviceHandle() const;
80 ::com::sun::star::uno::Any
getSurfaceHandle() const;
81 ::com::sun::star::uno::Reference
<
82 ::com::sun::star::rendering::XColorSpace
> getColorSpace() const;
84 void notifySizeUpdate( const ::com::sun::star::awt::Rectangle
& rBounds
);
86 /** called when DumpScreenContent property is enabled on
87 XGraphicDevice, and writes out bitmaps of current screen.
89 void dumpScreenContent() const;
91 void show( const ::rtl::Reference
< CanvasCustomSprite
>& );
92 void hide( const ::rtl::Reference
< CanvasCustomSprite
>& );
94 /// enable linear gradient shader "texture" with given parameters
95 void useLinearGradientShader( const ::com::sun::star::rendering::ARGBColor
* pColors
,
96 const ::com::sun::star::uno::Sequence
< double >& rStops
,
97 const ::basegfx::B2DHomMatrix
& rTexTransform
);
98 /// enable radial gradient shader "texture" with given parameters
99 void useRadialGradientShader( const ::com::sun::star::rendering::ARGBColor
* pColors
,
100 const ::com::sun::star::uno::Sequence
< double >& rStops
,
101 const ::basegfx::B2DHomMatrix
& rTexTransform
);
102 /// enable rectangular gradient shader "texture" with given parameters
103 void useRectangularGradientShader( const ::com::sun::star::rendering::ARGBColor
* pColors
,
104 const ::com::sun::star::uno::Sequence
< double >& rStops
,
105 const ::basegfx::B2DHomMatrix
& rTexTransform
);
107 /// create a pbuffer context (for rendering into background surface)
108 IBufferContextSharedPtr
createBufferContext(const ::basegfx::B2IVector
& rSize
) const;
110 /// Get instance of internal texture cache
111 TextureCache
& getTextureCache() const;
113 bool activateWindowContext();
116 void resize( const ::basegfx::B2IVector
& rNewSize
);
118 /** Phyical output device
120 Deliberately not a refcounted reference, because of
121 potential circular references for canvas. Needed to
124 com::sun::star::rendering::XGraphicDevice
* mpDevice
;
126 /// Pointer to sprite canvas (owner of this helper), needed to create bitmaps
127 SpriteCanvas
* mpSpriteCanvas
;
129 std::set
< ::rtl::Reference
< CanvasCustomSprite
> > maActiveSprites
;
131 /// For the frame counter timings
132 ::canvas::tools::ElapsedTime maLastUpdate
;
134 boost::shared_ptr
<TextureCache
> mpTextureCache
;
136 unsigned int mnLinearTwoColorGradientProgram
;
137 unsigned int mnLinearMultiColorGradientProgram
;
138 unsigned int mnRadialTwoColorGradientProgram
;
139 unsigned int mnRadialMultiColorGradientProgram
;
140 unsigned int mnRectangularTwoColorGradientProgram
;
141 unsigned int mnRectangularMultiColorGradientProgram
;
143 rtl::Reference
<OpenGLContext
> mxContext
;
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */