| 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" | |
| 15 #include "cc/resources/returned_resource.h" | 14 #include "cc/resources/returned_resource.h" |
| 16 #include "cc/scheduler/begin_frame_source.h" | 15 #include "cc/scheduler/begin_frame_source.h" |
| 17 #include "cc/surfaces/display_scheduler.h" | 16 #include "cc/surfaces/display_scheduler.h" |
| 18 #include "cc/surfaces/surface_aggregator.h" | 17 #include "cc/surfaces/surface_aggregator.h" |
| 19 #include "cc/surfaces/surface_id.h" | 18 #include "cc/surfaces/surface_id.h" |
| 20 #include "cc/surfaces/surface_manager.h" | 19 #include "cc/surfaces/surface_manager.h" |
| 21 #include "cc/surfaces/surfaces_export.h" | 20 #include "cc/surfaces/surfaces_export.h" |
| 22 #include "ui/events/latency_info.h" | 21 #include "ui/events/latency_info.h" |
| 23 | 22 |
| 24 namespace gpu { | 23 namespace gpu { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 45 class TextureMailboxDeleter; | 44 class TextureMailboxDeleter; |
| 46 | 45 |
| 47 // A Display produces a surface that can be used to draw to a physical display | 46 // A Display produces a surface that can be used to draw to a physical display |
| 48 // (OutputSurface). The client is responsible for creating and sizing the | 47 // (OutputSurface). The client is responsible for creating and sizing the |
| 49 // surface IDs used to draw into the display and deciding when to draw. | 48 // surface IDs used to draw into the display and deciding when to draw. |
| 50 class CC_SURFACES_EXPORT Display : public DisplaySchedulerClient, | 49 class CC_SURFACES_EXPORT Display : public DisplaySchedulerClient, |
| 51 public OutputSurfaceClient, | 50 public OutputSurfaceClient, |
| 52 public RendererClient, | 51 public RendererClient, |
| 53 public SurfaceDamageObserver { | 52 public SurfaceDamageObserver { |
| 54 public: | 53 public: |
| 54 // The |begin_frame_source| and |scheduler| may be null (together). In that |
| 55 // case, DrawAndSwap must be called externally when needed. |
| 55 Display(SurfaceManager* manager, | 56 Display(SurfaceManager* manager, |
| 56 SharedBitmapManager* bitmap_manager, | 57 SharedBitmapManager* bitmap_manager, |
| 57 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 58 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 58 const RendererSettings& settings, | 59 const RendererSettings& settings, |
| 59 uint32_t compositor_surface_namespace, | 60 uint32_t compositor_surface_namespace, |
| 60 base::SingleThreadTaskRunner* task_runner, | 61 std::unique_ptr<BeginFrameSource> begin_frame_source, |
| 61 std::unique_ptr<OutputSurface> output_surface); | 62 std::unique_ptr<OutputSurface> output_surface, |
| 63 std::unique_ptr<DisplayScheduler> scheduler, |
| 64 std::unique_ptr<TextureMailboxDeleter> texture_mailbox_deleter); |
| 65 |
| 62 ~Display() override; | 66 ~Display() override; |
| 63 | 67 |
| 64 bool Initialize(DisplayClient* client); | 68 bool Initialize(DisplayClient* client); |
| 65 | 69 |
| 66 // When this variant is used, no DisplayScheduler is created, and the caller | |
| 67 // is responsible for calling DrawAndSwap when required. | |
| 68 bool InitializeSynchronous(DisplayClient* client); | |
| 69 | |
| 70 // 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 |
| 71 // what scale this was rendered at. | 71 // what scale this was rendered at. |
| 72 void SetSurfaceId(SurfaceId id, float device_scale_factor); | 72 void SetSurfaceId(SurfaceId id, float device_scale_factor); |
| 73 void Resize(const gfx::Size& new_size); | 73 void Resize(const gfx::Size& new_size); |
| 74 void SetExternalClip(const gfx::Rect& clip); | 74 void SetExternalClip(const gfx::Rect& clip); |
| 75 void SetOutputIsSecure(bool secure); | 75 void SetOutputIsSecure(bool secure); |
| 76 | 76 |
| 77 SurfaceId CurrentSurfaceId(); | 77 SurfaceId CurrentSurfaceId(); |
| 78 | 78 |
| 79 // DisplaySchedulerClient implementation. | 79 // DisplaySchedulerClient implementation. |
| 80 bool DrawAndSwap() override; | 80 bool DrawAndSwap() override; |
| 81 | 81 |
| 82 // OutputSurfaceClient implementation. | 82 // OutputSurfaceClient implementation. |
| 83 void CommitVSyncParameters(base::TimeTicks timebase, | 83 void CommitVSyncParameters(base::TimeTicks timebase, |
| 84 base::TimeDelta interval) override {} | 84 base::TimeDelta interval) override; |
| 85 void SetBeginFrameSource(BeginFrameSource* source) override; | 85 void SetBeginFrameSource(BeginFrameSource* source) override; |
| 86 void SetNeedsRedrawRect(const gfx::Rect& damage_rect) override; | 86 void SetNeedsRedrawRect(const gfx::Rect& damage_rect) override; |
| 87 void DidSwapBuffers() override; | 87 void DidSwapBuffers() override; |
| 88 void DidSwapBuffersComplete() override; | 88 void DidSwapBuffersComplete() override; |
| 89 void ReclaimResources(const CompositorFrameAck* ack) override; | 89 void ReclaimResources(const CompositorFrameAck* ack) override; |
| 90 void DidLoseOutputSurface() override; | 90 void DidLoseOutputSurface() override; |
| 91 void SetExternalTilePriorityConstraints( | 91 void SetExternalTilePriorityConstraints( |
| 92 const gfx::Rect& viewport_rect, | 92 const gfx::Rect& viewport_rect, |
| 93 const gfx::Transform& transform) override; | 93 const gfx::Transform& transform) override; |
| 94 void SetMemoryPolicy(const ManagedMemoryPolicy& policy) override; | 94 void SetMemoryPolicy(const ManagedMemoryPolicy& policy) override; |
| 95 void SetTreeActivationCallback(const base::Closure& callback) override; | 95 void SetTreeActivationCallback(const base::Closure& callback) override; |
| 96 void OnDraw(const gfx::Transform& transform, | 96 void OnDraw(const gfx::Transform& transform, |
| 97 const gfx::Rect& viewport, | 97 const gfx::Rect& viewport, |
| 98 const gfx::Rect& clip, | 98 const gfx::Rect& clip, |
| 99 bool resourceless_software_draw) override; | 99 bool resourceless_software_draw) override; |
| 100 | 100 |
| 101 // RendererClient implementation. | 101 // RendererClient implementation. |
| 102 void SetFullRootLayerDamage() override; | 102 void SetFullRootLayerDamage() override; |
| 103 | 103 |
| 104 // SurfaceDamageObserver implementation. | 104 // SurfaceDamageObserver implementation. |
| 105 void OnSurfaceDamaged(SurfaceId surface, bool* changed) override; | 105 void OnSurfaceDamaged(SurfaceId surface, bool* changed) override; |
| 106 | 106 |
| 107 void SetEnlargePassTextureAmountForTesting( | 107 void SetEnlargePassTextureAmountForTesting( |
| 108 const gfx::Size& enlarge_texture_amount) { | 108 const gfx::Size& enlarge_texture_amount) { |
| 109 enlarge_texture_amount_ = enlarge_texture_amount; | 109 enlarge_texture_amount_ = enlarge_texture_amount; |
| 110 } | 110 } |
| 111 | 111 |
| 112 protected: | 112 private: |
| 113 // Virtual for tests. | |
| 114 virtual void CreateScheduler(); | |
| 115 | |
| 116 void InitializeRenderer(); | 113 void InitializeRenderer(); |
| 117 void UpdateRootSurfaceResourcesLocked(); | 114 void UpdateRootSurfaceResourcesLocked(); |
| 118 | 115 |
| 119 DisplayClient* client_; | 116 DisplayClient* client_; |
| 120 SurfaceManager* surface_manager_; | 117 SurfaceManager* surface_manager_; |
| 121 SharedBitmapManager* bitmap_manager_; | 118 SharedBitmapManager* bitmap_manager_; |
| 122 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; | 119 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; |
| 123 RendererSettings settings_; | 120 RendererSettings settings_; |
| 124 SurfaceId current_surface_id_; | 121 SurfaceId current_surface_id_; |
| 125 uint32_t compositor_surface_namespace_; | 122 uint32_t compositor_surface_namespace_; |
| 126 gfx::Size current_surface_size_; | 123 gfx::Size current_surface_size_; |
| 127 float device_scale_factor_ = 1.f; | 124 float device_scale_factor_ = 1.f; |
| 128 bool swapped_since_resize_ = false; | 125 bool swapped_since_resize_ = false; |
| 129 gfx::Rect external_clip_; | 126 gfx::Rect external_clip_; |
| 130 gfx::Size enlarge_texture_amount_; | 127 gfx::Size enlarge_texture_amount_; |
| 131 bool output_is_secure_ = false; | 128 bool output_is_secure_ = false; |
| 132 | 129 |
| 133 // TODO(danakj): Not needed if we create the scheduler from the constructor. | 130 // The begin_frame_source_ is often known by the output_surface_ and |
| 134 base::SingleThreadTaskRunner* task_runner_; | 131 // the scheduler_. |
| 135 | 132 std::unique_ptr<BeginFrameSource> begin_frame_source_; |
| 136 std::unique_ptr<OutputSurface> output_surface_; | 133 std::unique_ptr<OutputSurface> output_surface_; |
| 137 // An internal synthetic BFS. May be null when not used. | |
| 138 std::unique_ptr<BeginFrameSource> internal_begin_frame_source_; | |
| 139 // The real BFS tied to vsync provided by the BrowserCompositorOutputSurface. | |
| 140 BeginFrameSource* vsync_begin_frame_source_ = nullptr; | |
| 141 // The current BFS driving the Display/DisplayScheduler. | |
| 142 BeginFrameSource* observed_begin_frame_source_ = nullptr; | |
| 143 std::unique_ptr<DisplayScheduler> scheduler_; | 134 std::unique_ptr<DisplayScheduler> scheduler_; |
| 144 std::unique_ptr<ResourceProvider> resource_provider_; | 135 std::unique_ptr<ResourceProvider> resource_provider_; |
| 145 std::unique_ptr<SurfaceAggregator> aggregator_; | 136 std::unique_ptr<SurfaceAggregator> aggregator_; |
| 146 TextureMailboxDeleter texture_mailbox_deleter_; | 137 std::unique_ptr<TextureMailboxDeleter> texture_mailbox_deleter_; |
| 147 std::unique_ptr<DirectRenderer> renderer_; | 138 std::unique_ptr<DirectRenderer> renderer_; |
| 148 std::vector<ui::LatencyInfo> stored_latency_info_; | 139 std::vector<ui::LatencyInfo> stored_latency_info_; |
| 149 | 140 |
| 150 private: | 141 private: |
| 151 DISALLOW_COPY_AND_ASSIGN(Display); | 142 DISALLOW_COPY_AND_ASSIGN(Display); |
| 152 }; | 143 }; |
| 153 | 144 |
| 154 } // namespace cc | 145 } // namespace cc |
| 155 | 146 |
| 156 #endif // CC_SURFACES_DISPLAY_H_ | 147 #endif // CC_SURFACES_DISPLAY_H_ |
| OLD | NEW |