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 "base/bind_helpers.h" | 5 #include "base/bind_helpers.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 9 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
10 #include "content/browser/frame_host/render_widget_host_view_guest.h" | 10 #include "content/browser/frame_host/render_widget_host_view_guest.h" |
11 #include "content/browser/renderer_host/render_view_host_impl.h" | 11 #include "content/browser/renderer_host/render_view_host_impl.h" |
12 #include "content/common/browser_plugin/browser_plugin_messages.h" | 12 #include "content/common/browser_plugin/browser_plugin_messages.h" |
13 #include "content/common/frame_messages.h" | 13 #include "content/common/frame_messages.h" |
14 #include "content/common/gpu/gpu_messages.h" | 14 #include "content/common/gpu/gpu_messages.h" |
15 #include "content/common/host_shared_bitmap_manager.h" | |
16 #include "content/common/input/web_touch_event_traits.h" | 15 #include "content/common/input/web_touch_event_traits.h" |
17 #include "content/common/view_messages.h" | 16 #include "content/common/view_messages.h" |
18 #include "content/common/webplugin_geometry.h" | 17 #include "content/common/webplugin_geometry.h" |
19 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
20 #include "skia/ext/platform_canvas.h" | 19 #include "skia/ext/platform_canvas.h" |
21 #include "third_party/WebKit/public/platform/WebScreenInfo.h" | 20 #include "third_party/WebKit/public/platform/WebScreenInfo.h" |
22 | 21 |
23 #if defined(OS_MACOSX) | 22 #if defined(OS_MACOSX) |
24 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he
lper.h" | 23 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he
lper.h" |
25 #endif | 24 #endif |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 int gpu_host_id) { | 184 int gpu_host_id) { |
186 NOTREACHED(); | 185 NOTREACHED(); |
187 } | 186 } |
188 | 187 |
189 void RenderWidgetHostViewGuest::OnSwapCompositorFrame( | 188 void RenderWidgetHostViewGuest::OnSwapCompositorFrame( |
190 uint32 output_surface_id, | 189 uint32 output_surface_id, |
191 scoped_ptr<cc::CompositorFrame> frame) { | 190 scoped_ptr<cc::CompositorFrame> frame) { |
192 if (!guest_) | 191 if (!guest_) |
193 return; | 192 return; |
194 | 193 |
195 if (!guest_->attached()) { | |
196 // If the guest doesn't have an embedder then there's nothing to give the | |
197 // the frame to. | |
198 return; | |
199 } | |
200 | |
201 last_scroll_offset_ = frame->metadata.root_scroll_offset; | 194 last_scroll_offset_ = frame->metadata.root_scroll_offset; |
202 base::SharedMemoryHandle software_frame_handle = | 195 guest_->SwapCompositorFrame(output_surface_id, |
203 base::SharedMemory::NULLHandle(); | 196 host_->GetProcess()->GetID(), |
204 if (frame->software_frame_data) { | 197 host_->GetRoutingID(), |
205 cc::SoftwareFrameData* frame_data = frame->software_frame_data.get(); | 198 frame.Pass()); |
206 scoped_ptr<cc::SharedBitmap> bitmap = | |
207 HostSharedBitmapManager::current()->GetSharedBitmapFromId( | |
208 frame_data->size, frame_data->bitmap_id); | |
209 if (!bitmap) | |
210 return; | |
211 | |
212 RenderWidgetHostView* embedder_rwhv = | |
213 guest_->GetEmbedderRenderWidgetHostView(); | |
214 base::ProcessHandle embedder_pid = | |
215 embedder_rwhv->GetRenderWidgetHost()->GetProcess()->GetHandle(); | |
216 | |
217 bitmap->memory()->ShareToProcess(embedder_pid, &software_frame_handle); | |
218 } | |
219 | |
220 FrameMsg_CompositorFrameSwapped_Params guest_params; | |
221 frame->AssignTo(&guest_params.frame); | |
222 guest_params.output_surface_id = output_surface_id; | |
223 guest_params.producing_route_id = host_->GetRoutingID(); | |
224 guest_params.producing_host_id = host_->GetProcess()->GetID(); | |
225 guest_params.shared_memory_handle = software_frame_handle; | |
226 | |
227 guest_->SendMessageToEmbedder( | |
228 new BrowserPluginMsg_CompositorFrameSwapped( | |
229 guest_->browser_plugin_instance_id(), guest_params)); | |
230 } | 199 } |
231 | 200 |
232 bool RenderWidgetHostViewGuest::OnMessageReceived(const IPC::Message& msg) { | 201 bool RenderWidgetHostViewGuest::OnMessageReceived(const IPC::Message& msg) { |
233 return platform_view_->OnMessageReceived(msg); | 202 return platform_view_->OnMessageReceived(msg); |
234 } | 203 } |
235 | 204 |
236 void RenderWidgetHostViewGuest::InitAsChild( | 205 void RenderWidgetHostViewGuest::InitAsChild( |
237 gfx::NativeView parent_view) { | 206 gfx::NativeView parent_view) { |
238 platform_view_->InitAsChild(parent_view); | 207 platform_view_->InitAsChild(parent_view); |
239 } | 208 } |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 return kN32_SkColorType; | 523 return kN32_SkColorType; |
555 } | 524 } |
556 | 525 |
557 RenderWidgetHostViewBase* | 526 RenderWidgetHostViewBase* |
558 RenderWidgetHostViewGuest::GetGuestRenderWidgetHostView() const { | 527 RenderWidgetHostViewGuest::GetGuestRenderWidgetHostView() const { |
559 return static_cast<RenderWidgetHostViewBase*>( | 528 return static_cast<RenderWidgetHostViewBase*>( |
560 guest_->GetEmbedderRenderWidgetHostView()); | 529 guest_->GetEmbedderRenderWidgetHostView()); |
561 } | 530 } |
562 | 531 |
563 } // namespace content | 532 } // namespace content |
OLD | NEW |