浏览代码

temp

/siyaoH-1.17-PlatformMessage
siyao 4 年前
当前提交
a86821aa
共有 10 个文件被更改,包括 871 次插入225 次删除
  1. 19
      com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanel.cs
  2. 2
      com.unity.uiwidgets/Runtime/ui2/native_bindings.cs
  3. 2
      engine/Build.bee.cs
  4. 12
      engine/src/shell/platform/unity/android/uiwidgets_panel.cc
  5. 480
      engine/src/shell/platform/unity/android/unity_surface_manager.cc
  6. 28
      engine/src/shell/platform/unity/android/unity_surface_manager.h
  7. 64
      Samples/UIWidgetsSamples_2019_4/Assets/ANT.cs
  8. 11
      Samples/UIWidgetsSamples_2019_4/Assets/ANT.cs.meta
  9. 471
      Samples/UIWidgetsSamples_2019_4/Assets/ANT.unity
  10. 7
      Samples/UIWidgetsSamples_2019_4/Assets/ANT.unity.meta

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


using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using Color = UnityEngine.Color;
namespace Unity.UIWidgets.engine2 {

}
static bool _ShowDebugLog = false;
Texture2D targetTexture = null;
protected void OnEnable() {
base.OnEnable();

D.assert(_wrapper == null);
_wrapper = new UIWidgetsPanelWrapper();
_wrapper.Initiate(this, _currentWidth, _currentHeight, _currentDevicePixelRatio, settings);
texture = _wrapper.renderTexture;
if (targetTexture == null) {
targetTexture = new Texture2D(_currentWidth, _currentHeight, TextureFormat.BGRA32, 1, true);
// GetComponent<Renderer>().material.mainTexture = targetTexture;
Debug.Log($"{_currentWidth}, {_currentHeight}");
for (int y = 0; y < _currentHeight; y++) {
for (int x = 0; x < _currentWidth; x++) {
targetTexture.SetPixel(x, y, Color.green);
}
}
targetTexture.Apply();
}
texture = targetTexture;
Input_OnEnable();

}
protected virtual void Update() {
Graphics.CopyTexture(_wrapper.renderTexture,0,0, 100, 100, 400, 400, targetTexture, 0, 0, 100, 100);
Input_Update();
}

2
com.unity.uiwidgets/Runtime/ui2/native_bindings.cs


#if (UNITY_IOS || UNITY_TVOS || UNITY_WEBGL) && !UNITY_EDITOR
internal const string dllName = "__Internal";
#else
internal const string dllName = "libUIWidgets_d";
public const string dllName = "libUIWidgets_d";
#endif
}

2
engine/Build.bee.cs


var builtNP = np.SetupSpecificConfiguration(config, androidToolchain.DynamicLibraryFormat).DeployTo("build");
builtNP.DeployTo("../Samples/UIWidgetsSamples_2019_4/Assets/Plugins/Android");
builtNP.DeployTo("/Users/siyao/Documents/GitHub/untitled folder 2/unityLibrary/src/main/jniLibs/armeabi-v7a");
builtNP.DeployTo("/Users/siyao/Documents/GitHub/untitled folder 3/unityLibrary/src/main/jniLibs/armeabi-v7a");
}
np.ValidConfigurations = validConfigurations;
}

12
engine/src/shell/platform/unity/android/uiwidgets_panel.cc


FML_DCHECK(fbo_ == 0);
surface_manager_->MakeCurrent(EGL_NO_DISPLAY);
fbo_ = surface_manager_->CreateRenderSurface(native_texture_ptr);
fbo_ = surface_manager_->CreateRenderSurface(native_texture_ptr, width, height);
surface_manager_->ClearCurrent();
// fml::AutoResetWaitableEvent latch;

UIWIDGETS_API(void)
UIWidgetsPanel_onMouseLeave(UIWidgetsPanel* panel) { panel->OnMouseLeave(); }
} // namespace uiwidgets
UIWIDGETS_API(void)
SetTextureFromUnity(void* tex, int w, int h) { UnitySurfaceManager::SetTextureFromUnity(tex, w, h); }
UIWIDGETS_API(void)
draw_xxx() { UnitySurfaceManager::drawxxx(); }
} // namespace uiwidgets

480
engine/src/shell/platform/unity/android/unity_surface_manager.cc


#undef LOAD_VULKAN_FUNC
}
#else
// #define VERTEX_SHADER_SRC(ver, attr, varying) \
// ver \
// attr " highp vec3 pos;\n" attr " lowp vec4 color;\n" \
// "\n" varying " lowp vec4 ocolor;\n" \
// "\n" \
// "uniform highp mat4 worldMatrix;\n" \
// "uniform highp mat4 projMatrix;\n" \
// "\n" \
// "void main()\n" \
// "{\n" \
// " gl_Position = (projMatrix * worldMatrix) * vec4(pos,1);\n" \
// " ocolor = color;\n" \
// "}\n"
// static const char *kGlesVProgTextGLES2 = VERTEX_SHADER_SRC("\n", "attribute", "varying");
// static const char *kGlesVProgTextGLES3 = VERTEX_SHADER_SRC("#version 300 es\n", "in", "out");
// #define FRAGMENT_SHADER_SRC(ver, varying, outDecl, outVar) \
// ver \
// outDecl \
// varying " lowp vec4 ocolor;\n" \
// "\n" \
// "void main()\n" \
// "{\n" \
// " " outVar " = ocolor;\n" \
// "}\n"
// static const char *kGlesFShaderTextGLES2 = FRAGMENT_SHADER_SRC("\n", "varying", "\n", "gl_FragColor");
// static const char *kGlesFShaderTextGLES3 = FRAGMENT_SHADER_SRC("#version 300 es\n", "in", "out lowp vec4 fragColor;\n", "fragColor");
// enum VertexInputs
// {
// kVertexInputPosition = 0,
// kVertexInputColor = 1
// };
template <class T>
using EGLResult = std::pair<bool, T>;

#else
egl_display_(EGL_NO_DISPLAY),
egl_context_(EGL_NO_CONTEXT),
egl_resource_context_(EGL_NO_CONTEXT)
egl_resource_context_(EGL_NO_CONTEXT),
surface(EGL_NO_SURFACE)
// egl_config_(nullptr)
#endif
{

UnitySurfaceManager::~UnitySurfaceManager() { CleanUp(); }
GLuint UnitySurfaceManager::CreateRenderSurface(void *native_texture_ptr)
GLuint UnitySurfaceManager::CreateRenderSurface(void *native_texture_ptr, size_t width, size_t height)
int width = 100;
int height = 100;
#ifdef VulkanX
UnityVulkanImage image;

// canvas->drawTextBlob(text.get(), 50, 25, paint2);
canvas->flush();
#else
gr_context_ = ShellIOManager::CreateCompatibleResourceLoadingContext(
GrBackend::kOpenGL_GrBackend,
GPUSurfaceGLDelegate::GetDefaultPlatformGLInterface());
// gr_context_ = GrContext::MakeGL();
// unsigned int texture;
// glGenTextures(1, &texture);
int rowPitch = width * 4;
unsigned char *data = new unsigned char[rowPitch * height];
GrGLTextureInfo textureInfo;
textureInfo.fTarget = GR_GL_TEXTURE_2D;
textureInfo.fID = GrGLuint((long)native_texture_ptr);
textureInfo.fFormat = GR_GL_RGBA8;
unsigned char *dst = (unsigned char *)data;
for (size_t y = 0; y < height; ++y)
{
unsigned char *ptr = dst;
for (size_t x = 0; x < width; ++x)
{
// Simple "plasma effect": several combined sine waves
int vv = 255;
GrBackendTexture m_backendTex =
GrBackendTexture(width, height, GrMipMapped::kNo, textureInfo);
// Write the texture pixel
ptr[0] = vv;
// ptr[1] = vv;
// ptr[2] = vv;
ptr[3] = vv;
m_SkSurface = SkSurface::MakeFromBackendTexture(
gr_context_.get(), m_backendTex, kBottomLeft_GrSurfaceOrigin, 1,
kRGBA_8888_SkColorType, nullptr, nullptr);
SkCanvas *canvas = m_SkSurface->getCanvas();
// To next pixel (our pixels are 4 bpp)
ptr += 4;
}
canvas->drawColor(SK_ColorBLUE);
SkPaint paint;
// To next image row
dst += rowPitch;
}
GLuint gltex = (GLuint)(size_t)(native_texture_ptr);
glBindTexture(GL_TEXTURE_2D, gltex);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
SkRect rect = SkRect::MakeXYWH(50, 50, 40, 60);
canvas->drawRect(rect, paint);
// glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, native_texture_ptr);
// glGenerateMipmap(GL_TEXTURE_2D);
delete[](unsigned char *) data;
// glClearColor(1,0,0,1.0);
// glClear(GL_COLOR_BUFFER_BIT);
// gr_context_ = ShellIOManager::CreateCompatibleResourceLoadingContext(
// GrBackend::kOpenGL_GrBackend,
// GPUSurfaceGLDelegate::GetDefaultPlatformGLInterface());
// GrGLTextureInfo textureInfo;
// textureInfo.fTarget = GR_GL_TEXTURE_2D;
// textureInfo.fID = GrGLuint((long)native_texture_ptr);
// textureInfo.fFormat = GR_GL_RGBA8;
// // egl_context_
// GrBackendTexture m_backendTex =
// GrBackendTexture(width, height, GrMipMapped::kNo, textureInfo);
// m_SkSurface = SkSurface::MakeFromBackendTexture(
// gr_context_.get(), m_backendTex, kBottomLeft_GrSurfaceOrigin, 1,
// kRGBA_8888_SkColorType, nullptr, nullptr);
// SkCanvas *canvas = m_SkSurface->getCanvas();
// canvas->drawColor(SK_ColorBLUE);
// SkPaint paint;
// SkRect rect = SkRect::MakeXYWH(50, 50, 40, 60);
// canvas->drawRect(rect, paint);
#endif
return fbo_;

// return ret;
// }
// static void updatePixel(void *textureDataPtr, int width, int height, int textureRowPitch)
// {
// if (!textureDataPtr)
// return;
// unsigned char *dst = (unsigned char *)textureDataPtr;
// for (int y = 0; y < height; ++y)
// {
// unsigned char *ptr = dst;
// for (int x = 0; x < width; ++x)
// {
// // Simple "plasma effect": several combined sine waves
// int vv = 255;
// // Write the texture pixel
// ptr[0] = vv;
// // ptr[1] = vv;
// // ptr[2] = vv;
// ptr[3] = vv;
// // To next pixel (our pixels are 4 bpp)
// ptr += 4;
// }
// // To next image row
// dst += textureRowPitch;
// }
// return;
// }
static EGLResult<EGLConfig> ChooseEGLConfiguration(EGLDisplay display)
{
EGLint attributes[] = {

#endif
egl_display_ = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (egl_display_ == EGL_NO_DISPLAY)
{
FML_CHECK(false)
<< "Renderer type is invalid";
}
FML_CHECK(egl_display_ != EGL_NO_DISPLAY)
<< "Renderer type is invalid";
if (eglInitialize(egl_display_, nullptr, nullptr) != EGL_TRUE)
{
FML_CHECK(false)
<< "Renderer type is invalid";
}
FML_CHECK(eglInitialize(egl_display_, nullptr, nullptr) == EGL_TRUE)
<< "Renderer type is invalid";
auto valid_ = true;

if (!success)
{
FML_CHECK(false) << "Could not choose an EGL configuration.";
// LogLastEGLError();
// return;
}
EGLDisplay display = egl_display_;
FML_CHECK(success) << "Could not choose an EGL configuration.";
EGLSurface surface_ = eglCreatePbufferSurface(display, egl_config_, attribs);
success = surface_ != EGL_NO_SURFACE;
surface = eglCreatePbufferSurface(egl_display_, egl_config_, attribs);
success = surface != EGL_NO_SURFACE;
egl_context_ = eglCreateContext(display, egl_config_, EGL_NO_CONTEXT, attributes);
EGLDisplay display2 = egl_display_;
const EGLint attribs2[] = {EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE};
surface_ = eglCreatePbufferSurface(display2, egl_config_, attribs2);
auto xxx = surface_ != EGL_NO_SURFACE;
// auto egl_display_ = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE,
// EGL_DEFAULT_DISPLAY, displayAttribs);
// IUnityGraphics *graphics = unity_interfaces->Get<IUnityGraphics>();
// UnityGfxRenderer renderer = graphics->GetRenderer();
// if (renderer == kUnityGfxRendererOpenGLES20)
// {
// m_VertexShader = CreateShader(GL_VERTEX_SHADER, kGlesVProgTextGLES2);
// m_FragmentShader = CreateShader(GL_FRAGMENT_SHADER, kGlesFShaderTextGLES2);
// }
// else if (renderer == kUnityGfxRendererOpenGLES30)
// {
// m_VertexShader = CreateShader(GL_VERTEX_SHADER, kGlesVProgTextGLES3);
// m_FragmentShader = CreateShader(GL_FRAGMENT_SHADER, kGlesFShaderTextGLES3);
// }
// else
// {
// FML_CHECK(false)
// << "Renderer type is invalid";
// }
// m_Program = glCreateProgram();
// glBindAttribLocation(m_Program, kVertexInputPosition, "pos");
// glBindAttribLocation(m_Program, kVertexInputColor, "color");
// glAttachShader(m_Program, m_VertexShader);
// glAttachShader(m_Program, m_FragmentShader);
// glLinkProgram(m_Program);
// GLint status = 0;
// glGetProgramiv(m_Program, GL_LINK_STATUS, &status);
// assert(status == GL_TRUE);
// m_UniformWorldMatrix = glGetUniformLocation(m_Program, "worldMatrix");
// m_UniformProjMatrix = glGetUniformLocation(m_Program, "projMatrix");
// // Create vertex buffer
// glGenBuffers(1, &m_VertexBuffer);
// glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
// glBufferData(GL_ARRAY_BUFFER, 1024, NULL, GL_STREAM_DRAW);
// FML_CHECK(glGetError() == GL_NO_ERROR);
// UnityVulkanInstance instance = vulkan->Instance();
// VkDevice device = instance.device;
// ID3D11Device* d3d11_device = d3d11->GetDevice();
// IDXGIDevice* dxgi_device;
// HRESULT hr = d3d11_device->QueryInterface(
// __uuidof(IDXGIDevice), reinterpret_cast<void**>(&dxgi_device));
// FML_CHECK(SUCCEEDED(hr)) << "d3d11_device->QueryInterface(...) failed";
// IDXGIAdapter* dxgi_adapter;
// hr = dxgi_device->GetAdapter(&dxgi_adapter);
// FML_CHECK(SUCCEEDED(hr)) << "dxgi_adapter->GetAdapter(...) failed";
// dxgi_device->Release();
// DXGI_ADAPTER_DESC adapter_desc;
// hr = dxgi_adapter->GetDesc(&adapter_desc);
// FML_CHECK(SUCCEEDED(hr)) << "dxgi_adapter->GetDesc(...) failed";
// dxgi_adapter->Release();
// EGLint displayAttribs[] = {EGL_PLATFORM_ANGLE_TYPE_ANGLE,
// EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
// EGL_PLATFORM_ANGLE_D3D_LUID_HIGH_ANGLE,
// adapter_desc.AdapterLuid.HighPart,
// EGL_PLATFORM_ANGLE_D3D_LUID_LOW_ANGLE,
// adapter_desc.AdapterLuid.LowPart,
// EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE,
// EGL_TRUE,
// EGL_NONE};
// egl_display_ = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE,
// EGL_DEFAULT_DISPLAY, displayAttribs);
// FML_CHECK(egl_display_ != EGL_NO_DISPLAY)
// << "EGL: Failed to get a compatible EGLdisplay";
// if (eglInitialize(egl_display_, nullptr, nullptr) == EGL_FALSE) {
// FML_CHECK(false) << "EGL: Failed to initialize EGL";
// }
// EGLAttrib egl_device = 0;
// eglQueryDisplayAttribEXT(egl_display_, EGL_DEVICE_EXT, &egl_device);
// EGLAttrib angle_device = 0;
// eglQueryDeviceAttribEXT(reinterpret_cast<EGLDeviceEXT>(egl_device),
// EGL_D3D11_DEVICE_ANGLE, &angle_device);
// d3d11_device_ = reinterpret_cast<ID3D11Device*>(angle_device);
// const EGLint configAttributes[] = {EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8,
// EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8,
// EGL_DEPTH_SIZE, 8, EGL_STENCIL_SIZE, 8,
// EGL_NONE};
// EGLint numConfigs = 0;
// if (eglChooseConfig(egl_display_, configAttributes, &egl_config_, 1,
// &numConfigs) == EGL_FALSE ||
// numConfigs == 0) {
// FML_CHECK(false) << "EGL: Failed to choose first context";
// }
// const EGLint display_context_attributes[] = {EGL_CONTEXT_CLIENT_VERSION, 2,
// EGL_NONE};
// egl_context_ = eglCreateContext(egl_display_, egl_config_, EGL_NO_CONTEXT,
// display_context_attributes);
// if (egl_context_ == EGL_NO_CONTEXT) {
// FML_CHECK(false) << "EGL: Failed to create EGL context";
// }
// egl_resource_context_ = eglCreateContext(
// egl_display_, egl_config_, egl_context_, display_context_attributes);
// if (egl_resource_context_ == EGL_NO_CONTEXT) {
// FML_CHECK(false) << "EGL: Failed to create EGL resource context";
// }
egl_context_ = eglCreateContext(egl_display_, egl_config_, EGL_NO_CONTEXT, attributes);
return true;
}

// gr_context_.get(), m_backendTex, kBottomLeft_GrSurfaceOrigin, 1,
// kRGBA_8888_SkColorType, nullptr, nullptr);
}
static void *g_TextureHandle = NULL;
static int wi = 0;
static int he = 0;
static EGLDisplay egl_display_s;
static EGLConfig egl_config_s;
static EGLSurface surfaces;
static EGLContext egl_context_s;
static GLenum state;
static bool inited = false;
void UnitySurfaceManager::SetTextureFromUnity(void *tex, int w, int h)
{
g_TextureHandle = tex;
wi = w;
he = h;
// egl_display_s = eglGetDisplay(EGL_DEFAULT_DISPLAY);
// FML_CHECK(egl_display_s != EGL_NO_DISPLAY)
// << "Renderer type is invalid";
// state = glGetError();
// // Initialize the display connection.
// FML_CHECK(eglInitialize(egl_display_s, nullptr, nullptr) == EGL_TRUE)
// << "Renderer type is invalid";
// state = glGetError();
// bool success = false;
// std::tie(success, egl_config_s) = ChooseEGLConfiguration(egl_display_s);
// FML_CHECK(success) << "Could not choose an EGL configuration.";
// // state = glGetError();
// EGLint attributes[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE};
// egl_context_s = eglCreateContext(egl_display_s, egl_config_s, EGL_NO_CONTEXT, attributes);
// // state = glGetError();
// int k = 0;
}
void UnitySurfaceManager::drawxxx()
{
GLuint gltex = (GLuint)(size_t)(g_TextureHandle);
glBindTexture(GL_TEXTURE_2D, gltex);
state = glGetError();
auto check = state == GL_INVALID_FRAMEBUFFER_OPERATION;
int rowPitch = wi * 4;
unsigned char *data = new unsigned char[rowPitch * he];
// // glGetTexImage(gltex, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
unsigned char *dst = (unsigned char *)data;
for (int y = 0; y < he; ++y)
{
unsigned char *ptr = dst;
for (int x = 0; x < wi; ++x)
{
// Simple "plasma effect": several combined sine waves
int vv = 244;
// Write the texture pixel
ptr[0] = vv;
ptr[1] = vv;
ptr[2] = vv;
ptr[3] = vv;
// To next pixel (our pixels are 4 bpp)
ptr += 4;
}
// To next image row
dst += rowPitch;
}
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, wi, he, GL_RGBA, GL_UNSIGNED_BYTE, data);
state = eglGetError();
delete[](unsigned char *) data;
// auto ss = eglMakeCurrent(egl_display_s, EGL_NO_SURFACE, EGL_NO_SURFACE,
// egl_context_s) == GL_TRUE;
// state = glGetError();
// if (!inited)
// {
// unsigned int fbo = 0;
// glGenFramebuffers(1, &fbo);
// state = glGetError();
// glBindFramebuffer(GL_FRAMEBUFFER, fbo);
// state = glGetError();
// GLuint gltex = (GLuint)(size_t)(g_TextureHandle);
// // glBindTexture(GL_TEXTURE_2D, gltex);
// // state = glGetError();
// unsigned int texture;
// glGenTextures(1, &texture);
// glBindTexture(GL_TEXTURE_2D, texture);
// int rowPitch = 20 * 4;
// unsigned char *data = new unsigned char[rowPitch * 20];
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 20, 20, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
// state = glGetError();
// glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
// state = glGetError();
// // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
// // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// if (glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE)
// {
// int i = 0;
// }
// else
// {
// int j = 0;
// }
// inited = true;
// }
// else
// {
// state = glGetError();
// auto xxxxx = glCheckFramebufferStatus(GL_FRAMEBUFFER);
// if (xxxxx == GL_FRAMEBUFFER_COMPLETE)
// {
// int i = 0;
// }
// else
// {
// int j = 0;
// }
// GLuint gltex = (GLuint)(size_t)(g_TextureHandle);
// glBindTexture(GL_TEXTURE_2D, gltex);
// state = glGetError();
// auto check = state == GL_INVALID_FRAMEBUFFER_OPERATION;
// int rowPitch = wi * 4;
// unsigned char *data = new unsigned char[rowPitch * he];
// // // glGetTexImage(gltex, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
// unsigned char *dst = (unsigned char *)data;
// for (int y = 0; y < he; ++y)
// {
// unsigned char *ptr = dst;
// for (int x = 0; x < wi; ++x)
// {
// // Simple "plasma effect": several combined sine waves
// int vv = 255;
// // Write the texture pixel
// ptr[0] = vv;
// // ptr[1] = vv;
// // ptr[2] = vv;
// ptr[3] = vv;
// // To next pixel (our pixels are 4 bpp)
// ptr += 4;
// }
// // To next image row
// dst += rowPitch;
// }
// glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, wi, he, GL_RGBA, GL_UNSIGNED_BYTE, data);
// state = eglGetError();
// delete[](unsigned char *) data;
// // glClearColor(1, 0, 0, 1.0);
// // glClear(GL_COLOR_BUFFER_BIT);
// state = eglGetError();
// }
// ss = eglMakeCurrent(egl_display_s, EGL_NO_SURFACE, EGL_NO_SURFACE,
// EGL_NO_CONTEXT) == GL_TRUE;
// state = glGetError();
// int kk = 0;
}
} // namespace uiwidgets

28
engine/src/shell/platform/unity/android/unity_surface_manager.h


class UnitySurfaceManager
{
public:
static UnitySurfaceManager instance;
static void SetTextureFromUnity(void* tex, int w, int h);
static void drawxxx();
GLuint CreateRenderSurface(void *native_texture_ptr);
GLuint CreateRenderSurface(void *native_texture_ptr, size_t width, size_t height);
void DestroyRenderSurface();
bool ClearCurrent();

UnityVulkanInstance m_Instance;
#endif
GrBackendTexture m_backendTex;
GrGLTextureInfo textureInfo;
sk_sp<SkSurface> m_SkSurface;
// GrBackendTexture m_backendTex;
// GrGLTextureInfo textureInfo;
// sk_sp<SkSurface> m_SkSurface;
sk_sp<GrContext> gr_context_;
// sk_sp<GrContext> gr_context_;
EGLDisplay egl_display_;
EGLContext egl_context_;

EGLSurface surface;
// ID3D11Device* d3d11_device_;
// EGLImage fbo_egl_image_ = nullptr;
// GLuint fbo_texture_ = 0;
// GLuint m_VertexShader;
// GLuint m_FragmentShader;
// GLuint m_Program;
// GLuint m_VertexArray;
// GLuint m_VertexBuffer;
// int m_UniformWorldMatrix;
// int m_UniformProjMatrix;
};
} // namespace uiwidgets

64
Samples/UIWidgetsSamples_2019_4/Assets/ANT.cs


using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Unity.UIWidgets.ui;
using UnityEngine;
using Color = UnityEngine.Color;
public class ANT : MonoBehaviour
{
[DllImport(NativeBindings.dllName)]
private static extern void SetTextureFromUnity(System.IntPtr texture, int w, int h);
[DllImport(NativeBindings.dllName)]
private static extern void draw_xxx();
// Start is called before the first frame update
void Start()
{
CreateTextureAndPassToPlugin();
}
private void CreateTextureAndPassToPlugin()
{
// Create a texture
Texture2D tex = new Texture2D(20, 20, TextureFormat.ARGB32, false);
// Set point filtering just so we can see the pixels clearly
tex.filterMode = FilterMode.Point;
// Call Apply() so it's actually uploaded to the GPU
tex.Apply();
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 10; j++)
{
tex.SetPixel(i, j, Color.magenta);
}
}
tex.Apply();
// Set texture onto our material
GetComponent<Renderer>().material.mainTexture = tex;
#if !UNITY_EDITOR
// Pass texture pointer to the plugin
SetTextureFromUnity (tex.GetNativeTexturePtr(), tex.width, tex.height);
#endif
}
// Update is called once per frame
void Update()
{
#if !UNITY_EDITOR
var tex = (Texture2D)GetComponent<Renderer>().material.mainTexture;
Debug.Log("update");
draw_xxx();
Debug.Log("22");
tex.Apply();
Debug.Log("apply");
#endif
}
}

11
Samples/UIWidgetsSamples_2019_4/Assets/ANT.cs.meta


fileFormatVersion: 2
guid: aa747e6fb83a24dc9a775f403f818d85
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

471
Samples/UIWidgetsSamples_2019_4/Assets/ANT.unity


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 256
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 1
m_PVRDenoiserTypeDirect: 1
m_PVRDenoiserTypeIndirect: 1
m_PVRDenoiserTypeAO: 1
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &156821295
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 156821298}
- component: {fileID: 156821297}
- component: {fileID: 156821296}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &156821296
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 156821295}
m_Enabled: 1
--- !u!20 &156821297
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 156821295}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &156821298
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 156821295}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1206932713
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1206932716}
- component: {fileID: 1206932715}
- component: {fileID: 1206932714}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1206932714
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1206932713}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &1206932715
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1206932713}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 10
--- !u!4 &1206932716
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1206932713}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1313087942
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1313087946}
- component: {fileID: 1313087945}
- component: {fileID: 1313087944}
- component: {fileID: 1313087943}
- component: {fileID: 1313087947}
m_Layer: 0
m_Name: Plane
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!64 &1313087943
MeshCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1313087942}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 4
m_Convex: 0
m_CookingOptions: 30
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &1313087944
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1313087942}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 1c3f3f83b433c4572af5252129faaa72, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &1313087945
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1313087942}
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &1313087946
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1313087942}
m_LocalRotation: {x: -0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0}
--- !u!114 &1313087947
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1313087942}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: aa747e6fb83a24dc9a775f403f818d85, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1953640782
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1953640784}
- component: {fileID: 1953640783}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &1953640783
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1953640782}
m_Enabled: 1
serializedVersion: 10
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.802082
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 4
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &1953640784
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1953640782}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}

7
Samples/UIWidgetsSamples_2019_4/Assets/ANT.unity.meta


fileFormatVersion: 2
guid: 0f4091ef47c8c4d9f9e6b68acb464c91
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存