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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
/*
* Copyright (C) 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
*
* 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 WebPageCompositor_p_h
#define WebPageCompositor_p_h
#if USE(ACCELERATED_COMPOSITING)
#include "LayerCompositingThread.h"
#include "LayerRenderer.h"
#include <BlackBerryPlatformAnimationFrameRateController.h>
#include <BlackBerryPlatformGLES2Context.h>
#include <wtf/OwnPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
namespace WebCore {
class LayerWebKitThread;
};
namespace BlackBerry {
namespace WebKit {
class WebPageCompositorClient;
class WebPagePrivate;
// This class may only be used on the compositing thread. So it does not need to be threadsaferefcounted.
class WebPageCompositorPrivate : public RefCounted<WebPageCompositorPrivate>, public Platform::AnimationFrameRateClient {
public:
static PassRefPtr<WebPageCompositorPrivate> create(WebPagePrivate* page, WebPageCompositorClient* client)
{
return adoptRef(new WebPageCompositorPrivate(page, client));
}
~WebPageCompositorPrivate();
// Public API
void prepareFrame(double animationTime);
void render(const WebCore::IntRect& targetRect,
const WebCore::IntRect& clipRect,
const WebCore::TransformationMatrix&,
const WebCore::FloatRect& contents, // This is public API, thus takes transformed contents
const WebCore::FloatRect& viewport);
Platform::Graphics::GLES2Context* context() const { return m_context; }
void setContext(Platform::Graphics::GLES2Context*);
WebCore::LayerCompositingThread* rootLayer() const { return m_rootLayer.get(); }
void setRootLayer(WebCore::LayerCompositingThread*);
WebCore::LayerCompositingThread* overlayLayer() const { return m_overlayLayer.get(); }
void setOverlayLayer(WebCore::LayerCompositingThread*);
WebCore::LayerCompositingThread* compositingThreadOverlayLayer() const { return m_compositingThreadOverlayLayer.get(); }
bool drawsRootLayer() const;
void setDrawsRootLayer(bool drawsRootLayer) { m_drawsRootLayer = drawsRootLayer; }
// Render everything but the root layer, or everything if drawsRootLayer() is true.
bool drawLayers(const WebCore::IntRect& dstRect, const WebCore::FloatRect& contents);
WebCore::IntRect layoutRectForCompositing() const { return m_layoutRectForCompositing; }
void setLayoutRectForCompositing(const WebCore::IntRect& rect) { m_layoutRectForCompositing = rect; }
WebCore::IntSize contentsSizeForCompositing() const { return m_contentsSizeForCompositing; }
void setContentsSizeForCompositing(const WebCore::IntSize& size) { m_contentsSizeForCompositing = size; }
WebCore::LayerRenderingResults lastCompositingResults() const { return m_lastCompositingResults; }
void setLastCompositingResults(const WebCore::LayerRenderingResults& results) { m_lastCompositingResults = results; }
WebCore::Color backgroundColor() const { return m_backgroundColor; }
void setBackgroundColor(const WebCore::Color&);
void releaseLayerResources();
WebPagePrivate* page() const { return m_webPage; }
void setPage(WebPagePrivate* page);
void detach();
WebPageCompositorClient* client() const { return m_client; }
void compositorDestroyed();
void addOverlay(WebCore::LayerCompositingThread*);
void removeOverlay(WebCore::LayerCompositingThread*);
protected:
WebPageCompositorPrivate(WebPagePrivate*, WebPageCompositorClient*);
private:
void animationFrameChanged();
void compositeLayers(const WebCore::TransformationMatrix&);
WebPageCompositorClient* m_client;
WebPagePrivate* m_webPage;
Platform::Graphics::GLES2Context* m_context;
OwnPtr<WebCore::LayerRenderer> m_layerRenderer;
RefPtr<WebCore::LayerCompositingThread> m_rootLayer;
RefPtr<WebCore::LayerCompositingThread> m_overlayLayer;
RefPtr<WebCore::LayerCompositingThread> m_compositingThreadOverlayLayer;
WebCore::IntRect m_layoutRectForCompositing;
WebCore::IntSize m_contentsSizeForCompositing;
WebCore::LayerRenderingResults m_lastCompositingResults;
WebCore::Color m_backgroundColor;
bool m_drawsRootLayer;
};
} // namespace WebKit
} // namespace BlackBerry
#endif // USE(ACCELERATED_COMPOSITING)
#endif // WebPageCompositor_p_h
|