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/.
11 #ifndef INCLUDED_VCL_INC_OPENGL_RENDERLIST_H
12 #define INCLUDED_VCL_INC_OPENGL_RENDERLIST_H
14 #include <unordered_map>
16 #include <glm/glm.hpp>
18 #include <vcl/salgtype.hxx>
19 #include <basegfx/range/b2drange.hxx>
20 #include <basegfx/polygon/b2dpolypolygon.hxx>
22 #include <opengl/texture.hxx>
24 #include <com/sun/star/drawing/LineCap.hpp>
33 static_assert(sizeof(Vertex
) == (2*4 + 4*4 + 4*4), "Vertex struct has wrong size/alignment");
36 struct RenderParameters
38 std::vector
<Vertex
> maVertices
;
39 std::vector
<GLuint
> maIndices
;
42 struct RenderTextureParameters
44 std::vector
<GLfloat
> maVertices
;
45 std::vector
<GLfloat
> maTextureCoords
;
46 std::vector
<GLubyte
> maColors
;
47 OpenGLTexture maTexture
;
52 basegfx::B2DRange maOverlapTrackingRectangle
;
54 RenderParameters maTriangleParameters
;
55 RenderParameters maLineParameters
;
57 std::unordered_map
<GLuint
, RenderTextureParameters
> maTextureParametersMap
;
59 bool hasTriangles() const
61 return !maTriangleParameters
.maVertices
.empty();
66 return !maLineParameters
.maVertices
.empty();
69 bool hasTextures() const
71 return !maTextureParametersMap
.empty();
78 std::vector
<RenderEntry
> maRenderEntries
;
79 std::vector
<basegfx::B2DRange
> maRectangles
;
81 bool doesOverlap(const basegfx::B2DRange
& rDrawRectangle
)
83 if (!maRenderEntries
.back().maOverlapTrackingRectangle
.overlaps(rDrawRectangle
))
86 for (const basegfx::B2DRange
& rRectangle
: maRectangles
)
88 if (rRectangle
.overlaps(rDrawRectangle
))
94 void checkOverlapping(const basegfx::B2DRange
& rDrawRectangle
)
96 if (maRenderEntries
.empty() || doesOverlap(rDrawRectangle
))
98 maRenderEntries
.emplace_back();
99 maRenderEntries
.back().maOverlapTrackingRectangle
= rDrawRectangle
;
101 maRectangles
.clear();
102 maRectangles
.reserve(30);
103 maRectangles
.push_back(rDrawRectangle
);
107 maRenderEntries
.back().maOverlapTrackingRectangle
.expand(rDrawRectangle
);
109 if (maRectangles
.size() < 30)
111 maRectangles
.push_back(rDrawRectangle
);
115 basegfx::B2DRange
aTempRectangle(maRectangles
[0]);
116 aTempRectangle
.expand(rDrawRectangle
);
117 double minArea
= aTempRectangle
.getWidth() * aTempRectangle
.getHeight();
121 for (size_t i
= 1; i
< maRectangles
.size(); ++i
)
123 aTempRectangle
= maRectangles
[i
];
124 aTempRectangle
.expand(rDrawRectangle
);
125 area
= aTempRectangle
.getWidth() * aTempRectangle
.getHeight();
129 maRectangles
[index
].expand(rDrawRectangle
);
136 RenderList() = default;
140 return maRenderEntries
.empty();
145 maRenderEntries
.clear();
148 std::vector
<RenderEntry
>& getEntries()
150 return maRenderEntries
;
153 void addDrawTextureWithMaskColor(OpenGLTexture
const & rTexture
, Color nColor
, const SalTwoRect
& r2Rect
);
155 void addDrawPixel(long nX
, long nY
, Color nColor
);
157 void addDrawRectangle(long nX
, long nY
, long nWidth
, long nHeight
, double fTransparency
,
158 Color nLineColor
, Color nFillColor
);
160 void addDrawLine(long nX1
, long nY1
, long nX2
, long nY2
, Color nLineColor
, bool bUseAA
);
162 void addDrawPolyPolygon(const basegfx::B2DPolyPolygon
& rPolyPolygon
, double fTransparency
,
163 Color nLineColor
, Color nFillColor
, bool bUseAA
);
165 void addDrawPolyLine(const basegfx::B2DPolygon
& rPolygon
, double fTransparency
,
166 const basegfx::B2DVector
& rLineWidth
, basegfx::B2DLineJoin eLineJoin
,
167 css::drawing::LineCap eLineCap
, double fMiterMinimumAngle
,
168 Color nLineColor
, bool bUseAA
);
171 #endif // INCLUDED_VCL_INC_OPENGL_RENDERLIST_H
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */