Automated Commit: Committing new LKGM version 6953.0.0 for chromeos.
[chromium-blink-merge.git] / cc / surfaces / onscreen_display_client.h
blobef61e53ef580fa82afb6c2b43e6048b5778a1272
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"
17 namespace cc {
18 class ContextProvider;
19 class SurfaceManager;
20 class SurfaceDisplayOutputSurface;
22 // This class provides a DisplayClient implementation for drawing directly to an
23 // onscreen context.
24 class CC_SURFACES_EXPORT OnscreenDisplayClient
25 : NON_EXPORTED_BASE(DisplayClient) {
26 public:
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;
36 bool Initialize();
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_; }
53 private:
54 void ScheduleDraw();
55 void Draw();
57 scoped_ptr<OutputSurface> output_surface_;
58 scoped_ptr<Display> display_;
59 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
60 SurfaceDisplayOutputSurface* surface_display_output_surface_;
61 bool scheduled_draw_;
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_;
68 base::WeakPtrFactory<OnscreenDisplayClient> weak_ptr_factory_;
70 DISALLOW_COPY_AND_ASSIGN(OnscreenDisplayClient);
73 } // namespace cc
75 #endif // CC_SURFACES_ONSCREEN_DISPLAY_CLIENT_H_