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 10 matching lines...) Expand all Loading... | |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "platform/graphics/GraphicsLayer.h" | 27 #include "platform/graphics/GraphicsLayer.h" |
28 | 28 |
29 #include "SkImageFilter.h" | 29 #include "SkImageFilter.h" |
30 #include "SkMatrix44.h" | 30 #include "SkMatrix44.h" |
31 #include "base/trace_event/trace_event_argument.h" | |
31 #include "platform/DragImage.h" | 32 #include "platform/DragImage.h" |
33 #include "platform/JSONValues.h" | |
32 #include "platform/TraceEvent.h" | 34 #include "platform/TraceEvent.h" |
33 #include "platform/geometry/FloatRect.h" | 35 #include "platform/geometry/FloatRect.h" |
34 #include "platform/geometry/LayoutRect.h" | 36 #include "platform/geometry/LayoutRect.h" |
35 #include "platform/graphics/BitmapImage.h" | 37 #include "platform/graphics/BitmapImage.h" |
36 #include "platform/graphics/FirstPaintInvalidationTracking.h" | 38 #include "platform/graphics/FirstPaintInvalidationTracking.h" |
37 #include "platform/graphics/GraphicsContext.h" | 39 #include "platform/graphics/GraphicsContext.h" |
38 #include "platform/graphics/GraphicsLayerFactory.h" | 40 #include "platform/graphics/GraphicsLayerFactory.h" |
39 #include "platform/graphics/Image.h" | 41 #include "platform/graphics/Image.h" |
40 #include "platform/graphics/LinkHighlight.h" | 42 #include "platform/graphics/LinkHighlight.h" |
41 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" | 43 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" |
42 #include "platform/graphics/paint/DrawingRecorder.h" | 44 #include "platform/graphics/paint/DrawingRecorder.h" |
43 #include "platform/graphics/paint/PaintController.h" | 45 #include "platform/graphics/paint/PaintController.h" |
44 #include "platform/scroll/ScrollableArea.h" | 46 #include "platform/scroll/ScrollableArea.h" |
45 #include "platform/text/TextStream.h" | 47 #include "platform/text/TextStream.h" |
46 #include "public/platform/Platform.h" | 48 #include "public/platform/Platform.h" |
47 #include "public/platform/WebCompositorAnimation.h" | 49 #include "public/platform/WebCompositorAnimation.h" |
48 #include "public/platform/WebCompositorSupport.h" | 50 #include "public/platform/WebCompositorSupport.h" |
49 #include "public/platform/WebFilterOperations.h" | 51 #include "public/platform/WebFilterOperations.h" |
50 #include "public/platform/WebFloatPoint.h" | 52 #include "public/platform/WebFloatPoint.h" |
51 #include "public/platform/WebFloatRect.h" | 53 #include "public/platform/WebFloatRect.h" |
52 #include "public/platform/WebGraphicsLayerDebugInfo.h" | |
53 #include "public/platform/WebLayer.h" | 54 #include "public/platform/WebLayer.h" |
54 #include "public/platform/WebPoint.h" | 55 #include "public/platform/WebPoint.h" |
55 #include "public/platform/WebSize.h" | 56 #include "public/platform/WebSize.h" |
56 #include "wtf/CurrentTime.h" | 57 #include "wtf/CurrentTime.h" |
57 #include "wtf/HashMap.h" | 58 #include "wtf/HashMap.h" |
58 #include "wtf/HashSet.h" | 59 #include "wtf/HashSet.h" |
59 #include "wtf/text/WTFString.h" | 60 #include "wtf/text/WTFString.h" |
60 #include <algorithm> | 61 #include <algorithm> |
61 | 62 |
62 #ifndef NDEBUG | 63 #ifndef NDEBUG |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 , m_3dRenderingContext(0) | 116 , m_3dRenderingContext(0) |
116 { | 117 { |
117 #if ENABLE(ASSERT) | 118 #if ENABLE(ASSERT) |
118 if (m_client) | 119 if (m_client) |
119 m_client->verifyNotPainting(); | 120 m_client->verifyNotPainting(); |
120 #endif | 121 #endif |
121 | 122 |
122 m_contentLayerDelegate = adoptPtr(new ContentLayerDelegate(this)); | 123 m_contentLayerDelegate = adoptPtr(new ContentLayerDelegate(this)); |
123 m_layer = adoptPtr(Platform::current()->compositorSupport()->createContentLa yer(m_contentLayerDelegate.get())); | 124 m_layer = adoptPtr(Platform::current()->compositorSupport()->createContentLa yer(m_contentLayerDelegate.get())); |
124 m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible); | 125 m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible); |
125 m_layer->layer()->setWebLayerClient(this); | 126 m_layer->layer()->setLayerClient(this); |
126 m_layer->setAutomaticallyComputeRasterScale(true); | 127 m_layer->setAutomaticallyComputeRasterScale(true); |
127 | 128 |
128 // TODO(rbyers): Expose control over this to the web - crbug.com/489802: | 129 // TODO(rbyers): Expose control over this to the web - crbug.com/489802: |
129 setScrollBlocksOn(WebScrollBlocksOnStartTouch | WebScrollBlocksOnWheelEvent) ; | 130 setScrollBlocksOn(WebScrollBlocksOnStartTouch | WebScrollBlocksOnWheelEvent) ; |
130 } | 131 } |
131 | 132 |
132 GraphicsLayer::~GraphicsLayer() | 133 GraphicsLayer::~GraphicsLayer() |
133 { | 134 { |
134 for (size_t i = 0; i < m_linkHighlights.size(); ++i) | 135 for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
135 m_linkHighlights[i]->clearCurrentGraphicsLayer(); | 136 m_linkHighlights[i]->clearCurrentGraphicsLayer(); |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
427 if (childrenChanged) | 428 if (childrenChanged) |
428 updateChildList(); | 429 updateChildList(); |
429 } | 430 } |
430 | 431 |
431 void GraphicsLayer::setupContentsLayer(WebLayer* contentsLayer) | 432 void GraphicsLayer::setupContentsLayer(WebLayer* contentsLayer) |
432 { | 433 { |
433 ASSERT(contentsLayer); | 434 ASSERT(contentsLayer); |
434 m_contentsLayer = contentsLayer; | 435 m_contentsLayer = contentsLayer; |
435 m_contentsLayerId = m_contentsLayer->id(); | 436 m_contentsLayerId = m_contentsLayer->id(); |
436 | 437 |
437 m_contentsLayer->setWebLayerClient(this); | 438 m_contentsLayer->setLayerClient(this); |
438 m_contentsLayer->setTransformOrigin(FloatPoint3D()); | 439 m_contentsLayer->setTransformOrigin(FloatPoint3D()); |
439 m_contentsLayer->setUseParentBackfaceVisibility(true); | 440 m_contentsLayer->setUseParentBackfaceVisibility(true); |
440 | 441 |
441 // It is necessary to call setDrawsContent as soon as we receive the new con tentsLayer, for | 442 // It is necessary to call setDrawsContent as soon as we receive the new con tentsLayer, for |
442 // the correctness of early exit conditions in setDrawsContent() and setCont entsVisible(). | 443 // the correctness of early exit conditions in setDrawsContent() and setCont entsVisible(). |
443 m_contentsLayer->setDrawsContent(m_contentsVisible); | 444 m_contentsLayer->setDrawsContent(m_contentsVisible); |
444 | 445 |
445 // Insert the content layer first. Video elements require this, because they have | 446 // Insert the content layer first. Video elements require this, because they have |
446 // shadow content that must display in front of the video. | 447 // shadow content that must display in front of the video. |
447 m_layer->layer()->insertChild(m_contentsLayer, 0); | 448 m_layer->layer()->insertChild(m_contentsLayer, 0); |
(...skipping 10 matching lines...) Expand all Loading... | |
458 | 459 |
459 m_contentsLayer = 0; | 460 m_contentsLayer = 0; |
460 m_contentsLayerId = 0; | 461 m_contentsLayerId = 0; |
461 } | 462 } |
462 | 463 |
463 GraphicsLayerDebugInfo& GraphicsLayer::debugInfo() | 464 GraphicsLayerDebugInfo& GraphicsLayer::debugInfo() |
464 { | 465 { |
465 return m_debugInfo; | 466 return m_debugInfo; |
466 } | 467 } |
467 | 468 |
468 WebGraphicsLayerDebugInfo* GraphicsLayer::takeDebugInfoFor(WebLayer* layer) | |
469 { | |
470 GraphicsLayerDebugInfo* clone = m_debugInfo.clone(); | |
471 clone->setDebugName(debugName(layer)); | |
472 return clone; | |
473 } | |
474 | |
475 WebLayer* GraphicsLayer::contentsLayerIfRegistered() | 469 WebLayer* GraphicsLayer::contentsLayerIfRegistered() |
476 { | 470 { |
477 clearContentsLayerIfUnregistered(); | 471 clearContentsLayerIfUnregistered(); |
478 return m_contentsLayer; | 472 return m_contentsLayer; |
479 } | 473 } |
480 | 474 |
481 void GraphicsLayer::resetTrackedPaintInvalidations() | 475 void GraphicsLayer::resetTrackedPaintInvalidations() |
482 { | 476 { |
483 paintInvalidationTrackingMap().remove(this); | 477 paintInvalidationTrackingMap().remove(this); |
484 } | 478 } |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
744 return json; | 738 return json; |
745 } | 739 } |
746 | 740 |
747 String GraphicsLayer::layerTreeAsText(LayerTreeFlags flags) const | 741 String GraphicsLayer::layerTreeAsText(LayerTreeFlags flags) const |
748 { | 742 { |
749 RenderingContextMap renderingContextMap; | 743 RenderingContextMap renderingContextMap; |
750 RefPtr<JSONObject> json = layerTreeAsJSON(flags, renderingContextMap); | 744 RefPtr<JSONObject> json = layerTreeAsJSON(flags, renderingContextMap); |
751 return json->toPrettyJSONString(); | 745 return json->toPrettyJSONString(); |
752 } | 746 } |
753 | 747 |
754 String GraphicsLayer::debugName(WebLayer* webLayer) const | 748 static const cc::Layer* ccLayerForWebLayer(const WebLayer* webLayer) |
749 { | |
750 return webLayer ? webLayer->ccLayer() : nullptr; | |
751 } | |
752 | |
753 String GraphicsLayer::debugName(cc::Layer* layer) const | |
755 { | 754 { |
756 String name; | 755 String name; |
757 if (!m_client) | 756 if (!m_client) |
758 return name; | 757 return name; |
759 | 758 |
760 String highlightDebugName; | 759 String highlightDebugName; |
761 for (size_t i = 0; i < m_linkHighlights.size(); ++i) { | 760 for (size_t i = 0; i < m_linkHighlights.size(); ++i) { |
762 if (webLayer == m_linkHighlights[i]->layer()) { | 761 if (layer == ccLayerForWebLayer(m_linkHighlights[i]->layer())) { |
763 highlightDebugName = "LinkHighlight[" + String::number(i) + "] for " + m_client->debugName(this); | 762 highlightDebugName = "LinkHighlight[" + String::number(i) + "] for " + m_client->debugName(this); |
764 break; | 763 break; |
765 } | 764 } |
766 } | 765 } |
767 | 766 |
768 if (webLayer == m_contentsLayer) { | 767 if (layer == ccLayerForWebLayer(m_contentsLayer)) { |
769 name = "ContentsLayer for " + m_client->debugName(this); | 768 name = "ContentsLayer for " + m_client->debugName(this); |
770 } else if (!highlightDebugName.isEmpty()) { | 769 } else if (!highlightDebugName.isEmpty()) { |
771 name = highlightDebugName; | 770 name = highlightDebugName; |
772 } else if (webLayer == m_layer->layer()) { | 771 } else if (layer == ccLayerForWebLayer(m_layer->layer())) { |
773 name = m_client->debugName(this); | 772 name = m_client->debugName(this); |
774 } else { | 773 } else { |
775 ASSERT_NOT_REACHED(); | 774 ASSERT_NOT_REACHED(); |
776 } | 775 } |
777 return name; | 776 return name; |
778 } | 777 } |
779 | 778 |
780 void GraphicsLayer::setCompositingReasons(CompositingReasons reasons) | 779 void GraphicsLayer::setCompositingReasons(CompositingReasons reasons) |
781 { | 780 { |
782 m_debugInfo.setCompositingReasons(reasons); | 781 m_debugInfo.setCompositingReasons(reasons); |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1113 if (m_paintingPhase == phase) | 1112 if (m_paintingPhase == phase) |
1114 return; | 1113 return; |
1115 m_paintingPhase = phase; | 1114 m_paintingPhase = phase; |
1116 setNeedsDisplay(); | 1115 setNeedsDisplay(); |
1117 } | 1116 } |
1118 | 1117 |
1119 void GraphicsLayer::addLinkHighlight(LinkHighlight* linkHighlight) | 1118 void GraphicsLayer::addLinkHighlight(LinkHighlight* linkHighlight) |
1120 { | 1119 { |
1121 ASSERT(linkHighlight && !m_linkHighlights.contains(linkHighlight)); | 1120 ASSERT(linkHighlight && !m_linkHighlights.contains(linkHighlight)); |
1122 m_linkHighlights.append(linkHighlight); | 1121 m_linkHighlights.append(linkHighlight); |
1123 linkHighlight->layer()->setWebLayerClient(this); | 1122 linkHighlight->layer()->setLayerClient(this); |
1124 updateChildList(); | 1123 updateChildList(); |
1125 } | 1124 } |
1126 | 1125 |
1127 void GraphicsLayer::removeLinkHighlight(LinkHighlight* linkHighlight) | 1126 void GraphicsLayer::removeLinkHighlight(LinkHighlight* linkHighlight) |
1128 { | 1127 { |
1129 m_linkHighlights.remove(m_linkHighlights.find(linkHighlight)); | 1128 m_linkHighlights.remove(m_linkHighlights.find(linkHighlight)); |
1130 updateChildList(); | 1129 updateChildList(); |
1131 } | 1130 } |
1132 | 1131 |
1133 void GraphicsLayer::setScrollableArea(ScrollableArea* scrollableArea, bool isVie wport) | 1132 void GraphicsLayer::setScrollableArea(ScrollableArea* scrollableArea, bool isVie wport) |
(...skipping 27 matching lines...) Expand all Loading... | |
1161 { | 1160 { |
1162 if (m_scrollableArea) { | 1161 if (m_scrollableArea) { |
1163 DoublePoint newPosition = m_scrollableArea->minimumScrollPosition() + to DoubleSize(m_layer->layer()->scrollPositionDouble()); | 1162 DoublePoint newPosition = m_scrollableArea->minimumScrollPosition() + to DoubleSize(m_layer->layer()->scrollPositionDouble()); |
1164 | 1163 |
1165 // FrameView::setScrollPosition doesn't work for compositor commits (int eracts poorly with programmatic scroll animations) | 1164 // FrameView::setScrollPosition doesn't work for compositor commits (int eracts poorly with programmatic scroll animations) |
1166 // so we need to use the ScrollableArea version. The FrameView method sh ould go away soon anyway. | 1165 // so we need to use the ScrollableArea version. The FrameView method sh ould go away soon anyway. |
1167 m_scrollableArea->ScrollableArea::setScrollPosition(newPosition, Composi torScroll); | 1166 m_scrollableArea->ScrollableArea::setScrollPosition(newPosition, Composi torScroll); |
1168 } | 1167 } |
1169 } | 1168 } |
1170 | 1169 |
1170 scoped_refptr<base::trace_event::ConvertableToTraceFormat> GraphicsLayer::TakeDe bugInfo(cc::Layer* layer) | |
1171 { | |
1172 CString layerName = debugName(layer).utf8(); | |
1173 scoped_refptr<base::trace_event::TracedValue> tracedValue = m_debugInfo.asTr acedValue(); | |
1174 tracedValue->SetString("layer_name", std::string(layerName.data(), layerName .length())); | |
esprehn
2015/10/23 19:17:41
fyi: this is multiple copies of the string, once i
jbroman
2015/10/23 19:26:24
I know; maybe I should have left a TODO. There are
| |
1175 return tracedValue; | |
1176 } | |
1177 | |
1171 PaintController* GraphicsLayer::paintController() | 1178 PaintController* GraphicsLayer::paintController() |
1172 { | 1179 { |
1173 if (!m_paintController) | 1180 if (!m_paintController) |
1174 m_paintController = PaintController::create(); | 1181 m_paintController = PaintController::create(); |
1175 return m_paintController.get(); | 1182 return m_paintController.get(); |
1176 } | 1183 } |
1177 | 1184 |
1178 } // namespace blink | 1185 } // namespace blink |
1179 | 1186 |
1180 #ifndef NDEBUG | 1187 #ifndef NDEBUG |
1181 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) | 1188 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) |
1182 { | 1189 { |
1183 if (!layer) { | 1190 if (!layer) { |
1184 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); | 1191 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); |
1185 return; | 1192 return; |
1186 } | 1193 } |
1187 | 1194 |
1188 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); | 1195 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); |
1189 fprintf(stderr, "%s\n", output.utf8().data()); | 1196 fprintf(stderr, "%s\n", output.utf8().data()); |
1190 } | 1197 } |
1191 #endif | 1198 #endif |
OLD | NEW |