Code cleanup to make formatting consistent
across all the renderscript files.
Change-Id: Idf5fcc60877e44c8f074f7176e37f70b3b895a3c
diff --git a/java/Fountain/src/com/android/fountain/FountainRS.java b/java/Fountain/src/com/android/fountain/FountainRS.java
index 0afff34..53fb646 100644
--- a/java/Fountain/src/com/android/fountain/FountainRS.java
+++ b/java/Fountain/src/com/android/fountain/FountainRS.java
@@ -57,7 +57,7 @@
return;
}
int rate = (int)(pressure * pressure * 500.f);
- if(rate > 500) {
+ if (rate > 500) {
rate = 500;
}
if (rate > 0) {
diff --git a/java/Fountain/src/com/android/fountain/FountainView.java b/java/Fountain/src/com/android/fountain/FountainView.java
index 987bebe..50a9707 100644
--- a/java/Fountain/src/com/android/fountain/FountainView.java
+++ b/java/Fountain/src/com/android/fountain/FountainView.java
@@ -62,7 +62,7 @@
@Override
protected void onDetachedFromWindow() {
- if(mRS != null) {
+ if (mRS != null) {
mRS = null;
destroyRenderScript();
}
diff --git a/java/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java b/java/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
index 16f404f..c617759 100644
--- a/java/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
+++ b/java/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
@@ -141,7 +141,7 @@
float coeff2 = - 1.0f / (2.0f * sigma * sigma);
float normalizeFactor = 0.0f;
float floatR = 0.0f;
- for(r = -radius; r <= radius; r ++) {
+ for (r = -radius; r <= radius; r ++) {
floatR = (float)r;
gaussian[r + radius] = coeff1 * (float)Math.pow(e, floatR * floatR * coeff2);
normalizeFactor += gaussian[r + radius];
@@ -149,7 +149,7 @@
//Now we need to normalize the weights because all our coefficients need to add up to one
normalizeFactor = 1.0f / normalizeFactor;
- for(r = -radius; r <= radius; r ++) {
+ for (r = -radius; r <= radius; r ++) {
floatR = (float)r;
gaussian[r + radius] *= normalizeFactor;
}
@@ -159,22 +159,22 @@
float blurredPixelB = 0.0f;
float blurredPixelA = 0.0f;
- for(h = 0; h < height; h ++) {
- for(w = 0; w < width; w ++) {
+ for (h = 0; h < height; h ++) {
+ for (w = 0; w < width; w ++) {
blurredPixelR = 0.0f;
blurredPixelG = 0.0f;
blurredPixelB = 0.0f;
blurredPixelA = 0.0f;
- for(r = -radius; r <= radius; r ++) {
+ for (r = -radius; r <= radius; r ++) {
// Stepping left and right away from the pixel
int validW = w + r;
// Clamp to zero and width max() isn't exposed for ints yet
- if(validW < 0) {
+ if (validW < 0) {
validW = 0;
}
- if(validW > width - 1) {
+ if (validW > width - 1) {
validW = width - 1;
}
@@ -202,20 +202,20 @@
}
}
- for(h = 0; h < height; h ++) {
- for(w = 0; w < width; w ++) {
+ for (h = 0; h < height; h ++) {
+ for (w = 0; w < width; w ++) {
blurredPixelR = 0.0f;
blurredPixelG = 0.0f;
blurredPixelB = 0.0f;
blurredPixelA = 0.0f;
- for(r = -radius; r <= radius; r ++) {
+ for (r = -radius; r <= radius; r ++) {
int validH = h + r;
// Clamp to zero and width
- if(validH < 0) {
+ if (validH < 0) {
validH = 0;
}
- if(validH > height - 1) {
+ if (validH > height - 1) {
validH = height - 1;
}
@@ -252,36 +252,30 @@
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (fromUser) {
- if(seekBar == mRadiusSeekBar) {
+ if (seekBar == mRadiusSeekBar) {
float fRadius = progress / 100.0f;
fRadius *= (float)(MAX_RADIUS);
mRadius = (int)fRadius;
mScript.set_radius(mRadius);
- }
- else if(seekBar == mInBlackSeekBar) {
+ } else if (seekBar == mInBlackSeekBar) {
mInBlack = (float)progress;
mScriptVBlur.invoke_setLevels(mInBlack, mOutBlack, mInWhite, mOutWhite);
- }
- else if(seekBar == mOutBlackSeekBar) {
+ } else if (seekBar == mOutBlackSeekBar) {
mOutBlack = (float)progress;
mScriptVBlur.invoke_setLevels(mInBlack, mOutBlack, mInWhite, mOutWhite);
- }
- else if(seekBar == mInWhiteSeekBar) {
+ } else if (seekBar == mInWhiteSeekBar) {
mInWhite = (float)progress + 127.0f;
mScriptVBlur.invoke_setLevels(mInBlack, mOutBlack, mInWhite, mOutWhite);
- }
- else if(seekBar == mOutWhiteSeekBar) {
+ } else if (seekBar == mOutWhiteSeekBar) {
mOutWhite = (float)progress + 127.0f;
mScriptVBlur.invoke_setLevels(mInBlack, mOutBlack, mInWhite, mOutWhite);
- }
- else if(seekBar == mGammaSeekBar) {
+ } else if (seekBar == mGammaSeekBar) {
mGamma = (float)progress/100.0f;
mGamma = Math.max(mGamma, 0.1f);
mGamma = 1.0f / mGamma;
mScriptVBlur.invoke_setGamma(mGamma);
- }
- else if(seekBar == mSaturationSeekBar) {
+ } else if (seekBar == mSaturationSeekBar) {
mSaturation = (float)progress / 50.0f;
mScriptVBlur.invoke_setSaturation(mSaturation);
}
diff --git a/java/ImageProcessing/src/com/android/rs/image/horizontal_blur.rs b/java/ImageProcessing/src/com/android/rs/image/horizontal_blur.rs
index cfffac8..652ffd7 100644
--- a/java/ImageProcessing/src/com/android/rs/image/horizontal_blur.rs
+++ b/java/ImageProcessing/src/com/android/rs/image/horizontal_blur.rs
@@ -11,13 +11,13 @@
const float *gPtr = fs->gaussian;
if ((x > fs->radius) && (x < (fs->width - fs->radius))) {
const float4 *i = input + (x - fs->radius);
- for(int r = -fs->radius; r <= fs->radius; r ++) {
+ for (int r = -fs->radius; r <= fs->radius; r ++) {
blurredPixel += i->xyz * gPtr[0];
gPtr++;
i++;
}
} else {
- for(int r = -fs->radius; r <= fs->radius; r ++) {
+ for (int r = -fs->radius; r <= fs->radius; r ++) {
// Stepping left and right away from the pixel
int validW = rsClamp(x + r, (uint)0, (uint)(fs->width - 1));
blurredPixel += input[validW].xyz * gPtr[0];
diff --git a/java/ImageProcessing/src/com/android/rs/image/threshold.rs b/java/ImageProcessing/src/com/android/rs/image/threshold.rs
index d05ed6f..698540b 100644
--- a/java/ImageProcessing/src/com/android/rs/image/threshold.rs
+++ b/java/ImageProcessing/src/com/android/rs/image/threshold.rs
@@ -48,7 +48,7 @@
float normalizeFactor = 0.0f;
float floatR = 0.0f;
int r;
- for(r = -radius; r <= radius; r ++) {
+ for (r = -radius; r <= radius; r ++) {
floatR = (float)r;
gaussian[r + radius] = coeff1 * pow(e, floatR * floatR * coeff2);
normalizeFactor += gaussian[r + radius];
@@ -56,7 +56,7 @@
//Now we need to normalize the weights because all our coefficients need to add up to one
normalizeFactor = 1.0f / normalizeFactor;
- for(r = -radius; r <= radius; r ++) {
+ for (r = -radius; r <= radius; r ++) {
floatR = (float)r;
gaussian[r + radius] *= normalizeFactor;
}
@@ -68,8 +68,8 @@
rsSetObject(&ain,rsGetAllocation(InPixel));
uint32_t dimx = rsAllocationGetDimX(ain);
uint32_t dimy = rsAllocationGetDimY(ain);
- for(uint32_t y = 0; y < dimy; y++) {
- for(uint32_t x = 0; x < dimx; x++) {
+ for (uint32_t y = 0; y < dimy; y++) {
+ for (uint32_t x = 0; x < dimx; x++) {
ScratchPixel1[x + y * dimx] = convert_float4(InPixel[x + y * dimx]);
}
}
diff --git a/java/ImageProcessing/src/com/android/rs/image/vertical_blur.rs b/java/ImageProcessing/src/com/android/rs/image/vertical_blur.rs
index d901d2a..fe43354 100644
--- a/java/ImageProcessing/src/com/android/rs/image/vertical_blur.rs
+++ b/java/ImageProcessing/src/com/android/rs/image/vertical_blur.rs
@@ -66,13 +66,13 @@
const float *gPtr = fs->gaussian;
if ((y > fs->radius) && (y < (fs->height - fs->radius))) {
const float4 *i = input + ((y - fs->radius) * fs->width);
- for(int r = -fs->radius; r <= fs->radius; r ++) {
+ for (int r = -fs->radius; r <= fs->radius; r ++) {
blurredPixel += i->xyz * gPtr[0];
gPtr++;
i += fs->width;
}
} else {
- for(int r = -fs->radius; r <= fs->radius; r ++) {
+ for (int r = -fs->radius; r <= fs->radius; r ++) {
int validH = rsClamp(y + r, (uint)0, (uint)(fs->height - 1));
const float4 *i = input + validH * fs->width;
blurredPixel += i->xyz * gPtr[0];
diff --git a/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java b/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java
index 1531d09..954ec96 100644
--- a/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java
+++ b/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java
@@ -71,15 +71,15 @@
public void touchEvent(int x, int y) {
int dx = mLastX - x;
- if(Math.abs(dx) > 50 || Math.abs(dx) < 3) {
+ if (Math.abs(dx) > 50 || Math.abs(dx) < 3) {
dx = 0;
}
mRotation -= dx;
- if(mRotation > 360) {
+ if (mRotation > 360) {
mRotation -= 360;
}
- if(mRotation < 0) {
+ if (mRotation < 0) {
mRotation += 360;
}
@@ -186,10 +186,9 @@
FileA3D model = FileA3D.createFromResource(mRS, mRes, R.raw.robot);
FileA3D.IndexEntry entry = model.getIndexEntry(0);
- if(entry == null || entry.getClassID() != FileA3D.ClassID.MESH) {
+ if (entry == null || entry.getClassID() != FileA3D.ClassID.MESH) {
Log.e("rs", "could not load model");
- }
- else {
+ } else {
mMesh = (Mesh)entry.getObject();
mScript.set_gTestMesh(mMesh);
}
diff --git a/java/ModelViewer/src/com/android/modelviewer/SceneGraphView.java b/java/ModelViewer/src/com/android/modelviewer/SceneGraphView.java
index 9457fd7..1cabba1 100644
--- a/java/ModelViewer/src/com/android/modelviewer/SceneGraphView.java
+++ b/java/ModelViewer/src/com/android/modelviewer/SceneGraphView.java
@@ -64,7 +64,7 @@
@Override
protected void onDetachedFromWindow() {
- if(mRS != null) {
+ if (mRS != null) {
mRS = null;
destroyRenderScript();
}
diff --git a/java/ModelViewer/src/com/android/modelviewer/SgTransform.java b/java/ModelViewer/src/com/android/modelviewer/SgTransform.java
index 8351f42..f5484e2 100644
--- a/java/ModelViewer/src/com/android/modelviewer/SgTransform.java
+++ b/java/ModelViewer/src/com/android/modelviewer/SgTransform.java
@@ -70,7 +70,7 @@
void initData() {
int numElements = mTransformData.transforms.length;
mTransformData.transformTypes = new int[numElements];
- for(int i = 0; i < numElements; i ++) {
+ for (int i = 0; i < numElements; i ++) {
mTransformData.transforms[i] = new Float4(0, 0, 0, 0);
mTransformData.transformTypes[i] = TransformType.NONE.mID;
}
@@ -87,11 +87,11 @@
}
public ScriptField_SgTransform.Item getData() {
- if(mChildren.size() != 0) {
+ if (mChildren.size() != 0) {
mChildField = new ScriptField_SgTransform(mRS, mChildren.size());
mTransformData.children = mChildField.getAllocation();
- for(int i = 0; i < mChildren.size(); i ++) {
+ for (int i = 0; i < mChildren.size(); i ++) {
SgTransform child = (SgTransform)mChildren.get(i);
mChildField.set(child.getData(), i, false);
}
diff --git a/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java b/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java
index edf40e9..29c3728 100644
--- a/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java
+++ b/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java
@@ -67,15 +67,15 @@
public void touchEvent(int x, int y) {
int dx = mLastX - x;
- if(Math.abs(dx) > 50 || Math.abs(dx) < 3) {
+ if (Math.abs(dx) > 50 || Math.abs(dx) < 3) {
dx = 0;
}
mRotation -= dx;
- if(mRotation > 360) {
+ if (mRotation > 360) {
mRotation -= 360;
}
- if(mRotation < 0) {
+ if (mRotation < 0) {
mRotation += 360;
}
@@ -148,10 +148,9 @@
FileA3D model = FileA3D.createFromResource(mRS, mRes, R.raw.robot);
FileA3D.IndexEntry entry = model.getIndexEntry(0);
- if(entry == null || entry.getClassID() != FileA3D.ClassID.MESH) {
+ if (entry == null || entry.getClassID() != FileA3D.ClassID.MESH) {
Log.e("rs", "could not load model");
- }
- else {
+ } else {
mMesh = (Mesh)entry.getObject();
mScript.set_gTestMesh(mMesh);
}
diff --git a/java/ModelViewer/src/com/android/modelviewer/SimpleModelView.java b/java/ModelViewer/src/com/android/modelviewer/SimpleModelView.java
index 4253085..875c4bd 100644
--- a/java/ModelViewer/src/com/android/modelviewer/SimpleModelView.java
+++ b/java/ModelViewer/src/com/android/modelviewer/SimpleModelView.java
@@ -64,7 +64,7 @@
@Override
protected void onDetachedFromWindow() {
- if(mRS != null) {
+ if (mRS != null) {
mRS = null;
destroyRenderScript();
}
diff --git a/java/ModelViewer/src/com/android/modelviewer/transform.rs b/java/ModelViewer/src/com/android/modelviewer/transform.rs
index e7c04de..3c235d7 100644
--- a/java/ModelViewer/src/com/android/modelviewer/transform.rs
+++ b/java/ModelViewer/src/com/android/modelviewer/transform.rs
@@ -28,7 +28,7 @@
void appendTransformation(int type, float4 data, rs_matrix4x4 *mat) {
rs_matrix4x4 temp;
- switch(type) {
+ switch (type) {
case TRANSFORM_TRANSLATE:
rsMatrixLoadTranslate(&temp, data.x, data.y, data.z);
break;
@@ -60,15 +60,15 @@
//rsDebug("Transform is dirty", data->isDirty);
// Refresh matrices if dirty
- if(data->isDirty) {
+ if (data->isDirty) {
data->isDirty = 0;
toChild.changed = 1;
// Reset our local matrix
rsMatrixLoadIdentity(localMat);
- for(int i = 0; i < 16; i ++) {
- if(data->transformTypes[i] == TRANSFORM_NONE) {
+ for (int i = 0; i < 16; i ++) {
+ if (data->transformTypes[i] == TRANSFORM_NONE) {
break;
}
//rsDebug("Transform adding transformation", transformTypes[i]);
@@ -78,20 +78,19 @@
//rsDebug("Transform checking parent", (int)0);
- if(parent) {
- if(parent->changed) {
+ if (parent) {
+ if (parent->changed) {
toChild.changed = 1;
rsMatrixLoad(globalMat, parent->mat);
rsMatrixMultiply(globalMat, localMat);
}
- }
- else {
+ } else {
rsMatrixLoad(globalMat, localMat);
}
//rsDebug("Transform calling self with child ", (int)data->children.p);
- if(data->children.p) {
+ if (data->children.p) {
rsForEach(transformScript, data->children, data->children, (void*)&toChild);
}
}
diff --git a/java/Samples/src/com/android/samples/RsListRS.java b/java/Samples/src/com/android/samples/RsListRS.java
index ce9ab01..3aa20e8 100644
--- a/java/Samples/src/com/android/samples/RsListRS.java
+++ b/java/Samples/src/com/android/samples/RsListRS.java
@@ -109,7 +109,7 @@
int dx = mLastX - x;
int dy = mLastY - y;
- if(Math.abs(dy) <= 2) {
+ if (Math.abs(dy) <= 2) {
dy = 0;
}
@@ -124,7 +124,7 @@
mScript = new ScriptC_rslist(mRS, mRes, R.raw.rslist);
mListAllocs = new ScriptField_ListAllocs_s(mRS, DATA_LIST.length);
- for(int i = 0; i < DATA_LIST.length; i ++) {
+ for (int i = 0; i < DATA_LIST.length; i ++) {
ScriptField_ListAllocs_s.Item listElem = new ScriptField_ListAllocs_s.Item();
listElem.text = Allocation.createFromString(mRS, DATA_LIST[i]);
mListAllocs.set(listElem, i, false);
diff --git a/java/Samples/src/com/android/samples/RsListView.java b/java/Samples/src/com/android/samples/RsListView.java
index cd66fbb..21b58b1 100644
--- a/java/Samples/src/com/android/samples/RsListView.java
+++ b/java/Samples/src/com/android/samples/RsListView.java
@@ -64,7 +64,7 @@
@Override
protected void onDetachedFromWindow() {
- if(mRS != null) {
+ if (mRS != null) {
mRS = null;
destroyRenderScript();
}
@@ -87,8 +87,7 @@
if (act == ev.ACTION_DOWN) {
mRender.onActionDown((int)ev.getX(), (int)ev.getY());
ret = true;
- }
- else if (act == ev.ACTION_MOVE) {
+ } else if (act == ev.ACTION_MOVE) {
mRender.onActionMove((int)ev.getX(), (int)ev.getY());
ret = true;
}
diff --git a/java/Samples/src/com/android/samples/RsRenderStatesRS.java b/java/Samples/src/com/android/samples/RsRenderStatesRS.java
index dd2daa7..f0b69d1 100644
--- a/java/Samples/src/com/android/samples/RsRenderStatesRS.java
+++ b/java/Samples/src/com/android/samples/RsRenderStatesRS.java
@@ -307,10 +307,9 @@
FileA3D model = FileA3D.createFromResource(mRS, mRes, R.raw.torus);
FileA3D.IndexEntry entry = model.getIndexEntry(0);
- if(entry == null || entry.getClassID() != FileA3D.ClassID.MESH) {
+ if (entry == null || entry.getClassID() != FileA3D.ClassID.MESH) {
Log.e("rs", "could not load model");
- }
- else {
+ } else {
mTorus = (Mesh)entry.getObject();
mScript.set_gTorusMesh(mTorus);
}
diff --git a/java/Samples/src/com/android/samples/RsRenderStatesView.java b/java/Samples/src/com/android/samples/RsRenderStatesView.java
index c434c09..6893d20 100644
--- a/java/Samples/src/com/android/samples/RsRenderStatesView.java
+++ b/java/Samples/src/com/android/samples/RsRenderStatesView.java
@@ -64,7 +64,7 @@
@Override
protected void onDetachedFromWindow() {
- if(mRS != null) {
+ if (mRS != null) {
mRS = null;
destroyRenderScript();
}
diff --git a/java/Samples/src/com/android/samples/rslist.rs b/java/Samples/src/com/android/samples/rslist.rs
index 01b37ab..f29276a 100644
--- a/java/Samples/src/com/android/samples/rslist.rs
+++ b/java/Samples/src/com/android/samples/rslist.rs
@@ -56,12 +56,12 @@
int itemHeight = 80;
int currentYPos = itemHeight + textPos;
- for(int i = 0; i < allocSize; i ++) {
- if(currentYPos - itemHeight > height) {
+ for (int i = 0; i < allocSize; i ++) {
+ if (currentYPos - itemHeight > height) {
break;
}
- if(currentYPos > 0) {
+ if (currentYPos > 0) {
rsgDrawRect(0, currentYPos - 1, width, currentYPos, 0);
rsgDrawText(gList[i].text, 30, currentYPos - 32);
}
diff --git a/java/Samples/src/com/android/samples/rsrenderstates.rs b/java/Samples/src/com/android/samples/rsrenderstates.rs
index 4f8eada..f26633d 100644
--- a/java/Samples/src/com/android/samples/rsrenderstates.rs
+++ b/java/Samples/src/com/android/samples/rsrenderstates.rs
@@ -214,7 +214,7 @@
rsgBindProgramFragment(gProgFragmentColor);
rsgBindProgramStore(gProgStoreBlendNone);
- for(i = 0; i < 3; i ++) {
+ for (i = 0; i < 3; i ++) {
float iPlusOne = (float)(i + 1);
rsgProgramFragmentConstantColor(gProgFragmentColor,
0.1f*iPlusOne, 0.2f*iPlusOne, 0.3f*iPlusOne, 1);
@@ -223,7 +223,7 @@
}
rsgBindProgramStore(gProgStoreBlendAlpha);
- for(i = 0; i < 3; i ++) {
+ for (i = 0; i < 3; i ++) {
float iPlusOne = (float)(i + 1);
rsgProgramFragmentConstantColor(gProgFragmentColor,
0.2f*iPlusOne, 0.3f*iPlusOne, 0.1f*iPlusOne, 0.5);
@@ -232,7 +232,7 @@
}
rsgBindProgramStore(gProgStoreBlendAdd);
- for(i = 0; i < 3; i ++) {
+ for (i = 0; i < 3; i ++) {
float iPlusOne = (float)(i + 1);
rsgProgramFragmentConstantColor(gProgFragmentColor,
0.3f*iPlusOne, 0.1f*iPlusOne, 0.2f*iPlusOne, 0.5);
@@ -342,7 +342,7 @@
// Aplly a rotation to our mesh
gTorusRotation += 50.0f * gDt;
- if(gTorusRotation > 360.0f) {
+ if (gTorusRotation > 360.0f) {
gTorusRotation -= 360.0f;
}
@@ -379,11 +379,11 @@
float4 light1SpecCol = {0.5f, 0.5f, 0.9f, 1.0f};
gLight0Rotation += 50.0f * gDt;
- if(gLight0Rotation > 360.0f) {
+ if (gLight0Rotation > 360.0f) {
gLight0Rotation -= 360.0f;
}
gLight1Rotation -= 50.0f * gDt;
- if(gLight1Rotation > 360.0f) {
+ if (gLight1Rotation > 360.0f) {
gLight1Rotation -= 360.0f;
}
@@ -439,7 +439,7 @@
// Load model matrix
// Aplly a rotation to our mesh
gTorusRotation += 50.0f * gDt;
- if(gTorusRotation > 360.0f) {
+ if (gTorusRotation > 360.0f) {
gTorusRotation -= 360.0f;
}
@@ -475,7 +475,7 @@
// Load model matrix
// Aplly a rotation to our mesh
gTorusRotation += 50.0f * gDt;
- if(gTorusRotation > 360.0f) {
+ if (gTorusRotation > 360.0f) {
gTorusRotation -= 360.0f;
}
@@ -558,19 +558,17 @@
rsgBindTexture(gProgFragmentTexture, 0, gTexChecker);
- if(gAnisoTime >= 5.0f) {
+ if (gAnisoTime >= 5.0f) {
gAnisoTime = 0.0f;
anisoMode ++;
anisoMode = anisoMode % 3;
}
- if(anisoMode == 0) {
+ if (anisoMode == 0) {
rsgBindSampler(gProgFragmentTexture, 0, gMipLinearAniso8);
- }
- else if(anisoMode == 1) {
+ } else if (anisoMode == 1) {
rsgBindSampler(gProgFragmentTexture, 0, gMipLinearAniso15);
- }
- else {
+ } else {
rsgBindSampler(gProgFragmentTexture, 0, gMipLinearWrap);
}
@@ -587,13 +585,11 @@
rsgFontColor(1.0f, 1.0f, 1.0f, 1.0f);
rsgBindFont(gFontMono);
- if(anisoMode == 0) {
+ if (anisoMode == 0) {
rsgDrawText("Anisotropic filtering 8", 10, 40);
- }
- else if(anisoMode == 1) {
+ } else if (anisoMode == 1) {
rsgDrawText("Anisotropic filtering 15", 10, 40);
- }
- else {
+ } else {
rsgDrawText("Miplinear filtering", 10, 40);
}
}
@@ -605,7 +601,7 @@
rsgClearColor(0.2f, 0.2f, 0.2f, 0.0f);
rsgClearDepth(1.0f);
- switch(gDisplayMode) {
+ switch (gDisplayMode) {
case 0:
displayFontSamples();
break;
diff --git a/rsAdapter.cpp b/rsAdapter.cpp
index 1d1425c..2a705a1 100644
--- a/rsAdapter.cpp
+++ b/rsAdapter.cpp
@@ -24,28 +24,23 @@
using namespace android;
using namespace android::renderscript;
-
-Adapter1D::Adapter1D(Context *rsc) : ObjectBase(rsc)
-{
+Adapter1D::Adapter1D(Context *rsc) : ObjectBase(rsc) {
reset();
}
-Adapter1D::Adapter1D(Context *rsc, Allocation *a) : ObjectBase(rsc)
-{
+Adapter1D::Adapter1D(Context *rsc, Allocation *a) : ObjectBase(rsc) {
reset();
setAllocation(a);
}
-void Adapter1D::reset()
-{
+void Adapter1D::reset() {
mY = 0;
mZ = 0;
mLOD = 0;
mFace = 0;
}
-void * Adapter1D::getElement(uint32_t x)
-{
+void * Adapter1D::getElement(uint32_t x) {
rsAssert(mAllocation.get());
rsAssert(mAllocation->getPtr());
rsAssert(mAllocation->getType());
@@ -54,8 +49,7 @@
return ptr;
}
-void Adapter1D::subData(uint32_t xoff, uint32_t count, const void *data)
-{
+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();
@@ -63,44 +57,37 @@
}
}
-void Adapter1D::data(const void *data)
-{
+void Adapter1D::data(const void *data) {
memcpy(getElement(0),
data,
mAllocation.get()->getType()->getSizeBytes());
}
-void Adapter1D::serialize(OStream *stream) const
-{
-
+void Adapter1D::serialize(OStream *stream) const {
}
-Adapter1D *Adapter1D::createFromStream(Context *rsc, IStream *stream)
-{
+Adapter1D *Adapter1D::createFromStream(Context *rsc, IStream *stream) {
return NULL;
}
namespace android {
namespace renderscript {
-RsAdapter1D rsi_Adapter1DCreate(Context *rsc)
-{
+RsAdapter1D rsi_Adapter1DCreate(Context *rsc) {
Adapter1D *a = new Adapter1D(rsc);
a->incUserRef();
return a;
}
-void rsi_Adapter1DBindAllocation(Context *rsc, RsAdapter1D va, RsAllocation valloc)
-{
+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)
-{
+void rsi_Adapter1DSetConstraint(Context *rsc, RsAdapter1D va, RsDimension dim, uint32_t value) {
Adapter1D * a = static_cast<Adapter1D *>(va);
- switch(dim) {
+ switch (dim) {
case RS_DIMENSION_X:
rsAssert(!"Cannot contrain X in an 1D adapter");
return;
@@ -122,14 +109,12 @@
}
}
-void rsi_Adapter1DSubData(Context *rsc, RsAdapter1D va, uint32_t xoff, uint32_t count, const void *data)
-{
+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)
-{
+void rsi_Adapter1DData(Context *rsc, RsAdapter1D va, const void *data) {
Adapter1D * a = static_cast<Adapter1D *>(va);
a->data(data);
}
@@ -139,26 +124,22 @@
//////////////////////////
-Adapter2D::Adapter2D(Context *rsc) : ObjectBase(rsc)
-{
+Adapter2D::Adapter2D(Context *rsc) : ObjectBase(rsc) {
reset();
}
-Adapter2D::Adapter2D(Context *rsc, Allocation *a) : ObjectBase(rsc)
-{
+Adapter2D::Adapter2D(Context *rsc, Allocation *a) : ObjectBase(rsc) {
reset();
setAllocation(a);
}
-void Adapter2D::reset()
-{
+void Adapter2D::reset() {
mZ = 0;
mLOD = 0;
mFace = 0;
}
-void * Adapter2D::getElement(uint32_t x, uint32_t y) const
-{
+void * Adapter2D::getElement(uint32_t x, uint32_t y) const {
rsAssert(mAllocation.get());
rsAssert(mAllocation->getPtr());
rsAssert(mAllocation->getType());
@@ -167,8 +148,7 @@
return ptr;
}
-void Adapter2D::subData(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, const void *data)
-{
+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());
@@ -183,20 +163,16 @@
}
}
-void Adapter2D::data(const void *data)
-{
+void Adapter2D::data(const void *data) {
memcpy(getElement(0,0),
data,
mAllocation.get()->getType()->getSizeBytes());
}
-void Adapter2D::serialize(OStream *stream) const
-{
-
+void Adapter2D::serialize(OStream *stream) const {
}
-Adapter2D *Adapter2D::createFromStream(Context *rsc, IStream *stream)
-{
+Adapter2D *Adapter2D::createFromStream(Context *rsc, IStream *stream) {
return NULL;
}
@@ -204,24 +180,21 @@
namespace android {
namespace renderscript {
-RsAdapter2D rsi_Adapter2DCreate(Context *rsc)
-{
+RsAdapter2D rsi_Adapter2DCreate(Context *rsc) {
Adapter2D *a = new Adapter2D(rsc);
a->incUserRef();
return a;
}
-void rsi_Adapter2DBindAllocation(Context *rsc, RsAdapter2D va, RsAllocation valloc)
-{
+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)
-{
+void rsi_Adapter2DSetConstraint(Context *rsc, RsAdapter2D va, RsDimension dim, uint32_t value) {
Adapter2D * a = static_cast<Adapter2D *>(va);
- switch(dim) {
+ switch (dim) {
case RS_DIMENSION_X:
rsAssert(!"Cannot contrain X in an 2D adapter");
return;
@@ -243,14 +216,12 @@
}
}
-void rsi_Adapter2DData(Context *rsc, RsAdapter2D va, const void *data)
-{
+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)
-{
+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/rsAdapter.h b/rsAdapter.h
index 449e7ad..d150789 100644
--- a/rsAdapter.h
+++ b/rsAdapter.h
@@ -24,8 +24,7 @@
namespace renderscript {
-class Adapter1D : public ObjectBase
-{
+class Adapter1D : public ObjectBase {
public:
// By policy this allocation will hold a pointer to the type
@@ -62,8 +61,7 @@
uint32_t mFace;
};
-class Adapter2D : public ObjectBase
-{
+class Adapter2D : public ObjectBase {
public:
// By policy this allocation will hold a pointer to the type
@@ -97,7 +95,6 @@
uint32_t mFace;
};
-
}
}
#endif
diff --git a/rsAllocation.cpp b/rsAllocation.cpp
index 28078fc..23135e2 100644
--- a/rsAllocation.cpp
+++ b/rsAllocation.cpp
@@ -31,8 +31,7 @@
using namespace android;
using namespace android::renderscript;
-Allocation::Allocation(Context *rsc, const Type *type) : ObjectBase(rsc)
-{
+Allocation::Allocation(Context *rsc, const Type *type) : ObjectBase(rsc) {
init(rsc, type);
mPtr = malloc(mType->getSizeBytes());
@@ -46,8 +45,7 @@
Allocation::Allocation(Context *rsc, const Type *type, void *bmp,
void *callbackData, RsBitmapCallback_t callback)
-: ObjectBase(rsc)
-{
+ : ObjectBase(rsc) {
init(rsc, type);
mPtr = bmp;
@@ -55,8 +53,7 @@
mUserBitmapCallbackData = callbackData;
}
-void Allocation::init(Context *rsc, const Type *type)
-{
+void Allocation::init(Context *rsc, const Type *type) {
mPtr = NULL;
mCpuWrite = false;
@@ -82,8 +79,7 @@
mPtr = NULL;
}
-Allocation::~Allocation()
-{
+Allocation::~Allocation() {
if (mUserBitmapCallback != NULL) {
mUserBitmapCallback(mUserBitmapCallbackData);
} else {
@@ -103,29 +99,23 @@
}
}
-void Allocation::setCpuWritable(bool)
-{
+void Allocation::setCpuWritable(bool) {
}
-void Allocation::setGpuWritable(bool)
-{
+void Allocation::setGpuWritable(bool) {
}
-void Allocation::setCpuReadable(bool)
-{
+void Allocation::setCpuReadable(bool) {
}
-void Allocation::setGpuReadable(bool)
-{
+void Allocation::setGpuReadable(bool) {
}
-bool Allocation::fixAllocation()
-{
+bool Allocation::fixAllocation() {
return false;
}
-void Allocation::deferedUploadToTexture(const Context *rsc, bool genMipmap, uint32_t lodOffset)
-{
+void Allocation::deferedUploadToTexture(const Context *rsc, bool genMipmap, uint32_t lodOffset) {
rsAssert(lodOffset < mType->getLODCount());
mIsTexture = true;
mTextureLOD = lodOffset;
@@ -133,8 +123,7 @@
mTextureGenMipmap = !mType->getDimLOD() && genMipmap;
}
-void Allocation::uploadToTexture(const Context *rsc)
-{
+void Allocation::uploadToTexture(const Context *rsc) {
//rsAssert(!mTextureId);
mIsTexture = true;
@@ -170,11 +159,11 @@
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
Adapter2D adapt(getContext(), this);
- for(uint32_t lod = 0; (lod + mTextureLOD) < mType->getLODCount(); lod++) {
+ for (uint32_t lod = 0; (lod + mTextureLOD) < mType->getLODCount(); lod++) {
adapt.setLOD(lod+mTextureLOD);
uint16_t * ptr = static_cast<uint16_t *>(adapt.getElement(0,0));
- if(isFirstUpload) {
+ if (isFirstUpload) {
glTexImage2D(GL_TEXTURE_2D, lod, format,
adapt.getDimX(), adapt.getDimY(),
0, format, type, ptr);
@@ -193,14 +182,12 @@
rsc->checkError("Allocation::uploadToTexture");
}
-void Allocation::deferedUploadToBufferObject(const Context *rsc)
-{
+void Allocation::deferedUploadToBufferObject(const Context *rsc) {
mIsVertexBuffer = true;
mUploadDefered = true;
}
-void Allocation::uploadToBufferObject(const Context *rsc)
-{
+void Allocation::uploadToBufferObject(const Context *rsc) {
rsAssert(!mType->getDimY());
rsAssert(!mType->getDimZ());
@@ -225,8 +212,7 @@
rsc->checkError("Allocation::uploadToBufferObject");
}
-void Allocation::uploadCheck(const Context *rsc)
-{
+void Allocation::uploadCheck(const Context *rsc) {
if (mUploadDefered) {
mUploadDefered = false;
if (mIsVertexBuffer) {
@@ -239,8 +225,7 @@
}
-void Allocation::data(Context *rsc, const void *data, uint32_t sizeBytes)
-{
+void Allocation::data(Context *rsc, const void *data, uint32_t sizeBytes) {
uint32_t size = mType->getSizeBytes();
if (size != sizeBytes) {
LOGE("Allocation::data called with mismatched size expected %i, got %i", size, sizeBytes);
@@ -257,13 +242,11 @@
mUploadDefered = true;
}
-void Allocation::read(void *data)
-{
+void Allocation::read(void *data) {
memcpy(data, mPtr, mType->getSizeBytes());
}
-void Allocation::subData(Context *rsc, uint32_t xoff, uint32_t count, const void *data, uint32_t sizeBytes)
-{
+void Allocation::subData(Context *rsc, uint32_t xoff, uint32_t count, const void *data, uint32_t sizeBytes) {
uint32_t eSize = mType->getElementSizeBytes();
uint8_t * ptr = static_cast<uint8_t *>(mPtr);
ptr += eSize * xoff;
@@ -286,8 +269,7 @@
}
void Allocation::subData(Context *rsc, uint32_t xoff, uint32_t yoff,
- uint32_t w, uint32_t h, const void *data, uint32_t sizeBytes)
-{
+ uint32_t w, uint32_t h, const void *data, uint32_t sizeBytes) {
uint32_t eSize = mType->getElementSizeBytes();
uint32_t lineSize = eSize * w;
uint32_t destW = mType->getDimX();
@@ -315,13 +297,11 @@
}
void Allocation::subData(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t zoff,
- uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes)
-{
+ uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes) {
}
void Allocation::subElementData(Context *rsc, uint32_t x, const void *data,
- uint32_t cIdx, uint32_t sizeBytes)
-{
+ uint32_t cIdx, uint32_t sizeBytes) {
uint32_t eSize = mType->getElementSizeBytes();
uint8_t * ptr = static_cast<uint8_t *>(mPtr);
ptr += eSize * x;
@@ -358,8 +338,7 @@
}
void Allocation::subElementData(Context *rsc, uint32_t x, uint32_t y,
- const void *data, uint32_t cIdx, uint32_t sizeBytes)
-{
+ const void *data, uint32_t cIdx, uint32_t sizeBytes) {
uint32_t eSize = mType->getElementSizeBytes();
uint8_t * ptr = static_cast<uint8_t *>(mPtr);
ptr += eSize * (x + y * mType->getDimX());
@@ -401,13 +380,11 @@
mUploadDefered = true;
}
-void Allocation::addProgramToDirty(const Program *p)
-{
+void Allocation::addProgramToDirty(const Program *p) {
mToDirtyList.push(p);
}
-void Allocation::removeProgramToDirty(const Program *p)
-{
+void Allocation::removeProgramToDirty(const Program *p) {
for (size_t ct=0; ct < mToDirtyList.size(); ct++) {
if (mToDirtyList[ct] == p) {
mToDirtyList.removeAt(ct);
@@ -417,8 +394,7 @@
rsAssert(0);
}
-void Allocation::dumpLOGV(const char *prefix) const
-{
+void Allocation::dumpLOGV(const char *prefix) const {
ObjectBase::dumpLOGV(prefix);
String8 s(prefix);
@@ -432,11 +408,9 @@
LOGV("%s allocation mIsTexture=%i mTextureID=%i, mIsVertexBuffer=%i, mBufferID=%i",
prefix, mIsTexture, mTextureID, mIsVertexBuffer, mBufferID);
-
}
-void Allocation::serialize(OStream *stream) const
-{
+void Allocation::serialize(OStream *stream) const {
// Need to identify ourselves
stream->addU32((uint32_t)getClassId());
@@ -454,11 +428,10 @@
stream->addByteArray(mPtr, dataSize);
}
-Allocation *Allocation::createFromStream(Context *rsc, IStream *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) {
+ if (classID != RS_A3D_CLASS_ID_ALLOCATION) {
LOGE("allocation loading skipped due to invalid class id\n");
return NULL;
}
@@ -467,14 +440,14 @@
stream->loadString(&name);
Type *type = Type::createFromStream(rsc, stream);
- if(!type) {
+ if (!type) {
return NULL;
}
type->compute();
// Number of bytes we wrote out for this allocation
uint32_t dataSize = stream->loadU32();
- if(dataSize != type->getSizeBytes()) {
+ if (dataSize != type->getSizeBytes()) {
LOGE("failed to read allocation because numbytes written is not the same loaded type wants\n");
ObjectBase::checkDelete(type);
return NULL;
@@ -490,15 +463,13 @@
return alloc;
}
-void Allocation::sendDirty() const
-{
+void Allocation::sendDirty() const {
for (size_t ct=0; ct < mToDirtyList.size(); ct++) {
mToDirtyList[ct]->forceDirty();
}
}
-void Allocation::incRefs(const void *ptr, size_t ct, size_t startOff) const
-{
+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 = mType->getElement();
uint32_t stride = e->getSizeBytes();
@@ -511,8 +482,7 @@
}
}
-void Allocation::decRefs(const void *ptr, size_t ct, size_t startOff) const
-{
+void Allocation::decRefs(const void *ptr, size_t ct, size_t startOff) const {
const uint8_t *p = static_cast<const uint8_t *>(ptr);
const Element *e = mType->getElement();
uint32_t stride = e->getSizeBytes();
@@ -525,12 +495,10 @@
}
}
-void Allocation::copyRange1D(Context *rsc, const Allocation *src, int32_t srcOff, int32_t destOff, int32_t len)
-{
+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)
-{
+void Allocation::resize1D(Context *rsc, uint32_t dimX) {
Type *t = mType->cloneAndResize1D(rsc, dimX);
uint32_t oldDimX = mType->getDimX();
@@ -551,8 +519,7 @@
mType.set(t);
}
-void Allocation::resize2D(Context *rsc, uint32_t dimX, uint32_t dimY)
-{
+void Allocation::resize2D(Context *rsc, uint32_t dimX, uint32_t dimY) {
LOGE("not implemented");
}
@@ -563,20 +530,17 @@
namespace android {
namespace renderscript {
-void rsi_AllocationUploadToTexture(Context *rsc, RsAllocation va, bool genmip, uint32_t baseMipLevel)
-{
+void rsi_AllocationUploadToTexture(Context *rsc, RsAllocation va, bool genmip, uint32_t baseMipLevel) {
Allocation *alloc = static_cast<Allocation *>(va);
alloc->deferedUploadToTexture(rsc, genmip, baseMipLevel);
}
-void rsi_AllocationUploadToBufferObject(Context *rsc, RsAllocation va)
-{
+void rsi_AllocationUploadToBufferObject(Context *rsc, RsAllocation va) {
Allocation *alloc = static_cast<Allocation *>(va);
alloc->deferedUploadToBufferObject(rsc);
}
-static void mip565(const Adapter2D &out, const Adapter2D &in)
-{
+static void mip565(const Adapter2D &out, const Adapter2D &in) {
uint32_t w = out.getDimX();
uint32_t h = out.getDimY();
@@ -594,8 +558,7 @@
}
}
-static void mip8888(const Adapter2D &out, const Adapter2D &in)
-{
+static void mip8888(const Adapter2D &out, const Adapter2D &in) {
uint32_t w = out.getDimX();
uint32_t h = out.getDimY();
@@ -613,8 +576,7 @@
}
}
-static void mip8(const Adapter2D &out, const Adapter2D &in)
-{
+static void mip8(const Adapter2D &out, const Adapter2D &in) {
uint32_t w = out.getDimX();
uint32_t h = out.getDimY();
@@ -632,9 +594,8 @@
}
}
-static void mip(const Adapter2D &out, const Adapter2D &in)
-{
- switch(out.getBaseType()->getElement()->getSizeBits()) {
+static void mip(const Adapter2D &out, const Adapter2D &in) {
+ switch (out.getBaseType()->getElement()->getSizeBits()) {
case 32:
mip8888(out, in);
break;
@@ -644,60 +605,51 @@
case 8:
mip8(out, in);
break;
-
}
-
}
typedef void (*ElementConverter_t)(void *dst, const void *src, uint32_t count);
-static void elementConverter_cpy_16(void *dst, const void *src, uint32_t count)
-{
+static void elementConverter_cpy_16(void *dst, const void *src, uint32_t count) {
memcpy(dst, src, count * 2);
}
-static void elementConverter_cpy_8(void *dst, const void *src, uint32_t count)
-{
+static void elementConverter_cpy_8(void *dst, const void *src, uint32_t count) {
memcpy(dst, src, count);
}
-static void elementConverter_cpy_32(void *dst, const void *src, uint32_t count)
-{
+static void elementConverter_cpy_32(void *dst, const void *src, uint32_t count) {
memcpy(dst, src, count * 4);
}
-
-static void elementConverter_888_to_565(void *dst, const void *src, uint32_t count)
-{
+static void elementConverter_888_to_565(void *dst, const void *src, uint32_t count) {
uint16_t *d = static_cast<uint16_t *>(dst);
const uint8_t *s = static_cast<const uint8_t *>(src);
- while(count--) {
+ while (count--) {
*d = rs888to565(s[0], s[1], s[2]);
d++;
s+= 3;
}
}
-static void elementConverter_8888_to_565(void *dst, const void *src, uint32_t count)
-{
+static void elementConverter_8888_to_565(void *dst, const void *src, uint32_t count) {
uint16_t *d = static_cast<uint16_t *>(dst);
const uint8_t *s = static_cast<const uint8_t *>(src);
- while(count--) {
+ while (count--) {
*d = rs888to565(s[0], s[1], s[2]);
d++;
s+= 4;
}
}
-static ElementConverter_t pickConverter(const Element *dst, const Element *src)
-{
+static ElementConverter_t pickConverter(const Element *dst, const Element *src) {
GLenum srcGLType = src->getComponent().getGLType();
GLenum srcGLFmt = src->getComponent().getGLFormat();
GLenum dstGLType = dst->getComponent().getGLType();
GLenum dstGLFmt = dst->getComponent().getGLFormat();
if (srcGLFmt == dstGLFmt && srcGLType == dstGLType) {
- switch(dst->getSizeBytes()) {
+ switch (dst->getSizeBytes()) {
case 4:
return elementConverter_cpy_32;
case 2:
@@ -734,16 +686,16 @@
#ifndef ANDROID_RS_BUILD_FOR_HOST
RsAllocation rsi_AllocationCreateBitmapRef(Context *rsc, RsType vtype,
- void *bmp, void *callbackData, RsBitmapCallback_t callback)
-{
+ void *bmp, void *callbackData,
+ RsBitmapCallback_t callback) {
const Type * type = static_cast<const Type *>(vtype);
Allocation * alloc = new Allocation(rsc, type, bmp, callbackData, callback);
alloc->incUserRef();
return alloc;
}
-void rsi_AllocationUpdateFromBitmap(Context *rsc, RsAllocation va, RsElement _src, const void *data)
-{
+void rsi_AllocationUpdateFromBitmap(Context *rsc, RsAllocation va,
+ RsElement _src, const void *data) {
Allocation *texAlloc = static_cast<Allocation *>(va);
const Element *src = static_cast<const Element *>(_src);
const Element *dst = texAlloc->getType()->getElement();
@@ -757,7 +709,7 @@
if (genMips) {
Adapter2D adapt(rsc, texAlloc);
Adapter2D adapt2(rsc, texAlloc);
- for(uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) {
+ for (uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) {
adapt.setLOD(lod);
adapt2.setLOD(lod + 1);
mip(adapt2, adapt);
@@ -768,50 +720,42 @@
}
}
-void rsi_AllocationData(Context *rsc, RsAllocation va, const void *data, uint32_t sizeBytes)
-{
+void rsi_AllocationData(Context *rsc, RsAllocation va, const void *data, uint32_t sizeBytes) {
Allocation *a = static_cast<Allocation *>(va);
a->data(rsc, data, sizeBytes);
}
-void rsi_Allocation1DSubData(Context *rsc, RsAllocation va, uint32_t xoff, uint32_t count, const void *data, uint32_t sizeBytes)
-{
+void rsi_Allocation1DSubData(Context *rsc, RsAllocation va, uint32_t xoff, uint32_t count, const void *data, uint32_t sizeBytes) {
Allocation *a = static_cast<Allocation *>(va);
a->subData(rsc, xoff, count, data, sizeBytes);
}
-void rsi_Allocation2DSubElementData(Context *rsc, RsAllocation va, uint32_t x, uint32_t y, const void *data, uint32_t eoff, uint32_t sizeBytes)
-{
+void rsi_Allocation2DSubElementData(Context *rsc, RsAllocation va, uint32_t x, uint32_t y, const void *data, uint32_t eoff, uint32_t sizeBytes) {
Allocation *a = static_cast<Allocation *>(va);
a->subElementData(rsc, x, y, data, eoff, sizeBytes);
}
-void rsi_Allocation1DSubElementData(Context *rsc, RsAllocation va, uint32_t x, const void *data, uint32_t eoff, uint32_t sizeBytes)
-{
+void rsi_Allocation1DSubElementData(Context *rsc, RsAllocation va, uint32_t x, const void *data, uint32_t eoff, uint32_t sizeBytes) {
Allocation *a = static_cast<Allocation *>(va);
a->subElementData(rsc, x, data, eoff, sizeBytes);
}
-void rsi_Allocation2DSubData(Context *rsc, RsAllocation va, uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, const void *data, uint32_t sizeBytes)
-{
+void rsi_Allocation2DSubData(Context *rsc, RsAllocation va, uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, const void *data, uint32_t sizeBytes) {
Allocation *a = static_cast<Allocation *>(va);
a->subData(rsc, xoff, yoff, w, h, data, sizeBytes);
}
-void rsi_AllocationRead(Context *rsc, RsAllocation va, void *data)
-{
+void rsi_AllocationRead(Context *rsc, RsAllocation va, void *data) {
Allocation *a = static_cast<Allocation *>(va);
a->read(data);
}
-void rsi_AllocationResize1D(Context *rsc, RsAllocation va, uint32_t dimX)
-{
+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)
-{
+void rsi_AllocationResize2D(Context *rsc, RsAllocation va, uint32_t dimX, uint32_t dimY) {
Allocation *a = static_cast<Allocation *>(va);
a->resize2D(rsc, dimX, dimY);
}
@@ -821,24 +765,21 @@
}
}
-const void * rsaAllocationGetType(RsContext con, RsAllocation va)
-{
+const void * rsaAllocationGetType(RsContext con, RsAllocation va) {
Allocation *a = static_cast<Allocation *>(va);
a->getType()->incUserRef();
return a->getType();
}
-RsAllocation rsaAllocationCreateTyped(RsContext con, RsType vtype)
-{
+RsAllocation rsaAllocationCreateTyped(RsContext con, RsType vtype) {
Context *rsc = static_cast<Context *>(con);
Allocation * alloc = new Allocation(rsc, static_cast<Type *>(vtype));
alloc->incUserRef();
return alloc;
}
-RsAllocation rsaAllocationCreateFromBitmap(RsContext con, uint32_t w, uint32_t h, RsElement _dst, RsElement _src, bool genMips, const void *data)
-{
+RsAllocation rsaAllocationCreateFromBitmap(RsContext con, uint32_t w, uint32_t h, RsElement _dst, RsElement _src, bool genMips, const void *data) {
Context *rsc = static_cast<Context *>(con);
const Element *src = static_cast<const Element *>(_src);
const Element *dst = static_cast<const Element *>(_dst);
@@ -861,7 +802,7 @@
if (genMips) {
Adapter2D adapt(rsc, texAlloc);
Adapter2D adapt2(rsc, texAlloc);
- for(uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) {
+ for (uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) {
adapt.setLOD(lod);
adapt2.setLOD(lod + 1);
mip(adapt2, adapt);
diff --git a/rsAllocation.h b/rsAllocation.h
index 12cf832..f9a0fc9 100644
--- a/rsAllocation.h
+++ b/rsAllocation.h
@@ -25,8 +25,7 @@
class Program;
-class Allocation : public ObjectBase
-{
+class Allocation : public ObjectBase {
// The graphics equilivent of malloc. The allocation contains a structure of elements.
public:
diff --git a/rsAnimation.cpp b/rsAnimation.cpp
index 6200715..6abda3c 100644
--- a/rsAnimation.cpp
+++ b/rsAnimation.cpp
@@ -26,13 +26,10 @@
using namespace android;
using namespace android::renderscript;
-void Animation::serialize(OStream *stream) const
-{
-
+void Animation::serialize(OStream *stream) const {
}
-Animation *Animation::createFromStream(Context *rsc, IStream *stream)
-{
+Animation *Animation::createFromStream(Context *rsc, IStream *stream) {
return NULL;
}
@@ -133,8 +130,7 @@
uint32_t valueCount,
RsAnimationInterpolation interp,
RsAnimationEdge pre,
- RsAnimationEdge post)
-{
+ RsAnimationEdge post) {
//LOGE("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) {
diff --git a/rsAnimation.h b/rsAnimation.h
index 340314e..bff8d6f 100644
--- a/rsAnimation.h
+++ b/rsAnimation.h
@@ -25,8 +25,7 @@
namespace renderscript {
-class Animation : public ObjectBase
-{
+class Animation : public ObjectBase {
public:
~Animation();
@@ -62,9 +61,6 @@
float mInputMax;
};
-
-
-
}
}
#endif //ANDROID_STRUCTURED_ELEMENT_H
diff --git a/rsComponent.cpp b/rsComponent.cpp
index f51b23e..81ade5d 100644
--- a/rsComponent.cpp
+++ b/rsComponent.cpp
@@ -25,17 +25,14 @@
using namespace android;
using namespace android::renderscript;
-Component::Component()
-{
+Component::Component() {
set(RS_TYPE_NONE, RS_KIND_USER, false, 1);
}
-Component::~Component()
-{
+Component::~Component() {
}
-void Component::set(RsDataType dt, RsDataKind dk, bool norm, uint32_t vecSize)
-{
+void Component::set(RsDataType dt, RsDataKind dk, bool norm, uint32_t vecSize) {
mType = dt;
mKind = dk;
mNormalized = norm;
@@ -48,7 +45,7 @@
mIsSigned = false;
mIsPixel = false;
- switch(mKind) {
+ switch (mKind) {
case RS_KIND_PIXEL_L:
case RS_KIND_PIXEL_A:
mIsPixel = true;
@@ -74,7 +71,7 @@
break;
}
- switch(mType) {
+ switch (mType) {
case RS_TYPE_NONE:
return;
case RS_TYPE_UNSIGNED_5_6_5:
@@ -181,15 +178,11 @@
mBits = mTypeBits * mVectorSize;
}
-bool Component::isReference() const
-{
+bool Component::isReference() const {
return (mType >= RS_TYPE_ELEMENT);
}
-
-
-uint32_t Component::getGLType() const
-{
+uint32_t Component::getGLType() const {
switch (mType) {
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;
@@ -207,8 +200,7 @@
return 0;
}
-uint32_t Component::getGLFormat() const
-{
+uint32_t Component::getGLFormat() const {
switch (mKind) {
case RS_KIND_PIXEL_L: return GL_LUMINANCE;
case RS_KIND_PIXEL_A: return GL_ALPHA;
@@ -220,10 +212,9 @@
return 0;
}
-String8 Component::getGLSLType() const
-{
+String8 Component::getGLSLType() const {
if (mType == RS_TYPE_SIGNED_32) {
- switch(mVectorSize) {
+ switch (mVectorSize) {
case 1: return String8("int");
case 2: return String8("ivec2");
case 3: return String8("ivec3");
@@ -231,7 +222,7 @@
}
}
if (mType == RS_TYPE_FLOAT_32) {
- switch(mVectorSize) {
+ switch (mVectorSize) {
case 1: return String8("float");
case 2: return String8("vec2");
case 3: return String8("vec3");
@@ -300,8 +291,7 @@
"PIXEL_RGBA",
};
-void Component::dumpLOGV(const char *prefix) const
-{
+void Component::dumpLOGV(const char *prefix) const {
if (mType >= RS_TYPE_ELEMENT) {
LOGV("%s Component: %s, %s, vectorSize=%i, bits=%i",
prefix, gTypeObjStrings[mType - RS_TYPE_ELEMENT], gKindStrings[mKind], mVectorSize, mBits);
@@ -311,16 +301,14 @@
}
}
-void Component::serialize(OStream *stream) const
-{
+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)
-{
+void Component::loadFromStream(IStream *stream) {
mType = (RsDataType)stream->loadU8();
mKind = (RsDataKind)stream->loadU8();
uint8_t temp = stream->loadU8();
diff --git a/rsComponent.h b/rsComponent.h
index a775051..1bb4ff4 100644
--- a/rsComponent.h
+++ b/rsComponent.h
@@ -25,8 +25,7 @@
// An element is a group of Components that occupies one cell in a structure.
-class Component
-{
+class Component {
public:
Component();
~Component();
diff --git a/rsContext.cpp b/rsContext.cpp
index 9d766b7..18bf9fa 100644
--- a/rsContext.cpp
+++ b/rsContext.cpp
@@ -107,8 +107,7 @@
}
-bool Context::initGLThread()
-{
+bool Context::initGLThread() {
pthread_mutex_lock(&gInitMutex);
LOGV("initGLThread start %p", this);
@@ -239,7 +238,7 @@
mGL.GL_NV_texture_npot_2D_mipmap = NULL != strstr((const char *)mGL.mExtensions, "GL_NV_texture_npot_2D_mipmap");
mGL.EXT_texture_max_aniso = 1.0f;
bool hasAniso = NULL != strstr((const char *)mGL.mExtensions, "GL_EXT_texture_filter_anisotropic");
- if(hasAniso) {
+ if (hasAniso) {
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &mGL.EXT_texture_max_aniso);
}
@@ -248,8 +247,7 @@
return true;
}
-void Context::deinitEGL()
-{
+void Context::deinitEGL() {
LOGV("%p, deinitEGL", this);
if (mEGL.mContext != EGL_NO_CONTEXT) {
@@ -265,8 +263,7 @@
}
-uint32_t Context::runScript(Script *s)
-{
+uint32_t Context::runScript(Script *s) {
ObjectBaseRef<ProgramFragment> frag(mFragment);
ObjectBaseRef<ProgramVertex> vtx(mVertex);
ObjectBaseRef<ProgramStore> store(mFragmentStore);
@@ -283,16 +280,14 @@
return ret;
}
-void Context::checkError(const char *msg) const
-{
+void Context::checkError(const char *msg) const {
GLenum err = glGetError();
if (err != GL_NO_ERROR) {
LOGE("%p, GL Error, 0x%x, from %s", this, err, msg);
}
}
-uint32_t Context::runRootScript()
-{
+uint32_t Context::runRootScript() {
glViewport(0, 0, mWidth, mHeight);
timerSet(RS_TIMER_SCRIPT);
@@ -303,22 +298,19 @@
return ret;
}
-uint64_t Context::getTime() const
-{
+uint64_t Context::getTime() const {
struct timespec t;
clock_gettime(CLOCK_MONOTONIC, &t);
return t.tv_nsec + ((uint64_t)t.tv_sec * 1000 * 1000 * 1000);
}
-void Context::timerReset()
-{
+void Context::timerReset() {
for (int ct=0; ct < _RS_TIMER_TOTAL; ct++) {
mTimers[ct] = 0;
}
}
-void Context::timerInit()
-{
+void Context::timerInit() {
mTimeLast = getTime();
mTimeFrame = mTimeLast;
mTimeLastFrame = mTimeLast;
@@ -329,15 +321,14 @@
timerReset();
}
-void Context::timerFrame()
-{
+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) {
+ if (inverval >= averageFramerateInterval) {
inverval = inverval / 1000000;
mAverageFPS = (mAverageFPSFrameCount * 1000) / inverval;
mAverageFPSFrameCount = 0;
@@ -345,16 +336,14 @@
}
}
-void Context::timerSet(Timers tm)
-{
+void Context::timerSet(Timers tm) {
uint64_t last = mTimeLast;
mTimeLast = getTime();
mTimers[mTimerActive] += mTimeLast - last;
mTimerActive = tm;
}
-void Context::timerPrint()
-{
+void Context::timerPrint() {
double total = 0;
for (int ct = 0; ct < _RS_TIMER_TOTAL; ct++) {
total += mTimers[ct];
@@ -376,8 +365,7 @@
}
}
-bool Context::setupCheck()
-{
+bool Context::setupCheck() {
if (!mShaderCache.lookup(this, mVertex.get(), mFragment.get())) {
LOGE("Context::setupCheck() 1 fail");
return false;
@@ -394,15 +382,13 @@
mFragmentStore->setupGL2(this, &mStateFragmentStore);
}
-static bool getProp(const char *str)
-{
+static bool getProp(const char *str) {
char buf[PROPERTY_VALUE_MAX];
property_get(str, buf, "0");
return 0 != strcmp(buf, "0");
}
-void Context::displayDebugStats()
-{
+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;
@@ -419,8 +405,7 @@
mStateFont.setFontColor(oldR, oldG, oldB, oldA);
}
-void * Context::threadProc(void *vrsc)
-{
+void * Context::threadProc(void *vrsc) {
Context *rsc = static_cast<Context *>(vrsc);
rsc->mNativeThreadId = gettid();
@@ -479,7 +464,7 @@
if (mDraw && rsc->mIsGraphicsContext) {
targetTime = rsc->runRootScript();
- if(rsc->props.mLogVisual) {
+ if (rsc->props.mLogVisual) {
rsc->displayDebugStats();
}
@@ -526,8 +511,7 @@
return NULL;
}
-void * Context::helperThreadProc(void *vrsc)
-{
+void * Context::helperThreadProc(void *vrsc) {
Context *rsc = static_cast<Context *>(vrsc);
uint32_t idx = (uint32_t)android_atomic_inc(&rsc->mWorkers.mLaunchCount);
@@ -552,7 +536,7 @@
LOGE("pthread_setspecific %i", status);
}
- while(rsc->mRunning) {
+ while (rsc->mRunning) {
rsc->mWorkers.mLaunchSignals[idx].wait();
if (rsc->mWorkers.mLaunchCallback) {
rsc->mWorkers.mLaunchCallback(rsc->mWorkers.mLaunchData, idx);
@@ -565,21 +549,19 @@
return NULL;
}
-void Context::launchThreads(WorkerCallback_t cbk, void *data)
-{
+void Context::launchThreads(WorkerCallback_t cbk, void *data) {
mWorkers.mLaunchData = data;
mWorkers.mLaunchCallback = cbk;
mWorkers.mRunningCount = (int)mWorkers.mCount;
for (uint32_t ct = 0; ct < mWorkers.mCount; ct++) {
mWorkers.mLaunchSignals[ct].set();
}
- while(mWorkers.mRunningCount) {
+ while (mWorkers.mRunningCount) {
mWorkers.mCompleteSignal.wait();
}
}
-void Context::setPriority(int32_t p)
-{
+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
@@ -601,8 +583,7 @@
#endif
}
-Context::Context()
-{
+Context::Context() {
mDev = NULL;
mRunning = false;
mExit = false;
@@ -612,8 +593,7 @@
mErrorMsg = NULL;
}
-Context * Context::createContext(Device *dev, const RsSurfaceConfig *sc)
-{
+Context * Context::createContext(Device *dev, const RsSurfaceConfig *sc) {
Context * rsc = new Context();
if (!rsc->initContext(dev, sc)) {
delete rsc;
@@ -622,8 +602,7 @@
return rsc;
}
-bool Context::initContext(Device *dev, const RsSurfaceConfig *sc)
-{
+bool Context::initContext(Device *dev, const RsSurfaceConfig *sc) {
pthread_mutex_lock(&gInitMutex);
dev->addContext(this);
@@ -680,7 +659,7 @@
LOGE("Failed to start rs context thread.");
return false;
}
- while(!mRunning && (mError == RS_ERROR_NONE)) {
+ while (!mRunning && (mError == RS_ERROR_NONE)) {
usleep(100);
}
@@ -703,8 +682,7 @@
return true;
}
-Context::~Context()
-{
+Context::~Context() {
LOGV("Context::~Context");
mExit = true;
mPaused = false;
@@ -726,8 +704,7 @@
pthread_mutex_unlock(&gInitMutex);
}
-void Context::setSurface(uint32_t w, uint32_t h, ANativeWindow *sur)
-{
+void Context::setSurface(uint32_t w, uint32_t h, ANativeWindow *sur) {
rsAssert(mIsGraphicsContext);
EGLBoolean ret;
@@ -761,26 +738,22 @@
}
}
-void Context::pause()
-{
+void Context::pause() {
rsAssert(mIsGraphicsContext);
mPaused = true;
}
-void Context::resume()
-{
+void Context::resume() {
rsAssert(mIsGraphicsContext);
mPaused = false;
}
-void Context::setRootScript(Script *s)
-{
+void Context::setRootScript(Script *s) {
rsAssert(mIsGraphicsContext);
mRootScript.set(s);
}
-void Context::setFragmentStore(ProgramStore *pfs)
-{
+void Context::setFragmentStore(ProgramStore *pfs) {
rsAssert(mIsGraphicsContext);
if (pfs == NULL) {
mFragmentStore.set(mStateFragmentStore.mDefault);
@@ -789,8 +762,7 @@
}
}
-void Context::setFragment(ProgramFragment *pf)
-{
+void Context::setFragment(ProgramFragment *pf) {
rsAssert(mIsGraphicsContext);
if (pf == NULL) {
mFragment.set(mStateFragment.mDefault);
@@ -799,8 +771,7 @@
}
}
-void Context::setRaster(ProgramRaster *pr)
-{
+void Context::setRaster(ProgramRaster *pr) {
rsAssert(mIsGraphicsContext);
if (pr == NULL) {
mRaster.set(mStateRaster.mDefault);
@@ -809,8 +780,7 @@
}
}
-void Context::setVertex(ProgramVertex *pv)
-{
+void Context::setVertex(ProgramVertex *pv) {
rsAssert(mIsGraphicsContext);
if (pv == NULL) {
mVertex.set(mStateVertex.mDefault);
@@ -819,8 +789,7 @@
}
}
-void Context::setFont(Font *f)
-{
+void Context::setFont(Font *f) {
rsAssert(mIsGraphicsContext);
if (f == NULL) {
mFont.set(mStateFont.mDefault);
@@ -829,16 +798,14 @@
}
}
-void Context::assignName(ObjectBase *obj, const char *name, uint32_t len)
-{
+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++) {
+void Context::removeName(ObjectBase *obj) {
+ for (size_t ct=0; ct < mNames.size(); ct++) {
if (obj == mNames[ct]) {
mNames.removeAt(ct);
return;
@@ -846,8 +813,7 @@
}
}
-RsMessageToClientType Context::peekMessageToClient(size_t *receiveLen, uint32_t *subID, bool wait)
-{
+RsMessageToClientType Context::peekMessageToClient(size_t *receiveLen, uint32_t *subID, bool wait) {
*receiveLen = 0;
if (!wait && mIO.mToClient.isEmpty()) {
return RS_MESSAGE_TO_CLIENT_NONE;
@@ -863,8 +829,7 @@
return (RsMessageToClientType)commandID;
}
-RsMessageToClientType Context::getMessageToClient(void *data, size_t *receiveLen, uint32_t *subID, size_t bufferLen, bool wait)
-{
+RsMessageToClientType Context::getMessageToClient(void *data, size_t *receiveLen, uint32_t *subID, size_t bufferLen, bool wait) {
//LOGE("getMessageToClient %i %i", bufferLen, wait);
*receiveLen = 0;
if (!wait && mIO.mToClient.isEmpty()) {
@@ -889,8 +854,7 @@
return RS_MESSAGE_TO_CLIENT_RESIZE;
}
-bool Context::sendMessageToClient(const void *data, RsMessageToClientType cmdID, uint32_t subID, size_t len, bool waitForSpace)
-{
+bool Context::sendMessageToClient(const void *data, RsMessageToClientType cmdID, uint32_t subID, size_t len, bool waitForSpace) {
//LOGE("sendMessageToClient %i %i %i %i", cmdID, subID, len, waitForSpace);
if (cmdID == 0) {
LOGE("Attempting to send invalid command 0 to client.");
@@ -913,20 +877,17 @@
return true;
}
-void Context::initToClient()
-{
- while(!mRunning) {
+void Context::initToClient() {
+ while (!mRunning) {
usleep(100);
}
}
-void Context::deinitToClient()
-{
+void Context::deinitToClient() {
mIO.mToClient.shutdown();
}
-const char * Context::getError(RsError *err)
-{
+const char * Context::getError(RsError *err) {
*err = mError;
mError = RS_ERROR_NONE;
if (*err != RS_ERROR_NONE) {
@@ -935,16 +896,14 @@
return NULL;
}
-void Context::setError(RsError e, const char *msg)
-{
+void Context::setError(RsError e, const char *msg) {
mError = e;
mErrorMsg = msg;
sendMessageToClient(msg, RS_MESSAGE_TO_CLIENT_ERROR, e, strlen(msg) + 1, true);
}
-void Context::dumpDebug() const
-{
+void Context::dumpDebug() const {
LOGE("RS Context debug %p", this);
LOGE("RS Context debug");
@@ -971,18 +930,15 @@
namespace android {
namespace renderscript {
-void rsi_ContextFinish(Context *rsc)
-{
+void rsi_ContextFinish(Context *rsc) {
}
-void rsi_ContextBindRootScript(Context *rsc, RsScript vs)
-{
+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)
-{
+void rsi_ContextBindSampler(Context *rsc, uint32_t slot, RsSampler vs) {
Sampler *s = static_cast<Sampler *>(vs);
if (slot > RS_MAX_SAMPLER_SLOT) {
@@ -993,76 +949,63 @@
s->bindToContext(&rsc->mStateSampler, slot);
}
-void rsi_ContextBindProgramStore(Context *rsc, RsProgramStore vpfs)
-{
+void rsi_ContextBindProgramStore(Context *rsc, RsProgramStore vpfs) {
ProgramStore *pfs = static_cast<ProgramStore *>(vpfs);
rsc->setFragmentStore(pfs);
}
-void rsi_ContextBindProgramFragment(Context *rsc, RsProgramFragment vpf)
-{
+void rsi_ContextBindProgramFragment(Context *rsc, RsProgramFragment vpf) {
ProgramFragment *pf = static_cast<ProgramFragment *>(vpf);
rsc->setFragment(pf);
}
-void rsi_ContextBindProgramRaster(Context *rsc, RsProgramRaster vpr)
-{
+void rsi_ContextBindProgramRaster(Context *rsc, RsProgramRaster vpr) {
ProgramRaster *pr = static_cast<ProgramRaster *>(vpr);
rsc->setRaster(pr);
}
-void rsi_ContextBindProgramVertex(Context *rsc, RsProgramVertex vpv)
-{
+void rsi_ContextBindProgramVertex(Context *rsc, RsProgramVertex vpv) {
ProgramVertex *pv = static_cast<ProgramVertex *>(vpv);
rsc->setVertex(pv);
}
-void rsi_ContextBindFont(Context *rsc, RsFont vfont)
-{
+void rsi_ContextBindFont(Context *rsc, RsFont vfont) {
Font *font = static_cast<Font *>(vfont);
rsc->setFont(font);
}
-void rsi_AssignName(Context *rsc, void * obj, const char *name, uint32_t len)
-{
+void rsi_AssignName(Context *rsc, void * obj, const char *name, uint32_t len) {
ObjectBase *ob = static_cast<ObjectBase *>(obj);
rsc->assignName(ob, name, len);
}
-void rsi_ObjDestroy(Context *rsc, void *optr)
-{
+void rsi_ObjDestroy(Context *rsc, void *optr) {
ObjectBase *ob = static_cast<ObjectBase *>(optr);
rsc->removeName(ob);
ob->decUserRef();
}
-void rsi_ContextPause(Context *rsc)
-{
+void rsi_ContextPause(Context *rsc) {
rsc->pause();
}
-void rsi_ContextResume(Context *rsc)
-{
+void rsi_ContextResume(Context *rsc) {
rsc->resume();
}
-void rsi_ContextSetSurface(Context *rsc, uint32_t w, uint32_t h, ANativeWindow *sur)
-{
+void rsi_ContextSetSurface(Context *rsc, uint32_t w, uint32_t h, ANativeWindow *sur) {
rsc->setSurface(w, h, sur);
}
-void rsi_ContextSetPriority(Context *rsc, int32_t p)
-{
+void rsi_ContextSetPriority(Context *rsc, int32_t p) {
rsc->setPriority(p);
}
-void rsi_ContextDump(Context *rsc, int32_t bits)
-{
+void rsi_ContextDump(Context *rsc, int32_t bits) {
ObjectBase::dumpAll(rsc);
}
-const char * rsi_ContextGetError(Context *rsc, RsError *e)
-{
+const char* rsi_ContextGetError(Context *rsc, RsError *e) {
const char *msg = rsc->getError(e);
if (*e != RS_ERROR_NONE) {
LOGE("RS Error %i %s", *e, msg);
@@ -1074,16 +1017,14 @@
}
-RsContext rsContextCreate(RsDevice vdev, uint32_t version)
-{
+RsContext rsContextCreate(RsDevice vdev, uint32_t version) {
LOGV("rsContextCreate %p", vdev);
Device * dev = static_cast<Device *>(vdev);
Context *rsc = Context::createContext(dev, NULL);
return rsc;
}
-RsContext rsContextCreateGL(RsDevice vdev, uint32_t version, RsSurfaceConfig sc)
-{
+RsContext rsContextCreateGL(RsDevice vdev, uint32_t version, RsSurfaceConfig sc) {
LOGV("rsContextCreateGL %p", vdev);
Device * dev = static_cast<Device *>(vdev);
Context *rsc = Context::createContext(dev, &sc);
@@ -1091,40 +1032,34 @@
return rsc;
}
-void rsContextDestroy(RsContext vrsc)
-{
+void rsContextDestroy(RsContext vrsc) {
Context * rsc = static_cast<Context *>(vrsc);
delete rsc;
}
-RsMessageToClientType rsContextPeekMessage(RsContext vrsc, size_t *receiveLen, uint32_t *subID, bool wait)
-{
+RsMessageToClientType rsContextPeekMessage(RsContext vrsc, size_t *receiveLen, uint32_t *subID, bool wait) {
Context * rsc = static_cast<Context *>(vrsc);
return rsc->peekMessageToClient(receiveLen, subID, wait);
}
-RsMessageToClientType rsContextGetMessage(RsContext vrsc, void *data, size_t *receiveLen, uint32_t *subID, size_t bufferLen, bool wait)
-{
+RsMessageToClientType rsContextGetMessage(RsContext vrsc, void *data, size_t *receiveLen, uint32_t *subID, size_t bufferLen, bool wait) {
Context * rsc = static_cast<Context *>(vrsc);
return rsc->getMessageToClient(data, receiveLen, subID, bufferLen, wait);
}
-void rsContextInitToClient(RsContext vrsc)
-{
+void rsContextInitToClient(RsContext vrsc) {
Context * rsc = static_cast<Context *>(vrsc);
rsc->initToClient();
}
-void rsContextDeinitToClient(RsContext vrsc)
-{
+void rsContextDeinitToClient(RsContext vrsc) {
Context * rsc = static_cast<Context *>(vrsc);
rsc->deinitToClient();
}
// 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)
-{
+void rsaGetName(RsContext con, void * obj, const char **name) {
ObjectBase *ob = static_cast<ObjectBase *>(obj);
(*name) = ob->getName();
}
diff --git a/rsContext.h b/rsContext.h
index 2b9e57a..6945342 100644
--- a/rsContext.h
+++ b/rsContext.h
@@ -51,13 +51,13 @@
#if 0
#define CHECK_OBJ(o) { \
GET_TLS(); \
- if(!ObjectBase::isValid(rsc, (const ObjectBase *)o)) { \
+ if (!ObjectBase::isValid(rsc, (const ObjectBase *)o)) { \
LOGE("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)) { \
+ if (o && !ObjectBase::isValid(rsc, (const ObjectBase *)o)) { \
LOGE("Bad object %p at %s, %i", o, __FILE__, __LINE__); \
} \
}
@@ -66,8 +66,7 @@
#define CHECK_OBJ_OR_NULL(o)
#endif
-class Context
-{
+class Context {
public:
static Context * createContext(Device *, const RsSurfaceConfig *sc);
~Context();
@@ -155,7 +154,6 @@
uint32_t getWidth() const {return mWidth;}
uint32_t getHeight() const {return mHeight;}
-
ThreadIO mIO;
// Timers
diff --git a/rsContextHostStub.h b/rsContextHostStub.h
index ee32b57..aa18bdd 100644
--- a/rsContextHostStub.h
+++ b/rsContextHostStub.h
@@ -44,13 +44,11 @@
// ---------------------------------------------------------------------------
namespace android {
-
namespace renderscript {
class Device;
-class Context
-{
+class Context {
public:
Context(Device *, bool isGraphics, bool useDepth) {
mObjHead = NULL;
diff --git a/rsDevice.cpp b/rsDevice.cpp
index a96b114..dd96445 100644
--- a/rsDevice.cpp
+++ b/rsDevice.cpp
@@ -24,24 +24,18 @@
using namespace android;
using namespace android::renderscript;
-Device::Device()
-{
+Device::Device() {
mForceSW = false;
-
}
-Device::~Device()
-{
-
+Device::~Device() {
}
-void Device::addContext(Context *rsc)
-{
+void Device::addContext(Context *rsc) {
mContexts.push(rsc);
}
-void Device::removeContext(Context *rsc)
-{
+void Device::removeContext(Context *rsc) {
for (size_t idx=0; idx < mContexts.size(); idx++) {
if (mContexts[idx] == rsc) {
mContexts.removeAt(idx);
@@ -50,23 +44,17 @@
}
}
-
-
-RsDevice rsDeviceCreate()
-{
+RsDevice rsDeviceCreate() {
Device * d = new Device();
return d;
}
-void rsDeviceDestroy(RsDevice dev)
-{
+void rsDeviceDestroy(RsDevice dev) {
Device * d = static_cast<Device *>(dev);
delete d;
-
}
-void rsDeviceSetConfig(RsDevice dev, RsDeviceParam p, int32_t value)
-{
+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;
diff --git a/rsDevice.h b/rsDevice.h
index a8a4e77..ffb514b 100644
--- a/rsDevice.h
+++ b/rsDevice.h
@@ -37,14 +37,8 @@
protected:
Vector<Context *> mContexts;
-
-
};
-
-
-
-
}
}
#endif
diff --git a/rsElement.cpp b/rsElement.cpp
index 2ab3729..40321fe 100644
--- a/rsElement.cpp
+++ b/rsElement.cpp
@@ -27,17 +27,14 @@
using namespace android::renderscript;
-Element::Element(Context *rsc) : ObjectBase(rsc)
-{
+Element::Element(Context *rsc) : ObjectBase(rsc) {
mBits = 0;
mFields = NULL;
mFieldCount = 0;
mHasReference = false;
}
-
-Element::~Element()
-{
+Element::~Element() {
for (uint32_t ct = 0; ct < mRSC->mStateElement.mElements.size(); ct++) {
if (mRSC->mStateElement.mElements[ct] == this) {
mRSC->mStateElement.mElements.removeAt(ct);
@@ -47,16 +44,14 @@
clear();
}
-void Element::clear()
-{
+void Element::clear() {
delete [] mFields;
mFields = NULL;
mFieldCount = 0;
mHasReference = false;
}
-size_t Element::getSizeBits() const
-{
+size_t Element::getSizeBits() const {
if (!mFieldCount) {
return mBits;
}
@@ -68,8 +63,7 @@
return total;
}
-void Element::dumpLOGV(const char *prefix) const
-{
+void Element::dumpLOGV(const char *prefix) const {
ObjectBase::dumpLOGV(prefix);
LOGV("%s Element: fieldCount: %i, size bytes: %i", prefix, mFieldCount, getSizeBytes());
for (uint32_t ct = 0; ct < mFieldCount; ct++) {
@@ -80,8 +74,7 @@
}
}
-void Element::serialize(OStream *stream) const
-{
+void Element::serialize(OStream *stream) const {
// Need to identify ourselves
stream->addU32((uint32_t)getClassId());
@@ -92,18 +85,17 @@
// Now serialize all the fields
stream->addU32(mFieldCount);
- for(uint32_t ct = 0; ct < mFieldCount; ct++) {
+ 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)
-{
+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) {
+ if (classID != RS_A3D_CLASS_ID_ELEMENT) {
LOGE("element loading skipped due to invalid class id\n");
return NULL;
}
@@ -115,9 +107,9 @@
elem->mComponent.loadFromStream(stream);
elem->mFieldCount = stream->loadU32();
- if(elem->mFieldCount) {
+ if (elem->mFieldCount) {
elem->mFields = new ElementField_t [elem->mFieldCount];
- for(uint32_t ct = 0; ct < elem->mFieldCount; ct ++) {
+ for (uint32_t ct = 0; ct < elem->mFieldCount; ct ++) {
stream->loadString(&elem->mFields[ct].name);
elem->mFields[ct].arraySize = stream->loadU32();
Element *fieldElem = Element::createFromStream(rsc, stream);
@@ -128,7 +120,7 @@
// We need to check if this already exists
for (uint32_t ct=0; ct < rsc->mStateElement.mElements.size(); ct++) {
Element *ee = rsc->mStateElement.mElements[ct];
- if(ee->isEqual(elem)) {
+ if (ee->isEqual(elem)) {
ObjectBase::checkDelete(elem);
ee->incUserRef();
return ee;
@@ -141,11 +133,11 @@
}
bool Element::isEqual(const Element *other) const {
- if(other == NULL) {
+ if (other == NULL) {
return false;
}
if (!other->getFieldCount() && !mFieldCount) {
- if((other->getType() == getType()) &&
+ if ((other->getType() == getType()) &&
(other->getKind() == getKind()) &&
(other->getComponent().getIsNormalized() == getComponent().getIsNormalized()) &&
(other->getComponent().getVectorSize() == getComponent().getVectorSize())) {
@@ -168,7 +160,7 @@
}
void Element::compute() {
- if(mFieldCount == 0) {
+ if (mFieldCount == 0) {
mBits = mComponent.getBits();
mHasReference = mComponent.isReference();
return;
@@ -187,8 +179,7 @@
}
const Element * Element::create(Context *rsc, RsDataType dt, RsDataKind dk,
- bool isNorm, uint32_t vecSize)
-{
+ bool isNorm, uint32_t vecSize) {
// Look for an existing match.
for (uint32_t ct=0; ct < rsc->mStateElement.mElements.size(); ct++) {
const Element *ee = rsc->mStateElement.mElements[ct];
@@ -211,8 +202,7 @@
}
const Element * Element::create(Context *rsc, size_t count, const Element **ein,
- const char **nin, const size_t * lengths, const uint32_t *asin)
-{
+ const char **nin, const size_t * lengths, const uint32_t *asin) {
// Look for an existing match.
for (uint32_t ct=0; ct < rsc->mStateElement.mElements.size(); ct++) {
const Element *ee = rsc->mStateElement.mElements[ct];
@@ -248,8 +238,7 @@
return e;
}
-String8 Element::getGLSLType(uint32_t indent) const
-{
+String8 Element::getGLSLType(uint32_t indent) const {
String8 s;
for (uint32_t ct=0; ct < indent; ct++) {
s.append(" ");
@@ -267,8 +256,7 @@
return s;
}
-void Element::incRefs(const void *ptr) const
-{
+void Element::incRefs(const void *ptr) const {
if (!mFieldCount) {
if (mComponent.isReference()) {
ObjectBase *const*obp = static_cast<ObjectBase *const*>(ptr);
@@ -290,8 +278,7 @@
}
}
-void Element::decRefs(const void *ptr) const
-{
+void Element::decRefs(const void *ptr) const {
if (!mFieldCount) {
if (mComponent.isReference()) {
ObjectBase *const*obp = static_cast<ObjectBase *const*>(ptr);
@@ -314,8 +301,7 @@
}
-ElementState::ElementState()
-{
+ElementState::ElementState() {
const uint32_t initialCapacity = 32;
mBuilderElements.setCapacity(initialCapacity);
mBuilderNameStrings.setCapacity(initialCapacity);
@@ -323,8 +309,7 @@
mBuilderArrays.setCapacity(initialCapacity);
}
-ElementState::~ElementState()
-{
+ElementState::~ElementState() {
rsAssert(!mElements.size());
}
@@ -362,8 +347,7 @@
RsDataType dt,
RsDataKind dk,
bool norm,
- uint32_t vecSize)
-{
+ uint32_t vecSize) {
//LOGE("rsi_ElementCreate %i %i %i %i", dt, dk, norm, vecSize);
const Element *e = Element::create(rsc, dt, dk, norm, vecSize);
e->incUserRef();
@@ -375,8 +359,7 @@
const RsElement * ein,
const char ** names,
const size_t * nameLengths,
- const uint32_t * arraySizes)
-{
+ const uint32_t * arraySizes) {
//LOGE("rsi_ElementCreate2 %i", count);
const Element *e = Element::create(rsc, count, (const Element **)ein, names, nameLengths, arraySizes);
e->incUserRef();
@@ -386,8 +369,7 @@
}
}
-void rsaElementGetNativeData(RsContext con, RsElement elem, uint32_t *elemData, uint32_t elemDataSize)
-{
+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);
@@ -397,18 +379,15 @@
(*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 dataSize)
-{
+void rsaElementGetSubElements(RsContext con, RsElement elem, uint32_t *ids, const char **names, uint32_t dataSize) {
Element *e = static_cast<Element *>(elem);
rsAssert(e->getFieldCount() == dataSize);
- for(uint32_t i = 0; i < dataSize; i ++) {
+ for (uint32_t i = 0; i < dataSize; i ++) {
e->getField(i)->incUserRef();
ids[i] = (uint32_t)e->getField(i);
names[i] = e->getFieldName(i);
}
-
}
diff --git a/rsElement.h b/rsElement.h
index 506a530..26e2760 100644
--- a/rsElement.h
+++ b/rsElement.h
@@ -25,10 +25,8 @@
namespace android {
namespace renderscript {
-
// An element is a group of Components that occupies one cell in a structure.
-class Element : public ObjectBase
-{
+class Element : public ObjectBase {
public:
~Element();
diff --git a/rsFileA3D.cpp b/rsFileA3D.cpp
index e4c6dbd..0c8692d 100644
--- a/rsFileA3D.cpp
+++ b/rsFileA3D.cpp
@@ -30,8 +30,7 @@
using namespace android;
using namespace android::renderscript;
-FileA3D::FileA3D(Context *rsc) : ObjectBase(rsc)
-{
+FileA3D::FileA3D(Context *rsc) : ObjectBase(rsc) {
mAlloc = NULL;
mData = NULL;
mWriteStream = NULL;
@@ -42,43 +41,40 @@
mDataSize = 0;
}
-FileA3D::~FileA3D()
-{
- for(size_t i = 0; i < mIndex.size(); i ++) {
+FileA3D::~FileA3D() {
+ for (size_t i = 0; i < mIndex.size(); i ++) {
delete mIndex[i];
}
- for(size_t i = 0; i < mWriteIndex.size(); i ++) {
+ for (size_t i = 0; i < mWriteIndex.size(); i ++) {
delete mWriteIndex[i];
}
- if(mWriteStream) {
+ if (mWriteStream) {
delete mWriteStream;
}
- if(mReadStream) {
+ if (mReadStream) {
delete mWriteStream;
}
- if(mAlloc) {
+ if (mAlloc) {
free(mAlloc);
}
}
-void FileA3D::parseHeader(IStream *headerStream)
-{
+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 ++) {
+ for (uint32_t i = 0; i < numIndexEntries; i ++) {
A3DIndexEntry *entry = new A3DIndexEntry();
headerStream->loadString(&entry->mObjectName);
LOGV("Header data, entry name = %s", entry->mObjectName.string());
entry->mType = (RsA3DClassID)headerStream->loadU32();
- if(mUse64BitOffsets){
+ if (mUse64BitOffsets){
entry->mOffset = headerStream->loadOffset();
entry->mLength = headerStream->loadOffset();
- }
- else {
+ } else {
entry->mOffset = headerStream->loadU32();
entry->mLength = headerStream->loadU32();
}
@@ -87,8 +83,7 @@
}
}
-bool FileA3D::load(const void *data, size_t length)
-{
+bool FileA3D::load(const void *data, size_t length) {
const uint8_t *localData = (const uint8_t *)data;
size_t lengthRemaining = length;
@@ -103,7 +98,7 @@
// Next we get our header size
uint64_t headerSize = 0;
- if(lengthRemaining < sizeof(headerSize)) {
+ if (lengthRemaining < sizeof(headerSize)) {
return false;
}
@@ -111,7 +106,7 @@
localData += sizeof(headerSize);
lengthRemaining -= sizeof(headerSize);
- if(lengthRemaining < headerSize) {
+ if (lengthRemaining < headerSize) {
return false;
}
@@ -122,7 +117,7 @@
localData += headerSize;
lengthRemaining -= headerSize;
- if(lengthRemaining < sizeof(mDataSize)) {
+ if (lengthRemaining < sizeof(mDataSize)) {
return false;
}
@@ -131,7 +126,7 @@
localData += sizeof(mDataSize);
lengthRemaining -= sizeof(mDataSize);
- if(lengthRemaining < mDataSize) {
+ if (lengthRemaining < mDataSize) {
return false;
}
@@ -142,8 +137,7 @@
return true;
}
-bool FileA3D::load(FILE *f)
-{
+bool FileA3D::load(FILE *f) {
char magicString[12];
size_t len;
@@ -162,7 +156,7 @@
}
uint8_t *headerData = (uint8_t *)malloc(headerSize);
- if(!headerData) {
+ if (!headerData) {
return false;
}
@@ -207,23 +201,23 @@
}
const FileA3D::A3DIndexEntry *FileA3D::getIndexEntry(size_t index) const {
- if(index < mIndex.size()) {
+ if (index < mIndex.size()) {
return mIndex[index];
}
return NULL;
}
ObjectBase *FileA3D::initializeFromEntry(size_t index) {
- if(index >= mIndex.size()) {
+ if (index >= mIndex.size()) {
return NULL;
}
FileA3D::A3DIndexEntry *entry = mIndex[index];
- if(!entry) {
+ if (!entry) {
return NULL;
}
- if(entry->mRsObj) {
+ if (entry->mRsObj) {
entry->mRsObj->incUserRef();
return entry->mRsObj;
}
@@ -272,25 +266,24 @@
case RS_A3D_CLASS_ID_SCRIPT_C:
return NULL;
}
- if(entry->mRsObj) {
+ if (entry->mRsObj) {
entry->mRsObj->incUserRef();
}
return entry->mRsObj;
}
-bool FileA3D::writeFile(const char *filename)
-{
- if(!mWriteStream) {
+bool FileA3D::writeFile(const char *filename) {
+ if (!mWriteStream) {
LOGE("No objects to write\n");
return false;
}
- if(mWriteStream->getPos() == 0) {
+ if (mWriteStream->getPos() == 0) {
LOGE("No objects to write\n");
return false;
}
FILE *writeHandle = fopen(filename, "wb");
- if(!writeHandle) {
+ if (!writeHandle) {
LOGE("Couldn't open the file for writing\n");
return false;
}
@@ -304,14 +297,13 @@
uint32_t writeIndexSize = mWriteIndex.size();
headerStream.addU32(writeIndexSize);
- for(uint32_t i = 0; i < writeIndexSize; i ++) {
+ for (uint32_t i = 0; i < writeIndexSize; i ++) {
headerStream.addString(&mWriteIndex[i]->mObjectName);
headerStream.addU32((uint32_t)mWriteIndex[i]->mType);
- if(mUse64BitOffsets){
+ if (mUse64BitOffsets){
headerStream.addOffset(mWriteIndex[i]->mOffset);
headerStream.addOffset(mWriteIndex[i]->mLength);
- }
- else {
+ } else {
uint32_t offset = (uint32_t)mWriteIndex[i]->mOffset;
headerStream.addU32(offset);
offset = (uint32_t)mWriteIndex[i]->mLength;
@@ -338,7 +330,7 @@
int status = fclose(writeHandle);
- if(status != 0) {
+ if (status != 0) {
LOGE("Couldn't close file\n");
return false;
}
@@ -347,10 +339,10 @@
}
void FileA3D::appendToFile(ObjectBase *obj) {
- if(!obj) {
+ if (!obj) {
return;
}
- if(!mWriteStream) {
+ if (!mWriteStream) {
const uint64_t initialStreamSize = 256*1024;
mWriteStream = new OStream(initialStreamSize, false);
}
@@ -368,8 +360,7 @@
namespace android {
namespace renderscript {
-RsFile rsi_FileOpen(Context *rsc, char const *path, unsigned int len)
-{
+RsFile rsi_FileOpen(Context *rsc, char const *path, unsigned int len) {
FileA3D *fa3d = new FileA3D(rsc);
FILE *f = fopen("/sdcard/test.a3d", "rb");
@@ -383,14 +374,12 @@
return NULL;
}
-
}
}
-RsObjectBase rsaFileA3DGetEntryByIndex(RsContext con, uint32_t index, RsFile file)
-{
+RsObjectBase rsaFileA3DGetEntryByIndex(RsContext con, uint32_t index, RsFile file) {
FileA3D *fa3d = static_cast<FileA3D *>(file);
- if(!fa3d) {
+ if (!fa3d) {
LOGE("Can't load entry. No valid file");
return NULL;
}
@@ -402,43 +391,38 @@
}
-void rsaFileA3DGetNumIndexEntries(RsContext con, int32_t *numEntries, RsFile file)
-{
+void rsaFileA3DGetNumIndexEntries(RsContext con, int32_t *numEntries, RsFile file) {
FileA3D *fa3d = static_cast<FileA3D *>(file);
- if(fa3d) {
+ if (fa3d) {
*numEntries = fa3d->getNumIndexEntries();
- }
- else {
+ } else {
*numEntries = 0;
}
}
-void rsaFileA3DGetIndexEntries(RsContext con, RsFileIndexEntry *fileEntries, uint32_t numEntries, RsFile file)
-{
+void rsaFileA3DGetIndexEntries(RsContext con, RsFileIndexEntry *fileEntries, uint32_t numEntries, RsFile file) {
FileA3D *fa3d = static_cast<FileA3D *>(file);
- if(!fa3d) {
+ if (!fa3d) {
LOGE("Can't load index entries. No valid file");
return;
}
uint32_t numFileEntries = fa3d->getNumIndexEntries();
- if(numFileEntries != numEntries || numEntries == 0 || fileEntries == NULL) {
+ if (numFileEntries != numEntries || numEntries == 0 || fileEntries == NULL) {
LOGE("Can't load index entries. Invalid number requested");
return;
}
- for(uint32_t i = 0; i < numFileEntries; i ++) {
+ 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 rsaFileA3DCreateFromAssetStream(RsContext con, const void *data, uint32_t len)
-{
+RsFile rsaFileA3DCreateFromAssetStream(RsContext con, const void *data, uint32_t len) {
if (data == NULL) {
LOGE("File load failed. Asset stream is NULL");
return NULL;
diff --git a/rsFileA3D.h b/rsFileA3D.h
index b985907..3ece4c9 100644
--- a/rsFileA3D.h
+++ b/rsFileA3D.h
@@ -31,8 +31,7 @@
namespace renderscript {
-class FileA3D : public ObjectBase
-{
+class FileA3D : public ObjectBase {
public:
FileA3D(Context *rsc);
~FileA3D();
diff --git a/rsFont.cpp b/rsFont.cpp
index 66f455c..33b0f51 100644
--- a/rsFont.cpp
+++ b/rsFont.cpp
@@ -34,16 +34,14 @@
using namespace android;
using namespace android::renderscript;
-Font::Font(Context *rsc) : ObjectBase(rsc), mCachedGlyphs(NULL)
-{
+Font::Font(Context *rsc) : ObjectBase(rsc), mCachedGlyphs(NULL) {
mInitialized = false;
mHasKerning = false;
mFace = NULL;
}
-bool Font::init(const char *name, uint32_t fontSize, uint32_t dpi)
-{
- if(mInitialized) {
+bool Font::init(const char *name, uint32_t fontSize, uint32_t dpi) {
+ if (mInitialized) {
LOGE("Reinitialization of fonts not supported");
return false;
}
@@ -54,7 +52,7 @@
fullPath += name;
FT_Error error = FT_New_Face(mRSC->mStateFont.getLib(), fullPath.string(), 0, &mFace);
- if(error) {
+ if (error) {
LOGE("Unable to initialize font %s", fullPath.string());
return false;
}
@@ -64,7 +62,7 @@
mDpi = dpi;
error = FT_Set_Char_Size(mFace, fontSize * 64, 0, dpi, 0);
- if(error) {
+ if (error) {
LOGE("Unable to set font size on %s", fullPath.string());
return false;
}
@@ -75,15 +73,13 @@
return true;
}
-void Font::invalidateTextureCache()
-{
- for(uint32_t i = 0; i < mCachedGlyphs.size(); i ++) {
+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)
-{
+void Font::drawCachedGlyph(CachedGlyphInfo *glyph, int32_t x, int32_t y) {
FontState *state = &mRSC->mStateFont;
int32_t nPenX = x + glyph->mBitmapLeft;
@@ -127,7 +123,6 @@
bitmap[bY * bitmapW + bX] = tempCol;
}
}
-
}
void Font::measureCachedGlyph(CachedGlyphInfo *glyph, int32_t x, int32_t y, Rect *bounds) {
@@ -154,13 +149,12 @@
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) {
+ uint8_t *bitmap, uint32_t bitmapW, uint32_t bitmapH) {
+ if (!mInitialized || numGlyphs == 0 || text == NULL || len == 0) {
return;
}
- if(mode == Font::MEASURE) {
+ if (mode == Font::MEASURE) {
if (bounds == NULL) {
LOGE("No return rectangle provided to measure text");
return;
@@ -171,7 +165,7 @@
int32_t penX = x, penY = y;
int32_t glyphsLeft = 1;
- if(numGlyphs > 0) {
+ if (numGlyphs > 0) {
glyphsLeft = numGlyphs;
}
@@ -183,7 +177,7 @@
int32_t utfChar = utf32_at(text, len, index, &nextIndex);
// Reached the end of the string or encountered
- if(utfChar < 0) {
+ if (utfChar < 0) {
break;
}
@@ -193,8 +187,8 @@
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) {
+ if (cachedGlyph->mIsValid) {
+ switch (mode) {
case FRAMEBUFFER:
drawCachedGlyph(cachedGlyph, penX, penY);
break;
@@ -210,7 +204,7 @@
penX += (cachedGlyph->mAdvance.x >> 6);
// If we were given a specific number of glyphs, decrement
- if(numGlyphs > 0) {
+ if (numGlyphs > 0) {
glyphsLeft --;
}
}
@@ -219,21 +213,20 @@
Font::CachedGlyphInfo* Font::getCachedUTFChar(int32_t utfChar) {
CachedGlyphInfo *cachedGlyph = mCachedGlyphs.valueFor((uint32_t)utfChar);
- if(cachedGlyph == NULL) {
+ if (cachedGlyph == NULL) {
cachedGlyph = cacheGlyph((uint32_t)utfChar);
}
// Is the glyph still in texture cache?
- if(!cachedGlyph->mIsValid) {
+ if (!cachedGlyph->mIsValid) {
updateGlyphCache(cachedGlyph);
}
return cachedGlyph;
}
-void Font::updateGlyphCache(CachedGlyphInfo *glyph)
-{
+void Font::updateGlyphCache(CachedGlyphInfo *glyph) {
FT_Error error = FT_Load_Glyph( mFace, glyph->mGlyphIndex, FT_LOAD_RENDER );
- if(error) {
+ if (error) {
LOGE("Couldn't load glyph.");
return;
}
@@ -252,7 +245,7 @@
FontState *state = &mRSC->mStateFont;
glyph->mIsValid = state->cacheBitmap(bitmap, &startX, &startY);
- if(!glyph->mIsValid) {
+ if (!glyph->mIsValid) {
return;
}
@@ -273,8 +266,7 @@
glyph->mBitmapMaxV = (float)endY / (float)cacheHeight;
}
-Font::CachedGlyphInfo *Font::cacheGlyph(uint32_t glyph)
-{
+Font::CachedGlyphInfo *Font::cacheGlyph(uint32_t glyph) {
CachedGlyphInfo *newGlyph = new CachedGlyphInfo();
mCachedGlyphs.add(glyph, newGlyph);
@@ -286,21 +278,20 @@
return newGlyph;
}
-Font * Font::create(Context *rsc, const char *name, uint32_t fontSize, uint32_t dpi)
-{
+Font * Font::create(Context *rsc, const char *name, uint32_t fontSize, uint32_t dpi) {
rsc->mStateFont.checkInit();
Vector<Font*> &activeFonts = rsc->mStateFont.mActiveFonts;
- for(uint32_t i = 0; i < activeFonts.size(); i ++) {
+ for (uint32_t i = 0; i < activeFonts.size(); i ++) {
Font *ithFont = activeFonts[i];
- if(ithFont->mFontName == name && ithFont->mFontSize == fontSize && ithFont->mDpi == dpi) {
+ if (ithFont->mFontName == name && ithFont->mFontSize == fontSize && ithFont->mDpi == dpi) {
return ithFont;
}
}
Font *newFont = new Font(rsc);
bool isInitialized = newFont->init(name, fontSize, dpi);
- if(isInitialized) {
+ if (isInitialized) {
activeFonts.push(newFont);
rsc->mStateFont.precacheLatin(newFont);
return newFont;
@@ -308,12 +299,10 @@
ObjectBase::checkDelete(newFont);
return NULL;
-
}
-Font::~Font()
-{
- if(mFace) {
+Font::~Font() {
+ if (mFace) {
FT_Done_Face(mFace);
}
@@ -324,14 +313,13 @@
}
}
- for(uint32_t i = 0; i < mCachedGlyphs.size(); i ++) {
+ for (uint32_t i = 0; i < mCachedGlyphs.size(); i ++) {
CachedGlyphInfo *glyph = mCachedGlyphs.valueAt(i);
delete glyph;
}
}
-FontState::FontState()
-{
+FontState::FontState() {
mInitialized = false;
mMaxNumberOfQuads = 1024;
mCurrentQuadIndex = 0;
@@ -379,20 +367,18 @@
setFontColor(0.1f, 0.1f, 0.1f, 1.0f);
}
-FontState::~FontState()
-{
- for(uint32_t i = 0; i < mCacheLines.size(); i ++) {
+FontState::~FontState() {
+ for (uint32_t i = 0; i < mCacheLines.size(); i ++) {
delete mCacheLines[i];
}
rsAssert(!mActiveFonts.size());
}
-FT_Library FontState::getLib()
-{
- if(!mLibrary) {
+FT_Library FontState::getLib() {
+ if (!mLibrary) {
FT_Error error = FT_Init_FreeType(&mLibrary);
- if(error) {
+ if (error) {
LOGE("Unable to initialize freetype");
return NULL;
}
@@ -401,29 +387,26 @@
return mLibrary;
}
-void FontState::init(Context *rsc)
-{
+void FontState::init(Context *rsc) {
mRSC = rsc;
}
-void FontState::flushAllAndInvalidate()
-{
- if(mCurrentQuadIndex != 0) {
+void FontState::flushAllAndInvalidate() {
+ if (mCurrentQuadIndex != 0) {
issueDrawCommand();
mCurrentQuadIndex = 0;
}
- for(uint32_t i = 0; i < mActiveFonts.size(); i ++) {
+ for (uint32_t i = 0; i < mActiveFonts.size(); i ++) {
mActiveFonts[i]->invalidateTextureCache();
}
- for(uint32_t i = 0; i < mCacheLines.size(); i ++) {
+ for (uint32_t i = 0; i < mCacheLines.size(); i ++) {
mCacheLines[i]->mCurrentCol = 0;
}
}
-bool FontState::cacheBitmap(FT_Bitmap *bitmap, uint32_t *retOriginX, uint32_t *retOriginY)
-{
+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) {
+ if ((uint32_t)bitmap->rows > mCacheLines[mCacheLines.size()-1]->mMaxHeight) {
LOGE("Font size to large to fit in cache. width, height = %i, %i", (int)bitmap->width, (int)bitmap->rows);
return false;
}
@@ -433,27 +416,27 @@
uint32_t startY = 0;
bool bitmapFit = false;
- for(uint32_t i = 0; i < mCacheLines.size(); i ++) {
+ for (uint32_t i = 0; i < mCacheLines.size(); i ++) {
bitmapFit = mCacheLines[i]->fitBitmap(bitmap, &startX, &startY);
- if(bitmapFit) {
+ if (bitmapFit) {
break;
}
}
// If the new glyph didn't fit, flush the state so far and invalidate everything
- if(!bitmapFit) {
+ if (!bitmapFit) {
flushAllAndInvalidate();
// Try to fit it again
- for(uint32_t i = 0; i < mCacheLines.size(); i ++) {
+ for (uint32_t i = 0; i < mCacheLines.size(); i ++) {
bitmapFit = mCacheLines[i]->fitBitmap(bitmap, &startX, &startY);
- if(bitmapFit) {
+ if (bitmapFit) {
break;
}
}
// if we still don't fit, something is wrong and we shouldn't draw
- if(!bitmapFit) {
+ if (!bitmapFit) {
LOGE("Bitmap doesn't fit in cache. width, height = %i, %i", (int)bitmap->width, (int)bitmap->rows);
return false;
}
@@ -471,8 +454,8 @@
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 ++) {
+ 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;
}
@@ -484,7 +467,7 @@
mFontShaderF->bindTexture(mRSC, 0, mTextTexture.get());
// Some debug code
- /*for(uint32_t i = 0; i < mCacheLines.size(); i ++) {
+ /*for (uint32_t i = 0; i < mCacheLines.size(); i ++) {
LOGE("Cache Line: H: %u Empty Space: %f",
mCacheLines[i]->mMaxHeight,
(1.0f - (float)mCacheLines[i]->mCurrentCol/(float)mCacheLines[i]->mMaxWidth)*100.0f);
@@ -494,8 +477,7 @@
return true;
}
-void FontState::initRenderState()
-{
+void FontState::initRenderState() {
String8 shaderString("varying vec2 varTex0;\n");
shaderString.append("void main() {\n");
shaderString.append(" lowp vec4 col = UNI_Color;\n");
@@ -538,8 +520,7 @@
mFontProgramStore->setDepthMask(false);
}
-void FontState::initTextTexture()
-{
+void FontState::initTextTexture() {
const Element *alphaElem = Element::create(mRSC, RS_TYPE_UNSIGNED_8, RS_KIND_PIXEL_A, true, 1);
// We will allocate a texture to initially hold 32 character bitmaps
@@ -567,8 +548,7 @@
}
// Avoid having to reallocate memory and render quad by quad
-void FontState::initVertexArrayBuffers()
-{
+void FontState::initVertexArrayBuffers() {
// Now lets write index data
const Element *indexElem = Element::create(mRSC, RS_TYPE_UNSIGNED_16, RS_KIND_USER, false, 1);
uint32_t numIndicies = mMaxNumberOfQuads * 6;
@@ -578,7 +558,7 @@
uint16_t *indexPtr = (uint16_t*)indexAlloc->getPtr();
// Four verts, two triangles , six indices per quad
- for(uint32_t i = 0; i < mMaxNumberOfQuads; i ++) {
+ for (uint32_t i = 0; i < mMaxNumberOfQuads; i ++) {
int32_t i6 = i * 6;
int32_t i4 = i * 4;
@@ -613,9 +593,8 @@
}
// We don't want to allocate anything unless we actually draw text
-void FontState::checkInit()
-{
- if(mInitialized) {
+void FontState::checkInit() {
+ if (mInitialized) {
return;
}
@@ -647,7 +626,7 @@
ObjectBaseRef<const ProgramStore> tmpPS(mRSC->getFragmentStore());
mRSC->setFragmentStore(mFontProgramStore.get());
- if(mConstantsDirty) {
+ if (mConstantsDirty) {
mFontShaderFConstant->data(mRSC, &mConstants, sizeof(mConstants));
mConstantsDirty = false;
}
@@ -681,14 +660,13 @@
}
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)
-{
+ 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 = 5;
float *currentPos = mTextMeshPtr + mCurrentQuadIndex * vertsPerQuad * floatsPerVert;
@@ -697,7 +675,7 @@
float width = (float)mRSC->getWidth();
float height = (float)mRSC->getHeight();
- if(x1 > width || y1 < 0.0f || x2 < 0 || y4 > height) {
+ if (x1 > width || y1 < 0.0f || x2 < 0 || y4 > height) {
return;
}
@@ -732,7 +710,7 @@
mCurrentQuadIndex ++;
- if(mCurrentQuadIndex == mMaxNumberOfQuads) {
+ if (mCurrentQuadIndex == mMaxNumberOfQuads) {
issueDrawCommand();
mCurrentQuadIndex = 0;
}
@@ -741,7 +719,7 @@
uint32_t FontState::getRemainingCacheCapacity() {
uint32_t remainingCapacity = 0;
uint32_t totalPixels = 0;
- for(uint32_t i = 0; i < mCacheLines.size(); i ++) {
+ for (uint32_t i = 0; i < mCacheLines.size(); i ++) {
remainingCapacity += (mCacheLines[i]->mMaxWidth - mCacheLines[i]->mCurrentCol);
totalPixels += mCacheLines[i]->mMaxWidth;
}
@@ -753,7 +731,7 @@
// Remaining capacity is measured in %
uint32_t remainingCapacity = getRemainingCacheCapacity();
uint32_t precacheIdx = 0;
- while(remainingCapacity > 25 && precacheIdx < mLatinPrecache.size()) {
+ while (remainingCapacity > 25 && precacheIdx < mLatinPrecache.size()) {
font->getCachedUTFChar((int32_t)mLatinPrecache[precacheIdx]);
remainingCapacity = getRemainingCacheCapacity();
precacheIdx ++;
@@ -765,19 +743,18 @@
uint32_t startIndex, int32_t numGlyphs,
Font::RenderMode mode,
Font::Rect *bounds,
- uint8_t *bitmap, uint32_t bitmapW, uint32_t bitmapH)
-{
+ uint8_t *bitmap, uint32_t bitmapW, uint32_t bitmapH) {
checkInit();
// Render code here
Font *currentFont = mRSC->getFont();
- if(!currentFont) {
- if(!mDefault.get()) {
+ if (!currentFont) {
+ if (!mDefault.get()) {
mDefault.set(Font::create(mRSC, "DroidSans.ttf", 16, 96));
}
currentFont = mDefault.get();
}
- if(!currentFont) {
+ if (!currentFont) {
LOGE("Unable to initialize any fonts");
return;
}
@@ -785,7 +762,7 @@
currentFont->renderUTF(text, len, x, y, startIndex, numGlyphs,
mode, bounds, bitmap, bitmapW, bitmapH);
- if(mCurrentQuadIndex != 0) {
+ if (mCurrentQuadIndex != 0) {
issueDrawCommand();
mCurrentQuadIndex = 0;
}
@@ -819,8 +796,7 @@
*a = mConstants.mFontColor[3];
}
-void FontState::deinit(Context *rsc)
-{
+void FontState::deinit(Context *rsc) {
mInitialized = false;
mFontShaderFConstant.clear();
@@ -833,7 +809,7 @@
mFontProgramStore.clear();
mTextTexture.clear();
- for(uint32_t i = 0; i < mCacheLines.size(); i ++) {
+ for (uint32_t i = 0; i < mCacheLines.size(); i ++) {
delete mCacheLines[i];
}
mCacheLines.clear();
@@ -841,11 +817,11 @@
mDefault.clear();
Vector<Font*> fontsToDereference = mActiveFonts;
- for(uint32_t i = 0; i < fontsToDereference.size(); i ++) {
+ for (uint32_t i = 0; i < fontsToDereference.size(); i ++) {
fontsToDereference[i]->zeroUserRef();
}
- if(mLibrary) {
+ if (mLibrary) {
FT_Done_FreeType( mLibrary );
mLibrary = NULL;
}
@@ -854,10 +830,9 @@
namespace android {
namespace renderscript {
-RsFont rsi_FontCreateFromFile(Context *rsc, char const *name, uint32_t fontSize, uint32_t dpi)
-{
+RsFont rsi_FontCreateFromFile(Context *rsc, char const *name, uint32_t fontSize, uint32_t dpi) {
Font *newFont = Font::create(rsc, name, fontSize, dpi);
- if(newFont) {
+ if (newFont) {
newFont->incUserRef();
}
return newFont;
diff --git a/rsFont.h b/rsFont.h
index 0012b84..0f6815d 100644
--- a/rsFont.h
+++ b/rsFont.h
@@ -42,8 +42,7 @@
class FontState;
-class Font : public ObjectBase
-{
+class Font : public ObjectBase {
public:
enum RenderMode {
FRAMEBUFFER,
@@ -134,8 +133,7 @@
uint8_t *bitmap, uint32_t bitmapW, uint32_t bitmapH);
};
-class FontState
-{
+class FontState {
public:
FontState();
~FontState();
@@ -161,29 +159,28 @@
friend class Font;
- struct CacheTextureLine
- {
+ 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) {
+ 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) {
- if((uint32_t)bitmap->rows > mMaxHeight) {
+ if ((uint32_t)bitmap->rows > mMaxHeight) {
return false;
}
- if(mCurrentCol + (uint32_t)bitmap->width < mMaxWidth) {
- *retOriginX = mCurrentCol;
- *retOriginY = mCurrentRow;
- mCurrentCol += bitmap->width;
- mDirty = true;
+ if (mCurrentCol + (uint32_t)bitmap->width < mMaxWidth) {
+ *retOriginX = mCurrentCol;
+ *retOriginY = mCurrentRow;
+ mCurrentCol += bitmap->width;
+ mDirty = true;
return true;
}
@@ -254,17 +251,15 @@
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);
-
+ 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);
};
-
}
}
diff --git a/rsHandcode.h b/rsHandcode.h
index c02fd42..122a9ed 100644
--- a/rsHandcode.h
+++ b/rsHandcode.h
@@ -1,16 +1,14 @@
#define DATA_SYNC_SIZE 1024
-static inline void rsHCAPI_ContextFinish (RsContext rsc)
-{
+static inline void rsHCAPI_ContextFinish (RsContext rsc) {
ThreadIO *io = &((Context *)rsc)->mIO;
uint32_t size = sizeof(RS_CMD_ContextFinish);
RS_CMD_ContextFinish *cmd = static_cast<RS_CMD_ContextFinish *>(io->mToCore.reserve(size));
io->mToCore.commitSync(RS_CMD_ID_ContextFinish, size);
}
-static inline void rsHCAPI_ScriptInvokeV (RsContext rsc, RsScript va, uint32_t slot, const void * data, uint32_t sizeBytes)
-{
+static inline void rsHCAPI_ScriptInvokeV (RsContext rsc, RsScript va, uint32_t slot, const void * data, uint32_t sizeBytes) {
ThreadIO *io = &((Context *)rsc)->mIO;
uint32_t size = sizeof(RS_CMD_ScriptInvokeV);
if (sizeBytes < DATA_SYNC_SIZE) {
@@ -31,8 +29,7 @@
}
-static inline void rsHCAPI_ScriptSetVarV (RsContext rsc, RsScript va, uint32_t slot, const void * data, uint32_t sizeBytes)
-{
+static inline void rsHCAPI_ScriptSetVarV (RsContext rsc, RsScript va, uint32_t slot, const void * data, uint32_t sizeBytes) {
ThreadIO *io = &((Context *)rsc)->mIO;
uint32_t size = sizeof(RS_CMD_ScriptSetVarV);
if (sizeBytes < DATA_SYNC_SIZE) {
@@ -52,8 +49,7 @@
}
}
-static inline void rsHCAPI_AllocationData (RsContext rsc, RsAllocation va, const void * data, uint32_t sizeBytes)
-{
+static inline void rsHCAPI_AllocationData (RsContext rsc, RsAllocation va, const void * data, uint32_t sizeBytes) {
ThreadIO *io = &((Context *)rsc)->mIO;
uint32_t size = sizeof(RS_CMD_AllocationData);
if (sizeBytes < DATA_SYNC_SIZE) {
@@ -72,9 +68,7 @@
}
}
-
-static inline void rsHCAPI_Allocation1DSubData (RsContext rsc, RsAllocation va, uint32_t xoff, uint32_t count, const void * data, uint32_t sizeBytes)
-{
+static inline void rsHCAPI_Allocation1DSubData (RsContext rsc, RsAllocation va, uint32_t xoff, uint32_t count, const void * data, uint32_t sizeBytes) {
ThreadIO *io = &((Context *)rsc)->mIO;
uint32_t size = sizeof(RS_CMD_Allocation1DSubData);
if (sizeBytes < DATA_SYNC_SIZE) {
@@ -93,11 +87,9 @@
} else {
io->mToCore.commitSync(RS_CMD_ID_Allocation1DSubData, size);
}
-
}
-static inline void rsHCAPI_Allocation1DSubElementData (RsContext rsc, RsAllocation va, uint32_t x, const void * data, uint32_t comp_offset, uint32_t sizeBytes)
-{
+static inline void rsHCAPI_Allocation1DSubElementData (RsContext rsc, RsAllocation va, uint32_t x, const void * data, uint32_t comp_offset, uint32_t sizeBytes) {
ThreadIO *io = &((Context *)rsc)->mIO;
uint32_t size = sizeof(RS_CMD_Allocation1DSubElementData);
if (sizeBytes < DATA_SYNC_SIZE) {
@@ -116,6 +108,5 @@
} else {
io->mToCore.commitSync(RS_CMD_ID_Allocation1DSubElementData, size);
}
-
}
diff --git a/rsLocklessFifo.cpp b/rsLocklessFifo.cpp
index 10b38af..e87525e 100644
--- a/rsLocklessFifo.cpp
+++ b/rsLocklessFifo.cpp
@@ -21,26 +21,22 @@
using namespace android;
using namespace android::renderscript;
-LocklessCommandFifo::LocklessCommandFifo()
-{
+LocklessCommandFifo::LocklessCommandFifo() {
}
-LocklessCommandFifo::~LocklessCommandFifo()
-{
+LocklessCommandFifo::~LocklessCommandFifo() {
if (!mInShutdown) {
shutdown();
}
free(mBuffer);
}
-void LocklessCommandFifo::shutdown()
-{
+void LocklessCommandFifo::shutdown() {
mInShutdown = true;
mSignalToWorker.set();
}
-bool LocklessCommandFifo::init(uint32_t sizeInBytes)
-{
+bool LocklessCommandFifo::init(uint32_t sizeInBytes) {
// Add room for a buffer reset command
mBuffer = static_cast<uint8_t *>(malloc(sizeInBytes + 4));
if (!mBuffer) {
@@ -63,8 +59,7 @@
return true;
}
-uint32_t LocklessCommandFifo::getFreeSpace() const
-{
+uint32_t LocklessCommandFifo::getFreeSpace() const {
int32_t freeSpace = 0;
//dumpState("getFreeSpace");
@@ -80,14 +75,12 @@
return freeSpace;
}
-bool LocklessCommandFifo::isEmpty() const
-{
+bool LocklessCommandFifo::isEmpty() const {
return mPut == mGet;
}
-void * LocklessCommandFifo::reserve(uint32_t sizeInBytes)
-{
+void * LocklessCommandFifo::reserve(uint32_t sizeInBytes) {
// Add space for command header and loop token;
sizeInBytes += 8;
@@ -99,8 +92,7 @@
return mPut + 4;
}
-void LocklessCommandFifo::commit(uint32_t command, uint32_t sizeInBytes)
-{
+void LocklessCommandFifo::commit(uint32_t command, uint32_t sizeInBytes) {
if (mInShutdown) {
return;
}
@@ -112,8 +104,7 @@
mSignalToWorker.set();
}
-void LocklessCommandFifo::commitSync(uint32_t command, uint32_t sizeInBytes)
-{
+void LocklessCommandFifo::commitSync(uint32_t command, uint32_t sizeInBytes) {
if (mInShutdown) {
return;
}
@@ -125,26 +116,23 @@
flush();
}
-void LocklessCommandFifo::flush()
-{
+void LocklessCommandFifo::flush() {
//dumpState("flush 1");
- while(mPut != mGet) {
+ while (mPut != mGet) {
mSignalToControl.wait();
}
//dumpState("flush 2");
}
-void LocklessCommandFifo::wait()
-{
- while(isEmpty() && !mInShutdown) {
+void LocklessCommandFifo::wait() {
+ while (isEmpty() && !mInShutdown) {
mSignalToControl.set();
mSignalToWorker.wait();
}
}
-const void * LocklessCommandFifo::get(uint32_t *command, uint32_t *bytesData)
-{
- while(1) {
+const void * LocklessCommandFifo::get(uint32_t *command, uint32_t *bytesData) {
+ while (1) {
//dumpState("get");
wait();
if (mInShutdown) {
@@ -165,8 +153,7 @@
}
}
-void LocklessCommandFifo::next()
-{
+void LocklessCommandFifo::next() {
uint32_t bytes = reinterpret_cast<const uint16_t *>(mGet)[1];
mGet += ((bytes + 3) & ~3) + 4;
if (isEmpty()) {
@@ -175,12 +162,11 @@
//dumpState("next");
}
-bool LocklessCommandFifo::makeSpaceNonBlocking(uint32_t bytes)
-{
+bool LocklessCommandFifo::makeSpaceNonBlocking(uint32_t bytes) {
//dumpState("make space non-blocking");
if ((mPut+bytes) > mEnd) {
// Need to loop regardless of where get is.
- if((mGet > mPut) && (mBuffer+4 >= mGet)) {
+ if ((mGet > mPut) && (mBuffer+4 >= mGet)) {
return false;
}
@@ -192,19 +178,18 @@
}
// it will fit here so we just need to wait for space.
- if(getFreeSpace() < bytes) {
+ if (getFreeSpace() < bytes) {
return false;
}
return true;
}
-void LocklessCommandFifo::makeSpace(uint32_t bytes)
-{
+void LocklessCommandFifo::makeSpace(uint32_t bytes) {
//dumpState("make space");
if ((mPut+bytes) > mEnd) {
// Need to loop regardless of where get is.
- while((mGet > mPut) && (mBuffer+4 >= mGet)) {
+ while ((mGet > mPut) && (mBuffer+4 >= mGet)) {
usleep(100);
}
@@ -216,14 +201,13 @@
}
// it will fit here so we just need to wait for space.
- while(getFreeSpace() < bytes) {
+ while (getFreeSpace() < bytes) {
usleep(100);
}
}
-void LocklessCommandFifo::dumpState(const char *s) const
-{
+void LocklessCommandFifo::dumpState(const char *s) const {
LOGV("%s %p put %p, get %p, buf %p, end %p", s, this, mPut, mGet, mBuffer, mEnd);
}
diff --git a/rsLocklessFifo.h b/rsLocklessFifo.h
index b8ceeed..c963963 100644
--- a/rsLocklessFifo.h
+++ b/rsLocklessFifo.h
@@ -30,8 +30,7 @@
// will not require locking. It is not threadsafe for multiple
// readers or writers by design.
-class LocklessCommandFifo
-{
+class LocklessCommandFifo {
public:
bool init(uint32_t size);
void shutdown();
@@ -67,7 +66,6 @@
bool isEmpty() const;
uint32_t getFreeSpace() const;
-
private:
void dumpState(const char *) const;
};
diff --git a/rsMatrix.cpp b/rsMatrix.cpp
index 94eef13..ca41886 100644
--- a/rsMatrix.cpp
+++ b/rsMatrix.cpp
@@ -23,10 +23,7 @@
using namespace android;
using namespace android::renderscript;
-
-
-void Matrix::loadIdentity()
-{
+void Matrix::loadIdentity() {
set(0, 0, 1);
set(1, 0, 0);
set(2, 0, 0);
@@ -48,18 +45,15 @@
set(3, 3, 1);
}
-void Matrix::load(const float *v)
-{
+void Matrix::load(const float *v) {
memcpy(m, v, sizeof(m));
}
-void Matrix::load(const Matrix *v)
-{
+void Matrix::load(const Matrix *v) {
memcpy(m, v->m, sizeof(m));
}
-void Matrix::loadRotate(float rot, float x, float y, float z)
-{
+void Matrix::loadRotate(float rot, float x, float y, float z) {
float c, s;
m[3] = 0;
m[7] = 0;
@@ -97,24 +91,21 @@
m[10] = z*z*nc + c;
}
-void Matrix::loadScale(float x, float y, float z)
-{
+void Matrix::loadScale(float x, float y, float z) {
loadIdentity();
m[0] = x;
m[5] = y;
m[10] = z;
}
-void Matrix::loadTranslate(float x, float y, float z)
-{
+void Matrix::loadTranslate(float x, float y, float z) {
loadIdentity();
m[12] = x;
m[13] = y;
m[14] = z;
}
-void Matrix::loadMultiply(const Matrix *lhs, const Matrix *rhs)
-{
+void Matrix::loadMultiply(const Matrix *lhs, const Matrix *rhs) {
for (int i=0 ; i<4 ; i++) {
float ri0 = 0;
float ri1 = 0;
diff --git a/rsMatrix.h b/rsMatrix.h
index 11ce42e..4130b8e 100644
--- a/rsMatrix.h
+++ b/rsMatrix.h
@@ -23,8 +23,7 @@
namespace android {
namespace renderscript {
-struct Matrix
-{
+struct Matrix {
float m[16];
inline float get(int i, int j) const {
@@ -69,13 +68,8 @@
tmp.loadTranslate(x, y, z);
multiply(&tmp);
}
-
-
-
};
-
-
}
}
diff --git a/rsMesh.cpp b/rsMesh.cpp
index f2dd687..baf4c53 100644
--- a/rsMesh.cpp
+++ b/rsMesh.cpp
@@ -27,12 +27,10 @@
#include <OpenGl/glext.h>
#endif
-
using namespace android;
using namespace android::renderscript;
-Mesh::Mesh(Context *rsc) : ObjectBase(rsc)
-{
+Mesh::Mesh(Context *rsc) : ObjectBase(rsc) {
mPrimitives = NULL;
mPrimitivesCount = 0;
mVertexBuffers = NULL;
@@ -43,20 +41,19 @@
mAttribCount = 0;
}
-Mesh::~Mesh()
-{
- if(mVertexBuffers) {
+Mesh::~Mesh() {
+ if (mVertexBuffers) {
delete[] mVertexBuffers;
}
- if(mPrimitives) {
- for(uint32_t i = 0; i < mPrimitivesCount; i ++) {
+ if (mPrimitives) {
+ for (uint32_t i = 0; i < mPrimitivesCount; i ++) {
delete mPrimitives[i];
}
delete[] mPrimitives;
}
- if(mAttribs) {
+ if (mAttribs) {
delete[] mAttribs;
delete[] mAttribAllocationIndex;
}
@@ -64,14 +61,14 @@
bool Mesh::isValidGLComponent(const Element *elem, uint32_t fieldIdx) {
// Do not create attribs for padding
- if(elem->getFieldName(fieldIdx)[0] == '#') {
+ if (elem->getFieldName(fieldIdx)[0] == '#') {
return false;
}
// Only GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT, GL_FIXED, GL_FLOAT are accepted.
// Filter rs types accordingly
RsDataType dt = elem->getField(fieldIdx)->getComponent().getType();
- if(dt != RS_TYPE_FLOAT_32 && dt != RS_TYPE_UNSIGNED_8 &&
+ 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;
@@ -79,7 +76,7 @@
// Now make sure they are not arrays
uint32_t arraySize = elem->getFieldArraySize(fieldIdx);
- if(arraySize != 1) {
+ if (arraySize != 1) {
return false;
}
@@ -92,19 +89,19 @@
for (uint32_t ct=0; ct < mVertexBufferCount; ct++) {
const Element *elem = mVertexBuffers[ct]->getType()->getElement();
for (uint32_t ct=0; ct < elem->getFieldCount(); ct++) {
- if(isValidGLComponent(elem, ct)) {
+ if (isValidGLComponent(elem, ct)) {
mAttribCount ++;
}
}
}
- if(mAttribs) {
+ if (mAttribs) {
delete [] mAttribs;
delete [] mAttribAllocationIndex;
mAttribs = NULL;
mAttribAllocationIndex = NULL;
}
- if(!mAttribCount) {
+ if (!mAttribCount) {
return;
}
@@ -118,7 +115,7 @@
for (uint32_t fieldI=0; fieldI < elem->getFieldCount(); fieldI++) {
const Component &c = elem->getField(fieldI)->getComponent();
- if(!isValidGLComponent(elem, fieldI)) {
+ if (!isValidGLComponent(elem, fieldI)) {
continue;
}
@@ -138,9 +135,8 @@
}
}
-void Mesh::render(Context *rsc) const
-{
- for(uint32_t ct = 0; ct < mPrimitivesCount; ct ++) {
+void Mesh::render(Context *rsc) const {
+ for (uint32_t ct = 0; ct < mPrimitivesCount; ct ++) {
renderPrimitive(rsc, ct);
}
}
@@ -161,8 +157,7 @@
renderPrimitiveRange(rsc, primIndex, 0, mVertexBuffers[0]->getType()->getDimX());
}
-void Mesh::renderPrimitiveRange(Context *rsc, uint32_t primIndex, uint32_t start, uint32_t len) const
-{
+void Mesh::renderPrimitiveRange(Context *rsc, uint32_t primIndex, uint32_t start, uint32_t len) const {
if (len < 1 || primIndex >= mPrimitivesCount || mAttribCount == 0) {
LOGE("Invalid mesh or parameters");
return;
@@ -202,8 +197,7 @@
}
-void Mesh::uploadAll(Context *rsc)
-{
+void Mesh::uploadAll(Context *rsc) {
for (uint32_t ct = 0; ct < mVertexBufferCount; ct ++) {
if (mVertexBuffers[ct].get()) {
mVertexBuffers[ct]->deferedUploadToBufferObject(rsc);
@@ -217,10 +211,9 @@
}
}
-void Mesh::updateGLPrimitives()
-{
- for(uint32_t i = 0; i < mPrimitivesCount; i ++) {
- switch(mPrimitives[i]->mPrimitive) {
+void Mesh::updateGLPrimitives() {
+ for (uint32_t i = 0; i < mPrimitivesCount; i ++) {
+ switch (mPrimitives[i]->mPrimitive) {
case RS_PRIMITIVE_POINT: mPrimitives[i]->mGLPrimitive = GL_POINTS; break;
case RS_PRIMITIVE_LINE: mPrimitives[i]->mGLPrimitive = GL_LINES; break;
case RS_PRIMITIVE_LINE_STRIP: mPrimitives[i]->mGLPrimitive = GL_LINE_STRIP; break;
@@ -231,8 +224,7 @@
}
}
-void Mesh::serialize(OStream *stream) const
-{
+void Mesh::serialize(OStream *stream) const {
// Need to identify ourselves
stream->addU32((uint32_t)getClassId());
@@ -241,7 +233,7 @@
// Store number of vertex streams
stream->addU32(mVertexBufferCount);
- for(uint32_t vCount = 0; vCount < mVertexBufferCount; vCount ++) {
+ for (uint32_t vCount = 0; vCount < mVertexBufferCount; vCount ++) {
mVertexBuffers[vCount]->serialize(stream);
}
@@ -252,21 +244,19 @@
stream->addU8((uint8_t)prim->mPrimitive);
- if(prim->mIndexBuffer.get()) {
+ if (prim->mIndexBuffer.get()) {
stream->addU32(1);
prim->mIndexBuffer->serialize(stream);
- }
- else {
+ } else {
stream->addU32(0);
}
}
}
-Mesh *Mesh::createFromStream(Context *rsc, IStream *stream)
-{
+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) {
+ if (classID != RS_A3D_CLASS_ID_MESH) {
LOGE("mesh loading skipped due to invalid class id");
return NULL;
}
@@ -278,17 +268,17 @@
mesh->setName(name.string(), name.size());
mesh->mVertexBufferCount = stream->loadU32();
- if(mesh->mVertexBufferCount) {
+ if (mesh->mVertexBufferCount) {
mesh->mVertexBuffers = new ObjectBaseRef<Allocation>[mesh->mVertexBufferCount];
- for(uint32_t vCount = 0; vCount < mesh->mVertexBufferCount; vCount ++) {
+ for (uint32_t vCount = 0; vCount < mesh->mVertexBufferCount; vCount ++) {
Allocation *vertexAlloc = Allocation::createFromStream(rsc, stream);
mesh->mVertexBuffers[vCount].set(vertexAlloc);
}
}
mesh->mPrimitivesCount = stream->loadU32();
- if(mesh->mPrimitivesCount) {
+ if (mesh->mPrimitivesCount) {
mesh->mPrimitives = new Primitive_t *[mesh->mPrimitivesCount];
// load all primitives
@@ -300,7 +290,7 @@
// Check to see if the index buffer was stored
uint32_t isIndexPresent = stream->loadU32();
- if(isIndexPresent) {
+ if (isIndexPresent) {
Allocation *indexAlloc = Allocation::createFromStream(rsc, stream);
prim->mIndexBuffer.set(indexAlloc);
}
@@ -325,7 +315,7 @@
const Element *bufferElem = bufferType->getElement();
for (uint32_t ct=0; ct < bufferElem->getFieldCount(); ct++) {
- if(strcmp(bufferElem->getFieldName(ct), "position") == 0) {
+ if (strcmp(bufferElem->getFieldName(ct), "position") == 0) {
vectorSize = bufferElem->getField(ct)->getComponent().getVectorSize();
stride = bufferElem->getSizeBytes() / sizeof(float);
uint32_t offset = bufferElem->getFieldOffsetBytes(ct);
@@ -334,22 +324,22 @@
break;
}
}
- if(posPtr) {
+ if (posPtr) {
break;
}
}
mBBoxMin[0] = mBBoxMin[1] = mBBoxMin[2] = 1e6;
mBBoxMax[0] = mBBoxMax[1] = mBBoxMax[2] = -1e6;
- if(!posPtr) {
+ if (!posPtr) {
LOGE("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 ++) {
+ 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]);
}
@@ -358,25 +348,22 @@
}
-MeshContext::MeshContext()
-{
+MeshContext::MeshContext() {
}
-MeshContext::~MeshContext()
-{
+MeshContext::~MeshContext() {
}
namespace android {
namespace renderscript {
-RsMesh rsi_MeshCreate(Context *rsc, uint32_t vtxCount, uint32_t idxCount)
-{
+RsMesh rsi_MeshCreate(Context *rsc, uint32_t vtxCount, uint32_t idxCount) {
Mesh *sm = new Mesh(rsc);
sm->incUserRef();
sm->mPrimitivesCount = idxCount;
sm->mPrimitives = new Mesh::Primitive_t *[sm->mPrimitivesCount];
- for(uint32_t ct = 0; ct < idxCount; ct ++) {
+ for (uint32_t ct = 0; ct < idxCount; ct ++) {
sm->mPrimitives[ct] = new Mesh::Primitive_t;
}
@@ -386,16 +373,14 @@
return sm;
}
-void rsi_MeshBindVertex(Context *rsc, RsMesh mv, RsAllocation va, uint32_t slot)
-{
+void rsi_MeshBindVertex(Context *rsc, RsMesh mv, RsAllocation va, uint32_t slot) {
Mesh *sm = static_cast<Mesh *>(mv);
rsAssert(slot < sm->mVertexBufferCount);
sm->mVertexBuffers[slot].set((Allocation *)va);
}
-void rsi_MeshBindIndex(Context *rsc, RsMesh mv, RsAllocation va, uint32_t primType, uint32_t slot)
-{
+void rsi_MeshBindIndex(Context *rsc, RsMesh mv, RsAllocation va, uint32_t primType, uint32_t slot) {
Mesh *sm = static_cast<Mesh *>(mv);
rsAssert(slot < sm->mPrimitivesCount);
@@ -404,48 +389,42 @@
sm->updateGLPrimitives();
}
-void rsi_MeshInitVertexAttribs(Context *rsc, RsMesh mv)
-{
+void rsi_MeshInitVertexAttribs(Context *rsc, RsMesh mv) {
Mesh *sm = static_cast<Mesh *>(mv);
sm->initVertexAttribs();
}
}}
-void rsaMeshGetVertexBufferCount(RsContext con, RsMesh mv, int32_t *numVtx)
-{
+void rsaMeshGetVertexBufferCount(RsContext con, RsMesh mv, int32_t *numVtx) {
Mesh *sm = static_cast<Mesh *>(mv);
*numVtx = sm->mVertexBufferCount;
}
-void rsaMeshGetIndexCount(RsContext con, RsMesh mv, int32_t *numIdx)
-{
+void rsaMeshGetIndexCount(RsContext con, RsMesh mv, int32_t *numIdx) {
Mesh *sm = static_cast<Mesh *>(mv);
*numIdx = sm->mPrimitivesCount;
}
-void rsaMeshGetVertices(RsContext con, RsMesh mv, RsAllocation *vtxData, uint32_t vtxDataCount)
-{
+void rsaMeshGetVertices(RsContext con, RsMesh mv, RsAllocation *vtxData, uint32_t vtxDataCount) {
Mesh *sm = static_cast<Mesh *>(mv);
rsAssert(vtxDataCount == sm->mVertexBufferCount);
- for(uint32_t ct = 0; ct < vtxDataCount; ct ++) {
+ for (uint32_t ct = 0; ct < vtxDataCount; ct ++) {
vtxData[ct] = sm->mVertexBuffers[ct].get();
sm->mVertexBuffers[ct]->incUserRef();
}
}
-void rsaMeshGetIndices(RsContext con, RsMesh mv, RsAllocation *va, uint32_t *primType, uint32_t idxDataCount)
-{
+void rsaMeshGetIndices(RsContext con, RsMesh mv, RsAllocation *va, uint32_t *primType, uint32_t idxDataCount) {
Mesh *sm = static_cast<Mesh *>(mv);
rsAssert(idxDataCount == sm->mPrimitivesCount);
- for(uint32_t ct = 0; ct < idxDataCount; ct ++) {
+ for (uint32_t ct = 0; ct < idxDataCount; ct ++) {
va[ct] = sm->mPrimitives[ct]->mIndexBuffer.get();
primType[ct] = sm->mPrimitives[ct]->mPrimitive;
- if(sm->mPrimitives[ct]->mIndexBuffer.get()) {
+ if (sm->mPrimitives[ct]->mIndexBuffer.get()) {
sm->mPrimitives[ct]->mIndexBuffer->incUserRef();
}
}
-
}
diff --git a/rsMesh.h b/rsMesh.h
index 261b5a6..410b70b 100644
--- a/rsMesh.h
+++ b/rsMesh.h
@@ -26,8 +26,7 @@
// An element is a group of Components that occupies one cell in a structure.
-class Mesh : public ObjectBase
-{
+class Mesh : public ObjectBase {
public:
Mesh(Context *);
~Mesh();
@@ -79,15 +78,12 @@
uint32_t mAttribCount;
};
-class MeshContext
-{
+class MeshContext {
public:
MeshContext();
~MeshContext();
-
};
-
}
}
#endif //ANDROID_RS_TRIANGLE_MESH_H
diff --git a/rsMutex.cpp b/rsMutex.cpp
index 37752f2..2105288 100644
--- a/rsMutex.cpp
+++ b/rsMutex.cpp
@@ -20,17 +20,14 @@
using namespace android::renderscript;
-Mutex::Mutex()
-{
+Mutex::Mutex() {
}
-Mutex::~Mutex()
-{
+Mutex::~Mutex() {
pthread_mutex_destroy(&mMutex);
}
-bool Mutex::init()
-{
+bool Mutex::init() {
int status = pthread_mutex_init(&mMutex, NULL);
if (status) {
LOGE("Mutex::Mutex init failure");
@@ -39,8 +36,7 @@
return true;
}
-bool Mutex::lock()
-{
+bool Mutex::lock() {
int status;
status = pthread_mutex_lock(&mMutex);
if (status) {
@@ -50,8 +46,7 @@
return true;
}
-bool Mutex::unlock()
-{
+bool Mutex::unlock() {
int status;
status = pthread_mutex_unlock(&mMutex);
if (status) {
diff --git a/rsObjectBase.cpp b/rsObjectBase.cpp
index 44dc042..aec2f67 100644
--- a/rsObjectBase.cpp
+++ b/rsObjectBase.cpp
@@ -28,8 +28,7 @@
pthread_mutex_t ObjectBase::gObjectInitMutex = PTHREAD_MUTEX_INITIALIZER;
-ObjectBase::ObjectBase(Context *rsc)
-{
+ObjectBase::ObjectBase(Context *rsc) {
mUserRefCount = 0;
mSysRefCount = 0;
mRSC = rsc;
@@ -45,14 +44,13 @@
//LOGV("ObjectBase %p con", this);
}
-ObjectBase::~ObjectBase()
-{
+ObjectBase::~ObjectBase() {
//LOGV("~ObjectBase %p ref %i,%i", this, mUserRefCount, mSysRefCount);
#if RS_OBJECT_DEBUG
mStack.dump();
#endif
- if(mPrev || mNext) {
+ 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
@@ -66,8 +64,7 @@
rsAssert(!mSysRefCount);
}
-void ObjectBase::dumpLOGV(const char *op) const
-{
+void ObjectBase::dumpLOGV(const char *op) const {
if (mName.size()) {
LOGV("%s RSobj %p, name %s, refs %i,%i links %p,%p,%p",
op, this, mName.string(), mUserRefCount, mSysRefCount, mNext, mPrev, mRSC);
@@ -77,24 +74,20 @@
}
}
-void ObjectBase::incUserRef() const
-{
+void ObjectBase::incUserRef() const {
android_atomic_inc(&mUserRefCount);
//LOGV("ObjectBase %p incU ref %i, %i", this, mUserRefCount, mSysRefCount);
}
-void ObjectBase::incSysRef() const
-{
+void ObjectBase::incSysRef() const {
android_atomic_inc(&mSysRefCount);
//LOGV("ObjectBase %p incS ref %i, %i", this, mUserRefCount, mSysRefCount);
}
-void ObjectBase::preDestroy() const
-{
+void ObjectBase::preDestroy() const {
}
-bool ObjectBase::checkDelete(const ObjectBase *ref)
-{
+bool ObjectBase::checkDelete(const ObjectBase *ref) {
if (!ref) {
return false;
}
@@ -117,9 +110,7 @@
return true;
}
-
-bool ObjectBase::decUserRef() const
-{
+bool ObjectBase::decUserRef() const {
rsAssert(mUserRefCount > 0);
#if RS_OBJECT_DEBUG
LOGV("ObjectBase %p decU ref %i, %i", this, mUserRefCount, mSysRefCount);
@@ -136,8 +127,7 @@
return false;
}
-bool ObjectBase::zeroUserRef() const
-{
+bool ObjectBase::zeroUserRef() const {
//LOGV("ObjectBase %p zeroU ref %i, %i", this, mUserRefCount, mSysRefCount);
android_atomic_acquire_store(0, &mUserRefCount);
if (android_atomic_acquire_load(&mSysRefCount) <= 0) {
@@ -146,8 +136,7 @@
return false;
}
-bool ObjectBase::decSysRef() const
-{
+bool ObjectBase::decSysRef() const {
//LOGV("ObjectBase %p decS ref %i, %i", this, mUserRefCount, mSysRefCount);
rsAssert(mSysRefCount > 0);
if ((android_atomic_dec(&mSysRefCount) <= 1) &&
@@ -157,28 +146,23 @@
return false;
}
-void ObjectBase::setName(const char *name)
-{
+void ObjectBase::setName(const char *name) {
mName.setTo(name);
}
-void ObjectBase::setName(const char *name, uint32_t len)
-{
+void ObjectBase::setName(const char *name, uint32_t len) {
mName.setTo(name, len);
}
-void ObjectBase::asyncLock()
-{
+void ObjectBase::asyncLock() {
pthread_mutex_lock(&gObjectInitMutex);
}
-void ObjectBase::asyncUnlock()
-{
+void ObjectBase::asyncUnlock() {
pthread_mutex_unlock(&gObjectInitMutex);
}
-void ObjectBase::add() const
-{
+void ObjectBase::add() const {
asyncLock();
rsAssert(!mNext);
@@ -193,8 +177,7 @@
asyncUnlock();
}
-void ObjectBase::remove() const
-{
+void ObjectBase::remove() const {
//LOGV("calling remove rsc %p", mRSC);
if (!mRSC) {
rsAssert(!mPrev);
@@ -215,8 +198,7 @@
mNext = NULL;
}
-void ObjectBase::zeroAllUserRef(Context *rsc)
-{
+void ObjectBase::zeroAllUserRef(Context *rsc) {
if (rsc->props.mLogObjects) {
LOGV("Forcing release of all outstanding user refs.");
}
@@ -241,8 +223,7 @@
}
}
-void ObjectBase::dumpAll(Context *rsc)
-{
+void ObjectBase::dumpAll(Context *rsc) {
asyncLock();
LOGV("Dumping all objects");
@@ -256,8 +237,7 @@
asyncUnlock();
}
-bool ObjectBase::isValid(const Context *rsc, const ObjectBase *obj)
-{
+bool ObjectBase::isValid(const Context *rsc, const ObjectBase *obj) {
asyncLock();
const ObjectBase * o = rsc->mObjHead;
diff --git a/rsObjectBase.h b/rsObjectBase.h
index 5cc275a..01850f1 100644
--- a/rsObjectBase.h
+++ b/rsObjectBase.h
@@ -30,8 +30,7 @@
class OStream;
// An element is a group of Components that occupies one cell in a structure.
-class ObjectBase
-{
+class ObjectBase {
public:
ObjectBase(Context *rsc);
@@ -94,8 +93,7 @@
};
template<class T>
-class ObjectBaseRef
-{
+class ObjectBaseRef {
public:
ObjectBaseRef() {
mRef = NULL;
@@ -154,10 +152,8 @@
protected:
T * mRef;
-
};
-
}
}
diff --git a/rsProgram.cpp b/rsProgram.cpp
index ce3af2d..1c44e71 100644
--- a/rsProgram.cpp
+++ b/rsProgram.cpp
@@ -29,17 +29,15 @@
using namespace android;
using namespace android::renderscript;
-Program::Program(Context *rsc) : ObjectBase(rsc)
-{
+Program::Program(Context *rsc) : ObjectBase(rsc) {
initMemberVars();
}
Program::Program(Context *rsc, const char * shaderText, uint32_t shaderLength,
- const uint32_t * params, uint32_t paramLength) :
- ObjectBase(rsc)
-{
- initMemberVars();
+ const uint32_t * params, uint32_t paramLength)
+ : ObjectBase(rsc) {
+ initMemberVars();
for (uint32_t ct=0; ct < paramLength; ct+=2) {
if (params[ct] == RS_PROGRAM_PARAM_INPUT) {
mInputCount++;
@@ -78,7 +76,7 @@
}
mIsInternal = false;
uint32_t internalTokenLen = strlen(RS_SHADER_INTERNAL);
- if(shaderLength > internalTokenLen &&
+ if (shaderLength > internalTokenLen &&
strncmp(RS_SHADER_INTERNAL, shaderText, internalTokenLen) == 0) {
mIsInternal = true;
shaderText += internalTokenLen;
@@ -89,13 +87,12 @@
initAttribAndUniformArray();
}
-Program::~Program()
-{
- if(mRSC->props.mLogShaders) {
+Program::~Program() {
+ if (mRSC->props.mLogShaders) {
LOGV("Program::~Program with shader id %u", mShaderID);
}
- if(mShaderID) {
+ if (mShaderID) {
glDeleteShader(mShaderID);
}
@@ -144,8 +141,7 @@
mIsInternal = false;
}
-void Program::bindAllocation(Context *rsc, Allocation *alloc, uint32_t slot)
-{
+void Program::bindAllocation(Context *rsc, Allocation *alloc, uint32_t slot) {
if (alloc != NULL) {
if (slot >= mConstantCount) {
LOGE("Attempt to bind alloc at slot %u, on shader id %u, but const count is %u",
@@ -173,8 +169,7 @@
mDirty = true;
}
-void Program::bindTexture(Context *rsc, uint32_t slot, Allocation *a)
-{
+void Program::bindTexture(Context *rsc, uint32_t slot, Allocation *a) {
if (slot >= mTextureCount) {
LOGE("Attempt to bind texture to slot %u but tex count is %u", slot, mTextureCount);
rsc->setError(RS_ERROR_BAD_SHADER, "Cannot bind texture");
@@ -186,8 +181,7 @@
mDirty = true;
}
-void Program::bindSampler(Context *rsc, uint32_t slot, Sampler *s)
-{
+void Program::bindSampler(Context *rsc, uint32_t slot, Sampler *s) {
if (slot >= mTextureCount) {
LOGE("Attempt to bind sampler to slot %u but tex count is %u", slot, mTextureCount);
rsc->setError(RS_ERROR_BAD_SHADER, "Cannot bind sampler");
@@ -198,8 +192,7 @@
mDirty = true;
}
-String8 Program::getGLSLInputString() const
-{
+String8 Program::getGLSLInputString() const {
String8 s;
for (uint32_t ct=0; ct < mInputCount; ct++) {
const Element *e = mInputElements[ct].get();
@@ -208,7 +201,7 @@
// Cannot be complex
rsAssert(!f->getFieldCount());
- switch(f->getComponent().getVectorSize()) {
+ switch (f->getComponent().getVectorSize()) {
case 1: s.append("attribute float ATTRIB_"); break;
case 2: s.append("attribute vec2 ATTRIB_"); break;
case 3: s.append("attribute vec3 ATTRIB_"); break;
@@ -224,23 +217,18 @@
return s;
}
-String8 Program::getGLSLOutputString() const
-{
+String8 Program::getGLSLOutputString() const {
return String8();
}
-String8 Program::getGLSLConstantString() const
-{
+String8 Program::getGLSLConstantString() const {
return String8();
}
-
-void Program::createShader()
-{
+void Program::createShader() {
}
-bool Program::loadShader(Context *rsc, uint32_t type)
-{
+bool Program::loadShader(Context *rsc, uint32_t type) {
mShaderID = glCreateShader(type);
rsAssert(mShaderID);
@@ -281,8 +269,7 @@
return true;
}
-void Program::setShader(const char *txt, uint32_t len)
-{
+void Program::setShader(const char *txt, uint32_t len) {
mUserShader.setTo(txt, len);
}
@@ -299,17 +286,14 @@
// Cannot be complex
rsAssert(!f->getFieldCount());
- if(f->getType() == RS_TYPE_MATRIX_4X4) {
+ if (f->getType() == RS_TYPE_MATRIX_4X4) {
mShader.append("uniform mat4 UNI_");
- }
- else if(f->getType() == RS_TYPE_MATRIX_3X3) {
+ } else if (f->getType() == RS_TYPE_MATRIX_3X3) {
mShader.append("uniform mat3 UNI_");
- }
- else if(f->getType() == RS_TYPE_MATRIX_2X2) {
+ } else if (f->getType() == RS_TYPE_MATRIX_2X2) {
mShader.append("uniform mat2 UNI_");
- }
- else {
- switch(f->getComponent().getVectorSize()) {
+ } else {
+ switch (f->getComponent().getVectorSize()) {
case 1: mShader.append("uniform float UNI_"); break;
case 2: mShader.append("uniform vec2 UNI_"); break;
case 3: mShader.append("uniform vec3 UNI_"); break;
@@ -320,7 +304,7 @@
}
mShader.append(fn);
- if(e->getFieldArraySize(field) > 1) {
+ if (e->getFieldArraySize(field) > 1) {
mShader.appendFormat("[%d]", e->getFieldArraySize(field));
}
mShader.append(";\n");
@@ -331,30 +315,27 @@
void Program::logUniform(const Element *field, const float *fd, uint32_t arraySize ) {
RsDataType dataType = field->getType();
uint32_t elementSize = field->getSizeBytes() / sizeof(float);
- for(uint32_t i = 0; i < arraySize; i ++) {
- if(arraySize > 1) {
+ for (uint32_t i = 0; i < arraySize; i ++) {
+ if (arraySize > 1) {
LOGV("Array Element [%u]", i);
}
- if(dataType == RS_TYPE_MATRIX_4X4) {
+ if (dataType == RS_TYPE_MATRIX_4X4) {
LOGV("Matrix4x4");
LOGV("{%f, %f, %f, %f", fd[0], fd[4], fd[8], fd[12]);
LOGV(" %f, %f, %f, %f", fd[1], fd[5], fd[9], fd[13]);
LOGV(" %f, %f, %f, %f", fd[2], fd[6], fd[10], fd[14]);
LOGV(" %f, %f, %f, %f}", fd[3], fd[7], fd[11], fd[15]);
- }
- else if(dataType == RS_TYPE_MATRIX_3X3) {
+ } else if (dataType == RS_TYPE_MATRIX_3X3) {
LOGV("Matrix3x3");
LOGV("{%f, %f, %f", fd[0], fd[3], fd[6]);
LOGV(" %f, %f, %f", fd[1], fd[4], fd[7]);
LOGV(" %f, %f, %f}", fd[2], fd[5], fd[8]);
- }
- else if(dataType == RS_TYPE_MATRIX_2X2) {
+ } else if (dataType == RS_TYPE_MATRIX_2X2) {
LOGV("Matrix2x2");
LOGV("{%f, %f", fd[0], fd[2]);
LOGV(" %f, %f}", fd[1], fd[3]);
- }
- else {
- switch(field->getComponent().getVectorSize()) {
+ } else {
+ switch (field->getComponent().getVectorSize()) {
case 1:
LOGV("Uniform 1 = %f", fd[0]);
break;
@@ -380,17 +361,14 @@
void Program::setUniform(Context *rsc, const Element *field, const float *fd,
int32_t slot, uint32_t arraySize ) {
RsDataType dataType = field->getType();
- if(dataType == RS_TYPE_MATRIX_4X4) {
+ if (dataType == RS_TYPE_MATRIX_4X4) {
glUniformMatrix4fv(slot, arraySize, GL_FALSE, fd);
- }
- else if(dataType == RS_TYPE_MATRIX_3X3) {
+ } else if (dataType == RS_TYPE_MATRIX_3X3) {
glUniformMatrix3fv(slot, arraySize, GL_FALSE, fd);
- }
- else if(dataType == RS_TYPE_MATRIX_2X2) {
+ } else if (dataType == RS_TYPE_MATRIX_2X2) {
glUniformMatrix2fv(slot, arraySize, GL_FALSE, fd);
- }
- else {
- switch(field->getComponent().getVectorSize()) {
+ } else {
+ switch (field->getComponent().getVectorSize()) {
case 1:
glUniform1fv(slot, arraySize, fd);
break;
@@ -425,7 +403,7 @@
const Element *f = e->getField(field);
const char *fieldName = e->getFieldName(field);
// If this field is padding, skip it
- if(fieldName[0] == '#') {
+ if (fieldName[0] == '#') {
continue;
}
@@ -434,14 +412,14 @@
int32_t slot = -1;
uint32_t arraySize = 1;
- if(!isFragment) {
+ if (!isFragment) {
slot = sc->vtxUniformSlot(uidx);
arraySize = sc->vtxUniformSize(uidx);
} else {
slot = sc->fragUniformSlot(uidx);
arraySize = sc->fragUniformSize(uidx);
}
- if(rsc->props.mLogShadersUniforms) {
+ if (rsc->props.mLogShadersUniforms) {
LOGV("Uniform slot=%i, offset=%i, constant=%i, field=%i, uidx=%i, name=%s", slot, offset, ct, field, uidx, fieldName);
}
uidx ++;
@@ -449,7 +427,7 @@
continue;
}
- if(rsc->props.mLogShadersUniforms) {
+ if (rsc->props.mLogShadersUniforms) {
logUniform(f, fd, arraySize);
}
setUniform(rsc, f, fd, slot, arraySize);
@@ -462,7 +440,7 @@
for (uint32_t ct=0; ct < mInputCount; ct++) {
const Element *elem = mInputElements[ct].get();
for (uint32_t field=0; field < elem->getFieldCount(); field++) {
- if(elem->getFieldName(field)[0] != '#') {
+ if (elem->getFieldName(field)[0] != '#') {
mAttribCount ++;
}
}
@@ -473,35 +451,33 @@
const Element *elem = mConstantTypes[ct]->getElement();
for (uint32_t field=0; field < elem->getFieldCount(); field++) {
- if(elem->getFieldName(field)[0] != '#') {
+ if (elem->getFieldName(field)[0] != '#') {
mUniformCount ++;
}
}
}
mUniformCount += mTextureCount;
- if(mAttribCount) {
+ if (mAttribCount) {
mAttribNames = new String8[mAttribCount];
}
- if(mUniformCount) {
+ if (mUniformCount) {
mUniformNames = new String8[mUniformCount];
mUniformArraySizes = new uint32_t[mUniformCount];
}
}
-void Program::initAddUserElement(const Element *e, String8 *names, uint32_t *arrayLengths, uint32_t *count, const char *prefix)
-{
+void Program::initAddUserElement(const Element *e, String8 *names, uint32_t *arrayLengths, uint32_t *count, const char *prefix) {
rsAssert(e->getFieldCount());
for (uint32_t ct=0; ct < e->getFieldCount(); ct++) {
const Element *ce = e->getField(ct);
if (ce->getFieldCount()) {
initAddUserElement(ce, names, arrayLengths, count, prefix);
- }
- else if(e->getFieldName(ct)[0] != '#') {
+ } else if (e->getFieldName(ct)[0] != '#') {
String8 tmp(prefix);
tmp.append(e->getFieldName(ct));
names[*count].setTo(tmp.string());
- if(arrayLengths) {
+ if (arrayLengths) {
arrayLengths[*count] = e->getFieldArraySize(ct);
}
(*count)++;
@@ -512,21 +488,17 @@
namespace android {
namespace renderscript {
-
-void rsi_ProgramBindConstants(Context *rsc, RsProgram vp, uint32_t slot, RsAllocation constants)
-{
+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)
-{
+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)
-{
+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/rsProgram.h b/rsProgram.h
index 46692fd..b682b97 100644
--- a/rsProgram.h
+++ b/rsProgram.h
@@ -29,8 +29,7 @@
#define RS_SHADER_ATTR "ATTRIB_"
#define RS_SHADER_UNI "UNI_"
-class Program : public ObjectBase
-{
+class Program : public ObjectBase {
public:
Program(Context *);
@@ -110,8 +109,6 @@
bool loadShader(Context *, uint32_t type);
};
-
-
}
}
#endif
diff --git a/rsProgramFragment.cpp b/rsProgramFragment.cpp
index d089a5a..407522b 100644
--- a/rsProgramFragment.cpp
+++ b/rsProgramFragment.cpp
@@ -33,9 +33,9 @@
ProgramFragment::ProgramFragment(Context *rsc, const char * shaderText,
uint32_t shaderLength, const uint32_t * params,
- uint32_t paramLength) :
- Program(rsc, shaderText, shaderLength, params, paramLength)
-{
+ uint32_t paramLength)
+ : Program(rsc, shaderText, shaderLength, params, paramLength) {
+
mConstantColor[0] = 1.f;
mConstantColor[1] = 1.f;
mConstantColor[2] = 1.f;
@@ -44,21 +44,19 @@
init(rsc);
}
-ProgramFragment::~ProgramFragment()
-{
- if(mShaderID) {
+ProgramFragment::~ProgramFragment() {
+ if (mShaderID) {
mRSC->mShaderCache.cleanupFragment(mShaderID);
}
}
-void ProgramFragment::setConstantColor(Context *rsc, float r, float g, float b, float a)
-{
- if(isUserProgram()) {
+void ProgramFragment::setConstantColor(Context *rsc, float r, float g, float b, float a) {
+ if (isUserProgram()) {
LOGE("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(mConstants[0].get() == NULL) {
+ if (mConstants[0].get() == NULL) {
LOGE("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;
@@ -71,8 +69,7 @@
mDirty = true;
}
-void ProgramFragment::setupGL2(Context *rsc, ProgramFragmentState *state, ShaderCache *sc)
-{
+void ProgramFragment::setupGL2(Context *rsc, ProgramFragmentState *state, ShaderCache *sc) {
//LOGE("sgl2 frag1 %x", glGetError());
if ((state->mLast.get() == this) && !mDirty) {
return;
@@ -86,7 +83,7 @@
uint32_t numTexturesToBind = mTextureCount;
uint32_t numTexturesAvailable = rsc->getMaxFragmentTextures();
- if(numTexturesToBind >= numTexturesAvailable) {
+ if (numTexturesToBind >= numTexturesAvailable) {
LOGE("Attempting to bind %u textures on shader id %u, but only %u are available",
mTextureCount, (uint32_t)this, numTexturesAvailable);
rsc->setError(RS_ERROR_BAD_SHADER, "Cannot bind more textuers than available");
@@ -127,8 +124,7 @@
Program::loadShader(rsc, GL_FRAGMENT_SHADER);
}
-void ProgramFragment::createShader()
-{
+void ProgramFragment::createShader() {
if (mUserShader.length() > 1) {
mShader.append("precision mediump float;\n");
appendUserConstants();
@@ -144,8 +140,7 @@
}
}
-void ProgramFragment::init(Context *rsc)
-{
+void ProgramFragment::init(Context *rsc) {
uint32_t uniformIndex = 0;
if (mUserShader.size() > 0) {
for (uint32_t ct=0; ct < mConstantCount; ct++) {
@@ -164,29 +159,23 @@
createShader();
}
-void ProgramFragment::serialize(OStream *stream) const
-{
-
+void ProgramFragment::serialize(OStream *stream) const {
}
-ProgramFragment *ProgramFragment::createFromStream(Context *rsc, IStream *stream)
-{
+ProgramFragment *ProgramFragment::createFromStream(Context *rsc, IStream *stream) {
return NULL;
}
-ProgramFragmentState::ProgramFragmentState()
-{
+ProgramFragmentState::ProgramFragmentState() {
mPF = NULL;
}
-ProgramFragmentState::~ProgramFragmentState()
-{
+ProgramFragmentState::~ProgramFragmentState() {
ObjectBase::checkDelete(mPF);
mPF = NULL;
}
-void ProgramFragmentState::init(Context *rsc)
-{
+void ProgramFragmentState::init(Context *rsc) {
String8 shaderString(RS_SHADER_INTERNAL);
shaderString.append("varying lowp vec4 varColor;\n");
shaderString.append("varying vec2 varTex0;\n");
@@ -217,20 +206,17 @@
mDefault.set(pf);
}
-void ProgramFragmentState::deinit(Context *rsc)
-{
+void ProgramFragmentState::deinit(Context *rsc) {
mDefault.clear();
mLast.clear();
}
-
namespace android {
namespace renderscript {
RsProgramFragment rsi_ProgramFragmentCreate(Context *rsc, const char * shaderText,
uint32_t shaderLength, const uint32_t * params,
- uint32_t paramLength)
-{
+ uint32_t paramLength) {
ProgramFragment *pf = new ProgramFragment(rsc, shaderText, shaderLength, params, paramLength);
pf->incUserRef();
//LOGE("rsi_ProgramFragmentCreate %p", pf);
diff --git a/rsProgramFragment.h b/rsProgramFragment.h
index 1cf9ca7..3d28946 100644
--- a/rsProgramFragment.h
+++ b/rsProgramFragment.h
@@ -25,8 +25,7 @@
class ProgramFragmentState;
-class ProgramFragment : public Program
-{
+class ProgramFragment : public Program {
public:
ProgramFragment(Context *rsc, const char * shaderText,
uint32_t shaderLength, const uint32_t * params,
@@ -49,8 +48,7 @@
int32_t mTextureUniformIndexStart;
};
-class ProgramFragmentState
-{
+class ProgramFragmentState {
public:
ProgramFragmentState();
~ProgramFragmentState();
@@ -65,7 +63,6 @@
ObjectBaseRef<ProgramFragment> mLast;
};
-
}
}
#endif
diff --git a/rsProgramRaster.cpp b/rsProgramRaster.cpp
index 5f8c4ba..f2b5b9a 100644
--- a/rsProgramRaster.cpp
+++ b/rsProgramRaster.cpp
@@ -30,12 +30,10 @@
using namespace android::renderscript;
-ProgramRaster::ProgramRaster(Context *rsc,
- bool pointSmooth,
- bool lineSmooth,
- bool pointSprite) :
- Program(rsc)
-{
+ProgramRaster::ProgramRaster(Context *rsc, bool pointSmooth,
+ bool lineSmooth, bool pointSprite)
+ : Program(rsc) {
+
mPointSmooth = pointSmooth;
mLineSmooth = lineSmooth;
mPointSprite = pointSprite;
@@ -43,31 +41,27 @@
mCull = RS_CULL_BACK;
}
-ProgramRaster::~ProgramRaster()
-{
+ProgramRaster::~ProgramRaster() {
}
-void ProgramRaster::setLineWidth(float s)
-{
+void ProgramRaster::setLineWidth(float s) {
mLineWidth = s;
mDirty = true;
}
-void ProgramRaster::setCullMode(RsCullMode mode)
-{
+void ProgramRaster::setCullMode(RsCullMode mode) {
mCull = mode;
mDirty = true;
}
-void ProgramRaster::setupGL2(const Context *rsc, ProgramRasterState *state)
-{
+void ProgramRaster::setupGL2(const Context *rsc, ProgramRasterState *state) {
if (state->mLast.get() == this && !mDirty) {
return;
}
state->mLast.set(this);
mDirty = false;
- switch(mCull) {
+ switch (mCull) {
case RS_CULL_BACK:
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
@@ -82,66 +76,56 @@
}
}
-void ProgramRaster::serialize(OStream *stream) const
-{
-
+void ProgramRaster::serialize(OStream *stream) const {
}
-ProgramRaster *ProgramRaster::createFromStream(Context *rsc, IStream *stream)
-{
+ProgramRaster *ProgramRaster::createFromStream(Context *rsc, IStream *stream) {
return NULL;
}
-ProgramRasterState::ProgramRasterState()
-{
+ProgramRasterState::ProgramRasterState() {
}
-ProgramRasterState::~ProgramRasterState()
-{
+ProgramRasterState::~ProgramRasterState() {
}
-void ProgramRasterState::init(Context *rsc)
-{
+void ProgramRasterState::init(Context *rsc) {
ProgramRaster *pr = new ProgramRaster(rsc, false, false, false);
mDefault.set(pr);
}
-void ProgramRasterState::deinit(Context *rsc)
-{
+void ProgramRasterState::deinit(Context *rsc) {
mDefault.clear();
mLast.clear();
}
-
namespace android {
namespace renderscript {
RsProgramRaster rsi_ProgramRasterCreate(Context * rsc,
bool pointSmooth,
bool lineSmooth,
- bool pointSprite)
-{
- ProgramRaster *pr = new ProgramRaster(rsc,
- pointSmooth,
- lineSmooth,
- pointSprite);
+ bool pointSprite) {
+ ProgramRaster *pr = new ProgramRaster(rsc, pointSmooth,
+ lineSmooth, pointSprite);
pr->incUserRef();
return pr;
}
-void rsi_ProgramRasterSetLineWidth(Context * rsc, RsProgramRaster vpr, float s)
-{
+void rsi_ProgramRasterSetLineWidth(Context * rsc,
+ RsProgramRaster vpr,
+ float s) {
ProgramRaster *pr = static_cast<ProgramRaster *>(vpr);
pr->setLineWidth(s);
}
-void rsi_ProgramRasterSetCullMode(Context * rsc, RsProgramRaster vpr, RsCullMode mode)
-{
+void rsi_ProgramRasterSetCullMode(Context * rsc,
+ RsProgramRaster vpr,
+ RsCullMode mode) {
ProgramRaster *pr = static_cast<ProgramRaster *>(vpr);
pr->setCullMode(mode);
}
-
}
}
diff --git a/rsProgramRaster.h b/rsProgramRaster.h
index d5ed686..7958af9 100644
--- a/rsProgramRaster.h
+++ b/rsProgramRaster.h
@@ -25,8 +25,7 @@
class ProgramRasterState;
-class ProgramRaster : public Program
-{
+class ProgramRaster : public Program {
public:
ProgramRaster(Context *rsc,
bool pointSmooth,
@@ -50,8 +49,7 @@
RsCullMode mCull;
};
-class ProgramRasterState
-{
+class ProgramRasterState {
public:
ProgramRasterState();
~ProgramRasterState();
diff --git a/rsProgramStore.cpp b/rsProgramStore.cpp
index 876299f..72ac574 100644
--- a/rsProgramStore.cpp
+++ b/rsProgramStore.cpp
@@ -30,9 +30,7 @@
using namespace android::renderscript;
-ProgramStore::ProgramStore(Context *rsc) :
- Program(rsc)
-{
+ProgramStore::ProgramStore(Context *rsc) : Program(rsc) {
mDitherEnable = true;
mBlendEnable = false;
mColorRWriteEnable = true;
@@ -42,20 +40,15 @@
mBlendSrc = GL_ONE;
mBlendDst = GL_ZERO;
-
mDepthTestEnable = false;
mDepthWriteEnable = true;
mDepthFunc = GL_LESS;
-
-
}
-ProgramStore::~ProgramStore()
-{
+ProgramStore::~ProgramStore() {
}
-void ProgramStore::setupGL2(const Context *rsc, ProgramStoreState *state)
-{
+void ProgramStore::setupGL2(const Context *rsc, ProgramStoreState *state) {
if (state->mLast.get() == this) {
return;
}
@@ -76,7 +69,7 @@
if (rsc->mUserSurfaceConfig.depthMin > 0) {
glDepthMask(mDepthWriteEnable);
- if(mDepthTestEnable || mDepthWriteEnable) {
+ if (mDepthTestEnable || mDepthWriteEnable) {
glEnable(GL_DEPTH_TEST);
glDepthFunc(mDepthFunc);
} else {
@@ -100,28 +93,21 @@
}
}
-
-void ProgramStore::setDitherEnable(bool enable)
-{
+void ProgramStore::setDitherEnable(bool enable) {
mDitherEnable = enable;
}
-void ProgramStore::serialize(OStream *stream) const
-{
-
+void ProgramStore::serialize(OStream *stream) const {
}
-ProgramStore *ProgramStore::createFromStream(Context *rsc, IStream *stream)
-{
+ProgramStore *ProgramStore::createFromStream(Context *rsc, IStream *stream) {
return NULL;
}
-
-void ProgramStore::setDepthFunc(RsDepthFunc func)
-{
+void ProgramStore::setDepthFunc(RsDepthFunc func) {
mDepthTestEnable = true;
- switch(func) {
+ switch (func) {
case RS_DEPTH_FUNC_ALWAYS:
mDepthTestEnable = false;
mDepthFunc = GL_ALWAYS;
@@ -147,20 +133,18 @@
}
}
-void ProgramStore::setDepthMask(bool mask)
-{
+void ProgramStore::setDepthMask(bool mask) {
mDepthWriteEnable = mask;
}
-void ProgramStore::setBlendFunc(RsBlendSrcFunc src, RsBlendDstFunc dst)
-{
+void ProgramStore::setBlendFunc(RsBlendSrcFunc src, RsBlendDstFunc dst) {
mBlendEnable = true;
if ((src == RS_BLEND_SRC_ONE) &&
(dst == RS_BLEND_DST_ZERO)) {
mBlendEnable = false;
}
- switch(src) {
+ switch (src) {
case RS_BLEND_SRC_ZERO:
mBlendSrc = GL_ZERO;
break;
@@ -190,7 +174,7 @@
break;
}
- switch(dst) {
+ switch (dst) {
case RS_BLEND_DST_ZERO:
mBlendDst = GL_ZERO;
break;
@@ -218,81 +202,66 @@
}
}
-void ProgramStore::setColorMask(bool r, bool g, bool b, bool a)
-{
+void ProgramStore::setColorMask(bool r, bool g, bool b, bool a) {
mColorRWriteEnable = r;
mColorGWriteEnable = g;
mColorBWriteEnable = b;
mColorAWriteEnable = a;
}
-
-ProgramStoreState::ProgramStoreState()
-{
+ProgramStoreState::ProgramStoreState() {
mPFS = NULL;
}
-ProgramStoreState::~ProgramStoreState()
-{
+ProgramStoreState::~ProgramStoreState() {
ObjectBase::checkDelete(mPFS);
mPFS = NULL;
}
-void ProgramStoreState::init(Context *rsc)
-{
+void ProgramStoreState::init(Context *rsc) {
ProgramStore *pfs = new ProgramStore(rsc);
mDefault.set(pfs);
}
-void ProgramStoreState::deinit(Context *rsc)
-{
+void ProgramStoreState::deinit(Context *rsc) {
mDefault.clear();
mLast.clear();
}
-
namespace android {
namespace renderscript {
-void rsi_ProgramStoreBegin(Context * rsc, RsElement in, RsElement out)
-{
+void rsi_ProgramStoreBegin(Context * rsc, RsElement in, RsElement out) {
ObjectBase::checkDelete(rsc->mStateFragmentStore.mPFS);
rsc->mStateFragmentStore.mPFS = new ProgramStore(rsc);
}
-void rsi_ProgramStoreDepthFunc(Context *rsc, RsDepthFunc func)
-{
+void rsi_ProgramStoreDepthFunc(Context *rsc, RsDepthFunc func) {
rsc->mStateFragmentStore.mPFS->setDepthFunc(func);
}
-void rsi_ProgramStoreDepthMask(Context *rsc, bool mask)
-{
+void rsi_ProgramStoreDepthMask(Context *rsc, bool mask) {
rsc->mStateFragmentStore.mPFS->setDepthMask(mask);
}
-void rsi_ProgramStoreColorMask(Context *rsc, bool r, bool g, bool b, bool a)
-{
+void rsi_ProgramStoreColorMask(Context *rsc, bool r, bool g, bool b, bool a) {
rsc->mStateFragmentStore.mPFS->setColorMask(r, g, b, a);
}
-void rsi_ProgramStoreBlendFunc(Context *rsc, RsBlendSrcFunc src, RsBlendDstFunc dst)
-{
+void rsi_ProgramStoreBlendFunc(Context *rsc, RsBlendSrcFunc src, RsBlendDstFunc dst) {
rsc->mStateFragmentStore.mPFS->setBlendFunc(src, dst);
}
-RsProgramStore rsi_ProgramStoreCreate(Context *rsc)
-{
+RsProgramStore rsi_ProgramStoreCreate(Context *rsc) {
ProgramStore *pfs = rsc->mStateFragmentStore.mPFS;
pfs->incUserRef();
rsc->mStateFragmentStore.mPFS = 0;
return pfs;
}
-void rsi_ProgramStoreDither(Context *rsc, bool enable)
-{
+void rsi_ProgramStoreDither(Context *rsc, bool enable) {
rsc->mStateFragmentStore.mPFS->setDitherEnable(enable);
}
-
}
}
diff --git a/rsProgramStore.h b/rsProgramStore.h
index 95bcf3c..f8eb7cf 100644
--- a/rsProgramStore.h
+++ b/rsProgramStore.h
@@ -26,8 +26,7 @@
class ProgramStoreState;
-class ProgramStore : public Program
-{
+class ProgramStore : public Program {
public:
ProgramStore(Context *);
virtual ~ProgramStore();
@@ -64,8 +63,7 @@
bool mStencilTestEnable;
};
-class ProgramStoreState
-{
+class ProgramStoreState {
public:
ProgramStoreState();
~ProgramStoreState();
@@ -79,7 +77,6 @@
ProgramStore *mPFS;
};
-
}
}
#endif
diff --git a/rsProgramVertex.cpp b/rsProgramVertex.cpp
index 9ee2eeb..e165967 100644
--- a/rsProgramVertex.cpp
+++ b/rsProgramVertex.cpp
@@ -34,15 +34,13 @@
ProgramVertex::ProgramVertex(Context *rsc, const char * shaderText,
uint32_t shaderLength, const uint32_t * params,
- uint32_t paramLength) :
- Program(rsc, shaderText, shaderLength, params, paramLength)
-{
+ uint32_t paramLength)
+ : Program(rsc, shaderText, shaderLength, params, paramLength) {
init(rsc);
}
-ProgramVertex::~ProgramVertex()
-{
- if(mShaderID) {
+ProgramVertex::~ProgramVertex() {
+ if (mShaderID) {
mRSC->mShaderCache.cleanupVertex(mShaderID);
}
}
@@ -51,8 +49,7 @@
Program::loadShader(rsc, GL_VERTEX_SHADER);
}
-void ProgramVertex::createShader()
-{
+void ProgramVertex::createShader() {
if (mUserShader.length() > 1) {
appendUserConstants();
@@ -69,7 +66,7 @@
// Cannot be complex
rsAssert(!f->getFieldCount());
- switch(f->getComponent().getVectorSize()) {
+ switch (f->getComponent().getVectorSize()) {
case 1: mShader.append("attribute float ATTRIB_"); break;
case 2: mShader.append("attribute vec2 ATTRIB_"); break;
case 3: mShader.append("attribute vec3 ATTRIB_"); break;
@@ -89,8 +86,7 @@
}
}
-void ProgramVertex::setupGL2(Context *rsc, ProgramVertexState *state, ShaderCache *sc)
-{
+void ProgramVertex::setupGL2(Context *rsc, ProgramVertexState *state, ShaderCache *sc) {
//LOGE("sgl2 vtx1 %x", glGetError());
if ((state->mLast.get() == this) && !mDirty) {
return;
@@ -98,8 +94,8 @@
rsc->checkError("ProgramVertex::setupGL2 start");
- if(!isUserProgram()) {
- if(mConstants[0].get() == NULL) {
+ if (!isUserProgram()) {
+ if (mConstants[0].get() == NULL) {
LOGE("Unable to set fixed function emulation matrices because allocation is missing");
rsc->setError(RS_ERROR_BAD_SHADER, "Fixed function allocation missing");
return;
@@ -110,7 +106,7 @@
Matrix t;
t.load(&f[RS_PROGRAM_VERTEX_MODELVIEW_OFFSET]);
mvp.multiply(&t);
- for(uint32_t i = 0; i < 16; i ++) {
+ for (uint32_t i = 0; i < 16; i ++) {
f[RS_PROGRAM_VERTEX_MVP_OFFSET + i] = mvp.m[i];
}
}
@@ -122,14 +118,13 @@
rsc->checkError("ProgramVertex::setupGL2");
}
-void ProgramVertex::setProjectionMatrix(Context *rsc, const rsc_Matrix *m) const
-{
- if(isUserProgram()) {
+void ProgramVertex::setProjectionMatrix(Context *rsc, const rsc_Matrix *m) const {
+ if (isUserProgram()) {
LOGE("Attempting to set fixed function emulation matrix projection on user program");
rsc->setError(RS_ERROR_BAD_SHADER, "Cannot set emulation matrix on user shader");
return;
}
- if(mConstants[0].get() == NULL) {
+ if (mConstants[0].get() == NULL) {
LOGE("Unable to set fixed function emulation matrix projection because allocation is missing");
return;
}
@@ -138,14 +133,13 @@
mDirty = true;
}
-void ProgramVertex::setModelviewMatrix(Context *rsc, const rsc_Matrix *m) const
-{
- if(isUserProgram()) {
+void ProgramVertex::setModelviewMatrix(Context *rsc, const rsc_Matrix *m) const {
+ if (isUserProgram()) {
LOGE("Attempting to set fixed function emulation matrix modelview on user program");
rsc->setError(RS_ERROR_BAD_SHADER, "Cannot set emulation matrix on user shader");
return;
}
- if(mConstants[0].get() == NULL) {
+ if (mConstants[0].get() == NULL) {
LOGE("Unable to set fixed function emulation matrix modelview because allocation is missing");
rsc->setError(RS_ERROR_BAD_SHADER, "Fixed function allocation missing");
return;
@@ -155,14 +149,13 @@
mDirty = true;
}
-void ProgramVertex::setTextureMatrix(Context *rsc, const rsc_Matrix *m) const
-{
- if(isUserProgram()) {
+void ProgramVertex::setTextureMatrix(Context *rsc, const rsc_Matrix *m) const {
+ if (isUserProgram()) {
LOGE("Attempting to set fixed function emulation matrix texture on user program");
rsc->setError(RS_ERROR_BAD_SHADER, "Cannot set emulation matrix on user shader");
return;
}
- if(mConstants[0].get() == NULL) {
+ if (mConstants[0].get() == NULL) {
LOGE("Unable to set fixed function emulation matrix texture because allocation is missing");
rsc->setError(RS_ERROR_BAD_SHADER, "Fixed function allocation missing");
return;
@@ -172,14 +165,13 @@
mDirty = true;
}
-void ProgramVertex::getProjectionMatrix(Context *rsc, rsc_Matrix *m) const
-{
- if(isUserProgram()) {
+void ProgramVertex::getProjectionMatrix(Context *rsc, rsc_Matrix *m) const {
+ if (isUserProgram()) {
LOGE("Attempting to get fixed function emulation matrix projection on user program");
rsc->setError(RS_ERROR_BAD_SHADER, "Cannot get emulation matrix on user shader");
return;
}
- if(mConstants[0].get() == NULL) {
+ if (mConstants[0].get() == NULL) {
LOGE("Unable to get fixed function emulation matrix projection because allocation is missing");
rsc->setError(RS_ERROR_BAD_SHADER, "Fixed function allocation missing");
return;
@@ -188,9 +180,8 @@
memcpy(m, &f[RS_PROGRAM_VERTEX_PROJECTION_OFFSET], sizeof(rsc_Matrix));
}
-void ProgramVertex::transformToScreen(Context *rsc, float *v4out, const float *v3in) const
-{
- if(isUserProgram()) {
+void ProgramVertex::transformToScreen(Context *rsc, float *v4out, const float *v3in) const {
+ if (isUserProgram()) {
return;
}
float *f = static_cast<float *>(mConstants[0]->getPtr());
@@ -200,8 +191,7 @@
mvp.vectorMultiply(v4out, v3in);
}
-void ProgramVertex::init(Context *rsc)
-{
+void ProgramVertex::init(Context *rsc) {
uint32_t attribCount = 0;
uint32_t uniformCount = 0;
if (mUserShader.size() > 0) {
@@ -215,29 +205,23 @@
createShader();
}
-void ProgramVertex::serialize(OStream *stream) const
-{
-
+void ProgramVertex::serialize(OStream *stream) const {
}
-ProgramVertex *ProgramVertex::createFromStream(Context *rsc, IStream *stream)
-{
+ProgramVertex *ProgramVertex::createFromStream(Context *rsc, IStream *stream) {
return NULL;
}
///////////////////////////////////////////////////////////////////////
-ProgramVertexState::ProgramVertexState()
-{
+ProgramVertexState::ProgramVertexState() {
}
-ProgramVertexState::~ProgramVertexState()
-{
+ProgramVertexState::~ProgramVertexState() {
}
-void ProgramVertexState::init(Context *rsc)
-{
+void ProgramVertexState::init(Context *rsc) {
const Element *matrixElem = Element::create(rsc, RS_TYPE_MATRIX_4X4, RS_KIND_USER, false, 1);
const Element *f2Elem = Element::create(rsc, RS_TYPE_FLOAT_32, RS_KIND_USER, false, 2);
const Element *f3Elem = Element::create(rsc, RS_TYPE_FLOAT_32, RS_KIND_USER, false, 3);
@@ -286,11 +270,9 @@
mDefault.set(pv);
updateSize(rsc);
-
}
-void ProgramVertexState::updateSize(Context *rsc)
-{
+void ProgramVertexState::updateSize(Context *rsc) {
float *f = static_cast<float *>(mDefaultAlloc->getPtr());
Matrix m;
@@ -303,8 +285,7 @@
memcpy(&f[RS_PROGRAM_VERTEX_TEXTURE_OFFSET], m.m, sizeof(m));
}
-void ProgramVertexState::deinit(Context *rsc)
-{
+void ProgramVertexState::deinit(Context *rsc) {
mDefaultAlloc.clear();
mDefault.clear();
mLast.clear();
@@ -316,13 +297,11 @@
RsProgramVertex rsi_ProgramVertexCreate(Context *rsc, const char * shaderText,
uint32_t shaderLength, const uint32_t * params,
- uint32_t paramLength)
-{
+ uint32_t paramLength) {
ProgramVertex *pv = new ProgramVertex(rsc, shaderText, shaderLength, params, paramLength);
pv->incUserRef();
return pv;
}
-
}
}
diff --git a/rsProgramVertex.h b/rsProgramVertex.h
index 355df2b..824edbb 100644
--- a/rsProgramVertex.h
+++ b/rsProgramVertex.h
@@ -25,8 +25,7 @@
class ProgramVertexState;
-class ProgramVertex : public Program
-{
+class ProgramVertex : public Program {
public:
ProgramVertex(Context *,const char * shaderText, uint32_t shaderLength,
const uint32_t * params, uint32_t paramLength);
@@ -50,9 +49,7 @@
static ProgramVertex *createFromStream(Context *rsc, IStream *stream);
};
-
-class ProgramVertexState
-{
+class ProgramVertexState {
public:
ProgramVertexState();
~ProgramVertexState();
@@ -66,7 +63,6 @@
ObjectBaseRef<Allocation> mDefaultAlloc;
};
-
}
}
#endif
diff --git a/rsSampler.cpp b/rsSampler.cpp
index cbdc407..1d0d270 100644
--- a/rsSampler.cpp
+++ b/rsSampler.cpp
@@ -31,8 +31,7 @@
using namespace android::renderscript;
-Sampler::Sampler(Context *rsc) : ObjectBase(rsc)
-{
+Sampler::Sampler(Context *rsc) : ObjectBase(rsc) {
// Should not get called.
rsAssert(0);
}
@@ -43,8 +42,7 @@
RsSamplerValue wrapS,
RsSamplerValue wrapT,
RsSamplerValue wrapR,
- float aniso) : ObjectBase(rsc)
-{
+ float aniso) : ObjectBase(rsc) {
mMagFilter = magFilter;
mMinFilter = minFilter;
mWrapS = wrapS;
@@ -53,12 +51,10 @@
mAniso = aniso;
}
-Sampler::~Sampler()
-{
+Sampler::~Sampler() {
}
-void Sampler::setupGL(const Context *rsc, const Allocation *tex)
-{
+void Sampler::setupGL(const Context *rsc, const Allocation *tex) {
GLenum trans[] = {
GL_NEAREST, //RS_SAMPLER_NEAREST,
GL_LINEAR, //RS_SAMPLER_LINEAR,
@@ -96,57 +92,38 @@
}
float anisoValue = rsMin(rsc->ext_texture_max_aniso(), mAniso);
- if(rsc->ext_texture_max_aniso() > 1.0f) {
+ if (rsc->ext_texture_max_aniso() > 1.0f) {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisoValue);
}
rsc->checkError("Sampler::setupGL2 tex env");
}
-void Sampler::bindToContext(SamplerState *ss, uint32_t slot)
-{
+void Sampler::bindToContext(SamplerState *ss, uint32_t slot) {
ss->mSamplers[slot].set(this);
mBoundSlot = slot;
}
-void Sampler::unbindFromContext(SamplerState *ss)
-{
+void Sampler::unbindFromContext(SamplerState *ss) {
int32_t slot = mBoundSlot;
mBoundSlot = -1;
ss->mSamplers[slot].clear();
}
-void Sampler::serialize(OStream *stream) const
-{
-
+void Sampler::serialize(OStream *stream) const {
}
-Sampler *Sampler::createFromStream(Context *rsc, IStream *stream)
-{
+Sampler *Sampler::createFromStream(Context *rsc, IStream *stream) {
return NULL;
}
-/*
-void SamplerState::setupGL()
-{
- for (uint32_t ct=0; ct < RS_MAX_SAMPLER_SLOT; ct++) {
- Sampler *s = mSamplers[ct].get();
- if (s) {
- s->setupGL(rsc);
- } else {
- glBindTexture(GL_TEXTURE_2D, 0);
- }
- }
-}*/
-
////////////////////////////////
namespace android {
namespace renderscript {
-void rsi_SamplerBegin(Context *rsc)
-{
+void rsi_SamplerBegin(Context *rsc) {
SamplerState * ss = &rsc->mStateSampler;
ss->mMagFilter = RS_SAMPLER_LINEAR;
@@ -157,11 +134,10 @@
ss->mAniso = 1.0f;
}
-void rsi_SamplerSet(Context *rsc, RsSamplerParam param, RsSamplerValue value)
-{
+void rsi_SamplerSet(Context *rsc, RsSamplerParam param, RsSamplerValue value) {
SamplerState * ss = &rsc->mStateSampler;
- switch(param) {
+ switch (param) {
case RS_SAMPLER_MAG_FILTER:
ss->mMagFilter = value;
break;
@@ -183,11 +159,10 @@
}
}
-void rsi_SamplerSet2(Context *rsc, RsSamplerParam param, float value)
-{
+void rsi_SamplerSet2(Context *rsc, RsSamplerParam param, float value) {
SamplerState * ss = &rsc->mStateSampler;
- switch(param) {
+ switch (param) {
case RS_SAMPLER_ANISO:
ss->mAniso = value;
break;
@@ -197,8 +172,7 @@
}
}
-RsSampler rsi_SamplerCreate(Context *rsc)
-{
+RsSampler rsi_SamplerCreate(Context *rsc) {
SamplerState * ss = &rsc->mStateSampler;
Sampler * s = new Sampler(rsc,
@@ -212,5 +186,4 @@
return s;
}
-
}}
diff --git a/rsSampler.h b/rsSampler.h
index 4946355..737bb8b 100644
--- a/rsSampler.h
+++ b/rsSampler.h
@@ -28,8 +28,7 @@
class SamplerState;
-class Sampler : public ObjectBase
-{
+class Sampler : public ObjectBase {
public:
Sampler(Context *,
RsSamplerValue magFilter,
@@ -63,14 +62,11 @@
private:
Sampler(Context *);
-
};
-class SamplerState
-{
+class SamplerState {
public:
-
RsSamplerValue mMagFilter;
RsSamplerValue mMinFilter;
RsSamplerValue mWrapS;
@@ -78,15 +74,9 @@
RsSamplerValue mWrapR;
float mAniso;
-
ObjectBaseRef<Sampler> mSamplers[RS_MAX_SAMPLER_SLOT];
-
- //void setupGL();
-
};
-
-
}
}
#endif //ANDROID_RS_SAMPLER_H
diff --git a/rsScript.cpp b/rsScript.cpp
index ef380d2..4ffdbfd 100644
--- a/rsScript.cpp
+++ b/rsScript.cpp
@@ -19,35 +19,33 @@
using namespace android;
using namespace android::renderscript;
-Script::Script(Context *rsc) : ObjectBase(rsc)
-{
+Script::Script(Context *rsc) : ObjectBase(rsc) {
memset(&mEnviroment, 0, sizeof(mEnviroment));
mSlots = NULL;
mTypes = NULL;
}
-Script::~Script()
-{
- if(mSlots) {
+Script::~Script() {
+ if (mSlots) {
delete [] mSlots;
mSlots = NULL;
}
- if(mTypes) {
+ if (mTypes) {
delete [] mTypes;
mTypes = NULL;
}
}
void Script::initSlots() {
- if(mEnviroment.mFieldCount > 0) {
+ if (mEnviroment.mFieldCount > 0) {
mSlots = new ObjectBaseRef<Allocation>[mEnviroment.mFieldCount];
mTypes = new ObjectBaseRef<const Type>[mEnviroment.mFieldCount];
}
}
void Script::setSlot(uint32_t slot, Allocation *a) {
- if(slot >= mEnviroment.mFieldCount) {
+ if (slot >= mEnviroment.mFieldCount) {
LOGE("Script::setSlot unable to set allocation, invalid slot index");
return;
}
@@ -55,8 +53,7 @@
mSlots[slot].set(a);
}
-void Script::setVar(uint32_t slot, const void *val, uint32_t len)
-{
+void Script::setVar(uint32_t slot, const void *val, uint32_t len) {
int32_t *destPtr = ((int32_t **)mEnviroment.mFieldAddress)[slot];
if (destPtr) {
//LOGE("setVar f1 %f", ((const float *)destPtr)[0]);
@@ -73,72 +70,60 @@
namespace android {
namespace renderscript {
-
-void rsi_ScriptBindAllocation(Context * rsc, RsScript vs, RsAllocation va, uint32_t slot)
-{
+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);
//LOGE("rsi_ScriptBindAllocation %i %p %p", slot, a, a->getPtr());
}
-void rsi_ScriptSetTimeZone(Context * rsc, RsScript vs, const char * timeZone, uint32_t length)
-{
+void rsi_ScriptSetTimeZone(Context * rsc, RsScript vs, const char * timeZone, uint32_t length) {
Script *s = static_cast<Script *>(vs);
s->mEnviroment.mTimeZone = timeZone;
}
-void rsi_ScriptInvoke(Context *rsc, RsScript vs, uint32_t slot)
-{
+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)
-{
+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, uint32_t len)
-{
+void rsi_ScriptInvokeV(Context *rsc, RsScript vs, uint32_t slot, const void *data, uint32_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)
-{
+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_ScriptSetVarJ(Context *rsc, RsScript vs, uint32_t slot, long long value)
-{
+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)
-{
+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)
-{
+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, uint32_t len)
-{
+void rsi_ScriptSetVarV(Context *rsc, RsScript vs, uint32_t slot, const void *data, uint32_t len) {
const float *fp = (const float *)data;
Script *s = static_cast<Script *>(vs);
s->setVar(slot, data, len);
}
-
}
}
diff --git a/rsScript.h b/rsScript.h
index c73bb5e..9b6d8a9 100644
--- a/rsScript.h
+++ b/rsScript.h
@@ -29,8 +29,7 @@
class ProgramRaster;
class ProgramStore;
-class Script : public ObjectBase
-{
+class Script : public ObjectBase {
public:
typedef void (* InvokeFunc_t)(void);
@@ -79,7 +78,6 @@
};
-
}
}
#endif
diff --git a/rsScriptC.cpp b/rsScriptC.cpp
index c692bc1..033f316 100644
--- a/rsScriptC.cpp
+++ b/rsScriptC.cpp
@@ -33,14 +33,12 @@
ScriptC * sc = (ScriptC *) tls->mScript
-ScriptC::ScriptC(Context *rsc) : Script(rsc)
-{
+ScriptC::ScriptC(Context *rsc) : Script(rsc) {
mBccScript = NULL;
memset(&mProgram, 0, sizeof(mProgram));
}
-ScriptC::~ScriptC()
-{
+ScriptC::~ScriptC() {
if (mBccScript) {
bccDeleteScript(mBccScript);
}
@@ -48,8 +46,7 @@
mEnviroment.mScriptText = NULL;
}
-void ScriptC::setupScript(Context *rsc)
-{
+void ScriptC::setupScript(Context *rsc) {
setupGLState(rsc);
mEnviroment.mStartTimeMillis
= nanoseconds_to_milliseconds(systemTime(SYSTEM_TIME_MONOTONIC));
@@ -82,8 +79,7 @@
}
}
-const Allocation *ScriptC::ptrToAllocation(const void *ptr) const
-{
+const Allocation *ScriptC::ptrToAllocation(const void *ptr) const {
if (!ptr) {
return NULL;
}
@@ -98,8 +94,7 @@
return NULL;
}
-Script * ScriptC::setTLS(Script *sc)
-{
+Script * ScriptC::setTLS(Script *sc) {
Context::ScriptTLSStruct * tls = (Context::ScriptTLSStruct *)
pthread_getspecific(Context::gThreadTLSKey);
rsAssert(tls);
@@ -108,9 +103,7 @@
return old;
}
-
-void ScriptC::setupGLState(Context *rsc)
-{
+void ScriptC::setupGLState(Context *rsc) {
if (mEnviroment.mFragmentStore.get()) {
rsc->setFragmentStore(mEnviroment.mFragmentStore.get());
}
@@ -125,8 +118,7 @@
}
}
-uint32_t ScriptC::run(Context *rsc)
-{
+uint32_t ScriptC::run(Context *rsc) {
if (mProgram.mRoot == NULL) {
rsc->setError(RS_ERROR_BAD_SCRIPT, "Attempted to run bad script");
return 0;
@@ -151,7 +143,6 @@
return ret;
}
-
typedef struct {
Context *rsc;
ScriptC *script;
@@ -183,8 +174,7 @@
} MTLaunchStruct;
typedef int (*rs_t)(const void *, void *, const void *, uint32_t, uint32_t, uint32_t, uint32_t);
-static void wc_xy(void *usr, uint32_t idx)
-{
+static void wc_xy(void *usr, uint32_t idx) {
MTLaunchStruct *mtls = (MTLaunchStruct *)usr;
while (1) {
@@ -210,11 +200,9 @@
}
}
}
-
}
-static void wc_x(void *usr, uint32_t idx)
-{
+static void wc_x(void *usr, uint32_t idx) {
MTLaunchStruct *mtls = (MTLaunchStruct *)usr;
while (1) {
@@ -236,15 +224,13 @@
xPtrOut += mtls->eStrideOut;
}
}
-
}
void ScriptC::runForEach(Context *rsc,
const Allocation * ain,
Allocation * aout,
const void * usr,
- const RsScriptCall *sc)
-{
+ const RsScriptCall *sc) {
MTLaunchStruct mtls;
memset(&mtls, 0, sizeof(mtls));
@@ -295,7 +281,6 @@
setupScript(rsc);
Script * oldTLS = setTLS(this);
-
mtls.rsc = rsc;
mtls.ain = ain;
mtls.aout = aout;
@@ -350,8 +335,7 @@
setTLS(oldTLS);
}
-void ScriptC::Invoke(Context *rsc, uint32_t slot, const void *data, uint32_t len)
-{
+void ScriptC::Invoke(Context *rsc, uint32_t slot, const void *data, uint32_t len) {
//LOGE("rsi_ScriptInvoke %i", slot);
if ((slot >= mEnviroment.mInvokeFunctionCount) ||
(mEnviroment.mInvokeFunctions[slot] == NULL)) {
@@ -373,30 +357,25 @@
setTLS(oldTLS);
}
-ScriptCState::ScriptCState()
-{
+ScriptCState::ScriptCState() {
mScript.clear();
}
-ScriptCState::~ScriptCState()
-{
+ScriptCState::~ScriptCState() {
mScript.clear();
}
-void ScriptCState::init(Context *rsc)
-{
+void ScriptCState::init(Context *rsc) {
clear(rsc);
}
-void ScriptCState::clear(Context *rsc)
-{
+void ScriptCState::clear(Context *rsc) {
rsAssert(rsc);
mScript.clear();
mScript.set(new ScriptC(rsc));
}
-static BCCvoid* symbolLookup(BCCvoid* pContext, const BCCchar* name)
-{
+static BCCvoid* symbolLookup(BCCvoid* pContext, const BCCchar* name) {
const ScriptCState::SymbolTable_t *sym;
ScriptC *s = (ScriptC *)pContext;
sym = ScriptCState::lookupSymbol(name);
@@ -417,8 +396,7 @@
extern const char rs_runtime_lib_bc[];
extern unsigned rs_runtime_lib_bc_size;
-void ScriptCState::runCompiler(Context *rsc, ScriptC *s)
-{
+void ScriptCState::runCompiler(Context *rsc, ScriptC *s) {
{
StopWatch compileTimer("RenderScript compile time");
s->mBccScript = bccCreateScript();
@@ -437,7 +415,7 @@
}
bccGetExportFuncs(s->mBccScript, (BCCsizei*) &s->mEnviroment.mInvokeFunctionCount, 0, NULL);
- if(s->mEnviroment.mInvokeFunctionCount <= 0)
+ if (s->mEnviroment.mInvokeFunctionCount <= 0)
s->mEnviroment.mInvokeFunctions = NULL;
else {
s->mEnviroment.mInvokeFunctions = (Script::InvokeFunc_t*) calloc(s->mEnviroment.mInvokeFunctionCount, sizeof(Script::InvokeFunc_t));
@@ -445,7 +423,7 @@
}
bccGetExportVars(s->mBccScript, (BCCsizei*) &s->mEnviroment.mFieldCount, 0, NULL);
- if(s->mEnviroment.mFieldCount <= 0)
+ if (s->mEnviroment.mFieldCount <= 0)
s->mEnviroment.mFieldAddress = NULL;
else {
s->mEnviroment.mFieldAddress = (void **) calloc(s->mEnviroment.mFieldCount, sizeof(void *));
@@ -522,19 +500,15 @@
}
}
-
-
namespace android {
namespace renderscript {
-void rsi_ScriptCBegin(Context * rsc)
-{
+void rsi_ScriptCBegin(Context * rsc) {
ScriptCState *ss = &rsc->mScriptC;
ss->clear(rsc);
}
-void rsi_ScriptCSetText(Context *rsc, const char *text, uint32_t len)
-{
+void rsi_ScriptCSetText(Context *rsc, const char *text, uint32_t len) {
ScriptCState *ss = &rsc->mScriptC;
char *t = (char *)malloc(len + 1);
@@ -544,9 +518,7 @@
ss->mScript->mEnviroment.mScriptTextLength = len;
}
-
-RsScript rsi_ScriptCCreate(Context * rsc)
-{
+RsScript rsi_ScriptCCreate(Context * rsc) {
ScriptCState *ss = &rsc->mScriptC;
ObjectBaseRef<ScriptC> s(ss->mScript);
diff --git a/rsScriptC.h b/rsScriptC.h
index 86a7ad3..7ca33ac 100644
--- a/rsScriptC.h
+++ b/rsScriptC.h
@@ -28,9 +28,7 @@
namespace renderscript {
-
-class ScriptC : public Script
-{
+class ScriptC : public Script {
public:
typedef int (*RunScript_t)();
typedef void (*VoidFunc_t)();
@@ -73,8 +71,7 @@
Script * setTLS(Script *);
};
-class ScriptCState
-{
+class ScriptCState {
public:
ScriptCState();
~ScriptCState();
diff --git a/rsScriptC_Lib.cpp b/rsScriptC_Lib.cpp
index bb8e6a7..ab8d9d7 100644
--- a/rsScriptC_Lib.cpp
+++ b/rsScriptC_Lib.cpp
@@ -35,8 +35,7 @@
// Math routines
//////////////////////////////////////////////////////////////////////////////
-static float SC_sinf_fast(float x)
-{
+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;
@@ -53,8 +52,7 @@
return 0.2215f * (y * fabsf(y) - y) + y;
}
-static float SC_cosf_fast(float x)
-{
+static float SC_cosf_fast(float x) {
x += float(M_PI / 2);
const float A = 1.0f / (2.0f * M_PI);
@@ -73,31 +71,25 @@
return 0.2215f * (y * fabsf(y) - y) + y;
}
-
-static float SC_randf(float max)
-{
+static float SC_randf(float max) {
float r = (float)rand();
return r / RAND_MAX * max;
}
-static float SC_randf2(float min, float max)
-{
+static float SC_randf2(float min, float max) {
float r = (float)rand();
return r / RAND_MAX * (max - min) + min;
}
-static int SC_randi(int max)
-{
+static int SC_randi(int max) {
return (int)SC_randf(max);
}
-static int SC_randi2(int min, int max)
-{
+static int SC_randi2(int min, int max) {
return (int)SC_randf2(min, max);
}
-static float SC_frac(float v)
-{
+static float SC_frac(float v) {
int i = (int)floor(v);
return fmin(v - i, 0x1.fffffep-1f);
}
@@ -106,8 +98,7 @@
// Time routines
//////////////////////////////////////////////////////////////////////////////
-static int32_t SC_second()
-{
+static int32_t SC_second() {
GET_TLS();
time_t rawtime;
@@ -118,8 +109,7 @@
return timeinfo->tm_sec;
}
-static int32_t SC_minute()
-{
+static int32_t SC_minute() {
GET_TLS();
time_t rawtime;
@@ -130,8 +120,7 @@
return timeinfo->tm_min;
}
-static int32_t SC_hour()
-{
+static int32_t SC_hour() {
GET_TLS();
time_t rawtime;
@@ -142,8 +131,7 @@
return timeinfo->tm_hour;
}
-static int32_t SC_day()
-{
+static int32_t SC_day() {
GET_TLS();
time_t rawtime;
@@ -154,8 +142,7 @@
return timeinfo->tm_mday;
}
-static int32_t SC_month()
-{
+static int32_t SC_month() {
GET_TLS();
time_t rawtime;
@@ -166,8 +153,7 @@
return timeinfo->tm_mon;
}
-static int32_t SC_year()
-{
+static int32_t SC_year() {
GET_TLS();
time_t rawtime;
@@ -178,67 +164,57 @@
return timeinfo->tm_year;
}
-static int64_t SC_uptimeMillis()
-{
+static int64_t SC_uptimeMillis() {
return nanoseconds_to_milliseconds(systemTime(SYSTEM_TIME_MONOTONIC));
}
-static int64_t SC_uptimeNanos()
-{
+static int64_t SC_uptimeNanos() {
return systemTime(SYSTEM_TIME_MONOTONIC);
}
-static float SC_getDt()
-{
+static float SC_getDt() {
GET_TLS();
int64_t l = sc->mEnviroment.mLastDtTime;
sc->mEnviroment.mLastDtTime = systemTime(SYSTEM_TIME_MONOTONIC);
return ((float)(sc->mEnviroment.mLastDtTime - l)) / 1.0e9;
}
-
//////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////
-static uint32_t SC_allocGetDimX(RsAllocation va)
-{
+static uint32_t SC_allocGetDimX(RsAllocation va) {
const Allocation *a = static_cast<const Allocation *>(va);
CHECK_OBJ(a);
//LOGE("SC_allocGetDimX a=%p type=%p", a, a->getType());
return a->getType()->getDimX();
}
-static uint32_t SC_allocGetDimY(RsAllocation va)
-{
+static uint32_t SC_allocGetDimY(RsAllocation va) {
const Allocation *a = static_cast<const Allocation *>(va);
CHECK_OBJ(a);
return a->getType()->getDimY();
}
-static uint32_t SC_allocGetDimZ(RsAllocation va)
-{
+static uint32_t SC_allocGetDimZ(RsAllocation va) {
const Allocation *a = static_cast<const Allocation *>(va);
CHECK_OBJ(a);
return a->getType()->getDimZ();
}
-static uint32_t SC_allocGetDimLOD(RsAllocation va)
-{
+static uint32_t SC_allocGetDimLOD(RsAllocation va) {
const Allocation *a = static_cast<const Allocation *>(va);
CHECK_OBJ(a);
return a->getType()->getDimLOD();
}
-static uint32_t SC_allocGetDimFaces(RsAllocation va)
-{
+static uint32_t SC_allocGetDimFaces(RsAllocation va) {
const Allocation *a = static_cast<const Allocation *>(va);
CHECK_OBJ(a);
return a->getType()->getDimFaces();
}
-static const void * SC_getElementAtX(RsAllocation va, uint32_t x)
-{
+static const void * SC_getElementAtX(RsAllocation va, uint32_t x) {
const Allocation *a = static_cast<const Allocation *>(va);
CHECK_OBJ(a);
const Type *t = a->getType();
@@ -247,8 +223,7 @@
return &p[t->getElementSizeBytes() * x];
}
-static const void * SC_getElementAtXY(RsAllocation va, uint32_t x, uint32_t y)
-{
+static const void * SC_getElementAtXY(RsAllocation va, uint32_t x, uint32_t y) {
const Allocation *a = static_cast<const Allocation *>(va);
CHECK_OBJ(a);
const Type *t = a->getType();
@@ -257,8 +232,7 @@
return &p[t->getElementSizeBytes() * (x + y*t->getDimX())];
}
-static const void * SC_getElementAtXYZ(RsAllocation va, uint32_t x, uint32_t y, uint32_t z)
-{
+static const void * SC_getElementAtXYZ(RsAllocation va, uint32_t x, uint32_t y, uint32_t z) {
const Allocation *a = static_cast<const Allocation *>(va);
CHECK_OBJ(a);
const Type *t = a->getType();
@@ -280,6 +254,7 @@
*vdst = vsrc;
//LOGE("SC_setObject *");
}
+
static void SC_clearObject(void **vdst) {
//LOGE("SC_clearObject %p,%p", vdst, *vdst);
if (vdst[0]) {
@@ -289,12 +264,11 @@
*vdst = NULL;
//LOGE("SC_clearObject *");
}
+
static bool SC_isObject(RsAllocation vsrc) {
return vsrc != NULL;
}
-
-
static void SC_debugF(const char *s, float f) {
LOGE("%s %f, 0x%08x", s, f, *((int *) (&f)));
}
@@ -343,48 +317,41 @@
LOGE("%s %p", s, p);
}
-static uint32_t SC_toClient2(int cmdID, void *data, int len)
-{
+static uint32_t SC_toClient2(int cmdID, void *data, int len) {
GET_TLS();
//LOGE("SC_toClient %i %i %i", cmdID, len);
return rsc->sendMessageToClient(data, RS_MESSAGE_TO_CLIENT_USER, cmdID, len, false);
}
-static uint32_t SC_toClient(int cmdID)
-{
+static uint32_t SC_toClient(int cmdID) {
GET_TLS();
//LOGE("SC_toClient %i", cmdID);
return rsc->sendMessageToClient(NULL, RS_MESSAGE_TO_CLIENT_USER, cmdID, 0, false);
}
-static uint32_t SC_toClientBlocking2(int cmdID, void *data, int len)
-{
+static uint32_t SC_toClientBlocking2(int cmdID, void *data, int len) {
GET_TLS();
//LOGE("SC_toClientBlocking %i %i", cmdID, len);
return rsc->sendMessageToClient(data, RS_MESSAGE_TO_CLIENT_USER, cmdID, len, true);
}
-static uint32_t SC_toClientBlocking(int cmdID)
-{
+static uint32_t SC_toClientBlocking(int cmdID) {
GET_TLS();
//LOGE("SC_toClientBlocking %i", cmdID);
return rsc->sendMessageToClient(NULL, RS_MESSAGE_TO_CLIENT_USER, cmdID, 0, true);
}
-int SC_divsi3(int a, int b)
-{
+int SC_divsi3(int a, int b) {
return a / b;
}
-int SC_getAllocation(const void *ptr)
-{
+int SC_getAllocation(const void *ptr) {
GET_TLS();
const Allocation *alloc = sc->ptrToAllocation(ptr);
return (int)alloc;
}
-void SC_allocationMarkDirty(RsAllocation a)
-{
+void SC_allocationMarkDirty(RsAllocation a) {
Allocation *alloc = static_cast<Allocation *>(a);
alloc->sendDirty();
}
@@ -392,8 +359,7 @@
void SC_ForEach(RsScript vs,
RsAllocation vin,
RsAllocation vout,
- const void *usr)
-{
+ const void *usr) {
GET_TLS();
const Allocation *ain = static_cast<const Allocation *>(vin);
Allocation *aout = static_cast<Allocation *>(vout);
@@ -405,8 +371,7 @@
RsAllocation vin,
RsAllocation vout,
const void *usr,
- const RsScriptCall *call)
-{
+ const RsScriptCall *call) {
GET_TLS();
const Allocation *ain = static_cast<const Allocation *>(vin);
Allocation *aout = static_cast<Allocation *>(vout);
@@ -552,8 +517,7 @@
{ NULL, NULL, false }
};
-const ScriptCState::SymbolTable_t * ScriptCState::lookupSymbol(const char *sym)
-{
+const ScriptCState::SymbolTable_t * ScriptCState::lookupSymbol(const char *sym) {
ScriptCState::SymbolTable_t *syms = gSyms;
while (syms->mPtr) {
diff --git a/rsScriptC_LibCL.cpp b/rsScriptC_LibCL.cpp
index 7031f84..6c0e164 100644
--- a/rsScriptC_LibCL.cpp
+++ b/rsScriptC_LibCL.cpp
@@ -46,7 +46,6 @@
static float SC_exp10(float v) {
return pow(10.f, v);
-
}
static float SC_fract(float v, int *iptr) {
@@ -122,54 +121,42 @@
// Float util
//////////////////////////////////////////////////////////////////////////////
-static float SC_clamp_f32(float amount, float low, float high)
-{
+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)
-{
+static float SC_degrees(float radians) {
return radians * (180.f / M_PI);
}
-static float SC_max_f32(float v, float v2)
-{
+static float SC_max_f32(float v, float v2) {
return rsMax(v, v2);
}
-static float SC_min_f32(float v, float 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)
-{
+static float SC_mix_f32(float start, float stop, float amount) {
//LOGE("lerpf %f %f %f", start, stop, amount);
return start + (stop - start) * amount;
}
-static float SC_radians(float degrees)
-{
+static float SC_radians(float degrees) {
return degrees * (M_PI / 180.f);
}
-static float SC_step_f32(float edge, float v)
-{
+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)
-{
+static float SC_sign_f32(float value) {
if (value > 0) return 1.f;
if (value < 0) return -1.f;
return value;
}
-
-
-
-
//////////////////////////////////////////////////////////////////////////////
// Class implementation
//////////////////////////////////////////////////////////////////////////////
@@ -294,8 +281,7 @@
{ NULL, NULL, false }
};
-const ScriptCState::SymbolTable_t * ScriptCState::lookupSymbolCL(const char *sym)
-{
+const ScriptCState::SymbolTable_t * ScriptCState::lookupSymbolCL(const char *sym) {
ScriptCState::SymbolTable_t *syms = gSyms;
while (syms->mPtr) {
diff --git a/rsScriptC_LibGL.cpp b/rsScriptC_LibGL.cpp
index d877ebd..ef1475c 100644
--- a/rsScriptC_LibGL.cpp
+++ b/rsScriptC_LibGL.cpp
@@ -42,8 +42,7 @@
// Context
//////////////////////////////////////////////////////////////////////////////
-static void SC_bindTexture(RsProgramFragment vpf, uint32_t slot, RsAllocation va)
-{
+static void SC_bindTexture(RsProgramFragment vpf, uint32_t slot, RsAllocation va) {
CHECK_OBJ_OR_NULL(va);
CHECK_OBJ(vpf);
GET_TLS();
@@ -51,11 +50,9 @@
static_cast<ProgramFragment *>(vpf),
slot,
static_cast<Allocation *>(va));
-
}
-static void SC_bindSampler(RsProgramFragment vpf, uint32_t slot, RsSampler vs)
-{
+static void SC_bindSampler(RsProgramFragment vpf, uint32_t slot, RsSampler vs) {
CHECK_OBJ_OR_NULL(vs);
CHECK_OBJ(vpf);
GET_TLS();
@@ -63,32 +60,27 @@
static_cast<ProgramFragment *>(vpf),
slot,
static_cast<Sampler *>(vs));
-
}
-static void SC_bindProgramStore(RsProgramStore pfs)
-{
+static void SC_bindProgramStore(RsProgramStore pfs) {
CHECK_OBJ_OR_NULL(pfs);
GET_TLS();
rsi_ContextBindProgramStore(rsc, pfs);
}
-static void SC_bindProgramFragment(RsProgramFragment pf)
-{
+static void SC_bindProgramFragment(RsProgramFragment pf) {
CHECK_OBJ_OR_NULL(pf);
GET_TLS();
rsi_ContextBindProgramFragment(rsc, pf);
}
-static void SC_bindProgramVertex(RsProgramVertex pv)
-{
+static void SC_bindProgramVertex(RsProgramVertex pv) {
CHECK_OBJ_OR_NULL(pv);
GET_TLS();
rsi_ContextBindProgramVertex(rsc, pv);
}
-static void SC_bindProgramRaster(RsProgramRaster pv)
-{
+static void SC_bindProgramRaster(RsProgramRaster pv) {
CHECK_OBJ_OR_NULL(pv);
GET_TLS();
rsi_ContextBindProgramRaster(rsc, pv);
@@ -98,40 +90,33 @@
// VP
//////////////////////////////////////////////////////////////////////////////
-static void SC_vpLoadProjectionMatrix(const rsc_Matrix *m)
-{
+static void SC_vpLoadProjectionMatrix(const rsc_Matrix *m) {
GET_TLS();
rsc->getVertex()->setProjectionMatrix(rsc, m);
}
-static void SC_vpLoadModelMatrix(const rsc_Matrix *m)
-{
+static void SC_vpLoadModelMatrix(const rsc_Matrix *m) {
GET_TLS();
rsc->getVertex()->setModelviewMatrix(rsc, m);
}
-static void SC_vpLoadTextureMatrix(const rsc_Matrix *m)
-{
+static void SC_vpLoadTextureMatrix(const rsc_Matrix *m) {
GET_TLS();
rsc->getVertex()->setTextureMatrix(rsc, m);
}
-
-static void SC_pfConstantColor(RsProgramFragment vpf, float r, float g, float b, float a)
-{
+static void SC_pfConstantColor(RsProgramFragment vpf, float r, float g, float b, float a) {
GET_TLS();
CHECK_OBJ(vpf);
ProgramFragment *pf = static_cast<ProgramFragment *>(vpf);
pf->setConstantColor(rsc, r, g, b, a);
}
-static void SC_vpGetProjectionMatrix(rsc_Matrix *m)
-{
+static void SC_vpGetProjectionMatrix(rsc_Matrix *m) {
GET_TLS();
rsc->getVertex()->getProjectionMatrix(rsc, m);
}
-
//////////////////////////////////////////////////////////////////////////////
// Drawing
//////////////////////////////////////////////////////////////////////////////
@@ -143,8 +128,7 @@
float x3, float y3, float z3,
float u3, float v3,
float x4, float y4, float z4,
- float u4, float v4)
-{
+ float u4, float v4) {
GET_TLS();
if (!rsc->setupCheck()) {
return;
@@ -172,16 +156,14 @@
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)
-{
+ float x4, float y4, float z4) {
SC_drawQuadTexCoords(x1, y1, z1, 0, 1,
x2, y2, z2, 1, 1,
x3, y3, z3, 1, 0,
x4, y4, z4, 0, 0);
}
-static void SC_drawSpriteScreenspace(float x, float y, float z, float w, float h)
-{
+static void SC_drawSpriteScreenspace(float x, float y, float z, float w, float h) {
GET_TLS();
ObjectBaseRef<const ProgramVertex> tmp(rsc->getVertex());
rsc->setVertex(rsc->getDefaultProgramVertex());
@@ -228,8 +210,7 @@
*/
static void SC_drawRect(float x1, float y1,
- float x2, float y2, float z)
-{
+ float x2, float y2, float z) {
//LOGE("SC_drawRect %f,%f %f,%f %f", x1, y1, x2, y2, z);
SC_drawQuad(x1, y2, z,
x2, y2, z,
@@ -237,8 +218,7 @@
x1, y1, z);
}
-static void SC_drawMesh(RsMesh vsm)
-{
+static void SC_drawMesh(RsMesh vsm) {
CHECK_OBJ(vsm);
GET_TLS();
Mesh *sm = static_cast<Mesh *>(vsm);
@@ -248,8 +228,7 @@
sm->render(rsc);
}
-static void SC_drawMeshPrimitive(RsMesh vsm, uint32_t primIndex)
-{
+static void SC_drawMeshPrimitive(RsMesh vsm, uint32_t primIndex) {
CHECK_OBJ(vsm);
GET_TLS();
Mesh *sm = static_cast<Mesh *>(vsm);
@@ -259,8 +238,7 @@
sm->renderPrimitive(rsc, primIndex);
}
-static void SC_drawMeshPrimitiveRange(RsMesh vsm, uint32_t primIndex, uint32_t start, uint32_t len)
-{
+static void SC_drawMeshPrimitiveRange(RsMesh vsm, uint32_t primIndex, uint32_t start, uint32_t len) {
CHECK_OBJ(vsm);
GET_TLS();
Mesh *sm = static_cast<Mesh *>(vsm);
@@ -270,9 +248,9 @@
sm->renderPrimitiveRange(rsc, primIndex, start, len);
}
-static void SC_meshComputeBoundingBox(RsMesh vsm, float *minX, float *minY, float *minZ,
- float *maxX, float *maxY, float *maxZ)
-{
+static void SC_meshComputeBoundingBox(RsMesh vsm,
+ float *minX, float *minY, float *minZ,
+ float *maxX, float *maxY, float *maxZ) {
CHECK_OBJ(vsm);
GET_TLS();
Mesh *sm = static_cast<Mesh *>(vsm);
@@ -291,35 +269,31 @@
//////////////////////////////////////////////////////////////////////////////
-static void SC_color(float r, float g, float b, float a)
-{
+static void SC_color(float r, float g, float b, float a) {
GET_TLS();
ProgramFragment *pf = (ProgramFragment *)rsc->getFragment();
pf->setConstantColor(rsc, r, g, b, a);
}
-static void SC_uploadToTexture2(RsAllocation va, uint32_t baseMipLevel)
-{
+static void SC_uploadToTexture2(RsAllocation va, uint32_t baseMipLevel) {
CHECK_OBJ(va);
GET_TLS();
rsi_AllocationUploadToTexture(rsc, va, false, baseMipLevel);
}
-static void SC_uploadToTexture(RsAllocation va)
-{
+
+static void SC_uploadToTexture(RsAllocation va) {
CHECK_OBJ(va);
GET_TLS();
rsi_AllocationUploadToTexture(rsc, va, false, 0);
}
-static void SC_uploadToBufferObject(RsAllocation va)
-{
+static void SC_uploadToBufferObject(RsAllocation va) {
CHECK_OBJ(va);
GET_TLS();
rsi_AllocationUploadToBufferObject(rsc, va);
}
-static void SC_ClearColor(float r, float g, float b, float a)
-{
+static void SC_ClearColor(float r, float g, float b, float a) {
GET_TLS();
rsc->setupProgramStore();
@@ -327,8 +301,7 @@
glClear(GL_COLOR_BUFFER_BIT);
}
-static void SC_ClearDepth(float v)
-{
+static void SC_ClearDepth(float v) {
GET_TLS();
rsc->setupProgramStore();
@@ -336,20 +309,17 @@
glClear(GL_DEPTH_BUFFER_BIT);
}
-static uint32_t SC_getWidth()
-{
+static uint32_t SC_getWidth() {
GET_TLS();
return rsc->getWidth();
}
-static uint32_t SC_getHeight()
-{
+static uint32_t SC_getHeight() {
GET_TLS();
return rsc->getHeight();
}
-static void SC_DrawTextAlloc(RsAllocation va, int x, int y)
-{
+static void SC_DrawTextAlloc(RsAllocation va, int x, int y) {
CHECK_OBJ(va);
GET_TLS();
Allocation *alloc = static_cast<Allocation *>(va);
@@ -358,8 +328,7 @@
rsc->mStateFont.renderText(text, allocSize, x, y);
}
-static void SC_DrawText(const char *text, int x, int y)
-{
+static void SC_DrawText(const char *text, int x, int y) {
GET_TLS();
size_t textLen = strlen(text);
rsc->mStateFont.renderText(text, textLen, x, y);
@@ -367,26 +336,24 @@
static void SC_setMetrics(Font::Rect *metrics,
int32_t *left, int32_t *right,
- int32_t *top, int32_t *bottom)
-{
- if(left) {
+ int32_t *top, int32_t *bottom) {
+ if (left) {
*left = metrics->left;
}
- if(right) {
+ if (right) {
*right = metrics->right;
}
- if(top) {
+ if (top) {
*top = metrics->top;
}
- if(bottom) {
+ if (bottom) {
*bottom = metrics->bottom;
}
}
static void SC_MeasureTextAlloc(RsAllocation va,
int32_t *left, int32_t *right,
- int32_t *top, int32_t *bottom)
-{
+ int32_t *top, int32_t *bottom) {
CHECK_OBJ(va);
GET_TLS();
Allocation *alloc = static_cast<Allocation *>(va);
@@ -399,8 +366,7 @@
static void SC_MeasureText(const char *text,
int32_t *left, int32_t *right,
- int32_t *top, int32_t *bottom)
-{
+ int32_t *top, int32_t *bottom) {
GET_TLS();
size_t textLen = strlen(text);
Font::Rect metrics;
@@ -408,15 +374,13 @@
SC_setMetrics(&metrics, left, right, top, bottom);
}
-static void SC_BindFont(RsFont font)
-{
+static void SC_BindFont(RsFont font) {
CHECK_OBJ(font);
GET_TLS();
rsi_ContextBindFont(rsc, font);
}
-static void SC_FontColor(float r, float g, float b, float a)
-{
+static void SC_FontColor(float r, float g, float b, float a) {
GET_TLS();
rsc->mStateFont.setFontColor(r, g, b, a);
}
@@ -492,8 +456,7 @@
{ NULL, NULL, false }
};
-const ScriptCState::SymbolTable_t * ScriptCState::lookupSymbolGL(const char *sym)
-{
+const ScriptCState::SymbolTable_t * ScriptCState::lookupSymbolGL(const char *sym) {
ScriptCState::SymbolTable_t *syms = gSyms;
while (syms->mPtr) {
diff --git a/rsShaderCache.cpp b/rsShaderCache.cpp
index 193ced3..d254018 100644
--- a/rsShaderCache.cpp
+++ b/rsShaderCache.cpp
@@ -43,10 +43,10 @@
UniformQueryData **uniformList, uint32_t uniListSize) {
for (uint32_t ct=0; ct < prog->getUniformCount(); ct++) {
- if(data[ct].slot >= 0 && data[ct].arraySize > 1) {
+ 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) {
+ for (uint32_t ui = 0; ui < uniListSize; ui ++) {
+ if (prog->getUniformName(ct) == uniformList[ui]->name) {
data[ct].arraySize = (uint32_t)uniformList[ui]->arraySize;
break;
}
@@ -70,21 +70,20 @@
bool ShaderCache::hasArrayUniforms(ProgramVertex *vtx, ProgramFragment *frag) {
UniformData *data = mCurrent->vtxUniforms;
for (uint32_t ct=0; ct < vtx->getUniformCount(); ct++) {
- if(data[ct].slot >= 0 && data[ct].arraySize > 1) {
+ 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) {
+ if (data[ct].slot >= 0 && data[ct].arraySize > 1) {
return true;
}
}
return false;
}
-bool ShaderCache::lookup(Context *rsc, ProgramVertex *vtx, ProgramFragment *frag)
-{
+bool ShaderCache::lookup(Context *rsc, ProgramVertex *vtx, ProgramFragment *frag) {
if (!vtx->getShaderID()) {
vtx->loadShader(rsc);
}
@@ -93,12 +92,12 @@
}
// Don't try to cache if shaders failed to load
- if(!vtx->getShaderID() || !frag->getShaderID()) {
+ if (!vtx->getShaderID() || !frag->getShaderID()) {
return false;
}
//LOGV("ShaderCache lookup vtx %i, frag %i", vtx->getShaderID(), frag->getShaderID());
uint32_t entryCount = mEntries.size();
- for(uint32_t ct = 0; ct < entryCount; ct ++) {
+ for (uint32_t ct = 0; ct < entryCount; ct ++) {
if ((mEntries[ct]->vtx == vtx->getShaderID()) &&
(mEntries[ct]->frag == frag->getShaderID())) {
@@ -170,16 +169,16 @@
UniformQueryData **uniformList = NULL;
GLint numUniforms = 0;
bool hasArrays = hasArrayUniforms(vtx, frag);
- if(hasArrays) {
+ 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) {
+ 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++) {
+ 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,
@@ -199,8 +198,8 @@
uniformList, (uint32_t)numUniforms);
// Clean up the uniform data from GL
- if(uniformList != NULL) {
- for(uint32_t ct = 0; ct < (uint32_t)numUniforms; ct++) {
+ if (uniformList != NULL) {
+ for (uint32_t ct = 0; ct < (uint32_t)numUniforms; ct++) {
delete uniformList[ct];
}
delete[] uniformList;
@@ -216,17 +215,16 @@
int32_t ShaderCache::vtxAttribSlot(const String8 &attrName) const {
for (uint32_t ct=0; ct < mCurrent->vtxAttrCount; ct++) {
- if(attrName == mCurrent->vtxAttrs[ct].name) {
+ if (attrName == mCurrent->vtxAttrs[ct].name) {
return mCurrent->vtxAttrs[ct].slot;
}
}
return -1;
}
-void ShaderCache::cleanupVertex(uint32_t id)
-{
+void ShaderCache::cleanupVertex(uint32_t id) {
int32_t numEntries = (int32_t)mEntries.size();
- for(int32_t ct = 0; ct < numEntries; ct ++) {
+ for (int32_t ct = 0; ct < numEntries; ct ++) {
if (mEntries[ct]->vtx == id) {
glDeleteProgram(mEntries[ct]->program);
@@ -238,10 +236,9 @@
}
}
-void ShaderCache::cleanupFragment(uint32_t id)
-{
+void ShaderCache::cleanupFragment(uint32_t id) {
int32_t numEntries = (int32_t)mEntries.size();
- for(int32_t ct = 0; ct < numEntries; ct ++) {
+ for (int32_t ct = 0; ct < numEntries; ct ++) {
if (mEntries[ct]->frag == id) {
glDeleteProgram(mEntries[ct]->program);
@@ -253,7 +250,6 @@
}
}
-void ShaderCache::cleanupAll()
-{
+void ShaderCache::cleanupAll() {
}
diff --git a/rsShaderCache.h b/rsShaderCache.h
index 6b49e5f..3540366 100644
--- a/rsShaderCache.h
+++ b/rsShaderCache.h
@@ -27,8 +27,7 @@
// An element is a group of Components that occupies one cell in a structure.
-class ShaderCache
-{
+class ShaderCache {
public:
ShaderCache();
virtual ~ShaderCache();
@@ -56,12 +55,12 @@
UniformQueryData(uint32_t maxName) {
name = NULL;
nameLength = maxName;
- if(nameLength > 0 ) {
+ if (nameLength > 0 ) {
name = new char[nameLength];
}
}
~UniformQueryData() {
- if(name != NULL) {
+ if (name != NULL) {
delete[] name;
name = NULL;
}
@@ -80,26 +79,26 @@
uint32_t numFragUnis) : vtx(0), frag(0), program(0), vtxAttrCount(0),
vtxAttrs(0), vtxUniforms(0), fragUniforms(0) {
vtxAttrCount = numVtxAttr;
- if(numVtxAttr) {
+ if (numVtxAttr) {
vtxAttrs = new AttrData[numVtxAttr];
}
- if(numVtxUnis) {
+ if (numVtxUnis) {
vtxUniforms = new UniformData[numVtxUnis];
}
- if(numFragUnis) {
+ if (numFragUnis) {
fragUniforms = new UniformData[numFragUnis];
}
}
~ProgramEntry() {
- if(vtxAttrs) {
+ if (vtxAttrs) {
delete[] vtxAttrs;
vtxAttrs = NULL;
}
- if(vtxUniforms) {
+ if (vtxUniforms) {
delete[] vtxUniforms;
vtxUniforms = NULL;
}
- if(fragUniforms) {
+ if (fragUniforms) {
delete[] fragUniforms;
fragUniforms = NULL;
}
@@ -111,7 +110,6 @@
AttrData *vtxAttrs;
UniformData *vtxUniforms;
UniformData *fragUniforms;
-
};
Vector<ProgramEntry*> mEntries;
ProgramEntry *mCurrent;
diff --git a/rsSignal.cpp b/rsSignal.cpp
index 9239bfd..ccd20b9 100644
--- a/rsSignal.cpp
+++ b/rsSignal.cpp
@@ -20,19 +20,16 @@
using namespace android::renderscript;
-Signal::Signal()
-{
+Signal::Signal() {
mSet = true;
}
-Signal::~Signal()
-{
+Signal::~Signal() {
pthread_mutex_destroy(&mMutex);
pthread_cond_destroy(&mCondition);
}
-bool Signal::init()
-{
+bool Signal::init() {
int status = pthread_mutex_init(&mMutex, NULL);
if (status) {
LOGE("LocklessFifo mutex init failure");
@@ -49,8 +46,7 @@
return true;
}
-void Signal::set()
-{
+void Signal::set() {
int status;
status = pthread_mutex_lock(&mMutex);
@@ -72,8 +68,7 @@
}
}
-void Signal::wait()
-{
+void Signal::wait() {
int status;
status = pthread_mutex_lock(&mMutex);
diff --git a/rsStream.cpp b/rsStream.cpp
index 68241fa..49ed567 100644
--- a/rsStream.cpp
+++ b/rsStream.cpp
@@ -26,21 +26,18 @@
using namespace android;
using namespace android::renderscript;
-IStream::IStream(const uint8_t *buf, bool use64)
-{
+IStream::IStream(const uint8_t *buf, bool use64) {
mData = buf;
mPos = 0;
mUse64 = use64;
}
-void IStream::loadByteArray(void *dest, size_t numBytes)
-{
+void IStream::loadByteArray(void *dest, size_t numBytes) {
memcpy(dest, mData + mPos, numBytes);
mPos += numBytes;
}
-uint64_t IStream::loadOffset()
-{
+uint64_t IStream::loadOffset() {
uint64_t tmp;
if (mUse64) {
mPos = (mPos + 7) & (~7);
@@ -51,44 +48,37 @@
return loadU32();
}
-void IStream::loadString(String8 *s)
-{
+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)
-{
+OStream::OStream(uint64_t len, bool use64) {
mData = (uint8_t*)malloc(len);
mLength = len;
mPos = 0;
mUse64 = use64;
}
-OStream::~OStream()
-{
+OStream::~OStream() {
free(mData);
}
-void OStream::addByteArray(const void *src, size_t numBytes)
-{
+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) {
+ while (mPos + numBytes >= mLength) {
growSize();
}
memcpy(mData + mPos, src, numBytes);
mPos += numBytes;
}
-void OStream::addOffset(uint64_t v)
-{
+void OStream::addOffset(uint64_t v) {
if (mUse64) {
mPos = (mPos + 7) & (~7);
- if(mPos + sizeof(v) >= mLength) {
+ if (mPos + sizeof(v) >= mLength) {
growSize();
}
mData[mPos++] = (uint8_t)(v & 0xff);
@@ -99,28 +89,25 @@
mData[mPos++] = (uint8_t)((v >> 40) & 0xff);
mData[mPos++] = (uint8_t)((v >> 48) & 0xff);
mData[mPos++] = (uint8_t)((v >> 56) & 0xff);
- }
- else {
+ } else {
addU32(v);
}
}
-void OStream::addString(String8 *s)
-{
+void OStream::addString(String8 *s) {
uint32_t len = s->size();
addU32(len);
- if(mPos + len*sizeof(char) >= mLength) {
+ if (mPos + len*sizeof(char) >= mLength) {
growSize();
}
char *stringData = reinterpret_cast<char *>(&mData[mPos]);
- for(uint32_t i = 0; i < len; i ++) {
+ for (uint32_t i = 0; i < len; i ++) {
stringData[i] = s->string()[i];
}
mPos += len*sizeof(char);
}
-void OStream::growSize()
-{
+void OStream::growSize() {
uint8_t *newData = (uint8_t*)malloc(mLength*2);
memcpy(newData, mData, mLength*sizeof(uint8_t));
mLength = mLength * 2;
diff --git a/rsStream.h b/rsStream.h
index d401cd1..62bcf94 100644
--- a/rsStream.h
+++ b/rsStream.h
@@ -24,8 +24,7 @@
namespace android {
namespace renderscript {
-class IStream
-{
+class IStream {
public:
IStream(const uint8_t *, bool use64);
@@ -70,7 +69,7 @@
void reset() {
mPos = 0;
}
-
+
const uint8_t * getPtr() const {
return mData;
}
@@ -80,26 +79,25 @@
bool mUse64;
};
-class OStream
-{
+class OStream {
public:
OStream(uint64_t length, bool use64);
~OStream();
-
+
void align(uint32_t bytes) {
mPos = (mPos + (bytes - 1)) & (~(bytes - 1));
- if(mPos >= mLength) {
+ 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) {
+ if (mPos + sizeof(v) >= mLength) {
growSize();
}
mData[mPos++] = (uint8_t)(v & 0xff);
@@ -109,7 +107,7 @@
}
void addU32(uint32_t v) {
mPos = (mPos + 3) & (~3);
- if(mPos + sizeof(v) >= mLength) {
+ if (mPos + sizeof(v) >= mLength) {
growSize();
}
mData[mPos++] = (uint8_t)(v & 0xff);
@@ -119,14 +117,14 @@
}
void addU16(uint16_t v) {
mPos = (mPos + 1) & (~1);
- if(mPos + sizeof(v) >= mLength) {
+ 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) {
+ if (mPos + 1 >= mLength) {
growSize();
}
reinterpret_cast<uint8_t *>(&mData[mPos])[0] = v;
@@ -154,7 +152,7 @@
uint64_t mPos;
bool mUse64;
};
-
+
} // renderscript
} // android
diff --git a/rsThreadIO.cpp b/rsThreadIO.cpp
index 527b3d7..1c6c5ac 100644
--- a/rsThreadIO.cpp
+++ b/rsThreadIO.cpp
@@ -21,25 +21,21 @@
using namespace android;
using namespace android::renderscript;
-ThreadIO::ThreadIO()
-{
+ThreadIO::ThreadIO() {
mToCore.init(16 * 1024);
mToClient.init(1024);
}
-ThreadIO::~ThreadIO()
-{
+ThreadIO::~ThreadIO() {
}
-void ThreadIO::shutdown()
-{
+void ThreadIO::shutdown() {
mToCore.shutdown();
}
-bool ThreadIO::playCoreCommands(Context *con, bool waitForCommand)
-{
+bool ThreadIO::playCoreCommands(Context *con, bool waitForCommand) {
bool ret = false;
- while(!mToCore.isEmpty() || waitForCommand) {
+ while (!mToCore.isEmpty() || waitForCommand) {
uint32_t cmdID = 0;
uint32_t cmdSize = 0;
ret = true;
diff --git a/rsThreadIO.h b/rsThreadIO.h
index 95270f5..f9d0de7 100644
--- a/rsThreadIO.h
+++ b/rsThreadIO.h
@@ -42,7 +42,6 @@
LocklessCommandFifo mToClient;
intptr_t mToCoreRet;
-
};
diff --git a/rsType.cpp b/rsType.cpp
index cc07412..2a51335 100644
--- a/rsType.cpp
+++ b/rsType.cpp
@@ -25,15 +25,13 @@
using namespace android;
using namespace android::renderscript;
-Type::Type(Context *rsc) : ObjectBase(rsc)
-{
+Type::Type(Context *rsc) : ObjectBase(rsc) {
mLODs = 0;
mLODCount = 0;
clear();
}
-void Type::preDestroy()
-{
+void Type::preDestroy() {
for (uint32_t ct = 0; ct < mRSC->mStateType.mTypes.size(); ct++) {
if (mRSC->mStateType.mTypes[ct] == this) {
mRSC->mStateType.mTypes.removeAt(ct);
@@ -42,16 +40,14 @@
}
}
-Type::~Type()
-{
+Type::~Type() {
if (mLODs) {
delete [] mLODs;
mLODs = NULL;
}
}
-void Type::clear()
-{
+void Type::clear() {
if (mLODs) {
delete [] mLODs;
mLODs = NULL;
@@ -64,22 +60,18 @@
mElement.clear();
}
-TypeState::TypeState()
-{
+TypeState::TypeState() {
}
-TypeState::~TypeState()
-{
+TypeState::~TypeState() {
}
-size_t Type::getOffsetForFace(uint32_t face) const
-{
+size_t Type::getOffsetForFace(uint32_t face) const {
rsAssert(mFaces);
return 0;
}
-void Type::compute()
-{
+void Type::compute() {
uint32_t oldLODCount = mLODCount;
if (mDimLOD) {
uint32_t l2x = rsFindHighBit(mDimX) + 1;
@@ -92,7 +84,7 @@
mLODCount = 1;
}
if (mLODCount != oldLODCount) {
- if(mLODs){
+ if (mLODs){
delete [] mLODs;
}
mLODs = new LOD[mLODCount];
@@ -122,29 +114,25 @@
mTotalSizeBytes = offset;
}
-uint32_t Type::getLODOffset(uint32_t lod, uint32_t x) const
-{
+uint32_t Type::getLODOffset(uint32_t lod, uint32_t x) const {
uint32_t offset = mLODs[lod].mOffset;
offset += x * mElement->getSizeBytes();
return offset;
}
-uint32_t Type::getLODOffset(uint32_t lod, uint32_t x, uint32_t y) const
-{
+uint32_t Type::getLODOffset(uint32_t lod, uint32_t x, uint32_t y) const {
uint32_t offset = mLODs[lod].mOffset;
offset += (x + y * mLODs[lod].mX) * mElement->getSizeBytes();
return offset;
}
-uint32_t Type::getLODOffset(uint32_t lod, uint32_t x, uint32_t y, uint32_t z) const
-{
+uint32_t Type::getLODOffset(uint32_t lod, uint32_t x, uint32_t y, uint32_t z) const {
uint32_t offset = mLODs[lod].mOffset;
offset += (x + y*mLODs[lod].mX + z*mLODs[lod].mX*mLODs[lod].mY) * mElement->getSizeBytes();
return offset;
}
-void Type::dumpLOGV(const char *prefix) const
-{
+void Type::dumpLOGV(const char *prefix) const {
char buf[1024];
ObjectBase::dumpLOGV(prefix);
LOGV("%s Type: x=%i y=%i z=%i mip=%i face=%i", prefix, mDimX, mDimY, mDimZ, mDimLOD, mFaces);
@@ -152,8 +140,7 @@
mElement->dumpLOGV(buf);
}
-void Type::serialize(OStream *stream) const
-{
+void Type::serialize(OStream *stream) const {
// Need to identify ourselves
stream->addU32((uint32_t)getClassId());
@@ -170,11 +157,10 @@
stream->addU8((uint8_t)(mFaces ? 1 : 0));
}
-Type *Type::createFromStream(Context *rsc, IStream *stream)
-{
+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) {
+ if (classID != RS_A3D_CLASS_ID_TYPE) {
LOGE("type loading skipped due to invalid class id\n");
return NULL;
}
@@ -183,7 +169,7 @@
stream->loadString(&name);
Element *elem = Element::createFromStream(rsc, stream);
- if(!elem) {
+ if (!elem) {
return NULL;
}
@@ -195,8 +181,7 @@
return Type::getType(rsc, elem, x, y, z, lod != 0, faces !=0 );
}
-bool Type::getIsNp2() const
-{
+bool Type::getIsNp2() const {
uint32_t x = getDimX();
uint32_t y = getDimY();
uint32_t z = getDimZ();
@@ -214,7 +199,7 @@
}
bool Type::isEqual(const Type *other) const {
- if(other == NULL) {
+ if (other == NULL) {
return false;
}
if (other->getElement()->isEqual(getElement()) &&
@@ -230,8 +215,7 @@
Type * Type::getType(Context *rsc, const Element *e,
uint32_t dimX, uint32_t dimY, uint32_t dimZ,
- bool dimLOD, bool dimFaces)
-{
+ bool dimLOD, bool dimFaces) {
TypeState * stc = &rsc->mStateType;
ObjectBase::asyncLock();
@@ -267,14 +251,14 @@
return nt;
}
-Type * Type::cloneAndResize1D(Context *rsc, uint32_t dimX) const
-{
+Type * Type::cloneAndResize1D(Context *rsc, uint32_t dimX) const {
return getType(rsc, mElement.get(), dimX,
mDimY, mDimZ, mDimLOD, mFaces);
}
-Type * Type::cloneAndResize2D(Context *rsc, uint32_t dimX, uint32_t dimY) const
-{
+Type * Type::cloneAndResize2D(Context *rsc,
+ uint32_t dimX,
+ uint32_t dimY) const {
return getType(rsc, mElement.get(), dimX, dimY,
mDimZ, mDimLOD, mFaces);
}
@@ -289,8 +273,7 @@
}
RsType rsaTypeCreate(RsContext con, RsElement _e, uint32_t dimCount,
- const RsDimension *dims, const uint32_t *vals)
-{
+ const RsDimension *dims, const uint32_t *vals) {
Context *rsc = static_cast<Context *>(con);
Element *e = static_cast<Element *>(_e);
TypeState * stc = &rsc->mStateType;
@@ -302,7 +285,7 @@
uint32_t dimFaces = 0;
for (uint32_t ct=0; ct < dimCount; ct++) {
- switch(dims[ct]) {
+ switch (dims[ct]) {
case RS_DIMENSION_X: dimX = vals[ct]; break;
case RS_DIMENSION_Y: dimY = vals[ct]; break;
case RS_DIMENSION_Z: dimZ = vals[ct]; break;
@@ -318,8 +301,7 @@
return Type::getType(rsc, e, dimX, dimY, dimZ, dimLOD, dimFaces);
}
-void rsaTypeGetNativeData(RsContext con, RsType type, uint32_t *typeData, uint32_t typeDataSize)
-{
+void rsaTypeGetNativeData(RsContext con, RsType type, uint32_t *typeData, uint32_t typeDataSize) {
rsAssert(typeDataSize == 6);
// Pack the data in the follofing way mDimX; mDimY; mDimZ;
// mDimLOD; mDimFaces; mElement; into typeData
diff --git a/rsType.h b/rsType.h
index fd626ed..34498f0 100644
--- a/rsType.h
+++ b/rsType.h
@@ -25,12 +25,10 @@
namespace renderscript {
-class Type : public ObjectBase
-{
+class Type : public ObjectBase {
public:
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;}
diff --git a/rsUtils.h b/rsUtils.h
index 17feb22..0699b57 100644
--- a/rsUtils.h
+++ b/rsUtils.h
@@ -44,9 +44,9 @@
namespace renderscript {
#if 1
-#define rsAssert(v) do {if(!(v)) LOGE("rsAssert failed: %s, in %s at %i", #v, __FILE__, __LINE__);} while(0)
+#define rsAssert(v) do {if(!(v)) LOGE("rsAssert failed: %s, in %s at %i", #v, __FILE__, __LINE__);} while (0)
#else
-#define rsAssert(v) while(0)
+#define rsAssert(v) while (0)
#endif
typedef float rsvF_2 __attribute__ ((vector_size (8)));
@@ -79,8 +79,7 @@
}
template<typename T>
-T rsMax(T in1, T in2)
-{
+T rsMax(T in1, T in2) {
if (in1 < in2) {
return in2;
}
@@ -88,10 +87,9 @@
}
template<typename T>
-T rsFindHighBit(T val)
-{
+T rsFindHighBit(T val) {
uint32_t bit = 0;
- while(val > 1) {
+ while (val > 1) {
bit++;
val>>=1;
}
@@ -99,14 +97,12 @@
}
template<typename T>
-bool rsIsPow2(T val)
-{
+bool rsIsPow2(T val) {
return (val & (val-1)) == 0;
}
template<typename T>
-T rsHigherPow2(T v)
-{
+T rsHigherPow2(T v) {
if (rsIsPow2(v)) {
return v;
}
@@ -114,17 +110,14 @@
}
template<typename T>
-T rsLowerPow2(T v)
-{
+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)
-{
+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;
@@ -132,16 +125,14 @@
return t;
}
-static inline uint16_t rsBoxFilter565(uint16_t i1, uint16_t i2, uint16_t i3, uint16_t i4)
-{
+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)
-{
+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);
@@ -149,8 +140,6 @@
return (r >> 2) | ((g >> 2) << 8) | ((b >> 2) << 16) | ((a >> 2) << 24);
}
-
-
}
}
diff --git a/rsVertexArray.cpp b/rsVertexArray.cpp
index 8eb94d0..5062156 100644
--- a/rsVertexArray.cpp
+++ b/rsVertexArray.cpp
@@ -23,28 +23,22 @@
#include <OpenGL/gl.h>
#endif
-
using namespace android;
using namespace android::renderscript;
-
-VertexArray::VertexArray(const Attrib *attribs, uint32_t numAttribs)
-{
+VertexArray::VertexArray(const Attrib *attribs, uint32_t numAttribs) {
mAttribs = attribs;
mCount = numAttribs;
}
-VertexArray::~VertexArray()
-{
+VertexArray::~VertexArray() {
}
-VertexArray::Attrib::Attrib()
-{
+VertexArray::Attrib::Attrib() {
clear();
}
-void VertexArray::Attrib::clear()
-{
+void VertexArray::Attrib::clear() {
buffer = 0;
offset = 0;
type = 0;
@@ -55,8 +49,9 @@
name.setTo("");
}
-void VertexArray::Attrib::set(uint32_t type, uint32_t size, uint32_t stride, bool normalized, uint32_t offset, const char *name)
-{
+void VertexArray::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;
@@ -67,7 +62,7 @@
}
void VertexArray::logAttrib(uint32_t idx, uint32_t slot) const {
- if(idx == 0) {
+ if (idx == 0) {
LOGV("Starting vertex attribute binding");
}
LOGV("va %i: slot=%i name=%s buf=%i ptr=%p size=%i type=0x%x stride=0x%x norm=%i offset=0x%x",
@@ -82,8 +77,9 @@
mAttribs[idx].offset);
}
-void VertexArray::setupGL2(const Context *rsc, class VertexArrayState *state, ShaderCache *sc) const
-{
+void VertexArray::setupGL2(const Context *rsc,
+ class VertexArrayState *state,
+ ShaderCache *sc) const {
rsc->checkError("VertexArray::setupGL2 start");
for (uint32_t ct=1; ct <= 0xf/*state->mLastEnableCount*/; ct++) {
glDisableVertexAttribArray(ct);
@@ -92,10 +88,10 @@
rsc->checkError("VertexArray::setupGL2 disabled");
for (uint32_t ct=0; ct < mCount; ct++) {
int32_t slot = sc->vtxAttribSlot(mAttribs[ct].name);
- if(rsc->props.mLogShadersAttr) {
+ if (rsc->props.mLogShadersAttr) {
logAttrib(ct, slot);
}
- if(slot < 0) {
+ if (slot < 0) {
continue;
}
glEnableVertexAttribArray(slot);
diff --git a/rsVertexArray.h b/rsVertexArray.h
index c2d10e6..7bcfa68 100644
--- a/rsVertexArray.h
+++ b/rsVertexArray.h
@@ -27,8 +27,7 @@
class ShaderCache;
// An element is a group of Components that occupies one cell in a structure.
-class VertexArray
-{
+class VertexArray {
public:
class Attrib {
public:
diff --git a/rsg_ScriptJavaClass.cpp b/rsg_ScriptJavaClass.cpp
index 0169b98..a38553f 100644
--- a/rsg_ScriptJavaClass.cpp
+++ b/rsg_ScriptJavaClass.cpp
@@ -71,8 +71,7 @@
};
-static void genHeader(FILE *f, const char *packageName)
-{
+static void genHeader(FILE *f, const char *packageName) {
fprintf(f, "package %s;\n", packageName);
fprintf(f, "\n");
fprintf(f, "import android.renderscript.*;\n");
@@ -80,9 +79,8 @@
fprintf(f, "\n");
}
-static const char * RSTypeToJava(RsDataType dt)
-{
- switch(dt) {
+static const char * RSTypeToJava(RsDataType dt) {
+ switch (dt) {
//case RS_TYPE_FLOAT_16: return "float";
case RS_TYPE_FLOAT_32: return "float";
//case RS_TYPE_FLOAT_64: return "double";
@@ -112,9 +110,8 @@
return NULL;
}
-static const char * RSTypeToString(RsDataType dt)
-{
- switch(dt) {
+static const char * RSTypeToString(RsDataType dt) {
+ switch (dt) {
case RS_TYPE_FLOAT_16: return "F16";
case RS_TYPE_FLOAT_32: return "F32";
case RS_TYPE_FLOAT_64: return "F64";
@@ -144,8 +141,7 @@
return NULL;
}
-bool rsGenerateElementClass(const Element *e, const char *packageName, FILE *f)
-{
+bool rsGenerateElementClass(const Element *e, const char *packageName, FILE *f) {
genHeader(f, packageName);
fprintf(f, "class Element_%s {\n", e->name);
@@ -197,8 +193,7 @@
return true;
}
-bool rsGenerateElementClassFile(Element *e, const char *packageName)
-{
+bool rsGenerateElementClassFile(Element *e, const char *packageName) {
char buf[1024];
sprintf(buf, "Element_%s.java", e->name);
printf("Creating file %s \n", buf);
@@ -230,8 +225,7 @@
-int main(int argc, const char *argv)
-{
+int main(int argc, const char *argv) {
Element *u8 = new Element(RS_TYPE_UNSIGNED_8, 1);
Element *i32 = new Element(RS_TYPE_SIGNED_32, 1);
Element *f32 = new Element(RS_TYPE_FLOAT_32, 1);
@@ -262,6 +256,5 @@
printf("1\n");
rsGenerateElementClassFile(e_Pixel, "android");
rsGenerateElementClassFile(e_Params, "android");
-
}
diff --git a/rsg_generator.c b/rsg_generator.c
index f4e8c68..1e468bb 100644
--- a/rsg_generator.c
+++ b/rsg_generator.c
@@ -2,8 +2,7 @@
#include "spec.h"
#include <stdio.h>
-void printFileHeader(FILE *f)
-{
+void printFileHeader(FILE *f) {
fprintf(f, "/*\n");
fprintf(f, " * Copyright (C) 2010 The Android Open Source Project\n");
fprintf(f, " *\n");
@@ -21,14 +20,13 @@
fprintf(f, " */\n\n");
}
-void printVarType(FILE *f, const VarType *vt)
-{
+void printVarType(FILE *f, const VarType *vt) {
int ct;
if (vt->isConst) {
fprintf(f, "const ");
}
- switch(vt->type) {
+ switch (vt->type) {
case 0:
fprintf(f, "void");
break;
@@ -49,22 +47,21 @@
break;
}
- if(vt->ptrLevel) {
+ if (vt->ptrLevel) {
fprintf(f, " ");
- for(ct=0; ct < vt->ptrLevel; ct++) {
+ for (ct=0; ct < vt->ptrLevel; ct++) {
fprintf(f, "*");
}
}
- if(vt->name[0]) {
+ if (vt->name[0]) {
fprintf(f, " %s", vt->name);
}
}
-void printArgList(FILE *f, const ApiEntry * api, int assumePrevious)
-{
+void printArgList(FILE *f, const ApiEntry * api, int assumePrevious) {
int ct;
- for(ct=0; ct < api->paramCount; ct++) {
+ for (ct=0; ct < api->paramCount; ct++) {
if (ct || assumePrevious) {
fprintf(f, ", ");
}
@@ -72,23 +69,22 @@
}
}
-void printStructures(FILE *f)
-{
+void printStructures(FILE *f) {
int ct;
int ct2;
- for(ct=0; ct < apiCount; ct++) {
+ 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++) {
+ 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++) {
+ for (ct2=0; ct2 < api->paramCount; ct2++) {
fprintf(f, " ");
printVarType(f, &api->params[ct2]);
fprintf(f, ";\n");
@@ -97,8 +93,7 @@
}
}
-void printFuncDecl(FILE *f, const ApiEntry *api, const char *prefix, int addContext)
-{
+void printFuncDecl(FILE *f, const ApiEntry *api, const char *prefix, int addContext) {
printVarType(f, &api->ret);
fprintf(f, " %s%s (", prefix, api->name);
if (addContext) {
@@ -110,26 +105,23 @@
fprintf(f, ")");
}
-void printFuncDecls(FILE *f, const char *prefix, int addContext)
-{
+void printFuncDecls(FILE *f, const char *prefix, int addContext) {
int ct;
- for(ct=0; ct < apiCount; ct++) {
+ for (ct=0; ct < apiCount; ct++) {
printFuncDecl(f, &apis[ct], prefix, addContext);
fprintf(f, ";\n");
}
fprintf(f, "\n\n");
}
-void printPlaybackFuncs(FILE *f, const char *prefix)
-{
+void printPlaybackFuncs(FILE *f, const char *prefix) {
int ct;
- for(ct=0; ct < apiCount; ct++) {
+ for (ct=0; ct < apiCount; ct++) {
fprintf(f, "void %s%s (Context *, const void *);\n", prefix, apis[ct].name);
}
}
-void printApiCpp(FILE *f)
-{
+void printApiCpp(FILE *f) {
int ct;
int ct2;
@@ -144,7 +136,7 @@
fprintf(f, "#include \"rsHandcode.h\"\n");
fprintf(f, "\n");
- for(ct=0; ct < apiCount; ct++) {
+ for (ct=0; ct < apiCount; ct++) {
int needFlush = 0;
const ApiEntry * api = &apis[ct];
@@ -152,7 +144,7 @@
fprintf(f, "\n{\n");
if (api->handcodeApi) {
fprintf(f, " rsHCAPI_%s(rsc", api->name);
- for(ct2=0; ct2 < api->paramCount; ct2++) {
+ for (ct2=0; ct2 < api->paramCount; ct2++) {
const VarType *vt = &api->params[ct2];
fprintf(f, ", %s", vt->name);
}
@@ -163,7 +155,7 @@
fprintf(f, " RS_CMD_%s *cmd = static_cast<RS_CMD_%s *>(io->mToCore.reserve(sizeof(RS_CMD_%s)));\n", api->name, api->name, api->name);
fprintf(f, " uint32_t size = sizeof(RS_CMD_%s);\n", api->name);
- for(ct2=0; ct2 < api->paramCount; ct2++) {
+ for (ct2=0; ct2 < api->paramCount; ct2++) {
const VarType *vt = &api->params[ct2];
needFlush += vt->ptrLevel;
fprintf(f, " cmd->%s = %s;\n", vt->name, vt->name);
@@ -188,8 +180,7 @@
}
}
-void printPlaybackCpp(FILE *f)
-{
+void printPlaybackCpp(FILE *f) {
int ct;
int ct2;
@@ -204,7 +195,7 @@
fprintf(f, "#include \"rsHandcode.h\"\n");
fprintf(f, "\n");
- for(ct=0; ct < apiCount; ct++) {
+ for (ct=0; ct < apiCount; ct++) {
const ApiEntry * api = &apis[ct];
fprintf(f, "void rsp_%s(Context *con, const void *vp)\n", api->name);
@@ -219,7 +210,7 @@
fprintf(f, "con->mIO.mToCoreRet = (intptr_t)");
}
fprintf(f, "rsi_%s(con", api->name);
- for(ct2=0; ct2 < api->paramCount; ct2++) {
+ for (ct2=0; ct2 < api->paramCount; ct2++) {
const VarType *vt = &api->params[ct2];
fprintf(f, ",\n cmd->%s", vt->name);
}
@@ -230,7 +221,7 @@
fprintf(f, "RsPlaybackFunc gPlaybackFuncs[] = {\n");
fprintf(f, " NULL,\n");
- for(ct=0; ct < apiCount; ct++) {
+ for (ct=0; ct < apiCount; ct++) {
fprintf(f, " %s%s,\n", "rsp_", apis[ct].name);
}
fprintf(f, "};\n");
@@ -239,8 +230,7 @@
fprintf(f, "};\n");
}
-int main(int argc, char **argv)
-{
+int main(int argc, char **argv) {
if (argc != 3) {
fprintf(stderr, "usage: %s commandFile outFile\n", argv[0]);
return 1;
@@ -263,7 +253,7 @@
FILE *f = fopen(outFile, "w");
printFileHeader(f);
- switch(choice) {
+ switch (choice) {
case '0': // rsgApiStructs.h
{
fprintf(f, "\n");
diff --git a/scriptc/rs_core.rsh b/scriptc/rs_core.rsh
index 0e0532c..16482c1 100644
--- a/scriptc/rs_core.rsh
+++ b/scriptc/rs_core.rsh
@@ -736,11 +736,11 @@
static void
rsQuaternionSlerp(rs_quaternion *q, const rs_quaternion *q0, const rs_quaternion *q1, float t) {
- if(t <= 0.0f) {
+ if (t <= 0.0f) {
rsQuaternionSet(q, q0);
return;
}
- if(t >= 1.0f) {
+ if (t >= 1.0f) {
rsQuaternionSet(q, q1);
return;
}
@@ -750,7 +750,7 @@
rsQuaternionSet(&tempq1, q1);
float angle = rsQuaternionDot(q0, q1);
- if(angle < 0) {
+ if (angle < 0) {
rsQuaternionMultiply(&tempq0, -1.0f);
angle *= -1.0f;
}
@@ -762,13 +762,11 @@
float invSinTheta = 1.0f / sin(theta);
scale = sin(theta * (1.0f - t)) * invSinTheta;
invScale = sin(theta * t) * invSinTheta;
- }
- else {
+ } else {
scale = 1.0f - t;
invScale = t;
}
- }
- else {
+ } else {
rsQuaternionSet(&tempq1, tempq0.z, -tempq0.y, tempq0.x, -tempq0.w);
scale = sin(M_PI * (0.5f - t));
invScale = sin(M_PI * t);
@@ -870,27 +868,27 @@
float4 *near, float4 *far) {
float distToCenter = dot(left->xyz, sphere->xyz) + left->w;
- if(distToCenter < -sphere->w) {
+ if (distToCenter < -sphere->w) {
return false;
}
distToCenter = dot(right->xyz, sphere->xyz) + right->w;
- if(distToCenter < -sphere->w) {
+ if (distToCenter < -sphere->w) {
return false;
}
distToCenter = dot(top->xyz, sphere->xyz) + top->w;
- if(distToCenter < -sphere->w) {
+ if (distToCenter < -sphere->w) {
return false;
}
distToCenter = dot(bottom->xyz, sphere->xyz) + bottom->w;
- if(distToCenter < -sphere->w) {
+ if (distToCenter < -sphere->w) {
return false;
}
distToCenter = dot(near->xyz, sphere->xyz) + near->w;
- if(distToCenter < -sphere->w) {
+ if (distToCenter < -sphere->w) {
return false;
}
distToCenter = dot(far->xyz, sphere->xyz) + far->w;
- if(distToCenter < -sphere->w) {
+ if (distToCenter < -sphere->w) {
return false;
}
return true;