summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
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)