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

Side by Side Diff: Source/core/paint/LayerClipRecorder.cpp

Issue 898783003: Move rendering/RenderLayer* to layout/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/paint/LayerClipRecorder.h ('k') | Source/core/paint/LayerClipRecorderTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/paint/LayerClipRecorder.h" 6 #include "core/paint/LayerClipRecorder.h"
7 7
8 #include "core/layout/Layer.h"
8 #include "core/rendering/ClipRect.h" 9 #include "core/rendering/ClipRect.h"
9 #include "core/rendering/RenderLayer.h"
10 #include "core/rendering/RenderView.h" 10 #include "core/rendering/RenderView.h"
11 #include "platform/RuntimeEnabledFeatures.h" 11 #include "platform/RuntimeEnabledFeatures.h"
12 #include "platform/geometry/IntRect.h" 12 #include "platform/geometry/IntRect.h"
13 #include "platform/graphics/GraphicsContext.h" 13 #include "platform/graphics/GraphicsContext.h"
14 #include "platform/graphics/GraphicsLayer.h" 14 #include "platform/graphics/GraphicsLayer.h"
15 #include "platform/graphics/paint/ClipRecorder.h" 15 #include "platform/graphics/paint/ClipRecorder.h"
16 #include "platform/graphics/paint/DisplayItemList.h" 16 #include "platform/graphics/paint/DisplayItemList.h"
17 17
18 namespace blink { 18 namespace blink {
19 19
20 LayerClipRecorder::LayerClipRecorder(const RenderLayerModelObject* renderer, Gra phicsContext* graphicsContext, DisplayItem::Type clipType, const ClipRect& clipR ect, 20 LayerClipRecorder::LayerClipRecorder(const LayoutLayerModelObject* renderer, Gra phicsContext* graphicsContext, DisplayItem::Type clipType, const ClipRect& clipR ect,
21 const LayerPaintingInfo* localPaintingInfo, const LayoutPoint& fragmentOffse t, PaintLayerFlags paintFlags, BorderRadiusClippingRule rule) 21 const LayerPaintingInfo* localPaintingInfo, const LayoutPoint& fragmentOffse t, PaintLayerFlags paintFlags, BorderRadiusClippingRule rule)
22 : m_graphicsContext(graphicsContext) 22 : m_graphicsContext(graphicsContext)
23 , m_renderer(renderer) 23 , m_renderer(renderer)
24 , m_clipType(clipType) 24 , m_clipType(clipType)
25 { 25 {
26 ASSERT(renderer); 26 ASSERT(renderer);
27 27
28 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect()); 28 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect());
29 OwnPtr<ClipDisplayItem> clipDisplayItem = ClipDisplayItem::create(renderer-> displayItemClient(), clipType, snappedClipRect); 29 OwnPtr<ClipDisplayItem> clipDisplayItem = ClipDisplayItem::create(renderer-> displayItemClient(), clipType, snappedClipRect);
30 if (localPaintingInfo && clipRect.hasRadius()) 30 if (localPaintingInfo && clipRect.hasRadius())
31 collectRoundedRectClips(*renderer->layer(), *localPaintingInfo, graphics Context, fragmentOffset, paintFlags, rule, clipDisplayItem->roundedRectClips()); 31 collectRoundedRectClips(*renderer->layer(), *localPaintingInfo, graphics Context, fragmentOffset, paintFlags, rule, clipDisplayItem->roundedRectClips());
32 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) { 32 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) {
33 clipDisplayItem->replay(graphicsContext); 33 clipDisplayItem->replay(graphicsContext);
34 } else { 34 } else {
35 ASSERT(m_graphicsContext->displayItemList()); 35 ASSERT(m_graphicsContext->displayItemList());
36 m_graphicsContext->displayItemList()->add(clipDisplayItem.release()); 36 m_graphicsContext->displayItemList()->add(clipDisplayItem.release());
37 } 37 }
38 } 38 }
39 39
40 static bool inContainingBlockChain(RenderLayer* startLayer, RenderLayer* endLaye r) 40 static bool inContainingBlockChain(Layer* startLayer, Layer* endLayer)
41 { 41 {
42 if (startLayer == endLayer) 42 if (startLayer == endLayer)
43 return true; 43 return true;
44 44
45 RenderView* view = startLayer->renderer()->view(); 45 RenderView* view = startLayer->renderer()->view();
46 for (RenderBlock* currentBlock = startLayer->renderer()->containingBlock(); currentBlock && currentBlock != view; currentBlock = currentBlock->containingBlo ck()) { 46 for (RenderBlock* currentBlock = startLayer->renderer()->containingBlock(); currentBlock && currentBlock != view; currentBlock = currentBlock->containingBlo ck()) {
47 if (currentBlock->layer() == endLayer) 47 if (currentBlock->layer() == endLayer)
48 return true; 48 return true;
49 } 49 }
50 50
51 return false; 51 return false;
52 } 52 }
53 53
54 void LayerClipRecorder::collectRoundedRectClips(RenderLayer& renderLayer, const LayerPaintingInfo& localPaintingInfo, GraphicsContext* context, const LayoutPoin t& fragmentOffset, PaintLayerFlags paintFlags, 54 void LayerClipRecorder::collectRoundedRectClips(Layer& renderLayer, const LayerP aintingInfo& localPaintingInfo, GraphicsContext* context, const LayoutPoint& fra gmentOffset, PaintLayerFlags paintFlags,
55 BorderRadiusClippingRule rule, Vector<FloatRoundedRect>& roundedRectClips) 55 BorderRadiusClippingRule rule, Vector<FloatRoundedRect>& roundedRectClips)
56 { 56 {
57 // If the clip rect has been tainted by a border radius, then we have to wal k up our layer chain applying the clips from 57 // If the clip rect has been tainted by a border radius, then we have to wal k up our layer chain applying the clips from
58 // any layers with overflow. The condition for being able to apply these cli ps is that the overflow object be in our 58 // any layers with overflow. The condition for being able to apply these cli ps is that the overflow object be in our
59 // containing block chain so we check that also. 59 // containing block chain so we check that also.
60 for (RenderLayer* layer = rule == IncludeSelfForBorderRadius ? &renderLayer : renderLayer.parent(); layer; layer = layer->parent()) { 60 for (Layer* layer = rule == IncludeSelfForBorderRadius ? &renderLayer : rend erLayer.parent(); layer; layer = layer->parent()) {
61 // Composited scrolling layers handle border-radius clip in the composit or via a mask layer. We do not 61 // Composited scrolling layers handle border-radius clip in the composit or via a mask layer. We do not
62 // want to apply a border-radius clip to the layer contents itself, beca use that would require re-rastering 62 // want to apply a border-radius clip to the layer contents itself, beca use that would require re-rastering
63 // every frame to update the clip. We only want to make sure that the ma sk layer is properly clipped so 63 // every frame to update the clip. We only want to make sure that the ma sk layer is properly clipped so
64 // that it can in turn clip the scrolled contents in the compositor. 64 // that it can in turn clip the scrolled contents in the compositor.
65 if (layer->needsCompositedScrolling() && !(paintFlags & PaintLayerPainti ngChildClippingMaskPhase)) 65 if (layer->needsCompositedScrolling() && !(paintFlags & PaintLayerPainti ngChildClippingMaskPhase))
66 break; 66 break;
67 67
68 if (layer->renderer()->hasOverflowClip() && layer->renderer()->style()-> hasBorderRadius() && inContainingBlockChain(&renderLayer, layer)) { 68 if (layer->renderer()->hasOverflowClip() && layer->renderer()->style()-> hasBorderRadius() && inContainingBlockChain(&renderLayer, layer)) {
69 LayoutPoint delta(fragmentOffset); 69 LayoutPoint delta(fragmentOffset);
70 layer->convertToLayerCoords(localPaintingInfo.rootLayer, delta); 70 layer->convertToLayerCoords(localPaintingInfo.rootLayer, delta);
(...skipping 11 matching lines...) Expand all
82 DisplayItem::Type endType = DisplayItem::clipTypeToEndClipType(m_clipTyp e); 82 DisplayItem::Type endType = DisplayItem::clipTypeToEndClipType(m_clipTyp e);
83 OwnPtr<EndClipDisplayItem> endClip = EndClipDisplayItem::create(m_render er->displayItemClient(), endType); 83 OwnPtr<EndClipDisplayItem> endClip = EndClipDisplayItem::create(m_render er->displayItemClient(), endType);
84 ASSERT(m_graphicsContext->displayItemList()); 84 ASSERT(m_graphicsContext->displayItemList());
85 m_graphicsContext->displayItemList()->add(endClip.release()); 85 m_graphicsContext->displayItemList()->add(endClip.release());
86 } else { 86 } else {
87 m_graphicsContext->restore(); 87 m_graphicsContext->restore();
88 } 88 }
89 } 89 }
90 90
91 } // namespace blink 91 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/LayerClipRecorder.h ('k') | Source/core/paint/LayerClipRecorderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698