mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-27 01:03:08 +00:00
Merge pull request !39727 from WangYing/revert-merge-39015-master
This commit is contained in:
commit
99cf68dad0
@ -39,6 +39,7 @@ ArkUINativeModuleValue RectBridge::SetRadiusWidth(ArkUIRuntimeCallInfo* runtimeC
|
||||
bool isSupportPercent = true;
|
||||
if (!ArkTSUtils::ParseJsDimensionVpNG(vm, jsValue, radiusWidth, isSupportPercent)) {
|
||||
GetArkUINodeModifiers()->getRectModifier()->resetRectRadiusWidth(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
GetArkUINodeModifiers()->getRectModifier()->setRectRadiusWidth(
|
||||
nativeNode, radiusWidth.Value(), static_cast<int32_t>(radiusWidth.Unit()));
|
||||
@ -66,6 +67,7 @@ ArkUINativeModuleValue RectBridge::SetRadiusHeight(ArkUIRuntimeCallInfo* runtime
|
||||
bool isSupportPercent = true;
|
||||
if (!ArkTSUtils::ParseJsDimensionVpNG(vm, jsValue, radiusHeight, isSupportPercent)) {
|
||||
GetArkUINodeModifiers()->getRectModifier()->resetRectRadiusHeight(nativeNode);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
GetArkUINodeModifiers()->getRectModifier()->setRectRadiusHeight(
|
||||
nativeNode, radiusHeight.Value(), static_cast<int32_t>(radiusHeight.Unit()));
|
||||
|
@ -21,10 +21,6 @@
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
namespace {
|
||||
constexpr int NUM_0 = 0;
|
||||
constexpr int NUM_1 = 1;
|
||||
constexpr int NUM_2 = 2;
|
||||
constexpr int NUM_3 = 3;
|
||||
constexpr int POSITION_DIMENSION = 2;
|
||||
constexpr char END_CHAR = '\0';
|
||||
|
||||
@ -75,10 +71,10 @@ ArkUINativeModuleValue RelativeContainerBridge::SetGuideLine(ArkUIRuntimeCallInf
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
|
||||
Local<JSValueRef> idsArg = runtimeCallInfo->GetCallArgRef(NUM_1);
|
||||
Local<JSValueRef> directionsArg = runtimeCallInfo->GetCallArgRef(NUM_2);
|
||||
Local<JSValueRef> positionsArg = runtimeCallInfo->GetCallArgRef(NUM_3);
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
Local<JSValueRef> idsArg = runtimeCallInfo->GetCallArgRef(1);
|
||||
Local<JSValueRef> directionsArg = runtimeCallInfo->GetCallArgRef(2);
|
||||
Local<JSValueRef> positionsArg = runtimeCallInfo->GetCallArgRef(3);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
if (!idsArg->IsArray(vm) || !directionsArg->IsArray(vm) || !positionsArg->IsArray(vm)) {
|
||||
GetArkUINodeModifiers()->getRelativeContainerModifier()->resetGuideline(nativeNode);
|
||||
@ -136,10 +132,10 @@ ArkUINativeModuleValue RelativeContainerBridge::SetBarrier(ArkUIRuntimeCallInfo*
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
|
||||
Local<JSValueRef> idsArg = runtimeCallInfo->GetCallArgRef(NUM_1);
|
||||
Local<JSValueRef> directionsArg = runtimeCallInfo->GetCallArgRef(NUM_2);
|
||||
Local<JSValueRef> referenceIdsArg = runtimeCallInfo->GetCallArgRef(NUM_3);
|
||||
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
|
||||
Local<JSValueRef> idsArg = runtimeCallInfo->GetCallArgRef(1);
|
||||
Local<JSValueRef> directionsArg = runtimeCallInfo->GetCallArgRef(2);
|
||||
Local<JSValueRef> referenceIdsArg = runtimeCallInfo->GetCallArgRef(3);
|
||||
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
|
||||
if (!idsArg->IsArray(vm) || !directionsArg->IsArray(vm) || !referenceIdsArg->IsArray(vm)) {
|
||||
GetArkUINodeModifiers()->getRelativeContainerModifier()->resetBarrier(nativeNode);
|
||||
|
@ -73,7 +73,6 @@ napi_value AttachOffscreenCanvas(napi_env env, void* value, void*)
|
||||
|
||||
napi_value offscreenCanvas = nullptr;
|
||||
napi_create_object(env, &offscreenCanvas);
|
||||
|
||||
napi_property_descriptor desc[] = {
|
||||
DECLARE_NAPI_GETTER_SETTER("width", JSOffscreenCanvas::JsGetWidth, JSOffscreenCanvas::JsSetWidth),
|
||||
DECLARE_NAPI_GETTER_SETTER("height", JSOffscreenCanvas::JsGetHeight, JSOffscreenCanvas::JsSetHeight),
|
||||
@ -81,7 +80,6 @@ napi_value AttachOffscreenCanvas(napi_env env, void* value, void*)
|
||||
DECLARE_NAPI_FUNCTION("getContext", JSOffscreenCanvas::JsGetContext),
|
||||
};
|
||||
napi_define_properties(env, offscreenCanvas, sizeof(desc) / sizeof(*desc), desc);
|
||||
|
||||
napi_coerce_to_native_binding_object(
|
||||
env, offscreenCanvas, DetachOffscreenCanvas, AttachOffscreenCanvas, value, nullptr);
|
||||
napi_wrap_with_size(
|
||||
@ -197,17 +195,20 @@ napi_value JSOffscreenCanvas::JsGetHeight(napi_env env, napi_callback_info info)
|
||||
|
||||
napi_value JSOffscreenCanvas::JsSetWidth(napi_env env, napi_callback_info info)
|
||||
{
|
||||
ContainerScope scope(Container::CurrentIdSafely());
|
||||
JSOffscreenCanvas* me = static_cast<JSOffscreenCanvas*>(GetNapiCallbackInfoAndThis(env, info));
|
||||
return (me != nullptr && !me->isDetached_) ? me->OnSetWidth(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JSOffscreenCanvas::JsSetHeight(napi_env env, napi_callback_info info)
|
||||
{
|
||||
ContainerScope scope(Container::CurrentIdSafely());
|
||||
JSOffscreenCanvas* me = static_cast<JSOffscreenCanvas*>(GetNapiCallbackInfoAndThis(env, info));
|
||||
return (me != nullptr && !me->isDetached_) ? me->OnSetHeight(env, info) : nullptr;
|
||||
}
|
||||
napi_value JSOffscreenCanvas::JsTransferToImageBitmap(napi_env env, napi_callback_info info)
|
||||
{
|
||||
ContainerScope scope(Container::CurrentIdSafely());
|
||||
JSOffscreenCanvas* me = static_cast<JSOffscreenCanvas*>(GetNapiCallbackInfoAndThis(env, info));
|
||||
if (me->isDetached_) {
|
||||
JSException::Throw("%s", "Failed to execute 'transferToImageBitmap' on 'OffscreenCanvas': Cannot transfer an "
|
||||
@ -221,6 +222,7 @@ napi_value JSOffscreenCanvas::JsTransferToImageBitmap(napi_env env, napi_callbac
|
||||
|
||||
napi_value JSOffscreenCanvas::JsGetContext(napi_env env, napi_callback_info info)
|
||||
{
|
||||
ContainerScope scope(Container::CurrentIdSafely());
|
||||
JSOffscreenCanvas* me = static_cast<JSOffscreenCanvas*>(GetNapiCallbackInfoAndThis(env, info));
|
||||
if (me->isDetached_) {
|
||||
JSException::Throw(
|
||||
@ -463,6 +465,7 @@ napi_value JSOffscreenCanvas::CreateContext2d(napi_env env, double width, double
|
||||
|
||||
JSObject jsObject(vm, NapiValueToLocalValue(thisVal)->ToEcmaObject(vm));
|
||||
offscreenCanvasContext_ = Referenced::Claim(jsObject.Unwrap<JSOffscreenRenderingContext>());
|
||||
offscreenCanvasContext_->SetInstanceId(Container::CurrentId());
|
||||
offscreenCanvasContext_->SetOffscreenPattern(offscreenCanvasPattern_);
|
||||
offscreenCanvasContext_->AddOffscreenCanvasPattern(offscreenCanvasPattern_);
|
||||
offscreenCanvasContext_->SetWidth(width_);
|
||||
|
@ -38,6 +38,8 @@ public:
|
||||
static napi_value JsGetHeight(napi_env env, napi_callback_info info);
|
||||
static napi_value JsSetHeight(napi_env env, napi_callback_info info);
|
||||
static napi_value JsSetWidth(napi_env env, napi_callback_info info);
|
||||
napi_value OnGetWidth(napi_env env);
|
||||
napi_value OnGetHeight(napi_env env);
|
||||
|
||||
void JsCreateRadialGradient(const JSCallbackInfo& info) {}
|
||||
void JsFillRect(const JSCallbackInfo& info) {}
|
||||
@ -190,8 +192,6 @@ private:
|
||||
napi_value onTransferToImageBitmap(napi_env env);
|
||||
napi_value onGetContext(napi_env env, napi_callback_info info);
|
||||
void SetAntiAlias(napi_value argv);
|
||||
napi_value OnGetWidth(napi_env env);
|
||||
napi_value OnGetHeight(napi_env env);
|
||||
napi_value OnSetWidth(napi_env env, napi_callback_info info);
|
||||
napi_value OnSetHeight(napi_env env, napi_callback_info info);
|
||||
|
||||
|
@ -25,19 +25,23 @@
|
||||
namespace OHOS::Ace {
|
||||
|
||||
std::unique_ptr<GridColModel> GridColModel::instance_;
|
||||
std::mutex GridColModel::mutex_;
|
||||
|
||||
GridColModel* GridColModel::GetInstance()
|
||||
{
|
||||
if (!instance_) {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (!instance_) {
|
||||
#ifdef NG_BUILD
|
||||
instance_.reset(new NG::GridColModelNG());
|
||||
#else
|
||||
if (Container::IsCurrentUseNewPipeline()) {
|
||||
instance_.reset(new NG::GridColModelNG());
|
||||
} else {
|
||||
instance_.reset(new Framework::GridColModelImpl());
|
||||
}
|
||||
#else
|
||||
if (Container::IsCurrentUseNewPipeline()) {
|
||||
instance_.reset(new NG::GridColModelNG());
|
||||
} else {
|
||||
instance_.reset(new Framework::GridColModelImpl());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return instance_.get();
|
||||
}
|
||||
|
@ -22,18 +22,22 @@
|
||||
|
||||
namespace OHOS::Ace {
|
||||
std::unique_ptr<GridContainerModel> GridContainerModel::instance_;
|
||||
std::mutex GridContainerModel::mutex_;
|
||||
GridContainerModel* GridContainerModel::GetInstance()
|
||||
{
|
||||
if (!instance_) {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (!instance_) {
|
||||
#ifdef NG_BUILD
|
||||
instance_.reset(new NG::GridContainerModelNG());
|
||||
#else
|
||||
if (Container::IsCurrentUseNewPipeline()) {
|
||||
instance_.reset(new NG::GridContainerModelNG());
|
||||
} else {
|
||||
instance_.reset(new Framework::GridContainerModelImpl());
|
||||
}
|
||||
#else
|
||||
if (Container::IsCurrentUseNewPipeline()) {
|
||||
instance_.reset(new NG::GridContainerModelNG());
|
||||
} else {
|
||||
instance_.reset(new Framework::GridContainerModelImpl());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return instance_.get();
|
||||
}
|
||||
|
@ -28,19 +28,23 @@
|
||||
namespace OHOS::Ace {
|
||||
|
||||
std::unique_ptr<GridRowModel> GridRowModel::instance_;
|
||||
std::mutex GridRowModel::mutex_;
|
||||
|
||||
GridRowModel* GridRowModel::GetInstance()
|
||||
{
|
||||
if (!instance_) {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (!instance_) {
|
||||
#ifdef NG_BUILD
|
||||
instance_.reset(new NG::GridRowModelNG());
|
||||
#else
|
||||
if (Container::IsCurrentUseNewPipeline()) {
|
||||
instance_.reset(new NG::GridRowModelNG());
|
||||
} else {
|
||||
instance_.reset(new Framework::GridRowModelImpl());
|
||||
}
|
||||
#else
|
||||
if (Container::IsCurrentUseNewPipeline()) {
|
||||
instance_.reset(new NG::GridRowModelNG());
|
||||
} else {
|
||||
instance_.reset(new Framework::GridRowModelImpl());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return instance_.get();
|
||||
}
|
||||
|
@ -29,20 +29,26 @@
|
||||
#include "frameworks/core/components/plugin/plugin_component.h"
|
||||
|
||||
namespace OHOS::Ace {
|
||||
std::unique_ptr<PluginModel> PluginModel::instance_;
|
||||
std::mutex PluginModel::mutex_;
|
||||
|
||||
PluginModel* PluginModel::GetInstance()
|
||||
{
|
||||
if (!instance_) {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (!instance_) {
|
||||
#ifdef NG_BUILD
|
||||
static NG::PluginModelNG model;
|
||||
return &model;
|
||||
instance_.reset(new NG::PluginModelNG());
|
||||
#else
|
||||
if (Container::IsCurrentUseNewPipeline()) {
|
||||
static NG::PluginModelNG model;
|
||||
return &model;
|
||||
} else {
|
||||
static Framework::PluginModelImpl model;
|
||||
return &model;
|
||||
}
|
||||
if (Container::IsCurrentUseNewPipeline()) {
|
||||
instance_.reset(new NG::PluginModelNG());
|
||||
} else {
|
||||
instance_.reset(new Framework::PluginModelImpl());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return instance_.get();
|
||||
}
|
||||
} // namespace OHOS::Ace
|
||||
namespace OHOS::Ace::Framework {
|
||||
@ -139,7 +145,7 @@ void JSPlugin::JsOnComplete(const JSCallbackInfo& info)
|
||||
auto frameNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
|
||||
auto jsFunc = AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(), JSRef<JSFunc>::Cast(info[0]));
|
||||
auto OnComplete = [execCtx = info.GetExecutionContext(), func = std::move(jsFunc), node = frameNode](
|
||||
const std::string& param) {
|
||||
const std::string& param) {
|
||||
JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
|
||||
ACE_SCORING_EVENT("Plugin.OnComplete");
|
||||
PipelineContext::SetCallBackNode(node);
|
||||
@ -157,7 +163,7 @@ void JSPlugin::JsOnError(const JSCallbackInfo& info)
|
||||
auto frameNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
|
||||
auto jsFunc = AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(), JSRef<JSFunc>::Cast(info[0]));
|
||||
auto onError = [execCtx = info.GetExecutionContext(), func = std::move(jsFunc), node = frameNode](
|
||||
const std::string& param) {
|
||||
const std::string& param) {
|
||||
JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
|
||||
ACE_SCORING_EVENT("Plugin.OnComplete");
|
||||
std::vector<std::string> keys = { "errcode", "msg" };
|
||||
|
@ -29,19 +29,23 @@ constexpr double DEFAULT_OPACITY = 1.0;
|
||||
constexpr double STROKE_MITERLIMIT_DEFAULT = 4.0f;
|
||||
} // namespace
|
||||
std::unique_ptr<ShapeModel> ShapeModel::instance_;
|
||||
std::mutex ShapeModel::mutex_;
|
||||
|
||||
ShapeModel* ShapeModel::GetInstance()
|
||||
{
|
||||
if (!instance_) {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (!instance_) {
|
||||
#ifdef NG_BUILD
|
||||
instance_.reset(new NG::ShapeModelNG());
|
||||
#else
|
||||
if (Container::IsCurrentUseNewPipeline()) {
|
||||
instance_.reset(new NG::ShapeModelNG());
|
||||
} else {
|
||||
instance_.reset(new Framework::ShapeModelImpl());
|
||||
}
|
||||
#else
|
||||
if (Container::IsCurrentUseNewPipeline()) {
|
||||
instance_.reset(new NG::ShapeModelNG());
|
||||
} else {
|
||||
instance_.reset(new Framework::ShapeModelImpl());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return instance_.get();
|
||||
}
|
||||
|
@ -87,7 +87,15 @@ void JSVideo::Create(const JSCallbackInfo& info)
|
||||
|
||||
auto aiOptions = videoObj->GetProperty("imageAIOptions");
|
||||
if (aiOptions->IsObject()) {
|
||||
ParseImageAIOptions(aiOptions);
|
||||
auto engine = EngineHelper::GetCurrentEngine();
|
||||
CHECK_NULL_VOID(engine);
|
||||
NativeEngine* nativeEngine = engine->GetNativeEngine();
|
||||
CHECK_NULL_VOID(nativeEngine);
|
||||
panda::Local<JsiValue> value = aiOptions.Get().GetLocalHandle();
|
||||
JSValueWrapper valueWrapper = value;
|
||||
ScopeRAII scope(reinterpret_cast<napi_env>(nativeEngine));
|
||||
napi_value optionsValue = nativeEngine->ValueToNapiValue(valueWrapper);
|
||||
VideoModel::GetInstance()->SetImageAIOptions(optionsValue);
|
||||
}
|
||||
|
||||
std::string previewUri;
|
||||
@ -112,19 +120,6 @@ void JSVideo::Create(const JSCallbackInfo& info)
|
||||
}
|
||||
}
|
||||
|
||||
void JSVideo::ParseImageAIOptions(const JSRef<JSVal>& jsValue)
|
||||
{
|
||||
auto engine = EngineHelper::GetCurrentEngine();
|
||||
CHECK_NULL_VOID(engine);
|
||||
NativeEngine* nativeEngine = engine->GetNativeEngine();
|
||||
CHECK_NULL_VOID(nativeEngine);
|
||||
panda::Local<JsiValue> value = jsValue.Get().GetLocalHandle();
|
||||
JSValueWrapper valueWrapper = value;
|
||||
ScopeRAII scope(reinterpret_cast<napi_env>(nativeEngine));
|
||||
napi_value optionsValue = nativeEngine->ValueToNapiValue(valueWrapper);
|
||||
VideoModel::GetInstance()->SetImageAIOptions(optionsValue);
|
||||
}
|
||||
|
||||
void JSVideo::JsMuted(const JSCallbackInfo& info)
|
||||
{
|
||||
bool muted = false;
|
||||
@ -242,7 +237,7 @@ void JSVideo::JsOnStop(const JSCallbackInfo& info)
|
||||
return;
|
||||
}
|
||||
auto jsFunc = AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(), JSRef<JSFunc>::Cast(info[0]));
|
||||
auto targetNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
|
||||
WeakPtr<NG::FrameNode> targetNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
|
||||
auto onStop = [execCtx = info.GetExecutionContext(), func = std::move(jsFunc), node = targetNode](
|
||||
const std::string& param) {
|
||||
JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
|
||||
|
@ -48,7 +48,6 @@ public:
|
||||
|
||||
private:
|
||||
static EventMarker GetEventMarker(const JSCallbackInfo& info, const std::vector<std::string>& keys);
|
||||
static void ParseImageAIOptions(const JSRef<JSVal>& jsValue);
|
||||
};
|
||||
|
||||
} // namespace OHOS::Ace::Framework
|
||||
|
@ -44,6 +44,11 @@ XComponentType ConvertToXComponentType(const std::string& type)
|
||||
if (type == "node") {
|
||||
return XComponentType::NODE;
|
||||
}
|
||||
#ifdef PLATFORM_VIEW_SUPPORTED
|
||||
if (type == "platform_view") {
|
||||
return XComponentType::PLATFORM_VIEW;
|
||||
}
|
||||
#endif
|
||||
return XComponentType::SURFACE;
|
||||
}
|
||||
} // namespace
|
||||
@ -75,7 +80,7 @@ XComponentModel* XComponentModel::GetInstance()
|
||||
namespace OHOS::Ace::Framework {
|
||||
void SetControllerCallback(const JSRef<JSObject>& object, const JsiExecutionContext& execCtx)
|
||||
{
|
||||
auto targetNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
|
||||
WeakPtr<NG::FrameNode> targetNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
|
||||
auto jsCreatedFunc = object->GetProperty("onSurfaceCreated");
|
||||
if (jsCreatedFunc->IsFunction()) {
|
||||
auto jsFunc = AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(object), JSRef<JSFunc>::Cast(jsCreatedFunc));
|
||||
@ -227,7 +232,18 @@ void JSXComponent::Create(const JSCallbackInfo& info)
|
||||
auto soPath = info[1]->ToString();
|
||||
XComponentModel::GetInstance()->SetSoPath(soPath);
|
||||
}
|
||||
ParseImageAIOptions(aiOptions);
|
||||
|
||||
if (aiOptions->IsObject()) {
|
||||
auto engine = EngineHelper::GetCurrentEngine();
|
||||
CHECK_NULL_VOID(engine);
|
||||
NativeEngine* nativeEngine = engine->GetNativeEngine();
|
||||
CHECK_NULL_VOID(nativeEngine);
|
||||
panda::Local<JsiValue> value = aiOptions.Get().GetLocalHandle();
|
||||
JSValueWrapper valueWrapper = value;
|
||||
ScopeRAII scope(reinterpret_cast<napi_env>(nativeEngine));
|
||||
napi_value optionsValue = nativeEngine->ValueToNapiValue(valueWrapper);
|
||||
XComponentModel::GetInstance()->SetImageAIOptions(optionsValue);
|
||||
}
|
||||
}
|
||||
|
||||
void* JSXComponent::Create(const XComponentParams& params)
|
||||
@ -267,22 +283,6 @@ void* JSXComponent::Create(const XComponentParams& params)
|
||||
return jsXComponent;
|
||||
}
|
||||
|
||||
void JSXComponent::ParseImageAIOptions(const JSRef<JSVal>& jsValue)
|
||||
{
|
||||
if (!jsValue->IsObject()) {
|
||||
return;
|
||||
}
|
||||
auto engine = EngineHelper::GetCurrentEngine();
|
||||
CHECK_NULL_VOID(engine);
|
||||
NativeEngine* nativeEngine = engine->GetNativeEngine();
|
||||
CHECK_NULL_VOID(nativeEngine);
|
||||
panda::Local<JsiValue> value = jsValue.Get().GetLocalHandle();
|
||||
JSValueWrapper valueWrapper = value;
|
||||
ScopeRAII scope(reinterpret_cast<napi_env>(nativeEngine));
|
||||
napi_value optionsValue = nativeEngine->ValueToNapiValue(valueWrapper);
|
||||
XComponentModel::GetInstance()->SetImageAIOptions(optionsValue);
|
||||
}
|
||||
|
||||
bool JSXComponent::ChangeRenderType(int32_t renderType)
|
||||
{
|
||||
auto xcFrameNode = AceType::DynamicCast<NG::FrameNode>(frameNode_);
|
||||
|
@ -197,7 +197,6 @@ public:
|
||||
bool ChangeRenderType(int32_t renderType);
|
||||
|
||||
private:
|
||||
static void ParseImageAIOptions(const JSRef<JSVal>& jsValue);
|
||||
RefPtr<AceType> frameNode_;
|
||||
};
|
||||
} // namespace OHOS::Ace::Framework
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "frameworks/core/components_ng/pattern/folder_stack/folder_stack_layout_algorithm.h"
|
||||
#include "core/components_ng/pattern/folder_stack/folder_stack_layout_algorithm.h"
|
||||
|
||||
#include "base/memory/ace_type.h"
|
||||
#include "base/log/event_report.h"
|
||||
@ -121,7 +121,6 @@ void FolderStackLayoutAlgorithm::LayoutControlPartsStack(LayoutWrapper* layoutWr
|
||||
auto geometryNode = controlPartsStackWrapper->GetGeometryNode();
|
||||
auto controlPartsStackRect = GetControlPartsStackRect();
|
||||
geometryNode->SetMarginFrameOffset(controlPartsStackRect);
|
||||
|
||||
controlPartsStackWrapper->Layout();
|
||||
}
|
||||
|
||||
@ -130,6 +129,8 @@ void FolderStackLayoutAlgorithm::Measure(LayoutWrapper* layoutWrapper)
|
||||
CHECK_NULL_VOID(layoutWrapper);
|
||||
auto hostNode = AceType::DynamicCast<FolderStackGroupNode>(layoutWrapper->GetHostNode());
|
||||
CHECK_NULL_VOID(hostNode);
|
||||
auto pattern = layoutWrapper->GetHostNode()->GetPattern<FolderStackPattern>();
|
||||
CHECK_NULL_VOID(pattern);
|
||||
const auto& layoutProperty = DynamicCast<FolderStackLayoutProperty>(layoutWrapper->GetLayoutProperty());
|
||||
CHECK_NULL_VOID(layoutProperty);
|
||||
const auto& layoutConstraint = layoutProperty->GetLayoutConstraint();
|
||||
@ -143,8 +144,20 @@ void FolderStackLayoutAlgorithm::Measure(LayoutWrapper* layoutWrapper)
|
||||
OnHoverStatusChange(layoutWrapper);
|
||||
if (!isIntoFolderStack_) {
|
||||
MeasureByStack(hostNode, layoutWrapper);
|
||||
pattern->SetNeedCallBack(false);
|
||||
return;
|
||||
}
|
||||
if (!pattern->GetNeedCallBack()) {
|
||||
pattern->SetNeedCallBack(true);
|
||||
auto displayInfo = pattern->GetDisplayInfo();
|
||||
if (displayInfo) {
|
||||
FolderEventInfo event(displayInfo->GetFoldStatus());
|
||||
auto eventHub = layoutWrapper->GetHostNode()->GetEventHub<FolderStackEventHub>();
|
||||
if (eventHub) {
|
||||
eventHub->OnFolderStateChange(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
RangeCalculation(hostNode, layoutProperty, size);
|
||||
MeasureHoverStack(layoutWrapper, hostNode, layoutProperty, size);
|
||||
MeasureControlPartsStack(layoutWrapper, hostNode, layoutProperty, size);
|
||||
@ -175,7 +188,6 @@ void FolderStackLayoutAlgorithm::MeasureControlPartsStack(LayoutWrapper* layoutW
|
||||
CHECK_NULL_VOID(controlPartsWrapper);
|
||||
auto constraint = foldStackLayoutProperty->CreateChildConstraint();
|
||||
constraint.selfIdealSize = OptionalSizeF(size.Width(), preControlPartsStackHeight_);
|
||||
|
||||
const auto& padding = layoutWrapper->GetLayoutProperty()->CreatePaddingAndBorder();
|
||||
PaddingProperty controlPartsPadding;
|
||||
controlPartsPadding.left = CalcLength(padding.left.value_or(0));
|
||||
@ -207,7 +219,6 @@ void FolderStackLayoutAlgorithm::RangeCalculation(const RefPtr<FolderStackGroupN
|
||||
creaseY = static_cast<int32_t>(foldCrease.Bottom() - foldCrease.Height());
|
||||
creaseHeight = static_cast<int32_t>(foldCrease.Height());
|
||||
}
|
||||
|
||||
preHoverStackHeight_ = static_cast<float>(creaseY - length);
|
||||
preControlPartsStackHeight_ = static_cast<float>(size.Height() - creaseHeight - preHoverStackHeight_);
|
||||
controlPartsStackRect_ = OffsetF(0.0f, creaseY - length + creaseHeight);
|
||||
@ -280,6 +291,7 @@ bool FolderStackLayoutAlgorithm::IsIntoFolderStack(
|
||||
{
|
||||
auto pattern = layoutWrapper->GetHostNode()->GetPattern<FolderStackPattern>();
|
||||
CHECK_NULL_RETURN(pattern, false);
|
||||
CHECK_NULL_RETURN(!pattern->HasFoldStatusDelayTask(), false);
|
||||
auto displayInfo = pattern->GetDisplayInfo();
|
||||
if (!displayInfo) {
|
||||
auto container = Container::Current();
|
||||
@ -349,4 +361,5 @@ void FolderStackLayoutAlgorithm::MeasureByStack(
|
||||
auto geometryNode = hoverStackWrapper->GetGeometryNode();
|
||||
geometryNode->SetFrameSize(controlPartsWrapper->GetGeometryNode()->GetFrameSize());
|
||||
}
|
||||
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
@ -169,9 +169,11 @@ void FolderStackPattern::RefreshStack(FoldStatus foldStatus)
|
||||
pattern->OnFolderStateChangeSend(currentFoldStatus);
|
||||
host->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
|
||||
}
|
||||
pattern->hasFoldStatusDelayTask_ = false;
|
||||
});
|
||||
lastFoldStatus_ = currentFoldStatus_;
|
||||
TAG_LOGD(AceLogTag::ACE_FOLDER_STACK, "the last folding state was:%{public}d", lastFoldStatus_);
|
||||
hasFoldStatusDelayTask_ = true;
|
||||
taskExecutor->PostDelayedTask(
|
||||
foldStatusDelayTask_, TaskExecutor::TaskType::UI, DELAY_TIME, "ArkUIFolderStackStatusChange");
|
||||
}
|
||||
@ -181,6 +183,7 @@ void FolderStackPattern::OnFolderStateChangeSend(FoldStatus foldStatus)
|
||||
FolderEventInfo event(foldStatus);
|
||||
auto eventHub = GetEventHub<FolderStackEventHub>();
|
||||
if (eventHub) {
|
||||
needCallBack_ = true;
|
||||
eventHub->OnFolderStateChange(event);
|
||||
}
|
||||
}
|
||||
|
@ -87,6 +87,16 @@ public:
|
||||
|
||||
void DumpInfo() override;
|
||||
|
||||
bool GetNeedCallBack()
|
||||
{
|
||||
return needCallBack_;
|
||||
}
|
||||
|
||||
void SetNeedCallBack(bool needCallBack)
|
||||
{
|
||||
needCallBack_ = needCallBack;
|
||||
}
|
||||
|
||||
bool IsInHoverMode() const
|
||||
{
|
||||
return hasInHoverMode_;
|
||||
@ -103,6 +113,11 @@ public:
|
||||
return lastTime_;
|
||||
}
|
||||
|
||||
bool HasFoldStatusDelayTask() const
|
||||
{
|
||||
return hasFoldStatusDelayTask_;
|
||||
}
|
||||
|
||||
private:
|
||||
void OnDetachFromFrameNode(FrameNode* node) override;
|
||||
void RegisterFoldStatusListener();
|
||||
@ -123,10 +138,12 @@ private:
|
||||
bool isAppearCallback_ = false;
|
||||
RefPtr<DisplayInfo> displayInfo_;
|
||||
bool hasInHoverMode_ = false;
|
||||
bool needCallBack_ = false;
|
||||
FoldStatus currentFoldStatus_ = FoldStatus::UNKNOWN;
|
||||
FoldStatus lastFoldStatus_ = FoldStatus::UNKNOWN;
|
||||
CancelableCallback<void()> foldStatusDelayTask_;
|
||||
std::time_t lastTime_ = std::time(0);
|
||||
bool hasFoldStatusDelayTask_ = false;
|
||||
};
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_GRID_COL_MODEL_H
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
#include "frameworks/core/components_v2/grid_layout/grid_container_util_class.h"
|
||||
|
||||
@ -35,6 +36,7 @@ public:
|
||||
|
||||
private:
|
||||
static std::unique_ptr<GridColModel> instance_;
|
||||
static std::mutex mutex_;
|
||||
};
|
||||
} // namespace OHOS::Ace
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@ -23,7 +23,6 @@
|
||||
#include "core/components_v2/inspector/inspector_constants.h"
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
|
||||
void GridColModelNG::Create()
|
||||
{
|
||||
RefPtr<V2::GridContainerSize> span = AceType::MakeRefPtr<V2::GridContainerSize>(1);
|
||||
@ -32,14 +31,14 @@ void GridColModelNG::Create()
|
||||
Create(span, offset, order);
|
||||
}
|
||||
|
||||
void GridColModelNG::Create(const RefPtr<V2::GridContainerSize>& span, const RefPtr<V2::GridContainerSize>& offset,
|
||||
const RefPtr<V2::GridContainerSize>& order)
|
||||
void GridColModelNG::Create(const RefPtr<V2::GridContainerSize> &span, const RefPtr<V2::GridContainerSize> &offset,
|
||||
const RefPtr<V2::GridContainerSize> &order)
|
||||
{
|
||||
auto* stack = ViewStackProcessor::GetInstance();
|
||||
auto *stack = ViewStackProcessor::GetInstance();
|
||||
auto nodeId = stack->ClaimNodeId();
|
||||
ACE_LAYOUT_SCOPED_TRACE("Create[%s][self:%d]", V2::GRID_COL_ETS_TAG, nodeId);
|
||||
auto frameNode = FrameNode::GetOrCreateFrameNode(
|
||||
V2::GRID_COL_ETS_TAG, nodeId, []() { return AceType::MakeRefPtr<GridColLayoutPattern>(); });
|
||||
auto frameNode = FrameNode::GetOrCreateFrameNode(V2::GRID_COL_ETS_TAG, nodeId,
|
||||
[]() { return AceType::MakeRefPtr<GridColLayoutPattern>(); });
|
||||
stack->Push(frameNode);
|
||||
|
||||
ACE_UPDATE_LAYOUT_PROPERTY(GridColLayoutProperty, Span, *span);
|
||||
@ -54,17 +53,17 @@ RefPtr<FrameNode> GridColModelNG::CreateFrameNode(int32_t nodeId)
|
||||
return frameNode;
|
||||
}
|
||||
|
||||
void GridColModelNG::SetSpan(const RefPtr<V2::GridContainerSize>& span)
|
||||
void GridColModelNG::SetSpan(const RefPtr<V2::GridContainerSize> &span)
|
||||
{
|
||||
ACE_UPDATE_LAYOUT_PROPERTY(GridColLayoutProperty, Span, *span);
|
||||
}
|
||||
|
||||
void GridColModelNG::SetOffset(const RefPtr<V2::GridContainerSize>& offset)
|
||||
void GridColModelNG::SetOffset(const RefPtr<V2::GridContainerSize> &offset)
|
||||
{
|
||||
ACE_UPDATE_LAYOUT_PROPERTY(GridColLayoutProperty, Offset, *offset);
|
||||
}
|
||||
|
||||
void GridColModelNG::SetOrder(const RefPtr<V2::GridContainerSize>& order)
|
||||
void GridColModelNG::SetOrder(const RefPtr<V2::GridContainerSize> &order)
|
||||
{
|
||||
ACE_UPDATE_LAYOUT_PROPERTY(GridColLayoutProperty, Order, *order);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_GRID_CONTAINER_MODEL_H
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
#include "base/utils/macros.h"
|
||||
#include "frameworks/core/components/common/layout/grid_container_info.h"
|
||||
@ -32,6 +33,7 @@ public:
|
||||
|
||||
private:
|
||||
static std::unique_ptr<GridContainerModel> instance_;
|
||||
static std::mutex mutex_;
|
||||
};
|
||||
} // namespace OHOS::Ace
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
#include "core/components/common/layout/constants.h"
|
||||
#include "frameworks/core/components_v2/grid_layout/grid_container_util_class.h"
|
||||
@ -37,6 +38,7 @@ public:
|
||||
|
||||
private:
|
||||
static std::unique_ptr<GridRowModel> instance_;
|
||||
static std::mutex mutex_;
|
||||
};
|
||||
} // namespace OHOS::Ace
|
||||
|
||||
|
@ -64,12 +64,16 @@ void LinearSplitLayoutAlgorithm::Measure(LayoutWrapper* layoutWrapper)
|
||||
|
||||
// measure self size.
|
||||
auto [childTotalSize, childMaxSize] = MeasureChildren(layoutWrapper);
|
||||
auto padding = layoutWrapper->GetLayoutProperty()->CreatePaddingAndBorder();
|
||||
if (splitType_ == SplitType::ROW_SPLIT) {
|
||||
if (!layoutConstraint->selfIdealSize.Width()) {
|
||||
float width = std::max(minSize.Width(), childTotalSize.Width());
|
||||
if (maxSize.Width() > 0) {
|
||||
width = std::min(maxSize.Width(), width);
|
||||
}
|
||||
if (!childrenDragPos_.empty()) {
|
||||
width = childrenDragPos_.back() - childrenDragPos_.front() + padding.Width();
|
||||
}
|
||||
realSize.SetWidth(width);
|
||||
}
|
||||
if (!layoutConstraint->selfIdealSize.Height()) {
|
||||
@ -79,6 +83,9 @@ void LinearSplitLayoutAlgorithm::Measure(LayoutWrapper* layoutWrapper)
|
||||
} else if (splitType_ == SplitType::COLUMN_SPLIT) {
|
||||
if (!layoutConstraint->selfIdealSize.Height()) {
|
||||
float height = std::min(maxSize.Height(), childTotalSize.Height());
|
||||
if (!childrenDragPos_.empty()) {
|
||||
height = childrenDragPos_.back() - childrenDragPos_.front() + padding.Height();
|
||||
}
|
||||
realSize.SetHeight(height);
|
||||
}
|
||||
if (!layoutConstraint->selfIdealSize.Width()) {
|
||||
|
@ -29,6 +29,7 @@ namespace OHOS::Ace::NG {
|
||||
namespace {
|
||||
|
||||
constexpr std::size_t DEFAULT_DRAG_INDEX = -1;
|
||||
constexpr std::size_t SPLIT_INDEX_INC_ONE = 1;
|
||||
constexpr std::size_t SPLIT_INDEX_INC_TWO = 2;
|
||||
const std::string SPLIT_DRAG_SCENE = "split_drag_scene";
|
||||
} // namespace
|
||||
@ -98,6 +99,7 @@ void LinearSplitPattern::HandlePanStart(const GestureEvent& info)
|
||||
if (dragedSplitIndex_ == DEFAULT_DRAG_INDEX) {
|
||||
return;
|
||||
}
|
||||
CHECK_NULL_VOID(CheckChildrenConstrains());
|
||||
|
||||
isDragedMoving_ = true;
|
||||
|
||||
@ -261,6 +263,8 @@ void LinearSplitPattern::HandlePanUpdate(const GestureEvent& info)
|
||||
return;
|
||||
}
|
||||
|
||||
CHECK_NULL_VOID(CheckChildrenConstrains());
|
||||
|
||||
if (splitType_ == SplitType::ROW_SPLIT) {
|
||||
float locationDiff = childrenDragPos_[dragedSplitIndex_ + 1] - gestureOffsetX;
|
||||
float offsetDiff = xOffset - preOffset_;
|
||||
@ -530,6 +534,25 @@ void LinearSplitPattern::UpdateDragFRCSceneInfo(const GestureEvent& info, SceneS
|
||||
}
|
||||
}
|
||||
|
||||
bool LinearSplitPattern::CheckChildrenConstrains()
|
||||
{
|
||||
// If the minimum size of the child is greater than the split line interval, return false.
|
||||
auto preInterval = childrenDragPos_[dragedSplitIndex_ + SPLIT_INDEX_INC_ONE] - childrenDragPos_[dragedSplitIndex_] -
|
||||
static_cast<float>(DEFAULT_SPLIT_HEIGHT);
|
||||
float curInterval = 0.0f;
|
||||
if (dragedSplitIndex_ + SPLIT_INDEX_INC_TWO == childrenDragPos_.size() - 1) {
|
||||
curInterval = childrenDragPos_[dragedSplitIndex_ + SPLIT_INDEX_INC_TWO] -
|
||||
childrenDragPos_[dragedSplitIndex_ + SPLIT_INDEX_INC_ONE];
|
||||
} else {
|
||||
curInterval = childrenDragPos_[dragedSplitIndex_ + SPLIT_INDEX_INC_TWO] -
|
||||
childrenDragPos_[dragedSplitIndex_ + SPLIT_INDEX_INC_ONE] -
|
||||
static_cast<float>(DEFAULT_SPLIT_HEIGHT);
|
||||
}
|
||||
|
||||
return !(GreatNotEqual(childrenConstrains_[dragedSplitIndex_], preInterval) ||
|
||||
GreatNotEqual(childrenConstrains_[dragedSplitIndex_ + SPLIT_INDEX_INC_ONE], curInterval));
|
||||
}
|
||||
|
||||
void LinearSplitPattern::OnModifyDone()
|
||||
{
|
||||
Pattern::OnModifyDone();
|
||||
|
@ -87,6 +87,7 @@ private:
|
||||
float GetMinPosFromIndex(std::size_t index);
|
||||
float GetMaxPosFromIndex(std::size_t index);
|
||||
void UpdateDragFRCSceneInfo(const GestureEvent& info, SceneStatus sceneStatus);
|
||||
bool CheckChildrenConstrains();
|
||||
|
||||
std::vector<OffsetF> childrenOffset_;
|
||||
float splitLength_ = 0.0f;
|
||||
|
@ -25,6 +25,7 @@ void RelativeContainerModelNG::Create()
|
||||
{
|
||||
auto* stack = ViewStackProcessor::GetInstance();
|
||||
int32_t nodeId = stack->ClaimNodeId();
|
||||
ACE_LAYOUT_SCOPED_TRACE("Create[%s][self:%d]", V2::RELATIVE_CONTAINER_ETS_TAG, nodeId);
|
||||
auto frameNode = FrameNode::GetOrCreateFrameNode(V2::RELATIVE_CONTAINER_ETS_TAG, nodeId,
|
||||
[]() { return AceType::MakeRefPtr<OHOS::Ace::NG::RelativeContainerPattern>(); });
|
||||
ViewStackProcessor::GetInstance()->Push(frameNode);
|
||||
|
@ -32,7 +32,6 @@ void StackModelNG::Create()
|
||||
auto frameNode = FrameNode::GetOrCreateFrameNode(
|
||||
V2::STACK_ETS_TAG, nodeId, []() { return AceType::MakeRefPtr<StackPattern>(); });
|
||||
stack->Push(frameNode);
|
||||
frameNode->SetExclusiveEventForChild(true);
|
||||
}
|
||||
|
||||
void StackModelNG::Create(Alignment alignment)
|
||||
|
@ -26,7 +26,10 @@
|
||||
#include "base/utils/string_utils.h"
|
||||
#include "base/utils/system_properties.h"
|
||||
#include "base/utils/utils.h"
|
||||
#include "core/common/ace_engine.h"
|
||||
#include "core/common/ace_view.h"
|
||||
#include "core/common/ai/image_analyzer_manager.h"
|
||||
#include "core/common/container.h"
|
||||
#include "core/common/udmf/udmf_client.h"
|
||||
#include "core/components/common/layout/constants.h"
|
||||
#include "core/components/common/properties/color.h"
|
||||
@ -421,8 +424,43 @@ void VideoPattern::RegisterMediaPlayerEvent()
|
||||
"ArkUIVideoSeekDone");
|
||||
};
|
||||
mediaPlayer_->RegisterMediaPlayerSeekDoneEvent(std::move(seekDoneEvent));
|
||||
|
||||
#ifdef RENDER_EXTRACT_SUPPORTED
|
||||
auto&& textureRefreshEvent = [videoPattern, uiTaskExecutor](int32_t instanceId, int64_t textureId) {
|
||||
uiTaskExecutor.PostSyncTask([&videoPattern, instanceId, textureId] {
|
||||
auto video = videoPattern.Upgrade();
|
||||
CHECK_NULL_VOID(video);
|
||||
void* nativeWindow = video->GetNativeWindow(instanceId, textureId);
|
||||
if (!nativeWindow) {
|
||||
LOGE("the native window is nullptr.");
|
||||
return;
|
||||
}
|
||||
video->OnTextureRefresh(nativeWindow);
|
||||
}, "ArkUIVideoTextureRefresh");
|
||||
};
|
||||
mediaPlayer_->RegisterTextureEvent(textureRefreshEvent);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef RENDER_EXTRACT_SUPPORTED
|
||||
void* VideoPattern::GetNativeWindow(int32_t instanceId, int64_t textureId)
|
||||
{
|
||||
auto container = AceEngine::Get().GetContainer(instanceId);
|
||||
CHECK_NULL_RETURN(container, nullptr);
|
||||
auto nativeView = container->GetAceView();
|
||||
CHECK_NULL_RETURN(nativeView, nullptr);
|
||||
return const_cast<void*>(nativeView->GetNativeWindowById(textureId));
|
||||
}
|
||||
|
||||
void VideoPattern::OnTextureRefresh(void* surface)
|
||||
{
|
||||
CHECK_NULL_VOID(surface);
|
||||
auto renderContextForMediaPlayer = renderContextForMediaPlayerWeakPtr_.Upgrade();
|
||||
CHECK_NULL_VOID(renderContextForMediaPlayer);
|
||||
renderContextForMediaPlayer->MarkNewFrameAvailable(surface);
|
||||
}
|
||||
#endif
|
||||
|
||||
void VideoPattern::PrintPlayerStatus(PlaybackStatus status)
|
||||
{
|
||||
switch (status) {
|
||||
@ -802,9 +840,23 @@ void VideoPattern::OnAttachToFrameNode()
|
||||
pipeline->AddWindowStateChangedCallback(host->GetId());
|
||||
auto renderContext = host->GetRenderContext();
|
||||
CHECK_NULL_VOID(renderContext);
|
||||
|
||||
#ifdef RENDER_EXTRACT_SUPPORTED
|
||||
CHECK_NULL_VOID(renderSurface_);
|
||||
auto contextType = renderSurface_->IsTexture() ?
|
||||
RenderContext::ContextType::HARDWARE_TEXTURE : RenderContext::ContextType::HARDWARE_SURFACE;
|
||||
static RenderContext::ContextParam param = { contextType, "MediaPlayerSurface",
|
||||
RenderContext::PatternType::VIDEO };
|
||||
#else
|
||||
static RenderContext::ContextParam param = { RenderContext::ContextType::HARDWARE_SURFACE, "MediaPlayerSurface",
|
||||
RenderContext::PatternType::VIDEO };
|
||||
#endif
|
||||
renderContextForMediaPlayer_->InitContext(false, param);
|
||||
|
||||
if (SystemProperties::GetExtSurfaceEnabled()) {
|
||||
RegisterRenderContextCallBack();
|
||||
}
|
||||
|
||||
renderContext->UpdateBackgroundColor(Color::BLACK);
|
||||
renderContextForMediaPlayer_->UpdateBackgroundColor(Color::BLACK);
|
||||
renderContext->SetClipToBounds(true);
|
||||
@ -887,8 +939,12 @@ void VideoPattern::OnModifyDone()
|
||||
|
||||
// src has changed
|
||||
auto layoutProperty = GetLayoutProperty<VideoLayoutProperty>();
|
||||
#ifdef RENDER_EXTRACT_SUPPORTED
|
||||
if ((layoutProperty && layoutProperty->HasVideoSource() && layoutProperty->GetVideoSource().value() != src_)) {
|
||||
#else
|
||||
if (Container::GreatOrEqualAPITargetVersion(PlatformVersion::VERSION_TWELVE) &&
|
||||
(layoutProperty && layoutProperty->HasVideoSource() && layoutProperty->GetVideoSource().value() != src_)) {
|
||||
#endif
|
||||
ResetStatus();
|
||||
}
|
||||
|
||||
@ -1129,7 +1185,12 @@ bool VideoPattern::OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty,
|
||||
|
||||
void VideoPattern::OnAreaChangedInner()
|
||||
{
|
||||
#ifndef RENDER_EXTRACT_SUPPORTED
|
||||
auto isFullScreen = IsFullScreen();
|
||||
if (SystemProperties::GetExtSurfaceEnabled() && isFullScreen) {
|
||||
#else
|
||||
if (SystemProperties::GetExtSurfaceEnabled()) {
|
||||
#endif
|
||||
auto host = GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
auto geometryNode = host->GetGeometryNode();
|
||||
@ -1724,6 +1785,9 @@ void VideoPattern::EnableDrag()
|
||||
|
||||
VideoPattern::~VideoPattern()
|
||||
{
|
||||
if (renderContextForMediaPlayer_) {
|
||||
renderContextForMediaPlayer_->RemoveSurfaceChangedCallBack();
|
||||
}
|
||||
if (IsSupportImageAnalyzer()) {
|
||||
DestroyAnalyzerOverlay();
|
||||
}
|
||||
@ -1844,8 +1908,7 @@ bool VideoPattern::IsSupportImageAnalyzer()
|
||||
return isEnableAnalyzer_ && !needControlBar && imageAnalyzerManager_->IsSupportImageAnalyzerFeature();
|
||||
}
|
||||
|
||||
bool VideoPattern::ShouldUpdateImageAnalyzer()
|
||||
{
|
||||
bool VideoPattern::ShouldUpdateImageAnalyzer() {
|
||||
auto layoutProperty = GetLayoutProperty<VideoLayoutProperty>();
|
||||
CHECK_NULL_RETURN(layoutProperty, false);
|
||||
const auto& constraint = layoutProperty->GetCalcLayoutConstraint();
|
||||
@ -1883,7 +1946,7 @@ void VideoPattern::StartImageAnalyzer()
|
||||
auto pattern = weak.Upgrade();
|
||||
CHECK_NULL_VOID(pattern);
|
||||
pattern->CreateAnalyzerOverlay();
|
||||
}, ANALYZER_DELAY_TIME, "ArkUIVideoCreateAnalyzerOverlay");
|
||||
}, ANALYZER_DELAY_TIME, "ArkUIVideoCreateAnalyzerOverlay");
|
||||
}
|
||||
|
||||
void VideoPattern::CreateAnalyzerOverlay()
|
||||
@ -1928,7 +1991,7 @@ void VideoPattern::StartUpdateImageAnalyzer()
|
||||
}
|
||||
pattern->UpdateAnalyzerOverlay();
|
||||
pattern->isContentSizeChanged_ = false;
|
||||
}, ANALYZER_CAPTURE_DELAY_TIME, "ArkUIVideoUpdateAnalyzerOverlay");
|
||||
}, ANALYZER_CAPTURE_DELAY_TIME, "ArkUIVideoUpdateAnalyzerOverlay");
|
||||
isContentSizeChanged_ = true;
|
||||
}
|
||||
|
||||
|
@ -31,5 +31,7 @@ build_component_ng("xcomponent_pattern_ng") {
|
||||
"graphic_2d:librender_service_client",
|
||||
"hilog:libhilog",
|
||||
]
|
||||
} else if (is_arkui_x) {
|
||||
deps = [ "$ace_graphic/rosen/modules/render_service_client:librender_service_client_static" ]
|
||||
}
|
||||
}
|
||||
|
@ -31,4 +31,12 @@ void XComponentExtSurfaceCallbackClient::ProcessSurfaceChange(int32_t width, int
|
||||
xcPattern->XComponentSizeChange({ 0, 0, width, height }, true);
|
||||
}
|
||||
}
|
||||
|
||||
void XComponentExtSurfaceCallbackClient::ProcessSurfaceDestroy()
|
||||
{
|
||||
auto xcPattern = weakXComponentPattern_.Upgrade();
|
||||
if (xcPattern) {
|
||||
xcPattern->NativeXComponentDestroy();
|
||||
}
|
||||
}
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
|
||||
void ProcessSurfaceChange(int32_t width, int32_t height) override;
|
||||
|
||||
void ProcessSurfaceDestroy() override {}
|
||||
void ProcessSurfaceDestroy() override;
|
||||
|
||||
private:
|
||||
WeakPtr<XComponentPattern> weakXComponentPattern_;
|
||||
|
@ -38,6 +38,9 @@ public:
|
||||
static bool IsBackGroundColorAvailable(const XComponentType& type)
|
||||
{
|
||||
return type == XComponentType::TEXTURE || type == XComponentType::NODE ||
|
||||
#ifdef PLATFORM_VIEW_SUPPORTED
|
||||
type == XComponentType::PLATFORM_VIEW ||
|
||||
#endif
|
||||
(type == XComponentType::SURFACE && Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_ELEVEN));
|
||||
}
|
||||
static bool IsCommonEventAvailable(const XComponentType& type, std::optional<std::string>& libraryName)
|
||||
@ -70,15 +73,15 @@ public:
|
||||
{
|
||||
return XComponentType::UNKNOWN;
|
||||
}
|
||||
virtual void SetControllerOnCreated(SurfaceCreatedEvent&& onCreated) {}
|
||||
virtual void SetControllerOnChanged(SurfaceChangedEvent&& onChanged) {}
|
||||
virtual void SetControllerOnDestroyed(SurfaceDestroyedEvent&& onDestroyed) {}
|
||||
virtual std::optional<std::string> GetLibraryName()
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
virtual void EnableAnalyzer(bool enable) {}
|
||||
virtual void SetImageAIOptions(void* options) {}
|
||||
virtual void SetControllerOnCreated(SurfaceCreatedEvent&& onCreated) {}
|
||||
virtual void SetControllerOnChanged(SurfaceChangedEvent&& onChanged) {}
|
||||
virtual void SetControllerOnDestroyed(SurfaceDestroyedEvent&& onDestroyed) {}
|
||||
|
||||
private:
|
||||
static std::unique_ptr<XComponentModel> instance_;
|
||||
|
@ -74,6 +74,20 @@ std::optional<std::string> XComponentModelNG::GetLibraryName()
|
||||
return xcPattern->GetLibraryName();
|
||||
}
|
||||
|
||||
XComponentType XComponentModelNG::GetTypeImpl(const RefPtr<FrameNode>& frameNode)
|
||||
{
|
||||
CHECK_NULL_RETURN(frameNode, XComponentType::UNKNOWN);
|
||||
auto layoutProperty = frameNode->GetLayoutProperty<XComponentLayoutProperty>();
|
||||
CHECK_NULL_RETURN(layoutProperty, XComponentType::UNKNOWN);
|
||||
return layoutProperty->GetXComponentTypeValue();
|
||||
}
|
||||
|
||||
XComponentType XComponentModelNG::GetType()
|
||||
{
|
||||
auto frameNode = AceType::Claim(ViewStackProcessor::GetInstance()->GetMainFrameNode());
|
||||
return GetTypeImpl(frameNode);
|
||||
}
|
||||
|
||||
void XComponentModelNG::SetSoPath(const std::string& soPath)
|
||||
{
|
||||
auto frameNode = AceType::Claim(ViewStackProcessor::GetInstance()->GetMainFrameNode());
|
||||
@ -87,19 +101,6 @@ void XComponentModelNG::SetSoPath(const std::string& soPath)
|
||||
xcPattern->SetSoPath(soPath);
|
||||
}
|
||||
|
||||
XComponentType XComponentModelNG::GetTypeImpl(const RefPtr<FrameNode>& frameNode)
|
||||
{
|
||||
CHECK_NULL_RETURN(frameNode, XComponentType::UNKNOWN);
|
||||
auto layoutProperty = frameNode->GetLayoutProperty<XComponentLayoutProperty>();
|
||||
CHECK_NULL_RETURN(layoutProperty, XComponentType::UNKNOWN);
|
||||
return layoutProperty->GetXComponentTypeValue();
|
||||
}
|
||||
|
||||
XComponentType XComponentModelNG::GetType()
|
||||
{
|
||||
return GetTypeImpl(AceType::Claim(ViewStackProcessor::GetInstance()->GetMainFrameNode()));
|
||||
}
|
||||
|
||||
void XComponentModelNG::SetOnLoad(LoadEvent&& onLoad)
|
||||
{
|
||||
auto frameNode = AceType::Claim(ViewStackProcessor::GetInstance()->GetMainFrameNode());
|
||||
|
@ -41,11 +41,11 @@ public:
|
||||
void RegisterOnDestroy(const RefPtr<AceType>& node, DestroyEvent&& onDestroy) override;
|
||||
bool IsTexture() override;
|
||||
void SetDetachCallback(DetachCallback&& onDetach) override;
|
||||
void EnableAnalyzer(bool enable) override;
|
||||
void SetImageAIOptions(void* options) override;
|
||||
void SetControllerOnCreated(SurfaceCreatedEvent&& onCreated) override;
|
||||
void SetControllerOnChanged(SurfaceChangedEvent&& onChanged) override;
|
||||
void SetControllerOnDestroyed(SurfaceDestroyedEvent&& onDestroyed) override;
|
||||
void EnableAnalyzer(bool enable) override;
|
||||
void SetImageAIOptions(void* options) override;
|
||||
|
||||
static bool IsTexture(FrameNode* frameNode);
|
||||
static XComponentType GetType(FrameNode* frameNode);
|
||||
@ -65,7 +65,6 @@ public:
|
||||
static void SetDetachCallback(FrameNode* frameNode, DetachCallback&& onDetach);
|
||||
static void SetImageAIOptions(FrameNode* frameNode, void* options);
|
||||
|
||||
|
||||
private:
|
||||
static XComponentType GetTypeImpl(const RefPtr<FrameNode>& frameNode);
|
||||
};
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include <cstdlib>
|
||||
#include "core/components_ng/pattern/xcomponent/xcomponent_pattern.h"
|
||||
|
||||
#include "interfaces/native/ui_input_event.h"
|
||||
#include "interfaces/native/event/ui_input_event_impl.h"
|
||||
#include "interfaces/native/ui_input_event.h"
|
||||
|
||||
@ -30,6 +29,8 @@
|
||||
#include "base/ressched/ressched_report.h"
|
||||
#include "base/utils/system_properties.h"
|
||||
#include "base/utils/utils.h"
|
||||
#include "core/common/ace_engine.h"
|
||||
#include "core/common/ace_view.h"
|
||||
#include "core/common/ai/image_analyzer_manager.h"
|
||||
#include "core/components/common/layout/constants.h"
|
||||
#include "core/components_ng/event/gesture_event_hub.h"
|
||||
@ -55,22 +56,6 @@
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
namespace {
|
||||
#ifdef OHOS_PLATFORM
|
||||
constexpr int64_t INCREASE_CPU_TIME_ONCE = 4000000000; // 4s(unit: ns)
|
||||
constexpr double INFLEXION = 0.35;
|
||||
constexpr double FLING_FRICTION = 0.002;
|
||||
constexpr double GRAVITY = 9.8;
|
||||
const double DECELERATION = log(0.78) / log(0.9);
|
||||
const double DECEL_MINUS_ONE = DECELERATION - 1.0;
|
||||
constexpr int32_t MAX_SLIE_TIME = 5000;
|
||||
constexpr int32_t SECOND_UNIT = 1000;
|
||||
constexpr int32_t SQUARE = 2;
|
||||
constexpr int32_t DISTANCE_UNIT = 1000 * 1000;
|
||||
constexpr int32_t DELAY_TIME = 1;
|
||||
constexpr int32_t DPI_DENSITY_RATE = 160;
|
||||
constexpr double INCH_UNIT = 39.37;
|
||||
constexpr double TUNNING_FACTOR = 0.84;
|
||||
#endif
|
||||
std::string XComponentTypeToString(XComponentType type)
|
||||
{
|
||||
switch (type) {
|
||||
@ -84,6 +69,10 @@ std::string XComponentTypeToString(XComponentType type)
|
||||
return "texture";
|
||||
case XComponentType::NODE:
|
||||
return "node";
|
||||
#ifdef PLATFORM_VIEW_SUPPORTED
|
||||
case XComponentType::PLATFORM_VIEW:
|
||||
return "platform_view";
|
||||
#endif
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
@ -185,13 +174,14 @@ void XComponentPattern::Initialize()
|
||||
if (type_ == XComponentType::SURFACE || type_ == XComponentType::TEXTURE) {
|
||||
renderContext->SetClipToFrame(true);
|
||||
renderContext->SetClipToBounds(true);
|
||||
#ifdef RENDER_EXTRACT_SUPPORTED
|
||||
renderSurface_ = RenderSurface::Create(CovertToRenderSurfaceType(type_));
|
||||
#else
|
||||
renderSurface_ = RenderSurface::Create();
|
||||
#endif
|
||||
renderSurface_->SetInstanceId(GetHostInstanceId());
|
||||
if (type_ == XComponentType::SURFACE) {
|
||||
renderContextForSurface_ = RenderContext::Create();
|
||||
RenderContext::ContextParam param = { RenderContext::ContextType::HARDWARE_SURFACE, GetId() + "Surface" };
|
||||
renderContextForSurface_->InitContext(false, param);
|
||||
renderContextForSurface_->UpdateBackgroundColor(Color::BLACK);
|
||||
InitializeRenderContext();
|
||||
if (!SystemProperties::GetExtSurfaceEnabled()) {
|
||||
renderSurface_->SetRenderContext(renderContextForSurface_);
|
||||
} else {
|
||||
@ -200,6 +190,9 @@ void XComponentPattern::Initialize()
|
||||
pipelineContext->AddOnAreaChangeNode(host->GetId());
|
||||
extSurfaceClient_ = MakeRefPtr<XComponentExtSurfaceCallbackClient>(WeakClaim(this));
|
||||
renderSurface_->SetExtSurfaceCallback(extSurfaceClient_);
|
||||
#ifdef RENDER_EXTRACT_SUPPORTED
|
||||
RegisterRenderContextCallBack();
|
||||
#endif
|
||||
}
|
||||
handlingSurfaceRenderContext_ = renderContextForSurface_;
|
||||
} else if (type_ == XComponentType::TEXTURE) {
|
||||
@ -224,12 +217,143 @@ void XComponentPattern::Initialize()
|
||||
}
|
||||
}
|
||||
|
||||
void XComponentPattern::InitializeRenderContext()
|
||||
{
|
||||
renderContextForSurface_ = RenderContext::Create();
|
||||
#ifdef RENDER_EXTRACT_SUPPORTED
|
||||
auto contextType = type_ == XComponentType::TEXTURE ? RenderContext::ContextType::HARDWARE_TEXTURE
|
||||
: RenderContext::ContextType::HARDWARE_SURFACE;
|
||||
RenderContext::ContextParam param = { contextType, GetId() + "Surface" };
|
||||
#else
|
||||
RenderContext::ContextParam param = { RenderContext::ContextType::HARDWARE_SURFACE, GetId() + "Surface" };
|
||||
#endif
|
||||
|
||||
renderContextForSurface_->InitContext(false, param);
|
||||
|
||||
renderContextForSurface_->UpdateBackgroundColor(Color::BLACK);
|
||||
}
|
||||
|
||||
#ifdef RENDER_EXTRACT_SUPPORTED
|
||||
RenderSurface::RenderSurfaceType XComponentPattern::CovertToRenderSurfaceType(const XComponentType& hostType)
|
||||
{
|
||||
switch (hostType) {
|
||||
case XComponentType::SURFACE:
|
||||
return RenderSurface::RenderSurfaceType::SURFACE;
|
||||
case XComponentType::TEXTURE:
|
||||
return RenderSurface::RenderSurfaceType::TEXTURE;
|
||||
default:
|
||||
return RenderSurface::RenderSurfaceType::UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
void XComponentPattern::RegisterRenderContextCallBack()
|
||||
{
|
||||
CHECK_NULL_VOID(renderContextForSurface_);
|
||||
auto OnAreaChangedCallBack = [weak = WeakClaim(this)](float x, float y, float w, float h) mutable {
|
||||
auto pattern = weak.Upgrade();
|
||||
CHECK_NULL_VOID(pattern);
|
||||
auto host = pattern->GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
auto geometryNode = host->GetGeometryNode();
|
||||
CHECK_NULL_VOID(geometryNode);
|
||||
auto xcomponentNodeSize = geometryNode->GetContentSize();
|
||||
auto xcomponentNodeOffset = geometryNode->GetContentOffset();
|
||||
auto transformRelativeOffset = host->GetTransformRelativeOffset();
|
||||
Rect rect = Rect(transformRelativeOffset.GetX() + xcomponentNodeOffset.GetX(),
|
||||
transformRelativeOffset.GetY() + xcomponentNodeOffset.GetY(), xcomponentNodeSize.Width(),
|
||||
xcomponentNodeSize.Height());
|
||||
if (pattern->renderSurface_) {
|
||||
pattern->renderSurface_->SetExtSurfaceBoundsSync(rect.Left(), rect.Top(),
|
||||
rect.Width(), rect.Height());
|
||||
}
|
||||
};
|
||||
renderContextForSurface_->SetSurfaceChangedCallBack(OnAreaChangedCallBack);
|
||||
}
|
||||
|
||||
void XComponentPattern::RequestFocus()
|
||||
{
|
||||
auto host = GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
auto eventHub = host->GetEventHub<XComponentEventHub>();
|
||||
CHECK_NULL_VOID(eventHub);
|
||||
auto focusHub = eventHub->GetOrCreateFocusHub();
|
||||
CHECK_NULL_VOID(focusHub);
|
||||
|
||||
focusHub->RequestFocusImmediately();
|
||||
}
|
||||
|
||||
#ifdef PLATFORM_VIEW_SUPPORTED
|
||||
void* XComponentPattern::GetNativeWindow(int32_t instanceId, int64_t textureId)
|
||||
{
|
||||
auto container = AceEngine::Get().GetContainer(instanceId);
|
||||
CHECK_NULL_RETURN(container, nullptr);
|
||||
auto nativeView = container->GetAceView();
|
||||
CHECK_NULL_RETURN(nativeView, nullptr);
|
||||
return const_cast<void*>(nativeView->GetNativeWindowById(textureId));
|
||||
}
|
||||
|
||||
void XComponentPattern::OnTextureRefresh(void* surface)
|
||||
{
|
||||
CHECK_NULL_VOID(surface);
|
||||
auto renderContextForPlatformView = renderContextForPlatformViewWeakPtr_.Upgrade();
|
||||
CHECK_NULL_VOID(renderContextForPlatformView);
|
||||
renderContextForPlatformView->MarkNewFrameAvailable(surface);
|
||||
UpdatePlatformViewLayoutIfNeeded();
|
||||
}
|
||||
|
||||
void XComponentPattern::RegisterPlatformViewEvent()
|
||||
{
|
||||
CHECK_NULL_VOID(platformView_);
|
||||
ContainerScope scope(GetHostInstanceId());
|
||||
auto context = PipelineContext::GetCurrentContext();
|
||||
CHECK_NULL_VOID(context);
|
||||
|
||||
auto uiTaskExecutor = SingleTaskExecutor::Make(context->GetTaskExecutor(), TaskExecutor::TaskType::UI);
|
||||
auto xcPattern = WeakClaim(this);
|
||||
|
||||
auto&& textureRefreshEvent = [xcPattern, uiTaskExecutor](int32_t instanceId, int64_t textureId) {
|
||||
uiTaskExecutor.PostSyncTask([&xcPattern, instanceId, textureId] {
|
||||
auto xComponentPattern = xcPattern.Upgrade();
|
||||
CHECK_NULL_VOID(xComponentPattern);
|
||||
void* nativeWindow = xComponentPattern->GetNativeWindow(instanceId, textureId);
|
||||
if (!nativeWindow) {
|
||||
LOGE("the native window is nullptr.");
|
||||
return;
|
||||
}
|
||||
xComponentPattern->OnTextureRefresh(nativeWindow);
|
||||
}, "ArkUIXComponentPatternTextureRefreshEvent");
|
||||
};
|
||||
platformView_->RegisterTextureEvent(textureRefreshEvent);
|
||||
|
||||
auto&& platformViewReadyEvent = [xcPattern, uiTaskExecutor]() {
|
||||
uiTaskExecutor.PostSyncTask([&xcPattern] {
|
||||
auto xComponentPattern = xcPattern.Upgrade();
|
||||
CHECK_NULL_VOID(xComponentPattern);
|
||||
auto host = xComponentPattern->GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
host->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
|
||||
}, "ArkUIXComponentPatternPlatformViewReadyEvent");
|
||||
};
|
||||
platformView_->RegisterPlatformViewReadyEvent(platformViewReadyEvent);
|
||||
}
|
||||
|
||||
void XComponentPattern::PrepareSurface()
|
||||
{
|
||||
if (!platformView_ || renderSurface_->IsSurfaceValid()) {
|
||||
return;
|
||||
}
|
||||
if (!SystemProperties::GetExtSurfaceEnabled()) {
|
||||
renderSurface_->SetRenderContext(renderContextForPlatformView_);
|
||||
}
|
||||
renderSurface_->InitSurface();
|
||||
platformView_->SetRenderSurface(renderSurface_);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void XComponentPattern::OnAttachToFrameNode()
|
||||
{
|
||||
Initialize();
|
||||
#ifdef OHOS_PLATFORM
|
||||
physicalCoeff_ = GRAVITY * INCH_UNIT * PipelineBase::GetCurrentDensity() * DPI_DENSITY_RATE * TUNNING_FACTOR;
|
||||
#endif
|
||||
auto host = GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
auto pipeline = host->GetContextRefPtr();
|
||||
@ -246,8 +370,55 @@ void XComponentPattern::OnAttachToFrameNode()
|
||||
if (FrameReport::GetInstance().GetEnable()) {
|
||||
FrameReport::GetInstance().EnableSelfRender();
|
||||
}
|
||||
#ifdef PLATFORM_VIEW_SUPPORTED
|
||||
if (type_ == XComponentType::PLATFORM_VIEW) {
|
||||
PlatformViewInitialize();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PLATFORM_VIEW_SUPPORTED
|
||||
void XComponentPattern::PlatformViewInitialize()
|
||||
{
|
||||
auto host = GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
auto context = PipelineContext::GetCurrentContext();
|
||||
CHECK_NULL_VOID(context);
|
||||
platformView_ = PlatformViewProxy::GetInstance().Attach(GetId());
|
||||
platformView_->InitPlatformView();
|
||||
renderSurface_ = RenderSurface::Create();
|
||||
renderSurface_->SetInstanceId(GetHostInstanceId());
|
||||
renderContextForPlatformView_ = RenderContext::Create();
|
||||
InitEvent();
|
||||
auto renderContext = host->GetRenderContext();
|
||||
CHECK_NULL_VOID(renderContext);
|
||||
static RenderContext::ContextParam param = { RenderContext::ContextType::HARDWARE_TEXTURE,
|
||||
"PlatformViewSurface", RenderContext::PatternType::PLATFORM_VIEW };
|
||||
renderContextForPlatformView_->InitContext(false, param);
|
||||
renderSurfaceWeakPtr_ = renderSurface_;
|
||||
renderContextForPlatformViewWeakPtr_ = renderContextForPlatformView_;
|
||||
auto OnAttachCallBack = [weak = WeakClaim(this)](int64_t textureId, bool isAttach) mutable {
|
||||
auto xcomponentPattern = weak.Upgrade();
|
||||
CHECK_NULL_VOID(xcomponentPattern);
|
||||
if (auto renderSurface = xcomponentPattern->renderSurfaceWeakPtr_.Upgrade(); renderSurface) {
|
||||
renderSurface->AttachToGLContext(textureId, isAttach);
|
||||
}
|
||||
};
|
||||
renderContextForPlatformView_->AddAttachCallBack(OnAttachCallBack);
|
||||
auto OnUpdateCallBack = [weak = WeakClaim(this)](std::vector<float>& matrix) mutable {
|
||||
auto xcomponentPattern = weak.Upgrade();
|
||||
CHECK_NULL_VOID(xcomponentPattern);
|
||||
if (auto renderSurface = xcomponentPattern->renderSurfaceWeakPtr_.Upgrade(); renderSurface) {
|
||||
renderSurface->UpdateTextureImage(matrix);
|
||||
}
|
||||
};
|
||||
renderContextForPlatformView_->AddUpdateCallBack(OnUpdateCallBack);
|
||||
renderContext->UpdateBackgroundColor(Color::BLACK);
|
||||
renderContextForPlatformView_->UpdateBackgroundColor(Color::BLACK);
|
||||
renderContext->SetClipToBounds(true);
|
||||
}
|
||||
#endif
|
||||
|
||||
void XComponentPattern::OnModifyDone()
|
||||
{
|
||||
auto host = GetHost();
|
||||
@ -279,6 +450,7 @@ void XComponentPattern::OnModifyDone()
|
||||
|
||||
void XComponentPattern::OnAreaChangedInner()
|
||||
{
|
||||
#ifndef RENDER_EXTRACT_SUPPORTED
|
||||
if (SystemProperties::GetExtSurfaceEnabled()) {
|
||||
auto host = GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
@ -291,6 +463,7 @@ void XComponentPattern::OnAreaChangedInner()
|
||||
transformRelativeOffset.GetY() + xcomponentNodeOffset.GetY(), xcomponentNodeSize.Width(),
|
||||
xcomponentNodeSize.Height());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void XComponentPattern::SetSurfaceNodeToGraphic()
|
||||
@ -325,6 +498,17 @@ void XComponentPattern::SetSurfaceNodeToGraphic()
|
||||
|
||||
void XComponentPattern::OnRebuildFrame()
|
||||
{
|
||||
#ifdef PLATFORM_VIEW_SUPPORTED
|
||||
if (type_ == XComponentType::PLATFORM_VIEW) {
|
||||
auto host = GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
auto renderContext = host->GetRenderContext();
|
||||
CHECK_NULL_VOID(renderContext);
|
||||
CHECK_NULL_VOID(renderContextForPlatformView_);
|
||||
renderContext->AddChild(renderContextForPlatformView_, 0);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (type_ != XComponentType::SURFACE) {
|
||||
return;
|
||||
}
|
||||
@ -361,6 +545,11 @@ void XComponentPattern::OnDetachFromFrameNode(FrameNode* frameNode)
|
||||
ACE_LAYOUT_SCOPED_TRACE("XComponent[%s] FireControllerDestroyedEvent", GetId().c_str());
|
||||
eventHub->FireControllerDestroyedEvent(surfaceId_);
|
||||
}
|
||||
#ifdef RENDER_EXTRACT_SUPPORTED
|
||||
if (renderContextForSurface_) {
|
||||
renderContextForSurface_->RemoveSurfaceChangedCallBack();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
auto id = frameNode->GetId();
|
||||
@ -459,6 +648,7 @@ void XComponentPattern::BeforeSyncGeometryProperties(const DirtySwapConfig& conf
|
||||
NativeXComponentOffset(offset.GetX(), offset.GetY());
|
||||
hasXComponentInit_ = true;
|
||||
}
|
||||
#ifndef RENDER_EXTRACT_SUPPORTED
|
||||
if (SystemProperties::GetExtSurfaceEnabled()) {
|
||||
auto transformRelativeOffset = host->GetTransformRelativeOffset();
|
||||
renderSurface_->SetExtSurfaceBounds(
|
||||
@ -466,13 +656,43 @@ void XComponentPattern::BeforeSyncGeometryProperties(const DirtySwapConfig& conf
|
||||
static_cast<int32_t>(transformRelativeOffset.GetY() + localPosition_.GetY()),
|
||||
static_cast<int32_t>(drawSize_.Width()), static_cast<int32_t>(drawSize_.Height()));
|
||||
}
|
||||
#endif
|
||||
UpdateSurfaceBounds(false, config.frameOffsetChange);
|
||||
if (type_ == XComponentType::SURFACE && renderType_ == NodeRenderType::RENDER_TYPE_TEXTURE) {
|
||||
AddAfterLayoutTaskForExportTexture();
|
||||
}
|
||||
#ifdef PLATFORM_VIEW_SUPPORTED
|
||||
if (type_ == XComponentType::PLATFORM_VIEW) {
|
||||
UpdatePlatformViewLayoutIfNeeded();
|
||||
}
|
||||
#endif
|
||||
host->MarkNeedSyncRenderTree();
|
||||
}
|
||||
|
||||
#ifdef PLATFORM_VIEW_SUPPORTED
|
||||
void XComponentPattern::UpdatePlatformViewLayoutIfNeeded()
|
||||
{
|
||||
auto host = GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
auto transformRelativeOffset = host->GetTransformRelativeOffset();
|
||||
OffsetF offset = localPosition_ + transformRelativeOffset;
|
||||
if (lastDrawSize_ != drawSize_ || lastOffset_ != offset) {
|
||||
platformView_->UpdatePlatformViewLayout(drawSize_, offset);
|
||||
if (renderContextForPlatformView_) {
|
||||
renderContextForPlatformView_->SetBounds(localPosition_.GetX(), localPosition_.GetY(),
|
||||
drawSize_.Width(), drawSize_.Height());
|
||||
}
|
||||
if (SystemProperties::GetExtSurfaceEnabled()) {
|
||||
renderSurface_->SetExtSurfaceBounds(transformRelativeOffset.GetX() + localPosition_.GetX(),
|
||||
transformRelativeOffset.GetY() + localPosition_.GetY(), drawSize_.Width(),
|
||||
drawSize_.Height());
|
||||
}
|
||||
lastDrawSize_ = drawSize_;
|
||||
lastOffset_ = offset;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void XComponentPattern::DumpInfo()
|
||||
{
|
||||
DumpLog::GetInstance().AddDesc(std::string("xcomponentId: ").append(id_.value_or("no id")));
|
||||
@ -501,6 +721,11 @@ void XComponentPattern::NativeXComponentChange(float width, float height)
|
||||
CHECK_NULL_VOID(callback);
|
||||
CHECK_NULL_VOID(callback->OnSurfaceChanged);
|
||||
callback->OnSurfaceChanged(nativeXComponent_.get(), surface);
|
||||
#ifdef RENDER_EXTRACT_SUPPORTED
|
||||
auto host = GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
host->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void XComponentPattern::NativeXComponentDestroy()
|
||||
@ -567,6 +792,11 @@ void XComponentPattern::XComponentSizeInit()
|
||||
auto context = host->GetContextRefPtr();
|
||||
CHECK_NULL_VOID(context);
|
||||
InitNativeWindow(initSize_.Width(), initSize_.Height());
|
||||
#ifdef RENDER_EXTRACT_SUPPORTED
|
||||
if (xcomponentController_ && renderSurface_) {
|
||||
xcomponentController_->SetSurfaceId(renderSurface_->GetUniqueId());
|
||||
}
|
||||
#endif
|
||||
auto eventHub = host->GetEventHub<XComponentEventHub>();
|
||||
CHECK_NULL_VOID(eventHub);
|
||||
TAG_LOGI(AceLogTag::ACE_XCOMPONENT, "XComponent[%{public}s] triggers onLoad and OnSurfaceCreated callback",
|
||||
@ -660,6 +890,10 @@ void XComponentPattern::InitEvent()
|
||||
|
||||
void XComponentPattern::InitFocusEvent(const RefPtr<FocusHub>& focusHub)
|
||||
{
|
||||
#ifdef RENDER_EXTRACT_SUPPORTED
|
||||
focusHub->SetFocusable(true);
|
||||
#endif
|
||||
|
||||
auto onFocusEvent = [weak = WeakClaim(this)]() {
|
||||
auto pattern = weak.Upgrade();
|
||||
CHECK_NULL_VOID(pattern);
|
||||
@ -746,6 +980,11 @@ void XComponentPattern::InitAxisEvent(const RefPtr<InputEventHub>& inputHub)
|
||||
|
||||
void XComponentPattern::InitOnTouchIntercept(const RefPtr<GestureEventHub>& gestureHub)
|
||||
{
|
||||
#ifdef PLATFORM_VIEW_SUPPORTED
|
||||
if (type_ == XComponentType::PLATFORM_VIEW) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
gestureHub->SetOnTouchIntercept(
|
||||
[weak = WeakClaim(this)](
|
||||
const TouchEventInfo& touchEvent) -> HitTestMode {
|
||||
@ -814,20 +1053,6 @@ void XComponentPattern::HandleTouchEvent(const TouchEventInfo& info)
|
||||
"%{public}u",
|
||||
touchEventPoint_.x, touchEventPoint_.y, touchEventPoint_.id, touchType,
|
||||
static_cast<uint32_t>(info.GetTouches().size()));
|
||||
#ifdef OHOS_PLATFORM
|
||||
// increase cpu frequency
|
||||
if (touchType == TouchType::MOVE) {
|
||||
auto currentTime = GetSysTimestamp();
|
||||
auto increaseCpuTime = currentTime - startIncreaseTime_;
|
||||
if (increaseCpuTime >= INCREASE_CPU_TIME_ONCE) {
|
||||
startIncreaseTime_ = currentTime;
|
||||
ResSchedReport::GetInstance().ResSchedDataReport("slide_on");
|
||||
}
|
||||
lastTouchInfo_ = touchEventPoint_;
|
||||
} else if (touchType == TouchType::UP) {
|
||||
ReportSlideToRss();
|
||||
}
|
||||
#endif
|
||||
SetTouchPoint(info.GetTouches(), timeStamp, touchType);
|
||||
|
||||
if (nativeXComponent_ && nativeXComponentImpl_) {
|
||||
@ -836,50 +1061,38 @@ void XComponentPattern::HandleTouchEvent(const TouchEventInfo& info)
|
||||
{ touchInfo.GetFingerId(), ConvertNativeXComponentEventSourceType(info.GetSourceDevice()) });
|
||||
}
|
||||
NativeXComponentDispatchTouchEvent(touchEventPoint_, nativeXComponentTouchPoints_);
|
||||
|
||||
#ifdef RENDER_EXTRACT_SUPPORTED
|
||||
if (touchType == TouchType::DOWN) {
|
||||
RequestFocus();
|
||||
}
|
||||
#endif
|
||||
#ifdef PLATFORM_VIEW_SUPPORTED
|
||||
const auto& changedPoint = touchInfoList.front();
|
||||
PlatformViewDispatchTouchEvent(changedPoint);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef OHOS_PLATFORM
|
||||
void XComponentPattern::ReportSlideToRss()
|
||||
#ifdef PLATFORM_VIEW_SUPPORTED
|
||||
void XComponentPattern::PlatformViewDispatchTouchEvent(const TouchLocationInfo& changedPoint)
|
||||
{
|
||||
if (type_ != XComponentType::PLATFORM_VIEW) {
|
||||
return;
|
||||
}
|
||||
CHECK_NULL_VOID(platformView_);
|
||||
auto host = GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
auto* context = host->GetContext();
|
||||
CHECK_NULL_VOID(context);
|
||||
auto uiTaskExecutor = SingleTaskExecutor::Make(context->GetTaskExecutor(), TaskExecutor::TaskType::UI);
|
||||
uiTaskExecutor.PostDelayedTask([weakThis = WeakClaim(this)] {
|
||||
auto self = weakThis.Upgrade();
|
||||
CHECK_NULL_VOID(self);
|
||||
self->slideCount_++;
|
||||
ResSchedReport::GetInstance().ResSchedDataReport("slide_on");
|
||||
}, DELAY_TIME, "ArkUIXComponentSlideOn");
|
||||
uiTaskExecutor.PostDelayedTask([weakThis = WeakClaim(this)] {
|
||||
auto self = weakThis.Upgrade();
|
||||
CHECK_NULL_VOID(self);
|
||||
self->slideCount_--;
|
||||
if (self->slideCount_ == 0) {
|
||||
ResSchedReport::GetInstance().ResSchedDataReport("slide_off");
|
||||
}
|
||||
}, GetFlingDuration(GetUpVelocity(lastTouchInfo_, touchEventPoint_)) + DELAY_TIME, "ArkUIXComponentSlideOff");
|
||||
}
|
||||
|
||||
float XComponentPattern::GetUpVelocity(OH_NativeXComponent_TouchEvent lastMoveInfo,
|
||||
OH_NativeXComponent_TouchEvent upEventInfo)
|
||||
{
|
||||
float distance = sqrt(pow(lastMoveInfo.x - upEventInfo.x, SQUARE) + pow(lastMoveInfo.y - upEventInfo.y, SQUARE));
|
||||
int64_t time = abs(lastMoveInfo.timeStamp - upEventInfo.timeStamp);
|
||||
if (time < SECOND_UNIT) {
|
||||
return 0.0f;
|
||||
auto transformRelativeOffset = host->GetTransformRelativeOffset();
|
||||
NG::OffsetF pointOffset = localPosition_ + transformRelativeOffset;
|
||||
if (changedPoint.GetTouchType() == TouchType::DOWN) {
|
||||
platformView_->HandleTouchDown(pointOffset);
|
||||
} else if (changedPoint.GetTouchType() == TouchType::MOVE) {
|
||||
platformView_->HandleTouchMove(pointOffset);
|
||||
} else if (changedPoint.GetTouchType() == TouchType::UP) {
|
||||
platformView_->HandleTouchUp(pointOffset);
|
||||
} else if (changedPoint.GetTouchType() == TouchType::CANCEL) {
|
||||
platformView_->HandleTouchCancel(pointOffset);
|
||||
}
|
||||
return distance * DISTANCE_UNIT / (time / SECOND_UNIT); // unit: pixel/ms
|
||||
}
|
||||
|
||||
int XComponentPattern::GetFlingDuration(float velocity)
|
||||
{
|
||||
if (physicalCoeff_ - 0 < 1E-6 || velocity - 0 < 1E-6) {
|
||||
return 0;
|
||||
}
|
||||
double splineDeceleration = log(INFLEXION * velocity / (FLING_FRICTION * physicalCoeff_));
|
||||
return std::min((int)(SECOND_UNIT * exp(splineDeceleration / DECEL_MINUS_ONE)), MAX_SLIE_TIME);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1046,7 +1259,6 @@ std::vector<OH_NativeXComponent_HistoricalPoint> XComponentPattern::SetHistoryPo
|
||||
return historicalPoints;
|
||||
}
|
||||
|
||||
|
||||
void XComponentPattern::FireExternalEvent(RefPtr<NG::PipelineContext> context,
|
||||
const std::string& componentId, const uint32_t nodeId, const bool isDestroy)
|
||||
{
|
||||
@ -1390,6 +1602,110 @@ void XComponentPattern::OnWindowShow()
|
||||
hasReleasedSurface_ = false;
|
||||
}
|
||||
|
||||
void XComponentPattern::EnableAnalyzer(bool enable)
|
||||
{
|
||||
isEnableAnalyzer_ = enable;
|
||||
if (!isEnableAnalyzer_) {
|
||||
DestroyAnalyzerOverlay();
|
||||
return;
|
||||
}
|
||||
|
||||
CHECK_NULL_VOID(!imageAnalyzerManager_);
|
||||
auto host = GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
imageAnalyzerManager_ = std::make_shared<ImageAnalyzerManager>(host, ImageAnalyzerHolder::XCOMPONENT);
|
||||
}
|
||||
|
||||
void XComponentPattern::SetImageAIOptions(void *options)
|
||||
{
|
||||
if (!imageAnalyzerManager_) {
|
||||
imageAnalyzerManager_ = std::make_shared<ImageAnalyzerManager>(GetHost(), ImageAnalyzerHolder::XCOMPONENT);
|
||||
}
|
||||
CHECK_NULL_VOID(imageAnalyzerManager_);
|
||||
imageAnalyzerManager_->SetImageAIOptions(options);
|
||||
}
|
||||
|
||||
void XComponentPattern::StartImageAnalyzer(void* config, OnAnalyzedCallback& onAnalyzed)
|
||||
{
|
||||
if (!IsSupportImageAnalyzerFeature()) {
|
||||
CHECK_NULL_VOID(onAnalyzed);
|
||||
(onAnalyzed.value())(ImageAnalyzerState::UNSUPPORTED);
|
||||
return;
|
||||
}
|
||||
|
||||
CHECK_NULL_VOID(imageAnalyzerManager_);
|
||||
imageAnalyzerManager_->SetImageAnalyzerConfig(config);
|
||||
imageAnalyzerManager_->SetImageAnalyzerCallback(onAnalyzed);
|
||||
|
||||
auto host = GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
auto* context = host->GetContext();
|
||||
CHECK_NULL_VOID(context);
|
||||
auto uiTaskExecutor = SingleTaskExecutor::Make(context->GetTaskExecutor(), TaskExecutor::TaskType::UI);
|
||||
uiTaskExecutor.PostTask(
|
||||
[weak = WeakClaim(this)] {
|
||||
auto pattern = weak.Upgrade();
|
||||
CHECK_NULL_VOID(pattern);
|
||||
pattern->CreateAnalyzerOverlay();
|
||||
},
|
||||
"ArkUIXComponentCreateAnalyzerOverlay");
|
||||
}
|
||||
|
||||
void XComponentPattern::StopImageAnalyzer()
|
||||
{
|
||||
DestroyAnalyzerOverlay();
|
||||
}
|
||||
|
||||
bool XComponentPattern::IsSupportImageAnalyzerFeature()
|
||||
{
|
||||
return isEnableAnalyzer_ && imageAnalyzerManager_ && imageAnalyzerManager_->IsSupportImageAnalyzerFeature();
|
||||
}
|
||||
|
||||
void XComponentPattern::CreateAnalyzerOverlay()
|
||||
{
|
||||
auto host = GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
host->SetOverlayNode(nullptr);
|
||||
auto context = host->GetRenderContext();
|
||||
CHECK_NULL_VOID(context);
|
||||
auto pixelMap = context->GetThumbnailPixelMap();
|
||||
CHECK_NULL_VOID(pixelMap);
|
||||
if (IsSupportImageAnalyzerFeature()) {
|
||||
CHECK_NULL_VOID(imageAnalyzerManager_);
|
||||
imageAnalyzerManager_->CreateAnalyzerOverlay(pixelMap);
|
||||
}
|
||||
}
|
||||
|
||||
void XComponentPattern::UpdateAnalyzerOverlay()
|
||||
{
|
||||
auto context = GetHost()->GetRenderContext();
|
||||
CHECK_NULL_VOID(context);
|
||||
auto pixelMap = context->GetThumbnailPixelMap();
|
||||
CHECK_NULL_VOID(pixelMap);
|
||||
CHECK_NULL_VOID(imageAnalyzerManager_);
|
||||
imageAnalyzerManager_->UpdateAnalyzerOverlay(pixelMap);
|
||||
}
|
||||
|
||||
void XComponentPattern::UpdateAnalyzerUIConfig(const RefPtr<NG::GeometryNode>& geometryNode)
|
||||
{
|
||||
if (IsSupportImageAnalyzerFeature()) {
|
||||
CHECK_NULL_VOID(imageAnalyzerManager_);
|
||||
imageAnalyzerManager_->UpdateAnalyzerUIConfig(geometryNode);
|
||||
}
|
||||
}
|
||||
|
||||
void XComponentPattern::DestroyAnalyzerOverlay()
|
||||
{
|
||||
CHECK_NULL_VOID(imageAnalyzerManager_);
|
||||
imageAnalyzerManager_->DestroyAnalyzerOverlay();
|
||||
}
|
||||
|
||||
void XComponentPattern::ReleaseImageAnalyzer()
|
||||
{
|
||||
CHECK_NULL_VOID(imageAnalyzerManager_);
|
||||
imageAnalyzerManager_->ReleaseImageAnalyzer();
|
||||
}
|
||||
|
||||
RectF XComponentPattern::AdjustPaintRect(float positionX, float positionY, float width, float height, bool isRound)
|
||||
{
|
||||
RectF rect;
|
||||
@ -1466,110 +1782,6 @@ float XComponentPattern::RoundValueToPixelGrid(float value, bool isRound, bool f
|
||||
return value;
|
||||
}
|
||||
|
||||
void XComponentPattern::EnableAnalyzer(bool enable)
|
||||
{
|
||||
isEnableAnalyzer_ = enable;
|
||||
if (!isEnableAnalyzer_) {
|
||||
DestroyAnalyzerOverlay();
|
||||
return;
|
||||
}
|
||||
|
||||
CHECK_NULL_VOID(!imageAnalyzerManager_);
|
||||
auto host = GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
imageAnalyzerManager_ = std::make_shared<ImageAnalyzerManager>(host, ImageAnalyzerHolder::XCOMPONENT);
|
||||
}
|
||||
|
||||
void XComponentPattern::SetImageAIOptions(void *options)
|
||||
{
|
||||
if (!imageAnalyzerManager_) {
|
||||
imageAnalyzerManager_ = std::make_shared<ImageAnalyzerManager>(GetHost(), ImageAnalyzerHolder::XCOMPONENT);
|
||||
}
|
||||
CHECK_NULL_VOID(imageAnalyzerManager_);
|
||||
imageAnalyzerManager_->SetImageAIOptions(options);
|
||||
}
|
||||
|
||||
void XComponentPattern::StartImageAnalyzer(void* config, OnAnalyzedCallback& onAnalyzed)
|
||||
{
|
||||
if (!IsSupportImageAnalyzerFeature()) {
|
||||
CHECK_NULL_VOID(onAnalyzed);
|
||||
(onAnalyzed.value())(ImageAnalyzerState::UNSUPPORTED);
|
||||
return;
|
||||
}
|
||||
|
||||
CHECK_NULL_VOID(imageAnalyzerManager_);
|
||||
imageAnalyzerManager_->SetImageAnalyzerConfig(config);
|
||||
imageAnalyzerManager_->SetImageAnalyzerCallback(onAnalyzed);
|
||||
|
||||
auto host = GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
auto context = host->GetContext();
|
||||
CHECK_NULL_VOID(context);
|
||||
auto uiTaskExecutor = SingleTaskExecutor::Make(context->GetTaskExecutor(), TaskExecutor::TaskType::UI);
|
||||
uiTaskExecutor.PostTask(
|
||||
[weak = WeakClaim(this)] {
|
||||
auto pattern = weak.Upgrade();
|
||||
CHECK_NULL_VOID(pattern);
|
||||
pattern->CreateAnalyzerOverlay();
|
||||
},
|
||||
"ArkUIXComponentCreateAnalyzerOverlay");
|
||||
}
|
||||
|
||||
void XComponentPattern::StopImageAnalyzer()
|
||||
{
|
||||
DestroyAnalyzerOverlay();
|
||||
}
|
||||
|
||||
bool XComponentPattern::IsSupportImageAnalyzerFeature()
|
||||
{
|
||||
return isEnableAnalyzer_ && imageAnalyzerManager_ && imageAnalyzerManager_->IsSupportImageAnalyzerFeature();
|
||||
}
|
||||
|
||||
void XComponentPattern::CreateAnalyzerOverlay()
|
||||
{
|
||||
auto host = GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
host->SetOverlayNode(nullptr);
|
||||
auto context = host->GetRenderContext();
|
||||
CHECK_NULL_VOID(context);
|
||||
auto pixelMap = context->GetThumbnailPixelMap();
|
||||
CHECK_NULL_VOID(pixelMap);
|
||||
if (IsSupportImageAnalyzerFeature()) {
|
||||
CHECK_NULL_VOID(imageAnalyzerManager_);
|
||||
imageAnalyzerManager_->CreateAnalyzerOverlay(pixelMap);
|
||||
}
|
||||
}
|
||||
|
||||
void XComponentPattern::UpdateAnalyzerOverlay()
|
||||
{
|
||||
auto context = GetHost()->GetRenderContext();
|
||||
CHECK_NULL_VOID(context);
|
||||
auto pixelMap = context->GetThumbnailPixelMap();
|
||||
CHECK_NULL_VOID(pixelMap);
|
||||
CHECK_NULL_VOID(imageAnalyzerManager_);
|
||||
imageAnalyzerManager_->UpdateAnalyzerOverlay(pixelMap);
|
||||
}
|
||||
|
||||
void XComponentPattern::UpdateAnalyzerUIConfig(const RefPtr<NG::GeometryNode>& geometryNode)
|
||||
{
|
||||
if (IsSupportImageAnalyzerFeature()) {
|
||||
CHECK_NULL_VOID(imageAnalyzerManager_);
|
||||
imageAnalyzerManager_->UpdateAnalyzerUIConfig(geometryNode);
|
||||
}
|
||||
}
|
||||
|
||||
void XComponentPattern::DestroyAnalyzerOverlay()
|
||||
{
|
||||
CHECK_NULL_VOID(imageAnalyzerManager_);
|
||||
imageAnalyzerManager_->DestroyAnalyzerOverlay();
|
||||
}
|
||||
|
||||
void XComponentPattern::ReleaseImageAnalyzer()
|
||||
{
|
||||
CHECK_NULL_VOID(imageAnalyzerManager_);
|
||||
imageAnalyzerManager_->ReleaseImageAnalyzer();
|
||||
}
|
||||
|
||||
void XComponentPattern::SetSurfaceRotation(bool isLock)
|
||||
{
|
||||
if (type_ != XComponentType::SURFACE) {
|
||||
|
@ -39,6 +39,10 @@
|
||||
#include "core/components_ng/pattern/xcomponent/xcomponent_layout_property.h"
|
||||
#include "core/components_ng/pattern/xcomponent/xcomponent_paint_method.h"
|
||||
#include "core/components_ng/property/property.h"
|
||||
#ifdef PLATFORM_VIEW_SUPPORTED
|
||||
#include "core/common/platformview/platform_view_interface.h"
|
||||
#include "core/common/platformview/platform_view_proxy.h"
|
||||
#endif
|
||||
#include "core/components_ng/render/render_surface.h"
|
||||
#include "core/pipeline_ng/pipeline_context.h"
|
||||
#include "core/components_ng/manager/display_sync/ui_display_sync.h"
|
||||
@ -62,7 +66,12 @@ public:
|
||||
|
||||
bool IsAtomicNode() const override
|
||||
{
|
||||
#ifdef PLATFORM_VIEW_SUPPORTED
|
||||
return type_ == XComponentType::SURFACE || type_ == XComponentType::TEXTURE ||
|
||||
type_ == XComponentType::NODE || type_ == XComponentType::PLATFORM_VIEW;
|
||||
#else
|
||||
return type_ == XComponentType::SURFACE || type_ == XComponentType::TEXTURE || type_ == XComponentType::NODE;
|
||||
#endif
|
||||
}
|
||||
|
||||
RefPtr<LayoutProperty> CreateLayoutProperty() override
|
||||
@ -294,12 +303,12 @@ public:
|
||||
void SetIdealSurfaceOffsetY(float offsetY);
|
||||
void ClearIdealSurfaceOffset(bool isXAxis);
|
||||
void UpdateSurfaceBounds(bool needForceRender, bool frameOffsetChange = false);
|
||||
RectF AdjustPaintRect(float positionX, float positionY, float width, float height, bool isRound);
|
||||
float RoundValueToPixelGrid(float value, bool isRound, bool forceCeil, bool forceFloor);
|
||||
void EnableAnalyzer(bool enable);
|
||||
void SetImageAIOptions(void* options);
|
||||
void StartImageAnalyzer(void* config, OnAnalyzedCallback& onAnalyzed);
|
||||
void StopImageAnalyzer();
|
||||
RectF AdjustPaintRect(float positionX, float positionY, float width, float height, bool isRound);
|
||||
float RoundValueToPixelGrid(float value, bool isRound, bool forceCeil, bool forceFloor);
|
||||
|
||||
private:
|
||||
void OnAttachToFrameNode() override;
|
||||
@ -344,6 +353,7 @@ private:
|
||||
void AddAfterLayoutTaskForExportTexture();
|
||||
bool DoTextureExport();
|
||||
bool StopTextureExport();
|
||||
void InitializeRenderContext();
|
||||
void SetSurfaceNodeToGraphic();
|
||||
bool IsSupportImageAnalyzerFeature();
|
||||
void CreateAnalyzerOverlay();
|
||||
@ -352,10 +362,20 @@ private:
|
||||
void UpdateAnalyzerUIConfig(const RefPtr<NG::GeometryNode>& geometryNode);
|
||||
void ReleaseImageAnalyzer();
|
||||
void SetRotation(uint32_t rotation);
|
||||
#ifdef OHOS_PLATFORM
|
||||
float GetUpVelocity(OH_NativeXComponent_TouchEvent lastMoveInfo, OH_NativeXComponent_TouchEvent upEventInfo);
|
||||
int GetFlingDuration(float velocity);
|
||||
void ReportSlideToRss();
|
||||
|
||||
#ifdef RENDER_EXTRACT_SUPPORTED
|
||||
RenderSurface::RenderSurfaceType CovertToRenderSurfaceType(const XComponentType& hostType);
|
||||
void RegisterRenderContextCallBack();
|
||||
void RequestFocus();
|
||||
#ifdef PLATFORM_VIEW_SUPPORTED
|
||||
void PlatformViewInitialize();
|
||||
void* GetNativeWindow(int32_t instanceId, int64_t textureId);
|
||||
void OnTextureRefresh(void* surface);
|
||||
void PrepareSurface();
|
||||
void RegisterPlatformViewEvent();
|
||||
void PlatformViewDispatchTouchEvent(const TouchLocationInfo& changedPoint);
|
||||
void UpdatePlatformViewLayoutIfNeeded();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
std::vector<OH_NativeXComponent_HistoricalPoint> SetHistoryPoint(const std::list<TouchLocationInfo>& touchInfoList);
|
||||
@ -369,6 +389,14 @@ private:
|
||||
RefPtr<RenderContext> renderContextForSurface_;
|
||||
RefPtr<RenderContext> handlingSurfaceRenderContext_;
|
||||
WeakPtr<XComponentPattern> extPattern_;
|
||||
#if defined(RENDER_EXTRACT_SUPPORTED) && defined(PLATFORM_VIEW_SUPPORTED)
|
||||
WeakPtr<RenderSurface> renderSurfaceWeakPtr_;
|
||||
RefPtr<RenderContext> renderContextForPlatformView_;
|
||||
WeakPtr<RenderContext> renderContextForPlatformViewWeakPtr_;
|
||||
RefPtr<PlatformViewInterface> platformView_;
|
||||
SizeF lastDrawSize_;
|
||||
OffsetF lastOffset_;
|
||||
#endif
|
||||
|
||||
std::shared_ptr<OH_NativeXComponent> nativeXComponent_;
|
||||
RefPtr<NativeXComponentImpl> nativeXComponentImpl_;
|
||||
@ -405,12 +433,6 @@ private:
|
||||
bool isEnableAnalyzer_ = false;
|
||||
std::optional<int32_t> transformHintChangedCallbackId_;
|
||||
uint32_t rotation_ = 0;
|
||||
#ifdef OHOS_PLATFORM
|
||||
int64_t startIncreaseTime_ = 0;
|
||||
OH_NativeXComponent_TouchEvent lastTouchInfo_ {};
|
||||
int32_t slideCount_ = 0;
|
||||
double physicalCoeff_ = 0.0;
|
||||
#endif
|
||||
};
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
||||
|
@ -308,4 +308,4 @@ void MediaPlayerImpl::ProcessTextureRefresh(int32_t instanceId, int64_t textureI
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace OHOS::Ace::NG
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "base/utils/utils.h"
|
||||
#include "core/common/container.h"
|
||||
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
|
||||
RenderSurfaceImpl::~RenderSurfaceImpl()
|
||||
@ -62,13 +63,20 @@ void RenderSurfaceImpl::InitSurface()
|
||||
CHECK_NULL_VOID(callback);
|
||||
callback->ProcessSurfaceChange(width, height);
|
||||
});
|
||||
extSurface_->SetSurfaceDestroyed([weak = WeakClaim(this)]() {
|
||||
auto surfaceImpl = weak.Upgrade();
|
||||
CHECK_NULL_VOID(surfaceImpl);
|
||||
auto callback = surfaceImpl->extSurfaceCallback_;
|
||||
CHECK_NULL_VOID(callback);
|
||||
callback->ProcessSurfaceDestroy();
|
||||
});
|
||||
}
|
||||
|
||||
void RenderSurfaceImpl::UpdateSurfaceConfig() {}
|
||||
|
||||
void* RenderSurfaceImpl::GetNativeWindow()
|
||||
{
|
||||
return nullptr;
|
||||
return nativeWindow_;
|
||||
}
|
||||
|
||||
void RenderSurfaceImpl::SetRenderContext(const RefPtr<RenderContext>& renderContext)
|
||||
@ -76,14 +84,34 @@ void RenderSurfaceImpl::SetRenderContext(const RefPtr<RenderContext>& renderCont
|
||||
renderContext_ = WeakClaim(RawPtr(renderContext));
|
||||
}
|
||||
|
||||
void RenderSurfaceImpl::ConfigSurface(uint32_t surfaceWidth, uint32_t surfaceHeight) {}
|
||||
void RenderSurfaceImpl::ConfigSurface(uint32_t surfaceWidth, uint32_t surfaceHeight)
|
||||
{
|
||||
if (!extSurface_) {
|
||||
return;
|
||||
}
|
||||
isSetConfigSurface_ = true;
|
||||
|
||||
double x = (lastRect_.Width() - surfaceWidth) / 2 + lastRect_.Left();
|
||||
double y = (lastRect_.Height() - surfaceHeight) / 2 + lastRect_.Top();
|
||||
|
||||
extSurface_->SetBounds(surfaceId_, x, y, surfaceWidth, surfaceHeight);
|
||||
|
||||
lastRect_.SetHeight(surfaceHeight);
|
||||
lastRect_.SetWidth(surfaceWidth);
|
||||
}
|
||||
|
||||
bool RenderSurfaceImpl::IsSurfaceValid() const
|
||||
{
|
||||
return extSurface_ != nullptr;
|
||||
}
|
||||
|
||||
void RenderSurfaceImpl::CreateNativeWindow() {}
|
||||
void RenderSurfaceImpl::CreateNativeWindow()
|
||||
{
|
||||
if (extSurface_) {
|
||||
LOGI("RenderSurfaceImpl::CreateNativeWindow called");
|
||||
nativeWindow_ = extSurface_->AttachNativeWindow();
|
||||
}
|
||||
}
|
||||
|
||||
void RenderSurfaceImpl::AdjustNativeWindowSize(uint32_t width, uint32_t height) {}
|
||||
|
||||
|
@ -73,6 +73,7 @@ private:
|
||||
RefPtr<ExtSurface> extSurface_;
|
||||
RefPtr<ExtSurfaceCallbackInterface> extSurfaceCallback_;
|
||||
int64_t surfaceId_ = -1;
|
||||
void* nativeWindow_ = nullptr;
|
||||
bool isSetConfigSurface_ = false;
|
||||
Rect lastRect_;
|
||||
|
||||
|
@ -38,7 +38,7 @@ const uint32_t ADJUST_WEB_DRAW_LENGTH = 3000;
|
||||
const uint32_t DEFAULT_WEB_DRAW_LENGTH = 6167;
|
||||
const std::string SURFACE_WIDTH = "surface_width";
|
||||
const std::string SURFACE_HEIGHT = "surface_height";
|
||||
const int32_t SIZE_LIMIT = 7999;
|
||||
const int32_t SIZE_LIMIT = 5999;
|
||||
const int32_t PERMITTED_DIFFERENCE = 100;
|
||||
const int32_t FAILED_LIMIT = 3;
|
||||
|
||||
@ -317,6 +317,8 @@ bool RosenRenderSurface::CompareBufferSize(int32_t width, int32_t height,
|
||||
failTimes_++;
|
||||
if (failTimes_ <= FAILED_LIMIT) {
|
||||
pipeline->SetIsFreezeFlushMessage(true);
|
||||
ACE_SCOPED_TRACE("Web SetIsFreezeFlushMessage (width %d, height %d, bufferWidth %d, bufferHeight %d)",
|
||||
width, height, bufferWidth, bufferHeight);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -33,8 +33,21 @@ class ACE_FORCE_EXPORT RenderSurface : public virtual AceType {
|
||||
public:
|
||||
RenderSurface() = default;
|
||||
~RenderSurface() override = default;
|
||||
|
||||
|
||||
// under the condition of supporting cross platform and texture rendering,
|
||||
// it is necessary to dynamically set the rendering type of the surface node.
|
||||
// the defalut type is RenderSurfaceType::TEXTURE.
|
||||
#ifdef RENDER_EXTRACT_SUPPORTED
|
||||
enum class RenderSurfaceType {
|
||||
UNKNOWN = -1,
|
||||
SURFACE = 0,
|
||||
TEXTURE
|
||||
};
|
||||
static RefPtr<RenderSurface> Create(const RenderSurfaceType& type = RenderSurfaceType::TEXTURE);
|
||||
#else
|
||||
// under the condition of supporting ohos platform
|
||||
static RefPtr<RenderSurface> Create();
|
||||
#endif
|
||||
|
||||
virtual void InitSurface() {}
|
||||
|
||||
@ -86,6 +99,15 @@ public:
|
||||
|
||||
virtual void SetSurfaceDefaultSize(int32_t width, int32_t height) {}
|
||||
|
||||
virtual bool IsTexture()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void AttachToGLContext(int64_t textureId, bool isAttach) {}
|
||||
|
||||
virtual void UpdateTextureImage(std::vector<float>& matrix) {}
|
||||
|
||||
virtual void SetWebMessage(OffsetF offset) {}
|
||||
|
||||
virtual void SetWebSlideAxis(Axis axis) {}
|
||||
|
@ -16,19 +16,39 @@
|
||||
#if defined(ENABLE_ROSEN_BACKEND) && defined(OHOS_PLATFORM)
|
||||
#include "core/components_ng/render/adapter/rosen_render_surface.h"
|
||||
#endif
|
||||
#ifdef RENDER_EXTRACT_SUPPORTED
|
||||
#include "core/components_ng/render/adapter/render_texture_impl.h"
|
||||
#endif
|
||||
#include "core/components_ng/render/adapter/render_surface_impl.h"
|
||||
#include "core/components_ng/render/render_surface.h"
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
// under the condition of supporting cross platform and texture rendering
|
||||
#ifdef RENDER_EXTRACT_SUPPORTED
|
||||
RefPtr<RenderSurface> RenderSurface::Create(const RenderSurfaceTpye& type)
|
||||
{
|
||||
if (SystemProperties::GetRosenBackendEnabled()) {
|
||||
switch (type) {
|
||||
case RenderSurfaceTpye::SURFACE:
|
||||
return MakeRefPtr<RenderSurfaceImpl>();
|
||||
case RenderSurfaceTpye::TEXTURE:
|
||||
return MakeRefPtr<RenderTextureImpl>();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return MakeRefPtr<RenderSurface>();
|
||||
}
|
||||
#else
|
||||
// under the condition of supporting ohos platform
|
||||
RefPtr<RenderSurface> RenderSurface::Create()
|
||||
{
|
||||
if (SystemProperties::GetRosenBackendEnabled()) {
|
||||
#if defined(OHOS_PLATFORM) && defined(ENABLE_ROSEN_BACKEND)
|
||||
return MakeRefPtr<RosenRenderSurface>();
|
||||
#else
|
||||
return MakeRefPtr<RenderSurfaceImpl>();
|
||||
#endif
|
||||
}
|
||||
return MakeRefPtr<RenderSurface>();
|
||||
}
|
||||
#endif
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
@ -29,9 +29,10 @@ std::string g_strValue;
|
||||
|
||||
void SetXComponentBackgroundColor(ArkUINodeHandle node, uint32_t color)
|
||||
{
|
||||
auto *frameNode = reinterpret_cast<FrameNode *>(node);
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
if (!XComponentModelNG::IsTexture(frameNode)) {
|
||||
auto type = XComponentModelNG::GetType(frameNode);
|
||||
if (!XComponentModel::IsBackGroundColorAvailable(type)) {
|
||||
return;
|
||||
}
|
||||
ViewAbstract::SetBackgroundColor(frameNode, Color(color));
|
||||
@ -39,12 +40,13 @@ void SetXComponentBackgroundColor(ArkUINodeHandle node, uint32_t color)
|
||||
|
||||
void ResetXComponentBackgroundColor(ArkUINodeHandle node)
|
||||
{
|
||||
auto *frameNode = reinterpret_cast<FrameNode *>(node);
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
if (!XComponentModelNG::IsTexture(frameNode)) {
|
||||
auto type = XComponentModelNG::GetType(frameNode);
|
||||
if (!XComponentModel::IsBackGroundColorAvailable(type)) {
|
||||
return;
|
||||
}
|
||||
ViewAbstract::SetBackgroundColor(frameNode, Color(Color::TRANSPARENT));
|
||||
ViewAbstract::SetBackgroundColor(frameNode, (type == XComponentType::SURFACE) ? Color::BLACK : Color::TRANSPARENT);
|
||||
}
|
||||
|
||||
void SetXComponentOpacity(ArkUINodeHandle node, ArkUI_Float32 opacity)
|
||||
|
@ -58,6 +58,7 @@ ohos_shared_library("ace_xcomponent_controller") {
|
||||
"napi:ace_napi",
|
||||
]
|
||||
public_external_deps = [ "hilog:libhilog" ]
|
||||
|
||||
subsystem_name = ace_engine_subsystem
|
||||
innerapi_tags = [ "platformsdk_indirect" ]
|
||||
part_name = ace_engine_part
|
||||
|
@ -284,6 +284,24 @@ int32_t OH_NativeXComponent_DetachNativeRootNode(
|
||||
return component->DetachNativeRootNode(root->uiNodeHandle);
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_RegisterUIInputEventCallback(OH_NativeXComponent* component,
|
||||
void (*callback)(OH_NativeXComponent* component, ArkUI_UIInputEvent* event, ArkUI_UIInputEvent_Type type),
|
||||
ArkUI_UIInputEvent_Type type)
|
||||
{
|
||||
if ((component == nullptr) || (callback == nullptr)) {
|
||||
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
if (type == ArkUI_UIInputEvent_Type::ARKUI_UIINPUTEVENT_TYPE_AXIS) {
|
||||
return component->RegisterUIAxisEventCallback(callback);
|
||||
}
|
||||
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_SetNeedSoftKeyboard(OH_NativeXComponent* component, bool needSoftKeyboard)
|
||||
{
|
||||
return component ? component->SetNeedSoftKeyboard(needSoftKeyboard) : OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_RegisterSurfaceShowCallback(
|
||||
OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window))
|
||||
{
|
||||
@ -298,19 +316,6 @@ int32_t OH_NativeXComponent_RegisterSurfaceHideCallback(
|
||||
: OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_RegisterUIInputEventCallback(OH_NativeXComponent* component,
|
||||
void (*callback)(OH_NativeXComponent* component, ArkUI_UIInputEvent* event, ArkUI_UIInputEvent_Type type),
|
||||
ArkUI_UIInputEvent_Type type)
|
||||
{
|
||||
if ((component == nullptr) || (callback == nullptr)) {
|
||||
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
if (type == ArkUI_UIInputEvent_Type::ARKUI_UIINPUTEVENT_TYPE_AXIS) {
|
||||
return component->RegisterUIAxisEventCallback(callback);
|
||||
}
|
||||
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_RegisterOnTouchInterceptCallback(
|
||||
OH_NativeXComponent* component, HitTestMode (*callback)(OH_NativeXComponent* component, ArkUI_UIInputEvent* event))
|
||||
{
|
||||
@ -320,11 +325,6 @@ int32_t OH_NativeXComponent_RegisterOnTouchInterceptCallback(
|
||||
return component->RegisterOnTouchInterceptCallback(callback);
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_SetNeedSoftKeyboard(OH_NativeXComponent* component, bool needSoftKeyboard)
|
||||
{
|
||||
return component ? component->SetNeedSoftKeyboard(needSoftKeyboard) : OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_GetTouchEventSourceType(
|
||||
OH_NativeXComponent* component, int32_t pointId, OH_NativeXComponent_EventSourceType* sourceType)
|
||||
{
|
||||
|
@ -715,6 +715,32 @@ int32_t OH_NativeXComponent_AttachNativeRootNode(OH_NativeXComponent* component,
|
||||
*/
|
||||
int32_t OH_NativeXComponent_DetachNativeRootNode(OH_NativeXComponent* component, ArkUI_NodeHandle root);
|
||||
|
||||
/**
|
||||
* @brief Registers a UI input event callback for this <b>OH_NativeXComponent</b> instance and enables the callback to
|
||||
* be invoked when a UI input event is received.
|
||||
*
|
||||
* @param component Indicates the pointer to the <b>OH_NativeXComponent</b> instance.
|
||||
* @param callback Indicates the pointer to the UI input event callback.
|
||||
* @param type Indicates the type of the current UI input event.
|
||||
* @return Returns 0 if success.
|
||||
* Returns 401 if a parameter exception occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_NativeXComponent_RegisterUIInputEventCallback(OH_NativeXComponent* component,
|
||||
void (*callback)(OH_NativeXComponent* component, ArkUI_UIInputEvent* event, ArkUI_UIInputEvent_Type type),
|
||||
ArkUI_UIInputEvent_Type type);
|
||||
|
||||
/**
|
||||
* @brief Set whether the <b>OH_NativeXComponent</b> instance needs soft keyboard.
|
||||
* @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance.
|
||||
* @param needSoftKeyboard Indicates whether the <b>OH_NativeXComponent</b> instance needs soft keyboard or not.
|
||||
* Default value is false.
|
||||
* @return Returns the status code of the execution.
|
||||
* @since 12
|
||||
* @version 1.0
|
||||
*/
|
||||
int32_t OH_NativeXComponent_SetNeedSoftKeyboard(OH_NativeXComponent* component, bool needSoftKeyboard);
|
||||
|
||||
/**
|
||||
* @brief Registers a callback for this <b>OH_NativeXComponent</b> instance.
|
||||
*
|
||||
@ -739,21 +765,6 @@ int32_t OH_NativeXComponent_RegisterSurfaceShowCallback(
|
||||
int32_t OH_NativeXComponent_RegisterSurfaceHideCallback(
|
||||
OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window));
|
||||
|
||||
/**
|
||||
* @brief Registers a UI input event callback for this <b>OH_NativeXComponent</b> instance and enables the callback to
|
||||
* be invoked when a UI input event is received.
|
||||
*
|
||||
* @param component Indicates the pointer to the <b>OH_NativeXComponent</b> instance.
|
||||
* @param callback Indicates the pointer to the UI input event callback.
|
||||
* @param type Indicates the type of the current UI input event.
|
||||
* @return Returns 0 if success.
|
||||
* Returns 401 if a parameter exception occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_NativeXComponent_RegisterUIInputEventCallback(OH_NativeXComponent* component,
|
||||
void (*callback)(OH_NativeXComponent* component, ArkUI_UIInputEvent* event, ArkUI_UIInputEvent_Type type),
|
||||
ArkUI_UIInputEvent_Type type);
|
||||
|
||||
/**
|
||||
* @brief Registers a callback for this <b>OH_NativeXComponent</b> instance.
|
||||
*
|
||||
@ -766,17 +777,6 @@ int32_t OH_NativeXComponent_RegisterUIInputEventCallback(OH_NativeXComponent* co
|
||||
int32_t OH_NativeXComponent_RegisterOnTouchInterceptCallback(
|
||||
OH_NativeXComponent* component, HitTestMode (*callback)(OH_NativeXComponent* component, ArkUI_UIInputEvent* event));
|
||||
|
||||
/**
|
||||
* @brief Set whether the <b>OH_NativeXComponent</b> instance needs soft keyboard.
|
||||
* @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance.
|
||||
* @param needSoftKeyboard Indicates whether the <b>OH_NativeXComponent</b> instance needs soft keyboard or not.
|
||||
* Default value is false.
|
||||
* @return Returns the status code of the execution.
|
||||
* @since 12
|
||||
* @version 1.0
|
||||
*/
|
||||
int32_t OH_NativeXComponent_SetNeedSoftKeyboard(OH_NativeXComponent* component, bool needSoftKeyboard);
|
||||
|
||||
/**
|
||||
* @brief Obtains the touch event's source type dispatched by the ArkUI XComponent.
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
@ -27,9 +27,9 @@ public:
|
||||
~MockRenderSurface() override = default;
|
||||
MOCK_CONST_METHOD0(IsSurfaceValid, bool());
|
||||
MOCK_METHOD2(AdjustNativeWindowSize, void(uint32_t, uint32_t));
|
||||
MOCK_METHOD0(ReleaseSurfaceBuffers, void());
|
||||
MOCK_METHOD2(ConfigSurface, void(uint32_t, uint32_t));
|
||||
MOCK_METHOD4(SetExtSurfaceBounds, void(int32_t, int32_t, int32_t, int32_t));
|
||||
MOCK_METHOD0(ReleaseSurfaceBuffers, void());
|
||||
};
|
||||
} // namespace OHOS::Ace::NG
|
||||
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_RENDER_SURFACE_H
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2024-2025 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2024-2025 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
@ -20,10 +20,11 @@ namespace OHOS::Ace {
|
||||
void RelativeContainerTestUtilsNG::AddAlignRule(const std::string& id, const AlignDirection& direction,
|
||||
const HorizontalAlign& horizontalRule, std::map<AlignDirection, AlignRule>& alignRules)
|
||||
{
|
||||
auto alignDirection = AlignDirectionRtl(direction);
|
||||
AlignRule alignRule;
|
||||
alignRule.anchor = id;
|
||||
alignRule.horizontal = horizontalRule;
|
||||
alignRules[direction] = alignRule;
|
||||
alignRules[alignDirection] = alignRule;
|
||||
}
|
||||
|
||||
void RelativeContainerTestUtilsNG::AddAlignRule(const std::string& id, const AlignDirection& direction,
|
||||
@ -34,4 +35,15 @@ void RelativeContainerTestUtilsNG::AddAlignRule(const std::string& id, const Ali
|
||||
alignRule.vertical = verticalRule;
|
||||
alignRules[direction] = alignRule;
|
||||
}
|
||||
|
||||
AlignDirection RelativeContainerTestUtilsNG::AlignDirectionRtl(const AlignDirection& direction)
|
||||
{
|
||||
if (direction == AlignDirection::START) {
|
||||
return AlignDirection::LEFT;
|
||||
} else if (direction == AlignDirection::END) {
|
||||
return AlignDirection::RIGHT;
|
||||
} else {
|
||||
return direction;
|
||||
}
|
||||
}
|
||||
} // namespace OHOS::Ace
|
@ -28,6 +28,7 @@ public:
|
||||
const HorizontalAlign& horizontalRule, std::map<AlignDirection, AlignRule>& alignRules);
|
||||
static void AddAlignRule(const std::string& id, const AlignDirection& direction, const VerticalAlign& verticalRule,
|
||||
std::map<AlignDirection, AlignRule>& alignRules);
|
||||
static AlignDirection AlignDirectionRtl(const AlignDirection& direction);
|
||||
};
|
||||
} // namespace OHOS::Ace
|
||||
|
||||
|
@ -82,11 +82,11 @@ const float CHILD_OFFSET_HEIGHT = 0.0f;
|
||||
const float FORCE = 3.0f;
|
||||
TestProperty testProperty;
|
||||
bool isFocus = false;
|
||||
int g_surfaceShowNum = 1;
|
||||
const float SURFACE_WIDTH = 250.0f;
|
||||
const float SURFACE_HEIGHT = 150.0f;
|
||||
const float SURFACE_OFFSETX = 10.0f;
|
||||
const float SURFACE_OFFSETY = 20.0f;
|
||||
int g_surfaceShowNum = 1;
|
||||
bool isAxis = false;
|
||||
bool isLock = true;
|
||||
|
||||
@ -588,135 +588,6 @@ HWTEST_F(XComponentTestNg, XComponentTextureTypeTest011, TestSize.Level1)
|
||||
pattern->InitNativeWindow(MAX_WIDTH, MAX_HEIGHT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: XComponentControllerTest
|
||||
* @tc.desc: Test XComponentController's interface
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(XComponentTestNg, XComponentControllerTest, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. set type = XCOMPONENT_SURFACE_TYPE_VALUE and call CreateXComponentNode
|
||||
* @tc.expected: xcomponent frameNode create successfully
|
||||
*/
|
||||
testProperty.xcType = XCOMPONENT_SURFACE_TYPE_VALUE;
|
||||
auto frameNode = CreateXComponentNode(testProperty);
|
||||
EXPECT_TRUE(frameNode);
|
||||
EXPECT_EQ(frameNode->GetTag(), V2::XCOMPONENT_ETS_TAG);
|
||||
auto pattern = frameNode->GetPattern<XComponentPattern>();
|
||||
ASSERT_TRUE(pattern);
|
||||
pattern->hasXComponentInit_ = true;
|
||||
EXPECT_EQ(pattern->type_, XCOMPONENT_SURFACE_TYPE_VALUE);
|
||||
EXPECT_TRUE(pattern->IsAtomicNode());
|
||||
auto renderContext = AceType::MakeRefPtr<MockRenderContext>();
|
||||
pattern->handlingSurfaceRenderContext_ = renderContext;
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. call XcomponentController's interface releative to SetSurfaceRect
|
||||
* @tc.expected: handlingSurfaceRenderContext_->SetBounds(SURFACE_OFFSETX, SURFACE_OFFSETY,
|
||||
* SURFACE_WIDTH, SURFACE_HEIGHT) is called
|
||||
*/
|
||||
auto xcomponentController = pattern->xcomponentController_;
|
||||
EXPECT_TRUE(xcomponentController);
|
||||
pattern->drawSize_ = MAX_SIZE;
|
||||
xcomponentController->SetIdealSurfaceWidth(SURFACE_WIDTH);
|
||||
xcomponentController->SetIdealSurfaceHeight(SURFACE_HEIGHT);
|
||||
xcomponentController->SetIdealSurfaceOffsetX(SURFACE_OFFSETX);
|
||||
xcomponentController->SetIdealSurfaceOffsetY(SURFACE_OFFSETY);
|
||||
EXPECT_CALL(*AceType::DynamicCast<MockRenderContext>(pattern->handlingSurfaceRenderContext_),
|
||||
SetBounds(SURFACE_OFFSETX, SURFACE_OFFSETY, SURFACE_WIDTH, SURFACE_HEIGHT))
|
||||
.WillOnce(Return());
|
||||
xcomponentController->UpdateSurfaceBounds();
|
||||
|
||||
/**
|
||||
* @tc.steps: step3. call XcomponentController's interface releative to GetSurfaceRect
|
||||
* @tc.expected: the rect get from GetSurfaceRect equals the rect set by SetSurfaceRect
|
||||
*/
|
||||
auto surfaceWidth = 0.0f;
|
||||
auto surfaceHeight = 0.0f;
|
||||
auto surfaceOffsetX = 0.0f;
|
||||
auto surfaceOffsetY = 0.0f;
|
||||
xcomponentController->GetSurfaceSize(surfaceWidth, surfaceHeight);
|
||||
xcomponentController->GetLocalLocation(surfaceOffsetX, surfaceOffsetY);
|
||||
EXPECT_EQ(surfaceOffsetX, SURFACE_OFFSETX);
|
||||
EXPECT_EQ(surfaceOffsetY, SURFACE_OFFSETY);
|
||||
EXPECT_EQ(surfaceWidth, SURFACE_WIDTH);
|
||||
EXPECT_EQ(surfaceHeight, SURFACE_HEIGHT);
|
||||
|
||||
/**
|
||||
* @tc.steps: step4. call XcomponentController's ClearIdealSurfaceOffset
|
||||
* @tc.expected: handlingSurfaceRenderContext_->SetBounds(newSurfaceOffsetX, newSurfaceOffsetY,
|
||||
* SURFACE_WIDTH, SURFACE_HEIGHT) is called
|
||||
*/
|
||||
auto newSurfaceOffsetX = (MAX_WIDTH - SURFACE_WIDTH) / 2.0f;
|
||||
auto newSurfaceOffsetY = (MAX_HEIGHT - SURFACE_HEIGHT) / 2.0f;
|
||||
xcomponentController->ClearIdealSurfaceOffset(true);
|
||||
xcomponentController->ClearIdealSurfaceOffset(false);
|
||||
EXPECT_CALL(*AceType::DynamicCast<MockRenderContext>(pattern->handlingSurfaceRenderContext_),
|
||||
SetBounds(newSurfaceOffsetX, newSurfaceOffsetY, SURFACE_WIDTH, SURFACE_HEIGHT))
|
||||
.WillOnce(Return());
|
||||
xcomponentController->UpdateSurfaceBounds();
|
||||
|
||||
/**
|
||||
* @tc.steps: step5. call XcomponentController's interface relative to SetSurfaceRotation
|
||||
* @tc.expected: handlingSurfaceRenderContext_->SetSurfaceRotation(isLock) is called
|
||||
*/
|
||||
EXPECT_CALL(
|
||||
*AceType::DynamicCast<MockRenderContext>(pattern->handlingSurfaceRenderContext_), SetSurfaceRotation(isLock))
|
||||
.WillOnce(Return());
|
||||
xcomponentController->SetSurfaceRotation(isLock);
|
||||
|
||||
/**
|
||||
* @tc.steps: step6. call XcomponentController's interface relative to GetSurfaceRotation
|
||||
* @tc.expected: the lock status get from GetSurfaceRotation equals the lock status set by SetSurfaceRotation
|
||||
*/
|
||||
auto lock = xcomponentController->GetSurfaceRotation();
|
||||
EXPECT_EQ(lock, isLock);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: XComponentAxisEventTest012
|
||||
* @tc.desc: Test AxisEvent
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(XComponentTestNg, XComponentAxisEventTest012, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. set type = XCOMPONENT_SURFACE_TYPE and call CreateXComponentNode
|
||||
* @tc.expected: xcomponent frameNode create successfully
|
||||
*/
|
||||
testProperty.xcType = XCOMPONENT_SURFACE_TYPE_VALUE;
|
||||
auto frameNode = CreateXComponentNode(testProperty);
|
||||
ASSERT_TRUE(frameNode);
|
||||
auto pattern = frameNode->GetPattern<XComponentPattern>();
|
||||
ASSERT_TRUE(pattern);
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. create nativeXComponent instance
|
||||
* @tc.expected: focusHub & nativeXComponent instance create successfully
|
||||
*/
|
||||
auto pair = pattern->GetNativeXComponent();
|
||||
auto weakNativeXComponent = pair.second;
|
||||
auto nativeXComponent = weakNativeXComponent.lock();
|
||||
auto nativeXComponentImpl = pair.first;
|
||||
ASSERT_TRUE(nativeXComponent);
|
||||
ASSERT_TRUE(nativeXComponentImpl);
|
||||
|
||||
/**
|
||||
* @tc.steps: step3. register axis event for nativeXComponent instance
|
||||
*/
|
||||
auto callback = [](OH_NativeXComponent* /* nativeXComponent */, ArkUI_UIInputEvent* event,
|
||||
ArkUI_UIInputEvent_Type type) { isAxis = true; };
|
||||
nativeXComponent->RegisterUIAxisEventCallback(callback);
|
||||
|
||||
/**
|
||||
* @tc.steps: step4. call HandleAxisEvent
|
||||
*/
|
||||
AxisInfo event;
|
||||
pattern->HandleAxisEvent(event);
|
||||
EXPECT_TRUE(isAxis);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: XComponentOnAreaChangedInnerTest019
|
||||
* @tc.desc: Test XComponent OnAreaChangedInner.
|
||||
@ -1000,6 +871,7 @@ HWTEST_F(XComponentTestNg, XComponentDetachCallbackTest024, TestSize.Level1)
|
||||
xComponentEventHub->FireDetachEvent(XCOMPONENT_ID);
|
||||
EXPECT_FALSE(onDetachKey == CHECK_KEY);
|
||||
|
||||
|
||||
onDetachKey.clear();
|
||||
XComponentModelNG::SetXComponentType(Referenced::RawPtr(frameNode), XCOMPONENT_COMPONENT_TYPE_VALUE);
|
||||
xComponent.SetDetachCallback(std::move(onDetach));
|
||||
@ -1174,6 +1046,7 @@ HWTEST_F(XComponentTestNg, XComponentSurfaceTest, TestSize.Level1)
|
||||
ASSERT_TRUE(nativeXComponentImpl);
|
||||
pattern->hasXComponentInit_ = true;
|
||||
|
||||
|
||||
/**
|
||||
* @tc.steps: step3. call surfaceHide and surfaceShow event without register callbacks
|
||||
* @tc.expected: no error happens and g_surfaceShowNum remains the same
|
||||
@ -1222,6 +1095,135 @@ HWTEST_F(XComponentTestNg, XComponentSurfaceTest, TestSize.Level1)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: XComponentControllerTest
|
||||
* @tc.desc: Test XComponentController's interface
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(XComponentTestNg, XComponentControllerTest, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. set type = XCOMPONENT_SURFACE_TYPE_VALUE and call CreateXComponentNode
|
||||
* @tc.expected: xcomponent frameNode create successfully
|
||||
*/
|
||||
testProperty.xcType = XCOMPONENT_SURFACE_TYPE_VALUE;
|
||||
auto frameNode = CreateXComponentNode(testProperty);
|
||||
EXPECT_TRUE(frameNode);
|
||||
EXPECT_EQ(frameNode->GetTag(), V2::XCOMPONENT_ETS_TAG);
|
||||
auto pattern = frameNode->GetPattern<XComponentPattern>();
|
||||
ASSERT_TRUE(pattern);
|
||||
pattern->hasXComponentInit_ = true;
|
||||
EXPECT_EQ(pattern->type_, XCOMPONENT_SURFACE_TYPE_VALUE);
|
||||
EXPECT_TRUE(pattern->IsAtomicNode());
|
||||
auto renderContext = AceType::MakeRefPtr<MockRenderContext>();
|
||||
pattern->handlingSurfaceRenderContext_ = renderContext;
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. call XcomponentController's interface releative to SetSurfaceRect
|
||||
* @tc.expected: handlingSurfaceRenderContext_->SetBounds(SURFACE_OFFSETX, SURFACE_OFFSETY,
|
||||
* SURFACE_WIDTH, SURFACE_HEIGHT) is called
|
||||
*/
|
||||
auto xcomponentController = pattern->xcomponentController_;
|
||||
EXPECT_TRUE(xcomponentController);
|
||||
pattern->drawSize_ = MAX_SIZE;
|
||||
xcomponentController->SetIdealSurfaceWidth(SURFACE_WIDTH);
|
||||
xcomponentController->SetIdealSurfaceHeight(SURFACE_HEIGHT);
|
||||
xcomponentController->SetIdealSurfaceOffsetX(SURFACE_OFFSETX);
|
||||
xcomponentController->SetIdealSurfaceOffsetY(SURFACE_OFFSETY);
|
||||
EXPECT_CALL(*AceType::DynamicCast<MockRenderContext>(pattern->handlingSurfaceRenderContext_),
|
||||
SetBounds(SURFACE_OFFSETX, SURFACE_OFFSETY, SURFACE_WIDTH, SURFACE_HEIGHT))
|
||||
.WillOnce(Return());
|
||||
xcomponentController->UpdateSurfaceBounds();
|
||||
|
||||
/**
|
||||
* @tc.steps: step3. call XcomponentController's interface releative to GetSurfaceRect
|
||||
* @tc.expected: the rect get from GetSurfaceRect equals the rect set by SetSurfaceRect
|
||||
*/
|
||||
auto surfaceWidth = 0.0f;
|
||||
auto surfaceHeight = 0.0f;
|
||||
auto surfaceOffsetX = 0.0f;
|
||||
auto surfaceOffsetY = 0.0f;
|
||||
xcomponentController->GetSurfaceSize(surfaceWidth, surfaceHeight);
|
||||
xcomponentController->GetLocalLocation(surfaceOffsetX, surfaceOffsetY);
|
||||
EXPECT_EQ(surfaceOffsetX, SURFACE_OFFSETX);
|
||||
EXPECT_EQ(surfaceOffsetY, SURFACE_OFFSETY);
|
||||
EXPECT_EQ(surfaceWidth, SURFACE_WIDTH);
|
||||
EXPECT_EQ(surfaceHeight, SURFACE_HEIGHT);
|
||||
|
||||
/**
|
||||
* @tc.steps: step4. call XcomponentController's ClearIdealSurfaceOffset
|
||||
* @tc.expected: handlingSurfaceRenderContext_->SetBounds(newSurfaceOffsetX, newSurfaceOffsetY,
|
||||
* SURFACE_WIDTH, SURFACE_HEIGHT) is called
|
||||
*/
|
||||
auto newSurfaceOffsetX = (MAX_WIDTH - SURFACE_WIDTH) / 2.0f;
|
||||
auto newSurfaceOffsetY = (MAX_HEIGHT - SURFACE_HEIGHT) / 2.0f;
|
||||
xcomponentController->ClearIdealSurfaceOffset(true);
|
||||
xcomponentController->ClearIdealSurfaceOffset(false);
|
||||
EXPECT_CALL(*AceType::DynamicCast<MockRenderContext>(pattern->handlingSurfaceRenderContext_),
|
||||
SetBounds(newSurfaceOffsetX, newSurfaceOffsetY, SURFACE_WIDTH, SURFACE_HEIGHT))
|
||||
.WillOnce(Return());
|
||||
xcomponentController->UpdateSurfaceBounds();
|
||||
|
||||
/**
|
||||
* @tc.steps: step5. call XcomponentController's interface relative to SetSurfaceRotation
|
||||
* @tc.expected: handlingSurfaceRenderContext_->SetSurfaceRotation(isLock) is called
|
||||
*/
|
||||
EXPECT_CALL(
|
||||
*AceType::DynamicCast<MockRenderContext>(pattern->handlingSurfaceRenderContext_), SetSurfaceRotation(isLock))
|
||||
.WillOnce(Return());
|
||||
xcomponentController->SetSurfaceRotation(isLock);
|
||||
|
||||
/**
|
||||
* @tc.steps: step6. call XcomponentController's interface relative to GetSurfaceRotation
|
||||
* @tc.expected: the lock status get from GetSurfaceRotation equals the lock status set by SetSurfaceRotation
|
||||
*/
|
||||
auto lock = xcomponentController->GetSurfaceRotation();
|
||||
EXPECT_EQ(lock, isLock);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: XComponentAxisEventTest012
|
||||
* @tc.desc: Test AxisEvent
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(XComponentTestNg, XComponentAxisEventTest012, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. set type = XCOMPONENT_SURFACE_TYPE and call CreateXComponentNode
|
||||
* @tc.expected: xcomponent frameNode create successfully
|
||||
*/
|
||||
testProperty.xcType = XCOMPONENT_SURFACE_TYPE_VALUE;
|
||||
auto frameNode = CreateXComponentNode(testProperty);
|
||||
ASSERT_TRUE(frameNode);
|
||||
auto pattern = frameNode->GetPattern<XComponentPattern>();
|
||||
ASSERT_TRUE(pattern);
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. create nativeXComponent instance
|
||||
* @tc.expected: focusHub & nativeXComponent instance create successfully
|
||||
*/
|
||||
auto pair = pattern->GetNativeXComponent();
|
||||
auto weakNativeXComponent = pair.second;
|
||||
auto nativeXComponent = weakNativeXComponent.lock();
|
||||
auto nativeXComponentImpl = pair.first;
|
||||
ASSERT_TRUE(nativeXComponent);
|
||||
ASSERT_TRUE(nativeXComponentImpl);
|
||||
|
||||
/**
|
||||
* @tc.steps: step3. register axis event for nativeXComponent instance
|
||||
*/
|
||||
auto callback = [](OH_NativeXComponent* /* nativeXComponent */, ArkUI_UIInputEvent* event,
|
||||
ArkUI_UIInputEvent_Type type) { isAxis = true; };
|
||||
nativeXComponent->RegisterUIAxisEventCallback(callback);
|
||||
|
||||
/**
|
||||
* @tc.steps: step4. call HandleAxisEvent
|
||||
*/
|
||||
AxisInfo event;
|
||||
pattern->HandleAxisEvent(event);
|
||||
EXPECT_TRUE(isAxis);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: XComponentSourceTypeTest
|
||||
* @tc.desc: Test SourceType
|
||||
@ -1259,6 +1261,40 @@ HWTEST_F(XComponentTestNg, XComponentSourceTypeTest, TestSize.Level1)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: XComponentImageAnalyzerTest
|
||||
* @tc.desc: Test Enable Image Analyzer
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(XComponentTestNg, XComponentImageAnalyzerTest, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. set type = XCOMPONENT_SURFACE_TYPE and call CreateXComponentNode
|
||||
* @tc.expected: xcomponent frameNode create successfully
|
||||
*/
|
||||
testProperty.xcType = XCOMPONENT_SURFACE_TYPE_VALUE;
|
||||
auto frameNode = CreateXComponentNode(testProperty);
|
||||
ASSERT_TRUE(frameNode);
|
||||
auto pattern = frameNode->GetPattern<XComponentPattern>();
|
||||
ASSERT_TRUE(pattern);
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. call EnableImageAnalyzer
|
||||
* @tc.expected: IsSupportImageAnalyzerFeature() return right value
|
||||
*/
|
||||
pattern->EnableAnalyzer(true);
|
||||
EXPECT_TRUE(pattern->isEnableAnalyzer_);
|
||||
|
||||
if (ImageAnalyzerMgr::GetInstance().IsImageAnalyzerSupported()) {
|
||||
EXPECT_TRUE(pattern->IsSupportImageAnalyzerFeature());
|
||||
} else {
|
||||
EXPECT_FALSE(pattern->IsSupportImageAnalyzerFeature());
|
||||
}
|
||||
|
||||
pattern->imageAnalyzerManager_ = nullptr;
|
||||
EXPECT_FALSE(pattern->IsSupportImageAnalyzerFeature());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: XComponentSurfaceLifeCycleCallback
|
||||
* @tc.desc: Test XComponentController's surface life cycle callback
|
||||
@ -1326,39 +1362,4 @@ HWTEST_F(XComponentTestNg, XComponentSurfaceLifeCycleCallback, TestSize.Level1)
|
||||
pattern->OnDetachFromFrameNode(AceType::RawPtr(frameNode));
|
||||
EXPECT_STREQ(SURFACE_ID.c_str(), onSurfaceDestroyedSurfaceId.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: XComponentImageAnalyzerTest
|
||||
* @tc.desc: Test Enable Image Analyzer
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(XComponentTestNg, XComponentImageAnalyzerTest, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. set type = XCOMPONENT_SURFACE_TYPE and call CreateXComponentNode
|
||||
* @tc.expected: xcomponent frameNode create successfully
|
||||
*/
|
||||
testProperty.xcType = XCOMPONENT_SURFACE_TYPE_VALUE;
|
||||
auto frameNode = CreateXComponentNode(testProperty);
|
||||
ASSERT_TRUE(frameNode);
|
||||
auto pattern = frameNode->GetPattern<XComponentPattern>();
|
||||
ASSERT_TRUE(pattern);
|
||||
pattern->surfaceId_ = SURFACE_ID;
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. call EnableImageAnalyzer
|
||||
* @tc.expected: IsSupportImageAnalyzerFeature() return right value
|
||||
*/
|
||||
pattern->EnableAnalyzer(true);
|
||||
EXPECT_TRUE(pattern->isEnableAnalyzer_);
|
||||
|
||||
if (ImageAnalyzerMgr::GetInstance().IsImageAnalyzerSupported()) {
|
||||
EXPECT_TRUE(pattern->IsSupportImageAnalyzerFeature());
|
||||
} else {
|
||||
EXPECT_FALSE(pattern->IsSupportImageAnalyzerFeature());
|
||||
}
|
||||
|
||||
pattern->imageAnalyzerManager_ = nullptr;
|
||||
EXPECT_FALSE(pattern->IsSupportImageAnalyzerFeature());
|
||||
}
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
Loading…
Reference in New Issue
Block a user