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

Side by Side Diff: sky/engine/core/rendering/RenderLayer.cpp

Issue 758843004: Delete most of rendering/compositing. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "sky/engine/core/frame/Settings.h" 53 #include "sky/engine/core/frame/Settings.h"
54 #include "sky/engine/core/page/Page.h" 54 #include "sky/engine/core/page/Page.h"
55 #include "sky/engine/core/rendering/FilterEffectRenderer.h" 55 #include "sky/engine/core/rendering/FilterEffectRenderer.h"
56 #include "sky/engine/core/rendering/HitTestRequest.h" 56 #include "sky/engine/core/rendering/HitTestRequest.h"
57 #include "sky/engine/core/rendering/HitTestResult.h" 57 #include "sky/engine/core/rendering/HitTestResult.h"
58 #include "sky/engine/core/rendering/HitTestingTransformState.h" 58 #include "sky/engine/core/rendering/HitTestingTransformState.h"
59 #include "sky/engine/core/rendering/RenderGeometryMap.h" 59 #include "sky/engine/core/rendering/RenderGeometryMap.h"
60 #include "sky/engine/core/rendering/RenderInline.h" 60 #include "sky/engine/core/rendering/RenderInline.h"
61 #include "sky/engine/core/rendering/RenderTreeAsText.h" 61 #include "sky/engine/core/rendering/RenderTreeAsText.h"
62 #include "sky/engine/core/rendering/RenderView.h" 62 #include "sky/engine/core/rendering/RenderView.h"
63 #include "sky/engine/core/rendering/compositing/RenderLayerCompositor.h"
64 #include "sky/engine/platform/LengthFunctions.h" 63 #include "sky/engine/platform/LengthFunctions.h"
65 #include "sky/engine/platform/Partitions.h" 64 #include "sky/engine/platform/Partitions.h"
66 #include "sky/engine/platform/TraceEvent.h" 65 #include "sky/engine/platform/TraceEvent.h"
67 #include "sky/engine/platform/geometry/FloatPoint3D.h" 66 #include "sky/engine/platform/geometry/FloatPoint3D.h"
68 #include "sky/engine/platform/geometry/FloatRect.h" 67 #include "sky/engine/platform/geometry/FloatRect.h"
69 #include "sky/engine/platform/geometry/TransformState.h" 68 #include "sky/engine/platform/geometry/TransformState.h"
70 #include "sky/engine/platform/graphics/GraphicsContextStateSaver.h" 69 #include "sky/engine/platform/graphics/GraphicsContextStateSaver.h"
71 #include "sky/engine/platform/graphics/filters/ReferenceFilter.h" 70 #include "sky/engine/platform/graphics/filters/ReferenceFilter.h"
72 #include "sky/engine/platform/graphics/filters/SourceGraphic.h" 71 #include "sky/engine/platform/graphics/filters/SourceGraphic.h"
73 #include "sky/engine/platform/transforms/ScaleTransformOperation.h" 72 #include "sky/engine/platform/transforms/ScaleTransformOperation.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 RenderLayer::~RenderLayer() 123 RenderLayer::~RenderLayer()
125 { 124 {
126 removeFilterInfoIfNeeded(); 125 removeFilterInfoIfNeeded();
127 } 126 }
128 127
129 String RenderLayer::debugName() const 128 String RenderLayer::debugName() const
130 { 129 {
131 return renderer()->debugName(); 130 return renderer()->debugName();
132 } 131 }
133 132
134 RenderLayerCompositor* RenderLayer::compositor() const
135 {
136 if (!renderer()->view())
137 return 0;
138 return renderer()->view()->compositor();
139 }
140
141 void RenderLayer::contentChanged(ContentChangeType changeType) 133 void RenderLayer::contentChanged(ContentChangeType changeType)
142 { 134 {
143 // FIXME(sky): Remove 135 // FIXME(sky): Remove
144 } 136 }
145 137
146 bool RenderLayer::paintsWithFilters() const 138 bool RenderLayer::paintsWithFilters() const
147 { 139 {
148 // FIXME(sky): Remove 140 // FIXME(sky): Remove
149 return renderer()->hasFilter(); 141 return renderer()->hasFilter();
150 } 142 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 return ancestorScrollingLayer() != other->ancestorScrollingLayer(); 208 return ancestorScrollingLayer() != other->ancestorScrollingLayer();
217 } 209 }
218 210
219 void RenderLayer::updateTransformationMatrix() 211 void RenderLayer::updateTransformationMatrix()
220 { 212 {
221 if (m_transform) { 213 if (m_transform) {
222 RenderBox* box = renderBox(); 214 RenderBox* box = renderBox();
223 ASSERT(box); 215 ASSERT(box);
224 m_transform->makeIdentity(); 216 m_transform->makeIdentity();
225 box->style()->applyTransform(*m_transform, box->pixelSnappedBorderBoxRec t().size(), RenderStyle::IncludeTransformOrigin); 217 box->style()->applyTransform(*m_transform, box->pixelSnappedBorderBoxRec t().size(), RenderStyle::IncludeTransformOrigin);
226 makeMatrixRenderable(*m_transform, compositor()->hasAcceleratedCompositi ng()); 218 makeMatrixRenderable(*m_transform);
227 } 219 }
228 } 220 }
229 221
230 void RenderLayer::updateTransform(const RenderStyle* oldStyle, RenderStyle* newS tyle) 222 void RenderLayer::updateTransform(const RenderStyle* oldStyle, RenderStyle* newS tyle)
231 { 223 {
232 if (oldStyle && newStyle->transformDataEquivalent(*oldStyle)) 224 if (oldStyle && newStyle->transformDataEquivalent(*oldStyle))
233 return; 225 return;
234 226
235 // hasTransform() on the renderer is also true when there is transform-style : preserve-3d or perspective set, 227 // hasTransform() on the renderer is also true when there is transform-style : preserve-3d or perspective set,
236 // so check style too. 228 // so check style too.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 TransformationMatrix RenderLayer::currentTransform(RenderStyle::ApplyTransformOr igin applyOrigin) const 271 TransformationMatrix RenderLayer::currentTransform(RenderStyle::ApplyTransformOr igin applyOrigin) const
280 { 272 {
281 if (!m_transform) 273 if (!m_transform)
282 return TransformationMatrix(); 274 return TransformationMatrix();
283 275
284 // m_transform includes transform-origin, so we need to recompute the transf orm here. 276 // m_transform includes transform-origin, so we need to recompute the transf orm here.
285 if (applyOrigin == RenderStyle::ExcludeTransformOrigin) { 277 if (applyOrigin == RenderStyle::ExcludeTransformOrigin) {
286 RenderBox* box = renderBox(); 278 RenderBox* box = renderBox();
287 TransformationMatrix currTransform; 279 TransformationMatrix currTransform;
288 box->style()->applyTransform(currTransform, box->pixelSnappedBorderBoxRe ct().size(), RenderStyle::ExcludeTransformOrigin); 280 box->style()->applyTransform(currTransform, box->pixelSnappedBorderBoxRe ct().size(), RenderStyle::ExcludeTransformOrigin);
289 makeMatrixRenderable(currTransform, compositor()->hasAcceleratedComposit ing()); 281 makeMatrixRenderable(currTransform);
290 return currTransform; 282 return currTransform;
291 } 283 }
292 284
293 return *m_transform; 285 return *m_transform;
294 } 286 }
295 287
296 TransformationMatrix RenderLayer::renderableTransform(PaintBehavior paintBehavio r) const 288 TransformationMatrix RenderLayer::renderableTransform(PaintBehavior paintBehavio r) const
297 { 289 {
298 if (!m_transform) 290 if (!m_transform)
299 return TransformationMatrix(); 291 return TransformationMatrix();
300 292
301 if (paintBehavior & PaintBehaviorFlattenCompositingLayers) { 293 if (paintBehavior & PaintBehaviorFlattenCompositingLayers) {
302 TransformationMatrix matrix = *m_transform; 294 TransformationMatrix matrix = *m_transform;
303 makeMatrixRenderable(matrix, false /* flatten 3d */); 295 makeMatrixRenderable(matrix);
304 return matrix; 296 return matrix;
305 } 297 }
306 298
307 return *m_transform; 299 return *m_transform;
308 } 300 }
309 301
310 RenderLayer* RenderLayer::enclosingOverflowClipLayer(IncludeSelfOrNot includeSel f) const 302 RenderLayer* RenderLayer::enclosingOverflowClipLayer(IncludeSelfOrNot includeSel f) const
311 { 303 {
312 const RenderLayer* layer = (includeSelf == IncludeSelf) ? this : parent(); 304 const RenderLayer* layer = (includeSelf == IncludeSelf) ? this : parent();
313 while (layer) { 305 while (layer) {
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 531
540 bool RenderLayer::isPaintInvalidationContainer() const 532 bool RenderLayer::isPaintInvalidationContainer() const
541 { 533 {
542 return compositingState() == PaintsIntoOwnBacking || compositingState() == P aintsIntoGroupedBacking; 534 return compositingState() == PaintsIntoOwnBacking || compositingState() == P aintsIntoGroupedBacking;
543 } 535 }
544 536
545 // Note: enclosingCompositingLayer does not include squashed layers. Compositing stacking children of squashed layers 537 // Note: enclosingCompositingLayer does not include squashed layers. Compositing stacking children of squashed layers
546 // receive graphics layers that are parented to the compositing ancestor of the squashed layer. 538 // receive graphics layers that are parented to the compositing ancestor of the squashed layer.
547 RenderLayer* RenderLayer::enclosingLayerWithCompositedLayerMapping(IncludeSelfOr Not includeSelf) const 539 RenderLayer* RenderLayer::enclosingLayerWithCompositedLayerMapping(IncludeSelfOr Not includeSelf) const
548 { 540 {
549 ASSERT(isAllowedToQueryCompositingState()); 541 // FIXME(sky): Remove
550
551 if ((includeSelf == IncludeSelf) && compositingState() != NotComposited && c ompositingState() != PaintsIntoGroupedBacking)
552 return const_cast<RenderLayer*>(this);
553
554 for (const RenderLayer* curr = compositingContainer(); curr; curr = curr->co mpositingContainer()) {
555 if (curr->compositingState() != NotComposited && curr->compositingState( ) != PaintsIntoGroupedBacking)
556 return const_cast<RenderLayer*>(curr);
557 }
558
559 return 0; 542 return 0;
560 } 543 }
561 544
562 // Return the enclosingCompositedLayerForPaintInvalidation for the given RenderL ayer 545 // Return the enclosingCompositedLayerForPaintInvalidation for the given RenderL ayer
563 // including crossing frame boundaries. 546 // including crossing frame boundaries.
564 RenderLayer* RenderLayer::enclosingLayerForPaintInvalidationCrossingFrameBoundar ies() const 547 RenderLayer* RenderLayer::enclosingLayerForPaintInvalidationCrossingFrameBoundar ies() const
565 { 548 {
566 // FIXME(sky): remove 549 // FIXME(sky): remove
567 return enclosingLayerForPaintInvalidation(); 550 return enclosingLayerForPaintInvalidation();
568 } 551 }
569 552
570 RenderLayer* RenderLayer::enclosingLayerForPaintInvalidation() const 553 RenderLayer* RenderLayer::enclosingLayerForPaintInvalidation() const
571 { 554 {
572 ASSERT(isAllowedToQueryCompositingState());
573
574 if (isPaintInvalidationContainer()) 555 if (isPaintInvalidationContainer())
575 return const_cast<RenderLayer*>(this); 556 return const_cast<RenderLayer*>(this);
576 557
577 for (const RenderLayer* curr = parent(); curr; curr = curr->parent()) { 558 for (const RenderLayer* curr = parent(); curr; curr = curr->parent()) {
578 if (curr->isPaintInvalidationContainer()) 559 if (curr->isPaintInvalidationContainer())
579 return const_cast<RenderLayer*>(curr); 560 return const_cast<RenderLayer*>(curr);
580 } 561 }
581 562
582 return 0; 563 return 0;
583 } 564 }
584 565
585 RenderLayer* RenderLayer::enclosingFilterLayer(IncludeSelfOrNot includeSelf) con st 566 RenderLayer* RenderLayer::enclosingFilterLayer(IncludeSelfOrNot includeSelf) con st
586 { 567 {
587 const RenderLayer* curr = (includeSelf == IncludeSelf) ? this : parent(); 568 const RenderLayer* curr = (includeSelf == IncludeSelf) ? this : parent();
588 for (; curr; curr = curr->parent()) { 569 for (; curr; curr = curr->parent()) {
589 if (curr->requiresFullLayerImageForFilters()) 570 if (curr->requiresFullLayerImageForFilters())
590 return const_cast<RenderLayer*>(curr); 571 return const_cast<RenderLayer*>(curr);
591 } 572 }
592 573
593 return 0; 574 return 0;
594 } 575 }
595 576
596 void RenderLayer::setNeedsCompositingInputsUpdate() 577 void RenderLayer::setNeedsCompositingInputsUpdate()
597 { 578 {
598 m_needsAncestorDependentCompositingInputsUpdate = true; 579 // FIXME(sky): Remove
599 m_needsDescendantDependentCompositingInputsUpdate = true;
600
601 for (RenderLayer* current = this; current && !current->m_childNeedsCompositi ngInputsUpdate; current = current->parent())
602 current->m_childNeedsCompositingInputsUpdate = true;
603
604 compositor()->setNeedsCompositingUpdate(CompositingUpdateAfterCompositingInp utChange);
605 } 580 }
606 581
607 void RenderLayer::updateAncestorDependentCompositingInputs(const AncestorDepende ntCompositingInputs& compositingInputs) 582 void RenderLayer::updateAncestorDependentCompositingInputs(const AncestorDepende ntCompositingInputs& compositingInputs)
608 { 583 {
609 m_ancestorDependentCompositingInputs = compositingInputs; 584 m_ancestorDependentCompositingInputs = compositingInputs;
610 m_needsAncestorDependentCompositingInputsUpdate = false; 585 m_needsAncestorDependentCompositingInputsUpdate = false;
611 } 586 }
612 587
613 void RenderLayer::updateDescendantDependentCompositingInputs(const DescendantDep endentCompositingInputs& compositingInputs) 588 void RenderLayer::updateDescendantDependentCompositingInputs(const DescendantDep endentCompositingInputs& compositingInputs)
614 { 589 {
615 m_descendantDependentCompositingInputs = compositingInputs; 590 m_descendantDependentCompositingInputs = compositingInputs;
616 m_needsDescendantDependentCompositingInputsUpdate = false; 591 m_needsDescendantDependentCompositingInputsUpdate = false;
617 } 592 }
618 593
619 void RenderLayer::didUpdateCompositingInputs()
620 {
621 ASSERT(!needsCompositingInputsUpdate());
622 m_childNeedsCompositingInputsUpdate = false;
623 if (m_scrollableArea)
624 m_scrollableArea->updateNeedsCompositedScrolling();
625 }
626
627 void RenderLayer::setCompositingReasons(CompositingReasons reasons, CompositingR easons mask) 594 void RenderLayer::setCompositingReasons(CompositingReasons reasons, CompositingR easons mask)
628 { 595 {
629 if ((compositingReasons() & mask) == (reasons & mask)) 596 if ((compositingReasons() & mask) == (reasons & mask))
630 return; 597 return;
631 m_compositingReasons = (reasons & mask) | (compositingReasons() & ~mask); 598 m_compositingReasons = (reasons & mask) | (compositingReasons() & ~mask);
632 } 599 }
633 600
634 void RenderLayer::setHasCompositingDescendant(bool hasCompositingDescendant) 601 void RenderLayer::setHasCompositingDescendant(bool hasCompositingDescendant)
635 { 602 {
636 // FIXME(sky): Remove 603 // FIXME(sky): Remove
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 for (size_t i = 0; i < fragments.size(); ++i) { 1389 for (size_t i = 0; i < fragments.size(); ++i) {
1423 LayerFragment& fragment = fragments.at(i); 1390 LayerFragment& fragment = fragments.at(i);
1424 fragment.shouldPaintContent = shouldPaintContent; 1391 fragment.shouldPaintContent = shouldPaintContent;
1425 if (this != localPaintingInfo.rootLayer || !(localPaintFlags & PaintLaye rPaintingOverflowContents)) { 1392 if (this != localPaintingInfo.rootLayer || !(localPaintFlags & PaintLaye rPaintingOverflowContents)) {
1426 LayoutPoint newOffsetFromRoot = *offsetFromRoot; 1393 LayoutPoint newOffsetFromRoot = *offsetFromRoot;
1427 fragment.shouldPaintContent &= intersectsDamageRect(fragment.layerBo unds, fragment.backgroundRect.rect(), localPaintingInfo.rootLayer, &newOffsetFro mRoot); 1394 fragment.shouldPaintContent &= intersectsDamageRect(fragment.layerBo unds, fragment.backgroundRect.rect(), localPaintingInfo.rootLayer, &newOffsetFro mRoot);
1428 } 1395 }
1429 } 1396 }
1430 } 1397 }
1431 1398
1432 static inline LayoutSize subPixelAccumulationIfNeeded(const LayoutSize& subPixel Accumulation, CompositingState compositingState)
1433 {
1434 // Only apply the sub-pixel accumulation if we don't paint into our own back ing layer, otherwise the position
1435 // of the renderer already includes any sub-pixel offset.
1436 if (compositingState == PaintsIntoOwnBacking)
1437 return LayoutSize();
1438 return subPixelAccumulation;
1439 }
1440
1441 void RenderLayer::paintBackgroundForFragments(const LayerFragments& layerFragmen ts, GraphicsContext* context, GraphicsContext* transparencyLayerContext, 1399 void RenderLayer::paintBackgroundForFragments(const LayerFragments& layerFragmen ts, GraphicsContext* context, GraphicsContext* transparencyLayerContext,
1442 const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const L ayerPaintingInfo& localPaintingInfo, PaintBehavior paintBehavior, 1400 const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const L ayerPaintingInfo& localPaintingInfo, PaintBehavior paintBehavior,
1443 RenderObject* paintingRootForRenderer, PaintLayerFlags paintFlags) 1401 RenderObject* paintingRootForRenderer, PaintLayerFlags paintFlags)
1444 { 1402 {
1445 for (size_t i = 0; i < layerFragments.size(); ++i) { 1403 for (size_t i = 0; i < layerFragments.size(); ++i) {
1446 const LayerFragment& fragment = layerFragments.at(i); 1404 const LayerFragment& fragment = layerFragments.at(i);
1447 if (!fragment.shouldPaintContent) 1405 if (!fragment.shouldPaintContent)
1448 continue; 1406 continue;
1449 1407
1450 // Begin transparency layers lazily now that we know we have to paint so mething. 1408 // Begin transparency layers lazily now that we know we have to paint so mething.
1451 if (haveTransparency) 1409 if (haveTransparency)
1452 beginTransparencyLayers(transparencyLayerContext, localPaintingInfo. rootLayer, transparencyPaintDirtyRect, localPaintingInfo.subPixelAccumulation, l ocalPaintingInfo.paintBehavior); 1410 beginTransparencyLayers(transparencyLayerContext, localPaintingInfo. rootLayer, transparencyPaintDirtyRect, localPaintingInfo.subPixelAccumulation, l ocalPaintingInfo.paintBehavior);
1453 1411
1454 if (localPaintingInfo.clipToDirtyRect) { 1412 if (localPaintingInfo.clipToDirtyRect) {
1455 // Paint our background first, before painting any child layers. 1413 // Paint our background first, before painting any child layers.
1456 // Establish the clip used to paint our background. 1414 // Establish the clip used to paint our background.
1457 clipToRect(localPaintingInfo, context, fragment.backgroundRect, pain tFlags, DoNotIncludeSelfForBorderRadius); // Background painting will handle cli pping to self. 1415 clipToRect(localPaintingInfo, context, fragment.backgroundRect, pain tFlags, DoNotIncludeSelfForBorderRadius); // Background painting will handle cli pping to self.
1458 } 1416 }
1459 1417
1460 // Paint the background. 1418 // Paint the background.
1461 // FIXME: Eventually we will collect the region from the fragment itself instead of just from the paint info. 1419 // FIXME: Eventually we will collect the region from the fragment itself instead of just from the paint info.
1462 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect .rect()), PaintPhaseBlockBackground, paintBehavior, paintingRootForRenderer, 0, localPaintingInfo.rootLayer->renderer()); 1420 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect .rect()), PaintPhaseBlockBackground, paintBehavior, paintingRootForRenderer, 0, localPaintingInfo.rootLayer->renderer());
1463 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r enderBoxLocation() + subPixelAccumulationIfNeeded(localPaintingInfo.subPixelAccu mulation, compositingState()))); 1421 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r enderBoxLocation() + localPaintingInfo.subPixelAccumulation));
1464 1422
1465 if (localPaintingInfo.clipToDirtyRect) 1423 if (localPaintingInfo.clipToDirtyRect)
1466 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.back groundRect); 1424 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.back groundRect);
1467 } 1425 }
1468 } 1426 }
1469 1427
1470 void RenderLayer::paintForegroundForFragments(const LayerFragments& layerFragmen ts, GraphicsContext* context, GraphicsContext* transparencyLayerContext, 1428 void RenderLayer::paintForegroundForFragments(const LayerFragments& layerFragmen ts, GraphicsContext* context, GraphicsContext* transparencyLayerContext,
1471 const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const L ayerPaintingInfo& localPaintingInfo, PaintBehavior paintBehavior, 1429 const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const L ayerPaintingInfo& localPaintingInfo, PaintBehavior paintBehavior,
1472 RenderObject* paintingRootForRenderer, bool selectionOnly, PaintLayerFlags p aintFlags) 1430 RenderObject* paintingRootForRenderer, bool selectionOnly, PaintLayerFlags p aintFlags)
1473 { 1431 {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1508 1466
1509 for (size_t i = 0; i < layerFragments.size(); ++i) { 1467 for (size_t i = 0; i < layerFragments.size(); ++i) {
1510 const LayerFragment& fragment = layerFragments.at(i); 1468 const LayerFragment& fragment = layerFragments.at(i);
1511 if (!fragment.shouldPaintContent || fragment.foregroundRect.isEmpty()) 1469 if (!fragment.shouldPaintContent || fragment.foregroundRect.isEmpty())
1512 continue; 1470 continue;
1513 1471
1514 if (shouldClip) 1472 if (shouldClip)
1515 clipToRect(localPaintingInfo, context, fragment.foregroundRect, pain tFlags); 1473 clipToRect(localPaintingInfo, context, fragment.foregroundRect, pain tFlags);
1516 1474
1517 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.foregroundRect .rect()), phase, paintBehavior, paintingRootForRenderer, 0, localPaintingInfo.ro otLayer->renderer()); 1475 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.foregroundRect .rect()), phase, paintBehavior, paintingRootForRenderer, 0, localPaintingInfo.ro otLayer->renderer());
1518 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r enderBoxLocation() + subPixelAccumulationIfNeeded(localPaintingInfo.subPixelAccu mulation, compositingState()))); 1476 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r enderBoxLocation() + localPaintingInfo.subPixelAccumulation));
1519 1477
1520 if (shouldClip) 1478 if (shouldClip)
1521 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.fore groundRect); 1479 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.fore groundRect);
1522 } 1480 }
1523 } 1481 }
1524 1482
1525 void RenderLayer::paintOutlineForFragments(const LayerFragments& layerFragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo, 1483 void RenderLayer::paintOutlineForFragments(const LayerFragments& layerFragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo,
1526 PaintBehavior paintBehavior, RenderObject* paintingRootForRenderer, PaintLay erFlags paintFlags) 1484 PaintBehavior paintBehavior, RenderObject* paintingRootForRenderer, PaintLay erFlags paintFlags)
1527 { 1485 {
1528 for (size_t i = 0; i < layerFragments.size(); ++i) { 1486 for (size_t i = 0; i < layerFragments.size(); ++i) {
1529 const LayerFragment& fragment = layerFragments.at(i); 1487 const LayerFragment& fragment = layerFragments.at(i);
1530 if (fragment.outlineRect.isEmpty()) 1488 if (fragment.outlineRect.isEmpty())
1531 continue; 1489 continue;
1532 1490
1533 // Paint our own outline 1491 // Paint our own outline
1534 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.outlineRect.re ct()), PaintPhaseSelfOutline, paintBehavior, paintingRootForRenderer, 0, localPa intingInfo.rootLayer->renderer()); 1492 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.outlineRect.re ct()), PaintPhaseSelfOutline, paintBehavior, paintingRootForRenderer, 0, localPa intingInfo.rootLayer->renderer());
1535 clipToRect(localPaintingInfo, context, fragment.outlineRect, paintFlags, DoNotIncludeSelfForBorderRadius); 1493 clipToRect(localPaintingInfo, context, fragment.outlineRect, paintFlags, DoNotIncludeSelfForBorderRadius);
1536 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r enderBoxLocation() + subPixelAccumulationIfNeeded(localPaintingInfo.subPixelAccu mulation, compositingState()))); 1494 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r enderBoxLocation() + localPaintingInfo.subPixelAccumulation));
1537 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.outlineR ect); 1495 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.outlineR ect);
1538 } 1496 }
1539 } 1497 }
1540 1498
1541 void RenderLayer::paintMaskForFragments(const LayerFragments& layerFragments, Gr aphicsContext* context, const LayerPaintingInfo& localPaintingInfo, 1499 void RenderLayer::paintMaskForFragments(const LayerFragments& layerFragments, Gr aphicsContext* context, const LayerPaintingInfo& localPaintingInfo,
1542 RenderObject* paintingRootForRenderer, PaintLayerFlags paintFlags) 1500 RenderObject* paintingRootForRenderer, PaintLayerFlags paintFlags)
1543 { 1501 {
1544 for (size_t i = 0; i < layerFragments.size(); ++i) { 1502 for (size_t i = 0; i < layerFragments.size(); ++i) {
1545 const LayerFragment& fragment = layerFragments.at(i); 1503 const LayerFragment& fragment = layerFragments.at(i);
1546 if (!fragment.shouldPaintContent) 1504 if (!fragment.shouldPaintContent)
1547 continue; 1505 continue;
1548 1506
1549 if (localPaintingInfo.clipToDirtyRect) 1507 if (localPaintingInfo.clipToDirtyRect)
1550 clipToRect(localPaintingInfo, context, fragment.backgroundRect, pain tFlags, DoNotIncludeSelfForBorderRadius); // Mask painting will handle clipping to self. 1508 clipToRect(localPaintingInfo, context, fragment.backgroundRect, pain tFlags, DoNotIncludeSelfForBorderRadius); // Mask painting will handle clipping to self.
1551 1509
1552 // Paint the mask. 1510 // Paint the mask.
1553 // FIXME: Eventually we will collect the region from the fragment itself instead of just from the paint info. 1511 // FIXME: Eventually we will collect the region from the fragment itself instead of just from the paint info.
1554 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect .rect()), PaintPhaseMask, PaintBehaviorNormal, paintingRootForRenderer, 0, local PaintingInfo.rootLayer->renderer()); 1512 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect .rect()), PaintPhaseMask, PaintBehaviorNormal, paintingRootForRenderer, 0, local PaintingInfo.rootLayer->renderer());
1555 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r enderBoxLocation() + subPixelAccumulationIfNeeded(localPaintingInfo.subPixelAccu mulation, compositingState()))); 1513 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r enderBoxLocation() + localPaintingInfo.subPixelAccumulation));
1556 1514
1557 if (localPaintingInfo.clipToDirtyRect) 1515 if (localPaintingInfo.clipToDirtyRect)
1558 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.back groundRect); 1516 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.back groundRect);
1559 } 1517 }
1560 } 1518 }
1561 1519
1562 void RenderLayer::paintChildClippingMaskForFragments(const LayerFragments& layer Fragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo, 1520 void RenderLayer::paintChildClippingMaskForFragments(const LayerFragments& layer Fragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo,
1563 RenderObject* paintingRootForRenderer, PaintLayerFlags paintFlags) 1521 RenderObject* paintingRootForRenderer, PaintLayerFlags paintFlags)
1564 { 1522 {
1565 for (size_t i = 0; i < layerFragments.size(); ++i) { 1523 for (size_t i = 0; i < layerFragments.size(); ++i) {
1566 const LayerFragment& fragment = layerFragments.at(i); 1524 const LayerFragment& fragment = layerFragments.at(i);
1567 if (!fragment.shouldPaintContent) 1525 if (!fragment.shouldPaintContent)
1568 continue; 1526 continue;
1569 1527
1570 if (localPaintingInfo.clipToDirtyRect) 1528 if (localPaintingInfo.clipToDirtyRect)
1571 clipToRect(localPaintingInfo, context, fragment.foregroundRect, pain tFlags, IncludeSelfForBorderRadius); // Child clipping mask painting will handle clipping to self. 1529 clipToRect(localPaintingInfo, context, fragment.foregroundRect, pain tFlags, IncludeSelfForBorderRadius); // Child clipping mask painting will handle clipping to self.
1572 1530
1573 // Paint the the clipped mask. 1531 // Paint the the clipped mask.
1574 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect .rect()), PaintPhaseClippingMask, PaintBehaviorNormal, paintingRootForRenderer, 0, localPaintingInfo.rootLayer->renderer()); 1532 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect .rect()), PaintPhaseClippingMask, PaintBehaviorNormal, paintingRootForRenderer, 0, localPaintingInfo.rootLayer->renderer());
1575 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r enderBoxLocation() + subPixelAccumulationIfNeeded(localPaintingInfo.subPixelAccu mulation, compositingState()))); 1533 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r enderBoxLocation() + localPaintingInfo.subPixelAccumulation));
1576 1534
1577 if (localPaintingInfo.clipToDirtyRect) 1535 if (localPaintingInfo.clipToDirtyRect)
1578 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.fore groundRect); 1536 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.fore groundRect);
1579 } 1537 }
1580 } 1538 }
1581 1539
1582 void RenderLayer::paintOverflowControlsForFragments(const LayerFragments& layerF ragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags) 1540 void RenderLayer::paintOverflowControlsForFragments(const LayerFragments& layerF ragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags)
1583 { 1541 {
1584 for (size_t i = 0; i < layerFragments.size(); ++i) { 1542 for (size_t i = 0; i < layerFragments.size(); ++i) {
1585 const LayerFragment& fragment = layerFragments.at(i); 1543 const LayerFragment& fragment = layerFragments.at(i);
1586 clipToRect(localPaintingInfo, context, fragment.backgroundRect, paintFla gs); 1544 clipToRect(localPaintingInfo, context, fragment.backgroundRect, paintFla gs);
1587 if (RenderLayerScrollableArea* scrollableArea = this->scrollableArea()) 1545 if (RenderLayerScrollableArea* scrollableArea = this->scrollableArea())
1588 scrollableArea->paintOverflowControls(context, roundedIntPoint(toPoi nt(fragment.layerBounds.location() - renderBoxLocation() + subPixelAccumulationI fNeeded(localPaintingInfo.subPixelAccumulation, compositingState()))), pixelSnap pedIntRect(fragment.backgroundRect.rect()), true); 1546 scrollableArea->paintOverflowControls(context, roundedIntPoint(toPoi nt(fragment.layerBounds.location() - renderBoxLocation() + localPaintingInfo.sub PixelAccumulation)), pixelSnappedIntRect(fragment.backgroundRect.rect()), true);
1589 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.backgrou ndRect); 1547 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.backgrou ndRect);
1590 } 1548 }
1591 } 1549 }
1592 1550
1593 static inline LayoutRect frameVisibleRect(RenderObject* renderer) 1551 static inline LayoutRect frameVisibleRect(RenderObject* renderer)
1594 { 1552 {
1595 FrameView* frameView = renderer->document().view(); 1553 FrameView* frameView = renderer->document().view();
1596 if (!frameView) 1554 if (!frameView)
1597 return LayoutRect(); 1555 return LayoutRect();
1598 1556
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
2168 2126
2169 if (shouldIncludeTransform) 2127 if (shouldIncludeTransform)
2170 result = transform()->mapRect(result); 2128 result = transform()->mapRect(result);
2171 2129
2172 LayoutPoint delta; 2130 LayoutPoint delta;
2173 convertToLayerCoords(ancestorLayer, delta); 2131 convertToLayerCoords(ancestorLayer, delta);
2174 result.moveBy(delta); 2132 result.moveBy(delta);
2175 return result; 2133 return result;
2176 } 2134 }
2177 2135
2178 CompositingState RenderLayer::compositingState() const
2179 {
2180 // FIXME(sky): Remove
2181 return NotComposited;
2182 }
2183
2184 bool RenderLayer::isAllowedToQueryCompositingState() const
2185 {
2186 if (gCompositingQueryMode == CompositingQueriesAreAllowed)
2187 return true;
2188 return renderer()->document().lifecycle().state() >= DocumentLifecycle::InCo mpositingUpdate;
2189 }
2190
2191 GraphicsLayer* RenderLayer::graphicsLayerBacking() const 2136 GraphicsLayer* RenderLayer::graphicsLayerBacking() const
2192 { 2137 {
2193 return 0; 2138 return 0;
2194 } 2139 }
2195 2140
2196 bool RenderLayer::hasCompositedMask() const 2141 bool RenderLayer::hasCompositedMask() const
2197 { 2142 {
2198 // FIXME(sky): Remove 2143 // FIXME(sky): Remove
2199 return false; 2144 return false;
2200 } 2145 }
2201 2146
2202 bool RenderLayer::hasCompositedClippingMask() const 2147 bool RenderLayer::hasCompositedClippingMask() const
2203 { 2148 {
2204 // FIXME(sky): Remove 2149 // FIXME(sky): Remove
2205 return false; 2150 return false;
2206 } 2151 }
2207 2152
2208 bool RenderLayer::clipsCompositingDescendantsWithBorderRadius() const 2153 bool RenderLayer::clipsCompositingDescendantsWithBorderRadius() const
2209 { 2154 {
2210 RenderStyle* style = renderer()->style(); 2155 // FIXME(sky): Remove
2211 if (!style) 2156 return false;
2212 return false;
2213
2214 return compositor()->clipsCompositingDescendants(this) && style->hasBorderRa dius();
2215 } 2157 }
2216 2158
2217 bool RenderLayer::paintsWithTransform(PaintBehavior paintBehavior) const 2159 bool RenderLayer::paintsWithTransform(PaintBehavior paintBehavior) const
2218 { 2160 {
2219 return transform() && ((paintBehavior & PaintBehaviorFlattenCompositingLayer s) || compositingState() != PaintsIntoOwnBacking); 2161 return transform() && ((paintBehavior & PaintBehaviorFlattenCompositingLayer s) || compositingState() != PaintsIntoOwnBacking);
2220 } 2162 }
2221 2163
2222 bool RenderLayer::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const 2164 bool RenderLayer::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const
2223 { 2165 {
2224 if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant()) 2166 if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant())
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
2340 2282
2341 void RenderLayer::updateFilters(const RenderStyle* oldStyle, const RenderStyle* newStyle) 2283 void RenderLayer::updateFilters(const RenderStyle* oldStyle, const RenderStyle* newStyle)
2342 { 2284 {
2343 if (!newStyle->hasFilter() && (!oldStyle || !oldStyle->hasFilter())) 2285 if (!newStyle->hasFilter() && (!oldStyle || !oldStyle->hasFilter()))
2344 return; 2286 return;
2345 2287
2346 updateOrRemoveFilterClients(); 2288 updateOrRemoveFilterClients();
2347 updateOrRemoveFilterEffectRenderer(); 2289 updateOrRemoveFilterEffectRenderer();
2348 } 2290 }
2349 2291
2350 bool RenderLayer::attemptDirectCompositingUpdate(StyleDifference diff, const Ren derStyle* oldStyle)
2351 {
2352 // FIXME(sky): Remove this function now that we don't have compositing layer s.
2353 CompositingReasons oldPotentialCompositingReasonsFromStyle = m_potentialComp ositingReasonsFromStyle;
2354 compositor()->updatePotentialCompositingReasonsFromStyle(this);
2355
2356 // This function implements an optimization for transforms and opacity.
2357 // A common pattern is for a touchmove handler to update the transform
2358 // and/or an opacity of an element every frame while the user moves their
2359 // finger across the screen. The conditions below recognize when the
2360 // compositing state is set up to receive a direct transform or opacity
2361 // update.
2362
2363 if (!diff.hasAtMostPropertySpecificDifferences(StyleDifference::TransformCha nged | StyleDifference::OpacityChanged))
2364 return false;
2365 // The potentialCompositingReasonsFromStyle could have changed without
2366 // a corresponding StyleDifference if an animation started or ended.
2367 if (m_potentialCompositingReasonsFromStyle != oldPotentialCompositingReasons FromStyle)
2368 return false;
2369 return false;
2370 }
2371
2372 void RenderLayer::styleChanged(StyleDifference diff, const RenderStyle* oldStyle ) 2292 void RenderLayer::styleChanged(StyleDifference diff, const RenderStyle* oldStyle )
2373 { 2293 {
2374 if (attemptDirectCompositingUpdate(diff, oldStyle))
2375 return;
2376
2377 m_stackingNode->updateIsNormalFlowOnly(); 2294 m_stackingNode->updateIsNormalFlowOnly();
2378 m_stackingNode->updateStackingNodesAfterStyleChange(oldStyle); 2295 m_stackingNode->updateStackingNodesAfterStyleChange(oldStyle);
2379 2296
2380 if (m_scrollableArea) 2297 if (m_scrollableArea)
2381 m_scrollableArea->updateAfterStyleChange(oldStyle); 2298 m_scrollableArea->updateAfterStyleChange(oldStyle);
2382 2299
2383 // Overlay scrollbars can make this layer self-painting so we need 2300 // Overlay scrollbars can make this layer self-painting so we need
2384 // to recompute the bit once scrollbars have been updated. 2301 // to recompute the bit once scrollbars have been updated.
2385 updateSelfPaintingLayer(); 2302 updateSelfPaintingLayer();
2386 2303
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
2479 } 2396 }
2480 } 2397 }
2481 2398
2482 void showLayerTree(const blink::RenderObject* renderer) 2399 void showLayerTree(const blink::RenderObject* renderer)
2483 { 2400 {
2484 if (!renderer) 2401 if (!renderer)
2485 return; 2402 return;
2486 showLayerTree(renderer->enclosingLayer()); 2403 showLayerTree(renderer->enclosingLayer());
2487 } 2404 }
2488 #endif 2405 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698