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

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

Issue 13042012: Browser side changes for software compositing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 911
912 void RenderWidgetHostViewAura::Blur() { 912 void RenderWidgetHostViewAura::Blur() {
913 window_->Blur(); 913 window_->Blur();
914 } 914 }
915 915
916 bool RenderWidgetHostViewAura::HasFocus() const { 916 bool RenderWidgetHostViewAura::HasFocus() const {
917 return window_->HasFocus(); 917 return window_->HasFocus();
918 } 918 }
919 919
920 bool RenderWidgetHostViewAura::IsSurfaceAvailableForCopy() const { 920 bool RenderWidgetHostViewAura::IsSurfaceAvailableForCopy() const {
921 return current_surface_ || !!host_->GetBackingStore(false); 921 return current_surface_ || current_dib_ || !!host_->GetBackingStore(false);
922 } 922 }
923 923
924 void RenderWidgetHostViewAura::Show() { 924 void RenderWidgetHostViewAura::Show() {
925 window_->Show(); 925 window_->Show();
926 } 926 }
927 927
928 void RenderWidgetHostViewAura::Hide() { 928 void RenderWidgetHostViewAura::Hide() {
929 window_->Hide(); 929 window_->Hide();
930 } 930 }
931 931
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 released_front_lock_ = NULL; 1316 released_front_lock_ = NULL;
1317 UpdateExternalTexture(); 1317 UpdateExternalTexture();
1318 1318
1319 return true; 1319 return true;
1320 } 1320 }
1321 1321
1322 void RenderWidgetHostViewAura::SwapBuffersCompleted( 1322 void RenderWidgetHostViewAura::SwapBuffersCompleted(
1323 const BufferPresentedCallback& ack_callback, 1323 const BufferPresentedCallback& ack_callback,
1324 const scoped_refptr<ui::Texture>& texture_to_return) { 1324 const scoped_refptr<ui::Texture>& texture_to_return) {
1325 ui::Compositor* compositor = GetCompositor(); 1325 ui::Compositor* compositor = GetCompositor();
1326 if (!compositor) { 1326 if (!compositor)
1327 ack_callback.Run(false, texture_to_return); 1327 ack_callback.Run(false, texture_to_return);
1328 } else { 1328 else
1329 // Add sending an ACK to the list of things to do OnCompositingDidCommit 1329 AddOnCommitCallback(base::Bind(ack_callback, false, texture_to_return));
1330 can_lock_compositor_ = NO_PENDING_COMMIT;
1331 on_compositing_did_commit_callbacks_.push_back(
1332 base::Bind(ack_callback, false, texture_to_return));
1333 if (!compositor->HasObserver(this))
1334 compositor->AddObserver(this);
1335 }
1336 } 1330 }
1337 1331
1338 #if defined(OS_WIN) 1332 #if defined(OS_WIN)
1339 void RenderWidgetHostViewAura::UpdateTransientRects( 1333 void RenderWidgetHostViewAura::UpdateTransientRects(
1340 const std::vector<gfx::Rect>& rects) { 1334 const std::vector<gfx::Rect>& rects) {
1341 transient_rects_ = rects; 1335 transient_rects_ = rects;
1342 UpdateCutoutRects(); 1336 UpdateCutoutRects();
1343 } 1337 }
1344 1338
1345 void RenderWidgetHostViewAura::UpdateConstrainedWindowRects( 1339 void RenderWidgetHostViewAura::UpdateConstrainedWindowRects(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 released_front_lock_ = NULL; 1387 released_front_lock_ = NULL;
1394 CheckResizeLocks(frame_size_in_dip); 1388 CheckResizeLocks(frame_size_in_dip);
1395 1389
1396 if (paint_observer_) 1390 if (paint_observer_)
1397 paint_observer_->OnUpdateCompositorContent(); 1391 paint_observer_->OnUpdateCompositorContent();
1398 1392
1399 ui::Compositor* compositor = GetCompositor(); 1393 ui::Compositor* compositor = GetCompositor();
1400 if (!compositor) { 1394 if (!compositor) {
1401 SendDelegatedFrameAck(); 1395 SendDelegatedFrameAck();
1402 } else { 1396 } else {
1403 can_lock_compositor_ = NO_PENDING_COMMIT; 1397 AddOnCommitCallback(
1404 on_compositing_did_commit_callbacks_.push_back(
1405 base::Bind(&RenderWidgetHostViewAura::SendDelegatedFrameAck, 1398 base::Bind(&RenderWidgetHostViewAura::SendDelegatedFrameAck,
1406 base::Unretained(this))); 1399 AsWeakPtr()));
1407 if (!compositor->HasObserver(this))
1408 compositor->AddObserver(this);
1409 } 1400 }
1410 } 1401 }
1411 1402
1412 void RenderWidgetHostViewAura::SendDelegatedFrameAck() { 1403 void RenderWidgetHostViewAura::SendDelegatedFrameAck() {
1413 cc::CompositorFrameAck ack; 1404 cc::CompositorFrameAck ack;
1414 window_->layer()->TakeUnusedResourcesForChildCompositor(&ack.resources); 1405 window_->layer()->TakeUnusedResourcesForChildCompositor(&ack.resources);
1415 RenderWidgetHostImpl::SendSwapCompositorFrameAck( 1406 RenderWidgetHostImpl::SendSwapCompositorFrameAck(
1416 host_->GetRoutingID(), host_->GetProcess()->GetID(), ack); 1407 host_->GetRoutingID(), host_->GetProcess()->GetID(), ack);
1417 } 1408 }
1418 1409
1410 void RenderWidgetHostViewAura::SwapSoftwareFrame(
1411 scoped_ptr<cc::SoftwareFrameData> frame_data,
1412 float frame_device_scale_factor) {
1413 const gfx::Size& frame_size = frame_data->size;
1414 const gfx::Rect& damage_rect = frame_data->damage_rect;
1415 const TransportDIB::Id& dib_id = frame_data->dib_id;
1416
1417 #if defined(OS_WIN)
1418 TransportDIB::Handle my_handle = TransportDIB::DefaultHandleValue();
1419 ::DuplicateHandle(host_->GetProcess()->GetHandle(), dib_id.handle,
1420 ::GetCurrentProcess(), &my_handle,
1421 0, FALSE, DUPLICATE_SAME_ACCESS);
1422 current_dib_.reset(TransportDIB::Map(my_handle));
1423 #else
1424 current_dib_.reset(TransportDIB::Map(dib_id.handle));
1425 #endif
piman 2013/04/01 22:25:19 You need to check the new dib's size (in bytes) ag
slavi 2013/04/03 00:29:11 Done.
1426
1427 previous_damage_.op(RectToSkIRect(damage_rect), SkRegion::kUnion_Op);
1428 if (last_swapped_surface_size_ != frame_size) {
1429 DLOG_IF(ERROR, damage_rect != gfx::Rect(frame_size))
1430 << "Expected full damage rect";
1431 last_swapped_surface_size_ = frame_size;
1432 }
1433
1434 gfx::Size frame_size_in_dip = gfx::ToFlooredSize(
1435 gfx::ScaleSize(frame_size, 1.0f / frame_device_scale_factor));
1436 ui::Compositor* compositor = GetCompositor();
1437 if (!compositor || !current_dib_ || ShouldSkipFrame(frame_size_in_dip)) {
piman 2013/04/01 22:25:19 I don't think we can lump together those 3 cases.
slavi 2013/04/03 00:29:11 I split out the check for a valid dib and dib's si
piman 2013/04/03 18:36:53 ShouldSkipFrame has no impact on that though. It's
1438 SendSoftwareFrameAck(dib_id);
1439 return;
1440 }
1441
1442 window_->SetExternalTexture(NULL);
1443 released_front_lock_ = NULL;
1444 CheckResizeLocks(frame_size_in_dip);
1445 AddOnCommitCallback(
1446 base::Bind(&RenderWidgetHostViewAura::SendSoftwareFrameAck,
1447 AsWeakPtr(), dib_id));
piman 2013/04/01 22:25:19 I think here you need to return the old dib ID, no
slavi 2013/04/03 00:29:11 Done.
1448
1449 if (paint_observer_)
1450 paint_observer_->OnUpdateCompositorContent();
1451 window_->SchedulePaintInRect(ConvertRectToDIP(this, damage_rect));
1452 }
1453
1454 void RenderWidgetHostViewAura::SendSoftwareFrameAck(
1455 const TransportDIB::Id& id) {
1456 cc::CompositorFrameAck ack;
1457 ack.last_dib_id = id;
1458 RenderWidgetHostImpl::SendSwapCompositorFrameAck(
1459 host_->GetRoutingID(), host_->GetProcess()->GetID(), ack);
1460 }
1461
1462
1419 void RenderWidgetHostViewAura::OnSwapCompositorFrame( 1463 void RenderWidgetHostViewAura::OnSwapCompositorFrame(
1420 scoped_ptr<cc::CompositorFrame> frame) { 1464 scoped_ptr<cc::CompositorFrame> frame) {
1421 if (frame->delegated_frame_data) { 1465 if (frame->delegated_frame_data) {
1422 SwapDelegatedFrame(frame->delegated_frame_data.Pass(), 1466 SwapDelegatedFrame(frame->delegated_frame_data.Pass(),
1423 frame->metadata.device_scale_factor); 1467 frame->metadata.device_scale_factor);
1424 return; 1468 return;
1425 } 1469 }
1470
1471 if (frame->software_frame_data) {
1472 SwapSoftwareFrame(frame->software_frame_data.Pass(),
1473 frame->metadata.device_scale_factor);
1474 return;
1475 }
1476
1426 if (!frame->gl_frame_data || frame->gl_frame_data->mailbox.IsZero()) 1477 if (!frame->gl_frame_data || frame->gl_frame_data->mailbox.IsZero())
1427 return; 1478 return;
1428 1479
1429 BufferPresentedCallback ack_callback = base::Bind( 1480 BufferPresentedCallback ack_callback = base::Bind(
1430 &SendCompositorFrameAck, 1481 &SendCompositorFrameAck,
1431 host_->GetRoutingID(), host_->GetProcess()->GetID(), 1482 host_->GetRoutingID(), host_->GetProcess()->GetID(),
1432 frame->gl_frame_data->mailbox, frame->gl_frame_data->size); 1483 frame->gl_frame_data->mailbox, frame->gl_frame_data->size);
1433 1484
1434 if (!frame->gl_frame_data->sync_point) { 1485 if (!frame->gl_frame_data->sync_point) {
1435 LOG(ERROR) << "CompositorFrame without sync point. Skipping frame..."; 1486 LOG(ERROR) << "CompositorFrame without sync point. Skipping frame...";
1436 ack_callback.Run(true, scoped_refptr<ui::Texture>()); 1487 ack_callback.Run(true, scoped_refptr<ui::Texture>());
1437 return; 1488 return;
1438 } 1489 }
1439 1490
1440 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 1491 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
1441 factory->WaitSyncPoint(frame->gl_frame_data->sync_point); 1492 factory->WaitSyncPoint(frame->gl_frame_data->sync_point);
1442 1493
1443 std::string mailbox_name( 1494 std::string mailbox_name(
1444 reinterpret_cast<const char*>(frame->gl_frame_data->mailbox.name), 1495 reinterpret_cast<const char*>(frame->gl_frame_data->mailbox.name),
1445 sizeof(frame->gl_frame_data->mailbox.name)); 1496 sizeof(frame->gl_frame_data->mailbox.name));
1446 BuffersSwapped( 1497 BuffersSwapped(
1447 frame->gl_frame_data->size, mailbox_name, ack_callback); 1498 frame->gl_frame_data->size, mailbox_name, ack_callback);
1448 } 1499 }
1449 1500
1450 void RenderWidgetHostViewAura::BuffersSwapped( 1501 void RenderWidgetHostViewAura::BuffersSwapped(
1451 const gfx::Size& size, 1502 const gfx::Size& size,
1452 const std::string& mailbox_name, 1503 const std::string& mailbox_name,
1453 const BufferPresentedCallback& ack_callback) { 1504 const BufferPresentedCallback& ack_callback) {
1454 scoped_refptr<ui::Texture> texture_to_return(current_surface_); 1505 scoped_refptr<ui::Texture> texture_to_return(current_surface_);
1455 const gfx::Rect surface_rect = gfx::Rect(gfx::Point(), size); 1506 const gfx::Rect surface_rect = gfx::Rect(size);
1456 if (!SwapBuffersPrepare( 1507 if (!SwapBuffersPrepare(
1457 surface_rect, surface_rect, mailbox_name, ack_callback)) { 1508 surface_rect, surface_rect, mailbox_name, ack_callback)) {
1458 return; 1509 return;
1459 } 1510 }
1460 1511
1461 previous_damage_.setRect(RectToSkIRect(surface_rect)); 1512 previous_damage_.setRect(RectToSkIRect(surface_rect));
1462 skipped_damage_.setEmpty(); 1513 skipped_damage_.setEmpty();
1463 1514
1464 ui::Compositor* compositor = GetCompositor(); 1515 ui::Compositor* compositor = GetCompositor();
1465 if (compositor) { 1516 if (compositor) {
1466 gfx::Size surface_size = ConvertSizeToDIP(this, size); 1517 gfx::Size surface_size = ConvertSizeToDIP(this, size);
1467 window_->SchedulePaintInRect(gfx::Rect(surface_size)); 1518 window_->SchedulePaintInRect(gfx::Rect(surface_size));
1468 } 1519 }
1469 1520
1470 if (paint_observer_) 1521 if (paint_observer_)
1471 paint_observer_->OnUpdateCompositorContent(); 1522 paint_observer_->OnUpdateCompositorContent();
1472 1523
1473 SwapBuffersCompleted(ack_callback, texture_to_return); 1524 SwapBuffersCompleted(ack_callback, texture_to_return);
1474 } 1525 }
1475 1526
1476 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( 1527 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer(
1477 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, 1528 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel,
1478 int gpu_host_id) { 1529 int gpu_host_id) {
1479 scoped_refptr<ui::Texture> previous_texture(current_surface_); 1530 scoped_refptr<ui::Texture> previous_texture(current_surface_);
1480 const gfx::Rect surface_rect = 1531 const gfx::Rect surface_rect =
1481 gfx::Rect(gfx::Point(), params_in_pixel.surface_size); 1532 gfx::Rect(params_in_pixel.surface_size);
1482 gfx::Rect damage_rect(params_in_pixel.x, 1533 gfx::Rect damage_rect(params_in_pixel.x,
1483 params_in_pixel.y, 1534 params_in_pixel.y,
1484 params_in_pixel.width, 1535 params_in_pixel.width,
1485 params_in_pixel.height); 1536 params_in_pixel.height);
1486 BufferPresentedCallback ack_callback = base::Bind( 1537 BufferPresentedCallback ack_callback = base::Bind(
1487 &AcknowledgeBufferForGpu, params_in_pixel.route_id, gpu_host_id, 1538 &AcknowledgeBufferForGpu, params_in_pixel.route_id, gpu_host_id,
1488 params_in_pixel.mailbox_name); 1539 params_in_pixel.mailbox_name);
1489 1540
1490 if (!SwapBuffersPrepare( 1541 if (!SwapBuffersPrepare(
1491 surface_rect, damage_rect, params_in_pixel.mailbox_name, ack_callback)) { 1542 surface_rect, damage_rect, params_in_pixel.mailbox_name, ack_callback)) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { 1596 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() {
1546 } 1597 }
1547 1598
1548 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { 1599 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() {
1549 // This really tells us to release the frontbuffer. 1600 // This really tells us to release the frontbuffer.
1550 if (current_surface_) { 1601 if (current_surface_) {
1551 ui::Compositor* compositor = GetCompositor(); 1602 ui::Compositor* compositor = GetCompositor();
1552 if (compositor) { 1603 if (compositor) {
1553 // We need to wait for a commit to clear to guarantee that all we 1604 // We need to wait for a commit to clear to guarantee that all we
1554 // will not issue any more GL referencing the previous surface. 1605 // will not issue any more GL referencing the previous surface.
1555 can_lock_compositor_ = NO_PENDING_COMMIT; 1606 AddOnCommitCallback(
1556 on_compositing_did_commit_callbacks_.push_back(
1557 base::Bind(&RenderWidgetHostViewAura:: 1607 base::Bind(&RenderWidgetHostViewAura::
1558 SetSurfaceNotInUseByCompositor, 1608 SetSurfaceNotInUseByCompositor,
1559 AsWeakPtr(), 1609 AsWeakPtr(),
1560 current_surface_)); // Hold a ref so the texture will not 1610 current_surface_)); // Hold a ref so the texture will not
1561 // get deleted until after commit. 1611 // get deleted until after commit.
1562 if (!compositor->HasObserver(this))
1563 compositor->AddObserver(this);
1564 } 1612 }
1565 current_surface_ = NULL; 1613 current_surface_ = NULL;
1566 UpdateExternalTexture(); 1614 UpdateExternalTexture();
1567 } 1615 }
1568 } 1616 }
1569 1617
1570 bool RenderWidgetHostViewAura::HasAcceleratedSurface( 1618 bool RenderWidgetHostViewAura::HasAcceleratedSurface(
1571 const gfx::Size& desired_size) { 1619 const gfx::Size& desired_size) {
1572 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't 1620 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't
1573 // matter what is returned here as GetBackingStore is the only caller of this 1621 // matter what is returned here as GetBackingStore is the only caller of this
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1936 1984
1937 bool RenderWidgetHostViewAura::CanFocus() { 1985 bool RenderWidgetHostViewAura::CanFocus() {
1938 return popup_type_ == WebKit::WebPopupTypeNone; 1986 return popup_type_ == WebKit::WebPopupTypeNone;
1939 } 1987 }
1940 1988
1941 void RenderWidgetHostViewAura::OnCaptureLost() { 1989 void RenderWidgetHostViewAura::OnCaptureLost() {
1942 host_->LostCapture(); 1990 host_->LostCapture();
1943 } 1991 }
1944 1992
1945 void RenderWidgetHostViewAura::OnPaint(gfx::Canvas* canvas) { 1993 void RenderWidgetHostViewAura::OnPaint(gfx::Canvas* canvas) {
1946 paint_canvas_ = canvas; 1994 bool is_compositing_active = host_->is_accelerated_compositing_active();
1947 BackingStore* backing_store = host_->GetBackingStore(true); 1995 bool has_backing_store = !!host_->GetBackingStore(false);
1948 paint_canvas_ = NULL; 1996 if (is_compositing_active && current_dib_) {
1949 if (backing_store) { 1997 SkBitmap bitmap;
1950 static_cast<BackingStoreAura*>(backing_store)->SkiaShowRect(gfx::Point(), 1998 bitmap.setConfig(SkBitmap::kARGB_8888_Config,
1951 canvas); 1999 last_swapped_surface_size_.width(),
2000 last_swapped_surface_size_.height());
2001 bitmap.setPixels(current_dib_->memory());
2002
2003 SkCanvas* sk_canvas = canvas->sk_canvas();
2004 for (SkRegion::Iterator it(previous_damage_); !it.done(); it.next()) {
2005 const SkIRect& src_rect = it.rect();
2006 SkRect dst_rect = SkRect::Make(src_rect);
2007 sk_canvas->drawBitmapRect(bitmap, &src_rect, dst_rect, NULL);
2008 }
2009 previous_damage_.setEmpty();
2010
2011 if (paint_observer_)
2012 paint_observer_->OnPaintComplete();
2013 } else if (!is_compositing_active && has_backing_store) {
2014 paint_canvas_ = canvas;
2015 BackingStoreAura* backing_store = static_cast<BackingStoreAura*>(
2016 host_->GetBackingStore(true));
2017 paint_canvas_ = NULL;
2018 backing_store->SkiaShowRect(gfx::Point(), canvas);
2019
1952 if (paint_observer_) 2020 if (paint_observer_)
1953 paint_observer_->OnPaintComplete(); 2021 paint_observer_->OnPaintComplete();
1954 } else if (aura::Env::GetInstance()->render_white_bg()) { 2022 } else if (aura::Env::GetInstance()->render_white_bg()) {
1955 canvas->DrawColor(SK_ColorWHITE); 2023 canvas->DrawColor(SK_ColorWHITE);
1956 } 2024 }
1957 } 2025 }
1958 2026
1959 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged( 2027 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged(
1960 float device_scale_factor) { 2028 float device_scale_factor) {
1961 if (!host_) 2029 if (!host_)
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
2359 2427
2360 void RenderWidgetHostViewAura::OnCompositingDidCommit( 2428 void RenderWidgetHostViewAura::OnCompositingDidCommit(
2361 ui::Compositor* compositor) { 2429 ui::Compositor* compositor) {
2362 if (can_lock_compositor_ == NO_PENDING_COMMIT) { 2430 if (can_lock_compositor_ == NO_PENDING_COMMIT) {
2363 can_lock_compositor_ = YES; 2431 can_lock_compositor_ = YES;
2364 for (ResizeLockList::iterator it = resize_locks_.begin(); 2432 for (ResizeLockList::iterator it = resize_locks_.begin();
2365 it != resize_locks_.end(); ++it) 2433 it != resize_locks_.end(); ++it)
2366 if ((*it)->GrabDeferredLock()) 2434 if ((*it)->GrabDeferredLock())
2367 can_lock_compositor_ = YES_DID_LOCK; 2435 can_lock_compositor_ = YES_DID_LOCK;
2368 } 2436 }
2369 RunCompositingDidCommitCallbacks(); 2437 RunOnCommitCallbacks();
2370 locks_pending_commit_.clear(); 2438 locks_pending_commit_.clear();
2371 } 2439 }
2372 2440
2373 void RenderWidgetHostViewAura::OnCompositingStarted( 2441 void RenderWidgetHostViewAura::OnCompositingStarted(
2374 ui::Compositor* compositor, base::TimeTicks start_time) { 2442 ui::Compositor* compositor, base::TimeTicks start_time) {
2375 last_draw_ended_ = start_time; 2443 last_draw_ended_ = start_time;
2376 } 2444 }
2377 2445
2378 void RenderWidgetHostViewAura::OnCompositingEnded( 2446 void RenderWidgetHostViewAura::OnCompositingEnded(
2379 ui::Compositor* compositor) { 2447 ui::Compositor* compositor) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2458 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: 2526 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation:
2459 2527
2460 void RenderWidgetHostViewAura::OnLostResources() { 2528 void RenderWidgetHostViewAura::OnLostResources() {
2461 current_surface_ = NULL; 2529 current_surface_ = NULL;
2462 UpdateExternalTexture(); 2530 UpdateExternalTexture();
2463 locks_pending_commit_.clear(); 2531 locks_pending_commit_.clear();
2464 2532
2465 // Make sure all ImageTransportClients are deleted now that the context those 2533 // Make sure all ImageTransportClients are deleted now that the context those
2466 // are using is becoming invalid. This sends pending ACKs and needs to happen 2534 // are using is becoming invalid. This sends pending ACKs and needs to happen
2467 // after calling UpdateExternalTexture() which syncs with the impl thread. 2535 // after calling UpdateExternalTexture() which syncs with the impl thread.
2468 RunCompositingDidCommitCallbacks(); 2536 RunOnCommitCallbacks();
2469 2537
2470 DCHECK(!shared_surface_handle_.is_null()); 2538 DCHECK(!shared_surface_handle_.is_null());
2471 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 2539 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
2472 factory->DestroySharedSurfaceHandle(shared_surface_handle_); 2540 factory->DestroySharedSurfaceHandle(shared_surface_handle_);
2473 shared_surface_handle_ = factory->CreateSharedSurfaceHandle(); 2541 shared_surface_handle_ = factory->CreateSharedSurfaceHandle();
2474 host_->CompositingSurfaceUpdated(); 2542 host_->CompositingSurfaceUpdated();
2475 host_->ScheduleComposite(); 2543 host_->ScheduleComposite();
2476 } 2544 }
2477 2545
2478 //////////////////////////////////////////////////////////////////////////////// 2546 ////////////////////////////////////////////////////////////////////////////////
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
2614 gfx::Rect rect = window_->bounds(); 2682 gfx::Rect rect = window_->bounds();
2615 int border_x = rect.width() * kMouseLockBorderPercentage / 100; 2683 int border_x = rect.width() * kMouseLockBorderPercentage / 100;
2616 int border_y = rect.height() * kMouseLockBorderPercentage / 100; 2684 int border_y = rect.height() * kMouseLockBorderPercentage / 100;
2617 2685
2618 return global_mouse_position_.x() < rect.x() + border_x || 2686 return global_mouse_position_.x() < rect.x() + border_x ||
2619 global_mouse_position_.x() > rect.right() - border_x || 2687 global_mouse_position_.x() > rect.right() - border_x ||
2620 global_mouse_position_.y() < rect.y() + border_y || 2688 global_mouse_position_.y() < rect.y() + border_y ||
2621 global_mouse_position_.y() > rect.bottom() - border_y; 2689 global_mouse_position_.y() > rect.bottom() - border_y;
2622 } 2690 }
2623 2691
2624 void RenderWidgetHostViewAura::RunCompositingDidCommitCallbacks() { 2692 void RenderWidgetHostViewAura::RunOnCommitCallbacks() {
2625 for (std::vector<base::Closure>::const_iterator 2693 for (std::vector<base::Closure>::const_iterator
2626 it = on_compositing_did_commit_callbacks_.begin(); 2694 it = on_compositing_did_commit_callbacks_.begin();
2627 it != on_compositing_did_commit_callbacks_.end(); ++it) { 2695 it != on_compositing_did_commit_callbacks_.end(); ++it) {
2628 it->Run(); 2696 it->Run();
2629 } 2697 }
2630 on_compositing_did_commit_callbacks_.clear(); 2698 on_compositing_did_commit_callbacks_.clear();
2631 } 2699 }
2632 2700
2701 void RenderWidgetHostViewAura::AddOnCommitCallback(
2702 const base::Closure& callback) {
2703 ui::Compositor* compositor = GetCompositor();
2704 if (!compositor)
piman 2013/04/01 22:25:19 In all the callsites, this has already been checke
slavi 2013/04/03 00:29:11 Done.
2705 return;
2706
2707 if (!compositor->HasObserver(this))
2708 compositor->AddObserver(this);
2709
2710 can_lock_compositor_ = NO_PENDING_COMMIT;
piman 2013/04/01 22:25:19 I feel somewhat uneasy at moving this here. I unde
slavi 2013/04/03 00:29:11 Done.
2711 on_compositing_did_commit_callbacks_.push_back(callback);
2712 return;
piman 2013/04/01 22:25:19 not needed.
slavi 2013/04/03 00:29:11 Done.
2713 }
2714
2633 void RenderWidgetHostViewAura::AddedToRootWindow() { 2715 void RenderWidgetHostViewAura::AddedToRootWindow() {
2634 window_->GetRootWindow()->AddRootWindowObserver(this); 2716 window_->GetRootWindow()->AddRootWindowObserver(this);
2635 host_->ParentChanged(GetNativeViewId()); 2717 host_->ParentChanged(GetNativeViewId());
2636 UpdateScreenInfo(window_); 2718 UpdateScreenInfo(window_);
2637 if (popup_type_ != WebKit::WebPopupTypeNone) 2719 if (popup_type_ != WebKit::WebPopupTypeNone)
2638 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); 2720 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this));
2639 } 2721 }
2640 2722
2641 void RenderWidgetHostViewAura::RemovingFromRootWindow() { 2723 void RenderWidgetHostViewAura::RemovingFromRootWindow() {
2642 event_filter_for_popup_exit_.reset(); 2724 event_filter_for_popup_exit_.reset();
2643 window_->GetRootWindow()->RemoveRootWindowObserver(this); 2725 window_->GetRootWindow()->RemoveRootWindowObserver(this);
2644 host_->ParentChanged(0); 2726 host_->ParentChanged(0);
2645 // We are about to disconnect ourselves from the compositor, we need to issue 2727 // We are about to disconnect ourselves from the compositor, we need to issue
2646 // the callbacks now, because we won't get notified when the frame is done. 2728 // the callbacks now, because we won't get notified when the frame is done.
2647 // TODO(piman): this might in theory cause a race where the GPU process starts 2729 // TODO(piman): this might in theory cause a race where the GPU process starts
2648 // drawing to the buffer we haven't yet displayed. This will only show for 1 2730 // drawing to the buffer we haven't yet displayed. This will only show for 1
2649 // frame though, because we will reissue a new frame right away without that 2731 // frame though, because we will reissue a new frame right away without that
2650 // composited data. 2732 // composited data.
2651 ui::Compositor* compositor = GetCompositor(); 2733 ui::Compositor* compositor = GetCompositor();
2652 RunCompositingDidCommitCallbacks(); 2734 RunOnCommitCallbacks();
2653 locks_pending_commit_.clear(); 2735 locks_pending_commit_.clear();
2654 if (compositor && compositor->HasObserver(this)) 2736 if (compositor && compositor->HasObserver(this))
2655 compositor->RemoveObserver(this); 2737 compositor->RemoveObserver(this);
2656 DetachFromInputMethod(); 2738 DetachFromInputMethod();
2657 } 2739 }
2658 2740
2659 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() { 2741 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() {
2660 aura::RootWindow* root_window = window_->GetRootWindow(); 2742 aura::RootWindow* root_window = window_->GetRootWindow();
2661 return root_window ? root_window->compositor() : NULL; 2743 return root_window ? root_window->compositor() : NULL;
2662 } 2744 }
(...skipping 12 matching lines...) Expand all
2675 RenderWidgetHost* widget) { 2757 RenderWidgetHost* widget) {
2676 return new RenderWidgetHostViewAura(widget); 2758 return new RenderWidgetHostViewAura(widget);
2677 } 2759 }
2678 2760
2679 // static 2761 // static
2680 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { 2762 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) {
2681 GetScreenInfoForWindow(results, NULL); 2763 GetScreenInfoForWindow(results, NULL);
2682 } 2764 }
2683 2765
2684 } // namespace content 2766 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.h ('k') | content/content_renderer.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698