Merge "Introduce MeasuredText related perf tests"
This commit is contained in:
committed by
Android (Google) Code Review
commit
ea3ca9d720
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user