summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-07 05:33:41 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-07 05:33:41 +0000
commit8a19b5acd2bcc8e1e11643786d8ac830867ef3f5 (patch)
treee90965dc48e5d7f9b407354ae5ed6903accf3227
parente652df3e915ab9720480158f261a285e4a696a77 (diff)
downloadchromium_src-8a19b5acd2bcc8e1e11643786d8ac830867ef3f5.zip
chromium_src-8a19b5acd2bcc8e1e11643786d8ac830867ef3f5.tar.gz
chromium_src-8a19b5acd2bcc8e1e11643786d8ac830867ef3f5.tar.bz2
Use gpu::Mailbox in IPCs instead of std::string
gpu::Mailbox is safer since the size is checked in the deserializer. It's also overall less code. BUG=None Review URL: https://chromiumcodereview.appspot.com/12440005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186627 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--cc/texture_layer_unittest.cc4
-rw-r--r--cc/texture_mailbox.cc12
-rw-r--r--cc/texture_mailbox.h2
-rw-r--r--content/browser/browser_plugin/browser_plugin_guest.cc4
-rw-r--r--content/browser/browser_plugin/browser_plugin_guest.h8
-rw-r--r--content/browser/browser_plugin/browser_plugin_guest_manager.cc2
-rw-r--r--content/browser/browser_plugin/browser_plugin_guest_manager.h6
-rw-r--r--content/browser/gpu/gpu_process_host_ui_shim.cc8
-rw-r--r--content/browser/renderer_host/image_transport_factory.cc31
-rw-r--r--content/browser/renderer_host/render_widget_host_view_android.cc21
-rw-r--r--content/browser/renderer_host/render_widget_host_view_aura.cc18
-rw-r--r--content/browser/renderer_host/render_widget_host_view_aura.h8
-rw-r--r--content/common/browser_plugin/browser_plugin_messages.h5
-rw-r--r--content/common/gpu/gpu_messages.h7
-rw-r--r--content/common/gpu/texture_image_transport_surface.cc35
-rw-r--r--content/common/gpu/texture_image_transport_surface.h5
-rw-r--r--content/renderer/browser_plugin/browser_plugin.cc2
-rw-r--r--content/renderer/browser_plugin/browser_plugin.h6
-rw-r--r--content/renderer/browser_plugin/browser_plugin_compositing_helper.cc16
-rw-r--r--content/renderer/browser_plugin/browser_plugin_compositing_helper.h10
-rw-r--r--content/renderer/browser_plugin/browser_plugin_manager_impl.cc2
-rw-r--r--content/renderer/browser_plugin/browser_plugin_manager_impl.h6
-rw-r--r--gpu/command_buffer/service/mailbox_manager.cc5
-rw-r--r--gpu/command_buffer/service/mailbox_manager.h4
-rw-r--r--ui/compositor/DEPS1
-rw-r--r--ui/compositor/compositor.cc6
-rw-r--r--ui/compositor/compositor.gyp1
-rw-r--r--ui/compositor/compositor.h8
28 files changed, 115 insertions, 128 deletions
diff --git a/cc/texture_layer_unittest.cc b/cc/texture_layer_unittest.cc
index 6aaf459..7ebdac6 100644
--- a/cc/texture_layer_unittest.cc
+++ b/cc/texture_layer_unittest.cc
@@ -293,8 +293,10 @@ public:
}
void setMailbox(char mailbox_char) {
+ gpu::Mailbox name;
+ memset(name.name, mailbox_char, sizeof(name.name));
TextureMailbox mailbox(
- std::string(64, mailbox_char),
+ name,
base::Bind(
&TextureLayerImplWithMailboxThreadedCallback::releaseCallback,
base::Unretained(this)));
diff --git a/cc/texture_mailbox.cc b/cc/texture_mailbox.cc
index b534605..437fb1c 100644
--- a/cc/texture_mailbox.cc
+++ b/cc/texture_mailbox.cc
@@ -12,18 +12,6 @@ TextureMailbox::TextureMailbox()
}
TextureMailbox::TextureMailbox(
- const std::string& mailbox_name,
- const ReleaseCallback& mailbox_callback)
- : callback_(mailbox_callback),
- sync_point_(0) {
- DCHECK(mailbox_name.empty() == mailbox_callback.is_null());
- if (!mailbox_name.empty()) {
- CHECK(mailbox_name.size() == sizeof(name_.name));
- name_.SetName(reinterpret_cast<const int8*>(mailbox_name.data()));
- }
-}
-
-TextureMailbox::TextureMailbox(
const gpu::Mailbox& mailbox_name,
const ReleaseCallback& mailbox_callback)
: callback_(mailbox_callback),
diff --git a/cc/texture_mailbox.h b/cc/texture_mailbox.h
index 9314ddd..7520087 100644
--- a/cc/texture_mailbox.h
+++ b/cc/texture_mailbox.h
@@ -18,8 +18,6 @@ class CC_EXPORT TextureMailbox {
public:
typedef base::Callback<void(unsigned)> ReleaseCallback;
TextureMailbox();
- TextureMailbox(const std::string& mailbox_name,
- const ReleaseCallback& callback);
TextureMailbox(const gpu::Mailbox& mailbox_name,
const ReleaseCallback& callback);
TextureMailbox(const gpu::Mailbox& mailbox_name,
diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc
index da41a34..a649a5f 100644
--- a/content/browser/browser_plugin/browser_plugin_guest.cc
+++ b/content/browser/browser_plugin/browser_plugin_guest.cc
@@ -445,7 +445,7 @@ void BrowserPluginGuest::RenderViewGone(base::TerminationStatus status) {
void BrowserPluginGuest::AcknowledgeBufferPresent(
int route_id,
int gpu_host_id,
- const std::string& mailbox_name,
+ const gpu::Mailbox& mailbox_name,
uint32 sync_point) {
AcceleratedSurfaceMsg_BufferPresented_Params ack_params;
ack_params.mailbox_name = mailbox_name;
@@ -728,7 +728,7 @@ void BrowserPluginGuest::OnRespondPermission(
void BrowserPluginGuest::OnSwapBuffersACK(int instance_id,
int route_id,
int gpu_host_id,
- const std::string& mailbox_name,
+ const gpu::Mailbox& mailbox_name,
uint32 sync_point) {
AcknowledgeBufferPresent(route_id, gpu_host_id, mailbox_name, sync_point);
diff --git a/content/browser/browser_plugin/browser_plugin_guest.h b/content/browser/browser_plugin/browser_plugin_guest.h
index 1a31551..73ecae6 100644
--- a/content/browser/browser_plugin/browser_plugin_guest.h
+++ b/content/browser/browser_plugin/browser_plugin_guest.h
@@ -50,6 +50,10 @@ struct ViewHostMsg_UpdateRect_Params;
class WebCursor;
struct WebDropData;
+namespace gpu {
+struct Mailbox;
+}
+
namespace WebKit {
class WebInputEvent;
}
@@ -181,7 +185,7 @@ class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver,
// BrowserPluginGuest is already destroyed.
static void AcknowledgeBufferPresent(int route_id,
int gpu_host_id,
- const std::string& mailbox_name,
+ const gpu::Mailbox& mailbox_name,
uint32 sync_point);
// Returns whether BrowserPluginGuest is interested in receiving the given
@@ -292,7 +296,7 @@ class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver,
void OnSwapBuffersACK(int instance_id,
int route_id,
int gpu_host_id,
- const std::string& mailbox_name,
+ const gpu::Mailbox& mailbox_name,
uint32 sync_point);
void OnTerminateGuest(int instance_id);
diff --git a/content/browser/browser_plugin/browser_plugin_guest_manager.cc b/content/browser/browser_plugin/browser_plugin_guest_manager.cc
index a96dcfc..fc38cc7 100644
--- a/content/browser/browser_plugin/browser_plugin_guest_manager.cc
+++ b/content/browser/browser_plugin/browser_plugin_guest_manager.cc
@@ -211,7 +211,7 @@ void BrowserPluginGuestManager::OnUnhandledSwapBuffersACK(
int instance_id,
int route_id,
int gpu_host_id,
- const std::string& mailbox_name,
+ const gpu::Mailbox& mailbox_name,
uint32 sync_point) {
BrowserPluginGuest::AcknowledgeBufferPresent(route_id,
gpu_host_id,
diff --git a/content/browser/browser_plugin/browser_plugin_guest_manager.h b/content/browser/browser_plugin/browser_plugin_guest_manager.h
index a41dfc4..6362af3 100644
--- a/content/browser/browser_plugin/browser_plugin_guest_manager.h
+++ b/content/browser/browser_plugin/browser_plugin_guest_manager.h
@@ -22,6 +22,10 @@ namespace gfx {
class Point;
}
+namespace gpu {
+struct Mailbox;
+}
+
namespace IPC {
class Message;
} // namespace IPC
@@ -92,7 +96,7 @@ class CONTENT_EXPORT BrowserPluginGuestManager :
void OnUnhandledSwapBuffersACK(int instance_id,
int route_id,
int gpu_host_id,
- const std::string& mailbox_name,
+ const gpu::Mailbox& mailbox_name,
uint32 sync_point);
// Static factory instance (always NULL outside of tests).
diff --git a/content/browser/gpu/gpu_process_host_ui_shim.cc b/content/browser/gpu/gpu_process_host_ui_shim.cc
index 4e1a26e2..1fa06e6 100644
--- a/content/browser/gpu/gpu_process_host_ui_shim.cc
+++ b/content/browser/gpu/gpu_process_host_ui_shim.cc
@@ -321,10 +321,6 @@ void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped(
new AcceleratedSurfaceMsg_BufferPresented(params.route_id,
ack_params));
- if (!params.mailbox_name.empty() &&
- params.mailbox_name.length() != GL_MAILBOX_SIZE_CHROMIUM)
- return;
-
RenderWidgetHostViewPort* view = GetRenderWidgetHostViewFromSurfaceID(
params.surface_id);
if (!view)
@@ -353,10 +349,6 @@ void GpuProcessHostUIShim::OnAcceleratedSurfacePostSubBuffer(
new AcceleratedSurfaceMsg_BufferPresented(params.route_id,
ack_params));
- if (!params.mailbox_name.empty() &&
- params.mailbox_name.length() != GL_MAILBOX_SIZE_CHROMIUM)
- return;
-
RenderWidgetHostViewPort* view =
GetRenderWidgetHostViewFromSurfaceID(params.surface_id);
if (!view)
diff --git a/content/browser/renderer_host/image_transport_factory.cc b/content/browser/renderer_host/image_transport_factory.cc
index e37ea28..1027e2b 100644
--- a/content/browser/renderer_host/image_transport_factory.cc
+++ b/content/browser/renderer_host/image_transport_factory.cc
@@ -162,32 +162,23 @@ class ImageTransportClientTexture : public OwnedTexture {
host_context->createTexture()) {
}
- virtual void Consume(const std::string& mailbox_name,
+ virtual void Consume(const gpu::Mailbox& mailbox_name,
const gfx::Size& new_size) OVERRIDE {
- DCHECK(mailbox_name.size() == GL_MAILBOX_SIZE_CHROMIUM);
- mailbox_name_ = mailbox_name;
- if (mailbox_name.empty())
- return;
-
DCHECK(host_context_ && texture_id_);
+ mailbox_name_ = mailbox_name;
host_context_->bindTexture(GL_TEXTURE_2D, texture_id_);
- host_context_->consumeTextureCHROMIUM(
- GL_TEXTURE_2D,
- reinterpret_cast<const signed char*>(mailbox_name.c_str()));
+ host_context_->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox_name.name);
size_ = new_size;
host_context_->shallowFlushCHROMIUM();
}
- virtual std::string Produce() OVERRIDE {
- std::string name;
- if (!mailbox_name_.empty()) {
- DCHECK(host_context_ && texture_id_);
- host_context_->bindTexture(GL_TEXTURE_2D, texture_id_);
- host_context_->produceTextureCHROMIUM(
- GL_TEXTURE_2D,
- reinterpret_cast<const signed char*>(mailbox_name_.c_str()));
- mailbox_name_.swap(name);
- }
+ virtual gpu::Mailbox Produce() OVERRIDE {
+ DCHECK(!mailbox_name_.IsZero());
+ DCHECK(host_context_ && texture_id_);
+ host_context_->bindTexture(GL_TEXTURE_2D, texture_id_);
+ host_context_->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox_name_.name);
+ gpu::Mailbox name;
+ std::swap(mailbox_name_, name);
return name;
}
@@ -195,7 +186,7 @@ class ImageTransportClientTexture : public OwnedTexture {
virtual ~ImageTransportClientTexture() {}
private:
- std::string mailbox_name_;
+ gpu::Mailbox mailbox_name_;
DISALLOW_COPY_AND_ASSIGN(ImageTransportClientTexture);
};
diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc
index 8b08ad3..5573cb3 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -40,7 +40,7 @@ namespace content {
namespace {
void InsertSyncPointAndAckForGpu(
- int gpu_host_id, int route_id, const std::string& return_mailbox) {
+ int gpu_host_id, int route_id, const gpu::Mailbox& return_mailbox) {
uint32 sync_point =
ImageTransportFactoryAndroid::GetInstance()->InsertSyncPoint();
AcceleratedSurfaceMsg_BufferPresented_Params ack_params;
@@ -496,26 +496,13 @@ void RenderWidgetHostViewAndroid::OnSwapCompositorFrame(
void RenderWidgetHostViewAndroid::AcceleratedSurfaceBuffersSwapped(
const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
int gpu_host_id) {
- if (params.mailbox_name.empty())
+ if (params.mailbox_name.IsZero())
return;
- std::string return_mailbox;
- if (!current_mailbox_.IsZero()) {
- return_mailbox.assign(
- reinterpret_cast<const char*>(current_mailbox_.name),
- sizeof(current_mailbox_.name));
- }
-
base::Closure callback = base::Bind(&InsertSyncPointAndAckForGpu,
gpu_host_id, params.route_id,
- return_mailbox);
-
- gpu::Mailbox mailbox;
- std::copy(params.mailbox_name.data(),
- params.mailbox_name.data() + params.mailbox_name.length(),
- reinterpret_cast<char*>(mailbox.name));
-
- BuffersSwapped(mailbox, params.size, callback);
+ current_mailbox_);
+ BuffersSwapped(params.mailbox_name, params.size, callback);
}
void RenderWidgetHostViewAndroid::BuffersSwapped(
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
index d4accf4..643ef00 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -289,10 +289,7 @@ void SendCompositorFrameAck(
ack.gl_frame_data.reset(new cc::GLFrameData());
DCHECK(!texture_to_produce || !skip_frame);
if (texture_to_produce) {
- std::string mailbox_name = texture_to_produce->Produce();
- std::copy(mailbox_name.data(),
- mailbox_name.data() + mailbox_name.length(),
- reinterpret_cast<char*>(ack.gl_frame_data->mailbox.name));
+ ack.gl_frame_data->mailbox = texture_to_produce->Produce();
ack.gl_frame_data->size = texture_to_produce->size();
ack.gl_frame_data->sync_point =
content::ImageTransportFactory::GetInstance()->InsertSyncPoint();
@@ -310,7 +307,7 @@ void SendCompositorFrameAck(
void AcknowledgeBufferForGpu(
int32 route_id,
int gpu_host_id,
- const std::string& received_mailbox,
+ const gpu::Mailbox& received_mailbox,
bool skip_frame,
const scoped_refptr<ui::Texture>& texture_to_produce) {
AcceleratedSurfaceMsg_BufferPresented_Params ack;
@@ -1164,7 +1161,7 @@ void RenderWidgetHostViewAura::UpdateExternalTexture() {
bool RenderWidgetHostViewAura::SwapBuffersPrepare(
const gfx::Rect& surface_rect,
const gfx::Rect& damage_rect,
- const std::string& mailbox_name,
+ const gpu::Mailbox& mailbox_name,
const BufferPresentedCallback& ack_callback) {
if (last_swapped_surface_size_ != surface_rect.size()) {
// The surface could have shrunk since we skipped an update, in which
@@ -1175,7 +1172,7 @@ bool RenderWidgetHostViewAura::SwapBuffersPrepare(
}
if (ShouldSkipFrame(ConvertSizeToDIP(this, surface_rect.size())) ||
- mailbox_name.empty()) {
+ mailbox_name.IsZero()) {
skipped_damage_.op(RectToSkIRect(damage_rect), SkRegion::kUnion_Op);
ack_callback.Run(true, scoped_refptr<ui::Texture>());
return false;
@@ -1317,16 +1314,13 @@ void RenderWidgetHostViewAura::OnSwapCompositorFrame(
ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
factory->WaitSyncPoint(frame->gl_frame_data->sync_point);
- std::string mailbox_name(
- reinterpret_cast<const char*>(frame->gl_frame_data->mailbox.name),
- sizeof(frame->gl_frame_data->mailbox.name));
BuffersSwapped(
- frame->gl_frame_data->size, mailbox_name, ack_callback);
+ frame->gl_frame_data->size, frame->gl_frame_data->mailbox, ack_callback);
}
void RenderWidgetHostViewAura::BuffersSwapped(
const gfx::Size& size,
- const std::string& mailbox_name,
+ const gpu::Mailbox& mailbox_name,
const BufferPresentedCallback& ack_callback) {
scoped_refptr<ui::Texture> texture_to_return(current_surface_);
const gfx::Rect surface_rect = gfx::Rect(gfx::Point(), size);
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h
index 3e07745..73903a5 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.h
+++ b/content/browser/renderer_host/render_widget_host_view_aura.h
@@ -44,6 +44,10 @@ class Canvas;
class Display;
}
+namespace gpu {
+struct Mailbox;
+}
+
namespace ui {
class CompositorLock;
class InputMethod;
@@ -360,12 +364,12 @@ class RenderWidgetHostViewAura
// The common entry point for full buffer updates from renderer
// and GPU process.
void BuffersSwapped(const gfx::Size& size,
- const std::string& mailbox_name,
+ const gpu::Mailbox& mailbox_name,
const BufferPresentedCallback& ack_callback);
bool SwapBuffersPrepare(const gfx::Rect& surface_rect,
const gfx::Rect& damage_rect,
- const std::string& mailbox_name,
+ const gpu::Mailbox& mailbox_name,
const BufferPresentedCallback& ack_callback);
void SwapBuffersCompleted(
diff --git a/content/common/browser_plugin/browser_plugin_messages.h b/content/common/browser_plugin/browser_plugin_messages.h
index dd8e2b2..fb7e331 100644
--- a/content/common/browser_plugin/browser_plugin_messages.h
+++ b/content/common/browser_plugin/browser_plugin_messages.h
@@ -14,6 +14,7 @@
#include "content/common/content_export.h"
#include "content/common/content_param_traits.h"
#include "content/public/common/common_param_traits.h"
+#include "gpu/command_buffer/common/mailbox.h"
#include "ipc/ipc_channel_handle.h"
#include "ipc/ipc_message_macros.h"
#include "ipc/ipc_message_utils.h"
@@ -207,7 +208,7 @@ IPC_MESSAGE_ROUTED5(BrowserPluginHostMsg_BuffersSwappedACK,
int /* instance_id */,
int /* route_id */,
int /* gpu_host_id */,
- std::string /* mailbox_name */,
+ gpu::Mailbox /* mailbox_name */,
uint32 /* sync_point */)
// When a BrowserPlugin has been removed from the embedder's DOM, it informs
@@ -384,7 +385,7 @@ IPC_MESSAGE_CONTROL2(BrowserPluginMsg_UpdatedName,
IPC_MESSAGE_CONTROL5(BrowserPluginMsg_BuffersSwapped,
int /* instance_id */,
gfx::Size /* size */,
- std::string /* mailbox_name */,
+ gpu::Mailbox /* mailbox_name */,
int /* route_id */,
int /* gpu_host_id */)
diff --git a/content/common/gpu/gpu_messages.h b/content/common/gpu/gpu_messages.h
index feef8e8..20b3b9d 100644
--- a/content/common/gpu/gpu_messages.h
+++ b/content/common/gpu/gpu_messages.h
@@ -19,6 +19,7 @@
#include "content/public/common/gpu_memory_stats.h"
#include "gpu/command_buffer/common/command_buffer.h"
#include "gpu/command_buffer/common/constants.h"
+#include "gpu/command_buffer/common/mailbox.h"
#include "gpu/ipc/gpu_command_buffer_traits.h"
#include "ipc/ipc_channel_handle.h"
#include "ipc/ipc_message_macros.h"
@@ -48,7 +49,7 @@ IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params)
IPC_STRUCT_MEMBER(int32, surface_id)
IPC_STRUCT_MEMBER(uint64, surface_handle)
IPC_STRUCT_MEMBER(int32, route_id)
- IPC_STRUCT_MEMBER(std::string, mailbox_name)
+ IPC_STRUCT_MEMBER(gpu::Mailbox, mailbox_name)
IPC_STRUCT_MEMBER(gfx::Size, size)
#if defined(OS_MACOSX)
IPC_STRUCT_MEMBER(gfx::PluginWindowHandle, window)
@@ -65,7 +66,7 @@ IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params)
IPC_STRUCT_MEMBER(int, y)
IPC_STRUCT_MEMBER(int, width)
IPC_STRUCT_MEMBER(int, height)
- IPC_STRUCT_MEMBER(std::string, mailbox_name)
+ IPC_STRUCT_MEMBER(gpu::Mailbox, mailbox_name)
IPC_STRUCT_MEMBER(gfx::Size, surface_size)
#if defined(OS_MACOSX)
IPC_STRUCT_MEMBER(gfx::PluginWindowHandle, window)
@@ -78,7 +79,7 @@ IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfaceRelease_Params)
IPC_STRUCT_END()
IPC_STRUCT_BEGIN(AcceleratedSurfaceMsg_BufferPresented_Params)
- IPC_STRUCT_MEMBER(std::string, mailbox_name)
+ IPC_STRUCT_MEMBER(gpu::Mailbox, mailbox_name)
IPC_STRUCT_MEMBER(uint32, sync_point)
#if defined(OS_MACOSX)
IPC_STRUCT_MEMBER(int32, renderer_id)
diff --git a/content/common/gpu/texture_image_transport_surface.cc b/content/common/gpu/texture_image_transport_surface.cc
index a40b60d..186cc37 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);
glGenTextures(1, &backbuffer_.service_id);
}
@@ -449,13 +444,13 @@ void TextureImageTransportSurface::ConsumeTexture(Texture* texture) {
DCHECK(!texture->service_id);
scoped_ptr<TextureDefinition> definition(mailbox_manager_->ConsumeTexture(
- GL_TEXTURE_2D, texture->mailbox_name));
+ GL_TEXTURE_2D, MailboxName(texture->mailbox_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();
}
}
@@ -489,12 +484,12 @@ void TextureImageTransportSurface::ProduceTexture(Texture* texture) {
// at which point we consume the correct texture back.
bool success = mailbox_manager_->ProduceTexture(
GL_TEXTURE_2D,
- texture->mailbox_name,
+ MailboxName(texture->mailbox_name),
definition.release(),
NULL);
DCHECK(success);
texture->service_id = 0;
- texture->mailbox_name = MailboxName();
+ texture->mailbox_name = gpu::Mailbox();
}
} // namespace content
diff --git a/content/common/gpu/texture_image_transport_surface.h b/content/common/gpu/texture_image_transport_surface.h
index b29a97a..8b0e266 100644
--- a/content/common/gpu/texture_image_transport_surface.h
+++ b/content/common/gpu/texture_image_transport_surface.h
@@ -10,6 +10,7 @@
#include "base/basictypes.h"
#include "content/common/gpu/gpu_command_buffer_stub.h"
#include "content/common/gpu/image_transport_surface.h"
+#include "gpu/command_buffer/common/mailbox.h"
#include "gpu/command_buffer/service/mailbox_manager.h"
#include "gpu/command_buffer/service/texture_manager.h"
#include "ui/gl/gl_context.h"
@@ -71,14 +72,14 @@ class TextureImageTransportSurface
// The mailbox name for the current service_id. Needs to be unique per
// GL texture and is invalid while service_id is zero.
- gpu::gles2::MailboxName mailbox_name;
+ gpu::Mailbox mailbox_name;
};
virtual ~TextureImageTransportSurface();
void CreateBackTexture();
void AttachBackTextureToFBO();
void ReleaseBackTexture();
- void BufferPresentedImpl(const std::string& mailbox_name);
+ void BufferPresentedImpl(const gpu::Mailbox& mailbox_name);
void ProduceTexture(Texture* texture);
void ConsumeTexture(Texture* texture);
diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc
index 779740b..e975a2f 100644
--- a/content/renderer/browser_plugin/browser_plugin.cc
+++ b/content/renderer/browser_plugin/browser_plugin.cc
@@ -400,7 +400,7 @@ void BrowserPlugin::OnAdvanceFocus(int instance_id, bool reverse) {
void BrowserPlugin::OnBuffersSwapped(int instance_id,
const gfx::Size& size,
- std::string mailbox_name,
+ gpu::Mailbox mailbox_name,
int gpu_route_id,
int gpu_host_id) {
DCHECK(instance_id == instance_id_);
diff --git a/content/renderer/browser_plugin/browser_plugin.h b/content/renderer/browser_plugin/browser_plugin.h
index 8e51a5b..0294231 100644
--- a/content/renderer/browser_plugin/browser_plugin.h
+++ b/content/renderer/browser_plugin/browser_plugin.h
@@ -26,6 +26,10 @@ struct BrowserPluginHostMsg_ResizeGuest_Params;
struct BrowserPluginMsg_LoadCommit_Params;
struct BrowserPluginMsg_UpdateRect_Params;
+namespace gpu {
+struct Mailbox;
+}
+
namespace content {
class BrowserPluginCompositingHelper;
@@ -309,7 +313,7 @@ class CONTENT_EXPORT BrowserPlugin :
void OnAdvanceFocus(int instance_id, bool reverse);
void OnBuffersSwapped(int instance_id,
const gfx::Size& size,
- std::string mailbox_name,
+ gpu::Mailbox mailbox_name,
int gpu_route_id,
int gpu_host_id);
void OnGuestContentWindowReady(int instance_id,
diff --git a/content/renderer/browser_plugin/browser_plugin_compositing_helper.cc b/content/renderer/browser_plugin/browser_plugin_compositing_helper.cc
index c52a68e..f98d489b 100644
--- a/content/renderer/browser_plugin/browser_plugin_compositing_helper.cc
+++ b/content/renderer/browser_plugin/browser_plugin_compositing_helper.cc
@@ -63,9 +63,9 @@ void BrowserPluginCompositingHelper::EnableCompositing(bool enable) {
// We use a shared graphics context accessible from the main
// thread to do it.
void BrowserPluginCompositingHelper::FreeMailboxMemory(
- const std::string& mailbox_name,
+ const gpu::Mailbox& mailbox_name,
unsigned sync_point) {
- if (mailbox_name.empty())
+ if (mailbox_name.IsZero())
return;
scoped_refptr<cc::ContextProvider> context_provider =
@@ -87,14 +87,12 @@ void BrowserPluginCompositingHelper::FreeMailboxMemory(
unsigned texture_id = context->createTexture();
context->bindTexture(GL_TEXTURE_2D, texture_id);
- context->consumeTextureCHROMIUM(
- GL_TEXTURE_2D,
- reinterpret_cast<const int8*>(mailbox_name.data()));
+ context->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox_name.name);
context->deleteTexture(texture_id);
}
void BrowserPluginCompositingHelper::MailboxReleased(
- const std::string& mailbox_name,
+ const gpu::Mailbox& mailbox_name,
int gpu_route_id,
int gpu_host_id,
unsigned sync_point) {
@@ -156,7 +154,7 @@ void BrowserPluginCompositingHelper::OnContainerDestroy() {
void BrowserPluginCompositingHelper::OnBuffersSwapped(
const gfx::Size& size,
- const std::string& mailbox_name,
+ const gpu::Mailbox& mailbox_name,
int gpu_route_id,
int gpu_host_id,
float device_scale_factor) {
@@ -203,9 +201,9 @@ void BrowserPluginCompositingHelper::OnBuffersSwapped(
texture_layer_->setBounds(device_scale_adjusted_size);
}
- bool current_mailbox_valid = !mailbox_name.empty();
+ bool current_mailbox_valid = !mailbox_name.IsZero();
if (!last_mailbox_valid_) {
- MailboxReleased(std::string(), gpu_route_id, gpu_host_id, 0);
+ MailboxReleased(gpu::Mailbox(), gpu_route_id, gpu_host_id, 0);
if (!current_mailbox_valid)
return;
}
diff --git a/content/renderer/browser_plugin/browser_plugin_compositing_helper.h b/content/renderer/browser_plugin/browser_plugin_compositing_helper.h
index 998b739..8d9b1b2 100644
--- a/content/renderer/browser_plugin/browser_plugin_compositing_helper.h
+++ b/content/renderer/browser_plugin/browser_plugin_compositing_helper.h
@@ -17,6 +17,10 @@ class SolidColorLayer;
class TextureLayer;
}
+namespace gpu {
+struct Mailbox;
+}
+
namespace WebKit {
class WebPluginContainer;
class WebLayer;
@@ -36,7 +40,7 @@ class CONTENT_EXPORT BrowserPluginCompositingHelper :
void EnableCompositing(bool);
void OnContainerDestroy();
void OnBuffersSwapped(const gfx::Size& size,
- const std::string& mailbox_name,
+ const gpu::Mailbox& mailbox_name,
int gpu_route_id,
int gpu_host_id,
float device_scale_factor);
@@ -46,9 +50,9 @@ class CONTENT_EXPORT BrowserPluginCompositingHelper :
friend class base::RefCounted<BrowserPluginCompositingHelper>;
private:
~BrowserPluginCompositingHelper();
- void FreeMailboxMemory(const std::string& mailbox_name,
+ void FreeMailboxMemory(const gpu::Mailbox& mailbox_name,
unsigned sync_point);
- void MailboxReleased(const std::string& mailbox_name,
+ void MailboxReleased(const gpu::Mailbox& mailbox_name,
int gpu_route_id,
int gpu_host_id,
unsigned sync_point);
diff --git a/content/renderer/browser_plugin/browser_plugin_manager_impl.cc b/content/renderer/browser_plugin/browser_plugin_manager_impl.cc
index ac9880e..40f9517 100644
--- a/content/renderer/browser_plugin/browser_plugin_manager_impl.cc
+++ b/content/renderer/browser_plugin/browser_plugin_manager_impl.cc
@@ -100,7 +100,7 @@ void BrowserPluginManagerImpl::OnPluginAtPositionRequest(
void BrowserPluginManagerImpl::OnUnhandledSwap(const IPC::Message& message,
int instance_id,
const gfx::Size& size,
- std::string mailbox_name,
+ gpu::Mailbox mailbox_name,
int gpu_route_id,
int gpu_host_id) {
// After the BrowserPlugin object sends a destroy message to the
diff --git a/content/renderer/browser_plugin/browser_plugin_manager_impl.h b/content/renderer/browser_plugin/browser_plugin_manager_impl.h
index 2496474..b8505e3 100644
--- a/content/renderer/browser_plugin/browser_plugin_manager_impl.h
+++ b/content/renderer/browser_plugin/browser_plugin_manager_impl.h
@@ -16,6 +16,10 @@ namespace gfx {
class Point;
}
+namespace gpu {
+struct Mailbox;
+}
+
namespace content {
class BrowserPluginManagerImpl : public BrowserPluginManager {
@@ -46,7 +50,7 @@ class BrowserPluginManagerImpl : public BrowserPluginManager {
void OnUnhandledSwap(const IPC::Message& message,
int instance_id,
const gfx::Size& size,
- std::string mailbox_name,
+ gpu::Mailbox mailbox_name,
int gpu_route_id,
int gpu_host_id);
diff --git a/gpu/command_buffer/service/mailbox_manager.cc b/gpu/command_buffer/service/mailbox_manager.cc
index 9019393..ccc48eb 100644
--- a/gpu/command_buffer/service/mailbox_manager.cc
+++ b/gpu/command_buffer/service/mailbox_manager.cc
@@ -8,6 +8,7 @@
#include "base/rand_util.h"
#include "crypto/hmac.h"
+#include "gpu/command_buffer/common/mailbox.h"
#include "gpu/command_buffer/service/gl_utils.h"
#include "gpu/command_buffer/service/texture_definition.h"
@@ -19,6 +20,10 @@ MailboxName::MailboxName() {
std::fill(signature, signature + sizeof(signature), 0);
}
+MailboxName::MailboxName(const ::gpu::Mailbox& mailbox) {
+ std::copy(mailbox.name, mailbox.name + sizeof(mailbox.name), key);
+}
+
MailboxManager::MailboxManager()
: hmac_(crypto::HMAC::SHA256),
textures_(std::ptr_fun(&MailboxManager::TargetNameLess)) {
diff --git a/gpu/command_buffer/service/mailbox_manager.h b/gpu/command_buffer/service/mailbox_manager.h
index 8f97dd4..85a5ec0 100644
--- a/gpu/command_buffer/service/mailbox_manager.h
+++ b/gpu/command_buffer/service/mailbox_manager.h
@@ -22,6 +22,9 @@
typedef signed char GLbyte;
namespace gpu {
+
+struct Mailbox;
+
namespace gles2 {
class TextureDefinition;
@@ -32,6 +35,7 @@ class TextureManager;
// group. It is a random key signed with a hash of a private key.
struct GPU_EXPORT MailboxName {
MailboxName();
+ explicit MailboxName(const ::gpu::Mailbox& mailbox);
GLbyte key[GL_MAILBOX_SIZE_CHROMIUM / 2];
GLbyte signature[GL_MAILBOX_SIZE_CHROMIUM / 2];
};
diff --git a/ui/compositor/DEPS b/ui/compositor/DEPS
index 95ad49f..165753a 100644
--- a/ui/compositor/DEPS
+++ b/ui/compositor/DEPS
@@ -3,6 +3,7 @@
# Compositor out of WebKit.
include_rules = [
"+cc",
+ "+gpu/command_buffer/common/mailbox.h",
"+third_party/WebKit/Source/Platform/chromium/public",
"+third_party/WebKit/Source/WebKit/chromium/public",
"+webkit/glue",
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc
index 4cb9122..e28945f 100644
--- a/ui/compositor/compositor.cc
+++ b/ui/compositor/compositor.cc
@@ -11,7 +11,6 @@
#include "base/command_line.h"
#include "base/memory/singleton.h"
#include "base/message_loop.h"
-#include "base/string_util.h"
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
#include "cc/context_provider.h"
@@ -20,6 +19,7 @@
#include "cc/layer_tree_host.h"
#include "cc/output_surface.h"
#include "cc/thread_impl.h"
+#include "gpu/command_buffer/common/mailbox.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/compositor/compositor_observer.h"
#include "ui/compositor/compositor_switches.h"
@@ -262,8 +262,8 @@ Texture::Texture(bool flipped, const gfx::Size& size, float device_scale_factor)
Texture::~Texture() {
}
-std::string Texture::Produce() {
- return EmptyString();
+gpu::Mailbox Texture::Produce() {
+ return gpu::Mailbox();
}
CompositorLock::CompositorLock(Compositor* compositor)
diff --git a/ui/compositor/compositor.gyp b/ui/compositor/compositor.gyp
index 63143fc..26bfddc 100644
--- a/ui/compositor/compositor.gyp
+++ b/ui/compositor/compositor.gyp
@@ -14,6 +14,7 @@
'<(DEPTH)/base/base.gyp:base',
'<(DEPTH)/base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
'<(DEPTH)/cc/cc.gyp:cc',
+ '<(DEPTH)/gpu/gpu.gyp:gpu',
'<(DEPTH)/skia/skia.gyp:skia',
'<(DEPTH)/third_party/WebKit/Source/WebKit/chromium/WebKit.gyp:webkit',
'<(DEPTH)/ui/gl/gl.gyp:gl',
diff --git a/ui/compositor/compositor.h b/ui/compositor/compositor.h
index 1f263e2..83c34b4d 100644
--- a/ui/compositor/compositor.h
+++ b/ui/compositor/compositor.h
@@ -35,6 +35,10 @@ class Point;
class Rect;
}
+namespace gpu {
+struct Mailbox;
+}
+
namespace WebKit {
class WebGraphicsContext3D;
}
@@ -128,12 +132,12 @@ class COMPOSITOR_EXPORT Texture : public base::RefCounted<Texture> {
virtual WebKit::WebGraphicsContext3D* HostContext3D() = 0;
// Replaces the texture with the texture from the specified mailbox.
- virtual void Consume(const std::string& mailbox_name,
+ virtual void Consume(const gpu::Mailbox& mailbox_name,
const gfx::Size& new_size) {}
// Moves the texture into the mailbox and returns the mailbox name.
// The texture must have been previously consumed from a mailbox.
- virtual std::string Produce();
+ virtual gpu::Mailbox Produce();
protected:
virtual ~Texture();