浏览代码

fix

/siyaoH-1.17-PlatformMessage
siyao 4 年前
当前提交
bf3c9fb9
共有 16 个文件被更改,包括 83 次插入98 次删除
  1. 23
      com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanel.cs
  2. 3
      com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanelWrapper.cs
  3. 20
      engine/Build.bee.cs
  4. 4
      engine/README.md
  5. 6
      engine/src/assets/directory_asset_bundle.cc
  6. 9
      engine/src/flow/raster_cache.cc
  7. 3
      engine/src/lib/ui/painting/skottie.cc
  8. 4
      engine/src/runtime/mono_api.cc
  9. 2
      engine/src/shell/platform/unity/android/uiwidgets_panel.h
  10. 2
      engine/src/shell/platform/unity/android/android_task_runner.cc
  11. 49
      com.unity.uiwidgets/Runtime/engine2/AndroidPlatformUtil.cs
  12. 14
      com.unity.uiwidgets/Runtime/engine2/AndroidGLInit.cs
  13. 42
      com.unity.uiwidgets/Runtime/engine2/AndroidUnpackStreamingAsset.cs
  14. 0
      /com.unity.uiwidgets/Runtime/engine2/AndroidPlatformUtil.cs.meta
  15. 0
      /engine/src/shell/platform/unity/android/android_task_runner.h
  16. 0
      /engine/src/shell/platform/unity/android/android_task_runner.cc

23
com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanel.cs


using System.Collections;
using System.Collections.Generic;
using Unity.UIWidgets.engine2;
using engine2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;

}
#if !UNITY_EDITOR && UNITY_ANDROID
bool InitAnroidGLFlag = true;
bool AndroidInitialized = true;
IEnumerator InitAnroidGL() {
IEnumerator DoInitAndroid() {
AndroidGLInit.Init();
AndroidPlatformUtil.Init();
bool IsAndroidInitialized() {
if (AndroidInitialized) {
enabled = false;
AndroidInitialized = false;
startCoroutine(DoInitAndroid());
return false;
}
return true;
}
if (InitAnroidGLFlag) {
enabled = false;
InitAnroidGLFlag = false;
startCoroutine(InitAnroidGL());
return;
}
if (!IsAndroidInitialized()) {return ;}
#endif
base.OnEnable();

3
com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanelWrapper.cs


public void Initiate(IUIWidgetsWindow host, int width, int height, float dpr, Configurations _configurations) {
D.assert(renderTexture == null);
#if !UNITY_EDITOR && UNITY_ANDROID
AndroidUnpackStreamingAssets.OnEnable();
#endif
_recreateRenderTexture(width: width, height: height, devicePixelRatio: dpr);
_handle = GCHandle.Alloc(this);

20
engine/Build.bee.cs


//bee.exe mac
static void DeployAndroid()
{
Backend.Current.AddAliasDependency("android", new NPath("libUIWidgetsMac.xcodeproj/project.pbxproj"));
foreach (var dep in dependencies)
{
Backend.Current.AddAliasDependency("android", dep);

static void DeployMac()
{
var libUIWidgets = SetupLibUIWidgets(UIWidgetsBuildTargetPlatform.mac, out var dependencies);
var nativePrograms = new List<NativeProgram>();

{
Backend.Current.AddAliasDependency("mac", dep);
}
}
static void Main()

"src/shell/platform/unity/gfx_worker_task_runner.h",
"src/shell/platform/unity/uiwidgets_system.h",
"src/shell/platform/unity/android_unpack_streaming_asset.cc",
"src/shell/platform/unity/android_unpack_streaming_asset.h",
"src/shell/platform/unity/unity_console.cc",
"src/shell/platform/unity/unity_console.h",

var androidSource = new NPath[]
{
"src/shell/platform/unity/android_unpack_streaming_asset.cc",
"src/shell/platform/unity/android_unpack_streaming_asset.h",
"src/shell/platform/unity/android/cocoa_task_runner.cc",
"src/shell/platform/unity/android/android_task_runner.cc",
"src/shell/platform/unity/android/uiwidgets_panel.cc",
};

"-Wl,-z,now",
"-Wl,-z,relro",
"-Wl,-z,defs",
"--gcc-toolchain="+ Build.flutterRoot +
"--gcc-toolchain="+ flutterRoot +
"/third_party/android_tools/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64",
"-Wl,--no-undefined",
"-Wl,--exclude-libs,ALL",

"-nostdlib++",
"-Wl,--warn-shared-textrel",
"-nostdlib",
"--sysroot="+ Build.flutterRoot+"/third_party/android_tools/ndk/platforms/android-16/arch-arm",
"-L"+ Build.flutterRoot + "/third_party/android_tools/ndk/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a",
"--sysroot="+ flutterRoot+"/third_party/android_tools/ndk/platforms/android-16/arch-arm",
"-L"+ flutterRoot + "/third_party/android_tools/ndk/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a",
"-Wl,--build-id=sha1",
"-g",
"-Wl,-soname=libUIWidgets_d.so",

var buildNP = np.SetupSpecificConfiguration(config, androidToolchain.DynamicLibraryFormat).DeployTo("build");
var deoployNp = buildNP.DeployTo("../Samples/UIWidgetsSamples_2019_4/Assets/Plugins/Android");
buildNP.DeployTo("/Users/siyao/Documents/GitHub/untitled folder/unityLibrary/src/main/jniLibs/armeabi-v7a");
dependencies.Add(buildNP.Path);
dependencies.Add(deoployNp.Path);
}

{
var toolchain = ToolChain.Store.Host();
var validConfigurations = new List<NativeProgramConfiguration>();
foreach (var codegen in codegens)

4
engine/README.md


Follow https://github.com/flutter/flutter/wiki/Setting-up-the-Engine-development-environment
2. Checkout flutter-1.18-candidate.5
2. Checkout flutter-1.17-candidate.5
git checkout flutter-1.18-candidate.5
git checkout flutter-1.17-candidate.5
gclient sync -D
```

6
engine/src/assets/directory_asset_bundle.cc


#include "flutter/fml/file.h"
#include "flutter/fml/mapping.h"
#if __ANDROID__
#endif
namespace uiwidgets {
DirectoryAssetBundle::DirectoryAssetBundle(fml::UniqueFD descriptor)

}
#if __ANDROID__
const char* file = AndroidUnpackStreamingAsset::Unpack(asset_name.c_str());
AndroidUnpackStreamingAsset::Unpack(asset_name.c_str());
#endif
auto mapping = std::make_unique<fml::FileMapping>(fml::OpenFile(

9
engine/src/flow/raster_cache.cc


const SkRect& logical_rect)
: image_(std::move(image)), logical_rect_(logical_rect) {}
#if __ANDROID__
#define ABS(x) abs(x)
#define Math_abs(x) abs(x)
template<typename T>
T abs(T x) {
if (x < 0) {

}
#else
#define ABS(x) std::abs(x)
#define Math_abs(x) std::abs(x)
#endif
void RasterCacheResult::draw(SkCanvas& canvas, const SkPaint* paint) const {

RasterCache::GetDeviceBounds(logical_rect_, canvas.getTotalMatrix());
auto a = bounds.size().width() - image_->dimensions().width();
ABS(bounds.size().width() - image_->dimensions().width()) <= 1 &&
ABS(bounds.size().height() - image_->dimensions().height()) <= 1);
Math_abs(bounds.size().width() - image_->dimensions().width()) <= 1 &&
Math_abs(bounds.size().height() - image_->dimensions().height()) <= 1);
canvas.resetMatrix();
canvas.drawImage(image_, bounds.fLeft, bounds.fTop, paint);
}

3
engine/src/lib/ui/painting/skottie.cc


#include "skottie.h"
#include "lib/ui/ui_mono_state.h"
#if __ANDROID__
#endif
namespace uiwidgets {
fml::RefPtr<Skottie> Skottie::Create(char* path) {
#if __ANDROID__

4
engine/src/runtime/mono_api.cc


pthread_threadid_np(NULL, &tid);
return tid;
}
#endif
#ifdef __ANDROID__
#elif __ANDROID__
uint64_t GetCurrentThreadId() {
return gettid();
}

2
engine/src/shell/platform/unity/android/uiwidgets_panel.h


#include "shell/platform/unity/gfx_worker_task_runner.h"
#include "runtime/mono_api.h"
#include "unity_surface_manager.h"
#include "cocoa_task_runner.h"
#include "android_task_runner.h"
namespace uiwidgets {

2
engine/src/shell/platform/unity/android/android_task_runner.cc


#include "cocoa_task_runner.h"
#include "android_task_runner.h"
#include <flutter/fml/time/time_point.h>

49
com.unity.uiwidgets/Runtime/engine2/AndroidPlatformUtil.cs


#if !UNITY_EDITOR && UNITY_ANDROID
using UnityEngine;
using AOT;
using System;
using System.IO;
using System.Runtime.InteropServices;
using NativeBindings = Unity.UIWidgets.ui.NativeBindings;
namespace Unity.UIWidgets.engine2 {
public static class AndroidPlatformUtil {
[DllImport(NativeBindings.dllName)]
internal static extern void InitUnpackFile(UnpackFileCallback unpack);
internal delegate string UnpackFileCallback(string file);
[MonoPInvokeCallback(typeof(UnpackFileCallback))]
internal static string unpackFile(string file) {
var dir = Application.temporaryCachePath + "/";
if (!File.Exists(dir + file)) {
WWW unpackerWWW = new WWW("jar:file://" + Application.dataPath + "!/assets/" + file);
while (!unpackerWWW.isDone) {
} // This will block in the webplayer.
if (!string.IsNullOrEmpty(unpackerWWW.error)) {
Debug.Log("Error unpacking 'jar:file://" + Application.dataPath + "!/assets/" + file +
"'");
dir = "";
return dir + file;
}
File.WriteAllBytes(dir + file, unpackerWWW.bytes); // 64MB limit on File.WriteAllBytes.
}
return dir + file;
return "";
}
[DllImport(NativeBindings.dllName)]
static extern System.IntPtr GetUnityContextEventFunc();
public static void Init() {
if (Application.platform == RuntimePlatform.Android) {
InitUnpackFile(unpackFile);
GL.IssuePluginEvent(GetUnityContextEventFunc(), 1);
}
}
}
}
#endif

14
com.unity.uiwidgets/Runtime/engine2/AndroidGLInit.cs


using System.Runtime.InteropServices;
using Unity.UIWidgets.ui;
using UnityEngine;
namespace engine2 {
public class AndroidGLInit {
[DllImport(NativeBindings.dllName)]
static extern System.IntPtr GetUnityContextEventFunc();
public static void Init() {
GL.IssuePluginEvent(GetUnityContextEventFunc(), 1);
}
}
}

42
com.unity.uiwidgets/Runtime/engine2/AndroidUnpackStreamingAsset.cs


using UnityEngine;
using AOT;
using System;
using System.IO;
using System.Runtime.InteropServices;
using NativeBindings = Unity.UIWidgets.ui.NativeBindings;
public static class AndroidUnpackStreamingAssets {
[DllImport(NativeBindings.dllName)]
internal static extern void InitUnpackFile(UnpackFileCallback unpack);
internal delegate string UnpackFileCallback(string file);
[MonoPInvokeCallback(typeof(UnpackFileCallback))]
internal static string unpackFile(string file) {
if (Application.platform == RuntimePlatform.Android) {
var dir = Application.temporaryCachePath + "/";
if (!File.Exists(dir + file)) {
WWW unpackerWWW = new WWW("jar:file://" + Application.dataPath + "!/assets/" + file);
while (!unpackerWWW.isDone) {
} // This will block in the webplayer.
if (!string.IsNullOrEmpty(unpackerWWW.error)) {
Debug.Log("Error unpacking 'jar:file://" + Application.dataPath + "!/assets/" + file +
"'");
dir = "";
return dir + file;
}
File.WriteAllBytes(dir + file, unpackerWWW.bytes); // 64MB limit on File.WriteAllBytes.
}
return dir + file;
}
return "";
}
public static void OnEnable()
{
InitUnpackFile(unpackFile);
}
}

/com.unity.uiwidgets/Runtime/engine2/AndroidUnpackStreamingAsset.cs.meta → /com.unity.uiwidgets/Runtime/engine2/AndroidPlatformUtil.cs.meta

/engine/src/shell/platform/unity/android/cocoa_task_runner.h → /engine/src/shell/platform/unity/android/android_task_runner.h

/engine/src/shell/platform/unity/android/cocoa_task_runner.cc → /engine/src/shell/platform/unity/android/android_task_runner.cc

正在加载...
取消
保存