Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: ui/compositor/debug_utils.cc

Issue 11418040: gfx::Transform API clean-up (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/events/event.cc ('k') | ui/compositor/layer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef NDEBUG 5 #ifndef NDEBUG
6 6
7 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first.
8
7 #include "ui/compositor/debug_utils.h" 9 #include "ui/compositor/debug_utils.h"
8 10
11 #include <cmath>
9 #include <iomanip> 12 #include <iomanip>
10 #include <iostream> 13 #include <iostream>
11 #include <string> 14 #include <string>
12 15
13 #include "base/logging.h" 16 #include "base/logging.h"
14 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
15 #include "ui/compositor/layer.h" 18 #include "ui/compositor/layer.h"
16 #include "ui/gfx/interpolated_transform.h" 19 #include "ui/gfx/interpolated_transform.h"
17 #include "ui/gfx/point.h" 20 #include "ui/gfx/point.h"
18 #include "ui/gfx/point_conversions.h" 21 #include "ui/gfx/point_conversions.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 buf << L" opaque"; 53 buf << L" opaque";
51 break; 54 break;
52 case ui::LAYER_SOLID_COLOR: 55 case ui::LAYER_SOLID_COLOR:
53 buf << L" solid"; 56 buf << L" solid";
54 break; 57 break;
55 } 58 }
56 59
57 if (!layer->visible()) 60 if (!layer->visible())
58 buf << L" !visible"; 61 buf << L" !visible";
59 62
60 buf << L'\n' << UTF8ToWide(content_indent_str); 63 std::string property_indent_str(indent+3, ' ');
64 buf << L'\n' << UTF8ToWide(property_indent_str);
61 buf << L"bounds: " << layer->bounds().x() << L',' << layer->bounds().y(); 65 buf << L"bounds: " << layer->bounds().x() << L',' << layer->bounds().y();
62 buf << L' ' << layer->bounds().width() << L'x' << layer->bounds().height(); 66 buf << L' ' << layer->bounds().width() << L'x' << layer->bounds().height();
63 67
64 if (layer->opacity() != 1.0f) { 68 if (layer->opacity() != 1.0f) {
65 buf << L'\n' << UTF8ToWide(content_indent_str); 69 buf << L'\n' << UTF8ToWide(property_indent_str);
66 buf << L"opacity: " << std::setprecision(2) << layer->opacity(); 70 buf << L"opacity: " << std::setprecision(2) << layer->opacity();
67 } 71 }
68 72
69 if (!layer->transform().IsIdentity()) { 73 gfx::DecomposedTransform decomp;
70 gfx::Point translation; 74 if (!layer->transform().IsIdentity() &&
71 float rotation; 75 gfx::DecomposeTransform(&decomp, layer->transform())) {
72 gfx::Point3F scale; 76 buf << L'\n' << UTF8ToWide(property_indent_str);
73 if (ui::InterpolatedTransform::FactorTRS(layer->transform(), 77 buf << L"translation: " << std::fixed << decomp.translate[0];
74 &translation, 78 buf << L", " << decomp.translate[1];
75 &rotation,
76 &scale)) {
77 if (!translation.IsOrigin()) {
78 buf << L'\n' << UTF8ToWide(content_indent_str);
79 buf << L"translation: " << translation.x() << L", " << translation.y();
80 }
81 79
82 if (fabs(rotation) > 1e-5) { 80 buf << L'\n' << UTF8ToWide(property_indent_str);
83 buf << L'\n' << UTF8ToWide(content_indent_str); 81 buf << L"rotation: ";
84 buf << L"rotation: " << std::setprecision(4) << rotation; 82 buf << std::acos(decomp.quaternion[3]) * 360.0 / M_PI;
85 }
86 83
87 if (!gfx::ToFlooredPoint(scale.AsPointF()).IsOrigin()) { 84 buf << L'\n' << UTF8ToWide(property_indent_str);
88 buf << L'\n' << UTF8ToWide(content_indent_str); 85 buf << L"scale: " << decomp.scale[0];
89 buf << std::setprecision(4); 86 buf << L", " << decomp.scale[1];
90 buf << L"scale: " << scale.x() << L", " << scale.y();
91 }
92 }
93 } 87 }
94 88
95 VLOG(1) << buf.str(); 89 VLOG(1) << buf.str();
96 std::cout << buf.str() << std::endl; 90 std::cout << buf.str() << std::endl;
97 91
98 for (size_t i = 0, count = layer->children().size(); i < count; ++i) 92 for (size_t i = 0, count = layer->children().size(); i < count; ++i)
99 PrintLayerHierarchyImp(layer->children()[i], indent + 3, mouse_location); 93 PrintLayerHierarchyImp(layer->children()[i], indent + 3, mouse_location);
100 } 94 }
101 95
102 } // namespace 96 } // namespace
103 97
104 void PrintLayerHierarchy(const Layer* layer, gfx::Point mouse_location) { 98 void PrintLayerHierarchy(const Layer* layer, gfx::Point mouse_location) {
105 PrintLayerHierarchyImp(layer, 0, mouse_location); 99 PrintLayerHierarchyImp(layer, 0, mouse_location);
106 } 100 }
107 101
108 } // namespace ui 102 } // namespace ui
109 103
110 #endif // NDEBUG 104 #endif // NDEBUG
OLDNEW
« no previous file with comments | « ui/base/events/event.cc ('k') | ui/compositor/layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698