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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 26023004: aura: Allow delegated frames to be used by more than one impl layer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: frameprovider: are_layers_attached checks Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
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/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/debug/trace_event.h" 11 #include "base/debug/trace_event.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "cc/layers/delegated_frame_provider.h"
15 #include "cc/output/compositor_frame.h" 16 #include "cc/output/compositor_frame.h"
16 #include "cc/output/compositor_frame_ack.h" 17 #include "cc/output/compositor_frame_ack.h"
17 #include "cc/output/copy_output_request.h" 18 #include "cc/output/copy_output_request.h"
18 #include "cc/output/copy_output_result.h" 19 #include "cc/output/copy_output_result.h"
19 #include "cc/resources/texture_mailbox.h" 20 #include "cc/resources/texture_mailbox.h"
20 #include "cc/trees/layer_tree_settings.h" 21 #include "cc/trees/layer_tree_settings.h"
21 #include "content/browser/accessibility/browser_accessibility_manager.h" 22 #include "content/browser/accessibility/browser_accessibility_manager.h"
22 #include "content/browser/accessibility/browser_accessibility_state_impl.h" 23 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
23 #include "content/browser/aura/compositor_resize_lock.h" 24 #include "content/browser/aura/compositor_resize_lock.h"
24 #include "content/browser/gpu/compositor_util.h" 25 #include "content/browser/gpu/compositor_util.h"
(...skipping 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 } 1464 }
1464 1465
1465 if (output_surface_id != last_output_surface_id_) { 1466 if (output_surface_id != last_output_surface_id_) {
1466 // Resource ids are scoped by the output surface. 1467 // Resource ids are scoped by the output surface.
1467 // If the originating output surface doesn't match the last one, it 1468 // If the originating output surface doesn't match the last one, it
1468 // indicates the renderer's output surface may have been recreated, in which 1469 // indicates the renderer's output surface may have been recreated, in which
1469 // case we should recreate the DelegatedRendererLayer, to avoid matching 1470 // case we should recreate the DelegatedRendererLayer, to avoid matching
1470 // resources from the old one with resources from the new one which would 1471 // resources from the old one with resources from the new one which would
1471 // have the same id. Changing the layer to showing painted content destroys 1472 // have the same id. Changing the layer to showing painted content destroys
1472 // the DelegatedRendererLayer. 1473 // the DelegatedRendererLayer.
1473 // TODO(danakj): Lose and return all resources in the delegated layer first.
1474 window_->layer()->SetShowPaintedContent(); 1474 window_->layer()->SetShowPaintedContent();
1475 frame_provider_ = NULL;
1476
1477 // TODO(danakj): Lose all resources and send them back here, such as:
1478 // resource_collection_->LoseAllResources();
1479 // SendReturnedDelegatedResources(last_output_surface_id_);
1480
1481 // Drop the cc::DelegatedFrameResourceCollection so that we will not return
1482 // any resources from the old output surface with the new output surface id.
1483 resource_collection_->SetClient(NULL);
1484 resource_collection_ = NULL;
1475 last_output_surface_id_ = output_surface_id; 1485 last_output_surface_id_ = output_surface_id;
1476 } 1486 }
1477 if (frame_size.IsEmpty()) { 1487 if (frame_size.IsEmpty()) {
1478 // TODO(danakj): Return all resources in the delegated layer somehow. 1488 DCHECK_EQ(0u, frame_data->resource_list.size());
1479 window_->layer()->SetShowPaintedContent(); 1489 window_->layer()->SetShowPaintedContent();
1480 } else { 1490 } else {
1481 window_->layer()->SetDelegatedFrame(frame_data.Pass(), frame_size_in_dip); 1491 if (!resource_collection_) {
1492 resource_collection_ = new cc::DelegatedFrameResourceCollection;
1493 resource_collection_->SetClient(this);
1494 }
1495 if (!frame_provider_.get() || frame_size != frame_provider_->frame_size()) {
1496 frame_provider_ = new cc::DelegatedFrameProvider(
1497 resource_collection_.get(), frame_data.Pass());
1498 window_->layer()->SetShowDelegatedContent(frame_provider_.get(),
1499 frame_size_in_dip);
1500 } else {
1501 frame_provider_->SetFrameData(frame_data.Pass());
1502 }
1482 } 1503 }
1483 released_front_lock_ = NULL; 1504 released_front_lock_ = NULL;
1484 current_frame_size_ = frame_size_in_dip; 1505 current_frame_size_ = frame_size_in_dip;
1485 CheckResizeLock(); 1506 CheckResizeLock();
1486 1507
1487 if (paint_observer_) 1508 if (paint_observer_)
1488 paint_observer_->OnUpdateCompositorContent(); 1509 paint_observer_->OnUpdateCompositorContent();
1489 window_->SchedulePaintInRect(damage_rect_in_dip); 1510 window_->SchedulePaintInRect(damage_rect_in_dip);
1490 1511
1491 ui::Compositor* compositor = GetCompositor(); 1512 ui::Compositor* compositor = GetCompositor();
1492 if (!compositor) { 1513 if (!compositor) {
1493 SendDelegatedFrameAck(output_surface_id); 1514 SendDelegatedFrameAck(output_surface_id);
1494 } else { 1515 } else {
1495 compositor->SetLatencyInfo(latency_info); 1516 compositor->SetLatencyInfo(latency_info);
1496 AddOnCommitCallbackAndDisableLocks( 1517 AddOnCommitCallbackAndDisableLocks(
1497 base::Bind(&RenderWidgetHostViewAura::SendDelegatedFrameAck, 1518 base::Bind(&RenderWidgetHostViewAura::SendDelegatedFrameAck,
1498 AsWeakPtr(), 1519 AsWeakPtr(),
1499 output_surface_id)); 1520 output_surface_id));
1500 } 1521 }
1501 DidReceiveFrameFromRenderer(); 1522 DidReceiveFrameFromRenderer();
1502 } 1523 }
1503 1524
1504 void RenderWidgetHostViewAura::SendDelegatedFrameAck(uint32 output_surface_id) { 1525 void RenderWidgetHostViewAura::SendDelegatedFrameAck(uint32 output_surface_id) {
1505 cc::CompositorFrameAck ack; 1526 cc::CompositorFrameAck ack;
1506 window_->layer()->TakeUnusedResourcesForChildCompositor(&ack.resources); 1527 if (resource_collection_)
1507 RenderWidgetHostImpl::SendSwapCompositorFrameAck( 1528 resource_collection_->TakeUnusedResourcesForChildCompositor(&ack.resources);
1508 host_->GetRoutingID(), output_surface_id, 1529 RenderWidgetHostImpl::SendSwapCompositorFrameAck(host_->GetRoutingID(),
1509 host_->GetProcess()->GetID(), ack); 1530 output_surface_id,
1531 host_->GetProcess()->GetID(),
1532 ack);
1533 }
1534
1535 void RenderWidgetHostViewAura::UnusedResourcesAreAvailable() {
1536 // TODO(danakj): If no ack is pending, collect and send resources now.
1510 } 1537 }
1511 1538
1512 void RenderWidgetHostViewAura::SwapSoftwareFrame( 1539 void RenderWidgetHostViewAura::SwapSoftwareFrame(
1513 uint32 output_surface_id, 1540 uint32 output_surface_id,
1514 scoped_ptr<cc::SoftwareFrameData> frame_data, 1541 scoped_ptr<cc::SoftwareFrameData> frame_data,
1515 float frame_device_scale_factor, 1542 float frame_device_scale_factor,
1516 const ui::LatencyInfo& latency_info) { 1543 const ui::LatencyInfo& latency_info) {
1517 const gfx::Size& frame_size = frame_data->size; 1544 const gfx::Size& frame_size = frame_data->size;
1518 const gfx::Rect& damage_rect = frame_data->damage_rect; 1545 const gfx::Rect& damage_rect = frame_data->damage_rect;
1519 gfx::Size frame_size_in_dip = 1546 gfx::Size frame_size_in_dip =
(...skipping 1658 matching lines...) Expand 10 before | Expand all | Expand 10 after
3178 gfx::Screen::GetScreenFor(window_)->RemoveObserver(this); 3205 gfx::Screen::GetScreenFor(window_)->RemoveObserver(this);
3179 3206
3180 // This call is usually no-op since |this| object is already removed from the 3207 // This call is usually no-op since |this| object is already removed from the
3181 // Aura root window and we don't have a way to get an input method object 3208 // Aura root window and we don't have a way to get an input method object
3182 // associated with the window, but just in case. 3209 // associated with the window, but just in case.
3183 DetachFromInputMethod(); 3210 DetachFromInputMethod();
3184 FrameMemoryManager::GetInstance()->RemoveFrame(this); 3211 FrameMemoryManager::GetInstance()->RemoveFrame(this);
3185 // The destruction of the holder may call back into the RWHVA, so do it 3212 // The destruction of the holder may call back into the RWHVA, so do it
3186 // early. 3213 // early.
3187 framebuffer_holder_ = NULL; 3214 framebuffer_holder_ = NULL;
3215
3216 if (resource_collection_.get())
3217 resource_collection_->SetClient(NULL);
3188 } 3218 }
3189 3219
3190 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { 3220 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() {
3191 const gfx::Point screen_point = 3221 const gfx::Point screen_point =
3192 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); 3222 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint();
3193 aura::RootWindow* root_window = window_->GetRootWindow(); 3223 aura::RootWindow* root_window = window_->GetRootWindow();
3194 if (!root_window) 3224 if (!root_window)
3195 return; 3225 return;
3196 3226
3197 gfx::Rect screen_rect = GetViewBounds(); 3227 gfx::Rect screen_rect = GetViewBounds();
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
3387 RenderWidgetHost* widget) { 3417 RenderWidgetHost* widget) {
3388 return new RenderWidgetHostViewAura(widget); 3418 return new RenderWidgetHostViewAura(widget);
3389 } 3419 }
3390 3420
3391 // static 3421 // static
3392 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { 3422 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) {
3393 GetScreenInfoForWindow(results, NULL); 3423 GetScreenInfoForWindow(results, NULL);
3394 } 3424 }
3395 3425
3396 } // namespace content 3426 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698