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

Side by Side Diff: Source/core/paint/TableCellPainter.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: Fix bugs caught by unittest failures 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/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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 LayoutRect paintRect = paintBounds(paintOffset, AddOffsetFromParent); 105 LayoutRect paintRect = paintBounds(paintOffset, AddOffsetFromParent);
106 IntRect borderRect = pixelSnappedIntRect(paintRect.x() - leftWidth / 2, 106 IntRect borderRect = pixelSnappedIntRect(paintRect.x() - leftWidth / 2,
107 paintRect.y() - topWidth / 2, 107 paintRect.y() - topWidth / 2,
108 paintRect.width() + leftWidth / 2 + (rightWidth + 1) / 2, 108 paintRect.width() + leftWidth / 2 + (rightWidth + 1) / 2,
109 paintRect.height() + topWidth / 2 + (bottomWidth + 1) / 2); 109 paintRect.height() + topWidth / 2 + (bottomWidth + 1) / 2);
110 110
111 if (!borderRect.intersects(paintInfo.rect)) 111 if (!borderRect.intersects(paintInfo.rect))
112 return; 112 return;
113 113
114 GraphicsContext* graphicsContext = paintInfo.context; 114 GraphicsContext* graphicsContext = paintInfo.context;
115 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*graphicsContext , m_layoutTableCell, static_cast<DisplayItem::Type>(displayItemType))) 115 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*graphicsContext , m_layoutTableCell, static_cast<DisplayItem::Type>(displayItemType), paintOffse t))
116 return; 116 return;
117 117
118 LayoutObjectDrawingRecorder recorder(*graphicsContext, m_layoutTableCell, st atic_cast<DisplayItem::Type>(displayItemType), borderRect); 118 LayoutObjectDrawingRecorder recorder(*graphicsContext, m_layoutTableCell, st atic_cast<DisplayItem::Type>(displayItemType), borderRect, paintOffset);
119 Color cellColor = m_layoutTableCell.resolveColor(CSSPropertyColor); 119 Color cellColor = m_layoutTableCell.resolveColor(CSSPropertyColor);
120 bool antialias = BoxPainter::shouldAntialiasLines(graphicsContext); 120 bool antialias = BoxPainter::shouldAntialiasLines(graphicsContext);
121 121
122 // We never paint diagonals at the joins. We simply let the border with the highest 122 // We never paint diagonals at the joins. We simply let the border with the highest
123 // precedence paint on top of borders with lower precedence. 123 // precedence paint on top of borders with lower precedence.
124 if (displayItemType & DisplayItem::TableCollapsedBorderTop) { 124 if (displayItemType & DisplayItem::TableCollapsedBorderTop) {
125 ObjectPainter::drawLineForBoxSide(graphicsContext, borderRect.x(), borde rRect.y(), borderRect.maxX(), borderRect.y() + topWidth, BSTop, 125 ObjectPainter::drawLineForBoxSide(graphicsContext, borderRect.x(), borde rRect.y(), borderRect.maxX(), borderRect.y() + topWidth, BSTop,
126 topBorderValue.color().resolve(cellColor), collapsedBorderStyle(topB orderValue.style()), 0, 0, antialias); 126 topBorderValue.color().resolve(cellColor), collapsedBorderStyle(topB orderValue.style()), 0, 0, antialias);
127 } 127 }
128 if (displayItemType & DisplayItem::TableCollapsedBorderBottom) { 128 if (displayItemType & DisplayItem::TableCollapsedBorderBottom) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 return; 180 return;
181 181
182 LayoutTable* table = m_layoutTableCell.table(); 182 LayoutTable* table = m_layoutTableCell.table();
183 if (!table->collapseBorders() && m_layoutTableCell.style()->emptyCells() == HIDE && !m_layoutTableCell.firstChild()) 183 if (!table->collapseBorders() && m_layoutTableCell.style()->emptyCells() == HIDE && !m_layoutTableCell.firstChild())
184 return; 184 return;
185 185
186 bool needsToPaintBorder = m_layoutTableCell.styleRef().hasBorderDecoration() && !table->collapseBorders(); 186 bool needsToPaintBorder = m_layoutTableCell.styleRef().hasBorderDecoration() && !table->collapseBorders();
187 if (!m_layoutTableCell.hasBackground() && !m_layoutTableCell.styleRef().boxS hadow() && !needsToPaintBorder) 187 if (!m_layoutTableCell.hasBackground() && !m_layoutTableCell.styleRef().boxS hadow() && !needsToPaintBorder)
188 return; 188 return;
189 189
190 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte xt, m_layoutTableCell, DisplayItem::BoxDecorationBackground)) 190 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte xt, m_layoutTableCell, DisplayItem::BoxDecorationBackground, paintOffset))
191 return; 191 return;
192 192
193 LayoutRect visualOverflowRect = m_layoutTableCell.visualOverflowRect(); 193 LayoutRect visualOverflowRect = m_layoutTableCell.visualOverflowRect();
194 visualOverflowRect.moveBy(paintOffset); 194 visualOverflowRect.moveBy(paintOffset);
195 // TODO(chrishtr): the pixel-snapping here is likely incorrect. 195 // TODO(chrishtr): the pixel-snapping here is likely incorrect.
196 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutTableCell, DisplayItem::BoxDecorationBackground, pixelSnappedIntRect(visualOverflowRect)); 196 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutTableCell, DisplayItem::BoxDecorationBackground, pixelSnappedIntRect(visualOverflowRect), p aintOffset);
197 197
198 LayoutRect paintRect = paintBounds(paintOffset, DoNotAddOffsetFromParent); 198 LayoutRect paintRect = paintBounds(paintOffset, DoNotAddOffsetFromParent);
199 199
200 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef( ), Normal); 200 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef( ), Normal);
201 201
202 // Paint our cell background. 202 // Paint our cell background.
203 paintBackgroundsBehindCell(paintInfo, paintOffset, &m_layoutTableCell); 203 paintBackgroundsBehindCell(paintInfo, paintOffset, &m_layoutTableCell);
204 204
205 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef( ), Inset); 205 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef( ), Inset);
206 206
207 if (!needsToPaintBorder) 207 if (!needsToPaintBorder)
208 return; 208 return;
209 209
210 BoxPainter::paintBorder(m_layoutTableCell, paintInfo, paintRect, m_layoutTab leCell.styleRef()); 210 BoxPainter::paintBorder(m_layoutTableCell, paintInfo, paintRect, m_layoutTab leCell.styleRef());
211 } 211 }
212 212
213 void TableCellPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) 213 void TableCellPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
214 { 214 {
215 if (m_layoutTableCell.style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) 215 if (m_layoutTableCell.style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask)
216 return; 216 return;
217 217
218 LayoutTable* tableElt = m_layoutTableCell.table(); 218 LayoutTable* tableElt = m_layoutTableCell.table();
219 if (!tableElt->collapseBorders() && m_layoutTableCell.style()->emptyCells() == HIDE && !m_layoutTableCell.firstChild()) 219 if (!tableElt->collapseBorders() && m_layoutTableCell.style()->emptyCells() == HIDE && !m_layoutTableCell.firstChild())
220 return; 220 return;
221 221
222 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte xt, m_layoutTableCell, paintInfo.phase)) 222 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte xt, m_layoutTableCell, paintInfo.phase, paintOffset))
223 return; 223 return;
224 224
225 LayoutRect paintRect = paintBounds(paintOffset, DoNotAddOffsetFromParent); 225 LayoutRect paintRect = paintBounds(paintOffset, DoNotAddOffsetFromParent);
226 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutTableCell, paintInfo.phase, paintRect); 226 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutTableCell, paintInfo.phase, paintRect, paintOffset);
227 BoxPainter(m_layoutTableCell).paintMaskImages(paintInfo, paintRect); 227 BoxPainter(m_layoutTableCell).paintMaskImages(paintInfo, paintRect);
228 } 228 }
229 229
230 LayoutRect TableCellPainter::paintBounds(const LayoutPoint& paintOffset, PaintBo undOffsetBehavior paintBoundOffsetBehavior) 230 LayoutRect TableCellPainter::paintBounds(const LayoutPoint& paintOffset, PaintBo undOffsetBehavior paintBoundOffsetBehavior)
231 { 231 {
232 LayoutPoint adjustedPaintOffset = paintOffset; 232 LayoutPoint adjustedPaintOffset = paintOffset;
233 if (paintBoundOffsetBehavior == AddOffsetFromParent) 233 if (paintBoundOffsetBehavior == AddOffsetFromParent)
234 adjustedPaintOffset.moveBy(m_layoutTableCell.location()); 234 adjustedPaintOffset.moveBy(m_layoutTableCell.location());
235 return LayoutRect(adjustedPaintOffset, LayoutSize(m_layoutTableCell.pixelSna ppedSize())); 235 return LayoutRect(adjustedPaintOffset, LayoutSize(m_layoutTableCell.pixelSna ppedSize()));
236 } 236 }
237 237
238 } // namespace blink 238 } // namespace blink
239 239
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698