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

Side by Side Diff: Source/core/paint/ViewPainter.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/VideoPainter.cpp ('k') | Source/core/svg/graphics/SVGImage.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/ViewPainter.h" 6 #include "core/paint/ViewPainter.h"
7 7
8 #include "core/frame/FrameView.h" 8 #include "core/frame/FrameView.h"
9 #include "core/frame/Settings.h" 9 #include "core/frame/Settings.h"
10 #include "core/layout/LayoutBox.h" 10 #include "core/layout/LayoutBox.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // 1. The view paints background for the root element, the background positi oning respects 42 // 1. The view paints background for the root element, the background positi oning respects
43 // the positioning and transformation of the root element. 43 // the positioning and transformation of the root element.
44 // 2. CSS background-clip is ignored, the background layers always expand to cover the whole 44 // 2. CSS background-clip is ignored, the background layers always expand to cover the whole
45 // canvas. None of the stacking context effects (except transformation) o n the root element 45 // canvas. None of the stacking context effects (except transformation) o n the root element
46 // affects the background. 46 // affects the background.
47 // 3. The main frame is also responsible for painting the user-agent-defined base background 47 // 3. The main frame is also responsible for painting the user-agent-defined base background
48 // color. Conceptually it should be painted by the embedder but painting it here allows 48 // color. Conceptually it should be painted by the embedder but painting it here allows
49 // culling and pre-blending optimization when possible. 49 // culling and pre-blending optimization when possible.
50 50
51 GraphicsContext& context = *paintInfo.context; 51 GraphicsContext& context = *paintInfo.context;
52 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, m_layou tView, DisplayItem::BoxDecorationBackground))
53 return;
54
52 IntRect documentRect = m_layoutView.unscaledDocumentRect(); 55 IntRect documentRect = m_layoutView.unscaledDocumentRect();
53 const Document& document = m_layoutView.document(); 56 const Document& document = m_layoutView.document();
54 const FrameView& frameView = *m_layoutView.frameView(); 57 const FrameView& frameView = *m_layoutView.frameView();
55 bool isMainFrame = !document.ownerElement(); 58 bool isMainFrame = !document.ownerElement();
56 bool paintsBaseBackground = isMainFrame && !frameView.isTransparent(); 59 bool paintsBaseBackground = isMainFrame && !frameView.isTransparent();
57 bool shouldClearCanvas = paintsBaseBackground && (document.settings() && doc ument.settings()->shouldClearDocumentBackground()); 60 bool shouldClearCanvas = paintsBaseBackground && (document.settings() && doc ument.settings()->shouldClearDocumentBackground());
58 Color baseBackgroundColor = paintsBaseBackground ? frameView.baseBackgroundC olor() : Color(); 61 Color baseBackgroundColor = paintsBaseBackground ? frameView.baseBackgroundC olor() : Color();
59 Color rootBackgroundColor = m_layoutView.style()->visitedDependentColor(CSSP ropertyBackgroundColor); 62 Color rootBackgroundColor = m_layoutView.style()->visitedDependentColor(CSSP ropertyBackgroundColor);
60 const LayoutObject* rootObject = document.documentElement() ? document.docum entElement()->layoutObject() : nullptr; 63 const LayoutObject* rootObject = document.documentElement() ? document.docum entElement()->layoutObject() : nullptr;
61 64
62 LayoutObjectDrawingRecorder recorder(context, m_layoutView, DisplayItem::Box DecorationBackground, documentRect); 65 LayoutObjectDrawingRecorder recorder(context, m_layoutView, DisplayItem::Box DecorationBackground, documentRect);
63 if (recorder.canUseCachedDrawing())
64 return;
65 66
66 // Special handling for print economy mode. 67 // Special handling for print economy mode.
67 bool forceBackgroundToWhite = BoxPainter::shouldForceWhiteBackgroundForPrint Economy(m_layoutView.styleRef(), document); 68 bool forceBackgroundToWhite = BoxPainter::shouldForceWhiteBackgroundForPrint Economy(m_layoutView.styleRef(), document);
68 if (forceBackgroundToWhite) { 69 if (forceBackgroundToWhite) {
69 // If for any reason the view background is not transparent, paint white instead, otherwise keep transparent as is. 70 // If for any reason the view background is not transparent, paint white instead, otherwise keep transparent as is.
70 if (paintsBaseBackground || rootBackgroundColor.alpha() || m_layoutView. style()->backgroundLayers().image()) 71 if (paintsBaseBackground || rootBackgroundColor.alpha() || m_layoutView. style()->backgroundLayers().image())
71 context.fillRect(documentRect, Color::white, SkXfermode::kSrc_Mode); 72 context.fillRect(documentRect, Color::white, SkXfermode::kSrc_Mode);
72 return; 73 return;
73 } 74 }
74 75
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 ASSERT((*it)->clip() == BorderFillBox); 141 ASSERT((*it)->clip() == BorderFillBox);
141 BoxPainter::paintFillLayerExtended(m_layoutView, paintInfo, Color(), **i t, LayoutRect(paintRect), BackgroundBleedNone); 142 BoxPainter::paintFillLayerExtended(m_layoutView, paintInfo, Color(), **i t, LayoutRect(paintRect), BackgroundBleedNone);
142 } 143 }
143 context.restore(); 144 context.restore();
144 145
145 if (shouldDrawBackgroundInSeparateBuffer) 146 if (shouldDrawBackgroundInSeparateBuffer)
146 context.endLayer(); 147 context.endLayer();
147 } 148 }
148 149
149 } // namespace blink 150 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/VideoPainter.cpp ('k') | Source/core/svg/graphics/SVGImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698