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 |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
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 "platform/graphics/GraphicsLayer.h" | 26 #include "platform/graphics/GraphicsLayer.h" |
27 | 27 |
| 28 #include <algorithm> |
| 29 #include <cmath> |
| 30 #include <memory> |
| 31 #include <utility> |
28 #include "SkImageFilter.h" | 32 #include "SkImageFilter.h" |
29 #include "SkMatrix44.h" | 33 #include "SkMatrix44.h" |
30 #include "base/trace_event/trace_event_argument.h" | 34 #include "base/trace_event/trace_event_argument.h" |
31 #include "cc/layers/layer.h" | 35 #include "cc/layers/layer.h" |
32 #include "platform/DragImage.h" | 36 #include "platform/DragImage.h" |
33 #include "platform/geometry/FloatRect.h" | 37 #include "platform/geometry/FloatRect.h" |
34 #include "platform/geometry/LayoutRect.h" | 38 #include "platform/geometry/LayoutRect.h" |
35 #include "platform/geometry/Region.h" | 39 #include "platform/geometry/Region.h" |
36 #include "platform/graphics/BitmapImage.h" | 40 #include "platform/graphics/BitmapImage.h" |
37 #include "platform/graphics/CompositorFilterOperations.h" | 41 #include "platform/graphics/CompositorFilterOperations.h" |
38 #include "platform/graphics/FirstPaintInvalidationTracking.h" | 42 #include "platform/graphics/FirstPaintInvalidationTracking.h" |
39 #include "platform/graphics/GraphicsContext.h" | 43 #include "platform/graphics/GraphicsContext.h" |
40 #include "platform/graphics/Image.h" | 44 #include "platform/graphics/Image.h" |
| 45 #include "platform/graphics/InvalidationDebugging.h" |
41 #include "platform/graphics/LinkHighlight.h" | 46 #include "platform/graphics/LinkHighlight.h" |
42 #include "platform/graphics/paint/DrawingRecorder.h" | 47 #include "platform/graphics/paint/DrawingRecorder.h" |
43 #include "platform/graphics/paint/PaintCanvas.h" | 48 #include "platform/graphics/paint/PaintCanvas.h" |
44 #include "platform/graphics/paint/PaintController.h" | 49 #include "platform/graphics/paint/PaintController.h" |
45 #include "platform/graphics/paint/RasterInvalidationTracking.h" | 50 #include "platform/graphics/paint/RasterInvalidationTracking.h" |
46 #include "platform/instrumentation/tracing/TraceEvent.h" | 51 #include "platform/instrumentation/tracing/TraceEvent.h" |
47 #include "platform/json/JSONValues.h" | 52 #include "platform/json/JSONValues.h" |
48 #include "platform/scroll/ScrollableArea.h" | 53 #include "platform/scroll/ScrollableArea.h" |
49 #include "platform/text/TextStream.h" | 54 #include "platform/text/TextStream.h" |
50 #include "public/platform/Platform.h" | 55 #include "public/platform/Platform.h" |
51 #include "public/platform/WebCompositorSupport.h" | 56 #include "public/platform/WebCompositorSupport.h" |
52 #include "public/platform/WebFloatPoint.h" | 57 #include "public/platform/WebFloatPoint.h" |
53 #include "public/platform/WebFloatRect.h" | 58 #include "public/platform/WebFloatRect.h" |
54 #include "public/platform/WebLayer.h" | 59 #include "public/platform/WebLayer.h" |
55 #include "public/platform/WebPoint.h" | 60 #include "public/platform/WebPoint.h" |
56 #include "public/platform/WebSize.h" | 61 #include "public/platform/WebSize.h" |
57 #include "wtf/CurrentTime.h" | 62 #include "wtf/CurrentTime.h" |
58 #include "wtf/HashMap.h" | 63 #include "wtf/HashMap.h" |
59 #include "wtf/HashSet.h" | 64 #include "wtf/HashSet.h" |
60 #include "wtf/MathExtras.h" | 65 #include "wtf/MathExtras.h" |
61 #include "wtf/PtrUtil.h" | 66 #include "wtf/PtrUtil.h" |
62 #include "wtf/text/StringUTF8Adaptor.h" | 67 #include "wtf/text/StringUTF8Adaptor.h" |
63 #include "wtf/text/WTFString.h" | 68 #include "wtf/text/WTFString.h" |
64 #include <algorithm> | |
65 #include <cmath> | |
66 #include <memory> | |
67 #include <utility> | |
68 | 69 |
69 #ifndef NDEBUG | 70 #ifndef NDEBUG |
70 #include <stdio.h> | 71 #include <stdio.h> |
71 #endif | 72 #endif |
72 | 73 |
73 namespace blink { | 74 namespace blink { |
74 | 75 |
75 template class RasterInvalidationTrackingMap<const GraphicsLayer>; | 76 template class RasterInvalidationTrackingMap<const GraphicsLayer>; |
76 static RasterInvalidationTrackingMap<const GraphicsLayer>& | 77 static RasterInvalidationTrackingMap<const GraphicsLayer>& |
77 rasterInvalidationTrackingMap() { | 78 rasterInvalidationTrackingMap() { |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 if (auto* tracking = getRasterInvalidationTracking()) | 510 if (auto* tracking = getRasterInvalidationTracking()) |
510 return !tracking->trackedRasterInvalidations.isEmpty(); | 511 return !tracking->trackedRasterInvalidations.isEmpty(); |
511 return false; | 512 return false; |
512 } | 513 } |
513 | 514 |
514 const RasterInvalidationTracking* GraphicsLayer::getRasterInvalidationTracking() | 515 const RasterInvalidationTracking* GraphicsLayer::getRasterInvalidationTracking() |
515 const { | 516 const { |
516 return rasterInvalidationTrackingMap().find(this); | 517 return rasterInvalidationTrackingMap().find(this); |
517 } | 518 } |
518 | 519 |
519 void GraphicsLayer::trackRasterInvalidation(const DisplayItemClient& client, | 520 void GraphicsLayer::trackRasterInvalidation(const InvalidationDebugging& debug, |
520 const IntRect& rect, | 521 const IntRect& rect, |
521 PaintInvalidationReason reason) { | 522 PaintInvalidationReason reason) { |
522 if (!isTrackingOrCheckingRasterInvalidations() || rect.isEmpty()) | 523 if (!isTrackingOrCheckingRasterInvalidations() || rect.isEmpty()) |
523 return; | 524 return; |
524 | 525 |
525 RasterInvalidationTracking& tracking = | 526 RasterInvalidationTracking& tracking = |
526 rasterInvalidationTrackingMap().add(this); | 527 rasterInvalidationTrackingMap().add(this); |
527 | 528 |
528 if (m_isTrackingRasterInvalidations) { | 529 if (m_isTrackingRasterInvalidations) { |
529 RasterInvalidationInfo info; | 530 RasterInvalidationInfo info; |
530 info.client = &client; | 531 info.source = &debug; |
531 info.clientDebugName = client.debugName(); | 532 info.clientDebugName = debug.invalidationName(); |
532 info.rect = rect; | 533 info.rect = rect; |
533 info.reason = reason; | 534 info.reason = reason; |
534 tracking.trackedRasterInvalidations.push_back(info); | 535 tracking.trackedRasterInvalidations.push_back(info); |
535 } | 536 } |
536 | 537 |
537 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { | 538 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { |
538 // TODO(crbug.com/496260): Some antialiasing effects overflow the paint | 539 // TODO(crbug.com/496260): Some antialiasing effects overflow the paint |
539 // invalidation rect. | 540 // invalidation rect. |
540 IntRect r = rect; | 541 IntRect r = rect; |
541 r.inflate(1); | 542 r.inflate(1); |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 platformLayer()->setBlendMode(blendMode); | 1016 platformLayer()->setBlendMode(blendMode); |
1016 } | 1017 } |
1017 | 1018 |
1018 void GraphicsLayer::setIsRootForIsolatedGroup(bool isolated) { | 1019 void GraphicsLayer::setIsRootForIsolatedGroup(bool isolated) { |
1019 if (m_isRootForIsolatedGroup == isolated) | 1020 if (m_isRootForIsolatedGroup == isolated) |
1020 return; | 1021 return; |
1021 m_isRootForIsolatedGroup = isolated; | 1022 m_isRootForIsolatedGroup = isolated; |
1022 platformLayer()->setIsRootForIsolatedGroup(isolated); | 1023 platformLayer()->setIsRootForIsolatedGroup(isolated); |
1023 } | 1024 } |
1024 | 1025 |
| 1026 class GraphicsLayerInvalidationDebugging : public InvalidationDebugging { |
| 1027 public: |
| 1028 explicit GraphicsLayerInvalidationDebugging(GraphicsLayerClient* c, |
| 1029 GraphicsLayer* g) |
| 1030 : m_client(c), m_layer(g) {} |
| 1031 |
| 1032 WTF::String invalidationName() const final { |
| 1033 return m_client->debugName(m_layer); |
| 1034 } |
| 1035 |
| 1036 private: |
| 1037 GraphicsLayerClient* m_client; |
| 1038 GraphicsLayer* m_layer; |
| 1039 }; |
| 1040 |
1025 void GraphicsLayer::setContentsNeedsDisplay() { | 1041 void GraphicsLayer::setContentsNeedsDisplay() { |
1026 if (WebLayer* contentsLayer = contentsLayerIfRegistered()) { | 1042 if (WebLayer* contentsLayer = contentsLayerIfRegistered()) { |
1027 contentsLayer->invalidate(); | 1043 contentsLayer->invalidate(); |
1028 trackRasterInvalidation(*this, m_contentsRect, PaintInvalidationFull); | 1044 GraphicsLayerInvalidationDebugging debug(m_client, this); |
| 1045 trackRasterInvalidation(debug, m_contentsRect, PaintInvalidationFull); |
1029 } | 1046 } |
1030 } | 1047 } |
1031 | 1048 |
1032 void GraphicsLayer::setNeedsDisplay() { | 1049 void GraphicsLayer::setNeedsDisplay() { |
1033 if (!drawsContent()) | 1050 if (!drawsContent()) |
1034 return; | 1051 return; |
1035 | 1052 |
1036 // TODO(chrishtr): Stop invalidating the rects once | 1053 // TODO(chrishtr): Stop invalidating the rects once |
1037 // FrameView::paintRecursively() does so. | 1054 // FrameView::paintRecursively() does so. |
1038 m_layer->layer()->invalidate(); | 1055 m_layer->layer()->invalidate(); |
1039 for (size_t i = 0; i < m_linkHighlights.size(); ++i) | 1056 for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
1040 m_linkHighlights[i]->invalidate(); | 1057 m_linkHighlights[i]->invalidate(); |
1041 getPaintController().invalidateAll(); | 1058 getPaintController().invalidateAll(); |
1042 | 1059 |
1043 trackRasterInvalidation(*this, IntRect(IntPoint(), expandedIntSize(m_size)), | 1060 GraphicsLayerInvalidationDebugging debug(m_client, this); |
| 1061 trackRasterInvalidation(debug, IntRect(IntPoint(), expandedIntSize(m_size)), |
1044 PaintInvalidationFull); | 1062 PaintInvalidationFull); |
1045 } | 1063 } |
1046 | 1064 |
1047 DISABLE_CFI_PERF | 1065 DISABLE_CFI_PERF |
1048 void GraphicsLayer::setNeedsDisplayInRect( | 1066 void GraphicsLayer::setNeedsDisplayInRect( |
1049 const IntRect& rect, | 1067 const IntRect& rect, |
1050 PaintInvalidationReason invalidationReason, | 1068 PaintInvalidationReason invalidationReason, |
1051 const DisplayItemClient& client) { | 1069 const InvalidationDebugging& debug) { |
1052 if (!drawsContent()) | 1070 if (!drawsContent()) |
1053 return; | 1071 return; |
1054 | 1072 |
1055 m_layer->layer()->invalidateRect(rect); | 1073 m_layer->layer()->invalidateRect(rect); |
1056 if (FirstPaintInvalidationTracking::isEnabled()) | 1074 if (FirstPaintInvalidationTracking::isEnabled()) |
1057 m_debugInfo.appendAnnotatedInvalidateRect(rect, invalidationReason); | 1075 m_debugInfo.appendAnnotatedInvalidateRect(rect, invalidationReason); |
1058 for (size_t i = 0; i < m_linkHighlights.size(); ++i) | 1076 for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
1059 m_linkHighlights[i]->invalidate(); | 1077 m_linkHighlights[i]->invalidate(); |
1060 | 1078 |
1061 trackRasterInvalidation(client, rect, invalidationReason); | 1079 trackRasterInvalidation(debug, rect, invalidationReason); |
1062 } | 1080 } |
1063 | 1081 |
1064 void GraphicsLayer::setContentsRect(const IntRect& rect) { | 1082 void GraphicsLayer::setContentsRect(const IntRect& rect) { |
1065 if (rect == m_contentsRect) | 1083 if (rect == m_contentsRect) |
1066 return; | 1084 return; |
1067 | 1085 |
1068 m_contentsRect = rect; | 1086 m_contentsRect = rect; |
1069 updateContentsRect(); | 1087 updateContentsRect(); |
1070 } | 1088 } |
1071 | 1089 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) { | 1338 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) { |
1321 if (!layer) { | 1339 if (!layer) { |
1322 LOG(INFO) << "Cannot showGraphicsLayerTree for (nil)."; | 1340 LOG(INFO) << "Cannot showGraphicsLayerTree for (nil)."; |
1323 return; | 1341 return; |
1324 } | 1342 } |
1325 | 1343 |
1326 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); | 1344 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); |
1327 LOG(INFO) << output.utf8().data(); | 1345 LOG(INFO) << output.utf8().data(); |
1328 } | 1346 } |
1329 #endif | 1347 #endif |
OLD | NEW |