|
Lines 40-57
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec1
|
| 40 |
#include "WebPageProxyMessages.h" |
40 |
#include "WebPageProxyMessages.h" |
| 41 |
#include <WebCore/Frame.h> |
41 |
#include <WebCore/Frame.h> |
| 42 |
#include <WebCore/FrameView.h> |
42 |
#include <WebCore/FrameView.h> |
| 43 |
#include <WebCore/GraphicsSurface.h> |
|
|
| 44 |
#include <WebCore/InspectorController.h> |
| 45 |
#include <WebCore/Page.h> |
| 46 |
#include <WebCore/RenderLayer.h> |
| 47 |
#include <WebCore/RenderLayerBacking.h> |
| 48 |
#include <WebCore/RenderLayerCompositor.h> |
| 49 |
#include <WebCore/RenderView.h> |
| 50 |
#include <WebCore/Settings.h> |
43 |
#include <WebCore/Settings.h> |
| 51 |
#include <WebCore/SurfaceUpdateInfo.h> |
|
|
| 52 |
#include <WebCore/TextureMapperPlatformLayer.h> |
| 53 |
#include <wtf/CurrentTime.h> |
44 |
#include <wtf/CurrentTime.h> |
| 54 |
#include <wtf/TemporaryChange.h> |
|
|
| 55 |
|
45 |
|
| 56 |
#if ENABLE(CSS_SHADERS) |
46 |
#if ENABLE(CSS_SHADERS) |
| 57 |
#include "CustomFilterValidatedProgram.h" |
47 |
#include "CustomFilterValidatedProgram.h" |
|
Lines 72-122
CoordinatedLayerTreeHost::~CoordinatedLayerTreeHost()
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec2
|
| 72 |
#if ENABLE(CSS_SHADERS) |
62 |
#if ENABLE(CSS_SHADERS) |
| 73 |
disconnectCustomFilterPrograms(); |
63 |
disconnectCustomFilterPrograms(); |
| 74 |
#endif |
64 |
#endif |
| 75 |
purgeBackingStores(); |
|
|
| 76 |
|
| 77 |
LayerMap::iterator end = m_registeredLayers.end(); |
| 78 |
for (LayerMap::iterator it = m_registeredLayers.begin(); it != end; ++it) |
| 79 |
it->value->setCoordinator(0); |
| 80 |
} |
65 |
} |
| 81 |
|
66 |
|
| 82 |
CoordinatedLayerTreeHost::CoordinatedLayerTreeHost(WebPage* webPage) |
67 |
CoordinatedLayerTreeHost::CoordinatedLayerTreeHost(WebPage* webPage) |
| 83 |
: LayerTreeHost(webPage) |
68 |
: LayerTreeHost(webPage) |
| 84 |
, m_rootCompositingLayer(0) |
|
|
| 85 |
, m_notifyAfterScheduledLayerFlush(false) |
69 |
, m_notifyAfterScheduledLayerFlush(false) |
| 86 |
, m_isValid(true) |
70 |
, m_isValid(true) |
| 87 |
, m_isPurging(false) |
|
|
| 88 |
, m_isFlushingLayerChanges(false) |
| 89 |
, m_waitingForUIProcess(true) |
| 90 |
, m_isSuspended(false) |
71 |
, m_isSuspended(false) |
| 91 |
, m_shouldSyncFrame(false) |
72 |
, m_isWaitingForRenderer(true) |
| 92 |
, m_didInitializeRootCompositingLayer(false) |
|
|
| 93 |
, m_layerFlushTimer(this, &CoordinatedLayerTreeHost::layerFlushTimerFired) |
73 |
, m_layerFlushTimer(this, &CoordinatedLayerTreeHost::layerFlushTimerFired) |
| 94 |
, m_releaseInactiveAtlasesTimer(this, &CoordinatedLayerTreeHost::releaseInactiveAtlasesTimerFired) |
|
|
| 95 |
, m_layerFlushSchedulingEnabled(true) |
74 |
, m_layerFlushSchedulingEnabled(true) |
| 96 |
, m_forceRepaintAsyncCallbackID(0) |
75 |
, m_forceRepaintAsyncCallbackID(0) |
| 97 |
, m_animationsLocked(false) |
|
|
| 98 |
#if ENABLE(REQUEST_ANIMATION_FRAME) |
| 99 |
, m_lastAnimationServiceTime(0) |
| 100 |
#endif |
| 101 |
{ |
76 |
{ |
| 102 |
m_webPage->corePage()->settings()->setApplyDeviceScaleFactorInCompositor(true); |
77 |
m_coordinator = CompositingCoordinator::create(webPage->corePage(), this); |
| 103 |
|
78 |
|
| 104 |
// Create a root layer. |
79 |
m_coordinator->createRootLayer(webPage->size()); |
| 105 |
m_rootLayer = GraphicsLayer::create(this, this); |
80 |
m_layerTreeContext.coordinatedLayerID = toCoordinatedGraphicsLayer(m_coordinator->rootLayer())->id(); |
| 106 |
#ifndef NDEBUG |
|
|
| 107 |
m_rootLayer->setName("CoordinatedLayerTreeHost root layer"); |
| 108 |
#endif |
| 109 |
m_rootLayer->setDrawsContent(false); |
| 110 |
m_rootLayer->setSize(m_webPage->size()); |
| 111 |
m_layerTreeContext.coordinatedLayerID = toCoordinatedGraphicsLayer(m_rootLayer.get())->id(); |
| 112 |
|
81 |
|
| 113 |
CoordinatedSurface::setFactory(createCoordinatedSurface); |
82 |
CoordinatedSurface::setFactory(createCoordinatedSurface); |
| 114 |
|
83 |
|
| 115 |
// This is a temporary way to enable this only in the GL case, until TextureMapperImageBuffer is removed. |
84 |
if (webPage->hasPageOverlay()) |
| 116 |
// See https://bugs.webkit.org/show_bug.cgi?id=114869 |
|
|
| 117 |
CoordinatedGraphicsLayer::setShouldSupportContentsTiling(true); |
| 118 |
|
| 119 |
if (m_webPage->hasPageOverlay()) |
| 120 |
createPageOverlayLayer(); |
85 |
createPageOverlayLayer(); |
| 121 |
|
86 |
|
| 122 |
scheduleLayerFlush(); |
87 |
scheduleLayerFlush(); |
|
Lines 158-169
void CoordinatedLayerTreeHost::setShouldNotifyAfterNextScheduledLayerFlush(bool
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec3
|
| 158 |
|
123 |
|
| 159 |
void CoordinatedLayerTreeHost::setRootCompositingLayer(WebCore::GraphicsLayer* graphicsLayer) |
124 |
void CoordinatedLayerTreeHost::setRootCompositingLayer(WebCore::GraphicsLayer* graphicsLayer) |
| 160 |
{ |
125 |
{ |
| 161 |
if (m_rootCompositingLayer) |
126 |
m_coordinator->setRootCompositingLayer(graphicsLayer); |
| 162 |
m_rootCompositingLayer->removeFromParent(); |
|
|
| 163 |
|
| 164 |
m_rootCompositingLayer = graphicsLayer; |
| 165 |
if (m_rootCompositingLayer) |
| 166 |
m_rootLayer->addChildAtIndex(m_rootCompositingLayer, 0); |
| 167 |
} |
127 |
} |
| 168 |
|
128 |
|
| 169 |
void CoordinatedLayerTreeHost::invalidate() |
129 |
void CoordinatedLayerTreeHost::invalidate() |
|
Lines 171-177
void CoordinatedLayerTreeHost::invalidate()
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec4
|
| 171 |
cancelPendingLayerFlush(); |
131 |
cancelPendingLayerFlush(); |
| 172 |
|
132 |
|
| 173 |
ASSERT(m_isValid); |
133 |
ASSERT(m_isValid); |
| 174 |
m_rootLayer = nullptr; |
134 |
m_coordinator->clearRootLayer(); |
| 175 |
m_isValid = false; |
135 |
m_isValid = false; |
| 176 |
} |
136 |
} |
| 177 |
|
137 |
|
|
Lines 179-190
void CoordinatedLayerTreeHost::forceRepaint()
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec5
|
| 179 |
{ |
139 |
{ |
| 180 |
// This is necessary for running layout tests. Since in this case we are not waiting for a UIProcess to reply nicely. |
140 |
// This is necessary for running layout tests. Since in this case we are not waiting for a UIProcess to reply nicely. |
| 181 |
// Instead we are just triggering forceRepaint. But we still want to have the scripted animation callbacks being executed. |
141 |
// Instead we are just triggering forceRepaint. But we still want to have the scripted animation callbacks being executed. |
| 182 |
syncDisplayState(); |
142 |
m_coordinator->syncDisplayState(); |
| 183 |
|
143 |
|
| 184 |
// We need to schedule another flush, otherwise the forced paint might cancel a later expected flush. |
144 |
// We need to schedule another flush, otherwise the forced paint might cancel a later expected flush. |
| 185 |
// This is aligned with LayerTreeHostCA. |
145 |
// This is aligned with LayerTreeHostCA. |
| 186 |
scheduleLayerFlush(); |
146 |
scheduleLayerFlush(); |
| 187 |
flushPendingLayerChanges(); |
147 |
m_coordinator->flushPendingLayerChanges(); |
| 188 |
} |
148 |
} |
| 189 |
|
149 |
|
| 190 |
bool CoordinatedLayerTreeHost::forceRepaintAsync(uint64_t callbackID) |
150 |
bool CoordinatedLayerTreeHost::forceRepaintAsync(uint64_t callbackID) |
|
Lines 198-204
bool CoordinatedLayerTreeHost::forceRepaintAsync(uint64_t callbackID)
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec6
|
| 198 |
|
158 |
|
| 199 |
void CoordinatedLayerTreeHost::sizeDidChange(const WebCore::IntSize& newSize) |
159 |
void CoordinatedLayerTreeHost::sizeDidChange(const WebCore::IntSize& newSize) |
| 200 |
{ |
160 |
{ |
| 201 |
m_rootLayer->setSize(newSize); |
161 |
m_coordinator->sizeDidChange(newSize); |
| 202 |
scheduleLayerFlush(); |
162 |
scheduleLayerFlush(); |
| 203 |
} |
163 |
} |
| 204 |
|
164 |
|
|
Lines 233-343
void CoordinatedLayerTreeHost::setPageOverlayOpacity(PageOverlay*, float value)
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec7
|
| 233 |
scheduleLayerFlush(); |
193 |
scheduleLayerFlush(); |
| 234 |
} |
194 |
} |
| 235 |
|
195 |
|
| 236 |
bool CoordinatedLayerTreeHost::flushPendingLayerChanges() |
196 |
void CoordinatedLayerTreeHost::setVisibleContentsRect(const FloatRect& rect, const FloatPoint& trajectoryVector) |
| 237 |
{ |
197 |
{ |
| 238 |
if (m_waitingForUIProcess) |
198 |
m_coordinator->setVisibleContentsRect(rect, trajectoryVector); |
| 239 |
return false; |
199 |
scheduleLayerFlush(); |
| 240 |
|
|
|
| 241 |
TemporaryChange<bool> protector(m_isFlushingLayerChanges, true); |
| 242 |
|
| 243 |
initializeRootCompositingLayerIfNeeded(); |
| 244 |
|
| 245 |
m_rootLayer->flushCompositingStateForThisLayerOnly(); |
| 246 |
if (m_pageOverlayLayer) |
| 247 |
m_pageOverlayLayer->flushCompositingStateForThisLayerOnly(); |
| 248 |
|
| 249 |
bool didSync = m_webPage->corePage()->mainFrame()->view()->flushCompositingStateIncludingSubframes(); |
| 250 |
|
| 251 |
toCoordinatedGraphicsLayer(m_rootLayer.get())->updateContentBuffersIncludingSubLayers(); |
| 252 |
toCoordinatedGraphicsLayer(m_rootLayer.get())->syncPendingStateChangesIncludingSubLayers(); |
| 253 |
|
| 254 |
flushPendingImageBackingChanges(); |
| 255 |
|
| 256 |
if (m_shouldSyncFrame) { |
| 257 |
didSync = true; |
| 258 |
|
| 259 |
if (m_rootCompositingLayer) { |
| 260 |
m_state.contentsSize = roundedIntSize(m_rootCompositingLayer->size()); |
| 261 |
if (CoordinatedGraphicsLayer* contentsLayer = mainContentsLayer()) |
| 262 |
m_state.coveredRect = contentsLayer->coverRect(); |
| 263 |
} |
| 264 |
|
| 265 |
m_state.scrollPosition = m_visibleContentsRect.location(); |
| 266 |
|
| 267 |
m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::CommitCoordinatedGraphicsState(m_state)); |
| 268 |
|
| 269 |
clearPendingStateChanges(); |
| 270 |
m_waitingForUIProcess = true; |
| 271 |
m_shouldSyncFrame = false; |
| 272 |
} |
| 273 |
|
| 274 |
if (m_forceRepaintAsyncCallbackID) { |
| 275 |
m_webPage->send(Messages::WebPageProxy::VoidCallback(m_forceRepaintAsyncCallbackID)); |
| 276 |
m_forceRepaintAsyncCallbackID = 0; |
| 277 |
} |
| 278 |
|
| 279 |
return didSync; |
| 280 |
} |
200 |
} |
| 281 |
|
201 |
|
| 282 |
void CoordinatedLayerTreeHost::clearPendingStateChanges() |
202 |
void CoordinatedLayerTreeHost::renderNextFrame() |
| 283 |
{ |
203 |
{ |
| 284 |
m_state.layersToCreate.clear(); |
204 |
m_coordinator->renderNextFrame(); |
| 285 |
m_state.layersToUpdate.clear(); |
205 |
m_isWaitingForRenderer = false; |
| 286 |
m_state.layersToRemove.clear(); |
206 |
scheduleLayerFlush(); |
| 287 |
|
|
|
| 288 |
m_state.imagesToCreate.clear(); |
| 289 |
m_state.imagesToRemove.clear(); |
| 290 |
m_state.imagesToUpdate.clear(); |
| 291 |
m_state.imagesToClear.clear(); |
| 292 |
|
| 293 |
m_state.updateAtlasesToCreate.clear(); |
| 294 |
m_state.updateAtlasesToRemove.clear(); |
| 295 |
|
| 296 |
#if ENABLE(CSS_SHADERS) |
| 297 |
m_state.customFiltersToCreate.clear(); |
| 298 |
m_state.customFiltersToRemove.clear(); |
| 299 |
#endif |
| 300 |
} |
207 |
} |
| 301 |
|
208 |
|
| 302 |
void CoordinatedLayerTreeHost::initializeRootCompositingLayerIfNeeded() |
209 |
void CoordinatedLayerTreeHost::purgeBackingStores() |
| 303 |
{ |
210 |
{ |
| 304 |
if (m_didInitializeRootCompositingLayer) |
211 |
m_coordinator->purgeBackingStores(); |
| 305 |
return; |
|
|
| 306 |
|
| 307 |
m_state.rootCompositingLayer = toCoordinatedGraphicsLayer(m_rootLayer.get())->id(); |
| 308 |
m_didInitializeRootCompositingLayer = true; |
| 309 |
m_shouldSyncFrame = true; |
| 310 |
} |
212 |
} |
| 311 |
|
213 |
|
| 312 |
void CoordinatedLayerTreeHost::syncLayerState(CoordinatedLayerID id, CoordinatedGraphicsLayerState& state) |
214 |
void CoordinatedLayerTreeHost::willSyncLayerState(CoordinatedGraphicsLayerState& state) |
| 313 |
{ |
215 |
{ |
| 314 |
m_shouldSyncFrame = true; |
|
|
| 315 |
|
| 316 |
#if ENABLE(CSS_SHADERS) |
216 |
#if ENABLE(CSS_SHADERS) |
| 317 |
prepareCustomFilterProxiesIfNeeded(state); |
217 |
if (state.animationsChanged) |
| 318 |
#endif |
218 |
prepareCustomFilterProxiesForAnimations(state.animations); |
| 319 |
|
219 |
|
| 320 |
m_state.layersToUpdate.append(std::make_pair(id, state)); |
220 |
if (state.filtersChanged) |
|
|
221 |
checkCustomFilterProgramProxies(state.filters); |
| 222 |
#else |
| 223 |
UNUSED_PARAM(state); |
| 224 |
#endif |
| 321 |
} |
225 |
} |
| 322 |
|
226 |
|
| 323 |
#if ENABLE(CSS_SHADERS) |
227 |
#if ENABLE(CSS_SHADERS) |
| 324 |
void CoordinatedLayerTreeHost::prepareCustomFilterProxiesIfNeeded(CoordinatedGraphicsLayerState& state) |
228 |
void CoordinatedLayerTreeHost::prepareCustomFilterProxiesForAnimations(GraphicsLayerAnimations& activeAnimations) |
| 325 |
{ |
229 |
{ |
| 326 |
if (state.animationsChanged) { |
230 |
for (size_t i = 0; i < activeAnimations.animations().size(); ++i) { |
| 327 |
GraphicsLayerAnimations& activeAnimations = state.animations; |
231 |
const KeyframeValueList& keyframes = activeAnimations.animations().at(i).keyframes(); |
| 328 |
for (size_t i = 0; i < activeAnimations.animations().size(); ++i) { |
232 |
if (keyframes.property() != AnimatedPropertyWebkitFilter) |
| 329 |
const KeyframeValueList& keyframes = activeAnimations.animations().at(i).keyframes(); |
233 |
continue; |
| 330 |
if (keyframes.property() != AnimatedPropertyWebkitFilter) |
234 |
for (size_t j = 0; j < keyframes.size(); ++j) { |
| 331 |
continue; |
235 |
const FilterAnimationValue& filterValue = static_cast<const FilterAnimationValue&>(keyframes.at(j)); |
| 332 |
for (size_t j = 0; j < keyframes.size(); ++j) { |
236 |
checkCustomFilterProgramProxies(filterValue.value()); |
| 333 |
const FilterAnimationValue& filterValue = static_cast<const FilterAnimationValue&>(keyframes.at(j)); |
|
|
| 334 |
checkCustomFilterProgramProxies(filterValue.value()); |
| 335 |
} |
| 336 |
} |
237 |
} |
| 337 |
} |
238 |
} |
| 338 |
|
|
|
| 339 |
if (state.filtersChanged) |
| 340 |
checkCustomFilterProgramProxies(state.filters); |
| 341 |
} |
239 |
} |
| 342 |
|
240 |
|
| 343 |
void CoordinatedLayerTreeHost::checkCustomFilterProgramProxies(const FilterOperations& filters) |
241 |
void CoordinatedLayerTreeHost::checkCustomFilterProgramProxies(const FilterOperations& filters) |
|
Lines 367-373
void CoordinatedLayerTreeHost::checkCustomFilterProgramProxies(const FilterOpera
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec8
|
| 367 |
if (!customFilterProgramProxy->client()) { |
265 |
if (!customFilterProgramProxy->client()) { |
| 368 |
customFilterProgramProxy->setClient(this); |
266 |
customFilterProgramProxy->setClient(this); |
| 369 |
m_customFilterPrograms.add(customFilterProgramProxy.get()); |
267 |
m_customFilterPrograms.add(customFilterProgramProxy.get()); |
| 370 |
m_state.customFiltersToCreate.append(std::make_pair(customFilterProgramProxy->id(), customOperation->validatedProgram()->validatedProgramInfo())); |
268 |
m_coordinator->state().customFiltersToCreate.append(std::make_pair(customFilterProgramProxy->id(), customOperation->validatedProgram()->validatedProgramInfo())); |
| 371 |
} else { |
269 |
} else { |
| 372 |
// If the client was not disconnected then this coordinator must be the client for it. |
270 |
// If the client was not disconnected then this coordinator must be the client for it. |
| 373 |
ASSERT(customFilterProgramProxy->client() == this); |
271 |
ASSERT(customFilterProgramProxy->client() == this); |
|
Lines 380-386
void CoordinatedLayerTreeHost::removeCustomFilterProgramProxy(WebCustomFilterPro
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec9
|
| 380 |
// At this time the shader is not needed anymore, so we remove it from our set and |
278 |
// At this time the shader is not needed anymore, so we remove it from our set and |
| 381 |
// send a message to the other process to delete it. |
279 |
// send a message to the other process to delete it. |
| 382 |
m_customFilterPrograms.remove(customFilterProgramProxy); |
280 |
m_customFilterPrograms.remove(customFilterProgramProxy); |
| 383 |
m_state.customFiltersToRemove.append(customFilterProgramProxy->id()); |
281 |
m_coordinator->state().customFiltersToRemove.append(customFilterProgramProxy->id()); |
| 384 |
} |
282 |
} |
| 385 |
|
283 |
|
| 386 |
void CoordinatedLayerTreeHost::disconnectCustomFilterPrograms() |
284 |
void CoordinatedLayerTreeHost::disconnectCustomFilterPrograms() |
|
Lines 392-443
void CoordinatedLayerTreeHost::disconnectCustomFilterPrograms()
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec10
|
| 392 |
} |
290 |
} |
| 393 |
#endif // ENABLE(CSS_SHADERS) |
291 |
#endif // ENABLE(CSS_SHADERS) |
| 394 |
|
292 |
|
| 395 |
void CoordinatedLayerTreeHost::detachLayer(CoordinatedGraphicsLayer* layer) |
293 |
void CoordinatedLayerTreeHost::didFlushRootLayer() |
| 396 |
{ |
294 |
{ |
| 397 |
m_registeredLayers.remove(layer->id()); |
295 |
if (m_pageOverlayLayer) |
| 398 |
|
296 |
m_pageOverlayLayer->flushCompositingStateForThisLayerOnly(); |
| 399 |
size_t index = m_state.layersToCreate.find(layer->id()); |
|
|
| 400 |
if (index != notFound) { |
| 401 |
m_state.layersToCreate.remove(index); |
| 402 |
return; |
| 403 |
} |
| 404 |
|
| 405 |
m_state.layersToRemove.append(layer->id()); |
| 406 |
scheduleLayerFlush(); |
| 407 |
} |
297 |
} |
| 408 |
|
298 |
|
| 409 |
void CoordinatedLayerTreeHost::performScheduledLayerFlush() |
299 |
void CoordinatedLayerTreeHost::performScheduledLayerFlush() |
| 410 |
{ |
300 |
{ |
| 411 |
if (m_isSuspended || m_waitingForUIProcess) |
301 |
if (m_isSuspended || m_isWaitingForRenderer) |
| 412 |
return; |
302 |
return; |
| 413 |
|
303 |
|
| 414 |
syncDisplayState(); |
304 |
m_coordinator->syncDisplayState(); |
| 415 |
|
305 |
|
| 416 |
if (!m_isValid) |
306 |
if (!m_isValid) |
| 417 |
return; |
307 |
return; |
| 418 |
|
308 |
|
| 419 |
if (flushPendingLayerChanges()) |
309 |
bool didSync = m_coordinator->flushPendingLayerChanges(); |
| 420 |
didPerformScheduledLayerFlush(); |
|
|
| 421 |
} |
| 422 |
|
| 423 |
void CoordinatedLayerTreeHost::syncDisplayState() |
| 424 |
{ |
| 425 |
#if ENABLE(INSPECTOR) |
| 426 |
m_webPage->corePage()->inspectorController()->didBeginFrame(); |
| 427 |
#endif |
| 428 |
|
| 429 |
#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER) && !USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) |
| 430 |
// Make sure that any previously registered animation callbacks are being executed before we flush the layers. |
| 431 |
m_lastAnimationServiceTime = WTF::monotonicallyIncreasingTime(); |
| 432 |
m_webPage->corePage()->mainFrame()->view()->serviceScriptedAnimations(m_lastAnimationServiceTime); |
| 433 |
#endif |
| 434 |
|
310 |
|
| 435 |
m_webPage->layoutIfNeeded(); |
311 |
if (m_forceRepaintAsyncCallbackID) { |
| 436 |
} |
312 |
m_webPage->send(Messages::WebPageProxy::VoidCallback(m_forceRepaintAsyncCallbackID)); |
|
|
313 |
m_forceRepaintAsyncCallbackID = 0; |
| 314 |
} |
| 437 |
|
315 |
|
| 438 |
void CoordinatedLayerTreeHost::didPerformScheduledLayerFlush() |
316 |
if (m_notifyAfterScheduledLayerFlush && didSync) { |
| 439 |
{ |
|
|
| 440 |
if (m_notifyAfterScheduledLayerFlush) { |
| 441 |
static_cast<DrawingAreaImpl*>(m_webPage->drawingArea())->layerHostDidFlushLayers(); |
317 |
static_cast<DrawingAreaImpl*>(m_webPage->drawingArea())->layerHostDidFlushLayers(); |
| 442 |
m_notifyAfterScheduledLayerFlush = false; |
318 |
m_notifyAfterScheduledLayerFlush = false; |
| 443 |
} |
319 |
} |
|
Lines 452-466
void CoordinatedLayerTreeHost::createPageOverlayLayer()
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec11
|
| 452 |
{ |
328 |
{ |
| 453 |
ASSERT(!m_pageOverlayLayer); |
329 |
ASSERT(!m_pageOverlayLayer); |
| 454 |
|
330 |
|
| 455 |
m_pageOverlayLayer = GraphicsLayer::create(this, this); |
331 |
m_pageOverlayLayer = GraphicsLayer::create(graphicsLayerFactory(), m_coordinator.get()); |
| 456 |
#ifndef NDEBUG |
332 |
#ifndef NDEBUG |
| 457 |
m_pageOverlayLayer->setName("CoordinatedLayerTreeHost page overlay content"); |
333 |
m_pageOverlayLayer->setName("CompositingCoordinator page overlay content"); |
| 458 |
#endif |
334 |
#endif |
| 459 |
|
335 |
|
| 460 |
m_pageOverlayLayer->setDrawsContent(true); |
336 |
m_pageOverlayLayer->setDrawsContent(true); |
| 461 |
m_pageOverlayLayer->setSize(m_webPage->size()); |
337 |
m_pageOverlayLayer->setSize(m_coordinator->rootLayer()->size()); |
| 462 |
|
338 |
|
| 463 |
m_rootLayer->addChild(m_pageOverlayLayer.get()); |
339 |
m_coordinator->rootLayer()->addChild(m_pageOverlayLayer.get()); |
| 464 |
} |
340 |
} |
| 465 |
|
341 |
|
| 466 |
void CoordinatedLayerTreeHost::destroyPageOverlayLayer() |
342 |
void CoordinatedLayerTreeHost::destroyPageOverlayLayer() |
|
Lines 470-534
void CoordinatedLayerTreeHost::destroyPageOverlayLayer()
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec12
|
| 470 |
m_pageOverlayLayer = nullptr; |
346 |
m_pageOverlayLayer = nullptr; |
| 471 |
} |
347 |
} |
| 472 |
|
348 |
|
| 473 |
PassRefPtr<CoordinatedImageBacking> CoordinatedLayerTreeHost::createImageBackingIfNeeded(Image* image) |
349 |
void CoordinatedLayerTreeHost::paintLayerContents(const GraphicsLayer* graphicsLayer, GraphicsContext& graphicsContext, const IntRect& clipRect) |
| 474 |
{ |
|
|
| 475 |
CoordinatedImageBackingID imageID = CoordinatedImageBacking::getCoordinatedImageBackingID(image); |
| 476 |
ImageBackingMap::iterator it = m_imageBackings.find(imageID); |
| 477 |
RefPtr<CoordinatedImageBacking> imageBacking; |
| 478 |
if (it == m_imageBackings.end()) { |
| 479 |
imageBacking = CoordinatedImageBacking::create(this, image); |
| 480 |
m_imageBackings.add(imageID, imageBacking); |
| 481 |
} else |
| 482 |
imageBacking = it->value; |
| 483 |
|
| 484 |
return imageBacking; |
| 485 |
} |
| 486 |
|
| 487 |
void CoordinatedLayerTreeHost::createImageBacking(CoordinatedImageBackingID imageID) |
| 488 |
{ |
| 489 |
m_state.imagesToCreate.append(imageID); |
| 490 |
} |
| 491 |
|
| 492 |
void CoordinatedLayerTreeHost::updateImageBacking(CoordinatedImageBackingID imageID, PassRefPtr<CoordinatedSurface> coordinatedSurface) |
| 493 |
{ |
| 494 |
m_shouldSyncFrame = true; |
| 495 |
m_state.imagesToUpdate.append(std::make_pair(imageID, coordinatedSurface)); |
| 496 |
} |
| 497 |
|
| 498 |
void CoordinatedLayerTreeHost::clearImageBackingContents(CoordinatedImageBackingID imageID) |
| 499 |
{ |
| 500 |
m_shouldSyncFrame = true; |
| 501 |
m_state.imagesToClear.append(imageID); |
| 502 |
} |
| 503 |
|
| 504 |
void CoordinatedLayerTreeHost::removeImageBacking(CoordinatedImageBackingID imageID) |
| 505 |
{ |
| 506 |
if (m_isPurging) |
| 507 |
return; |
| 508 |
|
| 509 |
ASSERT(m_imageBackings.contains(imageID)); |
| 510 |
m_imageBackings.remove(imageID); |
| 511 |
|
| 512 |
m_state.imagesToRemove.append(imageID); |
| 513 |
} |
| 514 |
|
| 515 |
void CoordinatedLayerTreeHost::flushPendingImageBackingChanges() |
| 516 |
{ |
| 517 |
ImageBackingMap::iterator end = m_imageBackings.end(); |
| 518 |
for (ImageBackingMap::iterator iter = m_imageBackings.begin(); iter != end; ++iter) |
| 519 |
iter->value->update(); |
| 520 |
} |
| 521 |
|
| 522 |
void CoordinatedLayerTreeHost::notifyAnimationStarted(const WebCore::GraphicsLayer*, double /* time */) |
| 523 |
{ |
| 524 |
} |
| 525 |
|
| 526 |
void CoordinatedLayerTreeHost::notifyFlushRequired(const WebCore::GraphicsLayer*) |
| 527 |
{ |
| 528 |
scheduleLayerFlush(); |
| 529 |
} |
| 530 |
|
| 531 |
void CoordinatedLayerTreeHost::paintContents(const WebCore::GraphicsLayer* graphicsLayer, WebCore::GraphicsContext& graphicsContext, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect) |
| 532 |
{ |
350 |
{ |
| 533 |
if (graphicsLayer == m_pageOverlayLayer) { |
351 |
if (graphicsLayer == m_pageOverlayLayer) { |
| 534 |
// Overlays contain transparent contents and won't clear the context as part of their rendering, so we do it here. |
352 |
// Overlays contain transparent contents and won't clear the context as part of their rendering, so we do it here. |
|
Lines 538-552
void CoordinatedLayerTreeHost::paintContents(const WebCore::GraphicsLayer* graph
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec13
|
| 538 |
} |
356 |
} |
| 539 |
} |
357 |
} |
| 540 |
|
358 |
|
| 541 |
PassOwnPtr<GraphicsLayer> CoordinatedLayerTreeHost::createGraphicsLayer(GraphicsLayerClient* client) |
359 |
void CoordinatedLayerTreeHost::commitSceneState(WebCore::CoordinatedGraphicsState& state) |
| 542 |
{ |
360 |
{ |
| 543 |
CoordinatedGraphicsLayer* layer = new CoordinatedGraphicsLayer(client); |
361 |
m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::CommitCoordinatedGraphicsState(state)); |
| 544 |
layer->setCoordinator(this); |
362 |
m_isWaitingForRenderer = true; |
| 545 |
m_registeredLayers.add(layer->id(), layer); |
|
|
| 546 |
m_state.layersToCreate.append(layer->id()); |
| 547 |
layer->setNeedsVisibleRectAdjustment(); |
| 548 |
scheduleLayerFlush(); |
| 549 |
return adoptPtr(layer); |
| 550 |
} |
363 |
} |
| 551 |
|
364 |
|
| 552 |
PassRefPtr<CoordinatedSurface> CoordinatedLayerTreeHost::createCoordinatedSurface(const IntSize& size, CoordinatedSurface::Flags flags) |
365 |
PassRefPtr<CoordinatedSurface> CoordinatedLayerTreeHost::createCoordinatedSurface(const IntSize& size, CoordinatedSurface::Flags flags) |
|
Lines 554-626
PassRefPtr<CoordinatedSurface> CoordinatedLayerTreeHost::createCoordinatedSurfac
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec14
|
| 554 |
return WebCoordinatedSurface::create(size, flags); |
367 |
return WebCoordinatedSurface::create(size, flags); |
| 555 |
} |
368 |
} |
| 556 |
|
369 |
|
| 557 |
float CoordinatedLayerTreeHost::deviceScaleFactor() const |
|
|
| 558 |
{ |
| 559 |
return m_webPage->deviceScaleFactor(); |
| 560 |
} |
| 561 |
|
| 562 |
float CoordinatedLayerTreeHost::pageScaleFactor() const |
| 563 |
{ |
| 564 |
return m_webPage->pageScaleFactor(); |
| 565 |
} |
| 566 |
|
| 567 |
bool LayerTreeHost::supportsAcceleratedCompositing() |
370 |
bool LayerTreeHost::supportsAcceleratedCompositing() |
| 568 |
{ |
371 |
{ |
| 569 |
return true; |
372 |
return true; |
| 570 |
} |
373 |
} |
| 571 |
|
374 |
|
| 572 |
void CoordinatedLayerTreeHost::createUpdateAtlas(uint32_t atlasID, PassRefPtr<CoordinatedSurface> coordinatedSurface) |
|
|
| 573 |
{ |
| 574 |
m_state.updateAtlasesToCreate.append(std::make_pair(atlasID, coordinatedSurface)); |
| 575 |
} |
| 576 |
|
| 577 |
void CoordinatedLayerTreeHost::removeUpdateAtlas(uint32_t atlasID) |
| 578 |
{ |
| 579 |
if (m_isPurging) |
| 580 |
return; |
| 581 |
m_state.updateAtlasesToRemove.append(atlasID); |
| 582 |
} |
| 583 |
|
| 584 |
WebCore::FloatRect CoordinatedLayerTreeHost::visibleContentsRect() const |
| 585 |
{ |
| 586 |
return m_visibleContentsRect; |
| 587 |
} |
| 588 |
|
| 589 |
CoordinatedGraphicsLayer* CoordinatedLayerTreeHost::mainContentsLayer() |
| 590 |
{ |
| 591 |
if (!m_rootCompositingLayer) |
| 592 |
return 0; |
| 593 |
|
| 594 |
return toCoordinatedGraphicsLayer(m_rootCompositingLayer)->findFirstDescendantWithContentsRecursively(); |
| 595 |
} |
| 596 |
|
| 597 |
void CoordinatedLayerTreeHost::setVisibleContentsRect(const FloatRect& rect, const FloatPoint& trajectoryVector) |
| 598 |
{ |
| 599 |
// A zero trajectoryVector indicates that tiles all around the viewport are requested. |
| 600 |
if (CoordinatedGraphicsLayer* contentsLayer = mainContentsLayer()) |
| 601 |
contentsLayer->setVisibleContentRectTrajectoryVector(trajectoryVector); |
| 602 |
|
| 603 |
bool contentsRectDidChange = rect != m_visibleContentsRect; |
| 604 |
if (contentsRectDidChange) { |
| 605 |
m_visibleContentsRect = rect; |
| 606 |
|
| 607 |
LayerMap::iterator end = m_registeredLayers.end(); |
| 608 |
for (LayerMap::iterator it = m_registeredLayers.begin(); it != end; ++it) { |
| 609 |
it->value->setNeedsVisibleRectAdjustment(); |
| 610 |
} |
| 611 |
} |
| 612 |
|
| 613 |
scheduleLayerFlush(); |
| 614 |
if (m_webPage->useFixedLayout()) { |
| 615 |
// Round the rect instead of enclosing it to make sure that its size stays |
| 616 |
// the same while panning. This can have nasty effects on layout. |
| 617 |
m_webPage->setFixedVisibleContentRect(roundedIntRect(rect)); |
| 618 |
} |
| 619 |
} |
| 620 |
|
| 621 |
void CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged() |
375 |
void CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged() |
| 622 |
{ |
376 |
{ |
| 623 |
m_rootLayer->deviceOrPageScaleFactorChanged(); |
377 |
m_coordinator->deviceOrPageScaleFactorChanged(); |
| 624 |
if (m_pageOverlayLayer) |
378 |
if (m_pageOverlayLayer) |
| 625 |
m_pageOverlayLayer->deviceOrPageScaleFactorChanged(); |
379 |
m_pageOverlayLayer->deviceOrPageScaleFactorChanged(); |
| 626 |
} |
380 |
} |
|
Lines 631-725
void CoordinatedLayerTreeHost::pageBackgroundTransparencyChanged()
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec15
|
| 631 |
|
385 |
|
| 632 |
GraphicsLayerFactory* CoordinatedLayerTreeHost::graphicsLayerFactory() |
386 |
GraphicsLayerFactory* CoordinatedLayerTreeHost::graphicsLayerFactory() |
| 633 |
{ |
387 |
{ |
| 634 |
return this; |
388 |
return m_coordinator.get(); |
| 635 |
} |
389 |
} |
| 636 |
|
390 |
|
| 637 |
#if ENABLE(REQUEST_ANIMATION_FRAME) |
391 |
#if ENABLE(REQUEST_ANIMATION_FRAME) |
| 638 |
void CoordinatedLayerTreeHost::scheduleAnimation() |
392 |
void CoordinatedLayerTreeHost::scheduleAnimation() |
| 639 |
{ |
393 |
{ |
| 640 |
if (m_waitingForUIProcess) |
394 |
if (m_isWaitingForRenderer) |
| 641 |
return; |
395 |
return; |
| 642 |
|
396 |
|
| 643 |
if (m_layerFlushTimer.isActive()) |
397 |
if (m_layerFlushTimer.isActive()) |
| 644 |
return; |
398 |
return; |
| 645 |
|
399 |
|
| 646 |
// According to the requestAnimationFrame spec, rAF callbacks should not be faster than 60FPS. |
400 |
m_layerFlushTimer.startOneShot(m_coordinator->nextAnimationServiceTime()); |
| 647 |
static const double MinimalTimeoutForAnimations = 1. / 60.; |
|
|
| 648 |
m_layerFlushTimer.startOneShot(std::max<double>(0., MinimalTimeoutForAnimations - WTF::monotonicallyIncreasingTime() + m_lastAnimationServiceTime)); |
| 649 |
scheduleLayerFlush(); |
401 |
scheduleLayerFlush(); |
| 650 |
} |
402 |
} |
| 651 |
#endif |
403 |
#endif |
| 652 |
|
404 |
|
| 653 |
void CoordinatedLayerTreeHost::renderNextFrame() |
|
|
| 654 |
{ |
| 655 |
m_waitingForUIProcess = false; |
| 656 |
scheduleLayerFlush(); |
| 657 |
for (unsigned i = 0; i < m_updateAtlases.size(); ++i) |
| 658 |
m_updateAtlases[i]->didSwapBuffers(); |
| 659 |
} |
| 660 |
|
| 661 |
void CoordinatedLayerTreeHost::purgeBackingStores() |
| 662 |
{ |
| 663 |
TemporaryChange<bool> purgingToggle(m_isPurging, true); |
| 664 |
|
| 665 |
LayerMap::iterator end = m_registeredLayers.end(); |
| 666 |
for (LayerMap::iterator it = m_registeredLayers.begin(); it != end; ++it) |
| 667 |
it->value->purgeBackingStores(); |
| 668 |
|
| 669 |
m_imageBackings.clear(); |
| 670 |
m_updateAtlases.clear(); |
| 671 |
} |
| 672 |
|
| 673 |
bool CoordinatedLayerTreeHost::paintToSurface(const IntSize& size, CoordinatedSurface::Flags flags, uint32_t& atlasID, IntPoint& offset, CoordinatedSurface::Client* client) |
| 674 |
{ |
| 675 |
for (unsigned i = 0; i < m_updateAtlases.size(); ++i) { |
| 676 |
UpdateAtlas* atlas = m_updateAtlases[i].get(); |
| 677 |
if (atlas->supportsAlpha() == (flags & CoordinatedSurface::SupportsAlpha)) { |
| 678 |
// This will false if there is no available buffer space. |
| 679 |
if (atlas->paintOnAvailableBuffer(size, atlasID, offset, client)) |
| 680 |
return true; |
| 681 |
} |
| 682 |
} |
| 683 |
|
| 684 |
static const int ScratchBufferDimension = 1024; // Should be a power of two. |
| 685 |
m_updateAtlases.append(adoptPtr(new UpdateAtlas(this, ScratchBufferDimension, flags))); |
| 686 |
scheduleReleaseInactiveAtlases(); |
| 687 |
return m_updateAtlases.last()->paintOnAvailableBuffer(size, atlasID, offset, client); |
| 688 |
} |
| 689 |
|
| 690 |
const double ReleaseInactiveAtlasesTimerInterval = 0.5; |
| 691 |
|
| 692 |
void CoordinatedLayerTreeHost::scheduleReleaseInactiveAtlases() |
| 693 |
{ |
| 694 |
if (!m_releaseInactiveAtlasesTimer.isActive()) |
| 695 |
m_releaseInactiveAtlasesTimer.startRepeating(ReleaseInactiveAtlasesTimerInterval); |
| 696 |
} |
| 697 |
|
| 698 |
void CoordinatedLayerTreeHost::releaseInactiveAtlasesTimerFired(Timer<CoordinatedLayerTreeHost>*) |
| 699 |
{ |
| 700 |
// We always want to keep one atlas for non-composited content. |
| 701 |
OwnPtr<UpdateAtlas> atlasToKeepAnyway; |
| 702 |
bool foundActiveAtlasForNonCompositedContent = false; |
| 703 |
for (int i = m_updateAtlases.size() - 1; i >= 0; --i) { |
| 704 |
UpdateAtlas* atlas = m_updateAtlases[i].get(); |
| 705 |
if (!atlas->isInUse()) |
| 706 |
atlas->addTimeInactive(ReleaseInactiveAtlasesTimerInterval); |
| 707 |
bool usableForNonCompositedContent = !atlas->supportsAlpha(); |
| 708 |
if (atlas->isInactive()) { |
| 709 |
if (!foundActiveAtlasForNonCompositedContent && !atlasToKeepAnyway && usableForNonCompositedContent) |
| 710 |
atlasToKeepAnyway = m_updateAtlases[i].release(); |
| 711 |
m_updateAtlases.remove(i); |
| 712 |
} else if (usableForNonCompositedContent) |
| 713 |
foundActiveAtlasForNonCompositedContent = true; |
| 714 |
} |
| 715 |
|
| 716 |
if (!foundActiveAtlasForNonCompositedContent && atlasToKeepAnyway) |
| 717 |
m_updateAtlases.append(atlasToKeepAnyway.release()); |
| 718 |
|
| 719 |
if (m_updateAtlases.size() <= 1) |
| 720 |
m_releaseInactiveAtlasesTimer.stop(); |
| 721 |
} |
| 722 |
|
| 723 |
void CoordinatedLayerTreeHost::setBackgroundColor(const WebCore::Color& color) |
405 |
void CoordinatedLayerTreeHost::setBackgroundColor(const WebCore::Color& color) |
| 724 |
{ |
406 |
{ |
| 725 |
m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::SetBackgroundColor(color)); |
407 |
m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::SetBackgroundColor(color)); |
|
Lines 727-737
void CoordinatedLayerTreeHost::setBackgroundColor(const WebCore::Color& color)
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec16
|
| 727 |
|
409 |
|
| 728 |
void CoordinatedLayerTreeHost::commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) |
410 |
void CoordinatedLayerTreeHost::commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) |
| 729 |
{ |
411 |
{ |
| 730 |
LayerMap::iterator i = m_registeredLayers.find(layerID); |
412 |
m_coordinator->commitScrollOffset(layerID, offset); |
| 731 |
if (i == m_registeredLayers.end()) |
|
|
| 732 |
return; |
| 733 |
|
| 734 |
i->value->commitScrollOffset(offset); |
| 735 |
} |
413 |
} |
| 736 |
|
414 |
|
| 737 |
} // namespace WebKit |
415 |
} // namespace WebKit |