OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include <QuartzCore/QuartzCore.h> | 7 #include <QuartzCore/QuartzCore.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 *results = WebKit::WebScreenInfoFactory::screenInfo(NULL); | 219 *results = WebKit::WebScreenInfoFactory::screenInfo(NULL); |
220 } | 220 } |
221 | 221 |
222 /////////////////////////////////////////////////////////////////////////////// | 222 /////////////////////////////////////////////////////////////////////////////// |
223 // RenderWidgetHostViewMac, public: | 223 // RenderWidgetHostViewMac, public: |
224 | 224 |
225 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget) | 225 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget) |
226 : render_widget_host_(widget), | 226 : render_widget_host_(widget), |
227 about_to_validate_and_paint_(false), | 227 about_to_validate_and_paint_(false), |
228 call_set_needs_display_in_rect_pending_(false), | 228 call_set_needs_display_in_rect_pending_(false), |
| 229 last_frame_was_accelerated_(false), |
229 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 230 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
230 is_loading_(false), | 231 is_loading_(false), |
231 is_hidden_(false), | 232 is_hidden_(false), |
232 is_showing_context_menu_(false), | 233 is_showing_context_menu_(false), |
233 weak_factory_(this), | 234 weak_factory_(this), |
234 accelerated_compositing_active_(false), | 235 accelerated_compositing_active_(false), |
235 needs_gpu_visibility_update_after_repaint_(false), | 236 needs_gpu_visibility_update_after_repaint_(false), |
236 compositing_surface_(gfx::kNullPluginWindow) { | 237 compositing_surface_(gfx::kNullPluginWindow) { |
237 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| goes away. | 238 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| goes away. |
238 // Since we autorelease it, our caller must put |native_view()| into the view | 239 // Since we autorelease it, our caller must put |native_view()| into the view |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 void RenderWidgetHostViewMac::ImeCompositionRangeChanged( | 532 void RenderWidgetHostViewMac::ImeCompositionRangeChanged( |
532 const ui::Range& range) { | 533 const ui::Range& range) { |
533 // The RangeChanged message is only sent with valid values. The current | 534 // The RangeChanged message is only sent with valid values. The current |
534 // caret position (start == end) will be sent if there is no IME range. | 535 // caret position (start == end) will be sent if there is no IME range. |
535 [cocoa_view_ setMarkedRange:range.ToNSRange()]; | 536 [cocoa_view_ setMarkedRange:range.ToNSRange()]; |
536 } | 537 } |
537 | 538 |
538 void RenderWidgetHostViewMac::DidUpdateBackingStore( | 539 void RenderWidgetHostViewMac::DidUpdateBackingStore( |
539 const gfx::Rect& scroll_rect, int scroll_dx, int scroll_dy, | 540 const gfx::Rect& scroll_rect, int scroll_dx, int scroll_dy, |
540 const std::vector<gfx::Rect>& copy_rects) { | 541 const std::vector<gfx::Rect>& copy_rects) { |
| 542 last_frame_was_accelerated_ = false; |
| 543 |
541 if (!is_hidden_) { | 544 if (!is_hidden_) { |
542 std::vector<gfx::Rect> rects(copy_rects); | 545 std::vector<gfx::Rect> rects(copy_rects); |
543 | 546 |
544 // Because the findbar might be open, we cannot use scrollRect:by: here. For | 547 // Because the findbar might be open, we cannot use scrollRect:by: here. For |
545 // now, simply mark all of scroll rect as dirty. | 548 // now, simply mark all of scroll rect as dirty. |
546 if (!scroll_rect.IsEmpty()) | 549 if (!scroll_rect.IsEmpty()) |
547 rects.push_back(scroll_rect); | 550 rects.push_back(scroll_rect); |
548 | 551 |
549 for (size_t i = 0; i < rects.size(); ++i) { | 552 for (size_t i = 0; i < rects.size(); ++i) { |
550 NSRect ns_rect = [cocoa_view_ flipRectToNSRect:rects[i]]; | 553 NSRect ns_rect = [cocoa_view_ flipRectToNSRect:rects[i]]; |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 uint64 surface_id, | 872 uint64 surface_id, |
870 int renderer_id, | 873 int renderer_id, |
871 int32 route_id, | 874 int32 route_id, |
872 int gpu_host_id) { | 875 int gpu_host_id) { |
873 TRACE_EVENT0("browser", | 876 TRACE_EVENT0("browser", |
874 "RenderWidgetHostViewMac::AcceleratedSurfaceBuffersSwapped"); | 877 "RenderWidgetHostViewMac::AcceleratedSurfaceBuffersSwapped"); |
875 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 878 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
876 AcceleratedPluginView* view = ViewForPluginWindowHandle(window); | 879 AcceleratedPluginView* view = ViewForPluginWindowHandle(window); |
877 DCHECK(view); | 880 DCHECK(view); |
878 if (view) { | 881 if (view) { |
| 882 last_frame_was_accelerated_ = true; |
879 plugin_container_manager_.SetSurfaceWasPaintedTo(window, surface_id); | 883 plugin_container_manager_.SetSurfaceWasPaintedTo(window, surface_id); |
880 | 884 |
881 // The surface is hidden until its first paint, to not show gargabe. | 885 // The surface is hidden until its first paint, to not show gargabe. |
882 if (plugin_container_manager_.SurfaceShouldBeVisible(window)) | 886 if (plugin_container_manager_.SurfaceShouldBeVisible(window)) |
883 [view setHidden:NO]; | 887 [view setHidden:NO]; |
884 [view drawView]; | 888 [view drawView]; |
885 } | 889 } |
886 | 890 |
887 if (renderer_id != 0 || route_id != 0) { | 891 if (renderer_id != 0 || route_id != 0) { |
888 AcknowledgeSwapBuffers(renderer_id, | 892 AcknowledgeSwapBuffers(renderer_id, |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1731 - (void)drawRect:(NSRect)dirtyRect { | 1735 - (void)drawRect:(NSRect)dirtyRect { |
1732 if (!renderWidgetHostView_->render_widget_host_) { | 1736 if (!renderWidgetHostView_->render_widget_host_) { |
1733 // TODO(shess): Consider using something more noticable? | 1737 // TODO(shess): Consider using something more noticable? |
1734 [[NSColor whiteColor] set]; | 1738 [[NSColor whiteColor] set]; |
1735 NSRectFill(dirtyRect); | 1739 NSRectFill(dirtyRect); |
1736 return; | 1740 return; |
1737 } | 1741 } |
1738 | 1742 |
1739 const gfx::Rect damagedRect([self flipNSRectToRect:dirtyRect]); | 1743 const gfx::Rect damagedRect([self flipNSRectToRect:dirtyRect]); |
1740 | 1744 |
1741 if (renderWidgetHostView_->render_widget_host_-> | 1745 if (renderWidgetHostView_->last_frame_was_accelerated_) { |
1742 is_accelerated_compositing_active()) { | |
1743 gfx::Rect gpuRect; | 1746 gfx::Rect gpuRect; |
1744 | 1747 |
1745 gfx::PluginWindowHandle root_handle = | 1748 gfx::PluginWindowHandle root_handle = |
1746 renderWidgetHostView_->plugin_container_manager_.root_container_handle(); | 1749 renderWidgetHostView_->plugin_container_manager_.root_container_handle(); |
1747 if (root_handle != gfx::kNullPluginWindow) { | 1750 if (root_handle != gfx::kNullPluginWindow) { |
1748 AcceleratedPluginView* view = | 1751 AcceleratedPluginView* view = |
1749 renderWidgetHostView_->ViewForPluginWindowHandle(root_handle); | 1752 renderWidgetHostView_->ViewForPluginWindowHandle(root_handle); |
1750 DCHECK(view); | 1753 DCHECK(view); |
1751 if (view && ![view isHidden]) { | 1754 if (view && ![view isHidden]) { |
1752 gpuRect = [self flipNSRectToRect:[view frame]]; | 1755 gpuRect = [self flipNSRectToRect:[view frame]]; |
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2745 if (!string) return NO; | 2748 if (!string) return NO; |
2746 | 2749 |
2747 // If the user is currently using an IME, confirm the IME input, | 2750 // If the user is currently using an IME, confirm the IME input, |
2748 // and then insert the text from the service, the same as TextEdit and Safari. | 2751 // and then insert the text from the service, the same as TextEdit and Safari. |
2749 [self confirmComposition]; | 2752 [self confirmComposition]; |
2750 [self insertText:string]; | 2753 [self insertText:string]; |
2751 return YES; | 2754 return YES; |
2752 } | 2755 } |
2753 | 2756 |
2754 @end | 2757 @end |
OLD | NEW |