< prev index next >

modules/javafx.graphics/src/main/native-prism-sw/JPiscesRenderer.c

Print this page


   1 /*
   2  * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 229                                    ramp, &gradientTransform);
 230         (*env)->ReleaseIntArrayElements(env, jramp, ramp, 0);
 231     } else {
 232         setMemErrorFlag();
 233     }
 234 
 235     if (JNI_TRUE == readAndClearMemErrorFlag()) {
 236         JNI_ThrowNew(env, "java/lang/OutOfMemoryError",
 237                      "Allocation of internal renderer buffer failed.");
 238     }
 239 }
 240 
 241 /*
 242  * Class:     com_sun_pisces_PiscesRenderer
 243  * Method:    setTextureImpl
 244  * Signature: (I[IIILcom/sun/pisces/Transform6;Z)V
 245  */
 246 JNIEXPORT void JNICALL Java_com_sun_pisces_PiscesRenderer_setTextureImpl
 247   (JNIEnv *env, jobject this, jint imageType, jintArray dataArray,
 248       jint width, jint height, jint stride,
 249       jobject jTransform, jboolean repeat, jboolean hasAlpha)
 250 {
 251     Renderer* rdr;
 252     Transform6 textureTransform;
 253     jint *data;
 254 
 255     transform_get6(&textureTransform, env, jTransform);
 256 
 257     rdr = (Renderer*)JLongToPointer((*env)->GetLongField(env, this, fieldIds[RENDERER_NATIVE_PTR]));
 258 
 259     data = (jint*)(*env)->GetPrimitiveArrayCritical(env, dataArray, NULL);
 260     if (data != NULL) {
 261         jint *alloc_data = my_malloc(jint, width * height);
 262         if (alloc_data != NULL) {
 263             if (stride == width) {
 264                 memcpy(alloc_data, data, sizeof(jint) * width * height);
 265             } else {
 266                 jint i;
 267                 for (i = 0; i < height; i++) {
 268                     memcpy(alloc_data + (i*width), data + (i*stride), sizeof(jint) * width);
 269                 }
 270             }
 271             renderer_setTexture(rdr, IMAGE_MODE_NORMAL,
 272                 alloc_data, width, height, width, repeat, JNI_TRUE,
 273                 &textureTransform, JNI_TRUE, hasAlpha,
 274                 0, 0, width-1, height-1);
 275         } else {
 276             setMemErrorFlag();
 277         }
 278         (*env)->ReleasePrimitiveArrayCritical(env, dataArray, data, 0);
 279     } else {
 280         setMemErrorFlag();
 281     }
 282 
 283     if (JNI_TRUE == readAndClearMemErrorFlag()) {
 284         JNI_ThrowNew(env, "java/lang/OutOfMemoryError",
 285             "Allocation of internal renderer buffer failed.");
 286     }
 287 }
 288 
 289 Renderer*
 290 renderer_get(JNIEnv* env, jobject objectHandle) {
 291     return (Renderer*)JLongToPointer(
 292                 (*env)->GetLongField(env, objectHandle,


 640     } else {
 641         setMemErrorFlag();
 642     }
 643 
 644     RELEASE_SURFACE(surface, env, surfaceHandle);
 645 
 646     if (JNI_TRUE == readAndClearMemErrorFlag()) {
 647         JNI_ThrowNew(env, "java/lang/OutOfMemoryError",
 648             "Allocation of internal renderer buffer failed.");
 649     }
 650 }
 651 
 652 /*
 653  * Class:     com_sun_pisces_PiscesRenderer
 654  * Method:    drawImageImpl
 655  * Signature: (I[IIIIILcom/sun/pisces/Transform6;ZIIII)V
 656  */
 657 JNIEXPORT void JNICALL Java_com_sun_pisces_PiscesRenderer_drawImageImpl
 658 (JNIEnv *env, jobject this, jint imageType, jint imageMode,
 659     jintArray dataArray, jint width, jint height, jint offset, jint stride,
 660     jobject jTransform, jboolean repeat, jint bboxX, jint bboxY, jint bboxW, jint bboxH,

 661     jint lEdge, jint rEdge, jint tEdge, jint bEdge,
 662     jint txMin, jint tyMin, jint txMax, jint tyMax,
 663     jboolean hasAlpha)
 664 {
 665     Renderer* rdr;
 666     jint* data;
 667 
 668     rdr = (Renderer*)JLongToPointer((*env)->GetLongField(env, this, fieldIds[RENDERER_NATIVE_PTR]));
 669     data = (jint*)(*env)->GetPrimitiveArrayCritical(env, dataArray, NULL);
 670     if (data != NULL) {
 671         Transform6 textureTransform;
 672 
 673         transform_get6(&textureTransform, env, jTransform);
 674         renderer_setTexture(rdr, imageMode, data + offset, width, height, stride,
 675             repeat, JNI_TRUE, &textureTransform, JNI_FALSE, hasAlpha,
 676             txMin, tyMin, txMax, tyMax);
 677 
 678         fillRect(env, this, rdr,
 679             bboxX, bboxY, bboxW, bboxH,
 680             lEdge, rEdge, tEdge, bEdge);
 681 
 682         rdr->_texture_intData = NULL;
 683         (*env)->ReleasePrimitiveArrayCritical(env, dataArray, data, 0);
 684     } else {
 685         setMemErrorFlag();
 686     }
 687 
 688     if (JNI_TRUE == readAndClearMemErrorFlag()) {
 689         JNI_ThrowNew(env, "java/lang/OutOfMemoryError",
 690                      "Allocation of internal renderer buffer failed.");
 691     }
 692     PISCES_DEBUG_FLUSH(stdout);
 693 }
 694 
 695 /*


   1 /*
   2  * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 229                                    ramp, &gradientTransform);
 230         (*env)->ReleaseIntArrayElements(env, jramp, ramp, 0);
 231     } else {
 232         setMemErrorFlag();
 233     }
 234 
 235     if (JNI_TRUE == readAndClearMemErrorFlag()) {
 236         JNI_ThrowNew(env, "java/lang/OutOfMemoryError",
 237                      "Allocation of internal renderer buffer failed.");
 238     }
 239 }
 240 
 241 /*
 242  * Class:     com_sun_pisces_PiscesRenderer
 243  * Method:    setTextureImpl
 244  * Signature: (I[IIILcom/sun/pisces/Transform6;Z)V
 245  */
 246 JNIEXPORT void JNICALL Java_com_sun_pisces_PiscesRenderer_setTextureImpl
 247   (JNIEnv *env, jobject this, jint imageType, jintArray dataArray,
 248       jint width, jint height, jint stride,
 249       jobject jTransform, jboolean repeat, jboolean linearFiltering, jboolean hasAlpha)
 250 {
 251     Renderer* rdr;
 252     Transform6 textureTransform;
 253     jint *data;
 254 
 255     transform_get6(&textureTransform, env, jTransform);
 256 
 257     rdr = (Renderer*)JLongToPointer((*env)->GetLongField(env, this, fieldIds[RENDERER_NATIVE_PTR]));
 258 
 259     data = (jint*)(*env)->GetPrimitiveArrayCritical(env, dataArray, NULL);
 260     if (data != NULL) {
 261         jint *alloc_data = my_malloc(jint, width * height);
 262         if (alloc_data != NULL) {
 263             if (stride == width) {
 264                 memcpy(alloc_data, data, sizeof(jint) * width * height);
 265             } else {
 266                 jint i;
 267                 for (i = 0; i < height; i++) {
 268                     memcpy(alloc_data + (i*width), data + (i*stride), sizeof(jint) * width);
 269                 }
 270             }
 271             renderer_setTexture(rdr, IMAGE_MODE_NORMAL,
 272                 alloc_data, width, height, width, repeat, linearFiltering,
 273                 &textureTransform, JNI_TRUE, hasAlpha,
 274                 0, 0, width-1, height-1);
 275         } else {
 276             setMemErrorFlag();
 277         }
 278         (*env)->ReleasePrimitiveArrayCritical(env, dataArray, data, 0);
 279     } else {
 280         setMemErrorFlag();
 281     }
 282 
 283     if (JNI_TRUE == readAndClearMemErrorFlag()) {
 284         JNI_ThrowNew(env, "java/lang/OutOfMemoryError",
 285             "Allocation of internal renderer buffer failed.");
 286     }
 287 }
 288 
 289 Renderer*
 290 renderer_get(JNIEnv* env, jobject objectHandle) {
 291     return (Renderer*)JLongToPointer(
 292                 (*env)->GetLongField(env, objectHandle,


 640     } else {
 641         setMemErrorFlag();
 642     }
 643 
 644     RELEASE_SURFACE(surface, env, surfaceHandle);
 645 
 646     if (JNI_TRUE == readAndClearMemErrorFlag()) {
 647         JNI_ThrowNew(env, "java/lang/OutOfMemoryError",
 648             "Allocation of internal renderer buffer failed.");
 649     }
 650 }
 651 
 652 /*
 653  * Class:     com_sun_pisces_PiscesRenderer
 654  * Method:    drawImageImpl
 655  * Signature: (I[IIIIILcom/sun/pisces/Transform6;ZIIII)V
 656  */
 657 JNIEXPORT void JNICALL Java_com_sun_pisces_PiscesRenderer_drawImageImpl
 658 (JNIEnv *env, jobject this, jint imageType, jint imageMode,
 659     jintArray dataArray, jint width, jint height, jint offset, jint stride,
 660     jobject jTransform, jboolean repeat, jboolean linearFiltering,
 661     jint bboxX, jint bboxY, jint bboxW, jint bboxH,
 662     jint lEdge, jint rEdge, jint tEdge, jint bEdge,
 663     jint txMin, jint tyMin, jint txMax, jint tyMax,
 664     jboolean hasAlpha)
 665 {
 666     Renderer* rdr;
 667     jint* data;
 668 
 669     rdr = (Renderer*)JLongToPointer((*env)->GetLongField(env, this, fieldIds[RENDERER_NATIVE_PTR]));
 670     data = (jint*)(*env)->GetPrimitiveArrayCritical(env, dataArray, NULL);
 671     if (data != NULL) {
 672         Transform6 textureTransform;
 673 
 674         transform_get6(&textureTransform, env, jTransform);
 675         renderer_setTexture(rdr, imageMode, data + offset, width, height, stride,
 676             repeat, linearFiltering, &textureTransform, JNI_FALSE, hasAlpha,
 677             txMin, tyMin, txMax, tyMax);
 678 
 679         fillRect(env, this, rdr,
 680             bboxX, bboxY, bboxW, bboxH,
 681             lEdge, rEdge, tEdge, bEdge);
 682 
 683         rdr->_texture_intData = NULL;
 684         (*env)->ReleasePrimitiveArrayCritical(env, dataArray, data, 0);
 685     } else {
 686         setMemErrorFlag();
 687     }
 688 
 689     if (JNI_TRUE == readAndClearMemErrorFlag()) {
 690         JNI_ThrowNew(env, "java/lang/OutOfMemoryError",
 691                      "Allocation of internal renderer buffer failed.");
 692     }
 693     PISCES_DEBUG_FLUSH(stdout);
 694 }
 695 
 696 /*


< prev index next >