~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kwin/scene_xrender.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/********************************************************************
 
2
 KWin - the KDE window manager
 
3
 This file is part of the KDE project.
 
4
 
 
5
Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
 
6
 
 
7
This program is free software; you can redistribute it and/or modify
 
8
it under the terms of the GNU General Public License as published by
 
9
the Free Software Foundation; either version 2 of the License, or
 
10
(at your option) any later version.
 
11
 
 
12
This program is distributed in the hope that it will be useful,
 
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
GNU General Public License for more details.
 
16
 
 
17
You should have received a copy of the GNU General Public License
 
18
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
*********************************************************************/
 
20
 
 
21
#ifndef KWIN_SCENE_XRENDER_H
 
22
#define KWIN_SCENE_XRENDER_H
 
23
 
 
24
#include <config-workspace.h>
 
25
 
 
26
#include "scene.h"
 
27
#include "shadow.h"
 
28
 
 
29
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
 
30
#include <X11/extensions/Xrender.h>
 
31
#include <X11/extensions/Xfixes.h>
 
32
 
 
33
namespace KWin
 
34
{
 
35
 
 
36
 
 
37
class SceneXrender
 
38
    : public Scene
 
39
{
 
40
public:
 
41
    class EffectFrame;
 
42
    SceneXrender(Workspace* ws);
 
43
    virtual ~SceneXrender();
 
44
    virtual bool initFailed() const;
 
45
    virtual CompositingType compositingType() const {
 
46
        return XRenderCompositing;
 
47
    }
 
48
    virtual void paint(QRegion damage, ToplevelList windows);
 
49
    virtual void windowGeometryShapeChanged(Toplevel*);
 
50
    virtual void windowOpacityChanged(Toplevel*);
 
51
    virtual void windowAdded(Toplevel*);
 
52
    virtual void windowClosed(Toplevel*, Deleted*);
 
53
    virtual void windowDeleted(Deleted*);
 
54
    Picture bufferPicture();
 
55
protected:
 
56
    virtual void paintBackground(QRegion region);
 
57
    virtual void paintGenericScreen(int mask, ScreenPaintData data);
 
58
private:
 
59
    void paintTransformedScreen(int mask);
 
60
    void createBuffer();
 
61
    void flushBuffer(int mask, QRegion damage);
 
62
    bool selfCheck();
 
63
    void selfCheckSetup();
 
64
    bool selfCheckFinish();
 
65
    XRenderPictFormat* format;
 
66
    Picture front;
 
67
    static Picture buffer;
 
68
    static ScreenPaintData screen_paint;
 
69
    class Window;
 
70
    QHash< Toplevel*, Window* > windows;
 
71
    bool init_ok;
 
72
};
 
73
 
 
74
class SceneXrender::Window
 
75
    : public Scene::Window
 
76
{
 
77
public:
 
78
    Window(Toplevel* c);
 
79
    virtual ~Window();
 
80
    virtual void performPaint(int mask, QRegion region, WindowPaintData data);
 
81
    void discardPicture();
 
82
    void discardAlpha();
 
83
    QRegion transformedShape() const;
 
84
    void setTransformedShape(const QRegion& shape);
 
85
private:
 
86
    Picture picture();
 
87
    Picture alphaMask(double opacity);
 
88
    QRect mapToScreen(int mask, const WindowPaintData &data, const QRect &rect) const;
 
89
    QPoint mapToScreen(int mask, const WindowPaintData &data, const QPoint &point) const;
 
90
    void prepareTempPixmap(const QPixmap *left, const QPixmap *top, const QPixmap *right, const QPixmap *bottom);
 
91
    Picture _picture;
 
92
    XRenderPictFormat* format;
 
93
    Picture alpha;
 
94
    double alpha_cached_opacity;
 
95
    QRegion transformed_shape;
 
96
    static QPixmap *temp_pixmap;
 
97
};
 
98
 
 
99
class SceneXrender::EffectFrame
 
100
    : public Scene::EffectFrame
 
101
{
 
102
public:
 
103
    EffectFrame(EffectFrameImpl* frame);
 
104
    virtual ~EffectFrame();
 
105
 
 
106
    virtual void free();
 
107
    virtual void freeIconFrame();
 
108
    virtual void freeTextFrame();
 
109
    virtual void freeSelection();
 
110
    virtual void crossFadeIcon();
 
111
    virtual void crossFadeText();
 
112
    virtual void render(QRegion region, double opacity, double frameOpacity);
 
113
 
 
114
private:
 
115
    void updatePicture();
 
116
    void updateTextPicture();
 
117
 
 
118
    XRenderPicture* m_picture;
 
119
    XRenderPicture* m_textPicture;
 
120
    XRenderPicture* m_iconPicture;
 
121
    XRenderPicture* m_selectionPicture;
 
122
};
 
123
 
 
124
inline
 
125
Picture SceneXrender::bufferPicture()
 
126
{
 
127
    return buffer;
 
128
}
 
129
 
 
130
inline
 
131
QRegion SceneXrender::Window::transformedShape() const
 
132
{
 
133
    return transformed_shape;
 
134
}
 
135
 
 
136
inline
 
137
void SceneXrender::Window::setTransformedShape(const QRegion& shape)
 
138
{
 
139
    transformed_shape = shape;
 
140
}
 
141
 
 
142
/**
 
143
 * @short XRender implementation of Shadow.
 
144
 *
 
145
 * This class extends Shadow by the elements required for XRender rendering.
 
146
 * @author Jacopo De Simoi <wilderkde@gmail.org>
 
147
 **/
 
148
 
 
149
class SceneXRenderShadow
 
150
    : public Shadow
 
151
{
 
152
public:
 
153
    SceneXRenderShadow(Toplevel *toplevel);
 
154
    virtual ~SceneXRenderShadow();
 
155
 
 
156
    Qt::HANDLE x11ShadowPictureHandle(WindowQuadType);
 
157
    void layoutShadowRects(QRect& top, QRect& topRight,
 
158
                           QRect& right, QRect& bottomRight,
 
159
                           QRect& bottom, QRect& bottomLeft,
 
160
                           QRect& Left, QRect& topLeft);
 
161
 
 
162
    const QPixmap &resizedShadowPixmap(ShadowElements element) const {
 
163
        return m_resizedElements[element];
 
164
    };
 
165
 
 
166
protected:
 
167
    virtual void buildQuads();
 
168
 
 
169
private:
 
170
    QPixmap m_resizedElements[ShadowElementsCount];
 
171
};
 
172
 
 
173
} // namespace
 
174
 
 
175
#endif
 
176
 
 
177
#endif