| 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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 memset(data, 0, desc_.stride * desc_.size.height); | 423 memset(data, 0, desc_.stride * desc_.size.height); |
| 424 Unmap(); | 424 Unmap(); |
| 425 } | 425 } |
| 426 } | 426 } |
| 427 | 427 |
| 428 #if !defined(OS_NACL) | 428 #if !defined(OS_NACL) |
| 429 // static | 429 // static |
| 430 ImageHandle ImageData::NullHandle() { | 430 ImageHandle ImageData::NullHandle() { |
| 431 #if defined(OS_WIN) | 431 #if defined(OS_WIN) |
| 432 return NULL; | 432 return NULL; |
| 433 #elif defined(OS_MACOSX) || defined(OS_ANDROID) | 433 #elif defined(TOOLKIT_GTK) |
| 434 return 0; |
| 435 #else |
| 434 return ImageHandle(); | 436 return ImageHandle(); |
| 435 #else | |
| 436 return 0; | |
| 437 #endif | 437 #endif |
| 438 } | 438 } |
| 439 | 439 |
| 440 ImageHandle ImageData::HandleFromInt(int32_t i) { | 440 ImageHandle ImageData::HandleFromInt(int32_t i) { |
| 441 #if defined(OS_WIN) | 441 #if defined(OS_WIN) |
| 442 return reinterpret_cast<ImageHandle>(i); | 442 return reinterpret_cast<ImageHandle>(i); |
| 443 #elif defined(OS_MACOSX) || defined(OS_ANDROID) | 443 #elif defined(TOOLKIT_GTK) |
| 444 return static_cast<ImageHandle>(i); |
| 445 #else |
| 444 return ImageHandle(i, false); | 446 return ImageHandle(i, false); |
| 445 #else | |
| 446 return static_cast<ImageHandle>(i); | |
| 447 #endif | 447 #endif |
| 448 } | 448 } |
| 449 #endif // !defined(OS_NACL) | 449 #endif // !defined(OS_NACL) |
| 450 | 450 |
| 451 // PPB_ImageData_Proxy --------------------------------------------------------- | 451 // PPB_ImageData_Proxy --------------------------------------------------------- |
| 452 | 452 |
| 453 PPB_ImageData_Proxy::PPB_ImageData_Proxy(Dispatcher* dispatcher) | 453 PPB_ImageData_Proxy::PPB_ImageData_Proxy(Dispatcher* dispatcher) |
| 454 : InterfaceProxy(dispatcher) { | 454 : InterfaceProxy(dispatcher) { |
| 455 } | 455 } |
| 456 | 456 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 CreateImageData(instance, | 595 CreateImageData(instance, |
| 596 static_cast<PP_ImageDataFormat>(format), | 596 static_cast<PP_ImageDataFormat>(format), |
| 597 size, | 597 size, |
| 598 true /* init_to_zero */, | 598 true /* init_to_zero */, |
| 599 false /* is_nacl_plugin */, | 599 false /* is_nacl_plugin */, |
| 600 &desc, &image_handle, &byte_count); | 600 &desc, &image_handle, &byte_count); |
| 601 result->SetHostResource(instance, resource); | 601 result->SetHostResource(instance, resource); |
| 602 if (resource) { | 602 if (resource) { |
| 603 image_data_desc->resize(sizeof(PP_ImageDataDesc)); | 603 image_data_desc->resize(sizeof(PP_ImageDataDesc)); |
| 604 memcpy(&(*image_data_desc)[0], &desc, sizeof(PP_ImageDataDesc)); | 604 memcpy(&(*image_data_desc)[0], &desc, sizeof(PP_ImageDataDesc)); |
| 605 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_ANDROID) | 605 #if defined(TOOLKIT_GTK) |
| 606 *result_image_handle = image_handle; | |
| 607 #else | |
| 608 // On X Windows ImageHandle is a SysV shared memory key. | 606 // On X Windows ImageHandle is a SysV shared memory key. |
| 609 *result_image_handle = image_handle.fd; | 607 *result_image_handle = image_handle.fd; |
| 608 #else |
| 609 *result_image_handle = image_handle; |
| 610 #endif | 610 #endif |
| 611 } else { | 611 } else { |
| 612 image_data_desc->clear(); | 612 image_data_desc->clear(); |
| 613 *result_image_handle = ImageData::NullHandle(); | 613 *result_image_handle = ImageData::NullHandle(); |
| 614 } | 614 } |
| 615 } | 615 } |
| 616 | 616 |
| 617 void PPB_ImageData_Proxy::OnHostMsgCreateNaCl( | 617 void PPB_ImageData_Proxy::OnHostMsgCreateNaCl( |
| 618 PP_Instance instance, | 618 PP_Instance instance, |
| 619 int32_t format, | 619 int32_t format, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 // still cached in our process, the proxy still holds a reference so we can | 662 // still cached in our process, the proxy still holds a reference so we can |
| 663 // remove the one the renderer just sent is. If the proxy no longer holds a | 663 // remove the one the renderer just sent is. If the proxy no longer holds a |
| 664 // reference, we released everything and we should also release the one the | 664 // reference, we released everything and we should also release the one the |
| 665 // renderer just sent us. | 665 // renderer just sent us. |
| 666 dispatcher()->Send(new PpapiHostMsg_PPBCore_ReleaseResource( | 666 dispatcher()->Send(new PpapiHostMsg_PPBCore_ReleaseResource( |
| 667 API_ID_PPB_CORE, old_image_data)); | 667 API_ID_PPB_CORE, old_image_data)); |
| 668 } | 668 } |
| 669 | 669 |
| 670 } // namespace proxy | 670 } // namespace proxy |
| 671 } // namespace ppapi | 671 } // namespace ppapi |
| OLD | NEW |