| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_compositor_host.h" | 5 #include "content/renderer/pepper/pepper_compositor_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/shared_memory.h" | 12 #include "base/memory/shared_memory.h" |
| 13 #include "cc/blink/web_layer_impl.h" | 13 #include "cc/blink/web_layer_impl.h" |
| 14 #include "cc/layers/layer.h" | 14 #include "cc/layers/layer.h" |
| 15 #include "cc/layers/solid_color_layer.h" | 15 #include "cc/layers/solid_color_layer.h" |
| 16 #include "cc/layers/texture_layer.h" | 16 #include "cc/layers/texture_layer.h" |
| 17 #include "cc/resources/texture_mailbox.h" | 17 #include "cc/resources/texture_mailbox.h" |
| 18 #include "cc/trees/layer_tree_host.h" | 18 #include "cc/trees/layer_tree_host.h" |
| 19 #include "content/child/child_shared_bitmap_manager.h" | 19 #include "content/child/child_shared_bitmap_manager.h" |
| 20 #include "content/child/child_thread_impl.h" |
| 20 #include "content/public/renderer/renderer_ppapi_host.h" | 21 #include "content/public/renderer/renderer_ppapi_host.h" |
| 21 #include "content/renderer/pepper/gfx_conversion.h" | 22 #include "content/renderer/pepper/gfx_conversion.h" |
| 22 #include "content/renderer/pepper/host_globals.h" | 23 #include "content/renderer/pepper/host_globals.h" |
| 23 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 24 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 24 #include "content/renderer/pepper/ppb_image_data_impl.h" | 25 #include "content/renderer/pepper/ppb_image_data_impl.h" |
| 25 #include "content/renderer/render_thread_impl.h" | |
| 26 #include "ppapi/c/pp_errors.h" | 26 #include "ppapi/c/pp_errors.h" |
| 27 #include "ppapi/host/dispatch_host_message.h" | 27 #include "ppapi/host/dispatch_host_message.h" |
| 28 #include "ppapi/host/ppapi_host.h" | 28 #include "ppapi/host/ppapi_host.h" |
| 29 #include "ppapi/proxy/ppapi_messages.h" | 29 #include "ppapi/proxy/ppapi_messages.h" |
| 30 #include "ppapi/thunk/enter.h" | 30 #include "ppapi/thunk/enter.h" |
| 31 #include "ppapi/thunk/ppb_image_data_api.h" | 31 #include "ppapi/thunk/ppb_image_data_api.h" |
| 32 #include "third_party/khronos/GLES2/gl2.h" | 32 #include "third_party/khronos/GLES2/gl2.h" |
| 33 #include "ui/gfx/geometry/size_conversions.h" | 33 #include "ui/gfx/geometry/size_conversions.h" |
| 34 #include "ui/gfx/transform.h" | 34 #include "ui/gfx/transform.h" |
| 35 | 35 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 true); | 308 true); |
| 309 DCHECK(enter.succeeded()); | 309 DCHECK(enter.succeeded()); |
| 310 | 310 |
| 311 // TODO(penghuang): support all kinds of image. | 311 // TODO(penghuang): support all kinds of image. |
| 312 PP_ImageDataDesc desc; | 312 PP_ImageDataDesc desc; |
| 313 PP_Bool rv = enter.object()->Describe(&desc); | 313 PP_Bool rv = enter.object()->Describe(&desc); |
| 314 DCHECK_EQ(rv, PP_TRUE); | 314 DCHECK_EQ(rv, PP_TRUE); |
| 315 DCHECK_EQ(desc.stride, desc.size.width * 4); | 315 DCHECK_EQ(desc.stride, desc.size.width * 4); |
| 316 DCHECK_EQ(desc.format, PP_IMAGEDATAFORMAT_RGBA_PREMUL); | 316 DCHECK_EQ(desc.format, PP_IMAGEDATAFORMAT_RGBA_PREMUL); |
| 317 std::unique_ptr<cc::SharedBitmap> bitmap = | 317 std::unique_ptr<cc::SharedBitmap> bitmap = |
| 318 RenderThreadImpl::current() | 318 ChildThreadImpl::current() |
| 319 ->shared_bitmap_manager() | 319 ->shared_bitmap_manager() |
| 320 ->GetBitmapForSharedMemory(image_shm.get()); | 320 ->GetBitmapForSharedMemory(image_shm.get()); |
| 321 | 321 |
| 322 cc::TextureMailbox mailbox(bitmap.get(), PP_ToGfxSize(desc.size)); | 322 cc::TextureMailbox mailbox(bitmap.get(), PP_ToGfxSize(desc.size)); |
| 323 image_layer->SetTextureMailbox( | 323 image_layer->SetTextureMailbox( |
| 324 mailbox, | 324 mailbox, |
| 325 cc::SingleReleaseCallback::Create(base::Bind( | 325 cc::SingleReleaseCallback::Create(base::Bind( |
| 326 &PepperCompositorHost::ImageReleased, weak_factory_.GetWeakPtr(), | 326 &PepperCompositorHost::ImageReleased, weak_factory_.GetWeakPtr(), |
| 327 new_layer->common.resource_id, base::Passed(&image_shm), | 327 new_layer->common.resource_id, base::Passed(&image_shm), |
| 328 base::Passed(&bitmap)))); | 328 base::Passed(&bitmap)))); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 | 415 |
| 416 // If the host is not bound to the instance, return PP_OK immediately. | 416 // If the host is not bound to the instance, return PP_OK immediately. |
| 417 if (!bound_instance_) | 417 if (!bound_instance_) |
| 418 return PP_OK; | 418 return PP_OK; |
| 419 | 419 |
| 420 commit_layers_reply_context_ = context->MakeReplyMessageContext(); | 420 commit_layers_reply_context_ = context->MakeReplyMessageContext(); |
| 421 return PP_OK_COMPLETIONPENDING; | 421 return PP_OK_COMPLETIONPENDING; |
| 422 } | 422 } |
| 423 | 423 |
| 424 } // namespace content | 424 } // namespace content |
| OLD | NEW |