| OLD | NEW |
| 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 Loading... |
| 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 root_node->hit_test_behavior = mojo::gfx::composition::HitTestBehavior::New(); |
| 166 root_node->op = mojo::gfx::composition::NodeOp::New(); | 167 root_node->op = mojo::gfx::composition::NodeOp::New(); |
| 167 root_node->op->set_image(mojo::gfx::composition::ImageNodeOp::New()); | 168 root_node->op->set_image(mojo::gfx::composition::ImageNodeOp::New()); |
| 168 root_node->op->get_image()->content_rect = bounds.Clone(); | 169 root_node->op->get_image()->content_rect = bounds.Clone(); |
| 169 root_node->op->get_image()->image_resource_id = kCubeImageResourceId; | 170 root_node->op->get_image()->image_resource_id = kCubeImageResourceId; |
| 170 update->nodes.insert(kRootNodeId, root_node.Pass()); | 171 update->nodes.insert(kRootNodeId, root_node.Pass()); |
| 171 | 172 |
| 172 auto metadata = mojo::gfx::composition::SceneMetadata::New(); | 173 auto metadata = mojo::gfx::composition::SceneMetadata::New(); |
| 173 metadata->presentation_time = frame_info.presentation_time; | 174 metadata->presentation_time = frame_info.presentation_time; |
| 174 | 175 |
| 175 // Publish the scene. | 176 // Publish the scene. |
| 176 scene()->Update(update.Pass()); | 177 scene()->Update(update.Pass()); |
| 177 scene()->Publish(metadata.Pass()); | 178 scene()->Publish(metadata.Pass()); |
| 178 | 179 |
| 179 // Loop! | 180 // Loop! |
| 180 choreographer_.ScheduleDraw(); | 181 choreographer_.ScheduleDraw(); |
| 181 } | 182 } |
| 182 | 183 |
| 183 void SpinningCubeView::DrawCubeWithGL() { | 184 void SpinningCubeView::DrawCubeWithGL() { |
| 184 cube_.set_size(size_.width, size_.height); | 185 cube_.set_size(size_.width, size_.height); |
| 185 cube_.Draw(); | 186 cube_.Draw(); |
| 186 } | 187 } |
| 187 | 188 |
| 188 } // namespace examples | 189 } // namespace examples |
| OLD | NEW |