Add low-level allocation creation functions

Bug: 23535985

Create spec for rs_allocation_create.rsh that'll have functions
to create Elements, Types and Allocations from a Script.

Add this new header to scriptc/rs_core.rsh.

Change-Id: If64fbe8e5ddce11952563d40a12b234ebae5c386
diff --git a/api/generate.sh b/api/generate.sh
index 55d3f04..b569f67 100755
--- a/api/generate.sh
+++ b/api/generate.sh
@@ -31,7 +31,7 @@
 #    This can be manually changed when cut&pasting the snippet into guide_toc.cs.
 # 3. rsIs/Clear/SetObject is documented in rs_object_info but also found in rs_graphics.
 #    The latter must appear after the former.
-./generator rs_core.spec rs_value_types.spec rs_object_types.spec rs_convert.spec rs_math.spec rs_vector_math.spec rs_matrix.spec rs_quaternion.spec rs_atomic.spec rs_time.spec rs_allocation_data.spec rs_object_info.spec rs_for_each.spec rs_io.spec rs_debug.spec rs_graphics.spec
+./generator rs_core.spec rs_value_types.spec rs_object_types.spec rs_convert.spec rs_math.spec rs_vector_math.spec rs_matrix.spec rs_quaternion.spec rs_atomic.spec rs_time.spec rs_allocation_create.spec rs_allocation_data.spec rs_object_info.spec rs_for_each.spec rs_io.spec rs_debug.spec rs_graphics.spec
 
 rm generator
 
diff --git a/api/rs_allocation_create.spec b/api/rs_allocation_create.spec
new file mode 100644
index 0000000..5ca5656
--- /dev/null
+++ b/api/rs_allocation_create.spec
@@ -0,0 +1,163 @@
+#
+# Copyright (C) 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+header:
+summary: Allocation Creation Functions
+description:
+ The functions below can be used to create Allocations from a Script.
+
+ These functions can be called directly or indirectly from an invokable
+ function.  If some control-flow path can result in a call to these functions
+ from a RenderScript kernel function, a compiler error will be generated.
+end:
+
+function: rsCreateElement
+version: UNRELEASED
+ret: rs_element
+arg: rs_data_type data_type, "Data type of the Element"
+summary: Creates an rs_element object of the specified data type
+description:
+  Creates an rs_element object of the specified data type.  The data kind of
+  the Element will be set to RS_KIND_USER and vector_width will be set to 1,
+  indicating non-vector.
+test: none
+end:
+
+function: rsCreateVectorElement
+version: UNRELEASED
+ret: rs_element
+arg: rs_data_type data_type, "Data type of the Element"
+arg: uint32_t vector_width, "Vector width (either 2, 3, or 4)"
+summary: Creates an rs_element object of the specified data type and vector width
+description:
+  Creates an rs_element object of the specified data type and vector width.
+  Value of vector_width must be 2, 3 or 4.  The data kind of the Element will
+  be set to RS_KIND_USER.
+test: none
+end:
+
+function: rsCreatePixelElement
+version: UNRELEASED
+ret: rs_element
+arg: rs_data_type data_type, "Data type of the Element"
+arg: rs_data_kind data_kind, "Data kind of the Element"
+summary: Creates an rs_element object of the specified data type and data kind
+description:
+  Creates an rs_element object of the specified data type and data kind.  The
+  vector_width of the Element will be set to 1, indicating non-vector.
+test: none
+end:
+
+function: rsCreateElement
+version: UNRELEASED
+internal: true
+ret: rs_element
+arg: int32_t data_type
+arg: int32_t data_kind
+arg: bool isNormalized
+arg: uint32_t vecSize
+test: none
+end:
+
+function: rsCreateType
+version: UNRELEASED
+ret: rs_type
+arg: rs_element element, "Element to be associated with the Type"
+arg: uint32_t dimX, "Size along the X dimension"
+arg: uint32_t dimY, "Size along the Y dimension"
+arg: uint32_t dimZ, "Size along the Z dimension"
+arg: bool mipmaps, "Flag indicating if the Type has a mipmap chain"
+arg: bool faces, "Flag indicating if the Type is a cubemap"
+arg: rs_yuv_format yuv_format, "YUV layout for the Type"
+summary: Creates an rs_type object with the specified Element and shape attributes
+description:
+  Creates an rs_type object with the specified Element and shape attributes.
+
+  dimX specifies the size of the X dimension.
+
+  dimY, if present and non-zero, indicates that the Y dimension is present and
+  indicates its size.
+
+  dimZ, if present and non-zero, indicates that the Z dimension is present and
+  indicates its size.
+
+  mipmaps indicates the presence of level of detail (LOD).
+
+  faces indicates the  presence of cubemap faces.
+
+  yuv_format indicates the associated YUV format (or RS_YUV_NONE).
+test: none
+end:
+
+function: rsCreateType
+version: UNRELEASED
+ret: rs_type
+arg: rs_element element
+arg: uint32_t dimX
+arg: uint32_t dimY
+arg: uint32_t dimZ
+test:none
+end:
+
+function: rsCreateType
+version: UNRELEASED
+ret: rs_type
+arg: rs_element element
+arg: uint32_t dimX
+arg: uint32_t dimY
+test:none
+end:
+
+function: rsCreateType
+version: UNRELEASED
+ret: rs_type
+arg: rs_element element
+arg: uint32_t dimX
+test:none
+end:
+
+function: rsCreateAllocation
+version: UNRELEASED
+ret: rs_allocation
+arg: rs_type type, "Type of the Allocation"
+arg: uint32_t usage, "Usage flag for the allocation"
+summary: Create an rs_allocation object of given Type.
+description:
+  Creates an rs_allocation object of the given Type and usage.
+
+  RS_ALLOCATION_USAGE_SCRIPT and RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE are the
+  only supported usage flags for Allocations created from within a RenderScript
+  Script.
+test: none
+end:
+
+function: rsCreateAllocation
+version: UNRELEASED
+ret: rs_allocation
+arg: rs_type type
+test: none
+end:
+
+function: rsCreateAllocation
+version: UNRELEASED
+internal: true
+ret: rs_allocation
+arg: rs_type type
+arg: rs_allocation_mipmap_control mipmap
+arg: uint32_t usages
+arg: void* ptr
+test: none
+end:
diff --git a/api/rs_core.spec b/api/rs_core.spec
index b4d083a..afc7cf4 100644
--- a/api/rs_core.spec
+++ b/api/rs_core.spec
@@ -38,6 +38,7 @@
  #include "rs_value_types.rsh"
  #include "rs_object_types.rsh"
 
+ #include "rs_allocation_create.rsh"
  #include "rs_allocation_data.rsh"
  #include "rs_atomic.rsh"
  #include "rs_convert.rsh"
diff --git a/api/rs_object_types.spec b/api/rs_object_types.spec
index d9f20d7..40aa12a 100644
--- a/api/rs_object_types.spec
+++ b/api/rs_object_types.spec
@@ -182,6 +182,20 @@
  See the <a href='http://developer.android.com/reference/android/renderscript/Element.html#createPixel(android.renderscript.RenderScript,%20android.renderscript.Element.DataType, android.renderscript.Element.DataKind)'>Element.createPixel()</a> method.
 end:
 
+type: rs_yuv_format
+version: UNRELEASED
+enum:
+value: RS_YUV_NONE = 0
+value: RS_YUV_YV12 = 0x32315659
+value: RS_YUV_NV21 = 0x11
+value: RS_YUV_420_888 = 0x23
+summary: YUV format
+description:
+  Android YUV formats that can be associated with a RenderScript Type.
+
+  See <a href='http://developer.android.com/reference/android/graphics/ImageFormat.html'>android.graphics.ImageFormat</a> for a description of each format.
+end:
+
 type: rs_sampler_value
 version: 16
 enum: