diff --git a/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java b/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java index 0afff34f3c612..53fb6462154c7 100644 --- a/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java +++ b/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java @@ -57,7 +57,7 @@ public class FountainRS { return; } int rate = (int)(pressure * pressure * 500.f); - if(rate > 500) { + if (rate > 500) { rate = 500; } if (rate > 0) { diff --git a/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java b/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java index 987bebe79bdc6..50a9707ea7faa 100644 --- a/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java +++ b/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java @@ -62,7 +62,7 @@ public class FountainView extends RSSurfaceView { @Override protected void onDetachedFromWindow() { - if(mRS != null) { + if (mRS != null) { mRS = null; destroyRenderScript(); } diff --git a/libs/rs/java/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java b/libs/rs/java/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java index 16f404f6997ef..c617759f60e0b 100644 --- a/libs/rs/java/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java +++ b/libs/rs/java/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java @@ -141,7 +141,7 @@ public class ImageProcessingActivity extends Activity 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 @@ public class ImageProcessingActivity extends Activity //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 @@ public class ImageProcessingActivity extends Activity 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 @@ public class ImageProcessingActivity extends Activity } } - 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 class ImageProcessingActivity extends Activity 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/libs/rs/java/ImageProcessing/src/com/android/rs/image/horizontal_blur.rs b/libs/rs/java/ImageProcessing/src/com/android/rs/image/horizontal_blur.rs index cfffac8ff5070..652ffd76dd3df 100644 --- a/libs/rs/java/ImageProcessing/src/com/android/rs/image/horizontal_blur.rs +++ b/libs/rs/java/ImageProcessing/src/com/android/rs/image/horizontal_blur.rs @@ -11,13 +11,13 @@ void root(const void *v_in, void *v_out, const void *usrData, uint32_t x, uint32 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/libs/rs/java/ImageProcessing/src/com/android/rs/image/threshold.rs b/libs/rs/java/ImageProcessing/src/com/android/rs/image/threshold.rs index d05ed6fabc38d..698540bb17509 100644 --- a/libs/rs/java/ImageProcessing/src/com/android/rs/image/threshold.rs +++ b/libs/rs/java/ImageProcessing/src/com/android/rs/image/threshold.rs @@ -48,7 +48,7 @@ static void computeGaussianWeights() { 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 @@ static void computeGaussianWeights() { //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 @@ static void copyInput() { 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/libs/rs/java/ImageProcessing/src/com/android/rs/image/vertical_blur.rs b/libs/rs/java/ImageProcessing/src/com/android/rs/image/vertical_blur.rs index d901d2add2b3a..fe4335415c274 100644 --- a/libs/rs/java/ImageProcessing/src/com/android/rs/image/vertical_blur.rs +++ b/libs/rs/java/ImageProcessing/src/com/android/rs/image/vertical_blur.rs @@ -66,13 +66,13 @@ void root(const void *v_in, void *v_out, const void *usrData, uint32_t x, uint32 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/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java index 1531d0924b3bb..954ec9613613d 100644 --- a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java +++ b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java @@ -71,15 +71,15 @@ public class SceneGraphRS { 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 @@ public class SceneGraphRS { 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/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphView.java b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphView.java index 9457fd7059fcf..1cabba1bd68cf 100644 --- a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphView.java +++ b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphView.java @@ -64,7 +64,7 @@ public class SceneGraphView extends RSSurfaceView { @Override protected void onDetachedFromWindow() { - if(mRS != null) { + if (mRS != null) { mRS = null; destroyRenderScript(); } diff --git a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SgTransform.java b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SgTransform.java index 8351f42b53a2e..f5484e29c4246 100644 --- a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SgTransform.java +++ b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SgTransform.java @@ -70,7 +70,7 @@ public class SgTransform { 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 class SgTransform { } 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/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java index edf40e9b0fd81..29c37287fc385 100644 --- a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java +++ b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java @@ -67,15 +67,15 @@ public class SimpleModelRS { 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 @@ public class SimpleModelRS { 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/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelView.java b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelView.java index 42530857a61ed..875c4bdf42cf0 100644 --- a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelView.java +++ b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelView.java @@ -64,7 +64,7 @@ public class SimpleModelView extends RSSurfaceView { @Override protected void onDetachedFromWindow() { - if(mRS != null) { + if (mRS != null) { mRS = null; destroyRenderScript(); } diff --git a/libs/rs/java/ModelViewer/src/com/android/modelviewer/transform.rs b/libs/rs/java/ModelViewer/src/com/android/modelviewer/transform.rs index e7c04de4eaf86..3c235d779ae48 100644 --- a/libs/rs/java/ModelViewer/src/com/android/modelviewer/transform.rs +++ b/libs/rs/java/ModelViewer/src/com/android/modelviewer/transform.rs @@ -28,7 +28,7 @@ typedef struct { 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 @@ void root(const void *v_in, void *v_out, const void *usrData, uint32_t x, uint32 //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 @@ void root(const void *v_in, void *v_out, const void *usrData, uint32_t x, uint32 //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/libs/rs/java/Samples/src/com/android/samples/RsListRS.java b/libs/rs/java/Samples/src/com/android/samples/RsListRS.java index ce9ab018c1e27..3aa20e8a08eea 100644 --- a/libs/rs/java/Samples/src/com/android/samples/RsListRS.java +++ b/libs/rs/java/Samples/src/com/android/samples/RsListRS.java @@ -109,7 +109,7 @@ public class RsListRS { int dx = mLastX - x; int dy = mLastY - y; - if(Math.abs(dy) <= 2) { + if (Math.abs(dy) <= 2) { dy = 0; } @@ -124,7 +124,7 @@ public class RsListRS { 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/libs/rs/java/Samples/src/com/android/samples/RsListView.java b/libs/rs/java/Samples/src/com/android/samples/RsListView.java index cd66fbb789277..21b58b1f15c2b 100644 --- a/libs/rs/java/Samples/src/com/android/samples/RsListView.java +++ b/libs/rs/java/Samples/src/com/android/samples/RsListView.java @@ -64,7 +64,7 @@ public class RsListView extends RSSurfaceView { @Override protected void onDetachedFromWindow() { - if(mRS != null) { + if (mRS != null) { mRS = null; destroyRenderScript(); } @@ -87,8 +87,7 @@ public class RsListView extends RSSurfaceView { 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/libs/rs/java/Samples/src/com/android/samples/RsRenderStatesRS.java b/libs/rs/java/Samples/src/com/android/samples/RsRenderStatesRS.java index dd2daa78dd96a..f0b69d1d26287 100644 --- a/libs/rs/java/Samples/src/com/android/samples/RsRenderStatesRS.java +++ b/libs/rs/java/Samples/src/com/android/samples/RsRenderStatesRS.java @@ -307,10 +307,9 @@ public class RsRenderStatesRS { 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/libs/rs/java/Samples/src/com/android/samples/RsRenderStatesView.java b/libs/rs/java/Samples/src/com/android/samples/RsRenderStatesView.java index c434c098ac39b..6893d206fe198 100644 --- a/libs/rs/java/Samples/src/com/android/samples/RsRenderStatesView.java +++ b/libs/rs/java/Samples/src/com/android/samples/RsRenderStatesView.java @@ -64,7 +64,7 @@ public class RsRenderStatesView extends RSSurfaceView { @Override protected void onDetachedFromWindow() { - if(mRS != null) { + if (mRS != null) { mRS = null; destroyRenderScript(); } diff --git a/libs/rs/java/Samples/src/com/android/samples/rslist.rs b/libs/rs/java/Samples/src/com/android/samples/rslist.rs index 01b37ab0a3a41..f29276a4efe2d 100644 --- a/libs/rs/java/Samples/src/com/android/samples/rslist.rs +++ b/libs/rs/java/Samples/src/com/android/samples/rslist.rs @@ -56,12 +56,12 @@ int root(int launchID) { 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/libs/rs/java/Samples/src/com/android/samples/rsrenderstates.rs b/libs/rs/java/Samples/src/com/android/samples/rsrenderstates.rs index 4f8eada1c2ee1..f26633df8cdc1 100644 --- a/libs/rs/java/Samples/src/com/android/samples/rsrenderstates.rs +++ b/libs/rs/java/Samples/src/com/android/samples/rsrenderstates.rs @@ -214,7 +214,7 @@ void displayBlendingSamples() { 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 @@ void displayBlendingSamples() { } 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 @@ void displayBlendingSamples() { } 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 @@ void displayCullingSamples() { // 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 @@ void setupCustomShaderLights() { 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 @@ void displayCustomShaderSamples() { // 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 @@ void displayCustomShaderSamples2() { // 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 @@ void displayAnisoSample() { 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 @@ void displayAnisoSample() { 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 @@ int root(int launchID) { rsgClearColor(0.2f, 0.2f, 0.2f, 0.0f); rsgClearDepth(1.0f); - switch(gDisplayMode) { + switch (gDisplayMode) { case 0: displayFontSamples(); break; diff --git a/libs/rs/rsAdapter.cpp b/libs/rs/rsAdapter.cpp index 1d1425c276cb2..2a705a1d50c04 100644 --- a/libs/rs/rsAdapter.cpp +++ b/libs/rs/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 @@ void * Adapter1D::getElement(uint32_t x) 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::subData(uint32_t xoff, uint32_t count, const void *data) } } -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(va); Allocation * alloc = static_cast(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(va); - switch(dim) { + switch (dim) { case RS_DIMENSION_X: rsAssert(!"Cannot contrain X in an 1D adapter"); return; @@ -122,14 +109,12 @@ void rsi_Adapter1DSetConstraint(Context *rsc, RsAdapter1D va, RsDimension dim, u } } -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(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(va); a->data(data); } @@ -139,26 +124,22 @@ void rsi_Adapter1DData(Context *rsc, RsAdapter1D va, const void *data) ////////////////////////// -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 @@ void * Adapter2D::getElement(uint32_t x, uint32_t y) const 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::subData(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, co } } -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 @@ Adapter2D *Adapter2D::createFromStream(Context *rsc, IStream *stream) 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(va); Allocation * alloc = static_cast(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(va); - switch(dim) { + switch (dim) { case RS_DIMENSION_X: rsAssert(!"Cannot contrain X in an 2D adapter"); return; @@ -243,14 +216,12 @@ void rsi_Adapter2DSetConstraint(Context *rsc, RsAdapter2D va, RsDimension dim, u } } -void rsi_Adapter2DData(Context *rsc, RsAdapter2D va, const void *data) -{ +void rsi_Adapter2DData(Context *rsc, RsAdapter2D va, const void *data) { Adapter2D * a = static_cast(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(va); a->subData(xoff, yoff, w, h, data); } diff --git a/libs/rs/rsAdapter.h b/libs/rs/rsAdapter.h index 449e7ad48a8d1..d150789c4a192 100644 --- a/libs/rs/rsAdapter.h +++ b/libs/rs/rsAdapter.h @@ -24,8 +24,7 @@ namespace android { 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 @@ protected: 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 @@ protected: uint32_t mFace; }; - } } #endif diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp index 28078fce36d81..23135e2103366 100644 --- a/libs/rs/rsAllocation.cpp +++ b/libs/rs/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) : ObjectBase(rsc) 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 @@ Allocation::Allocation(Context *rsc, const Type *type, void *bmp, 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 @@ void Allocation::init(Context *rsc, const Type *type) mPtr = NULL; } -Allocation::~Allocation() -{ +Allocation::~Allocation() { if (mUserBitmapCallback != NULL) { mUserBitmapCallback(mUserBitmapCallbackData); } else { @@ -103,29 +99,23 @@ Allocation::~Allocation() } } -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 @@ void Allocation::deferedUploadToTexture(const Context *rsc, bool genMipmap, uint mTextureGenMipmap = !mType->getDimLOD() && genMipmap; } -void Allocation::uploadToTexture(const Context *rsc) -{ +void Allocation::uploadToTexture(const Context *rsc) { //rsAssert(!mTextureId); mIsTexture = true; @@ -170,11 +159,11 @@ void Allocation::uploadToTexture(const Context *rsc) 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(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 @@ void Allocation::uploadToTexture(const Context *rsc) 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 @@ void Allocation::uploadToBufferObject(const Context *rsc) 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::uploadCheck(const Context *rsc) } -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 @@ void Allocation::data(Context *rsc, const void *data, uint32_t sizeBytes) 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(mPtr); ptr += eSize * xoff; @@ -286,8 +269,7 @@ void Allocation::subData(Context *rsc, uint32_t xoff, uint32_t count, const void } 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, } 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(mPtr); ptr += eSize * x; @@ -358,8 +338,7 @@ void Allocation::subElementData(Context *rsc, uint32_t x, const void *data, } 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(mPtr); ptr += eSize * (x + y * mType->getDimX()); @@ -401,13 +380,11 @@ void Allocation::subElementData(Context *rsc, uint32_t x, uint32_t y, 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 @@ void Allocation::removeProgramToDirty(const Program *p) 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 @@ void Allocation::dumpLOGV(const char *prefix) const 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 @@ void Allocation::serialize(OStream *stream) const 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 @@ Allocation *Allocation::createFromStream(Context *rsc, IStream *stream) 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 @@ Allocation *Allocation::createFromStream(Context *rsc, IStream *stream) 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(ptr); const Element *e = mType->getElement(); uint32_t stride = e->getSizeBytes(); @@ -511,8 +482,7 @@ void Allocation::incRefs(const void *ptr, size_t ct, size_t startOff) const } } -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(ptr); const Element *e = mType->getElement(); uint32_t stride = e->getSizeBytes(); @@ -525,12 +495,10 @@ void Allocation::decRefs(const void *ptr, size_t ct, size_t startOff) const } } -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 @@ void Allocation::resize1D(Context *rsc, uint32_t dimX) 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 @@ void Allocation::resize2D(Context *rsc, uint32_t dimX, uint32_t dimY) 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(va); alloc->deferedUploadToTexture(rsc, genmip, baseMipLevel); } -void rsi_AllocationUploadToBufferObject(Context *rsc, RsAllocation va) -{ +void rsi_AllocationUploadToBufferObject(Context *rsc, RsAllocation va) { Allocation *alloc = static_cast(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 mip565(const Adapter2D &out, const Adapter2D &in) } } -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 mip8888(const Adapter2D &out, const Adapter2D &in) } } -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 mip8(const Adapter2D &out, const Adapter2D &in) } } -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 @@ static void mip(const Adapter2D &out, const Adapter2D &in) 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(dst); const uint8_t *s = static_cast(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(dst); const uint8_t *s = static_cast(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 @@ static ElementConverter_t pickConverter(const Element *dst, const Element *src) #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(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(va); const Element *src = static_cast(_src); const Element *dst = texAlloc->getType()->getElement(); @@ -757,7 +709,7 @@ void rsi_AllocationUpdateFromBitmap(Context *rsc, RsAllocation va, RsElement _sr 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_AllocationUpdateFromBitmap(Context *rsc, RsAllocation va, RsElement _sr } } -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(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(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(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(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(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(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(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(va); a->resize2D(rsc, dimX, dimY); } @@ -821,24 +765,21 @@ void rsi_AllocationResize2D(Context *rsc, RsAllocation va, uint32_t dimX, uint32 } } -const void * rsaAllocationGetType(RsContext con, RsAllocation va) -{ +const void * rsaAllocationGetType(RsContext con, RsAllocation va) { Allocation *a = static_cast(va); a->getType()->incUserRef(); return a->getType(); } -RsAllocation rsaAllocationCreateTyped(RsContext con, RsType vtype) -{ +RsAllocation rsaAllocationCreateTyped(RsContext con, RsType vtype) { Context *rsc = static_cast(con); Allocation * alloc = new Allocation(rsc, static_cast(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(con); const Element *src = static_cast(_src); const Element *dst = static_cast(_dst); @@ -861,7 +802,7 @@ RsAllocation rsaAllocationCreateFromBitmap(RsContext con, uint32_t w, uint32_t h 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/libs/rs/rsAllocation.h b/libs/rs/rsAllocation.h index 12cf832594383..f9a0fc9765d1a 100644 --- a/libs/rs/rsAllocation.h +++ b/libs/rs/rsAllocation.h @@ -25,8 +25,7 @@ namespace renderscript { 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/libs/rs/rsAnimation.cpp b/libs/rs/rsAnimation.cpp index 6200715cd3ef2..6abda3c0cd140 100644 --- a/libs/rs/rsAnimation.cpp +++ b/libs/rs/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 @@ RsAnimation rsi_AnimationCreate(Context *rsc, 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/libs/rs/rsAnimation.h b/libs/rs/rsAnimation.h index 340314e215201..bff8d6f4c57ff 100644 --- a/libs/rs/rsAnimation.h +++ b/libs/rs/rsAnimation.h @@ -25,8 +25,7 @@ namespace android { namespace renderscript { -class Animation : public ObjectBase -{ +class Animation : public ObjectBase { public: ~Animation(); @@ -62,9 +61,6 @@ protected: float mInputMax; }; - - - } } #endif //ANDROID_STRUCTURED_ELEMENT_H diff --git a/libs/rs/rsComponent.cpp b/libs/rs/rsComponent.cpp index f51b23e96c363..81ade5d4f60fe 100644 --- a/libs/rs/rsComponent.cpp +++ b/libs/rs/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 @@ void Component::set(RsDataType dt, RsDataKind dk, bool norm, uint32_t vecSize) mIsSigned = false; mIsPixel = false; - switch(mKind) { + switch (mKind) { case RS_KIND_PIXEL_L: case RS_KIND_PIXEL_A: mIsPixel = true; @@ -74,7 +71,7 @@ void Component::set(RsDataType dt, RsDataKind dk, bool norm, uint32_t vecSize) break; } - switch(mType) { + switch (mType) { case RS_TYPE_NONE: return; case RS_TYPE_UNSIGNED_5_6_5: @@ -181,15 +178,11 @@ void Component::set(RsDataType dt, RsDataKind dk, bool norm, uint32_t vecSize) 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 @@ uint32_t Component::getGLType() const 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 @@ uint32_t Component::getGLFormat() const 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 @@ String8 Component::getGLSLType() const } } 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 @@ static const char * gKindStrings[] = { "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::dumpLOGV(const char *prefix) const } } -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/libs/rs/rsComponent.h b/libs/rs/rsComponent.h index a7750511454f3..1bb4ff4840718 100644 --- a/libs/rs/rsComponent.h +++ b/libs/rs/rsComponent.h @@ -25,8 +25,7 @@ namespace renderscript { // An element is a group of Components that occupies one cell in a structure. -class Component -{ +class Component { public: Component(); ~Component(); diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index 9d766b71a93fc..18bf9fa2655e7 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -107,8 +107,7 @@ void printEGLConfiguration(EGLDisplay dpy, EGLConfig config) { } -bool Context::initGLThread() -{ +bool Context::initGLThread() { pthread_mutex_lock(&gInitMutex); LOGV("initGLThread start %p", this); @@ -239,7 +238,7 @@ bool Context::initGLThread() 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 @@ bool Context::initGLThread() return true; } -void Context::deinitEGL() -{ +void Context::deinitEGL() { LOGV("%p, deinitEGL", this); if (mEGL.mContext != EGL_NO_CONTEXT) { @@ -265,8 +263,7 @@ void Context::deinitEGL() } -uint32_t Context::runScript(Script *s) -{ +uint32_t Context::runScript(Script *s) { ObjectBaseRef frag(mFragment); ObjectBaseRef vtx(mVertex); ObjectBaseRef store(mFragmentStore); @@ -283,16 +280,14 @@ uint32_t Context::runScript(Script *s) 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 @@ uint32_t Context::runRootScript() 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 @@ void Context::timerInit() 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::timerFrame() } } -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 @@ void Context::timerPrint() } } -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 @@ void Context::setupProgramStore() { 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 @@ void Context::displayDebugStats() mStateFont.setFontColor(oldR, oldG, oldB, oldA); } -void * Context::threadProc(void *vrsc) -{ +void * Context::threadProc(void *vrsc) { Context *rsc = static_cast(vrsc); rsc->mNativeThreadId = gettid(); @@ -479,7 +464,7 @@ void * Context::threadProc(void *vrsc) if (mDraw && rsc->mIsGraphicsContext) { targetTime = rsc->runRootScript(); - if(rsc->props.mLogVisual) { + if (rsc->props.mLogVisual) { rsc->displayDebugStats(); } @@ -526,8 +511,7 @@ void * Context::threadProc(void *vrsc) return NULL; } -void * Context::helperThreadProc(void *vrsc) -{ +void * Context::helperThreadProc(void *vrsc) { Context *rsc = static_cast(vrsc); uint32_t idx = (uint32_t)android_atomic_inc(&rsc->mWorkers.mLaunchCount); @@ -552,7 +536,7 @@ void * Context::helperThreadProc(void *vrsc) 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 @@ void * Context::helperThreadProc(void *vrsc) 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 @@ void Context::setPriority(int32_t p) #endif } -Context::Context() -{ +Context::Context() { mDev = NULL; mRunning = false; mExit = false; @@ -612,8 +593,7 @@ Context::Context() 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 @@ Context * Context::createContext(Device *dev, const RsSurfaceConfig *sc) 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 @@ bool Context::initContext(Device *dev, const RsSurfaceConfig *sc) 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 @@ bool Context::initContext(Device *dev, const RsSurfaceConfig *sc) return true; } -Context::~Context() -{ +Context::~Context() { LOGV("Context::~Context"); mExit = true; mPaused = false; @@ -726,8 +704,7 @@ Context::~Context() 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::setSurface(uint32_t w, uint32_t h, ANativeWindow *sur) } } -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::setFragmentStore(ProgramStore *pfs) } } -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::setFragment(ProgramFragment *pf) } } -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::setRaster(ProgramRaster *pr) } } -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::setVertex(ProgramVertex *pv) } } -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::setFont(Font *f) } } -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 @@ void Context::removeName(ObjectBase *obj) } } -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 @@ RsMessageToClientType Context::peekMessageToClient(size_t *receiveLen, uint32_t 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 @@ RsMessageToClientType Context::getMessageToClient(void *data, size_t *receiveLen 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 @@ bool Context::sendMessageToClient(const void *data, RsMessageToClientType cmdID, 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 @@ const char * Context::getError(RsError *err) 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 @@ void Context::dumpDebug() const 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