浏览代码

update lists

/siyaoH-1.17-PlatformMessage
siyao 4 年前
当前提交
157ecdc0
共有 5 个文件被更改,包括 30 次插入35 次删除
  1. 22
      com.unity.uiwidgets/Runtime/ui2/text.cs
  2. 25
      engine/src/lib/ui/text/paragraph.cc
  3. 6
      engine/src/lib/ui/text/paragraph.h
  4. 2
      engine/src/shell/common/lists.cc
  5. 10
      engine/src/shell/common/lists.h

22
com.unity.uiwidgets/Runtime/ui2/text.cs


static extern void Paragraph_layout(IntPtr ptr, float width);
[DllImport(NativeBindings.dllName)]
static extern IntPtr Paragraph_getRectsForRange(IntPtr ptr, int start, int end,
static extern ui_.BaseList Paragraph_getRectsForRange(IntPtr ptr, int start, int end,
static extern IntPtr Paragraph_getRectsForPlaceholders(IntPtr ptr);
static extern ui_.BaseList Paragraph_getRectsForPlaceholders(IntPtr ptr);
[DllImport(NativeBindings.dllName)]
static extern unsafe void Paragraph_getPositionForOffset(IntPtr ptr, float dx, float dy, int* encodedPtr);

static extern void Paragraph_paint(IntPtr ptr, IntPtr canvas, float x, float y);
[DllImport(NativeBindings.dllName)]
static extern IntPtr Paragraph_computeLineMetrics(IntPtr ptr);
static extern ui_.BaseList Paragraph_computeLineMetrics(IntPtr ptr);
[DllImport(NativeBindings.dllName)]
static extern void Paragraph_dispose(IntPtr ptr);

public List<TextBox> getBoxesForRange(int start, int end,
BoxHeightStyle boxHeightStyle = BoxHeightStyle.tight,
BoxWidthStyle boxWidthStyle = BoxWidthStyle.tight) {
var data = Marshal.PtrToStructure<ui_.BaseList>(_getBoxesForRange( start, end, (int) boxHeightStyle, (int) boxWidthStyle)).toFloatArrayAndFree();
var data = _getBoxesForRange( start, end, (int) boxHeightStyle, (int) boxWidthStyle).toFloatArrayAndFree();
IntPtr _getBoxesForRange(int start, int end, int boxHeightStyle, int boxWidthStyle) =>
ui_.BaseList _getBoxesForRange(int start, int end, int boxHeightStyle, int boxWidthStyle) =>
var dataPtr = _getBoxesForPlaceholders();
ui_.BaseList data2 = Marshal.PtrToStructure<ui_.BaseList>(dataPtr);
float[] data = data2.toFloatArrayAndFree();
return _decodeTextBoxes(data, data2.length);
float[] data = _getBoxesForPlaceholders().toFloatArrayAndFree();
return _decodeTextBoxes(data, data.Length);
unsafe IntPtr _getBoxesForPlaceholders() => Paragraph_getRectsForPlaceholders(_ptr);
ui_.BaseList _getBoxesForPlaceholders() => Paragraph_getRectsForPlaceholders(_ptr);
public unsafe TextPosition getPositionForOffset(Offset offset) {
int[] encoded = new int[2];

}
public List<LineMetrics> computeLineMetrics() {
var data = Marshal.PtrToStructure<ui_.BaseList>(_computeLineMetrics()).toFloatArrayAndFree();
var data = _computeLineMetrics().toFloatArrayAndFree();
int count = data.Length / 9;
int position = 0;
List<LineMetrics> metrics = new List<LineMetrics>();

return metrics;
}
IntPtr _computeLineMetrics() => Paragraph_computeLineMetrics(_ptr);
ui_.BaseList _computeLineMetrics() => Paragraph_computeLineMetrics(_ptr);
}
public class ParagraphBuilder : NativeWrapper {

25
engine/src/lib/ui/text/paragraph.cc


// First value is the number of values.
// Then there are boxes.size() groups of 5 which are LTRBD, where D is the
// text direction index.
Float32List result = {new float[boxes.size() * 5], boxes.size() * 5};
int size = boxes.size() * 5;
Float32List result = {(float*)malloc(sizeof(float) * size),
boxes.size() * size};
unsigned long position = 0;
for (unsigned long i = 0; i < boxes.size(); i++) {
const txt::Paragraph::TextBox& box = boxes[i];

}
}
Float32List* Paragraph::getRectsForRange(unsigned start, unsigned end,
Float32List Paragraph::getRectsForRange(unsigned start, unsigned end,
return &EncodeTextBoxes(boxes);
return EncodeTextBoxes(boxes);
Float32List* Paragraph::getRectsForPlaceholders() {
Float32List Paragraph::getRectsForPlaceholders() {
return &EncodeTextBoxes(boxes);
return EncodeTextBoxes(boxes);
}
void Paragraph::getPositionForOffset(float dx, float dy, int* offset) {

boundaryPtr[1] = line_end;
}
Float32List* Paragraph::computeLineMetrics() {
Float32List Paragraph::computeLineMetrics() {
std::vector<txt::LineMetrics> metrics = m_paragraph->GetLineMetrics();
// Layout:

Float32List result = {new float[size], size};
Float32List result = {(float*)malloc(sizeof(float) * size), size};
unsigned long position = 0;
for (unsigned long i = 0; i < metrics.size(); i++) {
const txt::LineMetrics& line = metrics[i];

result.data[position++] = line.baseline;
result.data[position++] = static_cast<float>(line.line_number);
}
return &result;
return result;
}
UIWIDGETS_API(float) Paragraph_width(Paragraph* ptr) { return ptr->width(); }

ptr->layout(width);
}
UIWIDGETS_API(Float32List*)
UIWIDGETS_API(Float32List)
UIWIDGETS_API(Float32List*)
UIWIDGETS_API(Float32List)
Paragraph_getRectsForPlaceholders(Paragraph* ptr) {
return ptr->getRectsForPlaceholders();
}

ptr->paint(canvas, x, y);
}
UIWIDGETS_API(Float32List*)
UIWIDGETS_API(Float32List)
Paragraph_computeLineMetrics(Paragraph* ptr, float* data) {
return ptr->computeLineMetrics();
}

6
engine/src/lib/ui/text/paragraph.h


void layout(float width);
void paint(Canvas* canvas, float x, float y);
Float32List* getRectsForRange(unsigned start, unsigned end,
Float32List getRectsForRange(unsigned start, unsigned end,
Float32List* getRectsForPlaceholders();
Float32List getRectsForPlaceholders();
Float32List* computeLineMetrics();
Float32List computeLineMetrics();
size_t GetAllocationSize();
std::unique_ptr<txt::Paragraph> m_paragraph;

2
engine/src/shell/common/lists.cc


namespace uiwidgets {
namespace {
UIWIDGETS_API(void) Lists_Free(void* data) { delete []data; } // namespace
UIWIDGETS_API(void) Lists_Free(void* data) { free(data); } // namespace
} // namespace
} // namespace uiwidgets

10
engine/src/shell/common/lists.h


#include "runtime/mono_api.h"
namespace uiwidgets {
#define DATALIST(T, N) \
extern "C" struct N { \
T* data; \
int length; \
struct Float32List {
float* data;
int length;
DATALIST(float, Float32List)
DATALIST(int, Int32List)
DATALIST(char, CharList)
} // namespace uiwidgets
正在加载...
取消
保存