OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/mus/ws/server_window_surface.h" | 5 #include "components/mus/ws/server_window_surface.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "cc/output/compositor_frame.h" | 8 #include "cc/output/compositor_frame.h" |
9 #include "cc/quads/shared_quad_state.h" | 9 #include "cc/quads/shared_quad_state.h" |
10 #include "cc/quads/surface_draw_quad.h" | 10 #include "cc/quads/surface_draw_quad.h" |
11 #include "components/mus/public/cpp/surfaces/surfaces_type_converters.h" | |
12 #include "components/mus/surfaces/surfaces_state.h" | 11 #include "components/mus/surfaces/surfaces_state.h" |
13 #include "components/mus/ws/server_window.h" | 12 #include "components/mus/ws/server_window.h" |
14 #include "components/mus/ws/server_window_delegate.h" | 13 #include "components/mus/ws/server_window_delegate.h" |
15 #include "components/mus/ws/server_window_surface_manager.h" | 14 #include "components/mus/ws/server_window_surface_manager.h" |
16 | 15 |
17 namespace mus { | 16 namespace mus { |
18 namespace ws { | 17 namespace ws { |
19 namespace { | 18 namespace { |
20 | 19 |
21 void CallCallback(const base::Closure& callback, cc::SurfaceDrawStatus status) { | 20 void CallCallback(const base::Closure& callback, cc::SurfaceDrawStatus status) { |
(...skipping 21 matching lines...) Expand all Loading... |
43 // |surface_factory_|'s resources early on. | 42 // |surface_factory_|'s resources early on. |
44 surface_factory_.DestroyAll(); | 43 surface_factory_.DestroyAll(); |
45 | 44 |
46 if (registered_surface_factory_client_) { | 45 if (registered_surface_factory_client_) { |
47 cc::SurfaceManager* surface_manager = manager_->GetSurfaceManager(); | 46 cc::SurfaceManager* surface_manager = manager_->GetSurfaceManager(); |
48 surface_manager->UnregisterSurfaceFactoryClient(manager_->id_namespace()); | 47 surface_manager->UnregisterSurfaceFactoryClient(manager_->id_namespace()); |
49 } | 48 } |
50 } | 49 } |
51 | 50 |
52 void ServerWindowSurface::SubmitCompositorFrame( | 51 void ServerWindowSurface::SubmitCompositorFrame( |
53 cc::mojom::CompositorFramePtr frame, | 52 cc::CompositorFrame frame, |
54 const SubmitCompositorFrameCallback& callback) { | 53 const SubmitCompositorFrameCallback& callback) { |
55 gfx::Size frame_size = frame->passes[0]->output_rect.size(); | 54 gfx::Size frame_size = |
| 55 frame.delegated_frame_data->render_pass_list[0]->output_rect.size(); |
56 if (!surface_id_.is_null()) { | 56 if (!surface_id_.is_null()) { |
57 // If the size of the CompostiorFrame has changed then destroy the existing | 57 // If the size of the CompostiorFrame has changed then destroy the existing |
58 // Surface and create a new one of the appropriate size. | 58 // Surface and create a new one of the appropriate size. |
59 if (frame_size != last_submitted_frame_size_) { | 59 if (frame_size != last_submitted_frame_size_) { |
60 // Rendering of the topmost frame happens in two phases. First the frame | 60 // Rendering of the topmost frame happens in two phases. First the frame |
61 // is generated and submitted, and a later date it is actually drawn. | 61 // is generated and submitted, and a later date it is actually drawn. |
62 // During the time the frame is generated and drawn we can't destroy the | 62 // During the time the frame is generated and drawn we can't destroy the |
63 // surface, otherwise when drawn you get an empty surface. To deal with | 63 // surface, otherwise when drawn you get an empty surface. To deal with |
64 // this we schedule destruction via the delegate. The delegate will call | 64 // this we schedule destruction via the delegate. The delegate will call |
65 // us back when we're not waiting on a frame to be drawn (which may be | 65 // us back when we're not waiting on a frame to be drawn (which may be |
66 // synchronously). | 66 // synchronously). |
67 surfaces_scheduled_for_destruction_.insert(surface_id_); | 67 surfaces_scheduled_for_destruction_.insert(surface_id_); |
68 window()->delegate()->ScheduleSurfaceDestruction(window()); | 68 window()->delegate()->ScheduleSurfaceDestruction(window()); |
69 surface_id_ = manager_->GenerateId(); | 69 surface_id_ = manager_->GenerateId(); |
70 surface_factory_.Create(surface_id_); | 70 surface_factory_.Create(surface_id_); |
71 } | 71 } |
72 } | 72 } |
73 surface_factory_.SubmitCompositorFrame(surface_id_, | 73 std::unique_ptr<cc::CompositorFrame> frame_copy(new cc::CompositorFrame); |
74 ConvertToCompositorFrame(frame), | 74 *frame_copy = std::move(frame); |
| 75 surface_factory_.SubmitCompositorFrame(surface_id_, std::move(frame_copy), |
75 base::Bind(&CallCallback, callback)); | 76 base::Bind(&CallCallback, callback)); |
76 last_submitted_frame_size_ = frame_size; | 77 last_submitted_frame_size_ = frame_size; |
77 window()->delegate()->OnScheduleWindowPaint(window()); | 78 window()->delegate()->OnScheduleWindowPaint(window()); |
78 } | 79 } |
79 | 80 |
80 void ServerWindowSurface::DestroySurfacesScheduledForDestruction() { | 81 void ServerWindowSurface::DestroySurfacesScheduledForDestruction() { |
81 std::set<cc::SurfaceId> surfaces; | 82 std::set<cc::SurfaceId> surfaces; |
82 surfaces.swap(surfaces_scheduled_for_destruction_); | 83 surfaces.swap(surfaces_scheduled_for_destruction_); |
83 for (auto& id : surfaces) | 84 for (auto& id : surfaces) |
84 surface_factory_.Destroy(id); | 85 surface_factory_.Destroy(id); |
(...skipping 17 matching lines...) Expand all Loading... |
102 client_->ReturnResources(mojo::Array<cc::ReturnedResource>::From(resources)); | 103 client_->ReturnResources(mojo::Array<cc::ReturnedResource>::From(resources)); |
103 } | 104 } |
104 | 105 |
105 void ServerWindowSurface::SetBeginFrameSource( | 106 void ServerWindowSurface::SetBeginFrameSource( |
106 cc::BeginFrameSource* begin_frame_source) { | 107 cc::BeginFrameSource* begin_frame_source) { |
107 // TODO(tansell): Implement this. | 108 // TODO(tansell): Implement this. |
108 } | 109 } |
109 | 110 |
110 } // namespace ws | 111 } // namespace ws |
111 } // namespace mus | 112 } // namespace mus |
OLD | NEW |