Refactor DrawView to avoid extra allocates.

Summary: Previously, the first time we collected a draw view, we would make a clone, even though the draw view had never been mutated.  This refactors draw view to avoid this extra allocate.

Reviewed By: ahmedre

Differential Revision: D3719056
This commit is contained in:
Seth Kirby
2016-08-15 18:56:36 -07:00
committed by Ahmed El-Helw
parent cc216b5ec3
commit b2f41e2921
3 changed files with 70 additions and 42 deletions
@@ -42,7 +42,7 @@ import android.graphics.Color;
&& mClipRight == clipRight && mClipBottom == clipBottom;
}
public final void setClipBounds(
protected final void setClipBounds(
float clipLeft,
float clipTop,
float clipRight,
@@ -185,6 +185,13 @@ import android.graphics.Color;
return mFrozen;
}
/**
* Mark this object as frozen, indicating that it should not be mutated.
*/
public final void freeze() {
mFrozen = true;
}
/**
* Left position of this DrawCommand relative to the hosting View.
*/
@@ -226,7 +233,7 @@ import android.graphics.Color;
/**
* Updates boundaries of this DrawCommand.
*/
private void setBounds(float left, float top, float right, float bottom) {
protected final void setBounds(float left, float top, float right, float bottom) {
mLeft = left;
mTop = top;
mRight = right;
@@ -238,7 +245,7 @@ import android.graphics.Color;
/**
* Returns true if boundaries match and don't need to be updated. False otherwise.
*/
private boolean boundsMatch(float left, float top, float right, float bottom) {
protected final boolean boundsMatch(float left, float top, float right, float bottom) {
return mLeft == left && mTop == top && mRight == right && mBottom == bottom;
}
}