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/.
12 #include <vcl/opengl/OpenGLContext.hxx>
14 #include <rtl/ref.hxx>
15 #include <canvas/elapsedtime.hxx>
16 #include <com/sun/star/rendering/XGraphicDevice.hpp>
18 #include "ogl_buffercontext.hxx"
22 namespace vcl
{ class Window
; }
23 class SystemChildWindow
;
24 namespace basegfx
{ class B2IVector
; class B2DHomMatrix
; }
25 namespace com::sun::star::awt
{ struct Rectangle
; }
26 namespace com::sun::star::geometry
{ struct AffineMatrix2D
; }
33 class CanvasCustomSprite
;
36 class SpriteDeviceHelper
40 ~SpriteDeviceHelper();
43 SpriteDeviceHelper(const SpriteDeviceHelper
&) = delete;
44 const SpriteDeviceHelper
& operator=(const SpriteDeviceHelper
&) = delete;
46 void init( vcl::Window
& rWindow
,
47 SpriteCanvas
& rSpriteCanvas
,
48 const css::awt::Rectangle
& rViewArea
);
50 /// Dispose all internal references
53 // XWindowGraphicDevice
54 css::geometry::RealSize2D
getPhysicalResolution();
55 css::geometry::RealSize2D
getPhysicalSize();
56 css::uno::Reference
< css::rendering::XLinePolyPolygon2D
> createCompatibleLinePolyPolygon(
57 const css::uno::Reference
< css::rendering::XGraphicDevice
>& rDevice
,
58 const css::uno::Sequence
< css::uno::Sequence
< css::geometry::RealPoint2D
> >& points
);
59 css::uno::Reference
< css::rendering::XBezierPolyPolygon2D
> createCompatibleBezierPolyPolygon(
60 const css::uno::Reference
< css::rendering::XGraphicDevice
>& rDevice
,
61 const css::uno::Sequence
< css::uno::Sequence
< css::geometry::RealBezierSegment2D
> >& points
);
62 css::uno::Reference
< css::rendering::XBitmap
> createCompatibleBitmap(
63 const css::uno::Reference
< css::rendering::XGraphicDevice
>& rDevice
,
64 const css::geometry::IntegerSize2D
& size
);
65 css::uno::Reference
< css::rendering::XVolatileBitmap
> createVolatileBitmap(
66 const css::uno::Reference
< css::rendering::XGraphicDevice
>& rDevice
,
67 const css::geometry::IntegerSize2D
& size
);
68 css::uno::Reference
< css::rendering::XBitmap
> createCompatibleAlphaBitmap(
69 const css::uno::Reference
< css::rendering::XGraphicDevice
>& rDevice
,
70 const css::geometry::IntegerSize2D
& size
);
71 css::uno::Reference
< css::rendering::XVolatileBitmap
> createVolatileAlphaBitmap(
72 const css::uno::Reference
< css::rendering::XGraphicDevice
>& rDevice
,
73 const css::geometry::IntegerSize2D
& size
);
75 bool showBuffer( bool bIsVisible
, bool bUpdateAll
);
76 bool switchBuffer( bool bIsVisible
, bool bUpdateAll
);
78 css::uno::Any
isAccelerated() const;
79 css::uno::Any
getDeviceHandle() const;
80 css::uno::Any
getSurfaceHandle() const;
82 css::rendering::XColorSpace
> getColorSpace() const;
84 void notifySizeUpdate( const css::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 css::rendering::ARGBColor
* pColors
,
96 const css::uno::Sequence
< double >& rStops
,
97 const ::basegfx::B2DHomMatrix
& rTexTransform
);
98 /// enable radial gradient shader "texture" with given parameters
99 void useRadialGradientShader( const css::rendering::ARGBColor
* pColors
,
100 const css::uno::Sequence
< double >& rStops
,
101 const ::basegfx::B2DHomMatrix
& rTexTransform
);
102 /// enable rectangular gradient shader "texture" with given parameters
103 void useRectangularGradientShader( const css::rendering::ARGBColor
* pColors
,
104 const css::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;
114 /// Pointer to sprite canvas (owner of this helper), needed to create bitmaps
115 SpriteCanvas
* mpSpriteCanvas
;
117 std::set
< ::rtl::Reference
< CanvasCustomSprite
> > maActiveSprites
;
119 /// For the frame counter timings
120 ::canvas::tools::ElapsedTime maLastUpdate
;
122 std::shared_ptr
<TextureCache
> mpTextureCache
;
124 unsigned int mnLinearTwoColorGradientProgram
;
125 unsigned int mnLinearMultiColorGradientProgram
;
126 unsigned int mnRadialTwoColorGradientProgram
;
127 unsigned int mnRadialMultiColorGradientProgram
;
128 unsigned int mnRectangularTwoColorGradientProgram
;
129 unsigned int mnRectangularMultiColorGradientProgram
;
131 rtl::Reference
<OpenGLContext
> mxContext
;
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */