| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. | 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. |
| 6 | 6 |
| 7 #include "ui/compositor/debug_utils.h" | 7 #include "ui/compositor/debug_utils.h" |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <iomanip> | 10 #include <iomanip> |
| 11 #include <ostream> | 11 #include <ostream> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "third_party/skia/include/core/SkTypeface.h" |
| 16 #include "ui/compositor/layer.h" | 17 #include "ui/compositor/layer.h" |
| 17 #include "ui/gfx/geometry/point.h" | 18 #include "ui/gfx/geometry/point.h" |
| 18 #include "ui/gfx/geometry/point_conversions.h" | 19 #include "ui/gfx/geometry/point_conversions.h" |
| 19 #include "ui/gfx/interpolated_transform.h" | 20 #include "ui/gfx/interpolated_transform.h" |
| 20 #include "ui/gfx/transform.h" | 21 #include "ui/gfx/transform.h" |
| 21 | 22 |
| 22 using base::UTF8ToWide; | 23 using base::UTF8ToWide; |
| 23 | 24 |
| 24 namespace ui { | 25 namespace ui { |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 29 SkTypeface* g_hud_typeface; |
| 30 |
| 28 void PrintLayerHierarchyImp(const Layer* layer, | 31 void PrintLayerHierarchyImp(const Layer* layer, |
| 29 int indent, | 32 int indent, |
| 30 gfx::Point mouse_location, | 33 gfx::Point mouse_location, |
| 31 std::wostringstream* out) { | 34 std::wostringstream* out) { |
| 32 std::string indent_str(indent, ' '); | 35 std::string indent_str(indent, ' '); |
| 33 | 36 |
| 34 layer->transform().TransformPointReverse(&mouse_location); | 37 layer->transform().TransformPointReverse(&mouse_location); |
| 35 bool mouse_inside_layer_bounds = layer->bounds().Contains(mouse_location); | 38 bool mouse_inside_layer_bounds = layer->bounds().Contains(mouse_location); |
| 36 mouse_location.Offset(-layer->bounds().x(), -layer->bounds().y()); | 39 mouse_location.Offset(-layer->bounds().x(), -layer->bounds().y()); |
| 37 | 40 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 } // namespace | 114 } // namespace |
| 112 | 115 |
| 113 void PrintLayerHierarchy(const Layer* layer, gfx::Point mouse_location) { | 116 void PrintLayerHierarchy(const Layer* layer, gfx::Point mouse_location) { |
| 114 std::wostringstream out; | 117 std::wostringstream out; |
| 115 out << L"Layer hierarchy:\n"; | 118 out << L"Layer hierarchy:\n"; |
| 116 PrintLayerHierarchyImp(layer, 0, mouse_location, &out); | 119 PrintLayerHierarchyImp(layer, 0, mouse_location, &out); |
| 117 // Error so logs can be collected from end-users. | 120 // Error so logs can be collected from end-users. |
| 118 LOG(ERROR) << out.str(); | 121 LOG(ERROR) << out.str(); |
| 119 } | 122 } |
| 120 | 123 |
| 124 void SetHudTypeface(SkTypeface* typeface) { |
| 125 g_hud_typeface = typeface; |
| 126 } |
| 127 |
| 128 SkTypeface* GetHudTypeface() { |
| 129 if (!g_hud_typeface) { |
| 130 // This will be set pre-sandbox on Windows. On other platforms, just make |
| 131 // something here. |
| 132 g_hud_typeface = SkTypeface::CreateFromName("monospace", SkTypeface::kBold); |
| 133 } |
| 134 return g_hud_typeface; |
| 135 } |
| 136 |
| 121 } // namespace ui | 137 } // namespace ui |
| OLD | NEW |