< prev index next >

src/share/native/sun/awt/image/BufImgSurfaceData.c

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -30,10 +30,11 @@
 
 #include "img_util_md.h"
 #include "jni_util.h"
 /* Define uintptr_t */
 #include "gdefs.h"
+#include "Disposer.h"
 
 /**
  * This include file contains support code for loops using the
  * SurfaceData interface to talk to an X11 drawable from native
  * code.

@@ -78,23 +79,10 @@
     CHECK_NULL(colorDataID = (*env)->GetFieldID(env, icm, "colorData",
                                            "Lsun/awt/image/BufImgSurfaceData$ICMColorData;"));
 }
 
 /*
- * Class:     sun_java2d_SurfaceData
- * Method:    freeNativeICMData
- * Signature: (Ljava/awt/image/IndexColorModel;)V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_image_BufImgSurfaceData_freeNativeICMData
-    (JNIEnv *env, jclass sd, jlong pData)
-{
-    ColorData *cdata = (ColorData*)jlong_to_ptr(pData);
-    freeICMColorData(cdata);
-}
-
-/*
  * Class:     sun_awt_image_BufImgSurfaceData
  * Method:    initOps
  * Signature: (Ljava/lang/Object;IIIII)V
  */
 JNIEXPORT void JNICALL

@@ -138,10 +126,19 @@
     bisdo->rasbounds.x2 = width;
     bisdo->rasbounds.y2 = height;
 }
 
 /*
+ * Releases native structures associated with BufImgSurfaceData.ICMColorData.
+ */
+static void BufImg_Dispose_ICMColorData(JNIEnv *env, jlong pData)
+{
+    ColorData *cdata = (ColorData*)jlong_to_ptr(pData);
+    freeICMColorData(cdata);
+}
+
+/*
  * Method for disposing native BufImgSD
  */
 static void BufImg_Dispose(JNIEnv *env, SurfaceDataOps *ops)
 {
     /* ops is assumed non-null as it is checked in SurfaceData_DisposeOps */

@@ -315,10 +312,11 @@
                 free(cData);
                 return (ColorData*)NULL;
             }
 
             (*env)->SetObjectField(env, bisdo->icm, colorDataID, colorData);
+            Disposer_AddRecord(env, colorData, BufImg_Dispose_ICMColorData, pData);
         }
     }
 
     return cData;
 }
< prev index next >