Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 | 130 |
| 131 #if ENABLE(ASSERT) | 131 #if ENABLE(ASSERT) |
| 132 if (m_client) | 132 if (m_client) |
| 133 m_client->verifyNotPainting(); | 133 m_client->verifyNotPainting(); |
| 134 #endif | 134 #endif |
| 135 | 135 |
| 136 removeAllChildren(); | 136 removeAllChildren(); |
| 137 removeFromParent(); | 137 removeFromParent(); |
| 138 | 138 |
| 139 rasterInvalidationTrackingMap().remove(this); | 139 rasterInvalidationTrackingMap().remove(this); |
| 140 ASSERT(!m_parent); | 140 DCHECK(!m_parent); |
| 141 } | 141 } |
| 142 | 142 |
| 143 LayoutRect GraphicsLayer::visualRect() const { | 143 LayoutRect GraphicsLayer::visualRect() const { |
| 144 LayoutRect bounds = LayoutRect(FloatPoint(), size()); | 144 LayoutRect bounds = LayoutRect(FloatPoint(), size()); |
| 145 bounds.move(offsetFromLayoutObjectWithSubpixelAccumulation()); | 145 bounds.move(offsetFromLayoutObjectWithSubpixelAccumulation()); |
| 146 return bounds; | 146 return bounds; |
| 147 } | 147 } |
| 148 | 148 |
| 149 void GraphicsLayer::setHasWillChangeTransformHint(bool hasWillChangeTransform) { | 149 void GraphicsLayer::setHasWillChangeTransformHint(bool hasWillChangeTransform) { |
| 150 m_layer->layer()->setHasWillChangeTransformHint(hasWillChangeTransform); | 150 m_layer->layer()->setHasWillChangeTransformHint(hasWillChangeTransform); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void GraphicsLayer::setPreferredRasterBounds(const IntSize& bounds) { | 153 void GraphicsLayer::setPreferredRasterBounds(const IntSize& bounds) { |
| 154 m_preferredRasterBounds = bounds; | 154 m_preferredRasterBounds = bounds; |
| 155 m_hasPreferredRasterBounds = true; | 155 m_hasPreferredRasterBounds = true; |
| 156 m_layer->layer()->setPreferredRasterBounds(bounds); | 156 m_layer->layer()->setPreferredRasterBounds(bounds); |
| 157 } | 157 } |
| 158 | 158 |
| 159 void GraphicsLayer::clearPreferredRasterBounds() { | 159 void GraphicsLayer::clearPreferredRasterBounds() { |
| 160 m_preferredRasterBounds = IntSize(); | 160 m_preferredRasterBounds = IntSize(); |
| 161 m_hasPreferredRasterBounds = false; | 161 m_hasPreferredRasterBounds = false; |
| 162 m_layer->layer()->clearPreferredRasterBounds(); | 162 m_layer->layer()->clearPreferredRasterBounds(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void GraphicsLayer::setParent(GraphicsLayer* layer) { | 165 void GraphicsLayer::setParent(GraphicsLayer* layer) { |
| 166 ASSERT(!layer || !layer->hasAncestor(this)); | 166 #if DCHECK_IS_ON() // DCHECK references it's condition even when not enabled |
| 167 DCHECK(!layer || !layer->hasAncestor(this)); | |
| 168 #endif | |
|
Stephen Chennney
2016/11/29 19:51:38
The way to handle this is taken from https://coder
| |
| 167 m_parent = layer; | 169 m_parent = layer; |
| 168 } | 170 } |
| 169 | 171 |
| 170 #if ENABLE(ASSERT) | 172 #if DCHECK_IS_ON() |
| 171 | 173 |
| 172 bool GraphicsLayer::hasAncestor(GraphicsLayer* ancestor) const { | 174 bool GraphicsLayer::hasAncestor(GraphicsLayer* ancestor) const { |
| 173 for (GraphicsLayer* curr = parent(); curr; curr = curr->parent()) { | 175 for (GraphicsLayer* curr = parent(); curr; curr = curr->parent()) { |
| 174 if (curr == ancestor) | 176 if (curr == ancestor) |
| 175 return true; | 177 return true; |
| 176 } | 178 } |
| 177 | 179 |
| 178 return false; | 180 return false; |
| 179 } | 181 } |
| 180 | 182 |
| 181 #endif | 183 #endif |
| 182 | 184 |
| 183 bool GraphicsLayer::setChildren(const GraphicsLayerVector& newChildren) { | 185 bool GraphicsLayer::setChildren(const GraphicsLayerVector& newChildren) { |
| 184 // If the contents of the arrays are the same, nothing to do. | 186 // If the contents of the arrays are the same, nothing to do. |
| 185 if (newChildren == m_children) | 187 if (newChildren == m_children) |
| 186 return false; | 188 return false; |
| 187 | 189 |
| 188 removeAllChildren(); | 190 removeAllChildren(); |
| 189 | 191 |
| 190 size_t listSize = newChildren.size(); | 192 size_t listSize = newChildren.size(); |
| 191 for (size_t i = 0; i < listSize; ++i) | 193 for (size_t i = 0; i < listSize; ++i) |
| 192 addChildInternal(newChildren[i]); | 194 addChildInternal(newChildren[i]); |
| 193 | 195 |
| 194 updateChildList(); | 196 updateChildList(); |
| 195 | 197 |
| 196 return true; | 198 return true; |
| 197 } | 199 } |
| 198 | 200 |
| 199 void GraphicsLayer::addChildInternal(GraphicsLayer* childLayer) { | 201 void GraphicsLayer::addChildInternal(GraphicsLayer* childLayer) { |
| 200 ASSERT(childLayer != this); | 202 DCHECK_NE(childLayer, this); |
| 201 | 203 |
| 202 if (childLayer->parent()) | 204 if (childLayer->parent()) |
| 203 childLayer->removeFromParent(); | 205 childLayer->removeFromParent(); |
| 204 | 206 |
| 205 childLayer->setParent(this); | 207 childLayer->setParent(this); |
| 206 m_children.append(childLayer); | 208 m_children.append(childLayer); |
| 207 | 209 |
| 208 // Don't call updateChildList here, this function is used in cases where it | 210 // Don't call updateChildList here, this function is used in cases where it |
| 209 // should not be called until all children are processed. | 211 // should not be called until all children are processed. |
| 210 } | 212 } |
| 211 | 213 |
| 212 void GraphicsLayer::addChild(GraphicsLayer* childLayer) { | 214 void GraphicsLayer::addChild(GraphicsLayer* childLayer) { |
| 213 addChildInternal(childLayer); | 215 addChildInternal(childLayer); |
| 214 updateChildList(); | 216 updateChildList(); |
| 215 } | 217 } |
| 216 | 218 |
| 217 void GraphicsLayer::addChildBelow(GraphicsLayer* childLayer, | 219 void GraphicsLayer::addChildBelow(GraphicsLayer* childLayer, |
| 218 GraphicsLayer* sibling) { | 220 GraphicsLayer* sibling) { |
| 219 ASSERT(childLayer != this); | 221 DCHECK_NE(childLayer, this); |
| 220 childLayer->removeFromParent(); | 222 childLayer->removeFromParent(); |
| 221 | 223 |
| 222 bool found = false; | 224 bool found = false; |
| 223 for (unsigned i = 0; i < m_children.size(); i++) { | 225 for (unsigned i = 0; i < m_children.size(); i++) { |
| 224 if (sibling == m_children[i]) { | 226 if (sibling == m_children[i]) { |
| 225 m_children.insert(i, childLayer); | 227 m_children.insert(i, childLayer); |
| 226 found = true; | 228 found = true; |
| 227 break; | 229 break; |
| 228 } | 230 } |
| 229 } | 231 } |
| 230 | 232 |
| 231 childLayer->setParent(this); | 233 childLayer->setParent(this); |
| 232 | 234 |
| 233 if (!found) | 235 if (!found) |
| 234 m_children.append(childLayer); | 236 m_children.append(childLayer); |
| 235 | 237 |
| 236 updateChildList(); | 238 updateChildList(); |
| 237 } | 239 } |
| 238 | 240 |
| 239 void GraphicsLayer::removeAllChildren() { | 241 void GraphicsLayer::removeAllChildren() { |
| 240 while (!m_children.isEmpty()) { | 242 while (!m_children.isEmpty()) { |
| 241 GraphicsLayer* curLayer = m_children.back(); | 243 GraphicsLayer* curLayer = m_children.back(); |
| 242 ASSERT(curLayer->parent()); | 244 DCHECK(curLayer->parent()); |
| 243 curLayer->removeFromParent(); | 245 curLayer->removeFromParent(); |
| 244 } | 246 } |
| 245 } | 247 } |
| 246 | 248 |
| 247 void GraphicsLayer::removeFromParent() { | 249 void GraphicsLayer::removeFromParent() { |
| 248 if (m_parent) { | 250 if (m_parent) { |
| 249 // We use reverseFind so that removeAllChildren() isn't n^2. | 251 // We use reverseFind so that removeAllChildren() isn't n^2. |
| 250 m_parent->m_children.remove(m_parent->m_children.reverseFind(this)); | 252 m_parent->m_children.remove(m_parent->m_children.reverseFind(this)); |
| 251 setParent(0); | 253 setParent(0); |
| 252 } | 254 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 tracking.lastPaintedPicture = std::move(newPicture); | 299 tracking.lastPaintedPicture = std::move(newPicture); |
| 298 tracking.lastInterestRect = m_previousInterestRect; | 300 tracking.lastInterestRect = m_previousInterestRect; |
| 299 tracking.rasterInvalidationRegionSinceLastPaint = Region(); | 301 tracking.rasterInvalidationRegionSinceLastPaint = Region(); |
| 300 } | 302 } |
| 301 } | 303 } |
| 302 } | 304 } |
| 303 | 305 |
| 304 bool GraphicsLayer::paintWithoutCommit( | 306 bool GraphicsLayer::paintWithoutCommit( |
| 305 const IntRect* interestRect, | 307 const IntRect* interestRect, |
| 306 GraphicsContext::DisabledMode disabledMode) { | 308 GraphicsContext::DisabledMode disabledMode) { |
| 307 ASSERT(drawsContent()); | 309 DCHECK(drawsContent()); |
| 308 | 310 |
| 309 if (!m_client) | 311 if (!m_client) |
| 310 return false; | 312 return false; |
| 311 if (firstPaintInvalidationTrackingEnabled()) | 313 if (firstPaintInvalidationTrackingEnabled()) |
| 312 m_debugInfo.clearAnnotatedInvalidateRects(); | 314 m_debugInfo.clearAnnotatedInvalidateRects(); |
| 313 incrementPaintCount(); | 315 incrementPaintCount(); |
| 314 | 316 |
| 315 IntRect newInterestRect; | 317 IntRect newInterestRect; |
| 316 if (!interestRect) { | 318 if (!interestRect) { |
| 317 newInterestRect = | 319 newInterestRect = |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 420 | 422 |
| 421 void GraphicsLayer::registerContentsLayer(WebLayer* layer) { | 423 void GraphicsLayer::registerContentsLayer(WebLayer* layer) { |
| 422 if (!s_registeredLayerSet) | 424 if (!s_registeredLayerSet) |
| 423 s_registeredLayerSet = new HashSet<int>; | 425 s_registeredLayerSet = new HashSet<int>; |
| 424 if (s_registeredLayerSet->contains(layer->id())) | 426 if (s_registeredLayerSet->contains(layer->id())) |
| 425 CRASH(); | 427 CRASH(); |
| 426 s_registeredLayerSet->add(layer->id()); | 428 s_registeredLayerSet->add(layer->id()); |
| 427 } | 429 } |
| 428 | 430 |
| 429 void GraphicsLayer::unregisterContentsLayer(WebLayer* layer) { | 431 void GraphicsLayer::unregisterContentsLayer(WebLayer* layer) { |
| 430 ASSERT(s_registeredLayerSet); | 432 DCHECK(s_registeredLayerSet); |
| 431 if (!s_registeredLayerSet->contains(layer->id())) | 433 if (!s_registeredLayerSet->contains(layer->id())) |
| 432 CRASH(); | 434 CRASH(); |
| 433 s_registeredLayerSet->remove(layer->id()); | 435 s_registeredLayerSet->remove(layer->id()); |
| 434 } | 436 } |
| 435 | 437 |
| 436 void GraphicsLayer::setContentsTo(WebLayer* layer) { | 438 void GraphicsLayer::setContentsTo(WebLayer* layer) { |
| 437 bool childrenChanged = false; | 439 bool childrenChanged = false; |
| 438 if (layer) { | 440 if (layer) { |
| 439 ASSERT(s_registeredLayerSet); | 441 DCHECK(s_registeredLayerSet); |
| 440 if (!s_registeredLayerSet->contains(layer->id())) | 442 if (!s_registeredLayerSet->contains(layer->id())) |
| 441 CRASH(); | 443 CRASH(); |
| 442 if (m_contentsLayerId != layer->id()) { | 444 if (m_contentsLayerId != layer->id()) { |
| 443 setupContentsLayer(layer); | 445 setupContentsLayer(layer); |
| 444 childrenChanged = true; | 446 childrenChanged = true; |
| 445 } | 447 } |
| 446 updateContentsRect(); | 448 updateContentsRect(); |
| 447 } else { | 449 } else { |
| 448 if (m_contentsLayer) { | 450 if (m_contentsLayer) { |
| 449 childrenChanged = true; | 451 childrenChanged = true; |
| 450 | 452 |
| 451 // The old contents layer will be removed via updateChildList. | 453 // The old contents layer will be removed via updateChildList. |
| 452 m_contentsLayer = 0; | 454 m_contentsLayer = 0; |
| 453 m_contentsLayerId = 0; | 455 m_contentsLayerId = 0; |
| 454 } | 456 } |
| 455 } | 457 } |
| 456 | 458 |
| 457 if (childrenChanged) | 459 if (childrenChanged) |
| 458 updateChildList(); | 460 updateChildList(); |
| 459 } | 461 } |
| 460 | 462 |
| 461 void GraphicsLayer::setupContentsLayer(WebLayer* contentsLayer) { | 463 void GraphicsLayer::setupContentsLayer(WebLayer* contentsLayer) { |
| 462 ASSERT(contentsLayer); | 464 DCHECK(contentsLayer); |
| 463 m_contentsLayer = contentsLayer; | 465 m_contentsLayer = contentsLayer; |
| 464 m_contentsLayerId = m_contentsLayer->id(); | 466 m_contentsLayerId = m_contentsLayer->id(); |
| 465 | 467 |
| 466 m_contentsLayer->setLayerClient(this); | 468 m_contentsLayer->setLayerClient(this); |
| 467 m_contentsLayer->setTransformOrigin(FloatPoint3D()); | 469 m_contentsLayer->setTransformOrigin(FloatPoint3D()); |
| 468 m_contentsLayer->setUseParentBackfaceVisibility(true); | 470 m_contentsLayer->setUseParentBackfaceVisibility(true); |
| 469 | 471 |
| 470 // It is necessary to call setDrawsContent as soon as we receive the new | 472 // It is necessary to call setDrawsContent as soon as we receive the new |
| 471 // contentsLayer, for the correctness of early exit conditions in | 473 // contentsLayer, for the correctness of early exit conditions in |
| 472 // setDrawsContent() and setContentsVisible(). | 474 // setDrawsContent() and setContentsVisible(). |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 650 m_transformOrigin != | 652 m_transformOrigin != |
| 651 FloatPoint3D(m_size.width() * 0.5f, m_size.height() * 0.5f, 0)) | 653 FloatPoint3D(m_size.width() * 0.5f, m_size.height() * 0.5f, 0)) |
| 652 json->setArray("transformOrigin", pointAsJSONArray(m_transformOrigin)); | 654 json->setArray("transformOrigin", pointAsJSONArray(m_transformOrigin)); |
| 653 | 655 |
| 654 if (m_size != IntSize()) | 656 if (m_size != IntSize()) |
| 655 json->setArray("bounds", sizeAsJSONArray(m_size)); | 657 json->setArray("bounds", sizeAsJSONArray(m_size)); |
| 656 | 658 |
| 657 if (m_opacity != 1) | 659 if (m_opacity != 1) |
| 658 json->setDouble("opacity", m_opacity); | 660 json->setDouble("opacity", m_opacity); |
| 659 | 661 |
| 660 if (m_blendMode != WebBlendModeNormal) | 662 if (m_blendMode != WebBlendModeNormal) { |
| 661 json->setString("blendMode", | 663 json->setString("blendMode", |
| 662 compositeOperatorName(CompositeSourceOver, m_blendMode)); | 664 compositeOperatorName(CompositeSourceOver, m_blendMode)); |
| 665 } | |
| 663 | 666 |
| 664 if (m_isRootForIsolatedGroup) | 667 if (m_isRootForIsolatedGroup) |
| 665 json->setBoolean("isolate", m_isRootForIsolatedGroup); | 668 json->setBoolean("isolate", m_isRootForIsolatedGroup); |
| 666 | 669 |
| 667 if (m_contentsOpaque) | 670 if (m_contentsOpaque) |
| 668 json->setBoolean("contentsOpaque", m_contentsOpaque); | 671 json->setBoolean("contentsOpaque", m_contentsOpaque); |
| 669 | 672 |
| 670 if (!m_shouldFlattenTransform) | 673 if (!m_shouldFlattenTransform) |
| 671 json->setBoolean("shouldFlattenTransform", m_shouldFlattenTransform); | 674 json->setBoolean("shouldFlattenTransform", m_shouldFlattenTransform); |
| 672 | 675 |
| 673 if (m_renderingContext3d) { | 676 if (m_renderingContext3d) { |
| 674 RenderingContextMap::const_iterator it = | 677 RenderingContextMap::const_iterator it = |
| 675 renderingContextMap.find(m_renderingContext3d); | 678 renderingContextMap.find(m_renderingContext3d); |
| 676 int contextId = renderingContextMap.size() + 1; | 679 int contextId = renderingContextMap.size() + 1; |
| 677 if (it == renderingContextMap.end()) | 680 if (it == renderingContextMap.end()) |
| 678 renderingContextMap.set(m_renderingContext3d, contextId); | 681 renderingContextMap.set(m_renderingContext3d, contextId); |
| 679 else | 682 else |
| 680 contextId = it->value; | 683 contextId = it->value; |
| 681 | 684 |
| 682 json->setInteger("3dRenderingContext", contextId); | 685 json->setInteger("3dRenderingContext", contextId); |
| 683 } | 686 } |
| 684 | 687 |
| 685 if (m_drawsContent) | 688 if (m_drawsContent) |
| 686 json->setBoolean("drawsContent", m_drawsContent); | 689 json->setBoolean("drawsContent", m_drawsContent); |
| 687 | 690 |
| 688 if (!m_contentsVisible) | 691 if (!m_contentsVisible) |
| 689 json->setBoolean("contentsVisible", m_contentsVisible); | 692 json->setBoolean("contentsVisible", m_contentsVisible); |
| 690 | 693 |
| 691 if (!m_backfaceVisibility) | 694 if (!m_backfaceVisibility) { |
| 692 json->setString("backfaceVisibility", | 695 json->setString("backfaceVisibility", |
| 693 m_backfaceVisibility ? "visible" : "hidden"); | 696 m_backfaceVisibility ? "visible" : "hidden"); |
| 697 } | |
| 694 | 698 |
| 695 if (m_hasPreferredRasterBounds) { | 699 if (m_hasPreferredRasterBounds) { |
| 696 json->setArray("preferredRasterBounds", | 700 json->setArray("preferredRasterBounds", |
| 697 sizeAsJSONArray(m_preferredRasterBounds)); | 701 sizeAsJSONArray(m_preferredRasterBounds)); |
| 698 } | 702 } |
| 699 | 703 |
| 700 if (flags & LayerTreeIncludesDebugInfo) | 704 if (flags & LayerTreeIncludesDebugInfo) |
| 701 json->setString("client", pointerAsString(m_client)); | 705 json->setString("client", pointerAsString(m_client)); |
| 702 | 706 |
| 703 if (m_backgroundColor.alpha()) | 707 if (m_backgroundColor.alpha()) { |
| 704 json->setString("backgroundColor", | 708 json->setString("backgroundColor", |
| 705 m_backgroundColor.nameForLayoutTreeAsText()); | 709 m_backgroundColor.nameForLayoutTreeAsText()); |
| 710 } | |
| 706 | 711 |
| 707 if (!m_transform.isIdentity()) | 712 if (!m_transform.isIdentity()) |
| 708 json->setArray("transform", transformAsJSONArray(m_transform)); | 713 json->setArray("transform", transformAsJSONArray(m_transform)); |
| 709 | 714 |
| 710 if (flags & LayerTreeIncludesPaintInvalidations) | 715 if (flags & LayerTreeIncludesPaintInvalidations) |
| 711 rasterInvalidationTrackingMap().asJSON(this, json.get()); | 716 rasterInvalidationTrackingMap().asJSON(this, json.get()); |
| 712 | 717 |
| 713 if ((flags & LayerTreeIncludesPaintingPhases) && m_paintingPhase) { | 718 if ((flags & LayerTreeIncludesPaintingPhases) && m_paintingPhase) { |
| 714 std::unique_ptr<JSONArray> paintingPhasesJSON = JSONArray::create(); | 719 std::unique_ptr<JSONArray> paintingPhasesJSON = JSONArray::create(); |
| 715 if (m_paintingPhase & GraphicsLayerPaintBackground) | 720 if (m_paintingPhase & GraphicsLayerPaintBackground) |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 735 if (m_hasClipParent) | 740 if (m_hasClipParent) |
| 736 json->setBoolean("hasClipParent", true); | 741 json->setBoolean("hasClipParent", true); |
| 737 } | 742 } |
| 738 | 743 |
| 739 if (flags & | 744 if (flags & |
| 740 (LayerTreeIncludesDebugInfo | LayerTreeIncludesCompositingReasons)) { | 745 (LayerTreeIncludesDebugInfo | LayerTreeIncludesCompositingReasons)) { |
| 741 bool debug = flags & LayerTreeIncludesDebugInfo; | 746 bool debug = flags & LayerTreeIncludesDebugInfo; |
| 742 std::unique_ptr<JSONArray> compositingReasonsJSON = JSONArray::create(); | 747 std::unique_ptr<JSONArray> compositingReasonsJSON = JSONArray::create(); |
| 743 for (size_t i = 0; i < kNumberOfCompositingReasons; ++i) { | 748 for (size_t i = 0; i < kNumberOfCompositingReasons; ++i) { |
| 744 if (m_debugInfo.getCompositingReasons() & | 749 if (m_debugInfo.getCompositingReasons() & |
| 745 kCompositingReasonStringMap[i].reason) | 750 kCompositingReasonStringMap[i].reason) { |
| 746 compositingReasonsJSON->pushString( | 751 compositingReasonsJSON->pushString( |
| 747 debug ? kCompositingReasonStringMap[i].description | 752 debug ? kCompositingReasonStringMap[i].description |
| 748 : kCompositingReasonStringMap[i].shortName); | 753 : kCompositingReasonStringMap[i].shortName); |
| 754 } | |
| 749 } | 755 } |
| 750 json->setArray("compositingReasons", std::move(compositingReasonsJSON)); | 756 json->setArray("compositingReasons", std::move(compositingReasonsJSON)); |
| 751 | 757 |
| 752 std::unique_ptr<JSONArray> squashingDisallowedReasonsJSON = | 758 std::unique_ptr<JSONArray> squashingDisallowedReasonsJSON = |
| 753 JSONArray::create(); | 759 JSONArray::create(); |
| 754 for (size_t i = 0; i < kNumberOfSquashingDisallowedReasons; ++i) { | 760 for (size_t i = 0; i < kNumberOfSquashingDisallowedReasons; ++i) { |
| 755 if (m_debugInfo.getSquashingDisallowedReasons() & | 761 if (m_debugInfo.getSquashingDisallowedReasons() & |
| 756 kSquashingDisallowedReasonStringMap[i].reason) | 762 kSquashingDisallowedReasonStringMap[i].reason) { |
| 757 squashingDisallowedReasonsJSON->pushString( | 763 squashingDisallowedReasonsJSON->pushString( |
| 758 debug ? kSquashingDisallowedReasonStringMap[i].description | 764 debug ? kSquashingDisallowedReasonStringMap[i].description |
| 759 : kSquashingDisallowedReasonStringMap[i].shortName); | 765 : kSquashingDisallowedReasonStringMap[i].shortName); |
| 766 } | |
| 760 } | 767 } |
| 761 json->setArray("squashingDisallowedReasons", | 768 json->setArray("squashingDisallowedReasons", |
| 762 std::move(squashingDisallowedReasonsJSON)); | 769 std::move(squashingDisallowedReasonsJSON)); |
| 763 } | 770 } |
| 764 return json; | 771 return json; |
| 765 } | 772 } |
| 766 | 773 |
| 767 std::unique_ptr<JSONObject> GraphicsLayer::layerTreeAsJSONInternal( | 774 std::unique_ptr<JSONObject> GraphicsLayer::layerTreeAsJSONInternal( |
| 768 LayerTreeFlags flags, | 775 LayerTreeFlags flags, |
| 769 RenderingContextMap& renderingContextMap) const { | 776 RenderingContextMap& renderingContextMap) const { |
| 770 std::unique_ptr<JSONObject> json = | 777 std::unique_ptr<JSONObject> json = |
| 771 layerAsJSONInternal(flags, renderingContextMap); | 778 layerAsJSONInternal(flags, renderingContextMap); |
| 772 | 779 |
| 773 if (m_children.size()) { | 780 if (m_children.size()) { |
| 774 std::unique_ptr<JSONArray> childrenJSON = JSONArray::create(); | 781 std::unique_ptr<JSONArray> childrenJSON = JSONArray::create(); |
| 775 for (size_t i = 0; i < m_children.size(); i++) | 782 for (size_t i = 0; i < m_children.size(); i++) { |
| 776 childrenJSON->pushObject( | 783 childrenJSON->pushObject( |
| 777 m_children[i]->layerTreeAsJSONInternal(flags, renderingContextMap)); | 784 m_children[i]->layerTreeAsJSONInternal(flags, renderingContextMap)); |
| 785 } | |
| 778 json->setArray("children", std::move(childrenJSON)); | 786 json->setArray("children", std::move(childrenJSON)); |
| 779 } | 787 } |
| 780 | 788 |
| 781 return json; | 789 return json; |
| 782 } | 790 } |
| 783 | 791 |
| 784 void GraphicsLayer::layersAsJSONArray(LayerTreeFlags flags, | 792 void GraphicsLayer::layersAsJSONArray(LayerTreeFlags flags, |
| 785 RenderingContextMap& renderingContextMap, | 793 RenderingContextMap& renderingContextMap, |
| 786 JSONArray* jsonArray) const { | 794 JSONArray* jsonArray) const { |
| 787 jsonArray->pushObject(layerAsJSONInternal(flags, renderingContextMap)); | 795 jsonArray->pushObject(layerAsJSONInternal(flags, renderingContextMap)); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 814 } | 822 } |
| 815 } | 823 } |
| 816 | 824 |
| 817 if (layer->id() == m_contentsLayerId) { | 825 if (layer->id() == m_contentsLayerId) { |
| 818 name = "ContentsLayer for " + m_client->debugName(this); | 826 name = "ContentsLayer for " + m_client->debugName(this); |
| 819 } else if (!highlightDebugName.isEmpty()) { | 827 } else if (!highlightDebugName.isEmpty()) { |
| 820 name = highlightDebugName; | 828 name = highlightDebugName; |
| 821 } else if (layer == ccLayerForWebLayer(m_layer->layer())) { | 829 } else if (layer == ccLayerForWebLayer(m_layer->layer())) { |
| 822 name = m_client->debugName(this); | 830 name = m_client->debugName(this); |
| 823 } else { | 831 } else { |
| 824 ASSERT_NOT_REACHED(); | 832 NOTREACHED(); |
| 825 } | 833 } |
| 826 return name; | 834 return name; |
| 827 } | 835 } |
| 828 | 836 |
| 829 void GraphicsLayer::setCompositingReasons(CompositingReasons reasons) { | 837 void GraphicsLayer::setCompositingReasons(CompositingReasons reasons) { |
| 830 m_debugInfo.setCompositingReasons(reasons); | 838 m_debugInfo.setCompositingReasons(reasons); |
| 831 } | 839 } |
| 832 | 840 |
| 833 void GraphicsLayer::setSquashingDisallowedReasons( | 841 void GraphicsLayer::setSquashingDisallowedReasons( |
| 834 SquashingDisallowedReasons reasons) { | 842 SquashingDisallowedReasons reasons) { |
| 835 m_debugInfo.setSquashingDisallowedReasons(reasons); | 843 m_debugInfo.setSquashingDisallowedReasons(reasons); |
| 836 } | 844 } |
| 837 | 845 |
| 838 void GraphicsLayer::setOwnerNodeId(int nodeId) { | 846 void GraphicsLayer::setOwnerNodeId(int nodeId) { |
| 839 m_debugInfo.setOwnerNodeId(nodeId); | 847 m_debugInfo.setOwnerNodeId(nodeId); |
| 840 } | 848 } |
| 841 | 849 |
| 842 void GraphicsLayer::setPosition(const FloatPoint& point) { | 850 void GraphicsLayer::setPosition(const FloatPoint& point) { |
| 843 m_position = point; | 851 m_position = point; |
| 844 platformLayer()->setPosition(m_position); | 852 platformLayer()->setPosition(m_position); |
| 845 } | 853 } |
| 846 | 854 |
| 847 void GraphicsLayer::setSize(const FloatSize& size) { | 855 void GraphicsLayer::setSize(const FloatSize& size) { |
| 848 // We are receiving negative sizes here that cause assertions to fail in the | 856 // We are receiving negative sizes here that cause assertions to fail in the |
| 849 // compositor. Clamp them to 0 to avoid those assertions. | 857 // compositor. Clamp them to 0 to avoid those assertions. |
| 850 // FIXME: This should be an ASSERT instead, as negative sizes should not exist | 858 // FIXME: This should be an DCHECK instead, as negative sizes should not exist |
| 851 // in WebCore. | 859 // in WebCore. |
| 852 FloatSize clampedSize = size; | 860 FloatSize clampedSize = size; |
| 853 if (clampedSize.width() < 0 || clampedSize.height() < 0) | 861 if (clampedSize.width() < 0 || clampedSize.height() < 0) |
| 854 clampedSize = FloatSize(); | 862 clampedSize = FloatSize(); |
| 855 | 863 |
| 856 if (clampedSize == m_size) | 864 if (clampedSize == m_size) |
| 857 return; | 865 return; |
| 858 | 866 |
| 859 m_size = clampedSize; | 867 m_size = clampedSize; |
| 860 | 868 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1106 } | 1114 } |
| 1107 | 1115 |
| 1108 void GraphicsLayer::setPaintingPhase(GraphicsLayerPaintingPhase phase) { | 1116 void GraphicsLayer::setPaintingPhase(GraphicsLayerPaintingPhase phase) { |
| 1109 if (m_paintingPhase == phase) | 1117 if (m_paintingPhase == phase) |
| 1110 return; | 1118 return; |
| 1111 m_paintingPhase = phase; | 1119 m_paintingPhase = phase; |
| 1112 setNeedsDisplay(); | 1120 setNeedsDisplay(); |
| 1113 } | 1121 } |
| 1114 | 1122 |
| 1115 void GraphicsLayer::addLinkHighlight(LinkHighlight* linkHighlight) { | 1123 void GraphicsLayer::addLinkHighlight(LinkHighlight* linkHighlight) { |
| 1116 ASSERT(linkHighlight && !m_linkHighlights.contains(linkHighlight)); | 1124 DCHECK(linkHighlight && !m_linkHighlights.contains(linkHighlight)); |
| 1117 m_linkHighlights.append(linkHighlight); | 1125 m_linkHighlights.append(linkHighlight); |
| 1118 linkHighlight->layer()->setLayerClient(this); | 1126 linkHighlight->layer()->setLayerClient(this); |
| 1119 updateChildList(); | 1127 updateChildList(); |
| 1120 } | 1128 } |
| 1121 | 1129 |
| 1122 void GraphicsLayer::removeLinkHighlight(LinkHighlight* linkHighlight) { | 1130 void GraphicsLayer::removeLinkHighlight(LinkHighlight* linkHighlight) { |
| 1123 m_linkHighlights.remove(m_linkHighlights.find(linkHighlight)); | 1131 m_linkHighlights.remove(m_linkHighlights.find(linkHighlight)); |
| 1124 updateChildList(); | 1132 updateChildList(); |
| 1125 } | 1133 } |
| 1126 | 1134 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1168 m_debugInfo.setMainThreadScrollingReasons( | 1176 m_debugInfo.setMainThreadScrollingReasons( |
| 1169 platformLayer()->mainThreadScrollingReasons()); | 1177 platformLayer()->mainThreadScrollingReasons()); |
| 1170 } | 1178 } |
| 1171 | 1179 |
| 1172 void GraphicsLayer::didChangeScrollbarsHidden(bool hidden) { | 1180 void GraphicsLayer::didChangeScrollbarsHidden(bool hidden) { |
| 1173 if (m_scrollableArea) | 1181 if (m_scrollableArea) |
| 1174 m_scrollableArea->setScrollbarsHidden(hidden); | 1182 m_scrollableArea->setScrollbarsHidden(hidden); |
| 1175 } | 1183 } |
| 1176 | 1184 |
| 1177 PaintController& GraphicsLayer::getPaintController() { | 1185 PaintController& GraphicsLayer::getPaintController() { |
| 1178 RELEASE_ASSERT(drawsContent()); | 1186 CHECK(drawsContent()); |
| 1179 if (!m_paintController) | 1187 if (!m_paintController) |
| 1180 m_paintController = PaintController::create(); | 1188 m_paintController = PaintController::create(); |
| 1181 return *m_paintController; | 1189 return *m_paintController; |
| 1182 } | 1190 } |
| 1183 | 1191 |
| 1184 void GraphicsLayer::setElementId(const CompositorElementId& id) { | 1192 void GraphicsLayer::setElementId(const CompositorElementId& id) { |
| 1185 if (WebLayer* layer = platformLayer()) | 1193 if (WebLayer* layer = platformLayer()) |
| 1186 layer->setElementId(id); | 1194 layer->setElementId(id); |
| 1187 } | 1195 } |
| 1188 | 1196 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1311 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) { | 1319 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) { |
| 1312 if (!layer) { | 1320 if (!layer) { |
| 1313 LOG(INFO) << "Cannot showGraphicsLayerTree for (nil)."; | 1321 LOG(INFO) << "Cannot showGraphicsLayerTree for (nil)."; |
| 1314 return; | 1322 return; |
| 1315 } | 1323 } |
| 1316 | 1324 |
| 1317 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); | 1325 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); |
| 1318 LOG(INFO) << output.utf8().data(); | 1326 LOG(INFO) << output.utf8().data(); |
| 1319 } | 1327 } |
| 1320 #endif | 1328 #endif |
| OLD | NEW |