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
3 // found in the LICENSE file.
5 #ifndef CC_SURFACES_ONSCREEN_DISPLAY_CLIENT_H_
6 #define CC_SURFACES_ONSCREEN_DISPLAY_CLIENT_H_
8 #include "cc/surfaces/display_client.h"
10 #include "base/compiler_specific.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/single_thread_task_runner.h"
14 #include "cc/surfaces/display.h"
15 #include "cc/surfaces/surfaces_export.h"
18 class ContextProvider
;
20 class SurfaceDisplayOutputSurface
;
22 // This class provides a DisplayClient implementation for drawing directly to an
24 class CC_SURFACES_EXPORT OnscreenDisplayClient
25 : NON_EXPORTED_BASE(DisplayClient
) {
27 OnscreenDisplayClient(
28 scoped_ptr
<OutputSurface
> output_surface
,
29 SurfaceManager
* manager
,
30 SharedBitmapManager
* bitmap_manager
,
31 gpu::GpuMemoryBufferManager
* gpu_memory_buffer_manager
,
32 const RendererSettings
& settings
,
33 scoped_refptr
<base::SingleThreadTaskRunner
> task_runner
);
34 ~OnscreenDisplayClient() override
;
37 Display
* display() { return display_
.get(); }
38 void set_surface_output_surface(SurfaceDisplayOutputSurface
* surface
) {
39 surface_display_output_surface_
= surface
;
42 // DisplayClient implementation.
43 void DisplayDamaged() override
;
44 void DidSwapBuffers() override
;
45 void DidSwapBuffersComplete() override
;
46 void CommitVSyncParameters(base::TimeTicks timebase
,
47 base::TimeDelta interval
) override
;
48 void OutputSurfaceLost() override
;
49 void SetMemoryPolicy(const ManagedMemoryPolicy
& policy
) override
;
51 bool output_surface_lost() { return output_surface_lost_
; }
57 scoped_ptr
<OutputSurface
> output_surface_
;
58 scoped_ptr
<Display
> display_
;
59 scoped_refptr
<base::SingleThreadTaskRunner
> task_runner_
;
60 SurfaceDisplayOutputSurface
* surface_display_output_surface_
;
62 bool output_surface_lost_
;
63 // True if a draw should be scheduled, but it's hit the limit on max frames
68 base::WeakPtrFactory
<OnscreenDisplayClient
> weak_ptr_factory_
;
70 DISALLOW_COPY_AND_ASSIGN(OnscreenDisplayClient
);
75 #endif // CC_SURFACES_ONSCREEN_DISPLAY_CLIENT_H_