Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(828)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/GraphicsLayerDebugInfo.cpp

Issue 1419913002: Remove blink::WebLayerClient and WebGraphicsLayerDebugInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: try making webcore_shared link with base to fix win dbg component Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "config.h" 20 #include "config.h"
21 #include "platform/graphics/GraphicsLayerDebugInfo.h" 21 #include "platform/graphics/GraphicsLayerDebugInfo.h"
22 22
23 #include "public/platform/WebGraphicsLayerDebugInfo.h" 23 #include "base/trace_event/trace_event_argument.h"
24 #include "wtf/text/CString.h" 24 #include "wtf/text/CString.h"
25 25
26 namespace blink { 26 namespace blink {
27 27
28 GraphicsLayerDebugInfo::GraphicsLayerDebugInfo() 28 GraphicsLayerDebugInfo::GraphicsLayerDebugInfo()
29 : m_compositingReasons(CompositingReasonNone) 29 : m_compositingReasons(CompositingReasonNone)
30 , m_ownerNodeId(0) 30 , m_ownerNodeId(0)
31 { 31 {
32 } 32 }
33 33
34 GraphicsLayerDebugInfo::~GraphicsLayerDebugInfo() { } 34 GraphicsLayerDebugInfo::~GraphicsLayerDebugInfo() { }
35 35
36 void GraphicsLayerDebugInfo::appendAsTraceFormat(WebString* out) const 36 scoped_refptr<base::trace_event::TracedValue> GraphicsLayerDebugInfo::asTracedVa lue() const
37 { 37 {
38 RefPtr<JSONObject> jsonObject = JSONObject::create(); 38 scoped_refptr<base::trace_event::TracedValue> tracedValue = new base::trace_ event::TracedValue;
39 appendAnnotatedInvalidateRects(jsonObject.get()); 39 appendAnnotatedInvalidateRects(tracedValue.get());
40 appendCompositingReasons(jsonObject.get()); 40 appendCompositingReasons(tracedValue.get());
41 appendDebugName(jsonObject.get()); 41 appendOwnerNodeId(tracedValue.get());
42 appendOwnerNodeId(jsonObject.get()); 42 return tracedValue;
43 *out = jsonObject->toJSONString();
44 } 43 }
45 44
46 GraphicsLayerDebugInfo* GraphicsLayerDebugInfo::clone() const 45 void GraphicsLayerDebugInfo::appendAnnotatedInvalidateRects(base::trace_event::T racedValue* tracedValue) const
47 { 46 {
48 GraphicsLayerDebugInfo* toReturn = new GraphicsLayerDebugInfo(); 47 tracedValue->BeginArray("annotated_invalidation_rects");
49 toReturn->setCompositingReasons(m_compositingReasons); 48 for (const auto& annotatedRect : m_previousInvalidations) {
50 toReturn->setOwnerNodeId(m_ownerNodeId); 49 const FloatRect& rect = annotatedRect.rect;
51 toReturn->m_invalidations = m_invalidations; 50 tracedValue->BeginDictionary();
chrishtr 2015/10/23 17:23:13 Why these changes?
jbroman 2015/10/23 17:33:35 Need to produce a base::trace_event::ConvertableTo
chrishtr 2015/10/23 17:34:54 Is base::trace_event now allowed in Blink? I think
jbroman 2015/10/23 17:47:13 My understanding is "Don't use base's TRACE_EVENT
52 toReturn->m_previousInvalidations = m_previousInvalidations; 51 tracedValue->BeginArray("geometry_rect");
53 return toReturn; 52 tracedValue->AppendDouble(rect.x());
53 tracedValue->AppendDouble(rect.y());
54 tracedValue->AppendDouble(rect.width());
55 tracedValue->AppendDouble(rect.height());
56 tracedValue->EndArray();
57 tracedValue->SetString("reason", paintInvalidationReasonToString(annotat edRect.reason));
58 tracedValue->EndDictionary();
59 }
60 tracedValue->EndArray();
54 } 61 }
55 62
56 void GraphicsLayerDebugInfo::appendAnnotatedInvalidateRects(JSONObject* jsonObje ct) const 63 void GraphicsLayerDebugInfo::appendCompositingReasons(base::trace_event::TracedV alue* tracedValue) const
57 { 64 {
58 RefPtr<JSONArray> jsonArray = JSONArray::create(); 65 tracedValue->BeginArray("compositing_reasons");
59 for (const auto& annotatedRect : m_previousInvalidations) {
60 RefPtr<JSONObject> rectContainer = JSONObject::create();
61 RefPtr<JSONArray> rectArray = JSONArray::create();
62 const FloatRect& rect = annotatedRect.rect;
63 rectArray->pushNumber(rect.x());
64 rectArray->pushNumber(rect.y());
65 rectArray->pushNumber(rect.width());
66 rectArray->pushNumber(rect.height());
67 rectContainer->setArray("geometry_rect", rectArray);
68 rectContainer->setString("reason", paintInvalidationReasonToString(annot atedRect.reason));
69 jsonArray->pushObject(rectContainer);
70 }
71 jsonObject->setArray("annotated_invalidation_rects", jsonArray);
72 }
73
74 void GraphicsLayerDebugInfo::appendCompositingReasons(JSONObject* jsonObject) co nst
75 {
76 RefPtr<JSONArray> jsonArray = JSONArray::create();
77 for (size_t i = 0; i < kNumberOfCompositingReasons; ++i) { 66 for (size_t i = 0; i < kNumberOfCompositingReasons; ++i) {
78 if (!(m_compositingReasons & kCompositingReasonStringMap[i].reason)) 67 if (!(m_compositingReasons & kCompositingReasonStringMap[i].reason))
79 continue; 68 continue;
80 jsonArray->pushString(kCompositingReasonStringMap[i].description); 69 tracedValue->AppendString(kCompositingReasonStringMap[i].description);
81 } 70 }
82 jsonObject->setArray("compositing_reasons", jsonArray); 71 tracedValue->EndArray();
83 } 72 }
84 73
85 void GraphicsLayerDebugInfo::appendDebugName(JSONObject* jsonObject) const 74 void GraphicsLayerDebugInfo::appendOwnerNodeId(base::trace_event::TracedValue* t racedValue) const
86 {
87 if (m_debugName.isEmpty())
88 return;
89
90 jsonObject->setString("layer_name", m_debugName);
91 }
92
93 void GraphicsLayerDebugInfo::appendOwnerNodeId(JSONObject* jsonObject) const
94 { 75 {
95 if (!m_ownerNodeId) 76 if (!m_ownerNodeId)
96 return; 77 return;
97 78
98 jsonObject->setNumber("owner_node", m_ownerNodeId); 79 tracedValue->SetInteger("owner_node", m_ownerNodeId);
99 } 80 }
100 81
101 void GraphicsLayerDebugInfo::appendAnnotatedInvalidateRect(const FloatRect& rect , PaintInvalidationReason invalidationReason) 82 void GraphicsLayerDebugInfo::appendAnnotatedInvalidateRect(const FloatRect& rect , PaintInvalidationReason invalidationReason)
102 { 83 {
103 AnnotatedInvalidationRect annotatedRect = { 84 AnnotatedInvalidationRect annotatedRect = {
104 rect, 85 rect,
105 invalidationReason 86 invalidationReason
106 }; 87 };
107 m_invalidations.append(annotatedRect); 88 m_invalidations.append(annotatedRect);
108 } 89 }
109 90
110 void GraphicsLayerDebugInfo::clearAnnotatedInvalidateRects() 91 void GraphicsLayerDebugInfo::clearAnnotatedInvalidateRects()
111 { 92 {
112 m_previousInvalidations.clear(); 93 m_previousInvalidations.clear();
113 m_previousInvalidations.swap(m_invalidations); 94 m_previousInvalidations.swap(m_invalidations);
114 } 95 }
115 96
116 } // namespace blink 97 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698