diff --git a/libs/rs/jni/RenderScript_jni.cpp b/libs/rs/jni/RenderScript_jni.cpp index b5923644f41c3..5ac1f3adcff31 100644 --- a/libs/rs/jni/RenderScript_jni.cpp +++ b/libs/rs/jni/RenderScript_jni.cpp @@ -21,7 +21,6 @@ #include #include -#include #include #include diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp index 3a01a7531782a..dab32990b4e61 100644 --- a/libs/rs/rsAllocation.cpp +++ b/libs/rs/rsAllocation.cpp @@ -16,6 +16,9 @@ #include "rsContext.h" +#include +#include + using namespace android; using namespace android::renderscript; diff --git a/libs/rs/rsComponent.h b/libs/rs/rsComponent.h index 205e575c79c88..e1b05850cb858 100644 --- a/libs/rs/rsComponent.h +++ b/libs/rs/rsComponent.h @@ -17,11 +17,7 @@ #ifndef ANDROID_RS_STRUCTURED_COMPONENT_H #define ANDROID_RS_STRUCTURED_COMPONENT_H -#include -#include -#include - -#include "RenderScript.h" +#include "rsUtils.h" #include "rsObjectBase.h" // --------------------------------------------------------------------------- diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index 7c46c0e9fd006..0f78df4e6ebf0 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -19,6 +19,9 @@ #include "rsThreadIO.h" #include "utils/String8.h" +#include +#include + using namespace android; using namespace android::renderscript; diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h index 3f2775124e1dd..26d665bf73889 100644 --- a/libs/rs/rsContext.h +++ b/libs/rs/rsContext.h @@ -17,10 +17,6 @@ #ifndef ANDROID_RS_CONTEXT_H #define ANDROID_RS_CONTEXT_H -#include -#include -#include - #include "rsType.h" #include "rsMatrix.h" #include "rsAllocation.h" @@ -38,6 +34,10 @@ #include "rsgApiStructs.h" #include "rsLocklessFifo.h" +#include +#include + + // --------------------------------------------------------------------------- namespace android { diff --git a/libs/rs/rsDevice.h b/libs/rs/rsDevice.h index 3de3ffaa7a98d..156315f9746c2 100644 --- a/libs/rs/rsDevice.h +++ b/libs/rs/rsDevice.h @@ -17,9 +17,7 @@ #ifndef ANDROID_RS_DEVICE_H #define ANDROID_RS_DEVICE_H -#include - -//#include "StructuredComponent.h" +#include "rsUtils.h" // --------------------------------------------------------------------------- namespace android { diff --git a/libs/rs/rsElement.h b/libs/rs/rsElement.h index 2434977dbc2a9..ea6fa8f29aae8 100644 --- a/libs/rs/rsElement.h +++ b/libs/rs/rsElement.h @@ -17,8 +17,6 @@ #ifndef ANDROID_STRUCTURED_ELEMENT_H #define ANDROID_STRUCTURED_ELEMENT_H -#include - #include "rsComponent.h" // --------------------------------------------------------------------------- diff --git a/libs/rs/rsLight.cpp b/libs/rs/rsLight.cpp new file mode 100644 index 0000000000000..67d009544402a --- /dev/null +++ b/libs/rs/rsLight.cpp @@ -0,0 +1,123 @@ +/* + * 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; + + +Light::Light(bool isLocal, bool isMono) +{ + mIsLocal = isLocal; + mIsMono = isMono; + + mX = 0; + mY = 0; + mZ = 0; + + mR = 1.f; + mG = 1.f; + mB = 1.f; +} + +Light::~Light() +{ +} + +void Light::setPosition(float x, float y, float z) +{ + mX = x; + mY = y; + mZ = z; +} + +void Light::setColor(float r, float g, float b) +{ + mR = r; + mG = g; + mB = b; +} + +//////////////////////////////////////////// + +LightState::LightState() +{ + clear(); +} + +LightState::~LightState() +{ +} + +void LightState::clear() +{ + mIsLocal = false; + mIsMono = false; +} + + +//////////////////////////////////////////////////// +// + +namespace android { +namespace renderscript { + +void rsi_LightBegin(Context *rsc) +{ + rsc->mStateLight.clear(); +} + +void rsi_LightSetLocal(Context *rsc, bool isLocal) +{ + rsc->mStateLight.mIsLocal = isLocal; +} + +void rsi_LightSetMonochromatic(Context *rsc, bool isMono) +{ + rsc->mStateLight.mIsMono = isMono; +} + +RsLight rsi_LightCreate(Context *rsc) +{ + Light *l = new Light(rsc->mStateLight.mIsLocal, + rsc->mStateLight.mIsMono); + l->incRef(); + return l; +} + +void rsi_LightDestroy(Context *rsc, RsLight vl) +{ + Light *l = static_cast(vl); + l->decRef(); +} + +void rsi_LightSetColor(Context *rsc, RsLight vl, float r, float g, float b) +{ + Light *l = static_cast(vl); + l->setColor(r, g, b); +} + +void rsi_LightSetPosition(Context *rsc, RsLight vl, float x, float y, float z) +{ + Light *l = static_cast(vl); + l->setPosition(x, y, z); +} + + + +} +} diff --git a/libs/rs/rsLight.h b/libs/rs/rsLight.h new file mode 100644 index 0000000000000..76d1eccacdb72 --- /dev/null +++ b/libs/rs/rsLight.h @@ -0,0 +1,62 @@ +/* + * 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_LIGHT_H +#define ANDROID_LIGHT_H + + +#include "rsObjectBase.h" + +// --------------------------------------------------------------------------- +namespace android { +namespace renderscript { + + +// An element is a group of Components that occupies one cell in a structure. +class Light : public ObjectBase +{ +public: + Light(bool isLocal, bool isMono); + virtual ~Light(); + + // Values, mutable after creation. + void setPosition(float x, float y, float z); + void setColor(float r, float g, float b); + +protected: + float mR, mG, mB; + float mX, mY, mZ; + bool mIsLocal; + bool mIsMono; +}; + + +class LightState { +public: + LightState(); + ~LightState(); + + void clear(); + + bool mIsMono; + bool mIsLocal; +}; + + +} +} +#endif //ANDROID_LIGHT_H + diff --git a/libs/rs/rsLocklessFifo.cpp b/libs/rs/rsLocklessFifo.cpp index 37ec14b5ae646..fae92e52a2881 100644 --- a/libs/rs/rsLocklessFifo.cpp +++ b/libs/rs/rsLocklessFifo.cpp @@ -18,7 +18,6 @@ using namespace android; -#include LocklessCommandFifo::LocklessCommandFifo() { diff --git a/libs/rs/rsLocklessFifo.h b/libs/rs/rsLocklessFifo.h index 2f4d5c5a4df3e..abeddf76a26c2 100644 --- a/libs/rs/rsLocklessFifo.h +++ b/libs/rs/rsLocklessFifo.h @@ -18,10 +18,7 @@ #define ANDROID_RS_LOCKLESS_FIFO_H -#include -#include -#include -#include +#include "rsUtils.h" namespace android { diff --git a/libs/rs/rsMatrix.cpp b/libs/rs/rsMatrix.cpp index 258b836bc8942..5f6819765d527 100644 --- a/libs/rs/rsMatrix.cpp +++ b/libs/rs/rsMatrix.cpp @@ -20,8 +20,6 @@ #include "string.h" #include "math.h" -#include - using namespace android; using namespace android::renderscript; diff --git a/libs/rs/rsObjectBase.cpp b/libs/rs/rsObjectBase.cpp index 8f5232a6e420e..6842c372451a2 100644 --- a/libs/rs/rsObjectBase.cpp +++ b/libs/rs/rsObjectBase.cpp @@ -15,7 +15,6 @@ */ #include "rsObjectBase.h" -#include using namespace android; using namespace android::renderscript; diff --git a/libs/rs/rsProgramFragment.cpp b/libs/rs/rsProgramFragment.cpp index 8777335ae8005..f9eb1b269b8b5 100644 --- a/libs/rs/rsProgramFragment.cpp +++ b/libs/rs/rsProgramFragment.cpp @@ -17,6 +17,9 @@ #include "rsContext.h" #include "rsProgramFragment.h" +#include +#include + using namespace android; using namespace android::renderscript; diff --git a/libs/rs/rsProgramFragmentStore.cpp b/libs/rs/rsProgramFragmentStore.cpp index 96d37ae1af2d4..0b6568036bb5f 100644 --- a/libs/rs/rsProgramFragmentStore.cpp +++ b/libs/rs/rsProgramFragmentStore.cpp @@ -17,6 +17,9 @@ #include "rsContext.h" #include "rsProgramFragmentStore.h" +#include +#include + using namespace android; using namespace android::renderscript; diff --git a/libs/rs/rsProgramVertex.cpp b/libs/rs/rsProgramVertex.cpp index 19afad54fc0a0..ec666627367e0 100644 --- a/libs/rs/rsProgramVertex.cpp +++ b/libs/rs/rsProgramVertex.cpp @@ -17,6 +17,9 @@ #include "rsContext.h" #include "rsProgramVertex.h" +#include +#include + using namespace android; using namespace android::renderscript; diff --git a/libs/rs/rsSampler.cpp b/libs/rs/rsSampler.cpp index d89346e16cc98..418f1279c0579 100644 --- a/libs/rs/rsSampler.cpp +++ b/libs/rs/rsSampler.cpp @@ -14,16 +14,13 @@ * limitations under the License. */ -#include "rsContext.h" - - #include #include -#include #include "rsContext.h" #include "rsSampler.h" + using namespace android; using namespace android::renderscript; diff --git a/libs/rs/rsSampler.h b/libs/rs/rsSampler.h index 45d8c617b2334..4b504f68cc44f 100644 --- a/libs/rs/rsSampler.h +++ b/libs/rs/rsSampler.h @@ -17,11 +17,6 @@ #ifndef ANDROID_RS_SAMPLER_H #define ANDROID_RS_SAMPLER_H -#include -#include -#include -#include - #include "rsAllocation.h" #include "RenderScript.h" diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp index e170b8ca9d8fb..27c13bd41af6f 100644 --- a/libs/rs/rsScriptC.cpp +++ b/libs/rs/rsScriptC.cpp @@ -21,6 +21,9 @@ #include "acc/acc.h" #include "utils/String8.h" +#include +#include + using namespace android; using namespace android::renderscript; diff --git a/libs/rs/rsThreadIO.cpp b/libs/rs/rsThreadIO.cpp index 56415819adbb2..5f62ad1cda9f2 100644 --- a/libs/rs/rsThreadIO.cpp +++ b/libs/rs/rsThreadIO.cpp @@ -16,8 +16,6 @@ #include "rsContext.h" -#include - #include "rsThreadIO.h" using namespace android; diff --git a/libs/rs/rsThreadIO.h b/libs/rs/rsThreadIO.h index 973ee05e324d6..72746c55fba53 100644 --- a/libs/rs/rsThreadIO.h +++ b/libs/rs/rsThreadIO.h @@ -17,11 +17,7 @@ #ifndef ANDROID_RS_THREAD_IO_H #define ANDROID_RS_THREAD_IO_H -#include -#include - -#include "RenderScript.h" - +#include "rsUtils.h" #include "rsLocklessFifo.h" // --------------------------------------------------------------------------- diff --git a/libs/rs/rsTriangleMesh.cpp b/libs/rs/rsTriangleMesh.cpp index 6595ebc3fa93b..f26b7659918e7 100644 --- a/libs/rs/rsTriangleMesh.cpp +++ b/libs/rs/rsTriangleMesh.cpp @@ -22,8 +22,6 @@ using namespace android::renderscript; #include #include -#include - TriangleMesh::TriangleMesh() { mVertexElement = NULL; diff --git a/libs/rs/rsTriangleMesh.h b/libs/rs/rsTriangleMesh.h index 4e15d5abd7d0c..e56c7c293b2dc 100644 --- a/libs/rs/rsTriangleMesh.h +++ b/libs/rs/rsTriangleMesh.h @@ -17,15 +17,6 @@ #ifndef ANDROID_RS_TRIANGLE_MESH_H #define ANDROID_RS_TRIANGLE_MESH_H -#include -#include - -#include -#include -#include -#include - -#include #include "RenderScript.h" @@ -60,7 +51,7 @@ public: size_t mSizeNorm; // GL buffer info - GLuint mBufferObjects[2]; + uint32_t mBufferObjects[2]; void analyzeElement(); protected: diff --git a/libs/rs/rsUtils.h b/libs/rs/rsUtils.h index 5a43fb3f8e570..0a310974ace77 100644 --- a/libs/rs/rsUtils.h +++ b/libs/rs/rsUtils.h @@ -17,9 +17,13 @@ #ifndef ANDROID_RS_UTILS_H #define ANDROID_RS_UTILS_H -#include -#include +#include "RenderScript.h" + +#define LOG_TAG "rs" +#include +#include #include +#include namespace android { namespace renderscript {