Make Font class being able to create from native instance
This CL refactors followings:
- Use infomation stored in native instance as the source-of-truth.
- Being able to create Font instance from native instance.
- Use ByteBuffer as a wrapper of the native byte buffer.
Bug: 179113771
Test: atest CtsTextTestCases CtsGraphicsTestCases
Test: atest android.graphics.fonts.NativeSystemFontTest
Test: atest android.graphics.fonts.SystemFontsTest
Test: atest FrameworksCoreTests:android.text
Test: atest FrameworksCoreTests:android.graphics
Change-Id: Icc1df1c76ba78d4f8800984444439fd03970e179
diff --git a/libs/hwui/jni/text/TextShaper.cpp b/libs/hwui/jni/text/TextShaper.cpp
index 9785aa5..a6fb958 100644
--- a/libs/hwui/jni/text/TextShaper.cpp
+++ b/libs/hwui/jni/text/TextShaper.cpp
@@ -23,13 +23,14 @@
#include <set>
#include <algorithm>
-#include "SkPaint.h"
-#include "SkTypeface.h"
#include <hwui/MinikinSkia.h>
#include <hwui/MinikinUtils.h>
#include <hwui/Paint.h>
-#include <minikin/MinikinPaint.h>
#include <minikin/MinikinFont.h>
+#include <minikin/MinikinPaint.h>
+#include "FontUtils.h"
+#include "SkPaint.h"
+#include "SkTypeface.h"
namespace android {
@@ -149,7 +150,8 @@
// CriticalNative
static jlong TextShaper_Result_getFont(CRITICAL_JNI_PARAMS_COMMA jlong ptr, jint i) {
const LayoutWrapper* layout = reinterpret_cast<LayoutWrapper*>(ptr);
- return reinterpret_cast<jlong>(layout->layout.getFont(i));
+ std::shared_ptr<minikin::Font> fontRef = layout->layout.getFontRef(i);
+ return reinterpret_cast<jlong>(new FontWrapper(std::move(fontRef)));
}
// CriticalNative