24a614db45f4f2f5cc329d488f4a187af941d811
[WebKit-https.git] / Source / WebKit / gtk / WebCoreSupport / AcceleratedCompositingContext.h
1 /*
2  * Copyright (C) 2011 Igalia, S.L.
3  *
4  *  This library is free software; you can redistribute it and/or
5  *  modify it under the terms of the GNU Lesser General Public
6  *  License as published by the Free Software Foundation; either
7  *  version 2 of the License, or (at your option) any later version.
8  *
9  *  This library is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  *  Lesser General Public License for more details.
13  *
14  *  You should have received a copy of the GNU Lesser General Public
15  *  License along with this library; if not, write to the Free Software
16  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17  */
18
19 #ifndef AcceleratedCompositingContext_h
20 #define AcceleratedCompositingContext_h
21
22 #include "GraphicsLayer.h"
23 #include "GraphicsLayerClient.h"
24 #include "IntRect.h"
25 #include "IntSize.h"
26 #include "Timer.h"
27 #include "webkitwebview.h"
28 #include <wtf/PassOwnPtr.h>
29
30 #if USE(TEXTURE_MAPPER)
31 #if USE(TEXTURE_MAPPER_GL)
32 #include "GLContext.h"
33 #endif
34 #include "TextureMapperLayer.h"
35 #endif
36
37 #if USE(ACCELERATED_COMPOSITING)
38
39 namespace WebKit {
40
41 class AcceleratedCompositingContext : public WebCore::GraphicsLayerClient {
42     WTF_MAKE_NONCOPYABLE(AcceleratedCompositingContext);
43 public:
44     static PassOwnPtr<AcceleratedCompositingContext> create(WebKitWebView* webView)
45     {
46         return adoptPtr(new AcceleratedCompositingContext(webView));
47     }
48
49     virtual ~AcceleratedCompositingContext();
50     void attachRootGraphicsLayer(WebCore::GraphicsLayer*);
51     void scheduleRootLayerRepaint(const WebCore::IntRect&);
52     void markForSync();
53     void syncLayersTimeout();
54     void syncLayersNow();
55     void resizeRootLayer(const WebCore::IntSize&);
56     bool renderLayersToWindow(cairo_t*, const WebCore::IntRect& clipRect);
57     bool enabled();
58
59     // GraphicsLayerClient
60     virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time);
61     virtual void notifySyncRequired(const WebCore::GraphicsLayer*);
62     virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& rectToPaint);
63     virtual bool showDebugBorders(const WebCore::GraphicsLayer*) const;
64     virtual bool showRepaintCounter(const WebCore::GraphicsLayer*) const;
65
66 private:
67     WebKitWebView* m_webView;
68     unsigned int m_syncTimerCallbackId;
69
70 #if USE(CLUTTER)
71     WebCore::GraphicsLayer* m_rootGraphicsLayer;
72     GtkWidget* m_rootLayerEmbedder;
73 #elif USE(TEXTURE_MAPPER)
74     WebCore::TextureMapperLayer* m_rootTextureMapperLayer;
75     OwnPtr<WebCore::GraphicsLayer> m_rootGraphicsLayer;
76     OwnPtr<WebCore::TextureMapper> m_textureMapper;
77 #if USE(TEXTURE_MAPPER_GL)
78     WebCore::GLContext* glContext();
79     OwnPtr<WebCore::GLContext> m_context;
80 #endif
81 #endif
82
83     AcceleratedCompositingContext(WebKitWebView*);
84 };
85
86 } // namespace WebKit
87
88 #endif // USE(ACCELERATED_COMPOSITING)
89 #endif // AcceleratedCompositingContext_h