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