| OLD | NEW |
| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 IntRect documentRect = m_layoutView.unscaledDocumentRect(); | 52 IntRect documentRect = m_layoutView.unscaledDocumentRect(); |
| 53 const Document& document = m_layoutView.document(); | 53 const Document& document = m_layoutView.document(); |
| 54 const FrameView& frameView = *m_layoutView.frameView(); | 54 const FrameView& frameView = *m_layoutView.frameView(); |
| 55 bool isMainFrame = !document.ownerElement(); | 55 bool isMainFrame = !document.ownerElement(); |
| 56 bool paintsBaseBackground = isMainFrame && !frameView.isTransparent(); | 56 bool paintsBaseBackground = isMainFrame && !frameView.isTransparent(); |
| 57 bool shouldClearCanvas = paintsBaseBackground && (document.settings() && doc
ument.settings()->shouldClearDocumentBackground()); | 57 bool shouldClearCanvas = paintsBaseBackground && (document.settings() && doc
ument.settings()->shouldClearDocumentBackground()); |
| 58 Color baseBackgroundColor = paintsBaseBackground ? frameView.baseBackgroundC
olor() : Color(); | 58 Color baseBackgroundColor = paintsBaseBackground ? frameView.baseBackgroundC
olor() : Color(); |
| 59 Color rootBackgroundColor = m_layoutView.style()->visitedDependentColor(CSSP
ropertyBackgroundColor); |
| 59 const LayoutObject* rootObject = document.documentElement() ? document.docum
entElement()->layoutObject() : nullptr; | 60 const LayoutObject* rootObject = document.documentElement() ? document.docum
entElement()->layoutObject() : nullptr; |
| 60 | 61 |
| 61 LayoutObjectDrawingRecorder recorder(context, m_layoutView, DisplayItem::Box
DecorationBackground, documentRect); | 62 LayoutObjectDrawingRecorder recorder(context, m_layoutView, DisplayItem::Box
DecorationBackground, documentRect); |
| 62 if (recorder.canUseCachedDrawing()) | 63 if (recorder.canUseCachedDrawing()) |
| 63 return; | 64 return; |
| 64 | 65 |
| 66 // Special handling for print economy mode. |
| 67 bool forceBackgroundToWhite = BoxPainter::shouldForceWhiteBackgroundForPrint
Economy(m_layoutView.styleRef(), document); |
| 68 if (forceBackgroundToWhite) { |
| 69 // 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 context.fillRect(documentRect, Color::white, SkXfermode::kSrc_Mode); |
| 72 return; |
| 73 } |
| 74 |
| 65 // Compute the enclosing rect of the view, in root element space. | 75 // Compute the enclosing rect of the view, in root element space. |
| 66 // | 76 // |
| 67 // For background colors we can simply paint the document rect in the defaul
t space. | 77 // For background colors we can simply paint the document rect in the defaul
t space. |
| 68 // However for background image, the root element transform applies. The str
ategy is to apply | 78 // However for background image, the root element transform applies. The str
ategy is to apply |
| 69 // root element transform on the context and issue draw commands in the loca
l space, therefore | 79 // root element transform on the context and issue draw commands in the loca
l space, therefore |
| 70 // we need to apply inverse transform on the document rect to get to the roo
t element space. | 80 // we need to apply inverse transform on the document rect to get to the roo
t element space. |
| 71 bool backgroundRenderable = true; | 81 bool backgroundRenderable = true; |
| 72 TransformationMatrix transform; | 82 TransformationMatrix transform; |
| 73 IntRect paintRect = documentRect; | 83 IntRect paintRect = documentRect; |
| 74 if (!rootObject || !rootObject->isBox()) { | 84 if (!rootObject || !rootObject->isBox()) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 93 if (baseBackgroundColor.alpha()) | 103 if (baseBackgroundColor.alpha()) |
| 94 context.fillRect(documentRect, baseBackgroundColor, shouldClearCanva
s ? SkXfermode::kSrc_Mode : SkXfermode::kSrcOver_Mode); | 104 context.fillRect(documentRect, baseBackgroundColor, shouldClearCanva
s ? SkXfermode::kSrc_Mode : SkXfermode::kSrcOver_Mode); |
| 95 else if (shouldClearCanvas) | 105 else if (shouldClearCanvas) |
| 96 context.fillRect(documentRect, Color(), SkXfermode::kClear_Mode); | 106 context.fillRect(documentRect, Color(), SkXfermode::kClear_Mode); |
| 97 return; | 107 return; |
| 98 } | 108 } |
| 99 | 109 |
| 100 BoxPainter::FillLayerOcclusionOutputList reversedPaintList; | 110 BoxPainter::FillLayerOcclusionOutputList reversedPaintList; |
| 101 bool shouldDrawBackgroundInSeparateBuffer = BoxPainter(m_layoutView).calcula
teFillLayerOcclusionCulling(reversedPaintList, m_layoutView.style()->backgroundL
ayers()); | 111 bool shouldDrawBackgroundInSeparateBuffer = BoxPainter(m_layoutView).calcula
teFillLayerOcclusionCulling(reversedPaintList, m_layoutView.style()->backgroundL
ayers()); |
| 102 ASSERT(reversedPaintList.size()); | 112 ASSERT(reversedPaintList.size()); |
| 103 Color rootBackgroundColor = m_layoutView.style()->visitedDependentColor(CSSP
ropertyBackgroundColor); | |
| 104 | 113 |
| 105 // If the root background color is opaque, isolation group can be skipped be
cause the canvas | 114 // If the root background color is opaque, isolation group can be skipped be
cause the canvas |
| 106 // will be cleared by root background color. | 115 // will be cleared by root background color. |
| 107 if (!rootBackgroundColor.hasAlpha()) | 116 if (!rootBackgroundColor.hasAlpha()) |
| 108 shouldDrawBackgroundInSeparateBuffer = false; | 117 shouldDrawBackgroundInSeparateBuffer = false; |
| 109 | 118 |
| 110 // We are going to clear the canvas with transparent pixels, isolation group
can be skipped. | 119 // We are going to clear the canvas with transparent pixels, isolation group
can be skipped. |
| 111 if (!baseBackgroundColor.alpha() && shouldClearCanvas) | 120 if (!baseBackgroundColor.alpha() && shouldClearCanvas) |
| 112 shouldDrawBackgroundInSeparateBuffer = false; | 121 shouldDrawBackgroundInSeparateBuffer = false; |
| 113 | 122 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 131 ASSERT((*it)->clip() == BorderFillBox); | 140 ASSERT((*it)->clip() == BorderFillBox); |
| 132 BoxPainter::paintFillLayerExtended(m_layoutView, paintInfo, Color(), **i
t, LayoutRect(paintRect), BackgroundBleedNone); | 141 BoxPainter::paintFillLayerExtended(m_layoutView, paintInfo, Color(), **i
t, LayoutRect(paintRect), BackgroundBleedNone); |
| 133 } | 142 } |
| 134 context.restore(); | 143 context.restore(); |
| 135 | 144 |
| 136 if (shouldDrawBackgroundInSeparateBuffer) | 145 if (shouldDrawBackgroundInSeparateBuffer) |
| 137 context.endLayer(); | 146 context.endLayer(); |
| 138 } | 147 } |
| 139 | 148 |
| 140 } // namespace blink | 149 } // namespace blink |
| OLD | NEW |