OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef GPU_COMMAND_BUFFER_MAILBOX_H_ | 5 #ifndef GPU_COMMAND_BUFFER_MAILBOX_H_ |
6 #define GPU_COMMAND_BUFFER_MAILBOX_H_ | 6 #define GPU_COMMAND_BUFFER_MAILBOX_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
11 #include "gpu/gpu_export.h" | 11 #include "gpu/gpu_export.h" |
12 | 12 |
13 // From gl2/gl2ext.h. | 13 // From gl2/gl2ext.h. |
14 #ifndef GL_MAILBOX_SIZE_CHROMIUM | 14 #ifndef GL_MAILBOX_SIZE_CHROMIUM |
15 #define GL_MAILBOX_SIZE_CHROMIUM 64 | 15 #define GL_MAILBOX_SIZE_CHROMIUM 64 |
16 #endif | 16 #endif |
17 | 17 |
18 namespace gpu { | 18 namespace gpu { |
19 | 19 |
20 struct GPU_EXPORT Mailbox { | 20 struct GPU_EXPORT Mailbox { |
| 21 using Name = int8_t[GL_MAILBOX_SIZE_CHROMIUM]; |
| 22 |
21 Mailbox(); | 23 Mailbox(); |
22 bool IsZero() const; | 24 bool IsZero() const; |
23 void SetZero(); | 25 void SetZero(); |
24 void SetName(const int8_t* name); | 26 void SetName(const int8_t* name); |
25 | 27 |
26 // Generate a unique unguessable mailbox name. | 28 // Generate a unique unguessable mailbox name. |
27 static Mailbox Generate(); | 29 static Mailbox Generate(); |
28 | 30 |
29 // Verify that the mailbox was created through Mailbox::Generate. This only | 31 // Verify that the mailbox was created through Mailbox::Generate. This only |
30 // works in Debug (always returns true in Release). This is not a secure | 32 // works in Debug (always returns true in Release). This is not a secure |
31 // check, only to catch bugs where clients forgot to call Mailbox::Generate. | 33 // check, only to catch bugs where clients forgot to call Mailbox::Generate. |
32 bool Verify() const; | 34 bool Verify() const; |
33 | 35 |
34 int8_t name[GL_MAILBOX_SIZE_CHROMIUM]; | 36 Name name; |
| 37 |
35 bool operator<(const Mailbox& other) const { | 38 bool operator<(const Mailbox& other) const { |
36 return memcmp(this, &other, sizeof other) < 0; | 39 return memcmp(this, &other, sizeof other) < 0; |
37 } | 40 } |
38 bool operator==(const Mailbox& other) const { | 41 bool operator==(const Mailbox& other) const { |
39 return memcmp(this, &other, sizeof other) == 0; | 42 return memcmp(this, &other, sizeof other) == 0; |
40 } | 43 } |
41 bool operator!=(const Mailbox& other) const { | 44 bool operator!=(const Mailbox& other) const { |
42 return !operator==(other); | 45 return !operator==(other); |
43 } | 46 } |
44 }; | 47 }; |
45 | 48 |
46 } // namespace gpu | 49 } // namespace gpu |
47 | 50 |
48 #endif // GPU_COMMAND_BUFFER_MAILBOX_H_ | 51 #endif // GPU_COMMAND_BUFFER_MAILBOX_H_ |
49 | 52 |
OLD | NEW |