Fix crash in SpeechRecognizerImpl introduced in AudioParams refactor.
[chromium-blink-merge.git] / gpu / command_buffer / common / mailbox.h
blob94d63c53bbeb1af62096e4984ec11aee1f11df31
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.
5 #ifndef GPU_COMMAND_BUFFER_MAILBOX_H_
6 #define GPU_COMMAND_BUFFER_MAILBOX_H_
8 #include <stdint.h>
9 #include <string.h>
11 #include "gpu/gpu_export.h"
13 // From gl2/gl2ext.h.
14 #ifndef GL_MAILBOX_SIZE_CHROMIUM
15 #define GL_MAILBOX_SIZE_CHROMIUM 64
16 #endif
18 namespace gpu {
20 // A mailbox is an unguessable name that references texture image data.
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
23 // set of bytes, optionally with a checksum (in debug mode) to verify the
24 // name is valid.
25 // See src/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_texture_mailbox.txt for more
26 // details.
27 struct GPU_EXPORT Mailbox {
28 using Name = int8_t[GL_MAILBOX_SIZE_CHROMIUM];
30 Mailbox();
31 bool IsZero() const;
32 void SetZero();
33 void SetName(const int8_t* name);
35 // Generate a unique unguessable mailbox name.
36 static Mailbox Generate();
38 // 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
40 // check, only to catch bugs where clients forgot to call Mailbox::Generate.
41 bool Verify() const;
43 Name name;
45 bool operator<(const Mailbox& other) const {
46 return memcmp(this, &other, sizeof other) < 0;
48 bool operator==(const Mailbox& other) const {
49 return memcmp(this, &other, sizeof other) == 0;
51 bool operator!=(const Mailbox& other) const {
52 return !operator==(other);
56 } // namespace gpu
58 #endif // GPU_COMMAND_BUFFER_MAILBOX_H_