41 "CanvasCustomSprite::CanvasCustomSprite(): Invalid sprite canvas" );
50 ::osl::MutexGuard aGuard(
m_aMutex );
62 ::osl::MutexGuard aGuard(
m_aMutex );
67 const rendering::ViewState& viewState,
68 const rendering::RenderState& renderState )
74 ::osl::MutexGuard aGuard(
m_aMutex );
81 maPosition = ::basegfx::unotools::b2DPointFromRealPoint2D(aNewPos);
87 ::osl::MutexGuard aGuard(
m_aMutex );
98 ::osl::MutexGuard aGuard(
m_aMutex );
104 ::osl::MutexGuard aGuard(
m_aMutex );
111 ::osl::MutexGuard aGuard(
m_aMutex );
123 if( ::basegfx::fTools::equalZero(
mfAlpha ) )
127 const ::basegfx::B2IVector aSpriteSizePixel(
128 ::canvas::tools::roundUp(
maSize.Width ),
129 ::canvas::tools::roundUp(
maSize.Height ));
138 double aGLTransform[] =
145 glMultMatrixd(aGLTransform);
154 pBufferContext =
maCanvasHelper.getDeviceHelper()->createBufferContext(aSpriteSizePixel);
155 pBufferContext->startBufferRendering();
167 pBufferContext->endBufferRendering();
168 GLuint nTexture = pBufferContext->getTextureId();
169 glBindTexture(GL_TEXTURE_2D, nTexture);
171 glEnable(GL_TEXTURE_2D);
172 glTexParameteri(GL_TEXTURE_2D,
173 GL_TEXTURE_MIN_FILTER,
175 glTexParameteri(GL_TEXTURE_2D,
176 GL_TEXTURE_MAG_FILTER,
179 glBlendFunc(GL_SRC_ALPHA,
180 GL_ONE_MINUS_SRC_ALPHA);
187 const double fWidth=
maSize.Width;
188 const double fHeight=
maSize.Height;
191 const ::basegfx::triangulator::B2DTriangleVector rTriangulatedPolygon(
192 ::basegfx::triangulator::triangulate(
193 ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(
mxClip)));
195 glBegin(GL_TRIANGLES);
196 for(
size_t i=0;
i<rTriangulatedPolygon.size();
i++ )
198 const::basegfx::triangulator::B2DTriangle& rCandidate(rTriangulatedPolygon[
i]);
200 rCandidate.getA().getX()/fWidth,
201 rCandidate.getA().getY()/fHeight);
203 rCandidate.getA().getX(),
204 rCandidate.getA().getY());
207 rCandidate.getB().getX()/fWidth,
208 rCandidate.getB().getY()/fHeight);
210 rCandidate.getB().getX(),
211 rCandidate.getB().getY());
214 rCandidate.getC().getX()/fWidth,
215 rCandidate.getC().getY()/fHeight);
217 rCandidate.getC().getX(),
218 rCandidate.getC().getY());
224 const double fWidth=
maSize.Width/aSpriteSizePixel.getX();
225 const double fHeight=
maSize.Height/aSpriteSizePixel.getY();
227 glBegin(GL_TRIANGLE_STRIP);
228 glTexCoord2f(0,0); glVertex2d(0,0);
229 glTexCoord2f(0,fHeight); glVertex2d(0, aSpriteSizePixel.getY());
230 glTexCoord2f(fWidth,0); glVertex2d(aSpriteSizePixel.getX(),0);
231 glTexCoord2f(fWidth,fHeight); glVertex2d(aSpriteSizePixel.getX(),aSpriteSizePixel.getY());
235 glBindTexture(GL_TEXTURE_2D, 0);
236 glDisable(GL_TEXTURE_2D);
241 glBegin(GL_LINE_STRIP);
243 glVertex2d(-2,
maSize.Height+4);
245 glVertex2d(
maSize.Width+4,-2);
virtual void disposeThis() override
CanvasHelper maCanvasHelper
virtual void SAL_CALL setPriority(double nPriority) override
SpriteCanvasRef mpSpriteCanvas
MUST hold here, too, since CanvasHelper only contains a raw pointer (without refcounting)
css::geometry::AffineMatrix2D maTransformation
virtual void SAL_CALL transform(const css::geometry::AffineMatrix2D &aTransformation) override
CanvasCustomSprite(const css::geometry::RealSize2D &rSpriteSize, const SpriteCanvasRef &rRefDevice, SpriteDeviceHelper &rDeviceHelper)
Create a custom sprite.
virtual void SAL_CALL show() override
virtual void disposeThis() override
virtual void SAL_CALL move(const css::geometry::RealPoint2D &aNewPos, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState) override
virtual void SAL_CALL clip(const css::uno::Reference< css::rendering::XPolyPolygon2D > &aClip) override
virtual void SAL_CALL hide() override
virtual void SAL_CALL setAlpha(double alpha) override
::basegfx::B2DPoint maPosition
const css::geometry::RealSize2D maSize
virtual css::uno::Reference< css::rendering::XCanvas > SAL_CALL getContentCanvas() override
css::uno::Reference< css::rendering::XPolyPolygon2D > mxClip
bool renderSprite() const
Render sprite content at sprite position.
#define ENSURE_OR_THROW(c, m)
::basegfx::B2ISize maSize
constexpr double alpha[nDetails]
std::shared_ptr< IBufferContext > IBufferContextSharedPtr
void renderOSD(const std::vector< double > &rNumbers, double scale)
const cppcanvas::SpriteCanvasSharedPtr mpSpriteCanvas