Chromium Code Reviews| Index: content/renderer/pepper/pepper_graphics_2d_host.cc |
| diff --git a/content/renderer/pepper/pepper_graphics_2d_host.cc b/content/renderer/pepper/pepper_graphics_2d_host.cc |
| index f1d719748d3cf578a0009ada12d35f16f0dacf6b..15a57a9c82b71a610a7b5c635869d01aaec8f894 100644 |
| --- a/content/renderer/pepper/pepper_graphics_2d_host.cc |
| +++ b/content/renderer/pepper/pepper_graphics_2d_host.cc |
| @@ -8,6 +8,8 @@ |
| #include "base/debug/trace_event.h" |
| #include "base/logging.h" |
| #include "base/message_loop/message_loop.h" |
| +#include "cc/resources/texture_mailbox.h" |
| +#include "content/public/renderer/render_thread.h" |
| #include "content/public/renderer/renderer_ppapi_host.h" |
| #include "content/renderer/pepper/common.h" |
| #include "content/renderer/pepper/gfx_conversion.h" |
| @@ -187,8 +189,8 @@ PepperGraphics2DHost::PepperGraphics2DHost(RendererPpapiHost* host, |
| is_always_opaque_(false), |
| scale_(1.0f), |
| weak_ptr_factory_(this), |
| - is_running_in_process_(host->IsRunningInProcess()) { |
| -} |
| + is_running_in_process_(host->IsRunningInProcess()), |
| + texture_mailbox_modified_(true) {} |
| PepperGraphics2DHost::~PepperGraphics2DHost() { |
| // Unbind from the instance when destroyed if we're still bound. |
| @@ -312,6 +314,8 @@ bool PepperGraphics2DHost::BindToInstance( |
| new_instance->InvalidateRect(gfx::Rect()); |
| } |
| + texture_mailbox_modified_ = true; |
| + |
| bound_instance_ = new_instance; |
| return true; |
| } |
| @@ -551,6 +555,32 @@ int32_t PepperGraphics2DHost::OnHostMsgReadImageData( |
| return ReadImageData(image, &top_left) ? PP_OK : PP_ERROR_FAILED; |
| } |
| +void ReleaseCallback(scoped_ptr<base::SharedMemory> memory, |
| + unsigned sync_point, |
| + bool lost_resource) {} |
| + |
| +bool PepperGraphics2DHost::PrepareTextureMailbox(cc::TextureMailbox* mailbox) { |
| + if (!texture_mailbox_modified_) |
| + return false; |
|
piman
2013/09/05 00:19:43
one detail, as we switch to fullscreen and back, t
|
| + // TODO(jbauman): Send image_data_ through mailbox to avoid copy. |
| + gfx::Size pixel_image_size(image_data_->width(), image_data_->height()); |
| + int buffer_size = pixel_image_size.GetArea() * 4; |
| + scoped_ptr<base::SharedMemory> memory = |
| + RenderThread::Get()->HostAllocateSharedMemoryBuffer(buffer_size); |
| + if (!memory || !memory->Map(buffer_size)) |
| + return false; |
| + void* src = image_data_->Map(); |
| + memcpy(memory->memory(), src, buffer_size); |
|
piman
2013/09/05 00:19:43
image_data_->Unmap();
|
| + |
| + base::SharedMemory* mem = memory.get(); |
| + *mailbox = |
| + cc::TextureMailbox(mem, |
| + pixel_image_size, |
| + base::Bind(&ReleaseCallback, base::Passed(&memory))); |
| + texture_mailbox_modified_ = false; |
| + return true; |
| +} |
| + |
| int32_t PepperGraphics2DHost::Flush(PP_Resource* old_image_data) { |
| bool done_replace_contents = false; |
| bool no_update_visible = true; |
| @@ -616,6 +646,7 @@ int32_t PepperGraphics2DHost::Flush(PP_Resource* old_image_data) { |
| } else { |
| bound_instance_->InvalidateRect(op_rect); |
| } |
| + texture_mailbox_modified_ = true; |
| } |
| } |
| queued_operations_.clear(); |