| 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 CONTENT_BROWSER_COMPOSITOR_ONSCREEN_DISPLAY_CLIENT_H_ | 5 #ifndef CONTENT_BROWSER_COMPOSITOR_ONSCREEN_DISPLAY_CLIENT_H_ |
| 6 #define CONTENT_BROWSER_COMPOSITOR_ONSCREEN_DISPLAY_CLIENT_H_ | 6 #define CONTENT_BROWSER_COMPOSITOR_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/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "cc/surfaces/display.h" | 13 #include "cc/surfaces/display.h" |
| 14 | 14 |
| 15 namespace cc { | 15 namespace cc { |
| 16 class ContextProvider; | 16 class ContextProvider; |
| 17 class SurfaceManager; | 17 class SurfaceManager; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace content { | 20 namespace content { |
| 21 class SurfaceDisplayOutputSurface; |
| 21 | 22 |
| 22 // This class provides a DisplayClient implementation for drawing directly to an | 23 // This class provides a DisplayClient implementation for drawing directly to an |
| 23 // onscreen context. | 24 // onscreen context. |
| 24 class OnscreenDisplayClient : cc::DisplayClient { | 25 class OnscreenDisplayClient : cc::DisplayClient { |
| 25 public: | 26 public: |
| 26 OnscreenDisplayClient( | 27 OnscreenDisplayClient( |
| 27 scoped_ptr<cc::OutputSurface> output_surface, | 28 scoped_ptr<cc::OutputSurface> output_surface, |
| 28 cc::SurfaceManager* manager, | 29 cc::SurfaceManager* manager, |
| 29 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 30 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
| 30 virtual ~OnscreenDisplayClient(); | 31 virtual ~OnscreenDisplayClient(); |
| 31 | 32 |
| 32 cc::Display* display() { return display_.get(); } | 33 cc::Display* display() { return display_.get(); } |
| 34 void set_surface_output_surface(SurfaceDisplayOutputSurface* surface) { |
| 35 surface_display_output_surface_ = surface; |
| 36 } |
| 33 | 37 |
| 34 // cc::DisplayClient implementation. | 38 // cc::DisplayClient implementation. |
| 35 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface() OVERRIDE; | 39 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface() OVERRIDE; |
| 36 virtual void DisplayDamaged() OVERRIDE; | 40 virtual void DisplayDamaged() OVERRIDE; |
| 37 virtual void DidSwapBuffers() OVERRIDE; | 41 virtual void DidSwapBuffers() OVERRIDE; |
| 38 virtual void DidSwapBuffersComplete() OVERRIDE; | 42 virtual void DidSwapBuffersComplete() OVERRIDE; |
| 43 virtual void CommitVSyncParameters(base::TimeTicks timebase, |
| 44 base::TimeDelta interval) OVERRIDE; |
| 39 | 45 |
| 40 private: | 46 private: |
| 41 void ScheduleDraw(); | 47 void ScheduleDraw(); |
| 42 void Draw(); | 48 void Draw(); |
| 43 | 49 |
| 44 scoped_ptr<cc::OutputSurface> output_surface_; | 50 scoped_ptr<cc::OutputSurface> output_surface_; |
| 45 scoped_ptr<cc::Display> display_; | 51 scoped_ptr<cc::Display> display_; |
| 46 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 52 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 53 SurfaceDisplayOutputSurface* surface_display_output_surface_; |
| 47 bool scheduled_draw_; | 54 bool scheduled_draw_; |
| 48 // True if a draw should be scheduled, but it's hit the limit on max frames | 55 // True if a draw should be scheduled, but it's hit the limit on max frames |
| 49 // pending. | 56 // pending. |
| 50 bool deferred_draw_; | 57 bool deferred_draw_; |
| 51 int pending_frames_; | 58 int pending_frames_; |
| 52 | 59 |
| 53 base::WeakPtrFactory<OnscreenDisplayClient> weak_ptr_factory_; | 60 base::WeakPtrFactory<OnscreenDisplayClient> weak_ptr_factory_; |
| 54 | 61 |
| 55 DISALLOW_COPY_AND_ASSIGN(OnscreenDisplayClient); | 62 DISALLOW_COPY_AND_ASSIGN(OnscreenDisplayClient); |
| 56 }; | 63 }; |
| 57 | 64 |
| 58 } // namespace content | 65 } // namespace content |
| 59 | 66 |
| 60 #endif // CONTENT_BROWSER_COMPOSITOR_ONSCREEN_DISPLAY_CLIENT_H_ | 67 #endif // CONTENT_BROWSER_COMPOSITOR_ONSCREEN_DISPLAY_CLIENT_H_ |
| OLD | NEW |