Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 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 SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ | 5 #ifndef SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ |
| 6 #define SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ | 6 #define SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ |
| 7 | 7 |
| 8 #include "cc/surfaces/display_client.h" | 8 #include <stdint.h> |
| 9 #include "cc/surfaces/surface.h" | 9 |
| 10 #include "cc/surfaces/surface_factory.h" | 10 #include "base/macros.h" |
| 11 #include "cc/surfaces/surface_factory_client.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "cc/surfaces/surface_id_allocator.h" | 12 #include "cc/surfaces/surface_manager.h" |
| 13 #include "services/ui/surfaces/surfaces_state.h" | |
| 14 #include "ui/gfx/native_widget_types.h" | |
| 15 | 13 |
| 16 namespace cc { | 14 namespace cc { |
| 17 class Display; | 15 class SurfaceHittest; |
| 18 } | 16 class SurfaceManager; |
| 19 | 17 } // namespace cc |
| 20 namespace gpu { | |
| 21 class GpuChannelHost; | |
| 22 } | |
| 23 | 18 |
| 24 namespace ui { | 19 namespace ui { |
| 25 | 20 |
| 26 // TODO(fsamuel): This should become a mojo interface for the mus-gpu split. | 21 // The DisplayCompositor object is an object global to the Window Manager app |
|
sky
2016/10/03 16:16:02
Manager->Server
Fady Samuel
2016/10/03 18:27:06
Done.
| |
| 27 // TODO(fsamuel): This should not be a SurfaceFactoryClient. | 22 // that holds the SurfaceManager and allocates new Surfaces namespaces. |
| 28 // The DisplayCompositor receives CompositorFrames from all sources, | 23 // This object lives on the main thread of the Window Manager. |
|
sky
2016/10/03 16:16:02
Manager->Server
Fady Samuel
2016/10/03 18:27:06
Done.
| |
| 29 // creates a top-level CompositorFrame once per tick, and generates graphical | 24 // TODO(rjkroege, fsamuel): This object will need to change to support multiple |
| 30 // output. | 25 // displays. |
| 31 class DisplayCompositor : public cc::SurfaceFactoryClient, | 26 class DisplayCompositor : public base::RefCounted<DisplayCompositor> { |
| 32 public cc::DisplayClient { | |
| 33 public: | 27 public: |
| 34 DisplayCompositor(scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 28 DisplayCompositor(); |
| 35 gfx::AcceleratedWidget widget, | |
| 36 scoped_refptr<gpu::GpuChannelHost> gpu_channel, | |
| 37 const scoped_refptr<SurfacesState>& surfaces_state); | |
| 38 ~DisplayCompositor() override; | |
| 39 | 29 |
| 40 // DisplayCompositor embedders submit a CompositorFrame when content on the | 30 uint32_t next_client_id() { return next_client_id_++; } |
|
sky
2016/10/03 16:16:02
I would expect a function with this name to be a t
Fady Samuel
2016/10/03 18:27:06
Done.
| |
| 41 // display should be changed. A well-behaving embedder should only submit | |
| 42 // a CompositorFrame once per BeginFrame tick. The callback is called the | |
| 43 // first time this frame is used to draw, or if the frame is discarded. | |
| 44 void SubmitCompositorFrame(cc::CompositorFrame frame, | |
| 45 const base::Callback<void()>& callback); | |
| 46 | 31 |
| 47 // TODO(fsamuel): This is used for surface hittesting and should not be | 32 cc::SurfaceManager* manager() { return &manager_; } |
| 48 // exposed outside of DisplayCompositor. | |
| 49 const cc::SurfaceId& surface_id() const { return surface_id_; } | |
| 50 | |
| 51 // This requests the display CompositorFrame be rendered and given to the | |
| 52 // callback within CopyOutputRequest. | |
| 53 void RequestCopyOfOutput( | |
| 54 std::unique_ptr<cc::CopyOutputRequest> output_request); | |
| 55 | |
| 56 // TODO(fsamuel): Invent an async way to create a SurfaceNamespace | |
| 57 // A SurfaceNamespace can create CompositorFrameSinks where the client can | |
| 58 // make up the ID. | |
| 59 | 33 |
| 60 private: | 34 private: |
| 61 // SurfaceFactoryClient implementation. | 35 friend class base::RefCounted<DisplayCompositor>; |
| 62 void ReturnResources(const cc::ReturnedResourceArray& resources) override; | 36 ~DisplayCompositor(); |
| 63 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; | |
| 64 | 37 |
| 65 // DisplayClient implementation. | 38 // A Surface ID is an unsigned 64-bit int where the high 32-bits are generated |
| 66 void DisplayOutputSurfaceLost() override; | 39 // by the Surfaces service, and the low 32-bits are generated by the process |
| 67 void DisplayWillDrawAndSwap(bool will_draw_and_swap, | 40 // that requested the Surface. |
| 68 const cc::RenderPassList& render_passes) override; | 41 uint32_t next_client_id_; |
| 69 void DisplayDidDrawAndSwap() override; | 42 cc::SurfaceManager manager_; |
| 70 | 43 |
| 71 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | |
| 72 scoped_refptr<SurfacesState> surfaces_state_; | |
| 73 cc::SurfaceFactory factory_; | |
| 74 cc::SurfaceIdAllocator allocator_; | |
| 75 cc::SurfaceId surface_id_; | |
| 76 | |
| 77 gfx::Size display_size_; | |
| 78 std::unique_ptr<cc::Display> display_; | |
| 79 DISALLOW_COPY_AND_ASSIGN(DisplayCompositor); | 44 DISALLOW_COPY_AND_ASSIGN(DisplayCompositor); |
| 80 }; | 45 }; |
| 81 | 46 |
| 82 } // namespace ui | 47 } // namespace ui |
| 83 | 48 |
| 84 #endif // SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ | 49 #endif // SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ |
| OLD | NEW |