Merge "Fix performance regression by fixing keys used in Typeface.Builder" into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
5f873a09a0
@@ -18,6 +18,7 @@ package android.graphics.perftests;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.perftests.utils.BenchmarkState;
|
import android.perftests.utils.BenchmarkState;
|
||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
@@ -26,6 +27,8 @@ import androidx.test.InstrumentationRegistry;
|
|||||||
import androidx.test.filters.LargeTest;
|
import androidx.test.filters.LargeTest;
|
||||||
import androidx.test.runner.AndroidJUnit4;
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
|
import com.android.perftests.core.R;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@@ -104,4 +107,15 @@ public class TypefaceCreatePerfTest {
|
|||||||
|
|
||||||
outFile.delete();
|
outFile.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreate_fromResources() {
|
||||||
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
|
final Resources r = InstrumentationRegistry.getContext().getResources();
|
||||||
|
|
||||||
|
while (state.keepRunning()) {
|
||||||
|
Typeface face = r.getFont(R.font.samplefont);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -596,8 +596,8 @@ public class Typeface {
|
|||||||
final Font font = mFontBuilder.build();
|
final Font font = mFontBuilder.build();
|
||||||
final String key = mAssetManager == null ? null : createAssetUid(
|
final String key = mAssetManager == null ? null : createAssetUid(
|
||||||
mAssetManager, mPath, font.getTtcIndex(), font.getAxes(),
|
mAssetManager, mPath, font.getTtcIndex(), font.getAxes(),
|
||||||
font.getStyle().getWeight(), font.getStyle().getSlant(),
|
mWeight, mItalic,
|
||||||
mFallbackFamilyName);
|
mFallbackFamilyName == null ? DEFAULT_FAMILY : mFallbackFamilyName);
|
||||||
if (key != null) {
|
if (key != null) {
|
||||||
// Dynamic cache lookup is only for assets.
|
// Dynamic cache lookup is only for assets.
|
||||||
synchronized (sDynamicCacheLock) {
|
synchronized (sDynamicCacheLock) {
|
||||||
|
|||||||
Reference in New Issue
Block a user