Merge "Moving libRS"
diff --git a/CleanSpec.mk b/CleanSpec.mk
index d74d7b1..1cd5d01 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -119,6 +119,13 @@
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/media/audio/)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/content)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/src/android/content)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/*/src/renderscript)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/*/src/renderscript)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/*/src/RenderScript.stamp)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/*/src/RenderScript.stamp)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libRS_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libRSDriver_intermediates)
+$(call add-clean-step, rm -rf $(OUT_DIR)/host/$(HOST_PREBUILT_TAG)/obj/STATIC_LIBRARIES/libRS_intermediates)
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
diff --git a/graphics/jni/Android.mk b/graphics/jni/Android.mk
index ca69e1e..e85a23c 100644
--- a/graphics/jni/Android.mk
+++ b/graphics/jni/Android.mk
@@ -21,7 +21,7 @@
LOCAL_C_INCLUDES += \
$(JNI_H_INCLUDE) \
- $(LOCAL_PATH)/../../libs/rs \
+ frameworks/rs \
$(rs_generated_include_dir) \
$(call include-path-for, corecg graphics)
diff --git a/libs/rs/Allocation.cpp b/libs/rs/Allocation.cpp
deleted file mode 100644
index e37d5de..0000000
--- a/libs/rs/Allocation.cpp
+++ /dev/null
@@ -1,468 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#define LOG_TAG "libRS_cpp"
-
-#include <utils/Log.h>
-#include <malloc.h>
-
-#include "RenderScript.h"
-#include "Element.h"
-#include "Type.h"
-#include "Allocation.h"
-
-
-void * Allocation::getIDSafe() const {
- //if (mAdaptedAllocation != NULL) {
- //return mAdaptedAllocation.getID();
- //}
- return getID();
-}
-
-void Allocation::updateCacheInfo(const Type *t) {
- mCurrentDimX = t->getX();
- mCurrentDimY = t->getY();
- mCurrentDimZ = t->getZ();
- mCurrentCount = mCurrentDimX;
- if (mCurrentDimY > 1) {
- mCurrentCount *= mCurrentDimY;
- }
- if (mCurrentDimZ > 1) {
- mCurrentCount *= mCurrentDimZ;
- }
-}
-
-Allocation::Allocation(void *id, RenderScript *rs, const Type *t, uint32_t usage) : BaseObj(id, rs) {
- if ((usage & ~(RS_ALLOCATION_USAGE_SCRIPT |
- RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE |
- RS_ALLOCATION_USAGE_GRAPHICS_VERTEX |
- RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS |
- RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET |
- RS_ALLOCATION_USAGE_IO_INPUT |
- RS_ALLOCATION_USAGE_IO_OUTPUT)) != 0) {
- ALOGE("Unknown usage specified.");
- }
-
- if ((usage & RS_ALLOCATION_USAGE_IO_INPUT) != 0) {
- mWriteAllowed = false;
- if ((usage & ~(RS_ALLOCATION_USAGE_IO_INPUT |
- RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE |
- RS_ALLOCATION_USAGE_SCRIPT)) != 0) {
- ALOGE("Invalid usage combination.");
- }
- }
-
- mType = t;
- mUsage = usage;
-
- if (t != NULL) {
- updateCacheInfo(t);
- }
-}
-
-void Allocation::validateIsInt32() {
- RsDataType dt = mType->getElement()->getDataType();
- if ((dt == RS_TYPE_SIGNED_32) || (dt == RS_TYPE_UNSIGNED_32)) {
- return;
- }
- ALOGE("32 bit integer source does not match allocation type %i", dt);
-}
-
-void Allocation::validateIsInt16() {
- RsDataType dt = mType->getElement()->getDataType();
- if ((dt == RS_TYPE_SIGNED_16) || (dt == RS_TYPE_UNSIGNED_16)) {
- return;
- }
- ALOGE("16 bit integer source does not match allocation type %i", dt);
-}
-
-void Allocation::validateIsInt8() {
- RsDataType dt = mType->getElement()->getDataType();
- if ((dt == RS_TYPE_SIGNED_8) || (dt == RS_TYPE_UNSIGNED_8)) {
- return;
- }
- ALOGE("8 bit integer source does not match allocation type %i", dt);
-}
-
-void Allocation::validateIsFloat32() {
- RsDataType dt = mType->getElement()->getDataType();
- if (dt == RS_TYPE_FLOAT_32) {
- return;
- }
- ALOGE("32 bit float source does not match allocation type %i", dt);
-}
-
-void Allocation::validateIsObject() {
- RsDataType dt = mType->getElement()->getDataType();
- if ((dt == RS_TYPE_ELEMENT) ||
- (dt == RS_TYPE_TYPE) ||
- (dt == RS_TYPE_ALLOCATION) ||
- (dt == RS_TYPE_SAMPLER) ||
- (dt == RS_TYPE_SCRIPT) ||
- (dt == RS_TYPE_MESH) ||
- (dt == RS_TYPE_PROGRAM_FRAGMENT) ||
- (dt == RS_TYPE_PROGRAM_VERTEX) ||
- (dt == RS_TYPE_PROGRAM_RASTER) ||
- (dt == RS_TYPE_PROGRAM_STORE)) {
- return;
- }
- ALOGE("Object source does not match allocation type %i", dt);
-}
-
-void Allocation::updateFromNative() {
- BaseObj::updateFromNative();
-
- const void *typeID = rsaAllocationGetType(mRS->mContext, getID());
- if(typeID != NULL) {
- const Type *old = mType;
- Type *t = new Type((void *)typeID, mRS);
- t->updateFromNative();
- updateCacheInfo(t);
- mType = t;
- delete old;
- }
-}
-
-void Allocation::syncAll(RsAllocationUsageType srcLocation) {
- switch (srcLocation) {
- case RS_ALLOCATION_USAGE_SCRIPT:
- case RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS:
- case RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE:
- case RS_ALLOCATION_USAGE_GRAPHICS_VERTEX:
- break;
- default:
- ALOGE("Source must be exactly one usage type.");
- }
- rsAllocationSyncAll(mRS->mContext, getIDSafe(), srcLocation);
-}
-
-void Allocation::ioSendOutput() {
- if ((mUsage & RS_ALLOCATION_USAGE_IO_OUTPUT) == 0) {
- ALOGE("Can only send buffer if IO_OUTPUT usage specified.");
- }
- rsAllocationIoSend(mRS->mContext, getID());
-}
-
-void Allocation::ioGetInput() {
- if ((mUsage & RS_ALLOCATION_USAGE_IO_INPUT) == 0) {
- ALOGE("Can only send buffer if IO_OUTPUT usage specified.");
- }
- rsAllocationIoReceive(mRS->mContext, getID());
-}
-
-/*
-void copyFrom(BaseObj[] d) {
- mRS.validate();
- validateIsObject();
- if (d.length != mCurrentCount) {
- ALOGE("Array size mismatch, allocation sizeX = " +
- mCurrentCount + ", array length = " + d.length);
- }
- int i[] = new int[d.length];
- for (int ct=0; ct < d.length; ct++) {
- i[ct] = d[ct].getID();
- }
- copy1DRangeFromUnchecked(0, mCurrentCount, i);
-}
-*/
-
-
-/*
-void Allocation::setFromFieldPacker(int xoff, FieldPacker fp) {
- mRS.validate();
- int eSize = mType.mElement.getSizeBytes();
- final byte[] data = fp.getData();
-
- int count = data.length / eSize;
- if ((eSize * count) != data.length) {
- ALOGE("Field packer length " + data.length +
- " not divisible by element size " + eSize + ".");
- }
- copy1DRangeFromUnchecked(xoff, count, data);
-}
-
-void setFromFieldPacker(int xoff, int component_number, FieldPacker fp) {
- mRS.validate();
- if (component_number >= mType.mElement.mElements.length) {
- ALOGE("Component_number " + component_number + " out of range.");
- }
- if(xoff < 0) {
- ALOGE("Offset must be >= 0.");
- }
-
- final byte[] data = fp.getData();
- int eSize = mType.mElement.mElements[component_number].getSizeBytes();
- eSize *= mType.mElement.mArraySizes[component_number];
-
- if (data.length != eSize) {
- ALOGE("Field packer sizelength " + data.length +
- " does not match component size " + eSize + ".");
- }
-
- mRS.nAllocationElementData1D(getIDSafe(), xoff, mSelectedLOD,
- component_number, data, data.length);
-}
-*/
-
-void Allocation::generateMipmaps() {
- rsAllocationGenerateMipmaps(mRS->mContext, getID());
-}
-
-void Allocation::copy1DRangeFromUnchecked(uint32_t off, size_t count, const void *data, size_t dataLen) {
- if(count < 1) {
- ALOGE("Count must be >= 1.");
- return;
- }
- if((off + count) > mCurrentCount) {
- ALOGE("Overflow, Available count %zu, got %zu at offset %zu.", mCurrentCount, count, off);
- return;
- }
- if((count * mType->getElement()->getSizeBytes()) > dataLen) {
- ALOGE("Array too small for allocation type.");
- return;
- }
-
- rsAllocation1DData(mRS->mContext, getIDSafe(), off, mSelectedLOD, count, data, dataLen);
-}
-
-void Allocation::copy1DRangeFrom(uint32_t off, size_t count, const int32_t *d, size_t dataLen) {
- validateIsInt32();
- copy1DRangeFromUnchecked(off, count, d, dataLen);
-}
-
-void Allocation::copy1DRangeFrom(uint32_t off, size_t count, const int16_t *d, size_t dataLen) {
- validateIsInt16();
- copy1DRangeFromUnchecked(off, count, d, dataLen);
-}
-
-void Allocation::copy1DRangeFrom(uint32_t off, size_t count, const int8_t *d, size_t dataLen) {
- validateIsInt8();
- copy1DRangeFromUnchecked(off, count, d, dataLen);
-}
-
-void Allocation::copy1DRangeFrom(uint32_t off, size_t count, const float *d, size_t dataLen) {
- validateIsFloat32();
- copy1DRangeFromUnchecked(off, count, d, dataLen);
-}
-
-void Allocation::copy1DRangeFrom(uint32_t off, size_t count, const Allocation *data, uint32_t dataOff) {
- rsAllocationCopy2DRange(mRS->mContext, getIDSafe(), off, 0,
- mSelectedLOD, mSelectedFace,
- count, 1, data->getIDSafe(), dataOff, 0,
- data->mSelectedLOD, data->mSelectedFace);
-}
-
-void Allocation::validate2DRange(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h) {
- if (mAdaptedAllocation != NULL) {
-
- } else {
- if (((xoff + w) > mCurrentDimX) || ((yoff + h) > mCurrentDimY)) {
- ALOGE("Updated region larger than allocation.");
- }
- }
-}
-
-void Allocation::copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
- const int8_t *data, size_t dataLen) {
- validate2DRange(xoff, yoff, w, h);
- rsAllocation2DData(mRS->mContext, getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace,
- w, h, data, dataLen);
-}
-
-void Allocation::copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
- const int16_t *data, size_t dataLen) {
- validate2DRange(xoff, yoff, w, h);
- rsAllocation2DData(mRS->mContext, getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace,
- w, h, data, dataLen);
-}
-
-void Allocation::copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
- const int32_t *data, size_t dataLen) {
- validate2DRange(xoff, yoff, w, h);
- rsAllocation2DData(mRS->mContext, getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace,
- w, h, data, dataLen);
-}
-
-void Allocation::copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
- const float *data, size_t dataLen) {
- validate2DRange(xoff, yoff, w, h);
- rsAllocation2DData(mRS->mContext, getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace,
- w, h, data, dataLen);
-}
-
-void Allocation::copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
- const Allocation *data, size_t dataLen,
- uint32_t dataXoff, uint32_t dataYoff) {
- validate2DRange(xoff, yoff, w, h);
- rsAllocationCopy2DRange(mRS->mContext, getIDSafe(), xoff, yoff,
- mSelectedLOD, mSelectedFace,
- w, h, data->getIDSafe(), dataXoff, dataYoff,
- data->mSelectedLOD, data->mSelectedFace);
-}
-
-/*
-void copyTo(byte[] d) {
- validateIsInt8();
- mRS.validate();
- mRS.nAllocationRead(getID(), d);
-}
-
-void copyTo(short[] d) {
- validateIsInt16();
- mRS.validate();
- mRS.nAllocationRead(getID(), d);
-}
-
-void copyTo(int[] d) {
- validateIsInt32();
- mRS.validate();
- mRS.nAllocationRead(getID(), d);
-}
-
-void copyTo(float[] d) {
- validateIsFloat32();
- mRS.validate();
- mRS.nAllocationRead(getID(), d);
-}
-
-void resize(int dimX) {
- if ((mType.getY() > 0)|| (mType.getZ() > 0) || mType.hasFaces() || mType.hasMipmaps()) {
- throw new RSInvalidStateException("Resize only support for 1D allocations at this time.");
- }
- mRS.nAllocationResize1D(getID(), dimX);
- mRS.finish(); // Necessary because resize is fifoed and update is async.
-
- int typeID = mRS.nAllocationGetType(getID());
- mType = new Type(typeID, mRS);
- mType.updateFromNative();
- updateCacheInfo(mType);
-}
-
-void resize(int dimX, int dimY) {
- if ((mType.getZ() > 0) || mType.hasFaces() || mType.hasMipmaps()) {
- throw new RSInvalidStateException(
- "Resize only support for 2D allocations at this time.");
- }
- if (mType.getY() == 0) {
- throw new RSInvalidStateException(
- "Resize only support for 2D allocations at this time.");
- }
- mRS.nAllocationResize2D(getID(), dimX, dimY);
- mRS.finish(); // Necessary because resize is fifoed and update is async.
-
- int typeID = mRS.nAllocationGetType(getID());
- mType = new Type(typeID, mRS);
- mType.updateFromNative();
- updateCacheInfo(mType);
-}
-*/
-
-
-Allocation *Allocation::createTyped(RenderScript *rs, const Type *type,
- RsAllocationMipmapControl mips, uint32_t usage) {
- void *id = rsAllocationCreateTyped(rs->mContext, type->getID(), mips, usage, 0);
- if (id == 0) {
- ALOGE("Allocation creation failed.");
- return NULL;
- }
- return new Allocation(id, rs, type, usage);
-}
-
-Allocation *Allocation::createTyped(RenderScript *rs, const Type *type,
- RsAllocationMipmapControl mips, uint32_t usage, void *pointer) {
- void *id = rsAllocationCreateTyped(rs->mContext, type->getID(), mips, usage, (uint32_t)pointer);
- if (id == 0) {
- ALOGE("Allocation creation failed.");
- }
- return new Allocation(id, rs, type, usage);
-}
-
-Allocation *Allocation::createTyped(RenderScript *rs, const Type *type, uint32_t usage) {
- return createTyped(rs, type, RS_ALLOCATION_MIPMAP_NONE, usage);
-}
-
-Allocation *Allocation::createSized(RenderScript *rs, const Element *e, size_t count, uint32_t usage) {
- Type::Builder b(rs, e);
- b.setX(count);
- const Type *t = b.create();
-
- void *id = rsAllocationCreateTyped(rs->mContext, t->getID(), RS_ALLOCATION_MIPMAP_NONE, usage, 0);
- if (id == 0) {
- ALOGE("Allocation creation failed.");
- }
- return new Allocation(id, rs, t, usage);
-}
-
-
-/*
-SurfaceTexture getSurfaceTexture() {
- if ((mUsage & USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE) == 0) {
- throw new RSInvalidStateException("Allocation is not a surface texture.");
- }
-
- int id = mRS.nAllocationGetSurfaceTextureID(getID());
- return new SurfaceTexture(id);
-
-}
-
-void setSurfaceTexture(SurfaceTexture sur) {
- if ((mUsage & USAGE_IO_OUTPUT) == 0) {
- throw new RSInvalidStateException("Allocation is not USAGE_IO_OUTPUT.");
- }
-
- mRS.validate();
- mRS.nAllocationSetSurfaceTexture(getID(), sur);
-}
-
-
-static Allocation createFromBitmapResource(RenderScript rs,
- Resources res,
- int id,
- MipmapControl mips,
- int usage) {
-
- rs.validate();
- Bitmap b = BitmapFactory.decodeResource(res, id);
- Allocation alloc = createFromBitmap(rs, b, mips, usage);
- b.recycle();
- return alloc;
-}
-
-static Allocation createFromBitmapResource(RenderScript rs,
- Resources res,
- int id) {
- return createFromBitmapResource(rs, res, id,
- MipmapControl.MIPMAP_NONE,
- USAGE_GRAPHICS_TEXTURE);
-}
-
-static Allocation createFromString(RenderScript rs,
- String str,
- int usage) {
- rs.validate();
- byte[] allocArray = NULL;
- try {
- allocArray = str.getBytes("UTF-8");
- Allocation alloc = Allocation.createSized(rs, Element.U8(rs), allocArray.length, usage);
- alloc.copyFrom(allocArray);
- return alloc;
- }
- catch (Exception e) {
- throw new RSRuntimeException("Could not convert string to utf-8.");
- }
-}
-*/
-
diff --git a/libs/rs/Allocation.h b/libs/rs/Allocation.h
deleted file mode 100644
index c9e00a4..0000000
--- a/libs/rs/Allocation.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2008-2012 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.
- */
-
-#ifndef __ANDROID_ALLOCATION_H__
-#define __ANDROID_ALLOCATION_H__
-
-#include <pthread.h>
-#include <rs.h>
-
-#include "RenderScript.h"
-#include "Type.h"
-#include "Element.h"
-
-class Allocation : public BaseObj {
-protected:
- const Type *mType;
- uint32_t mUsage;
- Allocation *mAdaptedAllocation;
-
- bool mConstrainedLOD;
- bool mConstrainedFace;
- bool mConstrainedY;
- bool mConstrainedZ;
- bool mReadAllowed;
- bool mWriteAllowed;
- uint32_t mSelectedY;
- uint32_t mSelectedZ;
- uint32_t mSelectedLOD;
- RsAllocationCubemapFace mSelectedFace;
-
- uint32_t mCurrentDimX;
- uint32_t mCurrentDimY;
- uint32_t mCurrentDimZ;
- uint32_t mCurrentCount;
-
-
- void * getIDSafe() const;
- void updateCacheInfo(const Type *t);
-
- Allocation(void *id, RenderScript *rs, const Type *t, uint32_t usage);
-
- void validateIsInt32();
- void validateIsInt16();
- void validateIsInt8();
- void validateIsFloat32();
- void validateIsObject();
-
- virtual void updateFromNative();
-
- void validate2DRange(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h);
-
-public:
- const Type * getType() {
- return mType;
- }
-
- void syncAll(RsAllocationUsageType srcLocation);
- void ioSendOutput();
- void ioGetInput();
-
- //void copyFrom(BaseObj[] d);
- //void copyFromUnchecked(int[] d);
- //void copyFromUnchecked(short[] d);
- //void copyFromUnchecked(byte[] d);
- //void copyFromUnchecked(float[] d);
- //void copyFrom(int[] d);
- //void copyFrom(short[] d);
- //void copyFrom(byte[] d);
- //void copyFrom(float[] d);
- //void setFromFieldPacker(int xoff, FieldPacker fp);
- //void setFromFieldPacker(int xoff, int component_number, FieldPacker fp);
- void generateMipmaps();
- void copy1DRangeFromUnchecked(uint32_t off, size_t count, const void *data, size_t dataLen);
- void copy1DRangeFrom(uint32_t off, size_t count, const int32_t* d, size_t dataLen);
- void copy1DRangeFrom(uint32_t off, size_t count, const int16_t* d, size_t dataLen);
- void copy1DRangeFrom(uint32_t off, size_t count, const int8_t* d, size_t dataLen);
- void copy1DRangeFrom(uint32_t off, size_t count, const float* d, size_t dataLen);
- void copy1DRangeFrom(uint32_t off, size_t count, const Allocation *data, uint32_t dataOff);
-
- void copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
- const int32_t *data, size_t dataLen);
- void copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
- const int16_t *data, size_t dataLen);
- void copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
- const int8_t *data, size_t dataLen);
- void copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
- const float *data, size_t dataLen);
- void copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
- const Allocation *data, size_t dataLen,
- uint32_t dataXoff, uint32_t dataYoff);
-
- //void copyTo(byte[] d);
- //void copyTo(short[] d);
- //void copyTo(int[] d);
- //void copyTo(float[] d);
- void resize(int dimX);
- void resize(int dimX, int dimY);
-
- static Allocation *createTyped(RenderScript *rs, const Type *type,
- RsAllocationMipmapControl mips, uint32_t usage);
- static Allocation *createTyped(RenderScript *rs, const Type *type,
- RsAllocationMipmapControl mips, uint32_t usage, void * pointer);
-
- static Allocation *createTyped(RenderScript *rs, const Type *type,
- uint32_t usage = RS_ALLOCATION_USAGE_SCRIPT);
- static Allocation *createSized(RenderScript *rs, const Element *e, size_t count,
- uint32_t usage = RS_ALLOCATION_USAGE_SCRIPT);
- //SurfaceTexture *getSurfaceTexture();
- //void setSurfaceTexture(SurfaceTexture *sur);
-
-};
-
-#endif
diff --git a/libs/rs/Android.mk b/libs/rs/Android.mk
deleted file mode 100644
index f92741c..0000000
--- a/libs/rs/Android.mk
+++ /dev/null
@@ -1,238 +0,0 @@
-
-LOCAL_PATH:=$(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := libRSDriver
-
-LOCAL_SRC_FILES:= \
- driver/rsdAllocation.cpp \
- driver/rsdBcc.cpp \
- driver/rsdCore.cpp \
- driver/rsdFrameBuffer.cpp \
- driver/rsdFrameBufferObj.cpp \
- driver/rsdGL.cpp \
- driver/rsdMesh.cpp \
- driver/rsdMeshObj.cpp \
- driver/rsdPath.cpp \
- driver/rsdProgram.cpp \
- driver/rsdProgramRaster.cpp \
- driver/rsdProgramStore.cpp \
- driver/rsdRuntimeMath.cpp \
- driver/rsdRuntimeStubs.cpp \
- driver/rsdSampler.cpp \
- driver/rsdShader.cpp \
- driver/rsdShaderCache.cpp \
- driver/rsdVertexArray.cpp
-
-LOCAL_SHARED_LIBRARIES += libz libcutils libutils libEGL libGLESv1_CM libGLESv2
-LOCAL_SHARED_LIBRARIES += libbcc libbcinfo libgui
-
-LOCAL_C_INCLUDES += external/zlib dalvik
-LOCAL_C_INCLUDES += frameworks/compile/libbcc/include
-
-LOCAL_CFLAGS += -Werror -Wall -Wno-unused-parameter -Wno-unused-variable
-
-LOCAL_LDLIBS := -lpthread -ldl
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_STATIC_LIBRARY)
-
-# Build rsg-generator ====================
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := rsg-generator
-
-# These symbols are normally defined by BUILD_XXX, but we need to define them
-# here so that local-intermediates-dir works.
-
-LOCAL_IS_HOST_MODULE := true
-LOCAL_MODULE_CLASS := EXECUTABLES
-intermediates := $(local-intermediates-dir)
-
-LOCAL_SRC_FILES:= \
- spec.l \
- rsg_generator.c
-
-include $(BUILD_HOST_EXECUTABLE)
-
-# TODO: This should go into build/core/config.mk
-RSG_GENERATOR:=$(LOCAL_BUILT_MODULE)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := libRS
-
-LOCAL_MODULE_CLASS := SHARED_LIBRARIES
-intermediates:= $(local-intermediates-dir)
-
-# Generate custom headers
-
-GEN := $(addprefix $(intermediates)/, \
- rsgApiStructs.h \
- rsgApiFuncDecl.h \
- )
-
-$(GEN) : PRIVATE_PATH := $(LOCAL_PATH)
-$(GEN) : PRIVATE_CUSTOM_TOOL = $(RSG_GENERATOR) $< $@ <$(PRIVATE_PATH)/rs.spec
-$(GEN) : $(RSG_GENERATOR) $(LOCAL_PATH)/rs.spec
-$(GEN): $(intermediates)/%.h : $(LOCAL_PATH)/%.h.rsg
- $(transform-generated-source)
-
-# used in jni/Android.mk
-rs_generated_source += $(GEN)
-LOCAL_GENERATED_SOURCES += $(GEN)
-
-# Generate custom source files
-
-GEN := $(addprefix $(intermediates)/, \
- rsgApi.cpp \
- rsgApiReplay.cpp \
- )
-
-$(GEN) : PRIVATE_PATH := $(LOCAL_PATH)
-$(GEN) : PRIVATE_CUSTOM_TOOL = $(RSG_GENERATOR) $< $@ <$(PRIVATE_PATH)/rs.spec
-$(GEN) : $(RSG_GENERATOR) $(LOCAL_PATH)/rs.spec
-$(GEN): $(intermediates)/%.cpp : $(LOCAL_PATH)/%.cpp.rsg
- $(transform-generated-source)
-
-# used in jni/Android.mk
-rs_generated_source += $(GEN)
-
-LOCAL_GENERATED_SOURCES += $(GEN)
-
-LOCAL_SRC_FILES:= \
- rsAdapter.cpp \
- rsAllocation.cpp \
- rsAnimation.cpp \
- rsComponent.cpp \
- rsContext.cpp \
- rsDevice.cpp \
- rsElement.cpp \
- rsFBOCache.cpp \
- rsFifoSocket.cpp \
- rsFileA3D.cpp \
- rsFont.cpp \
- rsObjectBase.cpp \
- rsMatrix2x2.cpp \
- rsMatrix3x3.cpp \
- rsMatrix4x4.cpp \
- rsMesh.cpp \
- rsMutex.cpp \
- rsPath.cpp \
- rsProgram.cpp \
- rsProgramFragment.cpp \
- rsProgramStore.cpp \
- rsProgramRaster.cpp \
- rsProgramVertex.cpp \
- rsSampler.cpp \
- rsScript.cpp \
- rsScriptC.cpp \
- rsScriptC_Lib.cpp \
- rsScriptC_LibGL.cpp \
- rsSignal.cpp \
- rsStream.cpp \
- rsThreadIO.cpp \
- rsType.cpp \
- RenderScript.cpp \
- BaseObj.cpp \
- Element.cpp \
- Type.cpp \
- Allocation.cpp \
- Script.cpp \
- ScriptC.cpp
-
-LOCAL_SHARED_LIBRARIES += libz libcutils libutils libEGL libGLESv1_CM libGLESv2 libbcc
-LOCAL_SHARED_LIBRARIES += libui libbcinfo libgui
-
-LOCAL_STATIC_LIBRARIES := libdex libft2 libRSDriver
-
-LOCAL_C_INCLUDES += external/freetype/include external/zlib dalvik
-LOCAL_C_INCLUDES += frameworks/compile/libbcc/include
-
-LOCAL_CFLAGS += -Werror -Wall -Wno-unused-parameter -Wno-unused-variable
-
-LOCAL_LDLIBS := -lpthread -ldl
-LOCAL_MODULE:= libRS
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
-
-# Now build a host version for serialization
-include $(CLEAR_VARS)
-LOCAL_MODULE:= libRS
-LOCAL_MODULE_TAGS := optional
-
-intermediates := $(call intermediates-dir-for,STATIC_LIBRARIES,libRS,HOST,)
-
-# Generate custom headers
-
-GEN := $(addprefix $(intermediates)/, \
- rsgApiStructs.h \
- rsgApiFuncDecl.h \
- )
-
-$(GEN) : PRIVATE_PATH := $(LOCAL_PATH)
-$(GEN) : PRIVATE_CUSTOM_TOOL = $(RSG_GENERATOR) $< $@ <$(PRIVATE_PATH)/rs.spec
-$(GEN) : $(RSG_GENERATOR) $(LOCAL_PATH)/rs.spec
-$(GEN): $(intermediates)/%.h : $(LOCAL_PATH)/%.h.rsg
- $(transform-generated-source)
-
-LOCAL_GENERATED_SOURCES += $(GEN)
-
-# Generate custom source files
-
-GEN := $(addprefix $(intermediates)/, \
- rsgApi.cpp \
- rsgApiReplay.cpp \
- )
-
-$(GEN) : PRIVATE_PATH := $(LOCAL_PATH)
-$(GEN) : PRIVATE_CUSTOM_TOOL = $(RSG_GENERATOR) $< $@ <$(PRIVATE_PATH)/rs.spec
-$(GEN) : $(RSG_GENERATOR) $(LOCAL_PATH)/rs.spec
-$(GEN): $(intermediates)/%.cpp : $(LOCAL_PATH)/%.cpp.rsg
- $(transform-generated-source)
-
-LOCAL_GENERATED_SOURCES += $(GEN)
-
-LOCAL_CFLAGS += -Werror -Wall -Wno-unused-parameter -Wno-unused-variable
-LOCAL_CFLAGS += -DANDROID_RS_SERIALIZE
-LOCAL_CFLAGS += -fPIC
-
-LOCAL_SRC_FILES:= \
- rsAdapter.cpp \
- rsAllocation.cpp \
- rsAnimation.cpp \
- rsComponent.cpp \
- rsContext.cpp \
- rsDevice.cpp \
- rsElement.cpp \
- rsFBOCache.cpp \
- rsFifoSocket.cpp \
- rsFileA3D.cpp \
- rsFont.cpp \
- rsObjectBase.cpp \
- rsMatrix2x2.cpp \
- rsMatrix3x3.cpp \
- rsMatrix4x4.cpp \
- rsMesh.cpp \
- rsMutex.cpp \
- rsPath.cpp \
- rsProgram.cpp \
- rsProgramFragment.cpp \
- rsProgramStore.cpp \
- rsProgramRaster.cpp \
- rsProgramVertex.cpp \
- rsSampler.cpp \
- rsScript.cpp \
- rsScriptC.cpp \
- rsScriptC_Lib.cpp \
- rsScriptC_LibGL.cpp \
- rsSignal.cpp \
- rsStream.cpp \
- rsThreadIO.cpp \
- rsType.cpp
-
-LOCAL_STATIC_LIBRARIES := libcutils libutils
-
-LOCAL_LDLIBS := -lpthread
-
-include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/libs/rs/BaseObj.cpp b/libs/rs/BaseObj.cpp
deleted file mode 100644
index 82e51e7..0000000
--- a/libs/rs/BaseObj.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2008-2012 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.
- */
-
-#define LOG_TAG "libRS_cpp"
-
-#include <rs.h>
-
-#include "RenderScript.h"
-#include "BaseObj.h"
-
-void * BaseObj::getID() const {
- if (mID == NULL) {
- ALOGE("Internal error: Object id 0.");
- }
- return mID;
-}
-
-void * BaseObj::getObjID(const BaseObj *o) {
- return o == NULL ? NULL : o->getID();
-}
-
-
-BaseObj::BaseObj(void *id, RenderScript *rs) {
- mRS = rs;
- mID = id;
-}
-
-void BaseObj::checkValid() {
- if (mID == 0) {
- ALOGE("Invalid object.");
- }
-}
-
-BaseObj::~BaseObj() {
- rsObjDestroy(mRS->mContext, mID);
- mRS = NULL;
- mID = NULL;
-}
-
-void BaseObj::updateFromNative() {
- const char *name = NULL;
- rsaGetName(mRS, mID, &name);
- mName = name;
-}
-
-bool BaseObj::equals(const BaseObj *obj) {
- // Early-out check to see if both BaseObjs are actually the same
- if (this == obj)
- return true;
- return mID == obj->mID;
-}
-
-
-
diff --git a/libs/rs/BaseObj.h b/libs/rs/BaseObj.h
deleted file mode 100644
index 79761b1..0000000
--- a/libs/rs/BaseObj.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2008-2012 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.
- */
-
-#ifndef __ANDROID_BASE_OBJ_H__
-#define __ANDROID_BASE_OBJ_H__
-
-
-#include <pthread.h>
-#include <rs.h>
-
-#include "RenderScript.h"
-
-class BaseObj {
-protected:
- friend class Element;
- friend class Type;
- friend class Allocation;
- friend class Script;
- friend class ScriptC;
-
- void *mID;
- RenderScript *mRS;
- android::String8 mName;
-
- void * getID() const;
-
- BaseObj(void *id, RenderScript *rs);
- void checkValid();
-
- static void * getObjID(const BaseObj *o);
-
-public:
-
- virtual ~BaseObj();
- virtual void updateFromNative();
- virtual bool equals(const BaseObj *obj);
-};
-
-#endif
diff --git a/libs/rs/Element.cpp b/libs/rs/Element.cpp
deleted file mode 100644
index f318d40..0000000
--- a/libs/rs/Element.cpp
+++ /dev/null
@@ -1,428 +0,0 @@
-/*
- * Copyright (C) 2008-2012 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.
- */
-
-#define LOG_TAG "libRS_cpp"
-
-#include <utils/Log.h>
-#include <malloc.h>
-#include <string.h>
-
-#include "RenderScript.h"
-#include "Element.h"
-
-
-const Element * Element::getSubElement(uint32_t index) {
- if (!mVisibleElementMap.size()) {
- mRS->throwError("Element contains no sub-elements");
- }
- if (index >= mVisibleElementMap.size()) {
- mRS->throwError("Illegal sub-element index");
- }
- return mElements[mVisibleElementMap[index]];
-}
-
-const char * Element::getSubElementName(uint32_t index) {
- if (!mVisibleElementMap.size()) {
- mRS->throwError("Element contains no sub-elements");
- }
- if (index >= mVisibleElementMap.size()) {
- mRS->throwError("Illegal sub-element index");
- }
- return mElementNames[mVisibleElementMap[index]];
-}
-
-size_t Element::getSubElementArraySize(uint32_t index) {
- if (!mVisibleElementMap.size()) {
- mRS->throwError("Element contains no sub-elements");
- }
- if (index >= mVisibleElementMap.size()) {
- mRS->throwError("Illegal sub-element index");
- }
- return mArraySizes[mVisibleElementMap[index]];
-}
-
-uint32_t Element::getSubElementOffsetBytes(uint32_t index) {
- if (mVisibleElementMap.size()) {
- mRS->throwError("Element contains no sub-elements");
- }
- if (index >= mVisibleElementMap.size()) {
- mRS->throwError("Illegal sub-element index");
- }
- return mOffsetInBytes[mVisibleElementMap[index]];
-}
-
-
-#define CREATE_USER(N, T) const Element * Element::N(RenderScript *rs) { \
- return createUser(rs, RS_TYPE_##T); \
-}
-CREATE_USER(BOOLEAN, BOOLEAN);
-CREATE_USER(U8, UNSIGNED_8);
-CREATE_USER(I8, SIGNED_8);
-CREATE_USER(U16, UNSIGNED_16);
-CREATE_USER(I16, SIGNED_16);
-CREATE_USER(U32, UNSIGNED_32);
-CREATE_USER(I32, SIGNED_32);
-CREATE_USER(U64, UNSIGNED_64);
-CREATE_USER(I64, SIGNED_64);
-CREATE_USER(F32, FLOAT_32);
-CREATE_USER(F64, FLOAT_64);
-CREATE_USER(ELEMENT, ELEMENT);
-CREATE_USER(TYPE, TYPE);
-CREATE_USER(ALLOCATION, ALLOCATION);
-CREATE_USER(SAMPLER, SAMPLER);
-CREATE_USER(SCRIPT, SCRIPT);
-CREATE_USER(MESH, MESH);
-CREATE_USER(PROGRAM_FRAGMENT, PROGRAM_FRAGMENT);
-CREATE_USER(PROGRAM_VERTEX, PROGRAM_VERTEX);
-CREATE_USER(PROGRAM_RASTER, PROGRAM_RASTER);
-CREATE_USER(PROGRAM_STORE, PROGRAM_STORE);
-CREATE_USER(MATRIX_4X4, MATRIX_4X4);
-CREATE_USER(MATRIX_3X3, MATRIX_3X3);
-CREATE_USER(MATRIX_2X2, MATRIX_2X2);
-
-#define CREATE_PIXEL(N, T, K) const Element * Element::N(RenderScript *rs) { \
- return createPixel(rs, RS_TYPE_##T, RS_KIND_##K); \
-}
-CREATE_PIXEL(A_8, UNSIGNED_8, PIXEL_A);
-CREATE_PIXEL(RGB_565, UNSIGNED_5_6_5, PIXEL_RGB);
-CREATE_PIXEL(RGB_888, UNSIGNED_8, PIXEL_RGB);
-CREATE_PIXEL(RGBA_4444, UNSIGNED_4_4_4_4, PIXEL_RGBA);
-CREATE_PIXEL(RGBA_8888, UNSIGNED_8, PIXEL_RGBA);
-
-#define CREATE_VECTOR(N, T) const Element * Element::N##_2(RenderScript *rs) { \
- return createVector(rs, RS_TYPE_##T, 2); \
-} \
-const Element * Element::N##_3(RenderScript *rs) { \
- return createVector(rs, RS_TYPE_##T, 3); \
-} \
-const Element * Element::N##_4(RenderScript *rs) { \
- return createVector(rs, RS_TYPE_##T, 4); \
-}
-CREATE_VECTOR(U8, UNSIGNED_8);
-CREATE_VECTOR(I8, SIGNED_8);
-CREATE_VECTOR(U16, UNSIGNED_16);
-CREATE_VECTOR(I16, SIGNED_16);
-CREATE_VECTOR(U32, UNSIGNED_32);
-CREATE_VECTOR(I32, SIGNED_32);
-CREATE_VECTOR(U64, UNSIGNED_64);
-CREATE_VECTOR(I64, SIGNED_64);
-CREATE_VECTOR(F32, FLOAT_32);
-CREATE_VECTOR(F64, FLOAT_64);
-
-
-void Element::updateVisibleSubElements() {
- if (!mElements.size()) {
- return;
- }
- mVisibleElementMap.clear();
-
- int noPaddingFieldCount = 0;
- size_t fieldCount = mElementNames.size();
- // Find out how many elements are not padding
- for (size_t ct = 0; ct < fieldCount; ct ++) {
- if (mElementNames[ct].string()[0] != '#') {
- noPaddingFieldCount ++;
- }
- }
-
- // Make a map that points us at non-padding elements
- for (size_t ct = 0; ct < fieldCount; ct ++) {
- if (mElementNames[ct].string()[0] != '#') {
- mVisibleElementMap.push((uint32_t)ct);
- }
- }
-}
-
-Element::Element(void *id, RenderScript *rs,
- android::Vector<const Element *> &elements,
- android::Vector<android::String8> &elementNames,
- android::Vector<uint32_t> &arraySizes) : BaseObj(id, rs) {
- mSizeBytes = 0;
- mVectorSize = 1;
- mElements = elements;
- mArraySizes = arraySizes;
- mElementNames = elementNames;
-
- mType = RS_TYPE_NONE;
- mKind = RS_KIND_USER;
-
- for (size_t ct = 0; ct < mElements.size(); ct++ ) {
- mOffsetInBytes.push(mSizeBytes);
- mSizeBytes += mElements[ct]->mSizeBytes * mArraySizes[ct];
- }
- updateVisibleSubElements();
-}
-
-
-static uint32_t GetSizeInBytesForType(RsDataType dt) {
- switch(dt) {
- case RS_TYPE_NONE:
- return 0;
- case RS_TYPE_SIGNED_8:
- case RS_TYPE_UNSIGNED_8:
- case RS_TYPE_BOOLEAN:
- return 1;
-
- case RS_TYPE_FLOAT_16:
- case RS_TYPE_SIGNED_16:
- case RS_TYPE_UNSIGNED_16:
- case RS_TYPE_UNSIGNED_5_6_5:
- case RS_TYPE_UNSIGNED_5_5_5_1:
- case RS_TYPE_UNSIGNED_4_4_4_4:
- return 2;
-
- case RS_TYPE_FLOAT_32:
- case RS_TYPE_SIGNED_32:
- case RS_TYPE_UNSIGNED_32:
- return 4;
-
- case RS_TYPE_FLOAT_64:
- case RS_TYPE_SIGNED_64:
- case RS_TYPE_UNSIGNED_64:
- return 8;
-
- case RS_TYPE_MATRIX_4X4:
- return 16 * 4;
- case RS_TYPE_MATRIX_3X3:
- return 9 * 4;
- case RS_TYPE_MATRIX_2X2:
- return 4 * 4;
-
- case RS_TYPE_TYPE:
- case RS_TYPE_ALLOCATION:
- case RS_TYPE_SAMPLER:
- case RS_TYPE_SCRIPT:
- case RS_TYPE_MESH:
- case RS_TYPE_PROGRAM_FRAGMENT:
- case RS_TYPE_PROGRAM_VERTEX:
- case RS_TYPE_PROGRAM_RASTER:
- case RS_TYPE_PROGRAM_STORE:
- return 4;
-
- default:
- break;
- }
-
- ALOGE("Missing type %i", dt);
- return 0;
-}
-
-Element::Element(void *id, RenderScript *rs,
- RsDataType dt, RsDataKind dk, bool norm, uint32_t size) :
- BaseObj(id, rs)
-{
- uint32_t tsize = GetSizeInBytesForType(dt);
- if ((dt != RS_TYPE_UNSIGNED_5_6_5) &&
- (dt != RS_TYPE_UNSIGNED_4_4_4_4) &&
- (dt != RS_TYPE_UNSIGNED_5_5_5_1)) {
- if (size == 3) {
- mSizeBytes = tsize * 4;
- } else {
- mSizeBytes = tsize * size;
- }
- } else {
- mSizeBytes = tsize;
- }
- mType = dt;
- mKind = dk;
- mNormalized = norm;
- mVectorSize = size;
-}
-
-Element::~Element() {
-}
-
- /*
- Element(int id, RenderScript rs) {
- super(id, rs);
- }
- */
-
-void Element::updateFromNative() {
- BaseObj::updateFromNative();
-/*
- // we will pack mType; mKind; mNormalized; mVectorSize; NumSubElements
- int[] dataBuffer = new int[5];
- mRS.nElementGetNativeData(getID(), dataBuffer);
-
- mNormalized = dataBuffer[2] == 1 ? true : false;
- mVectorSize = dataBuffer[3];
- mSize = 0;
- for (DataType dt: DataType.values()) {
- if(dt.mID == dataBuffer[0]){
- mType = dt;
- mSize = mType.mSize * mVectorSize;
- }
- }
- for (DataKind dk: DataKind.values()) {
- if(dk.mID == dataBuffer[1]){
- mKind = dk;
- }
- }
-
- int numSubElements = dataBuffer[4];
- if(numSubElements > 0) {
- mElements = new Element[numSubElements];
- mElementNames = new String[numSubElements];
- mArraySizes = new int[numSubElements];
- mOffsetInBytes = new int[numSubElements];
-
- int[] subElementIds = new int[numSubElements];
- mRS.nElementGetSubElements(getID(), subElementIds, mElementNames, mArraySizes);
- for(int i = 0; i < numSubElements; i ++) {
- mElements[i] = new Element(subElementIds[i], mRS);
- mElements[i].updateFromNative();
- mOffsetInBytes[i] = mSize;
- mSize += mElements[i].mSize * mArraySizes[i];
- }
- }
- */
- updateVisibleSubElements();
-}
-
-const Element * Element::createUser(RenderScript *rs, RsDataType dt) {
- void * id = rsElementCreate(rs->mContext, dt, RS_KIND_USER, false, 1);
- return new Element(id, rs, dt, RS_KIND_USER, false, 1);
-}
-
-const Element * Element::createVector(RenderScript *rs, RsDataType dt, uint32_t size) {
- if (size < 2 || size > 4) {
- rs->throwError("Vector size out of range 2-4.");
- }
- void *id = rsElementCreate(rs->mContext, dt, RS_KIND_USER, false, size);
- return new Element(id, rs, dt, RS_KIND_USER, false, size);
-}
-
-const Element * Element::createPixel(RenderScript *rs, RsDataType dt, RsDataKind dk) {
- if (!(dk == RS_KIND_PIXEL_L ||
- dk == RS_KIND_PIXEL_A ||
- dk == RS_KIND_PIXEL_LA ||
- dk == RS_KIND_PIXEL_RGB ||
- dk == RS_KIND_PIXEL_RGBA ||
- dk == RS_KIND_PIXEL_DEPTH)) {
- rs->throwError("Unsupported DataKind");
- }
- if (!(dt == RS_TYPE_UNSIGNED_8 ||
- dt == RS_TYPE_UNSIGNED_16 ||
- dt == RS_TYPE_UNSIGNED_5_6_5 ||
- dt == RS_TYPE_UNSIGNED_4_4_4_4 ||
- dt == RS_TYPE_UNSIGNED_5_5_5_1)) {
- rs->throwError("Unsupported DataType");
- }
- if (dt == RS_TYPE_UNSIGNED_5_6_5 && dk != RS_KIND_PIXEL_RGB) {
- rs->throwError("Bad kind and type combo");
- }
- if (dt == RS_TYPE_UNSIGNED_5_5_5_1 && dk != RS_KIND_PIXEL_RGBA) {
- rs->throwError("Bad kind and type combo");
- }
- if (dt == RS_TYPE_UNSIGNED_4_4_4_4 && dk != RS_KIND_PIXEL_RGBA) {
- rs->throwError("Bad kind and type combo");
- }
- if (dt == RS_TYPE_UNSIGNED_16 && dk != RS_KIND_PIXEL_DEPTH) {
- rs->throwError("Bad kind and type combo");
- }
-
- int size = 1;
- switch (dk) {
- case RS_KIND_PIXEL_LA:
- size = 2;
- break;
- case RS_KIND_PIXEL_RGB:
- size = 3;
- break;
- case RS_KIND_PIXEL_RGBA:
- size = 4;
- break;
- case RS_KIND_PIXEL_DEPTH:
- size = 2;
- break;
- default:
- break;
- }
-
- void * id = rsElementCreate(rs->mContext, dt, dk, true, size);
- return new Element(id, rs, dt, dk, true, size);
-}
-
-bool Element::isCompatible(const Element *e) {
- // Try strict BaseObj equality to start with.
- if (this == e) {
- return true;
- }
-
- // Ignore mKind because it is allowed to be different (user vs. pixel).
- // We also ignore mNormalized because it can be different. The mType
- // field must be non-null since we require name equivalence for
- // user-created Elements.
- return ((mSizeBytes == e->mSizeBytes) &&
- (mType != NULL) &&
- (mType == e->mType) &&
- (mVectorSize == e->mVectorSize));
-}
-
-Element::Builder::Builder(RenderScript *rs) {
- mRS = rs;
- mSkipPadding = false;
-}
-
-void Element::Builder::add(const Element *e, android::String8 &name, uint32_t arraySize) {
- // Skip padding fields after a vector 3 type.
- if (mSkipPadding) {
- const char *s1 = "#padding_";
- const char *s2 = name;
- size_t len = strlen(s1);
- if (strlen(s2) >= len) {
- if (!memcmp(s1, s2, len)) {
- mSkipPadding = false;
- return;
- }
- }
- }
-
- if (e->mVectorSize == 3) {
- mSkipPadding = true;
- } else {
- mSkipPadding = false;
- }
-
- mElements.add(e);
- mElementNames.add(name);
- mArraySizes.add(arraySize);
-}
-
-const Element * Element::Builder::create() {
- size_t fieldCount = mElements.size();
- const char ** nameArray = (const char **)calloc(fieldCount, sizeof(char *));
- size_t* sizeArray = (size_t*)calloc(fieldCount, sizeof(size_t));
-
- for (size_t ct = 0; ct < fieldCount; ct++) {
- nameArray[ct] = mElementNames[ct].string();
- sizeArray[ct] = mElementNames[ct].length();
- }
-
- void *id = rsElementCreate2(mRS->mContext,
- (RsElement *)mElements.array(), fieldCount,
- nameArray, fieldCount * sizeof(size_t), sizeArray,
- (const uint32_t *)mArraySizes.array(), fieldCount);
-
-
- free(nameArray);
- free(sizeArray);
-
- Element *e = new Element(id, mRS, mElements, mElementNames, mArraySizes);
- return e;
-}
-
diff --git a/libs/rs/Element.h b/libs/rs/Element.h
deleted file mode 100644
index a579dc3..0000000
--- a/libs/rs/Element.h
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright (C) 2008-2012 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.
- */
-
-#ifndef __ANDROID_ELEMENT_H__
-#define __ANDROID_ELEMENT_H__
-
-#include <rs.h>
-#include "RenderScript.h"
-#include "BaseObj.h"
-
-class Element : public BaseObj {
-public:
- /**
- * Return if a element is too complex for use as a data source for a Mesh or
- * a Program.
- *
- * @return boolean
- */
- bool isComplex();
-
- /**
- * @hide
- * @return number of sub-elements in this element
- */
- size_t getSubElementCount() {
- return mVisibleElementMap.size();
- }
-
- /**
- * @hide
- * @param index index of the sub-element to return
- * @return sub-element in this element at given index
- */
- const Element * getSubElement(uint32_t index);
-
- /**
- * @hide
- * @param index index of the sub-element
- * @return sub-element in this element at given index
- */
- const char * getSubElementName(uint32_t index);
-
- /**
- * @hide
- * @param index index of the sub-element
- * @return array size of sub-element in this element at given index
- */
- size_t getSubElementArraySize(uint32_t index);
-
- /**
- * @hide
- * @param index index of the sub-element
- * @return offset in bytes of sub-element in this element at given index
- */
- uint32_t getSubElementOffsetBytes(uint32_t index);
-
- /**
- * @hide
- * @return element data type
- */
- RsDataType getDataType() const {
- return mType;
- }
-
- /**
- * @hide
- * @return element data kind
- */
- RsDataKind getDataKind() const {
- return mKind;
- }
-
- size_t getSizeBytes() const {
- return mSizeBytes;
- }
-
-
- static const Element * BOOLEAN(RenderScript *rs);
- static const Element * U8(RenderScript *rs);
- static const Element * I8(RenderScript *rs);
- static const Element * U16(RenderScript *rs);
- static const Element * I16(RenderScript *rs);
- static const Element * U32(RenderScript *rs);
- static const Element * I32(RenderScript *rs);
- static const Element * U64(RenderScript *rs);
- static const Element * I64(RenderScript *rs);
- static const Element * F32(RenderScript *rs);
- static const Element * F64(RenderScript *rs);
- static const Element * ELEMENT(RenderScript *rs);
- static const Element * TYPE(RenderScript *rs);
- static const Element * ALLOCATION(RenderScript *rs);
- static const Element * SAMPLER(RenderScript *rs);
- static const Element * SCRIPT(RenderScript *rs);
- static const Element * MESH(RenderScript *rs);
- static const Element * PROGRAM_FRAGMENT(RenderScript *rs);
- static const Element * PROGRAM_VERTEX(RenderScript *rs);
- static const Element * PROGRAM_RASTER(RenderScript *rs);
- static const Element * PROGRAM_STORE(RenderScript *rs);
-
- static const Element * A_8(RenderScript *rs);
- static const Element * RGB_565(RenderScript *rs);
- static const Element * RGB_888(RenderScript *rs);
- static const Element * RGBA_5551(RenderScript *rs);
- static const Element * RGBA_4444(RenderScript *rs);
- static const Element * RGBA_8888(RenderScript *rs);
-
- static const Element * F32_2(RenderScript *rs);
- static const Element * F32_3(RenderScript *rs);
- static const Element * F32_4(RenderScript *rs);
- static const Element * F64_2(RenderScript *rs);
- static const Element * F64_3(RenderScript *rs);
- static const Element * F64_4(RenderScript *rs);
- static const Element * U8_2(RenderScript *rs);
- static const Element * U8_3(RenderScript *rs);
- static const Element * U8_4(RenderScript *rs);
- static const Element * I8_2(RenderScript *rs);
- static const Element * I8_3(RenderScript *rs);
- static const Element * I8_4(RenderScript *rs);
- static const Element * U16_2(RenderScript *rs);
- static const Element * U16_3(RenderScript *rs);
- static const Element * U16_4(RenderScript *rs);
- static const Element * I16_2(RenderScript *rs);
- static const Element * I16_3(RenderScript *rs);
- static const Element * I16_4(RenderScript *rs);
- static const Element * U32_2(RenderScript *rs);
- static const Element * U32_3(RenderScript *rs);
- static const Element * U32_4(RenderScript *rs);
- static const Element * I32_2(RenderScript *rs);
- static const Element * I32_3(RenderScript *rs);
- static const Element * I32_4(RenderScript *rs);
- static const Element * U64_2(RenderScript *rs);
- static const Element * U64_3(RenderScript *rs);
- static const Element * U64_4(RenderScript *rs);
- static const Element * I64_2(RenderScript *rs);
- static const Element * I64_3(RenderScript *rs);
- static const Element * I64_4(RenderScript *rs);
- static const Element * MATRIX_4X4(RenderScript *rs);
- static const Element * MATRIX_3X3(RenderScript *rs);
- static const Element * MATRIX_2X2(RenderScript *rs);
-
- Element(void *id, RenderScript *rs,
- android::Vector<const Element *> &elements,
- android::Vector<android::String8> &elementNames,
- android::Vector<uint32_t> &arraySizes);
- Element(void *id, RenderScript *rs, RsDataType dt, RsDataKind dk, bool norm, uint32_t size);
- Element(RenderScript *rs);
- virtual ~Element();
-
- void updateFromNative();
- static const Element * createUser(RenderScript *rs, RsDataType dt);
- static const Element * createVector(RenderScript *rs, RsDataType dt, uint32_t size);
- static const Element * createPixel(RenderScript *rs, RsDataType dt, RsDataKind dk);
- bool isCompatible(const Element *e);
-
- class Builder {
- private:
- RenderScript *mRS;
- android::Vector<const Element *> mElements;
- android::Vector<android::String8> mElementNames;
- android::Vector<uint32_t> mArraySizes;
- bool mSkipPadding;
-
- public:
- Builder(RenderScript *rs);
- ~Builder();
- void add(const Element *, android::String8 &name, uint32_t arraySize = 1);
- const Element * create();
- };
-
-private:
- void updateVisibleSubElements();
-
- android::Vector<const Element *> mElements;
- android::Vector<android::String8> mElementNames;
- android::Vector<uint32_t> mArraySizes;
- android::Vector<uint32_t> mVisibleElementMap;
- android::Vector<uint32_t> mOffsetInBytes;
-
- RsDataType mType;
- RsDataKind mKind;
- bool mNormalized;
- size_t mSizeBytes;
- size_t mVectorSize;
-};
-
-#endif
diff --git a/libs/rs/RenderScript.cpp b/libs/rs/RenderScript.cpp
deleted file mode 100644
index 217b921..0000000
--- a/libs/rs/RenderScript.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (C) 2008-2012 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.
- */
-
-#define LOG_TAG "libRS_cpp"
-
-#include <utils/Log.h>
-#include <malloc.h>
-#include <string.h>
-
-#include "RenderScript.h"
-#include "rs.h"
-
-bool RenderScript::gInitialized = false;
-pthread_mutex_t RenderScript::gInitMutex = PTHREAD_MUTEX_INITIALIZER;
-
-RenderScript::RenderScript() {
- mDev = NULL;
- mContext = NULL;
- mErrorFunc = NULL;
- mMessageFunc = NULL;
- mMessageRun = false;
-
- memset(&mElements, 0, sizeof(mElements));
-}
-
-RenderScript::~RenderScript() {
- mMessageRun = false;
-
- rsContextDeinitToClient(mContext);
-
- void *res = NULL;
- int status = pthread_join(mMessageThreadId, &res);
-
- rsContextDestroy(mContext);
- mContext = NULL;
- rsDeviceDestroy(mDev);
- mDev = NULL;
-}
-
-bool RenderScript::init(int targetApi) {
- mDev = rsDeviceCreate();
- if (mDev == 0) {
- ALOGE("Device creation failed");
- return false;
- }
-
- mContext = rsContextCreate(mDev, 0, targetApi);
- if (mContext == 0) {
- ALOGE("Context creation failed");
- return false;
- }
-
-
- pid_t mNativeMessageThreadId;
-
- int status = pthread_create(&mMessageThreadId, NULL, threadProc, this);
- if (status) {
- ALOGE("Failed to start RenderScript message thread.");
- return false;
- }
- // Wait for the message thread to be active.
- while (!mMessageRun) {
- usleep(1000);
- }
-
- return true;
-}
-
-void RenderScript::throwError(const char *err) const {
- ALOGE("RS CPP error: %s", err);
- int * v = NULL;
- v[0] = 0;
-}
-
-
-void * RenderScript::threadProc(void *vrsc) {
- RenderScript *rs = static_cast<RenderScript *>(vrsc);
- size_t rbuf_size = 256;
- void * rbuf = malloc(rbuf_size);
-
- rsContextInitToClient(rs->mContext);
- rs->mMessageRun = true;
-
- while (rs->mMessageRun) {
- size_t receiveLen = 0;
- uint32_t usrID = 0;
- uint32_t subID = 0;
- RsMessageToClientType r = rsContextPeekMessage(rs->mContext,
- &receiveLen, sizeof(receiveLen),
- &usrID, sizeof(usrID));
-
- if (receiveLen >= rbuf_size) {
- rbuf_size = receiveLen + 32;
- rbuf = realloc(rbuf, rbuf_size);
- }
- if (!rbuf) {
- ALOGE("RenderScript::message handler realloc error %zu", rbuf_size);
- // No clean way to recover now?
- }
- rsContextGetMessage(rs->mContext, rbuf, rbuf_size, &receiveLen, sizeof(receiveLen),
- &subID, sizeof(subID));
-
- switch(r) {
- case RS_MESSAGE_TO_CLIENT_ERROR:
- ALOGE("RS Error %s", (const char *)rbuf);
-
- if(rs->mMessageFunc != NULL) {
- rs->mErrorFunc(usrID, (const char *)rbuf);
- }
- break;
- case RS_MESSAGE_TO_CLIENT_EXCEPTION:
- // teardown. But we want to avoid starving other threads during
- // teardown by yielding until the next line in the destructor can
- // execute to set mRun = false
- usleep(1000);
- break;
- case RS_MESSAGE_TO_CLIENT_USER:
- if(rs->mMessageFunc != NULL) {
- rs->mMessageFunc(usrID, rbuf, receiveLen);
- } else {
- ALOGE("Received a message from the script with no message handler installed.");
- }
- break;
-
- default:
- ALOGE("RenderScript unknown message type %i", r);
- }
- }
-
- if (rbuf) {
- free(rbuf);
- }
- ALOGE("RenderScript Message thread exiting.");
- return NULL;
-}
-
-void RenderScript::setErrorHandler(ErrorHandlerFunc_t func) {
- mErrorFunc = func;
-}
-
-void RenderScript::setMessageHandler(MessageHandlerFunc_t func) {
- mMessageFunc = func;
-}
-
-void RenderScript::contextDump() {
-}
-
-void RenderScript::finish() {
-
-}
-
-
diff --git a/libs/rs/RenderScript.h b/libs/rs/RenderScript.h
deleted file mode 100644
index 5ad76e2..0000000
--- a/libs/rs/RenderScript.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (C) 2008-2012 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.
- */
-
-#ifndef ANDROID_RENDERSCRIPT_H
-#define ANDROID_RENDERSCRIPT_H
-
-
-#include <pthread.h>
-#include <utils/String8.h>
-#include <utils/Vector.h>
-
-#include "rsDefines.h"
-
-class Element;
-class Type;
-class Allocation;
-
-class RenderScript {
- friend class BaseObj;
- friend class Allocation;
- friend class Element;
- friend class Type;
- friend class Script;
- friend class ScriptC;
-
-public:
- RenderScript();
- virtual ~RenderScript();
-
- typedef void (*ErrorHandlerFunc_t)(uint32_t errorNum, const char *errorText);
- typedef void (*MessageHandlerFunc_t)(uint32_t msgNum, const void *msgData, size_t msgLen);
-
-
- void setErrorHandler(ErrorHandlerFunc_t func);
- ErrorHandlerFunc_t getErrorHandler() {return mErrorFunc;}
-
- void setMessageHandler(MessageHandlerFunc_t func);
- MessageHandlerFunc_t getMessageHandler() {return mMessageFunc;}
-
- bool init(int targetApi);
- void contextDump();
- void finish();
-
-private:
- static bool gInitialized;
- static pthread_mutex_t gInitMutex;
-
- pthread_t mMessageThreadId;
- pid_t mNativeMessageThreadId;
- bool mMessageRun;
-
- RsDevice mDev;
- RsContext mContext;
-
- ErrorHandlerFunc_t mErrorFunc;
- MessageHandlerFunc_t mMessageFunc;
-
- struct {
- Element *U8;
- Element *I8;
- Element *U16;
- Element *I16;
- Element *U32;
- Element *I32;
- Element *U64;
- Element *I64;
- Element *F32;
- Element *F64;
- Element *BOOLEAN;
-
- Element *ELEMENT;
- Element *TYPE;
- Element *ALLOCATION;
- Element *SAMPLER;
- Element *SCRIPT;
- Element *MESH;
- Element *PROGRAM_FRAGMENT;
- Element *PROGRAM_VERTEX;
- Element *PROGRAM_RASTER;
- Element *PROGRAM_STORE;
-
- Element *A_8;
- Element *RGB_565;
- Element *RGB_888;
- Element *RGBA_5551;
- Element *RGBA_4444;
- Element *RGBA_8888;
-
- Element *FLOAT_2;
- Element *FLOAT_3;
- Element *FLOAT_4;
-
- Element *DOUBLE_2;
- Element *DOUBLE_3;
- Element *DOUBLE_4;
-
- Element *UCHAR_2;
- Element *UCHAR_3;
- Element *UCHAR_4;
-
- Element *CHAR_2;
- Element *CHAR_3;
- Element *CHAR_4;
-
- Element *USHORT_2;
- Element *USHORT_3;
- Element *USHORT_4;
-
- Element *SHORT_2;
- Element *SHORT_3;
- Element *SHORT_4;
-
- Element *UINT_2;
- Element *UINT_3;
- Element *UINT_4;
-
- Element *INT_2;
- Element *INT_3;
- Element *INT_4;
-
- Element *ULONG_2;
- Element *ULONG_3;
- Element *ULONG_4;
-
- Element *LONG_2;
- Element *LONG_3;
- Element *LONG_4;
-
- Element *MATRIX_4X4;
- Element *MATRIX_3X3;
- Element *MATRIX_2X2;
- } mElements;
-
-
-
- void throwError(const char *err) const;
-
- static void * threadProc(void *);
-
-};
-
-#endif
-
diff --git a/libs/rs/Script.cpp b/libs/rs/Script.cpp
deleted file mode 100644
index c87d460..0000000
--- a/libs/rs/Script.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2008-2012 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.
- */
-
-#define LOG_TAG "libRS_cpp"
-
-#include <utils/Log.h>
-#include <malloc.h>
-
-#include "RenderScript.h"
-#include "Element.h"
-#include "Type.h"
-#include "Allocation.h"
-#include "Script.h"
-
-void Script::invoke(uint32_t slot, const void *v, size_t len) const {
- rsScriptInvokeV(mRS->mContext, getID(), slot, v, len);
-}
-
-void Script::forEach(uint32_t slot, const Allocation *ain, const Allocation *aout,
- const void *usr, size_t usrLen) const {
- if ((ain == NULL) && (aout == NULL)) {
- mRS->throwError("At least one of ain or aout is required to be non-null.");
- }
- void *in_id = BaseObj::getObjID(ain);
- void *out_id = BaseObj::getObjID(aout);
- rsScriptForEach(mRS->mContext, getID(), slot, in_id, out_id, usr, usrLen);
-}
-
-
-Script::Script(void *id, RenderScript *rs) : BaseObj(id, rs) {
-}
-
-
-void Script::bindAllocation(const Allocation *va, uint32_t slot) const {
- rsScriptBindAllocation(mRS->mContext, getID(), BaseObj::getObjID(va), slot);
-}
-
-
-void Script::setVar(uint32_t index, const BaseObj *o) const {
- rsScriptSetVarObj(mRS->mContext, getID(), index, (o == NULL) ? 0 : o->getID());
-}
-
-void Script::setVar(uint32_t index, const void *v, size_t len) const {
- rsScriptSetVarV(mRS->mContext, getID(), index, v, len);
-}
-
-
-
-void Script::FieldBase::init(RenderScript *rs, uint32_t dimx, uint32_t usages) {
- mAllocation = Allocation::createSized(rs, mElement, dimx, RS_ALLOCATION_USAGE_SCRIPT | usages);
-}
-
-//Script::FieldBase::FieldBase() {
-//}
-
-
diff --git a/libs/rs/Script.h b/libs/rs/Script.h
deleted file mode 100644
index 0700898..0000000
--- a/libs/rs/Script.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2008-2012 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.
- */
-
-#ifndef __ANDROID_SCRIPT_H__
-#define __ANDROID_SCRIPT_H__
-
-#include <pthread.h>
-#include <rs.h>
-
-#include "RenderScript.h"
-#include "Allocation.h"
-
-class Type;
-class Element;
-class Allocation;
-
-class Script : public BaseObj {
-protected:
- Script(void *id, RenderScript *rs);
- void forEach(uint32_t slot, const Allocation *in, const Allocation *out, const void *v, size_t) const;
- void bindAllocation(const Allocation *va, uint32_t slot) const;
- void setVar(uint32_t index, const void *, size_t len) const;
- void setVar(uint32_t index, const BaseObj *o) const;
- void invoke(uint32_t slot, const void *v, size_t len) const;
-
-
- void invoke(uint32_t slot) const {
- invoke(slot, NULL, 0);
- }
- void setVar(uint32_t index, float v) const {
- setVar(index, &v, sizeof(v));
- }
- void setVar(uint32_t index, double v) const {
- setVar(index, &v, sizeof(v));
- }
- void setVar(uint32_t index, int32_t v) const {
- setVar(index, &v, sizeof(v));
- }
- void setVar(uint32_t index, int64_t v) const {
- setVar(index, &v, sizeof(v));
- }
- void setVar(uint32_t index, bool v) const {
- setVar(index, &v, sizeof(v));
- }
-
-public:
- class FieldBase {
- protected:
- const Element *mElement;
- Allocation *mAllocation;
-
- void init(RenderScript *rs, uint32_t dimx, uint32_t usages = 0);
-
- public:
- const Element *getElement() {
- return mElement;
- }
-
- const Type *getType() {
- return mAllocation->getType();
- }
-
- const Allocation *getAllocation() {
- return mAllocation;
- }
-
- //void updateAllocation();
- };
-};
-
-#endif
diff --git a/libs/rs/ScriptC.cpp b/libs/rs/ScriptC.cpp
deleted file mode 100644
index 80e8efc..0000000
--- a/libs/rs/ScriptC.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2008-2012 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.
- */
-
-#define LOG_TAG "libRS_cpp"
-
-#include <utils/Log.h>
-#include <malloc.h>
-
-#include "ScriptC.h"
-
-ScriptC::ScriptC(RenderScript *rs,
- const void *codeTxt, size_t codeLength,
- const char *cachedName, size_t cachedNameLength,
- const char *cacheDir, size_t cacheDirLength)
-: Script(NULL, rs) {
- mID = rsScriptCCreate(rs->mContext, cachedName, cachedNameLength,
- cacheDir, cacheDirLength, (const char *)codeTxt, codeLength);
-}
-
diff --git a/libs/rs/ScriptC.h b/libs/rs/ScriptC.h
deleted file mode 100644
index b68f61c..0000000
--- a/libs/rs/ScriptC.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2008-2012 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.
- */
-
-#ifndef __ANDROID_SCRIPTC_H__
-#define __ANDROID_SCRIPTC_H__
-
-#include <pthread.h>
-#include <rs.h>
-
-#include "Script.h"
-
-class ScriptC : public Script {
-protected:
- ScriptC(RenderScript *rs,
- const void *codeTxt, size_t codeLength,
- const char *cachedName, size_t cachedNameLength,
- const char *cacheDir, size_t cacheDirLength);
-
-};
-
-#endif
diff --git a/libs/rs/Type.cpp b/libs/rs/Type.cpp
deleted file mode 100644
index 1352bd7..0000000
--- a/libs/rs/Type.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-#define LOG_TAG "libRS_cpp"
-
-#include <utils/Log.h>
-#include <malloc.h>
-#include <string.h>
-
-#include "RenderScript.h"
-#include "Element.h"
-#include "Type.h"
-
-void Type::calcElementCount() {
- bool hasLod = hasMipmaps();
- uint32_t x = getX();
- uint32_t y = getY();
- uint32_t z = getZ();
- uint32_t faces = 1;
- if (hasFaces()) {
- faces = 6;
- }
- if (x == 0) {
- x = 1;
- }
- if (y == 0) {
- y = 1;
- }
- if (z == 0) {
- z = 1;
- }
-
- uint32_t count = x * y * z * faces;
- while (hasLod && ((x > 1) || (y > 1) || (z > 1))) {
- if(x > 1) {
- x >>= 1;
- }
- if(y > 1) {
- y >>= 1;
- }
- if(z > 1) {
- z >>= 1;
- }
-
- count += x * y * z * faces;
- }
- mElementCount = count;
-}
-
-
-Type::Type(void *id, RenderScript *rs) : BaseObj(id, rs) {
- mDimX = 0;
- mDimY = 0;
- mDimZ = 0;
- mDimMipmaps = false;
- mDimFaces = false;
- mElement = NULL;
-}
-
-void Type::updateFromNative() {
- // We have 6 integer to obtain mDimX; mDimY; mDimZ;
- // mDimLOD; mDimFaces; mElement;
-
- /*
- int[] dataBuffer = new int[6];
- mRS.nTypeGetNativeData(getID(), dataBuffer);
-
- mDimX = dataBuffer[0];
- mDimY = dataBuffer[1];
- mDimZ = dataBuffer[2];
- mDimMipmaps = dataBuffer[3] == 1 ? true : false;
- mDimFaces = dataBuffer[4] == 1 ? true : false;
-
- int elementID = dataBuffer[5];
- if(elementID != 0) {
- mElement = new Element(elementID, mRS);
- mElement.updateFromNative();
- }
- calcElementCount();
- */
-}
-
-Type::Builder::Builder(RenderScript *rs, const Element *e) {
- mRS = rs;
- mElement = e;
- mDimX = 0;
- mDimY = 0;
- mDimZ = 0;
- mDimMipmaps = false;
- mDimFaces = false;
-}
-
-void Type::Builder::setX(uint32_t value) {
- if(value < 1) {
- ALOGE("Values of less than 1 for Dimension X are not valid.");
- }
- mDimX = value;
-}
-
-void Type::Builder::setY(int value) {
- if(value < 1) {
- ALOGE("Values of less than 1 for Dimension Y are not valid.");
- }
- mDimY = value;
-}
-
-void Type::Builder::setMipmaps(bool value) {
- mDimMipmaps = value;
-}
-
-void Type::Builder::setFaces(bool value) {
- mDimFaces = value;
-}
-
-const Type * Type::Builder::create() {
- if (mDimZ > 0) {
- if ((mDimX < 1) || (mDimY < 1)) {
- ALOGE("Both X and Y dimension required when Z is present.");
- }
- if (mDimFaces) {
- ALOGE("Cube maps not supported with 3D types.");
- }
- }
- if (mDimY > 0) {
- if (mDimX < 1) {
- ALOGE("X dimension required when Y is present.");
- }
- }
- if (mDimFaces) {
- if (mDimY < 1) {
- ALOGE("Cube maps require 2D Types.");
- }
- }
-
- void * id = rsTypeCreate(mRS->mContext, mElement->getID(), mDimX, mDimY, mDimZ, mDimMipmaps, mDimFaces);
- Type *t = new Type(id, mRS);
- t->mElement = mElement;
- t->mDimX = mDimX;
- t->mDimY = mDimY;
- t->mDimZ = mDimZ;
- t->mDimMipmaps = mDimMipmaps;
- t->mDimFaces = mDimFaces;
-
- t->calcElementCount();
- return t;
-}
-
diff --git a/libs/rs/Type.h b/libs/rs/Type.h
deleted file mode 100644
index 53481c3..0000000
--- a/libs/rs/Type.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-#ifndef __ANDROID_TYPE_H__
-#define __ANDROID_TYPE_H__
-
-#include <rs.h>
-#include "RenderScript.h"
-#include "Element.h"
-
-class Type : public BaseObj {
-protected:
- friend class Allocation;
-
- uint32_t mDimX;
- uint32_t mDimY;
- uint32_t mDimZ;
- bool mDimMipmaps;
- bool mDimFaces;
- size_t mElementCount;
- const Element *mElement;
-
- void calcElementCount();
- virtual void updateFromNative();
-
-public:
-
- const Element* getElement() const {
- return mElement;
- }
-
- uint32_t getX() const {
- return mDimX;
- }
-
- uint32_t getY() const {
- return mDimY;
- }
-
- uint32_t getZ() const {
- return mDimZ;
- }
-
- bool hasMipmaps() const {
- return mDimMipmaps;
- }
-
- bool hasFaces() const {
- return mDimFaces;
- }
-
- size_t getCount() const {
- return mElementCount;
- }
-
- size_t getSizeBytes() const {
- return mElementCount * mElement->getSizeBytes();
- }
-
-
- Type(void *id, RenderScript *rs);
-
-
- class Builder {
- protected:
- RenderScript *mRS;
- uint32_t mDimX;
- uint32_t mDimY;
- uint32_t mDimZ;
- bool mDimMipmaps;
- bool mDimFaces;
- const Element *mElement;
-
- public:
- Builder(RenderScript *rs, const Element *e);
-
- void setX(uint32_t value);
- void setY(int value);
- void setMipmaps(bool value);
- void setFaces(bool value);
- const Type * create();
- };
-
-};
-
-#endif
diff --git a/libs/rs/driver/rsdAllocation.cpp b/libs/rs/driver/rsdAllocation.cpp
deleted file mode 100644
index f358f93..0000000
--- a/libs/rs/driver/rsdAllocation.cpp
+++ /dev/null
@@ -1,648 +0,0 @@
-/*
- * Copyright (C) 2011-2012 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.
- */
-
-
-#include "rsdCore.h"
-#include "rsdBcc.h"
-#include "rsdRuntime.h"
-#include "rsdAllocation.h"
-#include "rsdFrameBufferObj.h"
-
-#include "rsAllocation.h"
-
-#include "system/window.h"
-#include "hardware/gralloc.h"
-#include "ui/Rect.h"
-#include "ui/GraphicBufferMapper.h"
-#include "gui/SurfaceTexture.h"
-
-#include <GLES/gl.h>
-#include <GLES2/gl2.h>
-#include <GLES/glext.h>
-
-using namespace android;
-using namespace android::renderscript;
-
-
-
-const static GLenum gFaceOrder[] = {
- GL_TEXTURE_CUBE_MAP_POSITIVE_X,
- GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
- GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
- GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
- GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
- GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
-};
-
-
-GLenum rsdTypeToGLType(RsDataType t) {
- switch (t) {
- case RS_TYPE_UNSIGNED_5_6_5: return GL_UNSIGNED_SHORT_5_6_5;
- case RS_TYPE_UNSIGNED_5_5_5_1: return GL_UNSIGNED_SHORT_5_5_5_1;
- case RS_TYPE_UNSIGNED_4_4_4_4: return GL_UNSIGNED_SHORT_4_4_4_4;
-
- //case RS_TYPE_FLOAT_16: return GL_HALF_FLOAT;
- case RS_TYPE_FLOAT_32: return GL_FLOAT;
- case RS_TYPE_UNSIGNED_8: return GL_UNSIGNED_BYTE;
- case RS_TYPE_UNSIGNED_16: return GL_UNSIGNED_SHORT;
- case RS_TYPE_SIGNED_8: return GL_BYTE;
- case RS_TYPE_SIGNED_16: return GL_SHORT;
- default: break;
- }
- return 0;
-}
-
-GLenum rsdKindToGLFormat(RsDataKind k) {
- switch (k) {
- case RS_KIND_PIXEL_L: return GL_LUMINANCE;
- case RS_KIND_PIXEL_A: return GL_ALPHA;
- case RS_KIND_PIXEL_LA: return GL_LUMINANCE_ALPHA;
- case RS_KIND_PIXEL_RGB: return GL_RGB;
- case RS_KIND_PIXEL_RGBA: return GL_RGBA;
- case RS_KIND_PIXEL_DEPTH: return GL_DEPTH_COMPONENT16;
- default: break;
- }
- return 0;
-}
-
-
-static void Update2DTexture(const Context *rsc, const Allocation *alloc, const void *ptr,
- uint32_t xoff, uint32_t yoff, uint32_t lod,
- RsAllocationCubemapFace face, uint32_t w, uint32_t h) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- rsAssert(drv->textureID);
- RSD_CALL_GL(glBindTexture, drv->glTarget, drv->textureID);
- RSD_CALL_GL(glPixelStorei, GL_UNPACK_ALIGNMENT, 1);
- GLenum t = GL_TEXTURE_2D;
- if (alloc->mHal.state.hasFaces) {
- t = gFaceOrder[face];
- }
- RSD_CALL_GL(glTexSubImage2D, t, lod, xoff, yoff, w, h, drv->glFormat, drv->glType, ptr);
-}
-
-
-static void Upload2DTexture(const Context *rsc, const Allocation *alloc, bool isFirstUpload) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- RSD_CALL_GL(glBindTexture, drv->glTarget, drv->textureID);
- RSD_CALL_GL(glPixelStorei, GL_UNPACK_ALIGNMENT, 1);
-
- uint32_t faceCount = 1;
- if (alloc->mHal.state.hasFaces) {
- faceCount = 6;
- }
-
- rsdGLCheckError(rsc, "Upload2DTexture 1 ");
- for (uint32_t face = 0; face < faceCount; face ++) {
- for (uint32_t lod = 0; lod < alloc->mHal.state.type->getLODCount(); lod++) {
- const uint8_t *p = (const uint8_t *)drv->mallocPtr;
- p += alloc->mHal.state.type->getLODFaceOffset(lod, (RsAllocationCubemapFace)face, 0, 0);
-
- GLenum t = GL_TEXTURE_2D;
- if (alloc->mHal.state.hasFaces) {
- t = gFaceOrder[face];
- }
-
- if (isFirstUpload) {
- RSD_CALL_GL(glTexImage2D, t, lod, drv->glFormat,
- alloc->mHal.state.type->getLODDimX(lod),
- alloc->mHal.state.type->getLODDimY(lod),
- 0, drv->glFormat, drv->glType, p);
- } else {
- RSD_CALL_GL(glTexSubImage2D, t, lod, 0, 0,
- alloc->mHal.state.type->getLODDimX(lod),
- alloc->mHal.state.type->getLODDimY(lod),
- drv->glFormat, drv->glType, p);
- }
- }
- }
-
- if (alloc->mHal.state.mipmapControl == RS_ALLOCATION_MIPMAP_ON_SYNC_TO_TEXTURE) {
- RSD_CALL_GL(glGenerateMipmap, drv->glTarget);
- }
- rsdGLCheckError(rsc, "Upload2DTexture");
-}
-
-static void UploadToTexture(const Context *rsc, const Allocation *alloc) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- if (alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_IO_INPUT) {
- if (!drv->textureID) {
- RSD_CALL_GL(glGenTextures, 1, &drv->textureID);
- }
- return;
- }
-
- if (!drv->glType || !drv->glFormat) {
- return;
- }
-
- if (!alloc->getPtr()) {
- return;
- }
-
- bool isFirstUpload = false;
-
- if (!drv->textureID) {
- RSD_CALL_GL(glGenTextures, 1, &drv->textureID);
- isFirstUpload = true;
- }
-
- Upload2DTexture(rsc, alloc, isFirstUpload);
-
- if (!(alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_SCRIPT)) {
- if (drv->mallocPtr) {
- free(drv->mallocPtr);
- drv->mallocPtr = NULL;
- }
- }
- rsdGLCheckError(rsc, "UploadToTexture");
-}
-
-static void AllocateRenderTarget(const Context *rsc, const Allocation *alloc) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- if (!drv->glFormat) {
- return;
- }
-
- if (!drv->renderTargetID) {
- RSD_CALL_GL(glGenRenderbuffers, 1, &drv->renderTargetID);
-
- if (!drv->renderTargetID) {
- // This should generally not happen
- ALOGE("allocateRenderTarget failed to gen mRenderTargetID");
- rsc->dumpDebug();
- return;
- }
- RSD_CALL_GL(glBindRenderbuffer, GL_RENDERBUFFER, drv->renderTargetID);
- RSD_CALL_GL(glRenderbufferStorage, GL_RENDERBUFFER, drv->glFormat,
- alloc->mHal.state.dimensionX, alloc->mHal.state.dimensionY);
- }
- rsdGLCheckError(rsc, "AllocateRenderTarget");
-}
-
-static void UploadToBufferObject(const Context *rsc, const Allocation *alloc) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- rsAssert(!alloc->mHal.state.type->getDimY());
- rsAssert(!alloc->mHal.state.type->getDimZ());
-
- //alloc->mHal.state.usageFlags |= RS_ALLOCATION_USAGE_GRAPHICS_VERTEX;
-
- if (!drv->bufferID) {
- RSD_CALL_GL(glGenBuffers, 1, &drv->bufferID);
- }
- if (!drv->bufferID) {
- ALOGE("Upload to buffer object failed");
- drv->uploadDeferred = true;
- return;
- }
- RSD_CALL_GL(glBindBuffer, drv->glTarget, drv->bufferID);
- RSD_CALL_GL(glBufferData, drv->glTarget, alloc->mHal.state.type->getSizeBytes(),
- drv->mallocPtr, GL_DYNAMIC_DRAW);
- RSD_CALL_GL(glBindBuffer, drv->glTarget, 0);
- rsdGLCheckError(rsc, "UploadToBufferObject");
-}
-
-bool rsdAllocationInit(const Context *rsc, Allocation *alloc, bool forceZero) {
- DrvAllocation *drv = (DrvAllocation *)calloc(1, sizeof(DrvAllocation));
- if (!drv) {
- return false;
- }
-
- void * ptr = alloc->mHal.state.usrPtr;
- if (alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_IO_OUTPUT) {
- } else {
- ptr = malloc(alloc->mHal.state.type->getSizeBytes());
- if (!ptr) {
- free(drv);
- return false;
- }
- }
-
- drv->glTarget = GL_NONE;
- if (alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE) {
- if (alloc->mHal.state.hasFaces) {
- drv->glTarget = GL_TEXTURE_CUBE_MAP;
- } else {
- drv->glTarget = GL_TEXTURE_2D;
- }
- } else {
- if (alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_GRAPHICS_VERTEX) {
- drv->glTarget = GL_ARRAY_BUFFER;
- }
- }
-
- drv->glType = rsdTypeToGLType(alloc->mHal.state.type->getElement()->getComponent().getType());
- drv->glFormat = rsdKindToGLFormat(alloc->mHal.state.type->getElement()->getComponent().getKind());
-
-
- alloc->mHal.drvState.mallocPtr = ptr;
- drv->mallocPtr = (uint8_t *)ptr;
- alloc->mHal.drv = drv;
- if (forceZero && ptr) {
- memset(ptr, 0, alloc->mHal.state.type->getSizeBytes());
- }
-
- if (alloc->mHal.state.usageFlags & ~RS_ALLOCATION_USAGE_SCRIPT) {
- drv->uploadDeferred = true;
- }
-
- drv->readBackFBO = NULL;
-
- return true;
-}
-
-void rsdAllocationDestroy(const Context *rsc, Allocation *alloc) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- if (drv->bufferID) {
- // Causes a SW crash....
- //ALOGV(" mBufferID %i", mBufferID);
- //glDeleteBuffers(1, &mBufferID);
- //mBufferID = 0;
- }
- if (drv->textureID) {
- RSD_CALL_GL(glDeleteTextures, 1, &drv->textureID);
- drv->textureID = 0;
- }
- if (drv->renderTargetID) {
- RSD_CALL_GL(glDeleteRenderbuffers, 1, &drv->renderTargetID);
- drv->renderTargetID = 0;
- }
-
- if (drv->mallocPtr && !alloc->mHal.state.usrPtr) {
- free(drv->mallocPtr);
- drv->mallocPtr = NULL;
- }
- if (drv->readBackFBO != NULL) {
- delete drv->readBackFBO;
- drv->readBackFBO = NULL;
- }
- free(drv);
- alloc->mHal.drv = NULL;
-}
-
-void rsdAllocationResize(const Context *rsc, const Allocation *alloc,
- const Type *newType, bool zeroNew) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- drv->mallocPtr = (uint8_t *)realloc(drv->mallocPtr, newType->getSizeBytes());
-
- // fixme
- ((Allocation *)alloc)->mHal.drvState.mallocPtr = drv->mallocPtr;
-
- const uint32_t oldDimX = alloc->mHal.state.dimensionX;
- const uint32_t dimX = newType->getDimX();
-
- if (dimX > oldDimX) {
- const Element *e = alloc->mHal.state.type->getElement();
- uint32_t stride = e->getSizeBytes();
- memset(((uint8_t *)drv->mallocPtr) + stride * oldDimX, 0, stride * (dimX - oldDimX));
- }
-}
-
-static void rsdAllocationSyncFromFBO(const Context *rsc, const Allocation *alloc) {
- if (!alloc->getIsScript()) {
- return; // nothing to sync
- }
-
- RsdHal *dc = (RsdHal *)rsc->mHal.drv;
- RsdFrameBufferObj *lastFbo = dc->gl.currentFrameBuffer;
-
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
- if (!drv->textureID && !drv->renderTargetID) {
- return; // nothing was rendered here yet, so nothing to sync
- }
- if (drv->readBackFBO == NULL) {
- drv->readBackFBO = new RsdFrameBufferObj();
- drv->readBackFBO->setColorTarget(drv, 0);
- drv->readBackFBO->setDimensions(alloc->getType()->getDimX(),
- alloc->getType()->getDimY());
- }
-
- // Bind the framebuffer object so we can read back from it
- drv->readBackFBO->setActive(rsc);
-
- // Do the readback
- RSD_CALL_GL(glReadPixels, 0, 0, alloc->getType()->getDimX(), alloc->getType()->getDimY(),
- drv->glFormat, drv->glType, alloc->getPtr());
-
- // Revert framebuffer to its original
- lastFbo->setActive(rsc);
-}
-
-
-void rsdAllocationSyncAll(const Context *rsc, const Allocation *alloc,
- RsAllocationUsageType src) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- if (src == RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET) {
- if(!alloc->getIsRenderTarget()) {
- rsc->setError(RS_ERROR_FATAL_DRIVER,
- "Attempting to sync allocation from render target, "
- "for non-render target allocation");
- } else if (alloc->getType()->getElement()->getKind() != RS_KIND_PIXEL_RGBA) {
- rsc->setError(RS_ERROR_FATAL_DRIVER, "Cannot only sync from RGBA"
- "render target");
- } else {
- rsdAllocationSyncFromFBO(rsc, alloc);
- }
- return;
- }
-
- rsAssert(src == RS_ALLOCATION_USAGE_SCRIPT);
-
- if (alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE) {
- UploadToTexture(rsc, alloc);
- } else {
- if (alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET) {
- AllocateRenderTarget(rsc, alloc);
- }
- }
- if (alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_GRAPHICS_VERTEX) {
- UploadToBufferObject(rsc, alloc);
- }
-
- drv->uploadDeferred = false;
-}
-
-void rsdAllocationMarkDirty(const Context *rsc, const Allocation *alloc) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
- drv->uploadDeferred = true;
-}
-
-int32_t rsdAllocationInitSurfaceTexture(const Context *rsc, const Allocation *alloc) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
- UploadToTexture(rsc, alloc);
- return drv->textureID;
-}
-
-static bool IoGetBuffer(const Context *rsc, Allocation *alloc, ANativeWindow *nw) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- int32_t r = nw->dequeueBuffer(nw, &drv->wndBuffer);
- if (r) {
- rsc->setError(RS_ERROR_DRIVER, "Error getting next IO output buffer.");
- return false;
- }
-
- // This lock is implicitly released by the queue buffer in IoSend
- r = nw->lockBuffer(nw, drv->wndBuffer);
- if (r) {
- rsc->setError(RS_ERROR_DRIVER, "Error locking next IO output buffer.");
- return false;
- }
-
- // Must lock the whole surface
- GraphicBufferMapper &mapper = GraphicBufferMapper::get();
- Rect bounds(drv->wndBuffer->width, drv->wndBuffer->height);
-
- void *dst = NULL;
- mapper.lock(drv->wndBuffer->handle,
- GRALLOC_USAGE_SW_READ_NEVER | GRALLOC_USAGE_SW_WRITE_OFTEN,
- bounds, &dst);
- alloc->mHal.drvState.mallocPtr = dst;
- return true;
-}
-
-void rsdAllocationSetSurfaceTexture(const Context *rsc, Allocation *alloc, ANativeWindow *nw) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- //ALOGE("rsdAllocationSetSurfaceTexture %p %p", alloc, nw);
-
- // Cleanup old surface if there is one.
- if (alloc->mHal.state.wndSurface) {
- ANativeWindow *old = alloc->mHal.state.wndSurface;
- GraphicBufferMapper &mapper = GraphicBufferMapper::get();
- mapper.unlock(drv->wndBuffer->handle);
- old->queueBuffer(old, drv->wndBuffer);
- }
-
- if (nw != NULL) {
- int32_t r;
- r = native_window_set_usage(nw, GRALLOC_USAGE_SW_READ_RARELY |
- GRALLOC_USAGE_SW_WRITE_OFTEN);
- if (r) {
- rsc->setError(RS_ERROR_DRIVER, "Error setting IO output buffer usage.");
- return;
- }
-
- r = native_window_set_buffers_dimensions(nw, alloc->mHal.state.dimensionX,
- alloc->mHal.state.dimensionY);
- if (r) {
- rsc->setError(RS_ERROR_DRIVER, "Error setting IO output buffer dimensions.");
- return;
- }
-
- r = native_window_set_buffer_count(nw, 3);
- if (r) {
- rsc->setError(RS_ERROR_DRIVER, "Error setting IO output buffer count.");
- return;
- }
-
- IoGetBuffer(rsc, alloc, nw);
- }
-}
-
-void rsdAllocationIoSend(const Context *rsc, Allocation *alloc) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
- ANativeWindow *nw = alloc->mHal.state.wndSurface;
-
- GraphicBufferMapper &mapper = GraphicBufferMapper::get();
- mapper.unlock(drv->wndBuffer->handle);
- int32_t r = nw->queueBuffer(nw, drv->wndBuffer);
- if (r) {
- rsc->setError(RS_ERROR_DRIVER, "Error sending IO output buffer.");
- return;
- }
-
- IoGetBuffer(rsc, alloc, nw);
-}
-
-void rsdAllocationIoReceive(const Context *rsc, Allocation *alloc) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
- alloc->mHal.state.surfaceTexture->updateTexImage();
-}
-
-
-void rsdAllocationData1D(const Context *rsc, const Allocation *alloc,
- uint32_t xoff, uint32_t lod, uint32_t count,
- const void *data, size_t sizeBytes) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- const uint32_t eSize = alloc->mHal.state.type->getElementSizeBytes();
- uint8_t * ptr = drv->mallocPtr;
- ptr += eSize * xoff;
- uint32_t size = count * eSize;
-
- if (alloc->mHal.state.hasReferences) {
- alloc->incRefs(data, count);
- alloc->decRefs(ptr, count);
- }
-
- memcpy(ptr, data, size);
- drv->uploadDeferred = true;
-}
-
-void rsdAllocationData2D(const Context *rsc, const Allocation *alloc,
- uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, const void *data, size_t sizeBytes) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- uint32_t eSize = alloc->mHal.state.elementSizeBytes;
- uint32_t lineSize = eSize * w;
- uint32_t destW = alloc->mHal.state.dimensionX;
-
- if (drv->mallocPtr) {
- const uint8_t *src = static_cast<const uint8_t *>(data);
- uint8_t *dst = drv->mallocPtr;
- dst += alloc->mHal.state.type->getLODFaceOffset(lod, face, xoff, yoff);
-
- for (uint32_t line=yoff; line < (yoff+h); line++) {
- if (alloc->mHal.state.hasReferences) {
- alloc->incRefs(src, w);
- alloc->decRefs(dst, w);
- }
- memcpy(dst, src, lineSize);
- src += lineSize;
- dst += destW * eSize;
- }
- drv->uploadDeferred = true;
- } else {
- Update2DTexture(rsc, alloc, data, xoff, yoff, lod, face, w, h);
- }
-}
-
-void rsdAllocationData3D(const Context *rsc, const Allocation *alloc,
- uint32_t xoff, uint32_t yoff, uint32_t zoff,
- uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes) {
-
-}
-
-void rsdAllocationData1D_alloc(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstLod, uint32_t count,
- const android::renderscript::Allocation *srcAlloc,
- uint32_t srcXoff, uint32_t srcLod) {
-}
-
-uint8_t *getOffsetPtr(const android::renderscript::Allocation *alloc,
- uint32_t xoff, uint32_t yoff, uint32_t lod,
- RsAllocationCubemapFace face) {
- uint8_t *ptr = static_cast<uint8_t *>(alloc->getPtr());
- ptr += alloc->getType()->getLODOffset(lod, xoff, yoff);
-
- if (face != 0) {
- uint32_t totalSizeBytes = alloc->getType()->getSizeBytes();
- uint32_t faceOffset = totalSizeBytes / 6;
- ptr += faceOffset * (uint32_t)face;
- }
- return ptr;
-}
-
-
-void rsdAllocationData2D_alloc_script(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod,
- RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h,
- const android::renderscript::Allocation *srcAlloc,
- uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod,
- RsAllocationCubemapFace srcFace) {
- uint32_t elementSize = dstAlloc->getType()->getElementSizeBytes();
- for (uint32_t i = 0; i < h; i ++) {
- uint8_t *dstPtr = getOffsetPtr(dstAlloc, dstXoff, dstYoff + i, dstLod, dstFace);
- uint8_t *srcPtr = getOffsetPtr(srcAlloc, srcXoff, srcYoff + i, srcLod, srcFace);
- memcpy(dstPtr, srcPtr, w * elementSize);
-
- //ALOGE("COPIED dstXoff(%u), dstYoff(%u), dstLod(%u), dstFace(%u), w(%u), h(%u), srcXoff(%u), srcYoff(%u), srcLod(%u), srcFace(%u)",
- // dstXoff, dstYoff, dstLod, dstFace, w, h, srcXoff, srcYoff, srcLod, srcFace);
- }
-}
-
-void rsdAllocationData2D_alloc(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod,
- RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h,
- const android::renderscript::Allocation *srcAlloc,
- uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod,
- RsAllocationCubemapFace srcFace) {
- if (!dstAlloc->getIsScript() && !srcAlloc->getIsScript()) {
- rsc->setError(RS_ERROR_FATAL_DRIVER, "Non-script allocation copies not "
- "yet implemented.");
- return;
- }
- rsdAllocationData2D_alloc_script(rsc, dstAlloc, dstXoff, dstYoff,
- dstLod, dstFace, w, h, srcAlloc,
- srcXoff, srcYoff, srcLod, srcFace);
-}
-
-void rsdAllocationData3D_alloc(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff,
- uint32_t dstLod, RsAllocationCubemapFace dstFace,
- uint32_t w, uint32_t h, uint32_t d,
- const android::renderscript::Allocation *srcAlloc,
- uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff,
- uint32_t srcLod, RsAllocationCubemapFace srcFace) {
-}
-
-void rsdAllocationElementData1D(const Context *rsc, const Allocation *alloc,
- uint32_t x,
- const void *data, uint32_t cIdx, uint32_t sizeBytes) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- uint32_t eSize = alloc->mHal.state.elementSizeBytes;
- uint8_t * ptr = drv->mallocPtr;
- ptr += eSize * x;
-
- const Element * e = alloc->mHal.state.type->getElement()->getField(cIdx);
- ptr += alloc->mHal.state.type->getElement()->getFieldOffsetBytes(cIdx);
-
- if (alloc->mHal.state.hasReferences) {
- e->incRefs(data);
- e->decRefs(ptr);
- }
-
- memcpy(ptr, data, sizeBytes);
- drv->uploadDeferred = true;
-}
-
-void rsdAllocationElementData2D(const Context *rsc, const Allocation *alloc,
- uint32_t x, uint32_t y,
- const void *data, uint32_t cIdx, uint32_t sizeBytes) {
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- uint32_t eSize = alloc->mHal.state.elementSizeBytes;
- uint8_t * ptr = drv->mallocPtr;
- ptr += eSize * (x + y * alloc->mHal.state.dimensionX);
-
- const Element * e = alloc->mHal.state.type->getElement()->getField(cIdx);
- ptr += alloc->mHal.state.type->getElement()->getFieldOffsetBytes(cIdx);
-
- if (alloc->mHal.state.hasReferences) {
- e->incRefs(data);
- e->decRefs(ptr);
- }
-
- memcpy(ptr, data, sizeBytes);
- drv->uploadDeferred = true;
-}
-
-
diff --git a/libs/rs/driver/rsdAllocation.h b/libs/rs/driver/rsdAllocation.h
deleted file mode 100644
index e3a5126..0000000
--- a/libs/rs/driver/rsdAllocation.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef RSD_ALLOCATION_H
-#define RSD_ALLOCATION_H
-
-#include <rs_hal.h>
-#include <rsRuntime.h>
-
-#include <GLES/gl.h>
-#include <GLES2/gl2.h>
-
-class RsdFrameBufferObj;
-struct ANativeWindowBuffer;
-
-struct DrvAllocation {
- // Is this a legal structure to be used as a texture source.
- // Initially this will require 1D or 2D and color data
- uint32_t textureID;
-
- // Is this a legal structure to be used as a vertex source.
- // Initially this will require 1D and x(yzw). Additional per element data
- // is allowed.
- uint32_t bufferID;
-
- // Is this a legal structure to be used as an FBO render target
- uint32_t renderTargetID;
-
- uint8_t * mallocPtr;
-
- GLenum glTarget;
- GLenum glType;
- GLenum glFormat;
-
- bool uploadDeferred;
-
- RsdFrameBufferObj * readBackFBO;
- ANativeWindowBuffer *wndBuffer;
-};
-
-GLenum rsdTypeToGLType(RsDataType t);
-GLenum rsdKindToGLFormat(RsDataKind k);
-
-
-bool rsdAllocationInit(const android::renderscript::Context *rsc,
- android::renderscript::Allocation *alloc,
- bool forceZero);
-void rsdAllocationDestroy(const android::renderscript::Context *rsc,
- android::renderscript::Allocation *alloc);
-
-void rsdAllocationResize(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc,
- const android::renderscript::Type *newType, bool zeroNew);
-void rsdAllocationSyncAll(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc,
- RsAllocationUsageType src);
-void rsdAllocationMarkDirty(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc);
-int32_t rsdAllocationInitSurfaceTexture(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc);
-void rsdAllocationSetSurfaceTexture(const android::renderscript::Context *rsc,
- android::renderscript::Allocation *alloc, ANativeWindow *nw);
-void rsdAllocationIoSend(const android::renderscript::Context *rsc,
- android::renderscript::Allocation *alloc);
-void rsdAllocationIoReceive(const android::renderscript::Context *rsc,
- android::renderscript::Allocation *alloc);
-
-void rsdAllocationData1D(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc,
- uint32_t xoff, uint32_t lod, uint32_t count,
- const void *data, uint32_t sizeBytes);
-void rsdAllocationData2D(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc,
- uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h,
- const void *data, uint32_t sizeBytes);
-void rsdAllocationData3D(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc,
- uint32_t xoff, uint32_t yoff, uint32_t zoff,
- uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes);
-
-void rsdAllocationData1D_alloc(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstLod, uint32_t count,
- const android::renderscript::Allocation *srcAlloc,
- uint32_t srcXoff, uint32_t srcLod);
-void rsdAllocationData2D_alloc(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod,
- RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h,
- const android::renderscript::Allocation *srcAlloc,
- uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod,
- RsAllocationCubemapFace srcFace);
-void rsdAllocationData3D_alloc(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff,
- uint32_t dstLod, RsAllocationCubemapFace dstFace,
- uint32_t w, uint32_t h, uint32_t d,
- const android::renderscript::Allocation *srcAlloc,
- uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff,
- uint32_t srcLod, RsAllocationCubemapFace srcFace);
-
-void rsdAllocationElementData1D(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc,
- uint32_t x,
- const void *data, uint32_t elementOff, uint32_t sizeBytes);
-void rsdAllocationElementData2D(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc,
- uint32_t x, uint32_t y,
- const void *data, uint32_t elementOff, uint32_t sizeBytes);
-
-
-
-
-#endif
diff --git a/libs/rs/driver/rsdBcc.cpp b/libs/rs/driver/rsdBcc.cpp
deleted file mode 100644
index dd78684..0000000
--- a/libs/rs/driver/rsdBcc.cpp
+++ /dev/null
@@ -1,541 +0,0 @@
-/*
- * Copyright (C) 2011-2012 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.
- */
-
-#include "rsdCore.h"
-#include "rsdBcc.h"
-#include "rsdRuntime.h"
-
-#include <bcinfo/MetadataExtractor.h>
-
-#include "rsContext.h"
-#include "rsScriptC.h"
-
-#include "utils/Timers.h"
-#include "utils/StopWatch.h"
-extern "C" {
-#include "libdex/ZipArchive.h"
-}
-
-using namespace android;
-using namespace android::renderscript;
-
-struct DrvScript {
- int (*mRoot)();
- int (*mRootExpand)();
- void (*mInit)();
- void (*mFreeChildren)();
-
- BCCScriptRef mBccScript;
-
- bcinfo::MetadataExtractor *ME;
-
- InvokeFunc_t *mInvokeFunctions;
- ForEachFunc_t *mForEachFunctions;
- void ** mFieldAddress;
- bool * mFieldIsObject;
- const uint32_t *mExportForEachSignatureList;
-
- const uint8_t * mScriptText;
- uint32_t mScriptTextLength;
-};
-
-typedef void (*outer_foreach_t)(
- const android::renderscript::RsForEachStubParamStruct *,
- uint32_t x1, uint32_t x2,
- uint32_t instep, uint32_t outstep);
-
-static Script * setTLS(Script *sc) {
- ScriptTLSStruct * tls = (ScriptTLSStruct *)pthread_getspecific(rsdgThreadTLSKey);
- rsAssert(tls);
- Script *old = tls->mScript;
- tls->mScript = sc;
- return old;
-}
-
-
-bool rsdScriptInit(const Context *rsc,
- ScriptC *script,
- char const *resName,
- char const *cacheDir,
- uint8_t const *bitcode,
- size_t bitcodeSize,
- uint32_t flags) {
- //ALOGE("rsdScriptCreate %p %p %p %p %i %i %p", rsc, resName, cacheDir, bitcode, bitcodeSize, flags, lookupFunc);
-
- pthread_mutex_lock(&rsdgInitMutex);
-
- size_t exportFuncCount = 0;
- size_t exportVarCount = 0;
- size_t objectSlotCount = 0;
- size_t exportForEachSignatureCount = 0;
-
- DrvScript *drv = (DrvScript *)calloc(1, sizeof(DrvScript));
- if (drv == NULL) {
- goto error;
- }
- script->mHal.drv = drv;
-
- drv->mBccScript = bccCreateScript();
- script->mHal.info.isThreadable = true;
- drv->mScriptText = bitcode;
- drv->mScriptTextLength = bitcodeSize;
-
-
- drv->ME = new bcinfo::MetadataExtractor((const char*)drv->mScriptText,
- drv->mScriptTextLength);
- if (!drv->ME->extract()) {
- ALOGE("bcinfo: failed to read script metadata");
- goto error;
- }
-
- //ALOGE("mBccScript %p", script->mBccScript);
-
- if (bccRegisterSymbolCallback(drv->mBccScript, &rsdLookupRuntimeStub, script) != 0) {
- ALOGE("bcc: FAILS to register symbol callback");
- goto error;
- }
-
- if (bccReadBC(drv->mBccScript,
- resName,
- (char const *)drv->mScriptText,
- drv->mScriptTextLength, 0) != 0) {
- ALOGE("bcc: FAILS to read bitcode");
- goto error;
- }
-
- if (bccLinkFile(drv->mBccScript, "/system/lib/libclcore.bc", 0) != 0) {
- ALOGE("bcc: FAILS to link bitcode");
- goto error;
- }
-
- if (bccPrepareExecutable(drv->mBccScript, cacheDir, resName, 0) != 0) {
- ALOGE("bcc: FAILS to prepare executable");
- goto error;
- }
-
- drv->mRoot = reinterpret_cast<int (*)()>(bccGetFuncAddr(drv->mBccScript, "root"));
- drv->mRootExpand = reinterpret_cast<int (*)()>(bccGetFuncAddr(drv->mBccScript, "root.expand"));
- drv->mInit = reinterpret_cast<void (*)()>(bccGetFuncAddr(drv->mBccScript, "init"));
- drv->mFreeChildren = reinterpret_cast<void (*)()>(bccGetFuncAddr(drv->mBccScript, ".rs.dtor"));
-
- exportFuncCount = drv->ME->getExportFuncCount();
- if (exportFuncCount > 0) {
- drv->mInvokeFunctions = (InvokeFunc_t*) calloc(exportFuncCount,
- sizeof(InvokeFunc_t));
- bccGetExportFuncList(drv->mBccScript, exportFuncCount,
- (void **) drv->mInvokeFunctions);
- } else {
- drv->mInvokeFunctions = NULL;
- }
-
- exportVarCount = drv->ME->getExportVarCount();
- if (exportVarCount > 0) {
- drv->mFieldAddress = (void **) calloc(exportVarCount, sizeof(void*));
- drv->mFieldIsObject = (bool *) calloc(exportVarCount, sizeof(bool));
- bccGetExportVarList(drv->mBccScript, exportVarCount,
- (void **) drv->mFieldAddress);
- } else {
- drv->mFieldAddress = NULL;
- drv->mFieldIsObject = NULL;
- }
-
- objectSlotCount = drv->ME->getObjectSlotCount();
- if (objectSlotCount > 0) {
- const uint32_t *objectSlotList = drv->ME->getObjectSlotList();
- for (uint32_t ct=0; ct < objectSlotCount; ct++) {
- drv->mFieldIsObject[objectSlotList[ct]] = true;
- }
- }
-
- exportForEachSignatureCount = drv->ME->getExportForEachSignatureCount();
- drv->mExportForEachSignatureList = drv->ME->getExportForEachSignatureList();
- if (exportForEachSignatureCount > 0) {
- drv->mForEachFunctions =
- (ForEachFunc_t*) calloc(exportForEachSignatureCount,
- sizeof(ForEachFunc_t));
- bccGetExportForEachList(drv->mBccScript, exportForEachSignatureCount,
- (void **) drv->mForEachFunctions);
- } else {
- drv->mForEachFunctions = NULL;
- }
-
- // Copy info over to runtime
- script->mHal.info.exportedFunctionCount = drv->ME->getExportFuncCount();
- script->mHal.info.exportedVariableCount = drv->ME->getExportVarCount();
- script->mHal.info.exportedPragmaCount = drv->ME->getPragmaCount();
- script->mHal.info.exportedPragmaKeyList = drv->ME->getPragmaKeyList();
- script->mHal.info.exportedPragmaValueList = drv->ME->getPragmaValueList();
-
- if (drv->mRootExpand) {
- script->mHal.info.root = drv->mRootExpand;
- } else {
- script->mHal.info.root = drv->mRoot;
- }
-
- pthread_mutex_unlock(&rsdgInitMutex);
- return true;
-
-error:
-
- pthread_mutex_unlock(&rsdgInitMutex);
- if (drv->ME) {
- delete drv->ME;
- drv->ME = NULL;
- }
- free(drv);
- return false;
-
-}
-
-typedef struct {
- Context *rsc;
- Script *script;
- ForEachFunc_t kernel;
- uint32_t sig;
- const Allocation * ain;
- Allocation * aout;
- const void * usr;
- size_t usrLen;
-
- uint32_t mSliceSize;
- volatile int mSliceNum;
-
- const uint8_t *ptrIn;
- uint32_t eStrideIn;
- uint8_t *ptrOut;
- uint32_t eStrideOut;
-
- uint32_t xStart;
- uint32_t xEnd;
- uint32_t yStart;
- uint32_t yEnd;
- uint32_t zStart;
- uint32_t zEnd;
- uint32_t arrayStart;
- uint32_t arrayEnd;
-
- uint32_t dimX;
- uint32_t dimY;
- uint32_t dimZ;
- uint32_t dimArray;
-} MTLaunchStruct;
-typedef void (*rs_t)(const void *, void *, const void *, uint32_t, uint32_t, uint32_t, uint32_t);
-
-static void wc_xy(void *usr, uint32_t idx) {
- MTLaunchStruct *mtls = (MTLaunchStruct *)usr;
- RsForEachStubParamStruct p;
- memset(&p, 0, sizeof(p));
- p.usr = mtls->usr;
- p.usr_len = mtls->usrLen;
- RsdHal * dc = (RsdHal *)mtls->rsc->mHal.drv;
- uint32_t sig = mtls->sig;
-
- outer_foreach_t fn = (outer_foreach_t) mtls->kernel;
- while (1) {
- uint32_t slice = (uint32_t)android_atomic_inc(&mtls->mSliceNum);
- uint32_t yStart = mtls->yStart + slice * mtls->mSliceSize;
- uint32_t yEnd = yStart + mtls->mSliceSize;
- yEnd = rsMin(yEnd, mtls->yEnd);
- if (yEnd <= yStart) {
- return;
- }
-
- //ALOGE("usr idx %i, x %i,%i y %i,%i", idx, mtls->xStart, mtls->xEnd, yStart, yEnd);
- //ALOGE("usr ptr in %p, out %p", mtls->ptrIn, mtls->ptrOut);
- for (p.y = yStart; p.y < yEnd; p.y++) {
- uint32_t offset = mtls->dimX * p.y;
- p.out = mtls->ptrOut + (mtls->eStrideOut * offset);
- p.in = mtls->ptrIn + (mtls->eStrideIn * offset);
- fn(&p, mtls->xStart, mtls->xEnd, mtls->eStrideIn, mtls->eStrideOut);
- }
- }
-}
-
-static void wc_x(void *usr, uint32_t idx) {
- MTLaunchStruct *mtls = (MTLaunchStruct *)usr;
- RsForEachStubParamStruct p;
- memset(&p, 0, sizeof(p));
- p.usr = mtls->usr;
- p.usr_len = mtls->usrLen;
- RsdHal * dc = (RsdHal *)mtls->rsc->mHal.drv;
- uint32_t sig = mtls->sig;
-
- outer_foreach_t fn = (outer_foreach_t) mtls->kernel;
- while (1) {
- uint32_t slice = (uint32_t)android_atomic_inc(&mtls->mSliceNum);
- uint32_t xStart = mtls->xStart + slice * mtls->mSliceSize;
- uint32_t xEnd = xStart + mtls->mSliceSize;
- xEnd = rsMin(xEnd, mtls->xEnd);
- if (xEnd <= xStart) {
- return;
- }
-
- //ALOGE("usr slice %i idx %i, x %i,%i", slice, idx, xStart, xEnd);
- //ALOGE("usr ptr in %p, out %p", mtls->ptrIn, mtls->ptrOut);
-
- p.out = mtls->ptrOut + (mtls->eStrideOut * xStart);
- p.in = mtls->ptrIn + (mtls->eStrideIn * xStart);
- fn(&p, xStart, xEnd, mtls->eStrideIn, mtls->eStrideOut);
- }
-}
-
-void rsdScriptInvokeForEach(const Context *rsc,
- Script *s,
- uint32_t slot,
- const Allocation * ain,
- Allocation * aout,
- const void * usr,
- uint32_t usrLen,
- const RsScriptCall *sc) {
-
- RsdHal * dc = (RsdHal *)rsc->mHal.drv;
-
- MTLaunchStruct mtls;
- memset(&mtls, 0, sizeof(mtls));
-
- DrvScript *drv = (DrvScript *)s->mHal.drv;
- mtls.kernel = drv->mForEachFunctions[slot];
- rsAssert(mtls.kernel != NULL);
- mtls.sig = 0x1f; // temp fix for old apps, full table in slang_rs_export_foreach.cpp
- if (drv->mExportForEachSignatureList) {
- mtls.sig = drv->mExportForEachSignatureList[slot];
- }
- if (ain) {
- mtls.dimX = ain->getType()->getDimX();
- mtls.dimY = ain->getType()->getDimY();
- mtls.dimZ = ain->getType()->getDimZ();
- //mtls.dimArray = ain->getType()->getDimArray();
- } else if (aout) {
- mtls.dimX = aout->getType()->getDimX();
- mtls.dimY = aout->getType()->getDimY();
- mtls.dimZ = aout->getType()->getDimZ();
- //mtls.dimArray = aout->getType()->getDimArray();
- } else {
- rsc->setError(RS_ERROR_BAD_SCRIPT, "rsForEach called with null allocations");
- return;
- }
-
- if (!sc || (sc->xEnd == 0)) {
- mtls.xEnd = mtls.dimX;
- } else {
- rsAssert(sc->xStart < mtls.dimX);
- rsAssert(sc->xEnd <= mtls.dimX);
- rsAssert(sc->xStart < sc->xEnd);
- mtls.xStart = rsMin(mtls.dimX, sc->xStart);
- mtls.xEnd = rsMin(mtls.dimX, sc->xEnd);
- if (mtls.xStart >= mtls.xEnd) return;
- }
-
- if (!sc || (sc->yEnd == 0)) {
- mtls.yEnd = mtls.dimY;
- } else {
- rsAssert(sc->yStart < mtls.dimY);
- rsAssert(sc->yEnd <= mtls.dimY);
- rsAssert(sc->yStart < sc->yEnd);
- mtls.yStart = rsMin(mtls.dimY, sc->yStart);
- mtls.yEnd = rsMin(mtls.dimY, sc->yEnd);
- if (mtls.yStart >= mtls.yEnd) return;
- }
-
- mtls.xEnd = rsMax((uint32_t)1, mtls.xEnd);
- mtls.yEnd = rsMax((uint32_t)1, mtls.yEnd);
- mtls.zEnd = rsMax((uint32_t)1, mtls.zEnd);
- mtls.arrayEnd = rsMax((uint32_t)1, mtls.arrayEnd);
-
- rsAssert(!ain || (ain->getType()->getDimZ() == 0));
-
- Context *mrsc = (Context *)rsc;
- Script * oldTLS = setTLS(s);
-
- mtls.rsc = mrsc;
- mtls.ain = ain;
- mtls.aout = aout;
- mtls.script = s;
- mtls.usr = usr;
- mtls.usrLen = usrLen;
- mtls.mSliceSize = 10;
- mtls.mSliceNum = 0;
-
- mtls.ptrIn = NULL;
- mtls.eStrideIn = 0;
- if (ain) {
- mtls.ptrIn = (const uint8_t *)ain->getPtr();
- mtls.eStrideIn = ain->getType()->getElementSizeBytes();
- }
-
- mtls.ptrOut = NULL;
- mtls.eStrideOut = 0;
- if (aout) {
- mtls.ptrOut = (uint8_t *)aout->getPtr();
- mtls.eStrideOut = aout->getType()->getElementSizeBytes();
- }
-
- if ((dc->mWorkers.mCount > 1) && s->mHal.info.isThreadable) {
- if (mtls.dimY > 1) {
- rsdLaunchThreads(mrsc, wc_xy, &mtls);
- } else {
- rsdLaunchThreads(mrsc, wc_x, &mtls);
- }
-
- //ALOGE("launch 1");
- } else {
- RsForEachStubParamStruct p;
- memset(&p, 0, sizeof(p));
- p.usr = mtls.usr;
- p.usr_len = mtls.usrLen;
- uint32_t sig = mtls.sig;
-
- //ALOGE("launch 3");
- outer_foreach_t fn = (outer_foreach_t) mtls.kernel;
- for (p.ar[0] = mtls.arrayStart; p.ar[0] < mtls.arrayEnd; p.ar[0]++) {
- for (p.z = mtls.zStart; p.z < mtls.zEnd; p.z++) {
- for (p.y = mtls.yStart; p.y < mtls.yEnd; p.y++) {
- uint32_t offset = mtls.dimX * mtls.dimY * mtls.dimZ * p.ar[0] +
- mtls.dimX * mtls.dimY * p.z +
- mtls.dimX * p.y;
- p.out = mtls.ptrOut + (mtls.eStrideOut * offset);
- p.in = mtls.ptrIn + (mtls.eStrideIn * offset);
- fn(&p, mtls.xStart, mtls.xEnd, mtls.eStrideIn,
- mtls.eStrideOut);
- }
- }
- }
- }
-
- setTLS(oldTLS);
-}
-
-
-int rsdScriptInvokeRoot(const Context *dc, Script *script) {
- DrvScript *drv = (DrvScript *)script->mHal.drv;
-
- Script * oldTLS = setTLS(script);
- int ret = drv->mRoot();
- setTLS(oldTLS);
-
- return ret;
-}
-
-void rsdScriptInvokeInit(const Context *dc, Script *script) {
- DrvScript *drv = (DrvScript *)script->mHal.drv;
-
- if (drv->mInit) {
- drv->mInit();
- }
-}
-
-void rsdScriptInvokeFreeChildren(const Context *dc, Script *script) {
- DrvScript *drv = (DrvScript *)script->mHal.drv;
-
- if (drv->mFreeChildren) {
- drv->mFreeChildren();
- }
-}
-
-void rsdScriptInvokeFunction(const Context *dc, Script *script,
- uint32_t slot,
- const void *params,
- size_t paramLength) {
- DrvScript *drv = (DrvScript *)script->mHal.drv;
- //ALOGE("invoke %p %p %i %p %i", dc, script, slot, params, paramLength);
-
- Script * oldTLS = setTLS(script);
- ((void (*)(const void *, uint32_t))
- drv->mInvokeFunctions[slot])(params, paramLength);
- setTLS(oldTLS);
-}
-
-void rsdScriptSetGlobalVar(const Context *dc, const Script *script,
- uint32_t slot, void *data, size_t dataLength) {
- DrvScript *drv = (DrvScript *)script->mHal.drv;
- //rsAssert(!script->mFieldIsObject[slot]);
- //ALOGE("setGlobalVar %p %p %i %p %i", dc, script, slot, data, dataLength);
-
- int32_t *destPtr = ((int32_t **)drv->mFieldAddress)[slot];
- if (!destPtr) {
- //ALOGV("Calling setVar on slot = %i which is null", slot);
- return;
- }
-
- memcpy(destPtr, data, dataLength);
-}
-
-void rsdScriptSetGlobalBind(const Context *dc, const Script *script, uint32_t slot, void *data) {
- DrvScript *drv = (DrvScript *)script->mHal.drv;
- //rsAssert(!script->mFieldIsObject[slot]);
- //ALOGE("setGlobalBind %p %p %i %p", dc, script, slot, data);
-
- int32_t *destPtr = ((int32_t **)drv->mFieldAddress)[slot];
- if (!destPtr) {
- //ALOGV("Calling setVar on slot = %i which is null", slot);
- return;
- }
-
- memcpy(destPtr, &data, sizeof(void *));
-}
-
-void rsdScriptSetGlobalObj(const Context *dc, const Script *script, uint32_t slot, ObjectBase *data) {
- DrvScript *drv = (DrvScript *)script->mHal.drv;
- //rsAssert(script->mFieldIsObject[slot]);
- //ALOGE("setGlobalObj %p %p %i %p", dc, script, slot, data);
-
- int32_t *destPtr = ((int32_t **)drv->mFieldAddress)[slot];
- if (!destPtr) {
- //ALOGV("Calling setVar on slot = %i which is null", slot);
- return;
- }
-
- rsrSetObject(dc, script, (ObjectBase **)destPtr, data);
-}
-
-void rsdScriptDestroy(const Context *dc, Script *script) {
- DrvScript *drv = (DrvScript *)script->mHal.drv;
-
- if (drv->mFieldAddress) {
- size_t exportVarCount = drv->ME->getExportVarCount();
- for (size_t ct = 0; ct < exportVarCount; ct++) {
- if (drv->mFieldIsObject[ct]) {
- // The field address can be NULL if the script-side has
- // optimized the corresponding global variable away.
- if (drv->mFieldAddress[ct]) {
- rsrClearObject(dc, script, (ObjectBase **)drv->mFieldAddress[ct]);
- }
- }
- }
- free(drv->mFieldAddress);
- drv->mFieldAddress = NULL;
- free(drv->mFieldIsObject);
- drv->mFieldIsObject = NULL; }
-
- if (drv->mInvokeFunctions) {
- free(drv->mInvokeFunctions);
- drv->mInvokeFunctions = NULL;
- }
-
- if (drv->mForEachFunctions) {
- free(drv->mForEachFunctions);
- drv->mForEachFunctions = NULL;
- }
-
- delete drv->ME;
- drv->ME = NULL;
-
- free(drv);
- script->mHal.drv = NULL;
-
-}
-
-
diff --git a/libs/rs/driver/rsdBcc.h b/libs/rs/driver/rsdBcc.h
deleted file mode 100644
index 5f83ed2..0000000
--- a/libs/rs/driver/rsdBcc.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef RSD_BCC_H
-#define RSD_BCC_H
-
-#include <rs_hal.h>
-#include <rsRuntime.h>
-
-
-bool rsdScriptInit(const android::renderscript::Context *, android::renderscript::ScriptC *,
- char const *resName, char const *cacheDir,
- uint8_t const *bitcode, size_t bitcodeSize, uint32_t flags);
-void rsdScriptInvokeFunction(const android::renderscript::Context *dc,
- android::renderscript::Script *script,
- uint32_t slot,
- const void *params,
- size_t paramLength);
-
-void rsdScriptInvokeForEach(const android::renderscript::Context *rsc,
- android::renderscript::Script *s,
- uint32_t slot,
- const android::renderscript::Allocation * ain,
- android::renderscript::Allocation * aout,
- const void * usr,
- uint32_t usrLen,
- const RsScriptCall *sc);
-
-int rsdScriptInvokeRoot(const android::renderscript::Context *dc,
- android::renderscript::Script *script);
-void rsdScriptInvokeInit(const android::renderscript::Context *dc,
- android::renderscript::Script *script);
-void rsdScriptInvokeFreeChildren(const android::renderscript::Context *dc,
- android::renderscript::Script *script);
-
-void rsdScriptSetGlobalVar(const android::renderscript::Context *,
- const android::renderscript::Script *,
- uint32_t slot, void *data, size_t dataLen);
-void rsdScriptSetGlobalBind(const android::renderscript::Context *,
- const android::renderscript::Script *,
- uint32_t slot, void *data);
-void rsdScriptSetGlobalObj(const android::renderscript::Context *,
- const android::renderscript::Script *,
- uint32_t slot, android::renderscript::ObjectBase *data);
-
-void rsdScriptSetGlobal(const android::renderscript::Context *dc,
- const android::renderscript::Script *script,
- uint32_t slot,
- void *data,
- size_t dataLength);
-void rsdScriptGetGlobal(const android::renderscript::Context *dc,
- const android::renderscript::Script *script,
- uint32_t slot,
- void *data,
- size_t dataLength);
-void rsdScriptDestroy(const android::renderscript::Context *dc,
- android::renderscript::Script *script);
-
-
-#endif
diff --git a/libs/rs/driver/rsdCore.cpp b/libs/rs/driver/rsdCore.cpp
deleted file mode 100644
index 6a532e9..0000000
--- a/libs/rs/driver/rsdCore.cpp
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
- * Copyright (C) 2011-2012 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.
- */
-
-#include "rsdCore.h"
-#include "rsdAllocation.h"
-#include "rsdBcc.h"
-#include "rsdGL.h"
-#include "rsdPath.h"
-#include "rsdProgramStore.h"
-#include "rsdProgramRaster.h"
-#include "rsdProgramVertex.h"
-#include "rsdProgramFragment.h"
-#include "rsdMesh.h"
-#include "rsdSampler.h"
-#include "rsdFrameBuffer.h"
-
-#include <malloc.h>
-#include "rsContext.h"
-
-#include <sys/types.h>
-#include <sys/resource.h>
-#include <sched.h>
-#include <cutils/properties.h>
-#include <sys/syscall.h>
-#include <string.h>
-#include <bcc/bcc.h>
-
-using namespace android;
-using namespace android::renderscript;
-
-static void Shutdown(Context *rsc);
-static void SetPriority(const Context *rsc, int32_t priority);
-
-static RsdHalFunctions FunctionTable = {
- rsdGLInit,
- rsdGLShutdown,
- rsdGLSetSurface,
- rsdGLSwap,
-
- Shutdown,
- NULL,
- SetPriority,
- {
- rsdScriptInit,
- rsdScriptInvokeFunction,
- rsdScriptInvokeRoot,
- rsdScriptInvokeForEach,
- rsdScriptInvokeInit,
- rsdScriptInvokeFreeChildren,
- rsdScriptSetGlobalVar,
- rsdScriptSetGlobalBind,
- rsdScriptSetGlobalObj,
- rsdScriptDestroy
- },
-
- {
- rsdAllocationInit,
- rsdAllocationDestroy,
- rsdAllocationResize,
- rsdAllocationSyncAll,
- rsdAllocationMarkDirty,
- rsdAllocationInitSurfaceTexture,
- rsdAllocationSetSurfaceTexture,
- rsdAllocationIoSend,
- rsdAllocationIoReceive,
- rsdAllocationData1D,
- rsdAllocationData2D,
- rsdAllocationData3D,
- rsdAllocationData1D_alloc,
- rsdAllocationData2D_alloc,
- rsdAllocationData3D_alloc,
- rsdAllocationElementData1D,
- rsdAllocationElementData2D
- },
-
-
- {
- rsdProgramStoreInit,
- rsdProgramStoreSetActive,
- rsdProgramStoreDestroy
- },
-
- {
- rsdProgramRasterInit,
- rsdProgramRasterSetActive,
- rsdProgramRasterDestroy
- },
-
- {
- rsdProgramVertexInit,
- rsdProgramVertexSetActive,
- rsdProgramVertexDestroy
- },
-
- {
- rsdProgramFragmentInit,
- rsdProgramFragmentSetActive,
- rsdProgramFragmentDestroy
- },
-
- {
- rsdMeshInit,
- rsdMeshDraw,
- rsdMeshDestroy
- },
-
- {
- rsdPathInitStatic,
- rsdPathInitDynamic,
- rsdPathDraw,
- rsdPathDestroy
- },
-
- {
- rsdSamplerInit,
- rsdSamplerDestroy
- },
-
- {
- rsdFrameBufferInit,
- rsdFrameBufferSetActive,
- rsdFrameBufferDestroy
- },
-
-};
-
-pthread_key_t rsdgThreadTLSKey = 0;
-uint32_t rsdgThreadTLSKeyCount = 0;
-pthread_mutex_t rsdgInitMutex = PTHREAD_MUTEX_INITIALIZER;
-
-
-static void * HelperThreadProc(void *vrsc) {
- Context *rsc = static_cast<Context *>(vrsc);
- RsdHal *dc = (RsdHal *)rsc->mHal.drv;
-
-
- uint32_t idx = (uint32_t)android_atomic_inc(&dc->mWorkers.mLaunchCount);
-
- //ALOGV("RS helperThread starting %p idx=%i", rsc, idx);
-
- dc->mWorkers.mLaunchSignals[idx].init();
- dc->mWorkers.mNativeThreadId[idx] = gettid();
-
- int status = pthread_setspecific(rsdgThreadTLSKey, &dc->mTlsStruct);
- if (status) {
- ALOGE("pthread_setspecific %i", status);
- }
-
-#if 0
- typedef struct {uint64_t bits[1024 / 64]; } cpu_set_t;
- cpu_set_t cpuset;
- memset(&cpuset, 0, sizeof(cpuset));
- cpuset.bits[idx / 64] |= 1ULL << (idx % 64);
- int ret = syscall(241, rsc->mWorkers.mNativeThreadId[idx],
- sizeof(cpuset), &cpuset);
- ALOGE("SETAFFINITY ret = %i %s", ret, EGLUtils::strerror(ret));
-#endif
-
- while (!dc->mExit) {
- dc->mWorkers.mLaunchSignals[idx].wait();
- if (dc->mWorkers.mLaunchCallback) {
- dc->mWorkers.mLaunchCallback(dc->mWorkers.mLaunchData, idx);
- }
- android_atomic_dec(&dc->mWorkers.mRunningCount);
- dc->mWorkers.mCompleteSignal.set();
- }
-
- //ALOGV("RS helperThread exited %p idx=%i", rsc, idx);
- return NULL;
-}
-
-void rsdLaunchThreads(Context *rsc, WorkerCallback_t cbk, void *data) {
- RsdHal *dc = (RsdHal *)rsc->mHal.drv;
-
- dc->mWorkers.mLaunchData = data;
- dc->mWorkers.mLaunchCallback = cbk;
- android_atomic_release_store(dc->mWorkers.mCount, &dc->mWorkers.mRunningCount);
- for (uint32_t ct = 0; ct < dc->mWorkers.mCount; ct++) {
- dc->mWorkers.mLaunchSignals[ct].set();
- }
- while (android_atomic_acquire_load(&dc->mWorkers.mRunningCount) != 0) {
- dc->mWorkers.mCompleteSignal.wait();
- }
-}
-
-bool rsdHalInit(Context *rsc, uint32_t version_major, uint32_t version_minor) {
- rsc->mHal.funcs = FunctionTable;
-
- RsdHal *dc = (RsdHal *)calloc(1, sizeof(RsdHal));
- if (!dc) {
- ALOGE("Calloc for driver hal failed.");
- return false;
- }
- rsc->mHal.drv = dc;
-
- pthread_mutex_lock(&rsdgInitMutex);
- if (!rsdgThreadTLSKeyCount) {
- int status = pthread_key_create(&rsdgThreadTLSKey, NULL);
- if (status) {
- ALOGE("Failed to init thread tls key.");
- pthread_mutex_unlock(&rsdgInitMutex);
- return false;
- }
- }
- rsdgThreadTLSKeyCount++;
- pthread_mutex_unlock(&rsdgInitMutex);
-
- dc->mTlsStruct.mContext = rsc;
- dc->mTlsStruct.mScript = NULL;
- int status = pthread_setspecific(rsdgThreadTLSKey, &dc->mTlsStruct);
- if (status) {
- ALOGE("pthread_setspecific %i", status);
- }
-
-
- int cpu = sysconf(_SC_NPROCESSORS_ONLN);
- if(rsc->props.mDebugMaxThreads && (cpu > (int)rsc->props.mDebugMaxThreads)) {
- cpu = rsc->props.mDebugMaxThreads;
- }
- if (cpu < 2) {
- cpu = 0;
- }
- ALOGV("%p Launching thread(s), CPUs %i", rsc, cpu);
-
- dc->mWorkers.mCount = (uint32_t)cpu;
- dc->mWorkers.mThreadId = (pthread_t *) calloc(dc->mWorkers.mCount, sizeof(pthread_t));
- dc->mWorkers.mNativeThreadId = (pid_t *) calloc(dc->mWorkers.mCount, sizeof(pid_t));
- dc->mWorkers.mLaunchSignals = new Signal[dc->mWorkers.mCount];
- dc->mWorkers.mLaunchCallback = NULL;
-
- dc->mWorkers.mCompleteSignal.init();
-
- android_atomic_release_store(dc->mWorkers.mCount, &dc->mWorkers.mRunningCount);
- android_atomic_release_store(0, &dc->mWorkers.mLaunchCount);
-
- pthread_attr_t threadAttr;
- status = pthread_attr_init(&threadAttr);
- if (status) {
- ALOGE("Failed to init thread attribute.");
- return false;
- }
-
- for (uint32_t ct=0; ct < dc->mWorkers.mCount; ct++) {
- status = pthread_create(&dc->mWorkers.mThreadId[ct], &threadAttr, HelperThreadProc, rsc);
- if (status) {
- dc->mWorkers.mCount = ct;
- ALOGE("Created fewer than expected number of RS threads.");
- break;
- }
- }
- while (android_atomic_acquire_load(&dc->mWorkers.mRunningCount) != 0) {
- usleep(100);
- }
-
- pthread_attr_destroy(&threadAttr);
- return true;
-}
-
-
-void SetPriority(const Context *rsc, int32_t priority) {
- RsdHal *dc = (RsdHal *)rsc->mHal.drv;
- for (uint32_t ct=0; ct < dc->mWorkers.mCount; ct++) {
- setpriority(PRIO_PROCESS, dc->mWorkers.mNativeThreadId[ct], priority);
- }
- if (dc->mHasGraphics) {
- rsdGLSetPriority(rsc, priority);
- }
-}
-
-void Shutdown(Context *rsc) {
- RsdHal *dc = (RsdHal *)rsc->mHal.drv;
-
- dc->mExit = true;
- dc->mWorkers.mLaunchData = NULL;
- dc->mWorkers.mLaunchCallback = NULL;
- android_atomic_release_store(dc->mWorkers.mCount, &dc->mWorkers.mRunningCount);
- for (uint32_t ct = 0; ct < dc->mWorkers.mCount; ct++) {
- dc->mWorkers.mLaunchSignals[ct].set();
- }
- int status;
- void *res;
- for (uint32_t ct = 0; ct < dc->mWorkers.mCount; ct++) {
- status = pthread_join(dc->mWorkers.mThreadId[ct], &res);
- }
- rsAssert(android_atomic_acquire_load(&dc->mWorkers.mRunningCount) == 0);
-
- // Global structure cleanup.
- pthread_mutex_lock(&rsdgInitMutex);
- --rsdgThreadTLSKeyCount;
- if (!rsdgThreadTLSKeyCount) {
- pthread_key_delete(rsdgThreadTLSKey);
- }
- pthread_mutex_unlock(&rsdgInitMutex);
-
-}
-
diff --git a/libs/rs/driver/rsdCore.h b/libs/rs/driver/rsdCore.h
deleted file mode 100644
index 05ca13b..0000000
--- a/libs/rs/driver/rsdCore.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2011-2012 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.
- */
-
-#ifndef RSD_CORE_H
-#define RSD_CORE_H
-
-#include <rs_hal.h>
-
-#include "rsMutex.h"
-#include "rsSignal.h"
-
-#include "rsdGL.h"
-
-typedef void (* InvokeFunc_t)(void);
-typedef void (* ForEachFunc_t)(void);
-typedef void (*WorkerCallback_t)(void *usr, uint32_t idx);
-
-typedef struct RsdSymbolTableRec {
- const char * mName;
- void * mPtr;
- bool threadable;
-} RsdSymbolTable;
-
-typedef struct ScriptTLSStructRec {
- android::renderscript::Context * mContext;
- android::renderscript::Script * mScript;
-} ScriptTLSStruct;
-
-typedef struct RsdHalRec {
- uint32_t version_major;
- uint32_t version_minor;
- bool mHasGraphics;
-
- struct Workers {
- volatile int mRunningCount;
- volatile int mLaunchCount;
- uint32_t mCount;
- pthread_t *mThreadId;
- pid_t *mNativeThreadId;
- android::renderscript::Signal mCompleteSignal;
-
- android::renderscript::Signal *mLaunchSignals;
- WorkerCallback_t mLaunchCallback;
- void *mLaunchData;
- };
- Workers mWorkers;
- bool mExit;
-
- ScriptTLSStruct mTlsStruct;
-
- RsdGL gl;
-} RsdHal;
-
-extern pthread_key_t rsdgThreadTLSKey;
-extern uint32_t rsdgThreadTLSKeyCount;
-extern pthread_mutex_t rsdgInitMutex;
-
-
-void rsdLaunchThreads(android::renderscript::Context *rsc, WorkerCallback_t cbk, void *data);
-
-#endif
-
diff --git a/libs/rs/driver/rsdFrameBuffer.cpp b/libs/rs/driver/rsdFrameBuffer.cpp
deleted file mode 100644
index bb07d29..0000000
--- a/libs/rs/driver/rsdFrameBuffer.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-
-#include "rsdCore.h"
-#include "rsdFrameBuffer.h"
-#include "rsdFrameBufferObj.h"
-#include "rsdAllocation.h"
-
-#include "rsContext.h"
-#include "rsFBOCache.h"
-
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-
-using namespace android;
-using namespace android::renderscript;
-
-void setDepthAttachment(const Context *rsc, const FBOCache *fb) {
- RsdFrameBufferObj *fbo = (RsdFrameBufferObj*)fb->mHal.drv;
-
- DrvAllocation *depth = NULL;
- if (fb->mHal.state.depthTarget != NULL) {
- depth = (DrvAllocation *)fb->mHal.state.depthTarget->mHal.drv;
-
- if (depth->uploadDeferred) {
- rsdAllocationSyncAll(rsc, fb->mHal.state.depthTarget,
- RS_ALLOCATION_USAGE_SCRIPT);
- }
- }
- fbo->setDepthTarget(depth);
-}
-
-void setColorAttachment(const Context *rsc, const FBOCache *fb) {
- RsdFrameBufferObj *fbo = (RsdFrameBufferObj*)fb->mHal.drv;
- // Now attach color targets
- for (uint32_t i = 0; i < fb->mHal.state.colorTargetsCount; i ++) {
- DrvAllocation *color = NULL;
- if (fb->mHal.state.colorTargets[i] != NULL) {
- color = (DrvAllocation *)fb->mHal.state.colorTargets[i]->mHal.drv;
-
- if (color->uploadDeferred) {
- rsdAllocationSyncAll(rsc, fb->mHal.state.colorTargets[i],
- RS_ALLOCATION_USAGE_SCRIPT);
- }
- }
- fbo->setColorTarget(color, i);
- }
-}
-
-bool rsdFrameBufferInit(const Context *rsc, const FBOCache *fb) {
- RsdFrameBufferObj *fbo = new RsdFrameBufferObj();
- if (fbo == NULL) {
- return false;
- }
- fb->mHal.drv = fbo;
-
- RsdHal *dc = (RsdHal *)rsc->mHal.drv;
- dc->gl.currentFrameBuffer = fbo;
-
- return true;
-}
-
-void rsdFrameBufferSetActive(const Context *rsc, const FBOCache *fb) {
- setDepthAttachment(rsc, fb);
- setColorAttachment(rsc, fb);
-
- RsdFrameBufferObj *fbo = (RsdFrameBufferObj *)fb->mHal.drv;
- if (fb->mHal.state.colorTargets[0]) {
- fbo->setDimensions(fb->mHal.state.colorTargets[0]->getType()->getDimX(),
- fb->mHal.state.colorTargets[0]->getType()->getDimY());
- } else if (fb->mHal.state.depthTarget) {
- fbo->setDimensions(fb->mHal.state.depthTarget->getType()->getDimX(),
- fb->mHal.state.depthTarget->getType()->getDimY());
- }
-
- fbo->setActive(rsc);
-}
-
-void rsdFrameBufferDestroy(const Context *rsc, const FBOCache *fb) {
- RsdFrameBufferObj *fbo = (RsdFrameBufferObj *)fb->mHal.drv;
- delete fbo;
- fb->mHal.drv = NULL;
-}
-
-
diff --git a/libs/rs/driver/rsdFrameBuffer.h b/libs/rs/driver/rsdFrameBuffer.h
deleted file mode 100644
index dec59fc..0000000
--- a/libs/rs/driver/rsdFrameBuffer.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef RSD_FRAME_BUFFER_H
-#define RSD_FRAME_BUFFER_H
-
-#include <rs_hal.h>
-
-bool rsdFrameBufferInit(const android::renderscript::Context *rsc,
- const android::renderscript::FBOCache *fb);
-void rsdFrameBufferSetActive(const android::renderscript::Context *rsc,
- const android::renderscript::FBOCache *fb);
-void rsdFrameBufferDestroy(const android::renderscript::Context *rsc,
- const android::renderscript::FBOCache *fb);
-
-
-#endif // RSD_FRAME_BUFFER_H
diff --git a/libs/rs/driver/rsdFrameBufferObj.cpp b/libs/rs/driver/rsdFrameBufferObj.cpp
deleted file mode 100644
index 91452b0..0000000
--- a/libs/rs/driver/rsdFrameBufferObj.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-
-#include "rsdFrameBufferObj.h"
-#include "rsdAllocation.h"
-#include "rsdGL.h"
-
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-
-using namespace android;
-using namespace android::renderscript;
-
-RsdFrameBufferObj::RsdFrameBufferObj() {
- mFBOId = 0;
- mWidth = 0;
- mHeight = 0;
- mColorTargetsCount = 1;
- mColorTargets = new DrvAllocation*[mColorTargetsCount];
- for (uint32_t i = 0; i < mColorTargetsCount; i ++) {
- mColorTargets[i] = 0;
- }
- mDepthTarget = NULL;
- mDirty = true;
-}
-
-RsdFrameBufferObj::~RsdFrameBufferObj() {
- if(mFBOId != 0) {
- glDeleteFramebuffers(1, &mFBOId);
- }
- delete [] mColorTargets;
-}
-
-void RsdFrameBufferObj::checkError(const Context *rsc) {
- GLenum status;
- status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
- switch (status) {
- case GL_FRAMEBUFFER_COMPLETE:
- break;
- case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
- rsc->setError(RS_ERROR_BAD_VALUE,
- "Unable to set up render Target: RFRAMEBUFFER_INCOMPLETE_ATTACHMENT");
- break;
- case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
- rsc->setError(RS_ERROR_BAD_VALUE,
- "Unable to set up render Target: GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT");
- break;
- case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
- rsc->setError(RS_ERROR_BAD_VALUE,
- "Unable to set up render Target: GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS");
- break;
- case GL_FRAMEBUFFER_UNSUPPORTED:
- rsc->setError(RS_ERROR_BAD_VALUE,
- "Unable to set up render Target: GL_FRAMEBUFFER_UNSUPPORTED");
- break;
- }
-}
-
-
-void RsdFrameBufferObj::setDepthAttachment() {
- if (mDepthTarget != NULL) {
- if (mDepthTarget->textureID) {
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
- GL_TEXTURE_2D, mDepthTarget->textureID, 0);
- } else {
- glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
- GL_RENDERBUFFER, mDepthTarget->renderTargetID);
- }
- } else {
- // Reset last attachment
- glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0);
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
- }
-}
-
-void RsdFrameBufferObj::setColorAttachment() {
- // Now attach color targets
- for (uint32_t i = 0; i < mColorTargetsCount; i ++) {
- if (mColorTargets[i] != NULL) {
- if (mColorTargets[i]->textureID) {
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i,
- GL_TEXTURE_2D, mColorTargets[i]->textureID, 0);
- } else {
- glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i,
- GL_RENDERBUFFER, mColorTargets[i]->renderTargetID);
- }
- } else {
- // Reset last attachment
- glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i,
- GL_RENDERBUFFER, 0);
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i,
- GL_TEXTURE_2D, 0, 0);
- }
- }
-}
-
-bool RsdFrameBufferObj::renderToFramebuffer() {
- if (mDepthTarget != NULL) {
- return false;
- }
-
- for (uint32_t i = 0; i < mColorTargetsCount; i ++) {
- if (mColorTargets[i] != NULL) {
- return false;
- }
- }
- return true;
-}
-
-void RsdFrameBufferObj::setActive(const Context *rsc) {
- bool framebuffer = renderToFramebuffer();
- if (!framebuffer) {
- if(mFBOId == 0) {
- RSD_CALL_GL(glGenFramebuffers, 1, &mFBOId);
- }
- RSD_CALL_GL(glBindFramebuffer, GL_FRAMEBUFFER, mFBOId);
-
- if (mDirty) {
- setDepthAttachment();
- setColorAttachment();
- mDirty = false;
- }
-
- RSD_CALL_GL(glViewport, 0, 0, mWidth, mHeight);
- checkError(rsc);
- } else {
- RSD_CALL_GL(glBindFramebuffer, GL_FRAMEBUFFER, 0);
- RSD_CALL_GL(glViewport, 0, 0, rsc->getWidth(), rsc->getHeight());
- }
-}
diff --git a/libs/rs/driver/rsdFrameBufferObj.h b/libs/rs/driver/rsdFrameBufferObj.h
deleted file mode 100644
index c6e7deb..0000000
--- a/libs/rs/driver/rsdFrameBufferObj.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef _RSD_FRAMEBUFFER_OBJ_H_
-#define _RSD_FRAMEBUFFER_OBJ_H_
-
-#include <rsContext.h>
-
-class DrvAllocation;
-
-class RsdFrameBufferObj {
-public:
- RsdFrameBufferObj();
- ~RsdFrameBufferObj();
-
- void setActive(const android::renderscript::Context *rsc);
- void setColorTarget(DrvAllocation *color, uint32_t index) {
- mColorTargets[index] = color;
- mDirty = true;
- }
- void setDepthTarget(DrvAllocation *depth) {
- mDepthTarget = depth;
- mDirty = true;
- }
- void setDimensions(uint32_t width, uint32_t height) {
- mWidth = width;
- mHeight = height;
- }
-protected:
- uint32_t mFBOId;
- DrvAllocation **mColorTargets;
- uint32_t mColorTargetsCount;
- DrvAllocation *mDepthTarget;
-
- uint32_t mWidth;
- uint32_t mHeight;
-
- bool mDirty;
-
- bool renderToFramebuffer();
- void checkError(const android::renderscript::Context *rsc);
- void setColorAttachment();
- void setDepthAttachment();
-};
-
-#endif //_RSD_FRAMEBUFFER_STATE_H_
diff --git a/libs/rs/driver/rsdGL.cpp b/libs/rs/driver/rsdGL.cpp
deleted file mode 100644
index 0860417..0000000
--- a/libs/rs/driver/rsdGL.cpp
+++ /dev/null
@@ -1,546 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#include <ui/FramebufferNativeWindow.h>
-#include <ui/PixelFormat.h>
-
-#include <system/window.h>
-
-#include <sys/types.h>
-#include <sys/resource.h>
-#include <sched.h>
-
-#include <cutils/properties.h>
-
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-
-#include <string.h>
-
-#include "rsdCore.h"
-#include "rsdGL.h"
-
-#include <malloc.h>
-#include "rsContext.h"
-#include "rsDevice.h"
-#include "rsdShaderCache.h"
-#include "rsdVertexArray.h"
-#include "rsdFrameBufferObj.h"
-
-#include <gui/SurfaceTextureClient.h>
-#include <gui/DummyConsumer.h>
-
-using namespace android;
-using namespace android::renderscript;
-
-static int32_t gGLContextCount = 0;
-
-static void checkEglError(const char* op, EGLBoolean returnVal = EGL_TRUE) {
- struct EGLUtils {
- static const char *strerror(EGLint err) {
- switch (err){
- case EGL_SUCCESS: return "EGL_SUCCESS";
- case EGL_NOT_INITIALIZED: return "EGL_NOT_INITIALIZED";
- case EGL_BAD_ACCESS: return "EGL_BAD_ACCESS";
- case EGL_BAD_ALLOC: return "EGL_BAD_ALLOC";
- case EGL_BAD_ATTRIBUTE: return "EGL_BAD_ATTRIBUTE";
- case EGL_BAD_CONFIG: return "EGL_BAD_CONFIG";
- case EGL_BAD_CONTEXT: return "EGL_BAD_CONTEXT";
- case EGL_BAD_CURRENT_SURFACE: return "EGL_BAD_CURRENT_SURFACE";
- case EGL_BAD_DISPLAY: return "EGL_BAD_DISPLAY";
- case EGL_BAD_MATCH: return "EGL_BAD_MATCH";
- case EGL_BAD_NATIVE_PIXMAP: return "EGL_BAD_NATIVE_PIXMAP";
- case EGL_BAD_NATIVE_WINDOW: return "EGL_BAD_NATIVE_WINDOW";
- case EGL_BAD_PARAMETER: return "EGL_BAD_PARAMETER";
- case EGL_BAD_SURFACE: return "EGL_BAD_SURFACE";
- case EGL_CONTEXT_LOST: return "EGL_CONTEXT_LOST";
- default: return "UNKNOWN";
- }
- }
- };
-
- if (returnVal != EGL_TRUE) {
- fprintf(stderr, "%s() returned %d\n", op, returnVal);
- }
-
- for (EGLint error = eglGetError(); error != EGL_SUCCESS; error
- = eglGetError()) {
- fprintf(stderr, "after %s() eglError %s (0x%x)\n", op, EGLUtils::strerror(error),
- error);
- }
-}
-
-static void printEGLConfiguration(EGLDisplay dpy, EGLConfig config) {
-
-#define X(VAL) {VAL, #VAL}
- struct {EGLint attribute; const char* name;} names[] = {
- X(EGL_BUFFER_SIZE),
- X(EGL_ALPHA_SIZE),
- X(EGL_BLUE_SIZE),
- X(EGL_GREEN_SIZE),
- X(EGL_RED_SIZE),
- X(EGL_DEPTH_SIZE),
- X(EGL_STENCIL_SIZE),
- X(EGL_CONFIG_CAVEAT),
- X(EGL_CONFIG_ID),
- X(EGL_LEVEL),
- X(EGL_MAX_PBUFFER_HEIGHT),
- X(EGL_MAX_PBUFFER_PIXELS),
- X(EGL_MAX_PBUFFER_WIDTH),
- X(EGL_NATIVE_RENDERABLE),
- X(EGL_NATIVE_VISUAL_ID),
- X(EGL_NATIVE_VISUAL_TYPE),
- X(EGL_SAMPLES),
- X(EGL_SAMPLE_BUFFERS),
- X(EGL_SURFACE_TYPE),
- X(EGL_TRANSPARENT_TYPE),
- X(EGL_TRANSPARENT_RED_VALUE),
- X(EGL_TRANSPARENT_GREEN_VALUE),
- X(EGL_TRANSPARENT_BLUE_VALUE),
- X(EGL_BIND_TO_TEXTURE_RGB),
- X(EGL_BIND_TO_TEXTURE_RGBA),
- X(EGL_MIN_SWAP_INTERVAL),
- X(EGL_MAX_SWAP_INTERVAL),
- X(EGL_LUMINANCE_SIZE),
- X(EGL_ALPHA_MASK_SIZE),
- X(EGL_COLOR_BUFFER_TYPE),
- X(EGL_RENDERABLE_TYPE),
- X(EGL_CONFORMANT),
- };
-#undef X
-
- for (size_t j = 0; j < sizeof(names) / sizeof(names[0]); j++) {
- EGLint value = -1;
- EGLBoolean returnVal = eglGetConfigAttrib(dpy, config, names[j].attribute, &value);
- if (returnVal) {
- ALOGV(" %s: %d (0x%x)", names[j].name, value, value);
- }
- }
-}
-
-static void DumpDebug(RsdHal *dc) {
- ALOGE(" EGL ver %i %i", dc->gl.egl.majorVersion, dc->gl.egl.minorVersion);
- ALOGE(" EGL context %p surface %p, Display=%p", dc->gl.egl.context, dc->gl.egl.surface,
- dc->gl.egl.display);
- ALOGE(" GL vendor: %s", dc->gl.gl.vendor);
- ALOGE(" GL renderer: %s", dc->gl.gl.renderer);
- ALOGE(" GL Version: %s", dc->gl.gl.version);
- ALOGE(" GL Extensions: %s", dc->gl.gl.extensions);
- ALOGE(" GL int Versions %i %i", dc->gl.gl.majorVersion, dc->gl.gl.minorVersion);
-
- ALOGV("MAX Textures %i, %i %i", dc->gl.gl.maxVertexTextureUnits,
- dc->gl.gl.maxFragmentTextureImageUnits, dc->gl.gl.maxTextureImageUnits);
- ALOGV("MAX Attribs %i", dc->gl.gl.maxVertexAttribs);
- ALOGV("MAX Uniforms %i, %i", dc->gl.gl.maxVertexUniformVectors,
- dc->gl.gl.maxFragmentUniformVectors);
- ALOGV("MAX Varyings %i", dc->gl.gl.maxVaryingVectors);
-}
-
-void rsdGLShutdown(const Context *rsc) {
- RsdHal *dc = (RsdHal *)rsc->mHal.drv;
-
- dc->gl.shaderCache->cleanupAll();
- delete dc->gl.shaderCache;
- delete dc->gl.vertexArrayState;
-
- if (dc->gl.egl.context != EGL_NO_CONTEXT) {
- RSD_CALL_GL(eglMakeCurrent, dc->gl.egl.display,
- EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
- RSD_CALL_GL(eglDestroySurface, dc->gl.egl.display, dc->gl.egl.surfaceDefault);
- if (dc->gl.egl.surface != EGL_NO_SURFACE) {
- RSD_CALL_GL(eglDestroySurface, dc->gl.egl.display, dc->gl.egl.surface);
- }
- RSD_CALL_GL(eglDestroyContext, dc->gl.egl.display, dc->gl.egl.context);
- checkEglError("eglDestroyContext");
- }
-
- gGLContextCount--;
- if (!gGLContextCount) {
- RSD_CALL_GL(eglTerminate, dc->gl.egl.display);
- }
-}
-
-void getConfigData(const Context *rsc,
- EGLint *configAttribs, size_t configAttribsLen,
- uint32_t numSamples) {
- memset(configAttribs, 0, configAttribsLen*sizeof(*configAttribs));
-
- EGLint *configAttribsPtr = configAttribs;
-
- configAttribsPtr[0] = EGL_SURFACE_TYPE;
- configAttribsPtr[1] = EGL_WINDOW_BIT;
- configAttribsPtr += 2;
-
- configAttribsPtr[0] = EGL_RENDERABLE_TYPE;
- configAttribsPtr[1] = EGL_OPENGL_ES2_BIT;
- configAttribsPtr += 2;
-
- configAttribsPtr[0] = EGL_RED_SIZE;
- configAttribsPtr[1] = 8;
- configAttribsPtr += 2;
-
- configAttribsPtr[0] = EGL_GREEN_SIZE;
- configAttribsPtr[1] = 8;
- configAttribsPtr += 2;
-
- configAttribsPtr[0] = EGL_BLUE_SIZE;
- configAttribsPtr[1] = 8;
- configAttribsPtr += 2;
-
- if (rsc->mUserSurfaceConfig.alphaMin > 0) {
- configAttribsPtr[0] = EGL_ALPHA_SIZE;
- configAttribsPtr[1] = rsc->mUserSurfaceConfig.alphaMin;
- configAttribsPtr += 2;
- }
-
- if (rsc->mUserSurfaceConfig.depthMin > 0) {
- configAttribsPtr[0] = EGL_DEPTH_SIZE;
- configAttribsPtr[1] = rsc->mUserSurfaceConfig.depthMin;
- configAttribsPtr += 2;
- }
-
- if (rsc->mDev->mForceSW) {
- configAttribsPtr[0] = EGL_CONFIG_CAVEAT;
- configAttribsPtr[1] = EGL_SLOW_CONFIG;
- configAttribsPtr += 2;
- }
-
- if (numSamples > 1) {
- configAttribsPtr[0] = EGL_SAMPLE_BUFFERS;
- configAttribsPtr[1] = 1;
- configAttribsPtr[2] = EGL_SAMPLES;
- configAttribsPtr[3] = numSamples;
- configAttribsPtr += 4;
- }
-
- configAttribsPtr[0] = EGL_NONE;
- rsAssert(configAttribsPtr < (configAttribs + configAttribsLen));
-}
-
-bool rsdGLInit(const Context *rsc) {
- RsdHal *dc = (RsdHal *)rsc->mHal.drv;
-
- dc->gl.egl.numConfigs = -1;
-
- EGLint configAttribs[128];
- EGLint context_attribs2[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
-
- ALOGV("%p initEGL start", rsc);
- rsc->setWatchdogGL("eglGetDisplay", __LINE__, __FILE__);
- dc->gl.egl.display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
- checkEglError("eglGetDisplay");
-
- RSD_CALL_GL(eglInitialize, dc->gl.egl.display,
- &dc->gl.egl.majorVersion, &dc->gl.egl.minorVersion);
- checkEglError("eglInitialize");
-
- EGLBoolean ret;
-
- EGLint numConfigs = -1, n = 0;
- rsc->setWatchdogGL("eglChooseConfig", __LINE__, __FILE__);
-
- // Try minding a multisample config that matches the user request
- uint32_t minSample = rsc->mUserSurfaceConfig.samplesMin;
- uint32_t prefSample = rsc->mUserSurfaceConfig.samplesPref;
- for (uint32_t sampleCount = prefSample; sampleCount >= minSample; sampleCount--) {
- getConfigData(rsc, configAttribs, (sizeof(configAttribs) / sizeof(EGLint)), sampleCount);
- ret = eglChooseConfig(dc->gl.egl.display, configAttribs, 0, 0, &numConfigs);
- checkEglError("eglGetConfigs", ret);
- if (numConfigs > 0) {
- break;
- }
- }
-
- eglSwapInterval(dc->gl.egl.display, 0);
-
- if (numConfigs) {
- EGLConfig* const configs = new EGLConfig[numConfigs];
-
- rsc->setWatchdogGL("eglChooseConfig", __LINE__, __FILE__);
- ret = eglChooseConfig(dc->gl.egl.display,
- configAttribs, configs, numConfigs, &n);
- if (!ret || !n) {
- checkEglError("eglChooseConfig", ret);
- ALOGE("%p, couldn't find an EGLConfig matching the screen format\n", rsc);
- }
-
- // The first config is guaranteed to over-satisfy the constraints
- dc->gl.egl.config = configs[0];
-
- // go through the list and skip configs that over-satisfy our needs
- for (int i=0 ; i<n ; i++) {
- if (rsc->mUserSurfaceConfig.alphaMin <= 0) {
- EGLint alphaSize;
- eglGetConfigAttrib(dc->gl.egl.display,
- configs[i], EGL_ALPHA_SIZE, &alphaSize);
- if (alphaSize > 0) {
- continue;
- }
- }
-
- if (rsc->mUserSurfaceConfig.depthMin <= 0) {
- EGLint depthSize;
- eglGetConfigAttrib(dc->gl.egl.display,
- configs[i], EGL_DEPTH_SIZE, &depthSize);
- if (depthSize > 0) {
- continue;
- }
- }
-
- // Found one!
- dc->gl.egl.config = configs[i];
- break;
- }
-
- delete [] configs;
- }
-
- //if (props.mLogVisual) {
- if (0) {
- printEGLConfiguration(dc->gl.egl.display, dc->gl.egl.config);
- }
- //}
-
- rsc->setWatchdogGL("eglCreateContext", __LINE__, __FILE__);
- dc->gl.egl.context = eglCreateContext(dc->gl.egl.display, dc->gl.egl.config,
- EGL_NO_CONTEXT, context_attribs2);
- checkEglError("eglCreateContext");
- if (dc->gl.egl.context == EGL_NO_CONTEXT) {
- ALOGE("%p, eglCreateContext returned EGL_NO_CONTEXT", rsc);
- rsc->setWatchdogGL(NULL, 0, NULL);
- return false;
- }
- gGLContextCount++;
-
- // Create a BufferQueue with a fake consumer
- sp<BufferQueue> bq = new BufferQueue();
- sp<DummyConsumer> dummy = new DummyConsumer(bq);
- sp<SurfaceTextureClient> stc(new SurfaceTextureClient(static_cast<sp<ISurfaceTexture> >(bq)));
-
- dc->gl.egl.surfaceDefault = eglCreateWindowSurface(dc->gl.egl.display, dc->gl.egl.config,
- static_cast<ANativeWindow*>(stc.get()),
- NULL);
-
- checkEglError("eglCreateWindowSurface");
- if (dc->gl.egl.surfaceDefault == EGL_NO_SURFACE) {
- ALOGE("eglCreateWindowSurface returned EGL_NO_SURFACE");
- rsdGLShutdown(rsc);
- rsc->setWatchdogGL(NULL, 0, NULL);
- return false;
- }
-
- rsc->setWatchdogGL("eglMakeCurrent", __LINE__, __FILE__);
- ret = eglMakeCurrent(dc->gl.egl.display, dc->gl.egl.surfaceDefault,
- dc->gl.egl.surfaceDefault, dc->gl.egl.context);
- if (ret == EGL_FALSE) {
- ALOGE("eglMakeCurrent returned EGL_FALSE");
- checkEglError("eglMakeCurrent", ret);
- rsdGLShutdown(rsc);
- rsc->setWatchdogGL(NULL, 0, NULL);
- return false;
- }
-
- dc->gl.gl.version = glGetString(GL_VERSION);
- dc->gl.gl.vendor = glGetString(GL_VENDOR);
- dc->gl.gl.renderer = glGetString(GL_RENDERER);
- dc->gl.gl.extensions = glGetString(GL_EXTENSIONS);
-
- //ALOGV("EGL Version %i %i", mEGL.mMajorVersion, mEGL.mMinorVersion);
- //ALOGV("GL Version %s", mGL.mVersion);
- //ALOGV("GL Vendor %s", mGL.mVendor);
- //ALOGV("GL Renderer %s", mGL.mRenderer);
- //ALOGV("GL Extensions %s", mGL.mExtensions);
-
- const char *verptr = NULL;
- if (strlen((const char *)dc->gl.gl.version) > 9) {
- if (!memcmp(dc->gl.gl.version, "OpenGL ES-CM", 12)) {
- verptr = (const char *)dc->gl.gl.version + 12;
- }
- if (!memcmp(dc->gl.gl.version, "OpenGL ES ", 10)) {
- verptr = (const char *)dc->gl.gl.version + 9;
- }
- }
-
- if (!verptr) {
- ALOGE("Error, OpenGL ES Lite not supported");
- rsdGLShutdown(rsc);
- rsc->setWatchdogGL(NULL, 0, NULL);
- return false;
- } else {
- sscanf(verptr, " %i.%i", &dc->gl.gl.majorVersion, &dc->gl.gl.minorVersion);
- }
-
- glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &dc->gl.gl.maxVertexAttribs);
- glGetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS, &dc->gl.gl.maxVertexUniformVectors);
- glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &dc->gl.gl.maxVertexTextureUnits);
-
- glGetIntegerv(GL_MAX_VARYING_VECTORS, &dc->gl.gl.maxVaryingVectors);
- glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &dc->gl.gl.maxTextureImageUnits);
-
- glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &dc->gl.gl.maxFragmentTextureImageUnits);
- glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_VECTORS, &dc->gl.gl.maxFragmentUniformVectors);
-
- dc->gl.gl.OES_texture_npot = NULL != strstr((const char *)dc->gl.gl.extensions,
- "GL_OES_texture_npot");
- dc->gl.gl.IMG_texture_npot = NULL != strstr((const char *)dc->gl.gl.extensions,
- "GL_IMG_texture_npot");
- dc->gl.gl.NV_texture_npot_2D_mipmap = NULL != strstr((const char *)dc->gl.gl.extensions,
- "GL_NV_texture_npot_2D_mipmap");
- dc->gl.gl.EXT_texture_max_aniso = 1.0f;
- bool hasAniso = NULL != strstr((const char *)dc->gl.gl.extensions,
- "GL_EXT_texture_filter_anisotropic");
- if (hasAniso) {
- glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &dc->gl.gl.EXT_texture_max_aniso);
- }
-
- if (0) {
- DumpDebug(dc);
- }
-
- dc->gl.shaderCache = new RsdShaderCache();
- dc->gl.vertexArrayState = new RsdVertexArrayState();
- dc->gl.vertexArrayState->init(dc->gl.gl.maxVertexAttribs);
- dc->gl.currentFrameBuffer = NULL;
- dc->mHasGraphics = true;
-
- ALOGV("%p initGLThread end", rsc);
- rsc->setWatchdogGL(NULL, 0, NULL);
- return true;
-}
-
-
-bool rsdGLSetSurface(const Context *rsc, uint32_t w, uint32_t h, RsNativeWindow sur) {
- RsdHal *dc = (RsdHal *)rsc->mHal.drv;
-
- EGLBoolean ret;
- // WAR: Some drivers fail to handle 0 size surfaces correcntly.
- // Use the pbuffer to avoid this pitfall.
- if ((dc->gl.egl.surface != NULL) || (w == 0) || (h == 0)) {
- rsc->setWatchdogGL("eglMakeCurrent", __LINE__, __FILE__);
- ret = eglMakeCurrent(dc->gl.egl.display, dc->gl.egl.surfaceDefault,
- dc->gl.egl.surfaceDefault, dc->gl.egl.context);
- checkEglError("eglMakeCurrent", ret);
-
- rsc->setWatchdogGL("eglDestroySurface", __LINE__, __FILE__);
- ret = eglDestroySurface(dc->gl.egl.display, dc->gl.egl.surface);
- checkEglError("eglDestroySurface", ret);
-
- dc->gl.egl.surface = NULL;
- dc->gl.width = 1;
- dc->gl.height = 1;
- }
-
- if (dc->gl.wndSurface != NULL) {
- dc->gl.wndSurface->decStrong(NULL);
- }
-
- dc->gl.wndSurface = (ANativeWindow *)sur;
- if (dc->gl.wndSurface != NULL) {
- dc->gl.wndSurface->incStrong(NULL);
- dc->gl.width = w;
- dc->gl.height = h;
-
- rsc->setWatchdogGL("eglCreateWindowSurface", __LINE__, __FILE__);
- dc->gl.egl.surface = eglCreateWindowSurface(dc->gl.egl.display, dc->gl.egl.config,
- dc->gl.wndSurface, NULL);
- checkEglError("eglCreateWindowSurface");
- if (dc->gl.egl.surface == EGL_NO_SURFACE) {
- ALOGE("eglCreateWindowSurface returned EGL_NO_SURFACE");
- }
-
- rsc->setWatchdogGL("eglMakeCurrent", __LINE__, __FILE__);
- ret = eglMakeCurrent(dc->gl.egl.display, dc->gl.egl.surface,
- dc->gl.egl.surface, dc->gl.egl.context);
- checkEglError("eglMakeCurrent", ret);
- }
- rsc->setWatchdogGL(NULL, 0, NULL);
- return true;
-}
-
-void rsdGLSwap(const android::renderscript::Context *rsc) {
- RsdHal *dc = (RsdHal *)rsc->mHal.drv;
- RSD_CALL_GL(eglSwapBuffers, dc->gl.egl.display, dc->gl.egl.surface);
-}
-
-void rsdGLSetPriority(const Context *rsc, int32_t priority) {
- if (priority > 0) {
- // Mark context as low priority.
- ALOGV("low pri");
- } else {
- ALOGV("normal pri");
- }
-}
-
-void rsdGLCheckError(const android::renderscript::Context *rsc,
- const char *msg, bool isFatal) {
- GLenum err = glGetError();
- if (err != GL_NO_ERROR) {
- char buf[1024];
- snprintf(buf, sizeof(buf), "GL Error = 0x%08x, from: %s", err, msg);
-
- if (isFatal) {
- rsc->setError(RS_ERROR_FATAL_DRIVER, buf);
- } else {
- switch (err) {
- case GL_OUT_OF_MEMORY:
- rsc->setError(RS_ERROR_OUT_OF_MEMORY, buf);
- break;
- default:
- rsc->setError(RS_ERROR_DRIVER, buf);
- break;
- }
- }
-
- ALOGE("%p, %s", rsc, buf);
- }
-
-}
-
-void rsdGLClearColor(const android::renderscript::Context *rsc,
- float r, float g, float b, float a) {
- RSD_CALL_GL(glClearColor, r, g, b, a);
- RSD_CALL_GL(glClear, GL_COLOR_BUFFER_BIT);
-}
-
-void rsdGLClearDepth(const android::renderscript::Context *rsc, float v) {
- RSD_CALL_GL(glClearDepthf, v);
- RSD_CALL_GL(glClear, GL_DEPTH_BUFFER_BIT);
-}
-
-void rsdGLFinish(const android::renderscript::Context *rsc) {
- RSD_CALL_GL(glFinish);
-}
-
-void rsdGLDrawQuadTexCoords(const android::renderscript::Context *rsc,
- float x1, float y1, float z1, float u1, float v1,
- float x2, float y2, float z2, float u2, float v2,
- float x3, float y3, float z3, float u3, float v3,
- float x4, float y4, float z4, float u4, float v4) {
-
- float vtx[] = {x1,y1,z1, x2,y2,z2, x3,y3,z3, x4,y4,z4};
- const float tex[] = {u1,v1, u2,v2, u3,v3, u4,v4};
-
- RsdVertexArray::Attrib attribs[2];
- attribs[0].set(GL_FLOAT, 3, 12, false, (uint32_t)vtx, "ATTRIB_position");
- attribs[1].set(GL_FLOAT, 2, 8, false, (uint32_t)tex, "ATTRIB_texture0");
-
- RsdVertexArray va(attribs, 2);
- va.setup(rsc);
-
- RSD_CALL_GL(glDrawArrays, GL_TRIANGLE_FAN, 0, 4);
-}
diff --git a/libs/rs/driver/rsdGL.h b/libs/rs/driver/rsdGL.h
deleted file mode 100644
index 1e5b40f..0000000
--- a/libs/rs/driver/rsdGL.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef RSD_GL_H
-#define RSD_GL_H
-
-#include <rs_hal.h>
-#include <EGL/egl.h>
-
-#define RSD_CALL_GL(x, ...) rsc->setWatchdogGL(#x, __LINE__, __FILE__); x(__VA_ARGS__); rsc->setWatchdogGL(NULL, 0, NULL)
-
-class RsdShaderCache;
-class RsdVertexArrayState;
-class RsdFrameBufferObj;
-
-typedef void (* InvokeFunc_t)(void);
-typedef void (*WorkerCallback_t)(void *usr, uint32_t idx);
-
-typedef struct RsdGLRec {
- struct {
- EGLint numConfigs;
- EGLint majorVersion;
- EGLint minorVersion;
- EGLConfig config;
- EGLContext context;
- EGLSurface surface;
- EGLSurface surfaceDefault;
- EGLDisplay display;
- } egl;
-
- struct {
- const uint8_t * vendor;
- const uint8_t * renderer;
- const uint8_t * version;
- const uint8_t * extensions;
-
- uint32_t majorVersion;
- uint32_t minorVersion;
-
- int32_t maxVaryingVectors;
- int32_t maxTextureImageUnits;
-
- int32_t maxFragmentTextureImageUnits;
- int32_t maxFragmentUniformVectors;
-
- int32_t maxVertexAttribs;
- int32_t maxVertexUniformVectors;
- int32_t maxVertexTextureUnits;
-
- bool OES_texture_npot;
- bool IMG_texture_npot;
- bool NV_texture_npot_2D_mipmap;
- float EXT_texture_max_aniso;
- } gl;
-
- ANativeWindow *wndSurface;
- uint32_t width;
- uint32_t height;
- RsdShaderCache *shaderCache;
- RsdVertexArrayState *vertexArrayState;
- RsdFrameBufferObj *currentFrameBuffer;
-} RsdGL;
-
-
-bool rsdGLInit(const android::renderscript::Context *rsc);
-void rsdGLShutdown(const android::renderscript::Context *rsc);
-bool rsdGLSetSurface(const android::renderscript::Context *rsc,
- uint32_t w, uint32_t h, RsNativeWindow sur);
-void rsdGLSwap(const android::renderscript::Context *rsc);
-void rsdGLCheckError(const android::renderscript::Context *rsc,
- const char *msg, bool isFatal = false);
-void rsdGLSetPriority(const android::renderscript::Context *rsc,
- int32_t priority);
-void rsdGLClearColor(const android::renderscript::Context *rsc,
- float r, float g, float b, float a);
-void rsdGLClearDepth(const android::renderscript::Context *rsc, float v);
-void rsdGLFinish(const android::renderscript::Context *rsc);
-void rsdGLDrawQuadTexCoords(const android::renderscript::Context *rsc,
- float x1, float y1, float z1, float u1, float v1,
- float x2, float y2, float z2, float u2, float v2,
- float x3, float y3, float z3, float u3, float v3,
- float x4, float y4, float z4, float u4, float v4);
-
-#endif
-
diff --git a/libs/rs/driver/rsdMesh.cpp b/libs/rs/driver/rsdMesh.cpp
deleted file mode 100644
index 50daf3e..0000000
--- a/libs/rs/driver/rsdMesh.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-
-#include <rs_hal.h>
-#include <rsContext.h>
-#include <rsMesh.h>
-
-#include "rsdCore.h"
-#include "rsdMesh.h"
-#include "rsdMeshObj.h"
-#include "rsdShaderCache.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-bool rsdMeshInit(const Context *rsc, const Mesh *m) {
- RsdMeshObj *drv = NULL;
- if(m->mHal.drv) {
- drv = (RsdMeshObj*)m->mHal.drv;
- delete drv;
- }
- drv = new RsdMeshObj(rsc, m);
- m->mHal.drv = drv;
- return drv->init(rsc);
-}
-
-void rsdMeshDraw(const Context *rsc, const Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len) {
- if(m->mHal.drv) {
- RsdHal *dc = (RsdHal *)rsc->mHal.drv;
- if (!dc->gl.shaderCache->setup(rsc)) {
- return;
- }
-
- RsdMeshObj *drv = (RsdMeshObj*)m->mHal.drv;
- drv->renderPrimitiveRange(rsc, primIndex, start, len);
- }
-}
-
-void rsdMeshDestroy(const Context *rsc, const Mesh *m) {
- if(m->mHal.drv) {
- RsdMeshObj *drv = (RsdMeshObj*)m->mHal.drv;
- delete drv;
- }
-}
-
-
diff --git a/libs/rs/driver/rsdMesh.h b/libs/rs/driver/rsdMesh.h
deleted file mode 100644
index d2714fd..0000000
--- a/libs/rs/driver/rsdMesh.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef RSD_MESH_H
-#define RSD_MESH_H
-
-#include <rs_hal.h>
-
-
-bool rsdMeshInit(const android::renderscript::Context *rsc,
- const android::renderscript::Mesh *m);
-void rsdMeshDraw(const android::renderscript::Context *rsc,
- const android::renderscript::Mesh *m,
- uint32_t primIndex, uint32_t start, uint32_t len);
-void rsdMeshDestroy(const android::renderscript::Context *rsc,
- const android::renderscript::Mesh *m);
-
-
-#endif
diff --git a/libs/rs/driver/rsdMeshObj.cpp b/libs/rs/driver/rsdMeshObj.cpp
deleted file mode 100644
index 893f046..0000000
--- a/libs/rs/driver/rsdMeshObj.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#include <GLES/gl.h>
-#include <GLES2/gl2.h>
-#include <GLES/glext.h>
-
-#include <rs_hal.h>
-#include <rsContext.h>
-#include <rsMesh.h>
-
-#include "rsdAllocation.h"
-#include "rsdMeshObj.h"
-#include "rsdGL.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-RsdMeshObj::RsdMeshObj(const Context *rsc, const Mesh *rsMesh) {
- mRSMesh = rsMesh;
-
- mAttribs = NULL;
- mAttribAllocationIndex = NULL;
- mGLPrimitives = NULL;
-
- mAttribCount = 0;
-}
-
-RsdMeshObj::~RsdMeshObj() {
- if (mAttribs) {
- delete[] mAttribs;
- delete[] mAttribAllocationIndex;
- }
- if (mGLPrimitives) {
- delete[] mGLPrimitives;
- }
-}
-
-bool RsdMeshObj::isValidGLComponent(const Element *elem, uint32_t fieldIdx) {
- // Only GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT, GL_FIXED, GL_FLOAT are accepted.
- // Filter rs types accordingly
- RsDataType dt = elem->mHal.state.fields[fieldIdx]->mHal.state.dataType;
- if (dt != RS_TYPE_FLOAT_32 && dt != RS_TYPE_UNSIGNED_8 &&
- dt != RS_TYPE_UNSIGNED_16 && dt != RS_TYPE_SIGNED_8 &&
- dt != RS_TYPE_SIGNED_16) {
- return false;
- }
-
- // Now make sure they are not arrays
- uint32_t arraySize = elem->mHal.state.fieldArraySizes[fieldIdx];
- if (arraySize != 1) {
- return false;
- }
-
- return true;
-}
-
-bool RsdMeshObj::init(const Context *rsc) {
-
- updateGLPrimitives(rsc);
-
- // Count the number of gl attrs to initialize
- mAttribCount = 0;
- for (uint32_t ct=0; ct < mRSMesh->mHal.state.vertexBuffersCount; ct++) {
- const Element *elem = mRSMesh->mHal.state.vertexBuffers[ct]->getType()->getElement();
- for (uint32_t ct=0; ct < elem->mHal.state.fieldsCount; ct++) {
- if (isValidGLComponent(elem, ct)) {
- mAttribCount ++;
- }
- }
- }
-
- if (mAttribs) {
- delete [] mAttribs;
- delete [] mAttribAllocationIndex;
- mAttribs = NULL;
- mAttribAllocationIndex = NULL;
- }
- if (!mAttribCount) {
- return false;
- }
-
- mAttribs = new RsdVertexArray::Attrib[mAttribCount];
- mAttribAllocationIndex = new uint32_t[mAttribCount];
-
- uint32_t userNum = 0;
- for (uint32_t ct=0; ct < mRSMesh->mHal.state.vertexBuffersCount; ct++) {
- const Element *elem = mRSMesh->mHal.state.vertexBuffers[ct]->getType()->getElement();
- uint32_t stride = elem->mHal.state.elementSizeBytes;
- for (uint32_t fieldI=0; fieldI < elem->mHal.state.fieldsCount; fieldI++) {
- const Element *f = elem->mHal.state.fields[fieldI];
-
- if (!isValidGLComponent(elem, fieldI)) {
- continue;
- }
-
- mAttribs[userNum].size = f->mHal.state.vectorSize;
- mAttribs[userNum].offset = elem->mHal.state.fieldOffsetBytes[fieldI];
- mAttribs[userNum].type = rsdTypeToGLType(f->mHal.state.dataType);
- mAttribs[userNum].normalized = f->mHal.state.dataType != RS_TYPE_FLOAT_32;
- mAttribs[userNum].stride = stride;
- String8 tmp(RS_SHADER_ATTR);
- tmp.append(elem->mHal.state.fieldNames[fieldI]);
- mAttribs[userNum].name.setTo(tmp.string());
-
- // Remember which allocation this attribute came from
- mAttribAllocationIndex[userNum] = ct;
- userNum ++;
- }
- }
-
- return true;
-}
-
-void RsdMeshObj::renderPrimitiveRange(const Context *rsc, uint32_t primIndex,
- uint32_t start, uint32_t len) const {
- if (len < 1 || primIndex >= mRSMesh->mHal.state.primitivesCount || mAttribCount == 0) {
- rsc->setError(RS_ERROR_FATAL_DRIVER, "Invalid mesh or parameters");
- return;
- }
-
- for (uint32_t ct=0; ct < mRSMesh->mHal.state.vertexBuffersCount; ct++) {
- const Allocation *alloc = mRSMesh->mHal.state.vertexBuffers[ct];
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
- if (drv->uploadDeferred) {
- rsdAllocationSyncAll(rsc, alloc, RS_ALLOCATION_USAGE_SCRIPT);
- }
- }
-
- // update attributes with either buffer information or data ptr based on their current state
- for (uint32_t ct=0; ct < mAttribCount; ct++) {
- uint32_t allocIndex = mAttribAllocationIndex[ct];
- Allocation *alloc = mRSMesh->mHal.state.vertexBuffers[allocIndex];
- DrvAllocation *drvAlloc = (DrvAllocation *)alloc->mHal.drv;
-
- if (drvAlloc->bufferID) {
- mAttribs[ct].buffer = drvAlloc->bufferID;
- mAttribs[ct].ptr = NULL;
- } else {
- mAttribs[ct].buffer = 0;
- mAttribs[ct].ptr = (const uint8_t*)drvAlloc->mallocPtr;
- }
- }
-
- RsdVertexArray va(mAttribs, mAttribCount);
- va.setup(rsc);
-
- const Allocation *idxAlloc = mRSMesh->mHal.state.indexBuffers[primIndex];
- if (idxAlloc) {
- DrvAllocation *drvAlloc = (DrvAllocation *)idxAlloc->mHal.drv;
- if (drvAlloc->uploadDeferred) {
- rsdAllocationSyncAll(rsc, idxAlloc, RS_ALLOCATION_USAGE_SCRIPT);
- }
-
- if (drvAlloc->bufferID) {
- RSD_CALL_GL(glBindBuffer, GL_ELEMENT_ARRAY_BUFFER, drvAlloc->bufferID);
- RSD_CALL_GL(glDrawElements, mGLPrimitives[primIndex], len, GL_UNSIGNED_SHORT,
- (uint16_t *)(start * 2));
- } else {
- RSD_CALL_GL(glBindBuffer, GL_ELEMENT_ARRAY_BUFFER, 0);
- RSD_CALL_GL(glDrawElements, mGLPrimitives[primIndex], len, GL_UNSIGNED_SHORT,
- drvAlloc->mallocPtr);
- }
- } else {
- RSD_CALL_GL(glDrawArrays, mGLPrimitives[primIndex], start, len);
- }
-
- rsdGLCheckError(rsc, "Mesh::renderPrimitiveRange");
-}
-
-void RsdMeshObj::updateGLPrimitives(const Context *rsc) {
- mGLPrimitives = new uint32_t[mRSMesh->mHal.state.primitivesCount];
- for (uint32_t i = 0; i < mRSMesh->mHal.state.primitivesCount; i ++) {
- switch (mRSMesh->mHal.state.primitives[i]) {
- case RS_PRIMITIVE_POINT: mGLPrimitives[i] = GL_POINTS; break;
- case RS_PRIMITIVE_LINE: mGLPrimitives[i] = GL_LINES; break;
- case RS_PRIMITIVE_LINE_STRIP: mGLPrimitives[i] = GL_LINE_STRIP; break;
- case RS_PRIMITIVE_TRIANGLE: mGLPrimitives[i] = GL_TRIANGLES; break;
- case RS_PRIMITIVE_TRIANGLE_STRIP: mGLPrimitives[i] = GL_TRIANGLE_STRIP; break;
- case RS_PRIMITIVE_TRIANGLE_FAN: mGLPrimitives[i] = GL_TRIANGLE_FAN; break;
- default: rsc->setError(RS_ERROR_FATAL_DRIVER, "Invalid mesh primitive"); break;
- }
- }
-}
diff --git a/libs/rs/driver/rsdMeshObj.h b/libs/rs/driver/rsdMeshObj.h
deleted file mode 100644
index 1370f01..0000000
--- a/libs/rs/driver/rsdMeshObj.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef ANDROID_RSD_MESH_OBJ_H
-#define ANDROID_RSD_MESH_OBJ_H
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
- class Context;
- class Mesh;
- class Element;
-
-}
-}
-
-#include "driver/rsdVertexArray.h"
-
-// An element is a group of Components that occupies one cell in a structure.
-class RsdMeshObj {
-public:
- RsdMeshObj(const android::renderscript::Context *,
- const android::renderscript::Mesh *);
- ~RsdMeshObj();
-
- void renderPrimitiveRange(const android::renderscript::Context *,
- uint32_t primIndex, uint32_t start, uint32_t len) const;
-
- bool init(const android::renderscript::Context *rsc);
-
-protected:
- const android::renderscript::Mesh *mRSMesh;
-
- uint32_t *mGLPrimitives;
- void updateGLPrimitives(const android::renderscript::Context *rsc);
-
- bool isValidGLComponent(const android::renderscript::Element *elem, uint32_t fieldIdx);
- // Attribues that allow us to map to GL
- RsdVertexArray::Attrib *mAttribs;
- // This allows us to figure out which allocation the attribute
- // belongs to. In the event the allocation is uploaded to GL
- // buffer, it lets us properly map it
- uint32_t *mAttribAllocationIndex;
- uint32_t mAttribCount;
-};
-
-#endif //ANDROID_RSD_MESH_OBJ_H
-
-
-
diff --git a/libs/rs/driver/rsdPath.cpp b/libs/rs/driver/rsdPath.cpp
deleted file mode 100644
index e04bc02..0000000
--- a/libs/rs/driver/rsdPath.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#include <GLES/gl.h>
-#include <GLES2/gl2.h>
-#include <GLES/glext.h>
-
-#include <rs_hal.h>
-#include <rsContext.h>
-#include <rsPath.h>
-
-#include "rsdCore.h"
-#include "rsdPath.h"
-#include "rsdAllocation.h"
-#include "rsdGL.h"
-#include "rsdVertexArray.h"
-#include "rsdShaderCache.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-class DrvPath {
-protected:
- DrvPath();
-public:
- virtual ~DrvPath();
- virtual void draw(Context *) = 0;
-};
-
-class DrvPathStatic : public DrvPath {
-public:
- typedef struct {
- float x1, xc, x2;
- float y1, yc, y2;
- } segment_t;
-
- segment_t *mSegments;
- uint32_t mSegmentCount;
-
- DrvPathStatic(const Allocation *vtx, const Allocation *loops);
- virtual ~DrvPathStatic();
-
- virtual void draw(Context *);
-};
-
-class DrvPathDynamic : public DrvPath {
-public:
- DrvPathDynamic();
- virtual ~DrvPathDynamic();
-};
-
-static void cleanup(const Context *rsc, const Path *m) {
- DrvPath *dp = (DrvPath *)m->mHal.drv;
- if (dp) {
- delete dp;
- }
-}
-
-bool rsdPathInitStatic(const Context *rsc, const Path *m,
- const Allocation *vtx, const Allocation *loops) {
- DrvPathStatic *drv = NULL;
- cleanup(rsc, m);
-
- DrvPathStatic *dps = new DrvPathStatic(vtx, loops);
- //LOGE("init path m %p, %p", m, dps);
- m->mHal.drv = dps;
- return dps != NULL;
-}
-
-bool rsdPathInitDynamic(const Context *rsc, const Path *m) {
- return false;
-}
-
-
-void rsdPathDraw(const Context *rsc, const Path *m) {
- //LOGE("render m=%p", m);
-
- DrvPath *drv = (DrvPath *)m->mHal.drv;
- if(drv) {
- //LOGE("render 2 drv=%p", drv);
- drv->draw((Context *)rsc);
- }
-}
-
-void rsdPathDestroy(const Context *rsc, const Path *m) {
- cleanup(rsc, m);
- m->mHal.drv = NULL;
-}
-
-
-
-
-DrvPath::DrvPath() {
-}
-
-DrvPath::~DrvPath() {
-}
-
-DrvPathStatic::DrvPathStatic(const Allocation *vtx, const Allocation *loops) {
- mSegmentCount = vtx->getType()->getDimX() / 3;
- mSegments = new segment_t[mSegmentCount];
-
- const float *fin = (const float *)vtx->getPtr();
- for (uint32_t ct=0; ct < mSegmentCount; ct++) {
- segment_t *s = &mSegments[ct];
- s->x1 = fin[0];
- s->y1 = fin[1];
-
- s->xc = fin[2];
- s->yc = fin[3];
-
- s->x2 = fin[4];
- s->y2 = fin[5];
- fin += 6;
- }
-}
-
-DrvPathStatic::~DrvPathStatic() {
-}
-
-void DrvPathStatic::draw(Context *rsc) {
- const static float color[24] = {
- 1.f, 0.f, 0.f, 1.f, 0.5f, 0.f, 0.f, 1.f,
- 1.f, 0.f, 0.f, 1.f, 0.5f, 0.f, 0.f, 1.f,
- 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f};
- float vtx[12];
-
- //LOGE("draw");
- if (!rsc->setupCheck()) {
- return;
- }
-
- RsdHal *dc = (RsdHal *)rsc->mHal.drv;
- if (!dc->gl.shaderCache->setup(rsc)) {
- return;
- }
-
- RsdVertexArray::Attrib attribs[2];
- attribs[0].set(GL_FLOAT, 2, 8, false, (uint32_t)vtx, "ATTRIB_position");
- attribs[1].set(GL_FLOAT, 4, 16, false, (uint32_t)color, "ATTRIB_color");
- RsdVertexArray va(attribs, 2);
- va.setup(rsc);
-
- //LOGE("mSegmentCount %i", mSegmentCount);
- for (uint32_t ct=0; ct < mSegmentCount; ct++) {
- segment_t *s = &mSegments[ct];
-
- vtx[0] = s->x1;
- vtx[1] = s->y1;
- vtx[2] = s->xc;
- vtx[3] = s->yc;
-
- vtx[4] = s->x2;
- vtx[5] = s->y2;
- vtx[6] = s->xc;
- vtx[7] = s->yc;
-
- vtx[8] = s->x1;
- vtx[9] = s->y1;
- vtx[10] = s->x2;
- vtx[11] = s->y2;
-
- RSD_CALL_GL(glDrawArrays, GL_LINES, 0, 6);
- }
-
-}
-
-DrvPathDynamic::DrvPathDynamic() {
-}
-
-DrvPathDynamic::~DrvPathDynamic() {
-}
diff --git a/libs/rs/driver/rsdPath.h b/libs/rs/driver/rsdPath.h
deleted file mode 100644
index fa00972..0000000
--- a/libs/rs/driver/rsdPath.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef RSD_PATH_H
-#define RSD_PATH_H
-
-#include <rs_hal.h>
-
-
-bool rsdPathInitStatic(const android::renderscript::Context *rsc,
- const android::renderscript::Path *m,
- const android::renderscript::Allocation *vertex,
- const android::renderscript::Allocation *loops);
-bool rsdPathInitDynamic(const android::renderscript::Context *rsc,
- const android::renderscript::Path *m);
-void rsdPathDraw(const android::renderscript::Context *rsc,
- const android::renderscript::Path *m);
-void rsdPathDestroy(const android::renderscript::Context *rsc,
- const android::renderscript::Path *m);
-
-
-#endif
diff --git a/libs/rs/driver/rsdProgram.cpp b/libs/rs/driver/rsdProgram.cpp
deleted file mode 100644
index a96a5f9..0000000
--- a/libs/rs/driver/rsdProgram.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2011-2012 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.
- */
-
-
-#include "rsdCore.h"
-#include "rsdAllocation.h"
-#include "rsdProgramVertex.h"
-#include "rsdShader.h"
-#include "rsdShaderCache.h"
-
-#include "rsContext.h"
-#include "rsProgramVertex.h"
-#include "rsProgramFragment.h"
-
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-
-using namespace android;
-using namespace android::renderscript;
-
-bool rsdProgramVertexInit(const Context *rsc, const ProgramVertex *pv,
- const char* shader, size_t shaderLen,
- const char** textureNames, size_t textureNamesCount,
- const size_t *textureNamesLength) {
- RsdShader *drv = new RsdShader(pv, GL_VERTEX_SHADER, shader, shaderLen,
- textureNames, textureNamesCount, textureNamesLength);
- pv->mHal.drv = drv;
-
- return true;
-}
-
-static void SyncProgramConstants(const Context *rsc, const Program *p) {
- for (uint32_t ct=0; ct < p->mHal.state.texturesCount; ct++) {
- const Allocation *a = p->mHal.state.textures[ct];
- if (!a) {
- continue;
- }
- DrvAllocation *drvAlloc = (DrvAllocation *)a->mHal.drv;
- if (drvAlloc->uploadDeferred) {
- rsdAllocationSyncAll(rsc, a, RS_ALLOCATION_USAGE_SCRIPT);
- }
- }
-}
-
-void rsdProgramVertexSetActive(const Context *rsc, const ProgramVertex *pv) {
- RsdHal *dc = (RsdHal *)rsc->mHal.drv;
-
- SyncProgramConstants(rsc, pv);
- dc->gl.shaderCache->setActiveVertex((RsdShader*)pv->mHal.drv);
-}
-
-void rsdProgramVertexDestroy(const Context *rsc, const ProgramVertex *pv) {
- RsdHal *dc = (RsdHal *)rsc->mHal.drv;
-
- RsdShader *drv = NULL;
- if(pv->mHal.drv) {
- drv = (RsdShader*)pv->mHal.drv;
- if (rsc->props.mLogShaders) {
- ALOGV("Destroying vertex shader with ID %u", (uint32_t)pv);
- }
- if (drv->getStateBasedIDCount()) {
- dc->gl.shaderCache->cleanupVertex(drv);
- }
- delete drv;
- }
-}
-
-bool rsdProgramFragmentInit(const Context *rsc, const ProgramFragment *pf,
- const char* shader, size_t shaderLen,
- const char** textureNames, size_t textureNamesCount,
- const size_t *textureNamesLength) {
- RsdShader *drv = new RsdShader(pf, GL_FRAGMENT_SHADER, shader, shaderLen,
- textureNames, textureNamesCount, textureNamesLength);
- pf->mHal.drv = drv;
-
- return true;
-}
-
-void rsdProgramFragmentSetActive(const Context *rsc, const ProgramFragment *pf) {
- RsdHal *dc = (RsdHal *)rsc->mHal.drv;
-
- SyncProgramConstants(rsc, pf);
- dc->gl.shaderCache->setActiveFragment((RsdShader*)pf->mHal.drv);
-}
-
-void rsdProgramFragmentDestroy(const Context *rsc, const ProgramFragment *pf) {
- RsdHal *dc = (RsdHal *)rsc->mHal.drv;
-
- RsdShader *drv = NULL;
- if(pf->mHal.drv) {
- drv = (RsdShader*)pf->mHal.drv;
- if (rsc->props.mLogShaders) {
- ALOGV("Destroying fragment shader with ID %u", (uint32_t)pf);
- }
- if (drv->getStateBasedIDCount()) {
- dc->gl.shaderCache->cleanupFragment(drv);
- }
- delete drv;
- }
-}
-
-
diff --git a/libs/rs/driver/rsdProgramFragment.h b/libs/rs/driver/rsdProgramFragment.h
deleted file mode 100644
index b03a9fe..0000000
--- a/libs/rs/driver/rsdProgramFragment.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef RSD_PROGRAM_FRAGMENT_H
-#define RSD_PROGRAM_FRAGMENT_H
-
-#include <rs_hal.h>
-
-
-bool rsdProgramFragmentInit(const android::renderscript::Context *rsc,
- const android::renderscript::ProgramFragment *,
- const char* shader, size_t shaderLen,
- const char** textureNames, size_t textureNamesCount,
- const size_t *textureNamesLength);
-void rsdProgramFragmentSetActive(const android::renderscript::Context *rsc,
- const android::renderscript::ProgramFragment *);
-void rsdProgramFragmentDestroy(const android::renderscript::Context *rsc,
- const android::renderscript::ProgramFragment *);
-
-
-#endif //RSD_PROGRAM_Fragment_H
diff --git a/libs/rs/driver/rsdProgramRaster.cpp b/libs/rs/driver/rsdProgramRaster.cpp
deleted file mode 100644
index e5a0291..0000000
--- a/libs/rs/driver/rsdProgramRaster.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-
-#include "rsdCore.h"
-#include "rsdProgramStore.h"
-
-#include "rsContext.h"
-#include "rsProgramStore.h"
-
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-
-
-using namespace android;
-using namespace android::renderscript;
-
-bool rsdProgramRasterInit(const Context *, const ProgramRaster *) {
- return true;
-}
-
-void rsdProgramRasterSetActive(const Context *rsc, const ProgramRaster *pr) {
- switch (pr->mHal.state.cull) {
- case RS_CULL_BACK:
- RSD_CALL_GL(glEnable, GL_CULL_FACE);
- RSD_CALL_GL(glCullFace, GL_BACK);
- break;
- case RS_CULL_FRONT:
- RSD_CALL_GL(glEnable, GL_CULL_FACE);
- RSD_CALL_GL(glCullFace, GL_FRONT);
- break;
- case RS_CULL_NONE:
- RSD_CALL_GL(glDisable, GL_CULL_FACE);
- break;
- default:
- rsc->setError(RS_ERROR_FATAL_DRIVER, "Invalid cull type");
- break;
- }
-
-}
-
-void rsdProgramRasterDestroy(const Context *, const ProgramRaster *) {
-}
-
-
diff --git a/libs/rs/driver/rsdProgramRaster.h b/libs/rs/driver/rsdProgramRaster.h
deleted file mode 100644
index 20adaad..0000000
--- a/libs/rs/driver/rsdProgramRaster.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef RSD_PROGRAM_RASTER_H
-#define RSD_PROGRAM_RASTER_H
-
-#include <rs_hal.h>
-
-
-bool rsdProgramRasterInit(const android::renderscript::Context *rsc,
- const android::renderscript::ProgramRaster *);
-void rsdProgramRasterSetActive(const android::renderscript::Context *rsc,
- const android::renderscript::ProgramRaster *);
-void rsdProgramRasterDestroy(const android::renderscript::Context *rsc,
- const android::renderscript::ProgramRaster *);
-
-
-#endif
diff --git a/libs/rs/driver/rsdProgramStore.cpp b/libs/rs/driver/rsdProgramStore.cpp
deleted file mode 100644
index c1295e8..0000000
--- a/libs/rs/driver/rsdProgramStore.cpp
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-
-#include "rsdCore.h"
-#include "rsdProgramStore.h"
-
-#include "rsContext.h"
-#include "rsProgramStore.h"
-
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-
-
-using namespace android;
-using namespace android::renderscript;
-
-struct DrvProgramStore {
- GLenum blendSrc;
- GLenum blendDst;
- bool blendEnable;
-
- GLenum depthFunc;
- bool depthTestEnable;
-};
-
-bool rsdProgramStoreInit(const Context *rsc, const ProgramStore *ps) {
- DrvProgramStore *drv = (DrvProgramStore *)calloc(1, sizeof(DrvProgramStore));
- if (drv == NULL) {
- return false;
- }
-
- ps->mHal.drv = drv;
- drv->depthTestEnable = true;
-
- switch (ps->mHal.state.depthFunc) {
- case RS_DEPTH_FUNC_ALWAYS:
- drv->depthTestEnable = false;
- drv->depthFunc = GL_ALWAYS;
- break;
- case RS_DEPTH_FUNC_LESS:
- drv->depthFunc = GL_LESS;
- break;
- case RS_DEPTH_FUNC_LEQUAL:
- drv->depthFunc = GL_LEQUAL;
- break;
- case RS_DEPTH_FUNC_GREATER:
- drv->depthFunc = GL_GREATER;
- break;
- case RS_DEPTH_FUNC_GEQUAL:
- drv->depthFunc = GL_GEQUAL;
- break;
- case RS_DEPTH_FUNC_EQUAL:
- drv->depthFunc = GL_EQUAL;
- break;
- case RS_DEPTH_FUNC_NOTEQUAL:
- drv->depthFunc = GL_NOTEQUAL;
- break;
- default:
- ALOGE("Unknown depth function.");
- goto error;
- }
-
-
-
- drv->blendEnable = true;
- if ((ps->mHal.state.blendSrc == RS_BLEND_SRC_ONE) &&
- (ps->mHal.state.blendDst == RS_BLEND_DST_ZERO)) {
- drv->blendEnable = false;
- }
-
- switch (ps->mHal.state.blendSrc) {
- case RS_BLEND_SRC_ZERO:
- drv->blendSrc = GL_ZERO;
- break;
- case RS_BLEND_SRC_ONE:
- drv->blendSrc = GL_ONE;
- break;
- case RS_BLEND_SRC_DST_COLOR:
- drv->blendSrc = GL_DST_COLOR;
- break;
- case RS_BLEND_SRC_ONE_MINUS_DST_COLOR:
- drv->blendSrc = GL_ONE_MINUS_DST_COLOR;
- break;
- case RS_BLEND_SRC_SRC_ALPHA:
- drv->blendSrc = GL_SRC_ALPHA;
- break;
- case RS_BLEND_SRC_ONE_MINUS_SRC_ALPHA:
- drv->blendSrc = GL_ONE_MINUS_SRC_ALPHA;
- break;
- case RS_BLEND_SRC_DST_ALPHA:
- drv->blendSrc = GL_DST_ALPHA;
- break;
- case RS_BLEND_SRC_ONE_MINUS_DST_ALPHA:
- drv->blendSrc = GL_ONE_MINUS_DST_ALPHA;
- break;
- case RS_BLEND_SRC_SRC_ALPHA_SATURATE:
- drv->blendSrc = GL_SRC_ALPHA_SATURATE;
- break;
- default:
- rsc->setError(RS_ERROR_FATAL_DRIVER, "Unknown blend src mode.");
- goto error;
- }
-
- switch (ps->mHal.state.blendDst) {
- case RS_BLEND_DST_ZERO:
- drv->blendDst = GL_ZERO;
- break;
- case RS_BLEND_DST_ONE:
- drv->blendDst = GL_ONE;
- break;
- case RS_BLEND_DST_SRC_COLOR:
- drv->blendDst = GL_SRC_COLOR;
- break;
- case RS_BLEND_DST_ONE_MINUS_SRC_COLOR:
- drv->blendDst = GL_ONE_MINUS_SRC_COLOR;
- break;
- case RS_BLEND_DST_SRC_ALPHA:
- drv->blendDst = GL_SRC_ALPHA;
- break;
- case RS_BLEND_DST_ONE_MINUS_SRC_ALPHA:
- drv->blendDst = GL_ONE_MINUS_SRC_ALPHA;
- break;
- case RS_BLEND_DST_DST_ALPHA:
- drv->blendDst = GL_DST_ALPHA;
- break;
- case RS_BLEND_DST_ONE_MINUS_DST_ALPHA:
- drv->blendDst = GL_ONE_MINUS_DST_ALPHA;
- break;
- default:
- rsc->setError(RS_ERROR_FATAL_DRIVER, "Unknown blend dst mode.");
- goto error;
- }
-
- return true;
-
-error:
- free(drv);
- ps->mHal.drv = NULL;
- return false;
-}
-
-void rsdProgramStoreSetActive(const Context *rsc, const ProgramStore *ps) {
- DrvProgramStore *drv = (DrvProgramStore *)ps->mHal.drv;
-
- RSD_CALL_GL(glColorMask, ps->mHal.state.colorRWriteEnable,
- ps->mHal.state.colorGWriteEnable,
- ps->mHal.state.colorBWriteEnable,
- ps->mHal.state.colorAWriteEnable);
-
- if (drv->blendEnable) {
- RSD_CALL_GL(glEnable, GL_BLEND);
- RSD_CALL_GL(glBlendFunc, drv->blendSrc, drv->blendDst);
- } else {
- RSD_CALL_GL(glDisable, GL_BLEND);
- }
-
- if (rsc->mUserSurfaceConfig.depthMin > 0) {
- RSD_CALL_GL(glDepthMask, ps->mHal.state.depthWriteEnable);
- if (drv->depthTestEnable || ps->mHal.state.depthWriteEnable) {
- RSD_CALL_GL(glEnable, GL_DEPTH_TEST);
- RSD_CALL_GL(glDepthFunc, drv->depthFunc);
- } else {
- RSD_CALL_GL(glDisable, GL_DEPTH_TEST);
- }
- } else {
- RSD_CALL_GL(glDepthMask, false);
- RSD_CALL_GL(glDisable, GL_DEPTH_TEST);
- }
-
- /*
- if (rsc->mUserSurfaceConfig.stencilMin > 0) {
- } else {
- glStencilMask(0);
- glDisable(GL_STENCIL_TEST);
- }
- */
-
- if (ps->mHal.state.ditherEnable) {
- RSD_CALL_GL(glEnable, GL_DITHER);
- } else {
- RSD_CALL_GL(glDisable, GL_DITHER);
- }
-}
-
-void rsdProgramStoreDestroy(const Context *rsc, const ProgramStore *ps) {
- free(ps->mHal.drv);
- ps->mHal.drv = NULL;
-}
-
-
diff --git a/libs/rs/driver/rsdProgramStore.h b/libs/rs/driver/rsdProgramStore.h
deleted file mode 100644
index 217a0ce..0000000
--- a/libs/rs/driver/rsdProgramStore.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef RSD_PROGRAM_STORE_H
-#define RSD_PROGRAM_STORE_H
-
-#include <rs_hal.h>
-
-
-bool rsdProgramStoreInit(const android::renderscript::Context *rsc,
- const android::renderscript::ProgramStore *ps);
-void rsdProgramStoreSetActive(const android::renderscript::Context *rsc,
- const android::renderscript::ProgramStore *ps);
-void rsdProgramStoreDestroy(const android::renderscript::Context *rsc,
- const android::renderscript::ProgramStore *ps);
-
-
-#endif
diff --git a/libs/rs/driver/rsdProgramVertex.h b/libs/rs/driver/rsdProgramVertex.h
deleted file mode 100644
index f917a41..0000000
--- a/libs/rs/driver/rsdProgramVertex.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef RSD_PROGRAM_VERTEX_H
-#define RSD_PROGRAM_VERTEX_H
-
-#include <rs_hal.h>
-
-bool rsdProgramVertexInit(const android::renderscript::Context *rsc,
- const android::renderscript::ProgramVertex *,
- const char* shader, size_t shaderLen,
- const char** textureNames, size_t textureNamesCount,
- const size_t *textureNamesLength);
-void rsdProgramVertexSetActive(const android::renderscript::Context *rsc,
- const android::renderscript::ProgramVertex *);
-void rsdProgramVertexDestroy(const android::renderscript::Context *rsc,
- const android::renderscript::ProgramVertex *);
-
-
-#endif //RSD_PROGRAM_VERTEX_H
diff --git a/libs/rs/driver/rsdRuntime.h b/libs/rs/driver/rsdRuntime.h
deleted file mode 100644
index 840eced..0000000
--- a/libs/rs/driver/rsdRuntime.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef RSD_RUNTIME_STUBS_H
-#define RSD_RUNTIME_STUBS_H
-
-#include <rs_hal.h>
-#include <bcc/bcc.h>
-
-#include "rsMutex.h"
-
-const RsdSymbolTable * rsdLookupSymbolMath(const char *sym);
-
-void* rsdLookupRuntimeStub(void* pContext, char const* name);
-
-#endif
diff --git a/libs/rs/driver/rsdRuntimeMath.cpp b/libs/rs/driver/rsdRuntimeMath.cpp
deleted file mode 100644
index 753ef73..0000000
--- a/libs/rs/driver/rsdRuntimeMath.cpp
+++ /dev/null
@@ -1,567 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#include <cutils/compiler.h>
-
-#include "rsContext.h"
-#include "rsScriptC.h"
-#include "rsMatrix4x4.h"
-#include "rsMatrix3x3.h"
-#include "rsMatrix2x2.h"
-
-#include "rsdCore.h"
-#include "rsdRuntime.h"
-
-
-using namespace android;
-using namespace android::renderscript;
-
-
-static float SC_exp10(float v) {
- return pow(10.f, v);
-}
-
-static float SC_fract(float v, int *iptr) {
- int i = (int)floor(v);
- iptr[0] = i;
- return fmin(v - i, 0x1.fffffep-1f);
-}
-
-static float SC_log2(float v) {
- return log10(v) / log10(2.f);
-}
-
-static float SC_mad(float v1, float v2, float v3) {
- return v1 * v2 + v3;
-}
-
-#if 0
-static float SC_pown(float v, int p) {
- return powf(v, (float)p);
-}
-
-static float SC_powr(float v, float p) {
- return powf(v, p);
-}
-#endif
-
-float SC_rootn(float v, int r) {
- return pow(v, 1.f / r);
-}
-
-float SC_rsqrt(float v) {
- return 1.f / sqrtf(v);
-}
-
-float SC_sincos(float v, float *cosptr) {
- *cosptr = cosf(v);
- return sinf(v);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-// Integer
-//////////////////////////////////////////////////////////////////////////////
-
-
-static uint32_t SC_abs_i32(int32_t v) {return abs(v);}
-static uint16_t SC_abs_i16(int16_t v) {return (uint16_t)abs(v);}
-static uint8_t SC_abs_i8(int8_t v) {return (uint8_t)abs(v);}
-
-static uint32_t SC_clz_u32(uint32_t v) {return __builtin_clz(v);}
-static uint16_t SC_clz_u16(uint16_t v) {return (uint16_t)__builtin_clz(v);}
-static uint8_t SC_clz_u8(uint8_t v) {return (uint8_t)__builtin_clz(v);}
-static int32_t SC_clz_i32(int32_t v) {return (int32_t)__builtin_clz((uint32_t)v);}
-static int16_t SC_clz_i16(int16_t v) {return (int16_t)__builtin_clz(v);}
-static int8_t SC_clz_i8(int8_t v) {return (int8_t)__builtin_clz(v);}
-
-static uint32_t SC_max_u32(uint32_t v, uint32_t v2) {return rsMax(v, v2);}
-static uint16_t SC_max_u16(uint16_t v, uint16_t v2) {return rsMax(v, v2);}
-static uint8_t SC_max_u8(uint8_t v, uint8_t v2) {return rsMax(v, v2);}
-static int32_t SC_max_i32(int32_t v, int32_t v2) {return rsMax(v, v2);}
-static int16_t SC_max_i16(int16_t v, int16_t v2) {return rsMax(v, v2);}
-static int8_t SC_max_i8(int8_t v, int8_t v2) {return rsMax(v, v2);}
-
-static uint32_t SC_min_u32(uint32_t v, uint32_t v2) {return rsMin(v, v2);}
-static uint16_t SC_min_u16(uint16_t v, uint16_t v2) {return rsMin(v, v2);}
-static uint8_t SC_min_u8(uint8_t v, uint8_t v2) {return rsMin(v, v2);}
-static int32_t SC_min_i32(int32_t v, int32_t v2) {return rsMin(v, v2);}
-static int16_t SC_min_i16(int16_t v, int16_t v2) {return rsMin(v, v2);}
-static int8_t SC_min_i8(int8_t v, int8_t v2) {return rsMin(v, v2);}
-
-//////////////////////////////////////////////////////////////////////////////
-// Float util
-//////////////////////////////////////////////////////////////////////////////
-
-static float SC_clamp_f32(float amount, float low, float high) {
- return amount < low ? low : (amount > high ? high : amount);
-}
-
-static float SC_degrees(float radians) {
- return radians * (180.f / M_PI);
-}
-
-static float SC_max_f32(float v, float v2) {
- return rsMax(v, v2);
-}
-
-static float SC_min_f32(float v, float v2) {
- return rsMin(v, v2);
-}
-
-static float SC_mix_f32(float start, float stop, float amount) {
- //ALOGE("lerpf %f %f %f", start, stop, amount);
- return start + (stop - start) * amount;
-}
-
-static float SC_radians(float degrees) {
- return degrees * (M_PI / 180.f);
-}
-
-static float SC_step_f32(float edge, float v) {
- if (v < edge) return 0.f;
- return 1.f;
-}
-
-static float SC_sign_f32(float value) {
- if (value > 0) return 1.f;
- if (value < 0) return -1.f;
- return value;
-}
-
-static void SC_MatrixLoadIdentity_4x4(Matrix4x4 *m) {
- m->loadIdentity();
-}
-static void SC_MatrixLoadIdentity_3x3(Matrix3x3 *m) {
- m->loadIdentity();
-}
-static void SC_MatrixLoadIdentity_2x2(Matrix2x2 *m) {
- m->loadIdentity();
-}
-
-static void SC_MatrixLoad_4x4_f(Matrix4x4 *m, const float *f) {
- m->load(f);
-}
-static void SC_MatrixLoad_3x3_f(Matrix3x3 *m, const float *f) {
- m->load(f);
-}
-static void SC_MatrixLoad_2x2_f(Matrix2x2 *m, const float *f) {
- m->load(f);
-}
-
-static void SC_MatrixLoad_4x4_4x4(Matrix4x4 *m, const Matrix4x4 *s) {
- m->load(s);
-}
-static void SC_MatrixLoad_4x4_3x3(Matrix4x4 *m, const Matrix3x3 *s) {
- m->load(s);
-}
-static void SC_MatrixLoad_4x4_2x2(Matrix4x4 *m, const Matrix2x2 *s) {
- m->load(s);
-}
-static void SC_MatrixLoad_3x3_3x3(Matrix3x3 *m, const Matrix3x3 *s) {
- m->load(s);
-}
-static void SC_MatrixLoad_2x2_2x2(Matrix2x2 *m, const Matrix2x2 *s) {
- m->load(s);
-}
-
-static void SC_MatrixLoadRotate(Matrix4x4 *m, float rot, float x, float y, float z) {
- m->loadRotate(rot, x, y, z);
-}
-static void SC_MatrixLoadScale(Matrix4x4 *m, float x, float y, float z) {
- m->loadScale(x, y, z);
-}
-static void SC_MatrixLoadTranslate(Matrix4x4 *m, float x, float y, float z) {
- m->loadTranslate(x, y, z);
-}
-static void SC_MatrixRotate(Matrix4x4 *m, float rot, float x, float y, float z) {
- m->rotate(rot, x, y, z);
-}
-static void SC_MatrixScale(Matrix4x4 *m, float x, float y, float z) {
- m->scale(x, y, z);
-}
-static void SC_MatrixTranslate(Matrix4x4 *m, float x, float y, float z) {
- m->translate(x, y, z);
-}
-
-static void SC_MatrixLoadMultiply_4x4_4x4_4x4(Matrix4x4 *m, const Matrix4x4 *lhs, const Matrix4x4 *rhs) {
- m->loadMultiply(lhs, rhs);
-}
-static void SC_MatrixLoadMultiply_3x3_3x3_3x3(Matrix3x3 *m, const Matrix3x3 *lhs, const Matrix3x3 *rhs) {
- m->loadMultiply(lhs, rhs);
-}
-static void SC_MatrixLoadMultiply_2x2_2x2_2x2(Matrix2x2 *m, const Matrix2x2 *lhs, const Matrix2x2 *rhs) {
- m->loadMultiply(lhs, rhs);
-}
-
-static void SC_MatrixMultiply_4x4_4x4(Matrix4x4 *m, const Matrix4x4 *rhs) {
- m->multiply(rhs);
-}
-static void SC_MatrixMultiply_3x3_3x3(Matrix3x3 *m, const Matrix3x3 *rhs) {
- m->multiply(rhs);
-}
-static void SC_MatrixMultiply_2x2_2x2(Matrix2x2 *m, const Matrix2x2 *rhs) {
- m->multiply(rhs);
-}
-
-static void SC_MatrixLoadOrtho(Matrix4x4 *m, float l, float r, float b, float t, float n, float f) {
- m->loadOrtho(l, r, b, t, n, f);
-}
-static void SC_MatrixLoadFrustum(Matrix4x4 *m, float l, float r, float b, float t, float n, float f) {
- m->loadFrustum(l, r, b, t, n, f);
-}
-static void SC_MatrixLoadPerspective(Matrix4x4 *m, float fovy, float aspect, float near, float far) {
- m->loadPerspective(fovy, aspect, near, far);
-}
-
-static bool SC_MatrixInverse_4x4(Matrix4x4 *m) {
- return m->inverse();
-}
-static bool SC_MatrixInverseTranspose_4x4(Matrix4x4 *m) {
- return m->inverseTranspose();
-}
-static void SC_MatrixTranspose_4x4(Matrix4x4 *m) {
- m->transpose();
-}
-static void SC_MatrixTranspose_3x3(Matrix3x3 *m) {
- m->transpose();
-}
-static void SC_MatrixTranspose_2x2(Matrix2x2 *m) {
- m->transpose();
-}
-
-static float SC_randf(float max) {
- float r = (float)rand();
- r *= max;
- r /= RAND_MAX;
- return r;
-}
-
-static float SC_randf2(float min, float max) {
- float r = (float)rand();
- r /= RAND_MAX;
- r = r * (max - min) + min;
- return r;
-}
-
-static int SC_randi(int max) {
- return (int)SC_randf(max);
-}
-
-static int SC_randi2(int min, int max) {
- return (int)SC_randf2(min, max);
-}
-
-static float SC_frac(float v) {
- int i = (int)floor(v);
- return fmin(v - i, 0x1.fffffep-1f);
-}
-
-
-static int32_t SC_AtomicCas(volatile int32_t *ptr, int32_t expectedValue, int32_t newValue) {
- int32_t prev;
-
- do {
- int32_t ret = android_atomic_release_cas(expectedValue, newValue, ptr);
- if (!ret) {
- // The android cas return 0 if it wrote the value. This means the
- // previous value was the expected value and we can return.
- return expectedValue;
- }
- // We didn't write the value and need to load the "previous" value.
- prev = *ptr;
-
- // A race condition exists where the expected value could appear after our cas failed
- // above. In this case loop until we have a legit previous value or the
- // write passes.
- } while (prev == expectedValue);
- return prev;
-}
-
-
-static int32_t SC_AtomicInc(volatile int32_t *ptr) {
- return android_atomic_inc(ptr);
-}
-
-static int32_t SC_AtomicDec(volatile int32_t *ptr) {
- return android_atomic_dec(ptr);
-}
-
-static int32_t SC_AtomicAdd(volatile int32_t *ptr, int32_t value) {
- return android_atomic_add(value, ptr);
-}
-
-static int32_t SC_AtomicSub(volatile int32_t *ptr, int32_t value) {
- int32_t prev, status;
- do {
- prev = *ptr;
- status = android_atomic_release_cas(prev, prev - value, ptr);
- } while (CC_UNLIKELY(status != 0));
- return prev;
-}
-
-static int32_t SC_AtomicAnd(volatile int32_t *ptr, int32_t value) {
- return android_atomic_and(value, ptr);
-}
-
-static int32_t SC_AtomicOr(volatile int32_t *ptr, int32_t value) {
- return android_atomic_or(value, ptr);
-}
-
-static int32_t SC_AtomicXor(volatile int32_t *ptr, int32_t value) {
- int32_t prev, status;
- do {
- prev = *ptr;
- status = android_atomic_release_cas(prev, prev ^ value, ptr);
- } while (CC_UNLIKELY(status != 0));
- return prev;
-}
-
-static uint32_t SC_AtomicUMin(volatile uint32_t *ptr, uint32_t value) {
- uint32_t prev, status;
- do {
- prev = *ptr;
- uint32_t n = rsMin(value, prev);
- status = android_atomic_release_cas((int32_t) prev, (int32_t)n, (volatile int32_t*) ptr);
- } while (CC_UNLIKELY(status != 0));
- return prev;
-}
-
-static int32_t SC_AtomicMin(volatile int32_t *ptr, int32_t value) {
- int32_t prev, status;
- do {
- prev = *ptr;
- int32_t n = rsMin(value, prev);
- status = android_atomic_release_cas(prev, n, ptr);
- } while (CC_UNLIKELY(status != 0));
- return prev;
-}
-
-static uint32_t SC_AtomicUMax(volatile uint32_t *ptr, uint32_t value) {
- uint32_t prev, status;
- do {
- prev = *ptr;
- uint32_t n = rsMax(value, prev);
- status = android_atomic_release_cas((int32_t) prev, (int32_t) n, (volatile int32_t*) ptr);
- } while (CC_UNLIKELY(status != 0));
- return prev;
-}
-
-static int32_t SC_AtomicMax(volatile int32_t *ptr, int32_t value) {
- int32_t prev, status;
- do {
- prev = *ptr;
- int32_t n = rsMax(value, prev);
- status = android_atomic_release_cas(prev, n, ptr);
- } while (CC_UNLIKELY(status != 0));
- return prev;
-}
-
-
-
-//////////////////////////////////////////////////////////////////////////////
-// Class implementation
-//////////////////////////////////////////////////////////////////////////////
-
-// llvm name mangling ref
-// <builtin-type> ::= v # void
-// ::= b # bool
-// ::= c # char
-// ::= a # signed char
-// ::= h # unsigned char
-// ::= s # short
-// ::= t # unsigned short
-// ::= i # int
-// ::= j # unsigned int
-// ::= l # long
-// ::= m # unsigned long
-// ::= x # long long, __int64
-// ::= y # unsigned long long, __int64
-// ::= f # float
-// ::= d # double
-
-static RsdSymbolTable gSyms[] = {
- { "_Z4acosf", (void *)&acosf, true },
- { "_Z5acoshf", (void *)&acoshf, true },
- { "_Z4asinf", (void *)&asinf, true },
- { "_Z5asinhf", (void *)&asinhf, true },
- { "_Z4atanf", (void *)&atanf, true },
- { "_Z5atan2ff", (void *)&atan2f, true },
- { "_Z5atanhf", (void *)&atanhf, true },
- { "_Z4cbrtf", (void *)&cbrtf, true },
- { "_Z4ceilf", (void *)&ceilf, true },
- { "_Z8copysignff", (void *)©signf, true },
- { "_Z3cosf", (void *)&cosf, true },
- { "_Z4coshf", (void *)&coshf, true },
- { "_Z4erfcf", (void *)&erfcf, true },
- { "_Z3erff", (void *)&erff, true },
- { "_Z3expf", (void *)&expf, true },
- { "_Z4exp2f", (void *)&exp2f, true },
- { "_Z5exp10f", (void *)&SC_exp10, true },
- { "_Z5expm1f", (void *)&expm1f, true },
- { "_Z4fabsf", (void *)&fabsf, true },
- { "_Z4fdimff", (void *)&fdimf, true },
- { "_Z5floorf", (void *)&floorf, true },
- { "_Z3fmafff", (void *)&fmaf, true },
- { "_Z4fmaxff", (void *)&fmaxf, true },
- { "_Z4fminff", (void *)&fminf, true }, // float fmin(float, float)
- { "_Z4fmodff", (void *)&fmodf, true },
- { "_Z5fractfPf", (void *)&SC_fract, true },
- { "_Z5frexpfPi", (void *)&frexpf, true },
- { "_Z5hypotff", (void *)&hypotf, true },
- { "_Z5ilogbf", (void *)&ilogbf, true },
- { "_Z5ldexpfi", (void *)&ldexpf, true },
- { "_Z6lgammaf", (void *)&lgammaf, true },
- { "_Z6lgammafPi", (void *)&lgammaf_r, true },
- { "_Z3logf", (void *)&logf, true },
- { "_Z4log2f", (void *)&SC_log2, true },
- { "_Z5log10f", (void *)&log10f, true },
- { "_Z5log1pf", (void *)&log1pf, true },
- { "_Z4logbf", (void *)&logbf, true },
- { "_Z3madfff", (void *)&SC_mad, true },
- { "_Z4modffPf", (void *)&modff, true },
- //{ "_Z3nanj", (void *)&SC_nan, true },
- { "_Z9nextafterff", (void *)&nextafterf, true },
- { "_Z3powff", (void *)&powf, true },
- { "_Z9remainderff", (void *)&remainderf, true },
- { "_Z6remquoffPi", (void *)&remquof, true },
- { "_Z4rintf", (void *)&rintf, true },
- { "_Z5rootnfi", (void *)&SC_rootn, true },
- { "_Z5roundf", (void *)&roundf, true },
- { "_Z5rsqrtf", (void *)&SC_rsqrt, true },
- { "_Z3sinf", (void *)&sinf, true },
- { "_Z6sincosfPf", (void *)&SC_sincos, true },
- { "_Z4sinhf", (void *)&sinhf, true },
- { "_Z4sqrtf", (void *)&sqrtf, true },
- { "_Z3tanf", (void *)&tanf, true },
- { "_Z4tanhf", (void *)&tanhf, true },
- { "_Z6tgammaf", (void *)&tgammaf, true },
- { "_Z5truncf", (void *)&truncf, true },
-
- { "_Z3absi", (void *)&SC_abs_i32, true },
- { "_Z3abss", (void *)&SC_abs_i16, true },
- { "_Z3absc", (void *)&SC_abs_i8, true },
- { "_Z3clzj", (void *)&SC_clz_u32, true },
- { "_Z3clzt", (void *)&SC_clz_u16, true },
- { "_Z3clzh", (void *)&SC_clz_u8, true },
- { "_Z3clzi", (void *)&SC_clz_i32, true },
- { "_Z3clzs", (void *)&SC_clz_i16, true },
- { "_Z3clzc", (void *)&SC_clz_i8, true },
- { "_Z3maxjj", (void *)&SC_max_u32, true },
- { "_Z3maxtt", (void *)&SC_max_u16, true },
- { "_Z3maxhh", (void *)&SC_max_u8, true },
- { "_Z3maxii", (void *)&SC_max_i32, true },
- { "_Z3maxss", (void *)&SC_max_i16, true },
- { "_Z3maxcc", (void *)&SC_max_i8, true },
- { "_Z3minjj", (void *)&SC_min_u32, true },
- { "_Z3mintt", (void *)&SC_min_u16, true },
- { "_Z3minhh", (void *)&SC_min_u8, true },
- { "_Z3minii", (void *)&SC_min_i32, true },
- { "_Z3minss", (void *)&SC_min_i16, true },
- { "_Z3mincc", (void *)&SC_min_i8, true },
-
- { "_Z5clampfff", (void *)&SC_clamp_f32, true },
- { "_Z7degreesf", (void *)&SC_degrees, true },
- { "_Z3maxff", (void *)&SC_max_f32, true },
- { "_Z3minff", (void *)&SC_min_f32, true },
- { "_Z3mixfff", (void *)&SC_mix_f32, true },
- { "_Z7radiansf", (void *)&SC_radians, true },
- { "_Z4stepff", (void *)&SC_step_f32, true },
- //{ "smoothstep", (void *)&, true },
- { "_Z4signf", (void *)&SC_sign_f32, true },
-
- // matrix
- { "_Z20rsMatrixLoadIdentityP12rs_matrix4x4", (void *)&SC_MatrixLoadIdentity_4x4, true },
- { "_Z20rsMatrixLoadIdentityP12rs_matrix3x3", (void *)&SC_MatrixLoadIdentity_3x3, true },
- { "_Z20rsMatrixLoadIdentityP12rs_matrix2x2", (void *)&SC_MatrixLoadIdentity_2x2, true },
-
- { "_Z12rsMatrixLoadP12rs_matrix4x4PKf", (void *)&SC_MatrixLoad_4x4_f, true },
- { "_Z12rsMatrixLoadP12rs_matrix3x3PKf", (void *)&SC_MatrixLoad_3x3_f, true },
- { "_Z12rsMatrixLoadP12rs_matrix2x2PKf", (void *)&SC_MatrixLoad_2x2_f, true },
-
- { "_Z12rsMatrixLoadP12rs_matrix4x4PKS_", (void *)&SC_MatrixLoad_4x4_4x4, true },
- { "_Z12rsMatrixLoadP12rs_matrix4x4PK12rs_matrix3x3", (void *)&SC_MatrixLoad_4x4_3x3, true },
- { "_Z12rsMatrixLoadP12rs_matrix4x4PK12rs_matrix2x2", (void *)&SC_MatrixLoad_4x4_2x2, true },
- { "_Z12rsMatrixLoadP12rs_matrix3x3PKS_", (void *)&SC_MatrixLoad_3x3_3x3, true },
- { "_Z12rsMatrixLoadP12rs_matrix2x2PKS_", (void *)&SC_MatrixLoad_2x2_2x2, true },
-
- { "_Z18rsMatrixLoadRotateP12rs_matrix4x4ffff", (void *)&SC_MatrixLoadRotate, true },
- { "_Z17rsMatrixLoadScaleP12rs_matrix4x4fff", (void *)&SC_MatrixLoadScale, true },
- { "_Z21rsMatrixLoadTranslateP12rs_matrix4x4fff", (void *)&SC_MatrixLoadTranslate, true },
- { "_Z14rsMatrixRotateP12rs_matrix4x4ffff", (void *)&SC_MatrixRotate, true },
- { "_Z13rsMatrixScaleP12rs_matrix4x4fff", (void *)&SC_MatrixScale, true },
- { "_Z17rsMatrixTranslateP12rs_matrix4x4fff", (void *)&SC_MatrixTranslate, true },
-
- { "_Z20rsMatrixLoadMultiplyP12rs_matrix4x4PKS_S2_", (void *)&SC_MatrixLoadMultiply_4x4_4x4_4x4, true },
- { "_Z16rsMatrixMultiplyP12rs_matrix4x4PKS_", (void *)&SC_MatrixMultiply_4x4_4x4, true },
- { "_Z20rsMatrixLoadMultiplyP12rs_matrix3x3PKS_S2_", (void *)&SC_MatrixLoadMultiply_3x3_3x3_3x3, true },
- { "_Z16rsMatrixMultiplyP12rs_matrix3x3PKS_", (void *)&SC_MatrixMultiply_3x3_3x3, true },
- { "_Z20rsMatrixLoadMultiplyP12rs_matrix2x2PKS_S2_", (void *)&SC_MatrixLoadMultiply_2x2_2x2_2x2, true },
- { "_Z16rsMatrixMultiplyP12rs_matrix2x2PKS_", (void *)&SC_MatrixMultiply_2x2_2x2, true },
-
- { "_Z17rsMatrixLoadOrthoP12rs_matrix4x4ffffff", (void *)&SC_MatrixLoadOrtho, true },
- { "_Z19rsMatrixLoadFrustumP12rs_matrix4x4ffffff", (void *)&SC_MatrixLoadFrustum, true },
- { "_Z23rsMatrixLoadPerspectiveP12rs_matrix4x4ffff", (void *)&SC_MatrixLoadPerspective, true },
-
- { "_Z15rsMatrixInverseP12rs_matrix4x4", (void *)&SC_MatrixInverse_4x4, true },
- { "_Z24rsMatrixInverseTransposeP12rs_matrix4x4", (void *)&SC_MatrixInverseTranspose_4x4, true },
- { "_Z17rsMatrixTransposeP12rs_matrix4x4", (void *)&SC_MatrixTranspose_4x4, true },
- { "_Z17rsMatrixTransposeP12rs_matrix4x4", (void *)&SC_MatrixTranspose_3x3, true },
- { "_Z17rsMatrixTransposeP12rs_matrix4x4", (void *)&SC_MatrixTranspose_2x2, true },
-
- // RS Math
- { "_Z6rsRandi", (void *)&SC_randi, true },
- { "_Z6rsRandii", (void *)&SC_randi2, true },
- { "_Z6rsRandf", (void *)&SC_randf, true },
- { "_Z6rsRandff", (void *)&SC_randf2, true },
- { "_Z6rsFracf", (void *)&SC_frac, true },
-
- // Atomics
- { "_Z11rsAtomicIncPVi", (void *)&SC_AtomicInc, true },
- { "_Z11rsAtomicIncPVj", (void *)&SC_AtomicInc, true },
- { "_Z11rsAtomicDecPVi", (void *)&SC_AtomicDec, true },
- { "_Z11rsAtomicDecPVj", (void *)&SC_AtomicDec, true },
- { "_Z11rsAtomicAddPVii", (void *)&SC_AtomicAdd, true },
- { "_Z11rsAtomicAddPVjj", (void *)&SC_AtomicAdd, true },
- { "_Z11rsAtomicSubPVii", (void *)&SC_AtomicSub, true },
- { "_Z11rsAtomicSubPVjj", (void *)&SC_AtomicSub, true },
- { "_Z11rsAtomicAndPVii", (void *)&SC_AtomicAnd, true },
- { "_Z11rsAtomicAndPVjj", (void *)&SC_AtomicAnd, true },
- { "_Z10rsAtomicOrPVii", (void *)&SC_AtomicOr, true },
- { "_Z10rsAtomicOrPVjj", (void *)&SC_AtomicOr, true },
- { "_Z11rsAtomicXorPVii", (void *)&SC_AtomicXor, true },
- { "_Z11rsAtomicXorPVjj", (void *)&SC_AtomicXor, true },
- { "_Z11rsAtomicMinPVii", (void *)&SC_AtomicMin, true },
- { "_Z11rsAtomicMinPVjj", (void *)&SC_AtomicUMin, true },
- { "_Z11rsAtomicMaxPVii", (void *)&SC_AtomicMax, true },
- { "_Z11rsAtomicMaxPVjj", (void *)&SC_AtomicUMax, true },
- { "_Z11rsAtomicCasPViii", (void *)&SC_AtomicCas, true },
- { "_Z11rsAtomicCasPVjjj", (void *)&SC_AtomicCas, true },
-
- { NULL, NULL, false }
-};
-
-const RsdSymbolTable * rsdLookupSymbolMath(const char *sym) {
- const RsdSymbolTable *syms = gSyms;
-
- while (syms->mPtr) {
- if (!strcmp(syms->mName, sym)) {
- return syms;
- }
- syms++;
- }
- return NULL;
-}
-
diff --git a/libs/rs/driver/rsdRuntimeStubs.cpp b/libs/rs/driver/rsdRuntimeStubs.cpp
deleted file mode 100644
index aa9f159..0000000
--- a/libs/rs/driver/rsdRuntimeStubs.cpp
+++ /dev/null
@@ -1,720 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#include "rsContext.h"
-#include "rsScriptC.h"
-#include "rsMatrix4x4.h"
-#include "rsMatrix3x3.h"
-#include "rsMatrix2x2.h"
-#include "rsRuntime.h"
-
-#include "utils/Timers.h"
-#include "rsdCore.h"
-
-#include "rsdRuntime.h"
-#include "rsdPath.h"
-
-#include <time.h>
-
-using namespace android;
-using namespace android::renderscript;
-
-#define GET_TLS() ScriptTLSStruct * tls = \
- (ScriptTLSStruct *)pthread_getspecific(rsdgThreadTLSKey); \
- Context * rsc = tls->mContext; \
- ScriptC * sc = (ScriptC *) tls->mScript
-
-
-
-//////////////////////////////////////////////////////////////////////////////
-// Allocation
-//////////////////////////////////////////////////////////////////////////////
-
-
-static void SC_AllocationSyncAll2(Allocation *a, RsAllocationUsageType source) {
- GET_TLS();
- rsrAllocationSyncAll(rsc, sc, a, source);
-}
-
-static void SC_AllocationSyncAll(Allocation *a) {
- GET_TLS();
- rsrAllocationSyncAll(rsc, sc, a, RS_ALLOCATION_USAGE_SCRIPT);
-}
-
-static void SC_AllocationCopy1DRange(Allocation *dstAlloc,
- uint32_t dstOff,
- uint32_t dstMip,
- uint32_t count,
- Allocation *srcAlloc,
- uint32_t srcOff, uint32_t srcMip) {
- GET_TLS();
- rsrAllocationCopy1DRange(rsc, dstAlloc, dstOff, dstMip, count,
- srcAlloc, srcOff, srcMip);
-}
-
-static void SC_AllocationCopy2DRange(Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstYoff,
- uint32_t dstMip, uint32_t dstFace,
- uint32_t width, uint32_t height,
- Allocation *srcAlloc,
- uint32_t srcXoff, uint32_t srcYoff,
- uint32_t srcMip, uint32_t srcFace) {
- GET_TLS();
- rsrAllocationCopy2DRange(rsc, dstAlloc,
- dstXoff, dstYoff, dstMip, dstFace,
- width, height,
- srcAlloc,
- srcXoff, srcYoff, srcMip, srcFace);
-}
-
-
-//////////////////////////////////////////////////////////////////////////////
-// Context
-//////////////////////////////////////////////////////////////////////////////
-
-static void SC_BindTexture(ProgramFragment *pf, uint32_t slot, Allocation *a) {
- GET_TLS();
- rsrBindTexture(rsc, sc, pf, slot, a);
-}
-
-static void SC_BindVertexConstant(ProgramVertex *pv, uint32_t slot, Allocation *a) {
- GET_TLS();
- rsrBindConstant(rsc, sc, pv, slot, a);
-}
-
-static void SC_BindFragmentConstant(ProgramFragment *pf, uint32_t slot, Allocation *a) {
- GET_TLS();
- rsrBindConstant(rsc, sc, pf, slot, a);
-}
-
-static void SC_BindSampler(ProgramFragment *pf, uint32_t slot, Sampler *s) {
- GET_TLS();
- rsrBindSampler(rsc, sc, pf, slot, s);
-}
-
-static void SC_BindProgramStore(ProgramStore *ps) {
- GET_TLS();
- rsrBindProgramStore(rsc, sc, ps);
-}
-
-static void SC_BindProgramFragment(ProgramFragment *pf) {
- GET_TLS();
- rsrBindProgramFragment(rsc, sc, pf);
-}
-
-static void SC_BindProgramVertex(ProgramVertex *pv) {
- GET_TLS();
- rsrBindProgramVertex(rsc, sc, pv);
-}
-
-static void SC_BindProgramRaster(ProgramRaster *pr) {
- GET_TLS();
- rsrBindProgramRaster(rsc, sc, pr);
-}
-
-static void SC_BindFrameBufferObjectColorTarget(Allocation *a, uint32_t slot) {
- GET_TLS();
- rsrBindFrameBufferObjectColorTarget(rsc, sc, a, slot);
-}
-
-static void SC_BindFrameBufferObjectDepthTarget(Allocation *a) {
- GET_TLS();
- rsrBindFrameBufferObjectDepthTarget(rsc, sc, a);
-}
-
-static void SC_ClearFrameBufferObjectColorTarget(uint32_t slot) {
- GET_TLS();
- rsrClearFrameBufferObjectColorTarget(rsc, sc, slot);
-}
-
-static void SC_ClearFrameBufferObjectDepthTarget(Context *, Script *) {
- GET_TLS();
- rsrClearFrameBufferObjectDepthTarget(rsc, sc);
-}
-
-static void SC_ClearFrameBufferObjectTargets(Context *, Script *) {
- GET_TLS();
- rsrClearFrameBufferObjectTargets(rsc, sc);
-}
-
-
-//////////////////////////////////////////////////////////////////////////////
-// VP
-//////////////////////////////////////////////////////////////////////////////
-
-static void SC_VpLoadProjectionMatrix(const rsc_Matrix *m) {
- GET_TLS();
- rsrVpLoadProjectionMatrix(rsc, sc, m);
-}
-
-static void SC_VpLoadModelMatrix(const rsc_Matrix *m) {
- GET_TLS();
- rsrVpLoadModelMatrix(rsc, sc, m);
-}
-
-static void SC_VpLoadTextureMatrix(const rsc_Matrix *m) {
- GET_TLS();
- rsrVpLoadTextureMatrix(rsc, sc, m);
-}
-
-static void SC_PfConstantColor(ProgramFragment *pf, float r, float g, float b, float a) {
- GET_TLS();
- rsrPfConstantColor(rsc, sc, pf, r, g, b, a);
-}
-
-static void SC_VpGetProjectionMatrix(rsc_Matrix *m) {
- GET_TLS();
- rsrVpGetProjectionMatrix(rsc, sc, m);
-}
-
-
-//////////////////////////////////////////////////////////////////////////////
-// Drawing
-//////////////////////////////////////////////////////////////////////////////
-
-static void SC_DrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1,
- float x2, float y2, float z2, float u2, float v2,
- float x3, float y3, float z3, float u3, float v3,
- float x4, float y4, float z4, float u4, float v4) {
- GET_TLS();
- rsrDrawQuadTexCoords(rsc, sc,
- x1, y1, z1, u1, v1,
- x2, y2, z2, u2, v2,
- x3, y3, z3, u3, v3,
- x4, y4, z4, u4, v4);
-}
-
-static void SC_DrawQuad(float x1, float y1, float z1,
- float x2, float y2, float z2,
- float x3, float y3, float z3,
- float x4, float y4, float z4) {
- GET_TLS();
- rsrDrawQuad(rsc, sc, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4);
-}
-
-static void SC_DrawSpriteScreenspace(float x, float y, float z, float w, float h) {
- GET_TLS();
- rsrDrawSpriteScreenspace(rsc, sc, x, y, z, w, h);
-}
-
-static void SC_DrawRect(float x1, float y1, float x2, float y2, float z) {
- GET_TLS();
- rsrDrawRect(rsc, sc, x1, y1, x2, y2, z);
-}
-
-static void SC_DrawPath(Path *p) {
- GET_TLS();
- //rsrDrawPath(rsc, sc, p);
- rsdPathDraw(rsc, p);
-}
-
-static void SC_DrawMesh(Mesh *m) {
- GET_TLS();
- rsrDrawMesh(rsc, sc, m);
-}
-
-static void SC_DrawMeshPrimitive(Mesh *m, uint32_t primIndex) {
- GET_TLS();
- rsrDrawMeshPrimitive(rsc, sc, m, primIndex);
-}
-
-static void SC_DrawMeshPrimitiveRange(Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len) {
- GET_TLS();
- rsrDrawMeshPrimitiveRange(rsc, sc, m, primIndex, start, len);
-}
-
-static void SC_MeshComputeBoundingBox(Mesh *m,
- float *minX, float *minY, float *minZ,
- float *maxX, float *maxY, float *maxZ) {
- GET_TLS();
- rsrMeshComputeBoundingBox(rsc, sc, m, minX, minY, minZ, maxX, maxY, maxZ);
-}
-
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-
-
-static void SC_Color(float r, float g, float b, float a) {
- GET_TLS();
- rsrColor(rsc, sc, r, g, b, a);
-}
-
-static void SC_Finish() {
- GET_TLS();
- rsdGLFinish(rsc);
-}
-
-static void SC_ClearColor(float r, float g, float b, float a) {
- GET_TLS();
- rsrPrepareClear(rsc, sc);
- rsdGLClearColor(rsc, r, g, b, a);
-}
-
-static void SC_ClearDepth(float v) {
- GET_TLS();
- rsrPrepareClear(rsc, sc);
- rsdGLClearDepth(rsc, v);
-}
-
-static uint32_t SC_GetWidth() {
- GET_TLS();
- return rsrGetWidth(rsc, sc);
-}
-
-static uint32_t SC_GetHeight() {
- GET_TLS();
- return rsrGetHeight(rsc, sc);
-}
-
-static void SC_DrawTextAlloc(Allocation *a, int x, int y) {
- GET_TLS();
- rsrDrawTextAlloc(rsc, sc, a, x, y);
-}
-
-static void SC_DrawText(const char *text, int x, int y) {
- GET_TLS();
- rsrDrawText(rsc, sc, text, x, y);
-}
-
-static void SC_MeasureTextAlloc(Allocation *a,
- int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) {
- GET_TLS();
- rsrMeasureTextAlloc(rsc, sc, a, left, right, top, bottom);
-}
-
-static void SC_MeasureText(const char *text,
- int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) {
- GET_TLS();
- rsrMeasureText(rsc, sc, text, left, right, top, bottom);
-}
-
-static void SC_BindFont(Font *f) {
- GET_TLS();
- rsrBindFont(rsc, sc, f);
-}
-
-static void SC_FontColor(float r, float g, float b, float a) {
- GET_TLS();
- rsrFontColor(rsc, sc, r, g, b, a);
-}
-
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-
-static void SC_SetObject(ObjectBase **dst, ObjectBase * src) {
- GET_TLS();
- rsrSetObject(rsc, sc, dst, src);
-}
-
-static void SC_ClearObject(ObjectBase **dst) {
- GET_TLS();
- rsrClearObject(rsc, sc, dst);
-}
-
-static bool SC_IsObject(const ObjectBase *src) {
- GET_TLS();
- return rsrIsObject(rsc, sc, src);
-}
-
-
-
-
-static const Allocation * SC_GetAllocation(const void *ptr) {
- GET_TLS();
- return rsrGetAllocation(rsc, sc, ptr);
-}
-
-static void SC_ForEach_SAA(Script *target,
- Allocation *in,
- Allocation *out) {
- GET_TLS();
- rsrForEach(rsc, sc, target, in, out, NULL, 0, NULL);
-}
-
-static void SC_ForEach_SAAU(Script *target,
- Allocation *in,
- Allocation *out,
- const void *usr) {
- GET_TLS();
- rsrForEach(rsc, sc, target, in, out, usr, 0, NULL);
-}
-
-static void SC_ForEach_SAAUS(Script *target,
- Allocation *in,
- Allocation *out,
- const void *usr,
- const RsScriptCall *call) {
- GET_TLS();
- rsrForEach(rsc, sc, target, in, out, usr, 0, call);
-}
-
-static void SC_ForEach_SAAUL(Script *target,
- Allocation *in,
- Allocation *out,
- const void *usr,
- uint32_t usrLen) {
- GET_TLS();
- rsrForEach(rsc, sc, target, in, out, usr, usrLen, NULL);
-}
-
-static void SC_ForEach_SAAULS(Script *target,
- Allocation *in,
- Allocation *out,
- const void *usr,
- uint32_t usrLen,
- const RsScriptCall *call) {
- GET_TLS();
- rsrForEach(rsc, sc, target, in, out, usr, usrLen, call);
-}
-
-
-
-//////////////////////////////////////////////////////////////////////////////
-// Time routines
-//////////////////////////////////////////////////////////////////////////////
-
-static float SC_GetDt() {
- GET_TLS();
- return rsrGetDt(rsc, sc);
-}
-
-time_t SC_Time(time_t *timer) {
- GET_TLS();
- return rsrTime(rsc, sc, timer);
-}
-
-tm* SC_LocalTime(tm *local, time_t *timer) {
- GET_TLS();
- return rsrLocalTime(rsc, sc, local, timer);
-}
-
-int64_t SC_UptimeMillis() {
- GET_TLS();
- return rsrUptimeMillis(rsc, sc);
-}
-
-int64_t SC_UptimeNanos() {
- GET_TLS();
- return rsrUptimeNanos(rsc, sc);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-// Message routines
-//////////////////////////////////////////////////////////////////////////////
-
-static uint32_t SC_ToClient2(int cmdID, void *data, int len) {
- GET_TLS();
- return rsrToClient(rsc, sc, cmdID, data, len);
-}
-
-static uint32_t SC_ToClient(int cmdID) {
- GET_TLS();
- return rsrToClient(rsc, sc, cmdID, NULL, 0);
-}
-
-static uint32_t SC_ToClientBlocking2(int cmdID, void *data, int len) {
- GET_TLS();
- return rsrToClientBlocking(rsc, sc, cmdID, data, len);
-}
-
-static uint32_t SC_ToClientBlocking(int cmdID) {
- GET_TLS();
- return rsrToClientBlocking(rsc, sc, cmdID, NULL, 0);
-}
-
-int SC_divsi3(int a, int b) {
- return a / b;
-}
-
-int SC_modsi3(int a, int b) {
- return a % b;
-}
-
-unsigned int SC_udivsi3(unsigned int a, unsigned int b) {
- return a / b;
-}
-
-unsigned int SC_umodsi3(unsigned int a, unsigned int b) {
- return a % b;
-}
-
-static void SC_debugF(const char *s, float f) {
- ALOGD("%s %f, 0x%08x", s, f, *((int *) (&f)));
-}
-static void SC_debugFv2(const char *s, float f1, float f2) {
- ALOGD("%s {%f, %f}", s, f1, f2);
-}
-static void SC_debugFv3(const char *s, float f1, float f2, float f3) {
- ALOGD("%s {%f, %f, %f}", s, f1, f2, f3);
-}
-static void SC_debugFv4(const char *s, float f1, float f2, float f3, float f4) {
- ALOGD("%s {%f, %f, %f, %f}", s, f1, f2, f3, f4);
-}
-static void SC_debugD(const char *s, double d) {
- ALOGD("%s %f, 0x%08llx", s, d, *((long long *) (&d)));
-}
-static void SC_debugFM4v4(const char *s, const float *f) {
- ALOGD("%s {%f, %f, %f, %f", s, f[0], f[4], f[8], f[12]);
- ALOGD("%s %f, %f, %f, %f", s, f[1], f[5], f[9], f[13]);
- ALOGD("%s %f, %f, %f, %f", s, f[2], f[6], f[10], f[14]);
- ALOGD("%s %f, %f, %f, %f}", s, f[3], f[7], f[11], f[15]);
-}
-static void SC_debugFM3v3(const char *s, const float *f) {
- ALOGD("%s {%f, %f, %f", s, f[0], f[3], f[6]);
- ALOGD("%s %f, %f, %f", s, f[1], f[4], f[7]);
- ALOGD("%s %f, %f, %f}",s, f[2], f[5], f[8]);
-}
-static void SC_debugFM2v2(const char *s, const float *f) {
- ALOGD("%s {%f, %f", s, f[0], f[2]);
- ALOGD("%s %f, %f}",s, f[1], f[3]);
-}
-
-static void SC_debugI32(const char *s, int32_t i) {
- ALOGD("%s %i 0x%x", s, i, i);
-}
-static void SC_debugU32(const char *s, uint32_t i) {
- ALOGD("%s %u 0x%x", s, i, i);
-}
-static void SC_debugLL64(const char *s, long long ll) {
- ALOGD("%s %lld 0x%llx", s, ll, ll);
-}
-static void SC_debugULL64(const char *s, unsigned long long ll) {
- ALOGD("%s %llu 0x%llx", s, ll, ll);
-}
-
-static void SC_debugP(const char *s, const void *p) {
- ALOGD("%s %p", s, p);
-}
-
-
-//////////////////////////////////////////////////////////////////////////////
-// Stub implementation
-//////////////////////////////////////////////////////////////////////////////
-
-// llvm name mangling ref
-// <builtin-type> ::= v # void
-// ::= b # bool
-// ::= c # char
-// ::= a # signed char
-// ::= h # unsigned char
-// ::= s # short
-// ::= t # unsigned short
-// ::= i # int
-// ::= j # unsigned int
-// ::= l # long
-// ::= m # unsigned long
-// ::= x # long long, __int64
-// ::= y # unsigned long long, __int64
-// ::= f # float
-// ::= d # double
-
-static RsdSymbolTable gSyms[] = {
- { "memset", (void *)&memset, true },
- { "memcpy", (void *)&memcpy, true },
-
- // Refcounting
- { "_Z11rsSetObjectP10rs_elementS_", (void *)&SC_SetObject, true },
- { "_Z13rsClearObjectP10rs_element", (void *)&SC_ClearObject, true },
- { "_Z10rsIsObject10rs_element", (void *)&SC_IsObject, true },
-
- { "_Z11rsSetObjectP7rs_typeS_", (void *)&SC_SetObject, true },
- { "_Z13rsClearObjectP7rs_type", (void *)&SC_ClearObject, true },
- { "_Z10rsIsObject7rs_type", (void *)&SC_IsObject, true },
-
- { "_Z11rsSetObjectP13rs_allocationS_", (void *)&SC_SetObject, true },
- { "_Z13rsClearObjectP13rs_allocation", (void *)&SC_ClearObject, true },
- { "_Z10rsIsObject13rs_allocation", (void *)&SC_IsObject, true },
-
- { "_Z11rsSetObjectP10rs_samplerS_", (void *)&SC_SetObject, true },
- { "_Z13rsClearObjectP10rs_sampler", (void *)&SC_ClearObject, true },
- { "_Z10rsIsObject10rs_sampler", (void *)&SC_IsObject, true },
-
- { "_Z11rsSetObjectP9rs_scriptS_", (void *)&SC_SetObject, true },
- { "_Z13rsClearObjectP9rs_script", (void *)&SC_ClearObject, true },
- { "_Z10rsIsObject9rs_script", (void *)&SC_IsObject, true },
-
- { "_Z11rsSetObjectP7rs_pathS_", (void *)&SC_SetObject, true },
- { "_Z13rsClearObjectP7rs_path", (void *)&SC_ClearObject, true },
- { "_Z10rsIsObject7rs_path", (void *)&SC_IsObject, true },
-
- { "_Z11rsSetObjectP7rs_meshS_", (void *)&SC_SetObject, true },
- { "_Z13rsClearObjectP7rs_mesh", (void *)&SC_ClearObject, true },
- { "_Z10rsIsObject7rs_mesh", (void *)&SC_IsObject, true },
-
- { "_Z11rsSetObjectP19rs_program_fragmentS_", (void *)&SC_SetObject, true },
- { "_Z13rsClearObjectP19rs_program_fragment", (void *)&SC_ClearObject, true },
- { "_Z10rsIsObject19rs_program_fragment", (void *)&SC_IsObject, true },
-
- { "_Z11rsSetObjectP17rs_program_vertexS_", (void *)&SC_SetObject, true },
- { "_Z13rsClearObjectP17rs_program_vertex", (void *)&SC_ClearObject, true },
- { "_Z10rsIsObject17rs_program_vertex", (void *)&SC_IsObject, true },
-
- { "_Z11rsSetObjectP17rs_program_rasterS_", (void *)&SC_SetObject, true },
- { "_Z13rsClearObjectP17rs_program_raster", (void *)&SC_ClearObject, true },
- { "_Z10rsIsObject17rs_program_raster", (void *)&SC_IsObject, true },
-
- { "_Z11rsSetObjectP16rs_program_storeS_", (void *)&SC_SetObject, true },
- { "_Z13rsClearObjectP16rs_program_store", (void *)&SC_ClearObject, true },
- { "_Z10rsIsObject16rs_program_store", (void *)&SC_IsObject, true },
-
- { "_Z11rsSetObjectP7rs_fontS_", (void *)&SC_SetObject, true },
- { "_Z13rsClearObjectP7rs_font", (void *)&SC_ClearObject, true },
- { "_Z10rsIsObject7rs_font", (void *)&SC_IsObject, true },
-
- // Allocation ops
- { "_Z21rsAllocationMarkDirty13rs_allocation", (void *)&SC_AllocationSyncAll, true },
- { "_Z20rsgAllocationSyncAll13rs_allocation", (void *)&SC_AllocationSyncAll, false },
- { "_Z20rsgAllocationSyncAll13rs_allocationj", (void *)&SC_AllocationSyncAll2, false },
- { "_Z20rsgAllocationSyncAll13rs_allocation24rs_allocation_usage_type", (void *)&SC_AllocationSyncAll2, false },
- { "_Z15rsGetAllocationPKv", (void *)&SC_GetAllocation, true },
-
- { "_Z23rsAllocationCopy1DRange13rs_allocationjjjS_jj", (void *)&SC_AllocationCopy1DRange, false },
- { "_Z23rsAllocationCopy2DRange13rs_allocationjjj26rs_allocation_cubemap_facejjS_jjjS0_", (void *)&SC_AllocationCopy2DRange, false },
-
- // Messaging
-
- { "_Z14rsSendToClienti", (void *)&SC_ToClient, false },
- { "_Z14rsSendToClientiPKvj", (void *)&SC_ToClient2, false },
- { "_Z22rsSendToClientBlockingi", (void *)&SC_ToClientBlocking, false },
- { "_Z22rsSendToClientBlockingiPKvj", (void *)&SC_ToClientBlocking2, false },
-
- { "_Z22rsgBindProgramFragment19rs_program_fragment", (void *)&SC_BindProgramFragment, false },
- { "_Z19rsgBindProgramStore16rs_program_store", (void *)&SC_BindProgramStore, false },
- { "_Z20rsgBindProgramVertex17rs_program_vertex", (void *)&SC_BindProgramVertex, false },
- { "_Z20rsgBindProgramRaster17rs_program_raster", (void *)&SC_BindProgramRaster, false },
- { "_Z14rsgBindSampler19rs_program_fragmentj10rs_sampler", (void *)&SC_BindSampler, false },
- { "_Z14rsgBindTexture19rs_program_fragmentj13rs_allocation", (void *)&SC_BindTexture, false },
- { "_Z15rsgBindConstant19rs_program_fragmentj13rs_allocation", (void *)&SC_BindFragmentConstant, false },
- { "_Z15rsgBindConstant17rs_program_vertexj13rs_allocation", (void *)&SC_BindVertexConstant, false },
-
- { "_Z36rsgProgramVertexLoadProjectionMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadProjectionMatrix, false },
- { "_Z31rsgProgramVertexLoadModelMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadModelMatrix, false },
- { "_Z33rsgProgramVertexLoadTextureMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadTextureMatrix, false },
-
- { "_Z35rsgProgramVertexGetProjectionMatrixP12rs_matrix4x4", (void *)&SC_VpGetProjectionMatrix, false },
-
- { "_Z31rsgProgramFragmentConstantColor19rs_program_fragmentffff", (void *)&SC_PfConstantColor, false },
-
- { "_Z11rsgGetWidthv", (void *)&SC_GetWidth, false },
- { "_Z12rsgGetHeightv", (void *)&SC_GetHeight, false },
-
-
- { "_Z11rsgDrawRectfffff", (void *)&SC_DrawRect, false },
- { "_Z11rsgDrawQuadffffffffffff", (void *)&SC_DrawQuad, false },
- { "_Z20rsgDrawQuadTexCoordsffffffffffffffffffff", (void *)&SC_DrawQuadTexCoords, false },
- { "_Z24rsgDrawSpriteScreenspacefffff", (void *)&SC_DrawSpriteScreenspace, false },
-
- { "_Z11rsgDrawMesh7rs_mesh", (void *)&SC_DrawMesh, false },
- { "_Z11rsgDrawMesh7rs_meshj", (void *)&SC_DrawMeshPrimitive, false },
- { "_Z11rsgDrawMesh7rs_meshjjj", (void *)&SC_DrawMeshPrimitiveRange, false },
- { "_Z25rsgMeshComputeBoundingBox7rs_meshPfS0_S0_S0_S0_S0_", (void *)&SC_MeshComputeBoundingBox, false },
-
- { "_Z11rsgDrawPath7rs_path", (void *)&SC_DrawPath, false },
-
- { "_Z13rsgClearColorffff", (void *)&SC_ClearColor, false },
- { "_Z13rsgClearDepthf", (void *)&SC_ClearDepth, false },
-
- { "_Z11rsgDrawTextPKcii", (void *)&SC_DrawText, false },
- { "_Z11rsgDrawText13rs_allocationii", (void *)&SC_DrawTextAlloc, false },
- { "_Z14rsgMeasureTextPKcPiS1_S1_S1_", (void *)&SC_MeasureText, false },
- { "_Z14rsgMeasureText13rs_allocationPiS0_S0_S0_", (void *)&SC_MeasureTextAlloc, false },
-
- { "_Z11rsgBindFont7rs_font", (void *)&SC_BindFont, false },
- { "_Z12rsgFontColorffff", (void *)&SC_FontColor, false },
-
- { "_Z18rsgBindColorTarget13rs_allocationj", (void *)&SC_BindFrameBufferObjectColorTarget, false },
- { "_Z18rsgBindDepthTarget13rs_allocation", (void *)&SC_BindFrameBufferObjectDepthTarget, false },
- { "_Z19rsgClearColorTargetj", (void *)&SC_ClearFrameBufferObjectColorTarget, false },
- { "_Z19rsgClearDepthTargetv", (void *)&SC_ClearFrameBufferObjectDepthTarget, false },
- { "_Z24rsgClearAllRenderTargetsv", (void *)&SC_ClearFrameBufferObjectTargets, false },
-
- { "_Z9rsForEach9rs_script13rs_allocationS0_", (void *)&SC_ForEach_SAA, false },
- { "_Z9rsForEach9rs_script13rs_allocationS0_PKv", (void *)&SC_ForEach_SAAU, false },
- { "_Z9rsForEach9rs_script13rs_allocationS0_PKvPK16rs_script_call_t", (void *)&SC_ForEach_SAAUS, false },
- { "_Z9rsForEach9rs_script13rs_allocationS0_PKvj", (void *)&SC_ForEach_SAAUL, false },
- { "_Z9rsForEach9rs_script13rs_allocationS0_PKvjPK16rs_script_call_t", (void *)&SC_ForEach_SAAULS, false },
-
- // time
- { "_Z6rsTimePi", (void *)&SC_Time, true },
- { "_Z11rsLocaltimeP5rs_tmPKi", (void *)&SC_LocalTime, true },
- { "_Z14rsUptimeMillisv", (void*)&SC_UptimeMillis, true },
- { "_Z13rsUptimeNanosv", (void*)&SC_UptimeNanos, true },
- { "_Z7rsGetDtv", (void*)&SC_GetDt, false },
-
- // misc
- { "_Z5colorffff", (void *)&SC_Color, false },
- { "_Z9rsgFinishv", (void *)&SC_Finish, false },
-
- // Debug
- { "_Z7rsDebugPKcf", (void *)&SC_debugF, true },
- { "_Z7rsDebugPKcff", (void *)&SC_debugFv2, true },
- { "_Z7rsDebugPKcfff", (void *)&SC_debugFv3, true },
- { "_Z7rsDebugPKcffff", (void *)&SC_debugFv4, true },
- { "_Z7rsDebugPKcd", (void *)&SC_debugD, true },
- { "_Z7rsDebugPKcPK12rs_matrix4x4", (void *)&SC_debugFM4v4, true },
- { "_Z7rsDebugPKcPK12rs_matrix3x3", (void *)&SC_debugFM3v3, true },
- { "_Z7rsDebugPKcPK12rs_matrix2x2", (void *)&SC_debugFM2v2, true },
- { "_Z7rsDebugPKci", (void *)&SC_debugI32, true },
- { "_Z7rsDebugPKcj", (void *)&SC_debugU32, true },
- // Both "long" and "unsigned long" need to be redirected to their
- // 64-bit counterparts, since we have hacked Slang to use 64-bit
- // for "long" on Arm (to be similar to Java).
- { "_Z7rsDebugPKcl", (void *)&SC_debugLL64, true },
- { "_Z7rsDebugPKcm", (void *)&SC_debugULL64, true },
- { "_Z7rsDebugPKcx", (void *)&SC_debugLL64, true },
- { "_Z7rsDebugPKcy", (void *)&SC_debugULL64, true },
- { "_Z7rsDebugPKcPKv", (void *)&SC_debugP, true },
-
- { NULL, NULL, false }
-};
-
-
-void* rsdLookupRuntimeStub(void* pContext, char const* name) {
- ScriptC *s = (ScriptC *)pContext;
- if (!strcmp(name, "__isThreadable")) {
- return (void*) s->mHal.info.isThreadable;
- } else if (!strcmp(name, "__clearThreadable")) {
- s->mHal.info.isThreadable = false;
- return NULL;
- }
-
- RsdSymbolTable *syms = gSyms;
- const RsdSymbolTable *sym = rsdLookupSymbolMath(name);
-
- if (!sym) {
- while (syms->mPtr) {
- if (!strcmp(syms->mName, name)) {
- sym = syms;
- }
- syms++;
- }
- }
-
- if (sym) {
- s->mHal.info.isThreadable &= sym->threadable;
- return sym->mPtr;
- }
- ALOGE("ScriptC sym lookup failed for %s", name);
- return NULL;
-}
-
-
diff --git a/libs/rs/driver/rsdSampler.cpp b/libs/rs/driver/rsdSampler.cpp
deleted file mode 100644
index af48c61..0000000
--- a/libs/rs/driver/rsdSampler.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-
-#include "rsdCore.h"
-#include "rsdSampler.h"
-
-#include "rsContext.h"
-#include "rsSampler.h"
-#include "rsProgramVertex.h"
-#include "rsProgramFragment.h"
-
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-
-
-using namespace android;
-using namespace android::renderscript;
-
-bool rsdSamplerInit(const android::renderscript::Context *,
- const android::renderscript::Sampler *) {
- return true;
-}
-
-void rsdSamplerDestroy(const android::renderscript::Context *rsc,
- const android::renderscript::Sampler *s) {
-}
diff --git a/libs/rs/driver/rsdSampler.h b/libs/rs/driver/rsdSampler.h
deleted file mode 100644
index 3a64e9e..0000000
--- a/libs/rs/driver/rsdSampler.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef RSD_SAMPLER_H
-#define RSD_SAMPLER_H
-
-#include <rs_hal.h>
-
-
-bool rsdSamplerInit(const android::renderscript::Context *rsc,
- const android::renderscript::Sampler *);
-
-void rsdSamplerDestroy(const android::renderscript::Context *rsc,
- const android::renderscript::Sampler *);
-
-
-#endif // RSD_SAMPLER_H
diff --git a/libs/rs/driver/rsdShader.cpp b/libs/rs/driver/rsdShader.cpp
deleted file mode 100644
index 6d9fa90..0000000
--- a/libs/rs/driver/rsdShader.cpp
+++ /dev/null
@@ -1,604 +0,0 @@
-/*
- * Copyright (C) 2011-2012 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.
- */
-
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-
-#include <rs_hal.h>
-#include <rsContext.h>
-#include <rsProgram.h>
-
-#include "rsdCore.h"
-#include "rsdAllocation.h"
-#include "rsdShader.h"
-#include "rsdShaderCache.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-RsdShader::RsdShader(const Program *p, uint32_t type,
- const char * shaderText, size_t shaderLength,
- const char** textureNames, size_t textureNamesCount,
- const size_t *textureNamesLength) {
- mUserShader.setTo(shaderText, shaderLength);
- mRSProgram = p;
- mType = type;
- initMemberVars();
- initAttribAndUniformArray();
- init(textureNames, textureNamesCount, textureNamesLength);
-
- for(size_t i=0; i < textureNamesCount; i++) {
- mTextureNames.push(String8(textureNames[i], textureNamesLength[i]));
- }
-}
-
-RsdShader::~RsdShader() {
- for (uint32_t i = 0; i < mStateBasedShaders.size(); i ++) {
- StateBasedKey *state = mStateBasedShaders.itemAt(i);
- if (state->mShaderID) {
- glDeleteShader(state->mShaderID);
- }
- delete state;
- }
-
- delete[] mAttribNames;
- delete[] mUniformNames;
- delete[] mUniformArraySizes;
-}
-
-void RsdShader::initMemberVars() {
- mDirty = true;
- mAttribCount = 0;
- mUniformCount = 0;
-
- mAttribNames = NULL;
- mUniformNames = NULL;
- mUniformArraySizes = NULL;
- mCurrentState = NULL;
-
- mIsValid = false;
-}
-
-RsdShader::StateBasedKey *RsdShader::getExistingState() {
- RsdShader::StateBasedKey *returnKey = NULL;
-
- for (uint32_t i = 0; i < mStateBasedShaders.size(); i ++) {
- returnKey = mStateBasedShaders.itemAt(i);
-
- for (uint32_t ct = 0; ct < mRSProgram->mHal.state.texturesCount; ct ++) {
- uint32_t texType = 0;
- if (mRSProgram->mHal.state.textureTargets[ct] == RS_TEXTURE_2D) {
- Allocation *a = mRSProgram->mHal.state.textures[ct];
- if (a && a->mHal.state.surfaceTextureID) {
- texType = GL_TEXTURE_EXTERNAL_OES;
- } else {
- texType = GL_TEXTURE_2D;
- }
- } else {
- texType = GL_TEXTURE_CUBE_MAP;
- }
- if (texType != returnKey->mTextureTargets[ct]) {
- returnKey = NULL;
- break;
- }
- }
- }
- return returnKey;
-}
-
-uint32_t RsdShader::getStateBasedShaderID(const Context *rsc) {
- StateBasedKey *state = getExistingState();
- if (state != NULL) {
- mCurrentState = state;
- return mCurrentState->mShaderID;
- }
- // We have not created a shader for this particular state yet
- state = new StateBasedKey(mTextureCount);
- mCurrentState = state;
- mStateBasedShaders.add(state);
- createShader();
- loadShader(rsc);
- return mCurrentState->mShaderID;
-}
-
-void RsdShader::init(const char** textureNames, size_t textureNamesCount,
- const size_t *textureNamesLength) {
- uint32_t attribCount = 0;
- uint32_t uniformCount = 0;
- for (uint32_t ct=0; ct < mRSProgram->mHal.state.inputElementsCount; ct++) {
- initAddUserElement(mRSProgram->mHal.state.inputElements[ct], mAttribNames,
- NULL, &attribCount, RS_SHADER_ATTR);
- }
- for (uint32_t ct=0; ct < mRSProgram->mHal.state.constantsCount; ct++) {
- initAddUserElement(mRSProgram->mHal.state.constantTypes[ct]->getElement(),
- mUniformNames, mUniformArraySizes, &uniformCount, RS_SHADER_UNI);
- }
-
- mTextureUniformIndexStart = uniformCount;
- for (uint32_t ct=0; ct < mRSProgram->mHal.state.texturesCount; ct++) {
- mUniformNames[uniformCount].setTo("UNI_");
- mUniformNames[uniformCount].append(textureNames[ct], textureNamesLength[ct]);
- mUniformArraySizes[uniformCount] = 1;
- uniformCount++;
- }
-}
-
-String8 RsdShader::getGLSLInputString() const {
- String8 s;
- for (uint32_t ct=0; ct < mRSProgram->mHal.state.inputElementsCount; ct++) {
- const Element *e = mRSProgram->mHal.state.inputElements[ct];
- for (uint32_t field=0; field < e->mHal.state.fieldsCount; field++) {
- const Element *f = e->mHal.state.fields[field];
-
- // Cannot be complex
- rsAssert(!f->mHal.state.fieldsCount);
- switch (f->mHal.state.vectorSize) {
- case 1: s.append("attribute float ATTRIB_"); break;
- case 2: s.append("attribute vec2 ATTRIB_"); break;
- case 3: s.append("attribute vec3 ATTRIB_"); break;
- case 4: s.append("attribute vec4 ATTRIB_"); break;
- default:
- rsAssert(0);
- }
-
- s.append(e->mHal.state.fieldNames[field]);
- s.append(";\n");
- }
- }
- return s;
-}
-
-void RsdShader::appendAttributes() {
- for (uint32_t ct=0; ct < mRSProgram->mHal.state.inputElementsCount; ct++) {
- const Element *e = mRSProgram->mHal.state.inputElements[ct];
- for (uint32_t field=0; field < e->mHal.state.fieldsCount; field++) {
- const Element *f = e->mHal.state.fields[field];
- const char *fn = e->mHal.state.fieldNames[field];
-
- // Cannot be complex
- rsAssert(!f->mHal.state.fieldsCount);
- switch (f->mHal.state.vectorSize) {
- case 1: mShader.append("attribute float ATTRIB_"); break;
- case 2: mShader.append("attribute vec2 ATTRIB_"); break;
- case 3: mShader.append("attribute vec3 ATTRIB_"); break;
- case 4: mShader.append("attribute vec4 ATTRIB_"); break;
- default:
- rsAssert(0);
- }
-
- mShader.append(fn);
- mShader.append(";\n");
- }
- }
-}
-
-void RsdShader::appendTextures() {
-
- // TODO: this does not yet handle cases where the texture changes between IO
- // input and local
- bool appendUsing = true;
- for (uint32_t ct = 0; ct < mRSProgram->mHal.state.texturesCount; ct ++) {
- if (mRSProgram->mHal.state.textureTargets[ct] == RS_TEXTURE_2D) {
- Allocation *a = mRSProgram->mHal.state.textures[ct];
- if (a && a->mHal.state.surfaceTextureID) {
- if(appendUsing) {
- mShader.append("#extension GL_OES_EGL_image_external : require\n");
- appendUsing = false;
- }
- mShader.append("uniform samplerExternalOES UNI_");
- mCurrentState->mTextureTargets[ct] = GL_TEXTURE_EXTERNAL_OES;
- } else {
- mShader.append("uniform sampler2D UNI_");
- mCurrentState->mTextureTargets[ct] = GL_TEXTURE_2D;
- }
- } else {
- mShader.append("uniform samplerCube UNI_");
- mCurrentState->mTextureTargets[ct] = GL_TEXTURE_CUBE_MAP;
- }
-
- mShader.append(mTextureNames[ct]);
- mShader.append(";\n");
- }
-}
-
-bool RsdShader::createShader() {
- mShader.clear();
- if (mType == GL_FRAGMENT_SHADER) {
- mShader.append("precision mediump float;\n");
- }
- appendUserConstants();
- appendAttributes();
- appendTextures();
- mShader.append(mUserShader);
-
- return true;
-}
-
-bool RsdShader::loadShader(const Context *rsc) {
- mCurrentState->mShaderID = glCreateShader(mType);
- rsAssert(mCurrentState->mShaderID);
-
- if(!mShader.length()) {
- createShader();
- }
-
- if (rsc->props.mLogShaders) {
- ALOGV("Loading shader type %x, ID %i", mType, mCurrentState->mShaderID);
- ALOGV("%s", mShader.string());
- }
-
- if (mCurrentState->mShaderID) {
- const char * ss = mShader.string();
- RSD_CALL_GL(glShaderSource, mCurrentState->mShaderID, 1, &ss, NULL);
- RSD_CALL_GL(glCompileShader, mCurrentState->mShaderID);
-
- GLint compiled = 0;
- RSD_CALL_GL(glGetShaderiv, mCurrentState->mShaderID, GL_COMPILE_STATUS, &compiled);
- if (!compiled) {
- GLint infoLen = 0;
- RSD_CALL_GL(glGetShaderiv, mCurrentState->mShaderID, GL_INFO_LOG_LENGTH, &infoLen);
- if (infoLen) {
- char* buf = (char*) malloc(infoLen);
- if (buf) {
- RSD_CALL_GL(glGetShaderInfoLog, mCurrentState->mShaderID, infoLen, NULL, buf);
- rsc->setError(RS_ERROR_FATAL_PROGRAM_LINK, buf);
- free(buf);
- }
- RSD_CALL_GL(glDeleteShader, mCurrentState->mShaderID);
- mCurrentState->mShaderID = 0;
- return false;
- }
- }
- }
-
- if (rsc->props.mLogShaders) {
- ALOGV("--Shader load result %x ", glGetError());
- }
- mIsValid = true;
- return true;
-}
-
-void RsdShader::appendUserConstants() {
- for (uint32_t ct=0; ct < mRSProgram->mHal.state.constantsCount; ct++) {
- const Element *e = mRSProgram->mHal.state.constantTypes[ct]->getElement();
- for (uint32_t field=0; field < e->mHal.state.fieldsCount; field++) {
- const Element *f = e->mHal.state.fields[field];
- const char *fn = e->mHal.state.fieldNames[field];
-
- // Cannot be complex
- rsAssert(!f->mHal.state.fieldsCount);
- if (f->mHal.state.dataType == RS_TYPE_MATRIX_4X4) {
- mShader.append("uniform mat4 UNI_");
- } else if (f->mHal.state.dataType == RS_TYPE_MATRIX_3X3) {
- mShader.append("uniform mat3 UNI_");
- } else if (f->mHal.state.dataType == RS_TYPE_MATRIX_2X2) {
- mShader.append("uniform mat2 UNI_");
- } else {
- switch (f->mHal.state.vectorSize) {
- case 1: mShader.append("uniform float UNI_"); break;
- case 2: mShader.append("uniform vec2 UNI_"); break;
- case 3: mShader.append("uniform vec3 UNI_"); break;
- case 4: mShader.append("uniform vec4 UNI_"); break;
- default:
- rsAssert(0);
- }
- }
-
- mShader.append(fn);
- if (e->mHal.state.fieldArraySizes[field] > 1) {
- mShader.appendFormat("[%d]", e->mHal.state.fieldArraySizes[field]);
- }
- mShader.append(";\n");
- }
- }
-}
-
-void RsdShader::logUniform(const Element *field, const float *fd, uint32_t arraySize ) {
- RsDataType dataType = field->mHal.state.dataType;
- uint32_t elementSize = field->mHal.state.elementSizeBytes / sizeof(float);
- for (uint32_t i = 0; i < arraySize; i ++) {
- if (arraySize > 1) {
- ALOGV("Array Element [%u]", i);
- }
- if (dataType == RS_TYPE_MATRIX_4X4) {
- ALOGV("Matrix4x4");
- ALOGV("{%f, %f, %f, %f", fd[0], fd[4], fd[8], fd[12]);
- ALOGV(" %f, %f, %f, %f", fd[1], fd[5], fd[9], fd[13]);
- ALOGV(" %f, %f, %f, %f", fd[2], fd[6], fd[10], fd[14]);
- ALOGV(" %f, %f, %f, %f}", fd[3], fd[7], fd[11], fd[15]);
- } else if (dataType == RS_TYPE_MATRIX_3X3) {
- ALOGV("Matrix3x3");
- ALOGV("{%f, %f, %f", fd[0], fd[3], fd[6]);
- ALOGV(" %f, %f, %f", fd[1], fd[4], fd[7]);
- ALOGV(" %f, %f, %f}", fd[2], fd[5], fd[8]);
- } else if (dataType == RS_TYPE_MATRIX_2X2) {
- ALOGV("Matrix2x2");
- ALOGV("{%f, %f", fd[0], fd[2]);
- ALOGV(" %f, %f}", fd[1], fd[3]);
- } else {
- switch (field->mHal.state.vectorSize) {
- case 1:
- ALOGV("Uniform 1 = %f", fd[0]);
- break;
- case 2:
- ALOGV("Uniform 2 = %f %f", fd[0], fd[1]);
- break;
- case 3:
- ALOGV("Uniform 3 = %f %f %f", fd[0], fd[1], fd[2]);
- break;
- case 4:
- ALOGV("Uniform 4 = %f %f %f %f", fd[0], fd[1], fd[2], fd[3]);
- break;
- default:
- rsAssert(0);
- }
- }
- ALOGE("Element size %u data=%p", elementSize, fd);
- fd += elementSize;
- ALOGE("New data=%p", fd);
- }
-}
-
-void RsdShader::setUniform(const Context *rsc, const Element *field, const float *fd,
- int32_t slot, uint32_t arraySize ) {
- RsDataType dataType = field->mHal.state.dataType;
- if (dataType == RS_TYPE_MATRIX_4X4) {
- RSD_CALL_GL(glUniformMatrix4fv, slot, arraySize, GL_FALSE, fd);
- } else if (dataType == RS_TYPE_MATRIX_3X3) {
- RSD_CALL_GL(glUniformMatrix3fv, slot, arraySize, GL_FALSE, fd);
- } else if (dataType == RS_TYPE_MATRIX_2X2) {
- RSD_CALL_GL(glUniformMatrix2fv, slot, arraySize, GL_FALSE, fd);
- } else {
- switch (field->mHal.state.vectorSize) {
- case 1:
- RSD_CALL_GL(glUniform1fv, slot, arraySize, fd);
- break;
- case 2:
- RSD_CALL_GL(glUniform2fv, slot, arraySize, fd);
- break;
- case 3:
- RSD_CALL_GL(glUniform3fv, slot, arraySize, fd);
- break;
- case 4:
- RSD_CALL_GL(glUniform4fv, slot, arraySize, fd);
- break;
- default:
- rsAssert(0);
- }
- }
-}
-
-void RsdShader::setupSampler(const Context *rsc, const Sampler *s, const Allocation *tex) {
- RsdHal *dc = (RsdHal *)rsc->mHal.drv;
-
- GLenum trans[] = {
- GL_NEAREST, //RS_SAMPLER_NEAREST,
- GL_LINEAR, //RS_SAMPLER_LINEAR,
- GL_LINEAR_MIPMAP_LINEAR, //RS_SAMPLER_LINEAR_MIP_LINEAR,
- GL_REPEAT, //RS_SAMPLER_WRAP,
- GL_CLAMP_TO_EDGE, //RS_SAMPLER_CLAMP
- GL_LINEAR_MIPMAP_NEAREST, //RS_SAMPLER_LINEAR_MIP_NEAREST
- };
-
- GLenum transNP[] = {
- GL_NEAREST, //RS_SAMPLER_NEAREST,
- GL_LINEAR, //RS_SAMPLER_LINEAR,
- GL_LINEAR, //RS_SAMPLER_LINEAR_MIP_LINEAR,
- GL_CLAMP_TO_EDGE, //RS_SAMPLER_WRAP,
- GL_CLAMP_TO_EDGE, //RS_SAMPLER_CLAMP
- GL_LINEAR, //RS_SAMPLER_LINEAR_MIP_NEAREST,
- };
-
- // This tells us the correct texture type
- DrvAllocation *drvTex = (DrvAllocation *)tex->mHal.drv;
- const GLenum target = drvTex->glTarget;
-
- if (!dc->gl.gl.OES_texture_npot && tex->getType()->getIsNp2()) {
- if (tex->getHasGraphicsMipmaps() &&
- (dc->gl.gl.NV_texture_npot_2D_mipmap || dc->gl.gl.IMG_texture_npot)) {
- if (dc->gl.gl.NV_texture_npot_2D_mipmap) {
- RSD_CALL_GL(glTexParameteri, target, GL_TEXTURE_MIN_FILTER,
- trans[s->mHal.state.minFilter]);
- } else {
- switch (trans[s->mHal.state.minFilter]) {
- case GL_LINEAR_MIPMAP_LINEAR:
- RSD_CALL_GL(glTexParameteri, target, GL_TEXTURE_MIN_FILTER,
- GL_LINEAR_MIPMAP_NEAREST);
- break;
- default:
- RSD_CALL_GL(glTexParameteri, target, GL_TEXTURE_MIN_FILTER,
- trans[s->mHal.state.minFilter]);
- break;
- }
- }
- } else {
- RSD_CALL_GL(glTexParameteri, target, GL_TEXTURE_MIN_FILTER,
- transNP[s->mHal.state.minFilter]);
- }
- RSD_CALL_GL(glTexParameteri, target, GL_TEXTURE_MAG_FILTER,
- transNP[s->mHal.state.magFilter]);
- RSD_CALL_GL(glTexParameteri, target, GL_TEXTURE_WRAP_S, transNP[s->mHal.state.wrapS]);
- RSD_CALL_GL(glTexParameteri, target, GL_TEXTURE_WRAP_T, transNP[s->mHal.state.wrapT]);
- } else {
- if (tex->getHasGraphicsMipmaps()) {
- RSD_CALL_GL(glTexParameteri, target, GL_TEXTURE_MIN_FILTER,
- trans[s->mHal.state.minFilter]);
- } else {
- RSD_CALL_GL(glTexParameteri, target, GL_TEXTURE_MIN_FILTER,
- transNP[s->mHal.state.minFilter]);
- }
- RSD_CALL_GL(glTexParameteri, target, GL_TEXTURE_MAG_FILTER, trans[s->mHal.state.magFilter]);
- RSD_CALL_GL(glTexParameteri, target, GL_TEXTURE_WRAP_S, trans[s->mHal.state.wrapS]);
- RSD_CALL_GL(glTexParameteri, target, GL_TEXTURE_WRAP_T, trans[s->mHal.state.wrapT]);
- }
-
- float anisoValue = rsMin(dc->gl.gl.EXT_texture_max_aniso, s->mHal.state.aniso);
- if (dc->gl.gl.EXT_texture_max_aniso > 1.0f) {
- RSD_CALL_GL(glTexParameterf, target, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisoValue);
- }
-
- rsdGLCheckError(rsc, "Sampler::setup tex env");
-}
-
-void RsdShader::setupTextures(const Context *rsc, RsdShaderCache *sc) {
- if (mRSProgram->mHal.state.texturesCount == 0) {
- return;
- }
-
- RsdHal *dc = (RsdHal *)rsc->mHal.drv;
-
- uint32_t numTexturesToBind = mRSProgram->mHal.state.texturesCount;
- uint32_t numTexturesAvailable = dc->gl.gl.maxFragmentTextureImageUnits;
- if (numTexturesToBind >= numTexturesAvailable) {
- ALOGE("Attempting to bind %u textures on shader id %u, but only %u are available",
- mRSProgram->mHal.state.texturesCount, (uint32_t)this, numTexturesAvailable);
- rsc->setError(RS_ERROR_BAD_SHADER, "Cannot bind more textuers than available");
- numTexturesToBind = numTexturesAvailable;
- }
-
- for (uint32_t ct=0; ct < numTexturesToBind; ct++) {
- RSD_CALL_GL(glActiveTexture, GL_TEXTURE0 + ct);
- RSD_CALL_GL(glUniform1i, sc->fragUniformSlot(mTextureUniformIndexStart + ct), ct);
-
- if (!mRSProgram->mHal.state.textures[ct]) {
- // if nothing is bound, reset to default GL texture
- RSD_CALL_GL(glBindTexture, mCurrentState->mTextureTargets[ct], 0);
- continue;
- }
-
- DrvAllocation *drvTex = (DrvAllocation *)mRSProgram->mHal.state.textures[ct]->mHal.drv;
- if (drvTex->glTarget != GL_TEXTURE_2D &&
- drvTex->glTarget != GL_TEXTURE_CUBE_MAP &&
- drvTex->glTarget != GL_TEXTURE_EXTERNAL_OES) {
- ALOGE("Attempting to bind unknown texture to shader id %u, texture unit %u",
- (uint)this, ct);
- rsc->setError(RS_ERROR_BAD_SHADER, "Non-texture allocation bound to a shader");
- }
- RSD_CALL_GL(glBindTexture, drvTex->glTarget, drvTex->textureID);
- rsdGLCheckError(rsc, "ProgramFragment::setup tex bind");
- if (mRSProgram->mHal.state.samplers[ct]) {
- setupSampler(rsc, mRSProgram->mHal.state.samplers[ct],
- mRSProgram->mHal.state.textures[ct]);
- } else {
- RSD_CALL_GL(glTexParameteri, drvTex->glTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- RSD_CALL_GL(glTexParameteri, drvTex->glTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- RSD_CALL_GL(glTexParameteri, drvTex->glTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- RSD_CALL_GL(glTexParameteri, drvTex->glTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- rsdGLCheckError(rsc, "ProgramFragment::setup tex env");
- }
- rsdGLCheckError(rsc, "ProgramFragment::setup uniforms");
- }
-
- RSD_CALL_GL(glActiveTexture, GL_TEXTURE0);
- mDirty = false;
- rsdGLCheckError(rsc, "ProgramFragment::setup");
-}
-
-void RsdShader::setupUserConstants(const Context *rsc, RsdShaderCache *sc, bool isFragment) {
- uint32_t uidx = 0;
- for (uint32_t ct=0; ct < mRSProgram->mHal.state.constantsCount; ct++) {
- Allocation *alloc = mRSProgram->mHal.state.constants[ct];
- if (!alloc) {
- ALOGE("Attempting to set constants on shader id %u, but alloc at slot %u is not set",
- (uint32_t)this, ct);
- rsc->setError(RS_ERROR_BAD_SHADER, "No constant allocation bound");
- continue;
- }
-
- const uint8_t *data = static_cast<const uint8_t *>(alloc->getPtr());
- const Element *e = mRSProgram->mHal.state.constantTypes[ct]->getElement();
- for (uint32_t field=0; field < e->mHal.state.fieldsCount; field++) {
- const Element *f = e->mHal.state.fields[field];
- const char *fieldName = e->mHal.state.fieldNames[field];
-
- uint32_t offset = e->mHal.state.fieldOffsetBytes[field];
- const float *fd = reinterpret_cast<const float *>(&data[offset]);
-
- int32_t slot = -1;
- uint32_t arraySize = 1;
- if (!isFragment) {
- slot = sc->vtxUniformSlot(uidx);
- arraySize = sc->vtxUniformSize(uidx);
- } else {
- slot = sc->fragUniformSlot(uidx);
- arraySize = sc->fragUniformSize(uidx);
- }
- if (rsc->props.mLogShadersUniforms) {
- ALOGV("Uniform slot=%i, offset=%i, constant=%i, field=%i, uidx=%i, name=%s",
- slot, offset, ct, field, uidx, fieldName);
- }
- uidx ++;
- if (slot < 0) {
- continue;
- }
-
- if (rsc->props.mLogShadersUniforms) {
- logUniform(f, fd, arraySize);
- }
- setUniform(rsc, f, fd, slot, arraySize);
- }
- }
-}
-
-void RsdShader::setup(const android::renderscript::Context *rsc, RsdShaderCache *sc) {
-
- setupUserConstants(rsc, sc, mType == GL_FRAGMENT_SHADER);
- setupTextures(rsc, sc);
-}
-
-void RsdShader::initAttribAndUniformArray() {
- mAttribCount = 0;
- for (uint32_t ct=0; ct < mRSProgram->mHal.state.inputElementsCount; ct++) {
- const Element *elem = mRSProgram->mHal.state.inputElements[ct];
- mAttribCount += elem->mHal.state.fieldsCount;
- }
-
- mUniformCount = 0;
- for (uint32_t ct=0; ct < mRSProgram->mHal.state.constantsCount; ct++) {
- const Element *elem = mRSProgram->mHal.state.constantTypes[ct]->getElement();
- mUniformCount += elem->mHal.state.fieldsCount;
- }
- mUniformCount += mRSProgram->mHal.state.texturesCount;
-
- if (mAttribCount) {
- mAttribNames = new String8[mAttribCount];
- }
- if (mUniformCount) {
- mUniformNames = new String8[mUniformCount];
- mUniformArraySizes = new uint32_t[mUniformCount];
- }
-
- mTextureCount = mRSProgram->mHal.state.texturesCount;
-}
-
-void RsdShader::initAddUserElement(const Element *e, String8 *names, uint32_t *arrayLengths,
- uint32_t *count, const char *prefix) {
- rsAssert(e->mHal.state.fieldsCount);
- for (uint32_t ct=0; ct < e->mHal.state.fieldsCount; ct++) {
- const Element *ce = e->mHal.state.fields[ct];
- if (ce->mHal.state.fieldsCount) {
- initAddUserElement(ce, names, arrayLengths, count, prefix);
- } else {
- String8 tmp(prefix);
- tmp.append(e->mHal.state.fieldNames[ct]);
- names[*count].setTo(tmp.string());
- if (arrayLengths) {
- arrayLengths[*count] = e->mHal.state.fieldArraySizes[ct];
- }
- (*count)++;
- }
- }
-}
diff --git a/libs/rs/driver/rsdShader.h b/libs/rs/driver/rsdShader.h
deleted file mode 100644
index 2680b3e..0000000
--- a/libs/rs/driver/rsdShader.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (C) 2011-2012 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.
- */
-
-#ifndef ANDROID_RSD_SHADER_H
-#define ANDROID_RSD_SHADER_H
-
-#include <utils/String8.h>
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-class Element;
-class Context;
-class Program;
-
-}
-}
-
-class RsdShaderCache;
-
-#define RS_SHADER_ATTR "ATTRIB_"
-#define RS_SHADER_UNI "UNI_"
-
-class RsdShader {
-public:
-
- RsdShader(const android::renderscript::Program *p, uint32_t type,
- const char * shaderText, uint32_t shaderLength,
- const char** textureNames, size_t textureNamesCount,
- const size_t *textureNamesLength);
- virtual ~RsdShader();
-
- uint32_t getStateBasedShaderID(const android::renderscript::Context *);
-
- // Add ability to get all ID's to clean up the cached program objects
- uint32_t getStateBasedIDCount() const { return mStateBasedShaders.size(); }
- uint32_t getStateBasedID(uint32_t index) const {
- return mStateBasedShaders.itemAt(index)->mShaderID;
- }
-
- uint32_t getAttribCount() const {return mAttribCount;}
- uint32_t getUniformCount() const {return mUniformCount;}
- const android::String8 & getAttribName(uint32_t i) const {return mAttribNames[i];}
- const android::String8 & getUniformName(uint32_t i) const {return mUniformNames[i];}
- uint32_t getUniformArraySize(uint32_t i) const {return mUniformArraySizes[i];}
-
- android::String8 getGLSLInputString() const;
-
- bool isValid() const {return mIsValid;}
- void forceDirty() const {mDirty = true;}
-
- bool loadShader(const android::renderscript::Context *);
- void setup(const android::renderscript::Context *, RsdShaderCache *sc);
-
-protected:
-
- class StateBasedKey {
- public:
- StateBasedKey(uint32_t texCount) : mShaderID(0) {
- mTextureTargets = new uint32_t[texCount];
- }
- ~StateBasedKey() {
- delete[] mTextureTargets;
- }
- uint32_t mShaderID;
- uint32_t *mTextureTargets;
- };
-
- bool createShader();
- StateBasedKey *getExistingState();
-
- const android::renderscript::Program *mRSProgram;
- bool mIsValid;
-
- // Applies to vertex and fragment shaders only
- void appendUserConstants();
- void setupUserConstants(const android::renderscript::Context *rsc,
- RsdShaderCache *sc, bool isFragment);
- void initAddUserElement(const android::renderscript::Element *e,
- android::String8 *names, uint32_t *arrayLengths,
- uint32_t *count, const char *prefix);
- void setupTextures(const android::renderscript::Context *rsc, RsdShaderCache *sc);
- void setupSampler(const android::renderscript::Context *rsc,
- const android::renderscript::Sampler *s,
- const android::renderscript::Allocation *tex);
-
- void appendAttributes();
- void appendTextures();
-
- void initAttribAndUniformArray();
-
- mutable bool mDirty;
- android::String8 mShader;
- android::String8 mUserShader;
- uint32_t mType;
-
- uint32_t mTextureCount;
- StateBasedKey *mCurrentState;
- uint32_t mAttribCount;
- uint32_t mUniformCount;
- android::String8 *mAttribNames;
- android::String8 *mUniformNames;
- uint32_t *mUniformArraySizes;
-
- android::Vector<android::String8> mTextureNames;
-
- android::Vector<StateBasedKey*> mStateBasedShaders;
-
- int32_t mTextureUniformIndexStart;
-
- void logUniform(const android::renderscript::Element *field,
- const float *fd, uint32_t arraySize);
- void setUniform(const android::renderscript::Context *rsc,
- const android::renderscript::Element *field,
- const float *fd, int32_t slot, uint32_t arraySize );
- void initMemberVars();
- void init(const char** textureNames, size_t textureNamesCount,
- const size_t *textureNamesLength);
-};
-
-#endif //ANDROID_RSD_SHADER_H
-
-
-
-
diff --git a/libs/rs/driver/rsdShaderCache.cpp b/libs/rs/driver/rsdShaderCache.cpp
deleted file mode 100644
index 69b43fc..0000000
--- a/libs/rs/driver/rsdShaderCache.cpp
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * Copyright (C) 2011-2012 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.
- */
-
-#include <rs_hal.h>
-#include <rsContext.h>
-
-#include "rsdShader.h"
-#include "rsdShaderCache.h"
-#include "rsdGL.h"
-
-#include <GLES/gl.h>
-#include <GLES2/gl2.h>
-
-using namespace android;
-using namespace android::renderscript;
-
-
-RsdShaderCache::RsdShaderCache() {
- mEntries.setCapacity(16);
- mVertexDirty = true;
- mFragmentDirty = true;
-}
-
-RsdShaderCache::~RsdShaderCache() {
- cleanupAll();
-}
-
-void RsdShaderCache::updateUniformArrayData(const Context *rsc, RsdShader *prog, uint32_t linkedID,
- UniformData *data, const char* logTag,
- UniformQueryData **uniformList, uint32_t uniListSize) {
-
- for (uint32_t ct=0; ct < prog->getUniformCount(); ct++) {
- if (data[ct].slot >= 0 && data[ct].arraySize > 1) {
- //Iterate over the list of active GL uniforms and find highest array index
- for (uint32_t ui = 0; ui < uniListSize; ui ++) {
- if (prog->getUniformName(ct) == uniformList[ui]->name) {
- data[ct].arraySize = (uint32_t)uniformList[ui]->arraySize;
- break;
- }
- }
- }
-
- if (rsc->props.mLogShaders) {
- ALOGV("%s U, %s = %d, arraySize = %d\n", logTag,
- prog->getUniformName(ct).string(), data[ct].slot, data[ct].arraySize);
- }
- }
-}
-
-void RsdShaderCache::populateUniformData(RsdShader *prog, uint32_t linkedID, UniformData *data) {
- for (uint32_t ct=0; ct < prog->getUniformCount(); ct++) {
- data[ct].slot = glGetUniformLocation(linkedID, prog->getUniformName(ct));
- data[ct].arraySize = prog->getUniformArraySize(ct);
- }
-}
-
-bool RsdShaderCache::hasArrayUniforms(RsdShader *vtx, RsdShader *frag) {
- UniformData *data = mCurrent->vtxUniforms;
- for (uint32_t ct=0; ct < vtx->getUniformCount(); ct++) {
- if (data[ct].slot >= 0 && data[ct].arraySize > 1) {
- return true;
- }
- }
- data = mCurrent->fragUniforms;
- for (uint32_t ct=0; ct < frag->getUniformCount(); ct++) {
- if (data[ct].slot >= 0 && data[ct].arraySize > 1) {
- return true;
- }
- }
- return false;
-}
-
-bool RsdShaderCache::setup(const Context *rsc) {
- if (!mVertexDirty && !mFragmentDirty) {
- return true;
- }
-
- if (!link(rsc)) {
- return false;
- }
-
- if (mFragmentDirty) {
- mFragment->setup(rsc, this);
- mFragmentDirty = false;
- }
- if (mVertexDirty) {
- mVertex->setup(rsc, this);
- mVertexDirty = false;
- }
-
- return true;
-}
-
-bool RsdShaderCache::link(const Context *rsc) {
-
- RsdShader *vtx = mVertex;
- RsdShader *frag = mFragment;
-
- uint32_t vID = vtx->getStateBasedShaderID(rsc);
- uint32_t fID = frag->getStateBasedShaderID(rsc);
-
- // Don't try to cache if shaders failed to load
- if (!vID || !fID) {
- return false;
- }
- uint32_t entryCount = mEntries.size();
- for (uint32_t ct = 0; ct < entryCount; ct ++) {
- if ((mEntries[ct]->vtx == vID) && (mEntries[ct]->frag == fID)) {
-
- //ALOGV("SC using program %i", mEntries[ct]->program);
- glUseProgram(mEntries[ct]->program);
- mCurrent = mEntries[ct];
- //ALOGV("RsdShaderCache hit, using %i", ct);
- rsdGLCheckError(rsc, "RsdShaderCache::link (hit)");
- return true;
- }
- }
-
- ProgramEntry *e = new ProgramEntry(vtx->getAttribCount(),
- vtx->getUniformCount(),
- frag->getUniformCount());
- mEntries.push(e);
- mCurrent = e;
- e->vtx = vID;
- e->frag = fID;
- e->program = glCreateProgram();
- if (e->program) {
- GLuint pgm = e->program;
- glAttachShader(pgm, vID);
- //ALOGE("e1 %x", glGetError());
- glAttachShader(pgm, fID);
-
- glBindAttribLocation(pgm, 0, "ATTRIB_position");
- glBindAttribLocation(pgm, 1, "ATTRIB_color");
- glBindAttribLocation(pgm, 2, "ATTRIB_normal");
- glBindAttribLocation(pgm, 3, "ATTRIB_texture0");
-
- //ALOGE("e2 %x", glGetError());
- glLinkProgram(pgm);
- //ALOGE("e3 %x", glGetError());
- GLint linkStatus = GL_FALSE;
- glGetProgramiv(pgm, GL_LINK_STATUS, &linkStatus);
- if (linkStatus != GL_TRUE) {
- GLint bufLength = 0;
- glGetProgramiv(pgm, GL_INFO_LOG_LENGTH, &bufLength);
- if (bufLength) {
- char* buf = (char*) malloc(bufLength);
- if (buf) {
- glGetProgramInfoLog(pgm, bufLength, NULL, buf);
- rsc->setError(RS_ERROR_FATAL_PROGRAM_LINK, buf);
- free(buf);
- }
- }
- glDeleteProgram(pgm);
- return false;
- }
-
- for (uint32_t ct=0; ct < e->vtxAttrCount; ct++) {
- e->vtxAttrs[ct].slot = glGetAttribLocation(pgm, vtx->getAttribName(ct));
- e->vtxAttrs[ct].name = vtx->getAttribName(ct).string();
- if (rsc->props.mLogShaders) {
- ALOGV("vtx A %i, %s = %d\n", ct, vtx->getAttribName(ct).string(), e->vtxAttrs[ct].slot);
- }
- }
-
- populateUniformData(vtx, pgm, e->vtxUniforms);
- populateUniformData(frag, pgm, e->fragUniforms);
-
- // Only populate this list if we have arrays in our uniforms
- UniformQueryData **uniformList = NULL;
- GLint numUniforms = 0;
- bool hasArrays = hasArrayUniforms(vtx, frag);
- if (hasArrays) {
- // Get the number of active uniforms and the length of the longest name
- glGetProgramiv(pgm, GL_ACTIVE_UNIFORMS, &numUniforms);
- GLint maxNameLength = 0;
- glGetProgramiv(pgm, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxNameLength);
- if (numUniforms > 0 && maxNameLength > 0) {
- uniformList = new UniformQueryData*[numUniforms];
- // Iterate over all the uniforms and build the list we
- // can later use to match our uniforms to
- for (uint32_t ct = 0; ct < (uint32_t)numUniforms; ct++) {
- uniformList[ct] = new UniformQueryData(maxNameLength);
- glGetActiveUniform(pgm, ct, maxNameLength, &uniformList[ct]->writtenLength,
- &uniformList[ct]->arraySize, &uniformList[ct]->type,
- uniformList[ct]->name);
- //ALOGE("GL UNI idx=%u, arraySize=%u, name=%s", ct,
- // uniformList[ct]->arraySize, uniformList[ct]->name);
- }
- }
- }
-
- // We now know the highest index of all of the array uniforms
- // and we need to update our cache to reflect that
- // we may have declared [n], but only m < n elements are used
- updateUniformArrayData(rsc, vtx, pgm, e->vtxUniforms, "vtx",
- uniformList, (uint32_t)numUniforms);
- updateUniformArrayData(rsc, frag, pgm, e->fragUniforms, "frag",
- uniformList, (uint32_t)numUniforms);
-
- // Clean up the uniform data from GL
- if (uniformList != NULL) {
- for (uint32_t ct = 0; ct < (uint32_t)numUniforms; ct++) {
- delete uniformList[ct];
- }
- delete[] uniformList;
- uniformList = NULL;
- }
- }
-
- //ALOGV("SC made program %i", e->program);
- glUseProgram(e->program);
- rsdGLCheckError(rsc, "RsdShaderCache::link (miss)");
-
- return true;
-}
-
-int32_t RsdShaderCache::vtxAttribSlot(const String8 &attrName) const {
- for (uint32_t ct=0; ct < mCurrent->vtxAttrCount; ct++) {
- if (attrName == mCurrent->vtxAttrs[ct].name) {
- return mCurrent->vtxAttrs[ct].slot;
- }
- }
- return -1;
-}
-
-void RsdShaderCache::cleanupVertex(RsdShader *s) {
- int32_t numEntries = (int32_t)mEntries.size();
- uint32_t numShaderIDs = s->getStateBasedIDCount();
- for (uint32_t sId = 0; sId < numShaderIDs; sId ++) {
- uint32_t id = s->getStateBasedID(sId);
- for (int32_t ct = 0; ct < numEntries; ct ++) {
- if (mEntries[ct]->vtx == id) {
- glDeleteProgram(mEntries[ct]->program);
-
- delete mEntries[ct];
- mEntries.removeAt(ct);
- numEntries = (int32_t)mEntries.size();
- ct --;
- }
- }
- }
-}
-
-void RsdShaderCache::cleanupFragment(RsdShader *s) {
- int32_t numEntries = (int32_t)mEntries.size();
- uint32_t numShaderIDs = s->getStateBasedIDCount();
- for (uint32_t sId = 0; sId < numShaderIDs; sId ++) {
- uint32_t id = s->getStateBasedID(sId);
- for (int32_t ct = 0; ct < numEntries; ct ++) {
- if (mEntries[ct]->frag == id) {
- glDeleteProgram(mEntries[ct]->program);
-
- delete mEntries[ct];
- mEntries.removeAt(ct);
- numEntries = (int32_t)mEntries.size();
- ct --;
- }
- }
- }
-}
-
-void RsdShaderCache::cleanupAll() {
- for (uint32_t ct=0; ct < mEntries.size(); ct++) {
- glDeleteProgram(mEntries[ct]->program);
- free(mEntries[ct]);
- }
- mEntries.clear();
-}
-
diff --git a/libs/rs/driver/rsdShaderCache.h b/libs/rs/driver/rsdShaderCache.h
deleted file mode 100644
index 88aa32d..0000000
--- a/libs/rs/driver/rsdShaderCache.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright (C) 2011-2012 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.
- */
-
-#ifndef ANDROID_RSD_SHADER_CACHE_H
-#define ANDROID_RSD_SHADER_CACHE_H
-
-namespace android {
-namespace renderscript {
-
-class Context;
-
-}
-}
-
-#include <utils/String8.h>
-#include <utils/Vector.h>
-class RsdShader;
-
-// ---------------------------------------------------------------------------
-
-// An element is a group of Components that occupies one cell in a structure.
-class RsdShaderCache {
-public:
- RsdShaderCache();
- virtual ~RsdShaderCache();
-
- void setActiveVertex(RsdShader *pv) {
- mVertexDirty = true;
- mVertex = pv;
- }
-
- void setActiveFragment(RsdShader *pf) {
- mFragmentDirty = true;
- mFragment = pf;
- }
-
- bool setup(const android::renderscript::Context *rsc);
-
- void cleanupVertex(RsdShader *s);
- void cleanupFragment(RsdShader *s);
-
- void cleanupAll();
-
- int32_t vtxAttribSlot(const android::String8 &attrName) const;
- int32_t vtxUniformSlot(uint32_t a) const {return mCurrent->vtxUniforms[a].slot;}
- uint32_t vtxUniformSize(uint32_t a) const {return mCurrent->vtxUniforms[a].arraySize;}
- int32_t fragUniformSlot(uint32_t a) const {return mCurrent->fragUniforms[a].slot;}
- uint32_t fragUniformSize(uint32_t a) const {return mCurrent->fragUniforms[a].arraySize;}
-
-protected:
- bool link(const android::renderscript::Context *rsc);
- bool mFragmentDirty;
- bool mVertexDirty;
- RsdShader *mVertex;
- RsdShader *mFragment;
-
- struct UniformQueryData {
- char *name;
- uint32_t nameLength;
- int32_t writtenLength;
- int32_t arraySize;
- uint32_t type;
- UniformQueryData(uint32_t maxName) {
- name = NULL;
- nameLength = maxName;
- if (nameLength > 0 ) {
- name = new char[nameLength];
- }
- }
- ~UniformQueryData() {
- if (name != NULL) {
- delete[] name;
- name = NULL;
- }
- }
- };
- struct UniformData {
- int32_t slot;
- uint32_t arraySize;
- };
- struct AttrData {
- int32_t slot;
- const char* name;
- };
- struct ProgramEntry {
- ProgramEntry(uint32_t numVtxAttr, uint32_t numVtxUnis,
- uint32_t numFragUnis) : vtx(0), frag(0), program(0), vtxAttrCount(0),
- vtxAttrs(0), vtxUniforms(0), fragUniforms(0),
- fragUniformIsSTO(0) {
- vtxAttrCount = numVtxAttr;
- if (numVtxAttr) {
- vtxAttrs = new AttrData[numVtxAttr];
- }
- if (numVtxUnis) {
- vtxUniforms = new UniformData[numVtxUnis];
- }
- if (numFragUnis) {
- fragUniforms = new UniformData[numFragUnis];
- fragUniformIsSTO = new bool[numFragUnis];
- }
- }
- ~ProgramEntry() {
- if (vtxAttrs) {
- delete[] vtxAttrs;
- vtxAttrs = NULL;
- }
- if (vtxUniforms) {
- delete[] vtxUniforms;
- vtxUniforms = NULL;
- }
- if (fragUniforms) {
- delete[] fragUniforms;
- fragUniforms = NULL;
- }
- if (fragUniformIsSTO) {
- delete[] fragUniformIsSTO;
- fragUniformIsSTO = NULL;
- }
- }
- uint32_t vtx;
- uint32_t frag;
- uint32_t program;
- uint32_t vtxAttrCount;
- AttrData *vtxAttrs;
- UniformData *vtxUniforms;
- UniformData *fragUniforms;
- bool *fragUniformIsSTO;
- };
- android::Vector<ProgramEntry*> mEntries;
- ProgramEntry *mCurrent;
-
- bool hasArrayUniforms(RsdShader *vtx, RsdShader *frag);
- void populateUniformData(RsdShader *prog, uint32_t linkedID, UniformData *data);
- void updateUniformArrayData(const android::renderscript::Context *rsc,
- RsdShader *prog, uint32_t linkedID,
- UniformData *data, const char* logTag,
- UniformQueryData **uniformList, uint32_t uniListSize);
-};
-
-
-#endif //ANDROID_RSD_SHADER_CACHE_H
-
-
-
-
diff --git a/libs/rs/driver/rsdVertexArray.cpp b/libs/rs/driver/rsdVertexArray.cpp
deleted file mode 100644
index 1836e67..0000000
--- a/libs/rs/driver/rsdVertexArray.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#include <rs_hal.h>
-#include <rsContext.h>
-
-#include <GLES/gl.h>
-#include <GLES2/gl2.h>
-
-#include "rsdGL.h"
-#include "rsdCore.h"
-#include "rsdVertexArray.h"
-#include "rsdShaderCache.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-RsdVertexArray::RsdVertexArray(const Attrib *attribs, uint32_t numAttribs) {
- mAttribs = attribs;
- mCount = numAttribs;
-}
-
-RsdVertexArray::~RsdVertexArray() {
-}
-
-RsdVertexArray::Attrib::Attrib() {
- clear();
-}
-
-void RsdVertexArray::Attrib::clear() {
- buffer = 0;
- offset = 0;
- type = 0;
- size = 0;
- stride = 0;
- ptr = NULL;
- normalized = false;
- name.setTo("");
-}
-
-void RsdVertexArray::Attrib::set(uint32_t type, uint32_t size, uint32_t stride,
- bool normalized, uint32_t offset,
- const char *name) {
- clear();
- this->type = type;
- this->size = size;
- this->offset = offset;
- this->normalized = normalized;
- this->stride = stride;
- this->name.setTo(name);
-}
-
-void RsdVertexArray::logAttrib(uint32_t idx, uint32_t slot) const {
- if (idx == 0) {
- ALOGV("Starting vertex attribute binding");
- }
- ALOGV("va %i: slot=%i name=%s buf=%i ptr=%p size=%i type=0x%x stride=0x%x norm=%i offset=0x%x",
- idx, slot,
- mAttribs[idx].name.string(),
- mAttribs[idx].buffer,
- mAttribs[idx].ptr,
- mAttribs[idx].size,
- mAttribs[idx].type,
- mAttribs[idx].stride,
- mAttribs[idx].normalized,
- mAttribs[idx].offset);
-}
-
-void RsdVertexArray::setup(const Context *rsc) const {
-
- RsdHal *dc = (RsdHal *)rsc->mHal.drv;
- RsdVertexArrayState *state = dc->gl.vertexArrayState;
- RsdShaderCache *sc = dc->gl.shaderCache;
-
- rsdGLCheckError(rsc, "RsdVertexArray::setup start");
- uint32_t maxAttrs = state->mAttrsEnabledSize;
-
- for (uint32_t ct=1; ct < maxAttrs; ct++) {
- if(state->mAttrsEnabled[ct]) {
- glDisableVertexAttribArray(ct);
- state->mAttrsEnabled[ct] = false;
- }
- }
-
- rsdGLCheckError(rsc, "RsdVertexArray::setup disabled");
- for (uint32_t ct=0; ct < mCount; ct++) {
- int32_t slot = sc->vtxAttribSlot(mAttribs[ct].name);
- if (rsc->props.mLogShadersAttr) {
- logAttrib(ct, slot);
- }
- if (slot < 0 || slot >= (int32_t)maxAttrs) {
- continue;
- }
- glEnableVertexAttribArray(slot);
- state->mAttrsEnabled[slot] = true;
- glBindBuffer(GL_ARRAY_BUFFER, mAttribs[ct].buffer);
- glVertexAttribPointer(slot,
- mAttribs[ct].size,
- mAttribs[ct].type,
- mAttribs[ct].normalized,
- mAttribs[ct].stride,
- mAttribs[ct].ptr + mAttribs[ct].offset);
- }
- rsdGLCheckError(rsc, "RsdVertexArray::setup done");
-}
-////////////////////////////////////////////
-RsdVertexArrayState::RsdVertexArrayState() {
- mAttrsEnabled = NULL;
- mAttrsEnabledSize = 0;
-}
-
-RsdVertexArrayState::~RsdVertexArrayState() {
- if (mAttrsEnabled) {
- delete[] mAttrsEnabled;
- mAttrsEnabled = NULL;
- }
-}
-void RsdVertexArrayState::init(uint32_t maxAttrs) {
- mAttrsEnabledSize = maxAttrs;
- mAttrsEnabled = new bool[mAttrsEnabledSize];
- for (uint32_t ct = 0; ct < mAttrsEnabledSize; ct++) {
- mAttrsEnabled[ct] = false;
- }
-}
-
diff --git a/libs/rs/driver/rsdVertexArray.h b/libs/rs/driver/rsdVertexArray.h
deleted file mode 100644
index 3e807a3..0000000
--- a/libs/rs/driver/rsdVertexArray.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef ANDROID_RSD_VERTEX_ARRAY_H
-#define ANDROID_RSD_VERTEX_ARRAY_H
-
-namespace android {
-namespace renderscript {
-
-class Context;
-
-}
-}
-
-#include <utils/String8.h>
-
-// An element is a group of Components that occupies one cell in a structure.
-class RsdVertexArray {
-public:
- class Attrib {
- public:
- uint32_t buffer;
- const uint8_t * ptr;
- uint32_t offset;
- uint32_t type;
- uint32_t size;
- uint32_t stride;
- bool normalized;
- android::String8 name;
-
- Attrib();
- void clear();
- void set(uint32_t type, uint32_t size, uint32_t stride, bool normalized, uint32_t offset, const char *name);
- };
-
- RsdVertexArray(const Attrib *attribs, uint32_t numAttribs);
- virtual ~RsdVertexArray();
-
- void setup(const android::renderscript::Context *rsc) const;
- void logAttrib(uint32_t idx, uint32_t slot) const;
-
-protected:
- void clear(uint32_t index);
- uint32_t mActiveBuffer;
- const uint8_t * mActivePointer;
- uint32_t mCount;
-
- const Attrib *mAttribs;
-};
-
-
-class RsdVertexArrayState {
-public:
- RsdVertexArrayState();
- ~RsdVertexArrayState();
- void init(uint32_t maxAttrs);
-
- bool *mAttrsEnabled;
- uint32_t mAttrsEnabledSize;
-};
-
-
-#endif //ANDROID_RSD_VERTEX_ARRAY_H
-
-
-
diff --git a/libs/rs/rs.h b/libs/rs/rs.h
deleted file mode 100644
index 825b9b8..0000000
--- a/libs/rs/rs.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2007 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.
- */
-
-#ifndef RENDER_SCRIPT_H
-#define RENDER_SCRIPT_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include "rsDefines.h"
-
-//
-// A3D loading and object update code.
-// Should only be called at object creation, not thread safe
-RsObjectBase rsaFileA3DGetEntryByIndex(RsContext, uint32_t idx, RsFile);
-RsFile rsaFileA3DCreateFromMemory(RsContext, const void *data, uint32_t len);
-RsFile rsaFileA3DCreateFromAsset(RsContext, void *asset);
-RsFile rsaFileA3DCreateFromFile(RsContext, const char *path);
-void rsaFileA3DGetNumIndexEntries(RsContext, int32_t *numEntries, RsFile);
-void rsaFileA3DGetIndexEntries(RsContext, RsFileIndexEntry *fileEntries,
- uint32_t numEntries, RsFile);
-void rsaGetName(RsContext, void * obj, const char **name);
-// Mesh update functions
-void rsaMeshGetVertexBufferCount(RsContext, RsMesh, int32_t *vtxCount);
-void rsaMeshGetIndexCount(RsContext, RsMesh, int32_t *idxCount);
-void rsaMeshGetVertices(RsContext, RsMesh, RsAllocation *vtxData, uint32_t vtxDataCount);
-void rsaMeshGetIndices(RsContext, RsMesh, RsAllocation *va,
- uint32_t *primType, uint32_t idxDataCount);
-// Allocation update
-const void* rsaAllocationGetType(RsContext con, RsAllocation va);
-// Type update
-void rsaTypeGetNativeData(RsContext, RsType, uint32_t *typeData, uint32_t typeDataSize);
-// Element update
-void rsaElementGetNativeData(RsContext, RsElement, uint32_t *elemData, uint32_t elemDataSize);
-void rsaElementGetSubElements(RsContext, RsElement, uint32_t *ids, const char **names,
- uint32_t *arraySizes, uint32_t dataSize);
-
-RsDevice rsDeviceCreate();
-void rsDeviceDestroy(RsDevice dev);
-void rsDeviceSetConfig(RsDevice dev, RsDeviceParam p, int32_t value);
-RsContext rsContextCreate(RsDevice dev, uint32_t version, uint32_t sdkVersion);
-RsContext rsContextCreateGL(RsDevice dev, uint32_t version, uint32_t sdkVersion,
- RsSurfaceConfig sc, uint32_t dpi);
-
-#include "rsgApiFuncDecl.h"
-
-#endif // RENDER_SCRIPT_H
-
-
-
diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec
deleted file mode 100644
index b373056..0000000
--- a/libs/rs/rs.spec
+++ /dev/null
@@ -1,427 +0,0 @@
-
-ContextDestroy {
- direct
-}
-
-ContextGetMessage {
- direct
- param void *data
- param size_t *receiveLen
- param uint32_t *usrID
- ret RsMessageToClientType
-}
-
-ContextPeekMessage {
- direct
- param size_t *receiveLen
- param uint32_t *usrID
- ret RsMessageToClientType
-}
-
-ContextInitToClient {
- direct
-}
-
-ContextDeinitToClient {
- direct
-}
-
-TypeCreate {
- direct
- param RsElement e
- param uint32_t dimX
- param uint32_t dimY
- param uint32_t dimZ
- param bool mips
- param bool faces
- ret RsType
-}
-
-AllocationCreateTyped {
- direct
- param RsType vtype
- param RsAllocationMipmapControl mips
- param uint32_t usages
- param uint32_t ptr
- ret RsAllocation
-}
-
-AllocationCreateFromBitmap {
- direct
- param RsType vtype
- param RsAllocationMipmapControl mips
- param const void *data
- param uint32_t usages
- ret RsAllocation
-}
-
-AllocationCubeCreateFromBitmap {
- direct
- param RsType vtype
- param RsAllocationMipmapControl mips
- param const void *data
- param uint32_t usages
- ret RsAllocation
-}
-
-AllocationGetSurfaceTextureID {
- param RsAllocation alloc
- ret int32_t
-}
-
-AllocationGetSurfaceTextureID2 {
- param RsAllocation alloc
- param void *st
- sync
-}
-
-AllocationSetSurface {
- param RsAllocation alloc
- param RsNativeWindow sur
- sync
- }
-
-AllocationIoSend {
- param RsAllocation alloc
- }
-
-AllocationIoReceive {
- param RsAllocation alloc
- }
-
-
-ContextFinish {
- sync
- }
-
-ContextBindRootScript {
- param RsScript sampler
- }
-
-ContextBindProgramStore {
- param RsProgramStore pgm
- }
-
-ContextBindProgramFragment {
- param RsProgramFragment pgm
- }
-
-ContextBindProgramVertex {
- param RsProgramVertex pgm
- }
-
-ContextBindProgramRaster {
- param RsProgramRaster pgm
- }
-
-ContextBindFont {
- param RsFont pgm
- }
-
-ContextPause {
- }
-
-ContextResume {
- }
-
-ContextSetSurface {
- param uint32_t width
- param uint32_t height
- param RsNativeWindow sur
- sync
- }
-
-ContextDump {
- param int32_t bits
-}
-
-ContextSetPriority {
- param int32_t priority
- }
-
-ContextDestroyWorker {
- sync
-}
-
-AssignName {
- param RsObjectBase obj
- param const char *name
- }
-
-ObjDestroy {
- param RsAsyncVoidPtr objPtr
- }
-
-ElementCreate {
- direct
- param RsDataType mType
- param RsDataKind mKind
- param bool mNormalized
- param uint32_t mVectorSize
- ret RsElement
- }
-
-ElementCreate2 {
- direct
- param const RsElement * elements
- param const char ** names
- param const uint32_t * arraySize
- ret RsElement
- }
-
-AllocationCopyToBitmap {
- param RsAllocation alloc
- param void * data
- }
-
-
-Allocation1DData {
- param RsAllocation va
- param uint32_t xoff
- param uint32_t lod
- param uint32_t count
- param const void *data
- }
-
-Allocation1DElementData {
- param RsAllocation va
- param uint32_t x
- param uint32_t lod
- param const void *data
- param size_t comp_offset
- }
-
-Allocation2DData {
- param RsAllocation va
- param uint32_t xoff
- param uint32_t yoff
- param uint32_t lod
- param RsAllocationCubemapFace face
- param uint32_t w
- param uint32_t h
- param const void *data
- }
-
-Allocation2DElementData {
- param RsAllocation va
- param uint32_t x
- param uint32_t y
- param uint32_t lod
- param RsAllocationCubemapFace face
- param const void *data
- param size_t element_offset
- }
-
-AllocationGenerateMipmaps {
- param RsAllocation va
-}
-
-AllocationRead {
- param RsAllocation va
- param void * data
- }
-
-AllocationSyncAll {
- param RsAllocation va
- param RsAllocationUsageType src
-}
-
-
-AllocationResize1D {
- param RsAllocation va
- param uint32_t dimX
- }
-
-AllocationResize2D {
- param RsAllocation va
- param uint32_t dimX
- param uint32_t dimY
- }
-
-AllocationCopy2DRange {
- param RsAllocation dest
- param uint32_t destXoff
- param uint32_t destYoff
- param uint32_t destMip
- param uint32_t destFace
- param uint32_t width
- param uint32_t height
- param RsAllocation src
- param uint32_t srcXoff
- param uint32_t srcYoff
- param uint32_t srcMip
- param uint32_t srcFace
- }
-
-SamplerCreate {
- direct
- param RsSamplerValue magFilter
- param RsSamplerValue minFilter
- param RsSamplerValue wrapS
- param RsSamplerValue wrapT
- param RsSamplerValue wrapR
- param float mAniso
- ret RsSampler
-}
-
-ScriptBindAllocation {
- param RsScript vtm
- param RsAllocation va
- param uint32_t slot
- }
-
-ScriptSetTimeZone {
- param RsScript s
- param const char * timeZone
- }
-
-ScriptInvoke {
- param RsScript s
- param uint32_t slot
- }
-
-ScriptInvokeV {
- param RsScript s
- param uint32_t slot
- param const void * data
- }
-
-ScriptForEach {
- param RsScript s
- param uint32_t slot
- param RsAllocation ain
- param RsAllocation aout
- param const void * usr
-}
-
-ScriptSetVarI {
- param RsScript s
- param uint32_t slot
- param int value
- }
-
-ScriptSetVarObj {
- param RsScript s
- param uint32_t slot
- param RsObjectBase value
- }
-
-ScriptSetVarJ {
- param RsScript s
- param uint32_t slot
- param int64_t value
- }
-
-ScriptSetVarF {
- param RsScript s
- param uint32_t slot
- param float value
- }
-
-ScriptSetVarD {
- param RsScript s
- param uint32_t slot
- param double value
- }
-
-ScriptSetVarV {
- param RsScript s
- param uint32_t slot
- param const void * data
- }
-
-
-ScriptCCreate {
- param const char * resName
- param const char * cacheDir
- param const char * text
- ret RsScript
- }
-
-
-ProgramStoreCreate {
- direct
- param bool colorMaskR
- param bool colorMaskG
- param bool colorMaskB
- param bool colorMaskA
- param bool depthMask
- param bool ditherEnable
- param RsBlendSrcFunc srcFunc
- param RsBlendDstFunc destFunc
- param RsDepthFunc depthFunc
- ret RsProgramStore
- }
-
-ProgramRasterCreate {
- direct
- param bool pointSprite
- param RsCullMode cull
- ret RsProgramRaster
-}
-
-ProgramBindConstants {
- param RsProgram vp
- param uint32_t slot
- param RsAllocation constants
- }
-
-
-ProgramBindTexture {
- param RsProgramFragment pf
- param uint32_t slot
- param RsAllocation a
- }
-
-ProgramBindSampler {
- param RsProgramFragment pf
- param uint32_t slot
- param RsSampler s
- }
-
-ProgramFragmentCreate {
- direct
- param const char * shaderText
- param const char ** textureNames
- param const uint32_t * params
- ret RsProgramFragment
- }
-
-ProgramVertexCreate {
- direct
- param const char * shaderText
- param const char ** textureNames
- param const uint32_t * params
- ret RsProgramVertex
- }
-
-FontCreateFromFile {
- param const char *name
- param float fontSize
- param uint32_t dpi
- ret RsFont
- }
-
-FontCreateFromMemory {
- param const char *name
- param float fontSize
- param uint32_t dpi
- param const void *data
- ret RsFont
- }
-
-MeshCreate {
- param RsAllocation *vtx
- param RsAllocation *idx
- param uint32_t *primType
- ret RsMesh
- }
-
-PathCreate {
- param RsPathPrimitive pp
- param bool isStatic
- param RsAllocation vertex
- param RsAllocation loops
- param float quality
- ret RsPath
- }
diff --git a/libs/rs/rsAdapter.cpp b/libs/rs/rsAdapter.cpp
deleted file mode 100644
index 41811ae..0000000
--- a/libs/rs/rsAdapter.cpp
+++ /dev/null
@@ -1,238 +0,0 @@
-
-/*
- * Copyright (C) 2009 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.
- */
-
-#include "rsContext.h"
-#include "rsAdapter.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-Adapter1D::Adapter1D(Context *rsc) : ObjectBase(rsc) {
- reset();
-}
-
-Adapter1D::Adapter1D(Context *rsc, Allocation *a) : ObjectBase(rsc) {
- reset();
- setAllocation(a);
-}
-
-void Adapter1D::reset() {
- mY = 0;
- mZ = 0;
- mLOD = 0;
- mFace = 0;
-}
-
-void * Adapter1D::getElement(uint32_t x) {
- rsAssert(mAllocation.get());
- rsAssert(mAllocation->getPtr());
- rsAssert(mAllocation->getType());
- uint8_t * ptr = static_cast<uint8_t *>(mAllocation->getPtr());
- ptr += mAllocation->getType()->getLODOffset(mLOD, x, mY);
- return ptr;
-}
-
-void Adapter1D::subData(uint32_t xoff, uint32_t count, const void *data) {
- if (mAllocation.get() && mAllocation.get()->getType()) {
- void *ptr = getElement(xoff);
- count *= mAllocation.get()->getType()->getElementSizeBytes();
- memcpy(ptr, data, count);
- }
-}
-
-void Adapter1D::data(const void *data) {
- memcpy(getElement(0),
- data,
- mAllocation.get()->getType()->getSizeBytes());
-}
-
-void Adapter1D::serialize(OStream *stream) const {
-}
-
-Adapter1D *Adapter1D::createFromStream(Context *rsc, IStream *stream) {
- return NULL;
-}
-
-namespace android {
-namespace renderscript {
-
-RsAdapter1D rsi_Adapter1DCreate(Context *rsc) {
- Adapter1D *a = new Adapter1D(rsc);
- a->incUserRef();
- return a;
-}
-
-void rsi_Adapter1DBindAllocation(Context *rsc, RsAdapter1D va, RsAllocation valloc) {
- Adapter1D * a = static_cast<Adapter1D *>(va);
- Allocation * alloc = static_cast<Allocation *>(valloc);
- a->setAllocation(alloc);
-}
-
-void rsi_Adapter1DSetConstraint(Context *rsc, RsAdapter1D va, RsDimension dim, uint32_t value) {
- Adapter1D * a = static_cast<Adapter1D *>(va);
- switch (dim) {
- case RS_DIMENSION_X:
- rsAssert(!"Cannot contrain X in an 1D adapter");
- return;
- case RS_DIMENSION_Y:
- a->setY(value);
- break;
- case RS_DIMENSION_Z:
- a->setZ(value);
- break;
- case RS_DIMENSION_LOD:
- a->setLOD(value);
- break;
- case RS_DIMENSION_FACE:
- a->setFace(value);
- break;
- default:
- rsAssert(!"Unimplemented constraint");
- return;
- }
-}
-
-void rsi_Adapter1DSubData(Context *rsc, RsAdapter1D va, uint32_t xoff, uint32_t count, const void *data) {
- Adapter1D * a = static_cast<Adapter1D *>(va);
- a->subData(xoff, count, data);
-}
-
-void rsi_Adapter1DData(Context *rsc, RsAdapter1D va, const void *data) {
- Adapter1D * a = static_cast<Adapter1D *>(va);
- a->data(data);
-}
-
-}
-}
-
-//////////////////////////
-
-Adapter2D::Adapter2D(Context *rsc) : ObjectBase(rsc) {
- reset();
-}
-
-Adapter2D::Adapter2D(Context *rsc, Allocation *a) : ObjectBase(rsc) {
- reset();
- setAllocation(a);
-}
-
-void Adapter2D::reset() {
- mZ = 0;
- mLOD = 0;
- mFace = 0;
-}
-
-void * Adapter2D::getElement(uint32_t x, uint32_t y) const {
- rsAssert(mAllocation.get());
- rsAssert(mAllocation->getPtr());
- rsAssert(mAllocation->getType());
- if (mFace != 0 && !mAllocation->getType()->getDimFaces()) {
- ALOGE("Adapter wants cubemap face, but allocation has none");
- return NULL;
- }
-
- uint8_t * ptr = static_cast<uint8_t *>(mAllocation->getPtr());
- ptr += mAllocation->getType()->getLODOffset(mLOD, x, y);
-
- if (mFace != 0) {
- uint32_t totalSizeBytes = mAllocation->getType()->getSizeBytes();
- uint32_t faceOffset = totalSizeBytes / 6;
- ptr += faceOffset * mFace;
- }
- return ptr;
-}
-
-void Adapter2D::subData(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, const void *data) {
- rsAssert(mAllocation.get());
- rsAssert(mAllocation->getPtr());
- rsAssert(mAllocation->getType());
-
- uint32_t eSize = mAllocation.get()->getType()->getElementSizeBytes();
- uint32_t lineSize = eSize * w;
-
- const uint8_t *src = static_cast<const uint8_t *>(data);
- for (uint32_t line=yoff; line < (yoff+h); line++) {
- memcpy(getElement(xoff, line), src, lineSize);
- src += lineSize;
- }
-}
-
-void Adapter2D::data(const void *data) {
- memcpy(getElement(0,0),
- data,
- mAllocation.get()->getType()->getSizeBytes());
-}
-
-void Adapter2D::serialize(OStream *stream) const {
-}
-
-Adapter2D *Adapter2D::createFromStream(Context *rsc, IStream *stream) {
- return NULL;
-}
-
-
-namespace android {
-namespace renderscript {
-
-RsAdapter2D rsi_Adapter2DCreate(Context *rsc) {
- Adapter2D *a = new Adapter2D(rsc);
- a->incUserRef();
- return a;
-}
-
-void rsi_Adapter2DBindAllocation(Context *rsc, RsAdapter2D va, RsAllocation valloc) {
- Adapter2D * a = static_cast<Adapter2D *>(va);
- Allocation * alloc = static_cast<Allocation *>(valloc);
- a->setAllocation(alloc);
-}
-
-void rsi_Adapter2DSetConstraint(Context *rsc, RsAdapter2D va, RsDimension dim, uint32_t value) {
- Adapter2D * a = static_cast<Adapter2D *>(va);
- switch (dim) {
- case RS_DIMENSION_X:
- rsAssert(!"Cannot contrain X in an 2D adapter");
- return;
- case RS_DIMENSION_Y:
- rsAssert(!"Cannot contrain Y in an 2D adapter");
- break;
- case RS_DIMENSION_Z:
- a->setZ(value);
- break;
- case RS_DIMENSION_LOD:
- a->setLOD(value);
- break;
- case RS_DIMENSION_FACE:
- a->setFace(value);
- break;
- default:
- rsAssert(!"Unimplemented constraint");
- return;
- }
-}
-
-void rsi_Adapter2DData(Context *rsc, RsAdapter2D va, const void *data) {
- Adapter2D * a = static_cast<Adapter2D *>(va);
- a->data(data);
-}
-
-void rsi_Adapter2DSubData(Context *rsc, RsAdapter2D va, uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, const void *data) {
- Adapter2D * a = static_cast<Adapter2D *>(va);
- a->subData(xoff, yoff, w, h, data);
-}
-
-}
-}
diff --git a/libs/rs/rsAdapter.h b/libs/rs/rsAdapter.h
deleted file mode 100644
index d150789..0000000
--- a/libs/rs/rsAdapter.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#ifndef ANDROID_RS_ADAPTER_H
-#define ANDROID_RS_ADAPTER_H
-
-#include "rsAllocation.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-
-class Adapter1D : public ObjectBase {
-
-public:
- // By policy this allocation will hold a pointer to the type
- // but will not destroy it on destruction.
- Adapter1D(Context *);
- Adapter1D(Context *, Allocation *);
- void reset();
- void * getElement(uint32_t x);
-
- void setAllocation(Allocation *a) {mAllocation.set(a);}
-
- uint32_t getDimX() const {return mAllocation->getType()->getLODDimX(mLOD);}
-
- const Type * getBaseType() const {return mAllocation->getType();}
-
- inline void setY(uint32_t y) {mY = y;}
- inline void setZ(uint32_t z) {mZ = z;}
- inline void setLOD(uint32_t lod) {mLOD = lod;}
- inline void setFace(uint32_t face) {mFace = face;}
- //void setArray(uint32_t num, uint32_t value);
-
- void subData(uint32_t xoff, uint32_t count, const void *data);
- void data(const void *data);
-
- virtual void serialize(OStream *stream) const;
- virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_ADAPTER_1D; }
- static Adapter1D *createFromStream(Context *rsc, IStream *stream);
-
-protected:
- ObjectBaseRef<Allocation> mAllocation;
- uint32_t mY;
- uint32_t mZ;
- uint32_t mLOD;
- uint32_t mFace;
-};
-
-class Adapter2D : public ObjectBase {
-
-public:
- // By policy this allocation will hold a pointer to the type
- // but will not destroy it on destruction.
- Adapter2D(Context *);
- Adapter2D(Context *, Allocation *);
- void reset();
- void * getElement(uint32_t x, uint32_t y) const;
-
- uint32_t getDimX() const {return mAllocation->getType()->getLODDimX(mLOD);}
- uint32_t getDimY() const {return mAllocation->getType()->getLODDimY(mLOD);}
- const Type * getBaseType() const {return mAllocation->getType();}
-
- void setAllocation(Allocation *a) {mAllocation.set(a);}
- inline void setZ(uint32_t z) {mZ = z;}
- inline void setLOD(uint32_t lod) {mLOD = lod;}
- inline void setFace(uint32_t face) {mFace = face;}
- //void setArray(uint32_t num, uint32_t value);
-
- void data(const void *data);
- void subData(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, const void *data);
-
- virtual void serialize(OStream *stream) const;
- virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_ADAPTER_2D; }
- static Adapter2D *createFromStream(Context *rsc, IStream *stream);
-
-protected:
- ObjectBaseRef<Allocation> mAllocation;
- uint32_t mZ;
- uint32_t mLOD;
- uint32_t mFace;
-};
-
-}
-}
-#endif
-
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp
deleted file mode 100644
index cdff49c..0000000
--- a/libs/rs/rsAllocation.cpp
+++ /dev/null
@@ -1,741 +0,0 @@
-/*
- * Copyright (C) 2009-2012 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.
- */
-
-#include "rsContext.h"
-#include "rsAllocation.h"
-#include "rsAdapter.h"
-#include "rs_hal.h"
-
-#include "system/window.h"
-#include "gui/SurfaceTexture.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-Allocation::Allocation(Context *rsc, const Type *type, uint32_t usages,
- RsAllocationMipmapControl mc, void * ptr)
- : ObjectBase(rsc) {
-
- memset(&mHal, 0, sizeof(mHal));
- mHal.state.mipmapControl = RS_ALLOCATION_MIPMAP_NONE;
- mHal.state.usageFlags = usages;
- mHal.state.mipmapControl = mc;
- mHal.state.usrPtr = ptr;
-
- setType(type);
- updateCache();
-}
-
-Allocation * Allocation::createAllocation(Context *rsc, const Type *type, uint32_t usages,
- RsAllocationMipmapControl mc, void * ptr) {
- Allocation *a = new Allocation(rsc, type, usages, mc, ptr);
-
- if (!rsc->mHal.funcs.allocation.init(rsc, a, type->getElement()->getHasReferences())) {
- rsc->setError(RS_ERROR_FATAL_DRIVER, "Allocation::Allocation, alloc failure");
- delete a;
- return NULL;
- }
-
- return a;
-}
-
-void Allocation::updateCache() {
- const Type *type = mHal.state.type;
- mHal.state.dimensionX = type->getDimX();
- mHal.state.dimensionY = type->getDimY();
- mHal.state.dimensionZ = type->getDimZ();
- mHal.state.hasFaces = type->getDimFaces();
- mHal.state.hasMipmaps = type->getDimLOD();
- mHal.state.elementSizeBytes = type->getElementSizeBytes();
- mHal.state.hasReferences = mHal.state.type->getElement()->getHasReferences();
-}
-
-Allocation::~Allocation() {
- freeChildrenUnlocked();
- setSurfaceTexture(mRSC, NULL);
- mRSC->mHal.funcs.allocation.destroy(mRSC, this);
-}
-
-void Allocation::syncAll(Context *rsc, RsAllocationUsageType src) {
- rsc->mHal.funcs.allocation.syncAll(rsc, this, src);
-}
-
-void Allocation::read(void *data) {
- memcpy(data, getPtr(), mHal.state.type->getSizeBytes());
-}
-
-void Allocation::data(Context *rsc, uint32_t xoff, uint32_t lod,
- uint32_t count, const void *data, size_t sizeBytes) {
- const size_t eSize = mHal.state.type->getElementSizeBytes();
-
- if ((count * eSize) != sizeBytes) {
- ALOGE("Allocation::subData called with mismatched size expected %zu, got %zu",
- (count * eSize), sizeBytes);
- mHal.state.type->dumpLOGV("type info");
- return;
- }
-
- rsc->mHal.funcs.allocation.data1D(rsc, this, xoff, lod, count, data, sizeBytes);
- sendDirty(rsc);
-}
-
-void Allocation::data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, const void *data, size_t sizeBytes) {
- const size_t eSize = mHal.state.elementSizeBytes;
- const size_t lineSize = eSize * w;
-
- //ALOGE("data2d %p, %i %i %i %i %i %i %p %i", this, xoff, yoff, lod, face, w, h, data, sizeBytes);
-
- if ((lineSize * h) != sizeBytes) {
- ALOGE("Allocation size mismatch, expected %zu, got %zu", (lineSize * h), sizeBytes);
- rsAssert(!"Allocation::subData called with mismatched size");
- return;
- }
-
- rsc->mHal.funcs.allocation.data2D(rsc, this, xoff, yoff, lod, face, w, h, data, sizeBytes);
- sendDirty(rsc);
-}
-
-void Allocation::data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t zoff,
- uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, uint32_t d, const void *data, size_t sizeBytes) {
-}
-
-void Allocation::elementData(Context *rsc, uint32_t x, const void *data,
- uint32_t cIdx, size_t sizeBytes) {
- size_t eSize = mHal.state.elementSizeBytes;
-
- if (cIdx >= mHal.state.type->getElement()->getFieldCount()) {
- ALOGE("Error Allocation::subElementData component %i out of range.", cIdx);
- rsc->setError(RS_ERROR_BAD_VALUE, "subElementData component out of range.");
- return;
- }
-
- if (x >= mHal.state.dimensionX) {
- ALOGE("Error Allocation::subElementData X offset %i out of range.", x);
- rsc->setError(RS_ERROR_BAD_VALUE, "subElementData X offset out of range.");
- return;
- }
-
- const Element * e = mHal.state.type->getElement()->getField(cIdx);
- uint32_t elemArraySize = mHal.state.type->getElement()->getFieldArraySize(cIdx);
- if (sizeBytes != e->getSizeBytes() * elemArraySize) {
- ALOGE("Error Allocation::subElementData data size %zu does not match field size %zu.", sizeBytes, e->getSizeBytes());
- rsc->setError(RS_ERROR_BAD_VALUE, "subElementData bad size.");
- return;
- }
-
- rsc->mHal.funcs.allocation.elementData1D(rsc, this, x, data, cIdx, sizeBytes);
- sendDirty(rsc);
-}
-
-void Allocation::elementData(Context *rsc, uint32_t x, uint32_t y,
- const void *data, uint32_t cIdx, size_t sizeBytes) {
- size_t eSize = mHal.state.elementSizeBytes;
-
- if (x >= mHal.state.dimensionX) {
- ALOGE("Error Allocation::subElementData X offset %i out of range.", x);
- rsc->setError(RS_ERROR_BAD_VALUE, "subElementData X offset out of range.");
- return;
- }
-
- if (y >= mHal.state.dimensionY) {
- ALOGE("Error Allocation::subElementData X offset %i out of range.", x);
- rsc->setError(RS_ERROR_BAD_VALUE, "subElementData X offset out of range.");
- return;
- }
-
- if (cIdx >= mHal.state.type->getElement()->getFieldCount()) {
- ALOGE("Error Allocation::subElementData component %i out of range.", cIdx);
- rsc->setError(RS_ERROR_BAD_VALUE, "subElementData component out of range.");
- return;
- }
-
- const Element * e = mHal.state.type->getElement()->getField(cIdx);
- uint32_t elemArraySize = mHal.state.type->getElement()->getFieldArraySize(cIdx);
- if (sizeBytes != e->getSizeBytes() * elemArraySize) {
- ALOGE("Error Allocation::subElementData data size %zu does not match field size %zu.", sizeBytes, e->getSizeBytes());
- rsc->setError(RS_ERROR_BAD_VALUE, "subElementData bad size.");
- return;
- }
-
- rsc->mHal.funcs.allocation.elementData2D(rsc, this, x, y, data, cIdx, sizeBytes);
- sendDirty(rsc);
-}
-
-void Allocation::addProgramToDirty(const Program *p) {
- mToDirtyList.push(p);
-}
-
-void Allocation::removeProgramToDirty(const Program *p) {
- for (size_t ct=0; ct < mToDirtyList.size(); ct++) {
- if (mToDirtyList[ct] == p) {
- mToDirtyList.removeAt(ct);
- return;
- }
- }
- rsAssert(0);
-}
-
-void Allocation::dumpLOGV(const char *prefix) const {
- ObjectBase::dumpLOGV(prefix);
-
- String8 s(prefix);
- s.append(" type ");
- if (mHal.state.type) {
- mHal.state.type->dumpLOGV(s.string());
- }
-
- ALOGV("%s allocation ptr=%p mUsageFlags=0x04%x, mMipmapControl=0x%04x",
- prefix, getPtr(), mHal.state.usageFlags, mHal.state.mipmapControl);
-}
-
-uint32_t Allocation::getPackedSize() const {
- uint32_t numItems = mHal.state.type->getSizeBytes() / mHal.state.type->getElementSizeBytes();
- return numItems * mHal.state.type->getElement()->getSizeBytesUnpadded();
-}
-
-void Allocation::writePackedData(const Type *type,
- uint8_t *dst, const uint8_t *src, bool dstPadded) {
- const Element *elem = type->getElement();
- uint32_t unpaddedBytes = elem->getSizeBytesUnpadded();
- uint32_t paddedBytes = elem->getSizeBytes();
- uint32_t numItems = type->getSizeBytes() / paddedBytes;
-
- uint32_t srcInc = !dstPadded ? paddedBytes : unpaddedBytes;
- uint32_t dstInc = dstPadded ? paddedBytes : unpaddedBytes;
-
- // no sub-elements
- uint32_t fieldCount = elem->getFieldCount();
- if (fieldCount == 0) {
- for (uint32_t i = 0; i < numItems; i ++) {
- memcpy(dst, src, unpaddedBytes);
- src += srcInc;
- dst += dstInc;
- }
- return;
- }
-
- // Cache offsets
- uint32_t *offsetsPadded = new uint32_t[fieldCount];
- uint32_t *offsetsUnpadded = new uint32_t[fieldCount];
- uint32_t *sizeUnpadded = new uint32_t[fieldCount];
-
- for (uint32_t i = 0; i < fieldCount; i++) {
- offsetsPadded[i] = elem->getFieldOffsetBytes(i);
- offsetsUnpadded[i] = elem->getFieldOffsetBytesUnpadded(i);
- sizeUnpadded[i] = elem->getField(i)->getSizeBytesUnpadded();
- }
-
- uint32_t *srcOffsets = !dstPadded ? offsetsPadded : offsetsUnpadded;
- uint32_t *dstOffsets = dstPadded ? offsetsPadded : offsetsUnpadded;
-
- // complex elements, need to copy subelem after subelem
- for (uint32_t i = 0; i < numItems; i ++) {
- for (uint32_t fI = 0; fI < fieldCount; fI++) {
- memcpy(dst + dstOffsets[fI], src + srcOffsets[fI], sizeUnpadded[fI]);
- }
- src += srcInc;
- dst += dstInc;
- }
-
- delete[] offsetsPadded;
- delete[] offsetsUnpadded;
- delete[] sizeUnpadded;
-}
-
-void Allocation::unpackVec3Allocation(const void *data, size_t dataSize) {
- const uint8_t *src = (const uint8_t*)data;
- uint8_t *dst = (uint8_t*)getPtr();
-
- writePackedData(getType(), dst, src, true);
-}
-
-void Allocation::packVec3Allocation(OStream *stream) const {
- uint32_t paddedBytes = getType()->getElement()->getSizeBytes();
- uint32_t unpaddedBytes = getType()->getElement()->getSizeBytesUnpadded();
- uint32_t numItems = mHal.state.type->getSizeBytes() / paddedBytes;
-
- const uint8_t *src = (const uint8_t*)getPtr();
- uint8_t *dst = new uint8_t[numItems * unpaddedBytes];
-
- writePackedData(getType(), dst, src, false);
- stream->addByteArray(dst, getPackedSize());
-
- delete[] dst;
-}
-
-void Allocation::serialize(OStream *stream) const {
- // Need to identify ourselves
- stream->addU32((uint32_t)getClassId());
-
- String8 name(getName());
- stream->addString(&name);
-
- // First thing we need to serialize is the type object since it will be needed
- // to initialize the class
- mHal.state.type->serialize(stream);
-
- uint32_t dataSize = mHal.state.type->getSizeBytes();
- // 3 element vectors are padded to 4 in memory, but padding isn't serialized
- uint32_t packedSize = getPackedSize();
- // Write how much data we are storing
- stream->addU32(packedSize);
- if (dataSize == packedSize) {
- // Now write the data
- stream->addByteArray(getPtr(), dataSize);
- } else {
- // Now write the data
- packVec3Allocation(stream);
- }
-}
-
-Allocation *Allocation::createFromStream(Context *rsc, IStream *stream) {
- // First make sure we are reading the correct object
- RsA3DClassID classID = (RsA3DClassID)stream->loadU32();
- if (classID != RS_A3D_CLASS_ID_ALLOCATION) {
- ALOGE("allocation loading skipped due to invalid class id\n");
- return NULL;
- }
-
- String8 name;
- stream->loadString(&name);
-
- Type *type = Type::createFromStream(rsc, stream);
- if (!type) {
- return NULL;
- }
- type->compute();
-
- Allocation *alloc = Allocation::createAllocation(rsc, type, RS_ALLOCATION_USAGE_SCRIPT);
- type->decUserRef();
-
- // Number of bytes we wrote out for this allocation
- uint32_t dataSize = stream->loadU32();
- // 3 element vectors are padded to 4 in memory, but padding isn't serialized
- uint32_t packedSize = alloc->getPackedSize();
- if (dataSize != type->getSizeBytes() &&
- dataSize != packedSize) {
- ALOGE("failed to read allocation because numbytes written is not the same loaded type wants\n");
- ObjectBase::checkDelete(alloc);
- ObjectBase::checkDelete(type);
- return NULL;
- }
-
- alloc->setName(name.string(), name.size());
-
- if (dataSize == type->getSizeBytes()) {
- uint32_t count = dataSize / type->getElementSizeBytes();
- // Read in all of our allocation data
- alloc->data(rsc, 0, 0, count, stream->getPtr() + stream->getPos(), dataSize);
- } else {
- alloc->unpackVec3Allocation(stream->getPtr() + stream->getPos(), dataSize);
- }
- stream->reset(stream->getPos() + dataSize);
-
- return alloc;
-}
-
-void Allocation::sendDirty(const Context *rsc) const {
- for (size_t ct=0; ct < mToDirtyList.size(); ct++) {
- mToDirtyList[ct]->forceDirty();
- }
- mRSC->mHal.funcs.allocation.markDirty(rsc, this);
-}
-
-void Allocation::incRefs(const void *ptr, size_t ct, size_t startOff) const {
- const uint8_t *p = static_cast<const uint8_t *>(ptr);
- const Element *e = mHal.state.type->getElement();
- uint32_t stride = e->getSizeBytes();
-
- p += stride * startOff;
- while (ct > 0) {
- e->incRefs(p);
- ct --;
- p += stride;
- }
-}
-
-void Allocation::decRefs(const void *ptr, size_t ct, size_t startOff) const {
- if (!mHal.state.hasReferences || !getIsScript()) {
- return;
- }
- const uint8_t *p = static_cast<const uint8_t *>(ptr);
- const Element *e = mHal.state.type->getElement();
- uint32_t stride = e->getSizeBytes();
-
- p += stride * startOff;
- while (ct > 0) {
- e->decRefs(p);
- ct --;
- p += stride;
- }
-}
-
-void Allocation::freeChildrenUnlocked () {
- decRefs(getPtr(), mHal.state.type->getSizeBytes() / mHal.state.type->getElementSizeBytes(), 0);
-}
-
-bool Allocation::freeChildren() {
- if (mHal.state.hasReferences) {
- incSysRef();
- freeChildrenUnlocked();
- return decSysRef();
- }
- return false;
-}
-
-void Allocation::copyRange1D(Context *rsc, const Allocation *src, int32_t srcOff, int32_t destOff, int32_t len) {
-}
-
-void Allocation::resize1D(Context *rsc, uint32_t dimX) {
- uint32_t oldDimX = mHal.state.dimensionX;
- if (dimX == oldDimX) {
- return;
- }
-
- ObjectBaseRef<Type> t = mHal.state.type->cloneAndResize1D(rsc, dimX);
- if (dimX < oldDimX) {
- decRefs(getPtr(), oldDimX - dimX, dimX);
- }
- rsc->mHal.funcs.allocation.resize(rsc, this, t.get(), mHal.state.hasReferences);
- setType(t.get());
- updateCache();
-}
-
-void Allocation::resize2D(Context *rsc, uint32_t dimX, uint32_t dimY) {
- ALOGE("not implemented");
-}
-
-int32_t Allocation::getSurfaceTextureID(const Context *rsc) {
- int32_t id = rsc->mHal.funcs.allocation.initSurfaceTexture(rsc, this);
- mHal.state.surfaceTextureID = id;
- return id;
-}
-
-void Allocation::setSurfaceTexture(const Context *rsc, SurfaceTexture *st) {
- if(st != mHal.state.surfaceTexture) {
- if(mHal.state.surfaceTexture != NULL) {
- mHal.state.surfaceTexture->decStrong(NULL);
- }
- mHal.state.surfaceTexture = st;
- if(mHal.state.surfaceTexture != NULL) {
- mHal.state.surfaceTexture->incStrong(NULL);
- }
- }
-}
-
-void Allocation::setSurface(const Context *rsc, RsNativeWindow sur) {
- ANativeWindow *nw = (ANativeWindow *)sur;
- ANativeWindow *old = mHal.state.wndSurface;
- if (nw) {
- nw->incStrong(NULL);
- }
- rsc->mHal.funcs.allocation.setSurfaceTexture(rsc, this, nw);
- mHal.state.wndSurface = nw;
- if (old) {
- old->decStrong(NULL);
- }
-}
-
-void Allocation::ioSend(const Context *rsc) {
- rsc->mHal.funcs.allocation.ioSend(rsc, this);
-}
-
-void Allocation::ioReceive(const Context *rsc) {
- rsc->mHal.funcs.allocation.ioReceive(rsc, this);
-}
-
-
-/////////////////
-//
-
-namespace android {
-namespace renderscript {
-
-static void AllocationGenerateScriptMips(RsContext con, RsAllocation va);
-
-static void mip565(const Adapter2D &out, const Adapter2D &in) {
- uint32_t w = out.getDimX();
- uint32_t h = out.getDimY();
-
- for (uint32_t y=0; y < h; y++) {
- uint16_t *oPtr = static_cast<uint16_t *>(out.getElement(0, y));
- const uint16_t *i1 = static_cast<uint16_t *>(in.getElement(0, y*2));
- const uint16_t *i2 = static_cast<uint16_t *>(in.getElement(0, y*2+1));
-
- for (uint32_t x=0; x < w; x++) {
- *oPtr = rsBoxFilter565(i1[0], i1[1], i2[0], i2[1]);
- oPtr ++;
- i1 += 2;
- i2 += 2;
- }
- }
-}
-
-static void mip8888(const Adapter2D &out, const Adapter2D &in) {
- uint32_t w = out.getDimX();
- uint32_t h = out.getDimY();
-
- for (uint32_t y=0; y < h; y++) {
- uint32_t *oPtr = static_cast<uint32_t *>(out.getElement(0, y));
- const uint32_t *i1 = static_cast<uint32_t *>(in.getElement(0, y*2));
- const uint32_t *i2 = static_cast<uint32_t *>(in.getElement(0, y*2+1));
-
- for (uint32_t x=0; x < w; x++) {
- *oPtr = rsBoxFilter8888(i1[0], i1[1], i2[0], i2[1]);
- oPtr ++;
- i1 += 2;
- i2 += 2;
- }
- }
-}
-
-static void mip8(const Adapter2D &out, const Adapter2D &in) {
- uint32_t w = out.getDimX();
- uint32_t h = out.getDimY();
-
- for (uint32_t y=0; y < h; y++) {
- uint8_t *oPtr = static_cast<uint8_t *>(out.getElement(0, y));
- const uint8_t *i1 = static_cast<uint8_t *>(in.getElement(0, y*2));
- const uint8_t *i2 = static_cast<uint8_t *>(in.getElement(0, y*2+1));
-
- for (uint32_t x=0; x < w; x++) {
- *oPtr = (uint8_t)(((uint32_t)i1[0] + i1[1] + i2[0] + i2[1]) * 0.25f);
- oPtr ++;
- i1 += 2;
- i2 += 2;
- }
- }
-}
-
-static void mip(const Adapter2D &out, const Adapter2D &in) {
- switch (out.getBaseType()->getElement()->getSizeBits()) {
- case 32:
- mip8888(out, in);
- break;
- case 16:
- mip565(out, in);
- break;
- case 8:
- mip8(out, in);
- break;
- }
-}
-
-void rsi_AllocationSyncAll(Context *rsc, RsAllocation va, RsAllocationUsageType src) {
- Allocation *a = static_cast<Allocation *>(va);
- a->sendDirty(rsc);
- a->syncAll(rsc, src);
-}
-
-void rsi_AllocationGenerateMipmaps(Context *rsc, RsAllocation va) {
- Allocation *texAlloc = static_cast<Allocation *>(va);
- AllocationGenerateScriptMips(rsc, texAlloc);
-}
-
-void rsi_AllocationCopyToBitmap(Context *rsc, RsAllocation va, void *data, size_t dataLen) {
- Allocation *texAlloc = static_cast<Allocation *>(va);
- const Type * t = texAlloc->getType();
-
- size_t s = t->getDimX() * t->getDimY() * t->getElementSizeBytes();
- if (s != dataLen) {
- rsc->setError(RS_ERROR_BAD_VALUE, "Bitmap size didn't match allocation size");
- return;
- }
-
- memcpy(data, texAlloc->getPtr(), s);
-}
-
-void rsi_Allocation1DData(Context *rsc, RsAllocation va, uint32_t xoff, uint32_t lod,
- uint32_t count, const void *data, size_t sizeBytes) {
- Allocation *a = static_cast<Allocation *>(va);
- a->data(rsc, xoff, lod, count, data, sizeBytes);
-}
-
-void rsi_Allocation2DElementData(Context *rsc, RsAllocation va, uint32_t x, uint32_t y, uint32_t lod, RsAllocationCubemapFace face,
- const void *data, size_t sizeBytes, size_t eoff) {
- Allocation *a = static_cast<Allocation *>(va);
- a->elementData(rsc, x, y, data, eoff, sizeBytes);
-}
-
-void rsi_Allocation1DElementData(Context *rsc, RsAllocation va, uint32_t x, uint32_t lod,
- const void *data, size_t sizeBytes, size_t eoff) {
- Allocation *a = static_cast<Allocation *>(va);
- a->elementData(rsc, x, data, eoff, sizeBytes);
-}
-
-void rsi_Allocation2DData(Context *rsc, RsAllocation va, uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, const void *data, size_t sizeBytes) {
- Allocation *a = static_cast<Allocation *>(va);
- a->data(rsc, xoff, yoff, lod, face, w, h, data, sizeBytes);
-}
-
-void rsi_AllocationRead(Context *rsc, RsAllocation va, void *data, size_t data_length) {
- Allocation *a = static_cast<Allocation *>(va);
- a->read(data);
-}
-
-void rsi_AllocationResize1D(Context *rsc, RsAllocation va, uint32_t dimX) {
- Allocation *a = static_cast<Allocation *>(va);
- a->resize1D(rsc, dimX);
-}
-
-void rsi_AllocationResize2D(Context *rsc, RsAllocation va, uint32_t dimX, uint32_t dimY) {
- Allocation *a = static_cast<Allocation *>(va);
- a->resize2D(rsc, dimX, dimY);
-}
-
-static void AllocationGenerateScriptMips(RsContext con, RsAllocation va) {
- Context *rsc = static_cast<Context *>(con);
- Allocation *texAlloc = static_cast<Allocation *>(va);
- uint32_t numFaces = texAlloc->getType()->getDimFaces() ? 6 : 1;
- for (uint32_t face = 0; face < numFaces; face ++) {
- Adapter2D adapt(rsc, texAlloc);
- Adapter2D adapt2(rsc, texAlloc);
- adapt.setFace(face);
- adapt2.setFace(face);
- for (uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) {
- adapt.setLOD(lod);
- adapt2.setLOD(lod + 1);
- mip(adapt2, adapt);
- }
- }
-}
-
-RsAllocation rsi_AllocationCreateTyped(Context *rsc, RsType vtype,
- RsAllocationMipmapControl mips,
- uint32_t usages, uint32_t ptr) {
- Allocation * alloc = Allocation::createAllocation(rsc, static_cast<Type *>(vtype), usages, mips, (void *)ptr);
- if (!alloc) {
- return NULL;
- }
- alloc->incUserRef();
- return alloc;
-}
-
-RsAllocation rsi_AllocationCreateFromBitmap(Context *rsc, RsType vtype,
- RsAllocationMipmapControl mips,
- const void *data, size_t data_length, uint32_t usages) {
- Type *t = static_cast<Type *>(vtype);
-
- RsAllocation vTexAlloc = rsi_AllocationCreateTyped(rsc, vtype, mips, usages, 0);
- Allocation *texAlloc = static_cast<Allocation *>(vTexAlloc);
- if (texAlloc == NULL) {
- ALOGE("Memory allocation failure");
- return NULL;
- }
-
- memcpy(texAlloc->getPtr(), data, t->getDimX() * t->getDimY() * t->getElementSizeBytes());
- if (mips == RS_ALLOCATION_MIPMAP_FULL) {
- AllocationGenerateScriptMips(rsc, texAlloc);
- }
-
- texAlloc->sendDirty(rsc);
- return texAlloc;
-}
-
-RsAllocation rsi_AllocationCubeCreateFromBitmap(Context *rsc, RsType vtype,
- RsAllocationMipmapControl mips,
- const void *data, size_t data_length, uint32_t usages) {
- Type *t = static_cast<Type *>(vtype);
-
- // Cubemap allocation's faces should be Width by Width each.
- // Source data should have 6 * Width by Width pixels
- // Error checking is done in the java layer
- RsAllocation vTexAlloc = rsi_AllocationCreateTyped(rsc, vtype, mips, usages, 0);
- Allocation *texAlloc = static_cast<Allocation *>(vTexAlloc);
- if (texAlloc == NULL) {
- ALOGE("Memory allocation failure");
- return NULL;
- }
-
- uint32_t faceSize = t->getDimX();
- uint32_t strideBytes = faceSize * 6 * t->getElementSizeBytes();
- uint32_t copySize = faceSize * t->getElementSizeBytes();
-
- uint8_t *sourcePtr = (uint8_t*)data;
- for (uint32_t face = 0; face < 6; face ++) {
- Adapter2D faceAdapter(rsc, texAlloc);
- faceAdapter.setFace(face);
-
- for (uint32_t dI = 0; dI < faceSize; dI ++) {
- memcpy(faceAdapter.getElement(0, dI), sourcePtr + strideBytes * dI, copySize);
- }
-
- // Move the data pointer to the next cube face
- sourcePtr += copySize;
- }
-
- if (mips == RS_ALLOCATION_MIPMAP_FULL) {
- AllocationGenerateScriptMips(rsc, texAlloc);
- }
-
- texAlloc->sendDirty(rsc);
- return texAlloc;
-}
-
-void rsi_AllocationCopy2DRange(Context *rsc,
- RsAllocation dstAlloc,
- uint32_t dstXoff, uint32_t dstYoff,
- uint32_t dstMip, uint32_t dstFace,
- uint32_t width, uint32_t height,
- RsAllocation srcAlloc,
- uint32_t srcXoff, uint32_t srcYoff,
- uint32_t srcMip, uint32_t srcFace) {
- Allocation *dst = static_cast<Allocation *>(dstAlloc);
- Allocation *src= static_cast<Allocation *>(srcAlloc);
- rsc->mHal.funcs.allocation.allocData2D(rsc, dst, dstXoff, dstYoff, dstMip,
- (RsAllocationCubemapFace)dstFace,
- width, height,
- src, srcXoff, srcYoff,srcMip,
- (RsAllocationCubemapFace)srcFace);
-}
-
-int32_t rsi_AllocationGetSurfaceTextureID(Context *rsc, RsAllocation valloc) {
- Allocation *alloc = static_cast<Allocation *>(valloc);
- return alloc->getSurfaceTextureID(rsc);
-}
-
-void rsi_AllocationGetSurfaceTextureID2(Context *rsc, RsAllocation valloc, void *vst, size_t len) {
- Allocation *alloc = static_cast<Allocation *>(valloc);
- alloc->setSurfaceTexture(rsc, static_cast<SurfaceTexture *>(vst));
-}
-
-void rsi_AllocationSetSurface(Context *rsc, RsAllocation valloc, RsNativeWindow sur) {
- Allocation *alloc = static_cast<Allocation *>(valloc);
- alloc->setSurface(rsc, sur);
-}
-
-void rsi_AllocationIoSend(Context *rsc, RsAllocation valloc) {
- Allocation *alloc = static_cast<Allocation *>(valloc);
- alloc->ioSend(rsc);
-}
-
-void rsi_AllocationIoReceive(Context *rsc, RsAllocation valloc) {
- Allocation *alloc = static_cast<Allocation *>(valloc);
- alloc->ioReceive(rsc);
-}
-
-}
-}
-
-const void * rsaAllocationGetType(RsContext con, RsAllocation va) {
- Allocation *a = static_cast<Allocation *>(va);
- a->getType()->incUserRef();
-
- return a->getType();
-}
diff --git a/libs/rs/rsAllocation.h b/libs/rs/rsAllocation.h
deleted file mode 100644
index e2783d2..0000000
--- a/libs/rs/rsAllocation.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (C) 2009-2012 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.
- */
-
-#ifndef ANDROID_STRUCTURED_ALLOCATION_H
-#define ANDROID_STRUCTURED_ALLOCATION_H
-
-#include "rsType.h"
-
-struct ANativeWindow;
-
-// ---------------------------------------------------------------------------
-namespace android {
-class SurfaceTexture;
-
-namespace renderscript {
-
-class Program;
-
-/*****************************************************************************
- * CAUTION
- *
- * Any layout changes for this class may require a corresponding change to be
- * made to frameworks/compile/libbcc/lib/ScriptCRT/rs_core.c, which contains
- * a partial copy of the information below.
- *
- *****************************************************************************/
-class Allocation : public ObjectBase {
- // The graphics equivalent of malloc. The allocation contains a structure of elements.
-
-public:
- struct Hal {
- void * drv;
-
- struct State {
- const Type * type;
-
- uint32_t usageFlags;
- RsAllocationMipmapControl mipmapControl;
-
- // Cached fields from the Type and Element
- // to prevent pointer chasing in critical loops.
- uint32_t dimensionX;
- uint32_t dimensionY;
- uint32_t dimensionZ;
- uint32_t elementSizeBytes;
- bool hasMipmaps;
- bool hasFaces;
- bool hasReferences;
- void * usrPtr;
- int32_t surfaceTextureID;
- ANativeWindow *wndSurface;
- SurfaceTexture *surfaceTexture;
- };
- State state;
-
- struct DrvState {
- void * mallocPtr;
- } drvState;
-
- };
- Hal mHal;
-
- static Allocation * createAllocation(Context *rsc, const Type *, uint32_t usages,
- RsAllocationMipmapControl mc = RS_ALLOCATION_MIPMAP_NONE,
- void *ptr = 0);
- virtual ~Allocation();
- void updateCache();
-
- void * getPtr() const {return mHal.drvState.mallocPtr;}
- const Type * getType() const {return mHal.state.type;}
-
- void syncAll(Context *rsc, RsAllocationUsageType src);
-
- void copyRange1D(Context *rsc, const Allocation *src, int32_t srcOff, int32_t destOff, int32_t len);
-
- void resize1D(Context *rsc, uint32_t dimX);
- void resize2D(Context *rsc, uint32_t dimX, uint32_t dimY);
-
- void data(Context *rsc, uint32_t xoff, uint32_t lod, uint32_t count, const void *data, size_t sizeBytes);
- void data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, const void *data, size_t sizeBytes);
- void data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, uint32_t d, const void *data, size_t sizeBytes);
-
- void elementData(Context *rsc, uint32_t x,
- const void *data, uint32_t elementOff, size_t sizeBytes);
- void elementData(Context *rsc, uint32_t x, uint32_t y,
- const void *data, uint32_t elementOff, size_t sizeBytes);
-
- void read(void *data);
-
- void addProgramToDirty(const Program *);
- void removeProgramToDirty(const Program *);
-
- virtual void dumpLOGV(const char *prefix) const;
- virtual void serialize(OStream *stream) const;
- virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_ALLOCATION; }
- static Allocation *createFromStream(Context *rsc, IStream *stream);
-
- bool getIsScript() const {
- return (mHal.state.usageFlags & RS_ALLOCATION_USAGE_SCRIPT) != 0;
- }
- bool getIsTexture() const {
- return (mHal.state.usageFlags & RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE) != 0;
- }
- bool getIsRenderTarget() const {
- return (mHal.state.usageFlags & RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET) != 0;
- }
- bool getIsBufferObject() const {
- return (mHal.state.usageFlags & RS_ALLOCATION_USAGE_GRAPHICS_VERTEX) != 0;
- }
-
- void incRefs(const void *ptr, size_t ct, size_t startOff = 0) const;
- void decRefs(const void *ptr, size_t ct, size_t startOff = 0) const;
- virtual bool freeChildren();
-
- void sendDirty(const Context *rsc) const;
- bool getHasGraphicsMipmaps() const {
- return mHal.state.mipmapControl != RS_ALLOCATION_MIPMAP_NONE;
- }
-
- int32_t getSurfaceTextureID(const Context *rsc);
- void setSurfaceTexture(const Context *rsc, SurfaceTexture *st);
- void setSurface(const Context *rsc, RsNativeWindow sur);
- void ioSend(const Context *rsc);
- void ioReceive(const Context *rsc);
-
-protected:
- Vector<const Program *> mToDirtyList;
- ObjectBaseRef<const Type> mType;
- void setType(const Type *t) {
- mType.set(t);
- mHal.state.type = t;
- }
-
-private:
- void freeChildrenUnlocked();
- Allocation(Context *rsc, const Type *, uint32_t usages, RsAllocationMipmapControl mc, void *ptr);
-
- uint32_t getPackedSize() const;
- static void writePackedData(const Type *type, uint8_t *dst, const uint8_t *src, bool dstPadded);
- void unpackVec3Allocation(const void *data, size_t dataSize);
- void packVec3Allocation(OStream *stream) const;
-};
-
-}
-}
-#endif
-
diff --git a/libs/rs/rsAnimation.cpp b/libs/rs/rsAnimation.cpp
deleted file mode 100644
index a4093d9..0000000
--- a/libs/rs/rsAnimation.cpp
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#include "rsContext.h"
-#include "rsAnimation.h"
-
-
-using namespace android;
-using namespace android::renderscript;
-
-void Animation::serialize(OStream *stream) const {
-}
-
-Animation *Animation::createFromStream(Context *rsc, IStream *stream) {
- return NULL;
-}
-
-/*
-Animation::Animation(Context *rsc) : ObjectBase(rsc)
-{
- mAllocFile = __FILE__;
- mAllocLine = __LINE__;
-
- mValuesInput = NULL;
- mValuesOutput = NULL;
- mValueCount = 0;
- mInterpolation = RS_ANIMATION_INTERPOLATION_STEP;
- mEdgePre = RS_ANIMATION_EDGE_UNDEFINED;
- mEdgePost = RS_ANIMATION_EDGE_UNDEFINED;
- mInputMin = 0;
- mInputMax = 0;
-}
-
-Animation * Animation::create(Context *rsc,
- const float *inValues, const float *outValues,
- uint32_t valueCount, RsAnimationInterpolation interp,
- RsAnimationEdge pre, RsAnimationEdge post)
-{
- if (valueCount < 2) {
- rsc->setError(RS_ERROR_BAD_VALUE, "Animations require more than 2 values.");
- return NULL;
- }
- Animation *a = new Animation(rsc);
- if (!a) {
- rsc->setError(RS_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
-
- float *vin = (float *)malloc(valueCount * sizeof(float));
- float *vout = (float *)malloc(valueCount * sizeof(float));
- a->mValuesInput = vin;
- a->mValuesOutput = vout;
- if (a->mValuesInput == NULL || a->mValuesOutput == NULL) {
- delete a;
- rsc->setError(RS_ERROR_OUT_OF_MEMORY);
- return NULL;
- }
-
- a->mEdgePre = pre;
- a->mEdgePost = post;
- a->mInterpolation = interp;
- a->mValueCount = valueCount;
-
- memcpy(vin, inValues, valueCount * sizeof(float));
- memcpy(vout, outValues, valueCount * sizeof(float));
- a->mInputMin = inValues[0];
- a->mInputMax = inValues[0];
-
- bool needSort = false;
- for (uint32_t ct=1; ct < valueCount; ct++) {
- if (a->mInputMin > vin[ct]) {
- needSort = true;
- a->mInputMin = vin[ct];
- }
- if (a->mInputMax < vin[ct]) {
- a->mInputMax = vin[ct];
- } else {
- needSort = true;
- }
- }
-
- while (1) {
- bool changed = false;
- for (uint32_t ct=1; ct < valueCount; ct++) {
- if (vin[ct-1] > vin[ct]) {
- float t = vin[ct-1];
- vin[ct-1] = vin[ct];
- vin[ct] = t;
- t = vout[ct-1];
- vout[ct-1] = vout[ct];
- vout[ct] = t;
- changed = true;
- }
- }
- if (!changed) break;
- }
-
- return a;
-}
-*/
-
-
-/////////////////////////////////////////
-//
-
-namespace android {
-namespace renderscript {
-
-RsAnimation rsi_AnimationCreate(Context *rsc,
- const float *inValues,
- const float *outValues,
- uint32_t valueCount,
- RsAnimationInterpolation interp,
- RsAnimationEdge pre,
- RsAnimationEdge post) {
- //ALOGE("rsi_ElementCreate %i %i %i %i", dt, dk, norm, vecSize);
- Animation *a = NULL;//Animation::create(rsc, inValues, outValues, valueCount, interp, pre, post);
- if (a != NULL) {
- a->incUserRef();
- }
- return (RsAnimation)a;
-}
-
-
-}
-}
-
diff --git a/libs/rs/rsAnimation.h b/libs/rs/rsAnimation.h
deleted file mode 100644
index 526a081..0000000
--- a/libs/rs/rsAnimation.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#ifndef ANDROID_RS_ANIMATION_H
-#define ANDROID_RS_ANIMATION_H
-
-#include "rsUtils.h"
-#include "rsObjectBase.h"
-#include "rsDefines.h"
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-
-class Animation : public ObjectBase {
-public:
- ~Animation();
-
- static Animation * create(Context *rsc,
- const float *inValues, const float *outValues,
- uint32_t valueCount, RsAnimationInterpolation,
- RsAnimationEdge pre, RsAnimationEdge post);
-
- float eval(float) const;
-
- virtual void serialize(OStream *stream) const;
- virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_ANIMATION; }
- static Animation *createFromStream(Context *rsc, IStream *stream);
-
-protected:
- Animation(Context *rsc);
-
-
-
- float evalInRange(float) const;
-
-
-
- const float *mValuesInput;
- const float *mValuesOutput;
- uint32_t mValueCount;
- RsAnimationInterpolation mInterpolation;
- RsAnimationEdge mEdgePre;
- RsAnimationEdge mEdgePost;
-
- // derived
- float mInputMin;
- float mInputMax;
-};
-
-}
-}
-#endif //ANDROID_STRUCTURED_ELEMENT_H
-
diff --git a/libs/rs/rsComponent.cpp b/libs/rs/rsComponent.cpp
deleted file mode 100644
index 9c2c200..0000000
--- a/libs/rs/rsComponent.cpp
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#include "rsComponent.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-Component::Component() {
- set(RS_TYPE_NONE, RS_KIND_USER, false, 1);
-}
-
-Component::~Component() {
-}
-
-void Component::set(RsDataType dt, RsDataKind dk, bool norm, uint32_t vecSize) {
- mType = dt;
- mKind = dk;
- mNormalized = norm;
- mVectorSize = vecSize;
- rsAssert(vecSize <= 4);
-
- mBits = 0;
- mTypeBits = 0;
- mIsFloat = false;
- mIsSigned = false;
- mIsPixel = false;
-
- switch (mKind) {
- case RS_KIND_PIXEL_L:
- case RS_KIND_PIXEL_A:
- mIsPixel = true;
- rsAssert(mVectorSize == 1);
- rsAssert(mNormalized == true);
- break;
- case RS_KIND_PIXEL_LA:
- mIsPixel = true;
- rsAssert(mVectorSize == 2);
- rsAssert(mNormalized == true);
- break;
- case RS_KIND_PIXEL_RGB:
- mIsPixel = true;
- rsAssert(mVectorSize == 3);
- rsAssert(mNormalized == true);
- break;
- case RS_KIND_PIXEL_RGBA:
- mIsPixel = true;
- rsAssert(mVectorSize == 4);
- rsAssert(mNormalized == true);
- break;
- default:
- rsAssert(mKind != RS_KIND_INVALID);
- break;
- }
-
- switch (mType) {
- case RS_TYPE_NONE:
- return;
- case RS_TYPE_UNSIGNED_5_6_5:
- mVectorSize = 3;
- mBits = 16;
- mNormalized = true;
- rsAssert(mKind == RS_KIND_PIXEL_RGB);
- return;
- case RS_TYPE_UNSIGNED_5_5_5_1:
- mVectorSize = 4;
- mBits = 16;
- mNormalized = true;
- rsAssert(mKind == RS_KIND_PIXEL_RGBA);
- return;
- case RS_TYPE_UNSIGNED_4_4_4_4:
- mVectorSize = 4;
- mBits = 16;
- mNormalized = true;
- rsAssert(mKind == RS_KIND_PIXEL_RGBA);
- return;
-
- case RS_TYPE_MATRIX_4X4:
- mTypeBits = 16 * 32;
- rsAssert(mVectorSize == 1);
- rsAssert(mNormalized == false);
- rsAssert(mKind == RS_KIND_USER);
- break;
- case RS_TYPE_MATRIX_3X3:
- mTypeBits = 9 * 32;
- rsAssert(mVectorSize == 1);
- rsAssert(mNormalized == false);
- rsAssert(mKind == RS_KIND_USER);
- break;
- case RS_TYPE_MATRIX_2X2:
- mTypeBits = 4 * 32;
- rsAssert(mVectorSize == 1);
- rsAssert(mNormalized == false);
- rsAssert(mKind == RS_KIND_USER);
- break;
-
- case RS_TYPE_ELEMENT:
- case RS_TYPE_TYPE:
- case RS_TYPE_ALLOCATION:
- case RS_TYPE_SAMPLER:
- case RS_TYPE_SCRIPT:
- case RS_TYPE_MESH:
- case RS_TYPE_PROGRAM_FRAGMENT:
- case RS_TYPE_PROGRAM_VERTEX:
- case RS_TYPE_PROGRAM_RASTER:
- case RS_TYPE_PROGRAM_STORE:
- rsAssert(mVectorSize == 1);
- rsAssert(mNormalized == false);
- rsAssert(mKind == RS_KIND_USER);
- mBits = 32;
- mTypeBits = 32;
- return;
-
- case RS_TYPE_FLOAT_16:
- mTypeBits = 16;
- mIsFloat = true;
- break;
- case RS_TYPE_FLOAT_32:
- mTypeBits = 32;
- mIsFloat = true;
- break;
- case RS_TYPE_FLOAT_64:
- mTypeBits = 64;
- mIsFloat = true;
- break;
- case RS_TYPE_SIGNED_8:
- mTypeBits = 8;
- mIsSigned = true;
- break;
- case RS_TYPE_SIGNED_16:
- mTypeBits = 16;
- mIsSigned = true;
- break;
- case RS_TYPE_SIGNED_32:
- mTypeBits = 32;
- mIsSigned = true;
- break;
- case RS_TYPE_SIGNED_64:
- mTypeBits = 64;
- mIsSigned = true;
- break;
- case RS_TYPE_UNSIGNED_8:
- mTypeBits = 8;
- break;
- case RS_TYPE_UNSIGNED_16:
- mTypeBits = 16;
- break;
- case RS_TYPE_UNSIGNED_32:
- mTypeBits = 32;
- break;
- case RS_TYPE_UNSIGNED_64:
- mTypeBits = 64;
- break;
-
- case RS_TYPE_BOOLEAN:
- mTypeBits = 8;
- break;
- default:
- rsAssert(mType != RS_TYPE_INVALID);
- break;
- }
-
- mBitsUnpadded = mTypeBits * mVectorSize;
- mBits = mTypeBits * rsHigherPow2(mVectorSize);
-}
-
-bool Component::isReference() const {
- return (mType >= RS_TYPE_ELEMENT);
-}
-
-static const char * gTypeBasicStrings[] = {
- "NONE",
- "F16",
- "F32",
- "F64",
- "S8",
- "S16",
- "S32",
- "S64",
- "U8",
- "U16",
- "U32",
- "U64",
- "BOOLEAN",
- "UP_565",
- "UP_5551",
- "UP_4444",
- "MATRIX_4X4",
- "MATRIX_3X3",
- "MATRIX_2X2",
-};
-
-static const char * gTypeObjStrings[] = {
- "ELEMENT",
- "TYPE",
- "ALLOCATION",
- "SAMPLER",
- "SCRIPT",
- "MESH",
- "PROGRAM_FRAGMENT",
- "PROGRAM_VERTEX",
- "PROGRAM_RASTER",
- "PROGRAM_STORE",
-};
-
-static const char * gKindStrings[] = {
- "USER",
- "COLOR",
- "POSITION",
- "TEXTURE",
- "NORMAL",
- "INDEX",
- "POINT_SIZE",
- "PIXEL_L",
- "PIXEL_A",
- "PIXEL_LA",
- "PIXEL_RGB",
- "PIXEL_RGBA",
-};
-
-void Component::dumpLOGV(const char *prefix) const {
- if (mType >= RS_TYPE_ELEMENT) {
- ALOGV("%s Component: %s, %s, vectorSize=%i, bits=%i",
- prefix, gTypeObjStrings[mType - RS_TYPE_ELEMENT], gKindStrings[mKind], mVectorSize, mBits);
- } else {
- ALOGV("%s Component: %s, %s, vectorSize=%i, bits=%i",
- prefix, gTypeBasicStrings[mType], gKindStrings[mKind], mVectorSize, mBits);
- }
-}
-
-void Component::serialize(OStream *stream) const {
- stream->addU8((uint8_t)mType);
- stream->addU8((uint8_t)mKind);
- stream->addU8((uint8_t)(mNormalized ? 1 : 0));
- stream->addU32(mVectorSize);
-}
-
-void Component::loadFromStream(IStream *stream) {
- mType = (RsDataType)stream->loadU8();
- mKind = (RsDataKind)stream->loadU8();
- uint8_t temp = stream->loadU8();
- mNormalized = temp != 0;
- mVectorSize = stream->loadU32();
-
- set(mType, mKind, mNormalized, mVectorSize);
-}
-
-
-
-
diff --git a/libs/rs/rsComponent.h b/libs/rs/rsComponent.h
deleted file mode 100644
index a2e8c0f..0000000
--- a/libs/rs/rsComponent.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#ifndef ANDROID_COMPONENT_H
-#define ANDROID_COMPONENT_H
-
-#include "rsUtils.h"
-#include "rsDefines.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-
-// An element is a group of Components that occupies one cell in a structure.
-class Component {
-public:
- Component();
- ~Component();
-
- void set(RsDataType dt, RsDataKind dk, bool norm, uint32_t vecSize=1);
-
- void dumpLOGV(const char *prefix) const;
-
- RsDataType getType() const {return mType;}
- RsDataKind getKind() const {return mKind;}
- bool getIsNormalized() const {return mNormalized;}
- uint32_t getVectorSize() const {return mVectorSize;}
- bool getIsFloat() const {return mIsFloat;}
- bool getIsSigned() const {return mIsSigned;}
- uint32_t getBits() const {return mBits;}
- uint32_t getBitsUnpadded() const {return mBitsUnpadded;}
-
- // Helpers for reading / writing this class out
- void serialize(OStream *stream) const;
- void loadFromStream(IStream *stream);
-
- bool isReference() const;
-
-protected:
- RsDataType mType;
- RsDataKind mKind;
- bool mNormalized;
- uint32_t mVectorSize;
-
- // derived
- uint32_t mBits;
- uint32_t mBitsUnpadded;
- uint32_t mTypeBits;
- bool mIsFloat;
- bool mIsSigned;
- bool mIsPixel;
-};
-
-}
-}
-
-#endif
-
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
deleted file mode 100644
index 5e21763..0000000
--- a/libs/rs/rsContext.cpp
+++ /dev/null
@@ -1,770 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#include "rs.h"
-#include "rsDevice.h"
-#include "rsContext.h"
-#include "rsThreadIO.h"
-#include "rsMesh.h"
-#include <ui/FramebufferNativeWindow.h>
-#include <gui/DisplayEventReceiver.h>
-
-#include <sys/types.h>
-#include <sys/resource.h>
-#include <sched.h>
-
-#include <cutils/properties.h>
-
-#include <sys/syscall.h>
-#include <string.h>
-
-using namespace android;
-using namespace android::renderscript;
-
-pthread_mutex_t Context::gInitMutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_mutex_t Context::gLibMutex = PTHREAD_MUTEX_INITIALIZER;
-
-bool Context::initGLThread() {
- pthread_mutex_lock(&gInitMutex);
-
- if (!mHal.funcs.initGraphics(this)) {
- pthread_mutex_unlock(&gInitMutex);
- ALOGE("%p initGraphics failed", this);
- return false;
- }
-
- pthread_mutex_unlock(&gInitMutex);
- return true;
-}
-
-void Context::deinitEGL() {
- mHal.funcs.shutdownGraphics(this);
-}
-
-Context::PushState::PushState(Context *con) {
- mRsc = con;
- if (con->mIsGraphicsContext) {
- mFragment.set(con->getProgramFragment());
- mVertex.set(con->getProgramVertex());
- mStore.set(con->getProgramStore());
- mRaster.set(con->getProgramRaster());
- mFont.set(con->getFont());
- }
-}
-
-Context::PushState::~PushState() {
- if (mRsc->mIsGraphicsContext) {
- mRsc->setProgramFragment(mFragment.get());
- mRsc->setProgramVertex(mVertex.get());
- mRsc->setProgramStore(mStore.get());
- mRsc->setProgramRaster(mRaster.get());
- mRsc->setFont(mFont.get());
- }
-}
-
-
-uint32_t Context::runScript(Script *s) {
- PushState(this);
-
- uint32_t ret = s->run(this);
- return ret;
-}
-
-uint32_t Context::runRootScript() {
- timerSet(RS_TIMER_SCRIPT);
- mStateFragmentStore.mLast.clear();
- watchdog.inRoot = true;
- uint32_t ret = runScript(mRootScript.get());
- watchdog.inRoot = false;
-
- return ret;
-}
-
-uint64_t Context::getTime() const {
-#ifndef ANDROID_RS_SERIALIZE
- struct timespec t;
- clock_gettime(CLOCK_MONOTONIC, &t);
- return t.tv_nsec + ((uint64_t)t.tv_sec * 1000 * 1000 * 1000);
-#else
- return 0;
-#endif //ANDROID_RS_SERIALIZE
-}
-
-void Context::timerReset() {
- for (int ct=0; ct < _RS_TIMER_TOTAL; ct++) {
- mTimers[ct] = 0;
- }
-}
-
-void Context::timerInit() {
- mTimeLast = getTime();
- mTimeFrame = mTimeLast;
- mTimeLastFrame = mTimeLast;
- mTimerActive = RS_TIMER_INTERNAL;
- mAverageFPSFrameCount = 0;
- mAverageFPSStartTime = mTimeLast;
- mAverageFPS = 0;
- timerReset();
-}
-
-void Context::timerFrame() {
- mTimeLastFrame = mTimeFrame;
- mTimeFrame = getTime();
- // Update average fps
- const uint64_t averageFramerateInterval = 1000 * 1000000;
- mAverageFPSFrameCount ++;
- uint64_t inverval = mTimeFrame - mAverageFPSStartTime;
- if (inverval >= averageFramerateInterval) {
- inverval = inverval / 1000000;
- mAverageFPS = (mAverageFPSFrameCount * 1000) / inverval;
- mAverageFPSFrameCount = 0;
- mAverageFPSStartTime = mTimeFrame;
- }
-}
-
-void Context::timerSet(Timers tm) {
- uint64_t last = mTimeLast;
- mTimeLast = getTime();
- mTimers[mTimerActive] += mTimeLast - last;
- mTimerActive = tm;
-}
-
-void Context::timerPrint() {
- double total = 0;
- for (int ct = 0; ct < _RS_TIMER_TOTAL; ct++) {
- total += mTimers[ct];
- }
- uint64_t frame = mTimeFrame - mTimeLastFrame;
- mTimeMSLastFrame = frame / 1000000;
- mTimeMSLastScript = mTimers[RS_TIMER_SCRIPT] / 1000000;
- mTimeMSLastSwap = mTimers[RS_TIMER_CLEAR_SWAP] / 1000000;
-
-
- if (props.mLogTimes) {
- ALOGV("RS: Frame (%i), Script %2.1f%% (%i), Swap %2.1f%% (%i), Idle %2.1f%% (%lli), Internal %2.1f%% (%lli), Avg fps: %u",
- mTimeMSLastFrame,
- 100.0 * mTimers[RS_TIMER_SCRIPT] / total, mTimeMSLastScript,
- 100.0 * mTimers[RS_TIMER_CLEAR_SWAP] / total, mTimeMSLastSwap,
- 100.0 * mTimers[RS_TIMER_IDLE] / total, mTimers[RS_TIMER_IDLE] / 1000000,
- 100.0 * mTimers[RS_TIMER_INTERNAL] / total, mTimers[RS_TIMER_INTERNAL] / 1000000,
- mAverageFPS);
- }
-}
-
-bool Context::setupCheck() {
-
- mFragmentStore->setup(this, &mStateFragmentStore);
- mFragment->setup(this, &mStateFragment);
- mRaster->setup(this, &mStateRaster);
- mVertex->setup(this, &mStateVertex);
- mFBOCache.setup(this);
- return true;
-}
-
-void Context::setupProgramStore() {
- mFragmentStore->setup(this, &mStateFragmentStore);
-}
-
-static uint32_t getProp(const char *str) {
- char buf[PROPERTY_VALUE_MAX];
- property_get(str, buf, "0");
- return atoi(buf);
-}
-
-void Context::displayDebugStats() {
- char buffer[128];
- sprintf(buffer, "Avg fps %u, Frame %i ms, Script %i ms", mAverageFPS, mTimeMSLastFrame, mTimeMSLastScript);
- float oldR, oldG, oldB, oldA;
- mStateFont.getFontColor(&oldR, &oldG, &oldB, &oldA);
- uint32_t bufferLen = strlen(buffer);
-
- ObjectBaseRef<Font> lastFont(getFont());
- setFont(NULL);
- float shadowCol = 0.1f;
- mStateFont.setFontColor(shadowCol, shadowCol, shadowCol, 1.0f);
- mStateFont.renderText(buffer, bufferLen, 5, getHeight() - 6);
-
- mStateFont.setFontColor(1.0f, 0.7f, 0.0f, 1.0f);
- mStateFont.renderText(buffer, bufferLen, 4, getHeight() - 7);
-
- setFont(lastFont.get());
- mStateFont.setFontColor(oldR, oldG, oldB, oldA);
-}
-
-void * Context::threadProc(void *vrsc) {
- Context *rsc = static_cast<Context *>(vrsc);
-#ifndef ANDROID_RS_SERIALIZE
- rsc->mNativeThreadId = gettid();
- setpriority(PRIO_PROCESS, rsc->mNativeThreadId, ANDROID_PRIORITY_DISPLAY);
- rsc->mThreadPriority = ANDROID_PRIORITY_DISPLAY;
-#endif //ANDROID_RS_SERIALIZE
- rsc->props.mLogTimes = getProp("debug.rs.profile") != 0;
- rsc->props.mLogScripts = getProp("debug.rs.script") != 0;
- rsc->props.mLogObjects = getProp("debug.rs.object") != 0;
- rsc->props.mLogShaders = getProp("debug.rs.shader") != 0;
- rsc->props.mLogShadersAttr = getProp("debug.rs.shader.attributes") != 0;
- rsc->props.mLogShadersUniforms = getProp("debug.rs.shader.uniforms") != 0;
- rsc->props.mLogVisual = getProp("debug.rs.visual") != 0;
- rsc->props.mDebugMaxThreads = getProp("debug.rs.max-threads");
-
- if (!rsdHalInit(rsc, 0, 0)) {
- rsc->setError(RS_ERROR_FATAL_DRIVER, "Failed initializing GL");
- ALOGE("Hal init failed");
- return NULL;
- }
- rsc->mHal.funcs.setPriority(rsc, rsc->mThreadPriority);
-
- if (rsc->mIsGraphicsContext) {
- if (!rsc->initGLThread()) {
- rsc->setError(RS_ERROR_OUT_OF_MEMORY, "Failed initializing GL");
- return NULL;
- }
-
- rsc->mStateRaster.init(rsc);
- rsc->setProgramRaster(NULL);
- rsc->mStateVertex.init(rsc);
- rsc->setProgramVertex(NULL);
- rsc->mStateFragment.init(rsc);
- rsc->setProgramFragment(NULL);
- rsc->mStateFragmentStore.init(rsc);
- rsc->setProgramStore(NULL);
- rsc->mStateFont.init(rsc);
- rsc->setFont(NULL);
- rsc->mStateSampler.init(rsc);
- rsc->mFBOCache.init(rsc);
- }
-
- rsc->mRunning = true;
- if (!rsc->mIsGraphicsContext) {
- while (!rsc->mExit) {
- rsc->mIO.playCoreCommands(rsc, -1);
- }
- } else {
-#ifndef ANDROID_RS_SERIALIZE
- DisplayEventReceiver displayEvent;
- DisplayEventReceiver::Event eventBuffer[1];
-#endif
- int vsyncRate = 0;
- int targetRate = 0;
-
- bool drawOnce = false;
- while (!rsc->mExit) {
- rsc->timerSet(RS_TIMER_IDLE);
-
-#ifndef ANDROID_RS_SERIALIZE
- if (!rsc->mRootScript.get() || !rsc->mHasSurface || rsc->mPaused) {
- targetRate = 0;
- }
-
- if (vsyncRate != targetRate) {
- displayEvent.setVsyncRate(targetRate);
- vsyncRate = targetRate;
- }
- if (targetRate) {
- drawOnce |= rsc->mIO.playCoreCommands(rsc, displayEvent.getFd());
- while (displayEvent.getEvents(eventBuffer, 1) != 0) {
- //ALOGE("vs2 time past %lld", (rsc->getTime() - eventBuffer[0].header.timestamp) / 1000000);
- }
- } else
-#endif
- {
- drawOnce |= rsc->mIO.playCoreCommands(rsc, -1);
- }
-
- if ((rsc->mRootScript.get() != NULL) && rsc->mHasSurface &&
- (targetRate || drawOnce) && !rsc->mPaused) {
-
- drawOnce = false;
- targetRate = ((rsc->runRootScript() + 15) / 16);
-
- if (rsc->props.mLogVisual) {
- rsc->displayDebugStats();
- }
-
- rsc->timerSet(RS_TIMER_CLEAR_SWAP);
- rsc->mHal.funcs.swap(rsc);
- rsc->timerFrame();
- rsc->timerSet(RS_TIMER_INTERNAL);
- rsc->timerPrint();
- rsc->timerReset();
- }
- }
- }
-
- ALOGV("%p RS Thread exiting", rsc);
-
- if (rsc->mIsGraphicsContext) {
- pthread_mutex_lock(&gInitMutex);
- rsc->deinitEGL();
- pthread_mutex_unlock(&gInitMutex);
- }
-
- ALOGV("%p RS Thread exited", rsc);
- return NULL;
-}
-
-void Context::destroyWorkerThreadResources() {
- //ALOGV("destroyWorkerThreadResources 1");
- ObjectBase::zeroAllUserRef(this);
- if (mIsGraphicsContext) {
- mRaster.clear();
- mFragment.clear();
- mVertex.clear();
- mFragmentStore.clear();
- mFont.clear();
- mRootScript.clear();
- mStateRaster.deinit(this);
- mStateVertex.deinit(this);
- mStateFragment.deinit(this);
- mStateFragmentStore.deinit(this);
- mStateFont.deinit(this);
- mStateSampler.deinit(this);
- mFBOCache.deinit(this);
- }
- ObjectBase::freeAllChildren(this);
- mExit = true;
- //ALOGV("destroyWorkerThreadResources 2");
-}
-
-void Context::printWatchdogInfo(void *ctx) {
- Context *rsc = (Context *)ctx;
- if (rsc->watchdog.command && rsc->watchdog.file) {
- ALOGE("RS watchdog timeout: %i %s line %i %s", rsc->watchdog.inRoot,
- rsc->watchdog.command, rsc->watchdog.line, rsc->watchdog.file);
- } else {
- ALOGE("RS watchdog timeout: %i", rsc->watchdog.inRoot);
- }
-}
-
-
-void Context::setPriority(int32_t p) {
- // Note: If we put this in the proper "background" policy
- // the wallpapers can become completly unresponsive at times.
- // This is probably not what we want for something the user is actively
- // looking at.
- mThreadPriority = p;
- setpriority(PRIO_PROCESS, mNativeThreadId, p);
- mHal.funcs.setPriority(this, mThreadPriority);
-}
-
-Context::Context() {
- mDev = NULL;
- mRunning = false;
- mExit = false;
- mPaused = false;
- mObjHead = NULL;
- mError = RS_ERROR_NONE;
- mTargetSdkVersion = 14;
- mDPI = 96;
- mIsContextLite = false;
- memset(&watchdog, 0, sizeof(watchdog));
-}
-
-Context * Context::createContext(Device *dev, const RsSurfaceConfig *sc) {
- Context * rsc = new Context();
-
- if (!rsc->initContext(dev, sc)) {
- delete rsc;
- return NULL;
- }
- return rsc;
-}
-
-Context * Context::createContextLite() {
- Context * rsc = new Context();
- rsc->mIsContextLite = true;
- return rsc;
-}
-
-bool Context::initContext(Device *dev, const RsSurfaceConfig *sc) {
- pthread_mutex_lock(&gInitMutex);
-
- mIO.init();
- mIO.setTimeoutCallback(printWatchdogInfo, this, 2e9);
-
- dev->addContext(this);
- mDev = dev;
- if (sc) {
- mUserSurfaceConfig = *sc;
- } else {
- memset(&mUserSurfaceConfig, 0, sizeof(mUserSurfaceConfig));
- }
-
- mIsGraphicsContext = sc != NULL;
-
- int status;
- pthread_attr_t threadAttr;
-
- pthread_mutex_unlock(&gInitMutex);
-
- // Global init done at this point.
-
- status = pthread_attr_init(&threadAttr);
- if (status) {
- ALOGE("Failed to init thread attribute.");
- return false;
- }
-
- mHasSurface = false;
-
- timerInit();
- timerSet(RS_TIMER_INTERNAL);
-
- status = pthread_create(&mThreadId, &threadAttr, threadProc, this);
- if (status) {
- ALOGE("Failed to start rs context thread.");
- return false;
- }
- while (!mRunning && (mError == RS_ERROR_NONE)) {
- usleep(100);
- }
-
- if (mError != RS_ERROR_NONE) {
- ALOGE("Errors during thread init");
- return false;
- }
-
- pthread_attr_destroy(&threadAttr);
- return true;
-}
-
-Context::~Context() {
- ALOGV("%p Context::~Context", this);
-
- if (!mIsContextLite) {
- mPaused = false;
- void *res;
-
- mIO.shutdown();
- int status = pthread_join(mThreadId, &res);
- rsAssert(mExit);
-
- if (mHal.funcs.shutdownDriver) {
- mHal.funcs.shutdownDriver(this);
- }
-
- // Global structure cleanup.
- pthread_mutex_lock(&gInitMutex);
- if (mDev) {
- mDev->removeContext(this);
- mDev = NULL;
- }
- pthread_mutex_unlock(&gInitMutex);
- }
- ALOGV("%p Context::~Context done", this);
-}
-
-void Context::setSurface(uint32_t w, uint32_t h, RsNativeWindow sur) {
- rsAssert(mIsGraphicsContext);
- mHal.funcs.setSurface(this, w, h, sur);
-
- mHasSurface = sur != NULL;
- mWidth = w;
- mHeight = h;
-
- if (mWidth && mHeight) {
- mStateVertex.updateSize(this);
- mFBOCache.updateSize();
- }
-}
-
-uint32_t Context::getCurrentSurfaceWidth() const {
- for (uint32_t i = 0; i < mFBOCache.mHal.state.colorTargetsCount; i ++) {
- if (mFBOCache.mHal.state.colorTargets[i] != NULL) {
- return mFBOCache.mHal.state.colorTargets[i]->getType()->getDimX();
- }
- }
- if (mFBOCache.mHal.state.depthTarget != NULL) {
- return mFBOCache.mHal.state.depthTarget->getType()->getDimX();
- }
- return mWidth;
-}
-
-uint32_t Context::getCurrentSurfaceHeight() const {
- for (uint32_t i = 0; i < mFBOCache.mHal.state.colorTargetsCount; i ++) {
- if (mFBOCache.mHal.state.colorTargets[i] != NULL) {
- return mFBOCache.mHal.state.colorTargets[i]->getType()->getDimY();
- }
- }
- if (mFBOCache.mHal.state.depthTarget != NULL) {
- return mFBOCache.mHal.state.depthTarget->getType()->getDimY();
- }
- return mHeight;
-}
-
-void Context::pause() {
- rsAssert(mIsGraphicsContext);
- mPaused = true;
-}
-
-void Context::resume() {
- rsAssert(mIsGraphicsContext);
- mPaused = false;
-}
-
-void Context::setRootScript(Script *s) {
- rsAssert(mIsGraphicsContext);
- mRootScript.set(s);
-}
-
-void Context::setProgramStore(ProgramStore *pfs) {
- rsAssert(mIsGraphicsContext);
- if (pfs == NULL) {
- mFragmentStore.set(mStateFragmentStore.mDefault);
- } else {
- mFragmentStore.set(pfs);
- }
-}
-
-void Context::setProgramFragment(ProgramFragment *pf) {
- rsAssert(mIsGraphicsContext);
- if (pf == NULL) {
- mFragment.set(mStateFragment.mDefault);
- } else {
- mFragment.set(pf);
- }
-}
-
-void Context::setProgramRaster(ProgramRaster *pr) {
- rsAssert(mIsGraphicsContext);
- if (pr == NULL) {
- mRaster.set(mStateRaster.mDefault);
- } else {
- mRaster.set(pr);
- }
-}
-
-void Context::setProgramVertex(ProgramVertex *pv) {
- rsAssert(mIsGraphicsContext);
- if (pv == NULL) {
- mVertex.set(mStateVertex.mDefault);
- } else {
- mVertex.set(pv);
- }
-}
-
-void Context::setFont(Font *f) {
- rsAssert(mIsGraphicsContext);
- if (f == NULL) {
- mFont.set(mStateFont.mDefault);
- } else {
- mFont.set(f);
- }
-}
-
-void Context::assignName(ObjectBase *obj, const char *name, uint32_t len) {
- rsAssert(!obj->getName());
- obj->setName(name, len);
- mNames.add(obj);
-}
-
-void Context::removeName(ObjectBase *obj) {
- for (size_t ct=0; ct < mNames.size(); ct++) {
- if (obj == mNames[ct]) {
- mNames.removeAt(ct);
- return;
- }
- }
-}
-
-RsMessageToClientType Context::peekMessageToClient(size_t *receiveLen, uint32_t *subID) {
- return (RsMessageToClientType)mIO.getClientHeader(receiveLen, subID);
-}
-
-RsMessageToClientType Context::getMessageToClient(void *data, size_t *receiveLen, uint32_t *subID, size_t bufferLen) {
- return (RsMessageToClientType)mIO.getClientPayload(data, receiveLen, subID, bufferLen);
-}
-
-bool Context::sendMessageToClient(const void *data, RsMessageToClientType cmdID,
- uint32_t subID, size_t len, bool waitForSpace) const {
-
- return mIO.sendToClient(cmdID, subID, data, len, waitForSpace);
-}
-
-void Context::initToClient() {
- while (!mRunning) {
- usleep(100);
- }
-}
-
-void Context::deinitToClient() {
- mIO.clientShutdown();
-}
-
-void Context::setError(RsError e, const char *msg) const {
- mError = e;
- sendMessageToClient(msg, RS_MESSAGE_TO_CLIENT_ERROR, e, strlen(msg) + 1, true);
-}
-
-
-void Context::dumpDebug() const {
- ALOGE("RS Context debug %p", this);
- ALOGE("RS Context debug");
-
- ALOGE(" RS width %i, height %i", mWidth, mHeight);
- ALOGE(" RS running %i, exit %i, paused %i", mRunning, mExit, mPaused);
- ALOGE(" RS pThreadID %li, nativeThreadID %i", (long int)mThreadId, mNativeThreadId);
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-//
-
-namespace android {
-namespace renderscript {
-
-void rsi_ContextFinish(Context *rsc) {
-}
-
-void rsi_ContextBindRootScript(Context *rsc, RsScript vs) {
- Script *s = static_cast<Script *>(vs);
- rsc->setRootScript(s);
-}
-
-void rsi_ContextBindSampler(Context *rsc, uint32_t slot, RsSampler vs) {
- Sampler *s = static_cast<Sampler *>(vs);
-
- if (slot > RS_MAX_SAMPLER_SLOT) {
- ALOGE("Invalid sampler slot");
- return;
- }
-
- s->bindToContext(&rsc->mStateSampler, slot);
-}
-
-void rsi_ContextBindProgramStore(Context *rsc, RsProgramStore vpfs) {
- ProgramStore *pfs = static_cast<ProgramStore *>(vpfs);
- rsc->setProgramStore(pfs);
-}
-
-void rsi_ContextBindProgramFragment(Context *rsc, RsProgramFragment vpf) {
- ProgramFragment *pf = static_cast<ProgramFragment *>(vpf);
- rsc->setProgramFragment(pf);
-}
-
-void rsi_ContextBindProgramRaster(Context *rsc, RsProgramRaster vpr) {
- ProgramRaster *pr = static_cast<ProgramRaster *>(vpr);
- rsc->setProgramRaster(pr);
-}
-
-void rsi_ContextBindProgramVertex(Context *rsc, RsProgramVertex vpv) {
- ProgramVertex *pv = static_cast<ProgramVertex *>(vpv);
- rsc->setProgramVertex(pv);
-}
-
-void rsi_ContextBindFont(Context *rsc, RsFont vfont) {
- Font *font = static_cast<Font *>(vfont);
- rsc->setFont(font);
-}
-
-void rsi_AssignName(Context *rsc, RsObjectBase obj, const char *name, size_t name_length) {
- ObjectBase *ob = static_cast<ObjectBase *>(obj);
- rsc->assignName(ob, name, name_length);
-}
-
-void rsi_ObjDestroy(Context *rsc, void *optr) {
- ObjectBase *ob = static_cast<ObjectBase *>(optr);
- rsc->removeName(ob);
- ob->decUserRef();
-}
-
-void rsi_ContextPause(Context *rsc) {
- rsc->pause();
-}
-
-void rsi_ContextResume(Context *rsc) {
- rsc->resume();
-}
-
-void rsi_ContextSetSurface(Context *rsc, uint32_t w, uint32_t h, RsNativeWindow sur) {
- rsc->setSurface(w, h, sur);
-}
-
-void rsi_ContextSetPriority(Context *rsc, int32_t p) {
- rsc->setPriority(p);
-}
-
-void rsi_ContextDump(Context *rsc, int32_t bits) {
- ObjectBase::dumpAll(rsc);
-}
-
-void rsi_ContextDestroyWorker(Context *rsc) {
- rsc->destroyWorkerThreadResources();
-}
-
-void rsi_ContextDestroy(Context *rsc) {
- ALOGV("%p rsContextDestroy", rsc);
- rsContextDestroyWorker(rsc);
- delete rsc;
- ALOGV("%p rsContextDestroy done", rsc);
-}
-
-
-RsMessageToClientType rsi_ContextPeekMessage(Context *rsc,
- size_t * receiveLen, size_t receiveLen_length,
- uint32_t * subID, size_t subID_length) {
- return rsc->peekMessageToClient(receiveLen, subID);
-}
-
-RsMessageToClientType rsi_ContextGetMessage(Context *rsc, void * data, size_t data_length,
- size_t * receiveLen, size_t receiveLen_length,
- uint32_t * subID, size_t subID_length) {
- rsAssert(subID_length == sizeof(uint32_t));
- rsAssert(receiveLen_length == sizeof(size_t));
- return rsc->getMessageToClient(data, receiveLen, subID, data_length);
-}
-
-void rsi_ContextInitToClient(Context *rsc) {
- rsc->initToClient();
-}
-
-void rsi_ContextDeinitToClient(Context *rsc) {
- rsc->deinitToClient();
-}
-
-}
-}
-
-RsContext rsContextCreate(RsDevice vdev, uint32_t version,
- uint32_t sdkVersion) {
- ALOGV("rsContextCreate dev=%p", vdev);
- Device * dev = static_cast<Device *>(vdev);
- Context *rsc = Context::createContext(dev, NULL);
- if (rsc) {
- rsc->setTargetSdkVersion(sdkVersion);
- }
- return rsc;
-}
-
-RsContext rsContextCreateGL(RsDevice vdev, uint32_t version,
- uint32_t sdkVersion, RsSurfaceConfig sc,
- uint32_t dpi) {
- ALOGV("rsContextCreateGL dev=%p", vdev);
- Device * dev = static_cast<Device *>(vdev);
- Context *rsc = Context::createContext(dev, &sc);
- if (rsc) {
- rsc->setTargetSdkVersion(sdkVersion);
- rsc->setDPI(dpi);
- }
- ALOGV("%p rsContextCreateGL ret", rsc);
- return rsc;
-}
-
-// Only to be called at a3d load time, before object is visible to user
-// not thread safe
-void rsaGetName(RsContext con, void * obj, const char **name) {
- ObjectBase *ob = static_cast<ObjectBase *>(obj);
- (*name) = ob->getName();
-}
diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h
deleted file mode 100644
index de110c6..0000000
--- a/libs/rs/rsContext.h
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef ANDROID_RS_CONTEXT_H
-#define ANDROID_RS_CONTEXT_H
-
-#include "rsUtils.h"
-#include "rs_hal.h"
-
-#include "rsThreadIO.h"
-#include "rsScriptC.h"
-#include "rsSampler.h"
-#include "rsFont.h"
-#include "rsPath.h"
-#include "rsProgramFragment.h"
-#include "rsProgramStore.h"
-#include "rsProgramRaster.h"
-#include "rsProgramVertex.h"
-#include "rsFBOCache.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-
-namespace renderscript {
-
-class Device;
-
-#if 0
-#define CHECK_OBJ(o) { \
- GET_TLS(); \
- if (!ObjectBase::isValid(rsc, (const ObjectBase *)o)) { \
- ALOGE("Bad object %p at %s, %i", o, __FILE__, __LINE__); \
- } \
-}
-#define CHECK_OBJ_OR_NULL(o) { \
- GET_TLS(); \
- if (o && !ObjectBase::isValid(rsc, (const ObjectBase *)o)) { \
- ALOGE("Bad object %p at %s, %i", o, __FILE__, __LINE__); \
- } \
-}
-#else
-#define CHECK_OBJ(o)
-#define CHECK_OBJ_OR_NULL(o)
-#endif
-
-class Context {
-public:
- struct Hal {
- void * drv;
-
- RsdHalFunctions funcs;
- };
- Hal mHal;
-
- static Context * createContext(Device *, const RsSurfaceConfig *sc);
- static Context * createContextLite();
- ~Context();
-
- static pthread_mutex_t gInitMutex;
- // Library mutex (for providing thread-safe calls from the runtime)
- static pthread_mutex_t gLibMutex;
-
- class PushState {
- public:
- PushState(Context *);
- ~PushState();
-
- private:
- ObjectBaseRef<ProgramFragment> mFragment;
- ObjectBaseRef<ProgramVertex> mVertex;
- ObjectBaseRef<ProgramStore> mStore;
- ObjectBaseRef<ProgramRaster> mRaster;
- ObjectBaseRef<Font> mFont;
- Context *mRsc;
- };
-
- RsSurfaceConfig mUserSurfaceConfig;
-
- ElementState mStateElement;
- TypeState mStateType;
- SamplerState mStateSampler;
- ProgramFragmentState mStateFragment;
- ProgramStoreState mStateFragmentStore;
- ProgramRasterState mStateRaster;
- ProgramVertexState mStateVertex;
- FontState mStateFont;
-
- ScriptCState mScriptC;
- FBOCache mFBOCache;
-
- void swapBuffers();
- void setRootScript(Script *);
- void setProgramRaster(ProgramRaster *);
- void setProgramVertex(ProgramVertex *);
- void setProgramFragment(ProgramFragment *);
- void setProgramStore(ProgramStore *);
- void setFont(Font *);
-
- void updateSurface(void *sur);
-
- ProgramFragment * getProgramFragment() {return mFragment.get();}
- ProgramStore * getProgramStore() {return mFragmentStore.get();}
- ProgramRaster * getProgramRaster() {return mRaster.get();}
- ProgramVertex * getProgramVertex() {return mVertex.get();}
- Font * getFont() {return mFont.get();}
-
- bool setupCheck();
- void setupProgramStore();
-
- void pause();
- void resume();
- void setSurface(uint32_t w, uint32_t h, RsNativeWindow sur);
- void setPriority(int32_t p);
- void destroyWorkerThreadResources();
-
- void assignName(ObjectBase *obj, const char *name, uint32_t len);
- void removeName(ObjectBase *obj);
-
- RsMessageToClientType peekMessageToClient(size_t *receiveLen, uint32_t *subID);
- RsMessageToClientType getMessageToClient(void *data, size_t *receiveLen, uint32_t *subID, size_t bufferLen);
- bool sendMessageToClient(const void *data, RsMessageToClientType cmdID, uint32_t subID, size_t len, bool waitForSpace) const;
- uint32_t runScript(Script *s);
-
- void initToClient();
- void deinitToClient();
-
- ProgramFragment * getDefaultProgramFragment() const {
- return mStateFragment.mDefault.get();
- }
- ProgramVertex * getDefaultProgramVertex() const {
- return mStateVertex.mDefault.get();
- }
- ProgramStore * getDefaultProgramStore() const {
- return mStateFragmentStore.mDefault.get();
- }
- ProgramRaster * getDefaultProgramRaster() const {
- return mStateRaster.mDefault.get();
- }
- Font* getDefaultFont() const {
- return mStateFont.mDefault.get();
- }
-
- uint32_t getWidth() const {return mWidth;}
- uint32_t getHeight() const {return mHeight;}
-
- uint32_t getCurrentSurfaceWidth() const;
- uint32_t getCurrentSurfaceHeight() const;
-
- mutable ThreadIO mIO;
-
- // Timers
- enum Timers {
- RS_TIMER_IDLE,
- RS_TIMER_INTERNAL,
- RS_TIMER_SCRIPT,
- RS_TIMER_CLEAR_SWAP,
- _RS_TIMER_TOTAL
- };
- uint64_t getTime() const;
- void timerInit();
- void timerReset();
- void timerSet(Timers);
- void timerPrint();
- void timerFrame();
-
- struct {
- bool mLogTimes;
- bool mLogScripts;
- bool mLogObjects;
- bool mLogShaders;
- bool mLogShadersAttr;
- bool mLogShadersUniforms;
- bool mLogVisual;
- uint32_t mDebugMaxThreads;
- } props;
-
- mutable struct {
- bool inRoot;
- const char *command;
- const char *file;
- uint32_t line;
- } watchdog;
- static void printWatchdogInfo(void *ctx);
- void setWatchdogGL(const char *cmd, uint32_t line, const char *file) const {
- watchdog.command = cmd;
- watchdog.file = file;
- watchdog.line = line;
- }
-
- void dumpDebug() const;
- void setError(RsError e, const char *msg = NULL) const;
-
- mutable const ObjectBase * mObjHead;
-
- uint32_t getDPI() const {return mDPI;}
- void setDPI(uint32_t dpi) {mDPI = dpi;}
-
- uint32_t getTargetSdkVersion() const {return mTargetSdkVersion;}
- void setTargetSdkVersion(uint32_t sdkVer) {mTargetSdkVersion = sdkVer;}
-
- Device *mDev;
-protected:
-
- uint32_t mTargetSdkVersion;
- uint32_t mDPI;
- uint32_t mWidth;
- uint32_t mHeight;
- int32_t mThreadPriority;
- bool mIsGraphicsContext;
-
- bool mRunning;
- bool mExit;
- bool mPaused;
- mutable RsError mError;
-
- pthread_t mThreadId;
- pid_t mNativeThreadId;
-
- ObjectBaseRef<Script> mRootScript;
- ObjectBaseRef<ProgramFragment> mFragment;
- ObjectBaseRef<ProgramVertex> mVertex;
- ObjectBaseRef<ProgramStore> mFragmentStore;
- ObjectBaseRef<ProgramRaster> mRaster;
- ObjectBaseRef<Font> mFont;
-
- void displayDebugStats();
-
-private:
- Context();
- bool initContext(Device *, const RsSurfaceConfig *sc);
-
-
- bool initGLThread();
- void deinitEGL();
-
- uint32_t runRootScript();
-
- static void * threadProc(void *);
- static void * helperThreadProc(void *);
-
- bool mHasSurface;
- bool mIsContextLite;
-
- Vector<ObjectBase *> mNames;
-
- uint64_t mTimers[_RS_TIMER_TOTAL];
- Timers mTimerActive;
- uint64_t mTimeLast;
- uint64_t mTimeFrame;
- uint64_t mTimeLastFrame;
- uint32_t mTimeMSLastFrame;
- uint32_t mTimeMSLastScript;
- uint32_t mTimeMSLastSwap;
- uint32_t mAverageFPSFrameCount;
- uint64_t mAverageFPSStartTime;
- uint32_t mAverageFPS;
-};
-
-} // renderscript
-} // android
-#endif
diff --git a/libs/rs/rsDefines.h b/libs/rs/rsDefines.h
deleted file mode 100644
index 0e0cd8d..0000000
--- a/libs/rs/rsDefines.h
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * Copyright (C) 2007-2012 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.
- */
-
-#ifndef RENDER_SCRIPT_DEFINES_H
-#define RENDER_SCRIPT_DEFINES_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-//////////////////////////////////////////////////////
-//
-
-typedef void * RsAsyncVoidPtr;
-
-typedef void * RsAdapter1D;
-typedef void * RsAdapter2D;
-typedef void * RsAllocation;
-typedef void * RsAnimation;
-typedef void * RsContext;
-typedef void * RsDevice;
-typedef void * RsElement;
-typedef void * RsFile;
-typedef void * RsFont;
-typedef void * RsSampler;
-typedef void * RsScript;
-typedef void * RsMesh;
-typedef void * RsPath;
-typedef void * RsType;
-typedef void * RsObjectBase;
-
-typedef void * RsProgram;
-typedef void * RsProgramVertex;
-typedef void * RsProgramFragment;
-typedef void * RsProgramStore;
-typedef void * RsProgramRaster;
-
-typedef void * RsNativeWindow;
-
-typedef void (* RsBitmapCallback_t)(void *);
-
-typedef struct {
- float m[16];
-} rs_matrix4x4;
-
-typedef struct {
- float m[9];
-} rs_matrix3x3;
-
-typedef struct {
- float m[4];
-} rs_matrix2x2;
-
-enum RsDeviceParam {
- RS_DEVICE_PARAM_FORCE_SOFTWARE_GL,
- RS_DEVICE_PARAM_COUNT
-};
-
-typedef struct {
- uint32_t colorMin;
- uint32_t colorPref;
- uint32_t alphaMin;
- uint32_t alphaPref;
- uint32_t depthMin;
- uint32_t depthPref;
- uint32_t stencilMin;
- uint32_t stencilPref;
- uint32_t samplesMin;
- uint32_t samplesPref;
- float samplesQ;
-} RsSurfaceConfig;
-
-enum RsMessageToClientType {
- RS_MESSAGE_TO_CLIENT_NONE = 0,
- RS_MESSAGE_TO_CLIENT_EXCEPTION = 1,
- RS_MESSAGE_TO_CLIENT_RESIZE = 2,
- RS_MESSAGE_TO_CLIENT_ERROR = 3,
- RS_MESSAGE_TO_CLIENT_USER = 4
-};
-
-enum RsAllocationUsageType {
- RS_ALLOCATION_USAGE_SCRIPT = 0x0001,
- RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE = 0x0002,
- RS_ALLOCATION_USAGE_GRAPHICS_VERTEX = 0x0004,
- RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS = 0x0008,
- RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET = 0x0010,
- RS_ALLOCATION_USAGE_IO_INPUT = 0x0020,
- RS_ALLOCATION_USAGE_IO_OUTPUT = 0x0040,
-
- RS_ALLOCATION_USAGE_ALL = 0x00FF
-};
-
-enum RsAllocationMipmapControl {
- RS_ALLOCATION_MIPMAP_NONE = 0,
- RS_ALLOCATION_MIPMAP_FULL = 1,
- RS_ALLOCATION_MIPMAP_ON_SYNC_TO_TEXTURE = 2
-};
-
-enum RsAllocationCubemapFace {
- RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X = 0,
- RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_X = 1,
- RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Y = 2,
- RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Y = 3,
- RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Z = 4,
- RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Z = 5
-};
-
-enum RsDataType {
- RS_TYPE_NONE,
- RS_TYPE_FLOAT_16,
- RS_TYPE_FLOAT_32,
- RS_TYPE_FLOAT_64,
- RS_TYPE_SIGNED_8,
- RS_TYPE_SIGNED_16,
- RS_TYPE_SIGNED_32,
- RS_TYPE_SIGNED_64,
- RS_TYPE_UNSIGNED_8,
- RS_TYPE_UNSIGNED_16,
- RS_TYPE_UNSIGNED_32,
- RS_TYPE_UNSIGNED_64,
-
- RS_TYPE_BOOLEAN,
-
- RS_TYPE_UNSIGNED_5_6_5,
- RS_TYPE_UNSIGNED_5_5_5_1,
- RS_TYPE_UNSIGNED_4_4_4_4,
-
- RS_TYPE_MATRIX_4X4,
- RS_TYPE_MATRIX_3X3,
- RS_TYPE_MATRIX_2X2,
-
- RS_TYPE_ELEMENT = 1000,
- RS_TYPE_TYPE,
- RS_TYPE_ALLOCATION,
- RS_TYPE_SAMPLER,
- RS_TYPE_SCRIPT,
- RS_TYPE_MESH,
- RS_TYPE_PROGRAM_FRAGMENT,
- RS_TYPE_PROGRAM_VERTEX,
- RS_TYPE_PROGRAM_RASTER,
- RS_TYPE_PROGRAM_STORE,
-
- RS_TYPE_INVALID = 10000,
-};
-
-enum RsDataKind {
- RS_KIND_USER,
-
- RS_KIND_PIXEL_L = 7,
- RS_KIND_PIXEL_A,
- RS_KIND_PIXEL_LA,
- RS_KIND_PIXEL_RGB,
- RS_KIND_PIXEL_RGBA,
- RS_KIND_PIXEL_DEPTH,
-
- RS_KIND_INVALID = 100,
-};
-
-enum RsSamplerParam {
- RS_SAMPLER_MIN_FILTER,
- RS_SAMPLER_MAG_FILTER,
- RS_SAMPLER_WRAP_S,
- RS_SAMPLER_WRAP_T,
- RS_SAMPLER_WRAP_R,
- RS_SAMPLER_ANISO
-};
-
-enum RsSamplerValue {
- RS_SAMPLER_NEAREST,
- RS_SAMPLER_LINEAR,
- RS_SAMPLER_LINEAR_MIP_LINEAR,
- RS_SAMPLER_WRAP,
- RS_SAMPLER_CLAMP,
- RS_SAMPLER_LINEAR_MIP_NEAREST,
-
- RS_SAMPLER_INVALID = 100,
-};
-
-enum RsTextureTarget {
- RS_TEXTURE_2D,
- RS_TEXTURE_CUBE
-};
-
-enum RsDimension {
- RS_DIMENSION_X,
- RS_DIMENSION_Y,
- RS_DIMENSION_Z,
- RS_DIMENSION_LOD,
- RS_DIMENSION_FACE,
-
- RS_DIMENSION_ARRAY_0 = 100,
- RS_DIMENSION_ARRAY_1,
- RS_DIMENSION_ARRAY_2,
- RS_DIMENSION_ARRAY_3,
- RS_DIMENSION_MAX = RS_DIMENSION_ARRAY_3
-};
-
-enum RsDepthFunc {
- RS_DEPTH_FUNC_ALWAYS,
- RS_DEPTH_FUNC_LESS,
- RS_DEPTH_FUNC_LEQUAL,
- RS_DEPTH_FUNC_GREATER,
- RS_DEPTH_FUNC_GEQUAL,
- RS_DEPTH_FUNC_EQUAL,
- RS_DEPTH_FUNC_NOTEQUAL
-};
-
-enum RsBlendSrcFunc {
- RS_BLEND_SRC_ZERO, // 0
- RS_BLEND_SRC_ONE, // 1
- RS_BLEND_SRC_DST_COLOR, // 2
- RS_BLEND_SRC_ONE_MINUS_DST_COLOR, // 3
- RS_BLEND_SRC_SRC_ALPHA, // 4
- RS_BLEND_SRC_ONE_MINUS_SRC_ALPHA, // 5
- RS_BLEND_SRC_DST_ALPHA, // 6
- RS_BLEND_SRC_ONE_MINUS_DST_ALPHA, // 7
- RS_BLEND_SRC_SRC_ALPHA_SATURATE, // 8
- RS_BLEND_SRC_INVALID = 100,
-};
-
-enum RsBlendDstFunc {
- RS_BLEND_DST_ZERO, // 0
- RS_BLEND_DST_ONE, // 1
- RS_BLEND_DST_SRC_COLOR, // 2
- RS_BLEND_DST_ONE_MINUS_SRC_COLOR, // 3
- RS_BLEND_DST_SRC_ALPHA, // 4
- RS_BLEND_DST_ONE_MINUS_SRC_ALPHA, // 5
- RS_BLEND_DST_DST_ALPHA, // 6
- RS_BLEND_DST_ONE_MINUS_DST_ALPHA, // 7
-
- RS_BLEND_DST_INVALID = 100,
-};
-
-enum RsTexEnvMode {
- RS_TEX_ENV_MODE_NONE,
- RS_TEX_ENV_MODE_REPLACE,
- RS_TEX_ENV_MODE_MODULATE,
- RS_TEX_ENV_MODE_DECAL
-};
-
-enum RsProgramParam {
- RS_PROGRAM_PARAM_INPUT,
- RS_PROGRAM_PARAM_OUTPUT,
- RS_PROGRAM_PARAM_CONSTANT,
- RS_PROGRAM_PARAM_TEXTURE_TYPE,
-};
-
-enum RsPrimitive {
- RS_PRIMITIVE_POINT,
- RS_PRIMITIVE_LINE,
- RS_PRIMITIVE_LINE_STRIP,
- RS_PRIMITIVE_TRIANGLE,
- RS_PRIMITIVE_TRIANGLE_STRIP,
- RS_PRIMITIVE_TRIANGLE_FAN,
-
- RS_PRIMITIVE_INVALID = 100,
-};
-
-enum RsPathPrimitive {
- RS_PATH_PRIMITIVE_QUADRATIC_BEZIER,
- RS_PATH_PRIMITIVE_CUBIC_BEZIER
-};
-
-enum RsError {
- RS_ERROR_NONE = 0,
- RS_ERROR_BAD_SHADER = 1,
- RS_ERROR_BAD_SCRIPT = 2,
- RS_ERROR_BAD_VALUE = 3,
- RS_ERROR_OUT_OF_MEMORY = 4,
- RS_ERROR_DRIVER = 5,
-
- RS_ERROR_FATAL_UNKNOWN = 0x1000,
- RS_ERROR_FATAL_DRIVER = 0x1001,
- RS_ERROR_FATAL_PROGRAM_LINK = 0x1002
-};
-
-enum RsAnimationInterpolation {
- RS_ANIMATION_INTERPOLATION_STEP,
- RS_ANIMATION_INTERPOLATION_LINEAR,
- RS_ANIMATION_INTERPOLATION_BEZIER,
- RS_ANIMATION_INTERPOLATION_CARDINAL,
- RS_ANIMATION_INTERPOLATION_HERMITE,
- RS_ANIMATION_INTERPOLATION_BSPLINE
-};
-
-enum RsAnimationEdge {
- RS_ANIMATION_EDGE_UNDEFINED,
- RS_ANIMATION_EDGE_CONSTANT,
- RS_ANIMATION_EDGE_GRADIENT,
- RS_ANIMATION_EDGE_CYCLE,
- RS_ANIMATION_EDGE_OSCILLATE,
- RS_ANIMATION_EDGE_CYLE_RELATIVE
-};
-
-enum RsA3DClassID {
- RS_A3D_CLASS_ID_UNKNOWN,
- RS_A3D_CLASS_ID_MESH,
- RS_A3D_CLASS_ID_TYPE,
- RS_A3D_CLASS_ID_ELEMENT,
- RS_A3D_CLASS_ID_ALLOCATION,
- RS_A3D_CLASS_ID_PROGRAM_VERTEX,
- RS_A3D_CLASS_ID_PROGRAM_RASTER,
- RS_A3D_CLASS_ID_PROGRAM_FRAGMENT,
- RS_A3D_CLASS_ID_PROGRAM_STORE,
- RS_A3D_CLASS_ID_SAMPLER,
- RS_A3D_CLASS_ID_ANIMATION,
- RS_A3D_CLASS_ID_ADAPTER_1D,
- RS_A3D_CLASS_ID_ADAPTER_2D,
- RS_A3D_CLASS_ID_SCRIPT_C
-};
-
-enum RsCullMode {
- RS_CULL_BACK,
- RS_CULL_FRONT,
- RS_CULL_NONE,
- RS_CULL_INVALID = 100,
-};
-
-typedef struct {
- RsA3DClassID classID;
- const char* objectName;
-} RsFileIndexEntry;
-
-// Script to Script
-typedef struct {
- uint32_t xStart;
- uint32_t xEnd;
- uint32_t yStart;
- uint32_t yEnd;
- uint32_t zStart;
- uint32_t zEnd;
- uint32_t arrayStart;
- uint32_t arrayEnd;
-
-} RsScriptCall;
-
-#ifdef __cplusplus
-};
-#endif
-
-#endif // RENDER_SCRIPT_DEFINES_H
-
-
-
-
diff --git a/libs/rs/rsDevice.cpp b/libs/rs/rsDevice.cpp
deleted file mode 100644
index d7d03f6..0000000
--- a/libs/rs/rsDevice.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#include "rsDevice.h"
-#include "rsContext.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-Device::Device() {
- mForceSW = false;
-}
-
-Device::~Device() {
-}
-
-void Device::addContext(Context *rsc) {
- mContexts.push(rsc);
-}
-
-void Device::removeContext(Context *rsc) {
- for (size_t idx=0; idx < mContexts.size(); idx++) {
- if (mContexts[idx] == rsc) {
- mContexts.removeAt(idx);
- break;
- }
- }
-}
-
-RsDevice rsDeviceCreate() {
- Device * d = new Device();
- return d;
-}
-
-void rsDeviceDestroy(RsDevice dev) {
- Device * d = static_cast<Device *>(dev);
- delete d;
-}
-
-void rsDeviceSetConfig(RsDevice dev, RsDeviceParam p, int32_t value) {
- Device * d = static_cast<Device *>(dev);
- if (p == RS_DEVICE_PARAM_FORCE_SOFTWARE_GL) {
- d->mForceSW = value != 0;
- return;
- }
- rsAssert(0);
-}
-
diff --git a/libs/rs/rsDevice.h b/libs/rs/rsDevice.h
deleted file mode 100644
index ffb514b..0000000
--- a/libs/rs/rsDevice.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#ifndef ANDROID_RS_DEVICE_H
-#define ANDROID_RS_DEVICE_H
-
-#include "rsUtils.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-class Context;
-
-class Device {
-public:
- Device();
- ~Device();
-
- void addContext(Context *);
- void removeContext(Context *);
-
- bool mForceSW;
-
-protected:
- Vector<Context *> mContexts;
-};
-
-}
-}
-#endif
diff --git a/libs/rs/rsElement.cpp b/libs/rs/rsElement.cpp
deleted file mode 100644
index fb2892c..0000000
--- a/libs/rs/rsElement.cpp
+++ /dev/null
@@ -1,434 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-
-#include "rsContext.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-
-Element::Element(Context *rsc) : ObjectBase(rsc) {
- mBits = 0;
- mBitsUnpadded = 0;
- mFields = NULL;
- mFieldCount = 0;
- mHasReference = false;
- memset(&mHal, 0, sizeof(mHal));
-}
-
-Element::~Element() {
- clear();
-}
-
-void Element::preDestroy() const {
- for (uint32_t ct = 0; ct < mRSC->mStateElement.mElements.size(); ct++) {
- if (mRSC->mStateElement.mElements[ct] == this) {
- mRSC->mStateElement.mElements.removeAt(ct);
- break;
- }
- }
-}
-
-void Element::clear() {
- delete [] mFields;
- mFields = NULL;
- mFieldCount = 0;
- mHasReference = false;
-
- delete [] mHal.state.fields;
- delete [] mHal.state.fieldArraySizes;
- delete [] mHal.state.fieldNames;
- delete [] mHal.state.fieldNameLengths;
- delete [] mHal.state.fieldOffsetBytes;
-}
-
-size_t Element::getSizeBits() const {
- if (!mFieldCount) {
- return mBits;
- }
-
- size_t total = 0;
- for (size_t ct=0; ct < mFieldCount; ct++) {
- total += mFields[ct].e->mBits * mFields[ct].arraySize;
- }
- return total;
-}
-
-size_t Element::getSizeBitsUnpadded() const {
- if (!mFieldCount) {
- return mBitsUnpadded;
- }
-
- size_t total = 0;
- for (size_t ct=0; ct < mFieldCount; ct++) {
- total += mFields[ct].e->mBitsUnpadded * mFields[ct].arraySize;
- }
- return total;
-}
-
-void Element::dumpLOGV(const char *prefix) const {
- ObjectBase::dumpLOGV(prefix);
- ALOGV("%s Element: fieldCount: %zu, size bytes: %zu", prefix, mFieldCount, getSizeBytes());
- mComponent.dumpLOGV(prefix);
- for (uint32_t ct = 0; ct < mFieldCount; ct++) {
- ALOGV("%s Element field index: %u ------------------", prefix, ct);
- ALOGV("%s name: %s, offsetBits: %u, arraySize: %u",
- prefix, mFields[ct].name.string(), mFields[ct].offsetBits, mFields[ct].arraySize);
- mFields[ct].e->dumpLOGV(prefix);
- }
-}
-
-void Element::serialize(OStream *stream) const {
- // Need to identify ourselves
- stream->addU32((uint32_t)getClassId());
-
- String8 name(getName());
- stream->addString(&name);
-
- mComponent.serialize(stream);
-
- // Now serialize all the fields
- stream->addU32(mFieldCount);
- for (uint32_t ct = 0; ct < mFieldCount; ct++) {
- stream->addString(&mFields[ct].name);
- stream->addU32(mFields[ct].arraySize);
- mFields[ct].e->serialize(stream);
- }
-}
-
-Element *Element::createFromStream(Context *rsc, IStream *stream) {
- // First make sure we are reading the correct object
- RsA3DClassID classID = (RsA3DClassID)stream->loadU32();
- if (classID != RS_A3D_CLASS_ID_ELEMENT) {
- ALOGE("element loading skipped due to invalid class id\n");
- return NULL;
- }
-
- String8 name;
- stream->loadString(&name);
-
- Component component;
- component.loadFromStream(stream);
-
- uint32_t fieldCount = stream->loadU32();
- if (!fieldCount) {
- return (Element *)Element::create(rsc,
- component.getType(),
- component.getKind(),
- component.getIsNormalized(),
- component.getVectorSize());;
- }
-
- const Element **subElems = new const Element *[fieldCount];
- const char **subElemNames = new const char *[fieldCount];
- size_t *subElemNamesLengths = new size_t[fieldCount];
- uint32_t *arraySizes = new uint32_t[fieldCount];
-
- String8 elemName;
- for (uint32_t ct = 0; ct < fieldCount; ct ++) {
- stream->loadString(&elemName);
- subElemNamesLengths[ct] = elemName.length();
- char *tmpName = new char[subElemNamesLengths[ct]];
- memcpy(tmpName, elemName.string(), subElemNamesLengths[ct]);
- subElemNames[ct] = tmpName;
- arraySizes[ct] = stream->loadU32();
- subElems[ct] = Element::createFromStream(rsc, stream);
- }
-
- const Element *elem = Element::create(rsc, fieldCount, subElems, subElemNames,
- subElemNamesLengths, arraySizes);
- for (uint32_t ct = 0; ct < fieldCount; ct ++) {
- delete [] subElemNames[ct];
- subElems[ct]->decUserRef();
- }
- delete[] subElems;
- delete[] subElemNames;
- delete[] subElemNamesLengths;
- delete[] arraySizes;
-
- return (Element *)elem;
-}
-
-void Element::compute() {
- mHal.state.dataType = mComponent.getType();
- mHal.state.dataKind = mComponent.getKind();
- mHal.state.vectorSize = mComponent.getVectorSize();
-
- if (mFieldCount == 0) {
- mBits = mComponent.getBits();
- mBitsUnpadded = mComponent.getBitsUnpadded();
- mHasReference = mComponent.isReference();
-
- mHal.state.elementSizeBytes = getSizeBytes();
- return;
- }
-
- uint32_t noPaddingFieldCount = 0;
- for (uint32_t ct = 0; ct < mFieldCount; ct ++) {
- if (mFields[ct].name.string()[0] != '#') {
- noPaddingFieldCount ++;
- }
- }
-
- mHal.state.fields = new const Element*[noPaddingFieldCount];
- mHal.state.fieldArraySizes = new uint32_t[noPaddingFieldCount];
- mHal.state.fieldNames = new const char*[noPaddingFieldCount];
- mHal.state.fieldNameLengths = new uint32_t[noPaddingFieldCount];
- mHal.state.fieldOffsetBytes = new uint32_t[noPaddingFieldCount];
- mHal.state.fieldsCount = noPaddingFieldCount;
-
- size_t bits = 0;
- size_t bitsUnpadded = 0;
- for (size_t ct = 0, ctNoPadding = 0; ct < mFieldCount; ct++) {
- mFields[ct].offsetBits = bits;
- mFields[ct].offsetBitsUnpadded = bitsUnpadded;
- bits += mFields[ct].e->getSizeBits() * mFields[ct].arraySize;
- bitsUnpadded += mFields[ct].e->getSizeBitsUnpadded() * mFields[ct].arraySize;
-
- if (mFields[ct].e->mHasReference) {
- mHasReference = true;
- }
-
- if (mFields[ct].name.string()[0] == '#') {
- continue;
- }
-
- mHal.state.fields[ctNoPadding] = mFields[ct].e.get();
- mHal.state.fieldArraySizes[ctNoPadding] = mFields[ct].arraySize;
- mHal.state.fieldNames[ctNoPadding] = mFields[ct].name.string();
- mHal.state.fieldNameLengths[ctNoPadding] = mFields[ct].name.length() + 1; // to include 0
- mHal.state.fieldOffsetBytes[ctNoPadding] = mFields[ct].offsetBits >> 3;
-
- ctNoPadding ++;
- }
-
- mHal.state.elementSizeBytes = getSizeBytes();
-}
-
-ObjectBaseRef<const Element> Element::createRef(Context *rsc, RsDataType dt, RsDataKind dk,
- bool isNorm, uint32_t vecSize) {
- ObjectBaseRef<const Element> returnRef;
- // Look for an existing match.
- ObjectBase::asyncLock();
- for (uint32_t ct=0; ct < rsc->mStateElement.mElements.size(); ct++) {
- const Element *ee = rsc->mStateElement.mElements[ct];
- if (!ee->getFieldCount() &&
- (ee->getComponent().getType() == dt) &&
- (ee->getComponent().getKind() == dk) &&
- (ee->getComponent().getIsNormalized() == isNorm) &&
- (ee->getComponent().getVectorSize() == vecSize)) {
- // Match
- returnRef.set(ee);
- ObjectBase::asyncUnlock();
- return ee;
- }
- }
- ObjectBase::asyncUnlock();
-
- Element *e = new Element(rsc);
- returnRef.set(e);
- e->mComponent.set(dt, dk, isNorm, vecSize);
- e->compute();
-
- ObjectBase::asyncLock();
- rsc->mStateElement.mElements.push(e);
- ObjectBase::asyncUnlock();
-
- return returnRef;
-}
-
-ObjectBaseRef<const Element> Element::createRef(Context *rsc, size_t count, const Element **ein,
- const char **nin, const size_t * lengths, const uint32_t *asin) {
-
- ObjectBaseRef<const Element> returnRef;
- // Look for an existing match.
- ObjectBase::asyncLock();
- for (uint32_t ct=0; ct < rsc->mStateElement.mElements.size(); ct++) {
- const Element *ee = rsc->mStateElement.mElements[ct];
- if (ee->getFieldCount() == count) {
- bool match = true;
- for (uint32_t i=0; i < count; i++) {
- if ((ee->mFields[i].e.get() != ein[i]) ||
- (ee->mFields[i].name.length() != lengths[i]) ||
- (ee->mFields[i].name != nin[i]) ||
- (ee->mFields[i].arraySize != asin[i])) {
- match = false;
- break;
- }
- }
- if (match) {
- returnRef.set(ee);
- ObjectBase::asyncUnlock();
- return returnRef;
- }
- }
- }
- ObjectBase::asyncUnlock();
-
- Element *e = new Element(rsc);
- returnRef.set(e);
- e->mFields = new ElementField_t [count];
- e->mFieldCount = count;
- for (size_t ct=0; ct < count; ct++) {
- e->mFields[ct].e.set(ein[ct]);
- e->mFields[ct].name.setTo(nin[ct], lengths[ct]);
- e->mFields[ct].arraySize = asin[ct];
- }
- e->compute();
-
- ObjectBase::asyncLock();
- rsc->mStateElement.mElements.push(e);
- ObjectBase::asyncUnlock();
-
- return returnRef;
-}
-
-void Element::incRefs(const void *ptr) const {
- if (!mFieldCount) {
- if (mComponent.isReference()) {
- ObjectBase *const*obp = static_cast<ObjectBase *const*>(ptr);
- ObjectBase *ob = obp[0];
- if (ob) ob->incSysRef();
- }
- return;
- }
-
- const uint8_t *p = static_cast<const uint8_t *>(ptr);
- for (uint32_t i=0; i < mFieldCount; i++) {
- if (mFields[i].e->mHasReference) {
- const uint8_t *p2 = &p[mFields[i].offsetBits >> 3];
- for (uint32_t ct=0; ct < mFields[i].arraySize; ct++) {
- mFields[i].e->incRefs(p2);
- p2 += mFields[i].e->getSizeBytes();
- }
- }
- }
-}
-
-void Element::decRefs(const void *ptr) const {
- if (!mFieldCount) {
- if (mComponent.isReference()) {
- ObjectBase *const*obp = static_cast<ObjectBase *const*>(ptr);
- ObjectBase *ob = obp[0];
- if (ob) ob->decSysRef();
- }
- return;
- }
-
- const uint8_t *p = static_cast<const uint8_t *>(ptr);
- for (uint32_t i=0; i < mFieldCount; i++) {
- if (mFields[i].e->mHasReference) {
- const uint8_t *p2 = &p[mFields[i].offsetBits >> 3];
- for (uint32_t ct=0; ct < mFields[i].arraySize; ct++) {
- mFields[i].e->decRefs(p2);
- p2 += mFields[i].e->getSizeBytes();
- }
- }
- }
-}
-
-Element::Builder::Builder() {
- const uint32_t initialCapacity = 32;
- mBuilderElementRefs.setCapacity(initialCapacity);
- mBuilderElements.setCapacity(initialCapacity);
- mBuilderNameStrings.setCapacity(initialCapacity);
- mBuilderNameLengths.setCapacity(initialCapacity);
- mBuilderArrays.setCapacity(initialCapacity);
-}
-
-void Element::Builder::add(const Element *e, const char *nameStr, uint32_t arraySize) {
- mBuilderElementRefs.push(ObjectBaseRef<const Element>(e));
- mBuilderElements.push(e);
- mBuilderNameStrings.push(nameStr);
- mBuilderNameLengths.push(strlen(nameStr));
- mBuilderArrays.push(arraySize);
-
-}
-
-ObjectBaseRef<const Element> Element::Builder::create(Context *rsc) {
- return Element::createRef(rsc, mBuilderElements.size(),
- &(mBuilderElements.editArray()[0]),
- &(mBuilderNameStrings.editArray()[0]),
- mBuilderNameLengths.editArray(),
- mBuilderArrays.editArray());
-}
-
-
-ElementState::ElementState() {
-}
-
-ElementState::~ElementState() {
- rsAssert(!mElements.size());
-}
-
-/////////////////////////////////////////
-//
-
-namespace android {
-namespace renderscript {
-
-RsElement rsi_ElementCreate(Context *rsc,
- RsDataType dt,
- RsDataKind dk,
- bool norm,
- uint32_t vecSize) {
- return (RsElement)Element::create(rsc, dt, dk, norm, vecSize);
-}
-
-
-RsElement rsi_ElementCreate2(Context *rsc,
- const RsElement * ein,
- size_t ein_length,
-
- const char ** names,
- size_t nameLengths_length,
- const size_t * nameLengths,
-
- const uint32_t * arraySizes,
- size_t arraySizes_length) {
- return (RsElement)Element::create(rsc, ein_length, (const Element **)ein,
- names, nameLengths, arraySizes);
-}
-
-}
-}
-
-void rsaElementGetNativeData(RsContext con, RsElement elem,
- uint32_t *elemData, uint32_t elemDataSize) {
- rsAssert(elemDataSize == 5);
- // we will pack mType; mKind; mNormalized; mVectorSize; NumSubElements
- Element *e = static_cast<Element *>(elem);
-
- (*elemData++) = (uint32_t)e->getType();
- (*elemData++) = (uint32_t)e->getKind();
- (*elemData++) = e->getComponent().getIsNormalized() ? 1 : 0;
- (*elemData++) = e->getComponent().getVectorSize();
- (*elemData++) = e->getFieldCount();
-}
-
-void rsaElementGetSubElements(RsContext con, RsElement elem, uint32_t *ids,
- const char **names, uint32_t *arraySizes, uint32_t dataSize) {
- Element *e = static_cast<Element *>(elem);
- rsAssert(e->getFieldCount() == dataSize);
-
- for (uint32_t i = 0; i < dataSize; i ++) {
- e->getField(i)->incUserRef();
- ids[i] = (uint32_t)e->getField(i);
- names[i] = e->getFieldName(i);
- arraySizes[i] = e->getFieldArraySize(i);
- }
-}
diff --git a/libs/rs/rsElement.h b/libs/rs/rsElement.h
deleted file mode 100644
index b86d3bc..0000000
--- a/libs/rs/rsElement.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#ifndef ANDROID_STRUCTURED_ELEMENT_H
-#define ANDROID_STRUCTURED_ELEMENT_H
-
-#include "rsComponent.h"
-#include "rsUtils.h"
-#include "rsDefines.h"
-#include "rsObjectBase.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-/*****************************************************************************
- * CAUTION
- *
- * Any layout changes for this class may require a corresponding change to be
- * made to frameworks/compile/libbcc/lib/ScriptCRT/rs_core.c, which contains
- * a partial copy of the information below.
- *
- *****************************************************************************/
-// An element is a group of Components that occupies one cell in a structure.
-class Element : public ObjectBase {
-public:
- struct Hal {
- mutable void *drv;
-
- struct State {
- RsDataType dataType;
- RsDataKind dataKind;
- uint32_t vectorSize;
- uint32_t elementSizeBytes;
-
- // Subelements
- const Element **fields;
- uint32_t *fieldArraySizes;
- const char **fieldNames;
- uint32_t *fieldNameLengths;
- uint32_t *fieldOffsetBytes;
- uint32_t fieldsCount;
- };
- State state;
- };
- Hal mHal;
-
- class Builder {
- public:
- Builder();
- void add(const Element *e, const char *nameStr, uint32_t arraySize);
- ObjectBaseRef<const Element> create(Context *rsc);
- private:
- Vector<ObjectBaseRef<const Element> > mBuilderElementRefs;
- Vector<const Element *> mBuilderElements;
- Vector<const char*> mBuilderNameStrings;
- Vector<size_t> mBuilderNameLengths;
- Vector<uint32_t> mBuilderArrays;
- };
- uint32_t getGLType() const;
- uint32_t getGLFormat() const;
-
- size_t getSizeBitsUnpadded() const;
- size_t getSizeBytesUnpadded() const {
- return (getSizeBitsUnpadded() + 7) >> 3;
- }
-
- size_t getSizeBits() const;
- size_t getSizeBytes() const {
- return (getSizeBits() + 7) >> 3;
- }
-
- size_t getFieldOffsetBits(uint32_t componentNumber) const {
- return mFields[componentNumber].offsetBits;
- }
- size_t getFieldOffsetBytes(uint32_t componentNumber) const {
- return mFields[componentNumber].offsetBits >> 3;
- }
-
- size_t getFieldOffsetBytesUnpadded(uint32_t componentNumber) const {
- return mFields[componentNumber].offsetBitsUnpadded >> 3;
- }
-
- uint32_t getFieldCount() const {return mFieldCount;}
- const Element * getField(uint32_t idx) const {return mFields[idx].e.get();}
- const char * getFieldName(uint32_t idx) const {return mFields[idx].name.string();}
- uint32_t getFieldArraySize(uint32_t idx) const {return mFields[idx].arraySize;}
-
- const Component & getComponent() const {return mComponent;}
- RsDataType getType() const {return mComponent.getType();}
- RsDataKind getKind() const {return mComponent.getKind();}
- uint32_t getBits() const {return mBits;}
- uint32_t getBitsUnpadded() const {return mBitsUnpadded;}
-
- void dumpLOGV(const char *prefix) const;
- virtual void serialize(OStream *stream) const;
- virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_ELEMENT; }
- static Element *createFromStream(Context *rsc, IStream *stream);
-
- static ObjectBaseRef<const Element> createRef(Context *rsc,
- RsDataType dt,
- RsDataKind dk,
- bool isNorm,
- uint32_t vecSize);
- static ObjectBaseRef<const Element> createRef(Context *rsc, size_t count,
- const Element **,
- const char **,
- const size_t * lengths,
- const uint32_t *asin);
-
- static const Element* create(Context *rsc,
- RsDataType dt,
- RsDataKind dk,
- bool isNorm,
- uint32_t vecSize) {
- ObjectBaseRef<const Element> elem = createRef(rsc, dt, dk, isNorm, vecSize);
- elem->incUserRef();
- return elem.get();
- }
- static const Element* create(Context *rsc, size_t count,
- const Element **ein,
- const char **nin,
- const size_t * lengths,
- const uint32_t *asin) {
- ObjectBaseRef<const Element> elem = createRef(rsc, count, ein, nin, lengths, asin);
- elem->incUserRef();
- return elem.get();
- }
-
- void incRefs(const void *) const;
- void decRefs(const void *) const;
- bool getHasReferences() const {return mHasReference;}
-
-protected:
- // deallocate any components that are part of this element.
- void clear();
-
- typedef struct {
- String8 name;
- ObjectBaseRef<const Element> e;
- uint32_t offsetBits;
- uint32_t offsetBitsUnpadded;
- uint32_t arraySize;
- } ElementField_t;
- ElementField_t *mFields;
- size_t mFieldCount;
- bool mHasReference;
-
-
- virtual ~Element();
- Element(Context *);
-
- Component mComponent;
- uint32_t mBitsUnpadded;
- uint32_t mBits;
-
- void compute();
-
- virtual void preDestroy() const;
-};
-
-
-class ElementState {
-public:
- ElementState();
- ~ElementState();
-
- // Cache of all existing elements.
- Vector<Element *> mElements;
-};
-
-
-}
-}
-#endif //ANDROID_STRUCTURED_ELEMENT_H
diff --git a/libs/rs/rsEnv.h b/libs/rs/rsEnv.h
deleted file mode 100644
index b82eaf1..0000000
--- a/libs/rs/rsEnv.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <stdint.h>
-
-
-typedef void * RsAdapter1D;
-typedef void * RsAdapter2D;
-typedef void * RsAllocation;
-typedef void * RsContext;
-typedef void * RsDevice;
-typedef void * RsElement;
-typedef void * RsSampler;
-typedef void * RsScript;
-typedef void * RsMesh;
-typedef void * RsType;
-typedef void * RsProgramFragment;
-typedef void * RsProgramStore;
-
-typedef struct {
- float m[16];
-} rsc_Matrix;
-
-
-typedef struct {
- float v[4];
-} rsc_Vector4;
-
-#define RS_PROGRAM_VERTEX_MODELVIEW_OFFSET 0
-#define RS_PROGRAM_VERTEX_PROJECTION_OFFSET 16
-#define RS_PROGRAM_VERTEX_TEXTURE_OFFSET 32
-#define RS_PROGRAM_VERTEX_MVP_OFFSET 48
diff --git a/libs/rs/rsFBOCache.cpp b/libs/rs/rsFBOCache.cpp
deleted file mode 100644
index d50f3e0..0000000
--- a/libs/rs/rsFBOCache.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#include "rsFBOCache.h"
-
-#include "rsContext.h"
-#include "rsAllocation.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-
-FBOCache::FBOCache() {
- mDirty = true;
- mHal.state.colorTargetsCount = 1;
- mHal.state.colorTargets = new Allocation*[mHal.state.colorTargetsCount];
- mColorTargets = new ObjectBaseRef<Allocation>[mHal.state.colorTargetsCount];
- resetAll(NULL);
-}
-
-FBOCache::~FBOCache() {
- delete[] mHal.state.colorTargets;
- delete[] mColorTargets;
-}
-
-void FBOCache::init(Context *rsc) {
- rsc->mHal.funcs.framebuffer.init(rsc, this);
-}
-
-void FBOCache::deinit(Context *rsc) {
- rsc->mHal.funcs.framebuffer.destroy(rsc, this);
-}
-
-void FBOCache::bindColorTarget(Context *rsc, Allocation *a, uint32_t slot) {
- if (slot >= mHal.state.colorTargetsCount) {
- ALOGE("Invalid render target index");
- return;
- }
- if (a != NULL) {
- if (!a->getIsTexture()) {
- ALOGE("Invalid Color Target");
- return;
- }
- }
- mColorTargets[slot].set(a);
- mHal.state.colorTargets[slot] = a;
- mDirty = true;
-}
-
-void FBOCache::bindDepthTarget(Context *rsc, Allocation *a) {
- if (a != NULL) {
- if (!a->getIsRenderTarget()) {
- ALOGE("Invalid Depth Target");
- return;
- }
- }
- mDepthTarget.set(a);
- mHal.state.depthTarget = a;
- mDirty = true;
-}
-
-void FBOCache::resetAll(Context *) {
- for (uint32_t i = 0; i < mHal.state.colorTargetsCount; i ++) {
- mColorTargets[i].set(NULL);
- mHal.state.colorTargets[i] = NULL;
- }
- mDepthTarget.set(NULL);
- mHal.state.depthTarget = NULL;
- mDirty = true;
-}
-
-void FBOCache::setup(Context *rsc) {
- if (!mDirty) {
- return;
- }
-
- rsc->mHal.funcs.framebuffer.setActive(rsc, this);
-
- mDirty = false;
-}
diff --git a/libs/rs/rsFBOCache.h b/libs/rs/rsFBOCache.h
deleted file mode 100644
index abb84de..0000000
--- a/libs/rs/rsFBOCache.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef ANDROID_FRAME_BUFFER_OBJECT_CACHE_H
-#define ANDROID_FRAME_BUFFER_OBJECT_CACHE_H
-
-#include "rsObjectBase.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-class Allocation;
-
-class FBOCache {
-public:
- FBOCache();
- ~FBOCache();
-
- void init(Context *rsc);
- void deinit(Context *rsc);
-
- void bindColorTarget(Context *rsc, Allocation *a, uint32_t slot);
- void bindDepthTarget(Context *, Allocation *a);
- void resetAll(Context *);
-
- void setup(Context *);
- void updateSize() { mDirty = true; }
-
- struct Hal {
- mutable void *drv;
-
- struct State {
- Allocation **colorTargets;
- uint32_t colorTargetsCount;
- Allocation *depthTarget;
- };
- State state;
- };
- Hal mHal;
-
-protected:
- ObjectBaseRef<Allocation> *mColorTargets;
- ObjectBaseRef<Allocation> mDepthTarget;
- bool mDirty;
- void checkError(Context *);
- void setColorAttachment(Context *rsc);
- void setDepthAttachment(Context *rsc);
- bool renderToFramebuffer();
-
-};
-
-} // renderscript
-} // android
-
-#endif //ANDROID_FRAME_BUFFER_OBJECT_CACHE_H
diff --git a/libs/rs/rsFifo.h b/libs/rs/rsFifo.h
deleted file mode 100644
index 911f446..0000000
--- a/libs/rs/rsFifo.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef ANDROID_RS_FIFO_H
-#define ANDROID_RS_FIFO_H
-
-
-#include "rsUtils.h"
-
-namespace android {
-namespace renderscript {
-
-
-// A simple FIFO to be used as a producer / consumer between two
-// threads. One is writer and one is reader. The common cases
-// will not require locking. It is not threadsafe for multiple
-// readers or writers by design.
-
-class Fifo {
-protected:
- Fifo();
- virtual ~Fifo();
-
-public:
- bool virtual writeAsync(const void *data, size_t bytes, bool waitForSpace = true) = 0;
- void virtual writeWaitReturn(void *ret, size_t retSize) = 0;
- size_t virtual read(void *data, size_t bytes, bool doWait = true, uint64_t timeToWait = 0) = 0;
- void virtual readReturn(const void *data, size_t bytes) = 0;
-
- void virtual flush() = 0;
-
-};
-
-}
-}
-#endif
diff --git a/libs/rs/rsFifoSocket.cpp b/libs/rs/rsFifoSocket.cpp
deleted file mode 100644
index bd511cf..0000000
--- a/libs/rs/rsFifoSocket.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#include "rsFifoSocket.h"
-#include "utils/Timers.h"
-#include "utils/StopWatch.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <unistd.h>
-#include <poll.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-
-using namespace android;
-using namespace android::renderscript;
-
-FifoSocket::FifoSocket() {
- mShutdown = false;
-}
-
-FifoSocket::~FifoSocket() {
-
-}
-
-bool FifoSocket::init(bool supportNonBlocking, bool supportReturnValues, size_t maxDataSize) {
- int ret = socketpair(AF_UNIX, SOCK_STREAM, 0, sv);
- return false;
-}
-
-void FifoSocket::shutdown() {
- mShutdown = true;
- uint64_t d = 0;
- ::send(sv[0], &d, sizeof(d), 0);
- ::send(sv[1], &d, sizeof(d), 0);
- close(sv[0]);
- close(sv[1]);
-}
-
-bool FifoSocket::writeAsync(const void *data, size_t bytes, bool waitForSpace) {
- if (bytes == 0) {
- return true;
- }
- //ALOGE("writeAsync %p %i", data, bytes);
- size_t ret = ::send(sv[0], data, bytes, 0);
- //ALOGE("writeAsync ret %i", ret);
- rsAssert(ret == bytes);
- return true;
-}
-
-void FifoSocket::writeWaitReturn(void *retData, size_t retBytes) {
- if (mShutdown) {
- return;
- }
-
- //ALOGE("writeWaitReturn %p %i", retData, retBytes);
- size_t ret = ::recv(sv[0], retData, retBytes, MSG_WAITALL);
- //ALOGE("writeWaitReturn %i", ret);
- rsAssert(ret == retBytes);
-}
-
-size_t FifoSocket::read(void *data, size_t bytes) {
- if (mShutdown) {
- return 0;
- }
-
- //ALOGE("read %p %i", data, bytes);
- size_t ret = ::recv(sv[1], data, bytes, MSG_WAITALL);
- rsAssert(ret == bytes || mShutdown);
- //ALOGE("read ret %i bytes %i", ret, bytes);
- if (mShutdown) {
- ret = 0;
- }
- return ret;
-}
-
-bool FifoSocket::isEmpty() {
- struct pollfd p;
- p.fd = sv[1];
- p.events = POLLIN;
- int r = poll(&p, 1, 0);
- //ALOGE("poll r=%i", r);
- return r == 0;
-}
-
-
-void FifoSocket::readReturn(const void *data, size_t bytes) {
- //ALOGE("readReturn %p %Zu", data, bytes);
- size_t ret = ::send(sv[1], data, bytes, 0);
- //ALOGE("readReturn %Zu", ret);
- //rsAssert(ret == bytes);
-}
-
-
diff --git a/libs/rs/rsFifoSocket.h b/libs/rs/rsFifoSocket.h
deleted file mode 100644
index cac0a75..0000000
--- a/libs/rs/rsFifoSocket.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef ANDROID_RS_FIFO_SOCKET_H
-#define ANDROID_RS_FIFO_SOCKET_H
-
-
-#include "rsFifo.h"
-
-namespace android {
-namespace renderscript {
-
-
-class FifoSocket {
-public:
- FifoSocket();
- virtual ~FifoSocket();
-
- bool init(bool supportNonBlocking = true,
- bool supportReturnValues = true,
- size_t maxDataSize = 0);
- void shutdown();
-
- bool writeAsync(const void *data, size_t bytes, bool waitForSpace = true);
- void writeWaitReturn(void *ret, size_t retSize);
- size_t read(void *data, size_t bytes);
- void readReturn(const void *data, size_t bytes);
- bool isEmpty();
-
- int getWriteFd() {return sv[0];}
- int getReadFd() {return sv[1];}
-
-protected:
- int sv[2];
- bool mShutdown;
-};
-
-}
-}
-
-#endif
diff --git a/libs/rs/rsFileA3D.cpp b/libs/rs/rsFileA3D.cpp
deleted file mode 100644
index 173b9a5..0000000
--- a/libs/rs/rsFileA3D.cpp
+++ /dev/null
@@ -1,453 +0,0 @@
-
-/*
- * Copyright (C) 2009 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.
- */
-
-#include "rsContext.h"
-#include "rsFileA3D.h"
-
-#include "rsMesh.h"
-#include "rsAnimation.h"
-#include "rs.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-FileA3D::FileA3D(Context *rsc) : ObjectBase(rsc) {
- mAlloc = NULL;
- mData = NULL;
- mWriteStream = NULL;
- mReadStream = NULL;
- mAsset = NULL;
-
- mMajorVersion = 0;
- mMinorVersion = 1;
- mDataSize = 0;
-}
-
-FileA3D::~FileA3D() {
- for (size_t i = 0; i < mIndex.size(); i ++) {
- delete mIndex[i];
- }
- for (size_t i = 0; i < mWriteIndex.size(); i ++) {
- delete mWriteIndex[i];
- }
- if (mWriteStream) {
- delete mWriteStream;
- }
- if (mReadStream) {
- delete mWriteStream;
- }
- if (mAlloc) {
- free(mAlloc);
- }
- if (mAsset) {
- delete mAsset;
- }
-}
-
-void FileA3D::parseHeader(IStream *headerStream) {
- mMajorVersion = headerStream->loadU32();
- mMinorVersion = headerStream->loadU32();
- uint32_t flags = headerStream->loadU32();
- mUse64BitOffsets = (flags & 1) != 0;
-
- uint32_t numIndexEntries = headerStream->loadU32();
- for (uint32_t i = 0; i < numIndexEntries; i ++) {
- A3DIndexEntry *entry = new A3DIndexEntry();
- headerStream->loadString(&entry->mObjectName);
- //ALOGV("Header data, entry name = %s", entry->mObjectName.string());
- entry->mType = (RsA3DClassID)headerStream->loadU32();
- if (mUse64BitOffsets){
- entry->mOffset = headerStream->loadOffset();
- entry->mLength = headerStream->loadOffset();
- } else {
- entry->mOffset = headerStream->loadU32();
- entry->mLength = headerStream->loadU32();
- }
- entry->mRsObj = NULL;
- mIndex.push(entry);
- }
-}
-
-bool FileA3D::load(Asset *asset) {
- mAsset = asset;
- return load(asset->getBuffer(false), asset->getLength());
-}
-
-bool FileA3D::load(const void *data, size_t length) {
- const uint8_t *localData = (const uint8_t *)data;
-
- size_t lengthRemaining = length;
- size_t magicStrLen = 12;
- if ((length < magicStrLen) ||
- memcmp(data, "Android3D_ff", magicStrLen)) {
- return false;
- }
-
- localData += magicStrLen;
- lengthRemaining -= magicStrLen;
-
- // Next we get our header size
- uint64_t headerSize = 0;
- if (lengthRemaining < sizeof(headerSize)) {
- return false;
- }
-
- memcpy(&headerSize, localData, sizeof(headerSize));
- localData += sizeof(headerSize);
- lengthRemaining -= sizeof(headerSize);
-
- if (lengthRemaining < headerSize) {
- return false;
- }
-
- // Now open the stream to parse the header
- IStream headerStream(localData, false);
- parseHeader(&headerStream);
-
- localData += headerSize;
- lengthRemaining -= headerSize;
-
- if (lengthRemaining < sizeof(mDataSize)) {
- return false;
- }
-
- // Read the size of the data
- memcpy(&mDataSize, localData, sizeof(mDataSize));
- localData += sizeof(mDataSize);
- lengthRemaining -= sizeof(mDataSize);
-
- if (lengthRemaining < mDataSize) {
- return false;
- }
-
- // We should know enough to read the file in at this point.
- mData = (uint8_t *)localData;
- mReadStream = new IStream(mData, mUse64BitOffsets);
-
- return true;
-}
-
-bool FileA3D::load(FILE *f) {
- char magicString[12];
- size_t len;
-
- ALOGV("file open 1");
- len = fread(magicString, 1, 12, f);
- if ((len != 12) ||
- memcmp(magicString, "Android3D_ff", 12)) {
- return false;
- }
-
- // Next thing is the size of the header
- uint64_t headerSize = 0;
- len = fread(&headerSize, 1, sizeof(headerSize), f);
- if (len != sizeof(headerSize) || headerSize == 0) {
- return false;
- }
-
- uint8_t *headerData = (uint8_t *)malloc(headerSize);
- if (!headerData) {
- return false;
- }
-
- len = fread(headerData, 1, headerSize, f);
- if (len != headerSize) {
- return false;
- }
-
- // Now open the stream to parse the header
- IStream headerStream(headerData, false);
- parseHeader(&headerStream);
-
- free(headerData);
-
- // Next thing is the size of the header
- len = fread(&mDataSize, 1, sizeof(mDataSize), f);
- if (len != sizeof(mDataSize) || mDataSize == 0) {
- return false;
- }
-
- ALOGV("file open size = %lli", mDataSize);
-
- // We should know enough to read the file in at this point.
- mAlloc = malloc(mDataSize);
- if (!mAlloc) {
- return false;
- }
- mData = (uint8_t *)mAlloc;
- len = fread(mAlloc, 1, mDataSize, f);
- if (len != mDataSize) {
- return false;
- }
-
- mReadStream = new IStream(mData, mUse64BitOffsets);
-
- ALOGV("Header is read an stream initialized");
- return true;
-}
-
-size_t FileA3D::getNumIndexEntries() const {
- return mIndex.size();
-}
-
-const FileA3D::A3DIndexEntry *FileA3D::getIndexEntry(size_t index) const {
- if (index < mIndex.size()) {
- return mIndex[index];
- }
- return NULL;
-}
-
-ObjectBase *FileA3D::initializeFromEntry(size_t index) {
- if (index >= mIndex.size()) {
- return NULL;
- }
-
- FileA3D::A3DIndexEntry *entry = mIndex[index];
- if (!entry) {
- return NULL;
- }
-
- if (entry->mRsObj) {
- entry->mRsObj->incUserRef();
- return entry->mRsObj;
- }
-
- // Seek to the beginning of object
- mReadStream->reset(entry->mOffset);
- switch (entry->mType) {
- case RS_A3D_CLASS_ID_UNKNOWN:
- return NULL;
- case RS_A3D_CLASS_ID_MESH:
- entry->mRsObj = Mesh::createFromStream(mRSC, mReadStream);
- break;
- case RS_A3D_CLASS_ID_TYPE:
- entry->mRsObj = Type::createFromStream(mRSC, mReadStream);
- break;
- case RS_A3D_CLASS_ID_ELEMENT:
- entry->mRsObj = Element::createFromStream(mRSC, mReadStream);
- break;
- case RS_A3D_CLASS_ID_ALLOCATION:
- entry->mRsObj = Allocation::createFromStream(mRSC, mReadStream);
- break;
- case RS_A3D_CLASS_ID_PROGRAM_VERTEX:
- //entry->mRsObj = ProgramVertex::createFromStream(mRSC, mReadStream);
- break;
- case RS_A3D_CLASS_ID_PROGRAM_RASTER:
- //entry->mRsObj = ProgramRaster::createFromStream(mRSC, mReadStream);
- break;
- case RS_A3D_CLASS_ID_PROGRAM_FRAGMENT:
- //entry->mRsObj = ProgramFragment::createFromStream(mRSC, mReadStream);
- break;
- case RS_A3D_CLASS_ID_PROGRAM_STORE:
- //entry->mRsObj = ProgramStore::createFromStream(mRSC, mReadStream);
- break;
- case RS_A3D_CLASS_ID_SAMPLER:
- //entry->mRsObj = Sampler::createFromStream(mRSC, mReadStream);
- break;
- case RS_A3D_CLASS_ID_ANIMATION:
- //entry->mRsObj = Animation::createFromStream(mRSC, mReadStream);
- break;
- case RS_A3D_CLASS_ID_ADAPTER_1D:
- //entry->mRsObj = Adapter1D::createFromStream(mRSC, mReadStream);
- break;
- case RS_A3D_CLASS_ID_ADAPTER_2D:
- //entry->mRsObj = Adapter2D::createFromStream(mRSC, mReadStream);
- break;
- case RS_A3D_CLASS_ID_SCRIPT_C:
- break;
- }
- if (entry->mRsObj) {
- entry->mRsObj->incUserRef();
- }
- return entry->mRsObj;
-}
-
-bool FileA3D::writeFile(const char *filename) {
- if (!mWriteStream) {
- ALOGE("No objects to write\n");
- return false;
- }
- if (mWriteStream->getPos() == 0) {
- ALOGE("No objects to write\n");
- return false;
- }
-
- FILE *writeHandle = fopen(filename, "wb");
- if (!writeHandle) {
- ALOGE("Couldn't open the file for writing\n");
- return false;
- }
-
- // Open a new stream to make writing the header easier
- OStream headerStream(5*1024, false);
- headerStream.addU32(mMajorVersion);
- headerStream.addU32(mMinorVersion);
- uint32_t is64Bit = 0;
- headerStream.addU32(is64Bit);
-
- uint32_t writeIndexSize = mWriteIndex.size();
- headerStream.addU32(writeIndexSize);
- for (uint32_t i = 0; i < writeIndexSize; i ++) {
- headerStream.addString(&mWriteIndex[i]->mObjectName);
- headerStream.addU32((uint32_t)mWriteIndex[i]->mType);
- if (mUse64BitOffsets){
- headerStream.addOffset(mWriteIndex[i]->mOffset);
- headerStream.addOffset(mWriteIndex[i]->mLength);
- } else {
- uint32_t offset = (uint32_t)mWriteIndex[i]->mOffset;
- headerStream.addU32(offset);
- offset = (uint32_t)mWriteIndex[i]->mLength;
- headerStream.addU32(offset);
- }
- }
-
- // Write our magic string so we know we are reading the right file
- String8 magicString(A3D_MAGIC_KEY);
- fwrite(magicString.string(), sizeof(char), magicString.size(), writeHandle);
-
- // Store the size of the header to make it easier to parse when we read it
- uint64_t headerSize = headerStream.getPos();
- fwrite(&headerSize, sizeof(headerSize), 1, writeHandle);
-
- // Now write our header
- fwrite(headerStream.getPtr(), sizeof(uint8_t), headerStream.getPos(), writeHandle);
-
- // Now write the size of the data part of the file for easier parsing later
- uint64_t fileDataSize = mWriteStream->getPos();
- fwrite(&fileDataSize, sizeof(fileDataSize), 1, writeHandle);
-
- fwrite(mWriteStream->getPtr(), sizeof(uint8_t), mWriteStream->getPos(), writeHandle);
-
- int status = fclose(writeHandle);
-
- if (status != 0) {
- ALOGE("Couldn't close file\n");
- return false;
- }
-
- return true;
-}
-
-void FileA3D::appendToFile(ObjectBase *obj) {
- if (!obj) {
- return;
- }
- if (!mWriteStream) {
- const uint64_t initialStreamSize = 256*1024;
- mWriteStream = new OStream(initialStreamSize, false);
- }
- A3DIndexEntry *indexEntry = new A3DIndexEntry();
- indexEntry->mObjectName.setTo(obj->getName());
- indexEntry->mType = obj->getClassId();
- indexEntry->mOffset = mWriteStream->getPos();
- indexEntry->mRsObj = obj;
- mWriteIndex.push(indexEntry);
- obj->serialize(mWriteStream);
- indexEntry->mLength = mWriteStream->getPos() - indexEntry->mOffset;
- mWriteStream->align(4);
-}
-
-RsObjectBase rsaFileA3DGetEntryByIndex(RsContext con, uint32_t index, RsFile file) {
- FileA3D *fa3d = static_cast<FileA3D *>(file);
- if (!fa3d) {
- ALOGE("Can't load entry. No valid file");
- return NULL;
- }
-
- ObjectBase *obj = fa3d->initializeFromEntry(index);
- //ALOGV("Returning object with name %s", obj->getName());
-
- return obj;
-}
-
-
-void rsaFileA3DGetNumIndexEntries(RsContext con, int32_t *numEntries, RsFile file) {
- FileA3D *fa3d = static_cast<FileA3D *>(file);
-
- if (fa3d) {
- *numEntries = fa3d->getNumIndexEntries();
- } else {
- *numEntries = 0;
- }
-}
-
-void rsaFileA3DGetIndexEntries(RsContext con, RsFileIndexEntry *fileEntries, uint32_t numEntries, RsFile file) {
- FileA3D *fa3d = static_cast<FileA3D *>(file);
-
- if (!fa3d) {
- ALOGE("Can't load index entries. No valid file");
- return;
- }
-
- uint32_t numFileEntries = fa3d->getNumIndexEntries();
- if (numFileEntries != numEntries || numEntries == 0 || fileEntries == NULL) {
- ALOGE("Can't load index entries. Invalid number requested");
- return;
- }
-
- for (uint32_t i = 0; i < numFileEntries; i ++) {
- const FileA3D::A3DIndexEntry *entry = fa3d->getIndexEntry(i);
- fileEntries[i].classID = entry->getType();
- fileEntries[i].objectName = entry->getObjectName().string();
- }
-}
-
-RsFile rsaFileA3DCreateFromMemory(RsContext con, const void *data, uint32_t len) {
- if (data == NULL) {
- ALOGE("File load failed. Asset stream is NULL");
- return NULL;
- }
-
- Context *rsc = static_cast<Context *>(con);
- FileA3D *fa3d = new FileA3D(rsc);
- fa3d->incUserRef();
-
- fa3d->load(data, len);
- return fa3d;
-}
-
-RsFile rsaFileA3DCreateFromAsset(RsContext con, void *_asset) {
- Context *rsc = static_cast<Context *>(con);
- Asset *asset = static_cast<Asset *>(_asset);
- FileA3D *fa3d = new FileA3D(rsc);
- fa3d->incUserRef();
-
- fa3d->load(asset);
- return fa3d;
-}
-
-RsFile rsaFileA3DCreateFromFile(RsContext con, const char *path) {
- if (path == NULL) {
- ALOGE("File load failed. Path is NULL");
- return NULL;
- }
-
- Context *rsc = static_cast<Context *>(con);
- FileA3D *fa3d = NULL;
-
- FILE *f = fopen(path, "rb");
- if (f) {
- fa3d = new FileA3D(rsc);
- fa3d->incUserRef();
- fa3d->load(f);
- fclose(f);
- } else {
- ALOGE("Could not open file %s", path);
- }
-
- return fa3d;
-}
diff --git a/libs/rs/rsFileA3D.h b/libs/rs/rsFileA3D.h
deleted file mode 100644
index 08062c6..0000000
--- a/libs/rs/rsFileA3D.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#ifndef ANDROID_RS_FILE_A3D_H
-#define ANDROID_RS_FILE_A3D_H
-
-#include "rsMesh.h"
-
-#include <androidfw/Asset.h>
-#include <utils/String8.h>
-#include "rsStream.h"
-#include <stdio.h>
-
-#define A3D_MAGIC_KEY "Android3D_ff"
-
-// ---------------------------------------------------------------------------
-namespace android {
-
-namespace renderscript {
-
-class FileA3D : public ObjectBase {
-public:
- FileA3D(Context *rsc);
- ~FileA3D();
-
- uint32_t mMajorVersion;
- uint32_t mMinorVersion;
- uint64_t mIndexOffset;
- uint64_t mStringTableOffset;
- bool mUse64BitOffsets;
-
- class A3DIndexEntry {
- String8 mObjectName;
- RsA3DClassID mType;
- uint64_t mOffset;
- uint64_t mLength;
- ObjectBase *mRsObj;
- public:
- friend class FileA3D;
- const String8 &getObjectName() const {
- return mObjectName;
- }
- RsA3DClassID getType() const {
- return mType;
- }
- };
-
- bool load(FILE *f);
- bool load(Asset *asset);
- bool load(const void *data, size_t length);
-
- size_t getNumIndexEntries() const;
- const A3DIndexEntry* getIndexEntry(size_t index) const;
- ObjectBase *initializeFromEntry(size_t index);
-
- void appendToFile(ObjectBase *obj);
- bool writeFile(const char *filename);
-
- // Currently files do not get serialized,
- // but we need to inherit from ObjectBase for ref tracking
- virtual void serialize(OStream *stream) const {
- }
- virtual RsA3DClassID getClassId() const {
- return RS_A3D_CLASS_ID_UNKNOWN;
- }
-
-protected:
-
- void parseHeader(IStream *headerStream);
-
- const uint8_t * mData;
- void * mAlloc;
- uint64_t mDataSize;
- Asset *mAsset;
-
- OStream *mWriteStream;
- Vector<A3DIndexEntry*> mWriteIndex;
-
- IStream *mReadStream;
- Vector<A3DIndexEntry*> mIndex;
-};
-
-
-}
-}
-#endif //ANDROID_RS_FILE_A3D_H
-
-
diff --git a/libs/rs/rsFont.cpp b/libs/rs/rsFont.cpp
deleted file mode 100644
index 1f53c79..0000000
--- a/libs/rs/rsFont.cpp
+++ /dev/null
@@ -1,873 +0,0 @@
-
-/*
- * Copyright (C) 2009 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.
- */
-
-#include "rsContext.h"
-#include "rs.h"
-#include "rsFont.h"
-#include "rsProgramFragment.h"
-#include "rsMesh.h"
-#include <cutils/properties.h>
-
-#ifndef ANDROID_RS_SERIALIZE
-#include <ft2build.h>
-#include FT_FREETYPE_H
-#include FT_BITMAP_H
-#endif //ANDROID_RS_SERIALIZE
-
-using namespace android;
-using namespace android::renderscript;
-
-Font::Font(Context *rsc) : ObjectBase(rsc), mCachedGlyphs(NULL) {
- mInitialized = false;
- mHasKerning = false;
- mFace = NULL;
-}
-
-bool Font::init(const char *name, float fontSize, uint32_t dpi, const void *data, uint32_t dataLen) {
-#ifndef ANDROID_RS_SERIALIZE
- if (mInitialized) {
- ALOGE("Reinitialization of fonts not supported");
- return false;
- }
-
- FT_Error error = 0;
- if (data != NULL && dataLen > 0) {
- error = FT_New_Memory_Face(mRSC->mStateFont.getLib(), (const FT_Byte*)data, dataLen, 0, &mFace);
- } else {
- error = FT_New_Face(mRSC->mStateFont.getLib(), name, 0, &mFace);
- }
-
- if (error) {
- ALOGE("Unable to initialize font %s", name);
- return false;
- }
-
- mFontName = name;
- mFontSize = fontSize;
- mDpi = dpi;
-
- error = FT_Set_Char_Size(mFace, (FT_F26Dot6)(fontSize * 64.0f), 0, dpi, 0);
- if (error) {
- ALOGE("Unable to set font size on %s", name);
- return false;
- }
-
- mHasKerning = FT_HAS_KERNING(mFace);
-
- mInitialized = true;
-#endif //ANDROID_RS_SERIALIZE
- return true;
-}
-
-void Font::preDestroy() const {
- for (uint32_t ct = 0; ct < mRSC->mStateFont.mActiveFonts.size(); ct++) {
- if (mRSC->mStateFont.mActiveFonts[ct] == this) {
- mRSC->mStateFont.mActiveFonts.removeAt(ct);
- break;
- }
- }
-}
-
-void Font::invalidateTextureCache() {
- for (uint32_t i = 0; i < mCachedGlyphs.size(); i ++) {
- mCachedGlyphs.valueAt(i)->mIsValid = false;
- }
-}
-
-void Font::drawCachedGlyph(CachedGlyphInfo *glyph, int32_t x, int32_t y) {
- FontState *state = &mRSC->mStateFont;
-
- int32_t nPenX = x + glyph->mBitmapLeft;
- int32_t nPenY = y - glyph->mBitmapTop + glyph->mBitmapHeight;
-
- float u1 = glyph->mBitmapMinU;
- float u2 = glyph->mBitmapMaxU;
- float v1 = glyph->mBitmapMinV;
- float v2 = glyph->mBitmapMaxV;
-
- int32_t width = (int32_t) glyph->mBitmapWidth;
- int32_t height = (int32_t) glyph->mBitmapHeight;
-
- state->appendMeshQuad(nPenX, nPenY, 0, u1, v2,
- nPenX + width, nPenY, 0, u2, v2,
- nPenX + width, nPenY - height, 0, u2, v1,
- nPenX, nPenY - height, 0, u1, v1);
-}
-
-void Font::drawCachedGlyph(CachedGlyphInfo* glyph, int32_t x, int32_t y,
- uint8_t* bitmap, uint32_t bitmapW, uint32_t bitmapH) {
- int32_t nPenX = x + glyph->mBitmapLeft;
- int32_t nPenY = y + glyph->mBitmapTop;
-
- uint32_t endX = glyph->mBitmapMinX + glyph->mBitmapWidth;
- uint32_t endY = glyph->mBitmapMinY + glyph->mBitmapHeight;
-
- FontState *state = &mRSC->mStateFont;
- uint32_t cacheWidth = state->getCacheTextureType()->getDimX();
- const uint8_t* cacheBuffer = state->getTextTextureData();
-
- uint32_t cacheX = 0, cacheY = 0;
- int32_t bX = 0, bY = 0;
- for (cacheX = glyph->mBitmapMinX, bX = nPenX; cacheX < endX; cacheX++, bX++) {
- for (cacheY = glyph->mBitmapMinY, bY = nPenY; cacheY < endY; cacheY++, bY++) {
- if (bX < 0 || bY < 0 || bX >= (int32_t) bitmapW || bY >= (int32_t) bitmapH) {
- ALOGE("Skipping invalid index");
- continue;
- }
- uint8_t tempCol = cacheBuffer[cacheY * cacheWidth + cacheX];
- bitmap[bY * bitmapW + bX] = tempCol;
- }
- }
-}
-
-void Font::measureCachedGlyph(CachedGlyphInfo *glyph, int32_t x, int32_t y, Rect *bounds) {
- int32_t nPenX = x + glyph->mBitmapLeft;
- int32_t nPenY = y - glyph->mBitmapTop + glyph->mBitmapHeight;
-
- int32_t width = (int32_t) glyph->mBitmapWidth;
- int32_t height = (int32_t) glyph->mBitmapHeight;
-
- // 0, 0 is top left, so bottom is a positive number
- if (bounds->bottom < nPenY) {
- bounds->bottom = nPenY;
- }
- if (bounds->left > nPenX) {
- bounds->left = nPenX;
- }
- if (bounds->right < nPenX + width) {
- bounds->right = nPenX + width;
- }
- if (bounds->top > nPenY - height) {
- bounds->top = nPenY - height;
- }
-}
-
-void Font::renderUTF(const char *text, uint32_t len, int32_t x, int32_t y,
- uint32_t start, int32_t numGlyphs,
- RenderMode mode, Rect *bounds,
- uint8_t *bitmap, uint32_t bitmapW, uint32_t bitmapH) {
- if (!mInitialized || numGlyphs == 0 || text == NULL || len == 0) {
- return;
- }
-
- if (mode == Font::MEASURE) {
- if (bounds == NULL) {
- ALOGE("No return rectangle provided to measure text");
- return;
- }
- // Reset min and max of the bounding box to something large
- bounds->set(1e6, -1e6, 1e6, -1e6);
- }
-
- int32_t penX = x, penY = y;
- int32_t glyphsLeft = 1;
- if (numGlyphs > 0) {
- glyphsLeft = numGlyphs;
- }
-
- size_t index = start;
- size_t nextIndex = 0;
-
- while (glyphsLeft > 0) {
-
- int32_t utfChar = utf32_from_utf8_at(text, len, index, &nextIndex);
-
- // Reached the end of the string or encountered
- if (utfChar < 0) {
- break;
- }
-
- // Move to the next character in the array
- index = nextIndex;
-
- CachedGlyphInfo *cachedGlyph = getCachedUTFChar(utfChar);
-
- // If it's still not valid, we couldn't cache it, so we shouldn't draw garbage
- if (cachedGlyph->mIsValid) {
- switch (mode) {
- case FRAMEBUFFER:
- drawCachedGlyph(cachedGlyph, penX, penY);
- break;
- case BITMAP:
- drawCachedGlyph(cachedGlyph, penX, penY, bitmap, bitmapW, bitmapH);
- break;
- case MEASURE:
- measureCachedGlyph(cachedGlyph, penX, penY, bounds);
- break;
- }
- }
-
- penX += (cachedGlyph->mAdvanceX >> 6);
-
- // If we were given a specific number of glyphs, decrement
- if (numGlyphs > 0) {
- glyphsLeft --;
- }
- }
-}
-
-Font::CachedGlyphInfo* Font::getCachedUTFChar(int32_t utfChar) {
-
- CachedGlyphInfo *cachedGlyph = mCachedGlyphs.valueFor((uint32_t)utfChar);
- if (cachedGlyph == NULL) {
- cachedGlyph = cacheGlyph((uint32_t)utfChar);
- }
- // Is the glyph still in texture cache?
- if (!cachedGlyph->mIsValid) {
- updateGlyphCache(cachedGlyph);
- }
-
- return cachedGlyph;
-}
-
-void Font::updateGlyphCache(CachedGlyphInfo *glyph) {
-#ifndef ANDROID_RS_SERIALIZE
- FT_Error error = FT_Load_Glyph( mFace, glyph->mGlyphIndex, FT_LOAD_RENDER );
- if (error) {
- ALOGE("Couldn't load glyph.");
- return;
- }
-
- glyph->mAdvanceX = mFace->glyph->advance.x;
- glyph->mAdvanceY = mFace->glyph->advance.y;
- glyph->mBitmapLeft = mFace->glyph->bitmap_left;
- glyph->mBitmapTop = mFace->glyph->bitmap_top;
-
- FT_Bitmap *bitmap = &mFace->glyph->bitmap;
-
- // Now copy the bitmap into the cache texture
- uint32_t startX = 0;
- uint32_t startY = 0;
-
- // Let the font state figure out where to put the bitmap
- FontState *state = &mRSC->mStateFont;
- glyph->mIsValid = state->cacheBitmap(bitmap, &startX, &startY);
-
- if (!glyph->mIsValid) {
- return;
- }
-
- uint32_t endX = startX + bitmap->width;
- uint32_t endY = startY + bitmap->rows;
-
- glyph->mBitmapMinX = startX;
- glyph->mBitmapMinY = startY;
- glyph->mBitmapWidth = bitmap->width;
- glyph->mBitmapHeight = bitmap->rows;
-
- uint32_t cacheWidth = state->getCacheTextureType()->getDimX();
- uint32_t cacheHeight = state->getCacheTextureType()->getDimY();
-
- glyph->mBitmapMinU = (float)startX / (float)cacheWidth;
- glyph->mBitmapMinV = (float)startY / (float)cacheHeight;
- glyph->mBitmapMaxU = (float)endX / (float)cacheWidth;
- glyph->mBitmapMaxV = (float)endY / (float)cacheHeight;
-#endif //ANDROID_RS_SERIALIZE
-}
-
-Font::CachedGlyphInfo *Font::cacheGlyph(uint32_t glyph) {
- CachedGlyphInfo *newGlyph = new CachedGlyphInfo();
- mCachedGlyphs.add(glyph, newGlyph);
-#ifndef ANDROID_RS_SERIALIZE
- newGlyph->mGlyphIndex = FT_Get_Char_Index(mFace, glyph);
- newGlyph->mIsValid = false;
-#endif //ANDROID_RS_SERIALIZE
- updateGlyphCache(newGlyph);
-
- return newGlyph;
-}
-
-Font * Font::create(Context *rsc, const char *name, float fontSize, uint32_t dpi,
- const void *data, uint32_t dataLen) {
- rsc->mStateFont.checkInit();
- Vector<Font*> &activeFonts = rsc->mStateFont.mActiveFonts;
-
- for (uint32_t i = 0; i < activeFonts.size(); i ++) {
- Font *ithFont = activeFonts[i];
- if (ithFont->mFontName == name && ithFont->mFontSize == fontSize && ithFont->mDpi == dpi) {
- return ithFont;
- }
- }
-
- Font *newFont = new Font(rsc);
- bool isInitialized = newFont->init(name, fontSize, dpi, data, dataLen);
- if (isInitialized) {
- activeFonts.push(newFont);
- rsc->mStateFont.precacheLatin(newFont);
- return newFont;
- }
-
- ObjectBase::checkDelete(newFont);
- return NULL;
-}
-
-Font::~Font() {
-#ifndef ANDROID_RS_SERIALIZE
- if (mFace) {
- FT_Done_Face(mFace);
- }
-#endif
-
- for (uint32_t i = 0; i < mCachedGlyphs.size(); i ++) {
- CachedGlyphInfo *glyph = mCachedGlyphs.valueAt(i);
- delete glyph;
- }
-}
-
-FontState::FontState() {
- mInitialized = false;
- mMaxNumberOfQuads = 1024;
- mCurrentQuadIndex = 0;
- mRSC = NULL;
-#ifndef ANDROID_RS_SERIALIZE
- mLibrary = NULL;
-#endif //ANDROID_RS_SERIALIZE
-
- // Get the renderer properties
- char property[PROPERTY_VALUE_MAX];
-
- // Get the gamma
- float gamma = DEFAULT_TEXT_GAMMA;
- if (property_get(PROPERTY_TEXT_GAMMA, property, NULL) > 0) {
- gamma = atof(property);
- }
-
- // Get the black gamma threshold
- int32_t blackThreshold = DEFAULT_TEXT_BLACK_GAMMA_THRESHOLD;
- if (property_get(PROPERTY_TEXT_BLACK_GAMMA_THRESHOLD, property, NULL) > 0) {
- blackThreshold = atoi(property);
- }
- mBlackThreshold = (float)(blackThreshold) / 255.0f;
-
- // Get the white gamma threshold
- int32_t whiteThreshold = DEFAULT_TEXT_WHITE_GAMMA_THRESHOLD;
- if (property_get(PROPERTY_TEXT_WHITE_GAMMA_THRESHOLD, property, NULL) > 0) {
- whiteThreshold = atoi(property);
- }
- mWhiteThreshold = (float)(whiteThreshold) / 255.0f;
-
- // Compute the gamma tables
- mBlackGamma = gamma;
- mWhiteGamma = 1.0f / gamma;
-
- setFontColor(0.1f, 0.1f, 0.1f, 1.0f);
-}
-
-FontState::~FontState() {
- for (uint32_t i = 0; i < mCacheLines.size(); i ++) {
- delete mCacheLines[i];
- }
-
- rsAssert(!mActiveFonts.size());
-}
-#ifndef ANDROID_RS_SERIALIZE
-FT_Library FontState::getLib() {
- if (!mLibrary) {
- FT_Error error = FT_Init_FreeType(&mLibrary);
- if (error) {
- ALOGE("Unable to initialize freetype");
- return NULL;
- }
- }
-
- return mLibrary;
-}
-#endif //ANDROID_RS_SERIALIZE
-
-
-void FontState::init(Context *rsc) {
- mRSC = rsc;
-}
-
-void FontState::flushAllAndInvalidate() {
- if (mCurrentQuadIndex != 0) {
- issueDrawCommand();
- mCurrentQuadIndex = 0;
- }
- for (uint32_t i = 0; i < mActiveFonts.size(); i ++) {
- mActiveFonts[i]->invalidateTextureCache();
- }
- for (uint32_t i = 0; i < mCacheLines.size(); i ++) {
- mCacheLines[i]->mCurrentCol = 0;
- }
-}
-
-#ifndef ANDROID_RS_SERIALIZE
-bool FontState::cacheBitmap(FT_Bitmap *bitmap, uint32_t *retOriginX, uint32_t *retOriginY) {
- // If the glyph is too tall, don't cache it
- if ((uint32_t)bitmap->rows > mCacheLines[mCacheLines.size()-1]->mMaxHeight) {
- ALOGE("Font size to large to fit in cache. width, height = %i, %i", (int)bitmap->width, (int)bitmap->rows);
- return false;
- }
-
- // Now copy the bitmap into the cache texture
- uint32_t startX = 0;
- uint32_t startY = 0;
-
- bool bitmapFit = false;
- for (uint32_t i = 0; i < mCacheLines.size(); i ++) {
- bitmapFit = mCacheLines[i]->fitBitmap(bitmap, &startX, &startY);
- if (bitmapFit) {
- break;
- }
- }
-
- // If the new glyph didn't fit, flush the state so far and invalidate everything
- if (!bitmapFit) {
- flushAllAndInvalidate();
-
- // Try to fit it again
- for (uint32_t i = 0; i < mCacheLines.size(); i ++) {
- bitmapFit = mCacheLines[i]->fitBitmap(bitmap, &startX, &startY);
- if (bitmapFit) {
- break;
- }
- }
-
- // if we still don't fit, something is wrong and we shouldn't draw
- if (!bitmapFit) {
- ALOGE("Bitmap doesn't fit in cache. width, height = %i, %i", (int)bitmap->width, (int)bitmap->rows);
- return false;
- }
- }
-
- *retOriginX = startX;
- *retOriginY = startY;
-
- uint32_t endX = startX + bitmap->width;
- uint32_t endY = startY + bitmap->rows;
-
- uint32_t cacheWidth = getCacheTextureType()->getDimX();
-
- uint8_t *cacheBuffer = (uint8_t*)mTextTexture->getPtr();
- uint8_t *bitmapBuffer = bitmap->buffer;
-
- uint32_t cacheX = 0, bX = 0, cacheY = 0, bY = 0;
- for (cacheX = startX, bX = 0; cacheX < endX; cacheX ++, bX ++) {
- for (cacheY = startY, bY = 0; cacheY < endY; cacheY ++, bY ++) {
- uint8_t tempCol = bitmapBuffer[bY * bitmap->width + bX];
- cacheBuffer[cacheY*cacheWidth + cacheX] = tempCol;
- }
- }
-
- // This will dirty the texture and the shader so next time
- // we draw it will upload the data
-
- mTextTexture->sendDirty(mRSC);
- mFontShaderF->bindTexture(mRSC, 0, mTextTexture.get());
-
- // Some debug code
- /*for (uint32_t i = 0; i < mCacheLines.size(); i ++) {
- ALOGE("Cache Line: H: %u Empty Space: %f",
- mCacheLines[i]->mMaxHeight,
- (1.0f - (float)mCacheLines[i]->mCurrentCol/(float)mCacheLines[i]->mMaxWidth)*100.0f);
-
- }*/
-
- return true;
-}
-#endif //ANDROID_RS_SERIALIZE
-
-void FontState::initRenderState() {
- String8 shaderString("varying vec2 varTex0;\n");
- shaderString.append("void main() {\n");
- shaderString.append(" lowp vec4 col = UNI_Color;\n");
- shaderString.append(" col.a = texture2D(UNI_Tex0, varTex0.xy).a;\n");
- shaderString.append(" col.a = pow(col.a, UNI_Gamma);\n");
- shaderString.append(" gl_FragColor = col;\n");
- shaderString.append("}\n");
-
- const char *textureNames[] = { "Tex0" };
- const size_t textureNamesLengths[] = { 4 };
- size_t numTextures = sizeof(textureNamesLengths)/sizeof(*textureNamesLengths);
-
- ObjectBaseRef<const Element> colorElem = Element::createRef(mRSC, RS_TYPE_FLOAT_32,
- RS_KIND_USER, false, 4);
- ObjectBaseRef<const Element> gammaElem = Element::createRef(mRSC, RS_TYPE_FLOAT_32,
- RS_KIND_USER, false, 1);
- Element::Builder builder;
- builder.add(colorElem.get(), "Color", 1);
- builder.add(gammaElem.get(), "Gamma", 1);
- ObjectBaseRef<const Element> constInput = builder.create(mRSC);
-
- ObjectBaseRef<Type> inputType = Type::getTypeRef(mRSC, constInput.get(), 1, 0, 0, false, false);
-
- uint32_t tmp[4];
- tmp[0] = RS_PROGRAM_PARAM_CONSTANT;
- tmp[1] = (uint32_t)inputType.get();
- tmp[2] = RS_PROGRAM_PARAM_TEXTURE_TYPE;
- tmp[3] = RS_TEXTURE_2D;
-
- mFontShaderFConstant.set(Allocation::createAllocation(mRSC, inputType.get(),
- RS_ALLOCATION_USAGE_SCRIPT |
- RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS));
- ProgramFragment *pf = new ProgramFragment(mRSC, shaderString.string(), shaderString.length(),
- textureNames, numTextures, textureNamesLengths,
- tmp, 4);
- mFontShaderF.set(pf);
- mFontShaderF->bindAllocation(mRSC, mFontShaderFConstant.get(), 0);
-
- mFontSampler.set(Sampler::getSampler(mRSC, RS_SAMPLER_NEAREST, RS_SAMPLER_NEAREST,
- RS_SAMPLER_CLAMP, RS_SAMPLER_CLAMP,
- RS_SAMPLER_CLAMP).get());
- mFontShaderF->bindSampler(mRSC, 0, mFontSampler.get());
-
- mFontProgramStore.set(ProgramStore::getProgramStore(mRSC, true, true, true, true,
- false, false,
- RS_BLEND_SRC_SRC_ALPHA,
- RS_BLEND_DST_ONE_MINUS_SRC_ALPHA,
- RS_DEPTH_FUNC_ALWAYS).get());
- mFontProgramStore->init();
-}
-
-void FontState::initTextTexture() {
- ObjectBaseRef<const Element> alphaElem = Element::createRef(mRSC, RS_TYPE_UNSIGNED_8,
- RS_KIND_PIXEL_A, true, 1);
-
- // We will allocate a texture to initially hold 32 character bitmaps
- ObjectBaseRef<Type> texType = Type::getTypeRef(mRSC, alphaElem.get(),
- 1024, 256, 0, false, false);
-
- Allocation *cacheAlloc = Allocation::createAllocation(mRSC, texType.get(),
- RS_ALLOCATION_USAGE_SCRIPT | RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE);
- mTextTexture.set(cacheAlloc);
- mTextTexture->syncAll(mRSC, RS_ALLOCATION_USAGE_SCRIPT);
-
- // Split up our cache texture into lines of certain widths
- int32_t nextLine = 0;
- mCacheLines.push(new CacheTextureLine(16, texType->getDimX(), nextLine, 0));
- nextLine += mCacheLines.top()->mMaxHeight;
- mCacheLines.push(new CacheTextureLine(24, texType->getDimX(), nextLine, 0));
- nextLine += mCacheLines.top()->mMaxHeight;
- mCacheLines.push(new CacheTextureLine(24, texType->getDimX(), nextLine, 0));
- nextLine += mCacheLines.top()->mMaxHeight;
- mCacheLines.push(new CacheTextureLine(32, texType->getDimX(), nextLine, 0));
- nextLine += mCacheLines.top()->mMaxHeight;
- mCacheLines.push(new CacheTextureLine(32, texType->getDimX(), nextLine, 0));
- nextLine += mCacheLines.top()->mMaxHeight;
- mCacheLines.push(new CacheTextureLine(40, texType->getDimX(), nextLine, 0));
- nextLine += mCacheLines.top()->mMaxHeight;
- mCacheLines.push(new CacheTextureLine(texType->getDimY() - nextLine, texType->getDimX(), nextLine, 0));
-}
-
-// Avoid having to reallocate memory and render quad by quad
-void FontState::initVertexArrayBuffers() {
- // Now lets write index data
- ObjectBaseRef<const Element> indexElem = Element::createRef(mRSC, RS_TYPE_UNSIGNED_16, RS_KIND_USER, false, 1);
- uint32_t numIndicies = mMaxNumberOfQuads * 6;
- ObjectBaseRef<Type> indexType = Type::getTypeRef(mRSC, indexElem.get(), numIndicies, 0, 0, false, false);
-
- Allocation *indexAlloc = Allocation::createAllocation(mRSC, indexType.get(),
- RS_ALLOCATION_USAGE_SCRIPT |
- RS_ALLOCATION_USAGE_GRAPHICS_VERTEX);
- uint16_t *indexPtr = (uint16_t*)indexAlloc->getPtr();
-
- // Four verts, two triangles , six indices per quad
- for (uint32_t i = 0; i < mMaxNumberOfQuads; i ++) {
- int32_t i6 = i * 6;
- int32_t i4 = i * 4;
-
- indexPtr[i6 + 0] = i4 + 0;
- indexPtr[i6 + 1] = i4 + 1;
- indexPtr[i6 + 2] = i4 + 2;
-
- indexPtr[i6 + 3] = i4 + 0;
- indexPtr[i6 + 4] = i4 + 2;
- indexPtr[i6 + 5] = i4 + 3;
- }
-
- indexAlloc->sendDirty(mRSC);
-
- ObjectBaseRef<const Element> posElem = Element::createRef(mRSC, RS_TYPE_FLOAT_32, RS_KIND_USER, false, 3);
- ObjectBaseRef<const Element> texElem = Element::createRef(mRSC, RS_TYPE_FLOAT_32, RS_KIND_USER, false, 2);
-
- Element::Builder builder;
- builder.add(posElem.get(), "position", 1);
- builder.add(texElem.get(), "texture0", 1);
- ObjectBaseRef<const Element> vertexDataElem = builder.create(mRSC);
-
- ObjectBaseRef<Type> vertexDataType = Type::getTypeRef(mRSC, vertexDataElem.get(),
- mMaxNumberOfQuads * 4,
- 0, 0, false, false);
-
- Allocation *vertexAlloc = Allocation::createAllocation(mRSC, vertexDataType.get(),
- RS_ALLOCATION_USAGE_SCRIPT);
- mTextMeshPtr = (float*)vertexAlloc->getPtr();
-
- mMesh.set(new Mesh(mRSC, 1, 1));
- mMesh->setVertexBuffer(vertexAlloc, 0);
- mMesh->setPrimitive(indexAlloc, RS_PRIMITIVE_TRIANGLE, 0);
- mMesh->init();
-}
-
-// We don't want to allocate anything unless we actually draw text
-void FontState::checkInit() {
- if (mInitialized) {
- return;
- }
-
- initTextTexture();
- initRenderState();
-
- initVertexArrayBuffers();
-
- // We store a string with letters in a rough frequency of occurrence
- mLatinPrecache = String8(" eisarntolcdugpmhbyfvkwzxjq");
- mLatinPrecache += String8("EISARNTOLCDUGPMHBYFVKWZXJQ");
- mLatinPrecache += String8(",.?!()-+@;:`'");
- mLatinPrecache += String8("0123456789");
-
- mInitialized = true;
-}
-
-void FontState::issueDrawCommand() {
- Context::PushState ps(mRSC);
-
- mRSC->setProgramVertex(mRSC->getDefaultProgramVertex());
- mRSC->setProgramRaster(mRSC->getDefaultProgramRaster());
- mRSC->setProgramFragment(mFontShaderF.get());
- mRSC->setProgramStore(mFontProgramStore.get());
-
- if (mConstantsDirty) {
- mFontShaderFConstant->data(mRSC, 0, 0, 1, &mConstants, sizeof(mConstants));
- mConstantsDirty = false;
- }
-
- if (!mRSC->setupCheck()) {
- return;
- }
-
- mMesh->renderPrimitiveRange(mRSC, 0, 0, mCurrentQuadIndex * 6);
-}
-
-void FontState::appendMeshQuad(float x1, float y1, float z1,
- float u1, float v1,
- float x2, float y2, float z2,
- float u2, float v2,
- float x3, float y3, float z3,
- float u3, float v3,
- float x4, float y4, float z4,
- float u4, float v4) {
- const uint32_t vertsPerQuad = 4;
- const uint32_t floatsPerVert = 6;
- float *currentPos = mTextMeshPtr + mCurrentQuadIndex * vertsPerQuad * floatsPerVert;
-
- if (x1 > mSurfaceWidth || y1 < 0.0f || x2 < 0 || y4 > mSurfaceHeight) {
- return;
- }
-
- /*LOGE("V0 x: %f y: %f z: %f", x1, y1, z1);
- ALOGE("V1 x: %f y: %f z: %f", x2, y2, z2);
- ALOGE("V2 x: %f y: %f z: %f", x3, y3, z3);
- ALOGE("V3 x: %f y: %f z: %f", x4, y4, z4);*/
-
- (*currentPos++) = x1;
- (*currentPos++) = y1;
- (*currentPos++) = z1;
- (*currentPos++) = 0;
- (*currentPos++) = u1;
- (*currentPos++) = v1;
-
- (*currentPos++) = x2;
- (*currentPos++) = y2;
- (*currentPos++) = z2;
- (*currentPos++) = 0;
- (*currentPos++) = u2;
- (*currentPos++) = v2;
-
- (*currentPos++) = x3;
- (*currentPos++) = y3;
- (*currentPos++) = z3;
- (*currentPos++) = 0;
- (*currentPos++) = u3;
- (*currentPos++) = v3;
-
- (*currentPos++) = x4;
- (*currentPos++) = y4;
- (*currentPos++) = z4;
- (*currentPos++) = 0;
- (*currentPos++) = u4;
- (*currentPos++) = v4;
-
- mCurrentQuadIndex ++;
-
- if (mCurrentQuadIndex == mMaxNumberOfQuads) {
- issueDrawCommand();
- mCurrentQuadIndex = 0;
- }
-}
-
-uint32_t FontState::getRemainingCacheCapacity() {
- uint32_t remainingCapacity = 0;
- uint32_t totalPixels = 0;
- for (uint32_t i = 0; i < mCacheLines.size(); i ++) {
- remainingCapacity += (mCacheLines[i]->mMaxWidth - mCacheLines[i]->mCurrentCol);
- totalPixels += mCacheLines[i]->mMaxWidth;
- }
- remainingCapacity = (remainingCapacity * 100) / totalPixels;
- return remainingCapacity;
-}
-
-void FontState::precacheLatin(Font *font) {
- // Remaining capacity is measured in %
- uint32_t remainingCapacity = getRemainingCacheCapacity();
- uint32_t precacheIdx = 0;
- while (remainingCapacity > 25 && precacheIdx < mLatinPrecache.size()) {
- font->getCachedUTFChar((int32_t)mLatinPrecache[precacheIdx]);
- remainingCapacity = getRemainingCacheCapacity();
- precacheIdx ++;
- }
-}
-
-
-void FontState::renderText(const char *text, uint32_t len, int32_t x, int32_t y,
- uint32_t startIndex, int32_t numGlyphs,
- Font::RenderMode mode,
- Font::Rect *bounds,
- uint8_t *bitmap, uint32_t bitmapW, uint32_t bitmapH) {
- checkInit();
-
- // Render code here
- Font *currentFont = mRSC->getFont();
- if (!currentFont) {
- if (!mDefault.get()) {
- String8 fontsDir("/fonts/Roboto-Regular.ttf");
- String8 fullPath(getenv("ANDROID_ROOT"));
- fullPath += fontsDir;
-
- mDefault.set(Font::create(mRSC, fullPath.string(), 8, mRSC->getDPI()));
- }
- currentFont = mDefault.get();
- }
- if (!currentFont) {
- ALOGE("Unable to initialize any fonts");
- return;
- }
-
- // Cull things that are off the screen
- mSurfaceWidth = (float)mRSC->getCurrentSurfaceWidth();
- mSurfaceHeight = (float)mRSC->getCurrentSurfaceHeight();
-
- currentFont->renderUTF(text, len, x, y, startIndex, numGlyphs,
- mode, bounds, bitmap, bitmapW, bitmapH);
-
- if (mCurrentQuadIndex != 0) {
- issueDrawCommand();
- mCurrentQuadIndex = 0;
- }
-}
-
-void FontState::measureText(const char *text, uint32_t len, Font::Rect *bounds) {
- renderText(text, len, 0, 0, 0, -1, Font::MEASURE, bounds);
- bounds->bottom = - bounds->bottom;
- bounds->top = - bounds->top;
-}
-
-void FontState::setFontColor(float r, float g, float b, float a) {
- mConstants.mFontColor[0] = r;
- mConstants.mFontColor[1] = g;
- mConstants.mFontColor[2] = b;
- mConstants.mFontColor[3] = a;
-
- mConstants.mGamma = 1.0f;
- const float luminance = (r * 2.0f + g * 5.0f + b) / 8.0f;
- if (luminance <= mBlackThreshold) {
- mConstants.mGamma = mBlackGamma;
- } else if (luminance >= mWhiteThreshold) {
- mConstants.mGamma = mWhiteGamma;
- }
-
- mConstantsDirty = true;
-}
-
-void FontState::getFontColor(float *r, float *g, float *b, float *a) const {
- *r = mConstants.mFontColor[0];
- *g = mConstants.mFontColor[1];
- *b = mConstants.mFontColor[2];
- *a = mConstants.mFontColor[3];
-}
-
-void FontState::deinit(Context *rsc) {
- mInitialized = false;
-
- mFontShaderFConstant.clear();
-
- mMesh.clear();
-
- mFontShaderF.clear();
- mFontSampler.clear();
- mFontProgramStore.clear();
-
- mTextTexture.clear();
- for (uint32_t i = 0; i < mCacheLines.size(); i ++) {
- delete mCacheLines[i];
- }
- mCacheLines.clear();
-
- mDefault.clear();
-#ifndef ANDROID_RS_SERIALIZE
- if (mLibrary) {
- FT_Done_FreeType( mLibrary );
- mLibrary = NULL;
- }
-#endif //ANDROID_RS_SERIALIZE
-}
-
-#ifndef ANDROID_RS_SERIALIZE
-bool FontState::CacheTextureLine::fitBitmap(FT_Bitmap_ *bitmap, uint32_t *retOriginX, uint32_t *retOriginY) {
- if ((uint32_t)bitmap->rows > mMaxHeight) {
- return false;
- }
-
- if (mCurrentCol + (uint32_t)bitmap->width < mMaxWidth) {
- *retOriginX = mCurrentCol;
- *retOriginY = mCurrentRow;
- mCurrentCol += bitmap->width;
- mDirty = true;
- return true;
- }
-
- return false;
-}
-#endif //ANDROID_RS_SERIALIZE
-
-namespace android {
-namespace renderscript {
-
-RsFont rsi_FontCreateFromFile(Context *rsc,
- char const *name, size_t name_length,
- float fontSize, uint32_t dpi) {
- Font *newFont = Font::create(rsc, name, fontSize, dpi);
- if (newFont) {
- newFont->incUserRef();
- }
- return newFont;
-}
-
-RsFont rsi_FontCreateFromMemory(Context *rsc,
- char const *name, size_t name_length,
- float fontSize, uint32_t dpi,
- const void *data, size_t data_length) {
- Font *newFont = Font::create(rsc, name, fontSize, dpi, data, data_length);
- if (newFont) {
- newFont->incUserRef();
- }
- return newFont;
-}
-
-} // renderscript
-} // android
diff --git a/libs/rs/rsFont.h b/libs/rs/rsFont.h
deleted file mode 100644
index 2bd30b7..0000000
--- a/libs/rs/rsFont.h
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#ifndef ANDROID_RS_FONT_H
-#define ANDROID_RS_FONT_H
-
-#include "rsStream.h"
-#include <utils/String8.h>
-#include <utils/Vector.h>
-#include <utils/KeyedVector.h>
-
-struct FT_LibraryRec_;
-struct FT_FaceRec_;
-struct FT_Bitmap_;
-
-// ---------------------------------------------------------------------------
-namespace android {
-
-namespace renderscript {
-
-// Gamma (>= 1.0, <= 10.0)
-#define PROPERTY_TEXT_GAMMA "ro.text_gamma"
-#define PROPERTY_TEXT_BLACK_GAMMA_THRESHOLD "ro.text_gamma.black_threshold"
-#define PROPERTY_TEXT_WHITE_GAMMA_THRESHOLD "ro.text_gamma.white_threshold"
-
-#define DEFAULT_TEXT_GAMMA 1.4f
-#define DEFAULT_TEXT_BLACK_GAMMA_THRESHOLD 64
-#define DEFAULT_TEXT_WHITE_GAMMA_THRESHOLD 192
-
-class FontState;
-
-class Font : public ObjectBase {
-public:
- enum RenderMode {
- FRAMEBUFFER,
- BITMAP,
- MEASURE,
- };
-
- struct Rect {
- int32_t left;
- int32_t top;
- int32_t right;
- int32_t bottom;
- void set(int32_t l, int32_t r, int32_t t, int32_t b) {
- left = l;
- right = r;
- top = t;
- bottom = b;
- }
- };
-
- ~Font();
-
- // Currently files do not get serialized,
- // but we need to inherit from ObjectBase for ref tracking
- virtual void serialize(OStream *stream) const {
- }
- virtual RsA3DClassID getClassId() const {
- return RS_A3D_CLASS_ID_UNKNOWN;
- }
-
- static Font * create(Context *rsc, const char *name, float fontSize, uint32_t dpi,
- const void *data = NULL, uint32_t dataLen = 0);
-
-protected:
-
- friend class FontState;
-
- // Pointer to the utf data, length of data, where to start, number of glyphs ot read
- // (each glyph may be longer than a char because we are dealing with utf data)
- // Last two variables are the initial pen position
- void renderUTF(const char *text, uint32_t len, int32_t x, int32_t y,
- uint32_t start, int32_t numGlyphs,
- RenderMode mode = FRAMEBUFFER, Rect *bounds = NULL,
- uint8_t *bitmap = NULL, uint32_t bitmapW = 0, uint32_t bitmapH = 0);
-
- void invalidateTextureCache();
- struct CachedGlyphInfo
- {
- // Has the cache been invalidated?
- bool mIsValid;
- // Location of the cached glyph in the bitmap
- // in case we need to resize the texture
- uint32_t mBitmapMinX;
- uint32_t mBitmapMinY;
- uint32_t mBitmapWidth;
- uint32_t mBitmapHeight;
- // Also cache texture coords for the quad
- float mBitmapMinU;
- float mBitmapMinV;
- float mBitmapMaxU;
- float mBitmapMaxV;
- // Minimize how much we call freetype
- int32_t mGlyphIndex;
- int32_t mAdvanceX;
- int32_t mAdvanceY;
- // Values below contain a glyph's origin in the bitmap
- int32_t mBitmapLeft;
- int32_t mBitmapTop;
- };
-
- String8 mFontName;
- float mFontSize;
- uint32_t mDpi;
-
- Font(Context *rsc);
- bool init(const char *name, float fontSize, uint32_t dpi, const void *data = NULL, uint32_t dataLen = 0);
-
- virtual void preDestroy() const;
- FT_FaceRec_ *mFace;
- bool mInitialized;
- bool mHasKerning;
-
- DefaultKeyedVector<uint32_t, CachedGlyphInfo* > mCachedGlyphs;
- CachedGlyphInfo* getCachedUTFChar(int32_t utfChar);
-
- CachedGlyphInfo *cacheGlyph(uint32_t glyph);
- void updateGlyphCache(CachedGlyphInfo *glyph);
- void measureCachedGlyph(CachedGlyphInfo *glyph, int32_t x, int32_t y, Rect *bounds);
- void drawCachedGlyph(CachedGlyphInfo *glyph, int32_t x, int32_t y);
- void drawCachedGlyph(CachedGlyphInfo *glyph, int32_t x, int32_t y,
- uint8_t *bitmap, uint32_t bitmapW, uint32_t bitmapH);
-};
-
-class FontState {
-public:
- FontState();
- ~FontState();
-
- void init(Context *rsc);
- void deinit(Context *rsc);
-
- ObjectBaseRef<Font> mDefault;
-
- void renderText(const char *text, uint32_t len, int32_t x, int32_t y,
- uint32_t startIndex = 0, int numGlyphs = -1,
- Font::RenderMode mode = Font::FRAMEBUFFER,
- Font::Rect *bounds = NULL,
- uint8_t *bitmap = NULL, uint32_t bitmapW = 0, uint32_t bitmapH = 0);
-
- void measureText(const char *text, uint32_t len, Font::Rect *bounds);
-
- void setFontColor(float r, float g, float b, float a);
- void getFontColor(float *r, float *g, float *b, float *a) const;
-
-protected:
-
- float mSurfaceWidth;
- float mSurfaceHeight;
-
- friend class Font;
-
- struct CacheTextureLine {
- uint32_t mMaxHeight;
- uint32_t mMaxWidth;
- uint32_t mCurrentRow;
- uint32_t mCurrentCol;
- bool mDirty;
-
- CacheTextureLine(uint32_t maxHeight, uint32_t maxWidth, uint32_t currentRow, uint32_t currentCol)
- : mMaxHeight(maxHeight), mMaxWidth(maxWidth), mCurrentRow(currentRow),
- mCurrentCol(currentCol), mDirty(false) {
- }
-
- bool fitBitmap(FT_Bitmap_ *bitmap, uint32_t *retOriginX, uint32_t *retOriginY);
- };
-
- Vector<CacheTextureLine*> mCacheLines;
- uint32_t getRemainingCacheCapacity();
-
- void precacheLatin(Font *font);
- String8 mLatinPrecache;
-
- Context *mRSC;
-
- struct {
- float mFontColor[4];
- float mGamma;
- } mConstants;
- bool mConstantsDirty;
-
- float mBlackGamma;
- float mWhiteGamma;
-
- float mBlackThreshold;
- float mWhiteThreshold;
-
- // Free type library, we only need one copy
-#ifndef ANDROID_RS_SERIALIZE
- FT_LibraryRec_ *mLibrary;
- FT_LibraryRec_ *getLib();
-#endif //ANDROID_RS_SERIALIZE
- Vector<Font*> mActiveFonts;
-
- // Render state for the font
- ObjectBaseRef<Allocation> mFontShaderFConstant;
- ObjectBaseRef<ProgramFragment> mFontShaderF;
- ObjectBaseRef<Sampler> mFontSampler;
- ObjectBaseRef<ProgramStore> mFontProgramStore;
- void initRenderState();
-
- // Texture to cache glyph bitmaps
- ObjectBaseRef<Allocation> mTextTexture;
- void initTextTexture();
- const uint8_t* getTextTextureData() const {
- return (uint8_t*)mTextTexture->getPtr();
- }
-
-#ifndef ANDROID_RS_SERIALIZE
- bool cacheBitmap(FT_Bitmap_ *bitmap, uint32_t *retOriginX, uint32_t *retOriginY);
-#endif //ANDROID_RS_SERIALIZE
- const Type* getCacheTextureType() {
- return mTextTexture->getType();
- }
-
- void flushAllAndInvalidate();
-
- // Pointer to vertex data to speed up frame to frame work
- float *mTextMeshPtr;
- uint32_t mCurrentQuadIndex;
- uint32_t mMaxNumberOfQuads;
-
- void initVertexArrayBuffers();
- ObjectBaseRef<Mesh> mMesh;
-
- bool mInitialized;
-
- void checkInit();
-
- void issueDrawCommand();
-
- void appendMeshQuad(float x1, float y1, float z1,
- float u1, float v1,
- float x2, float y2, float z2,
- float u2, float v2,
- float x3, float y3, float z3,
- float u3, float v3,
- float x4, float y4, float z4,
- float u4, float v4);
-};
-
-}
-}
-
-#endif
diff --git a/libs/rs/rsMatrix2x2.cpp b/libs/rs/rsMatrix2x2.cpp
deleted file mode 100644
index 622113c..0000000
--- a/libs/rs/rsMatrix2x2.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#include "rsMatrix2x2.h"
-#include "rsMatrix3x3.h"
-#include "rsMatrix4x4.h"
-
-#include "stdlib.h"
-#include "string.h"
-#include "math.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-
-void Matrix2x2::loadIdentity() {
- m[0] = 1.f;
- m[1] = 0.f;
- m[2] = 0.f;
- m[3] = 1.f;
-}
-
-void Matrix2x2::load(const float *v) {
- memcpy(m, v, sizeof(m));
-}
-
-void Matrix2x2::load(const rs_matrix2x2 *v) {
- memcpy(m, v->m, sizeof(m));
-}
-
-void Matrix2x2::loadMultiply(const rs_matrix2x2 *lhs, const rs_matrix2x2 *rhs) {
- for (int i=0 ; i<2 ; i++) {
- float ri0 = 0;
- float ri1 = 0;
- for (int j=0 ; j<2 ; j++) {
- const float rhs_ij = ((const Matrix2x2 *)rhs)->get(i, j);
- ri0 += ((const Matrix2x2 *)lhs)->get(j, 0) * rhs_ij;
- ri1 += ((const Matrix2x2 *)lhs)->get(j, 1) * rhs_ij;
- }
- set(i, 0, ri0);
- set(i, 1, ri1);
- }
-}
-
-void Matrix2x2::transpose() {
- float temp = m[1];
- m[1] = m[2];
- m[2] = temp;
-}
-
diff --git a/libs/rs/rsMatrix2x2.h b/libs/rs/rsMatrix2x2.h
deleted file mode 100644
index 4dcb84a..0000000
--- a/libs/rs/rsMatrix2x2.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef ANDROID_RS_MATRIX_2x2_H
-#define ANDROID_RS_MATRIX_2x2_H
-
-#include "rsType.h"
-
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-struct Matrix2x2 : public rs_matrix2x2 {
- inline float get(uint32_t row, uint32_t col) const {
- return m[row*2 + col];
- }
-
- inline void set(uint32_t row, uint32_t col, float v) {
- m[row*2 + col] = v;
- }
-
- void loadIdentity();
- void load(const float *);
- void load(const rs_matrix2x2 *);
-
- void loadMultiply(const rs_matrix2x2 *lhs, const rs_matrix2x2 *rhs);
-
- void transpose();
-
- void multiply(const rs_matrix2x2 *rhs) {
- Matrix2x2 tmp;
- tmp.loadMultiply(this, rhs);
- load(&tmp);
- }
-};
-
-}
-}
-
-
-
-
-#endif
-
-
-
-
-
diff --git a/libs/rs/rsMatrix3x3.cpp b/libs/rs/rsMatrix3x3.cpp
deleted file mode 100644
index 3f9a2d1..0000000
--- a/libs/rs/rsMatrix3x3.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#include "rsMatrix2x2.h"
-#include "rsMatrix3x3.h"
-#include "rsMatrix4x4.h"
-
-#include "stdlib.h"
-#include "string.h"
-#include "math.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-void Matrix3x3::loadIdentity() {
- m[0] = 1.f;
- m[1] = 0.f;
- m[2] = 0.f;
- m[3] = 0.f;
- m[4] = 1.f;
- m[5] = 0.f;
- m[6] = 0.f;
- m[7] = 0.f;
- m[8] = 1.f;
-}
-
-void Matrix3x3::load(const float *v) {
- memcpy(m, v, sizeof(m));
-}
-
-void Matrix3x3::load(const rs_matrix3x3 *v) {
- memcpy(m, v->m, sizeof(m));
-}
-
-void Matrix3x3::loadMultiply(const rs_matrix3x3 *lhs, const rs_matrix3x3 *rhs) {
- for (int i=0 ; i<3 ; i++) {
- float ri0 = 0;
- float ri1 = 0;
- float ri2 = 0;
- for (int j=0 ; j<3 ; j++) {
- const float rhs_ij = ((const Matrix3x3 *)rhs)->get(i, j);
- ri0 += ((const Matrix3x3 *)lhs)->get(j, 0) * rhs_ij;
- ri1 += ((const Matrix3x3 *)lhs)->get(j, 1) * rhs_ij;
- ri2 += ((const Matrix3x3 *)lhs)->get(j, 2) * rhs_ij;
- }
- set(i, 0, ri0);
- set(i, 1, ri1);
- set(i, 2, ri2);
- }
-}
-
-void Matrix3x3::transpose() {
- int i, j;
- float temp;
- for (i = 0; i < 2; ++i) {
- for (j = i + 1; j < 3; ++j) {
- temp = get(i, j);
- set(i, j, get(j, i));
- set(j, i, temp);
- }
- }
-}
-
diff --git a/libs/rs/rsMatrix3x3.h b/libs/rs/rsMatrix3x3.h
deleted file mode 100644
index f96d270..0000000
--- a/libs/rs/rsMatrix3x3.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef ANDROID_RS_MATRIX_3x3_H
-#define ANDROID_RS_MATRIX_3x3_H
-
-#include "rsType.h"
-
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-struct Matrix3x3 : public rs_matrix3x3 {
- inline float get(uint32_t row, uint32_t col) const {
- return m[row*3 + col];
- }
-
- inline void set(uint32_t row, uint32_t col, float v) {
- m[row*3 + col] = v;
- }
-
- void loadIdentity();
- void load(const float *);
- void load(const rs_matrix3x3 *);
-
- void loadMultiply(const rs_matrix3x3 *lhs, const rs_matrix3x3 *rhs);
-
- void transpose();
-
- void multiply(const rs_matrix3x3 *rhs) {
- Matrix3x3 tmp;
- tmp.loadMultiply(this, rhs);
- load(&tmp);
- }
-};
-
-}
-}
-
-
-
-
-#endif
-
-
-
-
-
diff --git a/libs/rs/rsMatrix4x4.cpp b/libs/rs/rsMatrix4x4.cpp
deleted file mode 100644
index c6f96d8..0000000
--- a/libs/rs/rsMatrix4x4.cpp
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#include "rsMatrix2x2.h"
-#include "rsMatrix3x3.h"
-#include "rsMatrix4x4.h"
-
-#include "stdlib.h"
-#include "string.h"
-#include "math.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-//////////////////////////////////////////////////////////////////////////////
-// Heavy math functions
-//////////////////////////////////////////////////////////////////////////////
-
-
-
-
-
-// Returns true if the matrix was successfully inversed
-bool Matrix4x4::inverse() {
- rs_matrix4x4 result;
-
- int i, j;
- for (i = 0; i < 4; ++i) {
- for (j = 0; j < 4; ++j) {
- // computeCofactor for int i, int j
- int c0 = (i+1) % 4;
- int c1 = (i+2) % 4;
- int c2 = (i+3) % 4;
- int r0 = (j+1) % 4;
- int r1 = (j+2) % 4;
- int r2 = (j+3) % 4;
-
- float minor =
- (m[c0 + 4*r0] * (m[c1 + 4*r1] * m[c2 + 4*r2] - m[c1 + 4*r2] * m[c2 + 4*r1]))
- - (m[c0 + 4*r1] * (m[c1 + 4*r0] * m[c2 + 4*r2] - m[c1 + 4*r2] * m[c2 + 4*r0]))
- + (m[c0 + 4*r2] * (m[c1 + 4*r0] * m[c2 + 4*r1] - m[c1 + 4*r1] * m[c2 + 4*r0]));
-
- float cofactor = (i+j) & 1 ? -minor : minor;
-
- result.m[4*i + j] = cofactor;
- }
- }
-
- // Dot product of 0th column of source and 0th row of result
- float det = m[0]*result.m[0] + m[4]*result.m[1] +
- m[8]*result.m[2] + m[12]*result.m[3];
-
- if (fabs(det) < 1e-6) {
- return false;
- }
-
- det = 1.0f / det;
- for (i = 0; i < 16; ++i) {
- m[i] = result.m[i] * det;
- }
-
- return true;
-}
-
-// Returns true if the matrix was successfully inversed
-bool Matrix4x4::inverseTranspose() {
- rs_matrix4x4 result;
-
- int i, j;
- for (i = 0; i < 4; ++i) {
- for (j = 0; j < 4; ++j) {
- // computeCofactor for int i, int j
- int c0 = (i+1) % 4;
- int c1 = (i+2) % 4;
- int c2 = (i+3) % 4;
- int r0 = (j+1) % 4;
- int r1 = (j+2) % 4;
- int r2 = (j+3) % 4;
-
- float minor = (m[c0 + 4*r0] * (m[c1 + 4*r1] * m[c2 + 4*r2] - m[c1 + 4*r2] * m[c2 + 4*r1]))
- - (m[c0 + 4*r1] * (m[c1 + 4*r0] * m[c2 + 4*r2] - m[c1 + 4*r2] * m[c2 + 4*r0]))
- + (m[c0 + 4*r2] * (m[c1 + 4*r0] * m[c2 + 4*r1] - m[c1 + 4*r1] * m[c2 + 4*r0]));
-
- float cofactor = (i+j) & 1 ? -minor : minor;
-
- result.m[4*j + i] = cofactor;
- }
- }
-
- // Dot product of 0th column of source and 0th column of result
- float det = m[0]*result.m[0] + m[4]*result.m[4] +
- m[8]*result.m[8] + m[12]*result.m[12];
-
- if (fabs(det) < 1e-6) {
- return false;
- }
-
- det = 1.0f / det;
- for (i = 0; i < 16; ++i) {
- m[i] = result.m[i] * det;
- }
-
- return true;
-}
-
-void Matrix4x4::transpose() {
- int i, j;
- float temp;
- for (i = 0; i < 3; ++i) {
- for (j = i + 1; j < 4; ++j) {
- temp = m[i*4 + j];
- m[i*4 + j] = m[j*4 + i];
- m[j*4 + i] = temp;
- }
- }
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////
-
-void Matrix4x4::loadIdentity() {
- m[0] = 1.f;
- m[1] = 0.f;
- m[2] = 0.f;
- m[3] = 0.f;
- m[4] = 0.f;
- m[5] = 1.f;
- m[6] = 0.f;
- m[7] = 0.f;
- m[8] = 0.f;
- m[9] = 0.f;
- m[10] = 1.f;
- m[11] = 0.f;
- m[12] = 0.f;
- m[13] = 0.f;
- m[14] = 0.f;
- m[15] = 1.f;
-}
-
-void Matrix4x4::load(const float *v) {
- memcpy(m, v, sizeof(m));
-}
-
-void Matrix4x4::load(const rs_matrix4x4 *v) {
- memcpy(m, v->m, sizeof(m));
-}
-
-void Matrix4x4::load(const rs_matrix3x3 *v) {
- m[0] = v->m[0];
- m[1] = v->m[1];
- m[2] = v->m[2];
- m[3] = 0.f;
- m[4] = v->m[3];
- m[5] = v->m[4];
- m[6] = v->m[5];
- m[7] = 0.f;
- m[8] = v->m[6];
- m[9] = v->m[7];
- m[10] = v->m[8];
- m[11] = 0.f;
- m[12] = 0.f;
- m[13] = 0.f;
- m[14] = 0.f;
- m[15] = 1.f;
-}
-
-void Matrix4x4::load(const rs_matrix2x2 *v) {
- m[0] = v->m[0];
- m[1] = v->m[1];
- m[2] = 0.f;
- m[3] = 0.f;
- m[4] = v->m[2];
- m[5] = v->m[3];
- m[6] = 0.f;
- m[7] = 0.f;
- m[8] = 0.f;
- m[9] = 0.f;
- m[10] = 1.f;
- m[11] = 0.f;
- m[12] = 0.f;
- m[13] = 0.f;
- m[14] = 0.f;
- m[15] = 1.f;
-}
-
-
-void Matrix4x4::loadRotate(float rot, float x, float y, float z) {
- float c, s;
- m[3] = 0;
- m[7] = 0;
- m[11]= 0;
- m[12]= 0;
- m[13]= 0;
- m[14]= 0;
- m[15]= 1;
- rot *= float(M_PI / 180.0f);
- c = cosf(rot);
- s = sinf(rot);
-
- const float len = x*x + y*y + z*z;
- if (len != 1) {
- const float recipLen = 1.f / sqrtf(len);
- x *= recipLen;
- y *= recipLen;
- z *= recipLen;
- }
- const float nc = 1.0f - c;
- const float xy = x * y;
- const float yz = y * z;
- const float zx = z * x;
- const float xs = x * s;
- const float ys = y * s;
- const float zs = z * s;
- m[ 0] = x*x*nc + c;
- m[ 4] = xy*nc - zs;
- m[ 8] = zx*nc + ys;
- m[ 1] = xy*nc + zs;
- m[ 5] = y*y*nc + c;
- m[ 9] = yz*nc - xs;
- m[ 2] = zx*nc - ys;
- m[ 6] = yz*nc + xs;
- m[10] = z*z*nc + c;
-}
-
-void Matrix4x4::loadScale(float x, float y, float z) {
- loadIdentity();
- set(0, 0, x);
- set(1, 1, y);
- set(2, 2, z);
-}
-
-void Matrix4x4::loadTranslate(float x, float y, float z) {
- loadIdentity();
- m[12] = x;
- m[13] = y;
- m[14] = z;
-}
-
-void Matrix4x4::loadMultiply(const rs_matrix4x4 *lhs, const rs_matrix4x4 *rhs) {
- for (int i=0 ; i<4 ; i++) {
- float ri0 = 0;
- float ri1 = 0;
- float ri2 = 0;
- float ri3 = 0;
- for (int j=0 ; j<4 ; j++) {
- const float rhs_ij = ((const Matrix4x4 *)rhs)->get(i,j);
- ri0 += ((const Matrix4x4 *)lhs)->get(j,0) * rhs_ij;
- ri1 += ((const Matrix4x4 *)lhs)->get(j,1) * rhs_ij;
- ri2 += ((const Matrix4x4 *)lhs)->get(j,2) * rhs_ij;
- ri3 += ((const Matrix4x4 *)lhs)->get(j,3) * rhs_ij;
- }
- set(i,0, ri0);
- set(i,1, ri1);
- set(i,2, ri2);
- set(i,3, ri3);
- }
-}
-
-void Matrix4x4::loadOrtho(float left, float right, float bottom, float top, float near, float far) {
- loadIdentity();
- m[0] = 2.f / (right - left);
- m[5] = 2.f / (top - bottom);
- m[10]= -2.f / (far - near);
- m[12]= -(right + left) / (right - left);
- m[13]= -(top + bottom) / (top - bottom);
- m[14]= -(far + near) / (far - near);
-}
-
-void Matrix4x4::loadFrustum(float left, float right, float bottom, float top, float near, float far) {
- loadIdentity();
- m[0] = 2.f * near / (right - left);
- m[5] = 2.f * near / (top - bottom);
- m[8] = (right + left) / (right - left);
- m[9] = (top + bottom) / (top - bottom);
- m[10]= -(far + near) / (far - near);
- m[11]= -1.f;
- m[14]= -2.f * far * near / (far - near);
- m[15]= 0.f;
-}
-
-void Matrix4x4::loadPerspective(float fovy, float aspect, float near, float far) {
- float top = near * tan((float) (fovy * M_PI / 360.0f));
- float bottom = -top;
- float left = bottom * aspect;
- float right = top * aspect;
- loadFrustum(left, right, bottom, top, near, far);
-}
-
-void Matrix4x4::vectorMultiply(float *out, const float *in) const {
- out[0] = (m[0] * in[0]) + (m[4] * in[1]) + (m[8] * in[2]) + m[12];
- out[1] = (m[1] * in[0]) + (m[5] * in[1]) + (m[9] * in[2]) + m[13];
- out[2] = (m[2] * in[0]) + (m[6] * in[1]) + (m[10] * in[2]) + m[14];
- out[3] = (m[3] * in[0]) + (m[7] * in[1]) + (m[11] * in[2]) + m[15];
-}
-
-void Matrix4x4::logv(const char *s) const {
- ALOGV("%s {%f, %f, %f, %f", s, m[0], m[4], m[8], m[12]);
- ALOGV("%s %f, %f, %f, %f", s, m[1], m[5], m[9], m[13]);
- ALOGV("%s %f, %f, %f, %f", s, m[2], m[6], m[10], m[14]);
- ALOGV("%s %f, %f, %f, %f}", s, m[3], m[7], m[11], m[15]);
-}
diff --git a/libs/rs/rsMatrix4x4.h b/libs/rs/rsMatrix4x4.h
deleted file mode 100644
index d30184f..0000000
--- a/libs/rs/rsMatrix4x4.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#ifndef ANDROID_RS_MATRIX_4x4_H
-#define ANDROID_RS_MATRIX_4x4_H
-
-#include "rsType.h"
-
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-struct Matrix4x4 : public rs_matrix4x4 {
- float get(uint32_t row, uint32_t col) const {
- return m[row*4 + col];
- }
-
- void set(uint32_t row, uint32_t col, float v) {
- m[row*4 + col] = v;
- }
-
- void loadIdentity();
- void load(const float *);
- void load(const rs_matrix4x4 *);
- void load(const rs_matrix3x3 *);
- void load(const rs_matrix2x2 *);
-
- void loadRotate(float rot, float x, float y, float z);
- void loadScale(float x, float y, float z);
- void loadTranslate(float x, float y, float z);
- void loadMultiply(const rs_matrix4x4 *lhs, const rs_matrix4x4 *rhs);
-
- void loadOrtho(float l, float r, float b, float t, float n, float f);
- void loadFrustum(float l, float r, float b, float t, float n, float f);
- void loadPerspective(float fovy, float aspect, float near, float far);
-
- void vectorMultiply(float *v4out, const float *v3in) const;
-
- bool inverse();
- bool inverseTranspose();
- void transpose();
-
- void logv(const char *s) const;
-
-
- void multiply(const rs_matrix4x4 *rhs) {
- Matrix4x4 tmp;
- tmp.loadMultiply(this, rhs);
- load(&tmp);
- }
- void rotate(float rot, float x, float y, float z) {
- Matrix4x4 tmp;
- tmp.loadRotate(rot, x, y, z);
- multiply(&tmp);
- }
- void scale(float x, float y, float z) {
- Matrix4x4 tmp;
- tmp.loadScale(x, y, z);
- multiply(&tmp);
- }
- void translate(float x, float y, float z) {
- Matrix4x4 tmp;
- tmp.loadTranslate(x, y, z);
- multiply(&tmp);
- }
-};
-
-}
-}
-
-
-
-
-#endif
-
-
-
-
diff --git a/libs/rs/rsMesh.cpp b/libs/rs/rsMesh.cpp
deleted file mode 100644
index 399a52b..0000000
--- a/libs/rs/rsMesh.cpp
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#include "rsContext.h"
-#include "rsMesh.h"
-#include "rs.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-Mesh::Mesh(Context *rsc) : ObjectBase(rsc) {
- mHal.drv = NULL;
- mHal.state.primitives = NULL;
- mHal.state.primitivesCount = 0;
- mHal.state.indexBuffers = NULL;
- mHal.state.indexBuffersCount = 0;
- mHal.state.vertexBuffers = NULL;
- mHal.state.vertexBuffersCount = 0;
- mInitialized = false;
-
- mVertexBuffers = NULL;
- mIndexBuffers = NULL;
-}
-
-Mesh::Mesh(Context *rsc,
- uint32_t vertexBuffersCount,
- uint32_t primitivesCount) : ObjectBase(rsc) {
- mHal.drv = NULL;
- mHal.state.primitivesCount = primitivesCount;
- mHal.state.indexBuffersCount = primitivesCount;
- mHal.state.primitives = new RsPrimitive[mHal.state.primitivesCount];
- mHal.state.indexBuffers = new Allocation *[mHal.state.indexBuffersCount];
- for (uint32_t i = 0; i < mHal.state.primitivesCount; i ++) {
- mHal.state.primitives[i] = RS_PRIMITIVE_POINT;
- }
- for (uint32_t i = 0; i < mHal.state.indexBuffersCount; i ++) {
- mHal.state.indexBuffers[i] = NULL;
- }
- mHal.state.vertexBuffersCount = vertexBuffersCount;
- mHal.state.vertexBuffers = new Allocation *[mHal.state.vertexBuffersCount];
- for (uint32_t i = 0; i < mHal.state.vertexBuffersCount; i ++) {
- mHal.state.vertexBuffers[i] = NULL;
- }
-
- mVertexBuffers = new ObjectBaseRef<Allocation>[mHal.state.vertexBuffersCount];
- mIndexBuffers = new ObjectBaseRef<Allocation>[mHal.state.primitivesCount];
-}
-
-Mesh::~Mesh() {
-#ifndef ANDROID_RS_SERIALIZE
- mRSC->mHal.funcs.mesh.destroy(mRSC, this);
-#endif
-
- delete[] mHal.state.vertexBuffers;
- delete[] mHal.state.primitives;
- delete[] mHal.state.indexBuffers;
-
- delete[] mVertexBuffers;
- delete[] mIndexBuffers;
-}
-
-void Mesh::init() {
-#ifndef ANDROID_RS_SERIALIZE
- mRSC->mHal.funcs.mesh.init(mRSC, this);
-#endif
-}
-
-void Mesh::serialize(OStream *stream) const {
- // Need to identify ourselves
- stream->addU32((uint32_t)getClassId());
-
- String8 name(getName());
- stream->addString(&name);
-
- // Store number of vertex streams
- stream->addU32(mHal.state.vertexBuffersCount);
- for (uint32_t vCount = 0; vCount < mHal.state.vertexBuffersCount; vCount ++) {
- mHal.state.vertexBuffers[vCount]->serialize(stream);
- }
-
- stream->addU32(mHal.state.primitivesCount);
- // Store the primitives
- for (uint32_t pCount = 0; pCount < mHal.state.primitivesCount; pCount ++) {
- stream->addU8((uint8_t)mHal.state.primitives[pCount]);
-
- if (mHal.state.indexBuffers[pCount]) {
- stream->addU32(1);
- mHal.state.indexBuffers[pCount]->serialize(stream);
- } else {
- stream->addU32(0);
- }
- }
-}
-
-Mesh *Mesh::createFromStream(Context *rsc, IStream *stream) {
- // First make sure we are reading the correct object
- RsA3DClassID classID = (RsA3DClassID)stream->loadU32();
- if (classID != RS_A3D_CLASS_ID_MESH) {
- ALOGE("mesh loading skipped due to invalid class id");
- return NULL;
- }
-
- String8 name;
- stream->loadString(&name);
-
- uint32_t vertexBuffersCount = stream->loadU32();
- ObjectBaseRef<Allocation> *vertexBuffers = NULL;
- if (vertexBuffersCount) {
- vertexBuffers = new ObjectBaseRef<Allocation>[vertexBuffersCount];
-
- for (uint32_t vCount = 0; vCount < vertexBuffersCount; vCount ++) {
- Allocation *vertexAlloc = Allocation::createFromStream(rsc, stream);
- vertexBuffers[vCount].set(vertexAlloc);
- }
- }
-
- uint32_t primitivesCount = stream->loadU32();
- ObjectBaseRef<Allocation> *indexBuffers = NULL;
- RsPrimitive *primitives = NULL;
- if (primitivesCount) {
- indexBuffers = new ObjectBaseRef<Allocation>[primitivesCount];
- primitives = new RsPrimitive[primitivesCount];
-
- // load all primitives
- for (uint32_t pCount = 0; pCount < primitivesCount; pCount ++) {
- primitives[pCount] = (RsPrimitive)stream->loadU8();
-
- // Check to see if the index buffer was stored
- uint32_t isIndexPresent = stream->loadU32();
- if (isIndexPresent) {
- Allocation *indexAlloc = Allocation::createFromStream(rsc, stream);
- indexBuffers[pCount].set(indexAlloc);
- }
- }
- }
-
- Mesh *mesh = new Mesh(rsc, vertexBuffersCount, primitivesCount);
- mesh->setName(name.string(), name.size());
- for (uint32_t vCount = 0; vCount < vertexBuffersCount; vCount ++) {
- mesh->setVertexBuffer(vertexBuffers[vCount].get(), vCount);
- }
- for (uint32_t pCount = 0; pCount < primitivesCount; pCount ++) {
- mesh->setPrimitive(indexBuffers[pCount].get(), primitives[pCount], pCount);
- }
-
- // Cleanup
- if (vertexBuffersCount) {
- delete[] vertexBuffers;
- }
- if (primitivesCount) {
- delete[] indexBuffers;
- delete[] primitives;
- }
-
-#ifndef ANDROID_RS_SERIALIZE
- mesh->init();
- mesh->uploadAll(rsc);
-#endif
- return mesh;
-}
-
-void Mesh::render(Context *rsc) const {
- for (uint32_t ct = 0; ct < mHal.state.primitivesCount; ct ++) {
- renderPrimitive(rsc, ct);
- }
-}
-
-void Mesh::renderPrimitive(Context *rsc, uint32_t primIndex) const {
- if (primIndex >= mHal.state.primitivesCount) {
- ALOGE("Invalid primitive index");
- return;
- }
-
- if (mHal.state.indexBuffers[primIndex]) {
- renderPrimitiveRange(rsc, primIndex, 0, mHal.state.indexBuffers[primIndex]->getType()->getDimX());
- return;
- }
-
- renderPrimitiveRange(rsc, primIndex, 0, mHal.state.vertexBuffers[0]->getType()->getDimX());
-}
-
-void Mesh::renderPrimitiveRange(Context *rsc, uint32_t primIndex, uint32_t start, uint32_t len) const {
- if (len < 1 || primIndex >= mHal.state.primitivesCount) {
- ALOGE("Invalid mesh or parameters");
- return;
- }
-
- mRSC->mHal.funcs.mesh.draw(mRSC, this, primIndex, start, len);
-}
-
-void Mesh::uploadAll(Context *rsc) {
- for (uint32_t ct = 0; ct < mHal.state.vertexBuffersCount; ct ++) {
- if (mHal.state.vertexBuffers[ct]) {
- rsc->mHal.funcs.allocation.markDirty(rsc, mHal.state.vertexBuffers[ct]);
- }
- }
-
- for (uint32_t ct = 0; ct < mHal.state.primitivesCount; ct ++) {
- if (mHal.state.indexBuffers[ct]) {
- rsc->mHal.funcs.allocation.markDirty(rsc, mHal.state.indexBuffers[ct]);
- }
- }
-}
-
-void Mesh::computeBBox() {
- float *posPtr = NULL;
- uint32_t vectorSize = 0;
- uint32_t stride = 0;
- uint32_t numVerts = 0;
- // First we need to find the position ptr and stride
- for (uint32_t ct=0; ct < mHal.state.vertexBuffersCount; ct++) {
- const Type *bufferType = mHal.state.vertexBuffers[ct]->getType();
- const Element *bufferElem = bufferType->getElement();
-
- for (uint32_t ct=0; ct < bufferElem->getFieldCount(); ct++) {
- if (strcmp(bufferElem->getFieldName(ct), "position") == 0) {
- vectorSize = bufferElem->getField(ct)->getComponent().getVectorSize();
- stride = bufferElem->getSizeBytes() / sizeof(float);
- uint32_t offset = bufferElem->getFieldOffsetBytes(ct);
- posPtr = (float*)((uint8_t*)mHal.state.vertexBuffers[ct]->getPtr() + offset);
- numVerts = bufferType->getDimX();
- break;
- }
- }
- if (posPtr) {
- break;
- }
- }
-
- mBBoxMin[0] = mBBoxMin[1] = mBBoxMin[2] = 1e6;
- mBBoxMax[0] = mBBoxMax[1] = mBBoxMax[2] = -1e6;
- if (!posPtr) {
- ALOGE("Unable to compute bounding box");
- mBBoxMin[0] = mBBoxMin[1] = mBBoxMin[2] = 0.0f;
- mBBoxMax[0] = mBBoxMax[1] = mBBoxMax[2] = 0.0f;
- return;
- }
-
- for (uint32_t i = 0; i < numVerts; i ++) {
- for (uint32_t v = 0; v < vectorSize; v ++) {
- mBBoxMin[v] = rsMin(mBBoxMin[v], posPtr[v]);
- mBBoxMax[v] = rsMax(mBBoxMax[v], posPtr[v]);
- }
- posPtr += stride;
- }
-}
-
-namespace android {
-namespace renderscript {
-
-RsMesh rsi_MeshCreate(Context *rsc,
- RsAllocation * vtx, size_t vtxCount,
- RsAllocation * idx, size_t idxCount,
- uint32_t * primType, size_t primTypeCount) {
- rsAssert(idxCount == primTypeCount);
- Mesh *sm = new Mesh(rsc, vtxCount, idxCount);
- sm->incUserRef();
-
- for (uint32_t i = 0; i < vtxCount; i ++) {
- sm->setVertexBuffer((Allocation*)vtx[i], i);
- }
-
- for (uint32_t i = 0; i < idxCount; i ++) {
- sm->setPrimitive((Allocation*)idx[i], (RsPrimitive)primType[i], i);
- }
-
- sm->init();
-
- return sm;
-}
-
-}}
-
-void rsaMeshGetVertexBufferCount(RsContext con, RsMesh mv, int32_t *numVtx) {
- Mesh *sm = static_cast<Mesh *>(mv);
- *numVtx = sm->mHal.state.vertexBuffersCount;
-}
-
-void rsaMeshGetIndexCount(RsContext con, RsMesh mv, int32_t *numIdx) {
- Mesh *sm = static_cast<Mesh *>(mv);
- *numIdx = sm->mHal.state.primitivesCount;
-}
-
-void rsaMeshGetVertices(RsContext con, RsMesh mv, RsAllocation *vtxData, uint32_t vtxDataCount) {
- Mesh *sm = static_cast<Mesh *>(mv);
- rsAssert(vtxDataCount == sm->mHal.state.vertexBuffersCount);
-
- for (uint32_t ct = 0; ct < vtxDataCount; ct ++) {
- vtxData[ct] = sm->mHal.state.vertexBuffers[ct];
- sm->mHal.state.vertexBuffers[ct]->incUserRef();
- }
-}
-
-void rsaMeshGetIndices(RsContext con, RsMesh mv, RsAllocation *va, uint32_t *primType, uint32_t idxDataCount) {
- Mesh *sm = static_cast<Mesh *>(mv);
- rsAssert(idxDataCount == sm->mHal.state.primitivesCount);
-
- for (uint32_t ct = 0; ct < idxDataCount; ct ++) {
- va[ct] = sm->mHal.state.indexBuffers[ct];
- primType[ct] = sm->mHal.state.primitives[ct];
- if (sm->mHal.state.indexBuffers[ct]) {
- sm->mHal.state.indexBuffers[ct]->incUserRef();
- }
- }
-}
diff --git a/libs/rs/rsMesh.h b/libs/rs/rsMesh.h
deleted file mode 100644
index 7ca63cf..0000000
--- a/libs/rs/rsMesh.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef ANDROID_RS_MESH_H
-#define ANDROID_RS_MESH_H
-
-
-#include "rsObjectBase.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-/*****************************************************************************
- * CAUTION
- *
- * Any layout changes for this class may require a corresponding change to be
- * made to frameworks/compile/libbcc/lib/ScriptCRT/rs_core.c, which contains
- * a partial copy of the information below.
- *
- *****************************************************************************/
-
-// An element is a group of Components that occupies one cell in a structure.
-class Mesh : public ObjectBase {
-public:
- struct Hal {
- mutable void *drv;
-
- struct State {
- // Contains vertex data
- // Position, normal, texcoord, etc could either be strided in one allocation
- // of provided separetely in multiple ones
- Allocation **vertexBuffers;
- uint32_t vertexBuffersCount;
-
- // indexBuffers[i] could be NULL, in which case only primitives[i] is used
- Allocation **indexBuffers;
- uint32_t indexBuffersCount;
- RsPrimitive *primitives;
- uint32_t primitivesCount;
- };
- State state;
- };
- Hal mHal;
-
- Mesh(Context *);
- Mesh(Context *, uint32_t vertexBuffersCount, uint32_t primitivesCount);
- ~Mesh();
-
- virtual void serialize(OStream *stream) const;
- virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_MESH; }
- static Mesh *createFromStream(Context *rsc, IStream *stream);
- void init();
-
- void setVertexBuffer(Allocation *vb, uint32_t index) {
- mVertexBuffers[index].set(vb);
- mHal.state.vertexBuffers[index] = vb;
- }
-
- void setPrimitive(Allocation *idx, RsPrimitive prim, uint32_t index) {
- mIndexBuffers[index].set(idx);
- mHal.state.indexBuffers[index] = idx;
- mHal.state.primitives[index] = prim;
- }
-
- void render(Context *) const;
- void renderPrimitive(Context *, uint32_t primIndex) const;
- void renderPrimitiveRange(Context *, uint32_t primIndex, uint32_t start, uint32_t len) const;
- void uploadAll(Context *);
-
- // Bounding volumes
- float mBBoxMin[3];
- float mBBoxMax[3];
- void computeBBox();
-protected:
- ObjectBaseRef<Allocation> *mVertexBuffers;
- ObjectBaseRef<Allocation> *mIndexBuffers;
- bool mInitialized;
-};
-
-class MeshContext {
-public:
- MeshContext() {
- }
- ~MeshContext() {
- }
-};
-
-}
-}
-#endif //ANDROID_RS_MESH_H
-
-
-
diff --git a/libs/rs/rsMutex.cpp b/libs/rs/rsMutex.cpp
deleted file mode 100644
index 6512372..0000000
--- a/libs/rs/rsMutex.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#include "rsMutex.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-
-Mutex::Mutex() {
-}
-
-Mutex::~Mutex() {
- pthread_mutex_destroy(&mMutex);
-}
-
-bool Mutex::init() {
- int status = pthread_mutex_init(&mMutex, NULL);
- if (status) {
- ALOGE("Mutex::Mutex init failure");
- return false;
- }
- return true;
-}
-
-bool Mutex::lock() {
- int status;
- status = pthread_mutex_lock(&mMutex);
- if (status) {
- ALOGE("Mutex: error %i locking.", status);
- return false;
- }
- return true;
-}
-
-bool Mutex::unlock() {
- int status;
- status = pthread_mutex_unlock(&mMutex);
- if (status) {
- ALOGE("Mutex error %i unlocking.", status);
- return false;
- }
- return true;
-}
-
-
diff --git a/libs/rs/rsMutex.h b/libs/rs/rsMutex.h
deleted file mode 100644
index 47725d7..0000000
--- a/libs/rs/rsMutex.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#ifndef ANDROID_RS_MUTEX_H
-#define ANDROID_RS_MUTEX_H
-
-
-#include "rsUtils.h"
-
-namespace android {
-namespace renderscript {
-
-class Mutex {
-public:
- Mutex();
- ~Mutex();
-
- bool init();
- bool lock();
- bool unlock();
-
-protected:
- pthread_mutex_t mMutex;
-};
-
-}
-}
-
-#endif
-
diff --git a/libs/rs/rsObjectBase.cpp b/libs/rs/rsObjectBase.cpp
deleted file mode 100644
index 6a64582..0000000
--- a/libs/rs/rsObjectBase.cpp
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#include "rsObjectBase.h"
-#include "rsContext.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-pthread_mutex_t ObjectBase::gObjectInitMutex = PTHREAD_MUTEX_INITIALIZER;
-
-ObjectBase::ObjectBase(Context *rsc) {
- mUserRefCount = 0;
- mSysRefCount = 0;
- mRSC = rsc;
- mNext = NULL;
- mPrev = NULL;
-
-#if RS_OBJECT_DEBUG
- mStack.update(2);
-#endif
-
- rsAssert(rsc);
- add();
- //ALOGV("ObjectBase %p con", this);
-}
-
-ObjectBase::~ObjectBase() {
- //ALOGV("~ObjectBase %p ref %i,%i", this, mUserRefCount, mSysRefCount);
-#if RS_OBJECT_DEBUG
- mStack.dump();
-#endif
-
- if (mPrev || mNext) {
- // While the normal practice is to call remove before we call
- // delete. Its possible for objects without a re-use list
- // for avoiding duplication to be created on the stack. In those
- // cases we need to remove ourself here.
- asyncLock();
- remove();
- asyncUnlock();
- }
-
- rsAssert(!mUserRefCount);
- rsAssert(!mSysRefCount);
-}
-
-void ObjectBase::dumpLOGV(const char *op) const {
- if (mName.size()) {
- ALOGV("%s RSobj %p, name %s, refs %i,%i links %p,%p,%p",
- op, this, mName.string(), mUserRefCount, mSysRefCount, mNext, mPrev, mRSC);
- } else {
- ALOGV("%s RSobj %p, no-name, refs %i,%i links %p,%p,%p",
- op, this, mUserRefCount, mSysRefCount, mNext, mPrev, mRSC);
- }
-}
-
-void ObjectBase::incUserRef() const {
- android_atomic_inc(&mUserRefCount);
- //ALOGV("ObjectBase %p incU ref %i, %i", this, mUserRefCount, mSysRefCount);
-}
-
-void ObjectBase::incSysRef() const {
- android_atomic_inc(&mSysRefCount);
- //ALOGV("ObjectBase %p incS ref %i, %i", this, mUserRefCount, mSysRefCount);
-}
-
-void ObjectBase::preDestroy() const {
-}
-
-bool ObjectBase::freeChildren() {
- return false;
-}
-
-bool ObjectBase::checkDelete(const ObjectBase *ref) {
- if (!ref) {
- return false;
- }
-
- asyncLock();
- // This lock protects us against the non-RS threads changing
- // the ref counts. At this point we should be the only thread
- // working on them.
- if (ref->mUserRefCount || ref->mSysRefCount) {
- asyncUnlock();
- return false;
- }
-
- ref->remove();
- // At this point we can unlock because there should be no possible way
- // for another thread to reference this object.
- ref->preDestroy();
- asyncUnlock();
- delete ref;
- return true;
-}
-
-bool ObjectBase::decUserRef() const {
- rsAssert(mUserRefCount > 0);
-#if RS_OBJECT_DEBUG
- ALOGV("ObjectBase %p decU ref %i, %i", this, mUserRefCount, mSysRefCount);
- if (mUserRefCount <= 0) {
- mStack.dump();
- }
-#endif
-
-
- if ((android_atomic_dec(&mUserRefCount) <= 1) &&
- (android_atomic_acquire_load(&mSysRefCount) <= 0)) {
- return checkDelete(this);
- }
- return false;
-}
-
-bool ObjectBase::zeroUserRef() const {
- //ALOGV("ObjectBase %p zeroU ref %i, %i", this, mUserRefCount, mSysRefCount);
- android_atomic_acquire_store(0, &mUserRefCount);
- if (android_atomic_acquire_load(&mSysRefCount) <= 0) {
- return checkDelete(this);
- }
- return false;
-}
-
-bool ObjectBase::decSysRef() const {
- //ALOGV("ObjectBase %p decS ref %i, %i", this, mUserRefCount, mSysRefCount);
- rsAssert(mSysRefCount > 0);
- if ((android_atomic_dec(&mSysRefCount) <= 1) &&
- (android_atomic_acquire_load(&mUserRefCount) <= 0)) {
- return checkDelete(this);
- }
- return false;
-}
-
-void ObjectBase::setName(const char *name) {
- mName.setTo(name);
-}
-
-void ObjectBase::setName(const char *name, uint32_t len) {
- mName.setTo(name, len);
-}
-
-void ObjectBase::asyncLock() {
- pthread_mutex_lock(&gObjectInitMutex);
-}
-
-void ObjectBase::asyncUnlock() {
- pthread_mutex_unlock(&gObjectInitMutex);
-}
-
-void ObjectBase::add() const {
- asyncLock();
-
- rsAssert(!mNext);
- rsAssert(!mPrev);
- //ALOGV("calling add rsc %p", mRSC);
- mNext = mRSC->mObjHead;
- if (mRSC->mObjHead) {
- mRSC->mObjHead->mPrev = this;
- }
- mRSC->mObjHead = this;
-
- asyncUnlock();
-}
-
-void ObjectBase::remove() const {
- //ALOGV("calling remove rsc %p", mRSC);
- if (!mRSC) {
- rsAssert(!mPrev);
- rsAssert(!mNext);
- return;
- }
-
- if (mRSC->mObjHead == this) {
- mRSC->mObjHead = mNext;
- }
- if (mPrev) {
- mPrev->mNext = mNext;
- }
- if (mNext) {
- mNext->mPrev = mPrev;
- }
- mPrev = NULL;
- mNext = NULL;
-}
-
-void ObjectBase::zeroAllUserRef(Context *rsc) {
- if (rsc->props.mLogObjects) {
- ALOGV("Forcing release of all outstanding user refs.");
- }
-
- // This operation can be slow, only to be called during context cleanup.
- const ObjectBase * o = rsc->mObjHead;
- while (o) {
- //ALOGE("o %p", o);
- if (o->zeroUserRef()) {
- // deleted the object and possibly others, restart from head.
- o = rsc->mObjHead;
- //ALOGE("o head %p", o);
- } else {
- o = o->mNext;
- //ALOGE("o next %p", o);
- }
- }
-
- if (rsc->props.mLogObjects) {
- ALOGV("Objects remaining.");
- dumpAll(rsc);
- }
-}
-
-void ObjectBase::freeAllChildren(Context *rsc) {
- if (rsc->props.mLogObjects) {
- ALOGV("Forcing release of all child objects.");
- }
-
- // This operation can be slow, only to be called during context cleanup.
- ObjectBase * o = (ObjectBase *)rsc->mObjHead;
- while (o) {
- if (o->freeChildren()) {
- // deleted ref to self and possibly others, restart from head.
- o = (ObjectBase *)rsc->mObjHead;
- } else {
- o = (ObjectBase *)o->mNext;
- }
- }
-
- if (rsc->props.mLogObjects) {
- ALOGV("Objects remaining.");
- dumpAll(rsc);
- }
-}
-
-void ObjectBase::dumpAll(Context *rsc) {
- asyncLock();
-
- ALOGV("Dumping all objects");
- const ObjectBase * o = rsc->mObjHead;
- while (o) {
- ALOGV(" Object %p", o);
- o->dumpLOGV(" ");
- o = o->mNext;
- }
-
- asyncUnlock();
-}
-
-bool ObjectBase::isValid(const Context *rsc, const ObjectBase *obj) {
- asyncLock();
-
- const ObjectBase * o = rsc->mObjHead;
- while (o) {
- if (o == obj) {
- asyncUnlock();
- return true;
- }
- o = o->mNext;
- }
- asyncUnlock();
- return false;
-}
-
diff --git a/libs/rs/rsObjectBase.h b/libs/rs/rsObjectBase.h
deleted file mode 100644
index 586da19..0000000
--- a/libs/rs/rsObjectBase.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#ifndef ANDROID_RS_OBJECT_BASE_H
-#define ANDROID_RS_OBJECT_BASE_H
-
-#include "rsUtils.h"
-#include "rsDefines.h"
-
-#define RS_OBJECT_DEBUG 0
-
-#include <utils/CallStack.h>
-
-namespace android {
-namespace renderscript {
-
-class Context;
-class OStream;
-
-// An element is a group of Components that occupies one cell in a structure.
-class ObjectBase {
-public:
- ObjectBase(Context *rsc);
-
- void incSysRef() const;
- bool decSysRef() const;
-
- void incUserRef() const;
- bool decUserRef() const;
- bool zeroUserRef() const;
-
- static bool checkDelete(const ObjectBase *);
-
- const char * getName() const {
- return mName.string();
- }
- void setName(const char *);
- void setName(const char *, uint32_t len);
-
- Context * getContext() const {return mRSC;}
- virtual bool freeChildren();
-
- static void zeroAllUserRef(Context *rsc);
- static void freeAllChildren(Context *rsc);
- static void dumpAll(Context *rsc);
-
- virtual void dumpLOGV(const char *prefix) const;
- virtual void serialize(OStream *stream) const = 0;
- virtual RsA3DClassID getClassId() const = 0;
-
- static bool isValid(const Context *rsc, const ObjectBase *obj);
-
- // The async lock is taken during object creation in non-rs threads
- // and object deletion in the rs thread.
- static void asyncLock();
- static void asyncUnlock();
-
-protected:
- // Called inside the async lock for any object list management that is
- // necessary in derived classes.
- virtual void preDestroy() const;
-
- Context *mRSC;
- virtual ~ObjectBase();
-
-private:
- static pthread_mutex_t gObjectInitMutex;
-
- void add() const;
- void remove() const;
-
- String8 mName;
- mutable int32_t mSysRefCount;
- mutable int32_t mUserRefCount;
-
- mutable const ObjectBase * mPrev;
- mutable const ObjectBase * mNext;
-
-#if RS_OBJECT_DEBUG
- CallStack mStack;
-#endif
-
-};
-
-template<class T>
-class ObjectBaseRef {
-public:
- ObjectBaseRef() {
- mRef = NULL;
- }
-
- ObjectBaseRef(const ObjectBaseRef &ref) {
- mRef = ref.get();
- if (mRef) {
- mRef->incSysRef();
- }
- }
-
- ObjectBaseRef(T *ref) {
- mRef = ref;
- if (mRef) {
- ref->incSysRef();
- }
- }
-
- ObjectBaseRef & operator= (const ObjectBaseRef &ref) {
- if (&ref != this) {
- set(ref);
- }
- return *this;
- }
-
- ~ObjectBaseRef() {
- clear();
- }
-
- void set(T *ref) {
- if (mRef != ref) {
- clear();
- mRef = ref;
- if (mRef) {
- ref->incSysRef();
- }
- }
- }
-
- void set(const ObjectBaseRef &ref) {
- set(ref.mRef);
- }
-
- void clear() {
- if (mRef) {
- mRef->decSysRef();
- }
- mRef = NULL;
- }
-
- inline T * get() const {
- return mRef;
- }
-
- inline T * operator-> () const {
- return mRef;
- }
-
-protected:
- T * mRef;
-};
-
-}
-}
-
-#endif //ANDROID_RS_OBJECT_BASE_H
-
diff --git a/libs/rs/rsPath.cpp b/libs/rs/rsPath.cpp
deleted file mode 100644
index 055bb86..0000000
--- a/libs/rs/rsPath.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#include "rsContext.h"
-#include "rs.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-
-Path::Path(Context *rsc) : ObjectBase(rsc) {
-}
-
-Path::Path(Context *rsc, RsPathPrimitive pp, bool isStatic,
- Allocation *vtx, Allocation *loops, float quality)
-: ObjectBase(rsc) {
-
- memset(&mHal, 0, sizeof(mHal));
- mHal.state.quality = quality;
- mHal.state.primitive = pp;
-
- //LOGE("i1");
- rsc->mHal.funcs.path.initStatic(rsc, this, vtx, loops);
-
- //LOGE("i2");
-}
-
-Path::Path(Context *rsc, uint32_t vertexBuffersCount, uint32_t primitivesCount)
-: ObjectBase(rsc) {
-
-}
-
-Path::~Path() {
-
-}
-
-
-void Path::rasterize(const BezierSegment_t *s, uint32_t num, Allocation *alloc) {
-
- for (uint32_t i=0; i < num; i++) {
-
- }
-
-}
-
-void Path::render(Context *rsc) {
-}
-
-void Path::serialize(OStream *stream) const {
-
-}
-
-RsA3DClassID Path::getClassId() const {
- return RS_A3D_CLASS_ID_UNKNOWN;
-}
-
-namespace android {
-namespace renderscript {
-
-RsPath rsi_PathCreate(Context *rsc, RsPathPrimitive pp, bool isStatic,
- RsAllocation vtx, RsAllocation loops, float quality) {
- return new Path(rsc, pp, isStatic, (Allocation *)vtx, (Allocation *)loops, quality);
-}
-
-}
-}
diff --git a/libs/rs/rsPath.h b/libs/rs/rsPath.h
deleted file mode 100644
index 1abfc9a..0000000
--- a/libs/rs/rsPath.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef ANDROID_RS_PATH_H
-#define ANDROID_RS_PATH_H
-
-
-#include "rsObjectBase.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-class Path : public ObjectBase {
-public:
- struct {
- mutable void * drv;
-
- struct State {
- RsPathPrimitive primitive;
- float quality;
- };
- State state;
- } mHal;
-
- Path(Context *);
- Path(Context *, uint32_t vertexBuffersCount, uint32_t primitivesCount);
- Path(Context *, RsPathPrimitive pp, bool isStatic, Allocation *vtx, Allocation *loop, float q);
-
- ~Path();
-
- void render(Context *);
- virtual void serialize(OStream *stream) const;
- virtual RsA3DClassID getClassId() const;
-
-private:
-
-
- typedef struct {
- float x[4];
- float y[4];
- } BezierSegment_t;
-
- bool subdivideCheck(const BezierSegment_t *s, float u1, float u2);
-
- void rasterize(const BezierSegment_t *s, uint32_t num, Allocation *alloc);
-
-
-};
-
-}
-}
-#endif //ANDROID_RS_PATH_H
-
-
-
diff --git a/libs/rs/rsProgram.cpp b/libs/rs/rsProgram.cpp
deleted file mode 100644
index 7114f29..0000000
--- a/libs/rs/rsProgram.cpp
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#include "rsContext.h"
-#include "rsProgram.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-Program::Program(Context *rsc, const char * shaderText, size_t shaderLength,
- const uint32_t * params, size_t paramLength)
- : ProgramBase(rsc) {
-
- initMemberVars();
- for (uint32_t ct=0; ct < paramLength; ct+=2) {
- if (params[ct] == RS_PROGRAM_PARAM_INPUT) {
- mHal.state.inputElementsCount++;
- }
- if (params[ct] == RS_PROGRAM_PARAM_CONSTANT) {
- mHal.state.constantsCount++;
- }
- if (params[ct] == RS_PROGRAM_PARAM_TEXTURE_TYPE) {
- mHal.state.texturesCount++;
- }
- }
-
- mTextures = new ObjectBaseRef<Allocation>[mHal.state.texturesCount];
- mSamplers = new ObjectBaseRef<Sampler>[mHal.state.texturesCount];
- mInputElements = new ObjectBaseRef<Element>[mHal.state.inputElementsCount];
- mConstantTypes = new ObjectBaseRef<Type>[mHal.state.constantsCount];
- mConstants = new ObjectBaseRef<Allocation>[mHal.state.constantsCount];
-
- mHal.state.textures = new Allocation*[mHal.state.texturesCount];
- mHal.state.samplers = new Sampler*[mHal.state.texturesCount];
- mHal.state.textureTargets = new RsTextureTarget[mHal.state.texturesCount];
- mHal.state.inputElements = new Element*[mHal.state.inputElementsCount];
- mHal.state.constantTypes = new Type*[mHal.state.constantsCount];
- mHal.state.constants = new Allocation*[mHal.state.constantsCount];
-
- // Will initialize everything
- freeChildren();
-
- uint32_t input = 0;
- uint32_t constant = 0;
- uint32_t texture = 0;
- for (uint32_t ct=0; ct < paramLength; ct+=2) {
- if (params[ct] == RS_PROGRAM_PARAM_INPUT) {
- mInputElements[input].set(reinterpret_cast<Element *>(params[ct+1]));
- mHal.state.inputElements[input++] = reinterpret_cast<Element *>(params[ct+1]);
- }
- if (params[ct] == RS_PROGRAM_PARAM_CONSTANT) {
- mConstantTypes[constant].set(reinterpret_cast<Type *>(params[ct+1]));
- mHal.state.constantTypes[constant++] = reinterpret_cast<Type *>(params[ct+1]);
- }
- if (params[ct] == RS_PROGRAM_PARAM_TEXTURE_TYPE) {
- mHal.state.textureTargets[texture++] = (RsTextureTarget)params[ct+1];
- }
- }
- mIsInternal = false;
- uint32_t internalTokenLen = strlen(RS_SHADER_INTERNAL);
- if (shaderLength > internalTokenLen &&
- strncmp(RS_SHADER_INTERNAL, shaderText, internalTokenLen) == 0) {
- mIsInternal = true;
- shaderText += internalTokenLen;
- shaderLength -= internalTokenLen;
- }
- mUserShader.setTo(shaderText, shaderLength);
-}
-
-Program::~Program() {
- freeChildren();
-
- delete[] mTextures;
- delete[] mSamplers;
- delete[] mInputElements;
- delete[] mConstantTypes;
- delete[] mConstants;
-
- delete[] mHal.state.textures;
- delete[] mHal.state.samplers;
- delete[] mHal.state.textureTargets;
- delete[] mHal.state.inputElements;
- delete[] mHal.state.constantTypes;
- delete[] mHal.state.constants;
- mHal.state.inputElementsCount = 0;
- mHal.state.constantsCount = 0;
- mHal.state.texturesCount = 0;
-}
-
-bool Program::freeChildren() {
- for (uint32_t ct=0; ct < mHal.state.constantsCount; ct++) {
- bindAllocation(NULL, NULL, ct);
- }
-
- for (uint32_t ct=0; ct < mHal.state.texturesCount; ct++) {
- bindTexture(NULL, ct, NULL);
- bindSampler(NULL, ct, NULL);
- }
- return false;
-}
-
-void Program::initMemberVars() {
- mDirty = true;
-
- mHal.drv = NULL;
- mHal.state.textures = NULL;
- mHal.state.samplers = NULL;
- mHal.state.textureTargets = NULL;
- mHal.state.inputElements = NULL;
- mHal.state.constantTypes = NULL;
- mHal.state.constants = NULL;
-
- mHal.state.inputElementsCount = 0;
- mHal.state.constantsCount = 0;
- mHal.state.texturesCount = 0;
-
- mTextures = NULL;
- mSamplers = NULL;
- mInputElements = NULL;
- mConstantTypes = NULL;
- mConstants = NULL;
-
- mIsInternal = false;
-}
-
-void Program::bindAllocation(Context *rsc, Allocation *alloc, uint32_t slot) {
- if (alloc != NULL) {
- if (slot >= mHal.state.constantsCount) {
- ALOGE("Attempt to bind alloc at slot %u, on shader id %u, but const count is %u",
- slot, (uint32_t)this, mHal.state.constantsCount);
- rsc->setError(RS_ERROR_BAD_SHADER, "Cannot bind allocation");
- return;
- }
- if (alloc->getType() != mConstantTypes[slot].get()) {
- ALOGE("Attempt to bind alloc at slot %u, on shader id %u, but types mismatch",
- slot, (uint32_t)this);
- rsc->setError(RS_ERROR_BAD_SHADER, "Cannot bind allocation");
- return;
- }
- }
- if (mConstants[slot].get() == alloc) {
- return;
- }
- if (mConstants[slot].get()) {
- mConstants[slot]->removeProgramToDirty(this);
- }
- mConstants[slot].set(alloc);
- mHal.state.constants[slot] = alloc;
- if (alloc) {
- alloc->addProgramToDirty(this);
- }
- mDirty = true;
-}
-
-void Program::bindTexture(Context *rsc, uint32_t slot, Allocation *a) {
- if (slot >= mHal.state.texturesCount) {
- ALOGE("Attempt to bind texture to slot %u but tex count is %u", slot, mHal.state.texturesCount);
- rsc->setError(RS_ERROR_BAD_SHADER, "Cannot bind texture");
- return;
- }
-
- if (a && a->getType()->getDimFaces() && mHal.state.textureTargets[slot] != RS_TEXTURE_CUBE) {
- ALOGE("Attempt to bind cubemap to slot %u but 2d texture needed", slot);
- rsc->setError(RS_ERROR_BAD_SHADER, "Cannot bind cubemap to 2d texture slot");
- return;
- }
-
- mTextures[slot].set(a);
- mHal.state.textures[slot] = a;
-
- mDirty = true;
-}
-
-void Program::bindSampler(Context *rsc, uint32_t slot, Sampler *s) {
- if (slot >= mHal.state.texturesCount) {
- ALOGE("Attempt to bind sampler to slot %u but tex count is %u", slot, mHal.state.texturesCount);
- rsc->setError(RS_ERROR_BAD_SHADER, "Cannot bind sampler");
- return;
- }
-
- mSamplers[slot].set(s);
- mHal.state.samplers[slot] = s;
- mDirty = true;
-}
-
-namespace android {
-namespace renderscript {
-
-void rsi_ProgramBindConstants(Context *rsc, RsProgram vp, uint32_t slot, RsAllocation constants) {
- Program *p = static_cast<Program *>(vp);
- p->bindAllocation(rsc, static_cast<Allocation *>(constants), slot);
-}
-
-void rsi_ProgramBindTexture(Context *rsc, RsProgram vpf, uint32_t slot, RsAllocation a) {
- Program *p = static_cast<Program *>(vpf);
- p->bindTexture(rsc, slot, static_cast<Allocation *>(a));
-}
-
-void rsi_ProgramBindSampler(Context *rsc, RsProgram vpf, uint32_t slot, RsSampler s) {
- Program *p = static_cast<Program *>(vpf);
- p->bindSampler(rsc, slot, static_cast<Sampler *>(s));
-}
-
-}
-}
-
diff --git a/libs/rs/rsProgram.h b/libs/rs/rsProgram.h
deleted file mode 100644
index d032930..0000000
--- a/libs/rs/rsProgram.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef ANDROID_RS_PROGRAM_H
-#define ANDROID_RS_PROGRAM_H
-
-#include "rsProgramBase.h"
-#include "rsElement.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-#define RS_SHADER_INTERNAL "//rs_shader_internal\n"
-#define RS_SHADER_ATTR "ATTRIB_"
-#define RS_SHADER_UNI "UNI_"
-
-class Program : public ProgramBase {
-public:
- struct Hal {
- mutable void *drv;
-
- struct State {
- // The difference between Textures and Constants is how they are accessed
- // Texture lookups go though a sampler which in effect converts normalized
- // coordinates into type specific. Multiple samples may also be taken
- // and filtered.
- //
- // Constants are strictly accessed by the shader code
- Allocation **textures;
- RsTextureTarget *textureTargets;
- uint32_t texturesCount;
-
- Sampler **samplers;
- uint32_t samplersCount;
-
- Allocation **constants;
- Type **constantTypes;
- uint32_t constantsCount;
-
- Element **inputElements;
- uint32_t inputElementsCount;
- };
- State state;
- };
- Hal mHal;
-
- Program(Context *, const char * shaderText, size_t shaderLength,
- const uint32_t * params, size_t paramLength);
- virtual ~Program();
- virtual bool freeChildren();
-
- void bindAllocation(Context *, Allocation *, uint32_t slot);
-
- bool isUserProgram() const {return !mIsInternal;}
-
- void bindTexture(Context *, uint32_t slot, Allocation *);
- void bindSampler(Context *, uint32_t slot, Sampler *);
-
-protected:
- ObjectBaseRef<Allocation> *mTextures;
- ObjectBaseRef<Sampler> *mSamplers;
- ObjectBaseRef<Allocation> *mConstants;
- ObjectBaseRef<Type> *mConstantTypes;
- ObjectBaseRef<Element> *mInputElements;
-
- bool mIsInternal;
- String8 mUserShader;
- void initMemberVars();
-};
-
-}
-}
-#endif // ANDROID_RS_PROGRAM_H
-
-
-
diff --git a/libs/rs/rsProgramBase.h b/libs/rs/rsProgramBase.h
deleted file mode 100644
index 80da453..0000000
--- a/libs/rs/rsProgramBase.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef ANDROID_RS_PROGRAM_BASE_H
-#define ANDROID_RS_PROGRAM_BASE_H
-
-#include "rsObjectBase.h"
-#include "rsElement.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-class ProgramBase : public ObjectBase {
-public:
- ProgramBase(Context *rsc) : ObjectBase(rsc) {
- mDirty = true;
- }
-
- void forceDirty() const {mDirty = true;}
-
-protected:
- mutable bool mDirty;
-};
-
-}
-}
-#endif // ANDROID_RS_PROGRAM_BASE_H
-
-
-
diff --git a/libs/rs/rsProgramFragment.cpp b/libs/rs/rsProgramFragment.cpp
deleted file mode 100644
index bebde1e..0000000
--- a/libs/rs/rsProgramFragment.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#include "rsContext.h"
-#include "rsProgramFragment.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-ProgramFragment::ProgramFragment(Context *rsc, const char * shaderText, size_t shaderLength,
- const char** textureNames, size_t textureNamesCount, const size_t *textureNamesLength,
-
- const uint32_t * params, size_t paramLength)
- : Program(rsc, shaderText, shaderLength, params, paramLength) {
- mConstantColor[0] = 1.f;
- mConstantColor[1] = 1.f;
- mConstantColor[2] = 1.f;
- mConstantColor[3] = 1.f;
-
- mRSC->mHal.funcs.fragment.init(mRSC, this, mUserShader.string(), mUserShader.length(),
- textureNames, textureNamesCount, textureNamesLength);
-}
-
-ProgramFragment::~ProgramFragment() {
- mRSC->mHal.funcs.fragment.destroy(mRSC, this);
-}
-
-void ProgramFragment::setConstantColor(Context *rsc, float r, float g, float b, float a) {
- if (isUserProgram()) {
- ALOGE("Attempting to set fixed function emulation color on user program");
- rsc->setError(RS_ERROR_BAD_SHADER, "Cannot set fixed function emulation color on user program");
- return;
- }
- if (mHal.state.constants[0] == NULL) {
- ALOGE("Unable to set fixed function emulation color because allocation is missing");
- rsc->setError(RS_ERROR_BAD_SHADER, "Unable to set fixed function emulation color because allocation is missing");
- return;
- }
- mConstantColor[0] = r;
- mConstantColor[1] = g;
- mConstantColor[2] = b;
- mConstantColor[3] = a;
- memcpy(mHal.state.constants[0]->getPtr(), mConstantColor, 4*sizeof(float));
- mDirty = true;
-}
-
-void ProgramFragment::setup(Context *rsc, ProgramFragmentState *state) {
- if ((state->mLast.get() == this) && !mDirty) {
- return;
- }
- state->mLast.set(this);
-
- for (uint32_t ct=0; ct < mHal.state.texturesCount; ct++) {
- if (!mHal.state.textures[ct]) {
- ALOGE("No texture bound for shader id %u, texture unit %u", (uint)this, ct);
- rsc->setError(RS_ERROR_BAD_SHADER, "No texture bound");
- continue;
- }
- }
-
- rsc->mHal.funcs.fragment.setActive(rsc, this);
-}
-
-void ProgramFragment::serialize(OStream *stream) const {
-}
-
-ProgramFragment *ProgramFragment::createFromStream(Context *rsc, IStream *stream) {
- return NULL;
-}
-
-ProgramFragmentState::ProgramFragmentState() {
- mPF = NULL;
-}
-
-ProgramFragmentState::~ProgramFragmentState() {
- ObjectBase::checkDelete(mPF);
- mPF = NULL;
-}
-
-void ProgramFragmentState::init(Context *rsc) {
- String8 shaderString(RS_SHADER_INTERNAL);
- shaderString.append("varying lowp vec4 varColor;\n");
- shaderString.append("varying vec2 varTex0;\n");
- shaderString.append("void main() {\n");
- shaderString.append(" lowp vec4 col = UNI_Color;\n");
- shaderString.append(" gl_FragColor = col;\n");
- shaderString.append("}\n");
-
- ObjectBaseRef<const Element> colorElem = Element::createRef(rsc, RS_TYPE_FLOAT_32, RS_KIND_USER, false, 4);
- Element::Builder builder;
- builder.add(colorElem.get(), "Color", 1);
- ObjectBaseRef<const Element> constInput = builder.create(rsc);
-
- ObjectBaseRef<Type> inputType = Type::getTypeRef(rsc, constInput.get(), 1, 0, 0, false, false);
-
- uint32_t tmp[2];
- tmp[0] = RS_PROGRAM_PARAM_CONSTANT;
- tmp[1] = (uint32_t)inputType.get();
-
- Allocation *constAlloc = Allocation::createAllocation(rsc, inputType.get(),
- RS_ALLOCATION_USAGE_SCRIPT | RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS);
- ProgramFragment *pf = new ProgramFragment(rsc, shaderString.string(), shaderString.length(),
- NULL, 0, NULL, tmp, 2);
- pf->bindAllocation(rsc, constAlloc, 0);
- pf->setConstantColor(rsc, 1.0f, 1.0f, 1.0f, 1.0f);
-
- mDefault.set(pf);
-}
-
-void ProgramFragmentState::deinit(Context *rsc) {
- mDefault.clear();
- mLast.clear();
-}
-
-namespace android {
-namespace renderscript {
-
-RsProgramFragment rsi_ProgramFragmentCreate(Context *rsc, const char * shaderText,
- size_t shaderLength,
- const char** textureNames,
- size_t textureNamesCount,
- const size_t *textureNamesLength,
- const uint32_t * params, size_t paramLength) {
- ProgramFragment *pf = new ProgramFragment(rsc, shaderText, shaderLength,
- textureNames, textureNamesCount, textureNamesLength,
- params, paramLength);
- pf->incUserRef();
- //ALOGE("rsi_ProgramFragmentCreate %p", pf);
- return pf;
-}
-
-}
-}
-
diff --git a/libs/rs/rsProgramFragment.h b/libs/rs/rsProgramFragment.h
deleted file mode 100644
index 4eb28e7..0000000
--- a/libs/rs/rsProgramFragment.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#ifndef ANDROID_RS_PROGRAM_FRAGMENT_H
-#define ANDROID_RS_PROGRAM_FRAGMENT_H
-
-#include "rsProgram.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-class ProgramFragmentState;
-
-class ProgramFragment : public Program {
-public:
- ProgramFragment(Context *rsc, const char * shaderText, size_t shaderLength,
- const char** textureNames, size_t textureNamesCount, const size_t *textureNamesLength,
- const uint32_t * params, size_t paramLength);
- virtual ~ProgramFragment();
-
- virtual void setup(Context *, ProgramFragmentState *);
-
- virtual void serialize(OStream *stream) const;
- virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_FRAGMENT; }
- static ProgramFragment *createFromStream(Context *rsc, IStream *stream);
-
- void setConstantColor(Context *, float, float, float, float);
-
-protected:
- float mConstantColor[4];
- int32_t mTextureUniformIndexStart;
-};
-
-class ProgramFragmentState {
-public:
- ProgramFragmentState();
- ~ProgramFragmentState();
-
- ProgramFragment *mPF;
- void init(Context *rsc);
- void deinit(Context *rsc);
-
- ObjectBaseRef<ProgramFragment> mDefault;
- Vector<ProgramFragment *> mPrograms;
-
- ObjectBaseRef<ProgramFragment> mLast;
-};
-
-}
-}
-#endif
-
-
-
-
diff --git a/libs/rs/rsProgramRaster.cpp b/libs/rs/rsProgramRaster.cpp
deleted file mode 100644
index 94bfe42..0000000
--- a/libs/rs/rsProgramRaster.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#include "rsContext.h"
-#include "rsProgramRaster.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-
-ProgramRaster::ProgramRaster(Context *rsc, bool pointSprite, RsCullMode cull)
- : ProgramBase(rsc) {
-
- memset(&mHal, 0, sizeof(mHal));
- mHal.state.pointSprite = pointSprite;
- mHal.state.cull = cull;
- rsc->mHal.funcs.raster.init(rsc, this);
-}
-
-void ProgramRaster::preDestroy() const {
- for (uint32_t ct = 0; ct < mRSC->mStateRaster.mRasterPrograms.size(); ct++) {
- if (mRSC->mStateRaster.mRasterPrograms[ct] == this) {
- mRSC->mStateRaster.mRasterPrograms.removeAt(ct);
- break;
- }
- }
-}
-
-ProgramRaster::~ProgramRaster() {
- mRSC->mHal.funcs.raster.destroy(mRSC, this);
-}
-
-void ProgramRaster::setup(const Context *rsc, ProgramRasterState *state) {
- if (state->mLast.get() == this && !mDirty) {
- return;
- }
- state->mLast.set(this);
- mDirty = false;
-
- rsc->mHal.funcs.raster.setActive(rsc, this);
-}
-
-void ProgramRaster::serialize(OStream *stream) const {
-}
-
-ProgramRaster *ProgramRaster::createFromStream(Context *rsc, IStream *stream) {
- return NULL;
-}
-
-ProgramRasterState::ProgramRasterState() {
-}
-
-ProgramRasterState::~ProgramRasterState() {
-}
-
-void ProgramRasterState::init(Context *rsc) {
- mDefault.set(ProgramRaster::getProgramRaster(rsc, false, RS_CULL_BACK).get());
-}
-
-void ProgramRasterState::deinit(Context *rsc) {
- mDefault.clear();
- mLast.clear();
-}
-
-ObjectBaseRef<ProgramRaster> ProgramRaster::getProgramRaster(Context *rsc,
- bool pointSprite,
- RsCullMode cull) {
- ObjectBaseRef<ProgramRaster> returnRef;
- ObjectBase::asyncLock();
- for (uint32_t ct = 0; ct < rsc->mStateRaster.mRasterPrograms.size(); ct++) {
- ProgramRaster *existing = rsc->mStateRaster.mRasterPrograms[ct];
- if (existing->mHal.state.pointSprite != pointSprite) continue;
- if (existing->mHal.state.cull != cull) continue;
- returnRef.set(existing);
- ObjectBase::asyncUnlock();
- return returnRef;
- }
- ObjectBase::asyncUnlock();
-
- ProgramRaster *pr = new ProgramRaster(rsc, pointSprite, cull);
- returnRef.set(pr);
-
- ObjectBase::asyncLock();
- rsc->mStateRaster.mRasterPrograms.push(pr);
- ObjectBase::asyncUnlock();
-
- return returnRef;
-}
-
-namespace android {
-namespace renderscript {
-
-RsProgramRaster rsi_ProgramRasterCreate(Context * rsc, bool pointSprite, RsCullMode cull) {
- ObjectBaseRef<ProgramRaster> pr = ProgramRaster::getProgramRaster(rsc, pointSprite, cull);
- pr->incUserRef();
- return pr.get();
-}
-
-}
-}
-
diff --git a/libs/rs/rsProgramRaster.h b/libs/rs/rsProgramRaster.h
deleted file mode 100644
index c552ea3..0000000
--- a/libs/rs/rsProgramRaster.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2009-2011 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.
- */
-
-#ifndef ANDROID_RS_PROGRAM_RASTER_H
-#define ANDROID_RS_PROGRAM_RASTER_H
-
-#include "rsProgramBase.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-class ProgramRasterState;
-/*****************************************************************************
- * CAUTION
- *
- * Any layout changes for this class may require a corresponding change to be
- * made to frameworks/compile/libbcc/lib/ScriptCRT/rs_core.c, which contains
- * a partial copy of the information below.
- *
- *****************************************************************************/
-class ProgramRaster : public ProgramBase {
-public:
- struct Hal {
- mutable void *drv;
-
- struct State {
- bool pointSprite;
- RsCullMode cull;
- };
- State state;
- };
- Hal mHal;
-
- virtual void setup(const Context *, ProgramRasterState *);
- virtual void serialize(OStream *stream) const;
- virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_RASTER; }
- static ProgramRaster *createFromStream(Context *rsc, IStream *stream);
-
- static ObjectBaseRef<ProgramRaster> getProgramRaster(Context *rsc,
- bool pointSprite,
- RsCullMode cull);
-protected:
- virtual void preDestroy() const;
- virtual ~ProgramRaster();
-
-private:
- ProgramRaster(Context *rsc,
- bool pointSprite,
- RsCullMode cull);
-
-};
-
-class ProgramRasterState {
-public:
- ProgramRasterState();
- ~ProgramRasterState();
- void init(Context *rsc);
- void deinit(Context *rsc);
-
- ObjectBaseRef<ProgramRaster> mDefault;
- ObjectBaseRef<ProgramRaster> mLast;
-
- // Cache of all existing raster programs.
- Vector<ProgramRaster *> mRasterPrograms;
-};
-
-
-}
-}
-#endif
-
-
-
-
diff --git a/libs/rs/rsProgramStore.cpp b/libs/rs/rsProgramStore.cpp
deleted file mode 100644
index 7e25a22..0000000
--- a/libs/rs/rsProgramStore.cpp
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#include "rsContext.h"
-#include "rsProgramStore.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-
-ProgramStore::ProgramStore(Context *rsc,
- bool colorMaskR, bool colorMaskG, bool colorMaskB, bool colorMaskA,
- bool depthMask, bool ditherEnable,
- RsBlendSrcFunc srcFunc, RsBlendDstFunc destFunc,
- RsDepthFunc depthFunc) : ProgramBase(rsc) {
- memset(&mHal, 0, sizeof(mHal));
-
- mHal.state.ditherEnable = ditherEnable;
-
- mHal.state.colorRWriteEnable = colorMaskR;
- mHal.state.colorGWriteEnable = colorMaskG;
- mHal.state.colorBWriteEnable = colorMaskB;
- mHal.state.colorAWriteEnable = colorMaskA;
- mHal.state.blendSrc = srcFunc;
- mHal.state.blendDst = destFunc;
-
- mHal.state.depthWriteEnable = depthMask;
- mHal.state.depthFunc = depthFunc;
-}
-
-void ProgramStore::preDestroy() const {
- for (uint32_t ct = 0; ct < mRSC->mStateFragmentStore.mStorePrograms.size(); ct++) {
- if (mRSC->mStateFragmentStore.mStorePrograms[ct] == this) {
- mRSC->mStateFragmentStore.mStorePrograms.removeAt(ct);
- break;
- }
- }
-}
-
-ProgramStore::~ProgramStore() {
- mRSC->mHal.funcs.store.destroy(mRSC, this);
-}
-
-void ProgramStore::setup(const Context *rsc, ProgramStoreState *state) {
- if (state->mLast.get() == this) {
- return;
- }
- state->mLast.set(this);
-
- rsc->mHal.funcs.store.setActive(rsc, this);
-}
-
-void ProgramStore::serialize(OStream *stream) const {
-}
-
-ProgramStore *ProgramStore::createFromStream(Context *rsc, IStream *stream) {
- return NULL;
-}
-
-void ProgramStore::init() {
- mRSC->mHal.funcs.store.init(mRSC, this);
-}
-
-ProgramStoreState::ProgramStoreState() {
-}
-
-ProgramStoreState::~ProgramStoreState() {
-}
-
-ObjectBaseRef<ProgramStore> ProgramStore::getProgramStore(Context *rsc,
- bool colorMaskR,
- bool colorMaskG,
- bool colorMaskB,
- bool colorMaskA,
- bool depthMask, bool ditherEnable,
- RsBlendSrcFunc srcFunc,
- RsBlendDstFunc destFunc,
- RsDepthFunc depthFunc) {
- ObjectBaseRef<ProgramStore> returnRef;
- ObjectBase::asyncLock();
- for (uint32_t ct = 0; ct < rsc->mStateFragmentStore.mStorePrograms.size(); ct++) {
- ProgramStore *existing = rsc->mStateFragmentStore.mStorePrograms[ct];
- if (existing->mHal.state.ditherEnable != ditherEnable) continue;
- if (existing->mHal.state.colorRWriteEnable != colorMaskR) continue;
- if (existing->mHal.state.colorGWriteEnable != colorMaskG) continue;
- if (existing->mHal.state.colorBWriteEnable != colorMaskB) continue;
- if (existing->mHal.state.colorAWriteEnable != colorMaskA) continue;
- if (existing->mHal.state.blendSrc != srcFunc) continue;
- if (existing->mHal.state.blendDst != destFunc) continue;
- if (existing->mHal.state.depthWriteEnable != depthMask) continue;
- if (existing->mHal.state.depthFunc != depthFunc) continue;
-
- returnRef.set(existing);
- ObjectBase::asyncUnlock();
- return returnRef;
- }
- ObjectBase::asyncUnlock();
-
- ProgramStore *pfs = new ProgramStore(rsc,
- colorMaskR, colorMaskG, colorMaskB, colorMaskA,
- depthMask, ditherEnable,
- srcFunc, destFunc, depthFunc);
- returnRef.set(pfs);
-
- pfs->init();
-
- ObjectBase::asyncLock();
- rsc->mStateFragmentStore.mStorePrograms.push(pfs);
- ObjectBase::asyncUnlock();
-
- return returnRef;
-}
-
-
-
-void ProgramStoreState::init(Context *rsc) {
- mDefault.set(ProgramStore::getProgramStore(rsc,
- true, true, true, true,
- true, true,
- RS_BLEND_SRC_ONE, RS_BLEND_DST_ZERO,
- RS_DEPTH_FUNC_LESS).get());
-}
-
-void ProgramStoreState::deinit(Context *rsc) {
- mDefault.clear();
- mLast.clear();
-}
-
-
-namespace android {
-namespace renderscript {
-
-RsProgramStore rsi_ProgramStoreCreate(Context *rsc,
- bool colorMaskR, bool colorMaskG, bool colorMaskB, bool colorMaskA,
- bool depthMask, bool ditherEnable,
- RsBlendSrcFunc srcFunc, RsBlendDstFunc destFunc,
- RsDepthFunc depthFunc) {
-
-
- ObjectBaseRef<ProgramStore> ps = ProgramStore::getProgramStore(rsc,
- colorMaskR, colorMaskG,
- colorMaskB, colorMaskA,
- depthMask, ditherEnable,
- srcFunc, destFunc, depthFunc);
- ps->incUserRef();
- return ps.get();
-}
-
-}
-}
diff --git a/libs/rs/rsProgramStore.h b/libs/rs/rsProgramStore.h
deleted file mode 100644
index 9bb2795..0000000
--- a/libs/rs/rsProgramStore.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef ANDROID_RS_PROGRAM_FRAGMENT_STORE_H
-#define ANDROID_RS_PROGRAM_FRAGMENT_STORE_H
-
-#include "rsProgramBase.h"
-#include "rsStream.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-class ProgramStoreState;
-/*****************************************************************************
- * CAUTION
- *
- * Any layout changes for this class may require a corresponding change to be
- * made to frameworks/compile/libbcc/lib/ScriptCRT/rs_core.c, which contains
- * a partial copy of the information below.
- *
- *****************************************************************************/
-class ProgramStore : public ProgramBase {
-public:
- struct Hal {
- mutable void *drv;
-
- struct State {
- bool ditherEnable;
-
- //bool blendEnable;
- bool colorRWriteEnable;
- bool colorGWriteEnable;
- bool colorBWriteEnable;
- bool colorAWriteEnable;
- RsBlendSrcFunc blendSrc;
- RsBlendDstFunc blendDst;
-
- //bool depthTestEnable;
- bool depthWriteEnable;
- RsDepthFunc depthFunc;
- };
- State state;
- };
- Hal mHal;
-
- virtual void setup(const Context *, ProgramStoreState *);
-
- virtual void serialize(OStream *stream) const;
- virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_STORE; }
- static ProgramStore *createFromStream(Context *rsc, IStream *stream);
- static ObjectBaseRef<ProgramStore> getProgramStore(Context *,
- bool colorMaskR, bool colorMaskG,
- bool colorMaskB, bool colorMaskA,
- bool depthMask, bool ditherEnable,
- RsBlendSrcFunc srcFunc, RsBlendDstFunc destFunc,
- RsDepthFunc depthFunc);
- void init();
-protected:
- virtual void preDestroy() const;
- virtual ~ProgramStore();
-
-private:
- ProgramStore(Context *,
- bool colorMaskR, bool colorMaskG, bool colorMaskB, bool colorMaskA,
- bool depthMask, bool ditherEnable,
- RsBlendSrcFunc srcFunc, RsBlendDstFunc destFunc,
- RsDepthFunc depthFunc);
-};
-
-class ProgramStoreState {
-public:
- ProgramStoreState();
- ~ProgramStoreState();
- void init(Context *rsc);
- void deinit(Context *rsc);
-
- ObjectBaseRef<ProgramStore> mDefault;
- ObjectBaseRef<ProgramStore> mLast;
-
- // Cache of all existing store programs.
- Vector<ProgramStore *> mStorePrograms;
-};
-
-}
-}
-#endif
-
-
-
diff --git a/libs/rs/rsProgramVertex.cpp b/libs/rs/rsProgramVertex.cpp
deleted file mode 100644
index 23fcbe7..0000000
--- a/libs/rs/rsProgramVertex.cpp
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#include "rsContext.h"
-#include "rsProgramVertex.h"
-#include "rsMatrix4x4.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-
-ProgramVertex::ProgramVertex(Context *rsc, const char * shaderText, size_t shaderLength,
- const char** textureNames, size_t textureNamesCount, const size_t *textureNamesLength,
-
- const uint32_t * params, size_t paramLength)
- : Program(rsc, shaderText, shaderLength, params, paramLength) {
- mRSC->mHal.funcs.vertex.init(mRSC, this, mUserShader.string(), mUserShader.length(),
- textureNames, textureNamesCount, textureNamesLength);
-}
-
-ProgramVertex::~ProgramVertex() {
- mRSC->mHal.funcs.vertex.destroy(mRSC, this);
-}
-
-void ProgramVertex::setup(Context *rsc, ProgramVertexState *state) {
- if ((state->mLast.get() == this) && !mDirty) {
- return;
- }
-
- if (!isUserProgram()) {
- if (mHal.state.constants[0] == NULL) {
- rsc->setError(RS_ERROR_FATAL_UNKNOWN,
- "Unable to set fixed function emulation matrices because allocation is missing");
- return;
- }
- float *f = static_cast<float *>(mHal.state.constants[0]->getPtr());
- Matrix4x4 mvp;
- mvp.load(&f[RS_PROGRAM_VERTEX_PROJECTION_OFFSET]);
- Matrix4x4 t;
- t.load(&f[RS_PROGRAM_VERTEX_MODELVIEW_OFFSET]);
- mvp.multiply(&t);
- for (uint32_t i = 0; i < 16; i ++) {
- f[RS_PROGRAM_VERTEX_MVP_OFFSET + i] = mvp.m[i];
- }
- }
-
- state->mLast.set(this);
-
- rsc->mHal.funcs.vertex.setActive(rsc, this);
-}
-
-void ProgramVertex::setProjectionMatrix(Context *rsc, const rsc_Matrix *m) const {
- if (isUserProgram()) {
- rsc->setError(RS_ERROR_FATAL_UNKNOWN,
- "Attempting to set fixed function emulation matrix projection on user program");
- return;
- }
- if (mHal.state.constants[0] == NULL) {
- rsc->setError(RS_ERROR_FATAL_UNKNOWN,
- "Unable to set fixed function emulation matrix projection because allocation is missing");
- return;
- }
- float *f = static_cast<float *>(mHal.state.constants[0]->getPtr());
- memcpy(&f[RS_PROGRAM_VERTEX_PROJECTION_OFFSET], m, sizeof(rsc_Matrix));
- mDirty = true;
-}
-
-void ProgramVertex::setModelviewMatrix(Context *rsc, const rsc_Matrix *m) const {
- if (isUserProgram()) {
- rsc->setError(RS_ERROR_FATAL_UNKNOWN,
- "Attempting to set fixed function emulation matrix modelview on user program");
- return;
- }
- if (mHal.state.constants[0] == NULL) {
- rsc->setError(RS_ERROR_FATAL_UNKNOWN,
- "Unable to set fixed function emulation matrix modelview because allocation is missing");
- return;
- }
- float *f = static_cast<float *>(mHal.state.constants[0]->getPtr());
- memcpy(&f[RS_PROGRAM_VERTEX_MODELVIEW_OFFSET], m, sizeof(rsc_Matrix));
- mDirty = true;
-}
-
-void ProgramVertex::setTextureMatrix(Context *rsc, const rsc_Matrix *m) const {
- if (isUserProgram()) {
- rsc->setError(RS_ERROR_FATAL_UNKNOWN,
- "Attempting to set fixed function emulation matrix texture on user program");
- return;
- }
- if (mHal.state.constants[0] == NULL) {
- rsc->setError(RS_ERROR_FATAL_UNKNOWN,
- "Unable to set fixed function emulation matrix texture because allocation is missing");
- return;
- }
- float *f = static_cast<float *>(mHal.state.constants[0]->getPtr());
- memcpy(&f[RS_PROGRAM_VERTEX_TEXTURE_OFFSET], m, sizeof(rsc_Matrix));
- mDirty = true;
-}
-
-void ProgramVertex::getProjectionMatrix(Context *rsc, rsc_Matrix *m) const {
- if (isUserProgram()) {
- rsc->setError(RS_ERROR_FATAL_UNKNOWN,
- "Attempting to get fixed function emulation matrix projection on user program");
- return;
- }
- if (mHal.state.constants[0] == NULL) {
- rsc->setError(RS_ERROR_FATAL_UNKNOWN,
- "Unable to get fixed function emulation matrix projection because allocation is missing");
- return;
- }
- float *f = static_cast<float *>(mHal.state.constants[0]->getPtr());
- memcpy(m, &f[RS_PROGRAM_VERTEX_PROJECTION_OFFSET], sizeof(rsc_Matrix));
-}
-
-void ProgramVertex::transformToScreen(Context *rsc, float *v4out, const float *v3in) const {
- if (isUserProgram()) {
- return;
- }
- float *f = static_cast<float *>(mHal.state.constants[0]->getPtr());
- Matrix4x4 mvp;
- mvp.loadMultiply((Matrix4x4 *)&f[RS_PROGRAM_VERTEX_MODELVIEW_OFFSET],
- (Matrix4x4 *)&f[RS_PROGRAM_VERTEX_PROJECTION_OFFSET]);
- mvp.vectorMultiply(v4out, v3in);
-}
-
-void ProgramVertex::serialize(OStream *stream) const {
-}
-
-ProgramVertex *ProgramVertex::createFromStream(Context *rsc, IStream *stream) {
- return NULL;
-}
-
-
-///////////////////////////////////////////////////////////////////////
-
-ProgramVertexState::ProgramVertexState() {
-}
-
-ProgramVertexState::~ProgramVertexState() {
-}
-
-void ProgramVertexState::init(Context *rsc) {
- ObjectBaseRef<const Element> matrixElem = Element::createRef(rsc, RS_TYPE_MATRIX_4X4,
- RS_KIND_USER, false, 1);
- ObjectBaseRef<const Element> f2Elem = Element::createRef(rsc, RS_TYPE_FLOAT_32,
- RS_KIND_USER, false, 2);
- ObjectBaseRef<const Element> f3Elem = Element::createRef(rsc, RS_TYPE_FLOAT_32,
- RS_KIND_USER, false, 3);
- ObjectBaseRef<const Element> f4Elem = Element::createRef(rsc, RS_TYPE_FLOAT_32,
- RS_KIND_USER, false, 4);
-
- Element::Builder constBuilder;
- constBuilder.add(matrixElem.get(), "MV", 1);
- constBuilder.add(matrixElem.get(), "P", 1);
- constBuilder.add(matrixElem.get(), "TexMatrix", 1);
- constBuilder.add(matrixElem.get(), "MVP", 1);
- ObjectBaseRef<const Element> constInput = constBuilder.create(rsc);
-
- Element::Builder inputBuilder;
- inputBuilder.add(f4Elem.get(), "position", 1);
- inputBuilder.add(f4Elem.get(), "color", 1);
- inputBuilder.add(f3Elem.get(), "normal", 1);
- inputBuilder.add(f2Elem.get(), "texture0", 1);
- ObjectBaseRef<const Element> attrElem = inputBuilder.create(rsc);
-
- ObjectBaseRef<Type> inputType = Type::getTypeRef(rsc, constInput.get(), 1, 0, 0, false, false);
-
- String8 shaderString(RS_SHADER_INTERNAL);
- shaderString.append("varying vec4 varColor;\n");
- shaderString.append("varying vec2 varTex0;\n");
- shaderString.append("void main() {\n");
- shaderString.append(" gl_Position = UNI_MVP * ATTRIB_position;\n");
- shaderString.append(" gl_PointSize = 1.0;\n");
- shaderString.append(" varColor = ATTRIB_color;\n");
- shaderString.append(" varTex0 = ATTRIB_texture0;\n");
- shaderString.append("}\n");
-
- uint32_t tmp[4];
- tmp[0] = RS_PROGRAM_PARAM_CONSTANT;
- tmp[1] = (uint32_t)inputType.get();
- tmp[2] = RS_PROGRAM_PARAM_INPUT;
- tmp[3] = (uint32_t)attrElem.get();
-
- ProgramVertex *pv = new ProgramVertex(rsc, shaderString.string(), shaderString.length(),
- NULL, 0, NULL, tmp, 4);
- Allocation *alloc = Allocation::createAllocation(rsc, inputType.get(),
- RS_ALLOCATION_USAGE_SCRIPT | RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS);
- pv->bindAllocation(rsc, alloc, 0);
-
- mDefaultAlloc.set(alloc);
- mDefault.set(pv);
-
- updateSize(rsc);
-}
-
-void ProgramVertexState::updateSize(Context *rsc) {
- float *f = static_cast<float *>(mDefaultAlloc->getPtr());
-
- float surfaceWidth = (float)rsc->getCurrentSurfaceWidth();
- float surfaceHeight = (float)rsc->getCurrentSurfaceHeight();
-
- Matrix4x4 m;
- m.loadOrtho(0, surfaceWidth, surfaceHeight, 0, -1, 1);
- memcpy(&f[RS_PROGRAM_VERTEX_PROJECTION_OFFSET], m.m, sizeof(m));
- memcpy(&f[RS_PROGRAM_VERTEX_MVP_OFFSET], m.m, sizeof(m));
-
- m.loadIdentity();
- memcpy(&f[RS_PROGRAM_VERTEX_MODELVIEW_OFFSET], m.m, sizeof(m));
- memcpy(&f[RS_PROGRAM_VERTEX_TEXTURE_OFFSET], m.m, sizeof(m));
-}
-
-void ProgramVertexState::deinit(Context *rsc) {
- mDefaultAlloc.clear();
- mDefault.clear();
- mLast.clear();
-}
-
-
-namespace android {
-namespace renderscript {
-
-RsProgramVertex rsi_ProgramVertexCreate(Context *rsc, const char * shaderText, size_t shaderLength,
- const char** textureNames, size_t textureNamesCount,
- const size_t *textureNamesLength,
- const uint32_t * params, size_t paramLength) {
- ProgramVertex *pv = new ProgramVertex(rsc, shaderText, shaderLength,
- textureNames, textureNamesCount, textureNamesLength,
- params, paramLength);
- pv->incUserRef();
- return pv;
-}
-
-}
-}
diff --git a/libs/rs/rsProgramVertex.h b/libs/rs/rsProgramVertex.h
deleted file mode 100644
index 67c2a88..0000000
--- a/libs/rs/rsProgramVertex.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#ifndef ANDROID_RS_PROGRAM_VERTEX_H
-#define ANDROID_RS_PROGRAM_VERTEX_H
-
-#include "rsProgram.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-class ProgramVertexState;
-
-class ProgramVertex : public Program {
-public:
- ProgramVertex(Context *,const char * shaderText, size_t shaderLength,
- const char** textureNames, size_t textureNamesCount, const size_t *textureNamesLength,
- const uint32_t * params, size_t paramLength);
- virtual ~ProgramVertex();
-
- virtual void setup(Context *rsc, ProgramVertexState *state);
-
- void setProjectionMatrix(Context *, const rsc_Matrix *) const;
- void getProjectionMatrix(Context *, rsc_Matrix *) const;
- void setModelviewMatrix(Context *, const rsc_Matrix *) const;
- void setTextureMatrix(Context *, const rsc_Matrix *) const;
-
- void transformToScreen(Context *, float *v4out, const float *v3in) const;
-
- virtual void serialize(OStream *stream) const;
- virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_VERTEX; }
- static ProgramVertex *createFromStream(Context *rsc, IStream *stream);
-};
-
-class ProgramVertexState {
-public:
- ProgramVertexState();
- ~ProgramVertexState();
-
- void init(Context *rsc);
- void deinit(Context *rsc);
- void updateSize(Context *rsc);
-
- ObjectBaseRef<ProgramVertex> mDefault;
- ObjectBaseRef<ProgramVertex> mLast;
- ObjectBaseRef<Allocation> mDefaultAlloc;
-};
-
-}
-}
-#endif
-
-
diff --git a/libs/rs/rsRuntime.h b/libs/rs/rsRuntime.h
deleted file mode 100644
index 64f2de8..0000000
--- a/libs/rs/rsRuntime.h
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#include "rsContext.h"
-#include "rsScriptC.h"
-
-#include "utils/Timers.h"
-
-#include <time.h>
-
-namespace android {
-namespace renderscript {
-
-
-//////////////////////////////////////////////////////////////////////////////
-// Context
-//////////////////////////////////////////////////////////////////////////////
-
-void rsrBindTexture(Context *, Script *, ProgramFragment *, uint32_t slot, Allocation *);
-void rsrBindConstant(Context *, Script *, ProgramFragment *, uint32_t slot, Allocation *);
-void rsrBindConstant(Context *, Script *, ProgramVertex*, uint32_t slot, Allocation *);
-void rsrBindSampler(Context *, Script *, ProgramFragment *, uint32_t slot, Sampler *);
-void rsrBindProgramStore(Context *, Script *, ProgramStore *);
-void rsrBindProgramFragment(Context *, Script *, ProgramFragment *);
-void rsrBindProgramVertex(Context *, Script *, ProgramVertex *);
-void rsrBindProgramRaster(Context *, Script *, ProgramRaster *);
-void rsrBindFrameBufferObjectColorTarget(Context *, Script *, Allocation *, uint32_t slot);
-void rsrBindFrameBufferObjectDepthTarget(Context *, Script *, Allocation *);
-void rsrClearFrameBufferObjectColorTarget(Context *, Script *, uint32_t slot);
-void rsrClearFrameBufferObjectDepthTarget(Context *, Script *);
-void rsrClearFrameBufferObjectTargets(Context *, Script *);
-
-//////////////////////////////////////////////////////////////////////////////
-// VP
-//////////////////////////////////////////////////////////////////////////////
-
-void rsrVpLoadProjectionMatrix(Context *, Script *, const rsc_Matrix *m);
-void rsrVpLoadModelMatrix(Context *, Script *, const rsc_Matrix *m);
-void rsrVpLoadTextureMatrix(Context *, Script *, const rsc_Matrix *m);
-void rsrPfConstantColor(Context *, Script *, ProgramFragment *, float r, float g, float b, float a);
-void rsrVpGetProjectionMatrix(Context *, Script *, rsc_Matrix *m);
-
-//////////////////////////////////////////////////////////////////////////////
-// Drawing
-//////////////////////////////////////////////////////////////////////////////
-
-void rsrDrawQuadTexCoords(Context *, Script *,
- float x1, float y1, float z1, float u1, float v1,
- float x2, float y2, float z2, float u2, float v2,
- float x3, float y3, float z3, float u3, float v3,
- float x4, float y4, float z4, float u4, float v4);
-void rsrDrawQuad(Context *, Script *,
- float x1, float y1, float z1,
- float x2, float y2, float z2,
- float x3, float y3, float z3,
- float x4, float y4, float z4);
-void rsrDrawSpriteScreenspace(Context *, Script *,
- float x, float y, float z, float w, float h);
-void rsrDrawRect(Context *, Script *, float x1, float y1, float x2, float y2, float z);
-void rsrDrawPath(Context *, Script *, Path *);
-void rsrDrawMesh(Context *, Script *, Mesh *);
-void rsrDrawMeshPrimitive(Context *, Script *, Mesh *, uint32_t primIndex);
-void rsrDrawMeshPrimitiveRange(Context *, Script *, Mesh *,
- uint32_t primIndex, uint32_t start, uint32_t len);
-void rsrMeshComputeBoundingBox(Context *, Script *, Mesh *,
- float *minX, float *minY, float *minZ,
- float *maxX, float *maxY, float *maxZ);
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-
-
-void rsrColor(Context *, Script *, float r, float g, float b, float a);
-void rsrAllocationSyncAll(Context *, Script *, Allocation *);
-
-void rsrAllocationCopy1DRange(Context *, Allocation *dstAlloc,
- uint32_t dstOff,
- uint32_t dstMip,
- uint32_t count,
- Allocation *srcAlloc,
- uint32_t srcOff, uint32_t srcMip);
-void rsrAllocationCopy2DRange(Context *, Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstYoff,
- uint32_t dstMip, uint32_t dstFace,
- uint32_t width, uint32_t height,
- Allocation *srcAlloc,
- uint32_t srcXoff, uint32_t srcYoff,
- uint32_t srcMip, uint32_t srcFace);
-
-void rsrPrepareClear(Context *, Script *);
-uint32_t rsrGetWidth(Context *, Script *);
-uint32_t rsrGetHeight(Context *, Script *);
-void rsrDrawTextAlloc(Context *, Script *, Allocation *, int x, int y);
-void rsrDrawText(Context *, Script *, const char *text, int x, int y);
-void rsrSetMetrics(Context *, Script *, Font::Rect *metrics,
- int32_t *left, int32_t *right, int32_t *top, int32_t *bottom);
-void rsrMeasureTextAlloc(Context *, Script *, Allocation *,
- int32_t *left, int32_t *right, int32_t *top, int32_t *bottom);
-void rsrMeasureText(Context *, Script *, const char *text,
- int32_t *left, int32_t *right, int32_t *top, int32_t *bottom);
-void rsrBindFont(Context *, Script *, Font *);
-void rsrFontColor(Context *, Script *, float r, float g, float b, float a);
-
-//////////////////////////////////////////////////////////////////////////////
-// Time routines
-//////////////////////////////////////////////////////////////////////////////
-
-float rsrGetDt(Context *, Script *);
-time_t rsrTime(Context *, Script *, time_t *timer);
-tm* rsrLocalTime(Context *, Script *, tm *local, time_t *timer);
-int64_t rsrUptimeMillis(Context *, Script *);
-int64_t rsrUptimeNanos(Context *, Script *);
-
-//////////////////////////////////////////////////////////////////////////////
-// Message routines
-//////////////////////////////////////////////////////////////////////////////
-
-uint32_t rsrToClient(Context *, Script *, int cmdID, void *data, int len);
-uint32_t rsrToClientBlocking(Context *, Script *, int cmdID, void *data, int len);
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-
-void rsrSetObject(const Context *, const Script *, ObjectBase **dst, ObjectBase * src);
-void rsrClearObject(const Context *, const Script *, ObjectBase **dst);
-bool rsrIsObject(const Context *, const Script *, const ObjectBase *src);
-
-void rsrAllocationIncRefs(const Context *, const Allocation *, void *ptr,
- size_t elementCount, size_t startOffset);
-void rsrAllocationDecRefs(const Context *, const Allocation *, void *ptr,
- size_t elementCount, size_t startOffset);
-
-
-uint32_t rsrToClient(Context *, Script *, int cmdID, void *data, int len);
-uint32_t rsrToClientBlocking(Context *, Script *, int cmdID, void *data, int len);
-const Allocation * rsrGetAllocation(Context *, Script *, const void *ptr);
-
-void rsrAllocationMarkDirty(Context *, Script *, RsAllocation a);
-void rsrAllocationSyncAll(Context *, Script *, Allocation *a, RsAllocationUsageType source);
-
-
-void rsrForEach(Context *, Script *, Script *target,
- Allocation *in,
- Allocation *out,
- const void *usr,
- uint32_t usrBytes,
- const RsScriptCall *call);
-
-
-//////////////////////////////////////////////////////////////////////////////
-// Heavy math functions
-//////////////////////////////////////////////////////////////////////////////
-
-
-void rsrMatrixSet(rs_matrix4x4 *m, uint32_t row, uint32_t col, float v);
-float rsrMatrixGet(const rs_matrix4x4 *m, uint32_t row, uint32_t col);
-void rsrMatrixSet(rs_matrix3x3 *m, uint32_t row, uint32_t col, float v);
-float rsrMatrixGet(const rs_matrix3x3 *m, uint32_t row, uint32_t col);
-void rsrMatrixSet(rs_matrix2x2 *m, uint32_t row, uint32_t col, float v);
-float rsrMatrixGet(const rs_matrix2x2 *m, uint32_t row, uint32_t col);
-void rsrMatrixLoadIdentity_4x4(rs_matrix4x4 *m);
-void rsrMatrixLoadIdentity_3x3(rs_matrix3x3 *m);
-void rsrMatrixLoadIdentity_2x2(rs_matrix2x2 *m);
-void rsrMatrixLoad_4x4_f(rs_matrix4x4 *m, const float *v);
-void rsrMatrixLoad_3x3_f(rs_matrix3x3 *m, const float *v);
-void rsrMatrixLoad_2x2_f(rs_matrix2x2 *m, const float *v);
-void rsrMatrixLoad_4x4_4x4(rs_matrix4x4 *m, const rs_matrix4x4 *v);
-void rsrMatrixLoad_4x4_3x3(rs_matrix4x4 *m, const rs_matrix3x3 *v);
-void rsrMatrixLoad_4x4_2x2(rs_matrix4x4 *m, const rs_matrix2x2 *v);
-void rsrMatrixLoad_3x3_3x3(rs_matrix3x3 *m, const rs_matrix3x3 *v);
-void rsrMatrixLoad_2x2_2x2(rs_matrix2x2 *m, const rs_matrix2x2 *v);
-void rsrMatrixLoadRotate(rs_matrix4x4 *m, float rot, float x, float y, float z);
-void rsrMatrixLoadScale(rs_matrix4x4 *m, float x, float y, float z);
-void rsrMatrixLoadTranslate(rs_matrix4x4 *m, float x, float y, float z);
-void rsrMatrixLoadMultiply_4x4_4x4_4x4(rs_matrix4x4 *m, const rs_matrix4x4 *lhs,
- const rs_matrix4x4 *rhs);
-void rsrMatrixMultiply_4x4_4x4(rs_matrix4x4 *m, const rs_matrix4x4 *rhs);
-void rsrMatrixLoadMultiply_3x3_3x3_3x3(rs_matrix3x3 *m, const rs_matrix3x3 *lhs,
- const rs_matrix3x3 *rhs);
-void rsrMatrixMultiply_3x3_3x3(rs_matrix3x3 *m, const rs_matrix3x3 *rhs);
-void rsrMatrixLoadMultiply_2x2_2x2_2x2(rs_matrix2x2 *m, const rs_matrix2x2 *lhs,
- const rs_matrix2x2 *rhs);
-void rsrMatrixMultiply_2x2_2x2(rs_matrix2x2 *m, const rs_matrix2x2 *rhs);
-void rsrMatrixRotate(rs_matrix4x4 *m, float rot, float x, float y, float z);
-void rsrMatrixScale(rs_matrix4x4 *m, float x, float y, float z);
-void rsrMatrixTranslate(rs_matrix4x4 *m, float x, float y, float z);
-void rsrMatrixLoadOrtho(rs_matrix4x4 *m, float left, float right,
- float bottom, float top, float near, float far);
-void rsrMatrixLoadFrustum(rs_matrix4x4 *m, float left, float right,
- float bottom, float top, float near, float far);
-void rsrMatrixLoadPerspective(rs_matrix4x4* m, float fovy, float aspect, float near, float far);
-
-// Returns true if the matrix was successfully inversed
-bool rsrMatrixInverse_4x4(rs_matrix4x4 *m);
-// Returns true if the matrix was successfully inversed
-bool rsrMatrixInverseTranspose_4x4(rs_matrix4x4 *m);
-
-void rsrMatrixTranspose_4x4(rs_matrix4x4 *m);
-void rsrMatrixTranspose_3x3(rs_matrix3x3 *m);
-void rsrMatrixTranspose_2x2(rs_matrix2x2 *m);
-
-}
-}
diff --git a/libs/rs/rsSampler.cpp b/libs/rs/rsSampler.cpp
deleted file mode 100644
index c7180bd..0000000
--- a/libs/rs/rsSampler.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#include "rsContext.h"
-#include "rsSampler.h"
-#include "rs.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-
-Sampler::Sampler(Context *rsc) : ObjectBase(rsc) {
- // Should not get called.
- rsAssert(0);
-}
-
-Sampler::Sampler(Context *rsc,
- RsSamplerValue magFilter,
- RsSamplerValue minFilter,
- RsSamplerValue wrapS,
- RsSamplerValue wrapT,
- RsSamplerValue wrapR,
- float aniso) : ObjectBase(rsc) {
- mHal.state.magFilter = magFilter;
- mHal.state.minFilter = minFilter;
- mHal.state.wrapS = wrapS;
- mHal.state.wrapT = wrapT;
- mHal.state.wrapR = wrapR;
- mHal.state.aniso = aniso;
-
- mRSC->mHal.funcs.sampler.init(mRSC, this);
-}
-
-Sampler::~Sampler() {
- mRSC->mHal.funcs.sampler.destroy(mRSC, this);
-}
-
-void Sampler::preDestroy() const {
- for (uint32_t ct = 0; ct < mRSC->mStateSampler.mAllSamplers.size(); ct++) {
- if (mRSC->mStateSampler.mAllSamplers[ct] == this) {
- mRSC->mStateSampler.mAllSamplers.removeAt(ct);
- break;
- }
- }
-}
-
-void Sampler::bindToContext(SamplerState *ss, uint32_t slot) {
- ss->mSamplers[slot].set(this);
- mBoundSlot = slot;
-}
-
-void Sampler::unbindFromContext(SamplerState *ss) {
- int32_t slot = mBoundSlot;
- mBoundSlot = -1;
- ss->mSamplers[slot].clear();
-}
-
-void Sampler::serialize(OStream *stream) const {
-}
-
-Sampler *Sampler::createFromStream(Context *rsc, IStream *stream) {
- return NULL;
-}
-
-ObjectBaseRef<Sampler> Sampler::getSampler(Context *rsc,
- RsSamplerValue magFilter,
- RsSamplerValue minFilter,
- RsSamplerValue wrapS,
- RsSamplerValue wrapT,
- RsSamplerValue wrapR,
- float aniso) {
- ObjectBaseRef<Sampler> returnRef;
- ObjectBase::asyncLock();
- for (uint32_t ct = 0; ct < rsc->mStateSampler.mAllSamplers.size(); ct++) {
- Sampler *existing = rsc->mStateSampler.mAllSamplers[ct];
- if (existing->mHal.state.magFilter != magFilter) continue;
- if (existing->mHal.state.minFilter != minFilter ) continue;
- if (existing->mHal.state.wrapS != wrapS) continue;
- if (existing->mHal.state.wrapT != wrapT) continue;
- if (existing->mHal.state.wrapR != wrapR) continue;
- if (existing->mHal.state.aniso != aniso) continue;
- returnRef.set(existing);
- ObjectBase::asyncUnlock();
- return returnRef;
- }
- ObjectBase::asyncUnlock();
-
- Sampler *s = new Sampler(rsc, magFilter, minFilter, wrapS, wrapT, wrapR, aniso);
- returnRef.set(s);
-
- ObjectBase::asyncLock();
- rsc->mStateSampler.mAllSamplers.push(s);
- ObjectBase::asyncUnlock();
-
- return returnRef;
-}
-
-////////////////////////////////
-
-namespace android {
-namespace renderscript {
-
-RsSampler rsi_SamplerCreate(Context * rsc,
- RsSamplerValue magFilter,
- RsSamplerValue minFilter,
- RsSamplerValue wrapS,
- RsSamplerValue wrapT,
- RsSamplerValue wrapR,
- float aniso) {
- ObjectBaseRef<Sampler> s = Sampler::getSampler(rsc, magFilter, minFilter,
- wrapS, wrapT, wrapR, aniso);
- s->incUserRef();
- return s.get();
-}
-
-}}
diff --git a/libs/rs/rsSampler.h b/libs/rs/rsSampler.h
deleted file mode 100644
index dea4cb6..0000000
--- a/libs/rs/rsSampler.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#ifndef ANDROID_RS_SAMPLER_H
-#define ANDROID_RS_SAMPLER_H
-
-#include "rsAllocation.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-const static uint32_t RS_MAX_SAMPLER_SLOT = 16;
-
-class SamplerState;
-/*****************************************************************************
- * CAUTION
- *
- * Any layout changes for this class may require a corresponding change to be
- * made to frameworks/compile/libbcc/lib/ScriptCRT/rs_core.c, which contains
- * a partial copy of the information below.
- *
- *****************************************************************************/
-class Sampler : public ObjectBase {
-public:
- struct Hal {
- mutable void *drv;
-
- struct State {
- RsSamplerValue magFilter;
- RsSamplerValue minFilter;
- RsSamplerValue wrapS;
- RsSamplerValue wrapT;
- RsSamplerValue wrapR;
- float aniso;
- };
- State state;
- };
- Hal mHal;
-
- static ObjectBaseRef<Sampler> getSampler(Context *,
- RsSamplerValue magFilter,
- RsSamplerValue minFilter,
- RsSamplerValue wrapS,
- RsSamplerValue wrapT,
- RsSamplerValue wrapR,
- float aniso = 1.0f);
- void bindToContext(SamplerState *, uint32_t slot);
- void unbindFromContext(SamplerState *);
-
- virtual void serialize(OStream *stream) const;
- virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SAMPLER; }
- static Sampler *createFromStream(Context *rsc, IStream *stream);
-
-protected:
- int32_t mBoundSlot;
-
- virtual void preDestroy() const;
- virtual ~Sampler();
-
-private:
- Sampler(Context *);
- Sampler(Context *,
- RsSamplerValue magFilter,
- RsSamplerValue minFilter,
- RsSamplerValue wrapS,
- RsSamplerValue wrapT,
- RsSamplerValue wrapR,
- float aniso = 1.0f);
-};
-
-
-class SamplerState {
-public:
- ObjectBaseRef<Sampler> mSamplers[RS_MAX_SAMPLER_SLOT];
- void init(Context *rsc) {
- }
- void deinit(Context *rsc) {
- for (uint32_t i = 0; i < RS_MAX_SAMPLER_SLOT; i ++) {
- mSamplers[i].clear();
- }
- }
- // Cache of all existing raster programs.
- Vector<Sampler *> mAllSamplers;
-};
-
-}
-}
-#endif //ANDROID_RS_SAMPLER_H
-
-
-
diff --git a/libs/rs/rsScript.cpp b/libs/rs/rsScript.cpp
deleted file mode 100644
index 6a3bd4b..0000000
--- a/libs/rs/rsScript.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) 2009-2012 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.
- */
-
-#include "rsContext.h"
-#include <time.h>
-
-using namespace android;
-using namespace android::renderscript;
-
-Script::Script(Context *rsc) : ObjectBase(rsc) {
- memset(&mEnviroment, 0, sizeof(mEnviroment));
- memset(&mHal, 0, sizeof(mHal));
-
- mSlots = NULL;
- mTypes = NULL;
- mInitialized = false;
-}
-
-Script::~Script() {
- if (mSlots) {
- delete [] mSlots;
- mSlots = NULL;
- }
- if (mTypes) {
- delete [] mTypes;
- mTypes = NULL;
- }
-}
-
-void Script::setSlot(uint32_t slot, Allocation *a) {
- //ALOGE("setSlot %i %p", slot, a);
- if (slot >= mHal.info.exportedVariableCount) {
- ALOGE("Script::setSlot unable to set allocation, invalid slot index");
- return;
- }
-
- mSlots[slot].set(a);
- if (a != NULL) {
- mRSC->mHal.funcs.script.setGlobalBind(mRSC, this, slot, a->getPtr());
- } else {
- mRSC->mHal.funcs.script.setGlobalBind(mRSC, this, slot, NULL);
- }
-}
-
-void Script::setVar(uint32_t slot, const void *val, size_t len) {
- //ALOGE("setVar %i %p %i", slot, val, len);
- if (slot >= mHal.info.exportedVariableCount) {
- ALOGE("Script::setVar unable to set allocation, invalid slot index");
- return;
- }
- mRSC->mHal.funcs.script.setGlobalVar(mRSC, this, slot, (void *)val, len);
-}
-
-void Script::setVarObj(uint32_t slot, ObjectBase *val) {
- //ALOGE("setVarObj %i %p", slot, val);
- if (slot >= mHal.info.exportedVariableCount) {
- ALOGE("Script::setVarObj unable to set allocation, invalid slot index");
- return;
- }
- //ALOGE("setvarobj %i %p", slot, val);
- mRSC->mHal.funcs.script.setGlobalObj(mRSC, this, slot, val);
-}
-
-bool Script::freeChildren() {
- incSysRef();
- mRSC->mHal.funcs.script.invokeFreeChildren(mRSC, this);
- return decSysRef();
-}
-
-namespace android {
-namespace renderscript {
-
-void rsi_ScriptBindAllocation(Context * rsc, RsScript vs, RsAllocation va, uint32_t slot) {
- Script *s = static_cast<Script *>(vs);
- Allocation *a = static_cast<Allocation *>(va);
- s->setSlot(slot, a);
- //ALOGE("rsi_ScriptBindAllocation %i %p %p", slot, a, a->getPtr());
-}
-
-void rsi_ScriptSetTimeZone(Context * rsc, RsScript vs, const char * timeZone, size_t length) {
- // We unfortunately need to make a new copy of the string, since it is
- // not NULL-terminated. We then use setenv(), which properly handles
- // freeing/duplicating the actual string for the environment.
- char *tz = (char *) malloc(length + 1);
- if (!tz) {
- ALOGE("Couldn't allocate memory for timezone buffer");
- return;
- }
- strncpy(tz, timeZone, length);
- tz[length] = '\0';
- if (setenv("TZ", tz, 1) == 0) {
- tzset();
- } else {
- ALOGE("Error setting timezone");
- }
- free(tz);
-}
-
-void rsi_ScriptForEach(Context *rsc, RsScript vs, uint32_t slot,
- RsAllocation vain, RsAllocation vaout,
- const void *params, size_t paramLen) {
- Script *s = static_cast<Script *>(vs);
- s->runForEach(rsc, slot,
- static_cast<const Allocation *>(vain), static_cast<Allocation *>(vaout),
- params, paramLen);
-
-}
-
-void rsi_ScriptInvoke(Context *rsc, RsScript vs, uint32_t slot) {
- Script *s = static_cast<Script *>(vs);
- s->Invoke(rsc, slot, NULL, 0);
-}
-
-
-void rsi_ScriptInvokeData(Context *rsc, RsScript vs, uint32_t slot, void *data) {
- Script *s = static_cast<Script *>(vs);
- s->Invoke(rsc, slot, NULL, 0);
-}
-
-void rsi_ScriptInvokeV(Context *rsc, RsScript vs, uint32_t slot, const void *data, size_t len) {
- Script *s = static_cast<Script *>(vs);
- s->Invoke(rsc, slot, data, len);
-}
-
-void rsi_ScriptSetVarI(Context *rsc, RsScript vs, uint32_t slot, int value) {
- Script *s = static_cast<Script *>(vs);
- s->setVar(slot, &value, sizeof(value));
-}
-
-void rsi_ScriptSetVarObj(Context *rsc, RsScript vs, uint32_t slot, RsObjectBase value) {
- Script *s = static_cast<Script *>(vs);
- ObjectBase *o = static_cast<ObjectBase *>(value);
- s->setVarObj(slot, o);
-}
-
-void rsi_ScriptSetVarJ(Context *rsc, RsScript vs, uint32_t slot, long long value) {
- Script *s = static_cast<Script *>(vs);
- s->setVar(slot, &value, sizeof(value));
-}
-
-void rsi_ScriptSetVarF(Context *rsc, RsScript vs, uint32_t slot, float value) {
- Script *s = static_cast<Script *>(vs);
- s->setVar(slot, &value, sizeof(value));
-}
-
-void rsi_ScriptSetVarD(Context *rsc, RsScript vs, uint32_t slot, double value) {
- Script *s = static_cast<Script *>(vs);
- s->setVar(slot, &value, sizeof(value));
-}
-
-void rsi_ScriptSetVarV(Context *rsc, RsScript vs, uint32_t slot, const void *data, size_t len) {
- Script *s = static_cast<Script *>(vs);
- s->setVar(slot, data, len);
-}
-
-}
-}
-
diff --git a/libs/rs/rsScript.h b/libs/rs/rsScript.h
deleted file mode 100644
index 7879ea6..0000000
--- a/libs/rs/rsScript.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2009-2012 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.
- */
-
-#ifndef ANDROID_RS_SCRIPT_H
-#define ANDROID_RS_SCRIPT_H
-
-#include "rsAllocation.h"
-
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-class ProgramVertex;
-class ProgramFragment;
-class ProgramRaster;
-class ProgramStore;
-
-class Script : public ObjectBase {
-public:
- struct Hal {
- void * drv;
-
- struct DriverInfo {
- int mVersionMajor;
- int mVersionMinor;
-
- size_t exportedVariableCount;
- size_t exportedFunctionCount;
- size_t exportedPragmaCount;
- char const **exportedPragmaKeyList;
- char const **exportedPragmaValueList;
-
- int (* root)();
- bool isThreadable;
- };
- DriverInfo info;
- };
- Hal mHal;
-
- typedef void (* InvokeFunc_t)(void);
-
- Script(Context *);
- virtual ~Script();
-
- struct Enviroment_t {
- int64_t mStartTimeMillis;
- int64_t mLastDtTime;
-
- ObjectBaseRef<ProgramVertex> mVertex;
- ObjectBaseRef<ProgramFragment> mFragment;
- ObjectBaseRef<ProgramRaster> mRaster;
- ObjectBaseRef<ProgramStore> mFragmentStore;
- };
- Enviroment_t mEnviroment;
-
- void setSlot(uint32_t slot, Allocation *a);
- void setVar(uint32_t slot, const void *val, size_t len);
- void setVarObj(uint32_t slot, ObjectBase *val);
-
- virtual bool freeChildren();
-
- virtual void runForEach(Context *rsc,
- uint32_t slot,
- const Allocation * ain,
- Allocation * aout,
- const void * usr,
- size_t usrBytes,
- const RsScriptCall *sc = NULL) = 0;
-
- virtual void Invoke(Context *rsc, uint32_t slot, const void *data, size_t len) = 0;
- virtual void setupScript(Context *rsc) = 0;
- virtual uint32_t run(Context *) = 0;
-protected:
- bool mInitialized;
- ObjectBaseRef<Allocation> *mSlots;
- ObjectBaseRef<const Type> *mTypes;
-
-};
-
-
-}
-}
-#endif
-
diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp
deleted file mode 100644
index 79725b97..0000000
--- a/libs/rs/rsScriptC.cpp
+++ /dev/null
@@ -1,335 +0,0 @@
-/*
- * Copyright (C) 2009-2012 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.
- */
-
-#include "rsContext.h"
-#include "rsScriptC.h"
-#include "utils/Timers.h"
-#include "utils/StopWatch.h"
-
-#ifndef ANDROID_RS_SERIALIZE
-#include <bcinfo/BitcodeTranslator.h>
-#include <bcinfo/BitcodeWrapper.h>
-#endif
-
-using namespace android;
-using namespace android::renderscript;
-
-#define GET_TLS() Context::ScriptTLSStruct * tls = \
- (Context::ScriptTLSStruct *)pthread_getspecific(Context::gThreadTLSKey); \
- Context * rsc = tls->mContext; \
- ScriptC * sc = (ScriptC *) tls->mScript
-
-ScriptC::ScriptC(Context *rsc) : Script(rsc) {
-#ifndef ANDROID_RS_SERIALIZE
- BT = NULL;
-#endif
-}
-
-ScriptC::~ScriptC() {
-#ifndef ANDROID_RS_SERIALIZE
- if (BT) {
- delete BT;
- BT = NULL;
- }
-#endif
- if (mInitialized) {
- mRSC->mHal.funcs.script.invokeFreeChildren(mRSC, this);
- mRSC->mHal.funcs.script.destroy(mRSC, this);
- }
-}
-
-void ScriptC::setupScript(Context *rsc) {
- mEnviroment.mStartTimeMillis
- = nanoseconds_to_milliseconds(systemTime(SYSTEM_TIME_MONOTONIC));
-
- for (uint32_t ct=0; ct < mHal.info.exportedVariableCount; ct++) {
- if (mSlots[ct].get() && !mTypes[ct].get()) {
- mTypes[ct].set(mSlots[ct]->getType());
- }
-
- if (!mTypes[ct].get())
- continue;
- void *ptr = NULL;
- if (mSlots[ct].get()) {
- ptr = mSlots[ct]->getPtr();
- }
-
- rsc->mHal.funcs.script.setGlobalBind(rsc, this, ct, ptr);
- }
-}
-
-const Allocation *ScriptC::ptrToAllocation(const void *ptr) const {
- //ALOGE("ptr to alloc %p", ptr);
- if (!ptr) {
- return NULL;
- }
- for (uint32_t ct=0; ct < mHal.info.exportedVariableCount; ct++) {
- if (!mSlots[ct].get())
- continue;
- if (mSlots[ct]->getPtr() == ptr) {
- return mSlots[ct].get();
- }
- }
- ALOGE("ScriptC::ptrToAllocation, failed to find %p", ptr);
- return NULL;
-}
-
-void ScriptC::setupGLState(Context *rsc) {
- if (mEnviroment.mFragmentStore.get()) {
- rsc->setProgramStore(mEnviroment.mFragmentStore.get());
- }
- if (mEnviroment.mFragment.get()) {
- rsc->setProgramFragment(mEnviroment.mFragment.get());
- }
- if (mEnviroment.mVertex.get()) {
- rsc->setProgramVertex(mEnviroment.mVertex.get());
- }
- if (mEnviroment.mRaster.get()) {
- rsc->setProgramRaster(mEnviroment.mRaster.get());
- }
-}
-
-uint32_t ScriptC::run(Context *rsc) {
- if (mHal.info.root == NULL) {
- rsc->setError(RS_ERROR_BAD_SCRIPT, "Attempted to run bad script");
- return 0;
- }
-
- setupGLState(rsc);
- setupScript(rsc);
-
- uint32_t ret = 0;
-
- if (rsc->props.mLogScripts) {
- ALOGV("%p ScriptC::run invoking root, ptr %p", rsc, mHal.info.root);
- }
-
- ret = rsc->mHal.funcs.script.invokeRoot(rsc, this);
-
- if (rsc->props.mLogScripts) {
- ALOGV("%p ScriptC::run invoking complete, ret=%i", rsc, ret);
- }
-
- return ret;
-}
-
-
-void ScriptC::runForEach(Context *rsc,
- uint32_t slot,
- const Allocation * ain,
- Allocation * aout,
- const void * usr,
- size_t usrBytes,
- const RsScriptCall *sc) {
-
- Context::PushState ps(rsc);
-
- setupGLState(rsc);
- setupScript(rsc);
- rsc->mHal.funcs.script.invokeForEach(rsc, this, slot, ain, aout, usr, usrBytes, sc);
-}
-
-void ScriptC::Invoke(Context *rsc, uint32_t slot, const void *data, size_t len) {
- if (slot >= mHal.info.exportedFunctionCount) {
- rsc->setError(RS_ERROR_BAD_SCRIPT, "Calling invoke on bad script");
- return;
- }
- setupScript(rsc);
-
- if (rsc->props.mLogScripts) {
- ALOGV("%p ScriptC::Invoke invoking slot %i, ptr %p", rsc, slot, this);
- }
- rsc->mHal.funcs.script.invokeFunction(rsc, this, slot, data, len);
-}
-
-ScriptCState::ScriptCState() {
-}
-
-ScriptCState::~ScriptCState() {
-}
-
-/*
-static void* symbolLookup(void* pContext, char const* name) {
- const ScriptCState::SymbolTable_t *sym;
- ScriptC *s = (ScriptC *)pContext;
- if (!strcmp(name, "__isThreadable")) {
- return (void*) s->mHal.info.isThreadable;
- } else if (!strcmp(name, "__clearThreadable")) {
- s->mHal.info.isThreadable = false;
- return NULL;
- }
- sym = ScriptCState::lookupSymbol(name);
- if (!sym) {
- sym = ScriptCState::lookupSymbolCL(name);
- }
- if (!sym) {
- sym = ScriptCState::lookupSymbolGL(name);
- }
- if (sym) {
- s->mHal.info.isThreadable &= sym->threadable;
- return sym->mPtr;
- }
- ALOGE("ScriptC sym lookup failed for %s", name);
- return NULL;
-}
-*/
-
-#if 0
-extern const char rs_runtime_lib_bc[];
-extern unsigned rs_runtime_lib_bc_size;
-#endif
-
-bool ScriptC::runCompiler(Context *rsc,
- const char *resName,
- const char *cacheDir,
- const uint8_t *bitcode,
- size_t bitcodeLen) {
-
- //ALOGE("runCompiler %p %p %p %p %p %i", rsc, this, resName, cacheDir, bitcode, bitcodeLen);
-#ifndef ANDROID_RS_SERIALIZE
- uint32_t sdkVersion = 0;
- bcinfo::BitcodeWrapper bcWrapper((const char *)bitcode, bitcodeLen);
- if (!bcWrapper.unwrap()) {
- ALOGE("Bitcode is not in proper container format (raw or wrapper)");
- return false;
- }
-
- if (bcWrapper.getBCFileType() == bcinfo::BC_WRAPPER) {
- sdkVersion = bcWrapper.getTargetAPI();
- }
-
- if (sdkVersion == 0) {
- // This signals that we didn't have a wrapper containing information
- // about the bitcode.
- sdkVersion = rsc->getTargetSdkVersion();
- }
-
- if (BT) {
- delete BT;
- }
- BT = new bcinfo::BitcodeTranslator((const char *)bitcode, bitcodeLen,
- sdkVersion);
- if (!BT->translate()) {
- ALOGE("Failed to translate bitcode from version: %u", sdkVersion);
- delete BT;
- BT = NULL;
- return false;
- }
- bitcode = (const uint8_t *) BT->getTranslatedBitcode();
- bitcodeLen = BT->getTranslatedBitcodeSize();
-#endif
-
- if (!rsc->mHal.funcs.script.init(rsc, this, resName, cacheDir, bitcode, bitcodeLen, 0)) {
- return false;
- }
-
- mInitialized = true;
- mEnviroment.mFragment.set(rsc->getDefaultProgramFragment());
- mEnviroment.mVertex.set(rsc->getDefaultProgramVertex());
- mEnviroment.mFragmentStore.set(rsc->getDefaultProgramStore());
- mEnviroment.mRaster.set(rsc->getDefaultProgramRaster());
-
- rsc->mHal.funcs.script.invokeInit(rsc, this);
-
- for (size_t i=0; i < mHal.info.exportedPragmaCount; ++i) {
- const char * key = mHal.info.exportedPragmaKeyList[i];
- const char * value = mHal.info.exportedPragmaValueList[i];
- //ALOGE("pragma %s %s", keys[i], values[i]);
- if (!strcmp(key, "version")) {
- if (!strcmp(value, "1")) {
- continue;
- }
- ALOGE("Invalid version pragma value: %s\n", value);
- return false;
- }
-
- if (!strcmp(key, "stateVertex")) {
- if (!strcmp(value, "default")) {
- continue;
- }
- if (!strcmp(value, "parent")) {
- mEnviroment.mVertex.clear();
- continue;
- }
- ALOGE("Unrecognized value %s passed to stateVertex", value);
- return false;
- }
-
- if (!strcmp(key, "stateRaster")) {
- if (!strcmp(value, "default")) {
- continue;
- }
- if (!strcmp(value, "parent")) {
- mEnviroment.mRaster.clear();
- continue;
- }
- ALOGE("Unrecognized value %s passed to stateRaster", value);
- return false;
- }
-
- if (!strcmp(key, "stateFragment")) {
- if (!strcmp(value, "default")) {
- continue;
- }
- if (!strcmp(value, "parent")) {
- mEnviroment.mFragment.clear();
- continue;
- }
- ALOGE("Unrecognized value %s passed to stateFragment", value);
- return false;
- }
-
- if (!strcmp(key, "stateStore")) {
- if (!strcmp(value, "default")) {
- continue;
- }
- if (!strcmp(value, "parent")) {
- mEnviroment.mFragmentStore.clear();
- continue;
- }
- ALOGE("Unrecognized value %s passed to stateStore", value);
- return false;
- }
- }
-
- mSlots = new ObjectBaseRef<Allocation>[mHal.info.exportedVariableCount];
- mTypes = new ObjectBaseRef<const Type>[mHal.info.exportedVariableCount];
-
- return true;
-}
-
-namespace android {
-namespace renderscript {
-
-RsScript rsi_ScriptCCreate(Context *rsc,
- const char *resName, size_t resName_length,
- const char *cacheDir, size_t cacheDir_length,
- const char *text, size_t text_length)
-{
- ScriptC *s = new ScriptC(rsc);
-
- if (!s->runCompiler(rsc, resName, cacheDir, (uint8_t *)text, text_length)) {
- // Error during compile, destroy s and return null.
- ObjectBase::checkDelete(s);
- return NULL;
- }
-
- s->incUserRef();
- return s;
-}
-
-}
-}
diff --git a/libs/rs/rsScriptC.h b/libs/rs/rsScriptC.h
deleted file mode 100644
index 92e1f4f..0000000
--- a/libs/rs/rsScriptC.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2009-2012 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.
- */
-
-#ifndef ANDROID_RS_SCRIPT_C_H
-#define ANDROID_RS_SCRIPT_C_H
-
-#include "rsScript.h"
-
-#include "rsEnv.h"
-
-#ifndef ANDROID_RS_SERIALIZE
-#include "bcinfo/BitcodeTranslator.h"
-#endif
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-
-class ScriptC : public Script {
-public:
- typedef int (*RunScript_t)();
- typedef void (*VoidFunc_t)();
-
- ScriptC(Context *);
- virtual ~ScriptC();
-
-
- const Allocation *ptrToAllocation(const void *) const;
-
-
- virtual void Invoke(Context *rsc, uint32_t slot, const void *data, size_t len);
-
- virtual uint32_t run(Context *);
-
- virtual void runForEach(Context *rsc,
- uint32_t slot,
- const Allocation * ain,
- Allocation * aout,
- const void * usr,
- size_t usrBytes,
- const RsScriptCall *sc = NULL);
-
- virtual void serialize(OStream *stream) const { }
- virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SCRIPT_C; }
- static Type *createFromStream(Context *rsc, IStream *stream) { return NULL; }
-
- bool runCompiler(Context *rsc, const char *resName, const char *cacheDir,
- const uint8_t *bitcode, size_t bitcodeLen);
-
-//protected:
- void setupScript(Context *);
- void setupGLState(Context *);
- Script * setTLS(Script *);
- private:
-#ifndef ANDROID_RS_SERIALIZE
- bcinfo::BitcodeTranslator *BT;
-#endif
-};
-
-class ScriptCState {
-public:
- ScriptCState();
- ~ScriptCState();
-
- char * mScriptText;
- size_t mScriptLen;
-
- struct SymbolTable_t {
- const char * mName;
- void * mPtr;
- bool threadable;
- };
- static const SymbolTable_t * lookupSymbol(const char *);
- static const SymbolTable_t * lookupSymbolCL(const char *);
- static const SymbolTable_t * lookupSymbolGL(const char *);
-};
-
-
-}
-}
-#endif
diff --git a/libs/rs/rsScriptC_Lib.cpp b/libs/rs/rsScriptC_Lib.cpp
deleted file mode 100644
index 749495d..0000000
--- a/libs/rs/rsScriptC_Lib.cpp
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright (C) 2009-2012 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.
- */
-
-#include "rsContext.h"
-#include "rsScriptC.h"
-#include "rsMatrix4x4.h"
-#include "rsMatrix3x3.h"
-#include "rsMatrix2x2.h"
-#include "rsgApiStructs.h"
-
-#include "utils/Timers.h"
-
-#include <time.h>
-
-using namespace android;
-using namespace android::renderscript;
-
-
-namespace android {
-namespace renderscript {
-
-
-//////////////////////////////////////////////////////////////////////////////
-// Math routines
-//////////////////////////////////////////////////////////////////////////////
-
-#if 0
-static float SC_sinf_fast(float x) {
- const float A = 1.0f / (2.0f * M_PI);
- const float B = -16.0f;
- const float C = 8.0f;
-
- // scale angle for easy argument reduction
- x *= A;
-
- if (fabsf(x) >= 0.5f) {
- // argument reduction
- x = x - ceilf(x + 0.5f) + 1.0f;
- }
-
- const float y = B * x * fabsf(x) + C * x;
- return 0.2215f * (y * fabsf(y) - y) + y;
-}
-
-static float SC_cosf_fast(float x) {
- x += float(M_PI / 2);
-
- const float A = 1.0f / (2.0f * M_PI);
- const float B = -16.0f;
- const float C = 8.0f;
-
- // scale angle for easy argument reduction
- x *= A;
-
- if (fabsf(x) >= 0.5f) {
- // argument reduction
- x = x - ceilf(x + 0.5f) + 1.0f;
- }
-
- const float y = B * x * fabsf(x) + C * x;
- return 0.2215f * (y * fabsf(y) - y) + y;
-}
-#endif
-
-//////////////////////////////////////////////////////////////////////////////
-// Time routines
-//////////////////////////////////////////////////////////////////////////////
-
-time_t rsrTime(Context *rsc, Script *sc, time_t *timer) {
- return time(timer);
-}
-
-tm* rsrLocalTime(Context *rsc, Script *sc, tm *local, time_t *timer) {
- if (!local) {
- return NULL;
- }
-
- // The native localtime function is not thread-safe, so we
- // have to apply locking for proper behavior in RenderScript.
- pthread_mutex_lock(&rsc->gLibMutex);
- tm *tmp = localtime(timer);
- memcpy(local, tmp, sizeof(*tmp));
- pthread_mutex_unlock(&rsc->gLibMutex);
- return local;
-}
-
-int64_t rsrUptimeMillis(Context *rsc, Script *sc) {
- return nanoseconds_to_milliseconds(systemTime(SYSTEM_TIME_MONOTONIC));
-}
-
-int64_t rsrUptimeNanos(Context *rsc, Script *sc) {
- return systemTime(SYSTEM_TIME_MONOTONIC);
-}
-
-float rsrGetDt(Context *rsc, Script *sc) {
- int64_t l = sc->mEnviroment.mLastDtTime;
- sc->mEnviroment.mLastDtTime = systemTime(SYSTEM_TIME_MONOTONIC);
- return ((float)(sc->mEnviroment.mLastDtTime - l)) / 1.0e9;
-}
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-
-void rsrSetObject(const Context *rsc, const Script *sc, ObjectBase **dst, ObjectBase * src) {
- //ALOGE("rsiSetObject %p,%p %p", vdst, *vdst, vsrc);
- if (src) {
- CHECK_OBJ(src);
- src->incSysRef();
- }
- if (dst[0]) {
- CHECK_OBJ(dst[0]);
- dst[0]->decSysRef();
- }
- *dst = src;
-}
-
-void rsrClearObject(const Context *rsc, const Script *sc, ObjectBase **dst) {
- //ALOGE("rsiClearObject %p,%p", vdst, *vdst);
- if (dst[0]) {
- CHECK_OBJ(dst[0]);
- dst[0]->decSysRef();
- }
- *dst = NULL;
-}
-
-bool rsrIsObject(const Context *rsc, const Script *sc, const ObjectBase *src) {
- return src != NULL;
-}
-
-
-uint32_t rsrToClient(Context *rsc, Script *sc, int cmdID, void *data, int len) {
- //ALOGE("SC_toClient %i %i %i", cmdID, len);
- return rsc->sendMessageToClient(data, RS_MESSAGE_TO_CLIENT_USER, cmdID, len, false);
-}
-
-uint32_t rsrToClientBlocking(Context *rsc, Script *sc, int cmdID, void *data, int len) {
- //ALOGE("SC_toClientBlocking %i %i", cmdID, len);
- return rsc->sendMessageToClient(data, RS_MESSAGE_TO_CLIENT_USER, cmdID, len, true);
-}
-
-
-void rsrForEach(Context *rsc, Script *sc,
- Script *target,
- Allocation *in, Allocation *out,
- const void *usr, uint32_t usrBytes,
- const RsScriptCall *call) {
- target->runForEach(rsc, /* root slot */ 0, in, out, usr, usrBytes, call);
-}
-
-void rsrAllocationSyncAll(Context *rsc, Script *sc, Allocation *a, RsAllocationUsageType usage) {
- a->syncAll(rsc, usage);
-}
-
-void rsrAllocationCopy1DRange(Context *rsc, Allocation *dstAlloc,
- uint32_t dstOff,
- uint32_t dstMip,
- uint32_t count,
- Allocation *srcAlloc,
- uint32_t srcOff, uint32_t srcMip) {
- rsi_AllocationCopy2DRange(rsc, dstAlloc, dstOff, 0,
- dstMip, 0, count, 1,
- srcAlloc, srcOff, 0, srcMip, 0);
-}
-
-void rsrAllocationCopy2DRange(Context *rsc, Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstYoff,
- uint32_t dstMip, uint32_t dstFace,
- uint32_t width, uint32_t height,
- Allocation *srcAlloc,
- uint32_t srcXoff, uint32_t srcYoff,
- uint32_t srcMip, uint32_t srcFace) {
- rsi_AllocationCopy2DRange(rsc, dstAlloc, dstXoff, dstYoff,
- dstMip, dstFace, width, height,
- srcAlloc, srcXoff, srcYoff, srcMip, srcFace);
-}
-
-const Allocation * rsrGetAllocation(Context *rsc, Script *s, const void *ptr) {
- ScriptC *sc = (ScriptC *)s;
- return sc->ptrToAllocation(ptr);
-}
-
-}
-}
-
diff --git a/libs/rs/rsScriptC_LibGL.cpp b/libs/rs/rsScriptC_LibGL.cpp
deleted file mode 100644
index 21b1c42..0000000
--- a/libs/rs/rsScriptC_LibGL.cpp
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#include "rsContext.h"
-#include "rsScriptC.h"
-#include "rsMatrix4x4.h"
-#include "rsMatrix3x3.h"
-#include "rsMatrix2x2.h"
-#include "rsMesh.h"
-#include "rsgApiStructs.h"
-
-#include "utils/Timers.h"
-#include "driver/rsdVertexArray.h"
-#include "driver/rsdShaderCache.h"
-#include "driver/rsdCore.h"
-
-#define GL_GLEXT_PROTOTYPES
-
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-
-#include <time.h>
-
-using namespace android;
-using namespace android::renderscript;
-
-namespace android {
-namespace renderscript {
-
-//////////////////////////////////////////////////////////////////////////////
-// Context
-//////////////////////////////////////////////////////////////////////////////
-
-void rsrBindTexture(Context *rsc, Script *sc, ProgramFragment *pf, uint32_t slot, Allocation *a) {
- CHECK_OBJ_OR_NULL(a);
- CHECK_OBJ(pf);
- pf->bindTexture(rsc, slot, a);
-}
-
-void rsrBindConstant(Context *rsc, Script *sc, ProgramFragment *pf, uint32_t slot, Allocation *a) {
- CHECK_OBJ_OR_NULL(a);
- CHECK_OBJ(pf);
- pf->bindAllocation(rsc, a, slot);
-}
-
-void rsrBindConstant(Context *rsc, Script *sc, ProgramVertex *pv, uint32_t slot, Allocation *a) {
- CHECK_OBJ_OR_NULL(a);
- CHECK_OBJ(pv);
- pv->bindAllocation(rsc, a, slot);
-}
-
-void rsrBindSampler(Context *rsc, Script *sc, ProgramFragment *pf, uint32_t slot, Sampler *s) {
- CHECK_OBJ_OR_NULL(vs);
- CHECK_OBJ(vpf);
- pf->bindSampler(rsc, slot, s);
-}
-
-void rsrBindProgramStore(Context *rsc, Script *sc, ProgramStore *ps) {
- CHECK_OBJ_OR_NULL(ps);
- rsc->setProgramStore(ps);
-}
-
-void rsrBindProgramFragment(Context *rsc, Script *sc, ProgramFragment *pf) {
- CHECK_OBJ_OR_NULL(pf);
- rsc->setProgramFragment(pf);
-}
-
-void rsrBindProgramVertex(Context *rsc, Script *sc, ProgramVertex *pv) {
- CHECK_OBJ_OR_NULL(pv);
- rsc->setProgramVertex(pv);
-}
-
-void rsrBindProgramRaster(Context *rsc, Script *sc, ProgramRaster *pr) {
- CHECK_OBJ_OR_NULL(pr);
- rsc->setProgramRaster(pr);
-}
-
-void rsrBindFrameBufferObjectColorTarget(Context *rsc, Script *sc, Allocation *a, uint32_t slot) {
- CHECK_OBJ(va);
- rsc->mFBOCache.bindColorTarget(rsc, a, slot);
- rsc->mStateVertex.updateSize(rsc);
-}
-
-void rsrBindFrameBufferObjectDepthTarget(Context *rsc, Script *sc, Allocation *a) {
- CHECK_OBJ(va);
- rsc->mFBOCache.bindDepthTarget(rsc, a);
- rsc->mStateVertex.updateSize(rsc);
-}
-
-void rsrClearFrameBufferObjectColorTarget(Context *rsc, Script *sc, uint32_t slot) {
- rsc->mFBOCache.bindColorTarget(rsc, NULL, slot);
- rsc->mStateVertex.updateSize(rsc);
-}
-
-void rsrClearFrameBufferObjectDepthTarget(Context *rsc, Script *sc) {
- rsc->mFBOCache.bindDepthTarget(rsc, NULL);
- rsc->mStateVertex.updateSize(rsc);
-}
-
-void rsrClearFrameBufferObjectTargets(Context *rsc, Script *sc) {
- rsc->mFBOCache.resetAll(rsc);
- rsc->mStateVertex.updateSize(rsc);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-// VP
-//////////////////////////////////////////////////////////////////////////////
-
-void rsrVpLoadProjectionMatrix(Context *rsc, Script *sc, const rsc_Matrix *m) {
- rsc->getProgramVertex()->setProjectionMatrix(rsc, m);
-}
-
-void rsrVpLoadModelMatrix(Context *rsc, Script *sc, const rsc_Matrix *m) {
- rsc->getProgramVertex()->setModelviewMatrix(rsc, m);
-}
-
-void rsrVpLoadTextureMatrix(Context *rsc, Script *sc, const rsc_Matrix *m) {
- rsc->getProgramVertex()->setTextureMatrix(rsc, m);
-}
-
-void rsrPfConstantColor(Context *rsc, Script *sc, ProgramFragment *pf,
- float r, float g, float b, float a) {
- CHECK_OBJ(pf);
- pf->setConstantColor(rsc, r, g, b, a);
-}
-
-void rsrVpGetProjectionMatrix(Context *rsc, Script *sc, rsc_Matrix *m) {
- rsc->getProgramVertex()->getProjectionMatrix(rsc, m);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-// Drawing
-//////////////////////////////////////////////////////////////////////////////
-
-void rsrDrawQuadTexCoords(Context *rsc, Script *sc,
- float x1, float y1, float z1, float u1, float v1,
- float x2, float y2, float z2, float u2, float v2,
- float x3, float y3, float z3, float u3, float v3,
- float x4, float y4, float z4, float u4, float v4) {
- if (!rsc->setupCheck()) {
- return;
- }
-
- RsdHal *dc = (RsdHal *)rsc->mHal.drv;
- if (!dc->gl.shaderCache->setup(rsc)) {
- return;
- }
-
- //ALOGE("Quad");
- //ALOGE("%4.2f, %4.2f, %4.2f", x1, y1, z1);
- //ALOGE("%4.2f, %4.2f, %4.2f", x2, y2, z2);
- //ALOGE("%4.2f, %4.2f, %4.2f", x3, y3, z3);
- //ALOGE("%4.2f, %4.2f, %4.2f", x4, y4, z4);
-
- float vtx[] = {x1,y1,z1, x2,y2,z2, x3,y3,z3, x4,y4,z4};
- const float tex[] = {u1,v1, u2,v2, u3,v3, u4,v4};
-
- RsdVertexArray::Attrib attribs[2];
- attribs[0].set(GL_FLOAT, 3, 12, false, (uint32_t)vtx, "ATTRIB_position");
- attribs[1].set(GL_FLOAT, 2, 8, false, (uint32_t)tex, "ATTRIB_texture0");
-
- RsdVertexArray va(attribs, 2);
- va.setup(rsc);
-
- RSD_CALL_GL(glDrawArrays, GL_TRIANGLE_FAN, 0, 4);
-}
-
-void rsrDrawQuad(Context *rsc, Script *sc,
- float x1, float y1, float z1,
- float x2, float y2, float z2,
- float x3, float y3, float z3,
- float x4, float y4, float z4) {
- rsrDrawQuadTexCoords(rsc, sc, x1, y1, z1, 0, 1,
- x2, y2, z2, 1, 1,
- x3, y3, z3, 1, 0,
- x4, y4, z4, 0, 0);
-}
-
-void rsrDrawSpriteScreenspace(Context *rsc, Script *sc,
- float x, float y, float z, float w, float h) {
- ObjectBaseRef<const ProgramVertex> tmp(rsc->getProgramVertex());
- rsc->setProgramVertex(rsc->getDefaultProgramVertex());
- //rsc->setupCheck();
-
- //GLint crop[4] = {0, h, w, -h};
-
- float sh = rsc->getHeight();
-
- rsrDrawQuad(rsc, sc,
- x, sh - y, z,
- x+w, sh - y, z,
- x+w, sh - (y+h), z,
- x, sh - (y+h), z);
- rsc->setProgramVertex((ProgramVertex *)tmp.get());
-}
-
-void rsrDrawRect(Context *rsc, Script *sc, float x1, float y1, float x2, float y2, float z) {
- //ALOGE("SC_drawRect %f,%f %f,%f %f", x1, y1, x2, y2, z);
- rsrDrawQuad(rsc, sc, x1, y2, z, x2, y2, z, x2, y1, z, x1, y1, z);
-}
-
-void rsrDrawPath(Context *rsc, Script *sc, Path *sm) {
- CHECK_OBJ(sm);
- if (!rsc->setupCheck()) {
- return;
- }
- sm->render(rsc);
-}
-
-void rsrDrawMesh(Context *rsc, Script *sc, Mesh *sm) {
- CHECK_OBJ(sm);
- if (!rsc->setupCheck()) {
- return;
- }
- sm->render(rsc);
-}
-
-void rsrDrawMeshPrimitive(Context *rsc, Script *sc, Mesh *sm, uint32_t primIndex) {
- CHECK_OBJ(sm);
- if (!rsc->setupCheck()) {
- return;
- }
- sm->renderPrimitive(rsc, primIndex);
-}
-
-void rsrDrawMeshPrimitiveRange(Context *rsc, Script *sc, Mesh *sm, uint32_t primIndex,
- uint32_t start, uint32_t len) {
- CHECK_OBJ(sm);
- if (!rsc->setupCheck()) {
- return;
- }
- sm->renderPrimitiveRange(rsc, primIndex, start, len);
-}
-
-void rsrMeshComputeBoundingBox(Context *rsc, Script *sc, Mesh *sm,
- float *minX, float *minY, float *minZ,
- float *maxX, float *maxY, float *maxZ) {
- CHECK_OBJ(sm);
- sm->computeBBox();
- *minX = sm->mBBoxMin[0];
- *minY = sm->mBBoxMin[1];
- *minZ = sm->mBBoxMin[2];
- *maxX = sm->mBBoxMax[0];
- *maxY = sm->mBBoxMax[1];
- *maxZ = sm->mBBoxMax[2];
-}
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-
-
-void rsrColor(Context *rsc, Script *sc, float r, float g, float b, float a) {
- ProgramFragment *pf = rsc->getProgramFragment();
- pf->setConstantColor(rsc, r, g, b, a);
-}
-
-void rsrPrepareClear(Context *rsc, Script *sc) {
- rsc->mFBOCache.setup(rsc);
- rsc->setupProgramStore();
-}
-
-uint32_t rsrGetWidth(Context *rsc, Script *sc) {
- return rsc->getWidth();
-}
-
-uint32_t rsrGetHeight(Context *rsc, Script *sc) {
- return rsc->getHeight();
-}
-
-void rsrDrawTextAlloc(Context *rsc, Script *sc, Allocation *a, int x, int y) {
- const char *text = (const char *)a->getPtr();
- size_t allocSize = a->getType()->getSizeBytes();
- rsc->mStateFont.renderText(text, allocSize, x, y);
-}
-
-void rsrDrawText(Context *rsc, Script *sc, const char *text, int x, int y) {
- size_t textLen = strlen(text);
- rsc->mStateFont.renderText(text, textLen, x, y);
-}
-
-static void SetMetrics(Font::Rect *metrics,
- int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) {
- if (left) {
- *left = metrics->left;
- }
- if (right) {
- *right = metrics->right;
- }
- if (top) {
- *top = metrics->top;
- }
- if (bottom) {
- *bottom = metrics->bottom;
- }
-}
-
-void rsrMeasureTextAlloc(Context *rsc, Script *sc, Allocation *a,
- int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) {
- CHECK_OBJ(a);
- const char *text = (const char *)a->getPtr();
- size_t textLen = a->getType()->getSizeBytes();
- Font::Rect metrics;
- rsc->mStateFont.measureText(text, textLen, &metrics);
- SetMetrics(&metrics, left, right, top, bottom);
-}
-
-void rsrMeasureText(Context *rsc, Script *sc, const char *text,
- int32_t *left, int32_t *right, int32_t *top, int32_t *bottom) {
- size_t textLen = strlen(text);
- Font::Rect metrics;
- rsc->mStateFont.measureText(text, textLen, &metrics);
- SetMetrics(&metrics, left, right, top, bottom);
-}
-
-void rsrBindFont(Context *rsc, Script *sc, Font *font) {
- CHECK_OBJ(font);
- rsi_ContextBindFont(rsc, font);
-}
-
-void rsrFontColor(Context *rsc, Script *sc, float r, float g, float b, float a) {
- rsc->mStateFont.setFontColor(r, g, b, a);
-}
-
-}
-}
diff --git a/libs/rs/rsSignal.cpp b/libs/rs/rsSignal.cpp
deleted file mode 100644
index 3f6a13c..0000000
--- a/libs/rs/rsSignal.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#include "rsSignal.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-
-Signal::Signal() {
- mSet = true;
-}
-
-Signal::~Signal() {
- pthread_mutex_destroy(&mMutex);
- pthread_cond_destroy(&mCondition);
-}
-
-bool Signal::init() {
- int status = pthread_mutex_init(&mMutex, NULL);
- if (status) {
- ALOGE("LocklessFifo mutex init failure");
- return false;
- }
-
- status = pthread_cond_init(&mCondition, NULL);
- if (status) {
- ALOGE("LocklessFifo condition init failure");
- pthread_mutex_destroy(&mMutex);
- return false;
- }
-
- return true;
-}
-
-void Signal::set() {
- int status;
-
- status = pthread_mutex_lock(&mMutex);
- if (status) {
- ALOGE("LocklessCommandFifo: error %i locking for set condition.", status);
- return;
- }
-
- mSet = true;
-
- status = pthread_cond_signal(&mCondition);
- if (status) {
- ALOGE("LocklessCommandFifo: error %i on set condition.", status);
- }
-
- status = pthread_mutex_unlock(&mMutex);
- if (status) {
- ALOGE("LocklessCommandFifo: error %i unlocking for set condition.", status);
- }
-}
-
-bool Signal::wait(uint64_t timeout) {
- int status;
- bool ret = false;
-
- status = pthread_mutex_lock(&mMutex);
- if (status) {
- ALOGE("LocklessCommandFifo: error %i locking for condition.", status);
- return false;
- }
-
- if (!mSet) {
- if (!timeout) {
- status = pthread_cond_wait(&mCondition, &mMutex);
- } else {
-#if defined(HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE)
- status = pthread_cond_timeout_np(&mCondition, &mMutex, timeout / 1000000);
-#else
- // This is safe it will just make things less reponsive
- status = pthread_cond_wait(&mCondition, &mMutex);
-#endif
- }
- }
-
- if (!status) {
- mSet = false;
- ret = true;
- } else {
- if (status != ETIMEDOUT) {
- ALOGE("LocklessCommandFifo: error %i waiting for condition.", status);
- }
- }
-
- status = pthread_mutex_unlock(&mMutex);
- if (status) {
- ALOGE("LocklessCommandFifo: error %i unlocking for condition.", status);
- }
-
- return ret;
-}
-
diff --git a/libs/rs/rsSignal.h b/libs/rs/rsSignal.h
deleted file mode 100644
index fc31883..0000000
--- a/libs/rs/rsSignal.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#ifndef ANDROID_RS_SIGNAL_H
-#define ANDROID_RS_SIGNAL_H
-
-
-#include "rsUtils.h"
-
-namespace android {
-namespace renderscript {
-
-class Signal {
-public:
- Signal();
- ~Signal();
-
- bool init();
-
- void set();
-
- // returns true if the signal occured
- // false for timeout
- bool wait(uint64_t timeout = 0);
-
-protected:
- bool mSet;
- pthread_mutex_t mMutex;
- pthread_cond_t mCondition;
-};
-
-}
-}
-
-#endif
-
diff --git a/libs/rs/rsStream.cpp b/libs/rs/rsStream.cpp
deleted file mode 100644
index b9df0cc..0000000
--- a/libs/rs/rsStream.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-
-/*
- * Copyright (C) 2009 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.
- */
-
-#include "rsContext.h"
-#include "rsStream.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-IStream::IStream(const uint8_t *buf, bool use64) {
- mData = buf;
- mPos = 0;
- mUse64 = use64;
-}
-
-void IStream::loadByteArray(void *dest, size_t numBytes) {
- memcpy(dest, mData + mPos, numBytes);
- mPos += numBytes;
-}
-
-uint64_t IStream::loadOffset() {
- uint64_t tmp;
- if (mUse64) {
- mPos = (mPos + 7) & (~7);
- tmp = reinterpret_cast<const uint64_t *>(&mData[mPos])[0];
- mPos += sizeof(uint64_t);
- return tmp;
- }
- return loadU32();
-}
-
-void IStream::loadString(String8 *s) {
- uint32_t len = loadU32();
- s->setTo((const char *)&mData[mPos], len);
- mPos += len;
-}
-
-// Output stream implementation
-OStream::OStream(uint64_t len, bool use64) {
- mData = (uint8_t*)malloc(len);
- mLength = len;
- mPos = 0;
- mUse64 = use64;
-}
-
-OStream::~OStream() {
- free(mData);
-}
-
-void OStream::addByteArray(const void *src, size_t numBytes) {
- // We need to potentially grow more than once if the number of byes we write is substantial
- while (mPos + numBytes >= mLength) {
- growSize();
- }
- memcpy(mData + mPos, src, numBytes);
- mPos += numBytes;
-}
-
-void OStream::addOffset(uint64_t v) {
- if (mUse64) {
- mPos = (mPos + 7) & (~7);
- if (mPos + sizeof(v) >= mLength) {
- growSize();
- }
- mData[mPos++] = (uint8_t)(v & 0xff);
- mData[mPos++] = (uint8_t)((v >> 8) & 0xff);
- mData[mPos++] = (uint8_t)((v >> 16) & 0xff);
- mData[mPos++] = (uint8_t)((v >> 24) & 0xff);
- mData[mPos++] = (uint8_t)((v >> 32) & 0xff);
- mData[mPos++] = (uint8_t)((v >> 40) & 0xff);
- mData[mPos++] = (uint8_t)((v >> 48) & 0xff);
- mData[mPos++] = (uint8_t)((v >> 56) & 0xff);
- } else {
- addU32(v);
- }
-}
-
-void OStream::addString(String8 *s) {
- uint32_t len = s->size();
- addU32(len);
- if (mPos + len*sizeof(char) >= mLength) {
- growSize();
- }
- char *stringData = reinterpret_cast<char *>(&mData[mPos]);
- for (uint32_t i = 0; i < len; i ++) {
- stringData[i] = s->string()[i];
- }
- mPos += len*sizeof(char);
-}
-
-void OStream::growSize() {
- uint8_t *newData = (uint8_t*)malloc(mLength*2);
- memcpy(newData, mData, mLength*sizeof(uint8_t));
- mLength = mLength * 2;
- free(mData);
- mData = newData;
-}
-
-
diff --git a/libs/rs/rsStream.h b/libs/rs/rsStream.h
deleted file mode 100644
index 62bcf94..0000000
--- a/libs/rs/rsStream.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#ifndef ANDROID_RS_STREAM_H
-#define ANDROID_RS_STREAM_H
-
-#include <utils/String8.h>
-#include <stdio.h>
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-class IStream {
-public:
- IStream(const uint8_t *, bool use64);
-
- float loadF() {
- mPos = (mPos + 3) & (~3);
- float tmp = reinterpret_cast<const float *>(&mData[mPos])[0];
- mPos += sizeof(float);
- return tmp;
- }
- int32_t loadI32() {
- mPos = (mPos + 3) & (~3);
- int32_t tmp = reinterpret_cast<const int32_t *>(&mData[mPos])[0];
- mPos += sizeof(int32_t);
- return tmp;
- }
- uint32_t loadU32() {
- mPos = (mPos + 3) & (~3);
- uint32_t tmp = reinterpret_cast<const uint32_t *>(&mData[mPos])[0];
- mPos += sizeof(uint32_t);
- return tmp;
- }
- uint16_t loadU16() {
- mPos = (mPos + 1) & (~1);
- uint16_t tmp = reinterpret_cast<const uint16_t *>(&mData[mPos])[0];
- mPos += sizeof(uint16_t);
- return tmp;
- }
- inline uint8_t loadU8() {
- uint8_t tmp = reinterpret_cast<const uint8_t *>(&mData[mPos])[0];
- mPos += sizeof(uint8_t);
- return tmp;
- }
- void loadByteArray(void *dest, size_t numBytes);
- uint64_t loadOffset();
- void loadString(String8 *s);
- uint64_t getPos() const {
- return mPos;
- }
- void reset(uint64_t pos) {
- mPos = pos;
- }
- void reset() {
- mPos = 0;
- }
-
- const uint8_t * getPtr() const {
- return mData;
- }
-protected:
- const uint8_t * mData;
- uint64_t mPos;
- bool mUse64;
-};
-
-class OStream {
-public:
- OStream(uint64_t length, bool use64);
- ~OStream();
-
- void align(uint32_t bytes) {
- mPos = (mPos + (bytes - 1)) & (~(bytes - 1));
- if (mPos >= mLength) {
- growSize();
- }
- }
-
- void addF(float v) {
- uint32_t uintV = *reinterpret_cast<uint32_t*> (&v);
- addU32(uintV);
- }
- void addI32(int32_t v) {
- mPos = (mPos + 3) & (~3);
- if (mPos + sizeof(v) >= mLength) {
- growSize();
- }
- mData[mPos++] = (uint8_t)(v & 0xff);
- mData[mPos++] = (uint8_t)((v >> 8) & 0xff);
- mData[mPos++] = (uint8_t)((v >> 16) & 0xff);
- mData[mPos++] = (uint8_t)((v >> 24) & 0xff);
- }
- void addU32(uint32_t v) {
- mPos = (mPos + 3) & (~3);
- if (mPos + sizeof(v) >= mLength) {
- growSize();
- }
- mData[mPos++] = (uint8_t)(v & 0xff);
- mData[mPos++] = (uint8_t)((v >> 8) & 0xff);
- mData[mPos++] = (uint8_t)((v >> 16) & 0xff);
- mData[mPos++] = (uint8_t)((v >> 24) & 0xff);
- }
- void addU16(uint16_t v) {
- mPos = (mPos + 1) & (~1);
- if (mPos + sizeof(v) >= mLength) {
- growSize();
- }
- mData[mPos++] = (uint8_t)(v & 0xff);
- mData[mPos++] = (uint8_t)(v >> 8);
- }
- inline void addU8(uint8_t v) {
- if (mPos + 1 >= mLength) {
- growSize();
- }
- reinterpret_cast<uint8_t *>(&mData[mPos])[0] = v;
- mPos ++;
- }
- void addByteArray(const void *src, size_t numBytes);
- void addOffset(uint64_t v);
- void addString(String8 *s);
- uint64_t getPos() const {
- return mPos;
- }
- void reset(uint64_t pos) {
- mPos = pos;
- }
- void reset() {
- mPos = 0;
- }
- const uint8_t * getPtr() const {
- return mData;
- }
-protected:
- void growSize();
- uint8_t * mData;
- uint64_t mLength;
- uint64_t mPos;
- bool mUse64;
-};
-
-
-} // renderscript
-} // android
-#endif //ANDROID_RS_STREAM_H
-
-
diff --git a/libs/rs/rsThreadIO.cpp b/libs/rs/rsThreadIO.cpp
deleted file mode 100644
index 8a0a5dc..0000000
--- a/libs/rs/rsThreadIO.cpp
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#include "rsContext.h"
-#include "rsThreadIO.h"
-#include "rsgApiStructs.h"
-
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include <fcntl.h>
-#include <poll.h>
-
-
-using namespace android;
-using namespace android::renderscript;
-
-ThreadIO::ThreadIO() {
- mRunning = true;
- mPureFifo = false;
- mMaxInlineSize = 1024;
-}
-
-ThreadIO::~ThreadIO() {
-}
-
-void ThreadIO::init() {
- mToClient.init();
- mToCore.init();
-}
-
-void ThreadIO::shutdown() {
- mRunning = false;
- mToCore.shutdown();
-}
-
-void * ThreadIO::coreHeader(uint32_t cmdID, size_t dataLen) {
- //ALOGE("coreHeader %i %i", cmdID, dataLen);
- CoreCmdHeader *hdr = (CoreCmdHeader *)&mSendBuffer[0];
- hdr->bytes = dataLen;
- hdr->cmdID = cmdID;
- mSendLen = dataLen + sizeof(CoreCmdHeader);
- //mToCoreSocket.writeAsync(&hdr, sizeof(hdr));
- //ALOGE("coreHeader ret ");
- return &mSendBuffer[sizeof(CoreCmdHeader)];
-}
-
-void ThreadIO::coreCommit() {
- mToCore.writeAsync(&mSendBuffer, mSendLen);
-}
-
-void ThreadIO::clientShutdown() {
- mToClient.shutdown();
-}
-
-void ThreadIO::coreWrite(const void *data, size_t len) {
- //ALOGV("core write %p %i", data, (int)len);
- mToCore.writeAsync(data, len, true);
-}
-
-void ThreadIO::coreRead(void *data, size_t len) {
- //ALOGV("core read %p %i", data, (int)len);
- mToCore.read(data, len);
-}
-
-void ThreadIO::coreSetReturn(const void *data, size_t dataLen) {
- uint32_t buf;
- if (data == NULL) {
- data = &buf;
- dataLen = sizeof(buf);
- }
-
- mToCore.readReturn(data, dataLen);
-}
-
-void ThreadIO::coreGetReturn(void *data, size_t dataLen) {
- uint32_t buf;
- if (data == NULL) {
- data = &buf;
- dataLen = sizeof(buf);
- }
-
- mToCore.writeWaitReturn(data, dataLen);
-}
-
-void ThreadIO::setTimeoutCallback(void (*cb)(void *), void *dat, uint64_t timeout) {
- //mToCore.setTimeoutCallback(cb, dat, timeout);
-}
-
-bool ThreadIO::playCoreCommands(Context *con, int waitFd) {
- bool ret = false;
- const bool isLocal = !isPureFifo();
-
- uint8_t buf[2 * 1024];
- const CoreCmdHeader *cmd = (const CoreCmdHeader *)&buf[0];
- const void * data = (const void *)&buf[sizeof(CoreCmdHeader)];
-
- struct pollfd p[2];
- p[0].fd = mToCore.getReadFd();
- p[0].events = POLLIN;
- p[0].revents = 0;
- p[1].fd = waitFd;
- p[1].events = POLLIN;
- p[1].revents = 0;
- int pollCount = 1;
- if (waitFd >= 0) {
- pollCount = 2;
- }
-
- if (con->props.mLogTimes) {
- con->timerSet(Context::RS_TIMER_IDLE);
- }
-
- int waitTime = -1;
- while (mRunning) {
- int pr = poll(p, pollCount, waitTime);
- if (pr <= 0) {
- break;
- }
-
- if (p[0].revents) {
- size_t r = 0;
- if (isLocal) {
- r = mToCore.read(&buf[0], sizeof(CoreCmdHeader));
- mToCore.read(&buf[sizeof(CoreCmdHeader)], cmd->bytes);
- if (r != sizeof(CoreCmdHeader)) {
- // exception or timeout occurred.
- break;
- }
- } else {
- r = mToCore.read((void *)&cmd->cmdID, sizeof(cmd->cmdID));
- }
-
-
- ret = true;
- if (con->props.mLogTimes) {
- con->timerSet(Context::RS_TIMER_INTERNAL);
- }
- //ALOGV("playCoreCommands 3 %i %i", cmd->cmdID, cmd->bytes);
-
- if (cmd->cmdID >= (sizeof(gPlaybackFuncs) / sizeof(void *))) {
- rsAssert(cmd->cmdID < (sizeof(gPlaybackFuncs) / sizeof(void *)));
- ALOGE("playCoreCommands error con %p, cmd %i", con, cmd->cmdID);
- }
-
- if (isLocal) {
- gPlaybackFuncs[cmd->cmdID](con, data, cmd->bytes);
- } else {
- gPlaybackRemoteFuncs[cmd->cmdID](con, this);
- }
-
- if (con->props.mLogTimes) {
- con->timerSet(Context::RS_TIMER_IDLE);
- }
-
- if (waitFd < 0) {
- // If we don't have a secondary wait object we should stop blocking now
- // that at least one command has been processed.
- waitTime = 0;
- }
- }
-
- if (p[1].revents && !p[0].revents) {
- // We want to finish processing fifo events before processing the vsync.
- // Otherwise we can end up falling behind and having tremendous lag.
- break;
- }
- }
- return ret;
-}
-
-RsMessageToClientType ThreadIO::getClientHeader(size_t *receiveLen, uint32_t *usrID) {
- //ALOGE("getClientHeader");
- mToClient.read(&mLastClientHeader, sizeof(mLastClientHeader));
-
- receiveLen[0] = mLastClientHeader.bytes;
- usrID[0] = mLastClientHeader.userID;
- //ALOGE("getClientHeader %i %i %i", mLastClientHeader.cmdID, usrID[0], receiveLen[0]);
- return (RsMessageToClientType)mLastClientHeader.cmdID;
-}
-
-RsMessageToClientType ThreadIO::getClientPayload(void *data, size_t *receiveLen,
- uint32_t *usrID, size_t bufferLen) {
- //ALOGE("getClientPayload");
- receiveLen[0] = mLastClientHeader.bytes;
- usrID[0] = mLastClientHeader.userID;
- if (bufferLen < mLastClientHeader.bytes) {
- return RS_MESSAGE_TO_CLIENT_RESIZE;
- }
- if (receiveLen[0]) {
- mToClient.read(data, receiveLen[0]);
- }
- //ALOGE("getClientPayload x");
- return (RsMessageToClientType)mLastClientHeader.cmdID;
-}
-
-bool ThreadIO::sendToClient(RsMessageToClientType cmdID, uint32_t usrID, const void *data,
- size_t dataLen, bool waitForSpace) {
-
- //ALOGE("sendToClient %i %i %i", cmdID, usrID, (int)dataLen);
- ClientCmdHeader hdr;
- hdr.bytes = dataLen;
- hdr.cmdID = cmdID;
- hdr.userID = usrID;
-
- mToClient.writeAsync(&hdr, sizeof(hdr));
- if (dataLen) {
- mToClient.writeAsync(data, dataLen);
- }
-
- //ALOGE("sendToClient x");
- return true;
-}
-
diff --git a/libs/rs/rsThreadIO.h b/libs/rs/rsThreadIO.h
deleted file mode 100644
index cb7d4ab..0000000
--- a/libs/rs/rsThreadIO.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#ifndef ANDROID_RS_THREAD_IO_H
-#define ANDROID_RS_THREAD_IO_H
-
-#include "rsUtils.h"
-#include "rsFifoSocket.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-
-class Context;
-
-class ThreadIO {
-public:
- ThreadIO();
- ~ThreadIO();
-
- void init();
- void shutdown();
-
- size_t getMaxInlineSize() {
- return mMaxInlineSize;
- }
- bool isPureFifo() {
- return mPureFifo;
- }
-
- // Plays back commands from the client.
- // Returns true if any commands were processed.
- bool playCoreCommands(Context *con, int waitFd);
-
- void setTimeoutCallback(void (*)(void *), void *, uint64_t timeout);
-
- void * coreHeader(uint32_t, size_t dataLen);
- void coreCommit();
-
- void coreSetReturn(const void *data, size_t dataLen);
- void coreGetReturn(void *data, size_t dataLen);
- void coreWrite(const void *data, size_t len);
- void coreRead(void *data, size_t len);
-
- void asyncSetReturn(const void *data, size_t dataLen);
- void asyncGetReturn(void *data, size_t dataLen);
- void asyncWrite(const void *data, size_t len);
- void asyncRead(void *data, size_t len);
-
-
- RsMessageToClientType getClientHeader(size_t *receiveLen, uint32_t *usrID);
- RsMessageToClientType getClientPayload(void *data, size_t *receiveLen, uint32_t *subID, size_t bufferLen);
- bool sendToClient(RsMessageToClientType cmdID, uint32_t usrID, const void *data, size_t dataLen, bool waitForSpace);
- void clientShutdown();
-
-
-protected:
- typedef struct CoreCmdHeaderRec {
- uint32_t cmdID;
- uint32_t bytes;
- } CoreCmdHeader;
- typedef struct ClientCmdHeaderRec {
- uint32_t cmdID;
- uint32_t bytes;
- uint32_t userID;
- } ClientCmdHeader;
- ClientCmdHeader mLastClientHeader;
-
- bool mRunning;
- bool mPureFifo;
- size_t mMaxInlineSize;
-
- FifoSocket mToClient;
- FifoSocket mToCore;
-
- intptr_t mToCoreRet;
-
- size_t mSendLen;
- uint8_t mSendBuffer[2 * 1024];
-
-};
-
-
-}
-}
-#endif
-
diff --git a/libs/rs/rsType.cpp b/libs/rs/rsType.cpp
deleted file mode 100644
index b668a78..0000000
--- a/libs/rs/rsType.cpp
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#include "rsContext.h"
-
-using namespace android;
-using namespace android::renderscript;
-
-Type::Type(Context *rsc) : ObjectBase(rsc) {
- memset(&mHal, 0, sizeof(mHal));
- mDimLOD = false;
-}
-
-void Type::preDestroy() const {
- for (uint32_t ct = 0; ct < mRSC->mStateType.mTypes.size(); ct++) {
- if (mRSC->mStateType.mTypes[ct] == this) {
- mRSC->mStateType.mTypes.removeAt(ct);
- break;
- }
- }
-}
-
-Type::~Type() {
- clear();
-}
-
-void Type::clear() {
- if (mHal.state.lodCount) {
- delete [] mHal.state.lodDimX;
- delete [] mHal.state.lodDimY;
- delete [] mHal.state.lodDimZ;
- delete [] mHal.state.lodOffset;
- }
- mElement.clear();
- memset(&mHal, 0, sizeof(mHal));
-}
-
-TypeState::TypeState() {
-}
-
-TypeState::~TypeState() {
- rsAssert(!mTypes.size());
-}
-
-size_t Type::getOffsetForFace(uint32_t face) const {
- rsAssert(mHal.state.faces);
- return 0;
-}
-
-void Type::compute() {
- uint32_t oldLODCount = mHal.state.lodCount;
- if (mDimLOD) {
- uint32_t l2x = rsFindHighBit(mHal.state.dimX) + 1;
- uint32_t l2y = rsFindHighBit(mHal.state.dimY) + 1;
- uint32_t l2z = rsFindHighBit(mHal.state.dimZ) + 1;
-
- mHal.state.lodCount = rsMax(l2x, l2y);
- mHal.state.lodCount = rsMax(mHal.state.lodCount, l2z);
- } else {
- mHal.state.lodCount = 1;
- }
- if (mHal.state.lodCount != oldLODCount) {
- if (oldLODCount) {
- delete [] mHal.state.lodDimX;
- delete [] mHal.state.lodDimY;
- delete [] mHal.state.lodDimZ;
- delete [] mHal.state.lodOffset;
- }
- mHal.state.lodDimX = new uint32_t[mHal.state.lodCount];
- mHal.state.lodDimY = new uint32_t[mHal.state.lodCount];
- mHal.state.lodDimZ = new uint32_t[mHal.state.lodCount];
- mHal.state.lodOffset = new uint32_t[mHal.state.lodCount];
- }
-
- uint32_t tx = mHal.state.dimX;
- uint32_t ty = mHal.state.dimY;
- uint32_t tz = mHal.state.dimZ;
- size_t offset = 0;
- for (uint32_t lod=0; lod < mHal.state.lodCount; lod++) {
- mHal.state.lodDimX[lod] = tx;
- mHal.state.lodDimY[lod] = ty;
- mHal.state.lodDimZ[lod] = tz;
- mHal.state.lodOffset[lod] = offset;
- offset += tx * rsMax(ty, 1u) * rsMax(tz, 1u) * mElement->getSizeBytes();
- if (tx > 1) tx >>= 1;
- if (ty > 1) ty >>= 1;
- if (tz > 1) tz >>= 1;
- }
-
- // At this point the offset is the size of a mipmap chain;
- mMipChainSizeBytes = offset;
-
- if (mHal.state.faces) {
- offset *= 6;
- }
- mTotalSizeBytes = offset;
- mHal.state.element = mElement.get();
-}
-
-uint32_t Type::getLODOffset(uint32_t lod, uint32_t x) const {
- uint32_t offset = mHal.state.lodOffset[lod];
- offset += x * mElement->getSizeBytes();
- return offset;
-}
-
-uint32_t Type::getLODOffset(uint32_t lod, uint32_t x, uint32_t y) const {
- uint32_t offset = mHal.state.lodOffset[lod];
- offset += (x + y * mHal.state.lodDimX[lod]) * mElement->getSizeBytes();
- return offset;
-}
-
-uint32_t Type::getLODOffset(uint32_t lod, uint32_t x, uint32_t y, uint32_t z) const {
- uint32_t offset = mHal.state.lodOffset[lod];
- offset += (x +
- y * mHal.state.lodDimX[lod] +
- z * mHal.state.lodDimX[lod] * mHal.state.lodDimY[lod]) * mElement->getSizeBytes();
- return offset;
-}
-
-uint32_t Type::getLODFaceOffset(uint32_t lod, RsAllocationCubemapFace face,
- uint32_t x, uint32_t y) const {
- uint32_t offset = mHal.state.lodOffset[lod];
- offset += (x + y * mHal.state.lodDimX[lod]) * mElement->getSizeBytes();
-
- if (face != 0) {
- uint32_t faceOffset = getSizeBytes() / 6;
- offset += faceOffset * face;
- }
- return offset;
-}
-
-void Type::dumpLOGV(const char *prefix) const {
- char buf[1024];
- ObjectBase::dumpLOGV(prefix);
- ALOGV("%s Type: x=%u y=%u z=%u mip=%i face=%i", prefix,
- mHal.state.dimX,
- mHal.state.dimY,
- mHal.state.dimZ,
- mHal.state.lodCount,
- mHal.state.faces);
- snprintf(buf, sizeof(buf), "%s element: ", prefix);
- mElement->dumpLOGV(buf);
-}
-
-void Type::serialize(OStream *stream) const {
- // Need to identify ourselves
- stream->addU32((uint32_t)getClassId());
-
- String8 name(getName());
- stream->addString(&name);
-
- mElement->serialize(stream);
-
- stream->addU32(mHal.state.dimX);
- stream->addU32(mHal.state.dimY);
- stream->addU32(mHal.state.dimZ);
-
- stream->addU8((uint8_t)(mHal.state.lodCount ? 1 : 0));
- stream->addU8((uint8_t)(mHal.state.faces ? 1 : 0));
-}
-
-Type *Type::createFromStream(Context *rsc, IStream *stream) {
- // First make sure we are reading the correct object
- RsA3DClassID classID = (RsA3DClassID)stream->loadU32();
- if (classID != RS_A3D_CLASS_ID_TYPE) {
- ALOGE("type loading skipped due to invalid class id\n");
- return NULL;
- }
-
- String8 name;
- stream->loadString(&name);
-
- Element *elem = Element::createFromStream(rsc, stream);
- if (!elem) {
- return NULL;
- }
-
- uint32_t x = stream->loadU32();
- uint32_t y = stream->loadU32();
- uint32_t z = stream->loadU32();
- uint8_t lod = stream->loadU8();
- uint8_t faces = stream->loadU8();
- Type *type = Type::getType(rsc, elem, x, y, z, lod != 0, faces !=0 );
- elem->decUserRef();
- return type;
-}
-
-bool Type::getIsNp2() const {
- uint32_t x = getDimX();
- uint32_t y = getDimY();
- uint32_t z = getDimZ();
-
- if (x && (x & (x-1))) {
- return true;
- }
- if (y && (y & (y-1))) {
- return true;
- }
- if (z && (z & (z-1))) {
- return true;
- }
- return false;
-}
-
-ObjectBaseRef<Type> Type::getTypeRef(Context *rsc, const Element *e,
- uint32_t dimX, uint32_t dimY, uint32_t dimZ,
- bool dimLOD, bool dimFaces) {
- ObjectBaseRef<Type> returnRef;
-
- TypeState * stc = &rsc->mStateType;
-
- ObjectBase::asyncLock();
- for (uint32_t ct=0; ct < stc->mTypes.size(); ct++) {
- Type *t = stc->mTypes[ct];
- if (t->getElement() != e) continue;
- if (t->getDimX() != dimX) continue;
- if (t->getDimY() != dimY) continue;
- if (t->getDimZ() != dimZ) continue;
- if (t->getDimLOD() != dimLOD) continue;
- if (t->getDimFaces() != dimFaces) continue;
- returnRef.set(t);
- ObjectBase::asyncUnlock();
- return returnRef;
- }
- ObjectBase::asyncUnlock();
-
-
- Type *nt = new Type(rsc);
- nt->mDimLOD = dimLOD;
- returnRef.set(nt);
- nt->mElement.set(e);
- nt->mHal.state.dimX = dimX;
- nt->mHal.state.dimY = dimY;
- nt->mHal.state.dimZ = dimZ;
- nt->mHal.state.faces = dimFaces;
- nt->compute();
-
- ObjectBase::asyncLock();
- stc->mTypes.push(nt);
- ObjectBase::asyncUnlock();
-
- return returnRef;
-}
-
-ObjectBaseRef<Type> Type::cloneAndResize1D(Context *rsc, uint32_t dimX) const {
- return getTypeRef(rsc, mElement.get(), dimX,
- getDimY(), getDimZ(), getDimLOD(), getDimFaces());
-}
-
-ObjectBaseRef<Type> Type::cloneAndResize2D(Context *rsc,
- uint32_t dimX,
- uint32_t dimY) const {
- return getTypeRef(rsc, mElement.get(), dimX, dimY,
- getDimZ(), getDimLOD(), getDimFaces());
-}
-
-
-//////////////////////////////////////////////////
-//
-namespace android {
-namespace renderscript {
-
-RsType rsi_TypeCreate(Context *rsc, RsElement _e, uint32_t dimX,
- uint32_t dimY, uint32_t dimZ, bool mips, bool faces) {
- Element *e = static_cast<Element *>(_e);
-
- return Type::getType(rsc, e, dimX, dimY, dimZ, mips, faces);
-}
-
-}
-}
-
-void rsaTypeGetNativeData(RsContext con, RsType type, uint32_t *typeData, uint32_t typeDataSize) {
- rsAssert(typeDataSize == 6);
- // Pack the data in the follofing way mHal.state.dimX; mHal.state.dimY; mHal.state.dimZ;
- // mHal.state.lodCount; mHal.state.faces; mElement; into typeData
- Type *t = static_cast<Type *>(type);
-
- (*typeData++) = t->getDimX();
- (*typeData++) = t->getDimY();
- (*typeData++) = t->getDimZ();
- (*typeData++) = t->getDimLOD() ? 1 : 0;
- (*typeData++) = t->getDimFaces() ? 1 : 0;
- (*typeData++) = (uint32_t)t->getElement();
- t->getElement()->incUserRef();
-}
diff --git a/libs/rs/rsType.h b/libs/rs/rsType.h
deleted file mode 100644
index f1aeb0a..0000000
--- a/libs/rs/rsType.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef ANDROID_STRUCTURED_TYPE_H
-#define ANDROID_STRUCTURED_TYPE_H
-
-#include "rsElement.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-namespace renderscript {
-/*****************************************************************************
- * CAUTION
- *
- * Any layout changes for this class may require a corresponding change to be
- * made to frameworks/compile/libbcc/lib/ScriptCRT/rs_core.c, which contains
- * a partial copy of the information below.
- *
- *****************************************************************************/
-
-class Type : public ObjectBase {
-public:
- struct Hal {
- mutable void *drv;
-
- struct State {
- const Element * element;
-
- // Size of the structure in the various dimensions. A missing Dimension is
- // specified as a 0 and not a 1.
- uint32_t dimX;
- uint32_t dimY;
- uint32_t dimZ;
- uint32_t *lodDimX;
- uint32_t *lodDimY;
- uint32_t *lodDimZ;
- uint32_t *lodOffset;
- uint32_t lodCount;
- bool faces;
- };
- State state;
- };
- Hal mHal;
-
- Type * createTex2D(const Element *, size_t w, size_t h, bool mip);
-
- size_t getOffsetForFace(uint32_t face) const;
-
- size_t getSizeBytes() const {return mTotalSizeBytes;}
- size_t getElementSizeBytes() const {return mElement->getSizeBytes();}
- const Element * getElement() const {return mElement.get();}
-
- uint32_t getDimX() const {return mHal.state.dimX;}
- uint32_t getDimY() const {return mHal.state.dimY;}
- uint32_t getDimZ() const {return mHal.state.dimZ;}
- bool getDimLOD() const {return mDimLOD;}
- bool getDimFaces() const {return mHal.state.faces;}
-
- uint32_t getLODDimX(uint32_t lod) const {
- rsAssert(lod < mHal.state.lodCount);
- return mHal.state.lodDimX[lod];
- }
- uint32_t getLODDimY(uint32_t lod) const {
- rsAssert(lod < mHal.state.lodCount);
- return mHal.state.lodDimY[lod];
- }
- uint32_t getLODDimZ(uint32_t lod) const {
- rsAssert(lod < mHal.state.lodCount);
- return mHal.state.lodDimZ[lod];
- }
- uint32_t getLODOffset(uint32_t lod) const {
- rsAssert(lod < mHal.state.lodCount);
- return mHal.state.lodOffset[lod];
- }
- uint32_t getLODOffset(uint32_t lod, uint32_t x) const;
- uint32_t getLODOffset(uint32_t lod, uint32_t x, uint32_t y) const;
- uint32_t getLODOffset(uint32_t lod, uint32_t x, uint32_t y, uint32_t z) const;
-
- uint32_t getLODFaceOffset(uint32_t lod, RsAllocationCubemapFace face,
- uint32_t x, uint32_t y) const;
-
- uint32_t getLODCount() const {return mHal.state.lodCount;}
- bool getIsNp2() const;
-
- void clear();
- void compute();
-
- void dumpLOGV(const char *prefix) const;
- virtual void serialize(OStream *stream) const;
- virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_TYPE; }
- static Type *createFromStream(Context *rsc, IStream *stream);
-
- ObjectBaseRef<Type> cloneAndResize1D(Context *rsc, uint32_t dimX) const;
- ObjectBaseRef<Type> cloneAndResize2D(Context *rsc, uint32_t dimX, uint32_t dimY) const;
-
- static ObjectBaseRef<Type> getTypeRef(Context *rsc, const Element *e,
- uint32_t dimX, uint32_t dimY, uint32_t dimZ,
- bool dimLOD, bool dimFaces);
-
- static Type* getType(Context *rsc, const Element *e,
- uint32_t dimX, uint32_t dimY, uint32_t dimZ,
- bool dimLOD, bool dimFaces) {
- ObjectBaseRef<Type> type = getTypeRef(rsc, e, dimX, dimY, dimZ, dimLOD, dimFaces);
- type->incUserRef();
- return type.get();
- }
-
-protected:
- void makeLODTable();
- bool mDimLOD;
-
- // Internal structure from most to least significant.
- // * Array dimensions
- // * Faces
- // * Mipmaps
- // * xyz
-
- ObjectBaseRef<const Element> mElement;
-
- // count of mipmap levels, 0 indicates no mipmapping
-
- size_t mMipChainSizeBytes;
- size_t mTotalSizeBytes;
-protected:
- virtual void preDestroy() const;
- virtual ~Type();
-
-private:
- Type(Context *);
- Type(const Type &);
-};
-
-
-class TypeState {
-public:
- TypeState();
- ~TypeState();
-
- // Cache of all existing types.
- Vector<Type *> mTypes;
-};
-
-
-}
-}
-#endif //ANDROID_STRUCTURED_TYPE
diff --git a/libs/rs/rsUtils.h b/libs/rs/rsUtils.h
deleted file mode 100644
index cbbae6c..0000000
--- a/libs/rs/rsUtils.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#ifndef ANDROID_RS_UTILS_H
-#define ANDROID_RS_UTILS_H
-
-#define LOG_NDEBUG 0
-#define LOG_TAG "RenderScript"
-
-#include <utils/Log.h>
-
-#include "rsStream.h"
-
-#include <utils/String8.h>
-#include <utils/Vector.h>
-
-#include <stdlib.h>
-#include <pthread.h>
-#include <time.h>
-#include <cutils/atomic.h>
-
-#include <math.h>
-
-namespace android {
-namespace renderscript {
-
-#if 1
-#define rsAssert(v) do {if(!(v)) ALOGE("rsAssert failed: %s, in %s at %i", #v, __FILE__, __LINE__);} while (0)
-#else
-#define rsAssert(v) while (0)
-#endif
-
-typedef float rsvF_2 __attribute__ ((vector_size (8)));
-typedef float rsvF_4 __attribute__ ((vector_size (16)));
-typedef uint8_t rsvU8_4 __attribute__ ((vector_size (4)));
-
-union float2 {
- rsvF_2 v;
- float f[2];
-};
-
-union float4 {
- rsvF_4 v;
- float f[4];
-};
-
-union uchar4 {
- rsvU8_4 v;
- uint8_t f[4];
- uint32_t packed;
-};
-
-template<typename T>
-T rsMin(T in1, T in2)
-{
- if (in1 > in2) {
- return in2;
- }
- return in1;
-}
-
-template<typename T>
-T rsMax(T in1, T in2) {
- if (in1 < in2) {
- return in2;
- }
- return in1;
-}
-
-template<typename T>
-T rsFindHighBit(T val) {
- uint32_t bit = 0;
- while (val > 1) {
- bit++;
- val>>=1;
- }
- return bit;
-}
-
-template<typename T>
-bool rsIsPow2(T val) {
- return (val & (val-1)) == 0;
-}
-
-template<typename T>
-T rsHigherPow2(T v) {
- if (rsIsPow2(v)) {
- return v;
- }
- return 1 << (rsFindHighBit(v) + 1);
-}
-
-template<typename T>
-T rsLowerPow2(T v) {
- if (rsIsPow2(v)) {
- return v;
- }
- return 1 << rsFindHighBit(v);
-}
-
-static inline uint16_t rs888to565(uint32_t r, uint32_t g, uint32_t b) {
- uint16_t t = 0;
- t |= b >> 3;
- t |= (g >> 2) << 5;
- t |= (r >> 3) << 11;
- return t;
-}
-
-static inline uint16_t rsBoxFilter565(uint16_t i1, uint16_t i2, uint16_t i3, uint16_t i4) {
- uint32_t r = ((i1 & 0x1f) + (i2 & 0x1f) + (i3 & 0x1f) + (i4 & 0x1f));
- uint32_t g = ((i1 >> 5) & 0x3f) + ((i2 >> 5) & 0x3f) + ((i3 >> 5) & 0x3f) + ((i4 >> 5) & 0x3f);
- uint32_t b = ((i1 >> 11) + (i2 >> 11) + (i3 >> 11) + (i4 >> 11));
- return (r >> 2) | ((g >> 2) << 5) | ((b >> 2) << 11);
-}
-
-static inline uint32_t rsBoxFilter8888(uint32_t i1, uint32_t i2, uint32_t i3, uint32_t i4) {
- uint32_t r = (i1 & 0xff) + (i2 & 0xff) + (i3 & 0xff) + (i4 & 0xff);
- uint32_t g = ((i1 >> 8) & 0xff) + ((i2 >> 8) & 0xff) + ((i3 >> 8) & 0xff) + ((i4 >> 8) & 0xff);
- uint32_t b = ((i1 >> 16) & 0xff) + ((i2 >> 16) & 0xff) + ((i3 >> 16) & 0xff) + ((i4 >> 16) & 0xff);
- uint32_t a = ((i1 >> 24) & 0xff) + ((i2 >> 24) & 0xff) + ((i3 >> 24) & 0xff) + ((i4 >> 24) & 0xff);
- return (r >> 2) | ((g >> 2) << 8) | ((b >> 2) << 16) | ((a >> 2) << 24);
-}
-
-}
-}
-
-#endif //ANDROID_RS_OBJECT_BASE_H
-
-
diff --git a/libs/rs/rs_hal.h b/libs/rs/rs_hal.h
deleted file mode 100644
index e4bf17f..0000000
--- a/libs/rs/rs_hal.h
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef RS_HAL_H
-#define RS_HAL_H
-
-#include <rsDefines.h>
-
-struct ANativeWindow;
-
-namespace android {
-namespace renderscript {
-
-class Context;
-class ObjectBase;
-class Element;
-class Type;
-class Allocation;
-class Script;
-class ScriptC;
-class Path;
-class Program;
-class ProgramStore;
-class ProgramRaster;
-class ProgramVertex;
-class ProgramFragment;
-class Mesh;
-class Sampler;
-class FBOCache;
-
-typedef void *(*RsHalSymbolLookupFunc)(void *usrptr, char const *symbolName);
-
-typedef struct {
- const void *in;
- void *out;
- const void *usr;
- size_t usr_len;
- uint32_t x;
- uint32_t y;
- uint32_t z;
- uint32_t lod;
- RsAllocationCubemapFace face;
- uint32_t ar[16];
-} RsForEachStubParamStruct;
-
-/**
- * Script management functions
- */
-typedef struct {
- bool (*initGraphics)(const Context *);
- void (*shutdownGraphics)(const Context *);
- bool (*setSurface)(const Context *, uint32_t w, uint32_t h, RsNativeWindow);
- void (*swap)(const Context *);
-
- void (*shutdownDriver)(Context *);
- void (*getVersion)(unsigned int *major, unsigned int *minor);
- void (*setPriority)(const Context *, int32_t priority);
-
-
-
- struct {
- bool (*init)(const Context *rsc, ScriptC *s,
- char const *resName,
- char const *cacheDir,
- uint8_t const *bitcode,
- size_t bitcodeSize,
- uint32_t flags);
-
- void (*invokeFunction)(const Context *rsc, Script *s,
- uint32_t slot,
- const void *params,
- size_t paramLength);
- int (*invokeRoot)(const Context *rsc, Script *s);
- void (*invokeForEach)(const Context *rsc,
- Script *s,
- uint32_t slot,
- const Allocation * ain,
- Allocation * aout,
- const void * usr,
- uint32_t usrLen,
- const RsScriptCall *sc);
- void (*invokeInit)(const Context *rsc, Script *s);
- void (*invokeFreeChildren)(const Context *rsc, Script *s);
-
- void (*setGlobalVar)(const Context *rsc, const Script *s,
- uint32_t slot,
- void *data,
- size_t dataLength);
- void (*setGlobalBind)(const Context *rsc, const Script *s,
- uint32_t slot,
- void *data);
- void (*setGlobalObj)(const Context *rsc, const Script *s,
- uint32_t slot,
- ObjectBase *data);
-
- void (*destroy)(const Context *rsc, Script *s);
- } script;
-
- struct {
- bool (*init)(const Context *rsc, Allocation *alloc, bool forceZero);
- void (*destroy)(const Context *rsc, Allocation *alloc);
-
- void (*resize)(const Context *rsc, const Allocation *alloc, const Type *newType,
- bool zeroNew);
- void (*syncAll)(const Context *rsc, const Allocation *alloc, RsAllocationUsageType src);
- void (*markDirty)(const Context *rsc, const Allocation *alloc);
-
- int32_t (*initSurfaceTexture)(const Context *rsc, const Allocation *alloc);
- void (*setSurfaceTexture)(const Context *rsc, Allocation *alloc, ANativeWindow *sur);
- void (*ioSend)(const Context *rsc, Allocation *alloc);
- void (*ioReceive)(const Context *rsc, Allocation *alloc);
-
- void (*data1D)(const Context *rsc, const Allocation *alloc,
- uint32_t xoff, uint32_t lod, uint32_t count,
- const void *data, size_t sizeBytes);
- void (*data2D)(const Context *rsc, const Allocation *alloc,
- uint32_t xoff, uint32_t yoff, uint32_t lod,
- RsAllocationCubemapFace face, uint32_t w, uint32_t h,
- const void *data, size_t sizeBytes);
- void (*data3D)(const Context *rsc, const Allocation *alloc,
- uint32_t xoff, uint32_t yoff, uint32_t zoff,
- uint32_t lod, RsAllocationCubemapFace face,
- uint32_t w, uint32_t h, uint32_t d, const void *data, size_t sizeBytes);
-
- // Allocation to allocation copies
- void (*allocData1D)(const Context *rsc,
- const Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstLod, uint32_t count,
- const Allocation *srcAlloc, uint32_t srcXoff, uint32_t srcLod);
- void (*allocData2D)(const Context *rsc,
- const Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod,
- RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h,
- const Allocation *srcAlloc,
- uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod,
- RsAllocationCubemapFace srcFace);
- void (*allocData3D)(const Context *rsc,
- const Allocation *dstAlloc,
- uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff,
- uint32_t dstLod, RsAllocationCubemapFace dstFace,
- uint32_t w, uint32_t h, uint32_t d,
- const Allocation *srcAlloc,
- uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff,
- uint32_t srcLod, RsAllocationCubemapFace srcFace);
-
- void (*elementData1D)(const Context *rsc, const Allocation *alloc, uint32_t x,
- const void *data, uint32_t elementOff, size_t sizeBytes);
- void (*elementData2D)(const Context *rsc, const Allocation *alloc, uint32_t x, uint32_t y,
- const void *data, uint32_t elementOff, size_t sizeBytes);
-
-
- } allocation;
-
- struct {
- bool (*init)(const Context *rsc, const ProgramStore *ps);
- void (*setActive)(const Context *rsc, const ProgramStore *ps);
- void (*destroy)(const Context *rsc, const ProgramStore *ps);
- } store;
-
- struct {
- bool (*init)(const Context *rsc, const ProgramRaster *ps);
- void (*setActive)(const Context *rsc, const ProgramRaster *ps);
- void (*destroy)(const Context *rsc, const ProgramRaster *ps);
- } raster;
-
- struct {
- bool (*init)(const Context *rsc, const ProgramVertex *pv,
- const char* shader, size_t shaderLen,
- const char** textureNames, size_t textureNamesCount,
- const size_t *textureNamesLength);
- void (*setActive)(const Context *rsc, const ProgramVertex *pv);
- void (*destroy)(const Context *rsc, const ProgramVertex *pv);
- } vertex;
-
- struct {
- bool (*init)(const Context *rsc, const ProgramFragment *pf,
- const char* shader, size_t shaderLen,
- const char** textureNames, size_t textureNamesCount,
- const size_t *textureNamesLength);
- void (*setActive)(const Context *rsc, const ProgramFragment *pf);
- void (*destroy)(const Context *rsc, const ProgramFragment *pf);
- } fragment;
-
- struct {
- bool (*init)(const Context *rsc, const Mesh *m);
- void (*draw)(const Context *rsc, const Mesh *m, uint32_t primIndex, uint32_t start, uint32_t len);
- void (*destroy)(const Context *rsc, const Mesh *m);
- } mesh;
-
- struct {
- bool (*initStatic)(const Context *rsc, const Path *m, const Allocation *vtx, const Allocation *loops);
- bool (*initDynamic)(const Context *rsc, const Path *m);
- void (*draw)(const Context *rsc, const Path *m);
- void (*destroy)(const Context *rsc, const Path *m);
- } path;
-
- struct {
- bool (*init)(const Context *rsc, const Sampler *m);
- void (*destroy)(const Context *rsc, const Sampler *m);
- } sampler;
-
- struct {
- bool (*init)(const Context *rsc, const FBOCache *fb);
- void (*setActive)(const Context *rsc, const FBOCache *fb);
- void (*destroy)(const Context *rsc, const FBOCache *fb);
- } framebuffer;
-
-} RsdHalFunctions;
-
-
-}
-}
-
-
-bool rsdHalInit(android::renderscript::Context *, uint32_t version_major, uint32_t version_minor);
-
-#endif
-
diff --git a/libs/rs/rsgApi.cpp.rsg b/libs/rs/rsgApi.cpp.rsg
deleted file mode 100644
index 0cfbf08..0000000
--- a/libs/rs/rsgApi.cpp.rsg
+++ /dev/null
@@ -1 +0,0 @@
-2
diff --git a/libs/rs/rsgApiFuncDecl.h.rsg b/libs/rs/rsgApiFuncDecl.h.rsg
deleted file mode 100644
index d00491f..0000000
--- a/libs/rs/rsgApiFuncDecl.h.rsg
+++ /dev/null
@@ -1 +0,0 @@
-1
diff --git a/libs/rs/rsgApiReplay.cpp.rsg b/libs/rs/rsgApiReplay.cpp.rsg
deleted file mode 100644
index 00750ed..0000000
--- a/libs/rs/rsgApiReplay.cpp.rsg
+++ /dev/null
@@ -1 +0,0 @@
-3
diff --git a/libs/rs/rsgApiStructs.h.rsg b/libs/rs/rsgApiStructs.h.rsg
deleted file mode 100644
index 573541a..0000000
--- a/libs/rs/rsgApiStructs.h.rsg
+++ /dev/null
@@ -1 +0,0 @@
-0
diff --git a/libs/rs/rsg_generator.c b/libs/rs/rsg_generator.c
deleted file mode 100644
index c0f82dc..0000000
--- a/libs/rs/rsg_generator.c
+++ /dev/null
@@ -1,684 +0,0 @@
-
-#include "spec.h"
-#include <stdio.h>
-
-void printFileHeader(FILE *f) {
- fprintf(f, "/*\n");
- fprintf(f, " * Copyright (C) 2011 The Android Open Source Project\n");
- fprintf(f, " *\n");
- fprintf(f, " * Licensed under the Apache License, Version 2.0 (the \"License\");\n");
- fprintf(f, " * you may not use this file except in compliance with the License.\n");
- fprintf(f, " * You may obtain a copy of the License at\n");
- fprintf(f, " *\n");
- fprintf(f, " * http://www.apache.org/licenses/LICENSE-2.0\n");
- fprintf(f, " *\n");
- fprintf(f, " * Unless required by applicable law or agreed to in writing, software\n");
- fprintf(f, " * distributed under the License is distributed on an \"AS IS\" BASIS,\n");
- fprintf(f, " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n");
- fprintf(f, " * See the License for the specific language governing permissions and\n");
- fprintf(f, " * limitations under the License.\n");
- fprintf(f, " */\n\n");
-}
-
-void printVarType(FILE *f, const VarType *vt) {
- int ct;
- if (vt->isConst) {
- fprintf(f, "const ");
- }
-
- switch (vt->type) {
- case 0:
- fprintf(f, "void");
- break;
- case 1:
- fprintf(f, "int%i_t", vt->bits);
- break;
- case 2:
- fprintf(f, "uint%i_t", vt->bits);
- break;
- case 3:
- if (vt->bits == 32)
- fprintf(f, "float");
- else
- fprintf(f, "double");
- break;
- case 4:
- fprintf(f, "%s", vt->typeName);
- break;
- }
-
- if (vt->ptrLevel) {
- fprintf(f, " ");
- for (ct=0; ct < vt->ptrLevel; ct++) {
- fprintf(f, "*");
- }
- }
-}
-
-void printVarTypeAndName(FILE *f, const VarType *vt) {
- printVarType(f, vt);
-
- if (vt->name[0]) {
- fprintf(f, " %s", vt->name);
- }
-}
-
-void printArgList(FILE *f, const ApiEntry * api, int assumePrevious) {
- int ct;
- for (ct=0; ct < api->paramCount; ct++) {
- if (ct || assumePrevious) {
- fprintf(f, ", ");
- }
- printVarTypeAndName(f, &api->params[ct]);
- }
-}
-
-void printStructures(FILE *f) {
- int ct;
- int ct2;
-
- for (ct=0; ct < apiCount; ct++) {
- fprintf(f, "typedef struct RS_CMD_%s_rec RS_CMD_%s;\n", apis[ct].name, apis[ct].name);
- }
- fprintf(f, "\n");
-
- for (ct=0; ct < apiCount; ct++) {
- const ApiEntry * api = &apis[ct];
- fprintf(f, "#define RS_CMD_ID_%s %i\n", api->name, ct+1);
- fprintf(f, "struct RS_CMD_%s_rec {\n", api->name);
- //fprintf(f, " RsCommandHeader _hdr;\n");
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- fprintf(f, " ");
- printVarTypeAndName(f, &api->params[ct2]);
- fprintf(f, ";\n");
- }
- fprintf(f, "};\n\n");
- }
-}
-
-void printFuncDecl(FILE *f, const ApiEntry *api, const char *prefix, int addContext, int isFnPtr) {
- printVarTypeAndName(f, &api->ret);
- if (isFnPtr) {
- char t[1024];
- strcpy(t, api->name);
- if (strlen(prefix) == 0) {
- if (t[0] > 'A' && t[0] < 'Z') {
- t[0] -= 'A' - 'a';
- }
- }
- fprintf(f, " (* %s%s) (", prefix, api->name);
- } else {
- fprintf(f, " %s%s (", prefix, api->name);
- }
- if (!api->nocontext) {
- if (addContext) {
- fprintf(f, "Context *");
- } else {
- fprintf(f, "RsContext rsc");
- }
- }
- printArgList(f, api, !api->nocontext);
- fprintf(f, ")");
-}
-
-void printFuncDecls(FILE *f, const char *prefix, int addContext) {
- int ct;
- for (ct=0; ct < apiCount; ct++) {
- printFuncDecl(f, &apis[ct], prefix, addContext, 0);
- fprintf(f, ";\n");
- }
- fprintf(f, "\n\n");
-}
-
-void printFuncPointers(FILE *f, int addContext) {
- fprintf(f, "\n");
- fprintf(f, "typedef struct RsApiEntrypoints {\n");
- int ct;
- for (ct=0; ct < apiCount; ct++) {
- fprintf(f, " ");
- printFuncDecl(f, &apis[ct], "", addContext, 1);
- fprintf(f, ";\n");
- }
- fprintf(f, "} RsApiEntrypoints_t;\n\n");
-}
-
-void printPlaybackFuncs(FILE *f, const char *prefix) {
- int ct;
- for (ct=0; ct < apiCount; ct++) {
- if (apis[ct].direct) {
- continue;
- }
-
- fprintf(f, "void %s%s (Context *, const void *);\n", prefix, apis[ct].name);
- }
-}
-
-static int hasInlineDataPointers(const ApiEntry * api) {
- int ret = 0;
- int ct;
- if (api->sync || api->ret.typeName[0]) {
- return 0;
- }
- for (ct=0; ct < api->paramCount; ct++) {
- const VarType *vt = &api->params[ct];
-
- if (!vt->isConst && vt->ptrLevel) {
- // Non-const pointers cannot be inlined.
- return 0;
- }
- if (vt->ptrLevel > 1) {
- // not handled yet.
- return 0;
- }
-
- if (vt->isConst && vt->ptrLevel) {
- // Non-const pointers cannot be inlined.
- ret = 1;
- }
- }
- return ret;
-}
-
-void printApiCpp(FILE *f) {
- int ct;
- int ct2;
-
- fprintf(f, "#include \"rsDevice.h\"\n");
- fprintf(f, "#include \"rsContext.h\"\n");
- fprintf(f, "#include \"rsThreadIO.h\"\n");
- fprintf(f, "#include \"rsgApiStructs.h\"\n");
- fprintf(f, "#include \"rsgApiFuncDecl.h\"\n");
- fprintf(f, "#include \"rsFifo.h\"\n");
- fprintf(f, "\n");
- fprintf(f, "using namespace android;\n");
- fprintf(f, "using namespace android::renderscript;\n");
- fprintf(f, "\n");
-
- printFuncPointers(f, 0);
-
- // Generate RS funcs for local fifo
- for (ct=0; ct < apiCount; ct++) {
- int needFlush = 0;
- const ApiEntry * api = &apis[ct];
-
- fprintf(f, "static ");
- printFuncDecl(f, api, "LF_", 0, 0);
- fprintf(f, "\n{\n");
- if (api->direct) {
- fprintf(f, " ");
- if (api->ret.typeName[0]) {
- fprintf(f, "return ");
- }
- fprintf(f, "rsi_%s(", api->name);
- if (!api->nocontext) {
- fprintf(f, "(Context *)rsc");
- }
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if (ct2 > 0 || !api->nocontext) {
- fprintf(f, ", ");
- }
- fprintf(f, "%s", vt->name);
- }
- fprintf(f, ");\n");
- } else {
- fprintf(f, " ThreadIO *io = &((Context *)rsc)->mIO;\n");
- fprintf(f, " const uint32_t size = sizeof(RS_CMD_%s);\n", api->name);
- if (hasInlineDataPointers(api)) {
- fprintf(f, " uint32_t dataSize = 0;\n");
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if (vt->isConst && vt->ptrLevel) {
- fprintf(f, " dataSize += %s_length;\n", vt->name);
- }
- }
- }
-
- //fprintf(f, " ALOGE(\"add command %s\\n\");\n", api->name);
- if (hasInlineDataPointers(api)) {
- fprintf(f, " RS_CMD_%s *cmd = NULL;\n", api->name);
- fprintf(f, " if (dataSize < io->getMaxInlineSize()) {;\n");
- fprintf(f, " cmd = static_cast<RS_CMD_%s *>(io->coreHeader(RS_CMD_ID_%s, dataSize + size));\n", api->name, api->name);
- fprintf(f, " } else {\n");
- fprintf(f, " cmd = static_cast<RS_CMD_%s *>(io->coreHeader(RS_CMD_ID_%s, size));\n", api->name, api->name);
- fprintf(f, " }\n");
- fprintf(f, " uint8_t *payload = (uint8_t *)&cmd[1];\n");
- } else {
- fprintf(f, " RS_CMD_%s *cmd = static_cast<RS_CMD_%s *>(io->coreHeader(RS_CMD_ID_%s, size));\n", api->name, api->name, api->name);
- }
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- needFlush += vt->ptrLevel;
- if (vt->ptrLevel && hasInlineDataPointers(api)) {
- fprintf(f, " if (dataSize < io->getMaxInlineSize()) {\n");
- fprintf(f, " memcpy(payload, %s, %s_length);\n", vt->name, vt->name);
- fprintf(f, " cmd->%s = (", vt->name);
- printVarType(f, vt);
- fprintf(f, ")(payload - ((uint8_t *)&cmd[1]));\n");
- fprintf(f, " payload += %s_length;\n", vt->name);
- fprintf(f, " } else {\n");
- fprintf(f, " cmd->%s = %s;\n", vt->name, vt->name);
- fprintf(f, " }\n");
-
- } else {
- fprintf(f, " cmd->%s = %s;\n", vt->name, vt->name);
- }
- }
- if (api->ret.typeName[0] || api->sync) {
- needFlush = 1;
- }
-
- fprintf(f, " io->coreCommit();\n");
- if (hasInlineDataPointers(api)) {
- fprintf(f, " if (dataSize >= io->getMaxInlineSize()) {\n");
- fprintf(f, " io->coreGetReturn(NULL, 0);\n");
- fprintf(f, " }\n");
- } else if (api->ret.typeName[0]) {
- fprintf(f, "\n ");
- printVarType(f, &api->ret);
- fprintf(f, " ret;\n");
- fprintf(f, " io->coreGetReturn(&ret, sizeof(ret));\n");
- fprintf(f, " return ret;\n");
- } else if (needFlush) {
- fprintf(f, " io->coreGetReturn(NULL, 0);\n");
- }
- }
- fprintf(f, "};\n\n");
-
-
- // Generate a remote sender function
- const char * str = "core";
- if (api->direct) {
- str = "async";
- }
-
- fprintf(f, "static ");
- printFuncDecl(f, api, "RF_", 0, 0);
- fprintf(f, "\n{\n");
- fprintf(f, " ThreadIO *io = &((Context *)rsc)->mIO;\n");
- fprintf(f, " const uint32_t cmdID = RS_CMD_ID_%s;\n", api->name);
- fprintf(f, " io->%sWrite(&cmdID, sizeof(cmdID));\n\n", str);
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if (vt->ptrLevel == 0) {
- fprintf(f, " io->%sWrite(& %s, sizeof(%s));\n", str, vt->name, vt->name);
- }
- }
- fprintf(f, "\n");
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if ((vt->ptrLevel == 1) && (vt->isConst)) {
- fprintf(f, " io->%sWrite(%s, %s_length);\n", str, vt->name, vt->name);
- }
- }
- fprintf(f, "\n");
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if ((vt->ptrLevel == 2) && (vt->isConst)) {
- fprintf(f, " for (size_t ct = 0; ct < (%s_length_length / sizeof(%s_length)); ct++) {\n", vt->name, vt->name);
- fprintf(f, " io->%sWrite(%s[ct], %s_length[ct]);\n", str, vt->name, vt->name);
- fprintf(f, " }\n");
- }
- }
- fprintf(f, "\n");
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if ((vt->ptrLevel == 1) && (!vt->isConst)) {
- fprintf(f, " io->%sGetReturn(%s, %s_length);\n", str, vt->name, vt->name);
- }
- }
- fprintf(f, "\n");
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if ((vt->ptrLevel == 2) && (!vt->isConst)) {
- fprintf(f, " for (size_t ct = 0; ct < (%s_length_length / sizeof(%s_length)); ct++) {\n", vt->name, vt->name);
- fprintf(f, " io->%sGetReturn(%s[ct], %s_length[ct]);\n", str, vt->name, vt->name);
- fprintf(f, " }\n");
- }
- }
- fprintf(f, "\n");
-
- if (api->ret.typeName[0]) {
- fprintf(f, " ");
- printVarType(f, &api->ret);
- fprintf(f, " retValue;\n");
- fprintf(f, " io->%sGetReturn(&retValue, sizeof(retValue));\n", str);
- fprintf(f, " return retValue;\n");
- } else /*if (api->sync)*/ {
- fprintf(f, " io->%sGetReturn(NULL, 0);\n", str);
- }
- fprintf(f, "}\n\n");
- }
-
- fprintf(f, "\n");
- fprintf(f, "static RsApiEntrypoints_t s_LocalTable = {\n");
- for (ct=0; ct < apiCount; ct++) {
- fprintf(f, " LF_%s,\n", apis[ct].name);
- }
- fprintf(f, "};\n");
-
- fprintf(f, "\n");
- fprintf(f, "static RsApiEntrypoints_t s_RemoteTable = {\n");
- for (ct=0; ct < apiCount; ct++) {
- fprintf(f, " RF_%s,\n", apis[ct].name);
- }
- fprintf(f, "};\n");
-
- fprintf(f, "static RsApiEntrypoints_t *s_CurrentTable = &s_LocalTable;\n\n");
- for (ct=0; ct < apiCount; ct++) {
- int needFlush = 0;
- const ApiEntry * api = &apis[ct];
-
- printFuncDecl(f, api, "rs", 0, 0);
- fprintf(f, "\n{\n");
- fprintf(f, " ");
- if (api->ret.typeName[0]) {
- fprintf(f, "return ");
- }
- fprintf(f, "s_CurrentTable->%s(", api->name);
-
- if (!api->nocontext) {
- fprintf(f, "(Context *)rsc");
- }
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if (ct2 > 0 || !api->nocontext) {
- fprintf(f, ", ");
- }
- fprintf(f, "%s", vt->name);
- }
- fprintf(f, ");\n");
- fprintf(f, "}\n\n");
- }
-
-}
-
-void printPlaybackCpp(FILE *f) {
- int ct;
- int ct2;
-
- fprintf(f, "#include \"rsDevice.h\"\n");
- fprintf(f, "#include \"rsContext.h\"\n");
- fprintf(f, "#include \"rsThreadIO.h\"\n");
- fprintf(f, "#include \"rsgApiStructs.h\"\n");
- fprintf(f, "#include \"rsgApiFuncDecl.h\"\n");
- fprintf(f, "\n");
- fprintf(f, "namespace android {\n");
- fprintf(f, "namespace renderscript {\n");
- fprintf(f, "\n");
-
- for (ct=0; ct < apiCount; ct++) {
- const ApiEntry * api = &apis[ct];
- int needFlush = 0;
-
- if (api->direct) {
- continue;
- }
-
- fprintf(f, "void rsp_%s(Context *con, const void *vp, size_t cmdSizeBytes) {\n", api->name);
- fprintf(f, " const RS_CMD_%s *cmd = static_cast<const RS_CMD_%s *>(vp);\n", api->name, api->name);
-
- if (hasInlineDataPointers(api)) {
- fprintf(f, " const uint8_t *baseData = 0;\n");
- fprintf(f, " if (cmdSizeBytes != sizeof(RS_CMD_%s)) {\n", api->name);
- fprintf(f, " baseData = &((const uint8_t *)vp)[sizeof(*cmd)];\n");
- fprintf(f, " }\n");
- }
-
- fprintf(f, " ");
- if (api->ret.typeName[0]) {
- fprintf(f, "\n ");
- printVarType(f, &api->ret);
- fprintf(f, " ret = ");
- }
- fprintf(f, "rsi_%s(con", api->name);
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- needFlush += vt->ptrLevel;
-
- if (hasInlineDataPointers(api) && vt->ptrLevel) {
- fprintf(f, ",\n (const %s *)&baseData[(intptr_t)cmd->%s]", vt->typeName, vt->name);
- } else {
- fprintf(f, ",\n cmd->%s", vt->name);
- }
- }
- fprintf(f, ");\n");
-
- if (hasInlineDataPointers(api)) {
- fprintf(f, " size_t totalSize = 0;\n");
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- if (api->params[ct2].ptrLevel) {
- fprintf(f, " totalSize += cmd->%s_length;\n", api->params[ct2].name);
- }
- }
-
- fprintf(f, " if ((totalSize != 0) && (cmdSizeBytes == sizeof(RS_CMD_%s))) {\n", api->name);
- fprintf(f, " con->mIO.coreSetReturn(NULL, 0);\n");
- fprintf(f, " }\n");
- } else if (api->ret.typeName[0]) {
- fprintf(f, " con->mIO.coreSetReturn(&ret, sizeof(ret));\n");
- } else if (api->sync || needFlush) {
- fprintf(f, " con->mIO.coreSetReturn(NULL, 0);\n");
- }
-
- fprintf(f, "};\n\n");
- }
-
- for (ct=0; ct < apiCount; ct++) {
- const ApiEntry * api = &apis[ct];
- int needFlush = 0;
-
- fprintf(f, "void rspr_%s(Context *con, ThreadIO *io) {\n", api->name);
- fprintf(f, " RS_CMD_%s cmd;\n", api->name);
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if (vt->ptrLevel == 0) {
- fprintf(f, " io->coreRead(&cmd.%s, sizeof(cmd.%s));\n", vt->name, vt->name);
- }
- }
- fprintf(f, "\n");
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if (vt->ptrLevel == 1) {
- fprintf(f, " cmd.%s = (", vt->name);
- printVarType(f, vt);
- fprintf(f, ")malloc(cmd.%s_length);\n", vt->name);
-
- if (vt->isConst) {
- fprintf(f, " if (cmd.%s_length) io->coreRead((void *)cmd.%s, cmd.%s_length);\n", vt->name, vt->name, vt->name);
- }
- }
- }
- fprintf(f, "\n");
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if (vt->ptrLevel == 2) {
- fprintf(f, " for (size_t ct = 0; ct < (cmd.%s_length_length / sizeof(cmd.%s_length)); ct++) {\n", vt->name, vt->name);
- fprintf(f, " cmd.%s = (", vt->name);
- printVarType(f, vt);
- fprintf(f, ")malloc(cmd.%s_length[ct]);\n", vt->name);
- fprintf(f, " io->coreRead(& cmd.%s, cmd.%s_length[ct]);\n", vt->name, vt->name);
- fprintf(f, " }\n");
- }
- }
- fprintf(f, "\n");
-
- if (api->ret.typeName[0]) {
- fprintf(f, " ");
- printVarType(f, &api->ret);
- fprintf(f, " ret =\n");
- }
-
- fprintf(f, " rsi_%s(", api->name);
- if (!api->nocontext) {
- fprintf(f, "con");
- }
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if (ct2 > 0 || !api->nocontext) {
- fprintf(f, ",\n");
- }
- fprintf(f, " cmd.%s", vt->name);
- }
- fprintf(f, ");\n");
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if ((vt->ptrLevel == 1) && (!vt->isConst)) {
- fprintf(f, " io->coreSetReturn((void *)cmd.%s, cmd.%s_length);\n", vt->name, vt->name);
- }
- }
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if ((vt->ptrLevel == 2) && (!vt->isConst)) {
- fprintf(f, " for (size_t ct = 0; ct < (cmd.%s_length_length / sizeof(cmd.%s_length)); ct++) {\n", vt->name, vt->name);
- fprintf(f, " io->coreSetReturn((void *)cmd.%s[ct], cmd.%s_length[ct]);\n", vt->name, vt->name);
- fprintf(f, " }\n");
- }
- }
- fprintf(f, "\n");
-
- if (api->ret.typeName[0]) {
- fprintf(f, " io->coreSetReturn(&ret, sizeof(ret));\n");
- } else /*if (needFlush)*/ {
- fprintf(f, " io->coreSetReturn(NULL, 0);\n");
- }
-
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if (vt->ptrLevel == 1) {
- fprintf(f, " free((void *)cmd.%s);\n", vt->name);
- }
- }
- for (ct2=0; ct2 < api->paramCount; ct2++) {
- const VarType *vt = &api->params[ct2];
- if (vt->ptrLevel == 2) {
- fprintf(f, " for (size_t ct = 0; ct < (cmd.%s_length_length / sizeof(cmd.%s_length)); ct++) {\n", vt->name, vt->name);
- fprintf(f, " free((void *)cmd.%s);\n", vt->name);
- fprintf(f, " }\n");
- }
- }
-
- fprintf(f, "};\n\n");
- }
-
- fprintf(f, "RsPlaybackLocalFunc gPlaybackFuncs[%i] = {\n", apiCount + 1);
- fprintf(f, " NULL,\n");
- for (ct=0; ct < apiCount; ct++) {
- if (apis[ct].direct) {
- fprintf(f, " NULL,\n");
- } else {
- fprintf(f, " %s%s,\n", "rsp_", apis[ct].name);
- }
- }
- fprintf(f, "};\n");
-
- fprintf(f, "RsPlaybackRemoteFunc gPlaybackRemoteFuncs[%i] = {\n", apiCount + 1);
- fprintf(f, " NULL,\n");
- for (ct=0; ct < apiCount; ct++) {
- fprintf(f, " %s%s,\n", "rspr_", apis[ct].name);
- }
- fprintf(f, "};\n");
-
- fprintf(f, "};\n");
- fprintf(f, "};\n");
-}
-
-void yylex();
-
-int main(int argc, char **argv) {
- if (argc != 3) {
- fprintf(stderr, "usage: %s commandFile outFile\n", argv[0]);
- return 1;
- }
- const char* rsgFile = argv[1];
- const char* outFile = argv[2];
- FILE* input = fopen(rsgFile, "r");
-
- char choice = fgetc(input);
- fclose(input);
-
- if (choice < '0' || choice > '3') {
- fprintf(stderr, "Uknown command: \'%c\'\n", choice);
- return -2;
- }
-
- yylex();
- // printf("# of lines = %d\n", num_lines);
-
- FILE *f = fopen(outFile, "w");
-
- printFileHeader(f);
- switch (choice) {
- case '0': // rsgApiStructs.h
- {
- fprintf(f, "\n");
- fprintf(f, "#include \"rsContext.h\"\n");
- fprintf(f, "#include \"rsFifo.h\"\n");
- fprintf(f, "\n");
- fprintf(f, "namespace android {\n");
- fprintf(f, "namespace renderscript {\n");
- printStructures(f);
- printFuncDecls(f, "rsi_", 1);
- printPlaybackFuncs(f, "rsp_");
- fprintf(f, "\n\ntypedef struct RsPlaybackRemoteHeaderRec {\n");
- fprintf(f, " uint32_t command;\n");
- fprintf(f, " uint32_t size;\n");
- fprintf(f, "} RsPlaybackRemoteHeader;\n\n");
- fprintf(f, "typedef void (*RsPlaybackLocalFunc)(Context *, const void *, size_t sizeBytes);\n");
- fprintf(f, "typedef void (*RsPlaybackRemoteFunc)(Context *, ThreadIO *);\n");
- fprintf(f, "extern RsPlaybackLocalFunc gPlaybackFuncs[%i];\n", apiCount + 1);
- fprintf(f, "extern RsPlaybackRemoteFunc gPlaybackRemoteFuncs[%i];\n", apiCount + 1);
-
- fprintf(f, "}\n");
- fprintf(f, "}\n");
- }
- break;
-
- case '1': // rsgApiFuncDecl.h
- {
- printFuncDecls(f, "rs", 0);
- }
- break;
-
- case '2': // rsgApi.cpp
- {
- printApiCpp(f);
- }
- break;
-
- case '3': // rsgApiReplay.cpp
- {
- printFileHeader(f);
- printPlaybackCpp(f);
- }
- break;
-
- case '4': // rsgApiStream.cpp
- {
- printFileHeader(f);
- printPlaybackCpp(f);
- }
-
- case '5': // rsgApiStreamReplay.cpp
- {
- printFileHeader(f);
- printPlaybackCpp(f);
- }
- break;
- }
- fclose(f);
- return 0;
-}
diff --git a/libs/rs/scriptc/rs_allocation.rsh b/libs/rs/scriptc/rs_allocation.rsh
deleted file mode 100644
index b0840a0..0000000
--- a/libs/rs/scriptc/rs_allocation.rsh
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/** @file rs_allocation.rsh
- * \brief Allocation routines
- *
- *
- */
-
-#ifndef __RS_ALLOCATION_RSH__
-#define __RS_ALLOCATION_RSH__
-
-/**
- * Returns the Allocation for a given pointer. The pointer should point within
- * a valid allocation. The results are undefined if the pointer is not from a
- * valid allocation.
- */
-extern rs_allocation __attribute__((overloadable))
- rsGetAllocation(const void *);
-
-/**
- * Query the dimension of an allocation.
- *
- * @return uint32_t The X dimension of the allocation.
- */
-extern uint32_t __attribute__((overloadable))
- rsAllocationGetDimX(rs_allocation);
-
-/**
- * Query the dimension of an allocation.
- *
- * @return uint32_t The Y dimension of the allocation.
- */
-extern uint32_t __attribute__((overloadable))
- rsAllocationGetDimY(rs_allocation);
-
-/**
- * Query the dimension of an allocation.
- *
- * @return uint32_t The Z dimension of the allocation.
- */
-extern uint32_t __attribute__((overloadable))
- rsAllocationGetDimZ(rs_allocation);
-
-/**
- * Query an allocation for the presence of more than one LOD.
- *
- * @return uint32_t Returns 1 if more than one LOD is present, 0 otherwise.
- */
-extern uint32_t __attribute__((overloadable))
- rsAllocationGetDimLOD(rs_allocation);
-
-/**
- * Query an allocation for the presence of more than one face.
- *
- * @return uint32_t Returns 1 if more than one face is present, 0 otherwise.
- */
-extern uint32_t __attribute__((overloadable))
- rsAllocationGetDimFaces(rs_allocation);
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 14))
-
-/**
- * Copy part of an allocation from another allocation.
- *
- * @param dstAlloc Allocation to copy data into.
- * @param dstOff The offset of the first element to be copied in
- * the destination allocation.
- * @param dstMip Mip level in the destination allocation.
- * @param count The number of elements to be copied.
- * @param srcAlloc The source data allocation.
- * @param srcOff The offset of the first element in data to be
- * copied in the source allocation.
- * @param srcMip Mip level in the source allocation.
- */
-extern void __attribute__((overloadable))
- rsAllocationCopy1DRange(rs_allocation dstAlloc,
- uint32_t dstOff, uint32_t dstMip,
- uint32_t count,
- rs_allocation srcAlloc,
- uint32_t srcOff, uint32_t srcMip);
-
-/**
- * Copy a rectangular region into the allocation from another
- * allocation.
- *
- * @param dstAlloc allocation to copy data into.
- * @param dstXoff X offset of the region to update in the
- * destination allocation.
- * @param dstYoff Y offset of the region to update in the
- * destination allocation.
- * @param dstMip Mip level in the destination allocation.
- * @param dstFace Cubemap face of the destination allocation,
- * ignored for allocations that aren't cubemaps.
- * @param width Width of the incoming region to update.
- * @param height Height of the incoming region to update.
- * @param srcAlloc The source data allocation.
- * @param srcXoff X offset in data of the source allocation.
- * @param srcYoff Y offset in data of the source allocation.
- * @param srcMip Mip level in the source allocation.
- * @param srcFace Cubemap face of the source allocation,
- * ignored for allocations that aren't cubemaps.
- */
-extern void __attribute__((overloadable))
- rsAllocationCopy2DRange(rs_allocation dstAlloc,
- uint32_t dstXoff, uint32_t dstYoff,
- uint32_t dstMip,
- rs_allocation_cubemap_face dstFace,
- uint32_t width, uint32_t height,
- rs_allocation srcAlloc,
- uint32_t srcXoff, uint32_t srcYoff,
- uint32_t srcMip,
- rs_allocation_cubemap_face srcFace);
-
-#endif //defined(RS_VERSION) && (RS_VERSION >= 14)
-
-/**
- * Extract a single element from an allocation.
- */
-extern const void * __attribute__((overloadable))
- rsGetElementAt(rs_allocation, uint32_t x);
-/**
- * \overload
- */
-extern const void * __attribute__((overloadable))
- rsGetElementAt(rs_allocation, uint32_t x, uint32_t y);
-/**
- * \overload
- */
-extern const void * __attribute__((overloadable))
- rsGetElementAt(rs_allocation, uint32_t x, uint32_t y, uint32_t z);
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-
-/**
- * @param a allocation to get data from
- * @return element describing allocation layout
- */
-extern rs_element __attribute__((overloadable))
- rsAllocationGetElement(rs_allocation a);
-
-/**
- * Fetch allocation in a way described by the sampler
- * @param a 1D allocation to sample from
- * @param s sampler state
- * @param location to sample from
- */
-extern const float4 __attribute__((overloadable))
- rsSample(rs_allocation a, rs_sampler s, float location);
-/**
- * Fetch allocation in a way described by the sampler
- * @param a 1D allocation to sample from
- * @param s sampler state
- * @param location to sample from
- * @param lod mip level to sample from, for fractional values
- * mip levels will be interpolated if
- * RS_SAMPLER_LINEAR_MIP_LINEAR is used
- */
-extern const float4 __attribute__((overloadable))
- rsSample(rs_allocation a, rs_sampler s, float location, float lod);
-
-/**
- * Fetch allocation in a way described by the sampler
- * @param a 2D allocation to sample from
- * @param s sampler state
- * @param location to sample from
- */
-extern const float4 __attribute__((overloadable))
- rsSample(rs_allocation a, rs_sampler s, float2 location);
-
-/**
- * Fetch allocation in a way described by the sampler
- * @param a 2D allocation to sample from
- * @param s sampler state
- * @param location to sample from
- * @param lod mip level to sample from, for fractional values
- * mip levels will be interpolated if
- * RS_SAMPLER_LINEAR_MIP_LINEAR is used
- */
-extern const float4 __attribute__((overloadable))
- rsSample(rs_allocation a, rs_sampler s, float2 location, float lod);
-
-#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
-
-#endif
-
diff --git a/libs/rs/scriptc/rs_atomic.rsh b/libs/rs/scriptc/rs_atomic.rsh
deleted file mode 100644
index a455edd..0000000
--- a/libs/rs/scriptc/rs_atomic.rsh
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/** @file rs_atomic.rsh
- * \brief Atomic routines
- *
- *
- */
-
-#ifndef __RS_ATOMIC_RSH__
-#define __RS_ATOMIC_RSH__
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 14))
-
-/**
- * Atomic add one to the value at addr.
- * Equal to rsAtomicAdd(addr, 1)
- *
- * @param addr Address of value to increment
- *
- * @return old value
- */
-extern int32_t __attribute__((overloadable))
- rsAtomicInc(volatile int32_t* addr);
-/**
- * Atomic add one to the value at addr.
- * Equal to rsAtomicAdd(addr, 1)
- *
- * @param addr Address of value to increment
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
- rsAtomicInc(volatile uint32_t* addr);
-
-/**
- * Atomic subtract one from the value at addr. Equal to rsAtomicSub(addr, 1)
- *
- * @param addr Address of value to decrement
- *
- * @return old value
- */
-extern int32_t __attribute__((overloadable))
- rsAtomicDec(volatile int32_t* addr);
-/**
- * Atomic subtract one from the value at addr. Equal to rsAtomicSub(addr, 1)
- *
- * @param addr Address of value to decrement
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
- rsAtomicDec(volatile uint32_t* addr);
-
-/**
- * Atomic add a value to the value at addr. addr[0] += value
- *
- * @param addr Address of value to modify
- * @param value Amount to add to the value at addr
- *
- * @return old value
- */
-extern int32_t __attribute__((overloadable))
- rsAtomicAdd(volatile int32_t* addr, int32_t value);
-/**
- * Atomic add a value to the value at addr. addr[0] += value
- *
- * @param addr Address of value to modify
- * @param value Amount to add to the value at addr
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
- rsAtomicAdd(volatile uint32_t* addr, uint32_t value);
-
-/**
- * Atomic Subtract a value from the value at addr. addr[0] -= value
- *
- * @param addr Address of value to modify
- * @param value Amount to subtract from the value at addr
- *
- * @return old value
- */
-extern int32_t __attribute__((overloadable))
- rsAtomicSub(volatile int32_t* addr, int32_t value);
-/**
- * Atomic Subtract a value from the value at addr. addr[0] -= value
- *
- * @param addr Address of value to modify
- * @param value Amount to subtract from the value at addr
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
- rsAtomicSub(volatile uint32_t* addr, uint32_t value);
-
-/**
- * Atomic Bitwise and a value from the value at addr. addr[0] &= value
- *
- * @param addr Address of value to modify
- * @param value Amount to and with the value at addr
- *
- * @return old value
- */
-extern int32_t __attribute__((overloadable))
- rsAtomicAnd(volatile int32_t* addr, int32_t value);
-/**
- * Atomic Bitwise and a value from the value at addr. addr[0] &= value
- *
- * @param addr Address of value to modify
- * @param value Amount to and with the value at addr
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
- rsAtomicAnd(volatile uint32_t* addr, uint32_t value);
-
-/**
- * Atomic Bitwise or a value from the value at addr. addr[0] |= value
- *
- * @param addr Address of value to modify
- * @param value Amount to or with the value at addr
- *
- * @return old value
- */
-extern int32_t __attribute__((overloadable))
- rsAtomicOr(volatile int32_t* addr, int32_t value);
-/**
- * Atomic Bitwise or a value from the value at addr. addr[0] |= value
- *
- * @param addr Address of value to modify
- * @param value Amount to or with the value at addr
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
- rsAtomicOr(volatile uint32_t* addr, uint32_t value);
-
-/**
- * Atomic Bitwise xor a value from the value at addr. addr[0] ^= value
- *
- * @param addr Address of value to modify
- * @param value Amount to xor with the value at addr
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
- rsAtomicXor(volatile uint32_t* addr, uint32_t value);
-/**
- * Atomic Bitwise xor a value from the value at addr. addr[0] ^= value
- *
- * @param addr Address of value to modify
- * @param value Amount to xor with the value at addr
- *
- * @return old value
- */
-extern int32_t __attribute__((overloadable))
- rsAtomicXor(volatile int32_t* addr, int32_t value);
-
-/**
- * Atomic Set the value at addr to the min of addr and value
- * addr[0] = rsMin(addr[0], value)
- *
- * @param addr Address of value to modify
- * @param value comparison value
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
- rsAtomicMin(volatile uint32_t* addr, uint32_t value);
-/**
- * Atomic Set the value at addr to the min of addr and value
- * addr[0] = rsMin(addr[0], value)
- *
- * @param addr Address of value to modify
- * @param value comparison value
- *
- * @return old value
- */
-extern int32_t __attribute__((overloadable))
- rsAtomicMin(volatile int32_t* addr, int32_t value);
-
-/**
- * Atomic Set the value at addr to the max of addr and value
- * addr[0] = rsMax(addr[0], value)
- *
- * @param addr Address of value to modify
- * @param value comparison value
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
- rsAtomicMax(volatile uint32_t* addr, uint32_t value);
-/**
- * Atomic Set the value at addr to the max of addr and value
- * addr[0] = rsMin(addr[0], value)
- *
- * @param addr Address of value to modify
- * @param value comparison value
- *
- * @return old value
- */
-extern int32_t __attribute__((overloadable))
- rsAtomicMax(volatile int32_t* addr, int32_t value);
-
-/**
- * Compare-and-set operation with a full memory barrier.
- *
- * If the value at addr matches compareValue then newValue is written.
- *
- * @param addr The address to compare and replace if the compare passes.
- * @param compareValue The value to test addr[0] against.
- * @param newValue The value to write if the test passes.
- *
- * @return old value
- */
-extern int32_t __attribute__((overloadable))
- rsAtomicCas(volatile int32_t* addr, int32_t compareValue, int32_t newValue);
-
-/**
- * Compare-and-set operation with a full memory barrier.
- *
- * If the value at addr matches compareValue then newValue is written.
- *
- * @param addr The address to compare and replace if the compare passes.
- * @param compareValue The value to test addr[0] against.
- * @param newValue The value to write if the test passes.
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
- rsAtomicCas(volatile uint32_t* addr, uint32_t compareValue, uint32_t newValue);
-
-#endif //defined(RS_VERSION) && (RS_VERSION >= 14)
-
-#endif
-
diff --git a/libs/rs/scriptc/rs_cl.rsh b/libs/rs/scriptc/rs_cl.rsh
deleted file mode 100644
index bbc8fc5..0000000
--- a/libs/rs/scriptc/rs_cl.rsh
+++ /dev/null
@@ -1,867 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/** @file rs_cl.rsh
- * \brief Basic math functions
- *
- *
- */
-
-#ifndef __RS_CL_RSH__
-#define __RS_CL_RSH__
-
-// Conversions
-#define CVT_FUNC_2(typeout, typein) \
-_RS_RUNTIME typeout##2 __attribute__((overloadable)) \
- convert_##typeout##2(typein##2 v); \
-_RS_RUNTIME typeout##3 __attribute__((overloadable)) \
- convert_##typeout##3(typein##3 v); \
-_RS_RUNTIME typeout##4 __attribute__((overloadable)) \
- convert_##typeout##4(typein##4 v);
-
-
-#define CVT_FUNC(type) CVT_FUNC_2(type, uchar) \
- CVT_FUNC_2(type, char) \
- CVT_FUNC_2(type, ushort) \
- CVT_FUNC_2(type, short) \
- CVT_FUNC_2(type, uint) \
- CVT_FUNC_2(type, int) \
- CVT_FUNC_2(type, float)
-
-CVT_FUNC(char)
-CVT_FUNC(uchar)
-CVT_FUNC(short)
-CVT_FUNC(ushort)
-CVT_FUNC(int)
-CVT_FUNC(uint)
-CVT_FUNC(float)
-
-// Float ops, 6.11.2
-
-#define FN_FUNC_FN(fnc) \
-_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v); \
-_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v); \
-_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v);
-
-#define IN_FUNC_FN(fnc) \
-_RS_RUNTIME int2 __attribute__((overloadable)) fnc(float2 v); \
-_RS_RUNTIME int3 __attribute__((overloadable)) fnc(float3 v); \
-_RS_RUNTIME int4 __attribute__((overloadable)) fnc(float4 v);
-
-#define FN_FUNC_FN_FN(fnc) \
-_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, float2 v2); \
-_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, float3 v2); \
-_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, float4 v2);
-
-#define FN_FUNC_FN_F(fnc) \
-_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, float v2); \
-_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, float v2); \
-_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, float v2);
-
-#define FN_FUNC_FN_IN(fnc) \
-_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, int2 v2); \
-_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, int3 v2); \
-_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, int4 v2); \
-
-#define FN_FUNC_FN_I(fnc) \
-_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, int v2); \
-_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, int v2); \
-_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, int v2);
-
-#define FN_FUNC_FN_PFN(fnc) \
-_RS_RUNTIME float2 __attribute__((overloadable)) \
- fnc(float2 v1, float2 *v2); \
-_RS_RUNTIME float3 __attribute__((overloadable)) \
- fnc(float3 v1, float3 *v2); \
-_RS_RUNTIME float4 __attribute__((overloadable)) \
- fnc(float4 v1, float4 *v2);
-
-#define FN_FUNC_FN_PIN(fnc) \
-_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, int2 *v2); \
-_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, int3 *v2); \
-_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, int4 *v2);
-
-#define FN_FUNC_FN_FN_FN(fnc) \
-_RS_RUNTIME float2 __attribute__((overloadable)) \
- fnc(float2 v1, float2 v2, float2 v3); \
-_RS_RUNTIME float3 __attribute__((overloadable)) \
- fnc(float3 v1, float3 v2, float3 v3); \
-_RS_RUNTIME float4 __attribute__((overloadable)) \
- fnc(float4 v1, float4 v2, float4 v3);
-
-#define FN_FUNC_FN_FN_PIN(fnc) \
-_RS_RUNTIME float2 __attribute__((overloadable)) \
- fnc(float2 v1, float2 v2, int2 *v3); \
-_RS_RUNTIME float3 __attribute__((overloadable)) \
- fnc(float3 v1, float3 v2, int3 *v3); \
-_RS_RUNTIME float4 __attribute__((overloadable)) \
- fnc(float4 v1, float4 v2, int4 *v3);
-
-
-/**
- * Return the inverse cosine.
- *
- * Supports float, float2, float3, float4
- */
-extern float __attribute__((overloadable)) acos(float);
-FN_FUNC_FN(acos)
-
-/**
- * Return the inverse hyperbolic cosine.
- *
- * Supports float, float2, float3, float4
- */
-extern float __attribute__((overloadable)) acosh(float);
-FN_FUNC_FN(acosh)
-
-/**
- * Return the inverse cosine divided by PI.
- *
- * Supports float, float2, float3, float4
- */
-_RS_RUNTIME float __attribute__((overloadable)) acospi(float v);
-FN_FUNC_FN(acospi)
-
-/**
- * Return the inverse sine.
- *
- * Supports float, float2, float3, float4
- */
-extern float __attribute__((overloadable)) asin(float);
-FN_FUNC_FN(asin)
-
-/**
- * Return the inverse hyperbolic sine.
- *
- * Supports float, float2, float3, float4
- */
-extern float __attribute__((overloadable)) asinh(float);
-FN_FUNC_FN(asinh)
-
-
-/**
- * Return the inverse sine divided by PI.
- *
- * Supports float, float2, float3, float4
- */
-_RS_RUNTIME float __attribute__((overloadable)) asinpi(float v);
-FN_FUNC_FN(asinpi)
-
-/**
- * Return the inverse tangent.
- *
- * Supports float, float2, float3, float4
- */
-extern float __attribute__((overloadable)) atan(float);
-FN_FUNC_FN(atan)
-
-/**
- * Return the inverse tangent of y / x.
- *
- * Supports float, float2, float3, float4. Both arguments must be of the same
- * type.
- *
- * @param y
- * @param x
- */
-extern float __attribute__((overloadable)) atan2(float y, float x);
-FN_FUNC_FN_FN(atan2)
-
-/**
- * Return the inverse hyperbolic tangent.
- *
- * Supports float, float2, float3, float4
- */
-extern float __attribute__((overloadable)) atanh(float);
-FN_FUNC_FN(atanh)
-
-/**
- * Return the inverse tangent divided by PI.
- *
- * Supports float, float2, float3, float4
- */
-_RS_RUNTIME float __attribute__((overloadable)) atanpi(float v);
-FN_FUNC_FN(atanpi)
-
-/**
- * Return the inverse tangent of y / x, divided by PI.
- *
- * Supports float, float2, float3, float4. Both arguments must be of the same
- * type.
- *
- * @param y
- * @param x
- */
-_RS_RUNTIME float __attribute__((overloadable)) atan2pi(float y, float x);
-FN_FUNC_FN_FN(atan2pi)
-
-
-/**
- * Return the cube root.
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) cbrt(float);
-FN_FUNC_FN(cbrt)
-
-/**
- * Return the smallest integer not less than a value.
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) ceil(float);
-FN_FUNC_FN(ceil)
-
-/**
- * Copy the sign bit from y to x.
- *
- * Supports float, float2, float3, float4. Both arguments must be of the same
- * type.
- *
- * @param x
- * @param y
- */
-extern float __attribute__((overloadable)) copysign(float x, float y);
-FN_FUNC_FN_FN(copysign)
-
-/**
- * Return the cosine.
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) cos(float);
-FN_FUNC_FN(cos)
-
-/**
- * Return the hypebolic cosine.
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) cosh(float);
-FN_FUNC_FN(cosh)
-
-/**
- * Return the cosine of the value * PI.
- *
- * Supports float, float2, float3, float4.
- */
-_RS_RUNTIME float __attribute__((overloadable)) cospi(float v);
-FN_FUNC_FN(cospi)
-
-/**
- * Return the complementary error function.
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) erfc(float);
-FN_FUNC_FN(erfc)
-
-/**
- * Return the error function.
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) erf(float);
-FN_FUNC_FN(erf)
-
-/**
- * Return e ^ value.
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) exp(float);
-FN_FUNC_FN(exp)
-
-/**
- * Return 2 ^ value.
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) exp2(float);
-FN_FUNC_FN(exp2)
-
-/**
- * Return x ^ y.
- *
- * Supports float, float2, float3, float4. Both arguments must be of the same
- * type.
- */
-extern float __attribute__((overloadable)) pow(float x, float y);
-FN_FUNC_FN_FN(pow)
-
-/**
- * Return 10 ^ value.
- *
- * Supports float, float2, float3, float4.
- */
-_RS_RUNTIME float __attribute__((overloadable)) exp10(float v);
-FN_FUNC_FN(exp10)
-
-/**
- * Return (e ^ value) - 1.
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) expm1(float);
-FN_FUNC_FN(expm1)
-
-/**
- * Return the absolute value of a value.
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) fabs(float);
-FN_FUNC_FN(fabs)
-
-/**
- * Return the positive difference between two values.
- *
- * Supports float, float2, float3, float4. Both arguments must be of the same
- * type.
- */
-extern float __attribute__((overloadable)) fdim(float, float);
-FN_FUNC_FN_FN(fdim)
-
-/**
- * Return the smallest integer not greater than a value.
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) floor(float);
-FN_FUNC_FN(floor)
-
-/**
- * Return a*b + c.
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) fma(float a, float b, float c);
-FN_FUNC_FN_FN_FN(fma)
-
-/**
- * Return (x < y ? y : x)
- *
- * Supports float, float2, float3, float4.
- * @param x: may be float, float2, float3, float4
- * @param y: may be float or vector. If vector must match type of x.
- */
-extern float __attribute__((overloadable)) fmax(float x, float y);
-FN_FUNC_FN_FN(fmax);
-FN_FUNC_FN_F(fmax);
-
-/**
- * Return (x > y ? y : x)
- *
- * @param x: may be float, float2, float3, float4
- * @param y: may be float or vector. If vector must match type of x.
- */
-extern float __attribute__((overloadable)) fmin(float x, float y);
-FN_FUNC_FN_FN(fmin);
-FN_FUNC_FN_F(fmin);
-
-/**
- * Return the remainder from x / y
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) fmod(float x, float y);
-FN_FUNC_FN_FN(fmod)
-
-
-/**
- * Return fractional part of v
- *
- * @param iptr iptr[0] will be set to the floor of the input value.
- * Supports float, float2, float3, float4.
- */
-_RS_RUNTIME float __attribute__((overloadable)) fract(float v, float *iptr);
-FN_FUNC_FN_PFN(fract)
-
-/**
- * Return the mantissa and place the exponent into iptr[0]
- *
- * @param v Supports float, float2, float3, float4.
- * @param iptr Must have the same vector size as v.
- */
-extern float __attribute__((overloadable)) frexp(float v, int *iptr);
-FN_FUNC_FN_PIN(frexp)
-
-/**
- * Return sqrt(x*x + y*y)
- *
- * Supports float, float2, float3, float4.
- */
-extern float __attribute__((overloadable)) hypot(float x, float y);
-FN_FUNC_FN_FN(hypot)
-
-/**
- * Return the integer exponent of a value
- *
- * Supports 1,2,3,4 components
- */
-extern int __attribute__((overloadable)) ilogb(float);
-IN_FUNC_FN(ilogb)
-
-/**
- * Return (x * 2^y)
- *
- * @param x Supports 1,2,3,4 components
- * @param y Supports single component or matching vector.
- */
-extern float __attribute__((overloadable)) ldexp(float x, int y);
-FN_FUNC_FN_IN(ldexp)
-FN_FUNC_FN_I(ldexp)
-
-/**
- * Return the log gamma
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) lgamma(float);
-FN_FUNC_FN(lgamma)
-
-/**
- * Return the log gamma and sign
- *
- * @param x Supports 1,2,3,4 components
- * @param y Supports matching vector.
- */
-extern float __attribute__((overloadable)) lgamma(float x, int* y);
-FN_FUNC_FN_PIN(lgamma)
-
-/**
- * Return the natural logarithm
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) log(float);
-FN_FUNC_FN(log)
-
-/**
- * Return the base 10 logarithm
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) log10(float);
-FN_FUNC_FN(log10)
-
-/**
- * Return the base 2 logarithm
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) log2(float v);
-FN_FUNC_FN(log2)
-
-/**
- * Return the natural logarithm of (v + 1.0f)
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) log1p(float v);
-FN_FUNC_FN(log1p)
-
-/**
- * Compute the exponent of the value.
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) logb(float);
-FN_FUNC_FN(logb)
-
-/**
- * Compute (a * b) + c
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) mad(float a, float b, float c);
-FN_FUNC_FN_FN_FN(mad)
-
-/**
- * Return the integral and fractional components of a number
- * Supports 1,2,3,4 components
- *
- * @param x Source value
- * @param iret iret[0] will be set to the integral portion of the number.
- * @return The floating point portion of the value.
- */
-extern float __attribute__((overloadable)) modf(float x, float *iret);
-FN_FUNC_FN_PFN(modf);
-
-//extern float __attribute__((overloadable)) nan(uint);
-
-/**
- * Return the next floating point number from x towards y.
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) nextafter(float x, float y);
-FN_FUNC_FN_FN(nextafter)
-
-/**
- * Return (v ^ p).
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) pown(float v, int p);
-FN_FUNC_FN_IN(pown)
-
-/**
- * Return (v ^ p).
- * @param v must be greater than 0.
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) powr(float v, float p);
-FN_FUNC_FN_FN(powr)
-
-/**
- * Return round x/y to the nearest integer then compute the remander.
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) remainder(float x, float y);
-FN_FUNC_FN_FN(remainder)
-
-// document once we know the precision of bionic
-extern float __attribute__((overloadable)) remquo(float, float, int *);
-FN_FUNC_FN_FN_PIN(remquo)
-
-/**
- * Round to the nearest integral value.
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) rint(float);
-FN_FUNC_FN(rint)
-
-/**
- * Compute the Nth root of a value.
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) rootn(float v, int n);
-FN_FUNC_FN_IN(rootn)
-
-/**
- * Round to the nearest integral value. Half values are rounded away from zero.
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) round(float);
-FN_FUNC_FN(round)
-
-/**
- * Return the square root of a value.
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) sqrt(float);
-FN_FUNC_FN(sqrt)
-
-/**
- * Return (1 / sqrt(value)).
- *
- * @param v The incoming value in radians
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) rsqrt(float v);
-FN_FUNC_FN(rsqrt)
-
-/**
- * Return the sine of a value specified in radians.
- *
- * @param v The incoming value in radians
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) sin(float v);
-FN_FUNC_FN(sin)
-
-/**
- * Return the sine and cosine of a value.
- *
- * @return sine
- * @param v The incoming value in radians
- * @param *cosptr cosptr[0] will be set to the cosine value.
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) sincos(float v, float *cosptr);
-FN_FUNC_FN_PFN(sincos);
-
-/**
- * Return the hyperbolic sine of a value specified in radians.
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) sinh(float);
-FN_FUNC_FN(sinh)
-
-/**
- * Return the sin(v * PI).
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) sinpi(float v);
-FN_FUNC_FN(sinpi)
-
-/**
- * Return the tangent of a value.
- *
- * Supports 1,2,3,4 components
- * @param v The incoming value in radians
- */
-extern float __attribute__((overloadable)) tan(float v);
-FN_FUNC_FN(tan)
-
-/**
- * Return the hyperbolic tangent of a value.
- *
- * Supports 1,2,3,4 components
- * @param v The incoming value in radians
- */
-extern float __attribute__((overloadable)) tanh(float);
-FN_FUNC_FN(tanh)
-
-/**
- * Return tan(v * PI)
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) tanpi(float v);
-FN_FUNC_FN(tanpi)
-
-/**
- * Compute the gamma function of a value.
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) tgamma(float);
-FN_FUNC_FN(tgamma)
-
-/**
- * Round to integral using truncation.
- *
- * Supports 1,2,3,4 components
- */
-extern float __attribute__((overloadable)) trunc(float);
-FN_FUNC_FN(trunc)
-
-
-#define XN_FUNC_YN(typeout, fnc, typein) \
-extern typeout __attribute__((overloadable)) fnc(typein); \
-_RS_RUNTIME typeout##2 __attribute__((overloadable)) fnc(typein##2 v); \
-_RS_RUNTIME typeout##3 __attribute__((overloadable)) fnc(typein##3 v); \
-_RS_RUNTIME typeout##4 __attribute__((overloadable)) fnc(typein##4 v);
-
-#define UIN_FUNC_IN(fnc) \
-XN_FUNC_YN(uchar, fnc, char) \
-XN_FUNC_YN(ushort, fnc, short) \
-XN_FUNC_YN(uint, fnc, int)
-
-#define IN_FUNC_IN(fnc) \
-XN_FUNC_YN(uchar, fnc, uchar) \
-XN_FUNC_YN(char, fnc, char) \
-XN_FUNC_YN(ushort, fnc, ushort) \
-XN_FUNC_YN(short, fnc, short) \
-XN_FUNC_YN(uint, fnc, uint) \
-XN_FUNC_YN(int, fnc, int)
-
-
-#define XN_FUNC_XN_XN_BODY(type, fnc, body) \
-_RS_RUNTIME type __attribute__((overloadable)) \
- fnc(type v1, type v2); \
-_RS_RUNTIME type##2 __attribute__((overloadable)) \
- fnc(type##2 v1, type##2 v2); \
-_RS_RUNTIME type##3 __attribute__((overloadable)) \
- fnc(type##3 v1, type##3 v2); \
-_RS_RUNTIME type##4 __attribute__((overloadable)) \
- fnc(type##4 v1, type##4 v2);
-
-#define IN_FUNC_IN_IN_BODY(fnc, body) \
-XN_FUNC_XN_XN_BODY(uchar, fnc, body) \
-XN_FUNC_XN_XN_BODY(char, fnc, body) \
-XN_FUNC_XN_XN_BODY(ushort, fnc, body) \
-XN_FUNC_XN_XN_BODY(short, fnc, body) \
-XN_FUNC_XN_XN_BODY(uint, fnc, body) \
-XN_FUNC_XN_XN_BODY(int, fnc, body) \
-XN_FUNC_XN_XN_BODY(float, fnc, body)
-
-UIN_FUNC_IN(abs)
-IN_FUNC_IN(clz)
-
-/**
- * Return the minimum of two values.
- *
- * Supports 1,2,3,4 components of uchar, char, ushort, short, uint, int, float.
- */
-IN_FUNC_IN_IN_BODY(min, (v1 < v2 ? v1 : v2))
-FN_FUNC_FN_F(min)
-
-/**
- * Return the maximum of two values.
- *
- * Supports 1,2,3,4 components of uchar, char, ushort, short, uint, int, float.
- */
-IN_FUNC_IN_IN_BODY(max, (v1 > v2 ? v1 : v2))
-FN_FUNC_FN_F(max)
-
-/**
- * Clamp a value to a specified high and low bound.
- *
- * @param amount value to be clamped. Supports 1,2,3,4 components
- * @param low Lower bound, must be scalar or matching vector.
- * @param high High bound, must match type of low
- */
-_RS_RUNTIME float __attribute__((overloadable)) clamp(float amount, float low, float high);
-_RS_RUNTIME float2 __attribute__((overloadable)) clamp(float2 amount, float2 low, float2 high);
-_RS_RUNTIME float3 __attribute__((overloadable)) clamp(float3 amount, float3 low, float3 high);
-_RS_RUNTIME float4 __attribute__((overloadable)) clamp(float4 amount, float4 low, float4 high);
-_RS_RUNTIME float2 __attribute__((overloadable)) clamp(float2 amount, float low, float high);
-_RS_RUNTIME float3 __attribute__((overloadable)) clamp(float3 amount, float low, float high);
-_RS_RUNTIME float4 __attribute__((overloadable)) clamp(float4 amount, float low, float high);
-
-/**
- * Convert from radians to degrees.
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) degrees(float radians);
-FN_FUNC_FN(degrees)
-
-/**
- * return start + ((stop - start) * amount);
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) mix(float start, float stop, float amount);
-_RS_RUNTIME float2 __attribute__((overloadable)) mix(float2 start, float2 stop, float2 amount);
-_RS_RUNTIME float3 __attribute__((overloadable)) mix(float3 start, float3 stop, float3 amount);
-_RS_RUNTIME float4 __attribute__((overloadable)) mix(float4 start, float4 stop, float4 amount);
-_RS_RUNTIME float2 __attribute__((overloadable)) mix(float2 start, float2 stop, float amount);
-_RS_RUNTIME float3 __attribute__((overloadable)) mix(float3 start, float3 stop, float amount);
-_RS_RUNTIME float4 __attribute__((overloadable)) mix(float4 start, float4 stop, float amount);
-
-/**
- * Convert from degrees to radians.
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) radians(float degrees);
-FN_FUNC_FN(radians)
-
-/**
- * if (v < edge)
- * return 0.f;
- * else
- * return 1.f;
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) step(float edge, float v);
-_RS_RUNTIME float2 __attribute__((overloadable)) step(float2 edge, float2 v);
-_RS_RUNTIME float3 __attribute__((overloadable)) step(float3 edge, float3 v);
-_RS_RUNTIME float4 __attribute__((overloadable)) step(float4 edge, float4 v);
-_RS_RUNTIME float2 __attribute__((overloadable)) step(float2 edge, float v);
-_RS_RUNTIME float3 __attribute__((overloadable)) step(float3 edge, float v);
-_RS_RUNTIME float4 __attribute__((overloadable)) step(float4 edge, float v);
-
-// not implemented
-extern float __attribute__((overloadable)) smoothstep(float, float, float);
-extern float2 __attribute__((overloadable)) smoothstep(float2, float2, float2);
-extern float3 __attribute__((overloadable)) smoothstep(float3, float3, float3);
-extern float4 __attribute__((overloadable)) smoothstep(float4, float4, float4);
-extern float2 __attribute__((overloadable)) smoothstep(float, float, float2);
-extern float3 __attribute__((overloadable)) smoothstep(float, float, float3);
-extern float4 __attribute__((overloadable)) smoothstep(float, float, float4);
-
-/**
- * if (v < 0) return -1.f;
- * else if (v > 0) return 1.f;
- * else return 0.f;
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) sign(float v);
-FN_FUNC_FN(sign)
-
-/**
- * Compute the cross product of two vectors.
- *
- * Supports 3,4 components
- */
-_RS_RUNTIME float3 __attribute__((overloadable)) cross(float3 lhs, float3 rhs);
-_RS_RUNTIME float4 __attribute__((overloadable)) cross(float4 lhs, float4 rhs);
-
-/**
- * Compute the dot product of two vectors.
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) dot(float lhs, float rhs);
-_RS_RUNTIME float __attribute__((overloadable)) dot(float2 lhs, float2 rhs);
-_RS_RUNTIME float __attribute__((overloadable)) dot(float3 lhs, float3 rhs);
-_RS_RUNTIME float __attribute__((overloadable)) dot(float4 lhs, float4 rhs);
-
-/**
- * Compute the length of a vector.
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) length(float v);
-_RS_RUNTIME float __attribute__((overloadable)) length(float2 v);
-_RS_RUNTIME float __attribute__((overloadable)) length(float3 v);
-_RS_RUNTIME float __attribute__((overloadable)) length(float4 v);
-
-/**
- * Compute the distance between two points.
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) distance(float lhs, float rhs);
-_RS_RUNTIME float __attribute__((overloadable)) distance(float2 lhs, float2 rhs);
-_RS_RUNTIME float __attribute__((overloadable)) distance(float3 lhs, float3 rhs);
-_RS_RUNTIME float __attribute__((overloadable)) distance(float4 lhs, float4 rhs);
-
-/**
- * Normalize a vector.
- *
- * Supports 1,2,3,4 components
- */
-_RS_RUNTIME float __attribute__((overloadable)) normalize(float v);
-_RS_RUNTIME float2 __attribute__((overloadable)) normalize(float2 v);
-_RS_RUNTIME float3 __attribute__((overloadable)) normalize(float3 v);
-_RS_RUNTIME float4 __attribute__((overloadable)) normalize(float4 v);
-
-#undef CVT_FUNC
-#undef CVT_FUNC_2
-#undef FN_FUNC_FN
-#undef IN_FUNC_FN
-#undef FN_FUNC_FN_FN
-#undef FN_FUNC_FN_F
-#undef FN_FUNC_FN_IN
-#undef FN_FUNC_FN_I
-#undef FN_FUNC_FN_PFN
-#undef FN_FUNC_FN_PIN
-#undef FN_FUNC_FN_FN_FN
-#undef FN_FUNC_FN_FN_PIN
-#undef XN_FUNC_YN
-#undef UIN_FUNC_IN
-#undef IN_FUNC_IN
-#undef XN_FUNC_XN_XN_BODY
-#undef IN_FUNC_IN_IN_BODY
-
-#endif
diff --git a/libs/rs/scriptc/rs_core.rsh b/libs/rs/scriptc/rs_core.rsh
deleted file mode 100644
index 1b0f9db..0000000
--- a/libs/rs/scriptc/rs_core.rsh
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (C) 2011-2012 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.
- */
-
- /*! \mainpage notitle
- *
- * Renderscript is a high-performance runtime that provides graphics rendering and
- * compute operations at the native level. Renderscript code is compiled on devices
- * at runtime to allow platform-independence as well.
- * This reference documentation describes the Renderscript runtime APIs, which you
- * can utilize to write Renderscript code in C99. The Renderscript header
- * files are automatically included for you, except for the rs_graphics.rsh header. If
- * you are doing graphics rendering, include the graphics header file like this:
- *
- * <code>#include "rs_graphics.rsh"</code>
- *
- * To use Renderscript, you need to utilize the Renderscript runtime APIs documented here
- * as well as the Android framework APIs for Renderscript.
- * For documentation on the Android framework APIs, see the <a target="_parent" href=
- * "http://developer.android.com/reference/android/renderscript/package-summary.html">
- * android.renderscript</a> package reference.
- * For more information on how to develop with Renderscript and how the runtime and
- * Android framework APIs interact, see the <a target="_parent" href=
- * "http://developer.android.com/guide/topics/renderscript/index.html">Renderscript
- * developer guide</a> and the <a target="_parent" href=
- * "http://developer.android.com/resources/samples/RenderScript/index.html">
- * Renderscript samples</a>.
- */
-
-/** @file rs_core.rsh
- * \brief todo-jsams
- *
- * todo-jsams
- *
- */
-
-#ifndef __RS_CORE_RSH__
-#define __RS_CORE_RSH__
-
-#define _RS_RUNTIME extern
-
-#include "rs_types.rsh"
-#include "rs_allocation.rsh"
-#include "rs_atomic.rsh"
-#include "rs_cl.rsh"
-#include "rs_debug.rsh"
-#include "rs_element.rsh"
-#include "rs_math.rsh"
-#include "rs_matrix.rsh"
-#include "rs_object.rsh"
-#include "rs_quaternion.rsh"
-#include "rs_sampler.rsh"
-#include "rs_time.rsh"
-
-/**
- * Send a message back to the client. Will not block and returns true
- * if the message was sendable and false if the fifo was full.
- * A message ID is required. Data payload is optional.
- */
-extern bool __attribute__((overloadable))
- rsSendToClient(int cmdID);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
- rsSendToClient(int cmdID, const void *data, uint len);
-/**
- * Send a message back to the client, blocking until the message is queued.
- * A message ID is required. Data payload is optional.
- */
-extern void __attribute__((overloadable))
- rsSendToClientBlocking(int cmdID);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsSendToClientBlocking(int cmdID, const void *data, uint len);
-
-
-/**
- * Launch order hint for rsForEach calls. This provides a hint to the system to
- * determine in which order the root function of the target is called with each
- * cell of the allocation.
- *
- * This is a hint and implementations may not obey the order.
- */
-enum rs_for_each_strategy {
- RS_FOR_EACH_STRATEGY_SERIAL,
- RS_FOR_EACH_STRATEGY_DONT_CARE,
- RS_FOR_EACH_STRATEGY_DST_LINEAR,
- RS_FOR_EACH_STRATEGY_TILE_SMALL,
- RS_FOR_EACH_STRATEGY_TILE_MEDIUM,
- RS_FOR_EACH_STRATEGY_TILE_LARGE
-};
-
-
-/**
- * Structure to provide extra information to a rsForEach call. Primarly used to
- * restrict the call to a subset of cells in the allocation.
- */
-typedef struct rs_script_call {
- enum rs_for_each_strategy strategy;
- uint32_t xStart;
- uint32_t xEnd;
- uint32_t yStart;
- uint32_t yEnd;
- uint32_t zStart;
- uint32_t zEnd;
- uint32_t arrayStart;
- uint32_t arrayEnd;
-} rs_script_call_t;
-
-/**
- * Make a script to script call to launch work. One of the input or output is
- * required to be a valid object. The input and output must be of the same
- * dimensions.
- * API 10-13
- *
- * @param script The target script to call
- * @param input The allocation to source data from
- * @param output the allocation to write date into
- * @param usrData The user definied params to pass to the root script. May be
- * NULL.
- * @param sc Extra control infomation used to select a sub-region of the
- * allocation to be processed or suggest a walking strategy. May be
- * NULL.
- *
- * */
-#if !defined(RS_VERSION) || (RS_VERSION < 14)
-extern void __attribute__((overloadable))
- rsForEach(rs_script script, rs_allocation input,
- rs_allocation output, const void * usrData,
- const rs_script_call_t *sc);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsForEach(rs_script script, rs_allocation input,
- rs_allocation output, const void * usrData);
-#else
-
-/**
- * Make a script to script call to launch work. One of the input or output is
- * required to be a valid object. The input and output must be of the same
- * dimensions.
- * API 14+
- *
- * @param script The target script to call
- * @param input The allocation to source data from
- * @param output the allocation to write date into
- * @param usrData The user definied params to pass to the root script. May be
- * NULL.
- * @param usrDataLen The size of the userData structure. This will be used to
- * perform a shallow copy of the data if necessary.
- * @param sc Extra control infomation used to select a sub-region of the
- * allocation to be processed or suggest a walking strategy. May be
- * NULL.
- *
- */
-extern void __attribute__((overloadable))
- rsForEach(rs_script script, rs_allocation input, rs_allocation output,
- const void * usrData, size_t usrDataLen, const rs_script_call_t *);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsForEach(rs_script script, rs_allocation input, rs_allocation output,
- const void * usrData, size_t usrDataLen);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsForEach(rs_script script, rs_allocation input, rs_allocation output);
-#endif
-
-
-
-#undef _RS_RUNTIME
-
-#endif
diff --git a/libs/rs/scriptc/rs_debug.rsh b/libs/rs/scriptc/rs_debug.rsh
deleted file mode 100644
index 074c28f..0000000
--- a/libs/rs/scriptc/rs_debug.rsh
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/** @file rs_debug.rsh
- * \brief Utility debugging routines
- *
- * Routines intended to be used during application developement. These should
- * not be used in shipping applications. All print a string and value pair to
- * the standard log.
- *
- */
-
-#ifndef __RS_DEBUG_RSH__
-#define __RS_DEBUG_RSH__
-
-
-
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, float);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, float, float);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, float, float, float);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, float, float, float, float);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, double);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, const rs_matrix4x4 *);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, const rs_matrix3x3 *);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, const rs_matrix2x2 *);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, int);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, uint);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, long);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, unsigned long);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, long long);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, unsigned long long);
-/**
- * Debug function. Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
- rsDebug(const char *, const void *);
-#define RS_DEBUG(a) rsDebug(#a, a)
-#define RS_DEBUG_MARKER rsDebug(__FILE__, __LINE__)
-
-
-/**
- * Debug function. Prints a string and value to the log.
- */
-_RS_RUNTIME void __attribute__((overloadable)) rsDebug(const char *s, float2 v);
-/**
- * Debug function. Prints a string and value to the log.
- */
-_RS_RUNTIME void __attribute__((overloadable)) rsDebug(const char *s, float3 v);
-/**
- * Debug function. Prints a string and value to the log.
- */
-_RS_RUNTIME void __attribute__((overloadable)) rsDebug(const char *s, float4 v);
-
-#endif
diff --git a/libs/rs/scriptc/rs_element.rsh b/libs/rs/scriptc/rs_element.rsh
deleted file mode 100644
index 1a4cdb75..0000000
--- a/libs/rs/scriptc/rs_element.rsh
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-/** @file rs_element.rsh
- * \brief Element routines
- *
- *
- */
-
-#ifndef __RS_ELEMENT_RSH__
-#define __RS_ELEMENT_RSH__
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-
-/**
- * @param e element to get data from
- * @return number of sub-elements in this element
- */
-extern uint32_t __attribute__((overloadable))
- rsElementGetSubElementCount(rs_element e);
-
-/**
- * @param e element to get data from
- * @param index index of the sub-element to return
- * @return sub-element in this element at given index
- */
-extern rs_element __attribute__((overloadable))
- rsElementGetSubElement(rs_element, uint32_t index);
-
-/**
- * @param e element to get data from
- * @param index index of the sub-element to return
- * @return length of the sub-element name including the null
- * terminator (size of buffer needed to write the name)
- */
-extern uint32_t __attribute__((overloadable))
- rsElementGetSubElementNameLength(rs_element e, uint32_t index);
-
-/**
- * @param e element to get data from
- * @param index index of the sub-element
- * @param name array to store the name into
- * @param nameLength length of the provided name array
- * @return number of characters actually written, excluding the
- * null terminator
- */
-extern uint32_t __attribute__((overloadable))
- rsElementGetSubElementName(rs_element e, uint32_t index, char *name, uint32_t nameLength);
-
-/**
- * @param e element to get data from
- * @param index index of the sub-element
- * @return array size of sub-element in this element at given
- * index
- */
-extern uint32_t __attribute__((overloadable))
- rsElementGetSubElementArraySize(rs_element e, uint32_t index);
-
-/**
- * @param e element to get data from
- * @param index index of the sub-element
- * @return offset in bytes of sub-element in this element at
- * given index
- */
-extern uint32_t __attribute__((overloadable))
- rsElementGetSubElementOffsetBytes(rs_element e, uint32_t index);
-
-/**
- * @param e element to get data from
- * @return total size of the element in bytes
- */
-extern uint32_t __attribute__((overloadable))
- rsElementGetSizeBytes(rs_element e);
-
-/**
- * @param e element to get data from
- * @return element's data type
- */
-extern rs_data_type __attribute__((overloadable))
- rsElementGetDataType(rs_element e);
-
-/**
- * @param e element to get data from
- * @return element's data size
- */
-extern rs_data_kind __attribute__((overloadable))
- rsElementGetDataKind(rs_element e);
-
-/**
- * @param e element to get data from
- * @return length of the element vector (for float2, float3,
- * etc.)
- */
-extern uint32_t __attribute__((overloadable))
- rsElementGetVectorSize(rs_element e);
-
-#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
-
-#endif // __RS_ELEMENT_RSH__
-
diff --git a/libs/rs/scriptc/rs_graphics.rsh b/libs/rs/scriptc/rs_graphics.rsh
deleted file mode 100644
index 44ee99f..0000000
--- a/libs/rs/scriptc/rs_graphics.rsh
+++ /dev/null
@@ -1,421 +0,0 @@
-/*
- * Copyright (C) 2011-2012 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.
- */
-
-/** @file rs_graphics.rsh
- * \brief Renderscript graphics API
- *
- * A set of graphics functions used by Renderscript.
- *
- */
-#ifndef __RS_GRAPHICS_RSH__
-#define __RS_GRAPHICS_RSH__
-
-#include "rs_mesh.rsh"
-#include "rs_program.rsh"
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 14))
-/**
- * Set the color target used for all subsequent rendering calls
- * @param colorTarget
- * @param slot
- */
-extern void __attribute__((overloadable))
- rsgBindColorTarget(rs_allocation colorTarget, uint slot);
-
-/**
- * Clear the previously set color target
- * @param slot
- */
-extern void __attribute__((overloadable))
- rsgClearColorTarget(uint slot);
-
-/**
- * Set the depth target used for all subsequent rendering calls
- * @param depthTarget
- */
-extern void __attribute__((overloadable))
- rsgBindDepthTarget(rs_allocation depthTarget);
-
-/**
- * Clear the previously set depth target
- */
-extern void __attribute__((overloadable))
- rsgClearDepthTarget(void);
-
-/**
- * Clear all color and depth targets and resume rendering into
- * the framebuffer
- */
-extern void __attribute__((overloadable))
- rsgClearAllRenderTargets(void);
-
-/**
- * Force Renderscript to finish all rendering commands
- */
-extern uint __attribute__((overloadable))
- rsgFinish(void);
-
-#endif //defined(RS_VERSION) && (RS_VERSION >= 14)
-
-/**
- * Bind a new ProgramFragment to the rendering context.
- *
- * @param pf
- */
-extern void __attribute__((overloadable))
- rsgBindProgramFragment(rs_program_fragment pf);
-
-/**
- * Bind a new ProgramStore to the rendering context.
- *
- * @param ps
- */
-extern void __attribute__((overloadable))
- rsgBindProgramStore(rs_program_store ps);
-
-/**
- * Bind a new ProgramVertex to the rendering context.
- *
- * @param pv
- */
-extern void __attribute__((overloadable))
- rsgBindProgramVertex(rs_program_vertex pv);
-
-/**
- * Bind a new ProgramRaster to the rendering context.
- *
- * @param pr
- */
-extern void __attribute__((overloadable))
- rsgBindProgramRaster(rs_program_raster pr);
-
-/**
- * Bind a new Sampler object to a ProgramFragment. The sampler will
- * operate on the texture bound at the matching slot.
- *
- * @param slot
- */
-extern void __attribute__((overloadable))
- rsgBindSampler(rs_program_fragment, uint slot, rs_sampler);
-
-/**
- * Bind a new Allocation object to a ProgramFragment. The
- * Allocation must be a valid texture for the Program. The sampling
- * of the texture will be controled by the Sampler bound at the
- * matching slot.
- *
- * @param slot
- */
-extern void __attribute__((overloadable))
- rsgBindTexture(rs_program_fragment, uint slot, rs_allocation);
-
-/**
- * Load the projection matrix for a currently bound fixed function
- * vertex program. Calling this function with a custom vertex shader
- * would result in an error.
- * @param proj projection matrix
- */
-extern void __attribute__((overloadable))
- rsgProgramVertexLoadProjectionMatrix(const rs_matrix4x4 *proj);
-/**
- * Load the model matrix for a currently bound fixed function
- * vertex program. Calling this function with a custom vertex shader
- * would result in an error.
- * @param model model matrix
- */
-extern void __attribute__((overloadable))
- rsgProgramVertexLoadModelMatrix(const rs_matrix4x4 *model);
-/**
- * Load the texture matrix for a currently bound fixed function
- * vertex program. Calling this function with a custom vertex shader
- * would result in an error.
- * @param tex texture matrix
- */
-extern void __attribute__((overloadable))
- rsgProgramVertexLoadTextureMatrix(const rs_matrix4x4 *tex);
-/**
- * Get the projection matrix for a currently bound fixed function
- * vertex program. Calling this function with a custom vertex shader
- * would result in an error.
- * @param proj matrix to store the current projection matrix into
- */
-extern void __attribute__((overloadable))
- rsgProgramVertexGetProjectionMatrix(rs_matrix4x4 *proj);
-
-/**
- * Set the constant color for a fixed function emulation program.
- *
- * @param pf
- * @param r
- * @param g
- * @param b
- * @param a
- */
-extern void __attribute__((overloadable))
- rsgProgramFragmentConstantColor(rs_program_fragment pf, float r, float g, float b, float a);
-
-/**
- * Bind a new Allocation object to a ProgramFragment. The
- * Allocation must be a valid constant input for the Program.
- *
- * @param ps program object
- * @param slot index of the constant buffer on the program
- * @param c constants to bind
- */
-extern void __attribute__((overloadable))
- rsgBindConstant(rs_program_fragment ps, uint slot, rs_allocation c);
-
-/**
- * Bind a new Allocation object to a ProgramVertex. The
- * Allocation must be a valid constant input for the Program.
- *
- * @param pv program object
- * @param slot index of the constant buffer on the program
- * @param c constants to bind
- */
-extern void __attribute__((overloadable))
- rsgBindConstant(rs_program_vertex pv, uint slot, rs_allocation c);
-
-/**
- * Get the width of the current rendering surface.
- *
- * @return uint
- */
-extern uint __attribute__((overloadable))
- rsgGetWidth(void);
-
-/**
- * Get the height of the current rendering surface.
- *
- * @return uint
- */
-extern uint __attribute__((overloadable))
- rsgGetHeight(void);
-
-
-/**
- * Sync the contents of an allocation from its SCRIPT memory space to its HW
- * memory spaces.
- *
- * @param alloc
- */
-extern void __attribute__((overloadable))
- rsgAllocationSyncAll(rs_allocation alloc);
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 14))
-
-/**
- * Sync the contents of an allocation from memory space
- * specified by source.
- *
- * @param alloc
- * @param source
- */
-extern void __attribute__((overloadable))
- rsgAllocationSyncAll(rs_allocation alloc,
- rs_allocation_usage_type source);
-
-#endif //defined(RS_VERSION) && (RS_VERSION >= 14)
-
-/**
- * Low performance utility function for drawing a simple rectangle. Not
- * intended for drawing large quantities of geometry.
- *
- * @param x1
- * @param y1
- * @param x2
- * @param y2
- * @param z
- */
-extern void __attribute__((overloadable))
- rsgDrawRect(float x1, float y1, float x2, float y2, float z);
-
-/**
- * Low performance utility function for drawing a simple quad. Not intended for
- * drawing large quantities of geometry.
- *
- * @param x1
- * @param y1
- * @param z1
- * @param x2
- * @param y2
- * @param z2
- * @param x3
- * @param y3
- * @param z3
- * @param x4
- * @param y4
- * @param z4
- */
-extern void __attribute__((overloadable))
- rsgDrawQuad(float x1, float y1, float z1,
- float x2, float y2, float z2,
- float x3, float y3, float z3,
- float x4, float y4, float z4);
-
-
-/**
- * Low performance utility function for drawing a textured quad. Not intended
- * for drawing large quantities of geometry.
- *
- * @param x1
- * @param y1
- * @param z1
- * @param u1
- * @param v1
- * @param x2
- * @param y2
- * @param z2
- * @param u2
- * @param v2
- * @param x3
- * @param y3
- * @param z3
- * @param u3
- * @param v3
- * @param x4
- * @param y4
- * @param z4
- * @param u4
- * @param v4
- */
-extern void __attribute__((overloadable))
- rsgDrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1,
- float x2, float y2, float z2, float u2, float v2,
- float x3, float y3, float z3, float u3, float v3,
- float x4, float y4, float z4, float u4, float v4);
-
-
-/**
- * Low performance function for drawing rectangles in screenspace. This
- * function uses the default passthough ProgramVertex. Any bound ProgramVertex
- * is ignored. This function has considerable overhead and should not be used
- * for drawing in shipping applications.
- *
- * @param x
- * @param y
- * @param z
- * @param w
- * @param h
- */
-extern void __attribute__((overloadable))
- rsgDrawSpriteScreenspace(float x, float y, float z, float w, float h);
-
-extern void __attribute__((overloadable))
- rsgDrawPath(rs_path p);
-
-/**
- * Draw a mesh using the current context state. The whole mesh is
- * rendered.
- *
- * @param ism
- */
-extern void __attribute__((overloadable))
- rsgDrawMesh(rs_mesh ism);
-/**
- * Draw part of a mesh using the current context state.
- * @param ism mesh object to render
- * @param primitiveIndex for meshes that contain multiple primitive groups
- * this parameter specifies the index of the group to draw.
- */
-extern void __attribute__((overloadable))
- rsgDrawMesh(rs_mesh ism, uint primitiveIndex);
-/**
- * Draw specified index range of part of a mesh using the current context state.
- * @param ism mesh object to render
- * @param primitiveIndex for meshes that contain multiple primitive groups
- * this parameter specifies the index of the group to draw.
- * @param start starting index in the range
- * @param len number of indices to draw
- */
-extern void __attribute__((overloadable))
- rsgDrawMesh(rs_mesh ism, uint primitiveIndex, uint start, uint len);
-
-/**
- * Clears the rendering surface to the specified color.
- *
- * @param r
- * @param g
- * @param b
- * @param a
- */
-extern void __attribute__((overloadable))
- rsgClearColor(float r, float g, float b, float a);
-
-/**
- * Clears the depth suface to the specified value.
- */
-extern void __attribute__((overloadable))
- rsgClearDepth(float value);
-/**
- * Draws text given a string and location
- */
-extern void __attribute__((overloadable))
- rsgDrawText(const char *, int x, int y);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsgDrawText(rs_allocation, int x, int y);
-/**
- * Binds the font object to be used for all subsequent font rendering calls
- * @param font object to bind
- */
-extern void __attribute__((overloadable))
- rsgBindFont(rs_font font);
-/**
- * Sets the font color for all subsequent rendering calls
- * @param r red component
- * @param g green component
- * @param b blue component
- * @param a alpha component
- */
-extern void __attribute__((overloadable))
- rsgFontColor(float r, float g, float b, float a);
-/**
- * Returns the bounding box of the text relative to (0, 0)
- * Any of left, right, top, bottom could be NULL
- */
-extern void __attribute__((overloadable))
- rsgMeasureText(const char *, int *left, int *right, int *top, int *bottom);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsgMeasureText(rs_allocation, int *left, int *right, int *top, int *bottom);
-/**
- * Computes an axis aligned bounding box of a mesh object
- */
-extern void __attribute__((overloadable))
- rsgMeshComputeBoundingBox(rs_mesh mesh, float *minX, float *minY, float *minZ,
- float *maxX, float *maxY, float *maxZ);
-/**
- * \overload
- */
-__inline__ static void __attribute__((overloadable, always_inline))
-rsgMeshComputeBoundingBox(rs_mesh mesh, float3 *bBoxMin, float3 *bBoxMax) {
- float x1, y1, z1, x2, y2, z2;
- rsgMeshComputeBoundingBox(mesh, &x1, &y1, &z1, &x2, &y2, &z2);
- bBoxMin->x = x1;
- bBoxMin->y = y1;
- bBoxMin->z = z1;
- bBoxMax->x = x2;
- bBoxMax->y = y2;
- bBoxMax->z = z2;
-}
-
-#endif
-
diff --git a/libs/rs/scriptc/rs_math.rsh b/libs/rs/scriptc/rs_math.rsh
deleted file mode 100644
index 8117ca8..0000000
--- a/libs/rs/scriptc/rs_math.rsh
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/** @file rs_math.rsh
- * \brief todo-jsams
- *
- * todo-jsams
- *
- */
-
-#ifndef __RS_MATH_RSH__
-#define __RS_MATH_RSH__
-
-
-/**
- * Return a random value between 0 (or min_value) and max_malue.
- */
-extern int __attribute__((overloadable))
- rsRand(int max_value);
-/**
- * \overload
- */
-extern int __attribute__((overloadable))
- rsRand(int min_value, int max_value);
-/**
- * \overload
- */
-extern float __attribute__((overloadable))
- rsRand(float max_value);
-/**
- * \overload
- */
-extern float __attribute__((overloadable))
- rsRand(float min_value, float max_value);
-
-/**
- * Returns the fractional part of a float
- */
-extern float __attribute__((overloadable))
- rsFrac(float);
-
-
-/////////////////////////////////////////////////////
-// int ops
-/////////////////////////////////////////////////////
-
-/**
- * Clamp the value amount between low and high.
- *
- * @param amount The value to clamp
- * @param low
- * @param high
- */
-_RS_RUNTIME uint __attribute__((overloadable, always_inline)) rsClamp(uint amount, uint low, uint high);
-
-/**
- * \overload
- */
-_RS_RUNTIME int __attribute__((overloadable, always_inline)) rsClamp(int amount, int low, int high);
-/**
- * \overload
- */
-_RS_RUNTIME ushort __attribute__((overloadable, always_inline)) rsClamp(ushort amount, ushort low, ushort high);
-/**
- * \overload
- */
-_RS_RUNTIME short __attribute__((overloadable, always_inline)) rsClamp(short amount, short low, short high);
-/**
- * \overload
- */
-_RS_RUNTIME uchar __attribute__((overloadable, always_inline)) rsClamp(uchar amount, uchar low, uchar high);
-/**
- * \overload
- */
-_RS_RUNTIME char __attribute__((overloadable, always_inline)) rsClamp(char amount, char low, char high);
-
-
-/**
- * Computes 6 frustum planes from the view projection matrix
- * @param viewProj matrix to extract planes from
- * @param left plane
- * @param right plane
- * @param top plane
- * @param bottom plane
- * @param near plane
- * @param far plane
- */
-__inline__ static void __attribute__((overloadable, always_inline))
-rsExtractFrustumPlanes(const rs_matrix4x4 *viewProj,
- float4 *left, float4 *right,
- float4 *top, float4 *bottom,
- float4 *near, float4 *far) {
- // x y z w = a b c d in the plane equation
- left->x = viewProj->m[3] + viewProj->m[0];
- left->y = viewProj->m[7] + viewProj->m[4];
- left->z = viewProj->m[11] + viewProj->m[8];
- left->w = viewProj->m[15] + viewProj->m[12];
-
- right->x = viewProj->m[3] - viewProj->m[0];
- right->y = viewProj->m[7] - viewProj->m[4];
- right->z = viewProj->m[11] - viewProj->m[8];
- right->w = viewProj->m[15] - viewProj->m[12];
-
- top->x = viewProj->m[3] - viewProj->m[1];
- top->y = viewProj->m[7] - viewProj->m[5];
- top->z = viewProj->m[11] - viewProj->m[9];
- top->w = viewProj->m[15] - viewProj->m[13];
-
- bottom->x = viewProj->m[3] + viewProj->m[1];
- bottom->y = viewProj->m[7] + viewProj->m[5];
- bottom->z = viewProj->m[11] + viewProj->m[9];
- bottom->w = viewProj->m[15] + viewProj->m[13];
-
- near->x = viewProj->m[3] + viewProj->m[2];
- near->y = viewProj->m[7] + viewProj->m[6];
- near->z = viewProj->m[11] + viewProj->m[10];
- near->w = viewProj->m[15] + viewProj->m[14];
-
- far->x = viewProj->m[3] - viewProj->m[2];
- far->y = viewProj->m[7] - viewProj->m[6];
- far->z = viewProj->m[11] - viewProj->m[10];
- far->w = viewProj->m[15] - viewProj->m[14];
-
- float len = length(left->xyz);
- *left /= len;
- len = length(right->xyz);
- *right /= len;
- len = length(top->xyz);
- *top /= len;
- len = length(bottom->xyz);
- *bottom /= len;
- len = length(near->xyz);
- *near /= len;
- len = length(far->xyz);
- *far /= len;
-}
-
-/**
- * Checks if a sphere is withing the 6 frustum planes
- * @param sphere float4 representing the sphere
- * @param left plane
- * @param right plane
- * @param top plane
- * @param bottom plane
- * @param near plane
- * @param far plane
- */
-__inline__ static bool __attribute__((overloadable, always_inline))
-rsIsSphereInFrustum(float4 *sphere,
- float4 *left, float4 *right,
- float4 *top, float4 *bottom,
- float4 *near, float4 *far) {
-
- float distToCenter = dot(left->xyz, sphere->xyz) + left->w;
- if (distToCenter < -sphere->w) {
- return false;
- }
- distToCenter = dot(right->xyz, sphere->xyz) + right->w;
- if (distToCenter < -sphere->w) {
- return false;
- }
- distToCenter = dot(top->xyz, sphere->xyz) + top->w;
- if (distToCenter < -sphere->w) {
- return false;
- }
- distToCenter = dot(bottom->xyz, sphere->xyz) + bottom->w;
- if (distToCenter < -sphere->w) {
- return false;
- }
- distToCenter = dot(near->xyz, sphere->xyz) + near->w;
- if (distToCenter < -sphere->w) {
- return false;
- }
- distToCenter = dot(far->xyz, sphere->xyz) + far->w;
- if (distToCenter < -sphere->w) {
- return false;
- }
- return true;
-}
-
-
-/**
- * Pack floating point (0-1) RGB values into a uchar4. The alpha component is
- * set to 255 (1.0).
- *
- * @param r
- * @param g
- * @param b
- *
- * @return uchar4
- */
-_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float r, float g, float b);
-
-/**
- * Pack floating point (0-1) RGBA values into a uchar4.
- *
- * @param r
- * @param g
- * @param b
- * @param a
- *
- * @return uchar4
- */
-_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float r, float g, float b, float a);
-
-/**
- * Pack floating point (0-1) RGB values into a uchar4. The alpha component is
- * set to 255 (1.0).
- *
- * @param color
- *
- * @return uchar4
- */
-_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float3 color);
-
-/**
- * Pack floating point (0-1) RGBA values into a uchar4.
- *
- * @param color
- *
- * @return uchar4
- */
-_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float4 color);
-
-/**
- * Unpack a uchar4 color to float4. The resulting float range will be (0-1).
- *
- * @param c
- *
- * @return float4
- */
-_RS_RUNTIME float4 rsUnpackColor8888(uchar4 c);
-
-
-#endif
diff --git a/libs/rs/scriptc/rs_matrix.rsh b/libs/rs/scriptc/rs_matrix.rsh
deleted file mode 100644
index ebff7f4..0000000
--- a/libs/rs/scriptc/rs_matrix.rsh
+++ /dev/null
@@ -1,378 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/** @file rs_matrix.rsh
- * \brief Matrix routines
- *
- *
- */
-
-#ifndef __RS_MATRIX_RSH__
-#define __RS_MATRIX_RSH__
-
-/**
- * Set one element of a matrix.
- *
- * @param m The matrix to be set
- * @param row
- * @param col
- * @param v
- *
- * @return void
- */
-_RS_RUNTIME void __attribute__((overloadable))
-rsMatrixSet(rs_matrix4x4 *m, uint32_t row, uint32_t col, float v);
-/**
- * \overload
- */
-_RS_RUNTIME void __attribute__((overloadable))
-rsMatrixSet(rs_matrix3x3 *m, uint32_t row, uint32_t col, float v);
-/**
- * \overload
- */
-_RS_RUNTIME void __attribute__((overloadable))
-rsMatrixSet(rs_matrix2x2 *m, uint32_t row, uint32_t col, float v);
-
-/**
- * Get one element of a matrix.
- *
- * @param m The matrix to read from
- * @param row
- * @param col
- *
- * @return float
- */
-_RS_RUNTIME float __attribute__((overloadable))
-rsMatrixGet(const rs_matrix4x4 *m, uint32_t row, uint32_t col);
-/**
- * \overload
- */
-_RS_RUNTIME float __attribute__((overloadable))
-rsMatrixGet(const rs_matrix3x3 *m, uint32_t row, uint32_t col);
-/**
- * \overload
- */
-_RS_RUNTIME float __attribute__((overloadable))
-rsMatrixGet(const rs_matrix2x2 *m, uint32_t row, uint32_t col);
-
-/**
- * Set the elements of a matrix to the identity matrix.
- *
- * @param m
- */
-extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix4x4 *m);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix3x3 *m);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix2x2 *m);
-
-/**
- * Set the elements of a matrix from an array of floats.
- *
- * @param m
- */
-extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const float *v);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix3x3 *m, const float *v);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix2x2 *m, const float *v);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix4x4 *v);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix3x3 *v);
-
-/**
- * Set the elements of a matrix from another matrix.
- *
- * @param m
- */
-extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix2x2 *v);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix3x3 *m, const rs_matrix3x3 *v);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix2x2 *m, const rs_matrix2x2 *v);
-
-/**
- * Load a rotation matrix.
- *
- * @param m
- * @param rot
- * @param x
- * @param y
- * @param z
- */
-extern void __attribute__((overloadable))
-rsMatrixLoadRotate(rs_matrix4x4 *m, float rot, float x, float y, float z);
-
-/**
- * Load a scale matrix.
- *
- * @param m
- * @param x
- * @param y
- * @param z
- */
-extern void __attribute__((overloadable))
-rsMatrixLoadScale(rs_matrix4x4 *m, float x, float y, float z);
-
-/**
- * Load a translation matrix.
- *
- * @param m
- * @param x
- * @param y
- * @param z
- */
-extern void __attribute__((overloadable))
-rsMatrixLoadTranslate(rs_matrix4x4 *m, float x, float y, float z);
-
-/**
- * Multiply two matrix (lhs, rhs) and place the result in m.
- *
- * @param m
- * @param lhs
- * @param rhs
- */
-extern void __attribute__((overloadable))
-rsMatrixLoadMultiply(rs_matrix4x4 *m, const rs_matrix4x4 *lhs, const rs_matrix4x4 *rhs);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-rsMatrixLoadMultiply(rs_matrix3x3 *m, const rs_matrix3x3 *lhs, const rs_matrix3x3 *rhs);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-rsMatrixLoadMultiply(rs_matrix2x2 *m, const rs_matrix2x2 *lhs, const rs_matrix2x2 *rhs);
-
-/**
- * Multiply the matrix m by rhs and place the result back into m.
- *
- * @param m (lhs)
- * @param rhs
- */
-extern void __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix4x4 *m, const rs_matrix4x4 *rhs);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix3x3 *m, const rs_matrix3x3 *rhs);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix2x2 *m, const rs_matrix2x2 *rhs);
-
-/**
- * Multiple matrix m with a rotation matrix
- *
- * @param m
- * @param rot
- * @param x
- * @param y
- * @param z
- */
-extern void __attribute__((overloadable))
-rsMatrixRotate(rs_matrix4x4 *m, float rot, float x, float y, float z);
-
-/**
- * Multiple matrix m with a scale matrix
- *
- * @param m
- * @param x
- * @param y
- * @param z
- */
-extern void __attribute__((overloadable))
-rsMatrixScale(rs_matrix4x4 *m, float x, float y, float z);
-
-/**
- * Multiple matrix m with a translation matrix
- *
- * @param m
- * @param x
- * @param y
- * @param z
- */
-extern void __attribute__((overloadable))
-rsMatrixTranslate(rs_matrix4x4 *m, float x, float y, float z);
-
-/**
- * Load an Ortho projection matrix constructed from the 6 planes
- *
- * @param m
- * @param left
- * @param right
- * @param bottom
- * @param top
- * @param near
- * @param far
- */
-extern void __attribute__((overloadable))
-rsMatrixLoadOrtho(rs_matrix4x4 *m, float left, float right, float bottom, float top, float near, float far);
-
-/**
- * Load an Frustum projection matrix constructed from the 6 planes
- *
- * @param m
- * @param left
- * @param right
- * @param bottom
- * @param top
- * @param near
- * @param far
- */
-extern void __attribute__((overloadable))
-rsMatrixLoadFrustum(rs_matrix4x4 *m, float left, float right, float bottom, float top, float near, float far);
-
-/**
- * Load an perspective projection matrix constructed from the 6 planes
- *
- * @param m
- * @param fovy Field of view, in degrees along the Y axis.
- * @param aspect Ratio of x / y.
- * @param near
- * @param far
- */
-extern void __attribute__((overloadable))
-rsMatrixLoadPerspective(rs_matrix4x4* m, float fovy, float aspect, float near, float far);
-
-#if !defined(RS_VERSION) || (RS_VERSION < 14)
-/**
- * Multiply a vector by a matrix and return the result vector.
- * API version 10-13
- */
-_RS_RUNTIME float4 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix4x4 *m, float4 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float4 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix4x4 *m, float3 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float4 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix4x4 *m, float2 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float3 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix3x3 *m, float3 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float3 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix3x3 *m, float2 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float2 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix2x2 *m, float2 in);
-#else
-/**
- * Multiply a vector by a matrix and return the result vector.
- * API version 14+
- */
-_RS_RUNTIME float4 __attribute__((overloadable))
-rsMatrixMultiply(const rs_matrix4x4 *m, float4 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float4 __attribute__((overloadable))
-rsMatrixMultiply(const rs_matrix4x4 *m, float3 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float4 __attribute__((overloadable))
-rsMatrixMultiply(const rs_matrix4x4 *m, float2 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float3 __attribute__((overloadable))
-rsMatrixMultiply(const rs_matrix3x3 *m, float3 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float3 __attribute__((overloadable))
-rsMatrixMultiply(const rs_matrix3x3 *m, float2 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float2 __attribute__((overloadable))
-rsMatrixMultiply(const rs_matrix2x2 *m, float2 in);
-#endif
-
-
-/**
- * Returns true if the matrix was successfully inversed
- *
- * @param m
- */
-extern bool __attribute__((overloadable)) rsMatrixInverse(rs_matrix4x4 *m);
-
-/**
- * Returns true if the matrix was successfully inversed and transposed.
- *
- * @param m
- */
-extern bool __attribute__((overloadable)) rsMatrixInverseTranspose(rs_matrix4x4 *m);
-
-/**
- * Transpose the matrix m.
- *
- * @param m
- */
-extern void __attribute__((overloadable)) rsMatrixTranspose(rs_matrix4x4 *m);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixTranspose(rs_matrix3x3 *m);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixTranspose(rs_matrix2x2 *m);
-
-
-#endif
diff --git a/libs/rs/scriptc/rs_mesh.rsh b/libs/rs/scriptc/rs_mesh.rsh
deleted file mode 100644
index 87ffd33..0000000
--- a/libs/rs/scriptc/rs_mesh.rsh
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-/** @file rs_mesh.rsh
- * \brief Mesh routines
- *
- *
- */
-
-#ifndef __RS_MESH_RSH__
-#define __RS_MESH_RSH__
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-
-/**
- * @param m mesh to get data from
- * @return number of allocations in the mesh that contain vertex
- * data
- */
-extern uint32_t __attribute__((overloadable))
- rsgMeshGetVertexAllocationCount(rs_mesh m);
-
-/**
- * @param m mesh to get data from
- * @return number of primitive groups in the mesh. This would
- * include simple primitives as well as allocations
- * containing index data
- */
-extern uint32_t __attribute__((overloadable))
- rsgMeshGetPrimitiveCount(rs_mesh m);
-
-/**
- * @param m mesh to get data from
- * @param index index of the vertex allocation
- * @return allocation containing vertex data
- */
-extern rs_allocation __attribute__((overloadable))
- rsgMeshGetVertexAllocation(rs_mesh m, uint32_t index);
-
-/**
- * @param m mesh to get data from
- * @param index index of the index allocation
- * @return allocation containing index data
- */
-extern rs_allocation __attribute__((overloadable))
- rsgMeshGetIndexAllocation(rs_mesh m, uint32_t index);
-
-/**
- * @param m mesh to get data from
- * @param index index of the primitive
- * @return primitive describing how the mesh is rendered
- */
-extern rs_primitive __attribute__((overloadable))
- rsgMeshGetPrimitive(rs_mesh m, uint32_t index);
-
-#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
-
-#endif // __RS_MESH_RSH__
-
diff --git a/libs/rs/scriptc/rs_object.rsh b/libs/rs/scriptc/rs_object.rsh
deleted file mode 100644
index 1fc3f83..0000000
--- a/libs/rs/scriptc/rs_object.rsh
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/** @file rs_object.rsh
- * \brief Object routines
- *
- *
- */
-
-#ifndef __RS_OBJECT_RSH__
-#define __RS_OBJECT_RSH__
-
-
-/**
- * Copy reference to the specified object.
- *
- * @param dst
- * @param src
- */
-extern void __attribute__((overloadable))
- rsSetObject(rs_element *dst, rs_element src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsSetObject(rs_type *dst, rs_type src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsSetObject(rs_allocation *dst, rs_allocation src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsSetObject(rs_sampler *dst, rs_sampler src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsSetObject(rs_script *dst, rs_script src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsSetObject(rs_path *dst, rs_path src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsSetObject(rs_mesh *dst, rs_mesh src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsSetObject(rs_program_fragment *dst, rs_program_fragment src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsSetObject(rs_program_vertex *dst, rs_program_vertex src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsSetObject(rs_program_raster *dst, rs_program_raster src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsSetObject(rs_program_store *dst, rs_program_store src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsSetObject(rs_font *dst, rs_font src);
-
-/**
- * Sets the object to NULL.
- *
- * @return bool
- */
-extern void __attribute__((overloadable))
- rsClearObject(rs_element *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsClearObject(rs_type *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsClearObject(rs_allocation *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsClearObject(rs_sampler *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsClearObject(rs_script *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsClearObject(rs_path *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsClearObject(rs_mesh *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsClearObject(rs_program_fragment *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsClearObject(rs_program_vertex *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsClearObject(rs_program_raster *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsClearObject(rs_program_store *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
- rsClearObject(rs_font *dst);
-
-
-
-/**
- * Tests if the object is valid. Returns true if the object is valid, false if
- * it is NULL.
- *
- * @return bool
- */
-extern bool __attribute__((overloadable))
- rsIsObject(rs_element);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
- rsIsObject(rs_type);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
- rsIsObject(rs_allocation);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
- rsIsObject(rs_sampler);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
- rsIsObject(rs_script);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
- rsIsObject(rs_path);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
- rsIsObject(rs_mesh);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
- rsIsObject(rs_program_fragment);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
- rsIsObject(rs_program_vertex);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
- rsIsObject(rs_program_raster);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
- rsIsObject(rs_program_store);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
- rsIsObject(rs_font);
-
-#endif
diff --git a/libs/rs/scriptc/rs_program.rsh b/libs/rs/scriptc/rs_program.rsh
deleted file mode 100644
index 6a9929e..0000000
--- a/libs/rs/scriptc/rs_program.rsh
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-/** @file rs_program.rsh
- * \brief Program object routines
- *
- *
- */
-
-#ifndef __RS_PROGRAM_RSH__
-#define __RS_PROGRAM_RSH__
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-
-/**
- * @hide
- * Get program store depth function
- *
- * @param ps
- */
-extern rs_depth_func __attribute__((overloadable))
- rsgProgramStoreGetDepthFunc(rs_program_store ps);
-
-/**
- * @hide
- * Get program store depth mask
- *
- * @param ps
- */
-extern bool __attribute__((overloadable))
- rsgProgramStoreGetDepthMask(rs_program_store ps);
-/**
- * @hide
- * Get program store red component color mask
- *
- * @param ps
- */
-extern bool __attribute__((overloadable))
- rsgProgramStoreGetColorMaskR(rs_program_store ps);
-
-/**
- * @hide
- * Get program store green component color mask
- *
- * @param ps
- */
-extern bool __attribute__((overloadable))
- rsgProgramStoreGetColorMaskG(rs_program_store ps);
-
-/**
- * @hide
- * Get program store blur component color mask
- *
- * @param ps
- */
-extern bool __attribute__((overloadable))
- rsgProgramStoreGetColorMaskB(rs_program_store ps);
-
-/**
- * @hide
- * Get program store alpha component color mask
- *
- * @param ps
- */
-extern bool __attribute__((overloadable))
- rsgProgramStoreGetColorMaskA(rs_program_store ps);
-
-/**
- * @hide
- * Get program store blend source function
- *
- * @param ps
- */
-extern rs_blend_src_func __attribute__((overloadable))
- rsgProgramStoreGetBlendSrcFunc(rs_program_store ps);
-
-/**
- * @hide
- * Get program store blend destination function
- *
- * @param ps
- */
-extern rs_blend_dst_func __attribute__((overloadable))
- rsgProgramStoreGetBlendDstFunc(rs_program_store ps);
-
-/**
- * @hide
- * Get program store dither state
- *
- * @param ps
- */
-extern bool __attribute__((overloadable))
- rsgProgramStoreGetDitherEnabled(rs_program_store ps);
-
-/**
- * @hide
- * Get program raster point sprite state
- *
- * @param pr
- */
-extern bool __attribute__((overloadable))
- rsgProgramRasterGetPointSpriteEnabled(rs_program_raster pr);
-
-/**
- * @hide
- * Get program raster cull mode
- *
- * @param pr
- */
-extern rs_cull_mode __attribute__((overloadable))
- rsgProgramRasterGetCullMode(rs_program_raster pr);
-
-#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
-
-#endif // __RS_PROGRAM_RSH__
-
diff --git a/libs/rs/scriptc/rs_quaternion.rsh b/libs/rs/scriptc/rs_quaternion.rsh
deleted file mode 100644
index 4e08d2f..0000000
--- a/libs/rs/scriptc/rs_quaternion.rsh
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/** @file rs_quaternion.rsh
- * \brief Quaternion routines
- *
- *
- */
-
-#ifndef __RS_QUATERNION_RSH__
-#define __RS_QUATERNION_RSH__
-
-
-/**
- * Set the quaternion components
- * @param w component
- * @param x component
- * @param y component
- * @param z component
- */
-static void __attribute__((overloadable))
-rsQuaternionSet(rs_quaternion *q, float w, float x, float y, float z) {
- q->w = w;
- q->x = x;
- q->y = y;
- q->z = z;
-}
-
-/**
- * Set the quaternion from another quaternion
- * @param q destination quaternion
- * @param rhs source quaternion
- */
-static void __attribute__((overloadable))
-rsQuaternionSet(rs_quaternion *q, const rs_quaternion *rhs) {
- q->w = rhs->w;
- q->x = rhs->x;
- q->y = rhs->y;
- q->z = rhs->z;
-}
-
-/**
- * Multiply quaternion by a scalar
- * @param q quaternion to multiply
- * @param s scalar
- */
-static void __attribute__((overloadable))
-rsQuaternionMultiply(rs_quaternion *q, float s) {
- q->w *= s;
- q->x *= s;
- q->y *= s;
- q->z *= s;
-}
-
-/**
- * Add two quaternions
- * @param q destination quaternion to add to
- * @param rsh right hand side quaternion to add
- */
-static void
-rsQuaternionAdd(rs_quaternion *q, const rs_quaternion *rhs) {
- q->w *= rhs->w;
- q->x *= rhs->x;
- q->y *= rhs->y;
- q->z *= rhs->z;
-}
-
-/**
- * Loads a quaternion that represents a rotation about an arbitrary unit vector
- * @param q quaternion to set
- * @param rot angle to rotate by
- * @param x component of a vector
- * @param y component of a vector
- * @param x component of a vector
- */
-static void
-rsQuaternionLoadRotateUnit(rs_quaternion *q, float rot, float x, float y, float z) {
- rot *= (float)(M_PI / 180.0f) * 0.5f;
- float c = cos(rot);
- float s = sin(rot);
-
- q->w = c;
- q->x = x * s;
- q->y = y * s;
- q->z = z * s;
-}
-
-/**
- * Loads a quaternion that represents a rotation about an arbitrary vector
- * (doesn't have to be unit)
- * @param q quaternion to set
- * @param rot angle to rotate by
- * @param x component of a vector
- * @param y component of a vector
- * @param x component of a vector
- */
-static void
-rsQuaternionLoadRotate(rs_quaternion *q, float rot, float x, float y, float z) {
- const float len = x*x + y*y + z*z;
- if (len != 1) {
- const float recipLen = 1.f / sqrt(len);
- x *= recipLen;
- y *= recipLen;
- z *= recipLen;
- }
- rsQuaternionLoadRotateUnit(q, rot, x, y, z);
-}
-
-/**
- * Conjugates the quaternion
- * @param q quaternion to conjugate
- */
-static void
-rsQuaternionConjugate(rs_quaternion *q) {
- q->x = -q->x;
- q->y = -q->y;
- q->z = -q->z;
-}
-
-/**
- * Dot product of two quaternions
- * @param q0 first quaternion
- * @param q1 second quaternion
- * @return dot product between q0 and q1
- */
-static float
-rsQuaternionDot(const rs_quaternion *q0, const rs_quaternion *q1) {
- return q0->w*q1->w + q0->x*q1->x + q0->y*q1->y + q0->z*q1->z;
-}
-
-/**
- * Normalizes the quaternion
- * @param q quaternion to normalize
- */
-static void
-rsQuaternionNormalize(rs_quaternion *q) {
- const float len = rsQuaternionDot(q, q);
- if (len != 1) {
- const float recipLen = 1.f / sqrt(len);
- rsQuaternionMultiply(q, recipLen);
- }
-}
-
-/**
- * Multiply quaternion by another quaternion
- * @param q destination quaternion
- * @param rhs right hand side quaternion to multiply by
- */
-static void __attribute__((overloadable))
-rsQuaternionMultiply(rs_quaternion *q, const rs_quaternion *rhs) {
- rs_quaternion qtmp;
- rsQuaternionSet(&qtmp, q);
-
- q->w = qtmp.w*rhs->w - qtmp.x*rhs->x - qtmp.y*rhs->y - qtmp.z*rhs->z;
- q->x = qtmp.w*rhs->x + qtmp.x*rhs->w + qtmp.y*rhs->z - qtmp.z*rhs->y;
- q->y = qtmp.w*rhs->y + qtmp.y*rhs->w + qtmp.z*rhs->x - qtmp.x*rhs->z;
- q->z = qtmp.w*rhs->z + qtmp.z*rhs->w + qtmp.x*rhs->y - qtmp.y*rhs->x;
- rsQuaternionNormalize(q);
-}
-
-/**
- * Performs spherical linear interpolation between two quaternions
- * @param q result quaternion from interpolation
- * @param q0 first param
- * @param q1 second param
- * @param t how much to interpolate by
- */
-static void
-rsQuaternionSlerp(rs_quaternion *q, const rs_quaternion *q0, const rs_quaternion *q1, float t) {
- if (t <= 0.0f) {
- rsQuaternionSet(q, q0);
- return;
- }
- if (t >= 1.0f) {
- rsQuaternionSet(q, q1);
- return;
- }
-
- rs_quaternion tempq0, tempq1;
- rsQuaternionSet(&tempq0, q0);
- rsQuaternionSet(&tempq1, q1);
-
- float angle = rsQuaternionDot(q0, q1);
- if (angle < 0) {
- rsQuaternionMultiply(&tempq0, -1.0f);
- angle *= -1.0f;
- }
-
- float scale, invScale;
- if (angle + 1.0f > 0.05f) {
- if (1.0f - angle >= 0.05f) {
- float theta = acos(angle);
- float invSinTheta = 1.0f / sin(theta);
- scale = sin(theta * (1.0f - t)) * invSinTheta;
- invScale = sin(theta * t) * invSinTheta;
- } else {
- scale = 1.0f - t;
- invScale = t;
- }
- } else {
- rsQuaternionSet(&tempq1, tempq0.z, -tempq0.y, tempq0.x, -tempq0.w);
- scale = sin(M_PI * (0.5f - t));
- invScale = sin(M_PI * t);
- }
-
- rsQuaternionSet(q, tempq0.w*scale + tempq1.w*invScale, tempq0.x*scale + tempq1.x*invScale,
- tempq0.y*scale + tempq1.y*invScale, tempq0.z*scale + tempq1.z*invScale);
-}
-
-/**
- * Computes rotation matrix from the normalized quaternion
- * @param m resulting matrix
- * @param p normalized quaternion
- */
-static void rsQuaternionGetMatrixUnit(rs_matrix4x4 *m, const rs_quaternion *q) {
- float xx = q->x * q->x;
- float xy = q->x * q->y;
- float xz = q->x * q->z;
- float xw = q->x * q->w;
- float yy = q->y * q->y;
- float yz = q->y * q->z;
- float yw = q->y * q->w;
- float zz = q->z * q->z;
- float zw = q->z * q->w;
-
- m->m[0] = 1.0f - 2.0f * ( yy + zz );
- m->m[4] = 2.0f * ( xy - zw );
- m->m[8] = 2.0f * ( xz + yw );
- m->m[1] = 2.0f * ( xy + zw );
- m->m[5] = 1.0f - 2.0f * ( xx + zz );
- m->m[9] = 2.0f * ( yz - xw );
- m->m[2] = 2.0f * ( xz - yw );
- m->m[6] = 2.0f * ( yz + xw );
- m->m[10] = 1.0f - 2.0f * ( xx + yy );
- m->m[3] = m->m[7] = m->m[11] = m->m[12] = m->m[13] = m->m[14] = 0.0f;
- m->m[15] = 1.0f;
-}
-
-#endif
-
diff --git a/libs/rs/scriptc/rs_sampler.rsh b/libs/rs/scriptc/rs_sampler.rsh
deleted file mode 100644
index c8948c7..0000000
--- a/libs/rs/scriptc/rs_sampler.rsh
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-/** @file rs_sampler.rsh
- * \brief Sampler routines
- *
- *
- */
-
-#ifndef __RS_SAMPLER_RSH__
-#define __RS_SAMPLER_RSH__
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-
-/**
- * @hide
- * Get sampler minification value
- *
- * @param pr
- */
-extern rs_sampler_value __attribute__((overloadable))
- rsSamplerGetMinification(rs_sampler s);
-
-/**
- * @hide
- * Get sampler magnification value
- *
- * @param pr
- */
-extern rs_sampler_value __attribute__((overloadable))
- rsSamplerGetMagnification(rs_sampler s);
-
-/**
- * @hide
- * Get sampler wrap S value
- *
- * @param pr
- */
-extern rs_sampler_value __attribute__((overloadable))
- rsSamplerGetWrapS(rs_sampler s);
-
-/**
- * @hide
- * Get sampler wrap T value
- *
- * @param pr
- */
-extern rs_sampler_value __attribute__((overloadable))
- rsSamplerGetWrapT(rs_sampler s);
-
-/**
- * @hide
- * Get sampler anisotropy
- *
- * @param pr
- */
-extern float __attribute__((overloadable))
- rsSamplerGetAnisotropy(rs_sampler s);
-
-#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
-
-#endif // __RS_SAMPLER_RSH__
-
diff --git a/libs/rs/scriptc/rs_time.rsh b/libs/rs/scriptc/rs_time.rsh
deleted file mode 100644
index 60e3dee..0000000
--- a/libs/rs/scriptc/rs_time.rsh
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/** @file rs_time.rsh
- * \brief Renderscript time routines
- *
- * This file contains Renderscript functions relating to time and date
- * manipulation.
- */
-
-#ifndef __RS_TIME_RSH__
-#define __RS_TIME_RSH__
-
-/**
- * Calendar time interpreted as seconds elapsed since the Epoch (00:00:00 on
- * January 1, 1970, Coordinated Universal Time (UTC)).
- */
-typedef int rs_time_t;
-
-/**
- * Data structure for broken-down time components.
- *
- * tm_sec - Seconds after the minute. This ranges from 0 to 59, but possibly
- * up to 60 for leap seconds.
- * tm_min - Minutes after the hour. This ranges from 0 to 59.
- * tm_hour - Hours past midnight. This ranges from 0 to 23.
- * tm_mday - Day of the month. This ranges from 1 to 31.
- * tm_mon - Months since January. This ranges from 0 to 11.
- * tm_year - Years since 1900.
- * tm_wday - Days since Sunday. This ranges from 0 to 6.
- * tm_yday - Days since January 1. This ranges from 0 to 365.
- * tm_isdst - Flag to indicate whether daylight saving time is in effect. The
- * value is positive if it is in effect, zero if it is not, and
- * negative if the information is not available.
- */
-typedef struct {
- int tm_sec; ///< seconds
- int tm_min; ///< minutes
- int tm_hour; ///< hours
- int tm_mday; ///< day of the month
- int tm_mon; ///< month
- int tm_year; ///< year
- int tm_wday; ///< day of the week
- int tm_yday; ///< day of the year
- int tm_isdst; ///< daylight savings time
-} rs_tm;
-
-/**
- * Returns the number of seconds since the Epoch (00:00:00 UTC, January 1,
- * 1970). If @p timer is non-NULL, the result is also stored in the memory
- * pointed to by this variable. If an error occurs, a value of -1 is returned.
- *
- * @param timer Location to also store the returned calendar time.
- *
- * @return Seconds since the Epoch.
- */
-extern rs_time_t __attribute__((overloadable))
- rsTime(rs_time_t *timer);
-
-/**
- * Converts the time specified by @p timer into broken-down time and stores it
- * in @p local. This function also returns a pointer to @p local. If @p local
- * is NULL, this function does nothing and returns NULL.
- *
- * @param local Broken-down time.
- * @param timer Input time as calendar time.
- *
- * @return Pointer to broken-down time (same as input @p local).
- */
-extern rs_tm * __attribute__((overloadable))
- rsLocaltime(rs_tm *local, const rs_time_t *timer);
-
-/**
- * Returns the current system clock (uptime) in milliseconds.
- *
- * @return Uptime in milliseconds.
- */
-extern int64_t __attribute__((overloadable))
- rsUptimeMillis(void);
-
-/**
- * Returns the current system clock (uptime) in nanoseconds.
- *
- * @return Uptime in nanoseconds.
- */
-extern int64_t __attribute__((overloadable))
- rsUptimeNanos(void);
-
-/**
- * Returns the time in seconds since this function was last called in this
- * script.
- *
- * @return Time in seconds.
- */
-extern float __attribute__((overloadable))
- rsGetDt(void);
-
-#endif
diff --git a/libs/rs/scriptc/rs_types.rsh b/libs/rs/scriptc/rs_types.rsh
deleted file mode 100644
index 10617d8..0000000
--- a/libs/rs/scriptc/rs_types.rsh
+++ /dev/null
@@ -1,559 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/** @file rs_types.rsh
- *
- * Define the standard Renderscript types
- *
- * Integers
- * 8 bit: char, int8_t
- * 16 bit: short, int16_t
- * 32 bit: int, in32_t
- * 64 bit: long, long long, int64_t
- *
- * Unsigned Integers
- * 8 bit: uchar, uint8_t
- * 16 bit: ushort, uint16_t
- * 32 bit: uint, uint32_t
- * 64 bit: ulong, uint64_t
- *
- * Floating point
- * 32 bit: float
- * 64 bit: double
- *
- * Vectors of length 2, 3, and 4 are supported for all the types above.
- *
- */
-
-#ifndef __RS_TYPES_RSH__
-#define __RS_TYPES_RSH__
-
-#define M_PI 3.14159265358979323846264338327950288f /* pi */
-
-#include "stdbool.h"
-/**
- * 8 bit integer type
- */
-typedef char int8_t;
-/**
- * 16 bit integer type
- */
-typedef short int16_t;
-/**
- * 32 bit integer type
- */
-typedef int int32_t;
-/**
- * 64 bit integer type
- */
-typedef long long int64_t;
-/**
- * 8 bit unsigned integer type
- */
-typedef unsigned char uint8_t;
-/**
- * 16 bit unsigned integer type
- */
-typedef unsigned short uint16_t;
-/**
- * 32 bit unsigned integer type
- */
-typedef unsigned int uint32_t;
-/**
- * 64 bit unsigned integer type
- */
-typedef unsigned long long uint64_t;
-/**
- * 8 bit unsigned integer type
- */
-typedef uint8_t uchar;
-/**
- * 16 bit unsigned integer type
- */
-typedef uint16_t ushort;
-/**
- * 32 bit unsigned integer type
- */
-typedef uint32_t uint;
-/**
- * Typedef for unsigned long (use for 64-bit unsigned integers)
- */
-typedef uint64_t ulong;
-/**
- * Typedef for unsigned int
- */
-typedef uint32_t size_t;
-/**
- * Typedef for int (use for 32-bit integers)
- */
-typedef int32_t ssize_t;
-
-/**
- * \brief Opaque handle to a Renderscript element.
- *
- * See: android.renderscript.Element
- */
-typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_element;
-/**
- * \brief Opaque handle to a Renderscript type.
- *
- * See: android.renderscript.Type
- */
-typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_type;
-/**
- * \brief Opaque handle to a Renderscript allocation.
- *
- * See: android.renderscript.Allocation
- */
-typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_allocation;
-/**
- * \brief Opaque handle to a Renderscript sampler object.
- *
- * See: android.renderscript.Sampler
- */
-typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_sampler;
-/**
- * \brief Opaque handle to a Renderscript script object.
- *
- * See: android.renderscript.ScriptC
- */
-typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_script;
-/**
- * \brief Opaque handle to a Renderscript mesh object.
- *
- * See: android.renderscript.Mesh
- */
-typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_mesh;
-/**
- * \brief Opaque handle to a Renderscript Path object.
- *
- * See: android.renderscript.Path
- */
-typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_path;
-/**
- * \brief Opaque handle to a Renderscript ProgramFragment object.
- *
- * See: android.renderscript.ProgramFragment
- */
-typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_program_fragment;
-/**
- * \brief Opaque handle to a Renderscript ProgramVertex object.
- *
- * See: android.renderscript.ProgramVertex
- */
-typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_program_vertex;
-/**
- * \brief Opaque handle to a Renderscript ProgramRaster object.
- *
- * See: android.renderscript.ProgramRaster
- */
-typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_program_raster;
-/**
- * \brief Opaque handle to a Renderscript ProgramStore object.
- *
- * See: android.renderscript.ProgramStore
- */
-typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_program_store;
-/**
- * \brief Opaque handle to a Renderscript font object.
- *
- * See: android.renderscript.Font
- */
-typedef struct { const int* const p; } __attribute__((packed, aligned(4))) rs_font;
-
-/**
- * Vector version of the basic float type.
- * Provides two float fields packed into a single 64 bit field with 64 bit
- * alignment.
- */
-typedef float float2 __attribute__((ext_vector_type(2)));
-/**
- * Vector version of the basic float type. Provides three float fields packed
- * into a single 128 bit field with 128 bit alignment.
- */
-typedef float float3 __attribute__((ext_vector_type(3)));
-/**
- * Vector version of the basic float type.
- * Provides four float fields packed into a single 128 bit field with 128 bit
- * alignment.
- */
-typedef float float4 __attribute__((ext_vector_type(4)));
-
-/**
- * Vector version of the basic double type. Provides two double fields packed
- * into a single 128 bit field with 128 bit alignment.
- */
-typedef double double2 __attribute__((ext_vector_type(2)));
-/**
- * Vector version of the basic double type. Provides three double fields packed
- * into a single 256 bit field with 256 bit alignment.
- */
-typedef double double3 __attribute__((ext_vector_type(3)));
-/**
- * Vector version of the basic double type. Provides four double fields packed
- * into a single 256 bit field with 256 bit alignment.
- */
-typedef double double4 __attribute__((ext_vector_type(4)));
-
-/**
- * Vector version of the basic uchar type. Provides two uchar fields packed
- * into a single 16 bit field with 16 bit alignment.
- */
-typedef uchar uchar2 __attribute__((ext_vector_type(2)));
-/**
- * Vector version of the basic uchar type. Provides three uchar fields packed
- * into a single 32 bit field with 32 bit alignment.
- */
-typedef uchar uchar3 __attribute__((ext_vector_type(3)));
-/**
- * Vector version of the basic uchar type. Provides four uchar fields packed
- * into a single 32 bit field with 32 bit alignment.
- */
-typedef uchar uchar4 __attribute__((ext_vector_type(4)));
-
-/**
- * Vector version of the basic ushort type. Provides two ushort fields packed
- * into a single 32 bit field with 32 bit alignment.
- */
-typedef ushort ushort2 __attribute__((ext_vector_type(2)));
-/**
- * Vector version of the basic ushort type. Provides three ushort fields packed
- * into a single 64 bit field with 64 bit alignment.
- */
-typedef ushort ushort3 __attribute__((ext_vector_type(3)));
-/**
- * Vector version of the basic ushort type. Provides four ushort fields packed
- * into a single 64 bit field with 64 bit alignment.
- */
-typedef ushort ushort4 __attribute__((ext_vector_type(4)));
-
-/**
- * Vector version of the basic uint type. Provides two uint fields packed into a
- * single 64 bit field with 64 bit alignment.
- */
-typedef uint uint2 __attribute__((ext_vector_type(2)));
-/**
- * Vector version of the basic uint type. Provides three uint fields packed into
- * a single 128 bit field with 128 bit alignment.
- */
-typedef uint uint3 __attribute__((ext_vector_type(3)));
-/**
- * Vector version of the basic uint type. Provides four uint fields packed into
- * a single 128 bit field with 128 bit alignment.
- */
-typedef uint uint4 __attribute__((ext_vector_type(4)));
-
-/**
- * Vector version of the basic ulong type. Provides two ulong fields packed into
- * a single 128 bit field with 128 bit alignment.
- */
-typedef ulong ulong2 __attribute__((ext_vector_type(2)));
-/**
- * Vector version of the basic ulong type. Provides three ulong fields packed
- * into a single 256 bit field with 256 bit alignment.
- */
-typedef ulong ulong3 __attribute__((ext_vector_type(3)));
-/**
- * Vector version of the basic ulong type. Provides four ulong fields packed
- * into a single 256 bit field with 256 bit alignment.
- */
-typedef ulong ulong4 __attribute__((ext_vector_type(4)));
-
-/**
- * Vector version of the basic char type. Provides two char fields packed into a
- * single 16 bit field with 16 bit alignment.
- */
-typedef char char2 __attribute__((ext_vector_type(2)));
-/**
- * Vector version of the basic char type. Provides three char fields packed into
- * a single 32 bit field with 32 bit alignment.
- */
-typedef char char3 __attribute__((ext_vector_type(3)));
-/**
- * Vector version of the basic char type. Provides four char fields packed into
- * a single 32 bit field with 32 bit alignment.
- */
-typedef char char4 __attribute__((ext_vector_type(4)));
-
-/**
- * Vector version of the basic short type. Provides two short fields packed into
- * a single 32 bit field with 32 bit alignment.
- */
-typedef short short2 __attribute__((ext_vector_type(2)));
-/**
- * Vector version of the basic short type. Provides three short fields packed
- * into a single 64 bit field with 64 bit alignment.
- */
-typedef short short3 __attribute__((ext_vector_type(3)));
-/**
- * Vector version of the basic short type. Provides four short fields packed
- * into a single 64 bit field with 64 bit alignment.
- */
-typedef short short4 __attribute__((ext_vector_type(4)));
-
-/**
- * Vector version of the basic int type. Provides two int fields packed into a
- * single 64 bit field with 64 bit alignment.
- */
-typedef int int2 __attribute__((ext_vector_type(2)));
-/**
- * Vector version of the basic int type. Provides three int fields packed into a
- * single 128 bit field with 128 bit alignment.
- */
-typedef int int3 __attribute__((ext_vector_type(3)));
-/**
- * Vector version of the basic int type. Provides two four fields packed into a
- * single 128 bit field with 128 bit alignment.
- */
-typedef int int4 __attribute__((ext_vector_type(4)));
-
-/**
- * Vector version of the basic long type. Provides two long fields packed into a
- * single 128 bit field with 128 bit alignment.
- */
-typedef long long2 __attribute__((ext_vector_type(2)));
-/**
- * Vector version of the basic long type. Provides three long fields packed into
- * a single 256 bit field with 256 bit alignment.
- */
-typedef long long3 __attribute__((ext_vector_type(3)));
-/**
- * Vector version of the basic long type. Provides four long fields packed into
- * a single 256 bit field with 256 bit alignment.
- */
-typedef long long4 __attribute__((ext_vector_type(4)));
-
-/**
- * \brief 4x4 float matrix
- *
- * Native holder for RS matrix. Elements are stored in the array at the
- * location [row*4 + col]
- */
-typedef struct {
- float m[16];
-} rs_matrix4x4;
-/**
- * \brief 3x3 float matrix
- *
- * Native holder for RS matrix. Elements are stored in the array at the
- * location [row*3 + col]
- */
-typedef struct {
- float m[9];
-} rs_matrix3x3;
-/**
- * \brief 2x2 float matrix
- *
- * Native holder for RS matrix. Elements are stored in the array at the
- * location [row*2 + col]
- */
-typedef struct {
- float m[4];
-} rs_matrix2x2;
-
-/**
- * quaternion type for use with the quaternion functions
- */
-typedef float4 rs_quaternion;
-
-#define RS_PACKED __attribute__((packed, aligned(4)))
-#define NULL ((void *)0)
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 14))
-
-/**
- * \brief Enum for selecting cube map faces
- */
-typedef enum {
- RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X = 0,
- RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_X = 1,
- RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Y = 2,
- RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Y = 3,
- RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Z = 4,
- RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Z = 5
-} rs_allocation_cubemap_face;
-
-/**
- * \brief Bitfield to specify the usage types for an allocation.
- *
- * These values are ORed together to specify which usages or memory spaces are
- * relevant to an allocation or an operation on an allocation.
- */
-typedef enum {
- RS_ALLOCATION_USAGE_SCRIPT = 0x0001,
- RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE = 0x0002,
- RS_ALLOCATION_USAGE_GRAPHICS_VERTEX = 0x0004,
- RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS = 0x0008,
- RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET = 0x0010
-} rs_allocation_usage_type;
-
-#endif //defined(RS_VERSION) && (RS_VERSION >= 14)
-
-#if (defined(RS_VERSION) && (RS_VERSION >= 16))
-
-/**
- * Describes the way mesh vertex data is interpreted when rendering
- *
- **/
-typedef enum {
- RS_PRIMITIVE_POINT = 0,
- RS_PRIMITIVE_LINE = 1,
- RS_PRIMITIVE_LINE_STRIP = 2,
- RS_PRIMITIVE_TRIANGLE = 3,
- RS_PRIMITIVE_TRIANGLE_STRIP = 4,
- RS_PRIMITIVE_TRIANGLE_FAN = 5,
-
- RS_PRIMITIVE_INVALID = 100,
-} rs_primitive;
-
-/**
- * \brief Enumeration for possible element data types
- *
- * DataType represents the basic type information for a basic element. The
- * naming convention follows. For numeric types it is FLOAT,
- * SIGNED, or UNSIGNED followed by the _BITS where BITS is the
- * size of the data. BOOLEAN is a true / false (1,0)
- * represented in an 8 bit container. The UNSIGNED variants
- * with multiple bit definitions are for packed graphical data
- * formats and represent vectors with per vector member sizes
- * which are treated as a single unit for packing and alignment
- * purposes.
- *
- * MATRIX the three matrix types contain FLOAT_32 elements and are treated
- * as 32 bits for alignment purposes.
- *
- * RS_* objects. 32 bit opaque handles.
- */
-typedef enum {
- RS_TYPE_NONE = 0,
- //RS_TYPE_FLOAT_16,
- RS_TYPE_FLOAT_32 = 2,
- RS_TYPE_FLOAT_64 = 3,
- RS_TYPE_SIGNED_8 = 4,
- RS_TYPE_SIGNED_16 = 5,
- RS_TYPE_SIGNED_32 = 6,
- RS_TYPE_SIGNED_64 = 7,
- RS_TYPE_UNSIGNED_8 = 8,
- RS_TYPE_UNSIGNED_16 = 9,
- RS_TYPE_UNSIGNED_32 = 10,
- RS_TYPE_UNSIGNED_64 = 11,
-
- RS_TYPE_BOOLEAN = 12,
-
- RS_TYPE_UNSIGNED_5_6_5 = 13,
- RS_TYPE_UNSIGNED_5_5_5_1 = 14,
- RS_TYPE_UNSIGNED_4_4_4_4 = 15,
-
- RS_TYPE_MATRIX_4X4 = 16,
- RS_TYPE_MATRIX_3X3 = 17,
- RS_TYPE_MATRIX_2X2 = 18,
-
- RS_TYPE_ELEMENT = 1000,
- RS_TYPE_TYPE = 1001,
- RS_TYPE_ALLOCATION = 1002,
- RS_TYPE_SAMPLER = 1003,
- RS_TYPE_SCRIPT = 1004,
- RS_TYPE_MESH = 1005,
- RS_TYPE_PROGRAM_FRAGMENT = 1006,
- RS_TYPE_PROGRAM_VERTEX = 1007,
- RS_TYPE_PROGRAM_RASTER = 1008,
- RS_TYPE_PROGRAM_STORE = 1009,
-
- RS_TYPE_INVALID = 10000,
-} rs_data_type;
-
-/**
- * \brief Enumeration for possible element data kind
- *
- * The special interpretation of the data if required. This is primarly
- * useful for graphical data. USER indicates no special interpretation is
- * expected. PIXEL is used in conjunction with the standard data types for
- * representing texture formats.
- */
-typedef enum {
- RS_KIND_USER = 0,
-
- RS_KIND_PIXEL_L = 7,
- RS_KIND_PIXEL_A = 8,
- RS_KIND_PIXEL_LA = 9,
- RS_KIND_PIXEL_RGB = 10,
- RS_KIND_PIXEL_RGBA = 11,
- RS_KIND_PIXEL_DEPTH = 12,
-
- RS_KIND_INVALID = 100,
-} rs_data_kind;
-
-typedef enum {
- RS_DEPTH_FUNC_ALWAYS = 0,
- RS_DEPTH_FUNC_LESS = 1,
- RS_DEPTH_FUNC_LEQUAL = 2,
- RS_DEPTH_FUNC_GREATER = 3,
- RS_DEPTH_FUNC_GEQUAL = 4,
- RS_DEPTH_FUNC_EQUAL = 5,
- RS_DEPTH_FUNC_NOTEQUAL = 6,
-
- RS_DEPTH_FUNC_INVALID = 100,
-} rs_depth_func;
-
-typedef enum {
- RS_BLEND_SRC_ZERO = 0,
- RS_BLEND_SRC_ONE = 1,
- RS_BLEND_SRC_DST_COLOR = 2,
- RS_BLEND_SRC_ONE_MINUS_DST_COLOR = 3,
- RS_BLEND_SRC_SRC_ALPHA = 4,
- RS_BLEND_SRC_ONE_MINUS_SRC_ALPHA = 5,
- RS_BLEND_SRC_DST_ALPHA = 6,
- RS_BLEND_SRC_ONE_MINUS_DST_ALPHA = 7,
- RS_BLEND_SRC_SRC_ALPHA_SATURATE = 8,
-
- RS_BLEND_SRC_INVALID = 100,
-} rs_blend_src_func;
-
-typedef enum {
- RS_BLEND_DST_ZERO = 0,
- RS_BLEND_DST_ONE = 1,
- RS_BLEND_DST_SRC_COLOR = 2,
- RS_BLEND_DST_ONE_MINUS_SRC_COLOR = 3,
- RS_BLEND_DST_SRC_ALPHA = 4,
- RS_BLEND_DST_ONE_MINUS_SRC_ALPHA = 5,
- RS_BLEND_DST_DST_ALPHA = 6,
- RS_BLEND_DST_ONE_MINUS_DST_ALPHA = 7,
-
- RS_BLEND_DST_INVALID = 100,
-} rs_blend_dst_func;
-
-typedef enum {
- RS_CULL_BACK = 0,
- RS_CULL_FRONT = 1,
- RS_CULL_NONE = 2,
-
- RS_CULL_INVALID = 100,
-} rs_cull_mode;
-
-typedef enum {
- RS_SAMPLER_NEAREST = 0,
- RS_SAMPLER_LINEAR = 1,
- RS_SAMPLER_LINEAR_MIP_LINEAR = 2,
- RS_SAMPLER_WRAP = 3,
- RS_SAMPLER_CLAMP = 4,
- RS_SAMPLER_LINEAR_MIP_NEAREST = 5,
-
- RS_SAMPLER_INVALID = 100,
-} rs_sampler_value;
-
-#endif // (defined(RS_VERSION) && (RS_VERSION >= 16))
-
-#endif // __RS_TYPES_RSH__
diff --git a/libs/rs/spec.h b/libs/rs/spec.h
deleted file mode 100644
index ecc5cc7..0000000
--- a/libs/rs/spec.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef SPEC_H
-#define SPEC_H
-
-#include <string.h>
-#include <stdlib.h>
-
-#if __cplusplus
-extern "C" {
-#endif
-
-extern int num_lines;
-
-typedef struct {
- int isConst;
- int type;
- int bits;
- int ptrLevel;
- char name[256];
- char typeName[256];
-} VarType;
-
-extern VarType *currType;
-
-typedef struct {
- char name[256];
- int sync;
- int handcodeApi;
- int direct;
- int nocontext;
- int paramCount;
- VarType ret;
- VarType params[16];
-} ApiEntry;
-
-extern ApiEntry apis[128];
-extern int apiCount;
-
-extern int typeNextState;
-
-#if __cplusplus
-} // extern "C"
-#endif
-
-#endif // SPEC_H
diff --git a/libs/rs/spec.l b/libs/rs/spec.l
deleted file mode 100644
index a24bfd3..0000000
--- a/libs/rs/spec.l
+++ /dev/null
@@ -1,198 +0,0 @@
-%option stack
-
-%x comment
-%x api_entry
-%x api_entry2
-%x api_entry_param
-%x var_type
-
-DIGIT [0-9]
-ID [a-zA-Z_][a-zA-Z0-9_]*
-
- #include "spec.h"
-
- int num_lines = 0;
-
- VarType *currType = 0;
-
- ApiEntry apis[128];
- int apiCount = 0;
-
- int typeNextState;
-
- void checkPointerType() {
- VarType *baseType = currType;
- int curPtrLevel = 0;
- while (curPtrLevel < baseType->ptrLevel) {
- currType = &apis[apiCount].params[apis[apiCount].paramCount];
- currType->type = 4;
- currType->ptrLevel = curPtrLevel;
- if (currType->ptrLevel > 0) {
- currType->isConst = 1;
- }
- sprintf(currType->typeName, "%s", "size_t");
- switch(baseType->ptrLevel - curPtrLevel) {
- case 1:
- sprintf(currType->name, "%s_length", baseType->name);
- break;
- case 2:
- sprintf(currType->name, "%s_length_length", baseType->name);
- break;
- }
- apis[apiCount].paramCount++;
- curPtrLevel ++;
- }
- }
-
- extern "C" int yylex();
-
-%%
-
-"/*" BEGIN(comment);
-<comment>[^*\n]* /* eat anything that's not a '*' */
-<comment>"*"+[^*/\n]* /* eat up '*'s not followed by '/'s */
-<comment>\n ++num_lines;
-<comment>"*"+"/" BEGIN(INITIAL);
-
-<*>" " //printf("found ' '\n");
-<*>"\t" //printf("found ' '\n");
-<*>"\n" ++num_lines; //printf("found lf \n");
-
-{ID} {
- memset(&apis[apiCount], 0, sizeof(ApiEntry));
- memcpy(apis[apiCount].name, yytext, yyleng);
- BEGIN(api_entry);
- }
-
-<api_entry>"{" {
- BEGIN(api_entry2);
- }
-
-<api_entry2>"sync" {
- apis[apiCount].sync = 1;
- }
-
-<api_entry2>"handcodeApi" {
- apis[apiCount].handcodeApi = 1;
- }
-
-<api_entry2>"direct" {
- apis[apiCount].direct = 1;
- }
-
-<api_entry2>"nocontext" {
- apis[apiCount].nocontext = 1;
- }
-
-<api_entry2>"ret" {
- currType = &apis[apiCount].ret;
- typeNextState = api_entry2;
- BEGIN(var_type);
- }
-
-<api_entry2>"param" {
- currType = &apis[apiCount].params[apis[apiCount].paramCount];
- apis[apiCount].paramCount++;
- typeNextState = api_entry_param;
- BEGIN(var_type);
- }
-
-<var_type>"const" {
- currType->isConst = 1;
- }
-
-<var_type>"i8" {
- currType->type = 1;
- currType->bits = 8;
- BEGIN(typeNextState);
- }
-
-<var_type>"i16" {
- currType->type = 1;
- currType->bits = 16;
- BEGIN(typeNextState);
- }
-
-<var_type>"i32" {
- currType->type = 1;
- currType->bits = 32;
- BEGIN(typeNextState);
- }
-
-<var_type>"i64" {
- currType->type = 1;
- currType->bits = 64;
- BEGIN(typeNextState);
- }
-
-<var_type>"u8" {
- currType->type = 2;
- currType->bits = 8;
- BEGIN(typeNextState);
- }
-
-<var_type>"u16" {
- currType->type = 2;
- currType->bits = 16;
- BEGIN(typeNextState);
- }
-
-<var_type>"u32" {
- currType->type = 2;
- currType->bits = 32;
- BEGIN(typeNextState);
- }
-
-<var_type>"u64" {
- currType->type = 2;
- currType->bits = 64;
- BEGIN(typeNextState);
- }
-
-<var_type>"f" {
- currType->type = 3;
- currType->bits = 32;
- BEGIN(typeNextState);
- }
-
-<var_type>"d" {
- currType->type = 3;
- currType->bits = 64;
- BEGIN(typeNextState);
- }
-
-<var_type>{ID} {
- currType->type = 4;
- currType->bits = 32;
- memcpy(currType->typeName, yytext, yyleng);
- BEGIN(typeNextState);
- }
-
-<api_entry_param>"*" {
- currType->ptrLevel ++;
- }
-
-<api_entry_param>{ID} {
- memcpy(currType->name, yytext, yyleng);
- checkPointerType();
- BEGIN(api_entry2);
- }
-
-<api_entry2>"*" {
- currType->ptrLevel ++;
- }
-
-<api_entry2>"}" {
- apiCount++;
- BEGIN(INITIAL);
- }
-
-
-%%
-
-
-int yywrap()
-{
- return 1;
-}
-
diff --git a/libs/rs/tests/Android.mk b/libs/rs/tests/Android.mk
deleted file mode 100644
index 627ff72..0000000
--- a/libs/rs/tests/Android.mk
+++ /dev/null
@@ -1,36 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- compute.cpp \
- ScriptC_mono.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libRS \
- libz \
- libcutils \
- libutils \
- libEGL \
- libGLESv1_CM \
- libGLESv2 \
- libui \
- libbcc \
- libbcinfo \
- libgui
-
-LOCAL_MODULE:= rstest-compute
-
-LOCAL_MODULE_TAGS := tests
-
-intermediates := $(call intermediates-dir-for,STATIC_LIBRARIES,libRS,TARGET,)
-librs_generated_headers := \
- $(intermediates)/rsgApiStructs.h \
- $(intermediates)/rsgApiFuncDecl.h
-LOCAL_GENERATED_SOURCES := $(librs_generated_headers)
-
-LOCAL_C_INCLUDES += frameworks/base/libs/rs
-LOCAL_C_INCLUDES += $(intermediates)
-
-
-include $(BUILD_EXECUTABLE)
-
diff --git a/libs/rs/tests/ScriptC_mono.cpp b/libs/rs/tests/ScriptC_mono.cpp
deleted file mode 100644
index a6c63a8..0000000
--- a/libs/rs/tests/ScriptC_mono.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-
-/*
- * This file is auto-generated. DO NOT MODIFY!
- * The source Renderscript file: mono.rs
- */
-
-
-#include "ScriptC_mono.h"
-
-static const unsigned char __txt[] = {
- 0xde,0xc0,0x17,0x0b,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0xd0,0x04,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x42,0x43,0xc0,0xde,0x21,0x0c,0x00,0x00,
- 0x31,0x01,0x00,0x00,0x01,0x10,0x00,0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91,
- 0x41,0xc8,0x04,0x49,0x06,0x10,0x32,0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19,
- 0x1e,0x04,0x8b,0x62,0x80,0x14,0x45,0x02,0x42,0x92,0x0b,0x42,0xa4,0x10,0x32,0x14,
- 0x38,0x08,0x18,0x49,0x0a,0x32,0x44,0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80,
- 0x0c,0x19,0x21,0x72,0x24,0x07,0xc8,0x48,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0,
- 0x01,0x00,0x00,0x00,0x49,0x18,0x00,0x00,0x08,0x00,0x00,0x00,0x0b,0x8c,0x00,0x04,
- 0x41,0x10,0x04,0x09,0x01,0x04,0x41,0x10,0x04,0x89,0xff,0xff,0xff,0xff,0x1f,0xc0,
- 0x60,0x81,0xf0,0xff,0xff,0xff,0xff,0x03,0x18,0x00,0x00,0x00,0x89,0x20,0x00,0x00,
- 0x14,0x00,0x00,0x00,0x32,0x22,0x48,0x09,0x20,0x64,0x85,0x04,0x93,0x22,0xa4,0x84,
- 0x04,0x93,0x22,0xe3,0x84,0xa1,0x90,0x14,0x12,0x4c,0x8a,0x8c,0x0b,0x84,0xa4,0x4c,
- 0x10,0x54,0x73,0x04,0x60,0x40,0x60,0x06,0x80,0xc4,0x1c,0x01,0x42,0x64,0x04,0x60,
- 0x18,0x81,0x20,0xe8,0x94,0xc1,0x20,0x44,0x69,0x18,0x81,0x10,0x8a,0xb0,0x0e,0xb1,
- 0x61,0x84,0x41,0x28,0x83,0x70,0x8e,0x5e,0x11,0x8e,0xa3,0x38,0x10,0x30,0x8c,0x30,
- 0x00,0x00,0x00,0x00,0x13,0xb0,0x70,0x90,0x87,0x76,0xb0,0x87,0x3b,0x68,0x03,0x77,
- 0x78,0x07,0x77,0x28,0x87,0x36,0x60,0x87,0x74,0x70,0x87,0x7a,0xc0,0x87,0x36,0x38,
- 0x07,0x77,0xa8,0x87,0x72,0x08,0x07,0x71,0x48,0x87,0x0d,0xf2,0x50,0x0e,0x6d,0x00,
- 0x0f,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,
- 0xe9,0x10,0x07,0x7a,0x80,0x07,0x7a,0x80,0x07,0x6d,0x90,0x0e,0x78,0xa0,0x07,0x78,
- 0xa0,0x07,0x78,0xd0,0x06,0xe9,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x7a,0x10,
- 0x07,0x76,0xd0,0x06,0xe9,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,
- 0x72,0xd0,0x06,0xe9,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,
- 0xd0,0x06,0xe6,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,
- 0x06,0xe6,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,
- 0xf6,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6,
- 0x10,0x07,0x72,0x80,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x71,0x20,0x07,0x78,0xd0,
- 0x06,0xe1,0x00,0x07,0x7a,0x00,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xee,0x30,0x07,
- 0x72,0xd0,0x06,0xb3,0x60,0x07,0x74,0xa0,0xf3,0x40,0x86,0x04,0x32,0x42,0x44,0x04,
- 0x60,0x20,0x30,0x77,0x81,0x59,0x0a,0x34,0x44,0x51,0x00,0x00,0x08,0x00,0x00,0x00,
- 0x80,0x21,0x4a,0x03,0x04,0x00,0x00,0x00,0x00,0x00,0x0c,0x51,0x20,0x20,0x00,0x00,
- 0x00,0x00,0x00,0x60,0x88,0x22,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x59,0x20,0x00,
- 0x08,0x00,0x00,0x00,0x32,0x1e,0x98,0x10,0x19,0x11,0x4c,0x90,0x8c,0x09,0x26,0x47,
- 0xc6,0x04,0x43,0x02,0x85,0x50,0x06,0x44,0x4a,0x80,0xc4,0x18,0x81,0xce,0x9a,0x73,
- 0xfe,0x01,0x00,0x00,0x79,0x18,0x00,0x00,0x69,0x00,0x00,0x00,0x43,0x88,0x29,0x98,
- 0x84,0x05,0x87,0x3d,0x94,0x83,0x3c,0xcc,0x43,0x3a,0xbc,0x83,0x3b,0x2c,0x08,0xe2,
- 0x60,0x08,0x31,0x11,0x53,0xb1,0x20,0x52,0x87,0x70,0xb0,0x87,0x70,0xf8,0x05,0x78,
- 0x08,0x87,0x71,0x58,0x87,0x70,0x38,0x87,0x72,0xf8,0x05,0x77,0x08,0x87,0x76,0x28,
- 0x87,0x05,0x63,0x30,0x0e,0xef,0xd0,0x0e,0x6e,0x50,0x0e,0xf8,0x10,0x0e,0xed,0x00,
- 0x0f,0xec,0x50,0x0e,0x6e,0x10,0x0e,0xee,0x40,0x0e,0xf2,0xf0,0x0e,0xe9,0x40,0x0e,
- 0x6e,0x20,0x0f,0xf3,0xe0,0x06,0xe8,0x50,0x0e,0xec,0xc0,0x0e,0xef,0x30,0x0e,0xef,
- 0xd0,0x0e,0xf0,0x50,0x0f,0xf4,0x50,0x0e,0x43,0x04,0x00,0x19,0x42,0x4c,0xc8,0x94,
- 0x2c,0x20,0xce,0x21,0x15,0xdc,0x81,0x1e,0x16,0x04,0x75,0x30,0x84,0x98,0x96,0x49,
- 0x58,0x60,0x8c,0x83,0x29,0xb0,0xc3,0x3b,0x84,0x03,0x3d,0x0c,0x21,0xa6,0x66,0x72,
- 0x16,0x14,0xe7,0x20,0x0a,0xef,0xf0,0x0e,0xec,0xb0,0x40,0x88,0x83,0x38,0x18,0x22,
- 0x4c,0xd0,0x02,0x42,0x1e,0xde,0xe1,0x1d,0xe8,0x61,0x88,0x30,0x49,0x0b,0x82,0x39,
- 0x18,0x42,0x4c,0xd4,0x54,0x2d,0x78,0xde,0xa1,0x1d,0xdc,0x21,0x1d,0xe0,0xe1,0x1d,
- 0xe8,0xa1,0x1c,0xdc,0x81,0x1e,0xc0,0x60,0x1c,0xd0,0x21,0x1c,0xe4,0x61,0x08,0x31,
- 0x59,0x06,0xb0,0x20,0x9a,0x85,0x74,0x68,0x07,0x78,0x60,0x87,0x72,0x00,0x83,0x51,
- 0x78,0x83,0x51,0x58,0x83,0x35,0x00,0x03,0x5a,0x10,0x85,0x50,0x08,0x85,0x11,0xc7,
- 0x18,0xc0,0x83,0x3c,0x84,0xc3,0x39,0xb4,0x43,0x38,0x4c,0x11,0x80,0x61,0xc4,0x34,
- 0x06,0xef,0x00,0x0f,0xf4,0x90,0x0e,0xed,0x90,0x0e,0xfa,0x10,0x0e,0xf4,0x90,0x0e,
- 0xef,0xe0,0x0e,0xbf,0xc0,0x0e,0xe5,0x60,0x0f,0xe5,0xc0,0x0e,0x53,0x02,0x63,0x84,
- 0x33,0x06,0xf2,0x30,0x0f,0xbf,0x50,0x0e,0xf8,0x00,0x0f,0xef,0x20,0x0f,0xf4,0xf0,
- 0x0b,0xf6,0x10,0x0e,0xf2,0x30,0x65,0x38,0x14,0x66,0x04,0x34,0x06,0xf2,0x30,0x0f,
- 0xbf,0xf0,0x0e,0xe2,0xa0,0x0e,0xe5,0x30,0x0e,0xf4,0xf0,0x0b,0xf3,0xc0,0x0e,0xef,
- 0x40,0x0f,0xf3,0x30,0x05,0x18,0x71,0x8d,0x81,0x3c,0xcc,0xc3,0x2f,0x94,0x03,0x3e,
- 0xc0,0xc3,0x3b,0xc8,0x03,0x3d,0xfc,0x82,0x39,0xbc,0x83,0x3c,0x94,0x43,0x38,0x8c,
- 0x03,0x3a,0xfc,0x82,0x3b,0x84,0x43,0x3b,0x94,0xc3,0x94,0xe0,0x19,0x21,0x8d,0x81,
- 0x3c,0xcc,0xc3,0x2f,0x94,0x03,0x3e,0xc0,0xc3,0x3b,0xc8,0x03,0x3d,0xfc,0x82,0x39,
- 0xbc,0x83,0x3c,0x94,0x43,0x38,0x8c,0x03,0x3a,0x4c,0x09,0x22,0x00,0x00,0x00,0x00,
- 0x79,0x18,0x00,0x00,0x0b,0x00,0x00,0x00,0x33,0x08,0x80,0x1c,0xc4,0xe1,0x1c,0x66,
- 0x14,0x01,0x3d,0x88,0x43,0x38,0x84,0xc3,0x8c,0x42,0x80,0x07,0x79,0x78,0x07,0x73,
- 0x98,0xb1,0x0c,0xe6,0x00,0x0f,0xe1,0x30,0x0e,0xe3,0x50,0x0f,0xf2,0x10,0x0e,0xe3,
- 0x90,0x0f,0x00,0x00,0x71,0x20,0x00,0x00,0x13,0x00,0x00,0x00,0x06,0x40,0x18,0x62,
- 0x33,0x99,0x40,0x61,0x6c,0x8e,0xb3,0xd8,0x00,0x11,0x39,0xce,0x64,0x04,0x51,0x24,
- 0xb9,0xcd,0x03,0x08,0x0a,0xe7,0x2c,0x4e,0xc4,0xf3,0x3c,0x6f,0x05,0xcd,0x3f,0xdf,
- 0x83,0x33,0x75,0xd5,0xfd,0x17,0xec,0x6f,0x01,0x86,0xf0,0x2d,0x0e,0x30,0x99,0x81,
- 0xf6,0xcf,0xf5,0x1e,0x49,0x29,0x20,0x28,0x9c,0xb3,0x38,0x51,0xeb,0xf0,0x3c,0xcf,
- 0x77,0xd5,0xfd,0x17,0x00,0x00,0x00,0x00,0x61,0x20,0x00,0x00,0x21,0x00,0x00,0x00,
- 0x13,0x04,0x41,0x2c,0x10,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x04,0x46,0x00,0x68,
- 0xcd,0x00,0x90,0x9b,0x01,0x18,0x6b,0x38,0xe9,0x52,0x4e,0x3f,0xb1,0x8d,0xd9,0xf8,
- 0xab,0x4d,0x5f,0xf6,0x3d,0xa2,0x63,0x0d,0x40,0x20,0x8c,0x00,0x00,0x00,0x00,0x00,
- 0xb4,0x8c,0x11,0x03,0x42,0x08,0x88,0x69,0x90,0x81,0x72,0xa2,0x11,0x83,0x42,0x08,
- 0x8a,0x0a,0x9a,0x63,0x78,0xac,0x66,0x90,0xe1,0x7a,0xa4,0x11,0x03,0x42,0x08,0x0c,
- 0x6c,0x30,0x82,0xc9,0x06,0x00,0xc3,0x81,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
- 0xb6,0x40,0x54,0x3f,0xd2,0x18,0x43,0x51,0xfd,0x0e,0x35,0x01,0x01,0x31,0x00,0x00,
- 0x03,0x00,0x00,0x00,0x5b,0x06,0x20,0x98,0xb6,0x0c,0x47,0x30,0x01,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-};
-
-ScriptC_mono::ScriptC_mono(RenderScript *rs, const char *cacheDir, size_t cacheDirLength) :
- ScriptC(rs, __txt, sizeof(__txt), "mono.rs", 4, cacheDir, cacheDirLength) {
-}
-
-ScriptC_mono::~ScriptC_mono() {
-}
-
-void ScriptC_mono::forEach_root(const Allocation *ain, const Allocation *aout) const {
- forEach(0, ain, aout, NULL, 0);
-}
-
diff --git a/libs/rs/tests/ScriptC_mono.h b/libs/rs/tests/ScriptC_mono.h
deleted file mode 100644
index 69c41ac..0000000
--- a/libs/rs/tests/ScriptC_mono.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-
-/*
- * This file is auto-generated. DO NOT MODIFY!
- * The source Renderscript file: mono.rs
- */
-
-
-#include "ScriptC.h"
-
-class ScriptC_mono : protected ScriptC {
-private:
- int32_t __gInt;
- bool __gBool;
-public:
- ScriptC_mono(RenderScript *rs, const char *cacheDir, size_t cacheDirLength);
- virtual ~ScriptC_mono();
-
- void set_gInt(int32_t v) {
- setVar(0, v);
- __gInt = v;
- }
- int32_t get_gInt() const {
- return __gInt;
- }
-
- float get_cFloat() const {
- return 1.2f;
- }
-
- void set_gBool(bool v) {
- setVar(2, v);
- __gBool = v;
- }
- bool get_gBool() const {
- return __gBool;
- }
-
- void forEach_root(const Allocation *ain, const Allocation *aout) const;
-};
diff --git a/libs/rs/tests/compute.cpp b/libs/rs/tests/compute.cpp
deleted file mode 100644
index 42eaa52..0000000
--- a/libs/rs/tests/compute.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-
-#include "RenderScript.h"
-#include "Element.h"
-#include "Type.h"
-#include "Allocation.h"
-
-#include "ScriptC_mono.h"
-
-int main(int argc, char** argv)
-{
-
- RenderScript *rs = new RenderScript();
- printf("New RS %p\n", rs);
-
- bool r = rs->init(16);
- printf("Init returned %i\n", r);
-
- const Element *e = Element::RGBA_8888(rs);
- printf("Element %p\n", e);
-
- Type::Builder tb(rs, e);
- tb.setX(128);
- tb.setY(128);
- const Type *t = tb.create();
- printf("Type %p\n", t);
-
-
- Allocation *a1 = Allocation::createSized(rs, e, 1000);
- printf("Allocation %p\n", a1);
-
- Allocation *ain = Allocation::createTyped(rs, t);
- Allocation *aout = Allocation::createTyped(rs, t);
- printf("Allocation %p %p\n", ain, aout);
-
- ScriptC_mono * sc = new ScriptC_mono(rs, NULL, 0);
- printf("new script\n");
-
- uint32_t *buf = new uint32_t[t->getCount()];
- for (uint32_t ct=0; ct < t->getCount(); ct++) {
- buf[ct] = ct | (ct << 16);
- }
- //ain->copy1DRangeFrom(0, 128*128, (int32_t *)buf, 128*128*4);
- ain->copy1DRangeFromUnchecked(0, t->getCount(), buf, t->getCount()*4);
-
-
-
- sc->forEach_root(ain, aout);
- printf("for each done\n");
-
-
- printf("Deleting stuff\n");
- delete sc;
- delete t;
- delete a1;
- delete e;
- delete rs;
- printf("Delete OK\n");
-}