/src/libreoffice/canvas/inc/base/sprite.hxx
Line | Count | Source |
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 | | #pragma once |
21 | | |
22 | | #include <rtl/ref.hxx> |
23 | | #include <com/sun/star/lang/XComponent.hpp> |
24 | | #include <basegfx/point/b2dpoint.hxx> |
25 | | |
26 | | namespace basegfx |
27 | | { |
28 | | class B2DVector; |
29 | | class B2DRange; |
30 | | } |
31 | | |
32 | | namespace canvas |
33 | | { |
34 | | /* Definition of Sprite interface (as we mix with UNO here, has to |
35 | | be XInterface - reference holders to a Sprite must be able to |
36 | | control lifetime of reference target) |
37 | | */ |
38 | | |
39 | | /** Helper interface to connect SpriteCanvas with various |
40 | | sprite implementations. |
41 | | |
42 | | This interface should be implemented from every sprite class, |
43 | | as it provides essential repaint and update area facilitates. |
44 | | |
45 | | @derive typically, each canvas implementation will derive |
46 | | another interface from this one, that adds rendering |
47 | | functionality (which, of course, is impossible here in a |
48 | | generic way) |
49 | | */ |
50 | | class Sprite : public css::lang::XComponent |
51 | | { |
52 | | public: |
53 | | typedef ::rtl::Reference< Sprite > Reference; |
54 | | |
55 | | /** Query whether sprite update will fully cover the given area. |
56 | | |
57 | | Use this method to determine whether any background |
58 | | content (regardless of static or sprite) needs an update |
59 | | before rendering this sprite. |
60 | | |
61 | | @return true, if sprite redraw will fully overwrite given |
62 | | area (and thus, the background need not be redrawn |
63 | | beforehand). |
64 | | */ |
65 | | virtual bool isAreaUpdateOpaque( const ::basegfx::B2DRange& rUpdateArea ) const = 0; |
66 | | |
67 | | /** Query whether content has changed |
68 | | */ |
69 | | virtual bool isContentChanged() const = 0; |
70 | | |
71 | | /** Query position of the left, top pixel of the sprite |
72 | | */ |
73 | | virtual ::basegfx::B2DPoint getPosPixel() const = 0; |
74 | | |
75 | | /** Query size of the sprite in pixel. |
76 | | */ |
77 | | virtual ::basegfx::B2DVector getSizePixel() const = 0; |
78 | | |
79 | | /** Get area that is currently covered by the sprite |
80 | | |
81 | | This area is already adapted to clipping, alpha and |
82 | | transformation state of this sprite. |
83 | | */ |
84 | | virtual ::basegfx::B2DRange getUpdateArea() const = 0; |
85 | | |
86 | | /** Query sprite priority |
87 | | */ |
88 | | virtual double getPriority() const = 0; |
89 | | |
90 | | protected: |
91 | 0 | ~Sprite() {} |
92 | | }; |
93 | | |
94 | | /** Functor providing a StrictWeakOrdering for sprite references |
95 | | */ |
96 | | struct SpriteWeakOrder |
97 | | { |
98 | | bool operator()( const Sprite::Reference& rLHS, |
99 | | const Sprite::Reference& rRHS ) |
100 | 0 | { |
101 | 0 | const double nPrioL( rLHS->getPriority() ); |
102 | 0 | const double nPrioR( rRHS->getPriority() ); |
103 | | |
104 | | // if prios are equal, tie-break on ptr value |
105 | 0 | return nPrioL == nPrioR ? rLHS.get() < rRHS.get() : nPrioL < nPrioR; |
106 | 0 | } |
107 | | }; |
108 | | } |
109 | | |
110 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |