src/macosx/native/sun/awt/AWTSurfaceLayers.m

Print this page




  61         }
  62     }
  63 }
  64 
  65 // Updates back buffer size of the layer if it's an OpenGL layer
  66 // including all OpenGL sublayers
  67 + (void) repaintLayersRecursively:(CALayer*)aLayer {
  68     if ([aLayer isKindOfClass:[CAOpenGLLayer class]]) {
  69         [aLayer setNeedsDisplay];
  70     }
  71     for(CALayer *child in aLayer.sublayers) {
  72         [AWTSurfaceLayers repaintLayersRecursively: child];
  73     }
  74 }
  75 
  76 - (void) setBounds:(CGRect)rect {
  77     layer.anchorPoint = CGPointMake(0, 0);
  78 
  79     // translates values to the coordinate system of the "root" layer
  80     CGFloat newY = windowLayer.bounds.size.height - rect.origin.y - rect.size.height;

  81 
  82     // REMIND: why do we need to inverse position?
  83     CGRect newRect = CGRectMake(-rect.origin.x, -newY, rect.size.width, rect.size.height);
  84 
  85     layer.bounds = newRect;
  86     [AWTSurfaceLayers repaintLayersRecursively:layer];
  87 }
  88 
  89 @end
  90 
  91 /*
  92  * Class:     sun_lwawt_macosx_CPlatformComponent
  93  * Method:    nativeCreateLayer
  94  * Signature: ()J
  95  */
  96 JNIEXPORT jlong JNICALL
  97 Java_sun_lwawt_macosx_CPlatformComponent_nativeCreateComponent
  98 (JNIEnv *env, jobject obj, jlong windowLayerPtr)
  99 {
 100   __block AWTSurfaceLayers *surfaceLayers = nil;
 101 
 102 JNF_COCOA_ENTER(env);
 103 AWT_ASSERT_NOT_APPKIT_THREAD;
 104 
 105   [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){




  61         }
  62     }
  63 }
  64 
  65 // Updates back buffer size of the layer if it's an OpenGL layer
  66 // including all OpenGL sublayers
  67 + (void) repaintLayersRecursively:(CALayer*)aLayer {
  68     if ([aLayer isKindOfClass:[CAOpenGLLayer class]]) {
  69         [aLayer setNeedsDisplay];
  70     }
  71     for(CALayer *child in aLayer.sublayers) {
  72         [AWTSurfaceLayers repaintLayersRecursively: child];
  73     }
  74 }
  75 
  76 - (void) setBounds:(CGRect)rect {
  77     layer.anchorPoint = CGPointMake(0, 0);
  78 
  79     // translates values to the coordinate system of the "root" layer
  80     CGFloat newY = windowLayer.bounds.size.height - rect.origin.y - rect.size.height;
  81     CGRect newRect = CGRectMake(rect.origin.x, newY, rect.size.width, rect.size.height);
  82 
  83     layer.frame = newRect;

  84 

  85     [AWTSurfaceLayers repaintLayersRecursively:layer];
  86 }
  87 
  88 @end
  89 
  90 /*
  91  * Class:     sun_lwawt_macosx_CPlatformComponent
  92  * Method:    nativeCreateLayer
  93  * Signature: ()J
  94  */
  95 JNIEXPORT jlong JNICALL
  96 Java_sun_lwawt_macosx_CPlatformComponent_nativeCreateComponent
  97 (JNIEnv *env, jobject obj, jlong windowLayerPtr)
  98 {
  99   __block AWTSurfaceLayers *surfaceLayers = nil;
 100 
 101 JNF_COCOA_ENTER(env);
 102 AWT_ASSERT_NOT_APPKIT_THREAD;
 103 
 104   [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){