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

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

Issue 10837154: Mac HiDPI: Fix scale factor on external display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 8 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
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 } 361 }
362 362
363 RenderWidgetHost* RenderWidgetHostViewMac::GetRenderWidgetHost() const { 363 RenderWidgetHost* RenderWidgetHostViewMac::GetRenderWidgetHost() const {
364 return render_widget_host_; 364 return render_widget_host_;
365 } 365 }
366 366
367 void RenderWidgetHostViewMac::WasShown() { 367 void RenderWidgetHostViewMac::WasShown() {
368 if (!is_hidden_) 368 if (!is_hidden_)
369 return; 369 return;
370 370
371 // Check if the backing scale factor changed while the tab was in the
372 // background.
373 [cocoa_view_ updateTabBackingStoreScaleFactor];
374
375 if (web_contents_switch_paint_time_.is_null()) 371 if (web_contents_switch_paint_time_.is_null())
376 web_contents_switch_paint_time_ = base::TimeTicks::Now(); 372 web_contents_switch_paint_time_ = base::TimeTicks::Now();
377 is_hidden_ = false; 373 is_hidden_ = false;
378 render_widget_host_->WasShown(); 374 render_widget_host_->WasShown();
379 375
380 // We're messing with the window, so do this to ensure no flashes. 376 // We're messing with the window, so do this to ensure no flashes.
381 [[cocoa_view_ window] disableScreenUpdatesUntilFlush]; 377 [[cocoa_view_ window] disableScreenUpdatesUntilFlush];
382 } 378 }
383 379
384 void RenderWidgetHostViewMac::WasHidden() { 380 void RenderWidgetHostViewMac::WasHidden() {
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after
1429 1425
1430 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r { 1426 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r {
1431 self = [super initWithFrame:NSZeroRect]; 1427 self = [super initWithFrame:NSZeroRect];
1432 if (self) { 1428 if (self) {
1433 editCommand_helper_.reset(new RenderWidgetHostViewMacEditCommandHelper); 1429 editCommand_helper_.reset(new RenderWidgetHostViewMacEditCommandHelper);
1434 editCommand_helper_->AddEditingSelectorsToClass([self class]); 1430 editCommand_helper_->AddEditingSelectorsToClass([self class]);
1435 1431
1436 renderWidgetHostView_.reset(r); 1432 renderWidgetHostView_.reset(r);
1437 canBeKeyView_ = YES; 1433 canBeKeyView_ = YES;
1438 focusedPluginIdentifier_ = -1; 1434 focusedPluginIdentifier_ = -1;
1435 deviceScaleFactor_ = ScaleFactor(self);
1439 1436
1440 // OpenGL support: 1437 // OpenGL support:
1441 if ([self respondsToSelector: 1438 if ([self respondsToSelector:
1442 @selector(setWantsBestResolutionOpenGLSurface:)]) { 1439 @selector(setWantsBestResolutionOpenGLSurface:)]) {
1443 [self setWantsBestResolutionOpenGLSurface:YES]; 1440 [self setWantsBestResolutionOpenGLSurface:YES];
1444 } 1441 }
1445 handlingGlobalFrameDidChange_ = NO; 1442 handlingGlobalFrameDidChange_ = NO;
1446 [[NSNotificationCenter defaultCenter] 1443 [[NSNotificationCenter defaultCenter]
1447 addObserver:self 1444 addObserver:self
1448 selector:@selector(globalFrameDidChange:) 1445 selector:@selector(globalFrameDidChange:)
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
2022 name:NSWindowDidChangeScreenNotification 2019 name:NSWindowDidChangeScreenNotification
2023 object:newWindow]; 2020 object:newWindow];
2024 } 2021 }
2025 } 2022 }
2026 2023
2027 - (void)updateTabBackingStoreScaleFactor { 2024 - (void)updateTabBackingStoreScaleFactor {
2028 if (!renderWidgetHostView_->render_widget_host_) 2025 if (!renderWidgetHostView_->render_widget_host_)
2029 return; 2026 return;
2030 2027
2031 float scaleFactor = ScaleFactor(self); 2028 float scaleFactor = ScaleFactor(self);
2029 if (scaleFactor == deviceScaleFactor_)
2030 return;
2031 deviceScaleFactor_ = scaleFactor;
2032
2032 BackingStoreMac* backingStore = static_cast<BackingStoreMac*>( 2033 BackingStoreMac* backingStore = static_cast<BackingStoreMac*>(
2033 renderWidgetHostView_->render_widget_host_->GetBackingStore(false)); 2034 renderWidgetHostView_->render_widget_host_->GetBackingStore(false));
2034 if (backingStore) // NULL in hardware path. 2035 if (backingStore) // NULL in hardware path.
2035 backingStore->ScaleFactorChanged(scaleFactor); 2036 backingStore->ScaleFactorChanged(scaleFactor);
2036 2037
2037 renderWidgetHostView_->render_widget_host_->SetDeviceScaleFactor( 2038 renderWidgetHostView_->render_widget_host_->SetDeviceScaleFactor(
2038 scaleFactor); 2039 scaleFactor);
2039 } 2040 }
2040 2041
2041 // http://developer.apple.com/library/mac/#documentation/GraphicsAnimation/Conce ptual/HighResolutionOSX/CapturingScreenContents/CapturingScreenContents.html#//a pple_ref/doc/uid/TP40012302-CH10-SW4 2042 // http://developer.apple.com/library/mac/#documentation/GraphicsAnimation/Conce ptual/HighResolutionOSX/CapturingScreenContents/CapturingScreenContents.html#//a pple_ref/doc/uid/TP40012302-CH10-SW4
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after
2985 // Pointer comparison only, since we don't know if lastWindow_ is still 2986 // Pointer comparison only, since we don't know if lastWindow_ is still
2986 // valid. 2987 // valid.
2987 if (newWindow) { 2988 if (newWindow) {
2988 // If we move into a new window, refresh the frame information. We 2989 // If we move into a new window, refresh the frame information. We
2989 // don't need to do it if it was the same window as it used to be in, 2990 // don't need to do it if it was the same window as it used to be in,
2990 // since that case is covered by WasShown(). We only want to do this for 2991 // since that case is covered by WasShown(). We only want to do this for
2991 // real browser views, not popups. 2992 // real browser views, not popups.
2992 if (newWindow != lastWindow_) { 2993 if (newWindow != lastWindow_) {
2993 lastWindow_ = newWindow; 2994 lastWindow_ = newWindow;
2994 renderWidgetHostView_->WindowFrameChanged(); 2995 renderWidgetHostView_->WindowFrameChanged();
2996 [self updateTabBackingStoreScaleFactor];
Nico 2012/08/08 00:35:17 why only for key views?
sail 2012/08/08 00:45:00 Oops. Fixed.
2995 } 2997 }
2996 renderWidgetHostView_->ForceTextureReload(); 2998 renderWidgetHostView_->ForceTextureReload();
2997 } 2999 }
2998 } 3000 }
2999 3001
3000 // If we switch windows (or are removed from the view hierarchy), cancel any 3002 // If we switch windows (or are removed from the view hierarchy), cancel any
3001 // open mouse-downs. 3003 // open mouse-downs.
3002 if (hasOpenMouseDown_) { 3004 if (hasOpenMouseDown_) {
3003 WebMouseEvent event; 3005 WebMouseEvent event;
3004 event.type = WebInputEvent::MouseUp; 3006 event.type = WebInputEvent::MouseUp;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
3202 if (!string) return NO; 3204 if (!string) return NO;
3203 3205
3204 // If the user is currently using an IME, confirm the IME input, 3206 // If the user is currently using an IME, confirm the IME input,
3205 // and then insert the text from the service, the same as TextEdit and Safari. 3207 // and then insert the text from the service, the same as TextEdit and Safari.
3206 [self confirmComposition]; 3208 [self confirmComposition];
3207 [self insertText:string]; 3209 [self insertText:string];
3208 return YES; 3210 return YES;
3209 } 3211 }
3210 3212
3211 @end 3213 @end
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698