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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 | 340 |
341 void ImageData::InstanceWasDeleted() { | 341 void ImageData::InstanceWasDeleted() { |
342 ImageDataCache::GetInstance()->DidDeleteInstance(pp_instance()); | 342 ImageDataCache::GetInstance()->DidDeleteInstance(pp_instance()); |
343 } | 343 } |
344 | 344 |
345 PP_Bool ImageData::Describe(PP_ImageDataDesc* desc) { | 345 PP_Bool ImageData::Describe(PP_ImageDataDesc* desc) { |
346 memcpy(desc, &desc_, sizeof(PP_ImageDataDesc)); | 346 memcpy(desc, &desc_, sizeof(PP_ImageDataDesc)); |
347 return PP_TRUE; | 347 return PP_TRUE; |
348 } | 348 } |
349 | 349 |
350 int32_t ImageData::GetSharedMemory(base::SharedMemoryHandle* /* handle */, | 350 int32_t ImageData::GetSharedMemory(base::SharedMemory** /* shm */, |
351 uint32_t* /* byte_count */) { | 351 uint32_t* /* byte_count */) { |
352 // Not supported in the proxy (this method is for actually implementing the | 352 // Not supported in the proxy (this method is for actually implementing the |
353 // proxy in the host). | 353 // proxy in the host). |
354 return PP_ERROR_NOACCESS; | 354 return PP_ERROR_NOACCESS; |
355 } | 355 } |
356 | 356 |
357 void ImageData::SetIsCandidateForReuse() { | 357 void ImageData::SetIsCandidateForReuse() { |
358 is_candidate_for_reuse_ = true; | 358 is_candidate_for_reuse_ = true; |
359 } | 359 } |
360 | 360 |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 ppapi::ScopedPPResource resource(ppapi::ScopedPPResource::PassRef(), | 586 ppapi::ScopedPPResource resource(ppapi::ScopedPPResource::PassRef(), |
587 pp_resource); | 587 pp_resource); |
588 | 588 |
589 thunk::EnterResourceNoLock<PPB_ImageData_API> enter_resource(resource.get(), | 589 thunk::EnterResourceNoLock<PPB_ImageData_API> enter_resource(resource.get(), |
590 false); | 590 false); |
591 if (enter_resource.object()->Describe(desc) != PP_TRUE) { | 591 if (enter_resource.object()->Describe(desc) != PP_TRUE) { |
592 DVLOG(1) << "CreateImageData failed: could not Describe"; | 592 DVLOG(1) << "CreateImageData failed: could not Describe"; |
593 return 0; | 593 return 0; |
594 } | 594 } |
595 | 595 |
596 base::SharedMemoryHandle local_handle; | 596 base::SharedMemory* local_shm; |
597 if (enter_resource.object()->GetSharedMemory(&local_handle, byte_count) != | 597 if (enter_resource.object()->GetSharedMemory(&local_shm, byte_count) != |
598 PP_OK) { | 598 PP_OK) { |
599 DVLOG(1) << "CreateImageData failed: could not GetSharedMemory"; | 599 DVLOG(1) << "CreateImageData failed: could not GetSharedMemory"; |
600 return 0; | 600 return 0; |
601 } | 601 } |
602 | 602 |
603 *image_handle = dispatcher->ShareSharedMemoryHandleWithRemote(local_handle); | 603 *image_handle = |
| 604 dispatcher->ShareSharedMemoryHandleWithRemote(local_shm->handle()); |
604 return resource.Release(); | 605 return resource.Release(); |
605 } | 606 } |
606 | 607 |
607 void PPB_ImageData_Proxy::OnHostMsgCreatePlatform( | 608 void PPB_ImageData_Proxy::OnHostMsgCreatePlatform( |
608 PP_Instance instance, | 609 PP_Instance instance, |
609 int32_t format, | 610 int32_t format, |
610 const PP_Size& size, | 611 const PP_Size& size, |
611 PP_Bool init_to_zero, | 612 PP_Bool init_to_zero, |
612 HostResource* result, | 613 HostResource* result, |
613 PP_ImageDataDesc* desc, | 614 PP_ImageDataDesc* desc, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 // still cached in our process, the proxy still holds a reference so we can | 680 // still cached in our process, the proxy still holds a reference so we can |
680 // remove the one the renderer just sent is. If the proxy no longer holds a | 681 // remove the one the renderer just sent is. If the proxy no longer holds a |
681 // reference, we released everything and we should also release the one the | 682 // reference, we released everything and we should also release the one the |
682 // renderer just sent us. | 683 // renderer just sent us. |
683 dispatcher()->Send(new PpapiHostMsg_PPBCore_ReleaseResource( | 684 dispatcher()->Send(new PpapiHostMsg_PPBCore_ReleaseResource( |
684 API_ID_PPB_CORE, old_image_data)); | 685 API_ID_PPB_CORE, old_image_data)); |
685 } | 686 } |
686 | 687 |
687 } // namespace proxy | 688 } // namespace proxy |
688 } // namespace ppapi | 689 } // namespace ppapi |
OLD | NEW |