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 "ppapi/proxy/ppb_image_data_proxy.h" | 5 #include "ppapi/proxy/ppb_image_data_proxy.h" |
6 | 6 |
7 #include <string.h> // For memcpy | 7 #include <string.h> // For memcpy |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <vector> | 10 #include <vector> |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 } | 368 } |
369 | 369 |
370 // PlatformImageData ----------------------------------------------------------- | 370 // PlatformImageData ----------------------------------------------------------- |
371 | 371 |
372 #if !defined(OS_NACL) | 372 #if !defined(OS_NACL) |
373 PlatformImageData::PlatformImageData(const HostResource& resource, | 373 PlatformImageData::PlatformImageData(const HostResource& resource, |
374 const PP_ImageDataDesc& desc, | 374 const PP_ImageDataDesc& desc, |
375 ImageHandle handle) | 375 ImageHandle handle) |
376 : ImageData(resource, PPB_ImageData_Shared::PLATFORM, desc) { | 376 : ImageData(resource, PPB_ImageData_Shared::PLATFORM, desc) { |
377 #if defined(OS_WIN) | 377 #if defined(OS_WIN) |
378 transport_dib_.reset(TransportDIB::CreateWithHandle(handle)); | 378 transport_dib_.reset(TransportDIB::CreateWithHandle( |
| 379 base::SharedMemoryHandle(handle, base::GetCurrentProcId()))); |
379 #else | 380 #else |
380 transport_dib_.reset(TransportDIB::Map(handle)); | 381 transport_dib_.reset(TransportDIB::Map(handle)); |
381 #endif // defined(OS_WIN) | 382 #endif // defined(OS_WIN) |
382 } | 383 } |
383 | 384 |
384 PlatformImageData::~PlatformImageData() { | 385 PlatformImageData::~PlatformImageData() { |
385 } | 386 } |
386 | 387 |
387 void* PlatformImageData::Map() { | 388 void* PlatformImageData::Map() { |
388 if (!mapped_canvas_.get()) { | 389 if (!mapped_canvas_.get()) { |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 uint32_t byte_count; | 621 uint32_t byte_count; |
621 PP_Resource resource = | 622 PP_Resource resource = |
622 CreateImageData(instance, | 623 CreateImageData(instance, |
623 PPB_ImageData_Shared::PLATFORM, | 624 PPB_ImageData_Shared::PLATFORM, |
624 static_cast<PP_ImageDataFormat>(format), | 625 static_cast<PP_ImageDataFormat>(format), |
625 size, | 626 size, |
626 true /* init_to_zero */, | 627 true /* init_to_zero */, |
627 desc, &image_handle, &byte_count); | 628 desc, &image_handle, &byte_count); |
628 result->SetHostResource(instance, resource); | 629 result->SetHostResource(instance, resource); |
629 if (resource) { | 630 if (resource) { |
| 631 #if defined(OS_WIN) |
| 632 *result_image_handle = image_handle.GetHandle(); |
| 633 #else |
630 *result_image_handle = image_handle; | 634 *result_image_handle = image_handle; |
| 635 #endif |
631 } else { | 636 } else { |
632 *result_image_handle = PlatformImageData::NullHandle(); | 637 *result_image_handle = PlatformImageData::NullHandle(); |
633 } | 638 } |
634 } | 639 } |
635 | 640 |
636 void PPB_ImageData_Proxy::OnHostMsgCreateSimple( | 641 void PPB_ImageData_Proxy::OnHostMsgCreateSimple( |
637 PP_Instance instance, | 642 PP_Instance instance, |
638 int32_t format, | 643 int32_t format, |
639 const PP_Size& size, | 644 const PP_Size& size, |
640 PP_Bool init_to_zero, | 645 PP_Bool init_to_zero, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 // still cached in our process, the proxy still holds a reference so we can | 685 // still cached in our process, the proxy still holds a reference so we can |
681 // remove the one the renderer just sent is. If the proxy no longer holds a | 686 // remove the one the renderer just sent is. If the proxy no longer holds a |
682 // reference, we released everything and we should also release the one the | 687 // reference, we released everything and we should also release the one the |
683 // renderer just sent us. | 688 // renderer just sent us. |
684 dispatcher()->Send(new PpapiHostMsg_PPBCore_ReleaseResource( | 689 dispatcher()->Send(new PpapiHostMsg_PPBCore_ReleaseResource( |
685 API_ID_PPB_CORE, old_image_data)); | 690 API_ID_PPB_CORE, old_image_data)); |
686 } | 691 } |
687 | 692 |
688 } // namespace proxy | 693 } // namespace proxy |
689 } // namespace ppapi | 694 } // namespace ppapi |
OLD | NEW |