| 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 "core/paint/FramePainter.h" | 5 #include "core/paint/FramePainter.h" |
| 6 | 6 |
| 7 #include "core/editing/markers/DocumentMarkerController.h" | 7 #include "core/editing/markers/DocumentMarkerController.h" |
| 8 #include "core/fetch/MemoryCache.h" | 8 #include "core/fetch/MemoryCache.h" |
| 9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
| 10 #include "core/inspector/InspectorInstrumentation.h" | 10 #include "core/inspector/InspectorInstrumentation.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 ClipRecorder recorder(context, *frameView().layoutView(), DisplayItem::C
lipFrameScrollbars, LayoutRect(IntPoint(), visibleAreaWithScrollbars.size())); | 88 ClipRecorder recorder(context, *frameView().layoutView(), DisplayItem::C
lipFrameScrollbars, LayoutRect(IntPoint(), visibleAreaWithScrollbars.size())); |
| 89 | 89 |
| 90 paintScrollbars(context, scrollViewDirtyRect); | 90 paintScrollbars(context, scrollViewDirtyRect); |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 | 93 |
| 94 void FramePainter::paintContents(GraphicsContext& context, const GlobalPaintFlag
s globalPaintFlags, const IntRect& rect) | 94 void FramePainter::paintContents(GraphicsContext& context, const GlobalPaintFlag
s globalPaintFlags, const IntRect& rect) |
| 95 { | 95 { |
| 96 Document* document = frameView().frame().document(); | 96 Document* document = frameView().frame().document(); |
| 97 | 97 |
| 98 if (frameView().shouldThrottleRendering()) |
| 99 return; |
| 100 |
| 98 #ifndef NDEBUG | 101 #ifndef NDEBUG |
| 99 bool fillWithRed; | 102 bool fillWithRed; |
| 100 if (document->printing()) | 103 if (document->printing()) |
| 101 fillWithRed = false; // Printing, don't fill with red (can't remember wh
y). | 104 fillWithRed = false; // Printing, don't fill with red (can't remember wh
y). |
| 102 else if (frameView().frame().owner()) | 105 else if (frameView().frame().owner()) |
| 103 fillWithRed = false; // Subframe, don't fill with red. | 106 fillWithRed = false; // Subframe, don't fill with red. |
| 104 else if (frameView().isTransparent()) | 107 else if (frameView().isTransparent()) |
| 105 fillWithRed = false; // Transparent, don't fill with red. | 108 fillWithRed = false; // Transparent, don't fill with red. |
| 106 else if (globalPaintFlags & GlobalPaintSelectionOnly) | 109 else if (globalPaintFlags & GlobalPaintSelectionOnly) |
| 107 fillWithRed = false; // Selections are transparent, don't fill with red. | 110 fillWithRed = false; // Selections are transparent, don't fill with red. |
| 108 else | 111 else |
| 109 fillWithRed = true; | 112 fillWithRed = true; |
| 110 | 113 |
| 111 if (fillWithRed && !LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(
context, *frameView().layoutView(), DisplayItem::DebugRedFill)) { | 114 if (fillWithRed && !LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(
context, *frameView().layoutView(), DisplayItem::DebugRedFill)) { |
| 112 IntRect contentRect(IntPoint(), frameView().contentsSize()); | 115 IntRect contentRect(IntPoint(), frameView().contentsSize()); |
| 113 LayoutObjectDrawingRecorder drawingRecorder(context, *frameView().layout
View(), DisplayItem::DebugRedFill, contentRect); | 116 LayoutObjectDrawingRecorder drawingRecorder(context, *frameView().layout
View(), DisplayItem::DebugRedFill, contentRect); |
| 114 } | 117 } |
| 115 #endif | 118 #endif |
| 116 | 119 |
| 117 LayoutView* layoutView = frameView().layoutView(); | 120 LayoutView* layoutView = frameView().layoutView(); |
| 118 if (!layoutView) { | 121 if (!layoutView) { |
| 119 DLOG(ERROR) << "called FramePainter::paint with nil layoutObject"; | 122 DLOG(ERROR) << "called FramePainter::paint with nil layoutObject"; |
| 120 return; | 123 return; |
| 121 } | 124 } |
| 122 | 125 |
| 123 if (!frameView().shouldThrottleRendering()) { | 126 RELEASE_ASSERT(!frameView().needsLayout()); |
| 124 RELEASE_ASSERT(!frameView().needsLayout()); | 127 ASSERT(document->lifecycle().state() >= DocumentLifecycle::CompositingClean)
; |
| 125 ASSERT(document->lifecycle().state() >= DocumentLifecycle::CompositingCl
ean); | |
| 126 } | |
| 127 | 128 |
| 128 TRACE_EVENT1("devtools.timeline", "Paint", "data", InspectorPaintEvent::data
(layoutView, LayoutRect(rect), 0)); | 129 TRACE_EVENT1("devtools.timeline", "Paint", "data", InspectorPaintEvent::data
(layoutView, LayoutRect(rect), 0)); |
| 129 | 130 |
| 130 bool isTopLevelPainter = !s_inPaintContents; | 131 bool isTopLevelPainter = !s_inPaintContents; |
| 131 s_inPaintContents = true; | 132 s_inPaintContents = true; |
| 132 | 133 |
| 133 FontCachePurgePreventer fontCachePurgePreventer; | 134 FontCachePurgePreventer fontCachePurgePreventer; |
| 134 | 135 |
| 135 // TODO(jchaffraix): GlobalPaintFlags should be const during a paint | 136 // TODO(jchaffraix): GlobalPaintFlags should be const during a paint |
| 136 // phase. Thus we should set this flag upfront (crbug.com/510280). | 137 // phase. Thus we should set this flag upfront (crbug.com/510280). |
| 137 GlobalPaintFlags localPaintFlags = globalPaintFlags; | 138 GlobalPaintFlags localPaintFlags = globalPaintFlags; |
| 138 if (document->printing()) | 139 if (document->printing()) |
| 139 localPaintFlags |= GlobalPaintFlattenCompositingLayers | GlobalPaintPrin
ting; | 140 localPaintFlags |= GlobalPaintFlattenCompositingLayers | GlobalPaintPrin
ting; |
| 140 | 141 |
| 141 PaintLayer* rootLayer = layoutView->layer(); | 142 PaintLayer* rootLayer = layoutView->layer(); |
| 142 | 143 |
| 143 #if ENABLE(ASSERT) | 144 #if ENABLE(ASSERT) |
| 144 if (!frameView().shouldThrottleRendering()) | 145 layoutView->assertSubtreeIsLaidOut(); |
| 145 layoutView->assertSubtreeIsLaidOut(); | |
| 146 LayoutObject::SetLayoutNeededForbiddenScope forbidSetNeedsLayout(*rootLayer-
>layoutObject()); | 146 LayoutObject::SetLayoutNeededForbiddenScope forbidSetNeedsLayout(*rootLayer-
>layoutObject()); |
| 147 #endif | 147 #endif |
| 148 | 148 |
| 149 PaintLayerPainter layerPainter(*rootLayer); | 149 PaintLayerPainter layerPainter(*rootLayer); |
| 150 | 150 |
| 151 float deviceScaleFactor = blink::deviceScaleFactor(rootLayer->layoutObject()
->frame()); | 151 float deviceScaleFactor = blink::deviceScaleFactor(rootLayer->layoutObject()
->frame()); |
| 152 context.setDeviceScaleFactor(deviceScaleFactor); | 152 context.setDeviceScaleFactor(deviceScaleFactor); |
| 153 | 153 |
| 154 layerPainter.paint(context, LayoutRect(rect), localPaintFlags); | 154 layerPainter.paint(context, LayoutRect(rect), localPaintFlags); |
| 155 | 155 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 bar.paint(context, CullRect(rect)); | 211 bar.paint(context, CullRect(rect)); |
| 212 } | 212 } |
| 213 | 213 |
| 214 const FrameView& FramePainter::frameView() | 214 const FrameView& FramePainter::frameView() |
| 215 { | 215 { |
| 216 ASSERT(m_frameView); | 216 ASSERT(m_frameView); |
| 217 return *m_frameView; | 217 return *m_frameView; |
| 218 } | 218 } |
| 219 | 219 |
| 220 } // namespace blink | 220 } // namespace blink |
| OLD | NEW |