summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-08-03 16:23:07 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2009-08-03 16:23:07 -0700
commit9df76c7c2f94cf3a66a61b28432b7c5d68869255 (patch)
tree4f5fc5985c51bfccaad47108027055ffc0c83eef /libs
parent8a173f7632c517965f2f482a5a01c514907a076e (diff)
parentbd1c3ad0cdf8e60b849a009cdc0b36764cc1dacb (diff)
downloadframeworks_base-9df76c7c2f94cf3a66a61b28432b7c5d68869255.zip
frameworks_base-9df76c7c2f94cf3a66a61b28432b7c5d68869255.tar.gz
frameworks_base-9df76c7c2f94cf3a66a61b28432b7c5d68869255.tar.bz2
Merge change 9551
* changes: Implement the jni bindings for Adapter2D. Fix a refcount bug in the native adapter implementation. Use adapters in Film to border the mipmaps.
Diffstat (limited to 'libs')
-rw-r--r--libs/rs/java/Film/src/com/android/film/FilmRS.java17
-rw-r--r--libs/rs/rsAdapter.cpp16
2 files changed, 27 insertions, 6 deletions
diff --git a/libs/rs/java/Film/src/com/android/film/FilmRS.java b/libs/rs/java/Film/src/com/android/film/FilmRS.java
index 777a7cf..eda7624 100644
--- a/libs/rs/java/Film/src/com/android/film/FilmRS.java
+++ b/libs/rs/java/Film/src/com/android/film/FilmRS.java
@@ -28,6 +28,7 @@ import android.renderscript.ProgramVertexAlloc;
import android.renderscript.RenderScript;
import android.renderscript.Element;
import android.renderscript.Allocation;
+import android.renderscript.Dimension;
public class FilmRS {
private final int POS_TRANSLATE = 0;
@@ -175,7 +176,23 @@ public class FilmRS {
mImages[11] = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.p12, ie, true);
mImages[12] = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.p13, ie, true);
+ int black[] = new int[1024];
for(int ct=0; ct < mImages.length; ct++) {
+ Allocation.Adapter2D a = mImages[ct].createAdapter2D();
+
+ int size = 512;
+ int mip = 0;
+ while(size >= 2) {
+ a.subData(0, 0, 2, size, black);
+ a.subData(size-2, 0, 2, size, black);
+ a.subData(0, 0, size, 2, black);
+ a.subData(0, size-2, size, 2, black);
+ size >>= 1;
+ mip++;
+ a.setConstraint(Dimension.LOD, mip);
+ }
+ a.destroy();
+
mImages[ct].uploadToTexture(1);
mBufferIDs[ct] = mImages[ct].getID();
}
diff --git a/libs/rs/rsAdapter.cpp b/libs/rs/rsAdapter.cpp
index 7ac2aed..25f3340 100644
--- a/libs/rs/rsAdapter.cpp
+++ b/libs/rs/rsAdapter.cpp
@@ -61,8 +61,8 @@ void Adapter1D::subData(uint32_t xoff, uint32_t count, const void *data)
void Adapter1D::data(const void *data)
{
- memcpy(getElement(0),
- data,
+ memcpy(getElement(0),
+ data,
mAllocation.get()->getType()->getSizeBytes());
}
@@ -71,7 +71,9 @@ namespace renderscript {
RsAdapter1D rsi_Adapter1DCreate(Context *rsc)
{
- return new Adapter1D();
+ Adapter1D *a = new Adapter1D();
+ a->incRef();
+ return a;
}
void rsi_Adapter1DDestroy(Context *rsc, RsAdapter1D va)
@@ -176,8 +178,8 @@ void Adapter2D::subData(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, co
void Adapter2D::data(const void *data)
{
- memcpy(getElement(0,0),
- data,
+ memcpy(getElement(0,0),
+ data,
mAllocation.get()->getType()->getSizeBytes());
}
@@ -188,7 +190,9 @@ namespace renderscript {
RsAdapter2D rsi_Adapter2DCreate(Context *rsc)
{
- return new Adapter2D();
+ Adapter2D *a = new Adapter2D();
+ a->incRef();
+ return a;
}
void rsi_Adapter2DDestroy(Context *rsc, RsAdapter2D va)