Commit b43a1e5d authored by Alex Sakhartchouk's avatar Alex Sakhartchouk

Moving libRS

Change-Id: I1e42204e862585b9c2f7818b615890c60f08faf6
parent f9c1f993
......@@ -119,6 +119,13 @@ $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/fonts/DroidSans*)
$(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
# ************************************************
......@@ -21,7 +21,7 @@ rs_generated_include_dir := $(call intermediates-dir-for,SHARED_LIBRARIES,libRS,
LOCAL_C_INCLUDES += \
$(JNI_H_INCLUDE) \
$(LOCAL_PATH)/../../libs/rs \
frameworks/rs \
$(rs_generated_include_dir) \
$(call include-path-for, corecg graphics)
......
This diff is collapsed.
/*
* 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
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)
/*
* 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;
}
/*
* 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
This diff is collapsed.
/*
* 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);