16#include <com/sun/star/awt/XTopWindow.hpp>
17#include <com/sun/star/rendering/XIntegerBitmapColorSpace.hpp>
18#include <com/sun/star/uno/Reference.hxx>
36 glDisable(GL_CULL_FACE);
39 glMatrixMode(GL_PROJECTION);
43 glEnable(GL_POINT_SMOOTH);
44 glEnable(GL_LINE_SMOOTH);
45 glEnable(GL_POLYGON_SMOOTH);
46 glHint(GL_POINT_SMOOTH_HINT,GL_NICEST);
47 glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);
48 glHint(GL_POLYGON_SMOOTH_HINT,GL_NICEST);
49 glShadeModel(GL_FLAT);
56 static_cast<GLsizei
>(rSize.Width()),
57 static_cast<GLsizei
>(rSize.Height()) );
60 glMatrixMode(GL_MODELVIEW);
62 glTranslated(-1.0, 1.0, 0.0);
63 glScaled( 2.0 / rSize.Width(),
64 -2.0 / rSize.Height(),
68 glClearColor(0,0,0,0);
69 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
78 mnLinearTwoColorGradientProgram(0),
79 mnLinearMultiColorGradientProgram(0),
80 mnRadialTwoColorGradientProgram(0),
81 mnRadialMultiColorGradientProgram(0),
82 mnRectangularTwoColorGradientProgram(0),
83 mnRectangularMultiColorGradientProgram(0),
92 const awt::Rectangle& rViewArea )
96 rSpriteCanvas.setWindow(
97 uno::Reference<awt::XWindow2>(
99 uno::UNO_QUERY_THROW) );
178 const uno::Reference< rendering::XGraphicDevice >& ,
179 const uno::Sequence< uno::Sequence< geometry::RealPoint2D > >& points )
183 return uno::Reference< rendering::XLinePolyPolygon2D >();
185 return uno::Reference< rendering::XLinePolyPolygon2D >(
186 new ::basegfx::unotools::UnoPolyPolygon(
187 ::basegfx::unotools::polyPolygonFromPoint2DSequenceSequence( points )));
191 const uno::Reference< rendering::XGraphicDevice >& ,
192 const uno::Sequence< uno::Sequence< geometry::RealBezierSegment2D > >& points )
196 return uno::Reference< rendering::XBezierPolyPolygon2D >();
198 return uno::Reference< rendering::XBezierPolyPolygon2D >(
199 new ::basegfx::unotools::UnoPolyPolygon(
200 ::basegfx::unotools::polyPolygonFromBezier2DSequenceSequence( points ) ) );
204 const uno::Reference< rendering::XGraphicDevice >& ,
205 const geometry::IntegerSize2D& size )
209 return uno::Reference< rendering::XBitmap >();
211 return uno::Reference< rendering::XBitmap >(
218 const uno::Reference< rendering::XGraphicDevice >& ,
219 const geometry::IntegerSize2D& )
221 return uno::Reference< rendering::XVolatileBitmap >();
225 const uno::Reference< rendering::XGraphicDevice >& ,
226 const geometry::IntegerSize2D& size )
230 return uno::Reference< rendering::XBitmap >();
232 return uno::Reference< rendering::XBitmap >(
233 new CanvasBitmap( size,
239 const uno::Reference< rendering::XGraphicDevice >& ,
240 const geometry::IntegerSize2D& )
242 return uno::Reference< rendering::XVolatileBitmap >();
250 struct SpriteComparator
252 bool operator()( const ::rtl::Reference<CanvasCustomSprite>& rLHS,
253 const ::rtl::Reference<CanvasCustomSprite>& rRHS )
const
255 const double nPrioL( rLHS->getPriority() );
256 const double nPrioR( rRHS->getPriority() );
259 return nPrioL == nPrioR ? rLHS.get() < rRHS.get() : nPrioL < nPrioR;
273 const ::Size& rOutputSize = pChildWindow->
GetSizePixel();
280 std::vector< ::rtl::Reference<CanvasCustomSprite> > aSprites(
283 std::sort(aSprites.begin(),
286 for(
const auto& rSprite : aSprites )
287 rSprite->renderSprite();
291 glMatrixMode(GL_MODELVIEW);
293 glTranslated(-1.0, 1.0, 0.0);
294 glScaled( 2.0 / rOutputSize.Width(),
295 -2.0 / rOutputSize.Height(),
301 const double fps(denominator == 0.0 ? 100.0 : 1.0/denominator);
302 std::vector<double> aVec { fps,
static_cast<double>(
maActiveSprites.size()),
337 return css::uno::Any(
false);
344 return uno::Any(
reinterpret_cast<sal_Int64
>(pDevice));
364 0,0,rBounds.Width,rBounds.Height);
384 const ::basegfx::B2DHomMatrix& rTexTransform )
386 const GLint nTransformLocation = glGetUniformLocation(nProgramId,
389 float aTexTransform[] =
391 float(rTexTransform.get(0,0)), float(rTexTransform.get(1,0)),
392 float(rTexTransform.get(0,1)), float(rTexTransform.get(1,1)),
393 float(rTexTransform.get(0,2)), float(rTexTransform.get(1,2))
395 glUniformMatrix3x2fv(nTransformLocation,1,
false,aTexTransform);
399 const rendering::ARGBColor* pColors,
400 const uno::Sequence< double >& rStops,
401 const ::basegfx::B2DHomMatrix& rTexTransform )
403 glUseProgram(nProgramId);
405 GLuint nColorsTexture;
406 glActiveTexture(GL_TEXTURE0);
407 glGenTextures(1, &nColorsTexture);
408 glBindTexture(GL_TEXTURE_1D, nColorsTexture);
410 const sal_Int32 nColors=rStops.getLength();
411 glTexImage1D( GL_TEXTURE_1D, 0, GL_RGBA, nColors, 0, GL_RGBA, GL_DOUBLE, pColors );
412 glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
413 glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
415 GLuint nStopsTexture;
416 glActiveTexture(GL_TEXTURE1);
417 glGenTextures(1, &nStopsTexture);
418 glBindTexture(GL_TEXTURE_1D, nStopsTexture);
420 glTexImage1D( GL_TEXTURE_1D, 0, GL_ALPHA, nColors, 0, GL_ALPHA, GL_DOUBLE, rStops.getConstArray() );
421 glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
422 glTexParameteri( GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
424 const GLint nColorArrayLocation = glGetUniformLocation(nProgramId,
426 glUniform1i( nColorArrayLocation, 0 );
428 const GLint nStopArrayLocation = glGetUniformLocation(nProgramId,
430 glUniform1i( nStopArrayLocation, 1 );
432 const GLint nNumColorLocation = glGetUniformLocation(nProgramId,
434 glUniform1i( nNumColorLocation, nColors-1 );
440 const rendering::ARGBColor& rStartColor,
441 const rendering::ARGBColor& rEndColor,
442 const ::basegfx::B2DHomMatrix& rTexTransform )
444 glUseProgram(nProgramId);
446 const GLint nStartColorLocation = glGetUniformLocation(nProgramId,
448 glUniform4f(nStartColorLocation,
454 const GLint nEndColorLocation = glGetUniformLocation(nProgramId,
456 glUniform4f(nEndColorLocation,
466 const uno::Sequence< double >& rStops,
467 const ::basegfx::B2DHomMatrix& rTexTransform )
469 if( rStops.getLength() > 2 )
476 const uno::Sequence< double >& rStops,
477 const ::basegfx::B2DHomMatrix& rTexTransform )
479 if( rStops.getLength() > 2 )
486 const uno::Sequence< double >& rStops,
487 const ::basegfx::B2DHomMatrix& rTexTransform )
489 if( rStops.getLength() > 2 )
504 virtual void startBufferRendering()
override
509 virtual void endBufferRendering()
override
511 glBindFramebuffer(GL_FRAMEBUFFER, 0);
514 virtual GLuint getTextureId()
override
520 explicit BufferContextImpl(const ::basegfx::B2IVector& rSize) :
529 virtual ~BufferContextImpl()
override
540 return std::make_shared<BufferContextImpl>(rSize);
static css::uno::Reference< css::awt::XWindow > GetInterface(vcl::Window *pWindow)
Product of this component's factory.
void renderRecordedActions() const
Write out recorded actions.
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
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)
css::geometry::RealSize2D getPhysicalResolution()
unsigned int mnRectangularTwoColorGradientProgram
TextureCache & getTextureCache() const
Get instance of internal texture cache.
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)
css::uno::Any isAccelerated() const
bool showBuffer(bool bIsVisible, bool bUpdateAll)
void notifySizeUpdate(const css::awt::Rectangle &rBounds)
unsigned int mnLinearTwoColorGradientProgram
css::uno::Reference< css::rendering::XColorSpace > getColorSpace() const
css::uno::Any getSurfaceHandle() const
::canvas::tools::ElapsedTime maLastUpdate
For the frame counter timings.
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
IBufferContextSharedPtr createBufferContext(const ::basegfx::B2IVector &rSize) const
create a pbuffer context (for rendering into background surface)
void show(const ::rtl::Reference< CanvasCustomSprite > &)
css::uno::Reference< css::rendering::XVolatileBitmap > createVolatileBitmap(const css::uno::Reference< css::rendering::XGraphicDevice > &rDevice, const css::geometry::IntegerSize2D &size)
css::geometry::RealSize2D getPhysicalSize()
std::set< ::rtl::Reference< CanvasCustomSprite > > maActiveSprites
unsigned int mnRadialTwoColorGradientProgram
css::uno::Reference< css::rendering::XBitmap > createCompatibleBitmap(const css::uno::Reference< css::rendering::XGraphicDevice > &rDevice, const css::geometry::IntegerSize2D &size)
void dumpScreenContent() const
called when DumpScreenContent property is enabled on XGraphicDevice, and writes out bitmaps of curren...
void hide(const ::rtl::Reference< CanvasCustomSprite > &)
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
unsigned int mnRectangularMultiColorGradientProgram
unsigned int mnRadialMultiColorGradientProgram
SpriteCanvas * mpSpriteCanvas
Pointer to sprite canvas (owner of this helper), needed to create bitmaps.
void disposing()
Dispose all internal references.
rtl::Reference< OpenGLContext > mxContext
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)
css::uno::Any getDeviceHandle() const
bool switchBuffer(bool bIsVisible, bool bUpdateAll)
unsigned int mnLinearMultiColorGradientProgram
Point LogicToPixel(const Point &rLogicPt) const
const MapMode & GetMapMode() const
::OutputDevice const * GetOutDev() const
virtual void setPosSizePixel(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags=PosSizeFlags::All)
Point PixelToLogic(const Point &rDevicePt) const
virtual Size GetSizePixel() const
Size GetOutputSizePixel() const
#define SAL_INFO(area, stream)
std::shared_ptr< T > make_shared(Args &&... args)
std::shared_ptr< IBufferContext > IBufferContextSharedPtr
void renderOSD(const std::vector< double > &rNumbers, double scale)
static void setupUniforms(unsigned int nProgramId, const ::basegfx::B2DHomMatrix &rTexTransform)
static void initContext()
static void initTransformation(const ::Size &rSize)
const cppcanvas::SpriteCanvasSharedPtr mpSpriteCanvas
static void createFramebuffer(tools::Long nWidth, tools::Long nHeight, GLuint &nFramebufferId, GLuint &nRenderbufferDepthId, GLuint &nRenderbufferColorId)
static GLint LoadShaders(const OUString &rVertexShaderName, const OUString &rFragmentShaderName, const OUString &rGeometryShaderName, std::string_view preamble, std::string_view rDigest)