| 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 "cc/output/compositor_frame.h" | 7 #include "cc/output/compositor_frame.h" |
| 8 #include "cc/quads/shared_quad_state.h" | 8 #include "cc/quads/shared_quad_state.h" |
| 9 #include "cc/quads/surface_draw_quad.h" | 9 #include "cc/quads/surface_draw_quad.h" |
| 10 #include "components/mus/public/cpp/surfaces/surfaces_type_converters.h" | 10 #include "components/mus/public/cpp/surfaces/surfaces_type_converters.h" |
| 11 #include "components/mus/surfaces/surfaces_state.h" | 11 #include "components/mus/surfaces/surfaces_state.h" |
| 12 #include "components/mus/ws/server_window.h" | 12 #include "components/mus/ws/server_window.h" |
| 13 #include "components/mus/ws/server_window_delegate.h" | 13 #include "components/mus/ws/server_window_delegate.h" |
| 14 #include "components/mus/ws/server_window_surface_manager.h" | 14 #include "components/mus/ws/server_window_surface_manager.h" |
| 15 #include "ui/gfx/geometry/mojo/geometry_type_converters.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 mojo::Closure& callback, cc::SurfaceDrawStatus status) { | 20 void CallCallback(const mojo::Closure& callback, cc::SurfaceDrawStatus status) { |
| 22 callback.Run(); | 21 callback.Run(); |
| 23 } | 22 } |
| 24 | 23 |
| 25 } // namespace | 24 } // namespace |
| (...skipping 19 matching lines...) Expand all Loading... |
| 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 mojom::CompositorFramePtr frame, | 52 mojom::CompositorFramePtr frame, |
| 54 const SubmitCompositorFrameCallback& callback) { | 53 const SubmitCompositorFrameCallback& callback) { |
| 55 gfx::Size frame_size = frame->passes[0]->output_rect.To<gfx::Rect>().size(); | 54 gfx::Size frame_size = frame->passes[0]->output_rect.size(); |
| 56 if (!surface_id_.is_null()) { | 55 if (!surface_id_.is_null()) { |
| 57 // If the size of the CompostiorFrame has changed then destroy the existing | 56 // If the size of the CompostiorFrame has changed then destroy the existing |
| 58 // Surface and create a new one of the appropriate size. | 57 // Surface and create a new one of the appropriate size. |
| 59 if (frame_size != last_submitted_frame_size_) { | 58 if (frame_size != last_submitted_frame_size_) { |
| 60 // Rendering of the topmost frame happens in two phases. First the frame | 59 // 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. | 60 // 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 | 61 // 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 | 62 // surface, otherwise when drawn you get an empty surface. To deal with |
| 64 // this we schedule destruction via the delegate. The delegate will call | 63 // 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 | 64 // us back when we're not waiting on a frame to be drawn (which may be |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 other_window->GetOrCreateSurfaceManager()->GetDefaultSurface(); | 128 other_window->GetOrCreateSurfaceManager()->GetDefaultSurface(); |
| 130 ServerWindowSurface* underlay_surface = | 129 ServerWindowSurface* underlay_surface = |
| 131 other_window->GetOrCreateSurfaceManager()->GetUnderlaySurface(); | 130 other_window->GetOrCreateSurfaceManager()->GetUnderlaySurface(); |
| 132 | 131 |
| 133 if (!default_surface && !underlay_surface) | 132 if (!default_surface && !underlay_surface) |
| 134 return true; | 133 return true; |
| 135 | 134 |
| 136 cc::SurfaceDrawQuad* surface_quad = | 135 cc::SurfaceDrawQuad* surface_quad = |
| 137 render_pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); | 136 render_pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); |
| 138 if (default_surface) { | 137 if (default_surface) { |
| 139 surface_quad->SetAll(sqs, input->rect.To<gfx::Rect>(), | 138 surface_quad->SetAll(sqs, input->rect, input->opaque_rect, |
| 140 input->opaque_rect.To<gfx::Rect>(), | 139 input->visible_rect, input->needs_blending, |
| 141 input->visible_rect.To<gfx::Rect>(), | 140 default_surface->id()); |
| 142 input->needs_blending, default_surface->id()); | |
| 143 } | 141 } |
| 144 if (underlay_surface) { | 142 if (underlay_surface) { |
| 145 cc::SurfaceDrawQuad* underlay_quad = | 143 cc::SurfaceDrawQuad* underlay_quad = |
| 146 render_pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); | 144 render_pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); |
| 147 underlay_quad->SetAll(sqs, input->rect.To<gfx::Rect>(), | 145 underlay_quad->SetAll(sqs, input->rect, input->opaque_rect, |
| 148 input->opaque_rect.To<gfx::Rect>(), | 146 input->visible_rect, input->needs_blending, |
| 149 input->visible_rect.To<gfx::Rect>(), | 147 underlay_surface->id()); |
| 150 input->needs_blending, underlay_surface->id()); | |
| 151 } | 148 } |
| 152 return true; | 149 return true; |
| 153 } | 150 } |
| 154 | 151 |
| 155 void ServerWindowSurface::ReturnResources( | 152 void ServerWindowSurface::ReturnResources( |
| 156 const cc::ReturnedResourceArray& resources) { | 153 const cc::ReturnedResourceArray& resources) { |
| 157 if (!client_ || !base::MessageLoop::current()) | 154 if (!client_ || !base::MessageLoop::current()) |
| 158 return; | 155 return; |
| 159 client_->ReturnResources( | 156 client_->ReturnResources( |
| 160 mojo::Array<mojom::ReturnedResourcePtr>::From(resources)); | 157 mojo::Array<mojom::ReturnedResourcePtr>::From(resources)); |
| 161 } | 158 } |
| 162 | 159 |
| 163 void ServerWindowSurface::SetBeginFrameSource( | 160 void ServerWindowSurface::SetBeginFrameSource( |
| 164 cc::BeginFrameSource* begin_frame_source) { | 161 cc::BeginFrameSource* begin_frame_source) { |
| 165 // TODO(tansell): Implement this. | 162 // TODO(tansell): Implement this. |
| 166 } | 163 } |
| 167 | 164 |
| 168 } // namespace ws | 165 } // namespace ws |
| 169 } // namespace mus | 166 } // namespace mus |
| OLD | NEW |