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

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: Rebased. 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 } 1266 }
1267 } 1267 }
1268 1268
1269 void RenderWidgetHostViewAura::UpdateExternalTexture() { 1269 void RenderWidgetHostViewAura::UpdateExternalTexture() {
1270 // Delay processing accelerated compositing state change till here where we 1270 // Delay processing accelerated compositing state change till here where we
1271 // act upon the state change. (Clear the external texture if switching to 1271 // act upon the state change. (Clear the external texture if switching to
1272 // software mode or set the external texture if going to accelerated mode). 1272 // software mode or set the external texture if going to accelerated mode).
1273 if (accelerated_compositing_state_changed_) 1273 if (accelerated_compositing_state_changed_)
1274 accelerated_compositing_state_changed_ = false; 1274 accelerated_compositing_state_changed_ = false;
1275 1275
1276 if (current_surface_ && host_->is_accelerated_compositing_active()) { 1276 bool is_compositing_active = host_->is_accelerated_compositing_active();
1277 if (is_compositing_active && current_surface_) {
1277 window_->SetExternalTexture(current_surface_.get()); 1278 window_->SetExternalTexture(current_surface_.get());
1278 gfx::Size container_size = ConvertSizeToDIP(this, current_surface_->size()); 1279 gfx::Size container_size = ConvertSizeToDIP(this, current_surface_->size());
1279 CheckResizeLocks(container_size); 1280 CheckResizeLocks(container_size);
1281 } else if (is_compositing_active && current_dib_) {
1282 window_->SetExternalTexture(NULL);
1283 gfx::Size frame_size = ConvertSizeToDIP(this, last_swapped_surface_size_);
1284 CheckResizeLocks(frame_size);
1280 } else { 1285 } else {
1281 window_->SetExternalTexture(NULL); 1286 window_->SetExternalTexture(NULL);
1282 resize_locks_.clear(); 1287 resize_locks_.clear();
1283 } 1288 }
1284 } 1289 }
1285 1290
1286 bool RenderWidgetHostViewAura::SwapBuffersPrepare( 1291 bool RenderWidgetHostViewAura::SwapBuffersPrepare(
1287 const gfx::Rect& surface_rect, 1292 const gfx::Rect& surface_rect,
1288 const gfx::Rect& damage_rect, 1293 const gfx::Rect& damage_rect,
1289 const std::string& mailbox_name, 1294 const std::string& mailbox_name,
(...skipping 26 matching lines...) Expand all
1316 released_front_lock_ = NULL; 1321 released_front_lock_ = NULL;
1317 UpdateExternalTexture(); 1322 UpdateExternalTexture();
1318 1323
1319 return true; 1324 return true;
1320 } 1325 }
1321 1326
1322 void RenderWidgetHostViewAura::SwapBuffersCompleted( 1327 void RenderWidgetHostViewAura::SwapBuffersCompleted(
1323 const BufferPresentedCallback& ack_callback, 1328 const BufferPresentedCallback& ack_callback,
1324 const scoped_refptr<ui::Texture>& texture_to_return) { 1329 const scoped_refptr<ui::Texture>& texture_to_return) {
1325 ui::Compositor* compositor = GetCompositor(); 1330 ui::Compositor* compositor = GetCompositor();
1326 if (!compositor) { 1331 if (!compositor)
1327 ack_callback.Run(false, texture_to_return); 1332 ack_callback.Run(false, texture_to_return);
1328 } else { 1333 else
1329 // Add sending an ACK to the list of things to do OnCompositingDidCommit 1334 AddOnCommitCallbackAndDisableLocks(
1330 can_lock_compositor_ = NO_PENDING_COMMIT;
1331 on_compositing_did_commit_callbacks_.push_back(
1332 base::Bind(ack_callback, false, texture_to_return)); 1335 base::Bind(ack_callback, false, texture_to_return));
piman 2013/04/03 18:31:26 nit: style requires braces for the else clause if
slavi 2013/04/03 21:38:22 Done.
1333 if (!compositor->HasObserver(this))
1334 compositor->AddObserver(this);
1335 }
1336 } 1336 }
1337 1337
1338 #if defined(OS_WIN) 1338 #if defined(OS_WIN)
1339 void RenderWidgetHostViewAura::UpdateTransientRects( 1339 void RenderWidgetHostViewAura::UpdateTransientRects(
1340 const std::vector<gfx::Rect>& rects) { 1340 const std::vector<gfx::Rect>& rects) {
1341 transient_rects_ = rects; 1341 transient_rects_ = rects;
1342 UpdateCutoutRects(); 1342 UpdateCutoutRects();
1343 } 1343 }
1344 1344
1345 void RenderWidgetHostViewAura::UpdateConstrainedWindowRects( 1345 void RenderWidgetHostViewAura::UpdateConstrainedWindowRects(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 released_front_lock_ = NULL; 1393 released_front_lock_ = NULL;
1394 CheckResizeLocks(frame_size_in_dip); 1394 CheckResizeLocks(frame_size_in_dip);
1395 1395
1396 if (paint_observer_) 1396 if (paint_observer_)
1397 paint_observer_->OnUpdateCompositorContent(); 1397 paint_observer_->OnUpdateCompositorContent();
1398 1398
1399 ui::Compositor* compositor = GetCompositor(); 1399 ui::Compositor* compositor = GetCompositor();
1400 if (!compositor) { 1400 if (!compositor) {
1401 SendDelegatedFrameAck(); 1401 SendDelegatedFrameAck();
1402 } else { 1402 } else {
1403 can_lock_compositor_ = NO_PENDING_COMMIT; 1403 AddOnCommitCallbackAndDisableLocks(
1404 on_compositing_did_commit_callbacks_.push_back(
1405 base::Bind(&RenderWidgetHostViewAura::SendDelegatedFrameAck, 1404 base::Bind(&RenderWidgetHostViewAura::SendDelegatedFrameAck,
1406 base::Unretained(this))); 1405 AsWeakPtr()));
1407 if (!compositor->HasObserver(this))
1408 compositor->AddObserver(this);
1409 } 1406 }
1410 } 1407 }
1411 1408
1412 void RenderWidgetHostViewAura::SendDelegatedFrameAck() { 1409 void RenderWidgetHostViewAura::SendDelegatedFrameAck() {
1413 cc::CompositorFrameAck ack; 1410 cc::CompositorFrameAck ack;
1414 window_->layer()->TakeUnusedResourcesForChildCompositor(&ack.resources); 1411 window_->layer()->TakeUnusedResourcesForChildCompositor(&ack.resources);
1415 RenderWidgetHostImpl::SendSwapCompositorFrameAck( 1412 RenderWidgetHostImpl::SendSwapCompositorFrameAck(
1416 host_->GetRoutingID(), host_->GetProcess()->GetID(), ack); 1413 host_->GetRoutingID(), host_->GetProcess()->GetID(), ack);
1417 } 1414 }
1418 1415
1416 void RenderWidgetHostViewAura::SwapSoftwareFrame(
1417 scoped_ptr<cc::SoftwareFrameData> frame_data,
1418 float frame_device_scale_factor) {
1419 const gfx::Size& frame_size = frame_data->size;
1420 const gfx::Rect& damage_rect = frame_data->damage_rect;
1421 const TransportDIB::Id& dib_id = frame_data->dib_id;
1422
1423 scoped_ptr<TransportDIB> dib;
1424 #if defined(OS_WIN)
1425 TransportDIB::Handle my_handle = TransportDIB::DefaultHandleValue();
1426 ::DuplicateHandle(host_->GetProcess()->GetHandle(), dib_id.handle,
1427 ::GetCurrentProcess(), &my_handle,
1428 0, FALSE, DUPLICATE_SAME_ACCESS);
1429 dib.reset(TransportDIB::Map(my_handle));
1430 #elif defined(USE_X11)
1431 dib.reset(TransportDIB::Map(dib_id.shmkey));
1432 #else
1433 NOTIMPLEMENTED();
1434 #endif
1435
1436 // Validate the received DIB.
1437 size_t expected_size = 4 * frame_size.GetArea();
1438 if (!dib || dib->size() < expected_size) {
1439 host_->GetProcess()->ReceivedBadMessage();
1440 return;
1441 }
1442
1443 if (last_swapped_surface_size_ != frame_size)
1444 DLOG_IF(ERROR, damage_rect != gfx::Rect(frame_size))
piman 2013/04/03 18:31:26 nit: braces
slavi 2013/04/03 21:38:22 Done.
1445 << "Expected full damage rect";
1446
1447 // Update current_dib_ and friends.
piman 2013/04/03 18:31:26 nit: unnecessary comment.
slavi 2013/04/03 21:38:22 Done.
1448 TransportDIB::Id last_dib_id = current_dib_id_;
1449 current_dib_.reset(dib.release());
1450 current_dib_id_ = dib_id;
1451 last_swapped_surface_size_ = frame_size;
1452 previous_damage_.op(RectToSkIRect(damage_rect), SkRegion::kUnion_Op);
1453
1454 ui::Compositor* compositor = GetCompositor();
1455 gfx::Size frame_size_in_dip = gfx::ToFlooredSize(
1456 gfx::ScaleSize(frame_size, 1.0f / frame_device_scale_factor));
1457 if (!compositor || ShouldSkipFrame(frame_size_in_dip)) {
1458 SendSoftwareFrameAck(last_dib_id);
1459 return;
1460 }
1461
1462 window_->SetExternalTexture(NULL);
1463 released_front_lock_ = NULL;
1464 CheckResizeLocks(frame_size_in_dip);
1465 AddOnCommitCallbackAndDisableLocks(
1466 base::Bind(&RenderWidgetHostViewAura::SendSoftwareFrameAck,
1467 AsWeakPtr(), last_dib_id));
1468
1469 if (paint_observer_)
1470 paint_observer_->OnUpdateCompositorContent();
1471 window_->SchedulePaintInRect(ConvertRectToDIP(this, damage_rect));
1472 }
1473
1474 void RenderWidgetHostViewAura::SendSoftwareFrameAck(
1475 const TransportDIB::Id& id) {
1476 cc::CompositorFrameAck ack;
1477 ack.last_dib_id = id;
1478 RenderWidgetHostImpl::SendSwapCompositorFrameAck(
1479 host_->GetRoutingID(), host_->GetProcess()->GetID(), ack);
1480 }
1481
1482
1419 void RenderWidgetHostViewAura::OnSwapCompositorFrame( 1483 void RenderWidgetHostViewAura::OnSwapCompositorFrame(
1420 scoped_ptr<cc::CompositorFrame> frame) { 1484 scoped_ptr<cc::CompositorFrame> frame) {
1421 if (frame->delegated_frame_data) { 1485 if (frame->delegated_frame_data) {
1422 SwapDelegatedFrame(frame->delegated_frame_data.Pass(), 1486 SwapDelegatedFrame(frame->delegated_frame_data.Pass(),
1423 frame->metadata.device_scale_factor); 1487 frame->metadata.device_scale_factor);
1424 return; 1488 return;
1425 } 1489 }
1490
1491 if (frame->software_frame_data) {
1492 SwapSoftwareFrame(frame->software_frame_data.Pass(),
1493 frame->metadata.device_scale_factor);
1494 return;
1495 }
1496
1426 if (!frame->gl_frame_data || frame->gl_frame_data->mailbox.IsZero()) 1497 if (!frame->gl_frame_data || frame->gl_frame_data->mailbox.IsZero())
1427 return; 1498 return;
1428 1499
1429 BufferPresentedCallback ack_callback = base::Bind( 1500 BufferPresentedCallback ack_callback = base::Bind(
1430 &SendCompositorFrameAck, 1501 &SendCompositorFrameAck,
1431 host_->GetRoutingID(), host_->GetProcess()->GetID(), 1502 host_->GetRoutingID(), host_->GetProcess()->GetID(),
1432 frame->gl_frame_data->mailbox, frame->gl_frame_data->size); 1503 frame->gl_frame_data->mailbox, frame->gl_frame_data->size);
1433 1504
1434 if (!frame->gl_frame_data->sync_point) { 1505 if (!frame->gl_frame_data->sync_point) {
1435 LOG(ERROR) << "CompositorFrame without sync point. Skipping frame..."; 1506 LOG(ERROR) << "CompositorFrame without sync point. Skipping frame...";
1436 ack_callback.Run(true, scoped_refptr<ui::Texture>()); 1507 ack_callback.Run(true, scoped_refptr<ui::Texture>());
1437 return; 1508 return;
1438 } 1509 }
1439 1510
1440 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 1511 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
1441 factory->WaitSyncPoint(frame->gl_frame_data->sync_point); 1512 factory->WaitSyncPoint(frame->gl_frame_data->sync_point);
1442 1513
1443 std::string mailbox_name( 1514 std::string mailbox_name(
1444 reinterpret_cast<const char*>(frame->gl_frame_data->mailbox.name), 1515 reinterpret_cast<const char*>(frame->gl_frame_data->mailbox.name),
1445 sizeof(frame->gl_frame_data->mailbox.name)); 1516 sizeof(frame->gl_frame_data->mailbox.name));
1446 BuffersSwapped( 1517 BuffersSwapped(
1447 frame->gl_frame_data->size, mailbox_name, ack_callback); 1518 frame->gl_frame_data->size, mailbox_name, ack_callback);
1448 } 1519 }
1449 1520
1450 void RenderWidgetHostViewAura::BuffersSwapped( 1521 void RenderWidgetHostViewAura::BuffersSwapped(
1451 const gfx::Size& size, 1522 const gfx::Size& size,
1452 const std::string& mailbox_name, 1523 const std::string& mailbox_name,
1453 const BufferPresentedCallback& ack_callback) { 1524 const BufferPresentedCallback& ack_callback) {
1454 scoped_refptr<ui::Texture> texture_to_return(current_surface_); 1525 scoped_refptr<ui::Texture> texture_to_return(current_surface_);
1455 const gfx::Rect surface_rect = gfx::Rect(gfx::Point(), size); 1526 const gfx::Rect surface_rect = gfx::Rect(size);
1456 if (!SwapBuffersPrepare( 1527 if (!SwapBuffersPrepare(
1457 surface_rect, surface_rect, mailbox_name, ack_callback)) { 1528 surface_rect, surface_rect, mailbox_name, ack_callback)) {
1458 return; 1529 return;
1459 } 1530 }
1460 1531
1461 previous_damage_.setRect(RectToSkIRect(surface_rect)); 1532 previous_damage_.setRect(RectToSkIRect(surface_rect));
1462 skipped_damage_.setEmpty(); 1533 skipped_damage_.setEmpty();
1463 1534
1464 ui::Compositor* compositor = GetCompositor(); 1535 ui::Compositor* compositor = GetCompositor();
1465 if (compositor) { 1536 if (compositor) {
1466 gfx::Size surface_size = ConvertSizeToDIP(this, size); 1537 gfx::Size surface_size = ConvertSizeToDIP(this, size);
1467 window_->SchedulePaintInRect(gfx::Rect(surface_size)); 1538 window_->SchedulePaintInRect(gfx::Rect(surface_size));
1468 } 1539 }
1469 1540
1470 if (paint_observer_) 1541 if (paint_observer_)
1471 paint_observer_->OnUpdateCompositorContent(); 1542 paint_observer_->OnUpdateCompositorContent();
1472 1543
1473 SwapBuffersCompleted(ack_callback, texture_to_return); 1544 SwapBuffersCompleted(ack_callback, texture_to_return);
1474 } 1545 }
1475 1546
1476 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( 1547 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer(
1477 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, 1548 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel,
1478 int gpu_host_id) { 1549 int gpu_host_id) {
1479 scoped_refptr<ui::Texture> previous_texture(current_surface_); 1550 scoped_refptr<ui::Texture> previous_texture(current_surface_);
1480 const gfx::Rect surface_rect = 1551 const gfx::Rect surface_rect =
1481 gfx::Rect(gfx::Point(), params_in_pixel.surface_size); 1552 gfx::Rect(params_in_pixel.surface_size);
1482 gfx::Rect damage_rect(params_in_pixel.x, 1553 gfx::Rect damage_rect(params_in_pixel.x,
1483 params_in_pixel.y, 1554 params_in_pixel.y,
1484 params_in_pixel.width, 1555 params_in_pixel.width,
1485 params_in_pixel.height); 1556 params_in_pixel.height);
1486 BufferPresentedCallback ack_callback = base::Bind( 1557 BufferPresentedCallback ack_callback = base::Bind(
1487 &AcknowledgeBufferForGpu, params_in_pixel.route_id, gpu_host_id, 1558 &AcknowledgeBufferForGpu, params_in_pixel.route_id, gpu_host_id,
1488 params_in_pixel.mailbox_name); 1559 params_in_pixel.mailbox_name);
1489 1560
1490 if (!SwapBuffersPrepare( 1561 if (!SwapBuffersPrepare(
1491 surface_rect, damage_rect, params_in_pixel.mailbox_name, ack_callback)) { 1562 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() { 1616 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() {
1546 } 1617 }
1547 1618
1548 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { 1619 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() {
1549 // This really tells us to release the frontbuffer. 1620 // This really tells us to release the frontbuffer.
1550 if (current_surface_) { 1621 if (current_surface_) {
1551 ui::Compositor* compositor = GetCompositor(); 1622 ui::Compositor* compositor = GetCompositor();
1552 if (compositor) { 1623 if (compositor) {
1553 // We need to wait for a commit to clear to guarantee that all we 1624 // 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. 1625 // will not issue any more GL referencing the previous surface.
1555 can_lock_compositor_ = NO_PENDING_COMMIT; 1626 AddOnCommitCallbackAndDisableLocks(
1556 on_compositing_did_commit_callbacks_.push_back(
1557 base::Bind(&RenderWidgetHostViewAura:: 1627 base::Bind(&RenderWidgetHostViewAura::
1558 SetSurfaceNotInUseByCompositor, 1628 SetSurfaceNotInUseByCompositor,
1559 AsWeakPtr(), 1629 AsWeakPtr(),
1560 current_surface_)); // Hold a ref so the texture will not 1630 current_surface_)); // Hold a ref so the texture will not
1561 // get deleted until after commit. 1631 // get deleted until after commit.
1562 if (!compositor->HasObserver(this))
1563 compositor->AddObserver(this);
1564 } 1632 }
1565 current_surface_ = NULL; 1633 current_surface_ = NULL;
1566 UpdateExternalTexture(); 1634 UpdateExternalTexture();
1567 } 1635 }
1568 } 1636 }
1569 1637
1570 bool RenderWidgetHostViewAura::HasAcceleratedSurface( 1638 bool RenderWidgetHostViewAura::HasAcceleratedSurface(
1571 const gfx::Size& desired_size) { 1639 const gfx::Size& desired_size) {
1572 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't 1640 // 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 1641 // 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 2004
1937 bool RenderWidgetHostViewAura::CanFocus() { 2005 bool RenderWidgetHostViewAura::CanFocus() {
1938 return popup_type_ == WebKit::WebPopupTypeNone; 2006 return popup_type_ == WebKit::WebPopupTypeNone;
1939 } 2007 }
1940 2008
1941 void RenderWidgetHostViewAura::OnCaptureLost() { 2009 void RenderWidgetHostViewAura::OnCaptureLost() {
1942 host_->LostCapture(); 2010 host_->LostCapture();
1943 } 2011 }
1944 2012
1945 void RenderWidgetHostViewAura::OnPaint(gfx::Canvas* canvas) { 2013 void RenderWidgetHostViewAura::OnPaint(gfx::Canvas* canvas) {
1946 paint_canvas_ = canvas; 2014 bool is_compositing_active = host_->is_accelerated_compositing_active();
1947 BackingStore* backing_store = host_->GetBackingStore(true); 2015 bool has_backing_store = !!host_->GetBackingStore(false);
1948 paint_canvas_ = NULL; 2016 if (is_compositing_active && current_dib_) {
1949 if (backing_store) { 2017 SkBitmap bitmap;
1950 static_cast<BackingStoreAura*>(backing_store)->SkiaShowRect(gfx::Point(), 2018 bitmap.setConfig(SkBitmap::kARGB_8888_Config,
1951 canvas); 2019 last_swapped_surface_size_.width(),
2020 last_swapped_surface_size_.height());
2021 bitmap.setPixels(current_dib_->memory());
2022
2023 SkCanvas* sk_canvas = canvas->sk_canvas();
2024 for (SkRegion::Iterator it(previous_damage_); !it.done(); it.next()) {
2025 const SkIRect& src_rect = it.rect();
2026 SkRect dst_rect = SkRect::Make(src_rect);
2027 sk_canvas->drawBitmapRect(bitmap, &src_rect, dst_rect, NULL);
2028 }
2029 previous_damage_.setEmpty();
2030
2031 if (paint_observer_)
2032 paint_observer_->OnPaintComplete();
2033 } else if (!is_compositing_active && has_backing_store) {
2034 paint_canvas_ = canvas;
2035 BackingStoreAura* backing_store = static_cast<BackingStoreAura*>(
2036 host_->GetBackingStore(true));
2037 paint_canvas_ = NULL;
2038 backing_store->SkiaShowRect(gfx::Point(), canvas);
2039
1952 if (paint_observer_) 2040 if (paint_observer_)
1953 paint_observer_->OnPaintComplete(); 2041 paint_observer_->OnPaintComplete();
1954 } else if (aura::Env::GetInstance()->render_white_bg()) { 2042 } else if (aura::Env::GetInstance()->render_white_bg()) {
1955 canvas->DrawColor(SK_ColorWHITE); 2043 canvas->DrawColor(SK_ColorWHITE);
1956 } 2044 }
1957 } 2045 }
1958 2046
1959 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged( 2047 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged(
1960 float device_scale_factor) { 2048 float device_scale_factor) {
1961 if (!host_) 2049 if (!host_)
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
2359 2447
2360 void RenderWidgetHostViewAura::OnCompositingDidCommit( 2448 void RenderWidgetHostViewAura::OnCompositingDidCommit(
2361 ui::Compositor* compositor) { 2449 ui::Compositor* compositor) {
2362 if (can_lock_compositor_ == NO_PENDING_COMMIT) { 2450 if (can_lock_compositor_ == NO_PENDING_COMMIT) {
2363 can_lock_compositor_ = YES; 2451 can_lock_compositor_ = YES;
2364 for (ResizeLockList::iterator it = resize_locks_.begin(); 2452 for (ResizeLockList::iterator it = resize_locks_.begin();
2365 it != resize_locks_.end(); ++it) 2453 it != resize_locks_.end(); ++it)
2366 if ((*it)->GrabDeferredLock()) 2454 if ((*it)->GrabDeferredLock())
2367 can_lock_compositor_ = YES_DID_LOCK; 2455 can_lock_compositor_ = YES_DID_LOCK;
2368 } 2456 }
2369 RunCompositingDidCommitCallbacks(); 2457 RunOnCommitCallbacks();
2370 locks_pending_commit_.clear(); 2458 locks_pending_commit_.clear();
2371 } 2459 }
2372 2460
2373 void RenderWidgetHostViewAura::OnCompositingStarted( 2461 void RenderWidgetHostViewAura::OnCompositingStarted(
2374 ui::Compositor* compositor, base::TimeTicks start_time) { 2462 ui::Compositor* compositor, base::TimeTicks start_time) {
2375 last_draw_ended_ = start_time; 2463 last_draw_ended_ = start_time;
2376 } 2464 }
2377 2465
2378 void RenderWidgetHostViewAura::OnCompositingEnded( 2466 void RenderWidgetHostViewAura::OnCompositingEnded(
2379 ui::Compositor* compositor) { 2467 ui::Compositor* compositor) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2458 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: 2546 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation:
2459 2547
2460 void RenderWidgetHostViewAura::OnLostResources() { 2548 void RenderWidgetHostViewAura::OnLostResources() {
2461 current_surface_ = NULL; 2549 current_surface_ = NULL;
2462 UpdateExternalTexture(); 2550 UpdateExternalTexture();
2463 locks_pending_commit_.clear(); 2551 locks_pending_commit_.clear();
2464 2552
2465 // Make sure all ImageTransportClients are deleted now that the context those 2553 // 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 2554 // are using is becoming invalid. This sends pending ACKs and needs to happen
2467 // after calling UpdateExternalTexture() which syncs with the impl thread. 2555 // after calling UpdateExternalTexture() which syncs with the impl thread.
2468 RunCompositingDidCommitCallbacks(); 2556 RunOnCommitCallbacks();
2469 2557
2470 DCHECK(!shared_surface_handle_.is_null()); 2558 DCHECK(!shared_surface_handle_.is_null());
2471 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 2559 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
2472 factory->DestroySharedSurfaceHandle(shared_surface_handle_); 2560 factory->DestroySharedSurfaceHandle(shared_surface_handle_);
2473 shared_surface_handle_ = factory->CreateSharedSurfaceHandle(); 2561 shared_surface_handle_ = factory->CreateSharedSurfaceHandle();
2474 host_->CompositingSurfaceUpdated(); 2562 host_->CompositingSurfaceUpdated();
2475 host_->ScheduleComposite(); 2563 host_->ScheduleComposite();
2476 } 2564 }
2477 2565
2478 //////////////////////////////////////////////////////////////////////////////// 2566 ////////////////////////////////////////////////////////////////////////////////
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
2614 gfx::Rect rect = window_->bounds(); 2702 gfx::Rect rect = window_->bounds();
2615 int border_x = rect.width() * kMouseLockBorderPercentage / 100; 2703 int border_x = rect.width() * kMouseLockBorderPercentage / 100;
2616 int border_y = rect.height() * kMouseLockBorderPercentage / 100; 2704 int border_y = rect.height() * kMouseLockBorderPercentage / 100;
2617 2705
2618 return global_mouse_position_.x() < rect.x() + border_x || 2706 return global_mouse_position_.x() < rect.x() + border_x ||
2619 global_mouse_position_.x() > rect.right() - border_x || 2707 global_mouse_position_.x() > rect.right() - border_x ||
2620 global_mouse_position_.y() < rect.y() + border_y || 2708 global_mouse_position_.y() < rect.y() + border_y ||
2621 global_mouse_position_.y() > rect.bottom() - border_y; 2709 global_mouse_position_.y() > rect.bottom() - border_y;
2622 } 2710 }
2623 2711
2624 void RenderWidgetHostViewAura::RunCompositingDidCommitCallbacks() { 2712 void RenderWidgetHostViewAura::RunOnCommitCallbacks() {
2625 for (std::vector<base::Closure>::const_iterator 2713 for (std::vector<base::Closure>::const_iterator
2626 it = on_compositing_did_commit_callbacks_.begin(); 2714 it = on_compositing_did_commit_callbacks_.begin();
2627 it != on_compositing_did_commit_callbacks_.end(); ++it) { 2715 it != on_compositing_did_commit_callbacks_.end(); ++it) {
2628 it->Run(); 2716 it->Run();
2629 } 2717 }
2630 on_compositing_did_commit_callbacks_.clear(); 2718 on_compositing_did_commit_callbacks_.clear();
2631 } 2719 }
2632 2720
2721 void RenderWidgetHostViewAura::AddOnCommitCallbackAndDisableLocks(
2722 const base::Closure& callback) {
2723 ui::Compositor* compositor = GetCompositor();
2724 DCHECK(compositor);
2725
2726 if (!compositor->HasObserver(this))
2727 compositor->AddObserver(this);
2728
2729 can_lock_compositor_ = NO_PENDING_COMMIT;
2730 on_compositing_did_commit_callbacks_.push_back(callback);
2731 }
2732
2633 void RenderWidgetHostViewAura::AddedToRootWindow() { 2733 void RenderWidgetHostViewAura::AddedToRootWindow() {
2634 window_->GetRootWindow()->AddRootWindowObserver(this); 2734 window_->GetRootWindow()->AddRootWindowObserver(this);
2635 host_->ParentChanged(GetNativeViewId()); 2735 host_->ParentChanged(GetNativeViewId());
2636 UpdateScreenInfo(window_); 2736 UpdateScreenInfo(window_);
2637 if (popup_type_ != WebKit::WebPopupTypeNone) 2737 if (popup_type_ != WebKit::WebPopupTypeNone)
2638 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); 2738 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this));
2639 } 2739 }
2640 2740
2641 void RenderWidgetHostViewAura::RemovingFromRootWindow() { 2741 void RenderWidgetHostViewAura::RemovingFromRootWindow() {
2642 event_filter_for_popup_exit_.reset(); 2742 event_filter_for_popup_exit_.reset();
2643 window_->GetRootWindow()->RemoveRootWindowObserver(this); 2743 window_->GetRootWindow()->RemoveRootWindowObserver(this);
2644 host_->ParentChanged(0); 2744 host_->ParentChanged(0);
2645 // We are about to disconnect ourselves from the compositor, we need to issue 2745 // 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. 2746 // 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 2747 // 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 2748 // 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 2749 // frame though, because we will reissue a new frame right away without that
2650 // composited data. 2750 // composited data.
2651 ui::Compositor* compositor = GetCompositor(); 2751 ui::Compositor* compositor = GetCompositor();
2652 RunCompositingDidCommitCallbacks(); 2752 RunOnCommitCallbacks();
2653 locks_pending_commit_.clear(); 2753 locks_pending_commit_.clear();
2654 if (compositor && compositor->HasObserver(this)) 2754 if (compositor && compositor->HasObserver(this))
2655 compositor->RemoveObserver(this); 2755 compositor->RemoveObserver(this);
2656 } 2756 }
2657 2757
2658 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() { 2758 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() {
2659 aura::RootWindow* root_window = window_->GetRootWindow(); 2759 aura::RootWindow* root_window = window_->GetRootWindow();
2660 return root_window ? root_window->compositor() : NULL; 2760 return root_window ? root_window->compositor() : NULL;
2661 } 2761 }
2662 2762
(...skipping 11 matching lines...) Expand all
2674 RenderWidgetHost* widget) { 2774 RenderWidgetHost* widget) {
2675 return new RenderWidgetHostViewAura(widget); 2775 return new RenderWidgetHostViewAura(widget);
2676 } 2776 }
2677 2777
2678 // static 2778 // static
2679 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { 2779 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) {
2680 GetScreenInfoForWindow(results, NULL); 2780 GetScreenInfoForWindow(results, NULL);
2681 } 2781 }
2682 2782
2683 } // namespace content 2783 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698