[email protected] | bac37fd3 | 2013-08-16 17:31:00 | [diff] [blame] | 1 | // Copyright 2013 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_COMMON_GPU_CONTROL_H_ | ||||
6 | #define GPU_COMMAND_BUFFER_COMMON_GPU_CONTROL_H_ | ||||
7 | |||||
[email protected] | baed42c | 2013-10-01 05:06:35 | [diff] [blame] | 8 | #include <vector> |
9 | |||||
[email protected] | fff7cb3 | 2013-10-02 07:07:37 | [diff] [blame] | 10 | #include "base/callback.h" |
[email protected] | baed42c | 2013-10-01 05:06:35 | [diff] [blame] | 11 | #include "gpu/command_buffer/common/mailbox.h" |
[email protected] | 744e079 | 2013-09-27 01:18:35 | [diff] [blame] | 12 | #include "gpu/command_buffer/common/types.h" |
[email protected] | bac37fd3 | 2013-08-16 17:31:00 | [diff] [blame] | 13 | #include "gpu/gpu_export.h" |
14 | |||||
15 | namespace gfx { | ||||
16 | class GpuMemoryBuffer; | ||||
17 | } | ||||
18 | |||||
19 | namespace gpu { | ||||
[email protected] | f44d555 | 2013-10-29 04:56:29 | [diff] [blame^] | 20 | struct ManagedMemoryStats; |
[email protected] | bac37fd3 | 2013-08-16 17:31:00 | [diff] [blame] | 21 | |
22 | // Common interface for GpuControl implementations. | ||||
23 | class GPU_EXPORT GpuControl { | ||||
24 | public: | ||||
25 | GpuControl() {} | ||||
26 | virtual ~GpuControl() {} | ||||
27 | |||||
[email protected] | 744e079 | 2013-09-27 01:18:35 | [diff] [blame] | 28 | virtual bool SupportsGpuMemoryBuffer() = 0; |
29 | |||||
[email protected] | bac37fd3 | 2013-08-16 17:31:00 | [diff] [blame] | 30 | // Create a gpu memory buffer of the given dimensions and format. Returns |
31 | // its ID or -1 on error. | ||||
32 | virtual gfx::GpuMemoryBuffer* CreateGpuMemoryBuffer( | ||||
33 | size_t width, | ||||
34 | size_t height, | ||||
35 | unsigned internalformat, | ||||
36 | int32* id) = 0; | ||||
37 | |||||
38 | // Destroy a gpu memory buffer. The ID must be positive. | ||||
39 | virtual void DestroyGpuMemoryBuffer(int32 id) = 0; | ||||
40 | |||||
[email protected] | baed42c | 2013-10-01 05:06:35 | [diff] [blame] | 41 | // Generates n unique mailbox names that can be used with |
42 | // GL_texture_mailbox_CHROMIUM. | ||||
43 | virtual bool GenerateMailboxNames(unsigned num, | ||||
44 | std::vector<gpu::Mailbox>* names) = 0; | ||||
45 | |||||
[email protected] | fff7cb3 | 2013-10-02 07:07:37 | [diff] [blame] | 46 | // Inserts a sync point, returning its ID. Sync point IDs are global and can |
47 | // be used for cross-context synchronization. | ||||
48 | virtual uint32 InsertSyncPoint() = 0; | ||||
49 | |||||
50 | // Runs |callback| when a sync point is reached. | ||||
51 | virtual void SignalSyncPoint(uint32 sync_point, | ||||
52 | const base::Closure& callback) = 0; | ||||
53 | |||||
[email protected] | b88a48cc | 2013-10-05 05:10:10 | [diff] [blame] | 54 | // Runs |callback| when a query created via glCreateQueryEXT() has cleared |
55 | // passed the glEndQueryEXT() point. | ||||
56 | virtual void SignalQuery(uint32 query, const base::Closure& callback) = 0; | ||||
57 | |||||
[email protected] | f44d555 | 2013-10-29 04:56:29 | [diff] [blame^] | 58 | virtual void SendManagedMemoryStats(const ManagedMemoryStats& stats) = 0; |
59 | |||||
[email protected] | bac37fd3 | 2013-08-16 17:31:00 | [diff] [blame] | 60 | private: |
61 | DISALLOW_COPY_AND_ASSIGN(GpuControl); | ||||
62 | }; | ||||
63 | |||||
64 | } // namespace gpu | ||||
65 | |||||
66 | #endif // GPU_COMMAND_BUFFER_COMMON_GPU_CONTROL_H_ |