[vlc-commits] vout_macosx: added HiDPI support

Felix Paul Kühne git at videolan.org
Thu Jun 14 14:34:19 CEST 2012


vlc/vlc-2.0 | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Tue Jun 12 18:50:48 2012 +0200| [1a7fbfcdd59bf2775617ed1e28739dcc1034f47f] | committer: Felix Paul Kühne

vout_macosx: added HiDPI support

(cherry picked from commit af3a690427169763749987475727b0e37a6b6211)

(cherry picked from commit 405a83cda0fc0f45cd4851bed7cc1d525f6d8fa4)

(cherry picked from commit 4b2e143fa82231ecf563a8cb133edcc0839b4e1f)

(cherry picked from commit de9a7b4f9a61257dff5880b6543f79c13c502aad)

(cherry picked from commit f23389df0f358ec05ed0483a91cd4cfc56f867a5)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=1a7fbfcdd59bf2775617ed1e28739dcc1034f47f
---

 NEWS                                |    2 ++
 extras/package/macosx/Info.plist.in |    2 ++
 modules/video_output/macosx.m       |   35 ++++++++++++++++++++++++++++++++---
 3 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index 403ad02..ff8d26d 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,8 @@ Video Output:
    an ATI Radeon 9200 or a NVIDIA GeForceFX 5200 Ultra.
  * Fix video output of 10bit encoded contents on Intel-based Macs equipped
    with an Intel GMA 950 chipset running OS X 10.6 or later.
+ * Add support for the HiDPI mode used on recent Apple products with so-called
+   Retina Displays.
 
 Access:
  * Rework Digital TV module for Windows. DVB-T and DVB-C should work again
diff --git a/extras/package/macosx/Info.plist.in b/extras/package/macosx/Info.plist.in
index 24b3514..ffd3070 100644
--- a/extras/package/macosx/Info.plist.in
+++ b/extras/package/macosx/Info.plist.in
@@ -1375,5 +1375,7 @@
 	<string>VLCApplication</string>
 	<key>LSMinimumSystemVersion</key>
 	<string>10.5.0</string>
+	<key>NSHighResolutionCapable</key>
+	<true/>
 </dict>
 </plist>
diff --git a/modules/video_output/macosx.m b/modules/video_output/macosx.m
index e399082..c648950 100644
--- a/modules/video_output/macosx.m
+++ b/modules/video_output/macosx.m
@@ -52,6 +52,17 @@
 - (BOOL)isFullscreen;
 @end
 
+/* compilation support for 10.5 and 10.6 */
+#define OSX_LION NSAppKitVersionNumber >= 1115.2
+#ifndef MAC_OS_X_VERSION_10_7
+
+ at interface NSView (IntroducedInLion)
+- (NSRect)convertRectToBacking:(NSRect)aRect;
+- (void)setWantsBestResolutionOpenGLSurface:(BOOL)aBool;
+ at end
+
+#endif
+
 /**
  * Forward declarations
  */
@@ -378,7 +389,12 @@ static int Control (vout_display_t *vd, int query, va_list ap)
 
             if (!config_GetInt(vd, "macosx-video-autoresize"))
             {
-                NSRect bounds = [sys->glView bounds];
+                NSRect bounds;
+                /* on HiDPI displays, the point bounds don't equal the actual pixel based bounds */
+                if (OSX_LION)
+                    bounds = [sys->glView convertRectToBacking:[sys->glView bounds]];
+                else
+                    bounds = [sys->glView bounds];
                 cfg_tmp.display.width = bounds.size.width;
                 cfg_tmp.display.height = bounds.size.height;
             }
@@ -495,6 +511,10 @@ static void OpenglSwap (vlc_gl_t *gl)
     if (!self)
         return nil;
 
+    /* enable HiDPI support on OS X 10.7 and later */
+    if (OSX_LION)
+        [self setWantsBestResolutionOpenGLSurface:YES];
+
     /* Swap buffers only during the vertical retrace of the monitor.
      http://developer.apple.com/documentation/GraphicsImaging/
      Conceptual/OpenGL/chap5/chapter_5_section_44.html */
@@ -607,7 +627,12 @@ static void OpenglSwap (vlc_gl_t *gl)
 {
     VLCAssertMainThread();
 
-    NSRect bounds = [self bounds];
+    NSRect bounds;
+    /* on HiDPI displays, the point bounds don't equal the actual pixel based bounds */
+    if (OSX_LION)
+        bounds = [self convertRectToBacking:[self bounds]];
+    else
+        bounds = [self bounds];
     vout_display_place_t place;
     
     @synchronized(self) {
@@ -741,7 +766,11 @@ static void OpenglSwap (vlc_gl_t *gl)
     NSRect s_rect;
     BOOL b_inside;
 
-    s_rect = [self bounds];
+    /* on HiDPI displays, the point bounds don't equal the actual pixel based bounds */
+    if (OSX_LION)
+        s_rect = [self convertRectToBacking:[self bounds]];
+    else
+        s_rect = [self bounds];
     ml = [self convertPoint: [o_event locationInWindow] fromView: nil];
     b_inside = [self mouse: ml inRect: s_rect];
     



More information about the vlc-commits mailing list