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

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

Powered by Google App Engine
This is Rietveld 408576698