| 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 #ifndef COMPONENTS_VIEW_MANAGER_SURFACES_DISPLAY_IMPL_H_ | 5 #ifndef COMPONENTS_VIEW_MANAGER_SURFACES_DISPLAY_IMPL_H_ |
| 6 #define COMPONENTS_VIEW_MANAGER_SURFACES_DISPLAY_IMPL_H_ | 6 #define COMPONENTS_VIEW_MANAGER_SURFACES_DISPLAY_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "cc/surfaces/display_client.h" | 9 #include "cc/surfaces/display_client.h" |
| 10 #include "cc/surfaces/surface_factory.h" | 10 #include "cc/surfaces/surface_factory.h" |
| 11 #include "cc/surfaces/surface_factory_client.h" | 11 #include "cc/surfaces/surface_factory_client.h" |
| 12 #include "components/view_manager/public/interfaces/display.mojom.h" | 12 #include "components/view_manager/public/interfaces/surfaces.mojom.h" |
| 13 #include "components/view_manager/surfaces/surfaces_context_provider.h" |
| 13 #include "components/view_manager/surfaces/surfaces_state.h" | 14 #include "components/view_manager/surfaces/surfaces_state.h" |
| 14 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" | 15 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" |
| 16 #include "ui/gfx/native_widget_types.h" |
| 15 | 17 |
| 16 namespace cc { | 18 namespace cc { |
| 17 class Display; | 19 class Display; |
| 18 class SurfaceFactory; | 20 class SurfaceFactory; |
| 19 } | 21 } |
| 20 | 22 |
| 23 namespace gles2 { |
| 24 class GpuState; |
| 25 } |
| 26 |
| 21 namespace surfaces { | 27 namespace surfaces { |
| 22 | 28 |
| 23 class DisplayDelegate; | 29 class DisplayDelegate; |
| 30 class SurfacesScheduler; |
| 31 class SurfacesState; |
| 24 | 32 |
| 25 class DisplayImpl : public mojo::Display, | 33 // A TopLevelDisplayClient manages the top level surface that is rendered into a |
| 26 public mojo::ViewportParameterListener, | 34 // provided AcceleratedWidget. Frames are submitted here. New frames are |
| 27 public cc::DisplayClient, | 35 // scheduled to be generated here based on VSync. |
| 28 public cc::SurfaceFactoryClient { | 36 class TopLevelDisplayClient |
| 37 : public cc::DisplayClient, |
| 38 public cc::SurfaceFactoryClient, |
| 39 public surfaces::SurfacesContextProvider::Delegate { |
| 29 public: | 40 public: |
| 30 DisplayImpl(DisplayDelegate* display_delegate, | 41 TopLevelDisplayClient(gfx::AcceleratedWidget widget, |
| 31 const scoped_refptr<SurfacesState>& surfaces_state, | 42 const scoped_refptr<gles2::GpuState>& gpu_state, |
| 32 cc::SurfaceId cc_id, | 43 const scoped_refptr<SurfacesState>& surfaces_state); |
| 33 mojo::ContextProviderPtr context_provider, | 44 ~TopLevelDisplayClient() override; |
| 34 mojo::ResourceReturnerPtr returner, | |
| 35 mojo::InterfaceRequest<mojo::Display> display_request); | |
| 36 | 45 |
| 37 // Closes the connection and destroys |this| object. | 46 void SubmitFrame(mojo::FramePtr frame, const base::Closure& callback); |
| 38 void CloseConnection(); | |
| 39 | 47 |
| 40 private: | 48 private: |
| 41 ~DisplayImpl() override; | |
| 42 | |
| 43 void OnContextCreated(mojo::CommandBufferPtr gles2_client); | |
| 44 | |
| 45 // mojo::Display implementation: | |
| 46 void SubmitFrame(mojo::FramePtr frame, | |
| 47 const SubmitFrameCallback& callback) override; | |
| 48 | |
| 49 // DisplayClient implementation. | 49 // DisplayClient implementation. |
| 50 // TODO(rjkroege, fsamuel): This won't work correctly with multiple displays. | 50 // TODO(rjkroege, fsamuel): This won't work correctly with multiple displays. |
| 51 void CommitVSyncParameters(base::TimeTicks timebase, | 51 void CommitVSyncParameters(base::TimeTicks timebase, |
| 52 base::TimeDelta interval) override; | 52 base::TimeDelta interval) override; |
| 53 void OutputSurfaceLost() override; | 53 void OutputSurfaceLost() override; |
| 54 void SetMemoryPolicy(const cc::ManagedMemoryPolicy& policy) override; | 54 void SetMemoryPolicy(const cc::ManagedMemoryPolicy& policy) override; |
| 55 | 55 |
| 56 // ViewportParameterListener | 56 // SurfacesContextProvider::Delegate: |
| 57 void OnContextCreated(); |
| 57 void OnVSyncParametersUpdated(int64_t timebase, int64_t interval) override; | 58 void OnVSyncParametersUpdated(int64_t timebase, int64_t interval) override; |
| 58 | 59 |
| 59 // SurfaceFactoryClient implementation. | 60 // SurfaceFactoryClient implementation. |
| 60 void ReturnResources(const cc::ReturnedResourceArray& resources) override; | 61 void ReturnResources(const cc::ReturnedResourceArray& resources) override; |
| 61 | 62 |
| 62 void Draw(); | 63 void Draw(); |
| 63 | 64 |
| 64 DisplayDelegate* delegate_; | 65 scoped_refptr<gles2::GpuState> gpu_state_; |
| 65 scoped_refptr<SurfacesState> surfaces_state_; | 66 scoped_refptr<SurfacesState> surfaces_state_; |
| 66 cc::SurfaceFactory factory_; | 67 cc::SurfaceFactory factory_; |
| 67 cc::SurfaceId cc_id_; | 68 cc::SurfaceId cc_id_; |
| 68 mojo::ContextProviderPtr context_provider_; | |
| 69 mojo::ResourceReturnerPtr returner_; | |
| 70 | 69 |
| 71 gfx::Size last_submitted_frame_size_; | 70 gfx::Size last_submitted_frame_size_; |
| 72 mojo::FramePtr pending_frame_; | 71 mojo::FramePtr pending_frame_; |
| 73 SubmitFrameCallback pending_callback_; | 72 base::Closure pending_callback_; |
| 74 | 73 |
| 75 scoped_ptr<cc::Display> display_; | 74 scoped_ptr<cc::Display> display_; |
| 76 | 75 |
| 77 mojo::Binding<mojo::ViewportParameterListener> viewport_param_binding_; | 76 DISALLOW_COPY_AND_ASSIGN(TopLevelDisplayClient); |
| 78 mojo::Binding<mojo::Display> display_binding_; | |
| 79 bool connection_closed_; | |
| 80 | |
| 81 DISALLOW_COPY_AND_ASSIGN(DisplayImpl); | |
| 82 }; | 77 }; |
| 83 | 78 |
| 84 } // namespace surfaces | 79 } // namespace surfaces |
| 85 | 80 |
| 86 #endif // COMPONENTS_VIEW_MANAGER_SURFACES_DISPLAY_IMPL_H_ | 81 #endif // COMPONENTS_VIEW_MANAGER_SURFACES_DISPLAY_IMPL_H_ |
| OLD | NEW |