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 "base/debug/trace_event.h" |
7 #include "cc/output/compositor_frame.h" | 8 #include "cc/output/compositor_frame.h" |
8 #include "cc/resources/returned_resource.h" | 9 #include "cc/resources/returned_resource.h" |
9 #include "cc/surfaces/display.h" | 10 #include "cc/surfaces/display.h" |
10 #include "cc/surfaces/surface_id_allocator.h" | 11 #include "cc/surfaces/surface_id_allocator.h" |
11 #include "mojo/cc/context_provider_mojo.h" | 12 #include "mojo/cc/context_provider_mojo.h" |
12 #include "mojo/cc/direct_output_surface.h" | 13 #include "mojo/cc/direct_output_surface.h" |
13 #include "mojo/converters/geometry/geometry_type_converters.h" | 14 #include "mojo/converters/geometry/geometry_type_converters.h" |
14 #include "mojo/converters/surfaces/surfaces_type_converters.h" | 15 #include "mojo/converters/surfaces/surfaces_type_converters.h" |
15 | 16 |
16 namespace mojo { | 17 namespace mojo { |
| 18 namespace { |
| 19 void CallCallback(const mojo::Closure& callback) { |
| 20 callback.Run(); |
| 21 } |
| 22 } |
17 | 23 |
18 SurfacesImpl::SurfacesImpl(cc::SurfaceManager* manager, | 24 SurfacesImpl::SurfacesImpl(cc::SurfaceManager* manager, |
19 uint32_t id_namespace, | 25 uint32_t id_namespace, |
20 Client* client, | 26 Client* client, |
21 SurfacePtr* surface) | 27 SurfacePtr* surface) |
22 : manager_(manager), | 28 : manager_(manager), |
23 factory_(manager, this), | 29 factory_(manager, this), |
24 id_namespace_(id_namespace), | 30 id_namespace_(id_namespace), |
25 client_(client), | 31 client_(client), |
26 binding_(this, surface) { | 32 binding_(this, surface) { |
27 } | 33 } |
28 | 34 |
29 SurfacesImpl::~SurfacesImpl() { | 35 SurfacesImpl::~SurfacesImpl() { |
30 client_->OnDisplayBeingDestroyed(display_.get()); | 36 client_->OnDisplayBeingDestroyed(display_.get()); |
31 factory_.DestroyAll(); | 37 factory_.DestroyAll(); |
32 } | 38 } |
33 | 39 |
34 void SurfacesImpl::CreateSurface(SurfaceIdPtr id, mojo::SizePtr size) { | 40 void SurfacesImpl::CreateSurface(SurfaceIdPtr id, mojo::SizePtr size) { |
35 cc::SurfaceId cc_id = id.To<cc::SurfaceId>(); | 41 cc::SurfaceId cc_id = id.To<cc::SurfaceId>(); |
36 if (cc::SurfaceIdAllocator::NamespaceForId(cc_id) != id_namespace_) { | 42 if (cc::SurfaceIdAllocator::NamespaceForId(cc_id) != id_namespace_) { |
37 // Bad message, do something bad to the caller? | 43 // Bad message, do something bad to the caller? |
38 NOTREACHED(); | 44 NOTREACHED(); |
39 return; | 45 return; |
40 } | 46 } |
41 factory_.Create(id.To<cc::SurfaceId>(), size.To<gfx::Size>()); | 47 factory_.Create(id.To<cc::SurfaceId>(), size.To<gfx::Size>()); |
42 } | 48 } |
43 | 49 |
44 void SurfacesImpl::SubmitFrame(SurfaceIdPtr id, FramePtr frame_ptr) { | 50 void SurfacesImpl::SubmitFrame(SurfaceIdPtr id, |
| 51 FramePtr frame_ptr, |
| 52 const mojo::Closure& callback) { |
| 53 TRACE_EVENT0("mojo", "SurfacesImpl::SubmitFrame"); |
45 cc::SurfaceId cc_id = id.To<cc::SurfaceId>(); | 54 cc::SurfaceId cc_id = id.To<cc::SurfaceId>(); |
46 if (cc::SurfaceIdAllocator::NamespaceForId(cc_id) != id_namespace_) { | 55 if (cc::SurfaceIdAllocator::NamespaceForId(cc_id) != id_namespace_) { |
47 // Bad message, do something bad to the caller? | 56 // Bad message, do something bad to the caller? |
48 LOG(FATAL) << "Received frame for id " << cc_id.id << " namespace " | 57 LOG(FATAL) << "Received frame for id " << cc_id.id << " namespace " |
49 << cc::SurfaceIdAllocator::NamespaceForId(cc_id) | 58 << cc::SurfaceIdAllocator::NamespaceForId(cc_id) |
50 << " should be namespace " << id_namespace_; | 59 << " should be namespace " << id_namespace_; |
51 return; | 60 return; |
52 } | 61 } |
53 factory_.SubmitFrame(id.To<cc::SurfaceId>(), | 62 factory_.SubmitFrame(id.To<cc::SurfaceId>(), |
54 frame_ptr.To<scoped_ptr<cc::CompositorFrame> >(), | 63 frame_ptr.To<scoped_ptr<cc::CompositorFrame>>(), |
55 base::Closure()); | 64 base::Bind(&CallCallback, callback)); |
56 client_->FrameSubmitted(); | 65 client_->FrameSubmitted(); |
57 } | 66 } |
58 | 67 |
59 void SurfacesImpl::DestroySurface(SurfaceIdPtr id) { | 68 void SurfacesImpl::DestroySurface(SurfaceIdPtr id) { |
60 cc::SurfaceId cc_id = id.To<cc::SurfaceId>(); | 69 cc::SurfaceId cc_id = id.To<cc::SurfaceId>(); |
61 if (cc::SurfaceIdAllocator::NamespaceForId(cc_id) != id_namespace_) { | 70 if (cc::SurfaceIdAllocator::NamespaceForId(cc_id) != id_namespace_) { |
62 // Bad message, do something bad to the caller? | 71 // Bad message, do something bad to the caller? |
63 NOTREACHED(); | 72 NOTREACHED(); |
64 return; | 73 return; |
65 } | 74 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 base::TimeDelta interval) { | 120 base::TimeDelta interval) { |
112 } | 121 } |
113 | 122 |
114 void SurfacesImpl::OutputSurfaceLost() { | 123 void SurfacesImpl::OutputSurfaceLost() { |
115 } | 124 } |
116 | 125 |
117 void SurfacesImpl::SetMemoryPolicy(const cc::ManagedMemoryPolicy& policy) { | 126 void SurfacesImpl::SetMemoryPolicy(const cc::ManagedMemoryPolicy& policy) { |
118 } | 127 } |
119 | 128 |
120 } // namespace mojo | 129 } // namespace mojo |
OLD | NEW |