コード例 #1
0
ファイル: display.cpp プロジェクト: beanhome/dev
bool wxDisplayImplMacOSX::ChangeMode( const wxVideoMode& mode )
{
#ifndef __WXOSX_IPHONE__
    if (mode == wxDefaultVideoMode)
    {
        CGRestorePermanentDisplayConfiguration();
        return true;
    }
#endif

    boolean_t bExactMatch;
    CFDictionaryRef theCGMode = CGDisplayBestModeForParametersAndRefreshRate(
        m_id,
        (size_t)mode.GetDepth(),
        (size_t)mode.GetWidth(),
        (size_t)mode.GetHeight(),
        (double)mode.GetRefresh(),
        &bExactMatch );

    bool bOK = bExactMatch;

    if (bOK)
        bOK = CGDisplaySwitchToMode( m_id, theCGMode ) == CGDisplayNoErr;

    return bOK;
}
コード例 #2
0
ファイル: DisplayResOSX.cpp プロジェクト: DocOnDev/mythtv
bool DisplayResOSX::SwitchToVideoMode(int width, int height, double refreshrate)
{
    CGDirectDisplayID d = GetOSXDisplay(MythDisplay::GetWindowID());
    CFDictionaryRef dispMode = NULL;
    boolean_t match = 0;

    // find mode that matches the desired size
    if (refreshrate)
        dispMode = CGDisplayBestModeForParametersAndRefreshRate(
            d, 32, width, height, (CGRefreshRate)((short)refreshrate), &match);

    if (!match)
        dispMode = 
            CGDisplayBestModeForParameters(d, 32, width, height, &match);

    if (!match)
        dispMode = 
            CGDisplayBestModeForParameters(d, 16, width, height, &match);

    if (!match)
        return false;
    
    // switch mode and return success
    CGDisplayCapture(d);
    CGDisplayConfigRef cfg;
    CGBeginDisplayConfiguration(&cfg);
    CGConfigureDisplayFadeEffect(cfg, 0.3f, 0.5f, 0, 0, 0);
    CGConfigureDisplayMode(cfg, d, dispMode);
    CGError err = CGCompleteDisplayConfiguration(cfg, kCGConfigureForAppOnly);
    CGDisplayRelease(d);
    return (err == kCGErrorSuccess);
}
コード例 #3
0
bool nglVideoMode::SetMode (nglVideoMode* pVideoMode, bool Lock)
{
#ifdef __NGL_MACHO__
  bool done = false;

  boolean_t exactMatch;
  CFDictionaryRef mode = CGDisplayBestModeForParametersAndRefreshRate((CGDirectDisplayID)pVideoMode->mDisplay, pVideoMode->mBPP, pVideoMode->mWidth, pVideoMode->mHeight, pVideoMode->mRate, &exactMatch);
  CGDisplaySwitchToMode( (CGDirectDisplayID)pVideoMode->mDisplay, mode);
//  NGL_DEBUG( NGL_LOG("vidmode", NGL_LOG_INFO, _T("switching to %s: %s"), Dump().GetChars(), done ? _T("ok"):_T("failed")); )
  return done;
#else
  return false;
#endif
}
コード例 #4
0
ファイル: quartztoggler.cpp プロジェクト: skidr0w/gambatte
void QuartzToggler::setFullMode(const bool enable) {
	CGDirectDisplayID display = activeDspys[widgetScreen];
	CFDictionaryRef currentMode = CGDisplayCurrentMode(display);

	CFDictionaryRef mode = currentMode;

	if (enable) {
		int bpp = 0;
		CFNumberGetValue(static_cast<CFNumberRef>(CFDictionaryGetValue(currentMode, kCGDisplayBitsPerPixel)), kCFNumberIntType, &bpp);

		mode = CGDisplayBestModeForParametersAndRefreshRate(
			display,
			bpp,
			infoVector[widgetScreen][fullResIndex[widgetScreen]].w,
			infoVector[widgetScreen][fullResIndex[widgetScreen]].h,
			infoVector[widgetScreen][fullResIndex[widgetScreen]].rates[fullRateIndex[widgetScreen]] / 10.0,
			NULL
		);

		if (!isFull)
			originalMode = currentMode;
	} else if (isFull)
		mode = originalMode;

	if (mode != currentMode) {
		CGDisplaySwitchToMode(display, mode);

		double oldRate = 0.0;
		double newRate = 0.0;

		CFNumberGetValue(static_cast<CFNumberRef>(CFDictionaryGetValue(currentMode, kCGDisplayRefreshRate)), kCFNumberDoubleType, &oldRate);
		CFNumberGetValue(static_cast<CFNumberRef>(CFDictionaryGetValue(mode, kCGDisplayRefreshRate)), kCFNumberDoubleType, &newRate);

		if (static_cast<int>(oldRate * 10.0 + 0.5) != static_cast<int>(newRate * 10.0 + 0.5))
			emit rateChange(static_cast<int>(newRate * 10.0 + 0.5));
	}

	isFull = enable;
}
コード例 #5
0
bool wxDisplayImplMacOSX::ChangeMode( const wxVideoMode& mode )
{
    // Changing to default mode (wxDefaultVideoMode) doesn't
    // work because we don't have access to the system's 'scrn'
    // resource which holds the user's mode which the system
    // will return to after this app is done
    boolean_t bExactMatch;
    CFDictionaryRef theCGMode = CGDisplayBestModeForParametersAndRefreshRate(
        m_id,
        (size_t)mode.GetDepth(),
        (size_t)mode.GetWidth(),
        (size_t)mode.GetHeight(),
        (double)mode.GetRefresh(),
        &bExactMatch );

    bool bOK = bExactMatch;

    if (bOK)
        bOK = CGDisplaySwitchToMode( m_id, theCGMode ) == CGDisplayNoErr;

    return bOK;
}