This commit is contained in:
siyao 2020-09-28 19:03:09 +08:00
Родитель 0271daa722
Коммит 8008854436
11 изменённых файлов: 43 добавлений и 34 удалений

Просмотреть файл

@ -436,7 +436,7 @@ namespace Unity.UIWidgets.ui2 {
// If you add more fields, remember to update _kDataByteCount.
const int _kDataByteCount = 56;
public object[] _objects;
object[] _objects;
internal IntPtr[] _objectPtrs;
const int _kShaderIndex = 0;
const int _kColorFilterIndex = 1;

Просмотреть файл

@ -8,6 +8,7 @@ using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.external.simplejson;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.ui2 {
@ -645,12 +646,22 @@ namespace Unity.UIWidgets.ui2 {
}
}
static byte[] _fontChangeMessage =
Encoding.ASCII.GetBytes(JsonUtility.ToJson(new Dictionary<string, dynamic>() {{"type", "fontsChange"}}));
static byte[] _fontChangeMessageData;
static byte[] _fontChangeMessage {
get {
if (_fontChangeMessageData != null) {
return _fontChangeMessageData;
}
JSONObject message = new JSONObject();
message["type"] = "fontsChange";
_fontChangeMessageData = Encoding.ASCII.GetBytes(message.ToString());
return _fontChangeMessageData;
}
}
static void _sendFontChangeMessage() {
Window window = new Window();
window.onPlatformMessage?.Invoke("uiwidgets/system", _fontChangeMessage,
Window.instance.onPlatformMessage?.Invoke("uiwidgets/system", _fontChangeMessage,
(_) => { });
}
@ -661,12 +672,12 @@ namespace Unity.UIWidgets.ui2 {
IntPtr callbackHandle,
string fontFamily);
public struct BaseList {
public struct Float32List {
public IntPtr data;
public int length;
}
public static float[] toFloatArrayAndFree(this BaseList data) {
public static float[] toFloatArrayAndFree(this Float32List data) {
float[] result = new float[data.length];
Marshal.Copy(data.data, result, 0, data.length);
ui_.Lists_Free(data.data);
@ -699,9 +710,9 @@ namespace Unity.UIWidgets.ui2 {
List<Shadow> shadows = null,
List<FontFeature> fontFeatures = null
) {
D.assert(color == null || foreground == null
// "Cannot provide both a color and a foreground\n"+
// "The color argument is just a shorthand for \"foreground: Paint()..color = color\"."
D.assert(color == null || foreground == null, () =>
"Cannot provide both a color and a foreground\n"+
"The color argument is just a shorthand for \"foreground: Paint()..color = color\"."
);
_encoded = ui_._encodeTextStyle(
color,
@ -1523,12 +1534,12 @@ namespace Unity.UIWidgets.ui2 {
static extern void Paragraph_layout(IntPtr ptr, float width);
[DllImport(NativeBindings.dllName)]
static extern ui_.BaseList Paragraph_getRectsForRange(IntPtr ptr, int start, int end,
static extern ui_.Float32List Paragraph_getRectsForRange(IntPtr ptr, int start, int end,
int boxHeightStyle,
int boxWidthStyle);
[DllImport(NativeBindings.dllName)]
static extern ui_.BaseList Paragraph_getRectsForPlaceholders(IntPtr ptr);
static extern ui_.Float32List Paragraph_getRectsForPlaceholders(IntPtr ptr);
[DllImport(NativeBindings.dllName)]
static extern unsafe void Paragraph_getPositionForOffset(IntPtr ptr, float dx, float dy, int* encodedPtr);
@ -1543,7 +1554,7 @@ namespace Unity.UIWidgets.ui2 {
static extern void Paragraph_paint(IntPtr ptr, IntPtr canvas, float x, float y);
[DllImport(NativeBindings.dllName)]
static extern ui_.BaseList Paragraph_computeLineMetrics(IntPtr ptr);
static extern ui_.Float32List Paragraph_computeLineMetrics(IntPtr ptr);
[DllImport(NativeBindings.dllName)]
static extern void Paragraph_dispose(IntPtr ptr);
@ -1614,7 +1625,7 @@ namespace Unity.UIWidgets.ui2 {
}
// See paragraph.cc for the layout of this return value.
ui_.BaseList _getBoxesForRange(int start, int end, int boxHeightStyle, int boxWidthStyle) =>
ui_.Float32List _getBoxesForRange(int start, int end, int boxHeightStyle, int boxWidthStyle) =>
Paragraph_getRectsForRange(_ptr, start, end, boxHeightStyle, boxWidthStyle);
@ -1623,7 +1634,7 @@ namespace Unity.UIWidgets.ui2 {
return _decodeTextBoxes(data, data.Length);
}
ui_.BaseList _getBoxesForPlaceholders() => Paragraph_getRectsForPlaceholders(_ptr);
ui_.Float32List _getBoxesForPlaceholders() => Paragraph_getRectsForPlaceholders(_ptr);
public unsafe TextPosition getPositionForOffset(Offset offset) {
int[] encoded = new int[2];
@ -1689,7 +1700,7 @@ namespace Unity.UIWidgets.ui2 {
return metrics;
}
ui_.BaseList _computeLineMetrics() => Paragraph_computeLineMetrics(_ptr);
ui_.Float32List _computeLineMetrics() => Paragraph_computeLineMetrics(_ptr);
}
public class ParagraphBuilder : NativeWrapper {

Просмотреть файл

@ -314,7 +314,7 @@ class Build
};
np.Libraries.Add(new BagOfObjectFilesLibrary(
new NPath[]{
skiaRoot+"out/Debug/icudtl.o"
skiaRoot+"third_party/externals/icu/flutter/icudtl.o"
}));
np.CompilerSettings().Add(c => c.WithCppLanguageVersion(CppLanguageVersion.Cpp17));

Просмотреть файл

@ -48,10 +48,10 @@ ninja -C out/Debug -k 0
```
Ignore this error: "lld-link: error: could not open 'EGL': no such file or directory"
convert icudtl.dat to object file
convert icudtl.dat to object file in skia
```
cd out/Debug
ld -r -b binary -o .\icudtl.o .\icudtl.dat
cd SkiaRoot/third_party/externals/icu/flutter/icudtl.dat
ld -r -b binary -o icudtl.o icudtl.dat
```
### Build flutter fml

Просмотреть файл

@ -71,8 +71,6 @@ void FontCollection::RegisterFonts(
return;
}
// Structure described in https://flutter.io/custom-fonts/
if (!document.IsArray()) {
return;
}

Просмотреть файл

@ -71,7 +71,6 @@ class ICUContext {
UErrorCode err_code = U_ZERO_ERROR;
udata_setCommonData(GetMapping(), &err_code);
return (err_code == U_ZERO_ERROR);
// return true;
}
const uint8_t* GetMapping() const {

Просмотреть файл

@ -1,9 +1,9 @@
#pragma once
#include "flutter/fml/memory/ref_counted.h"
#include "flutter/third_party/txt/src/txt/paragraph.h"
#include "txt/paragraph.h"
#include "shell/common/lists.h"
#include "src/lib/ui/painting/canvas.h"
#include "lib/ui/painting/canvas.h"
#include "lib/ui/ui_mono_state.h"
namespace uiwidgets {

Просмотреть файл

@ -1,11 +1,11 @@
#pragma once
#include "flutter/fml/memory/ref_counted.h"
#include "flutter/third_party/txt/src/txt/paragraph.h"
#include "flutter/third_party/txt/src/txt/paragraph_builder.h"
#include "txt/paragraph.h"
#include "txt/paragraph_builder.h"
#include "font_collection.h"
#include "paragraph.h"
#include "src/lib/ui/painting/canvas.h"
#include "lib/ui/painting/canvas.h"
namespace uiwidgets {

Просмотреть файл

@ -19,9 +19,9 @@
#include "Unity/IUnityGraphicsD3D11.h"
#include "flutter/fml/message_loop.h"
#include "flutter/third_party/txt/src/txt/paragraph.h"
#include "flutter/third_party/txt/src/txt/paragraph_builder.h"
#include "flutter/third_party/txt/src/txt/font_collection.h"
#include "txt/paragraph.h"
#include "txt/paragraph_builder.h"
#include "txt/font_collection.h"
#include "flutter/fml/synchronization/waitable_event.h"
#include "include/core/SkCanvas.h"

Просмотреть файл

@ -1,7 +1,6 @@
#define RAPIDJSON_HAS_STDSTRING 1
#include "shell.h"
#include <filesystem>
#include <future>
#include <memory>
#include <sstream>
@ -219,8 +218,10 @@ static void PerformInitializationTasks(const Settings& settings) {
if (settings.icu_initialization_required) {
if (settings.icu_data_path.length() > 0) {
uiwidgets::icu::InitializeICU(settings.icu_data_path);
} else {
} else if (settings.icu_mapper) {
uiwidgets::icu::InitializeICUFromMapping(settings.icu_mapper());
} else {
FML_DLOG(WARNING) << "Skipping ICU initialization in the shell.";
}
}
});

Просмотреть файл

@ -8,7 +8,7 @@
#include "lib/ui/window/viewport_metrics.h"
#include "runtime/mono_api.h"
#include "shell/platform/embedder/embedder_engine.h"
#include "src/shell/common/switches.h"
#include "shell/common/switches.h"
#include "uiwidgets_system.h"
namespace uiwidgets {