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 <OpenGL/gl.h> | 8 #include <OpenGL/gl.h> |
9 #include <QuartzCore/QuartzCore.h> | 9 #include <QuartzCore/QuartzCore.h> |
10 | 10 |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget) | 500 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget) |
501 : render_widget_host_(RenderWidgetHostImpl::From(widget)), | 501 : render_widget_host_(RenderWidgetHostImpl::From(widget)), |
502 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 502 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
503 can_compose_inline_(true), | 503 can_compose_inline_(true), |
504 browser_compositor_has_pending_paint_(false), | 504 browser_compositor_has_pending_paint_(false), |
505 browser_compositor_view_placeholder_( | 505 browser_compositor_view_placeholder_( |
506 new BrowserCompositorViewPlaceholderMac), | 506 new BrowserCompositorViewPlaceholderMac), |
507 backing_store_scale_factor_(1), | 507 backing_store_scale_factor_(1), |
508 is_loading_(false), | 508 is_loading_(false), |
509 is_paused_for_resize_or_repaint_(false), | 509 is_paused_for_resize_or_repaint_(false), |
| 510 allow_pause_for_resize_or_repaint_(true), |
510 weak_factory_(this), | 511 weak_factory_(this), |
511 fullscreen_parent_host_view_(NULL), | 512 fullscreen_parent_host_view_(NULL), |
512 overlay_view_weak_factory_(this), | |
513 software_frame_weak_ptr_factory_(this) { | 513 software_frame_weak_ptr_factory_(this) { |
514 software_frame_manager_.reset(new SoftwareFrameManager( | 514 software_frame_manager_.reset(new SoftwareFrameManager( |
515 software_frame_weak_ptr_factory_.GetWeakPtr())); | 515 software_frame_weak_ptr_factory_.GetWeakPtr())); |
516 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| | 516 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| |
517 // goes away. Since we autorelease it, our caller must put | 517 // goes away. Since we autorelease it, our caller must put |
518 // |GetNativeView()| into the view hierarchy right after calling us. | 518 // |GetNativeView()| into the view hierarchy right after calling us. |
519 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] | 519 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] |
520 initWithRenderWidgetHostViewMac:this] autorelease]; | 520 initWithRenderWidgetHostViewMac:this] autorelease]; |
521 | 521 |
522 background_layer_.reset([[CALayer alloc] init]); | 522 background_layer_.reset([[CALayer alloc] init]); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 | 555 |
556 void RenderWidgetHostViewMac::SetDelegate( | 556 void RenderWidgetHostViewMac::SetDelegate( |
557 NSObject<RenderWidgetHostViewMacDelegate>* delegate) { | 557 NSObject<RenderWidgetHostViewMacDelegate>* delegate) { |
558 [cocoa_view_ setResponderDelegate:delegate]; | 558 [cocoa_view_ setResponderDelegate:delegate]; |
559 } | 559 } |
560 | 560 |
561 void RenderWidgetHostViewMac::SetAllowOverlappingViews(bool overlapping) { | 561 void RenderWidgetHostViewMac::SetAllowOverlappingViews(bool overlapping) { |
562 // TODO(ccameron): Remove callers of this function. | 562 // TODO(ccameron): Remove callers of this function. |
563 } | 563 } |
564 | 564 |
| 565 void RenderWidgetHostViewMac::SetAllowPauseForResizeOrRepaint(bool allow) { |
| 566 allow_pause_for_resize_or_repaint_ = allow; |
| 567 } |
| 568 |
565 /////////////////////////////////////////////////////////////////////////////// | 569 /////////////////////////////////////////////////////////////////////////////// |
566 // RenderWidgetHostViewMac, RenderWidgetHostView implementation: | 570 // RenderWidgetHostViewMac, RenderWidgetHostView implementation: |
567 | 571 |
568 bool RenderWidgetHostViewMac::EnsureCompositedIOSurface() { | 572 bool RenderWidgetHostViewMac::EnsureCompositedIOSurface() { |
569 // If the context or the IOSurface's context has had an error, re-build | 573 // If the context or the IOSurface's context has had an error, re-build |
570 // everything from scratch. | 574 // everything from scratch. |
571 if (compositing_iosurface_context_ && | 575 if (compositing_iosurface_context_ && |
572 compositing_iosurface_context_->HasBeenPoisoned()) { | 576 compositing_iosurface_context_->HasBeenPoisoned()) { |
573 LOG(ERROR) << "Failing EnsureCompositedIOSurface because " | 577 LOG(ERROR) << "Failing EnsureCompositedIOSurface because " |
574 << "context was poisoned"; | 578 << "context was poisoned"; |
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1585 // Request that a new frame be generated and dirty the view. | 1589 // Request that a new frame be generated and dirty the view. |
1586 if (render_widget_host_) | 1590 if (render_widget_host_) |
1587 render_widget_host_->ScheduleComposite(); | 1591 render_widget_host_->ScheduleComposite(); |
1588 [cocoa_view_ setNeedsDisplay:YES]; | 1592 [cocoa_view_ setNeedsDisplay:YES]; |
1589 | 1593 |
1590 // TODO(ccameron): It may be a good idea to request that the renderer recreate | 1594 // TODO(ccameron): It may be a good idea to request that the renderer recreate |
1591 // its GL context as well, and fall back to software if this happens | 1595 // its GL context as well, and fall back to software if this happens |
1592 // repeatedly. | 1596 // repeatedly. |
1593 } | 1597 } |
1594 | 1598 |
1595 void RenderWidgetHostViewMac::SetOverlayView( | |
1596 RenderWidgetHostViewMac* overlay, const gfx::Point& offset) { | |
1597 if (overlay_view_) | |
1598 overlay_view_->underlay_view_.reset(); | |
1599 | |
1600 overlay_view_ = overlay->overlay_view_weak_factory_.GetWeakPtr(); | |
1601 overlay_view_->underlay_view_ = overlay_view_weak_factory_.GetWeakPtr(); | |
1602 } | |
1603 | |
1604 void RenderWidgetHostViewMac::RemoveOverlayView() { | |
1605 if (overlay_view_) { | |
1606 overlay_view_->underlay_view_.reset(); | |
1607 overlay_view_.reset(); | |
1608 } | |
1609 } | |
1610 | |
1611 bool RenderWidgetHostViewMac::GetLineBreakIndex( | 1599 bool RenderWidgetHostViewMac::GetLineBreakIndex( |
1612 const std::vector<gfx::Rect>& bounds, | 1600 const std::vector<gfx::Rect>& bounds, |
1613 const gfx::Range& range, | 1601 const gfx::Range& range, |
1614 size_t* line_break_point) { | 1602 size_t* line_break_point) { |
1615 DCHECK(line_break_point); | 1603 DCHECK(line_break_point); |
1616 if (range.start() >= bounds.size() || range.is_reversed() || range.is_empty()) | 1604 if (range.start() >= bounds.size() || range.is_reversed() || range.is_empty()) |
1617 return false; | 1605 return false; |
1618 | 1606 |
1619 // We can't check line breaking completely from only rectangle array. Thus we | 1607 // We can't check line breaking completely from only rectangle array. Thus we |
1620 // assume the line breaking as the next character's y offset is larger than | 1608 // assume the line breaking as the next character's y offset is larger than |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2212 RenderWidgetHostImpl::AcknowledgeBufferPresent(pending_swap_ack_->route_id, | 2200 RenderWidgetHostImpl::AcknowledgeBufferPresent(pending_swap_ack_->route_id, |
2213 pending_swap_ack_->gpu_host_id, | 2201 pending_swap_ack_->gpu_host_id, |
2214 ack_params); | 2202 ack_params); |
2215 pending_swap_ack_.reset(); | 2203 pending_swap_ack_.reset(); |
2216 } | 2204 } |
2217 | 2205 |
2218 void RenderWidgetHostViewMac::PauseForPendingResizeOrRepaintsAndDraw() { | 2206 void RenderWidgetHostViewMac::PauseForPendingResizeOrRepaintsAndDraw() { |
2219 if (!render_widget_host_ || render_widget_host_->is_hidden()) | 2207 if (!render_widget_host_ || render_widget_host_->is_hidden()) |
2220 return; | 2208 return; |
2221 | 2209 |
2222 // Pausing for the overlay/underlay view prevents the other one from receiving | 2210 // Pausing for one view prevents others from receiving frames. |
2223 // frames. This may lead to large delays, causing overlaps. | 2211 // This may lead to large delays, causing overlaps. See crbug.com/352020. |
2224 // See crbug.com/352020. | 2212 if (!allow_pause_for_resize_or_repaint_) |
2225 if (underlay_view_ || overlay_view_) | |
2226 return; | 2213 return; |
2227 | 2214 |
2228 // Ensure that all frames are acked before waiting for a frame to come in. | 2215 // Ensure that all frames are acked before waiting for a frame to come in. |
2229 // Note that we will draw a frame at the end of this function, so it is safe | 2216 // Note that we will draw a frame at the end of this function, so it is safe |
2230 // to ack a never-drawn frame here. | 2217 // to ack a never-drawn frame here. |
2231 SendPendingSwapAck(); | 2218 SendPendingSwapAck(); |
2232 | 2219 |
2233 // Wait for a frame of the right size to come in. | 2220 // Wait for a frame of the right size to come in. |
2234 is_paused_for_resize_or_repaint_ = true; | 2221 is_paused_for_resize_or_repaint_ = true; |
2235 render_widget_host_->PauseForPendingResizeOrRepaints(); | 2222 render_widget_host_->PauseForPendingResizeOrRepaints(); |
(...skipping 1745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3981 | 3968 |
3982 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3969 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
3983 // regions that are not draggable. (See ControlRegionView in | 3970 // regions that are not draggable. (See ControlRegionView in |
3984 // native_app_window_cocoa.mm). This requires the render host view to be | 3971 // native_app_window_cocoa.mm). This requires the render host view to be |
3985 // draggable by default. | 3972 // draggable by default. |
3986 - (BOOL)mouseDownCanMoveWindow { | 3973 - (BOOL)mouseDownCanMoveWindow { |
3987 return YES; | 3974 return YES; |
3988 } | 3975 } |
3989 | 3976 |
3990 @end | 3977 @end |
OLD | NEW |