| 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 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 scoped_refptr<ImageData> cached_image_data = | 487 scoped_refptr<ImageData> cached_image_data = |
| 488 ImageDataCache::GetInstance()->Get(instance, type, | 488 ImageDataCache::GetInstance()->Get(instance, type, |
| 489 size.width, size.height, format); | 489 size.width, size.height, format); |
| 490 if (cached_image_data.get()) { | 490 if (cached_image_data.get()) { |
| 491 // We have one we can re-use rather than allocating a new one. | 491 // We have one we can re-use rather than allocating a new one. |
| 492 cached_image_data->RecycleToPlugin(PP_ToBool(init_to_zero)); | 492 cached_image_data->RecycleToPlugin(PP_ToBool(init_to_zero)); |
| 493 return cached_image_data->GetReference(); | 493 return cached_image_data->GetReference(); |
| 494 } | 494 } |
| 495 | 495 |
| 496 HostResource result; | 496 HostResource result; |
| 497 PP_ImageDataDesc desc; | 497 // Initialize desc so we don't send unitialized memory over IPC. |
| 498 // https://crbug.com/391023. |
| 499 PP_ImageDataDesc desc = {}; |
| 498 switch (type) { | 500 switch (type) { |
| 499 case PPB_ImageData_Shared::SIMPLE: { | 501 case PPB_ImageData_Shared::SIMPLE: { |
| 500 ppapi::proxy::SerializedHandle image_handle_wrapper; | 502 ppapi::proxy::SerializedHandle image_handle_wrapper; |
| 501 dispatcher->Send(new PpapiHostMsg_PPBImageData_CreateSimple( | 503 dispatcher->Send(new PpapiHostMsg_PPBImageData_CreateSimple( |
| 502 kApiID, instance, format, size, init_to_zero, | 504 kApiID, instance, format, size, init_to_zero, |
| 503 &result, &desc, &image_handle_wrapper)); | 505 &result, &desc, &image_handle_wrapper)); |
| 504 if (image_handle_wrapper.is_shmem()) { | 506 if (image_handle_wrapper.is_shmem()) { |
| 505 base::SharedMemoryHandle image_handle = image_handle_wrapper.shmem(); | 507 base::SharedMemoryHandle image_handle = image_handle_wrapper.shmem(); |
| 506 if (!result.is_null()) | 508 if (!result.is_null()) |
| 507 return | 509 return |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 // still cached in our process, the proxy still holds a reference so we can | 683 // still cached in our process, the proxy still holds a reference so we can |
| 682 // remove the one the renderer just sent is. If the proxy no longer holds a | 684 // remove the one the renderer just sent is. If the proxy no longer holds a |
| 683 // reference, we released everything and we should also release the one the | 685 // reference, we released everything and we should also release the one the |
| 684 // renderer just sent us. | 686 // renderer just sent us. |
| 685 dispatcher()->Send(new PpapiHostMsg_PPBCore_ReleaseResource( | 687 dispatcher()->Send(new PpapiHostMsg_PPBCore_ReleaseResource( |
| 686 API_ID_PPB_CORE, old_image_data)); | 688 API_ID_PPB_CORE, old_image_data)); |
| 687 } | 689 } |
| 688 | 690 |
| 689 } // namespace proxy | 691 } // namespace proxy |
| 690 } // namespace ppapi | 692 } // namespace ppapi |
| OLD | NEW |