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

Side by Side Diff: mojo/services/gfx/composition/cpp/formatting.cc

Issue 1552963002: Initial checkin of the new Mozart compositor. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-11
Patch Set: fix android build Created 4 years, 10 months 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
OLDNEW
(Empty)
1 // Copyright 2015 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 #include "mojo/services/gfx/composition/cpp/formatting.h"
6
7 #include <ostream>
8
9 namespace mojo {
10 namespace gfx {
11 namespace composition {
12
13 class Delimiter {
14 public:
15 Delimiter(std::ostream& os) : os_(os) {}
16
17 std::ostream& Append() {
18 if (need_comma_)
19 os_ << ", ";
20 else
21 need_comma_ = true;
22 return os_;
23 }
24
25 private:
26 std::ostream& os_;
27 bool need_comma_ = false;
28 };
29
30 std::ostream& operator<<(std::ostream& os,
31 const mojo::gfx::composition::SceneToken& value) {
32 return os << "{value=" << value.value << "}";
33 }
34
35 std::ostream& operator<<(std::ostream& os,
36 const mojo::gfx::composition::SceneUpdate& value) {
37 os << "{";
38 Delimiter d(os);
39 if (value.clear_resources) {
40 d.Append() << "clear_resources=true";
41 }
42 if (value.clear_nodes) {
43 d.Append() << "clear_nodes=true";
44 }
45 if (value.resources) {
46 d.Append() << "resources=" << value.resources;
47 }
48 if (value.nodes) {
49 d.Append() << "nodes=" << value.nodes;
50 }
51 os << "}";
52 return os;
53 }
54
55 std::ostream& operator<<(std::ostream& os,
56 const mojo::gfx::composition::SceneMetadata& value) {
57 return os << "{version=" << value.version
58 << ", presentation_time=" << value.presentation_time << "}";
59 }
60
61 std::ostream& operator<<(std::ostream& os,
62 const mojo::gfx::composition::Resource& value) {
63 os << "{";
64 if (value.is_scene()) {
65 os << "scene=" << value.get_scene();
66 } else if (value.is_mailbox_texture()) {
67 os << "mailbox_texture=" << value.get_mailbox_texture();
68 } else {
69 os << "???";
70 }
71 return os << "}";
72 }
73
74 std::ostream& operator<<(std::ostream& os,
75 const mojo::gfx::composition::SceneResource& value) {
76 return os << "{scene_token=" << value.scene_token << "}";
77 }
78
79 std::ostream& operator<<(
80 std::ostream& os,
81 const mojo::gfx::composition::MailboxTextureResource& value) {
82 return os << "{sync_point=" << value.sync_point << ", size=" << value.size
83 << "}";
84 }
85
86 std::ostream& operator<<(std::ostream& os,
87 const mojo::gfx::composition::Node& value) {
88 os << "{";
89 Delimiter d(os);
90 if (value.content_transform)
91 d.Append() << "content_transform=" << value.content_transform;
92 if (value.content_clip)
93 d.Append() << "content_clip=" << value.content_clip;
94 if (value.hit_id != mojo::gfx::composition::kHitIdNone)
95 d.Append() << "hit_id=" << value.hit_id;
96 if (value.op)
97 d.Append() << "op=" << value.op;
98 d.Append() << "combinator=" << &value.combinator;
99 if (value.child_node_ids)
100 d.Append() << "child_node_ids=" << value.child_node_ids;
101 return os << "}";
102 }
103
104 std::ostream& operator<<(
105 std::ostream& os,
106 const mojo::gfx::composition::Node::Combinator* value) {
107 switch (*value) {
108 case mojo::gfx::composition::Node::Combinator::MERGE:
109 return os << "MERGE";
110 case mojo::gfx::composition::Node::Combinator::PRUNE:
111 return os << "PRUNE";
112 case mojo::gfx::composition::Node::Combinator::FALLBACK:
113 return os << "FALLBACK";
114 default:
115 return os << "???";
116 }
117 }
118
119 std::ostream& operator<<(std::ostream& os,
120 const mojo::gfx::composition::NodeOp& value) {
121 os << "{";
122 if (value.is_rect()) {
123 os << "rect=" << value.get_rect();
124 } else if (value.is_image()) {
125 os << "image=" << value.get_image();
126 } else if (value.is_scene()) {
127 os << "scene=" << value.get_scene();
128 } else if (value.is_layer()) {
129 os << "layer=" << value.get_layer();
130 } else {
131 os << "???";
132 }
133 return os << "}";
134 }
135
136 std::ostream& operator<<(std::ostream& os,
137 const mojo::gfx::composition::RectNodeOp& value) {
138 return os << "{content_rect=" << value.content_rect
139 << ", color=" << value.color << "}";
140 }
141
142 std::ostream& operator<<(std::ostream& os,
143 const mojo::gfx::composition::ImageNodeOp& value) {
144 return os << "{content_rect=" << value.content_rect
145 << ", image_rect=" << value.image_rect
146 << ", image_resource_id=" << value.image_resource_id
147 << ", blend=" << value.blend << "}";
148 }
149
150 std::ostream& operator<<(std::ostream& os,
151 const mojo::gfx::composition::SceneNodeOp& value) {
152 return os << "{scene_resource_id=" << value.scene_resource_id
153 << ", scene_version=" << value.scene_version << "}";
154 }
155
156 std::ostream& operator<<(std::ostream& os,
157 const mojo::gfx::composition::LayerNodeOp& value) {
158 return os << "{layer_size=" << value.layer_size << ", blend=" << value.blend
159 << "}";
160 }
161
162 std::ostream& operator<<(std::ostream& os,
163 const mojo::gfx::composition::Color& value) {
164 return os << "{red=" << static_cast<int>(value.red)
165 << ", green=" << static_cast<int>(value.green)
166 << ", blue=" << static_cast<int>(value.blue)
167 << ", alpha=" << static_cast<int>(value.alpha) << "}";
168 }
169
170 std::ostream& operator<<(std::ostream& os,
171 const mojo::gfx::composition::Blend& value) {
172 return os << "{alpha=" << static_cast<int>(value.alpha) << "}";
173 }
174
175 std::ostream& operator<<(std::ostream& os,
176 const mojo::gfx::composition::FrameInfo& value) {
177 return os << "{frame_time=" << value.frame_time
178 << ", frame_interval=" << value.frame_interval
179 << ", frame_deadline=" << value.frame_deadline << "}";
180 }
181
182 } // namespace composition
183 } // namespace gfx
184 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/gfx/composition/cpp/formatting.h ('k') | mojo/services/gfx/composition/interfaces/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698