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

Unified Diff: Source/core/paint/BlockFlowPainter.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/layout/LayoutTextControlSingleLine.cpp ('k') | Source/core/paint/BlockPainter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/paint/BlockFlowPainter.cpp
diff --git a/Source/core/paint/BlockFlowPainter.cpp b/Source/core/paint/BlockFlowPainter.cpp
index e7cc6442b07763df355665be6c824d19b3a12f02..fde91d64a3a2a25b315cc81a1a15e17d319bcca9 100644
--- a/Source/core/paint/BlockFlowPainter.cpp
+++ b/Source/core/paint/BlockFlowPainter.cpp
@@ -62,12 +62,20 @@ void BlockFlowPainter::paintSelection(const PaintInfo& paintInfo, const LayoutPo
bounds = m_layoutBlockFlow.visualOverflowRect();
bounds.moveBy(paintOffset);
}
- LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutBlockFlow, DisplayItem::SelectionGap, bounds);
- ClipScope clipScope(paintInfo.context);
+
+ // Only create a DrawingRecorder and ClipScope if skipRecording is false. This logic is needed
+ // because selectionGaps(...) needs to be called even when we do not record.
+ bool skipRecording = LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.context, m_layoutBlockFlow, DisplayItem::SelectionGap);
+ Optional<DrawingRecorder> drawingRecorder;
+ Optional<ClipScope> clipScope;
+ if (!skipRecording) {
+ drawingRecorder.emplace(*paintInfo.context, m_layoutBlockFlow, DisplayItem::SelectionGap, bounds);
+ clipScope.emplace(paintInfo.context);
+ }
LayoutRect gapRectsBounds = m_layoutBlockFlow.selectionGaps(&m_layoutBlockFlow, paintOffset, LayoutSize(), lastTop, lastLeft, lastRight,
- recorder.canUseCachedDrawing() ? nullptr : &paintInfo,
- recorder.canUseCachedDrawing() ? nullptr : &clipScope);
+ skipRecording ? nullptr : &paintInfo,
+ skipRecording ? nullptr : &(*clipScope));
// TODO(wkorman): Rework below to process paint invalidation rects during layout rather than paint.
if (!gapRectsBounds.isEmpty()) {
DeprecatedPaintLayer* layer = m_layoutBlockFlow.enclosingLayer();
« no previous file with comments | « Source/core/layout/LayoutTextControlSingleLine.cpp ('k') | Source/core/paint/BlockPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698