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

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

Issue 865353002: Implement clip and scroll DisplayItems for PartPainter (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: amend one missing early out in PartPainter Created 5 years, 11 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
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/PartPainter.h" 6 #include "core/paint/PartPainter.h"
7 7
8 #include "core/paint/BoxPainter.h" 8 #include "core/paint/BoxPainter.h"
9
10 #include "core/paint/GraphicsContextAnnotator.h" 9 #include "core/paint/GraphicsContextAnnotator.h"
10 #include "core/paint/RenderDrawingRecorder.h"
11 #include "core/paint/RoundedInnerRectClipper.h"
11 #include "core/paint/ScrollableAreaPainter.h" 12 #include "core/paint/ScrollableAreaPainter.h"
13 #include "core/paint/TransformRecorder.h"
12 #include "core/rendering/PaintInfo.h" 14 #include "core/rendering/PaintInfo.h"
13 #include "core/rendering/RenderLayer.h" 15 #include "core/rendering/RenderLayer.h"
14 #include "core/rendering/RenderPart.h" 16 #include "core/rendering/RenderPart.h"
15 17
16 namespace blink { 18 namespace blink {
17 19
18 void PartPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffs et) 20 void PartPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffs et)
19 { 21 {
20 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, &m_renderPart); 22 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, &m_renderPart);
21 23
22 if (!m_renderPart.shouldPaint(paintInfo, paintOffset)) 24 if (!m_renderPart.shouldPaint(paintInfo, paintOffset))
23 return; 25 return;
24 26
25 LayoutPoint adjustedPaintOffset = paintOffset + m_renderPart.location(); 27 LayoutPoint adjustedPaintOffset = paintOffset + m_renderPart.location();
28 LayoutRect borderRect(adjustedPaintOffset, m_renderPart.size());
26 29
27 if (m_renderPart.hasBoxDecorationBackground() && (paintInfo.phase == PaintPh aseForeground || paintInfo.phase == PaintPhaseSelection)) 30 if (m_renderPart.hasBoxDecorationBackground() && (paintInfo.phase == PaintPh aseForeground || paintInfo.phase == PaintPhaseSelection))
28 BoxPainter(m_renderPart).paintBoxDecorationBackground(paintInfo, adjuste dPaintOffset); 31 BoxPainter(m_renderPart).paintBoxDecorationBackground(paintInfo, adjuste dPaintOffset);
29 32
30 if (paintInfo.phase == PaintPhaseMask) { 33 if (paintInfo.phase == PaintPhaseMask) {
31 BoxPainter(m_renderPart).paintMask(paintInfo, adjustedPaintOffset); 34 BoxPainter(m_renderPart).paintMask(paintInfo, adjustedPaintOffset);
32 return; 35 return;
33 } 36 }
34 37
35 if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSe lfOutline) && m_renderPart.style()->hasOutline()) 38 if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSe lfOutline) && m_renderPart.style()->hasOutline())
36 ObjectPainter(m_renderPart).paintOutline(paintInfo, LayoutRect(adjustedP aintOffset, m_renderPart.size())); 39 ObjectPainter(m_renderPart).paintOutline(paintInfo, borderRect);
37 40
38 if (paintInfo.phase != PaintPhaseForeground) 41 if (paintInfo.phase != PaintPhaseForeground)
39 return; 42 return;
40 43
44 OwnPtr<RoundedInnerRectClipper> clipper;
41 if (m_renderPart.style()->hasBorderRadius()) { 45 if (m_renderPart.style()->hasBorderRadius()) {
42 LayoutRect borderRect = LayoutRect(adjustedPaintOffset, m_renderPart.siz e());
43
44 if (borderRect.isEmpty()) 46 if (borderRect.isEmpty())
45 return; 47 return;
46 48
47 // Push a clip if we have a border radius, since we want to round the fo reground content that gets painted.
48 paintInfo.context->save();
49 FloatRoundedRect roundedInnerRect = m_renderPart.style()->getRoundedInne rBorderFor(borderRect, 49 FloatRoundedRect roundedInnerRect = m_renderPart.style()->getRoundedInne rBorderFor(borderRect,
50 m_renderPart.paddingTop() + m_renderPart.borderTop(), m_renderPart.p addingBottom() + m_renderPart.borderBottom(), m_renderPart.paddingLeft() + m_ren derPart.borderLeft(), m_renderPart.paddingRight() + m_renderPart.borderRight(), true, true); 50 m_renderPart.paddingTop() + m_renderPart.borderTop(), m_renderPart.p addingBottom() + m_renderPart.borderBottom(), m_renderPart.paddingLeft() + m_ren derPart.borderLeft(), m_renderPart.paddingRight() + m_renderPart.borderRight(), true, true);
51 BoxPainter::clipRoundedInnerRect(paintInfo.context, borderRect, roundedI nnerRect); 51 clipper = adoptPtr(new RoundedInnerRectClipper(m_renderPart, paintInfo, borderRect, roundedInnerRect, ApplyToDisplayListIfEnabled));
52 } 52 }
53 53
54 if (m_renderPart.widget()) 54 if (m_renderPart.widget())
55 m_renderPart.paintContents(paintInfo, paintOffset); 55 m_renderPart.paintContents(paintInfo, paintOffset);
56 56 clipper.clear();
chrishtr 2015/01/23 23:35:33 Instead of manual clear, put it in a sub-block wit
trchen 2015/01/23 23:40:43 Acknowledged.
trchen 2015/01/23 23:47:59 Done.
57 if (m_renderPart.style()->hasBorderRadius())
58 paintInfo.context->restore();
59 57
60 // Paint a partially transparent wash over selected widgets. 58 // Paint a partially transparent wash over selected widgets.
61 if (m_renderPart.isSelected() && !m_renderPart.document().printing()) { 59 if (m_renderPart.isSelected() && !m_renderPart.document().printing()) {
62 LayoutRect rect = m_renderPart.localSelectionRect(); 60 LayoutRect rect = m_renderPart.localSelectionRect();
63 rect.moveBy(adjustedPaintOffset); 61 rect.moveBy(adjustedPaintOffset);
64 paintInfo.context->fillRect(pixelSnappedIntRect(rect), m_renderPart.sele ctionBackgroundColor()); 62 IntRect selectionRect = pixelSnappedIntRect(rect);
63 RenderDrawingRecorder recorder(paintInfo.context, m_renderPart, paintInf o.phase, selectionRect);
64 paintInfo.context->fillRect(selectionRect, m_renderPart.selectionBackgro undColor());
65 } 65 }
66 66
67 if (m_renderPart.canResize()) 67 if (m_renderPart.canResize())
68 ScrollableAreaPainter(*m_renderPart.layer()->scrollableArea()).paintResi zer(paintInfo.context, roundedIntPoint(adjustedPaintOffset), paintInfo.rect); 68 ScrollableAreaPainter(*m_renderPart.layer()->scrollableArea()).paintResi zer(paintInfo.context, roundedIntPoint(adjustedPaintOffset), paintInfo.rect);
69 } 69 }
70 70
71 void PartPainter::paintContents(const PaintInfo& paintInfo, const LayoutPoint& p aintOffset) 71 void PartPainter::paintContents(const PaintInfo& paintInfo, const LayoutPoint& p aintOffset)
72 { 72 {
73 LayoutPoint adjustedPaintOffset = paintOffset + m_renderPart.location(); 73 LayoutPoint adjustedPaintOffset = paintOffset + m_renderPart.location();
74 74
75 Widget* widget = m_renderPart.widget(); 75 Widget* widget = m_renderPart.widget();
76 RELEASE_ASSERT(widget); 76 RELEASE_ASSERT(widget);
77 77
78 // Tell the widget to paint now. This is the only time the widget is allowed 78 // Tell the widget to paint now. This is the only time the widget is allowed
79 // to paint itself. That way it will composite properly with z-indexed layer s. 79 // to paint itself. That way it will composite properly with z-indexed layer s.
80 IntPoint widgetLocation = widget->frameRect().location(); 80 IntPoint widgetLocation = widget->frameRect().location();
81 IntPoint paintLocation(roundToInt(adjustedPaintOffset.x() + m_renderPart.bor derLeft() + m_renderPart.paddingLeft()), 81 IntPoint paintLocation(roundToInt(adjustedPaintOffset.x() + m_renderPart.bor derLeft() + m_renderPart.paddingLeft()),
82 roundToInt(adjustedPaintOffset.y() + m_renderPart.borderTop() + m_render Part.paddingTop())); 82 roundToInt(adjustedPaintOffset.y() + m_renderPart.borderTop() + m_render Part.paddingTop()));
83 IntRect paintRect = paintInfo.rect; 83 IntRect paintRect = paintInfo.rect;
84 84
85 IntSize widgetPaintOffset = paintLocation - widgetLocation; 85 IntSize widgetPaintOffset = paintLocation - widgetLocation;
86 // When painting widgets into compositing layers, tx and ty are relative to the enclosing compositing layer, 86 // When painting widgets into compositing layers, tx and ty are relative to the enclosing compositing layer,
87 // not the root. In this case, shift the CTM and adjust the paintRect to be root-relative to fix plug-in drawing. 87 // not the root. In this case, shift the CTM and adjust the paintRect to be root-relative to fix plug-in drawing.
88 if (!widgetPaintOffset.isZero()) { 88 TransformRecorder transform(*paintInfo.context, m_renderPart.displayItemClie nt(),
89 paintInfo.context->translate(widgetPaintOffset.width(), widgetPaintOffse t.height()); 89 AffineTransform::translation(widgetPaintOffset.width(), widgetPaintOffse t.height()));
90 paintRect.move(-widgetPaintOffset);
91 }
92 widget->paint(paintInfo.context, paintRect); 90 widget->paint(paintInfo.context, paintRect);
93
94 if (!widgetPaintOffset.isZero())
95 paintInfo.context->translate(-widgetPaintOffset.width(), -widgetPaintOff set.height());
96 } 91 }
97 92
98 } // namespace blink 93 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698