Blink roll 25b6bd3a7a131ffe68d809546ad1a20707915cdc:3a503f41ae42e5b79cfcd2ff10e65afde...
[chromium-blink-merge.git] / content / browser / compositor / onscreen_display_client.h
blob522274a6324ade6ed300da3387c72d71b28c93fd
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 CONTENT_BROWSER_COMPOSITOR_ONSCREEN_DISPLAY_CLIENT_H_
6 #define CONTENT_BROWSER_COMPOSITOR_ONSCREEN_DISPLAY_CLIENT_H_
8 #include "cc/surfaces/display_client.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/single_thread_task_runner.h"
13 #include "cc/surfaces/display.h"
15 namespace cc {
16 class ContextProvider;
17 class SurfaceManager;
20 namespace content {
21 class SurfaceDisplayOutputSurface;
23 // This class provides a DisplayClient implementation for drawing directly to an
24 // onscreen context.
25 class OnscreenDisplayClient : cc::DisplayClient {
26 public:
27 OnscreenDisplayClient(
28 scoped_ptr<cc::OutputSurface> output_surface,
29 cc::SurfaceManager* manager,
30 const cc::RendererSettings& settings,
31 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
32 ~OnscreenDisplayClient() override;
34 bool Initialize();
35 cc::Display* display() { return display_.get(); }
36 void set_surface_output_surface(SurfaceDisplayOutputSurface* surface) {
37 surface_display_output_surface_ = surface;
40 // cc::DisplayClient implementation.
41 void DisplayDamaged() override;
42 void DidSwapBuffers() override;
43 void DidSwapBuffersComplete() override;
44 void CommitVSyncParameters(base::TimeTicks timebase,
45 base::TimeDelta interval) override;
46 void OutputSurfaceLost() override;
47 void SetMemoryPolicy(const cc::ManagedMemoryPolicy& policy) override;
49 private:
50 void ScheduleDraw();
51 void Draw();
53 scoped_ptr<cc::OutputSurface> output_surface_;
54 scoped_ptr<cc::Display> display_;
55 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
56 SurfaceDisplayOutputSurface* surface_display_output_surface_;
57 bool scheduled_draw_;
58 bool output_surface_lost_;
59 // True if a draw should be scheduled, but it's hit the limit on max frames
60 // pending.
61 bool deferred_draw_;
62 int pending_frames_;
64 base::WeakPtrFactory<OnscreenDisplayClient> weak_ptr_factory_;
66 DISALLOW_COPY_AND_ASSIGN(OnscreenDisplayClient);
69 } // namespace content
71 #endif // CONTENT_BROWSER_COMPOSITOR_ONSCREEN_DISPLAY_CLIENT_H_