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" | |
32 #include "platform/DragImage.h" | 31 #include "platform/DragImage.h" |
33 #include "platform/JSONValues.h" | |
34 #include "platform/TraceEvent.h" | 32 #include "platform/TraceEvent.h" |
35 #include "platform/geometry/FloatRect.h" | 33 #include "platform/geometry/FloatRect.h" |
36 #include "platform/geometry/LayoutRect.h" | 34 #include "platform/geometry/LayoutRect.h" |
37 #include "platform/graphics/BitmapImage.h" | 35 #include "platform/graphics/BitmapImage.h" |
38 #include "platform/graphics/FirstPaintInvalidationTracking.h" | 36 #include "platform/graphics/FirstPaintInvalidationTracking.h" |
39 #include "platform/graphics/GraphicsContext.h" | 37 #include "platform/graphics/GraphicsContext.h" |
40 #include "platform/graphics/GraphicsLayerFactory.h" | 38 #include "platform/graphics/GraphicsLayerFactory.h" |
41 #include "platform/graphics/Image.h" | 39 #include "platform/graphics/Image.h" |
42 #include "platform/graphics/LinkHighlight.h" | 40 #include "platform/graphics/LinkHighlight.h" |
43 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" | 41 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" |
44 #include "platform/graphics/paint/DrawingRecorder.h" | 42 #include "platform/graphics/paint/DrawingRecorder.h" |
45 #include "platform/graphics/paint/PaintController.h" | 43 #include "platform/graphics/paint/PaintController.h" |
46 #include "platform/scroll/ScrollableArea.h" | 44 #include "platform/scroll/ScrollableArea.h" |
47 #include "platform/text/TextStream.h" | 45 #include "platform/text/TextStream.h" |
48 #include "public/platform/Platform.h" | 46 #include "public/platform/Platform.h" |
49 #include "public/platform/WebCompositorAnimation.h" | 47 #include "public/platform/WebCompositorAnimation.h" |
50 #include "public/platform/WebCompositorSupport.h" | 48 #include "public/platform/WebCompositorSupport.h" |
51 #include "public/platform/WebFilterOperations.h" | 49 #include "public/platform/WebFilterOperations.h" |
52 #include "public/platform/WebFloatPoint.h" | 50 #include "public/platform/WebFloatPoint.h" |
53 #include "public/platform/WebFloatRect.h" | 51 #include "public/platform/WebFloatRect.h" |
| 52 #include "public/platform/WebGraphicsLayerDebugInfo.h" |
54 #include "public/platform/WebLayer.h" | 53 #include "public/platform/WebLayer.h" |
55 #include "public/platform/WebPoint.h" | 54 #include "public/platform/WebPoint.h" |
56 #include "public/platform/WebSize.h" | 55 #include "public/platform/WebSize.h" |
57 #include "wtf/CurrentTime.h" | 56 #include "wtf/CurrentTime.h" |
58 #include "wtf/HashMap.h" | 57 #include "wtf/HashMap.h" |
59 #include "wtf/HashSet.h" | 58 #include "wtf/HashSet.h" |
60 #include "wtf/text/StringUTF8Adaptor.h" | |
61 #include "wtf/text/WTFString.h" | 59 #include "wtf/text/WTFString.h" |
62 #include <algorithm> | 60 #include <algorithm> |
63 | 61 |
64 #ifndef NDEBUG | 62 #ifndef NDEBUG |
65 #include <stdio.h> | 63 #include <stdio.h> |
66 #endif | 64 #endif |
67 | 65 |
68 namespace blink { | 66 namespace blink { |
69 | 67 |
70 static bool s_drawDebugRedFill = true; | 68 static bool s_drawDebugRedFill = true; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 , m_3dRenderingContext(0) | 117 , m_3dRenderingContext(0) |
120 { | 118 { |
121 #if ENABLE(ASSERT) | 119 #if ENABLE(ASSERT) |
122 if (m_client) | 120 if (m_client) |
123 m_client->verifyNotPainting(); | 121 m_client->verifyNotPainting(); |
124 #endif | 122 #endif |
125 | 123 |
126 m_contentLayerDelegate = adoptPtr(new ContentLayerDelegate(this)); | 124 m_contentLayerDelegate = adoptPtr(new ContentLayerDelegate(this)); |
127 m_layer = adoptPtr(Platform::current()->compositorSupport()->createContentLa
yer(m_contentLayerDelegate.get())); | 125 m_layer = adoptPtr(Platform::current()->compositorSupport()->createContentLa
yer(m_contentLayerDelegate.get())); |
128 m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible); | 126 m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible); |
129 m_layer->layer()->setLayerClient(this); | 127 m_layer->layer()->setWebLayerClient(this); |
130 | 128 |
131 // 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: |
132 setScrollBlocksOn(WebScrollBlocksOnStartTouch | WebScrollBlocksOnWheelEvent)
; | 130 setScrollBlocksOn(WebScrollBlocksOnStartTouch | WebScrollBlocksOnWheelEvent)
; |
133 } | 131 } |
134 | 132 |
135 GraphicsLayer::~GraphicsLayer() | 133 GraphicsLayer::~GraphicsLayer() |
136 { | 134 { |
137 for (size_t i = 0; i < m_linkHighlights.size(); ++i) | 135 for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
138 m_linkHighlights[i]->clearCurrentGraphicsLayer(); | 136 m_linkHighlights[i]->clearCurrentGraphicsLayer(); |
139 m_linkHighlights.clear(); | 137 m_linkHighlights.clear(); |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 if (childrenChanged) | 447 if (childrenChanged) |
450 updateChildList(); | 448 updateChildList(); |
451 } | 449 } |
452 | 450 |
453 void GraphicsLayer::setupContentsLayer(WebLayer* contentsLayer) | 451 void GraphicsLayer::setupContentsLayer(WebLayer* contentsLayer) |
454 { | 452 { |
455 ASSERT(contentsLayer); | 453 ASSERT(contentsLayer); |
456 m_contentsLayer = contentsLayer; | 454 m_contentsLayer = contentsLayer; |
457 m_contentsLayerId = m_contentsLayer->id(); | 455 m_contentsLayerId = m_contentsLayer->id(); |
458 | 456 |
459 m_contentsLayer->setLayerClient(this); | 457 m_contentsLayer->setWebLayerClient(this); |
460 m_contentsLayer->setTransformOrigin(FloatPoint3D()); | 458 m_contentsLayer->setTransformOrigin(FloatPoint3D()); |
461 m_contentsLayer->setUseParentBackfaceVisibility(true); | 459 m_contentsLayer->setUseParentBackfaceVisibility(true); |
462 | 460 |
463 // It is necessary to call setDrawsContent as soon as we receive the new con
tentsLayer, for | 461 // It is necessary to call setDrawsContent as soon as we receive the new con
tentsLayer, for |
464 // the correctness of early exit conditions in setDrawsContent() and setCont
entsVisible(). | 462 // the correctness of early exit conditions in setDrawsContent() and setCont
entsVisible(). |
465 m_contentsLayer->setDrawsContent(m_contentsVisible); | 463 m_contentsLayer->setDrawsContent(m_contentsVisible); |
466 | 464 |
467 // Insert the content layer first. Video elements require this, because they
have | 465 // Insert the content layer first. Video elements require this, because they
have |
468 // shadow content that must display in front of the video. | 466 // shadow content that must display in front of the video. |
469 m_layer->layer()->insertChild(m_contentsLayer, 0); | 467 m_layer->layer()->insertChild(m_contentsLayer, 0); |
(...skipping 10 matching lines...) Expand all Loading... |
480 | 478 |
481 m_contentsLayer = 0; | 479 m_contentsLayer = 0; |
482 m_contentsLayerId = 0; | 480 m_contentsLayerId = 0; |
483 } | 481 } |
484 | 482 |
485 GraphicsLayerDebugInfo& GraphicsLayer::debugInfo() | 483 GraphicsLayerDebugInfo& GraphicsLayer::debugInfo() |
486 { | 484 { |
487 return m_debugInfo; | 485 return m_debugInfo; |
488 } | 486 } |
489 | 487 |
| 488 WebGraphicsLayerDebugInfo* GraphicsLayer::takeDebugInfoFor(WebLayer* layer) |
| 489 { |
| 490 GraphicsLayerDebugInfo* clone = m_debugInfo.clone(); |
| 491 clone->setDebugName(debugName(layer)); |
| 492 return clone; |
| 493 } |
| 494 |
490 WebLayer* GraphicsLayer::contentsLayerIfRegistered() | 495 WebLayer* GraphicsLayer::contentsLayerIfRegistered() |
491 { | 496 { |
492 clearContentsLayerIfUnregistered(); | 497 clearContentsLayerIfUnregistered(); |
493 return m_contentsLayer; | 498 return m_contentsLayer; |
494 } | 499 } |
495 | 500 |
496 void GraphicsLayer::resetTrackedPaintInvalidations() | 501 void GraphicsLayer::resetTrackedPaintInvalidations() |
497 { | 502 { |
498 paintInvalidationTrackingMap().remove(this); | 503 paintInvalidationTrackingMap().remove(this); |
499 } | 504 } |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 return json; | 764 return json; |
760 } | 765 } |
761 | 766 |
762 String GraphicsLayer::layerTreeAsText(LayerTreeFlags flags) const | 767 String GraphicsLayer::layerTreeAsText(LayerTreeFlags flags) const |
763 { | 768 { |
764 RenderingContextMap renderingContextMap; | 769 RenderingContextMap renderingContextMap; |
765 RefPtr<JSONObject> json = layerTreeAsJSON(flags, renderingContextMap); | 770 RefPtr<JSONObject> json = layerTreeAsJSON(flags, renderingContextMap); |
766 return json->toPrettyJSONString(); | 771 return json->toPrettyJSONString(); |
767 } | 772 } |
768 | 773 |
769 static const cc::Layer* ccLayerForWebLayer(const WebLayer* webLayer) | 774 String GraphicsLayer::debugName(WebLayer* webLayer) const |
770 { | |
771 return webLayer ? webLayer->ccLayer() : nullptr; | |
772 } | |
773 | |
774 String GraphicsLayer::debugName(cc::Layer* layer) const | |
775 { | 775 { |
776 String name; | 776 String name; |
777 if (!m_client) | 777 if (!m_client) |
778 return name; | 778 return name; |
779 | 779 |
780 String highlightDebugName; | 780 String highlightDebugName; |
781 for (size_t i = 0; i < m_linkHighlights.size(); ++i) { | 781 for (size_t i = 0; i < m_linkHighlights.size(); ++i) { |
782 if (layer == ccLayerForWebLayer(m_linkHighlights[i]->layer())) { | 782 if (webLayer == m_linkHighlights[i]->layer()) { |
783 highlightDebugName = "LinkHighlight[" + String::number(i) + "] for "
+ m_client->debugName(this); | 783 highlightDebugName = "LinkHighlight[" + String::number(i) + "] for "
+ m_client->debugName(this); |
784 break; | 784 break; |
785 } | 785 } |
786 } | 786 } |
787 | 787 |
788 if (layer == ccLayerForWebLayer(m_contentsLayer)) { | 788 if (webLayer == m_contentsLayer) { |
789 name = "ContentsLayer for " + m_client->debugName(this); | 789 name = "ContentsLayer for " + m_client->debugName(this); |
790 } else if (!highlightDebugName.isEmpty()) { | 790 } else if (!highlightDebugName.isEmpty()) { |
791 name = highlightDebugName; | 791 name = highlightDebugName; |
792 } else if (layer == ccLayerForWebLayer(m_layer->layer())) { | 792 } else if (webLayer == m_layer->layer()) { |
793 name = m_client->debugName(this); | 793 name = m_client->debugName(this); |
794 } else { | 794 } else { |
795 ASSERT_NOT_REACHED(); | 795 ASSERT_NOT_REACHED(); |
796 } | 796 } |
797 return name; | 797 return name; |
798 } | 798 } |
799 | 799 |
800 void GraphicsLayer::setCompositingReasons(CompositingReasons reasons) | 800 void GraphicsLayer::setCompositingReasons(CompositingReasons reasons) |
801 { | 801 { |
802 m_debugInfo.setCompositingReasons(reasons); | 802 m_debugInfo.setCompositingReasons(reasons); |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1136 if (m_paintingPhase == phase) | 1136 if (m_paintingPhase == phase) |
1137 return; | 1137 return; |
1138 m_paintingPhase = phase; | 1138 m_paintingPhase = phase; |
1139 setNeedsDisplay(); | 1139 setNeedsDisplay(); |
1140 } | 1140 } |
1141 | 1141 |
1142 void GraphicsLayer::addLinkHighlight(LinkHighlight* linkHighlight) | 1142 void GraphicsLayer::addLinkHighlight(LinkHighlight* linkHighlight) |
1143 { | 1143 { |
1144 ASSERT(linkHighlight && !m_linkHighlights.contains(linkHighlight)); | 1144 ASSERT(linkHighlight && !m_linkHighlights.contains(linkHighlight)); |
1145 m_linkHighlights.append(linkHighlight); | 1145 m_linkHighlights.append(linkHighlight); |
1146 linkHighlight->layer()->setLayerClient(this); | 1146 linkHighlight->layer()->setWebLayerClient(this); |
1147 updateChildList(); | 1147 updateChildList(); |
1148 } | 1148 } |
1149 | 1149 |
1150 void GraphicsLayer::removeLinkHighlight(LinkHighlight* linkHighlight) | 1150 void GraphicsLayer::removeLinkHighlight(LinkHighlight* linkHighlight) |
1151 { | 1151 { |
1152 m_linkHighlights.remove(m_linkHighlights.find(linkHighlight)); | 1152 m_linkHighlights.remove(m_linkHighlights.find(linkHighlight)); |
1153 updateChildList(); | 1153 updateChildList(); |
1154 } | 1154 } |
1155 | 1155 |
1156 void GraphicsLayer::setScrollableArea(ScrollableArea* scrollableArea, bool isVie
wport) | 1156 void GraphicsLayer::setScrollableArea(ScrollableArea* scrollableArea, bool isVie
wport) |
(...skipping 27 matching lines...) Expand all Loading... |
1184 { | 1184 { |
1185 if (m_scrollableArea) { | 1185 if (m_scrollableArea) { |
1186 DoublePoint newPosition = m_scrollableArea->minimumScrollPosition() + to
DoubleSize(m_layer->layer()->scrollPositionDouble()); | 1186 DoublePoint newPosition = m_scrollableArea->minimumScrollPosition() + to
DoubleSize(m_layer->layer()->scrollPositionDouble()); |
1187 | 1187 |
1188 // FrameView::setScrollPosition doesn't work for compositor commits (int
eracts poorly with programmatic scroll animations) | 1188 // FrameView::setScrollPosition doesn't work for compositor commits (int
eracts poorly with programmatic scroll animations) |
1189 // so we need to use the ScrollableArea version. The FrameView method sh
ould go away soon anyway. | 1189 // so we need to use the ScrollableArea version. The FrameView method sh
ould go away soon anyway. |
1190 m_scrollableArea->ScrollableArea::setScrollPosition(newPosition, Composi
torScroll); | 1190 m_scrollableArea->ScrollableArea::setScrollPosition(newPosition, Composi
torScroll); |
1191 } | 1191 } |
1192 } | 1192 } |
1193 | 1193 |
1194 scoped_refptr<base::trace_event::ConvertableToTraceFormat> GraphicsLayer::TakeDe
bugInfo(cc::Layer* layer) | |
1195 { | |
1196 scoped_refptr<base::trace_event::TracedValue> tracedValue = m_debugInfo.asTr
acedValue(); | |
1197 tracedValue->SetString("layer_name", WTF::StringUTF8Adaptor(debugName(layer)
).asStringPiece()); | |
1198 return tracedValue; | |
1199 } | |
1200 | |
1201 PaintController* GraphicsLayer::paintController() | 1194 PaintController* GraphicsLayer::paintController() |
1202 { | 1195 { |
1203 if (!m_paintController) | 1196 if (!m_paintController) |
1204 m_paintController = PaintController::create(); | 1197 m_paintController = PaintController::create(); |
1205 return m_paintController.get(); | 1198 return m_paintController.get(); |
1206 } | 1199 } |
1207 | 1200 |
1208 } // namespace blink | 1201 } // namespace blink |
1209 | 1202 |
1210 #ifndef NDEBUG | 1203 #ifndef NDEBUG |
1211 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) | 1204 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) |
1212 { | 1205 { |
1213 if (!layer) { | 1206 if (!layer) { |
1214 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); | 1207 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); |
1215 return; | 1208 return; |
1216 } | 1209 } |
1217 | 1210 |
1218 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); | 1211 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); |
1219 fprintf(stderr, "%s\n", output.utf8().data()); | 1212 fprintf(stderr, "%s\n", output.utf8().data()); |
1220 } | 1213 } |
1221 #endif | 1214 #endif |
OLD | NEW |