|
Lines 1-6
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp_sec1
|
| 1 |
/* |
1 |
/* |
| 2 |
* Copyright (C) 2011 Apple Inc. All rights reserved. |
2 |
* Copyright (C) 2011 Apple Inc. All rights reserved. |
| 3 |
* Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). |
3 |
* Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). |
|
|
4 |
* Copyright (C) 2012 Company 100, Inc. All rights reserved. |
| 4 |
* |
5 |
* |
| 5 |
* Redistribution and use in source and binary forms, with or without |
6 |
* Redistribution and use in source and binary forms, with or without |
| 6 |
* modification, are permitted provided that the following conditions |
7 |
* modification, are permitted provided that the following conditions |
|
Lines 29-60
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp_sec2
|
| 29 |
#if USE(COORDINATED_GRAPHICS) |
30 |
#if USE(COORDINATED_GRAPHICS) |
| 30 |
#include "LayerTreeCoordinator.h" |
31 |
#include "LayerTreeCoordinator.h" |
| 31 |
|
32 |
|
| 32 |
#include "CoordinatedGraphicsArgumentCoders.h" |
|
|
| 33 |
#include "CoordinatedGraphicsLayer.h" |
33 |
#include "CoordinatedGraphicsLayer.h" |
| 34 |
#include "DrawingAreaImpl.h" |
34 |
#include "DrawingAreaImpl.h" |
| 35 |
#include "GraphicsContext.h" |
35 |
#include "GraphicsContext.h" |
| 36 |
#include "LayerTreeCoordinatorProxyMessages.h" |
|
|
| 37 |
#include "MessageID.h" |
| 38 |
#include "SurfaceUpdateInfo.h" |
| 39 |
#include "WebCoreArgumentCoders.h" |
| 40 |
#include "WebPage.h" |
36 |
#include "WebPage.h" |
| 41 |
#include "WebPageProxyMessages.h" |
|
|
| 42 |
#include <WebCore/Frame.h> |
| 43 |
#include <WebCore/FrameView.h> |
| 44 |
#include <WebCore/GraphicsSurface.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> |
| 51 |
#include <WebCore/TextureMapperPlatformLayer.h> |
| 52 |
#include <wtf/TemporaryChange.h> |
| 53 |
|
| 54 |
#if ENABLE(CSS_SHADERS) |
| 55 |
#include "CustomFilterValidatedProgram.h" |
| 56 |
#include "ValidatedCustomFilterOperation.h" |
| 57 |
#endif |
| 58 |
|
37 |
|
| 59 |
using namespace WebCore; |
38 |
using namespace WebCore; |
| 60 |
|
39 |
|
|
Lines 67-155
PassRefPtr<LayerTreeCoordinator> LayerTreeCoordinator::create(WebPage* webPage)
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp_sec3
|
| 67 |
|
46 |
|
| 68 |
LayerTreeCoordinator::~LayerTreeCoordinator() |
47 |
LayerTreeCoordinator::~LayerTreeCoordinator() |
| 69 |
{ |
48 |
{ |
| 70 |
#if ENABLE(CSS_SHADERS) |
|
|
| 71 |
disconnectCustomFilterPrograms(); |
| 72 |
#endif |
| 73 |
|
| 74 |
// Prevent setCoordinatedGraphicsLayerClient(0) -> detachLayer() from modifying the set while we iterate it. |
| 75 |
HashSet<WebCore::CoordinatedGraphicsLayer*> registeredLayers; |
| 76 |
registeredLayers.swap(m_registeredLayers); |
| 77 |
|
| 78 |
HashSet<WebCore::CoordinatedGraphicsLayer*>::iterator end = registeredLayers.end(); |
| 79 |
for (HashSet<WebCore::CoordinatedGraphicsLayer*>::iterator it = registeredLayers.begin(); it != end; ++it) |
| 80 |
(*it)->setCoordinator(0); |
| 81 |
} |
49 |
} |
| 82 |
|
50 |
|
| 83 |
LayerTreeCoordinator::LayerTreeCoordinator(WebPage* webPage) |
51 |
LayerTreeCoordinator::LayerTreeCoordinator(WebPage* webPage) |
| 84 |
: LayerTreeHost(webPage) |
52 |
: LayerTreeHost(webPage) |
| 85 |
, m_notifyAfterScheduledLayerFlush(false) |
53 |
, m_notifyAfterScheduledLayerFlush(false) |
| 86 |
, m_isValid(true) |
|
|
| 87 |
, m_isPurging(false) |
| 88 |
, m_waitingForUIProcess(true) |
| 89 |
, m_isSuspended(false) |
| 90 |
, m_contentsScale(1) |
| 91 |
, m_shouldSendScrollPositionUpdate(true) |
| 92 |
, m_shouldSyncFrame(false) |
| 93 |
, m_shouldSyncRootLayer(true) |
| 94 |
, m_layerFlushTimer(this, &LayerTreeCoordinator::layerFlushTimerFired) |
| 95 |
, m_releaseInactiveAtlasesTimer(this, &LayerTreeCoordinator::releaseInactiveAtlasesTimerFired) |
| 96 |
, m_layerFlushSchedulingEnabled(true) |
| 97 |
, m_forceRepaintAsyncCallbackID(0) |
54 |
, m_forceRepaintAsyncCallbackID(0) |
| 98 |
, m_animationsLocked(false) |
55 |
{ |
| 99 |
{ |
56 |
m_compositingCoordinatorMessageClient = WebCompositingCoordinatorMessageClient::create(m_webPage); |
| 100 |
// Create a root layer. |
57 |
m_compositingCoordinator = CompositingCoordinator::create(m_webPage->corePage(), this, m_compositingCoordinatorMessageClient.get()); |
| 101 |
m_rootLayer = GraphicsLayer::create(this, this); |
|
|
| 102 |
CoordinatedGraphicsLayer* coordinatedRootLayer = toCoordinatedGraphicsLayer(m_rootLayer.get()); |
| 103 |
coordinatedRootLayer->setRootLayer(true); |
| 104 |
#ifndef NDEBUG |
| 105 |
m_rootLayer->setName("LayerTreeCoordinator root layer"); |
| 106 |
#endif |
| 107 |
m_rootLayer->setDrawsContent(false); |
| 108 |
m_rootLayer->setSize(m_webPage->size()); |
| 109 |
m_layerTreeContext.coordinatedLayerID = toCoordinatedGraphicsLayer(coordinatedRootLayer)->id(); |
| 110 |
|
| 111 |
m_nonCompositedContentLayer = GraphicsLayer::create(this, this); |
| 112 |
#ifndef NDEBUG |
| 113 |
m_nonCompositedContentLayer->setName("LayerTreeCoordinator non-composited content"); |
| 114 |
#endif |
| 115 |
m_nonCompositedContentLayer->setDrawsContent(true); |
| 116 |
m_nonCompositedContentLayer->setSize(m_webPage->size()); |
| 117 |
|
58 |
|
| 118 |
m_rootLayer->addChild(m_nonCompositedContentLayer.get()); |
59 |
CoordinatedGraphicsLayer* rootLayer = toCoordinatedGraphicsLayer(m_compositingCoordinator->rootGraphicsLayer()); |
|
|
60 |
m_layerTreeContext.coordinatedLayerID = rootLayer->id(); |
| 119 |
|
61 |
|
| 120 |
if (m_webPage->hasPageOverlay()) |
62 |
if (m_webPage->hasPageOverlay()) |
| 121 |
createPageOverlayLayer(); |
63 |
m_compositingCoordinator->createPageOverlayLayer(); |
| 122 |
|
64 |
|
| 123 |
scheduleLayerFlush(); |
65 |
scheduleLayerFlush(); |
| 124 |
} |
66 |
} |
| 125 |
|
67 |
|
| 126 |
void LayerTreeCoordinator::setLayerFlushSchedulingEnabled(bool layerFlushingEnabled) |
68 |
void LayerTreeCoordinator::setLayerFlushSchedulingEnabled(bool layerFlushingEnabled) |
| 127 |
{ |
69 |
{ |
| 128 |
if (m_layerFlushSchedulingEnabled == layerFlushingEnabled) |
70 |
m_compositingCoordinator->setLayerFlushSchedulingEnabled(layerFlushingEnabled); |
| 129 |
return; |
|
|
| 130 |
|
| 131 |
m_layerFlushSchedulingEnabled = layerFlushingEnabled; |
| 132 |
|
| 133 |
if (m_layerFlushSchedulingEnabled) { |
| 134 |
scheduleLayerFlush(); |
| 135 |
return; |
| 136 |
} |
| 137 |
|
| 138 |
cancelPendingLayerFlush(); |
| 139 |
} |
71 |
} |
| 140 |
|
72 |
|
| 141 |
void LayerTreeCoordinator::scheduleLayerFlush() |
73 |
void LayerTreeCoordinator::scheduleLayerFlush() |
| 142 |
{ |
74 |
{ |
| 143 |
if (!m_layerFlushSchedulingEnabled) |
75 |
m_compositingCoordinator->scheduleLayerFlush(); |
| 144 |
return; |
|
|
| 145 |
|
| 146 |
if (!m_layerFlushTimer.isActive()) |
| 147 |
m_layerFlushTimer.startOneShot(0); |
| 148 |
} |
| 149 |
|
| 150 |
void LayerTreeCoordinator::cancelPendingLayerFlush() |
| 151 |
{ |
| 152 |
m_layerFlushTimer.stop(); |
| 153 |
} |
76 |
} |
| 154 |
|
77 |
|
| 155 |
void LayerTreeCoordinator::setShouldNotifyAfterNextScheduledLayerFlush(bool notifyAfterScheduledLayerFlush) |
78 |
void LayerTreeCoordinator::setShouldNotifyAfterNextScheduledLayerFlush(bool notifyAfterScheduledLayerFlush) |
|
Lines 159-188
void LayerTreeCoordinator::setShouldNotifyAfterNextScheduledLayerFlush(bool noti
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp_sec4
|
| 159 |
|
82 |
|
| 160 |
void LayerTreeCoordinator::setRootCompositingLayer(WebCore::GraphicsLayer* graphicsLayer) |
83 |
void LayerTreeCoordinator::setRootCompositingLayer(WebCore::GraphicsLayer* graphicsLayer) |
| 161 |
{ |
84 |
{ |
| 162 |
m_nonCompositedContentLayer->removeAllChildren(); |
85 |
m_compositingCoordinator->setRootCompositingLayer(graphicsLayer); |
| 163 |
m_nonCompositedContentLayer->setContentsOpaque(m_webPage->drawsBackground() && !m_webPage->drawsTransparentBackground()); |
|
|
| 164 |
|
| 165 |
// Add the accelerated layer tree hierarchy. |
| 166 |
if (graphicsLayer) |
| 167 |
m_nonCompositedContentLayer->addChild(graphicsLayer); |
| 168 |
} |
86 |
} |
| 169 |
|
87 |
|
| 170 |
void LayerTreeCoordinator::invalidate() |
88 |
void LayerTreeCoordinator::invalidate() |
| 171 |
{ |
89 |
{ |
| 172 |
cancelPendingLayerFlush(); |
90 |
m_compositingCoordinator->invalidate(); |
| 173 |
|
|
|
| 174 |
ASSERT(m_isValid); |
| 175 |
m_rootLayer = nullptr; |
| 176 |
m_isValid = false; |
| 177 |
} |
91 |
} |
| 178 |
|
92 |
|
| 179 |
void LayerTreeCoordinator::setNonCompositedContentsNeedDisplay(const WebCore::IntRect& rect) |
93 |
void LayerTreeCoordinator::setNonCompositedContentsNeedDisplay(const WebCore::IntRect& rect) |
| 180 |
{ |
94 |
{ |
| 181 |
m_nonCompositedContentLayer->setNeedsDisplayInRect(rect); |
95 |
m_compositingCoordinator->setNeedsDisplayInRect(rect); |
| 182 |
if (m_pageOverlayLayer) |
|
|
| 183 |
m_pageOverlayLayer->setNeedsDisplayInRect(rect); |
| 184 |
|
| 185 |
scheduleLayerFlush(); |
| 186 |
} |
96 |
} |
| 187 |
|
97 |
|
| 188 |
void LayerTreeCoordinator::scrollNonCompositedContents(const WebCore::IntRect& scrollRect, const WebCore::IntSize& /* scrollOffset */) |
98 |
void LayerTreeCoordinator::scrollNonCompositedContents(const WebCore::IntRect& scrollRect, const WebCore::IntSize& /* scrollOffset */) |
|
Lines 192-205
void LayerTreeCoordinator::scrollNonCompositedContents(const WebCore::IntRect& s
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp_sec5
|
| 192 |
|
102 |
|
| 193 |
void LayerTreeCoordinator::forceRepaint() |
103 |
void LayerTreeCoordinator::forceRepaint() |
| 194 |
{ |
104 |
{ |
| 195 |
// This is necessary for running layout tests. Since in this case we are not waiting for a UIProcess to reply nicely. |
105 |
m_compositingCoordinator->forceRepaint(); |
| 196 |
// Instead we are just triggering forceRepaint. But we still want to have the scripted animation callbacks being executed. |
|
|
| 197 |
syncDisplayState(); |
| 198 |
|
| 199 |
// We need to schedule another flush, otherwise the forced paint might cancel a later expected flush. |
| 200 |
// This is aligned with LayerTreeHostCA. |
| 201 |
scheduleLayerFlush(); |
| 202 |
flushPendingLayerChanges(); |
| 203 |
} |
106 |
} |
| 204 |
|
107 |
|
| 205 |
bool LayerTreeCoordinator::forceRepaintAsync(uint64_t callbackID) |
108 |
bool LayerTreeCoordinator::forceRepaintAsync(uint64_t callbackID) |
|
Lines 213-637
bool LayerTreeCoordinator::forceRepaintAsync(uint64_t callbackID)
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp_sec6
|
| 213 |
|
116 |
|
| 214 |
void LayerTreeCoordinator::sizeDidChange(const WebCore::IntSize& newSize) |
117 |
void LayerTreeCoordinator::sizeDidChange(const WebCore::IntSize& newSize) |
| 215 |
{ |
118 |
{ |
| 216 |
if (m_rootLayer->size() == newSize) |
119 |
m_compositingCoordinator->sizeDidChange(newSize); |
| 217 |
return; |
|
|
| 218 |
|
| 219 |
m_rootLayer->setSize(newSize); |
| 220 |
|
| 221 |
// If the newSize exposes new areas of the non-composited content a setNeedsDisplay is needed |
| 222 |
// for those newly exposed areas. |
| 223 |
FloatSize oldSize = m_nonCompositedContentLayer->size(); |
| 224 |
m_nonCompositedContentLayer->setSize(newSize); |
| 225 |
|
| 226 |
if (newSize.width() > oldSize.width()) { |
| 227 |
float height = std::min(static_cast<float>(newSize.height()), oldSize.height()); |
| 228 |
m_nonCompositedContentLayer->setNeedsDisplayInRect(FloatRect(oldSize.width(), 0, newSize.width() - oldSize.width(), height)); |
| 229 |
} |
| 230 |
|
| 231 |
if (newSize.height() > oldSize.height()) |
| 232 |
m_nonCompositedContentLayer->setNeedsDisplayInRect(FloatRect(0, oldSize.height(), newSize.width(), newSize.height() - oldSize.height())); |
| 233 |
|
| 234 |
if (m_pageOverlayLayer) |
| 235 |
m_pageOverlayLayer->setSize(newSize); |
| 236 |
|
| 237 |
scheduleLayerFlush(); |
| 238 |
} |
120 |
} |
| 239 |
|
121 |
|
| 240 |
void LayerTreeCoordinator::didInstallPageOverlay() |
122 |
void LayerTreeCoordinator::didInstallPageOverlay() |
| 241 |
{ |
123 |
{ |
| 242 |
createPageOverlayLayer(); |
124 |
m_compositingCoordinator->createPageOverlayLayer(); |
| 243 |
scheduleLayerFlush(); |
|
|
| 244 |
} |
125 |
} |
| 245 |
|
126 |
|
| 246 |
void LayerTreeCoordinator::didUninstallPageOverlay() |
127 |
void LayerTreeCoordinator::didUninstallPageOverlay() |
| 247 |
{ |
128 |
{ |
| 248 |
destroyPageOverlayLayer(); |
129 |
m_compositingCoordinator->destroyPageOverlayLayer(); |
| 249 |
scheduleLayerFlush(); |
|
|
| 250 |
} |
130 |
} |
| 251 |
|
131 |
|
| 252 |
void LayerTreeCoordinator::setPageOverlayNeedsDisplay(const WebCore::IntRect& rect) |
132 |
void LayerTreeCoordinator::setPageOverlayNeedsDisplay(const WebCore::IntRect& rect) |
| 253 |
{ |
133 |
{ |
| 254 |
ASSERT(m_pageOverlayLayer); |
134 |
m_compositingCoordinator->setPageOverlayNeedsDisplay(rect); |
| 255 |
m_pageOverlayLayer->setNeedsDisplayInRect(rect); |
|
|
| 256 |
scheduleLayerFlush(); |
| 257 |
} |
135 |
} |
| 258 |
|
136 |
|
| 259 |
void LayerTreeCoordinator::setPageOverlayOpacity(float value) |
137 |
void LayerTreeCoordinator::setPageOverlayOpacity(float value) |
| 260 |
{ |
138 |
{ |
| 261 |
ASSERT(m_pageOverlayLayer); |
139 |
m_compositingCoordinator->setPageOverlayOpacity(value); |
| 262 |
m_pageOverlayLayer->setOpacity(value); |
|
|
| 263 |
scheduleLayerFlush(); |
| 264 |
} |
140 |
} |
| 265 |
|
141 |
|
| 266 |
bool LayerTreeCoordinator::flushPendingLayerChanges() |
142 |
void LayerTreeCoordinator::pauseRendering() |
| 267 |
{ |
143 |
{ |
| 268 |
if (m_waitingForUIProcess) |
144 |
m_compositingCoordinator->pauseRendering(); |
| 269 |
return false; |
|
|
| 270 |
|
| 271 |
m_rootLayer->flushCompositingStateForThisLayerOnly(); |
| 272 |
m_nonCompositedContentLayer->flushCompositingStateForThisLayerOnly(); |
| 273 |
if (m_pageOverlayLayer) |
| 274 |
m_pageOverlayLayer->flushCompositingStateForThisLayerOnly(); |
| 275 |
|
| 276 |
bool didSync = m_webPage->corePage()->mainFrame()->view()->flushCompositingStateIncludingSubframes(); |
| 277 |
|
| 278 |
flushPendingImageBackingChanges(); |
| 279 |
|
| 280 |
if (m_shouldSyncRootLayer) { |
| 281 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetRootCompositingLayer(toCoordinatedGraphicsLayer(m_rootLayer.get())->id())); |
| 282 |
m_shouldSyncRootLayer = false; |
| 283 |
m_shouldSyncFrame = true; |
| 284 |
} |
| 285 |
|
| 286 |
for (size_t i = 0; i < m_detachedLayers.size(); ++i) |
| 287 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::DeleteCompositingLayer(m_detachedLayers[i])); |
| 288 |
m_detachedLayers.clear(); |
| 289 |
|
| 290 |
if (m_shouldSyncFrame) { |
| 291 |
didSync = true; |
| 292 |
|
| 293 |
IntSize contentsSize = roundedIntSize(m_nonCompositedContentLayer->size()); |
| 294 |
IntRect coveredRect = toCoordinatedGraphicsLayer(m_nonCompositedContentLayer.get())->coverRect(); |
| 295 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::DidRenderFrame(contentsSize, coveredRect)); |
| 296 |
m_waitingForUIProcess = true; |
| 297 |
m_shouldSyncFrame = false; |
| 298 |
} else |
| 299 |
unlockAnimations(); |
| 300 |
|
| 301 |
if (m_forceRepaintAsyncCallbackID) { |
| 302 |
m_webPage->send(Messages::WebPageProxy::VoidCallback(m_forceRepaintAsyncCallbackID)); |
| 303 |
m_forceRepaintAsyncCallbackID = 0; |
| 304 |
} |
| 305 |
|
| 306 |
return didSync; |
| 307 |
} |
| 308 |
|
| 309 |
void LayerTreeCoordinator::syncLayerState(CoordinatedLayerID id, const CoordinatedLayerInfo& info) |
| 310 |
{ |
| 311 |
if (m_shouldSendScrollPositionUpdate) { |
| 312 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::DidChangeScrollPosition(m_visibleContentsRect.location())); |
| 313 |
m_shouldSendScrollPositionUpdate = false; |
| 314 |
} |
| 315 |
|
| 316 |
m_shouldSyncFrame = true; |
| 317 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetCompositingLayerState(id, info)); |
| 318 |
} |
145 |
} |
| 319 |
|
146 |
|
| 320 |
void LayerTreeCoordinator::syncLayerChildren(CoordinatedLayerID id, const Vector<CoordinatedLayerID>& children) |
147 |
void LayerTreeCoordinator::resumeRendering() |
| 321 |
{ |
148 |
{ |
| 322 |
m_shouldSyncFrame = true; |
149 |
m_compositingCoordinator->resumeRendering(); |
| 323 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetCompositingLayerChildren(id, children)); |
|
|
| 324 |
} |
150 |
} |
| 325 |
|
151 |
|
| 326 |
#if USE(GRAPHICS_SURFACE) |
152 |
const IntSize& LayerTreeCoordinator::viewSize() const |
| 327 |
void LayerTreeCoordinator::createCanvas(CoordinatedLayerID id, PlatformLayer* canvasPlatformLayer) |
|
|
| 328 |
{ |
153 |
{ |
| 329 |
m_shouldSyncFrame = true; |
154 |
return m_webPage->size(); |
| 330 |
GraphicsSurfaceToken token = canvasPlatformLayer->graphicsSurfaceToken(); |
|
|
| 331 |
IntSize canvasSize = canvasPlatformLayer->platformLayerSize(); |
| 332 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::CreateCanvas(id, canvasSize, token)); |
| 333 |
} |
155 |
} |
| 334 |
|
156 |
|
| 335 |
void LayerTreeCoordinator::syncCanvas(CoordinatedLayerID id, PlatformLayer* canvasPlatformLayer) |
157 |
void LayerTreeCoordinator::layoutIfNeeded() |
| 336 |
{ |
158 |
{ |
| 337 |
m_shouldSyncFrame = true; |
159 |
m_webPage->layoutIfNeeded(); |
| 338 |
uint32_t frontBuffer = canvasPlatformLayer->copyToGraphicsSurface(); |
|
|
| 339 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::SyncCanvas(id, frontBuffer)); |
| 340 |
} |
160 |
} |
| 341 |
|
161 |
|
| 342 |
void LayerTreeCoordinator::destroyCanvas(CoordinatedLayerID id) |
162 |
bool LayerTreeCoordinator::isOpaqueContents() |
| 343 |
{ |
163 |
{ |
| 344 |
if (m_isPurging) |
164 |
return m_webPage->drawsBackground() && !m_webPage->drawsTransparentBackground(); |
| 345 |
return; |
|
|
| 346 |
|
| 347 |
m_shouldSyncFrame = true; |
| 348 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::DestroyCanvas(id)); |
| 349 |
} |
165 |
} |
| 350 |
#endif |
|
|
| 351 |
|
166 |
|
| 352 |
#if ENABLE(CSS_FILTERS) |
167 |
void LayerTreeCoordinator::didPerformScheduledLayerFlush(bool didSync) |
| 353 |
void LayerTreeCoordinator::syncLayerFilters(CoordinatedLayerID id, const FilterOperations& filters) |
|
|
| 354 |
{ |
168 |
{ |
| 355 |
m_shouldSyncFrame = true; |
169 |
if (m_forceRepaintAsyncCallbackID) { |
| 356 |
#if ENABLE(CSS_SHADERS) |
170 |
m_compositingCoordinatorMessageClient->invokeForceRepaintAsyncCallback(m_forceRepaintAsyncCallbackID); |
| 357 |
checkCustomFilterProgramProxies(filters); |
171 |
m_forceRepaintAsyncCallbackID = 0; |
| 358 |
#endif |
|
|
| 359 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetCompositingLayerFilters(id, filters)); |
| 360 |
} |
| 361 |
#endif |
| 362 |
|
| 363 |
#if ENABLE(CSS_SHADERS) |
| 364 |
void LayerTreeCoordinator::checkCustomFilterProgramProxies(const FilterOperations& filters) |
| 365 |
{ |
| 366 |
// We need to create the WebCustomFilterProgramProxy objects before we get to serialize the |
| 367 |
// custom filters to the other process. That's because WebCustomFilterProgramProxy needs |
| 368 |
// to link back to the coordinator, so that we can send a message to the UI process when |
| 369 |
// the program is not needed anymore. |
| 370 |
// Note that the serialization will only happen at a later time in ArgumentCoder<WebCore::FilterOperations>::encode. |
| 371 |
// At that point the program will only be serialized once. All the other times it will only use the ID of the program. |
| 372 |
for (size_t i = 0; i < filters.size(); ++i) { |
| 373 |
const FilterOperation* operation = filters.at(i); |
| 374 |
if (operation->getOperationType() != FilterOperation::VALIDATED_CUSTOM) |
| 375 |
continue; |
| 376 |
const ValidatedCustomFilterOperation* customOperation = static_cast<const ValidatedCustomFilterOperation*>(operation); |
| 377 |
ASSERT(customOperation->validatedProgram()->isInitialized()); |
| 378 |
TextureMapperPlatformCompiledProgram* program = customOperation->validatedProgram()->platformCompiledProgram(); |
| 379 |
|
| 380 |
RefPtr<WebCustomFilterProgramProxy> customFilterProgramProxy; |
| 381 |
if (program->client()) |
| 382 |
customFilterProgramProxy = static_cast<WebCustomFilterProgramProxy*>(program->client()); |
| 383 |
else { |
| 384 |
customFilterProgramProxy = WebCustomFilterProgramProxy::create(); |
| 385 |
program->setClient(customFilterProgramProxy); |
| 386 |
} |
| 387 |
|
| 388 |
if (!customFilterProgramProxy->client()) { |
| 389 |
customFilterProgramProxy->setClient(this); |
| 390 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::CreateCustomFilterProgram(customFilterProgramProxy->id(), customOperation->validatedProgram()->validatedProgramInfo())); |
| 391 |
} else { |
| 392 |
// If the client was not disconnected then this coordinator must be the client for it. |
| 393 |
ASSERT(customFilterProgramProxy->client() == this); |
| 394 |
} |
| 395 |
} |
172 |
} |
| 396 |
} |
|
|
| 397 |
|
| 398 |
void LayerTreeCoordinator::removeCustomFilterProgramProxy(WebCustomFilterProgramProxy* customFilterProgramProxy) |
| 399 |
{ |
| 400 |
// At this time the shader is not needed anymore, so we remove it from our set and |
| 401 |
// send a message to the other process to delete it. |
| 402 |
m_customFilterPrograms.remove(customFilterProgramProxy); |
| 403 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::RemoveCustomFilterProgram(customFilterProgramProxy->id())); |
| 404 |
} |
| 405 |
|
| 406 |
void LayerTreeCoordinator::disconnectCustomFilterPrograms() |
| 407 |
{ |
| 408 |
// Make sure that WebCore will not call into this coordinator anymore. |
| 409 |
HashSet<WebCustomFilterProgramProxy*>::iterator iter = m_customFilterPrograms.begin(); |
| 410 |
for (; iter != m_customFilterPrograms.end(); ++iter) |
| 411 |
(*iter)->setClient(0); |
| 412 |
} |
| 413 |
#endif |
| 414 |
|
| 415 |
void LayerTreeCoordinator::detachLayer(CoordinatedGraphicsLayer* layer) |
| 416 |
{ |
| 417 |
m_registeredLayers.remove(layer); |
| 418 |
m_shouldSyncFrame = true; |
| 419 |
m_detachedLayers.append(layer->id()); |
| 420 |
scheduleLayerFlush(); |
| 421 |
} |
| 422 |
|
| 423 |
static void updateOffsetFromViewportForSelf(RenderLayer* renderLayer) |
| 424 |
{ |
| 425 |
// These conditions must match the conditions in RenderLayerCompositor::requiresCompositingForPosition. |
| 426 |
RenderLayerBacking* backing = renderLayer->backing(); |
| 427 |
if (!backing) |
| 428 |
return; |
| 429 |
|
| 430 |
RenderStyle* style = renderLayer->renderer()->style(); |
| 431 |
if (!style) |
| 432 |
return; |
| 433 |
|
| 434 |
if (!renderLayer->renderer()->isOutOfFlowPositioned() || renderLayer->renderer()->style()->position() != FixedPosition) |
| 435 |
return; |
| 436 |
|
| 437 |
if (!renderLayer->renderer()->container()->isRenderView()) |
| 438 |
return; |
| 439 |
|
| 440 |
if (!renderLayer->isStackingContext()) |
| 441 |
return; |
| 442 |
|
| 443 |
CoordinatedGraphicsLayer* graphicsLayer = toCoordinatedGraphicsLayer(backing->graphicsLayer()); |
| 444 |
graphicsLayer->setFixedToViewport(true); |
| 445 |
} |
| 446 |
|
| 447 |
static void updateOffsetFromViewportForLayer(RenderLayer* renderLayer) |
| 448 |
{ |
| 449 |
updateOffsetFromViewportForSelf(renderLayer); |
| 450 |
|
| 451 |
if (renderLayer->firstChild()) |
| 452 |
updateOffsetFromViewportForLayer(renderLayer->firstChild()); |
| 453 |
if (renderLayer->nextSibling()) |
| 454 |
updateOffsetFromViewportForLayer(renderLayer->nextSibling()); |
| 455 |
} |
| 456 |
|
| 457 |
void LayerTreeCoordinator::syncFixedLayers() |
| 458 |
{ |
| 459 |
if (!m_webPage->corePage()->settings() || !m_webPage->corePage()->settings()->acceleratedCompositingForFixedPositionEnabled()) |
| 460 |
return; |
| 461 |
|
| 462 |
if (!m_webPage->mainFrame()->view()->hasViewportConstrainedObjects()) |
| 463 |
return; |
| 464 |
|
| 465 |
RenderLayer* rootRenderLayer = m_webPage->mainFrame()->contentRenderer()->compositor()->rootRenderLayer(); |
| 466 |
ASSERT(rootRenderLayer); |
| 467 |
if (rootRenderLayer->firstChild()) |
| 468 |
updateOffsetFromViewportForLayer(rootRenderLayer->firstChild()); |
| 469 |
} |
| 470 |
|
| 471 |
void LayerTreeCoordinator::lockAnimations() |
| 472 |
{ |
| 473 |
m_animationsLocked = true; |
| 474 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetAnimationsLocked(true)); |
| 475 |
} |
| 476 |
|
| 477 |
void LayerTreeCoordinator::unlockAnimations() |
| 478 |
{ |
| 479 |
if (!m_animationsLocked) |
| 480 |
return; |
| 481 |
|
| 482 |
m_animationsLocked = false; |
| 483 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetAnimationsLocked(false)); |
| 484 |
} |
| 485 |
|
| 486 |
void LayerTreeCoordinator::performScheduledLayerFlush() |
| 487 |
{ |
| 488 |
if (m_isSuspended || m_waitingForUIProcess) |
| 489 |
return; |
| 490 |
|
| 491 |
// We lock the animations while performing layout, to avoid flickers caused by animations continuing in the UI process while |
| 492 |
// the web process layout wants to cancel them. |
| 493 |
lockAnimations(); |
| 494 |
syncDisplayState(); |
| 495 |
|
| 496 |
// We can unlock the animations before flushing if there are no visible changes, for example if there are content updates |
| 497 |
// in a layer with opacity 0. |
| 498 |
bool canUnlockBeforeFlush = !m_isValid || !toCoordinatedGraphicsLayer(m_rootLayer.get())->hasPendingVisibleChanges(); |
| 499 |
if (canUnlockBeforeFlush) |
| 500 |
unlockAnimations(); |
| 501 |
|
| 502 |
if (!m_isValid) |
| 503 |
return; |
| 504 |
|
173 |
|
| 505 |
if (flushPendingLayerChanges()) |
174 |
if (didSync && m_notifyAfterScheduledLayerFlush) { |
| 506 |
didPerformScheduledLayerFlush(); |
|
|
| 507 |
} |
| 508 |
|
| 509 |
void LayerTreeCoordinator::syncDisplayState() |
| 510 |
{ |
| 511 |
#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER) && !USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) |
| 512 |
// Make sure that any previously registered animation callbacks are being executed before we flush the layers. |
| 513 |
m_webPage->corePage()->mainFrame()->view()->serviceScriptedAnimations(convertSecondsToDOMTimeStamp(currentTime())); |
| 514 |
#endif |
| 515 |
|
| 516 |
m_webPage->layoutIfNeeded(); |
| 517 |
} |
| 518 |
|
| 519 |
void LayerTreeCoordinator::didPerformScheduledLayerFlush() |
| 520 |
{ |
| 521 |
if (m_notifyAfterScheduledLayerFlush) { |
| 522 |
static_cast<DrawingAreaImpl*>(m_webPage->drawingArea())->layerHostDidFlushLayers(); |
175 |
static_cast<DrawingAreaImpl*>(m_webPage->drawingArea())->layerHostDidFlushLayers(); |
| 523 |
m_notifyAfterScheduledLayerFlush = false; |
176 |
m_notifyAfterScheduledLayerFlush = false; |
| 524 |
} |
177 |
} |
| 525 |
} |
178 |
} |
| 526 |
|
179 |
|
| 527 |
void LayerTreeCoordinator::layerFlushTimerFired(Timer<LayerTreeCoordinator>*) |
180 |
void LayerTreeCoordinator::paintContents(WebCore::GraphicsContext& graphicsContext, const IntRect& clipRect) |
| 528 |
{ |
|
|
| 529 |
performScheduledLayerFlush(); |
| 530 |
} |
| 531 |
|
| 532 |
void LayerTreeCoordinator::createPageOverlayLayer() |
| 533 |
{ |
| 534 |
ASSERT(!m_pageOverlayLayer); |
| 535 |
|
| 536 |
m_pageOverlayLayer = GraphicsLayer::create(this, this); |
| 537 |
#ifndef NDEBUG |
| 538 |
m_pageOverlayLayer->setName("LayerTreeCoordinator page overlay content"); |
| 539 |
#endif |
| 540 |
|
| 541 |
m_pageOverlayLayer->setDrawsContent(true); |
| 542 |
m_pageOverlayLayer->setSize(m_webPage->size()); |
| 543 |
|
| 544 |
m_rootLayer->addChild(m_pageOverlayLayer.get()); |
| 545 |
} |
| 546 |
|
| 547 |
void LayerTreeCoordinator::destroyPageOverlayLayer() |
| 548 |
{ |
| 549 |
ASSERT(m_pageOverlayLayer); |
| 550 |
m_pageOverlayLayer->removeFromParent(); |
| 551 |
m_pageOverlayLayer = nullptr; |
| 552 |
} |
| 553 |
|
| 554 |
PassRefPtr<CoordinatedImageBacking> LayerTreeCoordinator::createImageBackingIfNeeded(Image* image) |
| 555 |
{ |
| 556 |
CoordinatedImageBackingID imageID = CoordinatedImageBacking::getCoordinatedImageBackingID(image); |
| 557 |
ImageBackingMap::iterator it = m_imageBackings.find(imageID); |
| 558 |
RefPtr<CoordinatedImageBacking> imageBacking; |
| 559 |
if (it == m_imageBackings.end()) { |
| 560 |
imageBacking = CoordinatedImageBacking::create(this, image); |
| 561 |
m_imageBackings.add(imageID, imageBacking); |
| 562 |
} else |
| 563 |
imageBacking = it->value; |
| 564 |
|
| 565 |
return imageBacking; |
| 566 |
} |
| 567 |
|
| 568 |
void LayerTreeCoordinator::createImageBacking(CoordinatedImageBackingID imageID) |
| 569 |
{ |
181 |
{ |
| 570 |
m_shouldSyncFrame = true; |
182 |
m_webPage->drawRect(graphicsContext, clipRect); |
| 571 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::CreateImageBacking(imageID)); |
|
|
| 572 |
} |
| 573 |
|
| 574 |
void LayerTreeCoordinator::updateImageBacking(CoordinatedImageBackingID imageID, const ShareableSurface::Handle& handle) |
| 575 |
{ |
| 576 |
m_shouldSyncFrame = true; |
| 577 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::UpdateImageBacking(imageID, handle)); |
| 578 |
} |
| 579 |
|
| 580 |
void LayerTreeCoordinator::clearImageBackingContents(CoordinatedImageBackingID imageID) |
| 581 |
{ |
| 582 |
m_shouldSyncFrame = true; |
| 583 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::ClearImageBackingContents(imageID)); |
| 584 |
} |
| 585 |
|
| 586 |
void LayerTreeCoordinator::removeImageBacking(CoordinatedImageBackingID imageID) |
| 587 |
{ |
| 588 |
if (m_isPurging) |
| 589 |
return; |
| 590 |
|
| 591 |
ASSERT(m_imageBackings.contains(imageID)); |
| 592 |
m_shouldSyncFrame = true; |
| 593 |
m_imageBackings.remove(imageID); |
| 594 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::RemoveImageBacking(imageID)); |
| 595 |
} |
| 596 |
|
| 597 |
void LayerTreeCoordinator::flushPendingImageBackingChanges() |
| 598 |
{ |
| 599 |
ImageBackingMap::iterator end = m_imageBackings.end(); |
| 600 |
for (ImageBackingMap::iterator iter = m_imageBackings.begin(); iter != end; ++iter) |
| 601 |
iter->value->update(); |
| 602 |
} |
| 603 |
|
| 604 |
void LayerTreeCoordinator::notifyAnimationStarted(const WebCore::GraphicsLayer*, double /* time */) |
| 605 |
{ |
| 606 |
} |
| 607 |
|
| 608 |
void LayerTreeCoordinator::notifyFlushRequired(const WebCore::GraphicsLayer*) |
| 609 |
{ |
| 610 |
} |
| 611 |
|
| 612 |
void LayerTreeCoordinator::paintContents(const WebCore::GraphicsLayer* graphicsLayer, WebCore::GraphicsContext& graphicsContext, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect) |
| 613 |
{ |
| 614 |
if (graphicsLayer == m_nonCompositedContentLayer) { |
| 615 |
m_webPage->drawRect(graphicsContext, clipRect); |
| 616 |
return; |
| 617 |
} |
| 618 |
|
| 619 |
if (graphicsLayer == m_pageOverlayLayer) { |
| 620 |
// Overlays contain transparent contents and won't clear the context as part of their rendering, so we do it here. |
| 621 |
graphicsContext.clearRect(clipRect); |
| 622 |
m_webPage->drawPageOverlay(graphicsContext, clipRect); |
| 623 |
return; |
| 624 |
} |
| 625 |
} |
183 |
} |
| 626 |
|
184 |
|
| 627 |
PassOwnPtr<GraphicsLayer> LayerTreeCoordinator::createGraphicsLayer(GraphicsLayerClient* client) |
185 |
void LayerTreeCoordinator::paintOverlayContents(WebCore::GraphicsContext& graphicsContext, const IntRect& clipRect) |
| 628 |
{ |
186 |
{ |
| 629 |
CoordinatedGraphicsLayer* layer = new CoordinatedGraphicsLayer(client); |
187 |
// Overlays contain transparent contents and won't clear the context as part of their rendering, so we do it here. |
| 630 |
layer->setCoordinator(this); |
188 |
graphicsContext.clearRect(clipRect); |
| 631 |
m_registeredLayers.add(layer); |
189 |
m_webPage->drawPageOverlay(graphicsContext, clipRect); |
| 632 |
layer->setContentsScale(m_contentsScale); |
|
|
| 633 |
layer->adjustVisibleRect(); |
| 634 |
return adoptPtr(layer); |
| 635 |
} |
190 |
} |
| 636 |
|
191 |
|
| 637 |
bool LayerTreeHost::supportsAcceleratedCompositing() |
192 |
bool LayerTreeHost::supportsAcceleratedCompositing() |
|
Lines 639-741
bool LayerTreeHost::supportsAcceleratedCompositing()
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp_sec7
|
| 639 |
return true; |
194 |
return true; |
| 640 |
} |
195 |
} |
| 641 |
|
196 |
|
| 642 |
void LayerTreeCoordinator::createTile(CoordinatedLayerID layerID, uint32_t tileID, const SurfaceUpdateInfo& updateInfo, const WebCore::IntRect& tileRect) |
|
|
| 643 |
{ |
| 644 |
m_shouldSyncFrame = true; |
| 645 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::CreateTileForLayer(layerID, tileID, tileRect, updateInfo)); |
| 646 |
} |
| 647 |
|
| 648 |
void LayerTreeCoordinator::updateTile(CoordinatedLayerID layerID, uint32_t tileID, const SurfaceUpdateInfo& updateInfo, const WebCore::IntRect& tileRect) |
| 649 |
{ |
| 650 |
m_shouldSyncFrame = true; |
| 651 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::UpdateTileForLayer(layerID, tileID, tileRect, updateInfo)); |
| 652 |
} |
| 653 |
|
| 654 |
void LayerTreeCoordinator::removeTile(CoordinatedLayerID layerID, uint32_t tileID) |
| 655 |
{ |
| 656 |
if (m_isPurging) |
| 657 |
return; |
| 658 |
m_shouldSyncFrame = true; |
| 659 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::RemoveTileForLayer(layerID, tileID)); |
| 660 |
} |
| 661 |
|
| 662 |
void LayerTreeCoordinator::createUpdateAtlas(int atlasID, const ShareableSurface::Handle& handle) |
| 663 |
{ |
| 664 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::CreateUpdateAtlas(atlasID, handle)); |
| 665 |
} |
| 666 |
|
| 667 |
void LayerTreeCoordinator::removeUpdateAtlas(int atlasID) |
| 668 |
{ |
| 669 |
if (m_isPurging) |
| 670 |
return; |
| 671 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::RemoveUpdateAtlas(atlasID)); |
| 672 |
} |
| 673 |
|
| 674 |
WebCore::FloatRect LayerTreeCoordinator::visibleContentsRect() const |
| 675 |
{ |
| 676 |
return m_visibleContentsRect; |
| 677 |
} |
| 678 |
|
| 679 |
|
| 680 |
void LayerTreeCoordinator::setLayerAnimations(CoordinatedLayerID layerID, const GraphicsLayerAnimations& animations) |
| 681 |
{ |
| 682 |
m_shouldSyncFrame = true; |
| 683 |
GraphicsLayerAnimations activeAnimations = animations.getActiveAnimations(); |
| 684 |
#if ENABLE(CSS_SHADERS) |
| 685 |
for (size_t i = 0; i < activeAnimations.animations().size(); ++i) { |
| 686 |
const KeyframeValueList& keyframes = animations.animations().at(i).keyframes(); |
| 687 |
if (keyframes.property() != AnimatedPropertyWebkitFilter) |
| 688 |
continue; |
| 689 |
for (size_t j = 0; j < keyframes.size(); ++j) { |
| 690 |
const FilterAnimationValue* filterValue = static_cast<const FilterAnimationValue*>(keyframes.at(i)); |
| 691 |
checkCustomFilterProgramProxies(*filterValue->value()); |
| 692 |
} |
| 693 |
} |
| 694 |
#endif |
| 695 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetLayerAnimations(layerID, activeAnimations)); |
| 696 |
} |
| 697 |
|
| 698 |
void LayerTreeCoordinator::setVisibleContentsRect(const FloatRect& rect, float scale, const FloatPoint& trajectoryVector) |
197 |
void LayerTreeCoordinator::setVisibleContentsRect(const FloatRect& rect, float scale, const FloatPoint& trajectoryVector) |
| 699 |
{ |
198 |
{ |
| 700 |
bool contentsRectDidChange = rect != m_visibleContentsRect; |
199 |
m_compositingCoordinator->setVisibleContentsRect(rect, scale, trajectoryVector); |
| 701 |
bool contentsScaleDidChange = scale != m_contentsScale; |
|
|
| 702 |
|
| 703 |
// A zero trajectoryVector indicates that tiles all around the viewport are requested. |
| 704 |
toCoordinatedGraphicsLayer(m_nonCompositedContentLayer.get())->setVisibleContentRectTrajectoryVector(trajectoryVector); |
| 705 |
|
| 706 |
if (contentsRectDidChange || contentsScaleDidChange) { |
| 707 |
m_visibleContentsRect = rect; |
| 708 |
m_contentsScale = scale; |
| 709 |
|
200 |
|
| 710 |
HashSet<WebCore::CoordinatedGraphicsLayer*>::iterator end = m_registeredLayers.end(); |
|
|
| 711 |
for (HashSet<WebCore::CoordinatedGraphicsLayer*>::iterator it = m_registeredLayers.begin(); it != end; ++it) { |
| 712 |
if (contentsScaleDidChange) |
| 713 |
(*it)->setContentsScale(scale); |
| 714 |
if (contentsRectDidChange) |
| 715 |
(*it)->adjustVisibleRect(); |
| 716 |
} |
| 717 |
} |
| 718 |
|
| 719 |
scheduleLayerFlush(); |
| 720 |
if (m_webPage->useFixedLayout()) { |
201 |
if (m_webPage->useFixedLayout()) { |
| 721 |
// Round the rect instead of enclosing it to make sure that its size stays |
202 |
// Round the rect instead of enclosing it to make sure that its size stays |
| 722 |
// the same while panning. This can have nasty effects on layout. |
203 |
// the same while panning. This can have nasty effects on layout. |
| 723 |
m_webPage->setFixedVisibleContentRect(roundedIntRect(rect)); |
204 |
m_webPage->setFixedVisibleContentRect(roundedIntRect(rect)); |
| 724 |
} |
205 |
} |
| 725 |
|
|
|
| 726 |
if (contentsRectDidChange) |
| 727 |
m_shouldSendScrollPositionUpdate = true; |
| 728 |
} |
206 |
} |
| 729 |
|
207 |
|
| 730 |
GraphicsLayerFactory* LayerTreeCoordinator::graphicsLayerFactory() |
208 |
GraphicsLayerFactory* LayerTreeCoordinator::graphicsLayerFactory() |
| 731 |
{ |
209 |
{ |
| 732 |
return this; |
210 |
return m_compositingCoordinator.get(); |
| 733 |
} |
211 |
} |
| 734 |
|
212 |
|
| 735 |
#if ENABLE(REQUEST_ANIMATION_FRAME) |
213 |
#if ENABLE(REQUEST_ANIMATION_FRAME) |
| 736 |
void LayerTreeCoordinator::scheduleAnimation() |
214 |
void LayerTreeCoordinator::scheduleAnimation() |
| 737 |
{ |
215 |
{ |
| 738 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::RequestAnimationFrame()); |
216 |
m_compositingCoordinatorMessageClient->requestAnimationFrame(); |
| 739 |
} |
217 |
} |
| 740 |
|
218 |
|
| 741 |
void LayerTreeCoordinator::animationFrameReady() |
219 |
void LayerTreeCoordinator::animationFrameReady() |
|
Lines 746-829
void LayerTreeCoordinator::animationFrameReady()
a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp_sec8
|
| 746 |
|
224 |
|
| 747 |
void LayerTreeCoordinator::renderNextFrame() |
225 |
void LayerTreeCoordinator::renderNextFrame() |
| 748 |
{ |
226 |
{ |
| 749 |
m_waitingForUIProcess = false; |
227 |
m_compositingCoordinator->renderNextFrame(); |
| 750 |
scheduleLayerFlush(); |
|
|
| 751 |
for (unsigned i = 0; i < m_updateAtlases.size(); ++i) |
| 752 |
m_updateAtlases[i]->didSwapBuffers(); |
| 753 |
} |
| 754 |
|
| 755 |
bool LayerTreeCoordinator::layerTreeTileUpdatesAllowed() const |
| 756 |
{ |
| 757 |
return !m_isSuspended && !m_waitingForUIProcess; |
| 758 |
} |
228 |
} |
| 759 |
|
229 |
|
| 760 |
void LayerTreeCoordinator::purgeBackingStores() |
230 |
void LayerTreeCoordinator::purgeBackingStores() |
| 761 |
{ |
231 |
{ |
| 762 |
TemporaryChange<bool> purgingToggle(m_isPurging, true); |
232 |
m_compositingCoordinator->purgeBackingStores(); |
| 763 |
|
|
|
| 764 |
HashSet<WebCore::CoordinatedGraphicsLayer*>::iterator end = m_registeredLayers.end(); |
| 765 |
for (HashSet<WebCore::CoordinatedGraphicsLayer*>::iterator it = m_registeredLayers.begin(); it != end; ++it) |
| 766 |
(*it)->purgeBackingStores(); |
| 767 |
|
| 768 |
m_imageBackings.clear(); |
| 769 |
m_updateAtlases.clear(); |
| 770 |
} |
| 771 |
|
| 772 |
PassOwnPtr<WebCore::GraphicsContext> LayerTreeCoordinator::beginContentUpdate(const WebCore::IntSize& size, ShareableBitmap::Flags flags, int& atlasID, WebCore::IntPoint& offset) |
| 773 |
{ |
| 774 |
OwnPtr<WebCore::GraphicsContext> graphicsContext; |
| 775 |
for (unsigned i = 0; i < m_updateAtlases.size(); ++i) { |
| 776 |
UpdateAtlas* atlas = m_updateAtlases[i].get(); |
| 777 |
if (atlas->flags() == flags) { |
| 778 |
// This will return null if there is no available buffer space. |
| 779 |
graphicsContext = atlas->beginPaintingOnAvailableBuffer(atlasID, size, offset); |
| 780 |
if (graphicsContext) |
| 781 |
return graphicsContext.release(); |
| 782 |
} |
| 783 |
} |
| 784 |
|
| 785 |
static const int ScratchBufferDimension = 1024; // Should be a power of two. |
| 786 |
m_updateAtlases.append(adoptPtr(new UpdateAtlas(this, ScratchBufferDimension, flags))); |
| 787 |
scheduleReleaseInactiveAtlases(); |
| 788 |
return m_updateAtlases.last()->beginPaintingOnAvailableBuffer(atlasID, size, offset); |
| 789 |
} |
| 790 |
|
| 791 |
const double ReleaseInactiveAtlasesTimerInterval = 0.5; |
| 792 |
|
| 793 |
void LayerTreeCoordinator::scheduleReleaseInactiveAtlases() |
| 794 |
{ |
| 795 |
if (!m_releaseInactiveAtlasesTimer.isActive()) |
| 796 |
m_releaseInactiveAtlasesTimer.startRepeating(ReleaseInactiveAtlasesTimerInterval); |
| 797 |
} |
| 798 |
|
| 799 |
void LayerTreeCoordinator::releaseInactiveAtlasesTimerFired(Timer<LayerTreeCoordinator>*) |
| 800 |
{ |
| 801 |
// We always want to keep one atlas for non-composited content. |
| 802 |
OwnPtr<UpdateAtlas> atlasToKeepAnyway; |
| 803 |
bool foundActiveAtlasForNonCompositedContent = false; |
| 804 |
for (int i = m_updateAtlases.size() - 1; i >= 0; --i) { |
| 805 |
UpdateAtlas* atlas = m_updateAtlases[i].get(); |
| 806 |
if (!atlas->isInUse()) |
| 807 |
atlas->addTimeInactive(ReleaseInactiveAtlasesTimerInterval); |
| 808 |
bool usableForNonCompositedContent = atlas->flags() == ShareableBitmap::NoFlags; |
| 809 |
if (atlas->isInactive()) { |
| 810 |
if (!foundActiveAtlasForNonCompositedContent && !atlasToKeepAnyway && usableForNonCompositedContent) |
| 811 |
atlasToKeepAnyway = m_updateAtlases[i].release(); |
| 812 |
m_updateAtlases.remove(i); |
| 813 |
} else if (usableForNonCompositedContent) |
| 814 |
foundActiveAtlasForNonCompositedContent = true; |
| 815 |
} |
| 816 |
|
| 817 |
if (!foundActiveAtlasForNonCompositedContent && atlasToKeepAnyway) |
| 818 |
m_updateAtlases.append(atlasToKeepAnyway.release()); |
| 819 |
|
| 820 |
if (m_updateAtlases.size() <= 1) |
| 821 |
m_releaseInactiveAtlasesTimer.stop(); |
| 822 |
} |
233 |
} |
| 823 |
|
234 |
|
| 824 |
void LayerTreeCoordinator::setBackgroundColor(const WebCore::Color& color) |
235 |
void LayerTreeCoordinator::setBackgroundColor(const WebCore::Color& color) |
| 825 |
{ |
236 |
{ |
| 826 |
m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetBackgroundColor(color)); |
237 |
m_compositingCoordinatorMessageClient->setBackgroundColor(color); |
| 827 |
} |
238 |
} |
| 828 |
|
239 |
|
| 829 |
} // namespace WebKit |
240 |
} // namespace WebKit |