Roll leveldb 3f7758:803d69 (v1.17 -> v1.18)
[chromium-blink-merge.git] / gpu / command_buffer / client / gpu_control.h
bloba56bd516fc570a7015ee9c1c9d45c16c12779adf
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 GPU_COMMAND_BUFFER_CLIENT_GPU_CONTROL_H_
6 #define GPU_COMMAND_BUFFER_CLIENT_GPU_CONTROL_H_
8 #include <stdint.h>
10 #include <vector>
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"
18 extern "C" typedef struct _ClientBuffer* ClientBuffer;
20 namespace gfx {
21 class GpuMemoryBuffer;
24 namespace gpu {
26 // Common interface for GpuControl implementations.
27 class GPU_EXPORT GpuControl {
28 public:
29 GpuControl() {}
30 virtual ~GpuControl() {}
32 virtual Capabilities GetCapabilities() = 0;
34 // Create an image for a client buffer with the given dimensions and
35 // format. Returns its ID or -1 on error.
36 virtual int32_t CreateImage(ClientBuffer buffer,
37 size_t width,
38 size_t height,
39 unsigned internalformat) = 0;
41 // Destroy an image. The ID must be positive.
42 virtual void DestroyImage(int32_t id) = 0;
44 // Create a gpu memory buffer backed image with the given dimensions and
45 // format for |usage|. Returns its ID or -1 on error.
46 virtual int32_t CreateGpuMemoryBufferImage(size_t width,
47 size_t height,
48 unsigned internalformat,
49 unsigned usage) = 0;
51 // Inserts a sync point, returning its ID. Sync point IDs are global and can
52 // be used for cross-context synchronization.
53 virtual uint32_t InsertSyncPoint() = 0;
55 // Inserts a future sync point, returning its ID. Sync point IDs are global
56 // and can be used for cross-context synchronization. The sync point won't be
57 // retired immediately.
58 virtual uint32_t InsertFutureSyncPoint() = 0;
60 // Retires a future sync point. This will signal contexts that are waiting
61 // on it to start executing.
62 virtual void RetireSyncPoint(uint32_t sync_point) = 0;
64 // Runs |callback| when a sync point is reached.
65 virtual void SignalSyncPoint(uint32_t sync_point,
66 const base::Closure& callback) = 0;
68 // Runs |callback| when a query created via glCreateQueryEXT() has cleared
69 // passed the glEndQueryEXT() point.
70 virtual void SignalQuery(uint32_t query, const base::Closure& callback) = 0;
72 virtual void SetSurfaceVisible(bool visible) = 0;
74 // Attaches an external stream to the texture given by |texture_id| and
75 // returns a stream identifier.
76 virtual uint32_t CreateStreamTexture(uint32_t texture_id) = 0;
78 private:
79 DISALLOW_COPY_AND_ASSIGN(GpuControl);
82 } // namespace gpu
84 #endif // GPU_COMMAND_BUFFER_CLIENT_GPU_CONTROL_H_