Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / gpu / command_buffer / client / gpu_control.h
blob75bd082a34da478b9247d294c050e2cb8c864fcb
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 base {
21 class Lock;
24 namespace gfx {
25 class GpuMemoryBuffer;
28 namespace gpu {
30 // Common interface for GpuControl implementations.
31 class GPU_EXPORT GpuControl {
32 public:
33 GpuControl() {}
34 virtual ~GpuControl() {}
36 virtual Capabilities GetCapabilities() = 0;
38 // Create an image for a client buffer with the given dimensions and
39 // format. Returns its ID or -1 on error.
40 virtual int32_t CreateImage(ClientBuffer buffer,
41 size_t width,
42 size_t height,
43 unsigned internalformat) = 0;
45 // Destroy an image. The ID must be positive.
46 virtual void DestroyImage(int32_t id) = 0;
48 // Create a gpu memory buffer backed image with the given dimensions and
49 // format for |usage|. Returns its ID or -1 on error.
50 virtual int32_t CreateGpuMemoryBufferImage(size_t width,
51 size_t height,
52 unsigned internalformat,
53 unsigned usage) = 0;
55 // Inserts a sync point, returning its ID. Sync point IDs are global and can
56 // be used for cross-context synchronization.
57 virtual uint32_t InsertSyncPoint() = 0;
59 // Inserts a future sync point, returning its ID. Sync point IDs are global
60 // and can be used for cross-context synchronization. The sync point won't be
61 // retired immediately.
62 virtual uint32_t InsertFutureSyncPoint() = 0;
64 // Retires a future sync point. This will signal contexts that are waiting
65 // on it to start executing.
66 virtual void RetireSyncPoint(uint32_t sync_point) = 0;
68 // Runs |callback| when a sync point is reached.
69 virtual void SignalSyncPoint(uint32_t sync_point,
70 const base::Closure& callback) = 0;
72 // Runs |callback| when a query created via glCreateQueryEXT() has cleared
73 // passed the glEndQueryEXT() point.
74 virtual void SignalQuery(uint32_t query, const base::Closure& callback) = 0;
76 virtual void SetSurfaceVisible(bool visible) = 0;
78 // Attaches an external stream to the texture given by |texture_id| and
79 // returns a stream identifier.
80 virtual uint32_t CreateStreamTexture(uint32_t texture_id) = 0;
82 // Sets a lock this will be held on every callback from the GPU
83 // implementation. This lock must be set and must be held on every call into
84 // the GPU implementation if it is to be used from multiple threads. This
85 // may not be supported with all implementations.
86 virtual void SetLock(base::Lock*) = 0;
88 // Returns true if the channel to the Gpu is lost. When true, all contexts
89 // should be considered as lost.
90 virtual bool IsGpuChannelLost() = 0;
92 private:
93 DISALLOW_COPY_AND_ASSIGN(GpuControl);
96 } // namespace gpu
98 #endif // GPU_COMMAND_BUFFER_CLIENT_GPU_CONTROL_H_