summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2014-03-31 12:34:11 -0700
committerChris Craik <ccraik@google.com>2014-04-02 18:38:25 -0700
commit49e6c73913e9bee58ea5e3984be151ee8e033163 (patch)
treedb10cba6a686b5a2435eee07b18dfb285b2cb972 /libs
parent8754b73bf81aa0164f3e2a1a429ba0fda39202de (diff)
downloadframeworks_base-49e6c73913e9bee58ea5e3984be151ee8e033163.zip
frameworks_base-49e6c73913e9bee58ea5e3984be151ee8e033163.tar.gz
frameworks_base-49e6c73913e9bee58ea5e3984be151ee8e033163.tar.bz2
Move most TransformationInfo properties to RenderNode
This change dedupes the various properties that were represented both in TransformationInfo, and RenderProperties on the native side. RenderNode (and its associated properties) are now permanently attached to a View in SW or HW. The native copy of these properties are their sole representation. Alpha to come in a later CL. Also fixed issue with copying RenderNode's transform, and added support of deleting RenderNodes in software rendering. Change-Id: Ideb6e7f32b780e87aa1c32637c368356b3eee3a1
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/RenderNode.cpp8
-rw-r--r--libs/hwui/RenderProperties.cpp59
-rw-r--r--libs/hwui/RenderProperties.h29
3 files changed, 48 insertions, 48 deletions
diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp
index 34d98a1..663b67e 100644
--- a/libs/hwui/RenderNode.cpp
+++ b/libs/hwui/RenderNode.cpp
@@ -61,8 +61,12 @@ RenderNode::~RenderNode() {
void RenderNode::destroyDisplayListDeferred(RenderNode* displayList) {
if (displayList) {
- DISPLAY_LIST_LOGD("Deferring display list destruction");
- Caches::getInstance().deleteDisplayListDeferred(displayList);
+ if (Caches::hasInstance()) {
+ DISPLAY_LIST_LOGD("Deferring display list destruction");
+ Caches::getInstance().deleteDisplayListDeferred(displayList);
+ } else {
+ delete displayList;
+ }
}
}
diff --git a/libs/hwui/RenderProperties.cpp b/libs/hwui/RenderProperties.cpp
index 3975a76..e7e7768 100644
--- a/libs/hwui/RenderProperties.cpp
+++ b/libs/hwui/RenderProperties.cpp
@@ -45,28 +45,24 @@ RenderProperties::PrimitiveFields::PrimitiveFields()
, mPrevWidth(-1), mPrevHeight(-1)
, mPivotExplicitlySet(false)
, mMatrixDirty(false)
- , mMatrixIsIdentity(true)
, mMatrixFlags(0)
, mCaching(false) {
}
RenderProperties::ComputedFields::ComputedFields()
: mTransformMatrix(NULL)
- , mTransformCamera(NULL)
, mTransformMatrix3D(NULL)
, mClipPath(NULL) {
}
RenderProperties::ComputedFields::~ComputedFields() {
delete mTransformMatrix;
- delete mTransformCamera;
delete mTransformMatrix3D;
delete mClipPath;
}
RenderProperties::RenderProperties()
- : mCameraDistance(0)
- , mStaticMatrix(NULL)
+ : mStaticMatrix(NULL)
, mAnimationMatrix(NULL) {
}
@@ -82,9 +78,12 @@ RenderProperties& RenderProperties::operator=(const RenderProperties& other) {
setAnimationMatrix(other.getAnimationMatrix());
setCameraDistance(other.getCameraDistance());
- // Update the computed fields
- updateMatrix();
+ // Update the computed clip path
updateClipPath();
+
+ // Force recalculation of the matrix, since other's dirty bit may be clear
+ mPrimitiveFields.mMatrixDirty = true;
+ updateMatrix();
}
return *this;
}
@@ -106,8 +105,8 @@ void RenderProperties::debugOutputProperties(const int level) const {
ALOGD("%*sTranslate %.2f, %.2f, %.2f",
level * 2, "", mPrimitiveFields.mTranslationX, mPrimitiveFields.mTranslationY, mPrimitiveFields.mTranslationZ);
} else {
- ALOGD("%*sConcatMatrix %p: " MATRIX_4_STRING,
- level * 2, "", mComputedFields.mTransformMatrix, MATRIX_4_ARGS(mComputedFields.mTransformMatrix));
+ ALOGD("%*sConcatMatrix %p: " SK_MATRIX_STRING,
+ level * 2, "", mComputedFields.mTransformMatrix, SK_MATRIX_ARGS(mComputedFields.mTransformMatrix));
}
}
@@ -141,7 +140,7 @@ void RenderProperties::updateMatrix() {
if (mPrimitiveFields.mMatrixFlags && mPrimitiveFields.mMatrixFlags != TRANSLATION) {
if (!mComputedFields.mTransformMatrix) {
// only allocate a mPrimitiveFields.matrix if we have a complex transform
- mComputedFields.mTransformMatrix = new Matrix4();
+ mComputedFields.mTransformMatrix = new SkMatrix();
}
if (!mPrimitiveFields.mPivotExplicitlySet) {
if (mPrimitiveFields.mWidth != mPrimitiveFields.mPrevWidth || mPrimitiveFields.mHeight != mPrimitiveFields.mPrevHeight) {
@@ -153,33 +152,31 @@ void RenderProperties::updateMatrix() {
}
if ((mPrimitiveFields.mMatrixFlags & ROTATION_3D) == 0) {
- mComputedFields.mTransformMatrix->loadTranslate(
- mPrimitiveFields.mPivotX + mPrimitiveFields.mTranslationX,
- mPrimitiveFields.mPivotY + mPrimitiveFields.mTranslationY,
- 0);
- mComputedFields.mTransformMatrix->rotate(mPrimitiveFields.mRotation, 0, 0, 1);
- mComputedFields.mTransformMatrix->scale(mPrimitiveFields.mScaleX, mPrimitiveFields.mScaleY, 1);
- mComputedFields.mTransformMatrix->translate(-mPrimitiveFields.mPivotX, -mPrimitiveFields.mPivotY);
+ mComputedFields.mTransformMatrix->setTranslate(
+ mPrimitiveFields.mTranslationX, mPrimitiveFields.mTranslationY);
+ mComputedFields.mTransformMatrix->preRotate(mPrimitiveFields.mRotation,
+ mPrimitiveFields.mPivotX, mPrimitiveFields.mPivotY);
+ mComputedFields.mTransformMatrix->preScale(
+ mPrimitiveFields.mScaleX, mPrimitiveFields.mScaleY,
+ mPrimitiveFields.mPivotX, mPrimitiveFields.mPivotY);
} else {
- if (!mComputedFields.mTransformCamera) {
- mComputedFields.mTransformCamera = new Sk3DView();
+ if (!mComputedFields.mTransformMatrix3D) {
mComputedFields.mTransformMatrix3D = new SkMatrix();
}
- SkMatrix transformMatrix;
- transformMatrix.reset();
- mComputedFields.mTransformCamera->save();
- transformMatrix.preScale(mPrimitiveFields.mScaleX, mPrimitiveFields.mScaleY, mPrimitiveFields.mPivotX, mPrimitiveFields.mPivotY);
- mComputedFields.mTransformCamera->rotateX(mPrimitiveFields.mRotationX);
- mComputedFields.mTransformCamera->rotateY(mPrimitiveFields.mRotationY);
- mComputedFields.mTransformCamera->rotateZ(-mPrimitiveFields.mRotation);
- mComputedFields.mTransformCamera->getMatrix(mComputedFields.mTransformMatrix3D);
+ mComputedFields.mTransformMatrix->reset();
+ mComputedFields.mTransformCamera.save();
+ mComputedFields.mTransformMatrix->preScale(
+ mPrimitiveFields.mScaleX, mPrimitiveFields.mScaleY,
+ mPrimitiveFields.mPivotX, mPrimitiveFields.mPivotY);
+ mComputedFields.mTransformCamera.rotateX(mPrimitiveFields.mRotationX);
+ mComputedFields.mTransformCamera.rotateY(mPrimitiveFields.mRotationY);
+ mComputedFields.mTransformCamera.rotateZ(-mPrimitiveFields.mRotation);
+ mComputedFields.mTransformCamera.getMatrix(mComputedFields.mTransformMatrix3D);
mComputedFields.mTransformMatrix3D->preTranslate(-mPrimitiveFields.mPivotX, -mPrimitiveFields.mPivotY);
mComputedFields.mTransformMatrix3D->postTranslate(mPrimitiveFields.mPivotX + mPrimitiveFields.mTranslationX,
mPrimitiveFields.mPivotY + mPrimitiveFields.mTranslationY);
- transformMatrix.postConcat(*mComputedFields.mTransformMatrix3D);
- mComputedFields.mTransformCamera->restore();
-
- mComputedFields.mTransformMatrix->load(transformMatrix);
+ mComputedFields.mTransformMatrix->postConcat(*mComputedFields.mTransformMatrix3D);
+ mComputedFields.mTransformCamera.restore();
}
}
mPrimitiveFields.mMatrixDirty = false;
diff --git a/libs/hwui/RenderProperties.h b/libs/hwui/RenderProperties.h
index 061e469..dd68210 100644
--- a/libs/hwui/RenderProperties.h
+++ b/libs/hwui/RenderProperties.h
@@ -258,20 +258,20 @@ public:
return mPrimitiveFields.mPivotY;
}
+ bool isPivotExplicitlySet() const {
+ return mPrimitiveFields.mPivotExplicitlySet;
+ }
+
void setCameraDistance(float distance) {
- if (distance != mCameraDistance) {
- mCameraDistance = distance;
+ if (distance != getCameraDistance()) {
mPrimitiveFields.mMatrixDirty = true;
- if (!mComputedFields.mTransformCamera) {
- mComputedFields.mTransformCamera = new Sk3DView();
- mComputedFields.mTransformMatrix3D = new SkMatrix();
- }
- mComputedFields.mTransformCamera->setCameraLocation(0, 0, distance);
+ mComputedFields.mTransformCamera.setCameraLocation(0, 0, distance);
}
}
float getCameraDistance() const {
- return mCameraDistance;
+ // TODO: update getCameraLocationZ() to be const
+ return const_cast<Sk3DView*>(&mComputedFields.mTransformCamera)->getCameraLocationZ();
}
void setLeft(int left) {
@@ -396,7 +396,7 @@ public:
return mPrimitiveFields.mMatrixFlags;
}
- const Matrix4* getTransformMatrix() const {
+ const SkMatrix* getTransformMatrix() const {
return mComputedFields.mTransformMatrix;
}
@@ -481,13 +481,11 @@ private:
int mPrevWidth, mPrevHeight;
bool mPivotExplicitlySet;
bool mMatrixDirty;
- bool mMatrixIsIdentity;
uint32_t mMatrixFlags;
bool mCaching;
} mPrimitiveFields;
// mCameraDistance isn't in mPrimitiveFields as it has a complex setter
- float mCameraDistance;
SkMatrix* mStaticMatrix;
SkMatrix* mAnimationMatrix;
@@ -502,11 +500,12 @@ private:
* Stores the total transformation of the DisplayList based upon its scalar
* translate/rotate/scale properties.
*
- * In the common translation-only case, the matrix isn't allocated and the mTranslation
- * properties are used directly.
+ * In the common translation-only case, the matrix isn't necessarily allocated,
+ * and the mTranslation properties are used directly.
*/
- Matrix4* mTransformMatrix;
- Sk3DView* mTransformCamera;
+ SkMatrix* mTransformMatrix;
+
+ Sk3DView mTransformCamera;
SkMatrix* mTransformMatrix3D;
SkPath* mClipPath; // TODO: remove this, create new ops for efficient/special case clipping
SkRegion::Op mClipPathOp;