jdk/src/macosx/native/sun/awt/CGraphicsDevice.m
changeset 12840 4157f2200059
parent 12836 66cabfe1972f
child 13241 92c2140b5bb2
equal deleted inserted replaced
12839:6bce0ca69176 12840:4157f2200059
    90     jint h, w, bpp, refrate;
    90     jint h, w, bpp, refrate;
    91     JNF_COCOA_ENTER(env);
    91     JNF_COCOA_ENTER(env);
    92     CFStringRef currentBPP = CGDisplayModeCopyPixelEncoding(mode);
    92     CFStringRef currentBPP = CGDisplayModeCopyPixelEncoding(mode);
    93     bpp = getBPPFromModeString(currentBPP);
    93     bpp = getBPPFromModeString(currentBPP);
    94     refrate = CGDisplayModeGetRefreshRate(mode);
    94     refrate = CGDisplayModeGetRefreshRate(mode);
    95     h = CGDisplayPixelsHigh(displayID);
    95     h = CGDisplayModeGetHeight(mode);
    96     w = CGDisplayPixelsWide(displayID);
    96     w = CGDisplayModeGetWidth(mode);
    97     CFRelease(currentBPP);
    97     CFRelease(currentBPP);
    98     static JNF_CLASS_CACHE(jc_DisplayMode, "java/awt/DisplayMode");
    98     static JNF_CLASS_CACHE(jc_DisplayMode, "java/awt/DisplayMode");
    99     static JNF_CTOR_CACHE(jc_DisplayMode_ctor, jc_DisplayMode, "(IIII)V");
    99     static JNF_CTOR_CACHE(jc_DisplayMode_ctor, jc_DisplayMode, "(IIII)V");
   100     ret = JNFNewObject(env, jc_DisplayMode_ctor, w, h, bpp, refrate);
   100     ret = JNFNewObject(env, jc_DisplayMode_ctor, w, h, bpp, refrate);
   101     JNF_COCOA_EXIT(env);
   101     JNF_COCOA_EXIT(env);
   152 {
   152 {
   153     JNF_COCOA_ENTER(env);
   153     JNF_COCOA_ENTER(env);
   154     CFArrayRef allModes = CGDisplayCopyAllDisplayModes(displayID, NULL);
   154     CFArrayRef allModes = CGDisplayCopyAllDisplayModes(displayID, NULL);
   155     CGDisplayModeRef closestMatch = getBestModeForParameters(allModes, (int)w, (int)h, (int)bpp, (int)refrate);
   155     CGDisplayModeRef closestMatch = getBestModeForParameters(allModes, (int)w, (int)h, (int)bpp, (int)refrate);
   156     if (closestMatch != NULL) {
   156     if (closestMatch != NULL) {
   157         CGDisplayConfigRef config;
   157         [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
   158         CGError retCode = CGBeginDisplayConfiguration(&config);
   158             CGDisplayConfigRef config;
   159         if (retCode == kCGErrorSuccess) {
   159             CGError retCode = CGBeginDisplayConfiguration(&config);
   160             CGConfigureDisplayWithDisplayMode(config, displayID, closestMatch, NULL);
   160             if (retCode == kCGErrorSuccess) {
   161             CGCompleteDisplayConfiguration(config, kCGConfigureForAppOnly);
   161                 CGConfigureDisplayWithDisplayMode(config, displayID, closestMatch, NULL);
   162             CFRelease(config);
   162                 CGCompleteDisplayConfiguration(config, kCGConfigureForAppOnly);
   163         }
   163                 if (config != NULL) {
       
   164                     CFRelease(config);
       
   165                 }
       
   166             }
       
   167         }];
   164     }
   168     }
   165     CFRelease(allModes);
   169     CFRelease(allModes);
   166     JNF_COCOA_EXIT(env);
   170     JNF_COCOA_EXIT(env);
   167 }
   171 }
   168 
   172