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

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

Issue 731863003: Remove CSSCompositing (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: preland Created 6 years, 1 month 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
« no previous file with comments | « sky/engine/core/rendering/RenderLayer.h ('k') | sky/engine/core/rendering/RenderObject.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 , m_isRootLayer(renderer->isRenderView()) 94 , m_isRootLayer(renderer->isRenderView())
95 , m_usedTransparency(false) 95 , m_usedTransparency(false)
96 , m_3DTransformedDescendantStatusDirty(true) 96 , m_3DTransformedDescendantStatusDirty(true)
97 , m_has3DTransformedDescendant(false) 97 , m_has3DTransformedDescendant(false)
98 , m_containsDirtyOverlayScrollbars(false) 98 , m_containsDirtyOverlayScrollbars(false)
99 , m_hasFilterInfo(false) 99 , m_hasFilterInfo(false)
100 , m_needsAncestorDependentCompositingInputsUpdate(true) 100 , m_needsAncestorDependentCompositingInputsUpdate(true)
101 , m_needsDescendantDependentCompositingInputsUpdate(true) 101 , m_needsDescendantDependentCompositingInputsUpdate(true)
102 , m_childNeedsCompositingInputsUpdate(true) 102 , m_childNeedsCompositingInputsUpdate(true)
103 , m_hasCompositingDescendant(false) 103 , m_hasCompositingDescendant(false)
104 , m_shouldIsolateCompositedDescendants(false)
105 , m_lostGroupedMapping(false) 104 , m_lostGroupedMapping(false)
106 , m_renderer(renderer) 105 , m_renderer(renderer)
107 , m_parent(0) 106 , m_parent(0)
108 , m_previous(0) 107 , m_previous(0)
109 , m_next(0) 108 , m_next(0)
110 , m_first(0) 109 , m_first(0)
111 , m_last(0) 110 , m_last(0)
112 , m_staticInlinePosition(0) 111 , m_staticInlinePosition(0)
113 , m_staticBlockPosition(0) 112 , m_staticBlockPosition(0)
114 , m_potentialCompositingReasonsFromStyle(CompositingReasonNone) 113 , m_potentialCompositingReasonsFromStyle(CompositingReasonNone)
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 { 707 {
709 if (m_hasCompositingDescendant == static_cast<unsigned>(hasCompositingDescen dant)) 708 if (m_hasCompositingDescendant == static_cast<unsigned>(hasCompositingDescen dant))
710 return; 709 return;
711 710
712 m_hasCompositingDescendant = hasCompositingDescendant; 711 m_hasCompositingDescendant = hasCompositingDescendant;
713 712
714 if (hasCompositedLayerMapping()) 713 if (hasCompositedLayerMapping())
715 compositedLayerMapping()->setNeedsGraphicsLayerUpdate(GraphicsLayerUpdat eLocal); 714 compositedLayerMapping()->setNeedsGraphicsLayerUpdate(GraphicsLayerUpdat eLocal);
716 } 715 }
717 716
718 void RenderLayer::setShouldIsolateCompositedDescendants(bool shouldIsolateCompos itedDescendants)
719 {
720 if (m_shouldIsolateCompositedDescendants == static_cast<unsigned>(shouldIsol ateCompositedDescendants))
721 return;
722
723 m_shouldIsolateCompositedDescendants = shouldIsolateCompositedDescendants;
724
725 if (hasCompositedLayerMapping())
726 compositedLayerMapping()->setNeedsGraphicsLayerUpdate(GraphicsLayerUpdat eLocal);
727 }
728 717
729 bool RenderLayer::hasAncestorWithFilterOutsets() const 718 bool RenderLayer::hasAncestorWithFilterOutsets() const
730 { 719 {
731 for (const RenderLayer* curr = this; curr; curr = curr->parent()) { 720 for (const RenderLayer* curr = this; curr; curr = curr->parent()) {
732 RenderLayerModelObject* renderer = curr->renderer(); 721 RenderLayerModelObject* renderer = curr->renderer();
733 if (renderer->style()->hasFilterOutsets()) 722 if (renderer->style()->hasFilterOutsets())
734 return true; 723 return true;
735 } 724 }
736 return false; 725 return false;
737 } 726 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 return clipRect; 801 return clipRect;
813 } 802 }
814 803
815 LayoutRect RenderLayer::paintingExtent(const RenderLayer* rootLayer, const Layou tRect& paintDirtyRect, const LayoutSize& subPixelAccumulation, PaintBehavior pai ntBehavior) 804 LayoutRect RenderLayer::paintingExtent(const RenderLayer* rootLayer, const Layou tRect& paintDirtyRect, const LayoutSize& subPixelAccumulation, PaintBehavior pai ntBehavior)
816 { 805 {
817 return intersection(transparencyClipBox(this, rootLayer, PaintingTransparenc yClipBox, RootOfTransparencyClipBox, subPixelAccumulation, paintBehavior), paint DirtyRect); 806 return intersection(transparencyClipBox(this, rootLayer, PaintingTransparenc yClipBox, RootOfTransparencyClipBox, subPixelAccumulation, paintBehavior), paint DirtyRect);
818 } 807 }
819 808
820 void RenderLayer::beginTransparencyLayers(GraphicsContext* context, const Render Layer* rootLayer, const LayoutRect& paintDirtyRect, const LayoutSize& subPixelAc cumulation, PaintBehavior paintBehavior) 809 void RenderLayer::beginTransparencyLayers(GraphicsContext* context, const Render Layer* rootLayer, const LayoutRect& paintDirtyRect, const LayoutSize& subPixelAc cumulation, PaintBehavior paintBehavior)
821 { 810 {
822 bool createTransparencyLayerForBlendMode = m_stackingNode->isStackingContext () && hasDescendantWithBlendMode(); 811 if (paintsWithTransparency(paintBehavior) && m_usedTransparency)
823 if ((paintsWithTransparency(paintBehavior) || paintsWithBlendMode() || creat eTransparencyLayerForBlendMode) && m_usedTransparency)
824 return; 812 return;
825 813
826 RenderLayer* ancestor = transparentPaintingAncestor(); 814 RenderLayer* ancestor = transparentPaintingAncestor();
827 if (ancestor) 815 if (ancestor)
828 ancestor->beginTransparencyLayers(context, rootLayer, paintDirtyRect, su bPixelAccumulation, paintBehavior); 816 ancestor->beginTransparencyLayers(context, rootLayer, paintDirtyRect, su bPixelAccumulation, paintBehavior);
829 817
830 if (paintsWithTransparency(paintBehavior) || paintsWithBlendMode() || create TransparencyLayerForBlendMode) { 818 if (paintsWithTransparency(paintBehavior)) {
831 m_usedTransparency = true; 819 m_usedTransparency = true;
832 context->save(); 820 context->save();
833 LayoutRect clipRect = paintingExtent(rootLayer, paintDirtyRect, subPixel Accumulation, paintBehavior); 821 LayoutRect clipRect = paintingExtent(rootLayer, paintDirtyRect, subPixel Accumulation, paintBehavior);
834 context->clip(clipRect); 822 context->clip(clipRect);
835 823
836 if (paintsWithBlendMode())
837 context->setCompositeOperation(context->compositeOperation(), m_rend erer->style()->blendMode());
838
839 context->beginTransparencyLayer(renderer()->opacity()); 824 context->beginTransparencyLayer(renderer()->opacity());
840 825
841 if (paintsWithBlendMode())
842 context->setCompositeOperation(context->compositeOperation(), WebBle ndModeNormal);
843 #ifdef REVEAL_TRANSPARENCY_LAYERS 826 #ifdef REVEAL_TRANSPARENCY_LAYERS
844 context->setFillColor(Color(0.0f, 0.0f, 0.5f, 0.2f)); 827 context->setFillColor(Color(0.0f, 0.0f, 0.5f, 0.2f));
845 context->fillRect(clipRect); 828 context->fillRect(clipRect);
846 #endif 829 #endif
847 } 830 }
848 } 831 }
849 832
850 void* RenderLayer::operator new(size_t sz) 833 void* RenderLayer::operator new(size_t sz)
851 { 834 {
852 return partitionAlloc(Partitions::getRenderingPartition(), sz); 835 return partitionAlloc(Partitions::getRenderingPartition(), sz);
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 if (!rootRelativeBoundsComputed) { 1283 if (!rootRelativeBoundsComputed) {
1301 rootRelativeBounds = physicalBoundingBoxIncludingReflectionA ndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); 1284 rootRelativeBounds = physicalBoundingBoxIncludingReflectionA ndStackingChildren(paintingInfo.rootLayer, offsetFromRoot);
1302 rootRelativeBoundsComputed = true; 1285 rootRelativeBoundsComputed = true;
1303 } 1286 }
1304 1287
1305 context->clipPath(clipPath->path(rootRelativeBounds), clipPath-> windRule()); 1288 context->clipPath(clipPath->path(rootRelativeBounds), clipPath-> windRule());
1306 } 1289 }
1307 } 1290 }
1308 } 1291 }
1309 1292
1310 // Blending operations must be performed only with the nearest ancestor stac king context.
1311 // Note that there is no need to create a transparency layer if we're painti ng the root.
1312 bool createTransparencyLayerForBlendMode = !renderer()->isDocumentElement() && m_stackingNode->isStackingContext() && hasDescendantWithBlendMode();
1313
1314 if (createTransparencyLayerForBlendMode)
1315 beginTransparencyLayers(context, paintingInfo.rootLayer, paintingInfo.pa intDirtyRect, paintingInfo.subPixelAccumulation, paintingInfo.paintBehavior);
1316
1317 LayerPaintingInfo localPaintingInfo(paintingInfo); 1293 LayerPaintingInfo localPaintingInfo(paintingInfo);
1318 bool deferredFiltersEnabled = renderer()->document().settings()->deferredFil tersEnabled(); 1294 bool deferredFiltersEnabled = renderer()->document().settings()->deferredFil tersEnabled();
1319 FilterEffectRendererHelper filterPainter(filterRenderer() && paintsWithFilte rs()); 1295 FilterEffectRendererHelper filterPainter(filterRenderer() && paintsWithFilte rs());
1320 1296
1321 LayerFragments layerFragments; 1297 LayerFragments layerFragments;
1322 if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars) { 1298 if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars) {
1323 // Collect the fragments. This will compute the clip rectangles and pain t offsets for each layer fragment, as well as whether or not the content of each 1299 // Collect the fragments. This will compute the clip rectangles and pain t offsets for each layer fragment, as well as whether or not the content of each
1324 // fragment should paint. 1300 // fragment should paint.
1325 collectFragments(layerFragments, localPaintingInfo.rootLayer, localPaint ingInfo.paintDirtyRect, 1301 collectFragments(layerFragments, localPaintingInfo.rootLayer, localPaint ingInfo.paintDirtyRect,
1326 (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : Pai ntingClipRects, 1302 (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : Pai ntingClipRects,
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 1414
1439 if (shouldPaintMask) 1415 if (shouldPaintMask)
1440 paintMaskForFragments(layerFragments, context, localPaintingInfo, painti ngRootForRenderer, paintFlags); 1416 paintMaskForFragments(layerFragments, context, localPaintingInfo, painti ngRootForRenderer, paintFlags);
1441 1417
1442 if (shouldPaintClippingMask) { 1418 if (shouldPaintClippingMask) {
1443 // Paint the border radius mask for the fragments. 1419 // Paint the border radius mask for the fragments.
1444 paintChildClippingMaskForFragments(layerFragments, context, localPaintin gInfo, paintingRootForRenderer, paintFlags); 1420 paintChildClippingMaskForFragments(layerFragments, context, localPaintin gInfo, paintingRootForRenderer, paintFlags);
1445 } 1421 }
1446 1422
1447 // End our transparency layer 1423 // End our transparency layer
1448 if ((haveTransparency || paintsWithBlendMode() || createTransparencyLayerFor BlendMode) && m_usedTransparency) { 1424 if (haveTransparency && m_usedTransparency) {
1449 context->endLayer(); 1425 context->endLayer();
1450 context->restore(); 1426 context->restore();
1451 m_usedTransparency = false; 1427 m_usedTransparency = false;
1452 } 1428 }
1453 } 1429 }
1454 1430
1455 void RenderLayer::paintLayerByApplyingTransform(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags, const LayoutPoint& translationOffset) 1431 void RenderLayer::paintLayerByApplyingTransform(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags, const LayoutPoint& translationOffset)
1456 { 1432 {
1457 // This involves subtracting out the position of the layer in our current co ordinate space, but preserving 1433 // This involves subtracting out the position of the layer in our current co ordinate space, but preserving
1458 // the accumulated error for sub-pixel layout. 1434 // the accumulated error for sub-pixel layout.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 void RenderLayer::paintBackgroundForFragments(const LayerFragments& layerFragmen ts, GraphicsContext* context, GraphicsContext* transparencyLayerContext, 1523 void RenderLayer::paintBackgroundForFragments(const LayerFragments& layerFragmen ts, GraphicsContext* context, GraphicsContext* transparencyLayerContext,
1548 const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const L ayerPaintingInfo& localPaintingInfo, PaintBehavior paintBehavior, 1524 const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const L ayerPaintingInfo& localPaintingInfo, PaintBehavior paintBehavior,
1549 RenderObject* paintingRootForRenderer, PaintLayerFlags paintFlags) 1525 RenderObject* paintingRootForRenderer, PaintLayerFlags paintFlags)
1550 { 1526 {
1551 for (size_t i = 0; i < layerFragments.size(); ++i) { 1527 for (size_t i = 0; i < layerFragments.size(); ++i) {
1552 const LayerFragment& fragment = layerFragments.at(i); 1528 const LayerFragment& fragment = layerFragments.at(i);
1553 if (!fragment.shouldPaintContent) 1529 if (!fragment.shouldPaintContent)
1554 continue; 1530 continue;
1555 1531
1556 // Begin transparency layers lazily now that we know we have to paint so mething. 1532 // Begin transparency layers lazily now that we know we have to paint so mething.
1557 if (haveTransparency || paintsWithBlendMode()) 1533 if (haveTransparency)
1558 beginTransparencyLayers(transparencyLayerContext, localPaintingInfo. rootLayer, transparencyPaintDirtyRect, localPaintingInfo.subPixelAccumulation, l ocalPaintingInfo.paintBehavior); 1534 beginTransparencyLayers(transparencyLayerContext, localPaintingInfo. rootLayer, transparencyPaintDirtyRect, localPaintingInfo.subPixelAccumulation, l ocalPaintingInfo.paintBehavior);
1559 1535
1560 if (localPaintingInfo.clipToDirtyRect) { 1536 if (localPaintingInfo.clipToDirtyRect) {
1561 // Paint our background first, before painting any child layers. 1537 // Paint our background first, before painting any child layers.
1562 // Establish the clip used to paint our background. 1538 // Establish the clip used to paint our background.
1563 clipToRect(localPaintingInfo, context, fragment.backgroundRect, pain tFlags, DoNotIncludeSelfForBorderRadius); // Background painting will handle cli pping to self. 1539 clipToRect(localPaintingInfo, context, fragment.backgroundRect, pain tFlags, DoNotIncludeSelfForBorderRadius); // Background painting will handle cli pping to self.
1564 } 1540 }
1565 1541
1566 // Paint the background. 1542 // Paint the background.
1567 // FIXME: Eventually we will collect the region from the fragment itself instead of just from the paint info. 1543 // FIXME: Eventually we will collect the region from the fragment itself instead of just from the paint info.
1568 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect .rect()), PaintPhaseBlockBackground, paintBehavior, paintingRootForRenderer, 0, localPaintingInfo.rootLayer->renderer()); 1544 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect .rect()), PaintPhaseBlockBackground, paintBehavior, paintingRootForRenderer, 0, localPaintingInfo.rootLayer->renderer());
1569 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r enderBoxLocation() + subPixelAccumulationIfNeeded(localPaintingInfo.subPixelAccu mulation, compositingState()))); 1545 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r enderBoxLocation() + subPixelAccumulationIfNeeded(localPaintingInfo.subPixelAccu mulation, compositingState())));
1570 1546
1571 if (localPaintingInfo.clipToDirtyRect) 1547 if (localPaintingInfo.clipToDirtyRect)
1572 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.back groundRect); 1548 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.back groundRect);
1573 } 1549 }
1574 } 1550 }
1575 1551
1576 void RenderLayer::paintForegroundForFragments(const LayerFragments& layerFragmen ts, GraphicsContext* context, GraphicsContext* transparencyLayerContext, 1552 void RenderLayer::paintForegroundForFragments(const LayerFragments& layerFragmen ts, GraphicsContext* context, GraphicsContext* transparencyLayerContext,
1577 const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const L ayerPaintingInfo& localPaintingInfo, PaintBehavior paintBehavior, 1553 const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const L ayerPaintingInfo& localPaintingInfo, PaintBehavior paintBehavior,
1578 RenderObject* paintingRootForRenderer, bool selectionOnly, PaintLayerFlags p aintFlags) 1554 RenderObject* paintingRootForRenderer, bool selectionOnly, PaintLayerFlags p aintFlags)
1579 { 1555 {
1580 // Begin transparency if we have something to paint. 1556 // Begin transparency if we have something to paint.
1581 if (haveTransparency || paintsWithBlendMode()) { 1557 if (haveTransparency) {
1582 for (size_t i = 0; i < layerFragments.size(); ++i) { 1558 for (size_t i = 0; i < layerFragments.size(); ++i) {
1583 const LayerFragment& fragment = layerFragments.at(i); 1559 const LayerFragment& fragment = layerFragments.at(i);
1584 if (fragment.shouldPaintContent && !fragment.foregroundRect.isEmpty( )) { 1560 if (fragment.shouldPaintContent && !fragment.foregroundRect.isEmpty( )) {
1585 beginTransparencyLayers(transparencyLayerContext, localPaintingI nfo.rootLayer, transparencyPaintDirtyRect, localPaintingInfo.subPixelAccumulatio n, localPaintingInfo.paintBehavior); 1561 beginTransparencyLayers(transparencyLayerContext, localPaintingI nfo.rootLayer, transparencyPaintDirtyRect, localPaintingInfo.subPixelAccumulatio n, localPaintingInfo.paintBehavior);
1586 break; 1562 break;
1587 } 1563 }
1588 } 1564 }
1589 } 1565 }
1590 1566
1591 // Optimize clipping for the single fragment case. 1567 // Optimize clipping for the single fragment case.
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
2387 return false; 2363 return false;
2388 2364
2389 return compositor()->clipsCompositingDescendants(this) && style->hasBorderRa dius(); 2365 return compositor()->clipsCompositingDescendants(this) && style->hasBorderRa dius();
2390 } 2366 }
2391 2367
2392 bool RenderLayer::paintsWithTransform(PaintBehavior paintBehavior) const 2368 bool RenderLayer::paintsWithTransform(PaintBehavior paintBehavior) const
2393 { 2369 {
2394 return transform() && ((paintBehavior & PaintBehaviorFlattenCompositingLayer s) || compositingState() != PaintsIntoOwnBacking); 2370 return transform() && ((paintBehavior & PaintBehaviorFlattenCompositingLayer s) || compositingState() != PaintsIntoOwnBacking);
2395 } 2371 }
2396 2372
2397 bool RenderLayer::paintsWithBlendMode() const
2398 {
2399 return m_renderer->hasBlendMode() && compositingState() != PaintsIntoOwnBack ing;
2400 }
2401
2402 bool RenderLayer::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const 2373 bool RenderLayer::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const
2403 { 2374 {
2404 if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant()) 2375 if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant())
2405 return false; 2376 return false;
2406 2377
2407 if (paintsWithTransparency(PaintBehaviorNormal)) 2378 if (paintsWithTransparency(PaintBehaviorNormal))
2408 return false; 2379 return false;
2409 2380
2410 if (paintsWithFilters() && renderer()->style()->filter().hasFilterThatAffect sOpacity()) 2381 if (paintsWithFilters() && renderer()->style()->filter().hasFilterThatAffect sOpacity())
2411 return false; 2382 return false;
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
2684 } 2655 }
2685 } 2656 }
2686 2657
2687 void showLayerTree(const blink::RenderObject* renderer) 2658 void showLayerTree(const blink::RenderObject* renderer)
2688 { 2659 {
2689 if (!renderer) 2660 if (!renderer)
2690 return; 2661 return;
2691 showLayerTree(renderer->enclosingLayer()); 2662 showLayerTree(renderer->enclosingLayer());
2692 } 2663 }
2693 #endif 2664 #endif
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderLayer.h ('k') | sky/engine/core/rendering/RenderObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698