Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(371)

Side by Side Diff: services/ui/surfaces/display_compositor.h

Issue 2369793002: WIP: Propagate SurfaceID up window tree hierarchy
Patch Set: Fix input events: EventDispatcher ignores container windows Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 {
20 namespace surfaces {
25 21
26 // TODO(fsamuel): This should become a mojo interface for the mus-gpu split. 22 class DisplayCompositorClient;
27 // TODO(fsamuel): This should not be a SurfaceFactoryClient. 23
28 // The DisplayCompositor receives CompositorFrames from all sources, 24 // The DisplayCompositor object is an object global to the Window Manager app
29 // creates a top-level CompositorFrame once per tick, and generates graphical 25 // that holds the SurfaceManager and allocates new Surfaces namespaces.
30 // output. 26 // This object lives on the main thread of the Window Manager.
31 class DisplayCompositor : public cc::SurfaceFactoryClient, 27 // TODO(rjkroege, fsamuel): This object will need to change to support multiple
32 public cc::DisplayClient { 28 // displays.
29 class DisplayCompositor : public base::RefCounted<DisplayCompositor>,
30 public cc::SurfaceManager::Delegate {
33 public: 31 public:
34 DisplayCompositor(scoped_refptr<base::SingleThreadTaskRunner> task_runner, 32 explicit DisplayCompositor(DisplayCompositorClient* client);
35 gfx::AcceleratedWidget widget, 33
36 scoped_refptr<gpu::GpuChannelHost> gpu_channel, 34 uint32_t next_client_id() { return next_client_id_++; }
37 const scoped_refptr<SurfacesState>& surfaces_state); 35
36 cc::SurfaceManager* manager() { return &manager_; }
37
38 private:
39 friend class base::RefCounted<DisplayCompositor>;
38 ~DisplayCompositor() override; 40 ~DisplayCompositor() override;
39 41
40 // DisplayCompositor embedders submit a CompositorFrame when content on the 42 // cc::SurfaceManager::Delegate:
41 // display should be changed. A well-behaving embedder should only submit 43 void OnSurfaceCreated(const gfx::Size& size,
42 // a CompositorFrame once per BeginFrame tick. The callback is called the 44 float device_scale_factor,
43 // first time this frame is used to draw, or if the frame is discarded. 45 const cc::SurfaceId& surface_id) override;
44 void SubmitCompositorFrame(cc::CompositorFrame frame,
45 const base::Callback<void()>& callback);
46 46
47 // TODO(fsamuel): This is used for surface hittesting and should not be 47 DisplayCompositorClient* const client_;
48 // exposed outside of DisplayCompositor. 48 // A Surface ID is an unsigned 64-bit int where the high 32-bits are generated
49 const cc::SurfaceId& surface_id() const { return surface_id_; } 49 // by the Surfaces service, and the low 32-bits are generated by the process
50 // that requested the Surface.
51 uint32_t next_client_id_;
52 cc::SurfaceManager manager_;
50 53
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
60 private:
61 // SurfaceFactoryClient implementation.
62 void ReturnResources(const cc::ReturnedResourceArray& resources) override;
63 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override;
64
65 // DisplayClient implementation.
66 void DisplayOutputSurfaceLost() override;
67 void DisplayWillDrawAndSwap(bool will_draw_and_swap,
68 const cc::RenderPassList& render_passes) override;
69 void DisplayDidDrawAndSwap() override;
70
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); 54 DISALLOW_COPY_AND_ASSIGN(DisplayCompositor);
80 }; 55 };
81 56
57 } // namespace surfaces
82 } // namespace ui 58 } // namespace ui
83 59
84 #endif // SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ 60 #endif // SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_
OLDNEW
« no previous file with comments | « services/ui/surfaces/compositor_frame_sink.cc ('k') | services/ui/surfaces/display_compositor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698