Line data Source code
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 : #ifndef _VCLCANVAS_SPRITECANVASHELPER_HXX_
21 : #define _VCLCANVAS_SPRITECANVASHELPER_HXX_
22 :
23 : #include <com/sun/star/rendering/XSpriteCanvas.hpp>
24 : #include <com/sun/star/rendering/XIntegerBitmap.hpp>
25 :
26 : #include <vcl/virdev.hxx>
27 :
28 : #include <canvas/spriteredrawmanager.hxx>
29 : #include <canvas/elapsedtime.hxx>
30 : #include <canvas/vclwrapper.hxx>
31 : #include "canvashelper.hxx"
32 : #include "impltools.hxx"
33 :
34 :
35 : namespace vclcanvas
36 : {
37 : class SpriteCanvas;
38 :
39 0 : class SpriteCanvasHelper : public CanvasHelper
40 : {
41 : public:
42 : SpriteCanvasHelper();
43 :
44 : void init( const OutDevProviderSharedPtr& rOutDev,
45 : SpriteCanvas& rOwningSpriteCanvas,
46 : ::canvas::SpriteRedrawManager& rManager,
47 : bool bProtect,
48 : bool bHaveAlpha );
49 :
50 : /// Dispose all internal references
51 : void disposing();
52 :
53 : // XSpriteCanvas
54 : ::com::sun::star::uno::Reference<
55 : ::com::sun::star::rendering::XAnimatedSprite > createSpriteFromAnimation(
56 : const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XAnimation >& animation );
57 :
58 : ::com::sun::star::uno::Reference<
59 : ::com::sun::star::rendering::XAnimatedSprite > createSpriteFromBitmaps(
60 : const ::com::sun::star::uno::Sequence<
61 : ::com::sun::star::uno::Reference<
62 : ::com::sun::star::rendering::XBitmap > >& animationBitmaps,
63 : sal_Int8 interpolationMode );
64 :
65 : ::com::sun::star::uno::Reference<
66 : ::com::sun::star::rendering::XCustomSprite > createCustomSprite(
67 : const ::com::sun::star::geometry::RealSize2D& spriteSize );
68 :
69 : ::com::sun::star::uno::Reference<
70 : ::com::sun::star::rendering::XSprite > createClonedSprite(
71 : const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XSprite >& original );
72 :
73 : /** Actually perform the screen update
74 :
75 : @param bUpdateAll
76 : sal_True, if everything must be updated, not only changed
77 : sprites
78 :
79 : @param io_bSurfaceDirty
80 : In/out parameter, whether backbuffer surface is dirty (if
81 : yes, we're performing a full update, anyway)
82 : */
83 : sal_Bool updateScreen( sal_Bool bUpdateAll,
84 : bool& io_bSurfaceDirty );
85 :
86 : // SpriteRedrawManager functor calls
87 : // -------------------------------------------------
88 :
89 : /** Gets called for simple background repaints
90 : */
91 : void backgroundPaint( const ::basegfx::B2DRange& rUpdateRect );
92 :
93 : /** Gets called when area can be handled by scrolling.
94 :
95 : Called method must copy screen content from rMoveStart to
96 : rMoveEnd, and restore the background in the uncovered
97 : areas.
98 :
99 : @param rMoveStart
100 : Source rect of the scroll
101 :
102 : @param rMoveEnd
103 : Dest rect of the scroll
104 :
105 : @param rUpdateArea
106 : All info necessary, should rMoveStart be partially or
107 : fully outside the outdev
108 : */
109 : void scrollUpdate( const ::basegfx::B2DRange& rMoveStart,
110 : const ::basegfx::B2DRange& rMoveEnd,
111 : const ::canvas::SpriteRedrawManager::UpdateArea& rUpdateArea );
112 :
113 : void opaqueUpdate( const ::basegfx::B2DRange& rTotalArea,
114 : const ::std::vector< ::canvas::Sprite::Reference >& rSortedUpdateSprites );
115 :
116 : void genericUpdate( const ::basegfx::B2DRange& rTotalArea,
117 : const ::std::vector< ::canvas::Sprite::Reference >& rSortedUpdateSprites );
118 :
119 0 : ::com::sun::star::uno::Any isUnsafeScrolling() const
120 : {
121 0 : return ::com::sun::star::uno::makeAny(mbIsUnsafeScrolling);
122 : }
123 0 : void enableUnsafeScrolling( const ::com::sun::star::uno::Any& rAny )
124 : {
125 0 : mbIsUnsafeScrolling = rAny.get<bool>();
126 0 : }
127 :
128 0 : ::com::sun::star::uno::Any isSpriteBounds() const
129 : {
130 0 : return ::com::sun::star::uno::makeAny(mbShowSpriteBounds);
131 : }
132 0 : void enableSpriteBounds( const ::com::sun::star::uno::Any& rAny )
133 : {
134 0 : mbShowSpriteBounds = rAny.get<bool>();
135 0 : }
136 :
137 : private:
138 : void renderFrameCounter( OutputDevice& rOutDev );
139 : void renderSpriteCount( OutputDevice& rOutDev );
140 : void renderMemUsage( OutputDevice& rOutDev );
141 :
142 : /// Set from the SpriteCanvas: instance coordinating sprite redraw
143 : ::canvas::SpriteRedrawManager* mpRedrawManager;
144 :
145 : /// Set from the init method. used to generate sprites
146 : SpriteCanvas* mpOwningSpriteCanvas;
147 :
148 : /** Background compositing surface.
149 :
150 : Typically, sprites will be composited in the background,
151 : before pushing them to screen. This happens here.
152 : */
153 : ::canvas::vcltools::VCLObject< VirtualDevice > maVDev;
154 :
155 : /// For the frame counter timings
156 : ::canvas::tools::ElapsedTime maLastUpdate;
157 :
158 : /// When true, canvas displays debug info on each frame
159 : bool mbShowFrameInfo;
160 :
161 : /// When true, canvas creates all new sprites with red lines in the corners
162 : bool mbShowSpriteBounds;
163 :
164 : /// When true, canvas uses the scroll optimization (direct scrolls in front buffer)
165 : bool mbIsUnsafeScrolling;
166 : };
167 : }
168 :
169 : #endif /* _VCLCANVAS_SPRITECANVASHELPER_HXX_ */
170 :
171 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|