Chromium Code Reviews| 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/FramePainter.h" | 6 #include "core/paint/FramePainter.h" |
| 7 | 7 |
| 8 #include "core/dom/DocumentMarkerController.h" | 8 #include "core/dom/DocumentMarkerController.h" |
| 9 #include "core/fetch/MemoryCache.h" | 9 #include "core/fetch/MemoryCache.h" |
| 10 #include "core/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 Document* document = m_frameView.frame().document(); | 66 Document* document = m_frameView.frame().document(); |
| 67 | 67 |
| 68 #ifndef NDEBUG | 68 #ifndef NDEBUG |
| 69 bool fillWithRed; | 69 bool fillWithRed; |
| 70 if (document->printing()) | 70 if (document->printing()) |
| 71 fillWithRed = false; // Printing, don't fill with red (can't remember wh y). | 71 fillWithRed = false; // Printing, don't fill with red (can't remember wh y). |
| 72 else if (m_frameView.frame().owner()) | 72 else if (m_frameView.frame().owner()) |
| 73 fillWithRed = false; // Subframe, don't fill with red. | 73 fillWithRed = false; // Subframe, don't fill with red. |
| 74 else if (m_frameView.isTransparent()) | 74 else if (m_frameView.isTransparent()) |
| 75 fillWithRed = false; // Transparent, don't fill with red. | 75 fillWithRed = false; // Transparent, don't fill with red. |
| 76 else if (m_frameView.paintBehavior() & PaintBehaviorSelectionOnly) | 76 else if (gGlobalPaintFlags & GlobalPaintSelectionOnly) |
| 77 fillWithRed = false; // Selections are transparent, don't fill with red. | 77 fillWithRed = false; // Selections are transparent, don't fill with red. |
| 78 else if (m_frameView.nodeToDraw()) | 78 else if (m_frameView.nodeToDraw()) |
| 79 fillWithRed = false; // Element images are transparent, don't fill with red. | 79 fillWithRed = false; // Element images are transparent, don't fill with red. |
| 80 else | 80 else |
| 81 fillWithRed = true; | 81 fillWithRed = true; |
| 82 | 82 |
| 83 if (fillWithRed && !LayoutObjectDrawingRecorder::useCachedDrawingIfPossible( *context, *m_frameView.layoutView(), DisplayItem::DebugRedFill)) { | 83 if (fillWithRed && !LayoutObjectDrawingRecorder::useCachedDrawingIfPossible( *context, *m_frameView.layoutView(), DisplayItem::DebugRedFill)) { |
| 84 IntRect contentRect(IntPoint(), m_frameView.contentsSize()); | 84 IntRect contentRect(IntPoint(), m_frameView.contentsSize()); |
| 85 LayoutObjectDrawingRecorder drawingRecorder(*context, *m_frameView.layou tView(), DisplayItem::DebugRedFill, contentRect); | 85 LayoutObjectDrawingRecorder drawingRecorder(*context, *m_frameView.layou tView(), DisplayItem::DebugRedFill, contentRect); |
| 86 } | 86 } |
| 87 #endif | 87 #endif |
| 88 | 88 |
| 89 LayoutView* layoutView = m_frameView.layoutView(); | 89 LayoutView* layoutView = m_frameView.layoutView(); |
| 90 if (!layoutView) { | 90 if (!layoutView) { |
| 91 WTF_LOG_ERROR("called FramePainter::paint with nil layoutObject"); | 91 WTF_LOG_ERROR("called FramePainter::paint with nil layoutObject"); |
| 92 return; | 92 return; |
| 93 } | 93 } |
| 94 | 94 |
| 95 RELEASE_ASSERT(!m_frameView.needsLayout()); | 95 RELEASE_ASSERT(!m_frameView.needsLayout()); |
| 96 ASSERT(document->lifecycle().state() >= DocumentLifecycle::CompositingClean) ; | 96 ASSERT(document->lifecycle().state() >= DocumentLifecycle::CompositingClean) ; |
| 97 | 97 |
| 98 TRACE_EVENT1("devtools.timeline", "Paint", "data", InspectorPaintEvent::data (layoutView, LayoutRect(rect), 0)); | 98 TRACE_EVENT1("devtools.timeline", "Paint", "data", InspectorPaintEvent::data (layoutView, LayoutRect(rect), 0)); |
| 99 | 99 |
| 100 bool isTopLevelPainter = !s_inPaintContents; | 100 bool isTopLevelPainter = !s_inPaintContents; |
| 101 s_inPaintContents = true; | 101 s_inPaintContents = true; |
| 102 | 102 |
| 103 FontCachePurgePreventer fontCachePurgePreventer; | 103 FontCachePurgePreventer fontCachePurgePreventer; |
| 104 | 104 |
| 105 PaintBehavior oldPaintBehavior = m_frameView.paintBehavior(); | 105 // TODO: Why is this here and done globally once per paint phase? |
|
leviw_travelin_and_unemployed
2015/07/07 20:33:16
TODO(jchaffraix) ;)
Julien - ping for review
2015/07/08 01:16:30
Deal!
| |
| 106 | |
| 107 if (FrameView* parentView = m_frameView.parentFrameView()) { | |
| 108 if (parentView->paintBehavior() & PaintBehaviorFlattenCompositingLayers) | |
| 109 m_frameView.setPaintBehavior(m_frameView.paintBehavior() | PaintBeha viorFlattenCompositingLayers); | |
| 110 } | |
| 111 | |
| 112 if (document->printing()) | 106 if (document->printing()) |
| 113 m_frameView.setPaintBehavior(m_frameView.paintBehavior() | PaintBehavior FlattenCompositingLayers); | 107 gGlobalPaintFlags |= GlobalPaintFlattenCompositingLayers; |
| 114 | 108 |
| 115 ASSERT(!m_frameView.isPainting()); | 109 ASSERT(!m_frameView.isPainting()); |
| 116 m_frameView.setIsPainting(true); | 110 m_frameView.setIsPainting(true); |
| 117 | 111 |
| 118 // m_frameView.nodeToDraw() is used to draw only one element (and its descen dants) | 112 // m_frameView.nodeToDraw() is used to draw only one element (and its descen dants) |
| 119 LayoutObject* layoutObject = m_frameView.nodeToDraw() ? m_frameView.nodeToDr aw()->layoutObject() : 0; | 113 LayoutObject* layoutObject = m_frameView.nodeToDraw() ? m_frameView.nodeToDr aw()->layoutObject() : 0; |
| 120 DeprecatedPaintLayer* rootLayer = layoutView->layer(); | 114 DeprecatedPaintLayer* rootLayer = layoutView->layer(); |
| 121 | 115 |
| 122 #if ENABLE(ASSERT) | 116 #if ENABLE(ASSERT) |
| 123 layoutView->assertSubtreeIsLaidOut(); | 117 layoutView->assertSubtreeIsLaidOut(); |
| 124 LayoutObject::SetLayoutNeededForbiddenScope forbidSetNeedsLayout(*rootLayer- >layoutObject()); | 118 LayoutObject::SetLayoutNeededForbiddenScope forbidSetNeedsLayout(*rootLayer- >layoutObject()); |
| 125 #endif | 119 #endif |
| 126 | 120 |
| 127 DeprecatedPaintLayerPainter layerPainter(*rootLayer); | 121 DeprecatedPaintLayerPainter layerPainter(*rootLayer); |
| 128 | 122 |
| 129 float deviceScaleFactor = blink::deviceScaleFactor(rootLayer->layoutObject() ->frame()); | 123 float deviceScaleFactor = blink::deviceScaleFactor(rootLayer->layoutObject() ->frame()); |
| 130 context->setDeviceScaleFactor(deviceScaleFactor); | 124 context->setDeviceScaleFactor(deviceScaleFactor); |
| 131 | 125 |
| 132 layerPainter.paint(context, LayoutRect(rect), m_frameView.paintBehavior(), l ayoutObject); | 126 PaintBehavior paintBehavior = PaintBehaviorNormal; |
|
leviw_travelin_and_unemployed
2015/07/07 20:33:16
Why not just put PaintBehaviorNormal in both locat
Julien - ping for review
2015/07/08 01:16:30
Because variables are so 90's! Removed.
| |
| 127 layerPainter.paint(context, LayoutRect(rect), paintBehavior, layoutObject); | |
| 133 | 128 |
| 134 if (rootLayer->containsDirtyOverlayScrollbars()) | 129 if (rootLayer->containsDirtyOverlayScrollbars()) |
| 135 layerPainter.paintOverlayScrollbars(context, LayoutRect(rect), m_frameVi ew.paintBehavior(), layoutObject); | 130 layerPainter.paintOverlayScrollbars(context, LayoutRect(rect), paintBeha vior, layoutObject); |
| 136 | 131 |
| 137 m_frameView.setIsPainting(false); | 132 m_frameView.setIsPainting(false); |
| 138 | 133 |
| 139 m_frameView.setPaintBehavior(oldPaintBehavior); | |
| 140 m_frameView.setLastPaintTime(currentTime()); | 134 m_frameView.setLastPaintTime(currentTime()); |
| 141 | 135 |
| 142 // Regions may have changed as a result of the visibility/z-index of element changing. | 136 // Regions may have changed as a result of the visibility/z-index of element changing. |
| 143 if (document->annotatedRegionsDirty()) | 137 if (document->annotatedRegionsDirty()) |
| 144 m_frameView.updateAnnotatedRegions(); | 138 m_frameView.updateAnnotatedRegions(); |
| 145 | 139 |
| 146 if (isTopLevelPainter) { | 140 if (isTopLevelPainter) { |
| 147 // Everything that happens after paintContents completions is considered | 141 // Everything that happens after paintContents completions is considered |
| 148 // to be part of the next frame. | 142 // to be part of the next frame. |
| 149 memoryCache()->updateFramePaintTimestamp(); | 143 memoryCache()->updateFramePaintTimestamp(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 if (needsBackground) { | 182 if (needsBackground) { |
| 189 IntRect toFill = bar->frameRect(); | 183 IntRect toFill = bar->frameRect(); |
| 190 toFill.intersect(rect); | 184 toFill.intersect(rect); |
| 191 context->fillRect(toFill, m_frameView.baseBackgroundColor()); | 185 context->fillRect(toFill, m_frameView.baseBackgroundColor()); |
| 192 } | 186 } |
| 193 | 187 |
| 194 bar->paint(context, rect); | 188 bar->paint(context, rect); |
| 195 } | 189 } |
| 196 | 190 |
| 197 } // namespace blink | 191 } // namespace blink |
| OLD | NEW |