1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
/*
* Copyright (C) 2011 Igalia, S.L.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AcceleratedCompositingContext_h
#define AcceleratedCompositingContext_h
#include "GraphicsLayer.h"
#include "GraphicsLayerClient.h"
#include "IntRect.h"
#include "IntSize.h"
#include "Timer.h"
#include "webkitwebview.h"
#include <wtf/PassOwnPtr.h>
#if USE(TEXTURE_MAPPER)
#include "TextureMapperLayer.h"
#endif
#if USE(TEXTURE_MAPPER_GL)
#include "GLContext.h"
#include "RedirectedXCompositeWindow.h"
#include "TextureMapperFPSCounter.h"
#endif
#if USE(ACCELERATED_COMPOSITING)
namespace WebKit {
class AcceleratedCompositingContext : public WebCore::GraphicsLayerClient {
WTF_MAKE_NONCOPYABLE(AcceleratedCompositingContext);
public:
static PassOwnPtr<AcceleratedCompositingContext> create(WebKitWebView* webView)
{
return adoptPtr(new AcceleratedCompositingContext(webView));
}
virtual ~AcceleratedCompositingContext();
void setRootCompositingLayer(WebCore::GraphicsLayer*);
void setNonCompositedContentsNeedDisplay(const WebCore::IntRect&);
void scheduleLayerFlush();
void resizeRootLayer(const WebCore::IntSize&);
bool renderLayersToWindow(cairo_t*, const WebCore::IntRect& clipRect);
bool enabled();
// GraphicsLayerClient
virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time);
virtual void notifyFlushRequired(const WebCore::GraphicsLayer*);
virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& rectToPaint);
void initialize();
enum CompositePurpose { ForResize, NotForResize };
void compositeLayersToContext(CompositePurpose = NotForResize);
void flushAndRenderLayers();
bool flushPendingLayerChanges();
void scrollNonCompositedContents(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
private:
WebKitWebView* m_webView;
unsigned int m_layerFlushTimerCallbackId;
#if USE(TEXTURE_MAPPER_GL)
OwnPtr<WebCore::RedirectedXCompositeWindow> m_redirectedWindow;
OwnPtr<WebCore::GraphicsLayer> m_rootLayer;
OwnPtr<WebCore::GraphicsLayer> m_nonCompositedContentLayer;
OwnPtr<WebCore::TextureMapper> m_textureMapper;
double m_lastFlushTime;
double m_redrawPendingTime;
bool m_needsExtraFlush;
WebCore::TextureMapperFPSCounter m_fpsCounter;
void layerFlushTimerFired();
void stopAnyPendingLayerFlush();
static gboolean layerFlushTimerFiredCallback(AcceleratedCompositingContext*);
WebCore::GLContext* prepareForRendering();
void clearEverywhere();
#elif USE(TEXTURE_MAPPER)
WebCore::TextureMapperLayer* m_rootTextureMapperLayer;
OwnPtr<WebCore::GraphicsLayer> m_rootGraphicsLayer;
OwnPtr<WebCore::TextureMapper> m_textureMapper;
#endif
AcceleratedCompositingContext(WebKitWebView*);
};
} // namespace WebKit
#endif // USE(ACCELERATED_COMPOSITING)
#endif // AcceleratedCompositingContext_h
|