| 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 "services/surfaces/surfaces_impl.h" | 5 #include "services/surfaces/surfaces_impl.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "cc/output/compositor_frame.h" | 8 #include "cc/output/compositor_frame.h" |
| 9 #include "cc/resources/returned_resource.h" | 9 #include "cc/resources/returned_resource.h" |
| 10 #include "cc/surfaces/display.h" | 10 #include "cc/surfaces/display.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 factory_.DestroyAll(); | 37 factory_.DestroyAll(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void SurfacesImpl::CreateSurface(SurfaceIdPtr id, SizePtr size) { | 40 void SurfacesImpl::CreateSurface(SurfaceIdPtr id, SizePtr size) { |
| 41 cc::SurfaceId cc_id = id.To<cc::SurfaceId>(); | 41 cc::SurfaceId cc_id = id.To<cc::SurfaceId>(); |
| 42 if (cc::SurfaceIdAllocator::NamespaceForId(cc_id) != id_namespace_) { | 42 if (cc::SurfaceIdAllocator::NamespaceForId(cc_id) != id_namespace_) { |
| 43 // Bad message, do something bad to the caller? | 43 // Bad message, do something bad to the caller? |
| 44 NOTREACHED(); | 44 NOTREACHED(); |
| 45 return; | 45 return; |
| 46 } | 46 } |
| 47 factory_.Create(id.To<cc::SurfaceId>(), size.To<gfx::Size>()); | 47 factory_.Create(id.To<cc::SurfaceId>()); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void SurfacesImpl::SubmitFrame(SurfaceIdPtr id, | 50 void SurfacesImpl::SubmitFrame(SurfaceIdPtr id, |
| 51 FramePtr frame_ptr, | 51 FramePtr frame_ptr, |
| 52 const Closure& callback) { | 52 const Closure& callback) { |
| 53 TRACE_EVENT0("mojo", "SurfacesImpl::SubmitFrame"); | 53 TRACE_EVENT0("mojo", "SurfacesImpl::SubmitFrame"); |
| 54 cc::SurfaceId cc_id = id.To<cc::SurfaceId>(); | 54 cc::SurfaceId cc_id = id.To<cc::SurfaceId>(); |
| 55 if (cc::SurfaceIdAllocator::NamespaceForId(cc_id) != id_namespace_) { | 55 if (cc::SurfaceIdAllocator::NamespaceForId(cc_id) != id_namespace_) { |
| 56 // Bad message, do something bad to the caller? | 56 // Bad message, do something bad to the caller? |
| 57 LOG(FATAL) << "Received frame for id " << cc_id.id << " namespace " | 57 LOG(FATAL) << "Received frame for id " << cc_id.id << " namespace " |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 << " should be namespace " << id_namespace_; | 90 << " should be namespace " << id_namespace_; |
| 91 return; | 91 return; |
| 92 } | 92 } |
| 93 if (!display_) { | 93 if (!display_) { |
| 94 cc::RendererSettings settings; | 94 cc::RendererSettings settings; |
| 95 display_.reset(new cc::Display(this, manager_, nullptr, nullptr, settings)); | 95 display_.reset(new cc::Display(this, manager_, nullptr, nullptr, settings)); |
| 96 client_->SetDisplay(display_.get()); | 96 client_->SetDisplay(display_.get()); |
| 97 display_->Initialize(make_scoped_ptr(new DirectOutputSurface( | 97 display_->Initialize(make_scoped_ptr(new DirectOutputSurface( |
| 98 new ContextProviderMojo(command_buffer_handle_.Pass())))); | 98 new ContextProviderMojo(command_buffer_handle_.Pass())))); |
| 99 } | 99 } |
| 100 factory_.Create(cc_id, size.To<gfx::Size>()); | 100 factory_.Create(cc_id); |
| 101 display_->Resize(cc_id, size.To<gfx::Size>(), 1.f); | 101 display_->SetSurfaceId(cc_id, 1.f); |
| 102 display_->Resize(size.To<gfx::Size>()); |
| 102 parameter_listeners_.AddBinding(this, listener_request.Pass()); | 103 parameter_listeners_.AddBinding(this, listener_request.Pass()); |
| 103 } | 104 } |
| 104 | 105 |
| 105 void SurfacesImpl::ReturnResources(const cc::ReturnedResourceArray& resources) { | 106 void SurfacesImpl::ReturnResources(const cc::ReturnedResourceArray& resources) { |
| 106 Array<ReturnedResourcePtr> ret(resources.size()); | 107 Array<ReturnedResourcePtr> ret(resources.size()); |
| 107 for (size_t i = 0; i < resources.size(); ++i) { | 108 for (size_t i = 0; i < resources.size(); ++i) { |
| 108 ret[i] = ReturnedResource::From(resources[i]); | 109 ret[i] = ReturnedResource::From(resources[i]); |
| 109 } | 110 } |
| 110 binding_.client()->ReturnResources(ret.Pass()); | 111 binding_.client()->ReturnResources(ret.Pass()); |
| 111 } | 112 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 130 } | 131 } |
| 131 | 132 |
| 132 void SurfacesImpl::OnVSyncParametersUpdated(int64_t timebase, | 133 void SurfacesImpl::OnVSyncParametersUpdated(int64_t timebase, |
| 133 int64_t interval) { | 134 int64_t interval) { |
| 134 client_->OnVSyncParametersUpdated( | 135 client_->OnVSyncParametersUpdated( |
| 135 base::TimeTicks::FromInternalValue(timebase), | 136 base::TimeTicks::FromInternalValue(timebase), |
| 136 base::TimeDelta::FromInternalValue(interval)); | 137 base::TimeDelta::FromInternalValue(interval)); |
| 137 } | 138 } |
| 138 | 139 |
| 139 } // namespace mojo | 140 } // namespace mojo |
| OLD | NEW |