Merge "Made Element accessors thread-safe" into nyc-dev
diff --git a/rs/java/android/renderscript/Element.java b/rs/java/android/renderscript/Element.java
index 50226ac..9d2f750 100644
--- a/rs/java/android/renderscript/Element.java
+++ b/rs/java/android/renderscript/Element.java
@@ -311,8 +311,12 @@
* @return Element
*/
public static Element BOOLEAN(RenderScript rs) {
- if(rs.mElement_BOOLEAN == null) {
- rs.mElement_BOOLEAN = createUser(rs, DataType.BOOLEAN);
+ if (rs.mElement_BOOLEAN == null) {
+ synchronized (rs) {
+ if (rs.mElement_BOOLEAN == null) {
+ rs.mElement_BOOLEAN = createUser(rs, DataType.BOOLEAN);
+ }
+ }
}
return rs.mElement_BOOLEAN;
}
@@ -325,8 +329,12 @@
* @return Element
*/
public static Element U8(RenderScript rs) {
- if(rs.mElement_U8 == null) {
- rs.mElement_U8 = createUser(rs, DataType.UNSIGNED_8);
+ if (rs.mElement_U8 == null) {
+ synchronized (rs) {
+ if (rs.mElement_U8 == null) {
+ rs.mElement_U8 = createUser(rs, DataType.UNSIGNED_8);
+ }
+ }
}
return rs.mElement_U8;
}
@@ -339,436 +347,683 @@
* @return Element
*/
public static Element I8(RenderScript rs) {
- if(rs.mElement_I8 == null) {
- rs.mElement_I8 = createUser(rs, DataType.SIGNED_8);
+ if (rs.mElement_I8 == null) {
+ synchronized (rs) {
+ if (rs.mElement_I8 == null) {
+ rs.mElement_I8 = createUser(rs, DataType.SIGNED_8);
+ }
+ }
}
return rs.mElement_I8;
}
public static Element U16(RenderScript rs) {
- if(rs.mElement_U16 == null) {
- rs.mElement_U16 = createUser(rs, DataType.UNSIGNED_16);
+ if (rs.mElement_U16 == null) {
+ synchronized (rs) {
+ if (rs.mElement_U16 == null) {
+ rs.mElement_U16 = createUser(rs, DataType.UNSIGNED_16);
+ }
+ }
}
return rs.mElement_U16;
}
public static Element I16(RenderScript rs) {
- if(rs.mElement_I16 == null) {
- rs.mElement_I16 = createUser(rs, DataType.SIGNED_16);
+ if (rs.mElement_I16 == null) {
+ synchronized (rs) {
+ if (rs.mElement_I16 == null) {
+ rs.mElement_I16 = createUser(rs, DataType.SIGNED_16);
+ }
+ }
}
return rs.mElement_I16;
}
public static Element U32(RenderScript rs) {
- if(rs.mElement_U32 == null) {
- rs.mElement_U32 = createUser(rs, DataType.UNSIGNED_32);
+ if (rs.mElement_U32 == null) {
+ synchronized (rs) {
+ if (rs.mElement_U32 == null) {
+ rs.mElement_U32 = createUser(rs, DataType.UNSIGNED_32);
+ }
+ }
}
return rs.mElement_U32;
}
public static Element I32(RenderScript rs) {
- if(rs.mElement_I32 == null) {
- rs.mElement_I32 = createUser(rs, DataType.SIGNED_32);
+ if (rs.mElement_I32 == null) {
+ synchronized (rs) {
+ if (rs.mElement_I32 == null) {
+ rs.mElement_I32 = createUser(rs, DataType.SIGNED_32);
+ }
+ }
}
return rs.mElement_I32;
}
public static Element U64(RenderScript rs) {
- if(rs.mElement_U64 == null) {
- rs.mElement_U64 = createUser(rs, DataType.UNSIGNED_64);
+ if (rs.mElement_U64 == null) {
+ synchronized (rs) {
+ if (rs.mElement_U64 == null) {
+ rs.mElement_U64 = createUser(rs, DataType.UNSIGNED_64);
+ }
+ }
}
return rs.mElement_U64;
}
public static Element I64(RenderScript rs) {
- if(rs.mElement_I64 == null) {
- rs.mElement_I64 = createUser(rs, DataType.SIGNED_64);
+ if (rs.mElement_I64 == null) {
+ synchronized (rs) {
+ if (rs.mElement_I64 == null) {
+ rs.mElement_I64 = createUser(rs, DataType.SIGNED_64);
+ }
+ }
}
return rs.mElement_I64;
}
public static Element F16(RenderScript rs) {
- if(rs.mElement_F16 == null) {
- rs.mElement_F16 = createUser(rs, DataType.FLOAT_16);
+ if (rs.mElement_F16 == null) {
+ synchronized (rs) {
+ if (rs.mElement_F16 == null) {
+ rs.mElement_F16 = createUser(rs, DataType.FLOAT_16);
+ }
+ }
}
return rs.mElement_F16;
}
public static Element F32(RenderScript rs) {
- if(rs.mElement_F32 == null) {
- rs.mElement_F32 = createUser(rs, DataType.FLOAT_32);
+ if (rs.mElement_F32 == null) {
+ synchronized (rs) {
+ if (rs.mElement_F32 == null) {
+ rs.mElement_F32 = createUser(rs, DataType.FLOAT_32);
+ }
+ }
}
return rs.mElement_F32;
}
public static Element F64(RenderScript rs) {
- if(rs.mElement_F64 == null) {
- rs.mElement_F64 = createUser(rs, DataType.FLOAT_64);
+ if (rs.mElement_F64 == null) {
+ synchronized (rs) {
+ if (rs.mElement_F64 == null) {
+ rs.mElement_F64 = createUser(rs, DataType.FLOAT_64);
+ }
+ }
}
return rs.mElement_F64;
}
public static Element ELEMENT(RenderScript rs) {
- if(rs.mElement_ELEMENT == null) {
- rs.mElement_ELEMENT = createUser(rs, DataType.RS_ELEMENT);
+ if (rs.mElement_ELEMENT == null) {
+ synchronized (rs) {
+ if (rs.mElement_ELEMENT == null) {
+ rs.mElement_ELEMENT = createUser(rs, DataType.RS_ELEMENT);
+ }
+ }
}
return rs.mElement_ELEMENT;
}
public static Element TYPE(RenderScript rs) {
- if(rs.mElement_TYPE == null) {
- rs.mElement_TYPE = createUser(rs, DataType.RS_TYPE);
+ if (rs.mElement_TYPE == null) {
+ synchronized (rs) {
+ if (rs.mElement_TYPE == null) {
+ rs.mElement_TYPE = createUser(rs, DataType.RS_TYPE);
+ }
+ }
}
return rs.mElement_TYPE;
}
public static Element ALLOCATION(RenderScript rs) {
- if(rs.mElement_ALLOCATION == null) {
- rs.mElement_ALLOCATION = createUser(rs, DataType.RS_ALLOCATION);
+ if (rs.mElement_ALLOCATION == null) {
+ synchronized (rs) {
+ if (rs.mElement_ALLOCATION == null) {
+ rs.mElement_ALLOCATION = createUser(rs, DataType.RS_ALLOCATION);
+ }
+ }
}
return rs.mElement_ALLOCATION;
}
public static Element SAMPLER(RenderScript rs) {
- if(rs.mElement_SAMPLER == null) {
- rs.mElement_SAMPLER = createUser(rs, DataType.RS_SAMPLER);
+ if (rs.mElement_SAMPLER == null) {
+ synchronized (rs) {
+ if (rs.mElement_SAMPLER == null) {
+ rs.mElement_SAMPLER = createUser(rs, DataType.RS_SAMPLER);
+ }
+ }
}
return rs.mElement_SAMPLER;
}
public static Element SCRIPT(RenderScript rs) {
- if(rs.mElement_SCRIPT == null) {
- rs.mElement_SCRIPT = createUser(rs, DataType.RS_SCRIPT);
+ if (rs.mElement_SCRIPT == null) {
+ synchronized (rs) {
+ if (rs.mElement_SCRIPT == null) {
+ rs.mElement_SCRIPT = createUser(rs, DataType.RS_SCRIPT);
+ }
+ }
}
return rs.mElement_SCRIPT;
}
public static Element MESH(RenderScript rs) {
- if(rs.mElement_MESH == null) {
- rs.mElement_MESH = createUser(rs, DataType.RS_MESH);
+ if (rs.mElement_MESH == null) {
+ synchronized (rs) {
+ if (rs.mElement_MESH == null) {
+ rs.mElement_MESH = createUser(rs, DataType.RS_MESH);
+ }
+ }
}
return rs.mElement_MESH;
}
public static Element PROGRAM_FRAGMENT(RenderScript rs) {
- if(rs.mElement_PROGRAM_FRAGMENT == null) {
- rs.mElement_PROGRAM_FRAGMENT = createUser(rs, DataType.RS_PROGRAM_FRAGMENT);
+ if (rs.mElement_PROGRAM_FRAGMENT == null) {
+ synchronized (rs) {
+ if (rs.mElement_PROGRAM_FRAGMENT == null) {
+ rs.mElement_PROGRAM_FRAGMENT = createUser(rs, DataType.RS_PROGRAM_FRAGMENT);
+ }
+ }
}
return rs.mElement_PROGRAM_FRAGMENT;
}
public static Element PROGRAM_VERTEX(RenderScript rs) {
- if(rs.mElement_PROGRAM_VERTEX == null) {
- rs.mElement_PROGRAM_VERTEX = createUser(rs, DataType.RS_PROGRAM_VERTEX);
+ if (rs.mElement_PROGRAM_VERTEX == null) {
+ synchronized (rs) {
+ if (rs.mElement_PROGRAM_VERTEX == null) {
+ rs.mElement_PROGRAM_VERTEX = createUser(rs, DataType.RS_PROGRAM_VERTEX);
+ }
+ }
}
return rs.mElement_PROGRAM_VERTEX;
}
public static Element PROGRAM_RASTER(RenderScript rs) {
- if(rs.mElement_PROGRAM_RASTER == null) {
- rs.mElement_PROGRAM_RASTER = createUser(rs, DataType.RS_PROGRAM_RASTER);
+ if (rs.mElement_PROGRAM_RASTER == null) {
+ synchronized (rs) {
+ if (rs.mElement_PROGRAM_RASTER == null) {
+ rs.mElement_PROGRAM_RASTER = createUser(rs, DataType.RS_PROGRAM_RASTER);
+ }
+ }
}
return rs.mElement_PROGRAM_RASTER;
}
public static Element PROGRAM_STORE(RenderScript rs) {
- if(rs.mElement_PROGRAM_STORE == null) {
- rs.mElement_PROGRAM_STORE = createUser(rs, DataType.RS_PROGRAM_STORE);
+ if (rs.mElement_PROGRAM_STORE == null) {
+ synchronized (rs) {
+ if (rs.mElement_PROGRAM_STORE == null) {
+ rs.mElement_PROGRAM_STORE = createUser(rs, DataType.RS_PROGRAM_STORE);
+ }
+ }
}
return rs.mElement_PROGRAM_STORE;
}
public static Element FONT(RenderScript rs) {
- if(rs.mElement_FONT == null) {
- rs.mElement_FONT = createUser(rs, DataType.RS_FONT);
+ if (rs.mElement_FONT == null) {
+ synchronized (rs) {
+ if (rs.mElement_FONT == null) {
+ rs.mElement_FONT = createUser(rs, DataType.RS_FONT);
+ }
+ }
}
return rs.mElement_FONT;
}
-
public static Element A_8(RenderScript rs) {
- if(rs.mElement_A_8 == null) {
- rs.mElement_A_8 = createPixel(rs, DataType.UNSIGNED_8, DataKind.PIXEL_A);
+ if (rs.mElement_A_8 == null) {
+ synchronized (rs) {
+ if (rs.mElement_A_8 == null) {
+ rs.mElement_A_8 = createPixel(rs, DataType.UNSIGNED_8, DataKind.PIXEL_A);
+ }
+ }
}
return rs.mElement_A_8;
}
public static Element RGB_565(RenderScript rs) {
- if(rs.mElement_RGB_565 == null) {
- rs.mElement_RGB_565 = createPixel(rs, DataType.UNSIGNED_5_6_5, DataKind.PIXEL_RGB);
+ if (rs.mElement_RGB_565 == null) {
+ synchronized (rs) {
+ if (rs.mElement_RGB_565 == null) {
+ rs.mElement_RGB_565 = createPixel(rs, DataType.UNSIGNED_5_6_5, DataKind.PIXEL_RGB);
+ }
+ }
}
return rs.mElement_RGB_565;
}
public static Element RGB_888(RenderScript rs) {
- if(rs.mElement_RGB_888 == null) {
- rs.mElement_RGB_888 = createPixel(rs, DataType.UNSIGNED_8, DataKind.PIXEL_RGB);
+ if (rs.mElement_RGB_888 == null) {
+ synchronized (rs) {
+ if (rs.mElement_RGB_888 == null) {
+ rs.mElement_RGB_888 = createPixel(rs, DataType.UNSIGNED_8, DataKind.PIXEL_RGB);
+ }
+ }
}
return rs.mElement_RGB_888;
}
public static Element RGBA_5551(RenderScript rs) {
- if(rs.mElement_RGBA_5551 == null) {
- rs.mElement_RGBA_5551 = createPixel(rs, DataType.UNSIGNED_5_5_5_1, DataKind.PIXEL_RGBA);
+ if (rs.mElement_RGBA_5551 == null) {
+ synchronized (rs) {
+ if (rs.mElement_RGBA_5551 == null) {
+ rs.mElement_RGBA_5551 = createPixel(rs, DataType.UNSIGNED_5_5_5_1, DataKind.PIXEL_RGBA);
+ }
+ }
}
return rs.mElement_RGBA_5551;
}
public static Element RGBA_4444(RenderScript rs) {
- if(rs.mElement_RGBA_4444 == null) {
- rs.mElement_RGBA_4444 = createPixel(rs, DataType.UNSIGNED_4_4_4_4, DataKind.PIXEL_RGBA);
+ if (rs.mElement_RGBA_4444 == null) {
+ synchronized (rs) {
+ if (rs.mElement_RGBA_4444 == null) {
+ rs.mElement_RGBA_4444 = createPixel(rs, DataType.UNSIGNED_4_4_4_4, DataKind.PIXEL_RGBA);
+ }
+ }
}
return rs.mElement_RGBA_4444;
}
public static Element RGBA_8888(RenderScript rs) {
- if(rs.mElement_RGBA_8888 == null) {
- rs.mElement_RGBA_8888 = createPixel(rs, DataType.UNSIGNED_8, DataKind.PIXEL_RGBA);
+ if (rs.mElement_RGBA_8888 == null) {
+ synchronized (rs) {
+ if (rs.mElement_RGBA_8888 == null) {
+ rs.mElement_RGBA_8888 = createPixel(rs, DataType.UNSIGNED_8, DataKind.PIXEL_RGBA);
+ }
+ }
}
return rs.mElement_RGBA_8888;
}
public static Element F16_2(RenderScript rs) {
- if(rs.mElement_HALF_2 == null) {
- rs.mElement_HALF_2 = createVector(rs, DataType.FLOAT_16, 2);
+ if (rs.mElement_HALF_2 == null) {
+ synchronized (rs) {
+ if (rs.mElement_HALF_2 == null) {
+ rs.mElement_HALF_2 = createVector(rs, DataType.FLOAT_16, 2);
+ }
+ }
}
return rs.mElement_HALF_2;
}
public static Element F16_3(RenderScript rs) {
- if(rs.mElement_HALF_3 == null) {
- rs.mElement_HALF_3 = createVector(rs, DataType.FLOAT_16, 3);
+ if (rs.mElement_HALF_3 == null) {
+ synchronized (rs) {
+ if (rs.mElement_HALF_3 == null) {
+ rs.mElement_HALF_3 = createVector(rs, DataType.FLOAT_16, 3);
+ }
+ }
}
return rs.mElement_HALF_3;
}
public static Element F16_4(RenderScript rs) {
- if(rs.mElement_HALF_4 == null) {
- rs.mElement_HALF_4 = createVector(rs, DataType.FLOAT_16, 4);
+ if (rs.mElement_HALF_4 == null) {
+ synchronized (rs) {
+ if (rs.mElement_HALF_4 == null) {
+ rs.mElement_HALF_4 = createVector(rs, DataType.FLOAT_16, 4);
+ }
+ }
}
return rs.mElement_HALF_4;
}
public static Element F32_2(RenderScript rs) {
- if(rs.mElement_FLOAT_2 == null) {
- rs.mElement_FLOAT_2 = createVector(rs, DataType.FLOAT_32, 2);
+ if (rs.mElement_FLOAT_2 == null) {
+ synchronized (rs) {
+ if (rs.mElement_FLOAT_2 == null) {
+ rs.mElement_FLOAT_2 = createVector(rs, DataType.FLOAT_32, 2);
+ }
+ }
}
return rs.mElement_FLOAT_2;
}
public static Element F32_3(RenderScript rs) {
- if(rs.mElement_FLOAT_3 == null) {
- rs.mElement_FLOAT_3 = createVector(rs, DataType.FLOAT_32, 3);
+ if (rs.mElement_FLOAT_3 == null) {
+ synchronized (rs) {
+ if (rs.mElement_FLOAT_3 == null) {
+ rs.mElement_FLOAT_3 = createVector(rs, DataType.FLOAT_32, 3);
+ }
+ }
}
return rs.mElement_FLOAT_3;
}
public static Element F32_4(RenderScript rs) {
- if(rs.mElement_FLOAT_4 == null) {
- rs.mElement_FLOAT_4 = createVector(rs, DataType.FLOAT_32, 4);
+ if (rs.mElement_FLOAT_4 == null) {
+ synchronized (rs) {
+ if (rs.mElement_FLOAT_4 == null) {
+ rs.mElement_FLOAT_4 = createVector(rs, DataType.FLOAT_32, 4);
+ }
+ }
}
return rs.mElement_FLOAT_4;
}
public static Element F64_2(RenderScript rs) {
- if(rs.mElement_DOUBLE_2 == null) {
- rs.mElement_DOUBLE_2 = createVector(rs, DataType.FLOAT_64, 2);
+ if (rs.mElement_DOUBLE_2 == null) {
+ synchronized (rs) {
+ if (rs.mElement_DOUBLE_2 == null) {
+ rs.mElement_DOUBLE_2 = createVector(rs, DataType.FLOAT_64, 2);
+ }
+ }
}
return rs.mElement_DOUBLE_2;
}
public static Element F64_3(RenderScript rs) {
- if(rs.mElement_DOUBLE_3 == null) {
- rs.mElement_DOUBLE_3 = createVector(rs, DataType.FLOAT_64, 3);
+ if (rs.mElement_DOUBLE_3 == null) {
+ synchronized (rs) {
+ if (rs.mElement_DOUBLE_3 == null) {
+ rs.mElement_DOUBLE_3 = createVector(rs, DataType.FLOAT_64, 3);
+ }
+ }
}
return rs.mElement_DOUBLE_3;
}
public static Element F64_4(RenderScript rs) {
- if(rs.mElement_DOUBLE_4 == null) {
- rs.mElement_DOUBLE_4 = createVector(rs, DataType.FLOAT_64, 4);
+ if (rs.mElement_DOUBLE_4 == null) {
+ synchronized (rs) {
+ if (rs.mElement_DOUBLE_4 == null) {
+ rs.mElement_DOUBLE_4 = createVector(rs, DataType.FLOAT_64, 4);
+ }
+ }
}
return rs.mElement_DOUBLE_4;
}
public static Element U8_2(RenderScript rs) {
- if(rs.mElement_UCHAR_2 == null) {
- rs.mElement_UCHAR_2 = createVector(rs, DataType.UNSIGNED_8, 2);
+ if (rs.mElement_UCHAR_2 == null) {
+ synchronized (rs) {
+ if (rs.mElement_UCHAR_2 == null) {
+ rs.mElement_UCHAR_2 = createVector(rs, DataType.UNSIGNED_8, 2);
+ }
+ }
}
return rs.mElement_UCHAR_2;
}
public static Element U8_3(RenderScript rs) {
- if(rs.mElement_UCHAR_3 == null) {
- rs.mElement_UCHAR_3 = createVector(rs, DataType.UNSIGNED_8, 3);
+ if (rs.mElement_UCHAR_3 == null) {
+ synchronized (rs) {
+ if (rs.mElement_UCHAR_3 == null) {
+ rs.mElement_UCHAR_3 = createVector(rs, DataType.UNSIGNED_8, 3);
+ }
+ }
}
return rs.mElement_UCHAR_3;
}
public static Element U8_4(RenderScript rs) {
- if(rs.mElement_UCHAR_4 == null) {
- rs.mElement_UCHAR_4 = createVector(rs, DataType.UNSIGNED_8, 4);
+ if (rs.mElement_UCHAR_4 == null) {
+ synchronized (rs) {
+ if (rs.mElement_UCHAR_4 == null) {
+ rs.mElement_UCHAR_4 = createVector(rs, DataType.UNSIGNED_8, 4);
+ }
+ }
}
return rs.mElement_UCHAR_4;
}
public static Element I8_2(RenderScript rs) {
- if(rs.mElement_CHAR_2 == null) {
- rs.mElement_CHAR_2 = createVector(rs, DataType.SIGNED_8, 2);
+ if (rs.mElement_CHAR_2 == null) {
+ synchronized (rs) {
+ if (rs.mElement_CHAR_2 == null) {
+ rs.mElement_CHAR_2 = createVector(rs, DataType.SIGNED_8, 2);
+ }
+ }
}
return rs.mElement_CHAR_2;
}
public static Element I8_3(RenderScript rs) {
- if(rs.mElement_CHAR_3 == null) {
- rs.mElement_CHAR_3 = createVector(rs, DataType.SIGNED_8, 3);
+ if (rs.mElement_CHAR_3 == null) {
+ synchronized (rs) {
+ if (rs.mElement_CHAR_3 == null) {
+ rs.mElement_CHAR_3 = createVector(rs, DataType.SIGNED_8, 3);
+ }
+ }
}
return rs.mElement_CHAR_3;
}
public static Element I8_4(RenderScript rs) {
- if(rs.mElement_CHAR_4 == null) {
- rs.mElement_CHAR_4 = createVector(rs, DataType.SIGNED_8, 4);
+ if (rs.mElement_CHAR_4 == null) {
+ synchronized (rs) {
+ if (rs.mElement_CHAR_4 == null) {
+ rs.mElement_CHAR_4 = createVector(rs, DataType.SIGNED_8, 4);
+ }
+ }
}
return rs.mElement_CHAR_4;
}
public static Element U16_2(RenderScript rs) {
- if(rs.mElement_USHORT_2 == null) {
- rs.mElement_USHORT_2 = createVector(rs, DataType.UNSIGNED_16, 2);
+ if (rs.mElement_USHORT_2 == null) {
+ synchronized (rs) {
+ if (rs.mElement_USHORT_2 == null) {
+ rs.mElement_USHORT_2 = createVector(rs, DataType.UNSIGNED_16, 2);
+ }
+ }
}
return rs.mElement_USHORT_2;
}
public static Element U16_3(RenderScript rs) {
- if(rs.mElement_USHORT_3 == null) {
- rs.mElement_USHORT_3 = createVector(rs, DataType.UNSIGNED_16, 3);
+ if (rs.mElement_USHORT_3 == null) {
+ synchronized (rs) {
+ if (rs.mElement_USHORT_3 == null) {
+ rs.mElement_USHORT_3 = createVector(rs, DataType.UNSIGNED_16, 3);
+ }
+ }
}
return rs.mElement_USHORT_3;
}
public static Element U16_4(RenderScript rs) {
- if(rs.mElement_USHORT_4 == null) {
- rs.mElement_USHORT_4 = createVector(rs, DataType.UNSIGNED_16, 4);
+ if (rs.mElement_USHORT_4 == null) {
+ synchronized (rs) {
+ if (rs.mElement_USHORT_4 == null) {
+ rs.mElement_USHORT_4 = createVector(rs, DataType.UNSIGNED_16, 4);
+ }
+ }
}
return rs.mElement_USHORT_4;
}
public static Element I16_2(RenderScript rs) {
- if(rs.mElement_SHORT_2 == null) {
- rs.mElement_SHORT_2 = createVector(rs, DataType.SIGNED_16, 2);
+ if (rs.mElement_SHORT_2 == null) {
+ synchronized (rs) {
+ if (rs.mElement_SHORT_2 == null) {
+ rs.mElement_SHORT_2 = createVector(rs, DataType.SIGNED_16, 2);
+ }
+ }
}
return rs.mElement_SHORT_2;
}
public static Element I16_3(RenderScript rs) {
- if(rs.mElement_SHORT_3 == null) {
- rs.mElement_SHORT_3 = createVector(rs, DataType.SIGNED_16, 3);
+ if (rs.mElement_SHORT_3 == null) {
+ synchronized (rs) {
+ if (rs.mElement_SHORT_3 == null) {
+ rs.mElement_SHORT_3 = createVector(rs, DataType.SIGNED_16, 3);
+ }
+ }
}
return rs.mElement_SHORT_3;
}
public static Element I16_4(RenderScript rs) {
- if(rs.mElement_SHORT_4 == null) {
- rs.mElement_SHORT_4 = createVector(rs, DataType.SIGNED_16, 4);
+ if (rs.mElement_SHORT_4 == null) {
+ synchronized (rs) {
+ if (rs.mElement_SHORT_4 == null) {
+ rs.mElement_SHORT_4 = createVector(rs, DataType.SIGNED_16, 4);
+ }
+ }
}
return rs.mElement_SHORT_4;
}
public static Element U32_2(RenderScript rs) {
- if(rs.mElement_UINT_2 == null) {
- rs.mElement_UINT_2 = createVector(rs, DataType.UNSIGNED_32, 2);
+ if (rs.mElement_UINT_2 == null) {
+ synchronized (rs) {
+ if (rs.mElement_UINT_2 == null) {
+ rs.mElement_UINT_2 = createVector(rs, DataType.UNSIGNED_32, 2);
+ }
+ }
}
return rs.mElement_UINT_2;
}
public static Element U32_3(RenderScript rs) {
- if(rs.mElement_UINT_3 == null) {
- rs.mElement_UINT_3 = createVector(rs, DataType.UNSIGNED_32, 3);
+ if (rs.mElement_UINT_3 == null) {
+ synchronized (rs) {
+ if (rs.mElement_UINT_3 == null) {
+ rs.mElement_UINT_3 = createVector(rs, DataType.UNSIGNED_32, 3);
+ }
+ }
}
return rs.mElement_UINT_3;
}
public static Element U32_4(RenderScript rs) {
- if(rs.mElement_UINT_4 == null) {
- rs.mElement_UINT_4 = createVector(rs, DataType.UNSIGNED_32, 4);
+ if (rs.mElement_UINT_4 == null) {
+ synchronized (rs) {
+ if (rs.mElement_UINT_4 == null) {
+ rs.mElement_UINT_4 = createVector(rs, DataType.UNSIGNED_32, 4);
+ }
+ }
}
return rs.mElement_UINT_4;
}
public static Element I32_2(RenderScript rs) {
- if(rs.mElement_INT_2 == null) {
- rs.mElement_INT_2 = createVector(rs, DataType.SIGNED_32, 2);
+ if (rs.mElement_INT_2 == null) {
+ synchronized (rs) {
+ if (rs.mElement_INT_2 == null) {
+ rs.mElement_INT_2 = createVector(rs, DataType.SIGNED_32, 2);
+ }
+ }
}
return rs.mElement_INT_2;
}
public static Element I32_3(RenderScript rs) {
- if(rs.mElement_INT_3 == null) {
- rs.mElement_INT_3 = createVector(rs, DataType.SIGNED_32, 3);
+ if (rs.mElement_INT_3 == null) {
+ synchronized (rs) {
+ if (rs.mElement_INT_3 == null) {
+ rs.mElement_INT_3 = createVector(rs, DataType.SIGNED_32, 3);
+ }
+ }
}
return rs.mElement_INT_3;
}
public static Element I32_4(RenderScript rs) {
- if(rs.mElement_INT_4 == null) {
- rs.mElement_INT_4 = createVector(rs, DataType.SIGNED_32, 4);
+ if (rs.mElement_INT_4 == null) {
+ synchronized (rs) {
+ if (rs.mElement_INT_4 == null) {
+ rs.mElement_INT_4 = createVector(rs, DataType.SIGNED_32, 4);
+ }
+ }
}
return rs.mElement_INT_4;
}
public static Element U64_2(RenderScript rs) {
- if(rs.mElement_ULONG_2 == null) {
- rs.mElement_ULONG_2 = createVector(rs, DataType.UNSIGNED_64, 2);
+ if (rs.mElement_ULONG_2 == null) {
+ synchronized (rs) {
+ if (rs.mElement_ULONG_2 == null) {
+ rs.mElement_ULONG_2 = createVector(rs, DataType.UNSIGNED_64, 2);
+ }
+ }
}
return rs.mElement_ULONG_2;
}
public static Element U64_3(RenderScript rs) {
- if(rs.mElement_ULONG_3 == null) {
- rs.mElement_ULONG_3 = createVector(rs, DataType.UNSIGNED_64, 3);
+ if (rs.mElement_ULONG_3 == null) {
+ synchronized (rs) {
+ if (rs.mElement_ULONG_3 == null) {
+ rs.mElement_ULONG_3 = createVector(rs, DataType.UNSIGNED_64, 3);
+ }
+ }
}
return rs.mElement_ULONG_3;
}
public static Element U64_4(RenderScript rs) {
- if(rs.mElement_ULONG_4 == null) {
- rs.mElement_ULONG_4 = createVector(rs, DataType.UNSIGNED_64, 4);
+ if (rs.mElement_ULONG_4 == null) {
+ synchronized (rs) {
+ if (rs.mElement_ULONG_4 == null) {
+ rs.mElement_ULONG_4 = createVector(rs, DataType.UNSIGNED_64, 4);
+ }
+ }
}
return rs.mElement_ULONG_4;
}
public static Element I64_2(RenderScript rs) {
- if(rs.mElement_LONG_2 == null) {
- rs.mElement_LONG_2 = createVector(rs, DataType.SIGNED_64, 2);
+ if (rs.mElement_LONG_2 == null) {
+ synchronized (rs) {
+ if (rs.mElement_LONG_2 == null) {
+ rs.mElement_LONG_2 = createVector(rs, DataType.SIGNED_64, 2);
+ }
+ }
}
return rs.mElement_LONG_2;
}
public static Element I64_3(RenderScript rs) {
- if(rs.mElement_LONG_3 == null) {
- rs.mElement_LONG_3 = createVector(rs, DataType.SIGNED_64, 3);
+ if (rs.mElement_LONG_3 == null) {
+ synchronized (rs) {
+ if (rs.mElement_LONG_3 == null) {
+ rs.mElement_LONG_3 = createVector(rs, DataType.SIGNED_64, 3);
+ }
+ }
}
return rs.mElement_LONG_3;
}
public static Element I64_4(RenderScript rs) {
- if(rs.mElement_LONG_4 == null) {
- rs.mElement_LONG_4 = createVector(rs, DataType.SIGNED_64, 4);
+ if (rs.mElement_LONG_4 == null) {
+ synchronized (rs) {
+ if (rs.mElement_LONG_4 == null) {
+ rs.mElement_LONG_4 = createVector(rs, DataType.SIGNED_64, 4);
+ }
+ }
}
return rs.mElement_LONG_4;
}
public static Element YUV(RenderScript rs) {
if (rs.mElement_YUV == null) {
- rs.mElement_YUV = createPixel(rs, DataType.UNSIGNED_8, DataKind.PIXEL_YUV);
+ synchronized (rs) {
+ if (rs.mElement_YUV == null) {
+ rs.mElement_YUV = createPixel(rs, DataType.UNSIGNED_8, DataKind.PIXEL_YUV);
+ }
+ }
}
return rs.mElement_YUV;
}
public static Element MATRIX_4X4(RenderScript rs) {
- if(rs.mElement_MATRIX_4X4 == null) {
- rs.mElement_MATRIX_4X4 = createUser(rs, DataType.MATRIX_4X4);
+ if (rs.mElement_MATRIX_4X4 == null) {
+ synchronized (rs) {
+ if (rs.mElement_MATRIX_4X4 == null) {
+ rs.mElement_MATRIX_4X4 = createUser(rs, DataType.MATRIX_4X4);
+ }
+ }
}
return rs.mElement_MATRIX_4X4;
}
@@ -780,15 +1035,23 @@
}
public static Element MATRIX_3X3(RenderScript rs) {
- if(rs.mElement_MATRIX_3X3 == null) {
- rs.mElement_MATRIX_3X3 = createUser(rs, DataType.MATRIX_3X3);
+ if (rs.mElement_MATRIX_3X3 == null) {
+ synchronized (rs) {
+ if (rs.mElement_MATRIX_3X3 == null) {
+ rs.mElement_MATRIX_3X3 = createUser(rs, DataType.MATRIX_3X3);
+ }
+ }
}
return rs.mElement_MATRIX_3X3;
}
public static Element MATRIX_2X2(RenderScript rs) {
- if(rs.mElement_MATRIX_2X2 == null) {
- rs.mElement_MATRIX_2X2 = createUser(rs, DataType.MATRIX_2X2);
+ if (rs.mElement_MATRIX_2X2 == null) {
+ synchronized (rs) {
+ if (rs.mElement_MATRIX_2X2 == null) {
+ rs.mElement_MATRIX_2X2 = createUser(rs, DataType.MATRIX_2X2);
+ }
+ }
}
return rs.mElement_MATRIX_2X2;
}
diff --git a/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java
index 2650e5a..3d1370a 100644
--- a/rs/java/android/renderscript/RenderScript.java
+++ b/rs/java/android/renderscript/RenderScript.java
@@ -1037,97 +1037,97 @@
@SuppressWarnings({"FieldCanBeLocal"})
MessageThread mMessageThread;
- Element mElement_U8;
- Element mElement_I8;
- Element mElement_U16;
- Element mElement_I16;
- Element mElement_U32;
- Element mElement_I32;
- Element mElement_U64;
- Element mElement_I64;
- Element mElement_F16;
- Element mElement_F32;
- Element mElement_F64;
- Element mElement_BOOLEAN;
+ volatile Element mElement_U8;
+ volatile Element mElement_I8;
+ volatile Element mElement_U16;
+ volatile Element mElement_I16;
+ volatile Element mElement_U32;
+ volatile Element mElement_I32;
+ volatile Element mElement_U64;
+ volatile Element mElement_I64;
+ volatile Element mElement_F16;
+ volatile Element mElement_F32;
+ volatile Element mElement_F64;
+ volatile Element mElement_BOOLEAN;
- Element mElement_ELEMENT;
- Element mElement_TYPE;
- Element mElement_ALLOCATION;
- Element mElement_SAMPLER;
- Element mElement_SCRIPT;
- Element mElement_MESH;
- Element mElement_PROGRAM_FRAGMENT;
- Element mElement_PROGRAM_VERTEX;
- Element mElement_PROGRAM_RASTER;
- Element mElement_PROGRAM_STORE;
- Element mElement_FONT;
+ volatile Element mElement_ELEMENT;
+ volatile Element mElement_TYPE;
+ volatile Element mElement_ALLOCATION;
+ volatile Element mElement_SAMPLER;
+ volatile Element mElement_SCRIPT;
+ volatile Element mElement_MESH;
+ volatile Element mElement_PROGRAM_FRAGMENT;
+ volatile Element mElement_PROGRAM_VERTEX;
+ volatile Element mElement_PROGRAM_RASTER;
+ volatile Element mElement_PROGRAM_STORE;
+ volatile Element mElement_FONT;
- Element mElement_A_8;
- Element mElement_RGB_565;
- Element mElement_RGB_888;
- Element mElement_RGBA_5551;
- Element mElement_RGBA_4444;
- Element mElement_RGBA_8888;
+ volatile Element mElement_A_8;
+ volatile Element mElement_RGB_565;
+ volatile Element mElement_RGB_888;
+ volatile Element mElement_RGBA_5551;
+ volatile Element mElement_RGBA_4444;
+ volatile Element mElement_RGBA_8888;
- Element mElement_HALF_2;
- Element mElement_HALF_3;
- Element mElement_HALF_4;
+ volatile Element mElement_HALF_2;
+ volatile Element mElement_HALF_3;
+ volatile Element mElement_HALF_4;
- Element mElement_FLOAT_2;
- Element mElement_FLOAT_3;
- Element mElement_FLOAT_4;
+ volatile Element mElement_FLOAT_2;
+ volatile Element mElement_FLOAT_3;
+ volatile Element mElement_FLOAT_4;
- Element mElement_DOUBLE_2;
- Element mElement_DOUBLE_3;
- Element mElement_DOUBLE_4;
+ volatile Element mElement_DOUBLE_2;
+ volatile Element mElement_DOUBLE_3;
+ volatile Element mElement_DOUBLE_4;
- Element mElement_UCHAR_2;
- Element mElement_UCHAR_3;
- Element mElement_UCHAR_4;
+ volatile Element mElement_UCHAR_2;
+ volatile Element mElement_UCHAR_3;
+ volatile Element mElement_UCHAR_4;
- Element mElement_CHAR_2;
- Element mElement_CHAR_3;
- Element mElement_CHAR_4;
+ volatile Element mElement_CHAR_2;
+ volatile Element mElement_CHAR_3;
+ volatile Element mElement_CHAR_4;
- Element mElement_USHORT_2;
- Element mElement_USHORT_3;
- Element mElement_USHORT_4;
+ volatile Element mElement_USHORT_2;
+ volatile Element mElement_USHORT_3;
+ volatile Element mElement_USHORT_4;
- Element mElement_SHORT_2;
- Element mElement_SHORT_3;
- Element mElement_SHORT_4;
+ volatile Element mElement_SHORT_2;
+ volatile Element mElement_SHORT_3;
+ volatile Element mElement_SHORT_4;
- Element mElement_UINT_2;
- Element mElement_UINT_3;
- Element mElement_UINT_4;
+ volatile Element mElement_UINT_2;
+ volatile Element mElement_UINT_3;
+ volatile Element mElement_UINT_4;
- Element mElement_INT_2;
- Element mElement_INT_3;
- Element mElement_INT_4;
+ volatile Element mElement_INT_2;
+ volatile Element mElement_INT_3;
+ volatile Element mElement_INT_4;
- Element mElement_ULONG_2;
- Element mElement_ULONG_3;
- Element mElement_ULONG_4;
+ volatile Element mElement_ULONG_2;
+ volatile Element mElement_ULONG_3;
+ volatile Element mElement_ULONG_4;
- Element mElement_LONG_2;
- Element mElement_LONG_3;
- Element mElement_LONG_4;
+ volatile Element mElement_LONG_2;
+ volatile Element mElement_LONG_3;
+ volatile Element mElement_LONG_4;
- Element mElement_YUV;
+ volatile Element mElement_YUV;
- Element mElement_MATRIX_4X4;
- Element mElement_MATRIX_3X3;
- Element mElement_MATRIX_2X2;
+ volatile Element mElement_MATRIX_4X4;
+ volatile Element mElement_MATRIX_3X3;
+ volatile Element mElement_MATRIX_2X2;
- Sampler mSampler_CLAMP_NEAREST;
- Sampler mSampler_CLAMP_LINEAR;
- Sampler mSampler_CLAMP_LINEAR_MIP_LINEAR;
- Sampler mSampler_WRAP_NEAREST;
- Sampler mSampler_WRAP_LINEAR;
- Sampler mSampler_WRAP_LINEAR_MIP_LINEAR;
- Sampler mSampler_MIRRORED_REPEAT_NEAREST;
- Sampler mSampler_MIRRORED_REPEAT_LINEAR;
- Sampler mSampler_MIRRORED_REPEAT_LINEAR_MIP_LINEAR;
+ volatile Sampler mSampler_CLAMP_NEAREST;
+ volatile Sampler mSampler_CLAMP_LINEAR;
+ volatile Sampler mSampler_CLAMP_LINEAR_MIP_LINEAR;
+ volatile Sampler mSampler_WRAP_NEAREST;
+ volatile Sampler mSampler_WRAP_LINEAR;
+ volatile Sampler mSampler_WRAP_LINEAR_MIP_LINEAR;
+ volatile Sampler mSampler_MIRRORED_REPEAT_NEAREST;
+ volatile Sampler mSampler_MIRRORED_REPEAT_LINEAR;
+ volatile Sampler mSampler_MIRRORED_REPEAT_LINEAR_MIP_LINEAR;
ProgramStore mProgramStore_BLEND_NONE_DEPTH_TEST;
ProgramStore mProgramStore_BLEND_NONE_DEPTH_NO_DEPTH;
diff --git a/rs/java/android/renderscript/Sampler.java b/rs/java/android/renderscript/Sampler.java
index 5c4bae9..70e88bc 100644
--- a/rs/java/android/renderscript/Sampler.java
+++ b/rs/java/android/renderscript/Sampler.java
@@ -98,13 +98,17 @@
* @return Sampler
*/
public static Sampler CLAMP_NEAREST(RenderScript rs) {
- if(rs.mSampler_CLAMP_NEAREST == null) {
- Builder b = new Builder(rs);
- b.setMinification(Value.NEAREST);
- b.setMagnification(Value.NEAREST);
- b.setWrapS(Value.CLAMP);
- b.setWrapT(Value.CLAMP);
- rs.mSampler_CLAMP_NEAREST = b.create();
+ if (rs.mSampler_CLAMP_NEAREST == null) {
+ synchronized (rs) {
+ if (rs.mSampler_CLAMP_NEAREST == null) {
+ Builder b = new Builder(rs);
+ b.setMinification(Value.NEAREST);
+ b.setMagnification(Value.NEAREST);
+ b.setWrapS(Value.CLAMP);
+ b.setWrapT(Value.CLAMP);
+ rs.mSampler_CLAMP_NEAREST = b.create();
+ }
+ }
}
return rs.mSampler_CLAMP_NEAREST;
}
@@ -118,13 +122,17 @@
* @return Sampler
*/
public static Sampler CLAMP_LINEAR(RenderScript rs) {
- if(rs.mSampler_CLAMP_LINEAR == null) {
- Builder b = new Builder(rs);
- b.setMinification(Value.LINEAR);
- b.setMagnification(Value.LINEAR);
- b.setWrapS(Value.CLAMP);
- b.setWrapT(Value.CLAMP);
- rs.mSampler_CLAMP_LINEAR = b.create();
+ if (rs.mSampler_CLAMP_LINEAR == null) {
+ synchronized (rs) {
+ if (rs.mSampler_CLAMP_LINEAR == null) {
+ Builder b = new Builder(rs);
+ b.setMinification(Value.LINEAR);
+ b.setMagnification(Value.LINEAR);
+ b.setWrapS(Value.CLAMP);
+ b.setWrapT(Value.CLAMP);
+ rs.mSampler_CLAMP_LINEAR = b.create();
+ }
+ }
}
return rs.mSampler_CLAMP_LINEAR;
}
@@ -138,13 +146,17 @@
* @return Sampler
*/
public static Sampler CLAMP_LINEAR_MIP_LINEAR(RenderScript rs) {
- if(rs.mSampler_CLAMP_LINEAR_MIP_LINEAR == null) {
- Builder b = new Builder(rs);
- b.setMinification(Value.LINEAR_MIP_LINEAR);
- b.setMagnification(Value.LINEAR);
- b.setWrapS(Value.CLAMP);
- b.setWrapT(Value.CLAMP);
- rs.mSampler_CLAMP_LINEAR_MIP_LINEAR = b.create();
+ if (rs.mSampler_CLAMP_LINEAR_MIP_LINEAR == null) {
+ synchronized (rs) {
+ if (rs.mSampler_CLAMP_LINEAR_MIP_LINEAR == null) {
+ Builder b = new Builder(rs);
+ b.setMinification(Value.LINEAR_MIP_LINEAR);
+ b.setMagnification(Value.LINEAR);
+ b.setWrapS(Value.CLAMP);
+ b.setWrapT(Value.CLAMP);
+ rs.mSampler_CLAMP_LINEAR_MIP_LINEAR = b.create();
+ }
+ }
}
return rs.mSampler_CLAMP_LINEAR_MIP_LINEAR;
}
@@ -158,13 +170,17 @@
* @return Sampler
*/
public static Sampler WRAP_NEAREST(RenderScript rs) {
- if(rs.mSampler_WRAP_NEAREST == null) {
- Builder b = new Builder(rs);
- b.setMinification(Value.NEAREST);
- b.setMagnification(Value.NEAREST);
- b.setWrapS(Value.WRAP);
- b.setWrapT(Value.WRAP);
- rs.mSampler_WRAP_NEAREST = b.create();
+ if (rs.mSampler_WRAP_NEAREST == null) {
+ synchronized (rs) {
+ if (rs.mSampler_WRAP_NEAREST == null) {
+ Builder b = new Builder(rs);
+ b.setMinification(Value.NEAREST);
+ b.setMagnification(Value.NEAREST);
+ b.setWrapS(Value.WRAP);
+ b.setWrapT(Value.WRAP);
+ rs.mSampler_WRAP_NEAREST = b.create();
+ }
+ }
}
return rs.mSampler_WRAP_NEAREST;
}
@@ -178,13 +194,17 @@
* @return Sampler
*/
public static Sampler WRAP_LINEAR(RenderScript rs) {
- if(rs.mSampler_WRAP_LINEAR == null) {
- Builder b = new Builder(rs);
- b.setMinification(Value.LINEAR);
- b.setMagnification(Value.LINEAR);
- b.setWrapS(Value.WRAP);
- b.setWrapT(Value.WRAP);
- rs.mSampler_WRAP_LINEAR = b.create();
+ if (rs.mSampler_WRAP_LINEAR == null) {
+ synchronized (rs) {
+ if (rs.mSampler_WRAP_LINEAR == null) {
+ Builder b = new Builder(rs);
+ b.setMinification(Value.LINEAR);
+ b.setMagnification(Value.LINEAR);
+ b.setWrapS(Value.WRAP);
+ b.setWrapT(Value.WRAP);
+ rs.mSampler_WRAP_LINEAR = b.create();
+ }
+ }
}
return rs.mSampler_WRAP_LINEAR;
}
@@ -198,13 +218,17 @@
* @return Sampler
*/
public static Sampler WRAP_LINEAR_MIP_LINEAR(RenderScript rs) {
- if(rs.mSampler_WRAP_LINEAR_MIP_LINEAR == null) {
- Builder b = new Builder(rs);
- b.setMinification(Value.LINEAR_MIP_LINEAR);
- b.setMagnification(Value.LINEAR);
- b.setWrapS(Value.WRAP);
- b.setWrapT(Value.WRAP);
- rs.mSampler_WRAP_LINEAR_MIP_LINEAR = b.create();
+ if (rs.mSampler_WRAP_LINEAR_MIP_LINEAR == null) {
+ synchronized (rs) {
+ if (rs.mSampler_WRAP_LINEAR_MIP_LINEAR == null) {
+ Builder b = new Builder(rs);
+ b.setMinification(Value.LINEAR_MIP_LINEAR);
+ b.setMagnification(Value.LINEAR);
+ b.setWrapS(Value.WRAP);
+ b.setWrapT(Value.WRAP);
+ rs.mSampler_WRAP_LINEAR_MIP_LINEAR = b.create();
+ }
+ }
}
return rs.mSampler_WRAP_LINEAR_MIP_LINEAR;
}
@@ -218,13 +242,17 @@
* @return Sampler
*/
public static Sampler MIRRORED_REPEAT_NEAREST(RenderScript rs) {
- if(rs.mSampler_MIRRORED_REPEAT_NEAREST == null) {
- Builder b = new Builder(rs);
- b.setMinification(Value.NEAREST);
- b.setMagnification(Value.NEAREST);
- b.setWrapS(Value.MIRRORED_REPEAT);
- b.setWrapT(Value.MIRRORED_REPEAT);
- rs.mSampler_MIRRORED_REPEAT_NEAREST = b.create();
+ if (rs.mSampler_MIRRORED_REPEAT_NEAREST == null) {
+ synchronized (rs) {
+ if (rs.mSampler_MIRRORED_REPEAT_NEAREST == null) {
+ Builder b = new Builder(rs);
+ b.setMinification(Value.NEAREST);
+ b.setMagnification(Value.NEAREST);
+ b.setWrapS(Value.MIRRORED_REPEAT);
+ b.setWrapT(Value.MIRRORED_REPEAT);
+ rs.mSampler_MIRRORED_REPEAT_NEAREST = b.create();
+ }
+ }
}
return rs.mSampler_MIRRORED_REPEAT_NEAREST;
}
@@ -238,13 +266,17 @@
* @return Sampler
*/
public static Sampler MIRRORED_REPEAT_LINEAR(RenderScript rs) {
- if(rs.mSampler_MIRRORED_REPEAT_LINEAR == null) {
- Builder b = new Builder(rs);
- b.setMinification(Value.LINEAR);
- b.setMagnification(Value.LINEAR);
- b.setWrapS(Value.MIRRORED_REPEAT);
- b.setWrapT(Value.MIRRORED_REPEAT);
- rs.mSampler_MIRRORED_REPEAT_LINEAR = b.create();
+ if (rs.mSampler_MIRRORED_REPEAT_LINEAR == null) {
+ synchronized (rs) {
+ if (rs.mSampler_MIRRORED_REPEAT_LINEAR == null) {
+ Builder b = new Builder(rs);
+ b.setMinification(Value.LINEAR);
+ b.setMagnification(Value.LINEAR);
+ b.setWrapS(Value.MIRRORED_REPEAT);
+ b.setWrapT(Value.MIRRORED_REPEAT);
+ rs.mSampler_MIRRORED_REPEAT_LINEAR = b.create();
+ }
+ }
}
return rs.mSampler_MIRRORED_REPEAT_LINEAR;
}
@@ -258,13 +290,17 @@
* @return Sampler
*/
public static Sampler MIRRORED_REPEAT_LINEAR_MIP_LINEAR(RenderScript rs) {
- if(rs.mSampler_MIRRORED_REPEAT_LINEAR_MIP_LINEAR == null) {
- Builder b = new Builder(rs);
- b.setMinification(Value.LINEAR_MIP_LINEAR);
- b.setMagnification(Value.LINEAR);
- b.setWrapS(Value.MIRRORED_REPEAT);
- b.setWrapT(Value.MIRRORED_REPEAT);
- rs.mSampler_MIRRORED_REPEAT_LINEAR_MIP_LINEAR = b.create();
+ if (rs.mSampler_MIRRORED_REPEAT_LINEAR_MIP_LINEAR == null) {
+ synchronized (rs) {
+ if (rs.mSampler_MIRRORED_REPEAT_LINEAR_MIP_LINEAR == null) {
+ Builder b = new Builder(rs);
+ b.setMinification(Value.LINEAR_MIP_LINEAR);
+ b.setMagnification(Value.LINEAR);
+ b.setWrapS(Value.MIRRORED_REPEAT);
+ b.setWrapT(Value.MIRRORED_REPEAT);
+ rs.mSampler_MIRRORED_REPEAT_LINEAR_MIP_LINEAR = b.create();
+ }
+ }
}
return rs.mSampler_MIRRORED_REPEAT_LINEAR_MIP_LINEAR;
}