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

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

Issue 8508009: Debugging code to print layer tree (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes as requested Created 9 years, 1 month 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
OLDNEW
(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 <iomanip>
10 #include <iostream>
11 #include <string>
12
13 #include "base/utf_string_conversions.h"
14 #include "base/logging.h"
15 #include "ui/gfx/compositor/layer.h"
16 #include "ui/gfx/interpolated_transform.h"
17 #include "ui/gfx/transform.h"
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)) {
tfarina 2011/11/11 18:46:28 nit: gfx::Point(0, 0) -> gfx::Point()?
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++)
tfarina 2011/11/11 18:46:28 do we really need to cache size() here? is for per
tfarina 2011/11/11 18:46:28 ++i
80 PrintLayerHierarchyImp(layer->children()[i], indent + 3);
81 }
82
83 } // namespace
tfarina 2011/11/11 18:46:28 nit: there should be two spaces between } and // n
84
85 void PrintLayerHierarchy(const Layer* layer) {
86 PrintLayerHierarchyImp(layer, 0);
87 }
88
89 } // namespace ui
90
91 #endif // NDEBUG
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698