| 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/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 <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "cc/surfaces/surface.h" | 10 #include "cc/surfaces/surface.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "content/public/common/browser_plugin_guest_mode.h" | 26 #include "content/public/common/browser_plugin_guest_mode.h" |
| 27 #include "ui/gfx/geometry/size_conversions.h" | 27 #include "ui/gfx/geometry/size_conversions.h" |
| 28 #include "ui/gfx/geometry/size_f.h" | 28 #include "ui/gfx/geometry/size_f.h" |
| 29 | 29 |
| 30 namespace content { | 30 namespace content { |
| 31 | 31 |
| 32 RenderWidgetHostViewChildFrame::RenderWidgetHostViewChildFrame( | 32 RenderWidgetHostViewChildFrame::RenderWidgetHostViewChildFrame( |
| 33 RenderWidgetHost* widget_host) | 33 RenderWidgetHost* widget_host) |
| 34 : host_(RenderWidgetHostImpl::From(widget_host)), | 34 : host_(RenderWidgetHostImpl::From(widget_host)), |
| 35 use_surfaces_(UseSurfacesEnabled()), | 35 use_surfaces_(UseSurfacesEnabled()), |
| 36 next_surface_sequence_(1u), | |
| 37 last_output_surface_id_(0), | 36 last_output_surface_id_(0), |
| 38 current_surface_scale_factor_(1.f), | 37 current_surface_scale_factor_(1.f), |
| 39 ack_pending_count_(0), | 38 ack_pending_count_(0), |
| 40 frame_connector_(nullptr), | 39 frame_connector_(nullptr), |
| 41 weak_factory_(this) { | 40 weak_factory_(this) { |
| 42 if (use_surfaces_) { | 41 if (use_surfaces_) { |
| 43 id_allocator_ = CreateSurfaceIdAllocator(); | 42 id_allocator_ = CreateSurfaceIdAllocator(); |
| 44 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { | 43 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { |
| 45 host_->delegate()->GetInputEventRouter()->AddSurfaceIdNamespaceOwner( | 44 host_->delegate()->GetInputEventRouter()->AddSurfaceIdNamespaceOwner( |
| 46 GetSurfaceIdNamespace(), this); | 45 GetSurfaceIdNamespace(), this); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 | 292 |
| 294 if (!surface_factory_) { | 293 if (!surface_factory_) { |
| 295 cc::SurfaceManager* manager = GetSurfaceManager(); | 294 cc::SurfaceManager* manager = GetSurfaceManager(); |
| 296 surface_factory_ = make_scoped_ptr(new cc::SurfaceFactory(manager, this)); | 295 surface_factory_ = make_scoped_ptr(new cc::SurfaceFactory(manager, this)); |
| 297 } | 296 } |
| 298 | 297 |
| 299 if (surface_id_.is_null()) { | 298 if (surface_id_.is_null()) { |
| 300 surface_id_ = id_allocator_->GenerateId(); | 299 surface_id_ = id_allocator_->GenerateId(); |
| 301 surface_factory_->Create(surface_id_); | 300 surface_factory_->Create(surface_id_); |
| 302 | 301 |
| 303 cc::SurfaceSequence sequence = cc::SurfaceSequence( | 302 surface_sequence_ = cc::SurfaceSequence( |
| 304 id_allocator_->id_namespace(), next_surface_sequence_++); | 303 id_allocator_->id_namespace(), surface_sequence_.sequence + 1); |
| 305 // The renderer process will satisfy this dependency when it creates a | 304 // The renderer process will satisfy this dependency when it creates a |
| 306 // SurfaceLayer. | 305 // SurfaceLayer. |
| 307 cc::SurfaceManager* manager = GetSurfaceManager(); | 306 cc::SurfaceManager* manager = GetSurfaceManager(); |
| 308 manager->GetSurfaceForId(surface_id_)->AddDestructionDependency(sequence); | 307 manager->GetSurfaceForId(surface_id_) |
| 308 ->AddDestructionDependency(surface_sequence_); |
| 309 frame_connector_->SetChildFrameSurface(surface_id_, frame_size, | 309 frame_connector_->SetChildFrameSurface(surface_id_, frame_size, |
| 310 scale_factor, sequence); | 310 scale_factor, surface_sequence_); |
| 311 } | 311 } |
| 312 | 312 |
| 313 cc::SurfaceFactory::DrawCallback ack_callback = | 313 cc::SurfaceFactory::DrawCallback ack_callback = |
| 314 base::Bind(&RenderWidgetHostViewChildFrame::SurfaceDrawn, AsWeakPtr(), | 314 base::Bind(&RenderWidgetHostViewChildFrame::SurfaceDrawn, AsWeakPtr(), |
| 315 output_surface_id); | 315 output_surface_id); |
| 316 ack_pending_count_++; | 316 ack_pending_count_++; |
| 317 // If this value grows very large, something is going wrong. | 317 // If this value grows very large, something is going wrong. |
| 318 DCHECK_LT(ack_pending_count_, 1000U); | 318 DCHECK_LT(ack_pending_count_, 1000U); |
| 319 surface_factory_->SubmitCompositorFrame(surface_id_, frame.Pass(), | 319 surface_factory_->SubmitCompositorFrame(surface_id_, frame.Pass(), |
| 320 ack_callback); | 320 ack_callback); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 #endif | 484 #endif |
| 485 } | 485 } |
| 486 | 486 |
| 487 void RenderWidgetHostViewChildFrame::ClearCompositorSurfaceIfNecessary() { | 487 void RenderWidgetHostViewChildFrame::ClearCompositorSurfaceIfNecessary() { |
| 488 if (surface_factory_ && !surface_id_.is_null()) | 488 if (surface_factory_ && !surface_id_.is_null()) |
| 489 surface_factory_->Destroy(surface_id_); | 489 surface_factory_->Destroy(surface_id_); |
| 490 surface_id_ = cc::SurfaceId(); | 490 surface_id_ = cc::SurfaceId(); |
| 491 } | 491 } |
| 492 | 492 |
| 493 } // namespace content | 493 } // namespace content |
| OLD | NEW |