1/*
2 * Copyright (C) 2009, 2010, 2011 Research In Motion Limited. All rights reserved.
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 BackingStore_h
20#define BackingStore_h
21
22#include "BlackBerryGlobal.h"
23#include <BlackBerryPlatformMisc.h>
24
25namespace WebCore {
26class ChromeClientBlackBerry;
27class FloatPoint;
28class FrameLoaderClientBlackBerry;
29class GLES2Context;
30class IntRect;
31}
32
33namespace BlackBerry {
34namespace Platform {
35class IntRect;
36class FloatPoint;
37
38namespace Graphics {
39class Buffer;
40}
41}
42}
43
44namespace BlackBerry {
45namespace WebKit {
46
47class WebPage;
48class WebPagePrivate;
49class WebPageCompositorPrivate;
50class BackingStorePrivate;
51class BackingStoreClient;
52
53class BLACKBERRY_EXPORT BackingStore {
54public:
55    enum ResumeUpdateOperation { None, Blit, RenderAndBlit };
56    BackingStore(WebPage*, BackingStoreClient*);
57    virtual ~BackingStore();
58
59    void createSurface();
60
61    void suspendBackingStoreUpdates();
62    void resumeBackingStoreUpdates();
63
64    void suspendGeometryUpdates();
65    void resumeGeometryUpdates();
66
67    void suspendScreenUpdates();
68    void resumeScreenUpdates(BackingStore::ResumeUpdateOperation);
69
70    bool isScrollingOrZooming() const;
71    void setScrollingOrZooming(bool);
72
73    void blitVisibleContents();
74    void repaint(int x, int y, int width, int height, bool contentChanged, bool immediate);
75
76    bool hasBlitJobs() const;
77    void blitOnIdle();
78
79    void acquireBackingStoreMemory();
80    void releaseOwnedBackingStoreMemory();
81
82    bool drawContents(BlackBerry::Platform::Graphics::Buffer*, const BlackBerry::Platform::IntRect& dstRect, double scale, const BlackBerry::Platform::FloatPoint& documentScrollPosition);
83
84private:
85    friend class BlackBerry::WebKit::BackingStoreClient;
86    friend class BlackBerry::WebKit::BackingStorePrivate;
87    friend class BlackBerry::WebKit::WebPage;
88    friend class BlackBerry::WebKit::WebPagePrivate; // FIXME: For now, we expose our internals to WebPagePrivate. See PR #120301.
89    friend class BlackBerry::WebKit::WebPageCompositorPrivate;
90    friend class WebCore::ChromeClientBlackBerry;
91    friend class WebCore::FrameLoaderClientBlackBerry;
92    friend class WebCore::GLES2Context;
93    BackingStorePrivate *d;
94    DISABLE_COPY(BackingStore)
95};
96}
97}
98
99#endif // BackingStore_h
100