summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
Diffstat (limited to 'libs')
-rw-r--r--libs/rs/Android.mk1
-rw-r--r--libs/rs/RenderScript.h1
-rw-r--r--libs/rs/RenderScriptEnv.h1
-rw-r--r--libs/rs/java/Film/src/com/android/film/FilmRS.java5
-rw-r--r--libs/rs/java/Fountain/res/raw/fountain.c3
-rw-r--r--libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java20
-rw-r--r--libs/rs/java/RenderScript/android/renderscript/RSSurfaceView.java22
-rw-r--r--libs/rs/java/RenderScript/android/renderscript/RenderScript.java48
-rw-r--r--libs/rs/jni/RenderScript_jni.cpp75
-rw-r--r--libs/rs/rs.spec33
-rw-r--r--libs/rs/rsAllocation.cpp8
-rw-r--r--libs/rs/rsComponent.h6
-rw-r--r--libs/rs/rsContext.cpp14
-rw-r--r--libs/rs/rsContext.h5
-rw-r--r--libs/rs/rsDevice.h4
-rw-r--r--libs/rs/rsElement.cpp2
-rw-r--r--libs/rs/rsElement.h2
-rw-r--r--libs/rs/rsLight.cpp123
-rw-r--r--libs/rs/rsLight.h62
-rw-r--r--libs/rs/rsLocklessFifo.cpp10
-rw-r--r--libs/rs/rsLocklessFifo.h5
-rw-r--r--libs/rs/rsMatrix.cpp2
-rw-r--r--libs/rs/rsObjectBase.cpp5
-rw-r--r--libs/rs/rsProgramFragment.cpp5
-rw-r--r--libs/rs/rsProgramFragmentStore.cpp3
-rw-r--r--libs/rs/rsProgramVertex.cpp13
-rw-r--r--libs/rs/rsSampler.cpp5
-rw-r--r--libs/rs/rsSampler.h5
-rw-r--r--libs/rs/rsScriptC.cpp7
-rw-r--r--libs/rs/rsThreadIO.cpp9
-rw-r--r--libs/rs/rsThreadIO.h6
-rw-r--r--libs/rs/rsTriangleMesh.cpp15
-rw-r--r--libs/rs/rsTriangleMesh.h11
-rw-r--r--libs/rs/rsType.cpp13
-rw-r--r--libs/rs/rsUtils.h9
-rw-r--r--libs/ui/Camera.cpp131
-rw-r--r--libs/utils/BackupData.cpp21
-rw-r--r--libs/utils/BackupHelpers.cpp164
-rw-r--r--libs/utils/ResourceTypes.cpp22
39 files changed, 592 insertions, 304 deletions
diff --git a/libs/rs/Android.mk b/libs/rs/Android.mk
index 06c0595..f5297f8 100644
--- a/libs/rs/Android.mk
+++ b/libs/rs/Android.mk
@@ -85,6 +85,7 @@ LOCAL_SRC_FILES:= \
rsContext.cpp \
rsDevice.cpp \
rsElement.cpp \
+ rsLight.cpp \
rsLocklessFifo.cpp \
rsObjectBase.cpp \
rsMatrix.cpp \
diff --git a/libs/rs/RenderScript.h b/libs/rs/RenderScript.h
index 2b33419..734fba7 100644
--- a/libs/rs/RenderScript.h
+++ b/libs/rs/RenderScript.h
@@ -38,6 +38,7 @@ typedef void * RsScript;
typedef void * RsScriptBasicTemp;
typedef void * RsTriangleMesh;
typedef void * RsType;
+typedef void * RsLight;
typedef void * RsProgramVertex;
typedef void * RsProgramFragment;
diff --git a/libs/rs/RenderScriptEnv.h b/libs/rs/RenderScriptEnv.h
index 221ab41..53de1f1 100644
--- a/libs/rs/RenderScriptEnv.h
+++ b/libs/rs/RenderScriptEnv.h
@@ -14,6 +14,7 @@ typedef void * RsTriangleMesh;
typedef void * RsType;
typedef void * RsProgramFragment;
typedef void * RsProgramFragmentStore;
+typedef void * RsLight;
typedef struct {
diff --git a/libs/rs/java/Film/src/com/android/film/FilmRS.java b/libs/rs/java/Film/src/com/android/film/FilmRS.java
index 5c6a6fa..2711bf0 100644
--- a/libs/rs/java/Film/src/com/android/film/FilmRS.java
+++ b/libs/rs/java/Film/src/com/android/film/FilmRS.java
@@ -85,6 +85,7 @@ public class FilmRS {
private RenderScript.Allocation mAllocState;
private RenderScript.Allocation mAllocPV;
private RenderScript.TriangleMesh mMesh;
+ private RenderScript.Light mLight;
private float[] mBufferPos;
private float[] mBufferPV;
@@ -144,6 +145,10 @@ public class FilmRS {
mPV = mRS.programVertexCreate();
mPV.setName("PV");
+ mRS.lightBegin();
+ mLight = mRS.lightCreate();
+ mLight.setPosition(0, -0.5f, -1.0f);
+
Log.e("rs", "Done loading named");
}
diff --git a/libs/rs/java/Fountain/res/raw/fountain.c b/libs/rs/java/Fountain/res/raw/fountain.c
index 8a55406..6919565 100644
--- a/libs/rs/java/Fountain/res/raw/fountain.c
+++ b/libs/rs/java/Fountain/res/raw/fountain.c
@@ -3,7 +3,7 @@
#pragma version(1)
#pragma stateVertex(default)
#pragma stateFragment(PgmFragBackground)
-#pragma stateFragmentStore(parent)
+#pragma stateFragmentStore(PFSReplace)
int main(int launchID) {
@@ -36,6 +36,7 @@ int main(int launchID) {
drawRect(0, 256, 0, 512);
contextBindProgramFragment(NAMED_PgmFragParts);
+ contextBindProgramFragmentStore(NAMED_PFSBlend);
if (touch) {
newPart = loadI32(2, 0);
diff --git a/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java b/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java
index 467115a..745635f 100644
--- a/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java
+++ b/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java
@@ -56,6 +56,7 @@ public class FountainRS {
private RenderScript.Allocation mVertAlloc;
private RenderScript.Script mScript;
private RenderScript.ProgramFragmentStore mPFS;
+ private RenderScript.ProgramFragmentStore mPFS2;
private RenderScript.ProgramFragment mPF;
private RenderScript.ProgramFragment mPF2;
private RenderScript.Allocation mTexture;
@@ -79,20 +80,29 @@ public class FountainRS {
Bitmap b = bd.getBitmap();
mTexture = mRS.allocationCreateFromBitmap(b,
RenderScript.ElementPredefined.RGB_565,
- true);
+ false);
mTexture.uploadToTexture(0);
}
mRS.programFragmentStoreBegin(null, null);
mRS.programFragmentStoreBlendFunc(RenderScript.BlendSrcFunc.SRC_ALPHA, RenderScript.BlendDstFunc.ONE);
mRS.programFragmentStoreDepthFunc(RenderScript.DepthFunc.ALWAYS);
+ mRS.programFragmentStoreDepthMask(false);
+ mRS.programFragmentStoreDitherEnable(false);
mPFS = mRS.programFragmentStoreCreate();
- mPFS.setName("MyBlend");
- mRS.contextBindProgramFragmentStore(mPFS);
+ mPFS.setName("PFSBlend");
+
+ mRS.programFragmentStoreBegin(null, null);
+ mRS.programFragmentStoreDepthFunc(RenderScript.DepthFunc.ALWAYS);
+ mRS.programFragmentStoreDepthMask(false);
+ mRS.programFragmentStoreDitherEnable(false);
+ mPFS2 = mRS.programFragmentStoreCreate();
+ mPFS2.setName("PFSReplace");
+ mRS.contextBindProgramFragmentStore(mPFS2);
mRS.samplerBegin();
- mRS.samplerSet(RenderScript.SamplerParam.FILTER_MAG, RenderScript.SamplerValue.LINEAR);
- mRS.samplerSet(RenderScript.SamplerParam.FILTER_MIN, RenderScript.SamplerValue.LINEAR);
+ mRS.samplerSet(RenderScript.SamplerParam.FILTER_MAG, RenderScript.SamplerValue.NEAREST);
+ mRS.samplerSet(RenderScript.SamplerParam.FILTER_MIN, RenderScript.SamplerValue.NEAREST);
mSampler = mRS.samplerCreate();
diff --git a/libs/rs/java/RenderScript/android/renderscript/RSSurfaceView.java b/libs/rs/java/RenderScript/android/renderscript/RSSurfaceView.java
index 3d37c13..3835793 100644
--- a/libs/rs/java/RenderScript/android/renderscript/RSSurfaceView.java
+++ b/libs/rs/java/RenderScript/android/renderscript/RSSurfaceView.java
@@ -40,7 +40,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback
public RSSurfaceView(Context context) {
super(context);
init();
- Log.v("***", "RSSurfaceView");
+ Log.v(RenderScript.LOG_TAG, "RSSurfaceView");
}
/**
@@ -50,7 +50,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback
public RSSurfaceView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
- Log.v("***", "RSSurfaceView");
+ Log.v(RenderScript.LOG_TAG, "RSSurfaceView");
}
private void init() {
@@ -66,7 +66,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback
* not normally called or subclassed by clients of RSSurfaceView.
*/
public void surfaceCreated(SurfaceHolder holder) {
- Log.v("***", "surfaceCreated");
+ Log.v(RenderScript.LOG_TAG, "surfaceCreated");
mSurfaceHolder = holder;
//mGLThread.surfaceCreated();
}
@@ -77,7 +77,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback
*/
public void surfaceDestroyed(SurfaceHolder holder) {
// Surface will be destroyed when we return
- Log.v("***", "surfaceDestroyed");
+ Log.v(RenderScript.LOG_TAG, "surfaceDestroyed");
//mGLThread.surfaceDestroyed();
}
@@ -86,7 +86,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback
* not normally called or subclassed by clients of RSSurfaceView.
*/
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
- Log.v("***", "surfaceChanged");
+ Log.v(RenderScript.LOG_TAG, "surfaceChanged");
//mGLThread.onWindowResize(w, h);
}
@@ -98,7 +98,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback
* Must not be called before a renderer has been set.
*/
public void onPause() {
- Log.v("***", "onPause");
+ Log.v(RenderScript.LOG_TAG, "onPause");
//mGLThread.onPause();
}
@@ -110,7 +110,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback
* Must not be called before a renderer has been set.
*/
public void onResume() {
- Log.v("***", "onResume");
+ Log.v(RenderScript.LOG_TAG, "onResume");
//mGLThread.onResume();
}
@@ -121,7 +121,7 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback
* @param r the runnable to be run on the GL rendering thread.
*/
public void queueEvent(Runnable r) {
- Log.v("***", "queueEvent");
+ Log.v(RenderScript.LOG_TAG, "queueEvent");
//mGLThread.queueEvent(r);
}
@@ -139,14 +139,14 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback
// ----------------------------------------------------------------------
public RenderScript createRenderScript() {
- Log.v("***", "createRenderScript 1");
+ Log.v(RenderScript.LOG_TAG, "createRenderScript 1");
Surface sur = null;
while ((sur == null) || (mSurfaceHolder == null)) {
sur = getHolder().getSurface();
}
- Log.v("***", "createRenderScript 2");
+ Log.v(RenderScript.LOG_TAG, "createRenderScript 2");
RenderScript rs = new RenderScript(sur);
- Log.v("***", "createRenderScript 3 rs");
+ Log.v(RenderScript.LOG_TAG, "createRenderScript 3 rs");
return rs;
}
diff --git a/libs/rs/java/RenderScript/android/renderscript/RenderScript.java b/libs/rs/java/RenderScript/android/renderscript/RenderScript.java
index 4d5c4a0..a9db15f 100644
--- a/libs/rs/java/RenderScript/android/renderscript/RenderScript.java
+++ b/libs/rs/java/RenderScript/android/renderscript/RenderScript.java
@@ -32,7 +32,7 @@ import android.graphics.Bitmap;
import android.graphics.Color;
public class RenderScript {
- private static final String LOG_TAG = "libRS_jni";
+ static final String LOG_TAG = "libRS_jni";
private static final boolean DEBUG = false;
private static final boolean LOG_ENABLED = DEBUG ? Config.LOGD : Config.LOGV;
@@ -157,6 +157,14 @@ public class RenderScript {
native private void nProgramVertexSetTextureMatrixEnable(boolean enable);
native private int nProgramVertexCreate();
+ native private void nLightBegin();
+ native private void nLightSetIsMono(boolean isMono);
+ native private void nLightSetIsLocal(boolean isLocal);
+ native private int nLightCreate();
+ native private void nLightDestroy(int l);
+ native private void nLightSetColor(int l, float r, float g, float b);
+ native private void nLightSetPosition(int l, float x, float y, float z);
+
private int mDev;
private int mContext;
@@ -869,6 +877,44 @@ public class RenderScript {
return new Sampler(id);
}
+ //////////////////////////////////////////////////////////////////////////////////
+ // Light
+
+ public class Light extends BaseObj {
+ Light(int id) {
+ mID = id;
+ }
+
+ public void destroy() {
+ nLightDestroy(mID);
+ mID = 0;
+ }
+
+ public void setColor(float r, float g, float b) {
+ nLightSetColor(mID, r, g, b);
+ }
+
+ public void setPosition(float x, float y, float z) {
+ nLightSetPosition(mID, x, y, z);
+ }
+ }
+
+ public void lightBegin() {
+ nLightBegin();
+ }
+
+ public void lightSetIsMono(boolean isMono) {
+ nLightSetIsMono(isMono);
+ }
+
+ public void lightSetIsLocal(boolean isLocal) {
+ nLightSetIsLocal(isLocal);
+ }
+
+ public Light lightCreate() {
+ int id = nLightCreate();
+ return new Light(id);
+ }
///////////////////////////////////////////////////////////////////////////////////
// Root state
diff --git a/libs/rs/jni/RenderScript_jni.cpp b/libs/rs/jni/RenderScript_jni.cpp
index dcf3850..5677bb7 100644
--- a/libs/rs/jni/RenderScript_jni.cpp
+++ b/libs/rs/jni/RenderScript_jni.cpp
@@ -14,19 +14,20 @@
* limitations under the License.
*/
+#define LOG_TAG "libRS_jni"
+
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <math.h>
-
#include <utils/misc.h>
-#include <utils/Log.h>
#include <ui/Surface.h>
#include <core/SkBitmap.h>
+
#include "jni.h"
#include "JNIHelp.h"
#include "android_runtime/AndroidRuntime.h"
@@ -107,7 +108,6 @@ nContextCreate(JNIEnv *_env, jobject _this, jint dev, jobject wnd, jint ver)
if (window == NULL)
goto not_valid_surface;
- LOGE("nContextCreate 5");
return (jint)rsContextCreate((RsDevice)dev, window, ver);
}
@@ -880,10 +880,67 @@ static jint
nSamplerCreate(JNIEnv *_env, jobject _this)
{
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
- LOG_API("nSamplerCreate, con(%p), script(%p)", con, (RsScript)script);
+ LOG_API("nSamplerCreate, con(%p)", con);
return (jint)rsSamplerCreate();
}
+// ---------------------------------------------------------------------------
+
+static void
+nLightBegin(JNIEnv *_env, jobject _this)
+{
+ RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
+ LOG_API("nLightBegin, con(%p)", con);
+ rsLightBegin();
+}
+
+static void
+nLightSetIsMono(JNIEnv *_env, jobject _this, jboolean isMono)
+{
+ RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
+ LOG_API("nLightSetIsMono, con(%p), isMono(%i)", con, isMono);
+ rsLightSetMonochromatic(isMono);
+}
+
+static void
+nLightSetIsLocal(JNIEnv *_env, jobject _this, jboolean isLocal)
+{
+ RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
+ LOG_API("nLightSetIsLocal, con(%p), isLocal(%i)", con, isLocal);
+ rsLightSetLocal(isLocal);
+}
+
+static jint
+nLightCreate(JNIEnv *_env, jobject _this)
+{
+ RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
+ LOG_API("nLightCreate, con(%p)", con);
+ return (jint)rsLightCreate();
+}
+
+static void
+nLightDestroy(JNIEnv *_env, jobject _this, jint light)
+{
+ RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
+ LOG_API("nLightDestroy, con(%p), light(%p)", con, (RsLight)light);
+ rsLightDestroy((RsLight)light);
+}
+
+static void
+nLightSetColor(JNIEnv *_env, jobject _this, jint light, float r, float g, float b)
+{
+ RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
+ LOG_API("nLightSetColor, con(%p), light(%p), r(%f), g(%f), b(%f)", con, (RsLight)light, r, g, b);
+ rsLightSetColor((RsLight)light, r, g, b);
+}
+
+static void
+nLightSetPosition(JNIEnv *_env, jobject _this, jint light, float x, float y, float z)
+{
+ RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
+ LOG_API("nLightSetPosition, con(%p), light(%p), x(%f), y(%f), z(%f)", con, (RsLight)light, x, y, z);
+ rsLightSetPosition((RsLight)light, x, y, z);
+}
// ---------------------------------------------------------------------------
@@ -978,6 +1035,14 @@ static JNINativeMethod methods[] = {
{"nProgramVertexSetTextureMatrixEnable", "(Z)V", (void*)nProgramVertexSetTextureMatrixEnable },
{"nProgramVertexCreate", "()I", (void*)nProgramVertexCreate },
+{"nLightBegin", "()V", (void*)nLightBegin },
+{"nLightSetIsMono", "(Z)V", (void*)nLightSetIsMono },
+{"nLightSetIsLocal", "(Z)V", (void*)nLightSetIsLocal },
+{"nLightCreate", "()I", (void*)nLightCreate },
+{"nLightDestroy", "(I)V", (void*)nLightDestroy },
+{"nLightSetColor", "(IFFF)V", (void*)nLightSetColor },
+{"nLightSetPosition", "(IFFF)V", (void*)nLightSetPosition },
+
{"nContextBindRootScript", "(I)V", (void*)nContextBindRootScript },
{"nContextBindProgramFragmentStore","(I)V", (void*)nContextBindProgramFragmentStore },
{"nContextBindProgramFragment", "(I)V", (void*)nContextBindProgramFragment },
@@ -1003,8 +1068,6 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved)
JNIEnv* env = NULL;
jint result = -1;
- LOGE("****************************************************\n");
-
if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
LOGE("ERROR: GetEnv failed\n");
goto bail;
diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec
index dd489b8..fadda59 100644
--- a/libs/rs/rs.spec
+++ b/libs/rs/rs.spec
@@ -403,3 +403,36 @@ ProgramVertexSetTextureMatrixEnable {
param bool enable
}
+LightBegin {
+ }
+
+LightSetLocal {
+ param bool isLocal
+ }
+
+LightSetMonochromatic {
+ param bool isMono
+ }
+
+LightCreate {
+ ret RsLight light
+ }
+
+LightDestroy {
+ param RsLight light
+ }
+
+LightSetPosition {
+ param RsLight light
+ param float x
+ param float y
+ param float z
+ }
+
+LightSetColor {
+ param RsLight light
+ param float r
+ param float g
+ param float b
+ }
+
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp
index 3a01a75..bc14eac 100644
--- a/libs/rs/rsAllocation.cpp
+++ b/libs/rs/rsAllocation.cpp
@@ -16,6 +16,9 @@
#include "rsContext.h"
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+
using namespace android;
using namespace android::renderscript;
@@ -47,7 +50,6 @@ Allocation::Allocation(const Type *type)
Allocation::~Allocation()
{
- LOGE("Allocation %p destryed", this);
}
void Allocation::setCpuWritable(bool)
@@ -76,8 +78,6 @@ void Allocation::uploadToTexture(uint32_t lodOffset)
//rsAssert(!mTextureId);
rsAssert(lodOffset < mType->getLODCount());
- //LOGE("uploadToTexture %i, lod %i", mTextureID, lodOffset);
-
GLenum type = mType->getElement()->getGLType();
GLenum format = mType->getElement()->getGLFormat();
@@ -106,8 +106,6 @@ void Allocation::uploadToBufferObject()
rsAssert(!mType->getDimY());
rsAssert(!mType->getDimZ());
- //LOGE("uploadToTexture %i, lod %i", mTextureID, lodOffset);
-
if (!mBufferID) {
glGenBuffers(1, &mBufferID);
}
diff --git a/libs/rs/rsComponent.h b/libs/rs/rsComponent.h
index 205e575..e1b0585 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 <stdint.h>
-#include <sys/types.h>
-#include <stdlib.h>
-
-#include "RenderScript.h"
+#include "rsUtils.h"
#include "rsObjectBase.h"
// ---------------------------------------------------------------------------
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index 455c18d..4025ff8 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -20,6 +20,9 @@
#include "utils/String8.h"
#include <ui/FramebufferNativeWindow.h>
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+
using namespace android;
using namespace android::renderscript;
@@ -116,9 +119,6 @@ void * Context::threadProc(void *vrsc)
Context *rsc = static_cast<Context *>(vrsc);
gIO = new ThreadIO();
- rsc->mServerCommands.init(128);
- rsc->mServerReturns.init(128);
-
rsc->initEGL();
ScriptTLSStruct *tlsStruct = new ScriptTLSStruct;
@@ -166,9 +166,6 @@ Context::Context(Device *dev, Surface *sur)
mRunning = false;
mExit = false;
- mServerCommands.init(256);
- mServerReturns.init(256);
-
// see comment in header
gCon = this;
@@ -191,13 +188,14 @@ Context::Context(Device *dev, Surface *sur)
sparam.sched_priority = ANDROID_PRIORITY_DISPLAY;
pthread_attr_setschedparam(&threadAttr, &sparam);
- LOGE("RS Launching thread");
+ mWndSurface = sur;
+
+ LOGV("RS Launching thread");
status = pthread_create(&mThreadId, &threadAttr, threadProc, this);
if (status) {
LOGE("Failed to start rs context thread.");
}
- mWndSurface = sur;
while(!mRunning) {
sleep(1);
}
diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h
index e9d75e0..4d96a77 100644
--- a/libs/rs/rsContext.h
+++ b/libs/rs/rsContext.h
@@ -32,6 +32,7 @@
#include "rsProgramFragment.h"
#include "rsProgramFragmentStore.h"
#include "rsProgramVertex.h"
+#include "rsLight.h"
#include "rsgApiStructs.h"
#include "rsLocklessFifo.h"
@@ -61,6 +62,7 @@ public:
ProgramFragmentState mStateFragment;
ProgramFragmentStoreState mStateFragmentStore;
ProgramVertexState mStateVertex;
+ LightState mStateLight;
TriangleMeshContext mStateTriangleMesh;
@@ -113,9 +115,6 @@ protected:
bool mRunning;
bool mExit;
- LocklessCommandFifo mServerCommands;
- LocklessCommandFifo mServerReturns;
-
pthread_t mThreadId;
ObjectBaseRef<Script> mRootScript;
diff --git a/libs/rs/rsDevice.h b/libs/rs/rsDevice.h
index 3de3ffa..156315f 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 <utils/Vector.h>
-
-//#include "StructuredComponent.h"
+#include "rsUtils.h"
// ---------------------------------------------------------------------------
namespace android {
diff --git a/libs/rs/rsElement.cpp b/libs/rs/rsElement.cpp
index 5a44f47..069a128 100644
--- a/libs/rs/rsElement.cpp
+++ b/libs/rs/rsElement.cpp
@@ -410,8 +410,6 @@ RsElement rsi_ElementCreate(Context *rsc)
rsc->mStateElement.mComponentBuildList.clear();
se->incRef();
-
- LOGE("Create %p", se);
return se;
}
diff --git a/libs/rs/rsElement.h b/libs/rs/rsElement.h
index 2434977..ea6fa8f 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 <utils/Vector.h>
-
#include "rsComponent.h"
// ---------------------------------------------------------------------------
diff --git a/libs/rs/rsLight.cpp b/libs/rs/rsLight.cpp
new file mode 100644
index 0000000..67d0095
--- /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<Light *>(vl);
+ l->decRef();
+}
+
+void rsi_LightSetColor(Context *rsc, RsLight vl, float r, float g, float b)
+{
+ Light *l = static_cast<Light *>(vl);
+ l->setColor(r, g, b);
+}
+
+void rsi_LightSetPosition(Context *rsc, RsLight vl, float x, float y, float z)
+{
+ Light *l = static_cast<Light *>(vl);
+ l->setPosition(x, y, z);
+}
+
+
+
+}
+}
diff --git a/libs/rs/rsLight.h b/libs/rs/rsLight.h
new file mode 100644
index 0000000..76d1ecc
--- /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 37ec14b..c3fee54 100644
--- a/libs/rs/rsLocklessFifo.cpp
+++ b/libs/rs/rsLocklessFifo.cpp
@@ -18,7 +18,6 @@
using namespace android;
-#include <utils/Log.h>
LocklessCommandFifo::LocklessCommandFifo()
{
@@ -65,8 +64,6 @@ uint32_t LocklessCommandFifo::getFreeSpace() const
if (freeSpace < 0) {
freeSpace = 0;
}
-
- //LOGE("free %i", freeSpace);
return freeSpace;
}
@@ -91,13 +88,11 @@ void * LocklessCommandFifo::reserve(uint32_t sizeInBytes)
void LocklessCommandFifo::commit(uint32_t command, uint32_t sizeInBytes)
{
- //LOGE("commit cmd %i size %i", command, sizeInBytes);
//dumpState("commit 1");
reinterpret_cast<uint16_t *>(mPut)[0] = command;
reinterpret_cast<uint16_t *>(mPut)[1] = sizeInBytes;
mPut += ((sizeInBytes + 3) & ~3) + 4;
//dumpState("commit 2");
-
mSignalToWorker.set();
}
@@ -124,12 +119,9 @@ const void * LocklessCommandFifo::get(uint32_t *command, uint32_t *bytesData)
mSignalToControl.set();
mSignalToWorker.wait();
}
- //dumpState("get 3");
*command = reinterpret_cast<const uint16_t *>(mGet)[0];
*bytesData = reinterpret_cast<const uint16_t *>(mGet)[1];
- //LOGE("Got %i, %i", *command, *bytesData);
-
if (*command) {
// non-zero command is valid
return mGet+4;
@@ -174,7 +166,7 @@ void LocklessCommandFifo::makeSpace(uint32_t bytes)
void LocklessCommandFifo::dumpState(const char *s) const
{
- LOGE("%s put %p, get %p, buf %p, end %p", s, mPut, mGet, mBuffer, mEnd);
+ LOGV("%s put %p, get %p, buf %p, end %p", s, mPut, mGet, mBuffer, mEnd);
}
LocklessCommandFifo::Signal::Signal()
diff --git a/libs/rs/rsLocklessFifo.h b/libs/rs/rsLocklessFifo.h
index 2f4d5c5..abeddf7 100644
--- a/libs/rs/rsLocklessFifo.h
+++ b/libs/rs/rsLocklessFifo.h
@@ -18,10 +18,7 @@
#define ANDROID_RS_LOCKLESS_FIFO_H
-#include <stdint.h>
-#include <sys/types.h>
-#include <stdlib.h>
-#include <pthread.h>
+#include "rsUtils.h"
namespace android {
diff --git a/libs/rs/rsMatrix.cpp b/libs/rs/rsMatrix.cpp
index 258b836..5f68197 100644
--- a/libs/rs/rsMatrix.cpp
+++ b/libs/rs/rsMatrix.cpp
@@ -20,8 +20,6 @@
#include "string.h"
#include "math.h"
-#include <utils/Log.h>
-
using namespace android;
using namespace android::renderscript;
diff --git a/libs/rs/rsObjectBase.cpp b/libs/rs/rsObjectBase.cpp
index 8f5232a..3219c39 100644
--- a/libs/rs/rsObjectBase.cpp
+++ b/libs/rs/rsObjectBase.cpp
@@ -15,7 +15,6 @@
*/
#include "rsObjectBase.h"
-#include <utils/Log.h>
using namespace android;
using namespace android::renderscript;
@@ -34,14 +33,14 @@ ObjectBase::~ObjectBase()
void ObjectBase::incRef() const
{
mRefCount ++;
- //LOGE("ObjectBase %p inc ref %i", this, mRefCount);
+ //LOGV("ObjectBase %p inc ref %i", this, mRefCount);
}
void ObjectBase::decRef() const
{
rsAssert(mRefCount > 0);
mRefCount --;
- //LOGE("ObjectBase %p dec ref %i", this, mRefCount);
+ //LOGV("ObjectBase %p dec ref %i", this, mRefCount);
if (!mRefCount) {
delete this;
}
diff --git a/libs/rs/rsProgramFragment.cpp b/libs/rs/rsProgramFragment.cpp
index 8777335..f2e7095 100644
--- a/libs/rs/rsProgramFragment.cpp
+++ b/libs/rs/rsProgramFragment.cpp
@@ -17,6 +17,9 @@
#include "rsContext.h"
#include "rsProgramFragment.h"
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+
using namespace android;
using namespace android::renderscript;
@@ -168,8 +171,6 @@ void rsi_ProgramFragmentBindTexture(Context *rsc, RsProgramFragment vpf, uint32_
{
ProgramFragment *pf = static_cast<ProgramFragment *>(vpf);
pf->bindTexture(slot, static_cast<Allocation *>(a));
-
- //LOGE("%p %p", pf, rsc->getFragment());
if (pf == rsc->getFragment()) {
pf->setupGL();
}
diff --git a/libs/rs/rsProgramFragmentStore.cpp b/libs/rs/rsProgramFragmentStore.cpp
index 96d37ae..0b65680 100644
--- a/libs/rs/rsProgramFragmentStore.cpp
+++ b/libs/rs/rsProgramFragmentStore.cpp
@@ -17,6 +17,9 @@
#include "rsContext.h"
#include "rsProgramFragmentStore.h"
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+
using namespace android;
using namespace android::renderscript;
diff --git a/libs/rs/rsProgramVertex.cpp b/libs/rs/rsProgramVertex.cpp
index 19afad5..4089507 100644
--- a/libs/rs/rsProgramVertex.cpp
+++ b/libs/rs/rsProgramVertex.cpp
@@ -17,6 +17,9 @@
#include "rsContext.h"
#include "rsProgramVertex.h"
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+
using namespace android;
using namespace android::renderscript;
@@ -33,11 +36,11 @@ ProgramVertex::~ProgramVertex()
static void logMatrix(const char *txt, const float *f)
{
- LOGE("Matrix %s, %p", txt, f);
- LOGE("%6.2f, %6.2f, %6.2f, %6.2f", f[0], f[4], f[8], f[12]);
- LOGE("%6.2f, %6.2f, %6.2f, %6.2f", f[1], f[5], f[9], f[13]);
- LOGE("%6.2f, %6.2f, %6.2f, %6.2f", f[2], f[6], f[10], f[14]);
- LOGE("%6.2f, %6.2f, %6.2f, %6.2f", f[3], f[7], f[11], f[15]);
+ LOGV("Matrix %s, %p", txt, f);
+ LOGV("%6.2f, %6.2f, %6.2f, %6.2f", f[0], f[4], f[8], f[12]);
+ LOGV("%6.2f, %6.2f, %6.2f, %6.2f", f[1], f[5], f[9], f[13]);
+ LOGV("%6.2f, %6.2f, %6.2f, %6.2f", f[2], f[6], f[10], f[14]);
+ LOGV("%6.2f, %6.2f, %6.2f, %6.2f", f[3], f[7], f[11], f[15]);
}
void ProgramVertex::setupGL()
diff --git a/libs/rs/rsSampler.cpp b/libs/rs/rsSampler.cpp
index d89346e..418f127 100644
--- a/libs/rs/rsSampler.cpp
+++ b/libs/rs/rsSampler.cpp
@@ -14,16 +14,13 @@
* limitations under the License.
*/
-#include "rsContext.h"
-
-
#include <GLES/gl.h>
#include <GLES/glext.h>
-#include <utils/Log.h>
#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 45d8c61..4b504f6 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 <math.h>
-#include <EGL/egl.h>
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-
#include "rsAllocation.h"
#include "RenderScript.h"
diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp
index e170b8c..522ed00 100644
--- a/libs/rs/rsScriptC.cpp
+++ b/libs/rs/rsScriptC.cpp
@@ -21,6 +21,9 @@
#include "acc/acc.h"
#include "utils/String8.h"
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+
using namespace android;
using namespace android::renderscript;
@@ -469,14 +472,10 @@ void ScriptCState::runCompiler(Context *rsc)
accGetPragmas(mAccScript, &pragmaCount, pragmaMax, &str[0]);
for (int ct=0; ct < pragmaCount; ct+=2) {
- LOGE("pragma %i %s %s", ct, str[ct], str[ct+1]);
-
if (!strcmp(str[ct], "version")) {
continue;
-
}
-
if (!strcmp(str[ct], "stateVertex")) {
if (!strcmp(str[ct+1], "default")) {
continue;
diff --git a/libs/rs/rsThreadIO.cpp b/libs/rs/rsThreadIO.cpp
index 5641581..89df59d 100644
--- a/libs/rs/rsThreadIO.cpp
+++ b/libs/rs/rsThreadIO.cpp
@@ -16,8 +16,6 @@
#include "rsContext.h"
-#include <utils/Log.h>
-
#include "rsThreadIO.h"
using namespace android;
@@ -36,22 +34,17 @@ ThreadIO::~ThreadIO()
bool ThreadIO::playCoreCommands(Context *con, bool waitForCommand)
{
- //LOGE("playCoreCommands 1");
uint32_t cmdID = 0;
uint32_t cmdSize = 0;
bool ret = false;
while(!mToCore.isEmpty() || waitForCommand) {
ret = true;
- //LOGE("playCoreCommands 2");
const void * data = mToCore.get(&cmdID, &cmdSize);
waitForCommand = false;
- //LOGE("playCoreCommands 3 %i %i", cmdID, cmdSize);
+ //LOGV("playCoreCommands 3 %i %i", cmdID, cmdSize);
gPlaybackFuncs[cmdID](con, data);
- //LOGE("playCoreCommands 4");
-
mToCore.next();
- //LOGE("playCoreCommands 5");
}
return ret;
}
diff --git a/libs/rs/rsThreadIO.h b/libs/rs/rsThreadIO.h
index 973ee05..72746c5 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 <stdlib.h>
-#include <stdio.h>
-
-#include "RenderScript.h"
-
+#include "rsUtils.h"
#include "rsLocklessFifo.h"
// ---------------------------------------------------------------------------
diff --git a/libs/rs/rsTriangleMesh.cpp b/libs/rs/rsTriangleMesh.cpp
index 6595ebc..8c7bc92 100644
--- a/libs/rs/rsTriangleMesh.cpp
+++ b/libs/rs/rsTriangleMesh.cpp
@@ -22,8 +22,6 @@ using namespace android::renderscript;
#include <GLES/gl.h>
#include <GLES/glext.h>
-#include <utils/Log.h>
-
TriangleMesh::TriangleMesh()
{
mVertexElement = NULL;
@@ -122,7 +120,7 @@ void TriangleMesh::analyzeElement()
mSizeTex = 2;
}
}
- LOGE("TriangleMesh %i,%i %i,%i %i,%i", mSizeCoord, mOffsetCoord, mSizeNorm, mOffsetNorm, mSizeTex, mOffsetTex);
+ LOGV("TriangleMesh %i,%i %i,%i %i,%i", mSizeCoord, mOffsetCoord, mSizeNorm, mOffsetNorm, mSizeTex, mOffsetTex);
}
@@ -132,7 +130,6 @@ namespace renderscript {
void rsi_TriangleMeshBegin(Context *rsc, RsElement vertex, RsElement index)
{
- //LOGE("tmb %p %p", vertex, index);
TriangleMeshContext *tmc = &rsc->mStateTriangleMesh;
tmc->clear();
@@ -141,8 +138,6 @@ void rsi_TriangleMeshBegin(Context *rsc, RsElement vertex, RsElement index)
tmc->mIndexElement = static_cast<Element *>(index);
tmc->mIndexSizeBits = tmc->mIndexElement->getSizeBits();
- //LOGE("Element sizes %i %i", tmc->mVertexSizeBits, tmc->mIndexSizeBits);
-
assert(!(tmc->mVertexSizeBits & 0x7));
assert(!(tmc->mIndexSizeBits & 0x7));
}
@@ -200,8 +195,6 @@ RsTriangleMesh rsi_TriangleMeshCreate(Context *rsc)
return 0;
}
- LOGE("Create mesh, triangleCount %i", tm->mTriangleCount);
-
memcpy(tm->mVertexData, tmc->mVertexData.array(), tm->mVertexDataSize);
memcpy(tm->mIndexData, tmc->mIndexData.array(), tm->mIndexDataSize);
tm->analyzeElement();
@@ -227,8 +220,6 @@ void rsi_TriangleMeshRenderRange(Context *rsc, RsTriangleMesh vtm, uint32_t firs
rsc->setupCheck();
- //LOGE("1 %p ", vtm);
- //LOGE("1.1 %p %p", tm->mVertexData, tm->mIndexData);
if (!tm->mBufferObjects[0]) {
glGenBuffers(2, &tm->mBufferObjects[0]);
@@ -241,7 +232,6 @@ void rsi_TriangleMeshRenderRange(Context *rsc, RsTriangleMesh vtm, uint32_t firs
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
- //LOGE("1.2");
if (first >= tm->mTriangleCount) {
return;
}
@@ -254,7 +244,6 @@ void rsi_TriangleMeshRenderRange(Context *rsc, RsTriangleMesh vtm, uint32_t firs
const float *f = (const float *)tm->mVertexData;
- //LOGE("2");
glBindBuffer(GL_ARRAY_BUFFER, tm->mBufferObjects[0]);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, tm->mBufferObjects[1]);
@@ -285,8 +274,6 @@ void rsi_TriangleMeshRenderRange(Context *rsc, RsTriangleMesh vtm, uint32_t firs
glDrawElements(GL_TRIANGLES, count * 3, GL_UNSIGNED_SHORT, (GLvoid *)(first * 3 * 2));
- //LOGE("4");
-
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
diff --git a/libs/rs/rsTriangleMesh.h b/libs/rs/rsTriangleMesh.h
index 4e15d5a..e56c7c2 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 <stdlib.h>
-#include <stdio.h>
-
-#include <math.h>
-#include <EGL/egl.h>
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-
-#include <utils/Vector.h>
#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/rsType.cpp b/libs/rs/rsType.cpp
index 6b99820..bbe9720 100644
--- a/libs/rs/rsType.cpp
+++ b/libs/rs/rsType.cpp
@@ -63,7 +63,6 @@ size_t Type::getOffsetForFace(uint32_t face) const
void Type::compute()
{
- //LOGE("compute");
uint32_t oldLODCount = mLODCount;
if (mDimLOD) {
uint32_t l2x = rsFindHighBit(mDimX) + 1;
@@ -80,9 +79,6 @@ void Type::compute()
mLODs = new LOD[mLODCount];
}
- //LOGE("xyz %i %i %i", mDimX, mDimY, mDimZ);
- //LOGE("mips %i", mLODCount);
- //LOGE("e size %i", mElement->getSizeBytes());
uint32_t tx = mDimX;
uint32_t ty = mDimY;
uint32_t tz = mDimZ;
@@ -92,15 +88,12 @@ void Type::compute()
mLODs[lod].mY = ty;
mLODs[lod].mZ = tz;
mLODs[lod].mOffset = offset;
- //LOGE("txyz %i %i %i", tx, ty, tz);
offset += tx * rsMax(ty, 1u) * rsMax(tz, 1u) * mElement->getSizeBytes();
- tx >>= 1;
- ty >>= 1;
- tz >>= 1;
+ tx = (tx + 1) >> 1;
+ ty = (ty + 1) >> 1;
+ tz = (tz + 1) >> 1;
}
- //LOGE("size %i", offset);
-
// At this point the offset is the size of a mipmap chain;
mMipChainSizeBytes = offset;
diff --git a/libs/rs/rsUtils.h b/libs/rs/rsUtils.h
index 5a43fb3..3d3437b 100644
--- a/libs/rs/rsUtils.h
+++ b/libs/rs/rsUtils.h
@@ -17,9 +17,14 @@
#ifndef ANDROID_RS_UTILS_H
#define ANDROID_RS_UTILS_H
-#include <stdint.h>
-#include <sys/types.h>
+#define LOG_NDEBUG 0
+#define LOG_TAG "rs"
+#include <utils/Log.h>
+#include <utils/Vector.h>
#include <stdlib.h>
+#include <pthread.h>
+
+#include "RenderScript.h"
namespace android {
namespace renderscript {
diff --git a/libs/ui/Camera.cpp b/libs/ui/Camera.cpp
index 4228300..33b99b9 100644
--- a/libs/ui/Camera.cpp
+++ b/libs/ui/Camera.cpp
@@ -85,20 +85,6 @@ sp<Camera> Camera::create(const sp<ICamera>& camera)
void Camera::init()
{
mStatus = UNKNOWN_ERROR;
- mShutterCallback = 0;
- mShutterCallbackCookie = 0;
- mRawCallback = 0;
- mRawCallbackCookie = 0;
- mJpegCallback = 0;
- mJpegCallbackCookie = 0;
- mPreviewCallback = 0;
- mPreviewCallbackCookie = 0;
- mRecordingCallback = 0;
- mRecordingCallbackCookie = 0;
- mErrorCallback = 0;
- mErrorCallbackCookie = 0;
- mAutoFocusCallback = 0;
- mAutoFocusCallbackCookie = 0;
}
Camera::~Camera()
@@ -127,7 +113,6 @@ void Camera::disconnect()
{
LOGV("disconnect");
if (mCamera != 0) {
- mErrorCallback = 0;
mCamera->disconnect();
mCamera = 0;
}
@@ -285,125 +270,49 @@ String8 Camera::getParameters() const
return params;
}
-void Camera::setAutoFocusCallback(autofocus_callback cb, void *cookie)
+void Camera::setListener(const sp<CameraListener>& listener)
{
- LOGV("setAutoFocusCallback");
- mAutoFocusCallback = cb;
- mAutoFocusCallbackCookie = cookie;
-}
-
-void Camera::setShutterCallback(shutter_callback cb, void *cookie)
-{
- LOGV("setShutterCallback");
- mShutterCallback = cb;
- mShutterCallbackCookie = cookie;
-}
-
-void Camera::setRawCallback(frame_callback cb, void *cookie)
-{
- LOGV("setRawCallback");
- mRawCallback = cb;
- mRawCallbackCookie = cookie;
-}
-
-void Camera::setJpegCallback(frame_callback cb, void *cookie)
-{
- LOGV("setJpegCallback");
- mJpegCallback = cb;
- mJpegCallbackCookie = cookie;
+ Mutex::Autolock _l(mLock);
+ mListener = listener;
}
-void Camera::setPreviewCallback(frame_callback cb, void *cookie, int flag)
+void Camera::setPreviewCallbackFlags(int flag)
{
- LOGV("setPreviewCallback");
- mPreviewCallback = cb;
- mPreviewCallbackCookie = cookie;
+ LOGV("setPreviewCallbackFlags");
sp <ICamera> c = mCamera;
if (c == 0) return;
mCamera->setPreviewCallbackFlag(flag);
}
-void Camera::setRecordingCallback(frame_callback cb, void *cookie)
-{
- LOGV("setRecordingCallback");
- mRecordingCallback = cb;
- mRecordingCallbackCookie = cookie;
-}
-
-void Camera::setErrorCallback(error_callback cb, void *cookie)
-{
- LOGV("setErrorCallback");
- mErrorCallback = cb;
- mErrorCallbackCookie = cookie;
-}
-
// callback from camera service
void Camera::notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2)
{
- switch(msgType) {
- case CAMERA_MSG_ERROR:
- LOGV("errorCallback");
- if (mErrorCallback) {
- mErrorCallback((status_t)ext1, mErrorCallbackCookie);
- }
- break;
- case CAMERA_MSG_FOCUS:
- LOGV("autoFocusCallback");
- if (mAutoFocusCallback) {
- mAutoFocusCallback((bool)ext1, mAutoFocusCallbackCookie);
- }
- break;
- case CAMERA_MSG_SHUTTER:
- LOGV("shutterCallback");
- if (mShutterCallback) {
- mShutterCallback(mShutterCallbackCookie);
- }
- break;
- default:
- LOGV("notifyCallback(%d, %d, %d)", msgType, ext1, ext2);
- break;
+ sp<CameraListener> listener;
+ {
+ Mutex::Autolock _l(mLock);
+ listener = mListener;
+ }
+ if (listener != NULL) {
+ listener->notify(msgType, ext1, ext2);
}
}
// callback from camera service when frame or image is ready
void Camera::dataCallback(int32_t msgType, const sp<IMemory>& dataPtr)
{
- switch(msgType) {
- case CAMERA_MSG_PREVIEW_FRAME:
- LOGV("previewCallback");
- if (mPreviewCallback) {
- mPreviewCallback(dataPtr, mPreviewCallbackCookie);
- }
- break;
- case CAMERA_MSG_VIDEO_FRAME:
- LOGV("recordingCallback");
- if (mRecordingCallback) {
- mRecordingCallback(dataPtr, mRecordingCallbackCookie);
- }
- break;
- case CAMERA_MSG_RAW_IMAGE:
- LOGV("rawCallback");
- if (mRawCallback) {
- mRawCallback(dataPtr, mRawCallbackCookie);
- }
- break;
- case CAMERA_MSG_COMPRESSED_IMAGE:
- LOGV("jpegCallback");
- if (mJpegCallback) {
- mJpegCallback(dataPtr, mJpegCallbackCookie);
- }
- break;
- default:
- LOGV("dataCallback(%d, %p)", msgType, dataPtr.get());
- break;
+ sp<CameraListener> listener;
+ {
+ Mutex::Autolock _l(mLock);
+ listener = mListener;
+ }
+ if (listener != NULL) {
+ listener->postData(msgType, dataPtr);
}
}
void Camera::binderDied(const wp<IBinder>& who) {
LOGW("ICamera died");
- if (mErrorCallback) {
- mErrorCallback(DEAD_OBJECT, mErrorCallbackCookie);
- }
+ notifyCallback(CAMERA_MSG_ERROR, DEAD_OBJECT, 0);
}
void Camera::DeathNotifier::binderDied(const wp<IBinder>& who) {
diff --git a/libs/utils/BackupData.cpp b/libs/utils/BackupData.cpp
index 6a7f056..0868cff 100644
--- a/libs/utils/BackupData.cpp
+++ b/libs/utils/BackupData.cpp
@@ -99,10 +99,20 @@ BackupDataWriter::WriteEntityHeader(const String8& key, size_t dataSize)
return amt;
}
+ String8 k;
+ if (m_keyPrefix.length() > 0) {
+ k = m_keyPrefix;
+ k += ":";
+ k += key;
+ } else {
+ k = key;
+ }
+ LOGD("m_keyPrefix=%s key=%s k=%s", m_keyPrefix.string(), key.string(), k.string());
+
entity_header_v1 header;
ssize_t keyLen;
- keyLen = key.length();
+ keyLen = k.length();
header.type = tolel(BACKUP_HEADER_ENTITY_V1);
header.keyLen = tolel(keyLen);
@@ -115,7 +125,7 @@ BackupDataWriter::WriteEntityHeader(const String8& key, size_t dataSize)
}
m_pos += amt;
- amt = write(m_fd, key.string(), keyLen+1);
+ amt = write(m_fd, k.string(), keyLen+1);
if (amt != keyLen+1) {
m_status = errno;
return m_status;
@@ -148,6 +158,11 @@ BackupDataWriter::WriteEntityData(const void* data, size_t size)
return NO_ERROR;
}
+void
+BackupDataWriter::SetKeyPrefix(const String8& keyPrefix)
+{
+ m_keyPrefix = keyPrefix;
+}
BackupDataReader::BackupDataReader(int fd)
@@ -298,7 +313,7 @@ BackupDataReader::ReadEntityData(void* data, size_t size)
if (remaining <= 0) {
return 0;
}
- if (size > remaining) {
+ if (((int)size) > remaining) {
size = remaining;
}
//LOGD(" reading %d bytes", size);
diff --git a/libs/utils/BackupHelpers.cpp b/libs/utils/BackupHelpers.cpp
index d65a457..99a4abc 100644
--- a/libs/utils/BackupHelpers.cpp
+++ b/libs/utils/BackupHelpers.cpp
@@ -41,6 +41,33 @@ namespace android {
#define MAGIC0 0x70616e53 // Snap
#define MAGIC1 0x656c6946 // File
+/*
+ * File entity data format (v1):
+ *
+ * - 4-byte version number of the metadata, little endian (0x00000001 for v1)
+ * - 12 bytes of metadata
+ * - the file data itself
+ *
+ * i.e. a 16-byte metadata header followed by the raw file data. If the
+ * restore code does not recognize the metadata version, it can still
+ * interpret the file data itself correctly.
+ *
+ * file_metadata_v1:
+ *
+ * - 4 byte version number === 0x00000001 (little endian)
+ * - 4-byte access mode (little-endian)
+ * - undefined (8 bytes)
+ */
+
+struct file_metadata_v1 {
+ int version;
+ int mode;
+ int undefined_1;
+ int undefined_2;
+};
+
+const static int CURRENT_METADATA_VERSION = 1;
+
#if 1 // TEST_BACKUP_HELPERS
#define LOGP(f, x...) printf(f "\n", x)
#else
@@ -181,29 +208,48 @@ write_delete_file(BackupDataWriter* dataStream, const String8& key)
}
static int
-write_update_file(BackupDataWriter* dataStream, int fd, const String8& key,
+write_update_file(BackupDataWriter* dataStream, int fd, int mode, const String8& key,
char const* realFilename)
{
- LOGP("write_update_file %s (%s)\n", realFilename, key.string());
+ LOGP("write_update_file %s (%s) : mode 0%o\n", realFilename, key.string(), mode);
const int bufsize = 4*1024;
int err;
int amt;
int fileSize;
int bytesLeft;
+ file_metadata_v1 metadata;
char* buf = (char*)malloc(bufsize);
int crc = crc32(0L, Z_NULL, 0);
- bytesLeft = fileSize = lseek(fd, 0, SEEK_END);
+ fileSize = lseek(fd, 0, SEEK_END);
lseek(fd, 0, SEEK_SET);
+ if (sizeof(metadata) != 16) {
+ LOGE("ERROR: metadata block is the wrong size!");
+ }
+
+ bytesLeft = fileSize + sizeof(metadata);
err = dataStream->WriteEntityHeader(key, bytesLeft);
if (err != 0) {
+ free(buf);
+ return err;
+ }
+
+ // store the file metadata first
+ metadata.version = tolel(CURRENT_METADATA_VERSION);
+ metadata.mode = tolel(mode);
+ metadata.undefined_1 = metadata.undefined_2 = 0;
+ err = dataStream->WriteEntityData(&metadata, sizeof(metadata));
+ if (err != 0) {
+ free(buf);
return err;
}
+ bytesLeft -= sizeof(metadata); // bytesLeft should == fileSize now
+ // now store the file content
while ((amt = read(fd, buf, bufsize)) != 0 && bytesLeft > 0) {
bytesLeft -= amt;
if (bytesLeft < 0) {
@@ -211,6 +257,7 @@ write_update_file(BackupDataWriter* dataStream, int fd, const String8& key,
}
err = dataStream->WriteEntityData(buf, amt);
if (err != 0) {
+ free(buf);
return err;
}
}
@@ -224,6 +271,7 @@ write_update_file(BackupDataWriter* dataStream, int fd, const String8& key,
bytesLeft -= amt;
err = dataStream->WriteEntityData(buf, amt);
if (err != 0) {
+ free(buf);
return err;
}
}
@@ -233,7 +281,6 @@ write_update_file(BackupDataWriter* dataStream, int fd, const String8& key,
}
free(buf);
-
return NO_ERROR;
}
@@ -241,11 +288,19 @@ static int
write_update_file(BackupDataWriter* dataStream, const String8& key, char const* realFilename)
{
int err;
+ struct stat st;
+
+ err = stat(realFilename, &st);
+ if (err < 0) {
+ return errno;
+ }
+
int fd = open(realFilename, O_RDONLY);
if (fd == -1) {
return errno;
}
- err = write_update_file(dataStream, fd, key, realFilename);
+
+ err = write_update_file(dataStream, fd, st.st_mode, key, realFilename);
close(fd);
return err;
}
@@ -266,7 +321,6 @@ compute_crc32(int fd)
}
free(buf);
-
return crc;
}
@@ -302,6 +356,7 @@ back_up_files(int oldSnapshotFD, BackupDataWriter* dataStream, int newSnapshotFD
r.s.modTime_sec = st.st_mtime;
r.s.modTime_nsec = 0; // workaround sim breakage
//r.s.modTime_nsec = st.st_mtime_nsec;
+ r.s.mode = st.st_mode;
r.s.size = st.st_size;
// we compute the crc32 later down below, when we already have the file open.
@@ -349,13 +404,13 @@ back_up_files(int oldSnapshotFD, BackupDataWriter* dataStream, int newSnapshotFD
g.s.crc32 = compute_crc32(fd);
LOGP("%s", q.string());
- LOGP(" new: modTime=%d,%d size=%-3d crc32=0x%08x",
- f.modTime_sec, f.modTime_nsec, f.size, f.crc32);
- LOGP(" old: modTime=%d,%d size=%-3d crc32=0x%08x",
- g.s.modTime_sec, g.s.modTime_nsec, g.s.size, g.s.crc32);
+ LOGP(" new: modTime=%d,%d mode=%04o size=%-3d crc32=0x%08x",
+ f.modTime_sec, f.modTime_nsec, f.mode, f.size, f.crc32);
+ LOGP(" old: modTime=%d,%d mode=%04o size=%-3d crc32=0x%08x",
+ g.s.modTime_sec, g.s.modTime_nsec, g.s.mode, g.s.size, g.s.crc32);
if (f.modTime_sec != g.s.modTime_sec || f.modTime_nsec != g.s.modTime_nsec
- || f.size != g.s.size || f.crc32 != g.s.crc32) {
- write_update_file(dataStream, fd, p, g.file.string());
+ || f.mode != g.s.mode || f.size != g.s.size || f.crc32 != g.s.crc32) {
+ write_update_file(dataStream, fd, g.s.mode, p, g.file.string());
}
close(fd);
@@ -389,6 +444,7 @@ back_up_files(int oldSnapshotFD, BackupDataWriter* dataStream, int newSnapshotFD
RestoreHelperBase::RestoreHelperBase()
{
m_buf = malloc(RESTORE_BUF_SIZE);
+ m_loggedUnknownMetadata = false;
}
RestoreHelperBase::~RestoreHelperBase()
@@ -415,8 +471,25 @@ RestoreHelperBase::WriteFile(const String8& filename, BackupDataReader* in)
return err;
}
- // TODO: World readable/writable for now.
- mode = 0666;
+ // Get the metadata block off the head of the file entity and use that to
+ // set up the output file
+ file_metadata_v1 metadata;
+ amt = in->ReadEntityData(&metadata, sizeof(metadata));
+ if (amt != sizeof(metadata)) {
+ LOGW("Could not read metadata for %s -- %ld / %s", filename.string(),
+ (long)amt, strerror(errno));
+ return EIO;
+ }
+ metadata.version = fromlel(metadata.version);
+ metadata.mode = fromlel(metadata.mode);
+ if (metadata.version > CURRENT_METADATA_VERSION) {
+ if (!m_loggedUnknownMetadata) {
+ m_loggedUnknownMetadata = true;
+ LOGW("Restoring file with unsupported metadata version %d (currently %d)",
+ metadata.version, CURRENT_METADATA_VERSION);
+ }
+ }
+ mode = metadata.mode;
// Write the file and compute the crc
crc = crc32(0L, Z_NULL, 0);
@@ -450,6 +523,7 @@ RestoreHelperBase::WriteFile(const String8& filename, BackupDataReader* in)
r.s.modTime_sec = st.st_mtime;
r.s.modTime_nsec = 0; // workaround sim breakage
//r.s.modTime_nsec = st.st_mtime_nsec;
+ r.s.mode = st.st_mode;
r.s.size = st.st_size;
r.s.crc32 = crc;
@@ -536,6 +610,7 @@ compare_file(const char* path, const unsigned char* data, int len)
}
}
+ free(contents);
return contentsMatch && sizesMatch ? 0 : 1;
}
@@ -623,6 +698,7 @@ backup_helper_test_four()
states[0].modTime_sec = 0xfedcba98;
states[0].modTime_nsec = 0xdeadbeef;
+ states[0].mode = 0777; // decimal 511, hex 0x000001ff
states[0].size = 0xababbcbc;
states[0].crc32 = 0x12345678;
states[0].nameLen = -12;
@@ -632,6 +708,7 @@ backup_helper_test_four()
states[1].modTime_sec = 0x93400031;
states[1].modTime_nsec = 0xdeadbeef;
+ states[1].mode = 0666; // decimal 438, hex 0x000001b6
states[1].size = 0x88557766;
states[1].crc32 = 0x22334422;
states[1].nameLen = -1;
@@ -641,6 +718,7 @@ backup_helper_test_four()
states[2].modTime_sec = 0x33221144;
states[2].modTime_nsec = 0xdeadbeef;
+ states[2].mode = 0744; // decimal 484, hex 0x000001e4
states[2].size = 0x11223344;
states[2].crc32 = 0x01122334;
states[2].nameLen = 0;
@@ -650,6 +728,7 @@ backup_helper_test_four()
states[3].modTime_sec = 0x33221144;
states[3].modTime_nsec = 0xdeadbeef;
+ states[3].mode = 0755; // decimal 493, hex 0x000001ed
states[3].size = 0x11223344;
states[3].crc32 = 0x01122334;
states[3].nameLen = 0;
@@ -669,35 +748,38 @@ backup_helper_test_four()
static const unsigned char correct_data[] = {
// header
0x53, 0x6e, 0x61, 0x70, 0x04, 0x00, 0x00, 0x00,
- 0x46, 0x69, 0x6c, 0x65, 0xac, 0x00, 0x00, 0x00,
+ 0x46, 0x69, 0x6c, 0x65, 0xbc, 0x00, 0x00, 0x00,
// bytes_of_padding
0x98, 0xba, 0xdc, 0xfe, 0xef, 0xbe, 0xad, 0xde,
- 0xbc, 0xbc, 0xab, 0xab, 0x78, 0x56, 0x34, 0x12,
- 0x10, 0x00, 0x00, 0x00, 0x62, 0x79, 0x74, 0x65,
- 0x73, 0x5f, 0x6f, 0x66, 0x5f, 0x70, 0x61, 0x64,
- 0x64, 0x69, 0x6e, 0x67,
+ 0xff, 0x01, 0x00, 0x00, 0xbc, 0xbc, 0xab, 0xab,
+ 0x78, 0x56, 0x34, 0x12, 0x10, 0x00, 0x00, 0x00,
+ 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x6f, 0x66,
+ 0x5f, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67,
// bytes_of_padding3
0x31, 0x00, 0x40, 0x93, 0xef, 0xbe, 0xad, 0xde,
- 0x66, 0x77, 0x55, 0x88, 0x22, 0x44, 0x33, 0x22,
- 0x11, 0x00, 0x00, 0x00, 0x62, 0x79, 0x74, 0x65,
- 0x73, 0x5f, 0x6f, 0x66, 0x5f, 0x70, 0x61, 0x64,
- 0x64, 0x69, 0x6e, 0x67, 0x33, 0xab, 0xab, 0xab,
+ 0xb6, 0x01, 0x00, 0x00, 0x66, 0x77, 0x55, 0x88,
+ 0x22, 0x44, 0x33, 0x22, 0x11, 0x00, 0x00, 0x00,
+ 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x6f, 0x66,
+ 0x5f, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67,
+ 0x33, 0xab, 0xab, 0xab,
// bytes of padding2
0x44, 0x11, 0x22, 0x33, 0xef, 0xbe, 0xad, 0xde,
- 0x44, 0x33, 0x22, 0x11, 0x34, 0x23, 0x12, 0x01,
- 0x12, 0x00, 0x00, 0x00, 0x62, 0x79, 0x74, 0x65,
- 0x73, 0x5f, 0x6f, 0x66, 0x5f, 0x70, 0x61, 0x64,
- 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x32, 0xab, 0xab,
+ 0xe4, 0x01, 0x00, 0x00, 0x44, 0x33, 0x22, 0x11,
+ 0x34, 0x23, 0x12, 0x01, 0x12, 0x00, 0x00, 0x00,
+ 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x6f, 0x66,
+ 0x5f, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67,
+ 0x5f, 0x32, 0xab, 0xab,
// bytes of padding3
0x44, 0x11, 0x22, 0x33, 0xef, 0xbe, 0xad, 0xde,
- 0x44, 0x33, 0x22, 0x11, 0x34, 0x23, 0x12, 0x01,
- 0x13, 0x00, 0x00, 0x00, 0x62, 0x79, 0x74, 0x65,
- 0x73, 0x5f, 0x6f, 0x66, 0x5f, 0x70, 0x61, 0x64,
- 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x5f, 0x31, 0xab
+ 0xed, 0x01, 0x00, 0x00, 0x44, 0x33, 0x22, 0x11,
+ 0x34, 0x23, 0x12, 0x01, 0x13, 0x00, 0x00, 0x00,
+ 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x6f, 0x66,
+ 0x5f, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67,
+ 0x5f, 0x5f, 0x31, 0xab
};
err = compare_file(filename, correct_data, sizeof(correct_data));
@@ -731,14 +813,14 @@ backup_helper_test_four()
const FileState state = readSnapshot.valueAt(i);
if (name != filenames[i] || states[i].modTime_sec != state.modTime_sec
- || states[i].modTime_nsec != state.modTime_nsec
+ || states[i].modTime_nsec != state.modTime_nsec || states[i].mode != state.mode
|| states[i].size != state.size || states[i].crc32 != states[i].crc32) {
- fprintf(stderr, "state %d expected={%d/%d, 0x%08x, 0x%08x, %3d} '%s'\n"
- " actual={%d/%d, 0x%08x, 0x%08x, %3d} '%s'\n", i,
- states[i].modTime_sec, states[i].modTime_nsec, states[i].size, states[i].crc32,
- name.length(), filenames[i].string(),
- state.modTime_sec, state.modTime_nsec, state.size, state.crc32, state.nameLen,
- name.string());
+ fprintf(stderr, "state %d expected={%d/%d, 0x%08x, %04o, 0x%08x, %3d} '%s'\n"
+ " actual={%d/%d, 0x%08x, %04o, 0x%08x, %3d} '%s'\n", i,
+ states[i].modTime_sec, states[i].modTime_nsec, states[i].mode, states[i].size,
+ states[i].crc32, name.length(), filenames[i].string(),
+ state.modTime_sec, state.modTime_nsec, state.mode, state.size, state.crc32,
+ state.nameLen, name.string());
matched = false;
}
}
@@ -839,6 +921,7 @@ test_read_header_and_entity(BackupDataReader& reader, const char* str)
size_t actualSize;
bool done;
int type;
+ ssize_t nRead;
// printf("\n\n---------- test_read_header_and_entity -- %s\n\n", str);
@@ -873,8 +956,9 @@ test_read_header_and_entity(BackupDataReader& reader, const char* str)
goto finished;
}
- err = reader.ReadEntityData(buf, bufSize);
- if (err != NO_ERROR) {
+ nRead = reader.ReadEntityData(buf, bufSize);
+ if (nRead < 0) {
+ err = reader.Status();
fprintf(stderr, "ReadEntityData failed with %s\n", strerror(err));
goto finished;
}
diff --git a/libs/utils/ResourceTypes.cpp b/libs/utils/ResourceTypes.cpp
index 69d47f0..e4f9f0f 100644
--- a/libs/utils/ResourceTypes.cpp
+++ b/libs/utils/ResourceTypes.cpp
@@ -544,7 +544,7 @@ ResXMLParser::event_code_t ResXMLParser::next()
return mEventCode;
}
-const int32_t ResXMLParser::getCommentID() const
+int32_t ResXMLParser::getCommentID() const
{
return mCurNode != NULL ? dtohl(mCurNode->comment.index) : -1;
}
@@ -555,12 +555,12 @@ const uint16_t* ResXMLParser::getComment(size_t* outLen) const
return id >= 0 ? mTree.mStrings.stringAt(id, outLen) : NULL;
}
-const uint32_t ResXMLParser::getLineNumber() const
+uint32_t ResXMLParser::getLineNumber() const
{
return mCurNode != NULL ? dtohl(mCurNode->lineNumber) : -1;
}
-const int32_t ResXMLParser::getTextID() const
+int32_t ResXMLParser::getTextID() const
{
if (mEventCode == TEXT) {
return dtohl(((const ResXMLTree_cdataExt*)mCurExt)->data.index);
@@ -583,7 +583,7 @@ ssize_t ResXMLParser::getTextValue(Res_value* outValue) const
return BAD_TYPE;
}
-const int32_t ResXMLParser::getNamespacePrefixID() const
+int32_t ResXMLParser::getNamespacePrefixID() const
{
if (mEventCode == START_NAMESPACE || mEventCode == END_NAMESPACE) {
return dtohl(((const ResXMLTree_namespaceExt*)mCurExt)->prefix.index);
@@ -598,7 +598,7 @@ const uint16_t* ResXMLParser::getNamespacePrefix(size_t* outLen) const
return id >= 0 ? mTree.mStrings.stringAt(id, outLen) : NULL;
}
-const int32_t ResXMLParser::getNamespaceUriID() const
+int32_t ResXMLParser::getNamespaceUriID() const
{
if (mEventCode == START_NAMESPACE || mEventCode == END_NAMESPACE) {
return dtohl(((const ResXMLTree_namespaceExt*)mCurExt)->uri.index);
@@ -613,7 +613,7 @@ const uint16_t* ResXMLParser::getNamespaceUri(size_t* outLen) const
return id >= 0 ? mTree.mStrings.stringAt(id, outLen) : NULL;
}
-const int32_t ResXMLParser::getElementNamespaceID() const
+int32_t ResXMLParser::getElementNamespaceID() const
{
if (mEventCode == START_TAG) {
return dtohl(((const ResXMLTree_attrExt*)mCurExt)->ns.index);
@@ -630,7 +630,7 @@ const uint16_t* ResXMLParser::getElementNamespace(size_t* outLen) const
return id >= 0 ? mTree.mStrings.stringAt(id, outLen) : NULL;
}
-const int32_t ResXMLParser::getElementNameID() const
+int32_t ResXMLParser::getElementNameID() const
{
if (mEventCode == START_TAG) {
return dtohl(((const ResXMLTree_attrExt*)mCurExt)->name.index);
@@ -655,7 +655,7 @@ size_t ResXMLParser::getAttributeCount() const
return 0;
}
-const int32_t ResXMLParser::getAttributeNamespaceID(size_t idx) const
+int32_t ResXMLParser::getAttributeNamespaceID(size_t idx) const
{
if (mEventCode == START_TAG) {
const ResXMLTree_attrExt* tag = (const ResXMLTree_attrExt*)mCurExt;
@@ -678,7 +678,7 @@ const uint16_t* ResXMLParser::getAttributeNamespace(size_t idx, size_t* outLen)
return id >= 0 ? mTree.mStrings.stringAt(id, outLen) : NULL;
}
-const int32_t ResXMLParser::getAttributeNameID(size_t idx) const
+int32_t ResXMLParser::getAttributeNameID(size_t idx) const
{
if (mEventCode == START_TAG) {
const ResXMLTree_attrExt* tag = (const ResXMLTree_attrExt*)mCurExt;
@@ -701,7 +701,7 @@ const uint16_t* ResXMLParser::getAttributeName(size_t idx, size_t* outLen) const
return id >= 0 ? mTree.mStrings.stringAt(id, outLen) : NULL;
}
-const uint32_t ResXMLParser::getAttributeNameResID(size_t idx) const
+uint32_t ResXMLParser::getAttributeNameResID(size_t idx) const
{
int32_t id = getAttributeNameID(idx);
if (id >= 0 && (size_t)id < mTree.mNumResIds) {
@@ -710,7 +710,7 @@ const uint32_t ResXMLParser::getAttributeNameResID(size_t idx) const
return 0;
}
-const int32_t ResXMLParser::getAttributeValueStringID(size_t idx) const
+int32_t ResXMLParser::getAttributeValueStringID(size_t idx) const
{
if (mEventCode == START_TAG) {
const ResXMLTree_attrExt* tag = (const ResXMLTree_attrExt*)mCurExt;