| Index: ui/compositor/debug_utils.cc
|
| diff --git a/ui/compositor/debug_utils.cc b/ui/compositor/debug_utils.cc
|
| index 44c20602a53721ec899b9e80bcaf8d5cc94d107b..f80be6a50707f3644091ecd52e79a18df6b28c8b 100644
|
| --- a/ui/compositor/debug_utils.cc
|
| +++ b/ui/compositor/debug_utils.cc
|
| @@ -2,8 +2,6 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef NDEBUG
|
| -
|
| #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first.
|
|
|
| #include "ui/compositor/debug_utils.h"
|
| @@ -25,9 +23,10 @@ namespace ui {
|
|
|
| namespace {
|
|
|
| -void PrintLayerHierarchyImp(const Layer* layer, int indent,
|
| - gfx::Point mouse_location) {
|
| - std::wostringstream buf;
|
| +void PrintLayerHierarchyImp(const Layer* layer,
|
| + int indent,
|
| + gfx::Point mouse_location,
|
| + std::wostringstream* out) {
|
| std::string indent_str(indent, ' ');
|
| std::string content_indent_str(indent+1, ' ');
|
|
|
| @@ -35,70 +34,73 @@ void PrintLayerHierarchyImp(const Layer* layer, int indent,
|
| bool mouse_inside_layer_bounds = layer->bounds().Contains(mouse_location);
|
| mouse_location.Offset(-layer->bounds().x(), -layer->bounds().y());
|
|
|
| - buf << UTF8ToWide(indent_str);
|
| + *out << UTF8ToWide(indent_str);
|
| if (mouse_inside_layer_bounds)
|
| - buf << L'*';
|
| + *out << L'*';
|
| else
|
| - buf << L' ';
|
| + *out << L' ';
|
|
|
| - buf << UTF8ToWide(layer->name()) << L' ' << layer;
|
| + *out << UTF8ToWide(layer->name()) << L' ' << layer;
|
|
|
| switch (layer->type()) {
|
| case ui::LAYER_NOT_DRAWN:
|
| - buf << L" not_drawn";
|
| + *out << L" not_drawn";
|
| break;
|
| case ui::LAYER_TEXTURED:
|
| - buf << L" textured";
|
| + *out << L" textured";
|
| if (layer->fills_bounds_opaquely())
|
| - buf << L" opaque";
|
| + *out << L" opaque";
|
| break;
|
| case ui::LAYER_SOLID_COLOR:
|
| - buf << L" solid";
|
| + *out << L" solid";
|
| break;
|
| }
|
|
|
| if (!layer->visible())
|
| - buf << L" !visible";
|
| + *out << L" !visible";
|
|
|
| std::string property_indent_str(indent+3, ' ');
|
| - buf << L'\n' << UTF8ToWide(property_indent_str);
|
| - buf << L"bounds: " << layer->bounds().x() << L',' << layer->bounds().y();
|
| - buf << L' ' << layer->bounds().width() << L'x' << layer->bounds().height();
|
| + *out << L'\n' << UTF8ToWide(property_indent_str);
|
| + *out << L"bounds: " << layer->bounds().x() << L',' << layer->bounds().y();
|
| + *out << L' ' << layer->bounds().width() << L'x' << layer->bounds().height();
|
|
|
| if (layer->opacity() != 1.0f) {
|
| - buf << L'\n' << UTF8ToWide(property_indent_str);
|
| - buf << L"opacity: " << std::setprecision(2) << layer->opacity();
|
| + *out << L'\n' << UTF8ToWide(property_indent_str);
|
| + *out << L"opacity: " << std::setprecision(2) << layer->opacity();
|
| }
|
|
|
| gfx::DecomposedTransform decomp;
|
| if (!layer->transform().IsIdentity() &&
|
| gfx::DecomposeTransform(&decomp, layer->transform())) {
|
| - buf << L'\n' << UTF8ToWide(property_indent_str);
|
| - buf << L"translation: " << std::fixed << decomp.translate[0];
|
| - buf << L", " << decomp.translate[1];
|
| + *out << L'\n' << UTF8ToWide(property_indent_str);
|
| + *out << L"translation: " << std::fixed << decomp.translate[0];
|
| + *out << L", " << decomp.translate[1];
|
|
|
| - buf << L'\n' << UTF8ToWide(property_indent_str);
|
| - buf << L"rotation: ";
|
| - buf << std::acos(decomp.quaternion[3]) * 360.0 / M_PI;
|
| + *out << L'\n' << UTF8ToWide(property_indent_str);
|
| + *out << L"rotation: ";
|
| + *out << std::acos(decomp.quaternion[3]) * 360.0 / M_PI;
|
|
|
| - buf << L'\n' << UTF8ToWide(property_indent_str);
|
| - buf << L"scale: " << decomp.scale[0];
|
| - buf << L", " << decomp.scale[1];
|
| + *out << L'\n' << UTF8ToWide(property_indent_str);
|
| + *out << L"scale: " << decomp.scale[0];
|
| + *out << L", " << decomp.scale[1];
|
| }
|
|
|
| - VLOG(1) << buf.str();
|
| - std::cout << buf.str() << std::endl;
|
| + *out << L'\n';
|
|
|
| - for (size_t i = 0, count = layer->children().size(); i < count; ++i)
|
| - PrintLayerHierarchyImp(layer->children()[i], indent + 3, mouse_location);
|
| + for (size_t i = 0, count = layer->children().size(); i < count; ++i) {
|
| + PrintLayerHierarchyImp(
|
| + layer->children()[i], indent + 3, mouse_location, out);
|
| + }
|
| }
|
|
|
| } // namespace
|
|
|
| void PrintLayerHierarchy(const Layer* layer, gfx::Point mouse_location) {
|
| - PrintLayerHierarchyImp(layer, 0, mouse_location);
|
| + std::wostringstream out;
|
| + out << L"Layer hierarchy:\n";
|
| + PrintLayerHierarchyImp(layer, 0, mouse_location, &out);
|
| + // Error so logs can be collected from end-users.
|
| + LOG(ERROR) << out.str();
|
| }
|
|
|
| } // namespace ui
|
| -
|
| -#endif // NDEBUG
|
|
|