Chromium Code Reviews| Index: content/common/gpu/texture_image_transport_surface.cc |
| diff --git a/content/common/gpu/texture_image_transport_surface.cc b/content/common/gpu/texture_image_transport_surface.cc |
| index a40b60df36e7bc9c505f4483869a54e395342d41..bb48b818a93ff0a203ee2167bdcd05b9295a20a5 100644 |
| --- a/content/common/gpu/texture_image_transport_surface.cc |
| +++ b/content/common/gpu/texture_image_transport_surface.cc |
| @@ -214,9 +214,7 @@ bool TextureImageTransportSurface::SwapBuffers() { |
| DCHECK(backbuffer_.size == current_size_); |
| GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
| params.size = backbuffer_.size; |
| - const MailboxName& name = backbuffer_.mailbox_name; |
| - params.mailbox_name.assign( |
| - reinterpret_cast<const char*>(&name), sizeof(name)); |
| + params.mailbox_name = backbuffer_.mailbox_name; |
| glFlush(); |
| ProduceTexture(&backbuffer_); |
| @@ -256,9 +254,7 @@ bool TextureImageTransportSurface::PostSubBuffer( |
| params.y = y; |
| params.width = width; |
| params.height = height; |
| - const MailboxName& name = backbuffer_.mailbox_name; |
| - params.mailbox_name.assign( |
| - reinterpret_cast<const char*>(&name), sizeof(name)); |
| + params.mailbox_name = backbuffer_.mailbox_name; |
| glFlush(); |
| ProduceTexture(&backbuffer_); |
| @@ -316,12 +312,10 @@ void TextureImageTransportSurface::OnBufferPresented( |
| } |
| void TextureImageTransportSurface::BufferPresentedImpl( |
| - const std::string& mailbox_name) { |
| + const gpu::Mailbox& mailbox_name) { |
| DCHECK(!backbuffer_.service_id); |
| - if (!mailbox_name.empty()) { |
| - DCHECK(mailbox_name.length() == GL_MAILBOX_SIZE_CHROMIUM); |
| - mailbox_name.copy(reinterpret_cast<char *>(&backbuffer_.mailbox_name), |
| - sizeof(MailboxName)); |
| + if (!mailbox_name.IsZero()) { |
| + backbuffer_.mailbox_name = mailbox_name; |
| ConsumeTexture(&backbuffer_); |
| } |
| @@ -370,7 +364,7 @@ void TextureImageTransportSurface::ReleaseBackTexture() { |
| glDeleteTextures(1, &backbuffer_.service_id); |
| backbuffer_.service_id = 0; |
| - backbuffer_.mailbox_name = MailboxName(); |
| + backbuffer_.mailbox_name = gpu::Mailbox(); |
| glFlush(); |
| CHECK_GL_ERROR(); |
| } |
| @@ -401,12 +395,13 @@ void TextureImageTransportSurface::CreateBackTexture() { |
| } |
| if (!backbuffer_.service_id) { |
| - MailboxName new_mailbox_name; |
| - MailboxName& name = backbuffer_.mailbox_name; |
| + gpu::Mailbox& name = backbuffer_.mailbox_name; |
| // This slot should be uninitialized. |
| - DCHECK(!memcmp(&name, &new_mailbox_name, sizeof(MailboxName))); |
| + DCHECK(name.IsZero()); |
| + |
| + MailboxName new_mailbox_name; |
| mailbox_manager_->GenerateMailboxName(&new_mailbox_name); |
| - name = new_mailbox_name; |
| + name.SetName(new_mailbox_name.key); |
|
no sievers
2013/03/06 23:19:23
hmm, should MailboxName have an operator maybe?
piman
2013/03/07 01:48:02
cast operators are discouraged by the style guide.
|
| glGenTextures(1, &backbuffer_.service_id); |
| } |
| @@ -448,14 +443,17 @@ void TextureImageTransportSurface::AttachBackTextureToFBO() { |
| void TextureImageTransportSurface::ConsumeTexture(Texture* texture) { |
| DCHECK(!texture->service_id); |
| + MailboxName name; |
|
no sievers
2013/03/06 23:19:23
Also maybe a constructor from gpu::Mailbox?
piman
2013/03/07 01:48:02
Done.
|
| + memcpy(name.key, texture->mailbox_name.name, |
| + sizeof(texture->mailbox_name.name)); |
| scoped_ptr<TextureDefinition> definition(mailbox_manager_->ConsumeTexture( |
| - GL_TEXTURE_2D, texture->mailbox_name)); |
| + GL_TEXTURE_2D, name)); |
| if (definition.get()) { |
| texture->service_id = definition->ReleaseServiceId(); |
| texture->size = gfx::Size(definition->level_infos()[0][0].width, |
| definition->level_infos()[0][0].height); |
| } else { |
| - texture->mailbox_name = MailboxName(); |
| + texture->mailbox_name = gpu::Mailbox(); |
| } |
| } |
| @@ -487,14 +485,17 @@ void TextureImageTransportSurface::ProduceTexture(Texture* texture) { |
| // when the renderer context group goes away before the RWHV handles a pending |
| // ACK. We avoid leaking a texture in the mailbox by waiting for the final ACK |
| // at which point we consume the correct texture back. |
| + MailboxName name; |
| + memcpy(name.key, texture->mailbox_name.name, |
| + sizeof(texture->mailbox_name.name)); |
| bool success = mailbox_manager_->ProduceTexture( |
| GL_TEXTURE_2D, |
| - texture->mailbox_name, |
| + name, |
| definition.release(), |
| NULL); |
| DCHECK(success); |
| texture->service_id = 0; |
| - texture->mailbox_name = MailboxName(); |
| + texture->mailbox_name = gpu::Mailbox(); |
| } |
| } // namespace content |