Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / content / browser / compositor / browser_compositor_output_surface.h
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.
4
5 #ifndef CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_
6 #define CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_
7
8 #include "base/id_map.h"
9 #include "base/threading/non_thread_safe.h"
10 #include "cc/output/output_surface.h"
11 #include "content/common/content_export.h"
12 #include "ui/compositor/compositor_vsync_manager.h"
13
14 namespace cc {
15 class SoftwareOutputDevice;
16 }
17
18 namespace content {
19 class ContextProviderCommandBuffer;
20 class ReflectorImpl;
21 class WebGraphicsContext3DCommandBufferImpl;
22
23 class CONTENT_EXPORT BrowserCompositorOutputSurface
24     : public cc::OutputSurface,
25       public ui::CompositorVSyncManager::Observer,
26       public base::NonThreadSafe {
27  public:
28   virtual ~BrowserCompositorOutputSurface();
29
30   // cc::OutputSurface implementation.
31   virtual bool BindToClient(cc::OutputSurfaceClient* client) OVERRIDE;
32   virtual void Reshape(const gfx::Size& size, float scale_factor) OVERRIDE;
33
34   // ui::CompositorOutputSurface::Observer implementation.
35   virtual void OnUpdateVSyncParameters(base::TimeTicks timebase,
36                                        base::TimeDelta interval) OVERRIDE;
37
38   void OnUpdateVSyncParametersFromGpu(base::TimeTicks tiembase,
39                                       base::TimeDelta interval);
40
41   void SetReflector(ReflectorImpl* reflector);
42
43  protected:
44   // Constructor used by the accelerated implementation.
45   BrowserCompositorOutputSurface(
46       const scoped_refptr<ContextProviderCommandBuffer>& context,
47       int surface_id,
48       IDMap<BrowserCompositorOutputSurface>* output_surface_map,
49       const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager);
50
51   // Constructor used by the software implementation.
52   BrowserCompositorOutputSurface(
53       scoped_ptr<cc::SoftwareOutputDevice> software_device,
54       int surface_id,
55       IDMap<BrowserCompositorOutputSurface>* output_surface_map,
56       const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager);
57
58   int surface_id_;
59   IDMap<BrowserCompositorOutputSurface>* output_surface_map_;
60
61   scoped_refptr<ui::CompositorVSyncManager> vsync_manager_;
62   scoped_refptr<ReflectorImpl> reflector_;
63
64  private:
65   void Initialize();
66
67   DISALLOW_COPY_AND_ASSIGN(BrowserCompositorOutputSurface);
68 };
69
70 }  // namespace content
71
72 #endif  // CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_