Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: content/browser/frame_host/render_widget_host_view_child_frame.cc

Issue 1094113003: Allow out-of-process iframes to render to compositing surfaces. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed typo Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/browser/frame_host/render_widget_host_view_child_frame.h" 5 #include "content/browser/frame_host/render_widget_host_view_child_frame.h"
6 6
7 #include "cc/surfaces/surface.h"
8 #include "cc/surfaces/surface_factory.h"
9 #include "cc/surfaces/surface_manager.h"
10 #include "cc/surfaces/surface_sequence.h"
7 #include "content/browser/accessibility/browser_accessibility_manager.h" 11 #include "content/browser/accessibility/browser_accessibility_manager.h"
8 #include "content/browser/frame_host/cross_process_frame_connector.h" 12 #include "content/browser/frame_host/cross_process_frame_connector.h"
13 #include "content/browser/gpu/compositor_util.h"
9 #include "content/browser/renderer_host/render_widget_host_impl.h" 14 #include "content/browser/renderer_host/render_widget_host_impl.h"
10 #include "content/common/gpu/gpu_messages.h" 15 #include "content/common/gpu/gpu_messages.h"
11 #include "content/common/view_messages.h" 16 #include "content/common/view_messages.h"
12 #include "content/public/browser/render_process_host.h" 17 #include "content/public/browser/render_process_host.h"
13 18
14 namespace content { 19 namespace content {
15 20
16 RenderWidgetHostViewChildFrame::RenderWidgetHostViewChildFrame( 21 RenderWidgetHostViewChildFrame::RenderWidgetHostViewChildFrame(
17 RenderWidgetHost* widget_host) 22 RenderWidgetHost* widget_host)
18 : host_(RenderWidgetHostImpl::From(widget_host)), 23 : host_(RenderWidgetHostImpl::From(widget_host)),
24 use_surfaces_(UseSurfacesEnabled()),
25 next_surface_sequence_(1u),
26 last_output_surface_id_(0),
27 current_surface_scale_factor_(1.f),
19 frame_connector_(NULL) { 28 frame_connector_(NULL) {
20 host_->SetView(this); 29 host_->SetView(this);
21 } 30 }
22 31
23 RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() { 32 RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() {
33 if (!surface_id_.is_null())
34 surface_factory_->Destroy(surface_id_);
24 } 35 }
25 36
26 void RenderWidgetHostViewChildFrame::InitAsChild( 37 void RenderWidgetHostViewChildFrame::InitAsChild(
27 gfx::NativeView parent_view) { 38 gfx::NativeView parent_view) {
28 NOTREACHED(); 39 NOTREACHED();
29 } 40 }
30 41
31 RenderWidgetHost* RenderWidgetHostViewChildFrame::GetRenderWidgetHost() const { 42 RenderWidgetHost* RenderWidgetHostViewChildFrame::GetRenderWidgetHost() const {
32 return host_; 43 return host_;
33 } 44 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 193 }
183 194
184 #if defined(OS_ANDROID) 195 #if defined(OS_ANDROID)
185 void RenderWidgetHostViewChildFrame::LockCompositingSurface() { 196 void RenderWidgetHostViewChildFrame::LockCompositingSurface() {
186 } 197 }
187 198
188 void RenderWidgetHostViewChildFrame::UnlockCompositingSurface() { 199 void RenderWidgetHostViewChildFrame::UnlockCompositingSurface() {
189 } 200 }
190 #endif 201 #endif
191 202
203 void RenderWidgetHostViewChildFrame::SurfaceDrawn(uint32 output_surface_id,
204 cc::SurfaceDrawStatus drawn) {
205 cc::CompositorFrameAck ack;
206 host_->Send(new ViewMsg_SwapCompositorFrameAck(host_->GetRoutingID(),
207 output_surface_id, ack));
208 }
209
192 void RenderWidgetHostViewChildFrame::OnSwapCompositorFrame( 210 void RenderWidgetHostViewChildFrame::OnSwapCompositorFrame(
193 uint32 output_surface_id, 211 uint32 output_surface_id,
194 scoped_ptr<cc::CompositorFrame> frame) { 212 scoped_ptr<cc::CompositorFrame> frame) {
195 last_scroll_offset_ = frame->metadata.root_scroll_offset; 213 last_scroll_offset_ = frame->metadata.root_scroll_offset;
196 if (frame_connector_) { 214
215 if (!frame_connector_)
216 return;
217
218 // When not using surfaces, the frame just gets proxied to
219 // the embedder's renderer to be composited.
220 if (!frame->delegated_frame_data || !use_surfaces_) {
197 frame_connector_->ChildFrameCompositorFrameSwapped( 221 frame_connector_->ChildFrameCompositorFrameSwapped(
198 output_surface_id, 222 output_surface_id,
199 host_->GetProcess()->GetID(), 223 host_->GetProcess()->GetID(),
200 host_->GetRoutingID(), 224 host_->GetRoutingID(),
201 frame.Pass()); 225 frame.Pass());
226 return;
202 } 227 }
228
229 cc::RenderPass* root_pass =
230 frame->delegated_frame_data->render_pass_list.back();
231
232 gfx::Size frame_size = root_pass->output_rect.size();
233 float scale_factor = frame->metadata.device_scale_factor;
234
235 if (!surface_factory_) {
236 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
237 cc::SurfaceManager* manager = factory->GetSurfaceManager();
238 id_allocator_ = factory->GetContextFactory()->CreateSurfaceIdAllocator();
239 surface_factory_ = make_scoped_ptr(new cc::SurfaceFactory(manager, this));
240 }
241
242 // Check whether we need to recreate the cc::Surface, which means the child
243 // frame renderer has changed its output surface, or size, or scale factor.
244 if (output_surface_id != last_output_surface_id_ ||
245 frame_size != current_surface_size_ ||
246 scale_factor != current_surface_scale_factor_) {
247 if (!surface_id_.is_null()) {
248 surface_factory_->Destroy(surface_id_);
249 surface_id_ = cc::SurfaceId();
250 surface_factory_.reset();
251 }
252 last_output_surface_id_ = output_surface_id;
253 current_surface_size_ = frame_size;
254 current_surface_scale_factor_ = scale_factor;
255 }
256
257 if (surface_id_.is_null()) {
258 surface_id_ = id_allocator_->GenerateId();
259 surface_factory_->Create(surface_id_);
260
261 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
262 cc::SurfaceSequence sequence = cc::SurfaceSequence(
263 id_allocator_->id_namespace(), next_surface_sequence_++);
264 // The renderer will satisfy this dependency when it creates a
265 // SurfaceLayer.
266 factory->GetSurfaceManager()
267 ->GetSurfaceForId(surface_id_)
268 ->AddDestructionDependency(sequence);
jbauman 2015/05/01 23:58:10 I guess we'll also need to figure out what happens
kenrb 2015/05/05 16:24:37 I don't entirely understand James' response, but i
269 frame_connector_->SetChildFrameSurface(surface_id_, frame_size,
270 scale_factor, sequence);
271 }
272
273 cc::SurfaceFactory::DrawCallback ack_callback =
274 base::Bind(&RenderWidgetHostViewChildFrame::SurfaceDrawn, AsWeakPtr(),
275 output_surface_id);
276 surface_factory_->SubmitFrame(surface_id_, frame.Pass(), ack_callback);
203 } 277 }
204 278
205 void RenderWidgetHostViewChildFrame::GetScreenInfo( 279 void RenderWidgetHostViewChildFrame::GetScreenInfo(
206 blink::WebScreenInfo* results) { 280 blink::WebScreenInfo* results) {
207 } 281 }
208 282
209 gfx::Rect RenderWidgetHostViewChildFrame::GetBoundsInRootWindow() { 283 gfx::Rect RenderWidgetHostViewChildFrame::GetBoundsInRootWindow() {
210 // We do not have any root window specific parts in this view. 284 // We do not have any root window specific parts in this view.
211 return GetViewBounds(); 285 return GetViewBounds();
212 } 286 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 gfx::NativeViewId RenderWidgetHostViewChildFrame::GetParentForWindowlessPlugin() 369 gfx::NativeViewId RenderWidgetHostViewChildFrame::GetParentForWindowlessPlugin()
296 const { 370 const {
297 return NULL; 371 return NULL;
298 } 372 }
299 #endif // defined(OS_WIN) 373 #endif // defined(OS_WIN)
300 374
301 SkColorType RenderWidgetHostViewChildFrame::PreferredReadbackFormat() { 375 SkColorType RenderWidgetHostViewChildFrame::PreferredReadbackFormat() {
302 return kN32_SkColorType; 376 return kN32_SkColorType;
303 } 377 }
304 378
379 // cc::SurfaceFactoryClient implementation.
380 void RenderWidgetHostViewChildFrame::ReturnResources(
381 const cc::ReturnedResourceArray& resources) {
jbauman 2015/05/01 23:58:10 This needs to store the resources if there's an ac
kenrb 2015/05/05 16:24:38 Done.
382 // ??
383 }
384
305 BrowserAccessibilityManager* 385 BrowserAccessibilityManager*
306 RenderWidgetHostViewChildFrame::CreateBrowserAccessibilityManager( 386 RenderWidgetHostViewChildFrame::CreateBrowserAccessibilityManager(
307 BrowserAccessibilityDelegate* delegate) { 387 BrowserAccessibilityDelegate* delegate) {
308 return BrowserAccessibilityManager::Create( 388 return BrowserAccessibilityManager::Create(
309 BrowserAccessibilityManager::GetEmptyDocument(), delegate); 389 BrowserAccessibilityManager::GetEmptyDocument(), delegate);
310 } 390 }
311 391
312 } // namespace content 392 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698