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_
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"
19 class GpuMemoryBuffer;
23 struct ManagedMemoryStats;
25 // Common interface for GpuControl implementations.
26 class GPU_EXPORT GpuControl {
29 virtual ~GpuControl() {}
31 virtual Capabilities GetCapabilities() = 0;
33 // Create a gpu memory buffer of the given dimensions and format. Returns
34 // its ID or -1 on error.
35 virtual gfx::GpuMemoryBuffer* CreateGpuMemoryBuffer(
38 unsigned internalformat,
42 // Destroy a gpu memory buffer. The ID must be positive.
43 virtual void DestroyGpuMemoryBuffer(int32_t id) = 0;
45 // Inserts a sync point, returning its ID. Sync point IDs are global and can
46 // be used for cross-context synchronization.
47 virtual uint32_t InsertSyncPoint() = 0;
49 // Runs |callback| when a sync point is reached.
50 virtual void SignalSyncPoint(uint32_t sync_point,
51 const base::Closure& callback) = 0;
53 // Runs |callback| when a query created via glCreateQueryEXT() has cleared
54 // passed the glEndQueryEXT() point.
55 virtual void SignalQuery(uint32_t query, const base::Closure& callback) = 0;
57 virtual void SetSurfaceVisible(bool visible) = 0;
59 virtual void SendManagedMemoryStats(const ManagedMemoryStats& stats) = 0;
61 // Invokes the callback once the context has been flushed.
62 virtual void Echo(const base::Closure& callback) = 0;
64 // Attaches an external stream to the texture given by |texture_id| and
65 // returns a stream identifier.
66 virtual uint32_t CreateStreamTexture(uint32_t texture_id) = 0;
69 DISALLOW_COPY_AND_ASSIGN(GpuControl);
74 #endif // GPU_COMMAND_BUFFER_CLIENT_GPU_CONTROL_H_