Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 906 | 906 |
| 907 void RenderWidgetHostViewAura::Blur() { | 907 void RenderWidgetHostViewAura::Blur() { |
| 908 window_->Blur(); | 908 window_->Blur(); |
| 909 } | 909 } |
| 910 | 910 |
| 911 bool RenderWidgetHostViewAura::HasFocus() const { | 911 bool RenderWidgetHostViewAura::HasFocus() const { |
| 912 return window_->HasFocus(); | 912 return window_->HasFocus(); |
| 913 } | 913 } |
| 914 | 914 |
| 915 bool RenderWidgetHostViewAura::IsSurfaceAvailableForCopy() const { | 915 bool RenderWidgetHostViewAura::IsSurfaceAvailableForCopy() const { |
| 916 return current_surface_ || !!host_->GetBackingStore(false); | 916 return current_surface_ || current_dib_ || !!host_->GetBackingStore(false); |
| 917 } | 917 } |
| 918 | 918 |
| 919 void RenderWidgetHostViewAura::Show() { | 919 void RenderWidgetHostViewAura::Show() { |
| 920 window_->Show(); | 920 window_->Show(); |
| 921 } | 921 } |
| 922 | 922 |
| 923 void RenderWidgetHostViewAura::Hide() { | 923 void RenderWidgetHostViewAura::Hide() { |
| 924 window_->Hide(); | 924 window_->Hide(); |
| 925 } | 925 } |
| 926 | 926 |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1311 released_front_lock_ = NULL; | 1311 released_front_lock_ = NULL; |
| 1312 UpdateExternalTexture(); | 1312 UpdateExternalTexture(); |
| 1313 | 1313 |
| 1314 return true; | 1314 return true; |
| 1315 } | 1315 } |
| 1316 | 1316 |
| 1317 void RenderWidgetHostViewAura::SwapBuffersCompleted( | 1317 void RenderWidgetHostViewAura::SwapBuffersCompleted( |
| 1318 const BufferPresentedCallback& ack_callback, | 1318 const BufferPresentedCallback& ack_callback, |
| 1319 const scoped_refptr<ui::Texture>& texture_to_return) { | 1319 const scoped_refptr<ui::Texture>& texture_to_return) { |
| 1320 ui::Compositor* compositor = GetCompositor(); | 1320 ui::Compositor* compositor = GetCompositor(); |
| 1321 if (!compositor) { | 1321 if (!compositor) |
| 1322 ack_callback.Run(false, texture_to_return); | 1322 ack_callback.Run(false, texture_to_return); |
| 1323 } else { | 1323 else |
| 1324 // Add sending an ACK to the list of things to do OnCompositingDidCommit | 1324 AddOnCommitCallback(base::Bind(ack_callback, false, texture_to_return)); |
| 1325 can_lock_compositor_ = NO_PENDING_COMMIT; | |
| 1326 on_compositing_did_commit_callbacks_.push_back( | |
| 1327 base::Bind(ack_callback, false, texture_to_return)); | |
| 1328 if (!compositor->HasObserver(this)) | |
| 1329 compositor->AddObserver(this); | |
| 1330 } | |
| 1331 } | 1325 } |
| 1332 | 1326 |
| 1333 #if defined(OS_WIN) | 1327 #if defined(OS_WIN) |
| 1334 void RenderWidgetHostViewAura::UpdateTransientRects( | 1328 void RenderWidgetHostViewAura::UpdateTransientRects( |
| 1335 const std::vector<gfx::Rect>& rects) { | 1329 const std::vector<gfx::Rect>& rects) { |
| 1336 transient_rects_ = rects; | 1330 transient_rects_ = rects; |
| 1337 UpdateCutoutRects(); | 1331 UpdateCutoutRects(); |
| 1338 } | 1332 } |
| 1339 | 1333 |
| 1340 void RenderWidgetHostViewAura::UpdateConstrainedWindowRects( | 1334 void RenderWidgetHostViewAura::UpdateConstrainedWindowRects( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1388 released_front_lock_ = NULL; | 1382 released_front_lock_ = NULL; |
| 1389 CheckResizeLocks(frame_size_in_dip); | 1383 CheckResizeLocks(frame_size_in_dip); |
| 1390 | 1384 |
| 1391 if (paint_observer_) | 1385 if (paint_observer_) |
| 1392 paint_observer_->OnUpdateCompositorContent(); | 1386 paint_observer_->OnUpdateCompositorContent(); |
| 1393 | 1387 |
| 1394 ui::Compositor* compositor = GetCompositor(); | 1388 ui::Compositor* compositor = GetCompositor(); |
| 1395 if (!compositor) { | 1389 if (!compositor) { |
| 1396 SendDelegatedFrameAck(); | 1390 SendDelegatedFrameAck(); |
| 1397 } else { | 1391 } else { |
| 1398 can_lock_compositor_ = NO_PENDING_COMMIT; | 1392 AddOnCommitCallback( |
| 1399 on_compositing_did_commit_callbacks_.push_back( | |
| 1400 base::Bind(&RenderWidgetHostViewAura::SendDelegatedFrameAck, | 1393 base::Bind(&RenderWidgetHostViewAura::SendDelegatedFrameAck, |
| 1401 base::Unretained(this))); | 1394 AsWeakPtr())); |
| 1402 if (!compositor->HasObserver(this)) | |
| 1403 compositor->AddObserver(this); | |
| 1404 } | 1395 } |
| 1405 } | 1396 } |
| 1406 | 1397 |
| 1407 void RenderWidgetHostViewAura::SendDelegatedFrameAck() { | 1398 void RenderWidgetHostViewAura::SendDelegatedFrameAck() { |
| 1408 cc::CompositorFrameAck ack; | 1399 cc::CompositorFrameAck ack; |
| 1409 window_->layer()->TakeUnusedResourcesForChildCompositor(&ack.resources); | 1400 window_->layer()->TakeUnusedResourcesForChildCompositor(&ack.resources); |
| 1410 RenderWidgetHostImpl::SendSwapCompositorFrameAck( | 1401 RenderWidgetHostImpl::SendSwapCompositorFrameAck( |
| 1411 host_->GetRoutingID(), host_->GetProcess()->GetID(), ack); | 1402 host_->GetRoutingID(), host_->GetProcess()->GetID(), ack); |
| 1412 } | 1403 } |
| 1413 | 1404 |
| 1405 void RenderWidgetHostViewAura::SwapSoftwareFrame( | |
| 1406 scoped_ptr<cc::SoftwareFrameData> frame_data, | |
| 1407 float frame_device_scale_factor) { | |
| 1408 const gfx::Size& frame_size = frame_data->size; | |
| 1409 const gfx::Rect& damage_rect = frame_data->damage_rect; | |
| 1410 TransportDIB::Handle handle = frame_data->content_dib; | |
| 1411 | |
| 1412 #if defined(OS_WIN) | |
| 1413 ::DuplicateHandle(host_->GetProcess()->GetHandle(), handle, | |
|
slavi
2013/03/27 20:16:40
BUG: Save the original handle value so that we sen
| |
| 1414 ::GetCurrentProcess(), &handle, | |
| 1415 0, FALSE, DUPLICATE_SAME_ACCESS); | |
| 1416 #endif | |
| 1417 | |
| 1418 current_dib_.reset(TransportDIB::Map(handle)); | |
| 1419 previous_damage_.op(RectToSkIRect(damage_rect), SkRegion::kUnion_Op); | |
| 1420 if (last_swapped_surface_size_ != frame_size) { | |
| 1421 DLOG_IF(ERROR, damage_rect != gfx::Rect(frame_size)) | |
| 1422 << "Expected full damage rect"; | |
| 1423 last_swapped_surface_size_ = frame_size; | |
| 1424 } | |
| 1425 | |
| 1426 gfx::Size frame_size_in_dip = gfx::ToFlooredSize( | |
| 1427 gfx::ScaleSize(frame_size, 1.0f / frame_device_scale_factor)); | |
| 1428 ui::Compositor* compositor = GetCompositor(); | |
| 1429 if (!compositor || !current_dib_ || ShouldSkipFrame(frame_size_in_dip)) { | |
| 1430 SendSoftwareFrameAck(handle); | |
| 1431 return; | |
| 1432 } | |
| 1433 | |
| 1434 window_->SetExternalTexture(NULL); | |
| 1435 released_front_lock_ = NULL; | |
| 1436 CheckResizeLocks(frame_size_in_dip); | |
| 1437 AddOnCommitCallback( | |
| 1438 base::Bind(&RenderWidgetHostViewAura::SendSoftwareFrameAck, | |
| 1439 AsWeakPtr(), handle)); | |
| 1440 | |
| 1441 if (paint_observer_) | |
| 1442 paint_observer_->OnUpdateCompositorContent(); | |
| 1443 window_->SchedulePaintInRect(ConvertRectToDIP(this, damage_rect)); | |
| 1444 } | |
| 1445 | |
| 1446 void RenderWidgetHostViewAura::SendSoftwareFrameAck( | |
| 1447 TransportDIB::Handle handle) { | |
| 1448 cc::CompositorFrameAck ack; | |
| 1449 ack.last_content_dib = handle; | |
| 1450 RenderWidgetHostImpl::SendSwapCompositorFrameAck( | |
| 1451 host_->GetRoutingID(), host_->GetProcess()->GetID(), ack); | |
| 1452 } | |
| 1453 | |
| 1454 | |
| 1414 void RenderWidgetHostViewAura::OnSwapCompositorFrame( | 1455 void RenderWidgetHostViewAura::OnSwapCompositorFrame( |
| 1415 scoped_ptr<cc::CompositorFrame> frame) { | 1456 scoped_ptr<cc::CompositorFrame> frame) { |
| 1416 if (frame->delegated_frame_data) { | 1457 if (frame->delegated_frame_data) { |
| 1417 SwapDelegatedFrame(frame->delegated_frame_data.Pass(), | 1458 SwapDelegatedFrame(frame->delegated_frame_data.Pass(), |
| 1418 frame->metadata.device_scale_factor); | 1459 frame->metadata.device_scale_factor); |
| 1419 return; | 1460 return; |
| 1420 } | 1461 } |
| 1462 | |
| 1463 if (frame->software_frame_data) { | |
| 1464 SwapSoftwareFrame(frame->software_frame_data.Pass(), | |
| 1465 frame->metadata.device_scale_factor); | |
| 1466 return; | |
| 1467 } | |
| 1468 | |
| 1421 if (!frame->gl_frame_data || frame->gl_frame_data->mailbox.IsZero()) | 1469 if (!frame->gl_frame_data || frame->gl_frame_data->mailbox.IsZero()) |
| 1422 return; | 1470 return; |
| 1423 | 1471 |
| 1424 BufferPresentedCallback ack_callback = base::Bind( | 1472 BufferPresentedCallback ack_callback = base::Bind( |
| 1425 &SendCompositorFrameAck, | 1473 &SendCompositorFrameAck, |
| 1426 host_->GetRoutingID(), host_->GetProcess()->GetID(), | 1474 host_->GetRoutingID(), host_->GetProcess()->GetID(), |
| 1427 frame->gl_frame_data->mailbox, frame->gl_frame_data->size); | 1475 frame->gl_frame_data->mailbox, frame->gl_frame_data->size); |
| 1428 | 1476 |
| 1429 if (!frame->gl_frame_data->sync_point) { | 1477 if (!frame->gl_frame_data->sync_point) { |
| 1430 LOG(ERROR) << "CompositorFrame without sync point. Skipping frame..."; | 1478 LOG(ERROR) << "CompositorFrame without sync point. Skipping frame..."; |
| 1431 ack_callback.Run(true, scoped_refptr<ui::Texture>()); | 1479 ack_callback.Run(true, scoped_refptr<ui::Texture>()); |
| 1432 return; | 1480 return; |
| 1433 } | 1481 } |
| 1434 | 1482 |
| 1435 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 1483 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 1436 factory->WaitSyncPoint(frame->gl_frame_data->sync_point); | 1484 factory->WaitSyncPoint(frame->gl_frame_data->sync_point); |
| 1437 | 1485 |
| 1438 std::string mailbox_name( | 1486 std::string mailbox_name( |
| 1439 reinterpret_cast<const char*>(frame->gl_frame_data->mailbox.name), | 1487 reinterpret_cast<const char*>(frame->gl_frame_data->mailbox.name), |
| 1440 sizeof(frame->gl_frame_data->mailbox.name)); | 1488 sizeof(frame->gl_frame_data->mailbox.name)); |
| 1441 BuffersSwapped( | 1489 BuffersSwapped( |
| 1442 frame->gl_frame_data->size, mailbox_name, ack_callback); | 1490 frame->gl_frame_data->size, mailbox_name, ack_callback); |
| 1443 } | 1491 } |
| 1444 | 1492 |
| 1445 void RenderWidgetHostViewAura::BuffersSwapped( | 1493 void RenderWidgetHostViewAura::BuffersSwapped( |
| 1446 const gfx::Size& size, | 1494 const gfx::Size& size, |
| 1447 const std::string& mailbox_name, | 1495 const std::string& mailbox_name, |
| 1448 const BufferPresentedCallback& ack_callback) { | 1496 const BufferPresentedCallback& ack_callback) { |
| 1449 scoped_refptr<ui::Texture> texture_to_return(current_surface_); | 1497 scoped_refptr<ui::Texture> texture_to_return(current_surface_); |
| 1450 const gfx::Rect surface_rect = gfx::Rect(gfx::Point(), size); | 1498 const gfx::Rect surface_rect = gfx::Rect(size); |
| 1451 if (!SwapBuffersPrepare( | 1499 if (!SwapBuffersPrepare( |
| 1452 surface_rect, surface_rect, mailbox_name, ack_callback)) { | 1500 surface_rect, surface_rect, mailbox_name, ack_callback)) { |
| 1453 return; | 1501 return; |
| 1454 } | 1502 } |
| 1455 | 1503 |
| 1456 previous_damage_.setRect(RectToSkIRect(surface_rect)); | 1504 previous_damage_.setRect(RectToSkIRect(surface_rect)); |
| 1457 skipped_damage_.setEmpty(); | 1505 skipped_damage_.setEmpty(); |
| 1458 | 1506 |
| 1459 ui::Compositor* compositor = GetCompositor(); | 1507 ui::Compositor* compositor = GetCompositor(); |
| 1460 if (compositor) { | 1508 if (compositor) { |
| 1461 gfx::Size surface_size = ConvertSizeToDIP(this, size); | 1509 gfx::Size surface_size = ConvertSizeToDIP(this, size); |
| 1462 window_->SchedulePaintInRect(gfx::Rect(surface_size)); | 1510 window_->SchedulePaintInRect(gfx::Rect(surface_size)); |
| 1463 } | 1511 } |
| 1464 | 1512 |
| 1465 if (paint_observer_) | 1513 if (paint_observer_) |
| 1466 paint_observer_->OnUpdateCompositorContent(); | 1514 paint_observer_->OnUpdateCompositorContent(); |
| 1467 | 1515 |
| 1468 SwapBuffersCompleted(ack_callback, texture_to_return); | 1516 SwapBuffersCompleted(ack_callback, texture_to_return); |
| 1469 } | 1517 } |
| 1470 | 1518 |
| 1471 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( | 1519 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( |
| 1472 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, | 1520 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, |
| 1473 int gpu_host_id) { | 1521 int gpu_host_id) { |
| 1474 scoped_refptr<ui::Texture> previous_texture(current_surface_); | 1522 scoped_refptr<ui::Texture> previous_texture(current_surface_); |
| 1475 const gfx::Rect surface_rect = | 1523 const gfx::Rect surface_rect = |
| 1476 gfx::Rect(gfx::Point(), params_in_pixel.surface_size); | 1524 gfx::Rect(params_in_pixel.surface_size); |
| 1477 gfx::Rect damage_rect(params_in_pixel.x, | 1525 gfx::Rect damage_rect(params_in_pixel.x, |
| 1478 params_in_pixel.y, | 1526 params_in_pixel.y, |
| 1479 params_in_pixel.width, | 1527 params_in_pixel.width, |
| 1480 params_in_pixel.height); | 1528 params_in_pixel.height); |
| 1481 BufferPresentedCallback ack_callback = base::Bind( | 1529 BufferPresentedCallback ack_callback = base::Bind( |
| 1482 &AcknowledgeBufferForGpu, params_in_pixel.route_id, gpu_host_id, | 1530 &AcknowledgeBufferForGpu, params_in_pixel.route_id, gpu_host_id, |
| 1483 params_in_pixel.mailbox_name); | 1531 params_in_pixel.mailbox_name); |
| 1484 | 1532 |
| 1485 if (!SwapBuffersPrepare( | 1533 if (!SwapBuffersPrepare( |
| 1486 surface_rect, damage_rect, params_in_pixel.mailbox_name, ack_callback)) { | 1534 surface_rect, damage_rect, params_in_pixel.mailbox_name, ack_callback)) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1540 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { | 1588 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { |
| 1541 } | 1589 } |
| 1542 | 1590 |
| 1543 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { | 1591 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { |
| 1544 // This really tells us to release the frontbuffer. | 1592 // This really tells us to release the frontbuffer. |
| 1545 if (current_surface_) { | 1593 if (current_surface_) { |
| 1546 ui::Compositor* compositor = GetCompositor(); | 1594 ui::Compositor* compositor = GetCompositor(); |
| 1547 if (compositor) { | 1595 if (compositor) { |
| 1548 // We need to wait for a commit to clear to guarantee that all we | 1596 // We need to wait for a commit to clear to guarantee that all we |
| 1549 // will not issue any more GL referencing the previous surface. | 1597 // will not issue any more GL referencing the previous surface. |
| 1550 can_lock_compositor_ = NO_PENDING_COMMIT; | 1598 AddOnCommitCallback( |
| 1551 on_compositing_did_commit_callbacks_.push_back( | |
| 1552 base::Bind(&RenderWidgetHostViewAura:: | 1599 base::Bind(&RenderWidgetHostViewAura:: |
| 1553 SetSurfaceNotInUseByCompositor, | 1600 SetSurfaceNotInUseByCompositor, |
| 1554 AsWeakPtr(), | 1601 AsWeakPtr(), |
| 1555 current_surface_)); // Hold a ref so the texture will not | 1602 current_surface_)); // Hold a ref so the texture will not |
| 1556 // get deleted until after commit. | 1603 // get deleted until after commit. |
| 1557 if (!compositor->HasObserver(this)) | |
| 1558 compositor->AddObserver(this); | |
| 1559 } | 1604 } |
| 1560 current_surface_ = NULL; | 1605 current_surface_ = NULL; |
| 1561 UpdateExternalTexture(); | 1606 UpdateExternalTexture(); |
| 1562 } | 1607 } |
| 1563 } | 1608 } |
| 1564 | 1609 |
| 1565 bool RenderWidgetHostViewAura::HasAcceleratedSurface( | 1610 bool RenderWidgetHostViewAura::HasAcceleratedSurface( |
| 1566 const gfx::Size& desired_size) { | 1611 const gfx::Size& desired_size) { |
| 1567 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't | 1612 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't |
| 1568 // matter what is returned here as GetBackingStore is the only caller of this | 1613 // 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 Loading... | |
| 1931 | 1976 |
| 1932 bool RenderWidgetHostViewAura::CanFocus() { | 1977 bool RenderWidgetHostViewAura::CanFocus() { |
| 1933 return popup_type_ == WebKit::WebPopupTypeNone; | 1978 return popup_type_ == WebKit::WebPopupTypeNone; |
| 1934 } | 1979 } |
| 1935 | 1980 |
| 1936 void RenderWidgetHostViewAura::OnCaptureLost() { | 1981 void RenderWidgetHostViewAura::OnCaptureLost() { |
| 1937 host_->LostCapture(); | 1982 host_->LostCapture(); |
| 1938 } | 1983 } |
| 1939 | 1984 |
| 1940 void RenderWidgetHostViewAura::OnPaint(gfx::Canvas* canvas) { | 1985 void RenderWidgetHostViewAura::OnPaint(gfx::Canvas* canvas) { |
| 1941 paint_canvas_ = canvas; | 1986 bool is_compositing_active = host_->is_accelerated_compositing_active(); |
| 1942 BackingStore* backing_store = host_->GetBackingStore(true); | 1987 bool has_backing_store = !!host_->GetBackingStore(false); |
| 1943 paint_canvas_ = NULL; | 1988 if (is_compositing_active && current_dib_) { |
| 1944 if (backing_store) { | 1989 SkBitmap bitmap; |
| 1945 static_cast<BackingStoreAura*>(backing_store)->SkiaShowRect(gfx::Point(), | 1990 bitmap.setConfig(SkBitmap::kARGB_8888_Config, |
| 1946 canvas); | 1991 last_swapped_surface_size_.width(), |
| 1992 last_swapped_surface_size_.height()); | |
| 1993 bitmap.setPixels(current_dib_->memory()); | |
| 1994 | |
| 1995 SkCanvas* sk_canvas = canvas->sk_canvas(); | |
| 1996 for (SkRegion::Iterator it(previous_damage_); !it.done(); it.next()) { | |
| 1997 const SkIRect& src_rect = it.rect(); | |
| 1998 SkRect dst_rect = SkRect::Make(src_rect); | |
| 1999 sk_canvas->drawBitmapRect(bitmap, &src_rect, dst_rect, NULL); | |
| 2000 } | |
| 2001 previous_damage_.setEmpty(); | |
| 2002 | |
| 2003 if (paint_observer_) | |
| 2004 paint_observer_->OnPaintComplete(); | |
| 2005 } else if (!is_compositing_active && has_backing_store) { | |
| 2006 paint_canvas_ = canvas; | |
| 2007 BackingStoreAura* backing_store = static_cast<BackingStoreAura*>( | |
| 2008 host_->GetBackingStore(true)); | |
| 2009 paint_canvas_ = NULL; | |
| 2010 backing_store->SkiaShowRect(gfx::Point(), canvas); | |
| 2011 | |
| 1947 if (paint_observer_) | 2012 if (paint_observer_) |
| 1948 paint_observer_->OnPaintComplete(); | 2013 paint_observer_->OnPaintComplete(); |
| 1949 } else if (aura::Env::GetInstance()->render_white_bg()) { | 2014 } else if (aura::Env::GetInstance()->render_white_bg()) { |
| 1950 canvas->DrawColor(SK_ColorWHITE); | 2015 canvas->DrawColor(SK_ColorWHITE); |
| 1951 } | 2016 } |
| 1952 } | 2017 } |
| 1953 | 2018 |
| 1954 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged( | 2019 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged( |
| 1955 float device_scale_factor) { | 2020 float device_scale_factor) { |
| 1956 if (!host_) | 2021 if (!host_) |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2354 | 2419 |
| 2355 void RenderWidgetHostViewAura::OnCompositingDidCommit( | 2420 void RenderWidgetHostViewAura::OnCompositingDidCommit( |
| 2356 ui::Compositor* compositor) { | 2421 ui::Compositor* compositor) { |
| 2357 if (can_lock_compositor_ == NO_PENDING_COMMIT) { | 2422 if (can_lock_compositor_ == NO_PENDING_COMMIT) { |
| 2358 can_lock_compositor_ = YES; | 2423 can_lock_compositor_ = YES; |
| 2359 for (ResizeLockList::iterator it = resize_locks_.begin(); | 2424 for (ResizeLockList::iterator it = resize_locks_.begin(); |
| 2360 it != resize_locks_.end(); ++it) | 2425 it != resize_locks_.end(); ++it) |
| 2361 if ((*it)->GrabDeferredLock()) | 2426 if ((*it)->GrabDeferredLock()) |
| 2362 can_lock_compositor_ = YES_DID_LOCK; | 2427 can_lock_compositor_ = YES_DID_LOCK; |
| 2363 } | 2428 } |
| 2364 RunCompositingDidCommitCallbacks(); | 2429 RunOnCommitCallbacks(); |
| 2365 locks_pending_commit_.clear(); | 2430 locks_pending_commit_.clear(); |
| 2366 } | 2431 } |
| 2367 | 2432 |
| 2368 void RenderWidgetHostViewAura::OnCompositingStarted( | 2433 void RenderWidgetHostViewAura::OnCompositingStarted( |
| 2369 ui::Compositor* compositor, base::TimeTicks start_time) { | 2434 ui::Compositor* compositor, base::TimeTicks start_time) { |
| 2370 last_draw_ended_ = start_time; | 2435 last_draw_ended_ = start_time; |
| 2371 } | 2436 } |
| 2372 | 2437 |
| 2373 void RenderWidgetHostViewAura::OnCompositingEnded( | 2438 void RenderWidgetHostViewAura::OnCompositingEnded( |
| 2374 ui::Compositor* compositor) { | 2439 ui::Compositor* compositor) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2453 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: | 2518 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: |
| 2454 | 2519 |
| 2455 void RenderWidgetHostViewAura::OnLostResources() { | 2520 void RenderWidgetHostViewAura::OnLostResources() { |
| 2456 current_surface_ = NULL; | 2521 current_surface_ = NULL; |
| 2457 UpdateExternalTexture(); | 2522 UpdateExternalTexture(); |
| 2458 locks_pending_commit_.clear(); | 2523 locks_pending_commit_.clear(); |
| 2459 | 2524 |
| 2460 // Make sure all ImageTransportClients are deleted now that the context those | 2525 // Make sure all ImageTransportClients are deleted now that the context those |
| 2461 // are using is becoming invalid. This sends pending ACKs and needs to happen | 2526 // are using is becoming invalid. This sends pending ACKs and needs to happen |
| 2462 // after calling UpdateExternalTexture() which syncs with the impl thread. | 2527 // after calling UpdateExternalTexture() which syncs with the impl thread. |
| 2463 RunCompositingDidCommitCallbacks(); | 2528 RunOnCommitCallbacks(); |
| 2464 | 2529 |
| 2465 DCHECK(!shared_surface_handle_.is_null()); | 2530 DCHECK(!shared_surface_handle_.is_null()); |
| 2466 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 2531 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 2467 factory->DestroySharedSurfaceHandle(shared_surface_handle_); | 2532 factory->DestroySharedSurfaceHandle(shared_surface_handle_); |
| 2468 shared_surface_handle_ = factory->CreateSharedSurfaceHandle(); | 2533 shared_surface_handle_ = factory->CreateSharedSurfaceHandle(); |
| 2469 host_->CompositingSurfaceUpdated(); | 2534 host_->CompositingSurfaceUpdated(); |
| 2470 host_->ScheduleComposite(); | 2535 host_->ScheduleComposite(); |
| 2471 } | 2536 } |
| 2472 | 2537 |
| 2473 //////////////////////////////////////////////////////////////////////////////// | 2538 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2609 gfx::Rect rect = window_->bounds(); | 2674 gfx::Rect rect = window_->bounds(); |
| 2610 int border_x = rect.width() * kMouseLockBorderPercentage / 100; | 2675 int border_x = rect.width() * kMouseLockBorderPercentage / 100; |
| 2611 int border_y = rect.height() * kMouseLockBorderPercentage / 100; | 2676 int border_y = rect.height() * kMouseLockBorderPercentage / 100; |
| 2612 | 2677 |
| 2613 return global_mouse_position_.x() < rect.x() + border_x || | 2678 return global_mouse_position_.x() < rect.x() + border_x || |
| 2614 global_mouse_position_.x() > rect.right() - border_x || | 2679 global_mouse_position_.x() > rect.right() - border_x || |
| 2615 global_mouse_position_.y() < rect.y() + border_y || | 2680 global_mouse_position_.y() < rect.y() + border_y || |
| 2616 global_mouse_position_.y() > rect.bottom() - border_y; | 2681 global_mouse_position_.y() > rect.bottom() - border_y; |
| 2617 } | 2682 } |
| 2618 | 2683 |
| 2619 void RenderWidgetHostViewAura::RunCompositingDidCommitCallbacks() { | 2684 void RenderWidgetHostViewAura::RunOnCommitCallbacks() { |
| 2620 for (std::vector<base::Closure>::const_iterator | 2685 for (std::vector<base::Closure>::const_iterator |
| 2621 it = on_compositing_did_commit_callbacks_.begin(); | 2686 it = on_compositing_did_commit_callbacks_.begin(); |
| 2622 it != on_compositing_did_commit_callbacks_.end(); ++it) { | 2687 it != on_compositing_did_commit_callbacks_.end(); ++it) { |
| 2623 it->Run(); | 2688 it->Run(); |
| 2624 } | 2689 } |
| 2625 on_compositing_did_commit_callbacks_.clear(); | 2690 on_compositing_did_commit_callbacks_.clear(); |
| 2626 } | 2691 } |
| 2627 | 2692 |
| 2693 void RenderWidgetHostViewAura::AddOnCommitCallback( | |
| 2694 const base::Closure& callback) { | |
| 2695 ui::Compositor* compositor = GetCompositor(); | |
| 2696 if (!compositor) | |
| 2697 return; | |
| 2698 | |
| 2699 if (!compositor->HasObserver(this)) | |
| 2700 compositor->AddObserver(this); | |
| 2701 | |
| 2702 can_lock_compositor_ = NO_PENDING_COMMIT; | |
| 2703 on_compositing_did_commit_callbacks_.push_back(callback); | |
| 2704 return; | |
| 2705 } | |
| 2706 | |
| 2628 void RenderWidgetHostViewAura::AddedToRootWindow() { | 2707 void RenderWidgetHostViewAura::AddedToRootWindow() { |
| 2629 window_->GetRootWindow()->AddRootWindowObserver(this); | 2708 window_->GetRootWindow()->AddRootWindowObserver(this); |
| 2630 host_->ParentChanged(GetNativeViewId()); | 2709 host_->ParentChanged(GetNativeViewId()); |
| 2631 UpdateScreenInfo(window_); | 2710 UpdateScreenInfo(window_); |
| 2632 if (popup_type_ != WebKit::WebPopupTypeNone) | 2711 if (popup_type_ != WebKit::WebPopupTypeNone) |
| 2633 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); | 2712 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); |
| 2634 } | 2713 } |
| 2635 | 2714 |
| 2636 void RenderWidgetHostViewAura::RemovingFromRootWindow() { | 2715 void RenderWidgetHostViewAura::RemovingFromRootWindow() { |
| 2637 event_filter_for_popup_exit_.reset(); | 2716 event_filter_for_popup_exit_.reset(); |
| 2638 window_->GetRootWindow()->RemoveRootWindowObserver(this); | 2717 window_->GetRootWindow()->RemoveRootWindowObserver(this); |
| 2639 host_->ParentChanged(0); | 2718 host_->ParentChanged(0); |
| 2640 // We are about to disconnect ourselves from the compositor, we need to issue | 2719 // We are about to disconnect ourselves from the compositor, we need to issue |
| 2641 // the callbacks now, because we won't get notified when the frame is done. | 2720 // the callbacks now, because we won't get notified when the frame is done. |
| 2642 // TODO(piman): this might in theory cause a race where the GPU process starts | 2721 // TODO(piman): this might in theory cause a race where the GPU process starts |
| 2643 // drawing to the buffer we haven't yet displayed. This will only show for 1 | 2722 // drawing to the buffer we haven't yet displayed. This will only show for 1 |
| 2644 // frame though, because we will reissue a new frame right away without that | 2723 // frame though, because we will reissue a new frame right away without that |
| 2645 // composited data. | 2724 // composited data. |
| 2646 ui::Compositor* compositor = GetCompositor(); | 2725 ui::Compositor* compositor = GetCompositor(); |
| 2647 RunCompositingDidCommitCallbacks(); | 2726 RunOnCommitCallbacks(); |
| 2648 locks_pending_commit_.clear(); | 2727 locks_pending_commit_.clear(); |
| 2649 if (compositor && compositor->HasObserver(this)) | 2728 if (compositor && compositor->HasObserver(this)) |
| 2650 compositor->RemoveObserver(this); | 2729 compositor->RemoveObserver(this); |
| 2651 DetachFromInputMethod(); | 2730 DetachFromInputMethod(); |
| 2652 } | 2731 } |
| 2653 | 2732 |
| 2654 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() { | 2733 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() { |
| 2655 aura::RootWindow* root_window = window_->GetRootWindow(); | 2734 aura::RootWindow* root_window = window_->GetRootWindow(); |
| 2656 return root_window ? root_window->compositor() : NULL; | 2735 return root_window ? root_window->compositor() : NULL; |
| 2657 } | 2736 } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 2670 RenderWidgetHost* widget) { | 2749 RenderWidgetHost* widget) { |
| 2671 return new RenderWidgetHostViewAura(widget); | 2750 return new RenderWidgetHostViewAura(widget); |
| 2672 } | 2751 } |
| 2673 | 2752 |
| 2674 // static | 2753 // static |
| 2675 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 2754 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 2676 GetScreenInfoForWindow(results, NULL); | 2755 GetScreenInfoForWindow(results, NULL); |
| 2677 } | 2756 } |
| 2678 | 2757 |
| 2679 } // namespace content | 2758 } // namespace content |
| OLD | NEW |