浏览代码

Merge pull request #21 from Unity-Technologies/zxw/skiaBase

add missing native bindings
/siyaoH-1.17-PlatformMessage
GitHub 4 年前
当前提交
8c689b1c
共有 6 个文件被更改,包括 182 次插入83 次删除
  1. 59
      com.unity.uiwidgets/Runtime/ui2/compositing.cs
  2. 39
      com.unity.uiwidgets/Runtime/ui2/painting.cs
  3. 2
      engine/Build.bee.cs
  4. 54
      engine/src/lib/ui/compositing/scene_builder.cc
  5. 79
      engine/src/lib/ui/painting/path_measure.cc
  6. 32
      engine/src/lib/ui/painting/path_measure.h

59
com.unity.uiwidgets/Runtime/ui2/compositing.cs


Clip clipBehavior = Clip.none,
PhysicalShapeEngineLayer oldLayer = null) {
D.assert(_debugCheckCanBeUsedAsOldLayer(oldLayer, "PhysicalShapeEngineLayer"));
PhysicalShapeEngineLayer layer = new PhysicalShapeEngineLayer(SceneBuilder_pushPhysicalShape(_ptr, path._ptr, elevation, color.value, shadowColor?.value ?? 0xFF000000, (int)clipBehavior));
PhysicalShapeEngineLayer layer = new PhysicalShapeEngineLayer(SceneBuilder_pushPhysicalShape(_ptr, path._ptr, elevation, (int)color.value, (int)(shadowColor?.value ?? 0xFF000000), (int)clipBehavior));
D.assert(_debugPushLayer(layer));
return layer;
}

[DllImport(NativeBindings.dllName)]
static extern IntPtr SceneBuilder_pushOffset(IntPtr ptr, float dx, float dy);
/*
int clipBehavior);*/
static IntPtr SceneBuilder_pushClipRect(IntPtr ptr, float left, float right, float top, float bottom,
int clipBehavior) {
D.assert(false, () => "SceneBuilder_pushClipRect is not implemented yet!");
return IntPtr.Zero;
}
int clipBehavior);
/*
static extern unsafe IntPtr SceneBuilder_pushClipRRect(IntPtr ptr, float* rrect, int clipBehavior);*/
static unsafe IntPtr SceneBuilder_pushClipRRect(IntPtr ptr, float* rrect, int clipBehavior) {
D.assert(false, () => "SceneBuilder_pushClipRRect is not implemented yet!");
return IntPtr.Zero;
}
static extern unsafe IntPtr SceneBuilder_pushClipRRect(IntPtr ptr, float* rrect, int clipBehavior);
/*
static extern IntPtr SceneBuilder_pushClipPath(IntPtr ptr, IntPtr path, int clipBehavior);*/
static unsafe IntPtr SceneBuilder_pushClipPath(IntPtr ptr, IntPtr path, int clipBehavior) {
D.assert(false, () => "SceneBuilder_pushClipPath is not implemented yet!");
return IntPtr.Zero;
}
static extern IntPtr SceneBuilder_pushClipPath(IntPtr ptr, IntPtr path, int clipBehavior);
/*
static extern IntPtr SceneBuilder_pushOpacity(IntPtr ptr, int alpha, float dx, float dy);*/
static IntPtr SceneBuilder_pushOpacity(IntPtr ptr, int alpha, float dx, float dy) {
D.assert(false, () => "SceneBuilder_pushOpacity is not implemented yet!");
return IntPtr.Zero;
}
static extern IntPtr SceneBuilder_pushOpacity(IntPtr ptr, int alpha, float dx, float dy);
/*
static extern IntPtr SceneBuilder_pushBackdropFilter(IntPtr ptr, IntPtr filter);*/
static extern IntPtr SceneBuilder_pushBackdropFilter(IntPtr ptr, IntPtr filter);
static IntPtr SceneBuilder_pushBackdropFilter(IntPtr ptr, IntPtr filter) {
D.assert(false, () => "SceneBuilder_pushBackdropFilter is not implemented yet!");
return IntPtr.Zero;
}
/*
float bottom);*/
static void SceneBuilder_addPerformanceOverlay(int enabledOptions, float left, float right, float top,
float bottom) {
D.assert(false, () => "SceneBuilder_addPerformanceOverlay is not implemented yet!");
}
float bottom);
/*
static extern IntPtr SceneBuilder_pushPhysicalShape(IntPtr ptr, IntPtr path, float evelation, uint color,
uint shadowColor, int clipBehavior);*/
static IntPtr SceneBuilder_pushPhysicalShape(IntPtr ptr, IntPtr path, float elevation, uint color,
uint shadowColor, int clipBehavior) {
D.assert(false, () => "SceneBuilder_pushPhysicalShape is not implemented yet!");
return IntPtr.Zero;
}
static extern IntPtr SceneBuilder_pushPhysicalShape(IntPtr ptr, IntPtr path, float evelation, int color,
int shadowColor, int clipBehavior);
[DllImport(NativeBindings.dllName)]
static extern void SceneBuilder_pop(IntPtr ptr);

39
com.unity.uiwidgets/Runtime/ui2/painting.cs


return next;
}
/*
static extern IntPtr PathMeasure_constructor(IntPtr path, bool forcedClosed);*/
static IntPtr PathMeasure_constructor(IntPtr path, bool forcedClosed) {
D.assert(false, () => "PathMeasure_constructor is not implemented yet!");
return IntPtr.Zero;
}
static extern IntPtr PathMeasure_constructor(IntPtr path, bool forcedClosed);
/*
static extern void PathMeasure_dispose(IntPtr ptr);*/
static void PathMeasure_dispose(IntPtr ptr) {
D.assert(false, () => "PathMeasure_dispose is not implemented yet!");
}
static extern void PathMeasure_dispose(IntPtr ptr);
/*
static extern float PathMeasure_length(int contourIndex);*/
static extern float PathMeasure_length(int contourIndex);
static float PathMeasure_length(int contourIndex) {
D.assert(false, () => "PathMeasure_length is not implemented yet!");
return 0;
}
/*
static extern bool PathMeasure_isClosed(int contourIndex);*/
static bool PathMeasure_isClosed(int contourIndex) {
D.assert(false, () => "PathMeasure_isClosed is not implemented yet!");
return true;
}
static extern bool PathMeasure_isClosed(int contourIndex);
/*
static extern bool PathMeasure_nativeNextContour();*/
static bool PathMeasure_nativeNextContour() {
D.assert(false, () => "PathMeasure_nativeNextContour is not implemented yet!");
return false;
}
static extern bool PathMeasure_nativeNextContour();
}
public class ColorFilter : IEquatable<ColorFilter> {

2
engine/Build.bee.cs


"src/lib/ui/painting/multi_frame_codec.h",
"src/lib/ui/painting/path.cc",
"src/lib/ui/painting/path.h",
"src/lib/ui/painting/path_measure.cc",
"src/lib/ui/painting/path_measure.h",
"src/lib/ui/painting/paint.cc",
"src/lib/ui/painting/paint.h",
"src/lib/ui/painting/picture.cc",

54
engine/src/lib/ui/compositing/scene_builder.cc


return layer.get();
}
UIWIDGETS_API(EngineLayer*)
SceneBuilder_pushClipRect(SceneBuilder* ptr, float left, float right, float top,
float bottom, int clipBehavior) {
const auto layer = ptr->pushClipRect(left, right, top, bottom, clipBehavior);
layer->AddRef();
return layer.get();
}
UIWIDGETS_API(EngineLayer*)
SceneBuilder_pushClipRRect(SceneBuilder* ptr, float* rrect, int clipBehavior) {
const auto layer = ptr->pushClipRRect(RRect(rrect), clipBehavior);
layer->AddRef();
return layer.get();
}
UIWIDGETS_API(EngineLayer*)
SceneBuilder_pushClipPath(SceneBuilder* ptr, CanvasPath* path,
int clipBehavior) {
const auto layer = ptr->pushClipPath(path, clipBehavior);
layer->AddRef();
return layer.get();
}
UIWIDGETS_API(EngineLayer*)
SceneBuilder_pushOpacity(SceneBuilder* ptr, int alpha, float dx, float dy) {
const auto layer = ptr->pushOpacity(alpha, dx, dy);
layer->AddRef();
return layer.get();
}
UIWIDGETS_API(EngineLayer*)
SceneBuilder_pushBackdropFilter(SceneBuilder* ptr, ImageFilter* filter) {
const auto layer = ptr->pushBackdropFilter(filter);
layer->AddRef();
return layer.get();
}
UIWIDGETS_API(EngineLayer*)
SceneBuilder_pushPhysicalShape(SceneBuilder* ptr, CanvasPath* path,
float elevation, int color, int shadowColor,
int clipBehavior) {
const auto layer =
ptr->pushPhysicalShape(path, elevation, color, shadowColor, clipBehavior);
layer->AddRef();
return layer.get();
}
UIWIDGETS_API(void)
SceneBuilder_addPerformanceOverlay(SceneBuilder* ptr, int enabledOptions,
float left, float right, float top,
float bottom) {
ptr->addPerformanceOverlay(enabledOptions, left, right, top, bottom);
}
UIWIDGETS_API(void)
SceneBuilder_addRetained(SceneBuilder* ptr, EngineLayer* retainedLayer) {
ptr->addRetained(static_cast<fml::RefPtr<EngineLayer>>(retainedLayer));

79
engine/src/lib/ui/painting/path_measure.cc


#include "path_measure.h"
#include "runtime/mono_state.h"
namespace uiwidgets {
typedef CanvasPathMeasure PathMeasure;
CanvasPathMeasure::CanvasPathMeasure() {}
CanvasPathMeasure::~CanvasPathMeasure() {}
fml::RefPtr<CanvasPathMeasure> CanvasPathMeasure::Create(const CanvasPath* path,
bool forceClosed) {
fml::RefPtr<CanvasPathMeasure> pathMeasure =
fml::MakeRefCounted<CanvasPathMeasure>();
if (path) {
const SkPath skPath = path->path();
SkScalar resScale = 1;
pathMeasure->path_measure_ =
std::make_unique<SkContourMeasureIter>(skPath, forceClosed, resScale);
} else {
pathMeasure->path_measure_ = std::make_unique<SkContourMeasureIter>();
}
return pathMeasure;
}
void CanvasPathMeasure::setPath(const CanvasPath* path, bool isClosed) {
const SkPath& skPath = path->path();
path_measure_->reset(skPath, isClosed);
}
float CanvasPathMeasure::getLength(int contour_index) {
if (static_cast<std::vector<sk_sp<SkContourMeasure>>::size_type>(
contour_index) < measures_.size()) {
return measures_[contour_index]->length();
}
return -1;
}
bool CanvasPathMeasure::isClosed(int contour_index) {
if (static_cast<std::vector<sk_sp<SkContourMeasure>>::size_type>(
contour_index) < measures_.size()) {
return measures_[contour_index]->isClosed();
}
return false;
}
bool CanvasPathMeasure::nextContour() {
auto measure = path_measure_->next();
if (measure) {
measures_.push_back(std::move(measure));
return true;
}
return false;
}
UIWIDGETS_API(PathMeasure*)
PathMeasure_constructor(CanvasPath* path, bool forceClosed) {
const auto pathMeasure = PathMeasure::Create(path, forceClosed);
pathMeasure->AddRef();
return pathMeasure.get();
}
UIWIDGETS_API(void) PathMeasure_dispose(PathMeasure* ptr) { ptr->Release(); }
UIWIDGETS_API(float) PathMeasure_length(PathMeasure* ptr, int contourIndex) {
return ptr->getLength(contourIndex);
}
UIWIDGETS_API(bool) PathMeasure_isClosed(PathMeasure* ptr, int contourIndex) {
return ptr->isClosed(contourIndex);
}
UIWIDGETS_API(bool) PathMeasure_nativeNextContour(PathMeasure* ptr) {
return ptr->nextContour();
}
} // namespace uiwidgets

32
engine/src/lib/ui/painting/path_measure.h


#pragma once
#include <flutter/fml/memory/ref_counted.h>
#include <vector>
#include "include/core/SkContourMeasure.h"
#include "path.h"
namespace uiwidgets {
class CanvasPathMeasure : public fml::RefCountedThreadSafe<CanvasPathMeasure> {
FML_FRIEND_MAKE_REF_COUNTED(CanvasPathMeasure);
public:
~CanvasPathMeasure();
static fml::RefPtr<CanvasPathMeasure> Create(const CanvasPath* path,
bool forcedClosed);
void setPath(const CanvasPath* path, bool isClosed);
float getLength(int contour_index);
bool isClosed(int contour_index);
bool nextContour();
private:
CanvasPathMeasure();
std::unique_ptr<SkContourMeasureIter> path_measure_;
std::vector<sk_sp<SkContourMeasure>> measures_;
};
} // namespace uiwidgets
正在加载...
取消
保存