Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositor.cpp

Issue 2748103015: Replace ASSERT with DCHECK in core/layout/<sub dirs> (Closed)
Patch Set: Rebase with latest Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 m_rootShouldAlwaysCompositeDirty(true), 81 m_rootShouldAlwaysCompositeDirty(true),
82 m_needsUpdateFixedBackground(false), 82 m_needsUpdateFixedBackground(false),
83 m_isTrackingRasterInvalidations( 83 m_isTrackingRasterInvalidations(
84 layoutView.frameView()->isTrackingPaintInvalidations()), 84 layoutView.frameView()->isTrackingPaintInvalidations()),
85 m_inOverlayFullscreenVideo(false), 85 m_inOverlayFullscreenVideo(false),
86 m_rootLayerAttachment(RootLayerUnattached) { 86 m_rootLayerAttachment(RootLayerUnattached) {
87 updateAcceleratedCompositingSettings(); 87 updateAcceleratedCompositingSettings();
88 } 88 }
89 89
90 PaintLayerCompositor::~PaintLayerCompositor() { 90 PaintLayerCompositor::~PaintLayerCompositor() {
91 ASSERT(m_rootLayerAttachment == RootLayerUnattached); 91 DCHECK_EQ(m_rootLayerAttachment, RootLayerUnattached);
92 } 92 }
93 93
94 bool PaintLayerCompositor::inCompositingMode() const { 94 bool PaintLayerCompositor::inCompositingMode() const {
95 // FIXME: This should assert that lifecycle is >= CompositingClean since 95 // FIXME: This should assert that lifecycle is >= CompositingClean since
96 // the last step of updateIfNeeded can set this bit to false. 96 // the last step of updateIfNeeded can set this bit to false.
97 ASSERT(m_layoutView.layer()->isAllowedToQueryCompositingState()); 97 DCHECK(m_layoutView.layer()->isAllowedToQueryCompositingState());
98 return m_compositing; 98 return m_compositing;
99 } 99 }
100 100
101 bool PaintLayerCompositor::staleInCompositingMode() const { 101 bool PaintLayerCompositor::staleInCompositingMode() const {
102 return m_compositing; 102 return m_compositing;
103 } 103 }
104 104
105 void PaintLayerCompositor::setCompositingModeEnabled(bool enable) { 105 void PaintLayerCompositor::setCompositingModeEnabled(bool enable) {
106 if (enable == m_compositing) 106 if (enable == m_compositing)
107 return; 107 return;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // TODO(bbudge) Remove this check when trusted Pepper plugins are gone. 204 // TODO(bbudge) Remove this check when trusted Pepper plugins are gone.
205 if (localFrame->document()->isActive() && 205 if (localFrame->document()->isActive() &&
206 !localFrame->contentLayoutItem().isNull()) 206 !localFrame->contentLayoutItem().isNull())
207 localFrame->contentLayoutItem() 207 localFrame->contentLayoutItem()
208 .compositor() 208 .compositor()
209 ->updateIfNeededRecursiveInternal(); 209 ->updateIfNeededRecursiveInternal();
210 } 210 }
211 211
212 TRACE_EVENT0("blink", "PaintLayerCompositor::updateIfNeededRecursive"); 212 TRACE_EVENT0("blink", "PaintLayerCompositor::updateIfNeededRecursive");
213 213
214 ASSERT(!m_layoutView.needsLayout()); 214 DCHECK(!m_layoutView.needsLayout());
215 215
216 ScriptForbiddenScope forbidScript; 216 ScriptForbiddenScope forbidScript;
217 217
218 // FIXME: enableCompositingModeIfNeeded can trigger a 218 // FIXME: enableCompositingModeIfNeeded can trigger a
219 // CompositingUpdateRebuildTree, which asserts that it's not 219 // CompositingUpdateRebuildTree, which asserts that it's not
220 // InCompositingUpdate. 220 // InCompositingUpdate.
221 enableCompositingModeIfNeeded(); 221 enableCompositingModeIfNeeded();
222 222
223 rootLayer()->updateDescendantDependentFlags(); 223 rootLayer()->updateDescendantDependentFlags();
224 224
225 m_layoutView.commitPendingSelection(); 225 m_layoutView.commitPendingSelection();
226 226
227 lifecycle().advanceTo(DocumentLifecycle::InCompositingUpdate); 227 lifecycle().advanceTo(DocumentLifecycle::InCompositingUpdate);
228 updateIfNeeded(); 228 updateIfNeeded();
229 lifecycle().advanceTo(DocumentLifecycle::CompositingClean); 229 lifecycle().advanceTo(DocumentLifecycle::CompositingClean);
230 230
231 DocumentAnimations::updateAnimations(m_layoutView.document(), 231 DocumentAnimations::updateAnimations(m_layoutView.document(),
232 DocumentLifecycle::CompositingClean); 232 DocumentLifecycle::CompositingClean);
233 233
234 m_layoutView.frameView() 234 m_layoutView.frameView()
235 ->getScrollableArea() 235 ->getScrollableArea()
236 ->updateCompositorScrollAnimations(); 236 ->updateCompositorScrollAnimations();
237 if (const FrameView::ScrollableAreaSet* animatingScrollableAreas = 237 if (const FrameView::ScrollableAreaSet* animatingScrollableAreas =
238 m_layoutView.frameView()->animatingScrollableAreas()) { 238 m_layoutView.frameView()->animatingScrollableAreas()) {
239 for (ScrollableArea* scrollableArea : *animatingScrollableAreas) 239 for (ScrollableArea* scrollableArea : *animatingScrollableAreas)
240 scrollableArea->updateCompositorScrollAnimations(); 240 scrollableArea->updateCompositorScrollAnimations();
241 } 241 }
242 242
243 #if DCHECK_IS_ON() 243 #if DCHECK_IS_ON()
244 ASSERT(lifecycle().state() == DocumentLifecycle::CompositingClean); 244 DCHECK_EQ(lifecycle().state(), DocumentLifecycle::CompositingClean);
245 assertNoUnresolvedDirtyBits(); 245 assertNoUnresolvedDirtyBits();
246 for (Frame* child = m_layoutView.frameView()->frame().tree().firstChild(); 246 for (Frame* child = m_layoutView.frameView()->frame().tree().firstChild();
247 child; child = child->tree().nextSibling()) { 247 child; child = child->tree().nextSibling()) {
248 if (!child->isLocalFrame()) 248 if (!child->isLocalFrame())
249 continue; 249 continue;
250 LocalFrame* localFrame = toLocalFrame(child); 250 LocalFrame* localFrame = toLocalFrame(child);
251 if (localFrame->shouldThrottleRendering() || 251 if (localFrame->shouldThrottleRendering() ||
252 localFrame->contentLayoutItem().isNull()) 252 localFrame->contentLayoutItem().isNull())
253 continue; 253 continue;
254 localFrame->contentLayoutItem().compositor()->assertNoUnresolvedDirtyBits(); 254 localFrame->contentLayoutItem().compositor()->assertNoUnresolvedDirtyBits();
255 } 255 }
256 #endif 256 #endif
257 } 257 }
258 258
259 void PaintLayerCompositor::setNeedsCompositingUpdate( 259 void PaintLayerCompositor::setNeedsCompositingUpdate(
260 CompositingUpdateType updateType) { 260 CompositingUpdateType updateType) {
261 ASSERT(updateType != CompositingUpdateNone); 261 DCHECK_NE(updateType, CompositingUpdateNone);
262 m_pendingUpdateType = std::max(m_pendingUpdateType, updateType); 262 m_pendingUpdateType = std::max(m_pendingUpdateType, updateType);
263 if (Page* page = this->page()) 263 if (Page* page = this->page())
264 page->animator().scheduleVisualUpdate(m_layoutView.frame()); 264 page->animator().scheduleVisualUpdate(m_layoutView.frame());
265 lifecycle().ensureStateAtMost(DocumentLifecycle::LayoutClean); 265 lifecycle().ensureStateAtMost(DocumentLifecycle::LayoutClean);
266 } 266 }
267 267
268 void PaintLayerCompositor::didLayout() { 268 void PaintLayerCompositor::didLayout() {
269 // FIXME: Technically we only need to do this when the FrameView's 269 // FIXME: Technically we only need to do this when the FrameView's
270 // isScrollable method would return a different value. 270 // isScrollable method would return a different value.
271 m_rootShouldAlwaysCompositeDirty = true; 271 m_rootShouldAlwaysCompositeDirty = true;
272 enableCompositingModeIfNeeded(); 272 enableCompositingModeIfNeeded();
273 273
274 // FIXME: Rather than marking the entire LayoutView as dirty, we should 274 // FIXME: Rather than marking the entire LayoutView as dirty, we should
275 // track which Layers moved during layout and only dirty those 275 // track which Layers moved during layout and only dirty those
276 // specific Layers. 276 // specific Layers.
277 rootLayer()->setNeedsCompositingInputsUpdate(); 277 rootLayer()->setNeedsCompositingInputsUpdate();
278 } 278 }
279 279
280 #if DCHECK_IS_ON() 280 #if DCHECK_IS_ON()
281 281
282 void PaintLayerCompositor::assertNoUnresolvedDirtyBits() { 282 void PaintLayerCompositor::assertNoUnresolvedDirtyBits() {
283 ASSERT(m_pendingUpdateType == CompositingUpdateNone); 283 DCHECK_EQ(m_pendingUpdateType, CompositingUpdateNone);
284 ASSERT(!m_rootShouldAlwaysCompositeDirty); 284 DCHECK(!m_rootShouldAlwaysCompositeDirty);
285 } 285 }
286 286
287 #endif 287 #endif
288 288
289 void PaintLayerCompositor::applyOverlayFullscreenVideoAdjustmentIfNeeded() { 289 void PaintLayerCompositor::applyOverlayFullscreenVideoAdjustmentIfNeeded() {
290 m_inOverlayFullscreenVideo = false; 290 m_inOverlayFullscreenVideo = false;
291 if (!m_rootContentLayer) 291 if (!m_rootContentLayer)
292 return; 292 return;
293 293
294 bool isLocalRoot = m_layoutView.frame()->isLocalRoot(); 294 bool isLocalRoot = m_layoutView.frame()->isLocalRoot();
(...skipping 24 matching lines...) Expand all
319 319
320 m_rootContentLayer->removeAllChildren(); 320 m_rootContentLayer->removeAllChildren();
321 m_overflowControlsHostLayer->addChild(videoLayer); 321 m_overflowControlsHostLayer->addChild(videoLayer);
322 if (GraphicsLayer* backgroundLayer = fixedRootBackgroundLayer()) 322 if (GraphicsLayer* backgroundLayer = fixedRootBackgroundLayer())
323 backgroundLayer->removeFromParent(); 323 backgroundLayer->removeFromParent();
324 m_inOverlayFullscreenVideo = true; 324 m_inOverlayFullscreenVideo = true;
325 } 325 }
326 326
327 void PaintLayerCompositor::updateWithoutAcceleratedCompositing( 327 void PaintLayerCompositor::updateWithoutAcceleratedCompositing(
328 CompositingUpdateType updateType) { 328 CompositingUpdateType updateType) {
329 ASSERT(!hasAcceleratedCompositing()); 329 DCHECK(!hasAcceleratedCompositing());
330 330
331 if (updateType >= CompositingUpdateAfterCompositingInputChange) 331 if (updateType >= CompositingUpdateAfterCompositingInputChange)
332 CompositingInputsUpdater(rootLayer()).update(); 332 CompositingInputsUpdater(rootLayer()).update();
333 333
334 #if DCHECK_IS_ON() 334 #if DCHECK_IS_ON()
335 CompositingInputsUpdater::assertNeedsCompositingInputsUpdateBitsCleared( 335 CompositingInputsUpdater::assertNeedsCompositingInputsUpdateBitsCleared(
336 rootLayer()); 336 rootLayer());
337 #endif 337 #endif
338 } 338 }
339 339
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 bool PaintLayerCompositor::allocateOrClearCompositedLayerMapping( 494 bool PaintLayerCompositor::allocateOrClearCompositedLayerMapping(
495 PaintLayer* layer, 495 PaintLayer* layer,
496 const CompositingStateTransitionType compositedLayerUpdate) { 496 const CompositingStateTransitionType compositedLayerUpdate) {
497 bool compositedLayerMappingChanged = false; 497 bool compositedLayerMappingChanged = false;
498 498
499 // FIXME: It would be nice to directly use the layer's compositing reason, 499 // FIXME: It would be nice to directly use the layer's compositing reason,
500 // but allocateOrClearCompositedLayerMapping also gets called without having 500 // but allocateOrClearCompositedLayerMapping also gets called without having
501 // updated compositing requirements fully. 501 // updated compositing requirements fully.
502 switch (compositedLayerUpdate) { 502 switch (compositedLayerUpdate) {
503 case AllocateOwnCompositedLayerMapping: 503 case AllocateOwnCompositedLayerMapping:
504 ASSERT(!layer->hasCompositedLayerMapping()); 504 DCHECK(!layer->hasCompositedLayerMapping());
505 setCompositingModeEnabled(true); 505 setCompositingModeEnabled(true);
506 506
507 // If we need to issue paint invalidations, do so before allocating the 507 // If we need to issue paint invalidations, do so before allocating the
508 // compositedLayerMapping and clearing out the groupedMapping. 508 // compositedLayerMapping and clearing out the groupedMapping.
509 paintInvalidationOnCompositingChange(layer); 509 paintInvalidationOnCompositingChange(layer);
510 510
511 // If this layer was previously squashed, we need to remove its reference 511 // If this layer was previously squashed, we need to remove its reference
512 // to a groupedMapping right away, so that computing paint invalidation 512 // to a groupedMapping right away, so that computing paint invalidation
513 // rects will know the layer's correct compositingState. 513 // rects will know the layer's correct compositingState.
514 // FIXME: do we need to also remove the layer from it's location in the 514 // FIXME: do we need to also remove the layer from it's location in the
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 683
684 bool PaintLayerCompositor::scrollingLayerDidChange(PaintLayer* layer) { 684 bool PaintLayerCompositor::scrollingLayerDidChange(PaintLayer* layer) {
685 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator()) 685 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())
686 return scrollingCoordinator->scrollableAreaScrollLayerDidChange( 686 return scrollingCoordinator->scrollableAreaScrollLayerDidChange(
687 layer->getScrollableArea()); 687 layer->getScrollableArea());
688 return false; 688 return false;
689 } 689 }
690 690
691 std::unique_ptr<JSONObject> PaintLayerCompositor::layerTreeAsJSON( 691 std::unique_ptr<JSONObject> PaintLayerCompositor::layerTreeAsJSON(
692 LayerTreeFlags flags) const { 692 LayerTreeFlags flags) const {
693 ASSERT(lifecycle().state() >= DocumentLifecycle::PaintInvalidationClean || 693 DCHECK(lifecycle().state() >= DocumentLifecycle::PaintInvalidationClean ||
694 m_layoutView.frameView()->shouldThrottleRendering()); 694 m_layoutView.frameView()->shouldThrottleRendering());
695 695
696 // We skip dumping the scroll and clip layers to keep layerTreeAsText output 696 // We skip dumping the scroll and clip layers to keep layerTreeAsText output
697 // similar between platforms (unless we explicitly request dumping from the 697 // similar between platforms (unless we explicitly request dumping from the
698 // root. 698 // root.
699 GraphicsLayer* rootLayer = m_rootContentLayer.get(); 699 GraphicsLayer* rootLayer = m_rootContentLayer.get();
700 if (!rootLayer) 700 if (!rootLayer)
701 rootLayer = rootGraphicsLayer(); 701 rootLayer = rootGraphicsLayer();
702 702
703 if (!rootLayer) 703 if (!rootLayer)
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 graphicsLayer->contentsClippingMaskLayer()) { 980 graphicsLayer->contentsClippingMaskLayer()) {
981 setTracksRasterInvalidationsRecursive(clippingMaskLayer, 981 setTracksRasterInvalidationsRecursive(clippingMaskLayer,
982 tracksPaintInvalidations); 982 tracksPaintInvalidations);
983 } 983 }
984 } 984 }
985 985
986 void PaintLayerCompositor::setTracksRasterInvalidations( 986 void PaintLayerCompositor::setTracksRasterInvalidations(
987 bool tracksRasterInvalidations) { 987 bool tracksRasterInvalidations) {
988 #if DCHECK_IS_ON() 988 #if DCHECK_IS_ON()
989 FrameView* view = m_layoutView.frameView(); 989 FrameView* view = m_layoutView.frameView();
990 ASSERT(lifecycle().state() == DocumentLifecycle::PaintClean || 990 DCHECK(lifecycle().state() == DocumentLifecycle::PaintClean ||
991 (view && view->shouldThrottleRendering())); 991 (view && view->shouldThrottleRendering()));
992 #endif 992 #endif
993 993
994 m_isTrackingRasterInvalidations = tracksRasterInvalidations; 994 m_isTrackingRasterInvalidations = tracksRasterInvalidations;
995 if (GraphicsLayer* rootLayer = rootGraphicsLayer()) 995 if (GraphicsLayer* rootLayer = rootGraphicsLayer())
996 setTracksRasterInvalidationsRecursive(rootLayer, tracksRasterInvalidations); 996 setTracksRasterInvalidationsRecursive(rootLayer, tracksRasterInvalidations);
997 } 997 }
998 998
999 bool PaintLayerCompositor::isTrackingRasterInvalidations() const { 999 bool PaintLayerCompositor::isTrackingRasterInvalidations() const {
1000 return m_isTrackingRasterInvalidations; 1000 return m_isTrackingRasterInvalidations;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 1102
1103 // FIXME: with rootLayerScrolls, we probably don't even need 1103 // FIXME: with rootLayerScrolls, we probably don't even need
1104 // m_rootContentLayer? 1104 // m_rootContentLayer?
1105 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 1105 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
1106 // Need to clip to prevent transformed content showing outside this frame 1106 // Need to clip to prevent transformed content showing outside this frame
1107 m_rootContentLayer->setMasksToBounds(true); 1107 m_rootContentLayer->setMasksToBounds(true);
1108 } 1108 }
1109 } 1109 }
1110 1110
1111 if (shouldCreateOwnLayers && !m_overflowControlsHostLayer) { 1111 if (shouldCreateOwnLayers && !m_overflowControlsHostLayer) {
1112 ASSERT(!m_scrollLayer); 1112 DCHECK(!m_scrollLayer);
1113 ASSERT(!m_containerLayer); 1113 DCHECK(!m_containerLayer);
1114 1114
1115 // Create a layer to host the clipping layer and the overflow controls 1115 // Create a layer to host the clipping layer and the overflow controls
1116 // layers. 1116 // layers.
1117 m_overflowControlsHostLayer = GraphicsLayer::create(this); 1117 m_overflowControlsHostLayer = GraphicsLayer::create(this);
1118 1118
1119 // Clip iframe's overflow controls layer. 1119 // Clip iframe's overflow controls layer.
1120 bool containerMasksToBounds = !m_layoutView.frame()->isLocalRoot(); 1120 bool containerMasksToBounds = !m_layoutView.frame()->isLocalRoot();
1121 m_overflowControlsHostLayer->setMasksToBounds(containerMasksToBounds); 1121 m_overflowControlsHostLayer->setMasksToBounds(containerMasksToBounds);
1122 1122
1123 // Create a clipping layer if this is an iframe or settings require to clip. 1123 // Create a clipping layer if this is an iframe or settings require to clip.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 if (m_layerForScrollCorner) { 1176 if (m_layerForScrollCorner) {
1177 m_layerForScrollCorner = nullptr; 1177 m_layerForScrollCorner = nullptr;
1178 m_layoutView.frameView()->setScrollCornerNeedsPaintInvalidation(); 1178 m_layoutView.frameView()->setScrollCornerNeedsPaintInvalidation();
1179 } 1179 }
1180 1180
1181 if (m_overflowControlsHostLayer) { 1181 if (m_overflowControlsHostLayer) {
1182 m_overflowControlsHostLayer = nullptr; 1182 m_overflowControlsHostLayer = nullptr;
1183 m_containerLayer = nullptr; 1183 m_containerLayer = nullptr;
1184 m_scrollLayer = nullptr; 1184 m_scrollLayer = nullptr;
1185 } 1185 }
1186 ASSERT(!m_scrollLayer); 1186 DCHECK(!m_scrollLayer);
1187 m_rootContentLayer = nullptr; 1187 m_rootContentLayer = nullptr;
1188 } 1188 }
1189 1189
1190 void PaintLayerCompositor::attachRootLayer() { 1190 void PaintLayerCompositor::attachRootLayer() {
1191 // In Slimming Paint v2, PaintArtifactCompositor is responsible for the root 1191 // In Slimming Paint v2, PaintArtifactCompositor is responsible for the root
1192 // layer. 1192 // layer.
1193 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 1193 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
1194 return; 1194 return;
1195 1195
1196 if (m_layoutView.frame()->isLocalRoot()) { 1196 if (m_layoutView.frame()->isLocalRoot()) {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 } else if (graphicsLayer == m_scrollLayer.get()) { 1306 } else if (graphicsLayer == m_scrollLayer.get()) {
1307 name = "Frame Scrolling Layer"; 1307 name = "Frame Scrolling Layer";
1308 } else { 1308 } else {
1309 NOTREACHED(); 1309 NOTREACHED();
1310 } 1310 }
1311 1311
1312 return name; 1312 return name;
1313 } 1313 }
1314 1314
1315 } // namespace blink 1315 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698