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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
9 #include "cc/layers/layer.h" | 9 #include "cc/layers/layer.h" |
10 #include "cc/layers/solid_color_layer.h" | 10 #include "cc/layers/solid_color_layer.h" |
11 #include "cc/layers/texture_layer.h" | 11 #include "cc/layers/texture_layer.h" |
12 #include "cc/resources/texture_mailbox.h" | 12 #include "cc/resources/texture_mailbox.h" |
13 #include "cc/trees/layer_tree_host.h" | 13 #include "cc/trees/layer_tree_host.h" |
14 #include "content/child/child_shared_bitmap_manager.h" | 14 #include "content/child/child_shared_bitmap_manager.h" |
15 #include "content/child/child_thread.h" | 15 #include "content/child/child_thread_impl.h" |
16 #include "content/public/renderer/renderer_ppapi_host.h" | 16 #include "content/public/renderer/renderer_ppapi_host.h" |
17 #include "content/renderer/pepper/gfx_conversion.h" | 17 #include "content/renderer/pepper/gfx_conversion.h" |
18 #include "content/renderer/pepper/host_globals.h" | 18 #include "content/renderer/pepper/host_globals.h" |
19 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 19 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
20 #include "content/renderer/pepper/ppb_image_data_impl.h" | 20 #include "content/renderer/pepper/ppb_image_data_impl.h" |
21 #include "ppapi/c/pp_errors.h" | 21 #include "ppapi/c/pp_errors.h" |
22 #include "ppapi/host/dispatch_host_message.h" | 22 #include "ppapi/host/dispatch_host_message.h" |
23 #include "ppapi/host/ppapi_host.h" | 23 #include "ppapi/host/ppapi_host.h" |
24 #include "ppapi/proxy/ppapi_messages.h" | 24 #include "ppapi/proxy/ppapi_messages.h" |
25 #include "ppapi/thunk/enter.h" | 25 #include "ppapi/thunk/enter.h" |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 true); | 281 true); |
282 DCHECK(enter.succeeded()); | 282 DCHECK(enter.succeeded()); |
283 | 283 |
284 // TODO(penghuang): support all kinds of image. | 284 // TODO(penghuang): support all kinds of image. |
285 PP_ImageDataDesc desc; | 285 PP_ImageDataDesc desc; |
286 PP_Bool rv = enter.object()->Describe(&desc); | 286 PP_Bool rv = enter.object()->Describe(&desc); |
287 DCHECK_EQ(rv, PP_TRUE); | 287 DCHECK_EQ(rv, PP_TRUE); |
288 DCHECK_EQ(desc.stride, desc.size.width * 4); | 288 DCHECK_EQ(desc.stride, desc.size.width * 4); |
289 DCHECK_EQ(desc.format, PP_IMAGEDATAFORMAT_RGBA_PREMUL); | 289 DCHECK_EQ(desc.format, PP_IMAGEDATAFORMAT_RGBA_PREMUL); |
290 scoped_ptr<cc::SharedBitmap> bitmap = | 290 scoped_ptr<cc::SharedBitmap> bitmap = |
291 ChildThread::current() | 291 ChildThreadImpl::current() |
292 ->shared_bitmap_manager() | 292 ->shared_bitmap_manager() |
293 ->GetBitmapForSharedMemory(image_shm.get()); | 293 ->GetBitmapForSharedMemory(image_shm.get()); |
294 | 294 |
295 cc::TextureMailbox mailbox(bitmap.get(), PP_ToGfxSize(desc.size)); | 295 cc::TextureMailbox mailbox(bitmap.get(), PP_ToGfxSize(desc.size)); |
296 image_layer->SetTextureMailbox( | 296 image_layer->SetTextureMailbox( |
297 mailbox, | 297 mailbox, |
298 cc::SingleReleaseCallback::Create(base::Bind( | 298 cc::SingleReleaseCallback::Create(base::Bind( |
299 &PepperCompositorHost::ImageReleased, weak_factory_.GetWeakPtr(), | 299 &PepperCompositorHost::ImageReleased, weak_factory_.GetWeakPtr(), |
300 new_layer->common.resource_id, base::Passed(&image_shm), | 300 new_layer->common.resource_id, base::Passed(&image_shm), |
301 base::Passed(&bitmap)))); | 301 base::Passed(&bitmap)))); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 | 388 |
389 // If the host is not bound to the instance, return PP_OK immediately. | 389 // If the host is not bound to the instance, return PP_OK immediately. |
390 if (!bound_instance_) | 390 if (!bound_instance_) |
391 return PP_OK; | 391 return PP_OK; |
392 | 392 |
393 commit_layers_reply_context_ = context->MakeReplyMessageContext(); | 393 commit_layers_reply_context_ = context->MakeReplyMessageContext(); |
394 return PP_OK_COMPLETIONPENDING; | 394 return PP_OK_COMPLETIONPENDING; |
395 } | 395 } |
396 | 396 |
397 } // namespace content | 397 } // namespace content |
OLD | NEW |