Create private properties on GLCanvas for experimentation with 3d
Change-Id: I17772f61efce727cb4c1111f4d97f58c741786b8
diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp
index 5b751b9..2e7990e 100644
--- a/libs/hwui/Caches.cpp
+++ b/libs/hwui/Caches.cpp
@@ -55,6 +55,7 @@
initProperties();
initStaticProperties();
initExtensions();
+ initTempProperties();
mDebugLevel = readDebugLevel();
ALOGD("Enabling debug mode %d", mDebugLevel);
@@ -676,5 +677,36 @@
return mRegionMesh;
}
+///////////////////////////////////////////////////////////////////////////////
+// Temporary Properties
+///////////////////////////////////////////////////////////////////////////////
+
+void Caches::initTempProperties() {
+ propertyDirtyViewport = false;
+ propertyEnable3d = false;
+ propertyCameraDistance = 1.0f;
+ propertyShadowStrength = 0x3f;
+}
+
+void Caches::setTempProperty(const char* name, const char* value) {
+ ALOGD("setting property %s to %s", name, value);
+ if (!strcmp(name, "enable3d")) {
+ propertyEnable3d = !strcmp(value, "true");
+ propertyDirtyViewport = true;
+ ALOGD("enable3d = %d", propertyEnable3d);
+ return;
+ } else if (!strcmp(name, "cameraDistance")) {
+ propertyCameraDistance = fmin(fmax(atof(value), 0.001), 10);
+ propertyDirtyViewport = true;
+ ALOGD("camera dist multiplier = %.2f", propertyCameraDistance);
+ return;
+ } else if (!strcmp(name, "shadowStrength")) {
+ propertyShadowStrength = atoi(value);
+ ALOGD("shadow strength = 0x%x out of 0xff", propertyShadowStrength);
+ return;
+ }
+ ALOGD(" failed");
+}
+
}; // namespace uirenderer
}; // namespace android
diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h
index 963965d..01e8d84 100644
--- a/libs/hwui/Caches.h
+++ b/libs/hwui/Caches.h
@@ -353,6 +353,14 @@
PFNGLLABELOBJECTEXTPROC setLabel;
PFNGLGETOBJECTLABELEXTPROC getLabel;
+ // TEMPORARY properties
+ void initTempProperties();
+ void setTempProperty(const char* name, const char* value);
+ bool propertyEnable3d;
+ bool propertyDirtyViewport; // flag set when dirtying the viewport
+ float propertyCameraDistance;
+ int propertyShadowStrength;
+
private:
enum OverdrawColorSet {
kColorSet_Default = 0,
diff --git a/libs/hwui/Debug.h b/libs/hwui/Debug.h
index f619205..d6dc6ad 100644
--- a/libs/hwui/Debug.h
+++ b/libs/hwui/Debug.h
@@ -85,9 +85,6 @@
// Turn on to highlight drawing batches and merged batches with different colors
#define DEBUG_MERGE_BEHAVIOR 0
-// Turn on to enable 3D support in the renderer (off by default until API for control exists)
-#define DEBUG_ENABLE_3D 0
-
// Turn on to enable debugging shadow
#define DEBUG_SHADOW 0
diff --git a/libs/hwui/DisplayList.cpp b/libs/hwui/DisplayList.cpp
index c616cd8..de2106c 100644
--- a/libs/hwui/DisplayList.cpp
+++ b/libs/hwui/DisplayList.cpp
@@ -310,12 +310,12 @@
mPivotY = mPrevHeight / 2.0f;
}
}
- if (!DEBUG_ENABLE_3D && (mMatrixFlags & ROTATION_3D) == 0) {
+ if (!Caches::getInstance().propertyEnable3d && (mMatrixFlags & ROTATION_3D) == 0) {
mTransformMatrix->setTranslate(mTranslationX, mTranslationY);
mTransformMatrix->preRotate(mRotation, mPivotX, mPivotY);
mTransformMatrix->preScale(mScaleX, mScaleY, mPivotX, mPivotY);
} else {
- if (DEBUG_ENABLE_3D) {
+ if (Caches::getInstance().propertyEnable3d) {
mTransform.loadTranslate(mPivotX + mTranslationX, mPivotY + mTranslationY,
mTranslationZ);
mTransform.rotate(mRotationX, 1, 0, 0);
@@ -420,11 +420,11 @@
renderer.translate(mTranslationX, mTranslationY);
renderer.translateZ(mTranslationZ);
} else {
-#if DEBUG_ENABLE_3D
- renderer.concatMatrix(mTransform);
-#else
- renderer.concatMatrix(mTransformMatrix);
-#endif
+ if (Caches::getInstance().propertyEnable3d) {
+ renderer.concatMatrix(mTransform);
+ } else {
+ renderer.concatMatrix(mTransformMatrix);
+ }
}
}
bool clipToBoundsNeeded = mCaching ? false : mClipToBounds;
@@ -474,12 +474,12 @@
if (mMatrixFlags == TRANSLATION) {
matrix.translate(mTranslationX, mTranslationY, mTranslationZ);
} else {
-#if DEBUG_ENABLE_3D
- matrix.multiply(mTransform);
-#else
- mat4 temp(*mTransformMatrix);
- matrix.multiply(temp);
-#endif
+ if (Caches::getInstance().propertyEnable3d) {
+ matrix.multiply(mTransform);
+ } else {
+ mat4 temp(*mTransformMatrix);
+ matrix.multiply(temp);
+ }
}
}
}
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 578a251..cdef94e 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -182,10 +182,10 @@
}
void OpenGLRenderer::initViewport(int width, int height) {
- float dist = std::max(width, height) * 1.5;
-
- if (DEBUG_ENABLE_3D) {
+ if (mCaches.propertyEnable3d) {
// TODO: make view proj app configurable
+ float dist = std::max(width, height) * 1.5;
+ dist *= mCaches.propertyCameraDistance;
Matrix4 projection;
projection.loadFrustum(-width / 2, -height / 2, width / 2, height / 2, dist, 0);
Matrix4 view;
@@ -2081,6 +2081,12 @@
int32_t replayFlags) {
status_t status;
+ if (mCaches.propertyDirtyViewport) {
+ // force recalc of view/proj matrices
+ setViewport(mWidth, mHeight);
+ mCaches.propertyDirtyViewport = false;
+ }
+
// All the usual checks and setup operations (quickReject, setupDraw, etc.)
// will be performed by the display list itself
if (displayList && displayList->isRenderable()) {
@@ -3394,9 +3400,8 @@
mCaches.enableScissor();
SkPaint paint;
- paint.setColor(0x3f000000);
- // Force the draw to use alpha values.
- paint.setAntiAlias(true);
+ paint.setColor(mCaches.propertyShadowStrength << 24);
+ paint.setAntiAlias(true); // want to use AlphaVertex
VertexBuffer shadowVertexBuffer;
ShadowTessellator::tessellateAmbientShadow(width, height, casterTransform,