summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
Diffstat (limited to 'libs')
-rw-r--r--libs/rs/Android.mk4
-rw-r--r--libs/rs/RenderScript.h3
-rw-r--r--libs/rs/java/Film/src/com/android/film/FilmRS.java4
-rw-r--r--libs/rs/java/Film/src/com/android/film/FilmView.java3
-rw-r--r--libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java4
-rw-r--r--libs/rs/java/Fountain/src/com/android/fountain/FountainView.java3
-rw-r--r--libs/rs/java/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java5
-rw-r--r--libs/rs/rsContext.cpp76
-rw-r--r--libs/rs/rsContext.h3
-rw-r--r--libs/rs/rsVertexArray.cpp3
-rw-r--r--libs/surfaceflinger/SurfaceFlinger.cpp96
-rw-r--r--libs/surfaceflinger/SurfaceFlinger.h10
-rw-r--r--libs/ui/CameraParameters.cpp2
13 files changed, 142 insertions, 74 deletions
diff --git a/libs/rs/Android.mk b/libs/rs/Android.mk
index 88521f6..98464a0 100644
--- a/libs/rs/Android.mk
+++ b/libs/rs/Android.mk
@@ -110,5 +110,9 @@ LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
+# include the java examples
+include $(addprefix $(LOCAL_PATH)/,$(addsuffix /Android.mk,\
+ java \
+ ))
endif #simulator
diff --git a/libs/rs/RenderScript.h b/libs/rs/RenderScript.h
index 6662333..02667d8 100644
--- a/libs/rs/RenderScript.h
+++ b/libs/rs/RenderScript.h
@@ -55,7 +55,8 @@ RsDevice rsDeviceCreate();
void rsDeviceDestroy(RsDevice);
void rsDeviceSetConfig(RsDevice, RsDeviceParam, int32_t value);
-RsContext rsContextCreate(RsDevice, uint32_t version, bool useDepth);
+RsContext rsContextCreate(RsDevice, uint32_t version);
+RsContext rsContextCreateGL(RsDevice, uint32_t version, bool useDepth);
void rsContextDestroy(RsContext);
void rsObjDestroyOOB(RsContext, void *);
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 b80e619..7d04502 100644
--- a/libs/rs/java/Film/src/com/android/film/FilmRS.java
+++ b/libs/rs/java/Film/src/com/android/film/FilmRS.java
@@ -40,7 +40,7 @@ public class FilmRS {
public FilmRS() {
}
- public void init(RenderScript rs, Resources res, int width, int height) {
+ public void init(RenderScriptGL rs, Resources res, int width, int height) {
mRS = rs;
mRes = res;
initRS();
@@ -65,7 +65,7 @@ public class FilmRS {
private Resources mRes;
- private RenderScript mRS;
+ private RenderScriptGL mRS;
private Script mScriptStrip;
private Script mScriptImage;
private Sampler mSampler;
diff --git a/libs/rs/java/Film/src/com/android/film/FilmView.java b/libs/rs/java/Film/src/com/android/film/FilmView.java
index 4a201fd..5bc2811 100644
--- a/libs/rs/java/Film/src/com/android/film/FilmView.java
+++ b/libs/rs/java/Film/src/com/android/film/FilmView.java
@@ -22,6 +22,7 @@ import java.util.concurrent.Semaphore;
import android.renderscript.RSSurfaceView;
import android.renderscript.RenderScript;
+import android.renderscript.RenderScriptGL;
import android.content.Context;
import android.content.res.Resources;
@@ -45,7 +46,7 @@ public class FilmView extends RSSurfaceView {
//setFocusable(true);
}
- private RenderScript mRS;
+ private RenderScriptGL mRS;
private FilmRS mRender;
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 71f95a7..9356579 100644
--- a/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java
+++ b/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java
@@ -37,7 +37,7 @@ public class FountainRS {
public FountainRS() {
}
- public void init(RenderScript rs, Resources res, int width, int height) {
+ public void init(RenderScriptGL rs, Resources res, int width, int height) {
mRS = rs;
mRes = res;
initRS();
@@ -65,7 +65,7 @@ public class FountainRS {
private Resources mRes;
- private RenderScript mRS;
+ private RenderScriptGL mRS;
private Allocation mIntAlloc;
private SimpleMesh mSM;
private SomeData mSD;
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 fcb93f4..dfd6a49 100644
--- a/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java
+++ b/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java
@@ -22,6 +22,7 @@ import java.util.concurrent.Semaphore;
import android.renderscript.RSSurfaceView;
import android.renderscript.RenderScript;
+import android.renderscript.RenderScriptGL;
import android.content.Context;
import android.content.res.Resources;
@@ -45,7 +46,7 @@ public class FountainView extends RSSurfaceView {
//setFocusable(true);
}
- private RenderScript mRS;
+ private RenderScriptGL mRS;
private FountainRS mRender;
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
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 0ca00b3..568d3ab 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
@@ -126,14 +126,13 @@ public class ImageProcessingActivity extends Activity implements SurfaceHolder.C
}
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
- mRS.contextSetSurface(width, height, holder.getSurface());
}
public void surfaceDestroyed(SurfaceHolder holder) {
}
private Script.Invokable createScript() {
- mRS = new RenderScript(false, false);
+ mRS = RenderScript.create();
mRS.mMessageCallback = new FilterCallback();
mParamsType = Type.createFromClass(mRS, Params.class, 1, "Parameters");
@@ -164,7 +163,7 @@ public class ImageProcessingActivity extends Activity implements SurfaceHolder.C
sb.setType(true, 2);
Script.Invokable invokable = sb.addInvokable("main");
sb.setScript(getResources(), R.raw.threshold);
- sb.setRoot(true);
+ //sb.setRoot(true);
ScriptC script = sb.create();
script.bindAllocation(mParamsAllocation, 0);
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index 261b827..2e47ea3 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -289,15 +289,17 @@ void * Context::threadProc(void *vrsc)
LOGE("pthread_setspecific %i", status);
}
- rsc->mStateRaster.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight);
- rsc->setRaster(NULL);
- rsc->mStateVertex.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight);
- rsc->setVertex(NULL);
- rsc->mStateFragment.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight);
- rsc->setFragment(NULL);
- rsc->mStateFragmentStore.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight);
- rsc->setFragmentStore(NULL);
- rsc->mStateVertexArray.init(rsc);
+ if (rsc->mIsGraphicsContext) {
+ rsc->mStateRaster.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight);
+ rsc->setRaster(NULL);
+ rsc->mStateVertex.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight);
+ rsc->setVertex(NULL);
+ rsc->mStateFragment.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight);
+ rsc->setFragment(NULL);
+ rsc->mStateFragmentStore.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight);
+ rsc->setFragmentStore(NULL);
+ rsc->mStateVertexArray.init(rsc);
+ }
rsc->mRunning = true;
bool mDraw = true;
@@ -307,7 +309,7 @@ void * Context::threadProc(void *vrsc)
mDraw &= (rsc->mWndSurface != NULL);
uint32_t targetTime = 0;
- if (mDraw) {
+ if (mDraw && rsc->mIsGraphicsContext) {
targetTime = rsc->runRootScript();
mDraw = targetTime && !rsc->mPaused;
rsc->timerSet(RS_TIMER_CLEAR_SWAP);
@@ -329,23 +331,27 @@ void * Context::threadProc(void *vrsc)
}
LOGV("RS Thread exiting");
- rsc->mRaster.clear();
- rsc->mFragment.clear();
- rsc->mVertex.clear();
- rsc->mFragmentStore.clear();
- rsc->mRootScript.clear();
- rsc->mStateRaster.deinit(rsc);
- rsc->mStateVertex.deinit(rsc);
- rsc->mStateFragment.deinit(rsc);
- rsc->mStateFragmentStore.deinit(rsc);
+ if (rsc->mIsGraphicsContext) {
+ rsc->mRaster.clear();
+ rsc->mFragment.clear();
+ rsc->mVertex.clear();
+ rsc->mFragmentStore.clear();
+ rsc->mRootScript.clear();
+ rsc->mStateRaster.deinit(rsc);
+ rsc->mStateVertex.deinit(rsc);
+ rsc->mStateFragment.deinit(rsc);
+ rsc->mStateFragmentStore.deinit(rsc);
+ }
ObjectBase::zeroAllUserRef(rsc);
rsc->mObjDestroy.mNeedToEmpty = true;
rsc->objDestroyOOBRun();
- pthread_mutex_lock(&gInitMutex);
- rsc->deinitEGL();
- pthread_mutex_unlock(&gInitMutex);
+ if (rsc->mIsGraphicsContext) {
+ pthread_mutex_lock(&gInitMutex);
+ rsc->deinitEGL();
+ pthread_mutex_unlock(&gInitMutex);
+ }
LOGV("RS Thread exited");
return NULL;
@@ -371,7 +377,7 @@ void Context::setPriority(int32_t p)
#endif
}
-Context::Context(Device *dev, bool useDepth)
+Context::Context(Device *dev, bool isGraphics, bool useDepth)
{
pthread_mutex_lock(&gInitMutex);
@@ -383,6 +389,8 @@ Context::Context(Device *dev, bool useDepth)
mPaused = false;
mObjHead = NULL;
memset(&mEGL, 0, sizeof(mEGL));
+ memset(&mGL, 0, sizeof(mGL));
+ mIsGraphicsContext = isGraphics;
int status;
pthread_attr_t threadAttr;
@@ -454,7 +462,7 @@ Context::~Context()
void Context::setSurface(uint32_t w, uint32_t h, Surface *sur)
{
- LOGV("setSurface %i %i %p", w, h, sur);
+ rsAssert(mIsGraphicsContext);
EGLBoolean ret;
if (mEGL.mSurface != NULL) {
@@ -544,21 +552,25 @@ void Context::setSurface(uint32_t w, uint32_t h, Surface *sur)
void Context::pause()
{
+ rsAssert(mIsGraphicsContext);
mPaused = true;
}
void Context::resume()
{
+ rsAssert(mIsGraphicsContext);
mPaused = false;
}
void Context::setRootScript(Script *s)
{
+ rsAssert(mIsGraphicsContext);
mRootScript.set(s);
}
void Context::setFragmentStore(ProgramFragmentStore *pfs)
{
+ rsAssert(mIsGraphicsContext);
if (pfs == NULL) {
mFragmentStore.set(mStateFragmentStore.mDefault);
} else {
@@ -568,6 +580,7 @@ void Context::setFragmentStore(ProgramFragmentStore *pfs)
void Context::setFragment(ProgramFragment *pf)
{
+ rsAssert(mIsGraphicsContext);
if (pf == NULL) {
mFragment.set(mStateFragment.mDefault);
} else {
@@ -577,6 +590,7 @@ void Context::setFragment(ProgramFragment *pf)
void Context::setRaster(ProgramRaster *pr)
{
+ rsAssert(mIsGraphicsContext);
if (pr == NULL) {
mRaster.set(mStateRaster.mDefault);
} else {
@@ -586,6 +600,7 @@ void Context::setRaster(ProgramRaster *pr)
void Context::setVertex(ProgramVertex *pv)
{
+ rsAssert(mIsGraphicsContext);
if (pv == NULL) {
mVertex.set(mStateVertex.mDefault);
} else {
@@ -860,10 +875,19 @@ void rsi_ContextDump(Context *rsc, int32_t bits)
}
-RsContext rsContextCreate(RsDevice vdev, uint32_t version, bool useDepth)
+RsContext rsContextCreate(RsDevice vdev, uint32_t version)
+{
+ LOGV("rsContextCreate %p", vdev);
+ Device * dev = static_cast<Device *>(vdev);
+ Context *rsc = new Context(dev, false, false);
+ return rsc;
+}
+
+RsContext rsContextCreateGL(RsDevice vdev, uint32_t version, bool useDepth)
{
+ LOGV("rsContextCreateGL %p, %i", vdev, useDepth);
Device * dev = static_cast<Device *>(vdev);
- Context *rsc = new Context(dev, useDepth);
+ Context *rsc = new Context(dev, true, useDepth);
return rsc;
}
diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h
index 2edd16d..31d8cc8 100644
--- a/libs/rs/rsContext.h
+++ b/libs/rs/rsContext.h
@@ -51,7 +51,7 @@ namespace renderscript {
class Context
{
public:
- Context(Device *, bool useDepth);
+ Context(Device *, bool isGraphics, bool useDepth);
~Context();
static pthread_key_t gThreadTLSKey;
@@ -201,6 +201,7 @@ protected:
uint32_t mWidth;
uint32_t mHeight;
int32_t mThreadPriority;
+ bool mIsGraphicsContext;
bool mRunning;
bool mExit;
diff --git a/libs/rs/rsVertexArray.cpp b/libs/rs/rsVertexArray.cpp
index d0c0414..6c2002d 100644
--- a/libs/rs/rsVertexArray.cpp
+++ b/libs/rs/rsVertexArray.cpp
@@ -191,6 +191,9 @@ void VertexArray::setupGL2(const Context *rsc, class VertexArrayState *state, Sh
if (sc->isUserVertexProgram()) {
slot = sc->vtxAttribSlot(ct);
} else {
+ if (mAttribs[ct].kind == RS_KIND_USER) {
+ continue;
+ }
slot = sc->vtxAttribSlot(mAttribs[ct].kind);
}
diff --git a/libs/surfaceflinger/SurfaceFlinger.cpp b/libs/surfaceflinger/SurfaceFlinger.cpp
index 965b7dd..2d6152e 100644
--- a/libs/surfaceflinger/SurfaceFlinger.cpp
+++ b/libs/surfaceflinger/SurfaceFlinger.cpp
@@ -39,7 +39,6 @@
#include <ui/GraphicBufferAllocator.h>
#include <ui/PixelFormat.h>
-#include <ui/DisplayInfo.h>
#include <pixelflinger/pixelflinger.h>
#include <GLES/gl.h>
@@ -350,8 +349,8 @@ status_t SurfaceFlinger::readyToRun()
mServerCblk->connected |= 1<<dpy;
display_cblk_t* dcblk = mServerCblk->displays + dpy;
memset(dcblk, 0, sizeof(display_cblk_t));
- dcblk->w = w;
- dcblk->h = h;
+ dcblk->w = plane.getWidth();
+ dcblk->h = plane.getHeight();
dcblk->format = f;
dcblk->orientation = ISurfaceComposer::eOrientationDefault;
dcblk->xdpi = hw.getDpiX();
@@ -621,14 +620,8 @@ void SurfaceFlinger::handleTransactionLocked(
const DisplayHardware& hw(plane.displayHardware());
volatile display_cblk_t* dcblk = mServerCblk->displays + dpy;
dcblk->orientation = orientation;
- if (orientation & eOrientationSwapMask) {
- // 90 or 270 degrees orientation
- dcblk->w = hw.getHeight();
- dcblk->h = hw.getWidth();
- } else {
- dcblk->w = hw.getWidth();
- dcblk->h = hw.getHeight();
- }
+ dcblk->w = plane.getWidth();
+ dcblk->h = plane.getHeight();
mVisibleRegionsDirty = true;
mDirtyRegion.set(hw.bounds());
@@ -1795,13 +1788,47 @@ bool GraphicPlane::initialized() const {
return mHw ? true : false;
}
-void GraphicPlane::setDisplayHardware(DisplayHardware *hw) {
- mHw = hw;
+int GraphicPlane::getWidth() const {
+ return mWidth;
}
-void GraphicPlane::setTransform(const Transform& tr) {
- mTransform = tr;
- mGlobalTransform = mOrientationTransform * mTransform;
+int GraphicPlane::getHeight() const {
+ return mHeight;
+}
+
+void GraphicPlane::setDisplayHardware(DisplayHardware *hw)
+{
+ mHw = hw;
+
+ // initialize the display orientation transform.
+ // it's a constant that should come from the display driver.
+ int displayOrientation = ISurfaceComposer::eOrientationDefault;
+ char property[PROPERTY_VALUE_MAX];
+ if (property_get("ro.sf.hwrotation", property, NULL) > 0) {
+ //displayOrientation
+ switch (atoi(property)) {
+ case 90:
+ displayOrientation = ISurfaceComposer::eOrientation90;
+ break;
+ case 270:
+ displayOrientation = ISurfaceComposer::eOrientation270;
+ break;
+ }
+ }
+
+ const float w = hw->getWidth();
+ const float h = hw->getHeight();
+ GraphicPlane::orientationToTransfrom(displayOrientation, w, h,
+ &mDisplayTransform);
+ if (displayOrientation & ISurfaceComposer::eOrientationSwapMask) {
+ mDisplayWidth = h;
+ mDisplayHeight = w;
+ } else {
+ mDisplayWidth = w;
+ mDisplayHeight = h;
+ }
+
+ setOrientation(ISurfaceComposer::eOrientationDefault);
}
status_t GraphicPlane::orientationToTransfrom(
@@ -1810,8 +1837,9 @@ status_t GraphicPlane::orientationToTransfrom(
float a, b, c, d, x, y;
switch (orientation) {
case ISurfaceComposer::eOrientationDefault:
- a=1; b=0; c=0; d=1; x=0; y=0;
- break;
+ // make sure the default orientation is optimal
+ tr->reset();
+ return NO_ERROR;
case ISurfaceComposer::eOrientation90:
a=0; b=-1; c=1; d=0; x=w; y=0;
break;
@@ -1831,20 +1859,16 @@ status_t GraphicPlane::orientationToTransfrom(
status_t GraphicPlane::setOrientation(int orientation)
{
- const DisplayHardware& hw(displayHardware());
- const float w = hw.getWidth();
- const float h = hw.getHeight();
-
- if (orientation == ISurfaceComposer::eOrientationDefault) {
- // make sure the default orientation is optimal
- mOrientationTransform.reset();
- mOrientation = orientation;
- mGlobalTransform = mTransform;
- return NO_ERROR;
- }
-
// If the rotation can be handled in hardware, this is where
// the magic should happen.
+
+ const DisplayHardware& hw(displayHardware());
+ const float w = mDisplayWidth;
+ const float h = mDisplayHeight;
+ mWidth = int(w);
+ mHeight = int(h);
+
+ Transform orientationTransform;
if (UNLIKELY(orientation == 42)) {
float a, b, c, d, x, y;
const float r = (3.14159265f / 180.0f) * 42.0f;
@@ -1853,14 +1877,18 @@ status_t GraphicPlane::setOrientation(int orientation)
a=co; b=-si; c=si; d=co;
x = si*(h*0.5f) + (1-co)*(w*0.5f);
y =-si*(w*0.5f) + (1-co)*(h*0.5f);
- mOrientationTransform.set(a, b, c, d);
- mOrientationTransform.set(x, y);
+ orientationTransform.set(a, b, c, d);
+ orientationTransform.set(x, y);
} else {
GraphicPlane::orientationToTransfrom(orientation, w, h,
- &mOrientationTransform);
+ &orientationTransform);
+ if (orientation & ISurfaceComposer::eOrientationSwapMask) {
+ mWidth = int(h);
+ mHeight = int(w);
+ }
}
mOrientation = orientation;
- mGlobalTransform = mOrientationTransform * mTransform;
+ mGlobalTransform = mDisplayTransform * orientationTransform;
return NO_ERROR;
}
diff --git a/libs/surfaceflinger/SurfaceFlinger.h b/libs/surfaceflinger/SurfaceFlinger.h
index c0ab73d..2b7820c 100644
--- a/libs/surfaceflinger/SurfaceFlinger.h
+++ b/libs/surfaceflinger/SurfaceFlinger.h
@@ -116,9 +116,10 @@ public:
bool initialized() const;
void setDisplayHardware(DisplayHardware *);
- void setTransform(const Transform& tr);
status_t setOrientation(int orientation);
int getOrientation() const { return mOrientation; }
+ int getWidth() const;
+ int getHeight() const;
const DisplayHardware& displayHardware() const;
const Transform& transform() const;
@@ -129,10 +130,13 @@ private:
GraphicPlane operator = (const GraphicPlane&);
DisplayHardware* mHw;
- Transform mTransform;
- Transform mOrientationTransform;
Transform mGlobalTransform;
+ Transform mDisplayTransform;
int mOrientation;
+ float mDisplayWidth;
+ float mDisplayHeight;
+ int mWidth;
+ int mHeight;
};
// ---------------------------------------------------------------------------
diff --git a/libs/ui/CameraParameters.cpp b/libs/ui/CameraParameters.cpp
index c4958a0..493b9c1 100644
--- a/libs/ui/CameraParameters.cpp
+++ b/libs/ui/CameraParameters.cpp
@@ -59,6 +59,8 @@ const char CameraParameters::KEY_SUPPORTED_FOCUS_MODES[] = "focus-mode-values";
const char CameraParameters::KEY_FOCAL_LENGTH[] = "focal-length";
const char CameraParameters::KEY_HORIZONTAL_VIEW_ANGLE[] = "horizontal-view-angle";
const char CameraParameters::KEY_VERTICAL_VIEW_ANGLE[] = "vertical-view-angle";
+const char CameraParameters::KEY_EXPOSURE_COMPENSATION[] = "exposure-compensation";
+const char CameraParameters::KEY_SUPPORTED_EXPOSURE_COMPENSATION[] = "exposure-compensation-values";
// Values for white balance settings.
const char CameraParameters::WHITE_BALANCE_AUTO[] = "auto";