OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
18 */ | 18 */ |
19 | 19 |
20 #include "platform/graphics/GraphicsLayerDebugInfo.h" | 20 #include "platform/graphics/GraphicsLayerDebugInfo.h" |
21 | 21 |
22 #include "base/trace_event/trace_event_argument.h" | 22 #include "base/trace_event/trace_event_argument.h" |
23 | 23 |
24 namespace blink { | 24 namespace blink { |
25 | 25 |
26 GraphicsLayerDebugInfo::GraphicsLayerDebugInfo() | 26 GraphicsLayerDebugInfo::GraphicsLayerDebugInfo() |
27 : m_compositingReasons(CompositingReasonNone) | 27 : m_compositingReasons(CompositingReasonNone) |
28 , m_ownerNodeId(0) | |
29 { | 28 { |
30 } | 29 } |
31 | 30 |
32 GraphicsLayerDebugInfo::~GraphicsLayerDebugInfo() { } | 31 GraphicsLayerDebugInfo::~GraphicsLayerDebugInfo() { } |
33 | 32 |
34 scoped_refptr<base::trace_event::TracedValue> GraphicsLayerDebugInfo::asTracedVa
lue() const | 33 scoped_refptr<base::trace_event::TracedValue> GraphicsLayerDebugInfo::asTracedVa
lue() const |
35 { | 34 { |
36 scoped_refptr<base::trace_event::TracedValue> tracedValue = new base::trace_
event::TracedValue; | 35 scoped_refptr<base::trace_event::TracedValue> tracedValue = new base::trace_
event::TracedValue; |
37 appendAnnotatedInvalidateRects(tracedValue.get()); | 36 appendAnnotatedInvalidateRects(tracedValue.get()); |
38 appendCompositingReasons(tracedValue.get()); | 37 appendCompositingReasons(tracedValue.get()); |
39 appendOwnerNodeId(tracedValue.get()); | |
40 return tracedValue; | 38 return tracedValue; |
41 } | 39 } |
42 | 40 |
43 void GraphicsLayerDebugInfo::appendAnnotatedInvalidateRects(base::trace_event::T
racedValue* tracedValue) const | 41 void GraphicsLayerDebugInfo::appendAnnotatedInvalidateRects(base::trace_event::T
racedValue* tracedValue) const |
44 { | 42 { |
45 tracedValue->BeginArray("annotated_invalidation_rects"); | 43 tracedValue->BeginArray("annotated_invalidation_rects"); |
46 for (const auto& annotatedRect : m_previousInvalidations) { | 44 for (const auto& annotatedRect : m_previousInvalidations) { |
47 const FloatRect& rect = annotatedRect.rect; | 45 const FloatRect& rect = annotatedRect.rect; |
48 tracedValue->BeginDictionary(); | 46 tracedValue->BeginDictionary(); |
49 tracedValue->BeginArray("geometry_rect"); | 47 tracedValue->BeginArray("geometry_rect"); |
(...skipping 12 matching lines...) Expand all Loading... |
62 { | 60 { |
63 tracedValue->BeginArray("compositing_reasons"); | 61 tracedValue->BeginArray("compositing_reasons"); |
64 for (size_t i = 0; i < kNumberOfCompositingReasons; ++i) { | 62 for (size_t i = 0; i < kNumberOfCompositingReasons; ++i) { |
65 if (!(m_compositingReasons & kCompositingReasonStringMap[i].reason)) | 63 if (!(m_compositingReasons & kCompositingReasonStringMap[i].reason)) |
66 continue; | 64 continue; |
67 tracedValue->AppendString(kCompositingReasonStringMap[i].description); | 65 tracedValue->AppendString(kCompositingReasonStringMap[i].description); |
68 } | 66 } |
69 tracedValue->EndArray(); | 67 tracedValue->EndArray(); |
70 } | 68 } |
71 | 69 |
72 void GraphicsLayerDebugInfo::appendOwnerNodeId(base::trace_event::TracedValue* t
racedValue) const | |
73 { | |
74 if (!m_ownerNodeId) | |
75 return; | |
76 | |
77 tracedValue->SetInteger("owner_node", m_ownerNodeId); | |
78 } | |
79 | |
80 void GraphicsLayerDebugInfo::appendAnnotatedInvalidateRect(const FloatRect& rect
, PaintInvalidationReason invalidationReason) | 70 void GraphicsLayerDebugInfo::appendAnnotatedInvalidateRect(const FloatRect& rect
, PaintInvalidationReason invalidationReason) |
81 { | 71 { |
82 AnnotatedInvalidationRect annotatedRect = { | 72 AnnotatedInvalidationRect annotatedRect = { |
83 rect, | 73 rect, |
84 invalidationReason | 74 invalidationReason |
85 }; | 75 }; |
86 m_invalidations.append(annotatedRect); | 76 m_invalidations.append(annotatedRect); |
87 } | 77 } |
88 | 78 |
89 void GraphicsLayerDebugInfo::clearAnnotatedInvalidateRects() | 79 void GraphicsLayerDebugInfo::clearAnnotatedInvalidateRects() |
90 { | 80 { |
91 m_previousInvalidations.clear(); | 81 m_previousInvalidations.clear(); |
92 m_previousInvalidations.swap(m_invalidations); | 82 m_previousInvalidations.swap(m_invalidations); |
93 } | 83 } |
94 | 84 |
95 } // namespace blink | 85 } // namespace blink |
OLD | NEW |