xingweizhu
4 年前
当前提交
6a6487f3
共有 6 个文件被更改,包括 211 次插入 和 122 次删除
-
59com.unity.uiwidgets/Runtime/ui2/compositing.cs
-
39com.unity.uiwidgets/Runtime/ui2/painting.cs
-
2engine/Build.bee.cs
-
125engine/src/lib/ui/compositing/scene_builder.cc
-
76engine/src/lib/ui/painting/path_measure.cc
-
32engine/src/lib/ui/painting/path_measure.h
|
|||
#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
|
|
|||
#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 |
撰写
预览
正在加载...
取消
保存
Reference in new issue