Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef NDEBUG | |
| 6 | |
| 7 #include "ui/gfx/compositor/debug_utils.h" | |
| 8 | |
| 9 #include "base/utf_string_conversions.h" | |
| 10 #include "base/logging.h" | |
| 11 #include "ui/gfx/interpolated_transform.h" | |
| 12 #include "ui/gfx/transform.h" | |
| 13 #include "ui/gfx/compositor/layer.h" | |
|
tfarina
2011/11/09 14:30:50
sort in alphabetical order.
| |
| 14 | |
| 15 #include <iomanip> | |
|
tfarina
2011/11/09 14:30:50
C++ header includes should become before the proje
| |
| 16 #include <iostream> | |
| 17 #include <string> | |
| 18 | |
| 19 namespace ui { | |
| 20 | |
| 21 namespace { | |
| 22 | |
| 23 void PrintLayerHierarchyImp(const Layer* layer, int indent) { | |
| 24 if (!layer->visible()) | |
| 25 return; | |
| 26 | |
| 27 std::wostringstream buf; | |
| 28 std::string indent_str(indent, ' '); | |
| 29 std::string content_indent_str(indent+1, ' '); | |
| 30 | |
| 31 buf << UTF8ToWide(indent_str); | |
| 32 buf << L'+' << UTF8ToWide(layer->name()) << L' ' << layer; | |
| 33 | |
| 34 buf << L'\n' << UTF8ToWide(content_indent_str); | |
| 35 buf << L"bounds: " << layer->bounds().x() << L',' << layer->bounds().y(); | |
| 36 buf << L' ' << layer->bounds().width() << L'x' << layer->bounds().height(); | |
| 37 | |
| 38 if (!layer->hole_rect().IsEmpty()) { | |
| 39 buf << L'\n' << UTF8ToWide(content_indent_str); | |
| 40 gfx::Rect hole_rect = layer->hole_rect(); | |
| 41 buf << L"hole: " << hole_rect.x() << L',' << hole_rect.y(); | |
| 42 buf << L' ' << hole_rect.width() << L'x' << hole_rect.height(); | |
| 43 } | |
| 44 | |
| 45 if (layer->opacity() != 1.0f) { | |
| 46 buf << L'\n' << UTF8ToWide(content_indent_str); | |
| 47 buf << L"opacity: " << std::setprecision(2) << layer->opacity(); | |
| 48 } | |
| 49 | |
| 50 if (layer->transform().HasChange()) { | |
| 51 gfx::Point translation; | |
| 52 float rotation; | |
| 53 gfx::Point3f scale; | |
| 54 if (ui::InterpolatedTransform::FactorTRS(layer->transform(), | |
| 55 &translation, | |
| 56 &rotation, | |
| 57 &scale)) { | |
| 58 if (translation != gfx::Point(0, 0)) { | |
| 59 buf << L'\n' << UTF8ToWide(content_indent_str); | |
| 60 buf << L"translation: " << translation.x() << L", " << translation.y(); | |
| 61 } | |
| 62 | |
| 63 if (fabs(rotation) > 1e-5) { | |
| 64 buf << L'\n' << UTF8ToWide(content_indent_str); | |
| 65 buf << L"rotation: " << std::setprecision(4) << rotation; | |
| 66 } | |
| 67 | |
| 68 if (scale.AsPoint() != gfx::Point(0, 0)) { | |
| 69 buf << L'\n' << UTF8ToWide(content_indent_str); | |
| 70 buf << std::setprecision(4); | |
| 71 buf << L"scale: " << scale.x() << L", " << scale.y(); | |
| 72 } | |
| 73 } | |
| 74 } | |
| 75 | |
| 76 VLOG(1) << buf.str(); | |
| 77 std::cout << buf.str() << std::endl; | |
| 78 | |
| 79 for (size_t i = 0, count = layer->children().size(); i < count; i++) | |
| 80 PrintLayerHierarchyImp(layer->children()[i], indent + 3); | |
| 81 } | |
| 82 | |
| 83 } // namespace | |
| 84 | |
| 85 void PrintLayerHierarchy(const Layer* layer) { | |
| 86 PrintLayerHierarchyImp(layer, 0); | |
| 87 } | |
| 88 } // namespace ui | |
|
tfarina
2011/11/09 14:30:50
blank line here too please.
| |
| 89 #endif // NDEBUG | |
| OLD | NEW |