| 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 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // This name can be passed across processes permitting one context to share | 21 // This name can be passed across processes permitting one context to share |
| 22 // texture image data with another. The mailbox name consists of a random | 22 // texture image data with another. The mailbox name consists of a random |
| 23 // set of bytes, optionally with a checksum (in debug mode) to verify the | 23 // set of bytes, optionally with a checksum (in debug mode) to verify the |
| 24 // name is valid. | 24 // name is valid. |
| 25 // See src/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_texture_mailbox.txt for more | 25 // See src/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_texture_mailbox.txt for more |
| 26 // details. | 26 // details. |
| 27 struct GPU_EXPORT Mailbox { | 27 struct GPU_EXPORT Mailbox { |
| 28 using Name = int8_t[GL_MAILBOX_SIZE_CHROMIUM]; | 28 using Name = int8_t[GL_MAILBOX_SIZE_CHROMIUM]; |
| 29 | 29 |
| 30 Mailbox(); | 30 Mailbox(); |
| 31 |
| 32 static Mailbox FromVolatile(const volatile Mailbox& other) { |
| 33 // Because the copy constructor is trivial, const_cast is safe. |
| 34 return const_cast<const Mailbox&>(other); |
| 35 } |
| 36 |
| 31 bool IsZero() const; | 37 bool IsZero() const; |
| 32 void SetZero(); | 38 void SetZero(); |
| 33 void SetName(const int8_t* name); | 39 void SetName(const int8_t* name); |
| 34 | 40 |
| 35 // Generate a unique unguessable mailbox name. | 41 // Generate a unique unguessable mailbox name. |
| 36 static Mailbox Generate(); | 42 static Mailbox Generate(); |
| 37 | 43 |
| 38 // Verify that the mailbox was created through Mailbox::Generate. This only | 44 // Verify that the mailbox was created through Mailbox::Generate. This only |
| 39 // works in Debug (always returns true in Release). This is not a secure | 45 // works in Debug (always returns true in Release). This is not a secure |
| 40 // check, only to catch bugs where clients forgot to call Mailbox::Generate. | 46 // check, only to catch bugs where clients forgot to call Mailbox::Generate. |
| 41 bool Verify() const; | 47 bool Verify() const; |
| 42 | 48 |
| 43 Name name; | 49 Name name; |
| 44 | 50 |
| 45 bool operator<(const Mailbox& other) const { | 51 bool operator<(const Mailbox& other) const { |
| 46 return memcmp(this, &other, sizeof other) < 0; | 52 return memcmp(this, &other, sizeof other) < 0; |
| 47 } | 53 } |
| 48 bool operator==(const Mailbox& other) const { | 54 bool operator==(const Mailbox& other) const { |
| 49 return memcmp(this, &other, sizeof other) == 0; | 55 return memcmp(this, &other, sizeof other) == 0; |
| 50 } | 56 } |
| 51 bool operator!=(const Mailbox& other) const { | 57 bool operator!=(const Mailbox& other) const { |
| 52 return !operator==(other); | 58 return !operator==(other); |
| 53 } | 59 } |
| 54 }; | 60 }; |
| 55 | 61 |
| 56 } // namespace gpu | 62 } // namespace gpu |
| 57 | 63 |
| 58 #endif // GPU_COMMAND_BUFFER_MAILBOX_H_ | 64 #endif // GPU_COMMAND_BUFFER_MAILBOX_H_ |
| 59 | 65 |
| OLD | NEW |