modules/graphics/src/main/native-glass/mac/GlassView.m

Print this page




 642 {
 643     LOG("Java_com_sun_glass_ui_mac_MacView__1exitFullscreen");
 644     if (!jPtr) return;
 645 
 646     GLASS_ASSERT_MAIN_JAVA_THREAD(env);
 647     GLASS_POOL_ENTER;
 648     {
 649         NSView<GlassView> *view = getGlassView(env, jPtr);
 650         [view exitFullscreenWithAnimate:(jAnimate==JNI_TRUE)];
 651     }
 652     GLASS_POOL_EXIT;
 653     GLASS_CHECK_EXCEPTION(env);
 654 }
 655 
 656 /*
 657  * Class:     com_sun_glass_ui_mac_MacView
 658  * Method:    _uploadPixelsDirect
 659  * Signature: (JLjava/nio/Buffer;II)V
 660  */
 661 JNIEXPORT void JNICALL Java_com_sun_glass_ui_mac_MacView__1uploadPixelsDirect
 662 (JNIEnv *env, jobject jView, jlong jPtr, jobject jBuffer, jint jWidth, jint jHeight, jfloat jScale)
 663 {
 664     LOG("Java_com_sun_glass_ui_mac_MacView__1uploadPixelsDirect");
 665     if (!jPtr) return;
 666 
 667     GLASS_ASSERT_MAIN_JAVA_THREAD(env);
 668     NSView<GlassView> *view = getGlassView(env, jPtr);
 669 
 670 #ifndef FORCE_NOISE
 671     void *pixels = (*env)->GetDirectBufferAddress(env, jBuffer);
 672 #else
 673     void *pixels = _GenerateNoise(jWidth, jHeight);
 674 #endif
 675 
 676     // must be in the middle of begin/end
 677     if ((jWidth > 0) && (jHeight > 0))
 678     {
 679         [view pushPixels:pixels withWidth:(GLuint)jWidth withHeight:(GLuint)jHeight withScale:(GLfloat)jScale withEnv:env];
 680     }
 681 }
 682 
 683 /*
 684  * Class:     com_sun_glass_ui_mac_MacView
 685  * Method:    _uploadPixelsByteArray
 686  * Signature: (J[BIII)V
 687  */
 688 JNIEXPORT void JNICALL Java_com_sun_glass_ui_mac_MacView__1uploadPixelsByteArray
 689 (JNIEnv *env, jobject jView, jlong jPtr, jbyteArray jArray, jint jOffset, jint jWidth, jint jHeight, jfloat jScale)
 690 {
 691     LOG("Java_com_sun_glass_ui_mac_MacView__1uploadPixelsByteArray");
 692     if (!jPtr) return;
 693 
 694     GLASS_ASSERT_MAIN_JAVA_THREAD(env);
 695 
 696     jboolean isCopy = JNI_FALSE;
 697     u_int8_t *data = (*env)->GetPrimitiveArrayCritical(env, jArray, &isCopy);
 698     {
 699         assert((4*jWidth*jHeight + jOffset) == (*env)->GetArrayLength(env, jArray));
 700 
 701         NSView<GlassView> *view = getGlassView(env, jPtr);
 702 
 703 #ifndef FORCE_NOISE
 704         void *pixels = (data+jOffset);
 705 #else
 706         void *pixels = _GenerateNoise(jWidth, jHeight);
 707 #endif
 708 
 709         // must be in the middle of begin/end
 710         if ((jWidth > 0) && (jHeight > 0))
 711         {
 712             [view pushPixels:pixels withWidth:(GLuint)jWidth withHeight:(GLuint)jHeight withScale:(GLfloat)jScale withEnv:env];
 713         }
 714     }
 715     (*env)->ReleasePrimitiveArrayCritical(env, jArray, data, JNI_ABORT);
 716 }
 717 
 718 /*
 719  * Class:     com_sun_glass_ui_mac_MacView
 720  * Method:    _uploadPixelsIntArray
 721  * Signature: (J[IIII)V
 722  */
 723 JNIEXPORT void JNICALL Java_com_sun_glass_ui_mac_MacView__1uploadPixelsIntArray
 724 (JNIEnv *env, jobject jView, jlong jPtr, jintArray jArray, jint jOffset, jint jWidth, jint jHeight, jfloat jScale)
 725 {
 726     LOG("Java_com_sun_glass_ui_mac_MacView__1uploadPixelsIntArray");
 727     if (!jPtr) return;
 728 
 729     GLASS_ASSERT_MAIN_JAVA_THREAD(env);
 730 
 731     jboolean isCopy = JNI_FALSE;
 732     u_int32_t *data = (*env)->GetPrimitiveArrayCritical(env, jArray, &isCopy);
 733     {
 734         assert((jWidth*jHeight + jOffset) == (*env)->GetArrayLength(env, jArray));
 735 
 736         NSView<GlassView> *view = getGlassView(env, jPtr);
 737 
 738 #ifndef FORCE_NOISE
 739         void *pixels = (data+jOffset);
 740 #else
 741         void *pixels = _GenerateNoise(jWidth, jHeight);
 742 #endif
 743 
 744         // must be in the middle of begin/end
 745         if ((jWidth > 0) && (jHeight > 0))
 746         {
 747             [view pushPixels:pixels withWidth:(GLuint)jWidth withHeight:(GLuint)jHeight withScale:(GLfloat)jScale withEnv:env];
 748         }
 749     }
 750     (*env)->ReleasePrimitiveArrayCritical(env, jArray, data, JNI_ABORT);
 751 }
 752 
 753 /*
 754  * Input methods callback
 755  */
 756 
 757 /*
 758  * Class:     com_sun_glass_ui_mac_MacView
 759  * Method:    _enableInputMethodEvents
 760  * Signature: (JZ)V
 761  */
 762 JNIEXPORT void JNICALL Java_com_sun_glass_ui_mac_MacView__1enableInputMethodEvents
 763 (JNIEnv *env, jobject jView, jlong ptr, jboolean enable)
 764 {
 765     LOG("Java_com_sun_glass_ui_mac_MacView__1enableInputMethodEvents");
 766     if (!ptr) return;
 767 


 642 {
 643     LOG("Java_com_sun_glass_ui_mac_MacView__1exitFullscreen");
 644     if (!jPtr) return;
 645 
 646     GLASS_ASSERT_MAIN_JAVA_THREAD(env);
 647     GLASS_POOL_ENTER;
 648     {
 649         NSView<GlassView> *view = getGlassView(env, jPtr);
 650         [view exitFullscreenWithAnimate:(jAnimate==JNI_TRUE)];
 651     }
 652     GLASS_POOL_EXIT;
 653     GLASS_CHECK_EXCEPTION(env);
 654 }
 655 
 656 /*
 657  * Class:     com_sun_glass_ui_mac_MacView
 658  * Method:    _uploadPixelsDirect
 659  * Signature: (JLjava/nio/Buffer;II)V
 660  */
 661 JNIEXPORT void JNICALL Java_com_sun_glass_ui_mac_MacView__1uploadPixelsDirect
 662 (JNIEnv *env, jobject jView, jlong jPtr, jobject jBuffer, jint jWidth, jint jHeight, jfloat jScaleX, jfloat jScaleY)
 663 {
 664     LOG("Java_com_sun_glass_ui_mac_MacView__1uploadPixelsDirect");
 665     if (!jPtr) return;
 666 
 667     GLASS_ASSERT_MAIN_JAVA_THREAD(env);
 668     NSView<GlassView> *view = getGlassView(env, jPtr);
 669 
 670 #ifndef FORCE_NOISE
 671     void *pixels = (*env)->GetDirectBufferAddress(env, jBuffer);
 672 #else
 673     void *pixels = _GenerateNoise(jWidth, jHeight);
 674 #endif
 675 
 676     // must be in the middle of begin/end
 677     if ((jWidth > 0) && (jHeight > 0))
 678     {
 679         [view pushPixels:pixels withWidth:(GLuint)jWidth withHeight:(GLuint)jHeight withScaleX:(GLfloat)jScaleX withScaleY:(GLfloat)jScaleY withEnv:env];
 680     }
 681 }
 682 
 683 /*
 684  * Class:     com_sun_glass_ui_mac_MacView
 685  * Method:    _uploadPixelsByteArray
 686  * Signature: (J[BIII)V
 687  */
 688 JNIEXPORT void JNICALL Java_com_sun_glass_ui_mac_MacView__1uploadPixelsByteArray
 689 (JNIEnv *env, jobject jView, jlong jPtr, jbyteArray jArray, jint jOffset, jint jWidth, jint jHeight, jfloat jScaleX, jfloat jScaleY)
 690 {
 691     LOG("Java_com_sun_glass_ui_mac_MacView__1uploadPixelsByteArray");
 692     if (!jPtr) return;
 693 
 694     GLASS_ASSERT_MAIN_JAVA_THREAD(env);
 695 
 696     jboolean isCopy = JNI_FALSE;
 697     u_int8_t *data = (*env)->GetPrimitiveArrayCritical(env, jArray, &isCopy);
 698     {
 699         assert((4*jWidth*jHeight + jOffset) == (*env)->GetArrayLength(env, jArray));
 700 
 701         NSView<GlassView> *view = getGlassView(env, jPtr);
 702 
 703 #ifndef FORCE_NOISE
 704         void *pixels = (data+jOffset);
 705 #else
 706         void *pixels = _GenerateNoise(jWidth, jHeight);
 707 #endif
 708 
 709         // must be in the middle of begin/end
 710         if ((jWidth > 0) && (jHeight > 0))
 711         {
 712             [view pushPixels:pixels withWidth:(GLuint)jWidth withHeight:(GLuint)jHeight withScaleX:(GLfloat)jScaleX withScaleY:(GLfloat)jScaleY withEnv:env];
 713         }
 714     }
 715     (*env)->ReleasePrimitiveArrayCritical(env, jArray, data, JNI_ABORT);
 716 }
 717 
 718 /*
 719  * Class:     com_sun_glass_ui_mac_MacView
 720  * Method:    _uploadPixelsIntArray
 721  * Signature: (J[IIII)V
 722  */
 723 JNIEXPORT void JNICALL Java_com_sun_glass_ui_mac_MacView__1uploadPixelsIntArray
 724 (JNIEnv *env, jobject jView, jlong jPtr, jintArray jArray, jint jOffset, jint jWidth, jint jHeight, jfloat jScaleX, jfloat jScaleY)
 725 {
 726     LOG("Java_com_sun_glass_ui_mac_MacView__1uploadPixelsIntArray");
 727     if (!jPtr) return;
 728 
 729     GLASS_ASSERT_MAIN_JAVA_THREAD(env);
 730 
 731     jboolean isCopy = JNI_FALSE;
 732     u_int32_t *data = (*env)->GetPrimitiveArrayCritical(env, jArray, &isCopy);
 733     {
 734         assert((jWidth*jHeight + jOffset) == (*env)->GetArrayLength(env, jArray));
 735 
 736         NSView<GlassView> *view = getGlassView(env, jPtr);
 737 
 738 #ifndef FORCE_NOISE
 739         void *pixels = (data+jOffset);
 740 #else
 741         void *pixels = _GenerateNoise(jWidth, jHeight);
 742 #endif
 743 
 744         // must be in the middle of begin/end
 745         if ((jWidth > 0) && (jHeight > 0))
 746         {
 747             [view pushPixels:pixels withWidth:(GLuint)jWidth withHeight:(GLuint)jHeight withScaleX:(GLfloat)jScaleX withScaleY:(GLfloat)jScaleY withEnv:env];
 748         }
 749     }
 750     (*env)->ReleasePrimitiveArrayCritical(env, jArray, data, JNI_ABORT);
 751 }
 752 
 753 /*
 754  * Input methods callback
 755  */
 756 
 757 /*
 758  * Class:     com_sun_glass_ui_mac_MacView
 759  * Method:    _enableInputMethodEvents
 760  * Signature: (JZ)V
 761  */
 762 JNIEXPORT void JNICALL Java_com_sun_glass_ui_mac_MacView__1enableInputMethodEvents
 763 (JNIEnv *env, jobject jView, jlong ptr, jboolean enable)
 764 {
 765     LOG("Java_com_sun_glass_ui_mac_MacView__1enableInputMethodEvents");
 766     if (!ptr) return;
 767