| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/graphics/paint/RasterInvalidationTracking.h" | 5 #include "platform/graphics/paint/RasterInvalidationTracking.h" |
| 6 | 6 |
| 7 #include "platform/geometry/LayoutRect.h" | 7 #include "platform/geometry/LayoutRect.h" |
| 8 #include "platform/graphics/Color.h" | 8 #include "platform/graphics/Color.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 static std::unique_ptr<JSONArray> RectAsJSONArray(const T& rect) { | 34 static std::unique_ptr<JSONArray> RectAsJSONArray(const T& rect) { |
| 35 std::unique_ptr<JSONArray> array = JSONArray::Create(); | 35 std::unique_ptr<JSONArray> array = JSONArray::Create(); |
| 36 array->PushDouble(rect.X()); | 36 array->PushDouble(rect.X()); |
| 37 array->PushDouble(rect.Y()); | 37 array->PushDouble(rect.Y()); |
| 38 array->PushDouble(rect.Width()); | 38 array->PushDouble(rect.Width()); |
| 39 array->PushDouble(rect.Height()); | 39 array->PushDouble(rect.Height()); |
| 40 return array; | 40 return array; |
| 41 } | 41 } |
| 42 | 42 |
| 43 void RasterInvalidationTracking::AsJSON(JSONObject* json) { | 43 void RasterInvalidationTracking::AsJSON(JSONObject* json) { |
| 44 if (!tracked_raster_invalidations.IsEmpty()) { | 44 if (!invalidations.IsEmpty()) { |
| 45 std::sort(tracked_raster_invalidations.begin(), | 45 std::sort(invalidations.begin(), invalidations.end(), |
| 46 tracked_raster_invalidations.end(), | |
| 47 &CompareRasterInvalidationInfo); | 46 &CompareRasterInvalidationInfo); |
| 48 std::unique_ptr<JSONArray> paint_invalidations_json = JSONArray::Create(); | 47 std::unique_ptr<JSONArray> paint_invalidations_json = JSONArray::Create(); |
| 49 for (auto& info : tracked_raster_invalidations) { | 48 for (auto& info : invalidations) { |
| 50 std::unique_ptr<JSONObject> info_json = JSONObject::Create(); | 49 std::unique_ptr<JSONObject> info_json = JSONObject::Create(); |
| 51 info_json->SetString("object", info.client_debug_name); | 50 info_json->SetString("object", info.client_debug_name); |
| 52 if (!info.rect.IsEmpty()) { | 51 if (!info.rect.IsEmpty()) { |
| 53 if (info.rect == LayoutRect::InfiniteIntRect()) | 52 if (info.rect == LayoutRect::InfiniteIntRect()) |
| 54 info_json->SetString("rect", "infinite"); | 53 info_json->SetString("rect", "infinite"); |
| 55 else | 54 else |
| 56 info_json->SetArray("rect", RectAsJSONArray(info.rect)); | 55 info_json->SetArray("rect", RectAsJSONArray(info.rect)); |
| 57 } | 56 } |
| 58 info_json->SetString("reason", | 57 info_json->SetString("reason", |
| 59 PaintInvalidationReasonToString(info.reason)); | 58 PaintInvalidationReasonToString(info.reason)); |
| 60 paint_invalidations_json->PushObject(std::move(info_json)); | 59 paint_invalidations_json->PushObject(std::move(info_json)); |
| 61 } | 60 } |
| 62 json->SetArray("paintInvalidations", std::move(paint_invalidations_json)); | 61 json->SetArray("paintInvalidations", std::move(paint_invalidations_json)); |
| 63 } | 62 } |
| 64 | 63 |
| 65 if (!under_paint_invalidations.IsEmpty()) { | 64 if (!under_invalidations.IsEmpty()) { |
| 66 std::unique_ptr<JSONArray> under_paint_invalidations_json = | 65 std::unique_ptr<JSONArray> under_paint_invalidations_json = |
| 67 JSONArray::Create(); | 66 JSONArray::Create(); |
| 68 for (auto& under_paint_invalidation : under_paint_invalidations) { | 67 for (auto& under_paint_invalidation : under_invalidations) { |
| 69 std::unique_ptr<JSONObject> under_paint_invalidation_json = | 68 std::unique_ptr<JSONObject> under_paint_invalidation_json = |
| 70 JSONObject::Create(); | 69 JSONObject::Create(); |
| 71 under_paint_invalidation_json->SetDouble("x", under_paint_invalidation.x); | 70 under_paint_invalidation_json->SetDouble("x", under_paint_invalidation.x); |
| 72 under_paint_invalidation_json->SetDouble("y", under_paint_invalidation.y); | 71 under_paint_invalidation_json->SetDouble("y", under_paint_invalidation.y); |
| 73 under_paint_invalidation_json->SetString( | 72 under_paint_invalidation_json->SetString( |
| 74 "oldPixel", | 73 "oldPixel", |
| 75 Color(under_paint_invalidation.old_pixel).NameForLayoutTreeAsText()); | 74 Color(under_paint_invalidation.old_pixel).NameForLayoutTreeAsText()); |
| 76 under_paint_invalidation_json->SetString( | 75 under_paint_invalidation_json->SetString( |
| 77 "newPixel", | 76 "newPixel", |
| 78 Color(under_paint_invalidation.new_pixel).NameForLayoutTreeAsText()); | 77 Color(under_paint_invalidation.new_pixel).NameForLayoutTreeAsText()); |
| 79 under_paint_invalidations_json->PushObject( | 78 under_paint_invalidations_json->PushObject( |
| 80 std::move(under_paint_invalidation_json)); | 79 std::move(under_paint_invalidation_json)); |
| 81 } | 80 } |
| 82 json->SetArray("underPaintInvalidations", | 81 json->SetArray("underPaintInvalidations", |
| 83 std::move(under_paint_invalidations_json)); | 82 std::move(under_paint_invalidations_json)); |
| 84 } | 83 } |
| 85 } | 84 } |
| 86 | 85 |
| 87 } // namespace blink | 86 } // namespace blink |
| OLD | NEW |