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

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

Issue 1315993004: Implement a paint offset cache for slimming paint v2 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 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
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/InlinePainter.h" 6 #include "core/paint/InlinePainter.h"
7 7
8 #include "core/layout/LayoutBlock.h" 8 #include "core/layout/LayoutBlock.h"
9 #include "core/layout/LayoutInline.h" 9 #include "core/layout/LayoutInline.h"
10 #include "core/layout/LayoutTheme.h" 10 #include "core/layout/LayoutTheme.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 void InlinePainter::paintOutline(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) 47 void InlinePainter::paintOutline(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
48 { 48 {
49 const ComputedStyle& styleToUse = m_layoutInline.styleRef(); 49 const ComputedStyle& styleToUse = m_layoutInline.styleRef();
50 if (!styleToUse.hasOutline()) 50 if (!styleToUse.hasOutline())
51 return; 51 return;
52 52
53 if (styleToUse.outlineStyleIsAuto()) { 53 if (styleToUse.outlineStyleIsAuto()) {
54 if (!LayoutTheme::theme().shouldDrawDefaultFocusRing(&m_layoutInline)) 54 if (!LayoutTheme::theme().shouldDrawDefaultFocusRing(&m_layoutInline))
55 return; 55 return;
56 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.c ontext, m_layoutInline, paintInfo.phase)) 56 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.c ontext, m_layoutInline, paintInfo.phase, paintOffset))
57 return; 57 return;
58 58
59 Vector<LayoutRect> focusRingRects; 59 Vector<LayoutRect> focusRingRects;
60 m_layoutInline.addOutlineRects(focusRingRects, paintOffset); 60 m_layoutInline.addOutlineRects(focusRingRects, paintOffset);
61 61
62 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutInline, paintInfo.phase, outlinePaintRect(focusRingRects, LayoutPoint())); 62 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutInline, paintInfo.phase, outlinePaintRect(focusRingRects, LayoutPoint()), paintOffset);
63 // Only paint the focus ring by hand if the theme isn't able to draw the focus ring. 63 // Only paint the focus ring by hand if the theme isn't able to draw the focus ring.
64 ObjectPainter(m_layoutInline).paintFocusRing(paintInfo, styleToUse, focu sRingRects); 64 ObjectPainter(m_layoutInline).paintFocusRing(paintInfo, styleToUse, focu sRingRects);
65 return; 65 return;
66 } 66 }
67 67
68 if (styleToUse.outlineStyle() == BNONE) 68 if (styleToUse.outlineStyle() == BNONE)
69 return; 69 return;
70 70
71 GraphicsContext* graphicsContext = paintInfo.context; 71 GraphicsContext* graphicsContext = paintInfo.context;
72 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*graphicsContext , m_layoutInline, paintInfo.phase)) 72 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*graphicsContext , m_layoutInline, paintInfo.phase, paintOffset))
73 return; 73 return;
74 74
75 Vector<LayoutRect> rects; 75 Vector<LayoutRect> rects;
76 76
77 rects.append(LayoutRect()); 77 rects.append(LayoutRect());
78 for (InlineFlowBox* curr = m_layoutInline.firstLineBox(); curr; curr = curr- >nextLineBox()) { 78 for (InlineFlowBox* curr = m_layoutInline.firstLineBox(); curr; curr = curr- >nextLineBox()) {
79 RootInlineBox& root = curr->root(); 79 RootInlineBox& root = curr->root();
80 LayoutUnit top = std::max<LayoutUnit>(root.lineTop(), curr->logicalTop() ); 80 LayoutUnit top = std::max<LayoutUnit>(root.lineTop(), curr->logicalTop() );
81 LayoutUnit bottom = std::min<LayoutUnit>(root.lineBottom(), curr->logica lBottom()); 81 LayoutUnit bottom = std::min<LayoutUnit>(root.lineBottom(), curr->logica lBottom());
82 rects.append(LayoutRect(curr->x(), top, curr->logicalWidth(), bottom - t op)); 82 rects.append(LayoutRect(curr->x(), top, curr->logicalWidth(), bottom - t op));
83 } 83 }
84 rects.append(LayoutRect()); 84 rects.append(LayoutRect());
85 85
86 Color outlineColor = m_layoutInline.resolveColor(styleToUse, CSSPropertyOutl ineColor); 86 Color outlineColor = m_layoutInline.resolveColor(styleToUse, CSSPropertyOutl ineColor);
87 bool useTransparencyLayer = outlineColor.hasAlpha(); 87 bool useTransparencyLayer = outlineColor.hasAlpha();
88 88
89 LayoutObjectDrawingRecorder recorder(*graphicsContext, m_layoutInline, paint Info.phase, outlinePaintRect(rects, paintOffset)); 89 LayoutObjectDrawingRecorder recorder(*graphicsContext, m_layoutInline, paint Info.phase, outlinePaintRect(rects, paintOffset), paintOffset);
90 if (useTransparencyLayer) { 90 if (useTransparencyLayer) {
91 graphicsContext->beginLayer(static_cast<float>(outlineColor.alpha()) / 2 55); 91 graphicsContext->beginLayer(static_cast<float>(outlineColor.alpha()) / 2 55);
92 outlineColor = Color(outlineColor.red(), outlineColor.green(), outlineCo lor.blue()); 92 outlineColor = Color(outlineColor.red(), outlineColor.green(), outlineCo lor.blue());
93 } 93 }
94 94
95 for (unsigned i = 1; i < rects.size() - 1; i++) 95 for (unsigned i = 1; i < rects.size() - 1; i++)
96 paintOutlineForLine(graphicsContext, paintOffset, rects.at(i - 1), rects .at(i), rects.at(i + 1), outlineColor); 96 paintOutlineForLine(graphicsContext, paintOffset, rects.at(i - 1), rects .at(i), rects.at(i + 1), outlineColor);
97 97
98 if (useTransparencyLayer) 98 if (useTransparencyLayer)
99 graphicsContext->endLayer(); 99 graphicsContext->endLayer();
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 pixelSnappedBox.maxX() + outlineWidth, 216 pixelSnappedBox.maxX() + outlineWidth,
217 pixelSnappedBox.maxY() + outlineWidth, 217 pixelSnappedBox.maxY() + outlineWidth,
218 BSBottom, outlineColor, outlineStyle, 218 BSBottom, outlineColor, outlineStyle,
219 outlineWidth, 219 outlineWidth,
220 outlineWidth, 220 outlineWidth,
221 false); 221 false);
222 } 222 }
223 } 223 }
224 224
225 } // namespace blink 225 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698