< prev index next >

src/java.desktop/share/native/libawt/awt/image/DataBufferNative.c

Print this page
rev 16167 : 8170525: Fix minor issues in awt coding


  55         return pixelPtr;
  56     }
  57     SurfaceData_InvokeRelease(env, ops, lockInfo);
  58     SurfaceData_InvokeUnlock(env, ops, lockInfo);
  59     return NULL;
  60 }
  61 
  62 /*
  63  * Class:     sun_awt_image_DataBufferNative
  64  * Method:    getElem
  65  * Signature:
  66  */
  67 JNIEXPORT jint JNICALL
  68 Java_sun_awt_image_DataBufferNative_getElem(JNIEnv *env, jobject dbn,
  69                                             jint x, jint y, jobject sd)
  70 {
  71     jint returnVal = -1;
  72     unsigned char *pixelPtr;
  73     SurfaceDataRasInfo lockInfo;
  74     SurfaceDataOps *ops;

  75 
  76     ops = SurfaceData_GetOps(env, sd);
  77     JNU_CHECK_EXCEPTION_RETURN(env, -1);
  78 
  79     if (!(pixelPtr = DBN_GetPixelPointer(env, x, y, &lockInfo,
  80                                          ops, SD_LOCK_READ)))
  81     {
  82         return returnVal;
  83     }
  84     switch (lockInfo.pixelStride) {
  85     case 4:
  86         returnVal = *(int *)pixelPtr;
  87         break;
  88     /* REMIND: do we need a 3-byte case (for 24-bit) here? */
  89     case 2:
  90         returnVal = *(unsigned short *)pixelPtr;
  91         break;
  92     case 1:
  93         returnVal = *pixelPtr;
  94         break;




  55         return pixelPtr;
  56     }
  57     SurfaceData_InvokeRelease(env, ops, lockInfo);
  58     SurfaceData_InvokeUnlock(env, ops, lockInfo);
  59     return NULL;
  60 }
  61 
  62 /*
  63  * Class:     sun_awt_image_DataBufferNative
  64  * Method:    getElem
  65  * Signature:
  66  */
  67 JNIEXPORT jint JNICALL
  68 Java_sun_awt_image_DataBufferNative_getElem(JNIEnv *env, jobject dbn,
  69                                             jint x, jint y, jobject sd)
  70 {
  71     jint returnVal = -1;
  72     unsigned char *pixelPtr;
  73     SurfaceDataRasInfo lockInfo;
  74     SurfaceDataOps *ops;
  75     lockInfo.resBase = NULL;
  76 
  77     ops = SurfaceData_GetOps(env, sd);
  78     JNU_CHECK_EXCEPTION_RETURN(env, -1);
  79 
  80     if (!(pixelPtr = DBN_GetPixelPointer(env, x, y, &lockInfo,
  81                                          ops, SD_LOCK_READ)))
  82     {
  83         return returnVal;
  84     }
  85     switch (lockInfo.pixelStride) {
  86     case 4:
  87         returnVal = *(int *)pixelPtr;
  88         break;
  89     /* REMIND: do we need a 3-byte case (for 24-bit) here? */
  90     case 2:
  91         returnVal = *(unsigned short *)pixelPtr;
  92         break;
  93     case 1:
  94         returnVal = *pixelPtr;
  95         break;


< prev index next >