~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebKit/blackberry/WebKitSupport/BackingStoreTile.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2009, 2010, 2011, 2012 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 BackingStoreTile_h
 
20
#define BackingStoreTile_h
 
21
 
 
22
#include "BlackBerryPlatformIntRectRegion.h"
 
23
#include "BlackBerryPlatformPrimitives.h"
 
24
#include <wtf/PassRefPtr.h>
 
25
#include <wtf/RefCounted.h>
 
26
#include <wtf/RefPtr.h>
 
27
 
 
28
namespace BlackBerry {
 
29
namespace Platform {
 
30
namespace Graphics {
 
31
struct Buffer;
 
32
}
 
33
}
 
34
 
 
35
namespace WebKit {
 
36
 
 
37
// Represents a fence that has been inserted into the command stream. You can wait on the corresponding platform sync
 
38
// object to make sure that previous commands have been completed.
 
39
// There is no reason to wait twice on the same platform sync object, so the only mechanism provided to access the sync
 
40
// object will also clear it to prevent anyone from waiting again.
 
41
// Fence is only refcounted on the compositing thread, so RefCounted will suffice, we don't need ThreadSafeRefCounted.
 
42
class Fence : public RefCounted<Fence> {
 
43
public:
 
44
    static PassRefPtr<Fence> create(void* platformSync = 0)
 
45
    {
 
46
        return adoptRef(new Fence(platformSync));
 
47
    }
 
48
 
 
49
    // Returns 0 if this fence is stale (someone already waited on it)
 
50
    // Otherwise returns the platform sync object and clears the sync
 
51
    // object so no-one waits again.
 
52
    void* takePlatformSync()
 
53
    {
 
54
        void* tmp = m_platformSync;
 
55
        m_platformSync = 0;
 
56
        return tmp;
 
57
    }
 
58
 
 
59
    ~Fence();
 
60
 
 
61
private:
 
62
    Fence(void* platformSync)
 
63
        : m_platformSync(platformSync)
 
64
    {
 
65
    }
 
66
 
 
67
    void* m_platformSync;
 
68
};
 
69
 
 
70
class TileBuffer {
 
71
    public:
 
72
        TileBuffer(const Platform::IntSize&);
 
73
        ~TileBuffer();
 
74
        Platform::IntSize size() const;
 
75
        Platform::IntRect rect() const;
 
76
 
 
77
        bool isRendered(double scale) const;
 
78
        bool isRendered(const Platform::IntRectRegion& contents, double scale) const;
 
79
        void clearRenderedRegion();
 
80
        void clearRenderedRegion(const Platform::IntRectRegion&);
 
81
        void addRenderedRegion(const Platform::IntRectRegion&);
 
82
        Platform::IntRectRegion renderedRegion() const;
 
83
        Platform::IntRectRegion notRenderedRegion() const;
 
84
 
 
85
        double scale() { return m_scale; }
 
86
        void setScale(double scale) { m_scale = scale; };
 
87
 
 
88
        Platform::Graphics::Buffer* nativeBuffer() const;
 
89
        bool wasNativeBufferCreated() const;
 
90
 
 
91
        Fence* fence() const { return m_fence.get(); }
 
92
        void setFence(PassRefPtr<Fence> fence) { m_fence = fence; }
 
93
 
 
94
    private:
 
95
        Platform::IntSize m_size;
 
96
        Platform::IntRectRegion m_renderedRegion;
 
97
        RefPtr<Fence> m_fence;
 
98
        mutable Platform::Graphics::Buffer* m_buffer;
 
99
        double m_scale;
 
100
};
 
101
 
 
102
 
 
103
class BackingStoreTile {
 
104
public:
 
105
    enum BufferingMode { SingleBuffered, DoubleBuffered };
 
106
 
 
107
    static BackingStoreTile* create(const Platform::IntSize& size, BufferingMode mode)
 
108
    {
 
109
        return new BackingStoreTile(size, mode);
 
110
    }
 
111
 
 
112
    ~BackingStoreTile();
 
113
 
 
114
    Platform::IntSize size() const;
 
115
    Platform::IntRect rect() const;
 
116
 
 
117
    TileBuffer* frontBuffer() const;
 
118
    TileBuffer* backBuffer() const;
 
119
    bool isDoubleBuffered() const { return m_bufferingMode == DoubleBuffered; }
 
120
 
 
121
    void reset();
 
122
    bool backgroundPainted() const { return m_backgroundPainted; }
 
123
    void paintBackground();
 
124
 
 
125
    bool isCommitted() const { return m_committed; }
 
126
    void setCommitted(bool committed) { m_committed = committed; }
 
127
 
 
128
    void clearShift() { m_horizontalShift = 0; m_verticalShift = 0; }
 
129
    int horizontalShift() const { return m_horizontalShift; }
 
130
    void setHorizontalShift(int shift) { m_horizontalShift = shift; }
 
131
    int verticalShift() const { return m_verticalShift; }
 
132
    void setVerticalShift(int shift) { m_verticalShift = shift; }
 
133
 
 
134
    void swapBuffers();
 
135
 
 
136
private:
 
137
    BackingStoreTile(const Platform::IntSize&, BufferingMode);
 
138
 
 
139
    mutable TileBuffer* m_frontBuffer;
 
140
    BufferingMode m_bufferingMode;
 
141
    bool m_checkered;
 
142
    bool m_committed;
 
143
    bool m_backgroundPainted;
 
144
    int m_horizontalShift;
 
145
    int m_verticalShift;
 
146
};
 
147
 
 
148
} // namespace WebKit
 
149
} // namespace BlackBerry
 
150
 
 
151
#endif // BackingStoreTile_h