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/services/surfaces/surfaces_impl.h" | 5 #include "mojo/services/surfaces/surfaces_impl.h" |
6 | 6 |
7 #include "cc/output/compositor_frame.h" | 7 #include "cc/output/compositor_frame.h" |
8 #include "cc/resources/returned_resource.h" | 8 #include "cc/resources/returned_resource.h" |
9 #include "cc/surfaces/display.h" | 9 #include "cc/surfaces/display.h" |
10 #include "cc/surfaces/surface_id_allocator.h" | 10 #include "cc/surfaces/surface_id_allocator.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 NOTREACHED(); | 37 NOTREACHED(); |
38 return; | 38 return; |
39 } | 39 } |
40 factory_.Create(id.To<cc::SurfaceId>(), size.To<gfx::Size>()); | 40 factory_.Create(id.To<cc::SurfaceId>(), size.To<gfx::Size>()); |
41 } | 41 } |
42 | 42 |
43 void SurfacesImpl::SubmitFrame(SurfaceIdPtr id, FramePtr frame_ptr) { | 43 void SurfacesImpl::SubmitFrame(SurfaceIdPtr id, FramePtr frame_ptr) { |
44 cc::SurfaceId cc_id = id.To<cc::SurfaceId>(); | 44 cc::SurfaceId cc_id = id.To<cc::SurfaceId>(); |
45 if (cc::SurfaceIdAllocator::NamespaceForId(cc_id) != id_namespace_) { | 45 if (cc::SurfaceIdAllocator::NamespaceForId(cc_id) != id_namespace_) { |
46 // Bad message, do something bad to the caller? | 46 // Bad message, do something bad to the caller? |
47 LOG(FATAL) << "Received frame for id " << cc_id.id << " namespace " | 47 NOTREACHED(); |
48 << cc::SurfaceIdAllocator::NamespaceForId(cc_id) | |
49 << " should be namespace " << id_namespace_; | |
50 return; | 48 return; |
51 } | 49 } |
52 factory_.SubmitFrame(id.To<cc::SurfaceId>(), mojo::ConvertTo(frame_ptr)); | 50 factory_.SubmitFrame(id.To<cc::SurfaceId>(), mojo::ConvertTo(frame_ptr)); |
53 client_->FrameSubmitted(); | 51 client_->FrameSubmitted(); |
54 } | 52 } |
55 | 53 |
56 void SurfacesImpl::DestroySurface(SurfaceIdPtr id) { | 54 void SurfacesImpl::DestroySurface(SurfaceIdPtr id) { |
57 cc::SurfaceId cc_id = id.To<cc::SurfaceId>(); | 55 cc::SurfaceId cc_id = id.To<cc::SurfaceId>(); |
58 if (cc::SurfaceIdAllocator::NamespaceForId(cc_id) != id_namespace_) { | 56 if (cc::SurfaceIdAllocator::NamespaceForId(cc_id) != id_namespace_) { |
59 // Bad message, do something bad to the caller? | 57 // Bad message, do something bad to the caller? |
60 NOTREACHED(); | 58 NOTREACHED(); |
61 return; | 59 return; |
62 } | 60 } |
63 factory_.Destroy(id.To<cc::SurfaceId>()); | 61 factory_.Destroy(id.To<cc::SurfaceId>()); |
64 } | 62 } |
65 | 63 |
66 void SurfacesImpl::CreateGLES2BoundSurface(CommandBufferPtr gles2_client, | 64 void SurfacesImpl::CreateGLES2BoundSurface(CommandBufferPtr gles2_client, |
67 SurfaceIdPtr id, | 65 SurfaceIdPtr id, |
68 mojo::SizePtr size) { | 66 mojo::SizePtr size) { |
69 command_buffer_handle_ = gles2_client.PassMessagePipe(); | 67 command_buffer_handle_ = gles2_client.PassMessagePipe(); |
70 | 68 |
71 cc::SurfaceId cc_id = id.To<cc::SurfaceId>(); | 69 cc::SurfaceId cc_id = id.To<cc::SurfaceId>(); |
72 if (cc::SurfaceIdAllocator::NamespaceForId(cc_id) != id_namespace_) { | 70 if (cc::SurfaceIdAllocator::NamespaceForId(cc_id) != id_namespace_) { |
73 // Bad message, do something bad to the caller? | 71 // Bad message, do something bad to the caller? |
74 LOG(FATAL) << "Received request for id " << cc_id.id << " namespace " | 72 NOTREACHED(); |
75 << cc::SurfaceIdAllocator::NamespaceForId(cc_id) | |
76 << " should be namespace " << id_namespace_; | |
77 return; | 73 return; |
78 } | 74 } |
79 if (!display_) { | 75 if (!display_) { |
80 display_.reset(new cc::Display(this, manager_, NULL)); | 76 display_.reset(new cc::Display(this, manager_, NULL)); |
81 client_->SetDisplay(display_.get()); | 77 client_->SetDisplay(display_.get()); |
82 } | 78 } |
83 factory_.Create(cc_id, size.To<gfx::Size>()); | 79 factory_.Create(cc_id, size.To<gfx::Size>()); |
84 display_->Resize(cc_id, size.To<gfx::Size>()); | 80 display_->Resize(cc_id, size.To<gfx::Size>()); |
85 } | 81 } |
86 | 82 |
87 void SurfacesImpl::ReturnResources(const cc::ReturnedResourceArray& resources) { | 83 void SurfacesImpl::ReturnResources(const cc::ReturnedResourceArray& resources) { |
88 Array<ReturnedResourcePtr> ret(resources.size()); | 84 Array<ReturnedResourcePtr> ret(resources.size()); |
89 for (size_t i = 0; i < resources.size(); ++i) { | 85 for (size_t i = 0; i < resources.size(); ++i) { |
90 ret[i] = ReturnedResource::From(resources[i]); | 86 ret[i] = ReturnedResource::From(resources[i]); |
91 } | 87 } |
92 client()->ReturnResources(ret.Pass()); | 88 client()->ReturnResources(ret.Pass()); |
93 } | 89 } |
94 | 90 |
95 scoped_ptr<cc::OutputSurface> SurfacesImpl::CreateOutputSurface() { | 91 scoped_ptr<cc::OutputSurface> SurfacesImpl::CreateOutputSurface() { |
96 return make_scoped_ptr(new cc::OutputSurface( | 92 return make_scoped_ptr(new cc::OutputSurface( |
97 new ContextProviderMojo(command_buffer_handle_.Pass()))); | 93 new ContextProviderMojo(command_buffer_handle_.Pass()))); |
98 } | 94 } |
99 | 95 |
100 } // namespace mojo | 96 } // namespace mojo |
OLD | NEW |