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

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

Issue 1220583004: Refactor DrawingRecorders to check for cached drawings earlier (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 5 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
« no previous file with comments | « Source/core/paint/InlineFlowBoxPainter.cpp ('k') | Source/core/paint/InlineTextBoxPainter.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/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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 return outlineRect; 44 return outlineRect;
45 } 45 }
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 Vector<LayoutRect> focusRingRects; 55 return;
56 m_layoutInline.addFocusRingRects(focusRingRects, paintOffset); 56 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.c ontext, m_layoutInline, paintInfo.phase))
57 return;
57 58
58 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutInl ine, paintInfo.phase, outlinePaintRect(focusRingRects, LayoutPoint())); 59 Vector<LayoutRect> focusRingRects;
59 if (recorder.canUseCachedDrawing()) 60 m_layoutInline.addFocusRingRects(focusRingRects, paintOffset);
60 return;
61 61
62 // Only paint the focus ring by hand if the theme isn't able to draw the focus ring. 62 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutInline, paintInfo.phase, outlinePaintRect(focusRingRects, LayoutPoint()));
63 ObjectPainter(m_layoutInline).paintFocusRing(paintInfo, styleToUse, focusRingRects); 63 // Only paint the focus ring by hand if the theme isn't able to draw the focus ring.
64 } 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;
72 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*graphicsContext , m_layoutInline, paintInfo.phase))
73 return;
74
71 Vector<LayoutRect> rects; 75 Vector<LayoutRect> rects;
72 76
73 rects.append(LayoutRect()); 77 rects.append(LayoutRect());
74 for (InlineFlowBox* curr = m_layoutInline.firstLineBox(); curr; curr = curr- >nextLineBox()) { 78 for (InlineFlowBox* curr = m_layoutInline.firstLineBox(); curr; curr = curr- >nextLineBox()) {
75 RootInlineBox& root = curr->root(); 79 RootInlineBox& root = curr->root();
76 LayoutUnit top = std::max<LayoutUnit>(root.lineTop(), curr->logicalTop() ); 80 LayoutUnit top = std::max<LayoutUnit>(root.lineTop(), curr->logicalTop() );
77 LayoutUnit bottom = std::min<LayoutUnit>(root.lineBottom(), curr->logica lBottom()); 81 LayoutUnit bottom = std::min<LayoutUnit>(root.lineBottom(), curr->logica lBottom());
78 rects.append(LayoutRect(curr->x(), top, curr->logicalWidth(), bottom - t op)); 82 rects.append(LayoutRect(curr->x(), top, curr->logicalWidth(), bottom - t op));
79 } 83 }
80 rects.append(LayoutRect()); 84 rects.append(LayoutRect());
81 85
82 Color outlineColor = m_layoutInline.resolveColor(styleToUse, CSSPropertyOutl ineColor); 86 Color outlineColor = m_layoutInline.resolveColor(styleToUse, CSSPropertyOutl ineColor);
83 bool useTransparencyLayer = outlineColor.hasAlpha(); 87 bool useTransparencyLayer = outlineColor.hasAlpha();
84 88
85 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutInline, pai ntInfo.phase, outlinePaintRect(rects, paintOffset)); 89 LayoutObjectDrawingRecorder recorder(*graphicsContext, m_layoutInline, paint Info.phase, outlinePaintRect(rects, paintOffset));
86 if (recorder.canUseCachedDrawing())
87 return;
88
89 GraphicsContext* graphicsContext = paintInfo.context;
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
« no previous file with comments | « Source/core/paint/InlineFlowBoxPainter.cpp ('k') | Source/core/paint/InlineTextBoxPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698