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

Side by Side Diff: chrome/browser/renderer_host/render_widget_host_view_mac.mm

Issue 4815001: Use inner HWND for accelerated rendering on windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <QuartzCore/QuartzCore.h> 5 #include <QuartzCore/QuartzCore.h>
6 6
7 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" 7 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h"
8 8
9 #include "app/app_switches.h" 9 #include "app/app_switches.h"
10 #include "app/surface/io_surface_support_mac.h" 10 #include "app/surface/io_surface_support_mac.h"
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 void RenderWidgetHostViewMac::ImeCancelComposition() { 683 void RenderWidgetHostViewMac::ImeCancelComposition() {
684 [cocoa_view_ cancelComposition]; 684 [cocoa_view_ cancelComposition];
685 } 685 }
686 686
687 void RenderWidgetHostViewMac::DidUpdateBackingStore( 687 void RenderWidgetHostViewMac::DidUpdateBackingStore(
688 const gfx::Rect& scroll_rect, int scroll_dx, int scroll_dy, 688 const gfx::Rect& scroll_rect, int scroll_dx, int scroll_dy,
689 const std::vector<gfx::Rect>& copy_rects) { 689 const std::vector<gfx::Rect>& copy_rects) {
690 if (!is_hidden_) { 690 if (!is_hidden_) {
691 std::vector<gfx::Rect> rects(copy_rects); 691 std::vector<gfx::Rect> rects(copy_rects);
692 692
693 // Because the findbar might be open, we cannot use scrollRect:by: here. Fo r 693 // Because the findbar might be open, we cannot use scrollRect:by: here. For
694 // now, simply mark all of scroll rect as dirty. 694 // now, simply mark all of scroll rect as dirty.
695 if (!scroll_rect.IsEmpty()) 695 if (!scroll_rect.IsEmpty())
696 rects.push_back(scroll_rect); 696 rects.push_back(scroll_rect);
697 697
698 for (size_t i = 0; i < rects.size(); ++i) { 698 for (size_t i = 0; i < rects.size(); ++i) {
699 NSRect ns_rect = [cocoa_view_ flipRectToNSRect:rects[i]]; 699 NSRect ns_rect = [cocoa_view_ flipRectToNSRect:rects[i]];
700 700
701 if (about_to_validate_and_paint_) { 701 if (about_to_validate_and_paint_) {
702 // As much as we'd like to use -setNeedsDisplayInRect: here, we can't. 702 // As much as we'd like to use -setNeedsDisplayInRect: here, we can't.
703 // We're in the middle of executing a -drawRect:, and as soon as it 703 // We're in the middle of executing a -drawRect:, and as soon as it
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 if (plugin_container_manager_.SurfaceShouldBeVisible(window)) 943 if (plugin_container_manager_.SurfaceShouldBeVisible(window))
944 [view setHidden:NO]; 944 [view setHidden:NO];
945 [view setSurfaceWasSwapped:YES]; 945 [view setSurfaceWasSwapped:YES];
946 } 946 }
947 947
948 void RenderWidgetHostViewMac::UpdateRootGpuViewVisibility( 948 void RenderWidgetHostViewMac::UpdateRootGpuViewVisibility(
949 bool show_gpu_widget) { 949 bool show_gpu_widget) {
950 // Plugins are destroyed on page navigate. The compositor layer on the other 950 // Plugins are destroyed on page navigate. The compositor layer on the other
951 // hand is created on demand and then stays alive until its renderer process 951 // hand is created on demand and then stays alive until its renderer process
952 // dies (usually on cross-domain navigation). Instead, only a flag 952 // dies (usually on cross-domain navigation). Instead, only a flag
953 // |is_gpu_rendering_active()| is flipped when the compositor output should be 953 // |is_accelerated_compositing_active()| is flipped when the compositor output
954 // shown/hidden. 954 // should be shown/hidden.
955 // Show/hide the view belonging to the compositor here. 955 // Show/hide the view belonging to the compositor here.
956 plugin_container_manager_.set_gpu_rendering_active(show_gpu_widget); 956 plugin_container_manager_.set_gpu_rendering_active(show_gpu_widget);
957 957
958 gfx::PluginWindowHandle root_handle = 958 gfx::PluginWindowHandle root_handle =
959 plugin_container_manager_.root_container_handle(); 959 plugin_container_manager_.root_container_handle();
960 if (root_handle != gfx::kNullPluginWindow) { 960 if (root_handle != gfx::kNullPluginWindow) {
961 PluginViewMap::iterator it = plugin_views_.find(root_handle); 961 PluginViewMap::iterator it = plugin_views_.find(root_handle);
962 DCHECK(plugin_views_.end() != it); 962 DCHECK(plugin_views_.end() != it);
963 if (plugin_views_.end() == it) { 963 if (plugin_views_.end() == it) {
964 return; 964 return;
965 } 965 }
966 bool visible = 966 bool visible =
967 plugin_container_manager_.SurfaceShouldBeVisible(root_handle); 967 plugin_container_manager_.SurfaceShouldBeVisible(root_handle);
968 [[it->second window] disableScreenUpdatesUntilFlush]; 968 [[it->second window] disableScreenUpdatesUntilFlush];
969 [it->second setHidden:!visible]; 969 [it->second setHidden:!visible];
970 } 970 }
971 } 971 }
972 972
973 void RenderWidgetHostViewMac::HandleDelayedGpuViewHiding() { 973 void RenderWidgetHostViewMac::HandleDelayedGpuViewHiding() {
974 if (needs_gpu_visibility_update_after_repaint_) { 974 if (needs_gpu_visibility_update_after_repaint_) {
975 UpdateRootGpuViewVisibility(false); 975 UpdateRootGpuViewVisibility(false);
976 needs_gpu_visibility_update_after_repaint_ = false; 976 needs_gpu_visibility_update_after_repaint_ = false;
977 } 977 }
978 } 978 }
979 979
980 void RenderWidgetHostViewMac::GpuRenderingStateDidChange() { 980 void RenderWidgetHostViewMac::GpuRenderingStateDidChange() {
981 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 981 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
982 if (GetRenderWidgetHost()->is_gpu_rendering_active()) { 982 if (GetRenderWidgetHost()->is_accelerated_compositing_active()) {
983 UpdateRootGpuViewVisibility( 983 UpdateRootGpuViewVisibility(
984 GetRenderWidgetHost()->is_gpu_rendering_active()); 984 GetRenderWidgetHost()->is_accelerated_compositing_active());
985 } else { 985 } else {
986 needs_gpu_visibility_update_after_repaint_ = true; 986 needs_gpu_visibility_update_after_repaint_ = true;
987 } 987 }
988 } 988 }
989 989
990 void RenderWidgetHostViewMac::DrawAcceleratedSurfaceInstance( 990 void RenderWidgetHostViewMac::DrawAcceleratedSurfaceInstance(
991 CGLContextObj context, 991 CGLContextObj context,
992 gfx::PluginWindowHandle plugin_handle, 992 gfx::PluginWindowHandle plugin_handle,
993 NSSize size) { 993 NSSize size) {
994 // Called on the display link thread. 994 // Called on the display link thread.
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 - (void)drawRect:(NSRect)dirtyRect { 1572 - (void)drawRect:(NSRect)dirtyRect {
1573 if (!renderWidgetHostView_->render_widget_host_) { 1573 if (!renderWidgetHostView_->render_widget_host_) {
1574 // TODO(shess): Consider using something more noticable? 1574 // TODO(shess): Consider using something more noticable?
1575 [[NSColor whiteColor] set]; 1575 [[NSColor whiteColor] set];
1576 NSRectFill(dirtyRect); 1576 NSRectFill(dirtyRect);
1577 return; 1577 return;
1578 } 1578 }
1579 1579
1580 const gfx::Rect damagedRect([self flipNSRectToRect:dirtyRect]); 1580 const gfx::Rect damagedRect([self flipNSRectToRect:dirtyRect]);
1581 1581
1582 if (renderWidgetHostView_->render_widget_host_->is_gpu_rendering_active()) { 1582 if (renderWidgetHostView_->render_widget_host_->
1583 is_accelerated_compositing_active()) {
1583 gfx::Rect gpuRect; 1584 gfx::Rect gpuRect;
1584 1585
1585 gfx::PluginWindowHandle root_handle = 1586 gfx::PluginWindowHandle root_handle =
1586 renderWidgetHostView_->plugin_container_manager_.root_container_handle(); 1587 renderWidgetHostView_->plugin_container_manager_.root_container_handle();
1587 if (root_handle != gfx::kNullPluginWindow) { 1588 if (root_handle != gfx::kNullPluginWindow) {
1588 RenderWidgetHostViewMac::PluginViewMap::iterator it = 1589 RenderWidgetHostViewMac::PluginViewMap::iterator it =
1589 renderWidgetHostView_->plugin_views_.find(root_handle); 1590 renderWidgetHostView_->plugin_views_.find(root_handle);
1590 DCHECK(it != renderWidgetHostView_->plugin_views_.end()); 1591 DCHECK(it != renderWidgetHostView_->plugin_views_.end());
1591 if (it != renderWidgetHostView_->plugin_views_.end() && 1592 if (it != renderWidgetHostView_->plugin_views_.end() &&
1592 ![it->second isHidden]) { 1593 ![it->second isHidden]) {
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after
2568 if (!string) return NO; 2569 if (!string) return NO;
2569 2570
2570 // If the user is currently using an IME, confirm the IME input, 2571 // If the user is currently using an IME, confirm the IME input,
2571 // and then insert the text from the service, the same as TextEdit and Safari. 2572 // and then insert the text from the service, the same as TextEdit and Safari.
2572 [self confirmComposition]; 2573 [self confirmComposition];
2573 [self insertText:string]; 2574 [self insertText:string];
2574 return YES; 2575 return YES;
2575 } 2576 }
2576 2577
2577 @end 2578 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698