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