summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-15 14:22:37 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-15 14:22:37 +0000
commit64ba52f03b2936af0e6b924417ca8f29958b473e (patch)
tree62d4f2e60903550e97c618f9074ec92340bfe3f2 /gpu
parentb5641b965afa45a0c0a1e85a669935e9150ec9f0 (diff)
downloadchromium_src-64ba52f03b2936af0e6b924417ca8f29958b473e.zip
chromium_src-64ba52f03b2936af0e6b924417ca8f29958b473e.tar.gz
chromium_src-64ba52f03b2936af0e6b924417ca8f29958b473e.tar.bz2
gpu: Generate mailboxes on client side
Because mailboxes are now just a random number, we don't need to round-trip to the gpu process to generate them, which lets us get rid of IPCs, layers, etc. It also means generating a mailbox can't fail any more (even on a lost context), so, removing some code paths and associated tests. I'm adding a debug-only verification to ensure the mailboxes are generated from the crypto-random function (in debug, we burn a byte to compute a mini XOR-check as a sentinel for "we went through the Generate function"). It's not a secure check, but should hit incorrect/unsafe usage. BUG=None Review URL: https://codereview.chromium.org/165393003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251570 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rwxr-xr-xgpu/command_buffer/build_gles2_cmd_buffer.py10
-rw-r--r--gpu/command_buffer/client/client_test_helper.h2
-rw-r--r--gpu/command_buffer/client/gles2_implementation.cc34
-rw-r--r--gpu/command_buffer/client/gles2_implementation_impl_autogen.h18
-rw-r--r--gpu/command_buffer/client/gles2_implementation_unittest.cc25
-rw-r--r--gpu/command_buffer/client/gles2_implementation_unittest_autogen.h32
-rw-r--r--gpu/command_buffer/common/gpu_control.h5
-rw-r--r--gpu/command_buffer/common/mailbox.cc25
-rw-r--r--gpu/command_buffer/common/mailbox.h9
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc27
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc3
-rw-r--r--gpu/command_buffer/service/gpu_control_service.cc9
-rw-r--r--gpu/command_buffer/service/gpu_control_service.h2
-rw-r--r--gpu/command_buffer/service/in_process_command_buffer.cc7
-rw-r--r--gpu/command_buffer/service/in_process_command_buffer.h2
-rw-r--r--gpu/command_buffer/service/mailbox_manager.cc4
-rw-r--r--gpu/command_buffer/service/mailbox_manager.h3
-rw-r--r--gpu/command_buffer/service/mailbox_manager_unittest.cc18
-rw-r--r--gpu/command_buffer/tests/gl_texture_mailbox_unittest.cc1
19 files changed, 119 insertions, 117 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py
index 23dacf1..8e779e3 100755
--- a/gpu/command_buffer/build_gles2_cmd_buffer.py
+++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -1325,10 +1325,12 @@ _FUNCTION_INFO = {
},
'ConsumeTextureCHROMIUM': {
'decoder_func': 'DoConsumeTextureCHROMIUM',
+ 'impl_func': False,
'type': 'PUT',
'data_type': 'GLbyte',
'count': 64, # GL_MAILBOX_SIZE_CHROMIUM
'unit_test': False,
+ 'client_test': False,
'extension': True,
'chromium': True,
'trace_level': 1,
@@ -1908,10 +1910,12 @@ _FUNCTION_INFO = {
},
'ProduceTextureCHROMIUM': {
'decoder_func': 'DoProduceTextureCHROMIUM',
+ 'impl_func': False,
'type': 'PUT',
'data_type': 'GLbyte',
'count': 64, # GL_MAILBOX_SIZE_CHROMIUM
'unit_test': False,
+ 'client_test': False,
'extension': True,
'chromium': True,
'trace_level': 1,
@@ -4790,6 +4794,9 @@ TEST_F(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
def WriteGLES2Implementation(self, func, file):
"""Overrriden from TypeHandler."""
+ impl_func = func.GetInfo('impl_func')
+ if (impl_func != None and impl_func != True):
+ return;
file.Write("%s GLES2Implementation::%s(%s) {\n" %
(func.return_type, func.original_name,
func.MakeTypedOriginalArgString("")))
@@ -4810,6 +4817,9 @@ TEST_F(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
def WriteGLES2ImplementationUnitTest(self, func, file):
"""Writes the GLES2 Implemention unit test."""
+ client_test = func.GetInfo('client_test')
+ if (client_test != None and client_test != True):
+ return;
code = """
TEST_F(GLES2ImplementationTest, %(name)s) {
%(type)s data[%(count)d] = {0};
diff --git a/gpu/command_buffer/client/client_test_helper.h b/gpu/command_buffer/client/client_test_helper.h
index c6d6e02..88c37e8 100644
--- a/gpu/command_buffer/client/client_test_helper.h
+++ b/gpu/command_buffer/client/client_test_helper.h
@@ -94,8 +94,6 @@ class MockClientGpuControl : public GpuControl {
unsigned internalformat,
int32* id));
MOCK_METHOD1(DestroyGpuMemoryBuffer, void(int32 id));
- MOCK_METHOD2(GenerateMailboxNames, bool(unsigned num,
- std::vector<gpu::Mailbox>* names));
MOCK_METHOD0(InsertSyncPoint, uint32());
MOCK_METHOD2(SignalSyncPoint, void(uint32 id,
const base::Closure& callback));
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc
index b99b332..9275a49 100644
--- a/gpu/command_buffer/client/gles2_implementation.cc
+++ b/gpu/command_buffer/client/gles2_implementation.cc
@@ -3472,12 +3472,34 @@ void GLES2Implementation::GenMailboxCHROMIUM(
<< static_cast<const void*>(mailbox) << ")");
TRACE_EVENT0("gpu", "GLES2::GenMailboxCHROMIUM");
- std::vector<gpu::Mailbox> names;
- if (!gpu_control_->GenerateMailboxNames(1, &names)) {
- SetGLError(GL_OUT_OF_MEMORY, "glGenMailboxCHROMIUM", "Generate failed.");
- return;
- }
- memcpy(mailbox, names[0].name, GL_MAILBOX_SIZE_CHROMIUM);
+ gpu::Mailbox result = gpu::Mailbox::Generate();
+ memcpy(mailbox, result.name, sizeof(result.name));
+}
+
+void GLES2Implementation::ProduceTextureCHROMIUM(GLenum target,
+ const GLbyte* data) {
+ GPU_CLIENT_SINGLE_THREAD_CHECK();
+ GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glProduceTextureCHROMIUM("
+ << static_cast<const void*>(data) << ")");
+ const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data);
+ DCHECK(mailbox.Verify()) << "ProduceTextureCHROMIUM was passed a "
+ "mailbox that was not generated by "
+ "GenMailboxCHROMIUM.";
+ helper_->ProduceTextureCHROMIUMImmediate(target, data);
+ CheckGLError();
+}
+
+void GLES2Implementation::ConsumeTextureCHROMIUM(GLenum target,
+ const GLbyte* data) {
+ GPU_CLIENT_SINGLE_THREAD_CHECK();
+ GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glConsumeTextureCHROMIUM("
+ << static_cast<const void*>(data) << ")");
+ const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data);
+ DCHECK(mailbox.Verify()) << "ConsumeTextureCHROMIUM was passed a "
+ "mailbox that was not generated by "
+ "GenMailboxCHROMIUM.";
+ helper_->ConsumeTextureCHROMIUMImmediate(target, data);
+ CheckGLError();
}
void GLES2Implementation::PushGroupMarkerEXT(
diff --git a/gpu/command_buffer/client/gles2_implementation_impl_autogen.h b/gpu/command_buffer/client/gles2_implementation_impl_autogen.h
index 9dba99f..11c1df0 100644
--- a/gpu/command_buffer/client/gles2_implementation_impl_autogen.h
+++ b/gpu/command_buffer/client/gles2_implementation_impl_autogen.h
@@ -1678,24 +1678,6 @@ void GLES2Implementation::CopyTextureCHROMIUM(
CheckGLError();
}
-void GLES2Implementation::ProduceTextureCHROMIUM(
- GLenum target, const GLbyte* mailbox) {
- GPU_CLIENT_SINGLE_THREAD_CHECK();
- GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glProduceTextureCHROMIUM(" << GLES2Util::GetStringTextureBindTarget(target) << ", " << static_cast<const void*>(mailbox) << ")"); // NOLINT
- GPU_CLIENT_LOG("values: " << mailbox[0] << ", " << mailbox[1] << ", " << mailbox[2] << ", " << mailbox[3] << ", " << mailbox[4] << ", " << mailbox[5] << ", " << mailbox[6] << ", " << mailbox[7] << ", " << mailbox[8] << ", " << mailbox[9] << ", " << mailbox[10] << ", " << mailbox[11] << ", " << mailbox[12] << ", " << mailbox[13] << ", " << mailbox[14] << ", " << mailbox[15] << ", " << mailbox[16] << ", " << mailbox[17] << ", " << mailbox[18] << ", " << mailbox[19] << ", " << mailbox[20] << ", " << mailbox[21] << ", " << mailbox[22] << ", " << mailbox[23] << ", " << mailbox[24] << ", " << mailbox[25] << ", " << mailbox[26] << ", " << mailbox[27] << ", " << mailbox[28] << ", " << mailbox[29] << ", " << mailbox[30] << ", " << mailbox[31] << ", " << mailbox[32] << ", " << mailbox[33] << ", " << mailbox[34] << ", " << mailbox[35] << ", " << mailbox[36] << ", " << mailbox[37] << ", " << mailbox[38] << ", " << mailbox[39] << ", " << mailbox[40] << ", " << mailbox[41] << ", " << mailbox[42] << ", " << mailbox[43] << ", " << mailbox[44] << ", " << mailbox[45] << ", " << mailbox[46] << ", " << mailbox[47] << ", " << mailbox[48] << ", " << mailbox[49] << ", " << mailbox[50] << ", " << mailbox[51] << ", " << mailbox[52] << ", " << mailbox[53] << ", " << mailbox[54] << ", " << mailbox[55] << ", " << mailbox[56] << ", " << mailbox[57] << ", " << mailbox[58] << ", " << mailbox[59] << ", " << mailbox[60] << ", " << mailbox[61] << ", " << mailbox[62] << ", " << mailbox[63]); // NOLINT
- helper_->ProduceTextureCHROMIUMImmediate(target, mailbox);
- CheckGLError();
-}
-
-void GLES2Implementation::ConsumeTextureCHROMIUM(
- GLenum target, const GLbyte* mailbox) {
- GPU_CLIENT_SINGLE_THREAD_CHECK();
- GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glConsumeTextureCHROMIUM(" << GLES2Util::GetStringTextureBindTarget(target) << ", " << static_cast<const void*>(mailbox) << ")"); // NOLINT
- GPU_CLIENT_LOG("values: " << mailbox[0] << ", " << mailbox[1] << ", " << mailbox[2] << ", " << mailbox[3] << ", " << mailbox[4] << ", " << mailbox[5] << ", " << mailbox[6] << ", " << mailbox[7] << ", " << mailbox[8] << ", " << mailbox[9] << ", " << mailbox[10] << ", " << mailbox[11] << ", " << mailbox[12] << ", " << mailbox[13] << ", " << mailbox[14] << ", " << mailbox[15] << ", " << mailbox[16] << ", " << mailbox[17] << ", " << mailbox[18] << ", " << mailbox[19] << ", " << mailbox[20] << ", " << mailbox[21] << ", " << mailbox[22] << ", " << mailbox[23] << ", " << mailbox[24] << ", " << mailbox[25] << ", " << mailbox[26] << ", " << mailbox[27] << ", " << mailbox[28] << ", " << mailbox[29] << ", " << mailbox[30] << ", " << mailbox[31] << ", " << mailbox[32] << ", " << mailbox[33] << ", " << mailbox[34] << ", " << mailbox[35] << ", " << mailbox[36] << ", " << mailbox[37] << ", " << mailbox[38] << ", " << mailbox[39] << ", " << mailbox[40] << ", " << mailbox[41] << ", " << mailbox[42] << ", " << mailbox[43] << ", " << mailbox[44] << ", " << mailbox[45] << ", " << mailbox[46] << ", " << mailbox[47] << ", " << mailbox[48] << ", " << mailbox[49] << ", " << mailbox[50] << ", " << mailbox[51] << ", " << mailbox[52] << ", " << mailbox[53] << ", " << mailbox[54] << ", " << mailbox[55] << ", " << mailbox[56] << ", " << mailbox[57] << ", " << mailbox[58] << ", " << mailbox[59] << ", " << mailbox[60] << ", " << mailbox[61] << ", " << mailbox[62] << ", " << mailbox[63]); // NOLINT
- helper_->ConsumeTextureCHROMIUMImmediate(target, mailbox);
- CheckGLError();
-}
-
void GLES2Implementation::BindTexImage2DCHROMIUM(
GLenum target, GLint imageId) {
GPU_CLIENT_SINGLE_THREAD_CHECK();
diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc
index 6103309..b6803ba 100644
--- a/gpu/command_buffer/client/gles2_implementation_unittest.cc
+++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc
@@ -2845,6 +2845,31 @@ TEST_F(GLES2ImplementationTest, Enable) {
EXPECT_TRUE(NoCommandsWritten());
}
+TEST_F(GLES2ImplementationTest, ConsumeTextureCHROMIUM) {
+ struct Cmds {
+ cmds::ConsumeTextureCHROMIUMImmediate cmd;
+ GLbyte data[64];
+ };
+
+ Mailbox mailbox = Mailbox::Generate();
+ Cmds expected;
+ expected.cmd.Init(GL_TEXTURE_2D, mailbox.name);
+ gl_->ConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
+ EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
+}
+
+TEST_F(GLES2ImplementationTest, ProduceTextureCHROMIUM) {
+ struct Cmds {
+ cmds::ProduceTextureCHROMIUMImmediate cmd;
+ GLbyte data[64];
+ };
+
+ Mailbox mailbox = Mailbox::Generate();
+ Cmds expected;
+ expected.cmd.Init(GL_TEXTURE_2D, mailbox.name);
+ gl_->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
+ EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
+}
#include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h"
diff --git a/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h b/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h
index 6cefd1d..172b1b3 100644
--- a/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h
+++ b/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h
@@ -1738,38 +1738,6 @@ TEST_F(GLES2ImplementationTest, VertexAttribDivisorANGLE) {
EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
}
// TODO: Implement unit test for GenMailboxCHROMIUM
-
-TEST_F(GLES2ImplementationTest, ProduceTextureCHROMIUM) {
- GLbyte data[64] = {0};
- struct Cmds {
- cmds::ProduceTextureCHROMIUMImmediate cmd;
- GLbyte data[64];
- };
-
- for (int jj = 0; jj < 64; ++jj) {
- data[jj] = static_cast<GLbyte>(jj);
- }
- Cmds expected;
- expected.cmd.Init(GL_TEXTURE_2D, &data[0]);
- gl_->ProduceTextureCHROMIUM(GL_TEXTURE_2D, &data[0]);
- EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
-}
-
-TEST_F(GLES2ImplementationTest, ConsumeTextureCHROMIUM) {
- GLbyte data[64] = {0};
- struct Cmds {
- cmds::ConsumeTextureCHROMIUMImmediate cmd;
- GLbyte data[64];
- };
-
- for (int jj = 0; jj < 64; ++jj) {
- data[jj] = static_cast<GLbyte>(jj);
- }
- Cmds expected;
- expected.cmd.Init(GL_TEXTURE_2D, &data[0]);
- gl_->ConsumeTextureCHROMIUM(GL_TEXTURE_2D, &data[0]);
- EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
-}
// TODO: Implement unit test for BindUniformLocationCHROMIUM
TEST_F(GLES2ImplementationTest, BindTexImage2DCHROMIUM) {
diff --git a/gpu/command_buffer/common/gpu_control.h b/gpu/command_buffer/common/gpu_control.h
index 448ab1d..e15d5e6 100644
--- a/gpu/command_buffer/common/gpu_control.h
+++ b/gpu/command_buffer/common/gpu_control.h
@@ -39,11 +39,6 @@ class GPU_EXPORT GpuControl {
// Destroy a gpu memory buffer. The ID must be positive.
virtual void DestroyGpuMemoryBuffer(int32 id) = 0;
- // Generates n unique mailbox names that can be used with
- // GL_texture_mailbox_CHROMIUM.
- virtual bool GenerateMailboxNames(unsigned num,
- std::vector<gpu::Mailbox>* names) = 0;
-
// Inserts a sync point, returning its ID. Sync point IDs are global and can
// be used for cross-context synchronization.
virtual uint32 InsertSyncPoint() = 0;
diff --git a/gpu/command_buffer/common/mailbox.cc b/gpu/command_buffer/common/mailbox.cc
index 8d8393f..21602ab 100644
--- a/gpu/command_buffer/common/mailbox.cc
+++ b/gpu/command_buffer/common/mailbox.cc
@@ -7,6 +7,7 @@
#include <string.h>
#include "base/logging.h"
+#include "base/rand_util.h"
namespace gpu {
@@ -31,4 +32,28 @@ void Mailbox::SetName(const int8* n) {
memcpy(name, n, sizeof(name));
}
+Mailbox Mailbox::Generate() {
+ Mailbox result;
+ // Generates cryptographically-secure bytes.
+ base::RandBytes(result.name, sizeof(result.name));
+#if !defined(NDEBUG)
+ int8 value = 1;
+ for (size_t i = 1; i < sizeof(result.name); ++i)
+ value ^= result.name[i];
+ result.name[0] = value;
+#endif
+ return result;
+}
+
+bool Mailbox::Verify() const {
+#if !defined(NDEBUG)
+ int8 value = 1;
+ for (size_t i = 0; i < sizeof(name); ++i)
+ value ^= name[i];
+ return value == 0;
+#else
+ return true;
+#endif
+}
+
} // namespace gpu
diff --git a/gpu/command_buffer/common/mailbox.h b/gpu/command_buffer/common/mailbox.h
index 08a970f..06b4b59 100644
--- a/gpu/command_buffer/common/mailbox.h
+++ b/gpu/command_buffer/common/mailbox.h
@@ -22,6 +22,15 @@ struct GPU_EXPORT Mailbox {
bool IsZero() const;
void SetZero();
void SetName(const int8* name);
+
+ // Generate a unique unguessable mailbox name.
+ static Mailbox Generate();
+
+ // Verify that the mailbox was created through Mailbox::Generate. This only
+ // works in Debug (always returns true in Release). This is not a secure
+ // check, only to catch bugs where clients forgot to call Mailbox::Generate.
+ bool Verify() const;
+
int8 name[GL_MAILBOX_SIZE_CHROMIUM];
bool operator<(const Mailbox& other) const {
return memcmp(this, &other, sizeof other) < 0;
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 414ecc6..ffa66ed 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -10005,10 +10005,15 @@ error::Error GLES2DecoderImpl::HandleGenMailboxCHROMIUM(
}
void GLES2DecoderImpl::DoProduceTextureCHROMIUM(GLenum target,
- const GLbyte* mailbox) {
+ const GLbyte* data) {
TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoProduceTextureCHROMIUM",
"context", logger_.GetLogPrefix(),
- "mailbox[0]", static_cast<unsigned char>(mailbox[0]));
+ "mailbox[0]", static_cast<unsigned char>(data[0]));
+
+ const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data);
+ DLOG_IF(ERROR, !mailbox.Verify()) << "ProduceTextureCHROMIUM was passed a "
+ "mailbox that was not generated by "
+ "GenMailboxCHROMIUM.";
TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget(
&state_, target);
@@ -10027,17 +10032,18 @@ void GLES2DecoderImpl::DoProduceTextureCHROMIUM(GLenum target,
return;
}
- group_->mailbox_manager()->ProduceTexture(
- target,
- *reinterpret_cast<const Mailbox*>(mailbox),
- produced);
+ group_->mailbox_manager()->ProduceTexture(target, mailbox, produced);
}
void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target,
- const GLbyte* mailbox) {
+ const GLbyte* data) {
TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoConsumeTextureCHROMIUM",
"context", logger_.GetLogPrefix(),
- "mailbox[0]", static_cast<unsigned char>(mailbox[0]));
+ "mailbox[0]", static_cast<unsigned char>(data[0]));
+ const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data);
+ DLOG_IF(ERROR, !mailbox.Verify()) << "ConsumeTextureCHROMIUM was passed a "
+ "mailbox that was not generated by "
+ "GenMailboxCHROMIUM.";
scoped_refptr<TextureRef> texture_ref =
texture_manager()->GetTextureInfoForTargetUnlessDefault(&state_, target);
@@ -10054,10 +10060,7 @@ void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target,
"glConsumeTextureCHROMIUM", "unknown texture for target");
return;
}
- Texture* texture =
- group_->mailbox_manager()->ConsumeTexture(
- target,
- *reinterpret_cast<const Mailbox*>(mailbox));
+ Texture* texture = group_->mailbox_manager()->ConsumeTexture(target, mailbox);
if (!texture) {
LOCAL_SET_GL_ERROR(
GL_INVALID_OPERATION,
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
index 4d1c77e..e7187d0 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
@@ -7071,8 +7071,7 @@ TEST_F(GLES2DecoderTest, BeginEndQueryEXTGetErrorQueryCHROMIUM) {
}
TEST_F(GLES2DecoderTest, ProduceAndConsumeTextureCHROMIUM) {
- Mailbox mailbox;
- group().mailbox_manager()->GenerateMailbox(&mailbox);
+ Mailbox mailbox = Mailbox::Generate();
memcpy(shared_memory_address_, mailbox.name, sizeof(mailbox.name));
diff --git a/gpu/command_buffer/service/gpu_control_service.cc b/gpu/command_buffer/service/gpu_control_service.cc
index 9a198e6..893b872 100644
--- a/gpu/command_buffer/service/gpu_control_service.cc
+++ b/gpu/command_buffer/service/gpu_control_service.cc
@@ -123,13 +123,4 @@ bool GpuControlService::RegisterGpuMemoryBuffer(
internalformat);
}
-bool GpuControlService::GenerateMailboxNames(
- unsigned num, std::vector<gpu::Mailbox>* names) {
- DCHECK(names->empty());
- names->resize(num);
- for (unsigned i = 0; i < num; ++i)
- mailbox_manager_->GenerateMailbox(&(*names)[i]);
- return true;
-}
-
} // namespace gpu
diff --git a/gpu/command_buffer/service/gpu_control_service.h b/gpu/command_buffer/service/gpu_control_service.h
index 9e36f15..74fd4d5 100644
--- a/gpu/command_buffer/service/gpu_control_service.h
+++ b/gpu/command_buffer/service/gpu_control_service.h
@@ -38,8 +38,6 @@ class GPU_EXPORT GpuControlService : public GpuControl {
unsigned internalformat,
int32* id) OVERRIDE;
virtual void DestroyGpuMemoryBuffer(int32 id) OVERRIDE;
- virtual bool GenerateMailboxNames(unsigned num,
- std::vector<gpu::Mailbox>* names) OVERRIDE;
virtual uint32 InsertSyncPoint() OVERRIDE;
virtual void SignalSyncPoint(uint32 sync_point,
const base::Closure& callback) OVERRIDE;
diff --git a/gpu/command_buffer/service/in_process_command_buffer.cc b/gpu/command_buffer/service/in_process_command_buffer.cc
index ba469ee..5bc7ded 100644
--- a/gpu/command_buffer/service/in_process_command_buffer.cc
+++ b/gpu/command_buffer/service/in_process_command_buffer.cc
@@ -551,13 +551,6 @@ void InProcessCommandBuffer::DestroyGpuMemoryBuffer(int32 id) {
QueueTask(task);
}
-bool InProcessCommandBuffer::GenerateMailboxNames(
- unsigned num, std::vector<gpu::Mailbox>* names) {
- CheckSequencedThread();
- base::AutoLock lock(command_buffer_lock_);
- return gpu_control_->GenerateMailboxNames(num, names);
-}
-
uint32 InProcessCommandBuffer::InsertSyncPoint() {
return 0;
}
diff --git a/gpu/command_buffer/service/in_process_command_buffer.h b/gpu/command_buffer/service/in_process_command_buffer.h
index e469f78..199a294 100644
--- a/gpu/command_buffer/service/in_process_command_buffer.h
+++ b/gpu/command_buffer/service/in_process_command_buffer.h
@@ -104,8 +104,6 @@ class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer,
unsigned internalformat,
int32* id) OVERRIDE;
virtual void DestroyGpuMemoryBuffer(int32 id) OVERRIDE;
- virtual bool GenerateMailboxNames(unsigned num,
- std::vector<gpu::Mailbox>* names) OVERRIDE;
virtual uint32 InsertSyncPoint() OVERRIDE;
virtual void SignalSyncPoint(uint32 sync_point,
const base::Closure& callback) OVERRIDE;
diff --git a/gpu/command_buffer/service/mailbox_manager.cc b/gpu/command_buffer/service/mailbox_manager.cc
index e2fb86f..c337b48 100644
--- a/gpu/command_buffer/service/mailbox_manager.cc
+++ b/gpu/command_buffer/service/mailbox_manager.cc
@@ -21,10 +21,6 @@ MailboxManager::~MailboxManager() {
DCHECK(textures_to_mailboxes_.empty());
}
-void MailboxManager::GenerateMailbox(Mailbox* mailbox) {
- crypto::RandBytes(mailbox->name, sizeof(mailbox->name));
-}
-
Texture* MailboxManager::ConsumeTexture(unsigned target,
const Mailbox& mailbox) {
MailboxToTextureMap::iterator it =
diff --git a/gpu/command_buffer/service/mailbox_manager.h b/gpu/command_buffer/service/mailbox_manager.h
index 453863b..a231979 100644
--- a/gpu/command_buffer/service/mailbox_manager.h
+++ b/gpu/command_buffer/service/mailbox_manager.h
@@ -27,9 +27,6 @@ class GPU_EXPORT MailboxManager : public base::RefCounted<MailboxManager> {
public:
MailboxManager();
- // Generate a unique unguessable mailbox name.
- void GenerateMailbox(Mailbox* mailbox);
-
// Look up the texture definition from the named mailbox.
Texture* ConsumeTexture(unsigned target, const Mailbox& mailbox);
diff --git a/gpu/command_buffer/service/mailbox_manager_unittest.cc b/gpu/command_buffer/service/mailbox_manager_unittest.cc
index 9e1ff6b..f7a4155 100644
--- a/gpu/command_buffer/service/mailbox_manager_unittest.cc
+++ b/gpu/command_buffer/service/mailbox_manager_unittest.cc
@@ -34,8 +34,7 @@ class MailboxManagerTest : public testing::Test {
TEST_F(MailboxManagerTest, Basic) {
Texture* texture = CreateTexture();
- Mailbox name;
- manager_->GenerateMailbox(&name);
+ Mailbox name = Mailbox::Generate();
manager_->ProduceTexture(0, name, texture);
EXPECT_EQ(texture, manager_->ConsumeTexture(0, name));
@@ -54,8 +53,7 @@ TEST_F(MailboxManagerTest, Basic) {
TEST_F(MailboxManagerTest, ProduceMultipleMailbox) {
Texture* texture = CreateTexture();
- Mailbox name1;
- manager_->GenerateMailbox(&name1);
+ Mailbox name1 = Mailbox::Generate();
manager_->ProduceTexture(0, name1, texture);
EXPECT_EQ(texture, manager_->ConsumeTexture(0, name1));
@@ -65,8 +63,7 @@ TEST_F(MailboxManagerTest, ProduceMultipleMailbox) {
EXPECT_EQ(texture, manager_->ConsumeTexture(0, name1));
// Can produce again, with a different mailbox.
- Mailbox name2;
- manager_->GenerateMailbox(&name2);
+ Mailbox name2 = Mailbox::Generate();
manager_->ProduceTexture(0, name2, texture);
// Still available under all mailboxes.
@@ -85,8 +82,7 @@ TEST_F(MailboxManagerTest, ProduceMultipleTexture) {
Texture* texture1 = CreateTexture();
Texture* texture2 = CreateTexture();
- Mailbox name;
- manager_->GenerateMailbox(&name);
+ Mailbox name = Mailbox::Generate();
manager_->ProduceTexture(0, name, texture1);
EXPECT_EQ(texture1, manager_->ConsumeTexture(0, name));
@@ -107,10 +103,8 @@ TEST_F(MailboxManagerTest, ProduceMultipleTexture) {
TEST_F(MailboxManagerTest, ProduceMultipleTextureMailbox) {
Texture* texture1 = CreateTexture();
Texture* texture2 = CreateTexture();
- Mailbox name1;
- manager_->GenerateMailbox(&name1);
- Mailbox name2;
- manager_->GenerateMailbox(&name2);
+ Mailbox name1 = Mailbox::Generate();
+ Mailbox name2 = Mailbox::Generate();
// Put texture1 on name1 and name2.
manager_->ProduceTexture(0, name1, texture1);
diff --git a/gpu/command_buffer/tests/gl_texture_mailbox_unittest.cc b/gpu/command_buffer/tests/gl_texture_mailbox_unittest.cc
index 50a3bbc..ba3324d 100644
--- a/gpu/command_buffer/tests/gl_texture_mailbox_unittest.cc
+++ b/gpu/command_buffer/tests/gl_texture_mailbox_unittest.cc
@@ -130,7 +130,6 @@ TEST_F(GLTextureMailboxTest, ConsumeTextureValidatesKey) {
GLbyte invalid_mailbox[GL_MAILBOX_SIZE_CHROMIUM];
glGenMailboxCHROMIUM(invalid_mailbox);
- ++invalid_mailbox[GL_MAILBOX_SIZE_CHROMIUM - 1];
EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
glConsumeTextureCHROMIUM(GL_TEXTURE_2D, invalid_mailbox);