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

Side by Side Diff: examples/ui/spinning_cube/spinning_cube_view.cc

Issue 1776643004: Mozart: Specify texture origin explicitly. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-3
Patch Set: Created 4 years, 9 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
« no previous file with comments | « no previous file | mojo/dart/packages/mojo_services/lib/mojo/gfx/composition/resources.mojom.dart » ('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 2015 The Chromium Authors. All rights reserved. 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 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 #include "examples/ui/spinning_cube/spinning_cube_view.h" 5 #include "examples/ui/spinning_cube/spinning_cube_view.h"
6 6
7 #ifndef GL_GLEXT_PROTOTYPES 7 #ifndef GL_GLEXT_PROTOTYPES
8 #define GL_GLEXT_PROTOTYPES 8 #define GL_GLEXT_PROTOTYPES
9 #endif 9 #endif
10 10
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 auto update = mojo::gfx::composition::SceneUpdate::New(); 156 auto update = mojo::gfx::composition::SceneUpdate::New();
157 mojo::gfx::composition::ResourcePtr cube_resource = gl_renderer()->DrawGL( 157 mojo::gfx::composition::ResourcePtr cube_resource = gl_renderer()->DrawGL(
158 size_, true, 158 size_, true,
159 base::Bind(&SpinningCubeView::DrawCubeWithGL, base::Unretained(this))); 159 base::Bind(&SpinningCubeView::DrawCubeWithGL, base::Unretained(this)));
160 DCHECK(cube_resource); 160 DCHECK(cube_resource);
161 update->resources.insert(kCubeImageResourceId, cube_resource.Pass()); 161 update->resources.insert(kCubeImageResourceId, cube_resource.Pass());
162 162
163 auto root_node = mojo::gfx::composition::Node::New(); 163 auto root_node = mojo::gfx::composition::Node::New();
164 root_node->content_transform = mojo::Transform::New(); 164 root_node->content_transform = mojo::Transform::New();
165 mojo::SetIdentityTransform(root_node->content_transform.get()); 165 mojo::SetIdentityTransform(root_node->content_transform.get());
166 // TODO(jeffbrown): Figure out why spinning cube is drawing upside down.
167 // Other GL based programs don't seem to have this problem.
168 root_node->content_transform->matrix[5] = -1; // flip image vertically
169 root_node->content_transform->matrix[7] = size_.height;
170 root_node->op = mojo::gfx::composition::NodeOp::New(); 166 root_node->op = mojo::gfx::composition::NodeOp::New();
171 root_node->op->set_image(mojo::gfx::composition::ImageNodeOp::New()); 167 root_node->op->set_image(mojo::gfx::composition::ImageNodeOp::New());
172 root_node->op->get_image()->content_rect = bounds.Clone(); 168 root_node->op->get_image()->content_rect = bounds.Clone();
173 root_node->op->get_image()->image_resource_id = kCubeImageResourceId; 169 root_node->op->get_image()->image_resource_id = kCubeImageResourceId;
174 update->nodes.insert(kRootNodeId, root_node.Pass()); 170 update->nodes.insert(kRootNodeId, root_node.Pass());
175 171
176 auto metadata = mojo::gfx::composition::SceneMetadata::New(); 172 auto metadata = mojo::gfx::composition::SceneMetadata::New();
177 metadata->presentation_time = frame_info.presentation_time; 173 metadata->presentation_time = frame_info.presentation_time;
178 174
179 // Publish the scene. 175 // Publish the scene.
180 scene()->Update(update.Pass()); 176 scene()->Update(update.Pass());
181 scene()->Publish(metadata.Pass()); 177 scene()->Publish(metadata.Pass());
182 178
183 // Loop! 179 // Loop!
184 choreographer_.ScheduleDraw(); 180 choreographer_.ScheduleDraw();
185 } 181 }
186 182
187 void SpinningCubeView::DrawCubeWithGL() { 183 void SpinningCubeView::DrawCubeWithGL() {
188 cube_.set_size(size_.width, size_.height); 184 cube_.set_size(size_.width, size_.height);
189 cube_.Draw(); 185 cube_.Draw();
190 } 186 }
191 187
192 } // namespace examples 188 } // namespace examples
OLDNEW
« no previous file with comments | « no previous file | mojo/dart/packages/mojo_services/lib/mojo/gfx/composition/resources.mojom.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698