Merge "Introduce MeasuredText related perf tests"

This commit is contained in:
TreeHugger Robot
2018-01-29 19:30:42 +00:00
committed by Android (Google) Code Review
7 changed files with 468 additions and 73 deletions

View File

@@ -672,6 +672,13 @@ public class MeasuredParagraph {
return width;
}
/**
* This only works if the MeasuredParagraph is computed with buildForStaticLayout.
*/
@IntRange(from = 0) int getMemoryUsage() {
return nGetMemoryUsage(mNativePtr);
}
private static native /* Non Zero */ long nInitBuilder();
/**
@@ -718,4 +725,7 @@ public class MeasuredParagraph {
@CriticalNative
private static native /* Non Zero */ long nGetReleaseFunc();
@CriticalNative
private static native int nGetMemoryUsage(/* Non Zero */ long nativePtr);
}

View File

@@ -333,6 +333,20 @@ public class MeasuredText implements Spanned {
return getMeasuredParagraph(paraIndex).getWidth(start - paraStart, end - paraStart);
}
/**
* Returns the size of native MeasuredText memory usage
*
* Note that this may not be aculate. Must be used only for testing purposes.
* @hide
*/
public int getMemoryUsage() {
int r = 0;
for (int i = 0; i < getParagraphCount(); ++i) {
r += getMeasuredParagraph(i).getMemoryUsage();
}
return r;
}
///////////////////////////////////////////////////////////////////////////////////////////////
// Spanned overrides
//