| 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 #ifndef CC_SURFACES_DISPLAY_H_ | 5 #ifndef CC_SURFACES_DISPLAY_H_ |
| 6 #define CC_SURFACES_DISPLAY_H_ | 6 #define CC_SURFACES_DISPLAY_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "cc/output/output_surface_client.h" | 12 #include "cc/output/output_surface_client.h" |
| 13 #include "cc/output/renderer.h" | 13 #include "cc/output/renderer.h" |
| 14 #include "cc/output/texture_mailbox_deleter.h" |
| 14 #include "cc/resources/returned_resource.h" | 15 #include "cc/resources/returned_resource.h" |
| 15 #include "cc/scheduler/begin_frame_source.h" | 16 #include "cc/scheduler/begin_frame_source.h" |
| 16 #include "cc/surfaces/display_scheduler.h" | 17 #include "cc/surfaces/display_scheduler.h" |
| 17 #include "cc/surfaces/surface_aggregator.h" | 18 #include "cc/surfaces/surface_aggregator.h" |
| 18 #include "cc/surfaces/surface_id.h" | 19 #include "cc/surfaces/surface_id.h" |
| 19 #include "cc/surfaces/surface_manager.h" | 20 #include "cc/surfaces/surface_manager.h" |
| 20 #include "cc/surfaces/surfaces_export.h" | 21 #include "cc/surfaces/surfaces_export.h" |
| 21 #include "ui/events/latency_info.h" | 22 #include "ui/events/latency_info.h" |
| 22 | 23 |
| 23 namespace gpu { | 24 namespace gpu { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 44 class TextureMailboxDeleter; | 45 class TextureMailboxDeleter; |
| 45 | 46 |
| 46 // A Display produces a surface that can be used to draw to a physical display | 47 // A Display produces a surface that can be used to draw to a physical display |
| 47 // (OutputSurface). The client is responsible for creating and sizing the | 48 // (OutputSurface). The client is responsible for creating and sizing the |
| 48 // surface IDs used to draw into the display and deciding when to draw. | 49 // surface IDs used to draw into the display and deciding when to draw. |
| 49 class CC_SURFACES_EXPORT Display : public DisplaySchedulerClient, | 50 class CC_SURFACES_EXPORT Display : public DisplaySchedulerClient, |
| 50 public OutputSurfaceClient, | 51 public OutputSurfaceClient, |
| 51 public RendererClient, | 52 public RendererClient, |
| 52 public SurfaceDamageObserver { | 53 public SurfaceDamageObserver { |
| 53 public: | 54 public: |
| 54 Display(DisplayClient* client, | 55 Display(SurfaceManager* manager, |
| 55 SurfaceManager* manager, | |
| 56 SharedBitmapManager* bitmap_manager, | 56 SharedBitmapManager* bitmap_manager, |
| 57 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 57 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 58 const RendererSettings& settings, | 58 const RendererSettings& settings, |
| 59 uint32_t compositor_surface_namespace); | 59 uint32_t compositor_surface_namespace, |
| 60 base::SingleThreadTaskRunner* task_runner, |
| 61 std::unique_ptr<OutputSurface> output_surface); |
| 60 ~Display() override; | 62 ~Display() override; |
| 61 | 63 |
| 62 bool Initialize(std::unique_ptr<OutputSurface> output_surface, | 64 bool Initialize(DisplayClient* client); |
| 63 base::SingleThreadTaskRunner* task_runner); | 65 |
| 64 // When this variant is used, no DisplayScheduler is created, and the caller | 66 // When this variant is used, no DisplayScheduler is created, and the caller |
| 65 // is responsible for calling DrawAndSwap when required. | 67 // is responsible for calling DrawAndSwap when required. |
| 66 bool InitializeSynchronous(std::unique_ptr<OutputSurface> output_surface, | 68 bool InitializeSynchronous(DisplayClient* client); |
| 67 base::SingleThreadTaskRunner* task_runner); | |
| 68 | 69 |
| 69 // device_scale_factor is used to communicate to the external window system | 70 // device_scale_factor is used to communicate to the external window system |
| 70 // what scale this was rendered at. | 71 // what scale this was rendered at. |
| 71 void SetSurfaceId(SurfaceId id, float device_scale_factor); | 72 void SetSurfaceId(SurfaceId id, float device_scale_factor); |
| 72 void Resize(const gfx::Size& new_size); | 73 void Resize(const gfx::Size& new_size); |
| 73 void SetExternalClip(const gfx::Rect& clip); | 74 void SetExternalClip(const gfx::Rect& clip); |
| 74 void SetOutputIsSecure(bool secure); | 75 void SetOutputIsSecure(bool secure); |
| 75 | 76 |
| 76 SurfaceId CurrentSurfaceId(); | 77 SurfaceId CurrentSurfaceId(); |
| 77 | 78 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 103 // SurfaceDamageObserver implementation. | 104 // SurfaceDamageObserver implementation. |
| 104 void OnSurfaceDamaged(SurfaceId surface, bool* changed) override; | 105 void OnSurfaceDamaged(SurfaceId surface, bool* changed) override; |
| 105 | 106 |
| 106 void SetEnlargePassTextureAmountForTesting( | 107 void SetEnlargePassTextureAmountForTesting( |
| 107 const gfx::Size& enlarge_texture_amount) { | 108 const gfx::Size& enlarge_texture_amount) { |
| 108 enlarge_texture_amount_ = enlarge_texture_amount; | 109 enlarge_texture_amount_ = enlarge_texture_amount; |
| 109 } | 110 } |
| 110 | 111 |
| 111 protected: | 112 protected: |
| 112 // Virtual for tests. | 113 // Virtual for tests. |
| 113 virtual void CreateScheduler(base::SingleThreadTaskRunner* task_runner); | 114 virtual void CreateScheduler(); |
| 114 | 115 |
| 115 void InitializeRenderer(); | 116 void InitializeRenderer(); |
| 116 void UpdateRootSurfaceResourcesLocked(); | 117 void UpdateRootSurfaceResourcesLocked(); |
| 117 | 118 |
| 118 DisplayClient* client_; | 119 DisplayClient* client_; |
| 119 SurfaceManager* surface_manager_; | 120 SurfaceManager* surface_manager_; |
| 120 SharedBitmapManager* bitmap_manager_; | 121 SharedBitmapManager* bitmap_manager_; |
| 121 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; | 122 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; |
| 122 RendererSettings settings_; | 123 RendererSettings settings_; |
| 123 SurfaceId current_surface_id_; | 124 SurfaceId current_surface_id_; |
| 124 uint32_t compositor_surface_namespace_; | 125 uint32_t compositor_surface_namespace_; |
| 125 gfx::Size current_surface_size_; | 126 gfx::Size current_surface_size_; |
| 126 float device_scale_factor_; | 127 float device_scale_factor_ = 1.f; |
| 127 bool swapped_since_resize_; | 128 bool swapped_since_resize_ = false; |
| 128 gfx::Rect external_clip_; | 129 gfx::Rect external_clip_; |
| 129 gfx::Size enlarge_texture_amount_; | 130 gfx::Size enlarge_texture_amount_; |
| 130 bool output_is_secure_ = false; | 131 bool output_is_secure_ = false; |
| 131 | 132 |
| 133 // TODO(danakj): Not needed if we create the scheduler from the constructor. |
| 134 base::SingleThreadTaskRunner* task_runner_; |
| 135 |
| 132 std::unique_ptr<OutputSurface> output_surface_; | 136 std::unique_ptr<OutputSurface> output_surface_; |
| 133 // An internal synthetic BFS. May be null when not used. | 137 // An internal synthetic BFS. May be null when not used. |
| 134 std::unique_ptr<BeginFrameSource> internal_begin_frame_source_; | 138 std::unique_ptr<BeginFrameSource> internal_begin_frame_source_; |
| 135 // The real BFS tied to vsync provided by the BrowserCompositorOutputSurface. | 139 // The real BFS tied to vsync provided by the BrowserCompositorOutputSurface. |
| 136 BeginFrameSource* vsync_begin_frame_source_; | 140 BeginFrameSource* vsync_begin_frame_source_ = nullptr; |
| 137 // The current BFS driving the Display/DisplayScheduler. | 141 // The current BFS driving the Display/DisplayScheduler. |
| 138 BeginFrameSource* observed_begin_frame_source_; | 142 BeginFrameSource* observed_begin_frame_source_ = nullptr; |
| 139 std::unique_ptr<DisplayScheduler> scheduler_; | 143 std::unique_ptr<DisplayScheduler> scheduler_; |
| 140 std::unique_ptr<ResourceProvider> resource_provider_; | 144 std::unique_ptr<ResourceProvider> resource_provider_; |
| 141 std::unique_ptr<SurfaceAggregator> aggregator_; | 145 std::unique_ptr<SurfaceAggregator> aggregator_; |
| 146 TextureMailboxDeleter texture_mailbox_deleter_; |
| 142 std::unique_ptr<DirectRenderer> renderer_; | 147 std::unique_ptr<DirectRenderer> renderer_; |
| 143 std::unique_ptr<TextureMailboxDeleter> texture_mailbox_deleter_; | |
| 144 std::vector<ui::LatencyInfo> stored_latency_info_; | 148 std::vector<ui::LatencyInfo> stored_latency_info_; |
| 145 | 149 |
| 146 private: | 150 private: |
| 147 DISALLOW_COPY_AND_ASSIGN(Display); | 151 DISALLOW_COPY_AND_ASSIGN(Display); |
| 148 }; | 152 }; |
| 149 | 153 |
| 150 } // namespace cc | 154 } // namespace cc |
| 151 | 155 |
| 152 #endif // CC_SURFACES_DISPLAY_H_ | 156 #endif // CC_SURFACES_DISPLAY_H_ |
| OLD | NEW |