Changeset 54466 in vbox for trunk/src/VBox/HostServices/SharedOpenGL/render
- Timestamp:
- Feb 24, 2015 6:12:19 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m
r54025 r54466 219 219 #endif 220 220 221 /* Whether we control NSView automatic content zooming on Retina/HiDPI displays. */ 222 //#define VBOX_WITH_CONFIGURABLE_HIDPI_SCALING 1 221 223 222 224 #ifdef IN_VMSVGA3D … … 890 892 - (NSSize)size; 891 893 - (void)updateViewportCS; 894 #ifdef VBOX_WITH_CONFIGURABLE_HIDPI_SCALING 895 - (NSRect)safeConvertRectToBacking:(NSRect *)pRect; 896 - (CGFloat)safeGetBackingScaleFactor; 897 #endif 892 898 - (NSRect)safeConvertToScreen:(NSRect *)pRect; 893 899 - (void)vboxReshapePerform; … … 1423 1429 1424 1430 self = [super initWithFrame:frame]; 1431 #ifdef VBOX_WITH_CONFIGURABLE_HIDPI_SCALING 1432 [self performSelector:@selector(setWantsBestResolutionOpenGLSurface:) withObject: (id)YES]; 1433 #endif 1425 1434 1426 1435 COCOA_LOG_FLOW(("%s: returns self=%p\n", __PRETTY_FUNCTION__, (void *)self)); … … 1722 1731 COCOA_LOG_FLOW(("%s: returns\n", __PRETTY_FUNCTION__)); 1723 1732 } 1733 1734 #ifdef VBOX_WITH_CONFIGURABLE_HIDPI_SCALING 1735 - (NSRect)safeConvertRectToBacking:(NSRect *)pRect 1736 { 1737 NSRect resultingRect = NSZeroRect; 1738 1739 NSWindow *pWindow = [m_pParentView window]; 1740 if (pWindow) 1741 { 1742 if ([pWindow respondsToSelector:@selector(convertRectToBacking:)]) 1743 { 1744 NSMethodSignature *pSignature = [pWindow methodSignatureForSelector:@selector(convertRectToBacking:)]; 1745 if (pSignature) 1746 { 1747 NSInvocation *pInvocation = [NSInvocation invocationWithMethodSignature:pSignature]; 1748 if (pInvocation) 1749 { 1750 [pInvocation setSelector:@selector(convertRectToBacking:)]; 1751 [pInvocation setTarget:pWindow]; 1752 [pInvocation setArgument:pRect atIndex:2]; 1753 [pInvocation invoke]; 1754 [pInvocation getReturnValue:&resultingRect]; 1755 1756 DEBUG_MSG(("safeConvertRectToBacking: convert [X, Y, WxH]: [%d, %d, %dx%d] -> [%d, %d, %dx%d]\n", 1757 (int)pRect ->origin.x, (int)pRect ->origin.y, (int)pRect ->size.width, (int)pRect ->size.width, 1758 (int)resultingRect.origin.x, (int)resultingRect.origin.y, (int)resultingRect.size.width, (int)resultingRect.size.width)); 1759 1760 return resultingRect; 1761 } 1762 } 1763 } 1764 } 1765 else 1766 /* Should never happen. */ 1767 DEBUG_WARN(("safeConvertRectToBacking: parent widget has no window.\n")); 1768 1769 resultingRect = *pRect; 1770 1771 DEBUG_MSG(("safeConvertRectToBacking (reurn as is): convert [X, Y, WxH]: [%d, %d, %dx%d] -> [%d, %d, %dx%d]\n", 1772 (int)pRect ->origin.x, (int)pRect ->origin.y, (int)pRect ->size.width, (int)pRect ->size.width, 1773 (int)resultingRect.origin.x, (int)resultingRect.origin.y, (int)resultingRect.size.width, (int)resultingRect.size.width)); 1774 1775 return resultingRect; 1776 } 1777 1778 1779 - (CGFloat)safeGetBackingScaleFactor 1780 { 1781 /* Assume its default value. */ 1782 CGFloat backingScaleFactor = 1.; 1783 1784 NSWindow *pWindow = [m_pParentView window]; 1785 if (pWindow) 1786 { 1787 NSScreen *pScreen = [pWindow screen]; 1788 if (pScreen) 1789 { 1790 if ([pScreen respondsToSelector:@selector(backingScaleFactor)]) 1791 { 1792 NSMethodSignature *pSignature = [pScreen methodSignatureForSelector:@selector(backingScaleFactor)]; 1793 if (pSignature) 1794 { 1795 NSInvocation *pInvocation = [NSInvocation invocationWithMethodSignature:pSignature]; 1796 if (pInvocation) 1797 { 1798 [pInvocation setSelector:@selector(backingScaleFactor)]; 1799 [pInvocation setTarget:pScreen]; 1800 [pInvocation invoke]; 1801 [pInvocation getReturnValue:&backingScaleFactor]; 1802 1803 DEBUG_MSG(("safeGetBackingScaleFactor: %d\n", (int)backingScaleFactor)); 1804 1805 return backingScaleFactor; 1806 } 1807 else 1808 DEBUG_WARN(("safeGetBackingScaleFactor: unable to create invocation for backingScaleFactor method signature.\n")); 1809 } 1810 else 1811 DEBUG_WARN(("safeGetBackingScaleFactor: unable to create method signature for backingScaleFactor selector.\n")); 1812 } 1813 else 1814 DEBUG_WARN(("safeGetBackingScaleFactor: NSScreen does not respond to backingScaleFactor selector.\n")); 1815 } 1816 else 1817 /* Should never happen. */ 1818 DEBUG_WARN(("safeGetBackingScaleFactor: parent window has no screen.\n")); 1819 } 1820 else 1821 /* Should never happen. */ 1822 DEBUG_WARN(("safeGetBackingScaleFactor: parent widget has no window.\n")); 1823 1824 return backingScaleFactor; 1825 } 1826 1827 #endif 1828 1724 1829 1725 1830 - (NSRect)safeConvertToScreen:(NSRect *)pRect … … 2259 2364 2260 2365 CrVrScrCompositorConstIterInit(pCompositor, &CIter); 2261 2366 2367 float backingStretchFactor = 1.; 2368 #ifdef VBOX_WITH_CONFIGURABLE_HIDPI_SCALING 2369 /* Adjust viewport according to current NSView's backing store parameters. */ 2370 NSRect regularBounds = [self bounds]; 2371 NSRect backingBounds = [self safeConvertRectToBacking:®ularBounds]; 2372 glViewport(0, 0, backingBounds.size.width, backingBounds.size.height); 2373 2374 /* Update strech factor in order to satisfy current NSView's backing store parameters. */ 2375 backingStretchFactor = [self safeGetBackingScaleFactor]; 2376 #endif 2377 2262 2378 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0); 2263 2379 glDrawBuffer(GL_BACK); … … 2300 2416 VBoxRectTranslate(&DstRect, -RestrictDstRect.xLeft, -RestrictDstRect.yTop); 2301 2417 2302 vboxNSRectToRectUnstretched(&m_RootRect, &RestrictSrcRect, xStretch , yStretch);2418 vboxNSRectToRectUnstretched(&m_RootRect, &RestrictSrcRect, xStretch / backingStretchFactor, yStretch / backingStretchFactor); 2303 2419 VBoxRectTranslate(&RestrictSrcRect, 2304 2420 -CrVrScrCompositorEntryRectGet(pEntry)->xLeft,
Note:
See TracChangeset
for help on using the changeset viewer.