Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / gpu / command_buffer / client / gpu_control.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 GPU_COMMAND_BUFFER_CLIENT_GPU_CONTROL_H_
6 #define GPU_COMMAND_BUFFER_CLIENT_GPU_CONTROL_H_
7
8 #include <stdint.h>
9
10 #include <vector>
11
12 #include "base/callback.h"
13 #include "base/macros.h"
14 #include "gpu/command_buffer/common/capabilities.h"
15 #include "gpu/command_buffer/common/mailbox.h"
16 #include "gpu/gpu_export.h"
17
18 namespace gfx {
19 class GpuMemoryBuffer;
20 }
21
22 namespace gpu {
23
24 // Common interface for GpuControl implementations.
25 class GPU_EXPORT GpuControl {
26  public:
27   GpuControl() {}
28   virtual ~GpuControl() {}
29
30   virtual Capabilities GetCapabilities() = 0;
31
32   // Create a gpu memory buffer of the given dimensions and format. Returns
33   // its ID or -1 on error.
34   virtual gfx::GpuMemoryBuffer* CreateGpuMemoryBuffer(
35       size_t width,
36       size_t height,
37       unsigned internalformat,
38       unsigned usage,
39       int32_t* id) = 0;
40
41   // Destroy a gpu memory buffer. The ID must be positive.
42   virtual void DestroyGpuMemoryBuffer(int32_t id) = 0;
43
44   // Inserts a sync point, returning its ID. Sync point IDs are global and can
45   // be used for cross-context synchronization.
46   virtual uint32_t InsertSyncPoint() = 0;
47
48   // Inserts a future sync point, returning its ID. Sync point IDs are global
49   // and can be used for cross-context synchronization. The sync point won't be
50   // retired immediately.
51   virtual uint32_t InsertFutureSyncPoint() = 0;
52
53   // Retires a future sync point. This will signal contexts that are waiting
54   // on it to start executing.
55   virtual void RetireSyncPoint(uint32_t sync_point) = 0;
56
57   // Runs |callback| when a sync point is reached.
58   virtual void SignalSyncPoint(uint32_t sync_point,
59                                const base::Closure& callback) = 0;
60
61   // Runs |callback| when a query created via glCreateQueryEXT() has cleared
62   // passed the glEndQueryEXT() point.
63   virtual void SignalQuery(uint32_t query, const base::Closure& callback) = 0;
64
65   virtual void SetSurfaceVisible(bool visible) = 0;
66
67   // Invokes the callback once the context has been flushed.
68   virtual void Echo(const base::Closure& callback) = 0;
69
70   // Attaches an external stream to the texture given by |texture_id| and
71   // returns a stream identifier.
72   virtual uint32_t CreateStreamTexture(uint32_t texture_id) = 0;
73
74  private:
75   DISALLOW_COPY_AND_ASSIGN(GpuControl);
76 };
77
78 }  // namespace gpu
79
80 #endif  // GPU_COMMAND_BUFFER_CLIENT_GPU_CONTROL_H_