OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "platform/TraceEvent.h" | 32 #include "platform/TraceEvent.h" |
33 #include "platform/geometry/FloatRect.h" | 33 #include "platform/geometry/FloatRect.h" |
34 #include "platform/geometry/LayoutRect.h" | 34 #include "platform/geometry/LayoutRect.h" |
35 #include "platform/graphics/BitmapImage.h" | 35 #include "platform/graphics/BitmapImage.h" |
36 #include "platform/graphics/FirstPaintInvalidationTracking.h" | 36 #include "platform/graphics/FirstPaintInvalidationTracking.h" |
37 #include "platform/graphics/GraphicsContext.h" | 37 #include "platform/graphics/GraphicsContext.h" |
38 #include "platform/graphics/GraphicsLayerFactory.h" | 38 #include "platform/graphics/GraphicsLayerFactory.h" |
39 #include "platform/graphics/Image.h" | 39 #include "platform/graphics/Image.h" |
40 #include "platform/graphics/LinkHighlight.h" | 40 #include "platform/graphics/LinkHighlight.h" |
41 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" | 41 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" |
42 #include "platform/graphics/paint/DisplayItemList.h" | |
43 #include "platform/graphics/paint/DrawingRecorder.h" | 42 #include "platform/graphics/paint/DrawingRecorder.h" |
| 43 #include "platform/graphics/paint/PaintController.h" |
44 #include "platform/scroll/ScrollableArea.h" | 44 #include "platform/scroll/ScrollableArea.h" |
45 #include "platform/text/TextStream.h" | 45 #include "platform/text/TextStream.h" |
46 #include "public/platform/Platform.h" | 46 #include "public/platform/Platform.h" |
47 #include "public/platform/WebCompositorAnimation.h" | 47 #include "public/platform/WebCompositorAnimation.h" |
48 #include "public/platform/WebCompositorSupport.h" | 48 #include "public/platform/WebCompositorSupport.h" |
49 #include "public/platform/WebFilterOperations.h" | 49 #include "public/platform/WebFilterOperations.h" |
50 #include "public/platform/WebFloatPoint.h" | 50 #include "public/platform/WebFloatPoint.h" |
51 #include "public/platform/WebFloatRect.h" | 51 #include "public/platform/WebFloatRect.h" |
52 #include "public/platform/WebGraphicsLayerDebugInfo.h" | 52 #include "public/platform/WebGraphicsLayerDebugInfo.h" |
53 #include "public/platform/WebLayer.h" | 53 #include "public/platform/WebLayer.h" |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 } | 304 } |
305 | 305 |
306 void GraphicsLayer::paint(GraphicsContext& context, const IntRect& clip) | 306 void GraphicsLayer::paint(GraphicsContext& context, const IntRect& clip) |
307 { | 307 { |
308 if (!m_client) | 308 if (!m_client) |
309 return; | 309 return; |
310 if (firstPaintInvalidationTrackingEnabled()) | 310 if (firstPaintInvalidationTrackingEnabled()) |
311 m_debugInfo.clearAnnotatedInvalidateRects(); | 311 m_debugInfo.clearAnnotatedInvalidateRects(); |
312 incrementPaintCount(); | 312 incrementPaintCount(); |
313 #ifndef NDEBUG | 313 #ifndef NDEBUG |
314 if (m_displayItemList && contentsOpaque() && s_drawDebugRedFill) { | 314 if (m_paintController && contentsOpaque() && s_drawDebugRedFill) { |
315 FloatRect rect(FloatPoint(), size()); | 315 FloatRect rect(FloatPoint(), size()); |
316 if (!DrawingRecorder::useCachedDrawingIfPossible(context, *this, Display
Item::DebugRedFill)) { | 316 if (!DrawingRecorder::useCachedDrawingIfPossible(context, *this, Display
Item::DebugRedFill)) { |
317 DrawingRecorder recorder(context, *this, DisplayItem::DebugRedFill,
rect); | 317 DrawingRecorder recorder(context, *this, DisplayItem::DebugRedFill,
rect); |
318 context.fillRect(rect, SK_ColorRED); | 318 context.fillRect(rect, SK_ColorRED); |
319 } | 319 } |
320 } | 320 } |
321 #endif | 321 #endif |
322 m_client->paintContents(this, context, m_paintingPhase, clip); | 322 m_client->paintContents(this, context, m_paintingPhase, clip); |
323 if (!m_textPainted && m_displayItemList->textPainted()) { | 323 if (!m_textPainted && m_paintController->textPainted()) { |
324 m_textPainted = true; | 324 m_textPainted = true; |
325 m_client->notifyTextPainted(); | 325 m_client->notifyTextPainted(); |
326 } | 326 } |
327 } | 327 } |
328 | 328 |
329 void GraphicsLayer::updateChildList() | 329 void GraphicsLayer::updateChildList() |
330 { | 330 { |
331 WebLayer* childHost = m_layer->layer(); | 331 WebLayer* childHost = m_layer->layer(); |
332 childHost->removeAllChildren(); | 332 childHost->removeAllChildren(); |
333 | 333 |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 if (clampedSize == m_size) | 806 if (clampedSize == m_size) |
807 return; | 807 return; |
808 | 808 |
809 m_size = clampedSize; | 809 m_size = clampedSize; |
810 | 810 |
811 m_layer->layer()->setBounds(flooredIntSize(m_size)); | 811 m_layer->layer()->setBounds(flooredIntSize(m_size)); |
812 // Note that we don't resize m_contentsLayer. It's up the caller to do that. | 812 // Note that we don't resize m_contentsLayer. It's up the caller to do that. |
813 | 813 |
814 #ifndef NDEBUG | 814 #ifndef NDEBUG |
815 // The red debug fill needs to be invalidated if the layer resizes. | 815 // The red debug fill needs to be invalidated if the layer resizes. |
816 if (m_displayItemList) | 816 if (m_paintController) |
817 m_displayItemList->invalidateUntracked(displayItemClient()); | 817 m_paintController->invalidateUntracked(displayItemClient()); |
818 #endif | 818 #endif |
819 } | 819 } |
820 | 820 |
821 void GraphicsLayer::setTransform(const TransformationMatrix& transform) | 821 void GraphicsLayer::setTransform(const TransformationMatrix& transform) |
822 { | 822 { |
823 m_transform = transform; | 823 m_transform = transform; |
824 platformLayer()->setTransform(TransformationMatrix::toSkMatrix44(m_transform
)); | 824 platformLayer()->setTransform(TransformationMatrix::toSkMatrix44(m_transform
)); |
825 } | 825 } |
826 | 826 |
827 void GraphicsLayer::setTransformOrigin(const FloatPoint3D& transformOrigin) | 827 void GraphicsLayer::setTransformOrigin(const FloatPoint3D& transformOrigin) |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 // TODO(chrishtr): stop invalidating the rects once FrameView::paintRecursiv
ely does so. | 999 // TODO(chrishtr): stop invalidating the rects once FrameView::paintRecursiv
ely does so. |
1000 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) | 1000 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) |
1001 m_needsDisplay = true; | 1001 m_needsDisplay = true; |
1002 | 1002 |
1003 m_layer->layer()->invalidate(); | 1003 m_layer->layer()->invalidate(); |
1004 if (isTrackingPaintInvalidations()) | 1004 if (isTrackingPaintInvalidations()) |
1005 trackPaintInvalidationRect(FloatRect(FloatPoint(), m_size)); | 1005 trackPaintInvalidationRect(FloatRect(FloatPoint(), m_size)); |
1006 for (size_t i = 0; i < m_linkHighlights.size(); ++i) | 1006 for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
1007 m_linkHighlights[i]->invalidate(); | 1007 m_linkHighlights[i]->invalidate(); |
1008 | 1008 |
1009 displayItemList()->invalidateAll(); | 1009 paintController()->invalidateAll(); |
1010 if (isTrackingPaintInvalidations()) | 1010 if (isTrackingPaintInvalidations()) |
1011 trackPaintInvalidationObject("##ALL##"); | 1011 trackPaintInvalidationObject("##ALL##"); |
1012 } | 1012 } |
1013 | 1013 |
1014 bool GraphicsLayer::needsDisplay() const | 1014 bool GraphicsLayer::needsDisplay() const |
1015 { | 1015 { |
1016 ASSERT(RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()); | 1016 ASSERT(RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()); |
1017 return m_needsDisplay; | 1017 return m_needsDisplay; |
1018 } | 1018 } |
1019 | 1019 |
1020 bool GraphicsLayer::commitIfNeeded() | 1020 bool GraphicsLayer::commitIfNeeded() |
1021 { | 1021 { |
1022 ASSERT(RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()); | 1022 ASSERT(RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()); |
1023 if (m_needsDisplay) { | 1023 if (m_needsDisplay) { |
1024 displayItemList()->commitNewDisplayItems(this); | 1024 paintController()->commitNewDisplayItems(this); |
1025 m_needsDisplay = false; | 1025 m_needsDisplay = false; |
1026 return true; | 1026 return true; |
1027 } | 1027 } |
1028 return false; | 1028 return false; |
1029 } | 1029 } |
1030 | 1030 |
1031 void GraphicsLayer::setNeedsDisplayInRect(const IntRect& rect, PaintInvalidation
Reason invalidationReason) | 1031 void GraphicsLayer::setNeedsDisplayInRect(const IntRect& rect, PaintInvalidation
Reason invalidationReason) |
1032 { | 1032 { |
1033 if (!drawsContent()) | 1033 if (!drawsContent()) |
1034 return; | 1034 return; |
1035 | 1035 |
1036 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) | 1036 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) |
1037 m_needsDisplay = true; | 1037 m_needsDisplay = true; |
1038 | 1038 |
1039 m_layer->layer()->invalidateRect(rect); | 1039 m_layer->layer()->invalidateRect(rect); |
1040 if (firstPaintInvalidationTrackingEnabled()) | 1040 if (firstPaintInvalidationTrackingEnabled()) |
1041 m_debugInfo.appendAnnotatedInvalidateRect(rect, invalidationReason); | 1041 m_debugInfo.appendAnnotatedInvalidateRect(rect, invalidationReason); |
1042 if (isTrackingPaintInvalidations()) | 1042 if (isTrackingPaintInvalidations()) |
1043 trackPaintInvalidationRect(rect); | 1043 trackPaintInvalidationRect(rect); |
1044 for (size_t i = 0; i < m_linkHighlights.size(); ++i) | 1044 for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
1045 m_linkHighlights[i]->invalidate(); | 1045 m_linkHighlights[i]->invalidate(); |
1046 } | 1046 } |
1047 | 1047 |
1048 void GraphicsLayer::invalidateDisplayItemClient(const DisplayItemClientWrapper&
displayItemClient, PaintInvalidationReason paintInvalidationReason, const IntRec
t& previousPaintInvalidationRect, const IntRect& newPaintInvalidationRect) | 1048 void GraphicsLayer::invalidateDisplayItemClient(const DisplayItemClientWrapper&
displayItemClient, PaintInvalidationReason paintInvalidationReason, const IntRec
t& previousPaintInvalidationRect, const IntRect& newPaintInvalidationRect) |
1049 { | 1049 { |
1050 m_needsDisplay = true; | 1050 m_needsDisplay = true; |
1051 displayItemList()->invalidate(displayItemClient, paintInvalidationReason, pr
eviousPaintInvalidationRect, newPaintInvalidationRect); | 1051 paintController()->invalidate(displayItemClient, paintInvalidationReason, pr
eviousPaintInvalidationRect, newPaintInvalidationRect); |
1052 if (isTrackingPaintInvalidations()) | 1052 if (isTrackingPaintInvalidations()) |
1053 trackPaintInvalidationObject(displayItemClient.debugName()); | 1053 trackPaintInvalidationObject(displayItemClient.debugName()); |
1054 } | 1054 } |
1055 | 1055 |
1056 void GraphicsLayer::setContentsRect(const IntRect& rect) | 1056 void GraphicsLayer::setContentsRect(const IntRect& rect) |
1057 { | 1057 { |
1058 if (rect == m_contentsRect) | 1058 if (rect == m_contentsRect) |
1059 return; | 1059 return; |
1060 | 1060 |
1061 m_contentsRect = rect; | 1061 m_contentsRect = rect; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 { | 1196 { |
1197 if (m_scrollableArea) { | 1197 if (m_scrollableArea) { |
1198 DoublePoint newPosition = m_scrollableArea->minimumScrollPosition() + to
DoubleSize(m_layer->layer()->scrollPositionDouble()); | 1198 DoublePoint newPosition = m_scrollableArea->minimumScrollPosition() + to
DoubleSize(m_layer->layer()->scrollPositionDouble()); |
1199 | 1199 |
1200 // FrameView::setScrollPosition doesn't work for compositor commits (int
eracts poorly with programmatic scroll animations) | 1200 // FrameView::setScrollPosition doesn't work for compositor commits (int
eracts poorly with programmatic scroll animations) |
1201 // so we need to use the ScrollableArea version. The FrameView method sh
ould go away soon anyway. | 1201 // so we need to use the ScrollableArea version. The FrameView method sh
ould go away soon anyway. |
1202 m_scrollableArea->ScrollableArea::setScrollPosition(newPosition, Composi
torScroll); | 1202 m_scrollableArea->ScrollableArea::setScrollPosition(newPosition, Composi
torScroll); |
1203 } | 1203 } |
1204 } | 1204 } |
1205 | 1205 |
1206 DisplayItemList* GraphicsLayer::displayItemList() | 1206 PaintController* GraphicsLayer::paintController() |
1207 { | 1207 { |
1208 if (!m_displayItemList) | 1208 if (!m_paintController) |
1209 m_displayItemList = DisplayItemList::create(); | 1209 m_paintController = PaintController::create(); |
1210 return m_displayItemList.get(); | 1210 return m_paintController.get(); |
1211 } | 1211 } |
1212 | 1212 |
1213 } // namespace blink | 1213 } // namespace blink |
1214 | 1214 |
1215 #ifndef NDEBUG | 1215 #ifndef NDEBUG |
1216 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) | 1216 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) |
1217 { | 1217 { |
1218 if (!layer) { | 1218 if (!layer) { |
1219 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); | 1219 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); |
1220 return; | 1220 return; |
1221 } | 1221 } |
1222 | 1222 |
1223 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); | 1223 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); |
1224 fprintf(stderr, "%s\n", output.utf8().data()); | 1224 fprintf(stderr, "%s\n", output.utf8().data()); |
1225 } | 1225 } |
1226 #endif | 1226 #endif |
OLD | NEW |