|
Lines 40-47
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> |
| 43 |
#include <WebCore/Settings.h> |
50 |
#include <WebCore/Settings.h> |
|
|
51 |
#include <WebCore/SurfaceUpdateInfo.h> |
| 52 |
#include <WebCore/TextureMapperPlatformLayer.h> |
| 44 |
#include <wtf/CurrentTime.h> |
53 |
#include <wtf/CurrentTime.h> |
|
|
54 |
#include <wtf/TemporaryChange.h> |
| 45 |
|
55 |
|
| 46 |
#if ENABLE(CSS_SHADERS) |
56 |
#if ENABLE(CSS_SHADERS) |
| 47 |
#include "CustomFilterValidatedProgram.h" |
57 |
#include "CustomFilterValidatedProgram.h" |
|
Lines 62-87
CoordinatedLayerTreeHost::~CoordinatedLayerTreeHost()
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec2
|
| 62 |
#if ENABLE(CSS_SHADERS) |
72 |
#if ENABLE(CSS_SHADERS) |
| 63 |
disconnectCustomFilterPrograms(); |
73 |
disconnectCustomFilterPrograms(); |
| 64 |
#endif |
74 |
#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); |
| 65 |
} |
80 |
} |
| 66 |
|
81 |
|
| 67 |
CoordinatedLayerTreeHost::CoordinatedLayerTreeHost(WebPage* webPage) |
82 |
CoordinatedLayerTreeHost::CoordinatedLayerTreeHost(WebPage* webPage) |
| 68 |
: LayerTreeHost(webPage) |
83 |
: LayerTreeHost(webPage) |
|
|
84 |
, m_rootCompositingLayer(0) |
| 69 |
, m_notifyAfterScheduledLayerFlush(false) |
85 |
, m_notifyAfterScheduledLayerFlush(false) |
| 70 |
, m_isValid(true) |
86 |
, m_isValid(true) |
|
|
87 |
, m_isPurging(false) |
| 88 |
, m_isFlushingLayerChanges(false) |
| 89 |
, m_waitingForUIProcess(true) |
| 71 |
, m_isSuspended(false) |
90 |
, m_isSuspended(false) |
| 72 |
, m_isWaitingForRenderer(true) |
91 |
, m_shouldSyncFrame(false) |
|
|
92 |
, m_didInitializeRootCompositingLayer(false) |
| 73 |
, m_layerFlushTimer(this, &CoordinatedLayerTreeHost::layerFlushTimerFired) |
93 |
, m_layerFlushTimer(this, &CoordinatedLayerTreeHost::layerFlushTimerFired) |
|
|
94 |
, m_releaseInactiveAtlasesTimer(this, &CoordinatedLayerTreeHost::releaseInactiveAtlasesTimerFired) |
| 74 |
, m_layerFlushSchedulingEnabled(true) |
95 |
, m_layerFlushSchedulingEnabled(true) |
| 75 |
, m_forceRepaintAsyncCallbackID(0) |
96 |
, m_forceRepaintAsyncCallbackID(0) |
|
|
97 |
, m_animationsLocked(false) |
| 98 |
#if ENABLE(REQUEST_ANIMATION_FRAME) |
| 99 |
, m_lastAnimationServiceTime(0) |
| 100 |
#endif |
| 76 |
{ |
101 |
{ |
| 77 |
m_coordinator = CompositingCoordinator::create(webPage->corePage(), this); |
102 |
m_webPage->corePage()->settings()->setApplyDeviceScaleFactorInCompositor(true); |
| 78 |
|
103 |
|
| 79 |
m_coordinator->createRootLayer(webPage->size()); |
104 |
// Create a root layer. |
| 80 |
m_layerTreeContext.coordinatedLayerID = toCoordinatedGraphicsLayer(m_coordinator->rootLayer())->id(); |
105 |
m_rootLayer = GraphicsLayer::create(this, this); |
|
|
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(); |
| 81 |
|
112 |
|
| 82 |
CoordinatedSurface::setFactory(createCoordinatedSurface); |
113 |
CoordinatedSurface::setFactory(createCoordinatedSurface); |
| 83 |
|
114 |
|
| 84 |
if (webPage->hasPageOverlay()) |
115 |
// This is a temporary way to enable this only in the GL case, until TextureMapperImageBuffer is removed. |
|
|
116 |
// See https://bugs.webkit.org/show_bug.cgi?id=114869 |
| 117 |
CoordinatedGraphicsLayer::setShouldSupportContentsTiling(true); |
| 118 |
|
| 119 |
if (m_webPage->hasPageOverlay()) |
| 85 |
createPageOverlayLayer(); |
120 |
createPageOverlayLayer(); |
| 86 |
|
121 |
|
| 87 |
scheduleLayerFlush(); |
122 |
scheduleLayerFlush(); |
|
Lines 123-129
void CoordinatedLayerTreeHost::setShouldNotifyAfterNextScheduledLayerFlush(bool
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec3
|
| 123 |
|
158 |
|
| 124 |
void CoordinatedLayerTreeHost::setRootCompositingLayer(WebCore::GraphicsLayer* graphicsLayer) |
159 |
void CoordinatedLayerTreeHost::setRootCompositingLayer(WebCore::GraphicsLayer* graphicsLayer) |
| 125 |
{ |
160 |
{ |
| 126 |
m_coordinator->setRootCompositingLayer(graphicsLayer); |
161 |
if (m_rootCompositingLayer) |
|
|
162 |
m_rootCompositingLayer->removeFromParent(); |
| 163 |
|
| 164 |
m_rootCompositingLayer = graphicsLayer; |
| 165 |
if (m_rootCompositingLayer) |
| 166 |
m_rootLayer->addChildAtIndex(m_rootCompositingLayer, 0); |
| 127 |
} |
167 |
} |
| 128 |
|
168 |
|
| 129 |
void CoordinatedLayerTreeHost::invalidate() |
169 |
void CoordinatedLayerTreeHost::invalidate() |
|
Lines 131-137
void CoordinatedLayerTreeHost::invalidate()
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec4
|
| 131 |
cancelPendingLayerFlush(); |
171 |
cancelPendingLayerFlush(); |
| 132 |
|
172 |
|
| 133 |
ASSERT(m_isValid); |
173 |
ASSERT(m_isValid); |
| 134 |
m_coordinator->clearRootLayer(); |
174 |
m_rootLayer = nullptr; |
| 135 |
m_isValid = false; |
175 |
m_isValid = false; |
| 136 |
} |
176 |
} |
| 137 |
|
177 |
|
|
Lines 139-150
void CoordinatedLayerTreeHost::forceRepaint()
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec5
|
| 139 |
{ |
179 |
{ |
| 140 |
// This is necessary for running layout tests. Since in this case we are not waiting for a UIProcess to reply nicely. |
180 |
// This is necessary for running layout tests. Since in this case we are not waiting for a UIProcess to reply nicely. |
| 141 |
// Instead we are just triggering forceRepaint. But we still want to have the scripted animation callbacks being executed. |
181 |
// Instead we are just triggering forceRepaint. But we still want to have the scripted animation callbacks being executed. |
| 142 |
m_coordinator->syncDisplayState(); |
182 |
syncDisplayState(); |
| 143 |
|
183 |
|
| 144 |
// We need to schedule another flush, otherwise the forced paint might cancel a later expected flush. |
184 |
// We need to schedule another flush, otherwise the forced paint might cancel a later expected flush. |
| 145 |
// This is aligned with LayerTreeHostCA. |
185 |
// This is aligned with LayerTreeHostCA. |
| 146 |
scheduleLayerFlush(); |
186 |
scheduleLayerFlush(); |
| 147 |
m_coordinator->flushPendingLayerChanges(); |
187 |
flushPendingLayerChanges(); |
| 148 |
} |
188 |
} |
| 149 |
|
189 |
|
| 150 |
bool CoordinatedLayerTreeHost::forceRepaintAsync(uint64_t callbackID) |
190 |
bool CoordinatedLayerTreeHost::forceRepaintAsync(uint64_t callbackID) |
|
Lines 158-164
bool CoordinatedLayerTreeHost::forceRepaintAsync(uint64_t callbackID)
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec6
|
| 158 |
|
198 |
|
| 159 |
void CoordinatedLayerTreeHost::sizeDidChange(const WebCore::IntSize& newSize) |
199 |
void CoordinatedLayerTreeHost::sizeDidChange(const WebCore::IntSize& newSize) |
| 160 |
{ |
200 |
{ |
| 161 |
m_coordinator->sizeDidChange(newSize); |
201 |
m_rootLayer->setSize(newSize); |
| 162 |
scheduleLayerFlush(); |
202 |
scheduleLayerFlush(); |
| 163 |
} |
203 |
} |
| 164 |
|
204 |
|
|
Lines 193-241
void CoordinatedLayerTreeHost::setPageOverlayOpacity(PageOverlay*, float value)
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec7
|
| 193 |
scheduleLayerFlush(); |
233 |
scheduleLayerFlush(); |
| 194 |
} |
234 |
} |
| 195 |
|
235 |
|
| 196 |
void CoordinatedLayerTreeHost::setVisibleContentsRect(const FloatRect& rect, const FloatPoint& trajectoryVector) |
236 |
bool CoordinatedLayerTreeHost::flushPendingLayerChanges() |
| 197 |
{ |
237 |
{ |
| 198 |
m_coordinator->setVisibleContentsRect(rect, trajectoryVector); |
238 |
if (m_waitingForUIProcess) |
| 199 |
scheduleLayerFlush(); |
239 |
return false; |
|
|
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; |
| 200 |
} |
280 |
} |
| 201 |
|
281 |
|
| 202 |
void CoordinatedLayerTreeHost::renderNextFrame() |
282 |
void CoordinatedLayerTreeHost::clearPendingStateChanges() |
| 203 |
{ |
283 |
{ |
| 204 |
m_coordinator->renderNextFrame(); |
284 |
m_state.layersToCreate.clear(); |
| 205 |
m_isWaitingForRenderer = false; |
285 |
m_state.layersToUpdate.clear(); |
| 206 |
scheduleLayerFlush(); |
286 |
m_state.layersToRemove.clear(); |
|
|
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 |
| 207 |
} |
300 |
} |
| 208 |
|
301 |
|
| 209 |
void CoordinatedLayerTreeHost::purgeBackingStores() |
302 |
void CoordinatedLayerTreeHost::initializeRootCompositingLayerIfNeeded() |
| 210 |
{ |
303 |
{ |
| 211 |
m_coordinator->purgeBackingStores(); |
304 |
if (m_didInitializeRootCompositingLayer) |
|
|
305 |
return; |
| 306 |
|
| 307 |
m_state.rootCompositingLayer = toCoordinatedGraphicsLayer(m_rootLayer.get())->id(); |
| 308 |
m_didInitializeRootCompositingLayer = true; |
| 309 |
m_shouldSyncFrame = true; |
| 212 |
} |
310 |
} |
| 213 |
|
311 |
|
| 214 |
void CoordinatedLayerTreeHost::willSyncLayerState(CoordinatedGraphicsLayerState& state) |
312 |
void CoordinatedLayerTreeHost::syncLayerState(CoordinatedLayerID id, CoordinatedGraphicsLayerState& state) |
| 215 |
{ |
313 |
{ |
| 216 |
#if ENABLE(CSS_SHADERS) |
314 |
m_shouldSyncFrame = true; |
| 217 |
if (state.animationsChanged) |
|
|
| 218 |
prepareCustomFilterProxiesForAnimations(state.animations); |
| 219 |
|
315 |
|
| 220 |
if (state.filtersChanged) |
316 |
#if ENABLE(CSS_SHADERS) |
| 221 |
checkCustomFilterProgramProxies(state.filters); |
317 |
prepareCustomFilterProxiesIfNeeded(state); |
| 222 |
#else |
|
|
| 223 |
UNUSED_PARAM(state); |
| 224 |
#endif |
318 |
#endif |
|
|
319 |
|
| 320 |
m_state.layersToUpdate.append(std::make_pair(id, state)); |
| 225 |
} |
321 |
} |
| 226 |
|
322 |
|
| 227 |
#if ENABLE(CSS_SHADERS) |
323 |
#if ENABLE(CSS_SHADERS) |
| 228 |
void CoordinatedLayerTreeHost::prepareCustomFilterProxiesForAnimations(GraphicsLayerAnimations& activeAnimations) |
324 |
void CoordinatedLayerTreeHost::prepareCustomFilterProxiesIfNeeded(CoordinatedGraphicsLayerState& state) |
| 229 |
{ |
325 |
{ |
| 230 |
for (size_t i = 0; i < activeAnimations.animations().size(); ++i) { |
326 |
if (state.animationsChanged) { |
| 231 |
const KeyframeValueList& keyframes = activeAnimations.animations().at(i).keyframes(); |
327 |
GraphicsLayerAnimations& activeAnimations = state.animations; |
| 232 |
if (keyframes.property() != AnimatedPropertyWebkitFilter) |
328 |
for (size_t i = 0; i < activeAnimations.animations().size(); ++i) { |
| 233 |
continue; |
329 |
const KeyframeValueList& keyframes = activeAnimations.animations().at(i).keyframes(); |
| 234 |
for (size_t j = 0; j < keyframes.size(); ++j) { |
330 |
if (keyframes.property() != AnimatedPropertyWebkitFilter) |
| 235 |
const FilterAnimationValue& filterValue = static_cast<const FilterAnimationValue&>(keyframes.at(j)); |
331 |
continue; |
| 236 |
checkCustomFilterProgramProxies(filterValue.value()); |
332 |
for (size_t j = 0; j < keyframes.size(); ++j) { |
|
|
333 |
const FilterAnimationValue& filterValue = static_cast<const FilterAnimationValue&>(keyframes.at(j)); |
| 334 |
checkCustomFilterProgramProxies(filterValue.value()); |
| 335 |
} |
| 237 |
} |
336 |
} |
| 238 |
} |
337 |
} |
|
|
338 |
|
| 339 |
if (state.filtersChanged) |
| 340 |
checkCustomFilterProgramProxies(state.filters); |
| 239 |
} |
341 |
} |
| 240 |
|
342 |
|
| 241 |
void CoordinatedLayerTreeHost::checkCustomFilterProgramProxies(const FilterOperations& filters) |
343 |
void CoordinatedLayerTreeHost::checkCustomFilterProgramProxies(const FilterOperations& filters) |
|
Lines 265-271
void CoordinatedLayerTreeHost::checkCustomFilterProgramProxies(const FilterOpera
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec8
|
| 265 |
if (!customFilterProgramProxy->client()) { |
367 |
if (!customFilterProgramProxy->client()) { |
| 266 |
customFilterProgramProxy->setClient(this); |
368 |
customFilterProgramProxy->setClient(this); |
| 267 |
m_customFilterPrograms.add(customFilterProgramProxy.get()); |
369 |
m_customFilterPrograms.add(customFilterProgramProxy.get()); |
| 268 |
m_coordinator->state().customFiltersToCreate.append(std::make_pair(customFilterProgramProxy->id(), customOperation->validatedProgram()->validatedProgramInfo())); |
370 |
m_state.customFiltersToCreate.append(std::make_pair(customFilterProgramProxy->id(), customOperation->validatedProgram()->validatedProgramInfo())); |
| 269 |
} else { |
371 |
} else { |
| 270 |
// If the client was not disconnected then this coordinator must be the client for it. |
372 |
// If the client was not disconnected then this coordinator must be the client for it. |
| 271 |
ASSERT(customFilterProgramProxy->client() == this); |
373 |
ASSERT(customFilterProgramProxy->client() == this); |
|
Lines 278-284
void CoordinatedLayerTreeHost::removeCustomFilterProgramProxy(WebCustomFilterPro
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec9
|
| 278 |
// At this time the shader is not needed anymore, so we remove it from our set and |
380 |
// At this time the shader is not needed anymore, so we remove it from our set and |
| 279 |
// send a message to the other process to delete it. |
381 |
// send a message to the other process to delete it. |
| 280 |
m_customFilterPrograms.remove(customFilterProgramProxy); |
382 |
m_customFilterPrograms.remove(customFilterProgramProxy); |
| 281 |
m_coordinator->state().customFiltersToRemove.append(customFilterProgramProxy->id()); |
383 |
m_state.customFiltersToRemove.append(customFilterProgramProxy->id()); |
| 282 |
} |
384 |
} |
| 283 |
|
385 |
|
| 284 |
void CoordinatedLayerTreeHost::disconnectCustomFilterPrograms() |
386 |
void CoordinatedLayerTreeHost::disconnectCustomFilterPrograms() |
|
Lines 290-319
void CoordinatedLayerTreeHost::disconnectCustomFilterPrograms()
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec10
|
| 290 |
} |
392 |
} |
| 291 |
#endif // ENABLE(CSS_SHADERS) |
393 |
#endif // ENABLE(CSS_SHADERS) |
| 292 |
|
394 |
|
| 293 |
void CoordinatedLayerTreeHost::didFlushRootLayer() |
395 |
void CoordinatedLayerTreeHost::detachLayer(CoordinatedGraphicsLayer* layer) |
| 294 |
{ |
396 |
{ |
| 295 |
if (m_pageOverlayLayer) |
397 |
m_registeredLayers.remove(layer->id()); |
| 296 |
m_pageOverlayLayer->flushCompositingStateForThisLayerOnly(); |
398 |
|
|
|
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(); |
| 297 |
} |
407 |
} |
| 298 |
|
408 |
|
| 299 |
void CoordinatedLayerTreeHost::performScheduledLayerFlush() |
409 |
void CoordinatedLayerTreeHost::performScheduledLayerFlush() |
| 300 |
{ |
410 |
{ |
| 301 |
if (m_isSuspended || m_isWaitingForRenderer) |
411 |
if (m_isSuspended || m_waitingForUIProcess) |
| 302 |
return; |
412 |
return; |
| 303 |
|
413 |
|
| 304 |
m_coordinator->syncDisplayState(); |
414 |
syncDisplayState(); |
| 305 |
|
415 |
|
| 306 |
if (!m_isValid) |
416 |
if (!m_isValid) |
| 307 |
return; |
417 |
return; |
| 308 |
|
418 |
|
| 309 |
bool didSync = m_coordinator->flushPendingLayerChanges(); |
419 |
if (flushPendingLayerChanges()) |
|
|
420 |
didPerformScheduledLayerFlush(); |
| 421 |
} |
| 310 |
|
422 |
|
| 311 |
if (m_forceRepaintAsyncCallbackID) { |
423 |
void CoordinatedLayerTreeHost::syncDisplayState() |
| 312 |
m_webPage->send(Messages::WebPageProxy::VoidCallback(m_forceRepaintAsyncCallbackID)); |
424 |
{ |
| 313 |
m_forceRepaintAsyncCallbackID = 0; |
425 |
#if ENABLE(INSPECTOR) |
| 314 |
} |
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 |
|
| 435 |
m_webPage->layoutIfNeeded(); |
| 436 |
} |
| 315 |
|
437 |
|
| 316 |
if (m_notifyAfterScheduledLayerFlush && didSync) { |
438 |
void CoordinatedLayerTreeHost::didPerformScheduledLayerFlush() |
|
|
439 |
{ |
| 440 |
if (m_notifyAfterScheduledLayerFlush) { |
| 317 |
static_cast<DrawingAreaImpl*>(m_webPage->drawingArea())->layerHostDidFlushLayers(); |
441 |
static_cast<DrawingAreaImpl*>(m_webPage->drawingArea())->layerHostDidFlushLayers(); |
| 318 |
m_notifyAfterScheduledLayerFlush = false; |
442 |
m_notifyAfterScheduledLayerFlush = false; |
| 319 |
} |
443 |
} |
|
Lines 328-342
void CoordinatedLayerTreeHost::createPageOverlayLayer()
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec11
|
| 328 |
{ |
452 |
{ |
| 329 |
ASSERT(!m_pageOverlayLayer); |
453 |
ASSERT(!m_pageOverlayLayer); |
| 330 |
|
454 |
|
| 331 |
m_pageOverlayLayer = GraphicsLayer::create(graphicsLayerFactory(), m_coordinator.get()); |
455 |
m_pageOverlayLayer = GraphicsLayer::create(this, this); |
| 332 |
#ifndef NDEBUG |
456 |
#ifndef NDEBUG |
| 333 |
m_pageOverlayLayer->setName("CompositingCoordinator page overlay content"); |
457 |
m_pageOverlayLayer->setName("CoordinatedLayerTreeHost page overlay content"); |
| 334 |
#endif |
458 |
#endif |
| 335 |
|
459 |
|
| 336 |
m_pageOverlayLayer->setDrawsContent(true); |
460 |
m_pageOverlayLayer->setDrawsContent(true); |
| 337 |
m_pageOverlayLayer->setSize(m_coordinator->rootLayer()->size()); |
461 |
m_pageOverlayLayer->setSize(m_webPage->size()); |
| 338 |
|
462 |
|
| 339 |
m_coordinator->rootLayer()->addChild(m_pageOverlayLayer.get()); |
463 |
m_rootLayer->addChild(m_pageOverlayLayer.get()); |
| 340 |
} |
464 |
} |
| 341 |
|
465 |
|
| 342 |
void CoordinatedLayerTreeHost::destroyPageOverlayLayer() |
466 |
void CoordinatedLayerTreeHost::destroyPageOverlayLayer() |
|
Lines 346-352
void CoordinatedLayerTreeHost::destroyPageOverlayLayer()
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec12
|
| 346 |
m_pageOverlayLayer = nullptr; |
470 |
m_pageOverlayLayer = nullptr; |
| 347 |
} |
471 |
} |
| 348 |
|
472 |
|
| 349 |
void CoordinatedLayerTreeHost::paintLayerContents(const GraphicsLayer* graphicsLayer, GraphicsContext& graphicsContext, const IntRect& clipRect) |
473 |
PassRefPtr<CoordinatedImageBacking> CoordinatedLayerTreeHost::createImageBackingIfNeeded(Image* image) |
|
|
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) |
| 350 |
{ |
532 |
{ |
| 351 |
if (graphicsLayer == m_pageOverlayLayer) { |
533 |
if (graphicsLayer == m_pageOverlayLayer) { |
| 352 |
// Overlays contain transparent contents and won't clear the context as part of their rendering, so we do it here. |
534 |
// Overlays contain transparent contents and won't clear the context as part of their rendering, so we do it here. |
|
Lines 356-365
void CoordinatedLayerTreeHost::paintLayerContents(const GraphicsLayer* graphicsL
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec13
|
| 356 |
} |
538 |
} |
| 357 |
} |
539 |
} |
| 358 |
|
540 |
|
| 359 |
void CoordinatedLayerTreeHost::commitSceneState(WebCore::CoordinatedGraphicsState& state) |
541 |
PassOwnPtr<GraphicsLayer> CoordinatedLayerTreeHost::createGraphicsLayer(GraphicsLayerClient* client) |
| 360 |
{ |
542 |
{ |
| 361 |
m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::CommitCoordinatedGraphicsState(state)); |
543 |
CoordinatedGraphicsLayer* layer = new CoordinatedGraphicsLayer(client); |
| 362 |
m_isWaitingForRenderer = true; |
544 |
layer->setCoordinator(this); |
|
|
545 |
m_registeredLayers.add(layer->id(), layer); |
| 546 |
m_state.layersToCreate.append(layer->id()); |
| 547 |
layer->setNeedsVisibleRectAdjustment(); |
| 548 |
scheduleLayerFlush(); |
| 549 |
return adoptPtr(layer); |
| 363 |
} |
550 |
} |
| 364 |
|
551 |
|
| 365 |
PassRefPtr<CoordinatedSurface> CoordinatedLayerTreeHost::createCoordinatedSurface(const IntSize& size, CoordinatedSurface::Flags flags) |
552 |
PassRefPtr<CoordinatedSurface> CoordinatedLayerTreeHost::createCoordinatedSurface(const IntSize& size, CoordinatedSurface::Flags flags) |
|
Lines 367-380
PassRefPtr<CoordinatedSurface> CoordinatedLayerTreeHost::createCoordinatedSurfac
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec14
|
| 367 |
return WebCoordinatedSurface::create(size, flags); |
554 |
return WebCoordinatedSurface::create(size, flags); |
| 368 |
} |
555 |
} |
| 369 |
|
556 |
|
|
|
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 |
|
| 370 |
bool LayerTreeHost::supportsAcceleratedCompositing() |
567 |
bool LayerTreeHost::supportsAcceleratedCompositing() |
| 371 |
{ |
568 |
{ |
| 372 |
return true; |
569 |
return true; |
| 373 |
} |
570 |
} |
| 374 |
|
571 |
|
|
|
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 |
|
| 375 |
void CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged() |
621 |
void CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged() |
| 376 |
{ |
622 |
{ |
| 377 |
m_coordinator->deviceOrPageScaleFactorChanged(); |
623 |
m_rootLayer->deviceOrPageScaleFactorChanged(); |
| 378 |
if (m_pageOverlayLayer) |
624 |
if (m_pageOverlayLayer) |
| 379 |
m_pageOverlayLayer->deviceOrPageScaleFactorChanged(); |
625 |
m_pageOverlayLayer->deviceOrPageScaleFactorChanged(); |
| 380 |
} |
626 |
} |
|
Lines 385-407
void CoordinatedLayerTreeHost::pageBackgroundTransparencyChanged()
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec15
|
| 385 |
|
631 |
|
| 386 |
GraphicsLayerFactory* CoordinatedLayerTreeHost::graphicsLayerFactory() |
632 |
GraphicsLayerFactory* CoordinatedLayerTreeHost::graphicsLayerFactory() |
| 387 |
{ |
633 |
{ |
| 388 |
return m_coordinator.get(); |
634 |
return this; |
| 389 |
} |
635 |
} |
| 390 |
|
636 |
|
| 391 |
#if ENABLE(REQUEST_ANIMATION_FRAME) |
637 |
#if ENABLE(REQUEST_ANIMATION_FRAME) |
| 392 |
void CoordinatedLayerTreeHost::scheduleAnimation() |
638 |
void CoordinatedLayerTreeHost::scheduleAnimation() |
| 393 |
{ |
639 |
{ |
| 394 |
if (m_isWaitingForRenderer) |
640 |
if (m_waitingForUIProcess) |
| 395 |
return; |
641 |
return; |
| 396 |
|
642 |
|
| 397 |
if (m_layerFlushTimer.isActive()) |
643 |
if (m_layerFlushTimer.isActive()) |
| 398 |
return; |
644 |
return; |
| 399 |
|
645 |
|
| 400 |
m_layerFlushTimer.startOneShot(m_coordinator->nextAnimationServiceTime()); |
646 |
// According to the requestAnimationFrame spec, rAF callbacks should not be faster than 60FPS. |
|
|
647 |
static const double MinimalTimeoutForAnimations = 1. / 60.; |
| 648 |
m_layerFlushTimer.startOneShot(std::max<double>(0., MinimalTimeoutForAnimations - WTF::monotonicallyIncreasingTime() + m_lastAnimationServiceTime)); |
| 401 |
scheduleLayerFlush(); |
649 |
scheduleLayerFlush(); |
| 402 |
} |
650 |
} |
| 403 |
#endif |
651 |
#endif |
| 404 |
|
652 |
|
|
|
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 |
|
| 405 |
void CoordinatedLayerTreeHost::setBackgroundColor(const WebCore::Color& color) |
723 |
void CoordinatedLayerTreeHost::setBackgroundColor(const WebCore::Color& color) |
| 406 |
{ |
724 |
{ |
| 407 |
m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::SetBackgroundColor(color)); |
725 |
m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::SetBackgroundColor(color)); |
|
Lines 409-415
void CoordinatedLayerTreeHost::setBackgroundColor(const WebCore::Color& color)
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp_sec16
|
| 409 |
|
727 |
|
| 410 |
void CoordinatedLayerTreeHost::commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) |
728 |
void CoordinatedLayerTreeHost::commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset) |
| 411 |
{ |
729 |
{ |
| 412 |
m_coordinator->commitScrollOffset(layerID, offset); |
730 |
LayerMap::iterator i = m_registeredLayers.find(layerID); |
|
|
731 |
if (i == m_registeredLayers.end()) |
| 732 |
return; |
| 733 |
|
| 734 |
i->value->commitScrollOffset(offset); |
| 413 |
} |
735 |
} |
| 414 |
|
736 |
|
| 415 |
} // namespace WebKit |
737 |
} // namespace WebKit |