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

Side by Side Diff: services/gfx/compositor/backend/gpu_output.h

Issue 2009503003: Mozart: Reduce pipeline depth and unify frame queue. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: address review comments Created 4 years, 6 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 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 SERVICES_GFX_COMPOSITOR_BACKEND_GPU_OUTPUT_H_ 5 #ifndef SERVICES_GFX_COMPOSITOR_BACKEND_GPU_OUTPUT_H_
6 #define SERVICES_GFX_COMPOSITOR_BACKEND_GPU_OUTPUT_H_ 6 #define SERVICES_GFX_COMPOSITOR_BACKEND_GPU_OUTPUT_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <mutex> 9 #include <mutex>
10 #include <queue> 10 #include <queue>
(...skipping 16 matching lines...) Expand all
27 public: 27 public:
28 GpuOutput(mojo::InterfaceHandle<mojo::ContextProvider> context_provider, 28 GpuOutput(mojo::InterfaceHandle<mojo::ContextProvider> context_provider,
29 const SchedulerCallbacks& scheduler_callbacks, 29 const SchedulerCallbacks& scheduler_callbacks,
30 const base::Closure& error_callback); 30 const base::Closure& error_callback);
31 ~GpuOutput() override; 31 ~GpuOutput() override;
32 32
33 Scheduler* GetScheduler() override; 33 Scheduler* GetScheduler() override;
34 void SubmitFrame(const scoped_refptr<RenderFrame>& frame) override; 34 void SubmitFrame(const scoped_refptr<RenderFrame>& frame) override;
35 35
36 private: 36 private:
37 struct FrameData : public base::RefCountedThreadSafe<FrameData> { 37 struct FrameData {
38 enum class State {
39 Pending, // initial state waiting for draw to start
40 Drawing, // draw has started
41 Finished // draw has finished
42 };
43
38 FrameData(const scoped_refptr<RenderFrame>& frame, int64_t submit_time); 44 FrameData(const scoped_refptr<RenderFrame>& frame, int64_t submit_time);
45 ~FrameData();
39 46
40 void Recycle(); 47 void ResetDrawState();
41 48
42 const scoped_refptr<RenderFrame> frame; 49 const scoped_refptr<RenderFrame> frame;
43 const int64_t submit_time; 50 const int64_t submit_time;
44 bool drawn = false; // set when DrawFrame is called 51 State state = State::Pending;
45 int64_t draw_time = 0; // 0 if not drawn 52 int64_t draw_started_time = 0; // time when drawing began
46 int64_t wait_time = 0; // 0 if not drawn 53 int64_t draw_issued_time = 0; // time when awaiting for finish began
47 54
48 private: 55 private:
49 friend class base::RefCountedThreadSafe<FrameData>;
50
51 ~FrameData();
52
53 DISALLOW_COPY_AND_ASSIGN(FrameData); 56 DISALLOW_COPY_AND_ASSIGN(FrameData);
54 }; 57 };
55 58
56 // |GpuRasterizer::Callbacks|: 59 // |GpuRasterizer::Callbacks|:
57 void OnRasterizerReady(int64_t vsync_timebase, 60 void OnRasterizerReady(int64_t vsync_timebase,
58 int64_t vsync_interval) override; 61 int64_t vsync_interval) override;
59 void OnRasterizerSuspended() override; 62 void OnRasterizerSuspended() override;
60 void OnRasterizerFinishedDraw(bool presented) override; 63 void OnRasterizerFinishedDraw(bool presented) override;
61 void OnRasterizerError() override; 64 void OnRasterizerError() override;
62 65
(...skipping 16 matching lines...) Expand all
79 // The rasterizer itself runs on its own thread. 82 // The rasterizer itself runs on its own thread.
80 std::unique_ptr<base::Thread> rasterizer_thread_; 83 std::unique_ptr<base::Thread> rasterizer_thread_;
81 scoped_refptr<base::SingleThreadTaskRunner> rasterizer_task_runner_; 84 scoped_refptr<base::SingleThreadTaskRunner> rasterizer_task_runner_;
82 base::WaitableEvent rasterizer_initialized_; 85 base::WaitableEvent rasterizer_initialized_;
83 std::unique_ptr<GpuRasterizer> rasterizer_; 86 std::unique_ptr<GpuRasterizer> rasterizer_;
84 87
85 // Holds state shared between the compositor and rasterizer threads. 88 // Holds state shared between the compositor and rasterizer threads.
86 struct { 89 struct {
87 std::mutex mutex; // guards all shared state 90 std::mutex mutex; // guards all shared state
88 91
89 // The most recently submitted frame. 92 // Queue of frames.
90 // Only null until the first frame has been submitted. 93 //
91 scoped_refptr<FrameData> current_frame_data; 94 // The head of this queue consists of up to |pipeline_depth| frames
92 95 // which are drawn and awaiting finish. These frames are popped off
93 // Frames drawn and awaiting completion by the rasterizer. 96 // the queue when finished unless the queue would become empty (such
94 std::queue<scoped_refptr<FrameData>> drawn_frames_awaiting_finish; 97 // that we always retain the current frame as the tail).
98 //
99 // The tail of this queue is a single frame which is either drawn or
100 // finished and represents the current (most recently submitted)
101 // content.
102 //
103 // The queue is only ever empty until the first frame is submitted.
104 // Subsequently, it always contains at least one frame.
105 std::queue<std::unique_ptr<FrameData>> frames;
95 106
96 // Set to true when the rasterizer is ready to draw. 107 // Set to true when the rasterizer is ready to draw.
97 bool rasterizer_ready = false; 108 bool rasterizer_ready = false;
98 109
99 // Set to true when a request to draw has been scheduled. 110 // Set to true when a request to draw has been scheduled.
100 bool draw_scheduled = false; 111 bool draw_scheduled = false;
101 } shared_state_; 112 } shared_state_;
102 113
103 DISALLOW_COPY_AND_ASSIGN(GpuOutput); 114 DISALLOW_COPY_AND_ASSIGN(GpuOutput);
104 }; 115 };
105 116
106 } // namespace compositor 117 } // namespace compositor
107 118
108 #endif // SERVICES_GFX_COMPOSITOR_BACKEND_GPU_OUTPUT_H_ 119 #endif // SERVICES_GFX_COMPOSITOR_BACKEND_GPU_OUTPUT_H_
OLDNEW
« no previous file with comments | « no previous file | services/gfx/compositor/backend/gpu_output.cc » ('j') | services/gfx/compositor/backend/gpu_output.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698