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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
/*
* Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "TiledDrawingArea.h"
#if USE(TILED_BACKING_STORE)
#include "DrawingAreaProxyMessages.h"
#include "MessageID.h"
#include "UpdateInfo.h"
#include "WebCoreArgumentCoders.h"
#include "WebPage.h"
#include "WebProcess.h"
using namespace WebCore;
namespace WebKit {
TiledDrawingArea::TiledDrawingArea(WebPage* webPage)
: DrawingArea(DrawingAreaTypeTiled, webPage)
, m_suspended(false)
, m_isWaitingForUIProcess(false)
, m_didSendTileUpdate(false)
, m_mainBackingStore(adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this))))
{
}
TiledDrawingArea::~TiledDrawingArea()
{
}
void TiledDrawingArea::scroll(const IntRect& scrollRect, const IntSize& scrollDelta)
{
// FIXME: Do something much smarter.
setNeedsDisplay(scrollRect);
}
void TiledDrawingArea::setNeedsDisplay(const IntRect& rect)
{
m_mainBackingStore->invalidate(rect);
}
void TiledDrawingArea::setSize(const IntSize& viewSize)
{
ASSERT(!m_suspended);
ASSERT_ARG(viewSize, !viewSize.isEmpty());
m_webPage->setSize(viewSize);
}
void TiledDrawingArea::setVisibleContentRectAndScale(const WebCore::IntRect& visibleContentsRect, float scale)
{
m_visibleContentRect = visibleContentsRect;
if (scale != m_mainBackingStore->contentsScale()) {
// Keep the tiles for the previous scale until enough content is available to be shown on the screen for the new scale.
// If we already have a previous set of tiles it means that two scale changed happened successively.
// In that case, make sure that our current main tiles have more content to show than the "previous previous"
// within the visible rect before replacing it.
if (!m_previousBackingStore || m_mainBackingStore->coverageRatio(m_visibleContentRect) > m_previousBackingStore->coverageRatio(m_visibleContentRect))
m_previousBackingStore = m_mainBackingStore.release();
m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this)));
m_mainBackingStore->setContentsScale(scale);
} else
m_mainBackingStore->adjustVisibleRect();
}
void TiledDrawingArea::setVisibleContentRectTrajectoryVector(const WebCore::FloatPoint& trajectoryVector)
{
m_mainBackingStore->setVisibleRectTrajectoryVector(trajectoryVector);
}
void TiledDrawingArea::renderNextFrame()
{
m_isWaitingForUIProcess = false;
m_mainBackingStore->updateTileBuffers();
}
void TiledDrawingArea::suspendPainting()
{
ASSERT(!m_suspended);
m_suspended = true;
}
void TiledDrawingArea::resumePainting()
{
ASSERT(m_suspended);
m_suspended = false;
m_mainBackingStore->updateTileBuffers();
}
void TiledDrawingArea::tiledBackingStorePaintBegin()
{
m_webPage->layoutIfNeeded();
}
void TiledDrawingArea::tiledBackingStorePaint(GraphicsContext* graphicsContext, const IntRect& contentRect)
{
m_webPage->drawRect(*graphicsContext, contentRect);
}
void TiledDrawingArea::tiledBackingStorePaintEnd(const Vector<IntRect>& paintedArea)
{
if (m_didSendTileUpdate) {
// Since we know that all tile updates following a page invalidate will all be rendered
// in one paint pass for all the tiles, we can send the swap tile message here.
m_webPage->send(Messages::DrawingAreaProxy::DidRenderFrame());
m_isWaitingForUIProcess = true;
m_didSendTileUpdate = false;
// Make sure that we destroy the previous backing store and remove its tiles only after DidRenderFrame
// was sent to swap recently created tiles' buffer. Else a frame could be rendered after the previous
// tiles were removed and before the new tile have their first back buffer swapped.
if (m_previousBackingStore && m_mainBackingStore->coverageRatio(m_visibleContentRect) >= 1.0f)
m_previousBackingStore.clear();
}
}
bool TiledDrawingArea::tiledBackingStoreUpdatesAllowed() const
{
return !m_suspended && !m_isWaitingForUIProcess;
}
IntRect TiledDrawingArea::tiledBackingStoreContentsRect()
{
return IntRect(IntPoint::zero(), m_webPage->size());
}
IntRect TiledDrawingArea::tiledBackingStoreVisibleRect()
{
return m_visibleContentRect;
}
Color TiledDrawingArea::tiledBackingStoreBackgroundColor() const
{
return Color::transparent;
}
void TiledDrawingArea::createTile(int tileID, const UpdateInfo& updateInfo)
{
m_webPage->send(Messages::DrawingAreaProxy::CreateTile(tileID, updateInfo));
m_didSendTileUpdate = true;
}
void TiledDrawingArea::updateTile(int tileID, const UpdateInfo& updateInfo)
{
m_webPage->send(Messages::DrawingAreaProxy::UpdateTile(tileID, updateInfo));
m_didSendTileUpdate = true;
}
void TiledDrawingArea::removeTile(int tileID)
{
m_webPage->send(Messages::DrawingAreaProxy::RemoveTile(tileID));
}
#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
void TiledDrawingArea::didReceiveLayerTreeHostMessage(CoreIPC::Connection* connection, CoreIPC::MessageID, CoreIPC::ArgumentDecoder* arguments)
{
}
#endif
} // namespace WebKit
#endif // USE(TILED_BACKING_STORE)
|