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