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

Unified Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 10548026: mac: Make dynamic DPI changes work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/backing_store_mac.mm ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host_view_mac.mm
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
index 7a95ba36c44d0cd104b2abb15359d4c142a400fa..d0e675c92522e71fff82e16630405927cae5aa14 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -159,6 +159,7 @@ float ScaleFactor(NSView* view) {
- (void)cancelChildPopups;
- (void)windowDidChangeBackingProperties:(NSNotification*)notification;
- (void)checkForPluginImeCancellation;
+- (void)updateTabBackingStoreScaleFactor;
@end
// NSEvent subtype for scroll gestures events.
@@ -399,6 +400,10 @@ void RenderWidgetHostViewMac::DidBecomeSelected() {
if (!is_hidden_)
return;
+ // Check if the backing scale factor changed while the tab was in the
+ // background.
+ [cocoa_view_ updateTabBackingStoreScaleFactor];
+
if (web_contents_switch_paint_time_.is_null())
web_contents_switch_paint_time_ = base::TimeTicks::Now();
is_hidden_ = false;
@@ -820,8 +825,6 @@ bool RenderWidgetHostViewMac::IsPopup() const {
BackingStore* RenderWidgetHostViewMac::AllocBackingStore(
const gfx::Size& size) {
- // TODO(thakis): Register for backing scale factor change events and pass
- // that on.
float scale = ScaleFactor(cocoa_view_);
return new BackingStoreMac(render_widget_host_, size, scale);
}
@@ -1890,6 +1893,20 @@ void RenderWidgetHostViewMac::SetTextInputActive(bool active) {
}
}
+- (void)updateTabBackingStoreScaleFactor {
+ if (!renderWidgetHostView_->render_widget_host_)
+ return;
+
+ float scaleFactor = ScaleFactor(self);
+ BackingStoreMac* backingStore = static_cast<BackingStoreMac*>(
+ renderWidgetHostView_->render_widget_host_->GetBackingStore(false));
+ if (backingStore) // NULL in hardware path.
+ backingStore->ScaleFactorChanged(scaleFactor);
+
+ renderWidgetHostView_->render_widget_host_->SetDeviceScaleFactor(
+ scaleFactor);
+}
+
// http://developer.apple.com/library/mac/#documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/CapturingScreenContents/CapturingScreenContents.html#//apple_ref/doc/uid/TP40012302-CH10-SW4
- (void)windowDidChangeBackingProperties:(NSNotification*)notification {
NSWindow* window = (NSWindow*)[notification object];
@@ -1899,11 +1916,16 @@ void RenderWidgetHostViewMac::SetTextInputActive(bool active) {
[[notification userInfo] objectForKey:NSBackingPropertyOldScaleFactorKey])
doubleValue];
if (newBackingScaleFactor != oldBackingScaleFactor) {
- // TODO(thakis): Tell backing store about new DPI, schedule repaint.
- if (renderWidgetHostView_->render_widget_host_) {
- renderWidgetHostView_->render_widget_host_->SetDeviceScaleFactor(
- newBackingScaleFactor);
- }
+ // Background tabs check if their scale factor changed when they become
+ // active, in DidBecomeSelected().
Avi (use Gerrit) 2012/06/14 04:51:20 Not for this CL, but we should rename that to DidB
Nico 2012/06/14 04:57:45 There's also a mac-only SetActive(true) call :-) T
+
+ // Allocating a CGLayerRef with the current scale factor immediately from
+ // this handler doesn't work. Schedule the backing store update on the
+ // next runloop cycle, then things are read for CGLayerRef allocations to
+ // work.
+ [self performSelector:@selector(updateTabBackingStoreScaleFactor)
+ withObject:nil
+ afterDelay:0];
}
}
« no previous file with comments | « content/browser/renderer_host/backing_store_mac.mm ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698