Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / gpu / command_buffer / client / gpu_control.h
blob7065d1edb44c27e6904166091e2a4ab299d01819
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/constants.h"
16 #include "gpu/command_buffer/common/mailbox.h"
17 #include "gpu/gpu_export.h"
19 extern "C" typedef struct _ClientBuffer* ClientBuffer;
21 namespace base {
22 class Lock;
25 namespace gfx {
26 class GpuMemoryBuffer;
29 namespace gpu {
31 // Common interface for GpuControl implementations.
32 class GPU_EXPORT GpuControl {
33 public:
34 GpuControl() {}
35 virtual ~GpuControl() {}
37 virtual Capabilities GetCapabilities() = 0;
39 // Create an image for a client buffer with the given dimensions and
40 // format. Returns its ID or -1 on error.
41 virtual int32_t CreateImage(ClientBuffer buffer,
42 size_t width,
43 size_t height,
44 unsigned internalformat) = 0;
46 // Destroy an image. The ID must be positive.
47 virtual void DestroyImage(int32_t id) = 0;
49 // Create a gpu memory buffer backed image with the given dimensions and
50 // format for |usage|. Returns its ID or -1 on error.
51 virtual int32_t CreateGpuMemoryBufferImage(size_t width,
52 size_t height,
53 unsigned internalformat,
54 unsigned usage) = 0;
56 // Inserts a sync point, returning its ID. Sync point IDs are global and can
57 // be used for cross-context synchronization.
58 virtual uint32_t InsertSyncPoint() = 0;
60 // Inserts a future sync point, returning its ID. Sync point IDs are global
61 // and can be used for cross-context synchronization. The sync point won't be
62 // retired immediately.
63 virtual uint32_t InsertFutureSyncPoint() = 0;
65 // Retires a future sync point. This will signal contexts that are waiting
66 // on it to start executing.
67 virtual void RetireSyncPoint(uint32_t sync_point) = 0;
69 // Runs |callback| when a sync point is reached.
70 virtual void SignalSyncPoint(uint32_t sync_point,
71 const base::Closure& callback) = 0;
73 // Runs |callback| when a query created via glCreateQueryEXT() has cleared
74 // passed the glEndQueryEXT() point.
75 virtual void SignalQuery(uint32_t query, const base::Closure& callback) = 0;
77 virtual void SetSurfaceVisible(bool visible) = 0;
79 // Attaches an external stream to the texture given by |texture_id| and
80 // returns a stream identifier.
81 virtual uint32_t CreateStreamTexture(uint32_t texture_id) = 0;
83 // Sets a lock this will be held on every callback from the GPU
84 // implementation. This lock must be set and must be held on every call into
85 // the GPU implementation if it is to be used from multiple threads. This
86 // may not be supported with all implementations.
87 virtual void SetLock(base::Lock*) = 0;
89 // Returns true if the channel to the Gpu is lost. When true, all contexts
90 // should be considered as lost.
91 virtual bool IsGpuChannelLost() = 0;
93 // The namespace and command buffer ID forms a unique pair for all existing
94 // GpuControl (on client) and matches for the corresponding command buffer
95 // (on server) in a single server process.
96 virtual CommandBufferNamespace GetNamespaceID() const = 0;
97 virtual uint64_t GetCommandBufferID() const = 0;
99 private:
100 DISALLOW_COPY_AND_ASSIGN(GpuControl);
103 } // namespace gpu
105 #endif // GPU_COMMAND_BUFFER_CLIENT_GPU_CONTROL_H_