LibreOffice Module canvas (master)  1
ogl_spritedevicehelper.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  */
9 
10 #pragma once
11 
13 
14 #include <rtl/ref.hxx>
15 #include <canvas/elapsedtime.hxx>
16 #include <com/sun/star/rendering/XGraphicDevice.hpp>
17 
18 #include "ogl_buffercontext.hxx"
19 
20 #include <set>
21 
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; }
27 
28 
29 namespace oglcanvas
30 {
31  class TextureCache;
32  class SpriteCanvas;
33  class CanvasCustomSprite;
34  class CanvasHelper;
35 
37  {
38  public:
41 
43  SpriteDeviceHelper(const SpriteDeviceHelper&) = delete;
44  const SpriteDeviceHelper& operator=(const SpriteDeviceHelper&) = delete;
45 
46  void init( vcl::Window& rWindow,
47  SpriteCanvas& rSpriteCanvas,
48  const css::awt::Rectangle& rViewArea );
49 
51  void disposing();
52 
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 );
74 
75  bool showBuffer( bool bIsVisible, bool bUpdateAll );
76  bool switchBuffer( bool bIsVisible, bool bUpdateAll );
77 
78  css::uno::Any isAccelerated() const;
79  css::uno::Any getDeviceHandle() const;
80  css::uno::Any getSurfaceHandle() const;
81  css::uno::Reference<
82  css::rendering::XColorSpace > getColorSpace() const;
83 
84  void notifySizeUpdate( const css::awt::Rectangle& rBounds );
85 
89  void dumpScreenContent() const;
90 
91  void show( const ::rtl::Reference< CanvasCustomSprite >& );
92  void hide( const ::rtl::Reference< CanvasCustomSprite >& );
93 
95  void useLinearGradientShader( const css::rendering::ARGBColor* pColors,
96  const css::uno::Sequence< double >& rStops,
97  const ::basegfx::B2DHomMatrix& rTexTransform );
99  void useRadialGradientShader( const css::rendering::ARGBColor* pColors,
100  const css::uno::Sequence< double >& rStops,
101  const ::basegfx::B2DHomMatrix& rTexTransform );
103  void useRectangularGradientShader( const css::rendering::ARGBColor* pColors,
104  const css::uno::Sequence< double >& rStops,
105  const ::basegfx::B2DHomMatrix& rTexTransform );
106 
108  IBufferContextSharedPtr createBufferContext(const ::basegfx::B2IVector& rSize) const;
109 
111  TextureCache& getTextureCache() const;
112 
113  private:
116 
117  std::set< ::rtl::Reference< CanvasCustomSprite > > maActiveSprites;
118 
121 
122  std::shared_ptr<TextureCache> mpTextureCache;
123 
130 
132  };
133 }
134 
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void disposing()
Dispose all internal references.
void useRadialGradientShader(const css::rendering::ARGBColor *pColors, const css::uno::Sequence< double > &rStops, const ::basegfx::B2DHomMatrix &rTexTransform)
enable radial gradient shader "texture" with given parameters
void dumpScreenContent() const
called when DumpScreenContent property is enabled on XGraphicDevice, and writes out bitmaps of curren...
std::shared_ptr< TextureCache > mpTextureCache
css::uno::Reference< css::rendering::XVolatileBitmap > createVolatileAlphaBitmap(const css::uno::Reference< css::rendering::XGraphicDevice > &rDevice, const css::geometry::IntegerSize2D &size)
TextureCache & getTextureCache() const
Get instance of internal texture cache.
Calculate elapsed time.
Definition: elapsedtime.hxx:34
const SpriteDeviceHelper & operator=(const SpriteDeviceHelper &)=delete
void useRectangularGradientShader(const css::rendering::ARGBColor *pColors, const css::uno::Sequence< double > &rStops, const ::basegfx::B2DHomMatrix &rTexTransform)
enable rectangular gradient shader "texture" with given parameters
css::uno::Reference< css::rendering::XVolatileBitmap > createVolatileBitmap(const css::uno::Reference< css::rendering::XGraphicDevice > &rDevice, const css::geometry::IntegerSize2D &size)
void show(const ::rtl::Reference< CanvasCustomSprite > &)
std::shared_ptr< IBufferContext > IBufferContextSharedPtr
css::geometry::RealSize2D getPhysicalSize()
bool showBuffer(bool bIsVisible, bool bUpdateAll)
::canvas::tools::ElapsedTime maLastUpdate
For the frame counter timings.
IBufferContextSharedPtr createBufferContext(const ::basegfx::B2IVector &rSize) const
create a pbuffer context (for rendering into background surface)
bool switchBuffer(bool bIsVisible, bool bUpdateAll)
css::uno::Reference< css::rendering::XColorSpace > getColorSpace() const
rtl::Reference< OpenGLContext > mxContext
size
css::uno::Reference< css::rendering::XBezierPolyPolygon2D > createCompatibleBezierPolyPolygon(const css::uno::Reference< css::rendering::XGraphicDevice > &rDevice, const css::uno::Sequence< css::uno::Sequence< css::geometry::RealBezierSegment2D > > &points)
void notifySizeUpdate(const css::awt::Rectangle &rBounds)
css::uno::Reference< css::rendering::XBitmap > createCompatibleAlphaBitmap(const css::uno::Reference< css::rendering::XGraphicDevice > &rDevice, const css::geometry::IntegerSize2D &size)
void init(vcl::Window &rWindow, SpriteCanvas &rSpriteCanvas, const css::awt::Rectangle &rViewArea)
Product of this component's factory.
css::uno::Reference< css::rendering::XBitmap > createCompatibleBitmap(const css::uno::Reference< css::rendering::XGraphicDevice > &rDevice, const css::geometry::IntegerSize2D &size)
void hide(const ::rtl::Reference< CanvasCustomSprite > &)
css::geometry::RealSize2D getPhysicalResolution()
std::set< ::rtl::Reference< CanvasCustomSprite > > maActiveSprites
css::uno::Reference< css::rendering::XLinePolyPolygon2D > createCompatibleLinePolyPolygon(const css::uno::Reference< css::rendering::XGraphicDevice > &rDevice, const css::uno::Sequence< css::uno::Sequence< css::geometry::RealPoint2D > > &points)
void useLinearGradientShader(const css::rendering::ARGBColor *pColors, const css::uno::Sequence< double > &rStops, const ::basegfx::B2DHomMatrix &rTexTransform)
enable linear gradient shader "texture" with given parameters
SpriteCanvas * mpSpriteCanvas
Pointer to sprite canvas (owner of this helper), needed to create bitmaps.