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

Side by Side Diff: Source/core/paint/TableCellPainter.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/ScrollableAreaPainter.cpp ('k') | Source/core/paint/TablePainter.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/TableCellPainter.h" 6 #include "core/paint/TableCellPainter.h"
7 7
8 #include "core/layout/LayoutTableCell.h" 8 #include "core/layout/LayoutTableCell.h"
9 #include "core/paint/BlockPainter.h" 9 #include "core/paint/BlockPainter.h"
10 #include "core/paint/BoxPainter.h" 10 #include "core/paint/BoxPainter.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 LayoutRect paintRect = paintBounds(paintOffset, AddOffsetFromParent); 99 LayoutRect paintRect = paintBounds(paintOffset, AddOffsetFromParent);
100 IntRect borderRect = pixelSnappedIntRect(paintRect.x() - leftWidth / 2, 100 IntRect borderRect = pixelSnappedIntRect(paintRect.x() - leftWidth / 2,
101 paintRect.y() - topWidth / 2, 101 paintRect.y() - topWidth / 2,
102 paintRect.width() + leftWidth / 2 + (rightWidth + 1) / 2, 102 paintRect.width() + leftWidth / 2 + (rightWidth + 1) / 2,
103 paintRect.height() + topWidth / 2 + (bottomWidth + 1) / 2); 103 paintRect.height() + topWidth / 2 + (bottomWidth + 1) / 2);
104 104
105 if (!borderRect.intersects(paintInfo.rect)) 105 if (!borderRect.intersects(paintInfo.rect))
106 return; 106 return;
107 107
108 GraphicsContext* graphicsContext = paintInfo.context; 108 GraphicsContext* graphicsContext = paintInfo.context;
109 LayoutObjectDrawingRecorder recorder(*graphicsContext, m_layoutTableCell, pa intInfo.phase, borderRect); 109 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*graphicsContext , m_layoutTableCell, paintInfo.phase))
110 if (recorder.canUseCachedDrawing())
111 return; 110 return;
112 111
112 LayoutObjectDrawingRecorder recorder(*graphicsContext, m_layoutTableCell, pa intInfo.phase, borderRect);
113 Color cellColor = m_layoutTableCell.resolveColor(CSSPropertyColor); 113 Color cellColor = m_layoutTableCell.resolveColor(CSSPropertyColor);
114 bool antialias = BoxPainter::shouldAntialiasLines(graphicsContext); 114 bool antialias = BoxPainter::shouldAntialiasLines(graphicsContext);
115 115
116 // We never paint diagonals at the joins. We simply let the border with the highest 116 // We never paint diagonals at the joins. We simply let the border with the highest
117 // precedence paint on top of borders with lower precedence. 117 // precedence paint on top of borders with lower precedence.
118 if (shouldPaintTop) { 118 if (shouldPaintTop) {
119 ObjectPainter::drawLineForBoxSide(graphicsContext, borderRect.x(), borde rRect.y(), borderRect.maxX(), borderRect.y() + topWidth, BSTop, 119 ObjectPainter::drawLineForBoxSide(graphicsContext, borderRect.x(), borde rRect.y(), borderRect.maxX(), borderRect.y() + topWidth, BSTop,
120 topBorderValue.color().resolve(cellColor), collapsedBorderStyle(topB orderValue.style()), 0, 0, antialias); 120 topBorderValue.color().resolve(cellColor), collapsedBorderStyle(topB orderValue.style()), 0, 0, antialias);
121 } 121 }
122 if (shouldPaintBottom) { 122 if (shouldPaintBottom) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 return; 173 return;
174 174
175 LayoutTable* table = m_layoutTableCell.table(); 175 LayoutTable* table = m_layoutTableCell.table();
176 if (!table->collapseBorders() && m_layoutTableCell.style()->emptyCells() == HIDE && !m_layoutTableCell.firstChild()) 176 if (!table->collapseBorders() && m_layoutTableCell.style()->emptyCells() == HIDE && !m_layoutTableCell.firstChild())
177 return; 177 return;
178 178
179 bool needsToPaintBorder = m_layoutTableCell.styleRef().hasBorderDecoration() && !table->collapseBorders(); 179 bool needsToPaintBorder = m_layoutTableCell.styleRef().hasBorderDecoration() && !table->collapseBorders();
180 if (!m_layoutTableCell.hasBackground() && !m_layoutTableCell.styleRef().boxS hadow() && !needsToPaintBorder) 180 if (!m_layoutTableCell.hasBackground() && !m_layoutTableCell.styleRef().boxS hadow() && !needsToPaintBorder)
181 return; 181 return;
182 182
183 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte xt, m_layoutTableCell, DisplayItem::BoxDecorationBackground))
184 return;
185
183 LayoutRect visualOverflowRect = m_layoutTableCell.visualOverflowRect(); 186 LayoutRect visualOverflowRect = m_layoutTableCell.visualOverflowRect();
184 visualOverflowRect.moveBy(paintOffset); 187 visualOverflowRect.moveBy(paintOffset);
185 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutTableCell, DisplayItem::BoxDecorationBackground, pixelSnappedIntRect(visualOverflowRect)); 188 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutTableCell, DisplayItem::BoxDecorationBackground, pixelSnappedIntRect(visualOverflowRect));
186 if (recorder.canUseCachedDrawing())
187 return;
188 189
189 LayoutRect paintRect = paintBounds(paintOffset, DoNotAddOffsetFromParent); 190 LayoutRect paintRect = paintBounds(paintOffset, DoNotAddOffsetFromParent);
190 191
191 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef( ), Normal); 192 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef( ), Normal);
192 193
193 // Paint our cell background. 194 // Paint our cell background.
194 paintBackgroundsBehindCell(paintInfo, paintOffset, &m_layoutTableCell); 195 paintBackgroundsBehindCell(paintInfo, paintOffset, &m_layoutTableCell);
195 196
196 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef( ), Inset); 197 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef( ), Inset);
197 198
198 if (!needsToPaintBorder) 199 if (!needsToPaintBorder)
199 return; 200 return;
200 201
201 BoxPainter::paintBorder(m_layoutTableCell, paintInfo, paintRect, m_layoutTab leCell.styleRef()); 202 BoxPainter::paintBorder(m_layoutTableCell, paintInfo, paintRect, m_layoutTab leCell.styleRef());
202 } 203 }
203 204
204 void TableCellPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) 205 void TableCellPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
205 { 206 {
206 if (m_layoutTableCell.style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) 207 if (m_layoutTableCell.style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask)
207 return; 208 return;
208 209
209 LayoutTable* tableElt = m_layoutTableCell.table(); 210 LayoutTable* tableElt = m_layoutTableCell.table();
210 if (!tableElt->collapseBorders() && m_layoutTableCell.style()->emptyCells() == HIDE && !m_layoutTableCell.firstChild()) 211 if (!tableElt->collapseBorders() && m_layoutTableCell.style()->emptyCells() == HIDE && !m_layoutTableCell.firstChild())
211 return; 212 return;
212 213
214 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte xt, m_layoutTableCell, paintInfo.phase))
215 return;
216
213 LayoutRect paintRect = paintBounds(paintOffset, DoNotAddOffsetFromParent); 217 LayoutRect paintRect = paintBounds(paintOffset, DoNotAddOffsetFromParent);
214 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutTableCell, paintInfo.phase, paintRect); 218 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutTableCell, paintInfo.phase, paintRect);
215 if (recorder.canUseCachedDrawing())
216 return;
217
218 BoxPainter(m_layoutTableCell).paintMaskImages(paintInfo, paintRect); 219 BoxPainter(m_layoutTableCell).paintMaskImages(paintInfo, paintRect);
219 } 220 }
220 221
221 LayoutRect TableCellPainter::paintBounds(const LayoutPoint& paintOffset, PaintBo undOffsetBehavior paintBoundOffsetBehavior) 222 LayoutRect TableCellPainter::paintBounds(const LayoutPoint& paintOffset, PaintBo undOffsetBehavior paintBoundOffsetBehavior)
222 { 223 {
223 LayoutPoint adjustedPaintOffset = paintOffset; 224 LayoutPoint adjustedPaintOffset = paintOffset;
224 if (paintBoundOffsetBehavior == AddOffsetFromParent) 225 if (paintBoundOffsetBehavior == AddOffsetFromParent)
225 adjustedPaintOffset.moveBy(m_layoutTableCell.location()); 226 adjustedPaintOffset.moveBy(m_layoutTableCell.location());
226 return LayoutRect(adjustedPaintOffset, LayoutSize(m_layoutTableCell.pixelSna ppedSize())); 227 return LayoutRect(adjustedPaintOffset, LayoutSize(m_layoutTableCell.pixelSna ppedSize()));
227 } 228 }
228 229
229 } // namespace blink 230 } // namespace blink
230 231
OLDNEW
« no previous file with comments | « Source/core/paint/ScrollableAreaPainter.cpp ('k') | Source/core/paint/TablePainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698