| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/pepper/pepper_graphics_2d_host.h" | 5 #include "content/renderer/pepper/pepper_graphics_2d_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 PP_Resource image, | 552 PP_Resource image, |
| 553 const PP_Point& top_left) { | 553 const PP_Point& top_left) { |
| 554 context->reply_msg = PpapiPluginMsg_Graphics2D_ReadImageDataAck(); | 554 context->reply_msg = PpapiPluginMsg_Graphics2D_ReadImageDataAck(); |
| 555 return ReadImageData(image, &top_left) ? PP_OK : PP_ERROR_FAILED; | 555 return ReadImageData(image, &top_left) ? PP_OK : PP_ERROR_FAILED; |
| 556 } | 556 } |
| 557 | 557 |
| 558 void ReleaseCallback(scoped_ptr<base::SharedMemory> memory, | 558 void ReleaseCallback(scoped_ptr<base::SharedMemory> memory, |
| 559 unsigned sync_point, | 559 unsigned sync_point, |
| 560 bool lost_resource) {} | 560 bool lost_resource) {} |
| 561 | 561 |
| 562 bool PepperGraphics2DHost::PrepareTextureMailbox(cc::TextureMailbox* mailbox) { | 562 bool PepperGraphics2DHost::PrepareTextureMailbox( |
| 563 cc::TextureMailbox* mailbox, |
| 564 scoped_ptr<cc::ScopedReleaseCallback>* release_callback) { |
| 563 if (!texture_mailbox_modified_) | 565 if (!texture_mailbox_modified_) |
| 564 return false; | 566 return false; |
| 565 // TODO(jbauman): Send image_data_ through mailbox to avoid copy. | 567 // TODO(jbauman): Send image_data_ through mailbox to avoid copy. |
| 566 gfx::Size pixel_image_size(image_data_->width(), image_data_->height()); | 568 gfx::Size pixel_image_size(image_data_->width(), image_data_->height()); |
| 567 int buffer_size = pixel_image_size.GetArea() * 4; | 569 int buffer_size = pixel_image_size.GetArea() * 4; |
| 568 scoped_ptr<base::SharedMemory> memory = | 570 scoped_ptr<base::SharedMemory> memory = |
| 569 RenderThread::Get()->HostAllocateSharedMemoryBuffer(buffer_size); | 571 RenderThread::Get()->HostAllocateSharedMemoryBuffer(buffer_size); |
| 570 if (!memory || !memory->Map(buffer_size)) | 572 if (!memory || !memory->Map(buffer_size)) |
| 571 return false; | 573 return false; |
| 572 void* src = image_data_->Map(); | 574 void* src = image_data_->Map(); |
| 573 memcpy(memory->memory(), src, buffer_size); | 575 memcpy(memory->memory(), src, buffer_size); |
| 574 image_data_->Unmap(); | 576 image_data_->Unmap(); |
| 575 | 577 |
| 576 base::SharedMemory* mem = memory.get(); | 578 base::SharedMemory* mem = memory.get(); |
| 577 *mailbox = | 579 *mailbox = cc::TextureMailbox(mem, pixel_image_size); |
| 578 cc::TextureMailbox(mem, | 580 *release_callback = cc::ScopedReleaseCallback::Create( |
| 579 pixel_image_size, | 581 base::Bind(&ReleaseCallback, base::Passed(&memory))); |
| 580 base::Bind(&ReleaseCallback, base::Passed(&memory))); | |
| 581 texture_mailbox_modified_ = false; | 582 texture_mailbox_modified_ = false; |
| 582 return true; | 583 return true; |
| 583 } | 584 } |
| 584 | 585 |
| 585 void PepperGraphics2DHost::AttachedToNewLayer() { | 586 void PepperGraphics2DHost::AttachedToNewLayer() { |
| 586 texture_mailbox_modified_ = true; | 587 texture_mailbox_modified_ = true; |
| 587 } | 588 } |
| 588 | 589 |
| 589 int32_t PepperGraphics2DHost::Flush(PP_Resource* old_image_data) { | 590 int32_t PepperGraphics2DHost::Flush(PP_Resource* old_image_data) { |
| 590 bool done_replace_contents = false; | 591 bool done_replace_contents = false; |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 gfx::Point inverse_scaled_point = | 795 gfx::Point inverse_scaled_point = |
| 795 gfx::ToFlooredPoint(gfx::ScalePoint(*delta, inverse_scale)); | 796 gfx::ToFlooredPoint(gfx::ScalePoint(*delta, inverse_scale)); |
| 796 if (original_delta != inverse_scaled_point) | 797 if (original_delta != inverse_scaled_point) |
| 797 return false; | 798 return false; |
| 798 } | 799 } |
| 799 | 800 |
| 800 return true; | 801 return true; |
| 801 } | 802 } |
| 802 | 803 |
| 803 } // namespace content | 804 } // namespace content |
| OLD | NEW |