LibreOffice Module canvas (master) 1
spritecanvashelper.cxx
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 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <sal/config.h>
21#include <sal/log.hxx>
22
23#include <boost/cast.hpp>
24
26#include <rtl/math.hxx>
28#include <vcl/canvastools.hxx>
29#include <vcl/outdev.hxx>
30#include <vcl/window.hxx>
31
33
36#include "spritecanvas.hxx"
37
38using namespace ::com::sun::star;
39
40#define FPS_BOUNDS ::tools::Rectangle(0,0,130,90)
41#define INFO_COLOR COL_RED
42
43namespace vclcanvas
44{
45 namespace
46 {
52 void spriteRedraw( OutputDevice& rOutDev,
53 const ::canvas::Sprite::Reference& rSprite )
54 {
55 // downcast to derived vclcanvas::Sprite interface, which
56 // provides the actual redraw methods.
57 ::boost::polymorphic_downcast< Sprite* >(rSprite.get())->redraw(rOutDev,
58 true);
59 }
60
61 double calcNumPixel( const ::canvas::Sprite::Reference& rSprite )
62 {
63 const ::basegfx::B2DVector& rSize(
64 ::boost::polymorphic_downcast< Sprite* >(rSprite.get())->getSizePixel() );
65
66 return rSize.getX() * rSize.getY();
67 }
68
69 void repaintBackground( OutputDevice& rOutDev,
70 OutputDevice const & rBackBuffer,
71 const ::basegfx::B2DRange& rArea )
72 {
73 const ::Point& rPos( vcl::unotools::pointFromB2DPoint( rArea.getMinimum()) );
74 const ::Size& rSize( vcl::unotools::sizeFromB2DSize( rArea.getRange()) );
75
76 rOutDev.DrawOutDev( rPos, rSize, rPos, rSize, rBackBuffer );
77 }
78
79 void opaqueUpdateSpriteArea( const ::canvas::Sprite::Reference& rSprite,
80 OutputDevice& rOutDev,
81 const ::basegfx::B2IRange& rArea )
82 {
83 const ::tools::Rectangle& rRequestedArea(
85
86 // clip output to actual update region (otherwise a)
87 // wouldn't save much render time, and b) will clutter
88 // scrolled sprite content outside this area)
89 rOutDev.EnableMapMode( false );
90 rOutDev.SetAntialiasing( AntialiasingFlags::Enable );
91 rOutDev.SetClipRegion(vcl::Region(rRequestedArea));
92
93 // repaint affected sprite directly to output device (at
94 // the actual screen output position)
95 ::boost::polymorphic_downcast< Sprite* >(
96 rSprite.get() )->redraw( rOutDev,
97 false ); // rendering
98 // directly to
99 // frontbuffer
100 }
101
102 void renderInfoText( OutputDevice& rOutDev,
103 const OUString& rStr,
104 const Point& rPos )
105 {
106 vcl::Font aVCLFont;
107 aVCLFont.SetFontHeight( 20 );
108 aVCLFont.SetColor( INFO_COLOR );
109
110 rOutDev.SetTextAlign(ALIGN_TOP);
111 rOutDev.SetTextColor( INFO_COLOR );
112 rOutDev.SetFont( aVCLFont );
113
114 rOutDev.DrawText( rPos, rStr );
115 }
116
117 }
118
120 mpRedrawManager( nullptr ),
121 mpOwningSpriteCanvas( nullptr ),
122 maVDev(VclPtr<VirtualDevice>::Create()),
123 mbShowFrameInfo( false ),
124 mbShowSpriteBounds( false ),
125 mbIsUnsafeScrolling( false )
126 {
127#if OSL_DEBUG_LEVEL > 0
128 // inverse defaults for verbose debug mode
129 mbShowFrameInfo = true;
130 // this looks like drawing errors, enable only if explicitly asked for
131 static bool enableShowSpriteBounds = getenv("CANVAS_SPRITE_BOUNDS") != nullptr;
132 mbShowSpriteBounds = enableShowSpriteBounds;
133#endif
134 }
135
137 {
138 SolarMutexGuard aGuard;
140 }
141
143 SpriteCanvas& rOwningSpriteCanvas,
145 bool bProtect,
146 bool bHaveAlpha )
147 {
148 mpOwningSpriteCanvas = &rOwningSpriteCanvas;
149 mpRedrawManager = &rManager;
150
151 CanvasHelper::init(rOwningSpriteCanvas,rOutDev,bProtect,bHaveAlpha);
152 }
153
155 {
156 mpRedrawManager = nullptr;
157 mpOwningSpriteCanvas = nullptr;
158
159 // forward to base
161 }
162
163 uno::Reference< rendering::XAnimatedSprite > SpriteCanvasHelper::createSpriteFromAnimation(
164 const uno::Reference< rendering::XAnimation >& )
165 {
166 return uno::Reference< rendering::XAnimatedSprite >();
167 }
168
169 uno::Reference< rendering::XAnimatedSprite > SpriteCanvasHelper::createSpriteFromBitmaps(
170 const uno::Sequence< uno::Reference< rendering::XBitmap > >& ,
171 sal_Int8 )
172 {
173 return uno::Reference< rendering::XAnimatedSprite >();
174 }
175
176 uno::Reference< rendering::XCustomSprite > SpriteCanvasHelper::createCustomSprite( const geometry::RealSize2D& spriteSize )
177 {
178 if( !mpRedrawManager || !mpDevice )
179 return uno::Reference< rendering::XCustomSprite >(); // we're disposed
180
181 return uno::Reference< rendering::XCustomSprite >(
182 new CanvasCustomSprite( spriteSize,
183 *mpDevice,
187 }
188
189 uno::Reference< rendering::XSprite > SpriteCanvasHelper::createClonedSprite( const uno::Reference< rendering::XSprite >& )
190 {
191 return uno::Reference< rendering::XSprite >();
192 }
193
194 bool SpriteCanvasHelper::updateScreen( bool bUpdateAll,
195 bool& io_bSurfaceDirty )
196 {
197 if( !mpRedrawManager ||
201 {
202 return false; // disposed, or otherwise dysfunctional
203 }
204
205 // commit to backbuffer
206 flush();
207
208 OutputDevice& rOutDev( mpOwningSpriteCanvas->getFrontBuffer()->getOutDev() );
210 OutputDevice& rBackOutDev( pBackBuffer->getOutDev() );
211
212 // actual OutputDevice is a shared resource - restore its
213 // state when done.
214 tools::OutDevStateKeeper aStateKeeper( rOutDev );
215
216 const Size aOutDevSize( rBackOutDev.GetOutputSizePixel() );
217 const Point aEmptyPoint(0,0);
218
219 vcl::Window* pTargetWindow = nullptr;
220 if( rOutDev.GetOutDevType() == OUTDEV_WINDOW )
221 {
222 pTargetWindow = rOutDev.GetOwnerWindow(); // TODO(Q3): Evil downcast.
223
224 // we're double-buffered, thus no need for paint area-limiting
225 // clips. besides that, will interfere with animations (as for
226 // Window-invalidate repaints, only parts of the window will
227 // be redrawn otherwise)
228 const vcl::Region aFullWindowRegion( ::tools::Rectangle(aEmptyPoint,
229 aOutDevSize) );
230 pTargetWindow->ExpandPaintClipRegion(aFullWindowRegion);
231 }
232
233 // TODO(P1): Might be worthwhile to track areas of background
234 // changes, too.
235 if( !bUpdateAll && !io_bSurfaceDirty )
236 {
237 if( mbShowFrameInfo )
238 {
239 // also repaint background below frame counter (fake
240 // that as a sprite vanishing in this area)
243 ::basegfx::B2DRectangle( 0.0, 0.0,
244 FPS_BOUNDS.Right(),
245 FPS_BOUNDS.Bottom() ) );
246 }
247
248 // background has not changed, so we're free to optimize
249 // repaint to areas where a sprite has changed
250
251 // process each independent area of overlapping sprites
252 // separately.
254 }
255 else
256 {
257 // background has changed, so we currently have no choice
258 // but repaint everything (or caller requested that)
259
260 maVDev->SetOutputSizePixel( aOutDevSize );
261 maVDev->EnableMapMode( false );
262 maVDev->DrawOutDev( aEmptyPoint, aOutDevSize,
263 aEmptyPoint, aOutDevSize,
264 rBackOutDev );
265
266 // repaint all active sprites on top of background into
267 // VDev.
268 OutputDevice& rTmpOutDev( *maVDev );
270 [&rTmpOutDev]( const ::canvas::Sprite::Reference& rSprite )
271 { spriteRedraw( rTmpOutDev, rSprite ); }
272 );
273
274 // flush to screen
275 rOutDev.EnableMapMode( false );
276 rOutDev.SetAntialiasing( AntialiasingFlags::Enable );
277 rOutDev.SetClipRegion();
278 rOutDev.DrawOutDev( aEmptyPoint, aOutDevSize,
279 aEmptyPoint, aOutDevSize,
280 *maVDev );
281 }
282
283 // change record vector must be cleared, for the next turn of
284 // rendering and sprite changing
286
287 io_bSurfaceDirty = false;
288
289 if( mbShowFrameInfo )
290 {
291 renderFrameCounter( rOutDev );
292 renderSpriteCount( rOutDev );
293 renderMemUsage( rOutDev );
294 }
295
296#if OSL_DEBUG_LEVEL > 0
297 static ::canvas::tools::ElapsedTime aElapsedTime;
298
299 // log time immediately after surface flip
300 SAL_INFO("canvas.vcl", "SpriteCanvasHelper::updateScreen(): flip done at " <<
301 aElapsedTime.getElapsedTime() );
302#endif
303
304 // sync output with screen, to ensure that we don't queue up
305 // render requests (calling code might rely on timing,
306 // i.e. assume that things are visible on screen after
307 // updateScreen() returns).
308 if( pTargetWindow )
309 {
310 // commit to screen
311 pTargetWindow->GetOutDev()->Flush();
312 }
313
314 return true;
315 }
316
317 void SpriteCanvasHelper::backgroundPaint( const ::basegfx::B2DRange& rUpdateRect )
318 {
322 "SpriteCanvasHelper::backgroundPaint(): NULL device pointer " );
323
324 OutputDevice& rOutDev( mpOwningSpriteCanvas->getFrontBuffer()->getOutDev() );
326 OutputDevice& rBackOutDev( pBackBuffer->getOutDev() );
327
328 repaintBackground( rOutDev, rBackOutDev, rUpdateRect );
329 }
330
331 void SpriteCanvasHelper::scrollUpdate( const ::basegfx::B2DRange& rMoveStart,
332 const ::basegfx::B2DRange& rMoveEnd,
333 const ::canvas::SpriteRedrawManager::UpdateArea& rUpdateArea )
334 {
338 "SpriteCanvasHelper::scrollUpdate(): NULL device pointer " );
339
340 OutputDevice& rOutDev( mpOwningSpriteCanvas->getFrontBuffer()->getOutDev() );
342 OutputDevice& rBackOutDev( pBackBuffer->getOutDev() );
343
344 const Size& rTargetSizePixel( rOutDev.GetOutputSizePixel() );
345 const ::basegfx::B2IRange aOutputBounds( 0,0,
346 rTargetSizePixel.Width(),
347 rTargetSizePixel.Height() );
348
349 // round rectangles to integer pixel. Note: have to be
350 // extremely careful here, to avoid off-by-one errors for
351 // the destination area: otherwise, the next scroll update
352 // would copy pixel that are not supposed to be part of
353 // the sprite.
354 ::basegfx::B2IRange aSourceRect(
356 const ::basegfx::B2IRange& rDestRect(
358 ::basegfx::B2IPoint aDestPos( rDestRect.getMinimum() );
359
360 std::vector< ::basegfx::B2IRange > aUnscrollableAreas;
361
362 // Since strictly speaking, this scroll algorithm is plain
363 // buggy, the scrolled area might actually lie _below_ another
364 // window - we've made this feature configurable via
365 // mbIsUnsafeScrolling.
366
367 // clip to output bounds (cannot properly scroll stuff
368 // _outside_ our screen area)
369 if( !mbIsUnsafeScrolling ||
371 aDestPos,
372 aUnscrollableAreas,
373 aOutputBounds ) )
374 {
375 // fully clipped scroll area: cannot simply scroll
376 // then. Perform normal opaque update (can use that, since
377 // one of the preconditions for scrollable update is
378 // opaque sprite content)
379
380 // repaint all affected sprites directly to output device
381 for( const auto& rComponent : rUpdateArea.maComponentList )
382 {
383 const ::canvas::Sprite::Reference& rSprite( rComponent.second.getSprite() );
384
385 if( rSprite.is() )
386 ::boost::polymorphic_downcast< Sprite* >(
387 rSprite.get() )->redraw( rOutDev,
388 false );
389 }
390 }
391 else
392 {
393 // scroll rOutDev content
394 rOutDev.CopyArea( vcl::unotools::pointFromB2IPoint( aDestPos ),
396 // TODO(Q2): use numeric_cast to check range
397 ::Size( static_cast<sal_Int32>(aSourceRect.getRange().getX()),
398 static_cast<sal_Int32>(aSourceRect.getRange().getY()) ) );
399
400 const ::canvas::SpriteRedrawManager::SpriteConnectedRanges::ComponentListType::const_iterator
401 aFirst( rUpdateArea.maComponentList.begin() );
402
403 ENSURE_OR_THROW( aFirst->second.getSprite().is(),
404 "VCLCanvas::scrollUpdate(): no sprite" );
405
406 // repaint uncovered areas from sprite. Need to actually
407 // clip here, since we're only repainting _parts_ of the
408 // sprite
410
411 for( const auto& rArea : aUnscrollableAreas )
412 opaqueUpdateSpriteArea( aFirst->second.getSprite(),
413 rOutDev, rArea );
414
415 rOutDev.Pop();
416 }
417
418 // repaint uncovered areas from backbuffer - take the
419 // _rounded_ rectangles from above, to have the update
420 // consistent with the scroll above.
421 std::vector< ::basegfx::B2DRange > aUncoveredAreas;
422 ::basegfx::computeSetDifference( aUncoveredAreas,
423 rUpdateArea.maTotalBounds,
424 ::basegfx::B2DRange( rDestRect ) );
425
426 for( const auto& rArea : aUncoveredAreas )
427 repaintBackground( rOutDev, rBackOutDev, rArea );
428 }
429
430 void SpriteCanvasHelper::opaqueUpdate( SAL_UNUSED_PARAMETER const ::basegfx::B2DRange&,
431 const std::vector< ::canvas::Sprite::Reference >& rSortedUpdateSprites )
432 {
436 "SpriteCanvasHelper::opaqueUpdate(): NULL device pointer " );
437
438 OutputDevice& rOutDev( mpOwningSpriteCanvas->getFrontBuffer()->getOutDev() );
439
440 // no need to clip output to actual update region - there will
441 // always be ALL sprites contained in the rectangular update
442 // area contained in rTotalArea (that's the way
443 // B2DConnectedRanges work). If rTotalArea appears to be
444 // smaller than the sprite - then this sprite carries a clip,
445 // and the update will be constrained to that rect.
446
447 // repaint all affected sprites directly to output device
448 for( const auto& rSprite : rSortedUpdateSprites )
449 {
450 if( rSprite.is() )
451 ::boost::polymorphic_downcast< Sprite* >(
452 rSprite.get() )->redraw( rOutDev,
453 false );
454 }
455 }
456
457 void SpriteCanvasHelper::genericUpdate( const ::basegfx::B2DRange& rRequestedArea,
458 const std::vector< ::canvas::Sprite::Reference >& rSortedUpdateSprites )
459 {
463 "SpriteCanvasHelper::genericUpdate(): NULL device pointer " );
464
465 OutputDevice& rOutDev( mpOwningSpriteCanvas->getFrontBuffer()->getOutDev() );
467 OutputDevice& rBackOutDev( pBackBuffer->getOutDev() );
468
469 // limit size of update VDev to target outdev's size
470 const Size& rTargetSizePixel( rOutDev.GetOutputSizePixel() );
471
472 // round output position towards zero. Don't want to truncate
473 // a fraction of a sprite pixel... Clip position at origin,
474 // otherwise, truncation of size below might leave visible
475 // areas uncovered by VDev.
476 const ::Point aOutputPosition(
477 std::max( sal_Int32( 0 ),
478 static_cast< sal_Int32 >(rRequestedArea.getMinX()) ),
479 std::max( sal_Int32( 0 ),
480 static_cast< sal_Int32 >(rRequestedArea.getMinY()) ) );
481 // round output size towards +infty. Don't want to truncate a
482 // fraction of a sprite pixel... Limit coverage of VDev to
483 // output device's area (i.e. not only to total size, but to
484 // cover _only_ the visible parts).
485 const ::Size aOutputSize(
486 std::max( sal_Int32( 0 ),
487 std::min( static_cast< sal_Int32 >(rTargetSizePixel.Width() - aOutputPosition.X()),
488 ::canvas::tools::roundUp( rRequestedArea.getMaxX() - aOutputPosition.X() ))),
489 std::max( sal_Int32( 0 ),
490 std::min( static_cast< sal_Int32 >(rTargetSizePixel.Height() - aOutputPosition.Y()),
491 ::canvas::tools::roundUp( rRequestedArea.getMaxY() - aOutputPosition.Y() ))));
492
493 // early exit for empty output area.
494 if( aOutputSize.Width() == 0 &&
495 aOutputSize.Height() == 0 )
496 {
497 return;
498 }
499
500 const Point aEmptyPoint(0,0);
501 const Size aCurrOutputSize( maVDev->GetOutputSizePixel() );
502
503 // adapt maVDev's size to the area that actually needs the
504 // repaint.
505 if( aCurrOutputSize.Width() < aOutputSize.Width() ||
506 aCurrOutputSize.Height() < aOutputSize.Height() )
507 {
508 // TODO(P1): Come up with a clever tactic to reduce maVDev
509 // from time to time. Reduction with threshold (say, if
510 // maVDev is more than twice too large) is not wise, as
511 // this might then toggle within the same updateScreen(),
512 // but for different disjunct sprite areas.
513 maVDev->SetOutputSizePixel( aOutputSize );
514 }
515
516 // paint background
517 maVDev->EnableMapMode( false );
518 maVDev->SetAntialiasing( AntialiasingFlags::Enable );
519 maVDev->SetClipRegion();
520 maVDev->DrawOutDev( aEmptyPoint, aOutputSize,
521 aOutputPosition, aOutputSize,
522 rBackOutDev );
523
524 // repaint all affected sprites on top of background into
525 // VDev.
526 for( const auto& rSprite : rSortedUpdateSprites )
527 {
528 if( rSprite.is() )
529 {
530 Sprite* pSprite = ::boost::polymorphic_downcast< Sprite* >( rSprite.get() );
531
532 // calc relative sprite position in rUpdateArea (which
533 // need not be the whole screen!)
534 const ::basegfx::B2DPoint& rSpriteScreenPos( pSprite->getPosPixel() );
535 const ::basegfx::B2DPoint& rSpriteRenderPos(
536 rSpriteScreenPos - vcl::unotools::b2DPointFromPoint(aOutputPosition)
537 );
538
539 pSprite->redraw( *maVDev, rSpriteRenderPos, true );
540 }
541 }
542
543 // flush to screen
544 rOutDev.EnableMapMode( false );
545 rOutDev.SetAntialiasing( AntialiasingFlags::Enable );
546 rOutDev.DrawOutDev( aOutputPosition, aOutputSize,
547 aEmptyPoint, aOutputSize,
548 *maVDev );
549 }
550
552 {
553 const double denominator( maLastUpdate.getElapsedTime() );
555
556 OUString text( ::rtl::math::doubleToUString( denominator == 0.0 ? 100.0 : 1.0/denominator,
557 rtl_math_StringFormat_F,
558 2,'.',nullptr,' ') );
559
560 // pad with leading space
561 while( text.getLength() < 6 )
562 text = " " + text;
563
564 text += " fps";
565
566 renderInfoText( rOutDev,
567 text,
568 Point(0, 0) );
569 }
570
571 namespace
572 {
573 template< typename T > struct Adder
574 {
575 typedef void result_type;
576
577 Adder( T& rAdderTarget,
578 T nIncrement ) :
579 mpTarget( &rAdderTarget ),
580 mnIncrement( nIncrement )
581 {
582 }
583
584 void operator()( const ::canvas::Sprite::Reference& ) { *mpTarget += mnIncrement; }
585 void operator()( T nIncrement ) { *mpTarget += nIncrement; }
586
589 };
590
591 template< typename T> Adder<T> makeAdder( T& rAdderTarget,
592 T nIncrement )
593 {
594 return Adder<T>(rAdderTarget, nIncrement);
595 }
596 }
597
599 {
600 if( !mpRedrawManager )
601 return;
602
603 sal_Int32 nCount(0);
604
605 mpRedrawManager->forEachSprite( makeAdder(nCount,sal_Int32(1)) );
606 OUString text( OUString::number(nCount) );
607
608 // pad with leading space
609 while( text.getLength() < 3 )
610 text = " " + text;
611
612 text = "Sprites: " + text;
613
614 renderInfoText( rOutDev,
615 text,
616 Point(0, 30) );
617 }
618
620 {
622
623 if( !(mpRedrawManager &&
624 pBackBuffer) )
625 return;
626
627 double nPixel(0.0);
628
629 // accumulate pixel count for each sprite into fCount
631 [&nPixel]( const ::canvas::Sprite::Reference& rSprite )
632 { makeAdder( nPixel, 1.0 )( calcNumPixel(rSprite) ); }
633 );
634
635 static const int NUM_VIRDEV(2);
636 static const int BYTES_PER_PIXEL(3);
637
638 const Size& rVDevSize( maVDev->GetOutputSizePixel() );
639 const Size& rBackBufferSize( pBackBuffer->getOutDev().GetOutputSizePixel() );
640
641 const double nMemUsage( nPixel * NUM_VIRDEV * BYTES_PER_PIXEL +
642 rVDevSize.Width()*rVDevSize.Height() * BYTES_PER_PIXEL +
643 rBackBufferSize.Width()*rBackBufferSize.Height() * BYTES_PER_PIXEL );
644
645 OUString text( ::rtl::math::doubleToUString( nMemUsage / 1048576.0,
646 rtl_math_StringFormat_F,
647 2,'.',nullptr,' ') );
648
649 // pad with leading space
650 while( text.getLength() < 4 )
651 text = " " + text;
652
653 text = "Mem: " + text + "MB";
654
655 renderInfoText( rOutDev,
656 text,
657 Point(0, 60) );
658 }
659}
660
661/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void EnableMapMode(bool bEnable=true)
void SetAntialiasing(AntialiasingFlags nMode)
void SetFont(const vcl::Font &rNewFont)
void SetTextAlign(TextAlign eAlign)
Size GetOutputSizePixel() const
void SetTextColor(const Color &rColor)
void SetClipRegion()
SAL_DLLPRIVATE void DrawOutDev(const Point &, const Size &, const Point &, const Size &, const Printer &)=delete
virtual void CopyArea(const Point &rDestPt, const Point &rSrcPt, const Size &rSrcSize, bool bWindowInvalidate=false)
virtual void Flush()
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
OutDevType GetOutDevType() const
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
virtual vcl::Window * GetOwnerWindow() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
void disposeAndClear()
B2IPoint getMinimum() const
B2I64Tuple getRange() const
TYPE getX() const
TYPE getY() const
This class manages smooth SpriteCanvas updates.
void forEachSpriteArea(Functor &rFunc) const
Call given functor for each sprite area that needs an update.
void clearChangeRecords()
Clear sprite change records (typically directly after a screen update)
void forEachSprite(const Functor &rFunc) const
Call given functor for each active sprite.
void updateSprite(const Sprite::Reference &rSprite, const ::basegfx::B2DPoint &rPos, const ::basegfx::B2DRange &rUpdateArea)
virtual ::basegfx::B2DPoint getPosPixel() const =0
Query position of the left, top pixel of the sprite.
void reset()
Reset the time.
Definition: elapsedtime.cxx:55
double getElapsedTime() const
Query the elapsed time.
Definition: elapsedtime.cxx:81
void SetColor(const Color &)
void SetFontHeight(tools::Long nHeight)
::OutputDevice const * GetOutDev() const
void ExpandPaintClipRegion(const vcl::Region &rRegion)
css::rendering::XGraphicDevice * mpDevice
Phyical output device.
void flush() const
Flush drawing queue.
void disposing()
Release all references.
void init(css::rendering::XGraphicDevice &rDevice, const OutDevProviderSharedPtr &rOutDev, bool bProtect, bool bHaveAlpha)
Initialize canvas helper.
::canvas::SpriteRedrawManager * mpRedrawManager
Set from the SpriteCanvas: instance coordinating sprite redraw.
void renderFrameCounter(OutputDevice &rOutDev)
css::uno::Reference< css::rendering::XSprite > createClonedSprite(const css::uno::Reference< css::rendering::XSprite > &original)
bool mbIsUnsafeScrolling
When true, canvas uses the scroll optimization (direct scrolls in front buffer)
void renderMemUsage(OutputDevice &rOutDev)
bool mbShowFrameInfo
When true, canvas displays debug info on each frame.
css::uno::Reference< css::rendering::XAnimatedSprite > createSpriteFromAnimation(const css::uno::Reference< css::rendering::XAnimation > &animation)
::canvas::tools::ElapsedTime maLastUpdate
For the frame counter timings.
css::uno::Reference< css::rendering::XAnimatedSprite > createSpriteFromBitmaps(const css::uno::Sequence< css::uno::Reference< css::rendering::XBitmap > > &animationBitmaps, sal_Int8 interpolationMode)
void renderSpriteCount(OutputDevice &rOutDev)
css::uno::Reference< css::rendering::XCustomSprite > createCustomSprite(const css::geometry::RealSize2D &spriteSize)
bool mbShowSpriteBounds
When true, canvas creates all new sprites with red lines in the corners.
void backgroundPaint(const ::basegfx::B2DRange &rUpdateRect)
Gets called for simple background repaints.
void scrollUpdate(const ::basegfx::B2DRange &rMoveStart, const ::basegfx::B2DRange &rMoveEnd, const ::canvas::SpriteRedrawManager::UpdateArea &rUpdateArea)
Gets called when area can be handled by scrolling.
void genericUpdate(const ::basegfx::B2DRange &rTotalArea, const std::vector< ::canvas::Sprite::Reference > &rSortedUpdateSprites)
void opaqueUpdate(const ::basegfx::B2DRange &rTotalArea, const std::vector< ::canvas::Sprite::Reference > &rSortedUpdateSprites)
void init(const OutDevProviderSharedPtr &rOutDev, SpriteCanvas &rOwningSpriteCanvas, ::canvas::SpriteRedrawManager &rManager, bool bProtect, bool bHaveAlpha)
void disposing()
Dispose all internal references.
SpriteCanvas * mpOwningSpriteCanvas
Set from the init method. used to generate sprites.
bool updateScreen(bool bUpdateAll, bool &io_bSurfaceDirty)
Actually perform the screen update.
VclPtr< VirtualDevice > maVDev
Background compositing surface.
Product of this component's factory.
BackBufferSharedPtr const & getBackBuffer() const
Get window for this canvas.
OutDevProviderSharedPtr const & getFrontBuffer() const
Get backbuffer for this canvas.
Specialization of canvas::Sprite interface, to also provide redraw methods.
virtual void redraw(OutputDevice &rOutDev, bool bBufferedUpdate) const =0
Redraw sprite at the stored position.
int nCount
#define ENSURE_OR_THROW(c, m)
#define max(a, b)
Definition: dx_winstuff.hxx:43
ALIGN_TOP
#define SAL_INFO(area, stream)
def text(shape, orig_st)
::basegfx::B2IRange spritePixelAreaFromB2DRange(const ::basegfx::B2DRange &rRange)
Clip a blit between two differently surfaces.
bool clipScrollArea(::basegfx::B2IRange &io_rSourceArea, ::basegfx::B2IPoint &io_rDestPoint, std::vector< ::basegfx::B2IRange > &o_ClippedAreas, const ::basegfx::B2IRange &rBounds)
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
Point pointFromB2IPoint(const basegfx::B2IPoint &rPoint)
tools::Rectangle rectangleFromB2IRectangle(const basegfx::B2IRange &rRect)
basegfx::B2DPoint b2DPointFromPoint(const ::Point &rPoint)
::Point pointFromB2DPoint(const basegfx::B2DPoint &rPoint)
::Size sizeFromB2DSize(const basegfx::B2DVector &rVec)
std::shared_ptr< OutDevProvider > OutDevProviderSharedPtr
std::shared_ptr< BackBuffer > BackBufferSharedPtr
Definition: backbuffer.hxx:47
OUTDEV_WINDOW
#define nPixel
#define INFO_COLOR
#define FPS_BOUNDS
T mnIncrement
T * mpTarget
signed char sal_Int8