| 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_mac.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
| 6 | 6 |
| 7 #import <objc/runtime.h> | 7 #import <objc/runtime.h> |
| 8 #include <QuartzCore/QuartzCore.h> | 8 #include <QuartzCore/QuartzCore.h> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 call_set_needs_display_in_rect_pending_(false), | 411 call_set_needs_display_in_rect_pending_(false), |
| 412 last_frame_was_accelerated_(false), | 412 last_frame_was_accelerated_(false), |
| 413 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 413 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| 414 can_compose_inline_(true), | 414 can_compose_inline_(true), |
| 415 software_frame_needs_to_send_ack_(false), | 415 software_frame_needs_to_send_ack_(false), |
| 416 allow_overlapping_views_(false), | 416 allow_overlapping_views_(false), |
| 417 use_core_animation_(false), | 417 use_core_animation_(false), |
| 418 is_loading_(false), | 418 is_loading_(false), |
| 419 weak_factory_(this), | 419 weak_factory_(this), |
| 420 fullscreen_parent_host_view_(NULL), | 420 fullscreen_parent_host_view_(NULL), |
| 421 pending_swap_buffers_acks_weak_factory_(this), | |
| 422 underlay_view_has_drawn_(false), | 421 underlay_view_has_drawn_(false), |
| 423 overlay_view_weak_factory_(this), | 422 overlay_view_weak_factory_(this), |
| 424 next_swap_ack_time_(base::Time::Now()), | |
| 425 software_frame_weak_ptr_factory_(this) { | 423 software_frame_weak_ptr_factory_(this) { |
| 426 software_frame_manager_.reset(new SoftwareFrameManager( | 424 software_frame_manager_.reset(new SoftwareFrameManager( |
| 427 software_frame_weak_ptr_factory_.GetWeakPtr())); | 425 software_frame_weak_ptr_factory_.GetWeakPtr())); |
| 428 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| | 426 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| |
| 429 // goes away. Since we autorelease it, our caller must put | 427 // goes away. Since we autorelease it, our caller must put |
| 430 // |GetNativeView()| into the view hierarchy right after calling us. | 428 // |GetNativeView()| into the view hierarchy right after calling us. |
| 431 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] | 429 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] |
| 432 initWithRenderWidgetHostViewMac:this] autorelease]; | 430 initWithRenderWidgetHostViewMac:this] autorelease]; |
| 433 | 431 |
| 434 if (GetCoreAnimationStatus() == CORE_ANIMATION_ENABLED_ALWAYS) { | 432 if (GetCoreAnimationStatus() == CORE_ANIMATION_ENABLED_ALWAYS) { |
| 435 EnableCoreAnimation(); | 433 EnableCoreAnimation(); |
| 436 } | 434 } |
| 437 | 435 |
| 438 render_widget_host_->SetView(this); | 436 render_widget_host_->SetView(this); |
| 439 } | 437 } |
| 440 | 438 |
| 441 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { | 439 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { |
| 442 // This is being called from |cocoa_view_|'s destructor, so invalidate the | 440 // This is being called from |cocoa_view_|'s destructor, so invalidate the |
| 443 // pointer. | 441 // pointer. |
| 444 cocoa_view_ = nil; | 442 cocoa_view_ = nil; |
| 445 | 443 |
| 446 AckPendingSwapBuffers(); | |
| 447 UnlockMouse(); | 444 UnlockMouse(); |
| 448 | 445 |
| 449 // Make sure that the layer doesn't reach into the now-invalid object. | 446 // Make sure that the layer doesn't reach into the now-invalid object. |
| 450 DestroyCompositedIOSurfaceAndLayer(kDestroyContext); | 447 DestroyCompositedIOSurfaceAndLayer(kDestroyContext); |
| 451 software_layer_.reset(); | 448 software_layer_.reset(); |
| 452 | 449 |
| 453 // We are owned by RenderWidgetHostViewCocoa, so if we go away before the | 450 // We are owned by RenderWidgetHostViewCocoa, so if we go away before the |
| 454 // RenderWidgetHost does we need to tell it not to hold a stale pointer to | 451 // RenderWidgetHost does we need to tell it not to hold a stale pointer to |
| 455 // us. | 452 // us. |
| 456 if (render_widget_host_) | 453 if (render_widget_host_) |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 if (!use_core_animation_) | 729 if (!use_core_animation_) |
| 733 [[cocoa_view_ window] disableScreenUpdatesUntilFlush]; | 730 [[cocoa_view_ window] disableScreenUpdatesUntilFlush]; |
| 734 | 731 |
| 735 [compositing_iosurface_layer_ setNeedsDisplay]; | 732 [compositing_iosurface_layer_ setNeedsDisplay]; |
| 736 } | 733 } |
| 737 | 734 |
| 738 void RenderWidgetHostViewMac::WasHidden() { | 735 void RenderWidgetHostViewMac::WasHidden() { |
| 739 if (render_widget_host_->is_hidden()) | 736 if (render_widget_host_->is_hidden()) |
| 740 return; | 737 return; |
| 741 | 738 |
| 742 // Send ACKs for any pending SwapBuffers (if any) since we won't be displaying | |
| 743 // them and the GPU process is waiting. | |
| 744 AckPendingSwapBuffers(); | |
| 745 | |
| 746 // If we have a renderer, then inform it that we are being hidden so it can | 739 // If we have a renderer, then inform it that we are being hidden so it can |
| 747 // reduce its resource utilization. | 740 // reduce its resource utilization. |
| 748 render_widget_host_->WasHidden(); | 741 render_widget_host_->WasHidden(); |
| 749 software_frame_manager_->SetVisibility(false); | 742 software_frame_manager_->SetVisibility(false); |
| 750 | 743 |
| 751 // There can be a transparent flash as this view is removed and the next is | 744 // There can be a transparent flash as this view is removed and the next is |
| 752 // added, because of OSX windowing races between displaying the contents of | 745 // added, because of OSX windowing races between displaying the contents of |
| 753 // the NSView and its corresponding OpenGL context. | 746 // the NSView and its corresponding OpenGL context. |
| 754 // disableScreenUpdatesUntilFlush prevents the transparent flash by avoiding | 747 // disableScreenUpdatesUntilFlush prevents the transparent flash by avoiding |
| 755 // screen updates until the next tab draws. | 748 // screen updates until the next tab draws. |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 if (!about_to_validate_and_paint_) | 974 if (!about_to_validate_and_paint_) |
| 982 [cocoa_view_ displayIfNeeded]; | 975 [cocoa_view_ displayIfNeeded]; |
| 983 } | 976 } |
| 984 | 977 |
| 985 void RenderWidgetHostViewMac::RenderProcessGone(base::TerminationStatus status, | 978 void RenderWidgetHostViewMac::RenderProcessGone(base::TerminationStatus status, |
| 986 int error_code) { | 979 int error_code) { |
| 987 Destroy(); | 980 Destroy(); |
| 988 } | 981 } |
| 989 | 982 |
| 990 void RenderWidgetHostViewMac::Destroy() { | 983 void RenderWidgetHostViewMac::Destroy() { |
| 991 AckPendingSwapBuffers(); | |
| 992 | |
| 993 [[NSNotificationCenter defaultCenter] | 984 [[NSNotificationCenter defaultCenter] |
| 994 removeObserver:cocoa_view_ | 985 removeObserver:cocoa_view_ |
| 995 name:NSWindowWillCloseNotification | 986 name:NSWindowWillCloseNotification |
| 996 object:popup_window_]; | 987 object:popup_window_]; |
| 997 | 988 |
| 998 // We've been told to destroy. | 989 // We've been told to destroy. |
| 999 [cocoa_view_ retain]; | 990 [cocoa_view_ retain]; |
| 1000 [cocoa_view_ removeFromSuperview]; | 991 [cocoa_view_ removeFromSuperview]; |
| 1001 [cocoa_view_ autorelease]; | 992 [cocoa_view_ autorelease]; |
| 1002 | 993 |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1377 } else { | 1368 } else { |
| 1378 if (!DrawIOSurfaceWithoutCoreAnimation()) { | 1369 if (!DrawIOSurfaceWithoutCoreAnimation()) { |
| 1379 [cocoa_view_ setNeedsDisplay:YES]; | 1370 [cocoa_view_ setNeedsDisplay:YES]; |
| 1380 GotAcceleratedCompositingError(); | 1371 GotAcceleratedCompositingError(); |
| 1381 return; | 1372 return; |
| 1382 } | 1373 } |
| 1383 } | 1374 } |
| 1384 } | 1375 } |
| 1385 } | 1376 } |
| 1386 | 1377 |
| 1387 void RenderWidgetHostViewMac::AckPendingSwapBuffers() { | |
| 1388 TRACE_EVENT0("browser", "RenderWidgetHostViewMac::AckPendingSwapBuffers"); | |
| 1389 | |
| 1390 // Cancel any outstanding delayed calls to this function. | |
| 1391 pending_swap_buffers_acks_weak_factory_.InvalidateWeakPtrs(); | |
| 1392 | |
| 1393 while (!pending_swap_buffers_acks_.empty()) { | |
| 1394 if (pending_swap_buffers_acks_.front().first != 0) { | |
| 1395 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; | |
| 1396 ack_params.sync_point = 0; | |
| 1397 if (compositing_iosurface_) | |
| 1398 ack_params.renderer_id = compositing_iosurface_->GetRendererID(); | |
| 1399 RenderWidgetHostImpl::AcknowledgeBufferPresent( | |
| 1400 pending_swap_buffers_acks_.front().first, | |
| 1401 pending_swap_buffers_acks_.front().second, | |
| 1402 ack_params); | |
| 1403 if (render_widget_host_) { | |
| 1404 render_widget_host_->AcknowledgeSwapBuffersToRenderer(); | |
| 1405 } | |
| 1406 } | |
| 1407 pending_swap_buffers_acks_.erase(pending_swap_buffers_acks_.begin()); | |
| 1408 } | |
| 1409 } | |
| 1410 | |
| 1411 void RenderWidgetHostViewMac::ThrottledAckPendingSwapBuffers() { | |
| 1412 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 1413 | |
| 1414 // Send VSync parameters to the renderer's compositor thread. | |
| 1415 base::TimeTicks vsync_timebase; | |
| 1416 base::TimeDelta vsync_interval; | |
| 1417 GetVSyncParameters(&vsync_timebase, &vsync_interval); | |
| 1418 if (render_widget_host_ && compositing_iosurface_) | |
| 1419 render_widget_host_->UpdateVSyncParameters(vsync_timebase, vsync_interval); | |
| 1420 | |
| 1421 // If the render widget host is responsible for throttling swaps to vsync rate | |
| 1422 // then don't ack the swapbuffers until a full vsync has passed since the last | |
| 1423 // ack was sent. | |
| 1424 bool throttle_swap_ack = | |
| 1425 render_widget_host_ && | |
| 1426 !render_widget_host_->is_threaded_compositing_enabled() && | |
| 1427 compositing_iosurface_context_ && | |
| 1428 !compositing_iosurface_context_->is_vsync_disabled(); | |
| 1429 base::Time now = base::Time::Now(); | |
| 1430 if (throttle_swap_ack && next_swap_ack_time_ > now) { | |
| 1431 base::TimeDelta next_swap_ack_delay = next_swap_ack_time_ - now; | |
| 1432 next_swap_ack_time_ += vsync_interval; | |
| 1433 base::MessageLoop::current()->PostDelayedTask( | |
| 1434 FROM_HERE, | |
| 1435 base::Bind(&RenderWidgetHostViewMac::AckPendingSwapBuffers, | |
| 1436 pending_swap_buffers_acks_weak_factory_.GetWeakPtr()), | |
| 1437 next_swap_ack_delay); | |
| 1438 } else { | |
| 1439 next_swap_ack_time_ = now + vsync_interval; | |
| 1440 AckPendingSwapBuffers(); | |
| 1441 } | |
| 1442 } | |
| 1443 | |
| 1444 bool RenderWidgetHostViewMac::DrawIOSurfaceWithoutCoreAnimation() { | 1378 bool RenderWidgetHostViewMac::DrawIOSurfaceWithoutCoreAnimation() { |
| 1445 CHECK(!use_core_animation_); | 1379 CHECK(!use_core_animation_); |
| 1446 CHECK(compositing_iosurface_); | 1380 CHECK(compositing_iosurface_); |
| 1447 | 1381 |
| 1448 GLint old_gl_surface_order = 0; | 1382 GLint old_gl_surface_order = 0; |
| 1449 GLint new_gl_surface_order = allow_overlapping_views_ ? -1 : 1; | 1383 GLint new_gl_surface_order = allow_overlapping_views_ ? -1 : 1; |
| 1450 [compositing_iosurface_context_->nsgl_context() | 1384 [compositing_iosurface_context_->nsgl_context() |
| 1451 getValues:&old_gl_surface_order | 1385 getValues:&old_gl_surface_order |
| 1452 forParameter:NSOpenGLCPSurfaceOrder]; | 1386 forParameter:NSOpenGLCPSurfaceOrder]; |
| 1453 if (old_gl_surface_order != new_gl_surface_order) { | 1387 if (old_gl_surface_order != new_gl_surface_order) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1497 overlay_view_rect, | 1431 overlay_view_rect, |
| 1498 overlay_view_->scale_factor(), | 1432 overlay_view_->scale_factor(), |
| 1499 overlay_view_->frame_subscriber(), | 1433 overlay_view_->frame_subscriber(), |
| 1500 true); | 1434 true); |
| 1501 } | 1435 } |
| 1502 | 1436 |
| 1503 return true; | 1437 return true; |
| 1504 } | 1438 } |
| 1505 | 1439 |
| 1506 void RenderWidgetHostViewMac::GotAcceleratedCompositingError() { | 1440 void RenderWidgetHostViewMac::GotAcceleratedCompositingError() { |
| 1507 AckPendingSwapBuffers(); | |
| 1508 DestroyCompositedIOSurfaceAndLayer(kDestroyContext); | 1441 DestroyCompositedIOSurfaceAndLayer(kDestroyContext); |
| 1509 // The existing GL contexts may be in a bad state, so don't re-use any of the | 1442 // The existing GL contexts may be in a bad state, so don't re-use any of the |
| 1510 // existing ones anymore, rather, allocate new ones. | 1443 // existing ones anymore, rather, allocate new ones. |
| 1511 CompositingIOSurfaceContext::MarkExistingContextsAsNotShareable(); | 1444 CompositingIOSurfaceContext::MarkExistingContextsAsNotShareable(); |
| 1512 // Request that a new frame be generated. | 1445 // Request that a new frame be generated. |
| 1513 if (render_widget_host_) | 1446 if (render_widget_host_) |
| 1514 render_widget_host_->ScheduleComposite(); | 1447 render_widget_host_->ScheduleComposite(); |
| 1515 // TODO(ccameron): It may be a good idea to request that the renderer recreate | 1448 // TODO(ccameron): It may be a good idea to request that the renderer recreate |
| 1516 // its GL context as well, and fall back to software if this happens | 1449 // its GL context as well, and fall back to software if this happens |
| 1517 // repeatedly. | 1450 // repeatedly. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1533 | 1466 |
| 1534 void RenderWidgetHostViewMac::RemoveOverlayView() { | 1467 void RenderWidgetHostViewMac::RemoveOverlayView() { |
| 1535 if (overlay_view_) { | 1468 if (overlay_view_) { |
| 1536 overlay_view_->underlay_view_.reset(); | 1469 overlay_view_->underlay_view_.reset(); |
| 1537 overlay_view_.reset(); | 1470 overlay_view_.reset(); |
| 1538 } | 1471 } |
| 1539 [cocoa_view_ setNeedsDisplay:YES]; | 1472 [cocoa_view_ setNeedsDisplay:YES]; |
| 1540 [[cocoa_view_ window] disableScreenUpdatesUntilFlush]; | 1473 [[cocoa_view_ window] disableScreenUpdatesUntilFlush]; |
| 1541 } | 1474 } |
| 1542 | 1475 |
| 1543 void RenderWidgetHostViewMac::GetVSyncParameters( | |
| 1544 base::TimeTicks* timebase, base::TimeDelta* interval) { | |
| 1545 if (compositing_iosurface_) { | |
| 1546 uint32 numerator = 0; | |
| 1547 uint32 denominator = 0; | |
| 1548 compositing_iosurface_->GetVSyncParameters( | |
| 1549 timebase, &numerator, &denominator); | |
| 1550 if (numerator > 0 && denominator > 0) { | |
| 1551 int64 interval_micros = | |
| 1552 1000000 * static_cast<int64>(numerator) / denominator; | |
| 1553 *interval = base::TimeDelta::FromMicroseconds(interval_micros); | |
| 1554 return; | |
| 1555 } | |
| 1556 } | |
| 1557 | |
| 1558 // Pass reasonable default values if unable to get the actual ones | |
| 1559 // (e.g. CVDisplayLink failed to return them because the display is | |
| 1560 // in sleep mode). | |
| 1561 static const int64 kOneOverSixtyMicroseconds = 16669; | |
| 1562 *timebase = base::TimeTicks::Now(), | |
| 1563 *interval = base::TimeDelta::FromMicroseconds(kOneOverSixtyMicroseconds); | |
| 1564 } | |
| 1565 | |
| 1566 bool RenderWidgetHostViewMac::GetLineBreakIndex( | 1476 bool RenderWidgetHostViewMac::GetLineBreakIndex( |
| 1567 const std::vector<gfx::Rect>& bounds, | 1477 const std::vector<gfx::Rect>& bounds, |
| 1568 const gfx::Range& range, | 1478 const gfx::Range& range, |
| 1569 size_t* line_break_point) { | 1479 size_t* line_break_point) { |
| 1570 DCHECK(line_break_point); | 1480 DCHECK(line_break_point); |
| 1571 if (range.start() >= bounds.size() || range.is_reversed() || range.is_empty()) | 1481 if (range.start() >= bounds.size() || range.is_reversed() || range.is_empty()) |
| 1572 return false; | 1482 return false; |
| 1573 | 1483 |
| 1574 // We can't check line breaking completely from only rectangle array. Thus we | 1484 // We can't check line breaking completely from only rectangle array. Thus we |
| 1575 // assume the line breaking as the next character's y offset is larger than | 1485 // assume the line breaking as the next character's y offset is larger than |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1688 return true; | 1598 return true; |
| 1689 } | 1599 } |
| 1690 | 1600 |
| 1691 void RenderWidgetHostViewMac::AcceleratedSurfaceBuffersSwapped( | 1601 void RenderWidgetHostViewMac::AcceleratedSurfaceBuffersSwapped( |
| 1692 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, | 1602 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, |
| 1693 int gpu_host_id) { | 1603 int gpu_host_id) { |
| 1694 TRACE_EVENT0("browser", | 1604 TRACE_EVENT0("browser", |
| 1695 "RenderWidgetHostViewMac::AcceleratedSurfaceBuffersSwapped"); | 1605 "RenderWidgetHostViewMac::AcceleratedSurfaceBuffersSwapped"); |
| 1696 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1606 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1697 | 1607 |
| 1698 pending_swap_buffers_acks_.push_back(std::make_pair(params.route_id, | |
| 1699 gpu_host_id)); | |
| 1700 | |
| 1701 CompositorSwapBuffers(params.surface_handle, | 1608 CompositorSwapBuffers(params.surface_handle, |
| 1702 params.size, | 1609 params.size, |
| 1703 params.scale_factor, | 1610 params.scale_factor, |
| 1704 params.latency_info); | 1611 params.latency_info); |
| 1705 | 1612 |
| 1706 ThrottledAckPendingSwapBuffers(); | 1613 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; |
| 1614 ack_params.sync_point = 0; |
| 1615 ack_params.renderer_id = compositing_iosurface_ ? |
| 1616 compositing_iosurface_->GetRendererID() : 0; |
| 1617 RenderWidgetHostImpl::AcknowledgeBufferPresent(params.route_id, |
| 1618 gpu_host_id, |
| 1619 ack_params); |
| 1620 render_widget_host_->AcknowledgeSwapBuffersToRenderer(); |
| 1707 } | 1621 } |
| 1708 | 1622 |
| 1709 void RenderWidgetHostViewMac::AcceleratedSurfacePostSubBuffer( | 1623 void RenderWidgetHostViewMac::AcceleratedSurfacePostSubBuffer( |
| 1710 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, | 1624 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, |
| 1711 int gpu_host_id) { | 1625 int gpu_host_id) { |
| 1712 TRACE_EVENT0("browser", | 1626 TRACE_EVENT0("browser", |
| 1713 "RenderWidgetHostViewMac::AcceleratedSurfacePostSubBuffer"); | 1627 "RenderWidgetHostViewMac::AcceleratedSurfacePostSubBuffer"); |
| 1714 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1628 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1715 | 1629 |
| 1716 pending_swap_buffers_acks_.push_back(std::make_pair(params.route_id, | |
| 1717 gpu_host_id)); | |
| 1718 | |
| 1719 CompositorSwapBuffers(params.surface_handle, | 1630 CompositorSwapBuffers(params.surface_handle, |
| 1720 params.surface_size, | 1631 params.surface_size, |
| 1721 params.surface_scale_factor, | 1632 params.surface_scale_factor, |
| 1722 params.latency_info); | 1633 params.latency_info); |
| 1723 | 1634 |
| 1724 ThrottledAckPendingSwapBuffers(); | 1635 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; |
| 1636 ack_params.sync_point = 0; |
| 1637 ack_params.renderer_id = compositing_iosurface_ ? |
| 1638 compositing_iosurface_->GetRendererID() : 0; |
| 1639 RenderWidgetHostImpl::AcknowledgeBufferPresent(params.route_id, |
| 1640 gpu_host_id, |
| 1641 ack_params); |
| 1642 render_widget_host_->AcknowledgeSwapBuffersToRenderer(); |
| 1725 } | 1643 } |
| 1726 | 1644 |
| 1727 void RenderWidgetHostViewMac::AcceleratedSurfaceSuspend() { | 1645 void RenderWidgetHostViewMac::AcceleratedSurfaceSuspend() { |
| 1728 if (compositing_iosurface_) | 1646 if (compositing_iosurface_) |
| 1729 compositing_iosurface_->UnrefIOSurface(); | 1647 compositing_iosurface_->UnrefIOSurface(); |
| 1730 } | 1648 } |
| 1731 | 1649 |
| 1732 void RenderWidgetHostViewMac::AcceleratedSurfaceRelease() { | 1650 void RenderWidgetHostViewMac::AcceleratedSurfaceRelease() { |
| 1733 DestroyCompositedIOSurfaceAndLayer(kDestroyContext); | 1651 DestroyCompositedIOSurfaceAndLayer(kDestroyContext); |
| 1734 } | 1652 } |
| 1735 | 1653 |
| 1736 bool RenderWidgetHostViewMac::HasAcceleratedSurface( | 1654 bool RenderWidgetHostViewMac::HasAcceleratedSurface( |
| 1737 const gfx::Size& desired_size) { | 1655 const gfx::Size& desired_size) { |
| 1738 if (last_frame_was_accelerated_) { | 1656 if (last_frame_was_accelerated_) { |
| 1739 return compositing_iosurface_ && | 1657 return compositing_iosurface_ && |
| 1740 compositing_iosurface_->HasIOSurface() && | 1658 compositing_iosurface_->HasIOSurface() && |
| 1741 (desired_size.IsEmpty() || | 1659 (desired_size.IsEmpty() || |
| 1742 compositing_iosurface_->dip_io_surface_size() == desired_size); | 1660 compositing_iosurface_->dip_io_surface_size() == desired_size); |
| 1743 } else { | 1661 } else { |
| 1744 return (software_frame_manager_->HasCurrentFrame() && | 1662 return (software_frame_manager_->HasCurrentFrame() && |
| 1745 (desired_size.IsEmpty() || | 1663 (desired_size.IsEmpty() || |
| 1746 software_frame_manager_->GetCurrentFrameSizeInDIP() == | 1664 software_frame_manager_->GetCurrentFrameSizeInDIP() == |
| 1747 desired_size)); | 1665 desired_size)); |
| 1748 } | 1666 } |
| 1749 return false; | 1667 return false; |
| 1750 } | 1668 } |
| 1751 | 1669 |
| 1752 void RenderWidgetHostViewMac::AboutToWaitForBackingStoreMsg() { | |
| 1753 AckPendingSwapBuffers(); | |
| 1754 } | |
| 1755 | |
| 1756 void RenderWidgetHostViewMac::OnSwapCompositorFrame( | 1670 void RenderWidgetHostViewMac::OnSwapCompositorFrame( |
| 1757 uint32 output_surface_id, scoped_ptr<cc::CompositorFrame> frame) { | 1671 uint32 output_surface_id, scoped_ptr<cc::CompositorFrame> frame) { |
| 1758 // Only software compositor frames are accepted. | 1672 // Only software compositor frames are accepted. |
| 1759 if (!frame->software_frame_data) { | 1673 if (!frame->software_frame_data) { |
| 1760 DLOG(ERROR) << "Received unexpected frame type."; | 1674 DLOG(ERROR) << "Received unexpected frame type."; |
| 1761 RecordAction( | 1675 RecordAction( |
| 1762 UserMetricsAction("BadMessageTerminate_UnexpectedFrameType")); | 1676 UserMetricsAction("BadMessageTerminate_UnexpectedFrameType")); |
| 1763 render_widget_host_->GetProcess()->ReceivedBadMessage(); | 1677 render_widget_host_->GetProcess()->ReceivedBadMessage(); |
| 1764 return; | 1678 return; |
| 1765 } | 1679 } |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1912 // Delete software backingstore. | 1826 // Delete software backingstore. |
| 1913 BackingStoreManager::RemoveBackingStore(render_widget_host_); | 1827 BackingStoreManager::RemoveBackingStore(render_widget_host_); |
| 1914 software_frame_manager_->DiscardCurrentFrame(); | 1828 software_frame_manager_->DiscardCurrentFrame(); |
| 1915 } | 1829 } |
| 1916 } | 1830 } |
| 1917 | 1831 |
| 1918 void RenderWidgetHostViewMac::GotSoftwareFrame() { | 1832 void RenderWidgetHostViewMac::GotSoftwareFrame() { |
| 1919 if (last_frame_was_accelerated_) { | 1833 if (last_frame_was_accelerated_) { |
| 1920 last_frame_was_accelerated_ = false; | 1834 last_frame_was_accelerated_ = false; |
| 1921 | 1835 |
| 1922 AckPendingSwapBuffers(); | |
| 1923 | |
| 1924 // If overlapping views are allowed, then don't unbind the context | 1836 // If overlapping views are allowed, then don't unbind the context |
| 1925 // from the view (that is, don't call clearDrawble -- just delete the | 1837 // from the view (that is, don't call clearDrawble -- just delete the |
| 1926 // texture and IOSurface). Rather, let it sit behind the software frame | 1838 // texture and IOSurface). Rather, let it sit behind the software frame |
| 1927 // that will be put up in front. This will prevent transparent | 1839 // that will be put up in front. This will prevent transparent |
| 1928 // flashes. | 1840 // flashes. |
| 1929 // http://crbug.com/154531 | 1841 // http://crbug.com/154531 |
| 1930 // Also note that it is necessary that clearDrawable be called if | 1842 // Also note that it is necessary that clearDrawable be called if |
| 1931 // overlapping views are not allowed, e.g, for content shell. | 1843 // overlapping views are not allowed, e.g, for content shell. |
| 1932 // http://crbug.com/178408 | 1844 // http://crbug.com/178408 |
| 1933 // Disable screen updates so that the changes of flashes is minimized. | 1845 // Disable screen updates so that the changes of flashes is minimized. |
| (...skipping 2151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4085 return YES; | 3997 return YES; |
| 4086 } | 3998 } |
| 4087 | 3999 |
| 4088 - (BOOL)isOpaque { | 4000 - (BOOL)isOpaque { |
| 4089 if (renderWidgetHostView_->use_core_animation_) | 4001 if (renderWidgetHostView_->use_core_animation_) |
| 4090 return YES; | 4002 return YES; |
| 4091 return [super isOpaque]; | 4003 return [super isOpaque]; |
| 4092 } | 4004 } |
| 4093 | 4005 |
| 4094 @end | 4006 @end |
| OLD | NEW |