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 "content/browser/browser_plugin/browser_plugin_guest.h" | 5 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 void BrowserPluginGuest::PointerLockPermissionResponse(bool allow) { | 313 void BrowserPluginGuest::PointerLockPermissionResponse(bool allow) { |
314 SendMessageToEmbedder( | 314 SendMessageToEmbedder( |
315 new BrowserPluginMsg_SetMouseLock(browser_plugin_instance_id(), allow)); | 315 new BrowserPluginMsg_SetMouseLock(browser_plugin_instance_id(), allow)); |
316 } | 316 } |
317 | 317 |
318 void BrowserPluginGuest::SwapCompositorFrame( | 318 void BrowserPluginGuest::SwapCompositorFrame( |
319 uint32 output_surface_id, | 319 uint32 output_surface_id, |
320 int host_process_id, | 320 int host_process_id, |
321 int host_routing_id, | 321 int host_routing_id, |
322 scoped_ptr<cc::CompositorFrame> frame) { | 322 scoped_ptr<cc::CompositorFrame> frame) { |
323 if (!attached()) { | |
324 // If the guest doesn't have an embedder then there's nothing to give the | |
325 // the frame to. | |
326 return; | |
327 } | |
328 | |
329 cc::RenderPass* root_pass = | 323 cc::RenderPass* root_pass = |
330 frame->delegated_frame_data->render_pass_list.back(); | 324 frame->delegated_frame_data->render_pass_list.back(); |
331 gfx::Size view_size(gfx::ToFlooredSize(gfx::ScaleSize( | 325 gfx::Size view_size(gfx::ToFlooredSize(gfx::ScaleSize( |
332 root_pass->output_rect.size(), | 326 root_pass->output_rect.size(), |
333 1.0f / frame->metadata.device_scale_factor))); | 327 1.0f / frame->metadata.device_scale_factor))); |
334 | 328 |
335 if (last_seen_view_size_ != view_size) { | 329 if (last_seen_view_size_ != view_size) { |
336 delegate_->GuestSizeChanged(last_seen_view_size_, view_size); | 330 delegate_->GuestSizeChanged(last_seen_view_size_, view_size); |
337 last_seen_view_size_ = view_size; | 331 last_seen_view_size_ = view_size; |
338 } | 332 } |
339 | 333 |
340 base::SharedMemoryHandle software_frame_handle = | |
341 base::SharedMemory::NULLHandle(); | |
342 if (frame->software_frame_data) { | |
343 cc::SoftwareFrameData* frame_data = frame->software_frame_data.get(); | |
344 scoped_ptr<cc::SharedBitmap> bitmap = | |
345 HostSharedBitmapManager::current()->GetSharedBitmapFromId( | |
346 frame_data->size, frame_data->bitmap_id); | |
347 if (!bitmap) | |
348 return; | |
349 | |
350 RenderWidgetHostView* embedder_rwhv = | |
351 GetEmbedderRenderWidgetHostView(); | |
352 base::ProcessHandle embedder_pid = | |
353 embedder_rwhv->GetRenderWidgetHost()->GetProcess()->GetHandle(); | |
354 | |
355 bitmap->memory()->ShareToProcess(embedder_pid, &software_frame_handle); | |
356 } | |
357 | |
358 FrameMsg_CompositorFrameSwapped_Params guest_params; | 334 FrameMsg_CompositorFrameSwapped_Params guest_params; |
359 frame->AssignTo(&guest_params.frame); | 335 frame->AssignTo(&guest_params.frame); |
360 guest_params.output_surface_id = output_surface_id; | 336 guest_params.output_surface_id = output_surface_id; |
361 guest_params.producing_route_id = host_routing_id; | 337 guest_params.producing_route_id = host_routing_id; |
362 guest_params.producing_host_id = host_process_id; | 338 guest_params.producing_host_id = host_process_id; |
363 guest_params.shared_memory_handle = software_frame_handle; | |
364 | 339 |
365 SendMessageToEmbedder( | 340 SendMessageToEmbedder( |
366 new BrowserPluginMsg_CompositorFrameSwapped( | 341 new BrowserPluginMsg_CompositorFrameSwapped( |
367 browser_plugin_instance_id(), guest_params)); | 342 browser_plugin_instance_id(), guest_params)); |
368 } | 343 } |
369 | 344 |
370 void BrowserPluginGuest::SetContentsOpaque(bool opaque) { | 345 void BrowserPluginGuest::SetContentsOpaque(bool opaque) { |
371 SendMessageToEmbedder( | 346 SendMessageToEmbedder( |
372 new BrowserPluginMsg_SetContentsOpaque( | 347 new BrowserPluginMsg_SetContentsOpaque( |
373 browser_plugin_instance_id(), opaque)); | 348 browser_plugin_instance_id(), opaque)); |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 void BrowserPluginGuest::OnImeCompositionRangeChanged( | 804 void BrowserPluginGuest::OnImeCompositionRangeChanged( |
830 const gfx::Range& range, | 805 const gfx::Range& range, |
831 const std::vector<gfx::Rect>& character_bounds) { | 806 const std::vector<gfx::Rect>& character_bounds) { |
832 static_cast<RenderWidgetHostViewBase*>( | 807 static_cast<RenderWidgetHostViewBase*>( |
833 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( | 808 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( |
834 range, character_bounds); | 809 range, character_bounds); |
835 } | 810 } |
836 #endif | 811 #endif |
837 | 812 |
838 } // namespace content | 813 } // namespace content |
OLD | NEW |