2
* Copyright (C) 2009, 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
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.
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.
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
19
#ifndef BackingStoreTile_h
20
#define BackingStoreTile_h
22
#include "BlackBerryPlatformIntRectRegion.h"
23
#include "BlackBerryPlatformPrimitives.h"
24
#include <wtf/PassRefPtr.h>
25
#include <wtf/RefCounted.h>
26
#include <wtf/RefPtr.h>
28
namespace BlackBerry {
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> {
44
static PassRefPtr<Fence> create(void* platformSync = 0)
46
return adoptRef(new Fence(platformSync));
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()
54
void* tmp = m_platformSync;
62
Fence(void* platformSync)
63
: m_platformSync(platformSync)
72
TileBuffer(const Platform::IntSize&);
74
Platform::IntSize size() const;
75
Platform::IntRect rect() const;
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;
85
double scale() { return m_scale; }
86
void setScale(double scale) { m_scale = scale; };
88
Platform::Graphics::Buffer* nativeBuffer() const;
89
bool wasNativeBufferCreated() const;
91
Fence* fence() const { return m_fence.get(); }
92
void setFence(PassRefPtr<Fence> fence) { m_fence = fence; }
95
Platform::IntSize m_size;
96
Platform::IntRectRegion m_renderedRegion;
97
RefPtr<Fence> m_fence;
98
mutable Platform::Graphics::Buffer* m_buffer;
103
class BackingStoreTile {
105
enum BufferingMode { SingleBuffered, DoubleBuffered };
107
static BackingStoreTile* create(const Platform::IntSize& size, BufferingMode mode)
109
return new BackingStoreTile(size, mode);
114
Platform::IntSize size() const;
115
Platform::IntRect rect() const;
117
TileBuffer* frontBuffer() const;
118
TileBuffer* backBuffer() const;
119
bool isDoubleBuffered() const { return m_bufferingMode == DoubleBuffered; }
122
bool backgroundPainted() const { return m_backgroundPainted; }
123
void paintBackground();
125
bool isCommitted() const { return m_committed; }
126
void setCommitted(bool committed) { m_committed = committed; }
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; }
137
BackingStoreTile(const Platform::IntSize&, BufferingMode);
139
mutable TileBuffer* m_frontBuffer;
140
BufferingMode m_bufferingMode;
143
bool m_backgroundPainted;
144
int m_horizontalShift;
148
} // namespace WebKit
149
} // namespace BlackBerry
151
#endif // BackingStoreTile_h