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

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

Issue 3067026: Initial port of accelerated compositor to Mac OS X 10.6. Reused... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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) 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/surface/io_surface_support_mac.h" 9 #include "app/surface/io_surface_support_mac.h"
10 #import "base/chrome_application_mac.h" 10 #import "base/chrome_application_mac.h"
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 void RenderWidgetHostViewMac::KillSelf() { 606 void RenderWidgetHostViewMac::KillSelf() {
607 if (shutdown_factory_.empty()) { 607 if (shutdown_factory_.empty()) {
608 [cocoa_view_ setHidden:YES]; 608 [cocoa_view_ setHidden:YES];
609 MessageLoop::current()->PostTask(FROM_HERE, 609 MessageLoop::current()->PostTask(FROM_HERE,
610 shutdown_factory_.NewRunnableMethod( 610 shutdown_factory_.NewRunnableMethod(
611 &RenderWidgetHostViewMac::ShutdownHost)); 611 &RenderWidgetHostViewMac::ShutdownHost));
612 } 612 }
613 } 613 }
614 614
615 gfx::PluginWindowHandle 615 gfx::PluginWindowHandle
616 RenderWidgetHostViewMac::AllocateFakePluginWindowHandle(bool opaque) { 616 RenderWidgetHostViewMac::AllocateFakePluginWindowHandle(bool opaque,
617 bool root) {
617 // Make sure we have a layer for the plugin to draw into. 618 // Make sure we have a layer for the plugin to draw into.
618 [cocoa_view_ ensureAcceleratedPluginLayer]; 619 [cocoa_view_ ensureAcceleratedPluginLayer];
619 620
620 return plugin_container_manager_.AllocateFakePluginWindowHandle(opaque); 621 return plugin_container_manager_.AllocateFakePluginWindowHandle(opaque, root);
621 } 622 }
622 623
623 void RenderWidgetHostViewMac::DestroyFakePluginWindowHandle( 624 void RenderWidgetHostViewMac::DestroyFakePluginWindowHandle(
624 gfx::PluginWindowHandle window) { 625 gfx::PluginWindowHandle window) {
625 plugin_container_manager_.DestroyFakePluginWindowHandle(window); 626 plugin_container_manager_.DestroyFakePluginWindowHandle(window);
626 } 627 }
627 628
628 void RenderWidgetHostViewMac::AcceleratedSurfaceSetIOSurface( 629 void RenderWidgetHostViewMac::AcceleratedSurfaceSetIOSurface(
629 gfx::PluginWindowHandle window, 630 gfx::PluginWindowHandle window,
630 int32 width, 631 int32 width,
(...skipping 12 matching lines...) Expand all
643 TransportDIB::Handle transport_dib) { 644 TransportDIB::Handle transport_dib) {
644 plugin_container_manager_.SetSizeAndTransportDIB(window, 645 plugin_container_manager_.SetSizeAndTransportDIB(window,
645 width, 646 width,
646 height, 647 height,
647 transport_dib); 648 transport_dib);
648 } 649 }
649 650
650 void RenderWidgetHostViewMac::AcceleratedSurfaceBuffersSwapped( 651 void RenderWidgetHostViewMac::AcceleratedSurfaceBuffersSwapped(
651 gfx::PluginWindowHandle window) { 652 gfx::PluginWindowHandle window) {
652 [cocoa_view_ drawAcceleratedPluginLayer]; 653 [cocoa_view_ drawAcceleratedPluginLayer];
654 if (GetRenderWidgetHost()->is_gpu_rendering_active()) {
655 // Additionally dirty the entire region of the view to make AppKit
656 // and Core Animation think that our CALayer needs to repaint
657 // itself.
658 [cocoa_view_ setNeedsDisplayInRect:[cocoa_view_ frame]];
659 }
653 } 660 }
654 661
655 void RenderWidgetHostViewMac::DrawAcceleratedSurfaceInstances( 662 void RenderWidgetHostViewMac::DrawAcceleratedSurfaceInstances(
656 CGLContextObj context) { 663 CGLContextObj context) {
657 CGLSetCurrentContext(context); 664 CGLSetCurrentContext(context);
658 gfx::Rect rect = GetWindowRect(); 665 gfx::Rect rect = GetWindowRect();
659 glMatrixMode(GL_PROJECTION); 666 glMatrixMode(GL_PROJECTION);
660 glLoadIdentity(); 667 glLoadIdentity();
661 // Note that we place the origin at the upper left corner with +y 668 // Note that we place the origin at the upper left corner with +y
662 // going down 669 // going down
663 glOrtho(0, rect.width(), rect.height(), 0, -1, 1); 670 glOrtho(0, rect.width(), rect.height(), 0, -1, 1);
664 glMatrixMode(GL_MODELVIEW); 671 glMatrixMode(GL_MODELVIEW);
665 glLoadIdentity(); 672 glLoadIdentity();
666 673
667 plugin_container_manager_.Draw(context); 674 plugin_container_manager_.Draw(
675 context, GetRenderWidgetHost()->is_gpu_rendering_active());
668 } 676 }
669 677
670 void RenderWidgetHostViewMac::AcceleratedSurfaceContextChanged() { 678 void RenderWidgetHostViewMac::AcceleratedSurfaceContextChanged() {
671 plugin_container_manager_.ForceTextureReload(); 679 plugin_container_manager_.ForceTextureReload();
672 } 680 }
673 681
674 void RenderWidgetHostViewMac::SetVisuallyDeemphasized(bool deemphasized) { 682 void RenderWidgetHostViewMac::SetVisuallyDeemphasized(bool deemphasized) {
675 // Mac uses tab-modal sheets, so this is a no-op. 683 // Mac uses tab-modal sheets, so this is a no-op.
676 } 684 }
677 685
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 } 1166 }
1159 1167
1160 - (void)drawRect:(NSRect)dirtyRect { 1168 - (void)drawRect:(NSRect)dirtyRect {
1161 if (!renderWidgetHostView_->render_widget_host_) { 1169 if (!renderWidgetHostView_->render_widget_host_) {
1162 // TODO(shess): Consider using something more noticable? 1170 // TODO(shess): Consider using something more noticable?
1163 [[NSColor whiteColor] set]; 1171 [[NSColor whiteColor] set];
1164 NSRectFill(dirtyRect); 1172 NSRectFill(dirtyRect);
1165 return; 1173 return;
1166 } 1174 }
1167 1175
1176 if (renderWidgetHostView_->render_widget_host_->is_gpu_rendering_active()) {
1177 // In this mode the accelerated plugin layer is considered to be
1178 // opaque. We do not want its contents to be blended with anything
1179 // underneath it.
1180 acceleratedPluginLayer_.get().opaque = YES;
1181 [acceleratedPluginLayer_.get() setNeedsDisplay];
1182 return;
1183 }
1184
1168 DCHECK( 1185 DCHECK(
1169 renderWidgetHostView_->render_widget_host_->process()->HasConnection()); 1186 renderWidgetHostView_->render_widget_host_->process()->HasConnection());
1170 DCHECK(!renderWidgetHostView_->about_to_validate_and_paint_); 1187 DCHECK(!renderWidgetHostView_->about_to_validate_and_paint_);
1171 1188
1172 renderWidgetHostView_->about_to_validate_and_paint_ = true; 1189 renderWidgetHostView_->about_to_validate_and_paint_ = true;
1173 BackingStoreMac* backing_store = static_cast<BackingStoreMac*>( 1190 BackingStoreMac* backing_store = static_cast<BackingStoreMac*>(
1174 renderWidgetHostView_->render_widget_host_->GetBackingStore(true)); 1191 renderWidgetHostView_->render_widget_host_->GetBackingStore(true));
1175 renderWidgetHostView_->about_to_validate_and_paint_ = false; 1192 renderWidgetHostView_->about_to_validate_and_paint_ = false;
1176 1193
1177 if (backing_store) { 1194 if (backing_store) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 // recorded. 1289 // recorded.
1273 renderWidgetHostView_->tab_switch_paint_time_ = base::TimeTicks(); 1290 renderWidgetHostView_->tab_switch_paint_time_ = base::TimeTicks();
1274 } 1291 }
1275 } else { 1292 } else {
1276 [[NSColor whiteColor] set]; 1293 [[NSColor whiteColor] set];
1277 NSRectFill(dirtyRect); 1294 NSRectFill(dirtyRect);
1278 if (renderWidgetHostView_->whiteout_start_time_.is_null()) 1295 if (renderWidgetHostView_->whiteout_start_time_.is_null())
1279 renderWidgetHostView_->whiteout_start_time_ = base::TimeTicks::Now(); 1296 renderWidgetHostView_->whiteout_start_time_ = base::TimeTicks::Now();
1280 } 1297 }
1281 1298
1299 // If we get here then the accelerated plugin layer is not supposed
1300 // to be considered opaque -- plugins overlay the browser's normal
1301 // painting.
1302 acceleratedPluginLayer_.get().opaque = NO;
1303
1282 // This helps keep accelerated plugins' output in better sync with the 1304 // This helps keep accelerated plugins' output in better sync with the
1283 // window as it resizes. 1305 // window as it resizes.
1284 [acceleratedPluginLayer_.get() setNeedsDisplay]; 1306 [acceleratedPluginLayer_.get() setNeedsDisplay];
1285 } 1307 }
1286 1308
1287 - (BOOL)canBecomeKeyView { 1309 - (BOOL)canBecomeKeyView {
1288 if (!renderWidgetHostView_->render_widget_host_) 1310 if (!renderWidgetHostView_->render_widget_host_)
1289 return NO; 1311 return NO;
1290 1312
1291 return canBeKeyView_; 1313 return canBeKeyView_;
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
2097 renderWidgetHostView_->render_widget_host_->ImeConfirmComposition(); 2119 renderWidgetHostView_->render_widget_host_->ImeConfirmComposition();
2098 2120
2099 [self cancelComposition]; 2121 [self cancelComposition];
2100 } 2122 }
2101 2123
2102 - (ViewID)viewID { 2124 - (ViewID)viewID {
2103 return VIEW_ID_TAB_CONTAINER_FOCUS_VIEW; 2125 return VIEW_ID_TAB_CONTAINER_FOCUS_VIEW;
2104 } 2126 }
2105 2127
2106 @end 2128 @end
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/render_widget_host_view_mac.h ('k') | chrome/browser/renderer_host/test/test_render_view_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698