| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/examples/surfaces_app/child_impl.h" | 5 #include "mojo/examples/surfaces_app/child_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "cc/output/compositor_frame.h" | 8 #include "cc/output/compositor_frame.h" |
| 9 #include "cc/output/delegated_frame_data.h" | 9 #include "cc/output/delegated_frame_data.h" |
| 10 #include "cc/quads/render_pass.h" | 10 #include "cc/quads/render_pass.h" |
| 11 #include "cc/quads/solid_color_draw_quad.h" | 11 #include "cc/quads/solid_color_draw_quad.h" |
| 12 #include "mojo/examples/surfaces_app/surfaces_util.h" | 12 #include "mojo/examples/surfaces_app/surfaces_util.h" |
| 13 #include "mojo/public/cpp/application/application_connection.h" | 13 #include "mojo/public/cpp/application/application_connection.h" |
| 14 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" | 14 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" |
| 15 #include "mojo/services/public/cpp/surfaces/surfaces_type_converters.h" | 15 #include "mojo/services/public/cpp/surfaces/surfaces_type_converters.h" |
| 16 #include "mojo/services/public/interfaces/surfaces/surface_id.mojom.h" | 16 #include "mojo/services/public/interfaces/surfaces/surface_id.mojom.h" |
| 17 #include "mojo/services/public/interfaces/surfaces/surfaces.mojom.h" | 17 #include "mojo/services/public/interfaces/surfaces/surfaces.mojom.h" |
| 18 #include "ui/gfx/rect.h" | 18 #include "ui/gfx/rect.h" |
| 19 #include "ui/gfx/transform.h" | 19 #include "ui/gfx/transform.h" |
| 20 | 20 |
| 21 namespace mojo { | 21 namespace mojo { |
| 22 namespace examples { | 22 namespace examples { |
| 23 | 23 |
| 24 using cc::RenderPass; | 24 using cc::RenderPass; |
| 25 using cc::RenderPassId; |
| 25 using cc::DrawQuad; | 26 using cc::DrawQuad; |
| 26 using cc::SolidColorDrawQuad; | 27 using cc::SolidColorDrawQuad; |
| 27 using cc::DelegatedFrameData; | 28 using cc::DelegatedFrameData; |
| 28 using cc::CompositorFrame; | 29 using cc::CompositorFrame; |
| 29 | 30 |
| 30 ChildImpl::ChildImpl(ApplicationConnection* surfaces_service_connection) { | 31 ChildImpl::ChildImpl(ApplicationConnection* surfaces_service_connection) { |
| 31 surfaces_service_connection->ConnectToService(&surface_); | 32 surfaces_service_connection->ConnectToService(&surface_); |
| 32 surface_.set_client(this); | 33 surface_.set_client(this); |
| 33 } | 34 } |
| 34 | 35 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 56 void ChildImpl::ReturnResources( | 57 void ChildImpl::ReturnResources( |
| 57 Array<ReturnedResourcePtr> resources) { | 58 Array<ReturnedResourcePtr> resources) { |
| 58 DCHECK(!resources.size()); | 59 DCHECK(!resources.size()); |
| 59 } | 60 } |
| 60 | 61 |
| 61 void ChildImpl::Draw() { | 62 void ChildImpl::Draw() { |
| 62 id_ = allocator_->GenerateId(); | 63 id_ = allocator_->GenerateId(); |
| 63 surface_->CreateSurface(mojo::SurfaceId::From(id_), | 64 surface_->CreateSurface(mojo::SurfaceId::From(id_), |
| 64 mojo::Size::From(size_)); | 65 mojo::Size::From(size_)); |
| 65 gfx::Rect rect(size_); | 66 gfx::Rect rect(size_); |
| 66 RenderPass::Id id(1, 1); | 67 RenderPassId id(1, 1); |
| 67 scoped_ptr<RenderPass> pass = RenderPass::Create(); | 68 scoped_ptr<RenderPass> pass = RenderPass::Create(); |
| 68 pass->SetNew(id, rect, rect, gfx::Transform()); | 69 pass->SetNew(id, rect, rect, gfx::Transform()); |
| 69 | 70 |
| 70 CreateAndAppendSimpleSharedQuadState(pass.get(), gfx::Transform(), size_); | 71 CreateAndAppendSimpleSharedQuadState(pass.get(), gfx::Transform(), size_); |
| 71 | 72 |
| 72 SolidColorDrawQuad* color_quad = | 73 SolidColorDrawQuad* color_quad = |
| 73 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 74 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 74 bool force_anti_aliasing_off = false; | 75 bool force_anti_aliasing_off = false; |
| 75 color_quad->SetNew(pass->shared_quad_state_list.back(), | 76 color_quad->SetNew(pass->shared_quad_state_list.back(), |
| 76 rect, | 77 rect, |
| 77 rect, | 78 rect, |
| 78 color_, | 79 color_, |
| 79 force_anti_aliasing_off); | 80 force_anti_aliasing_off); |
| 80 | 81 |
| 81 scoped_ptr<DelegatedFrameData> delegated_frame_data(new DelegatedFrameData); | 82 scoped_ptr<DelegatedFrameData> delegated_frame_data(new DelegatedFrameData); |
| 82 delegated_frame_data->render_pass_list.push_back(pass.Pass()); | 83 delegated_frame_data->render_pass_list.push_back(pass.Pass()); |
| 83 | 84 |
| 84 scoped_ptr<CompositorFrame> frame(new CompositorFrame); | 85 scoped_ptr<CompositorFrame> frame(new CompositorFrame); |
| 85 frame->delegated_frame_data = delegated_frame_data.Pass(); | 86 frame->delegated_frame_data = delegated_frame_data.Pass(); |
| 86 | 87 |
| 87 surface_->SubmitFrame(mojo::SurfaceId::From(id_), | 88 surface_->SubmitFrame(mojo::SurfaceId::From(id_), |
| 88 mojo::Frame::From(*frame)); | 89 mojo::Frame::From(*frame)); |
| 89 produce_callback_.Run(SurfaceId::From(id_)); | 90 produce_callback_.Run(SurfaceId::From(id_)); |
| 90 } | 91 } |
| 91 | 92 |
| 92 } // namespace examples | 93 } // namespace examples |
| 93 } // namespace mojo | 94 } // namespace mojo |
| OLD | NEW |