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

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

Issue 11418244: Order the GL overlays above windows if possible. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: oops, null check Created 8 years 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) 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 #include <QuartzCore/QuartzCore.h> 7 #include <QuartzCore/QuartzCore.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 /////////////////////////////////////////////////////////////////////////////// 282 ///////////////////////////////////////////////////////////////////////////////
283 // RenderWidgetHostViewMac, public: 283 // RenderWidgetHostViewMac, public:
284 284
285 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget) 285 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget)
286 : render_widget_host_(RenderWidgetHostImpl::From(widget)), 286 : render_widget_host_(RenderWidgetHostImpl::From(widget)),
287 about_to_validate_and_paint_(false), 287 about_to_validate_and_paint_(false),
288 call_set_needs_display_in_rect_pending_(false), 288 call_set_needs_display_in_rect_pending_(false),
289 last_frame_was_accelerated_(false), 289 last_frame_was_accelerated_(false),
290 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), 290 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
291 can_compose_inline_(true), 291 can_compose_inline_(true),
292 allow_overlapping_views_(false),
292 is_loading_(false), 293 is_loading_(false),
293 is_hidden_(false), 294 is_hidden_(false),
294 weak_factory_(this), 295 weak_factory_(this),
295 fullscreen_parent_host_view_(NULL) { 296 fullscreen_parent_host_view_(NULL) {
296 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| 297 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_|
297 // goes away. Since we autorelease it, our caller must put 298 // goes away. Since we autorelease it, our caller must put
298 // |GetNativeView()| into the view hierarchy right after calling us. 299 // |GetNativeView()| into the view hierarchy right after calling us.
299 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] 300 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc]
300 initWithRenderWidgetHostViewMac:this] autorelease]; 301 initWithRenderWidgetHostViewMac:this] autorelease];
301 render_widget_host_->SetView(this); 302 render_widget_host_->SetView(this);
302 } 303 }
303 304
304 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { 305 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() {
305 AckPendingSwapBuffers(); 306 AckPendingSwapBuffers();
306 UnlockMouse(); 307 UnlockMouse();
307 // We are owned by RenderWidgetHostViewCocoa, so if we go away before the 308 // We are owned by RenderWidgetHostViewCocoa, so if we go away before the
308 // RenderWidgetHost does we need to tell it not to hold a stale pointer to 309 // RenderWidgetHost does we need to tell it not to hold a stale pointer to
309 // us. 310 // us.
310 if (render_widget_host_) 311 if (render_widget_host_)
311 render_widget_host_->SetView(NULL); 312 render_widget_host_->SetView(NULL);
312 } 313 }
313 314
314 void RenderWidgetHostViewMac::SetDelegate( 315 void RenderWidgetHostViewMac::SetDelegate(
315 NSObject<RenderWidgetHostViewMacDelegate>* delegate) { 316 NSObject<RenderWidgetHostViewMacDelegate>* delegate) {
316 [cocoa_view_ setRWHVDelegate:delegate]; 317 [cocoa_view_ setRWHVDelegate:delegate];
317 } 318 }
318 319
320 void RenderWidgetHostViewMac::SetAllowOverlappingViews(bool overlapping) {
321 allow_overlapping_views_ = overlapping;
322 }
323
319 /////////////////////////////////////////////////////////////////////////////// 324 ///////////////////////////////////////////////////////////////////////////////
320 // RenderWidgetHostViewMac, RenderWidgetHostView implementation: 325 // RenderWidgetHostViewMac, RenderWidgetHostView implementation:
321 326
322 void RenderWidgetHostViewMac::InitAsChild( 327 void RenderWidgetHostViewMac::InitAsChild(
323 gfx::NativeView parent_view) { 328 gfx::NativeView parent_view) {
324 } 329 }
325 330
326 void RenderWidgetHostViewMac::InitAsPopup( 331 void RenderWidgetHostViewMac::InitAsPopup(
327 RenderWidgetHostView* parent_host_view, 332 RenderWidgetHostView* parent_host_view,
328 const gfx::Rect& pos) { 333 const gfx::Rect& pos) {
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 [NSString stringWithFormat:@"window %s delegate %s controller %s", 1044 [NSString stringWithFormat:@"window %s delegate %s controller %s",
1040 object_getClassName(window), 1045 object_getClassName(window),
1041 object_getClassName([window delegate]), 1046 object_getClassName([window delegate]),
1042 object_getClassName([window windowController])]; 1047 object_getClassName([window windowController])];
1043 base::mac::SetCrashKeyValue(kCrashKey, value); 1048 base::mac::SetCrashKeyValue(kCrashKey, value);
1044 } 1049 }
1045 1050
1046 return true; 1051 return true;
1047 } 1052 }
1048 1053
1049 if (!compositing_iosurface_.get()) 1054 if (!compositing_iosurface_.get()) {
1050 compositing_iosurface_.reset(CompositingIOSurfaceMac::Create()); 1055 CompositingIOSurfaceMac::SurfaceOrder order = allow_overlapping_views_ ?
1056 CompositingIOSurfaceMac::SURFACE_ORDER_BELOW_WINDOW :
1057 CompositingIOSurfaceMac::SURFACE_ORDER_ABOVE_WINDOW;
1058 compositing_iosurface_.reset(CompositingIOSurfaceMac::Create(order));
1059 }
1051 1060
1052 if (!compositing_iosurface_.get()) 1061 if (!compositing_iosurface_.get())
1053 return true; 1062 return true;
1054 1063
1055 compositing_iosurface_->SetIOSurface(surface_handle, size); 1064 compositing_iosurface_->SetIOSurface(surface_handle, size);
1056 1065
1057 GotAcceleratedFrame(); 1066 GotAcceleratedFrame();
1058 1067
1059 gfx::Size window_size(NSSizeToCGSize([cocoa_view_ frame].size)); 1068 gfx::Size window_size(NSSizeToCGSize([cocoa_view_ frame].size));
1060 if (window_size.IsEmpty()) { 1069 if (window_size.IsEmpty()) {
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after
2301 // blit the IOSurface below. 2310 // blit the IOSurface below.
2302 renderWidgetHostView_->about_to_validate_and_paint_ = true; 2311 renderWidgetHostView_->about_to_validate_and_paint_ = true;
2303 BackingStoreMac* backingStore = static_cast<BackingStoreMac*>( 2312 BackingStoreMac* backingStore = static_cast<BackingStoreMac*>(
2304 renderWidgetHostView_->render_widget_host_->GetBackingStore(true)); 2313 renderWidgetHostView_->render_widget_host_->GetBackingStore(true));
2305 renderWidgetHostView_->about_to_validate_and_paint_ = false; 2314 renderWidgetHostView_->about_to_validate_and_paint_ = false;
2306 2315
2307 const gfx::Rect damagedRect([self flipNSRectToRect:dirtyRect]); 2316 const gfx::Rect damagedRect([self flipNSRectToRect:dirtyRect]);
2308 2317
2309 if (renderWidgetHostView_->last_frame_was_accelerated_ && 2318 if (renderWidgetHostView_->last_frame_was_accelerated_ &&
2310 renderWidgetHostView_->compositing_iosurface_.get()) { 2319 renderWidgetHostView_->compositing_iosurface_.get()) {
2311 { 2320 if (renderWidgetHostView_->allow_overlapping_views_) {
2321 // If overlapping views need to be allowed, punch a hole in the window
2322 // to expose the GL underlay.
2312 TRACE_EVENT2("gpu", "NSRectFill clear", "w", damagedRect.width(), 2323 TRACE_EVENT2("gpu", "NSRectFill clear", "w", damagedRect.width(),
2313 "h", damagedRect.height()); 2324 "h", damagedRect.height());
2314 // Draw transparency to expose the GL underlay. NSRectFill is extremely 2325 // NSRectFill is extremely slow (15ms for a window on a fast MacPro), so
2315 // slow (15ms for a window on a fast MacPro), so this is only done when 2326 // this is only done when it's a real invalidation from window damage (not
2316 // it's a real invalidation from window damage (not when a BuffersSwapped 2327 // when a BuffersSwapped was received). Note that even a 1x1 NSRectFill
2317 // was received). Note that even a 1x1 NSRectFill can take many 2328 // can take many milliseconds sometimes (!) so this is skipped completely
2318 // milliseconds sometimes (!) so this is skipped completely for drawRects 2329 // for drawRects that are triggered by BuffersSwapped messages.
2319 // that are triggered by BuffersSwapped messages.
2320 [[NSColor clearColor] set]; 2330 [[NSColor clearColor] set];
2321 NSRectFill(dirtyRect); 2331 NSRectFill(dirtyRect);
2322 } 2332 }
2323 2333
2324 renderWidgetHostView_->compositing_iosurface_->DrawIOSurface( 2334 renderWidgetHostView_->compositing_iosurface_->DrawIOSurface(
2325 self, ScaleFactor(self)); 2335 self, ScaleFactor(self));
2326 return; 2336 return;
2327 } 2337 }
2328 2338
2329 if (backingStore) { 2339 if (backingStore) {
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after
3365 if (!string) return NO; 3375 if (!string) return NO;
3366 3376
3367 // If the user is currently using an IME, confirm the IME input, 3377 // If the user is currently using an IME, confirm the IME input,
3368 // and then insert the text from the service, the same as TextEdit and Safari. 3378 // and then insert the text from the service, the same as TextEdit and Safari.
3369 [self confirmComposition]; 3379 [self confirmComposition];
3370 [self insertText:string]; 3380 [self insertText:string];
3371 return YES; 3381 return YES;
3372 } 3382 }
3373 3383
3374 @end 3384 @end
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.h ('k') | content/browser/web_contents/web_contents_view_guest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698