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_ONSCREEN_DISPLAY_CLIENT_H_ | 5 #ifndef CC_SURFACES_ONSCREEN_DISPLAY_CLIENT_H_ |
6 #define CC_SURFACES_ONSCREEN_DISPLAY_CLIENT_H_ | 6 #define CC_SURFACES_ONSCREEN_DISPLAY_CLIENT_H_ |
7 | 7 |
8 #include "cc/surfaces/display_client.h" | 8 #include "cc/surfaces/display_client.h" |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
14 #include "cc/surfaces/display.h" | 14 #include "cc/surfaces/display.h" |
15 #include "cc/surfaces/surfaces_export.h" | 15 #include "cc/surfaces/surfaces_export.h" |
16 | 16 |
17 namespace cc { | 17 namespace cc { |
18 class ContextProvider; | 18 class ContextProvider; |
19 class DisplayScheduler; | |
20 class SurfaceManager; | 19 class SurfaceManager; |
21 class SurfaceDisplayOutputSurface; | 20 class SurfaceDisplayOutputSurface; |
22 class SyntheticBeginFrameSource; | |
23 | 21 |
24 // This class provides a DisplayClient implementation for drawing directly to an | 22 // This class provides a DisplayClient implementation for drawing directly to an |
25 // onscreen context. | 23 // onscreen context. |
26 class CC_SURFACES_EXPORT OnscreenDisplayClient | 24 class CC_SURFACES_EXPORT OnscreenDisplayClient |
27 : NON_EXPORTED_BASE(DisplayClient) { | 25 : NON_EXPORTED_BASE(DisplayClient) { |
28 public: | 26 public: |
29 OnscreenDisplayClient( | 27 OnscreenDisplayClient( |
30 scoped_ptr<OutputSurface> output_surface, | 28 scoped_ptr<OutputSurface> output_surface, |
31 SurfaceManager* manager, | 29 SurfaceManager* manager, |
32 SharedBitmapManager* bitmap_manager, | 30 SharedBitmapManager* bitmap_manager, |
33 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 31 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
34 const RendererSettings& settings, | 32 const RendererSettings& settings, |
35 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 33 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
36 ~OnscreenDisplayClient() override; | 34 ~OnscreenDisplayClient() override; |
37 | 35 |
38 bool Initialize(); | 36 bool Initialize(); |
39 Display* display() { return display_.get(); } | 37 Display* display() { return display_.get(); } |
40 void set_surface_output_surface(SurfaceDisplayOutputSurface* surface) { | 38 void set_surface_output_surface(SurfaceDisplayOutputSurface* surface) { |
41 surface_display_output_surface_ = surface; | 39 surface_display_output_surface_ = surface; |
42 } | 40 } |
43 | 41 |
44 // DisplayClient implementation. | 42 // DisplayClient implementation. |
| 43 void DisplayDamaged() override; |
| 44 void DidSwapBuffers() override; |
| 45 void DidSwapBuffersComplete() override; |
45 void CommitVSyncParameters(base::TimeTicks timebase, | 46 void CommitVSyncParameters(base::TimeTicks timebase, |
46 base::TimeDelta interval) override; | 47 base::TimeDelta interval) override; |
47 void OutputSurfaceLost() override; | 48 void OutputSurfaceLost() override; |
48 void SetMemoryPolicy(const ManagedMemoryPolicy& policy) override; | 49 void SetMemoryPolicy(const ManagedMemoryPolicy& policy) override; |
49 | 50 |
50 bool output_surface_lost() { return output_surface_lost_; } | 51 bool output_surface_lost() { return output_surface_lost_; } |
51 | 52 |
52 private: | 53 private: |
| 54 void ScheduleDraw(); |
| 55 void Draw(); |
| 56 |
53 scoped_ptr<OutputSurface> output_surface_; | 57 scoped_ptr<OutputSurface> output_surface_; |
54 scoped_ptr<Display> display_; | 58 scoped_ptr<Display> display_; |
55 scoped_ptr<SyntheticBeginFrameSource> synthetic_begin_frame_source_; | |
56 scoped_ptr<DisplayScheduler> scheduler_; | |
57 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 59 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
58 SurfaceDisplayOutputSurface* surface_display_output_surface_; | 60 SurfaceDisplayOutputSurface* surface_display_output_surface_; |
| 61 bool scheduled_draw_; |
59 bool output_surface_lost_; | 62 bool output_surface_lost_; |
| 63 // True if a draw should be scheduled, but it's hit the limit on max frames |
| 64 // pending. |
| 65 bool deferred_draw_; |
| 66 int pending_frames_; |
| 67 |
| 68 base::WeakPtrFactory<OnscreenDisplayClient> weak_ptr_factory_; |
60 | 69 |
61 DISALLOW_COPY_AND_ASSIGN(OnscreenDisplayClient); | 70 DISALLOW_COPY_AND_ASSIGN(OnscreenDisplayClient); |
62 }; | 71 }; |
63 | 72 |
64 } // namespace cc | 73 } // namespace cc |
65 | 74 |
66 #endif // CC_SURFACES_ONSCREEN_DISPLAY_CLIENT_H_ | 75 #endif // CC_SURFACES_ONSCREEN_DISPLAY_CLIENT_H_ |
OLD | NEW |