Chromium Code Reviews| Index: third_party/WebKit/Source/platform/graphics/GraphicsLayerDebugInfo.cpp |
| diff --git a/third_party/WebKit/Source/platform/graphics/GraphicsLayerDebugInfo.cpp b/third_party/WebKit/Source/platform/graphics/GraphicsLayerDebugInfo.cpp |
| index 4c2c76e9bb716876b16b62554071a8ab5378f352..056ee0792f700874345e684639296664a58889b7 100644 |
| --- a/third_party/WebKit/Source/platform/graphics/GraphicsLayerDebugInfo.cpp |
| +++ b/third_party/WebKit/Source/platform/graphics/GraphicsLayerDebugInfo.cpp |
| @@ -20,7 +20,7 @@ |
| #include "config.h" |
| #include "platform/graphics/GraphicsLayerDebugInfo.h" |
| -#include "public/platform/WebGraphicsLayerDebugInfo.h" |
| +#include "base/trace_event/trace_event_argument.h" |
| #include "wtf/text/CString.h" |
| namespace blink { |
| @@ -33,69 +33,50 @@ GraphicsLayerDebugInfo::GraphicsLayerDebugInfo() |
| GraphicsLayerDebugInfo::~GraphicsLayerDebugInfo() { } |
| -void GraphicsLayerDebugInfo::appendAsTraceFormat(WebString* out) const |
| +scoped_refptr<base::trace_event::TracedValue> GraphicsLayerDebugInfo::asTracedValue() const |
| { |
| - RefPtr<JSONObject> jsonObject = JSONObject::create(); |
| - appendAnnotatedInvalidateRects(jsonObject.get()); |
| - appendCompositingReasons(jsonObject.get()); |
| - appendDebugName(jsonObject.get()); |
| - appendOwnerNodeId(jsonObject.get()); |
| - *out = jsonObject->toJSONString(); |
| + scoped_refptr<base::trace_event::TracedValue> tracedValue = new base::trace_event::TracedValue; |
| + appendAnnotatedInvalidateRects(tracedValue.get()); |
| + appendCompositingReasons(tracedValue.get()); |
| + appendOwnerNodeId(tracedValue.get()); |
| + return tracedValue; |
| } |
| -GraphicsLayerDebugInfo* GraphicsLayerDebugInfo::clone() const |
| +void GraphicsLayerDebugInfo::appendAnnotatedInvalidateRects(base::trace_event::TracedValue* tracedValue) const |
| { |
| - GraphicsLayerDebugInfo* toReturn = new GraphicsLayerDebugInfo(); |
| - toReturn->setCompositingReasons(m_compositingReasons); |
| - toReturn->setOwnerNodeId(m_ownerNodeId); |
| - toReturn->m_invalidations = m_invalidations; |
| - toReturn->m_previousInvalidations = m_previousInvalidations; |
| - return toReturn; |
| -} |
| - |
| -void GraphicsLayerDebugInfo::appendAnnotatedInvalidateRects(JSONObject* jsonObject) const |
| -{ |
| - RefPtr<JSONArray> jsonArray = JSONArray::create(); |
| + tracedValue->BeginArray("annotated_invalidation_rects"); |
| for (const auto& annotatedRect : m_previousInvalidations) { |
| - RefPtr<JSONObject> rectContainer = JSONObject::create(); |
| - RefPtr<JSONArray> rectArray = JSONArray::create(); |
| const FloatRect& rect = annotatedRect.rect; |
| - rectArray->pushNumber(rect.x()); |
| - rectArray->pushNumber(rect.y()); |
| - rectArray->pushNumber(rect.width()); |
| - rectArray->pushNumber(rect.height()); |
| - rectContainer->setArray("geometry_rect", rectArray); |
| - rectContainer->setString("reason", paintInvalidationReasonToString(annotatedRect.reason)); |
| - jsonArray->pushObject(rectContainer); |
| + 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
|
| + tracedValue->BeginArray("geometry_rect"); |
| + tracedValue->AppendDouble(rect.x()); |
| + tracedValue->AppendDouble(rect.y()); |
| + tracedValue->AppendDouble(rect.width()); |
| + tracedValue->AppendDouble(rect.height()); |
| + tracedValue->EndArray(); |
| + tracedValue->SetString("reason", paintInvalidationReasonToString(annotatedRect.reason)); |
| + tracedValue->EndDictionary(); |
| } |
| - jsonObject->setArray("annotated_invalidation_rects", jsonArray); |
| + tracedValue->EndArray(); |
| } |
| -void GraphicsLayerDebugInfo::appendCompositingReasons(JSONObject* jsonObject) const |
| +void GraphicsLayerDebugInfo::appendCompositingReasons(base::trace_event::TracedValue* tracedValue) const |
| { |
| - RefPtr<JSONArray> jsonArray = JSONArray::create(); |
| + tracedValue->BeginArray("compositing_reasons"); |
| for (size_t i = 0; i < kNumberOfCompositingReasons; ++i) { |
| if (!(m_compositingReasons & kCompositingReasonStringMap[i].reason)) |
| continue; |
| - jsonArray->pushString(kCompositingReasonStringMap[i].description); |
| + tracedValue->AppendString(kCompositingReasonStringMap[i].description); |
| } |
| - jsonObject->setArray("compositing_reasons", jsonArray); |
| -} |
| - |
| -void GraphicsLayerDebugInfo::appendDebugName(JSONObject* jsonObject) const |
| -{ |
| - if (m_debugName.isEmpty()) |
| - return; |
| - |
| - jsonObject->setString("layer_name", m_debugName); |
| + tracedValue->EndArray(); |
| } |
| -void GraphicsLayerDebugInfo::appendOwnerNodeId(JSONObject* jsonObject) const |
| +void GraphicsLayerDebugInfo::appendOwnerNodeId(base::trace_event::TracedValue* tracedValue) const |
| { |
| if (!m_ownerNodeId) |
| return; |
| - jsonObject->setNumber("owner_node", m_ownerNodeId); |
| + tracedValue->SetInteger("owner_node", m_ownerNodeId); |
| } |
| void GraphicsLayerDebugInfo::appendAnnotatedInvalidateRect(const FloatRect& rect, PaintInvalidationReason invalidationReason) |