diff --git a/.gitignore b/.gitignore index 5a8c2db468f20a683f78dbc455b1652e7a9b64d0..422d8ad6376e0f7c2add60205ef8e3da35f4eadf 100644 --- a/.gitignore +++ b/.gitignore @@ -291,3 +291,5 @@ /node/__pycache__/ /ply/__pycache__/ /pyjson5/src/json5/__pycache__/ + +/rust/serde_jsonrc/ diff --git a/blink/common/loader/network_utils.cc b/blink/common/loader/network_utils.cc index 3a143f16f82e0bcde1a6aa43911623d622db42a1..e531ce213f79f92b86805afcf18a91cd29de3ab8 100644 --- a/blink/common/loader/network_utils.cc +++ b/blink/common/loader/network_utils.cc @@ -33,11 +33,19 @@ bool AlwaysAccessNetwork( } const char* ImageAcceptHeader() { +#if BUILDFLAG(IS_OHOS) +#if BUILDFLAG(ENABLE_AV1_DECODER) + return "image/avif,image/heif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8"; +#else + return "image/heif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8"; +#endif // BUILDFLAG(ENABLE_AV1_DECODER) +#else #if BUILDFLAG(ENABLE_AV1_DECODER) return "image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8"; #else return "image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8"; -#endif +#endif // BUILDFLAG(ENABLE_AV1_DECODER) +#endif // BUILDFLAG(IS_WIN) } void SetAcceptHeader(net::HttpRequestHeaders& headers, diff --git a/blink/common/loader/throttling_url_loader.cc b/blink/common/loader/throttling_url_loader.cc index 63c8eccdbeaa0674c8734e6ada848f3198b6a590..63b295d0a7907bea0251712bdc4381a51d2d9b00 100644 --- a/blink/common/loader/throttling_url_loader.cc +++ b/blink/common/loader/throttling_url_loader.cc @@ -703,8 +703,12 @@ void ThrottlingURLLoader::OnReceiveResponse( auto* throttle = entry.throttle.get(); bool throttle_deferred = false; base::Time start = base::Time::Now(); + auto weak_ptr = weak_factory_.GetWeakPtr(); throttle->BeforeWillProcessResponse(response_url_, *response_head, &throttle_deferred); + if (!weak_ptr) { + return; + } RecordExecutionTimeHistogram( GetStageNameForHistogram(DEFERRED_BEFORE_RESPONSE), start); if (!HandleThrottleResult(throttle, throttle_deferred, &deferred)) @@ -730,8 +734,12 @@ void ThrottlingURLLoader::OnReceiveResponse( auto* throttle = entry.throttle.get(); bool throttle_deferred = false; base::Time start = base::Time::Now(); + auto weak_ptr = weak_factory_.GetWeakPtr(); throttle->WillProcessResponse(response_url_, response_head.get(), &throttle_deferred); + if (!weak_ptr) { + return; + } RecordExecutionTimeHistogram(GetStageNameForHistogram(DEFERRED_RESPONSE), start); if (!HandleThrottleResult(throttle, throttle_deferred, &deferred)) @@ -899,7 +907,11 @@ void ThrottlingURLLoader::OnComplete( auto* throttle = entry.throttle.get(); bool throttle_deferred = false; base::Time start = base::Time::Now(); + auto weak_ptr = weak_factory_.GetWeakPtr(); throttle->WillOnCompleteWithError(status, &throttle_deferred); + if (!weak_ptr) { + return; + } RecordExecutionTimeHistogram(GetStageNameForHistogram(DEFERRED_COMPLETE), start); if (!HandleThrottleResult(throttle, throttle_deferred, &deferred)) diff --git a/blink/common/loader/throttling_url_loader_unittest.cc b/blink/common/loader/throttling_url_loader_unittest.cc index 10916231a36cb05b7d1baa4aa044d9cf27cdf10d..dfd5f632f2c3c57b4bb09d3f299f821cf3b6c1ee 100644 --- a/blink/common/loader/throttling_url_loader_unittest.cc +++ b/blink/common/loader/throttling_url_loader_unittest.cc @@ -344,9 +344,9 @@ class TestURLLoaderThrottle : public blink::URLLoaderThrottle { network::mojom::URLResponseHead* response_head, bool* defer) override { will_process_response_called_++; + response_url_ = response_url; if (will_process_response_callback_) will_process_response_callback_.Run(delegate_.get(), defer); - response_url_ = response_url; } void BeforeWillProcessResponse( @@ -426,6 +426,11 @@ class ThrottlingURLLoaderTest : public testing::Test { factory_.factory_remote().FlushForTesting(); } + void ResetLoader() { + ResetThrottleRawPointer(); + loader_.reset(); + } + void ResetThrottleRawPointer() { throttle_ = nullptr; } // Be the first member so it is destroyed last. @@ -471,6 +476,25 @@ TEST_F(ThrottlingURLLoaderTest, CancelBeforeStart) { EXPECT_EQ(1u, client_.on_complete_called()); } +TEST_F(ThrottlingURLLoaderTest, DeleteBeforeStart) { + base::RunLoop run_loop; + throttle_->set_will_start_request_callback(base::BindLambdaForTesting( + [this, &run_loop](blink::URLLoaderThrottle::Delegate* delegate, + bool* defer) { + ResetLoader(); + run_loop.Quit(); + })); + + CreateLoaderAndStart(); + run_loop.Run(); + + EXPECT_EQ(1u, factory_.create_loader_and_start_called()); + + EXPECT_EQ(0u, client_.on_received_response_called()); + EXPECT_EQ(0u, client_.on_received_redirect_called()); + EXPECT_EQ(0u, client_.on_complete_called()); +} + TEST_F(ThrottlingURLLoaderTest, DeferBeforeStart) { throttle_->set_will_start_request_callback(base::BindLambdaForTesting( [](blink::URLLoaderThrottle::Delegate* delegate, bool* defer) { @@ -701,6 +725,88 @@ TEST_F(ThrottlingURLLoaderTest, CancelBeforeRedirect) { EXPECT_EQ(1u, client_.on_complete_called()); } +TEST_F(ThrottlingURLLoaderTest, DeleteBeforeRedirect) { + base::RunLoop run_loop; + throttle_->set_will_redirect_request_callback(base::BindLambdaForTesting( + [this, &run_loop]( + blink::URLLoaderThrottle::Delegate* delegate, bool* /* defer */, + std::vector* /* removed_headers */, + net::HttpRequestHeaders* /* modified_headers */, + net::HttpRequestHeaders* /* modified_cors_exempt_headers */) { + ResetLoader(); + run_loop.Quit(); + })); + + CreateLoaderAndStart(); + + factory_.NotifyClientOnReceiveRedirect(); + + run_loop.Run(); + + EXPECT_EQ(0u, client_.on_received_response_called()); + EXPECT_EQ(0u, client_.on_received_redirect_called()); + EXPECT_EQ(0u, client_.on_complete_called()); +} + +TEST_F(ThrottlingURLLoaderTest, CancelBeforeWillRedirect) { + throttle_->set_before_will_redirect_request_callback( + base::BindLambdaForTesting( + [](blink::URLLoaderThrottle::Delegate* delegate, + bool* defer, + std::vector* /* removed_headers */, + net::HttpRequestHeaders* /* modified_headers */, + net::HttpRequestHeaders* /* modified_cors_exempt_headers */) { + delegate->CancelWithError(net::ERR_ACCESS_DENIED); + })); + + base::RunLoop run_loop; + client_.set_on_complete_callback( + base::BindLambdaForTesting([&run_loop](int error) { + EXPECT_EQ(net::ERR_ACCESS_DENIED, error); + run_loop.Quit(); + })); + + CreateLoaderAndStart(); + + factory_.NotifyClientOnReceiveRedirect(); + + run_loop.Run(); + + EXPECT_EQ(1u, throttle_->will_start_request_called()); + EXPECT_EQ(1u, throttle_->will_redirect_request_called()); + EXPECT_EQ(0u, throttle_->before_will_process_response_called()); + EXPECT_EQ(0u, throttle_->will_process_response_called()); + + EXPECT_EQ(0u, client_.on_received_response_called()); + EXPECT_EQ(0u, client_.on_received_redirect_called()); + EXPECT_EQ(1u, client_.on_complete_called()); +} + +TEST_F(ThrottlingURLLoaderTest, DeleteBeforeWillRedirect) { + base::RunLoop run_loop; + throttle_->set_before_will_redirect_request_callback( + base::BindLambdaForTesting( + [this, &run_loop]( + blink::URLLoaderThrottle::Delegate* delegate, + bool* defer, + std::vector* /* removed_headers */, + net::HttpRequestHeaders* /* modified_headers */, + net::HttpRequestHeaders* /* modified_cors_exempt_headers */) { + ResetLoader(); + run_loop.Quit(); + })); + + CreateLoaderAndStart(); + + factory_.NotifyClientOnReceiveRedirect(); + + run_loop.Run(); + + EXPECT_EQ(0u, client_.on_received_response_called()); + EXPECT_EQ(0u, client_.on_received_redirect_called()); + EXPECT_EQ(0u, client_.on_complete_called()); +} + TEST_F(ThrottlingURLLoaderTest, DeferBeforeRedirect) { base::RunLoop run_loop1; throttle_->set_will_redirect_request_callback(base::BindLambdaForTesting( @@ -948,6 +1054,77 @@ TEST_F(ThrottlingURLLoaderTest, CancelBeforeResponse) { EXPECT_EQ(1u, client_.on_complete_called()); } +TEST_F(ThrottlingURLLoaderTest, DeleteBeforeResponse) { + base::RunLoop run_loop; + throttle_->set_will_process_response_callback(base::BindLambdaForTesting( + [this, &run_loop](blink::URLLoaderThrottle::Delegate* delegate, + bool* defer) { + ResetLoader(); + run_loop.Quit(); + })); + + CreateLoaderAndStart(); + + factory_.NotifyClientOnReceiveResponse(); + + run_loop.Run(); + + EXPECT_EQ(0u, client_.on_received_response_called()); + EXPECT_EQ(0u, client_.on_received_redirect_called()); + EXPECT_EQ(0u, client_.on_complete_called()); +} + +TEST_F(ThrottlingURLLoaderTest, CancelBeforeWillProcessResponse) { + throttle_->set_before_will_process_response_callback( + base::BindLambdaForTesting( + [](blink::URLLoaderThrottle::Delegate* delegate, + bool* defer) { + delegate->CancelWithError(net::ERR_ACCESS_DENIED); + })); + + base::RunLoop run_loop; + client_.set_on_complete_callback( + base::BindLambdaForTesting([&run_loop](int error) { + EXPECT_EQ(net::ERR_ACCESS_DENIED, error); + run_loop.Quit(); + })); + + CreateLoaderAndStart(); + + factory_.NotifyClientOnReceiveResponse(); + + run_loop.Run(); + + EXPECT_EQ(1u, throttle_->will_start_request_called()); + EXPECT_EQ(0u, throttle_->will_redirect_request_called()); + EXPECT_EQ(1u, throttle_->before_will_process_response_called()); + EXPECT_EQ(0u, throttle_->will_process_response_called()); + EXPECT_EQ(0u, client_.on_received_response_called()); + EXPECT_EQ(0u, client_.on_received_redirect_called()); + EXPECT_EQ(1u, client_.on_complete_called()); +} + +TEST_F(ThrottlingURLLoaderTest, DeleteBeforeWillProcessResponse) { + base::RunLoop run_loop; + throttle_->set_before_will_process_response_callback( + base::BindLambdaForTesting( + [this, &run_loop](blink::URLLoaderThrottle::Delegate* delegate, + bool* defer) { + ResetLoader(); + run_loop.Quit(); + })); + + CreateLoaderAndStart(); + + factory_.NotifyClientOnReceiveResponse(); + + run_loop.Run(); + + EXPECT_EQ(0u, client_.on_received_response_called()); + EXPECT_EQ(0u, client_.on_received_redirect_called()); + EXPECT_EQ(0u, client_.on_complete_called()); +} + TEST_F(ThrottlingURLLoaderTest, DeferBeforeResponse) { base::RunLoop run_loop1; throttle_->set_will_process_response_callback(base::BindRepeating( diff --git a/blink/common/mime_util/mime_util.cc b/blink/common/mime_util/mime_util.cc index f49cf1fb0c620c9349859cca38d9c2b00e833eb7..3c0c02f75e86422af7874c4dde14225bd06694a7 100644 --- a/blink/common/mime_util/mime_util.cc +++ b/blink/common/mime_util/mime_util.cc @@ -41,6 +41,11 @@ const char* const kSupportedImageTypes[] = { #if BUILDFLAG(ENABLE_AV1_DECODER) "image/avif", #endif +#if BUILDFLAG(IS_OHOS) + "image/heif", + "image/heic", + "image/hevc", +#endif }; // Support every script type mentioned in the spec, as it notes that "User diff --git a/blink/common/scheduler/web_scheduler_tracked_feature.cc b/blink/common/scheduler/web_scheduler_tracked_feature.cc index 70e04c4aae13fd0e80770df0157d66a1d66da574..bf693fdfb7a6a438b289b74767602ac2050070aa 100644 --- a/blink/common/scheduler/web_scheduler_tracked_feature.cc +++ b/blink/common/scheduler/web_scheduler_tracked_feature.cc @@ -131,7 +131,7 @@ FeatureNames FeatureToNames(WebSchedulerTrackedFeature feature) { case WebSchedulerTrackedFeature::kEnableCacheNativeEmbed: return {"EnableCacheNativeEmbed", "enable native embed to bfcache"}; case WebSchedulerTrackedFeature::kEnableCacheMediaTakeOver: - return {"EnableCacheMediaIntercept", "enable media take over to bfcache"}; + return {"EnableCacheMediaTakeOver", "enable media take over to bfcache"}; #endif } return {}; diff --git a/blink/common/web_preferences/web_preferences_mojom_traits.cc b/blink/common/web_preferences/web_preferences_mojom_traits.cc index 8d9bf9d3b7e0bcc6fd21ae67507b807beb95ad99..36b3a9ec365d8db02440360cfcedcf268d2f268c 100644 --- a/blink/common/web_preferences/web_preferences_mojom_traits.cc +++ b/blink/common/web_preferences/web_preferences_mojom_traits.cc @@ -102,10 +102,6 @@ bool StructTraitsscrollbar_color = data.scrollbar_color(); #endif // OHOS_SCROLLBAR -#ifdef OHOS_EX_BLANK_TARGET_POPUP_INTERCEPT - out->blank_target_popup_intercept_enabled = - data.blank_target_popup_intercept_enabled(); -#endif // OHOS_EX_BLANK_TARGET_POPUP_INTERCEPT out->accelerated_2d_canvas_enabled = data.accelerated_2d_canvas_enabled(); out->canvas_2d_layers_enabled = data.canvas_2d_layers_enabled(); out->antialiased_2d_canvas_disabled = data.antialiased_2d_canvas_disabled(); @@ -263,6 +259,12 @@ bool StructTraitscustom_video_player_enable = data.custom_video_player_enable(); out->custom_video_player_overlay = data.custom_video_player_overlay(); #endif // OHOS_CUSTOM_VIDEO_PLAYER +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + out->enable_media_network_traffic_prompt = + data.enable_media_network_traffic_prompt(); + out->playback_with_mobile_data_allowed = + data.playback_with_mobile_data_allowed(); +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT return true; } diff --git a/blink/public/common/input/web_menu_source_type.h b/blink/public/common/input/web_menu_source_type.h index b3b0e8e71611e2fceb9e567894d4bfe1bc5c9a6d..cba648357eeb83c8744a2c142af61d7dfa61aa47 100644 --- a/blink/public/common/input/web_menu_source_type.h +++ b/blink/public/common/input/web_menu_source_type.h @@ -20,8 +20,8 @@ enum WebMenuSourceType { kMenuSourceAdjustSelection, kMenuSourceAdjustSelectionReset, #ifdef OHOS_EX_FREE_COPY - kMenuSourceSelectAndCopy, - kMenuSourceTypeLast = kMenuSourceSelectAndCopy + kMenuSourceShowFreeCopyMenu, + kMenuSourceTypeLast = kMenuSourceShowFreeCopyMenu #else kMenuSourceTypeLast = kMenuSourceAdjustSelectionReset #endif diff --git a/blink/public/common/web_preferences/web_preferences.h b/blink/public/common/web_preferences/web_preferences.h index dd95efb210f8f9157adbdb61d76910c8e0cf1e76..54c0ba6676b25d8fa95bb9c3dc1f48d1eb0a8830 100644 --- a/blink/public/common/web_preferences/web_preferences.h +++ b/blink/public/common/web_preferences/web_preferences.h @@ -290,9 +290,6 @@ struct BLINK_COMMON_EXPORT WebPreferences { bool disable_webauthn = false; #endif // BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) -#ifdef OHOS_EX_BLANK_TARGET_POPUP_INTERCEPT - bool blank_target_popup_intercept_enabled = true; -#endif // Enable forcibly modifying content rendering to result in a light on dark // color scheme. bool force_dark_mode_enabled = false; @@ -418,6 +415,11 @@ struct BLINK_COMMON_EXPORT WebPreferences { bool custom_video_player_overlay = false; #endif // OHOS_CUSTOM_VIDEO_PLAYER +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + bool enable_media_network_traffic_prompt = false; + bool playback_with_mobile_data_allowed = false; +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + // We try to keep the default values the same as the default values in // chrome, except for the cases where it would require lots of extra work for // the embedder to use the same default value. diff --git a/blink/public/common/web_preferences/web_preferences_mojom_traits.h b/blink/public/common/web_preferences/web_preferences_mojom_traits.h index 613365192d4526b35e80d8c69bcd6668b9b79c04..c02f078460ad85ed4c3dd2eca97836d69f834615 100644 --- a/blink/public/common/web_preferences/web_preferences_mojom_traits.h +++ b/blink/public/common/web_preferences/web_preferences_mojom_traits.h @@ -653,13 +653,6 @@ struct BLINK_COMMON_EXPORT StructTraits; + using RectChangeCB = base::RepeatingCallback; virtual void OnCreateNativeSurface(int native_embed_id, RectChangeCB rect_changed_cb) = 0; virtual void OnLayerRectChange(const gfx::Rect& rect) = 0; diff --git a/blink/public/strings/blink_strings.grd b/blink/public/strings/blink_strings.grd index 5d5317fb434d89f0ad2ddb823ee9a5ea570c6a67..66018f0aee22260cf983ba44765e931cf2349b3f 100644 --- a/blink/public/strings/blink_strings.grd +++ b/blink/public/strings/blink_strings.grd @@ -891,6 +891,17 @@ below: Invalid grammar + + + + Currently on a mobile data network, playback will consume traffic + + + Continue playing + + + Playing using mobile data + diff --git a/blink/public/strings/translations/blink_strings_zh-CN.xtb b/blink/public/strings/translations/blink_strings_zh-CN.xtb index d5a69b826eddb9a314ee72c375abff4085b4782a..49203c7fda4e70a6e6c9a0117e0d5a68679f2b47 100644 --- a/blink/public/strings/translations/blink_strings_zh-CN.xtb +++ b/blink/public/strings/translations/blink_strings_zh-CN.xtb @@ -178,4 +178,8 @@ 画中画 已部分选中 进入“画中画”模式 - \ No newline at end of file + +当前为移动数据网络,播放将消耗流量 +继续播放 +正在使用移动数据播放 + diff --git a/blink/public/web/web_local_frame_client.h b/blink/public/web/web_local_frame_client.h old mode 100755 new mode 100644 diff --git a/blink/public/web/web_settings.h b/blink/public/web/web_settings.h index 17734190a758257c897b93d49313b13651c1ddc2..7f18ae74c9ab253e8144f02ee448f4d35c3c8b9c 100644 --- a/blink/public/web/web_settings.h +++ b/blink/public/web/web_settings.h @@ -187,9 +187,6 @@ class WebSettings { #if defined(OHOS_EX_FREE_COPY) virtual void SetContextMenuCustomization(bool) = 0; #endif -#ifdef OHOS_EX_BLANK_TARGET_POPUP_INTERCEPT - virtual void EnableBlankTargetPopupIntercept(bool) = 0; -#endif // OHOS_EX_BLANK_TARGET_POPUP_INTERCEPT virtual void SetPasswordEchoDurationInSeconds(double) = 0; virtual void SetPasswordEchoEnabled(bool) = 0; virtual void SetPluginsEnabled(bool) = 0; @@ -311,6 +308,11 @@ class WebSettings { virtual void SetCustomVideoPlayerOverlay(bool overlay) = 0; #endif // OHOS_CUSTOM_VIDEO_PLAYER +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + virtual void SetMediaNetworkTrafficPromptEnabled(bool enable) = 0; + virtual void SetPlaybackWithMobileDataAllowed(bool allowed) = 0; +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + protected: ~WebSettings() = default; }; diff --git a/blink/renderer/bindings/core/v8/v8_code_cache.cc b/blink/renderer/bindings/core/v8/v8_code_cache.cc index 87434a291faf502c739d654ea5f15351fdf6ea6e..0a1bde5bdc2d740a899d6a33411d360daa1afd8f 100644 --- a/blink/renderer/bindings/core/v8/v8_code_cache.cc +++ b/blink/renderer/bindings/core/v8/v8_code_cache.cc @@ -414,6 +414,7 @@ scoped_refptr V8CodeCache::GenerateFullCodeCache( return cached_metadata; } +#if BUILDFLAG(IS_OHOS) V8CodeCache::CacheError V8CodeCache::GenerateCodeCache( ScriptState* script_state, const String& url, @@ -436,11 +437,9 @@ V8CodeCache::CacheError V8CodeCache::GenerateCodeCache( V8CodeCache::CacheError error = GenerateCodeCacheInternal( script_state, script, source_url, cache_handler, cache_options); - LOG(ERROR) << "Generate code cache end. Error code: " << static_cast(error) << ". url: " << url; return error; } -#if BUILDFLAG(IS_OHOS) V8CodeCache::CacheError V8CodeCache::GenerateCodeCacheInternal( ScriptState* script_state, const String& script_string, @@ -475,11 +474,11 @@ V8CodeCache::CacheError V8CodeCache::GenerateCodeCacheInternal( ProduceCacheInternal( isolate, code_cache_host, unbound_script, cache_handler, script_string.length(), source_url, - text_position, "v8.compile", V8CodeCache::ProduceCacheOptions::kSetTimeStamp); + text_position, "v8.precompile", V8CodeCache::ProduceCacheOptions::kSetTimeStamp); ProduceCacheInternal( isolate, code_cache_host, unbound_script, cache_handler, script_string.length(), source_url, - text_position, "v8.compile", V8CodeCache::ProduceCacheOptions::kProduceCodeCache); + text_position, "v8.precompile", V8CodeCache::ProduceCacheOptions::kProduceCodeCache); return V8CodeCache::CacheError::kNoError; } diff --git a/blink/renderer/bindings/core/v8/v8_script_runner.cc b/blink/renderer/bindings/core/v8/v8_script_runner.cc index 2c17ec9378630eb9f05be82cd548ada1bffbb9e3..b8e6656bd4a1fb306cbb051fea9534185bdb5e16 100644 --- a/blink/renderer/bindings/core/v8/v8_script_runner.cc +++ b/blink/renderer/bindings/core/v8/v8_script_runner.cc @@ -241,7 +241,11 @@ v8::MaybeLocal V8ScriptRunner::CompileScript( probe::V8Compile probe(execution_context, file_name, script_start_position.line_.ZeroBasedInt(), script_start_position.column_.ZeroBasedInt()); - +#if BUILDFLAG(IS_OHOS) + TRACE_EVENT_BEGIN2(kTraceEventCategoryGroup, "v8.compile location", "lineNumber", + script_start_position.line_.OneBasedInt(), "columnNumber", script_start_position.column_.OneBasedInt()); + TRACE_EVENT_END0(kTraceEventCategoryGroup, "v8.compile location"); +#endif if (!*TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(kTraceEventCategoryGroup)) { return CompileScriptInternal(isolate, script_state, classic_script, origin, compile_options, no_cache_reason, nullptr); @@ -743,6 +747,22 @@ v8::MaybeLocal V8ScriptRunner::CallFunction( inspector_function_call_event::Data( std::move(trace_context), context, function); }); +#if BUILDFLAG(IS_OHOS) + v8::Local original_function = GetBoundFunction(function); + v8::Local function_name = original_function->GetDebugName(); + if (!function_name.IsEmpty() && function_name->IsString()) { + TRACE_EVENT_BEGIN1("devtools.timeline", "FunctionName", "functionName", + ToCoreString(function_name.As()).Ascii().c_str()); + TRACE_EVENT_END0("devtools.timeline", "FunctionName"); + } + std::unique_ptr location = CaptureSourceLocation(original_function); + TRACE_EVENT_BEGIN2("devtools.timeline", "FunctionUrl", "url", + location->Url().Ascii().c_str(), "scriptId", location->ScriptId()); + TRACE_EVENT_END0("devtools.timeline", "FunctionUrl"); + TRACE_EVENT_BEGIN2("devtools.timeline", "FunctionLocation", "lineNumber", + location->LineNumber(), "columnNumber", location->ColumnNumber()); + TRACE_EVENT_END0("devtools.timeline", "FunctionLocation"); +#endif } probe::CallFunction probe(context, isolate->GetCurrentContext(), function, diff --git a/blink/renderer/controller/BUILD.gn b/blink/renderer/controller/BUILD.gn index b70e75fd6e29620bbb2c21b2f9bb1213e785ad75..432c9f3ccedc5da175a940bef7547c800d0aeb8b 100644 --- a/blink/renderer/controller/BUILD.gn +++ b/blink/renderer/controller/BUILD.gn @@ -189,6 +189,12 @@ test("blink_unittests") { "//build/config/fuchsia/test/mark_vmo_executable.shard.test-cml", ] } + + if (is_ohos) { + deps += [ + "//cef:libcef_static", + ] + } } test("blink_perf_tests") { @@ -262,12 +268,6 @@ source_set("blink_unittests_sources") { ] } - if (ohos_unittests) { - sources += [ - "//cef/libcef/common/soc_perf_util.cc", - ] - } - if (is_linux || is_chromeos || is_android || is_apple || is_win) { sources += [ "highest_pmf_reporter_test.cc", @@ -303,12 +303,6 @@ source_set("blink_unittests_sources") { "//v8", ] - if (ohos_unittests) { - deps +=[ - "//cef/libcef/common/mojom" - ] - } - configs += [ "//third_party/blink/renderer:config", "//third_party/blink/renderer:inside_blink", diff --git a/blink/renderer/core/css/css_counter_style_rule.cc b/blink/renderer/core/css/css_counter_style_rule.cc index 6ba7e7b00fad017d83e65f13dbe6826b9c4c328c..9b4074927531e7ea3ef2468706bd4daa3e4788d3 100644 --- a/blink/renderer/core/css/css_counter_style_rule.cc +++ b/blink/renderer/core/css/css_counter_style_rule.cc @@ -4,6 +4,7 @@ #include "third_party/blink/renderer/core/css/css_counter_style_rule.h" +#include "third_party/blink/renderer/core/css/css_markup.h" #include "third_party/blink/renderer/core/css/css_style_sheet.h" #include "third_party/blink/renderer/core/css/parser/at_rule_descriptor_parser.h" #include "third_party/blink/renderer/core/css/parser/css_parser_context.h" @@ -27,7 +28,7 @@ CSSCounterStyleRule::~CSSCounterStyleRule() = default; String CSSCounterStyleRule::cssText() const { StringBuilder result; result.Append("@counter-style "); - result.Append(name()); + SerializeIdentifier(name(), result); result.Append(" {"); // Note: The exact serialization isn't well specified. diff --git a/blink/renderer/core/css/css_font_palette_values_rule.cc b/blink/renderer/core/css/css_font_palette_values_rule.cc index 446190aba7bc44c1691355b94a2ae07b72e17c1b..51906bcbdad6016cebb39b05393f4538830b4395 100644 --- a/blink/renderer/core/css/css_font_palette_values_rule.cc +++ b/blink/renderer/core/css/css_font_palette_values_rule.cc @@ -4,6 +4,7 @@ #include "third_party/blink/renderer/core/css/css_font_palette_values_rule.h" +#include "third_party/blink/renderer/core/css/css_markup.h" #include "third_party/blink/renderer/core/css/css_style_sheet.h" #include "third_party/blink/renderer/core/css/parser/at_rule_descriptor_parser.h" #include "third_party/blink/renderer/core/css/parser/css_parser_context.h" @@ -26,7 +27,7 @@ CSSFontPaletteValuesRule::~CSSFontPaletteValuesRule() = default; String CSSFontPaletteValuesRule::cssText() const { StringBuilder result; result.Append("@font-palette-values "); - result.Append(name()); + SerializeIdentifier(name(), result); result.Append(" {"); String font_family = fontFamily(); diff --git a/blink/renderer/core/css/css_keyframes_rule.cc b/blink/renderer/core/css/css_keyframes_rule.cc index b44967ddce8acf61a8e758b10debd4d1ba9d6e56..b4797b870130a7cdbd02512ee17cf5d5af81be0a 100644 --- a/blink/renderer/core/css/css_keyframes_rule.cc +++ b/blink/renderer/core/css/css_keyframes_rule.cc @@ -29,6 +29,7 @@ #include "third_party/blink/renderer/core/css/cascade_layer.h" #include "third_party/blink/renderer/core/css/css_keyframe_rule.h" +#include "third_party/blink/renderer/core/css/css_markup.h" #include "third_party/blink/renderer/core/css/css_rule_list.h" #include "third_party/blink/renderer/core/css/css_style_sheet.h" #include "third_party/blink/renderer/core/css/parser/css_parser.h" @@ -162,7 +163,7 @@ String CSSKeyframesRule::cssText() const { } else { result.Append("@keyframes "); } - result.Append(name()); + SerializeIdentifier(name(), result); result.Append(" { \n"); unsigned size = length(); diff --git a/blink/renderer/core/css/parser/container_query_parser.cc b/blink/renderer/core/css/parser/container_query_parser.cc index 4e8fbd9e8903d8d71cd411b10e252d188f73ae02..f26e26547420065db00fa3f89fcfac28a9f0905b 100644 --- a/blink/renderer/core/css/parser/container_query_parser.cc +++ b/blink/renderer/core/css/parser/container_query_parser.cc @@ -113,7 +113,8 @@ ContainerQueryParser::ContainerQueryParser(const CSSParserContext& context) MediaQueryParser::SyntaxLevel::kLevel4) {} const MediaQueryExpNode* ContainerQueryParser::ParseCondition(String value) { - auto [tokens, raw_offsets] = CSSTokenizer(value).TokenizeToEOFWithOffsets(); + CSSTokenizer tokenizer(value); + auto [tokens, raw_offsets] = tokenizer.TokenizeToEOFWithOffsets(); CSSParserTokenRange range(tokens); CSSParserTokenOffsets offsets(tokens, std::move(raw_offsets), value); return ParseCondition(range, offsets); diff --git a/blink/renderer/core/css/parser/container_query_parser_test.cc b/blink/renderer/core/css/parser/container_query_parser_test.cc index 94ef0e9f7a6b10d345f78c8f98a57c03517ea28f..1672403efade218cec29b72c8fd8a6e207841f7a 100644 --- a/blink/renderer/core/css/parser/container_query_parser_test.cc +++ b/blink/renderer/core/css/parser/container_query_parser_test.cc @@ -86,6 +86,11 @@ TEST_F(ContainerQueryParserTest, ParseQuery) { EXPECT_EQ(String(test), ParseQuery(test)); } + // Escaped (unnecessarily but validly) characters in the identifier. + EXPECT_EQ("(width)", ParseQuery("(\\77 idth)")); + // Repro case for b/341640868 + EXPECT_EQ("(min-width: 100px)", ParseQuery("(min\\2d width: 100px)")); + // Invalid: EXPECT_EQ("", ParseQuery("(min-width)")); EXPECT_EQ("", ParseQuery("((width) or (width) and (width))")); diff --git a/blink/renderer/core/css/parser/css_parser_token.h b/blink/renderer/core/css/parser/css_parser_token.h index 45401aba5fa74e8e4534e82281761241893c0116..443656067062affcd5c0c8969a8e1d26e687bb57 100644 --- a/blink/renderer/core/css/parser/css_parser_token.h +++ b/blink/renderer/core/css/parser/css_parser_token.h @@ -94,6 +94,8 @@ class CORE_EXPORT CSSParserToken { value_is_8bit_(false), // Don't care. padding_(0) // Don't care. {} + + // The resulting CSSParserToken may hold a reference to the data in value. CSSParserToken(CSSParserTokenType type, StringView value, BlockType block_type = kNotBlock) diff --git a/blink/renderer/core/css/parser/css_tokenizer.h b/blink/renderer/core/css/parser/css_tokenizer.h index c46710b8ac99947725ff12c8eab7716605904f27..d303626aee1f7d8065f5612eed5df9fa796f32cb 100644 --- a/blink/renderer/core/css/parser/css_tokenizer.h +++ b/blink/renderer/core/css/parser/css_tokenizer.h @@ -31,6 +31,9 @@ class CORE_EXPORT CSSTokenizer { CSSTokenizer(const CSSTokenizer&) = delete; CSSTokenizer& operator=(const CSSTokenizer&) = delete; + // The CSSParserTokens in the result may hold references to the CSSTokenizer + // object, or the string data referenced by the CSSTokenizer. Do not use the + // tokens after the CSSTokenizer or its underlying String goes out of scope. Vector TokenizeToEOF(); wtf_size_t TokenCount(); @@ -38,6 +41,8 @@ class CORE_EXPORT CSSTokenizer { // There's an extra offset at the very end that returns the end byte // of the last token, i.e., the length of the input string. // This matches the convention CSSParserTokenOffsets expects. + // + // See the warning about holding a reference in TokenizeToEOF(). std::pair, Vector> TokenizeToEOFWithOffsets(); diff --git a/blink/renderer/core/css/resolver/style_cascade.cc b/blink/renderer/core/css/resolver/style_cascade.cc index d256faa8fc1d49694a38c8aa8478b1c4becdd496..96d7c8e96e184e576301dcbfeb3207637c98899f 100644 --- a/blink/renderer/core/css/resolver/style_cascade.cc +++ b/blink/renderer/core/css/resolver/style_cascade.cc @@ -1354,7 +1354,7 @@ CSSVariableData* StyleCascade::GetEnvironmentVariable( .GetStyleEngine() .EnsureEnvironmentVariables() .ResolveVariable(name, std::move(indices), !is_ua_scope); - LOG(INFO) << __func__ << " " << name << "=" << (result ? result->OriginalText().Utf8() : std::string("null")); + LOG(DEBUG) << __func__ << " " << name << "=" << (result ? result->OriginalText().Utf8() : std::string("null")); return result; #else return state_.GetDocument() diff --git a/blink/renderer/core/css/style_rule.cc b/blink/renderer/core/css/style_rule.cc index 32cfdd77e9418345a0325b780bef12950d205162..fc75a39bf59002e4a37398651f785c212fc82eb6 100644 --- a/blink/renderer/core/css/style_rule.cc +++ b/blink/renderer/core/css/style_rule.cc @@ -33,6 +33,7 @@ #include "third_party/blink/renderer/core/css/css_keyframes_rule.h" #include "third_party/blink/renderer/core/css/css_layer_block_rule.h" #include "third_party/blink/renderer/core/css/css_layer_statement_rule.h" +#include "third_party/blink/renderer/core/css/css_markup.h" #include "third_party/blink/renderer/core/css/css_media_rule.h" #include "third_party/blink/renderer/core/css/css_namespace_rule.h" #include "third_party/blink/renderer/core/css/css_page_rule.h" @@ -652,7 +653,7 @@ String StyleRuleBase::LayerNameAsString( if (result.length()) { result.Append("."); } - result.Append(part); + SerializeIdentifier(part, result); } return result.ReleaseString(); } diff --git a/blink/renderer/core/css/style_rule_font_feature_values.cc b/blink/renderer/core/css/style_rule_font_feature_values.cc index 4c9ead5597652d1292685a1f3b522fde682d0eae..1dfaf008609bcf47fcf53f1ff802ea6613a83e61 100644 --- a/blink/renderer/core/css/style_rule_font_feature_values.cc +++ b/blink/renderer/core/css/style_rule_font_feature_values.cc @@ -4,6 +4,7 @@ #include "third_party/blink/renderer/core/css/style_rule_font_feature_values.h" #include "third_party/blink/renderer/core/css/cascade_layer.h" +#include "third_party/blink/renderer/core/css/css_markup.h" #include "third_party/blink/renderer/platform/wtf/assertions.h" #include "third_party/blink/renderer/platform/wtf/text/string_builder.h" @@ -160,7 +161,7 @@ void StyleRuleFontFeatureValues::SetFamilies(Vector families) { String StyleRuleFontFeatureValues::FamilyAsString() const { StringBuilder families; for (wtf_size_t i = 0; i < families_.size(); ++i) { - families.Append(families_[i]); + families.Append(SerializeFontFamily(families_[i])); if (i < families_.size() - 1) { families.Append(", "); } diff --git a/blink/renderer/core/dom/document.cc b/blink/renderer/core/dom/document.cc index 2018b6b6d756b1444163dcc0426f589378c9f7a7..d68acd313e68180d8cc94c07738b86d40fac4b10 100644 --- a/blink/renderer/core/dom/document.cc +++ b/blink/renderer/core/dom/document.cc @@ -4323,11 +4323,11 @@ KURL Document::urlForBinding() const { } #if BUILDFLAG(IS_OHOS) - void Document::StartBoosting() { - OHOS::NWeb::OhosAdapterHelper::GetInstance() - .CreateSocPerfClientAdapter() - ->ApplySocPerfConfigByIdEx(OHOS::NWeb::SocPerfClientAdapter::SOC_PERF_WEB_GESTURE_ID, true); - } +void Document::StartBoosting() { + OHOS::NWeb::OhosAdapterHelper::GetInstance() + .CreateSocPerfClientAdapter() + ->ApplySocPerfConfigByIdEx(OHOS::NWeb::SocPerfClientAdapter::SOC_PERF_WEB_GESTURE_ID, true); +} #endif void Document::SetURL(const KURL& url) { @@ -4343,7 +4343,7 @@ void Document::SetURL(const KURL& url) { InNanoseconds() - base::ohos::TouchObserver::GetInstance().GetLastTouchUpTime() < MAX_TOUCH_UP_INTERVAL) { base::SingleThreadTaskRunner::GetCurrentDefault() ->PostDelayedTask(FROM_HERE, WTF::BindOnce(&Document::StartBoosting, - WrapWeakPersistent(this)), base::Milliseconds(LOAD_URL_DELAY_TIME)); + WrapWeakPersistent(this)), base::Milliseconds(LOAD_URL_DELAY_TIME)); } #endif diff --git a/blink/renderer/core/dom/node.h b/blink/renderer/core/dom/node.h index 6a7654b25fbd82af6b916bd8853ab2044981cbdc..b031c6ca9102fac7a5775ddb600a0a28a8d9ecfd 100644 --- a/blink/renderer/core/dom/node.h +++ b/blink/renderer/core/dom/node.h @@ -374,6 +374,11 @@ class CORE_EXPORT Node : public EventTarget { virtual bool IsMediaRemotingInterstitial() const { return false; } virtual bool IsPictureInPictureInterstitial() const { return false; } +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + virtual bool ShouldInterceptHitTest() const { return false; } + virtual bool ShouldOverlay() const { return false; } +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + // Traverses the ancestors of this node and returns true if any of them are // either a MediaControlElement or MediaControls. bool HasMediaControlAncestor() const; diff --git a/blink/renderer/core/editing/caret_display_item_client.cc b/blink/renderer/core/editing/caret_display_item_client.cc index 70621076ef660f01f100a14a3e687ba1e97b2f2a..d53b645bbc081465924792d296f9f8d3cf4c2cf8 100644 --- a/blink/renderer/core/editing/caret_display_item_client.cc +++ b/blink/renderer/core/editing/caret_display_item_client.cc @@ -278,17 +278,9 @@ void CaretDisplayItemClient::PaintCaret( } gfx::Rect paint_rect = ToPixelSnappedRect(drawing_rect); -#ifdef OHOS_INPUT_EVENTS - const int widthExtension = 2; - const RGBA32 kCaretColor = 0xFF0000FF; - Color color = Color::FromRGBA32(kCaretColor); - paint_rect.set_width(paint_rect.width() + widthExtension); - context.FillRect(paint_rect, color, AutoDarkMode::Disabled()); -#else context.FillRect(paint_rect, color_, PaintAutoDarkMode(layout_block_->StyleRef(), DarkModeFilter::ElementRole::kForeground)); -#endif } void CaretDisplayItemClient::RecordSelection( diff --git a/blink/renderer/core/editing/frame_selection.cc b/blink/renderer/core/editing/frame_selection.cc index 85d937aa85f1e491bb22d5506f3a1739f48d2bcb..88c41ebf975c94d51af48993a3911ae6e1dda9e5 100644 --- a/blink/renderer/core/editing/frame_selection.cc +++ b/blink/renderer/core/editing/frame_selection.cc @@ -1154,8 +1154,8 @@ gfx::Rect FrameSelection::ClippedSelectionBoundsInRootFrame() const { int top = std::min(selection_start_rect.top_right().y(), selection_end_rect.top_right().y()); selection_bounds = gfx::Rect(left, top, right - left, bottom - top); selection_bounds.Offset( - -(int)(frame_->GetPage()->GetVisualViewport().GetScrollOffset().x()), - -(int)(frame_->GetPage()->GetVisualViewport().GetScrollOffset().y())); + -(int)(frame_->GetPage()->GetVisualViewport().GetScrollOffset().x()), + -(int)(frame_->GetPage()->GetVisualViewport().GetScrollOffset().y())); return gfx::ScaleToEnclosingRect(selection_bounds, frame_->GetPage()->GetVisualViewport().Scale()); } #endif diff --git a/blink/renderer/core/editing/frame_selection.h b/blink/renderer/core/editing/frame_selection.h index 5d1796a4db7ae32058110ce19e2fc6609b803c08..2628a5acc1f9a8bac3f296d504a786d3d7227021 100644 --- a/blink/renderer/core/editing/frame_selection.h +++ b/blink/renderer/core/editing/frame_selection.h @@ -330,7 +330,7 @@ class CORE_EXPORT FrameSelection final void Trace(Visitor*) const override; #ifdef OHOS_CLIPBOARD - bool IsSelectAll() { return is_select_all_; } + bool IsSelectAll() const { return is_select_all_; } #endif // OHOS_CLIPBOARD #ifdef OHOS_DRAG_DROP diff --git a/blink/renderer/core/editing/selection_controller.cc b/blink/renderer/core/editing/selection_controller.cc index e7bb956e496f1a2e963da3e131e8a13671e27735..80fd10a561120fa48f71e2161ebced1dfd136e88 100644 --- a/blink/renderer/core/editing/selection_controller.cc +++ b/blink/renderer/core/editing/selection_controller.cc @@ -1619,7 +1619,7 @@ bool SelectionController::ShowSelectionByLastLongPressHitTestResult() { ContextMenuAllowedScope scope; frame_->GetEventHandler().ShowNonLocatedContextMenu( last_long_press_hit_test_result_.InnerElement(), - kMenuSourceSelectAndCopy); + kMenuSourceShowFreeCopyMenu); return true; } Node* inner_node = last_long_press_hit_test_result_.InnerNode(); @@ -1634,7 +1634,7 @@ bool SelectionController::ShowSelectionByLastLongPressHitTestResult() { if (did_select) { ContextMenuAllowedScope scope; frame_->GetEventHandler().ShowNonLocatedContextMenu( - nullptr, kMenuSourceSelectAndCopy); + nullptr, kMenuSourceShowFreeCopyMenu); return true; } diff --git a/blink/renderer/core/editing/selection_controller.h b/blink/renderer/core/editing/selection_controller.h index b9100d02b1ad0ca2d024915900f21b36e3b2237d..8ef1f06e3f5f4f7e9a60a70a4d3b38c5a58729e0 100644 --- a/blink/renderer/core/editing/selection_controller.h +++ b/blink/renderer/core/editing/selection_controller.h @@ -106,7 +106,7 @@ class CORE_EXPORT SelectionController final Document& GetDocument() const; -#if defined(OHOS_CLIPBOARD) +#ifdef OHOS_CLIPBOARD bool MouseSelectMenuShow(bool show); #endif diff --git a/blink/renderer/core/exported/web_document_subresource_filter_test.cc b/blink/renderer/core/exported/web_document_subresource_filter_test.cc index ae1798f448ede6f9b91d76c1dbec3141ed6cf915..fe63a0dfebeec0cf617f829aba37c1c708adb78f 100644 --- a/blink/renderer/core/exported/web_document_subresource_filter_test.cc +++ b/blink/renderer/core/exported/web_document_subresource_filter_test.cc @@ -43,51 +43,6 @@ class TestDocumentSubresourceFilter : public WebDocumentSubresourceFilter { return LoadPolicy::kAllow; } - #ifdef OHOS_ARKWEB_ADBLOCK - void ClearStatistics() override {} - - std::unique_ptr GetElementHidingSelectors( - const WebURL& document_url, - bool need_common_selectors) override { - return {}; - } - - bool HasGenericHideTypeOption( - const WebURL& document_url, - const url::Origin& parent_document_origin) override { - return false; - } - - bool HasElemHideTypeOption( - const WebURL& document_url, - const url::Origin& parent_document_origin) override { - return false; - } - - bool HasDocumentTypeOption( - const WebURL& document_url, - const url::Origin& parent_document_origin) override { - return false; - } - - void DidMatchCssRule(const WebURL& document_url, - const std::string& dom_path, - // unsigned rule_line_num = 0, - bool is_for_report = false) override {} - - void SetDidFinishLoad(bool did_load_finished) override {} - - bool GetDidFinishLoad() override { - return false; - } - - std::unique_ptr> GetUserDomPathSelectors( - const blink::WebURL& document_url, - bool need_generic_selectors) override { - return {}; - } - #endif - LoadPolicy GetLoadPolicyForWebSocketConnect(const WebURL& url) override { return kAllow; } diff --git a/blink/renderer/core/exported/web_settings_impl.cc b/blink/renderer/core/exported/web_settings_impl.cc index 4a22915ca750a209f02952d092659583f77074da..5281a009e253bc30627c9006ec41a858edf2fb1f 100644 --- a/blink/renderer/core/exported/web_settings_impl.cc +++ b/blink/renderer/core/exported/web_settings_impl.cc @@ -513,12 +513,6 @@ void WebSettingsImpl::SetContextMenuCustomization(bool enabled) { } #endif -#ifdef OHOS_EX_BLANK_TARGET_POPUP_INTERCEPT -void WebSettingsImpl::EnableBlankTargetPopupIntercept(bool enabled) { - settings_->EnableBlankTargetPopupIntercept(enabled); -} -#endif - #if BUILDFLAG(IS_OHOS) void WebSettingsImpl::SetNativeEmbedModeEnabled(bool enabled) { settings_->SetNativeEmbedModeEnabled(enabled); @@ -528,7 +522,6 @@ void WebSettingsImpl::RegisterNativeEmbedRule(const WebString& tag, const WebString& type) { settings_->RegisterNativeEmbedRule(tag, type); } - void WebSettingsImpl::SetDrawMode(int mode) { settings_->SetDrawMode(mode); } @@ -858,4 +851,13 @@ void WebSettingsImpl::SetCustomVideoPlayerOverlay(bool overlay) { settings_->SetCustomVideoPlayerOverlay(overlay); } #endif // OHOS_CUSTOM_VIDEO_PLAYER + +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT +void WebSettingsImpl::SetMediaNetworkTrafficPromptEnabled(bool enable) { + settings_->SetMediaNetworkTrafficPromptEnabled(enable); +} +void WebSettingsImpl::SetPlaybackWithMobileDataAllowed(bool allowed) { + settings_->SetPlaybackWithMobileDataAllowed(allowed); +} +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT } // namespace blink diff --git a/blink/renderer/core/exported/web_settings_impl.h b/blink/renderer/core/exported/web_settings_impl.h index 7b408f07396102efe4bfcffb0b0b82e7e7168313..8fb24741e90d5766f9ed3c9c6e40f7f49d8a7ac2 100644 --- a/blink/renderer/core/exported/web_settings_impl.h +++ b/blink/renderer/core/exported/web_settings_impl.h @@ -135,9 +135,6 @@ class CORE_EXPORT WebSettingsImpl final : public WebSettings { #endif // OHOS_SCROLLBAR #if defined(OHOS_EX_FREE_COPY) void SetContextMenuCustomization(bool) override; -#endif -#ifdef OHOS_EX_BLANK_TARGET_POPUP_INTERCEPT - void EnableBlankTargetPopupIntercept(bool) override; #endif void SetPasswordEchoDurationInSeconds(double) override; void SetPasswordEchoEnabled(bool) override; @@ -260,6 +257,11 @@ class CORE_EXPORT WebSettingsImpl final : public WebSettings { void SetCustomVideoPlayerOverlay(bool overlay) override; #endif // OHOS_CUSTOM_VIDEO_PLAYER +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + void SetMediaNetworkTrafficPromptEnabled(bool enable) override; + void SetPlaybackWithMobileDataAllowed(bool allowed) override; +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + bool RenderVSyncNotificationEnabled() const { return render_v_sync_notification_enabled_; } diff --git a/blink/renderer/core/exported/web_view_impl.cc b/blink/renderer/core/exported/web_view_impl.cc index 0cf2eb089c7795d4343667cf49ab2dde08acc621..3ee125664c3d418a8b0f11ff428837fc9ff3c56a 100644 --- a/blink/renderer/core/exported/web_view_impl.cc +++ b/blink/renderer/core/exported/web_view_impl.cc @@ -200,6 +200,10 @@ #include "content/public/common/content_switches.h" #endif +#ifdef OHOS_DISPLAY_CUTOUT +#include "third_party/blink/renderer/core/frame/display_cutout_client_impl.h" +#endif + // Get rid of WTF's pow define so we can use std::pow. #undef pow #include // for std::pow @@ -453,6 +457,55 @@ SkFontHinting RendererPreferencesToSkiaHinting( } #endif // !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_WIN) +void ApplyOhosWebPreferences(const web_pref::WebPreferences& prefs, + WebView* web_view, + WebSettings* settings, + WebViewImpl* web_view_impl) { +#if defined(OHOS_INPUT_EVENTS) + settings->SetVerticalHideScrollbars(prefs.hide_vertical_scrollbars); + settings->SetHorizontalHideScrollbars(prefs.hide_horizontal_scrollbars); + settings->SetScrollable(prefs.scroll_enabled); +#endif // defined(OHOS_INPUT_EVENTS) + +#if BUILDFLAG(IS_OHOS) + settings->SetNativeEmbedModeEnabled(prefs.native_embed_mode_enabled); + settings->RegisterNativeEmbedRule( + WebString::FromASCII(base::ToLowerASCII(prefs.embed_tag)), + WebString::FromASCII(base::ToLowerASCII(prefs.embed_tag_type))); + settings->SetDrawMode(prefs.draw_mode); +#endif // BUILDFLAG(IS_OHOS) + +#ifdef OHOS_SCROLLBAR + settings->SetScrollBarColor(prefs.scrollbar_color); +#endif // OHOS_SCROLLBAR + +#if defined(OHOS_EX_FREE_COPY) + settings->SetContextMenuCustomization( + prefs.contextmenu_customization_enabled); +#endif + +#if defined(OHOS_CLIPBOARD) + settings->SetCopyOption(prefs.copy_option); +#endif // defined(OHOS_CLIPBOARD) + +#if defined(OHOS_CUSTOM_VIDEO_PLAYER) + settings->SetCustomVideoPlayerEnabled(prefs.custom_video_player_enable); + settings->SetCustomVideoPlayerOverlay(prefs.custom_video_player_overlay); +#endif // OHOS_CUSTOM_VIDEO_PLAYER + +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + settings->SetMediaNetworkTrafficPromptEnabled( + prefs.enable_media_network_traffic_prompt); + settings->SetPlaybackWithMobileDataAllowed( + prefs.playback_with_mobile_data_allowed); +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + + +#if defined(OHOS_MEDIA) + settings->SetPreferHiddenVolumeControls(!base::ohos::IsPcDevice()); +#endif +} + } // namespace // WebView ---------------------------------------------------------------- @@ -1383,6 +1436,16 @@ void WebViewImpl::ResizeWithBrowserControls( size_.width() && ContentsSize().width() && main_frame_widget_size.width() != size_.width() && !fullscreen_controller_->IsFullscreenOrTransitioning(); +#ifdef OHOS_PAGE_UP_DOWN + if (!base::ohos::IsPcDevice()) { + bool is_width_height_change_diff = + (main_frame_widget_size.width() - size_.width()) * + (main_frame_widget_size.height() - size_.height()) < 0; + is_rotation = is_rotation && is_width_height_change_diff; + LOG(DEBUG)<<"when resize, is_rotation is "<IsOutermostMainFrame()) { @@ -1570,28 +1633,6 @@ void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs, RuntimeEnabledFeatures::SetWebKitScrollbarStylingEnabled( prefs.enable_webkit_scrollbar_styling); -#if defined(OHOS_INPUT_EVENTS) - settings->SetVerticalHideScrollbars(prefs.hide_vertical_scrollbars); - settings->SetHorizontalHideScrollbars(prefs.hide_horizontal_scrollbars); - settings->SetScrollable(prefs.scroll_enabled); -#endif // defined(OHOS_INPUT_EVENTS) - -#if BUILDFLAG(IS_OHOS) - settings->SetNativeEmbedModeEnabled(prefs.native_embed_mode_enabled); - settings->RegisterNativeEmbedRule( - WebString::FromASCII(base::ToLowerASCII(prefs.embed_tag)), - WebString::FromASCII(base::ToLowerASCII(prefs.embed_tag_type))); - settings->SetDrawMode(prefs.draw_mode); -#endif // BUILDFLAG(IS_OHOS) - -#ifdef OHOS_SCROLLBAR - settings->SetScrollBarColor(prefs.scrollbar_color); -#endif // OHOS_SCROLLBAR - -#if defined(OHOS_EX_FREE_COPY) - settings->SetContextMenuCustomization( - prefs.contextmenu_customization_enabled); -#endif // Enable gpu-accelerated 2d canvas if requested on the command line. RuntimeEnabledFeatures::SetAccelerated2dCanvasEnabled( prefs.accelerated_2d_canvas_enabled); @@ -1704,37 +1745,13 @@ void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs, settings->SetTextTrackWindowRadius( WebString::FromASCII(prefs.text_track_window_radius)); -#if defined(OHOS_CLIPBOARD) - settings->SetCopyOption(prefs.copy_option); -#endif // defined(OHOS_CLIPBOARD) - -#if defined(OHOS_VIEWPORT) || defined(OHOS_MEDIA) - bool is_2in1_device = base::CommandLine::ForCurrentProcess() - ->HasSwitch(::switches::kWebViewImplForLargeScreen); -#endif // defined(OHOS_VIEWPORT) || defined(OHOS_MEDIA) - // Needs to happen before SetDefaultPageScaleLimits below since that'll // recalculate the final page scale limits and that depends on this setting. -#if defined(OHOS_VIEWPORT) - if (is_2in1_device) { - settings->SetShrinksViewportContentToFit(false); - // Needs to happen before SetIgnoreViewportTagScaleLimits below. - web_view->SetDefaultPageScaleLimits(1.f, 4.f); - } else { - settings->SetShrinksViewportContentToFit( - prefs.shrinks_viewport_contents_to_fit); - // Needs to happen before SetIgnoreViewportTagScaleLimits below. - web_view->SetDefaultPageScaleLimits( - prefs.default_minimum_page_scale_factor, - prefs.default_maximum_page_scale_factor); - } -#else settings->SetShrinksViewportContentToFit( prefs.shrinks_viewport_contents_to_fit); // Needs to happen before SetIgnoreViewportTagScaleLimits below. web_view->SetDefaultPageScaleLimits(prefs.default_minimum_page_scale_factor, prefs.default_maximum_page_scale_factor); -#endif // #ifdef OHOS_VIEWPORT settings->SetFullscreenSupported(prefs.fullscreen_supported); settings->SetTextAutosizingEnabled(prefs.text_autosizing_enabled); @@ -1748,69 +1765,60 @@ void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs, settings->SetWebAppScope(WebString::FromASCII(prefs.web_app_scope.spec())); #if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) - settings->SetAllowCustomScrollbarInMainFrame(false); - settings->SetAccessibilityFontScaleFactor(prefs.font_scale_factor); - settings->SetDeviceScaleAdjustment(prefs.device_scale_adjustment); - web_view_impl->SetIgnoreViewportTagScaleLimits(prefs.force_enable_zoom); - settings->SetDefaultVideoPosterURL( - WebString::FromASCII(prefs.default_video_poster_url.spec())); - settings->SetSupportDeprecatedTargetDensityDPI( - prefs.support_deprecated_target_density_dpi); - settings->SetUseLegacyBackgroundSizeShorthandBehavior( - prefs.use_legacy_background_size_shorthand_behavior); - settings->SetWideViewportQuirkEnabled(prefs.wide_viewport_quirk); - settings->SetUseWideViewport(prefs.use_wide_viewport); - settings->SetForceZeroLayoutHeight(prefs.force_zero_layout_height); - settings->SetViewportMetaMergeContentQuirk( - prefs.viewport_meta_merge_content_quirk); - settings->SetViewportMetaNonUserScalableQuirk( - prefs.viewport_meta_non_user_scalable_quirk); - settings->SetViewportMetaZeroValuesQuirk( - prefs.viewport_meta_zero_values_quirk); - settings->SetClobberUserAgentInitialScaleQuirk( - prefs.clobber_user_agent_initial_scale_quirk); - settings->SetIgnoreMainFrameOverflowHiddenQuirk( - prefs.ignore_main_frame_overflow_hidden_quirk); - settings->SetReportScreenSizeInPhysicalPixelsQuirk( - prefs.report_screen_size_in_physical_pixels_quirk); - settings->SetShouldReuseGlobalForUnownedMainFrame( - prefs.reuse_global_for_unowned_main_frame); -#if defined(OHOS_MEDIA) - if (is_2in1_device) { - settings->SetPreferHiddenVolumeControls(false); - } else { + if (!base::ohos::IsPcDevice()) { + settings->SetAllowCustomScrollbarInMainFrame(false); + settings->SetAccessibilityFontScaleFactor(prefs.font_scale_factor); + settings->SetDeviceScaleAdjustment(prefs.device_scale_adjustment); + web_view_impl->SetIgnoreViewportTagScaleLimits(prefs.force_enable_zoom); + settings->SetDefaultVideoPosterURL( + WebString::FromASCII(prefs.default_video_poster_url.spec())); + settings->SetSupportDeprecatedTargetDensityDPI( + prefs.support_deprecated_target_density_dpi); + settings->SetUseLegacyBackgroundSizeShorthandBehavior( + prefs.use_legacy_background_size_shorthand_behavior); + settings->SetWideViewportQuirkEnabled(prefs.wide_viewport_quirk); + settings->SetUseWideViewport(prefs.use_wide_viewport); + settings->SetForceZeroLayoutHeight(prefs.force_zero_layout_height); + settings->SetViewportMetaMergeContentQuirk( + prefs.viewport_meta_merge_content_quirk); + settings->SetViewportMetaNonUserScalableQuirk( + prefs.viewport_meta_non_user_scalable_quirk); + settings->SetViewportMetaZeroValuesQuirk( + prefs.viewport_meta_zero_values_quirk); + settings->SetClobberUserAgentInitialScaleQuirk( + prefs.clobber_user_agent_initial_scale_quirk); + settings->SetIgnoreMainFrameOverflowHiddenQuirk( + prefs.ignore_main_frame_overflow_hidden_quirk); + settings->SetReportScreenSizeInPhysicalPixelsQuirk( + prefs.report_screen_size_in_physical_pixels_quirk); + settings->SetShouldReuseGlobalForUnownedMainFrame( + prefs.reuse_global_for_unowned_main_frame); settings->SetPreferHiddenVolumeControls(true); + settings->SetSpellCheckEnabledByDefault( + prefs.spellcheck_enabled_by_default); + + RuntimeEnabledFeatures::SetVideoFullscreenOrientationLockEnabled( + prefs.video_fullscreen_orientation_lock_enabled); + RuntimeEnabledFeatures::SetVideoRotateToFullscreenEnabled( + prefs.video_rotate_to_fullscreen_enabled); + settings->SetEmbeddedMediaExperienceEnabled( + prefs.embedded_media_experience_enabled); + settings->SetImmersiveModeEnabled(prefs.immersive_mode_enabled); + settings->SetDoNotUpdateSelectionOnMutatingSelectionRange( + prefs.do_not_update_selection_on_mutating_selection_range); + RuntimeEnabledFeatures::SetCSSHexAlphaColorEnabled( + prefs.css_hex_alpha_color_enabled); + RuntimeEnabledFeatures::SetScrollTopLeftInteropEnabled( + prefs.scroll_top_left_interop_enabled); + RuntimeEnabledFeatures::SetAcceleratedSmallCanvasesEnabled( + !prefs.disable_accelerated_small_canvases); } -#else - settings->SetPreferHiddenVolumeControls(true); -#endif // defined(OHOS_MEDIA) - settings->SetSpellCheckEnabledByDefault(prefs.spellcheck_enabled_by_default); - - RuntimeEnabledFeatures::SetVideoFullscreenOrientationLockEnabled( - prefs.video_fullscreen_orientation_lock_enabled); - RuntimeEnabledFeatures::SetVideoRotateToFullscreenEnabled( - prefs.video_rotate_to_fullscreen_enabled); - settings->SetEmbeddedMediaExperienceEnabled( - prefs.embedded_media_experience_enabled); - settings->SetImmersiveModeEnabled(prefs.immersive_mode_enabled); - settings->SetDoNotUpdateSelectionOnMutatingSelectionRange( - prefs.do_not_update_selection_on_mutating_selection_range); - RuntimeEnabledFeatures::SetCSSHexAlphaColorEnabled( - prefs.css_hex_alpha_color_enabled); - RuntimeEnabledFeatures::SetScrollTopLeftInteropEnabled( - prefs.scroll_top_left_interop_enabled); - RuntimeEnabledFeatures::SetAcceleratedSmallCanvasesEnabled( - !prefs.disable_accelerated_small_canvases); #endif // BUILDFLAG(IS_ANDROID) #if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) RuntimeEnabledFeatures::SetWebAuthEnabled(!prefs.disable_webauthn); #endif // BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) -#ifdef OHOS_EX_BLANK_TARGET_POPUP_INTERCEPT - settings->EnableBlankTargetPopupIntercept( - prefs.blank_target_popup_intercept_enabled); -#endif settings->SetForceDarkModeEnabled(prefs.force_dark_mode_enabled); settings->SetAccessibilityAlwaysShowFocus(prefs.always_show_focus); @@ -1820,19 +1828,8 @@ void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs, settings->SetRequireTransientActivationForShowFileOrDirectoryPicker( prefs.require_transient_activation_for_show_file_or_directory_picker); settings->SetViewportEnabled(prefs.viewport_enabled); - -#ifdef OHOS_VIEWPORT - if (is_2in1_device) { - settings->SetViewportMetaEnabled(false); - settings->SetViewportStyle(mojom::ViewportStyle::kDefault); - } else { - settings->SetViewportMetaEnabled(prefs.viewport_meta_enabled); - settings->SetViewportStyle(prefs.viewport_style); - } -#else settings->SetViewportMetaEnabled(prefs.viewport_meta_enabled); settings->SetViewportStyle(prefs.viewport_style); -#endif // #ifdef OHOS_VIEWPORT settings->SetAutoZoomFocusedEditableToLegibleScale( prefs.auto_zoom_focused_editable_to_legible_scale); @@ -1975,12 +1972,9 @@ void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs, } #if BUILDFLAG(IS_OHOS) - web_view_impl->SetPinchSmoothMode(prefs.pinch_smooth_mode); + ApplyOhosWebPreferences(prefs, web_view, settings, web_view_impl); #endif // BUILDFLAG(IS_OHOS) -#if defined(OHOS_CUSTOM_VIDEO_PLAYER) - settings->SetCustomVideoPlayerEnabled(prefs.custom_video_player_enable); - settings->SetCustomVideoPlayerOverlay(prefs.custom_video_player_overlay); -#endif // OHOS_CUSTOM_VIDEO_PLAYER + } void WebViewImpl::ThemeChanged() { @@ -3857,6 +3851,12 @@ void WebViewImpl::PageScaleFactorChanged() { SetDeviceEmulationTransform(device_emulation_transform); } } + +#ifdef OHOS_DISPLAY_CUTOUT + if (auto* local_frame = DynamicTo(GetPage()->MainFrame())) { + DisplayCutoutClientImpl::UpdateSafeArea(local_frame); + } +#endif } void WebViewImpl::OutermostMainFrameScrollOffsetChanged() { diff --git a/blink/renderer/core/frame/csp/execution_context_csp_delegate.cc b/blink/renderer/core/frame/csp/execution_context_csp_delegate.cc index c6e4f9dbd23c2802fb8ffd443676838fd77b84fb..4bfc5df42dd89f2192aa9b8c18cb758648e68918 100644 --- a/blink/renderer/core/frame/csp/execution_context_csp_delegate.cc +++ b/blink/renderer/core/frame/csp/execution_context_csp_delegate.cc @@ -199,7 +199,8 @@ void ExecutionContextCSPDelegate::PostViolationReport( for (const auto& report_endpoint : report_endpoints) { PingLoader::SendViolationReport(execution_context_.Get(), - KURL(report_endpoint), report); + KURL(report_endpoint), report, + is_frame_ancestors_violation); } } diff --git a/blink/renderer/core/frame/display_cutout_client_impl.cc b/blink/renderer/core/frame/display_cutout_client_impl.cc index e72e483ac1fef87d033c9ed8aadb9359fb1d8305..9ad8d5640667e4b3ec3b8571d908bd89fff235ff 100644 --- a/blink/renderer/core/frame/display_cutout_client_impl.cc +++ b/blink/renderer/core/frame/display_cutout_client_impl.cc @@ -8,6 +8,11 @@ #include "third_party/blink/renderer/core/css/style_engine.h" #include "third_party/blink/renderer/core/frame/local_frame.h" +#ifdef OHOS_DISPLAY_CUTOUT +#include "third_party/blink/renderer/core/page/page.h" +#include "ui/gfx/geometry/insets.h" +#endif + namespace blink { DisplayCutoutClientImpl::DisplayCutoutClientImpl( @@ -24,12 +29,36 @@ void DisplayCutoutClientImpl::BindMojoReceiver( MakeGarbageCollected(frame, std::move(receiver)); } +#ifdef OHOS_DISPLAY_CUTOUT +void DisplayCutoutClientImpl::UpdateSafeArea(LocalFrame* frame) { + if (!frame || !frame->GetDocument() || !frame->GetPage()) return; + + DocumentStyleEnvironmentVariables& vars = + frame->GetDocument()->GetStyleEngine().EnsureEnvironmentVariables(); + gfx::Insets safe_area = frame->GetPage()->SafeAreaScaled(); + LOG(DEBUG) << __func__ << " " << safe_area.ToString();; + + vars.SetVariable(UADefinedVariable::kSafeAreaInsetTop, + StyleEnvironmentVariables::FormatPx(safe_area.top())); + vars.SetVariable(UADefinedVariable::kSafeAreaInsetLeft, + StyleEnvironmentVariables::FormatPx(safe_area.left())); + vars.SetVariable(UADefinedVariable::kSafeAreaInsetBottom, + StyleEnvironmentVariables::FormatPx(safe_area.bottom())); + vars.SetVariable(UADefinedVariable::kSafeAreaInsetRight, + StyleEnvironmentVariables::FormatPx(safe_area.right())); +} +#endif + void DisplayCutoutClientImpl::SetSafeArea(const gfx::Insets& safe_area) { +#ifdef OHOS_DISPLAY_CUTOUT + if (frame_->GetPage()) { + frame_->GetPage()->SetSafeArea(safe_area); + } + DisplayCutoutClientImpl::UpdateSafeArea(frame_); +#else DocumentStyleEnvironmentVariables& vars = frame_->GetDocument()->GetStyleEngine().EnsureEnvironmentVariables(); -#ifdef OHOS_DISPLAY_CUTOUT - LOG(INFO) << __func__ << " " << safe_area.ToString(); -#endif + vars.SetVariable(UADefinedVariable::kSafeAreaInsetTop, StyleEnvironmentVariables::FormatPx(safe_area.top())); vars.SetVariable(UADefinedVariable::kSafeAreaInsetLeft, @@ -38,6 +67,7 @@ void DisplayCutoutClientImpl::SetSafeArea(const gfx::Insets& safe_area) { StyleEnvironmentVariables::FormatPx(safe_area.bottom())); vars.SetVariable(UADefinedVariable::kSafeAreaInsetRight, StyleEnvironmentVariables::FormatPx(safe_area.right())); +#endif } void DisplayCutoutClientImpl::Trace(Visitor* visitor) const { diff --git a/blink/renderer/core/frame/display_cutout_client_impl.h b/blink/renderer/core/frame/display_cutout_client_impl.h index 2549f6ce8fe87364b02d673ad4d2253989d6df37..ad733e464b8edca388e0d45e7374ea54414d68ca 100644 --- a/blink/renderer/core/frame/display_cutout_client_impl.h +++ b/blink/renderer/core/frame/display_cutout_client_impl.h @@ -37,6 +37,10 @@ class CORE_EXPORT DisplayCutoutClientImpl final void Trace(Visitor*) const; +#ifdef OHOS_DISPLAY_CUTOUT + static void UpdateSafeArea(LocalFrame* frame); +#endif + private: Member frame_; diff --git a/blink/renderer/core/frame/frame_test_helpers.h b/blink/renderer/core/frame/frame_test_helpers.h index 46866b60f7d965181150da0f1a14f20a551b0ae3..d130273ff73af0a231caed10cdc06cf7a44f2fb6 100644 --- a/blink/renderer/core/frame/frame_test_helpers.h +++ b/blink/renderer/core/frame/frame_test_helpers.h @@ -220,8 +220,6 @@ class TestWebFrameWidgetHost : public mojom::blink::WidgetHost, #if defined(OHOS_UNITTESTS) void DidNativeEmbedEvent(mojom::blink::NativeEmbedTouchEventPtr event) override {} void GetWordSelection(const WTF::String& text, int8_t offset, GetWordSelectionCallback callback) override {} - void CreateOverlay(const ::SkBitmap& image, const ::gfx::Rect& image_rect, - const ::gfx::Point& touch_point) override {} #endif // OHOS_UNITTESTS private: size_t cursor_set_count_ = 0; diff --git a/blink/renderer/core/frame/frame_view.cc b/blink/renderer/core/frame/frame_view.cc index 9d6a766499b211515d34b04963e52dbb7742d335..b075eee82c166256cf0f179708f276288af6af07 100644 --- a/blink/renderer/core/frame/frame_view.cc +++ b/blink/renderer/core/frame/frame_view.cc @@ -81,6 +81,9 @@ void FrameView::UpdateViewportIntersection(unsigned flags, occlusion_state == mojom::blink::FrameOcclusionState::kGuaranteedNotOccluded && parent_lifecycle_state >= DocumentLifecycle::kPrePaintClean; + if (!should_compute_occlusion) { + occlusion_state = mojom::blink::FrameOcclusionState::kUnknown; + } LayoutEmbeddedContent* owner_layout_object = owner_element->GetLayoutEmbeddedContent(); diff --git a/blink/renderer/core/frame/fullscreen_controller.cc b/blink/renderer/core/frame/fullscreen_controller.cc index 20d73ca49f4084c2e07aa68cf0b18d5301fa02d8..dd51e003182ee97c9abd3ae2ac1daa3be32838af 100644 --- a/blink/renderer/core/frame/fullscreen_controller.cc +++ b/blink/renderer/core/frame/fullscreen_controller.cc @@ -273,7 +273,7 @@ void FullscreenController::FullscreenElementChanged( if (new_element) { DCHECK(Fullscreen::IsFullscreenElement(*new_element)); -#if defined(OHOS_MEDIA) +#ifdef OHOS_MEDIA LOG(WARNING) << "OhMedia::FullscreenElementChanged new_element = " << new_element->localName(); #endif // OHOS_MEDIA @@ -285,7 +285,7 @@ void FullscreenController::FullscreenElementChanged( if (old_element) { DCHECK(!Fullscreen::IsFullscreenElement(*old_element)); -#if defined(OHOS_MEDIA) +#ifdef OHOS_MEDIA LOG(WARNING) << "OhMedia::FullscreenElementChanged old_element = " << old_element->localName(); #endif // OHOS_MEDIA diff --git a/blink/renderer/core/frame/local_frame.cc b/blink/renderer/core/frame/local_frame.cc index 792ccaa2c74faa35dab1750ea25b7903f64b7f63..79ac3a4b45e433e28bd3a29d144a457c41060c99 100644 --- a/blink/renderer/core/frame/local_frame.cc +++ b/blink/renderer/core/frame/local_frame.cc @@ -228,6 +228,10 @@ #include "third_party/blink/renderer/core/frame/window_controls_overlay_changed_delegate.h" #endif +#if BUILDFLAG(IS_OHOS) +#include "base/ohos/sys_info_utils.h" +#endif + namespace blink { namespace { @@ -1400,6 +1404,28 @@ void LocalFrame::SetPageAndTextZoomFactors(float page_zoom_factor, bool page_zoom_changed = (page_zoom_factor != page_zoom_factor_); +#if BUILDFLAG(IS_OHOS) + if (base::ohos::IsTabletDevice()) { + float zoom_factor_for_device_scale = + page->GetChromeClient().ZoomFactorForViewportLayout(); + zoom_factor_for_device_scale = + zoom_factor_for_device_scale ? zoom_factor_for_device_scale : 1; + float current_zoom_factor = page_zoom_factor / zoom_factor_for_device_scale; + if (page_zoom_changed && current_zoom_factor > 1.0f && + !scale_limits_min_changed_) { + scale_limits_min_changed_ = true; + page->ResetPageScaleConstraints(false); + scale_limits_max_changed_ = false; + } + if (page_zoom_changed && current_zoom_factor <= 1.0f && + !scale_limits_max_changed_) { + scale_limits_max_changed_ = true; + page->ResetPageScaleConstraints(true); + scale_limits_min_changed_ = false; + } + } +#endif + page_zoom_factor_ = page_zoom_factor; text_zoom_factor_ = text_zoom_factor; @@ -2678,8 +2704,12 @@ void LocalFrame::LoadJavaScriptURL(const KURL& url) { // Protect privileged pages against bookmarklets and other JavaScript // manipulations. if (SchemeRegistry::ShouldTreatURLSchemeAsNotAllowingJavascriptURLs( - GetDocument()->Url().Protocol())) + GetSecurityContext() + ->GetSecurityOrigin() + ->GetOriginOrPrecursorOriginIfOpaque() + ->Protocol())) { return; + } // TODO(mustaq): This is called only through the user typing a javascript URL // into the omnibox. See https://crbug.com/1082900 diff --git a/blink/renderer/core/frame/local_frame.h b/blink/renderer/core/frame/local_frame.h index 8b7339c6a21905dfc95ecab84f6428a77e6c1178..56637e8eae8a42c41b1523da1ba2a1d72d7a99a7 100644 --- a/blink/renderer/core/frame/local_frame.h +++ b/blink/renderer/core/frame/local_frame.h @@ -1141,6 +1141,11 @@ class CORE_EXPORT LocalFrame final window_controls_overlay_changed_delegate_; #endif +#if BUILDFLAG(IS_OHOS) + bool scale_limits_max_changed_ = false; + bool scale_limits_min_changed_ = false; +#endif + // The evidence for or against a frame being an ad frame. `absl::nullopt` if // not yet set or if the frame is a subfiltering root frame. (Only non-root // frames can be tagged as ad frames.) This is per-frame (as opposed to diff --git a/blink/renderer/core/frame/local_frame_client.h b/blink/renderer/core/frame/local_frame_client.h index 5e67d33036bb8fb094349aafc994e3371bcd719e..ab9d222dfde23184faa53a63633150cacb390cc8 100644 --- a/blink/renderer/core/frame/local_frame_client.h +++ b/blink/renderer/core/frame/local_frame_client.h @@ -66,6 +66,7 @@ #include "third_party/blink/renderer/core/frame/frame_client.h" #include "third_party/blink/renderer/core/frame/frame_types.h" #include "third_party/blink/renderer/core/html/link_resource.h" +#include "third_party/blink/renderer/core/layout/geometry/physical_offset.h" #include "third_party/blink/renderer/core/loader/document_loader.h" #include "third_party/blink/renderer/core/loader/frame_load_request.h" #include "third_party/blink/renderer/core/loader/frame_loader_types.h" diff --git a/blink/renderer/core/frame/local_frame_client_impl.cc b/blink/renderer/core/frame/local_frame_client_impl.cc index 1c4e78f71b90c175a1beeb560545f2d63300ddb9..f4107f777a7b569ef0b799415eb47684d4346e31 100644 --- a/blink/renderer/core/frame/local_frame_client_impl.cc +++ b/blink/renderer/core/frame/local_frame_client_impl.cc @@ -956,8 +956,7 @@ std::unique_ptr LocalFrameClientImpl::CreateWebMediaPlayer( } #if BUILDFLAG(IS_OHOS) -std::unique_ptr -LocalFrameClientImpl::CreateWebNativeBridge( +std::unique_ptr LocalFrameClientImpl::CreateWebNativeBridge( NativeLoader& native_loader, WebNativeClient* client) { WebLocalFrameImpl* web_frame = diff --git a/blink/renderer/core/frame/local_frame_view.cc b/blink/renderer/core/frame/local_frame_view.cc index 91d02545615e224704cea3de393ccdc229b905b9..30e57c2e1dacb4eb1ad74c8bd9dc76afbe945d15 100644 --- a/blink/renderer/core/frame/local_frame_view.cc +++ b/blink/renderer/core/frame/local_frame_view.cc @@ -3072,7 +3072,7 @@ void LocalFrameView::PushPaintArtifactToCompositor(bool repainted) { if (!paint_artifact_compositor_) { paint_artifact_compositor_ = std::make_unique( - page->GetScrollingCoordinator()->GetWeakPtr()); + page->GetScrollingCoordinator()->GetScrollCallbacks()); page->GetChromeClient().AttachRootLayer( paint_artifact_compositor_->RootLayer(), &GetFrame()); } @@ -4311,21 +4311,29 @@ void LocalFrameView::CollectAnnotatedRegions( bool LocalFrameView::UpdateViewportIntersectionsForSubtree( unsigned parent_flags, absl::optional& monotonic_time) { + // This will be recomputed, but default to the previous computed value if + // there's an early return. + bool needs_occlusion_tracking = false; + IntersectionObserverController* controller = + GetFrame().GetDocument()->GetIntersectionObserverController(); + if (controller) { + needs_occlusion_tracking = controller->NeedsOcclusionTracking(); + } + // TODO(dcheng): Since LocalFrameView tree updates are deferred, FrameViews // might still be in the LocalFrameView hierarchy even though the associated // Document is already detached. Investigate if this check and a similar check // in lifecycle updates are still needed when there are no more deferred // LocalFrameView updates: https://crbug.com/561683 - if (!GetFrame().GetDocument()->IsActive()) - return false; + if (!GetFrame().GetDocument()->IsActive()){ + return needs_occlusion_tracking; + } unsigned flags = GetIntersectionObservationFlags(parent_flags); - bool needs_occlusion_tracking = false; if (!NeedsLayout() || IsDisplayLocked()) { // Notify javascript IntersectionObservers - if (IntersectionObserverController* controller = - GetFrame().GetDocument()->GetIntersectionObserverController()) { + if (controller) { needs_occlusion_tracking |= controller->ComputeIntersections( flags, GetUkmAggregator(), monotonic_time); } diff --git a/blink/renderer/core/frame/remote_frame_view.cc b/blink/renderer/core/frame/remote_frame_view.cc index 2816c041c0f7f581383c3baacbf46ec612cbceb8..77d5540a032ab780b471a18e8301544172b73a6f 100644 --- a/blink/renderer/core/frame/remote_frame_view.cc +++ b/blink/renderer/core/frame/remote_frame_view.cc @@ -122,8 +122,10 @@ void RemoteFrameView::SetNeedsOcclusionTracking(bool needs_tracking) { return; needs_occlusion_tracking_ = needs_tracking; if (needs_tracking) { - if (LocalFrameView* parent_view = ParentLocalRootFrameView()) + if (LocalFrameView* parent_view = ParentLocalRootFrameView()) { + parent_view->SetIntersectionObservationState(LocalFrameView::kRequired); parent_view->ScheduleAnimation(); + } } } @@ -265,7 +267,6 @@ void RemoteFrameView::Dispose() { // RemoteFrameView is disconnected before detachment. if (owner_element && owner_element->OwnedEmbeddedContentView() == this) owner_element->SetEmbeddedContentView(nullptr); - SetNeedsOcclusionTracking(false); } void RemoteFrameView::SetFrameRect(const gfx::Rect& rect) { diff --git a/blink/renderer/core/frame/root_frame_viewport.cc b/blink/renderer/core/frame/root_frame_viewport.cc index 8d8525fb87c8b3e54150f342cafe09788ab5c20b..7a23cd03e7b9505c17054024d5d4b406f046298e 100644 --- a/blink/renderer/core/frame/root_frame_viewport.cc +++ b/blink/renderer/core/frame/root_frame_viewport.cc @@ -367,6 +367,7 @@ PhysicalRect RootFrameViewport::ScrollIntoView( PhysicalRect rect_in_document = rect_in_absolute; rect_in_document.Move( PhysicalOffset::FromVector2dFFloor(LayoutViewport().GetScrollOffset())); + #ifdef OHOS_CLIPBOARD ScrollOffset new_scroll_offset = ClampScrollOffset(ScrollAlignment::GetScrollOffsetToExpose( @@ -378,6 +379,7 @@ PhysicalRect RootFrameViewport::ScrollIntoView( scroll_snapport_rect, rect_in_document, *params->align_x.get(), *params->align_y.get(), GetScrollOffset())); #endif + if (params->type == mojom::blink::ScrollType::kUser) new_scroll_offset = ClampToUserScrollableOffset(new_scroll_offset); diff --git a/blink/renderer/core/frame/settings.h b/blink/renderer/core/frame/settings.h index 3d540a7ea5c84cd51c760ad015dc3dd74ce7b086..fa7c18e3c0a037942a31a70c413fdc12b0bde0d4 100644 --- a/blink/renderer/core/frame/settings.h +++ b/blink/renderer/core/frame/settings.h @@ -125,16 +125,6 @@ class CORE_EXPORT Settings { } #endif -#ifdef OHOS_EX_BLANK_TARGET_POPUP_INTERCEPT - void EnableBlankTargetPopupIntercept(bool enabled) { - blank_target_popup_intercept_enabled_ = enabled; - } - - bool IsBlankTargetPopupInterceptEnabled() const { - return blank_target_popup_intercept_enabled_; - } -#endif - void SetDelegate(SettingsDelegate*); #if defined(OHOS_CLIPBOARD) @@ -148,20 +138,35 @@ class CORE_EXPORT Settings { #endif // defined(OHOS_CLIPBOARD) #if defined(OHOS_CUSTOM_VIDEO_PLAYER) -void SetCustomVideoPlayerEnabled(bool enable) { - custom_video_player_enabled_ = enable; -} -bool IsCustomVideoPlayerEnabled() const { - return custom_video_player_enabled_; -} -void SetCustomVideoPlayerOverlay(bool overlay) { - custom_video_player_overlay_ = overlay; -} -bool IsCustomVideoPlayerOverlay() const { - return custom_video_player_overlay_; -} + void SetCustomVideoPlayerEnabled(bool enable) { + custom_video_player_enabled_ = enable; + } + bool IsCustomVideoPlayerEnabled() const { + return custom_video_player_enabled_; + } + void SetCustomVideoPlayerOverlay(bool overlay) { + custom_video_player_overlay_ = overlay; + } + bool IsCustomVideoPlayerOverlay() const { + return custom_video_player_overlay_; + } #endif // OHOS_CUSTOM_VIDEO_PLAYER +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + void SetMediaNetworkTrafficPromptEnabled(bool enable) { + media_network_traffic_prompt_enabled_ = enable; + } + bool IsMediaNetworkTrafficPromptEnabled() { + return media_network_traffic_prompt_enabled_; + } + void SetPlaybackWithMobileDataAllowed(bool allowed) { + playback_with_mobile_data_allowed_ = allowed; + } + bool IsPlaybackWithMobileDataAllowed() { + return playback_with_mobile_data_allowed_; + } +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + private: void Invalidate(SettingsDelegate::ChangeType); @@ -186,10 +191,6 @@ bool IsCustomVideoPlayerOverlay() const { bool contextmenu_customization_enabled_ = false; #endif // OHOS_EX_FREE_COPY -#ifdef OHOS_EX_BLANK_TARGET_POPUP_INTERCEPT - bool blank_target_popup_intercept_enabled_ = true; -#endif - #if BUILDFLAG(IS_OHOS) std::map embed_rule_; #endif @@ -202,6 +203,11 @@ bool IsCustomVideoPlayerOverlay() const { bool custom_video_player_enabled_ = false; bool custom_video_player_overlay_ = false; #endif // OHOS_CUSTOM_VIDEO_PLAYER + +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + bool media_network_traffic_prompt_enabled_ = false; + bool playback_with_mobile_data_allowed_ = false; +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT }; } // namespace blink diff --git a/blink/renderer/core/frame/web_frame_test.cc b/blink/renderer/core/frame/web_frame_test.cc index 6a11456ddfddf59eb5843047ad2d288d9fe7becc..9af4445cc9ea63c351ee9065e48ea2d077582f47 100644 --- a/blink/renderer/core/frame/web_frame_test.cc +++ b/blink/renderer/core/frame/web_frame_test.cc @@ -321,7 +321,12 @@ class WebFrameTest : public testing::Test { WebFrameTest() : base_url_("http://internal.test/"), not_base_url_("http://external.test/"), - chrome_url_("chrome://") {} + chrome_url_("chrome://test/") { + // This is needed so that a chrome: URL's origin is computed correctly, + // which is needed for Javascript URL security checks to work properly in + // tests below. + url::AddStandardScheme("chrome", url::SCHEME_WITH_HOST); + } ~WebFrameTest() override { url_test_helpers::UnregisterAllURLsAndClearMemoryCache(); @@ -499,6 +504,7 @@ class WebFrameTest : public testing::Test { std::string chrome_url_; ScopedTestingPlatformSupport platform_; + url::ScopedSchemeRegistryForTests scoped_registry_; }; TEST_F(WebFrameTest, ContentText) { diff --git a/blink/renderer/core/frame/web_frame_widget_impl.cc b/blink/renderer/core/frame/web_frame_widget_impl.cc index ca267c0337e6b3116def69ce9af48ce2d1362c81..03f9a45e4ad9094b4bb55084f461b293878e5d22 100644 --- a/blink/renderer/core/frame/web_frame_widget_impl.cc +++ b/blink/renderer/core/frame/web_frame_widget_impl.cc @@ -2698,7 +2698,8 @@ WebInputEventResult WebFrameWidgetImpl::HandleInputEvent( DCHECK(!WebInputEvent::IsTouchEventType(input_event.GetType())); CHECK(LocalRootImpl()); - if (input_event.GetType() == WebInputEvent::Type::kPointerUp) { + if (input_event.GetType() == WebInputEvent::Type::kPointerUp || + input_event.GetType() == WebInputEvent::Type::kKeyUp) { base::ohos::TouchObserver::GetInstance(). SetTouchUpTime(::base::subtle::TimeTicksNowIgnoringOverride().since_origin().InNanoseconds()); } @@ -3683,7 +3684,7 @@ void WebFrameWidgetImpl::SetPanAction(mojom::blink::PanAction pan_action) { } void WebFrameWidgetImpl::DidHandleGestureEvent(const WebGestureEvent& event) { -#if BUILDFLAG(IS_ANDROID) || defined(USE_AURA) || BUILDFLAG(IS_IOS) +#if BUILDFLAG(IS_ANDROID) || defined(USE_AURA) || BUILDFLAG(IS_IOS) || BUILDFLAG(IS_OHOS) if (event.GetType() == WebInputEvent::Type::kGestureTap) { widget_base_->ShowVirtualKeyboard(); } else if (event.GetType() == WebInputEvent::Type::kGestureLongPress) { @@ -4249,7 +4250,6 @@ void WebFrameWidgetImpl::NotifyPageScaleFactorChanged( void WebFrameWidgetImpl::SetPinchSmoothMode(bool enable) { widget_base_->LayerTreeHost()->SetPinchSmoothMode(enable); } - void WebFrameWidgetImpl::TouchHitTest(const WebPointerEvent& event, size_t finger_id) { WebPointerEvent transformed_event = @@ -4797,7 +4797,7 @@ void WebFrameWidgetImpl::DidNativeEmbedEvent(const WebPointerEvent& web_pointer_ #endif // defined(OHOS_INPUT_EVENTS) #ifdef OHOS_EX_FREE_COPY -void WebFrameWidgetImpl::SelectAndCopy() { +void WebFrameWidgetImpl::ShowFreeCopyMenu() { WebLocalFrame* local_frame = FocusedWebLocalFrameInWidget(); if (!local_frame) { return; @@ -4821,8 +4821,10 @@ void WebFrameWidgetImpl::RegisterClippedVisualViewportSelectionBounds( void WebFrameWidgetImpl::CreateOverlay(const SkBitmap& image, const gfx::Rect& image_rect, const gfx::Point & touch_point, - OnTextSelectedCallback callback) { + OnTextSelectedCallback callback, + OnDestroyImageAnalyzerOverlayCallback destroy_callback) { on_text_selected_callback_ = std::move(callback); + on_destroy_image_overlay_callback_ = std::move(destroy_callback); GetAssociatedFrameWidgetHost()->CreateOverlay(image, image_rect, touch_point); } @@ -4832,6 +4834,12 @@ void WebFrameWidgetImpl::OnTextSelected(bool flag) { } } +void WebFrameWidgetImpl::OnDestroyImageAnalyzerOverlay() { + if (on_destroy_image_overlay_callback_) { + on_destroy_image_overlay_callback_.Run(); + } +} + void WebFrameWidgetImpl::GetScreenRect(GetScreenRectCallback callback) { LocalFrame* frame = LocalRootImpl()->GetFrame(); LocalFrameView* view = frame->View(); @@ -4852,4 +4860,10 @@ void WebFrameWidgetImpl::GetScreenRect(GetScreenRectCallback callback) { std::move(callback).Run(screen_rect); } #endif + +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT +void WebFrameWidgetImpl::ShowToast(const cc::LayerTreeExtraState& state) { + widget_base_->LayerTreeHost()->ShowToast(state); +} +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT } // namespace blink diff --git a/blink/renderer/core/frame/web_frame_widget_impl.h b/blink/renderer/core/frame/web_frame_widget_impl.h index a04075486404ccf90e7497863190c881b243363b..44667858bff098dc5df33f5ad0ff81b1275b4c30 100644 --- a/blink/renderer/core/frame/web_frame_widget_impl.h +++ b/blink/renderer/core/frame/web_frame_widget_impl.h @@ -605,7 +605,7 @@ class CORE_EXPORT WebFrameWidgetImpl float minimum, float maximum); #if BUILDFLAG(IS_OHOS) - void SetPinchSmoothMode(bool isEnable); + void SetPinchSmoothMode(bool enable); #endif // BUILDFLAG(IS_OHOS) void UpdateViewportDescription( const ViewportDescription& viewport_description); @@ -676,15 +676,22 @@ class CORE_EXPORT WebFrameWidgetImpl #ifdef OHOS_AI using OnTextSelectedCallback = base::RepeatingCallback; + using OnDestroyImageAnalyzerOverlayCallback = base::RepeatingCallback; virtual void CreateOverlay(const SkBitmap& image, const gfx::Rect& image_rect, const gfx::Point & touch_point, - OnTextSelectedCallback callback); + OnTextSelectedCallback callback, + OnDestroyImageAnalyzerOverlayCallback destroy_callback); void OnTextSelected(bool flag) override; using GetScreenRectCallback = base::OnceCallback; void GetScreenRect(GetScreenRectCallback callback) override; + void OnDestroyImageAnalyzerOverlay() override; #endif +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + void ShowToast(const cc::LayerTreeExtraState& state) override; +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + protected: // WidgetBaseClient overrides: void WillBeginMainFrame() override; @@ -866,7 +873,7 @@ class CORE_EXPORT WebFrameWidgetImpl // PageWidgetEventHandler overrides: #if defined(OHOS_EX_FREE_COPY) - void SelectAndCopy() override; + void ShowFreeCopyMenu() override; #endif WebInputEventResult HandleKeyEvent(const WebKeyboardEvent&) override; void HandleMouseDown(LocalFrame&, const WebMouseEvent&) override; @@ -1165,10 +1172,13 @@ class CORE_EXPORT WebFrameWidgetImpl scoped_refptr last_hidden_page_popup_; #if defined(OHOS_INPUT_EVENTS) Element* last_focused_element_; + Document* last_focused_document_; + bool twice_ = false; #endif #ifdef OHOS_AI OnTextSelectedCallback on_text_selected_callback_; + OnDestroyImageAnalyzerOverlayCallback on_destroy_image_overlay_callback_; #endif base::WeakPtrFactory diff --git a/blink/renderer/core/fullscreen/fullscreen.cc b/blink/renderer/core/fullscreen/fullscreen.cc index c6de73f1d57801594a90f6b700e41510358c6e99..33ec3d7e5722a3a71674055f2dd3936265c78539 100644 --- a/blink/renderer/core/fullscreen/fullscreen.cc +++ b/blink/renderer/core/fullscreen/fullscreen.cc @@ -692,7 +692,7 @@ ScriptPromise Fullscreen::RequestFullscreen(Element& pending, FullscreenRequestType request_type, ScriptState* script_state, ExceptionState* exception_state) { -#if defined(OHOS_MEDIA) +#ifdef OHOS_MEDIA LOG(WARNING) << "OhMedia::RequestFullscreen localName = " << pending.localName() << ", CountFullscreenInTopLayer = " << CountFullscreenInTopLayer(pending.GetDocument()); @@ -982,9 +982,9 @@ ScriptPromise Fullscreen::ExitFullscreen(Document& doc, ScriptState* script_state, ExceptionState* exception_state, bool ua_originated) { -#if defined(OHOS_MEDIA) +#ifdef OHOS_MEDIA LOG(WARNING) << "OhMedia::ExitFullscreen"; -#endif // OHOS_MEDIA +#endif // OHOS_MEDIA // 1. Let |promise| be a new promise. // ScriptPromiseResolver is allocated after step 2. ScriptPromiseResolver* resolver = nullptr; @@ -1067,7 +1067,7 @@ ScriptPromise Fullscreen::ExitFullscreen(Document& doc, } void Fullscreen::DidExitFullscreen(Document& document) { -#if defined(OHOS_MEDIA) +#ifdef OHOS_MEDIA LOG(WARNING) << "OhMedia::DidExitFullscreen"; #endif // OHOS_MEDIA // If this is a response to an ExitFullscreen call then diff --git a/blink/renderer/core/html/html_anchor_element.cc b/blink/renderer/core/html/html_anchor_element.cc index b77e2b33244ca95fe0f90c722f7ba7f179e41c57..2bb0ae1edd8c798e1ef28aeb750114ded4a3c03e 100644 --- a/blink/renderer/core/html/html_anchor_element.cc +++ b/blink/renderer/core/html/html_anchor_element.cc @@ -66,11 +66,6 @@ #include "third_party/blink/renderer/platform/weborigin/security_policy.h" #include "ui/gfx/geometry/point_conversions.h" -#ifdef OHOS_EX_BLANK_TARGET_POPUP_INTERCEPT -#include "base/command_line.h" -#include "content/public/common/content_switches.h" -#endif - namespace blink { namespace { @@ -429,35 +424,6 @@ void HTMLAnchorElement::SendPings(const KURL& destination_url) const { } } -#ifdef OHOS_EX_BLANK_TARGET_POPUP_INTERCEPT -bool ShouldFixedTargetToTop(LocalFrame* frame) { - bool should_fixed_target_to_top = false; - if (!frame) { - return should_fixed_target_to_top; - } - - if (frame->GetSettings() && - !frame->GetSettings()->IsBlankTargetPopupInterceptEnabled()) { - return false; - } - - if (frame->IsMainFrame()) { - should_fixed_target_to_top = true; - } else if (!frame->DomWindow()->IsSandboxed( - network::mojom::blink::WebSandboxFlags::kTopNavigation) || - !frame->DomWindow()->IsSandboxed( - network::mojom::blink::WebSandboxFlags:: - kTopNavigationByUserActivation)) { - LOG(INFO) << "ShouldFixedTargetToTop: the frame is not MainFrame. " - "The flag of 'allow-top-navigation' or " - "'allow-top-navigation-by-user-activation' is set."; - should_fixed_target_to_top = true; - } - - return should_fixed_target_to_top; -} -#endif - void HTMLAnchorElement::HandleClick(Event& event) { event.SetDefaultHandled(); @@ -578,20 +544,6 @@ void HTMLAnchorElement::HandleClick(Event& event) { : mojom::blink::TriggeringEventInfo::kFromUntrustedEvent); frame_request.SetInputStartTime(event.PlatformTimeStamp()); -#ifdef OHOS_EX_BLANK_TARGET_POPUP_INTERCEPT - AtomicString fixed_target; - if ((*base::CommandLine::ForCurrentProcess()) - .HasSwitch(switches::kForBrowser)) { - if (!frame->Tree().FindFrameByName(target)) { - if (ShouldFixedTargetToTop(frame)) { - LOG(WARNING) - << "HTMLAnchorElement::HandleClick has fixed target frame to _top"; - fixed_target = "_top"; - } - } - } -#endif - frame->MaybeLogAdClickNavigation(); if (const AtomicString& attribution_src = @@ -613,15 +565,6 @@ void HTMLAnchorElement::HandleClick(Event& event) { /*element=*/this)); } -#ifdef OHOS_EX_BLANK_TARGET_POPUP_INTERCEPT - if ((*base::CommandLine::ForCurrentProcess()) - .HasSwitch(switches::kForBrowser)) { - fixed_target = fixed_target.IsNull() ? target : fixed_target; - } else { - fixed_target = target; - } -#endif - Frame* target_frame = frame->Tree().FindOrCreateFrameForNavigation(frame_request, target).frame; diff --git a/blink/renderer/core/html/html_frame_owner_element.cc b/blink/renderer/core/html/html_frame_owner_element.cc old mode 100755 new mode 100644 diff --git a/blink/renderer/core/html/html_plugin_element.cc b/blink/renderer/core/html/html_plugin_element.cc old mode 100755 new mode 100644 index d40b6c80e8656f17b1cb380f72406b9a4a534ca2..e0a1b8cc190afe510cfd8e71fd463f815545c9b8 --- a/blink/renderer/core/html/html_plugin_element.cc +++ b/blink/renderer/core/html/html_plugin_element.cc @@ -296,9 +296,6 @@ void HTMLPlugInElement::RemovedFrom(ContainerNode& insertion_point) { // Plugins can persist only through reattachment during a lifecycle // update. This method shouldn't be called in that lifecycle phase. DCHECK(!persisted_plugin_); - LOG(INFO)<<"HTMLPlugInElement::RemovedFrom"; - if (native_loader_) - native_loader_->OnDestroyNativeSurface(); HTMLFrameOwnerElement::RemovedFrom(insertion_point); } @@ -362,6 +359,13 @@ void HTMLPlugInElement::DetachLayoutTree(bool performing_reattach) { RemovePluginFromFrameView(plugin); ResetInstance(); +#if BUILDFLAG(IS_OHOS) + if (GetLayoutObject() && GetLayoutObject()->IsLayoutNative() && + native_loader_ && !performing_reattach) { + native_loader_->Dispose(); + native_loader_ = nullptr; + } +#endif HTMLFrameOwnerElement::DetachLayoutTree(performing_reattach); } @@ -591,7 +595,6 @@ HTMLPlugInElement::ObjectContentType HTMLPlugInElement::GetObjectContentType() return ObjectContentType::kPlugin; if (MIMETypeRegistry::IsSupportedNonImageMIMEType(mime_type)) return ObjectContentType::kFrame; - return ObjectContentType::kNone; } @@ -867,8 +870,8 @@ HTMLPlugInElement::CustomStyleForLayoutObject( #if BUILDFLAG(IS_OHOS) bool HTMLPlugInElement::CheckNativeType(const char* key) const { - if (GetObjectContentType() != ObjectContentType::kNone){ - LOG(ERROR) << "[NativeEmbed] It's a standard object content type" << (int)GetObjectContentType(); + if (GetObjectContentType() != ObjectContentType::kNone) { + LOG(ERROR) << "[NativeEmbed] It's a standard object content type " << (int)GetObjectContentType(); return false; } @@ -886,9 +889,10 @@ bool HTMLPlugInElement::CheckNativeType(const char* key) const { } if (!service_type_.StartsWith(rule[valid_key])) { - LOG(ERROR) << "[NativeEmbed] Registered type " << rule[valid_key].Utf8() << "doens't match " << service_type_; + LOG(ERROR) << "[NativeEmbed] Registered type " << rule[valid_key].Utf8() << " doens't match " << service_type_; return false; } + return true; } #endif diff --git a/blink/renderer/core/html/html_plugin_element.h b/blink/renderer/core/html/html_plugin_element.h index 0f3ffa6a3c8b43ec9f8746703af69096da477a90..7c2453ff69fe399919322c0f8d41403a21f4415e 100644 --- a/blink/renderer/core/html/html_plugin_element.h +++ b/blink/renderer/core/html/html_plugin_element.h @@ -110,10 +110,6 @@ class CORE_EXPORT HTMLPlugInElement bool CheckNativeType(const char* key) const; - bool ShouldLoadForNative() const { - return IsNativeType() && GetObjectContentType() == ObjectContentType::kNone; - } - HTMLNativeLoader* NativeLoader() const { return native_loader_.Get(); } #endif diff --git a/blink/renderer/core/html/media/html_media_element.cc b/blink/renderer/core/html/media/html_media_element.cc index d723cf6af9568fd17c6af4052c87da17d0c92e97..87f0c60a3174c9c170c167ebe1151678db352400 100644 --- a/blink/renderer/core/html/media/html_media_element.cc +++ b/blink/renderer/core/html/media/html_media_element.cc @@ -1379,7 +1379,7 @@ void HTMLMediaElement::LoadResource(const WebMediaPlayerSource& source, DCHECK(IsSafeToLoadURL(url, kComplain)); DVLOG(3) << "loadResource(" << *this << ", " << UrlForLoggingMedia(url) << ", " << content_type << ")"; -#if defined(OHOS_MEDIA) +#ifdef OHOS_MEDIA } else { LOG(WARNING) << "OhMedia::LoadResource source is not url"; #endif // OHOS_MEDIA @@ -1964,9 +1964,9 @@ void HTMLMediaElement::MediaLoadingFailed(WebMediaPlayer::NetworkState error, DVLOG(3) << "MediaLoadingFailed(" << *this << ", " << int{error} << ", message='" << input_message << "')"; -#if defined(OHOS_MEDIA) - LOG(INFO) << "OhMedia::MediaLoadingFailed error = " << int{error} - << ", message='" << input_message << "')"; +#ifdef OHOS_MEDIA + LOG(INFO) << "OhMedia::MediaLoadingFailed error = " << (int)error + << ", input_message = " << input_message << ")"; #endif // OHOS_MEDIA bool should_be_opaque = MediaShouldBeOpaque(); @@ -2940,7 +2940,7 @@ void HTMLMediaElement::PlayInternal() { void HTMLMediaElement::pause() { DVLOG(2) << "pause(" << *this << ")"; -#if defined(OHOS_MEDIA) +#ifdef OHOS_MEDIA LOG(WARNING) << "OhMedia::pause"; #endif // OHOS_MEDIA @@ -4004,9 +4004,17 @@ void HTMLMediaElement::UpdatePlayState(bool pause_speech /* = true */) { } } LOG(WARNING) << "OhMedia::UpdatePlayState should_be_playing = " - << should_be_playing << ", is_playing" << is_playing; + << should_be_playing << ",is_playing = " << is_playing; #endif // OHOS_MEDIA_POLICY +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + if (should_be_playing) { + if (IsPlaybackBlocked()) { + should_be_playing = false; + } + } +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + if (should_be_playing) { if (!is_playing) { // Set rate, muted before calling play in case they were set before the @@ -5248,6 +5256,16 @@ void HTMLMediaElement::FullscreenChanged(bool is_fullscreen) { } #endif // OHOS_CUSTOM_VIDEO_PLAYER +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT +bool HTMLMediaElement::IsPlaybackBlocked() { + return false; +} + +void HTMLMediaElement::TryUpdatePlayState() { + UpdatePlayState(); +} +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + STATIC_ASSERT_ENUM(WebMediaPlayer::kReadyStateHaveNothing, HTMLMediaElement::kHaveNothing); STATIC_ASSERT_ENUM(WebMediaPlayer::kReadyStateHaveMetadata, diff --git a/blink/renderer/core/html/media/html_media_element.h b/blink/renderer/core/html/media/html_media_element.h index 71ada938dbfd318181654af91bc770395b90f442..b8d2fc006e3fc77641ef969cc8de356512abd01e 100644 --- a/blink/renderer/core/html/media/html_media_element.h +++ b/blink/renderer/core/html/media/html_media_element.h @@ -420,6 +420,10 @@ class CORE_EXPORT HTMLMediaElement WebString GetTitle() const; #endif // defined(OHOS_MEDIA) +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + void TryUpdatePlayState(); +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + protected: // Assert the correct order of the children in shadow dom when DCHECK is on. static void AssertShadowRootChildren(ShadowRoot&); @@ -466,6 +470,10 @@ class CORE_EXPORT HTMLMediaElement void FullscreenChanged(bool is_fullscreen); #endif // OHOS_CUSTOM_VIDEO_PLAYER +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + virtual bool IsPlaybackBlocked(); +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + private: // Friend class for testing. friend class ContextMenuControllerTest; @@ -642,6 +650,9 @@ class CORE_EXPORT HTMLMediaElement void RequestEnterFullscreen() override {} void RequestExitFullscreen() override {} #endif // OHOS_CUSTOM_VIDEO_PLAYER +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + void AllowPlaybackWithMobileData() override {} +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT void LoadTimerFired(TimerBase*); void ProgressEventTimerFired(); diff --git a/blink/renderer/core/html/media/html_native_element.cc b/blink/renderer/core/html/media/html_native_element.cc deleted file mode 100755 index c347dd505bb627bd5b649890288f452f27a4893f..0000000000000000000000000000000000000000 --- a/blink/renderer/core/html/media/html_native_element.cc +++ /dev/null @@ -1,813 +0,0 @@ -/* - * Copyright (c) 2022-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 - * - * 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, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "third_party/blink/renderer/core/html/media/html_native_element.h" - -#include -#include - -#include "base/time/time.h" -#include "cc/layers/layer.h" -#include "media/mojo/mojom/native_bridge.mojom.h" -#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" -#include "third_party/blink/public/platform/platform.h" -#include "third_party/blink/public/platform/task_type.h" -#include "third_party/blink/renderer/core/core_initializer.h" -#include "third_party/blink/renderer/core/core_probes_inl.h" -#include "third_party/blink/renderer/core/css/style_engine.h" -#include "third_party/blink/renderer/core/dom/events/event.h" -#include "third_party/blink/renderer/core/dom/events/event_queue.h" -#include "third_party/blink/renderer/core/dom/shadow_root.h" -#include "third_party/blink/renderer/core/events/keyboard_event.h" -#include "third_party/blink/renderer/core/frame/local_dom_window.h" -#include "third_party/blink/renderer/core/frame/local_frame.h" -#include "third_party/blink/renderer/core/frame/local_frame_client.h" -#include "third_party/blink/renderer/core/frame/local_frame_view.h" -#include "third_party/blink/renderer/core/frame/page_scale_constraints_set.h" -#include "third_party/blink/renderer/core/frame/visual_viewport.h" -#include "third_party/blink/renderer/core/fullscreen/fullscreen.h" -#include "third_party/blink/renderer/core/html/media/media_error.h" -#include "third_party/blink/renderer/core/html_names.h" -#include "third_party/blink/renderer/core/inspector/console_message.h" -#include "third_party/blink/renderer/core/intersection_observer/intersection_observer.h" -#include "third_party/blink/renderer/core/intersection_observer/intersection_observer_entry.h" -#include "third_party/blink/renderer/core/layout/layout_native.h" -#include "third_party/blink/renderer/core/layout/layout_view.h" -#include "third_party/blink/renderer/core/page/chrome_client.h" -#include "third_party/blink/renderer/core/page/page.h" -#include "third_party/blink/renderer/platform/bindings/exception_messages.h" -#include "third_party/blink/renderer/platform/bindings/exception_state.h" -#include "third_party/blink/renderer/platform/heap/garbage_collected.h" -#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h" -#include "third_party/blink/renderer/platform/network/network_state_notifier.h" -#include "third_party/blink/renderer/platform/web_native_bridge.h" -#include "third_party/blink/renderer/platform/wtf/functional.h" - -namespace blink { - -using WeakNativeElementSet = HeapHashSet>; -using DocumentElementSetMap = - HeapHashMap, Member>; - -namespace { - -DocumentElementSetMap& DocumentToElementSetMap() { - DEFINE_STATIC_LOCAL(Persistent, map, - (MakeGarbageCollected())); - return *map; -} - -void AddElementToDocumentMap(HTMLNativeElement* element, Document* document) { - DocumentElementSetMap& map = DocumentToElementSetMap(); - WeakNativeElementSet* set = nullptr; - auto it = map.find(document); - if (it == map.end()) { - set = MakeGarbageCollected(); - map.insert(document, set); - } else { - set = it->value; - } - set->insert(element); -} - -void RemoveElementFromDocumentMap(HTMLNativeElement* element, - Document* document) { - DocumentElementSetMap& map = DocumentToElementSetMap(); - auto it = map.find(document); - DCHECK(it != map.end()); - WeakNativeElementSet* set = it->value; - set->erase(element); - if (set->empty()) { - map.erase(it); - } -} - -std::ostream& operator<<(std::ostream& stream, - HTMLNativeElement const& media_element) { - return stream << static_cast(&media_element); -} - -float PageConstraintInitalScale(const Document& document) { - float scale = 1.0; - if (auto* page = document.GetPage()) { - scale = page->GetPageScaleConstraintsSet().FinalConstraints().initial_scale; - } - return scale; -} - -} // anonymous namespace - -HTMLNativeElement::HTMLNativeElement(Document& document) - : HTMLElement(html_names::kNativeTag, document), - ActiveScriptWrappable({}), - ExecutionContextLifecycleStateObserver(GetExecutionContext()), - load_timer_(document.GetTaskRunner(TaskType::kInternalMedia), - this, - &HTMLNativeElement::LoadTimerFired), - async_event_queue_( - MakeGarbageCollected(GetExecutionContext(), - TaskType::kMediaElementEvent)), - network_state_(kNetworkEmpty), - cc_layer_(nullptr), - pending_action_flags_(0), - should_delay_load_event_(false), - have_fired_loaded_data_(false), - sent_stalled_event_(false), - processing_preference_change_(false), - lazy_load_intersection_observer_(nullptr) { - ResetMojoState(); - - SetHasCustomStyleCallbacks(); - AddElementToDocumentMap(this, &document); -} - -HTMLNativeElement::~HTMLNativeElement() { - DVLOG(1) << "~HTMLNativeElement(" << *this << ")"; -} - -void HTMLNativeElement::Dispose() { - ClearResourceWithoutLocking(); -} - -void HTMLNativeElement::DidMoveToNewDocument(Document& old_document) { - DVLOG(3) << "didMoveToNewDocument(" << *this << ")"; - - load_timer_.MoveToNewTaskRunner( - GetDocument().GetTaskRunner(TaskType::kInternalMedia)); - if (should_delay_load_event_) { - GetDocument().IncrementLoadEventDelayCount(); - // Note: Keeping the load event delay count increment on oldDocument that - // was added when should_delay_load_event_ was set so that destruction of - // web_media_player_ can not cause load event dispatching in oldDocument. - } else { - // Incrementing the load event delay count so that destruction of - // web_media_player_ can not cause load event dispatching in oldDocument. - old_document.IncrementLoadEventDelayCount(); - } - - RemoveElementFromDocumentMap(this, &old_document); - AddElementToDocumentMap(this, &GetDocument()); - SetExecutionContext(GetExecutionContext()); - - // FIXME: This is a temporary fix to prevent this object from causing the - // MediaPlayer to dereference LocalFrame and FrameLoader pointers from the - // previous document. This restarts the load, as if the src attribute had been - // set. A proper fix would provide a mechanism to allow this object to - // refresh the MediaPlayer's LocalFrame and FrameLoader references on document - // changes so that playback can be resumed properly. - // TODO(liberato): Consider checking that the new document's opener is the old - // document: GetDocument().GetFrame()->Opener() == old_document.GetFrame(). - auto new_origin = GetDocument().TopFrameOrigin(); - auto old_origin = old_document.TopFrameOrigin(); - const bool reuse = new_origin && old_origin && - old_origin->IsSameOriginWith(new_origin.get()); - if (!reuse) { - // Don't worry about notifications from any previous document if we're not - // re-using the player. - if (opener_context_observer_) { - opener_context_observer_->SetContextLifecycleNotifier(nullptr); - } - AttachToNewFrame(); - } else { - opener_document_ = old_document; - if (!opener_context_observer_) { - opener_context_observer_ = - MakeGarbageCollected(this); - } - opener_context_observer_->SetContextLifecycleNotifier( - opener_document_->GetExecutionContext()); - } - - // Decrement the load event delay count on oldDocument now that - // web_media_player_ has been destroyed and there is no risk of dispatching a - // load event from within the destructor. - old_document.DecrementLoadEventDelayCount(); - - HTMLElement::DidMoveToNewDocument(old_document); -} - -void HTMLNativeElement::AttachToNewFrame() { - opener_document_ = nullptr; - // Do not ask it to stop notifying us -- if this is a callback from the - // listener, then it's ExecutionContext has been destroyed and it's not - // allowed to unregister. - opener_context_observer_ = nullptr; - // Reset mojo state that is coupled to |old_document|'s execution context. - // NOTE: |native_bridge_host_remote_| is also coupled to |old_document|'s - // frame. - ResetMojoState(); - InvokeLoadAlgorithm(); -} - -void HTMLNativeElement::ResetMojoState() { - native_bridge_host_remote_ = MakeGarbageCollected>>( - GetExecutionContext()); - if (native_bridge_observer_remote_set_) { - native_bridge_observer_remote_set_->Value().Clear(); - } - native_bridge_observer_remote_set_ = MakeGarbageCollected>>( - GetExecutionContext()); -} - -String HTMLNativeElement::GetTypeAttribute() const { - if (auto* element = GetDocument().LocalOwner()) { - return element->TypeAttribute(); - } - - return String(); -} - -String HTMLNativeElement::GetSrcAttribute() const { - if (auto* element = GetDocument().LocalOwner()) { - return element->SrcAttribute(); - } - - return String(); -} - -String HTMLNativeElement::GetIdAttribute() const { - if (auto* element = GetDocument().LocalOwner()) { - return element->IdAttribute(); - } - - return String(); -} - -String HTMLNativeElement::GetTagName() const { - if (auto* element = GetDocument().LocalOwner()) { - return element->tagName(); - } - - return String(); -} - -ParamMap HTMLNativeElement::GetParamList() const { - if (auto* element = GetDocument().LocalOwner()) { - return element->ParamList(); - } - - return ParamMap(); -} - -bool HTMLNativeElement::SupportsFocus() const { - // If no controls specified, we should still be able to focus the element if - // it has tabIndex. - return HTMLElement::SupportsFocus(); -} - -bool HTMLNativeElement::IsMouseFocusable() const { - return !IsFullscreen() && SupportsFocus(); -} - -void HTMLNativeElement::ParseAttribute( - const AttributeModificationParams& params) { - HTMLElement::ParseAttribute(params); -} - -void HTMLNativeElement::ParserDidSetAttributes() { - HTMLElement::ParserDidSetAttributes(); -} - -// This method is being used as a way to know that cloneNode finished cloning -// attribute as there is no callback notifying about the end of a cloning -// operation. Indeed, it is required per spec to set the muted state based on -// the content attribute when the object is created. -void HTMLNativeElement::CloneNonAttributePropertiesFrom( - const Element& other, - CloneChildrenFlag flag) { - HTMLElement::CloneNonAttributePropertiesFrom(other, flag); -} - -void HTMLNativeElement::FinishParsingChildren() { - HTMLElement::FinishParsingChildren(); -} - -bool HTMLNativeElement::LayoutObjectIsNeeded(const DisplayStyle& style) const { - return HTMLElement::LayoutObjectIsNeeded(style); -} - -LayoutObject* HTMLNativeElement::CreateLayoutObject(const ComputedStyle&) { - return MakeGarbageCollected(this); -} - -Node::InsertionNotificationRequest HTMLNativeElement::InsertedInto( - ContainerNode& insertion_point) { - DVLOG(3) << "insertedInto(" << *this << ", " << insertion_point << ")"; - - HTMLElement::InsertedInto(insertion_point); - if (insertion_point.isConnected()) { - if ((!FastGetAttribute(html_names::kSrcAttr).empty()) && - network_state_ == kNetworkEmpty) { - InvokeLoadAlgorithm(); - } - } - - return kInsertionShouldCallDidNotifySubtreeInsertions; -} - -void HTMLNativeElement::RemovedFrom(ContainerNode& insertion_point) { - DVLOG(3) << "removedFrom(" << *this << ", " << insertion_point << ")"; - HTMLElement::RemovedFrom(insertion_point); -} - -void HTMLNativeElement::AttachLayoutTree(AttachContext& context) { - HTMLElement::AttachLayoutTree(context); - - UpdateLayoutObject(); -} - -void HTMLNativeElement::DidRecalcStyle(const StyleRecalcChange change) { - if (!change.ReattachLayoutTree()) { - UpdateLayoutObject(); - } -} - -void HTMLNativeElement::ScheduleLoadResource() { - // Schedule the timer to try the next element WITHOUT resetting state - // ala invokeLoadAlgorithm. - pending_action_flags_ |= kLoadMediaResource; - load_timer_.StartOneShot(base::TimeDelta(), FROM_HERE); -} - -void HTMLNativeElement::ScheduleEvent(const AtomicString& event_name) { - Event* event = Event::CreateCancelable(event_name); - event->SetTarget(this); - ScheduleEvent(event); -} - -void HTMLNativeElement::ScheduleEvent(Event* event) { - async_event_queue_->EnqueueEvent(FROM_HERE, *event); -} - -void HTMLNativeElement::LoadTimerFired(TimerBase*) { - DVLOG(3) << "LoadTimerFired(" << *this << ")"; - if (pending_action_flags_ & kLoadMediaResource) { - // 6 - If the media element has an assigned media provider object, then let - // mode be object. - - // 7 - Set the media element's networkState to NETWORK_LOADING. - SetNetworkState(kNetworkLoading); - - // 8 - Queue a task to fire a simple event named loadstart at the media - // element. - ScheduleEvent(event_type_names::kLoadstart); - - // 9 - Run the appropriate steps... - LoadResource(); - } - - pending_action_flags_ = 0; -} - -MediaError* HTMLNativeElement::error() const { - return error_; -} - -HTMLNativeElement::NetworkState HTMLNativeElement::getNetworkState() const { - return network_state_; -} - -void HTMLNativeElement::load() { - DVLOG(1) << "load(" << *this << ")"; - - InvokeLoadAlgorithm(); -} - -void HTMLNativeElement::InvokeLoadAlgorithm() { - DVLOG(3) << "invokeLoadAlgorithm(" << *this << ")"; - - // Perform the cleanup required for the resource load algorithm to run. - StopPeriodicTimers(); - load_timer_.Stop(); - // FIXME: Figure out appropriate place to reset LoadTextTrackResource if - // necessary and set pending_action_flags_ to 0 here. - pending_action_flags_ &= ~kLoadMediaResource; - sent_stalled_event_ = false; - have_fired_loaded_data_ = false; - - CancelPendingEventsAndCallbacks(); - - if (network_state_ == kNetworkLoading || network_state_ == kNetworkIdle) { - ScheduleEvent(event_type_names::kAbort); - } - - // If the element's networkState is not set to NETWORK_EMPTY, then - // run these substeps - if (network_state_ != kNetworkEmpty) { - // Queue a task to fire a simple event named emptied at the media - // element. - ScheduleEvent(event_type_names::kEmptied); - - // If a fetching process is in progress for the media element, the - // user agent should stop it. - SetNetworkState(kNetworkEmpty); - } - - SetError(nullptr); - - SetNetworkState(kNetworkNoSource); - - SetShouldDelayLoadEvent(false); - - ScheduleLoadResource(); -} - -void HTMLNativeElement::LoadResource() { - DCHECK(IsMainThread()); - // The resource fetch algorithm - SetNetworkState(kNetworkLoading); - - DCHECK(!error_); - - if (auto* frame = LocalFrameForNative()) { - LoadForWebNative(frame); - } -} - -LocalFrame* HTMLNativeElement::LocalFrameForNative() { - return opener_document_ ? opener_document_->GetFrame() - : GetDocument().GetFrame(); -} - -void HTMLNativeElement::LoadForWebNative(LocalFrame* frame) { - web_native_bridge_ = frame->Client()->CreateWebNativeBridge(*this, this); - if (!web_native_bridge_) { - return; - } - - GetNativeBridgeHostRemote().OnNativeBridgeAdded( - AddNativeBridgeObserverAndPassReceiver(), - web_native_bridge_->GetDelegateId()); - - if (GetLayoutObject()) { - GetLayoutObject()->SetShouldDoFullPaintInvalidation(); - } - - web_native_bridge_->StartPipeline(); -} - -void HTMLNativeElement::NoneSupported(const String& input_message) { - DVLOG(3) << "NoneSupported(" << *this << ", message='" << input_message - << "')"; - - StopPeriodicTimers(); - - const String& message = input_message; - - SetError(MakeGarbageCollected( - MediaError::kMediaErrSrcNotSupported, message)); - - SetNetworkState(kNetworkNoSource); - - ScheduleEvent(event_type_names::kError); - - SetShouldDelayLoadEvent(false); - - UpdateLayoutObject(); -} - -void HTMLNativeElement::MediaEngineError(MediaError* err) { - DVLOG(3) << "mediaEngineError(" << *this << ", " - << static_cast(err->code()) << ") message:" - << static_cast(err->message()).Ascii(); - - StopPeriodicTimers(); - - SetError(err); - - ScheduleEvent(event_type_names::kError); - - SetNetworkState(kNetworkIdle); - - SetShouldDelayLoadEvent(false); -} - -void HTMLNativeElement::CancelPendingEventsAndCallbacks() { - DVLOG(3) << "cancelPendingEventsAndCallbacks(" << *this << ")"; - async_event_queue_->CancelAllEvents(); -} - -void HTMLNativeElement::UpdateLayoutObject() { - if (GetLayoutObject()) { - GetLayoutObject()->UpdateFromElement(); - } -} - -gfx::Rect HTMLNativeElement::OwnerBoundingRect() { - if (bounding_rect_.IsEmpty()) { - if (auto* owner_element = GetDocument().LocalOwner()) { - bounding_rect_ = owner_element->PixelSnappedBoundingBox(); - } - } - - return bounding_rect_; -} - -void HTMLNativeElement::OnCreateNativeSurface(int native_embed_id, - RectChangeCB rect_changed_cb) { - native_embed_id_ = native_embed_id; - bounding_rect_changed_cb_ = rect_changed_cb; - if (cc_layer_) { - cc_layer_->SetNativeEmbedId(native_embed_id_); - } - - if (!native_bridge_observer_remote_set_) { - return; - } - - auto embed_info = media::mojom::blink::NativeEmbedInfo::New(); - auto* frame = LocalFrameForNative(); - if (frame && frame->View()) { - auto frame_to_viewport = - frame->View()->FrameToViewport(OwnerBoundingRect()); - auto bounding_rect = gfx::ScaleToEnclosingRect( - OwnerBoundingRect(), PageConstraintInitalScale(GetDocument())); - // We will use the position relative to visual viewport. - bounding_rect.set_origin( - gfx::Point(frame_to_viewport.x() - bounding_rect.x(), - frame_to_viewport.y() - bounding_rect.y())); - bounding_rect_.set_origin(bounding_rect.origin()); - embed_info->rect = bounding_rect; - if (!bounding_rect_changed_cb_.is_null()) { - bounding_rect_changed_cb_.Run(bounding_rect, false); - } - } - - embed_info->embed_id = native_embed_id_; - embed_info->type = GetTypeAttribute().IsNull() ? "" : GetTypeAttribute(); - embed_info->element_id = GetIdAttribute().IsNull() ? "" : GetIdAttribute(); - embed_info->source = GetSrcAttribute().IsNull() ? "" : GetSrcAttribute(); - embed_info->tag = GetTagName().IsNull() ? "" : GetTagName(); - if (!GetParamList().empty()) { - embed_info->params = GetParamList(); - } - - for (auto& observer : native_bridge_observer_remote_set_->Value()) { - // TODO: We actually only have one observer now so just using std::move - // here. - observer->OnCreateNativeSurface(std::move(embed_info)); - } -} - -void HTMLNativeElement::ClearResourceWithoutLocking() { - if (web_native_bridge_) { - web_native_bridge_.reset(); - native_bridge_observer_remote_set_->Value().Clear(); - } -} - -void HTMLNativeElement::UpdateSize(gfx::Size size) { - String native_type = GetTypeAttribute(); - LOG(INFO) << "NativeEmbed size:" << size.ToString() << ",native_type:" << native_type; - if (native_type == "native/video") { - return; - } - if (OwnerBoundingRect().size() != size) { - if (!bounding_rect_changed_cb_.is_null()) { - bounding_rect_changed_cb_.Run(gfx::ScaleToEnclosingRect( - bounding_rect_, PageConstraintInitalScale(GetDocument())), true); - } - } -} - -void HTMLNativeElement::OnLayerRectChange(const gfx::Rect& rect) { - if (OwnerBoundingRect().ApproximatelyEqual(rect, 1)) { - return; - } - - if (OwnerBoundingRect().size() != rect.size()) { - ScheduleEvent(event_type_names::kResize); - bounding_rect_ = rect; - if (!bounding_rect_changed_cb_.is_null()) { - bounding_rect_changed_cb_.Run(gfx::ScaleToEnclosingRect( - bounding_rect_, PageConstraintInitalScale(GetDocument())), true); - } - } else { - bounding_rect_.set_origin(rect.origin()); - } - - if (!native_bridge_observer_remote_set_) { - return; - } - - for (auto& observer : native_bridge_observer_remote_set_->Value()) { - observer->OnEmbedRectChange(gfx::Rect( - bounding_rect_.origin(), - gfx::ScaleToCeiledSize(bounding_rect_.size(), - PageConstraintInitalScale(GetDocument())))); - } -} - -void HTMLNativeElement::OnDestroyNativeSurface() { - bounding_rect_changed_cb_.Reset(); - if (!native_bridge_observer_remote_set_) { - return; - } - - for (auto& observer : native_bridge_observer_remote_set_->Value()) { - observer->OnDestroyNativeSurface(); - } -} - -void HTMLNativeElement::Repaint() { - if (cc_layer_) { - cc_layer_->SetNeedsDisplay(); - } - - UpdateLayoutObject(); - if (GetLayoutObject()) { - GetLayoutObject()->SetShouldDoFullPaintInvalidation(); - } -} - -void HTMLNativeElement::SetCcLayer(cc::Layer* cc_layer) { - if (cc_layer == cc_layer_) { - return; - } - - SetNeedsCompositingUpdate(); - cc_layer_ = cc_layer; - if (cc_layer_) { - LOG(INFO) << "[NativeEmbed] set native flag"; - cc_layer_->SetMayContainNative(true); - cc_layer_->SetNeedsPushProperties(); - cc_layer_->SetIsNativeVideo(GetTypeAttribute() == "native/video"); - } -} - -void HTMLNativeElement::StopPeriodicTimers() { - if (lazy_load_intersection_observer_) { - lazy_load_intersection_observer_->disconnect(); - lazy_load_intersection_observer_ = nullptr; - } -} - -void HTMLNativeElement::ClearNativeResource() { - StopPeriodicTimers(); - load_timer_.Stop(); - - pending_action_flags_ = 0; - - ClearResourceWithoutLocking(); - - if (GetLayoutObject()) { - GetLayoutObject()->SetShouldDoFullPaintInvalidation(); - } -} - -void HTMLNativeElement::ContextDestroyed() { - DVLOG(3) << "contextDestroyed(" << static_cast(this) << ")"; - - // Close the async event queue so that no events are enqueued. - CancelPendingEventsAndCallbacks(); - - // Clear everything in the Media Element - ClearNativeResource(); - SetNetworkState(kNetworkEmpty); - SetShouldDelayLoadEvent(false); - - UpdateLayoutObject(); - - StopPeriodicTimers(); -} - -bool HTMLNativeElement::HasPendingActivity() const { - const auto result = HasPendingActivityInternal(); - // TODO(dalecurtis): Replace c-style casts in followup patch. - DVLOG(3) << "HasPendingActivity(" << *this << ") = " << result; - return result; -} - -bool HTMLNativeElement::HasPendingActivityInternal() const { - // The delaying-the-load-event flag is set by resource selection algorithm - // when looking for a resource to load, before networkState has reached to - // kNetworkLoading. - if (should_delay_load_event_) { - return true; - } - - // Wait for any pending events to be fired. - if (async_event_queue_->HasPendingEvents()) { - return true; - } - - return false; -} - -bool HTMLNativeElement::IsFullscreen() const { - return Fullscreen::IsFullscreenElement(*this); -} - -cc::Layer* HTMLNativeElement::CcLayer() const { - return cc_layer_; -} - -bool HTMLNativeElement::IsURLAttribute(const Attribute& attribute) const { - return attribute.GetName() == html_names::kSrcAttr || - HTMLElement::IsURLAttribute(attribute); -} - -void HTMLNativeElement::SetShouldDelayLoadEvent(bool should_delay) { - if (should_delay_load_event_ == should_delay) { - return; - } - - should_delay_load_event_ = should_delay; - if (should_delay) { - GetDocument().IncrementLoadEventDelayCount(); - } else { - GetDocument().DecrementLoadEventDelayCount(); - } -} - -void HTMLNativeElement::Trace(Visitor* visitor) const { - visitor->Trace(load_timer_); - visitor->Trace(async_event_queue_); - visitor->Trace(error_); - visitor->Trace(lazy_load_intersection_observer_); - visitor->Trace(native_bridge_host_remote_); - visitor->Trace(native_bridge_observer_remote_set_); - visitor->Trace(opener_document_); - visitor->Trace(opener_context_observer_); - Supplementable::Trace(visitor); - HTMLElement::Trace(visitor); - ExecutionContextLifecycleStateObserver::Trace(visitor); -} - -void HTMLNativeElement::SetNetworkState(NetworkState state, - bool update_media_controls) { - if (network_state_ == state) { - return; - } - - network_state_ = state; -} - -media::mojom::blink::NativeBridgeHost& -HTMLNativeElement::GetNativeBridgeHostRemote() { - // It is an error to call this before having access to the document's frame. - DCHECK(GetDocument().GetFrame()); - if (!native_bridge_host_remote_->Value().is_bound()) { - GetDocument() - .GetFrame() - ->GetRemoteNavigationAssociatedInterfaces() - ->GetInterface( - native_bridge_host_remote_->Value().BindNewEndpointAndPassReceiver( - GetDocument().GetTaskRunner(TaskType::kInternalMedia))); - } - return *native_bridge_host_remote_->Value().get(); -} - -mojo::PendingAssociatedReceiver -HTMLNativeElement::AddNativeBridgeObserverAndPassReceiver() { - mojo::PendingAssociatedRemote - observer; - auto observer_receiver = observer.InitWithNewEndpointAndPassReceiver(); - native_bridge_observer_remote_set_->Value().Add( - std::move(observer), - GetDocument().GetTaskRunner(TaskType::kInternalMedia)); - return observer_receiver; -} - -void HTMLNativeElement::SetError(MediaError* error) { - error_ = error; - - if (!error) { - return; - } -} - -HTMLNativeElement::OpenerContextObserver::OpenerContextObserver( - HTMLNativeElement* element) - : element_(element) {} - -HTMLNativeElement::OpenerContextObserver::~OpenerContextObserver() = default; - -void HTMLNativeElement::OpenerContextObserver::Trace(Visitor* visitor) const { - ContextLifecycleObserver::Trace(visitor); - visitor->Trace(element_); -} - -void HTMLNativeElement::OpenerContextObserver::ContextDestroyed() { - element_->AttachToNewFrame(); -} - -int HTMLNativeElement::GetNativeEmbedId() { - return native_embed_id_; -} - -} // namespace blink diff --git a/blink/renderer/core/html/media/html_native_element.h b/blink/renderer/core/html/media/html_native_element.h deleted file mode 100755 index 8fce50e1f018a7142cb604d06b8c16fe4d8f7324..0000000000000000000000000000000000000000 --- a/blink/renderer/core/html/media/html_native_element.h +++ /dev/null @@ -1,297 +0,0 @@ -/* - * Copyright (c) 2022-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 - * - * 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, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_HTML_MEDIA_HTML_NATIVE_ELEMENT_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_HTML_MEDIA_HTML_NATIVE_ELEMENT_H_ - -#include - -#include "base/time/time.h" -#include "base/timer/elapsed_timer.h" -#include "media/mojo/mojom/native_bridge.mojom-blink.h" -#include "third_party/abseil-cpp/absl/types/optional.h" -#include "third_party/blink/public/common/media/display_type.h" -#include "third_party/blink/public/platform/web_native_client.h" -#include "third_party/blink/renderer/bindings/core/v8/active_script_wrappable.h" -#include "third_party/blink/renderer/core/core_export.h" -#include "third_party/blink/renderer/core/execution_context/execution_context_lifecycle_state_observer.h" -#include "third_party/blink/renderer/core/html/html_element.h" -#include "third_party/blink/renderer/core/html/html_frame_owner_element.h" -#include "third_party/blink/renderer/core/intersection_observer/intersection_observer.h" -#include "third_party/blink/renderer/platform/bindings/exception_state.h" -#include "third_party/blink/renderer/platform/heap/disallow_new_wrapper.h" -#include "third_party/blink/renderer/platform/heap/prefinalizer.h" -#include "third_party/blink/renderer/platform/mojo/heap_mojo_associated_receiver_set.h" -#include "third_party/blink/renderer/platform/mojo/heap_mojo_associated_remote.h" -#include "third_party/blink/renderer/platform/mojo/heap_mojo_associated_remote_set.h" -#include "third_party/blink/renderer/platform/network/mime/mime_type_registry.h" -#include "third_party/blink/renderer/platform/scheduler/public/post_cancellable_task.h" -#include "third_party/blink/renderer/platform/supplementable.h" -#include "third_party/blink/renderer/platform/timer.h" -#include "third_party/blink/renderer/platform/weborigin/kurl.h" -#include "third_party/blink/renderer/platform/wtf/threading_primitives.h" -#include "third_party/blink/renderer/platform/wtf/vector.h" - -namespace cc { -class Layer; -} - -namespace blink { - -class Event; -class EventQueue; -class ExceptionState; -class MediaError; -class ScriptState; -class WebNativeBridge; - -class CORE_EXPORT HTMLNativeElement - : public HTMLElement, - public Supplementable, - public ActiveScriptWrappable, - public ExecutionContextLifecycleStateObserver, - private WebNativeClient { - DEFINE_WRAPPERTYPEINFO(); - USING_PRE_FINALIZER(HTMLNativeElement, Dispose); - - public: - explicit HTMLNativeElement(Document&); - ~HTMLNativeElement() override; - - // TODO: Returne the acture size. - unsigned videoWidth() const { return 100; } - unsigned videoHeight() const { return 100; } - - void Trace(Visitor*) const override; - - cc::Layer* CcLayer() const; - - enum DelayedActionType { kLoadMediaResource = 1 << 0 }; - // error state - MediaError* error() const; - - enum NetworkState { - kNetworkEmpty, - kNetworkIdle, - kNetworkLoading, - kNetworkNoSource - }; - NetworkState getNetworkState() const; - - void load(); - - // EventTarget function. - // Both Node (via HTMLElement) and ExecutionContextLifecycleStateObserver - // define this method, which causes an ambiguity error at compile time. This - // class's constructor ensures that both implementations return document, so - // return the result of one of them here. - using HTMLElement::GetExecutionContext; - - bool IsFullscreen() const; - - // ScriptWrappable functions. - bool HasPendingActivity() const override; - - void ScheduleEvent(Event*); - - LocalFrame* LocalFrameForNative(); - - void LoadForWebNative(LocalFrame* frame); - - WebNativeBridge* GetWebNativeBridge() { return web_native_bridge_.get(); } - - int GetNativeEmbedId(); - - // WebNativeClient implementation. - void OnCreateNativeSurface(int native_embed_id, - RectChangeCB rect_changed_cb) final; - void OnLayerRectChange(const gfx::Rect& rect) final; - void OnDestroyNativeSurface() final; - void Repaint() final; - void SetCcLayer(cc::Layer*) final; - void UpdateSize(gfx::Size size); - - protected: - // Assert the correct order of the children in shadow dom when DCHECK is on. - static void AssertShadowRootChildren(ShadowRoot&); - - void Dispose(); - - // Returns a constant reference to the HeapMojoAssociatedRemoteSet holding all - // the bound remotes for the media::mojom::blink::MediaPlayerObserver - // interface. Needed to allow sending messages directly from - // HTMLNativeElement's subclasses. - const HeapMojoAssociatedRemoteSet& - GetNativeBridgeObserverRemoteSet() { - return native_bridge_observer_remote_set_->Value(); - } - - void ParseAttribute(const AttributeModificationParams&) override; - void FinishParsingChildren() final; - bool IsURLAttribute(const Attribute&) const override; - void AttachLayoutTree(AttachContext&) override; - void ParserDidSetAttributes() override; - void CloneNonAttributePropertiesFrom(const Element&, - CloneChildrenFlag) override; - - InsertionNotificationRequest InsertedInto(ContainerNode&) override; - void RemovedFrom(ContainerNode&) override; - - void DidMoveToNewDocument(Document& old_document) override; - - void UpdateLayoutObject(); - - private: - bool HasPendingActivityInternal() const; - - bool AlwaysCreateUserAgentShadowRoot() const final { return true; } - bool AreAuthorShadowsAllowed() const final { return false; } - - bool SupportsFocus() const final; - bool IsMouseFocusable() const final; - bool LayoutObjectIsNeeded(const DisplayStyle&) const override; - LayoutObject* CreateLayoutObject(const ComputedStyle&) override; - void DidNotifySubtreeInsertionsToDocument() override {} - void DidRecalcStyle(const StyleRecalcChange) final; - - bool CanStartSelection() const override { return false; } - - // ExecutionContextLifecycleStateObserver functions. - void ContextLifecycleStateChanged(mojom::FrameLifecycleState) override {} - void ContextDestroyed() override; - - // Returns a reference to the mojo remote for the NativeBridgeHost interface, - // requesting it first from the BrowserInterfaceBroker if needed. It is an - // error to call this method before having access to the document's frame. - media::mojom::blink::NativeBridgeHost& GetNativeBridgeHostRemote(); - - void LoadTimerFired(TimerBase*); - void StopPeriodicTimers(); - - // FIXME: Rename to scheduleNamedEvent for clarity. - void ScheduleEvent(const AtomicString& event_name); - - // loading - void InvokeLoadAlgorithm(); - void LoadResource(); - void ScheduleLoadResource(); - void ClearNativeResource(); - void ClearResourceWithoutLocking(); - void NoneSupported(const String&); - void MediaEngineError(MediaError*); - void CancelPendingEventsAndCallbacks(); - - void SetShouldDelayLoadEvent(bool); - - void SetNetworkState(NetworkState, bool update_media_controls = true); - - void SetError(MediaError* error); - - void ResetMojoState(); - - String GetTypeAttribute() const; - - String GetSrcAttribute() const; - - String GetIdAttribute() const; - - String GetTagName() const; - - ParamMap GetParamList() const; - - gfx::Rect OwnerBoundingRect(); - - // Adds a new NativeBridgeObserver remote that will be notified about native - // bridge events and returns a receiver that an observer implementation can - // bind to. - mojo::PendingAssociatedReceiver - AddNativeBridgeObserverAndPassReceiver(); - - // Timers used to schedule one-shot tasks with no delay. - HeapTaskRunnerTimer load_timer_; - - Member async_event_queue_; - - NetworkState network_state_; - - // To prevent potential regression when extended by the MSE API, do not set - // |error_| outside of constructor and SetError(). - Member error_; - - cc::Layer* cc_layer_; - - gfx::Rect bounding_rect_; - - RectChangeCB bounding_rect_changed_cb_; - - typedef unsigned PendingActionFlags; - PendingActionFlags pending_action_flags_; - - // FIXME: HTMLNativeElement has way too many state bits. - bool should_delay_load_event_ : 1; - bool have_fired_loaded_data_ : 1; - - // data has not been loaded since sending a "stalled" event - bool sent_stalled_event_ : 1; - - bool processing_preference_change_ : 1; - - // Notify HTMLNativeElement when a document's ExecutionContext is destroyed. - // It allows us to disconnect from a previous document's frame if we were - // using it to support our WebMediaPlayer rather than our current frame. - class OpenerContextObserver final - : public GarbageCollected, - public ContextLifecycleObserver { - public: - // Notify `element` when our context is destroyed. - explicit OpenerContextObserver(HTMLNativeElement* element); - ~OpenerContextObserver() final; - - void Trace(Visitor* visitor) const final; - - protected: - void ContextDestroyed() final; - - Member element_; - }; - - // Clean up things that are tied to any previous frame, including the player - // and mojo interfaces, when we switch to a new frame. - void AttachToNewFrame(); - - Member opener_document_; - Member opener_context_observer_; - - std::unique_ptr web_native_bridge_; - int native_embed_id_; - - friend class Internals; - - Member lazy_load_intersection_observer_; - - Member>> - native_bridge_host_remote_; - - // Multiple objects outside of the renderer process can register as observers, - // so we need to store the remotes in a set here. - Member>> - native_bridge_observer_remote_set_; -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_HTML_MEDIA_HTML_NATIVE_ELEMENT_H_ diff --git a/blink/renderer/core/html/media/html_video_element.cc b/blink/renderer/core/html/media/html_video_element.cc index cee0a03c7e236edf9f2b504fe6f8c99ab44f5856..6213809666db38e877e8c4957d548fc3373f32aa 100644 --- a/blink/renderer/core/html/media/html_video_element.cc +++ b/blink/renderer/core/html/media/html_video_element.cc @@ -70,6 +70,10 @@ #include "third_party/blink/renderer/platform/runtime_enabled_features.h" #include "third_party/blink/renderer/platform/web_test_support.h" +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT +#include "third_party/blink/renderer/modules/media_controls/elements/mobile_data_prompt/mobile_data_prompt.h" +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + namespace blink { namespace { @@ -108,6 +112,13 @@ HTMLVideoElement::HTMLVideoElement(Document& document) EnsureUserAgentShadowRoot(); UpdateStateIfNeeded(); + +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + if (document.GetSettings()) { + allow_playback_with_mobile_data_ = + document.GetSettings()->IsPlaybackWithMobileDataAllowed(); + } +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT } void HTMLVideoElement::Trace(Visitor* visitor) const { @@ -116,6 +127,9 @@ void HTMLVideoElement::Trace(Visitor* visitor) const { visitor->Trace(wake_lock_); visitor->Trace(remoting_interstitial_); visitor->Trace(picture_in_picture_interstitial_); +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + visitor->Trace(mobile_data_prompts_); +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT Supplementable::Trace(visitor); HTMLMediaElement::Trace(visitor); } @@ -801,4 +815,38 @@ void HTMLVideoElement::RequestExitFullscreen() { } #endif // OHOS_CUSTOM_VIDEO_PLAYER +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT +void HTMLVideoElement::AllowPlaybackWithMobileData() { + LOG(INFO) << "AllowPlaybackWithMobileData"; + if (allow_playback_with_mobile_data_) { + return; + } + allow_playback_with_mobile_data_ = true; + + for (auto& mobile_data_prompt : mobile_data_prompts_) { + mobile_data_prompt->Hide(); + } + for (auto& observer : GetMediaPlayerObserverRemoteSet()) { + observer->OnPlaybackWithMobileDataAllowed(); + } +} + +bool HTMLVideoElement::IsPlaybackWithMobileDataAllowed() { + return allow_playback_with_mobile_data_; +} + +void HTMLVideoElement::AddMobileDataPrompt(MobileDataPrompt* mobile_data_prompt) { + mobile_data_prompts_.insert(mobile_data_prompt); +} + +bool HTMLVideoElement::IsPlaybackBlocked() { + for (auto& mobile_data_prompt : mobile_data_prompts_) { + if (mobile_data_prompt->Visible()) { + return true; + } + } + return false; +} +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + } // namespace blink diff --git a/blink/renderer/core/html/media/html_video_element.h b/blink/renderer/core/html/media/html_video_element.h index c2463fd0d0786a0d92e7197753da69c80e711305..6fe225c7ed0a086106d27d9770ec0a8d407d41ed 100644 --- a/blink/renderer/core/html/media/html_video_element.h +++ b/blink/renderer/core/html/media/html_video_element.h @@ -44,6 +44,10 @@ class PictureInPictureInterstitial; class StaticBitmapImage; class VideoWakeLock; +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT +class MobileDataPrompt; +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + class CORE_EXPORT HTMLVideoElement final : public HTMLMediaElement, public CanvasImageSource, @@ -160,6 +164,13 @@ class CORE_EXPORT HTMLVideoElement final VideoWakeLock* wake_lock_for_tests() const { return wake_lock_; } +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + void AllowPlaybackWithMobileData() final; + bool IsPlaybackWithMobileDataAllowed(); + void AddMobileDataPrompt(MobileDataPrompt*); + bool IsPlaybackBlocked() final; +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + protected: // EventTarget overrides. void AddedEventListener(const AtomicString& event_type, @@ -253,6 +264,11 @@ class CORE_EXPORT HTMLVideoElement final // Used to fulfill blink::Image requests (CreateImage(), // GetSourceImageForCanvas(), etc). Created on demand. std::unique_ptr resource_provider_; + +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + bool allow_playback_with_mobile_data_ = false; + HeapHashSet> mobile_data_prompts_; +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT }; } // namespace blink diff --git a/blink/renderer/core/html/media/video_wake_lock.cc b/blink/renderer/core/html/media/video_wake_lock.cc index 2600bb4dc1beaeb78dfb39f7a5406928f8365c17..7cbf188788f1eb3f756eec4d725e53b7898781b7 100644 --- a/blink/renderer/core/html/media/video_wake_lock.cc +++ b/blink/renderer/core/html/media/video_wake_lock.cc @@ -230,6 +230,7 @@ void VideoWakeLock::UpdateWakeLockService() { if (!wake_lock_service_) return; + LOG(INFO) << "OhMedia::UpdateWakeLockService active? " << active_; if (active_) { wake_lock_service_->RequestWakeLock(); } else { diff --git a/blink/renderer/core/html/resources/html.css b/blink/renderer/core/html/resources/html.css old mode 100755 new mode 100644 diff --git a/blink/renderer/core/input/event_handler.cc b/blink/renderer/core/input/event_handler.cc index 6c3e1e800fd7d4cf4530d0e6913474600945dbcd..bc6f21c6e6c9c674cc36ca0488094776fdcaeb53 100644 --- a/blink/renderer/core/input/event_handler.cc +++ b/blink/renderer/core/input/event_handler.cc @@ -331,7 +331,6 @@ HitTestResult EventHandler::HitTestResultAtLocation( const LayoutObject* stop_node, bool no_lifecycle_update) { TRACE_EVENT0("blink", "EventHandler::HitTestResultAtLocation"); - // We always send HitTestResultAtLocation to the main frame if we have one, // otherwise we might hit areas that are obscured by higher frames. if (frame_->GetPage()) { @@ -1105,7 +1104,12 @@ WebInputEventResult EventHandler::HandleMouseMoveOrLeaveEvent( mev.InnerNode()); LocalFrameView* view = frame_->View(); +#ifdef OHOS_DRAG_DROP + bool is_draging = mouse_event_manager_->IsDraging(); + if ((!is_remote_frame || is_portal) && view && !is_draging) { +#else if ((!is_remote_frame || is_portal) && view) { +#endif absl::optional optional_cursor = SelectCursor(mev.GetHitTestLocation(), mev.GetHitTestResult()); if (optional_cursor.has_value()) { @@ -2052,7 +2056,7 @@ WebInputEventResult EventHandler::SendContextMenuEvent( HitTestRequest request(HitTestRequest::kActive); #if defined(OHOS_EX_FREE_COPY) int hit_test_flag = 0; - if (event.menu_source_type == kMenuSourceSelectAndCopy) { + if (event.menu_source_type == kMenuSourceShowFreeCopyMenu) { hit_test_flag |= HitTestRequest::kReadOnly; } else { hit_test_flag |= HitTestRequest::kActive; @@ -2181,7 +2185,7 @@ WebInputEventResult EventHandler::ShowNonLocatedContextMenu( HitTestRequest request(HitTestRequest::kActive); #if defined(OHOS_EX_FREE_COPY) HitTestRequest::HitTestRequestType hit_test_request_type = 0; - if (source_type == kMenuSourceSelectAndCopy) { + if (source_type == kMenuSourceShowFreeCopyMenu) { hit_test_request_type |= HitTestRequest::kReadOnly; } else { hit_test_request_type |= HitTestRequest::kActive; diff --git a/blink/renderer/core/input/mouse_event_manager.cc b/blink/renderer/core/input/mouse_event_manager.cc index cfe9d62794744ebbd743d775d9eda5a81584886e..d48a85cf0fd1f0226e78c7bb87fa71882a770cbc 100644 --- a/blink/renderer/core/input/mouse_event_manager.cc +++ b/blink/renderer/core/input/mouse_event_manager.cc @@ -1118,6 +1118,13 @@ DragState& MouseEventManager::GetDragState() { return frame_->GetPage()->GetDragController().GetDragState(); } +#ifdef OHOS_DRAG_DROP +bool MouseEventManager::IsDraging() { + DCHECK(frame_->GetPage()); + return frame_->GetPage()->GetDragController().IsDraging(); +} +#endif + void MouseEventManager::ResetDragSource() { // Check validity of drag source. if (!frame_->GetPage()) @@ -1251,12 +1258,17 @@ void MouseEventManager::SetOverlayInProgress(bool flag) { } } +void MouseEventManager::OnDestroyImageAnalyzerOverlay() { + LOG(INFO) << "MouseEventManager::OnDestroyImageAnalyzerOverlay"; + overlay_in_progress_ = false; + last_analyzed_image_ = nullptr; +} + template void MouseEventManager::HandleCreateOverlay(T const& targeted_event) { if (!frame_ || !frame_->View()) { return; } - HitTestLocation location(frame_->View()->ConvertFromRootFrame( gfx::ToFlooredPoint(targeted_event.PositionInRootFrame()))); HitTestResult hit_test_result = @@ -1289,7 +1301,8 @@ void MouseEventManager::HandleCreateOverlay(T const& targeted_event) { bm, image_rect, gfx::Point(touch_point.x() - image_rect.x(), touch_point.y() - image_rect.y()), - base::BindRepeating(&MouseEventManager::SetOverlayInProgress, weak_ptr_factory_.GetWeakPtr())); + base::BindRepeating(&MouseEventManager::SetOverlayInProgress, weak_ptr_factory_.GetWeakPtr()), + base::BindRepeating(&MouseEventManager::OnDestroyImageAnalyzerOverlay, weak_ptr_factory_.GetWeakPtr())); } } #endif diff --git a/blink/renderer/core/input/mouse_event_manager.h b/blink/renderer/core/input/mouse_event_manager.h index 878e3c6c60468699e5214ab0c5a88fbdfc43735d..2dd96a421dedb23f880ef650257960f1ccd3e04f 100644 --- a/blink/renderer/core/input/mouse_event_manager.h +++ b/blink/renderer/core/input/mouse_event_manager.h @@ -100,6 +100,10 @@ class CORE_EXPORT MouseEventManager final DragState& GetDragState(); +#ifdef OHOS_DRAG_DROP + bool IsDraging(); +#endif + void FocusDocumentView(); // Resets the state that indicates the next events could cause a drag. It is @@ -156,6 +160,7 @@ class CORE_EXPORT MouseEventManager final void CreateOverlayCallback(); bool GetOverlayInProgress(); void SetOverlayInProgress(bool flag); + void OnDestroyImageAnalyzerOverlay(); template void HandleCreateOverlay(T const& targeted_event); #endif diff --git a/blink/renderer/core/input/pointer_event_manager.cc b/blink/renderer/core/input/pointer_event_manager.cc index 28a0047986b3e6ee11288ca49a87b67c643b78db..a5dd4b85e29627d490e0e6cc904f49c568578097 100644 --- a/blink/renderer/core/input/pointer_event_manager.cc +++ b/blink/renderer/core/input/pointer_event_manager.cc @@ -36,6 +36,7 @@ #if BUILDFLAG(IS_OHOS) #include "third_party/blink/renderer/core/frame/local_frame_client.h" #include "third_party/blink/renderer/core/frame/settings.h" +#include "third_party/blink/renderer/core/frame/visual_viewport.h" #include "third_party/blink/renderer/core/geometry/dom_rect.h" #include "third_party/blink/renderer/core/html/html_frame_owner_element.h" #include "third_party/blink/renderer/core/html/html_image_loader.h" diff --git a/blink/renderer/core/inspector/build.gni b/blink/renderer/core/inspector/build.gni index 084a3b190f22961d20f63f83381ff37abe187d42..3c6cc482c4dbdef03610289db70462cce9788320 100644 --- a/blink/renderer/core/inspector/build.gni +++ b/blink/renderer/core/inspector/build.gni @@ -136,6 +136,7 @@ blink_core_tests_inspector = [ "inspector_emulation_agent_test.cc", "inspector_highlight_test.cc", "inspector_history_test.cc", + "inspector_page_agent_unittest.cc", "inspector_media_context_impl_unittest.cc", "inspector_session_state_test.cc", "inspector_style_resolver_test.cc", diff --git a/blink/renderer/core/inspector/inspector_layer_tree_agent.cc b/blink/renderer/core/inspector/inspector_layer_tree_agent.cc index 74ced4e323e32f2b6b95c8e4b9fd83f3e0d59b39..9c11c0535e42493fc51a6b9be1a6659474b24e54 100644 --- a/blink/renderer/core/inspector/inspector_layer_tree_agent.cc +++ b/blink/renderer/core/inspector/inspector_layer_tree_agent.cc @@ -305,6 +305,11 @@ void InspectorLayerTreeAgent::GatherLayers( return; if (layer->layer_tree_host()->is_hud_layer(layer)) return; +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + if (layer->layer_tree_host()->is_toast_layer(layer)) { + return; + } +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT layers->emplace_back(BuildObjectForLayer(RootLayer(), layer)); for (auto child : layer->children()) GatherLayers(child.get(), layers); diff --git a/blink/renderer/core/inspector/inspector_page_agent.cc b/blink/renderer/core/inspector/inspector_page_agent.cc index 8f4b06c584a0d75a605d0afbdc2a47eee7292b6e..41911fc2316d1ebad943b0a99b2d20532a66bb69 100644 --- a/blink/renderer/core/inspector/inspector_page_agent.cc +++ b/blink/renderer/core/inspector/inspector_page_agent.cc @@ -480,6 +480,42 @@ String InspectorPageAgent::CachedResourceTypeJson( return ResourceTypeJson(ToResourceType(cached_resource.GetType())); } +InspectorPageAgent::PageReloadScriptInjection::PageReloadScriptInjection( + InspectorAgentState& agent_state) + : pending_script_to_evaluate_on_load_once_(&agent_state, + /*default_value=*/{}), + target_url_for_pending_script_(&agent_state, + /*default_value=*/{}) {} + +void InspectorPageAgent::PageReloadScriptInjection::clear() { + script_to_evaluate_on_load_once_ = {}; + pending_script_to_evaluate_on_load_once_.Set({}); + target_url_for_pending_script_.Set({}); +} + +void InspectorPageAgent::PageReloadScriptInjection::SetPending( + String script, + const KURL& target_url) { + pending_script_to_evaluate_on_load_once_.Set(script); + target_url_for_pending_script_.Set(target_url.GetString()); +} + +void InspectorPageAgent::PageReloadScriptInjection::PromoteToLoadOnce() { + script_to_evaluate_on_load_once_ = + pending_script_to_evaluate_on_load_once_.Get(); + target_url_for_active_script_ = target_url_for_pending_script_.Get(); + pending_script_to_evaluate_on_load_once_.Set({}); + target_url_for_pending_script_.Set({}); +} + +String InspectorPageAgent::PageReloadScriptInjection::GetScriptForInjection( + const KURL& target_url) { + if (target_url_for_active_script_ == target_url.GetString()) { + return script_to_evaluate_on_load_once_; + } + return {}; +} + InspectorPageAgent::InspectorPageAgent( InspectedFrames* inspected_frames, Client* client, @@ -505,7 +541,8 @@ InspectorPageAgent::InspectorPageAgent( /*default_value=*/false), standard_font_size_(&agent_state_, /*default_value=*/0), fixed_font_size_(&agent_state_, /*default_value=*/0), - script_font_families_cbor_(&agent_state_, std::vector()) {} + script_font_families_cbor_(&agent_state_, std::vector()), + script_injection_on_load_(agent_state_) {} void InspectorPageAgent::Restore() { if (enabled_.Get()) @@ -544,8 +581,7 @@ protocol::Response InspectorPageAgent::enable() { protocol::Response InspectorPageAgent::disable() { agent_state_.ClearAllFields(); pending_isolated_worlds_.clear(); - script_to_evaluate_on_load_once_ = String(); - pending_script_to_evaluate_on_load_once_ = String(); + script_injection_on_load_.clear(); instrumenting_agents_->RemoveInspectorPageAgent(this); inspector_resource_content_loader_->Cancel( resource_content_loader_client_id_); @@ -668,8 +704,9 @@ protocol::Response InspectorPageAgent::setAdBlockingEnabled(bool enable) { protocol::Response InspectorPageAgent::reload( Maybe optional_bypass_cache, Maybe optional_script_to_evaluate_on_load) { - pending_script_to_evaluate_on_load_once_ = - optional_script_to_evaluate_on_load.fromMaybe(""); + script_injection_on_load_.SetPending( + optional_script_to_evaluate_on_load.fromMaybe(""), + inspected_frames_->Root()->Loader().GetDocumentLoader()->Url()); v8_session_->setSkipAllPauses(true); return protocol::Response::Success(); } @@ -984,11 +1021,19 @@ void InspectorPageAgent::DidCreateMainWorldContext(LocalFrame* frame) { EvaluateScriptOnNewDocument(*frame, key); } - if (!script_to_evaluate_on_load_once_.empty()) { - ClassicScript::CreateUnspecifiedScript(script_to_evaluate_on_load_once_) - ->RunScript(frame->DomWindow(), - ExecuteScriptPolicy::kExecuteScriptWhenScriptsDisabled); + String script = script_injection_on_load_.GetScriptForInjection( + frame->Loader().GetDocumentLoader()->Url()); + if (script.empty()) { + return; } + ScriptState* script_state = ToScriptStateForMainWorld(frame); + if (!script_state) { + return; + } + + ClassicScript::CreateUnspecifiedScript(script)->RunScript( + frame->DomWindow(), + ExecuteScriptPolicy::kExecuteScriptWhenScriptsDisabled); } void InspectorPageAgent::EvaluateScriptOnNewDocument( @@ -1050,8 +1095,7 @@ void InspectorPageAgent::LoadEventFired(LocalFrame* frame) { void InspectorPageAgent::WillCommitLoad(LocalFrame*, DocumentLoader* loader) { if (loader->GetFrame() == inspected_frames_->Root()) { - script_to_evaluate_on_load_once_ = pending_script_to_evaluate_on_load_once_; - pending_script_to_evaluate_on_load_once_ = String(); + script_injection_on_load_.PromoteToLoadOnce(); } GetFrontend()->frameNavigated(BuildObjectForFrame(loader->GetFrame()), protocol::Page::NavigationTypeEnum::Navigation); diff --git a/blink/renderer/core/inspector/inspector_page_agent.h b/blink/renderer/core/inspector/inspector_page_agent.h index a1c17c7c1f84fb44ec2263403a740c77b336b143..3825fdb071a39b2af6762741a55710844bf62bb7 100644 --- a/blink/renderer/core/inspector/inspector_page_agent.h +++ b/blink/renderer/core/inspector/inspector_page_agent.h @@ -93,6 +93,22 @@ class CORE_EXPORT InspectorPageAgent final kOtherResource }; + class CORE_EXPORT PageReloadScriptInjection { + private: + String script_to_evaluate_on_load_once_; + String target_url_for_active_script_; + InspectorAgentState::String pending_script_to_evaluate_on_load_once_; + InspectorAgentState::String target_url_for_pending_script_; + + public: + explicit PageReloadScriptInjection(InspectorAgentState&); + + void clear(); + void SetPending(String script, const KURL& target_url); + void PromoteToLoadOnce(); + String GetScriptForInjection(const KURL& target_url); + }; + static bool CachedResourceContent(const Resource*, String* result, bool* base64_encoded); @@ -306,8 +322,6 @@ class CORE_EXPORT InspectorPageAgent final ad_script_identifiers_; v8_inspector::V8InspectorSession* v8_session_; Client* client_; - String pending_script_to_evaluate_on_load_once_; - String script_to_evaluate_on_load_once_; Member inspector_resource_content_loader_; int resource_content_loader_client_id_; InspectorAgentState::Boolean intercept_file_chooser_; @@ -322,6 +336,7 @@ class CORE_EXPORT InspectorPageAgent final InspectorAgentState::Integer standard_font_size_; InspectorAgentState::Integer fixed_font_size_; InspectorAgentState::Bytes script_font_families_cbor_; + PageReloadScriptInjection script_injection_on_load_; }; } // namespace blink diff --git a/blink/renderer/core/inspector/inspector_page_agent_unittest.cc b/blink/renderer/core/inspector/inspector_page_agent_unittest.cc new file mode 100644 index 0000000000000000000000000000000000000000..5f115c22ca08a4cf99d2e1a4b00fed32cfcaf7d9 --- /dev/null +++ b/blink/renderer/core/inspector/inspector_page_agent_unittest.cc @@ -0,0 +1,58 @@ +// Copyright 2024 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "third_party/blink/renderer/core/inspector/inspector_page_agent.h" + +#include "testing/gtest/include/gtest/gtest.h" +#include "third_party/blink/renderer/core/inspector/inspector_session_state.h" +#include "third_party/blink/renderer/platform/weborigin/kurl.h" + +class PageReloadScriptInjectionTest : public testing::Test { + protected: + blink::mojom::blink::DevToolsSessionStatePtr session_state_cookie_; + blink::InspectorAgentState agent_state_; + blink::InspectorPageAgent::PageReloadScriptInjection injection_; + blink::InspectorSessionState state_; + + public: + PageReloadScriptInjectionTest() + : agent_state_("page"), + injection_(agent_state_), + state_(session_state_cookie_.Clone()) {} + + void SetUp() override { agent_state_.InitFrom(&state_); } +}; + +TEST_F(PageReloadScriptInjectionTest, PromotesScript) { + blink::KURL url("http://example.com"); + injection_.SetPending("script", url); + ASSERT_TRUE(injection_.GetScriptForInjection(url).empty()); + injection_.PromoteToLoadOnce(); + ASSERT_EQ(injection_.GetScriptForInjection(url), "script"); + injection_.PromoteToLoadOnce(); + ASSERT_TRUE(injection_.GetScriptForInjection(url).empty()); +} + +TEST_F(PageReloadScriptInjectionTest, ClearsScript) { + blink::KURL url("http://example.com"); + injection_.SetPending("script", url); + injection_.clear(); + injection_.PromoteToLoadOnce(); + ASSERT_TRUE(injection_.GetScriptForInjection(url).empty()); + + injection_.SetPending("script", url); + injection_.PromoteToLoadOnce(); + ASSERT_EQ(injection_.GetScriptForInjection(url), "script"); + injection_.clear(); + ASSERT_TRUE(injection_.GetScriptForInjection(url).empty()); +} + +TEST_F(PageReloadScriptInjectionTest, ChecksLoaderId) { + blink::KURL url("http://example.com"); + blink::KURL url2("about:blank"); + injection_.SetPending("script", url); + injection_.PromoteToLoadOnce(); + ASSERT_TRUE(injection_.GetScriptForInjection(url2).empty()); +} + diff --git a/blink/renderer/core/layout/hit_test_result.h b/blink/renderer/core/layout/hit_test_result.h index fcf187b4d2c5b62b9d626472ee2b8f5b0b3077f7..1a9528f6c8a30b8d237d63bab54163d749d892c9 100644 --- a/blink/renderer/core/layout/hit_test_result.h +++ b/blink/renderer/core/layout/hit_test_result.h @@ -208,6 +208,10 @@ class CORE_EXPORT HitTestResult { // the return value is const. const NodeSet& ListBasedTestResult() const; +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + NodeSet& MutableListBasedTestResult(); // See above. +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + // Collapse the rect-based test result into a single target at the specified // location. HitTestLocation ResolveRectBasedTest( @@ -221,7 +225,9 @@ class CORE_EXPORT HitTestResult { #endif private: +#ifndef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT NodeSet& MutableListBasedTestResult(); // See above. +#endif // !OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT HTMLMediaElement* MediaElement() const; std::tuple AddNodeToListBasedTestResultInternal(Node* node, diff --git a/blink/renderer/core/layout/layout_box_model_object.cc b/blink/renderer/core/layout/layout_box_model_object.cc index 0eecf1c82d7c0a264c6da498f101f8ecb620eb80..613969cd136cbb2d5e9fbf6d0f8854ef2fe0d6b0 100644 --- a/blink/renderer/core/layout/layout_box_model_object.cc +++ b/blink/renderer/core/layout/layout_box_model_object.cc @@ -490,7 +490,7 @@ PhysicalRect LayoutBoxModelObject::PhysicalVisualOverflowRectIncludingFilters() const { NOT_DESTROYED(); PhysicalRect bounds_rect = PhysicalVisualOverflowRect(); - if (!StyleRef().HasFilter()) + if (!HasReflection() && !StyleRef().HasFilter()) return bounds_rect; gfx::RectF float_rect(bounds_rect); gfx::RectF filter_reference_box = Layer()->FilterReferenceBox(); diff --git a/blink/renderer/core/layout/layout_native.cc b/blink/renderer/core/layout/layout_native.cc old mode 100755 new mode 100644 index 37202402c40dd1a752ceae6328853b807e57ca54..fbb4a780b078e5accb9265303297d63bfa58a3a1 --- a/blink/renderer/core/layout/layout_native.cc +++ b/blink/renderer/core/layout/layout_native.cc @@ -23,15 +23,8 @@ namespace blink { -namespace { - -const float kInitEffectZoom = 1.0f; - -} // namespace - LayoutNative::LayoutNative(Element* native) : LayoutImage(native) { SetImageResource(MakeGarbageCollected()); - SetIntrinsicSize(CalculateIntrinsicSize(kInitEffectZoom)); } LayoutNative::~LayoutNative() = default; @@ -40,120 +33,17 @@ void LayoutNative::Trace(Visitor* visitor) const { LayoutImage::Trace(visitor); } -LayoutSize LayoutNative::DefaultSize() { - return LayoutSize(kDefaultWidth, kDefaultHeight); -} - -void LayoutNative::UpdateIntrinsicSize(bool is_in_layout) { - NOT_DESTROYED(); - LayoutSize size = CalculateIntrinsicSize(StyleRef().EffectiveZoom()); - // Never set the element size to zero when in a media document. - if (size.IsEmpty() && GetNode()->ownerDocument() && - GetNode()->ownerDocument()->IsMediaDocument()) { - return; - } - - if (auto* layout_view = View()) { - size = LayoutSize(layout_view->GetLayoutSize()); - } - - if (size == IntrinsicSize()) { - return; - } - - SetIntrinsicSize(size); - SetIntrinsicLogicalWidthsDirty(); - if (!is_in_layout) { - SetNeedsLayoutAndFullPaintInvalidation( - layout_invalidation_reason::kSizeChanged); - } - - if (!NativeElement() || !NativeElement()->NativeLoader()) { - return; - } - NativeElement()->NativeLoader()->UpdateSize(gfx::Size(size.Width().ToInt(), - size.Height().ToInt())); -} - -LayoutSize LayoutNative::CalculateIntrinsicSize(float scale) { - NOT_DESTROYED(); - - LayoutSize size = DefaultSize(); - size.Scale(scale); - - if (!NativeElement() || !NativeElement()->NativeLoader()) { - return size; - } - - if (const auto* content = - NativeElement()->NativeLoader()->GetWebNativeBridge()) { - gfx::Size nature_size = content->NaturalSize(); - if (!nature_size.IsEmpty()) { - LayoutSize layout_size = LayoutSize(nature_size); - layout_size.Scale(scale); - return layout_size; - } - } - - return size; -} - -void LayoutNative::ImageChanged(WrappedImagePtr new_image, - CanDeferInvalidation defer) { - NOT_DESTROYED(); - LayoutImage::ImageChanged(new_image, defer); - - // The intrinsic size is now that of the image, but in case we already had the - // intrinsic size of the video we call this here to restore the video size. - UpdateIntrinsicSize(/* is_in_layout */ false); -} - void LayoutNative::PaintReplaced(const PaintInfo& paint_info, const PhysicalOffset& paint_offset) const { NOT_DESTROYED(); NativePainter(*this).PaintReplaced(paint_info, paint_offset); } -void LayoutNative::UpdateLayout() { - NOT_DESTROYED(); - UpdateNativeContent(/* is_in_layout */ true); - - LayoutImage::UpdateLayout(); -} - -HTMLPlugInElement* LayoutNative::NativeElement() const { +HTMLPlugInElement* LayoutNative::PluginElement() const { NOT_DESTROYED(); return To(GetNode()); } -void LayoutNative::UpdateFromElement() { - NOT_DESTROYED(); - LayoutImage::UpdateFromElement(); - UpdateNativeContent(/* is_in_layout */ false); - - SetShouldDoFullPaintInvalidation(); -} - -void LayoutNative::UpdateNativeContent(bool is_in_layout) { - NOT_DESTROYED(); - UpdateIntrinsicSize(is_in_layout); - - if (!NativeElement() || !NativeElement()->NativeLoader()) { - return; - } - - auto* native_bridge = NativeElement()->NativeLoader()->GetWebNativeBridge(); - if (!native_bridge) { - return; - } - - if (!NativeElement()->InActiveDocument()) { - return; - } - - NativeElement()->SetNeedsCompositingUpdate(); -} - PhysicalRect LayoutNative::ReplacedContentRectFrom( const LayoutSize size, const NGPhysicalBoxStrut& border_padding) const { @@ -165,10 +55,10 @@ PhysicalRect LayoutNative::ReplacedContentRectFrom( bool LayoutNative::SupportsAcceleratedRendering() const { NOT_DESTROYED(); - if (!NativeElement() || !NativeElement()->NativeLoader()) { + if (!PluginElement() || !PluginElement()->NativeLoader()) { return false; } - return !!NativeElement()->NativeLoader()->CcLayer(); + return !!PluginElement()->NativeLoader()->CcLayer(); } CompositingReasons LayoutNative::AdditionalCompositingReasons() const { diff --git a/blink/renderer/core/layout/layout_native.h b/blink/renderer/core/layout/layout_native.h old mode 100755 new mode 100644 index af8b839efc51e87e0162671b160f7f0c0f0ad90f..15b386486c8947b7e1c26560d54fde2b0b8fcf06 --- a/blink/renderer/core/layout/layout_native.h +++ b/blink/renderer/core/layout/layout_native.h @@ -36,7 +36,7 @@ class LayoutNative final : public LayoutImage { bool SupportsAcceleratedRendering() const; - HTMLPlugInElement* NativeElement() const; + HTMLPlugInElement* PluginElement() const; const char* GetName() const override { NOT_DESTROYED(); @@ -49,11 +49,6 @@ class LayoutNative final : public LayoutImage { } private: - void UpdateFromElement() override; - - LayoutSize CalculateIntrinsicSize(float scale); - void UpdateIntrinsicSize(bool is_in_layout); - bool IsChildAllowed(LayoutObject*, const ComputedStyle&) const final { NOT_DESTROYED(); return false; @@ -64,8 +59,6 @@ class LayoutNative final : public LayoutImage { return false; } - void ImageChanged(WrappedImagePtr, CanDeferInvalidation) override; - bool IsOfType(LayoutObjectType type) const override { NOT_DESTROYED(); return type == kLayoutObjectNative || LayoutImage::IsOfType(type); @@ -74,21 +67,17 @@ class LayoutNative final : public LayoutImage { void PaintReplaced(const PaintInfo&, const PhysicalOffset& paint_offset) const override; - void UpdateLayout() override; - bool CanHaveAdditionalCompositingReasons() const override { NOT_DESTROYED(); return true; } CompositingReasons AdditionalCompositingReasons() const override; - - void UpdateNativeContent(bool is_in_layout); }; template <> struct DowncastTraits { static bool AllowFrom(const LayoutObject& object) { - return object.IsLayoutImage(); + return object.IsLayoutNative(); } }; diff --git a/blink/renderer/core/layout/layout_view.cc b/blink/renderer/core/layout/layout_view.cc index e0d26db254e446af54d94843c47c27d1a0ee7067..2dae0d84eaca802cbb2872c1d07b12f49d755538 100644 --- a/blink/renderer/core/layout/layout_view.cc +++ b/blink/renderer/core/layout/layout_view.cc @@ -70,6 +70,11 @@ #include "third_party/blink/renderer/platform/fonts/font_cache.h" #endif +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT +#include "third_party/blink/renderer/core/frame/settings.h" +#include "third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h" +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + namespace blink { namespace { @@ -158,6 +163,21 @@ bool LayoutView::HitTest(const HitTestLocation& location, HitTestLatencyRecorder hit_test_latency_recorder( result.GetHitTestRequest().AllowsChildFrameContent()); +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + bool media_network_traffic_prompt_enabled = + GetDocument().GetSettings() && + GetDocument().GetSettings()->IsMediaNetworkTrafficPromptEnabled(); + if (media_network_traffic_prompt_enabled) { + LocalFrameView* frame_view = GetFrameView(); + if (frame_view && frame_view->GetPaintArtifactCompositor()) { + bool hit_layer = + frame_view->GetPaintArtifactCompositor()->TryHitTest(location, result); + if (hit_layer) { + return hit_layer; + } + } + } +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT return HitTestNoLifecycleUpdate(location, result); } diff --git a/blink/renderer/core/loader/alternate_signed_exchange_resource_info.cc b/blink/renderer/core/loader/alternate_signed_exchange_resource_info.cc index 3d2cd9f5e5c11041f8962adb8badf6028f74b569..2da4e56e8d0accec2ab626d9b3d6431ffce2403c 100644 --- a/blink/renderer/core/loader/alternate_signed_exchange_resource_info.cc +++ b/blink/renderer/core/loader/alternate_signed_exchange_resource_info.cc @@ -29,13 +29,23 @@ constexpr char kAllowedAltSxg[] = "allowed-alt-sxg"; const char kDefaultAcceptHeader[] = "*/*"; const char kStylesheetAcceptHeader[] = "text/css,*/*;q=0.1"; +#if BUILDFLAG(IS_OHOS) +#if BUILDFLAG(ENABLE_AV1_DECODER) +constexpr char kImageAcceptHeader[] = + "image/avif,image/heif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8"; +#else +constexpr char kImageAcceptHeader[] = + "image/heif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8"; +#endif // BUILDFLAG(ENABLE_AV1_DECODER) +#else #if BUILDFLAG(ENABLE_AV1_DECODER) constexpr char kImageAcceptHeader[] = "image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8"; #else constexpr char kImageAcceptHeader[] = "image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8"; -#endif +#endif // BUILDFLAG(ENABLE_AV1_DECODER) +#endif // BUILDFLAG(IS_WIN) using AlternateSignedExchangeMachingKey = std::pairAllowLoad(url, request_context, reporting_disposition))) { - LOG(WARNING) << "[AdBlock] Subresource request blocked : " - << url.GetString().Utf8(); + LOG(WARNING) << "[AdBlock] Subresource request blocked : ***"; return ResourceRequestBlockedReason::kSubresourceFilter; } if ((GetUserSubresourceFilter() && !GetUserSubresourceFilter()->AllowLoad(url, request_context, reporting_disposition))) { - LOG(WARNING) << "[User AdBlock] Subresource request blocked : " - << url.GetString().Utf8(); + LOG(WARNING) << "[User AdBlock] Subresource request blocked : ***"; return ResourceRequestBlockedReason::kSubresourceFilter; } #else if (GetSubresourceFilter()) { if (!GetSubresourceFilter()->AllowLoad(url, request_context, reporting_disposition)) { - LOG(WARNING) << "[AdBlock] Subresource request blocked : " - << url.GetString().Utf8(); + LOG(WARNING) << "[AdBlock] Subresource request blocked : ***"; return ResourceRequestBlockedReason::kSubresourceFilter; } } diff --git a/blink/renderer/core/loader/base_fetch_context_test.cc b/blink/renderer/core/loader/base_fetch_context_test.cc index 017f9d8eef0a27c7407cc2a7cfbd13d605b5c4f3..24e7b559832f29c42a3b594f8ffdf0d4b6afb935 100644 --- a/blink/renderer/core/loader/base_fetch_context_test.cc +++ b/blink/renderer/core/loader/base_fetch_context_test.cc @@ -64,11 +64,6 @@ class MockBaseFetchContext final : public BaseFetchContext { const override { return SecurityOrigin::CreateUniqueOpaque(); } -#ifdef OHOS_ARKWEB_ADBLOCK - SubresourceFilter* GetUserSubresourceFilter() const override { - return {}; - } -#endif bool AllowScriptFromSource(const KURL&) const override { return false; } SubresourceFilter* GetSubresourceFilter() const override { return nullptr; } bool ShouldBlockRequestByInspector(const KURL&) const override { diff --git a/blink/renderer/core/loader/cookie_jar.cc b/blink/renderer/core/loader/cookie_jar.cc index a7e9215aebd94201c675267078984e2e71a75b1c..415bca57f38f1b7ec9dc658fe90fd7f66bc9aa3c 100644 --- a/blink/renderer/core/loader/cookie_jar.cc +++ b/blink/renderer/core/loader/cookie_jar.cc @@ -69,9 +69,9 @@ void CookieJar::SetCookie(const String& value) { if (cookie_url.IsEmpty()) return; - #if BUILDFLAG(IS_OHOS) - helper_.NoticeCookieChanged(); - #endif +#if BUILDFLAG(IS_OHOS) + helper_.NoticeCookieChanged(); +#endif base::ElapsedTimer timer; bool requested = RequestRestrictedCookieManagerIfNeeded(); diff --git a/blink/renderer/core/loader/cookie_jar_helper.cc b/blink/renderer/core/loader/cookie_jar_helper.cc index c26bdcfb19a4af980e489f3142df268c9f499f68..400c54bf74e3040b96d1f60bb7e90411a3ced4a2 100644 --- a/blink/renderer/core/loader/cookie_jar_helper.cc +++ b/blink/renderer/core/loader/cookie_jar_helper.cc @@ -68,7 +68,7 @@ bool CookieJarHelper::IPCNeeded(CookieBackend* backend) { buffer_ = mojo::SharedBufferHandle::Create(sizeof(bool)); if (buffer_.is_valid()) { mapping_ = buffer_->Map(sizeof(bool)); - auto handle = + auto handle = buffer_->Clone(mojo::SharedBufferHandle::AccessMode::READ_WRITE); backend->get()->RegisterCookieChangeObserver( cookie_url, document_->SiteForCookies(), document_->TopFrameOrigin(), @@ -90,7 +90,6 @@ void CookieJarHelper::NoticeCookieChanged() { *cookie_changed = true; } - CookieJarHelper::ShmRegisterRecord* CookieJarHelper::getOrCreateShmRegisterRecord() { for (auto item : shm_record_list_) { @@ -100,7 +99,7 @@ CookieJarHelper::getOrCreateShmRegisterRecord() { return item; } } - CookieJarHelper::ShmRegisterRecord* record = + CookieJarHelper::ShmRegisterRecord* record = new CookieJarHelper::ShmRegisterRecord( document_->CookieURL(), document_->SiteForCookies(), document_->TopFrameOrigin()); diff --git a/blink/renderer/core/loader/cookie_jar_helper.h b/blink/renderer/core/loader/cookie_jar_helper.h index e17e838f3742dd37d3a0968be15bcd0e75ed2ef5..05bf5f66a9658d6c6cfd1e9e13514a66b43e236b 100644 --- a/blink/renderer/core/loader/cookie_jar_helper.h +++ b/blink/renderer/core/loader/cookie_jar_helper.h @@ -20,7 +20,7 @@ namespace blink { class CookieJarHelper { public: - using CookieBackend = + using CookieBackend = HeapMojoRemote; explicit CookieJarHelper(Document* document); diff --git a/blink/renderer/core/loader/document_loader.cc b/blink/renderer/core/loader/document_loader.cc index 5f14cc16b46fa0b9f8a1671341bd4b9232496ec7..5d7b727f80af32b59968f87ce784b8c9470a536e 100644 --- a/blink/renderer/core/loader/document_loader.cc +++ b/blink/renderer/core/loader/document_loader.cc @@ -517,7 +517,7 @@ DocumentLoader::DocumentLoader( params_->origin_agent_cluster_left_as_default), is_cross_site_cross_browsing_context_group_( params_->is_cross_site_cross_browsing_context_group), - should_have_sticky_user_activation_( + should_have_sticky_user_activation_( params_->should_have_sticky_user_activation), navigation_api_back_entries_(params_->navigation_api_back_entries), navigation_api_forward_entries_(params_->navigation_api_forward_entries), @@ -1653,6 +1653,11 @@ void DocumentLoader::SetDefersLoading(LoaderFreezeMode mode) { void DocumentLoader::DetachFromFrame(bool flush_microtask_queue) { DCHECK(frame_); + +#ifdef OHOS_LOG_MESSAGE + LOG(INFO) << "Document loader DetachFromFrame, url: ***"; +#endif + StopLoading(); // `frame_` may become null because this method can get re-entered. If it // is null we've already run the code below so just return early. @@ -1854,6 +1859,11 @@ void DocumentLoader::StartLoadingResponse() { // always be a frame here. if (frame_ && frame_->GetDocument()->IsMediaDocument()) { parser_->Finish(); + +#ifdef OHOS_LOG_MESSAGE + LOG(INFO) << "Document loader StartLoadingResponse, url: ***"; +#endif + StopLoading(); return; } @@ -2580,6 +2590,7 @@ void DocumentLoader::CommitNavigation() { } else { frame_->SetStickyUserActivationState(); } + // The DocumentLoader was flagged as activated if it needs to notify the frame // that it was activated before navigation. Update the frame state based on // the new value. diff --git a/blink/renderer/core/loader/empty_clients.h b/blink/renderer/core/loader/empty_clients.h index d24fc2a01bca6e324e091ddd163e86227b36338c..f40dbcff65008283730e279e1e1d81da1370e6b2 100644 --- a/blink/renderer/core/loader/empty_clients.h +++ b/blink/renderer/core/loader/empty_clients.h @@ -264,7 +264,8 @@ class CORE_EXPORT EmptyChromeClient : public ChromeClient { const SkBitmap& image, const gfx::Rect& image_rect, const gfx::Point& touch_point, - OnTextSelectedCallback callback) override {} + OnTextSelectedCallback callback, + OnDestroyImageAnalyzerOverlayCallback destroy_callback) override {} #endif private: const display::ScreenInfos empty_screen_infos_{display::ScreenInfo()}; diff --git a/blink/renderer/core/loader/form_submission.cc b/blink/renderer/core/loader/form_submission.cc index 5b599997782b7fe322367993abd9768aa05db124..35bc2b104ec7c2a4866f214bd92713da1f08d188 100644 --- a/blink/renderer/core/loader/form_submission.cc +++ b/blink/renderer/core/loader/form_submission.cc @@ -58,12 +58,6 @@ #include "third_party/blink/renderer/platform/wtf/text/string_builder.h" #include "third_party/blink/renderer/platform/wtf/text/text_encoding.h" -#ifdef OHOS_EX_BLANK_TARGET_POPUP_INTERCEPT -#include "base/command_line.h" -#include "content/public/common/content_switches.h" -#include "third_party/blink/renderer/core/frame/settings.h" -#endif - namespace blink { static int64_t GenerateFormDataIdentifier() { @@ -353,24 +347,6 @@ FormSubmission* FormSubmission::Create(HTMLFormElement* form, frame_request.SetNoOpener(); } -#ifdef OHOS_EX_BLANK_TARGET_POPUP_INTERCEPT - if ((*base::CommandLine::ForCurrentProcess()) - .HasSwitch(switches::kForBrowser)) { - bool blank_target_popup_intercept_enabled = true; - Settings* settings = form->GetDocument().GetFrame()->GetSettings(); - if (settings) { - blank_target_popup_intercept_enabled = - settings->IsBlankTargetPopupInterceptEnabled(); - } - if (blank_target_popup_intercept_enabled && - !form->GetDocument().GetFrame()->Tree().FindFrameByName( - target_or_base_target)) { - LOG(WARNING) << "FormSubmission::Navigate has fixed target frame to _top"; - target_or_base_target = "_top"; - } - } -#endif - Frame* target_frame = form->GetDocument() .GetFrame() diff --git a/blink/renderer/core/loader/frame_fetch_context_test.cc b/blink/renderer/core/loader/frame_fetch_context_test.cc index 610b4e5ba22c29c08e680cd3dacdac2691ef309b..d9f792049c254d9a7599ff7c58a205fb0d915293 100644 --- a/blink/renderer/core/loader/frame_fetch_context_test.cc +++ b/blink/renderer/core/loader/frame_fetch_context_test.cc @@ -156,52 +156,6 @@ class FixedPolicySubresourceFilter : public WebDocumentSubresourceFilter { LoadPolicy GetLoadPolicyForWebTransportConnect(const WebURL&) override { return policy_; } - - #ifdef OHOS_ARKWEB_ADBLOCK - void ClearStatistics() override {} - - std::unique_ptr GetElementHidingSelectors( - const WebURL& document_url, - bool need_common_selectors) override { - return {}; - } - - bool HasGenericHideTypeOption( - const WebURL& document_url, - const url::Origin& parent_document_origin) override { - return false; - } - - bool HasElemHideTypeOption( - const WebURL& document_url, - const url::Origin& parent_document_origin) override { - return false; - } - - bool HasDocumentTypeOption( - const WebURL& document_url, - const url::Origin& parent_document_origin) override { - return false; - } - - void DidMatchCssRule(const WebURL& document_url, - const std::string& dom_path, - // unsigned rule_line_num = 0, - bool is_for_report = false) override {} - - void SetDidFinishLoad(bool did_load_finished) override {} - - bool GetDidFinishLoad() override { - return false; - } - - std::unique_ptr> GetUserDomPathSelectors( - const blink::WebURL& document_url, - bool need_generic_selectors) override { - return {}; - } - #endif - void ReportDisallowedLoad() override { ++*filtered_load_counter_; } bool ShouldLogToConsole() override { return false; } diff --git a/blink/renderer/core/loader/frame_loader.cc b/blink/renderer/core/loader/frame_loader.cc index 79bf5279beb23bfe2af1383b78951ebf9dd730e8..2fc545f4e7fe8f4b7ea603cf05ca0a5edd785958 100644 --- a/blink/renderer/core/loader/frame_loader.cc +++ b/blink/renderer/core/loader/frame_loader.cc @@ -1117,6 +1117,11 @@ void FrameLoader::CommitNavigation( // document. if (commit_reason == CommitReason::kXSLT && document_loader_) document_loader_->SetSentDidFinishLoad(); + +#ifdef OHOS_LOG_MESSAGE + LOG(INFO) << "Frame loader CommitNavigation, url: ***"; +#endif + if (!DetachDocument()) { DCHECK(!is_provisional); return; @@ -1234,8 +1239,17 @@ void FrameLoader::StopAllLoaders(bool abort_client) { frame_->GetDocument()->CancelParsing(); frame_->DomWindow()->navigation()->InformAboutCanceledNavigation(); + +#ifdef OHOS_LOG_MESSAGE + if (document_loader_) { + LOG(INFO) << "Frame loader StopAllLoaders, url: ***"; + document_loader_->StopLoading(); + } +#else if (document_loader_) document_loader_->StopLoading(); +#endif + if (abort_client) CancelClientNavigation(); else diff --git a/blink/renderer/core/loader/mixed_content_checker.cc b/blink/renderer/core/loader/mixed_content_checker.cc index 3104cbf8494df84951e8f382faca23e4d5152ca4..760c88db0047540a4b1606eeda6833db5724084b 100644 --- a/blink/renderer/core/loader/mixed_content_checker.cc +++ b/blink/renderer/core/loader/mixed_content_checker.cc @@ -474,7 +474,7 @@ bool MixedContentChecker::ShouldBlockFetch( allowed = !strict_mode; } else { allowed = !strict_mode && !GURL(url).HostIsIPAddress(); - } + }; #else allowed = !strict_mode && !GURL(url).HostIsIPAddress(); #endif diff --git a/blink/renderer/core/loader/native_loader.cc b/blink/renderer/core/loader/native_loader.cc index 05286aa39c589347bf9ab316aa376ff8b571c366..091bc3db6e55c0e68716551173d96abfeb19d51d 100644 --- a/blink/renderer/core/loader/native_loader.cc +++ b/blink/renderer/core/loader/native_loader.cc @@ -149,14 +149,6 @@ void NativeLoader::LoadResource(LocalFrame* frame) { web_native_bridge_->StartPipeline(); } -gfx::Rect NativeLoader::PluginBoundingRect() { - if (bounding_rect_.IsEmpty()) { - bounding_rect_ = plugin_element_->PixelSnappedBoundingBox(); - } - - return bounding_rect_; -} - void NativeLoader::OnCreateNativeSurface(int native_embed_id, RectChangeCB rect_changed_cb) { LOG(INFO) << "[NativeEmbed] NativeLoader::OnCreateNativeSurface"; @@ -164,10 +156,19 @@ void NativeLoader::OnCreateNativeSurface(int native_embed_id, return; } - if (PluginBoundingRect().IsEmpty()) { + if (bounding_rect_.IsEmpty()) { plugin_element_->GetDocument().UpdateStyleAndLayoutForNode( plugin_element_, DocumentUpdateReason::kPlugin); + if (auto* layout_object = plugin_element_->GetLayoutObject()) { + const auto& replaced = To(layout_object); + bounding_rect_ = ToPixelSnappedRect(replaced->ReplacedContentRect()); + } + if (bounding_rect_.IsEmpty()) { + first_update_rect_ = false; + } } + LOG(INFO) << "NativeEmbed NativeLoader::OnCreateNativeSurface:" + << bounding_rect_.ToString(); native_embed_id_ = native_embed_id; bounding_rect_changed_cb_ = rect_changed_cb; @@ -181,7 +182,7 @@ void NativeLoader::OnCreateNativeSurface(int native_embed_id, bounding_rect_.set_origin(bounds_to_viewport.origin()); embed_info->rect = bounds_to_viewport; if (!bounding_rect_changed_cb_.is_null()) { - bounding_rect_changed_cb_.Run(bounds_to_viewport, false); + bounding_rect_changed_cb_.Run(bounds_to_viewport); } } @@ -208,47 +209,32 @@ void NativeLoader::OnCreateNativeSurface(int native_embed_id, void NativeLoader::OnLayerRectVisibilityChange(bool visibility) { visibility_ = visibility; first_update_visibility = true; - if(native_embed_id_ != -1) { + if (native_embed_id_ != -1) { for (auto& observer : native_bridge_observer_remote_set_->Value()) { observer->OnLayerRectVisibilityChange(visibility_, native_embed_id_); } } } -void NativeLoader::UpdateSize(gfx::Size size) { - String native_type = GetTypeAttribute(); - LOG(INFO) << "NativeEmbed size:" << size.ToString() << ",native_type:" << native_type; - if (native_type == "native/video") { - return; - } - if (PluginBoundingRect().size() != size) { - if (!bounding_rect_changed_cb_.is_null()) { - bounding_rect_changed_cb_.Run(BoundsToViewport(bounding_rect_, plugin_element_->GetDocument()), true); - } - } -} - void NativeLoader::OnLayerRectChange(const gfx::Rect& rect) { - if (PluginBoundingRect().ApproximatelyEqual(rect, 1) || + if (bounding_rect_.ApproximatelyEqual(rect, 1) || !native_bridge_observer_remote_set_) { return; } - if (PluginBoundingRect().size() != rect.size()) { + if (bounding_rect_.size() != rect.size()) { bounding_rect_ = rect; if (!bounding_rect_changed_cb_.is_null()) { - bounding_rect_changed_cb_.Run(BoundsToViewport(bounding_rect_, plugin_element_->GetDocument()), true); + bounding_rect_changed_cb_.Run(BoundsToViewport(bounding_rect_, plugin_element_->GetDocument())); } } else { bounding_rect_.set_origin(rect.origin()); } + LOG(INFO) << "NativeEmbed NativeLoader::OnLayerRectChange:" + << bounding_rect_.ToString(); for (auto& observer : native_bridge_observer_remote_set_->Value()) { - observer->OnEmbedRectChange(gfx::Rect( - bounding_rect_.origin(), - gfx::ScaleToCeiledSize( - bounding_rect_.size(), - PageConstraintInitalScale(plugin_element_->GetDocument())))); + observer->OnEmbedRectChange(BoundsToViewport(bounding_rect_, plugin_element_->GetDocument())); } } @@ -287,7 +273,6 @@ void NativeLoader::SetCcLayer(cc::Layer* cc_layer) { << GetTypeAttribute(); cc_layer_->SetMayContainNative(true); cc_layer_->SetNeedsPushProperties(); - cc_layer_->SetIsNativeVideo(GetTypeAttribute() == "native/video"); } } diff --git a/blink/renderer/core/loader/native_loader.h b/blink/renderer/core/loader/native_loader.h index a55f2d3d129d1aa939a0da24a17b06f246dd4feb..beffcfd194e3c174e1a5c00f1319eae9e4c2fccb 100644 --- a/blink/renderer/core/loader/native_loader.h +++ b/blink/renderer/core/loader/native_loader.h @@ -73,6 +73,8 @@ class CORE_EXPORT NativeLoader HTMLPlugInElement* current_plugin_element() { return plugin_element_.Get(); } + void Dispose(); + // WebNativeClient implementation. void OnCreateNativeSurface(int native_embed_id, RectChangeCB rect_changed_cb) final; @@ -81,15 +83,12 @@ class CORE_EXPORT NativeLoader void OnDestroyNativeSurface() final; void Repaint() final; void SetCcLayer(cc::Layer*) final; - void UpdateSize(gfx::Size size); virtual String DebugName() const = 0; protected: // Assert the correct order of the children in shadow dom when DCHECK is on. static void AssertShadowRootChildren(ShadowRoot&); - void Dispose(); - // Returns a constant reference to the HeapMojoAssociatedRemoteSet holding all // the bound remotes for the media::mojom::blink::MediaPlayerObserver // interface. Needed to allow sending messages directly from @@ -121,7 +120,6 @@ class CORE_EXPORT NativeLoader String GetIdAttribute() const; String GetTagName() const; ParamMap GetParamList() const; - gfx::Rect PluginBoundingRect(); // Adds a new NativeBridgeObserver remote that will be notified about native // bridge events and returns a receiver that an observer implementation can @@ -142,7 +140,7 @@ class CORE_EXPORT NativeLoader void AttachToNewFrame(); std::unique_ptr web_native_bridge_; - int native_embed_id_; + int native_embed_id_ = -1; bool visibility_ = false; bool first_update_visibility = false; diff --git a/blink/renderer/core/loader/navigation_policy.cc b/blink/renderer/core/loader/navigation_policy.cc index 724844748c3e91e3ab46f16950131bc4d307d92c..8e6059123cc97a07b63edd60f33497e1c66109a3 100644 --- a/blink/renderer/core/loader/navigation_policy.cc +++ b/blink/renderer/core/loader/navigation_policy.cc @@ -64,7 +64,8 @@ NavigationPolicy NavigationPolicyFromEventModifiers(int16_t button, return shift ? kNavigationPolicyNewForegroundTab : kNavigationPolicyNewBackgroundTab; } - return shift ? kNavigationPolicyNewWindow : kNavigationPolicyDownload; + LOG(INFO) << "navigation policy from event modifiers " << shift; + return shift ? kNavigationPolicyNewWindow : kNavigationPolicyCurrentTab; } NavigationPolicy NavigationPolicyFromEventInternal(const Event* event) { diff --git a/blink/renderer/core/loader/ping_loader.cc b/blink/renderer/core/loader/ping_loader.cc index 9b71f2faa14b0a81285e6a9dee432d900bd08d67..3ee0240f8d20717bd0e6526d3c9728f3724bbc3d 100644 --- a/blink/renderer/core/loader/ping_loader.cc +++ b/blink/renderer/core/loader/ping_loader.cc @@ -138,7 +138,8 @@ void PingLoader::SendLinkAuditPing(LocalFrame* frame, void PingLoader::SendViolationReport(ExecutionContext* execution_context, const KURL& report_url, - scoped_refptr report) { + scoped_refptr report, + bool is_frame_ancestors_violation) { ResourceRequest request(report_url); request.SetHttpMethod(http_names::kPOST); request.SetHTTPContentType("application/csp-report"); @@ -147,7 +148,16 @@ void PingLoader::SendViolationReport(ExecutionContext* execution_context, request.SetCredentialsMode(network::mojom::CredentialsMode::kSameOrigin); request.SetRequestContext(mojom::blink::RequestContextType::CSP_REPORT); request.SetRequestDestination(network::mojom::RequestDestination::kReport); - request.SetRequestorOrigin(execution_context->GetSecurityOrigin()); + + // For frame-ancestors violations, execution_context->GetSecurityOrigin() is + // the origin of the embedding frame, while violations should be sent by the + // (blocked) embedded frame. + if (is_frame_ancestors_violation) { + request.SetRequestorOrigin(SecurityOrigin::CreateUniqueOpaque()); + } else { + request.SetRequestorOrigin(execution_context->GetSecurityOrigin()); + } + request.SetRedirectMode(network::mojom::RedirectMode::kError); FetchParameters params( std::move(request), diff --git a/blink/renderer/core/loader/ping_loader.h b/blink/renderer/core/loader/ping_loader.h index 8fab6e6b884f3ff5b6d585dc3a5c52d71402505f..97163c6a8fc75195befc762e7ad4c0dcefc11c55 100644 --- a/blink/renderer/core/loader/ping_loader.h +++ b/blink/renderer/core/loader/ping_loader.h @@ -68,7 +68,8 @@ class CORE_EXPORT PingLoader { const KURL& destination_url); static void SendViolationReport(ExecutionContext* execution_context, const KURL& report_url, - scoped_refptr report); + scoped_refptr report, + bool is_frame_ancestors_violation); // The last argument is guaranteed to be set to the size of payload if // these method return true. If these method returns false, the value diff --git a/blink/renderer/core/loader/ping_loader_test.cc b/blink/renderer/core/loader/ping_loader_test.cc index 178b84245eac3e7eb4e6bcdc69b14261417dda95..22934928bf2b789286d92560aadf162f8a9b8f4e 100644 --- a/blink/renderer/core/loader/ping_loader_test.cc +++ b/blink/renderer/core/loader/ping_loader_test.cc @@ -157,7 +157,7 @@ TEST_F(PingLoaderTest, ViolationPriority) { url_test_helpers::RegisterMockedURLLoad( ping_url, test::CoreTestDataPath("bar.html"), "text/html"); PingLoader::SendViolationReport(GetFrame().DomWindow(), ping_url, - EncodedFormData::Create()); + EncodedFormData::Create(), false); url_test_helpers::ServeAsynchronousRequests(); const PartialResourceRequest& request = client_->PingRequest(); ASSERT_FALSE(request.IsNull()); @@ -165,6 +165,23 @@ TEST_F(PingLoaderTest, ViolationPriority) { EXPECT_EQ(ResourceLoadPriority::kVeryLow, request.Priority()); } +TEST_F(PingLoaderTest, FrameAncestorsViolationHasOpaqueOrigin) { + SetDocumentURL(KURL("http://localhost/foo.html")); + + KURL ping_url("https://localhost/bar.html"); + // TODO(crbug.com/41337257): We should use the mock functionality + // via |PageTestBase::dummy_page_holder_|. + url_test_helpers::RegisterMockedURLLoad( + ping_url, test::CoreTestDataPath("bar.html"), "text/html"); + PingLoader::SendViolationReport(GetFrame().DomWindow(), ping_url, + EncodedFormData::Create(), true); + url_test_helpers::ServeAsynchronousRequests(); + const PartialResourceRequest& request = client_->PingRequest(); + ASSERT_FALSE(request.IsNull()); + ASSERT_EQ(request.Url(), ping_url); + EXPECT_EQ(request.HttpHeaderField(AtomicString("Origin")), String()); +} + TEST_F(PingLoaderTest, BeaconPriority) { SetDocumentURL(KURL("https://localhost/foo.html")); diff --git a/blink/renderer/core/loader/resource/css_style_sheet_resource.cc b/blink/renderer/core/loader/resource/css_style_sheet_resource.cc index 02eed14174262a020258cdefa78856f6f756e8b5..ed0de4979dacfb49680254a0cefcfa1c86b7d2f7 100644 --- a/blink/renderer/core/loader/resource/css_style_sheet_resource.cc +++ b/blink/renderer/core/loader/resource/css_style_sheet_resource.cc @@ -82,9 +82,9 @@ CSSStyleSheetResource* CSSStyleSheetResource::CreateForOfflineResource( ResourceRequest request(kurl); request.SetRequestorOrigin(SecurityOrigin::Create(origin_url)); request.SetCredentialsMode(network::mojom::CredentialsMode::kInclude); - + ResourceLoaderOptions options(nullptr); - + TextResourceDecoderOptions decoder_options( TextResourceDecoderOptions::kCSSContent, UTF8Encoding()); diff --git a/blink/renderer/core/loader/resource/image_resource.cc b/blink/renderer/core/loader/resource/image_resource.cc index ad036e80b8b3769623cd6999d6c5fc90f7490252..9349472a3b7c6b836c07306d54dfd2e309201cfb 100644 --- a/blink/renderer/core/loader/resource/image_resource.cc +++ b/blink/renderer/core/loader/resource/image_resource.cc @@ -245,9 +245,9 @@ ImageResource* ImageResource::CreateForOfflineResource(const KURL& kurl, ResourceRequest request(kurl); request.SetInspectorId(CreateUniqueIdentifier()); request.SetRequestorOrigin(SecurityOrigin::Create(origin_url)); - + ResourceLoaderOptions options(nullptr); - + auto image_resource = MakeGarbageCollected( request, options, ImageResourceContent::CreateNotStarted()); diff --git a/blink/renderer/core/loader/resource/script_resource.cc b/blink/renderer/core/loader/resource/script_resource.cc index f36bcb8a8dd19ef6f3279f86c5d6d6532e10d644..eba72f5d23f358361cc1ab2962450cfa7827bd1b 100644 --- a/blink/renderer/core/loader/resource/script_resource.cc +++ b/blink/renderer/core/loader/resource/script_resource.cc @@ -112,7 +112,7 @@ ScriptResource* ScriptResource::CreateForTest( #if BUILDFLAG(IS_OHOS) ScriptResource* ScriptResource::CreateForOfflineResource(const KURL& kurl, const KURL& origin_url, - const ResourceResponse& response, + ResourceResponse response, const bool is_module) { ResourceRequest request(kurl); if (is_module) { @@ -129,12 +129,12 @@ ScriptResource* ScriptResource::CreateForOfflineResource(const KURL& kurl, } request.SetRequestorOrigin(SecurityOrigin::Create(origin_url)); - + ResourceLoaderOptions options(nullptr); - + TextResourceDecoderOptions decoder_options( - TextResourceDecoderOptions::kCSSContent, UTF8Encoding()); - + TextResourceDecoderOptions::kPlainTextContent, UTF8Encoding()); + auto script_type = is_module ? mojom::blink::ScriptType::kModule : mojom::blink::ScriptType::kClassic; diff --git a/blink/renderer/core/loader/resource/script_resource.h b/blink/renderer/core/loader/resource/script_resource.h index 706139e13a62ff98cb645cbfa99487b44223647f..53ad8d8d3995237642d4c5be5f6cbaf702f80a00 100644 --- a/blink/renderer/core/loader/resource/script_resource.h +++ b/blink/renderer/core/loader/resource/script_resource.h @@ -78,7 +78,7 @@ class CORE_EXPORT ScriptResource final : public TextResource { #if BUILDFLAG(IS_OHOS) static ScriptResource* CreateForOfflineResource(const KURL& kurl, const KURL& origin_url, - const ResourceResponse& response, + ResourceResponse response, const bool is_module); #endif diff --git a/blink/renderer/core/mojo/mojo.cc b/blink/renderer/core/mojo/mojo.cc index 44832166c0aeefe95911114ec643137365b58eac..abaef2a89183be66c74e2fa60972b2c42bf209e2 100644 --- a/blink/renderer/core/mojo/mojo.cc +++ b/blink/renderer/core/mojo/mojo.cc @@ -119,7 +119,6 @@ void Mojo::bindInterface(ScriptState* script_state, && !base::EqualsCaseInsensitiveASCII(name.c_str(), kExtensionsMimeHandlerBeforeUnloadControl)) return; #endif - auto handle = mojo::ScopedMessagePipeHandle::From(request_handle->TakeHandle()); diff --git a/blink/renderer/core/page/chrome_client.h b/blink/renderer/core/page/chrome_client.h index b9d63fe5460187cfe8340510d2e8923ff7619166..117d1f5f96dd1fe0d91096d2b5d184a9e847c33b 100644 --- a/blink/renderer/core/page/chrome_client.h +++ b/blink/renderer/core/page/chrome_client.h @@ -594,11 +594,13 @@ class CORE_EXPORT ChromeClient : public GarbageCollected { #ifdef OHOS_AI using OnTextSelectedCallback = base::RepeatingCallback; + using OnDestroyImageAnalyzerOverlayCallback = base::RepeatingCallback; virtual void CreateOverlay(LocalFrame* frame, const SkBitmap& image, const gfx::Rect& image_rect, const gfx::Point& touch_point, - OnTextSelectedCallback callback) = 0; + OnTextSelectedCallback callback, + OnDestroyImageAnalyzerOverlayCallback destroy_callback) = 0; #endif protected: ChromeClient() = default; diff --git a/blink/renderer/core/page/chrome_client_impl.cc b/blink/renderer/core/page/chrome_client_impl.cc index 6e299e517452f3de95665ff06a0e77d38c435116..ddbdcb286609345a7a9b3c61a7d35a052c4d269c 100644 --- a/blink/renderer/core/page/chrome_client_impl.cc +++ b/blink/renderer/core/page/chrome_client_impl.cc @@ -1455,9 +1455,11 @@ void ChromeClientImpl::CreateOverlay(LocalFrame* frame, const SkBitmap& image, const gfx::Rect& image_rect, const gfx::Point& touch_point, - OnTextSelectedCallback callback) { + OnTextSelectedCallback callback, + OnDestroyImageAnalyzerOverlayCallback destroy_callback) { WebLocalFrameImpl* web_frame = WebLocalFrameImpl::FromFrame(frame); - web_frame->LocalRootFrameWidget()->CreateOverlay(image, image_rect, touch_point, std::move(callback)); + web_frame->LocalRootFrameWidget()->CreateOverlay(image, image_rect, touch_point, std::move(callback), + std::move(destroy_callback)); } #endif diff --git a/blink/renderer/core/page/chrome_client_impl.h b/blink/renderer/core/page/chrome_client_impl.h index fb16d929821e86c35ddd9f2b3b2b87ad458d6620..78a9f571eb6973327f436d1f5e7d31bdc1f4cf09 100644 --- a/blink/renderer/core/page/chrome_client_impl.h +++ b/blink/renderer/core/page/chrome_client_impl.h @@ -321,7 +321,8 @@ class CORE_EXPORT ChromeClientImpl final : public ChromeClient { const SkBitmap& image, const gfx::Rect& image_rect, const gfx::Point& touch_point, - OnTextSelectedCallback callback) override; + OnTextSelectedCallback callback, + OnDestroyImageAnalyzerOverlayCallback destroy_callback) override; #endif private: bool IsChromeClientImpl() const override { return true; } diff --git a/blink/renderer/core/page/chrome_client_impl_test.cc b/blink/renderer/core/page/chrome_client_impl_test.cc index 138ec19bd5893ada73bb479eccc0c9cc0916bd11..df53435a810138259a78672d86797b6b7c60c0be 100644 --- a/blink/renderer/core/page/chrome_client_impl_test.cc +++ b/blink/renderer/core/page/chrome_client_impl_test.cc @@ -194,14 +194,6 @@ TEST_F(FormSubmissionTest, FormGetSubmissionNewFrameUrlTest) { ASSERT_TRUE(form_elem); SubmitForm(*form_elem); -#ifdef OHOS_EX_BLANK_TARGET_POPUP_INTERCEPT - if ((*base::CommandLine::ForCurrentProcess()) - .HasSwitch(switches::kForBrowser)) { - EXPECT_TRUE(chrome_client_->GetLastUrl().IsEmpty()); - } else { - EXPECT_EQ("foo=bar", chrome_client_->GetLastUrl().Query()); - } -#endif } class FakeColorChooserClient : public GarbageCollected, diff --git a/blink/renderer/core/page/context_menu_controller.cc b/blink/renderer/core/page/context_menu_controller.cc index f8f29d7daa2e40cf62e0d7ddf6250f36f1682461..98ee5c68bd84e8c693009cb7880bf3d755d1eb81 100644 --- a/blink/renderer/core/page/context_menu_controller.cc +++ b/blink/renderer/core/page/context_menu_controller.cc @@ -95,9 +95,10 @@ #include "third_party/blink/public/web/web_element_collection.h" #include "third_party/blink/renderer/core/css/css_image_value.h" #include "third_party/blink/renderer/core/css/css_uri_value.h" +#include "third_party/blink/renderer/core/dom/node_computed_style.h" +#include "third_party/blink/renderer/core/editing/visible_position.h" #include "third_party/blink/renderer/core/frame/settings.h" #include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h" -#include "third_party/blink/renderer/core/dom/node_computed_style.h" #endif namespace blink { @@ -520,7 +521,6 @@ bool ContextMenuController::ShowContextMenu(LocalFrame* frame, if (IsHitTestStopNode(*node)) { break; } - // the node is , try to get image url. if (IsA(node)) { HTMLImageElement* img_element = To(node); @@ -858,16 +858,14 @@ bool ContextMenuController::ShowContextMenu(LocalFrame* frame, bool contextmenu_customization_enabled = page_->GetSettings().IsContextMenuCustomizationEnabled(); if (contextmenu_customization_enabled && - source_type == kMenuSourceSelectAndCopy && data.selected_text.empty() && + source_type == kMenuSourceShowFreeCopyMenu && data.selected_text.empty() && !selected_frame->SelectedText().empty()) { data.selected_text = selected_frame->SelectedText().Utf8(); } data.is_selectable = false; - if (contextmenu_customization_enabled && result.InnerNode() && - result.InnerNode()->GetLayoutObject() && - result.InnerNode()->GetLayoutObject()->IsSelectable()) { - data.is_selectable = true; + if (contextmenu_customization_enabled) { + data.is_selectable = ShouldShowFreeCopyMenu(result); } #endif @@ -920,6 +918,29 @@ bool ContextMenuController::ShowContextMenu(LocalFrame* frame, return true; } +#ifdef OHOS_EX_FREE_COPY +bool ContextMenuController::ShouldShowFreeCopyMenu( + const HitTestResult& result) { + if (!result.InnerNode() || !result.InnerNode()->GetLayoutObject()) { + return false; + } + if (!result.InnerNode()->GetLayoutObject()->IsSelectable()) { + return false; + } + if (result.IsLiveLink()) { + const PositionInFlatTreeWithAffinity pos = + CreateVisiblePosition(FromPositionInDOMTree( + result.GetPosition())) + .ToPositionWithAffinity(); + if (pos.IsNull() || + !pos.AnchorNode()->IsDescendantOf(result.URLElement())) { + return false; + } + } + return true; +} +#endif + #ifdef OHOS_CLIPBOARD GURL ContextMenuController::GetChildImageUrlFromElement( const blink::WebElement& element, gfx::Point point) { diff --git a/blink/renderer/core/page/context_menu_controller.h b/blink/renderer/core/page/context_menu_controller.h index 8cd79e7c7958cd4d45adb04017017ebf7361a07c..a5211d6cabe055db1eb1720c2c66223ff56b595b 100644 --- a/blink/renderer/core/page/context_menu_controller.h +++ b/blink/renderer/core/page/context_menu_controller.h @@ -135,6 +135,9 @@ class CORE_EXPORT ContextMenuController final GURL GetChildImageUrlFromElement(const blink::WebElement& element, gfx::Point point); #endif +#ifdef OHOS_EX_FREE_COPY + bool ShouldShowFreeCopyMenu(const HitTestResult& result); +#endif bool ShouldShowContextMenuFromTouch(const ContextMenuData&); Node* GetContextMenuNodeWithImageContents(); diff --git a/blink/renderer/core/page/drag_controller.cc b/blink/renderer/core/page/drag_controller.cc index e2fea0ba07c2782076e7e6a04f75498a7a33506c..25b84b438ba4a35e2b8f94a46ae1a79483bd63e7 100644 --- a/blink/renderer/core/page/drag_controller.cc +++ b/blink/renderer/core/page/drag_controller.cc @@ -174,7 +174,12 @@ DragController::DragController(Page* page) file_input_element_under_mouse_(nullptr), document_is_handling_drag_(false), drag_destination_action_(kDragDestinationActionNone), +#ifdef OHOS_DRAG_DROP + did_initiate_drag_(false), + is_draging_(false) {} +#else did_initiate_drag_(false) {} +#endif static DocumentFragment* DocumentFragmentFromDragData( DragData* drag_data, @@ -239,6 +244,7 @@ void DragController::ClearDragCaret() { void DragController::DragEnded() { #ifdef OHOS_DRAG_DROP RestoreDragLinkEffects(); + is_draging_ = false; #endif drag_initiator_ = nullptr; did_initiate_drag_ = false; @@ -1511,6 +1517,9 @@ bool DragController::StartDrag(LocalFrame* frame, DoSystemDrag(drag_image.get(), drag_obj_rect, effective_drag_initiation_location, state.drag_data_transfer_.Get(), frame); +#ifdef OHOS_DRAG_DROP + is_draging_ = true; +#endif return true; } @@ -1897,6 +1906,11 @@ void DragController::RestoreDragImageEffects() { return; element->setAttribute(html_names::kStyleAttr, origin_style_.ToAtomicString()); } + +bool DragController::IsDraging() { + return is_draging_; +} + #endif void DragController::Trace(Visitor* visitor) const { diff --git a/blink/renderer/core/page/drag_controller.h b/blink/renderer/core/page/drag_controller.h index e79f099fa4a477349b463ce9d145426c33613f5d..4eff4406d734454c91561742ccb9e01bf2a34ea8 100644 --- a/blink/renderer/core/page/drag_controller.h +++ b/blink/renderer/core/page/drag_controller.h @@ -124,6 +124,7 @@ class CORE_EXPORT DragController final bool IsInImageDraging(); bool IsInTextDraging(); void SetDragInitState(bool did_initiate_drag); + bool IsDraging(); #endif @@ -170,6 +171,7 @@ class CORE_EXPORT DragController final bool did_initiate_drag_; #ifdef OHOS_DRAG_DROP WTF::StringBuilder origin_style_; + bool is_draging_; #endif }; diff --git a/blink/renderer/core/page/page.cc b/blink/renderer/core/page/page.cc index 766ad13e9a7b49e25168ae46d088cd99ecb22fd1..280f8e209d17e36a27a4d31f749b31ea40020137 100644 --- a/blink/renderer/core/page/page.cc +++ b/blink/renderer/core/page/page.cc @@ -499,6 +499,25 @@ void Page::SetUserAgentPageScaleConstraints( root_view->SetNeedsLayout(); } +#if BUILDFLAG(IS_OHOS) +void Page::ResetPageScaleConstraints(bool constraint_for_mobile) { + if (constraint_for_mobile) { + SetDefaultPageScaleLimits(0.25f, 5.0f); + } else { + SetDefaultPageScaleLimits(1.0f, 4.0f); + } + + PageScaleConstraints constraints = + GetPageScaleConstraintsSet().UserAgentConstraints(); + constraints.minimum_scale = + GetPageScaleConstraintsSet().DefaultConstraints().minimum_scale; + constraints.maximum_scale = + GetPageScaleConstraintsSet().DefaultConstraints().maximum_scale; + + SetUserAgentPageScaleConstraints(constraints); +} +#endif + void Page::SetPageScaleFactor(float scale) { GetVisualViewport().SetScale(scale); } @@ -1145,6 +1164,15 @@ void Page::UpdateLifecycle(LocalFrame& root, } } +#ifdef OHOS_DISPLAY_CUTOUT +gfx::Insets Page::SafeAreaScaled() const { + if (PageScaleFactor() == 0.0f) { + return safe_area_; + } + return gfx::ScaleToFlooredInsets(safe_area_, 1 / PageScaleFactor()); +} +#endif + template class CORE_TEMPLATE_EXPORT Supplement; const char InternalSettingsPageSupplementBase::kSupplementName[] = diff --git a/blink/renderer/core/page/page.h b/blink/renderer/core/page/page.h index 577187aafcd96a3f044eb041b7f253821da28f63..3df9fde8d8f4dc661316b1bc3268c9dcb3ef37c0 100644 --- a/blink/renderer/core/page/page.h +++ b/blink/renderer/core/page/page.h @@ -61,6 +61,10 @@ #include "third_party/blink/renderer/platform/wtf/forward.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" +#ifdef OHOS_DISPLAY_CUTOUT +#include "ui/gfx/geometry/insets.h" +#endif + namespace cc { class AnimationHost; } @@ -313,6 +317,10 @@ class CORE_EXPORT Page final : public GarbageCollected, void SetDefaultPageScaleLimits(float min_scale, float max_scale); void SetUserAgentPageScaleConstraints( const PageScaleConstraints& new_constraints); +#if BUILDFLAG(IS_OHOS) + // Ignore shrinks_viewport_contents_to_fit if browser zoom works. + void ResetPageScaleConstraints(bool constraint_for_mobile); +#endif #if DCHECK_IS_ON() void SetIsPainting(bool painting) { is_painting_ = painting; } @@ -424,6 +432,11 @@ class CORE_EXPORT Page final : public GarbageCollected, return *v8_compile_hints_; } +#ifdef OHOS_DISPLAY_CUTOUT + gfx::Insets SafeAreaScaled() const; + void SetSafeArea(gfx::Insets safe_area) { safe_area_ = safe_area; } +#endif + private: friend class ScopedPagePauser; @@ -567,6 +580,10 @@ class CORE_EXPORT Page final : public GarbageCollected, // browser side FrameTree has the FrameTree::Type of kFencedFrame. bool is_fenced_frame_tree_ = false; +#ifdef OHOS_DISPLAY_CUTOUT + gfx::Insets safe_area_; +#endif + // This tracks the mode that the fenced frame is set to. blink::FencedFrame::DeprecatedFencedFrameMode fenced_frame_mode_ = blink::FencedFrame::DeprecatedFencedFrameMode::kDefault; diff --git a/blink/renderer/core/page/scrolling/scrolling_coordinator.cc b/blink/renderer/core/page/scrolling/scrolling_coordinator.cc index 6301866dde8bac2cd1f21c52f1a959584a6bb938..12108ac2c7aab775a471bbc9a486e66d6f439840 100644 --- a/blink/renderer/core/page/scrolling/scrolling_coordinator.cc +++ b/blink/renderer/core/page/scrolling/scrolling_coordinator.cc @@ -111,7 +111,7 @@ bool ScrollingCoordinator::UpdateCompositorScrollOffset( void ScrollingCoordinator::WillBeDestroyed() { DCHECK(page_); page_ = nullptr; - weak_ptr_factory_.InvalidateWeakPtrs(); + callbacks_.reset(); } } // namespace blink diff --git a/blink/renderer/core/page/scrolling/scrolling_coordinator.h b/blink/renderer/core/page/scrolling/scrolling_coordinator.h index ac9492743ad1a4c482fb4cccff41e66ee749782b..612e8fedee70bef9b23cf7a0bb95566bb85a1f0c 100644 --- a/blink/renderer/core/page/scrolling/scrolling_coordinator.h +++ b/blink/renderer/core/page/scrolling/scrolling_coordinator.h @@ -42,13 +42,12 @@ class ScrollableArea; // ScrollingCoordinator is a page-level object that mediates scroll-related // interactions between Blink and the compositor. class CORE_EXPORT ScrollingCoordinator final - : public GarbageCollected, - public CompositorScrollCallbacks { + : public GarbageCollected { public: explicit ScrollingCoordinator(Page*); ScrollingCoordinator(const ScrollingCoordinator&) = delete; ScrollingCoordinator& operator=(const ScrollingCoordinator&) = delete; - ~ScrollingCoordinator() override; + ~ScrollingCoordinator(); void Trace(Visitor*) const; void WillBeDestroyed(); @@ -69,22 +68,55 @@ class CORE_EXPORT ScrollingCoordinator final const CompositorElementId&); // ScrollCallbacks implementation - void DidCompositorScroll( - CompositorElementId, - const gfx::PointF&, - const absl::optional&) override; - void DidChangeScrollbarsHidden(CompositorElementId, bool hidden) override; + void DidCompositorScroll(CompositorElementId, + const gfx::PointF&, + const absl::optional&); + void DidChangeScrollbarsHidden(CompositorElementId, bool hidden); - base::WeakPtr GetWeakPtr() { + base::WeakPtr GetScrollCallbacks() { DCHECK(page_); - return weak_ptr_factory_.GetWeakPtr(); + if (!callbacks_) { + callbacks_ = std::make_unique(this); + } + return callbacks_->GetWeakPtr(); } protected: Member page_; private: - base::WeakPtrFactory weak_ptr_factory_{this}; + // This class adapts a base::WeakPtr into a GC-aware weak reference to the + // ScrollingCoordinator. The cc::ScrollTree needs a WeakPtr since it lives + // outside of Blink, but we cannot safely take a WeakPtr to a GC object + // (crbug.com/1485318, crbug.com/1246423). So we hand out a WeakPtr to a + // non-GC'ed proxy that holds a WeakPersistent to the ScrollingCoordinator. + class CallbackProxy : public CompositorScrollCallbacks { + public: + explicit CallbackProxy(ScrollingCoordinator* sc) + : scrolling_coordinator_(sc) {} + base::WeakPtr GetWeakPtr() { + return weak_ptr_factory_.GetWeakPtr(); + } + void DidCompositorScroll(CompositorElementId element_id, + const gfx::PointF& offset, + const absl::optional& + snap_target_ids) override { + if (ScrollingCoordinator* sc = scrolling_coordinator_.Get()) { + sc->DidCompositorScroll(element_id, offset, snap_target_ids); + } + } + void DidChangeScrollbarsHidden(CompositorElementId element_id, + bool hidden) override { + if (ScrollingCoordinator* sc = scrolling_coordinator_.Get()) { + sc->DidChangeScrollbarsHidden(element_id, hidden); + } + } + + private: + base::WeakPtrFactory weak_ptr_factory_{this}; + WeakPersistent scrolling_coordinator_; + }; + std::unique_ptr callbacks_; }; } // namespace blink diff --git a/blink/renderer/core/paint/DEPS b/blink/renderer/core/paint/DEPS index 7b2b644ed89b254e97c59116d0a41f6c137f3b17..38d0a0b6b9c1c3598d2ae5a782d405bf90bf3733 100644 --- a/blink/renderer/core/paint/DEPS +++ b/blink/renderer/core/paint/DEPS @@ -5,6 +5,8 @@ include_rules = [ # For DCHECK. "+base/logging.h", "+components/shared_highlighting/core/common", + # Hash function access + "+base/hash/hash.h", ] specific_include_rules = { diff --git a/blink/renderer/core/paint/build.gni b/blink/renderer/core/paint/build.gni index 288cd08800d5b971ae2218d32e3aa748a5d32f0e..4559236058b7b4e680579fb59d92c23599e07538 100644 --- a/blink/renderer/core/paint/build.gni +++ b/blink/renderer/core/paint/build.gni @@ -196,6 +196,8 @@ blink_core_sources_paint = [ "timing/image_paint_timing_detector.h", "timing/largest_contentful_paint_calculator.cc", "timing/largest_contentful_paint_calculator.h", + "timing/media_record_id.cc", + "timing/media_record_id.h", "timing/paint_timing.cc", "timing/paint_timing_detector.cc", "timing/paint_timing_detector.h", diff --git a/blink/renderer/core/paint/link_highlight_impl.cc b/blink/renderer/core/paint/link_highlight_impl.cc index 7cb2360689085c6a63a55ff8d0ac6b981e1c9d6e..31d6315d195d306caf01fb820594526ab379a3bc 100644 --- a/blink/renderer/core/paint/link_highlight_impl.cc +++ b/blink/renderer/core/paint/link_highlight_impl.cc @@ -216,10 +216,6 @@ LinkHighlightImpl::LinkHighlightFragment::PaintContentsToDisplayList() { flags.setStyle(cc::PaintFlags::kFill_Style); flags.setAntiAlias(true); flags.setColor(color_.Rgb()); -#ifdef OHOS_DRAG_DROP - flags.setColor(0x00FFFFFF); // transparent - flags.setBlendMode(SkBlendMode::kSrcOver); // blend mode -#endif canvas->drawPath(path_.GetSkPath(), flags); display_list->StartPaint(); diff --git a/blink/renderer/core/paint/native_painter.cc b/blink/renderer/core/paint/native_painter.cc index 1df95ba61edeed86158ed3bed9ca4b01d11b431d..21d4b5aa6e7827ed3f79dae9d7ad22459ea828d6 100644 --- a/blink/renderer/core/paint/native_painter.cc +++ b/blink/renderer/core/paint/native_painter.cc @@ -38,9 +38,9 @@ void NativePainter::PaintReplaced(const PaintInfo& paint_info, return; } - if (!layout_native_.NativeElement() || - !layout_native_.NativeElement()->NativeLoader() || - !layout_native_.NativeElement()->NativeLoader()->GetWebNativeBridge()) { + if (!layout_native_.PluginElement() || + !layout_native_.PluginElement()->NativeLoader() || + !layout_native_.PluginElement()->NativeLoader()->GetWebNativeBridge()) { return; } @@ -82,7 +82,7 @@ void NativePainter::PaintReplaced(const PaintInfo& paint_info, !force_software_video_paint; if (paint_with_foreign_layer) { if (cc::Layer* layer = - layout_native_.NativeElement()->NativeLoader()->CcLayer()) { + layout_native_.PluginElement()->NativeLoader()->CcLayer()) { gfx::RectF rect(-replaced_rect.X().ToFloat(), -replaced_rect.Y().ToFloat(), layout_native_.Size().Width().ToFloat(), diff --git a/blink/renderer/core/paint/paint_layer_scrollable_area.cc b/blink/renderer/core/paint/paint_layer_scrollable_area.cc index e25bd0b5bb3dff9c698c3ae76d4e005fa57af47f..79588e8e9c9f54f8aedacd87f49dcf4a7257ce95 100644 --- a/blink/renderer/core/paint/paint_layer_scrollable_area.cc +++ b/blink/renderer/core/paint/paint_layer_scrollable_area.cc @@ -131,6 +131,7 @@ const int kResizerControlExpandRatioForTouch = 2; const int kResizerControlReduceRatioForPcOhos = 2; const int kResizerControlReduceRatioForOhos = 6; const int kMaxScrollbarThicknessForOhos = 20; +const int kScrollbarMargin = 4; #endif PaintLayerScrollableArea::PaintLayerScrollableArea(PaintLayer& layer) @@ -1405,6 +1406,22 @@ gfx::Rect PaintLayerScrollableArea::RectForHorizontalScrollbar() const { const gfx::Rect& scroll_corner = ScrollCornerRect(); gfx::Size border_box_size = PixelSnappedBorderBoxSize(); + +#ifdef OHOS_SCROLLBAR + int marginBottom = 0; + if (HorizontalScrollbar()->IsOverlayScrollbar()) { + marginBottom = ScaleFromDIP() * kScrollbarMargin; + } + return gfx::Rect( + HorizontalScrollbarStart(), + border_box_size.height() - GetLayoutBox()->BorderBottom().ToInt() - + HorizontalScrollbar()->ScrollbarThickness() - marginBottom, + border_box_size.width() - + (GetLayoutBox()->BorderLeft() + GetLayoutBox()->BorderRight()) + .ToInt() - + scroll_corner.width(), + HorizontalScrollbar()->ScrollbarThickness()); +#else return gfx::Rect( HorizontalScrollbarStart(), border_box_size.height() - GetLayoutBox()->BorderBottom().ToInt() - @@ -1414,6 +1431,7 @@ gfx::Rect PaintLayerScrollableArea::RectForHorizontalScrollbar() const { .ToInt() - scroll_corner.width(), HorizontalScrollbar()->ScrollbarThickness()); +#endif } gfx::Rect PaintLayerScrollableArea::RectForVerticalScrollbar() const { @@ -1433,9 +1451,20 @@ gfx::Rect PaintLayerScrollableArea::RectForVerticalScrollbar() const { int PaintLayerScrollableArea::VerticalScrollbarStart() const { if (GetLayoutBox()->ShouldPlaceBlockDirectionScrollbarOnLogicalLeft()) return GetLayoutBox()->BorderLeft().ToInt(); +#ifdef OHOS_SCROLLBAR + int marginRight = 0; + if (VerticalScrollbar()->IsOverlayScrollbar()) { + marginRight = ScaleFromDIP() * kScrollbarMargin; + } + return PixelSnappedBorderBoxSize().width() - + GetLayoutBox()->BorderRight().ToInt() - + VerticalScrollbar()->ScrollbarThickness() - + marginRight; +#else return PixelSnappedBorderBoxSize().width() - GetLayoutBox()->BorderRight().ToInt() - VerticalScrollbar()->ScrollbarThickness(); +#endif } int PaintLayerScrollableArea::HorizontalScrollbarStart() const { @@ -2411,6 +2440,7 @@ PhysicalRect PaintLayerScrollableArea::ScrollIntoView( scroll_snapport_rect, local_expose_rect, *params->align_x.get(), *params->align_y.get(), GetScrollOffset()); #endif + ScrollOffset new_scroll_offset( ClampScrollOffset(gfx::ToRoundedVector2d(target_offset))); @@ -3232,17 +3262,17 @@ int32_t PaintLayerScrollableArea::ClampScrollOffsetLimit(int32_t scroll_offset_l // 1. root frame可以scroll时不处理paint layer的滚动,以防止元素整体上移 if (GetLayoutBox() && GetLayoutBox()->GetFrameView() && Layer() && Layer()->Size().Height() < ScrollHeight()) { - LocalFrameView* parentFrameView = GetLayoutBox()->GetFrameView(); - while (parentFrameView && parentFrameView->ParentFrameView()) { - parentFrameView = parentFrameView->ParentFrameView(); - } - ScrollableArea* scrollableArea = - (parentFrameView ? parentFrameView->GetScrollableArea() : nullptr); - if (scrollableArea && - scrollableArea->MaximumScrollOffset() != - scrollableArea->MinimumScrollOffset()) { - return 0; - } + LocalFrameView* parentFrameView = GetLayoutBox()->GetFrameView(); + while (parentFrameView && parentFrameView->ParentFrameView()) { + parentFrameView = parentFrameView->ParentFrameView(); + } + ScrollableArea* scrollableArea = + (parentFrameView ? parentFrameView->GetScrollableArea() : nullptr); + if (scrollableArea && + scrollableArea->MaximumScrollOffset() != + scrollableArea->MinimumScrollOffset()) { + return 0; + } } // 2. 当前root layer无法scroll时也不处理paint layer的滚动,以防止元素整体上移 diff --git a/blink/renderer/core/paint/timing/image_element_timing.cc b/blink/renderer/core/paint/timing/image_element_timing.cc index a8501cfcc91e57b3348e3db8ff11256c4d7176b2..21f7a0ac38732e5381da6b82544044b8e6da3a11 100644 --- a/blink/renderer/core/paint/timing/image_element_timing.cc +++ b/blink/renderer/core/paint/timing/image_element_timing.cc @@ -68,7 +68,7 @@ void ImageElementTiming::NotifyImageFinished( return; const auto& insertion_result = images_notified_.insert( - std::make_pair(&layout_object, cached_image), ImageInfo()); + MediaRecordId::GenerateHash(&layout_object, cached_image), ImageInfo()); if (insertion_result.is_new_entry) insertion_result.stored_value->value.load_time_ = base::TimeTicks::Now(); } @@ -97,8 +97,8 @@ void ImageElementTiming::NotifyImagePainted( if (!internal::IsExplicitlyRegisteredForTiming(layout_object)) return; - auto it = - images_notified_.find(std::make_pair(&layout_object, &cached_image)); + auto it = images_notified_.find( + MediaRecordId::GenerateHash(&layout_object, &cached_image)); // It is possible that the pair is not in |images_notified_|. See // https://crbug.com/1027948 if (it != images_notified_.end() && !it->value.is_painted_) { @@ -218,7 +218,8 @@ void ImageElementTiming::NotifyBackgroundImagePainted( ImageInfo& info = images_notified_ - .insert(std::make_pair(layout_object, cached_image), ImageInfo()) + .insert(MediaRecordId::GenerateHash(layout_object, cached_image), + ImageInfo()) .stored_value->value; if (!info.is_painted_) { info.is_painted_ = true; @@ -246,7 +247,7 @@ void ImageElementTiming::ReportImagePaintPresentationTime( void ImageElementTiming::NotifyImageRemoved(const LayoutObject* layout_object, const ImageResourceContent* image) { - images_notified_.erase(std::make_pair(layout_object, image)); + images_notified_.erase(MediaRecordId::GenerateHash(layout_object, image)); } void ImageElementTiming::Trace(Visitor* visitor) const { diff --git a/blink/renderer/core/paint/timing/image_element_timing.h b/blink/renderer/core/paint/timing/image_element_timing.h index 0a152210de91ab69c255be8caa951616afb3df06..7d3f5dd7c9137b277543e52d4d1e327d75b01e84 100644 --- a/blink/renderer/core/paint/timing/image_element_timing.h +++ b/blink/renderer/core/paint/timing/image_element_timing.h @@ -5,12 +5,11 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_TIMING_IMAGE_ELEMENT_TIMING_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_TIMING_IMAGE_ELEMENT_TIMING_H_ -#include - #include "base/time/time.h" #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/dom/element.h" #include "third_party/blink/renderer/core/frame/local_dom_window.h" +#include "third_party/blink/renderer/core/paint/timing/media_record_id.h" #include "third_party/blink/renderer/platform/heap/collection_support/heap_hash_map.h" #include "third_party/blink/renderer/platform/heap/collection_support/heap_vector.h" #include "third_party/blink/renderer/platform/supplementable.h" @@ -123,13 +122,12 @@ class CORE_EXPORT ImageElementTiming final DISALLOW_NEW(); }; - typedef std::pair RecordId; // Hashmap of pairs of elements, LayoutObjects (for the elements) and // ImageResourceContent (for the src) which correspond to either images or // background images whose paint has been observed. For background images, // only the |is_painted_| bit is used, as the timestamp needs to be tracked by // |background_image_timestamps_|. - WTF::HashMap images_notified_; + WTF::HashMap images_notified_; // Hashmap of background images which contain information about the load time // of the background image. diff --git a/blink/renderer/core/paint/timing/image_element_timing_test.cc b/blink/renderer/core/paint/timing/image_element_timing_test.cc index f1aee5cdd179398a2552e8af2de273479522a623..3643ad57403d46d5bc341478ebb51db6ccc9f175 100644 --- a/blink/renderer/core/paint/timing/image_element_timing_test.cc +++ b/blink/renderer/core/paint/timing/image_element_timing_test.cc @@ -9,6 +9,7 @@ #include "third_party/blink/renderer/core/layout/layout_image.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_image.h" #include "third_party/blink/renderer/core/loader/resource/image_resource_content.h" +#include "third_party/blink/renderer/core/paint/timing/media_record_id.h" #include "third_party/blink/renderer/platform/graphics/unaccelerated_static_bitmap_image.h" #include "third_party/blink/renderer/platform/testing/paint_test_configurations.h" #include "third_party/blink/renderer/platform/testing/url_test_helpers.h" @@ -60,11 +61,9 @@ class ImageElementTimingTest : public testing::Test, return nullptr; } - bool ImagesNotifiedContains( - const std::pair& - record_id) { + bool ImagesNotifiedContains(MediaRecordIdHash record_id_hash) { return ImageElementTiming::From(*GetDoc()->domWindow()) - .images_notified_.Contains(record_id); + .images_notified_.Contains(record_id_hash); } unsigned ImagesNotifiedSize() { @@ -159,7 +158,7 @@ TEST_P(ImageElementTimingTest, IgnoresUnmarkedElement) { ASSERT_TRUE(layout_image); UpdateAllLifecyclePhases(); EXPECT_FALSE(ImagesNotifiedContains( - std::make_pair(layout_image, layout_image->CachedImage()))); + MediaRecordId::GenerateHash(layout_image, layout_image->CachedImage()))); } TEST_P(ImageElementTimingTest, ImageInsideSVG) { @@ -179,7 +178,7 @@ TEST_P(ImageElementTimingTest, ImageInsideSVG) { // |layout_image| should have had its paint notified to ImageElementTiming. EXPECT_TRUE(ImagesNotifiedContains( - std::make_pair(layout_image, layout_image->CachedImage()))); + MediaRecordId::GenerateHash(layout_image, layout_image->CachedImage()))); } TEST_P(ImageElementTimingTest, ImageInsideNonRenderedSVG) { @@ -214,7 +213,7 @@ TEST_P(ImageElementTimingTest, ImageRemoved) { ASSERT_TRUE(layout_image); UpdateAllLifecyclePhases(); EXPECT_TRUE(ImagesNotifiedContains( - std::make_pair(layout_image, layout_image->CachedImage()))); + MediaRecordId::GenerateHash(layout_image, layout_image->CachedImage()))); GetDoc()->getElementById("target")->remove(); // |layout_image| should no longer be part of |images_notified| since it will @@ -234,7 +233,7 @@ TEST_P(ImageElementTimingTest, SVGImageRemoved) { LayoutSVGImage* layout_image = SetSVGImageResource("target", 5, 5); ASSERT_TRUE(layout_image); UpdateAllLifecyclePhases(); - EXPECT_TRUE(ImagesNotifiedContains(std::make_pair( + EXPECT_TRUE(ImagesNotifiedContains(MediaRecordId::GenerateHash( layout_image, layout_image->ImageResource()->CachedImage()))); GetDoc()->getElementById("target")->remove(); @@ -261,7 +260,8 @@ TEST_P(ImageElementTimingTest, BackgroundImageRemoved) { object->Style()->BackgroundLayers().GetImage()->CachedImage(); UpdateAllLifecyclePhases(); EXPECT_EQ(ImagesNotifiedSize(), 1u); - EXPECT_TRUE(ImagesNotifiedContains(std::make_pair(object, content))); + EXPECT_TRUE( + ImagesNotifiedContains(MediaRecordId::GenerateHash(object, content))); GetDoc()->getElementById("target")->remove(); EXPECT_EQ(ImagesNotifiedSize(), 0u); diff --git a/blink/renderer/core/paint/timing/image_paint_timing_detector.cc b/blink/renderer/core/paint/timing/image_paint_timing_detector.cc index b4ed09ccd893b39d4497fc9a237c1ab00bda91fa..e516c2a15a362fa71fcb1d644e8eb61ea2934b1e 100644 --- a/blink/renderer/core/paint/timing/image_paint_timing_detector.cc +++ b/blink/renderer/core/paint/timing/image_paint_timing_detector.cc @@ -231,8 +231,8 @@ void ImagePaintTimingDetector::OnPaintFinished() { void ImagePaintTimingDetector::NotifyImageRemoved( const LayoutObject& object, const MediaTiming* media_timing) { - RecordId record_id = std::make_pair(&object, media_timing); - records_manager_.RemoveRecord(record_id); + records_manager_.RemoveRecord( + MediaRecordId::GenerateHash(&object, media_timing)); } void ImagePaintTimingDetector::StopRecordEntries() { @@ -270,7 +270,7 @@ void ImageRecordsManager::AssignPaintTimeToRegisteredQueuedRecords( unsigned last_queued_frame_index) { while (!images_queued_for_paint_time_.empty()) { const base::WeakPtr& record = - images_queued_for_paint_time_.front().first; + images_queued_for_paint_time_.front().image_record; if (!record) { images_queued_for_paint_time_.pop_front(); continue; @@ -282,8 +282,8 @@ void ImageRecordsManager::AssignPaintTimeToRegisteredQueuedRecords( record->first_animated_frame_time = timestamp; record->queue_animated_paint = false; } - auto it = - pending_images_.find(images_queued_for_paint_time_.front().second); + auto it = pending_images_.find( + images_queued_for_paint_time_.front().record_id_hash); images_queued_for_paint_time_.pop_front(); // A record may be in |images_queued_for_paint_time_| twice, for instance if // is already loaded by the time of its first paint. @@ -319,7 +319,8 @@ bool ImagePaintTimingDetector::RecordImage( if (image_border.IsEmpty()) return false; - RecordId record_id = std::make_pair(&object, &media_timing); + MediaRecordId record_id(&object, &media_timing); + MediaRecordIdHash record_id_hash = record_id.GetHash(); if (int depth = IgnorePaintTimingScope::IgnoreDepth()) { // Record the largest loaded image that is hidden due to documentElement @@ -340,17 +341,18 @@ bool ImagePaintTimingDetector::RecordImage( return false; } - if (records_manager_.IsRecordedImage(record_id)) { + if (records_manager_.IsRecordedImage(record_id_hash)) { base::WeakPtr record = - records_manager_.GetPendingImage(record_id); + records_manager_.GetPendingImage(record_id_hash); if (!record) return false; if (ShouldReportAnimatedImages() && media_timing.IsPaintedFirstFrame()) { added_entry_in_latest_frame_ |= - records_manager_.OnFirstAnimatedFramePainted(record_id, frame_index_); + records_manager_.OnFirstAnimatedFramePainted(record_id_hash, + frame_index_); } if (!record->loaded && media_timing.IsSufficientContentLoadedForPaint()) { - records_manager_.OnImageLoaded(record_id, frame_index_, style_image); + records_manager_.OnImageLoaded(record_id_hash, frame_index_, style_image); added_entry_in_latest_frame_ = true; if (absl::optional& visualizer = frame_view_->GetPaintTimingDetector().Visualizer()) { @@ -386,10 +388,11 @@ bool ImagePaintTimingDetector::RecordImage( if (ShouldReportAnimatedImages() && media_timing.IsPaintedFirstFrame()) { added_entry_in_latest_frame_ |= - records_manager_.OnFirstAnimatedFramePainted(record_id, frame_index_); + records_manager_.OnFirstAnimatedFramePainted(record_id_hash, + frame_index_); } if (media_timing.IsSufficientContentLoadedForPaint()) { - records_manager_.OnImageLoaded(record_id, frame_index_, style_image); + records_manager_.OnImageLoaded(record_id_hash, frame_index_, style_image); added_entry_in_latest_frame_ = true; return true; } @@ -445,8 +448,8 @@ uint64_t ImagePaintTimingDetector::ComputeImageRectSize( void ImagePaintTimingDetector::NotifyImageFinished( const LayoutObject& object, const MediaTiming* media_timing) { - RecordId record_id = std::make_pair(&object, media_timing); - records_manager_.NotifyImageFinished(record_id); + records_manager_.NotifyImageFinished( + MediaRecordId::GenerateHash(&object, media_timing)); } void ImagePaintTimingDetector::ReportLargestIgnoredImage() { @@ -458,9 +461,9 @@ ImageRecordsManager::ImageRecordsManager(LocalFrameView* frame_view) : size_ordered_set_(&LargeImageFirst), frame_view_(frame_view) {} bool ImageRecordsManager::OnFirstAnimatedFramePainted( - const RecordId& record_id, + MediaRecordIdHash record_id_hash, unsigned current_frame_index) { - base::WeakPtr record = GetPendingImage(record_id); + base::WeakPtr record = GetPendingImage(record_id_hash); DCHECK(record); if (record->media_timing && !record->media_timing->GetFirstVideoFrameTime().is_null()) { @@ -473,19 +476,19 @@ bool ImageRecordsManager::OnFirstAnimatedFramePainted( // Otherwise, this is an animated images, and so we should wait for the // presentation callback to fire to set the first frame presentation time. record->queue_animated_paint = true; - QueueToMeasurePaintTime(record_id, record, current_frame_index); + QueueToMeasurePaintTime(record_id_hash, record, current_frame_index); return true; } return false; } -void ImageRecordsManager::OnImageLoaded(const RecordId& record_id, +void ImageRecordsManager::OnImageLoaded(MediaRecordIdHash record_id_hash, unsigned current_frame_index, const StyleFetchedImage* style_image) { - base::WeakPtr record = GetPendingImage(record_id); + base::WeakPtr record = GetPendingImage(record_id_hash); DCHECK(record); if (!style_image) { - auto it = image_finished_times_.find(record_id); + auto it = image_finished_times_.find(record_id_hash); if (it != image_finished_times_.end()) { record->load_time = it->value; DCHECK(!record->load_time.is_null()); @@ -498,7 +501,7 @@ void ImageRecordsManager::OnImageLoaded(const RecordId& record_id, record->origin_clean = style_image->IsOriginClean(); } } - OnImageLoadedInternal(record_id, record, current_frame_index); + OnImageLoadedInternal(record_id_hash, record, current_frame_index); } void ImageRecordsManager::ReportLargestIgnoredImage( @@ -518,25 +521,25 @@ void ImageRecordsManager::ReportLargestIgnoredImage( DCHECK(document); PaintTiming::From(*document).MarkFirstContentfulPaint(); - RecordId record_id = std::make_pair(node->GetLayoutObject(), - largest_ignored_image_->media_timing); - recorded_images_.insert(record_id); + MediaRecordIdHash record_id_hash = MediaRecordId::GenerateHash( + node->GetLayoutObject(), largest_ignored_image_->media_timing); + recorded_images_.insert(record_id_hash); base::WeakPtr record = largest_ignored_image_->AsWeakPtr(); size_ordered_set_.insert(record); - pending_images_.insert(record_id, std::move(largest_ignored_image_)); - OnImageLoadedInternal(record_id, record, current_frame_index); + pending_images_.insert(record_id_hash, std::move(largest_ignored_image_)); + OnImageLoadedInternal(record_id_hash, record, current_frame_index); } void ImageRecordsManager::OnImageLoadedInternal( - const RecordId& record_id, + MediaRecordIdHash record_id_hash, base::WeakPtr& record, unsigned current_frame_index) { SetLoaded(record); - QueueToMeasurePaintTime(record_id, record, current_frame_index); + QueueToMeasurePaintTime(record_id_hash, record, current_frame_index); } void ImageRecordsManager::MaybeUpdateLargestIgnoredImage( - const RecordId& record_id, + const MediaRecordId& record_id, const uint64_t& visual_size, const gfx::Rect& frame_visual_rect, const gfx::RectF& root_visual_rect, @@ -544,14 +547,14 @@ void ImageRecordsManager::MaybeUpdateLargestIgnoredImage( if (visual_size && (!largest_ignored_image_ || visual_size > largest_ignored_image_->recorded_size)) { largest_ignored_image_ = CreateImageRecord( - *record_id.first, record_id.second, visual_size, frame_visual_rect, - root_visual_rect, is_loaded_after_mouseover); + *record_id.GetLayoutObject(), record_id.GetMediaTiming(), visual_size, + frame_visual_rect, root_visual_rect, is_loaded_after_mouseover); largest_ignored_image_->load_time = base::TimeTicks::Now(); } } bool ImageRecordsManager::RecordFirstPaintAndReturnIsPending( - const RecordId& record_id, + const MediaRecordId& record_id, const uint64_t& visual_size, const gfx::Rect& frame_visual_rect, const gfx::RectF& root_visual_rect, @@ -562,7 +565,7 @@ bool ImageRecordsManager::RecordFirstPaintAndReturnIsPending( if (visual_size == 0u) { return false; } - recorded_images_.insert(record_id); + recorded_images_.insert(record_id.GetHash()); // If this cannot become an LCP candidate, no need to do anything else. if (visual_size == 0u || (largest_painted_image_ && @@ -588,10 +591,10 @@ bool ImageRecordsManager::RecordFirstPaintAndReturnIsPending( } std::unique_ptr record = CreateImageRecord( - *record_id.first, record_id.second, visual_size, frame_visual_rect, - root_visual_rect, is_loaded_after_mouseover); + *record_id.GetLayoutObject(), record_id.GetMediaTiming(), visual_size, + frame_visual_rect, root_visual_rect, is_loaded_after_mouseover); size_ordered_set_.insert(record->AsWeakPtr()); - pending_images_.insert(record_id, std::move(record)); + pending_images_.insert(record_id.GetHash(), std::move(record)); return true; } diff --git a/blink/renderer/core/paint/timing/image_paint_timing_detector.h b/blink/renderer/core/paint/timing/image_paint_timing_detector.h index 413176e992e110db2818d7ed2b06ebae232fea1f..5a5ee2a9033de3aa74c5296ce6b1e962524a8fd8 100644 --- a/blink/renderer/core/paint/timing/image_paint_timing_detector.h +++ b/blink/renderer/core/paint/timing/image_paint_timing_detector.h @@ -15,6 +15,7 @@ #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/dom/dom_node_ids.h" #include "third_party/blink/renderer/core/loader/resource/image_resource_content.h" +#include "third_party/blink/renderer/core/paint/timing/media_record_id.h" #include "third_party/blink/renderer/core/paint/timing/paint_timing_detector.h" #include "third_party/blink/renderer/platform/allow_discouraged_type.h" #include "third_party/blink/renderer/platform/loader/fetch/media_timing.h" @@ -90,8 +91,6 @@ class ImageRecord : public base::SupportsWeakPtr { bool is_loaded_after_mouseover = false; }; -typedef std::pair RecordId; - // |ImageRecordsManager| is the manager of all of the images that Largest // Image Paint cares about. Note that an image does not necessarily correspond // to a node; it can also be one of the background images attached to a node. @@ -115,10 +114,10 @@ class CORE_EXPORT ImageRecordsManager { ImageRecordsManager& operator=(const ImageRecordsManager&) = delete; ImageRecord* LargestImage() const; - inline void RemoveRecord(const RecordId& record_id) { - recorded_images_.erase(record_id); - image_finished_times_.erase(record_id); - auto it = pending_images_.find(record_id); + inline void RemoveRecord(MediaRecordIdHash record_id_hash) { + recorded_images_.erase(record_id_hash); + image_finished_times_.erase(record_id_hash); + auto it = pending_images_.find(record_id_hash); if (it != pending_images_.end()) { size_ordered_set_.erase(it->value->AsWeakPtr()); pending_images_.erase(it); @@ -128,41 +127,42 @@ class CORE_EXPORT ImageRecordsManager { } } // Returns whether an image was added to |pending_images_|. - bool RecordFirstPaintAndReturnIsPending(const RecordId& record_id, + bool RecordFirstPaintAndReturnIsPending(const MediaRecordId& record_id, const uint64_t& visual_size, const gfx::Rect& frame_visual_rect, const gfx::RectF& root_visual_rect, double bpp, bool is_loaded_after_mouseover); - bool IsRecordedImage(const RecordId& record_id) const { - return recorded_images_.Contains(record_id); + bool IsRecordedImage(MediaRecordIdHash record_id_hash) const { + return recorded_images_.Contains(record_id_hash); } - void NotifyImageFinished(const RecordId& record_id) { + void NotifyImageFinished(MediaRecordIdHash record_id_hash) { // TODO(npm): Ideally NotifyImageFinished() would only be called when the // record has not yet been inserted in |image_finished_times_| but that's // not currently the case. If we plumb some information from // MediaTiming we may be able to ensure that this call does not // require the Contains() check, which would save time. - if (!image_finished_times_.Contains(record_id)) { - image_finished_times_.insert(record_id, base::TimeTicks::Now()); + if (!image_finished_times_.Contains(record_id_hash)) { + image_finished_times_.insert(record_id_hash, base::TimeTicks::Now()); } } - inline base::WeakPtr GetPendingImage(const RecordId& record_id) { - auto it = pending_images_.find(record_id); + inline base::WeakPtr GetPendingImage( + MediaRecordIdHash record_id_hash) { + auto it = pending_images_.find(record_id_hash); return it == pending_images_.end() ? nullptr : it->value->AsWeakPtr(); } - bool OnFirstAnimatedFramePainted(const RecordId&, + bool OnFirstAnimatedFramePainted(MediaRecordIdHash, unsigned current_frame_index); - void OnImageLoaded(const RecordId&, + void OnImageLoaded(MediaRecordIdHash, unsigned current_frame_index, const StyleFetchedImage*); // Receives a candidate image painted under opacity 0 but without nested // opacity. May update |largest_ignored_image_| if the new candidate has a // larger size. - void MaybeUpdateLargestIgnoredImage(const RecordId&, + void MaybeUpdateLargestIgnoredImage(const MediaRecordId&, const uint64_t& visual_size, const gfx::Rect& frame_visual_rect, const gfx::RectF& root_visual_rect, @@ -186,19 +186,31 @@ class CORE_EXPORT ImageRecordsManager { const gfx::Rect& frame_visual_rect, const gfx::RectF& root_visual_rect, bool is_loaded_after_mouseover); - inline void QueueToMeasurePaintTime(const RecordId& record_id, + inline void QueueToMeasurePaintTime(MediaRecordIdHash record_id_hash, base::WeakPtr& record, unsigned current_frame_index) { record->frame_index = current_frame_index; - images_queued_for_paint_time_.push_back(std::make_pair(record, record_id)); + images_queued_for_paint_time_.push_back( + ImageRecordAndHashPair(record, record_id_hash)); } inline void SetLoaded(base::WeakPtr& record) { record->loaded = true; } - void OnImageLoadedInternal(const RecordId&, + void OnImageLoadedInternal(MediaRecordIdHash, base::WeakPtr&, unsigned current_frame_index); + struct ImageRecordAndHashPair { + ImageRecordAndHashPair(base::WeakPtr& record, + MediaRecordIdHash id_hash) { + image_record = record; + record_id_hash = id_hash; + } + + base::WeakPtr image_record; + MediaRecordIdHash record_id_hash; + }; + // The ImageRecord corresponding to the largest image that has been loaded and // painted. std::unique_ptr largest_painted_image_; @@ -207,24 +219,23 @@ class CORE_EXPORT ImageRecordsManager { // timestamp, ordered by size. ImageRecordSet size_ordered_set_; - // RecordId for images for which we have seen a first paint. A RecordId is - // added to this set regardless of whether the image could be an LCP - // candidate. - HashSet recorded_images_; + // MediaRecordId for images for which we have seen a first paint. A + // MediaRecordId is added to this set regardless of whether the image could be + // an LCP candidate. + HashSet recorded_images_; - // Map of RecordId to ImageRecord for images for which the first paint has - // been seen but which do not have the paint time set yet. This may contain - // only images which are potential LCP candidates. - HashMap> pending_images_; + // Map of MediaRecordId to ImageRecord for images for which the first paint + // has been seen but which do not have the paint time set yet. This may + // contain only images which are potential LCP candidates. + HashMap> pending_images_; // |ImageRecord|s waiting for paint time are stored in this map // until they get a presentation time. - Deque, RecordId>> - images_queued_for_paint_time_; + Deque images_queued_for_paint_time_; // Map containing timestamps of when LayoutObject::ImageNotifyFinished is // first called. - HashMap image_finished_times_; + HashMap image_finished_times_; Member frame_view_; diff --git a/blink/renderer/core/paint/timing/media_record_id.cc b/blink/renderer/core/paint/timing/media_record_id.cc new file mode 100644 index 0000000000000000000000000000000000000000..e49c898d1111015d80a71ddc11bd791bb2a0dca1 --- /dev/null +++ b/blink/renderer/core/paint/timing/media_record_id.cc @@ -0,0 +1,27 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "third_party/blink/renderer/core/paint/timing/media_record_id.h" + +#include "base/hash/hash.h" + +namespace blink { + +MediaRecordId::MediaRecordId(const LayoutObject* layout, + const MediaTiming* media) + : layout_object_(layout), + media_timing_(media), + hash_(GenerateHash(layout, media)) {} + +// This hash is used as a key where previously MediaRecordId was used directly. +// That helps us avoid storing references to the GCed LayoutObject and +// MediaTiming, as that can be unsafe when using regular WTF containers. It also +// helps us avoid needlessly allocating MediaRecordId on the heap. +MediaRecordIdHash MediaRecordId::GenerateHash(const LayoutObject* layout, + const MediaTiming* media) { + return base::HashInts(reinterpret_cast(layout), + reinterpret_cast(media)); +} + +} // namespace blink diff --git a/blink/renderer/core/paint/timing/media_record_id.h b/blink/renderer/core/paint/timing/media_record_id.h new file mode 100644 index 0000000000000000000000000000000000000000..32952101e8463e31617d1b5f67c36abf04303c4a --- /dev/null +++ b/blink/renderer/core/paint/timing/media_record_id.h @@ -0,0 +1,37 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_TIMING_MEDIA_RECORD_ID_H_ +#define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_TIMING_MEDIA_RECORD_ID_H_ + +#include "third_party/blink/renderer/core/core_export.h" +#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" + +namespace blink { +class LayoutObject; +class MediaTiming; + +using MediaRecordIdHash = size_t; + +class MediaRecordId { + STACK_ALLOCATED(); + + public: + static MediaRecordIdHash CORE_EXPORT GenerateHash(const LayoutObject* layout, + const MediaTiming* media); + + MediaRecordId(const LayoutObject* layout, const MediaTiming* media); + + MediaRecordIdHash GetHash() const { return hash_; } + const LayoutObject* GetLayoutObject() const { return layout_object_; } + const MediaTiming* GetMediaTiming() const { return media_timing_; } + + private: + const LayoutObject* const layout_object_; + const MediaTiming* const media_timing_; + const MediaRecordIdHash hash_; +}; + +} // namespace blink +#endif diff --git a/blink/renderer/core/paint/timing/paint_timing.cc b/blink/renderer/core/paint/timing/paint_timing.cc index b1c947b887bbceea505e92d675d4da668473fd6a..5df3bae43b016c26e6d420d8410c627653798eef 100644 --- a/blink/renderer/core/paint/timing/paint_timing.cc +++ b/blink/renderer/core/paint/timing/paint_timing.cc @@ -127,10 +127,10 @@ void PaintTiming::MarkFirstContentfulPaint() { return; if (IgnorePaintTimingScope::IgnoreDepth() > 0) return; - SetFirstContentfulPaint(clock_->NowTicks()); #ifdef OHOS_LOG_MESSAGE LOG(INFO) << "event_message: MarkFirstContentfulPaint"; #endif + SetFirstContentfulPaint(clock_->NowTicks()); } void PaintTiming::MarkFirstImagePaint() { diff --git a/blink/renderer/core/scroll/scrollable_area.cc b/blink/renderer/core/scroll/scrollable_area.cc index 5b48068bf1b2bfc2cb0a7785963c0844b0263ed4..8760dd33dc99db9eeda8daa5433e9473d68986b9 100644 --- a/blink/renderer/core/scroll/scrollable_area.cc +++ b/blink/renderer/core/scroll/scrollable_area.cc @@ -110,11 +110,7 @@ ScrollableArea::ScrollableArea( horizontal_scrollbar_needs_paint_invalidation_(false), vertical_scrollbar_needs_paint_invalidation_(false), scroll_corner_needs_paint_invalidation_(false), -#ifdef OHOS_SCROLLBAR - scrollbars_hidden_if_overlay_(false), -#else scrollbars_hidden_if_overlay_(true), -#endif scrollbar_captured_(false), mouse_over_scrollbar_(false), has_been_disposed_(false), @@ -669,22 +665,6 @@ void ScrollableArea::SetScrollbarColor(SkColor colorValue) { void ScrollableArea::SetScrollbarOverlayColorTheme( ScrollbarOverlayColorTheme overlay_theme) { scrollbar_overlay_color_theme_ = overlay_theme; -#ifdef OHOS_SCROLLBAR - if(HasOverlayScrollbars()) { - //set scrollbar color for overlay color theme - if(scrollbar_overlay_color_theme_ == kScrollbarOverlayColorThemeDark) { - SkColor skDark = SkColorSetRGB(0x18, 0x24, 0x31); - SetScrollbarColor(skDark); - LOG(INFO) << "ScrollableArea::SetScrollbarOverlayColorTheme" - << " scrollbar color is RGB:0x18, 0x24, 0x31"; - } else { - SkColor skLight = SkColorSetRGB(0xFF, 0xFF, 0xFF); - SetScrollbarColor(skLight); - LOG(INFO) << "ScrollableArea::SetScrollbarOverlayColorTheme" - << " scrollbar color is RGB:0xFF, 0xFF, 0xFF"; - } - } -#endif // OHOS_SCROLLBAR if (Scrollbar* scrollbar = HorizontalScrollbar()) { GetPageScrollbarTheme().UpdateScrollbarOverlayColorTheme(*scrollbar); @@ -717,7 +697,6 @@ void ScrollableArea::RecalculateScrollbarOverlayColorTheme() { background_color.GetHSL(hue, saturation, lightness); overlay_theme = lightness <= 0.5 ? kScrollbarOverlayColorThemeLight : kScrollbarOverlayColorThemeDark; - scrollbar_overlay_color_theme_ = overlay_theme; } } diff --git a/blink/renderer/core/scroll/scrollbar_theme_aura.cc b/blink/renderer/core/scroll/scrollbar_theme_aura.cc index 028218371fcb7908fa1fe95b2b58dda455a60d47..50cd14027bf3a1b4d0700d04346ba125836c58d4 100644 --- a/blink/renderer/core/scroll/scrollbar_theme_aura.cc +++ b/blink/renderer/core/scroll/scrollbar_theme_aura.cc @@ -56,9 +56,7 @@ namespace { // TODO(crbug.com/953847): Adapt testharness tests to native themes and remove // this. constexpr int kScrollbarThicknessForWebTests = 15; -#ifdef OHOS_SCROLLBAR -constexpr int kScrollbarForceThicknessForWeb = 16; -#endif + // While the theme does not have specific values for scrollbar-width: thin // we just use a fixed 2/3 ratio of the default value. constexpr float kAutoProportion = 1.f; @@ -179,9 +177,6 @@ int ScrollbarThemeAura::ScrollbarThickness(float scale_from_dip, WebThemeEngineHelper::GetNativeThemeEngine()->GetSize( WebThemeEngine::kPartScrollbarVerticalTrack); - if (!OverlayScrollbarsEnabled()) { - return kScrollbarForceThicknessForWeb; - } return scrollbar_size.width() * Proportion(scrollbar_width) * scale_from_dip; } diff --git a/blink/renderer/core/typed_arrays/dom_array_buffer.cc b/blink/renderer/core/typed_arrays/dom_array_buffer.cc index bbf87ad0314be98b90ddf509d458261411d4178b..32a62e1fb9a554f6b910881b04a5a8fd2ef6e659 100644 --- a/blink/renderer/core/typed_arrays/dom_array_buffer.cc +++ b/blink/renderer/core/typed_arrays/dom_array_buffer.cc @@ -51,7 +51,7 @@ static void AccumulateArrayBuffersForAllWorlds( if (!object->has_non_main_world_wrappers() && IsMainThread()) { const DOMWrapperWorld& world = DOMWrapperWorld::MainWorld(); v8::Local wrapper = world.DomDataStore().Get(const_cast(object), isolate); - if (!wrapper.IsEmpty()){ + if (!wrapper.IsEmpty()) { buffers.push_back(v8::Local::Cast(wrapper)); } return; diff --git a/blink/renderer/core/workers/worker_or_worklet_global_scope.cc b/blink/renderer/core/workers/worker_or_worklet_global_scope.cc index a978be69f4f89e7c80b8b4f5c996c083a55b365f..01172fd468f9820aefd28f03995014b05483b3e1 100644 --- a/blink/renderer/core/workers/worker_or_worklet_global_scope.cc +++ b/blink/renderer/core/workers/worker_or_worklet_global_scope.cc @@ -461,6 +461,13 @@ void WorkerOrWorkletGlobalScope::Dispose() { script_controller_->Dispose(); script_controller_.Clear(); +#ifdef OHOS_LOG_MESSAGE + if (resource_fetchers_.size()) { + LOG(INFO) << "Worker or WorkletGlobalScope Dispose, the size of resource_fetchers_: " + << resource_fetchers_.size(); + } +#endif + for (ResourceFetcher* resource_fetcher : resource_fetchers_) { resource_fetcher->StopFetching(); resource_fetcher->ClearContext(); diff --git a/blink/renderer/modules/accessibility/ax_object_cache_impl.cc b/blink/renderer/modules/accessibility/ax_object_cache_impl.cc index 0de34e2c2327120ce357fbbc9594bb6ffb9a6d6c..b0d37309e7dbd3b9e6061d2269e01e193fef5932 100644 --- a/blink/renderer/modules/accessibility/ax_object_cache_impl.cc +++ b/blink/renderer/modules/accessibility/ax_object_cache_impl.cc @@ -691,9 +691,11 @@ AXObjectCacheImpl::AXObjectCacheImpl(Document& document, permission_observer_receiver_(this, document.GetExecutionContext()), render_accessibility_host_(document.GetExecutionContext()), ax_tree_source_(BlinkAXTreeSource::Create(*this)), - ax_tree_serializer_(std::make_unique>( - ax_tree_source_, - /*crash_on_error*/ true)) { + ax_tree_serializer_( + std::make_unique< + ui::AXTreeSerializer>>( + ax_tree_source_, + /*crash_on_error*/ true)) { use_ax_menu_list_ = GetSettings()->GetUseAXMenuList(); } @@ -3987,7 +3989,8 @@ bool AXObjectCacheImpl::SerializeEntireTree(size_t max_node_count, // or a partial accessibility tree. AXTreeSerializer is stateful, but the // first time you serialize from a brand-new tree you're guaranteed to get a // complete tree. - ui::AXTreeSerializer serializer(tree_source); + ui::AXTreeSerializer> serializer( + tree_source); if (max_node_count) serializer.set_max_node_count(max_node_count); diff --git a/blink/renderer/modules/accessibility/ax_object_cache_impl.h b/blink/renderer/modules/accessibility/ax_object_cache_impl.h index eeea077f3bc086065b2dbed1fe38c3ee572e83a1..339eae38265b206e4a99447152503b39e12bf00d 100644 --- a/blink/renderer/modules/accessibility/ax_object_cache_impl.h +++ b/blink/renderer/modules/accessibility/ax_object_cache_impl.h @@ -930,7 +930,8 @@ class MODULES_EXPORT AXObjectCacheImpl render_accessibility_host_; Member ax_tree_source_; - std::unique_ptr> ax_tree_serializer_; + std::unique_ptr>> + ax_tree_serializer_; HeapDeque> dirty_objects_; diff --git a/blink/renderer/modules/breakout_box/media_stream_audio_track_underlying_sink.cc b/blink/renderer/modules/breakout_box/media_stream_audio_track_underlying_sink.cc index 2a0317081260237bb24656fb51d4a5cb38cde86a..d7673a818fb2085829e86a0527c60de1f7ccca32 100644 --- a/blink/renderer/modules/breakout_box/media_stream_audio_track_underlying_sink.cc +++ b/blink/renderer/modules/breakout_box/media_stream_audio_track_underlying_sink.cc @@ -78,6 +78,18 @@ ScriptPromise MediaStreamAudioTrackUnderlyingSink::write( return ScriptPromise(); } + const auto& data = audio_data->data(); + media::AudioParameters params( + media::AudioParameters::AUDIO_PCM_LOW_LATENCY, + media::ChannelLayoutConfig::Guess(data->channel_count()), + data->sample_rate(), data->frame_count()); + if (!params.IsValid()) { + audio_data->close(); + exception_state.ThrowDOMException(DOMExceptionCode::kOperationError, + "Invalid audio data"); + return ScriptPromise(); + } + source_broker_->PushAudioData(audio_data->data()); audio_data->close(); diff --git a/blink/renderer/modules/breakout_box/pushable_media_stream_audio_source.cc b/blink/renderer/modules/breakout_box/pushable_media_stream_audio_source.cc index 6d17be5aa5e3444f44aee98455591d7da3778b52..147cab1e96765f673fe2914f82dfc52bfb189854 100644 --- a/blink/renderer/modules/breakout_box/pushable_media_stream_audio_source.cc +++ b/blink/renderer/modules/breakout_box/pushable_media_stream_audio_source.cc @@ -137,15 +137,18 @@ void PushableMediaStreamAudioSource::DeliverData( params.format() != media::AudioParameters::AUDIO_PCM_LOW_LATENCY || last_channels_ != channel_count || last_sample_rate_ != sample_rate || last_frames_ != frame_count) { - SetFormat( + params = media::AudioParameters(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, media::ChannelLayoutConfig::Guess(channel_count), - sample_rate, frame_count)); + sample_rate, frame_count); + SetFormat(params); last_channels_ = channel_count; last_sample_rate_ = sample_rate; last_frames_ = frame_count; } + CHECK(params.IsValid()); + // If |data|'s sample format has the same memory layout as a media::AudioBus, // |audio_bus| will simply wrap it. Otherwise, |data| will be copied and // converted into |audio_bus|. diff --git a/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.cc b/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.cc index 96ed5e259e5fc97d917f99fe898488033731e6a1..3326870f9639dd7681b4f869a5a9626b91a7568a 100644 --- a/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.cc +++ b/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.cc @@ -1271,7 +1271,7 @@ void BaseRenderingContext2D::clip(Path2D* dom_path, IdentifiabilitySensitiveStringToken(winding_rule_string)); } ClipInternal(dom_path->GetPath(), winding_rule_string, - UsePaintCache::kEnabled); + path2d_use_paint_cache_); } bool BaseRenderingContext2D::isPointInPath(const double x, diff --git a/blink/renderer/modules/media_controls/BUILD.gn b/blink/renderer/modules/media_controls/BUILD.gn index 23d338b17b597d44587fab4e0a78bb63fdbc5354..449105399f141dbb4b1aeac9b491fb5c82394a0f 100644 --- a/blink/renderer/modules/media_controls/BUILD.gn +++ b/blink/renderer/modules/media_controls/BUILD.gn @@ -108,6 +108,15 @@ blink_modules_sources("media_controls") { ] } + if (defined(ohos_media_network_traffic_prompt) && ohos_media_network_traffic_prompt) { + sources += [ + "elements/mobile_data_prompt/mobile_data_prompt.cc", + "elements/mobile_data_prompt/mobile_data_prompt.h", + "elements/mobile_data_prompt/mobile_data_prompt_button.cc", + "elements/mobile_data_prompt/mobile_data_prompt_button.h", + ] + } + deps = [ ":media_controls_resources", "//services/service_manager/public/cpp", diff --git a/blink/renderer/modules/media_controls/media_controls_impl.cc b/blink/renderer/modules/media_controls/media_controls_impl.cc index b87a5fc01e75918c872e24c7cc48e15691753cf2..1505b8a7f844fb05f731b2cc6bb647f24533387c 100644 --- a/blink/renderer/modules/media_controls/media_controls_impl.cc +++ b/blink/renderer/modules/media_controls/media_controls_impl.cc @@ -105,6 +105,10 @@ #include "third_party/blink/renderer/platform/web_test_support.h" #include "ui/gfx/geometry/size.h" +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT +#include "third_party/blink/renderer/modules/media_controls/elements/mobile_data_prompt/mobile_data_prompt.h" +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + namespace blink { namespace { @@ -653,6 +657,13 @@ void MediaControlsImpl::InitializeControls() { *this))); } +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + if (MediaElement().IsHTMLVideoElement()) { + mobile_data_prompt_ = MakeGarbageCollected(VideoElement()); + ParserAppendChild(mobile_data_prompt_); + } +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + // Set the default CSS classes. UpdateCSSClassFromState(); } @@ -910,7 +921,7 @@ void MediaControlsImpl::Reset() { // If the player has entered an error state, force it into the paused state. if (MediaElement().error()) { -#if defined(OHOS_MEDIA) +#ifdef OHOS_MEDIA LOG(INFO) << "OhMedia::pause"; #endif // OHOS_MEDIA MediaElement().pause(); @@ -1056,9 +1067,10 @@ void MediaControlsImpl::MaybeShowOverlayPlayButton() { } void MediaControlsImpl::MakeOpaque() { -#if defined(OHOS_MEDIA) +#ifdef OHOS_MEDIA LOG(WARNING) << "OhMedia::MakeOpaque"; #endif // OHOS_MEDIA + ShowCursor(); #if defined(OHOS_MEDIA) if (MediaElement().IsFullscreen()) { diff --git a/blink/renderer/modules/media_controls/media_controls_impl.h b/blink/renderer/modules/media_controls/media_controls_impl.h index 718126e6d6f1e20f5a1577bdaa8d355842152901..4c9cbe9db38c667074c39a125b46b2878d7cc17b 100644 --- a/blink/renderer/modules/media_controls/media_controls_impl.h +++ b/blink/renderer/modules/media_controls/media_controls_impl.h @@ -76,6 +76,10 @@ class MediaControlEnteredFullscreenPanelElement; class MediaControlEnteredFullscreenTitleDisplayElement; #endif // defined(OHOS_MEDIA) +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT +class MobileDataPrompt; +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + // Default implementation of the core/ MediaControls interface used by // HTMLMediaElement. class MODULES_EXPORT MediaControlsImpl final : public HTMLDivElement, @@ -402,6 +406,10 @@ class MODULES_EXPORT MediaControlsImpl final : public HTMLDivElement, entered_fullscreen_title_display_; #endif // defined(OHOS_MEDIA) +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + Member mobile_data_prompt_; +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + Member media_event_listener_; Member orientation_lock_delegate_; Member diff --git a/blink/renderer/modules/media_controls/resources/mediaControls.css b/blink/renderer/modules/media_controls/resources/mediaControls.css index 6fae6d34acd02de8a7b780ca2b06785be822eb75..e0982488f05445c011a227c2bd8613d9c2cddd23 100644 --- a/blink/renderer/modules/media_controls/resources/mediaControls.css +++ b/blink/renderer/modules/media_controls/resources/mediaControls.css @@ -1679,3 +1679,48 @@ audio::-internal-media-controls-text-track-list { border: 1px solid WindowText; } } + +/* ohos */ +video::-internal-mobile-data-prompt { + --ohos_id_color_mask_light: #000; + --ohos_id_color_text_primary_contrary: #fff; + --ohos_id_text_size_body2: 14px; + --ohos_id_text_font_family_regular: normal; + position: absolute; + left: 0; + top:0; + right: 0; + bottom: 0; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + transform: translate3d(0,0,0); + background-color: var(--ohos_id_color_mask_light); + font-size: var(--ohos_id_text_size_body2); + font-weight: var(--ohos_id_text_font_family_regular); + color: var(--ohos_id_color_text_primary_contrary); +} + +video::-internal-mobile-data-prompt-message { + display: flex; + justify-content: center; + align-items: center; + padding-left: calc(clamp(0px, calc(100% - 599px), 1px) * 8 + 16px); + padding-right: calc(clamp(0px, calc(100% - 599px), 1px) * 8 + 16px); + width: 100%; + box-sizing: border-box; + margin-bottom: 16px; +} + +video::-internal-mobile-data-prompt-button { + display: flex; + justify-content: center; + align-items: center; + background-color: rgba(255,255,255,0.1); + border: 0px solid #000; + border-radius: 100px; + padding: 4px 14px; + height: 28px; + font-weight: 500; +} diff --git a/blink/renderer/modules/peerconnection/rtc_peer_connection_handler.cc b/blink/renderer/modules/peerconnection/rtc_peer_connection_handler.cc index 9634a17050ab5b9e35afbc925e1bd258714008ed..936009ac015ec3e031ccc093602f0093d5d47e8d 100644 --- a/blink/renderer/modules/peerconnection/rtc_peer_connection_handler.cc +++ b/blink/renderer/modules/peerconnection/rtc_peer_connection_handler.cc @@ -1069,7 +1069,7 @@ bool RTCPeerConnectionHandler::Initialize( if (!client_on_stack) { return false; } - + DCHECK(frame); frame_ = frame; peer_connection_tracker_ = PeerConnectionTracker::From(*frame); diff --git a/blink/renderer/modules/screen_orientation/screen_orientation.cc b/blink/renderer/modules/screen_orientation/screen_orientation.cc index cefb2a970baceb79f84749767ae1114867c977a3..a7776ff0da0c06a5945b6ccacf8bf8adf58ced75 100644 --- a/blink/renderer/modules/screen_orientation/screen_orientation.cc +++ b/blink/renderer/modules/screen_orientation/screen_orientation.cc @@ -141,7 +141,7 @@ void ScreenOrientation::SetAngle(uint16_t angle) { ScriptPromise ScreenOrientation::lock(ScriptState* state, const AtomicString& lock_string, ExceptionState& exception_state) { -#if defined(OHOS_MEDIA) +#ifdef OHOS_MEDIA LOG(INFO) << "OhMedia::ScreenOrientation lock = " << lock_string; #endif // OHOS_MEDIA if (!state->ContextIsValid() || !Controller()) { diff --git a/blink/renderer/modules/webaudio/BUILD.gn b/blink/renderer/modules/webaudio/BUILD.gn index 76c638b461304587d10cc1636eaedb06069673bb..411e3a9a49443bc37ca5bded9ef1d6e31a081b0b 100644 --- a/blink/renderer/modules/webaudio/BUILD.gn +++ b/blink/renderer/modules/webaudio/BUILD.gn @@ -112,8 +112,6 @@ blink_modules_sources("webaudio") { "delay_handler.h", "delay_node.cc", "delay_node.h", - "delay_processor.cc", - "delay_processor.h", "dynamics_compressor_handler.cc", "dynamics_compressor_handler.h", "dynamics_compressor_node.cc", diff --git a/blink/renderer/modules/webaudio/audio_handler.cc b/blink/renderer/modules/webaudio/audio_handler.cc index 8fec407591d25ae8623db12be8a9cc3df2f3d60c..01c95ecee17f613def2b892ecbfbfca563af9845 100644 --- a/blink/renderer/modules/webaudio/audio_handler.cc +++ b/blink/renderer/modules/webaudio/audio_handler.cc @@ -397,7 +397,9 @@ bool AudioHandler::InputsAreSilent() { void AudioHandler::SilenceOutputs() { for (auto& output : outputs_) { - output->Bus()->Zero(); + if (output->IsConnectedDuringRendering()) { + output->Bus()->Zero(); + } } } diff --git a/blink/renderer/modules/webaudio/audio_node_output.cc b/blink/renderer/modules/webaudio/audio_node_output.cc index 50908e248b765fd058766ecce7f51af5d179d6cb..3fd73d3731c76c67cb94da130393381f21b78830 100644 --- a/blink/renderer/modules/webaudio/audio_node_output.cc +++ b/blink/renderer/modules/webaudio/audio_node_output.cc @@ -154,6 +154,16 @@ unsigned AudioNodeOutput::RenderingFanOutCount() const { return rendering_fan_out_count_; } +unsigned AudioNodeOutput::RenderingParamFanOutCount() const { + DCHECK(GetDeferredTaskHandler().IsAudioThread()); + return rendering_param_fan_out_count_; +} + +bool AudioNodeOutput::IsConnectedDuringRendering() const { + DCHECK(GetDeferredTaskHandler().IsAudioThread()); + return RenderingFanOutCount() > 0 || RenderingParamFanOutCount() > 0; +} + void AudioNodeOutput::DisconnectAllInputs() { GetDeferredTaskHandler().AssertGraphOwner(); diff --git a/blink/renderer/modules/webaudio/audio_node_output.h b/blink/renderer/modules/webaudio/audio_node_output.h index 5256097593ea216fcb1a9477d506cf3f467d6607..aef701ce1895a7af1dd0e26c976e01e92e9c3b11 100644 --- a/blink/renderer/modules/webaudio/audio_node_output.h +++ b/blink/renderer/modules/webaudio/audio_node_output.h @@ -65,6 +65,15 @@ class MODULES_EXPORT AudioNodeOutput final { // during the course of a render quantum. unsigned RenderingFanOutCount() const; + // Returns the number of AudioParams that this output is connected to + // during rendering. Unlike `ParamFanOutCount()` this will not change + // during a render quantum. MUST be called from the audio thread. + unsigned RenderingParamFanOutCount() const; + + // Return true if either `RenderingFanOutCount()` or + // `RenderingParamFanOutCount()` is greater than zero. + bool IsConnectedDuringRendering() const; + // Must be called with the context's graph lock. void DisconnectAll(); @@ -106,10 +115,10 @@ class MODULES_EXPORT AudioNodeOutput final { // It must be called with the context's graph lock. unsigned FanOutCount(); - // Similar to fanOutCount(), paramFanOutCount() is the number of AudioParams - // that we're connected to. This method should not be called in audio thread - // rendering code, instead renderingParamFanOutCount() should be used. - // It must be called with the context's graph lock. + // Similar to `FanOutCount()`, `ParamFanOutCount()` is the number of + // AudioParams that this output is connected to. This method MUST be + // called from the main thread with the context graph lock. + // For audio thread, use `RenderingParamFanOutCount()` instead. unsigned ParamFanOutCount(); // Must be called with the context's graph lock. diff --git a/blink/renderer/modules/webaudio/audio_param_handler.h b/blink/renderer/modules/webaudio/audio_param_handler.h index 6343c4863b5d325a360489a3f3aab3df860d870c..128f283f8d6150cf8b9062ae034d1112930892fc 100644 --- a/blink/renderer/modules/webaudio/audio_param_handler.h +++ b/blink/renderer/modules/webaudio/audio_param_handler.h @@ -123,8 +123,12 @@ class AudioParamHandler final : public ThreadSafeRefCounted, float Value(); void SetValue(float); - AutomationRate GetAutomationRate() const { return automation_rate_; } + AutomationRate GetAutomationRate() const { + base::AutoLock rate_locker(RateLock()); + return automation_rate_; + } void SetAutomationRate(AutomationRate automation_rate) { + base::AutoLock rate_locker(RateLock()); automation_rate_ = automation_rate; } @@ -163,6 +167,8 @@ class AudioParamHandler final : public ThreadSafeRefCounted, return intrinsic_value_.load(std::memory_order_relaxed); } + base::Lock& RateLock() const { return rate_lock_; } + private: AudioParamHandler(BaseAudioContext&, AudioParamType, @@ -195,8 +201,12 @@ class AudioParamHandler final : public ThreadSafeRefCounted, float default_value_; + // Protects `automation_rate_`. + mutable base::Lock rate_lock_; + // The automation rate of the AudioParam (k-rate or a-rate) AutomationRate automation_rate_; + // `rate_mode_` determines if the user can change the automation rate to a // different value. const AutomationRateMode rate_mode_; diff --git a/blink/renderer/modules/webaudio/audio_worklet_handler.cc b/blink/renderer/modules/webaudio/audio_worklet_handler.cc index 586db551c9168f46836089c4781797b46a4e16d2..719ec6ff38ba33e6ddd7426938cce4da200898fe 100644 --- a/blink/renderer/modules/webaudio/audio_worklet_handler.cc +++ b/blink/renderer/modules/webaudio/audio_worklet_handler.cc @@ -114,7 +114,9 @@ void AudioWorkletHandler::Process(uint32_t frames_to_process) { // state. If so, silence the connected outputs and return. if (!processor_ || processor_->hasErrorOccurred()) { for (unsigned i = 0; i < NumberOfOutputs(); ++i) { - Output(i).Bus()->Zero(); + if (Output(i).IsConnectedDuringRendering()) { + Output(i).Bus()->Zero(); + } } return; } diff --git a/blink/renderer/modules/webaudio/cpu/arm/oscillator_kernel_neon.cc b/blink/renderer/modules/webaudio/cpu/arm/oscillator_kernel_neon.cc index 060f19ab2f504872f1659ad464e91f24d4b770fc..42faff91805794e96425136b07e9fbdf0ead976e 100644 --- a/blink/renderer/modules/webaudio/cpu/arm/oscillator_kernel_neon.cc +++ b/blink/renderer/modules/webaudio/cpu/arm/oscillator_kernel_neon.cc @@ -187,8 +187,10 @@ double OscillatorHandler::ProcessARateVectorKernel( static_cast(virt_index[0]), static_cast(virt_index[1]), static_cast(virt_index[2]), static_cast(virt_index[3])}; - // Convert virtual index to actual index into wave data. - const uint32x4_t v_read0 = vcvtq_u32_f32(v_virt_index); + // Convert virtual index to actual index into wave data, wrap the index + // around if needed. + const uint32x4_t v_read0 = + vandq_u32(vcvtq_u32_f32(v_virt_index), vdupq_n_u32(read_index_mask)); // v_read1 = v_read0 + 1, but wrap the index around, if needed. const uint32x4_t v_read1 = vandq_u32(vaddq_u32(v_read0, vdupq_n_u32(1)), diff --git a/blink/renderer/modules/webaudio/delay_handler.cc b/blink/renderer/modules/webaudio/delay_handler.cc index 8c9263833b890ddb3ac2f562928d5bf9c360122e..5548e27689acba1c3b301a19567256bf138ebb7f 100644 --- a/blink/renderer/modules/webaudio/delay_handler.cc +++ b/blink/renderer/modules/webaudio/delay_handler.cc @@ -4,43 +4,189 @@ #include "third_party/blink/renderer/modules/webaudio/delay_handler.h" -#include - -#include "third_party/blink/renderer/modules/webaudio/audio_node.h" +#include "third_party/blink/renderer/modules/webaudio/audio_node_input.h" +#include "third_party/blink/renderer/modules/webaudio/audio_node_output.h" #include "third_party/blink/renderer/modules/webaudio/base_audio_context.h" -#include "third_party/blink/renderer/modules/webaudio/delay_processor.h" +#include "third_party/blink/renderer/platform/audio/audio_bus.h" +#include "third_party/blink/renderer/platform/audio/delay.h" namespace blink { namespace { -constexpr unsigned kNumberOfChannels = 1; +constexpr unsigned kNumberOfOutputs = 1; +constexpr unsigned kDefaultNumberOfChannels = 1; } // namespace +scoped_refptr DelayHandler::Create(AudioNode& node, + float sample_rate, + AudioParamHandler& delay_time, + double max_delay_time) { + return base::AdoptRef( + new DelayHandler(node, sample_rate, delay_time, max_delay_time)); +} + +DelayHandler::~DelayHandler() { + Uninitialize(); +} + DelayHandler::DelayHandler(AudioNode& node, float sample_rate, AudioParamHandler& delay_time, double max_delay_time) - : AudioBasicProcessorHandler( - kNodeTypeDelay, - node, - sample_rate, - std::make_unique( - sample_rate, - kNumberOfChannels, - node.context()->GetDeferredTaskHandler().RenderQuantumFrames(), - delay_time, - max_delay_time)) { + : AudioHandler(kNodeTypeDelay, node, sample_rate), + number_of_channels_(kDefaultNumberOfChannels), + sample_rate_(sample_rate), + render_quantum_frames_( + node.context()->GetDeferredTaskHandler().RenderQuantumFrames()), + delay_time_(&delay_time), + max_delay_time_(max_delay_time) { + AddInput(); + AddOutput(kNumberOfOutputs); Initialize(); } -scoped_refptr DelayHandler::Create(AudioNode& node, - float sample_rate, - AudioParamHandler& delay_time, - double max_delay_time) { - return base::AdoptRef( - new DelayHandler(node, sample_rate, delay_time, max_delay_time)); +void DelayHandler::Process(uint32_t frames_to_process) { + AudioBus* destination_bus = Output(0).Bus(); + + if (!IsInitialized() || number_of_channels_ != Output(0).NumberOfChannels()) { + destination_bus->Zero(); + } else { + scoped_refptr source_bus = Input(0).Bus(); + + if (!Input(0).IsConnected()) { + source_bus->Zero(); + } + + base::AutoTryLock process_try_locker(process_lock_); + base::AutoTryLock rate_try_locker(delay_time_->RateLock()); + if (process_try_locker.is_acquired() && rate_try_locker.is_acquired()) { + DCHECK_EQ(source_bus->NumberOfChannels(), + destination_bus->NumberOfChannels()); + DCHECK_EQ(source_bus->NumberOfChannels(), kernels_.size()); + + if (delay_time_->IsAudioRate()) { + for (unsigned i = 0; i < kernels_.size(); ++i) { + // Assumes that the automation rate cannot change in the middle of + // the process function. (See crbug.com/357391257) + CHECK(delay_time_->IsAudioRate()); + delay_time_->CalculateSampleAccurateValues(kernels_[i]->DelayTimes(), + frames_to_process); + kernels_[i]->ProcessARate(source_bus->Channel(i)->Data(), + destination_bus->Channel(i)->MutableData(), + frames_to_process); + } + } else { + for (unsigned i = 0; i < kernels_.size(); ++i) { + CHECK(!delay_time_->IsAudioRate()); + kernels_[i]->SetDelayTime(delay_time_->FinalValue()); + kernels_[i]->ProcessKRate(source_bus->Channel(i)->Data(), + destination_bus->Channel(i)->MutableData(), + frames_to_process); + } + } + } else { + destination_bus->Zero(); + } + } +} + +void DelayHandler::ProcessOnlyAudioParams(uint32_t frames_to_process) { + if (!IsInitialized()) { + return; + } + + DCHECK_LE(frames_to_process, render_quantum_frames_); + float values[render_quantum_frames_]; + delay_time_->CalculateSampleAccurateValues(values, frames_to_process); +} + +void DelayHandler::Initialize() { + if (IsInitialized()) { + return; + } + + { + base::AutoLock locker(process_lock_); + DCHECK(!kernels_.size()); + + // Create processing kernels, one per channel. + for (unsigned i = 0; i < number_of_channels_; ++i) { + kernels_.push_back(std::make_unique(max_delay_time_, sample_rate_, + render_quantum_frames_)); + } + } + + AudioHandler::Initialize(); +} + +void DelayHandler::Uninitialize() { + if (!IsInitialized()) { + return; + } + + { + base::AutoLock locker(process_lock_); + kernels_.clear(); + } + + AudioHandler::Uninitialize(); +} + +void DelayHandler::CheckNumberOfChannelsForInput(AudioNodeInput* input) { + DCHECK(Context()->IsAudioThread()); + Context()->AssertGraphOwner(); + DCHECK_EQ(input, &Input(0)); + + // As soon as we know the channel count of our input, we can lazily + // initialize. Sometimes this may be called more than once with different + // channel counts, in which case we must safely uninitialize and then + // re-initialize with the new channel count. + const unsigned number_of_channels = input->NumberOfChannels(); + + if (IsInitialized() && number_of_channels != Output(0).NumberOfChannels()) { + // We're already initialized but the channel count has changed. + Uninitialize(); + } + + if (!IsInitialized()) { + // This will propagate the channel count to any nodes connected further down + // the chain... + Output(0).SetNumberOfChannels(number_of_channels); + + // Re-initialize the processor with the new channel count. + number_of_channels_ = number_of_channels; + + Initialize(); + } + + AudioHandler::CheckNumberOfChannelsForInput(input); +} + +bool DelayHandler::RequiresTailProcessing() const { + // Always return true even if the tail time and latency might both be + // zero. This is for simplicity; most interesting delay nodes have non-zero + // delay times anyway. And it's ok to return true. It just means the node + // lives a little longer than strictly necessary. + return true; +} + +double DelayHandler::TailTime() const { + // Account for worst case delay. + // Don't try to track actual delay time which can change dynamically. + return max_delay_time_; +} + +double DelayHandler::LatencyTime() const { + // A "delay" effect is expected to delay the signal, and this is not + // considered latency. + return 0; +} + +void DelayHandler::PullInputs(uint32_t frames_to_process) { + // Render directly into output bus for in-place processing + Input(0).Pull(Output(0).Bus(), frames_to_process); } } // namespace blink diff --git a/blink/renderer/modules/webaudio/delay_handler.h b/blink/renderer/modules/webaudio/delay_handler.h index 99f042f3d7047681393562d68c17c2bfcacc8bc2..feca6545a62aa1ab42ec4aa1e1b742a534ae105c 100644 --- a/blink/renderer/modules/webaudio/delay_handler.h +++ b/blink/renderer/modules/webaudio/delay_handler.h @@ -5,26 +5,56 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_WEBAUDIO_DELAY_HANDLER_H_ #define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBAUDIO_DELAY_HANDLER_H_ +#include + #include "base/memory/scoped_refptr.h" -#include "third_party/blink/renderer/modules/webaudio/audio_basic_processor_handler.h" +#include "third_party/blink/renderer/modules/webaudio/audio_handler.h" +#include "third_party/blink/renderer/modules/webaudio/audio_node.h" namespace blink { -class AudioNode; class AudioParamHandler; +class AudioNodeInput; +class Delay; -class DelayHandler : public AudioBasicProcessorHandler { +class DelayHandler final : public AudioHandler { public: static scoped_refptr Create(AudioNode&, float sample_rate, AudioParamHandler& delay_time, double max_delay_time); + ~DelayHandler() override; + private: DelayHandler(AudioNode&, float sample_rate, AudioParamHandler& delay_time, double max_delay_time); + + void Process(uint32_t frames_to_process) override; + void ProcessOnlyAudioParams(uint32_t frames_to_process) override; + + void Initialize() override; + void Uninitialize() override; + + void CheckNumberOfChannelsForInput(AudioNodeInput*) override; + + bool RequiresTailProcessing() const override; + double TailTime() const override; + double LatencyTime() const override; + + void PullInputs(uint32_t frames_to_process) override; + + unsigned number_of_channels_; + float sample_rate_; + unsigned render_quantum_frames_; + + Vector> kernels_ GUARDED_BY(process_lock_); + mutable base::Lock process_lock_; + + scoped_refptr delay_time_; + double max_delay_time_; }; } // namespace blink diff --git a/blink/renderer/modules/webaudio/delay_processor.cc b/blink/renderer/modules/webaudio/delay_processor.cc deleted file mode 100644 index 28427ea28fd550efb948a83c7602e74656baee07..0000000000000000000000000000000000000000 --- a/blink/renderer/modules/webaudio/delay_processor.cc +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (C) 2010, Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - */ - -#include "third_party/blink/renderer/modules/webaudio/delay_processor.h" - -#include - -#include "third_party/blink/renderer/platform/audio/audio_delay_dsp_kernel.h" -#include "third_party/blink/renderer/platform/audio/audio_utilities.h" - -namespace blink { - -namespace { - -class DelayDSPKernel final : public AudioDSPKernel { - public: - explicit DelayDSPKernel(DelayProcessor* processor) - : AudioDSPKernel(processor), - delay_(processor->MaxDelayTime(), - processor->SampleRate(), - processor->RenderQuantumFrames()) { - DCHECK(processor); - DCHECK_GT(processor->SampleRate(), 0); - } - - // Process the delay. Basically dispatches to either ProcessKRate or - // ProcessARate. - void Process(const float* source, - float* destination, - uint32_t frames_to_process) override { - if (HasSampleAccurateValues() && IsAudioRate()) { - GetDelayProcessor()->DelayTime().CalculateSampleAccurateValues( - delay_.DelayTimes(), frames_to_process); - delay_.ProcessARate(source, destination, frames_to_process); - } else { - delay_.SetDelayTime(GetDelayProcessor()->DelayTime().FinalValue()); - delay_.ProcessKRate(source, destination, frames_to_process); - } - } - - void ProcessOnlyAudioParams(uint32_t frames_to_process) override { - DCHECK_LE(frames_to_process, RenderQuantumFrames()); - - float values[RenderQuantumFrames()]; - - GetDelayProcessor()->DelayTime().CalculateSampleAccurateValues( - values, frames_to_process); - } - - void Reset() override { delay_.Reset(); } - - double TailTime() const override { - // Account for worst case delay. - // Don't try to track actual delay time which can change dynamically. - return delay_.MaxDelayTime(); - } - - double LatencyTime() const override { return 0; } - - bool RequiresTailProcessing() const override { - // Always return true even if the tail time and latency might both - // be zero. This is for simplicity; most interesting delay nodes - // have non-zero delay times anyway. And it's ok to return true. It - // just means the node lives a little longer than strictly - // necessary. - return true; - } - - private: - bool HasSampleAccurateValues() { - return GetDelayProcessor()->DelayTime().HasSampleAccurateValues(); - } - - bool IsAudioRate() { return GetDelayProcessor()->DelayTime().IsAudioRate(); } - - DelayProcessor* GetDelayProcessor() { - return static_cast(Processor()); - } - - AudioDelayDSPKernel delay_; -}; - -} // namespace - -DelayProcessor::DelayProcessor(float sample_rate, - unsigned number_of_channels, - unsigned render_quantum_frames, - AudioParamHandler& delay_time, - double max_delay_time) - : AudioDSPKernelProcessor(sample_rate, - number_of_channels, - render_quantum_frames), - delay_time_(&delay_time), - max_delay_time_(max_delay_time) {} - -DelayProcessor::~DelayProcessor() { - if (IsInitialized()) { - Uninitialize(); - } -} - -std::unique_ptr DelayProcessor::CreateKernel() { - return std::make_unique(this); -} - -void DelayProcessor::ProcessOnlyAudioParams(uint32_t frames_to_process) { - DCHECK_LE(frames_to_process, RenderQuantumFrames()); - - float values[RenderQuantumFrames()]; - - delay_time_->CalculateSampleAccurateValues(values, frames_to_process); -} - -} // namespace blink diff --git a/blink/renderer/modules/webaudio/delay_processor.h b/blink/renderer/modules/webaudio/delay_processor.h deleted file mode 100644 index 197c307234551e63e4c9ab6e386b642d650e1303..0000000000000000000000000000000000000000 --- a/blink/renderer/modules/webaudio/delay_processor.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2010, Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - */ - -#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_WEBAUDIO_DELAY_PROCESSOR_H_ -#define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBAUDIO_DELAY_PROCESSOR_H_ - -#include - -#include "base/memory/scoped_refptr.h" -#include "third_party/blink/renderer/modules/webaudio/audio_param.h" -#include "third_party/blink/renderer/platform/audio/audio_dsp_kernel_processor.h" - -namespace blink { - -class AudioDSPKernel; - -class DelayProcessor final : public AudioDSPKernelProcessor { - public: - DelayProcessor(float sample_rate, - unsigned number_of_channels, - unsigned render_quantum_frames, - AudioParamHandler& delay_time, - double max_delay_time); - ~DelayProcessor() override; - - std::unique_ptr CreateKernel() override; - - void ProcessOnlyAudioParams(uint32_t frames_to_process) override; - - AudioParamHandler& DelayTime() const { return *delay_time_; } - double MaxDelayTime() { return max_delay_time_; } - - private: - scoped_refptr delay_time_; - double max_delay_time_; -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBAUDIO_DELAY_PROCESSOR_H_ diff --git a/blink/renderer/modules/webgl/webgl2_rendering_context_base.cc b/blink/renderer/modules/webgl/webgl2_rendering_context_base.cc index 65cc99ee2a79e95581894867fd86253eda42ce4e..1216ac64ed5f690d9dfe6da51c7296d0378e8468 100644 --- a/blink/renderer/modules/webgl/webgl2_rendering_context_base.cc +++ b/blink/renderer/modules/webgl/webgl2_rendering_context_base.cc @@ -129,7 +129,7 @@ bool ValidateSubSourceAndGetData(DOMArrayBufferView* view, // type size is at most 8, so no overflow. byte_offset = sub_offset * type_size; } - base::CheckedNumeric total = byte_offset; + base::CheckedNumeric total = byte_offset; total += byte_length; if (!total.IsValid() || total.ValueOrDie() > view->byteLength()) { return false; diff --git a/blink/renderer/modules/webmidi/midi_dispatcher.cc b/blink/renderer/modules/webmidi/midi_dispatcher.cc index 2af62a4e4089757bafc3394d43c873c04fd7619a..7926fb7b42eac7308fe022fe81fe953caf6bbcd4 100644 --- a/blink/renderer/modules/webmidi/midi_dispatcher.cc +++ b/blink/renderer/modules/webmidi/midi_dispatcher.cc @@ -144,6 +144,7 @@ void MIDIDispatcher::DataReceived(uint32_t port, } void MIDIDispatcher::Trace(Visitor* visitor) const { + visitor->Trace(client_); visitor->Trace(midi_session_); visitor->Trace(receiver_); visitor->Trace(midi_session_provider_); diff --git a/blink/renderer/modules/webmidi/midi_dispatcher.h b/blink/renderer/modules/webmidi/midi_dispatcher.h index 1a987955f48609ab166b8760cc848a60e84143bf..1e3f7b21b052a039067ac3b7120878d6eabf31f8 100644 --- a/blink/renderer/modules/webmidi/midi_dispatcher.h +++ b/blink/renderer/modules/webmidi/midi_dispatcher.h @@ -17,7 +17,7 @@ namespace blink { class MIDIDispatcher : public GarbageCollected, public midi::mojom::blink::MidiSessionClient { public: - class Client { + class Client : public GarbageCollectedMixin { public: virtual void DidAddInputPort(const String& id, const String& manufacturer, @@ -68,7 +68,7 @@ class MIDIDispatcher : public GarbageCollected, void Trace(Visitor* visitor) const; private: - Client* client_ = nullptr; + Member client_; bool initialized_ = false; diff --git a/blink/renderer/modules/webtransport/web_transport.cc b/blink/renderer/modules/webtransport/web_transport.cc index 5be71aaaf02cece299e5e3f414e398bb0c462b22..44fbdda7040a765d8a3b0c9667e854812bc69bc4 100644 --- a/blink/renderer/modules/webtransport/web_transport.cc +++ b/blink/renderer/modules/webtransport/web_transport.cc @@ -1038,12 +1038,12 @@ void WebTransport::OnClosed( v8::Isolate* isolate = script_state_->GetIsolate(); v8::Local reason; - WebTransportCloseInfo idl_close_info; + auto* idl_close_info = MakeGarbageCollected(); if (close_info) { - idl_close_info.setCloseCode(close_info->code); - idl_close_info.setReason(close_info->reason); + idl_close_info->setCloseCode(close_info->code); + idl_close_info->setReason(close_info->reason); } - reason = ToV8(&idl_close_info, script_state_); + reason = ToV8(idl_close_info, script_state_); v8::Local error = WebTransportError::Create( isolate, /*stream_error_code=*/absl::nullopt, "The session is closed.", diff --git a/blink/renderer/modules/webusb/usb_device.cc b/blink/renderer/modules/webusb/usb_device.cc index a8fecf06d635fc1b570ec2b027ddf475e460da81..56a3ef90cb105e9f7c9d6f996dd35970dce53a4b 100644 --- a/blink/renderer/modules/webusb/usb_device.cc +++ b/blink/renderer/modules/webusb/usb_device.cc @@ -4,9 +4,11 @@ #include "third_party/blink/renderer/modules/webusb/usb_device.h" +#include #include #include "base/containers/span.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/public/platform/platform.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h" @@ -637,14 +639,14 @@ ScriptPromise USBDevice::isochronousTransferOut( if (data.ByteLength() > std::numeric_limits::max()) { exception_state.ThrowDOMException(DOMExceptionCode::kDataError, kBufferTooBig); - } + } + absl::optional total_bytes = TotalPacketLength(packet_lengths); if (!total_bytes.has_value()) { exception_state.ThrowDOMException(DOMExceptionCode::kDataError, kPacketLengthsTooBig); return ScriptPromise(); } - if (total_bytes.value() != data.ByteLength()) { exception_state.ThrowDOMException(DOMExceptionCode::kDataError, kBufferSizeMismatch); diff --git a/blink/renderer/platform/BUILD.gn b/blink/renderer/platform/BUILD.gn index 0d43508d7e9ec286bba1c5d3741cd3acb881cb9c..6a95f882f7a542ed240e0e6a220afc0d49704481 100644 --- a/blink/renderer/platform/BUILD.gn +++ b/blink/renderer/platform/BUILD.gn @@ -307,8 +307,6 @@ component("platform") { "audio/audio_callback_metric_reporter.h", "audio/audio_channel.cc", "audio/audio_channel.h", - "audio/audio_delay_dsp_kernel.cc", - "audio/audio_delay_dsp_kernel.h", "audio/audio_destination.cc", "audio/audio_destination.h", "audio/audio_dsp_kernel.cc", @@ -334,6 +332,8 @@ component("platform") { "audio/cpu/x86/vector_math_sse.cc", "audio/cpu/x86/vector_math_sse.h", "audio/cpu/x86/vector_math_x86.h", + "audio/delay.cc", + "audio/delay.h", "audio/denormal_disabler.h", "audio/direct_convolver.cc", "audio/direct_convolver.h", @@ -1840,14 +1840,21 @@ component("platform") { deps += [ "//third_party/libavif" ] } + if (is_ohos) { + sources += [ + "image-decoders/heif/heif_image_decoder.cc", + "image-decoders/heif/heif_image_decoder.h", + ] + } + if (current_cpu == "x86" || current_cpu == "x64") { deps += [ ":blink_x86_avx" ] - sources += [ "audio/cpu/x86/audio_delay_dsp_kernel_sse2.cc" ] + sources += [ "audio/cpu/x86/delay_sse2.cc" ] allow_circular_includes_from += [ ":blink_x86_avx" ] } if (current_cpu == "arm64" || (current_cpu == "arm" && arm_use_neon)) { - sources += [ "audio/cpu/arm/audio_delay_dsp_kernel_neon.cc" ] + sources += [ "audio/cpu/arm/delay_neon.cc" ] } if (use_webaudio_ffmpeg) { @@ -2287,15 +2294,6 @@ source_set("blink_platform_unittests_sources") { } sources += [ "testing/run_all_tests.cc" ] - if (ohos_unittests) { - sources += [ - "//cef/libcef/common/soc_perf_util.cc", - "//content/browser/browser_thread_impl.cc", - "//content/browser/scheduler/browser_task_executor.cc", - "//content/public/renderer/render_thread.cc", - "//content/child/child_thread_impl.cc", - ] - } configs += [ ":blink_platform_pch", @@ -2353,9 +2351,9 @@ source_set("blink_platform_unittests_sources") { ] if (ohos_unittests) { - deps +=[ - "//cef/libcef/common/mojom" - ] + deps += [ + "//cef:libcef_static", + ] } deps += [ ":bridge_ice_controller_tests" ] diff --git a/blink/renderer/platform/audio/cpu/arm/audio_delay_dsp_kernel_neon.cc b/blink/renderer/platform/audio/cpu/arm/delay_neon.cc similarity index 90% rename from blink/renderer/platform/audio/cpu/arm/audio_delay_dsp_kernel_neon.cc rename to blink/renderer/platform/audio/cpu/arm/delay_neon.cc index e520e896464bf3470a1d56930286988e8265827e..02aff4d89f9ede42952d3c882a46b4c3fe953fed 100644 --- a/blink/renderer/platform/audio/cpu/arm/audio_delay_dsp_kernel_neon.cc +++ b/blink/renderer/platform/audio/cpu/arm/delay_neon.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "third_party/blink/renderer/platform/audio/audio_delay_dsp_kernel.h" +#include "third_party/blink/renderer/platform/audio/delay.h" #include @@ -49,7 +49,7 @@ ALWAYS_INLINE static float32x4_t WrapPositionVector( reinterpret_cast(v_buffer_length), cmp))); } -std::tuple AudioDelayDSPKernel::ProcessARateVector( +std::tuple Delay::ProcessARateVector( float* destination, uint32_t frames_to_process) const { const int buffer_length = buffer_.size(); @@ -61,7 +61,6 @@ std::tuple AudioDelayDSPKernel::ProcessARateVector( int w_index = write_index_; const float32x4_t v_sample_rate = vdupq_n_f32(sample_rate); - const float32x4_t v_all_zeros = vdupq_n_f32(0); // The buffer length as a float and as an int so we don't need to constant // convert from one to the other. @@ -89,8 +88,7 @@ std::tuple AudioDelayDSPKernel::ProcessARateVector( int k = 0; for (int n = 0; n < number_of_loops; ++n, k += 4) { - const float32x4_t v_delay_time = vmaxq_f32(vld1q_f32(delay_times + k), - v_all_zeros); + const float32x4_t v_delay_time = vld1q_f32(delay_times + k); const float32x4_t v_desired_delay_frames = vmulq_f32(v_delay_time, v_sample_rate); @@ -103,8 +101,7 @@ std::tuple AudioDelayDSPKernel::ProcessARateVector( WrapPositionVector(v_read_position, v_buffer_length_float); // Get indices into the buffer for the samples we need for interpolation. - const int32x4_t v_read_index1 = WrapIndexVector( - vcvtq_s32_f32(v_read_position), v_buffer_length_int); + const int32x4_t v_read_index1 = vcvtq_s32_f32(v_read_position); const int32x4_t v_read_index2 = WrapIndexVector( vaddq_s32(v_read_index1, vdupq_n_s32(1)), v_buffer_length_int); @@ -137,15 +134,16 @@ std::tuple AudioDelayDSPKernel::ProcessARateVector( // Update |w_index| based on how many frames we processed here, wrapping // around if needed. w_index = write_index_ + k; - if (w_index >= buffer_length) + if (w_index >= buffer_length) { w_index -= buffer_length; + } return std::make_tuple(k, w_index); } -void AudioDelayDSPKernel::HandleNaN(float* delay_times, - uint32_t frames_to_process, - float max_time) { +void Delay::HandleNaN(float* delay_times, + uint32_t frames_to_process, + float max_time) { unsigned k = 0; int number_of_loops = frames_to_process / 4; @@ -182,8 +180,9 @@ void AudioDelayDSPKernel::HandleNaN(float* delay_times, // Handle any frames not done in the loop above. for (; k < frames_to_process; ++k) { - if (std::isnan(delay_times[k])) + if (std::isnan(delay_times[k])) { delay_times[k] = max_time; + } } } #endif diff --git a/blink/renderer/platform/audio/cpu/x86/audio_delay_dsp_kernel_sse2.cc b/blink/renderer/platform/audio/cpu/x86/delay_sse2.cc similarity index 87% rename from blink/renderer/platform/audio/cpu/x86/audio_delay_dsp_kernel_sse2.cc rename to blink/renderer/platform/audio/cpu/x86/delay_sse2.cc index c843528504271a5ece37c6e8b147464bdcf6a0ff..67f18cb75834610cfbc410b172c1fc8d747bfa56 100644 --- a/blink/renderer/platform/audio/cpu/x86/audio_delay_dsp_kernel_sse2.cc +++ b/blink/renderer/platform/audio/cpu/x86/delay_sse2.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "third_party/blink/renderer/platform/audio/audio_delay_dsp_kernel.h" +#include "third_party/blink/renderer/platform/audio/delay.h" #include @@ -48,7 +48,7 @@ ALWAYS_INLINE static __m128 WrapPositionVector(__m128 v_position, return _mm_sub_ps(v_position, _mm_and_ps(v_buffer_length, cmp)); } -std::tuple AudioDelayDSPKernel::ProcessARateVector( +std::tuple Delay::ProcessARateVector( float* destination, uint32_t frames_to_process) const { const int buffer_length = buffer_.size(); @@ -56,10 +56,10 @@ std::tuple AudioDelayDSPKernel::ProcessARateVector( const float sample_rate = sample_rate_; const float* delay_times = delay_times_.Data(); + int w_index = write_index_; const __m128 v_sample_rate = _mm_set1_ps(sample_rate); - const __m128 v_all_zeros = _mm_setzero_ps(); // The buffer length as a float and as an int so we don't need to constant // convert from one to the other. @@ -82,10 +82,7 @@ std::tuple AudioDelayDSPKernel::ProcessARateVector( int k = 0; for (int n = 0; n < number_of_loops; ++n, k += 4) { - // It's possible that `delay_time` contains negative values. Make sure - // they are greater than zero. - const __m128 v_delay_time = _mm_max_ps(_mm_loadu_ps(delay_times + k), - v_all_zeros); + const __m128 v_delay_time = _mm_loadu_ps(delay_times + k); const __m128 v_desired_delay_frames = _mm_mul_ps(v_delay_time, v_sample_rate); @@ -98,8 +95,7 @@ std::tuple AudioDelayDSPKernel::ProcessARateVector( WrapPositionVector(v_read_position, v_buffer_length_float); // Get indices into the buffer for the samples we need for interpolation. - const __m128i v_read_index1 = WrapIndexVector( - _mm_cvttps_epi32(v_read_position), v_buffer_length_int); + const __m128i v_read_index1 = _mm_cvttps_epi32(v_read_position); const __m128i v_read_index2 = WrapIndexVector( _mm_add_epi32(v_read_index1, _mm_set1_epi32(1)), v_buffer_length_int); @@ -131,15 +127,16 @@ std::tuple AudioDelayDSPKernel::ProcessARateVector( // Update |w_index|_ based on how many frames we processed here, wrapping // around if needed. w_index = write_index_ + k; - if (w_index >= buffer_length) + if (w_index >= buffer_length) { w_index -= buffer_length; + } return std::make_tuple(k, w_index); } -void AudioDelayDSPKernel::HandleNaN(float* delay_times, - uint32_t frames_to_process, - float max_time) { +void Delay::HandleNaN(float* delay_times, + uint32_t frames_to_process, + float max_time) { unsigned k = 0; const unsigned number_of_loops = frames_to_process / 4; @@ -166,8 +163,9 @@ void AudioDelayDSPKernel::HandleNaN(float* delay_times, // Handle any frames not done in the loop above. for (; k < frames_to_process; ++k) { - if (std::isnan(delay_times[k])) + if (std::isnan(delay_times[k])) { delay_times[k] = max_time; + } } } diff --git a/blink/renderer/platform/audio/audio_delay_dsp_kernel.cc b/blink/renderer/platform/audio/delay.cc similarity index 87% rename from blink/renderer/platform/audio/audio_delay_dsp_kernel.cc rename to blink/renderer/platform/audio/delay.cc index e5a31e89f929ea9a85297b5834a9712bbd730c97..e43211016cca9e59ac54aec38c0c7646e39e0b2f 100644 --- a/blink/renderer/platform/audio/audio_delay_dsp_kernel.cc +++ b/blink/renderer/platform/audio/delay.cc @@ -23,7 +23,7 @@ * DAMAGE. */ -#include "third_party/blink/renderer/platform/audio/audio_delay_dsp_kernel.h" +#include "third_party/blink/renderer/platform/audio/delay.h" #include @@ -64,9 +64,9 @@ void CopyToCircularBuffer(float* buffer, } // namespace -AudioDelayDSPKernel::AudioDelayDSPKernel(double max_delay_time, - float sample_rate, - unsigned render_quantum_frames) +Delay::Delay(double max_delay_time, + float sample_rate, + unsigned render_quantum_frames) : max_delay_time_(max_delay_time), delay_times_(render_quantum_frames), temp_buffer_(render_quantum_frames), @@ -82,10 +82,9 @@ AudioDelayDSPKernel::AudioDelayDSPKernel(double max_delay_time, buffer_.Zero(); } -size_t AudioDelayDSPKernel::BufferLengthForDelay( - double max_delay_time, - double sample_rate, - unsigned render_quantum_frames) const { +size_t Delay::BufferLengthForDelay(double max_delay_time, + double sample_rate, + unsigned render_quantum_frames) const { // Compute the length of the buffer needed to handle a max delay of // `maxDelayTime`. Add an additional render quantum frame size so we can // vectorize the delay processing. The extra space is needed so that writes @@ -95,13 +94,13 @@ size_t AudioDelayDSPKernel::BufferLengthForDelay( audio_utilities::kRoundUp); } -double AudioDelayDSPKernel::DelayTime(float sample_rate) { +double Delay::DelayTime(float sample_rate) { return desired_delay_frames_ / sample_rate; } #if !(defined(ARCH_CPU_X86_FAMILY) || defined(CPU_ARM_NEON)) // Default scalar versions if simd/neon are not available. -std::tuple AudioDelayDSPKernel::ProcessARateVector( +std::tuple Delay::ProcessARateVector( float* destination, uint32_t frames_to_process) const { // We don't have a vectorized version, so just do nothing and return the 0 to @@ -109,20 +108,21 @@ std::tuple AudioDelayDSPKernel::ProcessARateVector( return std::make_tuple(0, write_index_); } -void AudioDelayDSPKernel::HandleNaN(float* delay_times, - uint32_t frames_to_process, - float max_time) { +void Delay::HandleNaN(float* delay_times, + uint32_t frames_to_process, + float max_time) { for (unsigned k = 0; k < frames_to_process; ++k) { - if (std::isnan(delay_times[k])) + if (std::isnan(delay_times[k])) { delay_times[k] = max_time; + } } } #endif -int AudioDelayDSPKernel::ProcessARateScalar(unsigned start, - int w_index, - float* destination, - uint32_t frames_to_process) const { +int Delay::ProcessARateScalar(unsigned start, + int w_index, + float* destination, + uint32_t frames_to_process) const { const int buffer_length = buffer_.size(); const float* buffer = buffer_.Data(); @@ -135,7 +135,7 @@ int AudioDelayDSPKernel::ProcessARateScalar(unsigned start, const float* delay_times = delay_times_.Data(); for (unsigned i = start; i < frames_to_process; ++i) { - double delay_time = std::fmax(delay_times[i], 0); + double delay_time = delay_times[i]; double desired_delay_frames = delay_time * sample_rate; double read_position = w_index + buffer_length - desired_delay_frames; @@ -170,9 +170,9 @@ int AudioDelayDSPKernel::ProcessARateScalar(unsigned start, return w_index; } -void AudioDelayDSPKernel::ProcessARate(const float* source, - float* destination, - uint32_t frames_to_process) { +void Delay::ProcessARate(const float* source, + float* destination, + uint32_t frames_to_process) { int buffer_length = buffer_.size(); float* buffer = buffer_.Data(); @@ -202,9 +202,9 @@ void AudioDelayDSPKernel::ProcessARate(const float* source, } } -void AudioDelayDSPKernel::ProcessKRate(const float* source, - float* destination, - uint32_t frames_to_process) { +void Delay::ProcessKRate(const float* source, + float* destination, + uint32_t frames_to_process) { int buffer_length = buffer_.size(); float* buffer = buffer_.Data(); @@ -298,7 +298,7 @@ void AudioDelayDSPKernel::ProcessKRate(const float* source, } } -void AudioDelayDSPKernel::Reset() { +void Delay::Reset() { buffer_.Zero(); } diff --git a/blink/renderer/platform/audio/audio_delay_dsp_kernel.h b/blink/renderer/platform/audio/delay.h similarity index 86% rename from blink/renderer/platform/audio/audio_delay_dsp_kernel.h rename to blink/renderer/platform/audio/delay.h index 5fd3a24feaf0114f11a869804e1ff275cec324b6..cdcfa186fc2bd56ea1fa0e3a6f84070eb70aa080 100644 --- a/blink/renderer/platform/audio/audio_delay_dsp_kernel.h +++ b/blink/renderer/platform/audio/delay.h @@ -23,20 +23,21 @@ * DAMAGE. */ -#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_AUDIO_AUDIO_DELAY_DSP_KERNEL_H_ -#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_AUDIO_AUDIO_DELAY_DSP_KERNEL_H_ +#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_AUDIO_DELAY_H_ +#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_AUDIO_DELAY_H_ #include "third_party/blink/renderer/platform/audio/audio_array.h" -#include "third_party/blink/renderer/platform/audio/audio_dsp_kernel.h" #include "third_party/blink/renderer/platform/platform_export.h" namespace blink { -class PLATFORM_EXPORT AudioDelayDSPKernel { +// Implementation of a generic delay line with no dependencies. It does not +// have any thread affinity and there is no consideration on thread safety. +class PLATFORM_EXPORT Delay { public: - AudioDelayDSPKernel(double max_delay_time, - float sample_rate, - unsigned render_quantum_frames); + Delay(double max_delay_time, + float sample_rate, + unsigned render_quantum_frames); // Handles k-rate processing. Call `SetDelayFrames()` or `SetDelayTime()` to // set the delay before calling this function. @@ -86,9 +87,6 @@ class PLATFORM_EXPORT AudioDelayDSPKernel { uint32_t frames_to_process, float max_time); - AudioDelayDSPKernel(AudioDSPKernelProcessor*, - size_t processing_size_in_frames); - double DelayTime(float sample_rate); size_t BufferLengthForDelay(double delay_time, @@ -115,4 +113,4 @@ class PLATFORM_EXPORT AudioDelayDSPKernel { } // namespace blink -#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_AUDIO_AUDIO_DELAY_DSP_KERNEL_H_ +#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_AUDIO_DELAY_H_ diff --git a/blink/renderer/platform/audio/hrtf_panner.h b/blink/renderer/platform/audio/hrtf_panner.h index 7890e1f1c5d3224ab7d090ae7969e53aebb12744..13092f10ff10dbb1852126699e3b36f44a703775 100644 --- a/blink/renderer/platform/audio/hrtf_panner.h +++ b/blink/renderer/platform/audio/hrtf_panner.h @@ -26,7 +26,7 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_AUDIO_HRTF_PANNER_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_AUDIO_HRTF_PANNER_H_ -#include "third_party/blink/renderer/platform/audio/audio_delay_dsp_kernel.h" +#include "third_party/blink/renderer/platform/audio/delay.h" #include "third_party/blink/renderer/platform/audio/fft_convolver.h" #include "third_party/blink/renderer/platform/audio/panner.h" @@ -109,8 +109,8 @@ class HRTFPanner final : public Panner { FFTConvolver convolver_l2_; FFTConvolver convolver_r2_; - AudioDelayDSPKernel delay_line_l_; - AudioDelayDSPKernel delay_line_r_; + Delay delay_line_l_; + Delay delay_line_r_; AudioFloatArray temp_l1_; AudioFloatArray temp_r1_; diff --git a/blink/renderer/platform/bindings/parkable_string.cc b/blink/renderer/platform/bindings/parkable_string.cc index e5567a94369b4a04a1bc625dd6e74b06f0ae096d..fbca85329fb11c82907464d7f066036a84a24b98 100644 --- a/blink/renderer/platform/bindings/parkable_string.cc +++ b/blink/renderer/platform/bindings/parkable_string.cc @@ -885,7 +885,7 @@ ParkableString::ParkableString(scoped_refptr&& impl, bool is_parkabl impl_ = nullptr; return; } - + if (is_parkable) { impl_ = ParkableStringManager::Instance().Add(std::move(impl), nullptr); diff --git a/blink/renderer/platform/exported/resource_load_info_notifier_wrapper.cc b/blink/renderer/platform/exported/resource_load_info_notifier_wrapper.cc index 680492efb0cfd70d78dac811b4f872a677ae3ede..088ac9ced779158bebc1af0a4d0e1b28ba9dcadd 100644 --- a/blink/renderer/platform/exported/resource_load_info_notifier_wrapper.cc +++ b/blink/renderer/platform/exported/resource_load_info_notifier_wrapper.cc @@ -19,6 +19,10 @@ #include "third_party/blink/public/mojom/loader/resource_load_info_notifier.mojom.h" #include "third_party/blink/public/platform/weak_wrapper_resource_load_info_notifier.h" +#if BUILDFLAG(IS_OHOS) +#include "base/debug/dump_without_crashing.h" +#endif // BUILDFLAG(IS_OHOS) + namespace blink { ResourceLoadInfoNotifierWrapper::ResourceLoadInfoNotifierWrapper( @@ -204,6 +208,11 @@ void ResourceLoadInfoNotifierWrapper::NotifyResourceLoadCompleted( void ResourceLoadInfoNotifierWrapper::NotifyResourceLoadCanceled( int net_error) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); + if (!resource_load_info_) { + LOG(ERROR) << "used shared memory : " << used_shared_memory_; + base::debug::DumpWithoutCrashing(); + return; + } RecordLoadHistograms(url::Origin::Create(resource_load_info_->final_url), resource_load_info_->request_destination, net_error); diff --git a/blink/renderer/platform/exported/web_cache.cc b/blink/renderer/platform/exported/web_cache.cc index c8544519847cf26010836f5c906623b878e0cfaf..6a02ce1f4106c26d6fb876f6758c1daa9acaf4d3 100644 --- a/blink/renderer/platform/exported/web_cache.cc +++ b/blink/renderer/platform/exported/web_cache.cc @@ -95,7 +95,7 @@ void WebCache::AddResourceToCache(const std::string& url, TRACE_EVENT1("net", "WebCache::AddResourceToCache", "url", url.c_str()); MemoryCache* cache = MemoryCache::Get(); if (!cache) { - LOG(DEBUG) << "Cannot get MemoryCache."; + LOG(ERROR) << "Cannot get MemoryCache."; return; } @@ -127,13 +127,13 @@ void WebCache::AddResourceToCache(const std::string& url, kurl, origin_url, response, resource_type == OfflineResourceType::MODULE_JS); break; default: - LOG(DEBUG) << "Type is not supported to be added into MemoryCache."; + LOG(ERROR) << "Type is not supported to be added into MemeryCache."; return; } resource_obj->AppendData((char*)resource.data(), resource.size()); resource_obj->ResponseReceived(response); - resource_obj->Finish(base::TimeTicks(), nullptr); + resource_obj->Finish(base::TimeTicks(), base::SingleThreadTaskRunner::GetCurrentDefault().get()); resource_obj->SetKeepAliveOn(); cache->Add(resource_obj); @@ -141,11 +141,12 @@ void WebCache::AddResourceToCache(const std::string& url, } ResourceResponse WebCache::GetResourceResponse(const KURL& kurl, - const base::flat_map& response_headers) { + const base::flat_map& response_headers) +{ ResourceResponse response(kurl); response.SetCurrentRequestUrl(kurl); - for (auto header : response_headers) { + for (auto header: response_headers) { response.SetHttpHeaderField(AtomicString(header.first.c_str()), AtomicString(header.second.c_str())); } diff --git a/blink/renderer/platform/fonts/font_cache.cc b/blink/renderer/platform/fonts/font_cache.cc index ef70eda118fda48800919169bbb89bf45f891a95..8800c4943ca99c252fce7481021385aa45e2ff9b 100644 --- a/blink/renderer/platform/fonts/font_cache.cc +++ b/blink/renderer/platform/fonts/font_cache.cc @@ -394,6 +394,14 @@ void FontCache::CrashWithFontInfo(const FontDescription* font_description) { base::debug::Alias(&is_test_font_mgr); base::debug::Alias(&num_families); +#if BUILDFLAG(IS_OHOS) + LOG(ERROR) << __func__ << " [forfontcrash] font_mgr:" << font_mgr << " " + << static_font_mgr << " " << skia_default_font_mgr + << " test_font_mgr:" << is_test_font_mgr + << " num_families:" << num_families << " " + << font_description->ToString(); +#endif + CHECK(false); } diff --git a/blink/renderer/platform/fonts/shaping/harfbuzz_shaper.cc b/blink/renderer/platform/fonts/shaping/harfbuzz_shaper.cc index dc1377a90a9f79e5ecb591abde07bd865dbc2a5c..e1acc0901d633d81c812e94bdf363a8f4cc656a0 100644 --- a/blink/renderer/platform/fonts/shaping/harfbuzz_shaper.cc +++ b/blink/renderer/platform/fonts/shaping/harfbuzz_shaper.cc @@ -393,6 +393,18 @@ CanvasRotationInVertical CanvasRotationForRun( } // namespace +inline void HarfBuzzShaper::CheckTextLen(unsigned start, + unsigned length) const { + CHECK_LE(start, text_.length()); + CHECK_LE(length, text_.length() - start); +} + +inline void HarfBuzzShaper::CheckTextEnd(unsigned start, unsigned end) const { + CHECK_LE(start, end); + CHECK_LE(start, text_.length()); + CHECK_LE(end, text_.length()); +} + void HarfBuzzShaper::CommitGlyphs(RangeData* range_data, const SimpleFontData* current_font, UScriptCode current_run_script, @@ -588,7 +600,7 @@ bool HarfBuzzShaper::CollectFallbackHintChars( if (it->action_ == kReshapeQueueNextFont) break; - CHECK_LE((it->start_index_ + it->num_characters_), text_.length()); + CheckTextLen(it->start_index_, it->num_characters_); if (text_.Is8Bit()) { for (unsigned i = 0; i < it->num_characters_; i++) { hint.push_back(text_[it->start_index_ + i]); @@ -817,12 +829,13 @@ void HarfBuzzShaper::ShapeSegment( // Clamp the start and end offsets of the queue item to the offsets // representing the shaping window. - unsigned shape_start = + const unsigned shape_start = std::max(range_data->start, current_queue_item.start_index_); - unsigned shape_end = + const unsigned shape_end = std::min(range_data->end, current_queue_item.start_index_ + current_queue_item.num_characters_); DCHECK_GT(shape_end, shape_start); + CheckTextEnd(shape_start, shape_end); CaseMapIntend case_map_intend = CaseMapIntend::kKeepSameCase; if (needs_caps_handling) { diff --git a/blink/renderer/platform/fonts/shaping/harfbuzz_shaper.h b/blink/renderer/platform/fonts/shaping/harfbuzz_shaper.h index 76b3277551039e5f3aadd13d083e9e320f54b72c..6f6a965a8f53e346c8b1d352c1b609cb6b705435 100644 --- a/blink/renderer/platform/fonts/shaping/harfbuzz_shaper.h +++ b/blink/renderer/platform/fonts/shaping/harfbuzz_shaper.h @@ -133,6 +133,9 @@ class PLATFORM_EXPORT HarfBuzzShaper final { const BufferSlice&, ShapeResult*) const; + void CheckTextLen(unsigned start, unsigned length) const; + void CheckTextEnd(unsigned start, unsigned end) const; + const String text_; EmojiMetricsCallback emoji_metrics_reporter_for_testing_; }; diff --git a/blink/renderer/platform/fonts/skia/font_cache_skia.cc b/blink/renderer/platform/fonts/skia/font_cache_skia.cc index 80e766d5f6a700494815b461123b820f3c822f49..9dd7f4fe58b72ee02b0bdc6630bf2e63153ac72f 100644 --- a/blink/renderer/platform/fonts/skia/font_cache_skia.cc +++ b/blink/renderer/platform/fonts/skia/font_cache_skia.cc @@ -58,6 +58,10 @@ #error This file should not be used by MacOS. #endif +#if BUILDFLAG(IS_OHOS) +constexpr SkFourByteTag kWghtTag = SkSetFourByteTag('w', 'g', 'h', 't'); +#endif + namespace blink { AtomicString ToAtomicString(const SkString& str) { @@ -204,6 +208,9 @@ scoped_refptr FontCache::GetLastResortFallbackFont( GetFontPlatformData(description, ohos_sans_creation_params, AlternateFontName::kLastResort); } + if (!font_platform_data) { + LOG(ERROR) << __func__ << " [forfontcrash] no font_platform_data"; + } #endif DCHECK(font_platform_data); @@ -245,8 +252,45 @@ sk_sp FontCache::CreateTypeface( // TODO(https://crbug.com/1425390: Assign FontCache::font_manager_ in the // ctor. auto font_manager = font_manager_ ? font_manager_ : SkFontMgr::RefDefault(); - return sk_sp(font_manager->matchFamilyStyle( + auto typeface = sk_sp(font_manager->matchFamilyStyle( name.empty() ? nullptr : name.c_str(), font_description.SkiaFontStyle())); +#if BUILDFLAG(IS_OHOS) + if (!typeface) { + return nullptr; + } + + int existing_axes = typeface->getVariationDesignPosition(nullptr, 0); + if (existing_axes <= 0) + return typeface; + + Vector coordinates_to_set; + coordinates_to_set.resize(existing_axes); + + if (typeface->getVariationDesignPosition(coordinates_to_set.data(), + existing_axes) != existing_axes) { + return typeface; + } + bool hasChanged = false; + for (auto& coordinate : coordinates_to_set) { + if (coordinate.axis == kWghtTag) { + coordinate.value = SkFloatToScalar(font_description.SkiaFontStyle().weight()); + hasChanged = true; + } + } + if (!hasChanged) { + SkFontArguments::VariationPosition::Coordinate coordinate; + coordinate.axis = kWghtTag; + coordinate.value = SkFloatToScalar(font_description.SkiaFontStyle().weight()); + coordinates_to_set.push_back(coordinate); + } + SkFontArguments::VariationPosition variation_design_position{ + coordinates_to_set.data(), static_cast(coordinates_to_set.size())}; + SkFontArguments fontArgs; + fontArgs.setVariationDesignPosition(variation_design_position); + return typeface->makeClone(fontArgs); +#else + return typeface; +#endif } #if !BUILDFLAG(IS_WIN) diff --git a/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.cc b/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.cc index 062487d2228381f07ac350cf025c0d9438efbe8a..b78ed82e3819d5dbdb7e37d8698a22e033d50f5d 100644 --- a/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.cc +++ b/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.cc @@ -38,6 +38,13 @@ #include "third_party/blink/renderer/platform/wtf/hash_set.h" #include "ui/gfx/geometry/rect.h" +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT +#include "third_party/blink/renderer/core/dom/dom_node_ids.h" +#include "third_party/blink/renderer/core/layout/hit_test_location.h" +#include "third_party/blink/renderer/core/layout/layout_box_model_object.h" +#include "third_party/blink/renderer/core/paint/paint_layer.h" +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + namespace blink { // cc property trees make use of a sequence number to identify when tree @@ -860,6 +867,7 @@ void PaintArtifactCompositor::Update( // We need additional bookkeeping for backdrop-filter mask. if (effect.RequiresCompositingForBackdropFilterMask() && effect.CcNodeId(g_s_property_tree_sequence_number) == effect_id) { + CHECK(pending_layer.GetContentLayerClient()); static_cast(layer).SetIsBackdropFilterMask(true); layer.SetElementId(effect.GetCompositorElementId()); auto& effect_tree = host->property_trees()->effect_tree_mutable(); @@ -876,15 +884,36 @@ void PaintArtifactCompositor::Update( property_tree_manager.EnsureCompositorScrollAndTransformNode( scroll_translation); +#if defined(OHOS_CUSTOM_VIDEO_PLAYER) || defined(OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT) + bool should_at_top_in_z_order = false; #if defined(OHOS_CUSTOM_VIDEO_PLAYER) - if (layer.ShouldOverlay()) { + if (!should_at_top_in_z_order) { + should_at_top_in_z_order = layer.ShouldOverlay(); + } +#endif // OHOS_CUSTOM_VIDEO_PLAYER +#if defined(OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT) + if (!should_at_top_in_z_order) { + DisplayItemClient* display_item_client = + reinterpret_cast( + pending_layer.FirstPaintChunk().id.client_id); + if (display_item_client) { + Node* node = DOMNodeIds::NodeForId(display_item_client->OwnerNodeId()); + if (node && node->ShouldOverlay()) { + if (node->GetLayoutObject()->HasNonZeroEffectiveOpacity()) { + should_at_top_in_z_order = true; + } + } + } + } +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + if (should_at_top_in_z_order) { layer_list_builder_for_video.Add(&layer); } else { layer_list_builder.Add(&layer); } #else layer_list_builder.Add(&layer); -#endif // OHOS_CUSTOM_VIDEO_PLAYER +#endif // OHOS_CUSTOM_VIDEO_PLAYER || OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT layer.set_property_tree_sequence_number( root_layer_->property_tree_sequence_number()); @@ -907,10 +936,11 @@ void PaintArtifactCompositor::Update( } #if defined(OHOS_CUSTOM_VIDEO_PLAYER) - auto video_layers = layer_list_builder_for_video.Finalize(); - for (const auto& video_layer : video_layers) { + overlay_cc_layers_ = layer_list_builder_for_video.Finalize(); + for (const auto& video_layer : overlay_cc_layers_) { layer_list_builder.Add(video_layer); } + std::reverse(overlay_cc_layers_.begin(), overlay_cc_layers_.end()); #endif // OHOS_CUSTOM_VIDEO_PLAYER if (unification_enabled) { @@ -1424,4 +1454,52 @@ void PaintArtifactCompositor::SetNeedsUpdate( } } +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT +bool PaintArtifactCompositor::TryHitTest(const HitTestLocation& location, + HitTestResult& result) { + for (auto& cc_layer : overlay_cc_layers_) { + for (auto& pending_layer : pending_layers_) { + if (cc_layer.get() != &(pending_layer.CcLayer())) { + continue; + } + DisplayItemClient* display_item_client = + reinterpret_cast( + pending_layer.FirstPaintChunk().id.client_id); + if (!display_item_client) { + break; + } + Node* node = DOMNodeIds::NodeForId(display_item_client->OwnerNodeId()); + if (!node) { + break; + } + LayoutBoxModelObject* layout_object = node->GetLayoutBoxModelObject(); + if (!layout_object) { + break; + } + PhysicalOffset new_point = + layout_object->AbsoluteToLocalPoint(location.Point()); + HitTestLocation new_hit_test_location(new_point); + HitTestRequest::HitTestRequestType new_hit_type = + result.GetHitTestRequest().GetType() | + HitTestRequest::kIgnorePointerEventsNone; + new_hit_type = new_hit_type & ~HitTestRequest::kListBased; + new_hit_type = new_hit_type & ~HitTestRequest::kPenetratingList; + HitTestResult new_result(HitTestRequest(new_hit_type), location); + auto hit = layout_object->HitTestAllPhases( + new_result, new_hit_test_location, {}); + if (hit) { + result.SetNodeAndPosition( + new_result.InnerNode(), new_result.LocalPoint()); + return true; + } + } + } + return false; +} + +bool PaintArtifactCompositor::HasOverlayLayes() { + return !overlay_cc_layers_.empty(); +} +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + } // namespace blink diff --git a/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h b/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h index abf1376752d4cc456dcf5d42550e71580fb70205..df293eb2791af871dd1b50a594a158842e158c9b 100644 --- a/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h +++ b/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h @@ -40,6 +40,11 @@ class ContentLayerClientImpl; class JSONObject; class SynthesizedClip; +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT +class HitTestLocation; +class HitTestResult; +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + using CompositorScrollCallbacks = cc::ScrollCallbacks; // This enum is used for histograms and should not be renumbered (see: @@ -269,6 +274,11 @@ class PLATFORM_EXPORT PaintArtifactCompositor final // found by `element_id`. bool SetScrollbarNeedsDisplay(CompositorElementId element_id); +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + bool TryHitTest(const HitTestLocation& location, HitTestResult& result); + bool HasOverlayLayes(); +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + private: void UpdateCompositorViewportProperties(const ViewportProperties&, PropertyTreeManager&, @@ -366,6 +376,10 @@ class PLATFORM_EXPORT PaintArtifactCompositor final class OldPendingLayerMatcher; PendingLayers pending_layers_; +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + cc::LayerList overlay_cc_layers_; +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + // ScrollTranslationNodes of the PaintArtifact that are painted. // This member variable is only used in PaintArtifactCompositor::Update. // The value indicates if the scroll should be composited. diff --git a/blink/renderer/platform/graphics/compositing/paint_artifact_compositor_test.cc b/blink/renderer/platform/graphics/compositing/paint_artifact_compositor_test.cc index cffdf5ea4a2d274308267e4e7dabc224fc171d7a..4483e28b20551d007684baad99218b3c7a315fd1 100644 --- a/blink/renderer/platform/graphics/compositing/paint_artifact_compositor_test.cc +++ b/blink/renderer/platform/graphics/compositing/paint_artifact_compositor_test.cc @@ -4791,4 +4791,30 @@ TEST_P(PaintArtifactCompositorTest, EXPECT_TRUE(cc_clip_expander->AppliesLocalClip()); } +TEST_P(PaintArtifactCompositorTest, + CreatePictureLayerForSolidColorBackdropFilterMask) { + CompositorFilterOperations filter; + filter.AppendBlurFilter(5); + auto backdrop_filter = CreateBackdropFilterEffect(e0(), filter); + + EffectPaintPropertyNode::State mask_state; + mask_state.local_transform_space = &t0(); + mask_state.output_clip = &c0(); + mask_state.blend_mode = SkBlendMode::kDstIn; + mask_state.direct_compositing_reasons = + CompositingReason::kBackdropFilterMask; + auto mask = + EffectPaintPropertyNode::Create(*backdrop_filter, std::move(mask_state)); + + Update(TestPaintArtifact() + .Chunk(t0(), c0(), *backdrop_filter) + .RectDrawing(gfx::Rect(150, 150, 100, 100), Color::kWhite) + .Chunk(t0(), c0(), *mask) + .RectDrawing(gfx::Rect(150, 150, 100, 100), Color::kBlack) + .IsSolidColor() + .Build()); + ASSERT_EQ(2u, LayerCount()); + EXPECT_FALSE(LayerAt(1)->IsSolidColorLayerForTesting()); +} + } // namespace blink diff --git a/blink/renderer/platform/graphics/compositing/pending_layer.cc b/blink/renderer/platform/graphics/compositing/pending_layer.cc index f7075b2339ef62c1e6a56121ce08a479da5b9a26..67ec2c6b744217d0db4d8943885e73b04a6fc675 100644 --- a/blink/renderer/platform/graphics/compositing/pending_layer.cc +++ b/blink/renderer/platform/graphics/compositing/pending_layer.cc @@ -120,7 +120,7 @@ std::unique_ptr PendingLayer::ToJSON() const { VectorAsJSONArray(offset_of_decomposited_transforms_)); result->SetArray("paint_chunks", chunks_.ToJSON()); result->SetBoolean("draws_content", DrawsContent()); - result->SetBoolean("is_solid_color", is_solid_color_); + result->SetBoolean("is_solid_color", IsSolidColor()); return result; } @@ -561,6 +561,25 @@ void PendingLayer::UpdateSolidColorLayer(PendingLayer* old_pending_layer) { cc_layer_->SetIsDrawable(draws_content_); } +bool PendingLayer::UsesSolidColorLayer() const { + if (!RuntimeEnabledFeatures::SolidColorLayersEnabled() || !IsSolidColor()) { + return false; + } + // We need a PictureLayer for the backdrop filter mask. + if (property_tree_state_.Effect() + .RequiresCompositingForBackdropFilterMask()) { + return false; + } +#if BUILDFLAG(IS_MAC) + // TODO(crbug.com/922899): Additionally, on Mac, we require that the color is + // opaque due to the bug. Remove this condition once that bug is fixed. + if (GetSolidColor().fA != 1.0f) { + return false; + } +#endif // BUILDFLAG(IS_MAC) + return true; +} + void PendingLayer::UpdateCompositedLayer(PendingLayer* old_pending_layer, cc::LayerSelection& layer_selection, bool tracks_raster_invalidations, diff --git a/blink/renderer/platform/graphics/compositing/pending_layer.h b/blink/renderer/platform/graphics/compositing/pending_layer.h index f9bd5d015e4b1ab7a19ff35cd2806bb536b3f4a1..e75ab665fcb581b18f7783dd61847bc57e05a29d 100644 --- a/blink/renderer/platform/graphics/compositing/pending_layer.h +++ b/blink/renderer/platform/graphics/compositing/pending_layer.h @@ -184,9 +184,7 @@ class PLATFORM_EXPORT PendingLayer { void UpdateLayerProperties(cc::LayerSelection&, bool selection_only); - bool UsesSolidColorLayer() const { - return RuntimeEnabledFeatures::SolidColorLayersEnabled() && is_solid_color_; - } + bool UsesSolidColorLayer() const; // The rects are in the space of property_tree_state. gfx::RectF bounds_; diff --git a/blink/renderer/platform/graphics/deferred_image_decoder.cc b/blink/renderer/platform/graphics/deferred_image_decoder.cc index 86ff7d20ad54a2beefd296dede76bd5215165b9a..ce5e459233ce81ddbca500557cd0181f18b991b3 100644 --- a/blink/renderer/platform/graphics/deferred_image_decoder.cc +++ b/blink/renderer/platform/graphics/deferred_image_decoder.cc @@ -199,6 +199,14 @@ sk_sp DeferredImageDecoder::CreateGenerator() { DCHECK(image_metadata_); image_metadata_->all_data_received_prior_to_decode = !incremental_decode_needed_.value(); +#if BUILDFLAG(IS_OHOS) + if (image_type == "heif") { + // Heif image only supports hardware decode now. We need to trigger the task + // by updating all_data_received_prior_to_decode flag even if it is not the + // first decoding and the task can only trigger when all data is received. + image_metadata_->all_data_received_prior_to_decode = all_data_received_; + } +#endif auto generator = DecodingImageGenerator::Create( frame_generator_, info, std::move(segment_reader), std::move(frames), diff --git a/blink/renderer/platform/image-decoders/bmp/bmp_image_reader.cc b/blink/renderer/platform/image-decoders/bmp/bmp_image_reader.cc index 1a19fcfb635d6e3634d3eedee7373633e8d462c2..8b87baed3cec9a02194389356e8e482467e6ebe0 100644 --- a/blink/renderer/platform/image-decoders/bmp/bmp_image_reader.cc +++ b/blink/renderer/platform/image-decoders/bmp/bmp_image_reader.cc @@ -723,22 +723,29 @@ bool BMPImageReader::ProcessColorTable() { const wtf_size_t header_end = header_offset_ + info_header_.size; wtf_size_t colors_in_palette = info_header_.clr_used; + CHECK_LE(colors_in_palette, 256u); // Enforced by ProcessInfoHeader(). wtf_size_t table_size_in_bytes = colors_in_palette * bytes_per_color; const wtf_size_t table_end = header_end + table_size_in_bytes; if (table_end < header_end) return parent_->SetFailed(); - // Some BMPs don't contain a complete palette. Avoid reading off the end. + // Some BMPs don't contain a complete palette. Truncate it instead of reading + // off the end of the palette. if (img_data_offset_ && (img_data_offset_ < table_end)) { - colors_in_palette = (img_data_offset_ - header_end) / bytes_per_color; + wtf_size_t colors_in_truncated_palette = + (img_data_offset_ - header_end) / bytes_per_color; + CHECK_LE(colors_in_truncated_palette, colors_in_palette); + colors_in_palette = colors_in_truncated_palette; table_size_in_bytes = colors_in_palette * bytes_per_color; } - // Read color table. + // If we don't have enough data to read in the whole palette yet, stop here. if ((decoded_offset_ > data_->size()) || ((data_->size() - decoded_offset_) < table_size_in_bytes)) return false; - color_table_.resize(info_header_.clr_used); + + // Read the color table. + color_table_.resize(colors_in_palette); for (wtf_size_t i = 0; i < colors_in_palette; ++i) { color_table_[i].rgb_blue = ReadUint8(0); @@ -746,12 +753,6 @@ bool BMPImageReader::ProcessColorTable() { color_table_[i].rgb_red = ReadUint8(2); decoded_offset_ += bytes_per_color; } - // Explicitly zero any colors past the end of a truncated palette. - for (wtf_size_t i = colors_in_palette; i < info_header_.clr_used; ++i) { - color_table_[i].rgb_blue = 0; - color_table_[i].rgb_green = 0; - color_table_[i].rgb_red = 0; - } // We've now decoded all the non-image data we care about. Skip anything // else before the actual raster data. @@ -927,7 +928,7 @@ BMPImageReader::ProcessingResult BMPImageReader::ProcessRLEData() { for (wtf_size_t which = 0; coord_.x() < end_x;) { // Some images specify color values past the end of the // color table; set these pixels to black. - if (color_indexes[which] < info_header_.clr_used) + if (color_indexes[which] < color_table_.size()) SetI(color_indexes[which]); else SetRGBA(0, 0, 0, 255); @@ -1001,7 +1002,7 @@ BMPImageReader::ProcessingResult BMPImageReader::ProcessNonRLEData( } } else { // See comments near the end of ProcessRLEData(). - if (color_index < info_header_.clr_used) + if (color_index < color_table_.size()) SetI(color_index); else SetRGBA(0, 0, 0, 255); @@ -1061,10 +1062,6 @@ void BMPImageReader::MoveBufferToNextRow() { void BMPImageReader::ColorCorrectCurrentRow() { if (decoding_and_mask_) return; - // Postprocess the image data according to the profile. - const ColorProfileTransform* const transform = parent_->ColorTransform(); - if (!transform) - return; int decoder_width = parent_->Size().width(); // Enforce 0 ≤ current row < bitmap height. CHECK_GE(coord_.y(), 0); @@ -1072,6 +1069,10 @@ void BMPImageReader::ColorCorrectCurrentRow() { // Enforce decoder width == bitmap width exactly. (The bitmap rowbytes might // add a bit of padding, but we are only converting one row at a time.) CHECK_EQ(decoder_width, buffer_->Bitmap().width()); + // Postprocess the image data according to the profile. + const ColorProfileTransform* const transform = parent_->ColorTransform(); + if (!transform) + return; ImageFrame::PixelData* const row = buffer_->GetAddr(0, coord_.y()); const skcms_PixelFormat fmt = XformColorFormat(); const skcms_AlphaFormat alpha = diff --git a/blink/renderer/platform/image-decoders/heif/heif_image_decoder.cc b/blink/renderer/platform/image-decoders/heif/heif_image_decoder.cc new file mode 100644 index 0000000000000000000000000000000000000000..37afed99d1e4696e870edc0dd151b8d89afa6fd1 --- /dev/null +++ b/blink/renderer/platform/image-decoders/heif/heif_image_decoder.cc @@ -0,0 +1,330 @@ +/* + * 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 + * + * 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, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "third_party/blink/renderer/platform/image-decoders/heif/heif_image_decoder.h" + +#include + +#include +#include +#include + +#include "base/bits.h" +#include "base/containers/adapters.h" +#include "base/logging.h" +#include "base/memory/scoped_refptr.h" +#include "base/numerics/safe_conversions.h" +#include "base/ranges/algorithm.h" +#include "base/timer/elapsed_timer.h" +#include "build/build_config.h" +#include "media/video/half_float_maker.h" +#include "third_party/abseil-cpp/absl/types/optional.h" +#include "third_party/blink/renderer/platform/image-decoders/image_animation.h" +#include "third_party/blink/renderer/platform/image-decoders/image_decoder.h" +#include "third_party/ohos_ndk/includes/ohos_adapter/ohos_adapter_helper.h" +#include "third_party/skia/include/core/SkColorSpace.h" + +#if defined(ARCH_CPU_BIG_ENDIAN) +#error Blink assumes a little-endian target. +#endif + +namespace blink { + +namespace { + +// Refer to +// fundation/multimedia/image_framework/plugins/common/libs/image/formatagentplugin/src/heif_format_agent.cpp. +constexpr uint32_t kHeaderSize = 32; +constexpr uint32_t kHeaderLeastSize = 8; +constexpr size_t kHeaderNextSize = 16; +constexpr uint32_t kOffsetSize = 8; + +constexpr uint32_t kShiftBase = 8; +constexpr uint32_t kTimesSeven = 7; +constexpr uint32_t kTimesFive = 5; +constexpr uint32_t kTimesThree = 3; +constexpr uint32_t kTimesTwo = 2; + +uint32_t Fourcc(uint8_t c1, uint8_t c2, uint8_t c3, uint8_t c4) { + return (c1 << (kShiftBase * kTimesThree)) | (c2 << (kShiftBase * kTimesTwo)) | + (c3 << kShiftBase) | (c4); +} + +uint32_t EndianSwap32(uint32_t value) { + return ((value & 0xFF) << (kShiftBase * kTimesThree)) | + ((value & 0xFF00) << kShiftBase) | ((value & 0xFF0000) >> kShiftBase) | + (value >> (kShiftBase * kTimesThree)); +} + +uint64_t EndianSwap64(uint64_t value) { + return (((value & 0x00000000000000FFULL) << (kShiftBase * kTimesSeven)) | + ((value & 0x000000000000FF00ULL) << (kShiftBase * kTimesFive)) | + ((value & 0x0000000000FF0000ULL) << (kShiftBase * kTimesThree)) | + ((value & 0x00000000FF000000ULL) << (kShiftBase)) | + ((value & 0x000000FF00000000ULL) >> (kShiftBase)) | + ((value & 0x0000FF0000000000ULL) >> (kShiftBase * kTimesThree)) | + ((value & 0x00FF000000000000ULL) >> (kShiftBase * kTimesFive)) | + ((value) >> (kShiftBase * kTimesSeven))); +} + +bool IsHeif64(const void* buffer, + const size_t bytes_read, + int64_t& offset, + uint64_t& chunk_size) { + // If it is 1, a 64-bit check is required. + if (chunk_size == 1) { + // This indicates that the next 8 bytes represent the chunk size, + // and chunk data comes after that. + if (bytes_read < kHeaderNextSize) { + LOG(INFO) << "[HeifSupport] bytes_read " << bytes_read + << " is less than sixteen."; + return false; + } + auto* chunk_size_ptr = + static_cast(buffer) + (offset / sizeof(uint64_t)); + chunk_size = EndianSwap64(*chunk_size_ptr); + if (chunk_size < kHeaderNextSize) { + // The smallest valid chunk is 16 bytes long in this case. + LOG(INFO) << "[HeifSupport] chunk_size " + << static_cast(chunk_size) + << " is less than sixteen."; + return false; + } + offset += kOffsetSize; + } else if (chunk_size < kHeaderLeastSize) { + // The smallest valid chunk is 8 bytes long. + LOG(INFO) << "[HeifSupport] chunk_size " + << static_cast(chunk_size) + << " is less than eight."; + return false; + } + + if (chunk_size > bytes_read) { + chunk_size = bytes_read; + } + return true; +} + +bool CheckFormat(const void* header_data, uint32_t data_size) { + if (!header_data) { + LOG(INFO) << "[HeifSupport] header_data is null."; + return false; + } + // Any valid ftyp box should have at least 8 bytes. + if (data_size < kHeaderLeastSize) { + LOG(INFO) << "[HeifSupport] data_size " << data_size + << " is less than eight."; + return false; + } + + uint32_t tmp_buff[kHeaderSize]; + // TODO: Use memcpy_s. + memcpy(tmp_buff, header_data, kHeaderSize); + + const uint32_t* ptr = reinterpret_cast(tmp_buff); + uint64_t chunk_size = EndianSwap32(ptr[0]); // first item + uint32_t chunk_type = EndianSwap32(ptr[1]); // second item + if (chunk_type != Fourcc('f', 't', 'y', 'p')) { + LOG(INFO) << "[HeifSupport] head type is not ftyp."; + return false; + } + + int64_t offset = kOffsetSize; + if (!IsHeif64(tmp_buff, data_size, offset, chunk_size)) { + return false; + } + int64_t chunk_data_size = static_cast(chunk_size) - offset; + // It should at least have major brand (4-byte) and minor version (4-bytes). + // The rest of the chunk (if any) is a list of (4-byte) compatible brands. + if (chunk_data_size < kHeaderLeastSize) { + LOG(INFO) << "[HeifSupport] chunk data size " + << static_cast(chunk_data_size) + << " is less than eight."; + return false; + } + uint32_t num_compatible_brands = + (uint32_t)(chunk_data_size - kOffsetSize) / sizeof(uint32_t); + if (num_compatible_brands != 0 && + num_compatible_brands + kTimesTwo < kHeaderSize) { + for (size_t i = 0; i < num_compatible_brands + 2; + ++i) { + // need next 2 item + if (i == 1) { + // Skip this index, it refers to the minorVersion, not a brand. + continue; + } + auto* brand_ptr = + static_cast(tmp_buff) + (num_compatible_brands + i); + uint32_t brand = EndianSwap32(*brand_ptr); + if (brand == Fourcc('m', 'i', 'f', '1') || + brand == Fourcc('h', 'e', 'i', 'c') || + brand == Fourcc('m', 's', 'f', '1') || + brand == Fourcc('h', 'e', 'v', 'c')) { + return true; + } + } + } + LOG(INFO) << "[HeifSupport] check heif format is failed."; + return false; +} + +} // namespace + +std::unique_ptr + HEIFImageDecoder::decoder_adapter_; + +HEIFImageDecoder::HEIFImageDecoder(AlphaOption alpha_option, + HighBitDepthDecodingOption hbd_option, + const ColorBehavior& color_behavior, + wtf_size_t max_decoded_bytes, + AnimationOption animation_option) + : ImageDecoder(alpha_option, + hbd_option, + color_behavior, + max_decoded_bytes) {} + +HEIFImageDecoder::~HEIFImageDecoder() { + decoder_adapter_ = nullptr; +} + +const AtomicString& HEIFImageDecoder::MimeType() const { + DEFINE_STATIC_LOCAL(const AtomicString, heif_mime_type, ("image/heif")); + return heif_mime_type; +} + +bool HEIFImageDecoder::ImageIsHighBitDepth() { + return bit_depth_ > 8; +} + +void HEIFImageDecoder::OnSetData(SegmentReader* data) { + if (!IsAllDataReceived() || !data || data->size() == 0) { + return; + } + LOG(INFO) << "[HeifSupport] HEIFImageDecoder::OnSetData parse image size " << data->size(); + auto sk_data = data->GetAsSkData(); + base::span encoded_data = + base::make_span(sk_data->bytes(), sk_data->size()); + + if (GetDecoderAdapter()->ParseImageInfo(encoded_data.data(), + (uint32_t)encoded_data.size())) { + LOG(INFO) << "[HeifSupport] HEIF image size " << GetDecoderAdapter()->GetImageWidth() + << " * " << GetDecoderAdapter()->GetImageHeight(); + SetSize(GetDecoderAdapter()->GetImageWidth(), + GetDecoderAdapter()->GetImageHeight()); + return; + } + LOG(ERROR) << "[HeifSupport] Fail to parsing image information. "; + SetFailed(); +} + +cc::YUVSubsampling HEIFImageDecoder::GetYUVSubsampling() const { + return cc::YUVSubsampling::k420; +} + +gfx::Size HEIFImageDecoder::DecodedYUVSize(cc::YUVIndex index) const { + DCHECK(IsDecodedSizeAvailable()); + return Size(); +} + +wtf_size_t HEIFImageDecoder::DecodedYUVWidthBytes(cc::YUVIndex index) const { + return 0; +} + +SkYUVColorSpace HEIFImageDecoder::GetYUVColorSpace() const { + DCHECK(CanDecodeToYUV()); + DCHECK_NE(yuv_color_space_, SkYUVColorSpace::kIdentity_SkYUVColorSpace); + return yuv_color_space_; +} + +uint8_t HEIFImageDecoder::GetYUVBitDepth() const { + DCHECK(CanDecodeToYUV()); + return bit_depth_; +} + +absl::optional HEIFImageDecoder::GetHDRMetadata() const { + return hdr_metadata_; +} + +void HEIFImageDecoder::DecodeToYUV() {} + +int HEIFImageDecoder::RepetitionCount() const { + return kAnimationNone; +} + +bool HEIFImageDecoder::FrameIsReceivedAtIndex(wtf_size_t index) const { + return true; +} + +absl::optional HEIFImageDecoder::FrameTimestampAtIndex( + wtf_size_t index) const { + return index < frame_buffer_cache_.size() + ? frame_buffer_cache_[index].Timestamp() + : absl::nullopt; +} + +base::TimeDelta HEIFImageDecoder::FrameDurationAtIndex(wtf_size_t index) const { + return index < frame_buffer_cache_.size() + ? frame_buffer_cache_[index].Duration() + : base::TimeDelta(); +} + +bool HEIFImageDecoder::ImageHasBothStillAndAnimatedSubImages() const { + return false; +} + +void HEIFImageDecoder::DecodeSize() {} + +wtf_size_t HEIFImageDecoder::DecodeFrameCount() { + decoded_frame_count_ = 1; + return IsDecodedSizeAvailable() ? decoded_frame_count_ + : frame_buffer_cache_.size(); +} + +void HEIFImageDecoder::InitializeNewFrame(wtf_size_t index) {} + +void HEIFImageDecoder::Decode(wtf_size_t index) {} + +bool HEIFImageDecoder::CanReusePreviousFrameBuffer(wtf_size_t index) const { + return true; +} + +bool HEIFImageDecoder::MatchesHeifSignature(const sk_sp& data) { + base::span encoded_data = + base::make_span(data->bytes(), data->size()); + if (CheckFormat(encoded_data.data(), (uint32_t)encoded_data.size())) { + LOG(INFO) << "[HeifSupport] HEIFImageDecoder::MatchesHeifSignature is heif " + "format."; + return true; + } + + // Do double check. + if (GetDecoderAdapter()->ParseImageInfo(encoded_data.data(), + (uint32_t)encoded_data.size())) { + return GetDecoderAdapter()->GetEncodedFormat() == "image/heif"; + } + LOG(INFO) << "[HeifSupport] Fail to parsing image information. "; + return false; +} + +OHOS::NWeb::OhosImageDecoderAdapter* HEIFImageDecoder::GetDecoderAdapter() { + if (!decoder_adapter_) { + decoder_adapter_ = OHOS::NWeb::OhosAdapterHelper::GetInstance() + .CreateOhosImageDecoderAdapter(); + } + + return decoder_adapter_.get(); +} + +} // namespace blink \ No newline at end of file diff --git a/blink/renderer/platform/image-decoders/heif/heif_image_decoder.h b/blink/renderer/platform/image-decoders/heif/heif_image_decoder.h new file mode 100644 index 0000000000000000000000000000000000000000..f0027e8734f391193b495245c748d540a5501944 --- /dev/null +++ b/blink/renderer/platform/image-decoders/heif/heif_image_decoder.h @@ -0,0 +1,89 @@ +/* + * 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 + * + * 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, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_IMAGE_DECODERS_HEIF_HEIF_IMAGE_DECODER_H_ +#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_IMAGE_DECODERS_HEIF_HEIF_IMAGE_DECODER_H_ + +#include + +#include "third_party/blink/renderer/platform/allow_discouraged_type.h" +#include "third_party/blink/renderer/platform/image-decoders/image_decoder.h" +#include "third_party/blink/renderer/platform/wtf/vector.h" +#include "third_party/skia/include/core/SkImageInfo.h" +#include "ui/gfx/color_space.h" +#include "ui/gfx/color_transform.h" + +namespace OHOS::NWeb { +class OhosImageDecoderAdapter; +} + +namespace blink { + +// Software decode is not supported now.This class is only used to implicate +// the image type and size. +class PLATFORM_EXPORT HEIFImageDecoder final : public ImageDecoder { + public: + HEIFImageDecoder(AlphaOption, + HighBitDepthDecodingOption, + const ColorBehavior&, + wtf_size_t max_decoded_bytes, + AnimationOption); + HEIFImageDecoder(const HEIFImageDecoder&) = delete; + HEIFImageDecoder& operator=(const HEIFImageDecoder&) = delete; + ~HEIFImageDecoder() override; + + // ImageDecoder: + String FilenameExtension() const override { return "heif"; } + const AtomicString& MimeType() const override; + bool ImageIsHighBitDepth() override; + void OnSetData(SegmentReader* data) override; + cc::YUVSubsampling GetYUVSubsampling() const override; + gfx::Size DecodedYUVSize(cc::YUVIndex) const override; + wtf_size_t DecodedYUVWidthBytes(cc::YUVIndex) const override; + SkYUVColorSpace GetYUVColorSpace() const override; + uint8_t GetYUVBitDepth() const override; + absl::optional GetHDRMetadata() const override; + void DecodeToYUV() override; + int RepetitionCount() const override; + bool FrameIsReceivedAtIndex(wtf_size_t) const override; + absl::optional FrameTimestampAtIndex( + wtf_size_t) const override; + base::TimeDelta FrameDurationAtIndex(wtf_size_t) const override; + bool ImageHasBothStillAndAnimatedSubImages() const override; + + static bool MatchesHeifSignature(const sk_sp& data); + static OHOS::NWeb::OhosImageDecoderAdapter* GetDecoderAdapter(); + + private: + // ImageDecoder: + void DecodeSize() override; + wtf_size_t DecodeFrameCount() override; + void InitializeNewFrame(wtf_size_t) override; + void Decode(wtf_size_t) override; + bool CanReusePreviousFrameBuffer(wtf_size_t) const override; + + // The bit depth from the container. + uint8_t bit_depth_ = 0; + absl::optional hdr_metadata_; + + // This is only used to parse image size and type. + static std::unique_ptr decoder_adapter_; + wtf_size_t decoded_frame_count_ = 0; + SkYUVColorSpace yuv_color_space_ = SkYUVColorSpace::kIdentity_SkYUVColorSpace; +}; + +} // namespace blink + +#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_IMAGE_DECODERS_HEIF_HEIF_IMAGE_DECODER_H_ diff --git a/blink/renderer/platform/image-decoders/image_decoder.cc b/blink/renderer/platform/image-decoders/image_decoder.cc index 350db59c90f6d40dccb2f3e682ae2aa8b2f084ad..a8ffe9cd1def06066ac07f8f4c13c7feeb0c5973 100644 --- a/blink/renderer/platform/image-decoders/image_decoder.cc +++ b/blink/renderer/platform/image-decoders/image_decoder.cc @@ -47,6 +47,9 @@ #if BUILDFLAG(ENABLE_AV1_DECODER) #include "third_party/blink/renderer/platform/image-decoders/avif/avif_image_decoder.h" #endif +#if BUILDFLAG(IS_OHOS) +#include "third_party/blink/renderer/platform/image-decoders/heif/heif_image_decoder.h" +#endif namespace blink { @@ -68,6 +71,10 @@ cc::ImageType FileExtensionToImageType(String image_extension) { #if BUILDFLAG(ENABLE_AV1_DECODER) if (image_extension == "avif") return cc::ImageType::kAVIF; +#endif +#if BUILDFLAG(IS_OHOS) + if (image_extension == "heif") + return cc::ImageType::kHEIF; #endif return cc::ImageType::kInvalid; } @@ -175,6 +182,11 @@ String SniffMimeTypeInternal(scoped_refptr reader) { if (AVIFImageDecoder::MatchesAVIFSignature(fast_reader)) return "image/avif"; #endif +#if BUILDFLAG(IS_OHOS) + if (HEIFImageDecoder::MatchesHeifSignature(reader->GetAsSkData())) { + return "image/heif"; + } +#endif return String(); } @@ -258,6 +270,12 @@ std::unique_ptr ImageDecoder::CreateByMimeType( decoder = std::make_unique( alpha_option, high_bit_depth_decoding_option, color_behavior, max_decoded_bytes, animation_option); +#endif +#if BUILDFLAG(IS_OHOS) + } else if (mime_type == "image/heif") { + decoder = std::make_unique( + alpha_option, high_bit_depth_decoding_option, color_behavior, + max_decoded_bytes, animation_option); #endif } diff --git a/blink/renderer/platform/loader/fetch/buffering_bytes_consumer.cc b/blink/renderer/platform/loader/fetch/buffering_bytes_consumer.cc index 16ff233a0eafd9da9cd9a6b7bcc2d957e38a6534..910a1c12e66355dd8ddebc054e04b0f47ed2670c 100644 --- a/blink/renderer/platform/loader/fetch/buffering_bytes_consumer.cc +++ b/blink/renderer/platform/loader/fetch/buffering_bytes_consumer.cc @@ -145,10 +145,12 @@ mojo::ScopedDataPipeConsumerHandle BufferingBytesConsumer::DrainAsDataPipe() { } void BufferingBytesConsumer::SetClient(BytesConsumer::Client* client) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); client_ = client; } void BufferingBytesConsumer::ClearClient() { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); client_ = nullptr; } @@ -181,6 +183,7 @@ void BufferingBytesConsumer::OnTimerFired(TimerBase*) { } void BufferingBytesConsumer::OnStateChange() { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); BytesConsumer::Client* client = client_; BufferData(); if (client) diff --git a/blink/renderer/platform/loader/fetch/buffering_bytes_consumer.h b/blink/renderer/platform/loader/fetch/buffering_bytes_consumer.h index ad2e7f7a5096d4036941cbffe711600a7dc240c5..f45ab8c351e46d981eff0acb56ab54c60cde1bb0 100644 --- a/blink/renderer/platform/loader/fetch/buffering_bytes_consumer.h +++ b/blink/renderer/platform/loader/fetch/buffering_bytes_consumer.h @@ -100,6 +100,7 @@ class PLATFORM_EXPORT BufferingBytesConsumer final bool has_seen_end_of_data_ = false; bool has_seen_error_ = false; Member client_; + SEQUENCE_CHECKER(sequence_checker_); }; } // namespace blink diff --git a/blink/renderer/platform/loader/fetch/resource_fetcher.cc b/blink/renderer/platform/loader/fetch/resource_fetcher.cc index e10fdd2c0edbd5312ce9a9f2ad01d1a6627c3754..3e4fa3d3e54da47d24ccae69ea1f907c87d5aee6 100644 --- a/blink/renderer/platform/loader/fetch/resource_fetcher.cc +++ b/blink/renderer/platform/loader/fetch/resource_fetcher.cc @@ -1224,9 +1224,10 @@ Resource* ResourceFetcher::RequestResource(FetchParameters& params, } }, base::TimeTicks::Now(), params.Url().ProtocolIsData())); +#if BUILDFLAG(IS_OHOS) TRACE_EVENT2("blink,blink.resource", "ResourceFetcher::requestResource", "url", params.Url().ElidedString().Utf8(), "method", params.GetResourceRequest().HttpMethod().Utf8()); - +#endif // |resource_request|'s origin can be null here, corresponding to the "client" // value in the spec. In that case client's origin is used. if (!resource_request.RequestorOrigin()) { @@ -2646,6 +2647,14 @@ void ResourceFetcher::StopFetchingInternal(StopFetchingTarget target) { } } +#ifdef OHOS_LOG_MESSAGE + if (loaders_to_cancel.size()) { + LOG(INFO) << "Resource fetcher StopFetchingInternal, the size of loaders_to_cancel: " + << loaders_to_cancel.size() << ", target: " + << static_cast(target); + } +#endif + for (const auto& loader : loaders_to_cancel) { if (loaders_.Contains(loader) || non_blocking_loaders_.Contains(loader)) loader->Cancel(); diff --git a/blink/renderer/platform/loader/fetch/resource_loader.cc b/blink/renderer/platform/loader/fetch/resource_loader.cc index dc27b2984e024073b6f45e1ad4350a0afab273f3..c9a0ea5c5d1e3461c4c4243a8072ed4e1f4623ab 100644 --- a/blink/renderer/platform/loader/fetch/resource_loader.cc +++ b/blink/renderer/platform/loader/fetch/resource_loader.cc @@ -454,11 +454,15 @@ void ResourceLoader::CodeCacheRequest::MaybeSendCachedCode( resource_response_time_.is_null() || resource_response_time_ != cached_code_response_time_) { ClearCachedCodeIfPresent(); + LOG(DEBUG) << "Cannot use code cache. timestamp not match. url: " << url_.GetString().Utf8().c_str() << + ". resource_response_time_: " << resource_response_time_ << + ". cached_code_response_time_: " << cached_code_response_time_; return; } } if (data.size() > 0) { + LOG(DEBUG) << "Send code cache to resource. url: " << url_.GetString().Utf8().c_str(); resource_loader->SendCachedCodeToResource(std::move(data)); } } @@ -678,6 +682,9 @@ void ResourceLoader::DidFailLoadingBody() { } void ResourceLoader::DidCancelLoadingBody() { +#ifdef OHOS_LOG_MESSAGE + LOG(WARNING) << "Resource loader DidCancelLoadingBody, url: ***"; +#endif Cancel(); } @@ -687,6 +694,9 @@ void ResourceLoader::StartWith(const ResourceRequestHead& request) { if (resource_->Options().synchronous_policy == kRequestSynchronously && fetcher_->GetProperties().FreezeMode() != LoaderFreezeMode::kNone) { +#ifdef OHOS_LOG_MESSAGE + LOG(WARNING) << "Resource loader StartWith, url: ***"; +#endif // TODO(yuzus): Evict bfcache if necessary. Cancel(); return; @@ -796,8 +806,15 @@ void ResourceLoader::ScheduleCancel() { } void ResourceLoader::CancelTimerFired(TimerBase*) { +#ifdef OHOS_LOG_MESSAGE + if (loader_ && !resource_->HasClientsOrObservers()) { + LOG(WARNING) << "Resource loader CancelTimerFired, url *"; + Cancel(); + } +#else if (loader_ && !resource_->HasClientsOrObservers()) Cancel(); +#endif } void ResourceLoader::Cancel() { diff --git a/blink/renderer/platform/loader/fetch/url_loader/resource_request_sender.cc b/blink/renderer/platform/loader/fetch/url_loader/resource_request_sender.cc index 70dee58a34564ca11c0e797cd3b0e7c076ff54de..68cec9f395dbd31966f86bbb9953434d63d4067c 100644 --- a/blink/renderer/platform/loader/fetch/url_loader/resource_request_sender.cc +++ b/blink/renderer/platform/loader/fetch/url_loader/resource_request_sender.cc @@ -229,10 +229,10 @@ int ResourceRequestSender::SendAsync( std::unique_ptr resource_load_info_notifier_wrapper, #if BUILDFLAG(IS_OHOS) - BackForwardCacheLoaderHelper* back_forward_cache_loader_helper, - bool is_sync_mode) { + BackForwardCacheLoaderHelper* back_forward_cache_loader_helper, + bool is_sync_mode) { #else - BackForwardCacheLoaderHelper* back_forward_cache_loader_helper) { + BackForwardCacheLoaderHelper* back_forward_cache_loader_helper) { #endif CheckSchemeForReferrerPolicy(*request); @@ -453,6 +453,11 @@ void ResourceRequestSender::OnTransferDataWithSharedMemory(base::ReadOnlySharedM return; } LOG(DEBUG) << "intercept ResourceRequestSender::OnTransferDataWithSharedMemory, buffer_size=" << buffer_size; + if (request_info_->resource_load_info_notifier_wrapper) { + request_info_->resource_load_info_notifier_wrapper->SetUsedSharedMemory(); + } else { + LOG(ERROR) << "resource load info notifier wrapper is nullptr"; + } request_info_->client->OnTransferDataWithSharedMemory(std::move(region), buffer_size); } #endif diff --git a/blink/renderer/platform/loader/fetch/url_loader/resource_request_sender_unittest.cc b/blink/renderer/platform/loader/fetch/url_loader/resource_request_sender_unittest.cc index 0f825be2656738d27c16bdb1fdd12d149391e7d9..9f954c8fc99238a8c583535448b2b2f2c70bfc0f 100644 --- a/blink/renderer/platform/loader/fetch/url_loader/resource_request_sender_unittest.cc +++ b/blink/renderer/platform/loader/fetch/url_loader/resource_request_sender_unittest.cc @@ -178,7 +178,7 @@ class ResourceRequestSenderTest : public testing::Test, std::vector>(), std::make_unique( /*resource_load_info_notifier=*/nullptr), - /*back_forward_cache_loader_helper=*/nullptr, false); + /*back_forward_cache_loader_helper=*/nullptr); } protected: diff --git a/blink/renderer/platform/loader/fetch/url_loader/sync_load_context.cc b/blink/renderer/platform/loader/fetch/url_loader/sync_load_context.cc index dec1ff54a4a5366758b75596087822333bb2fbc0..781faa3ff4e0b6d05e2e99295b82174495d14226 100644 --- a/blink/renderer/platform/loader/fetch/url_loader/sync_load_context.cc +++ b/blink/renderer/platform/loader/fetch/url_loader/sync_load_context.cc @@ -265,7 +265,7 @@ void SyncLoadContext::OnReceivedResponse( #if BUILDFLAG(IS_OHOS) void SyncLoadContext::OnTransferDataWithSharedMemory(base::ReadOnlySharedMemoryRegion region, uint64_t buffer_size) { TRACE_EVENT0("loading", "SyncLoadContext::OnTransferDataWithSharedMemory"); - LOG(DEBUG) << "shared-memory SyncLoadContext::OnTransferDataWithSharedMemory+++, buffer_size=" << buffer_size; + LOG(DEBUG) << "shared-memory SyncLoadContext::OnTransferDataWithSharedMemory+++, buffer_size:" << buffer_size; if (!region.IsValid()) { LOG(ERROR) << "shared-memory region is invalid"; response_->error_code = net::ERR_FAILED; @@ -281,6 +281,7 @@ void SyncLoadContext::OnTransferDataWithSharedMemory(base::ReadOnlySharedMemoryR } const char* buffer = mapping.GetMemoryAs(); size_t buffer_len = static_cast(buffer_size); + LOG(DEBUG) << "shared-memory SyncLoadContext::OnTransferDataWithSharedMemory, buffer_len:" << buffer_len; if (!response_->data) { response_->data = SharedBuffer::Create(buffer, buffer_len); } else { @@ -303,7 +304,7 @@ void SyncLoadContext::OnTransferDataWithSharedMemory(base::ReadOnlySharedMemoryR response_->head->encoded_body_length = network::mojom::EncodedBodyLength::New(status.encoded_body_length); CompleteRequest(); - LOG(DEBUG) << "shared-memory SyncLoadContext::OnTransferDataWithSharedMemory---, buffer_size=" << buffer_size; + LOG(DEBUG) << "shared-memory SyncLoadContext::OnTransferDataWithSharedMemory---, buffer_size:" << buffer_size; } #endif diff --git a/blink/renderer/platform/loader/fetch/url_loader/url_loader.cc b/blink/renderer/platform/loader/fetch/url_loader/url_loader.cc index 034407df5eac3ff21ac2107256967e95de18fdbb..58f32e3c47eb3cd3075409d046179fe03de86a17 100644 --- a/blink/renderer/platform/loader/fetch/url_loader/url_loader.cc +++ b/blink/renderer/platform/loader/fetch/url_loader/url_loader.cc @@ -604,7 +604,7 @@ void URLLoader::LoadAsynchronously( std::unique_ptr resource_load_info_notifier_wrapper, URLLoaderClient* client) { - LOG(DEBUG) << "intercept URLLoader::LoadASynchronously+++"; + LOG(DEBUG) << "intercept URLLoader::LoadAsynchronously+++"; if (!context_) { return; } @@ -618,7 +618,7 @@ void URLLoader::LoadAsynchronously( /*pass_response_pipe_to_client=*/false, no_mime_sniffing, base::TimeDelta(), nullptr, std::move(resource_load_info_notifier_wrapper)); - LOG(DEBUG) << "intercept URLLoader::LoadASynchronously---"; + LOG(DEBUG) << "intercept URLLoader::LoadAsynchronously---"; } void URLLoader::Cancel() { diff --git a/blink/renderer/platform/loader/fetch/url_loader/url_loader_unittest.cc b/blink/renderer/platform/loader/fetch/url_loader/url_loader_unittest.cc index 9fce0769f232fba5069e4cc6b66cdc948b12e043..184652a5e5fd969d84218ba117497fe815844f2e 100644 --- a/blink/renderer/platform/loader/fetch/url_loader/url_loader_unittest.cc +++ b/blink/renderer/platform/loader/fetch/url_loader/url_loader_unittest.cc @@ -102,12 +102,7 @@ class MockResourceRequestSender : public ResourceRequestSender { WebVector> throttles, std::unique_ptr resource_load_info_notifier_wrapper, - #if BUILDFLAG(IS_OHOS) - BackForwardCacheLoaderHelper* back_forward_cache_loader_helper, - bool is_sync_mode = true) override { - #else BackForwardCacheLoaderHelper* back_forward_cache_loader_helper) override { - #endif EXPECT_FALSE(resource_request_client_); if (sync_load_response_.head->encoded_body_length) { EXPECT_TRUE(loader_options & network::mojom::kURLLoadOptionSynchronous); diff --git a/blink/renderer/platform/media/web_media_player_impl.cc b/blink/renderer/platform/media/web_media_player_impl.cc index 485133d58a388f8f758b098cedfd136b2702870e..8537a7b9ce99ab2765739aa4740525199a2b1b85 100644 --- a/blink/renderer/platform/media/web_media_player_impl.cc +++ b/blink/renderer/platform/media/web_media_player_impl.cc @@ -1116,9 +1116,10 @@ void WebMediaPlayerImpl::DoSeek(base::TimeDelta time, bool time_updated) { TRACE_EVENT2("media", "WebMediaPlayerImpl::DoSeek", "target", time.InSecondsF(), "id", media_player_id_); -#if defined(OHOS_MEDIA) +#ifdef OHOS_MEDIA LOG(WARNING) << "OhMedia::DoSeek seconds = " << time.InSecondsF(); #endif // OHOS_MEDIA + ReadyState old_state = ready_state_; if (ready_state_ > WebMediaPlayer::kReadyStateHaveMetadata) SetReadyState(WebMediaPlayer::kReadyStateHaveMetadata); @@ -1200,7 +1201,7 @@ void WebMediaPlayerImpl::SetVolume(double volume) { watch_time_reporter_->OnVolumeChange(volume); client_->DidPlayerMutedStatusChange(volume == 0.0); -#if defined(OHOS_MEDIA) +#ifdef OHOS_MEDIA LOG(INFO) << "OhMedia::SetVolume volume is :" << volume; #endif // OHOS_MEDIA @@ -1974,9 +1975,9 @@ void WebMediaPlayerImpl::OnError(media::PipelineStatus status) { DCHECK(main_task_runner_->BelongsToCurrentThread()); DCHECK(status != media::PIPELINE_OK); -#if defined(OHOS_MEDIA) +#ifdef OHOS_MEDIA LOG(INFO) << "OhMedia::OnError PipelineStatus = " << status; -#endif // OHOS_MEDIA +#endif if (suppress_destruction_errors_) return; @@ -2292,7 +2293,7 @@ void WebMediaPlayerImpl::OnBufferingStateChangeInternal( DVLOG(1) << __func__ << "(" << state << ", " << reason << ")"; #ifdef OHOS_MEDIA - LOG(INFO) << "OhMedia::OnBufferingStateChangeInternal(" << (void*)this << ")" + LOG(INFO) << "OhMedia::OnBufferingStateChangeInternal(" << (void*)this << ")" << " state:" << BufferingStateToString(state, reason); #endif // OHOS_MEDIA @@ -2629,11 +2630,9 @@ void WebMediaPlayerImpl::OnFrameHidden(bool storing_in_bfcache) { void WebMediaPlayerImpl::OnFrameHidden() { #endif DCHECK(main_task_runner_->BelongsToCurrentThread()); - LOG(INFO) << "WebMediaPlayerImpl::OnFrameHidden()"; - -#if defined(OHOS_MEDIA) +#ifdef OHOS_MEDIA LOG(INFO) << "OhMedia::WebMediaPlayerImpl::OnFrameHidden()" - << " delegate_id:" << delegate_id_; + << " delegate_id_:" << delegate_id_; #endif // OHOS_MEDIA // Backgrounding a video requires a user gesture to resume playback. @@ -2681,11 +2680,10 @@ void WebMediaPlayerImpl::SuspendForFrameClosed() { void WebMediaPlayerImpl::OnFrameShown() { DCHECK(main_task_runner_->BelongsToCurrentThread()); background_pause_timer_.Stop(); - -#if defined(OHOS_MEDIA) +#ifdef OHOS_MEDIA LOG(INFO) << "OhMedia::WebMediaPlayerImpl::OnFrameShown()" - << " delegate_id:" << delegate_id_; -#endif // OHOD_MEDIA + << " delegate_id_:" << delegate_id_; +#endif // OHOS_MEDIA // Foreground videos don't require user gesture to continue playback. video_locked_when_paused_when_hidden_ = false; @@ -2708,8 +2706,8 @@ void WebMediaPlayerImpl::OnFrameShown() { if (paused_when_hidden_) { paused_when_hidden_ = false; -#if defined(OHOS_MEDIA) - LOG(WARNING) << "OhMedia::OnFrameShown ResumePlayBack()"; +#ifdef OHOS_MEDIA + LOG(WARNING) << "OhMedia::OnFrameShown ResumePlayback()"; #endif // OHOS_MEDIA client_->ResumePlayback(); // Calls UpdatePlayState() so return afterwards. return; @@ -4071,11 +4069,10 @@ void WebMediaPlayerImpl::OnFirstFrame(base::TimeTicks frame_time) { media_metrics_provider_->SetTimeToFirstFrame(elapsed); WriteSplitHistogram( &base::UmaHistogramMediumTimes, "Media.TimeToFirstFrame", elapsed); - -#if defined(OHOS_MEDIA) +#ifdef OHOS_MEDIA LOG(INFO) << __func__ << " OhMedia::delegate_id_:" << delegate_id_ << " elapsed:" << elapsed.InSecondsF(); -#endif // OHOS_MEDIA +#endif media::PipelineStatistics ps = GetPipelineStatistics(); if (client_) { diff --git a/blink/renderer/platform/peerconnection/rtc_video_encoder.cc b/blink/renderer/platform/peerconnection/rtc_video_encoder.cc index 6f4c0059c7deae7f6588e6e4771048533689beee..a4238aa8e7297dc6b01e63f37f00b9fe84da4c6d 100644 --- a/blink/renderer/platform/peerconnection/rtc_video_encoder.cc +++ b/blink/renderer/platform/peerconnection/rtc_video_encoder.cc @@ -1690,7 +1690,7 @@ int32_t RTCVideoEncoder::InitializeEncoder( DCHECK_CALLED_ON_VALID_SEQUENCE(webrtc_sequence_checker_); TRACE_EVENT1("webrtc", "RTCVideoEncoder::InitEncode", "config", vea_config.AsHumanReadableString()); - DVLOG(1) << __func__ << ": config=" << vea_config.AsHumanReadableString(); + LOG(INFO) << __func__ << ": config=" << vea_config.AsHumanReadableString(); auto init_start = base::TimeTicks::Now(); // This wait is necessary because this task is completed in GPU process // asynchronously but WebRTC API is synchronous. diff --git a/blink/renderer/platform/web_native_bridge_impl.cc b/blink/renderer/platform/web_native_bridge_impl.cc old mode 100755 new mode 100644 index 73f1b421a7bc871fa47559bbc1d92ea4f5e718af..24e086251dd4df4868a90f0cb6bbd985d92d99f1 --- a/blink/renderer/platform/web_native_bridge_impl.cc +++ b/blink/renderer/platform/web_native_bridge_impl.cc @@ -184,15 +184,6 @@ void WebNativeBridgeImpl::OnSurfaceDestroyed() { client_->OnDestroyNativeSurface(); } -void WebNativeBridgeImpl::OnLayerRectChange(const gfx::Rect& rect) { - DCHECK(main_task_runner_->BelongsToCurrentThread()); - LOG(DEBUG) << "[NativeEmbed] OnLayerRectChange."; - - client_->OnLayerRectChange(rect); - - layer_rect_ = rect; -} - void WebNativeBridgeImpl::OnLayerRectVisibilityChange(bool visibility) { DCHECK(main_task_runner_->BelongsToCurrentThread()); LOG(INFO) << "[NativeEmbed] OnLayerRectVisibilityChange: " @@ -201,6 +192,15 @@ void WebNativeBridgeImpl::OnLayerRectVisibilityChange(bool visibility) { client_->OnLayerRectVisibilityChange(visibility); } +void WebNativeBridgeImpl::OnLayerRectChange(const gfx::Rect& rect) { + DCHECK(main_task_runner_->BelongsToCurrentThread()); + LOG(DEBUG) << "[NativeEmbed] WebNativeBridgeImpl::OnLayerRectChange"; + + client_->OnLayerRectChange(rect); + + layer_rect_ = rect; +} + gfx::Size WebNativeBridgeImpl::NaturalSize() const { return layer_rect_.size(); } @@ -210,8 +210,9 @@ void WebNativeBridgeImpl::OnSetLayer() { DVLOG(1) << __func__; DCHECK(main_task_runner_->BelongsToCurrentThread()); DCHECK(!video_layer_); - media::WebRectChangedCB rect_change_cb = base::BindRepeating( + media::RectChangedCB rect_change_cb = base::BindRepeating( &WebNativeBridgeImpl::OnLayerRectChange, base::Unretained(this)); + media::RectVisibilityChangedCB rect_visibility_change_cb = base::BindRepeating( &WebNativeBridgeImpl::OnLayerRectVisibilityChange, base::Unretained(this)); @@ -220,4 +221,4 @@ void WebNativeBridgeImpl::OnSetLayer() { client_->SetCcLayer(video_layer_.get()); } -} // namespace blink +} // namespace blink \ No newline at end of file diff --git a/blink/renderer/platform/web_native_bridge_impl.h b/blink/renderer/platform/web_native_bridge_impl.h old mode 100755 new mode 100644 diff --git a/blink/renderer/platform/widget/compositing/layer_tree_settings.cc b/blink/renderer/platform/widget/compositing/layer_tree_settings.cc index 27e07893d32aa9ae8b1832426e11cbad4f019728..2931117545c890318a26f5410c07824d6ddf717f 100644 --- a/blink/renderer/platform/widget/compositing/layer_tree_settings.cc +++ b/blink/renderer/platform/widget/compositing/layer_tree_settings.cc @@ -29,6 +29,7 @@ #include "ui/native_theme/overlay_scrollbar_constants_aura.h" #ifdef OHOS_NWEB_EX #include "base/ohos/sys_info_utils.h" +#include "content/public/common/content_switches.h" #endif namespace blink { @@ -188,9 +189,16 @@ cc::ManagedMemoryPolicy GetGpuMemoryPolicy( std::min(actual.bytes_limit_when_visible, static_cast(2000 * 1024 * 1024)); } else { +#if BUILDFLAG(IS_OHOS) + // it needs more tile memory for foldable phone. + actual.bytes_limit_when_visible = + std::min(actual.bytes_limit_when_visible, + static_cast(1024 * 1024 * 1024)); +#else actual.bytes_limit_when_visible = std::min(actual.bytes_limit_when_visible, static_cast(256 * 1024 * 1024)); +#endif } } @@ -348,11 +356,7 @@ cc::LayerTreeSettings GenerateLayerTreeSettings( settings.use_partial_raster = !cmd.HasSwitch(switches::kDisablePartialRaster); // Partial raster is not supported with RawDraw settings.use_partial_raster &= !::features::IsUsingRawDraw(); -#if defined(OHOS_INPUT_EVENTS) - settings.enable_elastic_overscroll = true; -#else settings.enable_elastic_overscroll = platform->IsElasticOverscrollEnabled(); -#endif settings.resource_settings.use_gpu_memory_buffer_resources = cmd.HasSwitch(switches::kEnableGpuMemoryBufferCompositorResources); settings.use_painted_device_scale_factor = true; @@ -532,8 +536,9 @@ cc::LayerTreeSettings GenerateLayerTreeSettings( if (base::CommandLine::ForCurrentProcess()->HasSwitch( ::switches::kForBrowser) && !base::SysInfo::IsLowEndDevice()) { - bool excludable_devices = base::CommandLine::ForCurrentProcess() - ->HasSwitch(::switches::kEnableDeleteUnusedResourcesDelay); + bool excludable_devices = + base::ohos::IsTabletDevice() || base::ohos::IsPcDevice(); + settings.enable_delete_unused_resources_delay = !excludable_devices; } #endif diff --git a/blink/renderer/platform/widget/frame_widget.h b/blink/renderer/platform/widget/frame_widget.h index b79cdda91e8c89e5026518b1589e731918513b0d..4183837d4e41be294432fdddba83f53f505c8af4 100644 --- a/blink/renderer/platform/widget/frame_widget.h +++ b/blink/renderer/platform/widget/frame_widget.h @@ -29,6 +29,10 @@ class LayerTreeSettings; class LayerTreeDebugState; class PaintImage; struct ElementId; + +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT +class LayerTreeExtraState; +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT } // namespace cc namespace display { @@ -307,6 +311,10 @@ class PLATFORM_EXPORT FrameWidget { #endif virtual void GetInputElementAttributes(HashMap& attributes) const = 0; + +#ifdef OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT + virtual void ShowToast(const cc::LayerTreeExtraState& state) = 0; +#endif // OHOS_MEDIA_NETWORK_TRAFFIC_PROMPT }; } // namespace blink diff --git a/blink/renderer/platform/widget/input/elastic_overscroll_controller.cc b/blink/renderer/platform/widget/input/elastic_overscroll_controller.cc index 395f1f56bfb7f9a50b6244a99bdeff730fc67777..603605761b11a77f3466c4ff13ff927ec401f283 100644 --- a/blink/renderer/platform/widget/input/elastic_overscroll_controller.cc +++ b/blink/renderer/platform/widget/input/elastic_overscroll_controller.cc @@ -137,8 +137,10 @@ void ElasticOverscrollController::ObserveGestureEventAndResult( case WebInputEvent::Type::kGestureScrollBegin: { received_overscroll_update_ = false; overscroll_behavior_ = cc::OverscrollBehavior(); +#if !defined(OHOS_INPUT_EVENTS) if (gesture_event.data.scroll_begin.synthetic) return; +#endif bool enter_momentum = gesture_event.data.scroll_begin.inertial_phase == WebGestureEvent::InertialPhaseState::kMomentum; @@ -161,8 +163,10 @@ void ElasticOverscrollController::ObserveGestureEventAndResult( break; } case WebInputEvent::Type::kGestureScrollEnd: { +#if !defined(OHOS_INPUT_EVENTS) if (gesture_event.data.scroll_end.synthetic) return; +#endif ObserveRealScrollEnd(event_timestamp); break; } @@ -177,8 +181,14 @@ void ElasticOverscrollController::UpdateVelocity( float time_delta = (event_timestamp - last_scroll_event_timestamp_).InSecondsF(); if (time_delta < kScrollVelocityZeroingTimeout && time_delta > 0) { +#if defined(OHOS_INPUT_EVENTS) + scroll_velocity_ = gfx::Vector2dF( + CanScrollHorizontally() ? event_delta.x() / time_delta : 0, + event_delta.y() / time_delta); +#else scroll_velocity_ = gfx::Vector2dF(event_delta.x() / time_delta, event_delta.y() / time_delta); +#endif } else { scroll_velocity_ = gfx::Vector2dF(); } @@ -230,7 +240,7 @@ void ElasticOverscrollController::Overscroll( adjusted_overscroll_delta.set_x(0); #if defined(OHOS_INPUT_EVENTS) if (!CanScrollVertically() && CanScrollHorizontally()) -#else +#else if (!CanScrollVertically()) #endif adjusted_overscroll_delta.set_y(0); @@ -343,10 +353,6 @@ void ElasticOverscrollController::Animate(base::TimeTicks time) { if (!CanScrollHorizontally()) { new_stretch_amount.set_x(0); } - - if (!CanScrollVertically()) { - new_stretch_amount.set_y(0); - } #endif stretch_scroll_force_ = AccumulatedOverscrollForStretchAmount(new_stretch_amount); diff --git a/blink/renderer/platform/widget/input/elastic_overscroll_controller_bezier.cc b/blink/renderer/platform/widget/input/elastic_overscroll_controller_bezier.cc index 2a987b56244a42e8ea937a6f2d77d2df903c6d14..7d07a02bd3611e382e106cf0e050eca2347793d9 100644 --- a/blink/renderer/platform/widget/input/elastic_overscroll_controller_bezier.cc +++ b/blink/renderer/platform/widget/input/elastic_overscroll_controller_bezier.cc @@ -12,7 +12,7 @@ namespace { #if defined(OHOS_INPUT_EVENTS) // Used to determine how far the scroller is allowed to stretch. -constexpr double kOverscrollBoundaryMultiplier = 0.3f; +constexpr double kOverscrollBoundaryMultiplier = 0.57f; // Maximum duration for the bounce back animation. constexpr double kBounceBackMaxDurationMilliseconds = 500.0; @@ -259,7 +259,8 @@ ElasticOverscrollControllerBezier::StretchAmountForAccumulatedOverscroll( tanh(2 * accumulated_overscroll.y() / scroll_bounds().height()) * overscroll_boundary.y()); } - + LOG(DEBUG)<<"OverScroll width hand scroll x is "<<(overbounce_distance.x()); + LOG(DEBUG)<<"OverScroll width hand scroll y is "<<(overbounce_distance.y()); return overbounce_distance; } @@ -286,7 +287,8 @@ ElasticOverscrollControllerBezier::AccumulatedOverscrollForStretchAmount( float atanh_value = atanh(stretch_amount.y() / overscroll_boundary.y()); overscrolled_amount.set_y((atanh_value / 2) * scroll_bounds().height()); } - + LOG(DEBUG)<<"OverScroll leave hand scroll x is "<<(overscrolled_amount.x()); + LOG(DEBUG)<<"OverScroll leave hand scroll y is "<<(overscrolled_amount.y()); return overscrolled_amount; } } // namespace blink diff --git a/blink/renderer/platform/widget/input/frame_widget_input_handler_impl.cc b/blink/renderer/platform/widget/input/frame_widget_input_handler_impl.cc index 46eac640166ce7f5895a471b6cd4cb04bc26eb2b..a54c21c63576924f60dabfa94343ad2c68cce05e 100644 --- a/blink/renderer/platform/widget/input/frame_widget_input_handler_impl.cc +++ b/blink/renderer/platform/widget/input/frame_widget_input_handler_impl.cc @@ -483,7 +483,7 @@ FrameWidgetInputHandlerImpl::HandlingState::~HandlingState() { } #if defined(OHOS_EX_FREE_COPY) -void FrameWidgetInputHandlerImpl::SelectAndCopy() { +void FrameWidgetInputHandlerImpl::ShowFreeCopyMenu() { RunOnMainThread(base::BindOnce( [](base::WeakPtr widget, base::WeakPtr handler) { @@ -491,7 +491,7 @@ void FrameWidgetInputHandlerImpl::SelectAndCopy() { if (!widget) { return; } - handler->SelectAndCopy(); + handler->ShowFreeCopyMenu(); }, widget_, main_thread_frame_widget_input_handler_)); } diff --git a/blink/renderer/platform/widget/input/frame_widget_input_handler_impl.h b/blink/renderer/platform/widget/input/frame_widget_input_handler_impl.h index c566ffdadd27dfb4e0ebad6516b1aa9ee6e34740..4433e6f8211a6b59979c7fba9daacf8a834e5304 100644 --- a/blink/renderer/platform/widget/input/frame_widget_input_handler_impl.h +++ b/blink/renderer/platform/widget/input/frame_widget_input_handler_impl.h @@ -99,7 +99,7 @@ class PLATFORM_EXPORT FrameWidgetInputHandlerImpl void MoveCaret(const gfx::Point& point) override; #if defined(OHOS_EX_FREE_COPY) - void SelectAndCopy() override; + void ShowFreeCopyMenu() override; #endif private: enum class UpdateState { kNone, kIsPasting, kIsSelectingRange }; diff --git a/blink/renderer/platform/widget/input/input_handler_proxy.cc b/blink/renderer/platform/widget/input/input_handler_proxy.cc old mode 100644 new mode 100755 index 5c24f2b10673472b7462cfe45094a10e83d7bbef..e88653145ae63a63adc9ae2d5956be0e729c7205 --- a/blink/renderer/platform/widget/input/input_handler_proxy.cc +++ b/blink/renderer/platform/widget/input/input_handler_proxy.cc @@ -436,6 +436,9 @@ void InputHandlerProxy::NativeHitTestResult(bool native, size_t fingerId, int la layerId = layer_impl->id(); native = true; } + if (layer_impl) { + nativeRect_ = layer_impl->GetNativeRect(); + } native_map_[fingerId] = native; if (native) { native_id_map_[fingerId] = layerId; @@ -457,9 +460,15 @@ void InputHandlerProxy::SendNativeEvent(const WebTouchEvent& touch_event, cc::LayerImpl* layer_impl = input_handler_->GetLayerImplById(layer_id); if (layer_impl) { embed_id_ = std::to_string(layer_impl->native_embed_id()); - gfx::RectF nativeRect = layer_impl->GetNativeRect(); - x = x - nativeRect.x(); - y = y - nativeRect.y(); + float scale = layer_impl->GetIdealContentsScaleKey(); + float initScale = layer_impl->GetInitScale(); + if (initScale > 0.f && scale > 0.f) { + x = (x - nativeRect_.x()) / (scale / initScale); + y = (y - nativeRect_.y()) / (scale / initScale); + } else { + x = x - nativeRect_.x(); + y = y - nativeRect_.y(); + } client_->DidNativeEmbedEvent(type, embed_id_, id, x, y); } else { if (!native_event_queue_->empty()) { @@ -505,6 +514,7 @@ bool InputHandlerProxy::DidNativeEmbedEvent(const WebInputEvent& event) { return result; } + void InputHandlerProxy::SetGestureEventResult(bool result) { LOG(DEBUG)<<"[NativeEmbed] SetGestureEventResult result is : "<empty()) { diff --git a/blink/renderer/platform/widget/input/input_handler_proxy.h b/blink/renderer/platform/widget/input/input_handler_proxy.h index 0bb4840bd1e477d4e78a79393c403bbaada154fd..ea11cd7d9cc799b2b3ab2e5c8331c0bd0275a52a 100644 --- a/blink/renderer/platform/widget/input/input_handler_proxy.h +++ b/blink/renderer/platform/widget/input/input_handler_proxy.h @@ -241,7 +241,6 @@ class PLATFORM_EXPORT InputHandlerProxy : public cc::InputHandlerClient, WebInputEvent::Type type, size_t i, bool result = true); void TriggerVsyncImplTask(); void NativeHitTestResult(bool native, size_t fingerId, int layerId); - void NativeHitTestResult(bool native, size_t fingerId); #endif #if defined(OHOS_INPUT_EVENTS) void SetOverscrollMode(int mode); @@ -456,6 +455,7 @@ class PLATFORM_EXPORT InputHandlerProxy : public cc::InputHandlerClient, std::unordered_map native_map_; WebTouchEvent start_touch_event_; std::unordered_map native_id_map_; + gfx::RectF nativeRect_; #endif }; diff --git a/blink/renderer/platform/widget/input/main_thread_event_queue.cc b/blink/renderer/platform/widget/input/main_thread_event_queue.cc index e2acb5b8319410ced28774495e19b05c52c27831..3a85f9fd49846c9bd5f566c76f1f0daca28fffae 100644 --- a/blink/renderer/platform/widget/input/main_thread_event_queue.cc +++ b/blink/renderer/platform/widget/input/main_thread_event_queue.cc @@ -273,9 +273,6 @@ MainThreadEventQueue::MainThreadEventQueue( scoped_refptr widget_scheduler, bool allow_raf_aligned_input) : client_(client), - last_touch_start_forced_nonblocking_due_to_fling_(false), - needs_low_latency_(false), - needs_unbuffered_input_for_debugger_(false), allow_raf_aligned_input_(allow_raf_aligned_input), main_task_runner_(main_task_runner), widget_scheduler_(std::move(widget_scheduler)) { diff --git a/blink/renderer/platform/widget/input/main_thread_event_queue.h b/blink/renderer/platform/widget/input/main_thread_event_queue.h index e94abaa333722b006f8a236ee3fc2daeb8da99cc..d4b8d146953849a90b693da2de43ce27d7ec4b07 100644 --- a/blink/renderer/platform/widget/input/main_thread_event_queue.h +++ b/blink/renderer/platform/widget/input/main_thread_event_queue.h @@ -170,13 +170,20 @@ class PLATFORM_EXPORT MainThreadEventQueue friend class MainThreadEventQueueTest; friend class MainThreadEventQueueInitializationTest; MainThreadEventQueueClient* client_; - bool last_touch_start_forced_nonblocking_due_to_fling_; - bool needs_low_latency_; - bool needs_unbuffered_input_for_debugger_; - bool allow_raf_aligned_input_; - bool needs_low_latency_until_pointer_up_ = false; + const bool allow_raf_aligned_input_; + bool last_touch_start_forced_nonblocking_due_to_fling_ = false; bool has_pointerrawupdate_handlers_ = false; + // These variables are read on the compositor thread but are + // written on the main thread, so we use atomics to keep them + // lock free. Reading these variables off of the compositor thread + // is best effort. It is fine that the compositor executes a slightly + // different path for events in flight while these variables are + // mutated via the main thread. + std::atomic needs_low_latency_ = false; + std::atomic needs_unbuffered_input_for_debugger_ = false; + std::atomic needs_low_latency_until_pointer_up_ = false; + // Contains data to be shared between main thread and compositor thread. struct SharedState { SharedState(); diff --git a/blink/renderer/platform/widget/input/software_compositor_proxy_ohos.cc b/blink/renderer/platform/widget/input/software_compositor_proxy_ohos.cc index 406ded9172d46abe82bae8e0bd35947e2d4f11c7..e55e9f02a394b9e5a6efbf741df765236fe865b8 100644 --- a/blink/renderer/platform/widget/input/software_compositor_proxy_ohos.cc +++ b/blink/renderer/platform/widget/input/software_compositor_proxy_ohos.cc @@ -84,6 +84,7 @@ void SoftwareCompositorProxyOhos::DrawRect(const gfx::Rect& rect) LOG(DEBUG) << "DrawRect in blink"; if (!software_render_) { LOG(ERROR) << "software render init error"; + return; } software_render_->DrawRect(rect); } diff --git a/blink/renderer/platform/widget/input/widget_base_input_handler.cc b/blink/renderer/platform/widget/input/widget_base_input_handler.cc index e20ce5e81387d25758951ce98803f9f791896900..f8138bd92c71fcb1ccaa5b0a87e9b03e045e5740 100644 --- a/blink/renderer/platform/widget/input/widget_base_input_handler.cc +++ b/blink/renderer/platform/widget/input/widget_base_input_handler.cc @@ -309,7 +309,7 @@ void WidgetBaseInputHandler::HandleInputEvent( weak_ptr_factory_.GetWeakPtr(); HandlingState handling_state(weak_self, IsTouchStartOrMove(input_event)); -#if BUILDFLAG(IS_ANDROID) +#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) ImeEventGuard guard(widget_->GetWeakPtr()); #endif diff --git a/blink/renderer/platform/widget/widget_base.cc b/blink/renderer/platform/widget/widget_base.cc index 4b6803ebd29e9043291958a138c830f9a061fd6b..1bf7b92eb407972bb41ea05d692af6e0443f1176 100644 --- a/blink/renderer/platform/widget/widget_base.cc +++ b/blink/renderer/platform/widget/widget_base.cc @@ -1579,7 +1579,7 @@ void WidgetBase::OnImeEventGuardFinish(ImeEventGuard* guard) { // are ignored. These must explicitly be updated once finished handling the // ime event. UpdateSelectionBounds(); -#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS) +#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS) || BUILDFLAG(IS_OHOS) if (guard->show_virtual_keyboard()) ShowVirtualKeyboard(); else diff --git a/blink/renderer/platform/wtf/text/string_view.h b/blink/renderer/platform/wtf/text/string_view.h index d2b9b261e7bd814acab0da78d3018ead426e0d1b..9a6f403c3af94891d8b8582114bd3acd7e711050 100644 --- a/blink/renderer/platform/wtf/text/string_view.h +++ b/blink/renderer/platform/wtf/text/string_view.h @@ -271,7 +271,8 @@ inline StringView::StringView(const StringView& view, unsigned offset, unsigned length) : impl_(view.impl_), length_(length) { - SECURITY_DCHECK(offset + length <= view.length()); + SECURITY_DCHECK(offset <= view.length()); + SECURITY_DCHECK(length <= view.length() - offset); if (Is8Bit()) bytes_ = view.Characters8() + offset; else @@ -317,7 +318,8 @@ inline void StringView::Clear() { inline void StringView::Set(const StringImpl& impl, unsigned offset, unsigned length) { - SECURITY_DCHECK(offset + length <= impl.length()); + SECURITY_DCHECK(offset <= impl.length()); + SECURITY_DCHECK(length <= impl.length() - offset); length_ = length; impl_ = const_cast(&impl); if (impl.Is8Bit()) diff --git a/blink/renderer/platform/wtf/text/string_view_test.cc b/blink/renderer/platform/wtf/text/string_view_test.cc index d8eb2afaa2ecb8a1fd0fbcc04c4c9b8b3b6cb821..efadac6e98a05ede6270d576dfcdb78dab196431 100644 --- a/blink/renderer/platform/wtf/text/string_view_test.cc +++ b/blink/renderer/platform/wtf/text/string_view_test.cc @@ -374,6 +374,16 @@ TEST(StringViewTest, ConstructionLiteral16) { EXPECT_EQ(String("12"), StringView(kChars16, 2u)); } +#if ENABLE_SECURITY_ASSERT +TEST(StringViewTest, OverflowInConstructor) { + EXPECT_DEATH_IF_SUPPORTED(StringView(StringView("12"), 2, -1), ""); +} + +TEST(StringViewTest, OverflowInSet) { + EXPECT_DEATH_IF_SUPPORTED(StringView(String("12"), 2, -1), ""); +} +#endif // ENABLE_SECURITY_ASSERT + TEST(StringViewTest, IsEmpty) { EXPECT_FALSE(StringView(kChars).empty()); EXPECT_TRUE(StringView(kChars, 0).empty()); diff --git a/blink/tools/blinkpy/presubmit/audit_non_blink_usage.py b/blink/tools/blinkpy/presubmit/audit_non_blink_usage.py index 569a2e9dcc37aaad1368d2daa742775ce12ecdd9..7197616a7be18333d51c61a256f1d712a52b8256 100755 --- a/blink/tools/blinkpy/presubmit/audit_non_blink_usage.py +++ b/blink/tools/blinkpy/presubmit/audit_non_blink_usage.py @@ -68,6 +68,7 @@ _CONFIG = [ 'base::DefaultTickClock', 'base::ElapsedTimer', 'base::EnumSet', + 'base::HashInts', 'base::JobDelegate', 'base::JobHandle', 'base::PostJob', diff --git a/crashpad/README.chromium b/crashpad/README.chromium index 07677c3a085d99e05703a781798a56604e1581ab..ee2051e51fdcf56a047578a62a65f567811ef144 100644 --- a/crashpad/README.chromium +++ b/crashpad/README.chromium @@ -2,7 +2,7 @@ Name: Crashpad Short Name: crashpad URL: https://crashpad.chromium.org/ Version: unknown -Revision: 3a6bc8c527ede01d82d7c9bd7c08687f7a924de7 +Revision: 37afd37401253ebcebcf6e07ce15c8cfecb1a1cc License: Apache 2.0 License File: crashpad/LICENSE Security Critical: yes diff --git a/crashpad/crashpad/DEPS b/crashpad/crashpad/DEPS index 0ef3c1f4be915fab63afc6edb35c3d2454d7d787..75216e547f93fb2d820bcc57d9f16e4fdea30385 100644 --- a/crashpad/crashpad/DEPS +++ b/crashpad/crashpad/DEPS @@ -116,16 +116,6 @@ deps = { 'condition': 'checkout_fuchsia and host_os == "linux"', 'dep_type': 'cipd' }, - 'crashpad/third_party/fuchsia/sdk/mac-amd64': { - 'packages': [ - { - 'package': 'fuchsia/sdk/gn/mac-amd64', - 'version': 'latest' - }, - ], - 'condition': 'checkout_fuchsia and host_os == "mac"', - 'dep_type': 'cipd' - }, 'crashpad/third_party/fuchsia/sdk/linux-amd64': { 'packages': [ { diff --git a/crashpad/crashpad/client/crash_report_database.cc b/crashpad/crashpad/client/crash_report_database.cc index 0f5132d889f4e774124a53b64780d60b8899187e..9919de406f90324fe5374d11a84d3b7626790021 100644 --- a/crashpad/crashpad/client/crash_report_database.cc +++ b/crashpad/crashpad/client/crash_report_database.cc @@ -25,7 +25,7 @@ #if defined(OHOS_CRASHPAD) #include "third_party/crashpad/crashpad/util/linux/crashpad_dfx.h" #endif - + #if defined(OHOS_CRASHPAD) std::string g_crash_dump_path_suffix = ""; #endif diff --git a/crashpad/crashpad/client/crashpad_client_linux.cc b/crashpad/crashpad/client/crashpad_client_linux.cc index 6548f4170168dfa09e0d5c7128dbe1e39881de43..e58a3b7c73c0495515b455515b8a2775097a202f 100644 --- a/crashpad/crashpad/client/crashpad_client_linux.cc +++ b/crashpad/crashpad/client/crashpad_client_linux.cc @@ -49,11 +49,10 @@ #include "util/posix/signals.h" #include "util/posix/spawn_subprocess.h" - #if defined(OHOS_CRASHPAD) #include "third_party/crashpad/crashpad/util/linux/crashpad_dfx.h" #endif - + #if defined(OHOS_CRASHPAD) std::string g_happen_time = ""; std::string g_bundle_name = ""; @@ -305,6 +304,7 @@ class LaunchAtCrashHandler : public SignalHandler { argv_strings_.push_back(FormatArgumentAddress("trace-parent-with-exception", &GetExceptionInfo())); + StringVectorToCStringVector(argv_strings_, &argv_); return Install(unhandled_signals); } @@ -313,7 +313,8 @@ class LaunchAtCrashHandler : public SignalHandler { #if defined(OHOS_CRASHPAD) ScopedPrSetPtracer set_ptracer(sys_getpid(), /* may_log= */ false); const std::string process_type = "browser"; - const std::string package_name = CrashpadDfx::GetProcessBundleName(); + const std::string error_reason = "browser exited"; + const std::string bundle_name = CrashpadDfx::GetProcessBundleName(); #endif pid_t pid = fork(); if (pid < 0) { @@ -342,7 +343,7 @@ class LaunchAtCrashHandler : public SignalHandler { waitpid(pid, &status, 0); #if defined(OHOS_CRASHPAD) #if defined(REPORT_SYS_EVENT) - CrashpadDfx::ReportProcessCrash(process_type,g_happen_time,package_name); + CrashpadDfx::ProcessCrashReport(process_type, g_happen_time, bundle_name, error_reason); #endif // defined(REPORT_SYS_EVENT) LOG(INFO) << "crashpad LaunchAtCrashHandler::HandleCrashImpl, parent process wait child process exit, status = " \ << status << ", child process pid = " << pid; diff --git a/crashpad/crashpad/handler/linux/exception_handler_server.cc b/crashpad/crashpad/handler/linux/exception_handler_server.cc index bc595b855694ebd48f6f6c8bf997f0da33ec350f..754604140bce0becf3914b05f597423d572cbf44 100644 --- a/crashpad/crashpad/handler/linux/exception_handler_server.cc +++ b/crashpad/crashpad/handler/linux/exception_handler_server.cc @@ -39,12 +39,13 @@ #if defined(OHOS_CRASHPAD) #include "third_party/crashpad/crashpad/util/linux/crashpad_dfx.h" #endif - + #if defined(OHOS_CRASHPAD) uid_t g_process_uid = 0; extern std::string g_happen_time; extern std::string g_bundle_name; #endif + namespace crashpad { namespace { @@ -551,10 +552,9 @@ bool ExceptionHandlerServer::HandleCrashDumpRequest( #if defined(OHOS_CRASHPAD) const std::string process_type = "render"; - const std::string package_name = g_bundle_name; - const std::string happen_time = g_happen_time; + const std::string error_reason = "render exited"; #if defined(REPORT_SYS_EVENT) - CrashpadDfx::ReportProcessCrash(process_type,happen_time,package_name); + CrashpadDfx::ProcessCrashReport(process_type, g_happen_time, g_bundle_name, error_reason); #endif #endif return SendMessageToClient( diff --git a/crashpad/crashpad/snapshot/sanitized/module_snapshot_sanitized.cc b/crashpad/crashpad/snapshot/sanitized/module_snapshot_sanitized.cc index 192b4cb10add6e3aaa70b96b86bc8ae90b90a070..476ebe019eee87d76a8bceaa885dc58f01c6af62 100644 --- a/crashpad/crashpad/snapshot/sanitized/module_snapshot_sanitized.cc +++ b/crashpad/crashpad/snapshot/sanitized/module_snapshot_sanitized.cc @@ -97,9 +97,11 @@ ModuleSnapshotSanitized::AnnotationsSimpleMap() const { std::map annotations = snapshot_->AnnotationsSimpleMap(); if (allowed_annotations_) { - for (auto kv = annotations.begin(); kv != annotations.end(); ++kv) { - if (!KeyIsAllowed(kv->first, *allowed_annotations_)) { - annotations.erase(kv); + for (auto kv = annotations.begin(); kv != annotations.end();) { + if (KeyIsAllowed(kv->first, *allowed_annotations_)) { + ++kv; + } else { + kv = annotations.erase(kv); } } } diff --git a/crashpad/crashpad/util/linux/crashpad_dfx.cc b/crashpad/crashpad/util/linux/crashpad_dfx.cc index 4b5c840ccbb07efe9d9e671f207b6b30de9832c8..8f6eab0e9fb0691d328e118135b597821958770d 100644 --- a/crashpad/crashpad/util/linux/crashpad_dfx.cc +++ b/crashpad/crashpad/util/linux/crashpad_dfx.cc @@ -21,7 +21,7 @@ #include #include #include - + #include #include #include @@ -40,10 +40,11 @@ #include "third_party/ohos_ndk/includes/ohos_adapter/ohos_adapter_helper.h" // For process crash constants -constexpr char PACKAGE_NAME[] = "PACKAGE_NAME"; +constexpr char BUNDLE_NAME[] = "BUNDLE_NAME"; constexpr char PROCESS_CRASH[] = "PROCESS_CRASH"; constexpr char PROCESS_TYPE[] = "PROCESS_TYPE"; constexpr char CRASH_COUNT[] = "CRASH_COUNT"; +constexpr char ERROR_REASON[] = "ERROR_REASON"; // For process crash log constants constexpr char UID[] = "UID"; @@ -102,19 +103,19 @@ std::string CrashpadDfx::GetBuildId(const uint64_t noteAddr,const uint64_t noteS memcpy(&nhdr, reinterpret_cast(noteAddr + offset), sizeof(nhdr)); LOG(DEBUG) << "Note header read at offset " << offset << ": namesz=" << nhdr.n_namesz << ", descsz=" << nhdr.n_descsz << ", type=" << nhdr.n_type; offset += sizeof(nhdr); - + if (noteSize - offset < nhdr.n_namesz) { LOG(ERROR) << "Insufficient space for reading note name at offset " << offset; return ""; } - + std::string name(nhdr.n_namesz, '\0'); memcpy(&(name[0]), reinterpret_cast(noteAddr + offset), nhdr.n_namesz); if (name.back() == '\0') { name.resize(name.size() - 1); // Trim trailing '\0' } offset += (nhdr.n_namesz + 3) & ~3; // Align to 4 bytes - + if (name == "GNU" && nhdr.n_type == NT_GNU_BUILD_ID) { if (noteSize - offset < nhdr.n_descsz || nhdr.n_descsz == 0) { LOG(ERROR) << "Insufficient space for reading build ID at offset " << offset; @@ -122,7 +123,7 @@ std::string CrashpadDfx::GetBuildId(const uint64_t noteAddr,const uint64_t noteS } std::string buildIdRaw(nhdr.n_descsz, '\0'); memcpy(&buildIdRaw[0], reinterpret_cast(noteAddr + offset), nhdr.n_descsz); - + std::string buildIdHex; for (unsigned char c : buildIdRaw) { char hex[3]; @@ -163,7 +164,7 @@ std::string CrashpadDfx::GetBuildIdFromSO(const std::string& soFilePath) { Elf64_Ehdr* ehdr = reinterpret_cast(mapped); Elf64_Shdr* shdrs = reinterpret_cast(reinterpret_cast(mapped) + ehdr->e_shoff); - + std::string buildId; for (int i = 0; i < ehdr->e_shnum; ++i) { Elf64_Shdr& shdr = shdrs[i]; @@ -179,10 +180,10 @@ std::string CrashpadDfx::GetBuildIdFromSO(const std::string& soFilePath) { if (buildId.empty()) { LOG(WARNING) << "No Build ID found in the file."; } - + munmap(mapped, stat_buf.st_size); close(fd); - + return buildId; } @@ -219,7 +220,7 @@ std::string CrashpadDfx::GetProcessBundleName() { LOG(ERROR) << "CommandLine object is null. Cannot retrieve bundle name."; return ""; } - + if (command_line->HasSwitch("bundle-name")) { std::string bundle_name = command_line->GetSwitchValueASCII("bundle-name"); if (bundle_name.empty()) { @@ -233,19 +234,21 @@ std::string CrashpadDfx::GetProcessBundleName() { } } -void CrashpadDfx::ReportProcessCrash(const std::string process_type, +void CrashpadDfx::ProcessCrashReport(const std::string process_type, const std::string happen_time, - const std::string package_name) { + const std::string bundle_name, + const std::string error_reason) { const std::string build_id = RetrieveBuildId(); uid_t uid = GetEffectiveProcessUID(); const std::string user_id = std::to_string(getuid()/200000);; const std::string crash_count = std::to_string(GetAndUpdateRenderProcessCrashCount(process_type)); - + OHOS::NWeb::OhosAdapterHelper::GetInstance().GetHiSysEventAdapterInstance().Write( PROCESS_CRASH, OHOS::NWeb::HiSysEventAdapter::EventType::FAULT, { - PACKAGE_NAME,package_name, + BUNDLE_NAME,bundle_name, PROCESS_TYPE,process_type, + ERROR_REASON,error_reason, CRASH_COUNT,crash_count, UID,std::to_string(uid), BUILDID,build_id, diff --git a/crashpad/crashpad/util/linux/crashpad_dfx.h b/crashpad/crashpad/util/linux/crashpad_dfx.h index 00f57f4b174d3c41d5eda5e0b43b6f34ba361fce..728a9884439b9bdaf4e708abe470c51c52838783 100644 --- a/crashpad/crashpad/util/linux/crashpad_dfx.h +++ b/crashpad/crashpad/util/linux/crashpad_dfx.h @@ -15,12 +15,12 @@ #if defined(OHOS_CRASHPAD) #include #include - + #include #include #include #include - + #include "base/files/file_path.h" #include "util/file/file_io.h" #include "util/file/file_reader.h" @@ -28,16 +28,17 @@ #include "util/file/scoped_remove_file.h" #include "util/misc/metrics.h" #include "util/misc/uuid.h" - + namespace crashpad { - + class CrashpadDfx { - + public: - - static void ReportProcessCrash(const std::string process_type, + + static void ProcessCrashReport(const std::string process_type, const std::string happen_time, - const std::string package_name); + const std::string bundle_name, + const std::string error_reason); static std::string GetProcessBundleName(); static std::string GetCurrentTime(); static std::string UpdateCrashDumpPathSuffix(); diff --git a/crashpad/crashpad/util/linux/crashpad_dfx_elf_define.h b/crashpad/crashpad/util/linux/crashpad_dfx_elf_define.h index 6ad7697536cac7dac71f5ff56ce73917cab62316..273a564a81c3e8aa409ae7ed4f94d2fea3f13433 100644 --- a/crashpad/crashpad/util/linux/crashpad_dfx_elf_define.h +++ b/crashpad/crashpad/util/linux/crashpad_dfx_elf_define.h @@ -13,14 +13,14 @@ * limitations under the License. */ #if defined(OHOS_CRASHPAD) - + #include #include #if !is_mingw #include #include #endif - + namespace crashpad_dfx { static const std::string NOTE_GNU_BUILD_ID = ".note.gnu.build-id"; static const std::string NOTES = ".notes"; @@ -35,7 +35,7 @@ static const std::string SYMTAB = ".symtab"; static const std::string DYNSYM = ".dynsym"; static const std::string DYNSTR = ".dynstr"; static const std::string PLT = ".plt"; - + struct ElfLoadInfo { uint64_t offset = 0; uint64_t tableVaddr = 0; @@ -43,7 +43,7 @@ struct ElfLoadInfo { uint64_t align = 0; uint64_t mmapLen = 0; }; - + struct ElfSymbol { std::string nameStr = ""; uint32_t name = 0; @@ -53,7 +53,7 @@ struct ElfSymbol { uint64_t value = 0; uint64_t size = 0; }; - + struct ElfShdr { uint32_t name = 0; // Section name (string tbl index) uint32_t type = 0; // Section type @@ -66,14 +66,14 @@ struct ElfShdr { uint64_t addrAlign = 0; // Section alignment uint64_t entSize = 0; // Entry size if section holds table }; - + struct ShdrInfo { uint64_t addr = 0; uint64_t entSize = 0; uint64_t offset = 0; uint64_t size = 0; }; - + struct __attribute__((packed)) DwarfEhFrameHdr { unsigned char version = 0; unsigned char ehFramePtrEnc = 0; @@ -81,11 +81,11 @@ struct __attribute__((packed)) DwarfEhFrameHdr { unsigned char tableEnc = 0; ElfW(Addr) ehFrame; }; - + struct MiniDebugInfo { uint64_t offset = 0; uintptr_t size = 0; }; - + } // namespace crashpad_dfx -#endif +#endif \ No newline at end of file diff --git a/crashpad/crashpad/util/linux/exception_handler_client.cc b/crashpad/crashpad/util/linux/exception_handler_client.cc index 179f81409878e2e782440f302439612e77004925..a16da9f73c78cad825d79fdc8d012d30a0b8eba7 100644 --- a/crashpad/crashpad/util/linux/exception_handler_client.cc +++ b/crashpad/crashpad/util/linux/exception_handler_client.cc @@ -29,9 +29,6 @@ #include "util/linux/socket.h" #include "util/misc/from_pointer_cast.h" #include "util/posix/signals.h" -#if defined(OHOS_CRASHPAD) -#include "base/process/process_handle.h" -#endif #if BUILDFLAG(IS_ANDROID) #include @@ -156,7 +153,7 @@ int ExceptionHandlerClient::SendCrashDumpRequest( message.requesting_thread_stack_address = stack_pointer; message.client_info = info; #if defined(OHOS_CRASHPAD) - message.real_pid = base::GetCurrentRealPid(); + message.real_pid = getprocpid(); #endif // defined(OHOS_CRASHPAD) return UnixCredentialSocket::SendMsg(server_sock_, &message, sizeof(message)); } @@ -171,7 +168,7 @@ int ExceptionHandlerClient::WaitForCrashDumpComplete() { switch (message.type) { case ExceptionHandlerProtocol::ServerToClientMessage::kTypeForkBroker: { #if defined(OHOS_CRASHPAD) - pid_t real_pid = base::GetCurrentRealPid(); + pid_t real_pid = getprocpid(); LOG(INFO) << "crashpad ExceptionHandlerClient::WaitForCrashDumpComplete" \ ", received message.type = kTypeForkBroker, use broker process to dump, real pid = " << real_pid; #endif diff --git a/freetype/BUILD.gn b/freetype/BUILD.gn index 903d2662e3636fb38b68b032d4179f9a287561d0..fd09d4323cfeb6dc4a08b64aa8fd7d8a78846ed0 100644 --- a/freetype/BUILD.gn +++ b/freetype/BUILD.gn @@ -24,7 +24,7 @@ config("freetype_component_config") { "FT_CONFIG_OPTIONS_H=\"freetype-custom/freetype/config/ftoption.h\"", ] - if (!is_android) { + if (!is_android && !is_ohos) { # Selects type1cid.c and type1.c modules in # freetype-custom-include/freetype/config/ftmodule.h. defines += [ "PDFIUM_REQUIRED_MODULES" ] @@ -123,7 +123,7 @@ source_set("freetype_source") { sources += [ "src/src/base/ftsystem.c" ] } - if (!is_android) { + if (!is_android && !is_ohos) { sources += [ "src/src/base/ftcid.c", "src/src/cid/type1cid.c", diff --git a/hunspell/google/bdict_reader.cc b/hunspell/google/bdict_reader.cc index d51112ea48e7358866ffd5db86074e6b03182962..56abd15dd1217c4d7f7f4455035da874560fa74d 100644 --- a/hunspell/google/bdict_reader.cc +++ b/hunspell/google/bdict_reader.cc @@ -5,6 +5,7 @@ #include "third_party/hunspell/google/bdict_reader.h" #include +#include #include "base/check.h" @@ -413,19 +414,32 @@ NodeReader::FindResult NodeReader::ReaderForLookupAt( if (index >= static_cast(lookup_num_chars()) || !is_valid_) return FIND_DONE; - size_t child_offset; + size_t child_offset = 0; if (is_lookup_32()) { // Table contains 32-bit absolute offsets. - child_offset = - reinterpret_cast(table_begin)[index]; + + // We need to use memcpy here instead of just casting the offset into a + // pointer to an int because the cast can cause undefined behavior if + // the pointer is not alligned, and in this case it is not. + int byte_offset = index * sizeof(uint32_t); + std::memcpy(&child_offset, + reinterpret_cast(table_begin + byte_offset), + sizeof(uint32_t)); if (!child_offset) return FIND_NOTHING; // This entry in the table is empty. } else { // Table contains 16-bit offsets relative to the current node. - child_offset = - reinterpret_cast(table_begin)[index]; - if (!child_offset) + + // We need to use memcpy here instead of just casting the offset into a + // pointer to an int because the cast can cause undefined behavior if + // the pointer is not alligned, and in this case it is not. + int byte_offset = index * sizeof(uint16_t); + std::memcpy(&child_offset, + reinterpret_cast(table_begin + byte_offset), + sizeof(uint16_t)); + if (!child_offset) { return FIND_NOTHING; // This entry in the table is empty. + } child_offset += node_offset_; } diff --git a/libvpx/BUILD.gn b/libvpx/BUILD.gn old mode 100644 new mode 100755 index c5aad48a48d6b6cb5b3e08ffd579c959bda782d6..2e8688da24090582162d22706c294d33233e995c --- a/libvpx/BUILD.gn +++ b/libvpx/BUILD.gn @@ -5,7 +5,7 @@ import("//build/config/android/config.gni") import("//build/config/arm.gni") import("//build/config/chromeos/ui_mode.gni") -import("//build/config/sanitizers/sanitizers.gni") +import("//testing/test.gni") import("//third_party/libvpx/libvpx_srcs.gni") import("//third_party/nasm/nasm_assemble.gni") @@ -30,7 +30,10 @@ if (current_cpu == "x86") { cpu_arch_full = "arm" } } else if (current_cpu == "arm64") { - if (is_chromeos || is_mac) { + if (is_win || is_chromeos || is_mac) { + # This is necessary for CrOS and macOS as they reuse the Linux + # configuration, of which there are two (see the later definition of + # os_category). cpu_arch_full = "arm64-highbd" } else { cpu_arch_full = current_cpu @@ -67,6 +70,7 @@ libvpx_include_dirs = [ "source/libvpx", ] +# Private configuration used in building libvpx. config("libvpx_config") { include_dirs = libvpx_include_dirs @@ -93,8 +97,47 @@ config("libvpx_config") { } # This config is applied to targets that depend on libvpx. -config("libvpx_external_config") { - include_dirs = [ "source/libvpx" ] +config("libvpx_public_config") { + include_dirs = [ + "source/libvpx", + platform_include_dir, + ] +} + +executable("decode_encode_profile_test") { + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ "//build/config/compiler:no_chromium_code" ] + include_dirs = libvpx_include_dirs + [ + "source/libvpx/third_party/libwebm/", + "source/libvpx/third_party/googletest/src/include/", + "source/libvpx/third_party/googletest/src/", + ] + + testonly = true + sources = [ + "source/libvpx/test/decode_test_driver.cc", + "source/libvpx/test/encode_test_driver.cc", + "source/libvpx/test/init_vpx_test.cc", + "source/libvpx/test/test_libvpx.cc", + "source/libvpx/test/test_vectors.cc", + "source/libvpx/test/test_vectors.h", + "source/libvpx/third_party/googletest/src/src/gtest-all.cc", + "source/libvpx/third_party/libwebm/mkvparser/mkvparser.cc", + "source/libvpx/third_party/libwebm/mkvparser/mkvreader.cc", + "source/libvpx/tools_common.h", + "source/libvpx/webmdec.cc", + "source/libvpx/y4minput.c", + "tests/pgo/decode_encode_profile_test.cc", + ] + deps = [ ":libvpx" ] + + # gtest-death-test dependency on fdio for fuchsia builds + if (is_fuchsia) { + deps += [ + "//third_party/fuchsia-sdk/sdk/pkg/fdio", + "//third_party/fuchsia-sdk/sdk/pkg/zx", + ] + } } if (current_cpu == "x86" || (current_cpu == "x64" && !is_msan)) { @@ -259,14 +302,104 @@ if (current_cpu == "loong64") { } } -if (cpu_arch_full == "arm-neon-cpu-detect") { - static_library("libvpx_intrinsics_neon") { - configs -= [ "//build/config/compiler:compiler_arm_fpu" ] +if (current_cpu == "arm" || current_cpu == "arm64") { + source_set("libvpx_intrinsics_neon") { + check_includes = false + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ "//build/config/compiler:no_chromium_code" ] + configs += [ ":libvpx_config" ] + if (current_cpu == "arm") { + configs -= [ "//build/config/compiler:compiler_arm_fpu" ] + cflags = [ "-mfpu=neon" ] + } + if (cpu_arch_full == "arm-neon") { + sources = libvpx_srcs_arm_neon_neon + deps = [ ":libvpx_arm_neon_headers" ] + } else if (cpu_arch_full == "arm-neon-highbd") { + sources = libvpx_srcs_arm_neon_highbd_neon + deps = [ ":libvpx_arm_neon_highbd_headers" ] + } else if (cpu_arch_full == "arm-neon-cpu-detect") { + sources = libvpx_srcs_arm_neon_cpu_detect_neon + deps = [ ":libvpx_arm_neon_cpu_detect_headers" ] + } else if (cpu_arch_full == "arm64") { + sources = libvpx_srcs_arm64_neon + deps = [ ":libvpx_arm64_headers" ] + } else if (cpu_arch_full == "arm64-highbd") { + sources = libvpx_srcs_arm64_highbd_neon + deps = [ ":libvpx_arm64_highbd_headers" ] + } + } +} + +if (current_cpu == "arm64") { + source_set("libvpx_intrinsics_neon_dotprod") { + check_includes = false + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ "//build/config/compiler:no_chromium_code" ] + configs += [ ":libvpx_config" ] + if (!is_win || is_clang) { + cflags = [ "-march=armv8.2-a+dotprod" ] + } + if (cpu_arch_full == "arm64") { + sources = libvpx_srcs_arm64_neon_dotprod + deps = [ ":libvpx_arm64_headers" ] + } else if (cpu_arch_full == "arm64-highbd") { + sources = libvpx_srcs_arm64_highbd_neon_dotprod + deps = [ ":libvpx_arm64_highbd_headers" ] + } + } + + source_set("libvpx_intrinsics_neon_i8mm") { + check_includes = false + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ "//build/config/compiler:no_chromium_code" ] configs += [ ":libvpx_config" ] - cflags = [ "-mfpu=neon" ] - sources = libvpx_srcs_arm_neon_cpu_detect_neon - deps = [ ":libvpx_arm_neon_cpu_detect_headers" ] + if (!is_win || is_clang) { + cflags = [ "-march=armv8.2-a+i8mm" ] + } + if (cpu_arch_full == "arm64") { + sources = libvpx_srcs_arm64_neon_i8mm + deps = [ ":libvpx_arm64_headers" ] + } else if (cpu_arch_full == "arm64-highbd") { + sources = libvpx_srcs_arm64_highbd_neon_i8mm + deps = [ ":libvpx_arm64_highbd_headers" ] + } } + + # SVE is disabled for Windows due to a limitation with clang-cl-18: + # third_party\llvm-build\Release+Asserts\lib\clang\18\include\arm_sve.h(271,1): + # error: cannot mangle this built-in __SVInt8_t type yet +# if (!is_win) { +# source_set("libvpx_intrinsics_sve") { +# check_includes = false +# configs -= [ "//build/config/compiler:chromium_code" ] +# configs += [ "//build/config/compiler:no_chromium_code" ] +# configs += [ ":libvpx_config" ] +# cflags = [ "-march=armv8.2-a+dotprod+i8mm+sve" ] +# if (cpu_arch_full == "arm64") { +# sources = libvpx_srcs_arm64_sve +# deps = [ ":libvpx_arm64_headers" ] +# } else if (cpu_arch_full == "arm64-highbd") { +# sources = libvpx_srcs_arm64_highbd_sve +# deps = [ ":libvpx_arm64_highbd_headers" ] +# } +# } +# +# source_set("libvpx_intrinsics_sve2") { +# check_includes = false +# configs -= [ "//build/config/compiler:chromium_code" ] +# configs += [ "//build/config/compiler:no_chromium_code" ] +# configs += [ ":libvpx_config" ] +# cflags = [ "-march=armv9-a+sve2" ] +# if (cpu_arch_full == "arm64") { +# sources = libvpx_srcs_arm64_sve2 +# deps = [ ":libvpx_arm64_headers" ] +# } else if (cpu_arch_full == "arm64-highbd") { +# sources = libvpx_srcs_arm64_highbd_sve2 +# deps = [ ":libvpx_arm64_highbd_headers" ] +# } +# } +# } } if (current_cpu == "arm") { @@ -443,9 +576,20 @@ static_library("libvpx") { ":libvpx_intrinsics_ssse3", ] } - if (cpu_arch_full == "arm-neon-cpu-detect") { + if (cpu_arch_full == "arm-neon-highbd" || cpu_arch_full == "arm-neon" || + cpu_arch_full == "arm-neon-cpu-detect" || current_cpu == "arm64") { deps += [ ":libvpx_intrinsics_neon" ] } + if (current_cpu == "arm64") { + deps += [ ":libvpx_intrinsics_neon_dotprod" ] + deps += [ ":libvpx_intrinsics_neon_i8mm" ] +# if (!is_win) { +# deps += [ +# ":libvpx_intrinsics_sve", +# ":libvpx_intrinsics_sve2", +# ] +# } + } if (is_android) { deps += [ "//third_party/android_ndk:cpu_features" ] } @@ -456,7 +600,7 @@ static_library("libvpx") { deps += [ ":libvpx_loongarch_lsx" ] } - public_configs = [ ":libvpx_external_config" ] + public_configs = [ ":libvpx_public_config" ] } static_library("libvpxrc") { @@ -478,5 +622,5 @@ static_library("libvpxrc") { configs += [ ":libvpx_config" ] public_deps = [ ":libvpx" ] - public_configs = [ ":libvpx_external_config" ] + public_configs = [ ":libvpx_public_config" ] } diff --git a/libvpx/DEPS b/libvpx/DEPS old mode 100644 new mode 100755 diff --git a/libvpx/DIR_METADATA b/libvpx/DIR_METADATA old mode 100644 new mode 100755 index 0cc7e5f4ac199baabd6ba12b7b1ffafefb2bde0f..38eefd9f71f32abc4e8e280f0b01357e1e1fd5f5 --- a/libvpx/DIR_METADATA +++ b/libvpx/DIR_METADATA @@ -1,3 +1,6 @@ monorail: { component: "Internals>Media>Video" } +buganizer_public: { + component_id: 1456526 +} diff --git a/libvpx/OWNERS b/libvpx/OWNERS old mode 100644 new mode 100755 index 3ae58b3fda9e13400d7da88833dfc8f1d0842a90..0ffe9a40657434a533dd9fbff0e3bac6f8179a63 --- a/libvpx/OWNERS +++ b/libvpx/OWNERS @@ -2,3 +2,7 @@ jzern@chromium.org jzern@google.com wtc@google.com + +# Secondary OWNERS +dalecurtis@chromium.org +eugene@chromium.org diff --git a/libvpx/README.chromium b/libvpx/README.chromium old mode 100644 new mode 100755 index 65b1576376681f185e1cbff083e99b40358c8c49..4a6d83d7f49af45378eeca39e5b584e962a2e578 --- a/libvpx/README.chromium +++ b/libvpx/README.chromium @@ -1,12 +1,12 @@ Name: libvpx URL: https://chromium.googlesource.com/webm/libvpx -Version: 0 -Date: Friday April 14 2023 -Revision: 27171320f5e36f7b18071bfa1d9616863ca1b4e8 -CPEPrefix: cpe:/a:webmproject:libvpx:1.13.0 +Version: N/A +Revision: 713e0faca06c4dfdb7e3229cb604068f789584e9 +CPEPrefix: cpe:/a:webmproject:libvpx:1.14.0 License: BSD License File: source/libvpx/LICENSE Security Critical: yes +Shipped: yes Description: Contains the sources used to compile libvpx binaries used by Google Chrome and @@ -26,17 +26,19 @@ Please follow these steps to update libvpx source code: Use the generated commit message for the roll. -2. Generate .gni and config files. +2. Generate .gni and config files: cd third_party/libvpx ./generate_gni.sh - Update 'Version' and 'CPEPrefix' in this file if necessary. + Update 'Revision' and 'CPEPrefix' in this file if necessary. 3. Amend the commit created by the first step: git commit -a --amend + Add `Bug: b:308446709` to the commit message. + 4. Upload the change to Gerrit: git cl upload @@ -58,3 +60,12 @@ Configuration for the build is taken from vpx_config.h for each platform. A tool to verify vpx_config.h and vpx_config.asm are matched. This also prints the final configuration after checking. + +The PGO (Profile-Guided Optimization) test cases located in the tests/pgo +directory require a set of test data. To download this test data, execute +the following command: + + python3 ./source/libvpx/test/android/get_files.py \ + -i tests/pgo/pgo-test-data.sha1 \ + -o ../../out/Default/ \ + -u http://downloads.webmproject.org/test_data/libvpx diff --git a/libvpx/generate_gni.sh b/libvpx/generate_gni.sh old mode 100755 new mode 100644 index 07eb4f25781a142959c3a52fca159fe184f99647..89d6033eec1c1117b41d0b74f98bec30d06648db --- a/libvpx/generate_gni.sh +++ b/libvpx/generate_gni.sh @@ -136,14 +136,13 @@ function convert_srcs_to_project_files() { local intrinsic_list=$(echo "$source_list" \ | egrep '(mmx|sse2|sse3|ssse3|sse4|avx|avx2|avx512).c$') - # Select all neon files ending in C but only when building in RTCD mode - if [[ "libvpx_srcs_arm_neon_cpu_detect" == "$2" ]]; then - # Select all arm neon files ending in _neon.c and all asm files. + if [[ "$2" =~ arm ]]; then + # Select all arm neon files ending in _neon*.c, _sve*.c and all asm files. # The asm files need to be included in the intrinsics target because # they need the -mfpu=neon flag. # the pattern may need to be updated if vpx_scale gets intrinsics local intrinsic_list=$(echo "$source_list" \ - | egrep 'neon.*(\.c|\.asm)$') + | egrep '(neon|sve).*(\.c|\.asm)$') fi # Select loongarch lsx files ending in C from source_list. @@ -194,13 +193,27 @@ function convert_srcs_to_project_files() { local c_headers=$(echo "$source_list" | egrep '\.h$') local assembly_sources=$(echo -e "$source_list\n$intrinsic_list" | \ egrep '\.asm$') - local neon_sources=$(echo "$intrinsic_list" | grep '_neon\.c$') + local neon_sources=$(echo "$intrinsic_list" | \ + grep -e '_neon\.c$' -e '_neon_asm\.c') write_gni c_sources $2 "$BASE_DIR/libvpx_srcs.gni" write_gni c_headers $2_headers "$BASE_DIR/libvpx_srcs.gni" write_gni assembly_sources $2_assembly "$BASE_DIR/libvpx_srcs.gni" if [ 0 -ne ${#neon_sources} ]; then write_gni neon_sources $2_neon "$BASE_DIR/libvpx_srcs.gni" fi + if [[ "$2" =~ arm64 ]]; then + local neon_dotprod_sources=$(echo "$intrinsic_list" | \ + grep '_neon_dotprod\.c$') + local neon_i8mm_sources=$(echo "$intrinsic_list" | \ + grep '_neon_i8mm\.c$') + local sve_sources=$(echo "$intrinsic_list" | grep '_sve\.c$') + local sve2_sources=$(echo "$intrinsic_list" | grep '_sve2\.c$') + write_gni neon_dotprod_sources $2_neon_dotprod \ + "$BASE_DIR/libvpx_srcs.gni" + write_gni neon_i8mm_sources $2_neon_i8mm "$BASE_DIR/libvpx_srcs.gni" + write_gni sve_sources $2_sve "$BASE_DIR/libvpx_srcs.gni" + write_gni sve2_sources $2_sve2 "$BASE_DIR/libvpx_srcs.gni" + fi fi fi } @@ -349,24 +362,21 @@ function gen_config_files() { } function update_readme() { - local IFS=$'\n' - # Split git log output '\n' on the newline to produce 2 - # array entries. - local vals=($(git --no-pager log -1 --format="%cd%n%H" \ - --date=format:"%A %B %d %Y")) + local revision=$(git --no-pager log -1 --format="%H") sed -E -i.bak \ - -e "s/^(Date:)[[:space:]]+.*$/\1 ${vals[0]}/" \ - -e "s/^(Revision:)[[:space:]]+[a-f0-9]{40}/\1 ${vals[1]}/" \ + -e "s/^(Revision:)[[:space:]]+[a-f0-9]{40}/\1 ${revision}/" \ ${BASE_DIR}/README.chromium rm ${BASE_DIR}/README.chromium.bak cat < /dev/null \ + || echo "ERROR: 'git cl format' failed. Please run 'git cl format' manually." diff --git a/libvpx/include/elf.h b/libvpx/include/elf.h old mode 100644 new mode 100755 diff --git a/libvpx/libvpx_srcs.gni b/libvpx/libvpx_srcs.gni old mode 100644 new mode 100755 index 1b82e5b95539132a565c4f63b39d86693ea878eb..43f578e6dfd4684a8138061be9e1d07804c9b6bc --- a/libvpx/libvpx_srcs.gni +++ b/libvpx/libvpx_srcs.gni @@ -146,6 +146,7 @@ libvpx_srcs_x86 = [ "//third_party/libvpx/source/libvpx/vpx_dsp/quantize.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sad.c", "//third_party/libvpx/source/libvpx/vpx_dsp/skin_detection.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/sse.c", "//third_party/libvpx/source/libvpx/vpx_dsp/subtract.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sum_squares.c", "//third_party/libvpx/source/libvpx/vpx_dsp/variance.c", @@ -272,6 +273,7 @@ libvpx_srcs_x86_headers = [ "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_ext_ratectrl.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_extend.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.h", + "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass_stats.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_job_queue.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_lookahead.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_mbgraph.h", @@ -310,6 +312,7 @@ libvpx_srcs_x86_headers = [ "//third_party/libvpx/source/libvpx/vpx/vpx_frame_buffer.h", "//third_party/libvpx/source/libvpx/vpx/vpx_image.h", "//third_party/libvpx/source/libvpx/vpx/vpx_integer.h", + "//third_party/libvpx/source/libvpx/vpx/vpx_tpl.h", "//third_party/libvpx/source/libvpx/vpx_dsp/bitreader.h", "//third_party/libvpx/source/libvpx/vpx_dsp/bitreader_buffer.h", "//third_party/libvpx/source/libvpx/vpx_dsp/bitwriter.h", @@ -356,7 +359,6 @@ libvpx_srcs_x86_headers = [ "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops.h", "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops_aligned.h", "//third_party/libvpx/source/libvpx/vpx_ports/mips.h", - "//third_party/libvpx/source/libvpx/vpx_ports/msvc.h", "//third_party/libvpx/source/libvpx/vpx_ports/static_assert.h", "//third_party/libvpx/source/libvpx/vpx_ports/system_state.h", "//third_party/libvpx/source/libvpx/vpx_ports/vpx_once.h", @@ -366,6 +368,7 @@ libvpx_srcs_x86_headers = [ "//third_party/libvpx/source/libvpx/vpx_scale/yv12config.h", "//third_party/libvpx/source/libvpx/vpx_util/endian_inl.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h", + "//third_party/libvpx/source/libvpx/vpx_util/vpx_pthread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h", @@ -465,23 +468,25 @@ libvpx_srcs_x86_sse4_1 = [ "//third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_idct32x32_add_sse4.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_idct4x4_add_sse4.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_idct8x8_add_sse4.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/x86/sse_sse4.c", ] -libvpx_srcs_x86_avx = [ - "//third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_diamond_search_sad_avx.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/x86/quantize_avx.c", -] +libvpx_srcs_x86_avx = + [ "//third_party/libvpx/source/libvpx/vpx_dsp/x86/quantize_avx.c" ] libvpx_srcs_x86_avx2 = [ "//third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_error_avx2.c", "//third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_quantize_avx2.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/avg_intrin_avx2.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/x86/avg_pred_avx2.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_convolve_avx2.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_quantize_intrin_avx2.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_sad4d_avx2.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_sad_avx2.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/x86/inv_txfm_avx2.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/loopfilter_avx2.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/quantize_avx2.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/sad4d_avx2.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/sad_avx2.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/x86/sse_avx2.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/subtract_avx2.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/variance_avx2.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/vpx_subpixel_8t_intrin_avx2.c", @@ -633,6 +638,7 @@ libvpx_srcs_x86_64 = [ "//third_party/libvpx/source/libvpx/vpx_dsp/quantize.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sad.c", "//third_party/libvpx/source/libvpx/vpx_dsp/skin_detection.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/sse.c", "//third_party/libvpx/source/libvpx/vpx_dsp/subtract.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sum_squares.c", "//third_party/libvpx/source/libvpx/vpx_dsp/variance.c", @@ -759,6 +765,7 @@ libvpx_srcs_x86_64_headers = [ "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_ext_ratectrl.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_extend.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.h", + "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass_stats.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_job_queue.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_lookahead.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_mbgraph.h", @@ -797,6 +804,7 @@ libvpx_srcs_x86_64_headers = [ "//third_party/libvpx/source/libvpx/vpx/vpx_frame_buffer.h", "//third_party/libvpx/source/libvpx/vpx/vpx_image.h", "//third_party/libvpx/source/libvpx/vpx/vpx_integer.h", + "//third_party/libvpx/source/libvpx/vpx/vpx_tpl.h", "//third_party/libvpx/source/libvpx/vpx_dsp/bitreader.h", "//third_party/libvpx/source/libvpx/vpx_dsp/bitreader_buffer.h", "//third_party/libvpx/source/libvpx/vpx_dsp/bitwriter.h", @@ -843,7 +851,6 @@ libvpx_srcs_x86_64_headers = [ "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops.h", "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops_aligned.h", "//third_party/libvpx/source/libvpx/vpx_ports/mips.h", - "//third_party/libvpx/source/libvpx/vpx_ports/msvc.h", "//third_party/libvpx/source/libvpx/vpx_ports/static_assert.h", "//third_party/libvpx/source/libvpx/vpx_ports/system_state.h", "//third_party/libvpx/source/libvpx/vpx_ports/vpx_once.h", @@ -853,6 +860,7 @@ libvpx_srcs_x86_64_headers = [ "//third_party/libvpx/source/libvpx/vpx_scale/yv12config.h", "//third_party/libvpx/source/libvpx/vpx_util/endian_inl.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h", + "//third_party/libvpx/source/libvpx/vpx_util/vpx_pthread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h", @@ -956,23 +964,25 @@ libvpx_srcs_x86_64_sse4_1 = [ "//third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_idct32x32_add_sse4.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_idct4x4_add_sse4.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_idct8x8_add_sse4.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/x86/sse_sse4.c", ] -libvpx_srcs_x86_64_avx = [ - "//third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_diamond_search_sad_avx.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/x86/quantize_avx.c", -] +libvpx_srcs_x86_64_avx = + [ "//third_party/libvpx/source/libvpx/vpx_dsp/x86/quantize_avx.c" ] libvpx_srcs_x86_64_avx2 = [ "//third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_error_avx2.c", "//third_party/libvpx/source/libvpx/vp9/encoder/x86/vp9_quantize_avx2.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/avg_intrin_avx2.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/x86/avg_pred_avx2.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_convolve_avx2.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_quantize_intrin_avx2.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_sad4d_avx2.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/highbd_sad_avx2.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/x86/inv_txfm_avx2.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/loopfilter_avx2.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/quantize_avx2.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/sad4d_avx2.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/sad_avx2.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/x86/sse_avx2.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/subtract_avx2.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/variance_avx2.c", "//third_party/libvpx/source/libvpx/vpx_dsp/x86/vpx_subpixel_8t_intrin_avx2.c", @@ -1122,13 +1132,14 @@ libvpx_srcs_arm = [ "//third_party/libvpx/source/libvpx/vpx_dsp/quantize.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sad.c", "//third_party/libvpx/source/libvpx/vpx_dsp/skin_detection.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/sse.c", "//third_party/libvpx/source/libvpx/vpx_dsp/subtract.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sum_squares.c", "//third_party/libvpx/source/libvpx/vpx_dsp/variance.c", "//third_party/libvpx/source/libvpx/vpx_dsp/vpx_convolve.c", "//third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp_rtcd.c", "//third_party/libvpx/source/libvpx/vpx_mem/vpx_mem.c", - "//third_party/libvpx/source/libvpx/vpx_ports/arm_cpudetect.c", + "//third_party/libvpx/source/libvpx/vpx_ports/aarch32_cpudetect.c", "//third_party/libvpx/source/libvpx/vpx_scale/generic/gen_scalers.c", "//third_party/libvpx/source/libvpx/vpx_scale/generic/vpx_scale.c", "//third_party/libvpx/source/libvpx/vpx_scale/generic/yv12config.c", @@ -1249,6 +1260,7 @@ libvpx_srcs_arm_headers = [ "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_ext_ratectrl.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_extend.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.h", + "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass_stats.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_job_queue.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_lookahead.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_mbgraph.h", @@ -1287,6 +1299,7 @@ libvpx_srcs_arm_headers = [ "//third_party/libvpx/source/libvpx/vpx/vpx_frame_buffer.h", "//third_party/libvpx/source/libvpx/vpx/vpx_image.h", "//third_party/libvpx/source/libvpx/vpx/vpx_integer.h", + "//third_party/libvpx/source/libvpx/vpx/vpx_tpl.h", "//third_party/libvpx/source/libvpx/vpx_dsp/bitreader.h", "//third_party/libvpx/source/libvpx/vpx_dsp/bitreader_buffer.h", "//third_party/libvpx/source/libvpx/vpx_dsp/bitwriter.h", @@ -1306,6 +1319,7 @@ libvpx_srcs_arm_headers = [ "//third_party/libvpx/source/libvpx/vpx_mem/include/vpx_mem_intrnl.h", "//third_party/libvpx/source/libvpx/vpx_mem/vpx_mem.h", "//third_party/libvpx/source/libvpx/vpx_ports/arm.h", + "//third_party/libvpx/source/libvpx/vpx_ports/arm_cpudetect.h", "//third_party/libvpx/source/libvpx/vpx_ports/bitops.h", "//third_party/libvpx/source/libvpx/vpx_ports/compiler_attributes.h", "//third_party/libvpx/source/libvpx/vpx_ports/emmintrin_compat.h", @@ -1314,7 +1328,6 @@ libvpx_srcs_arm_headers = [ "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops.h", "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops_aligned.h", "//third_party/libvpx/source/libvpx/vpx_ports/mips.h", - "//third_party/libvpx/source/libvpx/vpx_ports/msvc.h", "//third_party/libvpx/source/libvpx/vpx_ports/static_assert.h", "//third_party/libvpx/source/libvpx/vpx_ports/system_state.h", "//third_party/libvpx/source/libvpx/vpx_ports/vpx_once.h", @@ -1324,6 +1337,7 @@ libvpx_srcs_arm_headers = [ "//third_party/libvpx/source/libvpx/vpx_scale/yv12config.h", "//third_party/libvpx/source/libvpx/vpx_util/endian_inl.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h", + "//third_party/libvpx/source/libvpx/vpx_util/vpx_pthread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h", @@ -1332,19 +1346,6 @@ libvpx_srcs_arm_assembly = [] libvpx_srcs_arm_neon = [ "//third_party/libvpx/source/libvpx/vp8/common/alloccommon.c", "//third_party/libvpx/source/libvpx/vp8/common/arm/loopfilter_arm.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/bilinearpredict_neon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/copymem_neon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/dc_only_idct_add_neon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/dequant_idct_neon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/dequantizeb_neon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/idct_blk_neon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/iwalsh_neon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/loopfiltersimplehorizontaledge_neon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/loopfiltersimpleverticaledge_neon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/mbloopfilter_neon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/shortidct4x4llm_neon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/sixtappredict_neon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/vp8_loopfilter_neon.c", "//third_party/libvpx/source/libvpx/vp8/common/blockd.c", "//third_party/libvpx/source/libvpx/vp8/common/dequantize.c", "//third_party/libvpx/source/libvpx/vp8/common/entropy.c", @@ -1377,10 +1378,6 @@ libvpx_srcs_arm_neon = [ "//third_party/libvpx/source/libvpx/vp8/decoder/detokenize.c", "//third_party/libvpx/source/libvpx/vp8/decoder/onyxd_if.c", "//third_party/libvpx/source/libvpx/vp8/decoder/threading.c", - "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/denoising_neon.c", - "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/fastquantizeb_neon.c", - "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/shortfdct_neon.c", - "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/vp8_shortwalsh4x4_neon.c", "//third_party/libvpx/source/libvpx/vp8/encoder/bitstream.c", "//third_party/libvpx/source/libvpx/vp8/encoder/boolhuff.c", "//third_party/libvpx/source/libvpx/vp8/encoder/copy_c.c", @@ -1406,9 +1403,6 @@ libvpx_srcs_arm_neon = [ "//third_party/libvpx/source/libvpx/vp8/encoder/vp8_quantize.c", "//third_party/libvpx/source/libvpx/vp8/vp8_cx_iface.c", "//third_party/libvpx/source/libvpx/vp8/vp8_dx_iface.c", - "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht16x16_add_neon.c", - "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht4x4_add_neon.c", - "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht8x8_add_neon.c", "//third_party/libvpx/source/libvpx/vp9/common/vp9_alloccommon.c", "//third_party/libvpx/source/libvpx/vp9/common/vp9_blockd.c", "//third_party/libvpx/source/libvpx/vp9/common/vp9_common_data.c", @@ -1438,12 +1432,6 @@ libvpx_srcs_arm_neon = [ "//third_party/libvpx/source/libvpx/vp9/decoder/vp9_detokenize.c", "//third_party/libvpx/source/libvpx/vp9/decoder/vp9_dsubexp.c", "//third_party/libvpx/source/libvpx/vp9/decoder/vp9_job_queue.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_dct_neon.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_denoiser_neon.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_diamond_search_sad_neon.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_error_neon.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_frame_scale_neon.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_quantize_neon.c", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.c", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_context_tree.c", @@ -1485,34 +1473,6 @@ libvpx_srcs_arm_neon = [ "//third_party/libvpx/source/libvpx/vpx/src/vpx_encoder.c", "//third_party/libvpx/source/libvpx/vpx/src/vpx_image.c", "//third_party/libvpx/source/libvpx/vpx_dsp/add_noise.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/avg_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/avg_pred_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/deblock_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct16x16_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct32x32_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct4x4_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct8x8_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct_partial_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/hadamard_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct16x16_1_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct16x16_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_135_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_1_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_34_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct8x8_1_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct8x8_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/intrapred_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/quantize_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sad4d_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sad_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/subpel_variance_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/subtract_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sum_squares_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/variance_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_neon_asm.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_scaled_convolve8_neon.c", "//third_party/libvpx/source/libvpx/vpx_dsp/avg.c", "//third_party/libvpx/source/libvpx/vpx_dsp/bitreader.c", "//third_party/libvpx/source/libvpx/vpx_dsp/bitreader_buffer.c", @@ -1528,13 +1488,14 @@ libvpx_srcs_arm_neon = [ "//third_party/libvpx/source/libvpx/vpx_dsp/quantize.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sad.c", "//third_party/libvpx/source/libvpx/vpx_dsp/skin_detection.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/sse.c", "//third_party/libvpx/source/libvpx/vpx_dsp/subtract.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sum_squares.c", "//third_party/libvpx/source/libvpx/vpx_dsp/variance.c", "//third_party/libvpx/source/libvpx/vpx_dsp/vpx_convolve.c", "//third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp_rtcd.c", "//third_party/libvpx/source/libvpx/vpx_mem/vpx_mem.c", - "//third_party/libvpx/source/libvpx/vpx_ports/arm_cpudetect.c", + "//third_party/libvpx/source/libvpx/vpx_ports/aarch32_cpudetect.c", "//third_party/libvpx/source/libvpx/vpx_scale/generic/gen_scalers.c", "//third_party/libvpx/source/libvpx/vpx_scale/generic/vpx_scale.c", "//third_party/libvpx/source/libvpx/vpx_scale/generic/yv12config.c", @@ -1657,6 +1618,7 @@ libvpx_srcs_arm_neon_headers = [ "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_ext_ratectrl.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_extend.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.h", + "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass_stats.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_job_queue.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_lookahead.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_mbgraph.h", @@ -1695,6 +1657,7 @@ libvpx_srcs_arm_neon_headers = [ "//third_party/libvpx/source/libvpx/vpx/vpx_frame_buffer.h", "//third_party/libvpx/source/libvpx/vpx/vpx_image.h", "//third_party/libvpx/source/libvpx/vpx/vpx_integer.h", + "//third_party/libvpx/source/libvpx/vpx/vpx_tpl.h", "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct_neon.h", "//third_party/libvpx/source/libvpx/vpx_dsp/arm/mem_neon.h", "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sum_neon.h", @@ -1720,6 +1683,7 @@ libvpx_srcs_arm_neon_headers = [ "//third_party/libvpx/source/libvpx/vpx_mem/include/vpx_mem_intrnl.h", "//third_party/libvpx/source/libvpx/vpx_mem/vpx_mem.h", "//third_party/libvpx/source/libvpx/vpx_ports/arm.h", + "//third_party/libvpx/source/libvpx/vpx_ports/arm_cpudetect.h", "//third_party/libvpx/source/libvpx/vpx_ports/bitops.h", "//third_party/libvpx/source/libvpx/vpx_ports/compiler_attributes.h", "//third_party/libvpx/source/libvpx/vpx_ports/emmintrin_compat.h", @@ -1728,7 +1692,6 @@ libvpx_srcs_arm_neon_headers = [ "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops.h", "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops_aligned.h", "//third_party/libvpx/source/libvpx/vpx_ports/mips.h", - "//third_party/libvpx/source/libvpx/vpx_ports/msvc.h", "//third_party/libvpx/source/libvpx/vpx_ports/static_assert.h", "//third_party/libvpx/source/libvpx/vpx_ports/system_state.h", "//third_party/libvpx/source/libvpx/vpx_ports/vpx_once.h", @@ -1738,6 +1701,7 @@ libvpx_srcs_arm_neon_headers = [ "//third_party/libvpx/source/libvpx/vpx_scale/yv12config.h", "//third_party/libvpx/source/libvpx/vpx_util/endian_inl.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h", + "//third_party/libvpx/source/libvpx/vpx_util/vpx_pthread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h", @@ -1762,6 +1726,63 @@ libvpx_srcs_arm_neon_assembly = [ "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_avg_neon_asm.asm", "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_copy_neon_asm.asm", ] +libvpx_srcs_arm_neon_neon = [ + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/bilinearpredict_neon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/copymem_neon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/dc_only_idct_add_neon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/dequant_idct_neon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/dequantizeb_neon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/idct_blk_neon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/iwalsh_neon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/loopfiltersimplehorizontaledge_neon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/loopfiltersimpleverticaledge_neon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/mbloopfilter_neon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/shortidct4x4llm_neon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/sixtappredict_neon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/vp8_loopfilter_neon.c", + "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/denoising_neon.c", + "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/fastquantizeb_neon.c", + "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/shortfdct_neon.c", + "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/vp8_shortwalsh4x4_neon.c", + "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht16x16_add_neon.c", + "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht4x4_add_neon.c", + "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht8x8_add_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_dct_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_denoiser_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_diamond_search_sad_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_error_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_frame_scale_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_quantize_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/avg_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/avg_pred_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/deblock_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct16x16_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct32x32_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct4x4_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct8x8_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct_partial_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/hadamard_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct16x16_1_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct16x16_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_135_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_1_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_34_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct8x8_1_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct8x8_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/intrapred_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/quantize_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sad4d_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sad_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sse_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/subpel_variance_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/subtract_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sum_squares_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/variance_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_neon_asm.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_scaled_convolve8_neon.c", +] libvpx_srcs_arm_neon_cpu_detect = [ "//third_party/libvpx/source/libvpx/vp8/common/alloccommon.c", "//third_party/libvpx/source/libvpx/vp8/common/arm/loopfilter_arm.c", @@ -1907,13 +1928,14 @@ libvpx_srcs_arm_neon_cpu_detect = [ "//third_party/libvpx/source/libvpx/vpx_dsp/quantize.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sad.c", "//third_party/libvpx/source/libvpx/vpx_dsp/skin_detection.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/sse.c", "//third_party/libvpx/source/libvpx/vpx_dsp/subtract.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sum_squares.c", "//third_party/libvpx/source/libvpx/vpx_dsp/variance.c", "//third_party/libvpx/source/libvpx/vpx_dsp/vpx_convolve.c", "//third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp_rtcd.c", "//third_party/libvpx/source/libvpx/vpx_mem/vpx_mem.c", - "//third_party/libvpx/source/libvpx/vpx_ports/arm_cpudetect.c", + "//third_party/libvpx/source/libvpx/vpx_ports/aarch32_cpudetect.c", "//third_party/libvpx/source/libvpx/vpx_scale/generic/gen_scalers.c", "//third_party/libvpx/source/libvpx/vpx_scale/generic/vpx_scale.c", "//third_party/libvpx/source/libvpx/vpx_scale/generic/yv12config.c", @@ -2036,6 +2058,7 @@ libvpx_srcs_arm_neon_cpu_detect_headers = [ "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_ext_ratectrl.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_extend.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.h", + "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass_stats.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_job_queue.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_lookahead.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_mbgraph.h", @@ -2074,6 +2097,7 @@ libvpx_srcs_arm_neon_cpu_detect_headers = [ "//third_party/libvpx/source/libvpx/vpx/vpx_frame_buffer.h", "//third_party/libvpx/source/libvpx/vpx/vpx_image.h", "//third_party/libvpx/source/libvpx/vpx/vpx_integer.h", + "//third_party/libvpx/source/libvpx/vpx/vpx_tpl.h", "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct_neon.h", "//third_party/libvpx/source/libvpx/vpx_dsp/arm/mem_neon.h", "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sum_neon.h", @@ -2099,6 +2123,7 @@ libvpx_srcs_arm_neon_cpu_detect_headers = [ "//third_party/libvpx/source/libvpx/vpx_mem/include/vpx_mem_intrnl.h", "//third_party/libvpx/source/libvpx/vpx_mem/vpx_mem.h", "//third_party/libvpx/source/libvpx/vpx_ports/arm.h", + "//third_party/libvpx/source/libvpx/vpx_ports/arm_cpudetect.h", "//third_party/libvpx/source/libvpx/vpx_ports/bitops.h", "//third_party/libvpx/source/libvpx/vpx_ports/compiler_attributes.h", "//third_party/libvpx/source/libvpx/vpx_ports/emmintrin_compat.h", @@ -2107,7 +2132,6 @@ libvpx_srcs_arm_neon_cpu_detect_headers = [ "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops.h", "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops_aligned.h", "//third_party/libvpx/source/libvpx/vpx_ports/mips.h", - "//third_party/libvpx/source/libvpx/vpx_ports/msvc.h", "//third_party/libvpx/source/libvpx/vpx_ports/static_assert.h", "//third_party/libvpx/source/libvpx/vpx_ports/system_state.h", "//third_party/libvpx/source/libvpx/vpx_ports/vpx_once.h", @@ -2117,6 +2141,7 @@ libvpx_srcs_arm_neon_cpu_detect_headers = [ "//third_party/libvpx/source/libvpx/vpx_scale/yv12config.h", "//third_party/libvpx/source/libvpx/vpx_util/endian_inl.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h", + "//third_party/libvpx/source/libvpx/vpx_util/vpx_pthread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h", @@ -2189,29 +2214,18 @@ libvpx_srcs_arm_neon_cpu_detect_neon = [ "//third_party/libvpx/source/libvpx/vpx_dsp/arm/quantize_neon.c", "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sad4d_neon.c", "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sad_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sse_neon.c", "//third_party/libvpx/source/libvpx/vpx_dsp/arm/subpel_variance_neon.c", "//third_party/libvpx/source/libvpx/vpx_dsp/arm/subtract_neon.c", "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sum_squares_neon.c", "//third_party/libvpx/source/libvpx/vpx_dsp/arm/variance_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_neon_asm.c", "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_neon.c", "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_scaled_convolve8_neon.c", ] libvpx_srcs_arm64 = [ "//third_party/libvpx/source/libvpx/vp8/common/alloccommon.c", "//third_party/libvpx/source/libvpx/vp8/common/arm/loopfilter_arm.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/bilinearpredict_neon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/copymem_neon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/dc_only_idct_add_neon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/dequant_idct_neon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/dequantizeb_neon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/idct_blk_neon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/iwalsh_neon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/loopfiltersimplehorizontaledge_neon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/loopfiltersimpleverticaledge_neon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/mbloopfilter_neon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/shortidct4x4llm_neon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/sixtappredict_neon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/vp8_loopfilter_neon.c", "//third_party/libvpx/source/libvpx/vp8/common/blockd.c", "//third_party/libvpx/source/libvpx/vp8/common/dequantize.c", "//third_party/libvpx/source/libvpx/vp8/common/entropy.c", @@ -2244,10 +2258,6 @@ libvpx_srcs_arm64 = [ "//third_party/libvpx/source/libvpx/vp8/decoder/detokenize.c", "//third_party/libvpx/source/libvpx/vp8/decoder/onyxd_if.c", "//third_party/libvpx/source/libvpx/vp8/decoder/threading.c", - "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/denoising_neon.c", - "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/fastquantizeb_neon.c", - "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/shortfdct_neon.c", - "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/vp8_shortwalsh4x4_neon.c", "//third_party/libvpx/source/libvpx/vp8/encoder/bitstream.c", "//third_party/libvpx/source/libvpx/vp8/encoder/boolhuff.c", "//third_party/libvpx/source/libvpx/vp8/encoder/copy_c.c", @@ -2273,9 +2283,6 @@ libvpx_srcs_arm64 = [ "//third_party/libvpx/source/libvpx/vp8/encoder/vp8_quantize.c", "//third_party/libvpx/source/libvpx/vp8/vp8_cx_iface.c", "//third_party/libvpx/source/libvpx/vp8/vp8_dx_iface.c", - "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht16x16_add_neon.c", - "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht4x4_add_neon.c", - "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht8x8_add_neon.c", "//third_party/libvpx/source/libvpx/vp9/common/vp9_alloccommon.c", "//third_party/libvpx/source/libvpx/vp9/common/vp9_blockd.c", "//third_party/libvpx/source/libvpx/vp9/common/vp9_common_data.c", @@ -2305,12 +2312,6 @@ libvpx_srcs_arm64 = [ "//third_party/libvpx/source/libvpx/vp9/decoder/vp9_detokenize.c", "//third_party/libvpx/source/libvpx/vp9/decoder/vp9_dsubexp.c", "//third_party/libvpx/source/libvpx/vp9/decoder/vp9_job_queue.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_dct_neon.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_denoiser_neon.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_diamond_search_sad_neon.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_error_neon.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_frame_scale_neon.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_quantize_neon.c", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.c", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_context_tree.c", @@ -2352,39 +2353,6 @@ libvpx_srcs_arm64 = [ "//third_party/libvpx/source/libvpx/vpx/src/vpx_encoder.c", "//third_party/libvpx/source/libvpx/vpx/src/vpx_image.c", "//third_party/libvpx/source/libvpx/vpx_dsp/add_noise.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/avg_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/avg_pred_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/deblock_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct16x16_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct32x32_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct4x4_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct8x8_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct_partial_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/hadamard_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct16x16_1_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct16x16_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_135_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_1_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_34_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct4x4_1_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct4x4_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct8x8_1_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct8x8_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/intrapred_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/loopfilter_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/quantize_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sad4d_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sad_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/subpel_variance_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/subtract_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sum_squares_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/variance_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_avg_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_copy_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_scaled_convolve8_neon.c", "//third_party/libvpx/source/libvpx/vpx_dsp/avg.c", "//third_party/libvpx/source/libvpx/vpx_dsp/bitreader.c", "//third_party/libvpx/source/libvpx/vpx_dsp/bitreader_buffer.c", @@ -2400,13 +2368,14 @@ libvpx_srcs_arm64 = [ "//third_party/libvpx/source/libvpx/vpx_dsp/quantize.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sad.c", "//third_party/libvpx/source/libvpx/vpx_dsp/skin_detection.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/sse.c", "//third_party/libvpx/source/libvpx/vpx_dsp/subtract.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sum_squares.c", "//third_party/libvpx/source/libvpx/vpx_dsp/variance.c", "//third_party/libvpx/source/libvpx/vpx_dsp/vpx_convolve.c", "//third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp_rtcd.c", "//third_party/libvpx/source/libvpx/vpx_mem/vpx_mem.c", - "//third_party/libvpx/source/libvpx/vpx_ports/arm_cpudetect.c", + "//third_party/libvpx/source/libvpx/vpx_ports/aarch64_cpudetect.c", "//third_party/libvpx/source/libvpx/vpx_scale/generic/gen_scalers.c", "//third_party/libvpx/source/libvpx/vpx_scale/generic/vpx_scale.c", "//third_party/libvpx/source/libvpx/vpx_scale/generic/yv12config.c", @@ -2529,6 +2498,7 @@ libvpx_srcs_arm64_headers = [ "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_ext_ratectrl.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_extend.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.h", + "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass_stats.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_job_queue.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_lookahead.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_mbgraph.h", @@ -2567,6 +2537,7 @@ libvpx_srcs_arm64_headers = [ "//third_party/libvpx/source/libvpx/vpx/vpx_frame_buffer.h", "//third_party/libvpx/source/libvpx/vpx/vpx_image.h", "//third_party/libvpx/source/libvpx/vpx/vpx_integer.h", + "//third_party/libvpx/source/libvpx/vpx/vpx_tpl.h", "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct_neon.h", "//third_party/libvpx/source/libvpx/vpx_dsp/arm/mem_neon.h", "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sum_neon.h", @@ -2591,6 +2562,7 @@ libvpx_srcs_arm64_headers = [ "//third_party/libvpx/source/libvpx/vpx_mem/include/vpx_mem_intrnl.h", "//third_party/libvpx/source/libvpx/vpx_mem/vpx_mem.h", "//third_party/libvpx/source/libvpx/vpx_ports/arm.h", + "//third_party/libvpx/source/libvpx/vpx_ports/arm_cpudetect.h", "//third_party/libvpx/source/libvpx/vpx_ports/bitops.h", "//third_party/libvpx/source/libvpx/vpx_ports/compiler_attributes.h", "//third_party/libvpx/source/libvpx/vpx_ports/emmintrin_compat.h", @@ -2599,7 +2571,6 @@ libvpx_srcs_arm64_headers = [ "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops.h", "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops_aligned.h", "//third_party/libvpx/source/libvpx/vpx_ports/mips.h", - "//third_party/libvpx/source/libvpx/vpx_ports/msvc.h", "//third_party/libvpx/source/libvpx/vpx_ports/static_assert.h", "//third_party/libvpx/source/libvpx/vpx_ports/system_state.h", "//third_party/libvpx/source/libvpx/vpx_ports/vpx_once.h", @@ -2609,14 +2580,13 @@ libvpx_srcs_arm64_headers = [ "//third_party/libvpx/source/libvpx/vpx_scale/yv12config.h", "//third_party/libvpx/source/libvpx/vpx_util/endian_inl.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h", + "//third_party/libvpx/source/libvpx/vpx_util/vpx_pthread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h", ] libvpx_srcs_arm64_assembly = [] -libvpx_srcs_arm_neon_highbd = [ - "//third_party/libvpx/source/libvpx/vp8/common/alloccommon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/loopfilter_arm.c", +libvpx_srcs_arm64_neon = [ "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/bilinearpredict_neon.c", "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/copymem_neon.c", "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/dc_only_idct_add_neon.c", @@ -2630,6 +2600,72 @@ libvpx_srcs_arm_neon_highbd = [ "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/shortidct4x4llm_neon.c", "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/sixtappredict_neon.c", "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/vp8_loopfilter_neon.c", + "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/denoising_neon.c", + "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/fastquantizeb_neon.c", + "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/shortfdct_neon.c", + "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/vp8_shortwalsh4x4_neon.c", + "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht16x16_add_neon.c", + "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht4x4_add_neon.c", + "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht8x8_add_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_dct_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_denoiser_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_diamond_search_sad_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_error_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_frame_scale_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_quantize_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/avg_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/avg_pred_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/deblock_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct16x16_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct32x32_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct4x4_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct8x8_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct_partial_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/hadamard_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct16x16_1_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct16x16_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_135_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_1_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_34_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct4x4_1_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct4x4_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct8x8_1_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct8x8_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/intrapred_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/loopfilter_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/quantize_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sad4d_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sad_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sse_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/subpel_variance_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/subtract_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sum_squares_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/variance_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_avg_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_copy_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_scaled_convolve8_neon.c", +] +libvpx_srcs_arm64_neon_dotprod = [ + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sad4d_neon_dotprod.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sad_neon_dotprod.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sse_neon_dotprod.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/variance_neon_dotprod.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_neon_dotprod.c", +] +libvpx_srcs_arm64_neon_i8mm = [ + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_neon_i8mm.c", +] +libvpx_srcs_arm64_sve = [ + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_error_sve.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sum_squares_sve.c", +] +libvpx_srcs_arm64_sve2 = [] +libvpx_srcs_arm_neon_highbd = [ + "//third_party/libvpx/source/libvpx/vp8/common/alloccommon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/loopfilter_arm.c", "//third_party/libvpx/source/libvpx/vp8/common/blockd.c", "//third_party/libvpx/source/libvpx/vp8/common/dequantize.c", "//third_party/libvpx/source/libvpx/vp8/common/entropy.c", @@ -2662,10 +2698,6 @@ libvpx_srcs_arm_neon_highbd = [ "//third_party/libvpx/source/libvpx/vp8/decoder/detokenize.c", "//third_party/libvpx/source/libvpx/vp8/decoder/onyxd_if.c", "//third_party/libvpx/source/libvpx/vp8/decoder/threading.c", - "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/denoising_neon.c", - "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/fastquantizeb_neon.c", - "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/shortfdct_neon.c", - "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/vp8_shortwalsh4x4_neon.c", "//third_party/libvpx/source/libvpx/vp8/encoder/bitstream.c", "//third_party/libvpx/source/libvpx/vp8/encoder/boolhuff.c", "//third_party/libvpx/source/libvpx/vp8/encoder/copy_c.c", @@ -2691,12 +2723,6 @@ libvpx_srcs_arm_neon_highbd = [ "//third_party/libvpx/source/libvpx/vp8/encoder/vp8_quantize.c", "//third_party/libvpx/source/libvpx/vp8/vp8_cx_iface.c", "//third_party/libvpx/source/libvpx/vp8/vp8_dx_iface.c", - "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_highbd_iht16x16_add_neon.c", - "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_highbd_iht4x4_add_neon.c", - "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_highbd_iht8x8_add_neon.c", - "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht16x16_add_neon.c", - "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht4x4_add_neon.c", - "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht8x8_add_neon.c", "//third_party/libvpx/source/libvpx/vp9/common/vp9_alloccommon.c", "//third_party/libvpx/source/libvpx/vp9/common/vp9_blockd.c", "//third_party/libvpx/source/libvpx/vp9/common/vp9_common_data.c", @@ -2726,13 +2752,6 @@ libvpx_srcs_arm_neon_highbd = [ "//third_party/libvpx/source/libvpx/vp9/decoder/vp9_detokenize.c", "//third_party/libvpx/source/libvpx/vp9/decoder/vp9_dsubexp.c", "//third_party/libvpx/source/libvpx/vp9/decoder/vp9_job_queue.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_dct_neon.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_denoiser_neon.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_diamond_search_sad_neon.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_error_neon.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_frame_scale_neon.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_highbd_error_neon.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_quantize_neon.c", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.c", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_context_tree.c", @@ -2774,55 +2793,6 @@ libvpx_srcs_arm_neon_highbd = [ "//third_party/libvpx/source/libvpx/vpx/src/vpx_encoder.c", "//third_party/libvpx/source/libvpx/vpx/src/vpx_image.c", "//third_party/libvpx/source/libvpx/vpx_dsp/add_noise.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/avg_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/avg_pred_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/deblock_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct16x16_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct32x32_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct4x4_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct8x8_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct_partial_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/hadamard_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_avg_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_avg_pred_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_hadamard_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct16x16_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct32x32_1024_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct32x32_135_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct32x32_34_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct32x32_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct4x4_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct8x8_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_intrapred_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_loopfilter_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_quantize_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_sad4d_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_sad_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_subpel_variance_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_variance_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_vpx_convolve8_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_vpx_convolve_avg_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_vpx_convolve_copy_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_vpx_convolve_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct16x16_1_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct16x16_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_135_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_1_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_34_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct8x8_1_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct8x8_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/intrapred_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/quantize_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sad4d_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sad_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/subpel_variance_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/subtract_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sum_squares_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/variance_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_neon_asm.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_scaled_convolve8_neon.c", "//third_party/libvpx/source/libvpx/vpx_dsp/avg.c", "//third_party/libvpx/source/libvpx/vpx_dsp/bitreader.c", "//third_party/libvpx/source/libvpx/vpx_dsp/bitreader_buffer.c", @@ -2838,13 +2808,14 @@ libvpx_srcs_arm_neon_highbd = [ "//third_party/libvpx/source/libvpx/vpx_dsp/quantize.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sad.c", "//third_party/libvpx/source/libvpx/vpx_dsp/skin_detection.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/sse.c", "//third_party/libvpx/source/libvpx/vpx_dsp/subtract.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sum_squares.c", "//third_party/libvpx/source/libvpx/vpx_dsp/variance.c", "//third_party/libvpx/source/libvpx/vpx_dsp/vpx_convolve.c", "//third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp_rtcd.c", "//third_party/libvpx/source/libvpx/vpx_mem/vpx_mem.c", - "//third_party/libvpx/source/libvpx/vpx_ports/arm_cpudetect.c", + "//third_party/libvpx/source/libvpx/vpx_ports/aarch32_cpudetect.c", "//third_party/libvpx/source/libvpx/vpx_scale/generic/gen_scalers.c", "//third_party/libvpx/source/libvpx/vpx_scale/generic/vpx_scale.c", "//third_party/libvpx/source/libvpx/vpx_scale/generic/yv12config.c", @@ -2967,6 +2938,7 @@ libvpx_srcs_arm_neon_highbd_headers = [ "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_ext_ratectrl.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_extend.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.h", + "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass_stats.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_job_queue.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_lookahead.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_mbgraph.h", @@ -3005,6 +2977,7 @@ libvpx_srcs_arm_neon_highbd_headers = [ "//third_party/libvpx/source/libvpx/vpx/vpx_frame_buffer.h", "//third_party/libvpx/source/libvpx/vpx/vpx_image.h", "//third_party/libvpx/source/libvpx/vpx/vpx_integer.h", + "//third_party/libvpx/source/libvpx/vpx/vpx_tpl.h", "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct_neon.h", "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct_neon.h", "//third_party/libvpx/source/libvpx/vpx_dsp/arm/mem_neon.h", @@ -3031,6 +3004,7 @@ libvpx_srcs_arm_neon_highbd_headers = [ "//third_party/libvpx/source/libvpx/vpx_mem/include/vpx_mem_intrnl.h", "//third_party/libvpx/source/libvpx/vpx_mem/vpx_mem.h", "//third_party/libvpx/source/libvpx/vpx_ports/arm.h", + "//third_party/libvpx/source/libvpx/vpx_ports/arm_cpudetect.h", "//third_party/libvpx/source/libvpx/vpx_ports/bitops.h", "//third_party/libvpx/source/libvpx/vpx_ports/compiler_attributes.h", "//third_party/libvpx/source/libvpx/vpx_ports/emmintrin_compat.h", @@ -3039,7 +3013,6 @@ libvpx_srcs_arm_neon_highbd_headers = [ "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops.h", "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops_aligned.h", "//third_party/libvpx/source/libvpx/vpx_ports/mips.h", - "//third_party/libvpx/source/libvpx/vpx_ports/msvc.h", "//third_party/libvpx/source/libvpx/vpx_ports/static_assert.h", "//third_party/libvpx/source/libvpx/vpx_ports/system_state.h", "//third_party/libvpx/source/libvpx/vpx_ports/vpx_once.h", @@ -3049,6 +3022,7 @@ libvpx_srcs_arm_neon_highbd_headers = [ "//third_party/libvpx/source/libvpx/vpx_scale/yv12config.h", "//third_party/libvpx/source/libvpx/vpx_util/endian_inl.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h", + "//third_party/libvpx/source/libvpx/vpx_util/vpx_pthread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h", @@ -3073,9 +3047,7 @@ libvpx_srcs_arm_neon_highbd_assembly = [ "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_avg_neon_asm.asm", "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_copy_neon_asm.asm", ] -libvpx_srcs_arm64_highbd = [ - "//third_party/libvpx/source/libvpx/vp8/common/alloccommon.c", - "//third_party/libvpx/source/libvpx/vp8/common/arm/loopfilter_arm.c", +libvpx_srcs_arm_neon_highbd_neon = [ "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/bilinearpredict_neon.c", "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/copymem_neon.c", "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/dc_only_idct_add_neon.c", @@ -3089,6 +3061,77 @@ libvpx_srcs_arm64_highbd = [ "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/shortidct4x4llm_neon.c", "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/sixtappredict_neon.c", "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/vp8_loopfilter_neon.c", + "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/denoising_neon.c", + "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/fastquantizeb_neon.c", + "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/shortfdct_neon.c", + "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/vp8_shortwalsh4x4_neon.c", + "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_highbd_iht16x16_add_neon.c", + "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_highbd_iht4x4_add_neon.c", + "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_highbd_iht8x8_add_neon.c", + "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht16x16_add_neon.c", + "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht4x4_add_neon.c", + "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht8x8_add_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_dct_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_denoiser_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_diamond_search_sad_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_error_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_frame_scale_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_highbd_error_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_quantize_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/avg_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/avg_pred_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/deblock_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct16x16_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct32x32_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct4x4_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct8x8_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct_partial_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/hadamard_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_avg_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_avg_pred_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_hadamard_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct16x16_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct32x32_1024_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct32x32_135_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct32x32_34_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct32x32_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct4x4_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct8x8_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_intrapred_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_loopfilter_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_quantize_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_sad4d_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_sad_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_sse_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_subpel_variance_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_variance_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_vpx_convolve8_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_vpx_convolve_avg_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_vpx_convolve_copy_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct16x16_1_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct16x16_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_135_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_1_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_34_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct8x8_1_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct8x8_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/intrapred_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/quantize_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sad4d_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sad_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sse_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/subpel_variance_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/subtract_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sum_squares_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/variance_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_neon_asm.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_scaled_convolve8_neon.c", +] +libvpx_srcs_arm64_highbd = [ + "//third_party/libvpx/source/libvpx/vp8/common/alloccommon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/loopfilter_arm.c", "//third_party/libvpx/source/libvpx/vp8/common/blockd.c", "//third_party/libvpx/source/libvpx/vp8/common/dequantize.c", "//third_party/libvpx/source/libvpx/vp8/common/entropy.c", @@ -3121,10 +3164,6 @@ libvpx_srcs_arm64_highbd = [ "//third_party/libvpx/source/libvpx/vp8/decoder/detokenize.c", "//third_party/libvpx/source/libvpx/vp8/decoder/onyxd_if.c", "//third_party/libvpx/source/libvpx/vp8/decoder/threading.c", - "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/denoising_neon.c", - "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/fastquantizeb_neon.c", - "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/shortfdct_neon.c", - "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/vp8_shortwalsh4x4_neon.c", "//third_party/libvpx/source/libvpx/vp8/encoder/bitstream.c", "//third_party/libvpx/source/libvpx/vp8/encoder/boolhuff.c", "//third_party/libvpx/source/libvpx/vp8/encoder/copy_c.c", @@ -3150,12 +3189,6 @@ libvpx_srcs_arm64_highbd = [ "//third_party/libvpx/source/libvpx/vp8/encoder/vp8_quantize.c", "//third_party/libvpx/source/libvpx/vp8/vp8_cx_iface.c", "//third_party/libvpx/source/libvpx/vp8/vp8_dx_iface.c", - "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_highbd_iht16x16_add_neon.c", - "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_highbd_iht4x4_add_neon.c", - "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_highbd_iht8x8_add_neon.c", - "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht16x16_add_neon.c", - "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht4x4_add_neon.c", - "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht8x8_add_neon.c", "//third_party/libvpx/source/libvpx/vp9/common/vp9_alloccommon.c", "//third_party/libvpx/source/libvpx/vp9/common/vp9_blockd.c", "//third_party/libvpx/source/libvpx/vp9/common/vp9_common_data.c", @@ -3185,13 +3218,6 @@ libvpx_srcs_arm64_highbd = [ "//third_party/libvpx/source/libvpx/vp9/decoder/vp9_detokenize.c", "//third_party/libvpx/source/libvpx/vp9/decoder/vp9_dsubexp.c", "//third_party/libvpx/source/libvpx/vp9/decoder/vp9_job_queue.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_dct_neon.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_denoiser_neon.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_diamond_search_sad_neon.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_error_neon.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_frame_scale_neon.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_highbd_error_neon.c", - "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_quantize_neon.c", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_bitstream.c", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_context_tree.c", @@ -3233,60 +3259,6 @@ libvpx_srcs_arm64_highbd = [ "//third_party/libvpx/source/libvpx/vpx/src/vpx_encoder.c", "//third_party/libvpx/source/libvpx/vpx/src/vpx_image.c", "//third_party/libvpx/source/libvpx/vpx_dsp/add_noise.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/avg_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/avg_pred_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/deblock_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct16x16_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct32x32_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct4x4_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct8x8_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct_partial_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/hadamard_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_avg_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_avg_pred_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_hadamard_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct16x16_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct32x32_1024_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct32x32_135_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct32x32_34_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct32x32_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct4x4_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct8x8_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_intrapred_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_loopfilter_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_quantize_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_sad4d_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_sad_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_subpel_variance_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_variance_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_vpx_convolve8_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_vpx_convolve_avg_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_vpx_convolve_copy_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_vpx_convolve_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct16x16_1_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct16x16_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_135_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_1_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_34_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct4x4_1_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct4x4_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct8x8_1_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct8x8_add_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/intrapred_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/loopfilter_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/quantize_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sad4d_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sad_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/subpel_variance_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/subtract_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sum_squares_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/variance_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_avg_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_copy_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_neon.c", - "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_scaled_convolve8_neon.c", "//third_party/libvpx/source/libvpx/vpx_dsp/avg.c", "//third_party/libvpx/source/libvpx/vpx_dsp/bitreader.c", "//third_party/libvpx/source/libvpx/vpx_dsp/bitreader_buffer.c", @@ -3302,13 +3274,14 @@ libvpx_srcs_arm64_highbd = [ "//third_party/libvpx/source/libvpx/vpx_dsp/quantize.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sad.c", "//third_party/libvpx/source/libvpx/vpx_dsp/skin_detection.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/sse.c", "//third_party/libvpx/source/libvpx/vpx_dsp/subtract.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sum_squares.c", "//third_party/libvpx/source/libvpx/vpx_dsp/variance.c", "//third_party/libvpx/source/libvpx/vpx_dsp/vpx_convolve.c", "//third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp_rtcd.c", "//third_party/libvpx/source/libvpx/vpx_mem/vpx_mem.c", - "//third_party/libvpx/source/libvpx/vpx_ports/arm_cpudetect.c", + "//third_party/libvpx/source/libvpx/vpx_ports/aarch64_cpudetect.c", "//third_party/libvpx/source/libvpx/vpx_scale/generic/gen_scalers.c", "//third_party/libvpx/source/libvpx/vpx_scale/generic/vpx_scale.c", "//third_party/libvpx/source/libvpx/vpx_scale/generic/yv12config.c", @@ -3431,6 +3404,7 @@ libvpx_srcs_arm64_highbd_headers = [ "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_ext_ratectrl.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_extend.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.h", + "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass_stats.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_job_queue.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_lookahead.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_mbgraph.h", @@ -3469,6 +3443,7 @@ libvpx_srcs_arm64_highbd_headers = [ "//third_party/libvpx/source/libvpx/vpx/vpx_frame_buffer.h", "//third_party/libvpx/source/libvpx/vpx/vpx_image.h", "//third_party/libvpx/source/libvpx/vpx/vpx_integer.h", + "//third_party/libvpx/source/libvpx/vpx/vpx_tpl.h", "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct_neon.h", "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct_neon.h", "//third_party/libvpx/source/libvpx/vpx_dsp/arm/mem_neon.h", @@ -3494,6 +3469,7 @@ libvpx_srcs_arm64_highbd_headers = [ "//third_party/libvpx/source/libvpx/vpx_mem/include/vpx_mem_intrnl.h", "//third_party/libvpx/source/libvpx/vpx_mem/vpx_mem.h", "//third_party/libvpx/source/libvpx/vpx_ports/arm.h", + "//third_party/libvpx/source/libvpx/vpx_ports/arm_cpudetect.h", "//third_party/libvpx/source/libvpx/vpx_ports/bitops.h", "//third_party/libvpx/source/libvpx/vpx_ports/compiler_attributes.h", "//third_party/libvpx/source/libvpx/vpx_ports/emmintrin_compat.h", @@ -3502,7 +3478,6 @@ libvpx_srcs_arm64_highbd_headers = [ "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops.h", "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops_aligned.h", "//third_party/libvpx/source/libvpx/vpx_ports/mips.h", - "//third_party/libvpx/source/libvpx/vpx_ports/msvc.h", "//third_party/libvpx/source/libvpx/vpx_ports/static_assert.h", "//third_party/libvpx/source/libvpx/vpx_ports/system_state.h", "//third_party/libvpx/source/libvpx/vpx_ports/vpx_once.h", @@ -3512,11 +3487,119 @@ libvpx_srcs_arm64_highbd_headers = [ "//third_party/libvpx/source/libvpx/vpx_scale/yv12config.h", "//third_party/libvpx/source/libvpx/vpx_util/endian_inl.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h", + "//third_party/libvpx/source/libvpx/vpx_util/vpx_pthread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h", ] libvpx_srcs_arm64_highbd_assembly = [] +libvpx_srcs_arm64_highbd_neon = [ + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/bilinearpredict_neon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/copymem_neon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/dc_only_idct_add_neon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/dequant_idct_neon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/dequantizeb_neon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/idct_blk_neon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/iwalsh_neon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/loopfiltersimplehorizontaledge_neon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/loopfiltersimpleverticaledge_neon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/mbloopfilter_neon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/shortidct4x4llm_neon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/sixtappredict_neon.c", + "//third_party/libvpx/source/libvpx/vp8/common/arm/neon/vp8_loopfilter_neon.c", + "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/denoising_neon.c", + "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/fastquantizeb_neon.c", + "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/shortfdct_neon.c", + "//third_party/libvpx/source/libvpx/vp8/encoder/arm/neon/vp8_shortwalsh4x4_neon.c", + "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_highbd_iht16x16_add_neon.c", + "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_highbd_iht4x4_add_neon.c", + "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_highbd_iht8x8_add_neon.c", + "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht16x16_add_neon.c", + "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht4x4_add_neon.c", + "//third_party/libvpx/source/libvpx/vp9/common/arm/neon/vp9_iht8x8_add_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_dct_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_denoiser_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_diamond_search_sad_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_error_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_frame_scale_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_highbd_error_neon.c", + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_quantize_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/avg_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/avg_pred_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/deblock_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct16x16_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct32x32_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct4x4_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct8x8_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/fdct_partial_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/hadamard_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_avg_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_avg_pred_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_hadamard_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct16x16_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct32x32_1024_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct32x32_135_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct32x32_34_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct32x32_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct4x4_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_idct8x8_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_intrapred_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_loopfilter_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_quantize_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_sad4d_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_sad_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_sse_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_subpel_variance_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_variance_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_vpx_convolve8_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_vpx_convolve_avg_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_vpx_convolve_copy_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct16x16_1_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct16x16_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_135_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_1_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_34_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct32x32_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct4x4_1_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct4x4_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct8x8_1_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/idct8x8_add_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/intrapred_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/loopfilter_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/quantize_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sad4d_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sad_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sse_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/subpel_variance_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/subtract_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sum_squares_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/variance_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_avg_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_copy_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve_neon.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_scaled_convolve8_neon.c", +] +libvpx_srcs_arm64_highbd_neon_dotprod = [ + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_variance_neon_dotprod.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sad4d_neon_dotprod.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sad_neon_dotprod.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sse_neon_dotprod.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/variance_neon_dotprod.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_neon_dotprod.c", +] +libvpx_srcs_arm64_highbd_neon_i8mm = [ + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/vpx_convolve8_neon_i8mm.c", +] +libvpx_srcs_arm64_highbd_sve = [ + "//third_party/libvpx/source/libvpx/vp9/encoder/arm/neon/vp9_error_sve.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_variance_sve.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_vpx_convolve8_sve.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/sum_squares_sve.c", +] +libvpx_srcs_arm64_highbd_sve2 = [ + "//third_party/libvpx/source/libvpx/vpx_dsp/arm/highbd_vpx_convolve8_sve2.c", +] libvpx_srcs_mips = [ "//third_party/libvpx/source/libvpx/vp8/common/alloccommon.c", "//third_party/libvpx/source/libvpx/vp8/common/blockd.c", @@ -3661,6 +3744,7 @@ libvpx_srcs_mips = [ "//third_party/libvpx/source/libvpx/vpx_dsp/quantize.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sad.c", "//third_party/libvpx/source/libvpx/vpx_dsp/skin_detection.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/sse.c", "//third_party/libvpx/source/libvpx/vpx_dsp/subtract.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sum_squares.c", "//third_party/libvpx/source/libvpx/vpx_dsp/variance.c", @@ -3788,6 +3872,7 @@ libvpx_srcs_mips_headers = [ "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_ext_ratectrl.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_extend.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.h", + "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass_stats.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_job_queue.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_lookahead.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_mbgraph.h", @@ -3826,6 +3911,7 @@ libvpx_srcs_mips_headers = [ "//third_party/libvpx/source/libvpx/vpx/vpx_frame_buffer.h", "//third_party/libvpx/source/libvpx/vpx/vpx_image.h", "//third_party/libvpx/source/libvpx/vpx/vpx_integer.h", + "//third_party/libvpx/source/libvpx/vpx/vpx_tpl.h", "//third_party/libvpx/source/libvpx/vpx_dsp/bitreader.h", "//third_party/libvpx/source/libvpx/vpx_dsp/bitreader_buffer.h", "//third_party/libvpx/source/libvpx/vpx_dsp/bitwriter.h", @@ -3854,7 +3940,6 @@ libvpx_srcs_mips_headers = [ "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops.h", "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops_aligned.h", "//third_party/libvpx/source/libvpx/vpx_ports/mips.h", - "//third_party/libvpx/source/libvpx/vpx_ports/msvc.h", "//third_party/libvpx/source/libvpx/vpx_ports/static_assert.h", "//third_party/libvpx/source/libvpx/vpx_ports/system_state.h", "//third_party/libvpx/source/libvpx/vpx_ports/vpx_once.h", @@ -3864,6 +3949,7 @@ libvpx_srcs_mips_headers = [ "//third_party/libvpx/source/libvpx/vpx_scale/yv12config.h", "//third_party/libvpx/source/libvpx/vpx_util/endian_inl.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h", + "//third_party/libvpx/source/libvpx/vpx_util/vpx_pthread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h", @@ -4013,6 +4099,7 @@ libvpx_srcs_loongarch = [ "//third_party/libvpx/source/libvpx/vpx_dsp/quantize.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sad.c", "//third_party/libvpx/source/libvpx/vpx_dsp/skin_detection.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/sse.c", "//third_party/libvpx/source/libvpx/vpx_dsp/subtract.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sum_squares.c", "//third_party/libvpx/source/libvpx/vpx_dsp/variance.c", @@ -4140,6 +4227,7 @@ libvpx_srcs_loongarch_headers = [ "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_ext_ratectrl.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_extend.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.h", + "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass_stats.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_job_queue.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_lookahead.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_mbgraph.h", @@ -4178,6 +4266,7 @@ libvpx_srcs_loongarch_headers = [ "//third_party/libvpx/source/libvpx/vpx/vpx_frame_buffer.h", "//third_party/libvpx/source/libvpx/vpx/vpx_image.h", "//third_party/libvpx/source/libvpx/vpx/vpx_integer.h", + "//third_party/libvpx/source/libvpx/vpx/vpx_tpl.h", "//third_party/libvpx/source/libvpx/vpx_dsp/bitreader.h", "//third_party/libvpx/source/libvpx/vpx_dsp/bitreader_buffer.h", "//third_party/libvpx/source/libvpx/vpx_dsp/bitwriter.h", @@ -4205,7 +4294,6 @@ libvpx_srcs_loongarch_headers = [ "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops.h", "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops_aligned.h", "//third_party/libvpx/source/libvpx/vpx_ports/mips.h", - "//third_party/libvpx/source/libvpx/vpx_ports/msvc.h", "//third_party/libvpx/source/libvpx/vpx_ports/static_assert.h", "//third_party/libvpx/source/libvpx/vpx_ports/system_state.h", "//third_party/libvpx/source/libvpx/vpx_ports/vpx_once.h", @@ -4215,6 +4303,7 @@ libvpx_srcs_loongarch_headers = [ "//third_party/libvpx/source/libvpx/vpx_scale/yv12config.h", "//third_party/libvpx/source/libvpx/vpx_util/endian_inl.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h", + "//third_party/libvpx/source/libvpx/vpx_util/vpx_pthread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h", @@ -4399,6 +4488,7 @@ libvpx_srcs_ppc64 = [ "//third_party/libvpx/source/libvpx/vpx_dsp/quantize.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sad.c", "//third_party/libvpx/source/libvpx/vpx_dsp/skin_detection.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/sse.c", "//third_party/libvpx/source/libvpx/vpx_dsp/subtract.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sum_squares.c", "//third_party/libvpx/source/libvpx/vpx_dsp/variance.c", @@ -4526,6 +4616,7 @@ libvpx_srcs_ppc64_headers = [ "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_ext_ratectrl.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_extend.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.h", + "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass_stats.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_job_queue.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_lookahead.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_mbgraph.h", @@ -4564,6 +4655,7 @@ libvpx_srcs_ppc64_headers = [ "//third_party/libvpx/source/libvpx/vpx/vpx_frame_buffer.h", "//third_party/libvpx/source/libvpx/vpx/vpx_image.h", "//third_party/libvpx/source/libvpx/vpx/vpx_integer.h", + "//third_party/libvpx/source/libvpx/vpx/vpx_tpl.h", "//third_party/libvpx/source/libvpx/vpx_dsp/bitreader.h", "//third_party/libvpx/source/libvpx/vpx_dsp/bitreader_buffer.h", "//third_party/libvpx/source/libvpx/vpx_dsp/bitwriter.h", @@ -4591,7 +4683,6 @@ libvpx_srcs_ppc64_headers = [ "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops.h", "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops_aligned.h", "//third_party/libvpx/source/libvpx/vpx_ports/mips.h", - "//third_party/libvpx/source/libvpx/vpx_ports/msvc.h", "//third_party/libvpx/source/libvpx/vpx_ports/ppc.h", "//third_party/libvpx/source/libvpx/vpx_ports/static_assert.h", "//third_party/libvpx/source/libvpx/vpx_ports/system_state.h", @@ -4602,6 +4693,7 @@ libvpx_srcs_ppc64_headers = [ "//third_party/libvpx/source/libvpx/vpx_scale/yv12config.h", "//third_party/libvpx/source/libvpx/vpx_util/endian_inl.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h", + "//third_party/libvpx/source/libvpx/vpx_util/vpx_pthread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h", @@ -4751,6 +4843,7 @@ libvpx_srcs_nacl = [ "//third_party/libvpx/source/libvpx/vpx_dsp/quantize.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sad.c", "//third_party/libvpx/source/libvpx/vpx_dsp/skin_detection.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/sse.c", "//third_party/libvpx/source/libvpx/vpx_dsp/subtract.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sum_squares.c", "//third_party/libvpx/source/libvpx/vpx_dsp/variance.c", @@ -4877,6 +4970,7 @@ libvpx_srcs_nacl_headers = [ "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_ext_ratectrl.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_extend.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.h", + "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass_stats.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_job_queue.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_lookahead.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_mbgraph.h", @@ -4915,6 +5009,7 @@ libvpx_srcs_nacl_headers = [ "//third_party/libvpx/source/libvpx/vpx/vpx_frame_buffer.h", "//third_party/libvpx/source/libvpx/vpx/vpx_image.h", "//third_party/libvpx/source/libvpx/vpx/vpx_integer.h", + "//third_party/libvpx/source/libvpx/vpx/vpx_tpl.h", "//third_party/libvpx/source/libvpx/vpx_dsp/bitreader.h", "//third_party/libvpx/source/libvpx/vpx_dsp/bitreader_buffer.h", "//third_party/libvpx/source/libvpx/vpx_dsp/bitwriter.h", @@ -4942,7 +5037,6 @@ libvpx_srcs_nacl_headers = [ "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops.h", "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops_aligned.h", "//third_party/libvpx/source/libvpx/vpx_ports/mips.h", - "//third_party/libvpx/source/libvpx/vpx_ports/msvc.h", "//third_party/libvpx/source/libvpx/vpx_ports/static_assert.h", "//third_party/libvpx/source/libvpx/vpx_ports/system_state.h", "//third_party/libvpx/source/libvpx/vpx_ports/vpx_once.h", @@ -4952,6 +5046,7 @@ libvpx_srcs_nacl_headers = [ "//third_party/libvpx/source/libvpx/vpx_scale/yv12config.h", "//third_party/libvpx/source/libvpx/vpx_util/endian_inl.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h", + "//third_party/libvpx/source/libvpx/vpx_util/vpx_pthread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h", @@ -5101,6 +5196,7 @@ libvpx_srcs_generic = [ "//third_party/libvpx/source/libvpx/vpx_dsp/quantize.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sad.c", "//third_party/libvpx/source/libvpx/vpx_dsp/skin_detection.c", + "//third_party/libvpx/source/libvpx/vpx_dsp/sse.c", "//third_party/libvpx/source/libvpx/vpx_dsp/subtract.c", "//third_party/libvpx/source/libvpx/vpx_dsp/sum_squares.c", "//third_party/libvpx/source/libvpx/vpx_dsp/variance.c", @@ -5227,6 +5323,7 @@ libvpx_srcs_generic_headers = [ "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_ext_ratectrl.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_extend.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass.h", + "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_firstpass_stats.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_job_queue.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_lookahead.h", "//third_party/libvpx/source/libvpx/vp9/encoder/vp9_mbgraph.h", @@ -5265,6 +5362,7 @@ libvpx_srcs_generic_headers = [ "//third_party/libvpx/source/libvpx/vpx/vpx_frame_buffer.h", "//third_party/libvpx/source/libvpx/vpx/vpx_image.h", "//third_party/libvpx/source/libvpx/vpx/vpx_integer.h", + "//third_party/libvpx/source/libvpx/vpx/vpx_tpl.h", "//third_party/libvpx/source/libvpx/vpx_dsp/bitreader.h", "//third_party/libvpx/source/libvpx/vpx_dsp/bitreader_buffer.h", "//third_party/libvpx/source/libvpx/vpx_dsp/bitwriter.h", @@ -5292,7 +5390,6 @@ libvpx_srcs_generic_headers = [ "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops.h", "//third_party/libvpx/source/libvpx/vpx_ports/mem_ops_aligned.h", "//third_party/libvpx/source/libvpx/vpx_ports/mips.h", - "//third_party/libvpx/source/libvpx/vpx_ports/msvc.h", "//third_party/libvpx/source/libvpx/vpx_ports/static_assert.h", "//third_party/libvpx/source/libvpx/vpx_ports/system_state.h", "//third_party/libvpx/source/libvpx/vpx_ports/vpx_once.h", @@ -5302,6 +5399,7 @@ libvpx_srcs_generic_headers = [ "//third_party/libvpx/source/libvpx/vpx_scale/yv12config.h", "//third_party/libvpx/source/libvpx/vpx_util/endian_inl.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_atomics.h", + "//third_party/libvpx/source/libvpx/vpx_util/vpx_pthread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_thread.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_timestamp.h", "//third_party/libvpx/source/libvpx/vpx_util/vpx_write_yuv_frame.h", diff --git a/libvpx/source/config/ios/arm-neon/vp8_rtcd.h b/libvpx/source/config/ios/arm-neon/vp8_rtcd.h old mode 100644 new mode 100755 index eb0b3a7cb44e16dc07e8b8f4985011dc9aa9fd16..102501094254bb09d784498a444bed4e77bf00a4 --- a/libvpx/source/config/ios/arm-neon/vp8_rtcd.h +++ b/libvpx/source/config/ios/arm-neon/vp8_rtcd.h @@ -83,36 +83,6 @@ void vp8_bilinear_predict8x8_neon(unsigned char* src_ptr, int dst_pitch); #define vp8_bilinear_predict8x8 vp8_bilinear_predict8x8_neon -void vp8_blend_b_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_b vp8_blend_b_c - -void vp8_blend_mb_inner_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_inner vp8_blend_mb_inner_c - -void vp8_blend_mb_outer_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_outer vp8_blend_mb_outer_c - int vp8_block_error_c(short* coeff, short* dqcoeff); #define vp8_block_error vp8_block_error_c diff --git a/libvpx/source/config/ios/arm-neon/vp9_rtcd.h b/libvpx/source/config/ios/arm-neon/vp9_rtcd.h old mode 100644 new mode 100755 index 8b1eaf7118999079707c57c10c757dd8add312e5..4c2a4adad26c6ce30557ea637f0f159d9bf1e61b --- a/libvpx/source/config/ios/arm-neon/vp9_rtcd.h +++ b/libvpx/source/config/ios/arm-neon/vp9_rtcd.h @@ -21,7 +21,9 @@ struct macroblockd; /* Encoder forward decls */ struct macroblock; -struct vp9_variance_vtable; +struct macroblock_plane; +struct vp9_sad_table; +struct ScanOrder; struct search_site_config; struct mv; union int_mv; @@ -77,7 +79,7 @@ int vp9_diamond_search_sad_c(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); int vp9_diamond_search_sad_neon(const struct macroblock* x, const struct search_site_config* cfg, @@ -87,7 +89,7 @@ int vp9_diamond_search_sad_neon(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); #define vp9_diamond_search_sad vp9_diamond_search_sad_neon @@ -170,46 +172,38 @@ void vp9_iht8x8_64_add_neon(const tran_low_t* input, void vp9_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp vp9_quantize_fp_neon void vp9_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp_32x32 vp9_quantize_fp_32x32_neon void vp9_scale_and_extend_frame_c(const struct yv12_buffer_config* src, diff --git a/libvpx/source/config/ios/arm-neon/vpx_config.asm b/libvpx/source/config/ios/arm-neon/vpx_config.asm old mode 100644 new mode 100755 index b25d6cda2f6458c61d38707e609bb771c352e43a..a60671882a83a87fd0c0c81df1c25c08ad9b0324 --- a/libvpx/source/config/ios/arm-neon/vpx_config.asm +++ b/libvpx/source/config/ios/arm-neon/vpx_config.asm @@ -4,6 +4,8 @@ .syntax unified .equ VPX_ARCH_ARM , 1 .equ ARCH_ARM , 1 +.equ VPX_ARCH_AARCH64 , 0 +.equ ARCH_AARCH64 , 0 .equ VPX_ARCH_MIPS , 0 .equ ARCH_MIPS , 0 .equ VPX_ARCH_X86 , 0 @@ -14,8 +16,12 @@ .equ ARCH_PPC , 0 .equ VPX_ARCH_LOONGARCH , 0 .equ ARCH_LOONGARCH , 0 -.equ HAVE_NEON , 1 .equ HAVE_NEON_ASM , 1 +.equ HAVE_NEON , 1 +.equ HAVE_NEON_DOTPROD , 0 +.equ HAVE_NEON_I8MM , 0 +.equ HAVE_SVE , 0 +.equ HAVE_SVE2 , 0 .equ HAVE_MIPS32 , 0 .equ HAVE_DSPR2 , 0 .equ HAVE_MSA , 0 diff --git a/libvpx/source/config/ios/arm-neon/vpx_config.c b/libvpx/source/config/ios/arm-neon/vpx_config.c old mode 100644 new mode 100755 index f4f0c112a0dbd486ee1dc734fb5af9ead29c03b9..0a31bce02e50e10d6aa3387bee9ee11dcba2e55d --- a/libvpx/source/config/ios/arm-neon/vpx_config.c +++ b/libvpx/source/config/ios/arm-neon/vpx_config.c @@ -6,5 +6,5 @@ /* in the file PATENTS. All contributing project authors may */ /* be found in the AUTHORS file in the root of the source tree. */ #include "vpx/vpx_codec.h" -static const char* const cfg = "--target=armv7-linux-gcc --enable-external-build --enable-postproc --enable-multi-res-encoding --enable-temporal-denoising --enable-vp9-temporal-denoising --enable-vp9-postproc --size-limit=16384x16384 --enable-realtime-only --disable-install-docs --disable-libyuv"; +static const char* const cfg = "--target=armv7-linux-gcc --disable-runtime-cpu-detect --enable-external-build --enable-postproc --enable-multi-res-encoding --enable-temporal-denoising --enable-vp9-temporal-denoising --enable-vp9-postproc --size-limit=16384x16384 --enable-realtime-only --disable-install-docs --disable-libyuv"; const char *vpx_codec_build_config(void) {return cfg;} diff --git a/libvpx/source/config/ios/arm-neon/vpx_config.h b/libvpx/source/config/ios/arm-neon/vpx_config.h old mode 100644 new mode 100755 index 12337a51a17da2e208727efb57a5eb8c7ba86bee..c274e6d5351e06f6cf4d1c3af19af1ad64c8361d --- a/libvpx/source/config/ios/arm-neon/vpx_config.h +++ b/libvpx/source/config/ios/arm-neon/vpx_config.h @@ -12,6 +12,8 @@ #define INLINE inline #define VPX_ARCH_ARM 1 #define ARCH_ARM 1 +#define VPX_ARCH_AARCH64 0 +#define ARCH_AARCH64 0 #define VPX_ARCH_MIPS 0 #define ARCH_MIPS 0 #define VPX_ARCH_X86 0 @@ -22,8 +24,12 @@ #define ARCH_PPC 0 #define VPX_ARCH_LOONGARCH 0 #define ARCH_LOONGARCH 0 -#define HAVE_NEON 1 #define HAVE_NEON_ASM 1 +#define HAVE_NEON 1 +#define HAVE_NEON_DOTPROD 0 +#define HAVE_NEON_I8MM 0 +#define HAVE_SVE 0 +#define HAVE_SVE2 0 #define HAVE_MIPS32 0 #define HAVE_DSPR2 0 #define HAVE_MSA 0 diff --git a/libvpx/source/config/ios/arm-neon/vpx_dsp_rtcd.h b/libvpx/source/config/ios/arm-neon/vpx_dsp_rtcd.h old mode 100644 new mode 100755 index 5f53e098fbce9c240022ccf1103dbdb00ed53d98..a39859cbb0728f1d4dcc23faed8df7809622e4ba --- a/libvpx/source/config/ios/arm-neon/vpx_dsp_rtcd.h +++ b/libvpx/source/config/ios/arm-neon/vpx_dsp_rtcd.h @@ -1181,28 +1181,20 @@ void vpx_post_proc_down_and_across_mb_row_neon(unsigned char* src, void vpx_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vpx_quantize_b vpx_quantize_b_neon void vpx_quantize_b_32x32_c(const tran_low_t* coeff_ptr, @@ -1663,6 +1655,292 @@ void vpx_sad8x8x4d_neon(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_sad8x8x4d vpx_sad8x8x4d_neon +unsigned int vpx_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x16 vpx_sad_skip_16x16_neon + +void vpx_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x16x4d vpx_sad_skip_16x16x4d_neon + +unsigned int vpx_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x32 vpx_sad_skip_16x32_neon + +void vpx_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x32x4d vpx_sad_skip_16x32x4d_neon + +unsigned int vpx_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x8 vpx_sad_skip_16x8_neon + +void vpx_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x8x4d vpx_sad_skip_16x8x4d_neon + +unsigned int vpx_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x16 vpx_sad_skip_32x16_neon + +void vpx_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x16x4d vpx_sad_skip_32x16x4d_neon + +unsigned int vpx_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x32 vpx_sad_skip_32x32_neon + +void vpx_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x32x4d vpx_sad_skip_32x32x4d_neon + +unsigned int vpx_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x64_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x64 vpx_sad_skip_32x64_neon + +void vpx_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x64x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x64x4d vpx_sad_skip_32x64x4d_neon + +unsigned int vpx_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_4x4_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x4 vpx_sad_skip_4x4_neon + +void vpx_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_4x4x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x4x4d vpx_sad_skip_4x4x4d_neon + +unsigned int vpx_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_4x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x8 vpx_sad_skip_4x8_neon + +void vpx_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_4x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x8x4d vpx_sad_skip_4x8x4d_neon + +unsigned int vpx_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_64x32 vpx_sad_skip_64x32_neon + +void vpx_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_64x32x4d vpx_sad_skip_64x32x4d_neon + +unsigned int vpx_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x64_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_64x64 vpx_sad_skip_64x64_neon + +void vpx_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x64x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_64x64x4d vpx_sad_skip_64x64x4d_neon + +unsigned int vpx_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x16 vpx_sad_skip_8x16_neon + +void vpx_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x16x4d vpx_sad_skip_8x16x4d_neon + +unsigned int vpx_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x4_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x4 vpx_sad_skip_8x4_neon + +void vpx_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x4x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x4x4d vpx_sad_skip_8x4x4d_neon + +unsigned int vpx_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x8 vpx_sad_skip_8x8_neon + +void vpx_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x8x4d vpx_sad_skip_8x8x4d_neon + int vpx_satd_c(const int16_t* coeff, int length); int vpx_satd_neon(const int16_t* coeff, int length); #define vpx_satd vpx_satd_neon @@ -1756,6 +2034,20 @@ void vpx_scaled_vert_c(const uint8_t* src, int h); #define vpx_scaled_vert vpx_scaled_vert_c +int64_t vpx_sse_c(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +int64_t vpx_sse_neon(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +#define vpx_sse vpx_sse_neon + uint32_t vpx_sub_pixel_avg_variance16x16_c(const uint8_t* src_ptr, int src_stride, int x_offset, diff --git a/libvpx/source/config/ios/arm-neon/vpx_scale_rtcd.h b/libvpx/source/config/ios/arm-neon/vpx_scale_rtcd.h old mode 100644 new mode 100755 diff --git a/libvpx/source/config/ios/arm64/vp8_rtcd.h b/libvpx/source/config/ios/arm64/vp8_rtcd.h old mode 100644 new mode 100755 index eb0b3a7cb44e16dc07e8b8f4985011dc9aa9fd16..102501094254bb09d784498a444bed4e77bf00a4 --- a/libvpx/source/config/ios/arm64/vp8_rtcd.h +++ b/libvpx/source/config/ios/arm64/vp8_rtcd.h @@ -83,36 +83,6 @@ void vp8_bilinear_predict8x8_neon(unsigned char* src_ptr, int dst_pitch); #define vp8_bilinear_predict8x8 vp8_bilinear_predict8x8_neon -void vp8_blend_b_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_b vp8_blend_b_c - -void vp8_blend_mb_inner_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_inner vp8_blend_mb_inner_c - -void vp8_blend_mb_outer_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_outer vp8_blend_mb_outer_c - int vp8_block_error_c(short* coeff, short* dqcoeff); #define vp8_block_error vp8_block_error_c diff --git a/libvpx/source/config/ios/arm64/vp9_rtcd.h b/libvpx/source/config/ios/arm64/vp9_rtcd.h old mode 100644 new mode 100755 index 8b1eaf7118999079707c57c10c757dd8add312e5..d9c47bef7fdaac11a51b3075dac87bc6ba0f216e --- a/libvpx/source/config/ios/arm64/vp9_rtcd.h +++ b/libvpx/source/config/ios/arm64/vp9_rtcd.h @@ -21,7 +21,9 @@ struct macroblockd; /* Encoder forward decls */ struct macroblock; -struct vp9_variance_vtable; +struct macroblock_plane; +struct vp9_sad_table; +struct ScanOrder; struct search_site_config; struct mv; union int_mv; @@ -39,7 +41,14 @@ int64_t vp9_block_error_neon(const tran_low_t* coeff, const tran_low_t* dqcoeff, intptr_t block_size, int64_t* ssz); -#define vp9_block_error vp9_block_error_neon +int64_t vp9_block_error_sve(const tran_low_t* coeff, + const tran_low_t* dqcoeff, + intptr_t block_size, + int64_t* ssz); +RTCD_EXTERN int64_t (*vp9_block_error)(const tran_low_t* coeff, + const tran_low_t* dqcoeff, + intptr_t block_size, + int64_t* ssz); int64_t vp9_block_error_fp_c(const tran_low_t* coeff, const tran_low_t* dqcoeff, @@ -47,7 +56,12 @@ int64_t vp9_block_error_fp_c(const tran_low_t* coeff, int64_t vp9_block_error_fp_neon(const tran_low_t* coeff, const tran_low_t* dqcoeff, int block_size); -#define vp9_block_error_fp vp9_block_error_fp_neon +int64_t vp9_block_error_fp_sve(const tran_low_t* coeff, + const tran_low_t* dqcoeff, + int block_size); +RTCD_EXTERN int64_t (*vp9_block_error_fp)(const tran_low_t* coeff, + const tran_low_t* dqcoeff, + int block_size); int vp9_denoiser_filter_c(const uint8_t* sig, int sig_stride, @@ -77,7 +91,7 @@ int vp9_diamond_search_sad_c(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); int vp9_diamond_search_sad_neon(const struct macroblock* x, const struct search_site_config* cfg, @@ -87,7 +101,7 @@ int vp9_diamond_search_sad_neon(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); #define vp9_diamond_search_sad vp9_diamond_search_sad_neon @@ -170,46 +184,38 @@ void vp9_iht8x8_64_add_neon(const tran_low_t* input, void vp9_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp vp9_quantize_fp_neon void vp9_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp_32x32 vp9_quantize_fp_32x32_neon void vp9_scale_and_extend_frame_c(const struct yv12_buffer_config* src, @@ -232,6 +238,15 @@ static void setup_rtcd_internal(void) { int flags = arm_cpu_caps(); (void)flags; + + vp9_block_error = vp9_block_error_neon; + if (flags & HAS_SVE) { + vp9_block_error = vp9_block_error_sve; + } + vp9_block_error_fp = vp9_block_error_fp_neon; + if (flags & HAS_SVE) { + vp9_block_error_fp = vp9_block_error_fp_sve; + } } #endif diff --git a/libvpx/source/config/ios/arm64/vpx_config.asm b/libvpx/source/config/ios/arm64/vpx_config.asm old mode 100644 new mode 100755 index b8329af59b5b7d4751ed70eb050aed6ad011715e..afcaccfcb73ed78c204ce931689e936bd6f32d93 --- a/libvpx/source/config/ios/arm64/vpx_config.asm +++ b/libvpx/source/config/ios/arm64/vpx_config.asm @@ -4,6 +4,8 @@ .syntax unified .equ VPX_ARCH_ARM , 1 .equ ARCH_ARM , 1 +.equ VPX_ARCH_AARCH64 , 1 +.equ ARCH_AARCH64 , 1 .equ VPX_ARCH_MIPS , 0 .equ ARCH_MIPS , 0 .equ VPX_ARCH_X86 , 0 @@ -14,8 +16,12 @@ .equ ARCH_PPC , 0 .equ VPX_ARCH_LOONGARCH , 0 .equ ARCH_LOONGARCH , 0 -.equ HAVE_NEON , 1 .equ HAVE_NEON_ASM , 0 +.equ HAVE_NEON , 1 +.equ HAVE_NEON_DOTPROD , 1 +.equ HAVE_NEON_I8MM , 1 +.equ HAVE_SVE , 1 +.equ HAVE_SVE2 , 1 .equ HAVE_MIPS32 , 0 .equ HAVE_DSPR2 , 0 .equ HAVE_MSA , 0 @@ -54,7 +60,7 @@ .equ CONFIG_DEBUG_LIBS , 0 .equ CONFIG_DEQUANT_TOKENS , 0 .equ CONFIG_DC_RECON , 0 -.equ CONFIG_RUNTIME_CPU_DETECT , 0 +.equ CONFIG_RUNTIME_CPU_DETECT , 1 .equ CONFIG_POSTPROC , 1 .equ CONFIG_VP9_POSTPROC , 1 .equ CONFIG_MULTITHREAD , 1 diff --git a/libvpx/source/config/ios/arm64/vpx_config.c b/libvpx/source/config/ios/arm64/vpx_config.c old mode 100644 new mode 100755 diff --git a/libvpx/source/config/ios/arm64/vpx_config.h b/libvpx/source/config/ios/arm64/vpx_config.h old mode 100644 new mode 100755 index ed6a89d6b39f1003cb41e0664d5bd65f248cf808..39bc1e6f09283fc2b38da8df41c964b38e2e165b --- a/libvpx/source/config/ios/arm64/vpx_config.h +++ b/libvpx/source/config/ios/arm64/vpx_config.h @@ -12,6 +12,8 @@ #define INLINE inline #define VPX_ARCH_ARM 1 #define ARCH_ARM 1 +#define VPX_ARCH_AARCH64 1 +#define ARCH_AARCH64 1 #define VPX_ARCH_MIPS 0 #define ARCH_MIPS 0 #define VPX_ARCH_X86 0 @@ -22,8 +24,12 @@ #define ARCH_PPC 0 #define VPX_ARCH_LOONGARCH 0 #define ARCH_LOONGARCH 0 -#define HAVE_NEON 1 #define HAVE_NEON_ASM 0 +#define HAVE_NEON 1 +#define HAVE_NEON_DOTPROD 1 +#define HAVE_NEON_I8MM 1 +#define HAVE_SVE 1 +#define HAVE_SVE2 1 #define HAVE_MIPS32 0 #define HAVE_DSPR2 0 #define HAVE_MSA 0 @@ -62,7 +68,7 @@ #define CONFIG_DEBUG_LIBS 0 #define CONFIG_DEQUANT_TOKENS 0 #define CONFIG_DC_RECON 0 -#define CONFIG_RUNTIME_CPU_DETECT 0 +#define CONFIG_RUNTIME_CPU_DETECT 1 #define CONFIG_POSTPROC 1 #define CONFIG_VP9_POSTPROC 1 #define CONFIG_MULTITHREAD 1 diff --git a/libvpx/source/config/ios/arm64/vpx_dsp_rtcd.h b/libvpx/source/config/ios/arm64/vpx_dsp_rtcd.h old mode 100644 new mode 100755 index 5f53e098fbce9c240022ccf1103dbdb00ed53d98..0e5bfd955c85e41b1e1d30986f16e5fe61ae153f --- a/libvpx/source/config/ios/arm64/vpx_dsp_rtcd.h +++ b/libvpx/source/config/ios/arm64/vpx_dsp_rtcd.h @@ -68,7 +68,39 @@ void vpx_convolve8_neon(const uint8_t* src, int y_step_q4, int w, int h); -#define vpx_convolve8 vpx_convolve8_neon +void vpx_convolve8_neon_dotprod(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_convolve8_neon_i8mm(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +RTCD_EXTERN void (*vpx_convolve8)(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); void vpx_convolve8_avg_c(const uint8_t* src, ptrdiff_t src_stride, @@ -92,7 +124,39 @@ void vpx_convolve8_avg_neon(const uint8_t* src, int y_step_q4, int w, int h); -#define vpx_convolve8_avg vpx_convolve8_avg_neon +void vpx_convolve8_avg_neon_dotprod(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_convolve8_avg_neon_i8mm(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +RTCD_EXTERN void (*vpx_convolve8_avg)(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); void vpx_convolve8_avg_horiz_c(const uint8_t* src, ptrdiff_t src_stride, @@ -116,7 +180,39 @@ void vpx_convolve8_avg_horiz_neon(const uint8_t* src, int y_step_q4, int w, int h); -#define vpx_convolve8_avg_horiz vpx_convolve8_avg_horiz_neon +void vpx_convolve8_avg_horiz_neon_dotprod(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_convolve8_avg_horiz_neon_i8mm(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +RTCD_EXTERN void (*vpx_convolve8_avg_horiz)(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); void vpx_convolve8_avg_vert_c(const uint8_t* src, ptrdiff_t src_stride, @@ -140,7 +236,39 @@ void vpx_convolve8_avg_vert_neon(const uint8_t* src, int y_step_q4, int w, int h); -#define vpx_convolve8_avg_vert vpx_convolve8_avg_vert_neon +void vpx_convolve8_avg_vert_neon_dotprod(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_convolve8_avg_vert_neon_i8mm(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +RTCD_EXTERN void (*vpx_convolve8_avg_vert)(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); void vpx_convolve8_horiz_c(const uint8_t* src, ptrdiff_t src_stride, @@ -164,7 +292,39 @@ void vpx_convolve8_horiz_neon(const uint8_t* src, int y_step_q4, int w, int h); -#define vpx_convolve8_horiz vpx_convolve8_horiz_neon +void vpx_convolve8_horiz_neon_dotprod(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_convolve8_horiz_neon_i8mm(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +RTCD_EXTERN void (*vpx_convolve8_horiz)(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); void vpx_convolve8_vert_c(const uint8_t* src, ptrdiff_t src_stride, @@ -188,7 +348,39 @@ void vpx_convolve8_vert_neon(const uint8_t* src, int y_step_q4, int w, int h); -#define vpx_convolve8_vert vpx_convolve8_vert_neon +void vpx_convolve8_vert_neon_dotprod(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_convolve8_vert_neon_i8mm(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +RTCD_EXTERN void (*vpx_convolve8_vert)(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); void vpx_convolve_avg_c(const uint8_t* src, ptrdiff_t src_stride, @@ -700,7 +892,18 @@ void vpx_get16x16var_neon(const uint8_t* src_ptr, int ref_stride, unsigned int* sse, int* sum); -#define vpx_get16x16var vpx_get16x16var_neon +void vpx_get16x16var_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); +RTCD_EXTERN void (*vpx_get16x16var)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); unsigned int vpx_get4x4sse_cs_c(const unsigned char* src_ptr, int src_stride, @@ -710,7 +913,14 @@ unsigned int vpx_get4x4sse_cs_neon(const unsigned char* src_ptr, int src_stride, const unsigned char* ref_ptr, int ref_stride); -#define vpx_get4x4sse_cs vpx_get4x4sse_cs_neon +unsigned int vpx_get4x4sse_cs_neon_dotprod(const unsigned char* src_ptr, + int src_stride, + const unsigned char* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_get4x4sse_cs)(const unsigned char* src_ptr, + int src_stride, + const unsigned char* ref_ptr, + int ref_stride); void vpx_get8x8var_c(const uint8_t* src_ptr, int src_stride, @@ -724,7 +934,18 @@ void vpx_get8x8var_neon(const uint8_t* src_ptr, int ref_stride, unsigned int* sse, int* sum); -#define vpx_get8x8var vpx_get8x8var_neon +void vpx_get8x8var_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); +RTCD_EXTERN void (*vpx_get8x8var)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); unsigned int vpx_get_mb_ss_c(const int16_t*); #define vpx_get_mb_ss vpx_get_mb_ss_c @@ -1115,7 +1336,16 @@ unsigned int vpx_mse16x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_mse16x16 vpx_mse16x16_neon +unsigned int vpx_mse16x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_mse16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_mse16x8_c(const uint8_t* src_ptr, int src_stride, @@ -1127,7 +1357,16 @@ unsigned int vpx_mse16x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_mse16x8 vpx_mse16x8_neon +unsigned int vpx_mse16x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_mse16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_mse8x16_c(const uint8_t* src_ptr, int src_stride, @@ -1139,7 +1378,16 @@ unsigned int vpx_mse8x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_mse8x16 vpx_mse8x16_neon +unsigned int vpx_mse8x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_mse8x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_mse8x8_c(const uint8_t* src_ptr, int src_stride, @@ -1151,7 +1399,16 @@ unsigned int vpx_mse8x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_mse8x8 vpx_mse8x8_neon +unsigned int vpx_mse8x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_mse8x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); void vpx_plane_add_noise_c(uint8_t* start, const int8_t* noise, @@ -1181,28 +1438,20 @@ void vpx_post_proc_down_and_across_mb_row_neon(unsigned char* src, void vpx_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vpx_quantize_b vpx_quantize_b_neon void vpx_quantize_b_32x32_c(const tran_low_t* coeff_ptr, @@ -1229,7 +1478,14 @@ unsigned int vpx_sad16x16_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad16x16 vpx_sad16x16_neon +unsigned int vpx_sad16x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad16x16_avg_c(const uint8_t* src_ptr, int src_stride, @@ -1241,7 +1497,16 @@ unsigned int vpx_sad16x16_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad16x16_avg vpx_sad16x16_avg_neon +unsigned int vpx_sad16x16_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad16x16_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad16x16x4d_c(const uint8_t* src_ptr, int src_stride, @@ -1253,7 +1518,16 @@ void vpx_sad16x16x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad16x16x4d vpx_sad16x16x4d_neon +void vpx_sad16x16x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad16x16x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad16x32_c(const uint8_t* src_ptr, int src_stride, @@ -1263,7 +1537,14 @@ unsigned int vpx_sad16x32_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad16x32 vpx_sad16x32_neon +unsigned int vpx_sad16x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad16x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad16x32_avg_c(const uint8_t* src_ptr, int src_stride, @@ -1275,7 +1556,16 @@ unsigned int vpx_sad16x32_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad16x32_avg vpx_sad16x32_avg_neon +unsigned int vpx_sad16x32_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad16x32_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad16x32x4d_c(const uint8_t* src_ptr, int src_stride, @@ -1287,7 +1577,16 @@ void vpx_sad16x32x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad16x32x4d vpx_sad16x32x4d_neon +void vpx_sad16x32x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad16x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad16x8_c(const uint8_t* src_ptr, int src_stride, @@ -1297,7 +1596,14 @@ unsigned int vpx_sad16x8_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad16x8 vpx_sad16x8_neon +unsigned int vpx_sad16x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad16x8_avg_c(const uint8_t* src_ptr, int src_stride, @@ -1309,7 +1615,16 @@ unsigned int vpx_sad16x8_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad16x8_avg vpx_sad16x8_avg_neon +unsigned int vpx_sad16x8_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad16x8_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad16x8x4d_c(const uint8_t* src_ptr, int src_stride, @@ -1321,7 +1636,16 @@ void vpx_sad16x8x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad16x8x4d vpx_sad16x8x4d_neon +void vpx_sad16x8x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad16x8x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad32x16_c(const uint8_t* src_ptr, int src_stride, @@ -1331,7 +1655,14 @@ unsigned int vpx_sad32x16_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad32x16 vpx_sad32x16_neon +unsigned int vpx_sad32x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad32x16_avg_c(const uint8_t* src_ptr, int src_stride, @@ -1343,7 +1674,16 @@ unsigned int vpx_sad32x16_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad32x16_avg vpx_sad32x16_avg_neon +unsigned int vpx_sad32x16_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad32x16_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad32x16x4d_c(const uint8_t* src_ptr, int src_stride, @@ -1355,7 +1695,16 @@ void vpx_sad32x16x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad32x16x4d vpx_sad32x16x4d_neon +void vpx_sad32x16x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad32x16x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad32x32_c(const uint8_t* src_ptr, int src_stride, @@ -1365,7 +1714,14 @@ unsigned int vpx_sad32x32_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad32x32 vpx_sad32x32_neon +unsigned int vpx_sad32x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad32x32_avg_c(const uint8_t* src_ptr, int src_stride, @@ -1377,7 +1733,16 @@ unsigned int vpx_sad32x32_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad32x32_avg vpx_sad32x32_avg_neon +unsigned int vpx_sad32x32_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad32x32_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad32x32x4d_c(const uint8_t* src_ptr, int src_stride, @@ -1389,7 +1754,16 @@ void vpx_sad32x32x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad32x32x4d vpx_sad32x32x4d_neon +void vpx_sad32x32x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad32x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad32x64_c(const uint8_t* src_ptr, int src_stride, @@ -1399,7 +1773,14 @@ unsigned int vpx_sad32x64_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad32x64 vpx_sad32x64_neon +unsigned int vpx_sad32x64_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad32x64_avg_c(const uint8_t* src_ptr, int src_stride, @@ -1411,7 +1792,16 @@ unsigned int vpx_sad32x64_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad32x64_avg vpx_sad32x64_avg_neon +unsigned int vpx_sad32x64_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad32x64_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad32x64x4d_c(const uint8_t* src_ptr, int src_stride, @@ -1423,7 +1813,16 @@ void vpx_sad32x64x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad32x64x4d vpx_sad32x64x4d_neon +void vpx_sad32x64x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad32x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad4x4_c(const uint8_t* src_ptr, int src_stride, @@ -1501,7 +1900,14 @@ unsigned int vpx_sad64x32_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad64x32 vpx_sad64x32_neon +unsigned int vpx_sad64x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad64x32_avg_c(const uint8_t* src_ptr, int src_stride, @@ -1513,7 +1919,16 @@ unsigned int vpx_sad64x32_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad64x32_avg vpx_sad64x32_avg_neon +unsigned int vpx_sad64x32_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad64x32_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad64x32x4d_c(const uint8_t* src_ptr, int src_stride, @@ -1525,7 +1940,16 @@ void vpx_sad64x32x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad64x32x4d vpx_sad64x32x4d_neon +void vpx_sad64x32x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad64x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad64x64_c(const uint8_t* src_ptr, int src_stride, @@ -1535,7 +1959,14 @@ unsigned int vpx_sad64x64_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad64x64 vpx_sad64x64_neon +unsigned int vpx_sad64x64_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad64x64_avg_c(const uint8_t* src_ptr, int src_stride, @@ -1547,7 +1978,16 @@ unsigned int vpx_sad64x64_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad64x64_avg vpx_sad64x64_avg_neon +unsigned int vpx_sad64x64_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad64x64_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad64x64x4d_c(const uint8_t* src_ptr, int src_stride, @@ -1559,7 +1999,16 @@ void vpx_sad64x64x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad64x64x4d vpx_sad64x64x4d_neon +void vpx_sad64x64x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad64x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad8x16_c(const uint8_t* src_ptr, int src_stride, @@ -1663,6 +2112,420 @@ void vpx_sad8x8x4d_neon(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_sad8x8x4d vpx_sad8x8x4d_neon +unsigned int vpx_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x16x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_16x16x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_16x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x32x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_16x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x8x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_16x8x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x16x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x16x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x32x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x64_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x64_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x64x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x64x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_4x4_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x4 vpx_sad_skip_4x4_neon + +void vpx_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_4x4x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x4x4d vpx_sad_skip_4x4x4d_neon + +unsigned int vpx_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_4x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x8 vpx_sad_skip_4x8_neon + +void vpx_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_4x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x8x4d vpx_sad_skip_4x8x4d_neon + +unsigned int vpx_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x32x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_64x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x64_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x64_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x64x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x64x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_64x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x16 vpx_sad_skip_8x16_neon + +void vpx_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x16x4d vpx_sad_skip_8x16x4d_neon + +unsigned int vpx_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x4_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x4 vpx_sad_skip_8x4_neon + +void vpx_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x4x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x4x4d vpx_sad_skip_8x4x4d_neon + +unsigned int vpx_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x8 vpx_sad_skip_8x8_neon + +void vpx_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x8x4d vpx_sad_skip_8x8x4d_neon + int vpx_satd_c(const int16_t* coeff, int length); int vpx_satd_neon(const int16_t* coeff, int length); #define vpx_satd vpx_satd_neon @@ -1756,6 +2619,31 @@ void vpx_scaled_vert_c(const uint8_t* src, int h); #define vpx_scaled_vert vpx_scaled_vert_c +int64_t vpx_sse_c(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +int64_t vpx_sse_neon(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +int64_t vpx_sse_neon_dotprod(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +RTCD_EXTERN int64_t (*vpx_sse)(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); + uint32_t vpx_sub_pixel_avg_variance16x16_c(const uint8_t* src_ptr, int src_stride, int x_offset, @@ -2218,7 +3106,10 @@ void vpx_subtract_block_neon(int rows, uint64_t vpx_sum_squares_2d_i16_c(const int16_t* src, int stride, int size); uint64_t vpx_sum_squares_2d_i16_neon(const int16_t* src, int stride, int size); -#define vpx_sum_squares_2d_i16 vpx_sum_squares_2d_i16_neon +uint64_t vpx_sum_squares_2d_i16_sve(const int16_t* src, int stride, int size); +RTCD_EXTERN uint64_t (*vpx_sum_squares_2d_i16)(const int16_t* src, + int stride, + int size); void vpx_tm_predictor_16x16_c(uint8_t* dst, ptrdiff_t stride, @@ -2310,7 +3201,16 @@ unsigned int vpx_variance16x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance16x16 vpx_variance16x16_neon +unsigned int vpx_variance16x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance16x32_c(const uint8_t* src_ptr, int src_stride, @@ -2322,7 +3222,16 @@ unsigned int vpx_variance16x32_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance16x32 vpx_variance16x32_neon +unsigned int vpx_variance16x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance16x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance16x8_c(const uint8_t* src_ptr, int src_stride, @@ -2334,7 +3243,16 @@ unsigned int vpx_variance16x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance16x8 vpx_variance16x8_neon +unsigned int vpx_variance16x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance32x16_c(const uint8_t* src_ptr, int src_stride, @@ -2346,7 +3264,16 @@ unsigned int vpx_variance32x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance32x16 vpx_variance32x16_neon +unsigned int vpx_variance32x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance32x32_c(const uint8_t* src_ptr, int src_stride, @@ -2358,7 +3285,16 @@ unsigned int vpx_variance32x32_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance32x32 vpx_variance32x32_neon +unsigned int vpx_variance32x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance32x64_c(const uint8_t* src_ptr, int src_stride, @@ -2370,7 +3306,16 @@ unsigned int vpx_variance32x64_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance32x64 vpx_variance32x64_neon +unsigned int vpx_variance32x64_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance4x4_c(const uint8_t* src_ptr, int src_stride, @@ -2382,7 +3327,16 @@ unsigned int vpx_variance4x4_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance4x4 vpx_variance4x4_neon +unsigned int vpx_variance4x4_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance4x4)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance4x8_c(const uint8_t* src_ptr, int src_stride, @@ -2394,7 +3348,16 @@ unsigned int vpx_variance4x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance4x8 vpx_variance4x8_neon +unsigned int vpx_variance4x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance4x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance64x32_c(const uint8_t* src_ptr, int src_stride, @@ -2406,7 +3369,16 @@ unsigned int vpx_variance64x32_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance64x32 vpx_variance64x32_neon +unsigned int vpx_variance64x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance64x64_c(const uint8_t* src_ptr, int src_stride, @@ -2418,7 +3390,16 @@ unsigned int vpx_variance64x64_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance64x64 vpx_variance64x64_neon +unsigned int vpx_variance64x64_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance8x16_c(const uint8_t* src_ptr, int src_stride, @@ -2430,7 +3411,16 @@ unsigned int vpx_variance8x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance8x16 vpx_variance8x16_neon +unsigned int vpx_variance8x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance8x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance8x4_c(const uint8_t* src_ptr, int src_stride, @@ -2442,7 +3432,16 @@ unsigned int vpx_variance8x4_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance8x4 vpx_variance8x4_neon +unsigned int vpx_variance8x4_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance8x4)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance8x8_c(const uint8_t* src_ptr, int src_stride, @@ -2454,7 +3453,16 @@ unsigned int vpx_variance8x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance8x8 vpx_variance8x8_neon +unsigned int vpx_variance8x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance8x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); void vpx_ve_predictor_4x4_c(uint8_t* dst, ptrdiff_t stride, @@ -2476,6 +3484,297 @@ static void setup_rtcd_internal(void) { int flags = arm_cpu_caps(); (void)flags; + + vpx_convolve8 = vpx_convolve8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_convolve8 = vpx_convolve8_neon_dotprod; + } + if (flags & HAS_NEON_I8MM) { + vpx_convolve8 = vpx_convolve8_neon_i8mm; + } + vpx_convolve8_avg = vpx_convolve8_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_convolve8_avg = vpx_convolve8_avg_neon_dotprod; + } + if (flags & HAS_NEON_I8MM) { + vpx_convolve8_avg = vpx_convolve8_avg_neon_i8mm; + } + vpx_convolve8_avg_horiz = vpx_convolve8_avg_horiz_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_convolve8_avg_horiz = vpx_convolve8_avg_horiz_neon_dotprod; + } + if (flags & HAS_NEON_I8MM) { + vpx_convolve8_avg_horiz = vpx_convolve8_avg_horiz_neon_i8mm; + } + vpx_convolve8_avg_vert = vpx_convolve8_avg_vert_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_convolve8_avg_vert = vpx_convolve8_avg_vert_neon_dotprod; + } + if (flags & HAS_NEON_I8MM) { + vpx_convolve8_avg_vert = vpx_convolve8_avg_vert_neon_i8mm; + } + vpx_convolve8_horiz = vpx_convolve8_horiz_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_convolve8_horiz = vpx_convolve8_horiz_neon_dotprod; + } + if (flags & HAS_NEON_I8MM) { + vpx_convolve8_horiz = vpx_convolve8_horiz_neon_i8mm; + } + vpx_convolve8_vert = vpx_convolve8_vert_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_convolve8_vert = vpx_convolve8_vert_neon_dotprod; + } + if (flags & HAS_NEON_I8MM) { + vpx_convolve8_vert = vpx_convolve8_vert_neon_i8mm; + } + vpx_get16x16var = vpx_get16x16var_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_get16x16var = vpx_get16x16var_neon_dotprod; + } + vpx_get4x4sse_cs = vpx_get4x4sse_cs_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_get4x4sse_cs = vpx_get4x4sse_cs_neon_dotprod; + } + vpx_get8x8var = vpx_get8x8var_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_get8x8var = vpx_get8x8var_neon_dotprod; + } + vpx_mse16x16 = vpx_mse16x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_mse16x16 = vpx_mse16x16_neon_dotprod; + } + vpx_mse16x8 = vpx_mse16x8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_mse16x8 = vpx_mse16x8_neon_dotprod; + } + vpx_mse8x16 = vpx_mse8x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_mse8x16 = vpx_mse8x16_neon_dotprod; + } + vpx_mse8x8 = vpx_mse8x8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_mse8x8 = vpx_mse8x8_neon_dotprod; + } + vpx_sad16x16 = vpx_sad16x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x16 = vpx_sad16x16_neon_dotprod; + } + vpx_sad16x16_avg = vpx_sad16x16_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x16_avg = vpx_sad16x16_avg_neon_dotprod; + } + vpx_sad16x16x4d = vpx_sad16x16x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x16x4d = vpx_sad16x16x4d_neon_dotprod; + } + vpx_sad16x32 = vpx_sad16x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x32 = vpx_sad16x32_neon_dotprod; + } + vpx_sad16x32_avg = vpx_sad16x32_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x32_avg = vpx_sad16x32_avg_neon_dotprod; + } + vpx_sad16x32x4d = vpx_sad16x32x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x32x4d = vpx_sad16x32x4d_neon_dotprod; + } + vpx_sad16x8 = vpx_sad16x8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x8 = vpx_sad16x8_neon_dotprod; + } + vpx_sad16x8_avg = vpx_sad16x8_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x8_avg = vpx_sad16x8_avg_neon_dotprod; + } + vpx_sad16x8x4d = vpx_sad16x8x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x8x4d = vpx_sad16x8x4d_neon_dotprod; + } + vpx_sad32x16 = vpx_sad32x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x16 = vpx_sad32x16_neon_dotprod; + } + vpx_sad32x16_avg = vpx_sad32x16_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x16_avg = vpx_sad32x16_avg_neon_dotprod; + } + vpx_sad32x16x4d = vpx_sad32x16x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x16x4d = vpx_sad32x16x4d_neon_dotprod; + } + vpx_sad32x32 = vpx_sad32x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x32 = vpx_sad32x32_neon_dotprod; + } + vpx_sad32x32_avg = vpx_sad32x32_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x32_avg = vpx_sad32x32_avg_neon_dotprod; + } + vpx_sad32x32x4d = vpx_sad32x32x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x32x4d = vpx_sad32x32x4d_neon_dotprod; + } + vpx_sad32x64 = vpx_sad32x64_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x64 = vpx_sad32x64_neon_dotprod; + } + vpx_sad32x64_avg = vpx_sad32x64_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x64_avg = vpx_sad32x64_avg_neon_dotprod; + } + vpx_sad32x64x4d = vpx_sad32x64x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x64x4d = vpx_sad32x64x4d_neon_dotprod; + } + vpx_sad64x32 = vpx_sad64x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad64x32 = vpx_sad64x32_neon_dotprod; + } + vpx_sad64x32_avg = vpx_sad64x32_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad64x32_avg = vpx_sad64x32_avg_neon_dotprod; + } + vpx_sad64x32x4d = vpx_sad64x32x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad64x32x4d = vpx_sad64x32x4d_neon_dotprod; + } + vpx_sad64x64 = vpx_sad64x64_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad64x64 = vpx_sad64x64_neon_dotprod; + } + vpx_sad64x64_avg = vpx_sad64x64_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad64x64_avg = vpx_sad64x64_avg_neon_dotprod; + } + vpx_sad64x64x4d = vpx_sad64x64x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad64x64x4d = vpx_sad64x64x4d_neon_dotprod; + } + vpx_sad_skip_16x16 = vpx_sad_skip_16x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_16x16 = vpx_sad_skip_16x16_neon_dotprod; + } + vpx_sad_skip_16x16x4d = vpx_sad_skip_16x16x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_16x16x4d = vpx_sad_skip_16x16x4d_neon_dotprod; + } + vpx_sad_skip_16x32 = vpx_sad_skip_16x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_16x32 = vpx_sad_skip_16x32_neon_dotprod; + } + vpx_sad_skip_16x32x4d = vpx_sad_skip_16x32x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_16x32x4d = vpx_sad_skip_16x32x4d_neon_dotprod; + } + vpx_sad_skip_16x8 = vpx_sad_skip_16x8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_16x8 = vpx_sad_skip_16x8_neon_dotprod; + } + vpx_sad_skip_16x8x4d = vpx_sad_skip_16x8x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_16x8x4d = vpx_sad_skip_16x8x4d_neon_dotprod; + } + vpx_sad_skip_32x16 = vpx_sad_skip_32x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_32x16 = vpx_sad_skip_32x16_neon_dotprod; + } + vpx_sad_skip_32x16x4d = vpx_sad_skip_32x16x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_32x16x4d = vpx_sad_skip_32x16x4d_neon_dotprod; + } + vpx_sad_skip_32x32 = vpx_sad_skip_32x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_32x32 = vpx_sad_skip_32x32_neon_dotprod; + } + vpx_sad_skip_32x32x4d = vpx_sad_skip_32x32x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_32x32x4d = vpx_sad_skip_32x32x4d_neon_dotprod; + } + vpx_sad_skip_32x64 = vpx_sad_skip_32x64_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_32x64 = vpx_sad_skip_32x64_neon_dotprod; + } + vpx_sad_skip_32x64x4d = vpx_sad_skip_32x64x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_32x64x4d = vpx_sad_skip_32x64x4d_neon_dotprod; + } + vpx_sad_skip_64x32 = vpx_sad_skip_64x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_64x32 = vpx_sad_skip_64x32_neon_dotprod; + } + vpx_sad_skip_64x32x4d = vpx_sad_skip_64x32x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_64x32x4d = vpx_sad_skip_64x32x4d_neon_dotprod; + } + vpx_sad_skip_64x64 = vpx_sad_skip_64x64_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_64x64 = vpx_sad_skip_64x64_neon_dotprod; + } + vpx_sad_skip_64x64x4d = vpx_sad_skip_64x64x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_64x64x4d = vpx_sad_skip_64x64x4d_neon_dotprod; + } + vpx_sse = vpx_sse_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sse = vpx_sse_neon_dotprod; + } + vpx_sum_squares_2d_i16 = vpx_sum_squares_2d_i16_neon; + if (flags & HAS_SVE) { + vpx_sum_squares_2d_i16 = vpx_sum_squares_2d_i16_sve; + } + vpx_variance16x16 = vpx_variance16x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance16x16 = vpx_variance16x16_neon_dotprod; + } + vpx_variance16x32 = vpx_variance16x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance16x32 = vpx_variance16x32_neon_dotprod; + } + vpx_variance16x8 = vpx_variance16x8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance16x8 = vpx_variance16x8_neon_dotprod; + } + vpx_variance32x16 = vpx_variance32x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance32x16 = vpx_variance32x16_neon_dotprod; + } + vpx_variance32x32 = vpx_variance32x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance32x32 = vpx_variance32x32_neon_dotprod; + } + vpx_variance32x64 = vpx_variance32x64_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance32x64 = vpx_variance32x64_neon_dotprod; + } + vpx_variance4x4 = vpx_variance4x4_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance4x4 = vpx_variance4x4_neon_dotprod; + } + vpx_variance4x8 = vpx_variance4x8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance4x8 = vpx_variance4x8_neon_dotprod; + } + vpx_variance64x32 = vpx_variance64x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance64x32 = vpx_variance64x32_neon_dotprod; + } + vpx_variance64x64 = vpx_variance64x64_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance64x64 = vpx_variance64x64_neon_dotprod; + } + vpx_variance8x16 = vpx_variance8x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance8x16 = vpx_variance8x16_neon_dotprod; + } + vpx_variance8x4 = vpx_variance8x4_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance8x4 = vpx_variance8x4_neon_dotprod; + } + vpx_variance8x8 = vpx_variance8x8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance8x8 = vpx_variance8x8_neon_dotprod; + } } #endif diff --git a/libvpx/source/config/ios/arm64/vpx_scale_rtcd.h b/libvpx/source/config/ios/arm64/vpx_scale_rtcd.h old mode 100644 new mode 100755 diff --git a/libvpx/source/config/linux/arm-neon-cpu-detect/vp8_rtcd.h b/libvpx/source/config/linux/arm-neon-cpu-detect/vp8_rtcd.h old mode 100644 new mode 100755 index 27bf70021fa4d84209afe4f4ffb9b1f6c8c672d0..2a17959a57d5101151b5413feb356c45a9aedb02 --- a/libvpx/source/config/linux/arm-neon-cpu-detect/vp8_rtcd.h +++ b/libvpx/source/config/linux/arm-neon-cpu-detect/vp8_rtcd.h @@ -103,36 +103,6 @@ RTCD_EXTERN void (*vp8_bilinear_predict8x8)(unsigned char* src_ptr, unsigned char* dst_ptr, int dst_pitch); -void vp8_blend_b_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_b vp8_blend_b_c - -void vp8_blend_mb_inner_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_inner vp8_blend_mb_inner_c - -void vp8_blend_mb_outer_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_outer vp8_blend_mb_outer_c - int vp8_block_error_c(short* coeff, short* dqcoeff); #define vp8_block_error vp8_block_error_c diff --git a/libvpx/source/config/linux/arm-neon-cpu-detect/vp9_rtcd.h b/libvpx/source/config/linux/arm-neon-cpu-detect/vp9_rtcd.h old mode 100644 new mode 100755 index ea010dbe5c7387de5ff617d355476ec44f7b64df..654f4966fb4007ecc11a4ef68dffc7e54e5beb26 --- a/libvpx/source/config/linux/arm-neon-cpu-detect/vp9_rtcd.h +++ b/libvpx/source/config/linux/arm-neon-cpu-detect/vp9_rtcd.h @@ -21,7 +21,9 @@ struct macroblockd; /* Encoder forward decls */ struct macroblock; -struct vp9_variance_vtable; +struct macroblock_plane; +struct vp9_sad_table; +struct ScanOrder; struct search_site_config; struct mv; union int_mv; @@ -90,7 +92,7 @@ int vp9_diamond_search_sad_c(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); int vp9_diamond_search_sad_neon(const struct macroblock* x, const struct search_site_config* cfg, @@ -100,7 +102,7 @@ int vp9_diamond_search_sad_neon(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); RTCD_EXTERN int (*vp9_diamond_search_sad)( const struct macroblock* x, @@ -111,7 +113,7 @@ RTCD_EXTERN int (*vp9_diamond_search_sad)( int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); void vp9_fht16x16_c(const int16_t* input, @@ -211,65 +213,55 @@ RTCD_EXTERN void (*vp9_iht8x8_64_add)(const tran_low_t* input, void vp9_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_quantize_fp)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_quantize_fp)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_quantize_fp_32x32)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_quantize_fp_32x32)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vp9_scale_and_extend_frame_c(const struct yv12_buffer_config* src, struct yv12_buffer_config* dst, diff --git a/libvpx/source/config/linux/arm-neon-cpu-detect/vpx_config.asm b/libvpx/source/config/linux/arm-neon-cpu-detect/vpx_config.asm old mode 100644 new mode 100755 index f84a5bcfafa234dece39272a5297ffa0d5642f74..94ea5b371db8bed34d7fbaf5a302ed8bfa93ee1f --- a/libvpx/source/config/linux/arm-neon-cpu-detect/vpx_config.asm +++ b/libvpx/source/config/linux/arm-neon-cpu-detect/vpx_config.asm @@ -3,6 +3,8 @@ .syntax unified .equ VPX_ARCH_ARM , 1 .equ ARCH_ARM , 1 +.equ VPX_ARCH_AARCH64 , 0 +.equ ARCH_AARCH64 , 0 .equ VPX_ARCH_MIPS , 0 .equ ARCH_MIPS , 0 .equ VPX_ARCH_X86 , 0 @@ -13,8 +15,12 @@ .equ ARCH_PPC , 0 .equ VPX_ARCH_LOONGARCH , 0 .equ ARCH_LOONGARCH , 0 -.equ HAVE_NEON , 1 .equ HAVE_NEON_ASM , 1 +.equ HAVE_NEON , 1 +.equ HAVE_NEON_DOTPROD , 0 +.equ HAVE_NEON_I8MM , 0 +.equ HAVE_SVE , 0 +.equ HAVE_SVE2 , 0 .equ HAVE_MIPS32 , 0 .equ HAVE_DSPR2 , 0 .equ HAVE_MSA , 0 diff --git a/libvpx/source/config/linux/arm-neon-cpu-detect/vpx_config.c b/libvpx/source/config/linux/arm-neon-cpu-detect/vpx_config.c old mode 100644 new mode 100755 diff --git a/libvpx/source/config/linux/arm-neon-cpu-detect/vpx_config.h b/libvpx/source/config/linux/arm-neon-cpu-detect/vpx_config.h old mode 100644 new mode 100755 index e34c8c2314d6e5bbe263f73f05eb52959f3a719e..308226b6dd62a8fcd94e42547be4b20a2a6e55a5 --- a/libvpx/source/config/linux/arm-neon-cpu-detect/vpx_config.h +++ b/libvpx/source/config/linux/arm-neon-cpu-detect/vpx_config.h @@ -12,6 +12,8 @@ #define INLINE inline #define VPX_ARCH_ARM 1 #define ARCH_ARM 1 +#define VPX_ARCH_AARCH64 0 +#define ARCH_AARCH64 0 #define VPX_ARCH_MIPS 0 #define ARCH_MIPS 0 #define VPX_ARCH_X86 0 @@ -22,8 +24,12 @@ #define ARCH_PPC 0 #define VPX_ARCH_LOONGARCH 0 #define ARCH_LOONGARCH 0 -#define HAVE_NEON 1 #define HAVE_NEON_ASM 1 +#define HAVE_NEON 1 +#define HAVE_NEON_DOTPROD 0 +#define HAVE_NEON_I8MM 0 +#define HAVE_SVE 0 +#define HAVE_SVE2 0 #define HAVE_MIPS32 0 #define HAVE_DSPR2 0 #define HAVE_MSA 0 diff --git a/libvpx/source/config/linux/arm-neon-cpu-detect/vpx_dsp_rtcd.h b/libvpx/source/config/linux/arm-neon-cpu-detect/vpx_dsp_rtcd.h old mode 100644 new mode 100755 index a01df16dcb83ee6008c259dd18754955f4fbd7a5..a1f21454323cac02d9bab4e9a3386bf555763ca7 --- a/libvpx/source/config/linux/arm-neon-cpu-detect/vpx_dsp_rtcd.h +++ b/libvpx/source/config/linux/arm-neon-cpu-detect/vpx_dsp_rtcd.h @@ -1558,40 +1558,29 @@ RTCD_EXTERN void (*vpx_post_proc_down_and_across_mb_row)(unsigned char* src, void vpx_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vpx_quantize_b)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vpx_quantize_b)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vpx_quantize_b_32x32_c(const tran_low_t* coeff_ptr, const struct macroblock_plane* const mb_plane, @@ -2201,6 +2190,383 @@ RTCD_EXTERN void (*vpx_sad8x8x4d)(const uint8_t* src_ptr, int ref_stride, uint32_t sad_array[4]); +unsigned int vpx_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_16x16x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_16x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_16x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_16x8x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x16x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x64_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x64x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_4x4_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_4x4)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_4x4x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_4x4x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_4x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_4x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_4x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_4x8x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_64x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x64_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x64x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_64x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_8x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_8x16x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x4_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_8x4)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x4x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_8x4x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_8x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_8x8x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + int vpx_satd_c(const int16_t* coeff, int length); int vpx_satd_neon(const int16_t* coeff, int length); RTCD_EXTERN int (*vpx_satd)(const int16_t* coeff, int length); @@ -2304,6 +2670,25 @@ void vpx_scaled_vert_c(const uint8_t* src, int h); #define vpx_scaled_vert vpx_scaled_vert_c +int64_t vpx_sse_c(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +int64_t vpx_sse_neon(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +RTCD_EXTERN int64_t (*vpx_sse)(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); + uint32_t vpx_sub_pixel_avg_variance16x16_c(const uint8_t* src_ptr, int src_stride, int x_offset, @@ -3733,12 +4118,94 @@ static void setup_rtcd_internal(void) { vpx_sad8x8x4d = vpx_sad8x8x4d_c; if (flags & HAS_NEON) vpx_sad8x8x4d = vpx_sad8x8x4d_neon; + vpx_sad_skip_16x16 = vpx_sad_skip_16x16_c; + if (flags & HAS_NEON) + vpx_sad_skip_16x16 = vpx_sad_skip_16x16_neon; + vpx_sad_skip_16x16x4d = vpx_sad_skip_16x16x4d_c; + if (flags & HAS_NEON) + vpx_sad_skip_16x16x4d = vpx_sad_skip_16x16x4d_neon; + vpx_sad_skip_16x32 = vpx_sad_skip_16x32_c; + if (flags & HAS_NEON) + vpx_sad_skip_16x32 = vpx_sad_skip_16x32_neon; + vpx_sad_skip_16x32x4d = vpx_sad_skip_16x32x4d_c; + if (flags & HAS_NEON) + vpx_sad_skip_16x32x4d = vpx_sad_skip_16x32x4d_neon; + vpx_sad_skip_16x8 = vpx_sad_skip_16x8_c; + if (flags & HAS_NEON) + vpx_sad_skip_16x8 = vpx_sad_skip_16x8_neon; + vpx_sad_skip_16x8x4d = vpx_sad_skip_16x8x4d_c; + if (flags & HAS_NEON) + vpx_sad_skip_16x8x4d = vpx_sad_skip_16x8x4d_neon; + vpx_sad_skip_32x16 = vpx_sad_skip_32x16_c; + if (flags & HAS_NEON) + vpx_sad_skip_32x16 = vpx_sad_skip_32x16_neon; + vpx_sad_skip_32x16x4d = vpx_sad_skip_32x16x4d_c; + if (flags & HAS_NEON) + vpx_sad_skip_32x16x4d = vpx_sad_skip_32x16x4d_neon; + vpx_sad_skip_32x32 = vpx_sad_skip_32x32_c; + if (flags & HAS_NEON) + vpx_sad_skip_32x32 = vpx_sad_skip_32x32_neon; + vpx_sad_skip_32x32x4d = vpx_sad_skip_32x32x4d_c; + if (flags & HAS_NEON) + vpx_sad_skip_32x32x4d = vpx_sad_skip_32x32x4d_neon; + vpx_sad_skip_32x64 = vpx_sad_skip_32x64_c; + if (flags & HAS_NEON) + vpx_sad_skip_32x64 = vpx_sad_skip_32x64_neon; + vpx_sad_skip_32x64x4d = vpx_sad_skip_32x64x4d_c; + if (flags & HAS_NEON) + vpx_sad_skip_32x64x4d = vpx_sad_skip_32x64x4d_neon; + vpx_sad_skip_4x4 = vpx_sad_skip_4x4_c; + if (flags & HAS_NEON) + vpx_sad_skip_4x4 = vpx_sad_skip_4x4_neon; + vpx_sad_skip_4x4x4d = vpx_sad_skip_4x4x4d_c; + if (flags & HAS_NEON) + vpx_sad_skip_4x4x4d = vpx_sad_skip_4x4x4d_neon; + vpx_sad_skip_4x8 = vpx_sad_skip_4x8_c; + if (flags & HAS_NEON) + vpx_sad_skip_4x8 = vpx_sad_skip_4x8_neon; + vpx_sad_skip_4x8x4d = vpx_sad_skip_4x8x4d_c; + if (flags & HAS_NEON) + vpx_sad_skip_4x8x4d = vpx_sad_skip_4x8x4d_neon; + vpx_sad_skip_64x32 = vpx_sad_skip_64x32_c; + if (flags & HAS_NEON) + vpx_sad_skip_64x32 = vpx_sad_skip_64x32_neon; + vpx_sad_skip_64x32x4d = vpx_sad_skip_64x32x4d_c; + if (flags & HAS_NEON) + vpx_sad_skip_64x32x4d = vpx_sad_skip_64x32x4d_neon; + vpx_sad_skip_64x64 = vpx_sad_skip_64x64_c; + if (flags & HAS_NEON) + vpx_sad_skip_64x64 = vpx_sad_skip_64x64_neon; + vpx_sad_skip_64x64x4d = vpx_sad_skip_64x64x4d_c; + if (flags & HAS_NEON) + vpx_sad_skip_64x64x4d = vpx_sad_skip_64x64x4d_neon; + vpx_sad_skip_8x16 = vpx_sad_skip_8x16_c; + if (flags & HAS_NEON) + vpx_sad_skip_8x16 = vpx_sad_skip_8x16_neon; + vpx_sad_skip_8x16x4d = vpx_sad_skip_8x16x4d_c; + if (flags & HAS_NEON) + vpx_sad_skip_8x16x4d = vpx_sad_skip_8x16x4d_neon; + vpx_sad_skip_8x4 = vpx_sad_skip_8x4_c; + if (flags & HAS_NEON) + vpx_sad_skip_8x4 = vpx_sad_skip_8x4_neon; + vpx_sad_skip_8x4x4d = vpx_sad_skip_8x4x4d_c; + if (flags & HAS_NEON) + vpx_sad_skip_8x4x4d = vpx_sad_skip_8x4x4d_neon; + vpx_sad_skip_8x8 = vpx_sad_skip_8x8_c; + if (flags & HAS_NEON) + vpx_sad_skip_8x8 = vpx_sad_skip_8x8_neon; + vpx_sad_skip_8x8x4d = vpx_sad_skip_8x8x4d_c; + if (flags & HAS_NEON) + vpx_sad_skip_8x8x4d = vpx_sad_skip_8x8x4d_neon; vpx_satd = vpx_satd_c; if (flags & HAS_NEON) vpx_satd = vpx_satd_neon; vpx_scaled_2d = vpx_scaled_2d_c; if (flags & HAS_NEON) vpx_scaled_2d = vpx_scaled_2d_neon; + vpx_sse = vpx_sse_c; + if (flags & HAS_NEON) { + vpx_sse = vpx_sse_neon; + } vpx_sub_pixel_avg_variance16x16 = vpx_sub_pixel_avg_variance16x16_c; if (flags & HAS_NEON) vpx_sub_pixel_avg_variance16x16 = vpx_sub_pixel_avg_variance16x16_neon; diff --git a/libvpx/source/config/linux/arm-neon-cpu-detect/vpx_scale_rtcd.h b/libvpx/source/config/linux/arm-neon-cpu-detect/vpx_scale_rtcd.h old mode 100644 new mode 100755 diff --git a/libvpx/source/config/linux/arm-neon-highbd/vp8_rtcd.h b/libvpx/source/config/linux/arm-neon-highbd/vp8_rtcd.h old mode 100644 new mode 100755 index eb0b3a7cb44e16dc07e8b8f4985011dc9aa9fd16..102501094254bb09d784498a444bed4e77bf00a4 --- a/libvpx/source/config/linux/arm-neon-highbd/vp8_rtcd.h +++ b/libvpx/source/config/linux/arm-neon-highbd/vp8_rtcd.h @@ -83,36 +83,6 @@ void vp8_bilinear_predict8x8_neon(unsigned char* src_ptr, int dst_pitch); #define vp8_bilinear_predict8x8 vp8_bilinear_predict8x8_neon -void vp8_blend_b_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_b vp8_blend_b_c - -void vp8_blend_mb_inner_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_inner vp8_blend_mb_inner_c - -void vp8_blend_mb_outer_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_outer vp8_blend_mb_outer_c - int vp8_block_error_c(short* coeff, short* dqcoeff); #define vp8_block_error vp8_block_error_c diff --git a/libvpx/source/config/linux/arm-neon-highbd/vp9_rtcd.h b/libvpx/source/config/linux/arm-neon-highbd/vp9_rtcd.h old mode 100644 new mode 100755 index acfadf825c23143297ccacf420de551120482901..e64cb2c35ae41f8e525dc5c35e8b263b910bbad9 --- a/libvpx/source/config/linux/arm-neon-highbd/vp9_rtcd.h +++ b/libvpx/source/config/linux/arm-neon-highbd/vp9_rtcd.h @@ -21,7 +21,9 @@ struct macroblockd; /* Encoder forward decls */ struct macroblock; -struct vp9_variance_vtable; +struct macroblock_plane; +struct vp9_sad_table; +struct ScanOrder; struct search_site_config; struct mv; union int_mv; @@ -77,7 +79,7 @@ int vp9_diamond_search_sad_c(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); int vp9_diamond_search_sad_neon(const struct macroblock* x, const struct search_site_config* cfg, @@ -87,7 +89,7 @@ int vp9_diamond_search_sad_neon(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); #define vp9_diamond_search_sad vp9_diamond_search_sad_neon @@ -245,46 +247,40 @@ void vp9_highbd_post_proc_down_and_across_c(const uint16_t* src_ptr, void vp9_highbd_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_highbd_quantize_fp_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_highbd_quantize_fp vp9_highbd_quantize_fp_neon -void vp9_highbd_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -void vp9_highbd_quantize_fp_32x32_neon(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); +void vp9_highbd_quantize_fp_32x32_c( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); +void vp9_highbd_quantize_fp_32x32_neon( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); #define vp9_highbd_quantize_fp_32x32 vp9_highbd_quantize_fp_32x32_neon void vp9_highbd_temporal_filter_apply_c(const uint8_t* frame1, @@ -331,46 +327,38 @@ void vp9_iht8x8_64_add_neon(const tran_low_t* input, void vp9_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp vp9_quantize_fp_neon void vp9_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp_32x32 vp9_quantize_fp_32x32_neon void vp9_scale_and_extend_frame_c(const struct yv12_buffer_config* src, diff --git a/libvpx/source/config/linux/arm-neon-highbd/vpx_config.asm b/libvpx/source/config/linux/arm-neon-highbd/vpx_config.asm old mode 100644 new mode 100755 index 17faf085d6acd0a4c1557c19c6e2ceac074f9c01..d6f8d896a1e6a9685e19a33ea362b7e509788358 --- a/libvpx/source/config/linux/arm-neon-highbd/vpx_config.asm +++ b/libvpx/source/config/linux/arm-neon-highbd/vpx_config.asm @@ -3,6 +3,8 @@ .syntax unified .equ VPX_ARCH_ARM , 1 .equ ARCH_ARM , 1 +.equ VPX_ARCH_AARCH64 , 0 +.equ ARCH_AARCH64 , 0 .equ VPX_ARCH_MIPS , 0 .equ ARCH_MIPS , 0 .equ VPX_ARCH_X86 , 0 @@ -13,8 +15,12 @@ .equ ARCH_PPC , 0 .equ VPX_ARCH_LOONGARCH , 0 .equ ARCH_LOONGARCH , 0 -.equ HAVE_NEON , 1 .equ HAVE_NEON_ASM , 1 +.equ HAVE_NEON , 1 +.equ HAVE_NEON_DOTPROD , 0 +.equ HAVE_NEON_I8MM , 0 +.equ HAVE_SVE , 0 +.equ HAVE_SVE2 , 0 .equ HAVE_MIPS32 , 0 .equ HAVE_DSPR2 , 0 .equ HAVE_MSA , 0 diff --git a/libvpx/source/config/linux/arm-neon-highbd/vpx_config.c b/libvpx/source/config/linux/arm-neon-highbd/vpx_config.c old mode 100644 new mode 100755 index 86db589c379ed33ce94b5c5f20a8f3614856bc77..feea40546f0c84dd2751d398b2ed9abc2bc3f622 --- a/libvpx/source/config/linux/arm-neon-highbd/vpx_config.c +++ b/libvpx/source/config/linux/arm-neon-highbd/vpx_config.c @@ -6,5 +6,5 @@ /* in the file PATENTS. All contributing project authors may */ /* be found in the AUTHORS file in the root of the source tree. */ #include "vpx/vpx_codec.h" -static const char* const cfg = "--target=armv7-linux-gcc --enable-external-build --enable-postproc --enable-multi-res-encoding --enable-temporal-denoising --enable-vp9-temporal-denoising --enable-vp9-postproc --size-limit=16384x16384 --enable-realtime-only --disable-install-docs --disable-libyuv --enable-vp9-highbitdepth"; +static const char* const cfg = "--target=armv7-linux-gcc --disable-runtime-cpu-detect --enable-external-build --enable-postproc --enable-multi-res-encoding --enable-temporal-denoising --enable-vp9-temporal-denoising --enable-vp9-postproc --size-limit=16384x16384 --enable-realtime-only --disable-install-docs --disable-libyuv --enable-vp9-highbitdepth"; const char *vpx_codec_build_config(void) {return cfg;} diff --git a/libvpx/source/config/linux/arm-neon-highbd/vpx_config.h b/libvpx/source/config/linux/arm-neon-highbd/vpx_config.h old mode 100644 new mode 100755 index 64e6c90ebd3a73f785dd7a5716670aa65b06514b..337b10505c68fa6046b6d01eb97a0d4bdc0b90c3 --- a/libvpx/source/config/linux/arm-neon-highbd/vpx_config.h +++ b/libvpx/source/config/linux/arm-neon-highbd/vpx_config.h @@ -12,6 +12,8 @@ #define INLINE inline #define VPX_ARCH_ARM 1 #define ARCH_ARM 1 +#define VPX_ARCH_AARCH64 0 +#define ARCH_AARCH64 0 #define VPX_ARCH_MIPS 0 #define ARCH_MIPS 0 #define VPX_ARCH_X86 0 @@ -22,8 +24,12 @@ #define ARCH_PPC 0 #define VPX_ARCH_LOONGARCH 0 #define ARCH_LOONGARCH 0 -#define HAVE_NEON 1 #define HAVE_NEON_ASM 1 +#define HAVE_NEON 1 +#define HAVE_NEON_DOTPROD 0 +#define HAVE_NEON_I8MM 0 +#define HAVE_SVE 0 +#define HAVE_SVE2 0 #define HAVE_MIPS32 0 #define HAVE_DSPR2 0 #define HAVE_MSA 0 diff --git a/libvpx/source/config/linux/arm-neon-highbd/vpx_dsp_rtcd.h b/libvpx/source/config/linux/arm-neon-highbd/vpx_dsp_rtcd.h old mode 100644 new mode 100755 index 69d38d127483de538d08a76d48a4ad240f82d803..3a063dddd388a7137d6fbed46ed57dbca9602051 --- a/libvpx/source/config/linux/arm-neon-highbd/vpx_dsp_rtcd.h +++ b/libvpx/source/config/linux/arm-neon-highbd/vpx_dsp_rtcd.h @@ -4144,28 +4144,20 @@ void vpx_highbd_minmax_8x8_neon(const uint8_t* s8, void vpx_highbd_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_highbd_quantize_b_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vpx_highbd_quantize_b vpx_highbd_quantize_b_neon void vpx_highbd_quantize_b_32x32_c( @@ -4628,10 +4620,310 @@ void vpx_highbd_sad8x8x4d_neon(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_highbd_sad8x8x4d vpx_highbd_sad8x8x4d_neon +unsigned int vpx_highbd_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_16x16 vpx_highbd_sad_skip_16x16_neon + +void vpx_highbd_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_16x16x4d vpx_highbd_sad_skip_16x16x4d_neon + +unsigned int vpx_highbd_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_16x32 vpx_highbd_sad_skip_16x32_neon + +void vpx_highbd_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_16x32x4d vpx_highbd_sad_skip_16x32x4d_neon + +unsigned int vpx_highbd_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_16x8 vpx_highbd_sad_skip_16x8_neon + +void vpx_highbd_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_16x8x4d vpx_highbd_sad_skip_16x8x4d_neon + +unsigned int vpx_highbd_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_32x16 vpx_highbd_sad_skip_32x16_neon + +void vpx_highbd_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_32x16x4d vpx_highbd_sad_skip_32x16x4d_neon + +unsigned int vpx_highbd_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_32x32 vpx_highbd_sad_skip_32x32_neon + +void vpx_highbd_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_32x32x4d vpx_highbd_sad_skip_32x32x4d_neon + +unsigned int vpx_highbd_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x64_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_32x64 vpx_highbd_sad_skip_32x64_neon + +void vpx_highbd_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x64x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_32x64x4d vpx_highbd_sad_skip_32x64x4d_neon + +unsigned int vpx_highbd_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_4x4_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_4x4 vpx_highbd_sad_skip_4x4_neon + +void vpx_highbd_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_4x4x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_4x4x4d vpx_highbd_sad_skip_4x4x4d_neon + +unsigned int vpx_highbd_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_4x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_4x8 vpx_highbd_sad_skip_4x8_neon + +void vpx_highbd_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_4x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_4x8x4d vpx_highbd_sad_skip_4x8x4d_neon + +unsigned int vpx_highbd_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_64x32 vpx_highbd_sad_skip_64x32_neon + +void vpx_highbd_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_64x32x4d vpx_highbd_sad_skip_64x32x4d_neon + +unsigned int vpx_highbd_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x64_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_64x64 vpx_highbd_sad_skip_64x64_neon + +void vpx_highbd_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x64x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_64x64x4d vpx_highbd_sad_skip_64x64x4d_neon + +unsigned int vpx_highbd_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_8x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x16 vpx_highbd_sad_skip_8x16_neon + +void vpx_highbd_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_8x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x16x4d vpx_highbd_sad_skip_8x16x4d_neon + +unsigned int vpx_highbd_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_8x4_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x4 vpx_highbd_sad_skip_8x4_neon + +void vpx_highbd_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_8x4x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x4x4d vpx_highbd_sad_skip_8x4x4d_neon + +unsigned int vpx_highbd_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_8x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x8 vpx_highbd_sad_skip_8x8_neon + +void vpx_highbd_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_8x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x8x4d vpx_highbd_sad_skip_8x8x4d_neon + int vpx_highbd_satd_c(const tran_low_t* coeff, int length); int vpx_highbd_satd_neon(const tran_low_t* coeff, int length); #define vpx_highbd_satd vpx_highbd_satd_neon +int64_t vpx_highbd_sse_c(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +int64_t vpx_highbd_sse_neon(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +#define vpx_highbd_sse vpx_highbd_sse_neon + void vpx_highbd_subtract_block_c(int rows, int cols, int16_t* diff_ptr, @@ -5130,28 +5422,20 @@ void vpx_post_proc_down_and_across_mb_row_neon(unsigned char* src, void vpx_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vpx_quantize_b vpx_quantize_b_neon void vpx_quantize_b_32x32_c(const tran_low_t* coeff_ptr, @@ -5612,6 +5896,292 @@ void vpx_sad8x8x4d_neon(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_sad8x8x4d vpx_sad8x8x4d_neon +unsigned int vpx_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x16 vpx_sad_skip_16x16_neon + +void vpx_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x16x4d vpx_sad_skip_16x16x4d_neon + +unsigned int vpx_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x32 vpx_sad_skip_16x32_neon + +void vpx_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x32x4d vpx_sad_skip_16x32x4d_neon + +unsigned int vpx_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x8 vpx_sad_skip_16x8_neon + +void vpx_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x8x4d vpx_sad_skip_16x8x4d_neon + +unsigned int vpx_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x16 vpx_sad_skip_32x16_neon + +void vpx_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x16x4d vpx_sad_skip_32x16x4d_neon + +unsigned int vpx_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x32 vpx_sad_skip_32x32_neon + +void vpx_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x32x4d vpx_sad_skip_32x32x4d_neon + +unsigned int vpx_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x64_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x64 vpx_sad_skip_32x64_neon + +void vpx_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x64x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x64x4d vpx_sad_skip_32x64x4d_neon + +unsigned int vpx_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_4x4_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x4 vpx_sad_skip_4x4_neon + +void vpx_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_4x4x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x4x4d vpx_sad_skip_4x4x4d_neon + +unsigned int vpx_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_4x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x8 vpx_sad_skip_4x8_neon + +void vpx_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_4x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x8x4d vpx_sad_skip_4x8x4d_neon + +unsigned int vpx_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_64x32 vpx_sad_skip_64x32_neon + +void vpx_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_64x32x4d vpx_sad_skip_64x32x4d_neon + +unsigned int vpx_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x64_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_64x64 vpx_sad_skip_64x64_neon + +void vpx_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x64x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_64x64x4d vpx_sad_skip_64x64x4d_neon + +unsigned int vpx_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x16 vpx_sad_skip_8x16_neon + +void vpx_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x16x4d vpx_sad_skip_8x16x4d_neon + +unsigned int vpx_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x4_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x4 vpx_sad_skip_8x4_neon + +void vpx_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x4x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x4x4d vpx_sad_skip_8x4x4d_neon + +unsigned int vpx_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x8 vpx_sad_skip_8x8_neon + +void vpx_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x8x4d vpx_sad_skip_8x8x4d_neon + int vpx_satd_c(const tran_low_t* coeff, int length); int vpx_satd_neon(const tran_low_t* coeff, int length); #define vpx_satd vpx_satd_neon @@ -5705,6 +6275,20 @@ void vpx_scaled_vert_c(const uint8_t* src, int h); #define vpx_scaled_vert vpx_scaled_vert_c +int64_t vpx_sse_c(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +int64_t vpx_sse_neon(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +#define vpx_sse vpx_sse_neon + uint32_t vpx_sub_pixel_avg_variance16x16_c(const uint8_t* src_ptr, int src_stride, int x_offset, diff --git a/libvpx/source/config/linux/arm-neon-highbd/vpx_scale_rtcd.h b/libvpx/source/config/linux/arm-neon-highbd/vpx_scale_rtcd.h old mode 100644 new mode 100755 diff --git a/libvpx/source/config/linux/arm-neon/vp8_rtcd.h b/libvpx/source/config/linux/arm-neon/vp8_rtcd.h old mode 100644 new mode 100755 index eb0b3a7cb44e16dc07e8b8f4985011dc9aa9fd16..102501094254bb09d784498a444bed4e77bf00a4 --- a/libvpx/source/config/linux/arm-neon/vp8_rtcd.h +++ b/libvpx/source/config/linux/arm-neon/vp8_rtcd.h @@ -83,36 +83,6 @@ void vp8_bilinear_predict8x8_neon(unsigned char* src_ptr, int dst_pitch); #define vp8_bilinear_predict8x8 vp8_bilinear_predict8x8_neon -void vp8_blend_b_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_b vp8_blend_b_c - -void vp8_blend_mb_inner_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_inner vp8_blend_mb_inner_c - -void vp8_blend_mb_outer_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_outer vp8_blend_mb_outer_c - int vp8_block_error_c(short* coeff, short* dqcoeff); #define vp8_block_error vp8_block_error_c diff --git a/libvpx/source/config/linux/arm-neon/vp9_rtcd.h b/libvpx/source/config/linux/arm-neon/vp9_rtcd.h old mode 100644 new mode 100755 index 8b1eaf7118999079707c57c10c757dd8add312e5..4c2a4adad26c6ce30557ea637f0f159d9bf1e61b --- a/libvpx/source/config/linux/arm-neon/vp9_rtcd.h +++ b/libvpx/source/config/linux/arm-neon/vp9_rtcd.h @@ -21,7 +21,9 @@ struct macroblockd; /* Encoder forward decls */ struct macroblock; -struct vp9_variance_vtable; +struct macroblock_plane; +struct vp9_sad_table; +struct ScanOrder; struct search_site_config; struct mv; union int_mv; @@ -77,7 +79,7 @@ int vp9_diamond_search_sad_c(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); int vp9_diamond_search_sad_neon(const struct macroblock* x, const struct search_site_config* cfg, @@ -87,7 +89,7 @@ int vp9_diamond_search_sad_neon(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); #define vp9_diamond_search_sad vp9_diamond_search_sad_neon @@ -170,46 +172,38 @@ void vp9_iht8x8_64_add_neon(const tran_low_t* input, void vp9_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp vp9_quantize_fp_neon void vp9_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp_32x32 vp9_quantize_fp_32x32_neon void vp9_scale_and_extend_frame_c(const struct yv12_buffer_config* src, diff --git a/libvpx/source/config/linux/arm-neon/vpx_config.asm b/libvpx/source/config/linux/arm-neon/vpx_config.asm old mode 100644 new mode 100755 index a87c381157839aa26c5880ae1a2d6d9d2a887c4d..010e19f5c862f858fd513061b02db46976b7d813 --- a/libvpx/source/config/linux/arm-neon/vpx_config.asm +++ b/libvpx/source/config/linux/arm-neon/vpx_config.asm @@ -3,6 +3,8 @@ .syntax unified .equ VPX_ARCH_ARM , 1 .equ ARCH_ARM , 1 +.equ VPX_ARCH_AARCH64 , 0 +.equ ARCH_AARCH64 , 0 .equ VPX_ARCH_MIPS , 0 .equ ARCH_MIPS , 0 .equ VPX_ARCH_X86 , 0 @@ -13,8 +15,12 @@ .equ ARCH_PPC , 0 .equ VPX_ARCH_LOONGARCH , 0 .equ ARCH_LOONGARCH , 0 -.equ HAVE_NEON , 1 .equ HAVE_NEON_ASM , 1 +.equ HAVE_NEON , 1 +.equ HAVE_NEON_DOTPROD , 0 +.equ HAVE_NEON_I8MM , 0 +.equ HAVE_SVE , 0 +.equ HAVE_SVE2 , 0 .equ HAVE_MIPS32 , 0 .equ HAVE_DSPR2 , 0 .equ HAVE_MSA , 0 diff --git a/libvpx/source/config/linux/arm-neon/vpx_config.c b/libvpx/source/config/linux/arm-neon/vpx_config.c old mode 100644 new mode 100755 index f4f0c112a0dbd486ee1dc734fb5af9ead29c03b9..0a31bce02e50e10d6aa3387bee9ee11dcba2e55d --- a/libvpx/source/config/linux/arm-neon/vpx_config.c +++ b/libvpx/source/config/linux/arm-neon/vpx_config.c @@ -6,5 +6,5 @@ /* in the file PATENTS. All contributing project authors may */ /* be found in the AUTHORS file in the root of the source tree. */ #include "vpx/vpx_codec.h" -static const char* const cfg = "--target=armv7-linux-gcc --enable-external-build --enable-postproc --enable-multi-res-encoding --enable-temporal-denoising --enable-vp9-temporal-denoising --enable-vp9-postproc --size-limit=16384x16384 --enable-realtime-only --disable-install-docs --disable-libyuv"; +static const char* const cfg = "--target=armv7-linux-gcc --disable-runtime-cpu-detect --enable-external-build --enable-postproc --enable-multi-res-encoding --enable-temporal-denoising --enable-vp9-temporal-denoising --enable-vp9-postproc --size-limit=16384x16384 --enable-realtime-only --disable-install-docs --disable-libyuv"; const char *vpx_codec_build_config(void) {return cfg;} diff --git a/libvpx/source/config/linux/arm-neon/vpx_config.h b/libvpx/source/config/linux/arm-neon/vpx_config.h old mode 100644 new mode 100755 index 12337a51a17da2e208727efb57a5eb8c7ba86bee..c274e6d5351e06f6cf4d1c3af19af1ad64c8361d --- a/libvpx/source/config/linux/arm-neon/vpx_config.h +++ b/libvpx/source/config/linux/arm-neon/vpx_config.h @@ -12,6 +12,8 @@ #define INLINE inline #define VPX_ARCH_ARM 1 #define ARCH_ARM 1 +#define VPX_ARCH_AARCH64 0 +#define ARCH_AARCH64 0 #define VPX_ARCH_MIPS 0 #define ARCH_MIPS 0 #define VPX_ARCH_X86 0 @@ -22,8 +24,12 @@ #define ARCH_PPC 0 #define VPX_ARCH_LOONGARCH 0 #define ARCH_LOONGARCH 0 -#define HAVE_NEON 1 #define HAVE_NEON_ASM 1 +#define HAVE_NEON 1 +#define HAVE_NEON_DOTPROD 0 +#define HAVE_NEON_I8MM 0 +#define HAVE_SVE 0 +#define HAVE_SVE2 0 #define HAVE_MIPS32 0 #define HAVE_DSPR2 0 #define HAVE_MSA 0 diff --git a/libvpx/source/config/linux/arm-neon/vpx_dsp_rtcd.h b/libvpx/source/config/linux/arm-neon/vpx_dsp_rtcd.h old mode 100644 new mode 100755 index 5f53e098fbce9c240022ccf1103dbdb00ed53d98..a39859cbb0728f1d4dcc23faed8df7809622e4ba --- a/libvpx/source/config/linux/arm-neon/vpx_dsp_rtcd.h +++ b/libvpx/source/config/linux/arm-neon/vpx_dsp_rtcd.h @@ -1181,28 +1181,20 @@ void vpx_post_proc_down_and_across_mb_row_neon(unsigned char* src, void vpx_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vpx_quantize_b vpx_quantize_b_neon void vpx_quantize_b_32x32_c(const tran_low_t* coeff_ptr, @@ -1663,6 +1655,292 @@ void vpx_sad8x8x4d_neon(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_sad8x8x4d vpx_sad8x8x4d_neon +unsigned int vpx_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x16 vpx_sad_skip_16x16_neon + +void vpx_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x16x4d vpx_sad_skip_16x16x4d_neon + +unsigned int vpx_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x32 vpx_sad_skip_16x32_neon + +void vpx_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x32x4d vpx_sad_skip_16x32x4d_neon + +unsigned int vpx_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x8 vpx_sad_skip_16x8_neon + +void vpx_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x8x4d vpx_sad_skip_16x8x4d_neon + +unsigned int vpx_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x16 vpx_sad_skip_32x16_neon + +void vpx_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x16x4d vpx_sad_skip_32x16x4d_neon + +unsigned int vpx_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x32 vpx_sad_skip_32x32_neon + +void vpx_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x32x4d vpx_sad_skip_32x32x4d_neon + +unsigned int vpx_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x64_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x64 vpx_sad_skip_32x64_neon + +void vpx_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x64x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x64x4d vpx_sad_skip_32x64x4d_neon + +unsigned int vpx_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_4x4_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x4 vpx_sad_skip_4x4_neon + +void vpx_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_4x4x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x4x4d vpx_sad_skip_4x4x4d_neon + +unsigned int vpx_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_4x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x8 vpx_sad_skip_4x8_neon + +void vpx_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_4x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x8x4d vpx_sad_skip_4x8x4d_neon + +unsigned int vpx_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_64x32 vpx_sad_skip_64x32_neon + +void vpx_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_64x32x4d vpx_sad_skip_64x32x4d_neon + +unsigned int vpx_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x64_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_64x64 vpx_sad_skip_64x64_neon + +void vpx_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x64x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_64x64x4d vpx_sad_skip_64x64x4d_neon + +unsigned int vpx_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x16 vpx_sad_skip_8x16_neon + +void vpx_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x16x4d vpx_sad_skip_8x16x4d_neon + +unsigned int vpx_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x4_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x4 vpx_sad_skip_8x4_neon + +void vpx_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x4x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x4x4d vpx_sad_skip_8x4x4d_neon + +unsigned int vpx_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x8 vpx_sad_skip_8x8_neon + +void vpx_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x8x4d vpx_sad_skip_8x8x4d_neon + int vpx_satd_c(const int16_t* coeff, int length); int vpx_satd_neon(const int16_t* coeff, int length); #define vpx_satd vpx_satd_neon @@ -1756,6 +2034,20 @@ void vpx_scaled_vert_c(const uint8_t* src, int h); #define vpx_scaled_vert vpx_scaled_vert_c +int64_t vpx_sse_c(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +int64_t vpx_sse_neon(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +#define vpx_sse vpx_sse_neon + uint32_t vpx_sub_pixel_avg_variance16x16_c(const uint8_t* src_ptr, int src_stride, int x_offset, diff --git a/libvpx/source/config/linux/arm-neon/vpx_scale_rtcd.h b/libvpx/source/config/linux/arm-neon/vpx_scale_rtcd.h old mode 100644 new mode 100755 diff --git a/libvpx/source/config/linux/arm/vp8_rtcd.h b/libvpx/source/config/linux/arm/vp8_rtcd.h old mode 100644 new mode 100755 index a9ac77c44cd1aa608a6116e8df4f712c8c538d92..e5963c248b9078aa10f9be3177ffe078d3a55cb9 --- a/libvpx/source/config/linux/arm/vp8_rtcd.h +++ b/libvpx/source/config/linux/arm/vp8_rtcd.h @@ -59,36 +59,6 @@ void vp8_bilinear_predict8x8_c(unsigned char* src_ptr, int dst_pitch); #define vp8_bilinear_predict8x8 vp8_bilinear_predict8x8_c -void vp8_blend_b_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_b vp8_blend_b_c - -void vp8_blend_mb_inner_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_inner vp8_blend_mb_inner_c - -void vp8_blend_mb_outer_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_outer vp8_blend_mb_outer_c - int vp8_block_error_c(short* coeff, short* dqcoeff); #define vp8_block_error vp8_block_error_c diff --git a/libvpx/source/config/linux/arm/vp9_rtcd.h b/libvpx/source/config/linux/arm/vp9_rtcd.h old mode 100644 new mode 100755 index 3417d008c752392b43b2b96c2765f020842680e5..55c703d9be440383e75693c22147a352d8bcfed0 --- a/libvpx/source/config/linux/arm/vp9_rtcd.h +++ b/libvpx/source/config/linux/arm/vp9_rtcd.h @@ -21,7 +21,9 @@ struct macroblockd; /* Encoder forward decls */ struct macroblock; -struct vp9_variance_vtable; +struct macroblock_plane; +struct vp9_sad_table; +struct ScanOrder; struct search_site_config; struct mv; union int_mv; @@ -61,7 +63,7 @@ int vp9_diamond_search_sad_c(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); #define vp9_diamond_search_sad vp9_diamond_search_sad_c @@ -120,26 +122,22 @@ void vp9_iht8x8_64_add_c(const tran_low_t* input, void vp9_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp vp9_quantize_fp_c void vp9_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp_32x32 vp9_quantize_fp_32x32_c void vp9_scale_and_extend_frame_c(const struct yv12_buffer_config* src, diff --git a/libvpx/source/config/linux/arm/vpx_config.asm b/libvpx/source/config/linux/arm/vpx_config.asm old mode 100644 new mode 100755 index 258dea6f11bebf5935f0fbb7ff7ac2791a68646c..d88fb3d0031bf5c13951c67f71750d5b510349b3 --- a/libvpx/source/config/linux/arm/vpx_config.asm +++ b/libvpx/source/config/linux/arm/vpx_config.asm @@ -3,6 +3,8 @@ .syntax unified .equ VPX_ARCH_ARM , 1 .equ ARCH_ARM , 1 +.equ VPX_ARCH_AARCH64 , 0 +.equ ARCH_AARCH64 , 0 .equ VPX_ARCH_MIPS , 0 .equ ARCH_MIPS , 0 .equ VPX_ARCH_X86 , 0 @@ -13,8 +15,12 @@ .equ ARCH_PPC , 0 .equ VPX_ARCH_LOONGARCH , 0 .equ ARCH_LOONGARCH , 0 -.equ HAVE_NEON , 0 .equ HAVE_NEON_ASM , 0 +.equ HAVE_NEON , 0 +.equ HAVE_NEON_DOTPROD , 0 +.equ HAVE_NEON_I8MM , 0 +.equ HAVE_SVE , 0 +.equ HAVE_SVE2 , 0 .equ HAVE_MIPS32 , 0 .equ HAVE_DSPR2 , 0 .equ HAVE_MSA , 0 diff --git a/libvpx/source/config/linux/arm/vpx_config.c b/libvpx/source/config/linux/arm/vpx_config.c old mode 100644 new mode 100755 index b0d23e72fed238aa885ab479a01d210550c98bdb..8c1a83b2b6df23c6802b6deac85c9e22e2575aa2 --- a/libvpx/source/config/linux/arm/vpx_config.c +++ b/libvpx/source/config/linux/arm/vpx_config.c @@ -6,5 +6,5 @@ /* in the file PATENTS. All contributing project authors may */ /* be found in the AUTHORS file in the root of the source tree. */ #include "vpx/vpx_codec.h" -static const char* const cfg = "--target=armv7-linux-gcc --disable-neon --enable-external-build --enable-postproc --enable-multi-res-encoding --enable-temporal-denoising --enable-vp9-temporal-denoising --enable-vp9-postproc --size-limit=16384x16384 --enable-realtime-only --disable-install-docs --disable-libyuv"; +static const char* const cfg = "--target=armv7-linux-gcc --disable-neon --disable-runtime-cpu-detect --enable-external-build --enable-postproc --enable-multi-res-encoding --enable-temporal-denoising --enable-vp9-temporal-denoising --enable-vp9-postproc --size-limit=16384x16384 --enable-realtime-only --disable-install-docs --disable-libyuv"; const char *vpx_codec_build_config(void) {return cfg;} diff --git a/libvpx/source/config/linux/arm/vpx_config.h b/libvpx/source/config/linux/arm/vpx_config.h old mode 100644 new mode 100755 index e0983b32525f15edeb23e6fabceb1104f9819e89..90d4bd9452bbcf2596c549989b7ff11505c9c0b6 --- a/libvpx/source/config/linux/arm/vpx_config.h +++ b/libvpx/source/config/linux/arm/vpx_config.h @@ -12,6 +12,8 @@ #define INLINE inline #define VPX_ARCH_ARM 1 #define ARCH_ARM 1 +#define VPX_ARCH_AARCH64 0 +#define ARCH_AARCH64 0 #define VPX_ARCH_MIPS 0 #define ARCH_MIPS 0 #define VPX_ARCH_X86 0 @@ -22,8 +24,12 @@ #define ARCH_PPC 0 #define VPX_ARCH_LOONGARCH 0 #define ARCH_LOONGARCH 0 -#define HAVE_NEON 0 #define HAVE_NEON_ASM 0 +#define HAVE_NEON 0 +#define HAVE_NEON_DOTPROD 0 +#define HAVE_NEON_I8MM 0 +#define HAVE_SVE 0 +#define HAVE_SVE2 0 #define HAVE_MIPS32 0 #define HAVE_DSPR2 0 #define HAVE_MSA 0 diff --git a/libvpx/source/config/linux/arm/vpx_dsp_rtcd.h b/libvpx/source/config/linux/arm/vpx_dsp_rtcd.h old mode 100644 new mode 100755 index 3348d8fd27dd95f9f37c9bb2583ff6efbfbf06fb..f4cdd67ecf1d141c0cd70748a42c0ef2bcb1de80 --- a/libvpx/source/config/linux/arm/vpx_dsp_rtcd.h +++ b/libvpx/source/config/linux/arm/vpx_dsp_rtcd.h @@ -718,16 +718,12 @@ void vpx_post_proc_down_and_across_mb_row_c(unsigned char* src, void vpx_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vpx_quantize_b vpx_quantize_b_c void vpx_quantize_b_32x32_c(const tran_low_t* coeff_ptr, @@ -999,6 +995,175 @@ void vpx_sad8x8x4d_c(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_sad8x8x4d vpx_sad8x8x4d_c +unsigned int vpx_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x16 vpx_sad_skip_16x16_c + +void vpx_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x16x4d vpx_sad_skip_16x16x4d_c + +unsigned int vpx_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x32 vpx_sad_skip_16x32_c + +void vpx_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x32x4d vpx_sad_skip_16x32x4d_c + +unsigned int vpx_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x8 vpx_sad_skip_16x8_c + +void vpx_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x8x4d vpx_sad_skip_16x8x4d_c + +unsigned int vpx_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x16 vpx_sad_skip_32x16_c + +void vpx_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x16x4d vpx_sad_skip_32x16x4d_c + +unsigned int vpx_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x32 vpx_sad_skip_32x32_c + +void vpx_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x32x4d vpx_sad_skip_32x32x4d_c + +unsigned int vpx_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x64 vpx_sad_skip_32x64_c + +void vpx_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x64x4d vpx_sad_skip_32x64x4d_c + +unsigned int vpx_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x4 vpx_sad_skip_4x4_c + +void vpx_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x4x4d vpx_sad_skip_4x4x4d_c + +unsigned int vpx_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x8 vpx_sad_skip_4x8_c + +void vpx_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x8x4d vpx_sad_skip_4x8x4d_c + +unsigned int vpx_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_64x32 vpx_sad_skip_64x32_c + +void vpx_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_64x32x4d vpx_sad_skip_64x32x4d_c + +unsigned int vpx_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_64x64 vpx_sad_skip_64x64_c + +void vpx_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_64x64x4d vpx_sad_skip_64x64x4d_c + +unsigned int vpx_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x16 vpx_sad_skip_8x16_c + +void vpx_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x16x4d vpx_sad_skip_8x16x4d_c + +unsigned int vpx_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x4 vpx_sad_skip_8x4_c + +void vpx_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x4x4d vpx_sad_skip_8x4x4d_c + +unsigned int vpx_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x8 vpx_sad_skip_8x8_c + +void vpx_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x8x4d vpx_sad_skip_8x8x4d_c + int vpx_satd_c(const int16_t* coeff, int length); #define vpx_satd vpx_satd_c @@ -1080,6 +1245,14 @@ void vpx_scaled_vert_c(const uint8_t* src, int h); #define vpx_scaled_vert vpx_scaled_vert_c +int64_t vpx_sse_c(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +#define vpx_sse vpx_sse_c + uint32_t vpx_sub_pixel_avg_variance16x16_c(const uint8_t* src_ptr, int src_stride, int x_offset, diff --git a/libvpx/source/config/linux/arm/vpx_scale_rtcd.h b/libvpx/source/config/linux/arm/vpx_scale_rtcd.h old mode 100644 new mode 100755 diff --git a/libvpx/source/config/linux/arm64-highbd/vp8_rtcd.h b/libvpx/source/config/linux/arm64-highbd/vp8_rtcd.h old mode 100644 new mode 100755 index eb0b3a7cb44e16dc07e8b8f4985011dc9aa9fd16..102501094254bb09d784498a444bed4e77bf00a4 --- a/libvpx/source/config/linux/arm64-highbd/vp8_rtcd.h +++ b/libvpx/source/config/linux/arm64-highbd/vp8_rtcd.h @@ -83,36 +83,6 @@ void vp8_bilinear_predict8x8_neon(unsigned char* src_ptr, int dst_pitch); #define vp8_bilinear_predict8x8 vp8_bilinear_predict8x8_neon -void vp8_blend_b_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_b vp8_blend_b_c - -void vp8_blend_mb_inner_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_inner vp8_blend_mb_inner_c - -void vp8_blend_mb_outer_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_outer vp8_blend_mb_outer_c - int vp8_block_error_c(short* coeff, short* dqcoeff); #define vp8_block_error vp8_block_error_c diff --git a/libvpx/source/config/linux/arm64-highbd/vp9_rtcd.h b/libvpx/source/config/linux/arm64-highbd/vp9_rtcd.h old mode 100644 new mode 100755 index acfadf825c23143297ccacf420de551120482901..53900f30360230a62781ad10866f79da1afeba74 --- a/libvpx/source/config/linux/arm64-highbd/vp9_rtcd.h +++ b/libvpx/source/config/linux/arm64-highbd/vp9_rtcd.h @@ -21,7 +21,9 @@ struct macroblockd; /* Encoder forward decls */ struct macroblock; -struct vp9_variance_vtable; +struct macroblock_plane; +struct vp9_sad_table; +struct ScanOrder; struct search_site_config; struct mv; union int_mv; @@ -39,7 +41,14 @@ int64_t vp9_block_error_neon(const tran_low_t* coeff, const tran_low_t* dqcoeff, intptr_t block_size, int64_t* ssz); -#define vp9_block_error vp9_block_error_neon +int64_t vp9_block_error_sve(const tran_low_t* coeff, + const tran_low_t* dqcoeff, + intptr_t block_size, + int64_t* ssz); +RTCD_EXTERN int64_t (*vp9_block_error)(const tran_low_t* coeff, + const tran_low_t* dqcoeff, + intptr_t block_size, + int64_t* ssz); int64_t vp9_block_error_fp_c(const tran_low_t* coeff, const tran_low_t* dqcoeff, @@ -47,7 +56,12 @@ int64_t vp9_block_error_fp_c(const tran_low_t* coeff, int64_t vp9_block_error_fp_neon(const tran_low_t* coeff, const tran_low_t* dqcoeff, int block_size); -#define vp9_block_error_fp vp9_block_error_fp_neon +int64_t vp9_block_error_fp_sve(const tran_low_t* coeff, + const tran_low_t* dqcoeff, + int block_size); +RTCD_EXTERN int64_t (*vp9_block_error_fp)(const tran_low_t* coeff, + const tran_low_t* dqcoeff, + int block_size); int vp9_denoiser_filter_c(const uint8_t* sig, int sig_stride, @@ -77,7 +91,7 @@ int vp9_diamond_search_sad_c(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); int vp9_diamond_search_sad_neon(const struct macroblock* x, const struct search_site_config* cfg, @@ -87,7 +101,7 @@ int vp9_diamond_search_sad_neon(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); #define vp9_diamond_search_sad vp9_diamond_search_sad_neon @@ -245,46 +259,40 @@ void vp9_highbd_post_proc_down_and_across_c(const uint16_t* src_ptr, void vp9_highbd_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_highbd_quantize_fp_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_highbd_quantize_fp vp9_highbd_quantize_fp_neon -void vp9_highbd_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -void vp9_highbd_quantize_fp_32x32_neon(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); +void vp9_highbd_quantize_fp_32x32_c( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); +void vp9_highbd_quantize_fp_32x32_neon( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); #define vp9_highbd_quantize_fp_32x32 vp9_highbd_quantize_fp_32x32_neon void vp9_highbd_temporal_filter_apply_c(const uint8_t* frame1, @@ -331,46 +339,38 @@ void vp9_iht8x8_64_add_neon(const tran_low_t* input, void vp9_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp vp9_quantize_fp_neon void vp9_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp_32x32 vp9_quantize_fp_32x32_neon void vp9_scale_and_extend_frame_c(const struct yv12_buffer_config* src, @@ -393,6 +393,15 @@ static void setup_rtcd_internal(void) { int flags = arm_cpu_caps(); (void)flags; + + vp9_block_error = vp9_block_error_neon; + if (flags & HAS_SVE) { + vp9_block_error = vp9_block_error_sve; + } + vp9_block_error_fp = vp9_block_error_fp_neon; + if (flags & HAS_SVE) { + vp9_block_error_fp = vp9_block_error_fp_sve; + } } #endif diff --git a/libvpx/source/config/linux/arm64-highbd/vpx_config.asm b/libvpx/source/config/linux/arm64-highbd/vpx_config.asm old mode 100644 new mode 100755 index 2755641317387cb0c93941478532d87342cbc331..ffb2045b6d9f9e339194e3d41a058c5eaf04c044 --- a/libvpx/source/config/linux/arm64-highbd/vpx_config.asm +++ b/libvpx/source/config/linux/arm64-highbd/vpx_config.asm @@ -3,6 +3,8 @@ .syntax unified .equ VPX_ARCH_ARM , 1 .equ ARCH_ARM , 1 +.equ VPX_ARCH_AARCH64 , 1 +.equ ARCH_AARCH64 , 1 .equ VPX_ARCH_MIPS , 0 .equ ARCH_MIPS , 0 .equ VPX_ARCH_X86 , 0 @@ -13,8 +15,12 @@ .equ ARCH_PPC , 0 .equ VPX_ARCH_LOONGARCH , 0 .equ ARCH_LOONGARCH , 0 -.equ HAVE_NEON , 1 .equ HAVE_NEON_ASM , 0 +.equ HAVE_NEON , 1 +.equ HAVE_NEON_DOTPROD , 1 +.equ HAVE_NEON_I8MM , 1 +.equ HAVE_SVE , 1 +.equ HAVE_SVE2 , 1 .equ HAVE_MIPS32 , 0 .equ HAVE_DSPR2 , 0 .equ HAVE_MSA , 0 @@ -53,7 +59,7 @@ .equ CONFIG_DEBUG_LIBS , 0 .equ CONFIG_DEQUANT_TOKENS , 0 .equ CONFIG_DC_RECON , 0 -.equ CONFIG_RUNTIME_CPU_DETECT , 0 +.equ CONFIG_RUNTIME_CPU_DETECT , 1 .equ CONFIG_POSTPROC , 1 .equ CONFIG_VP9_POSTPROC , 1 .equ CONFIG_MULTITHREAD , 1 diff --git a/libvpx/source/config/linux/arm64-highbd/vpx_config.c b/libvpx/source/config/linux/arm64-highbd/vpx_config.c old mode 100644 new mode 100755 diff --git a/libvpx/source/config/linux/arm64-highbd/vpx_config.h b/libvpx/source/config/linux/arm64-highbd/vpx_config.h old mode 100644 new mode 100755 index 2ae065f8850df08f0f912b7a117975dbf5645f15..cbfa51ce6ceb9e367609f8d2373ae7534931120b --- a/libvpx/source/config/linux/arm64-highbd/vpx_config.h +++ b/libvpx/source/config/linux/arm64-highbd/vpx_config.h @@ -12,6 +12,8 @@ #define INLINE inline #define VPX_ARCH_ARM 1 #define ARCH_ARM 1 +#define VPX_ARCH_AARCH64 1 +#define ARCH_AARCH64 1 #define VPX_ARCH_MIPS 0 #define ARCH_MIPS 0 #define VPX_ARCH_X86 0 @@ -22,8 +24,12 @@ #define ARCH_PPC 0 #define VPX_ARCH_LOONGARCH 0 #define ARCH_LOONGARCH 0 -#define HAVE_NEON 1 #define HAVE_NEON_ASM 0 +#define HAVE_NEON 1 +#define HAVE_NEON_DOTPROD 1 +#define HAVE_NEON_I8MM 1 +#define HAVE_SVE 1 +#define HAVE_SVE2 1 #define HAVE_MIPS32 0 #define HAVE_DSPR2 0 #define HAVE_MSA 0 @@ -62,7 +68,7 @@ #define CONFIG_DEBUG_LIBS 0 #define CONFIG_DEQUANT_TOKENS 0 #define CONFIG_DC_RECON 0 -#define CONFIG_RUNTIME_CPU_DETECT 0 +#define CONFIG_RUNTIME_CPU_DETECT 1 #define CONFIG_POSTPROC 1 #define CONFIG_VP9_POSTPROC 1 #define CONFIG_MULTITHREAD 1 diff --git a/libvpx/source/config/linux/arm64-highbd/vpx_dsp_rtcd.h b/libvpx/source/config/linux/arm64-highbd/vpx_dsp_rtcd.h old mode 100644 new mode 100755 index 69d38d127483de538d08a76d48a4ad240f82d803..9d8ba2f6a46d0a6f9e7e4707a5986cefe43fc667 --- a/libvpx/source/config/linux/arm64-highbd/vpx_dsp_rtcd.h +++ b/libvpx/source/config/linux/arm64-highbd/vpx_dsp_rtcd.h @@ -68,7 +68,39 @@ void vpx_convolve8_neon(const uint8_t* src, int y_step_q4, int w, int h); -#define vpx_convolve8 vpx_convolve8_neon +void vpx_convolve8_neon_dotprod(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_convolve8_neon_i8mm(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +RTCD_EXTERN void (*vpx_convolve8)(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); void vpx_convolve8_avg_c(const uint8_t* src, ptrdiff_t src_stride, @@ -92,7 +124,39 @@ void vpx_convolve8_avg_neon(const uint8_t* src, int y_step_q4, int w, int h); -#define vpx_convolve8_avg vpx_convolve8_avg_neon +void vpx_convolve8_avg_neon_dotprod(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_convolve8_avg_neon_i8mm(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +RTCD_EXTERN void (*vpx_convolve8_avg)(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); void vpx_convolve8_avg_horiz_c(const uint8_t* src, ptrdiff_t src_stride, @@ -116,7 +180,39 @@ void vpx_convolve8_avg_horiz_neon(const uint8_t* src, int y_step_q4, int w, int h); -#define vpx_convolve8_avg_horiz vpx_convolve8_avg_horiz_neon +void vpx_convolve8_avg_horiz_neon_dotprod(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_convolve8_avg_horiz_neon_i8mm(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +RTCD_EXTERN void (*vpx_convolve8_avg_horiz)(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); void vpx_convolve8_avg_vert_c(const uint8_t* src, ptrdiff_t src_stride, @@ -140,7 +236,39 @@ void vpx_convolve8_avg_vert_neon(const uint8_t* src, int y_step_q4, int w, int h); -#define vpx_convolve8_avg_vert vpx_convolve8_avg_vert_neon +void vpx_convolve8_avg_vert_neon_dotprod(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_convolve8_avg_vert_neon_i8mm(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +RTCD_EXTERN void (*vpx_convolve8_avg_vert)(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); void vpx_convolve8_horiz_c(const uint8_t* src, ptrdiff_t src_stride, @@ -164,7 +292,39 @@ void vpx_convolve8_horiz_neon(const uint8_t* src, int y_step_q4, int w, int h); -#define vpx_convolve8_horiz vpx_convolve8_horiz_neon +void vpx_convolve8_horiz_neon_dotprod(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_convolve8_horiz_neon_i8mm(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +RTCD_EXTERN void (*vpx_convolve8_horiz)(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); void vpx_convolve8_vert_c(const uint8_t* src, ptrdiff_t src_stride, @@ -188,7 +348,39 @@ void vpx_convolve8_vert_neon(const uint8_t* src, int y_step_q4, int w, int h); -#define vpx_convolve8_vert vpx_convolve8_vert_neon +void vpx_convolve8_vert_neon_dotprod(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_convolve8_vert_neon_i8mm(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +RTCD_EXTERN void (*vpx_convolve8_vert)(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); void vpx_convolve_avg_c(const uint8_t* src, ptrdiff_t src_stride, @@ -700,7 +892,18 @@ void vpx_get16x16var_neon(const uint8_t* src_ptr, int ref_stride, unsigned int* sse, int* sum); -#define vpx_get16x16var vpx_get16x16var_neon +void vpx_get16x16var_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); +RTCD_EXTERN void (*vpx_get16x16var)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); unsigned int vpx_get4x4sse_cs_c(const unsigned char* src_ptr, int src_stride, @@ -710,7 +913,14 @@ unsigned int vpx_get4x4sse_cs_neon(const unsigned char* src_ptr, int src_stride, const unsigned char* ref_ptr, int ref_stride); -#define vpx_get4x4sse_cs vpx_get4x4sse_cs_neon +unsigned int vpx_get4x4sse_cs_neon_dotprod(const unsigned char* src_ptr, + int src_stride, + const unsigned char* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_get4x4sse_cs)(const unsigned char* src_ptr, + int src_stride, + const unsigned char* ref_ptr, + int ref_stride); void vpx_get8x8var_c(const uint8_t* src_ptr, int src_stride, @@ -724,7 +934,18 @@ void vpx_get8x8var_neon(const uint8_t* src_ptr, int ref_stride, unsigned int* sse, int* sum); -#define vpx_get8x8var vpx_get8x8var_neon +void vpx_get8x8var_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); +RTCD_EXTERN void (*vpx_get8x8var)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); unsigned int vpx_get_mb_ss_c(const int16_t*); #define vpx_get_mb_ss vpx_get_mb_ss_c @@ -811,7 +1032,18 @@ void vpx_highbd_10_get16x16var_neon(const uint8_t* src_ptr, int ref_stride, unsigned int* sse, int* sum); -#define vpx_highbd_10_get16x16var vpx_highbd_10_get16x16var_neon +void vpx_highbd_10_get16x16var_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); +RTCD_EXTERN void (*vpx_highbd_10_get16x16var)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); void vpx_highbd_10_get8x8var_c(const uint8_t* src_ptr, int src_stride, @@ -825,7 +1057,18 @@ void vpx_highbd_10_get8x8var_neon(const uint8_t* src_ptr, int ref_stride, unsigned int* sse, int* sum); -#define vpx_highbd_10_get8x8var vpx_highbd_10_get8x8var_neon +void vpx_highbd_10_get8x8var_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); +RTCD_EXTERN void (*vpx_highbd_10_get8x8var)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); unsigned int vpx_highbd_10_mse16x16_c(const uint8_t* src_ptr, int src_stride, @@ -837,7 +1080,16 @@ unsigned int vpx_highbd_10_mse16x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_10_mse16x16 vpx_highbd_10_mse16x16_neon +unsigned int vpx_highbd_10_mse16x16_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_10_mse16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_10_mse16x8_c(const uint8_t* src_ptr, int src_stride, @@ -849,7 +1101,16 @@ unsigned int vpx_highbd_10_mse16x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_10_mse16x8 vpx_highbd_10_mse16x8_neon +unsigned int vpx_highbd_10_mse16x8_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_10_mse16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_10_mse8x16_c(const uint8_t* src_ptr, int src_stride, @@ -861,7 +1122,16 @@ unsigned int vpx_highbd_10_mse8x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_10_mse8x16 vpx_highbd_10_mse8x16_neon +unsigned int vpx_highbd_10_mse8x16_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_10_mse8x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_10_mse8x8_c(const uint8_t* src_ptr, int src_stride, @@ -873,7 +1143,16 @@ unsigned int vpx_highbd_10_mse8x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_10_mse8x8 vpx_highbd_10_mse8x8_neon +unsigned int vpx_highbd_10_mse8x8_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_10_mse8x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); uint32_t vpx_highbd_10_sub_pixel_avg_variance16x16_c( const uint8_t* src_ptr, @@ -1373,7 +1652,16 @@ unsigned int vpx_highbd_10_variance16x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_10_variance16x16 vpx_highbd_10_variance16x16_neon +unsigned int vpx_highbd_10_variance16x16_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_10_variance16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_10_variance16x32_c(const uint8_t* src_ptr, int src_stride, @@ -1385,7 +1673,16 @@ unsigned int vpx_highbd_10_variance16x32_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_10_variance16x32 vpx_highbd_10_variance16x32_neon +unsigned int vpx_highbd_10_variance16x32_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_10_variance16x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_10_variance16x8_c(const uint8_t* src_ptr, int src_stride, @@ -1397,7 +1694,16 @@ unsigned int vpx_highbd_10_variance16x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_10_variance16x8 vpx_highbd_10_variance16x8_neon +unsigned int vpx_highbd_10_variance16x8_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_10_variance16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_10_variance32x16_c(const uint8_t* src_ptr, int src_stride, @@ -1409,7 +1715,16 @@ unsigned int vpx_highbd_10_variance32x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_10_variance32x16 vpx_highbd_10_variance32x16_neon +unsigned int vpx_highbd_10_variance32x16_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_10_variance32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_10_variance32x32_c(const uint8_t* src_ptr, int src_stride, @@ -1421,7 +1736,16 @@ unsigned int vpx_highbd_10_variance32x32_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_10_variance32x32 vpx_highbd_10_variance32x32_neon +unsigned int vpx_highbd_10_variance32x32_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_10_variance32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_10_variance32x64_c(const uint8_t* src_ptr, int src_stride, @@ -1433,7 +1757,16 @@ unsigned int vpx_highbd_10_variance32x64_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_10_variance32x64 vpx_highbd_10_variance32x64_neon +unsigned int vpx_highbd_10_variance32x64_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_10_variance32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_10_variance4x4_c(const uint8_t* src_ptr, int src_stride, @@ -1445,7 +1778,16 @@ unsigned int vpx_highbd_10_variance4x4_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_10_variance4x4 vpx_highbd_10_variance4x4_neon +unsigned int vpx_highbd_10_variance4x4_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_10_variance4x4)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_10_variance4x8_c(const uint8_t* src_ptr, int src_stride, @@ -1457,7 +1799,16 @@ unsigned int vpx_highbd_10_variance4x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_10_variance4x8 vpx_highbd_10_variance4x8_neon +unsigned int vpx_highbd_10_variance4x8_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_10_variance4x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_10_variance64x32_c(const uint8_t* src_ptr, int src_stride, @@ -1469,7 +1820,16 @@ unsigned int vpx_highbd_10_variance64x32_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_10_variance64x32 vpx_highbd_10_variance64x32_neon +unsigned int vpx_highbd_10_variance64x32_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_10_variance64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_10_variance64x64_c(const uint8_t* src_ptr, int src_stride, @@ -1481,7 +1841,16 @@ unsigned int vpx_highbd_10_variance64x64_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_10_variance64x64 vpx_highbd_10_variance64x64_neon +unsigned int vpx_highbd_10_variance64x64_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_10_variance64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_10_variance8x16_c(const uint8_t* src_ptr, int src_stride, @@ -1493,7 +1862,16 @@ unsigned int vpx_highbd_10_variance8x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_10_variance8x16 vpx_highbd_10_variance8x16_neon +unsigned int vpx_highbd_10_variance8x16_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_10_variance8x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_10_variance8x4_c(const uint8_t* src_ptr, int src_stride, @@ -1505,7 +1883,16 @@ unsigned int vpx_highbd_10_variance8x4_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_10_variance8x4 vpx_highbd_10_variance8x4_neon +unsigned int vpx_highbd_10_variance8x4_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_10_variance8x4)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_10_variance8x8_c(const uint8_t* src_ptr, int src_stride, @@ -1517,7 +1904,16 @@ unsigned int vpx_highbd_10_variance8x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_10_variance8x8 vpx_highbd_10_variance8x8_neon +unsigned int vpx_highbd_10_variance8x8_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_10_variance8x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); void vpx_highbd_12_get16x16var_c(const uint8_t* src_ptr, int src_stride, @@ -1531,7 +1927,18 @@ void vpx_highbd_12_get16x16var_neon(const uint8_t* src_ptr, int ref_stride, unsigned int* sse, int* sum); -#define vpx_highbd_12_get16x16var vpx_highbd_12_get16x16var_neon +void vpx_highbd_12_get16x16var_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); +RTCD_EXTERN void (*vpx_highbd_12_get16x16var)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); void vpx_highbd_12_get8x8var_c(const uint8_t* src_ptr, int src_stride, @@ -1545,7 +1952,18 @@ void vpx_highbd_12_get8x8var_neon(const uint8_t* src_ptr, int ref_stride, unsigned int* sse, int* sum); -#define vpx_highbd_12_get8x8var vpx_highbd_12_get8x8var_neon +void vpx_highbd_12_get8x8var_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); +RTCD_EXTERN void (*vpx_highbd_12_get8x8var)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); unsigned int vpx_highbd_12_mse16x16_c(const uint8_t* src_ptr, int src_stride, @@ -1557,7 +1975,16 @@ unsigned int vpx_highbd_12_mse16x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_12_mse16x16 vpx_highbd_12_mse16x16_neon +unsigned int vpx_highbd_12_mse16x16_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_12_mse16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_12_mse16x8_c(const uint8_t* src_ptr, int src_stride, @@ -1569,10 +1996,19 @@ unsigned int vpx_highbd_12_mse16x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_12_mse16x8 vpx_highbd_12_mse16x8_neon - -unsigned int vpx_highbd_12_mse8x16_c(const uint8_t* src_ptr, - int src_stride, +unsigned int vpx_highbd_12_mse16x8_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_12_mse16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); + +unsigned int vpx_highbd_12_mse8x16_c(const uint8_t* src_ptr, + int src_stride, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); @@ -1581,7 +2017,16 @@ unsigned int vpx_highbd_12_mse8x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_12_mse8x16 vpx_highbd_12_mse8x16_neon +unsigned int vpx_highbd_12_mse8x16_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_12_mse8x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_12_mse8x8_c(const uint8_t* src_ptr, int src_stride, @@ -1593,7 +2038,16 @@ unsigned int vpx_highbd_12_mse8x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_12_mse8x8 vpx_highbd_12_mse8x8_neon +unsigned int vpx_highbd_12_mse8x8_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_12_mse8x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); uint32_t vpx_highbd_12_sub_pixel_avg_variance16x16_c( const uint8_t* src_ptr, @@ -2093,7 +2547,16 @@ unsigned int vpx_highbd_12_variance16x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_12_variance16x16 vpx_highbd_12_variance16x16_neon +unsigned int vpx_highbd_12_variance16x16_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_12_variance16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_12_variance16x32_c(const uint8_t* src_ptr, int src_stride, @@ -2105,7 +2568,16 @@ unsigned int vpx_highbd_12_variance16x32_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_12_variance16x32 vpx_highbd_12_variance16x32_neon +unsigned int vpx_highbd_12_variance16x32_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_12_variance16x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_12_variance16x8_c(const uint8_t* src_ptr, int src_stride, @@ -2117,7 +2589,16 @@ unsigned int vpx_highbd_12_variance16x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_12_variance16x8 vpx_highbd_12_variance16x8_neon +unsigned int vpx_highbd_12_variance16x8_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_12_variance16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_12_variance32x16_c(const uint8_t* src_ptr, int src_stride, @@ -2129,7 +2610,16 @@ unsigned int vpx_highbd_12_variance32x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_12_variance32x16 vpx_highbd_12_variance32x16_neon +unsigned int vpx_highbd_12_variance32x16_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_12_variance32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_12_variance32x32_c(const uint8_t* src_ptr, int src_stride, @@ -2141,7 +2631,16 @@ unsigned int vpx_highbd_12_variance32x32_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_12_variance32x32 vpx_highbd_12_variance32x32_neon +unsigned int vpx_highbd_12_variance32x32_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_12_variance32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_12_variance32x64_c(const uint8_t* src_ptr, int src_stride, @@ -2153,7 +2652,16 @@ unsigned int vpx_highbd_12_variance32x64_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_12_variance32x64 vpx_highbd_12_variance32x64_neon +unsigned int vpx_highbd_12_variance32x64_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_12_variance32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_12_variance4x4_c(const uint8_t* src_ptr, int src_stride, @@ -2165,7 +2673,16 @@ unsigned int vpx_highbd_12_variance4x4_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_12_variance4x4 vpx_highbd_12_variance4x4_neon +unsigned int vpx_highbd_12_variance4x4_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_12_variance4x4)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_12_variance4x8_c(const uint8_t* src_ptr, int src_stride, @@ -2177,7 +2694,16 @@ unsigned int vpx_highbd_12_variance4x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_12_variance4x8 vpx_highbd_12_variance4x8_neon +unsigned int vpx_highbd_12_variance4x8_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_12_variance4x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_12_variance64x32_c(const uint8_t* src_ptr, int src_stride, @@ -2189,7 +2715,16 @@ unsigned int vpx_highbd_12_variance64x32_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_12_variance64x32 vpx_highbd_12_variance64x32_neon +unsigned int vpx_highbd_12_variance64x32_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_12_variance64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_12_variance64x64_c(const uint8_t* src_ptr, int src_stride, @@ -2201,7 +2736,16 @@ unsigned int vpx_highbd_12_variance64x64_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_12_variance64x64 vpx_highbd_12_variance64x64_neon +unsigned int vpx_highbd_12_variance64x64_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_12_variance64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_12_variance8x16_c(const uint8_t* src_ptr, int src_stride, @@ -2213,7 +2757,16 @@ unsigned int vpx_highbd_12_variance8x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_12_variance8x16 vpx_highbd_12_variance8x16_neon +unsigned int vpx_highbd_12_variance8x16_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_12_variance8x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_12_variance8x4_c(const uint8_t* src_ptr, int src_stride, @@ -2225,7 +2778,16 @@ unsigned int vpx_highbd_12_variance8x4_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_12_variance8x4 vpx_highbd_12_variance8x4_neon +unsigned int vpx_highbd_12_variance8x4_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_12_variance8x4)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_12_variance8x8_c(const uint8_t* src_ptr, int src_stride, @@ -2237,7 +2799,16 @@ unsigned int vpx_highbd_12_variance8x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_12_variance8x8 vpx_highbd_12_variance8x8_neon +unsigned int vpx_highbd_12_variance8x8_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_12_variance8x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); void vpx_highbd_8_get16x16var_c(const uint8_t* src_ptr, int src_stride, @@ -2251,7 +2822,18 @@ void vpx_highbd_8_get16x16var_neon(const uint8_t* src_ptr, int ref_stride, unsigned int* sse, int* sum); -#define vpx_highbd_8_get16x16var vpx_highbd_8_get16x16var_neon +void vpx_highbd_8_get16x16var_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); +RTCD_EXTERN void (*vpx_highbd_8_get16x16var)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); void vpx_highbd_8_get8x8var_c(const uint8_t* src_ptr, int src_stride, @@ -2265,7 +2847,18 @@ void vpx_highbd_8_get8x8var_neon(const uint8_t* src_ptr, int ref_stride, unsigned int* sse, int* sum); -#define vpx_highbd_8_get8x8var vpx_highbd_8_get8x8var_neon +void vpx_highbd_8_get8x8var_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); +RTCD_EXTERN void (*vpx_highbd_8_get8x8var)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); unsigned int vpx_highbd_8_mse16x16_c(const uint8_t* src_ptr, int src_stride, @@ -2277,7 +2870,16 @@ unsigned int vpx_highbd_8_mse16x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_8_mse16x16 vpx_highbd_8_mse16x16_neon +unsigned int vpx_highbd_8_mse16x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_8_mse16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_8_mse16x8_c(const uint8_t* src_ptr, int src_stride, @@ -2289,7 +2891,16 @@ unsigned int vpx_highbd_8_mse16x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_8_mse16x8 vpx_highbd_8_mse16x8_neon +unsigned int vpx_highbd_8_mse16x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_8_mse16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_8_mse8x16_c(const uint8_t* src_ptr, int src_stride, @@ -2301,7 +2912,16 @@ unsigned int vpx_highbd_8_mse8x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_8_mse8x16 vpx_highbd_8_mse8x16_neon +unsigned int vpx_highbd_8_mse8x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_8_mse8x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_8_mse8x8_c(const uint8_t* src_ptr, int src_stride, @@ -2313,7 +2933,16 @@ unsigned int vpx_highbd_8_mse8x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_8_mse8x8 vpx_highbd_8_mse8x8_neon +unsigned int vpx_highbd_8_mse8x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_8_mse8x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); uint32_t vpx_highbd_8_sub_pixel_avg_variance16x16_c(const uint8_t* src_ptr, int src_stride, @@ -2806,7 +3435,16 @@ unsigned int vpx_highbd_8_variance16x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_8_variance16x16 vpx_highbd_8_variance16x16_neon +unsigned int vpx_highbd_8_variance16x16_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_8_variance16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_8_variance16x32_c(const uint8_t* src_ptr, int src_stride, @@ -2818,7 +3456,16 @@ unsigned int vpx_highbd_8_variance16x32_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_8_variance16x32 vpx_highbd_8_variance16x32_neon +unsigned int vpx_highbd_8_variance16x32_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_8_variance16x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_8_variance16x8_c(const uint8_t* src_ptr, int src_stride, @@ -2830,7 +3477,16 @@ unsigned int vpx_highbd_8_variance16x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_8_variance16x8 vpx_highbd_8_variance16x8_neon +unsigned int vpx_highbd_8_variance16x8_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_8_variance16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_8_variance32x16_c(const uint8_t* src_ptr, int src_stride, @@ -2842,7 +3498,16 @@ unsigned int vpx_highbd_8_variance32x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_8_variance32x16 vpx_highbd_8_variance32x16_neon +unsigned int vpx_highbd_8_variance32x16_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_8_variance32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_8_variance32x32_c(const uint8_t* src_ptr, int src_stride, @@ -2854,7 +3519,16 @@ unsigned int vpx_highbd_8_variance32x32_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_8_variance32x32 vpx_highbd_8_variance32x32_neon +unsigned int vpx_highbd_8_variance32x32_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_8_variance32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_8_variance32x64_c(const uint8_t* src_ptr, int src_stride, @@ -2866,7 +3540,16 @@ unsigned int vpx_highbd_8_variance32x64_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_8_variance32x64 vpx_highbd_8_variance32x64_neon +unsigned int vpx_highbd_8_variance32x64_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_8_variance32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_8_variance4x4_c(const uint8_t* src_ptr, int src_stride, @@ -2878,7 +3561,16 @@ unsigned int vpx_highbd_8_variance4x4_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_8_variance4x4 vpx_highbd_8_variance4x4_neon +unsigned int vpx_highbd_8_variance4x4_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_8_variance4x4)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_8_variance4x8_c(const uint8_t* src_ptr, int src_stride, @@ -2890,7 +3582,16 @@ unsigned int vpx_highbd_8_variance4x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_8_variance4x8 vpx_highbd_8_variance4x8_neon +unsigned int vpx_highbd_8_variance4x8_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_8_variance4x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_8_variance64x32_c(const uint8_t* src_ptr, int src_stride, @@ -2902,7 +3603,16 @@ unsigned int vpx_highbd_8_variance64x32_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_8_variance64x32 vpx_highbd_8_variance64x32_neon +unsigned int vpx_highbd_8_variance64x32_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_8_variance64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_8_variance64x64_c(const uint8_t* src_ptr, int src_stride, @@ -2914,7 +3624,16 @@ unsigned int vpx_highbd_8_variance64x64_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_8_variance64x64 vpx_highbd_8_variance64x64_neon +unsigned int vpx_highbd_8_variance64x64_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_8_variance64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_8_variance8x16_c(const uint8_t* src_ptr, int src_stride, @@ -2926,7 +3645,16 @@ unsigned int vpx_highbd_8_variance8x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_8_variance8x16 vpx_highbd_8_variance8x16_neon +unsigned int vpx_highbd_8_variance8x16_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_8_variance8x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_8_variance8x4_c(const uint8_t* src_ptr, int src_stride, @@ -2938,7 +3666,16 @@ unsigned int vpx_highbd_8_variance8x4_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_8_variance8x4 vpx_highbd_8_variance8x4_neon +unsigned int vpx_highbd_8_variance8x4_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_8_variance8x4)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_8_variance8x8_c(const uint8_t* src_ptr, int src_stride, @@ -2950,7 +3687,16 @@ unsigned int vpx_highbd_8_variance8x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_8_variance8x8 vpx_highbd_8_variance8x8_neon +unsigned int vpx_highbd_8_variance8x8_sve(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_8_variance8x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_avg_4x4_c(const uint8_t* s8, int p); unsigned int vpx_highbd_avg_4x4_neon(const uint8_t* s8, int p); @@ -2998,7 +3744,30 @@ void vpx_highbd_convolve8_neon(const uint16_t* src, int w, int h, int bd); -#define vpx_highbd_convolve8 vpx_highbd_convolve8_neon +void vpx_highbd_convolve8_sve2(const uint16_t* src, + ptrdiff_t src_stride, + uint16_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h, + int bd); +RTCD_EXTERN void (*vpx_highbd_convolve8)(const uint16_t* src, + ptrdiff_t src_stride, + uint16_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h, + int bd); void vpx_highbd_convolve8_avg_c(const uint16_t* src, ptrdiff_t src_stride, @@ -3024,7 +3793,30 @@ void vpx_highbd_convolve8_avg_neon(const uint16_t* src, int w, int h, int bd); -#define vpx_highbd_convolve8_avg vpx_highbd_convolve8_avg_neon +void vpx_highbd_convolve8_avg_sve2(const uint16_t* src, + ptrdiff_t src_stride, + uint16_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h, + int bd); +RTCD_EXTERN void (*vpx_highbd_convolve8_avg)(const uint16_t* src, + ptrdiff_t src_stride, + uint16_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h, + int bd); void vpx_highbd_convolve8_avg_horiz_c(const uint16_t* src, ptrdiff_t src_stride, @@ -3050,7 +3842,30 @@ void vpx_highbd_convolve8_avg_horiz_neon(const uint16_t* src, int w, int h, int bd); -#define vpx_highbd_convolve8_avg_horiz vpx_highbd_convolve8_avg_horiz_neon +void vpx_highbd_convolve8_avg_horiz_sve(const uint16_t* src, + ptrdiff_t src_stride, + uint16_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h, + int bd); +RTCD_EXTERN void (*vpx_highbd_convolve8_avg_horiz)(const uint16_t* src, + ptrdiff_t src_stride, + uint16_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h, + int bd); void vpx_highbd_convolve8_avg_vert_c(const uint16_t* src, ptrdiff_t src_stride, @@ -3076,7 +3891,30 @@ void vpx_highbd_convolve8_avg_vert_neon(const uint16_t* src, int w, int h, int bd); -#define vpx_highbd_convolve8_avg_vert vpx_highbd_convolve8_avg_vert_neon +void vpx_highbd_convolve8_avg_vert_sve2(const uint16_t* src, + ptrdiff_t src_stride, + uint16_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h, + int bd); +RTCD_EXTERN void (*vpx_highbd_convolve8_avg_vert)(const uint16_t* src, + ptrdiff_t src_stride, + uint16_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h, + int bd); void vpx_highbd_convolve8_horiz_c(const uint16_t* src, ptrdiff_t src_stride, @@ -3102,7 +3940,30 @@ void vpx_highbd_convolve8_horiz_neon(const uint16_t* src, int w, int h, int bd); -#define vpx_highbd_convolve8_horiz vpx_highbd_convolve8_horiz_neon +void vpx_highbd_convolve8_horiz_sve(const uint16_t* src, + ptrdiff_t src_stride, + uint16_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h, + int bd); +RTCD_EXTERN void (*vpx_highbd_convolve8_horiz)(const uint16_t* src, + ptrdiff_t src_stride, + uint16_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h, + int bd); void vpx_highbd_convolve8_vert_c(const uint16_t* src, ptrdiff_t src_stride, @@ -3128,7 +3989,30 @@ void vpx_highbd_convolve8_vert_neon(const uint16_t* src, int w, int h, int bd); -#define vpx_highbd_convolve8_vert vpx_highbd_convolve8_vert_neon +void vpx_highbd_convolve8_vert_sve2(const uint16_t* src, + ptrdiff_t src_stride, + uint16_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h, + int bd); +RTCD_EXTERN void (*vpx_highbd_convolve8_vert)(const uint16_t* src, + ptrdiff_t src_stride, + uint16_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h, + int bd); void vpx_highbd_convolve_avg_c(const uint16_t* src, ptrdiff_t src_stride, @@ -4144,28 +5028,20 @@ void vpx_highbd_minmax_8x8_neon(const uint8_t* s8, void vpx_highbd_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_highbd_quantize_b_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vpx_highbd_quantize_b vpx_highbd_quantize_b_neon void vpx_highbd_quantize_b_32x32_c( @@ -4628,12 +5504,312 @@ void vpx_highbd_sad8x8x4d_neon(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_highbd_sad8x8x4d vpx_highbd_sad8x8x4d_neon -int vpx_highbd_satd_c(const tran_low_t* coeff, int length); -int vpx_highbd_satd_neon(const tran_low_t* coeff, int length); -#define vpx_highbd_satd vpx_highbd_satd_neon +unsigned int vpx_highbd_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_16x16 vpx_highbd_sad_skip_16x16_neon -void vpx_highbd_subtract_block_c(int rows, - int cols, +void vpx_highbd_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_16x16x4d vpx_highbd_sad_skip_16x16x4d_neon + +unsigned int vpx_highbd_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_16x32 vpx_highbd_sad_skip_16x32_neon + +void vpx_highbd_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_16x32x4d vpx_highbd_sad_skip_16x32x4d_neon + +unsigned int vpx_highbd_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_16x8 vpx_highbd_sad_skip_16x8_neon + +void vpx_highbd_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_16x8x4d vpx_highbd_sad_skip_16x8x4d_neon + +unsigned int vpx_highbd_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_32x16 vpx_highbd_sad_skip_32x16_neon + +void vpx_highbd_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_32x16x4d vpx_highbd_sad_skip_32x16x4d_neon + +unsigned int vpx_highbd_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_32x32 vpx_highbd_sad_skip_32x32_neon + +void vpx_highbd_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_32x32x4d vpx_highbd_sad_skip_32x32x4d_neon + +unsigned int vpx_highbd_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x64_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_32x64 vpx_highbd_sad_skip_32x64_neon + +void vpx_highbd_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x64x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_32x64x4d vpx_highbd_sad_skip_32x64x4d_neon + +unsigned int vpx_highbd_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_4x4_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_4x4 vpx_highbd_sad_skip_4x4_neon + +void vpx_highbd_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_4x4x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_4x4x4d vpx_highbd_sad_skip_4x4x4d_neon + +unsigned int vpx_highbd_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_4x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_4x8 vpx_highbd_sad_skip_4x8_neon + +void vpx_highbd_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_4x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_4x8x4d vpx_highbd_sad_skip_4x8x4d_neon + +unsigned int vpx_highbd_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_64x32 vpx_highbd_sad_skip_64x32_neon + +void vpx_highbd_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_64x32x4d vpx_highbd_sad_skip_64x32x4d_neon + +unsigned int vpx_highbd_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x64_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_64x64 vpx_highbd_sad_skip_64x64_neon + +void vpx_highbd_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x64x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_64x64x4d vpx_highbd_sad_skip_64x64x4d_neon + +unsigned int vpx_highbd_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_8x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x16 vpx_highbd_sad_skip_8x16_neon + +void vpx_highbd_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_8x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x16x4d vpx_highbd_sad_skip_8x16x4d_neon + +unsigned int vpx_highbd_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_8x4_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x4 vpx_highbd_sad_skip_8x4_neon + +void vpx_highbd_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_8x4x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x4x4d vpx_highbd_sad_skip_8x4x4d_neon + +unsigned int vpx_highbd_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_8x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x8 vpx_highbd_sad_skip_8x8_neon + +void vpx_highbd_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_8x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x8x4d vpx_highbd_sad_skip_8x8x4d_neon + +int vpx_highbd_satd_c(const tran_low_t* coeff, int length); +int vpx_highbd_satd_neon(const tran_low_t* coeff, int length); +#define vpx_highbd_satd vpx_highbd_satd_neon + +int64_t vpx_highbd_sse_c(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +int64_t vpx_highbd_sse_neon(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +#define vpx_highbd_sse vpx_highbd_sse_neon + +void vpx_highbd_subtract_block_c(int rows, + int cols, int16_t* diff_ptr, ptrdiff_t diff_stride, const uint8_t* src8_ptr, @@ -5064,7 +6240,16 @@ unsigned int vpx_mse16x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_mse16x16 vpx_mse16x16_neon +unsigned int vpx_mse16x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_mse16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_mse16x8_c(const uint8_t* src_ptr, int src_stride, @@ -5076,7 +6261,16 @@ unsigned int vpx_mse16x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_mse16x8 vpx_mse16x8_neon +unsigned int vpx_mse16x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_mse16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_mse8x16_c(const uint8_t* src_ptr, int src_stride, @@ -5088,7 +6282,16 @@ unsigned int vpx_mse8x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_mse8x16 vpx_mse8x16_neon +unsigned int vpx_mse8x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_mse8x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_mse8x8_c(const uint8_t* src_ptr, int src_stride, @@ -5100,7 +6303,16 @@ unsigned int vpx_mse8x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_mse8x8 vpx_mse8x8_neon +unsigned int vpx_mse8x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_mse8x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); void vpx_plane_add_noise_c(uint8_t* start, const int8_t* noise, @@ -5130,28 +6342,20 @@ void vpx_post_proc_down_and_across_mb_row_neon(unsigned char* src, void vpx_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vpx_quantize_b vpx_quantize_b_neon void vpx_quantize_b_32x32_c(const tran_low_t* coeff_ptr, @@ -5178,7 +6382,14 @@ unsigned int vpx_sad16x16_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad16x16 vpx_sad16x16_neon +unsigned int vpx_sad16x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad16x16_avg_c(const uint8_t* src_ptr, int src_stride, @@ -5190,7 +6401,16 @@ unsigned int vpx_sad16x16_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad16x16_avg vpx_sad16x16_avg_neon +unsigned int vpx_sad16x16_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad16x16_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad16x16x4d_c(const uint8_t* src_ptr, int src_stride, @@ -5202,7 +6422,16 @@ void vpx_sad16x16x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad16x16x4d vpx_sad16x16x4d_neon +void vpx_sad16x16x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad16x16x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad16x32_c(const uint8_t* src_ptr, int src_stride, @@ -5212,7 +6441,14 @@ unsigned int vpx_sad16x32_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad16x32 vpx_sad16x32_neon +unsigned int vpx_sad16x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad16x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad16x32_avg_c(const uint8_t* src_ptr, int src_stride, @@ -5224,7 +6460,16 @@ unsigned int vpx_sad16x32_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad16x32_avg vpx_sad16x32_avg_neon +unsigned int vpx_sad16x32_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad16x32_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad16x32x4d_c(const uint8_t* src_ptr, int src_stride, @@ -5236,7 +6481,16 @@ void vpx_sad16x32x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad16x32x4d vpx_sad16x32x4d_neon +void vpx_sad16x32x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad16x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad16x8_c(const uint8_t* src_ptr, int src_stride, @@ -5246,7 +6500,14 @@ unsigned int vpx_sad16x8_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad16x8 vpx_sad16x8_neon +unsigned int vpx_sad16x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad16x8_avg_c(const uint8_t* src_ptr, int src_stride, @@ -5258,7 +6519,16 @@ unsigned int vpx_sad16x8_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad16x8_avg vpx_sad16x8_avg_neon +unsigned int vpx_sad16x8_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad16x8_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad16x8x4d_c(const uint8_t* src_ptr, int src_stride, @@ -5270,7 +6540,16 @@ void vpx_sad16x8x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad16x8x4d vpx_sad16x8x4d_neon +void vpx_sad16x8x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad16x8x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad32x16_c(const uint8_t* src_ptr, int src_stride, @@ -5280,7 +6559,14 @@ unsigned int vpx_sad32x16_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad32x16 vpx_sad32x16_neon +unsigned int vpx_sad32x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad32x16_avg_c(const uint8_t* src_ptr, int src_stride, @@ -5292,7 +6578,16 @@ unsigned int vpx_sad32x16_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad32x16_avg vpx_sad32x16_avg_neon +unsigned int vpx_sad32x16_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad32x16_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad32x16x4d_c(const uint8_t* src_ptr, int src_stride, @@ -5304,7 +6599,16 @@ void vpx_sad32x16x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad32x16x4d vpx_sad32x16x4d_neon +void vpx_sad32x16x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad32x16x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad32x32_c(const uint8_t* src_ptr, int src_stride, @@ -5314,7 +6618,14 @@ unsigned int vpx_sad32x32_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad32x32 vpx_sad32x32_neon +unsigned int vpx_sad32x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad32x32_avg_c(const uint8_t* src_ptr, int src_stride, @@ -5326,7 +6637,16 @@ unsigned int vpx_sad32x32_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad32x32_avg vpx_sad32x32_avg_neon +unsigned int vpx_sad32x32_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad32x32_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad32x32x4d_c(const uint8_t* src_ptr, int src_stride, @@ -5338,7 +6658,16 @@ void vpx_sad32x32x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad32x32x4d vpx_sad32x32x4d_neon +void vpx_sad32x32x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad32x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad32x64_c(const uint8_t* src_ptr, int src_stride, @@ -5348,7 +6677,14 @@ unsigned int vpx_sad32x64_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad32x64 vpx_sad32x64_neon +unsigned int vpx_sad32x64_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad32x64_avg_c(const uint8_t* src_ptr, int src_stride, @@ -5360,10 +6696,19 @@ unsigned int vpx_sad32x64_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad32x64_avg vpx_sad32x64_avg_neon - -void vpx_sad32x64x4d_c(const uint8_t* src_ptr, - int src_stride, +unsigned int vpx_sad32x64_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad32x64_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); + +void vpx_sad32x64x4d_c(const uint8_t* src_ptr, + int src_stride, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); @@ -5372,7 +6717,16 @@ void vpx_sad32x64x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad32x64x4d vpx_sad32x64x4d_neon +void vpx_sad32x64x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad32x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad4x4_c(const uint8_t* src_ptr, int src_stride, @@ -5450,7 +6804,14 @@ unsigned int vpx_sad64x32_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad64x32 vpx_sad64x32_neon +unsigned int vpx_sad64x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad64x32_avg_c(const uint8_t* src_ptr, int src_stride, @@ -5462,7 +6823,16 @@ unsigned int vpx_sad64x32_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad64x32_avg vpx_sad64x32_avg_neon +unsigned int vpx_sad64x32_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad64x32_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad64x32x4d_c(const uint8_t* src_ptr, int src_stride, @@ -5474,143 +6844,591 @@ void vpx_sad64x32x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad64x32x4d vpx_sad64x32x4d_neon +void vpx_sad64x32x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad64x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad64x64_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad64x64_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +unsigned int vpx_sad64x64_avg_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +unsigned int vpx_sad64x64_avg_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +unsigned int vpx_sad64x64_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad64x64_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); + +void vpx_sad64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad64x64x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad64x64x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad64x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad8x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad8x16 vpx_sad8x16_neon + +unsigned int vpx_sad8x16_avg_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +unsigned int vpx_sad8x16_avg_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +#define vpx_sad8x16_avg vpx_sad8x16_avg_neon + +void vpx_sad8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad8x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad8x16x4d vpx_sad8x16x4d_neon + +unsigned int vpx_sad8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad8x4_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad8x4 vpx_sad8x4_neon + +unsigned int vpx_sad8x4_avg_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +unsigned int vpx_sad8x4_avg_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +#define vpx_sad8x4_avg vpx_sad8x4_avg_neon + +void vpx_sad8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad8x4x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad8x4x4d vpx_sad8x4x4d_neon + +unsigned int vpx_sad8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad8x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad8x8 vpx_sad8x8_neon + +unsigned int vpx_sad8x8_avg_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +unsigned int vpx_sad8x8_avg_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +#define vpx_sad8x8_avg vpx_sad8x8_avg_neon + +void vpx_sad8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad8x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad8x8x4d vpx_sad8x8x4d_neon + +unsigned int vpx_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x16x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_16x16x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_16x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x32x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_16x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x8x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_16x8x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x16x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x16x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x32x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x64_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x64_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x64x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x64x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_4x4_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x4 vpx_sad_skip_4x4_neon + +void vpx_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_4x4x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x4x4d vpx_sad_skip_4x4x4d_neon + +unsigned int vpx_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_4x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x8 vpx_sad_skip_4x8_neon + +void vpx_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_4x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x8x4d vpx_sad_skip_4x8x4d_neon + +unsigned int vpx_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x32x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_64x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x64_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x64_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x64x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x64x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_64x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x16 vpx_sad_skip_8x16_neon -unsigned int vpx_sad64x64_c(const uint8_t* src_ptr, +void vpx_sad_skip_8x16x4d_c(const uint8_t* src_ptr, int src_stride, - const uint8_t* ref_ptr, - int ref_stride); -unsigned int vpx_sad64x64_neon(const uint8_t* src_ptr, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x16x4d_neon(const uint8_t* src_ptr, int src_stride, - const uint8_t* ref_ptr, - int ref_stride); -#define vpx_sad64x64 vpx_sad64x64_neon + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x16x4d vpx_sad_skip_8x16x4d_neon -unsigned int vpx_sad64x64_avg_c(const uint8_t* src_ptr, +unsigned int vpx_sad_skip_8x4_c(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, - int ref_stride, - const uint8_t* second_pred); -unsigned int vpx_sad64x64_avg_neon(const uint8_t* src_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x4_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, - int ref_stride, - const uint8_t* second_pred); -#define vpx_sad64x64_avg vpx_sad64x64_avg_neon - -void vpx_sad64x64x4d_c(const uint8_t* src_ptr, - int src_stride, - const uint8_t* const ref_array[4], - int ref_stride, - uint32_t sad_array[4]); -void vpx_sad64x64x4d_neon(const uint8_t* src_ptr, - int src_stride, - const uint8_t* const ref_array[4], - int ref_stride, - uint32_t sad_array[4]); -#define vpx_sad64x64x4d vpx_sad64x64x4d_neon + int ref_stride); +#define vpx_sad_skip_8x4 vpx_sad_skip_8x4_neon -unsigned int vpx_sad8x16_c(const uint8_t* src_ptr, +void vpx_sad_skip_8x4x4d_c(const uint8_t* src_ptr, int src_stride, - const uint8_t* ref_ptr, - int ref_stride); -unsigned int vpx_sad8x16_neon(const uint8_t* src_ptr, - int src_stride, - const uint8_t* ref_ptr, - int ref_stride); -#define vpx_sad8x16 vpx_sad8x16_neon - -unsigned int vpx_sad8x16_avg_c(const uint8_t* src_ptr, - int src_stride, - const uint8_t* ref_ptr, - int ref_stride, - const uint8_t* second_pred); -unsigned int vpx_sad8x16_avg_neon(const uint8_t* src_ptr, - int src_stride, - const uint8_t* ref_ptr, - int ref_stride, - const uint8_t* second_pred); -#define vpx_sad8x16_avg vpx_sad8x16_avg_neon - -void vpx_sad8x16x4d_c(const uint8_t* src_ptr, - int src_stride, - const uint8_t* const ref_array[4], - int ref_stride, - uint32_t sad_array[4]); -void vpx_sad8x16x4d_neon(const uint8_t* src_ptr, - int src_stride, - const uint8_t* const ref_array[4], - int ref_stride, - uint32_t sad_array[4]); -#define vpx_sad8x16x4d vpx_sad8x16x4d_neon - -unsigned int vpx_sad8x4_c(const uint8_t* src_ptr, - int src_stride, - const uint8_t* ref_ptr, - int ref_stride); -unsigned int vpx_sad8x4_neon(const uint8_t* src_ptr, - int src_stride, - const uint8_t* ref_ptr, - int ref_stride); -#define vpx_sad8x4 vpx_sad8x4_neon - -unsigned int vpx_sad8x4_avg_c(const uint8_t* src_ptr, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x4x4d_neon(const uint8_t* src_ptr, int src_stride, - const uint8_t* ref_ptr, + const uint8_t* const ref_array[4], int ref_stride, - const uint8_t* second_pred); -unsigned int vpx_sad8x4_avg_neon(const uint8_t* src_ptr, - int src_stride, - const uint8_t* ref_ptr, - int ref_stride, - const uint8_t* second_pred); -#define vpx_sad8x4_avg vpx_sad8x4_avg_neon - -void vpx_sad8x4x4d_c(const uint8_t* src_ptr, - int src_stride, - const uint8_t* const ref_array[4], - int ref_stride, - uint32_t sad_array[4]); -void vpx_sad8x4x4d_neon(const uint8_t* src_ptr, - int src_stride, - const uint8_t* const ref_array[4], - int ref_stride, - uint32_t sad_array[4]); -#define vpx_sad8x4x4d vpx_sad8x4x4d_neon + uint32_t sad_array[4]); +#define vpx_sad_skip_8x4x4d vpx_sad_skip_8x4x4d_neon -unsigned int vpx_sad8x8_c(const uint8_t* src_ptr, - int src_stride, - const uint8_t* ref_ptr, - int ref_stride); -unsigned int vpx_sad8x8_neon(const uint8_t* src_ptr, - int src_stride, - const uint8_t* ref_ptr, - int ref_stride); -#define vpx_sad8x8 vpx_sad8x8_neon +unsigned int vpx_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x8 vpx_sad_skip_8x8_neon -unsigned int vpx_sad8x8_avg_c(const uint8_t* src_ptr, +void vpx_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x8x4d_neon(const uint8_t* src_ptr, int src_stride, - const uint8_t* ref_ptr, + const uint8_t* const ref_array[4], int ref_stride, - const uint8_t* second_pred); -unsigned int vpx_sad8x8_avg_neon(const uint8_t* src_ptr, - int src_stride, - const uint8_t* ref_ptr, - int ref_stride, - const uint8_t* second_pred); -#define vpx_sad8x8_avg vpx_sad8x8_avg_neon - -void vpx_sad8x8x4d_c(const uint8_t* src_ptr, - int src_stride, - const uint8_t* const ref_array[4], - int ref_stride, - uint32_t sad_array[4]); -void vpx_sad8x8x4d_neon(const uint8_t* src_ptr, - int src_stride, - const uint8_t* const ref_array[4], - int ref_stride, - uint32_t sad_array[4]); -#define vpx_sad8x8x4d vpx_sad8x8x4d_neon + uint32_t sad_array[4]); +#define vpx_sad_skip_8x8x4d vpx_sad_skip_8x8x4d_neon int vpx_satd_c(const tran_low_t* coeff, int length); int vpx_satd_neon(const tran_low_t* coeff, int length); @@ -5705,6 +7523,31 @@ void vpx_scaled_vert_c(const uint8_t* src, int h); #define vpx_scaled_vert vpx_scaled_vert_c +int64_t vpx_sse_c(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +int64_t vpx_sse_neon(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +int64_t vpx_sse_neon_dotprod(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +RTCD_EXTERN int64_t (*vpx_sse)(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); + uint32_t vpx_sub_pixel_avg_variance16x16_c(const uint8_t* src_ptr, int src_stride, int x_offset, @@ -6167,7 +8010,10 @@ void vpx_subtract_block_neon(int rows, uint64_t vpx_sum_squares_2d_i16_c(const int16_t* src, int stride, int size); uint64_t vpx_sum_squares_2d_i16_neon(const int16_t* src, int stride, int size); -#define vpx_sum_squares_2d_i16 vpx_sum_squares_2d_i16_neon +uint64_t vpx_sum_squares_2d_i16_sve(const int16_t* src, int stride, int size); +RTCD_EXTERN uint64_t (*vpx_sum_squares_2d_i16)(const int16_t* src, + int stride, + int size); void vpx_tm_predictor_16x16_c(uint8_t* dst, ptrdiff_t stride, @@ -6259,7 +8105,16 @@ unsigned int vpx_variance16x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance16x16 vpx_variance16x16_neon +unsigned int vpx_variance16x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance16x32_c(const uint8_t* src_ptr, int src_stride, @@ -6271,7 +8126,16 @@ unsigned int vpx_variance16x32_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance16x32 vpx_variance16x32_neon +unsigned int vpx_variance16x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance16x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance16x8_c(const uint8_t* src_ptr, int src_stride, @@ -6283,7 +8147,16 @@ unsigned int vpx_variance16x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance16x8 vpx_variance16x8_neon +unsigned int vpx_variance16x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance32x16_c(const uint8_t* src_ptr, int src_stride, @@ -6295,7 +8168,16 @@ unsigned int vpx_variance32x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance32x16 vpx_variance32x16_neon +unsigned int vpx_variance32x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance32x32_c(const uint8_t* src_ptr, int src_stride, @@ -6307,7 +8189,16 @@ unsigned int vpx_variance32x32_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance32x32 vpx_variance32x32_neon +unsigned int vpx_variance32x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance32x64_c(const uint8_t* src_ptr, int src_stride, @@ -6319,7 +8210,16 @@ unsigned int vpx_variance32x64_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance32x64 vpx_variance32x64_neon +unsigned int vpx_variance32x64_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance4x4_c(const uint8_t* src_ptr, int src_stride, @@ -6331,7 +8231,16 @@ unsigned int vpx_variance4x4_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance4x4 vpx_variance4x4_neon +unsigned int vpx_variance4x4_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance4x4)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance4x8_c(const uint8_t* src_ptr, int src_stride, @@ -6343,7 +8252,16 @@ unsigned int vpx_variance4x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance4x8 vpx_variance4x8_neon +unsigned int vpx_variance4x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance4x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance64x32_c(const uint8_t* src_ptr, int src_stride, @@ -6355,7 +8273,16 @@ unsigned int vpx_variance64x32_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance64x32 vpx_variance64x32_neon +unsigned int vpx_variance64x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance64x64_c(const uint8_t* src_ptr, int src_stride, @@ -6367,7 +8294,16 @@ unsigned int vpx_variance64x64_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance64x64 vpx_variance64x64_neon +unsigned int vpx_variance64x64_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance8x16_c(const uint8_t* src_ptr, int src_stride, @@ -6379,7 +8315,16 @@ unsigned int vpx_variance8x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance8x16 vpx_variance8x16_neon +unsigned int vpx_variance8x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance8x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance8x4_c(const uint8_t* src_ptr, int src_stride, @@ -6391,7 +8336,16 @@ unsigned int vpx_variance8x4_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance8x4 vpx_variance8x4_neon +unsigned int vpx_variance8x4_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance8x4)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance8x8_c(const uint8_t* src_ptr, int src_stride, @@ -6403,7 +8357,16 @@ unsigned int vpx_variance8x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance8x8 vpx_variance8x8_neon +unsigned int vpx_variance8x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance8x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); void vpx_ve_predictor_4x4_c(uint8_t* dst, ptrdiff_t stride, @@ -6425,6 +8388,549 @@ static void setup_rtcd_internal(void) { int flags = arm_cpu_caps(); (void)flags; + + vpx_convolve8 = vpx_convolve8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_convolve8 = vpx_convolve8_neon_dotprod; + } + if (flags & HAS_NEON_I8MM) { + vpx_convolve8 = vpx_convolve8_neon_i8mm; + } + vpx_convolve8_avg = vpx_convolve8_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_convolve8_avg = vpx_convolve8_avg_neon_dotprod; + } + if (flags & HAS_NEON_I8MM) { + vpx_convolve8_avg = vpx_convolve8_avg_neon_i8mm; + } + vpx_convolve8_avg_horiz = vpx_convolve8_avg_horiz_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_convolve8_avg_horiz = vpx_convolve8_avg_horiz_neon_dotprod; + } + if (flags & HAS_NEON_I8MM) { + vpx_convolve8_avg_horiz = vpx_convolve8_avg_horiz_neon_i8mm; + } + vpx_convolve8_avg_vert = vpx_convolve8_avg_vert_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_convolve8_avg_vert = vpx_convolve8_avg_vert_neon_dotprod; + } + if (flags & HAS_NEON_I8MM) { + vpx_convolve8_avg_vert = vpx_convolve8_avg_vert_neon_i8mm; + } + vpx_convolve8_horiz = vpx_convolve8_horiz_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_convolve8_horiz = vpx_convolve8_horiz_neon_dotprod; + } + if (flags & HAS_NEON_I8MM) { + vpx_convolve8_horiz = vpx_convolve8_horiz_neon_i8mm; + } + vpx_convolve8_vert = vpx_convolve8_vert_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_convolve8_vert = vpx_convolve8_vert_neon_dotprod; + } + if (flags & HAS_NEON_I8MM) { + vpx_convolve8_vert = vpx_convolve8_vert_neon_i8mm; + } + vpx_get16x16var = vpx_get16x16var_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_get16x16var = vpx_get16x16var_neon_dotprod; + } + vpx_get4x4sse_cs = vpx_get4x4sse_cs_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_get4x4sse_cs = vpx_get4x4sse_cs_neon_dotprod; + } + vpx_get8x8var = vpx_get8x8var_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_get8x8var = vpx_get8x8var_neon_dotprod; + } + vpx_highbd_10_get16x16var = vpx_highbd_10_get16x16var_neon; + if (flags & HAS_SVE) { + vpx_highbd_10_get16x16var = vpx_highbd_10_get16x16var_sve; + } + vpx_highbd_10_get8x8var = vpx_highbd_10_get8x8var_neon; + if (flags & HAS_SVE) { + vpx_highbd_10_get8x8var = vpx_highbd_10_get8x8var_sve; + } + vpx_highbd_10_mse16x16 = vpx_highbd_10_mse16x16_neon; + if (flags & HAS_SVE) { + vpx_highbd_10_mse16x16 = vpx_highbd_10_mse16x16_sve; + } + vpx_highbd_10_mse16x8 = vpx_highbd_10_mse16x8_neon; + if (flags & HAS_SVE) { + vpx_highbd_10_mse16x8 = vpx_highbd_10_mse16x8_sve; + } + vpx_highbd_10_mse8x16 = vpx_highbd_10_mse8x16_neon; + if (flags & HAS_SVE) { + vpx_highbd_10_mse8x16 = vpx_highbd_10_mse8x16_sve; + } + vpx_highbd_10_mse8x8 = vpx_highbd_10_mse8x8_neon; + if (flags & HAS_SVE) { + vpx_highbd_10_mse8x8 = vpx_highbd_10_mse8x8_sve; + } + vpx_highbd_10_variance16x16 = vpx_highbd_10_variance16x16_neon; + if (flags & HAS_SVE) { + vpx_highbd_10_variance16x16 = vpx_highbd_10_variance16x16_sve; + } + vpx_highbd_10_variance16x32 = vpx_highbd_10_variance16x32_neon; + if (flags & HAS_SVE) { + vpx_highbd_10_variance16x32 = vpx_highbd_10_variance16x32_sve; + } + vpx_highbd_10_variance16x8 = vpx_highbd_10_variance16x8_neon; + if (flags & HAS_SVE) { + vpx_highbd_10_variance16x8 = vpx_highbd_10_variance16x8_sve; + } + vpx_highbd_10_variance32x16 = vpx_highbd_10_variance32x16_neon; + if (flags & HAS_SVE) { + vpx_highbd_10_variance32x16 = vpx_highbd_10_variance32x16_sve; + } + vpx_highbd_10_variance32x32 = vpx_highbd_10_variance32x32_neon; + if (flags & HAS_SVE) { + vpx_highbd_10_variance32x32 = vpx_highbd_10_variance32x32_sve; + } + vpx_highbd_10_variance32x64 = vpx_highbd_10_variance32x64_neon; + if (flags & HAS_SVE) { + vpx_highbd_10_variance32x64 = vpx_highbd_10_variance32x64_sve; + } + vpx_highbd_10_variance4x4 = vpx_highbd_10_variance4x4_neon; + if (flags & HAS_SVE) { + vpx_highbd_10_variance4x4 = vpx_highbd_10_variance4x4_sve; + } + vpx_highbd_10_variance4x8 = vpx_highbd_10_variance4x8_neon; + if (flags & HAS_SVE) { + vpx_highbd_10_variance4x8 = vpx_highbd_10_variance4x8_sve; + } + vpx_highbd_10_variance64x32 = vpx_highbd_10_variance64x32_neon; + if (flags & HAS_SVE) { + vpx_highbd_10_variance64x32 = vpx_highbd_10_variance64x32_sve; + } + vpx_highbd_10_variance64x64 = vpx_highbd_10_variance64x64_neon; + if (flags & HAS_SVE) { + vpx_highbd_10_variance64x64 = vpx_highbd_10_variance64x64_sve; + } + vpx_highbd_10_variance8x16 = vpx_highbd_10_variance8x16_neon; + if (flags & HAS_SVE) { + vpx_highbd_10_variance8x16 = vpx_highbd_10_variance8x16_sve; + } + vpx_highbd_10_variance8x4 = vpx_highbd_10_variance8x4_neon; + if (flags & HAS_SVE) { + vpx_highbd_10_variance8x4 = vpx_highbd_10_variance8x4_sve; + } + vpx_highbd_10_variance8x8 = vpx_highbd_10_variance8x8_neon; + if (flags & HAS_SVE) { + vpx_highbd_10_variance8x8 = vpx_highbd_10_variance8x8_sve; + } + vpx_highbd_12_get16x16var = vpx_highbd_12_get16x16var_neon; + if (flags & HAS_SVE) { + vpx_highbd_12_get16x16var = vpx_highbd_12_get16x16var_sve; + } + vpx_highbd_12_get8x8var = vpx_highbd_12_get8x8var_neon; + if (flags & HAS_SVE) { + vpx_highbd_12_get8x8var = vpx_highbd_12_get8x8var_sve; + } + vpx_highbd_12_mse16x16 = vpx_highbd_12_mse16x16_neon; + if (flags & HAS_SVE) { + vpx_highbd_12_mse16x16 = vpx_highbd_12_mse16x16_sve; + } + vpx_highbd_12_mse16x8 = vpx_highbd_12_mse16x8_neon; + if (flags & HAS_SVE) { + vpx_highbd_12_mse16x8 = vpx_highbd_12_mse16x8_sve; + } + vpx_highbd_12_mse8x16 = vpx_highbd_12_mse8x16_neon; + if (flags & HAS_SVE) { + vpx_highbd_12_mse8x16 = vpx_highbd_12_mse8x16_sve; + } + vpx_highbd_12_mse8x8 = vpx_highbd_12_mse8x8_neon; + if (flags & HAS_SVE) { + vpx_highbd_12_mse8x8 = vpx_highbd_12_mse8x8_sve; + } + vpx_highbd_12_variance16x16 = vpx_highbd_12_variance16x16_neon; + if (flags & HAS_SVE) { + vpx_highbd_12_variance16x16 = vpx_highbd_12_variance16x16_sve; + } + vpx_highbd_12_variance16x32 = vpx_highbd_12_variance16x32_neon; + if (flags & HAS_SVE) { + vpx_highbd_12_variance16x32 = vpx_highbd_12_variance16x32_sve; + } + vpx_highbd_12_variance16x8 = vpx_highbd_12_variance16x8_neon; + if (flags & HAS_SVE) { + vpx_highbd_12_variance16x8 = vpx_highbd_12_variance16x8_sve; + } + vpx_highbd_12_variance32x16 = vpx_highbd_12_variance32x16_neon; + if (flags & HAS_SVE) { + vpx_highbd_12_variance32x16 = vpx_highbd_12_variance32x16_sve; + } + vpx_highbd_12_variance32x32 = vpx_highbd_12_variance32x32_neon; + if (flags & HAS_SVE) { + vpx_highbd_12_variance32x32 = vpx_highbd_12_variance32x32_sve; + } + vpx_highbd_12_variance32x64 = vpx_highbd_12_variance32x64_neon; + if (flags & HAS_SVE) { + vpx_highbd_12_variance32x64 = vpx_highbd_12_variance32x64_sve; + } + vpx_highbd_12_variance4x4 = vpx_highbd_12_variance4x4_neon; + if (flags & HAS_SVE) { + vpx_highbd_12_variance4x4 = vpx_highbd_12_variance4x4_sve; + } + vpx_highbd_12_variance4x8 = vpx_highbd_12_variance4x8_neon; + if (flags & HAS_SVE) { + vpx_highbd_12_variance4x8 = vpx_highbd_12_variance4x8_sve; + } + vpx_highbd_12_variance64x32 = vpx_highbd_12_variance64x32_neon; + if (flags & HAS_SVE) { + vpx_highbd_12_variance64x32 = vpx_highbd_12_variance64x32_sve; + } + vpx_highbd_12_variance64x64 = vpx_highbd_12_variance64x64_neon; + if (flags & HAS_SVE) { + vpx_highbd_12_variance64x64 = vpx_highbd_12_variance64x64_sve; + } + vpx_highbd_12_variance8x16 = vpx_highbd_12_variance8x16_neon; + if (flags & HAS_SVE) { + vpx_highbd_12_variance8x16 = vpx_highbd_12_variance8x16_sve; + } + vpx_highbd_12_variance8x4 = vpx_highbd_12_variance8x4_neon; + if (flags & HAS_SVE) { + vpx_highbd_12_variance8x4 = vpx_highbd_12_variance8x4_sve; + } + vpx_highbd_12_variance8x8 = vpx_highbd_12_variance8x8_neon; + if (flags & HAS_SVE) { + vpx_highbd_12_variance8x8 = vpx_highbd_12_variance8x8_sve; + } + vpx_highbd_8_get16x16var = vpx_highbd_8_get16x16var_neon; + if (flags & HAS_SVE) { + vpx_highbd_8_get16x16var = vpx_highbd_8_get16x16var_sve; + } + vpx_highbd_8_get8x8var = vpx_highbd_8_get8x8var_neon; + if (flags & HAS_SVE) { + vpx_highbd_8_get8x8var = vpx_highbd_8_get8x8var_sve; + } + vpx_highbd_8_mse16x16 = vpx_highbd_8_mse16x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_highbd_8_mse16x16 = vpx_highbd_8_mse16x16_neon_dotprod; + } + vpx_highbd_8_mse16x8 = vpx_highbd_8_mse16x8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_highbd_8_mse16x8 = vpx_highbd_8_mse16x8_neon_dotprod; + } + vpx_highbd_8_mse8x16 = vpx_highbd_8_mse8x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_highbd_8_mse8x16 = vpx_highbd_8_mse8x16_neon_dotprod; + } + vpx_highbd_8_mse8x8 = vpx_highbd_8_mse8x8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_highbd_8_mse8x8 = vpx_highbd_8_mse8x8_neon_dotprod; + } + vpx_highbd_8_variance16x16 = vpx_highbd_8_variance16x16_neon; + if (flags & HAS_SVE) { + vpx_highbd_8_variance16x16 = vpx_highbd_8_variance16x16_sve; + } + vpx_highbd_8_variance16x32 = vpx_highbd_8_variance16x32_neon; + if (flags & HAS_SVE) { + vpx_highbd_8_variance16x32 = vpx_highbd_8_variance16x32_sve; + } + vpx_highbd_8_variance16x8 = vpx_highbd_8_variance16x8_neon; + if (flags & HAS_SVE) { + vpx_highbd_8_variance16x8 = vpx_highbd_8_variance16x8_sve; + } + vpx_highbd_8_variance32x16 = vpx_highbd_8_variance32x16_neon; + if (flags & HAS_SVE) { + vpx_highbd_8_variance32x16 = vpx_highbd_8_variance32x16_sve; + } + vpx_highbd_8_variance32x32 = vpx_highbd_8_variance32x32_neon; + if (flags & HAS_SVE) { + vpx_highbd_8_variance32x32 = vpx_highbd_8_variance32x32_sve; + } + vpx_highbd_8_variance32x64 = vpx_highbd_8_variance32x64_neon; + if (flags & HAS_SVE) { + vpx_highbd_8_variance32x64 = vpx_highbd_8_variance32x64_sve; + } + vpx_highbd_8_variance4x4 = vpx_highbd_8_variance4x4_neon; + if (flags & HAS_SVE) { + vpx_highbd_8_variance4x4 = vpx_highbd_8_variance4x4_sve; + } + vpx_highbd_8_variance4x8 = vpx_highbd_8_variance4x8_neon; + if (flags & HAS_SVE) { + vpx_highbd_8_variance4x8 = vpx_highbd_8_variance4x8_sve; + } + vpx_highbd_8_variance64x32 = vpx_highbd_8_variance64x32_neon; + if (flags & HAS_SVE) { + vpx_highbd_8_variance64x32 = vpx_highbd_8_variance64x32_sve; + } + vpx_highbd_8_variance64x64 = vpx_highbd_8_variance64x64_neon; + if (flags & HAS_SVE) { + vpx_highbd_8_variance64x64 = vpx_highbd_8_variance64x64_sve; + } + vpx_highbd_8_variance8x16 = vpx_highbd_8_variance8x16_neon; + if (flags & HAS_SVE) { + vpx_highbd_8_variance8x16 = vpx_highbd_8_variance8x16_sve; + } + vpx_highbd_8_variance8x4 = vpx_highbd_8_variance8x4_neon; + if (flags & HAS_SVE) { + vpx_highbd_8_variance8x4 = vpx_highbd_8_variance8x4_sve; + } + vpx_highbd_8_variance8x8 = vpx_highbd_8_variance8x8_neon; + if (flags & HAS_SVE) { + vpx_highbd_8_variance8x8 = vpx_highbd_8_variance8x8_sve; + } + vpx_highbd_convolve8 = vpx_highbd_convolve8_neon; + if (flags & HAS_SVE2) { + vpx_highbd_convolve8 = vpx_highbd_convolve8_sve2; + } + vpx_highbd_convolve8_avg = vpx_highbd_convolve8_avg_neon; + if (flags & HAS_SVE2) { + vpx_highbd_convolve8_avg = vpx_highbd_convolve8_avg_sve2; + } + vpx_highbd_convolve8_avg_horiz = vpx_highbd_convolve8_avg_horiz_neon; + if (flags & HAS_SVE) { + vpx_highbd_convolve8_avg_horiz = vpx_highbd_convolve8_avg_horiz_sve; + } + vpx_highbd_convolve8_avg_vert = vpx_highbd_convolve8_avg_vert_neon; + if (flags & HAS_SVE2) { + vpx_highbd_convolve8_avg_vert = vpx_highbd_convolve8_avg_vert_sve2; + } + vpx_highbd_convolve8_horiz = vpx_highbd_convolve8_horiz_neon; + if (flags & HAS_SVE) { + vpx_highbd_convolve8_horiz = vpx_highbd_convolve8_horiz_sve; + } + vpx_highbd_convolve8_vert = vpx_highbd_convolve8_vert_neon; + if (flags & HAS_SVE2) { + vpx_highbd_convolve8_vert = vpx_highbd_convolve8_vert_sve2; + } + vpx_mse16x16 = vpx_mse16x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_mse16x16 = vpx_mse16x16_neon_dotprod; + } + vpx_mse16x8 = vpx_mse16x8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_mse16x8 = vpx_mse16x8_neon_dotprod; + } + vpx_mse8x16 = vpx_mse8x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_mse8x16 = vpx_mse8x16_neon_dotprod; + } + vpx_mse8x8 = vpx_mse8x8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_mse8x8 = vpx_mse8x8_neon_dotprod; + } + vpx_sad16x16 = vpx_sad16x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x16 = vpx_sad16x16_neon_dotprod; + } + vpx_sad16x16_avg = vpx_sad16x16_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x16_avg = vpx_sad16x16_avg_neon_dotprod; + } + vpx_sad16x16x4d = vpx_sad16x16x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x16x4d = vpx_sad16x16x4d_neon_dotprod; + } + vpx_sad16x32 = vpx_sad16x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x32 = vpx_sad16x32_neon_dotprod; + } + vpx_sad16x32_avg = vpx_sad16x32_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x32_avg = vpx_sad16x32_avg_neon_dotprod; + } + vpx_sad16x32x4d = vpx_sad16x32x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x32x4d = vpx_sad16x32x4d_neon_dotprod; + } + vpx_sad16x8 = vpx_sad16x8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x8 = vpx_sad16x8_neon_dotprod; + } + vpx_sad16x8_avg = vpx_sad16x8_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x8_avg = vpx_sad16x8_avg_neon_dotprod; + } + vpx_sad16x8x4d = vpx_sad16x8x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x8x4d = vpx_sad16x8x4d_neon_dotprod; + } + vpx_sad32x16 = vpx_sad32x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x16 = vpx_sad32x16_neon_dotprod; + } + vpx_sad32x16_avg = vpx_sad32x16_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x16_avg = vpx_sad32x16_avg_neon_dotprod; + } + vpx_sad32x16x4d = vpx_sad32x16x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x16x4d = vpx_sad32x16x4d_neon_dotprod; + } + vpx_sad32x32 = vpx_sad32x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x32 = vpx_sad32x32_neon_dotprod; + } + vpx_sad32x32_avg = vpx_sad32x32_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x32_avg = vpx_sad32x32_avg_neon_dotprod; + } + vpx_sad32x32x4d = vpx_sad32x32x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x32x4d = vpx_sad32x32x4d_neon_dotprod; + } + vpx_sad32x64 = vpx_sad32x64_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x64 = vpx_sad32x64_neon_dotprod; + } + vpx_sad32x64_avg = vpx_sad32x64_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x64_avg = vpx_sad32x64_avg_neon_dotprod; + } + vpx_sad32x64x4d = vpx_sad32x64x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x64x4d = vpx_sad32x64x4d_neon_dotprod; + } + vpx_sad64x32 = vpx_sad64x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad64x32 = vpx_sad64x32_neon_dotprod; + } + vpx_sad64x32_avg = vpx_sad64x32_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad64x32_avg = vpx_sad64x32_avg_neon_dotprod; + } + vpx_sad64x32x4d = vpx_sad64x32x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad64x32x4d = vpx_sad64x32x4d_neon_dotprod; + } + vpx_sad64x64 = vpx_sad64x64_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad64x64 = vpx_sad64x64_neon_dotprod; + } + vpx_sad64x64_avg = vpx_sad64x64_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad64x64_avg = vpx_sad64x64_avg_neon_dotprod; + } + vpx_sad64x64x4d = vpx_sad64x64x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad64x64x4d = vpx_sad64x64x4d_neon_dotprod; + } + vpx_sad_skip_16x16 = vpx_sad_skip_16x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_16x16 = vpx_sad_skip_16x16_neon_dotprod; + } + vpx_sad_skip_16x16x4d = vpx_sad_skip_16x16x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_16x16x4d = vpx_sad_skip_16x16x4d_neon_dotprod; + } + vpx_sad_skip_16x32 = vpx_sad_skip_16x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_16x32 = vpx_sad_skip_16x32_neon_dotprod; + } + vpx_sad_skip_16x32x4d = vpx_sad_skip_16x32x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_16x32x4d = vpx_sad_skip_16x32x4d_neon_dotprod; + } + vpx_sad_skip_16x8 = vpx_sad_skip_16x8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_16x8 = vpx_sad_skip_16x8_neon_dotprod; + } + vpx_sad_skip_16x8x4d = vpx_sad_skip_16x8x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_16x8x4d = vpx_sad_skip_16x8x4d_neon_dotprod; + } + vpx_sad_skip_32x16 = vpx_sad_skip_32x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_32x16 = vpx_sad_skip_32x16_neon_dotprod; + } + vpx_sad_skip_32x16x4d = vpx_sad_skip_32x16x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_32x16x4d = vpx_sad_skip_32x16x4d_neon_dotprod; + } + vpx_sad_skip_32x32 = vpx_sad_skip_32x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_32x32 = vpx_sad_skip_32x32_neon_dotprod; + } + vpx_sad_skip_32x32x4d = vpx_sad_skip_32x32x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_32x32x4d = vpx_sad_skip_32x32x4d_neon_dotprod; + } + vpx_sad_skip_32x64 = vpx_sad_skip_32x64_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_32x64 = vpx_sad_skip_32x64_neon_dotprod; + } + vpx_sad_skip_32x64x4d = vpx_sad_skip_32x64x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_32x64x4d = vpx_sad_skip_32x64x4d_neon_dotprod; + } + vpx_sad_skip_64x32 = vpx_sad_skip_64x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_64x32 = vpx_sad_skip_64x32_neon_dotprod; + } + vpx_sad_skip_64x32x4d = vpx_sad_skip_64x32x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_64x32x4d = vpx_sad_skip_64x32x4d_neon_dotprod; + } + vpx_sad_skip_64x64 = vpx_sad_skip_64x64_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_64x64 = vpx_sad_skip_64x64_neon_dotprod; + } + vpx_sad_skip_64x64x4d = vpx_sad_skip_64x64x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_64x64x4d = vpx_sad_skip_64x64x4d_neon_dotprod; + } + vpx_sse = vpx_sse_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sse = vpx_sse_neon_dotprod; + } + vpx_sum_squares_2d_i16 = vpx_sum_squares_2d_i16_neon; + if (flags & HAS_SVE) { + vpx_sum_squares_2d_i16 = vpx_sum_squares_2d_i16_sve; + } + vpx_variance16x16 = vpx_variance16x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance16x16 = vpx_variance16x16_neon_dotprod; + } + vpx_variance16x32 = vpx_variance16x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance16x32 = vpx_variance16x32_neon_dotprod; + } + vpx_variance16x8 = vpx_variance16x8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance16x8 = vpx_variance16x8_neon_dotprod; + } + vpx_variance32x16 = vpx_variance32x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance32x16 = vpx_variance32x16_neon_dotprod; + } + vpx_variance32x32 = vpx_variance32x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance32x32 = vpx_variance32x32_neon_dotprod; + } + vpx_variance32x64 = vpx_variance32x64_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance32x64 = vpx_variance32x64_neon_dotprod; + } + vpx_variance4x4 = vpx_variance4x4_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance4x4 = vpx_variance4x4_neon_dotprod; + } + vpx_variance4x8 = vpx_variance4x8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance4x8 = vpx_variance4x8_neon_dotprod; + } + vpx_variance64x32 = vpx_variance64x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance64x32 = vpx_variance64x32_neon_dotprod; + } + vpx_variance64x64 = vpx_variance64x64_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance64x64 = vpx_variance64x64_neon_dotprod; + } + vpx_variance8x16 = vpx_variance8x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance8x16 = vpx_variance8x16_neon_dotprod; + } + vpx_variance8x4 = vpx_variance8x4_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance8x4 = vpx_variance8x4_neon_dotprod; + } + vpx_variance8x8 = vpx_variance8x8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance8x8 = vpx_variance8x8_neon_dotprod; + } } #endif diff --git a/libvpx/source/config/linux/arm64-highbd/vpx_scale_rtcd.h b/libvpx/source/config/linux/arm64-highbd/vpx_scale_rtcd.h old mode 100644 new mode 100755 diff --git a/libvpx/source/config/linux/arm64/vp8_rtcd.h b/libvpx/source/config/linux/arm64/vp8_rtcd.h old mode 100644 new mode 100755 index eb0b3a7cb44e16dc07e8b8f4985011dc9aa9fd16..102501094254bb09d784498a444bed4e77bf00a4 --- a/libvpx/source/config/linux/arm64/vp8_rtcd.h +++ b/libvpx/source/config/linux/arm64/vp8_rtcd.h @@ -83,36 +83,6 @@ void vp8_bilinear_predict8x8_neon(unsigned char* src_ptr, int dst_pitch); #define vp8_bilinear_predict8x8 vp8_bilinear_predict8x8_neon -void vp8_blend_b_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_b vp8_blend_b_c - -void vp8_blend_mb_inner_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_inner vp8_blend_mb_inner_c - -void vp8_blend_mb_outer_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_outer vp8_blend_mb_outer_c - int vp8_block_error_c(short* coeff, short* dqcoeff); #define vp8_block_error vp8_block_error_c diff --git a/libvpx/source/config/linux/arm64/vp9_rtcd.h b/libvpx/source/config/linux/arm64/vp9_rtcd.h old mode 100644 new mode 100755 index 8b1eaf7118999079707c57c10c757dd8add312e5..fec72c77b3b4433d64014c2ff818ce3b16d6684a --- a/libvpx/source/config/linux/arm64/vp9_rtcd.h +++ b/libvpx/source/config/linux/arm64/vp9_rtcd.h @@ -21,7 +21,9 @@ struct macroblockd; /* Encoder forward decls */ struct macroblock; -struct vp9_variance_vtable; +struct macroblock_plane; +struct vp9_sad_table; +struct ScanOrder; struct search_site_config; struct mv; union int_mv; @@ -39,7 +41,14 @@ int64_t vp9_block_error_neon(const tran_low_t* coeff, const tran_low_t* dqcoeff, intptr_t block_size, int64_t* ssz); -#define vp9_block_error vp9_block_error_neon +int64_t vp9_block_error_sve(const tran_low_t* coeff, + const tran_low_t* dqcoeff, + intptr_t block_size, + int64_t* ssz); +RTCD_EXTERN int64_t (*vp9_block_error)(const tran_low_t* coeff, + const tran_low_t* dqcoeff, + intptr_t block_size, + int64_t* ssz); int64_t vp9_block_error_fp_c(const tran_low_t* coeff, const tran_low_t* dqcoeff, @@ -47,7 +56,12 @@ int64_t vp9_block_error_fp_c(const tran_low_t* coeff, int64_t vp9_block_error_fp_neon(const tran_low_t* coeff, const tran_low_t* dqcoeff, int block_size); -#define vp9_block_error_fp vp9_block_error_fp_neon +int64_t vp9_block_error_fp_sve(const tran_low_t* coeff, + const tran_low_t* dqcoeff, + int block_size); +RTCD_EXTERN int64_t (*vp9_block_error_fp)(const tran_low_t* coeff, + const tran_low_t* dqcoeff, + int block_size); int vp9_denoiser_filter_c(const uint8_t* sig, int sig_stride, @@ -77,7 +91,7 @@ int vp9_diamond_search_sad_c(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); int vp9_diamond_search_sad_neon(const struct macroblock* x, const struct search_site_config* cfg, @@ -87,7 +101,7 @@ int vp9_diamond_search_sad_neon(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); #define vp9_diamond_search_sad vp9_diamond_search_sad_neon @@ -170,46 +184,38 @@ void vp9_iht8x8_64_add_neon(const tran_low_t* input, void vp9_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp vp9_quantize_fp_neon void vp9_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp_32x32 vp9_quantize_fp_32x32_neon void vp9_scale_and_extend_frame_c(const struct yv12_buffer_config* src, @@ -232,6 +238,19 @@ static void setup_rtcd_internal(void) { int flags = arm_cpu_caps(); (void)flags; + + vp9_block_error = vp9_block_error_neon; +#if defined (__clang__) && (__clang_major__ >= 17) + if (flags & HAS_SVE) { + vp9_block_error = vp9_block_error_sve; + } +#endif + vp9_block_error_fp = vp9_block_error_fp_neon; +#if defined (__clang__) && (__clang_major__ >= 17) + if (flags & HAS_SVE) { + vp9_block_error_fp = vp9_block_error_fp_sve; + } +#endif } #endif diff --git a/libvpx/source/config/linux/arm64/vpx_config.asm b/libvpx/source/config/linux/arm64/vpx_config.asm old mode 100644 new mode 100755 index 653a8cedb97ccbb4e80745fbf066d29136045f9f..0c55d08057762caa87c9eb5626a03aebd0c69ea1 --- a/libvpx/source/config/linux/arm64/vpx_config.asm +++ b/libvpx/source/config/linux/arm64/vpx_config.asm @@ -3,6 +3,8 @@ .syntax unified .equ VPX_ARCH_ARM , 1 .equ ARCH_ARM , 1 +.equ VPX_ARCH_AARCH64 , 1 +.equ ARCH_AARCH64 , 1 .equ VPX_ARCH_MIPS , 0 .equ ARCH_MIPS , 0 .equ VPX_ARCH_X86 , 0 @@ -13,8 +15,12 @@ .equ ARCH_PPC , 0 .equ VPX_ARCH_LOONGARCH , 0 .equ ARCH_LOONGARCH , 0 -.equ HAVE_NEON , 1 .equ HAVE_NEON_ASM , 0 +.equ HAVE_NEON , 1 +.equ HAVE_NEON_DOTPROD , 1 +.equ HAVE_NEON_I8MM , 1 +.equ HAVE_SVE , 1 +.equ HAVE_SVE2 , 1 .equ HAVE_MIPS32 , 0 .equ HAVE_DSPR2 , 0 .equ HAVE_MSA , 0 @@ -53,7 +59,7 @@ .equ CONFIG_DEBUG_LIBS , 0 .equ CONFIG_DEQUANT_TOKENS , 0 .equ CONFIG_DC_RECON , 0 -.equ CONFIG_RUNTIME_CPU_DETECT , 0 +.equ CONFIG_RUNTIME_CPU_DETECT , 1 .equ CONFIG_POSTPROC , 1 .equ CONFIG_VP9_POSTPROC , 1 .equ CONFIG_MULTITHREAD , 1 diff --git a/libvpx/source/config/linux/arm64/vpx_config.c b/libvpx/source/config/linux/arm64/vpx_config.c old mode 100644 new mode 100755 diff --git a/libvpx/source/config/linux/arm64/vpx_config.h b/libvpx/source/config/linux/arm64/vpx_config.h old mode 100644 new mode 100755 index ed6a89d6b39f1003cb41e0664d5bd65f248cf808..39bc1e6f09283fc2b38da8df41c964b38e2e165b --- a/libvpx/source/config/linux/arm64/vpx_config.h +++ b/libvpx/source/config/linux/arm64/vpx_config.h @@ -12,6 +12,8 @@ #define INLINE inline #define VPX_ARCH_ARM 1 #define ARCH_ARM 1 +#define VPX_ARCH_AARCH64 1 +#define ARCH_AARCH64 1 #define VPX_ARCH_MIPS 0 #define ARCH_MIPS 0 #define VPX_ARCH_X86 0 @@ -22,8 +24,12 @@ #define ARCH_PPC 0 #define VPX_ARCH_LOONGARCH 0 #define ARCH_LOONGARCH 0 -#define HAVE_NEON 1 #define HAVE_NEON_ASM 0 +#define HAVE_NEON 1 +#define HAVE_NEON_DOTPROD 1 +#define HAVE_NEON_I8MM 1 +#define HAVE_SVE 1 +#define HAVE_SVE2 1 #define HAVE_MIPS32 0 #define HAVE_DSPR2 0 #define HAVE_MSA 0 @@ -62,7 +68,7 @@ #define CONFIG_DEBUG_LIBS 0 #define CONFIG_DEQUANT_TOKENS 0 #define CONFIG_DC_RECON 0 -#define CONFIG_RUNTIME_CPU_DETECT 0 +#define CONFIG_RUNTIME_CPU_DETECT 1 #define CONFIG_POSTPROC 1 #define CONFIG_VP9_POSTPROC 1 #define CONFIG_MULTITHREAD 1 diff --git a/libvpx/source/config/linux/arm64/vpx_dsp_rtcd.h b/libvpx/source/config/linux/arm64/vpx_dsp_rtcd.h old mode 100644 new mode 100755 index 5f53e098fbce9c240022ccf1103dbdb00ed53d98..65fc5a36ff8ab262d618b0b00182ae05c10c1793 --- a/libvpx/source/config/linux/arm64/vpx_dsp_rtcd.h +++ b/libvpx/source/config/linux/arm64/vpx_dsp_rtcd.h @@ -68,7 +68,39 @@ void vpx_convolve8_neon(const uint8_t* src, int y_step_q4, int w, int h); -#define vpx_convolve8 vpx_convolve8_neon +void vpx_convolve8_neon_dotprod(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_convolve8_neon_i8mm(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +RTCD_EXTERN void (*vpx_convolve8)(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); void vpx_convolve8_avg_c(const uint8_t* src, ptrdiff_t src_stride, @@ -92,7 +124,39 @@ void vpx_convolve8_avg_neon(const uint8_t* src, int y_step_q4, int w, int h); -#define vpx_convolve8_avg vpx_convolve8_avg_neon +void vpx_convolve8_avg_neon_dotprod(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_convolve8_avg_neon_i8mm(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +RTCD_EXTERN void (*vpx_convolve8_avg)(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); void vpx_convolve8_avg_horiz_c(const uint8_t* src, ptrdiff_t src_stride, @@ -116,7 +180,39 @@ void vpx_convolve8_avg_horiz_neon(const uint8_t* src, int y_step_q4, int w, int h); -#define vpx_convolve8_avg_horiz vpx_convolve8_avg_horiz_neon +void vpx_convolve8_avg_horiz_neon_dotprod(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_convolve8_avg_horiz_neon_i8mm(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +RTCD_EXTERN void (*vpx_convolve8_avg_horiz)(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); void vpx_convolve8_avg_vert_c(const uint8_t* src, ptrdiff_t src_stride, @@ -140,7 +236,39 @@ void vpx_convolve8_avg_vert_neon(const uint8_t* src, int y_step_q4, int w, int h); -#define vpx_convolve8_avg_vert vpx_convolve8_avg_vert_neon +void vpx_convolve8_avg_vert_neon_dotprod(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_convolve8_avg_vert_neon_i8mm(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +RTCD_EXTERN void (*vpx_convolve8_avg_vert)(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); void vpx_convolve8_horiz_c(const uint8_t* src, ptrdiff_t src_stride, @@ -164,7 +292,39 @@ void vpx_convolve8_horiz_neon(const uint8_t* src, int y_step_q4, int w, int h); -#define vpx_convolve8_horiz vpx_convolve8_horiz_neon +void vpx_convolve8_horiz_neon_dotprod(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_convolve8_horiz_neon_i8mm(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +RTCD_EXTERN void (*vpx_convolve8_horiz)(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); void vpx_convolve8_vert_c(const uint8_t* src, ptrdiff_t src_stride, @@ -188,7 +348,39 @@ void vpx_convolve8_vert_neon(const uint8_t* src, int y_step_q4, int w, int h); -#define vpx_convolve8_vert vpx_convolve8_vert_neon +void vpx_convolve8_vert_neon_dotprod(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_convolve8_vert_neon_i8mm(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +RTCD_EXTERN void (*vpx_convolve8_vert)(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); void vpx_convolve_avg_c(const uint8_t* src, ptrdiff_t src_stride, @@ -700,7 +892,18 @@ void vpx_get16x16var_neon(const uint8_t* src_ptr, int ref_stride, unsigned int* sse, int* sum); -#define vpx_get16x16var vpx_get16x16var_neon +void vpx_get16x16var_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); +RTCD_EXTERN void (*vpx_get16x16var)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); unsigned int vpx_get4x4sse_cs_c(const unsigned char* src_ptr, int src_stride, @@ -710,7 +913,14 @@ unsigned int vpx_get4x4sse_cs_neon(const unsigned char* src_ptr, int src_stride, const unsigned char* ref_ptr, int ref_stride); -#define vpx_get4x4sse_cs vpx_get4x4sse_cs_neon +unsigned int vpx_get4x4sse_cs_neon_dotprod(const unsigned char* src_ptr, + int src_stride, + const unsigned char* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_get4x4sse_cs)(const unsigned char* src_ptr, + int src_stride, + const unsigned char* ref_ptr, + int ref_stride); void vpx_get8x8var_c(const uint8_t* src_ptr, int src_stride, @@ -724,7 +934,18 @@ void vpx_get8x8var_neon(const uint8_t* src_ptr, int ref_stride, unsigned int* sse, int* sum); -#define vpx_get8x8var vpx_get8x8var_neon +void vpx_get8x8var_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); +RTCD_EXTERN void (*vpx_get8x8var)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); unsigned int vpx_get_mb_ss_c(const int16_t*); #define vpx_get_mb_ss vpx_get_mb_ss_c @@ -1115,7 +1336,16 @@ unsigned int vpx_mse16x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_mse16x16 vpx_mse16x16_neon +unsigned int vpx_mse16x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_mse16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_mse16x8_c(const uint8_t* src_ptr, int src_stride, @@ -1127,7 +1357,16 @@ unsigned int vpx_mse16x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_mse16x8 vpx_mse16x8_neon +unsigned int vpx_mse16x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_mse16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_mse8x16_c(const uint8_t* src_ptr, int src_stride, @@ -1139,7 +1378,16 @@ unsigned int vpx_mse8x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_mse8x16 vpx_mse8x16_neon +unsigned int vpx_mse8x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_mse8x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_mse8x8_c(const uint8_t* src_ptr, int src_stride, @@ -1151,7 +1399,16 @@ unsigned int vpx_mse8x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_mse8x8 vpx_mse8x8_neon +unsigned int vpx_mse8x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_mse8x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); void vpx_plane_add_noise_c(uint8_t* start, const int8_t* noise, @@ -1181,28 +1438,20 @@ void vpx_post_proc_down_and_across_mb_row_neon(unsigned char* src, void vpx_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vpx_quantize_b vpx_quantize_b_neon void vpx_quantize_b_32x32_c(const tran_low_t* coeff_ptr, @@ -1229,7 +1478,14 @@ unsigned int vpx_sad16x16_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad16x16 vpx_sad16x16_neon +unsigned int vpx_sad16x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad16x16_avg_c(const uint8_t* src_ptr, int src_stride, @@ -1241,7 +1497,16 @@ unsigned int vpx_sad16x16_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad16x16_avg vpx_sad16x16_avg_neon +unsigned int vpx_sad16x16_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad16x16_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad16x16x4d_c(const uint8_t* src_ptr, int src_stride, @@ -1253,7 +1518,16 @@ void vpx_sad16x16x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad16x16x4d vpx_sad16x16x4d_neon +void vpx_sad16x16x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad16x16x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad16x32_c(const uint8_t* src_ptr, int src_stride, @@ -1263,7 +1537,14 @@ unsigned int vpx_sad16x32_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad16x32 vpx_sad16x32_neon +unsigned int vpx_sad16x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad16x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad16x32_avg_c(const uint8_t* src_ptr, int src_stride, @@ -1275,7 +1556,16 @@ unsigned int vpx_sad16x32_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad16x32_avg vpx_sad16x32_avg_neon +unsigned int vpx_sad16x32_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad16x32_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad16x32x4d_c(const uint8_t* src_ptr, int src_stride, @@ -1287,7 +1577,16 @@ void vpx_sad16x32x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad16x32x4d vpx_sad16x32x4d_neon +void vpx_sad16x32x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad16x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad16x8_c(const uint8_t* src_ptr, int src_stride, @@ -1297,7 +1596,14 @@ unsigned int vpx_sad16x8_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad16x8 vpx_sad16x8_neon +unsigned int vpx_sad16x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad16x8_avg_c(const uint8_t* src_ptr, int src_stride, @@ -1309,7 +1615,16 @@ unsigned int vpx_sad16x8_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad16x8_avg vpx_sad16x8_avg_neon +unsigned int vpx_sad16x8_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad16x8_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad16x8x4d_c(const uint8_t* src_ptr, int src_stride, @@ -1321,7 +1636,16 @@ void vpx_sad16x8x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad16x8x4d vpx_sad16x8x4d_neon +void vpx_sad16x8x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad16x8x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad32x16_c(const uint8_t* src_ptr, int src_stride, @@ -1331,7 +1655,14 @@ unsigned int vpx_sad32x16_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad32x16 vpx_sad32x16_neon +unsigned int vpx_sad32x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad32x16_avg_c(const uint8_t* src_ptr, int src_stride, @@ -1343,7 +1674,16 @@ unsigned int vpx_sad32x16_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad32x16_avg vpx_sad32x16_avg_neon +unsigned int vpx_sad32x16_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad32x16_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad32x16x4d_c(const uint8_t* src_ptr, int src_stride, @@ -1355,7 +1695,16 @@ void vpx_sad32x16x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad32x16x4d vpx_sad32x16x4d_neon +void vpx_sad32x16x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad32x16x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad32x32_c(const uint8_t* src_ptr, int src_stride, @@ -1365,7 +1714,14 @@ unsigned int vpx_sad32x32_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad32x32 vpx_sad32x32_neon +unsigned int vpx_sad32x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad32x32_avg_c(const uint8_t* src_ptr, int src_stride, @@ -1377,7 +1733,16 @@ unsigned int vpx_sad32x32_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad32x32_avg vpx_sad32x32_avg_neon +unsigned int vpx_sad32x32_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad32x32_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad32x32x4d_c(const uint8_t* src_ptr, int src_stride, @@ -1389,7 +1754,16 @@ void vpx_sad32x32x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad32x32x4d vpx_sad32x32x4d_neon +void vpx_sad32x32x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad32x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad32x64_c(const uint8_t* src_ptr, int src_stride, @@ -1399,7 +1773,14 @@ unsigned int vpx_sad32x64_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad32x64 vpx_sad32x64_neon +unsigned int vpx_sad32x64_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad32x64_avg_c(const uint8_t* src_ptr, int src_stride, @@ -1411,7 +1792,16 @@ unsigned int vpx_sad32x64_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad32x64_avg vpx_sad32x64_avg_neon +unsigned int vpx_sad32x64_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad32x64_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad32x64x4d_c(const uint8_t* src_ptr, int src_stride, @@ -1423,7 +1813,16 @@ void vpx_sad32x64x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad32x64x4d vpx_sad32x64x4d_neon +void vpx_sad32x64x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad32x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad4x4_c(const uint8_t* src_ptr, int src_stride, @@ -1501,7 +1900,14 @@ unsigned int vpx_sad64x32_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad64x32 vpx_sad64x32_neon +unsigned int vpx_sad64x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad64x32_avg_c(const uint8_t* src_ptr, int src_stride, @@ -1513,7 +1919,16 @@ unsigned int vpx_sad64x32_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad64x32_avg vpx_sad64x32_avg_neon +unsigned int vpx_sad64x32_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad64x32_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad64x32x4d_c(const uint8_t* src_ptr, int src_stride, @@ -1525,7 +1940,16 @@ void vpx_sad64x32x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad64x32x4d vpx_sad64x32x4d_neon +void vpx_sad64x32x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad64x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad64x64_c(const uint8_t* src_ptr, int src_stride, @@ -1535,7 +1959,14 @@ unsigned int vpx_sad64x64_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad64x64 vpx_sad64x64_neon +unsigned int vpx_sad64x64_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad64x64_avg_c(const uint8_t* src_ptr, int src_stride, @@ -1547,7 +1978,16 @@ unsigned int vpx_sad64x64_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad64x64_avg vpx_sad64x64_avg_neon +unsigned int vpx_sad64x64_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad64x64_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad64x64x4d_c(const uint8_t* src_ptr, int src_stride, @@ -1559,7 +1999,16 @@ void vpx_sad64x64x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad64x64x4d vpx_sad64x64x4d_neon +void vpx_sad64x64x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad64x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad8x16_c(const uint8_t* src_ptr, int src_stride, @@ -1663,6 +2112,420 @@ void vpx_sad8x8x4d_neon(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_sad8x8x4d vpx_sad8x8x4d_neon +unsigned int vpx_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x16x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_16x16x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_16x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x32x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_16x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x8x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_16x8x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x16x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x16x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x32x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x64_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x64_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x64x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x64x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_4x4_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x4 vpx_sad_skip_4x4_neon + +void vpx_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_4x4x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x4x4d vpx_sad_skip_4x4x4d_neon + +unsigned int vpx_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_4x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x8 vpx_sad_skip_4x8_neon + +void vpx_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_4x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x8x4d vpx_sad_skip_4x8x4d_neon + +unsigned int vpx_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x32x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_64x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x64_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x64_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x64x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x64x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_64x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x16 vpx_sad_skip_8x16_neon + +void vpx_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x16x4d vpx_sad_skip_8x16x4d_neon + +unsigned int vpx_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x4_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x4 vpx_sad_skip_8x4_neon + +void vpx_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x4x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x4x4d vpx_sad_skip_8x4x4d_neon + +unsigned int vpx_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x8 vpx_sad_skip_8x8_neon + +void vpx_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x8x4d vpx_sad_skip_8x8x4d_neon + int vpx_satd_c(const int16_t* coeff, int length); int vpx_satd_neon(const int16_t* coeff, int length); #define vpx_satd vpx_satd_neon @@ -1756,6 +2619,31 @@ void vpx_scaled_vert_c(const uint8_t* src, int h); #define vpx_scaled_vert vpx_scaled_vert_c +int64_t vpx_sse_c(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +int64_t vpx_sse_neon(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +int64_t vpx_sse_neon_dotprod(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +RTCD_EXTERN int64_t (*vpx_sse)(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); + uint32_t vpx_sub_pixel_avg_variance16x16_c(const uint8_t* src_ptr, int src_stride, int x_offset, @@ -2218,7 +3106,10 @@ void vpx_subtract_block_neon(int rows, uint64_t vpx_sum_squares_2d_i16_c(const int16_t* src, int stride, int size); uint64_t vpx_sum_squares_2d_i16_neon(const int16_t* src, int stride, int size); -#define vpx_sum_squares_2d_i16 vpx_sum_squares_2d_i16_neon +uint64_t vpx_sum_squares_2d_i16_sve(const int16_t* src, int stride, int size); +RTCD_EXTERN uint64_t (*vpx_sum_squares_2d_i16)(const int16_t* src, + int stride, + int size); void vpx_tm_predictor_16x16_c(uint8_t* dst, ptrdiff_t stride, @@ -2310,7 +3201,16 @@ unsigned int vpx_variance16x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance16x16 vpx_variance16x16_neon +unsigned int vpx_variance16x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance16x32_c(const uint8_t* src_ptr, int src_stride, @@ -2322,7 +3222,16 @@ unsigned int vpx_variance16x32_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance16x32 vpx_variance16x32_neon +unsigned int vpx_variance16x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance16x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance16x8_c(const uint8_t* src_ptr, int src_stride, @@ -2334,7 +3243,16 @@ unsigned int vpx_variance16x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance16x8 vpx_variance16x8_neon +unsigned int vpx_variance16x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance32x16_c(const uint8_t* src_ptr, int src_stride, @@ -2346,7 +3264,16 @@ unsigned int vpx_variance32x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance32x16 vpx_variance32x16_neon +unsigned int vpx_variance32x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance32x32_c(const uint8_t* src_ptr, int src_stride, @@ -2358,7 +3285,16 @@ unsigned int vpx_variance32x32_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance32x32 vpx_variance32x32_neon +unsigned int vpx_variance32x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance32x64_c(const uint8_t* src_ptr, int src_stride, @@ -2370,7 +3306,16 @@ unsigned int vpx_variance32x64_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance32x64 vpx_variance32x64_neon +unsigned int vpx_variance32x64_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance4x4_c(const uint8_t* src_ptr, int src_stride, @@ -2382,7 +3327,16 @@ unsigned int vpx_variance4x4_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance4x4 vpx_variance4x4_neon +unsigned int vpx_variance4x4_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance4x4)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance4x8_c(const uint8_t* src_ptr, int src_stride, @@ -2394,7 +3348,16 @@ unsigned int vpx_variance4x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance4x8 vpx_variance4x8_neon +unsigned int vpx_variance4x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance4x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance64x32_c(const uint8_t* src_ptr, int src_stride, @@ -2406,7 +3369,16 @@ unsigned int vpx_variance64x32_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance64x32 vpx_variance64x32_neon +unsigned int vpx_variance64x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance64x64_c(const uint8_t* src_ptr, int src_stride, @@ -2418,7 +3390,16 @@ unsigned int vpx_variance64x64_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance64x64 vpx_variance64x64_neon +unsigned int vpx_variance64x64_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance8x16_c(const uint8_t* src_ptr, int src_stride, @@ -2430,7 +3411,16 @@ unsigned int vpx_variance8x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance8x16 vpx_variance8x16_neon +unsigned int vpx_variance8x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance8x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance8x4_c(const uint8_t* src_ptr, int src_stride, @@ -2442,7 +3432,16 @@ unsigned int vpx_variance8x4_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance8x4 vpx_variance8x4_neon +unsigned int vpx_variance8x4_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance8x4)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance8x8_c(const uint8_t* src_ptr, int src_stride, @@ -2454,7 +3453,16 @@ unsigned int vpx_variance8x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance8x8 vpx_variance8x8_neon +unsigned int vpx_variance8x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance8x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); void vpx_ve_predictor_4x4_c(uint8_t* dst, ptrdiff_t stride, @@ -2476,6 +3484,299 @@ static void setup_rtcd_internal(void) { int flags = arm_cpu_caps(); (void)flags; + + vpx_convolve8 = vpx_convolve8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_convolve8 = vpx_convolve8_neon_dotprod; + } + if (flags & HAS_NEON_I8MM) { + vpx_convolve8 = vpx_convolve8_neon_i8mm; + } + vpx_convolve8_avg = vpx_convolve8_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_convolve8_avg = vpx_convolve8_avg_neon_dotprod; + } + if (flags & HAS_NEON_I8MM) { + vpx_convolve8_avg = vpx_convolve8_avg_neon_i8mm; + } + vpx_convolve8_avg_horiz = vpx_convolve8_avg_horiz_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_convolve8_avg_horiz = vpx_convolve8_avg_horiz_neon_dotprod; + } + if (flags & HAS_NEON_I8MM) { + vpx_convolve8_avg_horiz = vpx_convolve8_avg_horiz_neon_i8mm; + } + vpx_convolve8_avg_vert = vpx_convolve8_avg_vert_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_convolve8_avg_vert = vpx_convolve8_avg_vert_neon_dotprod; + } + if (flags & HAS_NEON_I8MM) { + vpx_convolve8_avg_vert = vpx_convolve8_avg_vert_neon_i8mm; + } + vpx_convolve8_horiz = vpx_convolve8_horiz_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_convolve8_horiz = vpx_convolve8_horiz_neon_dotprod; + } + if (flags & HAS_NEON_I8MM) { + vpx_convolve8_horiz = vpx_convolve8_horiz_neon_i8mm; + } + vpx_convolve8_vert = vpx_convolve8_vert_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_convolve8_vert = vpx_convolve8_vert_neon_dotprod; + } + if (flags & HAS_NEON_I8MM) { + vpx_convolve8_vert = vpx_convolve8_vert_neon_i8mm; + } + vpx_get16x16var = vpx_get16x16var_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_get16x16var = vpx_get16x16var_neon_dotprod; + } + vpx_get4x4sse_cs = vpx_get4x4sse_cs_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_get4x4sse_cs = vpx_get4x4sse_cs_neon_dotprod; + } + vpx_get8x8var = vpx_get8x8var_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_get8x8var = vpx_get8x8var_neon_dotprod; + } + vpx_mse16x16 = vpx_mse16x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_mse16x16 = vpx_mse16x16_neon_dotprod; + } + vpx_mse16x8 = vpx_mse16x8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_mse16x8 = vpx_mse16x8_neon_dotprod; + } + vpx_mse8x16 = vpx_mse8x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_mse8x16 = vpx_mse8x16_neon_dotprod; + } + vpx_mse8x8 = vpx_mse8x8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_mse8x8 = vpx_mse8x8_neon_dotprod; + } + vpx_sad16x16 = vpx_sad16x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x16 = vpx_sad16x16_neon_dotprod; + } + vpx_sad16x16_avg = vpx_sad16x16_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x16_avg = vpx_sad16x16_avg_neon_dotprod; + } + vpx_sad16x16x4d = vpx_sad16x16x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x16x4d = vpx_sad16x16x4d_neon_dotprod; + } + vpx_sad16x32 = vpx_sad16x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x32 = vpx_sad16x32_neon_dotprod; + } + vpx_sad16x32_avg = vpx_sad16x32_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x32_avg = vpx_sad16x32_avg_neon_dotprod; + } + vpx_sad16x32x4d = vpx_sad16x32x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x32x4d = vpx_sad16x32x4d_neon_dotprod; + } + vpx_sad16x8 = vpx_sad16x8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x8 = vpx_sad16x8_neon_dotprod; + } + vpx_sad16x8_avg = vpx_sad16x8_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x8_avg = vpx_sad16x8_avg_neon_dotprod; + } + vpx_sad16x8x4d = vpx_sad16x8x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad16x8x4d = vpx_sad16x8x4d_neon_dotprod; + } + vpx_sad32x16 = vpx_sad32x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x16 = vpx_sad32x16_neon_dotprod; + } + vpx_sad32x16_avg = vpx_sad32x16_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x16_avg = vpx_sad32x16_avg_neon_dotprod; + } + vpx_sad32x16x4d = vpx_sad32x16x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x16x4d = vpx_sad32x16x4d_neon_dotprod; + } + vpx_sad32x32 = vpx_sad32x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x32 = vpx_sad32x32_neon_dotprod; + } + vpx_sad32x32_avg = vpx_sad32x32_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x32_avg = vpx_sad32x32_avg_neon_dotprod; + } + vpx_sad32x32x4d = vpx_sad32x32x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x32x4d = vpx_sad32x32x4d_neon_dotprod; + } + vpx_sad32x64 = vpx_sad32x64_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x64 = vpx_sad32x64_neon_dotprod; + } + vpx_sad32x64_avg = vpx_sad32x64_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x64_avg = vpx_sad32x64_avg_neon_dotprod; + } + vpx_sad32x64x4d = vpx_sad32x64x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad32x64x4d = vpx_sad32x64x4d_neon_dotprod; + } + vpx_sad64x32 = vpx_sad64x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad64x32 = vpx_sad64x32_neon_dotprod; + } + vpx_sad64x32_avg = vpx_sad64x32_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad64x32_avg = vpx_sad64x32_avg_neon_dotprod; + } + vpx_sad64x32x4d = vpx_sad64x32x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad64x32x4d = vpx_sad64x32x4d_neon_dotprod; + } + vpx_sad64x64 = vpx_sad64x64_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad64x64 = vpx_sad64x64_neon_dotprod; + } + vpx_sad64x64_avg = vpx_sad64x64_avg_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad64x64_avg = vpx_sad64x64_avg_neon_dotprod; + } + vpx_sad64x64x4d = vpx_sad64x64x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad64x64x4d = vpx_sad64x64x4d_neon_dotprod; + } + vpx_sad_skip_16x16 = vpx_sad_skip_16x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_16x16 = vpx_sad_skip_16x16_neon_dotprod; + } + vpx_sad_skip_16x16x4d = vpx_sad_skip_16x16x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_16x16x4d = vpx_sad_skip_16x16x4d_neon_dotprod; + } + vpx_sad_skip_16x32 = vpx_sad_skip_16x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_16x32 = vpx_sad_skip_16x32_neon_dotprod; + } + vpx_sad_skip_16x32x4d = vpx_sad_skip_16x32x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_16x32x4d = vpx_sad_skip_16x32x4d_neon_dotprod; + } + vpx_sad_skip_16x8 = vpx_sad_skip_16x8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_16x8 = vpx_sad_skip_16x8_neon_dotprod; + } + vpx_sad_skip_16x8x4d = vpx_sad_skip_16x8x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_16x8x4d = vpx_sad_skip_16x8x4d_neon_dotprod; + } + vpx_sad_skip_32x16 = vpx_sad_skip_32x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_32x16 = vpx_sad_skip_32x16_neon_dotprod; + } + vpx_sad_skip_32x16x4d = vpx_sad_skip_32x16x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_32x16x4d = vpx_sad_skip_32x16x4d_neon_dotprod; + } + vpx_sad_skip_32x32 = vpx_sad_skip_32x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_32x32 = vpx_sad_skip_32x32_neon_dotprod; + } + vpx_sad_skip_32x32x4d = vpx_sad_skip_32x32x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_32x32x4d = vpx_sad_skip_32x32x4d_neon_dotprod; + } + vpx_sad_skip_32x64 = vpx_sad_skip_32x64_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_32x64 = vpx_sad_skip_32x64_neon_dotprod; + } + vpx_sad_skip_32x64x4d = vpx_sad_skip_32x64x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_32x64x4d = vpx_sad_skip_32x64x4d_neon_dotprod; + } + vpx_sad_skip_64x32 = vpx_sad_skip_64x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_64x32 = vpx_sad_skip_64x32_neon_dotprod; + } + vpx_sad_skip_64x32x4d = vpx_sad_skip_64x32x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_64x32x4d = vpx_sad_skip_64x32x4d_neon_dotprod; + } + vpx_sad_skip_64x64 = vpx_sad_skip_64x64_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_64x64 = vpx_sad_skip_64x64_neon_dotprod; + } + vpx_sad_skip_64x64x4d = vpx_sad_skip_64x64x4d_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sad_skip_64x64x4d = vpx_sad_skip_64x64x4d_neon_dotprod; + } + vpx_sse = vpx_sse_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sse = vpx_sse_neon_dotprod; + } + vpx_sum_squares_2d_i16 = vpx_sum_squares_2d_i16_neon; +#if defined (__clang__) && (__clang_major__ >= 17) + if (flags & HAS_SVE) { + vpx_sum_squares_2d_i16 = vpx_sum_squares_2d_i16_sve; + } +#endif + vpx_variance16x16 = vpx_variance16x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance16x16 = vpx_variance16x16_neon_dotprod; + } + vpx_variance16x32 = vpx_variance16x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance16x32 = vpx_variance16x32_neon_dotprod; + } + vpx_variance16x8 = vpx_variance16x8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance16x8 = vpx_variance16x8_neon_dotprod; + } + vpx_variance32x16 = vpx_variance32x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance32x16 = vpx_variance32x16_neon_dotprod; + } + vpx_variance32x32 = vpx_variance32x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance32x32 = vpx_variance32x32_neon_dotprod; + } + vpx_variance32x64 = vpx_variance32x64_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance32x64 = vpx_variance32x64_neon_dotprod; + } + vpx_variance4x4 = vpx_variance4x4_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance4x4 = vpx_variance4x4_neon_dotprod; + } + vpx_variance4x8 = vpx_variance4x8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance4x8 = vpx_variance4x8_neon_dotprod; + } + vpx_variance64x32 = vpx_variance64x32_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance64x32 = vpx_variance64x32_neon_dotprod; + } + vpx_variance64x64 = vpx_variance64x64_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance64x64 = vpx_variance64x64_neon_dotprod; + } + vpx_variance8x16 = vpx_variance8x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance8x16 = vpx_variance8x16_neon_dotprod; + } + vpx_variance8x4 = vpx_variance8x4_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance8x4 = vpx_variance8x4_neon_dotprod; + } + vpx_variance8x8 = vpx_variance8x8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_variance8x8 = vpx_variance8x8_neon_dotprod; + } } #endif diff --git a/libvpx/source/config/linux/arm64/vpx_scale_rtcd.h b/libvpx/source/config/linux/arm64/vpx_scale_rtcd.h old mode 100644 new mode 100755 diff --git a/libvpx/source/config/linux/generic/vp8_rtcd.h b/libvpx/source/config/linux/generic/vp8_rtcd.h old mode 100644 new mode 100755 index 3a166c097ebb4355e0e83af13cf3d1a56bdd3bca..7719e1c4a61055fd69f3d3eb82aa1eee92a1f8ae --- a/libvpx/source/config/linux/generic/vp8_rtcd.h +++ b/libvpx/source/config/linux/generic/vp8_rtcd.h @@ -59,36 +59,6 @@ void vp8_bilinear_predict8x8_c(unsigned char* src_ptr, int dst_pitch); #define vp8_bilinear_predict8x8 vp8_bilinear_predict8x8_c -void vp8_blend_b_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_b vp8_blend_b_c - -void vp8_blend_mb_inner_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_inner vp8_blend_mb_inner_c - -void vp8_blend_mb_outer_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_outer vp8_blend_mb_outer_c - int vp8_block_error_c(short* coeff, short* dqcoeff); #define vp8_block_error vp8_block_error_c diff --git a/libvpx/source/config/linux/generic/vp9_rtcd.h b/libvpx/source/config/linux/generic/vp9_rtcd.h old mode 100644 new mode 100755 index 02526ef923223d08539265f8645dcd484efd0a9a..ee9940ac10d95049893608010c51c0d948ec343f --- a/libvpx/source/config/linux/generic/vp9_rtcd.h +++ b/libvpx/source/config/linux/generic/vp9_rtcd.h @@ -21,7 +21,9 @@ struct macroblockd; /* Encoder forward decls */ struct macroblock; -struct vp9_variance_vtable; +struct macroblock_plane; +struct vp9_sad_table; +struct ScanOrder; struct search_site_config; struct mv; union int_mv; @@ -61,7 +63,7 @@ int vp9_diamond_search_sad_c(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); #define vp9_diamond_search_sad vp9_diamond_search_sad_c @@ -175,26 +177,23 @@ void vp9_highbd_post_proc_down_and_across_c(const uint16_t* src_ptr, void vp9_highbd_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_highbd_quantize_fp vp9_highbd_quantize_fp_c -void vp9_highbd_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); +void vp9_highbd_quantize_fp_32x32_c( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); #define vp9_highbd_quantize_fp_32x32 vp9_highbd_quantize_fp_32x32_c void vp9_highbd_temporal_filter_apply_c(const uint8_t* frame1, @@ -229,26 +228,22 @@ void vp9_iht8x8_64_add_c(const tran_low_t* input, void vp9_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp vp9_quantize_fp_c void vp9_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp_32x32 vp9_quantize_fp_32x32_c void vp9_scale_and_extend_frame_c(const struct yv12_buffer_config* src, diff --git a/libvpx/source/config/linux/generic/vpx_config.asm b/libvpx/source/config/linux/generic/vpx_config.asm old mode 100644 new mode 100755 index c7b60a243e0a2e19a8d85edab5649f453a123362..b2b9ab7b5dc5231855fe058616c314d82091195a --- a/libvpx/source/config/linux/generic/vpx_config.asm +++ b/libvpx/source/config/linux/generic/vpx_config.asm @@ -3,6 +3,8 @@ .syntax unified .equ VPX_ARCH_ARM , 0 .equ ARCH_ARM , 0 +.equ VPX_ARCH_AARCH64 , 0 +.equ ARCH_AARCH64 , 0 .equ VPX_ARCH_MIPS , 0 .equ ARCH_MIPS , 0 .equ VPX_ARCH_X86 , 0 @@ -13,8 +15,12 @@ .equ ARCH_PPC , 0 .equ VPX_ARCH_LOONGARCH , 0 .equ ARCH_LOONGARCH , 0 -.equ HAVE_NEON , 0 .equ HAVE_NEON_ASM , 0 +.equ HAVE_NEON , 0 +.equ HAVE_NEON_DOTPROD , 0 +.equ HAVE_NEON_I8MM , 0 +.equ HAVE_SVE , 0 +.equ HAVE_SVE2 , 0 .equ HAVE_MIPS32 , 0 .equ HAVE_DSPR2 , 0 .equ HAVE_MSA , 0 diff --git a/libvpx/source/config/linux/generic/vpx_config.c b/libvpx/source/config/linux/generic/vpx_config.c old mode 100644 new mode 100755 diff --git a/libvpx/source/config/linux/generic/vpx_config.h b/libvpx/source/config/linux/generic/vpx_config.h old mode 100644 new mode 100755 index f0664c038e9a84e4496763d44830d6bb3b7c635d..cf565e8d7f6d05acf8d460b48c99cee3e348d4ff --- a/libvpx/source/config/linux/generic/vpx_config.h +++ b/libvpx/source/config/linux/generic/vpx_config.h @@ -12,6 +12,8 @@ #define INLINE inline #define VPX_ARCH_ARM 0 #define ARCH_ARM 0 +#define VPX_ARCH_AARCH64 0 +#define ARCH_AARCH64 0 #define VPX_ARCH_MIPS 0 #define ARCH_MIPS 0 #define VPX_ARCH_X86 0 @@ -22,8 +24,12 @@ #define ARCH_PPC 0 #define VPX_ARCH_LOONGARCH 0 #define ARCH_LOONGARCH 0 -#define HAVE_NEON 0 #define HAVE_NEON_ASM 0 +#define HAVE_NEON 0 +#define HAVE_NEON_DOTPROD 0 +#define HAVE_NEON_I8MM 0 +#define HAVE_SVE 0 +#define HAVE_SVE2 0 #define HAVE_MIPS32 0 #define HAVE_DSPR2 0 #define HAVE_MSA 0 diff --git a/libvpx/source/config/linux/generic/vpx_dsp_rtcd.h b/libvpx/source/config/linux/generic/vpx_dsp_rtcd.h old mode 100644 new mode 100755 index 28d34ec0107176901e33d18796c3eefd4b13aed3..050b1f90569ee2525c7ddf9366f9a4a47e8be156 --- a/libvpx/source/config/linux/generic/vpx_dsp_rtcd.h +++ b/libvpx/source/config/linux/generic/vpx_dsp_rtcd.h @@ -2418,16 +2418,12 @@ void vpx_highbd_minmax_8x8_c(const uint8_t* s8, void vpx_highbd_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vpx_highbd_quantize_b vpx_highbd_quantize_b_c void vpx_highbd_quantize_b_32x32_c( @@ -2700,9 +2696,186 @@ void vpx_highbd_sad8x8x4d_c(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_highbd_sad8x8x4d vpx_highbd_sad8x8x4d_c +unsigned int vpx_highbd_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_16x16 vpx_highbd_sad_skip_16x16_c + +void vpx_highbd_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_16x16x4d vpx_highbd_sad_skip_16x16x4d_c + +unsigned int vpx_highbd_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_16x32 vpx_highbd_sad_skip_16x32_c + +void vpx_highbd_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_16x32x4d vpx_highbd_sad_skip_16x32x4d_c + +unsigned int vpx_highbd_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_16x8 vpx_highbd_sad_skip_16x8_c + +void vpx_highbd_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_16x8x4d vpx_highbd_sad_skip_16x8x4d_c + +unsigned int vpx_highbd_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_32x16 vpx_highbd_sad_skip_32x16_c + +void vpx_highbd_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_32x16x4d vpx_highbd_sad_skip_32x16x4d_c + +unsigned int vpx_highbd_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_32x32 vpx_highbd_sad_skip_32x32_c + +void vpx_highbd_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_32x32x4d vpx_highbd_sad_skip_32x32x4d_c + +unsigned int vpx_highbd_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_32x64 vpx_highbd_sad_skip_32x64_c + +void vpx_highbd_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_32x64x4d vpx_highbd_sad_skip_32x64x4d_c + +unsigned int vpx_highbd_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_4x4 vpx_highbd_sad_skip_4x4_c + +void vpx_highbd_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_4x4x4d vpx_highbd_sad_skip_4x4x4d_c + +unsigned int vpx_highbd_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_4x8 vpx_highbd_sad_skip_4x8_c + +void vpx_highbd_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_4x8x4d vpx_highbd_sad_skip_4x8x4d_c + +unsigned int vpx_highbd_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_64x32 vpx_highbd_sad_skip_64x32_c + +void vpx_highbd_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_64x32x4d vpx_highbd_sad_skip_64x32x4d_c + +unsigned int vpx_highbd_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_64x64 vpx_highbd_sad_skip_64x64_c + +void vpx_highbd_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_64x64x4d vpx_highbd_sad_skip_64x64x4d_c + +unsigned int vpx_highbd_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x16 vpx_highbd_sad_skip_8x16_c + +void vpx_highbd_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x16x4d vpx_highbd_sad_skip_8x16x4d_c + +unsigned int vpx_highbd_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x4 vpx_highbd_sad_skip_8x4_c + +void vpx_highbd_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x4x4d vpx_highbd_sad_skip_8x4x4d_c + +unsigned int vpx_highbd_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x8 vpx_highbd_sad_skip_8x8_c + +void vpx_highbd_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x8x4d vpx_highbd_sad_skip_8x8x4d_c + int vpx_highbd_satd_c(const tran_low_t* coeff, int length); #define vpx_highbd_satd vpx_highbd_satd_c +int64_t vpx_highbd_sse_c(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +#define vpx_highbd_sse vpx_highbd_sse_c + void vpx_highbd_subtract_block_c(int rows, int cols, int16_t* diff_ptr, @@ -2997,16 +3170,12 @@ void vpx_post_proc_down_and_across_mb_row_c(unsigned char* src, void vpx_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vpx_quantize_b vpx_quantize_b_c void vpx_quantize_b_32x32_c(const tran_low_t* coeff_ptr, @@ -3278,6 +3447,175 @@ void vpx_sad8x8x4d_c(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_sad8x8x4d vpx_sad8x8x4d_c +unsigned int vpx_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x16 vpx_sad_skip_16x16_c + +void vpx_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x16x4d vpx_sad_skip_16x16x4d_c + +unsigned int vpx_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x32 vpx_sad_skip_16x32_c + +void vpx_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x32x4d vpx_sad_skip_16x32x4d_c + +unsigned int vpx_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x8 vpx_sad_skip_16x8_c + +void vpx_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x8x4d vpx_sad_skip_16x8x4d_c + +unsigned int vpx_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x16 vpx_sad_skip_32x16_c + +void vpx_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x16x4d vpx_sad_skip_32x16x4d_c + +unsigned int vpx_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x32 vpx_sad_skip_32x32_c + +void vpx_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x32x4d vpx_sad_skip_32x32x4d_c + +unsigned int vpx_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x64 vpx_sad_skip_32x64_c + +void vpx_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x64x4d vpx_sad_skip_32x64x4d_c + +unsigned int vpx_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x4 vpx_sad_skip_4x4_c + +void vpx_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x4x4d vpx_sad_skip_4x4x4d_c + +unsigned int vpx_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x8 vpx_sad_skip_4x8_c + +void vpx_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x8x4d vpx_sad_skip_4x8x4d_c + +unsigned int vpx_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_64x32 vpx_sad_skip_64x32_c + +void vpx_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_64x32x4d vpx_sad_skip_64x32x4d_c + +unsigned int vpx_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_64x64 vpx_sad_skip_64x64_c + +void vpx_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_64x64x4d vpx_sad_skip_64x64x4d_c + +unsigned int vpx_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x16 vpx_sad_skip_8x16_c + +void vpx_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x16x4d vpx_sad_skip_8x16x4d_c + +unsigned int vpx_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x4 vpx_sad_skip_8x4_c + +void vpx_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x4x4d vpx_sad_skip_8x4x4d_c + +unsigned int vpx_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x8 vpx_sad_skip_8x8_c + +void vpx_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x8x4d vpx_sad_skip_8x8x4d_c + int vpx_satd_c(const tran_low_t* coeff, int length); #define vpx_satd vpx_satd_c @@ -3359,6 +3697,14 @@ void vpx_scaled_vert_c(const uint8_t* src, int h); #define vpx_scaled_vert vpx_scaled_vert_c +int64_t vpx_sse_c(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +#define vpx_sse vpx_sse_c + uint32_t vpx_sub_pixel_avg_variance16x16_c(const uint8_t* src_ptr, int src_stride, int x_offset, diff --git a/libvpx/source/config/linux/generic/vpx_scale_rtcd.h b/libvpx/source/config/linux/generic/vpx_scale_rtcd.h old mode 100644 new mode 100755 diff --git a/libvpx/source/config/linux/ia32/vp8_rtcd.h b/libvpx/source/config/linux/ia32/vp8_rtcd.h old mode 100644 new mode 100755 index e8b8a0e7250bf32663e159de6138aad36bb8017b..36216770a1e8342a0902cad35d35cfeb3bc6b8bf --- a/libvpx/source/config/linux/ia32/vp8_rtcd.h +++ b/libvpx/source/config/linux/ia32/vp8_rtcd.h @@ -105,36 +105,6 @@ RTCD_EXTERN void (*vp8_bilinear_predict8x8)(unsigned char* src_ptr, unsigned char* dst_ptr, int dst_pitch); -void vp8_blend_b_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_b vp8_blend_b_c - -void vp8_blend_mb_inner_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_inner vp8_blend_mb_inner_c - -void vp8_blend_mb_outer_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_outer vp8_blend_mb_outer_c - int vp8_block_error_c(short* coeff, short* dqcoeff); int vp8_block_error_sse2(short* coeff, short* dqcoeff); #define vp8_block_error vp8_block_error_sse2 diff --git a/libvpx/source/config/linux/ia32/vp9_rtcd.h b/libvpx/source/config/linux/ia32/vp9_rtcd.h old mode 100644 new mode 100755 index e9e663f801f7a9b6a2167e0c68203c61bde927e0..7771ee3e1a90d32eff2728e1237abe44bdd442f7 --- a/libvpx/source/config/linux/ia32/vp9_rtcd.h +++ b/libvpx/source/config/linux/ia32/vp9_rtcd.h @@ -21,7 +21,9 @@ struct macroblockd; /* Encoder forward decls */ struct macroblock; -struct vp9_variance_vtable; +struct macroblock_plane; +struct vp9_sad_table; +struct ScanOrder; struct search_site_config; struct mv; union int_mv; @@ -89,29 +91,9 @@ int vp9_diamond_search_sad_c(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); -int vp9_diamond_search_sad_avx(const struct macroblock* x, - const struct search_site_config* cfg, - struct mv* ref_mv, - uint32_t start_mv_sad, - struct mv* best_mv, - int search_param, - int sad_per_bit, - int* num00, - const struct vp9_variance_vtable* fn_ptr, - const struct mv* center_mv); -RTCD_EXTERN int (*vp9_diamond_search_sad)( - const struct macroblock* x, - const struct search_site_config* cfg, - struct mv* ref_mv, - uint32_t start_mv_sad, - struct mv* best_mv, - int search_param, - int sad_per_bit, - int* num00, - const struct vp9_variance_vtable* fn_ptr, - const struct mv* center_mv); +#define vp9_diamond_search_sad vp9_diamond_search_sad_c void vp9_fht16x16_c(const int16_t* input, tran_low_t* output, @@ -278,65 +260,57 @@ void vp9_highbd_post_proc_down_and_across_c(const uint16_t* src_ptr, void vp9_highbd_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_highbd_quantize_fp_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_highbd_quantize_fp)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); - -void vp9_highbd_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -void vp9_highbd_quantize_fp_32x32_avx2(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_highbd_quantize_fp_32x32)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_highbd_quantize_fp)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); + +void vp9_highbd_quantize_fp_32x32_c( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); +void vp9_highbd_quantize_fp_32x32_avx2( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_highbd_quantize_fp_32x32)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vp9_highbd_temporal_filter_apply_c(const uint8_t* frame1, unsigned int stride, @@ -382,95 +356,79 @@ void vp9_iht8x8_64_add_sse2(const tran_low_t* input, void vp9_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_sse2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_ssse3(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_quantize_fp)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_quantize_fp)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_ssse3(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_quantize_fp_32x32)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_quantize_fp_32x32)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vp9_scale_and_extend_frame_c(const struct yv12_buffer_config* src, struct yv12_buffer_config* dst, @@ -501,9 +459,6 @@ static void setup_rtcd_internal(void) { vp9_block_error_fp = vp9_block_error_fp_sse2; if (flags & HAS_AVX2) vp9_block_error_fp = vp9_block_error_fp_avx2; - vp9_diamond_search_sad = vp9_diamond_search_sad_c; - if (flags & HAS_AVX) - vp9_diamond_search_sad = vp9_diamond_search_sad_avx; vp9_highbd_iht16x16_256_add = vp9_highbd_iht16x16_256_add_c; if (flags & HAS_SSE4_1) vp9_highbd_iht16x16_256_add = vp9_highbd_iht16x16_256_add_sse4_1; diff --git a/libvpx/source/config/linux/ia32/vpx_config.asm b/libvpx/source/config/linux/ia32/vpx_config.asm old mode 100644 new mode 100755 index ef06dce9453045de0ce01fd8a39f6bc38772bc6b..63ae1278c6728ba9e4d8c279c9e3de041c31db94 --- a/libvpx/source/config/linux/ia32/vpx_config.asm +++ b/libvpx/source/config/linux/ia32/vpx_config.asm @@ -1,5 +1,7 @@ %define VPX_ARCH_ARM 0 %define ARCH_ARM 0 +%define VPX_ARCH_AARCH64 0 +%define ARCH_AARCH64 0 %define VPX_ARCH_MIPS 0 %define ARCH_MIPS 0 %define VPX_ARCH_X86 1 @@ -10,8 +12,12 @@ %define ARCH_PPC 0 %define VPX_ARCH_LOONGARCH 0 %define ARCH_LOONGARCH 0 -%define HAVE_NEON 0 %define HAVE_NEON_ASM 0 +%define HAVE_NEON 0 +%define HAVE_NEON_DOTPROD 0 +%define HAVE_NEON_I8MM 0 +%define HAVE_SVE 0 +%define HAVE_SVE2 0 %define HAVE_MIPS32 0 %define HAVE_DSPR2 0 %define HAVE_MSA 0 diff --git a/libvpx/source/config/linux/ia32/vpx_config.c b/libvpx/source/config/linux/ia32/vpx_config.c old mode 100644 new mode 100755 diff --git a/libvpx/source/config/linux/ia32/vpx_config.h b/libvpx/source/config/linux/ia32/vpx_config.h old mode 100644 new mode 100755 index 11f171b58696ab9aa48961aabed90ca7f256c52e..92a30a0f9df55f4af629e85af8e2c69167d3cf7c --- a/libvpx/source/config/linux/ia32/vpx_config.h +++ b/libvpx/source/config/linux/ia32/vpx_config.h @@ -12,6 +12,8 @@ #define INLINE inline #define VPX_ARCH_ARM 0 #define ARCH_ARM 0 +#define VPX_ARCH_AARCH64 0 +#define ARCH_AARCH64 0 #define VPX_ARCH_MIPS 0 #define ARCH_MIPS 0 #define VPX_ARCH_X86 1 @@ -22,8 +24,12 @@ #define ARCH_PPC 0 #define VPX_ARCH_LOONGARCH 0 #define ARCH_LOONGARCH 0 -#define HAVE_NEON 0 #define HAVE_NEON_ASM 0 +#define HAVE_NEON 0 +#define HAVE_NEON_DOTPROD 0 +#define HAVE_NEON_I8MM 0 +#define HAVE_SVE 0 +#define HAVE_SVE2 0 #define HAVE_MIPS32 0 #define HAVE_DSPR2 0 #define HAVE_MSA 0 diff --git a/libvpx/source/config/linux/ia32/vpx_dsp_rtcd.h b/libvpx/source/config/linux/ia32/vpx_dsp_rtcd.h old mode 100644 new mode 100755 index f42c6864f47f2a27103b93990f7d5ac87239fcf5..677a8fe4877928026d7be8e0a1a4af0f163def33 --- a/libvpx/source/config/linux/ia32/vpx_dsp_rtcd.h +++ b/libvpx/source/config/linux/ia32/vpx_dsp_rtcd.h @@ -44,7 +44,18 @@ void vpx_comp_avg_pred_sse2(uint8_t* comp_pred, int height, const uint8_t* ref, int ref_stride); -#define vpx_comp_avg_pred vpx_comp_avg_pred_sse2 +void vpx_comp_avg_pred_avx2(uint8_t* comp_pred, + const uint8_t* pred, + int width, + int height, + const uint8_t* ref, + int ref_stride); +RTCD_EXTERN void (*vpx_comp_avg_pred)(uint8_t* comp_pred, + const uint8_t* pred, + int width, + int height, + const uint8_t* ref, + int ref_stride); void vpx_convolve8_c(const uint8_t* src, ptrdiff_t src_stride, @@ -4432,52 +4443,37 @@ void vpx_highbd_minmax_8x8_c(const uint8_t* s8, void vpx_highbd_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_highbd_quantize_b_sse2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_highbd_quantize_b_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vpx_highbd_quantize_b)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vpx_highbd_quantize_b)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vpx_highbd_quantize_b_32x32_c( const tran_low_t* coeff_ptr, @@ -5136,10 +5132,435 @@ void vpx_highbd_sad8x8x4d_sse2(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_highbd_sad8x8x4d vpx_highbd_sad8x8x4d_sse2 +unsigned int vpx_highbd_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x16_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x16x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_16x16x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_16x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_16x32x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x8_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x8x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_16x8x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x16_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x16x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_32x16x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_32x32x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x64_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x64_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x64x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x64x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_32x64x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_4x4 vpx_highbd_sad_skip_4x4_c + +void vpx_highbd_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_4x4x4d vpx_highbd_sad_skip_4x4x4d_c + +unsigned int vpx_highbd_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_4x8 vpx_highbd_sad_skip_4x8_c + +void vpx_highbd_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_4x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_4x8x4d vpx_highbd_sad_skip_4x8x4d_sse2 + +unsigned int vpx_highbd_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_64x32x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x64_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x64_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x64x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x64x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_64x64x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_8x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x16 vpx_highbd_sad_skip_8x16_sse2 + +void vpx_highbd_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_8x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x16x4d vpx_highbd_sad_skip_8x16x4d_sse2 + +unsigned int vpx_highbd_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x4 vpx_highbd_sad_skip_8x4_c + +void vpx_highbd_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x4x4d vpx_highbd_sad_skip_8x4x4d_c + +unsigned int vpx_highbd_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_8x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x8 vpx_highbd_sad_skip_8x8_sse2 + +void vpx_highbd_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_8x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x8x4d vpx_highbd_sad_skip_8x8x4d_sse2 + int vpx_highbd_satd_c(const tran_low_t* coeff, int length); int vpx_highbd_satd_avx2(const tran_low_t* coeff, int length); RTCD_EXTERN int (*vpx_highbd_satd)(const tran_low_t* coeff, int length); +int64_t vpx_highbd_sse_c(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +int64_t vpx_highbd_sse_sse4_1(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +int64_t vpx_highbd_sse_avx2(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +RTCD_EXTERN int64_t (*vpx_highbd_sse)(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); + void vpx_highbd_subtract_block_c(int rows, int cols, int16_t* diff_ptr, @@ -5282,7 +5703,12 @@ void vpx_idct16x16_256_add_c(const tran_low_t* input, void vpx_idct16x16_256_add_sse2(const tran_low_t* input, uint8_t* dest, int stride); -#define vpx_idct16x16_256_add vpx_idct16x16_256_add_sse2 +void vpx_idct16x16_256_add_avx2(const tran_low_t* input, + uint8_t* dest, + int stride); +RTCD_EXTERN void (*vpx_idct16x16_256_add)(const tran_low_t* input, + uint8_t* dest, + int stride); void vpx_idct16x16_38_add_c(const tran_low_t* input, uint8_t* dest, int stride); void vpx_idct16x16_38_add_sse2(const tran_low_t* input, @@ -5296,7 +5722,12 @@ void vpx_idct32x32_1024_add_c(const tran_low_t* input, void vpx_idct32x32_1024_add_sse2(const tran_low_t* input, uint8_t* dest, int stride); -#define vpx_idct32x32_1024_add vpx_idct32x32_1024_add_sse2 +void vpx_idct32x32_1024_add_avx2(const tran_low_t* input, + uint8_t* dest, + int stride); +RTCD_EXTERN void (*vpx_idct32x32_1024_add)(const tran_low_t* input, + uint8_t* dest, + int stride); void vpx_idct32x32_135_add_c(const tran_low_t* input, uint8_t* dest, @@ -5307,6 +5738,9 @@ void vpx_idct32x32_135_add_sse2(const tran_low_t* input, void vpx_idct32x32_135_add_ssse3(const tran_low_t* input, uint8_t* dest, int stride); +void vpx_idct32x32_135_add_avx2(const tran_low_t* input, + uint8_t* dest, + int stride); RTCD_EXTERN void (*vpx_idct32x32_135_add)(const tran_low_t* input, uint8_t* dest, int stride); @@ -5707,76 +6141,53 @@ void vpx_post_proc_down_and_across_mb_row_sse2(unsigned char* src, void vpx_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_sse2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_ssse3(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_avx(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vpx_quantize_b)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vpx_quantize_b)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vpx_quantize_b_32x32_c(const tran_low_t* coeff_ptr, const struct macroblock_plane* const mb_plane, @@ -6355,24 +6766,372 @@ void vpx_sad8x8x4d_sse2(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_sad8x8x4d vpx_sad8x8x4d_sse2 -int vpx_satd_c(const tran_low_t* coeff, int length); -int vpx_satd_sse2(const tran_low_t* coeff, int length); -int vpx_satd_avx2(const tran_low_t* coeff, int length); -RTCD_EXTERN int (*vpx_satd)(const tran_low_t* coeff, int length); +unsigned int vpx_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x16 vpx_sad_skip_16x16_sse2 -void vpx_scaled_2d_c(const uint8_t* src, - ptrdiff_t src_stride, - uint8_t* dst, - ptrdiff_t dst_stride, - const InterpKernel* filter, - int x0_q4, - int x_step_q4, - int y0_q4, - int y_step_q4, - int w, - int h); -void vpx_scaled_2d_ssse3(const uint8_t* src, - ptrdiff_t src_stride, +void vpx_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x16x4d vpx_sad_skip_16x16x4d_sse2 + +unsigned int vpx_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x32 vpx_sad_skip_16x32_sse2 + +void vpx_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x32x4d vpx_sad_skip_16x32x4d_sse2 + +unsigned int vpx_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x8 vpx_sad_skip_16x8_sse2 + +void vpx_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x8x4d vpx_sad_skip_16x8x4d_sse2 + +unsigned int vpx_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x16_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x16x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x16x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x64_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x64_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x64x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x64x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x4 vpx_sad_skip_4x4_c + +void vpx_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x4x4d vpx_sad_skip_4x4x4d_c + +unsigned int vpx_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_4x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x8 vpx_sad_skip_4x8_sse2 + +void vpx_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_4x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x8x4d vpx_sad_skip_4x8x4d_sse2 + +unsigned int vpx_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_64x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x64_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x64_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x64x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x64x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_64x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x16 vpx_sad_skip_8x16_sse2 + +void vpx_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x16x4d vpx_sad_skip_8x16x4d_sse2 + +unsigned int vpx_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x4 vpx_sad_skip_8x4_c + +void vpx_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x4x4d vpx_sad_skip_8x4x4d_c + +unsigned int vpx_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x8 vpx_sad_skip_8x8_sse2 + +void vpx_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x8x4d vpx_sad_skip_8x8x4d_sse2 + +int vpx_satd_c(const tran_low_t* coeff, int length); +int vpx_satd_sse2(const tran_low_t* coeff, int length); +int vpx_satd_avx2(const tran_low_t* coeff, int length); +RTCD_EXTERN int (*vpx_satd)(const tran_low_t* coeff, int length); + +void vpx_scaled_2d_c(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_scaled_2d_ssse3(const uint8_t* src, + ptrdiff_t src_stride, uint8_t* dst, ptrdiff_t dst_stride, const InterpKernel* filter, @@ -6459,6 +7218,31 @@ void vpx_scaled_vert_c(const uint8_t* src, int h); #define vpx_scaled_vert vpx_scaled_vert_c +int64_t vpx_sse_c(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +int64_t vpx_sse_sse4_1(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +int64_t vpx_sse_avx2(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +RTCD_EXTERN int64_t (*vpx_sse)(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); + uint32_t vpx_sub_pixel_avg_variance16x16_c(const uint8_t* src_ptr, int src_stride, int x_offset, @@ -7699,6 +8483,9 @@ static void setup_rtcd_internal(void) { (void)flags; + vpx_comp_avg_pred = vpx_comp_avg_pred_sse2; + if (flags & HAS_AVX2) + vpx_comp_avg_pred = vpx_comp_avg_pred_avx2; vpx_convolve8 = vpx_convolve8_sse2; if (flags & HAS_SSSE3) vpx_convolve8 = vpx_convolve8_ssse3; @@ -7972,15 +8759,78 @@ static void setup_rtcd_internal(void) { vpx_highbd_sad64x64x4d = vpx_highbd_sad64x64x4d_sse2; if (flags & HAS_AVX2) vpx_highbd_sad64x64x4d = vpx_highbd_sad64x64x4d_avx2; + vpx_highbd_sad_skip_16x16 = vpx_highbd_sad_skip_16x16_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x16 = vpx_highbd_sad_skip_16x16_avx2; + vpx_highbd_sad_skip_16x16x4d = vpx_highbd_sad_skip_16x16x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x16x4d = vpx_highbd_sad_skip_16x16x4d_avx2; + vpx_highbd_sad_skip_16x32 = vpx_highbd_sad_skip_16x32_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x32 = vpx_highbd_sad_skip_16x32_avx2; + vpx_highbd_sad_skip_16x32x4d = vpx_highbd_sad_skip_16x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x32x4d = vpx_highbd_sad_skip_16x32x4d_avx2; + vpx_highbd_sad_skip_16x8 = vpx_highbd_sad_skip_16x8_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x8 = vpx_highbd_sad_skip_16x8_avx2; + vpx_highbd_sad_skip_16x8x4d = vpx_highbd_sad_skip_16x8x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x8x4d = vpx_highbd_sad_skip_16x8x4d_avx2; + vpx_highbd_sad_skip_32x16 = vpx_highbd_sad_skip_32x16_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x16 = vpx_highbd_sad_skip_32x16_avx2; + vpx_highbd_sad_skip_32x16x4d = vpx_highbd_sad_skip_32x16x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x16x4d = vpx_highbd_sad_skip_32x16x4d_avx2; + vpx_highbd_sad_skip_32x32 = vpx_highbd_sad_skip_32x32_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x32 = vpx_highbd_sad_skip_32x32_avx2; + vpx_highbd_sad_skip_32x32x4d = vpx_highbd_sad_skip_32x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x32x4d = vpx_highbd_sad_skip_32x32x4d_avx2; + vpx_highbd_sad_skip_32x64 = vpx_highbd_sad_skip_32x64_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x64 = vpx_highbd_sad_skip_32x64_avx2; + vpx_highbd_sad_skip_32x64x4d = vpx_highbd_sad_skip_32x64x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x64x4d = vpx_highbd_sad_skip_32x64x4d_avx2; + vpx_highbd_sad_skip_64x32 = vpx_highbd_sad_skip_64x32_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_64x32 = vpx_highbd_sad_skip_64x32_avx2; + vpx_highbd_sad_skip_64x32x4d = vpx_highbd_sad_skip_64x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_64x32x4d = vpx_highbd_sad_skip_64x32x4d_avx2; + vpx_highbd_sad_skip_64x64 = vpx_highbd_sad_skip_64x64_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_64x64 = vpx_highbd_sad_skip_64x64_avx2; + vpx_highbd_sad_skip_64x64x4d = vpx_highbd_sad_skip_64x64x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_64x64x4d = vpx_highbd_sad_skip_64x64x4d_avx2; vpx_highbd_satd = vpx_highbd_satd_c; if (flags & HAS_AVX2) vpx_highbd_satd = vpx_highbd_satd_avx2; + vpx_highbd_sse = vpx_highbd_sse_c; + if (flags & HAS_SSE4_1) { + vpx_highbd_sse = vpx_highbd_sse_sse4_1; + } + if (flags & HAS_AVX2) { + vpx_highbd_sse = vpx_highbd_sse_avx2; + } vpx_highbd_subtract_block = vpx_highbd_subtract_block_c; if (flags & HAS_AVX2) vpx_highbd_subtract_block = vpx_highbd_subtract_block_avx2; + vpx_idct16x16_256_add = vpx_idct16x16_256_add_sse2; + if (flags & HAS_AVX2) + vpx_idct16x16_256_add = vpx_idct16x16_256_add_avx2; + vpx_idct32x32_1024_add = vpx_idct32x32_1024_add_sse2; + if (flags & HAS_AVX2) + vpx_idct32x32_1024_add = vpx_idct32x32_1024_add_avx2; vpx_idct32x32_135_add = vpx_idct32x32_135_add_sse2; if (flags & HAS_SSSE3) vpx_idct32x32_135_add = vpx_idct32x32_135_add_ssse3; + if (flags & HAS_AVX2) + vpx_idct32x32_135_add = vpx_idct32x32_135_add_avx2; vpx_idct32x32_34_add = vpx_idct32x32_34_add_sse2; if (flags & HAS_SSSE3) vpx_idct32x32_34_add = vpx_idct32x32_34_add_ssse3; @@ -8049,12 +8899,49 @@ static void setup_rtcd_internal(void) { vpx_sad64x64x4d = vpx_sad64x64x4d_sse2; if (flags & HAS_AVX2) vpx_sad64x64x4d = vpx_sad64x64x4d_avx2; + vpx_sad_skip_32x16 = vpx_sad_skip_32x16_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x16 = vpx_sad_skip_32x16_avx2; + vpx_sad_skip_32x16x4d = vpx_sad_skip_32x16x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x16x4d = vpx_sad_skip_32x16x4d_avx2; + vpx_sad_skip_32x32 = vpx_sad_skip_32x32_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x32 = vpx_sad_skip_32x32_avx2; + vpx_sad_skip_32x32x4d = vpx_sad_skip_32x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x32x4d = vpx_sad_skip_32x32x4d_avx2; + vpx_sad_skip_32x64 = vpx_sad_skip_32x64_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x64 = vpx_sad_skip_32x64_avx2; + vpx_sad_skip_32x64x4d = vpx_sad_skip_32x64x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x64x4d = vpx_sad_skip_32x64x4d_avx2; + vpx_sad_skip_64x32 = vpx_sad_skip_64x32_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_64x32 = vpx_sad_skip_64x32_avx2; + vpx_sad_skip_64x32x4d = vpx_sad_skip_64x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_64x32x4d = vpx_sad_skip_64x32x4d_avx2; + vpx_sad_skip_64x64 = vpx_sad_skip_64x64_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_64x64 = vpx_sad_skip_64x64_avx2; + vpx_sad_skip_64x64x4d = vpx_sad_skip_64x64x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_64x64x4d = vpx_sad_skip_64x64x4d_avx2; vpx_satd = vpx_satd_sse2; if (flags & HAS_AVX2) vpx_satd = vpx_satd_avx2; vpx_scaled_2d = vpx_scaled_2d_c; if (flags & HAS_SSSE3) vpx_scaled_2d = vpx_scaled_2d_ssse3; + vpx_sse = vpx_sse_c; + if (flags & HAS_SSE4_1) { + vpx_sse = vpx_sse_sse4_1; + } + if (flags & HAS_AVX2) { + vpx_sse = vpx_sse_avx2; + } vpx_sub_pixel_avg_variance16x16 = vpx_sub_pixel_avg_variance16x16_sse2; if (flags & HAS_SSSE3) vpx_sub_pixel_avg_variance16x16 = vpx_sub_pixel_avg_variance16x16_ssse3; diff --git a/libvpx/source/config/linux/ia32/vpx_scale_rtcd.h b/libvpx/source/config/linux/ia32/vpx_scale_rtcd.h old mode 100644 new mode 100755 diff --git a/libvpx/source/config/linux/loongarch/vp8_rtcd.h b/libvpx/source/config/linux/loongarch/vp8_rtcd.h old mode 100644 new mode 100755 index 7a23f15f226f08002d3b74d913a63fe6a80bf97a..a9ee12391986a715e2ba20500ebfd6349c4bc0ff --- a/libvpx/source/config/linux/loongarch/vp8_rtcd.h +++ b/libvpx/source/config/linux/loongarch/vp8_rtcd.h @@ -59,36 +59,6 @@ void vp8_bilinear_predict8x8_c(unsigned char* src_ptr, int dst_pitch); #define vp8_bilinear_predict8x8 vp8_bilinear_predict8x8_c -void vp8_blend_b_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_b vp8_blend_b_c - -void vp8_blend_mb_inner_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_inner vp8_blend_mb_inner_c - -void vp8_blend_mb_outer_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_outer vp8_blend_mb_outer_c - int vp8_block_error_c(short* coeff, short* dqcoeff); int vp8_block_error_lsx(short* coeff, short* dqcoeff); RTCD_EXTERN int (*vp8_block_error)(short* coeff, short* dqcoeff); diff --git a/libvpx/source/config/linux/loongarch/vp9_rtcd.h b/libvpx/source/config/linux/loongarch/vp9_rtcd.h old mode 100644 new mode 100755 index f9d9a9a6699a64e7053c6b08ffa28264b12c00b9..16202f07b2db47bd96fbede7ebcbe38996f9cfdf --- a/libvpx/source/config/linux/loongarch/vp9_rtcd.h +++ b/libvpx/source/config/linux/loongarch/vp9_rtcd.h @@ -21,7 +21,9 @@ struct macroblockd; /* Encoder forward decls */ struct macroblock; -struct vp9_variance_vtable; +struct macroblock_plane; +struct vp9_sad_table; +struct ScanOrder; struct search_site_config; struct mv; union int_mv; @@ -61,7 +63,7 @@ int vp9_diamond_search_sad_c(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); #define vp9_diamond_search_sad vp9_diamond_search_sad_c @@ -120,26 +122,22 @@ void vp9_iht8x8_64_add_c(const tran_low_t* input, void vp9_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp vp9_quantize_fp_c void vp9_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp_32x32 vp9_quantize_fp_32x32_c void vp9_scale_and_extend_frame_c(const struct yv12_buffer_config* src, diff --git a/libvpx/source/config/linux/loongarch/vpx_config.c b/libvpx/source/config/linux/loongarch/vpx_config.c old mode 100644 new mode 100755 diff --git a/libvpx/source/config/linux/loongarch/vpx_config.h b/libvpx/source/config/linux/loongarch/vpx_config.h old mode 100644 new mode 100755 index 0b85fbd8fe0d2f1c5e46d06676e517d657ea9dbc..a8e357a6c774340d2ef89be3a593ccdad2e62038 --- a/libvpx/source/config/linux/loongarch/vpx_config.h +++ b/libvpx/source/config/linux/loongarch/vpx_config.h @@ -12,6 +12,8 @@ #define INLINE inline #define VPX_ARCH_ARM 0 #define ARCH_ARM 0 +#define VPX_ARCH_AARCH64 0 +#define ARCH_AARCH64 0 #define VPX_ARCH_MIPS 0 #define ARCH_MIPS 0 #define VPX_ARCH_X86 0 @@ -22,8 +24,12 @@ #define ARCH_PPC 0 #define VPX_ARCH_LOONGARCH 1 #define ARCH_LOONGARCH 1 -#define HAVE_NEON 0 #define HAVE_NEON_ASM 0 +#define HAVE_NEON 0 +#define HAVE_NEON_DOTPROD 0 +#define HAVE_NEON_I8MM 0 +#define HAVE_SVE 0 +#define HAVE_SVE2 0 #define HAVE_MIPS32 0 #define HAVE_DSPR2 0 #define HAVE_MSA 0 diff --git a/libvpx/source/config/linux/loongarch/vpx_dsp_rtcd.h b/libvpx/source/config/linux/loongarch/vpx_dsp_rtcd.h old mode 100644 new mode 100755 index f4740a1ddb2bd685b179dd16fc44ad7521e2d0c9..01f3f38d99cdd085ada33e3019b13e6d051be86c --- a/libvpx/source/config/linux/loongarch/vpx_dsp_rtcd.h +++ b/libvpx/source/config/linux/loongarch/vpx_dsp_rtcd.h @@ -1090,40 +1090,29 @@ void vpx_post_proc_down_and_across_mb_row_c(unsigned char* src, void vpx_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_lsx(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vpx_quantize_b)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vpx_quantize_b)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vpx_quantize_b_32x32_c(const tran_low_t* coeff_ptr, const struct macroblock_plane* const mb_plane, @@ -1508,6 +1497,175 @@ RTCD_EXTERN void (*vpx_sad8x8x4d)(const uint8_t* src_ptr, int ref_stride, uint32_t sad_array[4]); +unsigned int vpx_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x16 vpx_sad_skip_16x16_c + +void vpx_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x16x4d vpx_sad_skip_16x16x4d_c + +unsigned int vpx_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x32 vpx_sad_skip_16x32_c + +void vpx_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x32x4d vpx_sad_skip_16x32x4d_c + +unsigned int vpx_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x8 vpx_sad_skip_16x8_c + +void vpx_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x8x4d vpx_sad_skip_16x8x4d_c + +unsigned int vpx_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x16 vpx_sad_skip_32x16_c + +void vpx_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x16x4d vpx_sad_skip_32x16x4d_c + +unsigned int vpx_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x32 vpx_sad_skip_32x32_c + +void vpx_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x32x4d vpx_sad_skip_32x32x4d_c + +unsigned int vpx_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x64 vpx_sad_skip_32x64_c + +void vpx_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x64x4d vpx_sad_skip_32x64x4d_c + +unsigned int vpx_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x4 vpx_sad_skip_4x4_c + +void vpx_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x4x4d vpx_sad_skip_4x4x4d_c + +unsigned int vpx_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x8 vpx_sad_skip_4x8_c + +void vpx_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x8x4d vpx_sad_skip_4x8x4d_c + +unsigned int vpx_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_64x32 vpx_sad_skip_64x32_c + +void vpx_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_64x32x4d vpx_sad_skip_64x32x4d_c + +unsigned int vpx_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_64x64 vpx_sad_skip_64x64_c + +void vpx_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_64x64x4d vpx_sad_skip_64x64x4d_c + +unsigned int vpx_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x16 vpx_sad_skip_8x16_c + +void vpx_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x16x4d vpx_sad_skip_8x16x4d_c + +unsigned int vpx_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x4 vpx_sad_skip_8x4_c + +void vpx_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x4x4d vpx_sad_skip_8x4x4d_c + +unsigned int vpx_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x8 vpx_sad_skip_8x8_c + +void vpx_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x8x4d vpx_sad_skip_8x8x4d_c + int vpx_satd_c(const int16_t* coeff, int length); #define vpx_satd vpx_satd_c @@ -1589,6 +1747,14 @@ void vpx_scaled_vert_c(const uint8_t* src, int h); #define vpx_scaled_vert vpx_scaled_vert_c +int64_t vpx_sse_c(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +#define vpx_sse vpx_sse_c + uint32_t vpx_sub_pixel_avg_variance16x16_c(const uint8_t* src_ptr, int src_stride, int x_offset, diff --git a/libvpx/source/config/linux/loongarch/vpx_scale_rtcd.h b/libvpx/source/config/linux/loongarch/vpx_scale_rtcd.h old mode 100644 new mode 100755 diff --git a/libvpx/source/config/linux/mips64el/vp8_rtcd.h b/libvpx/source/config/linux/mips64el/vp8_rtcd.h old mode 100644 new mode 100755 index 3a166c097ebb4355e0e83af13cf3d1a56bdd3bca..7719e1c4a61055fd69f3d3eb82aa1eee92a1f8ae --- a/libvpx/source/config/linux/mips64el/vp8_rtcd.h +++ b/libvpx/source/config/linux/mips64el/vp8_rtcd.h @@ -59,36 +59,6 @@ void vp8_bilinear_predict8x8_c(unsigned char* src_ptr, int dst_pitch); #define vp8_bilinear_predict8x8 vp8_bilinear_predict8x8_c -void vp8_blend_b_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_b vp8_blend_b_c - -void vp8_blend_mb_inner_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_inner vp8_blend_mb_inner_c - -void vp8_blend_mb_outer_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_outer vp8_blend_mb_outer_c - int vp8_block_error_c(short* coeff, short* dqcoeff); #define vp8_block_error vp8_block_error_c diff --git a/libvpx/source/config/linux/mips64el/vp9_rtcd.h b/libvpx/source/config/linux/mips64el/vp9_rtcd.h old mode 100644 new mode 100755 index 97754ac8188e39f15f69d6db3773dd6b414788f0..e3508d0f36a4ccb1ed11a04db0cd415b2d615929 --- a/libvpx/source/config/linux/mips64el/vp9_rtcd.h +++ b/libvpx/source/config/linux/mips64el/vp9_rtcd.h @@ -21,7 +21,9 @@ struct macroblockd; /* Encoder forward decls */ struct macroblock; -struct vp9_variance_vtable; +struct macroblock_plane; +struct vp9_sad_table; +struct ScanOrder; struct search_site_config; struct mv; union int_mv; @@ -61,7 +63,7 @@ int vp9_diamond_search_sad_c(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); #define vp9_diamond_search_sad vp9_diamond_search_sad_c @@ -120,26 +122,22 @@ void vp9_iht8x8_64_add_c(const tran_low_t* input, void vp9_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp vp9_quantize_fp_c void vp9_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp_32x32 vp9_quantize_fp_32x32_c void vp9_scale_and_extend_frame_c(const struct yv12_buffer_config* src, diff --git a/libvpx/source/config/linux/mips64el/vpx_config.c b/libvpx/source/config/linux/mips64el/vpx_config.c old mode 100644 new mode 100755 diff --git a/libvpx/source/config/linux/mips64el/vpx_config.h b/libvpx/source/config/linux/mips64el/vpx_config.h old mode 100644 new mode 100755 index d76f54ef2a0dc259a4467ec5e3fe73b60bacb59a..1ec8f3130774e110a2a3fe2181c847f678b0d425 --- a/libvpx/source/config/linux/mips64el/vpx_config.h +++ b/libvpx/source/config/linux/mips64el/vpx_config.h @@ -12,6 +12,8 @@ #define INLINE inline #define VPX_ARCH_ARM 0 #define ARCH_ARM 0 +#define VPX_ARCH_AARCH64 0 +#define ARCH_AARCH64 0 #define VPX_ARCH_MIPS 1 #define ARCH_MIPS 1 #define VPX_ARCH_X86 0 @@ -22,8 +24,12 @@ #define ARCH_PPC 0 #define VPX_ARCH_LOONGARCH 0 #define ARCH_LOONGARCH 0 -#define HAVE_NEON 0 #define HAVE_NEON_ASM 0 +#define HAVE_NEON 0 +#define HAVE_NEON_DOTPROD 0 +#define HAVE_NEON_I8MM 0 +#define HAVE_SVE 0 +#define HAVE_SVE2 0 #define HAVE_MIPS32 0 #define HAVE_DSPR2 0 #define HAVE_MSA 0 diff --git a/libvpx/source/config/linux/mips64el/vpx_dsp_rtcd.h b/libvpx/source/config/linux/mips64el/vpx_dsp_rtcd.h old mode 100644 new mode 100755 index 4aa408c2d017e3e0305eff7e97f5a458990637a4..5f8ff53268c889d7dd586fd4615615c3c3003ad7 --- a/libvpx/source/config/linux/mips64el/vpx_dsp_rtcd.h +++ b/libvpx/source/config/linux/mips64el/vpx_dsp_rtcd.h @@ -718,16 +718,12 @@ void vpx_post_proc_down_and_across_mb_row_c(unsigned char* src, void vpx_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vpx_quantize_b vpx_quantize_b_c void vpx_quantize_b_32x32_c(const tran_low_t* coeff_ptr, @@ -999,6 +995,175 @@ void vpx_sad8x8x4d_c(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_sad8x8x4d vpx_sad8x8x4d_c +unsigned int vpx_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x16 vpx_sad_skip_16x16_c + +void vpx_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x16x4d vpx_sad_skip_16x16x4d_c + +unsigned int vpx_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x32 vpx_sad_skip_16x32_c + +void vpx_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x32x4d vpx_sad_skip_16x32x4d_c + +unsigned int vpx_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x8 vpx_sad_skip_16x8_c + +void vpx_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x8x4d vpx_sad_skip_16x8x4d_c + +unsigned int vpx_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x16 vpx_sad_skip_32x16_c + +void vpx_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x16x4d vpx_sad_skip_32x16x4d_c + +unsigned int vpx_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x32 vpx_sad_skip_32x32_c + +void vpx_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x32x4d vpx_sad_skip_32x32x4d_c + +unsigned int vpx_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x64 vpx_sad_skip_32x64_c + +void vpx_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x64x4d vpx_sad_skip_32x64x4d_c + +unsigned int vpx_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x4 vpx_sad_skip_4x4_c + +void vpx_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x4x4d vpx_sad_skip_4x4x4d_c + +unsigned int vpx_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x8 vpx_sad_skip_4x8_c + +void vpx_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x8x4d vpx_sad_skip_4x8x4d_c + +unsigned int vpx_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_64x32 vpx_sad_skip_64x32_c + +void vpx_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_64x32x4d vpx_sad_skip_64x32x4d_c + +unsigned int vpx_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_64x64 vpx_sad_skip_64x64_c + +void vpx_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_64x64x4d vpx_sad_skip_64x64x4d_c + +unsigned int vpx_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x16 vpx_sad_skip_8x16_c + +void vpx_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x16x4d vpx_sad_skip_8x16x4d_c + +unsigned int vpx_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x4 vpx_sad_skip_8x4_c + +void vpx_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x4x4d vpx_sad_skip_8x4x4d_c + +unsigned int vpx_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x8 vpx_sad_skip_8x8_c + +void vpx_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x8x4d vpx_sad_skip_8x8x4d_c + int vpx_satd_c(const int16_t* coeff, int length); #define vpx_satd vpx_satd_c @@ -1080,6 +1245,14 @@ void vpx_scaled_vert_c(const uint8_t* src, int h); #define vpx_scaled_vert vpx_scaled_vert_c +int64_t vpx_sse_c(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +#define vpx_sse vpx_sse_c + uint32_t vpx_sub_pixel_avg_variance16x16_c(const uint8_t* src_ptr, int src_stride, int x_offset, diff --git a/libvpx/source/config/linux/mips64el/vpx_scale_rtcd.h b/libvpx/source/config/linux/mips64el/vpx_scale_rtcd.h old mode 100644 new mode 100755 diff --git a/libvpx/source/config/linux/mipsel/vp8_rtcd.h b/libvpx/source/config/linux/mipsel/vp8_rtcd.h old mode 100644 new mode 100755 index 3a166c097ebb4355e0e83af13cf3d1a56bdd3bca..7719e1c4a61055fd69f3d3eb82aa1eee92a1f8ae --- a/libvpx/source/config/linux/mipsel/vp8_rtcd.h +++ b/libvpx/source/config/linux/mipsel/vp8_rtcd.h @@ -59,36 +59,6 @@ void vp8_bilinear_predict8x8_c(unsigned char* src_ptr, int dst_pitch); #define vp8_bilinear_predict8x8 vp8_bilinear_predict8x8_c -void vp8_blend_b_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_b vp8_blend_b_c - -void vp8_blend_mb_inner_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_inner vp8_blend_mb_inner_c - -void vp8_blend_mb_outer_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_outer vp8_blend_mb_outer_c - int vp8_block_error_c(short* coeff, short* dqcoeff); #define vp8_block_error vp8_block_error_c diff --git a/libvpx/source/config/linux/mipsel/vp9_rtcd.h b/libvpx/source/config/linux/mipsel/vp9_rtcd.h old mode 100644 new mode 100755 index 97754ac8188e39f15f69d6db3773dd6b414788f0..e3508d0f36a4ccb1ed11a04db0cd415b2d615929 --- a/libvpx/source/config/linux/mipsel/vp9_rtcd.h +++ b/libvpx/source/config/linux/mipsel/vp9_rtcd.h @@ -21,7 +21,9 @@ struct macroblockd; /* Encoder forward decls */ struct macroblock; -struct vp9_variance_vtable; +struct macroblock_plane; +struct vp9_sad_table; +struct ScanOrder; struct search_site_config; struct mv; union int_mv; @@ -61,7 +63,7 @@ int vp9_diamond_search_sad_c(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); #define vp9_diamond_search_sad vp9_diamond_search_sad_c @@ -120,26 +122,22 @@ void vp9_iht8x8_64_add_c(const tran_low_t* input, void vp9_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp vp9_quantize_fp_c void vp9_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp_32x32 vp9_quantize_fp_32x32_c void vp9_scale_and_extend_frame_c(const struct yv12_buffer_config* src, diff --git a/libvpx/source/config/linux/mipsel/vpx_config.c b/libvpx/source/config/linux/mipsel/vpx_config.c old mode 100644 new mode 100755 diff --git a/libvpx/source/config/linux/mipsel/vpx_config.h b/libvpx/source/config/linux/mipsel/vpx_config.h old mode 100644 new mode 100755 index 42e7cf62445b9c88009afb4b614b4312bae31740..052ebf9939f727a37403add7354c4222313c2c91 --- a/libvpx/source/config/linux/mipsel/vpx_config.h +++ b/libvpx/source/config/linux/mipsel/vpx_config.h @@ -12,6 +12,8 @@ #define INLINE inline #define VPX_ARCH_ARM 0 #define ARCH_ARM 0 +#define VPX_ARCH_AARCH64 0 +#define ARCH_AARCH64 0 #define VPX_ARCH_MIPS 1 #define ARCH_MIPS 1 #define VPX_ARCH_X86 0 @@ -22,8 +24,12 @@ #define ARCH_PPC 0 #define VPX_ARCH_LOONGARCH 0 #define ARCH_LOONGARCH 0 -#define HAVE_NEON 0 #define HAVE_NEON_ASM 0 +#define HAVE_NEON 0 +#define HAVE_NEON_DOTPROD 0 +#define HAVE_NEON_I8MM 0 +#define HAVE_SVE 0 +#define HAVE_SVE2 0 #define HAVE_MIPS32 1 #define HAVE_DSPR2 0 #define HAVE_MSA 0 diff --git a/libvpx/source/config/linux/mipsel/vpx_dsp_rtcd.h b/libvpx/source/config/linux/mipsel/vpx_dsp_rtcd.h old mode 100644 new mode 100755 index 4aa408c2d017e3e0305eff7e97f5a458990637a4..5f8ff53268c889d7dd586fd4615615c3c3003ad7 --- a/libvpx/source/config/linux/mipsel/vpx_dsp_rtcd.h +++ b/libvpx/source/config/linux/mipsel/vpx_dsp_rtcd.h @@ -718,16 +718,12 @@ void vpx_post_proc_down_and_across_mb_row_c(unsigned char* src, void vpx_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vpx_quantize_b vpx_quantize_b_c void vpx_quantize_b_32x32_c(const tran_low_t* coeff_ptr, @@ -999,6 +995,175 @@ void vpx_sad8x8x4d_c(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_sad8x8x4d vpx_sad8x8x4d_c +unsigned int vpx_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x16 vpx_sad_skip_16x16_c + +void vpx_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x16x4d vpx_sad_skip_16x16x4d_c + +unsigned int vpx_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x32 vpx_sad_skip_16x32_c + +void vpx_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x32x4d vpx_sad_skip_16x32x4d_c + +unsigned int vpx_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x8 vpx_sad_skip_16x8_c + +void vpx_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x8x4d vpx_sad_skip_16x8x4d_c + +unsigned int vpx_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x16 vpx_sad_skip_32x16_c + +void vpx_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x16x4d vpx_sad_skip_32x16x4d_c + +unsigned int vpx_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x32 vpx_sad_skip_32x32_c + +void vpx_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x32x4d vpx_sad_skip_32x32x4d_c + +unsigned int vpx_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x64 vpx_sad_skip_32x64_c + +void vpx_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x64x4d vpx_sad_skip_32x64x4d_c + +unsigned int vpx_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x4 vpx_sad_skip_4x4_c + +void vpx_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x4x4d vpx_sad_skip_4x4x4d_c + +unsigned int vpx_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x8 vpx_sad_skip_4x8_c + +void vpx_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x8x4d vpx_sad_skip_4x8x4d_c + +unsigned int vpx_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_64x32 vpx_sad_skip_64x32_c + +void vpx_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_64x32x4d vpx_sad_skip_64x32x4d_c + +unsigned int vpx_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_64x64 vpx_sad_skip_64x64_c + +void vpx_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_64x64x4d vpx_sad_skip_64x64x4d_c + +unsigned int vpx_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x16 vpx_sad_skip_8x16_c + +void vpx_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x16x4d vpx_sad_skip_8x16x4d_c + +unsigned int vpx_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x4 vpx_sad_skip_8x4_c + +void vpx_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x4x4d vpx_sad_skip_8x4x4d_c + +unsigned int vpx_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x8 vpx_sad_skip_8x8_c + +void vpx_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x8x4d vpx_sad_skip_8x8x4d_c + int vpx_satd_c(const int16_t* coeff, int length); #define vpx_satd vpx_satd_c @@ -1080,6 +1245,14 @@ void vpx_scaled_vert_c(const uint8_t* src, int h); #define vpx_scaled_vert vpx_scaled_vert_c +int64_t vpx_sse_c(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +#define vpx_sse vpx_sse_c + uint32_t vpx_sub_pixel_avg_variance16x16_c(const uint8_t* src_ptr, int src_stride, int x_offset, diff --git a/libvpx/source/config/linux/mipsel/vpx_scale_rtcd.h b/libvpx/source/config/linux/mipsel/vpx_scale_rtcd.h old mode 100644 new mode 100755 diff --git a/libvpx/source/config/linux/ppc64/vp8_rtcd.h b/libvpx/source/config/linux/ppc64/vp8_rtcd.h old mode 100644 new mode 100755 index d469712c46c33bab71f852c9cc45c4541a93138e..225647fef5ad750ede3fb405e08f6edbe0af6703 --- a/libvpx/source/config/linux/ppc64/vp8_rtcd.h +++ b/libvpx/source/config/linux/ppc64/vp8_rtcd.h @@ -59,36 +59,6 @@ void vp8_bilinear_predict8x8_c(unsigned char* src_ptr, int dst_pitch); #define vp8_bilinear_predict8x8 vp8_bilinear_predict8x8_c -void vp8_blend_b_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_b vp8_blend_b_c - -void vp8_blend_mb_inner_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_inner vp8_blend_mb_inner_c - -void vp8_blend_mb_outer_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_outer vp8_blend_mb_outer_c - int vp8_block_error_c(short* coeff, short* dqcoeff); #define vp8_block_error vp8_block_error_c diff --git a/libvpx/source/config/linux/ppc64/vp9_rtcd.h b/libvpx/source/config/linux/ppc64/vp9_rtcd.h old mode 100644 new mode 100755 index 1eb3bdd741474e4ac0d1c7a0c378d317b3e76ee0..d0ceec1fd28e84c88498a23a8bf2979533fedeba --- a/libvpx/source/config/linux/ppc64/vp9_rtcd.h +++ b/libvpx/source/config/linux/ppc64/vp9_rtcd.h @@ -21,7 +21,9 @@ struct macroblockd; /* Encoder forward decls */ struct macroblock; -struct vp9_variance_vtable; +struct macroblock_plane; +struct vp9_sad_table; +struct ScanOrder; struct search_site_config; struct mv; union int_mv; @@ -61,7 +63,7 @@ int vp9_diamond_search_sad_c(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); #define vp9_diamond_search_sad vp9_diamond_search_sad_c @@ -132,46 +134,38 @@ void vp9_iht8x8_64_add_vsx(const tran_low_t* input, void vp9_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_vsx(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp vp9_quantize_fp_vsx void vp9_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_vsx(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp_32x32 vp9_quantize_fp_32x32_vsx void vp9_scale_and_extend_frame_c(const struct yv12_buffer_config* src, diff --git a/libvpx/source/config/linux/ppc64/vpx_config.asm b/libvpx/source/config/linux/ppc64/vpx_config.asm old mode 100644 new mode 100755 index 9eeb3da04b0e89f4b9030036fe681f7091aaf218..2d04a90390ed64c470ce3a3c6bae18497cd2f0b4 --- a/libvpx/source/config/linux/ppc64/vpx_config.asm +++ b/libvpx/source/config/linux/ppc64/vpx_config.asm @@ -3,6 +3,8 @@ .syntax unified .equ VPX_ARCH_ARM , 0 .equ ARCH_ARM , 0 +.equ VPX_ARCH_AARCH64 , 0 +.equ ARCH_AARCH64 , 0 .equ VPX_ARCH_MIPS , 0 .equ ARCH_MIPS , 0 .equ VPX_ARCH_X86 , 0 @@ -13,8 +15,12 @@ .equ ARCH_PPC , 1 .equ VPX_ARCH_LOONGARCH , 0 .equ ARCH_LOONGARCH , 0 -.equ HAVE_NEON , 0 .equ HAVE_NEON_ASM , 0 +.equ HAVE_NEON , 0 +.equ HAVE_NEON_DOTPROD , 0 +.equ HAVE_NEON_I8MM , 0 +.equ HAVE_SVE , 0 +.equ HAVE_SVE2 , 0 .equ HAVE_MIPS32 , 0 .equ HAVE_DSPR2 , 0 .equ HAVE_MSA , 0 diff --git a/libvpx/source/config/linux/ppc64/vpx_config.c b/libvpx/source/config/linux/ppc64/vpx_config.c old mode 100644 new mode 100755 diff --git a/libvpx/source/config/linux/ppc64/vpx_config.h b/libvpx/source/config/linux/ppc64/vpx_config.h old mode 100644 new mode 100755 index 86327283ac556bf565eebabcc9c9e674853906df..8c758ab78df1dbf200c61aaec3a7890cf9b74785 --- a/libvpx/source/config/linux/ppc64/vpx_config.h +++ b/libvpx/source/config/linux/ppc64/vpx_config.h @@ -12,6 +12,8 @@ #define INLINE inline #define VPX_ARCH_ARM 0 #define ARCH_ARM 0 +#define VPX_ARCH_AARCH64 0 +#define ARCH_AARCH64 0 #define VPX_ARCH_MIPS 0 #define ARCH_MIPS 0 #define VPX_ARCH_X86 0 @@ -22,8 +24,12 @@ #define ARCH_PPC 1 #define VPX_ARCH_LOONGARCH 0 #define ARCH_LOONGARCH 0 -#define HAVE_NEON 0 #define HAVE_NEON_ASM 0 +#define HAVE_NEON 0 +#define HAVE_NEON_DOTPROD 0 +#define HAVE_NEON_I8MM 0 +#define HAVE_SVE 0 +#define HAVE_SVE2 0 #define HAVE_MIPS32 0 #define HAVE_DSPR2 0 #define HAVE_MSA 0 diff --git a/libvpx/source/config/linux/ppc64/vpx_dsp_rtcd.h b/libvpx/source/config/linux/ppc64/vpx_dsp_rtcd.h old mode 100644 new mode 100755 index 4fd6dd0e326b1f48cf26bbf2ed72c232945f6267..8749b4382e463830d7f93f1f205a2769800a105b --- a/libvpx/source/config/linux/ppc64/vpx_dsp_rtcd.h +++ b/libvpx/source/config/linux/ppc64/vpx_dsp_rtcd.h @@ -938,28 +938,20 @@ void vpx_post_proc_down_and_across_mb_row_vsx(unsigned char* src, void vpx_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_vsx(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vpx_quantize_b vpx_quantize_b_vsx void vpx_quantize_b_32x32_c(const tran_low_t* coeff_ptr, @@ -1362,6 +1354,175 @@ void vpx_sad8x8x4d_c(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_sad8x8x4d vpx_sad8x8x4d_c +unsigned int vpx_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x16 vpx_sad_skip_16x16_c + +void vpx_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x16x4d vpx_sad_skip_16x16x4d_c + +unsigned int vpx_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x32 vpx_sad_skip_16x32_c + +void vpx_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x32x4d vpx_sad_skip_16x32x4d_c + +unsigned int vpx_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x8 vpx_sad_skip_16x8_c + +void vpx_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x8x4d vpx_sad_skip_16x8x4d_c + +unsigned int vpx_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x16 vpx_sad_skip_32x16_c + +void vpx_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x16x4d vpx_sad_skip_32x16x4d_c + +unsigned int vpx_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x32 vpx_sad_skip_32x32_c + +void vpx_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x32x4d vpx_sad_skip_32x32x4d_c + +unsigned int vpx_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x64 vpx_sad_skip_32x64_c + +void vpx_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x64x4d vpx_sad_skip_32x64x4d_c + +unsigned int vpx_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x4 vpx_sad_skip_4x4_c + +void vpx_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x4x4d vpx_sad_skip_4x4x4d_c + +unsigned int vpx_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x8 vpx_sad_skip_4x8_c + +void vpx_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x8x4d vpx_sad_skip_4x8x4d_c + +unsigned int vpx_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_64x32 vpx_sad_skip_64x32_c + +void vpx_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_64x32x4d vpx_sad_skip_64x32x4d_c + +unsigned int vpx_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_64x64 vpx_sad_skip_64x64_c + +void vpx_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_64x64x4d vpx_sad_skip_64x64x4d_c + +unsigned int vpx_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x16 vpx_sad_skip_8x16_c + +void vpx_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x16x4d vpx_sad_skip_8x16x4d_c + +unsigned int vpx_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x4 vpx_sad_skip_8x4_c + +void vpx_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x4x4d vpx_sad_skip_8x4x4d_c + +unsigned int vpx_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x8 vpx_sad_skip_8x8_c + +void vpx_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x8x4d vpx_sad_skip_8x8x4d_c + int vpx_satd_c(const int16_t* coeff, int length); #define vpx_satd vpx_satd_c @@ -1443,6 +1604,14 @@ void vpx_scaled_vert_c(const uint8_t* src, int h); #define vpx_scaled_vert vpx_scaled_vert_c +int64_t vpx_sse_c(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +#define vpx_sse vpx_sse_c + uint32_t vpx_sub_pixel_avg_variance16x16_c(const uint8_t* src_ptr, int src_stride, int x_offset, diff --git a/libvpx/source/config/linux/ppc64/vpx_scale_rtcd.h b/libvpx/source/config/linux/ppc64/vpx_scale_rtcd.h old mode 100644 new mode 100755 diff --git a/libvpx/source/config/linux/x64/vp8_rtcd.h b/libvpx/source/config/linux/x64/vp8_rtcd.h old mode 100644 new mode 100755 index e8b8a0e7250bf32663e159de6138aad36bb8017b..36216770a1e8342a0902cad35d35cfeb3bc6b8bf --- a/libvpx/source/config/linux/x64/vp8_rtcd.h +++ b/libvpx/source/config/linux/x64/vp8_rtcd.h @@ -105,36 +105,6 @@ RTCD_EXTERN void (*vp8_bilinear_predict8x8)(unsigned char* src_ptr, unsigned char* dst_ptr, int dst_pitch); -void vp8_blend_b_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_b vp8_blend_b_c - -void vp8_blend_mb_inner_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_inner vp8_blend_mb_inner_c - -void vp8_blend_mb_outer_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_outer vp8_blend_mb_outer_c - int vp8_block_error_c(short* coeff, short* dqcoeff); int vp8_block_error_sse2(short* coeff, short* dqcoeff); #define vp8_block_error vp8_block_error_sse2 diff --git a/libvpx/source/config/linux/x64/vp9_rtcd.h b/libvpx/source/config/linux/x64/vp9_rtcd.h old mode 100644 new mode 100755 index e9e663f801f7a9b6a2167e0c68203c61bde927e0..7771ee3e1a90d32eff2728e1237abe44bdd442f7 --- a/libvpx/source/config/linux/x64/vp9_rtcd.h +++ b/libvpx/source/config/linux/x64/vp9_rtcd.h @@ -21,7 +21,9 @@ struct macroblockd; /* Encoder forward decls */ struct macroblock; -struct vp9_variance_vtable; +struct macroblock_plane; +struct vp9_sad_table; +struct ScanOrder; struct search_site_config; struct mv; union int_mv; @@ -89,29 +91,9 @@ int vp9_diamond_search_sad_c(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); -int vp9_diamond_search_sad_avx(const struct macroblock* x, - const struct search_site_config* cfg, - struct mv* ref_mv, - uint32_t start_mv_sad, - struct mv* best_mv, - int search_param, - int sad_per_bit, - int* num00, - const struct vp9_variance_vtable* fn_ptr, - const struct mv* center_mv); -RTCD_EXTERN int (*vp9_diamond_search_sad)( - const struct macroblock* x, - const struct search_site_config* cfg, - struct mv* ref_mv, - uint32_t start_mv_sad, - struct mv* best_mv, - int search_param, - int sad_per_bit, - int* num00, - const struct vp9_variance_vtable* fn_ptr, - const struct mv* center_mv); +#define vp9_diamond_search_sad vp9_diamond_search_sad_c void vp9_fht16x16_c(const int16_t* input, tran_low_t* output, @@ -278,65 +260,57 @@ void vp9_highbd_post_proc_down_and_across_c(const uint16_t* src_ptr, void vp9_highbd_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_highbd_quantize_fp_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_highbd_quantize_fp)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); - -void vp9_highbd_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -void vp9_highbd_quantize_fp_32x32_avx2(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_highbd_quantize_fp_32x32)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_highbd_quantize_fp)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); + +void vp9_highbd_quantize_fp_32x32_c( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); +void vp9_highbd_quantize_fp_32x32_avx2( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_highbd_quantize_fp_32x32)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vp9_highbd_temporal_filter_apply_c(const uint8_t* frame1, unsigned int stride, @@ -382,95 +356,79 @@ void vp9_iht8x8_64_add_sse2(const tran_low_t* input, void vp9_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_sse2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_ssse3(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_quantize_fp)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_quantize_fp)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_ssse3(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_quantize_fp_32x32)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_quantize_fp_32x32)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vp9_scale_and_extend_frame_c(const struct yv12_buffer_config* src, struct yv12_buffer_config* dst, @@ -501,9 +459,6 @@ static void setup_rtcd_internal(void) { vp9_block_error_fp = vp9_block_error_fp_sse2; if (flags & HAS_AVX2) vp9_block_error_fp = vp9_block_error_fp_avx2; - vp9_diamond_search_sad = vp9_diamond_search_sad_c; - if (flags & HAS_AVX) - vp9_diamond_search_sad = vp9_diamond_search_sad_avx; vp9_highbd_iht16x16_256_add = vp9_highbd_iht16x16_256_add_c; if (flags & HAS_SSE4_1) vp9_highbd_iht16x16_256_add = vp9_highbd_iht16x16_256_add_sse4_1; diff --git a/libvpx/source/config/linux/x64/vpx_config.asm b/libvpx/source/config/linux/x64/vpx_config.asm old mode 100644 new mode 100755 index 1a1a18d7114af817e28d90300521015cd456cb0e..9a2754f2b28808885cdbfb1f26d1eb813b8f8e52 --- a/libvpx/source/config/linux/x64/vpx_config.asm +++ b/libvpx/source/config/linux/x64/vpx_config.asm @@ -1,5 +1,7 @@ %define VPX_ARCH_ARM 0 %define ARCH_ARM 0 +%define VPX_ARCH_AARCH64 0 +%define ARCH_AARCH64 0 %define VPX_ARCH_MIPS 0 %define ARCH_MIPS 0 %define VPX_ARCH_X86 0 @@ -10,8 +12,12 @@ %define ARCH_PPC 0 %define VPX_ARCH_LOONGARCH 0 %define ARCH_LOONGARCH 0 -%define HAVE_NEON 0 %define HAVE_NEON_ASM 0 +%define HAVE_NEON 0 +%define HAVE_NEON_DOTPROD 0 +%define HAVE_NEON_I8MM 0 +%define HAVE_SVE 0 +%define HAVE_SVE2 0 %define HAVE_MIPS32 0 %define HAVE_DSPR2 0 %define HAVE_MSA 0 diff --git a/libvpx/source/config/linux/x64/vpx_config.c b/libvpx/source/config/linux/x64/vpx_config.c old mode 100644 new mode 100755 diff --git a/libvpx/source/config/linux/x64/vpx_config.h b/libvpx/source/config/linux/x64/vpx_config.h old mode 100644 new mode 100755 index 0b6b52ce6c838ca05d8ec986860b21abc70d5154..dcaf89acaf8cdfe2993a730b1562c66c3924cdf8 --- a/libvpx/source/config/linux/x64/vpx_config.h +++ b/libvpx/source/config/linux/x64/vpx_config.h @@ -12,6 +12,8 @@ #define INLINE inline #define VPX_ARCH_ARM 0 #define ARCH_ARM 0 +#define VPX_ARCH_AARCH64 0 +#define ARCH_AARCH64 0 #define VPX_ARCH_MIPS 0 #define ARCH_MIPS 0 #define VPX_ARCH_X86 0 @@ -22,8 +24,12 @@ #define ARCH_PPC 0 #define VPX_ARCH_LOONGARCH 0 #define ARCH_LOONGARCH 0 -#define HAVE_NEON 0 #define HAVE_NEON_ASM 0 +#define HAVE_NEON 0 +#define HAVE_NEON_DOTPROD 0 +#define HAVE_NEON_I8MM 0 +#define HAVE_SVE 0 +#define HAVE_SVE2 0 #define HAVE_MIPS32 0 #define HAVE_DSPR2 0 #define HAVE_MSA 0 diff --git a/libvpx/source/config/linux/x64/vpx_dsp_rtcd.h b/libvpx/source/config/linux/x64/vpx_dsp_rtcd.h old mode 100644 new mode 100755 index 907cab18d3ddab5c1e28a1f2cd90338c9ed52547..5dcdd93e0888dacd2a8521cd4a2f8fb3fbd45155 --- a/libvpx/source/config/linux/x64/vpx_dsp_rtcd.h +++ b/libvpx/source/config/linux/x64/vpx_dsp_rtcd.h @@ -44,7 +44,18 @@ void vpx_comp_avg_pred_sse2(uint8_t* comp_pred, int height, const uint8_t* ref, int ref_stride); -#define vpx_comp_avg_pred vpx_comp_avg_pred_sse2 +void vpx_comp_avg_pred_avx2(uint8_t* comp_pred, + const uint8_t* pred, + int width, + int height, + const uint8_t* ref, + int ref_stride); +RTCD_EXTERN void (*vpx_comp_avg_pred)(uint8_t* comp_pred, + const uint8_t* pred, + int width, + int height, + const uint8_t* ref, + int ref_stride); void vpx_convolve8_c(const uint8_t* src, ptrdiff_t src_stride, @@ -4509,52 +4520,37 @@ void vpx_highbd_minmax_8x8_c(const uint8_t* s8, void vpx_highbd_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_highbd_quantize_b_sse2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_highbd_quantize_b_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vpx_highbd_quantize_b)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vpx_highbd_quantize_b)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vpx_highbd_quantize_b_32x32_c( const tran_low_t* coeff_ptr, @@ -5213,10 +5209,435 @@ void vpx_highbd_sad8x8x4d_sse2(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_highbd_sad8x8x4d vpx_highbd_sad8x8x4d_sse2 +unsigned int vpx_highbd_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x16_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x16x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_16x16x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_16x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_16x32x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x8_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x8x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_16x8x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x16_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x16x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_32x16x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_32x32x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x64_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x64_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x64x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x64x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_32x64x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_4x4 vpx_highbd_sad_skip_4x4_c + +void vpx_highbd_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_4x4x4d vpx_highbd_sad_skip_4x4x4d_c + +unsigned int vpx_highbd_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_4x8 vpx_highbd_sad_skip_4x8_c + +void vpx_highbd_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_4x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_4x8x4d vpx_highbd_sad_skip_4x8x4d_sse2 + +unsigned int vpx_highbd_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_64x32x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x64_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x64_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x64x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x64x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_64x64x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_8x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x16 vpx_highbd_sad_skip_8x16_sse2 + +void vpx_highbd_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_8x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x16x4d vpx_highbd_sad_skip_8x16x4d_sse2 + +unsigned int vpx_highbd_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x4 vpx_highbd_sad_skip_8x4_c + +void vpx_highbd_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x4x4d vpx_highbd_sad_skip_8x4x4d_c + +unsigned int vpx_highbd_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_8x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x8 vpx_highbd_sad_skip_8x8_sse2 + +void vpx_highbd_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_8x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x8x4d vpx_highbd_sad_skip_8x8x4d_sse2 + int vpx_highbd_satd_c(const tran_low_t* coeff, int length); int vpx_highbd_satd_avx2(const tran_low_t* coeff, int length); RTCD_EXTERN int (*vpx_highbd_satd)(const tran_low_t* coeff, int length); +int64_t vpx_highbd_sse_c(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +int64_t vpx_highbd_sse_sse4_1(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +int64_t vpx_highbd_sse_avx2(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +RTCD_EXTERN int64_t (*vpx_highbd_sse)(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); + void vpx_highbd_subtract_block_c(int rows, int cols, int16_t* diff_ptr, @@ -5359,7 +5780,12 @@ void vpx_idct16x16_256_add_c(const tran_low_t* input, void vpx_idct16x16_256_add_sse2(const tran_low_t* input, uint8_t* dest, int stride); -#define vpx_idct16x16_256_add vpx_idct16x16_256_add_sse2 +void vpx_idct16x16_256_add_avx2(const tran_low_t* input, + uint8_t* dest, + int stride); +RTCD_EXTERN void (*vpx_idct16x16_256_add)(const tran_low_t* input, + uint8_t* dest, + int stride); void vpx_idct16x16_38_add_c(const tran_low_t* input, uint8_t* dest, int stride); void vpx_idct16x16_38_add_sse2(const tran_low_t* input, @@ -5373,7 +5799,12 @@ void vpx_idct32x32_1024_add_c(const tran_low_t* input, void vpx_idct32x32_1024_add_sse2(const tran_low_t* input, uint8_t* dest, int stride); -#define vpx_idct32x32_1024_add vpx_idct32x32_1024_add_sse2 +void vpx_idct32x32_1024_add_avx2(const tran_low_t* input, + uint8_t* dest, + int stride); +RTCD_EXTERN void (*vpx_idct32x32_1024_add)(const tran_low_t* input, + uint8_t* dest, + int stride); void vpx_idct32x32_135_add_c(const tran_low_t* input, uint8_t* dest, @@ -5384,6 +5815,9 @@ void vpx_idct32x32_135_add_sse2(const tran_low_t* input, void vpx_idct32x32_135_add_ssse3(const tran_low_t* input, uint8_t* dest, int stride); +void vpx_idct32x32_135_add_avx2(const tran_low_t* input, + uint8_t* dest, + int stride); RTCD_EXTERN void (*vpx_idct32x32_135_add)(const tran_low_t* input, uint8_t* dest, int stride); @@ -5784,76 +6218,53 @@ void vpx_post_proc_down_and_across_mb_row_sse2(unsigned char* src, void vpx_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_sse2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_ssse3(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_avx(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vpx_quantize_b)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vpx_quantize_b)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vpx_quantize_b_32x32_c(const tran_low_t* coeff_ptr, const struct macroblock_plane* const mb_plane, @@ -6432,24 +6843,372 @@ void vpx_sad8x8x4d_sse2(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_sad8x8x4d vpx_sad8x8x4d_sse2 -int vpx_satd_c(const tran_low_t* coeff, int length); -int vpx_satd_sse2(const tran_low_t* coeff, int length); -int vpx_satd_avx2(const tran_low_t* coeff, int length); -RTCD_EXTERN int (*vpx_satd)(const tran_low_t* coeff, int length); +unsigned int vpx_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x16 vpx_sad_skip_16x16_sse2 -void vpx_scaled_2d_c(const uint8_t* src, - ptrdiff_t src_stride, - uint8_t* dst, - ptrdiff_t dst_stride, - const InterpKernel* filter, - int x0_q4, - int x_step_q4, - int y0_q4, - int y_step_q4, - int w, - int h); -void vpx_scaled_2d_ssse3(const uint8_t* src, - ptrdiff_t src_stride, +void vpx_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x16x4d vpx_sad_skip_16x16x4d_sse2 + +unsigned int vpx_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x32 vpx_sad_skip_16x32_sse2 + +void vpx_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x32x4d vpx_sad_skip_16x32x4d_sse2 + +unsigned int vpx_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x8 vpx_sad_skip_16x8_sse2 + +void vpx_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x8x4d vpx_sad_skip_16x8x4d_sse2 + +unsigned int vpx_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x16_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x16x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x16x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x64_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x64_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x64x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x64x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x4 vpx_sad_skip_4x4_c + +void vpx_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x4x4d vpx_sad_skip_4x4x4d_c + +unsigned int vpx_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_4x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x8 vpx_sad_skip_4x8_sse2 + +void vpx_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_4x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x8x4d vpx_sad_skip_4x8x4d_sse2 + +unsigned int vpx_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_64x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x64_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x64_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x64x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x64x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_64x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x16 vpx_sad_skip_8x16_sse2 + +void vpx_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x16x4d vpx_sad_skip_8x16x4d_sse2 + +unsigned int vpx_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x4 vpx_sad_skip_8x4_c + +void vpx_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x4x4d vpx_sad_skip_8x4x4d_c + +unsigned int vpx_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x8 vpx_sad_skip_8x8_sse2 + +void vpx_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x8x4d vpx_sad_skip_8x8x4d_sse2 + +int vpx_satd_c(const tran_low_t* coeff, int length); +int vpx_satd_sse2(const tran_low_t* coeff, int length); +int vpx_satd_avx2(const tran_low_t* coeff, int length); +RTCD_EXTERN int (*vpx_satd)(const tran_low_t* coeff, int length); + +void vpx_scaled_2d_c(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_scaled_2d_ssse3(const uint8_t* src, + ptrdiff_t src_stride, uint8_t* dst, ptrdiff_t dst_stride, const InterpKernel* filter, @@ -6536,6 +7295,31 @@ void vpx_scaled_vert_c(const uint8_t* src, int h); #define vpx_scaled_vert vpx_scaled_vert_c +int64_t vpx_sse_c(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +int64_t vpx_sse_sse4_1(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +int64_t vpx_sse_avx2(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +RTCD_EXTERN int64_t (*vpx_sse)(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); + uint32_t vpx_sub_pixel_avg_variance16x16_c(const uint8_t* src_ptr, int src_stride, int x_offset, @@ -7776,6 +8560,9 @@ static void setup_rtcd_internal(void) { (void)flags; + vpx_comp_avg_pred = vpx_comp_avg_pred_sse2; + if (flags & HAS_AVX2) + vpx_comp_avg_pred = vpx_comp_avg_pred_avx2; vpx_convolve8 = vpx_convolve8_sse2; if (flags & HAS_SSSE3) vpx_convolve8 = vpx_convolve8_ssse3; @@ -8052,15 +8839,78 @@ static void setup_rtcd_internal(void) { vpx_highbd_sad64x64x4d = vpx_highbd_sad64x64x4d_sse2; if (flags & HAS_AVX2) vpx_highbd_sad64x64x4d = vpx_highbd_sad64x64x4d_avx2; + vpx_highbd_sad_skip_16x16 = vpx_highbd_sad_skip_16x16_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x16 = vpx_highbd_sad_skip_16x16_avx2; + vpx_highbd_sad_skip_16x16x4d = vpx_highbd_sad_skip_16x16x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x16x4d = vpx_highbd_sad_skip_16x16x4d_avx2; + vpx_highbd_sad_skip_16x32 = vpx_highbd_sad_skip_16x32_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x32 = vpx_highbd_sad_skip_16x32_avx2; + vpx_highbd_sad_skip_16x32x4d = vpx_highbd_sad_skip_16x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x32x4d = vpx_highbd_sad_skip_16x32x4d_avx2; + vpx_highbd_sad_skip_16x8 = vpx_highbd_sad_skip_16x8_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x8 = vpx_highbd_sad_skip_16x8_avx2; + vpx_highbd_sad_skip_16x8x4d = vpx_highbd_sad_skip_16x8x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x8x4d = vpx_highbd_sad_skip_16x8x4d_avx2; + vpx_highbd_sad_skip_32x16 = vpx_highbd_sad_skip_32x16_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x16 = vpx_highbd_sad_skip_32x16_avx2; + vpx_highbd_sad_skip_32x16x4d = vpx_highbd_sad_skip_32x16x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x16x4d = vpx_highbd_sad_skip_32x16x4d_avx2; + vpx_highbd_sad_skip_32x32 = vpx_highbd_sad_skip_32x32_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x32 = vpx_highbd_sad_skip_32x32_avx2; + vpx_highbd_sad_skip_32x32x4d = vpx_highbd_sad_skip_32x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x32x4d = vpx_highbd_sad_skip_32x32x4d_avx2; + vpx_highbd_sad_skip_32x64 = vpx_highbd_sad_skip_32x64_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x64 = vpx_highbd_sad_skip_32x64_avx2; + vpx_highbd_sad_skip_32x64x4d = vpx_highbd_sad_skip_32x64x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x64x4d = vpx_highbd_sad_skip_32x64x4d_avx2; + vpx_highbd_sad_skip_64x32 = vpx_highbd_sad_skip_64x32_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_64x32 = vpx_highbd_sad_skip_64x32_avx2; + vpx_highbd_sad_skip_64x32x4d = vpx_highbd_sad_skip_64x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_64x32x4d = vpx_highbd_sad_skip_64x32x4d_avx2; + vpx_highbd_sad_skip_64x64 = vpx_highbd_sad_skip_64x64_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_64x64 = vpx_highbd_sad_skip_64x64_avx2; + vpx_highbd_sad_skip_64x64x4d = vpx_highbd_sad_skip_64x64x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_64x64x4d = vpx_highbd_sad_skip_64x64x4d_avx2; vpx_highbd_satd = vpx_highbd_satd_c; if (flags & HAS_AVX2) vpx_highbd_satd = vpx_highbd_satd_avx2; + vpx_highbd_sse = vpx_highbd_sse_c; + if (flags & HAS_SSE4_1) { + vpx_highbd_sse = vpx_highbd_sse_sse4_1; + } + if (flags & HAS_AVX2) { + vpx_highbd_sse = vpx_highbd_sse_avx2; + } vpx_highbd_subtract_block = vpx_highbd_subtract_block_c; if (flags & HAS_AVX2) vpx_highbd_subtract_block = vpx_highbd_subtract_block_avx2; + vpx_idct16x16_256_add = vpx_idct16x16_256_add_sse2; + if (flags & HAS_AVX2) + vpx_idct16x16_256_add = vpx_idct16x16_256_add_avx2; + vpx_idct32x32_1024_add = vpx_idct32x32_1024_add_sse2; + if (flags & HAS_AVX2) + vpx_idct32x32_1024_add = vpx_idct32x32_1024_add_avx2; vpx_idct32x32_135_add = vpx_idct32x32_135_add_sse2; if (flags & HAS_SSSE3) vpx_idct32x32_135_add = vpx_idct32x32_135_add_ssse3; + if (flags & HAS_AVX2) + vpx_idct32x32_135_add = vpx_idct32x32_135_add_avx2; vpx_idct32x32_34_add = vpx_idct32x32_34_add_sse2; if (flags & HAS_SSSE3) vpx_idct32x32_34_add = vpx_idct32x32_34_add_ssse3; @@ -8129,12 +8979,49 @@ static void setup_rtcd_internal(void) { vpx_sad64x64x4d = vpx_sad64x64x4d_sse2; if (flags & HAS_AVX2) vpx_sad64x64x4d = vpx_sad64x64x4d_avx2; + vpx_sad_skip_32x16 = vpx_sad_skip_32x16_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x16 = vpx_sad_skip_32x16_avx2; + vpx_sad_skip_32x16x4d = vpx_sad_skip_32x16x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x16x4d = vpx_sad_skip_32x16x4d_avx2; + vpx_sad_skip_32x32 = vpx_sad_skip_32x32_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x32 = vpx_sad_skip_32x32_avx2; + vpx_sad_skip_32x32x4d = vpx_sad_skip_32x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x32x4d = vpx_sad_skip_32x32x4d_avx2; + vpx_sad_skip_32x64 = vpx_sad_skip_32x64_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x64 = vpx_sad_skip_32x64_avx2; + vpx_sad_skip_32x64x4d = vpx_sad_skip_32x64x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x64x4d = vpx_sad_skip_32x64x4d_avx2; + vpx_sad_skip_64x32 = vpx_sad_skip_64x32_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_64x32 = vpx_sad_skip_64x32_avx2; + vpx_sad_skip_64x32x4d = vpx_sad_skip_64x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_64x32x4d = vpx_sad_skip_64x32x4d_avx2; + vpx_sad_skip_64x64 = vpx_sad_skip_64x64_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_64x64 = vpx_sad_skip_64x64_avx2; + vpx_sad_skip_64x64x4d = vpx_sad_skip_64x64x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_64x64x4d = vpx_sad_skip_64x64x4d_avx2; vpx_satd = vpx_satd_sse2; if (flags & HAS_AVX2) vpx_satd = vpx_satd_avx2; vpx_scaled_2d = vpx_scaled_2d_c; if (flags & HAS_SSSE3) vpx_scaled_2d = vpx_scaled_2d_ssse3; + vpx_sse = vpx_sse_c; + if (flags & HAS_SSE4_1) { + vpx_sse = vpx_sse_sse4_1; + } + if (flags & HAS_AVX2) { + vpx_sse = vpx_sse_avx2; + } vpx_sub_pixel_avg_variance16x16 = vpx_sub_pixel_avg_variance16x16_sse2; if (flags & HAS_SSSE3) vpx_sub_pixel_avg_variance16x16 = vpx_sub_pixel_avg_variance16x16_ssse3; diff --git a/libvpx/source/config/linux/x64/vpx_scale_rtcd.h b/libvpx/source/config/linux/x64/vpx_scale_rtcd.h old mode 100644 new mode 100755 diff --git a/libvpx/source/config/mac/ia32/vp8_rtcd.h b/libvpx/source/config/mac/ia32/vp8_rtcd.h old mode 100644 new mode 100755 index e8b8a0e7250bf32663e159de6138aad36bb8017b..36216770a1e8342a0902cad35d35cfeb3bc6b8bf --- a/libvpx/source/config/mac/ia32/vp8_rtcd.h +++ b/libvpx/source/config/mac/ia32/vp8_rtcd.h @@ -105,36 +105,6 @@ RTCD_EXTERN void (*vp8_bilinear_predict8x8)(unsigned char* src_ptr, unsigned char* dst_ptr, int dst_pitch); -void vp8_blend_b_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_b vp8_blend_b_c - -void vp8_blend_mb_inner_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_inner vp8_blend_mb_inner_c - -void vp8_blend_mb_outer_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_outer vp8_blend_mb_outer_c - int vp8_block_error_c(short* coeff, short* dqcoeff); int vp8_block_error_sse2(short* coeff, short* dqcoeff); #define vp8_block_error vp8_block_error_sse2 diff --git a/libvpx/source/config/mac/ia32/vp9_rtcd.h b/libvpx/source/config/mac/ia32/vp9_rtcd.h old mode 100644 new mode 100755 index e9e663f801f7a9b6a2167e0c68203c61bde927e0..7771ee3e1a90d32eff2728e1237abe44bdd442f7 --- a/libvpx/source/config/mac/ia32/vp9_rtcd.h +++ b/libvpx/source/config/mac/ia32/vp9_rtcd.h @@ -21,7 +21,9 @@ struct macroblockd; /* Encoder forward decls */ struct macroblock; -struct vp9_variance_vtable; +struct macroblock_plane; +struct vp9_sad_table; +struct ScanOrder; struct search_site_config; struct mv; union int_mv; @@ -89,29 +91,9 @@ int vp9_diamond_search_sad_c(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); -int vp9_diamond_search_sad_avx(const struct macroblock* x, - const struct search_site_config* cfg, - struct mv* ref_mv, - uint32_t start_mv_sad, - struct mv* best_mv, - int search_param, - int sad_per_bit, - int* num00, - const struct vp9_variance_vtable* fn_ptr, - const struct mv* center_mv); -RTCD_EXTERN int (*vp9_diamond_search_sad)( - const struct macroblock* x, - const struct search_site_config* cfg, - struct mv* ref_mv, - uint32_t start_mv_sad, - struct mv* best_mv, - int search_param, - int sad_per_bit, - int* num00, - const struct vp9_variance_vtable* fn_ptr, - const struct mv* center_mv); +#define vp9_diamond_search_sad vp9_diamond_search_sad_c void vp9_fht16x16_c(const int16_t* input, tran_low_t* output, @@ -278,65 +260,57 @@ void vp9_highbd_post_proc_down_and_across_c(const uint16_t* src_ptr, void vp9_highbd_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_highbd_quantize_fp_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_highbd_quantize_fp)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); - -void vp9_highbd_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -void vp9_highbd_quantize_fp_32x32_avx2(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_highbd_quantize_fp_32x32)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_highbd_quantize_fp)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); + +void vp9_highbd_quantize_fp_32x32_c( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); +void vp9_highbd_quantize_fp_32x32_avx2( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_highbd_quantize_fp_32x32)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vp9_highbd_temporal_filter_apply_c(const uint8_t* frame1, unsigned int stride, @@ -382,95 +356,79 @@ void vp9_iht8x8_64_add_sse2(const tran_low_t* input, void vp9_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_sse2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_ssse3(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_quantize_fp)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_quantize_fp)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_ssse3(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_quantize_fp_32x32)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_quantize_fp_32x32)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vp9_scale_and_extend_frame_c(const struct yv12_buffer_config* src, struct yv12_buffer_config* dst, @@ -501,9 +459,6 @@ static void setup_rtcd_internal(void) { vp9_block_error_fp = vp9_block_error_fp_sse2; if (flags & HAS_AVX2) vp9_block_error_fp = vp9_block_error_fp_avx2; - vp9_diamond_search_sad = vp9_diamond_search_sad_c; - if (flags & HAS_AVX) - vp9_diamond_search_sad = vp9_diamond_search_sad_avx; vp9_highbd_iht16x16_256_add = vp9_highbd_iht16x16_256_add_c; if (flags & HAS_SSE4_1) vp9_highbd_iht16x16_256_add = vp9_highbd_iht16x16_256_add_sse4_1; diff --git a/libvpx/source/config/mac/ia32/vpx_config.asm b/libvpx/source/config/mac/ia32/vpx_config.asm old mode 100644 new mode 100755 index ef06dce9453045de0ce01fd8a39f6bc38772bc6b..63ae1278c6728ba9e4d8c279c9e3de041c31db94 --- a/libvpx/source/config/mac/ia32/vpx_config.asm +++ b/libvpx/source/config/mac/ia32/vpx_config.asm @@ -1,5 +1,7 @@ %define VPX_ARCH_ARM 0 %define ARCH_ARM 0 +%define VPX_ARCH_AARCH64 0 +%define ARCH_AARCH64 0 %define VPX_ARCH_MIPS 0 %define ARCH_MIPS 0 %define VPX_ARCH_X86 1 @@ -10,8 +12,12 @@ %define ARCH_PPC 0 %define VPX_ARCH_LOONGARCH 0 %define ARCH_LOONGARCH 0 -%define HAVE_NEON 0 %define HAVE_NEON_ASM 0 +%define HAVE_NEON 0 +%define HAVE_NEON_DOTPROD 0 +%define HAVE_NEON_I8MM 0 +%define HAVE_SVE 0 +%define HAVE_SVE2 0 %define HAVE_MIPS32 0 %define HAVE_DSPR2 0 %define HAVE_MSA 0 diff --git a/libvpx/source/config/mac/ia32/vpx_config.c b/libvpx/source/config/mac/ia32/vpx_config.c old mode 100644 new mode 100755 diff --git a/libvpx/source/config/mac/ia32/vpx_config.h b/libvpx/source/config/mac/ia32/vpx_config.h old mode 100644 new mode 100755 index 11f171b58696ab9aa48961aabed90ca7f256c52e..92a30a0f9df55f4af629e85af8e2c69167d3cf7c --- a/libvpx/source/config/mac/ia32/vpx_config.h +++ b/libvpx/source/config/mac/ia32/vpx_config.h @@ -12,6 +12,8 @@ #define INLINE inline #define VPX_ARCH_ARM 0 #define ARCH_ARM 0 +#define VPX_ARCH_AARCH64 0 +#define ARCH_AARCH64 0 #define VPX_ARCH_MIPS 0 #define ARCH_MIPS 0 #define VPX_ARCH_X86 1 @@ -22,8 +24,12 @@ #define ARCH_PPC 0 #define VPX_ARCH_LOONGARCH 0 #define ARCH_LOONGARCH 0 -#define HAVE_NEON 0 #define HAVE_NEON_ASM 0 +#define HAVE_NEON 0 +#define HAVE_NEON_DOTPROD 0 +#define HAVE_NEON_I8MM 0 +#define HAVE_SVE 0 +#define HAVE_SVE2 0 #define HAVE_MIPS32 0 #define HAVE_DSPR2 0 #define HAVE_MSA 0 diff --git a/libvpx/source/config/mac/ia32/vpx_dsp_rtcd.h b/libvpx/source/config/mac/ia32/vpx_dsp_rtcd.h old mode 100644 new mode 100755 index f42c6864f47f2a27103b93990f7d5ac87239fcf5..677a8fe4877928026d7be8e0a1a4af0f163def33 --- a/libvpx/source/config/mac/ia32/vpx_dsp_rtcd.h +++ b/libvpx/source/config/mac/ia32/vpx_dsp_rtcd.h @@ -44,7 +44,18 @@ void vpx_comp_avg_pred_sse2(uint8_t* comp_pred, int height, const uint8_t* ref, int ref_stride); -#define vpx_comp_avg_pred vpx_comp_avg_pred_sse2 +void vpx_comp_avg_pred_avx2(uint8_t* comp_pred, + const uint8_t* pred, + int width, + int height, + const uint8_t* ref, + int ref_stride); +RTCD_EXTERN void (*vpx_comp_avg_pred)(uint8_t* comp_pred, + const uint8_t* pred, + int width, + int height, + const uint8_t* ref, + int ref_stride); void vpx_convolve8_c(const uint8_t* src, ptrdiff_t src_stride, @@ -4432,52 +4443,37 @@ void vpx_highbd_minmax_8x8_c(const uint8_t* s8, void vpx_highbd_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_highbd_quantize_b_sse2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_highbd_quantize_b_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vpx_highbd_quantize_b)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vpx_highbd_quantize_b)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vpx_highbd_quantize_b_32x32_c( const tran_low_t* coeff_ptr, @@ -5136,10 +5132,435 @@ void vpx_highbd_sad8x8x4d_sse2(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_highbd_sad8x8x4d vpx_highbd_sad8x8x4d_sse2 +unsigned int vpx_highbd_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x16_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x16x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_16x16x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_16x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_16x32x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x8_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x8x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_16x8x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x16_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x16x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_32x16x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_32x32x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x64_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x64_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x64x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x64x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_32x64x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_4x4 vpx_highbd_sad_skip_4x4_c + +void vpx_highbd_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_4x4x4d vpx_highbd_sad_skip_4x4x4d_c + +unsigned int vpx_highbd_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_4x8 vpx_highbd_sad_skip_4x8_c + +void vpx_highbd_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_4x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_4x8x4d vpx_highbd_sad_skip_4x8x4d_sse2 + +unsigned int vpx_highbd_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_64x32x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x64_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x64_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x64x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x64x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_64x64x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_8x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x16 vpx_highbd_sad_skip_8x16_sse2 + +void vpx_highbd_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_8x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x16x4d vpx_highbd_sad_skip_8x16x4d_sse2 + +unsigned int vpx_highbd_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x4 vpx_highbd_sad_skip_8x4_c + +void vpx_highbd_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x4x4d vpx_highbd_sad_skip_8x4x4d_c + +unsigned int vpx_highbd_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_8x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x8 vpx_highbd_sad_skip_8x8_sse2 + +void vpx_highbd_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_8x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x8x4d vpx_highbd_sad_skip_8x8x4d_sse2 + int vpx_highbd_satd_c(const tran_low_t* coeff, int length); int vpx_highbd_satd_avx2(const tran_low_t* coeff, int length); RTCD_EXTERN int (*vpx_highbd_satd)(const tran_low_t* coeff, int length); +int64_t vpx_highbd_sse_c(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +int64_t vpx_highbd_sse_sse4_1(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +int64_t vpx_highbd_sse_avx2(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +RTCD_EXTERN int64_t (*vpx_highbd_sse)(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); + void vpx_highbd_subtract_block_c(int rows, int cols, int16_t* diff_ptr, @@ -5282,7 +5703,12 @@ void vpx_idct16x16_256_add_c(const tran_low_t* input, void vpx_idct16x16_256_add_sse2(const tran_low_t* input, uint8_t* dest, int stride); -#define vpx_idct16x16_256_add vpx_idct16x16_256_add_sse2 +void vpx_idct16x16_256_add_avx2(const tran_low_t* input, + uint8_t* dest, + int stride); +RTCD_EXTERN void (*vpx_idct16x16_256_add)(const tran_low_t* input, + uint8_t* dest, + int stride); void vpx_idct16x16_38_add_c(const tran_low_t* input, uint8_t* dest, int stride); void vpx_idct16x16_38_add_sse2(const tran_low_t* input, @@ -5296,7 +5722,12 @@ void vpx_idct32x32_1024_add_c(const tran_low_t* input, void vpx_idct32x32_1024_add_sse2(const tran_low_t* input, uint8_t* dest, int stride); -#define vpx_idct32x32_1024_add vpx_idct32x32_1024_add_sse2 +void vpx_idct32x32_1024_add_avx2(const tran_low_t* input, + uint8_t* dest, + int stride); +RTCD_EXTERN void (*vpx_idct32x32_1024_add)(const tran_low_t* input, + uint8_t* dest, + int stride); void vpx_idct32x32_135_add_c(const tran_low_t* input, uint8_t* dest, @@ -5307,6 +5738,9 @@ void vpx_idct32x32_135_add_sse2(const tran_low_t* input, void vpx_idct32x32_135_add_ssse3(const tran_low_t* input, uint8_t* dest, int stride); +void vpx_idct32x32_135_add_avx2(const tran_low_t* input, + uint8_t* dest, + int stride); RTCD_EXTERN void (*vpx_idct32x32_135_add)(const tran_low_t* input, uint8_t* dest, int stride); @@ -5707,76 +6141,53 @@ void vpx_post_proc_down_and_across_mb_row_sse2(unsigned char* src, void vpx_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_sse2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_ssse3(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_avx(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vpx_quantize_b)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vpx_quantize_b)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vpx_quantize_b_32x32_c(const tran_low_t* coeff_ptr, const struct macroblock_plane* const mb_plane, @@ -6355,24 +6766,372 @@ void vpx_sad8x8x4d_sse2(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_sad8x8x4d vpx_sad8x8x4d_sse2 -int vpx_satd_c(const tran_low_t* coeff, int length); -int vpx_satd_sse2(const tran_low_t* coeff, int length); -int vpx_satd_avx2(const tran_low_t* coeff, int length); -RTCD_EXTERN int (*vpx_satd)(const tran_low_t* coeff, int length); +unsigned int vpx_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x16 vpx_sad_skip_16x16_sse2 -void vpx_scaled_2d_c(const uint8_t* src, - ptrdiff_t src_stride, - uint8_t* dst, - ptrdiff_t dst_stride, - const InterpKernel* filter, - int x0_q4, - int x_step_q4, - int y0_q4, - int y_step_q4, - int w, - int h); -void vpx_scaled_2d_ssse3(const uint8_t* src, - ptrdiff_t src_stride, +void vpx_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x16x4d vpx_sad_skip_16x16x4d_sse2 + +unsigned int vpx_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x32 vpx_sad_skip_16x32_sse2 + +void vpx_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x32x4d vpx_sad_skip_16x32x4d_sse2 + +unsigned int vpx_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x8 vpx_sad_skip_16x8_sse2 + +void vpx_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x8x4d vpx_sad_skip_16x8x4d_sse2 + +unsigned int vpx_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x16_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x16x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x16x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x64_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x64_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x64x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x64x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x4 vpx_sad_skip_4x4_c + +void vpx_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x4x4d vpx_sad_skip_4x4x4d_c + +unsigned int vpx_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_4x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x8 vpx_sad_skip_4x8_sse2 + +void vpx_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_4x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x8x4d vpx_sad_skip_4x8x4d_sse2 + +unsigned int vpx_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_64x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x64_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x64_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x64x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x64x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_64x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x16 vpx_sad_skip_8x16_sse2 + +void vpx_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x16x4d vpx_sad_skip_8x16x4d_sse2 + +unsigned int vpx_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x4 vpx_sad_skip_8x4_c + +void vpx_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x4x4d vpx_sad_skip_8x4x4d_c + +unsigned int vpx_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x8 vpx_sad_skip_8x8_sse2 + +void vpx_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x8x4d vpx_sad_skip_8x8x4d_sse2 + +int vpx_satd_c(const tran_low_t* coeff, int length); +int vpx_satd_sse2(const tran_low_t* coeff, int length); +int vpx_satd_avx2(const tran_low_t* coeff, int length); +RTCD_EXTERN int (*vpx_satd)(const tran_low_t* coeff, int length); + +void vpx_scaled_2d_c(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_scaled_2d_ssse3(const uint8_t* src, + ptrdiff_t src_stride, uint8_t* dst, ptrdiff_t dst_stride, const InterpKernel* filter, @@ -6459,6 +7218,31 @@ void vpx_scaled_vert_c(const uint8_t* src, int h); #define vpx_scaled_vert vpx_scaled_vert_c +int64_t vpx_sse_c(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +int64_t vpx_sse_sse4_1(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +int64_t vpx_sse_avx2(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +RTCD_EXTERN int64_t (*vpx_sse)(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); + uint32_t vpx_sub_pixel_avg_variance16x16_c(const uint8_t* src_ptr, int src_stride, int x_offset, @@ -7699,6 +8483,9 @@ static void setup_rtcd_internal(void) { (void)flags; + vpx_comp_avg_pred = vpx_comp_avg_pred_sse2; + if (flags & HAS_AVX2) + vpx_comp_avg_pred = vpx_comp_avg_pred_avx2; vpx_convolve8 = vpx_convolve8_sse2; if (flags & HAS_SSSE3) vpx_convolve8 = vpx_convolve8_ssse3; @@ -7972,15 +8759,78 @@ static void setup_rtcd_internal(void) { vpx_highbd_sad64x64x4d = vpx_highbd_sad64x64x4d_sse2; if (flags & HAS_AVX2) vpx_highbd_sad64x64x4d = vpx_highbd_sad64x64x4d_avx2; + vpx_highbd_sad_skip_16x16 = vpx_highbd_sad_skip_16x16_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x16 = vpx_highbd_sad_skip_16x16_avx2; + vpx_highbd_sad_skip_16x16x4d = vpx_highbd_sad_skip_16x16x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x16x4d = vpx_highbd_sad_skip_16x16x4d_avx2; + vpx_highbd_sad_skip_16x32 = vpx_highbd_sad_skip_16x32_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x32 = vpx_highbd_sad_skip_16x32_avx2; + vpx_highbd_sad_skip_16x32x4d = vpx_highbd_sad_skip_16x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x32x4d = vpx_highbd_sad_skip_16x32x4d_avx2; + vpx_highbd_sad_skip_16x8 = vpx_highbd_sad_skip_16x8_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x8 = vpx_highbd_sad_skip_16x8_avx2; + vpx_highbd_sad_skip_16x8x4d = vpx_highbd_sad_skip_16x8x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x8x4d = vpx_highbd_sad_skip_16x8x4d_avx2; + vpx_highbd_sad_skip_32x16 = vpx_highbd_sad_skip_32x16_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x16 = vpx_highbd_sad_skip_32x16_avx2; + vpx_highbd_sad_skip_32x16x4d = vpx_highbd_sad_skip_32x16x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x16x4d = vpx_highbd_sad_skip_32x16x4d_avx2; + vpx_highbd_sad_skip_32x32 = vpx_highbd_sad_skip_32x32_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x32 = vpx_highbd_sad_skip_32x32_avx2; + vpx_highbd_sad_skip_32x32x4d = vpx_highbd_sad_skip_32x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x32x4d = vpx_highbd_sad_skip_32x32x4d_avx2; + vpx_highbd_sad_skip_32x64 = vpx_highbd_sad_skip_32x64_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x64 = vpx_highbd_sad_skip_32x64_avx2; + vpx_highbd_sad_skip_32x64x4d = vpx_highbd_sad_skip_32x64x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x64x4d = vpx_highbd_sad_skip_32x64x4d_avx2; + vpx_highbd_sad_skip_64x32 = vpx_highbd_sad_skip_64x32_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_64x32 = vpx_highbd_sad_skip_64x32_avx2; + vpx_highbd_sad_skip_64x32x4d = vpx_highbd_sad_skip_64x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_64x32x4d = vpx_highbd_sad_skip_64x32x4d_avx2; + vpx_highbd_sad_skip_64x64 = vpx_highbd_sad_skip_64x64_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_64x64 = vpx_highbd_sad_skip_64x64_avx2; + vpx_highbd_sad_skip_64x64x4d = vpx_highbd_sad_skip_64x64x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_64x64x4d = vpx_highbd_sad_skip_64x64x4d_avx2; vpx_highbd_satd = vpx_highbd_satd_c; if (flags & HAS_AVX2) vpx_highbd_satd = vpx_highbd_satd_avx2; + vpx_highbd_sse = vpx_highbd_sse_c; + if (flags & HAS_SSE4_1) { + vpx_highbd_sse = vpx_highbd_sse_sse4_1; + } + if (flags & HAS_AVX2) { + vpx_highbd_sse = vpx_highbd_sse_avx2; + } vpx_highbd_subtract_block = vpx_highbd_subtract_block_c; if (flags & HAS_AVX2) vpx_highbd_subtract_block = vpx_highbd_subtract_block_avx2; + vpx_idct16x16_256_add = vpx_idct16x16_256_add_sse2; + if (flags & HAS_AVX2) + vpx_idct16x16_256_add = vpx_idct16x16_256_add_avx2; + vpx_idct32x32_1024_add = vpx_idct32x32_1024_add_sse2; + if (flags & HAS_AVX2) + vpx_idct32x32_1024_add = vpx_idct32x32_1024_add_avx2; vpx_idct32x32_135_add = vpx_idct32x32_135_add_sse2; if (flags & HAS_SSSE3) vpx_idct32x32_135_add = vpx_idct32x32_135_add_ssse3; + if (flags & HAS_AVX2) + vpx_idct32x32_135_add = vpx_idct32x32_135_add_avx2; vpx_idct32x32_34_add = vpx_idct32x32_34_add_sse2; if (flags & HAS_SSSE3) vpx_idct32x32_34_add = vpx_idct32x32_34_add_ssse3; @@ -8049,12 +8899,49 @@ static void setup_rtcd_internal(void) { vpx_sad64x64x4d = vpx_sad64x64x4d_sse2; if (flags & HAS_AVX2) vpx_sad64x64x4d = vpx_sad64x64x4d_avx2; + vpx_sad_skip_32x16 = vpx_sad_skip_32x16_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x16 = vpx_sad_skip_32x16_avx2; + vpx_sad_skip_32x16x4d = vpx_sad_skip_32x16x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x16x4d = vpx_sad_skip_32x16x4d_avx2; + vpx_sad_skip_32x32 = vpx_sad_skip_32x32_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x32 = vpx_sad_skip_32x32_avx2; + vpx_sad_skip_32x32x4d = vpx_sad_skip_32x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x32x4d = vpx_sad_skip_32x32x4d_avx2; + vpx_sad_skip_32x64 = vpx_sad_skip_32x64_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x64 = vpx_sad_skip_32x64_avx2; + vpx_sad_skip_32x64x4d = vpx_sad_skip_32x64x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x64x4d = vpx_sad_skip_32x64x4d_avx2; + vpx_sad_skip_64x32 = vpx_sad_skip_64x32_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_64x32 = vpx_sad_skip_64x32_avx2; + vpx_sad_skip_64x32x4d = vpx_sad_skip_64x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_64x32x4d = vpx_sad_skip_64x32x4d_avx2; + vpx_sad_skip_64x64 = vpx_sad_skip_64x64_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_64x64 = vpx_sad_skip_64x64_avx2; + vpx_sad_skip_64x64x4d = vpx_sad_skip_64x64x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_64x64x4d = vpx_sad_skip_64x64x4d_avx2; vpx_satd = vpx_satd_sse2; if (flags & HAS_AVX2) vpx_satd = vpx_satd_avx2; vpx_scaled_2d = vpx_scaled_2d_c; if (flags & HAS_SSSE3) vpx_scaled_2d = vpx_scaled_2d_ssse3; + vpx_sse = vpx_sse_c; + if (flags & HAS_SSE4_1) { + vpx_sse = vpx_sse_sse4_1; + } + if (flags & HAS_AVX2) { + vpx_sse = vpx_sse_avx2; + } vpx_sub_pixel_avg_variance16x16 = vpx_sub_pixel_avg_variance16x16_sse2; if (flags & HAS_SSSE3) vpx_sub_pixel_avg_variance16x16 = vpx_sub_pixel_avg_variance16x16_ssse3; diff --git a/libvpx/source/config/mac/ia32/vpx_scale_rtcd.h b/libvpx/source/config/mac/ia32/vpx_scale_rtcd.h old mode 100644 new mode 100755 diff --git a/libvpx/source/config/mac/x64/vp8_rtcd.h b/libvpx/source/config/mac/x64/vp8_rtcd.h old mode 100644 new mode 100755 index e8b8a0e7250bf32663e159de6138aad36bb8017b..36216770a1e8342a0902cad35d35cfeb3bc6b8bf --- a/libvpx/source/config/mac/x64/vp8_rtcd.h +++ b/libvpx/source/config/mac/x64/vp8_rtcd.h @@ -105,36 +105,6 @@ RTCD_EXTERN void (*vp8_bilinear_predict8x8)(unsigned char* src_ptr, unsigned char* dst_ptr, int dst_pitch); -void vp8_blend_b_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_b vp8_blend_b_c - -void vp8_blend_mb_inner_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_inner vp8_blend_mb_inner_c - -void vp8_blend_mb_outer_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_outer vp8_blend_mb_outer_c - int vp8_block_error_c(short* coeff, short* dqcoeff); int vp8_block_error_sse2(short* coeff, short* dqcoeff); #define vp8_block_error vp8_block_error_sse2 diff --git a/libvpx/source/config/mac/x64/vp9_rtcd.h b/libvpx/source/config/mac/x64/vp9_rtcd.h old mode 100644 new mode 100755 index e9e663f801f7a9b6a2167e0c68203c61bde927e0..7771ee3e1a90d32eff2728e1237abe44bdd442f7 --- a/libvpx/source/config/mac/x64/vp9_rtcd.h +++ b/libvpx/source/config/mac/x64/vp9_rtcd.h @@ -21,7 +21,9 @@ struct macroblockd; /* Encoder forward decls */ struct macroblock; -struct vp9_variance_vtable; +struct macroblock_plane; +struct vp9_sad_table; +struct ScanOrder; struct search_site_config; struct mv; union int_mv; @@ -89,29 +91,9 @@ int vp9_diamond_search_sad_c(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); -int vp9_diamond_search_sad_avx(const struct macroblock* x, - const struct search_site_config* cfg, - struct mv* ref_mv, - uint32_t start_mv_sad, - struct mv* best_mv, - int search_param, - int sad_per_bit, - int* num00, - const struct vp9_variance_vtable* fn_ptr, - const struct mv* center_mv); -RTCD_EXTERN int (*vp9_diamond_search_sad)( - const struct macroblock* x, - const struct search_site_config* cfg, - struct mv* ref_mv, - uint32_t start_mv_sad, - struct mv* best_mv, - int search_param, - int sad_per_bit, - int* num00, - const struct vp9_variance_vtable* fn_ptr, - const struct mv* center_mv); +#define vp9_diamond_search_sad vp9_diamond_search_sad_c void vp9_fht16x16_c(const int16_t* input, tran_low_t* output, @@ -278,65 +260,57 @@ void vp9_highbd_post_proc_down_and_across_c(const uint16_t* src_ptr, void vp9_highbd_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_highbd_quantize_fp_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_highbd_quantize_fp)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); - -void vp9_highbd_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -void vp9_highbd_quantize_fp_32x32_avx2(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_highbd_quantize_fp_32x32)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_highbd_quantize_fp)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); + +void vp9_highbd_quantize_fp_32x32_c( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); +void vp9_highbd_quantize_fp_32x32_avx2( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_highbd_quantize_fp_32x32)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vp9_highbd_temporal_filter_apply_c(const uint8_t* frame1, unsigned int stride, @@ -382,95 +356,79 @@ void vp9_iht8x8_64_add_sse2(const tran_low_t* input, void vp9_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_sse2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_ssse3(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_quantize_fp)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_quantize_fp)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_ssse3(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_quantize_fp_32x32)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_quantize_fp_32x32)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vp9_scale_and_extend_frame_c(const struct yv12_buffer_config* src, struct yv12_buffer_config* dst, @@ -501,9 +459,6 @@ static void setup_rtcd_internal(void) { vp9_block_error_fp = vp9_block_error_fp_sse2; if (flags & HAS_AVX2) vp9_block_error_fp = vp9_block_error_fp_avx2; - vp9_diamond_search_sad = vp9_diamond_search_sad_c; - if (flags & HAS_AVX) - vp9_diamond_search_sad = vp9_diamond_search_sad_avx; vp9_highbd_iht16x16_256_add = vp9_highbd_iht16x16_256_add_c; if (flags & HAS_SSE4_1) vp9_highbd_iht16x16_256_add = vp9_highbd_iht16x16_256_add_sse4_1; diff --git a/libvpx/source/config/mac/x64/vpx_config.asm b/libvpx/source/config/mac/x64/vpx_config.asm old mode 100644 new mode 100755 index 1a1a18d7114af817e28d90300521015cd456cb0e..9a2754f2b28808885cdbfb1f26d1eb813b8f8e52 --- a/libvpx/source/config/mac/x64/vpx_config.asm +++ b/libvpx/source/config/mac/x64/vpx_config.asm @@ -1,5 +1,7 @@ %define VPX_ARCH_ARM 0 %define ARCH_ARM 0 +%define VPX_ARCH_AARCH64 0 +%define ARCH_AARCH64 0 %define VPX_ARCH_MIPS 0 %define ARCH_MIPS 0 %define VPX_ARCH_X86 0 @@ -10,8 +12,12 @@ %define ARCH_PPC 0 %define VPX_ARCH_LOONGARCH 0 %define ARCH_LOONGARCH 0 -%define HAVE_NEON 0 %define HAVE_NEON_ASM 0 +%define HAVE_NEON 0 +%define HAVE_NEON_DOTPROD 0 +%define HAVE_NEON_I8MM 0 +%define HAVE_SVE 0 +%define HAVE_SVE2 0 %define HAVE_MIPS32 0 %define HAVE_DSPR2 0 %define HAVE_MSA 0 diff --git a/libvpx/source/config/mac/x64/vpx_config.c b/libvpx/source/config/mac/x64/vpx_config.c old mode 100644 new mode 100755 diff --git a/libvpx/source/config/mac/x64/vpx_config.h b/libvpx/source/config/mac/x64/vpx_config.h old mode 100644 new mode 100755 index 0b6b52ce6c838ca05d8ec986860b21abc70d5154..dcaf89acaf8cdfe2993a730b1562c66c3924cdf8 --- a/libvpx/source/config/mac/x64/vpx_config.h +++ b/libvpx/source/config/mac/x64/vpx_config.h @@ -12,6 +12,8 @@ #define INLINE inline #define VPX_ARCH_ARM 0 #define ARCH_ARM 0 +#define VPX_ARCH_AARCH64 0 +#define ARCH_AARCH64 0 #define VPX_ARCH_MIPS 0 #define ARCH_MIPS 0 #define VPX_ARCH_X86 0 @@ -22,8 +24,12 @@ #define ARCH_PPC 0 #define VPX_ARCH_LOONGARCH 0 #define ARCH_LOONGARCH 0 -#define HAVE_NEON 0 #define HAVE_NEON_ASM 0 +#define HAVE_NEON 0 +#define HAVE_NEON_DOTPROD 0 +#define HAVE_NEON_I8MM 0 +#define HAVE_SVE 0 +#define HAVE_SVE2 0 #define HAVE_MIPS32 0 #define HAVE_DSPR2 0 #define HAVE_MSA 0 diff --git a/libvpx/source/config/mac/x64/vpx_dsp_rtcd.h b/libvpx/source/config/mac/x64/vpx_dsp_rtcd.h old mode 100644 new mode 100755 index 907cab18d3ddab5c1e28a1f2cd90338c9ed52547..5dcdd93e0888dacd2a8521cd4a2f8fb3fbd45155 --- a/libvpx/source/config/mac/x64/vpx_dsp_rtcd.h +++ b/libvpx/source/config/mac/x64/vpx_dsp_rtcd.h @@ -44,7 +44,18 @@ void vpx_comp_avg_pred_sse2(uint8_t* comp_pred, int height, const uint8_t* ref, int ref_stride); -#define vpx_comp_avg_pred vpx_comp_avg_pred_sse2 +void vpx_comp_avg_pred_avx2(uint8_t* comp_pred, + const uint8_t* pred, + int width, + int height, + const uint8_t* ref, + int ref_stride); +RTCD_EXTERN void (*vpx_comp_avg_pred)(uint8_t* comp_pred, + const uint8_t* pred, + int width, + int height, + const uint8_t* ref, + int ref_stride); void vpx_convolve8_c(const uint8_t* src, ptrdiff_t src_stride, @@ -4509,52 +4520,37 @@ void vpx_highbd_minmax_8x8_c(const uint8_t* s8, void vpx_highbd_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_highbd_quantize_b_sse2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_highbd_quantize_b_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vpx_highbd_quantize_b)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vpx_highbd_quantize_b)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vpx_highbd_quantize_b_32x32_c( const tran_low_t* coeff_ptr, @@ -5213,10 +5209,435 @@ void vpx_highbd_sad8x8x4d_sse2(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_highbd_sad8x8x4d vpx_highbd_sad8x8x4d_sse2 +unsigned int vpx_highbd_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x16_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x16x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_16x16x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_16x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_16x32x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x8_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x8x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_16x8x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x16_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x16x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_32x16x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_32x32x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x64_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x64_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x64x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x64x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_32x64x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_4x4 vpx_highbd_sad_skip_4x4_c + +void vpx_highbd_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_4x4x4d vpx_highbd_sad_skip_4x4x4d_c + +unsigned int vpx_highbd_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_4x8 vpx_highbd_sad_skip_4x8_c + +void vpx_highbd_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_4x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_4x8x4d vpx_highbd_sad_skip_4x8x4d_sse2 + +unsigned int vpx_highbd_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_64x32x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x64_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x64_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x64x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x64x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_64x64x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_8x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x16 vpx_highbd_sad_skip_8x16_sse2 + +void vpx_highbd_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_8x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x16x4d vpx_highbd_sad_skip_8x16x4d_sse2 + +unsigned int vpx_highbd_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x4 vpx_highbd_sad_skip_8x4_c + +void vpx_highbd_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x4x4d vpx_highbd_sad_skip_8x4x4d_c + +unsigned int vpx_highbd_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_8x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x8 vpx_highbd_sad_skip_8x8_sse2 + +void vpx_highbd_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_8x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x8x4d vpx_highbd_sad_skip_8x8x4d_sse2 + int vpx_highbd_satd_c(const tran_low_t* coeff, int length); int vpx_highbd_satd_avx2(const tran_low_t* coeff, int length); RTCD_EXTERN int (*vpx_highbd_satd)(const tran_low_t* coeff, int length); +int64_t vpx_highbd_sse_c(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +int64_t vpx_highbd_sse_sse4_1(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +int64_t vpx_highbd_sse_avx2(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +RTCD_EXTERN int64_t (*vpx_highbd_sse)(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); + void vpx_highbd_subtract_block_c(int rows, int cols, int16_t* diff_ptr, @@ -5359,7 +5780,12 @@ void vpx_idct16x16_256_add_c(const tran_low_t* input, void vpx_idct16x16_256_add_sse2(const tran_low_t* input, uint8_t* dest, int stride); -#define vpx_idct16x16_256_add vpx_idct16x16_256_add_sse2 +void vpx_idct16x16_256_add_avx2(const tran_low_t* input, + uint8_t* dest, + int stride); +RTCD_EXTERN void (*vpx_idct16x16_256_add)(const tran_low_t* input, + uint8_t* dest, + int stride); void vpx_idct16x16_38_add_c(const tran_low_t* input, uint8_t* dest, int stride); void vpx_idct16x16_38_add_sse2(const tran_low_t* input, @@ -5373,7 +5799,12 @@ void vpx_idct32x32_1024_add_c(const tran_low_t* input, void vpx_idct32x32_1024_add_sse2(const tran_low_t* input, uint8_t* dest, int stride); -#define vpx_idct32x32_1024_add vpx_idct32x32_1024_add_sse2 +void vpx_idct32x32_1024_add_avx2(const tran_low_t* input, + uint8_t* dest, + int stride); +RTCD_EXTERN void (*vpx_idct32x32_1024_add)(const tran_low_t* input, + uint8_t* dest, + int stride); void vpx_idct32x32_135_add_c(const tran_low_t* input, uint8_t* dest, @@ -5384,6 +5815,9 @@ void vpx_idct32x32_135_add_sse2(const tran_low_t* input, void vpx_idct32x32_135_add_ssse3(const tran_low_t* input, uint8_t* dest, int stride); +void vpx_idct32x32_135_add_avx2(const tran_low_t* input, + uint8_t* dest, + int stride); RTCD_EXTERN void (*vpx_idct32x32_135_add)(const tran_low_t* input, uint8_t* dest, int stride); @@ -5784,76 +6218,53 @@ void vpx_post_proc_down_and_across_mb_row_sse2(unsigned char* src, void vpx_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_sse2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_ssse3(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_avx(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vpx_quantize_b)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vpx_quantize_b)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vpx_quantize_b_32x32_c(const tran_low_t* coeff_ptr, const struct macroblock_plane* const mb_plane, @@ -6432,24 +6843,372 @@ void vpx_sad8x8x4d_sse2(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_sad8x8x4d vpx_sad8x8x4d_sse2 -int vpx_satd_c(const tran_low_t* coeff, int length); -int vpx_satd_sse2(const tran_low_t* coeff, int length); -int vpx_satd_avx2(const tran_low_t* coeff, int length); -RTCD_EXTERN int (*vpx_satd)(const tran_low_t* coeff, int length); +unsigned int vpx_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x16 vpx_sad_skip_16x16_sse2 -void vpx_scaled_2d_c(const uint8_t* src, - ptrdiff_t src_stride, - uint8_t* dst, - ptrdiff_t dst_stride, - const InterpKernel* filter, - int x0_q4, - int x_step_q4, - int y0_q4, - int y_step_q4, - int w, - int h); -void vpx_scaled_2d_ssse3(const uint8_t* src, - ptrdiff_t src_stride, +void vpx_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x16x4d vpx_sad_skip_16x16x4d_sse2 + +unsigned int vpx_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x32 vpx_sad_skip_16x32_sse2 + +void vpx_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x32x4d vpx_sad_skip_16x32x4d_sse2 + +unsigned int vpx_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x8 vpx_sad_skip_16x8_sse2 + +void vpx_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x8x4d vpx_sad_skip_16x8x4d_sse2 + +unsigned int vpx_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x16_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x16x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x16x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x64_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x64_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x64x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x64x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x4 vpx_sad_skip_4x4_c + +void vpx_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x4x4d vpx_sad_skip_4x4x4d_c + +unsigned int vpx_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_4x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x8 vpx_sad_skip_4x8_sse2 + +void vpx_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_4x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x8x4d vpx_sad_skip_4x8x4d_sse2 + +unsigned int vpx_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_64x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x64_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x64_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x64x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x64x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_64x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x16 vpx_sad_skip_8x16_sse2 + +void vpx_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x16x4d vpx_sad_skip_8x16x4d_sse2 + +unsigned int vpx_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x4 vpx_sad_skip_8x4_c + +void vpx_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x4x4d vpx_sad_skip_8x4x4d_c + +unsigned int vpx_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x8 vpx_sad_skip_8x8_sse2 + +void vpx_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x8x4d vpx_sad_skip_8x8x4d_sse2 + +int vpx_satd_c(const tran_low_t* coeff, int length); +int vpx_satd_sse2(const tran_low_t* coeff, int length); +int vpx_satd_avx2(const tran_low_t* coeff, int length); +RTCD_EXTERN int (*vpx_satd)(const tran_low_t* coeff, int length); + +void vpx_scaled_2d_c(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_scaled_2d_ssse3(const uint8_t* src, + ptrdiff_t src_stride, uint8_t* dst, ptrdiff_t dst_stride, const InterpKernel* filter, @@ -6536,6 +7295,31 @@ void vpx_scaled_vert_c(const uint8_t* src, int h); #define vpx_scaled_vert vpx_scaled_vert_c +int64_t vpx_sse_c(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +int64_t vpx_sse_sse4_1(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +int64_t vpx_sse_avx2(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +RTCD_EXTERN int64_t (*vpx_sse)(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); + uint32_t vpx_sub_pixel_avg_variance16x16_c(const uint8_t* src_ptr, int src_stride, int x_offset, @@ -7776,6 +8560,9 @@ static void setup_rtcd_internal(void) { (void)flags; + vpx_comp_avg_pred = vpx_comp_avg_pred_sse2; + if (flags & HAS_AVX2) + vpx_comp_avg_pred = vpx_comp_avg_pred_avx2; vpx_convolve8 = vpx_convolve8_sse2; if (flags & HAS_SSSE3) vpx_convolve8 = vpx_convolve8_ssse3; @@ -8052,15 +8839,78 @@ static void setup_rtcd_internal(void) { vpx_highbd_sad64x64x4d = vpx_highbd_sad64x64x4d_sse2; if (flags & HAS_AVX2) vpx_highbd_sad64x64x4d = vpx_highbd_sad64x64x4d_avx2; + vpx_highbd_sad_skip_16x16 = vpx_highbd_sad_skip_16x16_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x16 = vpx_highbd_sad_skip_16x16_avx2; + vpx_highbd_sad_skip_16x16x4d = vpx_highbd_sad_skip_16x16x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x16x4d = vpx_highbd_sad_skip_16x16x4d_avx2; + vpx_highbd_sad_skip_16x32 = vpx_highbd_sad_skip_16x32_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x32 = vpx_highbd_sad_skip_16x32_avx2; + vpx_highbd_sad_skip_16x32x4d = vpx_highbd_sad_skip_16x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x32x4d = vpx_highbd_sad_skip_16x32x4d_avx2; + vpx_highbd_sad_skip_16x8 = vpx_highbd_sad_skip_16x8_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x8 = vpx_highbd_sad_skip_16x8_avx2; + vpx_highbd_sad_skip_16x8x4d = vpx_highbd_sad_skip_16x8x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x8x4d = vpx_highbd_sad_skip_16x8x4d_avx2; + vpx_highbd_sad_skip_32x16 = vpx_highbd_sad_skip_32x16_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x16 = vpx_highbd_sad_skip_32x16_avx2; + vpx_highbd_sad_skip_32x16x4d = vpx_highbd_sad_skip_32x16x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x16x4d = vpx_highbd_sad_skip_32x16x4d_avx2; + vpx_highbd_sad_skip_32x32 = vpx_highbd_sad_skip_32x32_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x32 = vpx_highbd_sad_skip_32x32_avx2; + vpx_highbd_sad_skip_32x32x4d = vpx_highbd_sad_skip_32x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x32x4d = vpx_highbd_sad_skip_32x32x4d_avx2; + vpx_highbd_sad_skip_32x64 = vpx_highbd_sad_skip_32x64_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x64 = vpx_highbd_sad_skip_32x64_avx2; + vpx_highbd_sad_skip_32x64x4d = vpx_highbd_sad_skip_32x64x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x64x4d = vpx_highbd_sad_skip_32x64x4d_avx2; + vpx_highbd_sad_skip_64x32 = vpx_highbd_sad_skip_64x32_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_64x32 = vpx_highbd_sad_skip_64x32_avx2; + vpx_highbd_sad_skip_64x32x4d = vpx_highbd_sad_skip_64x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_64x32x4d = vpx_highbd_sad_skip_64x32x4d_avx2; + vpx_highbd_sad_skip_64x64 = vpx_highbd_sad_skip_64x64_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_64x64 = vpx_highbd_sad_skip_64x64_avx2; + vpx_highbd_sad_skip_64x64x4d = vpx_highbd_sad_skip_64x64x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_64x64x4d = vpx_highbd_sad_skip_64x64x4d_avx2; vpx_highbd_satd = vpx_highbd_satd_c; if (flags & HAS_AVX2) vpx_highbd_satd = vpx_highbd_satd_avx2; + vpx_highbd_sse = vpx_highbd_sse_c; + if (flags & HAS_SSE4_1) { + vpx_highbd_sse = vpx_highbd_sse_sse4_1; + } + if (flags & HAS_AVX2) { + vpx_highbd_sse = vpx_highbd_sse_avx2; + } vpx_highbd_subtract_block = vpx_highbd_subtract_block_c; if (flags & HAS_AVX2) vpx_highbd_subtract_block = vpx_highbd_subtract_block_avx2; + vpx_idct16x16_256_add = vpx_idct16x16_256_add_sse2; + if (flags & HAS_AVX2) + vpx_idct16x16_256_add = vpx_idct16x16_256_add_avx2; + vpx_idct32x32_1024_add = vpx_idct32x32_1024_add_sse2; + if (flags & HAS_AVX2) + vpx_idct32x32_1024_add = vpx_idct32x32_1024_add_avx2; vpx_idct32x32_135_add = vpx_idct32x32_135_add_sse2; if (flags & HAS_SSSE3) vpx_idct32x32_135_add = vpx_idct32x32_135_add_ssse3; + if (flags & HAS_AVX2) + vpx_idct32x32_135_add = vpx_idct32x32_135_add_avx2; vpx_idct32x32_34_add = vpx_idct32x32_34_add_sse2; if (flags & HAS_SSSE3) vpx_idct32x32_34_add = vpx_idct32x32_34_add_ssse3; @@ -8129,12 +8979,49 @@ static void setup_rtcd_internal(void) { vpx_sad64x64x4d = vpx_sad64x64x4d_sse2; if (flags & HAS_AVX2) vpx_sad64x64x4d = vpx_sad64x64x4d_avx2; + vpx_sad_skip_32x16 = vpx_sad_skip_32x16_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x16 = vpx_sad_skip_32x16_avx2; + vpx_sad_skip_32x16x4d = vpx_sad_skip_32x16x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x16x4d = vpx_sad_skip_32x16x4d_avx2; + vpx_sad_skip_32x32 = vpx_sad_skip_32x32_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x32 = vpx_sad_skip_32x32_avx2; + vpx_sad_skip_32x32x4d = vpx_sad_skip_32x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x32x4d = vpx_sad_skip_32x32x4d_avx2; + vpx_sad_skip_32x64 = vpx_sad_skip_32x64_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x64 = vpx_sad_skip_32x64_avx2; + vpx_sad_skip_32x64x4d = vpx_sad_skip_32x64x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x64x4d = vpx_sad_skip_32x64x4d_avx2; + vpx_sad_skip_64x32 = vpx_sad_skip_64x32_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_64x32 = vpx_sad_skip_64x32_avx2; + vpx_sad_skip_64x32x4d = vpx_sad_skip_64x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_64x32x4d = vpx_sad_skip_64x32x4d_avx2; + vpx_sad_skip_64x64 = vpx_sad_skip_64x64_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_64x64 = vpx_sad_skip_64x64_avx2; + vpx_sad_skip_64x64x4d = vpx_sad_skip_64x64x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_64x64x4d = vpx_sad_skip_64x64x4d_avx2; vpx_satd = vpx_satd_sse2; if (flags & HAS_AVX2) vpx_satd = vpx_satd_avx2; vpx_scaled_2d = vpx_scaled_2d_c; if (flags & HAS_SSSE3) vpx_scaled_2d = vpx_scaled_2d_ssse3; + vpx_sse = vpx_sse_c; + if (flags & HAS_SSE4_1) { + vpx_sse = vpx_sse_sse4_1; + } + if (flags & HAS_AVX2) { + vpx_sse = vpx_sse_avx2; + } vpx_sub_pixel_avg_variance16x16 = vpx_sub_pixel_avg_variance16x16_sse2; if (flags & HAS_SSSE3) vpx_sub_pixel_avg_variance16x16 = vpx_sub_pixel_avg_variance16x16_ssse3; diff --git a/libvpx/source/config/mac/x64/vpx_scale_rtcd.h b/libvpx/source/config/mac/x64/vpx_scale_rtcd.h old mode 100644 new mode 100755 diff --git a/libvpx/source/config/nacl/vp8_rtcd.h b/libvpx/source/config/nacl/vp8_rtcd.h old mode 100644 new mode 100755 index 3a166c097ebb4355e0e83af13cf3d1a56bdd3bca..7719e1c4a61055fd69f3d3eb82aa1eee92a1f8ae --- a/libvpx/source/config/nacl/vp8_rtcd.h +++ b/libvpx/source/config/nacl/vp8_rtcd.h @@ -59,36 +59,6 @@ void vp8_bilinear_predict8x8_c(unsigned char* src_ptr, int dst_pitch); #define vp8_bilinear_predict8x8 vp8_bilinear_predict8x8_c -void vp8_blend_b_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_b vp8_blend_b_c - -void vp8_blend_mb_inner_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_inner vp8_blend_mb_inner_c - -void vp8_blend_mb_outer_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_outer vp8_blend_mb_outer_c - int vp8_block_error_c(short* coeff, short* dqcoeff); #define vp8_block_error vp8_block_error_c diff --git a/libvpx/source/config/nacl/vp9_rtcd.h b/libvpx/source/config/nacl/vp9_rtcd.h old mode 100644 new mode 100755 index 02526ef923223d08539265f8645dcd484efd0a9a..ee9940ac10d95049893608010c51c0d948ec343f --- a/libvpx/source/config/nacl/vp9_rtcd.h +++ b/libvpx/source/config/nacl/vp9_rtcd.h @@ -21,7 +21,9 @@ struct macroblockd; /* Encoder forward decls */ struct macroblock; -struct vp9_variance_vtable; +struct macroblock_plane; +struct vp9_sad_table; +struct ScanOrder; struct search_site_config; struct mv; union int_mv; @@ -61,7 +63,7 @@ int vp9_diamond_search_sad_c(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); #define vp9_diamond_search_sad vp9_diamond_search_sad_c @@ -175,26 +177,23 @@ void vp9_highbd_post_proc_down_and_across_c(const uint16_t* src_ptr, void vp9_highbd_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_highbd_quantize_fp vp9_highbd_quantize_fp_c -void vp9_highbd_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); +void vp9_highbd_quantize_fp_32x32_c( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); #define vp9_highbd_quantize_fp_32x32 vp9_highbd_quantize_fp_32x32_c void vp9_highbd_temporal_filter_apply_c(const uint8_t* frame1, @@ -229,26 +228,22 @@ void vp9_iht8x8_64_add_c(const tran_low_t* input, void vp9_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp vp9_quantize_fp_c void vp9_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp_32x32 vp9_quantize_fp_32x32_c void vp9_scale_and_extend_frame_c(const struct yv12_buffer_config* src, diff --git a/libvpx/source/config/nacl/vpx_config.c b/libvpx/source/config/nacl/vpx_config.c old mode 100644 new mode 100755 diff --git a/libvpx/source/config/nacl/vpx_config.h b/libvpx/source/config/nacl/vpx_config.h old mode 100644 new mode 100755 index f0664c038e9a84e4496763d44830d6bb3b7c635d..cf565e8d7f6d05acf8d460b48c99cee3e348d4ff --- a/libvpx/source/config/nacl/vpx_config.h +++ b/libvpx/source/config/nacl/vpx_config.h @@ -12,6 +12,8 @@ #define INLINE inline #define VPX_ARCH_ARM 0 #define ARCH_ARM 0 +#define VPX_ARCH_AARCH64 0 +#define ARCH_AARCH64 0 #define VPX_ARCH_MIPS 0 #define ARCH_MIPS 0 #define VPX_ARCH_X86 0 @@ -22,8 +24,12 @@ #define ARCH_PPC 0 #define VPX_ARCH_LOONGARCH 0 #define ARCH_LOONGARCH 0 -#define HAVE_NEON 0 #define HAVE_NEON_ASM 0 +#define HAVE_NEON 0 +#define HAVE_NEON_DOTPROD 0 +#define HAVE_NEON_I8MM 0 +#define HAVE_SVE 0 +#define HAVE_SVE2 0 #define HAVE_MIPS32 0 #define HAVE_DSPR2 0 #define HAVE_MSA 0 diff --git a/libvpx/source/config/nacl/vpx_dsp_rtcd.h b/libvpx/source/config/nacl/vpx_dsp_rtcd.h old mode 100644 new mode 100755 index 28d34ec0107176901e33d18796c3eefd4b13aed3..050b1f90569ee2525c7ddf9366f9a4a47e8be156 --- a/libvpx/source/config/nacl/vpx_dsp_rtcd.h +++ b/libvpx/source/config/nacl/vpx_dsp_rtcd.h @@ -2418,16 +2418,12 @@ void vpx_highbd_minmax_8x8_c(const uint8_t* s8, void vpx_highbd_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vpx_highbd_quantize_b vpx_highbd_quantize_b_c void vpx_highbd_quantize_b_32x32_c( @@ -2700,9 +2696,186 @@ void vpx_highbd_sad8x8x4d_c(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_highbd_sad8x8x4d vpx_highbd_sad8x8x4d_c +unsigned int vpx_highbd_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_16x16 vpx_highbd_sad_skip_16x16_c + +void vpx_highbd_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_16x16x4d vpx_highbd_sad_skip_16x16x4d_c + +unsigned int vpx_highbd_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_16x32 vpx_highbd_sad_skip_16x32_c + +void vpx_highbd_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_16x32x4d vpx_highbd_sad_skip_16x32x4d_c + +unsigned int vpx_highbd_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_16x8 vpx_highbd_sad_skip_16x8_c + +void vpx_highbd_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_16x8x4d vpx_highbd_sad_skip_16x8x4d_c + +unsigned int vpx_highbd_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_32x16 vpx_highbd_sad_skip_32x16_c + +void vpx_highbd_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_32x16x4d vpx_highbd_sad_skip_32x16x4d_c + +unsigned int vpx_highbd_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_32x32 vpx_highbd_sad_skip_32x32_c + +void vpx_highbd_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_32x32x4d vpx_highbd_sad_skip_32x32x4d_c + +unsigned int vpx_highbd_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_32x64 vpx_highbd_sad_skip_32x64_c + +void vpx_highbd_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_32x64x4d vpx_highbd_sad_skip_32x64x4d_c + +unsigned int vpx_highbd_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_4x4 vpx_highbd_sad_skip_4x4_c + +void vpx_highbd_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_4x4x4d vpx_highbd_sad_skip_4x4x4d_c + +unsigned int vpx_highbd_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_4x8 vpx_highbd_sad_skip_4x8_c + +void vpx_highbd_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_4x8x4d vpx_highbd_sad_skip_4x8x4d_c + +unsigned int vpx_highbd_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_64x32 vpx_highbd_sad_skip_64x32_c + +void vpx_highbd_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_64x32x4d vpx_highbd_sad_skip_64x32x4d_c + +unsigned int vpx_highbd_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_64x64 vpx_highbd_sad_skip_64x64_c + +void vpx_highbd_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_64x64x4d vpx_highbd_sad_skip_64x64x4d_c + +unsigned int vpx_highbd_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x16 vpx_highbd_sad_skip_8x16_c + +void vpx_highbd_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x16x4d vpx_highbd_sad_skip_8x16x4d_c + +unsigned int vpx_highbd_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x4 vpx_highbd_sad_skip_8x4_c + +void vpx_highbd_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x4x4d vpx_highbd_sad_skip_8x4x4d_c + +unsigned int vpx_highbd_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x8 vpx_highbd_sad_skip_8x8_c + +void vpx_highbd_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x8x4d vpx_highbd_sad_skip_8x8x4d_c + int vpx_highbd_satd_c(const tran_low_t* coeff, int length); #define vpx_highbd_satd vpx_highbd_satd_c +int64_t vpx_highbd_sse_c(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +#define vpx_highbd_sse vpx_highbd_sse_c + void vpx_highbd_subtract_block_c(int rows, int cols, int16_t* diff_ptr, @@ -2997,16 +3170,12 @@ void vpx_post_proc_down_and_across_mb_row_c(unsigned char* src, void vpx_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vpx_quantize_b vpx_quantize_b_c void vpx_quantize_b_32x32_c(const tran_low_t* coeff_ptr, @@ -3278,6 +3447,175 @@ void vpx_sad8x8x4d_c(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_sad8x8x4d vpx_sad8x8x4d_c +unsigned int vpx_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x16 vpx_sad_skip_16x16_c + +void vpx_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x16x4d vpx_sad_skip_16x16x4d_c + +unsigned int vpx_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x32 vpx_sad_skip_16x32_c + +void vpx_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x32x4d vpx_sad_skip_16x32x4d_c + +unsigned int vpx_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x8 vpx_sad_skip_16x8_c + +void vpx_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x8x4d vpx_sad_skip_16x8x4d_c + +unsigned int vpx_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x16 vpx_sad_skip_32x16_c + +void vpx_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x16x4d vpx_sad_skip_32x16x4d_c + +unsigned int vpx_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x32 vpx_sad_skip_32x32_c + +void vpx_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x32x4d vpx_sad_skip_32x32x4d_c + +unsigned int vpx_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_32x64 vpx_sad_skip_32x64_c + +void vpx_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_32x64x4d vpx_sad_skip_32x64x4d_c + +unsigned int vpx_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x4 vpx_sad_skip_4x4_c + +void vpx_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x4x4d vpx_sad_skip_4x4x4d_c + +unsigned int vpx_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x8 vpx_sad_skip_4x8_c + +void vpx_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x8x4d vpx_sad_skip_4x8x4d_c + +unsigned int vpx_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_64x32 vpx_sad_skip_64x32_c + +void vpx_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_64x32x4d vpx_sad_skip_64x32x4d_c + +unsigned int vpx_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_64x64 vpx_sad_skip_64x64_c + +void vpx_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_64x64x4d vpx_sad_skip_64x64x4d_c + +unsigned int vpx_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x16 vpx_sad_skip_8x16_c + +void vpx_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x16x4d vpx_sad_skip_8x16x4d_c + +unsigned int vpx_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x4 vpx_sad_skip_8x4_c + +void vpx_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x4x4d vpx_sad_skip_8x4x4d_c + +unsigned int vpx_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x8 vpx_sad_skip_8x8_c + +void vpx_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x8x4d vpx_sad_skip_8x8x4d_c + int vpx_satd_c(const tran_low_t* coeff, int length); #define vpx_satd vpx_satd_c @@ -3359,6 +3697,14 @@ void vpx_scaled_vert_c(const uint8_t* src, int h); #define vpx_scaled_vert vpx_scaled_vert_c +int64_t vpx_sse_c(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +#define vpx_sse vpx_sse_c + uint32_t vpx_sub_pixel_avg_variance16x16_c(const uint8_t* src_ptr, int src_stride, int x_offset, diff --git a/libvpx/source/config/nacl/vpx_scale_rtcd.h b/libvpx/source/config/nacl/vpx_scale_rtcd.h old mode 100644 new mode 100755 diff --git a/libvpx/source/config/vpx_version.h b/libvpx/source/config/vpx_version.h old mode 100644 new mode 100755 index cdeeb75d2a0169f2f4a80aff561cce4a7850ee12..2b886158b0c20d11c19ae529e7e98110863aa4f5 --- a/libvpx/source/config/vpx_version.h +++ b/libvpx/source/config/vpx_version.h @@ -1,9 +1,9 @@ // This file is generated. Do not edit. #define VERSION_MAJOR 1 -#define VERSION_MINOR 13 -#define VERSION_PATCH 0 -#define VERSION_EXTRA "243-g27171320f" +#define VERSION_MINOR 14 +#define VERSION_PATCH 1 +#define VERSION_EXTRA "290-g713e0faca" #define VERSION_PACKED \ ((VERSION_MAJOR << 16) | (VERSION_MINOR << 8) | (VERSION_PATCH)) -#define VERSION_STRING_NOSP "v1.13.0-243-g27171320f" -#define VERSION_STRING " v1.13.0-243-g27171320f" +#define VERSION_STRING_NOSP "v1.14.1-290-g713e0faca" +#define VERSION_STRING " v1.14.1-290-g713e0faca" diff --git a/libvpx/source/config/win/arm64/vp8_rtcd.h b/libvpx/source/config/win/arm64-highbd/vp8_rtcd.h old mode 100644 new mode 100755 similarity index 95% rename from libvpx/source/config/win/arm64/vp8_rtcd.h rename to libvpx/source/config/win/arm64-highbd/vp8_rtcd.h index eb0b3a7cb44e16dc07e8b8f4985011dc9aa9fd16..102501094254bb09d784498a444bed4e77bf00a4 --- a/libvpx/source/config/win/arm64/vp8_rtcd.h +++ b/libvpx/source/config/win/arm64-highbd/vp8_rtcd.h @@ -83,36 +83,6 @@ void vp8_bilinear_predict8x8_neon(unsigned char* src_ptr, int dst_pitch); #define vp8_bilinear_predict8x8 vp8_bilinear_predict8x8_neon -void vp8_blend_b_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_b vp8_blend_b_c - -void vp8_blend_mb_inner_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_inner vp8_blend_mb_inner_c - -void vp8_blend_mb_outer_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_outer vp8_blend_mb_outer_c - int vp8_block_error_c(short* coeff, short* dqcoeff); #define vp8_block_error vp8_block_error_c diff --git a/libvpx/source/config/win/arm64/vp9_rtcd.h b/libvpx/source/config/win/arm64-highbd/vp9_rtcd.h old mode 100644 new mode 100755 similarity index 84% rename from libvpx/source/config/win/arm64/vp9_rtcd.h rename to libvpx/source/config/win/arm64-highbd/vp9_rtcd.h index acfadf825c23143297ccacf420de551120482901..e64cb2c35ae41f8e525dc5c35e8b263b910bbad9 --- a/libvpx/source/config/win/arm64/vp9_rtcd.h +++ b/libvpx/source/config/win/arm64-highbd/vp9_rtcd.h @@ -21,7 +21,9 @@ struct macroblockd; /* Encoder forward decls */ struct macroblock; -struct vp9_variance_vtable; +struct macroblock_plane; +struct vp9_sad_table; +struct ScanOrder; struct search_site_config; struct mv; union int_mv; @@ -77,7 +79,7 @@ int vp9_diamond_search_sad_c(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); int vp9_diamond_search_sad_neon(const struct macroblock* x, const struct search_site_config* cfg, @@ -87,7 +89,7 @@ int vp9_diamond_search_sad_neon(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); #define vp9_diamond_search_sad vp9_diamond_search_sad_neon @@ -245,46 +247,40 @@ void vp9_highbd_post_proc_down_and_across_c(const uint16_t* src_ptr, void vp9_highbd_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_highbd_quantize_fp_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_highbd_quantize_fp vp9_highbd_quantize_fp_neon -void vp9_highbd_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -void vp9_highbd_quantize_fp_32x32_neon(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); +void vp9_highbd_quantize_fp_32x32_c( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); +void vp9_highbd_quantize_fp_32x32_neon( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); #define vp9_highbd_quantize_fp_32x32 vp9_highbd_quantize_fp_32x32_neon void vp9_highbd_temporal_filter_apply_c(const uint8_t* frame1, @@ -331,46 +327,38 @@ void vp9_iht8x8_64_add_neon(const tran_low_t* input, void vp9_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp vp9_quantize_fp_neon void vp9_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vp9_quantize_fp_32x32 vp9_quantize_fp_32x32_neon void vp9_scale_and_extend_frame_c(const struct yv12_buffer_config* src, diff --git a/libvpx/source/config/win/arm64/vpx_config.asm b/libvpx/source/config/win/arm64-highbd/vpx_config.asm old mode 100644 new mode 100755 similarity index 93% rename from libvpx/source/config/win/arm64/vpx_config.asm rename to libvpx/source/config/win/arm64-highbd/vpx_config.asm index 0bbb0fab711dc513653ff62f2b304f5550eff960..7d7e38fcb56fe3ddf1efedabef052172755e1999 --- a/libvpx/source/config/win/arm64/vpx_config.asm +++ b/libvpx/source/config/win/arm64-highbd/vpx_config.asm @@ -4,6 +4,8 @@ .syntax unified .equ VPX_ARCH_ARM , 1 .equ ARCH_ARM , 1 +.equ VPX_ARCH_AARCH64 , 1 +.equ ARCH_AARCH64 , 1 .equ VPX_ARCH_MIPS , 0 .equ ARCH_MIPS , 0 .equ VPX_ARCH_X86 , 0 @@ -14,8 +16,12 @@ .equ ARCH_PPC , 0 .equ VPX_ARCH_LOONGARCH , 0 .equ ARCH_LOONGARCH , 0 -.equ HAVE_NEON , 1 .equ HAVE_NEON_ASM , 0 +.equ HAVE_NEON , 1 +.equ HAVE_NEON_DOTPROD , 1 +.equ HAVE_NEON_I8MM , 1 +.equ HAVE_SVE , 0 +.equ HAVE_SVE2 , 0 .equ HAVE_MIPS32 , 0 .equ HAVE_DSPR2 , 0 .equ HAVE_MSA , 0 @@ -54,7 +60,7 @@ .equ CONFIG_DEBUG_LIBS , 0 .equ CONFIG_DEQUANT_TOKENS , 0 .equ CONFIG_DC_RECON , 0 -.equ CONFIG_RUNTIME_CPU_DETECT , 0 +.equ CONFIG_RUNTIME_CPU_DETECT , 1 .equ CONFIG_POSTPROC , 1 .equ CONFIG_VP9_POSTPROC , 1 .equ CONFIG_MULTITHREAD , 1 diff --git a/libvpx/source/config/win/arm64/vpx_config.c b/libvpx/source/config/win/arm64-highbd/vpx_config.c old mode 100644 new mode 100755 similarity index 95% rename from libvpx/source/config/win/arm64/vpx_config.c rename to libvpx/source/config/win/arm64-highbd/vpx_config.c index b24e1a582f4380d7f977d10ab9767527e090ded1..cb12cbe770c97204d4889e382be97fe8189ca5b9 --- a/libvpx/source/config/win/arm64/vpx_config.c +++ b/libvpx/source/config/win/arm64-highbd/vpx_config.c @@ -6,5 +6,5 @@ /* in the file PATENTS. All contributing project authors may */ /* be found in the AUTHORS file in the root of the source tree. */ #include "vpx/vpx_codec.h" -static const char* const cfg = "--target=arm64-win64-vs15 --enable-external-build --enable-postproc --enable-multi-res-encoding --enable-temporal-denoising --enable-vp9-temporal-denoising --enable-vp9-postproc --size-limit=16384x16384 --enable-realtime-only --disable-install-docs --disable-libyuv --enable-vp9-highbitdepth"; +static const char* const cfg = "--target=arm64-win64-vs15 --enable-external-build --enable-postproc --enable-multi-res-encoding --enable-temporal-denoising --enable-vp9-temporal-denoising --enable-vp9-postproc --size-limit=16384x16384 --enable-realtime-only --disable-install-docs --disable-libyuv --enable-vp9-highbitdepth --disable-sve --disable-sve2"; const char *vpx_codec_build_config(void) {return cfg;} diff --git a/libvpx/source/config/win/arm64/vpx_config.h b/libvpx/source/config/win/arm64-highbd/vpx_config.h old mode 100644 new mode 100755 similarity index 94% rename from libvpx/source/config/win/arm64/vpx_config.h rename to libvpx/source/config/win/arm64-highbd/vpx_config.h index f9a2093c3b8e7626f176119464d3442910defcee..74d3936464befbd70053e5ce5059aa6efb2939c4 --- a/libvpx/source/config/win/arm64/vpx_config.h +++ b/libvpx/source/config/win/arm64-highbd/vpx_config.h @@ -12,6 +12,8 @@ #define INLINE __inline #define VPX_ARCH_ARM 1 #define ARCH_ARM 1 +#define VPX_ARCH_AARCH64 1 +#define ARCH_AARCH64 1 #define VPX_ARCH_MIPS 0 #define ARCH_MIPS 0 #define VPX_ARCH_X86 0 @@ -22,8 +24,12 @@ #define ARCH_PPC 0 #define VPX_ARCH_LOONGARCH 0 #define ARCH_LOONGARCH 0 -#define HAVE_NEON 1 #define HAVE_NEON_ASM 0 +#define HAVE_NEON 1 +#define HAVE_NEON_DOTPROD 1 +#define HAVE_NEON_I8MM 1 +#define HAVE_SVE 0 +#define HAVE_SVE2 0 #define HAVE_MIPS32 0 #define HAVE_DSPR2 0 #define HAVE_MSA 0 @@ -62,7 +68,7 @@ #define CONFIG_DEBUG_LIBS 0 #define CONFIG_DEQUANT_TOKENS 0 #define CONFIG_DC_RECON 0 -#define CONFIG_RUNTIME_CPU_DETECT 0 +#define CONFIG_RUNTIME_CPU_DETECT 1 #define CONFIG_POSTPROC 1 #define CONFIG_VP9_POSTPROC 1 #define CONFIG_MULTITHREAD 1 diff --git a/libvpx/source/config/win/arm64/vpx_dsp_rtcd.h b/libvpx/source/config/win/arm64-highbd/vpx_dsp_rtcd.h old mode 100644 new mode 100755 similarity index 77% rename from libvpx/source/config/win/arm64/vpx_dsp_rtcd.h rename to libvpx/source/config/win/arm64-highbd/vpx_dsp_rtcd.h index 69d38d127483de538d08a76d48a4ad240f82d803..f6641cb99f27294060c47a639ba2e61a8b11f4f8 --- a/libvpx/source/config/win/arm64/vpx_dsp_rtcd.h +++ b/libvpx/source/config/win/arm64-highbd/vpx_dsp_rtcd.h @@ -68,7 +68,39 @@ void vpx_convolve8_neon(const uint8_t* src, int y_step_q4, int w, int h); -#define vpx_convolve8 vpx_convolve8_neon +void vpx_convolve8_neon_dotprod(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_convolve8_neon_i8mm(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +RTCD_EXTERN void (*vpx_convolve8)(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); void vpx_convolve8_avg_c(const uint8_t* src, ptrdiff_t src_stride, @@ -92,7 +124,39 @@ void vpx_convolve8_avg_neon(const uint8_t* src, int y_step_q4, int w, int h); -#define vpx_convolve8_avg vpx_convolve8_avg_neon +void vpx_convolve8_avg_neon_dotprod(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_convolve8_avg_neon_i8mm(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +RTCD_EXTERN void (*vpx_convolve8_avg)(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); void vpx_convolve8_avg_horiz_c(const uint8_t* src, ptrdiff_t src_stride, @@ -116,7 +180,39 @@ void vpx_convolve8_avg_horiz_neon(const uint8_t* src, int y_step_q4, int w, int h); -#define vpx_convolve8_avg_horiz vpx_convolve8_avg_horiz_neon +void vpx_convolve8_avg_horiz_neon_dotprod(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_convolve8_avg_horiz_neon_i8mm(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +RTCD_EXTERN void (*vpx_convolve8_avg_horiz)(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); void vpx_convolve8_avg_vert_c(const uint8_t* src, ptrdiff_t src_stride, @@ -140,7 +236,39 @@ void vpx_convolve8_avg_vert_neon(const uint8_t* src, int y_step_q4, int w, int h); -#define vpx_convolve8_avg_vert vpx_convolve8_avg_vert_neon +void vpx_convolve8_avg_vert_neon_dotprod(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_convolve8_avg_vert_neon_i8mm(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +RTCD_EXTERN void (*vpx_convolve8_avg_vert)(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); void vpx_convolve8_horiz_c(const uint8_t* src, ptrdiff_t src_stride, @@ -164,7 +292,39 @@ void vpx_convolve8_horiz_neon(const uint8_t* src, int y_step_q4, int w, int h); -#define vpx_convolve8_horiz vpx_convolve8_horiz_neon +void vpx_convolve8_horiz_neon_dotprod(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_convolve8_horiz_neon_i8mm(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +RTCD_EXTERN void (*vpx_convolve8_horiz)(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); void vpx_convolve8_vert_c(const uint8_t* src, ptrdiff_t src_stride, @@ -188,7 +348,39 @@ void vpx_convolve8_vert_neon(const uint8_t* src, int y_step_q4, int w, int h); -#define vpx_convolve8_vert vpx_convolve8_vert_neon +void vpx_convolve8_vert_neon_dotprod(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_convolve8_vert_neon_i8mm(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +RTCD_EXTERN void (*vpx_convolve8_vert)(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); void vpx_convolve_avg_c(const uint8_t* src, ptrdiff_t src_stride, @@ -700,7 +892,18 @@ void vpx_get16x16var_neon(const uint8_t* src_ptr, int ref_stride, unsigned int* sse, int* sum); -#define vpx_get16x16var vpx_get16x16var_neon +void vpx_get16x16var_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); +RTCD_EXTERN void (*vpx_get16x16var)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); unsigned int vpx_get4x4sse_cs_c(const unsigned char* src_ptr, int src_stride, @@ -710,7 +913,14 @@ unsigned int vpx_get4x4sse_cs_neon(const unsigned char* src_ptr, int src_stride, const unsigned char* ref_ptr, int ref_stride); -#define vpx_get4x4sse_cs vpx_get4x4sse_cs_neon +unsigned int vpx_get4x4sse_cs_neon_dotprod(const unsigned char* src_ptr, + int src_stride, + const unsigned char* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_get4x4sse_cs)(const unsigned char* src_ptr, + int src_stride, + const unsigned char* ref_ptr, + int ref_stride); void vpx_get8x8var_c(const uint8_t* src_ptr, int src_stride, @@ -724,7 +934,18 @@ void vpx_get8x8var_neon(const uint8_t* src_ptr, int ref_stride, unsigned int* sse, int* sum); -#define vpx_get8x8var vpx_get8x8var_neon +void vpx_get8x8var_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); +RTCD_EXTERN void (*vpx_get8x8var)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse, + int* sum); unsigned int vpx_get_mb_ss_c(const int16_t*); #define vpx_get_mb_ss vpx_get_mb_ss_c @@ -2277,7 +2498,16 @@ unsigned int vpx_highbd_8_mse16x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_8_mse16x16 vpx_highbd_8_mse16x16_neon +unsigned int vpx_highbd_8_mse16x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_8_mse16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_8_mse16x8_c(const uint8_t* src_ptr, int src_stride, @@ -2289,7 +2519,16 @@ unsigned int vpx_highbd_8_mse16x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_8_mse16x8 vpx_highbd_8_mse16x8_neon +unsigned int vpx_highbd_8_mse16x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_8_mse16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_8_mse8x16_c(const uint8_t* src_ptr, int src_stride, @@ -2301,7 +2540,16 @@ unsigned int vpx_highbd_8_mse8x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_8_mse8x16 vpx_highbd_8_mse8x16_neon +unsigned int vpx_highbd_8_mse8x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_8_mse8x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_highbd_8_mse8x8_c(const uint8_t* src_ptr, int src_stride, @@ -2313,7 +2561,16 @@ unsigned int vpx_highbd_8_mse8x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_highbd_8_mse8x8 vpx_highbd_8_mse8x8_neon +unsigned int vpx_highbd_8_mse8x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_highbd_8_mse8x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); uint32_t vpx_highbd_8_sub_pixel_avg_variance16x16_c(const uint8_t* src_ptr, int src_stride, @@ -4144,28 +4401,20 @@ void vpx_highbd_minmax_8x8_neon(const uint8_t* s8, void vpx_highbd_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_highbd_quantize_b_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vpx_highbd_quantize_b vpx_highbd_quantize_b_neon void vpx_highbd_quantize_b_32x32_c( @@ -4628,85 +4877,385 @@ void vpx_highbd_sad8x8x4d_neon(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_highbd_sad8x8x4d vpx_highbd_sad8x8x4d_neon -int vpx_highbd_satd_c(const tran_low_t* coeff, int length); -int vpx_highbd_satd_neon(const tran_low_t* coeff, int length); -#define vpx_highbd_satd vpx_highbd_satd_neon +unsigned int vpx_highbd_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_16x16 vpx_highbd_sad_skip_16x16_neon -void vpx_highbd_subtract_block_c(int rows, - int cols, - int16_t* diff_ptr, - ptrdiff_t diff_stride, - const uint8_t* src8_ptr, - ptrdiff_t src_stride, - const uint8_t* pred8_ptr, - ptrdiff_t pred_stride, - int bd); -void vpx_highbd_subtract_block_neon(int rows, - int cols, - int16_t* diff_ptr, - ptrdiff_t diff_stride, - const uint8_t* src8_ptr, - ptrdiff_t src_stride, - const uint8_t* pred8_ptr, - ptrdiff_t pred_stride, - int bd); -#define vpx_highbd_subtract_block vpx_highbd_subtract_block_neon +void vpx_highbd_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_16x16x4d vpx_highbd_sad_skip_16x16x4d_neon -void vpx_highbd_tm_predictor_16x16_c(uint16_t* dst, - ptrdiff_t stride, - const uint16_t* above, - const uint16_t* left, - int bd); -void vpx_highbd_tm_predictor_16x16_neon(uint16_t* dst, - ptrdiff_t stride, - const uint16_t* above, - const uint16_t* left, - int bd); -#define vpx_highbd_tm_predictor_16x16 vpx_highbd_tm_predictor_16x16_neon +unsigned int vpx_highbd_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_16x32 vpx_highbd_sad_skip_16x32_neon -void vpx_highbd_tm_predictor_32x32_c(uint16_t* dst, - ptrdiff_t stride, - const uint16_t* above, - const uint16_t* left, - int bd); -void vpx_highbd_tm_predictor_32x32_neon(uint16_t* dst, - ptrdiff_t stride, - const uint16_t* above, - const uint16_t* left, - int bd); -#define vpx_highbd_tm_predictor_32x32 vpx_highbd_tm_predictor_32x32_neon +void vpx_highbd_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_16x32x4d vpx_highbd_sad_skip_16x32x4d_neon -void vpx_highbd_tm_predictor_4x4_c(uint16_t* dst, - ptrdiff_t stride, - const uint16_t* above, - const uint16_t* left, - int bd); -void vpx_highbd_tm_predictor_4x4_neon(uint16_t* dst, - ptrdiff_t stride, - const uint16_t* above, - const uint16_t* left, - int bd); -#define vpx_highbd_tm_predictor_4x4 vpx_highbd_tm_predictor_4x4_neon +unsigned int vpx_highbd_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_16x8 vpx_highbd_sad_skip_16x8_neon -void vpx_highbd_tm_predictor_8x8_c(uint16_t* dst, - ptrdiff_t stride, - const uint16_t* above, - const uint16_t* left, - int bd); -void vpx_highbd_tm_predictor_8x8_neon(uint16_t* dst, - ptrdiff_t stride, - const uint16_t* above, - const uint16_t* left, - int bd); -#define vpx_highbd_tm_predictor_8x8 vpx_highbd_tm_predictor_8x8_neon +void vpx_highbd_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_16x8x4d vpx_highbd_sad_skip_16x8x4d_neon -void vpx_highbd_v_predictor_16x16_c(uint16_t* dst, - ptrdiff_t stride, - const uint16_t* above, - const uint16_t* left, - int bd); -void vpx_highbd_v_predictor_16x16_neon(uint16_t* dst, - ptrdiff_t stride, +unsigned int vpx_highbd_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_32x16 vpx_highbd_sad_skip_32x16_neon + +void vpx_highbd_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_32x16x4d vpx_highbd_sad_skip_32x16x4d_neon + +unsigned int vpx_highbd_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_32x32 vpx_highbd_sad_skip_32x32_neon + +void vpx_highbd_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_32x32x4d vpx_highbd_sad_skip_32x32x4d_neon + +unsigned int vpx_highbd_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x64_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_32x64 vpx_highbd_sad_skip_32x64_neon + +void vpx_highbd_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x64x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_32x64x4d vpx_highbd_sad_skip_32x64x4d_neon + +unsigned int vpx_highbd_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_4x4_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_4x4 vpx_highbd_sad_skip_4x4_neon + +void vpx_highbd_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_4x4x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_4x4x4d vpx_highbd_sad_skip_4x4x4d_neon + +unsigned int vpx_highbd_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_4x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_4x8 vpx_highbd_sad_skip_4x8_neon + +void vpx_highbd_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_4x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_4x8x4d vpx_highbd_sad_skip_4x8x4d_neon + +unsigned int vpx_highbd_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_64x32 vpx_highbd_sad_skip_64x32_neon + +void vpx_highbd_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_64x32x4d vpx_highbd_sad_skip_64x32x4d_neon + +unsigned int vpx_highbd_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x64_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_64x64 vpx_highbd_sad_skip_64x64_neon + +void vpx_highbd_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x64x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_64x64x4d vpx_highbd_sad_skip_64x64x4d_neon + +unsigned int vpx_highbd_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_8x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x16 vpx_highbd_sad_skip_8x16_neon + +void vpx_highbd_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_8x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x16x4d vpx_highbd_sad_skip_8x16x4d_neon + +unsigned int vpx_highbd_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_8x4_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x4 vpx_highbd_sad_skip_8x4_neon + +void vpx_highbd_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_8x4x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x4x4d vpx_highbd_sad_skip_8x4x4d_neon + +unsigned int vpx_highbd_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_8x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x8 vpx_highbd_sad_skip_8x8_neon + +void vpx_highbd_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_8x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x8x4d vpx_highbd_sad_skip_8x8x4d_neon + +int vpx_highbd_satd_c(const tran_low_t* coeff, int length); +int vpx_highbd_satd_neon(const tran_low_t* coeff, int length); +#define vpx_highbd_satd vpx_highbd_satd_neon + +int64_t vpx_highbd_sse_c(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +int64_t vpx_highbd_sse_neon(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +#define vpx_highbd_sse vpx_highbd_sse_neon + +void vpx_highbd_subtract_block_c(int rows, + int cols, + int16_t* diff_ptr, + ptrdiff_t diff_stride, + const uint8_t* src8_ptr, + ptrdiff_t src_stride, + const uint8_t* pred8_ptr, + ptrdiff_t pred_stride, + int bd); +void vpx_highbd_subtract_block_neon(int rows, + int cols, + int16_t* diff_ptr, + ptrdiff_t diff_stride, + const uint8_t* src8_ptr, + ptrdiff_t src_stride, + const uint8_t* pred8_ptr, + ptrdiff_t pred_stride, + int bd); +#define vpx_highbd_subtract_block vpx_highbd_subtract_block_neon + +void vpx_highbd_tm_predictor_16x16_c(uint16_t* dst, + ptrdiff_t stride, + const uint16_t* above, + const uint16_t* left, + int bd); +void vpx_highbd_tm_predictor_16x16_neon(uint16_t* dst, + ptrdiff_t stride, + const uint16_t* above, + const uint16_t* left, + int bd); +#define vpx_highbd_tm_predictor_16x16 vpx_highbd_tm_predictor_16x16_neon + +void vpx_highbd_tm_predictor_32x32_c(uint16_t* dst, + ptrdiff_t stride, + const uint16_t* above, + const uint16_t* left, + int bd); +void vpx_highbd_tm_predictor_32x32_neon(uint16_t* dst, + ptrdiff_t stride, + const uint16_t* above, + const uint16_t* left, + int bd); +#define vpx_highbd_tm_predictor_32x32 vpx_highbd_tm_predictor_32x32_neon + +void vpx_highbd_tm_predictor_4x4_c(uint16_t* dst, + ptrdiff_t stride, + const uint16_t* above, + const uint16_t* left, + int bd); +void vpx_highbd_tm_predictor_4x4_neon(uint16_t* dst, + ptrdiff_t stride, + const uint16_t* above, + const uint16_t* left, + int bd); +#define vpx_highbd_tm_predictor_4x4 vpx_highbd_tm_predictor_4x4_neon + +void vpx_highbd_tm_predictor_8x8_c(uint16_t* dst, + ptrdiff_t stride, + const uint16_t* above, + const uint16_t* left, + int bd); +void vpx_highbd_tm_predictor_8x8_neon(uint16_t* dst, + ptrdiff_t stride, + const uint16_t* above, + const uint16_t* left, + int bd); +#define vpx_highbd_tm_predictor_8x8 vpx_highbd_tm_predictor_8x8_neon + +void vpx_highbd_v_predictor_16x16_c(uint16_t* dst, + ptrdiff_t stride, + const uint16_t* above, + const uint16_t* left, + int bd); +void vpx_highbd_v_predictor_16x16_neon(uint16_t* dst, + ptrdiff_t stride, const uint16_t* above, const uint16_t* left, int bd); @@ -5064,7 +5613,16 @@ unsigned int vpx_mse16x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_mse16x16 vpx_mse16x16_neon +unsigned int vpx_mse16x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_mse16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_mse16x8_c(const uint8_t* src_ptr, int src_stride, @@ -5076,7 +5634,16 @@ unsigned int vpx_mse16x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_mse16x8 vpx_mse16x8_neon +unsigned int vpx_mse16x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_mse16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_mse8x16_c(const uint8_t* src_ptr, int src_stride, @@ -5088,7 +5655,16 @@ unsigned int vpx_mse8x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_mse8x16 vpx_mse8x16_neon +unsigned int vpx_mse8x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_mse8x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_mse8x8_c(const uint8_t* src_ptr, int src_stride, @@ -5100,7 +5676,16 @@ unsigned int vpx_mse8x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_mse8x8 vpx_mse8x8_neon +unsigned int vpx_mse8x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_mse8x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); void vpx_plane_add_noise_c(uint8_t* start, const int8_t* noise, @@ -5130,28 +5715,20 @@ void vpx_post_proc_down_and_across_mb_row_neon(unsigned char* src, void vpx_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_neon(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); #define vpx_quantize_b vpx_quantize_b_neon void vpx_quantize_b_32x32_c(const tran_low_t* coeff_ptr, @@ -5178,7 +5755,14 @@ unsigned int vpx_sad16x16_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad16x16 vpx_sad16x16_neon +unsigned int vpx_sad16x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad16x16_avg_c(const uint8_t* src_ptr, int src_stride, @@ -5190,7 +5774,16 @@ unsigned int vpx_sad16x16_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad16x16_avg vpx_sad16x16_avg_neon +unsigned int vpx_sad16x16_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad16x16_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad16x16x4d_c(const uint8_t* src_ptr, int src_stride, @@ -5202,7 +5795,16 @@ void vpx_sad16x16x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad16x16x4d vpx_sad16x16x4d_neon +void vpx_sad16x16x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad16x16x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad16x32_c(const uint8_t* src_ptr, int src_stride, @@ -5212,7 +5814,14 @@ unsigned int vpx_sad16x32_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad16x32 vpx_sad16x32_neon +unsigned int vpx_sad16x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad16x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad16x32_avg_c(const uint8_t* src_ptr, int src_stride, @@ -5224,7 +5833,16 @@ unsigned int vpx_sad16x32_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad16x32_avg vpx_sad16x32_avg_neon +unsigned int vpx_sad16x32_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad16x32_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad16x32x4d_c(const uint8_t* src_ptr, int src_stride, @@ -5236,7 +5854,16 @@ void vpx_sad16x32x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad16x32x4d vpx_sad16x32x4d_neon +void vpx_sad16x32x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad16x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad16x8_c(const uint8_t* src_ptr, int src_stride, @@ -5246,7 +5873,14 @@ unsigned int vpx_sad16x8_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad16x8 vpx_sad16x8_neon +unsigned int vpx_sad16x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad16x8_avg_c(const uint8_t* src_ptr, int src_stride, @@ -5258,19 +5892,37 @@ unsigned int vpx_sad16x8_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad16x8_avg vpx_sad16x8_avg_neon - -void vpx_sad16x8x4d_c(const uint8_t* src_ptr, - int src_stride, - const uint8_t* const ref_array[4], - int ref_stride, +unsigned int vpx_sad16x8_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad16x8_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); + +void vpx_sad16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, uint32_t sad_array[4]); void vpx_sad16x8x4d_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad16x8x4d vpx_sad16x8x4d_neon +void vpx_sad16x8x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad16x8x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad32x16_c(const uint8_t* src_ptr, int src_stride, @@ -5280,7 +5932,14 @@ unsigned int vpx_sad32x16_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad32x16 vpx_sad32x16_neon +unsigned int vpx_sad32x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad32x16_avg_c(const uint8_t* src_ptr, int src_stride, @@ -5292,7 +5951,16 @@ unsigned int vpx_sad32x16_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad32x16_avg vpx_sad32x16_avg_neon +unsigned int vpx_sad32x16_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad32x16_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad32x16x4d_c(const uint8_t* src_ptr, int src_stride, @@ -5304,7 +5972,16 @@ void vpx_sad32x16x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad32x16x4d vpx_sad32x16x4d_neon +void vpx_sad32x16x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad32x16x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad32x32_c(const uint8_t* src_ptr, int src_stride, @@ -5314,7 +5991,14 @@ unsigned int vpx_sad32x32_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad32x32 vpx_sad32x32_neon +unsigned int vpx_sad32x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad32x32_avg_c(const uint8_t* src_ptr, int src_stride, @@ -5326,7 +6010,16 @@ unsigned int vpx_sad32x32_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad32x32_avg vpx_sad32x32_avg_neon +unsigned int vpx_sad32x32_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad32x32_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad32x32x4d_c(const uint8_t* src_ptr, int src_stride, @@ -5338,7 +6031,16 @@ void vpx_sad32x32x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad32x32x4d vpx_sad32x32x4d_neon +void vpx_sad32x32x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad32x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad32x64_c(const uint8_t* src_ptr, int src_stride, @@ -5348,7 +6050,14 @@ unsigned int vpx_sad32x64_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad32x64 vpx_sad32x64_neon +unsigned int vpx_sad32x64_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad32x64_avg_c(const uint8_t* src_ptr, int src_stride, @@ -5360,7 +6069,16 @@ unsigned int vpx_sad32x64_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad32x64_avg vpx_sad32x64_avg_neon +unsigned int vpx_sad32x64_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad32x64_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad32x64x4d_c(const uint8_t* src_ptr, int src_stride, @@ -5372,7 +6090,16 @@ void vpx_sad32x64x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad32x64x4d vpx_sad32x64x4d_neon +void vpx_sad32x64x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad32x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); unsigned int vpx_sad4x4_c(const uint8_t* src_ptr, int src_stride, @@ -5450,7 +6177,14 @@ unsigned int vpx_sad64x32_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, int ref_stride); -#define vpx_sad64x32 vpx_sad64x32_neon +unsigned int vpx_sad64x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); unsigned int vpx_sad64x32_avg_c(const uint8_t* src_ptr, int src_stride, @@ -5462,7 +6196,16 @@ unsigned int vpx_sad64x32_avg_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, const uint8_t* second_pred); -#define vpx_sad64x32_avg vpx_sad64x32_avg_neon +unsigned int vpx_sad64x32_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad64x32_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); void vpx_sad64x32x4d_c(const uint8_t* src_ptr, int src_stride, @@ -5474,143 +6217,591 @@ void vpx_sad64x32x4d_neon(const uint8_t* src_ptr, const uint8_t* const ref_array[4], int ref_stride, uint32_t sad_array[4]); -#define vpx_sad64x32x4d vpx_sad64x32x4d_neon +void vpx_sad64x32x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad64x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad64x64_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad64x64_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +unsigned int vpx_sad64x64_avg_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +unsigned int vpx_sad64x64_avg_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +unsigned int vpx_sad64x64_avg_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +RTCD_EXTERN unsigned int (*vpx_sad64x64_avg)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); + +void vpx_sad64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad64x64x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad64x64x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad64x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad8x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad8x16 vpx_sad8x16_neon + +unsigned int vpx_sad8x16_avg_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +unsigned int vpx_sad8x16_avg_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +#define vpx_sad8x16_avg vpx_sad8x16_avg_neon + +void vpx_sad8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad8x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad8x16x4d vpx_sad8x16x4d_neon + +unsigned int vpx_sad8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad8x4_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad8x4 vpx_sad8x4_neon + +unsigned int vpx_sad8x4_avg_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +unsigned int vpx_sad8x4_avg_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +#define vpx_sad8x4_avg vpx_sad8x4_avg_neon + +void vpx_sad8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad8x4x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad8x4x4d vpx_sad8x4x4d_neon + +unsigned int vpx_sad8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad8x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad8x8 vpx_sad8x8_neon + +unsigned int vpx_sad8x8_avg_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +unsigned int vpx_sad8x8_avg_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + const uint8_t* second_pred); +#define vpx_sad8x8_avg vpx_sad8x8_avg_neon + +void vpx_sad8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad8x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad8x8x4d vpx_sad8x8x4d_neon + +unsigned int vpx_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x16x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_16x16x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_16x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x32x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_16x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x8x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_16x8x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x16x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x16x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x16x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x32x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x64_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x64_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x64x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x64x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_4x4_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x4 vpx_sad_skip_4x4_neon + +void vpx_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_4x4x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x4x4d vpx_sad_skip_4x4x4d_neon + +unsigned int vpx_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_4x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x8 vpx_sad_skip_4x8_neon + +void vpx_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_4x8x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x8x4d vpx_sad_skip_4x8x4d_neon + +unsigned int vpx_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x32_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x32x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x32x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_64x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x64_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x64_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x64x4d_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x64x4d_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_64x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x16_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x16 vpx_sad_skip_8x16_neon -unsigned int vpx_sad64x64_c(const uint8_t* src_ptr, +void vpx_sad_skip_8x16x4d_c(const uint8_t* src_ptr, int src_stride, - const uint8_t* ref_ptr, - int ref_stride); -unsigned int vpx_sad64x64_neon(const uint8_t* src_ptr, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x16x4d_neon(const uint8_t* src_ptr, int src_stride, - const uint8_t* ref_ptr, - int ref_stride); -#define vpx_sad64x64 vpx_sad64x64_neon + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x16x4d vpx_sad_skip_8x16x4d_neon -unsigned int vpx_sad64x64_avg_c(const uint8_t* src_ptr, +unsigned int vpx_sad_skip_8x4_c(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, - int ref_stride, - const uint8_t* second_pred); -unsigned int vpx_sad64x64_avg_neon(const uint8_t* src_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x4_neon(const uint8_t* src_ptr, int src_stride, const uint8_t* ref_ptr, - int ref_stride, - const uint8_t* second_pred); -#define vpx_sad64x64_avg vpx_sad64x64_avg_neon - -void vpx_sad64x64x4d_c(const uint8_t* src_ptr, - int src_stride, - const uint8_t* const ref_array[4], - int ref_stride, - uint32_t sad_array[4]); -void vpx_sad64x64x4d_neon(const uint8_t* src_ptr, - int src_stride, - const uint8_t* const ref_array[4], - int ref_stride, - uint32_t sad_array[4]); -#define vpx_sad64x64x4d vpx_sad64x64x4d_neon + int ref_stride); +#define vpx_sad_skip_8x4 vpx_sad_skip_8x4_neon -unsigned int vpx_sad8x16_c(const uint8_t* src_ptr, +void vpx_sad_skip_8x4x4d_c(const uint8_t* src_ptr, int src_stride, - const uint8_t* ref_ptr, - int ref_stride); -unsigned int vpx_sad8x16_neon(const uint8_t* src_ptr, - int src_stride, - const uint8_t* ref_ptr, - int ref_stride); -#define vpx_sad8x16 vpx_sad8x16_neon - -unsigned int vpx_sad8x16_avg_c(const uint8_t* src_ptr, - int src_stride, - const uint8_t* ref_ptr, - int ref_stride, - const uint8_t* second_pred); -unsigned int vpx_sad8x16_avg_neon(const uint8_t* src_ptr, - int src_stride, - const uint8_t* ref_ptr, - int ref_stride, - const uint8_t* second_pred); -#define vpx_sad8x16_avg vpx_sad8x16_avg_neon - -void vpx_sad8x16x4d_c(const uint8_t* src_ptr, - int src_stride, - const uint8_t* const ref_array[4], - int ref_stride, - uint32_t sad_array[4]); -void vpx_sad8x16x4d_neon(const uint8_t* src_ptr, - int src_stride, - const uint8_t* const ref_array[4], - int ref_stride, - uint32_t sad_array[4]); -#define vpx_sad8x16x4d vpx_sad8x16x4d_neon - -unsigned int vpx_sad8x4_c(const uint8_t* src_ptr, - int src_stride, - const uint8_t* ref_ptr, - int ref_stride); -unsigned int vpx_sad8x4_neon(const uint8_t* src_ptr, - int src_stride, - const uint8_t* ref_ptr, - int ref_stride); -#define vpx_sad8x4 vpx_sad8x4_neon - -unsigned int vpx_sad8x4_avg_c(const uint8_t* src_ptr, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x4x4d_neon(const uint8_t* src_ptr, int src_stride, - const uint8_t* ref_ptr, + const uint8_t* const ref_array[4], int ref_stride, - const uint8_t* second_pred); -unsigned int vpx_sad8x4_avg_neon(const uint8_t* src_ptr, - int src_stride, - const uint8_t* ref_ptr, - int ref_stride, - const uint8_t* second_pred); -#define vpx_sad8x4_avg vpx_sad8x4_avg_neon - -void vpx_sad8x4x4d_c(const uint8_t* src_ptr, - int src_stride, - const uint8_t* const ref_array[4], - int ref_stride, - uint32_t sad_array[4]); -void vpx_sad8x4x4d_neon(const uint8_t* src_ptr, - int src_stride, - const uint8_t* const ref_array[4], - int ref_stride, - uint32_t sad_array[4]); -#define vpx_sad8x4x4d vpx_sad8x4x4d_neon + uint32_t sad_array[4]); +#define vpx_sad_skip_8x4x4d vpx_sad_skip_8x4x4d_neon -unsigned int vpx_sad8x8_c(const uint8_t* src_ptr, - int src_stride, - const uint8_t* ref_ptr, - int ref_stride); -unsigned int vpx_sad8x8_neon(const uint8_t* src_ptr, - int src_stride, - const uint8_t* ref_ptr, - int ref_stride); -#define vpx_sad8x8 vpx_sad8x8_neon +unsigned int vpx_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x8_neon(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x8 vpx_sad_skip_8x8_neon -unsigned int vpx_sad8x8_avg_c(const uint8_t* src_ptr, +void vpx_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x8x4d_neon(const uint8_t* src_ptr, int src_stride, - const uint8_t* ref_ptr, + const uint8_t* const ref_array[4], int ref_stride, - const uint8_t* second_pred); -unsigned int vpx_sad8x8_avg_neon(const uint8_t* src_ptr, - int src_stride, - const uint8_t* ref_ptr, - int ref_stride, - const uint8_t* second_pred); -#define vpx_sad8x8_avg vpx_sad8x8_avg_neon - -void vpx_sad8x8x4d_c(const uint8_t* src_ptr, - int src_stride, - const uint8_t* const ref_array[4], - int ref_stride, - uint32_t sad_array[4]); -void vpx_sad8x8x4d_neon(const uint8_t* src_ptr, - int src_stride, - const uint8_t* const ref_array[4], - int ref_stride, - uint32_t sad_array[4]); -#define vpx_sad8x8x4d vpx_sad8x8x4d_neon + uint32_t sad_array[4]); +#define vpx_sad_skip_8x8x4d vpx_sad_skip_8x8x4d_neon int vpx_satd_c(const tran_low_t* coeff, int length); int vpx_satd_neon(const tran_low_t* coeff, int length); @@ -5705,6 +6896,31 @@ void vpx_scaled_vert_c(const uint8_t* src, int h); #define vpx_scaled_vert vpx_scaled_vert_c +int64_t vpx_sse_c(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +int64_t vpx_sse_neon(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +int64_t vpx_sse_neon_dotprod(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +RTCD_EXTERN int64_t (*vpx_sse)(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); + uint32_t vpx_sub_pixel_avg_variance16x16_c(const uint8_t* src_ptr, int src_stride, int x_offset, @@ -6259,7 +7475,16 @@ unsigned int vpx_variance16x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance16x16 vpx_variance16x16_neon +unsigned int vpx_variance16x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance16x32_c(const uint8_t* src_ptr, int src_stride, @@ -6271,7 +7496,16 @@ unsigned int vpx_variance16x32_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance16x32 vpx_variance16x32_neon +unsigned int vpx_variance16x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance16x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance16x8_c(const uint8_t* src_ptr, int src_stride, @@ -6283,7 +7517,16 @@ unsigned int vpx_variance16x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance16x8 vpx_variance16x8_neon +unsigned int vpx_variance16x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance32x16_c(const uint8_t* src_ptr, int src_stride, @@ -6295,7 +7538,16 @@ unsigned int vpx_variance32x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance32x16 vpx_variance32x16_neon +unsigned int vpx_variance32x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance32x32_c(const uint8_t* src_ptr, int src_stride, @@ -6307,7 +7559,16 @@ unsigned int vpx_variance32x32_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance32x32 vpx_variance32x32_neon +unsigned int vpx_variance32x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance32x64_c(const uint8_t* src_ptr, int src_stride, @@ -6319,7 +7580,16 @@ unsigned int vpx_variance32x64_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance32x64 vpx_variance32x64_neon +unsigned int vpx_variance32x64_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance4x4_c(const uint8_t* src_ptr, int src_stride, @@ -6331,7 +7601,16 @@ unsigned int vpx_variance4x4_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance4x4 vpx_variance4x4_neon +unsigned int vpx_variance4x4_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance4x4)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance4x8_c(const uint8_t* src_ptr, int src_stride, @@ -6343,7 +7622,16 @@ unsigned int vpx_variance4x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance4x8 vpx_variance4x8_neon +unsigned int vpx_variance4x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance4x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance64x32_c(const uint8_t* src_ptr, int src_stride, @@ -6355,7 +7643,16 @@ unsigned int vpx_variance64x32_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance64x32 vpx_variance64x32_neon +unsigned int vpx_variance64x32_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance64x64_c(const uint8_t* src_ptr, int src_stride, @@ -6367,7 +7664,16 @@ unsigned int vpx_variance64x64_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance64x64 vpx_variance64x64_neon +unsigned int vpx_variance64x64_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance8x16_c(const uint8_t* src_ptr, int src_stride, @@ -6379,7 +7685,16 @@ unsigned int vpx_variance8x16_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance8x16 vpx_variance8x16_neon +unsigned int vpx_variance8x16_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance8x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance8x4_c(const uint8_t* src_ptr, int src_stride, @@ -6391,7 +7706,16 @@ unsigned int vpx_variance8x4_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance8x4 vpx_variance8x4_neon +unsigned int vpx_variance8x4_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance8x4)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); unsigned int vpx_variance8x8_c(const uint8_t* src_ptr, int src_stride, @@ -6403,7 +7727,16 @@ unsigned int vpx_variance8x8_neon(const uint8_t* src_ptr, const uint8_t* ref_ptr, int ref_stride, unsigned int* sse); -#define vpx_variance8x8 vpx_variance8x8_neon +unsigned int vpx_variance8x8_neon_dotprod(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); +RTCD_EXTERN unsigned int (*vpx_variance8x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride, + unsigned int* sse); void vpx_ve_predictor_4x4_c(uint8_t* dst, ptrdiff_t stride, @@ -6425,6 +7758,237 @@ static void setup_rtcd_internal(void) { int flags = arm_cpu_caps(); (void)flags; + + vpx_convolve8 = vpx_convolve8_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_convolve8 = vpx_convolve8_neon_dotprod; + if (flags & HAS_NEON_I8MM) + vpx_convolve8 = vpx_convolve8_neon_i8mm; + vpx_convolve8_avg = vpx_convolve8_avg_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_convolve8_avg = vpx_convolve8_avg_neon_dotprod; + if (flags & HAS_NEON_I8MM) + vpx_convolve8_avg = vpx_convolve8_avg_neon_i8mm; + vpx_convolve8_avg_horiz = vpx_convolve8_avg_horiz_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_convolve8_avg_horiz = vpx_convolve8_avg_horiz_neon_dotprod; + if (flags & HAS_NEON_I8MM) + vpx_convolve8_avg_horiz = vpx_convolve8_avg_horiz_neon_i8mm; + vpx_convolve8_avg_vert = vpx_convolve8_avg_vert_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_convolve8_avg_vert = vpx_convolve8_avg_vert_neon_dotprod; + if (flags & HAS_NEON_I8MM) + vpx_convolve8_avg_vert = vpx_convolve8_avg_vert_neon_i8mm; + vpx_convolve8_horiz = vpx_convolve8_horiz_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_convolve8_horiz = vpx_convolve8_horiz_neon_dotprod; + if (flags & HAS_NEON_I8MM) + vpx_convolve8_horiz = vpx_convolve8_horiz_neon_i8mm; + vpx_convolve8_vert = vpx_convolve8_vert_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_convolve8_vert = vpx_convolve8_vert_neon_dotprod; + if (flags & HAS_NEON_I8MM) + vpx_convolve8_vert = vpx_convolve8_vert_neon_i8mm; + vpx_get16x16var = vpx_get16x16var_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_get16x16var = vpx_get16x16var_neon_dotprod; + vpx_get4x4sse_cs = vpx_get4x4sse_cs_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_get4x4sse_cs = vpx_get4x4sse_cs_neon_dotprod; + vpx_get8x8var = vpx_get8x8var_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_get8x8var = vpx_get8x8var_neon_dotprod; + vpx_highbd_8_mse16x16 = vpx_highbd_8_mse16x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_highbd_8_mse16x16 = vpx_highbd_8_mse16x16_neon_dotprod; + } + vpx_highbd_8_mse16x8 = vpx_highbd_8_mse16x8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_highbd_8_mse16x8 = vpx_highbd_8_mse16x8_neon_dotprod; + } + vpx_highbd_8_mse8x16 = vpx_highbd_8_mse8x16_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_highbd_8_mse8x16 = vpx_highbd_8_mse8x16_neon_dotprod; + } + vpx_highbd_8_mse8x8 = vpx_highbd_8_mse8x8_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_highbd_8_mse8x8 = vpx_highbd_8_mse8x8_neon_dotprod; + } + vpx_mse16x16 = vpx_mse16x16_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_mse16x16 = vpx_mse16x16_neon_dotprod; + vpx_mse16x8 = vpx_mse16x8_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_mse16x8 = vpx_mse16x8_neon_dotprod; + vpx_mse8x16 = vpx_mse8x16_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_mse8x16 = vpx_mse8x16_neon_dotprod; + vpx_mse8x8 = vpx_mse8x8_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_mse8x8 = vpx_mse8x8_neon_dotprod; + vpx_sad16x16 = vpx_sad16x16_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad16x16 = vpx_sad16x16_neon_dotprod; + vpx_sad16x16_avg = vpx_sad16x16_avg_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad16x16_avg = vpx_sad16x16_avg_neon_dotprod; + vpx_sad16x16x4d = vpx_sad16x16x4d_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad16x16x4d = vpx_sad16x16x4d_neon_dotprod; + vpx_sad16x32 = vpx_sad16x32_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad16x32 = vpx_sad16x32_neon_dotprod; + vpx_sad16x32_avg = vpx_sad16x32_avg_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad16x32_avg = vpx_sad16x32_avg_neon_dotprod; + vpx_sad16x32x4d = vpx_sad16x32x4d_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad16x32x4d = vpx_sad16x32x4d_neon_dotprod; + vpx_sad16x8 = vpx_sad16x8_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad16x8 = vpx_sad16x8_neon_dotprod; + vpx_sad16x8_avg = vpx_sad16x8_avg_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad16x8_avg = vpx_sad16x8_avg_neon_dotprod; + vpx_sad16x8x4d = vpx_sad16x8x4d_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad16x8x4d = vpx_sad16x8x4d_neon_dotprod; + vpx_sad32x16 = vpx_sad32x16_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad32x16 = vpx_sad32x16_neon_dotprod; + vpx_sad32x16_avg = vpx_sad32x16_avg_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad32x16_avg = vpx_sad32x16_avg_neon_dotprod; + vpx_sad32x16x4d = vpx_sad32x16x4d_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad32x16x4d = vpx_sad32x16x4d_neon_dotprod; + vpx_sad32x32 = vpx_sad32x32_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad32x32 = vpx_sad32x32_neon_dotprod; + vpx_sad32x32_avg = vpx_sad32x32_avg_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad32x32_avg = vpx_sad32x32_avg_neon_dotprod; + vpx_sad32x32x4d = vpx_sad32x32x4d_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad32x32x4d = vpx_sad32x32x4d_neon_dotprod; + vpx_sad32x64 = vpx_sad32x64_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad32x64 = vpx_sad32x64_neon_dotprod; + vpx_sad32x64_avg = vpx_sad32x64_avg_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad32x64_avg = vpx_sad32x64_avg_neon_dotprod; + vpx_sad32x64x4d = vpx_sad32x64x4d_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad32x64x4d = vpx_sad32x64x4d_neon_dotprod; + vpx_sad64x32 = vpx_sad64x32_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad64x32 = vpx_sad64x32_neon_dotprod; + vpx_sad64x32_avg = vpx_sad64x32_avg_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad64x32_avg = vpx_sad64x32_avg_neon_dotprod; + vpx_sad64x32x4d = vpx_sad64x32x4d_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad64x32x4d = vpx_sad64x32x4d_neon_dotprod; + vpx_sad64x64 = vpx_sad64x64_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad64x64 = vpx_sad64x64_neon_dotprod; + vpx_sad64x64_avg = vpx_sad64x64_avg_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad64x64_avg = vpx_sad64x64_avg_neon_dotprod; + vpx_sad64x64x4d = vpx_sad64x64x4d_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad64x64x4d = vpx_sad64x64x4d_neon_dotprod; + vpx_sad_skip_16x16 = vpx_sad_skip_16x16_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad_skip_16x16 = vpx_sad_skip_16x16_neon_dotprod; + vpx_sad_skip_16x16x4d = vpx_sad_skip_16x16x4d_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad_skip_16x16x4d = vpx_sad_skip_16x16x4d_neon_dotprod; + vpx_sad_skip_16x32 = vpx_sad_skip_16x32_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad_skip_16x32 = vpx_sad_skip_16x32_neon_dotprod; + vpx_sad_skip_16x32x4d = vpx_sad_skip_16x32x4d_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad_skip_16x32x4d = vpx_sad_skip_16x32x4d_neon_dotprod; + vpx_sad_skip_16x8 = vpx_sad_skip_16x8_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad_skip_16x8 = vpx_sad_skip_16x8_neon_dotprod; + vpx_sad_skip_16x8x4d = vpx_sad_skip_16x8x4d_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad_skip_16x8x4d = vpx_sad_skip_16x8x4d_neon_dotprod; + vpx_sad_skip_32x16 = vpx_sad_skip_32x16_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad_skip_32x16 = vpx_sad_skip_32x16_neon_dotprod; + vpx_sad_skip_32x16x4d = vpx_sad_skip_32x16x4d_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad_skip_32x16x4d = vpx_sad_skip_32x16x4d_neon_dotprod; + vpx_sad_skip_32x32 = vpx_sad_skip_32x32_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad_skip_32x32 = vpx_sad_skip_32x32_neon_dotprod; + vpx_sad_skip_32x32x4d = vpx_sad_skip_32x32x4d_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad_skip_32x32x4d = vpx_sad_skip_32x32x4d_neon_dotprod; + vpx_sad_skip_32x64 = vpx_sad_skip_32x64_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad_skip_32x64 = vpx_sad_skip_32x64_neon_dotprod; + vpx_sad_skip_32x64x4d = vpx_sad_skip_32x64x4d_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad_skip_32x64x4d = vpx_sad_skip_32x64x4d_neon_dotprod; + vpx_sad_skip_64x32 = vpx_sad_skip_64x32_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad_skip_64x32 = vpx_sad_skip_64x32_neon_dotprod; + vpx_sad_skip_64x32x4d = vpx_sad_skip_64x32x4d_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad_skip_64x32x4d = vpx_sad_skip_64x32x4d_neon_dotprod; + vpx_sad_skip_64x64 = vpx_sad_skip_64x64_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad_skip_64x64 = vpx_sad_skip_64x64_neon_dotprod; + vpx_sad_skip_64x64x4d = vpx_sad_skip_64x64x4d_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_sad_skip_64x64x4d = vpx_sad_skip_64x64x4d_neon_dotprod; + vpx_sse = vpx_sse_neon; + if (flags & HAS_NEON_DOTPROD) { + vpx_sse = vpx_sse_neon_dotprod; + } + vpx_variance16x16 = vpx_variance16x16_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_variance16x16 = vpx_variance16x16_neon_dotprod; + vpx_variance16x32 = vpx_variance16x32_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_variance16x32 = vpx_variance16x32_neon_dotprod; + vpx_variance16x8 = vpx_variance16x8_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_variance16x8 = vpx_variance16x8_neon_dotprod; + vpx_variance32x16 = vpx_variance32x16_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_variance32x16 = vpx_variance32x16_neon_dotprod; + vpx_variance32x32 = vpx_variance32x32_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_variance32x32 = vpx_variance32x32_neon_dotprod; + vpx_variance32x64 = vpx_variance32x64_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_variance32x64 = vpx_variance32x64_neon_dotprod; + vpx_variance4x4 = vpx_variance4x4_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_variance4x4 = vpx_variance4x4_neon_dotprod; + vpx_variance4x8 = vpx_variance4x8_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_variance4x8 = vpx_variance4x8_neon_dotprod; + vpx_variance64x32 = vpx_variance64x32_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_variance64x32 = vpx_variance64x32_neon_dotprod; + vpx_variance64x64 = vpx_variance64x64_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_variance64x64 = vpx_variance64x64_neon_dotprod; + vpx_variance8x16 = vpx_variance8x16_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_variance8x16 = vpx_variance8x16_neon_dotprod; + vpx_variance8x4 = vpx_variance8x4_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_variance8x4 = vpx_variance8x4_neon_dotprod; + vpx_variance8x8 = vpx_variance8x8_neon; + if (flags & HAS_NEON_DOTPROD) + vpx_variance8x8 = vpx_variance8x8_neon_dotprod; } #endif diff --git a/libvpx/source/config/win/arm64/vpx_scale_rtcd.h b/libvpx/source/config/win/arm64-highbd/vpx_scale_rtcd.h old mode 100644 new mode 100755 similarity index 100% rename from libvpx/source/config/win/arm64/vpx_scale_rtcd.h rename to libvpx/source/config/win/arm64-highbd/vpx_scale_rtcd.h diff --git a/libvpx/source/config/win/ia32/vp8_rtcd.h b/libvpx/source/config/win/ia32/vp8_rtcd.h old mode 100644 new mode 100755 index e8b8a0e7250bf32663e159de6138aad36bb8017b..36216770a1e8342a0902cad35d35cfeb3bc6b8bf --- a/libvpx/source/config/win/ia32/vp8_rtcd.h +++ b/libvpx/source/config/win/ia32/vp8_rtcd.h @@ -105,36 +105,6 @@ RTCD_EXTERN void (*vp8_bilinear_predict8x8)(unsigned char* src_ptr, unsigned char* dst_ptr, int dst_pitch); -void vp8_blend_b_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_b vp8_blend_b_c - -void vp8_blend_mb_inner_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_inner vp8_blend_mb_inner_c - -void vp8_blend_mb_outer_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_outer vp8_blend_mb_outer_c - int vp8_block_error_c(short* coeff, short* dqcoeff); int vp8_block_error_sse2(short* coeff, short* dqcoeff); #define vp8_block_error vp8_block_error_sse2 diff --git a/libvpx/source/config/win/ia32/vp9_rtcd.h b/libvpx/source/config/win/ia32/vp9_rtcd.h old mode 100644 new mode 100755 index e9e663f801f7a9b6a2167e0c68203c61bde927e0..7771ee3e1a90d32eff2728e1237abe44bdd442f7 --- a/libvpx/source/config/win/ia32/vp9_rtcd.h +++ b/libvpx/source/config/win/ia32/vp9_rtcd.h @@ -21,7 +21,9 @@ struct macroblockd; /* Encoder forward decls */ struct macroblock; -struct vp9_variance_vtable; +struct macroblock_plane; +struct vp9_sad_table; +struct ScanOrder; struct search_site_config; struct mv; union int_mv; @@ -89,29 +91,9 @@ int vp9_diamond_search_sad_c(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); -int vp9_diamond_search_sad_avx(const struct macroblock* x, - const struct search_site_config* cfg, - struct mv* ref_mv, - uint32_t start_mv_sad, - struct mv* best_mv, - int search_param, - int sad_per_bit, - int* num00, - const struct vp9_variance_vtable* fn_ptr, - const struct mv* center_mv); -RTCD_EXTERN int (*vp9_diamond_search_sad)( - const struct macroblock* x, - const struct search_site_config* cfg, - struct mv* ref_mv, - uint32_t start_mv_sad, - struct mv* best_mv, - int search_param, - int sad_per_bit, - int* num00, - const struct vp9_variance_vtable* fn_ptr, - const struct mv* center_mv); +#define vp9_diamond_search_sad vp9_diamond_search_sad_c void vp9_fht16x16_c(const int16_t* input, tran_low_t* output, @@ -278,65 +260,57 @@ void vp9_highbd_post_proc_down_and_across_c(const uint16_t* src_ptr, void vp9_highbd_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_highbd_quantize_fp_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_highbd_quantize_fp)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); - -void vp9_highbd_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -void vp9_highbd_quantize_fp_32x32_avx2(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_highbd_quantize_fp_32x32)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_highbd_quantize_fp)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); + +void vp9_highbd_quantize_fp_32x32_c( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); +void vp9_highbd_quantize_fp_32x32_avx2( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_highbd_quantize_fp_32x32)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vp9_highbd_temporal_filter_apply_c(const uint8_t* frame1, unsigned int stride, @@ -382,95 +356,79 @@ void vp9_iht8x8_64_add_sse2(const tran_low_t* input, void vp9_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_sse2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_ssse3(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_quantize_fp)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_quantize_fp)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_ssse3(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_quantize_fp_32x32)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_quantize_fp_32x32)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vp9_scale_and_extend_frame_c(const struct yv12_buffer_config* src, struct yv12_buffer_config* dst, @@ -501,9 +459,6 @@ static void setup_rtcd_internal(void) { vp9_block_error_fp = vp9_block_error_fp_sse2; if (flags & HAS_AVX2) vp9_block_error_fp = vp9_block_error_fp_avx2; - vp9_diamond_search_sad = vp9_diamond_search_sad_c; - if (flags & HAS_AVX) - vp9_diamond_search_sad = vp9_diamond_search_sad_avx; vp9_highbd_iht16x16_256_add = vp9_highbd_iht16x16_256_add_c; if (flags & HAS_SSE4_1) vp9_highbd_iht16x16_256_add = vp9_highbd_iht16x16_256_add_sse4_1; diff --git a/libvpx/source/config/win/ia32/vpx_config.asm b/libvpx/source/config/win/ia32/vpx_config.asm old mode 100644 new mode 100755 index d74fa3d216f5a80618c67a94c0b614309d68f90c..25dfcff92493364956ce97f18bd36f1f36042db0 --- a/libvpx/source/config/win/ia32/vpx_config.asm +++ b/libvpx/source/config/win/ia32/vpx_config.asm @@ -1,5 +1,7 @@ %define VPX_ARCH_ARM 0 %define ARCH_ARM 0 +%define VPX_ARCH_AARCH64 0 +%define ARCH_AARCH64 0 %define VPX_ARCH_MIPS 0 %define ARCH_MIPS 0 %define VPX_ARCH_X86 1 @@ -10,8 +12,12 @@ %define ARCH_PPC 0 %define VPX_ARCH_LOONGARCH 0 %define ARCH_LOONGARCH 0 -%define HAVE_NEON 0 %define HAVE_NEON_ASM 0 +%define HAVE_NEON 0 +%define HAVE_NEON_DOTPROD 0 +%define HAVE_NEON_I8MM 0 +%define HAVE_SVE 0 +%define HAVE_SVE2 0 %define HAVE_MIPS32 0 %define HAVE_DSPR2 0 %define HAVE_MSA 0 diff --git a/libvpx/source/config/win/ia32/vpx_config.c b/libvpx/source/config/win/ia32/vpx_config.c old mode 100644 new mode 100755 diff --git a/libvpx/source/config/win/ia32/vpx_config.h b/libvpx/source/config/win/ia32/vpx_config.h old mode 100644 new mode 100755 index 6a64f0958549a5755ea981b7a7171279c09cbfbb..ec2b1def3534d5145f64bf9e485496769ed4b2b4 --- a/libvpx/source/config/win/ia32/vpx_config.h +++ b/libvpx/source/config/win/ia32/vpx_config.h @@ -12,6 +12,8 @@ #define INLINE __inline #define VPX_ARCH_ARM 0 #define ARCH_ARM 0 +#define VPX_ARCH_AARCH64 0 +#define ARCH_AARCH64 0 #define VPX_ARCH_MIPS 0 #define ARCH_MIPS 0 #define VPX_ARCH_X86 1 @@ -22,8 +24,12 @@ #define ARCH_PPC 0 #define VPX_ARCH_LOONGARCH 0 #define ARCH_LOONGARCH 0 -#define HAVE_NEON 0 #define HAVE_NEON_ASM 0 +#define HAVE_NEON 0 +#define HAVE_NEON_DOTPROD 0 +#define HAVE_NEON_I8MM 0 +#define HAVE_SVE 0 +#define HAVE_SVE2 0 #define HAVE_MIPS32 0 #define HAVE_DSPR2 0 #define HAVE_MSA 0 diff --git a/libvpx/source/config/win/ia32/vpx_dsp_rtcd.h b/libvpx/source/config/win/ia32/vpx_dsp_rtcd.h old mode 100644 new mode 100755 index f42c6864f47f2a27103b93990f7d5ac87239fcf5..677a8fe4877928026d7be8e0a1a4af0f163def33 --- a/libvpx/source/config/win/ia32/vpx_dsp_rtcd.h +++ b/libvpx/source/config/win/ia32/vpx_dsp_rtcd.h @@ -44,7 +44,18 @@ void vpx_comp_avg_pred_sse2(uint8_t* comp_pred, int height, const uint8_t* ref, int ref_stride); -#define vpx_comp_avg_pred vpx_comp_avg_pred_sse2 +void vpx_comp_avg_pred_avx2(uint8_t* comp_pred, + const uint8_t* pred, + int width, + int height, + const uint8_t* ref, + int ref_stride); +RTCD_EXTERN void (*vpx_comp_avg_pred)(uint8_t* comp_pred, + const uint8_t* pred, + int width, + int height, + const uint8_t* ref, + int ref_stride); void vpx_convolve8_c(const uint8_t* src, ptrdiff_t src_stride, @@ -4432,52 +4443,37 @@ void vpx_highbd_minmax_8x8_c(const uint8_t* s8, void vpx_highbd_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_highbd_quantize_b_sse2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_highbd_quantize_b_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vpx_highbd_quantize_b)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vpx_highbd_quantize_b)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vpx_highbd_quantize_b_32x32_c( const tran_low_t* coeff_ptr, @@ -5136,10 +5132,435 @@ void vpx_highbd_sad8x8x4d_sse2(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_highbd_sad8x8x4d vpx_highbd_sad8x8x4d_sse2 +unsigned int vpx_highbd_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x16_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x16x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_16x16x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_16x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_16x32x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x8_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x8x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_16x8x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x16_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x16x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_32x16x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_32x32x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x64_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x64_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x64x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x64x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_32x64x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_4x4 vpx_highbd_sad_skip_4x4_c + +void vpx_highbd_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_4x4x4d vpx_highbd_sad_skip_4x4x4d_c + +unsigned int vpx_highbd_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_4x8 vpx_highbd_sad_skip_4x8_c + +void vpx_highbd_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_4x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_4x8x4d vpx_highbd_sad_skip_4x8x4d_sse2 + +unsigned int vpx_highbd_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_64x32x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x64_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x64_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x64x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x64x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_64x64x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_8x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x16 vpx_highbd_sad_skip_8x16_sse2 + +void vpx_highbd_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_8x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x16x4d vpx_highbd_sad_skip_8x16x4d_sse2 + +unsigned int vpx_highbd_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x4 vpx_highbd_sad_skip_8x4_c + +void vpx_highbd_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x4x4d vpx_highbd_sad_skip_8x4x4d_c + +unsigned int vpx_highbd_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_8x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x8 vpx_highbd_sad_skip_8x8_sse2 + +void vpx_highbd_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_8x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x8x4d vpx_highbd_sad_skip_8x8x4d_sse2 + int vpx_highbd_satd_c(const tran_low_t* coeff, int length); int vpx_highbd_satd_avx2(const tran_low_t* coeff, int length); RTCD_EXTERN int (*vpx_highbd_satd)(const tran_low_t* coeff, int length); +int64_t vpx_highbd_sse_c(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +int64_t vpx_highbd_sse_sse4_1(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +int64_t vpx_highbd_sse_avx2(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +RTCD_EXTERN int64_t (*vpx_highbd_sse)(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); + void vpx_highbd_subtract_block_c(int rows, int cols, int16_t* diff_ptr, @@ -5282,7 +5703,12 @@ void vpx_idct16x16_256_add_c(const tran_low_t* input, void vpx_idct16x16_256_add_sse2(const tran_low_t* input, uint8_t* dest, int stride); -#define vpx_idct16x16_256_add vpx_idct16x16_256_add_sse2 +void vpx_idct16x16_256_add_avx2(const tran_low_t* input, + uint8_t* dest, + int stride); +RTCD_EXTERN void (*vpx_idct16x16_256_add)(const tran_low_t* input, + uint8_t* dest, + int stride); void vpx_idct16x16_38_add_c(const tran_low_t* input, uint8_t* dest, int stride); void vpx_idct16x16_38_add_sse2(const tran_low_t* input, @@ -5296,7 +5722,12 @@ void vpx_idct32x32_1024_add_c(const tran_low_t* input, void vpx_idct32x32_1024_add_sse2(const tran_low_t* input, uint8_t* dest, int stride); -#define vpx_idct32x32_1024_add vpx_idct32x32_1024_add_sse2 +void vpx_idct32x32_1024_add_avx2(const tran_low_t* input, + uint8_t* dest, + int stride); +RTCD_EXTERN void (*vpx_idct32x32_1024_add)(const tran_low_t* input, + uint8_t* dest, + int stride); void vpx_idct32x32_135_add_c(const tran_low_t* input, uint8_t* dest, @@ -5307,6 +5738,9 @@ void vpx_idct32x32_135_add_sse2(const tran_low_t* input, void vpx_idct32x32_135_add_ssse3(const tran_low_t* input, uint8_t* dest, int stride); +void vpx_idct32x32_135_add_avx2(const tran_low_t* input, + uint8_t* dest, + int stride); RTCD_EXTERN void (*vpx_idct32x32_135_add)(const tran_low_t* input, uint8_t* dest, int stride); @@ -5707,76 +6141,53 @@ void vpx_post_proc_down_and_across_mb_row_sse2(unsigned char* src, void vpx_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_sse2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_ssse3(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_avx(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vpx_quantize_b)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vpx_quantize_b)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vpx_quantize_b_32x32_c(const tran_low_t* coeff_ptr, const struct macroblock_plane* const mb_plane, @@ -6355,24 +6766,372 @@ void vpx_sad8x8x4d_sse2(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_sad8x8x4d vpx_sad8x8x4d_sse2 -int vpx_satd_c(const tran_low_t* coeff, int length); -int vpx_satd_sse2(const tran_low_t* coeff, int length); -int vpx_satd_avx2(const tran_low_t* coeff, int length); -RTCD_EXTERN int (*vpx_satd)(const tran_low_t* coeff, int length); +unsigned int vpx_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x16 vpx_sad_skip_16x16_sse2 -void vpx_scaled_2d_c(const uint8_t* src, - ptrdiff_t src_stride, - uint8_t* dst, - ptrdiff_t dst_stride, - const InterpKernel* filter, - int x0_q4, - int x_step_q4, - int y0_q4, - int y_step_q4, - int w, - int h); -void vpx_scaled_2d_ssse3(const uint8_t* src, - ptrdiff_t src_stride, +void vpx_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x16x4d vpx_sad_skip_16x16x4d_sse2 + +unsigned int vpx_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x32 vpx_sad_skip_16x32_sse2 + +void vpx_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x32x4d vpx_sad_skip_16x32x4d_sse2 + +unsigned int vpx_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x8 vpx_sad_skip_16x8_sse2 + +void vpx_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x8x4d vpx_sad_skip_16x8x4d_sse2 + +unsigned int vpx_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x16_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x16x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x16x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x64_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x64_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x64x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x64x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x4 vpx_sad_skip_4x4_c + +void vpx_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x4x4d vpx_sad_skip_4x4x4d_c + +unsigned int vpx_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_4x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x8 vpx_sad_skip_4x8_sse2 + +void vpx_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_4x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x8x4d vpx_sad_skip_4x8x4d_sse2 + +unsigned int vpx_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_64x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x64_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x64_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x64x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x64x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_64x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x16 vpx_sad_skip_8x16_sse2 + +void vpx_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x16x4d vpx_sad_skip_8x16x4d_sse2 + +unsigned int vpx_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x4 vpx_sad_skip_8x4_c + +void vpx_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x4x4d vpx_sad_skip_8x4x4d_c + +unsigned int vpx_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x8 vpx_sad_skip_8x8_sse2 + +void vpx_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x8x4d vpx_sad_skip_8x8x4d_sse2 + +int vpx_satd_c(const tran_low_t* coeff, int length); +int vpx_satd_sse2(const tran_low_t* coeff, int length); +int vpx_satd_avx2(const tran_low_t* coeff, int length); +RTCD_EXTERN int (*vpx_satd)(const tran_low_t* coeff, int length); + +void vpx_scaled_2d_c(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_scaled_2d_ssse3(const uint8_t* src, + ptrdiff_t src_stride, uint8_t* dst, ptrdiff_t dst_stride, const InterpKernel* filter, @@ -6459,6 +7218,31 @@ void vpx_scaled_vert_c(const uint8_t* src, int h); #define vpx_scaled_vert vpx_scaled_vert_c +int64_t vpx_sse_c(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +int64_t vpx_sse_sse4_1(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +int64_t vpx_sse_avx2(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +RTCD_EXTERN int64_t (*vpx_sse)(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); + uint32_t vpx_sub_pixel_avg_variance16x16_c(const uint8_t* src_ptr, int src_stride, int x_offset, @@ -7699,6 +8483,9 @@ static void setup_rtcd_internal(void) { (void)flags; + vpx_comp_avg_pred = vpx_comp_avg_pred_sse2; + if (flags & HAS_AVX2) + vpx_comp_avg_pred = vpx_comp_avg_pred_avx2; vpx_convolve8 = vpx_convolve8_sse2; if (flags & HAS_SSSE3) vpx_convolve8 = vpx_convolve8_ssse3; @@ -7972,15 +8759,78 @@ static void setup_rtcd_internal(void) { vpx_highbd_sad64x64x4d = vpx_highbd_sad64x64x4d_sse2; if (flags & HAS_AVX2) vpx_highbd_sad64x64x4d = vpx_highbd_sad64x64x4d_avx2; + vpx_highbd_sad_skip_16x16 = vpx_highbd_sad_skip_16x16_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x16 = vpx_highbd_sad_skip_16x16_avx2; + vpx_highbd_sad_skip_16x16x4d = vpx_highbd_sad_skip_16x16x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x16x4d = vpx_highbd_sad_skip_16x16x4d_avx2; + vpx_highbd_sad_skip_16x32 = vpx_highbd_sad_skip_16x32_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x32 = vpx_highbd_sad_skip_16x32_avx2; + vpx_highbd_sad_skip_16x32x4d = vpx_highbd_sad_skip_16x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x32x4d = vpx_highbd_sad_skip_16x32x4d_avx2; + vpx_highbd_sad_skip_16x8 = vpx_highbd_sad_skip_16x8_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x8 = vpx_highbd_sad_skip_16x8_avx2; + vpx_highbd_sad_skip_16x8x4d = vpx_highbd_sad_skip_16x8x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x8x4d = vpx_highbd_sad_skip_16x8x4d_avx2; + vpx_highbd_sad_skip_32x16 = vpx_highbd_sad_skip_32x16_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x16 = vpx_highbd_sad_skip_32x16_avx2; + vpx_highbd_sad_skip_32x16x4d = vpx_highbd_sad_skip_32x16x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x16x4d = vpx_highbd_sad_skip_32x16x4d_avx2; + vpx_highbd_sad_skip_32x32 = vpx_highbd_sad_skip_32x32_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x32 = vpx_highbd_sad_skip_32x32_avx2; + vpx_highbd_sad_skip_32x32x4d = vpx_highbd_sad_skip_32x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x32x4d = vpx_highbd_sad_skip_32x32x4d_avx2; + vpx_highbd_sad_skip_32x64 = vpx_highbd_sad_skip_32x64_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x64 = vpx_highbd_sad_skip_32x64_avx2; + vpx_highbd_sad_skip_32x64x4d = vpx_highbd_sad_skip_32x64x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x64x4d = vpx_highbd_sad_skip_32x64x4d_avx2; + vpx_highbd_sad_skip_64x32 = vpx_highbd_sad_skip_64x32_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_64x32 = vpx_highbd_sad_skip_64x32_avx2; + vpx_highbd_sad_skip_64x32x4d = vpx_highbd_sad_skip_64x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_64x32x4d = vpx_highbd_sad_skip_64x32x4d_avx2; + vpx_highbd_sad_skip_64x64 = vpx_highbd_sad_skip_64x64_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_64x64 = vpx_highbd_sad_skip_64x64_avx2; + vpx_highbd_sad_skip_64x64x4d = vpx_highbd_sad_skip_64x64x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_64x64x4d = vpx_highbd_sad_skip_64x64x4d_avx2; vpx_highbd_satd = vpx_highbd_satd_c; if (flags & HAS_AVX2) vpx_highbd_satd = vpx_highbd_satd_avx2; + vpx_highbd_sse = vpx_highbd_sse_c; + if (flags & HAS_SSE4_1) { + vpx_highbd_sse = vpx_highbd_sse_sse4_1; + } + if (flags & HAS_AVX2) { + vpx_highbd_sse = vpx_highbd_sse_avx2; + } vpx_highbd_subtract_block = vpx_highbd_subtract_block_c; if (flags & HAS_AVX2) vpx_highbd_subtract_block = vpx_highbd_subtract_block_avx2; + vpx_idct16x16_256_add = vpx_idct16x16_256_add_sse2; + if (flags & HAS_AVX2) + vpx_idct16x16_256_add = vpx_idct16x16_256_add_avx2; + vpx_idct32x32_1024_add = vpx_idct32x32_1024_add_sse2; + if (flags & HAS_AVX2) + vpx_idct32x32_1024_add = vpx_idct32x32_1024_add_avx2; vpx_idct32x32_135_add = vpx_idct32x32_135_add_sse2; if (flags & HAS_SSSE3) vpx_idct32x32_135_add = vpx_idct32x32_135_add_ssse3; + if (flags & HAS_AVX2) + vpx_idct32x32_135_add = vpx_idct32x32_135_add_avx2; vpx_idct32x32_34_add = vpx_idct32x32_34_add_sse2; if (flags & HAS_SSSE3) vpx_idct32x32_34_add = vpx_idct32x32_34_add_ssse3; @@ -8049,12 +8899,49 @@ static void setup_rtcd_internal(void) { vpx_sad64x64x4d = vpx_sad64x64x4d_sse2; if (flags & HAS_AVX2) vpx_sad64x64x4d = vpx_sad64x64x4d_avx2; + vpx_sad_skip_32x16 = vpx_sad_skip_32x16_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x16 = vpx_sad_skip_32x16_avx2; + vpx_sad_skip_32x16x4d = vpx_sad_skip_32x16x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x16x4d = vpx_sad_skip_32x16x4d_avx2; + vpx_sad_skip_32x32 = vpx_sad_skip_32x32_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x32 = vpx_sad_skip_32x32_avx2; + vpx_sad_skip_32x32x4d = vpx_sad_skip_32x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x32x4d = vpx_sad_skip_32x32x4d_avx2; + vpx_sad_skip_32x64 = vpx_sad_skip_32x64_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x64 = vpx_sad_skip_32x64_avx2; + vpx_sad_skip_32x64x4d = vpx_sad_skip_32x64x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x64x4d = vpx_sad_skip_32x64x4d_avx2; + vpx_sad_skip_64x32 = vpx_sad_skip_64x32_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_64x32 = vpx_sad_skip_64x32_avx2; + vpx_sad_skip_64x32x4d = vpx_sad_skip_64x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_64x32x4d = vpx_sad_skip_64x32x4d_avx2; + vpx_sad_skip_64x64 = vpx_sad_skip_64x64_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_64x64 = vpx_sad_skip_64x64_avx2; + vpx_sad_skip_64x64x4d = vpx_sad_skip_64x64x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_64x64x4d = vpx_sad_skip_64x64x4d_avx2; vpx_satd = vpx_satd_sse2; if (flags & HAS_AVX2) vpx_satd = vpx_satd_avx2; vpx_scaled_2d = vpx_scaled_2d_c; if (flags & HAS_SSSE3) vpx_scaled_2d = vpx_scaled_2d_ssse3; + vpx_sse = vpx_sse_c; + if (flags & HAS_SSE4_1) { + vpx_sse = vpx_sse_sse4_1; + } + if (flags & HAS_AVX2) { + vpx_sse = vpx_sse_avx2; + } vpx_sub_pixel_avg_variance16x16 = vpx_sub_pixel_avg_variance16x16_sse2; if (flags & HAS_SSSE3) vpx_sub_pixel_avg_variance16x16 = vpx_sub_pixel_avg_variance16x16_ssse3; diff --git a/libvpx/source/config/win/ia32/vpx_scale_rtcd.h b/libvpx/source/config/win/ia32/vpx_scale_rtcd.h old mode 100644 new mode 100755 diff --git a/libvpx/source/config/win/x64/vp8_rtcd.h b/libvpx/source/config/win/x64/vp8_rtcd.h old mode 100644 new mode 100755 index e8b8a0e7250bf32663e159de6138aad36bb8017b..36216770a1e8342a0902cad35d35cfeb3bc6b8bf --- a/libvpx/source/config/win/x64/vp8_rtcd.h +++ b/libvpx/source/config/win/x64/vp8_rtcd.h @@ -105,36 +105,6 @@ RTCD_EXTERN void (*vp8_bilinear_predict8x8)(unsigned char* src_ptr, unsigned char* dst_ptr, int dst_pitch); -void vp8_blend_b_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_b vp8_blend_b_c - -void vp8_blend_mb_inner_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_inner vp8_blend_mb_inner_c - -void vp8_blend_mb_outer_c(unsigned char* y, - unsigned char* u, - unsigned char* v, - int y_1, - int u_1, - int v_1, - int alpha, - int stride); -#define vp8_blend_mb_outer vp8_blend_mb_outer_c - int vp8_block_error_c(short* coeff, short* dqcoeff); int vp8_block_error_sse2(short* coeff, short* dqcoeff); #define vp8_block_error vp8_block_error_sse2 diff --git a/libvpx/source/config/win/x64/vp9_rtcd.h b/libvpx/source/config/win/x64/vp9_rtcd.h old mode 100644 new mode 100755 index e9e663f801f7a9b6a2167e0c68203c61bde927e0..7771ee3e1a90d32eff2728e1237abe44bdd442f7 --- a/libvpx/source/config/win/x64/vp9_rtcd.h +++ b/libvpx/source/config/win/x64/vp9_rtcd.h @@ -21,7 +21,9 @@ struct macroblockd; /* Encoder forward decls */ struct macroblock; -struct vp9_variance_vtable; +struct macroblock_plane; +struct vp9_sad_table; +struct ScanOrder; struct search_site_config; struct mv; union int_mv; @@ -89,29 +91,9 @@ int vp9_diamond_search_sad_c(const struct macroblock* x, int search_param, int sad_per_bit, int* num00, - const struct vp9_variance_vtable* fn_ptr, + const struct vp9_sad_table* sad_fn_ptr, const struct mv* center_mv); -int vp9_diamond_search_sad_avx(const struct macroblock* x, - const struct search_site_config* cfg, - struct mv* ref_mv, - uint32_t start_mv_sad, - struct mv* best_mv, - int search_param, - int sad_per_bit, - int* num00, - const struct vp9_variance_vtable* fn_ptr, - const struct mv* center_mv); -RTCD_EXTERN int (*vp9_diamond_search_sad)( - const struct macroblock* x, - const struct search_site_config* cfg, - struct mv* ref_mv, - uint32_t start_mv_sad, - struct mv* best_mv, - int search_param, - int sad_per_bit, - int* num00, - const struct vp9_variance_vtable* fn_ptr, - const struct mv* center_mv); +#define vp9_diamond_search_sad vp9_diamond_search_sad_c void vp9_fht16x16_c(const int16_t* input, tran_low_t* output, @@ -278,65 +260,57 @@ void vp9_highbd_post_proc_down_and_across_c(const uint16_t* src_ptr, void vp9_highbd_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_highbd_quantize_fp_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_highbd_quantize_fp)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); - -void vp9_highbd_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -void vp9_highbd_quantize_fp_32x32_avx2(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_highbd_quantize_fp_32x32)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_highbd_quantize_fp)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); + +void vp9_highbd_quantize_fp_32x32_c( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); +void vp9_highbd_quantize_fp_32x32_avx2( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_highbd_quantize_fp_32x32)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vp9_highbd_temporal_filter_apply_c(const uint8_t* frame1, unsigned int stride, @@ -382,95 +356,79 @@ void vp9_iht8x8_64_add_sse2(const tran_low_t* input, void vp9_quantize_fp_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_sse2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_ssse3(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_quantize_fp)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_quantize_fp)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_ssse3(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vp9_quantize_fp_32x32_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vp9_quantize_fp_32x32)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* round_ptr, - const int16_t* quant_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vp9_quantize_fp_32x32)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vp9_scale_and_extend_frame_c(const struct yv12_buffer_config* src, struct yv12_buffer_config* dst, @@ -501,9 +459,6 @@ static void setup_rtcd_internal(void) { vp9_block_error_fp = vp9_block_error_fp_sse2; if (flags & HAS_AVX2) vp9_block_error_fp = vp9_block_error_fp_avx2; - vp9_diamond_search_sad = vp9_diamond_search_sad_c; - if (flags & HAS_AVX) - vp9_diamond_search_sad = vp9_diamond_search_sad_avx; vp9_highbd_iht16x16_256_add = vp9_highbd_iht16x16_256_add_c; if (flags & HAS_SSE4_1) vp9_highbd_iht16x16_256_add = vp9_highbd_iht16x16_256_add_sse4_1; diff --git a/libvpx/source/config/win/x64/vpx_config.asm b/libvpx/source/config/win/x64/vpx_config.asm old mode 100644 new mode 100755 index 3eb20d4c653a559db7c0e049da45038f05ad7fff..99b5f88a044dcd9aa69c29517af808185620f94d --- a/libvpx/source/config/win/x64/vpx_config.asm +++ b/libvpx/source/config/win/x64/vpx_config.asm @@ -1,5 +1,7 @@ %define VPX_ARCH_ARM 0 %define ARCH_ARM 0 +%define VPX_ARCH_AARCH64 0 +%define ARCH_AARCH64 0 %define VPX_ARCH_MIPS 0 %define ARCH_MIPS 0 %define VPX_ARCH_X86 0 @@ -10,8 +12,12 @@ %define ARCH_PPC 0 %define VPX_ARCH_LOONGARCH 0 %define ARCH_LOONGARCH 0 -%define HAVE_NEON 0 %define HAVE_NEON_ASM 0 +%define HAVE_NEON 0 +%define HAVE_NEON_DOTPROD 0 +%define HAVE_NEON_I8MM 0 +%define HAVE_SVE 0 +%define HAVE_SVE2 0 %define HAVE_MIPS32 0 %define HAVE_DSPR2 0 %define HAVE_MSA 0 diff --git a/libvpx/source/config/win/x64/vpx_config.c b/libvpx/source/config/win/x64/vpx_config.c old mode 100644 new mode 100755 diff --git a/libvpx/source/config/win/x64/vpx_config.h b/libvpx/source/config/win/x64/vpx_config.h old mode 100644 new mode 100755 index c4c21718e3aa4eef737ae1cc5ae6131422fa8d8d..7635be0551fa339ae841fe490f06b117fde3b478 --- a/libvpx/source/config/win/x64/vpx_config.h +++ b/libvpx/source/config/win/x64/vpx_config.h @@ -12,6 +12,8 @@ #define INLINE __inline #define VPX_ARCH_ARM 0 #define ARCH_ARM 0 +#define VPX_ARCH_AARCH64 0 +#define ARCH_AARCH64 0 #define VPX_ARCH_MIPS 0 #define ARCH_MIPS 0 #define VPX_ARCH_X86 0 @@ -22,8 +24,12 @@ #define ARCH_PPC 0 #define VPX_ARCH_LOONGARCH 0 #define ARCH_LOONGARCH 0 -#define HAVE_NEON 0 #define HAVE_NEON_ASM 0 +#define HAVE_NEON 0 +#define HAVE_NEON_DOTPROD 0 +#define HAVE_NEON_I8MM 0 +#define HAVE_SVE 0 +#define HAVE_SVE2 0 #define HAVE_MIPS32 0 #define HAVE_DSPR2 0 #define HAVE_MSA 0 diff --git a/libvpx/source/config/win/x64/vpx_dsp_rtcd.h b/libvpx/source/config/win/x64/vpx_dsp_rtcd.h old mode 100644 new mode 100755 index 907cab18d3ddab5c1e28a1f2cd90338c9ed52547..5dcdd93e0888dacd2a8521cd4a2f8fb3fbd45155 --- a/libvpx/source/config/win/x64/vpx_dsp_rtcd.h +++ b/libvpx/source/config/win/x64/vpx_dsp_rtcd.h @@ -44,7 +44,18 @@ void vpx_comp_avg_pred_sse2(uint8_t* comp_pred, int height, const uint8_t* ref, int ref_stride); -#define vpx_comp_avg_pred vpx_comp_avg_pred_sse2 +void vpx_comp_avg_pred_avx2(uint8_t* comp_pred, + const uint8_t* pred, + int width, + int height, + const uint8_t* ref, + int ref_stride); +RTCD_EXTERN void (*vpx_comp_avg_pred)(uint8_t* comp_pred, + const uint8_t* pred, + int width, + int height, + const uint8_t* ref, + int ref_stride); void vpx_convolve8_c(const uint8_t* src, ptrdiff_t src_stride, @@ -4509,52 +4520,37 @@ void vpx_highbd_minmax_8x8_c(const uint8_t* s8, void vpx_highbd_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_highbd_quantize_b_sse2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_highbd_quantize_b_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vpx_highbd_quantize_b)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vpx_highbd_quantize_b)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vpx_highbd_quantize_b_32x32_c( const tran_low_t* coeff_ptr, @@ -5213,10 +5209,435 @@ void vpx_highbd_sad8x8x4d_sse2(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_highbd_sad8x8x4d vpx_highbd_sad8x8x4d_sse2 +unsigned int vpx_highbd_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x16_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_16x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x16x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_16x16x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_16x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_16x32x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_16x8_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_16x8)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_16x8x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_16x8x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x16_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x16x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_32x16x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_32x32x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x64_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_32x64_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x64x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_32x64x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_32x64x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_4x4 vpx_highbd_sad_skip_4x4_c + +void vpx_highbd_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_4x4x4d vpx_highbd_sad_skip_4x4x4d_c + +unsigned int vpx_highbd_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_4x8 vpx_highbd_sad_skip_4x8_c + +void vpx_highbd_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_4x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_4x8x4d vpx_highbd_sad_skip_4x8x4d_sse2 + +unsigned int vpx_highbd_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_64x32x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x64_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_64x64_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_highbd_sad_skip_64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_highbd_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x64x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_64x64x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_highbd_sad_skip_64x64x4d)( + const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_highbd_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_8x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x16 vpx_highbd_sad_skip_8x16_sse2 + +void vpx_highbd_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_8x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x16x4d vpx_highbd_sad_skip_8x16x4d_sse2 + +unsigned int vpx_highbd_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x4 vpx_highbd_sad_skip_8x4_c + +void vpx_highbd_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x4x4d vpx_highbd_sad_skip_8x4x4d_c + +unsigned int vpx_highbd_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_highbd_sad_skip_8x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_highbd_sad_skip_8x8 vpx_highbd_sad_skip_8x8_sse2 + +void vpx_highbd_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_highbd_sad_skip_8x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_highbd_sad_skip_8x8x4d vpx_highbd_sad_skip_8x8x4d_sse2 + int vpx_highbd_satd_c(const tran_low_t* coeff, int length); int vpx_highbd_satd_avx2(const tran_low_t* coeff, int length); RTCD_EXTERN int (*vpx_highbd_satd)(const tran_low_t* coeff, int length); +int64_t vpx_highbd_sse_c(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +int64_t vpx_highbd_sse_sse4_1(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +int64_t vpx_highbd_sse_avx2(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); +RTCD_EXTERN int64_t (*vpx_highbd_sse)(const uint8_t* a8, + int a_stride, + const uint8_t* b8, + int b_stride, + int width, + int height); + void vpx_highbd_subtract_block_c(int rows, int cols, int16_t* diff_ptr, @@ -5359,7 +5780,12 @@ void vpx_idct16x16_256_add_c(const tran_low_t* input, void vpx_idct16x16_256_add_sse2(const tran_low_t* input, uint8_t* dest, int stride); -#define vpx_idct16x16_256_add vpx_idct16x16_256_add_sse2 +void vpx_idct16x16_256_add_avx2(const tran_low_t* input, + uint8_t* dest, + int stride); +RTCD_EXTERN void (*vpx_idct16x16_256_add)(const tran_low_t* input, + uint8_t* dest, + int stride); void vpx_idct16x16_38_add_c(const tran_low_t* input, uint8_t* dest, int stride); void vpx_idct16x16_38_add_sse2(const tran_low_t* input, @@ -5373,7 +5799,12 @@ void vpx_idct32x32_1024_add_c(const tran_low_t* input, void vpx_idct32x32_1024_add_sse2(const tran_low_t* input, uint8_t* dest, int stride); -#define vpx_idct32x32_1024_add vpx_idct32x32_1024_add_sse2 +void vpx_idct32x32_1024_add_avx2(const tran_low_t* input, + uint8_t* dest, + int stride); +RTCD_EXTERN void (*vpx_idct32x32_1024_add)(const tran_low_t* input, + uint8_t* dest, + int stride); void vpx_idct32x32_135_add_c(const tran_low_t* input, uint8_t* dest, @@ -5384,6 +5815,9 @@ void vpx_idct32x32_135_add_sse2(const tran_low_t* input, void vpx_idct32x32_135_add_ssse3(const tran_low_t* input, uint8_t* dest, int stride); +void vpx_idct32x32_135_add_avx2(const tran_low_t* input, + uint8_t* dest, + int stride); RTCD_EXTERN void (*vpx_idct32x32_135_add)(const tran_low_t* input, uint8_t* dest, int stride); @@ -5784,76 +6218,53 @@ void vpx_post_proc_down_and_across_mb_row_sse2(unsigned char* src, void vpx_quantize_b_c(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_sse2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_ssse3(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_avx(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); void vpx_quantize_b_avx2(const tran_low_t* coeff_ptr, intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, + const struct macroblock_plane* const mb_plane, tran_low_t* qcoeff_ptr, tran_low_t* dqcoeff_ptr, const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); -RTCD_EXTERN void (*vpx_quantize_b)(const tran_low_t* coeff_ptr, - intptr_t n_coeffs, - const int16_t* zbin_ptr, - const int16_t* round_ptr, - const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, - tran_low_t* qcoeff_ptr, - tran_low_t* dqcoeff_ptr, - const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan, - const int16_t* iscan); + const struct ScanOrder* const scan_order); +RTCD_EXTERN void (*vpx_quantize_b)( + const tran_low_t* coeff_ptr, + intptr_t n_coeffs, + const struct macroblock_plane* const mb_plane, + tran_low_t* qcoeff_ptr, + tran_low_t* dqcoeff_ptr, + const int16_t* dequant_ptr, + uint16_t* eob_ptr, + const struct ScanOrder* const scan_order); void vpx_quantize_b_32x32_c(const tran_low_t* coeff_ptr, const struct macroblock_plane* const mb_plane, @@ -6432,24 +6843,372 @@ void vpx_sad8x8x4d_sse2(const uint8_t* src_ptr, uint32_t sad_array[4]); #define vpx_sad8x8x4d vpx_sad8x8x4d_sse2 -int vpx_satd_c(const tran_low_t* coeff, int length); -int vpx_satd_sse2(const tran_low_t* coeff, int length); -int vpx_satd_avx2(const tran_low_t* coeff, int length); -RTCD_EXTERN int (*vpx_satd)(const tran_low_t* coeff, int length); +unsigned int vpx_sad_skip_16x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x16 vpx_sad_skip_16x16_sse2 -void vpx_scaled_2d_c(const uint8_t* src, - ptrdiff_t src_stride, - uint8_t* dst, - ptrdiff_t dst_stride, - const InterpKernel* filter, - int x0_q4, - int x_step_q4, - int y0_q4, - int y_step_q4, - int w, - int h); -void vpx_scaled_2d_ssse3(const uint8_t* src, - ptrdiff_t src_stride, +void vpx_sad_skip_16x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x16x4d vpx_sad_skip_16x16x4d_sse2 + +unsigned int vpx_sad_skip_16x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x32 vpx_sad_skip_16x32_sse2 + +void vpx_sad_skip_16x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x32x4d vpx_sad_skip_16x32x4d_sse2 + +unsigned int vpx_sad_skip_16x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_16x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_16x8 vpx_sad_skip_16x8_sse2 + +void vpx_sad_skip_16x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_16x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_16x8x4d vpx_sad_skip_16x8x4d_sse2 + +unsigned int vpx_sad_skip_32x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x16_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x16)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x16x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x16x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_32x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x64_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_32x64_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_32x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_32x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x64x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_32x64x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_32x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_4x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x4 vpx_sad_skip_4x4_c + +void vpx_sad_skip_4x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x4x4d vpx_sad_skip_4x4x4d_c + +unsigned int vpx_sad_skip_4x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_4x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_4x8 vpx_sad_skip_4x8_sse2 + +void vpx_sad_skip_4x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_4x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_4x8x4d vpx_sad_skip_4x8x4d_sse2 + +unsigned int vpx_sad_skip_64x32_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x32_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x32_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_64x32)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_64x32x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x32x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x32x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_64x32x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_64x64_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x64_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_64x64_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +RTCD_EXTERN unsigned int (*vpx_sad_skip_64x64)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); + +void vpx_sad_skip_64x64x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x64x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_64x64x4d_avx2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +RTCD_EXTERN void (*vpx_sad_skip_64x64x4d)(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); + +unsigned int vpx_sad_skip_8x16_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x16_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x16 vpx_sad_skip_8x16_sse2 + +void vpx_sad_skip_8x16x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x16x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x16x4d vpx_sad_skip_8x16x4d_sse2 + +unsigned int vpx_sad_skip_8x4_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x4 vpx_sad_skip_8x4_c + +void vpx_sad_skip_8x4x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x4x4d vpx_sad_skip_8x4x4d_c + +unsigned int vpx_sad_skip_8x8_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +unsigned int vpx_sad_skip_8x8_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* ref_ptr, + int ref_stride); +#define vpx_sad_skip_8x8 vpx_sad_skip_8x8_sse2 + +void vpx_sad_skip_8x8x4d_c(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +void vpx_sad_skip_8x8x4d_sse2(const uint8_t* src_ptr, + int src_stride, + const uint8_t* const ref_array[4], + int ref_stride, + uint32_t sad_array[4]); +#define vpx_sad_skip_8x8x4d vpx_sad_skip_8x8x4d_sse2 + +int vpx_satd_c(const tran_low_t* coeff, int length); +int vpx_satd_sse2(const tran_low_t* coeff, int length); +int vpx_satd_avx2(const tran_low_t* coeff, int length); +RTCD_EXTERN int (*vpx_satd)(const tran_low_t* coeff, int length); + +void vpx_scaled_2d_c(const uint8_t* src, + ptrdiff_t src_stride, + uint8_t* dst, + ptrdiff_t dst_stride, + const InterpKernel* filter, + int x0_q4, + int x_step_q4, + int y0_q4, + int y_step_q4, + int w, + int h); +void vpx_scaled_2d_ssse3(const uint8_t* src, + ptrdiff_t src_stride, uint8_t* dst, ptrdiff_t dst_stride, const InterpKernel* filter, @@ -6536,6 +7295,31 @@ void vpx_scaled_vert_c(const uint8_t* src, int h); #define vpx_scaled_vert vpx_scaled_vert_c +int64_t vpx_sse_c(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +int64_t vpx_sse_sse4_1(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +int64_t vpx_sse_avx2(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); +RTCD_EXTERN int64_t (*vpx_sse)(const uint8_t* src, + int src_stride, + const uint8_t* ref, + int ref_stride, + int width, + int height); + uint32_t vpx_sub_pixel_avg_variance16x16_c(const uint8_t* src_ptr, int src_stride, int x_offset, @@ -7776,6 +8560,9 @@ static void setup_rtcd_internal(void) { (void)flags; + vpx_comp_avg_pred = vpx_comp_avg_pred_sse2; + if (flags & HAS_AVX2) + vpx_comp_avg_pred = vpx_comp_avg_pred_avx2; vpx_convolve8 = vpx_convolve8_sse2; if (flags & HAS_SSSE3) vpx_convolve8 = vpx_convolve8_ssse3; @@ -8052,15 +8839,78 @@ static void setup_rtcd_internal(void) { vpx_highbd_sad64x64x4d = vpx_highbd_sad64x64x4d_sse2; if (flags & HAS_AVX2) vpx_highbd_sad64x64x4d = vpx_highbd_sad64x64x4d_avx2; + vpx_highbd_sad_skip_16x16 = vpx_highbd_sad_skip_16x16_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x16 = vpx_highbd_sad_skip_16x16_avx2; + vpx_highbd_sad_skip_16x16x4d = vpx_highbd_sad_skip_16x16x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x16x4d = vpx_highbd_sad_skip_16x16x4d_avx2; + vpx_highbd_sad_skip_16x32 = vpx_highbd_sad_skip_16x32_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x32 = vpx_highbd_sad_skip_16x32_avx2; + vpx_highbd_sad_skip_16x32x4d = vpx_highbd_sad_skip_16x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x32x4d = vpx_highbd_sad_skip_16x32x4d_avx2; + vpx_highbd_sad_skip_16x8 = vpx_highbd_sad_skip_16x8_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x8 = vpx_highbd_sad_skip_16x8_avx2; + vpx_highbd_sad_skip_16x8x4d = vpx_highbd_sad_skip_16x8x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_16x8x4d = vpx_highbd_sad_skip_16x8x4d_avx2; + vpx_highbd_sad_skip_32x16 = vpx_highbd_sad_skip_32x16_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x16 = vpx_highbd_sad_skip_32x16_avx2; + vpx_highbd_sad_skip_32x16x4d = vpx_highbd_sad_skip_32x16x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x16x4d = vpx_highbd_sad_skip_32x16x4d_avx2; + vpx_highbd_sad_skip_32x32 = vpx_highbd_sad_skip_32x32_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x32 = vpx_highbd_sad_skip_32x32_avx2; + vpx_highbd_sad_skip_32x32x4d = vpx_highbd_sad_skip_32x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x32x4d = vpx_highbd_sad_skip_32x32x4d_avx2; + vpx_highbd_sad_skip_32x64 = vpx_highbd_sad_skip_32x64_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x64 = vpx_highbd_sad_skip_32x64_avx2; + vpx_highbd_sad_skip_32x64x4d = vpx_highbd_sad_skip_32x64x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_32x64x4d = vpx_highbd_sad_skip_32x64x4d_avx2; + vpx_highbd_sad_skip_64x32 = vpx_highbd_sad_skip_64x32_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_64x32 = vpx_highbd_sad_skip_64x32_avx2; + vpx_highbd_sad_skip_64x32x4d = vpx_highbd_sad_skip_64x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_64x32x4d = vpx_highbd_sad_skip_64x32x4d_avx2; + vpx_highbd_sad_skip_64x64 = vpx_highbd_sad_skip_64x64_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_64x64 = vpx_highbd_sad_skip_64x64_avx2; + vpx_highbd_sad_skip_64x64x4d = vpx_highbd_sad_skip_64x64x4d_sse2; + if (flags & HAS_AVX2) + vpx_highbd_sad_skip_64x64x4d = vpx_highbd_sad_skip_64x64x4d_avx2; vpx_highbd_satd = vpx_highbd_satd_c; if (flags & HAS_AVX2) vpx_highbd_satd = vpx_highbd_satd_avx2; + vpx_highbd_sse = vpx_highbd_sse_c; + if (flags & HAS_SSE4_1) { + vpx_highbd_sse = vpx_highbd_sse_sse4_1; + } + if (flags & HAS_AVX2) { + vpx_highbd_sse = vpx_highbd_sse_avx2; + } vpx_highbd_subtract_block = vpx_highbd_subtract_block_c; if (flags & HAS_AVX2) vpx_highbd_subtract_block = vpx_highbd_subtract_block_avx2; + vpx_idct16x16_256_add = vpx_idct16x16_256_add_sse2; + if (flags & HAS_AVX2) + vpx_idct16x16_256_add = vpx_idct16x16_256_add_avx2; + vpx_idct32x32_1024_add = vpx_idct32x32_1024_add_sse2; + if (flags & HAS_AVX2) + vpx_idct32x32_1024_add = vpx_idct32x32_1024_add_avx2; vpx_idct32x32_135_add = vpx_idct32x32_135_add_sse2; if (flags & HAS_SSSE3) vpx_idct32x32_135_add = vpx_idct32x32_135_add_ssse3; + if (flags & HAS_AVX2) + vpx_idct32x32_135_add = vpx_idct32x32_135_add_avx2; vpx_idct32x32_34_add = vpx_idct32x32_34_add_sse2; if (flags & HAS_SSSE3) vpx_idct32x32_34_add = vpx_idct32x32_34_add_ssse3; @@ -8129,12 +8979,49 @@ static void setup_rtcd_internal(void) { vpx_sad64x64x4d = vpx_sad64x64x4d_sse2; if (flags & HAS_AVX2) vpx_sad64x64x4d = vpx_sad64x64x4d_avx2; + vpx_sad_skip_32x16 = vpx_sad_skip_32x16_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x16 = vpx_sad_skip_32x16_avx2; + vpx_sad_skip_32x16x4d = vpx_sad_skip_32x16x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x16x4d = vpx_sad_skip_32x16x4d_avx2; + vpx_sad_skip_32x32 = vpx_sad_skip_32x32_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x32 = vpx_sad_skip_32x32_avx2; + vpx_sad_skip_32x32x4d = vpx_sad_skip_32x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x32x4d = vpx_sad_skip_32x32x4d_avx2; + vpx_sad_skip_32x64 = vpx_sad_skip_32x64_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x64 = vpx_sad_skip_32x64_avx2; + vpx_sad_skip_32x64x4d = vpx_sad_skip_32x64x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_32x64x4d = vpx_sad_skip_32x64x4d_avx2; + vpx_sad_skip_64x32 = vpx_sad_skip_64x32_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_64x32 = vpx_sad_skip_64x32_avx2; + vpx_sad_skip_64x32x4d = vpx_sad_skip_64x32x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_64x32x4d = vpx_sad_skip_64x32x4d_avx2; + vpx_sad_skip_64x64 = vpx_sad_skip_64x64_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_64x64 = vpx_sad_skip_64x64_avx2; + vpx_sad_skip_64x64x4d = vpx_sad_skip_64x64x4d_sse2; + if (flags & HAS_AVX2) + vpx_sad_skip_64x64x4d = vpx_sad_skip_64x64x4d_avx2; vpx_satd = vpx_satd_sse2; if (flags & HAS_AVX2) vpx_satd = vpx_satd_avx2; vpx_scaled_2d = vpx_scaled_2d_c; if (flags & HAS_SSSE3) vpx_scaled_2d = vpx_scaled_2d_ssse3; + vpx_sse = vpx_sse_c; + if (flags & HAS_SSE4_1) { + vpx_sse = vpx_sse_sse4_1; + } + if (flags & HAS_AVX2) { + vpx_sse = vpx_sse_avx2; + } vpx_sub_pixel_avg_variance16x16 = vpx_sub_pixel_avg_variance16x16_sse2; if (flags & HAS_SSSE3) vpx_sub_pixel_avg_variance16x16 = vpx_sub_pixel_avg_variance16x16_ssse3; diff --git a/libvpx/source/config/win/x64/vpx_scale_rtcd.h b/libvpx/source/config/win/x64/vpx_scale_rtcd.h old mode 100644 new mode 100755 diff --git a/libvpx/tests/fuzzer/vp8_encoder_fuzz_test.cc b/libvpx/tests/fuzzer/vp8_encoder_fuzz_test.cc new file mode 100755 index 0000000000000000000000000000000000000000..be6ef70fe3b21627f71da130cd50a6703ba5c727 --- /dev/null +++ b/libvpx/tests/fuzzer/vp8_encoder_fuzz_test.cc @@ -0,0 +1,271 @@ +/* + * Copyright (c) 2023 The WebM project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include +#include +#include + +#include "third_party/fuzztest/src/fuzztest/fuzztest.h" +#include "third_party/googletest/src/googletest/include/gtest/gtest.h" +#include "third_party/libvpx/source/libvpx/vpx/vp8cx.h" +#include "third_party/libvpx/source/libvpx/vpx/vpx_codec.h" +#include "third_party/libvpx/source/libvpx/vpx/vpx_encoder.h" +#include "third_party/libvpx/source/libvpx/vpx/vpx_image.h" + +using fuzztest::Arbitrary; +using fuzztest::ElementOf; +using fuzztest::FlatMap; +using fuzztest::InRange; +using fuzztest::Just; +using fuzztest::StructOf; +using fuzztest::VariantOf; +using fuzztest::VectorOf; + +// Represents a VideoEncoder::configure() method call. +// Parameters: +// VideoEncoderConfig config +struct Configure { + unsigned int threads; // Not part of VideoEncoderConfig + unsigned int width; // Nonzero + unsigned int height; // Nonzero + // TODO(wtc): displayWidth, displayHeight, bitrate, framerate, + // scalabilityMode. + vpx_rc_mode end_usage; // Implies bitrateMode: constant, variable. + // Note: quantizer not implemented for VP8. + vpx_enc_deadline_t deadline; // Implies LatencyMode: quality, realtime. + // TODO(wtc): contentHint. +}; + +auto AnyConfigureWithSize(unsigned int width, unsigned int height) { + return StructOf( + // Chrome's WebCodecs uses at most 16 threads. + /*threads=*/InRange(0u, 16u), /*width=*/Just(width), + /*height=*/Just(height), + /*end_usage=*/ElementOf({VPX_VBR, VPX_CBR}), + /*deadline=*/ + ElementOf({VPX_DL_GOOD_QUALITY, VPX_DL_REALTIME})); +} + +auto AnyConfigureWithMaxSize(unsigned int max_width, unsigned int max_height) { + return StructOf( + // Chrome's WebCodecs uses at most 16 threads. + /*threads=*/InRange(0u, 16u), + /*width=*/InRange(1u, max_width), + /*height=*/InRange(1u, max_height), + /*end_usage=*/ElementOf({VPX_VBR, VPX_CBR}), + /*deadline=*/ + ElementOf({VPX_DL_GOOD_QUALITY, VPX_DL_REALTIME})); +} + +// Represents a VideoEncoder::encode() method call. +// Parameters: +// VideoFrame frame +// optional VideoEncoderEncodeOptions options = {} +struct Encode { + bool key_frame; + // Note: quantizer not implemented for VP8 +}; + +auto AnyEncode() { + return StructOf(Arbitrary()); +} + +using MethodCall = std::variant; + +auto AnyMethodCallWithMaxSize(unsigned int max_width, unsigned int max_height) { + return VariantOf(AnyConfigureWithMaxSize(max_width, max_height), AnyEncode()); +} + +struct CallSequence { + Configure initialize; + std::vector method_calls; +}; + +auto AnyCallSequenceWithMaxSize(unsigned int max_width, + unsigned int max_height) { + return StructOf( + /*initialize=*/AnyConfigureWithSize(max_width, max_height), + /*method_calls=*/VectorOf(AnyMethodCallWithMaxSize(max_width, max_height)) + .WithMaxSize(20)); +} + +auto AnyCallSequence() { + return FlatMap(AnyCallSequenceWithMaxSize, + /*max_width=*/InRange(1u, 1920u), + /*max_height=*/InRange(1u, 1080u)); +} + +void VP8EncodeArbitraryCallSequenceSucceeds(int speed, + const CallSequence& call_sequence) { + vpx_codec_iface_t* const iface = vpx_codec_vp8_cx(); + vpx_codec_enc_cfg_t cfg; + ASSERT_EQ(vpx_codec_enc_config_default(iface, &cfg, /*usage=*/0), + VPX_CODEC_OK); + cfg.g_threads = call_sequence.initialize.threads; + cfg.g_w = call_sequence.initialize.width; + cfg.g_h = call_sequence.initialize.height; + cfg.g_timebase.num = 1; + cfg.g_timebase.den = 1000 * 1000; // microseconds + cfg.g_pass = VPX_RC_ONE_PASS; + cfg.g_lag_in_frames = 0; + cfg.rc_end_usage = call_sequence.initialize.end_usage; + cfg.rc_min_quantizer = 2; + cfg.rc_max_quantizer = 58; + + vpx_codec_ctx_t enc; + ASSERT_EQ(vpx_codec_enc_init(&enc, iface, &cfg, 0), VPX_CODEC_OK); + + ASSERT_EQ(vpx_codec_control(&enc, VP8E_SET_CPUUSED, speed), VPX_CODEC_OK); + + vpx_enc_deadline_t deadline = call_sequence.initialize.deadline; + const vpx_codec_cx_pkt_t* pkt; + + int frame_index = 0; + for (const auto& call : call_sequence.method_calls) { + if (std::holds_alternative(call)) { + const Configure& configure = std::get(call); + cfg.g_threads = configure.threads; + cfg.g_w = configure.width; + cfg.g_h = configure.height; + cfg.rc_end_usage = configure.end_usage; + ASSERT_EQ(vpx_codec_enc_config_set(&enc, &cfg), VPX_CODEC_OK) + << vpx_codec_error_detail(&enc); + deadline = configure.deadline; + } else { + // Encode a frame. + const Encode& encode = std::get(call); + // VP8 supports only one image format: 8-bit YUV 4:2:0. + vpx_image_t* const image = + vpx_img_alloc(nullptr, VPX_IMG_FMT_I420, cfg.g_w, cfg.g_h, 1); + ASSERT_NE(image, nullptr); + + for (unsigned int i = 0; i < image->d_h; ++i) { + memset(image->planes[0] + i * image->stride[0], 128, image->d_w); + } + const unsigned int uv_h = (image->d_h + 1) / 2; + const unsigned int uv_w = (image->d_w + 1) / 2; + for (unsigned int i = 0; i < uv_h; ++i) { + memset(image->planes[1] + i * image->stride[1], 128, uv_w); + memset(image->planes[2] + i * image->stride[2], 128, uv_w); + } + + const vpx_enc_frame_flags_t flags = + encode.key_frame ? VPX_EFLAG_FORCE_KF : 0; + ASSERT_EQ(vpx_codec_encode(&enc, image, frame_index, 1, flags, deadline), + VPX_CODEC_OK); + frame_index++; + vpx_codec_iter_t iter = nullptr; + while ((pkt = vpx_codec_get_cx_data(&enc, &iter)) != nullptr) { + ASSERT_EQ(pkt->kind, VPX_CODEC_CX_FRAME_PKT); + if (encode.key_frame) { + ASSERT_EQ(pkt->data.frame.flags & VPX_FRAME_IS_KEY, VPX_FRAME_IS_KEY); + } + } + vpx_img_free(image); + } + } + + // Flush the encoder. + bool got_data; + do { + ASSERT_EQ(vpx_codec_encode(&enc, nullptr, 0, 1, 0, deadline), VPX_CODEC_OK); + got_data = false; + vpx_codec_iter_t iter = nullptr; + while ((pkt = vpx_codec_get_cx_data(&enc, &iter)) != nullptr) { + ASSERT_EQ(pkt->kind, VPX_CODEC_CX_FRAME_PKT); + got_data = true; + } + } while (got_data); + + ASSERT_EQ(vpx_codec_destroy(&enc), VPX_CODEC_OK); +} + +FUZZ_TEST(VP8EncodeFuzzTest, VP8EncodeArbitraryCallSequenceSucceeds) + .WithDomains(/*speed=*/InRange(-16, 16), + /*call_sequence=*/AnyCallSequence()); + +// speed: range -16..16 +// end_usage: Rate control mode +void VP8EncodeSucceeds(unsigned int threads, + int speed, + vpx_rc_mode end_usage, + unsigned int width, + unsigned int height, + int num_frames) { + vpx_codec_iface_t* const iface = vpx_codec_vp8_cx(); + vpx_codec_enc_cfg_t cfg; + ASSERT_EQ(vpx_codec_enc_config_default(iface, &cfg, /*usage=*/0), + VPX_CODEC_OK); + cfg.g_threads = threads; + cfg.g_w = width; + cfg.g_h = height; + cfg.g_timebase.num = 1; + cfg.g_timebase.den = 1000 * 1000; // microseconds + cfg.g_pass = VPX_RC_ONE_PASS; + cfg.g_lag_in_frames = 0; + cfg.rc_end_usage = end_usage; + cfg.rc_min_quantizer = 2; + cfg.rc_max_quantizer = 58; + + vpx_codec_ctx_t enc; + ASSERT_EQ(vpx_codec_enc_init(&enc, iface, &cfg, 0), VPX_CODEC_OK); + + ASSERT_EQ(vpx_codec_control(&enc, VP8E_SET_CPUUSED, speed), VPX_CODEC_OK); + + // VP8 supports only one image format: 8-bit YUV 4:2:0. + vpx_image_t* const image = + vpx_img_alloc(nullptr, VPX_IMG_FMT_I420, cfg.g_w, cfg.g_h, 1); + ASSERT_NE(image, nullptr); + + for (unsigned int i = 0; i < image->d_h; ++i) { + memset(image->planes[0] + i * image->stride[0], 128, image->d_w); + } + const unsigned int uv_h = (image->d_h + 1) / 2; + const unsigned int uv_w = (image->d_w + 1) / 2; + for (unsigned int i = 0; i < uv_h; ++i) { + memset(image->planes[1] + i * image->stride[1], 128, uv_w); + memset(image->planes[2] + i * image->stride[2], 128, uv_w); + } + + // Encode frames. + const vpx_enc_deadline_t deadline = VPX_DL_REALTIME; + const vpx_codec_cx_pkt_t* pkt; + for (int i = 0; i < num_frames; ++i) { + ASSERT_EQ(vpx_codec_encode(&enc, image, i, 1, 0, deadline), VPX_CODEC_OK); + vpx_codec_iter_t iter = nullptr; + while ((pkt = vpx_codec_get_cx_data(&enc, &iter)) != nullptr) { + ASSERT_EQ(pkt->kind, VPX_CODEC_CX_FRAME_PKT); + } + } + + // Flush the encoder. + bool got_data; + do { + ASSERT_EQ(vpx_codec_encode(&enc, nullptr, 0, 1, 0, deadline), VPX_CODEC_OK); + got_data = false; + vpx_codec_iter_t iter = nullptr; + while ((pkt = vpx_codec_get_cx_data(&enc, &iter)) != nullptr) { + ASSERT_EQ(pkt->kind, VPX_CODEC_CX_FRAME_PKT); + got_data = true; + } + } while (got_data); + + vpx_img_free(image); + ASSERT_EQ(vpx_codec_destroy(&enc), VPX_CODEC_OK); +} + +// Chrome's WebCodecs uses at most 16 threads. +FUZZ_TEST(VP8EncodeFuzzTest, VP8EncodeSucceeds) + .WithDomains(/*threads=*/InRange(0u, 16u), + /*speed=*/InRange(-16, 16), + /*end_usage=*/ElementOf({VPX_VBR, VPX_CBR}), + /*width=*/InRange(1u, 1920u), + /*height=*/InRange(1u, 1080u), + /*num_frames=*/InRange(1, 10)); diff --git a/libvpx/tests/fuzzer/vp9_encoder_fuzz_test.cc b/libvpx/tests/fuzzer/vp9_encoder_fuzz_test.cc new file mode 100755 index 0000000000000000000000000000000000000000..6fc728e4898b02fbaecd2373fe697e601f220f8f --- /dev/null +++ b/libvpx/tests/fuzzer/vp9_encoder_fuzz_test.cc @@ -0,0 +1,330 @@ +/* + * Copyright (c) 2023 The WebM project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include +#include +#include +#include + +#include "third_party/fuzztest/src/fuzztest/fuzztest.h" +#include "third_party/googletest/src/googletest/include/gtest/gtest.h" +#include "third_party/libvpx/source/libvpx/vpx/vp8cx.h" +#include "third_party/libvpx/source/libvpx/vpx/vpx_codec.h" +#include "third_party/libvpx/source/libvpx/vpx/vpx_encoder.h" +#include "third_party/libvpx/source/libvpx/vpx/vpx_image.h" + +using fuzztest::Arbitrary; +using fuzztest::ElementOf; +using fuzztest::FlatMap; +using fuzztest::InRange; +using fuzztest::Just; +using fuzztest::StructOf; +using fuzztest::VariantOf; +using fuzztest::VectorOf; + +auto AnyBitDepth() { + vpx_codec_iface_t* const iface = vpx_codec_vp9_cx(); + return (vpx_codec_get_caps(iface) & VPX_CODEC_CAP_HIGHBITDEPTH) + ? ElementOf({VPX_BITS_8, VPX_BITS_10, VPX_BITS_12}) + : Just(VPX_BITS_8); +} + +// Represents a VideoEncoder::configure() method call. +// Parameters: +// VideoEncoderConfig config +struct Configure { + unsigned int threads; // Not part of VideoEncoderConfig + unsigned int width; // Nonzero + unsigned int height; // Nonzero + // TODO(wtc): displayWidth, displayHeight, bitrate, framerate, + // scalabilityMode. + vpx_rc_mode end_usage; // Implies bitrateMode: constant, variable. + // TODO(wtc): quantizer. + vpx_enc_deadline_t deadline; // Implies LatencyMode: quality, realtime. + // TODO(wtc): contentHint. +}; + +auto AnyConfigureWithSize(unsigned int width, unsigned int height) { + return StructOf( + // Chrome's WebCodecs uses at most 16 threads. + /*threads=*/InRange(0u, 16u), /*width=*/Just(width), + /*height=*/Just(height), + /*end_usage=*/ElementOf({VPX_VBR, VPX_CBR}), + /*deadline=*/ + ElementOf({VPX_DL_GOOD_QUALITY, VPX_DL_REALTIME})); +} + +auto AnyConfigureWithMaxSize(unsigned int max_width, unsigned int max_height) { + return StructOf( + // Chrome's WebCodecs uses at most 16 threads. + /*threads=*/InRange(0u, 16u), + /*width=*/InRange(1u, max_width), + /*height=*/InRange(1u, max_height), + /*end_usage=*/ElementOf({VPX_VBR, VPX_CBR}), + /*deadline=*/ + ElementOf({VPX_DL_GOOD_QUALITY, VPX_DL_REALTIME})); +} + +// Represents a VideoEncoder::encode() method call. +// Parameters: +// VideoFrame frame +// optional VideoEncoderEncodeOptions options = {} +struct Encode { + bool key_frame; + // TODO(wtc): quantizer. +}; + +auto AnyEncode() { + return StructOf(Arbitrary()); +} + +using MethodCall = std::variant; + +auto AnyMethodCallWithMaxSize(unsigned int max_width, unsigned int max_height) { + return VariantOf(AnyConfigureWithMaxSize(max_width, max_height), AnyEncode()); +} + +struct CallSequence { + Configure initialize; + std::vector method_calls; +}; + +auto AnyCallSequenceWithMaxSize(unsigned int max_width, + unsigned int max_height) { + return StructOf( + /*initialize=*/AnyConfigureWithSize(max_width, max_height), + /*method_calls=*/VectorOf(AnyMethodCallWithMaxSize(max_width, max_height)) + .WithMaxSize(20)); +} + +auto AnyCallSequence() { + return FlatMap(AnyCallSequenceWithMaxSize, + /*max_width=*/InRange(1u, 1920u), + /*max_height=*/InRange(1u, 1080u)); +} + +void* Memset16(void* dest, int val, size_t length) { + uint16_t* dest16 = reinterpret_cast(dest); + for (size_t i = 0; i < length; i++) { + *dest16++ = val; + } + return dest; +} + +vpx_image_t* CreateGrayImage(vpx_bit_depth_t bit_depth, + vpx_img_fmt_t fmt, + unsigned int width, + unsigned int height) { + if (bit_depth > VPX_BITS_8) { + fmt = static_cast(fmt | VPX_IMG_FMT_HIGHBITDEPTH); + } + vpx_image_t* image = vpx_img_alloc(nullptr, fmt, width, height, 1); + if (!image) { + return image; + } + + const int val = 1 << (bit_depth - 1); + const unsigned int uv_h = + (image->d_h + image->y_chroma_shift) >> image->y_chroma_shift; + const unsigned int uv_w = + (image->d_w + image->x_chroma_shift) >> image->x_chroma_shift; + if (bit_depth > VPX_BITS_8) { + for (unsigned int i = 0; i < image->d_h; ++i) { + Memset16(image->planes[0] + i * image->stride[0], val, image->d_w); + } + for (unsigned int i = 0; i < uv_h; ++i) { + Memset16(image->planes[1] + i * image->stride[1], val, uv_w); + Memset16(image->planes[2] + i * image->stride[2], val, uv_w); + } + } else { + for (unsigned int i = 0; i < image->d_h; ++i) { + memset(image->planes[0] + i * image->stride[0], val, image->d_w); + } + for (unsigned int i = 0; i < uv_h; ++i) { + memset(image->planes[1] + i * image->stride[1], val, uv_w); + memset(image->planes[2] + i * image->stride[2], val, uv_w); + } + } + + return image; +} + +void VP9EncodeArbitraryCallSequenceSucceeds(int speed, + unsigned int row_mt, + vpx_bit_depth_t bit_depth, + vpx_img_fmt_t fmt, + const CallSequence& call_sequence) { + ASSERT_EQ(fmt & VPX_IMG_FMT_HIGHBITDEPTH, 0); + const bool high_bit_depth = bit_depth > VPX_BITS_8; + const bool is_420 = fmt == VPX_IMG_FMT_I420; + vpx_codec_iface_t* const iface = vpx_codec_vp9_cx(); + vpx_codec_enc_cfg_t cfg; + ASSERT_EQ(vpx_codec_enc_config_default(iface, &cfg, /*usage=*/0), + VPX_CODEC_OK); + cfg.g_threads = call_sequence.initialize.threads; + // In profiles 0 and 2, only 4:2:0 format is allowed. In profiles 1 and 3, + // all other subsampling formats are allowed. In profiles 0 and 1, only bit + // depth 8 is allowed. In profiles 2 and 3, only bit depths 10 and 12 are + // allowed. + cfg.g_profile = 2 * high_bit_depth + !is_420; + cfg.g_w = call_sequence.initialize.width; + cfg.g_h = call_sequence.initialize.height; + cfg.g_bit_depth = bit_depth; + cfg.g_input_bit_depth = bit_depth; + cfg.g_timebase.num = 1; + cfg.g_timebase.den = 1000 * 1000; // microseconds + cfg.g_pass = VPX_RC_ONE_PASS; + cfg.g_lag_in_frames = 0; + cfg.rc_end_usage = call_sequence.initialize.end_usage; + cfg.rc_min_quantizer = 2; + cfg.rc_max_quantizer = 58; + + vpx_codec_ctx_t enc; + ASSERT_EQ(vpx_codec_enc_init(&enc, iface, &cfg, + high_bit_depth ? VPX_CODEC_USE_HIGHBITDEPTH : 0), + VPX_CODEC_OK); + + ASSERT_EQ(vpx_codec_control(&enc, VP8E_SET_CPUUSED, speed), VPX_CODEC_OK); + ASSERT_EQ(vpx_codec_control(&enc, VP9E_SET_ROW_MT, row_mt), VPX_CODEC_OK); + + vpx_enc_deadline_t deadline = call_sequence.initialize.deadline; + const vpx_codec_cx_pkt_t* pkt; + + int frame_index = 0; + for (const auto& call : call_sequence.method_calls) { + if (std::holds_alternative(call)) { + const Configure& configure = std::get(call); + cfg.g_threads = configure.threads; + cfg.g_w = configure.width; + cfg.g_h = configure.height; + cfg.rc_end_usage = configure.end_usage; + ASSERT_EQ(vpx_codec_enc_config_set(&enc, &cfg), VPX_CODEC_OK) + << vpx_codec_error_detail(&enc); + deadline = configure.deadline; + } else { + // Encode a frame. + const Encode& encode = std::get(call); + vpx_image_t* const image = + CreateGrayImage(bit_depth, fmt, cfg.g_w, cfg.g_h); + ASSERT_NE(image, nullptr); + + const vpx_enc_frame_flags_t flags = + encode.key_frame ? VPX_EFLAG_FORCE_KF : 0; + ASSERT_EQ(vpx_codec_encode(&enc, image, frame_index, 1, flags, deadline), + VPX_CODEC_OK); + frame_index++; + vpx_codec_iter_t iter = nullptr; + while ((pkt = vpx_codec_get_cx_data(&enc, &iter)) != nullptr) { + ASSERT_EQ(pkt->kind, VPX_CODEC_CX_FRAME_PKT); + if (encode.key_frame) { + ASSERT_EQ(pkt->data.frame.flags & VPX_FRAME_IS_KEY, VPX_FRAME_IS_KEY); + } + } + vpx_img_free(image); + } + } + + // Flush the encoder. + bool got_data; + do { + ASSERT_EQ(vpx_codec_encode(&enc, nullptr, 0, 1, 0, deadline), VPX_CODEC_OK); + got_data = false; + vpx_codec_iter_t iter = nullptr; + while ((pkt = vpx_codec_get_cx_data(&enc, &iter)) != nullptr) { + ASSERT_EQ(pkt->kind, VPX_CODEC_CX_FRAME_PKT); + got_data = true; + } + } while (got_data); + + ASSERT_EQ(vpx_codec_destroy(&enc), VPX_CODEC_OK); +} + +FUZZ_TEST(VP9EncodeFuzzTest, VP9EncodeArbitraryCallSequenceSucceeds) + .WithDomains( + /*speed=*/InRange(-9, 9), + /*row_mt=*/InRange(0u, 1u), + /*bit_depth=*/AnyBitDepth(), + // Only generate image formats that don't have the + // VPX_IMG_FMT_HIGHBITDEPTH bit set. If bit_depth > 8, we will set the + // VPX_IMG_FMT_HIGHBITDEPTH bit before passing the image format to + // vpx_img_alloc(). To reduce the search space, don't generate + // VPX_IMG_FMT_I440 (not used) and VPX_IMG_FMT_NV12 (which is converted + // to I420 in vp9_copy_and_extend_frame()). + /*fmt=*/ + ElementOf({VPX_IMG_FMT_I420, VPX_IMG_FMT_I422, VPX_IMG_FMT_I444}), + /*call_sequence=*/AnyCallSequence()); + +// speed: range -9..9 +// end_usage: Rate control mode +void VP9EncodeSucceeds(unsigned int threads, + int speed, + vpx_rc_mode end_usage, + unsigned int width, + unsigned int height, + int num_frames) { + vpx_codec_iface_t* const iface = vpx_codec_vp9_cx(); + vpx_codec_enc_cfg_t cfg; + ASSERT_EQ(vpx_codec_enc_config_default(iface, &cfg, /*usage=*/0), + VPX_CODEC_OK); + cfg.g_threads = threads; + cfg.g_w = width; + cfg.g_h = height; + cfg.g_timebase.num = 1; + cfg.g_timebase.den = 1000 * 1000; // microseconds + cfg.g_pass = VPX_RC_ONE_PASS; + cfg.g_lag_in_frames = 0; + cfg.rc_end_usage = end_usage; + cfg.rc_min_quantizer = 2; + cfg.rc_max_quantizer = 58; + + vpx_codec_ctx_t enc; + ASSERT_EQ(vpx_codec_enc_init(&enc, iface, &cfg, 0), VPX_CODEC_OK); + + ASSERT_EQ(vpx_codec_control(&enc, VP8E_SET_CPUUSED, speed), VPX_CODEC_OK); + + vpx_image_t* const image = + CreateGrayImage(VPX_BITS_8, VPX_IMG_FMT_I420, cfg.g_w, cfg.g_h); + ASSERT_NE(image, nullptr); + + // Encode frames. + const vpx_enc_deadline_t deadline = VPX_DL_REALTIME; + const vpx_codec_cx_pkt_t* pkt; + for (int i = 0; i < num_frames; ++i) { + ASSERT_EQ(vpx_codec_encode(&enc, image, i, 1, 0, deadline), VPX_CODEC_OK); + vpx_codec_iter_t iter = nullptr; + while ((pkt = vpx_codec_get_cx_data(&enc, &iter)) != nullptr) { + ASSERT_EQ(pkt->kind, VPX_CODEC_CX_FRAME_PKT); + } + } + + // Flush the encoder. + bool got_data; + do { + ASSERT_EQ(vpx_codec_encode(&enc, nullptr, 0, 1, 0, deadline), VPX_CODEC_OK); + got_data = false; + vpx_codec_iter_t iter = nullptr; + while ((pkt = vpx_codec_get_cx_data(&enc, &iter)) != nullptr) { + ASSERT_EQ(pkt->kind, VPX_CODEC_CX_FRAME_PKT); + got_data = true; + } + } while (got_data); + + vpx_img_free(image); + ASSERT_EQ(vpx_codec_destroy(&enc), VPX_CODEC_OK); +} + +// Chrome's WebCodecs uses at most 16 threads. +FUZZ_TEST(VP9EncodeFuzzTest, VP9EncodeSucceeds) + .WithDomains(/*threads=*/InRange(0u, 16u), + /*speed=*/InRange(-9, 9), + /*end_usage=*/ElementOf({VPX_VBR, VPX_CBR}), + /*width=*/InRange(1u, 1920u), + /*height=*/InRange(1u, 1080u), + /*num_frames=*/InRange(1, 10)); diff --git a/libvpx/tests/pgo/decode_encode_profile_test.cc b/libvpx/tests/pgo/decode_encode_profile_test.cc new file mode 100755 index 0000000000000000000000000000000000000000..1bd6ce8eb1c717fe3dcfdf8b4e6aeae2b9e69861 --- /dev/null +++ b/libvpx/tests/pgo/decode_encode_profile_test.cc @@ -0,0 +1,327 @@ +// Copyright 2024 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Implementation of a PGO test for the decoder and encoder + +#include "third_party/googletest/src/include/gtest/gtest.h" + +#include "third_party/libvpx/source/config/vpx_version.h" +#include "third_party/libvpx/source/libvpx/test/codec_factory.h" +#include "third_party/libvpx/source/libvpx/test/i420_video_source.h" +#include "third_party/libvpx/source/libvpx/test/util.h" +#include "third_party/libvpx/source/libvpx/test/webm_video_source.h" +#include "third_party/libvpx/source/libvpx/vpx_ports/vpx_timer.h" +#include "third_party/libvpx/source/libvpx/vpx_util/vpx_pthread.h" + +namespace { + +using std::make_tuple; + +constexpr int kMaxPsnr = 100; +constexpr double kUsecsInSec = 1000000.0; +constexpr vpx_rational kTimebase = {33333333, 1000000000}; + +/** + * Test vectors: + * Parameter ID 0 - video file name + * Parameter ID 1 - number of threads + */ +using DecodePerfParam = std::tuple; + +const DecodePerfParam kVP9DecodePerfVectors[] = { + make_tuple("./vp90-2-bbb_426x240_tile_1x1_180kbps.webm", 4), + make_tuple("./vp90-2-tos_1280x534_tile_1x4_1306kbps.webm", 2), + make_tuple("./vp90-2-tos_1920x800_tile_1x4_fpm_2335kbps.webm", 2), + make_tuple("./vp90-2-bbb_1280x720_tile_1x4_1310kbps.webm", 2), + make_tuple("./vp90-2-tos_854x356_tile_1x2_fpm_546kbps.webm", 2), + make_tuple("./vp90-2-sintel_1280x546_tile_1x4_1257kbps.webm", 2), + make_tuple("./vp90-2-sintel_640x272_tile_1x2_318kbps.webm", 2), + make_tuple("./vp90-2-tos_1280x534_tile_1x4_fpm_952kbps.webm", 2), + make_tuple("./vp90-2-bbb_1920x1080_tile_1x1_2581kbps.webm", 2), + make_tuple("./vp90-2-sintel_1920x818_tile_1x4_fpm_2279kbps.webm", 2), + make_tuple("./vp90-2-tos_854x356_tile_1x2_656kbps.webm", 2), + make_tuple("./vp90-2-bbb_640x360_tile_1x2_337kbps.webm", 2), + make_tuple("./vp90-2-tos_426x178_tile_1x1_181kbps.webm", 2), + make_tuple("./vp90-2-sintel_854x364_tile_1x2_621kbps.webm", 2), + make_tuple("./vp90-2-bbb_1920x1080_tile_1x4_2586kbps.webm", 2), + make_tuple("./vp90-2-sintel_426x182_tile_1x1_171kbps.webm", 2), + make_tuple("./vp90-2-bbb_854x480_tile_1x2_651kbps.webm", 2), + make_tuple("./vp90-2-tos_640x266_tile_1x2_336kbps.webm", 2), + make_tuple("./vp90-2-bbb_1920x1080_tile_1x4_fpm_2304kbps.webm", 2), +}; + +/** + * Class for obtaining video frames from memory. + * + * The class is used to pass frames from the decoder to the encoder. + * Using an in-memory source allows to exercise the encoder on embedded + * devices with limited storage space, where storing large YUV files + * is not feasible. + */ +class InMemoryVideoSource : public ::libvpx_test::VideoSource { + public: + InMemoryVideoSource() : img_(nullptr) { + pthread_mutex_init(&mutex_, nullptr); + pthread_mutex_init(&producer_mutex_, nullptr); + pthread_cond_init(&cond_, nullptr); + pthread_cond_init(&cond_producer_, nullptr); + end_of_input_ = false; + } + + ~InMemoryVideoSource() override = default; + + void ReleaseImage() { + pthread_mutex_lock(&mutex_); + img_ = nullptr; + pthread_mutex_unlock(&mutex_); + pthread_cond_signal(&cond_producer_); + } + + void SetImage(const vpx_image_t* img, bool end_of_input = false) { + pthread_mutex_lock(&mutex_); + /** + * It is not trivial to copy the vpx_image_t struct, since the raw + * buffer size is not stored. + * The buffer is locked by the encoder until the frame is encoded. + */ + // Silence -Wcast-qual warnings + img_ = const_cast(img); + end_of_input_ = end_of_input; + pthread_mutex_unlock(&mutex_); + pthread_cond_signal(&cond_); + } + + /** + * Wait for the encoder to finish encoding of the current frame. + */ + void WaitForEncoder() { + pthread_mutex_lock(&producer_mutex_); + + while (img_ != nullptr) { + pthread_cond_wait(&cond_producer_, &producer_mutex_); + } + + pthread_mutex_unlock(&producer_mutex_); + } + + void Begin() override {} + + void Next() override { + // Wait for the next frame, img to be non-null. Use cond to signal + pthread_mutex_lock(&mutex_); + + while (img_ == nullptr && !end_of_input_) { + pthread_cond_wait(&cond_, &mutex_); + } + + pthread_mutex_unlock(&mutex_); + } + + vpx_image_t* img() const override { return img_; } + + vpx_codec_pts_t pts() const override { return 0; } + + unsigned long duration() const override { return 1; } + + vpx_rational_t timebase() const override { return {33333333, 1000000000}; } + + unsigned int frame() const override { return 0; } + + unsigned int limit() const override { return 0; } + + private: + vpx_image_t* img_; + pthread_mutex_t mutex_; + pthread_mutex_t producer_mutex_; + pthread_cond_t cond_; + pthread_cond_t cond_producer_; + bool end_of_input_; +}; + +THREADFN EncoderThreadAdapter(void* obj); + +class VP9M2MEncoder : public ::libvpx_test::EncoderTest { + public: + VP9M2MEncoder(unsigned int threads) + : EncoderTest(&libvpx_test::kVP9), + initialized_(false), + min_psnr_(kMaxPsnr), + encoding_mode_(::libvpx_test::kRealTime), + speed_(0), + threads_(threads) { + InitializeConfig(); + SetMode(encoding_mode_); + + cfg_.g_timebase = kTimebase; + cfg_.g_lag_in_frames = 0; + cfg_.rc_min_quantizer = 2; + cfg_.rc_max_quantizer = 56; + cfg_.rc_dropframe_thresh = 0; + cfg_.rc_undershoot_pct = 50; + cfg_.rc_overshoot_pct = 50; + cfg_.rc_buf_sz = 1000; + cfg_.rc_buf_initial_sz = 500; + cfg_.rc_buf_optimal_sz = 600; + cfg_.rc_resize_allowed = 0; + cfg_.rc_end_usage = VPX_CBR; + cfg_.g_error_resilient = 1; + cfg_.g_threads = threads_; + } + + ~VP9M2MEncoder() override = default; + + void Shutdown() { + SetImage(nullptr, true); + abort_ = true; + pthread_join(thread_, nullptr); + } + + void RunLoopEncode() { RunLoop(&in_mem_source_); } + + void WaitForEncoder() { in_mem_source_.WaitForEncoder(); } + + bool SetImage(const vpx_image_t* img, bool end_of_input = false) { + in_mem_source_.SetImage(img, end_of_input); + + if (!initialized_) { + Init(img); + } + + return initialized_; + } + + protected: + void ReleaseImage() { in_mem_source_.ReleaseImage(); } + + void PostEncodeFrameHook(libvpx_test::Encoder* /*encoder*/) override { + // Call ReleaseImage to set img_ to null. + // This signals that the frame has been encoded. + ReleaseImage(); + } + + void PreEncodeFrameHook(::libvpx_test::VideoSource* video, + ::libvpx_test::Encoder* encoder) override { + if (video->frame() == 0) { + const int log2_tile_columns = 3; + encoder->Control(VP8E_SET_CPUUSED, speed_); + encoder->Control(VP9E_SET_TILE_COLUMNS, log2_tile_columns); + encoder->Control(VP9E_SET_FRAME_PARALLEL_DECODING, 1); + encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 0); + } + } + + void Run(void* arg) { + pthread_create(&thread_, nullptr, EncoderThreadAdapter, arg); + } + + void BeginPassHook(unsigned int /*pass*/) override { min_psnr_ = kMaxPsnr; } + + void PSNRPktHook(const vpx_codec_cx_pkt_t* pkt) override { + if (pkt->data.psnr.psnr[0] < min_psnr_) { + min_psnr_ = pkt->data.psnr.psnr[0]; + } + } + + bool DoDecode() const override { return false; } + + bool Init(const vpx_image_t* img) { + cfg_.rc_target_bitrate = img->bps; + init_flags_ = VPX_CODEC_USE_PSNR; + cfg_.g_w = img->d_w; + cfg_.g_h = img->d_h; + cfg_.g_threads = threads_; + initialized_ = true; + speed_ = 9; + + Run(this); + return initialized_; + } + + private: + bool initialized_; + double min_psnr_; + libvpx_test::TestMode encoding_mode_; + int speed_; + unsigned int threads_; + pthread_t thread_; + InMemoryVideoSource in_mem_source_; +}; + +THREADFN EncoderThreadAdapter(void* obj) { + VP9M2MEncoder* p = reinterpret_cast(obj); + p->RunLoopEncode(); + return THREAD_EXIT_SUCCESS; +} + +class DecodeEncodePerfTest : public ::testing::TestWithParam { + public: + DecodeEncodePerfTest() + : video_name_(GET_PARAM(0)), thread_count_(GET_PARAM(1)) {} + + const char* GetParamVideoName() const { return video_name_; } + + unsigned int GetParamThreadCount() const { return thread_count_; } + + private: + const char* video_name_; + unsigned int thread_count_; +}; + +// In-memory decode and encode test for Profile Guided Optimizations +// +// This performance test is designed to exercise the decoder and encoder +// and generate a compilation profile for the decoder and encoder. +// Contrary to the name we don't really care to measure the actual test case +// performance, but rather to hit as many code paths as possible. +// The decoder and encoder run on separate threads, but the frames are +// synchronized instead of using a buffer queue. +// TODO(crbug.com/chromium/325103518): introduce noise to the decoded frames. + +TEST_P(DecodeEncodePerfTest, PerfTest) { + VP9M2MEncoder encoder(GetParamThreadCount()); + + libvpx_test::WebMVideoSource video(GetParamVideoName()); + + video.Init(); + + vpx_codec_dec_cfg_t cfg = vpx_codec_dec_cfg_t(); + cfg.threads = GetParamThreadCount(); + libvpx_test::VP9Decoder decoder(cfg, 0); + libvpx_test::DxDataIterator dec_iter = decoder.GetDxData(); + + vpx_usec_timer t; + vpx_usec_timer_start(&t); + + for (video.Begin(); video.cxdata() != nullptr; video.Next()) { + const vpx_image_t* d_img; + decoder.DecodeFrame(video.cxdata(), video.frame_size()); + d_img = dec_iter.Next(); + ASSERT_TRUE(encoder.SetImage(d_img)); + encoder.WaitForEncoder(); + } + + printf("Exiting\n"); + encoder.Shutdown(); + + vpx_usec_timer_mark(&t); + const double elapsed_secs_ = + static_cast(vpx_usec_timer_elapsed(&t)) / kUsecsInSec; + const unsigned frames = video.frame_number(); + const double fps = static_cast(frames) / elapsed_secs_; + + printf("{\n"); + printf("\t\"type\" : \"decode_perf_test\",\n"); + printf("\t\"version\" : \"%s\",\n", VERSION_STRING_NOSP); + printf("\t\"videoName\" : \"%s\",\n", GetParamVideoName()); + printf("\t\"threadCount\" : %u,\n", GetParamThreadCount()); + printf("\t\"decodeTimeSecs\" : %f,\n", elapsed_secs_); + printf("\t\"totalFrames\" : %u,\n", frames); + printf("\t\"framesPerSecond\" : %f\n", fps); + printf("}\n"); +} + +INSTANTIATE_TEST_SUITE_P(VP9, + DecodeEncodePerfTest, + ::testing::ValuesIn(kVP9DecodePerfVectors)); +} // namespace diff --git a/libvpx/tests/pgo/pgo-test-data.sha1 b/libvpx/tests/pgo/pgo-test-data.sha1 new file mode 100755 index 0000000000000000000000000000000000000000..062e2e56051e72164e08d981b6de0eb98405e073 --- /dev/null +++ b/libvpx/tests/pgo/pgo-test-data.sha1 @@ -0,0 +1,19 @@ +8cdd435d89029987ee196896e21520e5f879f04d *vp90-2-bbb_1280x720_tile_1x4_1310kbps.webm +091b373aa2ecb59aa5c647affd5bcafcc7547364 *vp90-2-bbb_1920x1080_tile_1x1_2581kbps.webm +87ee28032b0963a44b73a850fcc816a6dc83efbb *vp90-2-bbb_1920x1080_tile_1x4_2586kbps.webm +c6ce25c4bfd4bdfc2932b70428e3dfe11210ec4f *vp90-2-bbb_1920x1080_tile_1x4_fpm_2304kbps.webm +2064bdb22aa71c2691e0469fb62e8087a43f08f8 *vp90-2-bbb_426x240_tile_1x1_180kbps.webm +8080eda22694910162f0996e8a962612f381a57f *vp90-2-bbb_640x360_tile_1x2_337kbps.webm +a484b335c27ea189c0f0d77babea4a510ce12d50 *vp90-2-bbb_854x480_tile_1x2_651kbps.webm +3eacf1f006250be4cc5c92a7ef146e385ee62653 *vp90-2-sintel_1280x546_tile_1x4_1257kbps.webm +217f089a16447490823127b36ce0d945522accfd *vp90-2-sintel_1920x818_tile_1x4_fpm_2279kbps.webm +eedb3c641e60dacbe082491a16df529a5c9187df *vp90-2-sintel_426x182_tile_1x1_171kbps.webm +cb7e4955af183dff33bcba0c837f0922ab066400 *vp90-2-sintel_640x272_tile_1x2_318kbps.webm +48613f9380e2580002f8a09d6e412ea4e89a52b9 *vp90-2-sintel_854x364_tile_1x2_621kbps.webm +990a91f24dd284562d21d714ae773dff5452cad8 *vp90-2-tos_1280x534_tile_1x4_1306kbps.webm +aa402217577a659cfc670157735b4b8e9aa670fe *vp90-2-tos_1280x534_tile_1x4_fpm_952kbps.webm +b6dd558c90bca466b4bcbd03b3371648186465a7 *vp90-2-tos_1920x800_tile_1x4_fpm_2335kbps.webm +1a9c2914ba932a38f0a143efc1ad0e318e78888b *vp90-2-tos_426x178_tile_1x1_181kbps.webm +a3d2b09f24debad4747a1b3066f572be4273bced *vp90-2-tos_640x266_tile_1x2_336kbps.webm +c64b03b5c090e6888cb39685c31f00a6b79fa45c *vp90-2-tos_854x356_tile_1x2_656kbps.webm +94b533dbcf94292001e27cc51fec87f9e8c90c0b *vp90-2-tos_854x356_tile_1x2_fpm_546kbps.webm diff --git a/libxml/src/parser.c b/libxml/src/parser.c index 78c384f2f97dbe6715ee4d302b15f13c0a335099..4aa5acd32c97fa7f82b52ac034306282cb566131 100644 --- a/libxml/src/parser.c +++ b/libxml/src/parser.c @@ -14665,8 +14665,6 @@ xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options, const char *encodi } #ifdef LIBXML_SAX1_ENABLED if (options & XML_PARSE_SAX1) { - ctxt->sax->startElement = xmlSAX2StartElement; - ctxt->sax->endElement = xmlSAX2EndElement; ctxt->sax->startElementNs = NULL; ctxt->sax->endElementNs = NULL; ctxt->sax->initialized = 1; diff --git a/libxml/src/tree.c b/libxml/src/tree.c index eae778d6541aba710b238b4f576c3a647f7db131..d1eab8969aecfc0ad4e160161d27146ad0ea825e 100644 --- a/libxml/src/tree.c +++ b/libxml/src/tree.c @@ -4473,40 +4473,36 @@ xmlNodePtr xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent) { xmlNodePtr ret = NULL; xmlNodePtr p = NULL,q; + xmlDtdPtr newSubset = NULL; while (node != NULL) { + if (node->type == XML_DTD_NODE ) { #ifdef LIBXML_TREE_ENABLED - if (node->type == XML_DTD_NODE ) { - if (doc == NULL) { - node = node->next; - continue; - } - if (doc->intSubset == NULL) { - q = (xmlNodePtr) xmlCopyDtd( (xmlDtdPtr) node ); - if (q == NULL) goto error; - q->doc = doc; - q->parent = parent; - doc->intSubset = (xmlDtdPtr) q; - xmlAddChild(parent, q); - } else { - q = (xmlNodePtr) doc->intSubset; - xmlAddChild(parent, q); - } - } else + if ((doc == NULL) || (doc->intSubset != NULL)) { + node = node->next; + continue; + } + q = (xmlNodePtr) xmlCopyDtd( (xmlDtdPtr) node ); + if (q == NULL) goto error; + q->doc = doc; + q->parent = parent; + newSubset = (xmlDtdPtr) q; +#else + node = node->next; + continue; #endif /* LIBXML_TREE_ENABLED */ - q = xmlStaticCopyNode(node, doc, parent, 1); - if (q == NULL) goto error; - if (ret == NULL) { - q->prev = NULL; - ret = p = q; - } else if (p != q) { - /* the test is required if xmlStaticCopyNode coalesced 2 text nodes */ - p->next = q; - q->prev = p; - p = q; - } - node = node->next; + } else { + q = xmlStaticCopyNode(node, doc, parent, 1); + if (q == NULL) goto error; + } + if (ret == NULL) { + q->prev = NULL; + ret = p = q; + } + node = node->next; } + if (newSubset != NULL) + doc->intSubset = newSubset; return(ret); error: xmlFreeNodeList(ret); diff --git a/libxml/src/xmlreader.c b/libxml/src/xmlreader.c index 979385a138229da1fc93cb47b0e301776a8e460e..fefd68e0b91527ddecfa7464ca2b0fab77bd413a 100644 --- a/libxml/src/xmlreader.c +++ b/libxml/src/xmlreader.c @@ -1443,6 +1443,7 @@ node_found: * Handle XInclude if asked for */ if ((reader->xinclude) && (reader->in_xinclude == 0) && + (reader->state != XML_TEXTREADER_BACKTRACK) && (reader->node != NULL) && (reader->node->type == XML_ELEMENT_NODE) && (reader->node->ns != NULL) && diff --git a/node/linux/node-linux-x64/bin/npm b/node/linux/node-linux-x64/bin/npm index 11dba890dd558eecb3eec4cd7bb8aa988c880c33..2b33341bee6c08e6fd8bc6aadaf6a04c3ebe6110 100755 --- a/node/linux/node-linux-x64/bin/npm +++ b/node/linux/node-linux-x64/bin/npm @@ -1,16 +1,3 @@ -# Copyright (c) 2021 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 -# -# 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, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - #!/bin/sh (set -o igncr) 2>/dev/null && set -o igncr; # cygwin encoding fix diff --git a/ohos_patch/0006-4.0-Beta1.patch b/ohos_patch/0006-4.0-Beta1.patch new file mode 100644 index 0000000000000000000000000000000000000000..bf674107cac68d95ad5942f393e4b7bd0cd61e36 --- /dev/null +++ b/ohos_patch/0006-4.0-Beta1.patch @@ -0,0 +1,31706 @@ +diff --git a/src/base/BUILD.gn b/src/base/BUILD.gn +index b4d96fbe8fb..c5c8570cc5f +--- a/src/base/BUILD.gn ++++ b/src/base/BUILD.gn +@@ -163,12 +163,7 @@ if (is_fuchsia) { + if (is_ohos) { + import("//build/config/ohos/config.gni") + config("ohos_system_libs") { +- libs = [ +- "hilog", +- "utils.z", +- "eventhandler.z", +- "hitrace_meter", +- ] ++ libs = [ "nweb_ohos_adapter.z" ] + + include_dirs = ohos_src_includes + lib_dirs = ohos_libs_dir +@@ -944,6 +939,13 @@ mixed_component("base") { + "vlog.h", + ] + ++ if (is_ohos) { ++ sources += [ ++ "datashare_uri_utils.h", ++ "datashare_uri_utils.cc", ++ ] ++ } ++ + # Various files that are unused in the Chromium build, but presumably here to + # make downstream's life easier. They are not included in the main sources + # list to avoid breaking GN formatting's auto-sorting. +@@ -1611,11 +1613,13 @@ mixed_component("base") { + "nix/xdg_util.cc", + "nix/xdg_util.h", + "system/sys_info_linux.cc", ++ "memory/platform_shared_memory_region_ohos.cc", + ] + deps += [ + "//base/third_party/symbolize", + "//base/third_party/xdg_mime", + "//base/third_party/xdg_user_dirs", ++ "//third_party/ashmem", + ] + + # Add this build flag in gn file to enable stack trace dump +@@ -2412,7 +2416,7 @@ mixed_component("base") { + + # Android and MacOS have their own custom shared memory handle + # implementations. e.g. due to supporting both POSIX and native handles. +- if (is_posix && !is_android && !is_mac) { ++ if (is_posix && !is_android && !is_mac && !is_ohos) { + sources += [ "memory/platform_shared_memory_region_posix.cc" ] + } + +diff --git a/src/base/allocator/partition_allocator/page_allocator_internals_posix.h b/src/base/allocator/partition_allocator/page_allocator_internals_posix.h +index 778a03919e4..533bb9009fb +--- a/src/base/allocator/partition_allocator/page_allocator_internals_posix.h ++++ b/src/base/allocator/partition_allocator/page_allocator_internals_posix.h +@@ -27,7 +27,7 @@ + #include + #include + #endif +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + #include + #endif + #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) +@@ -62,7 +62,7 @@ namespace base { + + namespace { + +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + const char* PageTagToName(PageTag tag) { + // Important: All the names should be string literals. As per prctl.h in + // //third_party/android_ndk the kernel keeps a pointer to the name instead +@@ -178,7 +178,7 @@ uintptr_t SystemAllocPagesInternal(uintptr_t hint, + ret = nullptr; + } + +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + // On Android, anonymous mappings can have a name attached to them. This is + // useful for debugging, and double-checking memory attribution. + if (ret) { +diff --git a/src/base/allocator/partition_allocator/thread_cache.h b/src/base/allocator/partition_allocator/thread_cache.h +index 944650a703f..dbf1bdcd019 +--- a/src/base/allocator/partition_allocator/thread_cache.h ++++ b/src/base/allocator/partition_allocator/thread_cache.h +@@ -68,7 +68,7 @@ class ThreadCache; + extern BASE_EXPORT PartitionTlsKey g_thread_cache_key; + // On Android, we have to go through emutls, since this is always a shared + // library, so don't bother. +-#if defined(PA_THREAD_LOCAL_TLS) && !BUILDFLAG(IS_ANDROID) ++#if defined(PA_THREAD_LOCAL_TLS) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_OHOS) + #define PA_THREAD_CACHE_FAST_TLS + #endif + +diff --git a/src/base/atomic_ref_count.h b/src/base/atomic_ref_count.h +index 5e48c823806..57f1dea6559 +--- a/src/base/atomic_ref_count.h ++++ b/src/base/atomic_ref_count.h +@@ -12,6 +12,10 @@ + + namespace base { + ++namespace subtle { ++class RefCountedOverflowTest; ++} // namespace subtle ++ + class AtomicRefCount { + public: + constexpr AtomicRefCount() : ref_count_(0) {} +@@ -61,6 +65,8 @@ class AtomicRefCount { + } + + private: ++ friend subtle::RefCountedOverflowTest; ++ + std::atomic_int ref_count_; + }; + +diff --git a/src/base/datashare_uri_utils.cc b/src/base/datashare_uri_utils.cc +new file mode 100644 +index 00000000000..497c56d66e0 +--- /dev/null ++++ b/src/base/datashare_uri_utils.cc +@@ -0,0 +1,30 @@ ++// Copyright 2013 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "base/datashare_uri_utils.h" ++ ++#include ++#include "base/logging.h" ++#include "base/strings/utf_string_conversions.h" ++#include "ohos_adapter_helper.h" ++ ++namespace base { ++ ++File OpenDatashareUriForRead(const FilePath& datashare_uri) { ++ int fd = OHOS::NWeb::OhosAdapterHelper::GetInstance() ++ .GetDatashareInstance() ++ .OpenDataShareUriForRead(datashare_uri.value()); ++ if (fd < 0) { ++ LOG(INFO) << " open datashare uri for read, fd is invalid"; ++ return File(); ++ } ++ return File(fd); ++} ++std::u16string GetFileDisplayName(const FilePath& datashare_uri) { ++ std::string display_name = OHOS::NWeb::OhosAdapterHelper::GetInstance() ++ .GetDatashareInstance() ++ .GetFileDisplayName(datashare_uri.value()); ++ return base::UTF8ToUTF16(display_name); ++} ++} // namespace base +diff --git a/src/base/datashare_uri_utils.h b/src/base/datashare_uri_utils.h +new file mode 100644 +index 00000000000..33b947dc1c6 +--- /dev/null ++++ b/src/base/datashare_uri_utils.h +@@ -0,0 +1,25 @@ ++// Copyright 2013 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef BASE_DATASHARE_URI_UTILS_H_ ++#define BASE_DATASHARE_URI_UTILS_H_ ++ ++#include ++ ++#include "base/base_export.h" ++#include "base/files/file.h" ++#include "base/files/file_path.h" ++ ++namespace base { ++ ++// Opens a datashare URI for read and returns the file descriptor to the caller. ++BASE_EXPORT File OpenDatashareUriForRead(const FilePath& uri); ++ ++// The display name of the file that is to be exposed as File.name in the ++// DOM layer. If it is empty, the base part of the |file_path| is used. ++BASE_EXPORT std::u16string GetFileDisplayName(const FilePath& datashare_uri); ++ ++} // namespace base ++ ++#endif // BASE_DATASHARE_URI_UTILS_H_ +diff --git a/src/base/files/dir_reader_posix.h b/src/base/files/dir_reader_posix.h +index b5d910a29a8..ae092201f60 +--- a/src/base/files/dir_reader_posix.h ++++ b/src/base/files/dir_reader_posix.h +@@ -17,7 +17,8 @@ + // seems worse than falling back to enumerating all file descriptors so we will + // probably never implement this on the Mac. + +-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || \ ++ BUILDFLAG(IS_OHOS) + #include "base/files/dir_reader_linux.h" + #else + #include "base/files/dir_reader_fallback.h" +@@ -25,7 +26,8 @@ + + namespace base { + +-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || \ ++ BUILDFLAG(IS_OHOS) + typedef DirReaderLinux DirReaderPosix; + #else + typedef DirReaderFallback DirReaderPosix; +diff --git a/src/base/files/file_path.cc b/src/base/files/file_path.cc +index f948ecf7577..abfbf333a2d +--- a/src/base/files/file_path.cc ++++ b/src/base/files/file_path.cc +@@ -1403,4 +1403,11 @@ bool FilePath::IsContentUri() const { + } + #endif + ++#if BUILDFLAG(IS_OHOS) ++bool FilePath::IsDataShareUri() const { ++ return StartsWith(path_, "datashare://", base::CompareCase::INSENSITIVE_ASCII) || ++ StartsWith(path_, "dataability://", base::CompareCase::INSENSITIVE_ASCII) || ++ StartsWith(path_, "file://media/", base::CompareCase::INSENSITIVE_ASCII); ++} ++#endif + } // namespace base +diff --git a/src/base/files/file_path.h b/src/base/files/file_path.h +index f9a98e0f055..0fce25f18ca +--- a/src/base/files/file_path.h ++++ b/src/base/files/file_path.h +@@ -477,6 +477,11 @@ class BASE_EXPORT FilePath { + bool IsContentUri() const; + #endif + ++#if BUILDFLAG(IS_OHOS) ++ // Return true if the path is a datashare uri or dataability, or false otherwise ++ bool IsDataShareUri() const; ++#endif ++ + private: + // Remove trailing separators from this object. If the path is absolute, it + // will never be stripped any more than to refer to the absolute root +diff --git a/src/base/files/file_util_posix.cc b/src/base/files/file_util_posix.cc +index 584d51b168e..fd23151aff5 +--- a/src/base/files/file_util_posix.cc ++++ b/src/base/files/file_util_posix.cc +@@ -66,6 +66,11 @@ + #include + #endif + ++ ++#if BUILDFLAG(IS_OHOS) ++#include "base/datashare_uri_utils.h" ++#endif ++ + // We need to do this on AIX due to some inconsistencies in how AIX + // handles XOPEN_SOURCE and ALL_SOURCE. + #if BUILDFLAG(IS_AIX) +@@ -430,6 +435,12 @@ bool PathExists(const FilePath& path) { + if (path.IsContentUri()) { + return ContentUriExists(path); + } ++#endif ++#if BUILDFLAG(IS_OHOS) ++ if(path.IsDataShareUri()) { ++ File file = OpenDatashareUriForRead(path); ++ return file.IsValid(); ++ } + #endif + return access(path.value().c_str(), F_OK) == 0; + } +@@ -785,11 +796,22 @@ bool GetFileInfo(const FilePath& file_path, File::Info* results) { + return file.GetInfo(results); + } else { + #endif // BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_OHOS) ++ if (file_path.IsDataShareUri()) { ++ File file = OpenDatashareUriForRead(file_path); ++ if (!file.IsValid()) ++ return false; ++ return file.GetInfo(results); ++ } else { ++#endif + if (File::Stat(file_path.value().c_str(), &file_info) != 0) + return false; + #if BUILDFLAG(IS_ANDROID) + } + #endif // BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_OHOS) ++ } ++#endif // BUILDFLAG(IS_OHOS) + + results->FromStat(file_info); + return true; +@@ -1123,8 +1145,16 @@ bool CopyFile(const FilePath& from_path, const FilePath& to_path) { + } else { + infile = File(from_path, File::FLAG_OPEN | File::FLAG_READ); + } ++#else ++#if BUILDFLAG(IS_OHOS) ++ if(from_path.IsDataShareUri()) { ++ infile = OpenDatashareUriForRead(from_path); ++ } else { ++ infile = File(from_path, File::FLAG_OPEN | File::FLAG_READ); ++ } + #else + infile = File(from_path, File::FLAG_OPEN | File::FLAG_READ); ++#endif + #endif + if (!infile.IsValid()) + return false; +diff --git a/src/base/files/memory_mapped_file.cc b/src/base/files/memory_mapped_file.cc +index 6e466b9f3ff..ee12abc4ee1 +--- a/src/base/files/memory_mapped_file.cc ++++ b/src/base/files/memory_mapped_file.cc +@@ -34,16 +34,46 @@ MemoryMappedFile::~MemoryMappedFile() { + return; + } + +- if (data_) { ++ if ((data_ != nullptr) && (mapper_ == nullptr)) { + delete [] data_; + data_ = nullptr; + } + length_ = 0; ++ mapper_.reset(); + #else + CloseHandles(); + #endif + } + ++#if BUILDFLAG(IS_OHOS) ++void MemoryMappedFile::SetOhosFileMapper(std::unique_ptr &mapper) { ++ if (IsValid()) { ++ if (customizeData_) { ++ if (mapper_ == nullptr) { ++ delete [] data_; ++ data_ = nullptr; ++ } else { ++ mapper_ = nullptr; ++ } ++ } else { ++ CloseHandles(); ++ } ++ } ++ ++ customizeData_ = true; ++ ++ if (!mapper->IsCompressed()) { ++ mapper_ = std::move(mapper); ++ data_ = reinterpret_cast(mapper_->GetDataPtr()); ++ length_ = mapper_->GetDataLen(); ++ } else { ++ std::unique_ptr dest; ++ mapper->UnzipData(dest, length_); ++ data_ = dest.release(); ++ } ++} ++#endif ++ + #if !BUILDFLAG(IS_NACL) + bool MemoryMappedFile::Initialize(const FilePath& file_name, Access access) { + if (IsValid()) +diff --git a/src/base/files/memory_mapped_file.h b/src/base/files/memory_mapped_file.h +index 2d96dfa52aa..312af7c694d +--- a/src/base/files/memory_mapped_file.h ++++ b/src/base/files/memory_mapped_file.h +@@ -18,6 +18,10 @@ + #include "base/win/scoped_handle.h" + #endif + ++#if BUILDFLAG(IS_OHOS) ++#include "ohos_adapter_helper.h" ++#endif ++ + namespace base { + + class FilePath; +@@ -116,10 +120,17 @@ class BASE_EXPORT MemoryMappedFile { + if (IsValid() && !customizeData_) { + CloseHandles(); + } ++ if (mapper_ == nullptr && data_ != nullptr) { ++ delete [] data_; ++ data_ = nullptr; ++ } ++ mapper_.reset(); + customizeData_ = true; + data_ = data.release(); + length_ = length; + } ++ ++ void SetOhosFileMapper(std::unique_ptr &mapper); + #endif + + private: +@@ -153,6 +164,7 @@ class BASE_EXPORT MemoryMappedFile { + size_t length_; + #if BUILDFLAG(IS_OHOS) + bool customizeData_ = false; ++ std::unique_ptr mapper_; + #endif + + #if BUILDFLAG(IS_WIN) +diff --git a/src/base/i18n/icu_util.cc b/src/base/i18n/icu_util.cc +index 87283aef6e1..2fc23f50154 +--- a/src/base/i18n/icu_util.cc ++++ b/src/base/i18n/icu_util.cc +@@ -277,19 +277,19 @@ int LoadIcuDataByHap(PlatformFile data_fd, + const MemoryMappedFile::Region& data_region, + std::unique_ptr* out_mapped_data_file, + UErrorCode* out_error_code) { +- size_t length = 0; +- std::unique_ptr data; + auto resourceInstance = OHOS::NWeb::OhosAdapterHelper::GetInstance().GetResourceAdapter(); +- if (!resourceInstance->GetRawFileData(kIcuDataFileNameHap, length, data, true)) { ++ std::unique_ptr fileMapper = nullptr; ++ if (!resourceInstance->GetRawFileMapper(kIcuDataFileNameHap, fileMapper, true)) { + LOG(ERROR) << "Couldn't mmap icu data file by hap: " << kIcuDataFileNameHap; + return 1; + } ++ LOG(INFO) << "icu data file length: " << fileMapper->GetDataLen(); + + *out_mapped_data_file = std::make_unique(); + (*out_error_code) = U_ZERO_ERROR; + InitializeExternalTimeZoneData(); +- (*out_mapped_data_file)->SetDataAndLength(data, length); +- LOG(INFO) << "icu data file length: " << length; ++ (*out_mapped_data_file)->SetOhosFileMapper(fileMapper); ++ + udata_setCommonData(const_cast((*out_mapped_data_file)->data()), out_error_code); + if (U_FAILURE(*out_error_code)) { + LOG(ERROR) << "Failed to initialize ICU with data file: " << u_errorName(*out_error_code); +diff --git a/src/base/logging.cc b/src/base/logging.cc +index 6f930c3dbc8..c1c8c6e7562 +--- a/src/base/logging.cc ++++ b/src/base/logging.cc +@@ -80,7 +80,7 @@ typedef HANDLE FileHandle; + #endif + + #if BUILDFLAG(IS_OHOS) +-#include "hilog/log.h" ++#include "hilog_adapter.h" + #endif + + #if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) +@@ -594,22 +594,6 @@ LogMessage::LogMessage(const char* file, int line, const char* condition) + stream_ << "Check failed: " << condition << ". "; + } + +-#if BUILDFLAG(IS_OHOS) +-extern "C" { +- int HiLogPrintArgs(LogType type, LogLevel level, unsigned int domain, const char* tag, const char* fmt, va_list ap); +-} +- +-int HiLogPrintOHOS(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...) +-{ +- int ret; +- va_list ap; +- va_start(ap, fmt); +- ret = HiLogPrintArgs(type, level, domain, tag, fmt, ap); +- va_end(ap); +- return ret; +-} +-#endif +- + LogMessage::~LogMessage() { + size_t stack_start = stream_.tellp(); + #if !defined(OFFICIAL_BUILD) && !BUILDFLAG(IS_NACL) && !defined(__UCLIBC__) && \ +@@ -835,26 +819,28 @@ LogMessage::~LogMessage() { + __android_log_write(priority, kAndroidLogTag, str_newline.c_str()); + #endif + #elif BUILDFLAG(IS_OHOS) +- LogLevel priority = +- (severity_ < 0) ? LogLevel::LOG_DEBUG : LogLevel::LOG_LEVEL_MAX; ++ auto priority = (severity_ < 0) ? OHOS::NWeb::LogLevelAdapter::DEBUG ++ : OHOS::NWeb::LogLevelAdapter::LEVEL_MAX; + switch (severity_) { + case LOGGING_INFO: +- priority = LogLevel::LOG_INFO; ++ priority = OHOS::NWeb::LogLevelAdapter::INFO; + break; + case LOGGING_WARNING: +- priority = LogLevel::LOG_WARN; ++ priority = OHOS::NWeb::LogLevelAdapter::WARN; + break; + case LOGGING_ERROR: +- priority = LogLevel::LOG_ERROR; ++ priority = OHOS::NWeb::LogLevelAdapter::ERROR; + break; + case LOGGING_FATAL: +- priority = LogLevel::LOG_FATAL; ++ priority = OHOS::NWeb::LogLevelAdapter::FATAL; + break; + case LOGGING_DEBUG: +- priority = LogLevel::LOG_DEBUG; ++ priority = OHOS::NWeb::LogLevelAdapter::DEBUG; + } + const char kOHOSLogTag[] = "chromium"; +- HiLogPrintOHOS(LOG_CORE, priority, 0xD004500, kOHOSLogTag, str_newline.c_str()); ++ OHOS::NWeb::HiLogAdapter::PrintLog(priority, kOHOSLogTag, ++ "%{public}s", ++ str_newline.c_str()); + #elif BUILDFLAG(IS_FUCHSIA) + // LogMessage() will silently drop the message if the logger is not valid. + // Skip the final character of |str_newline|, since LogMessage() will add +diff --git a/src/base/memory/discardable_memory.cc b/src/base/memory/discardable_memory.cc +index 77b0b291c66..a2007a3dbd1 +--- a/src/base/memory/discardable_memory.cc ++++ b/src/base/memory/discardable_memory.cc +@@ -10,9 +10,9 @@ + #include "base/metrics/field_trial_params.h" + #include "build/build_config.h" + +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + #include "third_party/ashmem/ashmem.h" +-#endif // BUILDFLAG(IS_ANDROID) ++#endif // BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + + namespace base { + +@@ -24,7 +24,7 @@ const base::Feature kMadvFreeDiscardableMemory{ + "MadvFreeDiscardableMemory", base::FEATURE_DISABLED_BY_DEFAULT}; + #endif // BUILDFLAG(IS_POSIX) + +-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_OHOS) + const base::Feature kDiscardableMemoryBackingTrial{ + "DiscardableMemoryBackingTrial", base::FEATURE_DISABLED_BY_DEFAULT}; + +@@ -43,13 +43,13 @@ const base::FeatureParam + &kDiscardableMemoryBackingParamOptions}; + + #endif // BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || +- // BUILDFLAG(IS_CHROMEOS) ++ // BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_OHOS) + + } // namespace features + + namespace { + +-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_OHOS) + + DiscardableMemoryBacking GetBackingForFieldTrial() { + DiscardableMemoryTrialGroup trial_group = +@@ -64,19 +64,19 @@ DiscardableMemoryBacking GetBackingForFieldTrial() { + NOTREACHED(); + } + #endif // BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || +- // BUILDFLAG(IS_CHROMEOS) ++ // BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_OHOS) + + } // namespace + +-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_OHOS) + + // Probe capabilities of this device to determine whether we should participate + // in the discardable memory backing trial. + bool DiscardableMemoryBackingFieldTrialIsEnabled() { +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + if (!ashmem_device_is_supported()) + return false; +-#endif // BUILDFLAG(IS_ANDROID) ++#endif // BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + if (base::GetMadvFreeSupport() != base::MadvFreeSupport::kSupported) + return false; + +@@ -91,24 +91,24 @@ DiscardableMemoryTrialGroup GetDiscardableMemoryBackingFieldTrialGroup() { + return features::kDiscardableMemoryBackingParam.Get(); + } + #endif // BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || +- // BUILDFLAG(IS_CHROMEOS) ++ // BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_OHOS) + + DiscardableMemory::DiscardableMemory() = default; + + DiscardableMemory::~DiscardableMemory() = default; + + DiscardableMemoryBacking GetDiscardableMemoryBacking() { +-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_OHOS) + if (DiscardableMemoryBackingFieldTrialIsEnabled()) { + return GetBackingForFieldTrial(); + } + #endif // BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || +- // BUILDFLAG(IS_CHROMEOS) ++ // BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_OHOS) + +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + if (ashmem_device_is_supported()) + return DiscardableMemoryBacking::kSharedMemory; +-#endif // BUILDFLAG(IS_ANDROID) ++#endif // BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + + #if BUILDFLAG(IS_POSIX) + if (base::FeatureList::IsEnabled( +diff --git a/src/base/memory/discardable_memory_internal.h b/src/base/memory/discardable_memory_internal.h +index 5b274454210..03971c7133a +--- a/src/base/memory/discardable_memory_internal.h ++++ b/src/base/memory/discardable_memory_internal.h +@@ -10,7 +10,7 @@ + #include "base/metrics/field_trial_params.h" + #include "build/build_config.h" + +-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_OHOS) + + namespace base { + +@@ -48,6 +48,6 @@ GetDiscardableMemoryBackingFieldTrialGroup(); + } // namespace base + + #endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || +- // BUILDFLAG(IS_ANDROID) ++ // BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + + #endif // BASE_MEMORY_DISCARDABLE_MEMORY_INTERNAL_H_ +diff --git a/src/base/memory/discardable_shared_memory.cc b/src/base/memory/discardable_shared_memory.cc +index b2e51258832..2bc8966028e +--- a/src/base/memory/discardable_shared_memory.cc ++++ b/src/base/memory/discardable_shared_memory.cc +@@ -26,7 +26,7 @@ + #include + #endif + +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + #include "third_party/ashmem/ashmem.h" + #endif + +@@ -122,7 +122,7 @@ size_t AlignToPageSize(size_t size) { + return bits::AlignUp(size, base::GetPageSize()); + } + +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + bool UseAshmemUnpinningForDiscardableMemory() { + if (!ashmem_device_is_supported()) + return false; +@@ -135,7 +135,7 @@ bool UseAshmemUnpinningForDiscardableMemory() { + } + return true; + } +-#endif // BUILDFLAG(IS_ANDROID) ++#endif // BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + + } // namespace + +@@ -275,7 +275,7 @@ DiscardableSharedMemory::LockResult DiscardableSharedMemory::Lock( + if (!length) + return PURGED; + +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + // Ensure that the platform won't discard the required pages. + return LockPages(shared_memory_region_, + AlignToPageSize(sizeof(SharedState)) + offset, length); +@@ -479,7 +479,7 @@ void DiscardableSharedMemory::ReleaseMemoryIfPossible(size_t offset, + #else // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) + #define MADV_PURGE_ARGUMENT MADV_FREE + #endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || +- // BUILDFLAG(IS_ANDROID) ++ // BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + // Advise the kernel to remove resources associated with purged pages. + // Subsequent accesses of memory pages will succeed, but might result in + // zero-fill-on-demand pages. +@@ -559,7 +559,7 @@ DiscardableSharedMemory::LockResult DiscardableSharedMemory::LockPages( + const UnsafeSharedMemoryRegion& region, + size_t offset, + size_t length) { +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + if (region.IsValid()) { + if (UseAshmemUnpinningForDiscardableMemory()) { + int pin_result = +@@ -579,7 +579,7 @@ void DiscardableSharedMemory::UnlockPages( + const UnsafeSharedMemoryRegion& region, + size_t offset, + size_t length) { +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + if (region.IsValid()) { + if (UseAshmemUnpinningForDiscardableMemory()) { + int unpin_result = +@@ -594,7 +594,7 @@ Time DiscardableSharedMemory::Now() const { + return Time::Now(); + } + +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + // static + bool DiscardableSharedMemory::IsAshmemDeviceSupportedForTesting() { + return UseAshmemUnpinningForDiscardableMemory(); +diff --git a/src/base/memory/discardable_shared_memory.h b/src/base/memory/discardable_shared_memory.h +index 8eebe95e67c..cd0763dd5aa +--- a/src/base/memory/discardable_shared_memory.h ++++ b/src/base/memory/discardable_shared_memory.h +@@ -160,7 +160,7 @@ class BASE_EXPORT DiscardableSharedMemory { + trace_event::ProcessMemoryDump* pmd, + bool is_owned) const; + +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + // Returns true if the Ashmem device is supported on this system. + // Only use this for unit-testing. + static bool IsAshmemDeviceSupportedForTesting(); +diff --git a/src/base/memory/platform_shared_memory_region.h b/src/base/memory/platform_shared_memory_region.h +index 8cb49016913..3618a913937 +--- a/src/base/memory/platform_shared_memory_region.h ++++ b/src/base/memory/platform_shared_memory_region.h +@@ -32,7 +32,7 @@ class SandboxIPCHandler; + namespace base { + namespace subtle { + +-#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_OHOS) + // Helper structs to keep two descriptors on POSIX. It's needed to support + // ConvertToReadOnly(). + struct BASE_EXPORT FDPair { +@@ -116,7 +116,7 @@ class BASE_EXPORT PlatformSharedMemoryRegion { + kMaxValue = GET_SHMEM_TEMP_DIR_FAILURE + }; + +-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_OHOS) ++#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) + // Structure to limit access to executable region creation. + struct ExecutableRegion { + private: +@@ -146,7 +146,7 @@ class BASE_EXPORT PlatformSharedMemoryRegion { + #elif BUILDFLAG(IS_WIN) + using PlatformHandle = HANDLE; + using ScopedPlatformHandle = win::ScopedHandle; +-#elif BUILDFLAG(IS_ANDROID) ++#elif BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + using PlatformHandle = int; + using ScopedPlatformHandle = ScopedFD; + #else +@@ -174,7 +174,7 @@ class BASE_EXPORT PlatformSharedMemoryRegion { + Mode mode, + size_t size, + const UnguessableToken& guid); +-#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC) ++#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_OHOS) + // Specialized version of Take() for POSIX that takes only one file descriptor + // instead of pair. Cannot be used with kWritable |mode|. + static PlatformSharedMemoryRegion Take(ScopedFD handle, +@@ -263,7 +263,7 @@ class BASE_EXPORT PlatformSharedMemoryRegion { + CheckPlatformHandlePermissionsCorrespondToMode); + static PlatformSharedMemoryRegion Create(Mode mode, + size_t size +-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_OHOS) ++#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) + , + bool executable = false + #endif +diff --git a/src/base/memory/platform_shared_memory_region_ohos.cc b/src/base/memory/platform_shared_memory_region_ohos.cc +new file mode 100644 +index 00000000000..2c9938ca37a +--- /dev/null ++++ b/src/base/memory/platform_shared_memory_region_ohos.cc +@@ -0,0 +1,203 @@ ++// Copyright (c) 2023 Huawei Device Co., Ltd. ++// Copyright 2018 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "base/memory/platform_shared_memory_region.h" ++ ++#include ++ ++#include "base/bits.h" ++#include "base/logging.h" ++#include "base/memory/page_size.h" ++#include "base/memory/shared_memory_tracker.h" ++#include "base/metrics/histogram_macros.h" ++#include "base/posix/eintr_wrapper.h" ++#include "third_party/ashmem/ashmem.h" ++ ++namespace base { ++namespace subtle { ++ ++// For OHOS, we use ashmem the same way Android does to implement SharedMemory. ++ ++namespace { ++ ++int GetAshmemRegionProtectionMask(int fd) { ++ int prot = ashmem_get_prot_region(fd); ++ if (prot < 0) { ++ PLOG(ERROR) << "ashmem_get_prot_region failed"; ++ return -1; ++ } ++ return prot; ++} ++ ++} // namespace ++ ++// static ++PlatformSharedMemoryRegion PlatformSharedMemoryRegion::Take( ++ ScopedFD fd, ++ Mode mode, ++ size_t size, ++ const UnguessableToken& guid) { ++ if (!fd.is_valid()) ++ return {}; ++ ++ if (size == 0) ++ return {}; ++ ++ if (size > static_cast(std::numeric_limits::max())) ++ return {}; ++ ++ CHECK(CheckPlatformHandlePermissionsCorrespondToMode(fd.get(), mode, size)); ++ ++ return PlatformSharedMemoryRegion(std::move(fd), mode, size, guid); ++} ++ ++int PlatformSharedMemoryRegion::GetPlatformHandle() const { ++ return handle_.get(); ++} ++ ++bool PlatformSharedMemoryRegion::IsValid() const { ++ return handle_.is_valid(); ++} ++ ++PlatformSharedMemoryRegion PlatformSharedMemoryRegion::Duplicate() const { ++ if (!IsValid()) ++ return {}; ++ ++ CHECK_NE(mode_, Mode::kWritable) ++ << "Duplicating a writable shared memory region is prohibited"; ++ ++ ScopedFD duped_fd(HANDLE_EINTR(dup(handle_.get()))); ++ if (!duped_fd.is_valid()) { ++ DPLOG(ERROR) << "dup(" << handle_.get() << ") failed"; ++ return {}; ++ } ++ ++ return PlatformSharedMemoryRegion(std::move(duped_fd), mode_, size_, guid_); ++} ++ ++bool PlatformSharedMemoryRegion::ConvertToReadOnly() { ++ if (!IsValid()) ++ return false; ++ ++ CHECK_EQ(mode_, Mode::kWritable) ++ << "Only writable shared memory region can be converted to read-only"; ++ ++ ScopedFD handle_copy(handle_.release()); ++ ++ int prot = GetAshmemRegionProtectionMask(handle_copy.get()); ++ if (prot < 0) ++ return false; ++ ++ prot &= ~PROT_WRITE; ++ int ret = ashmem_set_prot_region(handle_copy.get(), prot); ++ if (ret != 0) { ++ DPLOG(ERROR) << "ashmem_set_prot_region failed"; ++ return false; ++ } ++ ++ handle_ = std::move(handle_copy); ++ mode_ = Mode::kReadOnly; ++ return true; ++} ++ ++bool PlatformSharedMemoryRegion::ConvertToUnsafe() { ++ if (!IsValid()) ++ return false; ++ ++ CHECK_EQ(mode_, Mode::kWritable) ++ << "Only writable shared memory region can be converted to unsafe"; ++ ++ mode_ = Mode::kUnsafe; ++ return true; ++} ++ ++bool PlatformSharedMemoryRegion::MapAtInternal(off_t offset, ++ size_t size, ++ void** memory, ++ size_t* mapped_size) const { ++ // IMPORTANT: Even if the mapping is readonly and the mapped data is not ++ // changing, the region must ALWAYS be mapped with MAP_SHARED, otherwise with ++ // ashmem the mapping is equivalent to a private anonymous mapping. ++ bool write_allowed = mode_ != Mode::kReadOnly; ++ *memory = mmap(nullptr, size, PROT_READ | (write_allowed ? PROT_WRITE : 0), ++ MAP_SHARED, handle_.get(), offset); ++ ++ bool mmap_succeeded = *memory && *memory != reinterpret_cast(-1); ++ if (!mmap_succeeded) { ++ DPLOG(ERROR) << "mmap " << handle_.get() << " failed"; ++ return false; ++ } ++ ++ *mapped_size = size; ++ return true; ++} ++ ++// static ++PlatformSharedMemoryRegion PlatformSharedMemoryRegion::Create(Mode mode, ++ size_t size) { ++ if (size == 0) { ++ return {}; ++ } ++ ++ // Align size as required by ashmem_create_region() API documentation. This ++ // operation may overflow so check that the result doesn't decrease. ++ size_t rounded_size = bits::AlignUp(size, GetPageSize()); ++ if (rounded_size < size || ++ rounded_size > static_cast(std::numeric_limits::max())) { ++ return {}; ++ } ++ ++ CHECK_NE(mode, Mode::kReadOnly) << "Creating a region in read-only mode will " ++ "lead to this region being non-modifiable"; ++ ++ UnguessableToken guid = UnguessableToken::Create(); ++ ++ int fd = ashmem_create_region( ++ SharedMemoryTracker::GetDumpNameForTracing(guid).c_str(), rounded_size); ++ if (fd < 0) { ++ DPLOG(ERROR) << "ashmem_create_region failed"; ++ return {}; ++ } ++ ++ ScopedFD scoped_fd(fd); ++ int err = ashmem_set_prot_region(scoped_fd.get(), PROT_READ | PROT_WRITE); ++ if (err < 0) { ++ DPLOG(ERROR) << "ashmem_set_prot_region failed"; ++ return {}; ++ } ++ ++ return PlatformSharedMemoryRegion(std::move(scoped_fd), mode, size, guid); ++} ++ ++bool PlatformSharedMemoryRegion::CheckPlatformHandlePermissionsCorrespondToMode( ++ PlatformHandle handle, ++ Mode mode, ++ size_t size) { ++ int prot = GetAshmemRegionProtectionMask(handle); ++ if (prot < 0) ++ return false; ++ ++ bool is_read_only = (prot & PROT_WRITE) == 0; ++ bool expected_read_only = mode == Mode::kReadOnly; ++ ++ if (is_read_only != expected_read_only) { ++ LOG(ERROR) << "Ashmem region has a wrong protection mask: it is" ++ << (is_read_only ? " " : " not ") << "read-only but it should" ++ << (expected_read_only ? " " : " not ") << "be"; ++ return false; ++ } ++ ++ return true; ++} ++ ++PlatformSharedMemoryRegion::PlatformSharedMemoryRegion( ++ ScopedFD fd, ++ Mode mode, ++ size_t size, ++ const UnguessableToken& guid) ++ : handle_(std::move(fd)), mode_(mode), size_(size), guid_(guid) {} ++ ++} // namespace subtle ++} // namespace base +diff --git a/src/base/memory/platform_shared_memory_region_unittest.cc b/src/base/memory/platform_shared_memory_region_unittest.cc +index a04e990f120..2942a509c79 +--- a/src/base/memory/platform_shared_memory_region_unittest.cc ++++ b/src/base/memory/platform_shared_memory_region_unittest.cc +@@ -211,7 +211,7 @@ TEST_F(PlatformSharedMemoryRegionTest, MapAtWithOverflowTest) { + EXPECT_FALSE(mapping.IsValid()); + } + +-#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC) ++#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_OHOS) + // Tests that the second handle is closed after a conversion to read-only on + // POSIX. + TEST_F(PlatformSharedMemoryRegionTest, +diff --git a/src/base/memory/ref_counted.h b/src/base/memory/ref_counted.h +index ff570c11414..4ccecc4b17f +--- a/src/base/memory/ref_counted.h ++++ b/src/base/memory/ref_counted.h +@@ -13,6 +13,7 @@ + #include "base/base_export.h" + #include "base/check_op.h" + #include "base/compiler_specific.h" ++// TODO(dcheng): Remove this separately. + #include "base/gtest_prod_util.h" + #include "base/memory/scoped_refptr.h" + #include "base/sequence_checker.h" +@@ -110,7 +111,7 @@ class BASE_EXPORT RefCountedBase { + template + friend scoped_refptr base::AdoptRef(U*); + +- FRIEND_TEST_ALL_PREFIXES(RefCountedDeathTest, TestOverflowCheck); ++ friend class RefCountedOverflowTest; + + void Adopted() const { + #if DCHECK_IS_ON() +@@ -186,6 +187,8 @@ class BASE_EXPORT RefCountedThreadSafeBase { + template + friend scoped_refptr base::AdoptRef(U*); + ++ friend class RefCountedOverflowTest; ++ + void Adopted() const { + #if DCHECK_IS_ON() + DCHECK(needs_adopt_ref_); +@@ -201,7 +204,7 @@ class BASE_EXPORT RefCountedThreadSafeBase { + // MakeRefCounted. + DCHECK(!needs_adopt_ref_); + #endif +- ref_count_.Increment(); ++ CHECK_NE(ref_count_.Increment(), std::numeric_limits::max()); + } + + ALWAYS_INLINE void AddRefWithCheckImpl() const { +@@ -212,7 +215,9 @@ class BASE_EXPORT RefCountedThreadSafeBase { + // MakeRefCounted. + DCHECK(!needs_adopt_ref_); + #endif +- CHECK_GT(ref_count_.Increment(), 0); ++ int pre_increment_count = ref_count_.Increment(); ++ CHECK_GT(pre_increment_count, 0); ++ CHECK_NE(pre_increment_count, std::numeric_limits::max()); + } + + ALWAYS_INLINE bool ReleaseImpl() const { +@@ -305,9 +310,8 @@ class BASE_EXPORT ScopedAllowCrossThreadRefCountAccess final { + // And start-from-one ref count is a step to merge WTF::RefCounted into + // base::RefCounted. + // +-#define REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE() \ +- static constexpr ::base::subtle::StartRefCountFromOneTag \ +- kRefCountPreference = ::base::subtle::kStartRefCountFromOneTag ++#define REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE() \ ++ using RefCountPreferenceTag = ::base::subtle::StartRefCountFromOneTag + + template + class RefCounted; +@@ -322,10 +326,9 @@ struct DefaultRefCountedTraits { + template > + class RefCounted : public subtle::RefCountedBase { + public: +- static constexpr subtle::StartRefCountFromZeroTag kRefCountPreference = +- subtle::kStartRefCountFromZeroTag; ++ using RefCountPreferenceTag = subtle::StartRefCountFromZeroTag; + +- RefCounted() : subtle::RefCountedBase(T::kRefCountPreference) {} ++ RefCounted() : subtle::RefCountedBase(subtle::GetRefCountPreference()) {} + + RefCounted(const RefCounted&) = delete; + RefCounted& operator=(const RefCounted&) = delete; +@@ -390,16 +393,15 @@ struct DefaultRefCountedThreadSafeTraits { + template > + class RefCountedThreadSafe : public subtle::RefCountedThreadSafeBase { + public: +- static constexpr subtle::StartRefCountFromZeroTag kRefCountPreference = +- subtle::kStartRefCountFromZeroTag; ++ using RefCountPreferenceTag = subtle::StartRefCountFromZeroTag; + + explicit RefCountedThreadSafe() +- : subtle::RefCountedThreadSafeBase(T::kRefCountPreference) {} ++ : subtle::RefCountedThreadSafeBase(subtle::GetRefCountPreference()) {} + + RefCountedThreadSafe(const RefCountedThreadSafe&) = delete; + RefCountedThreadSafe& operator=(const RefCountedThreadSafe&) = delete; + +- void AddRef() const { AddRefImpl(T::kRefCountPreference); } ++ void AddRef() const { AddRefImpl(subtle::GetRefCountPreference()); } + + void Release() const { + if (subtle::RefCountedThreadSafeBase::Release()) { +diff --git a/src/base/memory/ref_counted_delete_on_sequence.h b/src/base/memory/ref_counted_delete_on_sequence.h +index 1a56d97e6de..0bacded1a95 +--- a/src/base/memory/ref_counted_delete_on_sequence.h ++++ b/src/base/memory/ref_counted_delete_on_sequence.h +@@ -32,14 +32,13 @@ namespace base { + template + class RefCountedDeleteOnSequence : public subtle::RefCountedThreadSafeBase { + public: +- static constexpr subtle::StartRefCountFromZeroTag kRefCountPreference = +- subtle::kStartRefCountFromZeroTag; ++ using RefCountPreferenceTag = subtle::StartRefCountFromZeroTag; + + // A SequencedTaskRunner for the current sequence can be acquired by calling + // SequencedTaskRunnerHandle::Get(). + explicit RefCountedDeleteOnSequence( + scoped_refptr owning_task_runner) +- : subtle::RefCountedThreadSafeBase(T::kRefCountPreference), ++ : subtle::RefCountedThreadSafeBase(subtle::GetRefCountPreference()), + owning_task_runner_(std::move(owning_task_runner)) { + DCHECK(owning_task_runner_); + } +@@ -48,7 +47,7 @@ class RefCountedDeleteOnSequence : public subtle::RefCountedThreadSafeBase { + RefCountedDeleteOnSequence& operator=(const RefCountedDeleteOnSequence&) = + delete; + +- void AddRef() const { AddRefImpl(T::kRefCountPreference); } ++ void AddRef() const { AddRefImpl(subtle::GetRefCountPreference()); } + + void Release() const { + if (subtle::RefCountedThreadSafeBase::Release()) +diff --git a/src/base/memory/ref_counted_unittest.cc b/src/base/memory/ref_counted_unittest.cc +index f6cb39b2ff1..2016005be1e +--- a/src/base/memory/ref_counted_unittest.cc ++++ b/src/base/memory/ref_counted_unittest.cc +@@ -177,15 +177,6 @@ class CheckRefptrNull : public base::RefCounted { + raw_ptr> ptr_ = nullptr; + }; + +-class Overflow : public base::RefCounted { +- public: +- Overflow() = default; +- +- private: +- friend class base::RefCounted; +- ~Overflow() = default; +-}; +- + } // namespace + + TEST(RefCountedUnitTest, TestSelfAssignment) { +@@ -693,12 +684,88 @@ TEST(RefCountedDeathTest, TestAdoptRef) { + } + + #if defined(ARCH_CPU_64_BITS) +-TEST(RefCountedDeathTest, TestOverflowCheck) { ++class RefCountedOverflowTest : public ::testing::Test { ++ public: ++ static uint32_t& GetMutableRefCount(RefCountedBase* ref_counted) { ++ return ref_counted->ref_count_; ++ } ++ ++ static std::atomic_int& GetMutableRefCount( ++ RefCountedThreadSafeBase* ref_counted) { ++ return ref_counted->ref_count_.ref_count_; ++ } ++}; ++ ++TEST_F(RefCountedOverflowTest, NonThreadSafeStartFromZero) { ++ class Overflow : public base::RefCounted { ++ public: ++ Overflow() { EXPECT_FALSE(HasOneRef()); } ++ ++ private: ++ friend class base::RefCounted; ++ ~Overflow() = default; ++ }; ++ ++ auto p = base::MakeRefCounted(); ++ GetMutableRefCount(p.get()) = std::numeric_limits::max(); ++ EXPECT_CHECK_DEATH(p->AddRef()); ++ // Ensure `p` doesn't leak and fail lsan builds. ++ GetMutableRefCount(p.get()) = 1; ++} ++ ++TEST_F(RefCountedOverflowTest, NonThreadSafeStartFromOne) { ++ class Overflow : public base::RefCounted { ++ public: ++ REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE(); ++ ++ Overflow() { EXPECT_TRUE(HasOneRef()); } ++ ++ private: ++ friend class base::RefCounted; ++ ~Overflow() = default; ++ }; ++ ++ auto p = base::MakeRefCounted(); ++ GetMutableRefCount(p.get()) = std::numeric_limits::max(); ++ EXPECT_CHECK_DEATH(p->AddRef()); ++ // Ensure `p` doesn't leak and fail lsan builds. ++ GetMutableRefCount(p.get()) = 1; ++} ++ ++TEST_F(RefCountedOverflowTest, ThreadSafeStartFromZero) { ++ class Overflow : public base::RefCountedThreadSafe { ++ public: ++ Overflow() { EXPECT_FALSE(HasOneRef()); } ++ ++ private: ++ friend class base::RefCountedThreadSafe; ++ ~Overflow() = default; ++ }; ++ ++ auto p = base::MakeRefCounted(); ++ GetMutableRefCount(p.get()) = std::numeric_limits::max(); ++ EXPECT_CHECK_DEATH(p->AddRef()); ++ // Ensure `p` doesn't leak and fail lsan builds. ++ GetMutableRefCount(p.get()) = 1; ++} ++ ++TEST_F(RefCountedOverflowTest, ThreadSafeStartFromOne) { ++ class Overflow : public base::RefCountedThreadSafe { ++ public: ++ REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE(); ++ ++ Overflow() { EXPECT_TRUE(HasOneRef()); } ++ ++ private: ++ friend class base::RefCountedThreadSafe; ++ ~Overflow() = default; ++ }; ++ + auto p = base::MakeRefCounted(); +- p->ref_count_ = std::numeric_limits::max(); ++ GetMutableRefCount(p.get()) = std::numeric_limits::max(); + EXPECT_CHECK_DEATH(p->AddRef()); + // Ensure `p` doesn't leak and fail lsan builds. +- p->ref_count_ = 1; ++ GetMutableRefCount(p.get()) = 1; + } + #endif + +diff --git a/src/base/memory/scoped_refptr.h b/src/base/memory/scoped_refptr.h +index ed70d55aac4..cb4202432af +--- a/src/base/memory/scoped_refptr.h ++++ b/src/base/memory/scoped_refptr.h +@@ -41,19 +41,37 @@ enum AdoptRefTag { kAdoptRefTag }; + enum StartRefCountFromZeroTag { kStartRefCountFromZeroTag }; + enum StartRefCountFromOneTag { kStartRefCountFromOneTag }; + ++template ++struct RefCountPreferenceTagTraits; ++ ++template <> ++struct RefCountPreferenceTagTraits { ++ static constexpr StartRefCountFromZeroTag kTag = kStartRefCountFromZeroTag; ++}; ++ ++template <> ++struct RefCountPreferenceTagTraits { ++ static constexpr StartRefCountFromOneTag kTag = kStartRefCountFromOneTag; ++}; ++ ++template ++constexpr Tag GetRefCountPreference() { ++ return RefCountPreferenceTagTraits::kTag; ++} ++ + template + constexpr bool IsRefCountPreferenceOverridden(const T*, + const RefCounted*) { +- return !std::is_same, +- std::decay_t>::value; ++ return !std::is_same_v())>, ++ std::decay_t())>>; + } + + template + constexpr bool IsRefCountPreferenceOverridden( + const T*, + const RefCountedThreadSafe*) { +- return !std::is_same, +- std::decay_t>::value; ++ return !std::is_same_v())>, ++ std::decay_t())>>; + } + + constexpr bool IsRefCountPreferenceOverridden(...) { +@@ -67,7 +85,7 @@ constexpr bool IsRefCountPreferenceOverridden(...) { + // from 1 instead of 0. + template + scoped_refptr AdoptRef(T* obj) { +- using Tag = std::decay_t; ++ using Tag = std::decay_t())>; + static_assert(std::is_same::value, + "Use AdoptRef only if the reference count starts from one."); + +@@ -96,7 +114,7 @@ scoped_refptr AdoptRefIfNeeded(T* obj, StartRefCountFromOneTag) { + template + scoped_refptr MakeRefCounted(Args&&... args) { + T* obj = new T(std::forward(args)...); +- return subtle::AdoptRefIfNeeded(obj, T::kRefCountPreference); ++ return subtle::AdoptRefIfNeeded(obj, subtle::GetRefCountPreference()); + } + + // Takes an instance of T, which is a ref counted type, and wraps the object +diff --git a/src/base/message_loop/message_pump_ohos.cc b/src/base/message_loop/message_pump_ohos.cc +index 9d56060d50c..14ff8d84901 +--- a/src/base/message_loop/message_pump_ohos.cc ++++ b/src/base/message_loop/message_pump_ohos.cc +@@ -8,9 +8,6 @@ + #include + #include + +-#include +-#include +- + #include "base/callback_helpers.h" + #include "base/check_op.h" + #include "base/lazy_instance.h" +@@ -18,6 +15,7 @@ + #include "base/notreached.h" + #include "base/run_loop.h" + #include "build/build_config.h" ++#include "ohos_adapter_helper.h" + #if defined(__MUSL__) + #include + #endif +@@ -36,7 +34,7 @@ namespace base { + namespace { + + class EventHandlerFileDescriptorListener +- : public OHOS::AppExecFwk::FileDescriptorListener { ++ : public OHOS::NWeb::EventHandlerFDListenerAdapter { + public: + explicit EventHandlerFileDescriptorListener(MessagePumpForUI* pump, + int non_delay_fd, +@@ -97,9 +95,10 @@ constexpr uint64_t kTryNativeTasksBeforeIdleBit = uint64_t(1) << 32; + } // namespace + + MessagePumpForUI::MessagePumpForUI() { +- ohos_event_handler_ = OHOS::AppExecFwk::EventHandler::Current(); +- if (!ohos_event_handler_) { +- LOG(ERROR) << "MessagePumpForUI get current event handler failed"; ++ ohos_event_handler_adapter_ = ++ OHOS::NWeb::OhosAdapterHelper::GetInstance().GetEventHandlerAdapter(); ++ if (!ohos_event_handler_adapter_) { ++ LOG(ERROR) << "MessagePumpForUI creat event handler adapter failed"; + return; + } + +@@ -116,17 +115,19 @@ MessagePumpForUI::MessagePumpForUI() { + + ohos_listener = std::make_shared( + this, non_delayed_fd_, delayed_fd_); +- ohos_event_handler_->AddFileDescriptorListener( +- non_delayed_fd_, OHOS::AppExecFwk::FILE_DESCRIPTOR_INPUT_EVENT, +- ohos_listener); +- ohos_event_handler_->AddFileDescriptorListener( +- delayed_fd_, OHOS::AppExecFwk::FILE_DESCRIPTOR_INPUT_EVENT, +- ohos_listener); ++ if (!ohos_event_handler_adapter_->AddFileDescriptorListener( ++ non_delayed_fd_, OHOS::NWeb::EventHandlerAdapter::INPUT_EVENT, ++ ohos_listener) || ++ !ohos_event_handler_adapter_->AddFileDescriptorListener( ++ delayed_fd_, OHOS::NWeb::EventHandlerAdapter::INPUT_EVENT, ++ ohos_listener)) { ++ LOG(ERROR) << "MessagePumpForUI AddFileDescriptorListener failed"; ++ }; + } + + MessagePumpForUI::~MessagePumpForUI() { +- ohos_event_handler_->RemoveFileDescriptorListener(non_delayed_fd_); +- ohos_event_handler_->RemoveFileDescriptorListener(delayed_fd_); ++ ohos_event_handler_adapter_->RemoveFileDescriptorListener(non_delayed_fd_); ++ ohos_event_handler_adapter_->RemoveFileDescriptorListener(delayed_fd_); + + close(non_delayed_fd_); + close(delayed_fd_); +diff --git a/src/base/message_loop/message_pump_ohos.h b/src/base/message_loop/message_pump_ohos.h +index 1997c75f856..992215bcb0c +--- a/src/base/message_loop/message_pump_ohos.h ++++ b/src/base/message_loop/message_pump_ohos.h +@@ -2,13 +2,13 @@ + #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_OHOS_H_ + + #include +-#include + + #include "base/base_export.h" + #include "base/callback.h" + #include "base/compiler_specific.h" + #include "base/message_loop/message_pump.h" + #include "base/time/time.h" ++#include "event_handler_adapter.h" + #include "third_party/abseil-cpp/absl/types/optional.h" + + namespace base { +@@ -82,8 +82,8 @@ class BASE_EXPORT MessagePumpForUI : public MessagePump { + // The file descriptor used to signal that delayed work is available. + int delayed_fd_; + +- std::shared_ptr ohos_event_handler_; +- std::shared_ptr ohos_listener; ++ std::unique_ptr ohos_event_handler_adapter_; ++ std::shared_ptr ohos_listener; + }; + + } // namespace base +diff --git a/src/base/metrics/field_trial.cc b/src/base/metrics/field_trial.cc +index a4f3b0ce3c4..d96cb961036 +--- a/src/base/metrics/field_trial.cc ++++ b/src/base/metrics/field_trial.cc +@@ -852,7 +852,7 @@ int FieldTrialList::GetFieldTrialDescriptor() { + if (!global_ || !global_->readonly_allocator_region_.IsValid()) + return -1; + +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + return global_->readonly_allocator_region_.GetPlatformHandle(); + #else + return global_->readonly_allocator_region_.GetPlatformHandle().fd; +diff --git a/src/base/metrics/field_trial_unittest.cc b/src/base/metrics/field_trial_unittest.cc +index 91b5907c44a..87fc641e3a7 +--- a/src/base/metrics/field_trial_unittest.cc ++++ b/src/base/metrics/field_trial_unittest.cc +@@ -1423,7 +1423,7 @@ TEST_F(FieldTrialListTest, SerializeSharedMemoryRegionMetadata) { + FieldTrialList::SerializeSharedMemoryRegionMetadata(shm.region, &options); + + #if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + int shm_fd = shm.region.GetPlatformHandle(); + #else + int shm_fd = shm.region.GetPlatformHandle().fd; +diff --git a/src/base/metrics/sample_vector.cc b/src/base/metrics/sample_vector.cc +index 5a7769d96f0..2e546952669 +--- a/src/base/metrics/sample_vector.cc ++++ b/src/base/metrics/sample_vector.cc +@@ -267,6 +267,12 @@ void SampleVectorBase::MoveSingleSampleToCounts() { + if (sample.count == 0) + return; + ++ // Stop here if the sample bucket would be out of range for the AtomicCount ++ // array. ++ if (sample.bucket >= counts_size()) { ++ return; ++ } ++ + // Move the value into storage. Sum and redundant-count already account + // for this entry so no need to call IncreaseSumAndCount(). + subtle::NoBarrier_AtomicIncrement(&counts()[sample.bucket], sample.count); +diff --git a/src/base/test/test_shared_memory_util.cc b/src/base/test/test_shared_memory_util.cc +index 17fd0b207e2..1267fcdcd8f +--- a/src/base/test/test_shared_memory_util.cc ++++ b/src/base/test/test_shared_memory_util.cc +@@ -132,7 +132,7 @@ bool CheckReadOnlyPlatformSharedMemoryRegionForTesting( + return CheckReadOnlySharedMemoryFuchsiaHandle(region.GetPlatformHandle()); + #elif BUILDFLAG(IS_WIN) + return CheckReadOnlySharedMemoryWindowsHandle(region.GetPlatformHandle()); +-#elif BUILDFLAG(IS_ANDROID) ++#elif BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + return CheckReadOnlySharedMemoryFdPosix(region.GetPlatformHandle()); + #else + return CheckReadOnlySharedMemoryFdPosix(region.GetPlatformHandle().fd); +diff --git a/src/base/trace_event/trace_event_ohos.cc b/src/base/trace_event/trace_event_ohos.cc +index 0d8e7f6aa3f..effe5505730 +--- a/src/base/trace_event/trace_event_ohos.cc ++++ b/src/base/trace_event/trace_event_ohos.cc +@@ -14,10 +14,12 @@ + */ + + #include "base/trace_event/trace_event_ohos.h" +- ++ + #include "base/logging.h" +-#include "hitrace_meter.h" +- ++#include "ohos_adapter_helper.h" ++ ++using OHOS::NWeb::OhosAdapterHelper; ++ + bool IsBytraceEnable() { + #if defined(ENABLE_OHOS_BYTRACE) + return true; +@@ -25,21 +27,21 @@ bool IsBytraceEnable() { + return false; + #endif + } +- ++ + BytraceArg GetArg(double i) { + BytraceArg arg; + arg.value.as_double = i; + arg.type = TYPE_NUMBER; + return arg; + } +- ++ + BytraceArg GetArg(const char* i) { + BytraceArg arg; + arg.value.as_string = i; + arg.type = TYPE_STRING; + return arg; + } +- ++ + std::string GetStringFromArg(const BytraceArg& arg) { + switch (arg.type) { + case TYPE_NUMBER: { +@@ -53,49 +55,54 @@ std::string GetStringFromArg(const BytraceArg& arg) { + } + } + } +- ++ + std::string GetStringWithArgs(const std::string& name) { + return name; + } +- ++ + void StartBytrace(const std::string& value) { + #if defined(ENABLE_OHOS_BYTRACE) +- StartTrace(HITRACE_TAG_NWEB, value); ++ OhosAdapterHelper::GetInstance().GetHiTraceAdapterInstance().StartTrace( ++ value); + #endif + } +- ++ + void FinishBytrace() { + #if defined(ENABLE_OHOS_BYTRACE) +- FinishTrace(HITRACE_TAG_NWEB); ++ OhosAdapterHelper::GetInstance().GetHiTraceAdapterInstance().FinishTrace(); + #endif + } +- ++ + void StartAsyncBytrace(const std::string& value, int32_t taskId) { + #if defined(ENABLE_OHOS_BYTRACE) +- StartAsyncTrace(HITRACE_TAG_NWEB, value, taskId); ++ OhosAdapterHelper::GetInstance().GetHiTraceAdapterInstance().StartAsyncTrace( ++ value, taskId); + #endif + } +- ++ + void FinishAsyncBytrace(const std::string& value, int32_t taskId) { + #if defined(ENABLE_OHOS_BYTRACE) +- FinishAsyncTrace(HITRACE_TAG_NWEB, value, taskId); ++ OhosAdapterHelper::GetInstance().GetHiTraceAdapterInstance().FinishAsyncTrace( ++ value, taskId); + #endif + } + + void CountBytrace(const std::string& name, int64_t count) { + #if defined(ENABLE_OHOS_BYTRACE) +- CountTrace(HITRACE_TAG_NWEB, name, count); +-#endif ++ OhosAdapterHelper::GetInstance().GetHiTraceAdapterInstance().CountTrace( ++ name, count); ++#endif + } +- ++ + ScopedBytrace::ScopedBytrace(const std::string& proc) : proc_(proc) { + #if defined(ENABLE_OHOS_BYTRACE) +- StartTrace(HITRACE_TAG_NWEB, proc_); ++ OhosAdapterHelper::GetInstance().GetHiTraceAdapterInstance().StartTrace( ++ proc_); + #endif + } +- ++ + ScopedBytrace::~ScopedBytrace() { + #if defined(ENABLE_OHOS_BYTRACE) +- FinishTrace(HITRACE_TAG_NWEB); ++ OhosAdapterHelper::GetInstance().GetHiTraceAdapterInstance().FinishTrace(); + #endif + } +diff --git a/src/build/config/compiler/BUILD.gn b/src/build/config/compiler/BUILD.gn +index 28ee784acd7..f0bb58ed147 +--- a/src/build/config/compiler/BUILD.gn ++++ b/src/build/config/compiler/BUILD.gn +@@ -1485,6 +1485,13 @@ config("default_warnings") { + "-Wno-error=non-c-typedef-for-linkage", + "-Wno-c++11-narrowing", + "-Wno-builtin-assume-aligned-alignment", ++ "-Wno-deprecated-builtins", ++ "-Wno-deprecated-non-prototype", ++ "-Wno-array-parameter", ++ "-Wno-error=unused-but-set-variable", ++ "-Wno-unused-but-set-variable", ++ "-Wno-deprecated-declarations", ++ "-Wno-unqualified-std-cast-call", + ] + } else { + cflags += [ +diff --git a/src/build/config/ohos/BUILD.gn b/src/build/config/ohos/BUILD.gn +index 5cb5cb6ccc4..cd29898a445 +--- a/src/build/config/ohos/BUILD.gn ++++ b/src/build/config/ohos/BUILD.gn +@@ -31,6 +31,9 @@ config("compiler") { + "_LIBCPP_HAS_MUSL_LIBC", + "__BUILD_LINUX_WITH_CLANG", + ] ++ if (current_cpu == "x64") { ++ defines += [ "PTRACE_GET_THREAD_AREA=25" ] ++ } + } else { + defines += [ "__BUILD_LINUX_WITH_CLANG" ] + } +@@ -80,8 +83,7 @@ config("compiler") { + compile_api_level = arm64_ndk_api_level + } + } else if (current_cpu == "x64") { +- abi_target = "" +- compile_api_level = "" ++ abi_target = "x86_64-linux-ohos" + } else { + assert(false, "Architecture not supported") + } +@@ -89,6 +91,9 @@ config("compiler") { + if (use_musl) { + cflags += [ "--target=$abi_target" ] + include_dirs = [ "$ohos_toolchain_root/include/libcxx-ohos/include/c++/v1" ] ++ if (current_cpu == "x64") { ++ include_dirs += [ "$ohos_sysroot/usr/include/x86_64-linux-ohos/asm-x86" ] ++ } + ldflags += [ "--target=$abi_target" ] + } else { + cflags += [ +@@ -125,13 +130,13 @@ config("runtime_library") { + defines = [ "__BUILD_LINUX_WITH_CLANG" ] + } + if (use_musl) { +- ldflags += [ "-Wl,--dynamic-linker,/lib/ld-musl-arm.so.1" ] ++ dynamic_linker = "/lib/ld-musl-arm.so.1" + + if (current_cpu == "arm") { + ldflags += [ "-L" + rebase_path("$ohos_sysroot/usr/lib/arm-linux-ohos", + root_build_dir) ] + ldflags += +- [ "-L" + rebase_path("$ohos_toolchain_root/lib/arm-linux-ohos/c++", ++ [ "-L" + rebase_path("$ohos_toolchain_root/lib/arm-linux-ohos", + root_build_dir) ] + ldflags += + [ "-L" + rebase_path( +@@ -141,21 +146,43 @@ config("runtime_library") { + } + + if (current_cpu == "arm64") { ++ dynamic_linker = "/lib/ld-musl-aarch64.so.1" + ldflags += [ "-Wl,-z,max-page-size=4096" ] + ldflags += [ "-Wl,--hash-style=gnu" ] + ldflags += + [ "-L" + rebase_path("$ohos_sysroot/usr/lib/aarch64-linux-ohos", + root_build_dir) ] + ldflags += [ "-L" + rebase_path( +- "$ohos_toolchain_root/lib/aarch64-linux-ohos/c++", ++ "$ohos_toolchain_root/lib/aarch64-linux-ohos", + root_build_dir) ] + ldflags += + [ "-L" + rebase_path( + "$ohos_toolchain_root/lib/clang/current/lib/aarch64-linux-ohos", + root_build_dir) ] + libclang_rt_file = "$ohos_toolchain_root/lib/clang/current/lib/aarch64-linux-ohos/libclang_rt.builtins.a" ++ ++ if (is_asan) { ++ libasan_file = "$ohos_toolchain_root/lib/clang/current/lib/aarch64-linux-ohos/libclang_rt.asan.so" ++ libs += [ rebase_path(libasan_file) ] ++ } ++ } ++ ++ if (current_cpu == "x64") { ++ ldflags += [ "-Wl,-z,max-page-size=4096" ] ++ ldflags += [ "-Wl,--hash-style=gnu" ] ++ ldflags += [ "-L" + rebase_path("$ohos_sysroot/usr/lib/x86_64-linux-ohos", ++ root_build_dir) ] ++ ldflags += ++ [ "-L" + rebase_path("$ohos_toolchain_root/lib/x86_64-linux-ohos", ++ root_build_dir) ] ++ ldflags += ++ [ "-L" + rebase_path( ++ "$ohos_toolchain_root/lib/clang/current/lib/x86_64-linux-ohos", ++ root_build_dir) ] ++ libclang_rt_file = "$ohos_toolchain_root/lib/clang/current/lib/x86_64-linux-ohos/libclang_rt.builtins.a" + } + ++ ldflags += [ "-Wl,--dynamic-linker,$dynamic_linker" ] + libs += [ + rebase_path(libclang_rt_file), + "c", +diff --git a/src/build/config/ohos/config.gni b/src/build/config/ohos/config.gni +index 882ca78b35d..6a133926342 +--- a/src/build/config/ohos/config.gni ++++ b/src/build/config/ohos/config.gni +@@ -53,84 +53,30 @@ if (is_ohos) { + ohos_ndk_root = "//../../../prebuilts" + ohos_build_root = "//../../.." + if (use_musl) { +- ohos_toolchain_root = "$ohos_ndk_root/clang/ohos/linux-x86_64/llvm" +- ohos_sysroot = "$ohos_build_root/out/rk3568/obj/third_party/musl" +- } else { +- ohos_toolchain_root = "$ohos_ndk_root/clang/host/linux-x86/clang-r353983c" +- if (current_cpu == "arm") { +- ohos_sysroot = "$ohos_ndk_root/aosp_prebuilt_libs/asdk_libs/ndk/platforms/current/arch-arm" +- } else if (current_cpu == "arm64") { +- ohos_sysroot = "$ohos_ndk_root/aosp_prebuilt_libs/asdk_libs/ndk/platforms/current/arch-arm64" ++ if (current_cpu == "x64") { ++ ohos_toolchain_root = "$ohos_ndk_root/clang/ohos/windows-x86_64/llvm" ++ ohos_sysroot = "$ohos_build_root/out/arm64/obj/third_party/musl" ++ ohos_libs_root = "$ohos_build_root/out/arm64/packages/phone/system/lib64" + } else { +- assert(false, "Unsupport target cpu") ++ ohos_toolchain_root = "$ohos_ndk_root/clang/ohos/linux-x86_64/llvm" ++ if (product_name == "rk3568") { ++ ohos_sysroot = "$ohos_build_root/out/rk3568/obj/third_party/musl" ++ if (current_cpu == "arm") { ++ ohos_libs_root = "$ohos_build_root/out/rk3568/packages/phone/system/lib" ++ } else { ++ ohos_libs_root = "$ohos_build_root/out/rk3568/packages/phone/system/lib64" ++ } ++ } else { ++ ohos_sysroot = "$ohos_build_root/out/generic_generic_arm_64only/hisi_newbaltimore_newphone_standard/obj/third_party/musl" ++ ohos_libs_root = "$ohos_build_root/out/generic_generic_arm_64only/hisi_newbaltimore_newphone_standard/packages/phone/system/lib64" ++ } + } ++ } else { ++ assert(false, "Unsupport Non-musl target!") + } + + # ohos include and libs dependencies +- ohos_src_includes = [ +- "$ohos_build_root/base/location/services/location_locator/callback/include", +- "$ohos_build_root/base/location/services/location_common/common/include", +- "$ohos_build_root/base/location/interfaces/inner_api/include", +- "$ohos_build_root/base/notification/eventhandler/interfaces/inner_api", +- "$ohos_build_root/base/location/services/utils/include", +- "$ohos_build_root/foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler/include", +- +- "$ohos_build_root/foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler/include", +- "$ohos_build_root/base/hiviewdfx/hilog/interfaces/native/innerkits/include", +- "$ohos_build_root/foundation/graphic/graphic_2d/interfaces/inner_api/common", +- "$ohos_build_root/drivers/peripheral/display/interfaces/include", +- "$ohos_build_root/foundation/graphic/graphic_2d/utils/buffer_handle/export", +- "$ohos_build_root/foundation/multimedia/player_framework/interfaces/inner_api/native", +- "$ohos_build_root/drivers/peripheral/base", +- "$ohos_build_root/foundation/graphic/graphic_2d/interfaces/inner_api/surface", +- "$ohos_build_root/foundation/graphic/surface/interfaces/kits", +- "$ohos_build_root/foundation/communication/ipc/interfaces/innerkits/ipc_core/include", +- "$ohos_build_root/base/inputmethod/imf/frameworks/inputmethod_controller/include", +- "$ohos_build_root/base/inputmethod/imf/services/include", +- "$ohos_build_root/base/inputmethod/imf/frameworks/inputmethod_ability/include", +- "$ohos_build_root/commonlibrary/c_utils/base/include", +- "$ohos_build_root/third_party/bounds_checking_function/include", +- "$ohos_build_root/foundation/multimodalinput/input/interfaces/native/innerkits/event/include", +- "$ohos_build_root/base/location/utils/include", +- "$ohos_build_root/base/location/interfaces/innerkits/locator_standard/include", +- "$ohos_build_root/base/location/location_common/common/include", +- "$ohos_build_root/foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include", +- "$ohos_build_root/utils/system/safwk/native/include", +- "$ohos_build_root/foundation/aafwk/standard/interfaces/innerkits/base/include", +- "$ohos_build_root/foundation/aafwk/standard/interfaces/innerkits/want/include/ohos/aafwk/content", +- "$ohos_build_root/foundation/appexecfwk/standard/common/log/include", +- "$ohos_build_root/foundation/appexecfwk/standard/common/perf/include", +- "$ohos_build_root/foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base/include", +- "$ohos_build_root/foundation/aafwk/standard/interfaces/innerkits/app_manager/include", +- "$ohos_build_root/foundation/distributedschedule/dmsfwk/services/dtbschedmgr/include", +- "$ohos_build_root/third_party/jsoncpp/include", +- "$ohos_build_root/third_party/json/include", +- "$ohos_build_root/base/security/access_token/interfaces/innerkits/accesstoken/include/", +- "$ohos_build_root/foundation/aafwk/standard/interfaces/innerkits/uri/include", +- "$ohos_build_root/base/web/webview/ohos_adapter/interfaces", +- "$ohos_build_root/base/location/services/location_common/common/include", +- "$ohos_build_root/base/location/interfaces/inner_api/include", +- "$ohos_build_root/base/location/services/utils/include", +- "$ohos_build_root/base/location/services/location_locator/callback/include", +- "$ohos_build_root/base/hiviewdfx/hitrace/interfaces/native/innerkits/include/hitrace_meter", +- "$ohos_build_root/base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include/", +- ] +- +- if (use_musl) { +- if (current_cpu == "arm") { +- ohos_libs_root = "$ohos_build_root/out/rk3568/packages/phone/system/lib" +- } else if (current_cpu == "arm64") { +- ohos_libs_root = +- "$ohos_build_root/out/rk3568/packages/phone/system/lib64" +- } +- } else { +- if (current_cpu == "arm") { +- ohos_libs_root = +- "$ohos_build_root/out/ohos-arm-release/packages/phone/system/lib" +- } else if (current_cpu == "arm64") { +- ohos_libs_root = "$ohos_build_root/out/ohos-arm64-release/packages/phone/system/lib64" +- } +- } ++ ohos_src_includes = [ "$ohos_build_root/base/web/webview/ohos_adapter/interfaces" ] + + ohos_libs_dir = [ + "$ohos_libs_root", +@@ -139,21 +85,17 @@ if (is_ohos) { + ] + } else { + if (use_musl) { +- ohos_build_root = "//ohos_ndk" +- ohos_ndk_root = "//ohos_ndk" ++ if (current_cpu == "x64") { ++ ohos_build_root = "//ohos_ndk_x86" ++ ohos_ndk_root = "//ohos_ndk_x86" ++ } else { ++ ohos_build_root = "//ohos_ndk" ++ ohos_ndk_root = "//ohos_ndk" ++ } + ohos_toolchain_root = "$ohos_ndk_root/toolchains/llvm" + ohos_sysroot = "$ohos_ndk_root/sysroot" + } else { +- ohos_build_root = "//ohos_ndk_aosp" +- ohos_ndk_root = "//ohos_ndk_aosp" +- ohos_toolchain_root = "$ohos_ndk_root/toolchains/clang-r353983c" +- if (current_cpu == "arm") { +- ohos_sysroot = "$ohos_ndk_root/aosp_prebuilt_libs/asdk_libs/ndk/platforms/current/arch-arm" +- } else if (current_cpu == "arm64") { +- ohos_sysroot = "$ohos_ndk_root/aosp_prebuilt_libs/asdk_libs/ndk/platforms/current/arch-arm64" +- } else { +- assert(false, "Unsupport target cpu") +- } ++ assert(false, "Unsupport Non-musl target!") + } + + if (use_ohos_sdk_sysroot) { +@@ -163,43 +105,14 @@ if (is_ohos) { + } + + # ohos include and libs dependencies, corresponding to gen_ohos_ndk.sh +- ohos_src_includes = [ +- "$ohos_build_root/includes/libeventhandler", +- "$ohos_build_root/includes/utils", +- "$ohos_build_root/includes/bounds_checking_function", +- "$ohos_build_root/includes/common", +- "$ohos_build_root/includes/display", +- "$ohos_build_root/includes/graphic_util", +- "$ohos_build_root/includes/media", +- "$ohos_build_root/includes/peripheral", +- "$ohos_build_root/includes/surface", +- "$ohos_build_root/includes/ipc_core", +- "$ohos_build_root/includes/inputmethod_controller", +- "$ohos_build_root/includes", +- "$ohos_build_root/includes/inputmethod_services", +- "$ohos_build_root/includes/inputmethod_ability", +- "$ohos_build_root/includes/multimodalinput", +- "$ohos_build_root/includes/location", +- "$ohos_build_root/includes/location_utils", +- "$ohos_build_root/includes/location_callback", +- "$ohos_build_root/includes/location_request_config", +- "$ohos_build_root/includes/system_ability", +- "$ohos_build_root/includes/accesstoken", +- "$ohos_build_root/includes/aafwk/want/include/ohos/aafwk/content", +- "$ohos_build_root/includes/aafwk/uri/include", +- "$ohos_build_root/includes/aafwk/app_manager/include", +- "$ohos_build_root/includes/aafwk/base/include", +- "$ohos_build_root/includes/json", +- "$ohos_build_root/includes/appexecfwk", +- "$ohos_build_root/includes/ohos_adapter", +- "$ohos_build_root/includes/hitrace_meter", +- "$ohos_build_root/includes/hisysevent", +- ] ++ ohos_src_includes = [ "$ohos_build_root/includes/ohos_adapter" ] + + if (current_cpu == "arm") { + ohos_libs_dir = [ "$ohos_build_root/libs" ] + } else if (current_cpu == "arm64") { + ohos_libs_dir = [ "$ohos_build_root/libs64" ] ++ } else if (current_cpu == "x64") { ++ ohos_libs_dir = [ "$ohos_build_root/libs64" ] + } + } + } +diff --git a/src/build/config/sanitizers/BUILD.gn b/src/build/config/sanitizers/BUILD.gn +index a046c194b42..1a04fbdf966 +--- a/src/build/config/sanitizers/BUILD.gn ++++ b/src/build/config/sanitizers/BUILD.gn +@@ -252,8 +252,10 @@ config("common_sanitizer_flags") { + + # Allow non-default toolchains to enable sanitizers in toolchain_args even + # in official builds. +- assert(current_toolchain != default_toolchain || !is_official_build, +- "sanitizers not supported in official builds") ++ if (!is_ohos) { ++ assert(current_toolchain != default_toolchain || !is_official_build, ++ "sanitizers not supported in official builds") ++ } + + cflags += [ + # Column info in debug data confuses Visual Studio's debugger, so don't +@@ -611,15 +613,16 @@ config("not_fuzzed") { + config("cfi_config") { + if (is_ohos) { + _cfi_blocklist_path = "//tools/cfi/ignores.txt" +- ++ + cflags = [ + "-flto=thin", + "-fvisibility=hidden", + "-fsanitize=cfi-icall", + "-fsanitize-cfi-icall-generalize-pointers", +- "-fsanitize-blacklist=" + rebase_path(_cfi_blocklist_path, root_build_dir), ++ "-fsanitize-blacklist=" + ++ rebase_path(_cfi_blocklist_path, root_build_dir), + ] +- ++ + ldflags = [ + "-flto=thin", + "-fsanitize=cfi-icall", +diff --git a/src/build/toolchain/ohos/BUILD.gn b/src/build/toolchain/ohos/BUILD.gn +index 2046bc1321a..b5572e699ae +--- a/src/build/toolchain/ohos/BUILD.gn ++++ b/src/build/toolchain/ohos/BUILD.gn +@@ -61,3 +61,9 @@ ohos_clang_toolchain("ohos_clang_arm64") { + current_cpu = "arm64" + } + } ++ ++ohos_clang_toolchain("ohos_clang_x64") { ++ toolchain_args = { ++ current_cpu = "x64" ++ } ++} +diff --git a/src/cc/input/browser_controls_offset_manager.cc b/src/cc/input/browser_controls_offset_manager.cc +index 9c6e0c946a7..480bba42d91 +--- a/src/cc/input/browser_controls_offset_manager.cc ++++ b/src/cc/input/browser_controls_offset_manager.cc +@@ -195,6 +195,13 @@ void BrowserControlsOffsetManager::UpdateBrowserControlsState( + + ResetAnimations(); + ++ // If we're about to animate the controls in, then restart the animation after ++ // the scroll completes. We don't know if a scroll is in progress, but that's ++ // okay; the flag will be reset when a scroll starts next in that case. ++ if (animate && direction == AnimationDirection::SHOWING_CONTROLS) { ++ show_controls_when_scroll_completes_ = true; ++ } ++ + if (animate) + SetupAnimation(direction); + else +@@ -387,6 +394,11 @@ void BrowserControlsOffsetManager::ScrollBegin() { + if (pinch_gesture_active_) + return; + ++ // If an animation to show the controls is in progress, re-order the animation ++ // to start after the scroll completes. This ensures that the user doesn't ++ // accidentally hide the controls with a gesture that would not normally be ++ // enough to hide them. ++ show_controls_when_scroll_completes_ = IsAnimatingToShowControls(); + ResetAnimations(); + ResetBaseline(); + } +@@ -459,8 +471,13 @@ gfx::Vector2dF BrowserControlsOffsetManager::ScrollBy( + + // If the controls are fully visible, treat the current position as the + // new baseline even if the gesture didn't end. +- if (TopControlsShownRatio() == 1.f && BottomControlsShownRatio() == 1.f) ++ if (TopControlsShownRatio() == 1.f && BottomControlsShownRatio() == 1.f) { + ResetBaseline(); ++ // Once the controls are fully visible, then any cancelled animation to show ++ // them isn't relevant; the user definitely sees the controls and can decide ++ // if they'd like to keep them. ++ show_controls_when_scroll_completes_ = false; ++ } + + ResetAnimations(); + +@@ -476,6 +493,13 @@ void BrowserControlsOffsetManager::ScrollEnd() { + if (pinch_gesture_active_) + return; + ++ // See if we should animate the top bar in, in case there was a race between ++ // chrome showing the controls and the user performing a scroll. ++ if (show_controls_when_scroll_completes_) { ++ SetupAnimation(AnimationDirection::SHOWING_CONTROLS); ++ return; ++ } ++ + StartAnimationIfNecessary(); + } + +diff --git a/src/cc/input/browser_controls_offset_manager.h b/src/cc/input/browser_controls_offset_manager.h +index ab5448abe55..d8bc10c8b4e +--- a/src/cc/input/browser_controls_offset_manager.h ++++ b/src/cc/input/browser_controls_offset_manager.h +@@ -81,6 +81,11 @@ class CC_EXPORT BrowserControlsOffsetManager { + std::pair BottomControlsShownRatioRange(); + + bool HasAnimation(); ++ bool IsAnimatingToShowControls() const { ++ return top_controls_animation_.IsInitialized() && ++ top_controls_animation_.Direction() == ++ AnimationDirection::SHOWING_CONTROLS; ++ } + + void UpdateBrowserControlsState(BrowserControlsState constraints, + BrowserControlsState current, +@@ -177,6 +182,15 @@ class CC_EXPORT BrowserControlsOffsetManager { + absl::optional> + bottom_min_height_offset_animation_range_; + ++ // Should ScrollEnd() animate the controls into view? This is used if there's ++ // a race between chrome starting an animation to show the controls while the ++ // user is doing a scroll gesture, which would cancel animations. We want to ++ // err on the side of showing the controls, so that the user realizes that ++ // they're an option. If we have started, but not yet completed an animation ++ // to show the controls when the scroll starts, or if one starts during the ++ // gesture, then we reorder the animation until after the scroll. ++ bool show_controls_when_scroll_completes_ = false; ++ + // Class that holds and manages the state of the controls animations. + class Animation { + public: +@@ -184,8 +198,8 @@ class CC_EXPORT BrowserControlsOffsetManager { + + // Whether the animation is initialized with a direction and start and stop + // values. +- bool IsInitialized() { return initialized_; } +- AnimationDirection Direction() { return direction_; } ++ bool IsInitialized() const { return initialized_; } ++ AnimationDirection Direction() const { return direction_; } + void Initialize(AnimationDirection direction, + float start_value, + float stop_value, +diff --git a/src/cc/input/browser_controls_offset_manager_unittest.cc b/src/cc/input/browser_controls_offset_manager_unittest.cc +index ce295d29eff..847cffc864e +--- a/src/cc/input/browser_controls_offset_manager_unittest.cc ++++ b/src/cc/input/browser_controls_offset_manager_unittest.cc +@@ -1299,5 +1299,65 @@ TEST(BrowserControlsOffsetManagerTest, + EXPECT_FLOAT_EQ(20.f, manager->TopControlsMinHeightOffset()); + } + ++// Tests that a "show" animation that's interrupted by a scroll is restarted ++// when the gesture completes. ++TEST(BrowserControlsOffsetManagerTest, ++ InterruptedShowAnimationsAreRestartedAfterScroll) { ++ MockBrowserControlsOffsetManagerClient client(100.f, 0.5f, 0.5f); ++ BrowserControlsOffsetManager* manager = client.manager(); ++ // Start off with the controls mostly hidden, so that they will, by default, ++ // try to fully hide at the end of a scroll. ++ client.SetCurrentBrowserControlsShownRatio(/*top_ratio=*/0.2, ++ /*bottom_ratio=*/0.2); ++ ++ EXPECT_FALSE(manager->HasAnimation()); ++ ++ // Start an animation to show the controls ++ manager->UpdateBrowserControlsState(BrowserControlsState::kBoth, ++ BrowserControlsState::kShown, true); ++ EXPECT_TRUE(manager->IsAnimatingToShowControls()); ++ ++ // Start a scroll, which should cancel the animation. ++ manager->ScrollBegin(); ++ EXPECT_FALSE(manager->HasAnimation()); ++ ++ // Finish the scroll, which should restart the show animation. Since the ++ // animation didn't run yet, the controls would auto-hide otherwise since they ++ // started almost hidden. ++ manager->ScrollEnd(); ++ EXPECT_TRUE(manager->IsAnimatingToShowControls()); ++} ++ ++// If chrome tries to animate in browser controls during a scroll gesture, it ++// should animate them in after the scroll completes. ++TEST(BrowserControlsOffsetManagerTest, ++ ShowingControlsDuringScrollStartsAnimationAfterScroll) { ++ MockBrowserControlsOffsetManagerClient client(100.f, 0.5f, 0.5f); ++ BrowserControlsOffsetManager* manager = client.manager(); ++ // Start off with the controls mostly hidden, so that they will, by default, ++ // try to fully hide at the end of a scroll. ++ client.SetCurrentBrowserControlsShownRatio(/*top_ratio=*/0.2, ++ /*bottom_ratio=*/0.2); ++ ++ EXPECT_FALSE(manager->HasAnimation()); ++ ++ // Start a scroll. Make sure that there's no animation running, else we're ++ // testing the wrong case. ++ ASSERT_FALSE(manager->HasAnimation()); ++ manager->ScrollBegin(); ++ EXPECT_FALSE(manager->HasAnimation()); ++ ++ // Start an animation to show the controls. ++ manager->UpdateBrowserControlsState(BrowserControlsState::kBoth, ++ BrowserControlsState::kShown, true); ++ EXPECT_TRUE(manager->IsAnimatingToShowControls()); ++ ++ // Finish the scroll, and the animation should still be in progress and/or ++ // restarted. We don't really care which, as long as it wasn't cancelled and ++ // is trying to show the controls. ++ manager->ScrollEnd(); ++ EXPECT_TRUE(manager->IsAnimatingToShowControls()); ++} ++ + } // namespace + } // namespace cc +diff --git a/src/cc/input/scrollbar_animation_controller.cc b/src/cc/input/scrollbar_animation_controller.cc +index 098d0419e4e..466794be153 +--- a/src/cc/input/scrollbar_animation_controller.cc ++++ b/src/cc/input/scrollbar_animation_controller.cc +@@ -73,7 +73,11 @@ ScrollbarAnimationController::ScrollbarAnimationController( + animation_change_(AnimationChange::NONE), + scroll_element_id_(scroll_element_id), + opacity_(initial_opacity), ++#if BUILDFLAG(IS_OHOS) ++ show_scrollbars_on_scroll_gesture_(false), ++#else + show_scrollbars_on_scroll_gesture_(true), ++#endif + need_thinning_animation_(true), + is_mouse_down_(false), + tickmarks_showing_(false) { +@@ -172,7 +176,7 @@ void ScrollbarAnimationController::RunAnimationFrame(float progress) { + } else { + opacity = std::min(1.f - progress, opacity_); + } +- ++ TRACE_EVENT2("base", "RunAnimationFrameScroollbar", "opacity", opacity, "progress", progress); + ApplyOpacityToScrollbars(opacity); + if (progress == 1.f) + StopAnimation(); +@@ -300,7 +304,11 @@ void ScrollbarAnimationController::DidMouseMove( + // scrollbar. + if (is_mouse_down_) + return; ++#if BUILDFLAG(IS_OHOS) ++ need_trigger_scrollbar_fade_in_ = MouseIsNearScrollbar(ScrollbarOrientation::HORIZONTAL); ++#else + need_trigger_scrollbar_fade_in_ = MouseIsNearAnyScrollbar(); ++#endif + if (need_trigger_scrollbar_fade_in_before != + need_trigger_scrollbar_fade_in_) { + if (need_trigger_scrollbar_fade_in_) { +diff --git a/src/cc/input/single_scrollbar_animation_controller_thinning.h b/src/cc/input/single_scrollbar_animation_controller_thinning.h +index 44eef269f1a..cd7daf43269 +--- a/src/cc/input/single_scrollbar_animation_controller_thinning.h ++++ b/src/cc/input/single_scrollbar_animation_controller_thinning.h +@@ -22,9 +22,13 @@ class ScrollbarAnimationControllerClient; + // ScrollbarAnimationControllerThinning for one scrollbar + class CC_EXPORT SingleScrollbarAnimationControllerThinning { + public: ++#if BUILDFLAG(IS_OHOS) ++ static constexpr float kIdleThicknessScale = 0.5f; ++ static constexpr float kMouseMoveDistanceToTriggerExpand = 8.f; ++#else + static constexpr float kIdleThicknessScale = 0.4f; + static constexpr float kMouseMoveDistanceToTriggerExpand = 25.f; +- ++#endif + static std::unique_ptr Create( + ElementId scroll_element_id, + ScrollbarOrientation orientation, +diff --git a/src/cc/resources/ui_resource_bitmap.cc b/src/cc/resources/ui_resource_bitmap.cc +index ca32943d825..e80e49748ca +--- a/src/cc/resources/ui_resource_bitmap.cc ++++ b/src/cc/resources/ui_resource_bitmap.cc +@@ -75,7 +75,7 @@ UIResourceBitmap::UIResourceBitmap(const SkBitmap& skbitmap) { + DCHECK(skbitmap.isImmutable()); + + const SkBitmap* target = &skbitmap; +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + SkBitmap copy; + if (features::IsDrDcEnabled()) { + // TODO(vikassoni): Forcing everything to N32 while android backing cannot +diff --git a/src/cc/trees/layer_tree_host_impl.cc b/src/cc/trees/layer_tree_host_impl.cc +index 0c4379cb20f..afd8f34faef +--- a/src/cc/trees/layer_tree_host_impl.cc ++++ b/src/cc/trees/layer_tree_host_impl.cc +@@ -157,6 +157,10 @@ static_assert(kContainsSrgbCacheSize == + gfx::DisplayColorSpaces::kConfigCount / 2, + "sRGB cache must match the size of DisplayColorSpaces"); + ++#if BUILDFLAG(IS_OHOS) ++static bool g_frameIsScrolling = false; ++#endif ++ + bool IsMobileOptimized(LayerTreeImpl* active_tree) { + return util::IsMobileOptimized(active_tree->min_page_scale_factor(), + active_tree->max_page_scale_factor(), +@@ -2605,6 +2609,12 @@ viz::CompositorFrame LayerTreeHostImpl::GenerateCompositorFrame( + TRACE_EVENT_SCOPE_THREAD, "x", + scroll_accumulated_this_frame_.x(), "y", + scroll_accumulated_this_frame_.y()); ++ ++#if BUILDFLAG(IS_OHOS) ++ g_frameIsScrolling = scroll_accumulated_this_frame_.x() != 0 || ++ scroll_accumulated_this_frame_.y() != 0; ++#endif ++ + scroll_accumulated_this_frame_ = gfx::Vector2dF(); + + bool is_new_trace; +@@ -2642,6 +2652,10 @@ viz::CompositorFrame LayerTreeHostImpl::GenerateCompositorFrame( + + viz::CompositorFrameMetadata metadata = MakeCompositorFrameMetadata(); + ++#if BUILDFLAG(IS_OHOS) ++ metadata.is_scrolling = g_frameIsScrolling; ++#endif ++ + std::map + shared_element_render_pass_id_map; +diff --git a/src/cef/BUILD.gn b/src/cef/BUILD.gn +index 4af75193cdc..8eec5633765 +--- a/src/cef/BUILD.gn ++++ b/src/cef/BUILD.gn +@@ -601,6 +601,8 @@ static_library("libcef_static") { + "libcef/browser/net_service/cookie_manager_impl.h", + "libcef/browser/net_service/login_delegate.cc", + "libcef/browser/net_service/login_delegate.h", ++ "libcef/browser/net_service/proxy_config_monitor.cc", ++ "libcef/browser/net_service/proxy_config_monitor.h", + "libcef/browser/net_service/proxy_url_loader_factory.cc", + "libcef/browser/net_service/proxy_url_loader_factory.h", + "libcef/browser/net_service/resource_handler_wrapper.cc", +@@ -641,6 +643,12 @@ static_library("libcef_static") { + "libcef/browser/osr/touch_handle_drawable_osr.h", + "libcef/browser/osr/touch_selection_controller_client_osr.cc", + "libcef/browser/osr/touch_selection_controller_client_osr.h", ++ "libcef/browser/page_load_metrics/alloy_page_load_metrics_memory_tracker_factory.cc", ++ "libcef/browser/page_load_metrics/alloy_page_load_metrics_memory_tracker_factory.h", ++ "libcef/browser/page_load_metrics/page_load_metrics_initialize.cc", ++ "libcef/browser/page_load_metrics/page_load_metrics_initialize.h", ++ "libcef/browser/page_load_metrics/oh_page_load_metrics_observer.h", ++ "libcef/browser/page_load_metrics/oh_page_load_metrics_observer.cc", + "libcef/browser/path_util_impl.cc", + "libcef/browser/permission/alloy_access_request.cc", + "libcef/browser/permission/alloy_access_request.h", +@@ -660,6 +668,8 @@ static_library("libcef_static") { + "libcef/browser/print_settings_impl.h", + "libcef/browser/printing/constrained_window_views_client.cc", + "libcef/browser/printing/constrained_window_views_client.h", ++ "libcef/browser/printing/ohos_print_manager.cc", ++ "libcef/browser/printing/ohos_print_manager.h", + "libcef/browser/printing/print_view_manager.cc", + "libcef/browser/printing/print_view_manager.h", + "libcef/browser/process_util_impl.cc", +@@ -812,6 +822,8 @@ static_library("libcef_static") { + "libcef/renderer/extensions/extensions_dispatcher_delegate.h", + "libcef/renderer/extensions/extensions_renderer_client.cc", + "libcef/renderer/extensions/extensions_renderer_client.h", ++ "libcef/renderer/extensions/ohos_print_render_frame_helper_delegate.cc", ++ "libcef/renderer/extensions/ohos_print_render_frame_helper_delegate.h", + "libcef/renderer/extensions/print_render_frame_helper_delegate.cc", + "libcef/renderer/extensions/print_render_frame_helper_delegate.h", + "libcef/renderer/frame_impl.cc", +@@ -914,8 +926,6 @@ static_library("libcef_static") { + "libcef/browser/printing/constrained_window_views_client.h", + "libcef/browser/printing/print_view_manager.cc", + "libcef/browser/printing/print_view_manager.h", +- "libcef/renderer/extensions/print_render_frame_helper_delegate.cc", +- "libcef/renderer/extensions/print_render_frame_helper_delegate.h", + ] + } + +@@ -1039,6 +1049,7 @@ static_library("libcef_static") { + "//third_party/widevine/cdm", + "//third_party/widevine/cdm:headers", + "//third_party/zlib:minizip", ++ "//third_party/pdfium", + "//ui/base", + "//ui/base/ime", + "//ui/events:events_base", +diff --git a/src/cef/cef_paths.gypi b/src/cef/cef_paths.gypi +index b82cb6579f4..cbea313772d +--- a/src/cef/cef_paths.gypi ++++ b/src/cef/cef_paths.gypi +@@ -8,7 +8,7 @@ + # by hand. See the translator.README.txt file in the tools directory for + # more information. + # +-# $hash=c0184bbfa08d5b1a2168f3886235203d2fa5b758$ ++# $hash=3db581bbfb19eeb907bf6c4ee979567e7e6d31c8$ + # + + { +@@ -48,6 +48,7 @@ + 'include/cef_keyboard_handler.h', + 'include/cef_life_span_handler.h', + 'include/cef_load_handler.h', ++ 'include/cef_media_handler.h', + 'include/cef_menu_model.h', + 'include/cef_menu_model_delegate.h', + 'include/cef_navigation_entry.h', +@@ -148,6 +149,7 @@ + 'include/capi/cef_keyboard_handler_capi.h', + 'include/capi/cef_life_span_handler_capi.h', + 'include/capi/cef_load_handler_capi.h', ++ 'include/capi/cef_media_handler_capi.h', + 'include/capi/cef_menu_model_capi.h', + 'include/capi/cef_menu_model_delegate_capi.h', + 'include/capi/cef_navigation_entry_capi.h', +@@ -344,6 +346,8 @@ + 'libcef_dll/cpptoc/list_value_cpptoc.h', + 'libcef_dll/ctocpp/load_handler_ctocpp.cc', + 'libcef_dll/ctocpp/load_handler_ctocpp.h', ++ 'libcef_dll/ctocpp/media_handler_ctocpp.cc', ++ 'libcef_dll/ctocpp/media_handler_ctocpp.h', + 'libcef_dll/cpptoc/views/menu_button_cpptoc.cc', + 'libcef_dll/cpptoc/views/menu_button_cpptoc.h', + 'libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.cc', +@@ -662,6 +666,8 @@ + 'libcef_dll/ctocpp/list_value_ctocpp.h', + 'libcef_dll/cpptoc/load_handler_cpptoc.cc', + 'libcef_dll/cpptoc/load_handler_cpptoc.h', ++ 'libcef_dll/cpptoc/media_handler_cpptoc.cc', ++ 'libcef_dll/cpptoc/media_handler_cpptoc.h', + 'libcef_dll/ctocpp/views/menu_button_ctocpp.cc', + 'libcef_dll/ctocpp/views/menu_button_ctocpp.h', + 'libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.cc', +diff --git a/src/cef/include/capi/cef_app_capi.h b/src/cef/include/capi/cef_app_capi.h +index f5418cdfd97..c11eab67dc6 +--- a/src/cef/include/capi/cef_app_capi.h ++++ b/src/cef/include/capi/cef_app_capi.h +@@ -33,7 +33,7 @@ + // by hand. See the translator.README.txt file in the tools directory for + // more information. + // +-// $hash=7713ef16c0c137b67ad926fafe2dfae35d187b48$ ++// $hash=c743a09408ec26e3af7b55f9b1040dd8fae208ae$ + // + + #ifndef CEF_INCLUDE_CAPI_CEF_APP_CAPI_H_ +@@ -194,6 +194,11 @@ CEF_EXPORT void cef_set_osmodal_loop(int osModalLoop); + /// + CEF_EXPORT void cef_enable_highdpi_support(); + ++/// ++// This function should be called on the main application thread. ++/// ++CEF_EXPORT void cef_apply_http_dns(); ++ + #ifdef __cplusplus + } + #endif +diff --git a/src/cef/include/capi/cef_browser_capi.h b/src/cef/include/capi/cef_browser_capi.h +index d0d087ab0df..bd10d4fe406 +--- a/src/cef/include/capi/cef_browser_capi.h ++++ b/src/cef/include/capi/cef_browser_capi.h +@@ -33,7 +33,7 @@ + // by hand. See the translator.README.txt file in the tools directory for + // more information. + // +-// $hash=097fc69d7b712dde294d45394bc0eff518a34689$ ++// $hash=096dfbe3499f8bf467bf2602b5899501a9fc7674$ + // + + #ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_ +@@ -143,6 +143,16 @@ typedef struct _cef_browser_t { + /// + void(CEF_CALLBACK* reload_original_url)(struct _cef_browser_t* self); + ++ /// ++ // display the selection control when click Free copy structure ++ /// ++ void(CEF_CALLBACK* select_and_copy)(struct _cef_browser_t* self); ++ ++ /// ++ // should show free copy menu ++ /// ++ int(CEF_CALLBACK* should_show_free_copy)(struct _cef_browser_t* self); ++ + /// + // Set user agent for current page. + /// +@@ -244,6 +254,24 @@ typedef struct _cef_browser_t { + // Is loading to different document. + /// + int(CEF_CALLBACK* should_show_loading_ui)(struct _cef_browser_t* self); ++ ++ /// ++ // Set force enable zoom. ++ /// ++ void(CEF_CALLBACK* set_force_enable_zoom)(struct _cef_browser_t* self, ++ int forceEnableZoom); ++ ++ /// ++ // Whether force enable zoom had been enabled. ++ /// ++ int(CEF_CALLBACK* get_force_enable_zoom)(struct _cef_browser_t* self); ++ ++ /// ++ // Set whether the target_blank pop-up window is opened in the current tab. ++ /// ++ void(CEF_CALLBACK* set_enable_blank_target_popup_intercept)( ++ struct _cef_browser_t* self, ++ int enableBlankTargetPopup); + } cef_browser_t; + + /// +@@ -1130,13 +1158,27 @@ typedef struct _cef_browser_host_t { + /// + int(CEF_CALLBACK* is_audio_muted)(struct _cef_browser_host_t* self); + ++ /// ++ // Set the audio resume interval of the broswer. ++ /// ++ void(CEF_CALLBACK* set_audio_resume_interval)( ++ struct _cef_browser_host_t* self, ++ int resumeInterval); ++ ++ /// ++ // Set whether the browser's audio is exclusive. ++ /// ++ void(CEF_CALLBACK* set_audio_exclusive)(struct _cef_browser_host_t* self, ++ int audioExclusive); ++ + /// + // Execute a string of JavaScript code, return result by callback + /// + void(CEF_CALLBACK* execute_java_script)( + struct _cef_browser_host_t* self, + const cef_string_t* code, +- struct _cef_java_script_result_callback_t* callback); ++ struct _cef_java_script_result_callback_t* callback, ++ int extention); + + /// + // Set native window from ohos rs +@@ -1255,6 +1297,21 @@ typedef struct _cef_browser_host_t { + /// + void(CEF_CALLBACK* set_cache_mode)(struct _cef_browser_host_t* self, + int falg); ++ ++ /// ++ // Set should frame submission before draw ++ /// ++ void(CEF_CALLBACK* set_should_frame_submission_before_draw)( ++ struct _cef_browser_host_t* self, ++ int should); ++ ++ /// ++ // Set zoom with the dela facetor ++ /// ++ void(CEF_CALLBACK* zoom_by)(struct _cef_browser_host_t* self, ++ float delta, ++ float width, ++ float height); + } cef_browser_host_t; + + /// +@@ -1307,7 +1364,7 @@ typedef struct _cef_java_script_result_callback_t { + /// + void(CEF_CALLBACK* on_java_script_exe_result)( + struct _cef_java_script_result_callback_t* self, +- const cef_string_t* result); ++ struct _cef_value_t* result); + } cef_java_script_result_callback_t; + + /// +diff --git a/src/cef/include/capi/cef_client_capi.h b/src/cef/include/capi/cef_client_capi.h +index 606e22de72f..2f46c1159f5 +--- a/src/cef/include/capi/cef_client_capi.h ++++ b/src/cef/include/capi/cef_client_capi.h +@@ -33,7 +33,7 @@ + // by hand. See the translator.README.txt file in the tools directory for + // more information. + // +-// $hash=100836d9c768fb63da4c355cb0571e34d0c6a8dd$ ++// $hash=4e00a9ba8322af0c50d7afe9a6af5438bfdca3b9$ + // + + #ifndef CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_ +@@ -54,6 +54,7 @@ + #include "include/capi/cef_keyboard_handler_capi.h" + #include "include/capi/cef_life_span_handler_capi.h" + #include "include/capi/cef_load_handler_capi.h" ++#include "include/capi/cef_media_handler_capi.h" + #include "include/capi/cef_permission_request_capi.h" + #include "include/capi/cef_print_handler_capi.h" + #include "include/capi/cef_process_message_capi.h" +@@ -176,6 +177,12 @@ typedef struct _cef_client_t { + struct _cef_request_handler_t*(CEF_CALLBACK* get_request_handler)( + struct _cef_client_t* self); + ++ /// ++ // Return the handler for browser media events. ++ /// ++ struct _cef_media_handler_t*(CEF_CALLBACK* get_media_handler)( ++ struct _cef_client_t* self); ++ + /// + // Return the handler for browser geolocation permission request events. + /// +diff --git a/src/cef/include/capi/cef_jsdialog_handler_capi.h b/src/cef/include/capi/cef_jsdialog_handler_capi.h +index 15d43781582..fbc1b947756 +--- a/src/cef/include/capi/cef_jsdialog_handler_capi.h ++++ b/src/cef/include/capi/cef_jsdialog_handler_capi.h +@@ -33,7 +33,7 @@ + // by hand. See the translator.README.txt file in the tools directory for + // more information. + // +-// $hash=f8dc9d32c3f345e1c3b7d02a098bebaafad7e81f$ ++// $hash=b1cf567f0ff92e9ca62280d3d99b3dafcca1018a$ + // + + #ifndef CEF_INCLUDE_CAPI_CEF_JSDIALOG_HANDLER_CAPI_H_ +@@ -113,6 +113,7 @@ typedef struct _cef_jsdialog_handler_t { + int(CEF_CALLBACK* on_before_unload_dialog)( + struct _cef_jsdialog_handler_t* self, + struct _cef_browser_t* browser, ++ const cef_string_t* url, + const cef_string_t* message_text, + int is_reload, + struct _cef_jsdialog_callback_t* callback); +diff --git a/src/cef/include/capi/cef_life_span_handler_capi.h b/src/cef/include/capi/cef_life_span_handler_capi.h +index e1db2aa4605..f09a4809eff +--- a/src/cef/include/capi/cef_life_span_handler_capi.h ++++ b/src/cef/include/capi/cef_life_span_handler_capi.h +@@ -33,7 +33,7 @@ + // by hand. See the translator.README.txt file in the tools directory for + // more information. + // +-// $hash=f9ae882bb6092d1f94b7c78dc6b45369c8b0ec2e$ ++// $hash=09c6688a8b0655876e4b8fa58563e9db744ba953$ + // + + #ifndef CEF_INCLUDE_CAPI_CEF_LIFE_SPAN_HANDLER_CAPI_H_ +@@ -109,7 +109,8 @@ typedef struct _cef_life_span_handler_t { + struct _cef_frame_t* frame, + const cef_string_t* target_url, + cef_window_open_disposition_t target_disposition, +- int user_gesture); ++ int user_gesture, ++ struct _cef_callback_t* callback); + + /// + // Called after a new browser is created. It is now safe to begin performing +diff --git a/src/cef/include/capi/cef_load_handler_capi.h b/src/cef/include/capi/cef_load_handler_capi.h +index e8f8e10193d..3786a7d0384 +--- a/src/cef/include/capi/cef_load_handler_capi.h ++++ b/src/cef/include/capi/cef_load_handler_capi.h +@@ -33,7 +33,7 @@ + // by hand. See the translator.README.txt file in the tools directory for + // more information. + // +-// $hash=bf5522dc1385a750cad8b9197a588045beaaba58$ ++// $hash=4c56790292e7dc7c00e3465a32f04aace17dab3a$ + // + + #ifndef CEF_INCLUDE_CAPI_CEF_LOAD_HANDLER_CAPI_H_ +@@ -165,6 +165,14 @@ typedef struct _cef_load_handler_t { + void(CEF_CALLBACK* on_data_resubmission)(struct _cef_load_handler_t* self, + struct _cef_browser_t* browser, + struct _cef_callback_t* callback); ++ ++ /// ++ // Called when the first content rendering of web page. ++ /// ++ void(CEF_CALLBACK* on_first_contentful_paint)( ++ struct _cef_load_handler_t* self, ++ long navigationStartTick, ++ long firstContentfulPaintMs); + } cef_load_handler_t; + + #ifdef __cplusplus +diff --git a/src/cef/include/capi/cef_media_handler_capi.h b/src/cef/include/capi/cef_media_handler_capi.h +new file mode 100644 +index 00000000000..d8e19296468 +--- /dev/null ++++ b/src/cef/include/capi/cef_media_handler_capi.h +@@ -0,0 +1,73 @@ ++// Copyright (c) 2023 Marshall A. Greenblatt. All rights reserved. ++// ++// Redistribution and use in source and binary forms, with or without ++// modification, are permitted provided that the following conditions are ++// met: ++// ++// * Redistributions of source code must retain the above copyright ++// notice, this list of conditions and the following disclaimer. ++// * Redistributions in binary form must reproduce the above ++// copyright notice, this list of conditions and the following disclaimer ++// in the documentation and/or other materials provided with the ++// distribution. ++// * Neither the name of Google Inc. nor the name Chromium Embedded ++// Framework nor the names of its contributors may be used to endorse ++// or promote products derived from this software without specific prior ++// written permission. ++// ++// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ++// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ++// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ++// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ++// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ++// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ++// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ++// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ++// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ++// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++// ++// --------------------------------------------------------------------------- ++// ++// This file was generated by the CEF translator tool and should not edited ++// by hand. See the translator.README.txt file in the tools directory for ++// more information. ++// ++// $hash=e823f91059dcf96103209e695047899105a83d5d$ ++// ++ ++#ifndef CEF_INCLUDE_CAPI_CEF_MEDIA_HANDLER_CAPI_H_ ++#define CEF_INCLUDE_CAPI_CEF_MEDIA_HANDLER_CAPI_H_ ++#pragma once ++ ++#include "include/capi/cef_base_capi.h" ++#include "include/capi/cef_browser_capi.h" ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++/// ++// Implement this structure to handle events related to browser media status. ++// The functions of this structure will be called on the browser process UI ++// thread or render process main thread (TID_RENDERER). ++/// ++typedef struct _cef_media_handler_t { ++ /// ++ // Base structure. ++ /// ++ cef_base_ref_counted_t base; ++ ++ /// ++ // Called when the audio state changed. ++ /// ++ void(CEF_CALLBACK* on_audio_state_changed)(struct _cef_media_handler_t* self, ++ struct _cef_browser_t* browser, ++ int audible); ++} cef_media_handler_t; ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif // CEF_INCLUDE_CAPI_CEF_MEDIA_HANDLER_CAPI_H_ +diff --git a/src/cef/include/capi/cef_render_handler_capi.h b/src/cef/include/capi/cef_render_handler_capi.h +index 16c82b8fa0c..a0d8c1cc679 +--- a/src/cef/include/capi/cef_render_handler_capi.h ++++ b/src/cef/include/capi/cef_render_handler_capi.h +@@ -33,7 +33,7 @@ + // by hand. See the translator.README.txt file in the tools directory for + // more information. + // +-// $hash=3a236866417ec98ad3fb5f325b07250a31c0183c$ ++// $hash=c63fd11f0986eb774ef2b9a66bfbcad76f247695$ + // + + #ifndef CEF_INCLUDE_CAPI_CEF_RENDER_HANDLER_CAPI_H_ +@@ -259,6 +259,15 @@ typedef struct _cef_render_handler_t { + const cef_string_t* selected_text, + const cef_range_t* selected_range); + ++ /// ++ // Called when text selection has changed for the specified |browser|. |text| ++ // is the currently text and |selected_range| is the character range. ++ /// ++ void(CEF_CALLBACK* on_selection_changed)(struct _cef_render_handler_t* self, ++ struct _cef_browser_t* browser, ++ const cef_string_t* text, ++ const cef_range_t* selected_range); ++ + /// + // Called when an on-screen keyboard should be shown or hidden for the + // specified |browser|. |input_mode| specifies what kind of keyboard should be +@@ -271,6 +280,24 @@ typedef struct _cef_render_handler_t { + struct _cef_browser_t* browser, + cef_text_input_mode_t input_mode, + int show_keyboard); ++ ++ /// ++ // Called when the cursor position has changed. ++ /// ++ void(CEF_CALLBACK* on_cursor_update)(struct _cef_render_handler_t* self, ++ struct _cef_browser_t* browser, ++ const cef_rect_t* rect); ++ ++ /// ++ /// Called when swap buffer completed with new size. ++ /// ++ void(CEF_CALLBACK* on_complete_swap_with_new_size)( ++ struct _cef_render_handler_t* self); ++ ++ /// ++ /// Called when resize not work. ++ /// ++ void(CEF_CALLBACK* on_resize_not_work)(struct _cef_render_handler_t* self); + } cef_render_handler_t; + + #ifdef __cplusplus +diff --git a/src/cef/include/capi/cef_request_capi.h b/src/cef/include/capi/cef_request_capi.h +index 66d1721d93b..d945b5609c5 +--- a/src/cef/include/capi/cef_request_capi.h ++++ b/src/cef/include/capi/cef_request_capi.h +@@ -33,7 +33,7 @@ + // by hand. See the translator.README.txt file in the tools directory for + // more information. + // +-// $hash=77ebea253e3607ed44c60791bb461a202d95c222$ ++// $hash=1320c06229c36ceb433a0bcf79ba66e8de87ca69$ + // + + #ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CAPI_H_ +@@ -214,6 +214,12 @@ typedef struct _cef_request_t { + // the browser process to track a single request across multiple callbacks. + /// + uint64(CEF_CALLBACK* get_identifier)(struct _cef_request_t* self); ++ ++ /// ++ // Returns whether the request was made for the main frame document. Will be ++ // false (0) for subresources or iframes ++ /// ++ int(CEF_CALLBACK* is_main_frame)(struct _cef_request_t* self); + } cef_request_t; + + /// +diff --git a/src/cef/include/cef_api_hash.h b/src/cef/include/cef_api_hash.h +index 058fd83436f..85ab4600c35 +--- a/src/cef/include/cef_api_hash.h ++++ b/src/cef/include/cef_api_hash.h +@@ -42,15 +42,15 @@ + // way that may cause binary incompatibility with other builds. The universal + // hash value will change if any platform is affected whereas the platform hash + // values will change only if that particular platform is affected. +-#define CEF_API_HASH_UNIVERSAL "fa7171a110d7f5a06e06c770c9224972d99054ec" ++#define CEF_API_HASH_UNIVERSAL "1e5fe1954370c8581c30f9d82304967b0ce8ab98" + #if defined(OS_WIN) +-#define CEF_API_HASH_PLATFORM "56a3fec8d1782d7f1bf12d13c6f61b5707282879" ++#define CEF_API_HASH_PLATFORM "9bb05bb47f001e3446b332deb14ceabb83d8353a" + #elif defined(OS_MAC) +-#define CEF_API_HASH_PLATFORM "c01d748bab5bbdd4b4ed03a6b91fddf28c5ce635" ++#define CEF_API_HASH_PLATFORM "0fc04834c09b7db01bcfbc983070af3d963148d4" + #elif defined(OS_LINUX) +-#define CEF_API_HASH_PLATFORM "61c970f2c3d3c064401adeb42d16a19566d577c2" ++#define CEF_API_HASH_PLATFORM "c8ef9afacf3306af98ccc9799d85fab90ec0ba66" + #elif defined(OS_OHOS) +-#define CEF_API_HASH_PLATFORM "61c970f2c3d3c064401adeb42d16a19566d577c2" ++#define CEF_API_HASH_PLATFORM "c8ef9afacf3306af98ccc9799d85fab90ec0ba66" + #endif + + #ifdef __cplusplus +diff --git a/src/cef/include/cef_app.h b/src/cef/include/cef_app.h +index 56fb715b7f4..64e1a96b0f1 +--- a/src/cef/include/cef_app.h ++++ b/src/cef/include/cef_app.h +@@ -137,6 +137,14 @@ void CefSetOSModalLoop(bool osModalLoop); + /*--cef(capi_name=cef_enable_highdpi_support)--*/ + void CefEnableHighDPISupport(); + ++/* ---------- ohos nweb add begin --------- */ ++/// ++// This function should be called on the main application thread. ++/// ++/*--cef()--*/ ++void CefApplyHttpDns(); ++/* ---------- ohos nweb add end --------- */ ++ + /// + // Implement this interface to provide handler implementations. Methods will be + // called by the process and/or thread indicated. +diff --git a/src/cef/include/cef_browser.h b/src/cef/include/cef_browser.h +index 33090400deb..916a92565fa +--- a/src/cef/include/cef_browser.h ++++ b/src/cef/include/cef_browser.h +@@ -146,6 +146,18 @@ class CefBrowser : public virtual CefBaseRefCounted { + /*--cef()--*/ + virtual void ReloadOriginalUrl() = 0; + ++ /// ++ // display the selection control when click Free copy interface ++ /// ++ /*--cef()--*/ ++ virtual void SelectAndCopy() = 0; ++ ++ /// ++ // should show free copy menu ++ /// ++ /*--cef()--*/ ++ virtual bool ShouldShowFreeCopy() = 0; ++ + /// + // Set user agent for current page. + /// +@@ -253,6 +265,24 @@ class CefBrowser : public virtual CefBaseRefCounted { + /// + /*--cef()--*/ + virtual bool ShouldShowLoadingUI() = 0; ++ ++ /// ++ // Set force enable zoom. ++ /// ++ /*--cef()--*/ ++ virtual void SetForceEnableZoom(bool forceEnableZoom) = 0; ++ ++ /// ++ // Whether force enable zoom had been enabled. ++ /// ++ /*--cef()--*/ ++ virtual bool GetForceEnableZoom() = 0; ++ ++ /// ++ // Set whether the target_blank pop-up window is opened in the current tab. ++ /// ++ /*--cef()--*/ ++ virtual void SetEnableBlankTargetPopupIntercept(bool enableBlankTargetPopup) = 0; + /* ---------- ohos_nweb_ex add end --------- */ + }; + +@@ -1171,13 +1201,26 @@ class CefBrowserHost : public virtual CefBaseRefCounted { + /*--cef()--*/ + virtual bool IsAudioMuted() = 0; + ++ /// ++ // Set the audio resume interval of the broswer. ++ /// ++ /*--cef()--*/ ++ virtual void SetAudioResumeInterval(int resumeInterval) = 0; ++ ++ /// ++ // Set whether the browser's audio is exclusive. ++ /// ++ /*--cef()--*/ ++ virtual void SetAudioExclusive(bool audioExclusive) = 0; ++ + /// + // Execute a string of JavaScript code, return result by callback + /// + /*--cef()--*/ + virtual void ExecuteJavaScript( + const CefString& code, +- CefRefPtr callback) = 0; ++ CefRefPtr callback, ++ bool extention) = 0; + + /// + // Set native window from ohos rs +@@ -1294,6 +1337,18 @@ class CefBrowserHost : public virtual CefBaseRefCounted { + /// + /*--cef()--*/ + virtual void SetCacheMode(int falg) = 0; ++ ++ /// ++ // Set should frame submission before draw ++ /// ++ /*--cef()--*/ ++ virtual void SetShouldFrameSubmissionBeforeDraw(bool should) = 0; ++ ++ /// ++ // Set zoom with the dela facetor ++ /// ++ /*--cef()--*/ ++ virtual void ZoomBy(float delta, float width, float height) = 0; + }; + + /// +@@ -1308,7 +1363,7 @@ class CefJavaScriptResultCallback : public virtual CefBaseRefCounted { + // number of cookies that were deleted. + /// + /*--cef()--*/ +- virtual void OnJavaScriptExeResult(const CefString& result) = 0; ++ virtual void OnJavaScriptExeResult(CefRefPtr result) = 0; + }; + + /* ---------- ohos webview add begin --------- */ +diff --git a/src/cef/include/cef_client.h b/src/cef/include/cef_client.h +index 5d47a0ee5ec..3d22478daf2 +--- a/src/cef/include/cef_client.h ++++ b/src/cef/include/cef_client.h +@@ -52,6 +52,7 @@ + #include "include/cef_keyboard_handler.h" + #include "include/cef_life_span_handler.h" + #include "include/cef_load_handler.h" ++#include "include/cef_media_handler.h" + #include "include/cef_permission_request.h" + #include "include/cef_print_handler.h" + #include "include/cef_process_message.h" +@@ -169,6 +170,12 @@ class CefClient : public virtual CefBaseRefCounted { + /*--cef()--*/ + virtual CefRefPtr GetRequestHandler() { return nullptr; } + ++ /// ++ // Return the handler for browser media events. ++ /// ++ /*--cef()--*/ ++ virtual CefRefPtr GetMediaHandler() { return nullptr; } ++ + /// + // Return the handler for browser geolocation permission request events. + /// +diff --git a/src/cef/include/cef_jsdialog_handler.h b/src/cef/include/cef_jsdialog_handler.h +index b7e0945056c..a68aaac9988 +--- a/src/cef/include/cef_jsdialog_handler.h ++++ b/src/cef/include/cef_jsdialog_handler.h +@@ -103,6 +103,7 @@ class CefJSDialogHandler : public virtual CefBaseRefCounted { + /// + /*--cef(optional_param=message_text)--*/ + virtual bool OnBeforeUnloadDialog(CefRefPtr browser, ++ const CefString& url, + const CefString& message_text, + bool is_reload, + CefRefPtr callback) { +diff --git a/src/cef/include/cef_life_span_handler.h b/src/cef/include/cef_life_span_handler.h +index fe63d8466e8..9bcbf829d9f +--- a/src/cef/include/cef_life_span_handler.h ++++ b/src/cef/include/cef_life_span_handler.h +@@ -102,7 +102,8 @@ public: + CefRefPtr frame, + const CefString& target_url, + WindowOpenDisposition target_disposition, +- bool user_gesture) { ++ bool user_gesture, ++ CefRefPtr callback) { + return true; + } + +diff --git a/src/cef/include/cef_load_handler.h b/src/cef/include/cef_load_handler.h +index c349ab3f8b6..04c4eb58636 +--- a/src/cef/include/cef_load_handler.h ++++ b/src/cef/include/cef_load_handler.h +@@ -157,6 +157,13 @@ class CefLoadHandler : public virtual CefBaseRefCounted { + /*--cef(optional_param=url)--*/ + virtual void OnDataResubmission(CefRefPtr browser, + CefRefPtr callback) {} ++ ++ /// ++ // Called when the first content rendering of web page. ++ /// ++ /*--cef()--*/ ++ virtual void OnFirstContentfulPaint(long navigationStartTick, ++ long firstContentfulPaintMs) {} + }; + + #endif // CEF_INCLUDE_CEF_LOAD_HANDLER_H_ +diff --git a/src/cef/include/cef_media_handler.h b/src/cef/include/cef_media_handler.h +new file mode 100644 +index 00000000000..adb853f74a6 +--- /dev/null ++++ b/src/cef/include/cef_media_handler.h +@@ -0,0 +1,61 @@ ++// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. ++// ++// Redistribution and use in source and binary forms, with or without ++// modification, are permitted provided that the following conditions are ++// met: ++// ++// * Redistributions of source code must retain the above copyright ++// notice, this list of conditions and the following disclaimer. ++// * Redistributions in binary form must reproduce the above ++// copyright notice, this list of conditions and the following disclaimer ++// in the documentation and/or other materials provided with the ++// distribution. ++// * Neither the name of Google Inc. nor the name Chromium Embedded ++// Framework nor the names of its contributors may be used to endorse ++// or promote products derived from this software without specific prior ++// written permission. ++// ++// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ++// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ++// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ++// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ++// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ++// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ++// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ++// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ++// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ++// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++// ++// --------------------------------------------------------------------------- ++// ++// The contents of this file must follow a specific format in order to ++// support the CEF translator tool. See the translator.README.txt file in the ++// tools directory for more information. ++// ++ ++#ifndef CEF_INCLUDE_CEF_MEDIA_HANDLER_H_ ++#define CEF_INCLUDE_CEF_MEDIA_HANDLER_H_ ++#pragma once ++ ++#include "include/cef_base.h" ++#include "include/cef_browser.h" ++ ++/// ++// Implement this interface to handle events related to browser media status. ++// The methods of this class will be called on the browser process UI thread or ++// render process main thread (TID_RENDERER). ++/// ++/*--cef(source=client)--*/ ++class CefMediaHandler : public virtual CefBaseRefCounted { ++ public: ++ ++ /// ++ // Called when the audio state changed. ++ /// ++ /*--cef()--*/ ++ virtual void OnAudioStateChanged(CefRefPtr browser, ++ bool audible) {} ++}; ++ ++#endif // CEF_INCLUDE_CEF_MEDIA_HANDLER_H_ +diff --git a/src/cef/include/cef_render_handler.h b/src/cef/include/cef_render_handler.h +index a078c5a5883..c994f5a409a +--- a/src/cef/include/cef_render_handler.h ++++ b/src/cef/include/cef_render_handler.h +@@ -258,6 +258,16 @@ class CefRenderHandler : public virtual CefBaseRefCounted { + const CefString& selected_text, + const CefRange& selected_range) {} + ++ /// ++ // Called when text selection has changed for the specified |browser|. ++ // |text| is the currently text and |selected_range| is ++ // the character range. ++ /// ++ /*--cef(optional_param=text,optional_param=selected_range)--*/ ++ virtual void OnSelectionChanged(CefRefPtr browser, ++ const CefString& text, ++ const CefRange& selected_range) {} ++ + /// + // Called when an on-screen keyboard should be shown or hidden for the + // specified |browser|. |input_mode| specifies what kind of keyboard +@@ -269,6 +279,25 @@ class CefRenderHandler : public virtual CefBaseRefCounted { + virtual void OnVirtualKeyboardRequested(CefRefPtr browser, + TextInputMode input_mode, + bool show_keyboard) {} ++ ++ /// ++ // Called when the cursor position has changed. ++ /// ++ /*--cef()--*/ ++ virtual void OnCursorUpdate(CefRefPtr browser, ++ const CefRect& rect) {} ++ ++ /// ++ /// Called when swap buffer completed with new size. ++ /// ++ /*--cef()--*/ ++ virtual void OnCompleteSwapWithNewSize() {} ++ ++ /// ++ /// Called when resize not work. ++ /// ++ /*--cef()--*/ ++ virtual void OnResizeNotWork() {} + }; + + #endif // CEF_INCLUDE_CEF_RENDER_HANDLER_H_ +diff --git a/src/cef/include/cef_request.h b/src/cef/include/cef_request.h +index cbe2d035937..b16e38774e5 +--- a/src/cef/include/cef_request.h ++++ b/src/cef/include/cef_request.h +@@ -218,6 +218,13 @@ class CefRequest : public virtual CefBaseRefCounted { + /// + /*--cef()--*/ + virtual uint64 GetIdentifier() = 0; ++ ++ /// ++ // Returns whether the request was made for the main frame document. ++ // Will be false for subresources or iframes ++ /// ++ /*--cef()--*/ ++ virtual bool IsMainFrame() = 0; + }; + + /// +diff --git a/src/cef/include/internal/cef_types.h b/src/cef/include/internal/cef_types.h +index 6ec7dd2e48e..c23cddb8232 +--- a/src/cef/include/internal/cef_types.h ++++ b/src/cef/include/internal/cef_types.h +@@ -681,6 +681,9 @@ typedef struct _cef_browser_settings_t { + #if BUILDFLAG(IS_OHOS) + cef_state_t hide_vertical_scrollbars; + cef_state_t hide_horizontal_scrollbars; ++ bool contextmenu_customization_enabled; ++ cef_color_t scrollbar_color; ++ bool blank_target_popup_intercept_enabled; + #endif + /* ohos webview end */ + } cef_browser_settings_t; +@@ -1803,6 +1806,10 @@ typedef struct _cef_touch_event_t { + /// + cef_pointer_type_t pointer_type; + ++ /// ++ // The touch is from overlay. ++ /// ++ bool from_overlay; + } cef_touch_event_t; + + /// +diff --git a/src/cef/include/internal/cef_types_wrappers.h b/src/cef/include/internal/cef_types_wrappers.h +index d69abfcbf52..31ac7203968 +--- a/src/cef/include/internal/cef_types_wrappers.h ++++ b/src/cef/include/internal/cef_types_wrappers.h +@@ -750,6 +750,11 @@ struct CefBrowserSettingsTraits { + #if BUILDFLAG(IS_OHOS) + target->hide_vertical_scrollbars = src->hide_vertical_scrollbars; + target->hide_horizontal_scrollbars = src->hide_horizontal_scrollbars; ++ target->contextmenu_customization_enabled = ++ src->contextmenu_customization_enabled; ++ target->scrollbar_color = src->scrollbar_color; ++ target->blank_target_popup_intercept_enabled = ++ src->blank_target_popup_intercept_enabled; + #endif + /* ohos webview end */ + } +diff --git a/src/cef/libcef/browser/alloy/alloy_browser_host_impl.cc b/src/cef/libcef/browser/alloy/alloy_browser_host_impl.cc +index ec9cc632fb8..5761fafe0b5 +--- a/src/cef/libcef/browser/alloy/alloy_browser_host_impl.cc ++++ b/src/cef/libcef/browser/alloy/alloy_browser_host_impl.cc +@@ -37,6 +37,7 @@ + #include "base/command_line.h" + #include "chrome/browser/picture_in_picture/picture_in_picture_window_manager.h" + #include "content/browser/gpu/compositor_util.h" ++#include "content/browser/media/session/media_session_impl.h" + #include "content/browser/renderer_host/render_widget_host_impl.h" + #include "content/public/browser/desktop_media_id.h" + #include "content/public/browser/file_select_listener.h" +@@ -61,6 +62,10 @@ + + #include "libcef/browser/osr/touch_selection_controller_client_osr.h" + ++#if BUILDFLAG(IS_OHOS) ++#include "base/logging.h" ++#endif ++ + using content::KeyboardEventProcessingResult; + + namespace { +@@ -334,7 +339,7 @@ void AlloyBrowserHostImpl::CloseBrowser(bool force_close) { + #if BUILDFLAG(IS_OHOS) + // In cef_life_span_handler.h file show DoClose step. + // Step 1 to Step 3 is over. +- // This will replace Step 4 : User approves the close. Beause both in ++ // This will replace Step 4 : User approves the close. Beause both in + // Android and OH close will not be blocked by beforeunload event. + CloseContents(contents); + #endif +@@ -1130,6 +1135,24 @@ bool AlloyBrowserHostImpl::IsAudioMuted() { + return web_contents()->IsAudioMuted(); + } + ++void AlloyBrowserHostImpl::SetAudioResumeInterval(int resumeInterval) { ++ content::MediaSessionImpl* mediaSession = content::MediaSessionImpl::Get(web_contents()); ++ if (!mediaSession) { ++ LOG(ERROR) << "AlloyBrowserHostImpl::SetAudioResumeInterval get mediaSession failed."; ++ return; ++ } ++ mediaSession->audioResumeInterval_ = resumeInterval; ++} ++ ++void AlloyBrowserHostImpl::SetAudioExclusive(bool audioExclusive) { ++ content::MediaSessionImpl* mediaSession = content::MediaSessionImpl::Get(web_contents()); ++ if (!mediaSession) { ++ LOG(ERROR) << "AlloyBrowserHostImpl::SetAudioExclusive get mediaSession failed."; ++ return; ++ } ++ mediaSession->audioExclusive_ = audioExclusive; ++} ++ + // content::WebContentsDelegate methods. + // ----------------------------------------------------------------------------- + +@@ -1292,6 +1315,9 @@ void AlloyBrowserHostImpl::SetBackgroundColor(int color) { + + base_background_color_ = color; + OnWebPreferencesChanged(); ++#if BUILDFLAG(IS_OHOS) ++ UpdateBackgroundColor(color); ++#endif + } + + void AlloyBrowserHostImpl::UpdateBackgroundColor(int color) { +@@ -1625,6 +1651,13 @@ void AlloyBrowserHostImpl::DidFinishNavigation( + } + + void AlloyBrowserHostImpl::OnAudioStateChanged(bool audible) { ++#if BUILDFLAG(IS_OHOS) ++ LOG(INFO) << "OnAudioStateChanged: " << audible; ++ if (client_.get() && client_->GetMediaHandler().get()) { ++ client_->GetMediaHandler()->OnAudioStateChanged(this, audible); ++ } ++#endif // BUILDFLAG(IS_OHOS) ++ + if (audible) { + if (recently_audible_timer_) + recently_audible_timer_->Stop(); +@@ -1808,3 +1841,18 @@ void AlloyBrowserHostImpl::AddVisitedLinks(const std::vector& urls) { + } + } + } ++ ++#if BUILDFLAG(IS_OHOS) ++void AlloyBrowserHostImpl::SetShouldFrameSubmissionBeforeDraw(bool should) { ++ if (!CEF_CURRENTLY_ON_UIT()) { ++ CEF_POST_TASK(CEF_UIT, ++ base::BindOnce( ++ &AlloyBrowserHostImpl::SetShouldFrameSubmissionBeforeDraw, ++ this, should)); ++ return; ++ } ++ ++ if (platform_delegate_) ++ platform_delegate_->SetShouldFrameSubmissionBeforeDraw(should); ++} ++#endif +diff --git a/src/cef/libcef/browser/alloy/alloy_browser_host_impl.h b/src/cef/libcef/browser/alloy/alloy_browser_host_impl.h +index f134101b58c..41d17678e14 +--- a/src/cef/libcef/browser/alloy/alloy_browser_host_impl.h ++++ b/src/cef/libcef/browser/alloy/alloy_browser_host_impl.h +@@ -140,6 +140,8 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase, + void DragSourceEndedAt(int x, int y, DragOperationsMask op) override; + void SetAudioMuted(bool mute) override; + bool IsAudioMuted() override; ++ void SetAudioResumeInterval(int resumeInterval) override; ++ void SetAudioExclusive(bool audioExclusive) override; + void SetAccessibilityState(cef_state_t accessibility_state) override; + void SetAutoResizeEnabled(bool enabled, + const CefSize& min_size, +@@ -192,6 +194,7 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase, + CefFileDialogRunner::RunFileChooserCallback callback); + #if BUILDFLAG(IS_OHOS) + bool ShowContextMenu(const content::ContextMenuParams& params); ++ void SetShouldFrameSubmissionBeforeDraw(bool should) override; + #else + bool HandleContextMenu(content::WebContents* web_contents, + const content::ContextMenuParams& params); +diff --git a/src/cef/libcef/browser/alloy/alloy_content_browser_client.cc b/src/cef/libcef/browser/alloy/alloy_content_browser_client.cc +index f472e101210..3d2d6289479 +--- a/src/cef/libcef/browser/alloy/alloy_content_browser_client.cc ++++ b/src/cef/libcef/browser/alloy/alloy_content_browser_client.cc +@@ -9,6 +9,8 @@ + #include + #include + ++#include "base/command_line.h" ++#include "content/public/common/content_switches.h" + #include "include/cef_version.h" + #include "libcef/browser/alloy/alloy_browser_context.h" + #include "libcef/browser/alloy/alloy_browser_host_impl.h" +@@ -16,6 +18,7 @@ + #include "libcef/browser/alloy/alloy_client_cert_identity.h" + #include "libcef/browser/alloy/alloy_client_cert_lookup_table.h" + #include "libcef/browser/alloy/alloy_ssl_platform_key.h" ++#include "libcef/browser/alloy/alloy_ssl_platform_key_ohos.h" + #include "libcef/browser/alloy/alloy_web_contents_view_delegate.h" + #include "libcef/browser/browser_context.h" + #include "libcef/browser/browser_frame.h" +@@ -171,11 +174,22 @@ + #endif + + #if BUILDFLAG(IS_OHOS) ++#include "base/timer/timer.h" ++#include "base/values.h" ++#include "components/page_load_metrics/browser/metrics_navigation_throttle.h" ++#include "components/page_load_metrics/browser/metrics_web_contents_observer.h" ++#include "components/page_load_metrics/browser/page_load_metrics_embedder_base.h" ++#include "components/page_load_metrics/browser/page_load_metrics_memory_tracker.h" ++#include "libcef/browser/page_load_metrics/page_load_metrics_initialize.h" ++#include "libcef/browser/printing/ohos_print_manager.h" ++#include "net/proxy_resolution/proxy_config_service_ohos.h" ++#include "net/proxy_resolution/proxy_resolution_service.h" + #include "printing/buildflags/buildflags.h" + #if BUILDFLAG(ENABLE_PRINT_PREVIEW) + #include "chrome/services/printing/printing_service.h" + #include "libcef/browser/printing/print_view_manager.h" + #endif ++#include "services/network/public/mojom/network_service.mojom.h" + #endif + + #if BUILDFLAG(IS_OHOS) && BUILDFLAG(ENABLE_PLUGINS) +@@ -197,6 +211,8 @@ + #include "content/public/browser/url_loader_request_interceptor.h" + #endif + ++constexpr int32_t APPLICATION_API_10 = 10; ++ + namespace { + void TransferVector(const std::vector& source, + std::vector& target) { +@@ -419,6 +435,19 @@ class CefSelectClientCertificateCallbackImpl + delegate->ContinueWithCertificate(nullptr, nullptr); + } + ++ static int32_t GetApplicationApiVersion() { ++ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kOhosAppApiVersion)) { ++ LOG(ERROR) << "kOhosAppApiVersion not exist"; ++ return -1; ++ } ++ std::string apiVersion = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( ++ switches::kOhosAppApiVersion); ++ if (apiVersion.empty()) { ++ return -1; ++ } ++ return std::stoi(apiVersion); ++ } ++ + static scoped_refptr WrapOpenSSLPrivateKey( + bssl::UniquePtr key) { + if (!key) +@@ -429,6 +458,18 @@ class CefSelectClientCertificateCallbackImpl + net::GetSSLPlatformKeyTaskRunner()); + } + ++ static scoped_refptr WrapOpenSSLPrivateKeyOHOS( ++ const std::string& private_key_file) { ++ if (!private_key_file.c_str()) { ++ LOG(ERROR) << "WrapOpenSSLPrivateKey, private key file is null"; ++ return nullptr; ++ } ++ ++ return base::MakeRefCounted( ++ std::make_unique(private_key_file), ++ net::GetSSLPlatformKeyTaskRunner()); ++ } ++ + static net::ClientCertIdentityList ClientCertIdentityListFromCertificateList( + const net::CertificateList& certs) { + net::ClientCertIdentityList result; +@@ -444,23 +485,30 @@ class CefSelectClientCertificateCallbackImpl + CefRefPtr cert, + const std::string& private_key_file, + std::string& pkcs8) { +- CBS cbs; +- CBS_init(&cbs, reinterpret_cast(pkcs8.data()), +- pkcs8.size()); +- bssl::UniquePtr pkey(EVP_parse_private_key(&cbs)); +- if (!pkey || CBS_len(&cbs) != 0) { +- LOG(ERROR) << "AcquirePrivateKey: EVP parse private key failed, pkey = " +- << pkey << ", CBS length = " << CBS_len(&cbs); +- return; +- } ++ scoped_refptr ssl_private_key = nullptr; ++ if (GetApplicationApiVersion() < APPLICATION_API_10) { ++ CBS cbs; ++ CBS_init(&cbs, reinterpret_cast(pkcs8.data()), ++ pkcs8.size()); ++ bssl::UniquePtr pkey(EVP_parse_private_key(&cbs)); ++ if (!pkey || CBS_len(&cbs) != 0) { ++ LOG(ERROR) << "AcquirePrivateKey: EVP parse private key failed, pkey = " ++ << pkey << ", CBS length = " << CBS_len(&cbs); ++ return; ++ } + +- scoped_refptr ssl_private_key = +- WrapOpenSSLPrivateKey(std::move(pkey)); +- if (!ssl_private_key) { +- LOG(ERROR) << "AcquirePrivateKey: ssl private key parse failed"; +- return; ++ ssl_private_key = WrapOpenSSLPrivateKey(std::move(pkey)); ++ if (!ssl_private_key) { ++ LOG(ERROR) << "AcquirePrivateKey: ssl private key parse failed"; ++ return; ++ } ++ } else { ++ ssl_private_key = WrapOpenSSLPrivateKeyOHOS(private_key_file); ++ if (!ssl_private_key) { ++ LOG(ERROR) << "AcquirePrivateKey: ssl private key parse failed"; ++ return; ++ } + } +- + RunWithPrivateKey(std::move(delegate), cert, ssl_private_key); + } + +@@ -473,24 +521,77 @@ class CefSelectClientCertificateCallbackImpl + LOG(INFO) << "CefSelectClientCertificateCallbackImpl::RunSelectNow"; + CEF_REQUIRE_UIT(); + +- // Client certificate file read +- std::string cert_data; +- base::FilePath src_root_cert; +- base::PathService::Get(base::DIR_SOURCE_ROOT, &src_root_cert); +- if (!base::ReadFileToString(src_root_cert.AppendASCII(cert_chain_file), +- &cert_data)) { +- LOG(ERROR) << "RunSelectNow: read cert file to string failed"; +- return; +- } ++ net::CertificateList certsList; ++ if (GetApplicationApiVersion() < APPLICATION_API_10) { ++ // Client certificate file read ++ std::string cert_data; ++ base::FilePath src_root_cert; ++ base::PathService::Get(base::DIR_SOURCE_ROOT, &src_root_cert); ++ if (!base::ReadFileToString(src_root_cert.AppendASCII(cert_chain_file), ++ &cert_data)) { ++ LOG(ERROR) << "RunSelectNow: read cert file to string failed"; ++ return; ++ } + +- // Convert the client certificates file to X509 +- net::CertificateList certsList = +- net::X509Certificate::CreateCertificateListFromBytes( +- base::as_bytes(base::make_span(cert_data)), +- net::X509Certificate::FORMAT_AUTO); +- if (certsList.empty()) { +- LOG(ERROR) << "RunSelectNow: certs list is empty"; +- return; ++ // Convert the client certificates file to X509 ++ certsList = ++ net::X509Certificate::CreateCertificateListFromBytes( ++ base::as_bytes(base::make_span(cert_data)), ++ net::X509Certificate::FORMAT_AUTO); ++ if (certsList.empty()) { ++ LOG(ERROR) << "RunSelectNow: certs list is empty"; ++ return; ++ } ++ } else { ++ //Get client certificate from ohos cert manager ++ auto RootCertDataAdapter = OHOS::NWeb::OhosAdapterHelper::GetInstance().GetRootCertDataAdapter(); ++ if (RootCertDataAdapter == nullptr) { ++ LOG(ERROR) << "RunSelectNow: root cert data adapter is null"; ++ return; ++ } ++ char* uri = new char[private_key_file.length() + 1]; ++ if (uri == nullptr) { ++ LOG(ERROR) << "RunSelectNow: new uri memory failed"; ++ return; ++ } ++ ++ uint32_t i = 0; ++ for (; i < private_key_file.length(); i++) { ++ uri[i] = private_key_file[i]; ++ } ++ uri[i] = '\0'; ++ ++ auto certMaxSize = RootCertDataAdapter->GetAppCertMaxSize(); ++ uint8_t* certData = new uint8_t[certMaxSize]; ++ if (certData == nullptr) { ++ LOG(ERROR) << "RunSelectNow: new cert data memory failed"; ++ delete[] uri; ++ return; ++ } ++ ++ memset(certData, 0, certMaxSize); ++ uint32_t len = 0; ++ RootCertDataAdapter->GetAppCert((uint8_t*)uri, certData, &len); ++ if (len == 0) { ++ LOG(ERROR) << "RunSelectNow: get app cert failed"; ++ delete[] uri; ++ delete[] certData; ++ return; ++ } ++ ++ certsList = ++ net::X509Certificate::CreateCertificateListFromBytes( ++ base::as_bytes(base::make_span(static_cast(certData), len)), ++ net::X509Certificate::FORMAT_AUTO); ++ if (certsList.empty()) { ++ LOG(ERROR) << "RunSelectNow: certs list is empty"; ++ delete[] uri; ++ delete[] certData; ++ return; ++ } ++ ++ delete[] uri; ++ delete[] certData; + } + + auto client_certs = ClientCertIdentityListFromCertificateList(certsList); +@@ -517,12 +618,14 @@ class CefSelectClientCertificateCallbackImpl + + // Private key file read + std::string prikey_data; +- base::FilePath src_root_prikey; +- base::PathService::Get(base::DIR_SOURCE_ROOT, &src_root_prikey); +- if (!base::ReadFileToString(src_root_prikey.AppendASCII(private_key_file), +- &prikey_data)) { +- LOG(ERROR) << "RunSelectNow: private key file to string failed"; +- return; ++ if (GetApplicationApiVersion() < APPLICATION_API_10) { ++ base::FilePath src_root_prikey; ++ base::PathService::Get(base::DIR_SOURCE_ROOT, &src_root_prikey); ++ if (!base::ReadFileToString(src_root_prikey.AppendASCII(private_key_file), ++ &prikey_data)) { ++ LOG(ERROR) << "RunSelectNow: private key file to string failed"; ++ return; ++ } + } + + AcquirePrivateKey(std::move(delegate), certs[0], private_key_file, +@@ -604,7 +707,7 @@ class CefQuotaPermissionContext : public content::QuotaPermissionContext { + ~CefQuotaPermissionContext() override = default; + }; + +-#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_OHOS) ++#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) + breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost( + const std::string& process_type) { + base::FilePath dumps_path; +@@ -615,7 +718,12 @@ breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost( + // AlloyMainDelegate::InitCrashReporter. + breakpad::CrashHandlerHostLinux* crash_handler = + new breakpad::CrashHandlerHostLinux(process_type, dumps_path, +- true /* upload */); ++#if BUILDFLAG(IS_OHOS) ++ false /* upload */ ++#else ++ true /* upload */ ++#endif // BUILDFLAG(IS_OHOS) ++ ); + crash_handler->StartUploaderThread(); + return crash_handler; + } +@@ -699,6 +807,59 @@ const extensions::Extension* GetEnabledExtensionFromSiteURL( + return registry->enabled_extensions().GetByID(site_url.host()); + } + ++#if BUILDFLAG(IS_OHOS) ++static constexpr base::TimeDelta kPopupWindowCallbackTimeout = base::Milliseconds(500); ++class PopupWindowCallbackImpl: public CefCallback { ++public: ++ explicit PopupWindowCallbackImpl(content::mojom::FrameHost::GetCreateNewWindowCallback callback) ++ : callback_(std::move(callback)), task_runner_(base::SequencedTaskRunnerHandle::Get()) { ++ timeout_timer_ = std::make_unique(); ++ if (timeout_timer_) { ++ timeout_timer_->Start( ++ FROM_HERE, kPopupWindowCallbackTimeout, ++ base::BindOnce(&PopupWindowCallbackImpl::Cancel, this)); ++ } ++ } ++ ++ ~PopupWindowCallbackImpl() override { ++ if (timeout_timer_) { ++ timeout_timer_->Stop(); ++ timeout_timer_.reset(); ++ } ++ } ++ ++ void Continue() override { ++ if (task_runner_ && !task_runner_->RunsTasksInCurrentSequence()) { ++ task_runner_->PostTask( ++ FROM_HERE, base::BindOnce(&PopupWindowCallbackImpl::Continue, this)); ++ return; ++ } ++ LOG(INFO) << "PopupWindowCallbackImpl Continue"; ++ if (!callback_.is_null()) { ++ std::move(callback_).Run(content::mojom::CreateNewWindowStatus::kSuccess); ++ } ++ } ++ ++ void Cancel() override { ++ if (task_runner_ && !task_runner_->RunsTasksInCurrentSequence()) { ++ task_runner_->PostTask( ++ FROM_HERE, base::BindOnce(&PopupWindowCallbackImpl::Cancel, this)); ++ return; ++ } ++ LOG(INFO) << "PopupWindowCallbackImpl Cancel"; ++ if (!callback_.is_null()) { ++ std::move(callback_).Run(content::mojom::CreateNewWindowStatus::kBlocked); ++ } ++ } ++private: ++ content::mojom::FrameHost::GetCreateNewWindowCallback callback_; ++ scoped_refptr task_runner_; ++ std::unique_ptr timeout_timer_; ++ ++ IMPLEMENT_REFCOUNTING(PopupWindowCallbackImpl); ++}; ++#endif ++ + } // namespace + + AlloyContentBrowserClient::AlloyContentBrowserClient() = default; +@@ -1221,21 +1382,25 @@ bool AlloyContentBrowserClient::CanCreateWindow( + content::RenderFrameHost* opener, + const GURL& target_url, + WindowOpenDisposition disposition, +- bool user_gesture) { ++ bool user_gesture, ++ content::mojom::FrameHost::GetCreateNewWindowCallback callback) { + CEF_REQUIRE_UIT(); + content::WebContents* web_contents = + content::WebContents::FromRenderFrameHost(opener); + CefRefPtr browser_host = + CefBrowserHostBase::GetBrowserForContents(web_contents); + if (!browser_host) { ++ std::move(callback).Run(content::mojom::CreateNewWindowStatus::kBlocked); + return false; + } + if (!browser_host->settings().javascript_can_open_windows_automatically && !user_gesture) { + LOG(INFO) << "javascript_can_open_windows_automatically false"; ++ std::move(callback).Run(content::mojom::CreateNewWindowStatus::kBlocked); + return false; + } ++ CefRefPtr callbackImpl = new PopupWindowCallbackImpl(std::move(callback)); + return CefBrowserInfoManager::GetInstance()->CanCreateWindow( +- opener, target_url, disposition, user_gesture); ++ opener, target_url, disposition, user_gesture, callbackImpl); + } + #endif + +@@ -1281,6 +1446,11 @@ void AlloyContentBrowserClient::OverrideWebkitPrefs( + SkColor base_background_color; + renderer_prefs::PopulateWebPreferences(rvh, *prefs, base_background_color); + ++#if BUILDFLAG(IS_OHOS) && defined (OHOS_NWEB_EX) ++ prefs->force_enable_zoom = web_contents->GetForceEnableZoom(); ++ prefs->blank_target_popup_intercept_enabled = web_contents->GetEnableBlankTargetPopupIntercept(); ++#endif ++ + web_contents->SetPageBaseBackgroundColor(base_background_color); + } + +@@ -1320,6 +1490,16 @@ void AlloyContentBrowserClient:: + RegisterAssociatedInterfaceBindersForRenderFrameHost( + content::RenderFrameHost& render_frame_host, + blink::AssociatedInterfaceRegistry& associated_registry) { ++#if BUILDFLAG(IS_OHOS) ++ associated_registry.AddInterface(base::BindRepeating( ++ [](content::RenderFrameHost* render_frame_host, ++ mojo::PendingAssociatedReceiver< ++ page_load_metrics::mojom::PageLoadMetrics> receiver) { ++ page_load_metrics::MetricsWebContentsObserver::BindPageLoadMetrics( ++ std::move(receiver), render_frame_host); ++ }, ++ &render_frame_host)); ++#endif + associated_registry.AddInterface(base::BindRepeating( + [](content::RenderFrameHost* render_frame_host, + mojo::PendingAssociatedReceiver +@@ -1349,6 +1529,18 @@ void AlloyContentBrowserClient:: + }, + &render_frame_host)); + #endif ++ ++#if BUILDFLAG(IS_OHOS) ++ associated_registry.AddInterface(base::BindRepeating( ++ [](content::RenderFrameHost* render_frame_host, ++ mojo::PendingAssociatedReceiver ++ receiver) { ++ ++ printing::OhosPrintManager::BindPrintManagerHost(std::move(receiver), ++ render_frame_host); ++ }, ++ &render_frame_host)); ++#endif + } + + std::vector> +@@ -1369,6 +1561,17 @@ AlloyContentBrowserClient::CreateThrottlesForNavigation( + throttles.push_back(std::move(pdf_throttle)); + } + #endif ++#if BUILDFLAG(IS_OHOS) ++ if (navigation_handle->IsInMainFrame()) { ++ // MetricsNavigationThrottle requires that it runs before ++ // NavigationThrottles that may delay or cancel navigations, so only ++ // NavigationThrottles that don't delay or cancel navigations (e.g. ++ // throttles that are only observing callbacks without affecting navigation ++ // behavior) should be added before MetricsNavigationThrottle. ++ throttles.push_back(page_load_metrics::MetricsNavigationThrottle::Create( ++ navigation_handle)); ++ } ++#endif + + throttle::CreateThrottlesForNavigation(navigation_handle, throttles); + +@@ -1424,7 +1627,7 @@ AlloyContentBrowserClient::WillCreateURLLoaderRequestInterceptors( + return interceptors; + } + +-#if BUILDFLAG(IS_LINUX) ++#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_OHOS) + void AlloyContentBrowserClient::GetAdditionalMappedFilesForChildProcess( + const base::CommandLine& command_line, + int child_process_id, +@@ -1434,7 +1637,7 @@ void AlloyContentBrowserClient::GetAdditionalMappedFilesForChildProcess( + mappings->Share(kCrashDumpSignal, crash_signal_fd); + } + } +-#endif // BUILDFLAG(IS_LINUX) ++#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_OHOS) + + void AlloyContentBrowserClient::ExposeInterfacesToRenderer( + service_manager::BinderRegistry* registry, +@@ -1604,11 +1807,22 @@ void AlloyContentBrowserClient::OnNetworkServiceCreated( + DCHECK(g_browser_process); + PrefService* local_state = g_browser_process->local_state(); + DCHECK(local_state); +- + // Need to set up global NetworkService state before anything else uses it. + DCHECK(SystemNetworkContextManager::GetInstance()); + SystemNetworkContextManager::GetInstance()->OnNetworkServiceCreated( + network_service); ++ ++ if (net_service::NetHelpers::HasValidDnsOverHttpConfig()) { ++ auto config = net::DnsOverHttpsServerConfig::FromString( ++ net_service::NetHelpers::DnsOverHttpServerConfig()); ++ if (config.has_value()) { ++ network_service->ConfigureStubHostResolver( ++ true, net_service::NetHelpers::DnsOverHttpMode(), ++ {{std::move(*config)}}, true); ++ } else { ++ LOG(INFO) << "doh server invalid"; ++ } ++ } + } + + bool AlloyContentBrowserClient::ConfigureNetworkContextParams( +@@ -1670,6 +1884,10 @@ bool AlloyContentBrowserClient::ConfigureNetworkContextParams( + network::mojom::SSLVersion::kTLS1; + #endif + ++ // Add proxy settings ++ NWEB::ProxyConfigMonitor::GetInstance()->AddProxyToNetworkContextParams( ++ network_context_params); ++ + return true; + } + +@@ -1945,6 +2163,9 @@ void AlloyContentBrowserClient::OnWebContentsCreated( + extensions::CefExtensionWebContentsObserver::CreateForWebContents( + web_contents); + } ++#if BUILDFLAG(IS_OHOS) ++ cef::InitializePageLoadMetricsForWebContents(web_contents); ++#endif + } + + bool AlloyContentBrowserClient::IsFindInPageDisabledForOrigin( +diff --git a/src/cef/libcef/browser/alloy/alloy_content_browser_client.h b/src/cef/libcef/browser/alloy/alloy_content_browser_client.h +index 6bab20215fa..97c2aadd62b +--- a/src/cef/libcef/browser/alloy/alloy_content_browser_client.h ++++ b/src/cef/libcef/browser/alloy/alloy_content_browser_client.h +@@ -10,6 +10,7 @@ + #include + + #include "include/cef_request_context_handler.h" ++#include "libcef/browser/net_service/proxy_config_monitor.h" + #include "libcef/browser/request_context_impl.h" + + #include "base/memory/ref_counted.h" +@@ -111,7 +112,8 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient { + bool CanCreateWindow(content::RenderFrameHost* opener, + const GURL& target_url, + WindowOpenDisposition disposition, +- bool user_gesture) override; ++ bool user_gesture, ++ content::mojom::FrameHost::GetCreateNewWindowCallback callback) override; + #endif + void OverrideWebkitPrefs(content::WebContents* web_contents, + blink::web_pref::WebPreferences* prefs) override; +@@ -143,7 +145,7 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient { + const scoped_refptr& + network_loader_factory) override; + +-#if BUILDFLAG(IS_LINUX) ++#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_OHOS) + void GetAdditionalMappedFilesForChildProcess( + const base::CommandLine& command_line, + int child_process_id, +diff --git a/src/cef/libcef/browser/alloy/alloy_ssl_platform_key_ohos.h b/src/cef/libcef/browser/alloy/alloy_ssl_platform_key_ohos.h +new file mode 100644 +index 00000000000..56980e53b41 +--- /dev/null ++++ b/src/cef/libcef/browser/alloy/alloy_ssl_platform_key_ohos.h +@@ -0,0 +1,106 @@ ++/* ++ * Copyright (c) 2023 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 ++ * ++ * 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, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++#ifndef CEF_LIBCEF_BROWSER_ALLOY_ALLOY_SSL_PLATFORM_OHOS_KEY_ ++#define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_SSL_PLATFORM_OHOS_KEY_ ++#pragma once ++ ++#include ++#include ++ ++#include "include/cef_request_handler.h" ++ ++#include "crypto/rsa_private_key.h" ++#include "net/base/net_errors.h" ++#include "net/ssl/ssl_platform_key_util.h" ++#include "net/ssl/threaded_ssl_private_key.h" ++#include "third_party/boringssl/src/include/openssl/digest.h" ++#include "third_party/boringssl/src/include/openssl/ec.h" ++#include "third_party/boringssl/src/include/openssl/evp.h" ++#include "third_party/boringssl/src/include/openssl/rsa.h" ++#include "third_party/boringssl/src/include/openssl/ssl.h" ++#include "ohos_adapter_helper.h" ++ ++constexpr int32_t HASH_LENGTH = 256; ++ ++class SSLPlatformKeyOHOS : public net::ThreadedSSLPrivateKey::Delegate { ++ public: ++ explicit SSLPlatformKeyOHOS(const std::string& uri) ++ : uri_(uri) {} ++ ++ SSLPlatformKeyOHOS(const SSLPlatformKeyOHOS&) = delete; ++ SSLPlatformKeyOHOS& operator=(const SSLPlatformKeyOHOS&) = delete; ++ ++ ~SSLPlatformKeyOHOS() override = default; ++ ++ std::string GetProviderName() override { return "OHOS cert manager"; } ++ ++ std::vector GetAlgorithmPreferences() override { ++ return ++ { ++ // Only SHA-1 if the server supports no other hashes, but otherwise ++ // prefer smaller SHA-2 hashes. SHA-256 is considered fine and more ++ // likely to be supported by smartcards, etc. ++ SSL_SIGN_RSA_PKCS1_SHA256, SSL_SIGN_RSA_PKCS1_SHA384, ++ SSL_SIGN_RSA_PKCS1_SHA512, SSL_SIGN_RSA_PKCS1_SHA1, ++ ++ // Order PSS last so we preferentially use the more conservative ++ // option. While the platform APIs may support RSA-PSS, the key may ++ // not. Ideally the SSLPrivateKey would query this, but smartcards ++ // often do not support such queries well. ++ SSL_SIGN_RSA_PSS_SHA256, SSL_SIGN_RSA_PSS_SHA384, ++ SSL_SIGN_RSA_PSS_SHA512, ++ }; ++ } ++ ++ net::Error Sign(uint16_t algorithm, ++ base::span input, ++ std::vector* signature) override { ++ char* uri = new char[uri_.length() + 1]; ++ if (uri == nullptr) { ++ LOG(ERROR) << "OHOS cert manager sign failed, new uri memory failed"; ++ return net::ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED; ++ } ++ uint32_t i = 0; ++ for (; i < uri_.length(); i++) { ++ uri[i] = uri_[i]; ++ } ++ uri[i] = '\0'; ++ ++ std::unique_ptr ++ RootCertDataAdapter = OHOS::NWeb::OhosAdapterHelper::GetInstance().GetRootCertDataAdapter(); ++ if (RootCertDataAdapter == nullptr) { ++ LOG(ERROR) << "OHOS cert manager sign failed, root cert data adapter is null"; ++ delete[] uri; ++ return net::ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED; ++ } ++ ++ signature->resize(HASH_LENGTH, 0); ++ ++ auto ret = RootCertDataAdapter->Sign((uint8_t*)uri, input.data(), input.size(), signature->data(), signature->size()); ++ if (ret != 0) { ++ LOG(ERROR) << "OHOS cert manager sign failed, ret = " << ret; ++ delete[] uri; ++ return net::ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED; ++ } ++ ++ delete[] uri; ++ return net::OK; ++ } ++ ++ private: ++ std::string uri_; ++}; ++ ++#endif // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_SSL_PLATFORM_OHOS_KEY_ +\ No newline at end of file +diff --git a/src/cef/libcef/browser/alloy/browser_platform_delegate_alloy.cc b/src/cef/libcef/browser/alloy/browser_platform_delegate_alloy.cc +index 8c27ed9a7c8..20a008f773b +--- a/src/cef/libcef/browser/alloy/browser_platform_delegate_alloy.cc ++++ b/src/cef/libcef/browser/alloy/browser_platform_delegate_alloy.cc +@@ -29,16 +29,24 @@ + #include "third_party/blink/public/mojom/frame/find_in_page.mojom.h" + + #if BUILDFLAG(IS_OHOS) ++#include "chrome/browser/printing/print_view_manager_common.h" ++#include "libcef/browser/printing/ohos_print_manager.h" + #include "printing/buildflags/buildflags.h" + #if BUILDFLAG(ENABLE_PRINT_PREVIEW) +-#include "libcef/browser/printing/print_view_manager.h" + #include "chrome/browser/printing/print_view_manager.h" +-#include "chrome/browser/printing/print_view_manager_common.h" ++#include "libcef/browser/printing/print_view_manager.h" + #endif + #endif + + namespace { + ++#if BUILDFLAG(IS_OHOS) ++printing::OhosPrintManager* GetPrintViewManager( ++ content::WebContents* web_contents) { ++ return printing::OhosPrintManager::FromWebContents(web_contents); ++} ++#endif ++ + #if BUILDFLAG(IS_OHOS) && BUILDFLAG(ENABLE_PRINT_PREVIEW) + printing::CefPrintViewManager* GetPrintViewManager( + content::WebContents* web_contents) { +@@ -189,6 +197,10 @@ void CefBrowserPlatformDelegateAlloy::BrowserCreated( + web_contents_->SetDelegate(static_cast(browser)); + + PrefsTabHelper::CreateForWebContents(web_contents_); ++#if BUILDFLAG(IS_OHOS) ++ printing::OhosPrintManager::CreateForWebContents(web_contents_); ++#endif ++ + #if BUILDFLAG(IS_OHOS) && BUILDFLAG(ENABLE_PRINT_PREVIEW) + printing::CefPrintViewManager::CreateForWebContents(web_contents_); + #endif +@@ -275,7 +287,8 @@ void CefBrowserPlatformDelegateAlloy::SendTouchEventToRender( + return; + auto frame = browser_->GetMainFrame(); + if (frame && frame->IsValid()) { +- static_cast(frame.get())->SendTouchEvent(event); ++ static_cast(frame.get()) ++ ->SendHitEvent(event.x, event.y, event.radius_x, event.radius_y); + } + } + +@@ -373,6 +386,23 @@ bool CefBrowserPlatformDelegateAlloy::IsPrintPreviewSupported() const { + } + + void CefBrowserPlatformDelegateAlloy::Print() { ++#if BUILDFLAG(IS_OHOS) ++ REQUIRE_ALLOY_RUNTIME(); ++ ++ auto contents_to_use = printing::GetWebContentsToUse(web_contents_); ++ if (!contents_to_use) { ++ LOG(ERROR) << "contents_to_use is nullptr"; ++ return; ++ } ++ ++ auto printViewManager = GetPrintViewManager(contents_to_use); ++ if (!printViewManager) { ++ LOG(ERROR) << "printViewManager is nullptr"; ++ return; ++ } ++ ++ printViewManager->PrintNow(); ++#endif + #if BUILDFLAG(IS_OHOS) && BUILDFLAG(ENABLE_PRINT_PREVIEW) + REQUIRE_ALLOY_RUNTIME(); + +@@ -430,7 +460,7 @@ void CefBrowserPlatformDelegateAlloy::Find(const CefString& searchText, + ->StartFinding(searchText.ToString16(), forward, matchCase, findNext, + /*run_synchronously_for_testing=*/false + #if BUILDFLAG(IS_OHOS) +- , ++ , + newSession + #endif + ); +@@ -508,4 +538,4 @@ void CefBrowserPlatformDelegateAlloy::OnExtensionHostDeleted() { + DCHECK(is_background_host_); + DCHECK(extension_host_); + extension_host_ = nullptr; +-} ++} +\ No newline at end of file +diff --git a/src/cef/libcef/browser/browser_contents_delegate.cc b/src/cef/libcef/browser/browser_contents_delegate.cc +index a195db90058..159c816e611 +--- a/src/cef/libcef/browser/browser_contents_delegate.cc ++++ b/src/cef/libcef/browser/browser_contents_delegate.cc +@@ -516,6 +516,15 @@ void CefBrowserContentsDelegate::DidStopLoading() { + } + } + ++#if BUILDFLAG(IS_OHOS) ++void CefBrowserContentsDelegate::DidStartNavigation( ++ content::NavigationHandle* navigation) { ++ if (icon_helper_) { ++ icon_helper_->ClearFailedFaviconUrlSets(navigation); ++ } ++} ++#endif ++ + void CefBrowserContentsDelegate::DidFinishNavigation( + content::NavigationHandle* navigation_handle) { + const net::Error error_code = navigation_handle->GetNetErrorCode(); +diff --git a/src/cef/libcef/browser/browser_contents_delegate.h b/src/cef/libcef/browser/browser_contents_delegate.h +index b0e9389ad8b..c1ede55dff3 +--- a/src/cef/libcef/browser/browser_contents_delegate.h ++++ b/src/cef/libcef/browser/browser_contents_delegate.h +@@ -152,6 +152,9 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate, + content::RenderWidgetHost* render_widget_host) override; + void OnFocusChangedInPage(content::FocusedNodeDetails* details) override; + void WebContentsDestroyed() override; ++#if BUILDFLAG(IS_OHOS) ++ void DidStartNavigation(content::NavigationHandle* navigation) override; ++#endif + + // NotificationObserver methods. + void Observe(int type, +diff --git a/src/cef/libcef/browser/browser_frame.cc b/src/cef/libcef/browser/browser_frame.cc +index 83d3c867539..4e2d43d72c9 +--- a/src/cef/libcef/browser/browser_frame.cc ++++ b/src/cef/libcef/browser/browser_frame.cc +@@ -78,12 +78,6 @@ CefRefPtr CefBrowserFrame::GetFrameHost( + return nullptr; + } + +-void CefBrowserFrame::OnUpdateHitData(cef::mojom::HitDataParamsPtr params) { +- if (auto host = GetFrameHost()) { +- host->OnUpdateHitData(std::move(params)); +- } +-} +- + void CefBrowserFrame::OnGetImageForContextNode( + cef::mojom::GetImageForContextNodeParamsPtr params) { + if (auto host = GetFrameHost()) { +@@ -96,3 +90,9 @@ void CefBrowserFrame::OnGetImageForContextNodeNull() { + host->OnGetImageForContextNodeNull(); + } + } ++ ++void CefBrowserFrame::OnScriptedPrint(bool user_initiated) { ++ if (auto host = GetFrameHost()) { ++ host->OnScriptedPrint(user_initiated); ++ } ++} +\ No newline at end of file +diff --git a/src/cef/libcef/browser/browser_frame.h b/src/cef/libcef/browser/browser_frame.h +index b9e9a47b1d2..7cee989135e +--- a/src/cef/libcef/browser/browser_frame.h ++++ b/src/cef/libcef/browser/browser_frame.h +@@ -43,10 +43,10 @@ class CefBrowserFrame + void UpdateDraggableRegions( + absl::optional> regions) + override; +- void OnUpdateHitData(cef::mojom::HitDataParamsPtr params) override; + void OnGetImageForContextNode( + cef::mojom::GetImageForContextNodeParamsPtr params) override; + void OnGetImageForContextNodeNull() override; ++ void OnScriptedPrint(bool user_initiated) override; + + // FrameServiceBase methods: + bool ShouldCloseOnFinishNavigation() const override { return false; } +diff --git a/src/cef/libcef/browser/browser_host_base.cc b/src/cef/libcef/browser/browser_host_base.cc +index 6e2923b3455..574a0005bb6 +--- a/src/cef/libcef/browser/browser_host_base.cc ++++ b/src/cef/libcef/browser/browser_host_base.cc +@@ -32,6 +32,7 @@ + #include "content/public/browser/download_manager.h" + #include "content/public/browser/download_request_utils.h" + #if BUILDFLAG(IS_OHOS) ++#include + #include "content/public/browser/message_port_provider.h" + #include "third_party/blink/public/common/messaging/web_message_port.h" + #endif +@@ -47,6 +48,7 @@ + + #if BUILDFLAG(IS_OHOS) + #include "base/files/file_util.h" ++#include "base/rand_util.h" + #include "base/strings/string_number_conversions.h" + #include "chrome/browser/browser_process.h" + #include "content/public/common/mhtml_generation_params.h" +@@ -55,8 +57,18 @@ + #include "ui/base/resource/resource_bundle.h" + #endif + ++#if defined(OHOS_NWEB_EX) ++#include "content/public/common/content_switches.h" ++#endif ++ + namespace { + ++#if BUILDFLAG(IS_OHOS) ++static uint64_t DEFAULT_ZOOM_TIME_INTERNAL = 250; ++static float DEFAULT_MIN_ZOOM_FACTOR = 0.01f; ++static float DEFAULT_MAX_ZOOM_FACTOR = 100.0f; ++#endif ++ + // Associates a CefBrowserHostBase instance with a WebContents. This object will + // be deleted automatically when the WebContents is destroyed. + class WebContentsUserDataAdapter : public base::SupportsUserData::Data { +@@ -524,6 +536,9 @@ void CefBrowserHostBase::UpdateBrowserSettings( + #if BUILDFLAG(IS_OHOS) + settings_.hide_vertical_scrollbars = browser_settings.hide_vertical_scrollbars; + settings_.hide_horizontal_scrollbars = browser_settings.hide_horizontal_scrollbars; ++ settings_.contextmenu_customization_enabled = ++ browser_settings.contextmenu_customization_enabled; ++ settings_.scrollbar_color = browser_settings.scrollbar_color; + #endif + } + +@@ -542,8 +557,20 @@ void CefBrowserHostBase::PutUserAgent(const CefString& ua) { + return; + } + ++#if defined(OHOS_NWEB_EX) ++ std::string user_agent = ua; ++ const base::CommandLine& command_line = ++ *base::CommandLine::ForCurrentProcess(); ++ if (command_line.HasSwitch(switches::kForBrowser) && ++ (ua.empty() || ua.length() == 0)) { ++ user_agent = DefaultUserAgent(); ++ } ++ GetWebContents()->SetUserAgentOverride( ++ blink::UserAgentOverride::UserAgentOnly(user_agent), true); ++#else + GetWebContents()->SetUserAgentOverride( + blink::UserAgentOverride::UserAgentOnly(ua), true); ++#endif + + content::NavigationController& controller = GetWebContents()->GetController(); + for (int i = 0; i < controller.GetEntryCount(); ++i) { +@@ -578,7 +605,6 @@ void CefBrowserHostBase::UnregisterArkJSfunction( + } + javascriptInjector->RemoveInterface(object_name.ToString(), method_vector); + } +- + #endif + + void CefBrowserHostBase::ReplaceMisspelling(const CefString& word) { +@@ -645,6 +671,15 @@ void CefBrowserHostBase::SendMouseClickEvent(const CefMouseEvent& event, + if (platform_delegate_) { + platform_delegate_->SendMouseClickEvent(event, type, mouseUp, clickCount); + } ++ ++ if (mouseUp) ++ return; ++ ++ auto frame = GetMainFrame(); ++ if (frame && frame->IsValid()) { ++ static_cast(frame.get())->SendHitEvent( ++ event.x, event.y, 0, 0); ++ } + } + + void CefBrowserHostBase::SendMouseMoveEvent(const CefMouseEvent& event, +@@ -1018,6 +1053,39 @@ void CefBrowserHostBase::SlideScroll(float vx, + } + } + ++uint64_t CefBrowserHostBase::GetCurrentTimestamp() { ++ auto now = std::chrono::system_clock::now(); ++ return std::chrono::duration_cast(now.time_since_epoch()).count(); ++} ++ ++void CefBrowserHostBase::ZoomBy(float delta, ++ float width, ++ float height) { ++ if (delta < DEFAULT_MIN_ZOOM_FACTOR || delta > DEFAULT_MAX_ZOOM_FACTOR) { ++ LOG(ERROR) << "invalid zommby delta"; ++ return; ++ } ++ uint64_t cur_zoom_time = GetCurrentTimestamp(); ++ if (cur_zoom_time - last_zoom_time_ <= DEFAULT_ZOOM_TIME_INTERNAL) { ++ LOG(ERROR) << "zoomby ignore"; ++ return; ++ } ++ last_zoom_time_ = cur_zoom_time; ++ auto frame = GetMainFrame(); ++ if (frame && frame->IsValid()) { ++ static_cast(frame.get()) ++ ->ZoomBy(delta, width, height); ++ } ++} ++ ++void CefBrowserHostBase::GetHitData(int& type, CefString& extra_data) { ++ auto frame = GetMainFrame(); ++ if (frame && frame->IsValid()) { ++ static_cast(frame.get()) ++ ->GetHitData(type, extra_data); ++ } ++} ++ + CefRefPtr CefBrowserHostBase::GetWebState() { + auto web_contents = GetWebContents(); + if (!web_contents) { +@@ -1357,12 +1425,6 @@ void CefBrowserHostBase::OnDidFinishLoad(CefRefPtr frame, + contents_delegate_->OnLoadEnd(frame, validated_url, http_status_code); + } + +-void CefBrowserHostBase::OnUpdateHitData(const int type, +- const CefString extra_data) { +- cef_hit_data_.type = type; +- cef_hit_data_.extra_data = extra_data; +-} +- + void CefBrowserHostBase::ViewText(const std::string& text) { + if (!CEF_CURRENTLY_ON_UIT()) { + CEF_POST_TASK(CEF_UIT, +@@ -1491,18 +1553,27 @@ CefString CefBrowserHostBase::Title() { + void CefBrowserHostBase::CreateWebMessagePorts(std::vector& ports) { + auto web_contents = GetWebContents(); + if (web_contents) { +- std::vector portArr; +- web_contents->CreateWebMessagePorts(portArr); +- if (portArr.size() != 2) { +- LOG(ERROR) << "CreateWebMessagePorts size wrong"; +- return; +- } +- uint64_t pointer0 = reinterpret_cast(&portArr[0]); +- uint64_t pointer1 = reinterpret_cast(&portArr[1]); +- portMap_[std::make_pair(pointer0, pointer1)] = +- std::make_pair(std::move(portArr[0]), std::move(portArr[1])); +- ports.emplace_back(std::to_string(pointer0)); +- ports.emplace_back(std::to_string(pointer1)); ++ int retry_times = 0; ++ constexpr int MAX_RETRY_TIMES = 5; ++ do { ++ std::vector portArr; ++ web_contents->CreateWebMessagePorts(portArr); ++ if (portArr.size() != 2) { ++ LOG(ERROR) << "CreateWebMessagePorts size wrong"; ++ return; ++ } ++ uint64_t pointer0 = base::RandUint64(); ++ uint64_t pointer1 = base::RandUint64(); ++ auto iter = portMap_.find(std::make_pair(pointer0, pointer1)); ++ if (iter == portMap_.end()) { ++ portMap_[std::make_pair(pointer0, pointer1)] = ++ std::make_pair(std::move(portArr[0]), std::move(portArr[1])); ++ ports.emplace_back(std::to_string(pointer0)); ++ ports.emplace_back(std::to_string(pointer1)); ++ return; ++ } ++ retry_times++; ++ } while (retry_times < MAX_RETRY_TIMES); + } else { + LOG(ERROR) << "CreateWebMessagePorts web_contents its null"; + } +@@ -1597,6 +1668,117 @@ void CefBrowserHostBase::ClosePort(CefString& portHandle) { + LOG(INFO) << "ClosePort end"; + } + ++bool CefBrowserHostBase::ConvertCefValueToBlinkMsg( ++ CefRefPtr& original, ++ blink::WebMessagePort::Message& message) { ++ LOG(INFO) << "ConvertCefValueToBlinkMsg type:" << (int)original->GetType(); ++ switch (original->GetType()) { ++ case VTYPE_STRING: { ++ message = blink::WebMessagePort::Message( ++ base::UTF8ToUTF16(original->GetString().ToString())); ++ message.type_ = blink::WebMessagePort::Message::MessageType::STRING; ++ break; ++ } ++ case VTYPE_BINARY: { ++ CefRefPtr binValue = original->GetBinary(); ++ size_t len = binValue->GetSize(); ++ std::vector arr(len); ++ binValue->GetData(&arr[0], len, 0); ++ message = blink::WebMessagePort::Message(std::move(arr)); ++ message.type_ = blink::WebMessagePort::Message::MessageType::BINARY; ++ break; ++ } ++ case VTYPE_BOOL: { ++ message.bool_value_ = original->GetBool(); ++ message.type_ = blink::WebMessagePort::Message::MessageType::BOOLEAN; ++ break; ++ } ++ case VTYPE_INT: { ++ message.int64_value_ = original->GetInt(); ++ message.type_ = blink::WebMessagePort::Message::MessageType::INTEGER; ++ break; ++ } ++ case VTYPE_DOUBLE: { ++ message.double_value_ = original->GetDouble(); ++ message.type_ = blink::WebMessagePort::Message::MessageType::DOUBLE; ++ break; ++ } ++ case VTYPE_LIST: { ++ CefRefPtr value = original->GetList(); ++ CefValueType type = value->GetType(0); ++ size_t len = value->GetSize(); ++ switch (type) { ++ case VTYPE_STRING: { ++ std::vector msg_arr; ++ for (size_t i = 0; i < len; i++) { ++ msg_arr.push_back( ++ base::UTF8ToUTF16(value->GetString(i).ToString())); ++ } ++ message.string_arr_ = std::move(msg_arr); ++ message.type_ = ++ blink::WebMessagePort::Message::MessageType::STRINGARRAY; ++ break; ++ } ++ case VTYPE_BOOL: { ++ std::vector msg_arr; ++ for (size_t i = 0; i < len; i++) { ++ msg_arr.push_back(value->GetBool(i)); ++ } ++ message.bool_arr_ = std::move(msg_arr); ++ message.type_ = ++ blink::WebMessagePort::Message::MessageType::BOOLEANARRAY; ++ break; ++ } ++ case VTYPE_INT: { ++ std::vector msg_arr; ++ for (size_t i = 0; i < len; i++) { ++ msg_arr.push_back(value->GetInt(i)); ++ } ++ message.int64_arr_ = std::move(msg_arr); ++ message.type_ = ++ blink::WebMessagePort::Message::MessageType::INT64ARRAY; ++ break; ++ } ++ case VTYPE_DOUBLE: { ++ std::vector msg_arr; ++ for (size_t i = 0; i < len; i++) { ++ msg_arr.push_back(value->GetDouble(i)); ++ } ++ message.double_arr_ = std::move(msg_arr); ++ message.type_ = ++ blink::WebMessagePort::Message::MessageType::DOUBLEARRAY; ++ break; ++ } ++ default: ++ LOG(ERROR) << "Only support string, bool, int, double"; ++ break; ++ } ++ break; ++ } ++ case VTYPE_DICTIONARY: { ++ CefRefPtr dict = original->GetDictionary(); ++ std::u16string err_name = u""; ++ std::u16string err_msg = u""; ++ if (dict->HasKey("Error.name")) { ++ err_name = base::UTF8ToUTF16(dict->GetString("Error.name").ToString()); ++ } ++ if (dict->HasKey("Error.message")) { ++ err_msg = ++ base::UTF8ToUTF16(dict->GetString("Error.message").ToString()); ++ } ++ message.err_name_ = std::move(err_name); ++ message.err_msg_ = std::move(err_msg); ++ message.type_ = blink::WebMessagePort::Message::MessageType::ERROR; ++ break; ++ } ++ default: { ++ LOG(ERROR) << "Not support type:" << (int)original->GetType(); ++ break; ++ } ++ } ++ return true; ++} ++ + void CefBrowserHostBase::PostPortMessage(CefString& portHandle, + CefRefPtr data) { + auto web_contents = GetWebContents(); +@@ -1605,18 +1787,11 @@ void CefBrowserHostBase::PostPortMessage(CefString& portHandle, + return; + } + ++ // construct blink message + blink::WebMessagePort::Message message; +- if (data->GetType() == VTYPE_STRING) { +- message = blink::WebMessagePort::Message(base::UTF8ToUTF16(data->GetString().ToString())); +- } else if (data->GetType() == VTYPE_BINARY) { +- CefRefPtr binValue = data->GetBinary(); +- size_t len = binValue->GetSize(); +- std::vector arr(len); +- binValue->GetData(&arr[0], len, 0); +- message = blink::WebMessagePort::Message(std::move(arr)); +- } else { +- LOG(ERROR) << "CefBrowserHostBase::PostPortMessage not support type"; +- return; ++ if (!ConvertCefValueToBlinkMsg(data, message)) { ++ LOG(ERROR) << "Post meessage: convert cef value to blink message failed"; ++ return; + } + + // find the WebMessagePort in map +@@ -1716,21 +1891,86 @@ void WebMessageReceiverImpl::SetOnMessageCallback( + callback_ = callback; + } + +-// this will receive message from html5 +-bool WebMessageReceiverImpl::OnMessage(blink::WebMessagePort::Message message) { +- LOG(INFO) << "OnMessage start"; +- // Pass the message on to the receiver. +- if (callback_) { +- CefRefPtr data = CefValue::Create(); +- if (!message.data.empty()) { ++void WebMessageReceiverImpl::ConvertBlinkMsgToCefValue( ++ blink::WebMessagePort::Message& message, ++ CefRefPtr data) { ++ switch (message.type_) { ++ case blink::WebMessagePort::Message::MessageType::STRING: { + data->SetString(base::UTF16ToUTF8(message.data)); +- } else { ++ break; ++ } ++ case blink::WebMessagePort::Message::MessageType::BINARY: { + std::vector vecBinary = message.array_buffer; + CefRefPtr value = +- CefBinaryValue::Create(vecBinary.data(), vecBinary.size()); ++ CefBinaryValue::Create(vecBinary.data(), vecBinary.size()); + data->SetBinary(value); ++ break; + } ++ case blink::WebMessagePort::Message::MessageType::DOUBLE: { ++ data->SetDouble((message.double_value_)); ++ break; ++ } ++ case blink::WebMessagePort::Message::MessageType::BOOLEAN: { ++ data->SetBool((message.bool_value_)); ++ break; ++ } ++ case blink::WebMessagePort::Message::MessageType::INTEGER: { ++ data->SetInt((message.int64_value_)); ++ break; ++ } ++ case blink::WebMessagePort::Message::MessageType::STRINGARRAY: { ++ CefRefPtr value = CefListValue::Create(); ++ for (size_t i = 0; i < message.string_arr_.size(); i++) { ++ value->SetString(i, base::UTF16ToUTF8(message.string_arr_[i])); ++ } ++ data->SetList(value); ++ break; ++ } ++ case blink::WebMessagePort::Message::MessageType::BOOLEANARRAY: { ++ CefRefPtr value = CefListValue::Create(); ++ for (size_t i = 0; i < message.bool_arr_.size(); i++) { ++ value->SetBool(i, message.bool_arr_[i]); ++ } ++ data->SetList(value); ++ break; ++ } ++ case blink::WebMessagePort::Message::MessageType::DOUBLEARRAY: { ++ CefRefPtr value = CefListValue::Create(); ++ for (size_t i = 0; i < message.double_arr_.size(); i++) { ++ value->SetDouble(i, message.double_arr_[i]); ++ } ++ data->SetList(value); ++ break; ++ } ++ case blink::WebMessagePort::Message::MessageType::INT64ARRAY: { ++ CefRefPtr value = CefListValue::Create(); ++ for (size_t i = 0; i < message.int64_arr_.size(); i++) { ++ value->SetInt(i, message.int64_arr_[i]); ++ } ++ data->SetList(value); ++ break; ++ } ++ case blink::WebMessagePort::Message::MessageType::ERROR: { ++ std::u16string err_name = message.err_name_; ++ std::u16string err_msg = message.err_msg_; ++ CefRefPtr dict = CefDictionaryValue::Create(); ++ dict->SetString("Error.name", err_name); ++ dict->SetString("Error.message", err_msg); ++ data->SetDictionary(dict); ++ break; ++ } ++ default: ++ break; ++ } ++} + ++// this will receive message from html5 ++bool WebMessageReceiverImpl::OnMessage(blink::WebMessagePort::Message message) { ++ LOG(INFO) << "OnMessage start"; ++ // Pass the message on to the receiver. ++ if (callback_) { ++ CefRefPtr data = CefValue::Create(); ++ ConvertBlinkMsgToCefValue(message, data); + callback_->OnMessage(data); + } else { + LOG(ERROR) << "u should set callback to receive message"; +@@ -1739,11 +1979,6 @@ bool WebMessageReceiverImpl::OnMessage(blink::WebMessagePort::Message message) { + } + #endif + +-void CefBrowserHostBase::GetHitData(int& type, CefString& extra_data) { +- type = cef_hit_data_.type; +- extra_data = cef_hit_data_.extra_data; +-} +- + void CefBrowserHostBase::SetInitialScale(float scale) { + auto frame = GetMainFrame(); + if (frame && frame->IsValid()) { +@@ -1865,15 +2100,28 @@ void CefBrowserHostBase::LoadWithData(const CefString& data, + } + } + ++// static ++bool ValidateResultType(base::Value::Type type) { ++ if (type == base::Value::Type::STRING || type == base::Value::Type::DOUBLE || ++ type == base::Value::Type::INTEGER || ++ type == base::Value::Type::BOOLEAN) { ++ return true; ++ } ++ return false; ++} ++ + void CefBrowserHostBase::ExecuteJavaScript( + const CefString& code, +- CefRefPtr callback) { ++ CefRefPtr callback, ++ bool extention) { + auto web_contents = GetWebContents(); + // enable inject javaScript +- web_contents->GetMainFrame()->AllowInjectingJavaScript(); +- if (web_contents) { ++ LOG(INFO) << "ExecuteJavaScript with callback enter"; ++ if (web_contents && web_contents->GetMainFrame()) { + LOG(INFO) << "ExecuteJavaScript with callback"; +- web_contents->GetMainFrame()->ExecuteJavaScript( ++ web_contents->GetMainFrame()->AllowInjectingJavaScript(); ++ if (!extention) { ++ web_contents->GetMainFrame()->ExecuteJavaScript( + code.ToString16(), + base::BindOnce( + [](CefRefPtr callback, +@@ -1882,10 +2130,124 @@ void CefBrowserHostBase::ExecuteJavaScript( + std::string json; + base::JSONWriter::Write(result, &json); + if (callback != nullptr) { +- callback->OnJavaScriptExeResult(json); ++ CefRefPtr data = CefValue::Create(); ++ data->SetString(json); ++ callback->OnJavaScriptExeResult(data); + } + }, + callback)); ++ } else { ++ web_contents->GetMainFrame()->ExecuteJavaScript( ++ code.ToString16(), ++ base::BindOnce( ++ [](CefRefPtr callback, ++ base::Value result) { ++ LOG(INFO) << "javascript result callback enter, type:" ++ << result.GetTypeName(result.type()); ++ std::string json; ++ base::JSONWriter::Write(result, &json); ++ CefRefPtr data = CefValue::Create(); ++ switch (result.type()) { ++ case base::Value::Type::STRING: { ++ data->SetString(json); ++ break; ++ } ++ case base::Value::Type::DOUBLE: { ++ data->SetDouble(result.GetDouble()); ++ break; ++ } ++ case base::Value::Type::INTEGER: { ++ data->SetDouble(result.GetInt()); ++ break; ++ } ++ case base::Value::Type::BOOLEAN: { ++ data->SetBool(result.GetBool()); ++ break; ++ } ++ case base::Value::Type::BINARY: { ++ std::vector vec = result.GetBlob(); ++ CefRefPtr value = ++ CefBinaryValue::Create(vec.data(), vec.size()); ++ data->SetBinary(value); ++ break; ++ } ++ case base::Value::Type::LIST: { ++ int len = result.GetList().size(); ++ CefRefPtr value = CefListValue::Create(); ++ base::Value::Type typeFirst = base::Value::Type::NONE; ++ base::Value::Type typeCur = base::Value::Type::NONE; ++ bool support = true; ++ for (int i = 0; i < len; i++) { ++ base::Value list_ele = std::move(result.GetList()[i]); ++ typeCur = list_ele.type(); ++ if (!ValidateResultType(typeCur)) { ++ data->SetString( ++ "This type not support, only string/number/boolean " ++ "is supported for array elements"); ++ support = false; ++ break; ++ } ++ if (i == 0) { ++ typeFirst = typeCur; ++ } ++ if (typeCur != typeFirst) { ++ support = false; ++ data->SetString( ++ "This type not support, The elements in the array " ++ "must be the same."); ++ break; ++ } ++ switch (list_ele.type()) { ++ case base::Value::Type::STRING: { ++ CefString msgCef; ++ msgCef.FromString(list_ele.GetString()); ++ value->SetString(i, msgCef); ++ break; ++ } ++ case base::Value::Type::DOUBLE: { ++ value->SetDouble(i, list_ele.GetDouble()); ++ break; ++ } ++ case base::Value::Type::INTEGER: { ++ value->SetInt(i, list_ele.GetInt()); ++ break; ++ } ++ case base::Value::Type::BOOLEAN: { ++ value->SetBool(i, list_ele.GetBool()); ++ break; ++ } ++ default: { ++ LOG(ERROR) << "Not support type"; ++ support = false; ++ data->SetString( ++ "This type not support, only " ++ "string/number/boolean is supported for array " ++ "elements"); ++ break; ++ } ++ } ++ } ++ if (support) { ++ data->SetList(value); ++ } ++ break; ++ } ++ default: { ++ LOG(ERROR) ++ << "base::Value not support type:" << result.type(); ++ data->SetString( ++ "This type not support, only " ++ "string/number/boolean/arraybuffer/array is supported"); ++ break; ++ } ++ } ++ ++ if (callback != nullptr) { ++ callback->OnJavaScriptExeResult(data); ++ } ++ }, ++ callback)); ++ } + } + } + +@@ -1990,4 +2352,54 @@ bool CefBrowserHostBase::ShouldShowLoadingUI() { + } + return false; + } ++ ++bool CefBrowserHostBase::ShouldShowFreeCopy() { ++#if defined (OHOS_NWEB_EX) ++ if (!GetWebContents()) { ++ return false; ++ } ++ return GetWebContents()->ShouldShowFreeCopy(); ++#else ++ return false; ++#endif ++} ++ ++void CefBrowserHostBase::SetForceEnableZoom(bool forceEnableZoom) { ++#if defined (OHOS_NWEB_EX) ++ if (!GetWebContents()) { ++ return; ++ } ++ GetWebContents()->SetForceEnableZoom(forceEnableZoom); ++#endif ++} ++ ++void CefBrowserHostBase::SelectAndCopy() { ++#if defined(OHOS_NWEB_EX) ++ if (!GetWebContents()) { ++ return; ++ } ++ LOG(INFO) << "select and copy invoke"; ++ GetWebContents()->SelectAndCopy(); ++#endif ++} ++ ++bool CefBrowserHostBase::GetForceEnableZoom() { ++#if defined (OHOS_NWEB_EX) ++ if (!GetWebContents()) { ++ return false; ++ } ++ return GetWebContents()->GetForceEnableZoom(); ++#else ++ return false; ++#endif ++} ++ ++void CefBrowserHostBase::SetEnableBlankTargetPopupIntercept(bool enableBlankTargetPopup) { ++#if defined (OHOS_NWEB_EX) ++ if (!GetWebContents()) { ++ return; ++ } ++ GetWebContents()->SetEnableBlankTargetPopupIntercept(enableBlankTargetPopup); ++#endif ++} + #endif +diff --git a/src/cef/libcef/browser/browser_host_base.h b/src/cef/libcef/browser/browser_host_base.h +index a752ef2c3a2..854ffcedd3e +--- a/src/cef/libcef/browser/browser_host_base.h ++++ b/src/cef/libcef/browser/browser_host_base.h +@@ -109,16 +109,12 @@ class WebMessageReceiverImpl : public blink::WebMessagePort::MessageReceiver { + bool OnMessage(blink::WebMessagePort::Message message) override; + + void SetOnMessageCallback(CefRefPtr callback); ++ void ConvertBlinkMsgToCefValue(blink::WebMessagePort::Message& message, CefRefPtr data); + + private: + CefRefPtr callback_; + }; + +-struct CefHitData { +- int type; +- CefString extra_data; +-}; +- + // Base class for CefBrowserHost implementations. Includes functionality that is + // shared by the alloy and chrome runtimes. All methods are thread-safe unless + // otherwise indicated. +@@ -245,6 +241,12 @@ class CefBrowserHostBase : public CefBrowserHost, + void ScrollTo(float x, float y) override; + void ScrollBy(float delta_x, float delta_y) override; + void SlideScroll(float vx, float vy) override; ++ void ZoomBy(float delta, float width, float height) override; ++ void SetForceEnableZoom(bool forceEnableZoom) override; ++ bool GetForceEnableZoom() override; ++ void SelectAndCopy() override; ++ bool ShouldShowFreeCopy() override; ++ void SetEnableBlankTargetPopupIntercept(bool enableBlankTargetPopup) override; + /* ohos webview end */ + #endif + +@@ -307,7 +309,8 @@ class CefBrowserHostBase : public CefBrowserHost, + + void ExecuteJavaScript( + const CefString& code, +- CefRefPtr callback) override; ++ CefRefPtr callback, ++ bool extention) override; + + // CefBrowserContentsDelegate::Observer methods: + void OnStateChanged(CefBrowserContentsState state_changed) override; +@@ -358,7 +361,6 @@ class CefBrowserHostBase : public CefBrowserHost, + void OnDidFinishLoad(CefRefPtr frame, + const GURL& validated_url, + int http_status_code); +- void OnUpdateHitData(const int type, const CefString extra_data); + virtual void OnSetFocus(cef_focus_source_t source) = 0; + void ViewText(const std::string& text); + +@@ -427,6 +429,10 @@ class CefBrowserHostBase : public CefBrowserHost, + int cache_mode_ = 0; + #endif + ++#if BUILDFLAG(IS_OHOS) ++bool ConvertCefValueToBlinkMsg(CefRefPtr& original, blink::WebMessagePort::Message& message); ++#endif ++ + #if BUILDFLAG(IS_OHOS) + bool ShouldShowLoadingUI() override; + #endif +@@ -470,6 +476,7 @@ class CefBrowserHostBase : public CefBrowserHost, + void StoreWebArchiveInternal( + CefRefPtr callback, + const CefString& path); ++ uint64_t GetCurrentTimestamp(); + #endif // IS_OHOS + bool UseLegacyGeolocationPermissionAPI(); + // GURL is supplied by the content layer as requesting frame. +@@ -488,9 +495,9 @@ class CefBrowserHostBase : public CefBrowserHost, + runnerMap_; + std::unordered_map> + receiverMap_; ++ uint64_t last_zoom_time_ = 0; + #endif + +- CefHitData cef_hit_data_; + CefRefPtr geolocation_permissions_; + std::unique_ptr permission_request_handler_; + IMPLEMENT_REFCOUNTING(CefBrowserHostBase); +diff --git a/src/cef/libcef/browser/browser_info_manager.cc b/src/cef/libcef/browser/browser_info_manager.cc +index d4caf26dec4..c585d4fe98e +--- a/src/cef/libcef/browser/browser_info_manager.cc ++++ b/src/cef/libcef/browser/browser_info_manager.cc +@@ -107,7 +107,8 @@ scoped_refptr CefBrowserInfoManager::CreatePopupBrowserInfo( + bool CefBrowserInfoManager::CanCreateWindow(content::RenderFrameHost* opener, + const GURL& target_url, + WindowOpenDisposition disposition, +- bool user_gesture) { ++ bool user_gesture, ++ CefRefPtr callback) { + CEF_REQUIRE_UIT(); + content::Referrer referrer; + content::OpenURLParams params(target_url, referrer, disposition, +@@ -118,6 +119,7 @@ bool CefBrowserInfoManager::CanCreateWindow(content::RenderFrameHost* opener, + CefRefPtr browser; + if (!MaybeAllowNavigation(opener, params, browser) || !browser) { + LOG(INFO) << "not allow popup, cancel the popup"; ++ callback->Cancel(); + return false; + } + +@@ -130,9 +132,12 @@ bool CefBrowserInfoManager::CanCreateWindow(content::RenderFrameHost* opener, + DCHECK(opener_frame); + allow = !handler->OnPreBeforePopup( + browser.get(), opener_frame, target_url.spec(), +- static_cast(disposition), user_gesture); ++ static_cast(disposition), user_gesture, callback); + } + } ++ if (!allow) { ++ callback->Cancel(); ++ } + return allow; + } + #endif +diff --git a/src/cef/libcef/browser/browser_info_manager.h b/src/cef/libcef/browser/browser_info_manager.h +index 2426df47825..7d56b408fec +--- a/src/cef/libcef/browser/browser_info_manager.h ++++ b/src/cef/libcef/browser/browser_info_manager.h +@@ -84,7 +84,8 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver { + bool CanCreateWindow(content::RenderFrameHost* opener, + const GURL& target_url, + WindowOpenDisposition disposition, +- bool user_gesture); ++ bool user_gesture, ++ CefRefPtr callback); + #endif + + // Called from WebContentsDelegate::GetCustomWebContentsView (alloy runtime +diff --git a/src/cef/libcef/browser/browser_platform_delegate.cc b/src/cef/libcef/browser/browser_platform_delegate.cc +index d3f93c844f9..b85efb70ae8 +--- a/src/cef/libcef/browser/browser_platform_delegate.cc ++++ b/src/cef/libcef/browser/browser_platform_delegate.cc +@@ -439,4 +439,4 @@ int CefBrowserPlatformDelegate::TranslateWebEventModifiers( + if (cef_modifiers & EVENTFLAG_IS_REPEAT) + result |= blink::WebInputEvent::kIsAutoRepeat; + return result; +-} ++} +\ No newline at end of file +diff --git a/src/cef/libcef/browser/browser_platform_delegate.h b/src/cef/libcef/browser/browser_platform_delegate.h +index f69fa5b0c42..5da95330776 +--- a/src/cef/libcef/browser/browser_platform_delegate.h ++++ b/src/cef/libcef/browser/browser_platform_delegate.h +@@ -370,6 +370,7 @@ class CefBrowserPlatformDelegate { + bool right_aligned, + bool allow_multiple_selection); + ++ virtual void SetShouldFrameSubmissionBeforeDraw(bool should) {}; + protected: + // Allow deletion via std::unique_ptr only. + friend std::default_delete; +diff --git a/src/cef/libcef/browser/context.cc b/src/cef/libcef/browser/context.cc +index 382ca097c27..0d07978515c +--- a/src/cef/libcef/browser/context.cc ++++ b/src/cef/libcef/browser/context.cc +@@ -26,6 +26,12 @@ + #include "chrome/install_static/initialize_from_primary_module.h" + #endif + ++#if BUILDFLAG(IS_OHOS) ++#include "cef/libcef/browser/net_service/net_helpers.h" ++#include "content/public/browser/network_service_instance.h" ++#include "services/network/public/mojom/network_service.mojom.h" ++#endif ++ + namespace { + + CefContext* g_context = nullptr; +@@ -85,9 +91,14 @@ bool GetColor(const cef_color_t cef_in, bool is_windowless, SkColor* sk_out) { + return true; + } + ++#if BUILDFLAG(IS_OHOS) ++ *sk_out = SkColorSetARGB(CefColorGetA(cef_in), CefColorGetR(cef_in), CefColorGetG(cef_in), ++ CefColorGetB(cef_in)); ++#else + // Ignore the alpha component. + *sk_out = SkColorSetRGB(CefColorGetR(cef_in), CefColorGetG(cef_in), + CefColorGetB(cef_in)); ++#endif + return true; + } + +@@ -303,6 +314,33 @@ void CefSetOSModalLoop(bool osModalLoop) { + #endif // BUILDFLAG(IS_WIN) + } + ++#if BUILDFLAG(IS_OHOS) ++void CefApplyHttpDns() { ++ if (!net_service::NetHelpers::HasValidDnsOverHttpConfig()) { ++ LOG(WARNING) << __func__ << " User input mal mode:" ++ << net_service::NetHelpers::doh_mode; ++ return; ++ } ++ ++ network::mojom::NetworkService* network_service = ++ content::GetNetworkService(); ++ if (network_service) { ++ auto config = net::DnsOverHttpsServerConfig::FromString( ++ net_service::NetHelpers::DnsOverHttpServerConfig()); ++ if (config.has_value()) { ++ network_service->ConfigureStubHostResolver( ++ true, net_service::NetHelpers::DnsOverHttpMode(), ++ {{std::move(*config)}}, true); ++ } else { ++ LOG(INFO) << __func__ << "server config is invalid"; ++ } ++ } else { ++ LOG(INFO) << __func__ ++ << "will apply doh config after network service created"; ++ } ++} ++#endif ++ + // CefContext + + CefContext::CefContext() +diff --git a/src/cef/libcef/browser/extensions/extensions_api_client.cc b/src/cef/libcef/browser/extensions/extensions_api_client.cc +index 9dd257baa66..b2d10199603 +--- a/src/cef/libcef/browser/extensions/extensions_api_client.cc ++++ b/src/cef/libcef/browser/extensions/extensions_api_client.cc +@@ -20,6 +20,7 @@ + + #if BUILDFLAG(IS_OHOS) + #include "printing/buildflags/buildflags.h" ++#include "libcef/browser/printing/ohos_print_manager.h" + #if BUILDFLAG(ENABLE_PRINT_PREVIEW) + #include "libcef/browser/printing/print_view_manager.h" + #endif +@@ -64,6 +65,11 @@ CefExtensionsAPIClient::CreateMimeHandlerViewGuestDelegate( + void CefExtensionsAPIClient::AttachWebContentsHelpers( + content::WebContents* web_contents) const { + PrefsTabHelper::CreateForWebContents(web_contents); ++ ++#if BUILDFLAG(IS_OHOS) ++ printing::OhosPrintManager::CreateForWebContents(web_contents); ++#endif ++ + #if BUILDFLAG(IS_OHOS) && BUILDFLAG(ENABLE_PRINT_PREVIEW) + printing::CefPrintViewManager::CreateForWebContents(web_contents); + #endif +diff --git a/src/cef/libcef/browser/file_dialog_manager.cc b/src/cef/libcef/browser/file_dialog_manager.cc +index d6eb454fadc..888675941ab +--- a/src/cef/libcef/browser/file_dialog_manager.cc ++++ b/src/cef/libcef/browser/file_dialog_manager.cc +@@ -7,6 +7,7 @@ + + #include + ++#include "build/build_config.h" + #include "include/cef_dialog_handler.h" + #include "libcef/browser/alloy/alloy_browser_host_impl.h" + #include "libcef/browser/thread_util.h" +@@ -15,6 +16,10 @@ + #include "content/public/browser/render_frame_host.h" + #include "net/base/directory_lister.h" + ++#if BUILDFLAG(IS_OHOS) ++#include "base/datashare_uri_utils.h" ++#endif ++ + namespace { + + class CefFileDialogCallbackImpl : public CefFileDialogCallback { +@@ -357,8 +362,14 @@ void CefFileDialogManager::OnRunFileChooserDelegateCallback( + + // Convert FilePath list to SelectedFileInfo list. + for (size_t i = 0; i < file_paths.size(); ++i) { ++ std::u16string display_name = std::u16string(); ++#if BUILDFLAG(IS_OHOS) ++ if (file_paths[i].IsDataShareUri()) { ++ display_name = base::GetFileDisplayName(file_paths[i]); ++ } ++#endif + auto info = blink::mojom::FileChooserFileInfo::NewNativeFile( +- blink::mojom::NativeFileInfo::New(file_paths[i], std::u16string())); ++ blink::mojom::NativeFileInfo::New(file_paths[i], display_name)); + selected_files.push_back(std::move(info)); + } + } +diff --git a/src/cef/libcef/browser/frame_host_impl.cc b/src/cef/libcef/browser/frame_host_impl.cc +index b79a4ee9f58..1aa574a3237 +--- a/src/cef/libcef/browser/frame_host_impl.cc ++++ b/src/cef/libcef/browser/frame_host_impl.cc +@@ -660,12 +660,6 @@ void CefFrameHostImpl::UpdateDraggableRegions( + } + + #if BUILDFLAG(IS_OHOS) +-void CefFrameHostImpl::OnUpdateHitData(cef::mojom::HitDataParamsPtr params) { +- auto browser = GetBrowserHostBase(); +- if (browser) +- browser->OnUpdateHitData(params->type, params->extra_data_for_type); +-} +- + void CefFrameHostImpl::OnGetImageForContextNode( + cef::mojom::GetImageForContextNodeParamsPtr params) { + CefImageImpl* image_impl = new (std::nothrow) CefImageImpl(); +@@ -754,20 +748,40 @@ void CefFrameHostImpl::LoadHeaderUrl(const CefString& url, + additionalHttpHeaders); + } + +-void CefFrameHostImpl::SendTouchEvent(const CefTouchEvent& event) { +- cef::mojom::TouchEventParamsPtr touch_event = +- cef::mojom::TouchEventParams::New(); +- touch_event->x = event.x; +- touch_event->y = event.y; +- touch_event->width = event.radius_x; +- touch_event->height = event.radius_y; ++void CefFrameHostImpl::OnScriptedPrint(bool user_initiated) { ++ CefRefPtr handler = nullptr; ++ auto browser = GetBrowserHostBase(); ++ if (!browser) { ++ LOG(ERROR) << "browser is nullptr"; ++ return; ++ } ++ auto client = browser->GetClient(); ++ if (client) { ++ handler = client->GetPrintHandler(); ++ } ++ if (handler) { ++ handler->OnPrintStart(GetBrowser()); ++ } ++} ++ ++void CefFrameHostImpl::SendHitEvent( ++ float x, ++ float y, ++ float width, ++ float height) { ++ cef::mojom::HitEventParamsPtr hit_event = ++ cef::mojom::HitEventParams::New(); ++ hit_event->x = x; ++ hit_event->y = y; ++ hit_event->width = width; ++ hit_event->height = height; + SendToRenderFrame(__FUNCTION__, + base::BindOnce( +- [](cef::mojom::TouchEventParamsPtr touch_event, ++ [](cef::mojom::HitEventParamsPtr hit_event, + const RenderFrameType& render_frame) { +- render_frame->SendTouchEvent(std::move(touch_event)); ++ render_frame->SendHitEvent(std::move(hit_event)); + }, +- std::move(touch_event))); ++ std::move(hit_event))); + } + + void CefFrameHostImpl::SetInitialScale(float scale) { +@@ -908,6 +922,31 @@ void CefFrameHostImpl::SlideScroll(float vx, + }, + vx, vy)); + } ++ ++void CefFrameHostImpl::ZoomBy(float delta, ++ float width, ++ float height) { ++ SendToRenderFrame(__FUNCTION__, ++ base::BindOnce( ++ [](float delta, float width, float height, ++ const RenderFrameType& render_frame) { ++ render_frame->ZoomBy(delta, width, height); ++ }, ++ delta, width, height)); ++} ++ ++void CefFrameHostImpl::GetHitData(int& type, ++ CefString& extra_data) { ++ std::string temp_extra_data; ++ SendToRenderFrame(__FUNCTION__, ++ base::BindOnce( ++ [](int32_t* out_type, std::string* out_extra_data, ++ const RenderFrameType& render_frame) { ++ render_frame->GetHitData(out_type, out_extra_data); ++ }, ++ &type, &temp_extra_data)); ++ extra_data = temp_extra_data; ++} + #endif // BUILDFLAG(IS_OHOS) + + void CefExecuteJavaScriptWithUserGestureForTests(CefRefPtr frame, +diff --git a/src/cef/libcef/browser/frame_host_impl.h b/src/cef/libcef/browser/frame_host_impl.h +index 5a43da2de74..cec4148c551 +--- a/src/cef/libcef/browser/frame_host_impl.h ++++ b/src/cef/libcef/browser/frame_host_impl.h +@@ -144,15 +144,16 @@ class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame { + absl::optional> regions) + override; + #if BUILDFLAG(IS_OHOS) +- void OnUpdateHitData(cef::mojom::HitDataParamsPtr params) override; + void OnGetImageForContextNode( + cef::mojom::GetImageForContextNodeParamsPtr params) override; + void OnGetImageForContextNodeNull() override; + void LoadHeaderUrl(const CefString& url, + const CefString& additionalHttpHeaders) override; ++ void OnScriptedPrint(bool user_initiated) override; + + // Send the touch point to the rederer to get hitdata. + void SendTouchEvent(const CefTouchEvent& event); ++ void SendHitEvent(float x, float y, float width, float height); + + void SetInitialScale(float scale); + void SetJsOnlineProperty(bool network_up); +@@ -173,6 +174,8 @@ class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame { + void ScrollTo(float x, float y); + void ScrollBy(float delta_x, float delta_y); + void SlideScroll(float vx, float vy); ++ void ZoomBy(float delta, float width, float height); ++ void GetHitData(int& type, CefString& extra_data); + #endif // BUILDFLAG(IS_OHOS) + + static const int64_t kMainFrameId; +diff --git a/src/cef/libcef/browser/icon_helper.cc b/src/cef/libcef/browser/icon_helper.cc +index a35a195e514..ef644663e33 +--- a/src/cef/libcef/browser/icon_helper.cc ++++ b/src/cef/libcef/browser/icon_helper.cc +@@ -7,6 +7,7 @@ + + #include "include/cef_display_handler.h" + ++#include "base/hash/hash.h" + #include "base/logging.h" + #include "components/favicon_base/select_favicon_frames.h" + #include "content/public/browser/favicon_status.h" +@@ -69,7 +70,8 @@ void IconHelper::OnUpdateFaviconURL( + return; + } + for (const auto& candidate : candidates) { +- if (!candidate->icon_url.is_valid()) ++ if (!candidate->icon_url.is_valid() || ++ CheckFailedFaviconUrl(candidate->icon_url)) + continue; + switch (candidate->icon_type) { + case blink::mojom::FaviconIconType::kFavicon: +@@ -115,6 +117,7 @@ void IconHelper::DownloadFaviconCallback( + const std::vector& bitmaps, + const std::vector& original_bitmap_sizes) { + if (http_status_code == 404) { ++ InsertFailedFaviconUrl(image_url); + return; + } + +@@ -149,7 +152,7 @@ void IconHelper::DownloadFaviconCallback( + + if (web_contents_) { + content::NavigationEntry* entry = +- web_contents_->GetController().GetLastCommittedEntry(); ++ web_contents_->GetController().GetLastCommittedEntry(); + if (entry) { + entry->GetFavicon().valid = true; + entry->GetFavicon().url = image_url; +@@ -187,3 +190,22 @@ void IconHelper::OnReceivedIconUrl(const CefString& image_url, + handler_->OnReceivedIconUrl(image_url, data, width, height, color_type, + alpha_type); + } ++ ++void IconHelper::InsertFailedFaviconUrl(const GURL& icon_url) { ++ size_t url_hash = base::FastHash(icon_url.spec()); ++ failed_favicon_urls_set_.insert(url_hash); ++} ++ ++bool IconHelper::CheckFailedFaviconUrl(const GURL& icon_url) { ++ size_t url_hash = base::FastHash(icon_url.spec()); ++ return failed_favicon_urls_set_.find(url_hash) != ++ failed_favicon_urls_set_.end(); ++} ++ ++void IconHelper::ClearFailedFaviconUrlSets( ++ content::NavigationHandle* navigation) { ++ if (navigation && navigation->IsInPrimaryMainFrame() && ++ navigation->GetReloadType() == content::ReloadType::BYPASSING_CACHE) { ++ failed_favicon_urls_set_.clear(); ++ } ++} +diff --git a/src/cef/libcef/browser/icon_helper.h b/src/cef/libcef/browser/icon_helper.h +index c764342d66b..d72e6b2897f +--- a/src/cef/libcef/browser/icon_helper.h ++++ b/src/cef/libcef/browser/icon_helper.h +@@ -7,11 +7,13 @@ + #define CEF_LIBCEF_BROWSER_ICON_HELPER_H_ + #pragma once + ++#include + #include + + #include "include/cef_base.h" + #include "libcef/browser/thread_util.h" + ++#include "content/public/browser/navigation_handle.h" + #include "third_party/blink/public/mojom/favicon/favicon_url.mojom-forward.h" + #include "third_party/skia/include/core/SkBitmap.h" + +@@ -61,12 +63,17 @@ class IconHelper : public virtual CefBaseRefCounted { + size_t height, + cef_color_type_t color_type, + cef_alpha_type_t alpha_type); ++ void ClearFailedFaviconUrlSets(content::NavigationHandle* navigation_handle); + + private: ++ void InsertFailedFaviconUrl(const GURL& icon_url); ++ bool CheckFailedFaviconUrl(const GURL& icon_url); ++ + content::WebContents* web_contents_ = nullptr; + CefRefPtr handler_ = nullptr; + CefRefPtr browser_ = nullptr; + SkBitmap bitmap_; ++ std::unordered_set failed_favicon_urls_set_; + + IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(IconHelper); + }; +diff --git a/src/cef/libcef/browser/javascript/oh_gin_javascript_bridge_dispatcher_host.cc b/src/cef/libcef/browser/javascript/oh_gin_javascript_bridge_dispatcher_host.cc +index a26d2f3e810..66581ddca4b +--- a/src/cef/libcef/browser/javascript/oh_gin_javascript_bridge_dispatcher_host.cc ++++ b/src/cef/libcef/browser/javascript/oh_gin_javascript_bridge_dispatcher_host.cc +@@ -285,9 +285,11 @@ void OhGinJavascriptBridgeDispatcherHost::OnInvokeMethod( + + CefRefPtr result = CefListValue::Create(); + ++ if (!client_) ++ return; + int error = + client_->NotifyJavaScriptResult(ceflistvalue, method, classname, result); +- *error_code = OhGinJavascriptBridgeError(error); ++ *error_code = static_cast(error); + if (error != 0) { + return; + } +diff --git a/src/cef/libcef/browser/javascript/oh_gin_javascript_bridge_message_filter.cc b/src/cef/libcef/browser/javascript/oh_gin_javascript_bridge_message_filter.cc +index b2d7083ba3d..3b42ece32d3 +--- a/src/cef/libcef/browser/javascript/oh_gin_javascript_bridge_message_filter.cc ++++ b/src/cef/libcef/browser/javascript/oh_gin_javascript_bridge_message_filter.cc +@@ -6,6 +6,8 @@ + #include "oh_gin_javascript_bridge_message_filter.h" + + #include ++#include "base/memory/scoped_refptr.h" ++#include "base/task/thread_pool.h" + #include "base/types/pass_key.h" + #include "cef/libcef/common/javascript/oh_gin_javascript_bridge_messages.h" + #include "content/browser/renderer_host/agent_scheduling_group_host.h" +@@ -31,7 +33,9 @@ OhGinJavascriptBridgeMessageFilter::OhGinJavascriptBridgeMessageFilter( + agent_scheduling_group_(agent_scheduling_group), + current_routing_id_(MSG_ROUTING_NONE) {} + +-OhGinJavascriptBridgeMessageFilter::~OhGinJavascriptBridgeMessageFilter() {} ++OhGinJavascriptBridgeMessageFilter::~OhGinJavascriptBridgeMessageFilter() { ++ LOG(INFO) << "OhGinJavascriptBridgeMessageFilter dtor"; ++} + + void OhGinJavascriptBridgeMessageFilter::OnDestruct() const { + if (content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { +@@ -43,9 +47,12 @@ void OhGinJavascriptBridgeMessageFilter::OnDestruct() const { + + bool OhGinJavascriptBridgeMessageFilter::OnMessageReceived( + const IPC::Message& message) { +- std::thread dump_thread( +- [message, this] { this->OnMessageReceivedThread(message); }); +- dump_thread.detach(); ++ base::ThreadPool::PostTask( ++ FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_BLOCKING}, ++ base::BindOnce( ++ base::IgnoreResult( ++ &OhGinJavascriptBridgeMessageFilter::OnMessageReceivedThread), ++ base::WrapRefCounted(this), message)); + return true; + } + +diff --git a/src/cef/libcef/browser/javascript_dialog_manager.cc b/src/cef/libcef/browser/javascript_dialog_manager.cc +index bc967e32a89..1d430511512 +--- a/src/cef/libcef/browser/javascript_dialog_manager.cc ++++ b/src/cef/libcef/browser/javascript_dialog_manager.cc +@@ -152,6 +152,7 @@ void CefJavaScriptDialogManager::RunBeforeUnloadDialog( + } + + const std::u16string& message_text = u"Is it OK to leave/reload this page?"; ++ std::string url = web_contents ? web_contents->GetURL().spec() : ""; + + CefRefPtr client = browser_->GetClient(); + if (client.get()) { +@@ -162,7 +163,7 @@ void CefJavaScriptDialogManager::RunBeforeUnloadDialog( + + // Execute the user callback. + bool handled = handler->OnBeforeUnloadDialog( +- browser_, message_text, is_reload, callbackPtr.get()); ++ browser_, url, message_text, is_reload, callbackPtr.get()); + if (handled) + return; + +diff --git a/src/cef/libcef/browser/net_service/cookie_manager_impl.cc b/src/cef/libcef/browser/net_service/cookie_manager_impl.cc +index 70abc9df6a4..f0b6f66aa69 +--- a/src/cef/libcef/browser/net_service/cookie_manager_impl.cc ++++ b/src/cef/libcef/browser/net_service/cookie_manager_impl.cc +@@ -80,6 +80,18 @@ void ExecuteVisitor(CefRefPtr visitor, + std::string cookie_line = net::CanonicalCookie::BuildCookieLine(cookies); + visitor->SetCookieLine(CefString(cookie_line)); + } ++ ++bool FixInvalidGurl(const CefString& url, GURL &gurl) { ++ if (!gurl.is_valid()) { ++ GURL fixedGurl = GURL("https://" + url.ToString()); ++ if (fixedGurl.is_valid() && fixedGurl.host() == url.ToString()) { ++ gurl = fixedGurl; ++ return true; ++ } ++ return false; ++ } ++ return true; ++} + } // namespace + + CefCookieManagerImpl::CefCookieManagerImpl() : cookie_thread{"CookieThread"} { +@@ -170,8 +182,15 @@ bool CefCookieManagerImpl::VisitUrlCookies( + return false; + + GURL gurl = GURL(url.ToString()); +- if (!gurl.is_valid()) ++#if BUILDFLAG(IS_OHOS) ++ if(!FixInvalidGurl(url, gurl)) { + return false; ++ } ++#else ++ if (!gurl.is_valid()) { ++ return false; ++ } ++#endif + + if (!ValidContext()) { + StoreOrTriggerInitCallback(base::BindOnce( +@@ -187,9 +206,15 @@ bool CefCookieManagerImpl::SetCookie(const CefString& url, + const CefCookie& cookie, + CefRefPtr callback) { + GURL gurl = GURL(url.ToString()); ++#if BUILDFLAG(IS_OHOS) ++ if(!FixInvalidGurl(url, gurl)) { ++ return false; ++ } ++#else + if (!gurl.is_valid()) { + return false; + } ++#endif + if (!ValidContext()) { + StoreOrTriggerInitCallback(base::BindOnce( + base::IgnoreResult(&CefCookieManagerImpl::SetCookieInternal), this, +@@ -291,11 +316,15 @@ bool CefCookieManagerImpl::VisitUrlCookiesInternal( + DCHECK(visitor); + DCHECK(url.is_valid()); + ++#if BUILDFLAG(IS_OHOS) ++ net::CookieOptions options = net::CookieOptions::MakeAllInclusive(); ++#else + net::CookieOptions options; + if (includeHttpOnly) + options.set_include_httponly(); + options.set_same_site_cookie_context( + net::CookieOptions::SameSiteCookieContext::MakeInclusive()); ++#endif + + auto browser_context = GetBrowserContext(browser_context_getter_); + if (!browser_context) +diff --git a/src/cef/libcef/browser/net_service/login_delegate.cc b/src/cef/libcef/browser/net_service/login_delegate.cc +index 326b285c087..0ebfc51d3d6 +--- a/src/cef/libcef/browser/net_service/login_delegate.cc ++++ b/src/cef/libcef/browser/net_service/login_delegate.cc +@@ -4,8 +4,6 @@ + + #include "libcef/browser/net_service/login_delegate.h" + +-#include +- + #include "libcef/browser/browser_host_base.h" + #include "libcef/browser/net_database/cef_data_base_impl.h" + #include "libcef/browser/net_service/browser_urlrequest_impl.h" +@@ -80,11 +78,11 @@ class AuthCallbackImpl : public CefAuthCallback { + char password[MAX_PWD_LENGTH + 1] = {0}; + dataBase->GetHttpAuthCredentials(host_, realm_, username, password, MAX_PWD_LENGTH + 1); + if (username.empty() || strlen(password) == 0) { +- (void)memset_s(password, MAX_PWD_LENGTH + 1, 0, MAX_PWD_LENGTH + 1); ++ memset(password, 0, MAX_PWD_LENGTH + 1); + return false; + } + CefString passwordCef(password, strlen(password)); +- (void)memset_s(password, MAX_PWD_LENGTH + 1, 0, MAX_PWD_LENGTH + 1); ++ memset(password, 0, MAX_PWD_LENGTH + 1); + if (!task_runner_->RunsTasksInCurrentSequence()) { + task_runner_->PostTask( + FROM_HERE, base::BindOnce(&AuthCallbackImpl::Continue, this, username, +diff --git a/src/cef/libcef/browser/net_service/net_helpers.cc b/src/cef/libcef/browser/net_service/net_helpers.cc +index c8c630566b9..fb8804bbcc2 +--- a/src/cef/libcef/browser/net_service/net_helpers.cc ++++ b/src/cef/libcef/browser/net_service/net_helpers.cc +@@ -34,6 +34,11 @@ bool NetHelpers::accept_cookies = true; + bool NetHelpers::third_party_cookies = false; + int NetHelpers::cache_mode = 0; + ++#if BUILDFLAG(IS_OHOS) ++int NetHelpers::doh_mode = -1; ++std::string NetHelpers::doh_config = ""; ++#endif ++ + bool NetHelpers::ShouldBlockContentUrls() { + return !allow_content_access; + } +@@ -50,6 +55,45 @@ bool NetHelpers::IsThirdPartyCookieAllowed() { + return third_party_cookies; + } + ++#if BUILDFLAG(IS_OHOS) ++net::SecureDnsMode NetHelpers::DnsOverHttpMode() { ++ net::SecureDnsMode enum_sec_dns_mode = net::SecureDnsMode::kAutomatic; ++ switch (doh_mode) { ++ case 2: ++ enum_sec_dns_mode = net::SecureDnsMode::kSecure; ++ break; ++ case 1: ++ enum_sec_dns_mode = net::SecureDnsMode::kAutomatic; ++ break; ++ case 0: ++ enum_sec_dns_mode = net::SecureDnsMode::kOff; ++ break; ++ default: ++ LOG(WARNING) << __func__ << " User input mal mode:" << doh_mode; ++ break; ++ } ++ ++ return enum_sec_dns_mode; ++} ++ ++std::string NetHelpers::DnsOverHttpServerConfig() { ++ return doh_config; ++} ++ ++bool NetHelpers::HasValidDnsOverHttpConfig() { ++ if (doh_config.empty()) { ++ return false; ++ } ++ ++ if (doh_mode > static_cast(net::SecureDnsMode::kSecure) || ++ doh_mode < static_cast(net::SecureDnsMode::kOff)) { ++ return false; ++ } ++ ++ return true; ++} ++#endif ++ + bool IsSpecialFileUrl(const GURL& url) { + if (!url.is_valid() || !url.SchemeIsFile() || !url.has_path()) + return false; +diff --git a/src/cef/libcef/browser/net_service/net_helpers.h b/src/cef/libcef/browser/net_service/net_helpers.h +index 6c8fa83c33a..4f9e7662e94 +--- a/src/cef/libcef/browser/net_service/net_helpers.h ++++ b/src/cef/libcef/browser/net_service/net_helpers.h +@@ -5,6 +5,11 @@ + #ifndef CEF_LIBCEF_BROWSER_NET_SERVICE_NET_HELPERS_H_ + #define CEF_LIBCEF_BROWSER_NET_SERVICE_NET_HELPERS_H_ + ++#include ++ ++#include "build/build_config.h" ++#include "net/dns/public/secure_dns_mode.h" ++ + class GURL; + + namespace net_service { +@@ -24,12 +29,23 @@ class NETHELPERS_EXPORT NetHelpers { + static bool IsAllowAcceptCookies(); + static bool IsThirdPartyCookieAllowed(); + ++#if BUILDFLAG(IS_OHOS) ++ static net::SecureDnsMode DnsOverHttpMode(); ++ static std::string DnsOverHttpServerConfig(); ++ static bool HasValidDnsOverHttpConfig(); ++#endif ++ + static bool allow_content_access; + static bool allow_file_access; + static bool is_network_blocked; + static bool accept_cookies; + static bool third_party_cookies; + static int cache_mode; ++ ++#if BUILDFLAG(IS_OHOS) ++ static int doh_mode; ++ static std::string doh_config; ++#endif + }; + + bool IsSpecialFileUrl(const GURL& url); +diff --git a/src/cef/libcef/browser/net_service/proxy_config_monitor.cc b/src/cef/libcef/browser/net_service/proxy_config_monitor.cc +new file mode 100644 +index 00000000000..07f46f3aa2b +--- /dev/null ++++ b/src/cef/libcef/browser/net_service/proxy_config_monitor.cc +@@ -0,0 +1,159 @@ ++/* ++ * Copyright (c) 2023 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 ++ * ++ * 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, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++#include ++#include ++#include ++#include ++ ++#include "base/barrier_closure.h" ++#include "base/bind.h" ++#include "base/command_line.h" ++#include "base/no_destructor.h" ++#include "base/trace_event/trace_event.h" ++#include "mojo/public/cpp/bindings/pending_remote.h" ++#include "net/traffic_annotation/network_traffic_annotation.h" ++#include "libcef/browser/net_service/proxy_config_monitor.h" ++#include "services/network/public/mojom/network_context.mojom.h" ++ ++namespace NWEB { ++ ++namespace { ++ ++const char kProxyServerSwitch[] = "proxy-server"; ++const char kProxyBypassListSwitch[] = "proxy-bypass-list"; ++ ++constexpr net::NetworkTrafficAnnotationTag kProxyConfigTrafficAnnotation = ++ net::DefineNetworkTrafficAnnotation("webview_proxy_config", R"( ++ semantics { ++ sender: "Proxy configuration via a command line flag" ++ description: ++ "Used to fetch HTTP/HTTPS/SOCKS5/PAC proxy configuration when " ++ "proxy is configured by the --proxy-server command line flag. " ++ "When proxy implies automatic configuration, it can send network " ++ "requests in the scope of this annotation." ++ trigger: ++ "Whenever a network request is made when the system proxy settings " ++ "are used, and they indicate to use a proxy server." ++ data: ++ "Proxy configuration." ++ destination: OTHER ++ destination_other: "The proxy server specified in the configuration." ++ } ++ policy { ++ cookies_allowed: NO ++ setting: ++ "This request cannot be disabled in settings. However it will never " ++ "be made if user does not run with the '--proxy-server' switch." ++ policy_exception_justification: ++ "Not implemented, behaviour only available behind a switch." ++ })"); ++ ++} // namespace ++ ++ProxyConfigMonitor::ProxyConfigMonitor() { ++ TRACE_EVENT0("startup", "ProxyConfigMonitor"); ++ proxy_config_service_ = ++ std::make_unique( ++ base::ThreadTaskRunnerHandle::Get()); ++ proxy_config_service_->set_exclude_pac_url(true); ++ proxy_config_service_->AddObserver(this); ++} ++ ++ProxyConfigMonitor::~ProxyConfigMonitor() { ++ proxy_config_service_->RemoveObserver(this); ++} ++ ++ProxyConfigMonitor* ProxyConfigMonitor::GetInstance() { ++ static base::NoDestructor instance; ++ return instance.get(); ++} ++ ++void ProxyConfigMonitor::AddProxyToNetworkContextParams( ++ network::mojom::NetworkContextParams* network_context_params) { ++ const base::CommandLine& command_line = ++ *base::CommandLine::ForCurrentProcess(); ++ if (command_line.HasSwitch(kProxyServerSwitch)) { ++ std::string proxy = command_line.GetSwitchValueASCII(kProxyServerSwitch); ++ net::ProxyConfig proxy_config; ++ proxy_config.proxy_rules().ParseFromString(proxy); ++ if (command_line.HasSwitch(kProxyBypassListSwitch)) { ++ std::string bypass_list = ++ command_line.GetSwitchValueASCII(kProxyBypassListSwitch); ++ proxy_config.proxy_rules().bypass_rules.ParseFromString(bypass_list); ++ } ++ ++ network_context_params->initial_proxy_config = ++ net::ProxyConfigWithAnnotation(proxy_config, ++ kProxyConfigTrafficAnnotation); ++ } else { ++ mojo::PendingRemote proxy_config_client; ++ network_context_params->proxy_config_client_receiver = ++ proxy_config_client.InitWithNewPipeAndPassReceiver(); ++ proxy_config_client_set_.Add(std::move(proxy_config_client)); ++ ++ net::ProxyConfigWithAnnotation proxy_config; ++ net::ProxyConfigService::ConfigAvailability availability = ++ proxy_config_service_->GetLatestProxyConfig(&proxy_config); ++ if (availability == net::ProxyConfigService::CONFIG_VALID) ++ network_context_params->initial_proxy_config = proxy_config; ++ } ++} ++ ++void ProxyConfigMonitor::OnProxyConfigChanged( ++ const net::ProxyConfigWithAnnotation& config, ++ net::ProxyConfigService::ConfigAvailability availability) { ++ for (const auto& proxy_config_client : proxy_config_client_set_) { ++ switch (availability) { ++ case net::ProxyConfigService::CONFIG_VALID: ++ proxy_config_client->OnProxyConfigUpdated(config); ++ break; ++ case net::ProxyConfigService::CONFIG_UNSET: ++ proxy_config_client->OnProxyConfigUpdated( ++ net::ProxyConfigWithAnnotation::CreateDirect()); ++ break; ++ case net::ProxyConfigService::CONFIG_PENDING: ++ NOTREACHED(); ++ break; ++ } ++ } ++} ++ ++std::string ProxyConfigMonitor::SetProxyOverride( ++ const std::vector& ++ proxy_rules, ++ const std::vector& bypass_rules, ++ const bool reverse_bypass, ++ base::OnceClosure callback) { ++ return proxy_config_service_->SetProxyOverride( ++ proxy_rules, bypass_rules, reverse_bypass, ++ base::BindOnce(&ProxyConfigMonitor::FlushProxyConfig, ++ base::Unretained(this), std::move(callback))); ++} ++ ++void ProxyConfigMonitor::ClearProxyOverride(base::OnceClosure callback) { ++ proxy_config_service_->ClearProxyOverride( ++ base::BindOnce(&ProxyConfigMonitor::FlushProxyConfig, ++ base::Unretained(this), std::move(callback))); ++} ++ ++void ProxyConfigMonitor::FlushProxyConfig(base::OnceClosure callback) { ++ int count = proxy_config_client_set_.size(); ++ base::RepeatingClosure closure = ++ base::BarrierClosure(count, std::move(callback)); ++ for (auto& proxy_config_client : proxy_config_client_set_) ++ proxy_config_client->FlushProxyConfig(closure); ++} ++ ++} // namespace NWEB +diff --git a/src/cef/libcef/browser/net_service/proxy_config_monitor.h b/src/cef/libcef/browser/net_service/proxy_config_monitor.h +new file mode 100644 +index 00000000000..68d36c73789 +--- /dev/null ++++ b/src/cef/libcef/browser/net_service/proxy_config_monitor.h +@@ -0,0 +1,73 @@ ++/* ++ * Copyright (c) 2023 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 ++ * ++ * 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, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++#ifndef CEF_LIBCEF_BROWSER_NET_SERVICE_PROXY_CONFIG_MONITOR_H_ ++#define CEF_LIBCEF_BROWSER_NET_SERVICE_PROXY_CONFIG_MONITOR_H_ ++ ++#include ++#include ++#include ++ ++#include "base/no_destructor.h" ++#include "mojo/public/cpp/bindings/remote_set.h" ++#include "net/proxy_resolution/proxy_config_service_ohos.h" ++#include "services/network/public/mojom/network_service.mojom.h" ++ ++namespace network { ++namespace mojom { ++class ProxyConfigClient; ++} ++} // namespace network ++ ++namespace NWEB { ++ ++// This class configures proxy settings for NetworkContext if network service ++// is enabled. ++class ProxyConfigMonitor : public net::ProxyConfigService::Observer { ++ public: ++ ProxyConfigMonitor(const ProxyConfigMonitor&) = delete; ++ ProxyConfigMonitor& operator=(const ProxyConfigMonitor&) = delete; ++ ++ static ProxyConfigMonitor* GetInstance(); ++ ++ void AddProxyToNetworkContextParams( ++ network::mojom::NetworkContextParams* network_context_params); ++ std::string SetProxyOverride( ++ const std::vector& ++ proxy_rules, ++ const std::vector& bypass_rules, ++ const bool reverse_bypass, ++ base::OnceClosure callback); ++ void ClearProxyOverride(base::OnceClosure callback); ++ ++ private: ++ ProxyConfigMonitor(); ++ ~ProxyConfigMonitor() override; ++ ++ friend class base::NoDestructor; ++ // net::ProxyConfigService::Observer implementation: ++ void OnProxyConfigChanged( ++ const net::ProxyConfigWithAnnotation& config, ++ net::ProxyConfigService::ConfigAvailability availability) override; ++ ++ void FlushProxyConfig(base::OnceClosure callback); ++ ++ std::unique_ptr proxy_config_service_; ++ mojo::RemoteSet proxy_config_client_set_; ++}; ++ ++} // namespace ++ ++#endif // CEF_LIBCEF_BROWSER_NET_SERVICE_PROXY_CONFIG_MONITOR_H_ ++ +diff --git a/src/cef/libcef/browser/net_service/proxy_url_loader_factory.cc b/src/cef/libcef/browser/net_service/proxy_url_loader_factory.cc +index a016633fb53..18f44cd793a +--- a/src/cef/libcef/browser/net_service/proxy_url_loader_factory.cc ++++ b/src/cef/libcef/browser/net_service/proxy_url_loader_factory.cc +@@ -614,7 +614,8 @@ void InterceptedRequest::OnReceiveResponse( + request->SetURL(CefString(request_.url.spec())); + request->SetMethod(CefString(request_.method)); + request->Set(request_.headers); +- OnHttpErrorForUIThread(id_, request, request_.is_main_frame, request_.has_user_gesture, error_reponse); ++ request->SetDestination(request_.destination); ++ OnHttpErrorForUIThread(id_, request, request->IsMainFrame(), request_.has_user_gesture, error_reponse); + } + + if (current_request_uses_header_client_) { + diff --git a/src/cef/libcef/browser/net_service/resource_request_handler_wrapper.cc b/src/cef/libcef/browser/net_service/resource_request_handler_wrapper.cc +index dd61f9586df..1c03a4255e6 +--- a/src/cef/libcef/browser/net_service/resource_request_handler_wrapper.cc ++++ b/src/cef/libcef/browser/net_service/resource_request_handler_wrapper.cc +@@ -753,6 +753,9 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler { + + if (state->handler_) { + // Does the client want to handle the request? ++ if (request) { ++ state->pending_request_->SetDestination(request->destination); ++ } + resource_handler = state->handler_->GetResourceHandler( + init_state_->browser_, init_state_->frame_, + state->pending_request_.get()); +@@ -834,6 +837,9 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler { + + if (state->handler_) { + // Does the client want to handle the request? ++ if (request) { ++ state->pending_request_->SetDestination(request->destination); ++ } + resource_handler = state->handler_->GetResourceHandler( + init_state_->browser_, init_state_->frame_, + state->pending_request_.get()); +diff --git a/src/cef/libcef/browser/net_service/stream_reader_url_loader.cc b/src/cef/libcef/browser/net_service/stream_reader_url_loader.cc +index 6bbac04251d..200fadf1db7 +--- a/src/cef/libcef/browser/net_service/stream_reader_url_loader.cc ++++ b/src/cef/libcef/browser/net_service/stream_reader_url_loader.cc +@@ -18,9 +18,11 @@ + #include "base/threading/thread.h" + #include "base/threading/thread_task_runner_handle.h" + #include "content/public/browser/browser_thread.h" ++#include "net/base/features.h" + #include "net/base/io_buffer.h" + #include "net/http/http_status_code.h" + #include "net/http/http_util.h" ++#include "services/network/public/cpp/features.h" + #include "services/network/public/cpp/url_loader_completion_status.h" + + namespace net_service { +@@ -718,8 +720,15 @@ void StreamReaderURLLoader::ContinueResponse(bool was_redirected) { + void StreamReaderURLLoader::SendBody() { + DCHECK(thread_checker_.CalledOnValidThread()); + ++ MojoCreateDataPipeOptions options; ++ options.struct_size = sizeof(MojoCreateDataPipeOptions); ++ options.flags = MOJO_CREATE_DATA_PIPE_FLAG_NONE; ++ options.element_num_bytes = 1; ++ options.capacity_num_bytes = ++ network::features::GetDataPipeDefaultAllocationSize( ++ network::features::DataPipeAllocationSize::kLargerSizeIfPossible); + mojo::ScopedDataPipeConsumerHandle consumer_handle; +- if (CreateDataPipe(nullptr /*options*/, producer_handle_, consumer_handle) != ++ if (CreateDataPipe(&options /*options*/, producer_handle_, consumer_handle) != + MOJO_RESULT_OK) { + RequestComplete(net::ERR_FAILED); + return; +diff --git a/src/cef/libcef/browser/osr/browser_platform_delegate_osr.cc b/src/cef/libcef/browser/osr/browser_platform_delegate_osr.cc +index bdef16ae391..9c0ba9dad66 +--- a/src/cef/libcef/browser/osr/browser_platform_delegate_osr.cc ++++ b/src/cef/libcef/browser/osr/browser_platform_delegate_osr.cc +@@ -679,4 +679,11 @@ CefRenderWidgetHostViewOSR* CefBrowserPlatformDelegateOsr::GetOSRHostView() + } + + return nullptr; +-} +\ No newline at end of file ++} ++ ++void CefBrowserPlatformDelegateOsr::SetShouldFrameSubmissionBeforeDraw( ++ bool should) { ++ CefRenderWidgetHostViewOSR* view = GetOSRHostView(); ++ if (view) ++ view->SetShouldFrameSubmissionBeforeDraw(should); ++} +diff --git a/src/cef/libcef/browser/osr/browser_platform_delegate_osr.h b/src/cef/libcef/browser/osr/browser_platform_delegate_osr.h +index 7074ae9d773..2a3853c5013 +--- a/src/cef/libcef/browser/osr/browser_platform_delegate_osr.h ++++ b/src/cef/libcef/browser/osr/browser_platform_delegate_osr.h +@@ -99,6 +99,8 @@ class CefBrowserPlatformDelegateOsr + bool right_aligned, + bool allow_multiple_selection) override; + ++ void SetShouldFrameSubmissionBeforeDraw(bool should) override; ++ + // CefBrowserPlatformDelegateNative::WindowlessHandler methods: + CefWindowHandle GetParentWindowHandle() const override; + gfx::Point GetParentScreenPoint(const gfx::Point& view) const override; +diff --git a/src/cef/libcef/browser/osr/host_display_client_osr.cc b/src/cef/libcef/browser/osr/host_display_client_osr.cc +index ab354184464..f45e8a0c181 +--- a/src/cef/libcef/browser/osr/host_display_client_osr.cc ++++ b/src/cef/libcef/browser/osr/host_display_client_osr.cc +@@ -9,6 +9,7 @@ + #include "libcef/browser/osr/render_widget_host_view_osr.h" + + #include "base/memory/shared_memory_mapping.h" ++#include "base/trace_event/trace_event.h" + #include "components/viz/common/resources/resource_format.h" + #include "components/viz/common/resources/resource_sizes.h" + #include "mojo/public/cpp/system/platform_handle.h" +@@ -103,7 +104,10 @@ void CefLayeredWindowUpdaterOSR::Draw(const gfx::Rect& damage_rect, + CefHostDisplayClientOSR::CefHostDisplayClientOSR( + CefRenderWidgetHostViewOSR* const view, + gfx::AcceleratedWidget widget) +- : viz::HostDisplayClient(widget), view_(view) {} ++ : viz::HostDisplayClient(widget), view_(view) { ++ if (view_) ++ browser_impl_ = view_->browser_impl(); ++} + + CefHostDisplayClientOSR::~CefHostDisplayClientOSR() {} + +@@ -140,3 +144,16 @@ void CefHostDisplayClientOSR::CreateLayeredWindowUpdater( + void CefHostDisplayClientOSR::DidCompleteSwapWithNewSize( + const gfx::Size& size) {} + #endif ++ ++#if BUILDFLAG(IS_OHOS) ++void CefHostDisplayClientOSR::DidCompleteSwapWithNewSizeOHOS( ++ const gfx::Size& size) { ++ TRACE_EVENT1("cef", "CefHostDisplayClientOSR::DidCompleteSwapWithNewSize", ++ "size", size.ToString()); ++ if (browser_impl_ && browser_impl_->GetClient()) { ++ auto render_handler = browser_impl_->GetClient()->GetRenderHandler(); ++ if (render_handler) ++ render_handler->OnCompleteSwapWithNewSize(); ++ } ++} ++#endif +diff --git a/src/cef/libcef/browser/osr/host_display_client_osr.h b/src/cef/libcef/browser/osr/host_display_client_osr.h +index 284ccb32d55..da9e1e80f96 +--- a/src/cef/libcef/browser/osr/host_display_client_osr.h ++++ b/src/cef/libcef/browser/osr/host_display_client_osr.h +@@ -10,6 +10,7 @@ + #include "base/callback.h" + #include "base/memory/shared_memory_mapping.h" + #include "components/viz/host/host_display_client.h" ++#include "libcef/browser/alloy/alloy_browser_host_impl.h" + #include "ui/gfx/native_widget_types.h" + + class CefLayeredWindowUpdaterOSR; +@@ -41,6 +42,11 @@ class CefHostDisplayClientOSR : public viz::HostDisplayClient { + void DidCompleteSwapWithNewSize(const gfx::Size& size) override; + #endif + ++#if BUILDFLAG(IS_OHOS) ++ void DidCompleteSwapWithNewSizeOHOS(const gfx::Size& size) override; ++ CefRefPtr browser_impl_; ++#endif ++ + CefRenderWidgetHostViewOSR* const view_; + std::unique_ptr layered_window_updater_; + bool active_ = false; +diff --git a/src/cef/libcef/browser/osr/motion_event_osr.h b/src/cef/libcef/browser/osr/motion_event_osr.h +index ffc2402b067..eb39e9c8d8b +--- a/src/cef/libcef/browser/osr/motion_event_osr.h ++++ b/src/cef/libcef/browser/osr/motion_event_osr.h +@@ -39,11 +39,18 @@ class CefMotionEventOSR : public ui::MotionEventGeneric { + // touchcancel to make sure only send one ack per WebTouchEvent. + void MarkUnchangedTouchPointsAsStationary(blink::WebTouchEvent* event, + const CefTouchEvent& cef_event); +- ++#if BUILDFLAG(IS_OHOS) ++ bool FromOverlay() const override { return from_overlay_; }; ++ void SetFromOverlay(bool from_overlay) override { from_overlay_ = from_overlay; }; ++#endif ++ + private: + // Chromium can't cope with touch ids >31, so let's map the incoming + // ids to a safe range. + int id_map_[blink::WebTouchEvent::kTouchesLengthCap]; ++#if BUILDFLAG(IS_OHOS) ++ bool from_overlay_ = false; ++#endif + + int LookupId(int id); + int AddId(int id); +diff --git a/src/cef/libcef/browser/osr/render_widget_host_view_osr.cc b/src/cef/libcef/browser/osr/render_widget_host_view_osr.cc +index b5e9a81f243..03d7777aec6 +--- a/src/cef/libcef/browser/osr/render_widget_host_view_osr.cc ++++ b/src/cef/libcef/browser/osr/render_widget_host_view_osr.cc +@@ -256,10 +256,13 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR( + // Matching the attributes from BrowserCompositorMac. + delegated_frame_host_ = std::make_unique( + AllocateFrameSinkId(), delegated_frame_host_client_.get(), ++#if BUILDFLAG(IS_OHOS) ++ true /* should_register_frame_sink_id */); ++#else + false /* should_register_frame_sink_id */); ++#endif + + root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); +- + bool opaque = SkColorGetA(background_color_) == SK_AlphaOPAQUE; + GetRootLayer()->SetFillsBoundsOpaquely(opaque); + GetRootLayer()->SetColor(background_color_); +@@ -464,7 +467,6 @@ void CefRenderWidgetHostViewOSR::ShowWithVisibility( + browser_impl_->GetAcceleratedWidget()); + compositor->SetDelegate(this); + compositor->SetRootLayer(root_layer_.get()); +- compositor->AddChildFrameSink(GetFrameSinkId()); + + content::RenderWidgetHostImpl* render_widget_host_impl = + content::RenderWidgetHostImpl::From(render_widget_host_); +@@ -577,7 +579,23 @@ absl::optional CefRenderWidgetHostViewOSR::GetBackgroundColor() { + return background_color_; + } + +-void CefRenderWidgetHostViewOSR::UpdateBackgroundColor() {} ++void CefRenderWidgetHostViewOSR::UpdateBackgroundColor() { ++#if BUILDFLAG(IS_OHOS) ++ if (SkColorGetA(background_color_) != SK_AlphaOPAQUE) { ++#ifdef DISABLE_GPU ++ if (compositor_) { ++ compositor_->SetBackgroundColor(background_color_); ++ } ++#else ++ auto compositor = CefRenderWidgetHostViewOSR::GetCompositor( ++ browser_impl_->GetAcceleratedWidget()); ++ if (compositor) { ++ compositor->SetBackgroundColor(background_color_); ++ } ++#endif ++ } ++#endif ++} + + absl::optional + CefRenderWidgetHostViewOSR::GetDisplayFeature() { +@@ -649,10 +667,6 @@ void CefRenderWidgetHostViewOSR::OnDidUpdateVisualPropertiesComplete( + } else { + SynchronizeVisualProperties(cc::DeadlinePolicy::UseDefaultDeadline(), + metadata.local_surface_id); +-#if BUILDFLAG(IS_OHOS) +- // Fix egl resize pending problem. +- ReleaseResizeHold(); +-#endif + } + } + +@@ -867,10 +881,10 @@ display::ScreenInfos CefRenderWidgetHostViewOSR::GetNewScreenInfosForUpdate() { + screen_info.available_rect.height == 0) { + screen_info.available_rect = screenRect; + } +- LOG(INFO) << "CefRenderWidgetHostViewOSR::GetScreenInfo orientation:" +- << screen_info.orientation; +- LOG(INFO) << "CefRenderWidgetHostViewOSR::GetScreenInfo angel:" +- << screen_info.angle; ++ LOG(DEBUG) << "CefRenderWidgetHostViewOSR::GetScreenInfo orientation:" ++ << screen_info.orientation; ++ LOG(DEBUG) << "CefRenderWidgetHostViewOSR::GetScreenInfo angel:" ++ << screen_info.angle; + } + + display_screen_info = ScreenInfoFrom(screen_info); +@@ -1000,6 +1014,60 @@ void CefRenderWidgetHostViewOSR::SelectionChanged(const std::u16string& text, + CefRange cef_range(range.start(), range.end()); + handler->OnTextSelectionChanged(browser_impl_.get(), selected_text, + cef_range); ++ handler->OnSelectionChanged(browser_impl_.get(), text, cef_range); ++} ++ ++void CefRenderWidgetHostViewOSR::SelectionBoundsChanged( ++ const gfx::Rect& anchor_rect, ++ base::i18n::TextDirection anchor_dir, ++ const gfx::Rect& focus_rect, ++ base::i18n::TextDirection focus_dir, ++ const gfx::Rect& bounding_box, ++ bool is_anchor_first) { ++ if (!browser_impl_) { ++ LOG(ERROR) << "browser_impl_ is nullptr"; ++ return; ++ } ++ ++ focus_rect_x_ = focus_rect.x(); ++ focus_rect_y_ = focus_rect.y(); ++ focus_rect_width_ = focus_rect.width(); ++ focus_rect_height_ = focus_rect.height(); ++ ++ CefRefPtr handler = ++ browser_impl_->GetClient()->GetRenderHandler(); ++ CHECK(handler); ++ ++ int x = focus_rect.x(); ++ int y = focus_rect.y(); ++ ++ if (text_input_manager_ && text_input_manager_->GetTextInputState()) { ++ auto state = text_input_manager_->GetTextInputState(); ++ CHECK(state); ++ CHECK(state->edit_context_control_bounds); ++ int edit_bounds_x = state->edit_context_control_bounds->x(); ++ int edit_bounds_y = state->edit_context_control_bounds->y(); ++ int edit_bounds_width = state->edit_context_control_bounds->width(); ++ int edit_bounds_height = state->edit_context_control_bounds->height(); ++ x = x < edit_bounds_x ? edit_bounds_x : x; ++ x = x > (edit_bounds_x + edit_bounds_width) ++ ? (edit_bounds_x + edit_bounds_width) ++ : x; ++ y = y < edit_bounds_y ? edit_bounds_y : y; ++ y = y > (edit_bounds_y + edit_bounds_height) ++ ? (edit_bounds_y + edit_bounds_height) ++ : y; ++ } ++ ++ if (focus_rect_x_ != x && focus_rect_y_ != y) { ++ handler->OnCursorUpdate( ++ browser_impl_->GetBrowser(), ++ CefRect(focus_rect_x_, focus_rect_y_, focus_rect_width_, focus_rect_height_)); ++ } else { ++ handler->OnCursorUpdate( ++ browser_impl_->GetBrowser(), ++ CefRect(x, y, focus_rect_width_, focus_rect_height_)); ++ } + } + + const viz::LocalSurfaceId& CefRenderWidgetHostViewOSR::GetLocalSurfaceId() +@@ -1075,10 +1143,6 @@ void CefRenderWidgetHostViewOSR::DidNavigate() { + // can use the ID that was already provided. + SynchronizeVisualProperties(cc::DeadlinePolicy::UseExistingDeadline(), + GetLocalSurfaceId()); +-#if BUILDFLAG(IS_OHOS) +- // Fix egl resize pending problem. +- ReleaseResizeHold(); +-#endif + } else { + SynchronizeVisualProperties(cc::DeadlinePolicy::UseExistingDeadline(), + absl::nullopt); +@@ -1141,6 +1205,18 @@ void CefRenderWidgetHostViewOSR::OnRenderFrameMetadataChangedAfterActivation( + weak_ptr_factory_.GetWeakPtr())); + #endif + } ++ ++ gfx::Size viewport_size_in_pixels = metadata.viewport_size_in_pixels; ++ if (viewport_size_in_pixels != viewport_size_in_pixels_) { ++ TRACE_EVENT1("cef", ++ "CefRenderWidgetHostViewOSR::" ++ "OnRenderFrameMetadataChangedAfterActivation", ++ "viewport_size_in_pixels", viewport_size_in_pixels.ToString()); ++ viewport_size_in_pixels_ = viewport_size_in_pixels; ++ CEF_POST_TASK(CEF_UIT, ++ base::BindOnce(&CefRenderWidgetHostViewOSR::ReleaseResizeHold, ++ weak_ptr_factory_.GetWeakPtr())); ++ } + #endif + if (!page_scale_factor_) { + // set init page scale factor. +@@ -1188,7 +1264,11 @@ CefRenderWidgetHostViewOSR::CreateHostDisplayClient() { + } + + bool CefRenderWidgetHostViewOSR::InstallTransparency() { ++#if BUILDFLAG(IS_OHOS) ++ if (SkColorGetA(background_color_) != SK_AlphaOPAQUE) { ++#else + if (background_color_ == SK_ColorTRANSPARENT) { ++#endif + SetBackgroundColor(background_color_); + #ifdef DISABLE_GPU + if (compositor_) { +@@ -1216,10 +1296,13 @@ void CefRenderWidgetHostViewOSR::WasResized() { + + SynchronizeVisualProperties(cc::DeadlinePolicy::UseExistingDeadline(), + absl::nullopt); +-#if BUILDFLAG(IS_OHOS) +- // Fix egl resize pending problem. +- ReleaseResizeHold(); +-#endif ++} ++ ++void CefRenderWidgetHostViewOSR::SetShouldFrameSubmissionBeforeDraw( ++ bool should) { ++ TRACE_EVENT0( ++ "base", "CefRenderWidgetHostViewOSR::SetShouldFrameSubmissionBeforeDraw"); ++ should_wait_ = should; + } + + void CefRenderWidgetHostViewOSR::SynchronizeVisualProperties( +@@ -1228,6 +1311,12 @@ void CefRenderWidgetHostViewOSR::SynchronizeVisualProperties( + SetFrameRate(); + + const bool resized = ResizeRootLayer(); ++ if (resized && should_wait_) { ++ if (auto compositor = CefRenderWidgetHostViewOSR::GetCompositor( ++ browser_impl_->GetAcceleratedWidget())) { ++ compositor->SetShouldFrameSubmissionBeforeDraw(true); ++ } ++ } + bool surface_id_updated = false; + + if (!resized && child_local_surface_id) { +@@ -1530,6 +1619,7 @@ void CefRenderWidgetHostViewOSR::SendTouchEvent(const CefTouchEvent& event) { + } + + // Update the touch event first. ++ pointer_state_.SetFromOverlay(event.from_overlay); + if (!pointer_state_.OnTouch(event)) { + return; + } +@@ -1620,6 +1710,29 @@ void CefRenderWidgetHostViewOSR::OnUpdateTextInputStateCalled( + content::RenderWidgetHostViewBase* updated_view, + bool did_update_state) { + const auto state = text_input_manager->GetTextInputState(); ++#if BUILDFLAG(IS_OHOS) ++ if (!state || !state->show_ime_if_needed) { ++ return; ++ } ++ ++ CefRefPtr handler = ++ browser_impl_->GetClient()->GetRenderHandler(); ++ CHECK(handler); ++ ++ if (state->type != ui::TEXT_INPUT_TYPE_NONE && ++ state->mode != ui::TEXT_INPUT_MODE_NONE) { ++ if (state->type == ui::TEXT_INPUT_TYPE_NUMBER) { ++ handler->OnVirtualKeyboardRequested(browser_impl_->GetBrowser(), ++ CEF_TEXT_INPUT_MODE_NUMERIC, true); ++ } else { ++ handler->OnVirtualKeyboardRequested( ++ browser_impl_->GetBrowser(), ++ static_cast( ++ ui::TEXT_INPUT_MODE_DEFAULT), ++ true); ++ } ++ } ++#else + if (state && !state->show_ime_if_needed) { + return; + } +@@ -1641,20 +1754,30 @@ void CefRenderWidgetHostViewOSR::OnUpdateTextInputStateCalled( + + handler->OnVirtualKeyboardRequested(browser_impl_->GetBrowser(), mode, + show_keyboard); ++#endif + } + +-void CefRenderWidgetHostViewOSR::FocusedNodeChanged(bool is_editable_node, +- const gfx::Rect& node_bounds_in_screen) +-{ ++void CefRenderWidgetHostViewOSR::FocusedNodeChanged( ++ bool is_editable_node, ++ const gfx::Rect& node_bounds_in_screen) { + CefRefPtr handler = +- browser_impl_->GetClient()->GetRenderHandler(); ++ browser_impl_->GetClient()->GetRenderHandler(); + CHECK(handler); ++ ++ if (text_input_manager_ && text_input_manager_->GetTextInputState()) { ++ auto state = text_input_manager_->GetTextInputState(); ++ CHECK(state); ++ handler->OnCursorUpdate(browser_impl_->GetBrowser(), ++ CefRect(state->edit_context_control_bounds->x(), ++ state->edit_context_control_bounds->y(), ++ focus_rect_width_, focus_rect_height_)); ++ } + if (is_editable_node) { + handler->OnVirtualKeyboardRequested(browser_impl_->GetBrowser(), +- CEF_TEXT_INPUT_MODE_DEFAULT, false); ++ CEF_TEXT_INPUT_MODE_DEFAULT, false); + } else { + handler->OnVirtualKeyboardRequested(browser_impl_->GetBrowser(), +- CEF_TEXT_INPUT_MODE_NONE, false); ++ CEF_TEXT_INPUT_MODE_NONE, false); + } + } + +@@ -1744,6 +1867,11 @@ void CefRenderWidgetHostViewOSR::OnPaint(const gfx::Rect& damage_rect, + return; + } + ++ if (!browser_impl_ || !browser_impl_->client()) { ++ LOG(ERROR) << "get client failed."; ++ return; ++ } ++ + CefRefPtr handler = + browser_impl_->client()->GetRenderHandler(); + CHECK(handler); +@@ -1906,7 +2034,13 @@ bool CefRenderWidgetHostViewOSR::SetRootLayerSize(bool force) { + compositor_local_surface_id_allocator_.GetCurrentLocalSurfaceId()); + } + ++#if BUILDFLAG(IS_OHOS) ++ // We only need to notify the screen information change, the visual window ++ // adjustment is done by CefRenderWidgetHostViewOSR::WasResized. ++ return view_bounds_changed; ++#else + return (screen_info_changed || view_bounds_changed); ++#endif + } + + bool CefRenderWidgetHostViewOSR::ResizeRootLayer() { +@@ -1984,13 +2118,15 @@ void CefRenderWidgetHostViewOSR::OnScrollOffsetChanged() { + CefRefPtr handler = + browser_impl_->client()->GetRenderHandler(); + CHECK(handler); +- #if BUILDFLAG(IS_OHOS) +- handler->OnScrollOffsetChanged(browser_impl_.get(), std::round(last_scroll_offset_.x()), +- std::round(last_scroll_offset_.y())); +- #else ++#if BUILDFLAG(IS_OHOS) ++ float x = last_scroll_offset_.x(); ++ float y = last_scroll_offset_.y(); ++ handler->OnScrollOffsetChanged(browser_impl_.get(), std::round(x), ++ std::round(y)); ++#else + handler->OnScrollOffsetChanged(browser_impl_.get(), last_scroll_offset_.x(), + last_scroll_offset_.y()); +- #endif ++#endif + } + is_scroll_offset_changed_pending_ = false; + } +@@ -2005,6 +2141,11 @@ void CefRenderWidgetHostViewOSR::OnRootLayerChanged() { + root_layer_size_.width()); + } + } ++ ++void CefRenderWidgetHostViewOSR::GestureEventAck( ++ const blink::WebGestureEvent& event, blink::mojom::InputEventResultState ack_result) { ++ StopFlingingIfNecessary(event, ack_result); ++} + #endif + + void CefRenderWidgetHostViewOSR::AddGuestHostView( +diff --git a/src/cef/libcef/browser/osr/render_widget_host_view_osr.h b/src/cef/libcef/browser/osr/render_widget_host_view_osr.h +index 96cc2faf567..dc9f1d2e4af +--- a/src/cef/libcef/browser/osr/render_widget_host_view_osr.h ++++ b/src/cef/libcef/browser/osr/render_widget_host_view_osr.h +@@ -180,6 +180,8 @@ class CefRenderWidgetHostViewOSR + const cc::RenderFrameMetadata& metadata) override; + #endif + ++ void SetShouldFrameSubmissionBeforeDraw(bool should); ++ + viz::SurfaceId GetCurrentSurfaceId() const override; + void ImeCompositionRangeChanged( + const gfx::Range& range, +@@ -194,6 +196,12 @@ class CefRenderWidgetHostViewOSR + void SelectionChanged(const std::u16string& text, + size_t offset, + const gfx::Range& range) override; ++ void SelectionBoundsChanged(const gfx::Rect& anchor_rect, ++ base::i18n::TextDirection anchor_dir, ++ const gfx::Rect& focus_rect, ++ base::i18n::TextDirection focus_dir, ++ const gfx::Rect& bounding_box, ++ bool is_anchor_first) override; + const viz::LocalSurfaceId& GetLocalSurfaceId() const override; + const viz::FrameSinkId& GetFrameSinkId() const override; + viz::FrameSinkId GetRootFrameSinkId() override; +@@ -346,6 +354,8 @@ class CefRenderWidgetHostViewOSR + + #if BUILDFLAG(IS_OHOS) + void OnRootLayerChanged(); ++ void GestureEventAck(const blink::WebGestureEvent& event, ++ blink::mojom::InputEventResultState ack_result) override; + #endif + + void AddGuestHostView(CefRenderWidgetHostViewOSR* guest_host); +@@ -443,6 +453,12 @@ class CefRenderWidgetHostViewOSR + std::set guest_host_views_; + #if BUILDFLAG(IS_OHOS) + gfx::SizeF root_layer_size_; ++ double focus_rect_x_ = 0; ++ double focus_rect_y_ = 0; ++ double focus_rect_width_ = 0; ++ double focus_rect_height_ = 0; ++ bool should_wait_ = false; ++ gfx::Size viewport_size_in_pixels_; + #endif + + CefRefPtr browser_impl_; +diff --git a/src/cef/libcef/browser/osr/touch_selection_controller_client_osr.cc b/src/cef/libcef/browser/osr/touch_selection_controller_client_osr.cc +index f2751a7a4c0..08e22fa9b31 +--- a/src/cef/libcef/browser/osr/touch_selection_controller_client_osr.cc ++++ b/src/cef/libcef/browser/osr/touch_selection_controller_client_osr.cc +@@ -23,6 +23,12 @@ + #include "ui/gfx/geometry/size_conversions.h" + #include "base/logging.h" + ++#if defined(OHOS_NWEB_EX) ++#include "base/base_switches.h" ++#include "base/command_line.h" ++#include "content/public/common/content_switches.h" ++#endif ++ + namespace { + + // Delay before showing the quick menu, in milliseconds. +@@ -173,6 +179,16 @@ void CefTouchSelectionControllerClientOSR::OnScrollCompleted() { + + bool CefTouchSelectionControllerClientOSR::HandleContextMenu( + const content::ContextMenuParams& params) { ++#if defined(OHOS_NWEB_EX) ++ bool is_browser = ++ base::CommandLine::ForCurrentProcess() && ++ base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kForBrowser); ++ if (is_browser && params.selection_text.empty() && !params.is_editable) { ++ quick_menu_requested_ = false; ++ return false; ++ } ++#endif ++ + if ((params.source_type == ui::MENU_SOURCE_LONG_PRESS || + params.source_type == ui::MENU_SOURCE_TOUCH_EDIT_MENU || + params.source_type == ui::MENU_SOURCE_LONG_TAP) && +@@ -183,12 +199,23 @@ bool CefTouchSelectionControllerClientOSR::HandleContextMenu( + return true; + } + +- const bool from_touch = +- params.source_type == ui::MENU_SOURCE_LONG_PRESS || +- params.source_type == ui::MENU_SOURCE_LONG_TAP || +- params.source_type == ui::MENU_SOURCE_TOUCH_EDIT_MENU || +- params.source_type == ui::MENU_SOURCE_TOUCH; ++ bool from_touch = params.source_type == ui::MENU_SOURCE_LONG_PRESS || ++ params.source_type == ui::MENU_SOURCE_LONG_TAP || ++ params.source_type == ui::MENU_SOURCE_TOUCH_EDIT_MENU || ++ params.source_type == ui::MENU_SOURCE_TOUCH; ++#if defined(OHOS_NWEB_EX) ++ if (is_browser) { ++ from_touch = ++ from_touch || params.source_type == ui::MENU_SOURCE_SELECT_AND_COPY; ++ } ++#endif ++ + if (from_touch && (quick_menu_requested_ || !params.selection_text.empty())) { ++#if defined(OHOS_NWEB_EX) ++ if (is_browser) { ++ SelectionTextNotEmpty(!params.selection_text.empty()); ++ } ++#endif + quick_menu_requested_ = true; + ShowQuickMenu(); + return true; +@@ -420,6 +447,7 @@ void CefTouchSelectionControllerClientOSR::OnSelectionEvent( + ui::SelectionEventType event) { + // This function (implicitly) uses active_menu_client_, so we don't go to the + // active view for this. ++ SetTemporarilyHidden(false); + auto browser = rwhv_->browser_impl(); + switch (event) { + case ui::SELECTION_HANDLES_SHOWN: +@@ -507,6 +535,12 @@ bool CefTouchSelectionControllerClientOSR::IsCommandIdEnabled( + bool editable = rwhv_->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE; + bool readable = rwhv_->GetTextInputType() != ui::TEXT_INPUT_TYPE_PASSWORD; + bool has_selection = !rwhv_->GetSelectedText().empty(); ++#if defined(OHOS_NWEB_EX) ++ if (base::CommandLine::ForCurrentProcess()->HasSwitch( ++ switches::kForBrowser)) { ++ has_selection = has_selection || isSelectionTextNotEmpty_; ++ } ++#endif + switch (command_id) { + case QM_EDITFLAG_CAN_ELLIPSIS: + return true; // Always allowed to show the ellipsis button. +@@ -526,6 +560,9 @@ bool CefTouchSelectionControllerClientOSR::IsCommandIdEnabled( + can_paste = ui::Clipboard::GetForCurrentThread()->IsFormatAvailable( + ui::ClipboardFormatType::BitmapType(), + ui::ClipboardBuffer::kCopyPaste, &data_dst); ++ can_paste |= ui::Clipboard::GetForCurrentThread()->IsFormatAvailable( ++ ui::ClipboardFormatType::HtmlType(), ++ ui::ClipboardBuffer::kCopyPaste, &data_dst); + } + can_paste = can_paste ? can_paste : !result.empty(); + return editable && can_paste; +@@ -631,4 +668,11 @@ bool CefTouchSelectionControllerClientOSR:: + return true; + } + return false; +-} +\ No newline at end of file ++} ++ ++#if defined(OHOS_NWEB_EX) ++void CefTouchSelectionControllerClientOSR::SelectionTextNotEmpty( ++ bool selectionTextNotEmpty) { ++ isSelectionTextNotEmpty_ = selectionTextNotEmpty; ++} ++#endif +\ No newline at end of file +diff --git a/src/cef/libcef/browser/osr/touch_selection_controller_client_osr.h b/src/cef/libcef/browser/osr/touch_selection_controller_client_osr.h +index b7de80ae61a..5a4a6f96378 +--- a/src/cef/libcef/browser/osr/touch_selection_controller_client_osr.h ++++ b/src/cef/libcef/browser/osr/touch_selection_controller_client_osr.h +@@ -111,7 +111,9 @@ class CefTouchSelectionControllerClientOSR + void RunContextMenu() override; + bool ShouldShowQuickMenu() override; + std::u16string GetSelectedText() override; +- ++#if defined(OHOS_NWEB_EX) ++ void SelectionTextNotEmpty(bool has_selection); ++#endif + void NotifyTouchSelectionChanged(bool need_report); + void RunQuickMenu(); + // Not owned, non-null for the lifetime of this object. +@@ -153,6 +155,9 @@ class CefTouchSelectionControllerClientOSR + bool touch_down_ = false; + bool scroll_in_progress_ = false; + bool handle_drag_in_progress_ = false; ++#if defined(OHOS_NWEB_EX) ++ bool isSelectionTextNotEmpty_ = false; ++#endif + + base::WeakPtrFactory weak_ptr_factory_; + }; +diff --git a/src/cef/libcef/browser/page_load_metrics/alloy_page_load_metrics_memory_tracker_factory.cc b/src/cef/libcef/browser/page_load_metrics/alloy_page_load_metrics_memory_tracker_factory.cc +new file mode 100644 +index 00000000000..9a0db5c4144 +--- /dev/null ++++ b/src/cef/libcef/browser/page_load_metrics/alloy_page_load_metrics_memory_tracker_factory.cc +@@ -0,0 +1,43 @@ ++// Copyright 2021 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "libcef/browser/page_load_metrics/alloy_page_load_metrics_memory_tracker_factory.h" ++ ++#include "base/memory/singleton.h" ++#include "components/keyed_service/content/browser_context_dependency_manager.h" ++#include "components/keyed_service/content/browser_context_keyed_service_factory.h" ++#include "components/page_load_metrics/browser/page_load_metrics_memory_tracker.h" ++ ++namespace cef { ++ ++page_load_metrics::PageLoadMetricsMemoryTracker* ++AlloyPageLoadMetricsMemoryTrackerFactory::GetForBrowserContext( ++ content::BrowserContext* context) { ++ return static_cast( ++ GetInstance()->GetServiceForBrowserContext(context, true)); ++} ++ ++AlloyPageLoadMetricsMemoryTrackerFactory* ++AlloyPageLoadMetricsMemoryTrackerFactory::GetInstance() { ++ return base::Singleton::get(); ++} ++ ++AlloyPageLoadMetricsMemoryTrackerFactory:: ++ AlloyPageLoadMetricsMemoryTrackerFactory() ++ : BrowserContextKeyedServiceFactory( ++ "PageLoadMetricsMemoryTracker", ++ BrowserContextDependencyManager::GetInstance()) {} ++ ++KeyedService* AlloyPageLoadMetricsMemoryTrackerFactory::BuildServiceInstanceFor( ++ content::BrowserContext* context) const { ++ return new page_load_metrics::PageLoadMetricsMemoryTracker(); ++} ++ ++content::BrowserContext* ++AlloyPageLoadMetricsMemoryTrackerFactory::GetBrowserContextToUse( ++ content::BrowserContext* context) const { ++ return context; ++} ++ ++} // namespace cef +diff --git a/src/cef/libcef/browser/page_load_metrics/alloy_page_load_metrics_memory_tracker_factory.h b/src/cef/libcef/browser/page_load_metrics/alloy_page_load_metrics_memory_tracker_factory.h +new file mode 100644 +index 00000000000..cce36ceeab7 +--- /dev/null ++++ b/src/cef/libcef/browser/page_load_metrics/alloy_page_load_metrics_memory_tracker_factory.h +@@ -0,0 +1,36 @@ ++// Copyright 2021 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef CEF_LIBCEF_BROWSER_PAGE_LOAD_METRICS_ALLOY_PAGE_LOAD_METRICS_MEMORY_TRACKER_FACTORY_H_ ++#define CEF_LIBCEF_BROWSER_PAGE_LOAD_METRICS_ALLOY_PAGE_LOAD_METRICS_MEMORY_TRACKER_FACTORY_H_ ++ ++#include "components/keyed_service/content/browser_context_keyed_service_factory.h" ++ ++namespace page_load_metrics { ++class PageLoadMetricsMemoryTracker; ++} // namespace page_load_metrics ++ ++namespace cef { ++ ++class AlloyPageLoadMetricsMemoryTrackerFactory ++ : public BrowserContextKeyedServiceFactory { ++ public: ++ static page_load_metrics::PageLoadMetricsMemoryTracker* GetForBrowserContext( ++ content::BrowserContext* context); ++ ++ static AlloyPageLoadMetricsMemoryTrackerFactory* GetInstance(); ++ ++ AlloyPageLoadMetricsMemoryTrackerFactory(); ++ ++ private: ++ KeyedService* BuildServiceInstanceFor( ++ content::BrowserContext* context) const override; ++ ++ content::BrowserContext* GetBrowserContextToUse( ++ content::BrowserContext* context) const override; ++}; ++ ++} // namespace cef ++ ++#endif // CEF_LIBCEF_BROWSER_PAGE_LOAD_METRICS_ALLOY_PAGE_LOAD_METRICS_MEMORY_TRACKER_FACTORY_H_ +diff --git a/src/cef/libcef/browser/page_load_metrics/oh_page_load_metrics_observer.cc b/src/cef/libcef/browser/page_load_metrics/oh_page_load_metrics_observer.cc +new file mode 100644 +index 00000000000..fcd015e6aaa +--- /dev/null ++++ b/src/cef/libcef/browser/page_load_metrics/oh_page_load_metrics_observer.cc +@@ -0,0 +1,83 @@ ++// Copyright (c) 2014 The Chromium Embedded Framework Authors. ++// Portions copyright (c) 2012 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "libcef/browser/page_load_metrics/oh_page_load_metrics_observer.h" ++ ++#include ++ ++#include "base/time/time.h" ++#include "chrome/browser/browser_process.h" ++ ++#include "components/page_load_metrics/browser/observers/core/largest_contentful_paint_handler.h" ++#include "components/page_load_metrics/browser/page_load_metrics_util.h" ++#include "content/public/browser/browser_thread.h" ++#include "content/public/browser/navigation_handle.h" ++#include "content/public/browser/web_contents.h" ++#include "content/public/renderer/render_frame.h" ++#include "libcef/browser/alloy/alloy_browser_host_impl.h" ++#include "libcef/common/app_manager.h" ++#include "libcef/renderer/browser_impl.h" ++#include "services/network/public/cpp/network_quality_tracker.h" ++#include "url/gurl.h" ++ ++OhPageLoadMetricsObserver::OhPageLoadMetricsObserver() { ++ network_quality_tracker_ = g_browser_process->network_quality_tracker(); ++ DCHECK(network_quality_tracker_); ++} ++ ++OhPageLoadMetricsObserver::ObservePolicy OhPageLoadMetricsObserver::OnStart( ++ content::NavigationHandle* navigation_handle, ++ const GURL& currently_committed_url, ++ bool started_in_foreground) { ++ navigation_id_ = navigation_handle->GetNavigationId(); ++ ++ return CONTINUE_OBSERVING; ++} ++ ++page_load_metrics::PageLoadMetricsObserver::ObservePolicy ++OhPageLoadMetricsObserver::FlushMetricsOnAppEnterBackground( ++ const page_load_metrics::mojom::PageLoadTiming& timing) { ++ // We continue observing after being backgrounded, in case we are foregrounded ++ // again without being killed. In those cases we may still report non-buffered ++ // metrics such as FCP after being re-foregrounded. ++ return CONTINUE_OBSERVING; ++} ++ ++OhPageLoadMetricsObserver::ObservePolicy OhPageLoadMetricsObserver::OnHidden( ++ const page_load_metrics::mojom::PageLoadTiming& timing) { ++ return CONTINUE_OBSERVING; ++} ++ ++void OhPageLoadMetricsObserver::OnComplete( ++ const page_load_metrics::mojom::PageLoadTiming& timing) {} ++ ++void OhPageLoadMetricsObserver::OnFirstContentfulPaintInPage( ++ const page_load_metrics::mojom::PageLoadTiming& timing) { ++ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); ++ int64_t first_contentful_paint_ms = ++ timing.paint_timing->first_contentful_paint->InMilliseconds(); ++ ReportFirstContentfulPaint( ++ (GetDelegate().GetNavigationStart() - base::TimeTicks()).InMicroseconds(), ++ first_contentful_paint_ms); ++} ++ ++void OhPageLoadMetricsObserver::ReportFirstContentfulPaint( ++ int64_t navigation_start_tick, ++ int64_t first_contentful_paint_ms) { ++ CefRefPtr browser = ++ AlloyBrowserHostImpl::GetBrowserForContents( ++ GetDelegate().GetWebContents()); ++ if (!browser.get()) ++ return; ++ CefRefPtr client = browser->GetClient(); ++ if (!client.get()) ++ return; ++ CefRefPtr load_handler = client->GetLoadHandler(); ++ if (!load_handler.get()) ++ return; ++ load_handler->OnFirstContentfulPaint( ++ static_cast(navigation_start_tick), ++ static_cast(first_contentful_paint_ms)); ++} +diff --git a/src/cef/libcef/browser/page_load_metrics/oh_page_load_metrics_observer.h b/src/cef/libcef/browser/page_load_metrics/oh_page_load_metrics_observer.h +new file mode 100644 +index 00000000000..97029e27928 +--- /dev/null ++++ b/src/cef/libcef/browser/page_load_metrics/oh_page_load_metrics_observer.h +@@ -0,0 +1,58 @@ ++/// Copyright (c) 2012 The Chromium Embedded Framework Authors. ++// Portions copyright (c) 2011 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef CEF_LIBCEF_BROWSER_PAGE_LOAD_METRICS_OH_PAGE_LOAD_METRICS_OBSERVER_H_ ++#define CEF_LIBCEF_BROWSER_PAGE_LOAD_METRICS_OH_PAGE_LOAD_METRICS_OBSERVER_H_ ++ ++#include "base/memory/raw_ptr.h" ++#include "components/page_load_metrics/browser/page_load_metrics_observer.h" ++#include "net/nqe/effective_connection_type.h" ++ ++namespace network { ++class NetworkQualityTracker; ++} ++ ++class GURL; ++ ++class OhPageLoadMetricsObserver ++ : public page_load_metrics::PageLoadMetricsObserver { ++ public: ++ OhPageLoadMetricsObserver(); ++ ++ OhPageLoadMetricsObserver(const OhPageLoadMetricsObserver&) = delete; ++ OhPageLoadMetricsObserver& operator=(const OhPageLoadMetricsObserver&) = ++ delete; ++ ++ // page_load_metrics::PageLoadMetricsObserver: ++ // PageLoadMetricsObserver lifecycle callbacks ++ ObservePolicy OnStart(content::NavigationHandle* navigation_handle, ++ const GURL& currently_committed_url, ++ bool started_in_foreground) override; ++ ObservePolicy FlushMetricsOnAppEnterBackground( ++ const page_load_metrics::mojom::PageLoadTiming& timing) override; ++ ObservePolicy OnHidden( ++ const page_load_metrics::mojom::PageLoadTiming& timing) override; ++ void OnComplete( ++ const page_load_metrics::mojom::PageLoadTiming& timing) override; ++ ++ // PageLoadMetricsObserver event callbacks ++ void OnFirstContentfulPaintInPage( ++ const page_load_metrics::mojom::PageLoadTiming& timing) override; ++ ++ protected: ++ OhPageLoadMetricsObserver( ++ network::NetworkQualityTracker* network_quality_tracker) ++ : network_quality_tracker_(network_quality_tracker) {} ++ ++ virtual void ReportFirstContentfulPaint(int64_t navigation_start_tick, ++ int64_t first_contentful_paint_ms); ++ ++ private: ++ int64_t navigation_id_ = -1; ++ ++ raw_ptr network_quality_tracker_ = nullptr; ++}; ++ ++#endif // CEF_LIBCEF_BROWSER_PAGE_LOAD_METRICS_OH_PAGE_LOAD_METRICS_OBSERVER_H_ +diff --git a/src/cef/libcef/browser/page_load_metrics/page_load_metrics_initialize.cc b/src/cef/libcef/browser/page_load_metrics/page_load_metrics_initialize.cc +new file mode 100644 +index 00000000000..3c3aa2584d0 +--- /dev/null ++++ b/src/cef/libcef/browser/page_load_metrics/page_load_metrics_initialize.cc +@@ -0,0 +1,97 @@ ++// Copyright (c) 2014 The Chromium Embedded Framework Authors. ++// Portions copyright (c) 2012 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "libcef/browser/page_load_metrics/page_load_metrics_initialize.h" ++ ++#include "components/page_load_metrics/browser/metrics_web_contents_observer.h" ++#include "components/page_load_metrics/browser/page_load_metrics_embedder_base.h" ++#include "components/page_load_metrics/browser/page_load_metrics_memory_tracker.h" ++#include "components/page_load_metrics/browser/page_load_tracker.h" ++#include "libcef/browser/page_load_metrics/alloy_page_load_metrics_memory_tracker_factory.h" ++ ++#include "libcef/browser/page_load_metrics/oh_page_load_metrics_observer.h" ++ ++namespace content { ++class BrowserContext; ++} // namespace content ++ ++namespace page_load_metrics { ++class PageLoadMetricsMemoryTracker; ++} // namespace page_load_metrics ++ ++namespace cef { ++namespace { ++ ++class PageLoadMetricsEmbedder ++ : public page_load_metrics::PageLoadMetricsEmbedderBase { ++ public: ++ explicit PageLoadMetricsEmbedder(content::WebContents* web_contents); ++ ++ PageLoadMetricsEmbedder(const PageLoadMetricsEmbedder&) = delete; ++ PageLoadMetricsEmbedder& operator=(const PageLoadMetricsEmbedder&) = delete; ++ ++ ~PageLoadMetricsEmbedder() override; ++ ++ // page_load_metrics::PageLoadMetricsEmbedderBase: ++ bool IsNewTabPageUrl(const GURL& url) override; ++ bool IsNoStatePrefetch(content::WebContents* web_contents) override; ++ bool IsExtensionUrl(const GURL& url) override; ++ page_load_metrics::PageLoadMetricsMemoryTracker* ++ GetMemoryTrackerForBrowserContext( ++ content::BrowserContext* browser_context) override; ++ ++ protected: ++ // page_load_metrics::PageLoadMetricsEmbedderBase: ++ void RegisterEmbedderObservers( ++ page_load_metrics::PageLoadTracker* tracker) override; ++}; ++ ++PageLoadMetricsEmbedder::PageLoadMetricsEmbedder( ++ content::WebContents* web_contents) ++ : PageLoadMetricsEmbedderBase(web_contents) {} ++ ++PageLoadMetricsEmbedder::~PageLoadMetricsEmbedder() = default; ++ ++void PageLoadMetricsEmbedder::RegisterEmbedderObservers( ++ page_load_metrics::PageLoadTracker* tracker) { ++ tracker->AddObserver(std::make_unique()); ++} ++ ++bool PageLoadMetricsEmbedder::IsNewTabPageUrl(const GURL& url) { ++ return false; ++} ++ ++bool PageLoadMetricsEmbedder::IsNoStatePrefetch( ++ content::WebContents* web_contents) { ++ return false; ++} ++ ++bool PageLoadMetricsEmbedder::IsExtensionUrl(const GURL& url) { ++ return false; ++} ++ ++page_load_metrics::PageLoadMetricsMemoryTracker* ++PageLoadMetricsEmbedder::GetMemoryTrackerForBrowserContext( ++ content::BrowserContext* browser_context) { ++ if (!base::FeatureList::IsEnabled(features::kV8PerFrameMemoryMonitoring)) ++ return nullptr; ++ ++ return AlloyPageLoadMetricsMemoryTrackerFactory::GetForBrowserContext( ++ browser_context); ++} ++ ++} // namespace ++ ++void InitializePageLoadMetricsForWebContents( ++ content::WebContents* web_contents) { ++ // Change this method? consider to modify the peer in ++ // chrome/browser/page_load_metrics/page_load_metrics_initialize.cc ++ // weblayer/browser/page_load_metrics_initialize.cc ++ // as well. ++ page_load_metrics::MetricsWebContentsObserver::CreateForWebContents( ++ web_contents, std::make_unique(web_contents)); ++} ++ ++} // namespace cef +diff --git a/src/cef/libcef/browser/page_load_metrics/page_load_metrics_initialize.h b/src/cef/libcef/browser/page_load_metrics/page_load_metrics_initialize.h +new file mode 100644 +index 00000000000..576f294a21f +--- /dev/null ++++ b/src/cef/libcef/browser/page_load_metrics/page_load_metrics_initialize.h +@@ -0,0 +1,19 @@ ++// Copyright (c) 2012 The Chromium Embedded Framework Authors. ++// Portions copyright (c) 2011 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef CEF_LIBCEF_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_INITIALIZE_H_ ++#define CEF_LIBCEF_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_INITIALIZE_H_ ++ ++namespace content { ++class WebContents; ++} ++ ++namespace cef { ++void InitializePageLoadMetricsForWebContents( ++ content::WebContents* web_contents); ++ ++} // namespace cef ++ ++#endif // CEF_LIBCEF_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_INITIALIZE_H_ +diff --git a/src/cef/libcef/browser/prefs/renderer_prefs.cc b/src/cef/libcef/browser/prefs/renderer_prefs.cc +index fdd2157dcdb..f09d35674e8 +--- a/src/cef/libcef/browser/prefs/renderer_prefs.cc ++++ b/src/cef/libcef/browser/prefs/renderer_prefs.cc +@@ -379,11 +379,14 @@ void SetCefPrefs(const CefBrowserSettings& cef, + #if BUILDFLAG(IS_OHOS) + SET_STATE(cef.hide_vertical_scrollbars, web.hide_vertical_scrollbars); + SET_STATE(cef.hide_horizontal_scrollbars, web.hide_horizontal_scrollbars); ++ web.contextmenu_customization_enabled = cef.contextmenu_customization_enabled; ++ web.scrollbar_color = cef.scrollbar_color; ++ web.blank_target_popup_intercept_enabled = cef.blank_target_popup_intercept_enabled; + #endif + web.viewport_meta_enabled = cef.viewport_meta_enabled; + web.autoplay_policy = + cef.user_gesture_required +- ? blink::mojom::AutoplayPolicy::kUserGestureRequired ++ ? blink::mojom::AutoplayPolicy::kDocumentUserActivationRequired + : blink::mojom::AutoplayPolicy::kNoUserGestureRequired; + /* ohos webview end */ + } +diff --git a/src/cef/libcef/browser/printing/ohos_print_manager.cc b/src/cef/libcef/browser/printing/ohos_print_manager.cc +new file mode 100755 +index 00000000000..d6d44f11f9c +--- /dev/null ++++ b/src/cef/libcef/browser/printing/ohos_print_manager.cc +@@ -0,0 +1,366 @@ ++/* ++ * Copyright (c) 2023 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 ++ * ++ * 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, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++#include "libcef/browser/printing/ohos_print_manager.h" ++ ++#include ++#include ++ ++#include "base/bind.h" ++#include "base/command_line.h" ++#include "base/files/file_util.h" ++#include "base/logging.h" ++#include "base/memory/ptr_util.h" ++#include "base/memory/ref_counted_memory.h" ++#include "base/numerics/safe_conversions.h" ++#include "base/task/post_task.h" ++#include "base/task/task_traits.h" ++#include "base/task/thread_pool.h" ++#include "chrome/common/chrome_switches.h" ++#include "components/printing/browser/print_manager_utils.h" ++#include "components/printing/common/print.mojom.h" ++#include "content/public/browser/browser_thread.h" ++#include "content/public/browser/render_frame_host.h" ++#include "ohos_adapter_helper.h" ++#include "printing/print_job_constants.h" ++#include "printing/units.h" ++#include "third_party/pdfium/public/fpdfview.h" ++#include "third_party/skia/include/core/SkBitmap.h" ++#include "third_party/skia/include/core/SkImage.h" ++#include "third_party/skia/include/core/SkImageEncoder.h" ++ ++namespace printing { ++ ++namespace { ++ ++const std::string pdf_fileName = "/print.pdf"; ++const std::string image_fileName = "/print.png"; ++ ++uint32_t SaveDataToFd(int fd, ++ uint32_t page_count, ++ scoped_refptr data) { ++ bool result = fd > base::kInvalidFd && ++ base::IsValueInRangeForNumericType(data->size()); ++ if (result) { ++ result = base::WriteFileDescriptor(fd, *data); ++ } ++ if (fd > 0) { ++ sync(); ++ close(fd); ++ } ++ ++ return result ? page_count : 0; ++} ++ ++int MilsToDots(int val, int dpi) { ++ return static_cast(printing::ConvertUnitFloat(val, 1000, dpi)); ++} ++ ++} // namespace ++ ++OhosPrintManager::OhosPrintManager(content::WebContents* contents) ++ : PrintManager(contents), ++ content::WebContentsUserData(*contents) {} ++ ++OhosPrintManager::~OhosPrintManager() = default; ++ ++int OhosPrintManager::imageFd_ = -1; ++ ++// static ++void OhosPrintManager::BindPrintManagerHost( ++ mojo::PendingAssociatedReceiver receiver, ++ content::RenderFrameHost* rfh) { ++ auto* web_contents = content::WebContents::FromRenderFrameHost(rfh); ++ if (!web_contents) { ++ LOG(ERROR) << "web_contents is nullptr."; ++ return; ++ } ++ ++ auto* print_manager = OhosPrintManager::FromWebContents(web_contents); ++ if (!print_manager) { ++ LOG(ERROR) << "print_manager is nullptr."; ++ return; ++ } ++ ++ print_manager->BindReceiver(std::move(receiver), rfh); ++} ++ ++void OhosPrintManager::PdfWritingDone(int page_count) { ++ pdf_writing_done_callback().Run(page_count); ++ fd_ = -1; ++} ++ ++bool OhosPrintManager::PrintNow() { ++ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); ++ auto* rfh = web_contents()->GetMainFrame(); ++ if (!rfh || !rfh->IsRenderFrameLive()) { ++ LOG(ERROR) << "rfh is nullptr."; ++ return false; ++ } ++ GetPrintRenderFrame(rfh)->PrintRequestedPages(); ++ return true; ++} ++ ++void OhosPrintManager::GetDefaultPrintSettings( ++ GetDefaultPrintSettingsCallback callback) { ++ // Please process in the UI thread. ++ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); ++ auto params = printing::mojom::PrintParams::New(); ++ ++ DidExportPdf(); ++ printing::PageRanges page_ranges; ++ PdfWritingDoneCallback pdf_writing_done_callback = ++ base::BindRepeating([](int page_count) { ++ LOG(INFO) << "OhosPrintManager::pdf_writing_done_callback page_count = " ++ << page_count; ++ }); ++ UpdateParam(CreatePdfSettings(page_ranges), fd_, pdf_writing_done_callback); ++ printing::RenderParamsFromPrintSettings(*settings_, params.get()); ++ params->document_cookie = cookie(); ++ std::move(callback).Run(std::move(params)); ++} ++ ++void OhosPrintManager::UpdateParam( ++ std::unique_ptr settings, ++ int file_descriptor, ++ PrintManager::PdfWritingDoneCallback callback) { ++ DCHECK(settings); ++ DCHECK(callback); ++ settings_ = std::move(settings); ++ fd_ = file_descriptor; ++ set_pdf_writing_done_callback(std::move(callback)); ++ // Set a valid dummy cookie value. ++ set_cookie(1); ++} ++ ++void OhosPrintManager::ScriptedPrint( ++ printing::mojom::ScriptedPrintParamsPtr scripted_params, ++ ScriptedPrintCallback callback) { ++ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); ++ auto params = printing::mojom::PrintPagesParams::New(); ++ params->params = printing::mojom::PrintParams::New(); ++ ++ if (scripted_params->is_scripted && ++ GetCurrentTargetFrame()->IsNestedWithinFencedFrame()) { ++ LOG(ERROR) << "Script Print is not allowed."; ++ std::move(callback).Run(std::move(params)); ++ return; ++ } ++ ++ printing::RenderParamsFromPrintSettings(*settings_, params->params.get()); ++ params->params->document_cookie = scripted_params->cookie; ++ params->pages = printing::PageRange::GetPages(settings_->ranges()); ++ std::move(callback).Run(std::move(params)); ++} ++ ++void OhosPrintManager::DidPrintDocument( ++ printing::mojom::DidPrintDocumentParamsPtr params, ++ DidPrintDocumentCallback callback) { ++ if (params->document_cookie != cookie()) { ++ std::move(callback).Run(false); ++ return; ++ } ++ ++ const printing::mojom::DidPrintContentParams& content = *params->content; ++ if (!content.metafile_data_region.IsValid()) { ++ NOTREACHED() << "invalid memory handle"; ++ web_contents()->Stop(); ++ PdfWritingDone(0); ++ std::move(callback).Run(false); ++ return; ++ } ++ ++ auto data = base::RefCountedSharedMemoryMapping::CreateFromWholeRegion( ++ content.metafile_data_region); ++ if (!data) { ++ NOTREACHED() << "couldn't map"; ++ web_contents()->Stop(); ++ PdfWritingDone(0); ++ std::move(callback).Run(false); ++ return; ++ } ++ ++ if (number_pages() > printing::kMaxPageCount) { ++ web_contents()->Stop(); ++ PdfWritingDone(0); ++ std::move(callback).Run(false); ++ return; ++ } ++ ++ DCHECK(pdf_writing_done_callback()); ++ ++ base::PostTaskAndReplyWithResult( ++ base::ThreadPool::CreateTaskRunner( ++ {base::MayBlock(), base::TaskPriority::BEST_EFFORT, ++ base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN}) ++ .get(), ++ FROM_HERE, base::BindOnce(&SaveDataToFd, fd_, number_pages(), data), ++ base::BindOnce(&OhosPrintManager::OnDidPrintDocumentWritingDone, ++ pdf_writing_done_callback(), std::move(callback))); ++} ++ ++// static ++void OhosPrintManager::OnDidPrintDocumentWritingDone( ++ const PdfWritingDoneCallback& callback, ++ DidPrintDocumentCallback did_print_document_cb, ++ uint32_t page_count) { ++ DCHECK_LE(page_count, printing::kMaxPageCount); ++ if (callback) ++ callback.Run(base::checked_cast(page_count)); ++ std::move(did_print_document_cb).Run(true); ++ std::string filePath = ++ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( ++ switches::kUserDataDir); ++ std::string pdf_file = filePath + pdf_fileName; ++ std::string image_file = filePath + image_fileName; ++ ConvertPdfToImage(pdf_file, image_file); ++ ++ std::vector fileList; ++ std::vector fdList; ++ fdList.push_back(imageFd_); ++ std::string taskId; ++ OHOS::NWeb::OhosAdapterHelper::GetInstance() ++ .GetPrintManagerInstance() ++ .StartPrint(fileList, fdList, taskId); ++ if (imageFd_ > 0) { ++ sync(); ++ close(imageFd_); ++ } ++ base::FilePath pdf_file_path(pdf_file); ++ base::DeleteFile(pdf_file_path); ++ ++ base::FilePath image_file_path(image_file); ++ base::DeleteFile(image_file_path); ++} ++ ++std::unique_ptr OhosPrintManager::CreatePdfSettings( ++ const printing::PageRanges& page_ranges) { ++ auto settings = std::make_unique(); ++ // TODO: ++ // The printing subsystem needs to provide an interface to set DPI page width, ++ // height, margins, etc. ++ int dpi = dpi_; ++ gfx::Size physical_size_device_units; ++ int width_in_dots = MilsToDots(width_, dpi); ++ int height_in_dots = MilsToDots(height_, dpi); ++ physical_size_device_units.SetSize(width_in_dots, height_in_dots); ++ ++ gfx::Rect printable_area_device_units; ++ ++ printable_area_device_units.SetRect(0, 0, width_in_dots, height_in_dots); ++ ++ if (!page_ranges.empty()) ++ settings->set_ranges(page_ranges); ++ ++ settings->set_dpi(dpi); ++ settings->SetPrinterPrintableArea(physical_size_device_units, ++ printable_area_device_units, true); ++ ++ printing::PageMargins margins; ++ margins.left = 0; ++ margins.right = 0; ++ margins.top = 0; ++ margins.bottom = 0; ++ settings->SetCustomMargins(margins); ++ settings->set_should_print_backgrounds(true); ++ return settings; ++} ++ ++void OhosPrintManager::DidExportPdf() { ++ std::string filePath = ++ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( ++ switches::kUserDataDir); ++ filePath += pdf_fileName; ++ int fd = open(filePath.c_str(), O_RDWR | O_CREAT, (mode_t)0777); ++ if (fd <= 0) { ++ LOG(ERROR) << "open failed, errno = " << strerror(errno); ++ return; ++ } ++ fd_ = fd; ++} ++ ++bool OhosPrintManager::ConvertPdfToImage(const std::string& pdf_filename, ++ const std::string& image_filename) { ++ // Init PDFium library. ++ FPDF_InitLibrary(); ++ ++ // Open PDF. ++ FPDF_DOCUMENT pdf_doc = FPDF_LoadDocument(pdf_filename.c_str(), nullptr); ++ if (!pdf_doc) { ++ return false; ++ } ++ ++ // Get PDF pageCount. ++ // int pageCount = FPDF_GetPageCount(pdf_doc); ++ ++ // Get the first PDF document. ++ FPDF_PAGE pdf_page = FPDF_LoadPage(pdf_doc, 0); ++ if (!pdf_page) { ++ FPDF_CloseDocument(pdf_doc); ++ FPDF_DestroyLibrary(); ++ return false; ++ } ++ ++ // Get page width and height. ++ int page_width = FPDF_GetPageWidth(pdf_page); ++ int page_height = FPDF_GetPageHeight(pdf_page); ++ ++ // Create bitmap ++ FPDF_BITMAP bitmap = FPDFBitmap_Create(page_width, page_height, 0); ++ ++ FPDFBitmap_FillRect(bitmap, 0, 0, page_width, page_height, 0xFFFFFFFF); ++ ++ FPDF_RenderPageBitmap(bitmap, pdf_page, 0, 0, page_width, page_height, 0, 0); ++ ++ // Save PNG. ++ int width = FPDFBitmap_GetWidth(bitmap); ++ int height = FPDFBitmap_GetHeight(bitmap); ++ SkBitmap skBitmap; ++ skBitmap.setInfo(SkImageInfo::Make(width, height, kBGRA_8888_SkColorType, ++ kPremul_SkAlphaType)); ++ skBitmap.setPixels(FPDFBitmap_GetBuffer(bitmap)); ++ ++ sk_sp image = SkImage::MakeFromBitmap(skBitmap); ++ sk_sp skData(image->encodeToData(SkEncodedImageFormat::kPNG, 100)); ++ ++ int fd = open(image_filename.c_str(), O_RDWR | O_CREAT, (mode_t)0777); ++ imageFd_ = fd; ++ if (fd <= 0) { ++ LOG(ERROR) << "open failed, errno = " << strerror(errno); ++ FPDF_ClosePage(pdf_page); ++ FPDF_CloseDocument(pdf_doc); ++ FPDFBitmap_Destroy(bitmap); ++ FPDF_DestroyLibrary(); ++ return false; ++ } ++ ++ ssize_t bytes_written_total = 0; ++ ssize_t size = base::checked_cast(skData->size()); ++ for (ssize_t bytes_written_partial = 0; bytes_written_total < size; ++ bytes_written_total += bytes_written_partial) { ++ bytes_written_partial = write(fd, skData->bytes() + bytes_written_total, ++ size - bytes_written_total); ++ } ++ ++ FPDF_ClosePage(pdf_page); ++ FPDF_CloseDocument(pdf_doc); ++ FPDFBitmap_Destroy(bitmap); ++ FPDF_DestroyLibrary(); ++ return true; ++} ++ ++WEB_CONTENTS_USER_DATA_KEY_IMPL(OhosPrintManager); ++ ++} // namespace printing +diff --git a/src/cef/libcef/browser/printing/ohos_print_manager.h b/src/cef/libcef/browser/printing/ohos_print_manager.h +new file mode 100755 +index 00000000000..631f7441820 +--- /dev/null ++++ b/src/cef/libcef/browser/printing/ohos_print_manager.h +@@ -0,0 +1,88 @@ ++/* ++ * Copyright (c) 2023 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 ++ * ++ * 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, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++#ifndef OHOS_PRINT_MANAGER_H_ ++#define OHOS_PRINT_MANAGER_H_ ++ ++#include ++ ++#include "components/printing/browser/print_manager.h" ++#include "components/printing/common/print.mojom-forward.h" ++#include "content/public/browser/web_contents_user_data.h" ++#include "printing/print_settings.h" ++ ++namespace printing { ++ ++class OhosPrintManager : public printing::PrintManager, ++ public content::WebContentsUserData { ++ public: ++ OhosPrintManager(const OhosPrintManager&) = delete; ++ OhosPrintManager& operator=(const OhosPrintManager&) = delete; ++ ++ ~OhosPrintManager() override; ++ ++ static void BindPrintManagerHost( ++ mojo::PendingAssociatedReceiver ++ receiver, ++ content::RenderFrameHost* rfh); ++ ++ // printing::PrintManager: ++ void PdfWritingDone(int page_count) override; ++ ++ bool PrintNow(); ++ ++ // Updates the parameters for printing. ++ void UpdateParam(std::unique_ptr settings, ++ int file_descriptor, ++ PdfWritingDoneCallback callback); ++ ++ private: ++ friend class content::WebContentsUserData; ++ ++ explicit OhosPrintManager(content::WebContents* contents); ++ ++ // mojom::PrintManagerHost: ++ void DidPrintDocument(printing::mojom::DidPrintDocumentParamsPtr params, ++ DidPrintDocumentCallback callback) override; ++ void GetDefaultPrintSettings( ++ GetDefaultPrintSettingsCallback callback) override; ++ void ScriptedPrint(printing::mojom::ScriptedPrintParamsPtr params, ++ ScriptedPrintCallback callback) override; ++ ++ static void OnDidPrintDocumentWritingDone( ++ const PdfWritingDoneCallback& callback, ++ DidPrintDocumentCallback did_print_document_cb, ++ uint32_t page_count); ++ ++ std::unique_ptr CreatePdfSettings( ++ const printing::PageRanges& page_ranges); ++ void DidExportPdf(); ++ static bool ConvertPdfToImage(const std::string& pdf_filename, ++ const std::string& image_filename); ++ ++ std::unique_ptr settings_; ++ ++ int fd_ = -1; ++ static int imageFd_; ++ uint32_t width_ = 8270; ++ uint32_t height_ = 11690; ++ int dpi_ = 300; // DPI (Dots Per Inch) ++ ++ WEB_CONTENTS_USER_DATA_KEY_DECL(); ++}; ++ ++} // namespace printing ++ ++#endif // OHOS_PRINT_MANAGER_H_ +diff --git a/src/cef/libcef/browser/views/view_util.cc b/src/cef/libcef/browser/views/view_util.cc +index 94241e44aa9..5d20fb41b73 +--- a/src/cef/libcef/browser/views/view_util.cc ++++ b/src/cef/libcef/browser/views/view_util.cc +@@ -103,7 +103,9 @@ class UserData : public base::SupportsUserData::Data { + if (view_) { + // The CefView does not own the views::View. Remove the CefView's + // reference to the views::View. ++#if !BUILDFLAG(IS_OHOS) || defined(TOOLKIT_VIEWS) + CefViewAdapter::GetFor(view_)->Detach(); ++#endif + } + } + +diff --git a/src/cef/libcef/common/crash_reporter_client.h b/src/cef/libcef/common/crash_reporter_client.h +index 7646f543dc5..6d99f601ef5 +--- a/src/cef/libcef/common/crash_reporter_client.h ++++ b/src/cef/libcef/common/crash_reporter_client.h +@@ -99,7 +99,11 @@ class CefCrashReporterClient : public crash_reporter::CrashReporterClient { + const base::StringPiece& value); + + private: ++#if BUILDFLAG(IS_OHOS) ++ bool has_crash_config_file_ = true; ++#else + bool has_crash_config_file_ = false; ++#endif // BUILDFLAG(IS_OHOS) + + enum KeySize { SMALL_SIZE, MEDIUM_SIZE, LARGE_SIZE }; + +diff --git a/src/cef/libcef/common/mojom/cef.mojom b/src/cef/libcef/common/mojom/cef.mojom +index 5fc111634ee..fe282042e7b +--- a/src/cef/libcef/common/mojom/cef.mojom ++++ b/src/cef/libcef/common/mojom/cef.mojom +@@ -52,7 +52,7 @@ struct RequestParams { + }; + + [EnableIf=is_ohos] +-struct TouchEventParams { ++struct HitEventParams { + float x; + float y; + int32 width; +@@ -111,7 +111,7 @@ interface RenderFrame { + UpdateLocale(string locale); + + [EnableIf=is_ohos] +- SendTouchEvent(TouchEventParams params); ++ SendHitEvent(HitEventParams params); + + [EnableIf=is_ohos] + SetInitialScale(float initialScale); +@@ -143,6 +143,12 @@ interface RenderFrame { + + [EnableIf=is_ohos] + SlideScroll(float vx, float vy); ++ ++ [EnableIf=is_ohos, Sync] ++ ZoomBy(float delta, float width, float height) => (); ++ ++ [EnableIf=is_ohos, Sync] ++ GetHitData() => (int32 type, string extra_data); + }; + + // Interface for communicating with a frame in the browser process. +@@ -160,14 +166,14 @@ interface BrowserFrame { + // Draggable regions have updated. + UpdateDraggableRegions(array? regions); + +- [EnableIf=is_ohos] +- OnUpdateHitData(HitDataParams params); +- + [EnableIf=is_ohos] + OnGetImageForContextNode(GetImageForContextNodeParams params); + + [EnableIf=is_ohos] + OnGetImageForContextNodeNull(); ++ ++ [EnableIf=is_ohos] ++ OnScriptedPrint(bool user_initiated); + }; + + struct CrossOriginWhiteListEntry { +diff --git a/src/cef/libcef/common/net/scheme_registration.cc b/src/cef/libcef/common/net/scheme_registration.cc +index 74a02b838c6..bff16f2ccb6 +--- a/src/cef/libcef/common/net/scheme_registration.cc ++++ b/src/cef/libcef/common/net/scheme_registration.cc +@@ -70,6 +70,10 @@ bool IsInternalHandledScheme(const std::string& scheme) { + url::kWsScheme, + url::kWssScheme, + url::kResourcesScheme, ++#if BUILDFLAG(IS_OHOS) ++ url::kDataabilityScheme, ++ url::kDatashareScheme, ++#endif + }; + + for (size_t i = 0; i < sizeof(schemes) / sizeof(schemes[0]); ++i) { +diff --git a/src/cef/libcef/common/request_impl.cc b/src/cef/libcef/common/request_impl.cc +index fcb40950fca..cd47a63e78b +--- a/src/cef/libcef/common/request_impl.cc ++++ b/src/cef/libcef/common/request_impl.cc +@@ -388,6 +388,11 @@ uint64 CefRequestImpl::GetIdentifier() { + return identifier_; + } + ++bool CefRequestImpl::IsMainFrame() { ++ base::AutoLock lock_scope(lock_); ++ return (destination_ == network::mojom::RequestDestination::kDocument); ++} ++ + void CefRequestImpl::Set(const network::ResourceRequest* request, + uint64 identifier) { + base::AutoLock lock_scope(lock_); +@@ -859,6 +864,10 @@ void CefRequestImpl::Reset() { + changes_ = kChangedNone; + } + ++void CefRequestImpl::SetDestination(network::mojom::RequestDestination destination) { ++ base::AutoLock lock_scope(lock_); ++ destination_ = destination; ++} + // CefPostData ---------------------------------------------------------------- + + // static +diff --git a/src/cef/libcef/common/request_impl.h b/src/cef/libcef/common/request_impl.h +index cdd167e69de..b9e7ca3ec52 +--- a/src/cef/libcef/common/request_impl.h ++++ b/src/cef/libcef/common/request_impl.h +@@ -81,7 +81,7 @@ class CefRequestImpl : public CefRequest { + ResourceType GetResourceType() override; + TransitionType GetTransitionType() override; + uint64 GetIdentifier() override; +- ++ bool IsMainFrame() override; + // Populate this object from the ResourceRequest object. + void Set(const network::ResourceRequest* request, uint64 identifier); + +@@ -128,6 +128,7 @@ class CefRequestImpl : public CefRequest { + static cef_referrer_policy_t BlinkReferrerPolicyToNetReferrerPolicy( + network::mojom::ReferrerPolicy blink_policy); + ++ void SetDestination(network::mojom::RequestDestination destination); + private: + // Mark values as changed. Must be called before the new values are assigned. + void Changed(uint8_t changes); +@@ -149,6 +150,7 @@ class CefRequestImpl : public CefRequest { + ResourceType resource_type_; + TransitionType transition_type_; + uint64 identifier_; ++ network::mojom::RequestDestination destination_; + + // The below members are used by CefURLRequest. + int flags_; +diff --git a/src/cef/libcef/common/soc_perf_util.cc b/src/cef/libcef/common/soc_perf_util.cc +index 6d7ca453ab8..ab0967dc48a +--- a/src/cef/libcef/common/soc_perf_util.cc ++++ b/src/cef/libcef/common/soc_perf_util.cc +@@ -6,7 +6,7 @@ + #include "soc_perf_util.h" + + #include "base/logging.h" +-#include "base/trace_event/common/trace_event_common.h" ++#include "base/trace_event/trace_event.h" + #include "ohos_adapter_helper.h" + #include "soc_perf_client_adapter.h" + +@@ -29,7 +29,7 @@ const int REST_TIME_IN_SECOND = 2; + } // namespace + + void SocPerUtil::EnableFlingBoost() { +- TRACE_EVENT2("soc_perf", "SocPerUtil::EnableFlingBoost2", "layout_num", ++ TRACE_EVENT2("power", "SocPerUtil::EnableFlingBoost2", "layout_num", + video_layout_num, "layer_num", layer_num); + OHOS::NWeb::OhosAdapterHelper::GetInstance() + .CreateSocPerfClientAdapter() +@@ -47,7 +47,7 @@ void SocPerUtil::EnableFlingBoost() { + } + + void SocPerUtil::DisableFlingBoost() { +- TRACE_EVENT0("soc_perf", "SocPerUtil::DisableFlingBoost"); ++ TRACE_EVENT0("power", "SocPerUtil::DisableFlingBoost"); + + OHOS::NWeb::OhosAdapterHelper::GetInstance() + .CreateSocPerfClientAdapter() +@@ -66,12 +66,12 @@ void SocPerUtil::TryRunSocPerf() { + if ((base::Time().Now() - first_time_boost_timestamp).InSeconds() >= + MAX_BOOST_RUN_TIME_IN_SECOND) { + boost_finished = true; +- TRACE_EVENT0("soc_perf", "SocPerUtil::JsSocPerfFinished"); ++ TRACE_EVENT0("power", "SocPerUtil::JsSocPerfFinished"); + return; + } + if ((base::Time().Now() - last_time_boost_timestamp).InSeconds() >= + REST_TIME_IN_SECOND) { +- TRACE_EVENT0("soc_perf", "SocPerUtil::JsSocPerfThreadBoost"); ++ TRACE_EVENT0("power", "SocPerUtil::JsSocPerfThreadBoost"); + last_time_boost_timestamp = base::Time().Now(); + OHOS::NWeb::OhosAdapterHelper::GetInstance() + .CreateSocPerfClientAdapter() +@@ -90,4 +90,4 @@ void SocPerUtil::StartBoost() { + TryRunSocPerf(); + } + +-} // namespace soc_perf +\ No newline at end of file ++} // namespace soc_perf +diff --git a/src/cef/libcef/renderer/alloy/alloy_content_renderer_client.cc b/src/cef/libcef/renderer/alloy/alloy_content_renderer_client.cc +index c388996b30e..7654009315b +--- a/src/cef/libcef/renderer/alloy/alloy_content_renderer_client.cc ++++ b/src/cef/libcef/renderer/alloy/alloy_content_renderer_client.cc +@@ -103,6 +103,11 @@ + #include "base/strings/sys_string_conversions.h" + #endif + ++#if BUILDFLAG(IS_OHOS) ++#include "libcef/renderer/alloy/alloy_content_settings_client.h" ++#include "libcef/renderer/extensions/ohos_print_render_frame_helper_delegate.h" ++#endif ++ + #if BUILDFLAG(IS_OHOS) && BUILDFLAG(ENABLE_PRINT_PREVIEW) + #include "libcef/renderer/extensions/print_render_frame_helper_delegate.h" + #endif +@@ -118,6 +123,13 @@ + #include "components/pdf/renderer/pdf_find_in_page.h" + #endif + ++#if BUILDFLAG(IS_OHOS) ++#include "components/page_load_metrics/renderer/metrics_render_frame_observer.h" ++#include "components/subresource_filter/content/renderer/subresource_filter_agent.h" ++#include "components/subresource_filter/content/renderer/unverified_ruleset_dealer.h" ++#include "components/subresource_filter/core/common/common_features.h" ++#endif ++ + AlloyContentRendererClient::AlloyContentRendererClient() + : main_entry_time_(base::TimeTicks::Now()), + render_manager_(new CefRenderManager) { +@@ -247,6 +259,11 @@ void AlloyContentRendererClient::RenderThreadStarted() { + pdf::PepperPDFHost::SetPrintClient(pdf_print_client_.get()); + } + #endif ++#if BUILDFLAG(IS_OHOS) ++ subresource_filter_ruleset_dealer_ = ++ std::make_unique(); ++ thread->AddObserver(subresource_filter_ruleset_dealer_.get()); ++#endif + + if (extensions::ExtensionsEnabled()) + extensions_renderer_client_->RenderThreadStarted(); +@@ -285,6 +302,9 @@ void AlloyContentRendererClient::RenderThreadConnected() { + + void AlloyContentRendererClient::RenderFrameCreated( + content::RenderFrame* render_frame) { ++#if BUILDFLAG(IS_OHOS) ++ new AlloyContentSettingsClient(render_frame); ++#endif + auto render_frame_observer = new CefRenderFrameObserver(render_frame); + + #if BUILDFLAG(IS_OHOS) && BUILDFLAG(ENABLE_PLUGINS) +@@ -315,6 +335,15 @@ void AlloyContentRendererClient::RenderFrameCreated( + OnBrowserCreated(render_frame->GetRenderView(), is_windowless); + } + ++#if BUILDFLAG(IS_OHOS) ++ if (is_windowless.has_value()) { ++ new printing::PrintRenderFrameHelper( ++ render_frame, ++ base::WrapUnique(new extensions::OhosPrintRenderFrameHelperDelegate( ++ *is_windowless))); ++ } ++#endif ++ + #if BUILDFLAG(IS_OHOS) && BUILDFLAG(ENABLE_PRINT_PREVIEW) + if (is_windowless.has_value()) { + new printing::PrintRenderFrameHelper( +@@ -331,6 +360,26 @@ void AlloyContentRendererClient::RenderFrameCreated( + render_frame->GetRoutingID())); + } + #endif ++#if BUILDFLAG(IS_OHOS) ++ // Owned by |render_frame|. ++ page_load_metrics::MetricsRenderFrameObserver* metrics_render_frame_observer = ++ new page_load_metrics::MetricsRenderFrameObserver(render_frame); ++ // There is no render thread, thus no UnverifiedRulesetDealer in ++ // ChromeRenderViewTests. ++ if (subresource_filter_ruleset_dealer_) { ++ // Create AdResourceTracker to tracker ad resource loads at the chrome ++ // layer. ++ auto ad_resource_tracker = ++ std::make_unique(); ++ metrics_render_frame_observer->SetAdResourceTracker( ++ ad_resource_tracker.get()); ++ auto* subresource_filter_agent = ++ new subresource_filter::SubresourceFilterAgent( ++ render_frame, subresource_filter_ruleset_dealer_.get(), ++ std::move(ad_resource_tracker)); ++ subresource_filter_agent->Initialize(); ++ } ++#endif + } + + void AlloyContentRendererClient::WebViewCreated(blink::WebView* web_view) { +diff --git a/src/cef/libcef/renderer/alloy/alloy_content_renderer_client.h b/src/cef/libcef/renderer/alloy/alloy_content_renderer_client.h +index 59680bb4b81..7f2a7d921f3 +--- a/src/cef/libcef/renderer/alloy/alloy_content_renderer_client.h ++++ b/src/cef/libcef/renderer/alloy/alloy_content_renderer_client.h +@@ -46,6 +46,12 @@ namespace web_cache { + class WebCacheImpl; + } + ++#if BUILDFLAG(IS_OHOS) ++namespace subresource_filter { ++class UnverifiedRulesetDealer; ++} ++#endif ++ + class AlloyRenderThreadObserver; + class CefRenderManager; + class ChromePDFPrintClient; +@@ -159,6 +165,10 @@ class AlloyContentRendererClient + #if BUILDFLAG(IS_OHOS) && BUILDFLAG(ENABLE_PDF) + std::unique_ptr pdf_print_client_; + #endif ++#if BUILDFLAG(IS_OHOS) ++ std::unique_ptr ++ subresource_filter_ruleset_dealer_; ++#endif + + std::unique_ptr extensions_client_; + std::unique_ptr +diff --git a/src/cef/libcef/renderer/browser_impl.h b/src/cef/libcef/renderer/browser_impl.h +index 4b479fea9a4..35d8c19f8c0 +--- a/src/cef/libcef/renderer/browser_impl.h ++++ b/src/cef/libcef/renderer/browser_impl.h +@@ -105,6 +105,13 @@ class CefBrowserImpl : public CefBrowser, public blink::WebViewObserver { + + #if BUILDFLAG(IS_OHOS) + bool ShouldShowLoadingUI() override; ++ void SetForceEnableZoom(bool forceEnableZoom) override {}; ++ bool GetForceEnableZoom() override { ++ return false; ++ } ++ void SelectAndCopy() override{}; ++ bool ShouldShowFreeCopy() override { return false; }; ++ void SetEnableBlankTargetPopupIntercept(bool enableBlankTargetPopup) override {}; + #endif + + private: + diff --git a/src/cef/libcef/renderer/extensions/ohos_print_render_frame_helper_delegate.cc b/src/cef/libcef/renderer/extensions/ohos_print_render_frame_helper_delegate.cc +new file mode 100755 +index 00000000000..59fb2db72cc +--- /dev/null ++++ b/src/cef/libcef/renderer/extensions/ohos_print_render_frame_helper_delegate.cc +@@ -0,0 +1,43 @@ ++/* ++ * Copyright (c) 2023 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 ++ * ++ * 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, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++#include "libcef/renderer/extensions/ohos_print_render_frame_helper_delegate.h" ++ ++#include "libcef/common/extensions/extensions_util.h" ++#include "third_party/blink/public/web/web_element.h" ++ ++namespace extensions { ++ ++OhosPrintRenderFrameHelperDelegate::OhosPrintRenderFrameHelperDelegate( ++ bool is_windowless) ++ : is_windowless_(is_windowless) {} ++ ++OhosPrintRenderFrameHelperDelegate::~OhosPrintRenderFrameHelperDelegate() = default; ++ ++blink::WebElement OhosPrintRenderFrameHelperDelegate::GetPdfElement( ++ blink::WebLocalFrame* frame) { ++ return blink::WebElement(); ++} ++ ++bool OhosPrintRenderFrameHelperDelegate::IsPrintPreviewEnabled() { ++ return !is_windowless_ && PrintPreviewEnabled(); ++} ++ ++bool OhosPrintRenderFrameHelperDelegate::OverridePrint( ++ blink::WebLocalFrame* frame) { ++ return false; ++} ++ ++} // namespace extensions +diff --git a/src/cef/libcef/renderer/extensions/ohos_print_render_frame_helper_delegate.h b/src/cef/libcef/renderer/extensions/ohos_print_render_frame_helper_delegate.h +new file mode 100755 +index 00000000000..0d79bb75d73 +--- /dev/null ++++ b/src/cef/libcef/renderer/extensions/ohos_print_render_frame_helper_delegate.h +@@ -0,0 +1,39 @@ ++/* ++ * Copyright (c) 2023 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 ++ * ++ * 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, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++#ifndef OHOS_PRINT_RENDER_FRAME_HELPER_DELEGATE_H_ ++#define OHOS_PRINT_RENDER_FRAME_HELPER_DELEGATE_H_ ++ ++#include "components/printing/renderer/print_render_frame_helper.h" ++ ++namespace extensions { ++ ++class OhosPrintRenderFrameHelperDelegate ++ : public printing::PrintRenderFrameHelper::Delegate { ++ public: ++ explicit OhosPrintRenderFrameHelperDelegate(bool is_windowless); ++ ~OhosPrintRenderFrameHelperDelegate() override; ++ ++ blink::WebElement GetPdfElement(blink::WebLocalFrame* frame) override; ++ bool IsPrintPreviewEnabled() override; ++ bool OverridePrint(blink::WebLocalFrame* frame) override; ++ ++ private: ++ bool is_windowless_; ++}; ++ ++} // namespace extensions ++ ++#endif // OHOS_PRINT_RENDER_FRAME_HELPER_DELEGATE_H_ +\ No newline at end of file +diff --git a/src/cef/libcef/renderer/frame_impl.cc b/src/cef/libcef/renderer/frame_impl.cc +index e74978a2fa7..284dca51658 +--- a/src/cef/libcef/renderer/frame_impl.cc ++++ b/src/cef/libcef/renderer/frame_impl.cc +@@ -32,8 +32,10 @@ + #include "libcef/renderer/v8_impl.h" + + #include "base/strings/utf_string_conversions.h" ++#include "base/process/process_metrics.h" + #include "content/public/renderer/render_view.h" + #include "content/renderer/render_frame_impl.h" ++#include "skia/ext/image_operations.h" + #include "third_party/blink/public/mojom/frame/frame.mojom-blink.h" + #include "third_party/blink/public/platform/web_back_forward_cache_loader_helper.h" + #include "third_party/blink/public/platform/web_cache.h" +@@ -70,6 +72,9 @@ constexpr auto kConnectionTimeout = base::Seconds(4); + const std::string kAddressPrefix = "geo:0,0?q="; + const std::string kEmailPrefix = "mailto:"; + const std::string kPhoneNumberPrefix = "tel:"; ++const int kMaxContextImageNodeSizeIfDownScale = 1024; ++// 2GB ++const int kNeedImageDownScaleSysMemKB = 2097152; + + // The amount of content to overlap between two screens when using + // pageUp/pageDown methiods. static int PAGE_SCROLL_OVERLAP = 24; Standard +@@ -103,6 +108,49 @@ float computeSlidePosition(float v) { + return (v * POSITION_RATIO / 1000); + } + ++int GetSystemTotalMem() { ++ base::SystemMemoryInfoKB meminfo; ++ if (base::GetSystemMemoryInfo(&meminfo)) { ++ return meminfo.total; ++ } ++ LOG(WARNING) << "Get sys meminfo failed"; ++ return -1; ++} ++ ++bool NeedsDownscale(const gfx::Size& original_image_size, int total_mem) { ++ if (total_mem > kNeedImageDownScaleSysMemKB) { ++ return false; ++ } ++ if (original_image_size.width() <= kMaxContextImageNodeSizeIfDownScale && ++ original_image_size.height() <= kMaxContextImageNodeSizeIfDownScale) ++ return false; ++ return true; ++} ++ ++SkBitmap Downscale(const SkBitmap& image, int total_mem) { ++ if (image.isNull()) ++ return SkBitmap(); ++ ++ gfx::Size image_size(image.width(), image.height()); ++ if (!NeedsDownscale(image_size, total_mem)) ++ return image; ++ ++ gfx::SizeF scaled_size = gfx::SizeF(image_size); ++ ++ if (scaled_size.width() > kMaxContextImageNodeSizeIfDownScale) { ++ scaled_size.Scale(kMaxContextImageNodeSizeIfDownScale / scaled_size.width()); ++ } ++ ++ if (scaled_size.height() > kMaxContextImageNodeSizeIfDownScale) { ++ scaled_size.Scale(kMaxContextImageNodeSizeIfDownScale / scaled_size.height()); ++ } ++ ++ return skia::ImageOperations::Resize(image, ++ skia::ImageOperations::RESIZE_GOOD, ++ static_cast(scaled_size.width()), ++ static_cast(scaled_size.height())); ++} ++ + #endif // BUILDFLAG(IS_OHOS) + + } // namespace +@@ -750,11 +798,12 @@ void CefFrameImpl::LoadHeaderUrl(const CefString& url, + } + + void CefFrameImpl::OnFocusedNodeChanged(const blink::WebElement& element) { +- if (element.IsNull()) { +- LOG(INFO) << "FocusedHitDataChange element is NULL"; ++ if (element.IsNull() || is_update_) { ++ LOG(INFO) << "FocusedHitDataChange element is NULL or no need to report."; ++ is_update_ = false; + return; + } +- LOG(INFO) << "FocusedHitDataChangeBegin"; ++ + cef::mojom::HitDataParamsPtr data = cef::mojom::HitDataParams::New(); + data->href = element.GetAttribute("href").Utf16(); + data->anchor_text = element.TextContent().Utf16(); +@@ -764,22 +813,26 @@ void CefFrameImpl::OnFocusedNodeChanged(const blink::WebElement& element) { + GURL absolute_image_url = GetChildImageUrlFromElement(element); + PopulateHitTestData(absolute_link_url, absolute_image_url, + element.IsEditable(), data); +- LOG(INFO) << "FocusedHitDataChangeEnd"; +- SendToBrowserFrame(__FUNCTION__, +- base::BindOnce( +- [](cef::mojom::HitDataParamsPtr data, +- const BrowserFrameType& browser_frame) { +- browser_frame->OnUpdateHitData(std::move(data)); +- }, +- std::move(data))); ++ cef_hit_data_.type = data->type; ++ cef_hit_data_.extra_data = data->extra_data_for_type; + } + +-void CefFrameImpl::SendTouchEvent(cef::mojom::TouchEventParamsPtr params) { ++void CefFrameImpl::ScriptedPrint(bool user_initiated) { ++ SendToBrowserFrame( ++ __FUNCTION__, ++ base::BindOnce( ++ [](bool user_initiated, const BrowserFrameType& browser_frame) { ++ browser_frame->OnScriptedPrint(std::move(user_initiated)); ++ }, ++ std::move(user_initiated))); ++} ++ ++void CefFrameImpl::SendHitEvent(cef::mojom::HitEventParamsPtr params) { + auto render_frame = content::RenderFrame::FromWebFrame(frame_); + DCHECK(render_frame->IsMainFrame()); + blink::WebView* webview = render_frame->GetRenderView()->GetWebView(); + if (!webview) { +- LOG(INFO) << "SendTouchEvent webview is NULL"; ++ LOG(INFO) << "SendHitEvent webview is NULL"; + return; + } + const blink::WebHitTestResult result = +@@ -796,14 +849,9 @@ void CefFrameImpl::SendTouchEvent(cef::mojom::TouchEventParamsPtr params) { + + PopulateHitTestData(result.AbsoluteLinkURL(), absolute_image_url, + result.IsContentEditable(), data); +- SendToBrowserFrame( +- __FUNCTION__, +- base::BindOnce( +- [](cef::mojom::HitDataParamsPtr hit_test_data, +- const BrowserFrameType& browser_frame) { +- browser_frame->OnUpdateHitData(std::move(hit_test_data)); +- }, +- std::move(data))); ++ cef_hit_data_.type = data->type; ++ cef_hit_data_.extra_data = data->extra_data_for_type; ++ is_update_ = true; + } + + void CefFrameImpl::RemoveCache() { +@@ -844,6 +892,10 @@ void CefFrameImpl::GetImageForContextNode() { + LOG(ERROR) << "GetImageForContextNode frame is nullptr"; + return; + } ++ if (total_mem_ == -1) { ++ total_mem_ = GetSystemTotalMem(); ++ } ++ + cef::mojom::GetImageForContextNodeParamsPtr params = + cef::mojom::GetImageForContextNodeParams::New(); + blink::WebNode context_node = frame_->ContextMenuImageNode(); +@@ -866,10 +918,11 @@ void CefFrameImpl::GetImageForContextNode() { + original_size = web_element.GetImageSize(); + + SkBitmap image = web_element.ImageContents(); ++ SkBitmap resize_image = Downscale(image, total_mem_); + image_extension = "." + web_element.ImageExtension(); +- params->width = original_size.width(); +- params->height = original_size.height(); +- params->image = image; ++ params->width = resize_image.width(); ++ params->height = resize_image.height(); ++ params->image = resize_image; + params->image_extension = image_extension; + SendToBrowserFrame( + __FUNCTION__, +@@ -1074,6 +1127,17 @@ void CefFrameImpl::SlideScroll(float vx, float vy) { + webview->SmoothScroll(dx + scroll_offset.x(), dy + scroll_offset.y(), + base::Milliseconds(DEFAULT_SCROLL_ANIMATION_DURATION_MILLISEC)); + } ++ ++void CefFrameImpl::ZoomBy(float delta, float width, float height, cef::mojom::RenderFrame::ZoomByCallback callback) { ++ auto render_frame = content::RenderFrame::FromWebFrame(frame_); ++ DCHECK(render_frame->IsMainFrame()); ++ render_frame->SetZoomLevel(delta, gfx::Point(width / 2, height / 2)); ++ std::move(callback).Run(); ++} ++ ++void CefFrameImpl::GetHitData(cef::mojom::RenderFrame::GetHitDataCallback callback) { ++ std::move(callback).Run(cef_hit_data_.type, cef_hit_data_.extra_data); ++} + #endif // BUILDFLAG(IS_OHOS) + + // Enable deprecation warnings on Windows. See http://crbug.com/585142. +diff --git a/src/cef/libcef/renderer/frame_impl.h b/src/cef/libcef/renderer/frame_impl.h +index d5d4f727493..0a268cbb16e +--- a/src/cef/libcef/renderer/frame_impl.h ++++ b/src/cef/libcef/renderer/frame_impl.h +@@ -104,6 +104,7 @@ class CefFrameImpl : public CefFrame, public cef::mojom::RenderFrame { + void LoadHeaderUrl(const CefString& url, + const CefString& additionalHttpHeaders) override; + void OnFocusedNodeChanged(const blink::WebElement& element); ++ void ScriptedPrint(bool user_initiated); + #endif // BUILDFLAG(IS_OHOS) + + private: +@@ -150,7 +151,11 @@ class CefFrameImpl : public CefFrame, public cef::mojom::RenderFrame { + void DidStopLoading() override; + void MoveOrResizeStarted() override; + #if BUILDFLAG(IS_OHOS) +- void SendTouchEvent(cef::mojom::TouchEventParamsPtr params) override; ++ struct CefHitData { ++ int type; ++ CefString extra_data; ++ }; ++ void SendHitEvent(cef::mojom::HitEventParamsPtr params) override; + void SetInitialScale(float initialScale) override; + void SetJsOnlineProperty(bool network_up) override; + void PutZoomingForTextFactor(float factor) override; +@@ -163,6 +168,8 @@ class CefFrameImpl : public CefFrame, public cef::mojom::RenderFrame { + void ScrollTo(float x, float y) override; + void ScrollBy(float delta_x, float delta_y) override; + void SlideScroll(float vx, float vy) override; ++ void ZoomBy(float delta, float width, float height, cef::mojom::RenderFrame::ZoomByCallback callback) override; ++ void GetHitData(cef::mojom::RenderFrame::GetHitDataCallback callback) override; + GURL GetAbsoluteUrl(const blink::WebNode& node, + const std::u16string& url_fragment); + GURL GetAbsoluteSrcUrl(const blink::WebElement& element); +@@ -177,6 +184,9 @@ class CefFrameImpl : public CefFrame, public cef::mojom::RenderFrame { + const GURL& absolute_image_url, + bool is_editable, + cef::mojom::HitDataParamsPtr& data); ++ bool is_update_ = false; ++ CefHitData cef_hit_data_; ++ int total_mem_ = -1; + #endif // BUILDFLAG(IS_OHOS) + + CefBrowserImpl* browser_; +@@ -209,7 +219,6 @@ class CefFrameImpl : public CefFrame, public cef::mojom::RenderFrame { + mojo::Remote browser_frame_; + + base::WeakPtrFactory weak_ptr_factory_{this}; +- + IMPLEMENT_REFCOUNTING(CefFrameImpl); + }; + +diff --git a/src/cef/libcef/renderer/render_frame_observer.cc b/src/cef/libcef/renderer/render_frame_observer.cc +index 8c93e7469e4..72f310a0afa +--- a/src/cef/libcef/renderer/render_frame_observer.cc ++++ b/src/cef/libcef/renderer/render_frame_observer.cc +@@ -201,6 +201,12 @@ bool CefRenderFrameObserver::OnAssociatedInterfaceRequestForFrame( + return associated_interfaces_.TryBindInterface(interface_name, handle); + } + ++void CefRenderFrameObserver::ScriptedPrint(bool user_initiated) { ++ if (!frame_) ++ return; ++ frame_->ScriptedPrint(user_initiated); ++} ++ + void CefRenderFrameObserver::AttachFrame(CefFrameImpl* frame) { + DCHECK(frame); + DCHECK(!frame_); +diff --git a/src/cef/libcef/renderer/render_frame_observer.h b/src/cef/libcef/renderer/render_frame_observer.h +index 49648324563..f570f032273 +--- a/src/cef/libcef/renderer/render_frame_observer.h ++++ b/src/cef/libcef/renderer/render_frame_observer.h +@@ -45,6 +45,7 @@ class CefRenderFrameObserver : public content::RenderFrameObserver { + bool OnAssociatedInterfaceRequestForFrame( + const std::string& interface_name, + mojo::ScopedInterfaceEndpointHandle* handle) override; ++ void ScriptedPrint(bool user_initiated) override; + + service_manager::BinderRegistry* registry() { return ®istry_; } + blink::AssociatedInterfaceRegistry* associated_interfaces() { +diff --git a/src/cef/libcef_dll/cpptoc/browser_cpptoc.cc b/src/cef/libcef_dll/cpptoc/browser_cpptoc.cc +index d713abd8f25..e8b863f74fa +--- a/src/cef/libcef_dll/cpptoc/browser_cpptoc.cc ++++ b/src/cef/libcef_dll/cpptoc/browser_cpptoc.cc +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=de6d56ff06c32a54e999d9309218c6a546eaa146$ ++// $hash=50f8e037e07c7df816fb81da4dc9feffb78025f4$ + // + + #include "libcef_dll/cpptoc/browser_cpptoc.h" +@@ -215,6 +215,35 @@ void CEF_CALLBACK browser_reload_original_url(struct _cef_browser_t* self) { + CefBrowserCppToC::Get(self)->ReloadOriginalUrl(); + } + ++void CEF_CALLBACK browser_select_and_copy(struct _cef_browser_t* self) { ++ shutdown_checker::AssertNotShutdown(); ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ DCHECK(self); ++ if (!self) ++ return; ++ ++ // Execute ++ CefBrowserCppToC::Get(self)->SelectAndCopy(); ++} ++ ++int CEF_CALLBACK browser_should_show_free_copy(struct _cef_browser_t* self) { ++ shutdown_checker::AssertNotShutdown(); ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ DCHECK(self); ++ if (!self) ++ return 0; ++ ++ // Execute ++ bool _retval = CefBrowserCppToC::Get(self)->ShouldShowFreeCopy(); ++ ++ // Return type: bool ++ return _retval; ++} ++ + void CEF_CALLBACK + browser_set_browser_user_agent_string(struct _cef_browser_t* self, + const cef_string_t* user_agent) { +@@ -519,6 +548,53 @@ int CEF_CALLBACK browser_should_show_loading_ui(struct _cef_browser_t* self) { + return _retval; + } + ++void CEF_CALLBACK browser_set_force_enable_zoom(struct _cef_browser_t* self, ++ int forceEnableZoom) { ++ shutdown_checker::AssertNotShutdown(); ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ DCHECK(self); ++ if (!self) ++ return; ++ ++ // Execute ++ CefBrowserCppToC::Get(self)->SetForceEnableZoom(forceEnableZoom ? true ++ : false); ++} ++ ++int CEF_CALLBACK browser_get_force_enable_zoom(struct _cef_browser_t* self) { ++ shutdown_checker::AssertNotShutdown(); ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ DCHECK(self); ++ if (!self) ++ return 0; ++ ++ // Execute ++ bool _retval = CefBrowserCppToC::Get(self)->GetForceEnableZoom(); ++ ++ // Return type: bool ++ return _retval; ++} ++ ++void CEF_CALLBACK ++browser_set_enable_blank_target_popup_intercept(struct _cef_browser_t* self, ++ int enableBlankTargetPopup) { ++ shutdown_checker::AssertNotShutdown(); ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ DCHECK(self); ++ if (!self) ++ return; ++ ++ // Execute ++ CefBrowserCppToC::Get(self)->SetEnableBlankTargetPopupIntercept( ++ enableBlankTargetPopup ? true : false); ++} ++ + } // namespace + + // CONSTRUCTOR - Do not edit by hand. +@@ -537,6 +613,8 @@ CefBrowserCppToC::CefBrowserCppToC() { + GetStruct()->reload = browser_reload; + GetStruct()->reload_ignore_cache = browser_reload_ignore_cache; + GetStruct()->reload_original_url = browser_reload_original_url; ++ GetStruct()->select_and_copy = browser_select_and_copy; ++ GetStruct()->should_show_free_copy = browser_should_show_free_copy; + GetStruct()->set_browser_user_agent_string = + browser_set_browser_user_agent_string; + GetStruct()->stop_load = browser_stop_load; +@@ -556,6 +634,10 @@ CefBrowserCppToC::CefBrowserCppToC() { + GetStruct()->get_geolocation_permissions = + browser_get_geolocation_permissions; + GetStruct()->should_show_loading_ui = browser_should_show_loading_ui; ++ GetStruct()->set_force_enable_zoom = browser_set_force_enable_zoom; ++ GetStruct()->get_force_enable_zoom = browser_get_force_enable_zoom; ++ GetStruct()->set_enable_blank_target_popup_intercept = ++ browser_set_enable_blank_target_popup_intercept; + } + + // DESTRUCTOR - Do not edit by hand. +diff --git a/src/cef/libcef_dll/cpptoc/browser_host_cpptoc.cc b/src/cef/libcef_dll/cpptoc/browser_host_cpptoc.cc +index b7b75e6dd31..8d763c96337 +--- a/src/cef/libcef_dll/cpptoc/browser_host_cpptoc.cc ++++ b/src/cef/libcef_dll/cpptoc/browser_host_cpptoc.cc +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=fbbfbf396665393a59e2487e84880bafe3568174$ ++// $hash=afcef15ec29dd4cd2f862a2c97065c6c08f09040$ + // + + #include "libcef_dll/cpptoc/browser_host_cpptoc.h" +@@ -1801,10 +1801,42 @@ int CEF_CALLBACK browser_host_is_audio_muted(struct _cef_browser_host_t* self) { + return _retval; + } + ++void CEF_CALLBACK ++browser_host_set_audio_resume_interval(struct _cef_browser_host_t* self, ++ int resumeInterval) { ++ shutdown_checker::AssertNotShutdown(); ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ DCHECK(self); ++ if (!self) ++ return; ++ ++ // Execute ++ CefBrowserHostCppToC::Get(self)->SetAudioResumeInterval(resumeInterval); ++} ++ ++void CEF_CALLBACK ++browser_host_set_audio_exclusive(struct _cef_browser_host_t* self, ++ int audioExclusive) { ++ shutdown_checker::AssertNotShutdown(); ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ DCHECK(self); ++ if (!self) ++ return; ++ ++ // Execute ++ CefBrowserHostCppToC::Get(self)->SetAudioExclusive(audioExclusive ? true ++ : false); ++} ++ + void CEF_CALLBACK browser_host_execute_java_script( + struct _cef_browser_host_t* self, + const cef_string_t* code, +- struct _cef_java_script_result_callback_t* callback) { ++ struct _cef_java_script_result_callback_t* callback, ++ int extention) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING +@@ -1823,7 +1855,8 @@ void CEF_CALLBACK browser_host_execute_java_script( + + // Execute + CefBrowserHostCppToC::Get(self)->ExecuteJavaScript( +- CefString(code), CefJavaScriptResultCallbackCToCpp::Wrap(callback)); ++ CefString(code), CefJavaScriptResultCallbackCToCpp::Wrap(callback), ++ extention ? true : false); + } + + void CEF_CALLBACK +@@ -2133,6 +2166,38 @@ void CEF_CALLBACK browser_host_set_cache_mode(struct _cef_browser_host_t* self, + CefBrowserHostCppToC::Get(self)->SetCacheMode(falg); + } + ++void CEF_CALLBACK browser_host_set_should_frame_submission_before_draw( ++ struct _cef_browser_host_t* self, ++ int should) { ++ shutdown_checker::AssertNotShutdown(); ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ DCHECK(self); ++ if (!self) ++ return; ++ ++ // Execute ++ CefBrowserHostCppToC::Get(self)->SetShouldFrameSubmissionBeforeDraw( ++ should ? true : false); ++} ++ ++void CEF_CALLBACK browser_host_zoom_by(struct _cef_browser_host_t* self, ++ float delta, ++ float width, ++ float height) { ++ shutdown_checker::AssertNotShutdown(); ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ DCHECK(self); ++ if (!self) ++ return; ++ ++ // Execute ++ CefBrowserHostCppToC::Get(self)->ZoomBy(delta, width, height); ++} ++ + } // namespace + + // CONSTRUCTOR - Do not edit by hand. +@@ -2234,6 +2299,9 @@ CefBrowserHostCppToC::CefBrowserHostCppToC() { + GetStruct()->is_background_host = browser_host_is_background_host; + GetStruct()->set_audio_muted = browser_host_set_audio_muted; + GetStruct()->is_audio_muted = browser_host_is_audio_muted; ++ GetStruct()->set_audio_resume_interval = ++ browser_host_set_audio_resume_interval; ++ GetStruct()->set_audio_exclusive = browser_host_set_audio_exclusive; + GetStruct()->execute_java_script = browser_host_execute_java_script; + GetStruct()->set_native_window = browser_host_set_native_window; + GetStruct()->set_web_debugging_access = browser_host_set_web_debugging_access; +@@ -2255,6 +2323,9 @@ CefBrowserHostCppToC::CefBrowserHostCppToC() { + GetStruct()->set_file_access = browser_host_set_file_access; + GetStruct()->set_block_network = browser_host_set_block_network; + GetStruct()->set_cache_mode = browser_host_set_cache_mode; ++ GetStruct()->set_should_frame_submission_before_draw = ++ browser_host_set_should_frame_submission_before_draw; ++ GetStruct()->zoom_by = browser_host_zoom_by; + } + + // DESTRUCTOR - Do not edit by hand. +diff --git a/src/cef/libcef_dll/cpptoc/client_cpptoc.cc b/src/cef/libcef_dll/cpptoc/client_cpptoc.cc +index 84bae541153..e5c92d84180 +--- a/src/cef/libcef_dll/cpptoc/client_cpptoc.cc ++++ b/src/cef/libcef_dll/cpptoc/client_cpptoc.cc +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=9d36943180a6382a12e74a92d9d9967039f14ad3$ ++// $hash=7abad1c3dec145629b7d1d17793c7949154c498f$ + // + + #include "libcef_dll/cpptoc/client_cpptoc.h" +@@ -26,6 +26,7 @@ + #include "libcef_dll/cpptoc/keyboard_handler_cpptoc.h" + #include "libcef_dll/cpptoc/life_span_handler_cpptoc.h" + #include "libcef_dll/cpptoc/load_handler_cpptoc.h" ++#include "libcef_dll/cpptoc/media_handler_cpptoc.h" + #include "libcef_dll/cpptoc/permission_request_cpptoc.h" + #include "libcef_dll/cpptoc/print_handler_cpptoc.h" + #include "libcef_dll/cpptoc/render_handler_cpptoc.h" +@@ -295,6 +296,22 @@ client_get_request_handler(struct _cef_client_t* self) { + return CefRequestHandlerCppToC::Wrap(_retval); + } + ++struct _cef_media_handler_t* CEF_CALLBACK ++client_get_media_handler(struct _cef_client_t* self) { ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ DCHECK(self); ++ if (!self) ++ return NULL; ++ ++ // Execute ++ CefRefPtr _retval = ++ CefClientCppToC::Get(self)->GetMediaHandler(); ++ ++ // Return type: refptr_same ++ return CefMediaHandlerCppToC::Wrap(_retval); ++} ++ + struct _cef_permission_request_t* CEF_CALLBACK + client_get_permission_request(struct _cef_client_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING +@@ -402,6 +419,7 @@ CefClientCppToC::CefClientCppToC() { + GetStruct()->get_print_handler = client_get_print_handler; + GetStruct()->get_render_handler = client_get_render_handler; + GetStruct()->get_request_handler = client_get_request_handler; ++ GetStruct()->get_media_handler = client_get_media_handler; + GetStruct()->get_permission_request = client_get_permission_request; + GetStruct()->on_process_message_received = client_on_process_message_received; + GetStruct()->notify_java_script_result = client_notify_java_script_result; +diff --git a/src/cef/libcef_dll/cpptoc/java_script_result_callback_cpptoc.cc b/src/cef/libcef_dll/cpptoc/java_script_result_callback_cpptoc.cc +index 3ea3c17b151..1feca6b6547 +--- a/src/cef/libcef_dll/cpptoc/java_script_result_callback_cpptoc.cc ++++ b/src/cef/libcef_dll/cpptoc/java_script_result_callback_cpptoc.cc +@@ -9,10 +9,11 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=98a8f58c5379ac345b36c7cde9ba25d31837447b$ ++// $hash=9607b573a87d3440470b9a9fe3de07a1aa92af01$ + // + + #include "libcef_dll/cpptoc/java_script_result_callback_cpptoc.h" ++#include "libcef_dll/ctocpp/value_ctocpp.h" + #include "libcef_dll/shutdown_checker.h" + + namespace { +@@ -21,7 +22,7 @@ namespace { + + void CEF_CALLBACK java_script_result_callback_on_java_script_exe_result( + struct _cef_java_script_result_callback_t* self, +- const cef_string_t* result) { ++ struct _cef_value_t* result) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING +@@ -29,14 +30,14 @@ void CEF_CALLBACK java_script_result_callback_on_java_script_exe_result( + DCHECK(self); + if (!self) + return; +- // Verify param: result; type: string_byref_const ++ // Verify param: result; type: refptr_diff + DCHECK(result); + if (!result) + return; + + // Execute + CefJavaScriptResultCallbackCppToC::Get(self)->OnJavaScriptExeResult( +- CefString(result)); ++ CefValueCToCpp::Wrap(result)); + } + + } // namespace +diff --git a/src/cef/libcef_dll/cpptoc/jsdialog_handler_cpptoc.cc b/src/cef/libcef_dll/cpptoc/jsdialog_handler_cpptoc.cc +index 7148a942d24..fa1277939cc +--- a/src/cef/libcef_dll/cpptoc/jsdialog_handler_cpptoc.cc ++++ b/src/cef/libcef_dll/cpptoc/jsdialog_handler_cpptoc.cc +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=93d039a400e46cc0b87bbab7a9b68b61e6dd6a66$ ++// $hash=ba963d168a68dff5cdc383349f5e71ced0bebd06$ + // + + #include "libcef_dll/cpptoc/jsdialog_handler_cpptoc.h" +@@ -72,6 +72,7 @@ jsdialog_handler_on_jsdialog(struct _cef_jsdialog_handler_t* self, + int CEF_CALLBACK + jsdialog_handler_on_before_unload_dialog(struct _cef_jsdialog_handler_t* self, + cef_browser_t* browser, ++ const cef_string_t* url, + const cef_string_t* message_text, + int is_reload, + cef_jsdialog_callback_t* callback) { +@@ -86,6 +87,10 @@ jsdialog_handler_on_before_unload_dialog(struct _cef_jsdialog_handler_t* self, + DCHECK(browser); + if (!browser) + return 0; ++ // Verify param: url; type: string_byref_const ++ DCHECK(url); ++ if (!url) ++ return 0; + // Verify param: callback; type: refptr_diff + DCHECK(callback); + if (!callback) +@@ -94,7 +99,7 @@ jsdialog_handler_on_before_unload_dialog(struct _cef_jsdialog_handler_t* self, + + // Execute + bool _retval = CefJSDialogHandlerCppToC::Get(self)->OnBeforeUnloadDialog( +- CefBrowserCToCpp::Wrap(browser), CefString(message_text), ++ CefBrowserCToCpp::Wrap(browser), CefString(url), CefString(message_text), + is_reload ? true : false, CefJSDialogCallbackCToCpp::Wrap(callback)); + + // Return type: bool +diff --git a/src/cef/libcef_dll/cpptoc/life_span_handler_cpptoc.cc b/src/cef/libcef_dll/cpptoc/life_span_handler_cpptoc.cc +index ed436d9124b..fdea933033d +--- a/src/cef/libcef_dll/cpptoc/life_span_handler_cpptoc.cc ++++ b/src/cef/libcef_dll/cpptoc/life_span_handler_cpptoc.cc +@@ -9,12 +9,13 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=402f069391e367a81c76fc24b1081e713acabcae$ ++// $hash=41a83a28a4e40cf71a5a65a2b1ad51af98c38283$ + // + + #include "libcef_dll/cpptoc/life_span_handler_cpptoc.h" + #include "libcef_dll/cpptoc/client_cpptoc.h" + #include "libcef_dll/ctocpp/browser_ctocpp.h" ++#include "libcef_dll/ctocpp/callback_ctocpp.h" + #include "libcef_dll/ctocpp/dictionary_value_ctocpp.h" + #include "libcef_dll/ctocpp/frame_ctocpp.h" + #include "libcef_dll/shutdown_checker.h" +@@ -151,7 +152,8 @@ int CEF_CALLBACK life_span_handler_on_pre_before_popup( + cef_frame_t* frame, + const cef_string_t* target_url, + cef_window_open_disposition_t target_disposition, +- int user_gesture) { ++ int user_gesture, ++ cef_callback_t* callback) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING +@@ -167,12 +169,17 @@ int CEF_CALLBACK life_span_handler_on_pre_before_popup( + DCHECK(frame); + if (!frame) + return 0; ++ // Verify param: callback; type: refptr_diff ++ DCHECK(callback); ++ if (!callback) ++ return 0; + // Unverified params: target_url + + // Execute + bool _retval = CefLifeSpanHandlerCppToC::Get(self)->OnPreBeforePopup( + CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), +- CefString(target_url), target_disposition, user_gesture ? true : false); ++ CefString(target_url), target_disposition, user_gesture ? true : false, ++ CefCallbackCToCpp::Wrap(callback)); + + // Return type: bool + return _retval; +diff --git a/src/cef/libcef_dll/cpptoc/load_handler_cpptoc.cc b/src/cef/libcef_dll/cpptoc/load_handler_cpptoc.cc +index d27985a6a2c..2cf14225d3e +--- a/src/cef/libcef_dll/cpptoc/load_handler_cpptoc.cc ++++ b/src/cef/libcef_dll/cpptoc/load_handler_cpptoc.cc +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=c0c0bf119990d7ce088a2c9c7fc0fc4a0a378460$ ++// $hash=f1ffcd166d591807cd34edcbcc700d09bb11e0a5$ + // + + #include "libcef_dll/cpptoc/load_handler_cpptoc.h" +@@ -269,6 +269,23 @@ load_handler_on_data_resubmission(struct _cef_load_handler_t* self, + CefBrowserCToCpp::Wrap(browser), CefCallbackCToCpp::Wrap(callback)); + } + ++void CEF_CALLBACK ++load_handler_on_first_contentful_paint(struct _cef_load_handler_t* self, ++ long navigationStartTick, ++ long firstContentfulPaintMs) { ++ shutdown_checker::AssertNotShutdown(); ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ DCHECK(self); ++ if (!self) ++ return; ++ ++ // Execute ++ CefLoadHandlerCppToC::Get(self)->OnFirstContentfulPaint( ++ navigationStartTick, firstContentfulPaintMs); ++} ++ + } // namespace + + // CONSTRUCTOR - Do not edit by hand. +@@ -285,6 +302,8 @@ CefLoadHandlerCppToC::CefLoadHandlerCppToC() { + load_handler_on_refresh_accessed_history; + GetStruct()->on_page_visible = load_handler_on_page_visible; + GetStruct()->on_data_resubmission = load_handler_on_data_resubmission; ++ GetStruct()->on_first_contentful_paint = ++ load_handler_on_first_contentful_paint; + } + + // DESTRUCTOR - Do not edit by hand. +diff --git a/src/cef/libcef_dll/cpptoc/media_handler_cpptoc.cc b/src/cef/libcef_dll/cpptoc/media_handler_cpptoc.cc +new file mode 100644 +index 00000000000..3c3fe6e6dce +--- /dev/null ++++ b/src/cef/libcef_dll/cpptoc/media_handler_cpptoc.cc +@@ -0,0 +1,72 @@ ++// Copyright (c) 2023 The Chromium Embedded Framework Authors. All rights ++// reserved. Use of this source code is governed by a BSD-style license that ++// can be found in the LICENSE file. ++// ++// --------------------------------------------------------------------------- ++// ++// This file was generated by the CEF translator tool. If making changes by ++// hand only do so within the body of existing method and function ++// implementations. See the translator.README.txt file in the tools directory ++// for more information. ++// ++// $hash=2dcdc10f6a076e7300650e5bb427fbec9e42fc7e$ ++// ++ ++#include "libcef_dll/cpptoc/media_handler_cpptoc.h" ++#include "libcef_dll/ctocpp/browser_ctocpp.h" ++#include "libcef_dll/shutdown_checker.h" ++ ++namespace { ++ ++// MEMBER FUNCTIONS - Body may be edited by hand. ++ ++void CEF_CALLBACK ++media_handler_on_audio_state_changed(struct _cef_media_handler_t* self, ++ cef_browser_t* browser, ++ int audible) { ++ shutdown_checker::AssertNotShutdown(); ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ DCHECK(self); ++ if (!self) ++ return; ++ // Verify param: browser; type: refptr_diff ++ DCHECK(browser); ++ if (!browser) ++ return; ++ ++ // Execute ++ CefMediaHandlerCppToC::Get(self)->OnAudioStateChanged( ++ CefBrowserCToCpp::Wrap(browser), audible ? true : false); ++} ++ ++} // namespace ++ ++// CONSTRUCTOR - Do not edit by hand. ++ ++CefMediaHandlerCppToC::CefMediaHandlerCppToC() { ++ GetStruct()->on_audio_state_changed = media_handler_on_audio_state_changed; ++} ++ ++// DESTRUCTOR - Do not edit by hand. ++ ++CefMediaHandlerCppToC::~CefMediaHandlerCppToC() { ++ shutdown_checker::AssertNotShutdown(); ++} ++ ++template <> ++CefRefPtr CefCppToCRefCounted< ++ CefMediaHandlerCppToC, ++ CefMediaHandler, ++ cef_media_handler_t>::UnwrapDerived(CefWrapperType type, ++ cef_media_handler_t* s) { ++ NOTREACHED() << "Unexpected class type: " << type; ++ return nullptr; ++} ++ ++template <> ++CefWrapperType CefCppToCRefCounted::kWrapperType = ++ WT_MEDIA_HANDLER; +diff --git a/src/cef/libcef_dll/cpptoc/media_handler_cpptoc.h b/src/cef/libcef_dll/cpptoc/media_handler_cpptoc.h +new file mode 100644 +index 00000000000..c58b236b7a0 +--- /dev/null ++++ b/src/cef/libcef_dll/cpptoc/media_handler_cpptoc.h +@@ -0,0 +1,37 @@ ++// Copyright (c) 2023 The Chromium Embedded Framework Authors. All rights ++// reserved. Use of this source code is governed by a BSD-style license that ++// can be found in the LICENSE file. ++// ++// --------------------------------------------------------------------------- ++// ++// This file was generated by the CEF translator tool. If making changes by ++// hand only do so within the body of existing method and function ++// implementations. See the translator.README.txt file in the tools directory ++// for more information. ++// ++// $hash=b746efc1ae26c0a1f481d010b321817e5bf3f21f$ ++// ++ ++#ifndef CEF_LIBCEF_DLL_CPPTOC_MEDIA_HANDLER_CPPTOC_H_ ++#define CEF_LIBCEF_DLL_CPPTOC_MEDIA_HANDLER_CPPTOC_H_ ++#pragma once ++ ++#if !defined(WRAPPING_CEF_SHARED) ++#error This file can be included wrapper-side only ++#endif ++ ++#include "include/capi/cef_media_handler_capi.h" ++#include "include/cef_media_handler.h" ++#include "libcef_dll/cpptoc/cpptoc_ref_counted.h" ++ ++// Wrap a C++ class with a C structure. ++// This class may be instantiated and accessed wrapper-side only. ++class CefMediaHandlerCppToC : public CefCppToCRefCounted { ++ public: ++ CefMediaHandlerCppToC(); ++ virtual ~CefMediaHandlerCppToC(); ++}; ++ ++#endif // CEF_LIBCEF_DLL_CPPTOC_MEDIA_HANDLER_CPPTOC_H_ +diff --git a/src/cef/libcef_dll/cpptoc/render_handler_cpptoc.cc b/src/cef/libcef_dll/cpptoc/render_handler_cpptoc.cc +index 4add57745a8..01c3f4014aa +--- a/src/cef/libcef_dll/cpptoc/render_handler_cpptoc.cc ++++ b/src/cef/libcef_dll/cpptoc/render_handler_cpptoc.cc +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=5da07c9f36d3f52ef73ea85ebd73fecb31838536$ ++// $hash=1773b69c774a077f260546ab48b5a78af79c76ec$ + // + + #include "libcef_dll/cpptoc/render_handler_cpptoc.h" +@@ -598,6 +598,32 @@ render_handler_on_text_selection_changed(struct _cef_render_handler_t* self, + selected_rangeVal); + } + ++void CEF_CALLBACK ++render_handler_on_selection_changed(struct _cef_render_handler_t* self, ++ cef_browser_t* browser, ++ const cef_string_t* text, ++ const cef_range_t* selected_range) { ++ shutdown_checker::AssertNotShutdown(); ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ DCHECK(self); ++ if (!self) ++ return; ++ // Verify param: browser; type: refptr_diff ++ DCHECK(browser); ++ if (!browser) ++ return; ++ // Unverified params: text, selected_range ++ ++ // Translate param: selected_range; type: simple_byref_const ++ CefRange selected_rangeVal = selected_range ? *selected_range : CefRange(); ++ ++ // Execute ++ CefRenderHandlerCppToC::Get(self)->OnSelectionChanged( ++ CefBrowserCToCpp::Wrap(browser), CefString(text), selected_rangeVal); ++} ++ + void CEF_CALLBACK + render_handler_on_virtual_keyboard_requested(struct _cef_render_handler_t* self, + cef_browser_t* browser, +@@ -621,6 +647,62 @@ render_handler_on_virtual_keyboard_requested(struct _cef_render_handler_t* self, + show_keyboard ? true : false); + } + ++void CEF_CALLBACK ++render_handler_on_cursor_update(struct _cef_render_handler_t* self, ++ cef_browser_t* browser, ++ const cef_rect_t* rect) { ++ shutdown_checker::AssertNotShutdown(); ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ DCHECK(self); ++ if (!self) ++ return; ++ // Verify param: browser; type: refptr_diff ++ DCHECK(browser); ++ if (!browser) ++ return; ++ // Verify param: rect; type: simple_byref_const ++ DCHECK(rect); ++ if (!rect) ++ return; ++ ++ // Translate param: rect; type: simple_byref_const ++ CefRect rectVal = rect ? *rect : CefRect(); ++ ++ // Execute ++ CefRenderHandlerCppToC::Get(self)->OnCursorUpdate( ++ CefBrowserCToCpp::Wrap(browser), rectVal); ++} ++ ++void CEF_CALLBACK render_handler_on_complete_swap_with_new_size( ++ struct _cef_render_handler_t* self) { ++ shutdown_checker::AssertNotShutdown(); ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ DCHECK(self); ++ if (!self) ++ return; ++ ++ // Execute ++ CefRenderHandlerCppToC::Get(self)->OnCompleteSwapWithNewSize(); ++} ++ ++void CEF_CALLBACK ++render_handler_on_resize_not_work(struct _cef_render_handler_t* self) { ++ shutdown_checker::AssertNotShutdown(); ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ DCHECK(self); ++ if (!self) ++ return; ++ ++ // Execute ++ CefRenderHandlerCppToC::Get(self)->OnResizeNotWork(); ++} ++ + } // namespace + + // CONSTRUCTOR - Do not edit by hand. +@@ -650,8 +732,13 @@ CefRenderHandlerCppToC::CefRenderHandlerCppToC() { + render_handler_on_ime_composition_range_changed; + GetStruct()->on_text_selection_changed = + render_handler_on_text_selection_changed; ++ GetStruct()->on_selection_changed = render_handler_on_selection_changed; + GetStruct()->on_virtual_keyboard_requested = + render_handler_on_virtual_keyboard_requested; ++ GetStruct()->on_cursor_update = render_handler_on_cursor_update; ++ GetStruct()->on_complete_swap_with_new_size = ++ render_handler_on_complete_swap_with_new_size; ++ GetStruct()->on_resize_not_work = render_handler_on_resize_not_work; + } + + // DESTRUCTOR - Do not edit by hand. +diff --git a/src/cef/libcef_dll/cpptoc/request_cpptoc.cc b/src/cef/libcef_dll/cpptoc/request_cpptoc.cc +index 9086c22b3d0..9ab676d1ed6 +--- a/src/cef/libcef_dll/cpptoc/request_cpptoc.cc ++++ b/src/cef/libcef_dll/cpptoc/request_cpptoc.cc +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=4f55af31ee0cf2bde8f353e26283210430f2d871$ ++// $hash=8e59e7bde1fd99b84669621b2516f7f883e7eacd$ + // + + #include "libcef_dll/cpptoc/request_cpptoc.h" +@@ -402,6 +402,20 @@ uint64 CEF_CALLBACK request_get_identifier(struct _cef_request_t* self) { + return _retval; + } + ++int CEF_CALLBACK request_is_main_frame(struct _cef_request_t* self) { ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ DCHECK(self); ++ if (!self) ++ return 0; ++ ++ // Execute ++ bool _retval = CefRequestCppToC::Get(self)->IsMainFrame(); ++ ++ // Return type: bool ++ return _retval; ++} ++ + } // namespace + + // CONSTRUCTOR - Do not edit by hand. +@@ -431,6 +445,7 @@ CefRequestCppToC::CefRequestCppToC() { + GetStruct()->get_resource_type = request_get_resource_type; + GetStruct()->get_transition_type = request_get_transition_type; + GetStruct()->get_identifier = request_get_identifier; ++ GetStruct()->is_main_frame = request_is_main_frame; + } + + // DESTRUCTOR - Do not edit by hand. +diff --git a/src/cef/libcef_dll/ctocpp/browser_ctocpp.cc b/src/cef/libcef_dll/ctocpp/browser_ctocpp.cc +index a9bdc2a5571..f24a9b29137 +--- a/src/cef/libcef_dll/ctocpp/browser_ctocpp.cc ++++ b/src/cef/libcef_dll/ctocpp/browser_ctocpp.cc +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=ab991c66f7028ebb53acbd5cf350c89a880f4383$ ++// $hash=cfa8ef3e1c77142d85453c85aa2327479d2f1a57$ + // + + #include "libcef_dll/ctocpp/browser_ctocpp.h" +@@ -211,6 +211,35 @@ NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::ReloadOriginalUrl() { + _struct->reload_original_url(_struct); + } + ++NO_SANITIZE("cfi-icall") void CefBrowserCToCpp::SelectAndCopy() { ++ shutdown_checker::AssertNotShutdown(); ++ ++ cef_browser_t* _struct = GetStruct(); ++ if (CEF_MEMBER_MISSING(_struct, select_and_copy)) ++ return; ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ // Execute ++ _struct->select_and_copy(_struct); ++} ++ ++NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::ShouldShowFreeCopy() { ++ shutdown_checker::AssertNotShutdown(); ++ ++ cef_browser_t* _struct = GetStruct(); ++ if (CEF_MEMBER_MISSING(_struct, should_show_free_copy)) ++ return false; ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ // Execute ++ int _retval = _struct->should_show_free_copy(_struct); ++ ++ // Return type: bool ++ return _retval ? true : false; ++} ++ + NO_SANITIZE("cfi-icall") + void CefBrowserCToCpp::SetBrowserUserAgentString(const CefString& user_agent) { + shutdown_checker::AssertNotShutdown(); +@@ -518,6 +547,52 @@ NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::ShouldShowLoadingUI() { + return _retval ? true : false; + } + ++NO_SANITIZE("cfi-icall") ++void CefBrowserCToCpp::SetForceEnableZoom(bool forceEnableZoom) { ++ shutdown_checker::AssertNotShutdown(); ++ ++ cef_browser_t* _struct = GetStruct(); ++ if (CEF_MEMBER_MISSING(_struct, set_force_enable_zoom)) ++ return; ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ // Execute ++ _struct->set_force_enable_zoom(_struct, forceEnableZoom); ++} ++ ++NO_SANITIZE("cfi-icall") bool CefBrowserCToCpp::GetForceEnableZoom() { ++ shutdown_checker::AssertNotShutdown(); ++ ++ cef_browser_t* _struct = GetStruct(); ++ if (CEF_MEMBER_MISSING(_struct, get_force_enable_zoom)) ++ return false; ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ // Execute ++ int _retval = _struct->get_force_enable_zoom(_struct); ++ ++ // Return type: bool ++ return _retval ? true : false; ++} ++ ++NO_SANITIZE("cfi-icall") ++void CefBrowserCToCpp::SetEnableBlankTargetPopupIntercept( ++ bool enableBlankTargetPopup) { ++ shutdown_checker::AssertNotShutdown(); ++ ++ cef_browser_t* _struct = GetStruct(); ++ if (CEF_MEMBER_MISSING(_struct, set_enable_blank_target_popup_intercept)) ++ return; ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ // Execute ++ _struct->set_enable_blank_target_popup_intercept(_struct, ++ enableBlankTargetPopup); ++} ++ + // CONSTRUCTOR - Do not edit by hand. + + CefBrowserCToCpp::CefBrowserCToCpp() {} +diff --git a/src/cef/libcef_dll/ctocpp/browser_ctocpp.h b/src/cef/libcef_dll/ctocpp/browser_ctocpp.h +index f5981114720..f8c82d8fad4 +--- a/src/cef/libcef_dll/ctocpp/browser_ctocpp.h ++++ b/src/cef/libcef_dll/ctocpp/browser_ctocpp.h +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=66aac50bedd02f309bb3715b0d4cafb0cd824c4d$ ++// $hash=939b4755df9590d5eac90c86d8a53abbf3335de3$ + // + + #ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_CTOCPP_H_ +@@ -49,6 +49,8 @@ class CefBrowserCToCpp + void Reload() override; + void ReloadIgnoreCache() override; + void ReloadOriginalUrl() override; ++ void SelectAndCopy() override; ++ bool ShouldShowFreeCopy() override; + void SetBrowserUserAgentString(const CefString& user_agent) override; + void StopLoad() override; + int GetIdentifier() override; +@@ -66,6 +68,9 @@ class CefBrowserCToCpp + override; + CefRefPtr GetGeolocationPermissions() override; + bool ShouldShowLoadingUI() override; ++ void SetForceEnableZoom(bool forceEnableZoom) override; ++ bool GetForceEnableZoom() override; ++ void SetEnableBlankTargetPopupIntercept(bool enableBlankTargetPopup) override; + }; + + #endif // CEF_LIBCEF_DLL_CTOCPP_BROWSER_CTOCPP_H_ +diff --git a/src/cef/libcef_dll/ctocpp/browser_host_ctocpp.cc b/src/cef/libcef_dll/ctocpp/browser_host_ctocpp.cc +index 188871e22d0..e1c40c98ec2 +--- a/src/cef/libcef_dll/ctocpp/browser_host_ctocpp.cc ++++ b/src/cef/libcef_dll/ctocpp/browser_host_ctocpp.cc +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=4912cb91f0c5d4e550ab1441c8848477bc787a11$ ++// $hash=7d903e02f8fcf3326ea75b956aa5e7c20ce2fd46$ + // + + #include "libcef_dll/ctocpp/browser_host_ctocpp.h" +@@ -1585,10 +1585,39 @@ NO_SANITIZE("cfi-icall") bool CefBrowserHostCToCpp::IsAudioMuted() { + return _retval ? true : false; + } + ++NO_SANITIZE("cfi-icall") ++void CefBrowserHostCToCpp::SetAudioResumeInterval(int resumeInterval) { ++ shutdown_checker::AssertNotShutdown(); ++ ++ cef_browser_host_t* _struct = GetStruct(); ++ if (CEF_MEMBER_MISSING(_struct, set_audio_resume_interval)) ++ return; ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ // Execute ++ _struct->set_audio_resume_interval(_struct, resumeInterval); ++} ++ ++NO_SANITIZE("cfi-icall") ++void CefBrowserHostCToCpp::SetAudioExclusive(bool audioExclusive) { ++ shutdown_checker::AssertNotShutdown(); ++ ++ cef_browser_host_t* _struct = GetStruct(); ++ if (CEF_MEMBER_MISSING(_struct, set_audio_exclusive)) ++ return; ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ // Execute ++ _struct->set_audio_exclusive(_struct, audioExclusive); ++} ++ + NO_SANITIZE("cfi-icall") + void CefBrowserHostCToCpp::ExecuteJavaScript( + const CefString& code, +- CefRefPtr callback) { ++ CefRefPtr callback, ++ bool extention) { + shutdown_checker::AssertNotShutdown(); + + cef_browser_host_t* _struct = GetStruct(); +@@ -1609,7 +1638,7 @@ void CefBrowserHostCToCpp::ExecuteJavaScript( + // Execute + _struct->execute_java_script( + _struct, code.GetStruct(), +- CefJavaScriptResultCallbackCppToC::Wrap(callback)); ++ CefJavaScriptResultCallbackCppToC::Wrap(callback), extention); + } + + NO_SANITIZE("cfi-icall") +@@ -1903,6 +1932,34 @@ NO_SANITIZE("cfi-icall") void CefBrowserHostCToCpp::SetCacheMode(int falg) { + _struct->set_cache_mode(_struct, falg); + } + ++NO_SANITIZE("cfi-icall") ++void CefBrowserHostCToCpp::SetShouldFrameSubmissionBeforeDraw(bool should) { ++ shutdown_checker::AssertNotShutdown(); ++ ++ cef_browser_host_t* _struct = GetStruct(); ++ if (CEF_MEMBER_MISSING(_struct, set_should_frame_submission_before_draw)) ++ return; ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ // Execute ++ _struct->set_should_frame_submission_before_draw(_struct, should); ++} ++ ++NO_SANITIZE("cfi-icall") ++void CefBrowserHostCToCpp::ZoomBy(float delta, float width, float height) { ++ shutdown_checker::AssertNotShutdown(); ++ ++ cef_browser_host_t* _struct = GetStruct(); ++ if (CEF_MEMBER_MISSING(_struct, zoom_by)) ++ return; ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ // Execute ++ _struct->zoom_by(_struct, delta, width, height); ++} ++ + // CONSTRUCTOR - Do not edit by hand. + + CefBrowserHostCToCpp::CefBrowserHostCToCpp() {} +diff --git a/src/cef/libcef_dll/ctocpp/browser_host_ctocpp.h b/src/cef/libcef_dll/ctocpp/browser_host_ctocpp.h +index f75f810a9f1..60afdd17131 +--- a/src/cef/libcef_dll/ctocpp/browser_host_ctocpp.h ++++ b/src/cef/libcef_dll/ctocpp/browser_host_ctocpp.h +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=29c3bfce4a45f38ec3fd21096e13addeb83f6310$ ++// $hash=43abfd446fd6c12797d1f1489ccbe7d1011508b7$ + // + + #ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_HOST_CTOCPP_H_ +@@ -174,9 +174,11 @@ class CefBrowserHostCToCpp : public CefCToCppRefCounted callback) override; ++ void SetAudioResumeInterval(int resumeInterval) override; ++ void SetAudioExclusive(bool audioExclusive) override; ++ void ExecuteJavaScript(const CefString& code, ++ CefRefPtr callback, ++ bool extention) override; + void SetNativeWindow(cef_native_window_t window) override; + void SetWebDebuggingAccess(bool isEnableDebug) override; + bool GetWebDebuggingAccess() override; +@@ -196,6 +198,8 @@ class CefBrowserHostCToCpp : public CefCToCppRefCounted CefClientCToCpp::GetRequestHandler() { + return CefRequestHandlerCToCpp::Wrap(_retval); + } + ++NO_SANITIZE("cfi-icall") ++CefRefPtr CefClientCToCpp::GetMediaHandler() { ++ cef_client_t* _struct = GetStruct(); ++ if (CEF_MEMBER_MISSING(_struct, get_media_handler)) ++ return nullptr; ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ // Execute ++ cef_media_handler_t* _retval = _struct->get_media_handler(_struct); ++ ++ // Return type: refptr_same ++ return CefMediaHandlerCToCpp::Wrap(_retval); ++} ++ + NO_SANITIZE("cfi-icall") + CefRefPtr CefClientCToCpp::GetPermissionRequest() { + cef_client_t* _struct = GetStruct(); +diff --git a/src/cef/libcef_dll/ctocpp/client_ctocpp.h b/src/cef/libcef_dll/ctocpp/client_ctocpp.h +index 37f3eb67cc0..1ebe3303ca1 +--- a/src/cef/libcef_dll/ctocpp/client_ctocpp.h ++++ b/src/cef/libcef_dll/ctocpp/client_ctocpp.h +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=13d421c7598593f4bee5b3e62cb8aaf348a350f9$ ++// $hash=c9388b2d6e48b8298be0726e39170da862fce7aa$ + // + + #ifndef CEF_LIBCEF_DLL_CTOCPP_CLIENT_CTOCPP_H_ +@@ -49,6 +49,7 @@ class CefClientCToCpp + CefRefPtr GetPrintHandler() override; + CefRefPtr GetRenderHandler() override; + CefRefPtr GetRequestHandler() override; ++ CefRefPtr GetMediaHandler() override; + CefRefPtr GetPermissionRequest() override; + bool OnProcessMessageReceived(CefRefPtr browser, + CefRefPtr frame, +diff --git a/src/cef/libcef_dll/ctocpp/java_script_result_callback_ctocpp.cc b/src/cef/libcef_dll/ctocpp/java_script_result_callback_ctocpp.cc +index ee92ac0261b..edef652d011 +--- a/src/cef/libcef_dll/ctocpp/java_script_result_callback_ctocpp.cc ++++ b/src/cef/libcef_dll/ctocpp/java_script_result_callback_ctocpp.cc +@@ -9,17 +9,18 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=ec746fb1184b4ac8124e90ddcb226035a06bfeb2$ ++// $hash=4f1d80cb3bd00c0c9b94a9e2663f09f13474158a$ + // + + #include "libcef_dll/ctocpp/java_script_result_callback_ctocpp.h" ++#include "libcef_dll/cpptoc/value_cpptoc.h" + #include "libcef_dll/shutdown_checker.h" + + // VIRTUAL METHODS - Body may be edited by hand. + + NO_SANITIZE("cfi-icall") + void CefJavaScriptResultCallbackCToCpp::OnJavaScriptExeResult( +- const CefString& result) { ++ CefRefPtr result) { + shutdown_checker::AssertNotShutdown(); + + cef_java_script_result_callback_t* _struct = GetStruct(); +@@ -28,13 +29,13 @@ void CefJavaScriptResultCallbackCToCpp::OnJavaScriptExeResult( + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + +- // Verify param: result; type: string_byref_const +- DCHECK(!result.empty()); +- if (result.empty()) ++ // Verify param: result; type: refptr_diff ++ DCHECK(result.get()); ++ if (!result.get()) + return; + + // Execute +- _struct->on_java_script_exe_result(_struct, result.GetStruct()); ++ _struct->on_java_script_exe_result(_struct, CefValueCppToC::Wrap(result)); + } + + // CONSTRUCTOR - Do not edit by hand. +diff --git a/src/cef/libcef_dll/ctocpp/java_script_result_callback_ctocpp.h b/src/cef/libcef_dll/ctocpp/java_script_result_callback_ctocpp.h +index 6cb9bf41c40..e99022a5df8 +--- a/src/cef/libcef_dll/ctocpp/java_script_result_callback_ctocpp.h ++++ b/src/cef/libcef_dll/ctocpp/java_script_result_callback_ctocpp.h +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=17a3f0d9b77b19f01a9c147f900dc30016fa9e6e$ ++// $hash=3e43b09c02b4c9974c12ea450872d4ce0da42116$ + // + + #ifndef CEF_LIBCEF_DLL_CTOCPP_JAVA_SCRIPT_RESULT_CALLBACK_CTOCPP_H_ +@@ -37,7 +37,7 @@ class CefJavaScriptResultCallbackCToCpp + virtual ~CefJavaScriptResultCallbackCToCpp(); + + // CefJavaScriptResultCallback methods. +- void OnJavaScriptExeResult(const CefString& result) override; ++ void OnJavaScriptExeResult(CefRefPtr result) override; + }; + + #endif // CEF_LIBCEF_DLL_CTOCPP_JAVA_SCRIPT_RESULT_CALLBACK_CTOCPP_H_ +diff --git a/src/cef/libcef_dll/ctocpp/jsdialog_handler_ctocpp.cc b/src/cef/libcef_dll/ctocpp/jsdialog_handler_ctocpp.cc +index dba10ebfc9e..eaaf9c74c2b +--- a/src/cef/libcef_dll/ctocpp/jsdialog_handler_ctocpp.cc ++++ b/src/cef/libcef_dll/ctocpp/jsdialog_handler_ctocpp.cc +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=c95849f5069d934dcca81e86a11e76931582a22b$ ++// $hash=b6989ef194a6cebcb2fe9b2ba7c027081e8e79b3$ + // + + #include "libcef_dll/ctocpp/jsdialog_handler_ctocpp.h" +@@ -65,6 +65,7 @@ bool CefJSDialogHandlerCToCpp::OnJSDialog( + NO_SANITIZE("cfi-icall") + bool CefJSDialogHandlerCToCpp::OnBeforeUnloadDialog( + CefRefPtr browser, ++ const CefString& url, + const CefString& message_text, + bool is_reload, + CefRefPtr callback) { +@@ -80,6 +81,10 @@ bool CefJSDialogHandlerCToCpp::OnBeforeUnloadDialog( + DCHECK(browser.get()); + if (!browser.get()) + return false; ++ // Verify param: url; type: string_byref_const ++ DCHECK(!url.empty()); ++ if (url.empty()) ++ return false; + // Verify param: callback; type: refptr_diff + DCHECK(callback.get()); + if (!callback.get()) +@@ -88,8 +93,9 @@ bool CefJSDialogHandlerCToCpp::OnBeforeUnloadDialog( + + // Execute + int _retval = _struct->on_before_unload_dialog( +- _struct, CefBrowserCppToC::Wrap(browser), message_text.GetStruct(), +- is_reload, CefJSDialogCallbackCppToC::Wrap(callback)); ++ _struct, CefBrowserCppToC::Wrap(browser), url.GetStruct(), ++ message_text.GetStruct(), is_reload, ++ CefJSDialogCallbackCppToC::Wrap(callback)); + + // Return type: bool + return _retval ? true : false; +diff --git a/src/cef/libcef_dll/ctocpp/jsdialog_handler_ctocpp.h b/src/cef/libcef_dll/ctocpp/jsdialog_handler_ctocpp.h +index 740330b350f..6b8741ef19a +--- a/src/cef/libcef_dll/ctocpp/jsdialog_handler_ctocpp.h ++++ b/src/cef/libcef_dll/ctocpp/jsdialog_handler_ctocpp.h +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=55b3bcb925cfaf44f79c0e03fc55878d748f55ce$ ++// $hash=cdfe3bece7137f53e8b00682064f7831617a7b2f$ + // + + #ifndef CEF_LIBCEF_DLL_CTOCPP_JSDIALOG_HANDLER_CTOCPP_H_ +@@ -43,6 +43,7 @@ class CefJSDialogHandlerCToCpp + CefRefPtr callback, + bool& suppress_message) override; + bool OnBeforeUnloadDialog(CefRefPtr browser, ++ const CefString& url, + const CefString& message_text, + bool is_reload, + CefRefPtr callback) override; +diff --git a/src/cef/libcef_dll/ctocpp/life_span_handler_ctocpp.cc b/src/cef/libcef_dll/ctocpp/life_span_handler_ctocpp.cc +index 5b9fe7e624a..6bf78acf42a +--- a/src/cef/libcef_dll/ctocpp/life_span_handler_ctocpp.cc ++++ b/src/cef/libcef_dll/ctocpp/life_span_handler_ctocpp.cc +@@ -9,11 +9,12 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=873c979fdd4b48e65375437e6a70a900de50840d$ ++// $hash=138ac938523decbcb23ea3a483f7e5356ef931d9$ + // + + #include "libcef_dll/ctocpp/life_span_handler_ctocpp.h" + #include "libcef_dll/cpptoc/browser_cpptoc.h" ++#include "libcef_dll/cpptoc/callback_cpptoc.h" + #include "libcef_dll/cpptoc/dictionary_value_cpptoc.h" + #include "libcef_dll/cpptoc/frame_cpptoc.h" + #include "libcef_dll/ctocpp/client_ctocpp.h" +@@ -108,7 +109,8 @@ bool CefLifeSpanHandlerCToCpp::OnPreBeforePopup( + CefRefPtr frame, + const CefString& target_url, + WindowOpenDisposition target_disposition, +- bool user_gesture) { ++ bool user_gesture, ++ CefRefPtr callback) { + shutdown_checker::AssertNotShutdown(); + + cef_life_span_handler_t* _struct = GetStruct(); +@@ -125,12 +127,17 @@ bool CefLifeSpanHandlerCToCpp::OnPreBeforePopup( + DCHECK(frame.get()); + if (!frame.get()) + return false; ++ // Verify param: callback; type: refptr_diff ++ DCHECK(callback.get()); ++ if (!callback.get()) ++ return false; + // Unverified params: target_url + + // Execute + int _retval = _struct->on_pre_before_popup( + _struct, CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame), +- target_url.GetStruct(), target_disposition, user_gesture); ++ target_url.GetStruct(), target_disposition, user_gesture, ++ CefCallbackCppToC::Wrap(callback)); + + // Return type: bool + return _retval ? true : false; +diff --git a/src/cef/libcef_dll/ctocpp/life_span_handler_ctocpp.h b/src/cef/libcef_dll/ctocpp/life_span_handler_ctocpp.h +index 9693f44b289..095f0d8ead0 +--- a/src/cef/libcef_dll/ctocpp/life_span_handler_ctocpp.h ++++ b/src/cef/libcef_dll/ctocpp/life_span_handler_ctocpp.h +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=580b424b488c3974143484a05df444e91edfca5c$ ++// $hash=5eabdc3dbebae73e8cfb60a46d7f91a9974e6969$ + // + + #ifndef CEF_LIBCEF_DLL_CTOCPP_LIFE_SPAN_HANDLER_CTOCPP_H_ +@@ -53,7 +53,8 @@ class CefLifeSpanHandlerCToCpp + CefRefPtr frame, + const CefString& target_url, + WindowOpenDisposition target_disposition, +- bool user_gesture) override; ++ bool user_gesture, ++ CefRefPtr callback) override; + void OnAfterCreated(CefRefPtr browser) override; + bool DoClose(CefRefPtr browser) override; + void OnBeforeClose(CefRefPtr browser) override; +diff --git a/src/cef/libcef_dll/ctocpp/load_handler_ctocpp.cc b/src/cef/libcef_dll/ctocpp/load_handler_ctocpp.cc +index e0bb3339e65..107a05b213b +--- a/src/cef/libcef_dll/ctocpp/load_handler_ctocpp.cc ++++ b/src/cef/libcef_dll/ctocpp/load_handler_ctocpp.cc +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=710979924c3b6f6b6f1479dd75ed0e3c6dd02126$ ++// $hash=fa23abd5e49712096e86494af9b3654d1aef0b4f$ + // + + #include "libcef_dll/ctocpp/load_handler_ctocpp.h" +@@ -269,6 +269,22 @@ void CefLoadHandlerCToCpp::OnDataResubmission(CefRefPtr browser, + CefCallbackCppToC::Wrap(callback)); + } + ++NO_SANITIZE("cfi-icall") ++void CefLoadHandlerCToCpp::OnFirstContentfulPaint(long navigationStartTick, ++ long firstContentfulPaintMs) { ++ shutdown_checker::AssertNotShutdown(); ++ ++ cef_load_handler_t* _struct = GetStruct(); ++ if (CEF_MEMBER_MISSING(_struct, on_first_contentful_paint)) ++ return; ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ // Execute ++ _struct->on_first_contentful_paint(_struct, navigationStartTick, ++ firstContentfulPaintMs); ++} ++ + // CONSTRUCTOR - Do not edit by hand. + + CefLoadHandlerCToCpp::CefLoadHandlerCToCpp() {} +diff --git a/src/cef/libcef_dll/ctocpp/load_handler_ctocpp.h b/src/cef/libcef_dll/ctocpp/load_handler_ctocpp.h +index cc7e15c1858..9ebd2842271 +--- a/src/cef/libcef_dll/ctocpp/load_handler_ctocpp.h ++++ b/src/cef/libcef_dll/ctocpp/load_handler_ctocpp.h +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=12b88b0080727a6c6abf49b8ab17b8c18dc4e2f5$ ++// $hash=af4e0887244222b251dc40401ce0dfc6af788d90$ + // + + #ifndef CEF_LIBCEF_DLL_CTOCPP_LOAD_HANDLER_CTOCPP_H_ +@@ -67,6 +67,8 @@ class CefLoadHandlerCToCpp : public CefCToCppRefCounted browser, + CefRefPtr callback) override; ++ void OnFirstContentfulPaint(long navigationStartTick, ++ long firstContentfulPaintMs) override; + }; + + #endif // CEF_LIBCEF_DLL_CTOCPP_LOAD_HANDLER_CTOCPP_H_ +diff --git a/src/cef/libcef_dll/ctocpp/media_handler_ctocpp.cc b/src/cef/libcef_dll/ctocpp/media_handler_ctocpp.cc +new file mode 100644 +index 00000000000..29a65123d92 +--- /dev/null ++++ b/src/cef/libcef_dll/ctocpp/media_handler_ctocpp.cc +@@ -0,0 +1,66 @@ ++// Copyright (c) 2023 The Chromium Embedded Framework Authors. All rights ++// reserved. Use of this source code is governed by a BSD-style license that ++// can be found in the LICENSE file. ++// ++// --------------------------------------------------------------------------- ++// ++// This file was generated by the CEF translator tool. If making changes by ++// hand only do so within the body of existing method and function ++// implementations. See the translator.README.txt file in the tools directory ++// for more information. ++// ++// $hash=2722fa796f55add02305722393faeadcaa86bf66$ ++// ++ ++#include "libcef_dll/ctocpp/media_handler_ctocpp.h" ++#include "libcef_dll/cpptoc/browser_cpptoc.h" ++#include "libcef_dll/shutdown_checker.h" ++ ++// VIRTUAL METHODS - Body may be edited by hand. ++ ++NO_SANITIZE("cfi-icall") ++void CefMediaHandlerCToCpp::OnAudioStateChanged(CefRefPtr browser, ++ bool audible) { ++ shutdown_checker::AssertNotShutdown(); ++ ++ cef_media_handler_t* _struct = GetStruct(); ++ if (CEF_MEMBER_MISSING(_struct, on_audio_state_changed)) ++ return; ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ // Verify param: browser; type: refptr_diff ++ DCHECK(browser.get()); ++ if (!browser.get()) ++ return; ++ ++ // Execute ++ _struct->on_audio_state_changed(_struct, CefBrowserCppToC::Wrap(browser), ++ audible); ++} ++ ++// CONSTRUCTOR - Do not edit by hand. ++ ++CefMediaHandlerCToCpp::CefMediaHandlerCToCpp() {} ++ ++// DESTRUCTOR - Do not edit by hand. ++ ++CefMediaHandlerCToCpp::~CefMediaHandlerCToCpp() { ++ shutdown_checker::AssertNotShutdown(); ++} ++ ++template <> ++cef_media_handler_t* ++CefCToCppRefCounted::UnwrapDerived(CefWrapperType type, ++ CefMediaHandler* c) { ++ NOTREACHED() << "Unexpected class type: " << type; ++ return nullptr; ++} ++ ++template <> ++CefWrapperType CefCToCppRefCounted::kWrapperType = ++ WT_MEDIA_HANDLER; +diff --git a/src/cef/libcef_dll/ctocpp/media_handler_ctocpp.h b/src/cef/libcef_dll/ctocpp/media_handler_ctocpp.h +new file mode 100644 +index 00000000000..a30076c08c0 +--- /dev/null ++++ b/src/cef/libcef_dll/ctocpp/media_handler_ctocpp.h +@@ -0,0 +1,41 @@ ++// Copyright (c) 2023 The Chromium Embedded Framework Authors. All rights ++// reserved. Use of this source code is governed by a BSD-style license that ++// can be found in the LICENSE file. ++// ++// --------------------------------------------------------------------------- ++// ++// This file was generated by the CEF translator tool. If making changes by ++// hand only do so within the body of existing method and function ++// implementations. See the translator.README.txt file in the tools directory ++// for more information. ++// ++// $hash=b3b158709709751c908d88949d4d83081e2ae1f0$ ++// ++ ++#ifndef CEF_LIBCEF_DLL_CTOCPP_MEDIA_HANDLER_CTOCPP_H_ ++#define CEF_LIBCEF_DLL_CTOCPP_MEDIA_HANDLER_CTOCPP_H_ ++#pragma once ++ ++#if !defined(BUILDING_CEF_SHARED) ++#error This file can be included DLL-side only ++#endif ++ ++#include "include/capi/cef_media_handler_capi.h" ++#include "include/cef_media_handler.h" ++#include "libcef_dll/ctocpp/ctocpp_ref_counted.h" ++ ++// Wrap a C structure with a C++ class. ++// This class may be instantiated and accessed DLL-side only. ++class CefMediaHandlerCToCpp : public CefCToCppRefCounted { ++ public: ++ CefMediaHandlerCToCpp(); ++ virtual ~CefMediaHandlerCToCpp(); ++ ++ // CefMediaHandler methods. ++ void OnAudioStateChanged(CefRefPtr browser, ++ bool audible) override; ++}; ++ ++#endif // CEF_LIBCEF_DLL_CTOCPP_MEDIA_HANDLER_CTOCPP_H_ +diff --git a/src/cef/libcef_dll/ctocpp/render_handler_ctocpp.cc b/src/cef/libcef_dll/ctocpp/render_handler_ctocpp.cc +index 52053ab91a1..ead6b78974f +--- a/src/cef/libcef_dll/ctocpp/render_handler_ctocpp.cc ++++ b/src/cef/libcef_dll/ctocpp/render_handler_ctocpp.cc +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=f2f817e11a4ff708bf3e1be68b75527681387d39$ ++// $hash=d896b6f1e93865ab98eaf342886e45d6aa380da2$ + // + + #include "libcef_dll/ctocpp/render_handler_ctocpp.h" +@@ -494,6 +494,30 @@ void CefRenderHandlerCToCpp::OnTextSelectionChanged( + &selected_range); + } + ++NO_SANITIZE("cfi-icall") ++void CefRenderHandlerCToCpp::OnSelectionChanged( ++ CefRefPtr browser, ++ const CefString& text, ++ const CefRange& selected_range) { ++ shutdown_checker::AssertNotShutdown(); ++ ++ cef_render_handler_t* _struct = GetStruct(); ++ if (CEF_MEMBER_MISSING(_struct, on_selection_changed)) ++ return; ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ // Verify param: browser; type: refptr_diff ++ DCHECK(browser.get()); ++ if (!browser.get()) ++ return; ++ // Unverified params: text, selected_range ++ ++ // Execute ++ _struct->on_selection_changed(_struct, CefBrowserCppToC::Wrap(browser), ++ text.GetStruct(), &selected_range); ++} ++ + NO_SANITIZE("cfi-icall") + void CefRenderHandlerCToCpp::OnVirtualKeyboardRequested( + CefRefPtr browser, +@@ -517,6 +541,53 @@ void CefRenderHandlerCToCpp::OnVirtualKeyboardRequested( + _struct, CefBrowserCppToC::Wrap(browser), input_mode, show_keyboard); + } + ++NO_SANITIZE("cfi-icall") ++void CefRenderHandlerCToCpp::OnCursorUpdate(CefRefPtr browser, ++ const CefRect& rect) { ++ shutdown_checker::AssertNotShutdown(); ++ ++ cef_render_handler_t* _struct = GetStruct(); ++ if (CEF_MEMBER_MISSING(_struct, on_cursor_update)) ++ return; ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ // Verify param: browser; type: refptr_diff ++ DCHECK(browser.get()); ++ if (!browser.get()) ++ return; ++ ++ // Execute ++ _struct->on_cursor_update(_struct, CefBrowserCppToC::Wrap(browser), &rect); ++} ++ ++NO_SANITIZE("cfi-icall") ++void CefRenderHandlerCToCpp::OnCompleteSwapWithNewSize() { ++ shutdown_checker::AssertNotShutdown(); ++ ++ cef_render_handler_t* _struct = GetStruct(); ++ if (CEF_MEMBER_MISSING(_struct, on_complete_swap_with_new_size)) ++ return; ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ // Execute ++ _struct->on_complete_swap_with_new_size(_struct); ++} ++ ++NO_SANITIZE("cfi-icall") void CefRenderHandlerCToCpp::OnResizeNotWork() { ++ shutdown_checker::AssertNotShutdown(); ++ ++ cef_render_handler_t* _struct = GetStruct(); ++ if (CEF_MEMBER_MISSING(_struct, on_resize_not_work)) ++ return; ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ // Execute ++ _struct->on_resize_not_work(_struct); ++} ++ + // CONSTRUCTOR - Do not edit by hand. + + CefRenderHandlerCToCpp::CefRenderHandlerCToCpp() {} + diff --git a/src/cef/libcef_dll/ctocpp/render_handler_ctocpp.h b/src/cef/libcef_dll/ctocpp/render_handler_ctocpp.h +index 4b830fb9b0b..54d799715c7 +--- a/src/cef/libcef_dll/ctocpp/render_handler_ctocpp.h ++++ b/src/cef/libcef_dll/ctocpp/render_handler_ctocpp.h +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=db2cc3ecd0fa1658ae8ce19b1347175a1902daec$ ++// $hash=216f123c963b236b77fef8911c6044cbe6a66acd$ + // + + #ifndef CEF_LIBCEF_DLL_CTOCPP_RENDER_HANDLER_CTOCPP_H_ +@@ -86,9 +86,16 @@ class CefRenderHandlerCToCpp + void OnTextSelectionChanged(CefRefPtr browser, + const CefString& selected_text, + const CefRange& selected_range) override; ++ void OnSelectionChanged(CefRefPtr browser, ++ const CefString& text, ++ const CefRange& selected_range) override; + void OnVirtualKeyboardRequested(CefRefPtr browser, + TextInputMode input_mode, + bool show_keyboard) override; ++ void OnCursorUpdate(CefRefPtr browser, ++ const CefRect& rect) override; ++ void OnCompleteSwapWithNewSize() override; ++ void OnResizeNotWork() override; + }; + + #endif // CEF_LIBCEF_DLL_CTOCPP_RENDER_HANDLER_CTOCPP_H_ +diff --git a/src/cef/libcef_dll/ctocpp/request_ctocpp.cc b/src/cef/libcef_dll/ctocpp/request_ctocpp.cc +index 85b7fb9ceab..7a166f33c33 +--- a/src/cef/libcef_dll/ctocpp/request_ctocpp.cc ++++ b/src/cef/libcef_dll/ctocpp/request_ctocpp.cc +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=0cd351db644cd18b1cde6adf5355d2ceff949827$ ++// $hash=da9f4bfe6e4d4a75f3f4ccc672777467bcf52691$ + // + + #include "libcef_dll/ctocpp/request_ctocpp.h" +@@ -413,6 +413,20 @@ NO_SANITIZE("cfi-icall") uint64 CefRequestCToCpp::GetIdentifier() { + return _retval; + } + ++NO_SANITIZE("cfi-icall") bool CefRequestCToCpp::IsMainFrame() { ++ cef_request_t* _struct = GetStruct(); ++ if (CEF_MEMBER_MISSING(_struct, is_main_frame)) ++ return false; ++ ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ // Execute ++ int _retval = _struct->is_main_frame(_struct); ++ ++ // Return type: bool ++ return _retval ? true : false; ++} ++ + // CONSTRUCTOR - Do not edit by hand. + + CefRequestCToCpp::CefRequestCToCpp() {} +diff --git a/src/cef/libcef_dll/ctocpp/request_ctocpp.h b/src/cef/libcef_dll/ctocpp/request_ctocpp.h +index 7b3b6654250..dcd220f1c93 +--- a/src/cef/libcef_dll/ctocpp/request_ctocpp.h ++++ b/src/cef/libcef_dll/ctocpp/request_ctocpp.h +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=7e87acb36c494058615248f36c7536368d3d5fb5$ ++// $hash=677073805c6a87f896745311d30a7832768d66b0$ + // + + #ifndef CEF_LIBCEF_DLL_CTOCPP_REQUEST_CTOCPP_H_ +@@ -61,6 +61,7 @@ class CefRequestCToCpp + ResourceType GetResourceType() override; + TransitionType GetTransitionType() override; + uint64 GetIdentifier() override; ++ bool IsMainFrame() override; + }; + + #endif // CEF_LIBCEF_DLL_CTOCPP_REQUEST_CTOCPP_H_ +diff --git a/src/cef/libcef_dll/libcef_dll.cc b/src/cef/libcef_dll/libcef_dll.cc +index 74f9e4cd89e..fd2af147b0b +--- a/src/cef/libcef_dll/libcef_dll.cc ++++ b/src/cef/libcef_dll/libcef_dll.cc +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=b4f718eaa15556b762af4f0e6dbc1b55c8e2d83f$ ++// $hash=787cf2fc4d59195e39c7517fbec56c20e4415e6d$ + // + + #include "include/capi/cef_app_capi.h" +@@ -159,6 +159,13 @@ CEF_EXPORT void cef_enable_highdpi_support() { + CefEnableHighDPISupport(); + } + ++CEF_EXPORT void cef_apply_http_dns() { ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ // Execute ++ CefApplyHttpDns(); ++} ++ + CEF_EXPORT int cef_crash_reporting_enabled() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + +diff --git a/src/cef/libcef_dll/wrapper/libcef_dll_dylib.cc b/src/cef/libcef_dll/wrapper/libcef_dll_dylib.cc +index b7c094e621f..c01e35489d3 +--- a/src/cef/libcef_dll/wrapper/libcef_dll_dylib.cc ++++ b/src/cef/libcef_dll/wrapper/libcef_dll_dylib.cc +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=577c6334f41f1be591969c7789081b002e86b91c$ ++// $hash=c9224d945947dbe5cbaf9ee8adedad755621e62f$ + // + + #include +@@ -100,6 +100,7 @@ typedef void (*cef_run_message_loop_ptr)(); + typedef void (*cef_quit_message_loop_ptr)(); + typedef void (*cef_set_osmodal_loop_ptr)(int); + typedef void (*cef_enable_highdpi_support_ptr)(); ++typedef void (*cef_apply_http_dns_ptr)(); + typedef int (*cef_crash_reporting_enabled_ptr)(); + typedef void (*cef_set_crash_key_value_ptr)(const cef_string_t*, + const cef_string_t*); +@@ -520,6 +521,7 @@ struct libcef_pointers { + cef_quit_message_loop_ptr cef_quit_message_loop; + cef_set_osmodal_loop_ptr cef_set_osmodal_loop; + cef_enable_highdpi_support_ptr cef_enable_highdpi_support; ++ cef_apply_http_dns_ptr cef_apply_http_dns; + cef_crash_reporting_enabled_ptr cef_crash_reporting_enabled; + cef_set_crash_key_value_ptr cef_set_crash_key_value; + cef_create_directory_ptr cef_create_directory; +@@ -736,6 +738,7 @@ int libcef_init_pointers(const char* path) { + INIT_ENTRY(cef_quit_message_loop); + INIT_ENTRY(cef_set_osmodal_loop); + INIT_ENTRY(cef_enable_highdpi_support); ++ INIT_ENTRY(cef_apply_http_dns); + INIT_ENTRY(cef_crash_reporting_enabled); + INIT_ENTRY(cef_set_crash_key_value); + INIT_ENTRY(cef_create_directory); +@@ -997,6 +1000,10 @@ NO_SANITIZE("cfi-icall") void cef_enable_highdpi_support() { + g_libcef_pointers.cef_enable_highdpi_support(); + } + ++NO_SANITIZE("cfi-icall") void cef_apply_http_dns() { ++ g_libcef_pointers.cef_apply_http_dns(); ++} ++ + NO_SANITIZE("cfi-icall") int cef_crash_reporting_enabled() { + return g_libcef_pointers.cef_crash_reporting_enabled(); + } +diff --git a/src/cef/libcef_dll/wrapper/libcef_dll_wrapper.cc b/src/cef/libcef_dll/wrapper/libcef_dll_wrapper.cc +index 4d71c68db6f..afccd7ff87d +--- a/src/cef/libcef_dll/wrapper/libcef_dll_wrapper.cc ++++ b/src/cef/libcef_dll/wrapper/libcef_dll_wrapper.cc +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=45e769535f300e227783606b108546a49d9aa953$ ++// $hash=91c7f364ad0c5a79cace6aa81d16c10933d1937b$ + // + + #include "include/capi/cef_app_capi.h" +@@ -152,6 +152,13 @@ NO_SANITIZE("cfi-icall") CEF_GLOBAL void CefEnableHighDPISupport() { + cef_enable_highdpi_support(); + } + ++NO_SANITIZE("cfi-icall") CEF_GLOBAL void CefApplyHttpDns() { ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ // Execute ++ cef_apply_http_dns(); ++} ++ + NO_SANITIZE("cfi-icall") CEF_GLOBAL bool CefCrashReportingEnabled() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + +diff --git a/src/cef/libcef_dll/wrapper_types.h b/src/cef/libcef_dll/wrapper_types.h +index 1ed052157b7..5b84673bfc7 +--- a/src/cef/libcef_dll/wrapper_types.h ++++ b/src/cef/libcef_dll/wrapper_types.h +@@ -9,7 +9,7 @@ + // implementations. See the translator.README.txt file in the tools directory + // for more information. + // +-// $hash=dfb6a82e093895922f6f06700eb74d9d64493c24$ ++// $hash=e6d021c8d46123b4b1b40aad97179677b04fc10c$ + // + + #ifndef CEF_LIBCEF_DLL_WRAPPER_TYPES_H_ +@@ -84,6 +84,7 @@ enum CefWrapperType { + WT_LIFE_SPAN_HANDLER, + WT_LIST_VALUE, + WT_LOAD_HANDLER, ++ WT_MEDIA_HANDLER, + WT_MENU_BUTTON, + WT_MENU_BUTTON_DELEGATE, + WT_MENU_BUTTON_PRESSED_LOCK, +diff --git a/src/chrome/browser/BUILD.gn b/src/chrome/browser/BUILD.gn +index 2c25dcbca60..cc514b6c0c7 +--- a/src/chrome/browser/BUILD.gn ++++ b/src/chrome/browser/BUILD.gn +@@ -4502,6 +4502,8 @@ static_library("browser") { + + if (is_ohos && safe_browsing_mode == 0) { + sources -= [ ++ "enterprise/connectors/analysis/page_print_analysis_request.cc", ++ "enterprise/connectors/analysis/page_print_analysis_request.h", + "safe_browsing/generated_safe_browsing_pref.cc", + "safe_browsing/generated_safe_browsing_pref.h", + ] +diff --git a/src/chrome/browser/apps/guest_view/app_view_browsertest.cc b/src/chrome/browser/apps/guest_view/app_view_browsertest.cc +index 294923fb49d..bc3e42eb2dd +--- a/src/chrome/browser/apps/guest_view/app_view_browsertest.cc ++++ b/src/chrome/browser/apps/guest_view/app_view_browsertest.cc +@@ -92,6 +92,28 @@ class AppViewTest : public extensions::PlatformAppBrowserTest { + return test_guest_view_manager_; + } + ++ void CloseAppWindow() { ++ content::WebContents* embedder_web_contents = ++ GetFirstAppWindowWebContents(); ++ content::WebContentsDestroyedWatcher destroyed_watcher( ++ embedder_web_contents); ++ EXPECT_TRUE(content::ExecJs(embedder_web_contents, "window.close()")); ++ destroyed_watcher.Wait(); ++ } ++ ++ // Completes an onEmbedRequested request in `app`. Assumes the app has a ++ // `continueEmbedding` function which does this. ++ void ContinueEmbedding(const extensions::Extension* app, bool allow_request) { ++ content::WebContents* host_contents = ++ extensions::ProcessManager::Get(browser()->profile()) ++ ->GetBackgroundHostForExtension(app->id()) ++ ->host_contents(); ++ ASSERT_TRUE(content::WaitForLoadStop(host_contents)); ++ ASSERT_TRUE(content::ExecJs( ++ host_contents, ++ content::JsReplace("continueEmbedding($1);", allow_request))); ++ } ++ + private: + void SetUpOnMainThread() override { + extensions::PlatformAppBrowserTest::SetUpOnMainThread(); +@@ -175,6 +197,24 @@ IN_PROC_BROWSER_TEST_F(AppViewTest, TestAppViewEmbedSelfShouldFail) { + NO_TEST_SERVER); + } + ++IN_PROC_BROWSER_TEST_F(AppViewTest, TestCloseWithPendingEmbedRequestDeny) { ++ const extensions::Extension* skeleton_app = ++ InstallPlatformApp("app_view/shim/skeleton"); ++ TestHelper("testCloseWithPendingEmbedRequest", "app_view/shim", ++ skeleton_app->id(), NO_TEST_SERVER); ++ CloseAppWindow(); ++ ContinueEmbedding(skeleton_app, false); ++} ++ ++IN_PROC_BROWSER_TEST_F(AppViewTest, TestCloseWithPendingEmbedRequestAllow) { ++ const extensions::Extension* skeleton_app = ++ InstallPlatformApp("app_view/shim/skeleton"); ++ TestHelper("testCloseWithPendingEmbedRequest", "app_view/shim", ++ skeleton_app->id(), NO_TEST_SERVER); ++ CloseAppWindow(); ++ ContinueEmbedding(skeleton_app, true); ++} ++ + IN_PROC_BROWSER_TEST_F(AppViewTest, KillGuestWithInvalidInstanceID) { + const extensions::Extension* bad_app = + LoadAndLaunchPlatformApp("app_view/bad_app", "AppViewTest.LAUNCHED"); +@@ -248,9 +288,5 @@ IN_PROC_BROWSER_TEST_F(AppViewTest, + bad_app_obs.Wait(); + EXPECT_FALSE(bad_app_obs.did_exit_normally()); + // Now ask the guest to continue embedding. +- ASSERT_TRUE( +- ExecuteScript(extensions::ProcessManager::Get(browser()->profile()) +- ->GetBackgroundHostForExtension(guest_app->id()) +- ->web_contents(), +- "continueEmbedding();")); ++ ContinueEmbedding(guest_app, true); + } +diff --git a/src/chrome/browser/chrome_browser_interface_binders.cc b/src/chrome/browser/chrome_browser_interface_binders.cc +index 4a3a2cac193..9d3055c645e +--- a/src/chrome/browser/chrome_browser_interface_binders.cc ++++ b/src/chrome/browser/chrome_browser_interface_binders.cc +@@ -620,6 +620,8 @@ void PopulateChromeFrameBinders( + #endif // BUILDFLAG(ENABLE_UNHANDLED_TAP) + #endif // BUILDFLAG(BUILD_CONTEXTUAL_SEARCH) + ++#elif BUILDFLAG(IS_OHOS) ++ LOG(INFO) << "WebPayments not supported on OHOS"; + #else + map->Add( + base::BindRepeating(&badging::BadgeManager::BindFrameReceiver)); +diff --git a/src/chrome/browser/chrome_browser_main.cc b/src/chrome/browser/chrome_browser_main.cc +index e599b114f02..ce4b5726914 +--- a/src/chrome/browser/chrome_browser_main.cc ++++ b/src/chrome/browser/chrome_browser_main.cc +@@ -1185,7 +1185,9 @@ void ChromeBrowserMainParts::PreProfileInit() { + #else + InstallChromeJavaScriptAppModalDialogViewFactory(); + #endif ++#if !BUILDFLAG(IS_OHOS) || BUILDFLAG(OHOS_ENABLE_MEDIA_ROUTER) + media_router::ChromeMediaRouterFactory::DoPlatformInit(); ++#endif + } + + void ChromeBrowserMainParts::CallPostProfileInit(Profile* profile) { +diff --git a/src/chrome/browser/chrome_content_browser_client.cc b/src/chrome/browser/chrome_content_browser_client.cc +index 01aaad5f9ac..7af2581d02b +--- a/src/chrome/browser/chrome_content_browser_client.cc ++++ b/src/chrome/browser/chrome_content_browser_client.cc +@@ -5708,6 +5708,9 @@ bool ChromeContentBrowserClient::ShowPaymentHandlerWindow( + base::OnceCallback callback) { + #if BUILDFLAG(IS_ANDROID) + return false; ++#elif BUILDFLAG(IS_OHOS) ++ LOG(INFO) << "PaymentRequestDisplayManagerFactory not supported on OHOS"; ++ return false; + #else + payments::PaymentRequestDisplayManagerFactory::GetInstance() + ->GetForBrowserContext(browser_context) +diff --git a/src/chrome/browser/devtools/devtools_browsertest.cc b/src/chrome/browser/devtools/devtools_browsertest.cc +index 79159af2e58..9fe4fe5254d +--- a/src/chrome/browser/devtools/devtools_browsertest.cc ++++ b/src/chrome/browser/devtools/devtools_browsertest.cc +@@ -24,6 +24,7 @@ + #include "base/strings/stringprintf.h" + #include "base/strings/utf_string_conversions.h" + #include "base/task/single_thread_task_runner.h" ++#include "base/test/bind.h" + #include "base/test/test_timeouts.h" + #include "base/threading/thread_restrictions.h" + #include "base/threading/thread_task_runner_handle.h" +diff --git a/src/chrome/browser/enterprise/connectors/analysis/content_analysis_delegate.cc b/src/chrome/browser/enterprise/connectors/analysis/content_analysis_delegate.cc +index ed373a35792..f47701eb9d1 +--- a/src/chrome/browser/enterprise/connectors/analysis/content_analysis_delegate.cc ++++ b/src/chrome/browser/enterprise/connectors/analysis/content_analysis_delegate.cc +@@ -578,8 +578,10 @@ bool ContentAnalysisDelegate::UploadData() { + for (size_t i = 0; i < data_.paths.size(); ++i) + tasks[i].request = PrepareFileRequest(data_.paths[i]); + ++#if !BUILDFLAG(IS_OHOS) || BUILDFLAG(FULL_SAFE_BROWSING) + file_opening_job_ = + std::make_unique(std::move(tasks)); ++#endif + } + + data_uploaded_ = true; +diff --git a/src/chrome/browser/enterprise/connectors/analysis/content_analysis_delegate.h b/src/chrome/browser/enterprise/connectors/analysis/content_analysis_delegate.h +index 2699a318902..44720bfe78e +--- a/src/chrome/browser/enterprise/connectors/analysis/content_analysis_delegate.h ++++ b/src/chrome/browser/enterprise/connectors/analysis/content_analysis_delegate.h +@@ -395,7 +395,9 @@ class ContentAnalysisDelegate : public ContentAnalysisDelegateBase { + + // Owner of the FileOpeningJob responsible for opening files on parallel + // threads. Always nullptr for non-file content scanning. ++#if !BUILDFLAG(IS_OHOS) || BUILDFLAG(FULL_SAFE_BROWSING) + std::unique_ptr file_opening_job_; ++#endif + + base::TimeTicks upload_start_time_; + +diff --git a/src/chrome/browser/extensions/api/settings_private/prefs_util.cc b/src/chrome/browser/extensions/api/settings_private/prefs_util.cc +index 6a77c11eab7..debcbb2e9ac +--- a/src/chrome/browser/extensions/api/settings_private/prefs_util.cc ++++ b/src/chrome/browser/extensions/api/settings_private/prefs_util.cc +@@ -851,8 +851,10 @@ const PrefsUtil::TypedPrefMap& PrefsUtil::GetAllowlistedKeys() { + #endif // BUILDFLAG(GOOGLE_CHROME_BRANDING) + + // Media Remoting settings. ++#if !BUILDFLAG(IS_OHOS) || BUILDFLAG(OHOS_ENABLE_MEDIA_ROUTER) + (*s_allowlist)[media_router::prefs::kMediaRouterMediaRemotingEnabled] = + settings_api::PrefType::PREF_TYPE_BOOLEAN; ++#endif + + #if BUILDFLAG(IS_WIN) + // SwReporter settings. +diff --git a/src/chrome/browser/extensions/extension_util.cc b/src/chrome/browser/extensions/extension_util.cc +index 204c3508fc6..416d8bc2926 +--- a/src/chrome/browser/extensions/extension_util.cc ++++ b/src/chrome/browser/extensions/extension_util.cc +@@ -56,15 +56,8 @@ namespace util { + + namespace { + // Returns |extension_id|. See note below. +-std::string ReloadExtensionIfEnabled(const std::string& extension_id, +- content::BrowserContext* context) { +- ExtensionRegistry* registry = ExtensionRegistry::Get(context); +- bool extension_is_enabled = +- registry->enabled_extensions().Contains(extension_id); +- +- if (!extension_is_enabled) +- return extension_id; +- ++std::string ReloadExtension(const std::string& extension_id, ++ content::BrowserContext* context) { + // When we reload the extension the ID may be invalidated if we've passed it + // by const ref everywhere. Make a copy to be safe. http://crbug.com/103762 + std::string id = extension_id; +@@ -75,6 +68,18 @@ std::string ReloadExtensionIfEnabled(const std::string& extension_id, + return id; + } + ++std::string ReloadExtensionIfEnabled(const std::string& extension_id, ++ content::BrowserContext* context) { ++ ExtensionRegistry* registry = ExtensionRegistry::Get(context); ++ bool extension_is_enabled = ++ registry->enabled_extensions().Contains(extension_id); ++ ++ if (!extension_is_enabled) { ++ return extension_id; ++ } ++ return ReloadExtension(extension_id, context); ++} ++ + } // namespace + + bool HasIsolatedStorage(const std::string& extension_id, +@@ -169,14 +174,15 @@ bool AllowFileAccess(const std::string& extension_id, + void SetAllowFileAccess(const std::string& extension_id, + content::BrowserContext* context, + bool allow) { +- // Reload to update browser state. Only bother if the value changed and the +- // extension is actually enabled, since there is no UI otherwise. ++ // Reload to update browser state if the value changed. We need to reload even ++ // if the extension is disabled, in order to make sure file access is ++ // reinitialized correctly. + if (allow == AllowFileAccess(extension_id, context)) + return; + + ExtensionPrefs::Get(context)->SetAllowFileAccess(extension_id, allow); + +- ReloadExtensionIfEnabled(extension_id, context); ++ ReloadExtension(extension_id, context); + } + + bool IsAppLaunchable(const std::string& extension_id, +diff --git a/src/chrome/browser/extensions/extension_util_unittest.cc b/src/chrome/browser/extensions/extension_util_unittest.cc +new file mode 100644 +index 00000000000..a06c97dd201 +--- /dev/null ++++ b/src/chrome/browser/extensions/extension_util_unittest.cc +@@ -0,0 +1,148 @@ ++// Copyright 2023 The Chromium Authors ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "chrome/browser/extensions/extension_util.h" ++ ++#include "base/memory/scoped_refptr.h" ++#include "chrome/browser/extensions/chrome_test_extension_loader.h" ++#include "chrome/browser/extensions/extension_service.h" ++#include "chrome/browser/extensions/extension_service_test_base.h" ++#include "components/sessions/content/session_tab_helper.h" ++#include "content/public/test/web_contents_tester.h" ++#include "extensions/browser/test_extension_registry_observer.h" ++#include "extensions/common/permissions/permissions_data.h" ++#include "extensions/test/test_extension_dir.h" ++#include "url/gurl.h" ++ ++namespace extensions { ++ ++using ExtensionUtilUnittest = ExtensionServiceTestBase; ++ ++TEST_F(ExtensionUtilUnittest, SetAllowFileAccess) { ++ InitializeEmptyExtensionService(); ++ constexpr char kManifest[] = ++ R"({ ++ "name": "foo", ++ "version": "1.0", ++ "manifest_version": 2, ++ "permissions": [""] ++ })"; ++ ++ TestExtensionDir dir; ++ dir.WriteManifest(kManifest); ++ ++ ChromeTestExtensionLoader loader(profile()); ++ // An unpacked extension would get file access by default, so disabled it on ++ // the loader. ++ loader.set_allow_file_access(false); ++ ++ scoped_refptr extension = ++ loader.LoadExtension(dir.UnpackedPath()); ++ const std::string extension_id = extension->id(); ++ ++ GURL file_url("file://etc"); ++ std::unique_ptr web_contents( ++ content::WebContentsTester::CreateTestWebContents(profile(), nullptr)); ++ int tab_id = sessions::SessionTabHelper::IdForTab(web_contents.get()).id(); ++ ++ // Initially the file access pref will be false and the extension will not be ++ // able to capture a file URL page. ++ EXPECT_FALSE(util::AllowFileAccess(extension_id, profile())); ++ EXPECT_FALSE(extension->permissions_data()->CanCaptureVisiblePage( ++ file_url, tab_id, nullptr, CaptureRequirement::kActiveTabOrAllUrls)); ++ ++ // Calling SetAllowFileAccess should reload the extension with file access. ++ { ++ TestExtensionRegistryObserver observer(registry(), extension_id); ++ util::SetAllowFileAccess(extension_id, browser_context(), true); ++ extension = observer.WaitForExtensionInstalled(); ++ } ++ ++ EXPECT_TRUE(util::AllowFileAccess(extension_id, profile())); ++ EXPECT_TRUE(extension->permissions_data()->CanCaptureVisiblePage( ++ file_url, tab_id, nullptr, CaptureRequirement::kActiveTabOrAllUrls)); ++ ++ // Removing the file access should reload the extension again back to not ++ // having file access. ++ { ++ TestExtensionRegistryObserver observer(registry(), extension_id); ++ util::SetAllowFileAccess(extension_id, browser_context(), false); ++ extension = observer.WaitForExtensionInstalled(); ++ } ++ ++ EXPECT_FALSE(util::AllowFileAccess(extension_id, profile())); ++ EXPECT_FALSE(extension->permissions_data()->CanCaptureVisiblePage( ++ file_url, tab_id, nullptr, CaptureRequirement::kActiveTabOrAllUrls)); ++} ++ ++TEST_F(ExtensionUtilUnittest, SetAllowFileAccessWhileDisabled) { ++ InitializeEmptyExtensionService(); ++ constexpr char kManifest[] = ++ R"({ ++ "name": "foo", ++ "version": "1.0", ++ "manifest_version": 2, ++ "permissions": [""] ++ })"; ++ ++ TestExtensionDir dir; ++ dir.WriteManifest(kManifest); ++ ++ ChromeTestExtensionLoader loader(profile()); ++ // An unpacked extension would get file access by default, so disabled it on ++ // the loader. ++ loader.set_allow_file_access(false); ++ ++ scoped_refptr extension = ++ loader.LoadExtension(dir.UnpackedPath()); ++ const std::string extension_id = extension->id(); ++ ++ GURL file_url("file://etc"); ++ std::unique_ptr web_contents( ++ content::WebContentsTester::CreateTestWebContents(profile(), nullptr)); ++ int tab_id = sessions::SessionTabHelper::IdForTab(web_contents.get()).id(); ++ ++ // Initially the file access pref will be false and the extension will not be ++ // able to capture a file URL page. ++ EXPECT_FALSE(util::AllowFileAccess(extension_id, profile())); ++ EXPECT_FALSE(extension->permissions_data()->CanCaptureVisiblePage( ++ file_url, tab_id, nullptr, CaptureRequirement::kActiveTabOrAllUrls)); ++ ++ // Disabling the extension then calling SetAllowFileAccess should reload the ++ // extension with file access. ++ service()->DisableExtension(extension_id, ++ disable_reason::DISABLE_USER_ACTION); ++ { ++ TestExtensionRegistryObserver observer(registry(), extension_id); ++ util::SetAllowFileAccess(extension_id, browser_context(), true); ++ extension = observer.WaitForExtensionInstalled(); ++ } ++ // The extension should still be disabled. ++ EXPECT_FALSE(service()->IsExtensionEnabled(extension_id)); ++ ++ service()->EnableExtension(extension_id); ++ EXPECT_TRUE(util::AllowFileAccess(extension_id, profile())); ++ EXPECT_TRUE(extension->permissions_data()->CanCaptureVisiblePage( ++ file_url, tab_id, nullptr, CaptureRequirement::kActiveTabOrAllUrls)); ++ ++ // Disabling the extension and then removing the file access should reload it ++ // again back to not having file access. Regression test for ++ // crbug.com/1385343. ++ service()->DisableExtension(extension_id, ++ disable_reason::DISABLE_USER_ACTION); ++ { ++ TestExtensionRegistryObserver observer(registry(), extension_id); ++ util::SetAllowFileAccess(extension_id, browser_context(), false); ++ extension = observer.WaitForExtensionInstalled(); ++ } ++ // The extension should still be disabled. ++ EXPECT_FALSE(service()->IsExtensionEnabled(extension_id)); ++ ++ service()->EnableExtension(extension_id); ++ EXPECT_FALSE(util::AllowFileAccess(extension_id, profile())); ++ EXPECT_FALSE(extension->permissions_data()->CanCaptureVisiblePage( ++ file_url, tab_id, nullptr, CaptureRequirement::kActiveTabOrAllUrls)); ++} ++ ++} // namespace extensions +diff --git a/src/chrome/browser/performance_timeline_browsertest.cc b/src/chrome/browser/performance_timeline_browsertest.cc +new file mode 100644 +index 00000000000..d1038c6c72f +--- /dev/null ++++ b/src/chrome/browser/performance_timeline_browsertest.cc +@@ -0,0 +1,93 @@ ++// Copyright 2022 The Chromium Authors ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "chrome/browser/extensions/extension_browsertest.h" ++#include "chrome/test/base/in_process_browser_test.h" ++#include "chrome/test/base/ui_test_utils.h" ++#include "content/public/test/browser_test.h" ++#include "content/public/test/browser_test_utils.h" ++ ++namespace { ++ ++class PerformanceTimelineBrowserTest : public extensions::ExtensionBrowserTest { ++ protected: ++ content::WebContents* web_contents() const { ++ return browser()->tab_strip_model()->GetActiveWebContents(); ++ } ++ ++ void LoadScript(const extensions::Extension* extension) { ++ std::string script_code = content::JsReplace( ++ R"( ++ (async () => { ++ await new Promise( resolve => { ++ const script = document.createElement('script'); ++ script.addEventListener('load', resolve); ++ document.body.appendChild(script); ++ script.src = $1; ++ }); ++ })(); ++ )", ++ extension->GetResourceURL(extension->url(), "content_script.js") ++ .spec()); ++ EXPECT_EQ(content::EvalJs(web_contents(), script_code).error, ""); ++ } ++}; ++ ++} // namespace ++ ++// Fetched resources that are initiated from the IsolatedWorld should have NO ++// resource timing entry emitted. ++IN_PROC_BROWSER_TEST_F(PerformanceTimelineBrowserTest, ++ ResouceTiming_IsolatedWorld) { ++ ASSERT_TRUE(embedded_test_server()->Start()); ++ const extensions::Extension* extension = LoadExtension( ++ test_data_dir_.AppendASCII("resource_timing/fetch_resource")); ++ ASSERT_TRUE(extension); ++ GURL test_url = embedded_test_server()->GetURL( ++ "/extensions/resource_timing/test-page.html"); ++ ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), test_url)); ++ ++ // fetch resource from extension. ++ bool result = false; ++ EXPECT_TRUE(content::ExecuteScriptAndExtractBool( ++ web_contents(), "document.querySelector('#fetchResourceButton').click();", ++ &result)); ++ EXPECT_TRUE(result); ++ ++ // There should be 0 resource entry emitted. ++ EXPECT_EQ(content::EvalJs(web_contents(), "getResourceTimingEntryCount();") ++ .ExtractInt(), ++ 0); ++} ++ ++// Fetched resources that are initiated from the MainWorld should have one ++// resource timing entry emitted. ++IN_PROC_BROWSER_TEST_F(PerformanceTimelineBrowserTest, ++ ResouceTiming_MainWorld) { ++ ASSERT_TRUE(embedded_test_server()->Start()); ++ const extensions::Extension* extension = LoadExtension( ++ test_data_dir_.AppendASCII("resource_timing/fetch_resource")); ++ ASSERT_TRUE(extension); ++ ++ GURL test_url = embedded_test_server()->GetURL( ++ "/extensions/resource_timing/test-page.html"); ++ ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), test_url)); ++ ++ // Add script to DOM as a script tag element. ++ LoadScript(extension); ++ ++ // Execute added script which is to fetch resource; ++ EXPECT_EQ( ++ content::EvalJs(web_contents(), "(async ()=>{await fetchResource();})()") ++ .error, ++ ""); ++ ++ // There should be 1 resource entry emitted. ++ EXPECT_EQ( ++ content::EvalJs( ++ web_contents(), ++ "(async ()=>{return await getResourceTimingEntryCountAsync();})()") ++ .ExtractInt(), ++ 1); ++} +diff --git a/src/chrome/browser/printing/print_view_manager_base.cc b/src/chrome/browser/printing/print_view_manager_base.cc +index c63900f5d16..46c56e8df52 +--- a/src/chrome/browser/printing/print_view_manager_base.cc ++++ b/src/chrome/browser/printing/print_view_manager_base.cc +@@ -806,7 +806,7 @@ void PrintViewManagerBase::OnDocDone(int job_id, PrintedDocument* document) { + base::DoNothing()); + } + #endif +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + DCHECK_LE(number_pages(), kMaxPageCount); + PdfWritingDone(base::checked_cast(number_pages())); + #endif +@@ -937,7 +937,7 @@ void PrintViewManagerBase::TerminatePrintJob(bool cancel) { + // We don't need the metafile data anymore because the printing is canceled. + print_job_->Cancel(); + quit_inner_loop_.Reset(); +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + PdfWritingDone(0); + #endif + } else { +diff --git a/src/chrome/browser/printing/print_view_manager_basic.cc b/src/chrome/browser/printing/print_view_manager_basic.cc +index ae28a212520..408ebe601be +--- a/src/chrome/browser/printing/print_view_manager_basic.cc ++++ b/src/chrome/browser/printing/print_view_manager_basic.cc +@@ -44,7 +44,7 @@ void PrintViewManagerBasic::BindPrintManagerHost( + print_manager->BindReceiver(std::move(receiver), rfh); + } + +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + void PrintViewManagerBasic::PdfWritingDone(int page_count) { + pdf_writing_done_callback().Run(page_count); + } +diff --git a/src/chrome/browser/printing/print_view_manager_basic.h b/src/chrome/browser/printing/print_view_manager_basic.h +index 343a60748cb..7ef46950153 +--- a/src/chrome/browser/printing/print_view_manager_basic.h ++++ b/src/chrome/browser/printing/print_view_manager_basic.h +@@ -25,7 +25,7 @@ class PrintViewManagerBasic + mojo::PendingAssociatedReceiver receiver, + content::RenderFrameHost* rfh); + +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + // printing::PrintManager: + void PdfWritingDone(int page_count) override; + #endif +diff --git a/src/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc b/src/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc +index c837cd71478..87109004ac8 +--- a/src/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc ++++ b/src/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc +@@ -380,11 +380,13 @@ void ChromeBrowserMainExtraPartsProfiles:: + #endif + if (base::FeatureList::IsEnabled(media::kUseMediaHistoryStore)) + media_history::MediaHistoryKeyedServiceFactory::GetInstance(); ++#if !BUILDFLAG(IS_OHOS) || BUILDFLAG(OHOS_ENABLE_MEDIA_ROUTER) + media_router::ChromeLocalPresentationManagerFactory::GetInstance(); + media_router::ChromeMediaRouterFactory::GetInstance(); + #if !BUILDFLAG(IS_ANDROID) + media_router::MediaRouterUIServiceFactory::GetInstance(); + #endif ++#endif + // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch + // of lacros-chrome is complete. + #if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || \ +diff --git a/src/chrome/browser/task_manager/providers/web_contents/background_contents_tag.cc b/src/chrome/browser/task_manager/providers/web_contents/background_contents_tag.cc +index cb779845509..841470e607b +--- a/src/chrome/browser/task_manager/providers/web_contents/background_contents_tag.cc ++++ b/src/chrome/browser/task_manager/providers/web_contents/background_contents_tag.cc +@@ -12,6 +12,7 @@ + #include "chrome/browser/background/background_contents_service_factory.h" + #include "chrome/browser/profiles/profile.h" + #include "chrome/browser/task_manager/providers/web_contents/background_contents_task.h" ++#include "chrome/common/buildflags.h" + #include "content/public/browser/web_contents.h" + #include "extensions/browser/extension_registry.h" + #include "extensions/common/extension.h" +@@ -24,10 +25,14 @@ std::unique_ptr BackgroundContentsTag::CreateTask( + // Try to lookup the application name from the parent extension (if any). + Profile* profile = Profile::FromBrowserContext( + web_contents()->GetBrowserContext()); ++#if !BUILDFLAG(IS_OHOS) || BUILDFLAG(ENABLE_BACKGROUND_CONTENTS) + BackgroundContentsService* background_contents_service = + BackgroundContentsServiceFactory::GetForProfile(profile); + const std::string& application_id = + background_contents_service->GetParentApplicationId(background_contents_); ++#else ++ const std::string& application_id = std::string(); ++#endif + const extensions::ExtensionSet& extensions_set = + extensions::ExtensionRegistry::Get(profile)->enabled_extensions(); + const extensions::Extension* extension = +diff --git a/src/chrome/browser/ui/autofill/chrome_autofill_client.cc b/src/chrome/browser/ui/autofill/chrome_autofill_client.cc +index 11fb02e67b4..8a61027ab0a +--- a/src/chrome/browser/ui/autofill/chrome_autofill_client.cc ++++ b/src/chrome/browser/ui/autofill/chrome_autofill_client.cc +@@ -89,6 +89,7 @@ + #include "chrome/browser/ui/android/autofill/card_name_fix_flow_view_android.h" + #include "chrome/browser/ui/android/infobars/autofill_credit_card_filling_infobar.h" + #include "chrome/browser/ui/android/infobars/autofill_offer_notification_infobar.h" ++#include "chrome/browser/ui/autofill/payments/autofill_snackbar_controller_impl.h" + #include "chrome/browser/ui/autofill/payments/offer_notification_infobar_controller_impl.h" + #include "components/autofill/core/browser/payments/autofill_credit_card_filling_infobar_delegate_mobile.h" + #include "components/autofill/core/browser/payments/autofill_offer_notification_infobar_delegate_mobile.h" +@@ -778,7 +779,11 @@ void ChromeAutofillClient::OnVirtualCardDataAvailable( + // enabled. This is because the ManualFillingComponent for credit cards is + // only enabled when keyboard accessory is enabled. + if (features::IsAutofillManualFallbackEnabled()) { +- (new AutofillSnackbarControllerImpl(web_contents()))->Show(); ++ if (!autofill_snackbar_controller_impl_) { ++ autofill_snackbar_controller_impl_ = ++ std::make_unique(web_contents()); ++ } ++ autofill_snackbar_controller_impl_->Show(); + } + #else + VirtualCardManualFallbackBubbleControllerImpl::CreateForWebContents( +diff --git a/src/chrome/browser/ui/autofill/chrome_autofill_client.h b/src/chrome/browser/ui/autofill/chrome_autofill_client.h +index adaedbc19d7..e35afaa4bc7 +--- a/src/chrome/browser/ui/autofill/chrome_autofill_client.h ++++ b/src/chrome/browser/ui/autofill/chrome_autofill_client.h +@@ -40,6 +40,9 @@ + namespace autofill { + + class AutofillPopupControllerImpl; ++#if BUILDFLAG(IS_ANDROID) ++class AutofillSnackbarControllerImpl; ++#endif // BUILDFLAG(IS_ANDROID) + + // Chrome implementation of AutofillClient. + class ChromeAutofillClient +@@ -231,6 +234,8 @@ class ChromeAutofillClient + CardNameFixFlowControllerImpl card_name_fix_flow_controller_; + SaveCardMessageControllerAndroid save_card_message_controller_android_; + SaveUpdateAddressProfileFlowManager save_update_address_profile_flow_manager_; ++ std::unique_ptr ++ autofill_snackbar_controller_impl_; + #endif + CardUnmaskPromptControllerImpl unmask_controller_; + AutofillErrorDialogControllerImpl autofill_error_dialog_controller_; +diff --git a/src/chrome/browser/ui/autofill/payments/autofill_snackbar_controller_impl.cc b/src/chrome/browser/ui/autofill/payments/autofill_snackbar_controller_impl.cc +index 1b76c2b6e26..b4f61b323ab +--- a/src/chrome/browser/ui/autofill/payments/autofill_snackbar_controller_impl.cc ++++ b/src/chrome/browser/ui/autofill/payments/autofill_snackbar_controller_impl.cc +@@ -31,19 +31,13 @@ void AutofillSnackbarControllerImpl::Show() { + base::UmaHistogramBoolean("Autofill.Snackbar.VirtualCard.Shown", true); + } + +-void AutofillSnackbarControllerImpl::Dismiss() { +- if (!autofill_snackbar_view_) +- return; +- autofill_snackbar_view_->Dismiss(); +-} +- + void AutofillSnackbarControllerImpl::SetViewForTesting( + AutofillSnackbarView* view) { + autofill_snackbar_view_ = view; + } + + void AutofillSnackbarControllerImpl::OnActionClicked() { +- ManualFillingControllerImpl::GetOrCreate(web_contents_) ++ ManualFillingControllerImpl::GetOrCreate(GetWebContents()) + ->ShowAccessorySheetTab(autofill::AccessoryTabType::CREDIT_CARDS); + base::UmaHistogramBoolean("Autofill.Snackbar.VirtualCard.ActionClicked", + true); +@@ -67,4 +61,12 @@ content::WebContents* AutofillSnackbarControllerImpl::GetWebContents() const { + return web_contents_; + } + ++void AutofillSnackbarControllerImpl::Dismiss() { ++ if (!autofill_snackbar_view_) { ++ return; ++ } ++ ++ autofill_snackbar_view_->Dismiss(); ++} ++ + } // namespace autofill +diff --git a/src/chrome/browser/ui/autofill/payments/autofill_snackbar_controller_impl.h b/src/chrome/browser/ui/autofill/payments/autofill_snackbar_controller_impl.h +index 4e31278bc5e..a38931f3874 +--- a/src/chrome/browser/ui/autofill/payments/autofill_snackbar_controller_impl.h ++++ b/src/chrome/browser/ui/autofill/payments/autofill_snackbar_controller_impl.h +@@ -28,7 +28,7 @@ class AutofillSnackbarControllerImpl : public AutofillSnackbarController { + void Show(); + void SetViewForTesting(AutofillSnackbarView* view); + +- // AutofillSnackbarController implementation. ++ // AutofillSnackbarController: + void OnActionClicked() override; + void OnDismissed() override; + std::u16string GetMessageText() const override; +@@ -41,6 +41,7 @@ class AutofillSnackbarControllerImpl : public AutofillSnackbarController { + void Dismiss(); + + raw_ptr web_contents_; ++ + raw_ptr autofill_snackbar_view_ = nullptr; + }; + +diff --git a/src/chrome/browser/ui/browser_command_controller_unittest.cc b/src/chrome/browser/ui/browser_command_controller_unittest.cc +index 1a5862450d7..83a553c434d +--- a/src/chrome/browser/ui/browser_command_controller_unittest.cc ++++ b/src/chrome/browser/ui/browser_command_controller_unittest.cc +@@ -291,6 +291,7 @@ class FullscreenTestBrowserWindow : public TestBrowserWindow, + const GURL& url, + ExclusiveAccessBubbleType bubble_type, + ExclusiveAccessBubbleHideCallback bubble_first_hide_callback, ++ bool notify_download, + bool force_update) override {} + bool IsExclusiveAccessBubbleDisplayed() const override { return false; } + void OnExclusiveAccessUserInput() override {} +diff --git a/src/chrome/browser/ui/exclusive_access/exclusive_access_bubble.cc b/src/chrome/browser/ui/exclusive_access/exclusive_access_bubble.cc +index ff75fba5f70..a6a6e0868a3 +--- a/src/chrome/browser/ui/exclusive_access/exclusive_access_bubble.cc ++++ b/src/chrome/browser/ui/exclusive_access/exclusive_access_bubble.cc +@@ -119,8 +119,8 @@ std::u16string ExclusiveAccessBubble::GetCurrentAllowButtonText() const { + + std::u16string ExclusiveAccessBubble::GetInstructionText( + const std::u16string& accelerator) const { +- return exclusive_access_bubble::GetInstructionTextForType(bubble_type_, +- accelerator); ++ return exclusive_access_bubble::GetInstructionTextForType( ++ bubble_type_, accelerator, notify_download_, notify_overridden_); + } + + bool ExclusiveAccessBubble::IsHideTimeoutRunning() const { +diff --git a/src/chrome/browser/ui/exclusive_access/exclusive_access_bubble.h b/src/chrome/browser/ui/exclusive_access/exclusive_access_bubble.h +index fb15c6e67a4..e7edaea9146 +--- a/src/chrome/browser/ui/exclusive_access/exclusive_access_bubble.h ++++ b/src/chrome/browser/ui/exclusive_access/exclusive_access_bubble.h +@@ -110,6 +110,12 @@ class ExclusiveAccessBubble : public gfx::AnimationDelegate { + // The type of the bubble; controls e.g. which buttons to show. + ExclusiveAccessBubbleType bubble_type_; + ++ // The bubble should notify about downloads ++ bool notify_download_ = false; ++ ++ // The bubble should notify about overriding another ExclusiveAccessBubble ++ bool notify_overridden_ = false; ++ + private: + friend class ExclusiveAccessTest; + +diff --git a/src/chrome/browser/ui/exclusive_access/exclusive_access_bubble_type.cc b/src/chrome/browser/ui/exclusive_access/exclusive_access_bubble_type.cc +index 4aaec9d774d..a45fbb9fd3c +--- a/src/chrome/browser/ui/exclusive_access/exclusive_access_bubble_type.cc ++++ b/src/chrome/browser/ui/exclusive_access/exclusive_access_bubble_type.cc +@@ -16,6 +16,29 @@ + + namespace exclusive_access_bubble { + ++namespace { ++ ++// Helper function to categorize if the bubble type requires hold to exit. ++bool IsHoldRequiredToExit(ExclusiveAccessBubbleType type) { ++ switch (type) { ++ case EXCLUSIVE_ACCESS_BUBBLE_TYPE_KEYBOARD_LOCK_EXIT_INSTRUCTION: ++ return true; ++ case EXCLUSIVE_ACCESS_BUBBLE_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION: ++ case EXCLUSIVE_ACCESS_BUBBLE_TYPE_EXTENSION_FULLSCREEN_EXIT_INSTRUCTION: ++ case EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_EXIT_INSTRUCTION: ++ case EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_MOUSELOCK_EXIT_INSTRUCTION: ++ case EXCLUSIVE_ACCESS_BUBBLE_TYPE_MOUSELOCK_EXIT_INSTRUCTION: ++ return false; ++ case EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE: ++ NOTREACHED(); ++ return false; ++ } ++ NOTREACHED(); ++ return false; ++} ++ ++} // namespace ++ + std::u16string GetLabelTextForType(ExclusiveAccessBubbleType type, + const GURL& url, + extensions::ExtensionRegistry* registry) { +@@ -112,7 +135,23 @@ std::u16string GetAllowButtonTextForType(ExclusiveAccessBubbleType type, + } + + std::u16string GetInstructionTextForType(ExclusiveAccessBubbleType type, +- const std::u16string& accelerator) { ++ const std::u16string& accelerator, ++ bool notify_download, ++ bool notify_overridden) { ++ if (notify_download) { ++ if (notify_overridden) { ++ return IsHoldRequiredToExit(type) ++ ? l10n_util::GetStringFUTF16( ++ IDS_FULLSCREEN_HOLD_TO_SEE_DOWNLOADS_AND_EXIT, ++ accelerator) ++ : l10n_util::GetStringFUTF16( ++ IDS_FULLSCREEN_PRESS_TO_SEE_DOWNLOADS_AND_EXIT, ++ accelerator); ++ } ++ return l10n_util::GetStringFUTF16(IDS_FULLSCREEN_PRESS_TO_SEE_DOWNLOADS, ++ accelerator); ++ } ++ + switch (type) { + case EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_EXIT_INSTRUCTION: + case EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_MOUSELOCK_EXIT_INSTRUCTION: +@@ -137,4 +176,22 @@ std::u16string GetInstructionTextForType(ExclusiveAccessBubbleType type, + return std::u16string(); + } + ++bool IsExclusiveAccessModeBrowserFullscreen(ExclusiveAccessBubbleType type) { ++ switch (type) { ++ case EXCLUSIVE_ACCESS_BUBBLE_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION: ++ case EXCLUSIVE_ACCESS_BUBBLE_TYPE_EXTENSION_FULLSCREEN_EXIT_INSTRUCTION: ++ return true; ++ case EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_EXIT_INSTRUCTION: ++ case EXCLUSIVE_ACCESS_BUBBLE_TYPE_KEYBOARD_LOCK_EXIT_INSTRUCTION: ++ case EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_MOUSELOCK_EXIT_INSTRUCTION: ++ case EXCLUSIVE_ACCESS_BUBBLE_TYPE_MOUSELOCK_EXIT_INSTRUCTION: ++ return false; ++ case EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE: ++ NOTREACHED(); ++ return false; ++ } ++ NOTREACHED(); ++ return false; ++} ++ + } // namespace exclusive_access_bubble +diff --git a/src/chrome/browser/ui/exclusive_access/exclusive_access_bubble_type.h b/src/chrome/browser/ui/exclusive_access/exclusive_access_bubble_type.h +index b134ce308e3..5d2fa88f0f5 +--- a/src/chrome/browser/ui/exclusive_access/exclusive_access_bubble_type.h ++++ b/src/chrome/browser/ui/exclusive_access/exclusive_access_bubble_type.h +@@ -50,7 +50,12 @@ std::u16string GetAllowButtonTextForType(ExclusiveAccessBubbleType type, + // Gets the text instructing the user how to exit an exclusive access mode. + // |accelerator| is the name of the key to exit fullscreen mode. + std::u16string GetInstructionTextForType(ExclusiveAccessBubbleType type, +- const std::u16string& accelerator); ++ const std::u16string& accelerator, ++ bool notify_download, ++ bool notify_overridden); ++ ++// Helpers to categorize different types of ExclusiveAccessBubbleType. ++bool IsExclusiveAccessModeBrowserFullscreen(ExclusiveAccessBubbleType type); + + } // namespace exclusive_access_bubble + +diff --git a/src/chrome/browser/ui/exclusive_access/exclusive_access_context.h b/src/chrome/browser/ui/exclusive_access/exclusive_access_context.h +index 02b58048b9e..893d2c6fa7c +--- a/src/chrome/browser/ui/exclusive_access/exclusive_access_context.h ++++ b/src/chrome/browser/ui/exclusive_access/exclusive_access_context.h +@@ -53,6 +53,7 @@ class ExclusiveAccessContext { + const GURL& url, + ExclusiveAccessBubbleType bubble_type, + ExclusiveAccessBubbleHideCallback bubble_first_hide_callback, ++ bool notify_download, + bool force_update) = 0; + + virtual bool IsExclusiveAccessBubbleDisplayed() const = 0; +diff --git a/src/chrome/browser/ui/exclusive_access/exclusive_access_manager.cc b/src/chrome/browser/ui/exclusive_access/exclusive_access_manager.cc +index 0aa22122283..c58d84b9c1c +--- a/src/chrome/browser/ui/exclusive_access/exclusive_access_manager.cc ++++ b/src/chrome/browser/ui/exclusive_access/exclusive_access_manager.cc +@@ -78,7 +78,8 @@ void ExclusiveAccessManager::UpdateExclusiveAccessExitBubbleContent( + GURL url = GetExclusiveAccessBubbleURL(); + ExclusiveAccessBubbleType bubble_type = GetExclusiveAccessExitBubbleType(); + exclusive_access_context_->UpdateExclusiveAccessExitBubbleContent( +- url, bubble_type, std::move(bubble_first_hide_callback), force_update); ++ url, bubble_type, std::move(bubble_first_hide_callback), ++ /*notify_download=*/false, force_update); + } + + GURL ExclusiveAccessManager::GetExclusiveAccessBubbleURL() const { +diff --git a/src/chrome/browser/ui/exclusive_access/fullscreen_controller_interactive_browsertest.cc b/src/chrome/browser/ui/exclusive_access/fullscreen_controller_interactive_browsertest.cc +index ba550006487..94f9eb97199 +--- a/src/chrome/browser/ui/exclusive_access/fullscreen_controller_interactive_browsertest.cc ++++ b/src/chrome/browser/ui/exclusive_access/fullscreen_controller_interactive_browsertest.cc +@@ -978,7 +978,7 @@ IN_PROC_BROWSER_TEST_F(ExperimentalFullscreenControllerInteractiveTest, + ->UpdateExclusiveAccessExitBubbleContent( + browser()->exclusive_access_manager()->GetExclusiveAccessBubbleURL(), + EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE, std::move(callback), +- /*force_update=*/false); ++ /*notify_download=*/false, /*force_update=*/false); + run_loop.Run(); + EXPECT_FALSE(IsExclusiveAccessBubbleDisplayed()); + +diff --git a/src/chrome/browser/ui/exclusive_access/fullscreen_controller_state_unittest.cc b/src/chrome/browser/ui/exclusive_access/fullscreen_controller_state_unittest.cc +index 5e626216184..72dc42c1950 +--- a/src/chrome/browser/ui/exclusive_access/fullscreen_controller_state_unittest.cc ++++ b/src/chrome/browser/ui/exclusive_access/fullscreen_controller_state_unittest.cc +@@ -66,6 +66,7 @@ class FullscreenControllerTestWindow : public TestBrowserWindow, + const GURL& url, + ExclusiveAccessBubbleType bubble_type, + ExclusiveAccessBubbleHideCallback bubble_first_hide_callback, ++ bool notify_download, + bool force_update) override; + bool IsExclusiveAccessBubbleDisplayed() const override; + void OnExclusiveAccessUserInput() override; +@@ -187,6 +188,7 @@ void FullscreenControllerTestWindow::UpdateExclusiveAccessExitBubbleContent( + const GURL& url, + ExclusiveAccessBubbleType bubble_type, + ExclusiveAccessBubbleHideCallback bubble_first_hide_callback, ++ bool notify_download, + bool force_update) {} + + bool FullscreenControllerTestWindow::IsExclusiveAccessBubbleDisplayed() const { +diff --git a/src/chrome/browser/ui/pdf/chrome_pdf_web_contents_helper_client.cc b/src/chrome/browser/ui/pdf/chrome_pdf_web_contents_helper_client.cc +index 8e7c9c901e6..53107a29ca3 +--- a/src/chrome/browser/ui/pdf/chrome_pdf_web_contents_helper_client.cc ++++ b/src/chrome/browser/ui/pdf/chrome_pdf_web_contents_helper_client.cc +@@ -9,6 +9,7 @@ + #include "chrome/browser/ui/tab_contents/core_tab_helper.h" + #include "chrome/common/content_restriction.h" + #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h" ++#include "pdf/buildflags.h" + #include "ppapi/c/private/ppb_pdf.h" + + namespace { +@@ -43,8 +44,12 @@ ChromePDFWebContentsHelperClient::~ChromePDFWebContentsHelperClient() = default; + content::RenderFrameHost* ChromePDFWebContentsHelperClient::FindPdfFrame( + content::WebContents* contents) { + content::RenderFrameHost* main_frame = contents->GetMainFrame(); ++#if !BUILDFLAG(IS_OHOS) || BUILDFLAG(ENABLE_PDF) + content::RenderFrameHost* pdf_frame = + pdf_frame_util::FindPdfChildFrame(main_frame); ++#else ++ content::RenderFrameHost* pdf_frame = nullptr; ++#endif + return pdf_frame ? pdf_frame : main_frame; + } + +diff --git a/src/chrome/browser/ui/views/apps/chrome_native_app_window_views_aura_ash.cc b/src/chrome/browser/ui/views/apps/chrome_native_app_window_views_aura_ash.cc +index 9242d25ae91..3b4c1920d6d +--- a/src/chrome/browser/ui/views/apps/chrome_native_app_window_views_aura_ash.cc ++++ b/src/chrome/browser/ui/views/apps/chrome_native_app_window_views_aura_ash.cc +@@ -320,6 +320,7 @@ void ChromeNativeAppWindowViewsAuraAsh::SetFullscreen(int fullscreen_types) { + ? EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_EXIT_INSTRUCTION + : EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE, + ExclusiveAccessBubbleHideCallback(), ++ /*notify_download=*/false, + /*force_update=*/false); + } + +@@ -392,8 +393,10 @@ void ChromeNativeAppWindowViewsAuraAsh::UpdateExclusiveAccessExitBubbleContent( + const GURL& url, + ExclusiveAccessBubbleType bubble_type, + ExclusiveAccessBubbleHideCallback bubble_first_hide_callback, ++ bool notify_download, + bool force_update) { +- if (bubble_type == EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE) { ++ DCHECK(!notify_download || exclusive_access_bubble_); ++ if (bubble_type == EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE && !notify_download) { + exclusive_access_bubble_.reset(); + if (bubble_first_hide_callback) { + std::move(bubble_first_hide_callback) +@@ -404,7 +407,8 @@ void ChromeNativeAppWindowViewsAuraAsh::UpdateExclusiveAccessExitBubbleContent( + + if (exclusive_access_bubble_) { + exclusive_access_bubble_->UpdateContent( +- url, bubble_type, std::move(bubble_first_hide_callback), force_update); ++ url, bubble_type, std::move(bubble_first_hide_callback), ++ notify_download, force_update); + return; + } + +diff --git a/src/chrome/browser/ui/views/apps/chrome_native_app_window_views_aura_ash.h b/src/chrome/browser/ui/views/apps/chrome_native_app_window_views_aura_ash.h +index e6104cccd0b..a1326c67fe6 +--- a/src/chrome/browser/ui/views/apps/chrome_native_app_window_views_aura_ash.h ++++ b/src/chrome/browser/ui/views/apps/chrome_native_app_window_views_aura_ash.h +@@ -114,6 +114,7 @@ class ChromeNativeAppWindowViewsAuraAsh + const GURL& url, + ExclusiveAccessBubbleType bubble_type, + ExclusiveAccessBubbleHideCallback bubble_first_hide_callback, ++ bool notify_download, + bool force_update) override; + bool IsExclusiveAccessBubbleDisplayed() const override; + void OnExclusiveAccessUserInput() override; +diff --git a/src/chrome/browser/ui/views/exclusive_access_bubble_views.cc b/src/chrome/browser/ui/views/exclusive_access_bubble_views.cc +index e636a107b97..eb1540c4c45 +--- a/src/chrome/browser/ui/views/exclusive_access_bubble_views.cc ++++ b/src/chrome/browser/ui/views/exclusive_access_bubble_views.cc +@@ -128,8 +128,9 @@ void ExclusiveAccessBubbleViews::UpdateContent( + const GURL& url, + ExclusiveAccessBubbleType bubble_type, + ExclusiveAccessBubbleHideCallback bubble_first_hide_callback, ++ bool notify_download, + bool force_update) { +- DCHECK_NE(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE, bubble_type); ++ DCHECK(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE != bubble_type || notify_download); + if (bubble_type_ == bubble_type && url_ == url && !force_update) + return; + +@@ -139,7 +140,11 @@ void ExclusiveAccessBubbleViews::UpdateContent( + bubble_first_hide_callback_ = std::move(bubble_first_hide_callback); + + url_ = url; +- bubble_type_ = bubble_type; ++ // When a request to notify about a download is made, the bubble type ++ // should be preserved from the old value, and not be updated. ++ if (!notify_download) { ++ bubble_type_ = bubble_type; ++ } + UpdateViewContent(bubble_type_); + + gfx::Size size = GetPopupRect(true).size(); +@@ -212,10 +217,8 @@ void ExclusiveAccessBubbleViews::UpdateViewContent( + DCHECK_NE(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE, bubble_type); + + std::u16string accelerator; +- if (bubble_type == +- EXCLUSIVE_ACCESS_BUBBLE_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION || +- bubble_type == +- EXCLUSIVE_ACCESS_BUBBLE_TYPE_EXTENSION_FULLSCREEN_EXIT_INSTRUCTION) { ++ if (exclusive_access_bubble::IsExclusiveAccessModeBrowserFullscreen( ++ bubble_type)) { + accelerator = browser_fullscreen_exit_accelerator_; + } else { + accelerator = l10n_util::GetStringUTF16(IDS_APP_ESC_KEY); +diff --git a/src/chrome/browser/ui/views/exclusive_access_bubble_views.h b/src/chrome/browser/ui/views/exclusive_access_bubble_views.h +index a519e4c476c..982da52cb50 +--- a/src/chrome/browser/ui/views/exclusive_access_bubble_views.h ++++ b/src/chrome/browser/ui/views/exclusive_access_bubble_views.h +@@ -48,11 +48,15 @@ class ExclusiveAccessBubbleViews : public ExclusiveAccessBubble, + ~ExclusiveAccessBubbleViews() override; + + // |force_update| indicates the caller wishes to show the bubble contents +- // regardless of whether the contents have changed. ++ // regardless of whether the contents have changed. |notify_download| ++ // indicates if the notification should be about a new download. Note that ++ // bubble_type may be an invalid one for notify_download, as we want to ++ // preserve the current type. + void UpdateContent( + const GURL& url, + ExclusiveAccessBubbleType bubble_type, + ExclusiveAccessBubbleHideCallback bubble_first_hide_callback, ++ bool notify_download, + bool force_update); + + // Repositions |popup_| if it is visible. +diff --git a/src/chrome/browser/ui/views/frame/browser_view.cc b/src/chrome/browser/ui/views/frame/browser_view.cc +index e01b2274119..41b486c5744 +--- a/src/chrome/browser/ui/views/frame/browser_view.cc ++++ b/src/chrome/browser/ui/views/frame/browser_view.cc +@@ -1557,7 +1557,9 @@ void BrowserView::UpdateExclusiveAccessExitBubbleContent( + const GURL& url, + ExclusiveAccessBubbleType bubble_type, + ExclusiveAccessBubbleHideCallback bubble_first_hide_callback, ++ bool notify_download, + bool force_update) { ++ DCHECK(!notify_download || exclusive_access_bubble_); + // Trusted pinned mode does not allow to escape. So do not show the bubble. + bool is_trusted_pinned = + platform_util::IsBrowserLockedFullscreen(browser_.get()); +@@ -1566,7 +1568,8 @@ void BrowserView::UpdateExclusiveAccessExitBubbleContent( + // top that gives the user a hover target. In a public session we show the + // bubble. + // TODO(jamescook): Figure out what to do with mouse-lock. +- if (is_trusted_pinned || bubble_type == EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE || ++ if (is_trusted_pinned || ++ (!notify_download && bubble_type == EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE) || + (ShouldUseImmersiveFullscreenForUrl(url) && + !profiles::IsPublicSession())) { + // |exclusive_access_bubble_.reset()| will trigger callback for current +@@ -1581,10 +1584,13 @@ void BrowserView::UpdateExclusiveAccessExitBubbleContent( + + if (exclusive_access_bubble_) { + exclusive_access_bubble_->UpdateContent( +- url, bubble_type, std::move(bubble_first_hide_callback), force_update); ++ url, bubble_type, std::move(bubble_first_hide_callback), ++ notify_download, force_update); + return; + } + ++ // Notification about download should only be considered for a bubble that ++ // exists already. + exclusive_access_bubble_ = std::make_unique( + this, url, bubble_type, std::move(bubble_first_hide_callback)); + } +@@ -3777,6 +3783,7 @@ void BrowserView::ProcessFullscreen(bool fullscreen, + if (fullscreen && !chrome::IsRunningInAppMode()) { + UpdateExclusiveAccessExitBubbleContent( + url, bubble_type, ExclusiveAccessBubbleHideCallback(), ++ /*notify_download=*/false, + /*force_update=*/swapping_screens_during_fullscreen); + } + +diff --git a/src/chrome/browser/ui/views/frame/browser_view.h b/src/chrome/browser/ui/views/frame/browser_view.h +index fe8b0cef883..cffb03a13d3 +--- a/src/chrome/browser/ui/views/frame/browser_view.h ++++ b/src/chrome/browser/ui/views/frame/browser_view.h +@@ -445,6 +445,7 @@ class BrowserView : public BrowserWindow, + const GURL& url, + ExclusiveAccessBubbleType bubble_type, + ExclusiveAccessBubbleHideCallback bubble_first_hide_callback, ++ bool notify_download, + bool force_update) override; + bool IsExclusiveAccessBubbleDisplayed() const override; + void OnExclusiveAccessUserInput() override; +diff --git a/src/chrome/browser/ui/views/frame/desktop_browser_frame_aura_linux.cc b/src/chrome/browser/ui/views/frame/desktop_browser_frame_aura_linux.cc +index 3c5df9deaa8..5bbb219c8a7 +--- a/src/chrome/browser/ui/views/frame/desktop_browser_frame_aura_linux.cc ++++ b/src/chrome/browser/ui/views/frame/desktop_browser_frame_aura_linux.cc +@@ -95,7 +95,14 @@ void DesktopBrowserFrameAuraLinux::TabDraggingKindChanged( + } + + bool DesktopBrowserFrameAuraLinux::ShouldDrawRestoredFrameShadow() const { ++#if !BUILDFLAG(IS_OHOS) + return host_->SupportsClientFrameShadow() && UseCustomFrame(); ++#else ++ LOG(INFO) ++ << "DesktopBrowserFrameAuraLinux::ShouldDrawRestoredFrameShadow TODO for " ++ "OS_OHOS"; ++ return false; ++#endif + } + + void DesktopBrowserFrameAuraLinux::OnUseCustomChromeFrameChanged() { +diff --git a/src/chrome/browser/ui/views/media_router/presentation_receiver_window_view.cc b/src/chrome/browser/ui/views/media_router/presentation_receiver_window_view.cc +index f658db6840f..a5819e5bbc5 +--- a/src/chrome/browser/ui/views/media_router/presentation_receiver_window_view.cc ++++ b/src/chrome/browser/ui/views/media_router/presentation_receiver_window_view.cc +@@ -308,6 +308,7 @@ void PresentationReceiverWindowView::EnterFullscreen( + #endif + UpdateExclusiveAccessExitBubbleContent(url, bubble_type, + ExclusiveAccessBubbleHideCallback(), ++ /*notify_download=*/false, + /*force_update=*/false); + } + +@@ -322,15 +323,18 @@ void PresentationReceiverWindowView::UpdateExclusiveAccessExitBubbleContent( + const GURL& url, + ExclusiveAccessBubbleType bubble_type, + ExclusiveAccessBubbleHideCallback bubble_first_hide_callback, ++ bool notify_download, + bool force_update) { ++ DCHECK(!notify_download || exclusive_access_bubble_); + #if BUILDFLAG(IS_CHROMEOS_ASH) + // On Chrome OS, we will not show the toast for the normal browser fullscreen + // mode. The 'F11' text is confusing since how to access F11 on a Chromebook + // is not common knowledge and there is also a dedicated fullscreen toggle + // button available. +- if (bubble_type == EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE || url.is_empty()) { ++ if ((!notify_download && bubble_type == EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE) || ++ url.is_empty()) { + #else +- if (bubble_type == EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE) { ++ if (!notify_download && bubble_type == EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE) { + #endif + // |exclusive_access_bubble_.reset()| will trigger callback for current + // bubble with |ExclusiveAccessBubbleHideReason::kInterrupted| if available. +@@ -344,7 +348,8 @@ void PresentationReceiverWindowView::UpdateExclusiveAccessExitBubbleContent( + + if (exclusive_access_bubble_) { + exclusive_access_bubble_->UpdateContent( +- url, bubble_type, std::move(bubble_first_hide_callback), force_update); ++ url, bubble_type, std::move(bubble_first_hide_callback), ++ notify_download, force_update); + return; + } + +diff --git a/src/chrome/browser/ui/views/media_router/presentation_receiver_window_view.h b/src/chrome/browser/ui/views/media_router/presentation_receiver_window_view.h +index 6db9051de92..d39a57a89f9 +--- a/src/chrome/browser/ui/views/media_router/presentation_receiver_window_view.h ++++ b/src/chrome/browser/ui/views/media_router/presentation_receiver_window_view.h +@@ -97,6 +97,7 @@ class PresentationReceiverWindowView final + const GURL& url, + ExclusiveAccessBubbleType bubble_type, + ExclusiveAccessBubbleHideCallback bubble_first_hide_callback, ++ bool notify_download, + bool force_update) final; + bool IsExclusiveAccessBubbleDisplayed() const final; + void OnExclusiveAccessUserInput() final; +diff --git a/src/chrome/browser/ui/views/payments/contact_info_editor_view_controller_browsertest.cc b/src/chrome/browser/ui/views/payments/contact_info_editor_view_controller_browsertest.cc +index b4c3352c0c2..9edbf919763 +--- a/src/chrome/browser/ui/views/payments/contact_info_editor_view_controller_browsertest.cc ++++ b/src/chrome/browser/ui/views/payments/contact_info_editor_view_controller_browsertest.cc +@@ -114,8 +114,8 @@ IN_PROC_BROWSER_TEST_F(MAYBE_PaymentRequestContactInfoEditorTest, + .WillOnce(QuitMessageLoop(&data_loop)); + views::View* editor_sheet = dialog_view()->GetViewByID( + static_cast(DialogViewID::CONTACT_INFO_EDITOR_SHEET)); +- editor_sheet->AcceleratorPressed( +- ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)); ++ EXPECT_TRUE(editor_sheet->AcceleratorPressed( ++ ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE))); + data_loop.Run(); + + personal_data_manager->RemoveObserver(&personal_data_observer_); +diff --git a/src/chrome/browser/ui/views/payments/editor_view_controller.cc b/src/chrome/browser/ui/views/payments/editor_view_controller.cc +index 9912efbfa32..1a37a326a03 +--- a/src/chrome/browser/ui/views/payments/editor_view_controller.cc ++++ b/src/chrome/browser/ui/views/payments/editor_view_controller.cc +@@ -162,6 +162,13 @@ void EditorViewController::FillContentView(views::View* content_view) { + content_view->AddChildView(CreateEditorView().release()); + } + ++bool EditorViewController::ShouldAccelerateEnterKey() { ++ // We allow the user to confirm their details by pressing 'enter' irregardless ++ // of which edit field is currently focused, for quicker navigation through ++ // the form. ++ return true; ++} ++ + void EditorViewController::UpdateEditorView() { + UpdateContentView(); + UpdateFocus(GetFirstFocusedView()); +diff --git a/src/chrome/browser/ui/views/payments/editor_view_controller.h b/src/chrome/browser/ui/views/payments/editor_view_controller.h +index 8eb180a42d1..0015e5a3066 +--- a/src/chrome/browser/ui/views/payments/editor_view_controller.h ++++ b/src/chrome/browser/ui/views/payments/editor_view_controller.h +@@ -155,6 +155,7 @@ class EditorViewController : public PaymentRequestSheetController, + bool GetPrimaryButtonEnabled() override; + bool ShouldShowSecondaryButton() override; + void FillContentView(views::View* content_view) override; ++ bool ShouldAccelerateEnterKey() override; + + // Combobox callback. + virtual void OnPerformAction(ValidatingCombobox* combobox); +diff --git a/src/chrome/browser/ui/views/payments/empty_update_browsertest.cc b/src/chrome/browser/ui/views/payments/empty_update_browsertest.cc +index 625a9b10a31..3512fd4dcc9 +--- a/src/chrome/browser/ui/views/payments/empty_update_browsertest.cc ++++ b/src/chrome/browser/ui/views/payments/empty_update_browsertest.cc +@@ -4,72 +4,17 @@ + + #include + +-#include "base/test/scoped_feature_list.h" + #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" + #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" + #include "components/autofill/core/browser/autofill_test_utils.h" +-#include "content/public/common/content_features.h" + #include "content/public/test/browser_test.h" + #include "testing/gtest/include/gtest/gtest.h" + + namespace payments { + +-class PaymentRequestEmptyUpdateTest : public PaymentRequestBrowserTestBase { +- public: +- PaymentRequestEmptyUpdateTest(const PaymentRequestEmptyUpdateTest&) = delete; +- PaymentRequestEmptyUpdateTest& operator=( +- const PaymentRequestEmptyUpdateTest&) = delete; +- +- protected: +- PaymentRequestEmptyUpdateTest() { +- feature_list_.InitAndEnableFeature(features::kPaymentRequestBasicCard); +- } +- +- private: +- base::test::ScopedFeatureList feature_list_; +-}; ++using PaymentRequestEmptyUpdateTest = PaymentRequestBrowserTestBase; + + IN_PROC_BROWSER_TEST_F(PaymentRequestEmptyUpdateTest, NoCrash) { +- NavigateTo("/payment_request_empty_update_test.html"); +- AddAutofillProfile(autofill::test::GetFullProfile()); +- InvokePaymentRequestUI(); +- OpenShippingAddressSectionScreen(); +- +- ResetEventWaiterForSequence({DialogEvent::PROCESSING_SPINNER_SHOWN, +- DialogEvent::PROCESSING_SPINNER_HIDDEN, +- DialogEvent::SPEC_DONE_UPDATING}); +- +- ClickOnChildInListViewAndWait( +- /* child_index=*/0, /*total_num_children=*/1, +- DialogViewID::SHIPPING_ADDRESS_SHEET_LIST_VIEW, +- /*wait_for_animation=*/false); +- +- // No crash indicates a successful test. +-} +- +-// The tests in this class correspond to the tests of the same name in +-// PaymentRequestEmptyUpdateTest, with the basic-card being disabled. +-// Parameterized tests are not used because the test setup for both tests are +-// too different. +-class PaymentRequestEmptyUpdateBasicCardDisabledTest +- : public PaymentRequestBrowserTestBase { +- public: +- PaymentRequestEmptyUpdateBasicCardDisabledTest( +- const PaymentRequestEmptyUpdateBasicCardDisabledTest&) = delete; +- PaymentRequestEmptyUpdateBasicCardDisabledTest& operator=( +- const PaymentRequestEmptyUpdateBasicCardDisabledTest&) = delete; +- +- protected: +- PaymentRequestEmptyUpdateBasicCardDisabledTest() { +- feature_list_.InitAndDisableFeature(features::kPaymentRequestBasicCard); +- } +- +- private: +- base::test::ScopedFeatureList feature_list_; +-}; +- +-IN_PROC_BROWSER_TEST_F(PaymentRequestEmptyUpdateBasicCardDisabledTest, +- NoCrash) { + // Installs two apps to ensure that the payment request UI is shown. + std::string a_method_name; + InstallPaymentApp("a.com", "payment_request_success_responder.js", +diff --git a/src/chrome/browser/ui/views/payments/error_message_view_controller.cc b/src/chrome/browser/ui/views/payments/error_message_view_controller.cc +index 5eb7f1d766b..28cc3dd1d60 +--- a/src/chrome/browser/ui/views/payments/error_message_view_controller.cc ++++ b/src/chrome/browser/ui/views/payments/error_message_view_controller.cc +@@ -93,4 +93,13 @@ void ErrorMessageViewController::FillContentView(views::View* content_view) { + content_view->AddChildView(std::make_unique()); + } + ++bool ErrorMessageViewController::GetSheetId(DialogViewID* sheet_id) { ++ *sheet_id = DialogViewID::ERROR_SHEET; ++ return true; ++} ++ ++bool ErrorMessageViewController::ShouldAccelerateEnterKey() { ++ return true; ++} ++ + } // namespace payments +diff --git a/src/chrome/browser/ui/views/payments/error_message_view_controller.h b/src/chrome/browser/ui/views/payments/error_message_view_controller.h +index f1556884183..46b24236959 +--- a/src/chrome/browser/ui/views/payments/error_message_view_controller.h ++++ b/src/chrome/browser/ui/views/payments/error_message_view_controller.h +@@ -44,6 +44,8 @@ class ErrorMessageViewController : public PaymentRequestSheetController { + bool ShouldShowSecondaryButton() override; + std::u16string GetSheetTitle() override; + void FillContentView(views::View* content_view) override; ++ bool GetSheetId(DialogViewID* sheet_id) override; ++ bool ShouldAccelerateEnterKey() override; + }; + + } // namespace payments +diff --git a/src/chrome/browser/ui/views/payments/error_message_view_controller_browsertest.cc b/src/chrome/browser/ui/views/payments/error_message_view_controller_browsertest.cc +index 3a37ad389aa..0e68f294e83 +--- a/src/chrome/browser/ui/views/payments/error_message_view_controller_browsertest.cc ++++ b/src/chrome/browser/ui/views/payments/error_message_view_controller_browsertest.cc +@@ -5,55 +5,35 @@ + #include + + #include "base/strings/utf_string_conversions.h" +-#include "base/test/scoped_feature_list.h" + #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" + #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" + #include "chrome/test/base/ui_test_utils.h" +-#include "components/autofill/core/browser/autofill_test_utils.h" +-#include "components/autofill/core/browser/data_model/credit_card.h" +-#include "content/public/common/content_features.h" + #include "content/public/test/browser_test.h" + #include "content/public/test/browser_test_utils.h" + + namespace payments { + +-class PaymentRequestErrorMessageTest : public PaymentRequestBrowserTestBase { +- public: +- PaymentRequestErrorMessageTest(const PaymentRequestErrorMessageTest&) = +- delete; +- PaymentRequestErrorMessageTest& operator=( +- const PaymentRequestErrorMessageTest&) = delete; +- +- protected: +- PaymentRequestErrorMessageTest() { +- feature_list_.InitAndEnableFeature(::features::kPaymentRequestBasicCard); +- } +- +- private: +- base::test::ScopedFeatureList feature_list_; +-}; ++using PaymentRequestErrorMessageTest = PaymentRequestBrowserTestBase; + + // Testing the use of the complete('fail') JS API and the error message. + IN_PROC_BROWSER_TEST_F(PaymentRequestErrorMessageTest, CompleteFail) { ++ std::string payment_method_name; ++ InstallPaymentApp("a.com", "payment_request_success_responder.js", ++ &payment_method_name); ++ + NavigateTo("/payment_request_fail_complete_test.html"); +- autofill::AutofillProfile billing_profile(autofill::test::GetFullProfile()); +- AddAutofillProfile(billing_profile); +- autofill::CreditCard card(autofill::test::GetCreditCard()); // Visa +- card.set_billing_address_id(billing_profile.guid()); +- AddCreditCard(card); +- InvokePaymentRequestUI(); ++ ++ InvokePaymentRequestUIWithJs("buyWithMethods([{supportedMethods:'" + ++ payment_method_name + "'}]);"); + + // We are ready to pay. + ASSERT_TRUE(IsPayButtonEnabled()); + + // Once "Pay" is clicked, the page will call complete('fail') and the error + // message should be shown. +- OpenCVCPromptWithCVC(u"123"); +- +- ResetEventWaiterForSequence({DialogEvent::PROCESSING_SPINNER_SHOWN, +- DialogEvent::PROCESSING_SPINNER_HIDDEN, ++ ResetEventWaiterForSequence({DialogEvent::PROCESSING_SPINNER_HIDDEN, + DialogEvent::ERROR_MESSAGE_SHOWN}); +- ClickOnDialogViewAndWait(DialogViewID::CVC_PROMPT_CONFIRM_BUTTON); ++ ClickOnDialogViewAndWait(DialogViewID::PAY_BUTTON, dialog_view()); + EXPECT_FALSE(dialog_view()->throbber_overlay_for_testing()->GetVisible()); + + // The user can only close the dialog at this point. +@@ -62,28 +42,10 @@ IN_PROC_BROWSER_TEST_F(PaymentRequestErrorMessageTest, CompleteFail) { + /*wait_for_animation=*/false); + } + +-class PaymentRequestErrorMessageBasicCardDisabledTest +- : public PaymentRequestBrowserTestBase { +- public: +- PaymentRequestErrorMessageBasicCardDisabledTest( +- const PaymentRequestErrorMessageTest&) = delete; +- PaymentRequestErrorMessageBasicCardDisabledTest& operator=( +- const PaymentRequestErrorMessageBasicCardDisabledTest&) = delete; +- +- protected: +- PaymentRequestErrorMessageBasicCardDisabledTest() { +- feature_list_.InitAndDisableFeature(::features::kPaymentRequestBasicCard); +- } +- +- private: +- base::test::ScopedFeatureList feature_list_; +-}; +- +-// Testing the use of the complete('fail') JS API and the error message. +-IN_PROC_BROWSER_TEST_F(PaymentRequestErrorMessageBasicCardDisabledTest, +- CompleteFail) { ++IN_PROC_BROWSER_TEST_F(PaymentRequestErrorMessageTest, ++ EnterKeyClosesErrorDialog) { + std::string payment_method_name; +- InstallPaymentApp("a.com", "payment_request_success_responder.js", ++ InstallPaymentApp("a.com", "/payment_request_success_responder.js", + &payment_method_name); + + NavigateTo("/payment_request_fail_complete_test.html"); +@@ -99,12 +61,15 @@ IN_PROC_BROWSER_TEST_F(PaymentRequestErrorMessageBasicCardDisabledTest, + ResetEventWaiterForSequence({DialogEvent::PROCESSING_SPINNER_HIDDEN, + DialogEvent::ERROR_MESSAGE_SHOWN}); + ClickOnDialogViewAndWait(DialogViewID::PAY_BUTTON, dialog_view()); +- EXPECT_FALSE(dialog_view()->throbber_overlay_for_testing()->GetVisible()); + +- // The user can only close the dialog at this point. ++ // Trigger the 'Enter' accelerator, which should be present and mapped to ++ // close the dialog. ++ views::View* error_sheet = ++ dialog_view()->GetViewByID(static_cast(DialogViewID::ERROR_SHEET)); + ResetEventWaiter(DialogEvent::DIALOG_CLOSED); +- ClickOnDialogViewAndWait(DialogViewID::CANCEL_BUTTON, +- /*wait_for_animation=*/false); ++ EXPECT_TRUE(error_sheet->AcceleratorPressed( ++ ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE))); ++ WaitForObservedEvent(); + } + + } // namespace payments +diff --git a/src/chrome/browser/ui/views/payments/order_summary_view_controller.cc b/src/chrome/browser/ui/views/payments/order_summary_view_controller.cc +index 734f551df45..800872f0678 +--- a/src/chrome/browser/ui/views/payments/order_summary_view_controller.cc ++++ b/src/chrome/browser/ui/views/payments/order_summary_view_controller.cc +@@ -209,4 +209,13 @@ void OrderSummaryViewController::FillContentView(views::View* content_view) { + .release()); + } + ++bool OrderSummaryViewController::GetSheetId(DialogViewID* sheet_id) { ++ *sheet_id = DialogViewID::ORDER_SUMMARY_SHEET; ++ return true; ++} ++ ++bool OrderSummaryViewController::ShouldAccelerateEnterKey() { ++ return true; ++} ++ + } // namespace payments +diff --git a/src/chrome/browser/ui/views/payments/order_summary_view_controller.h b/src/chrome/browser/ui/views/payments/order_summary_view_controller.h +index 39f480535eb..f07703853f2 +--- a/src/chrome/browser/ui/views/payments/order_summary_view_controller.h ++++ b/src/chrome/browser/ui/views/payments/order_summary_view_controller.h +@@ -44,6 +44,8 @@ class OrderSummaryViewController : public PaymentRequestSheetController, + bool ShouldShowSecondaryButton() override; + std::u16string GetSheetTitle() override; + void FillContentView(views::View* content_view) override; ++ bool GetSheetId(DialogViewID* sheet_id) override; ++ bool ShouldAccelerateEnterKey() override; + + base::WeakPtrFactory weak_ptr_factory_{this}; + }; +diff --git a/src/chrome/browser/ui/views/payments/order_summary_view_controller_browsertest.cc b/src/chrome/browser/ui/views/payments/order_summary_view_controller_browsertest.cc +index 379dfcea241..cc48443a51d +--- a/src/chrome/browser/ui/views/payments/order_summary_view_controller_browsertest.cc ++++ b/src/chrome/browser/ui/views/payments/order_summary_view_controller_browsertest.cc +@@ -5,36 +5,24 @@ + #include + + #include "base/strings/utf_string_conversions.h" +-#include "base/test/scoped_feature_list.h" + #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" + #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" + #include "components/autofill/core/browser/autofill_test_utils.h" + #include "components/autofill/core/browser/data_model/autofill_profile.h" +-#include "content/public/common/content_features.h" + #include "content/public/test/browser_test.h" + #include "testing/gtest/include/gtest/gtest.h" + + namespace payments { + +-class PaymentRequestOrderSummaryViewControllerTest +- : public PaymentRequestBrowserTestBase { +- public: +- PaymentRequestOrderSummaryViewControllerTest( +- const PaymentRequestOrderSummaryViewControllerTest&) = delete; +- PaymentRequestOrderSummaryViewControllerTest& operator=( +- const PaymentRequestOrderSummaryViewControllerTest&) = delete; +- +- protected: +- PaymentRequestOrderSummaryViewControllerTest() { +- feature_list_.InitAndEnableFeature(::features::kPaymentRequestBasicCard); +- } +- +- private: +- base::test::ScopedFeatureList feature_list_; +-}; ++using PaymentRequestOrderSummaryViewControllerTest = ++ PaymentRequestBrowserTestBase; + + IN_PROC_BROWSER_TEST_F(PaymentRequestOrderSummaryViewControllerTest, +- OrderSummaryReflectsShippingOption) { ++ EnterKeyCompletesPayment) { ++ std::string payment_method_name; ++ InstallPaymentApp("a.com", "/payment_request_success_responder.js", ++ &payment_method_name); ++ + NavigateTo("/payment_request_dynamic_shipping_test.html"); + // In MI state, shipping is $5.00. + autofill::AutofillProfile michigan = autofill::test::GetFullProfile2(); +@@ -45,22 +33,10 @@ IN_PROC_BROWSER_TEST_F(PaymentRequestOrderSummaryViewControllerTest, + california.set_use_count(50U); + AddAutofillProfile(california); + +- InvokePaymentRequestUI(); +- +- OpenOrderSummaryScreen(); +- +- // No address is selected. +- // Verify the expected amounts are shown ('Total', 'Pending Shipping Price' +- // and 'Subtotal', respectively). +- EXPECT_EQ(u"USD", +- GetLabelText(DialogViewID::ORDER_SUMMARY_TOTAL_CURRENCY_LABEL)); +- EXPECT_EQ(u"$5.00", +- GetLabelText(DialogViewID::ORDER_SUMMARY_TOTAL_AMOUNT_LABEL)); +- EXPECT_EQ(u"$0.00", GetLabelText(DialogViewID::ORDER_SUMMARY_LINE_ITEM_1)); +- EXPECT_EQ(u"$5.00", GetLabelText(DialogViewID::ORDER_SUMMARY_LINE_ITEM_2)); ++ InvokePaymentRequestUIWithJs("buyWithMethods([{supportedMethods:'" + ++ payment_method_name + "'}]);"); + +- // Go to the shipping address screen and select the first address (MI state). +- ClickOnBackArrow(); ++ // Select a shipping address in order to enable the Continue button. + OpenShippingAddressSectionScreen(); + ResetEventWaiterForSequence({DialogEvent::PROCESSING_SPINNER_SHOWN, + DialogEvent::PROCESSING_SPINNER_HIDDEN, +@@ -76,95 +52,23 @@ IN_PROC_BROWSER_TEST_F(PaymentRequestOrderSummaryViewControllerTest, + // updated) and this hits a DCHECK. + WaitForAnimation(); + +- // Michigan address is selected and has standard shipping. +- std::vector shipping_address_labels = GetProfileLabelValues( +- DialogViewID::PAYMENT_SHEET_SHIPPING_ADDRESS_SECTION); +- EXPECT_EQ(u"Jane A. Smith", shipping_address_labels[0]); +- EXPECT_EQ(u"ACME, 123 Main Street, Unit 1, Greensdale, MI 48838", +- shipping_address_labels[1]); +- EXPECT_EQ(u"+1 310-555-7889", shipping_address_labels[2]); +- std::vector shipping_option_labels = +- GetShippingOptionLabelValues( +- DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION); +- EXPECT_EQ(u"Standard shipping in US", shipping_option_labels[0]); +- EXPECT_EQ(u"$5.00", shipping_option_labels[1]); +- +- // Go back to Order Summary screen to see updated totals. +- OpenOrderSummaryScreen(); +- +- // Verify the expected amounts are shown ('Total', 'Standard shipping in US' +- // and 'Subtotal', respectively). +- EXPECT_EQ(u"USD", +- GetLabelText(DialogViewID::ORDER_SUMMARY_TOTAL_CURRENCY_LABEL)); +- EXPECT_EQ(u"$10.00", +- GetLabelText(DialogViewID::ORDER_SUMMARY_TOTAL_AMOUNT_LABEL)); +- EXPECT_EQ(u"$5.00", GetLabelText(DialogViewID::ORDER_SUMMARY_LINE_ITEM_1)); +- EXPECT_EQ(u"$5.00", GetLabelText(DialogViewID::ORDER_SUMMARY_LINE_ITEM_2)); +- +- // Go to the shipping address screen and select the second address (CA state). +- ClickOnBackArrow(); +- OpenShippingAddressSectionScreen(); +- ResetEventWaiterForSequence({DialogEvent::PROCESSING_SPINNER_SHOWN, +- DialogEvent::PROCESSING_SPINNER_HIDDEN, +- DialogEvent::SPEC_DONE_UPDATING, +- DialogEvent::BACK_NAVIGATION}); +- ClickOnChildInListViewAndWait( +- /* child_index=*/1, /*total_num_children=*/2, +- DialogViewID::SHIPPING_ADDRESS_SHEET_LIST_VIEW, +- /*wait_for_animation=*/false); +- // Wait for the animation here explicitly, otherwise +- // ClickOnChildInListViewAndWait tries to install an AnimationDelegate before +- // the animation is kicked off (since that's triggered off of the spec being +- // updated) and this hits a DCHECK. +- WaitForAnimation(); +- +- // California address is selected and has free shipping. +- shipping_address_labels = GetProfileLabelValues( +- DialogViewID::PAYMENT_SHEET_SHIPPING_ADDRESS_SECTION); +- EXPECT_EQ(u"John H. Doe", shipping_address_labels[0]); +- EXPECT_EQ(u"Underworld, 666 Erebus St., Apt 8, Elysium, CA 91111", +- shipping_address_labels[1]); +- EXPECT_EQ(u"+1 650-211-1111", shipping_address_labels[2]); +- shipping_option_labels = GetShippingOptionLabelValues( +- DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION); +- EXPECT_EQ(u"Free shipping in California", shipping_option_labels[0]); +- EXPECT_EQ(u"$0.00", shipping_option_labels[1]); +- +- // Go back to Order Summary screen to see updated totals. + OpenOrderSummaryScreen(); + +- // Verify the expected amounts are shown ('Total', +- // 'Free shipping in California' and 'Subtotal', respectively). +- EXPECT_EQ(u"USD", +- GetLabelText(DialogViewID::ORDER_SUMMARY_TOTAL_CURRENCY_LABEL)); +- EXPECT_EQ(u"$5.00", +- GetLabelText(DialogViewID::ORDER_SUMMARY_TOTAL_AMOUNT_LABEL)); +- EXPECT_EQ(u"$0.00", GetLabelText(DialogViewID::ORDER_SUMMARY_LINE_ITEM_1)); +- EXPECT_EQ(u"$5.00", GetLabelText(DialogViewID::ORDER_SUMMARY_LINE_ITEM_2)); ++ ASSERT_TRUE(IsPayButtonEnabled()); ++ ++ // Trigger the 'Enter' accelerator, which should be present and mapped to ++ // close the dialog. ++ views::View* summary_sheet = dialog_view()->GetViewByID( ++ static_cast(DialogViewID::ORDER_SUMMARY_SHEET)); ++ ResetEventWaiterForSequence( ++ {DialogEvent::PROCESSING_SPINNER_SHOWN, DialogEvent::DIALOG_CLOSED}); ++ EXPECT_TRUE(summary_sheet->AcceleratorPressed( ++ ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE))); ++ WaitForObservedEvent(); + } + +-class PaymentRequestOrderSummaryViewControllerBasicCardDisabledTest +- : public PaymentRequestBrowserTestBase { +- public: +- PaymentRequestOrderSummaryViewControllerBasicCardDisabledTest( +- const PaymentRequestOrderSummaryViewControllerBasicCardDisabledTest&) = +- delete; +- PaymentRequestOrderSummaryViewControllerBasicCardDisabledTest& operator=( +- const PaymentRequestOrderSummaryViewControllerBasicCardDisabledTest&) = +- delete; +- +- protected: +- PaymentRequestOrderSummaryViewControllerBasicCardDisabledTest() { +- feature_list_.InitAndDisableFeature(::features::kPaymentRequestBasicCard); +- } +- +- private: +- base::test::ScopedFeatureList feature_list_; +-}; +- +-IN_PROC_BROWSER_TEST_F( +- PaymentRequestOrderSummaryViewControllerBasicCardDisabledTest, +- OrderSummaryReflectsShippingOption) { ++IN_PROC_BROWSER_TEST_F(PaymentRequestOrderSummaryViewControllerTest, ++ OrderSummaryReflectsShippingOption) { + std::string payment_method_name; + InstallPaymentApp("a.com", "payment_request_success_responder.js", + &payment_method_name); + diff --git a/src/chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h b/src/chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h +index 5bc831c0b7c..d570f4f64b9 +--- a/src/chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h ++++ b/src/chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h +@@ -86,6 +86,9 @@ enum class DialogViewID : int { + // The following are the ids for the individual sheets. + CONTACT_INFO_EDITOR_SHEET, + CREDIT_CARD_EDITOR_SHEET, ++ ERROR_SHEET, ++ ORDER_SUMMARY_SHEET, ++ PAYMENT_REQUEST_SHEET, + CVC_UNMASK_SHEET, + SHIPPING_ADDRESS_EDITOR_SHEET, + +diff --git a/src/chrome/browser/ui/views/payments/payment_request_sheet_controller.cc b/src/chrome/browser/ui/views/payments/payment_request_sheet_controller.cc +index cd2fba1c3c7..ba9b7aac231 +--- a/src/chrome/browser/ui/views/payments/payment_request_sheet_controller.cc ++++ b/src/chrome/browser/ui/views/payments/payment_request_sheet_controller.cc +@@ -232,7 +232,7 @@ std::unique_ptr PaymentRequestSheetController::CreateView() { + auto view = + views::Builder( + std::make_unique( +- primary_button_ ++ ShouldAccelerateEnterKey() + ? base::BindRepeating(&PaymentRequestSheetController:: + PerformPrimaryButtonAction, + weak_ptr_factory_.GetWeakPtr()) +@@ -495,12 +495,8 @@ std::unique_ptr PaymentRequestSheetController::CreateFooterView() { + } + + views::View* PaymentRequestSheetController::GetFirstFocusedView() { +- if (primary_button_ && primary_button_->GetEnabled()) +- return primary_button_; +- +- if (secondary_button_) +- return secondary_button_; +- ++ // Do not focus either of the buttons, per guidelines in ++ // docs/security/security-considerations-for-browser-ui.md + DCHECK(content_view_); + return content_view_; + } +@@ -513,6 +509,12 @@ bool PaymentRequestSheetController::DisplayDynamicBorderForHiddenContents() { + return true; + } + ++bool PaymentRequestSheetController::ShouldAccelerateEnterKey() { ++ // Subclasses must explicitly opt-into this behavior. Be aware of the risks of ++ // enabling click-jacking of the Enter key; see https://crbug.com/1403539 ++ return false; ++} ++ + void PaymentRequestSheetController::CloseButtonPressed() { + if (dialog()->IsInteractive()) + dialog()->CloseDialog(); +diff --git a/src/chrome/browser/ui/views/payments/payment_request_sheet_controller.h b/src/chrome/browser/ui/views/payments/payment_request_sheet_controller.h +index 59629669dc8..8a77184f5eb +--- a/src/chrome/browser/ui/views/payments/payment_request_sheet_controller.h ++++ b/src/chrome/browser/ui/views/payments/payment_request_sheet_controller.h +@@ -156,6 +156,12 @@ class PaymentRequestSheetController { + // Returns true to display dynamic top and bottom border for hidden contents. + virtual bool DisplayDynamicBorderForHiddenContents(); + ++ // Returns true if the subclass wants the 'Enter' key to be accelerated to ++ // always map to performing the primary button action (irregardless of the ++ // currently focused element). If a subclass returns true for this, it must ++ // also return true for ShouldShowPrimaryButton. ++ virtual bool ShouldAccelerateEnterKey(); ++ + void CloseButtonPressed(); + + views::MdTextButton* primary_button() { return primary_button_; } +diff --git a/src/chrome/browser/ui/views/payments/payment_request_shipping_address_instance_browsertest.cc b/src/chrome/browser/ui/views/payments/payment_request_shipping_address_instance_browsertest.cc +index cde7e18d73b..b52c90f687e +--- a/src/chrome/browser/ui/views/payments/payment_request_shipping_address_instance_browsertest.cc ++++ b/src/chrome/browser/ui/views/payments/payment_request_shipping_address_instance_browsertest.cc +@@ -3,83 +3,20 @@ + // found in the LICENSE file. + + #include "base/strings/utf_string_conversions.h" +-#include "base/test/scoped_feature_list.h" + #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" + #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" + #include "components/autofill/core/browser/autofill_test_utils.h" + #include "components/autofill/core/browser/data_model/autofill_profile.h" +-#include "components/autofill/core/browser/data_model/credit_card.h" +-#include "content/public/common/content_features.h" + #include "content/public/test/browser_test.h" + + namespace payments { + namespace { + +-class PaymentRequestShippingAddressInstanceTest +- : public PaymentRequestBrowserTestBase { +- public: +- PaymentRequestShippingAddressInstanceTest( +- const PaymentRequestShippingAddressInstanceTest&) = delete; +- PaymentRequestShippingAddressInstanceTest& operator=( +- const PaymentRequestShippingAddressInstanceTest&) = delete; +- +- protected: +- PaymentRequestShippingAddressInstanceTest() { +- feature_list_.InitWithFeatures({::features::kPaymentRequestBasicCard}, {}); +- } +- +- private: +- base::test::ScopedFeatureList feature_list_; +-}; ++using PaymentRequestShippingAddressInstanceTest = PaymentRequestBrowserTestBase; + + // If the page creates multiple PaymentRequest objects, it should not crash. + IN_PROC_BROWSER_TEST_F(PaymentRequestShippingAddressInstanceTest, + ShouldBeSameInstance) { +- NavigateTo("/payment_request_shipping_address_instance_test.html"); +- autofill::AutofillProfile billing_address = autofill::test::GetFullProfile(); +- AddAutofillProfile(billing_address); +- autofill::CreditCard card = autofill::test::GetCreditCard(); +- card.set_billing_address_id(billing_address.guid()); +- AddCreditCard(card); +- +- InvokePaymentRequestUI(); +- +- ResetEventWaiter(DialogEvent::DIALOG_CLOSED); +- +- PayWithCreditCardAndWait(u"123"); +- +- WaitForObservedEvent(); +- +- ExpectBodyContains({"Same instance: true"}); +-} +- +-// The tests in this class correspond to the tests of the same name in +-// PaymentRequestShippingAddressInstanceTest, but with basic-card disabled. +-// Parameterized tests are not used because the test setup for both tests are +-// too different. +-class PaymentRequestShippingAddressInstanceBasicCardDisabledTest +- : public PaymentRequestBrowserTestBase { +- public: +- PaymentRequestShippingAddressInstanceBasicCardDisabledTest( +- const PaymentRequestShippingAddressInstanceBasicCardDisabledTest&) = +- delete; +- PaymentRequestShippingAddressInstanceBasicCardDisabledTest& operator=( +- const PaymentRequestShippingAddressInstanceBasicCardDisabledTest&) = +- delete; +- +- protected: +- PaymentRequestShippingAddressInstanceBasicCardDisabledTest() { +- feature_list_.InitWithFeatures({}, {::features::kPaymentRequestBasicCard}); +- } +- +- private: +- base::test::ScopedFeatureList feature_list_; +-}; +- +-// If the page creates multiple PaymentRequest objects, it should not crash. +-IN_PROC_BROWSER_TEST_F( +- PaymentRequestShippingAddressInstanceBasicCardDisabledTest, +- ShouldBeSameInstance) { + std::string payment_method_name; + InstallPaymentApp("a.com", "payment_request_success_responder.js", + &payment_method_name); +diff --git a/src/chrome/browser/ui/views/payments/payment_sheet_view_controller.cc b/src/chrome/browser/ui/views/payments/payment_sheet_view_controller.cc +index f49e84de237..e5f9de88e96 +--- a/src/chrome/browser/ui/views/payments/payment_sheet_view_controller.cc ++++ b/src/chrome/browser/ui/views/payments/payment_sheet_view_controller.cc +@@ -463,6 +463,11 @@ PaymentSheetViewController::CreateExtraFooterView() { + return CreateProductLogoFooterView(); + } + ++bool PaymentSheetViewController::GetSheetId(DialogViewID* sheet_id) { ++ *sheet_id = DialogViewID::PAYMENT_REQUEST_SHEET; ++ return true; ++} ++ + // Creates the Order Summary row, which contains an "Order Summary" label, + // an inline list of display items, a Total Amount label, and a Chevron. Returns + // nullptr if WeakPtr has become null. +diff --git a/src/chrome/browser/ui/views/payments/payment_sheet_view_controller.h b/src/chrome/browser/ui/views/payments/payment_sheet_view_controller.h +index 2024a0d0849..4c2382233c2 +--- a/src/chrome/browser/ui/views/payments/payment_sheet_view_controller.h ++++ b/src/chrome/browser/ui/views/payments/payment_sheet_view_controller.h +@@ -51,6 +51,7 @@ class PaymentSheetViewController : public PaymentRequestSheetController, + std::u16string GetSheetTitle() override; + void FillContentView(views::View* content_view) override; + std::unique_ptr CreateExtraFooterView() override; ++ bool GetSheetId(DialogViewID* sheet_id) override; + + // These functions create the various sections and rows of the payment sheet. + // Where applicable, they also populate |accessible_content|, which shouldn't +diff --git a/src/chrome/browser/ui/views/payments/payment_sheet_view_controller_browsertest.cc b/src/chrome/browser/ui/views/payments/payment_sheet_view_controller_browsertest.cc +index 1f57c1ed2a4..9af1047b8a4 +--- a/src/chrome/browser/ui/views/payments/payment_sheet_view_controller_browsertest.cc ++++ b/src/chrome/browser/ui/views/payments/payment_sheet_view_controller_browsertest.cc +@@ -63,6 +63,66 @@ IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerNoShippingTest, + EXPECT_FALSE(IsPayButtonEnabled()); + } + ++using PaymentSheetViewControllerTest = PaymentRequestBrowserTestBase; ++ ++// The 'Continue' or 'Cancel' buttons should not be auto-focused; see ++// https://crbug.com/1403539 ++IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerTest, ++ ContinueIsNotAutoFocused) { ++ // Installs two apps so that the Payment Request UI will be shown. ++ std::string a_method_name; ++ InstallPaymentApp("a.com", "/payment_request_success_responder.js", ++ &a_method_name); ++ std::string b_method_name; ++ InstallPaymentApp("b.com", "/payment_request_success_responder.js", ++ &b_method_name); ++ ++ NavigateTo("/payment_request_no_shipping_test.html"); ++ InvokePaymentRequestUIWithJs(content::JsReplace( ++ "buyWithMethods([{supportedMethods:$1}, {supportedMethods:$2}]);", ++ a_method_name, b_method_name)); ++ ++ EXPECT_TRUE(IsViewVisible(DialogViewID::PAY_BUTTON)); ++ EXPECT_TRUE(IsViewVisible(DialogViewID::CANCEL_BUTTON)); ++ EXPECT_TRUE(IsPayButtonEnabled()); ++ ++ // Neither of the actionable buttons should receive default focus. ++ EXPECT_FALSE(dialog_view() ++ ->GetViewByID(static_cast(DialogViewID::PAY_BUTTON)) ++ ->HasFocus()); ++ EXPECT_FALSE(dialog_view() ++ ->GetViewByID(static_cast(DialogViewID::CANCEL_BUTTON)) ++ ->HasFocus()); ++} ++ ++// The Enter key should not be accelerated for the main payment sheet; see ++// https://crbug.com/1403539 ++IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerTest, EnterDoesNotContinue) { ++ // Installs two apps so that the Payment Request UI will be shown. ++ std::string a_method_name; ++ InstallPaymentApp("a.com", "/payment_request_success_responder.js", ++ &a_method_name); ++ std::string b_method_name; ++ InstallPaymentApp("b.com", "/payment_request_success_responder.js", ++ &b_method_name); ++ ++ NavigateTo("/payment_request_no_shipping_test.html"); ++ InvokePaymentRequestUIWithJs(content::JsReplace( ++ "buyWithMethods([{supportedMethods:$1}, {supportedMethods:$2}]);", ++ a_method_name, b_method_name)); ++ ++ EXPECT_TRUE(IsViewVisible(DialogViewID::PAY_BUTTON)); ++ EXPECT_TRUE(IsViewVisible(DialogViewID::CANCEL_BUTTON)); ++ EXPECT_TRUE(IsPayButtonEnabled()); ++ ++ // Trigger the 'Enter' accelerator - this should NOT be present and the ++ // dispatch should fail. ++ views::View* summary_sheet = dialog_view()->GetViewByID( ++ static_cast(DialogViewID::PAYMENT_REQUEST_SHEET)); ++ EXPECT_FALSE(summary_sheet->AcceleratorPressed( ++ ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE))); ++} ++ + // If shipping and contact info are not requested, their rows should not be + // present. + IN_PROC_BROWSER_TEST_F(PaymentSheetViewControllerNoShippingTest, +@@ -112,13 +172,18 @@ class PaymentSheetViewControllerNoShippingBasicCardDisabledTest + IN_PROC_BROWSER_TEST_F( + PaymentSheetViewControllerNoShippingBasicCardDisabledTest, + NoShippingNoContactRows) { +- std::string payment_method_name; ++ // Installs two apps so that the Payment Request UI will be shown. ++ std::string a_method_name; + InstallPaymentApp("a.com", "payment_request_success_responder.js", +- &payment_method_name); ++ &a_method_name); ++ std::string b_method_name; ++ InstallPaymentApp("b.com", "/payment_request_success_responder.js", ++ &b_method_name); + + NavigateTo("/payment_request_no_shipping_test.html"); +- InvokePaymentRequestUIWithJs("buyWithMethods([{supportedMethods:'" + +- payment_method_name + "'}]);"); ++ InvokePaymentRequestUIWithJs(content::JsReplace( ++ "buyWithMethods([{supportedMethods:$1}, {supportedMethods:$2}]);", ++ a_method_name, b_method_name)); + + EXPECT_NE(nullptr, dialog_view()->GetViewByID(static_cast( + DialogViewID::PAYMENT_SHEET_SUMMARY_SECTION))); +diff --git a/src/chrome/browser/ui/views/payments/profile_list_view_controller_browsertest.cc b/src/chrome/browser/ui/views/payments/profile_list_view_controller_browsertest.cc +index b50e2c2ab6c..5cfa2d99911 +--- a/src/chrome/browser/ui/views/payments/profile_list_view_controller_browsertest.cc ++++ b/src/chrome/browser/ui/views/payments/profile_list_view_controller_browsertest.cc +@@ -4,14 +4,12 @@ + + #include "base/guid.h" + #include "base/strings/utf_string_conversions.h" +-#include "base/test/scoped_feature_list.h" + #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" + #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" + #include "components/autofill/core/browser/autofill_test_utils.h" + #include "components/autofill/core/browser/data_model/autofill_profile.h" + #include "components/autofill/core/browser/field_types.h" + #include "components/autofill/core/browser/personal_data_manager.h" +-#include "content/public/common/content_features.h" + #include "content/public/test/browser_test.h" + #include "ui/views/controls/label.h" + +@@ -28,77 +26,9 @@ autofill::AutofillProfile CreateProfileWithPartialAddress() { + return profile; + } + +-class PaymentRequestProfileListTest : public PaymentRequestBrowserTestBase { +- protected: +- PaymentRequestProfileListTest() { +- feature_list_.InitAndEnableFeature(::features::kPaymentRequestBasicCard); +- } +- +- private: +- base::test::ScopedFeatureList feature_list_; +-}; ++using PaymentRequestProfileListTest = PaymentRequestBrowserTestBase; + + IN_PROC_BROWSER_TEST_F(PaymentRequestProfileListTest, PrioritizeCompleteness) { +- NavigateTo("/payment_request_free_shipping_test.html"); +- autofill::AutofillProfile complete = autofill::test::GetFullProfile(); +- autofill::AutofillProfile partial = CreateProfileWithPartialAddress(); +- complete.FinalizeAfterImport(); +- partial.FinalizeAfterImport(); +- partial.set_use_count(1000); +- +- AddAutofillProfile(complete); +- AddAutofillProfile(partial); +- +- // In the Personal Data Manager, the partial address is more frecent. +- autofill::PersonalDataManager* personal_data_manager = GetDataManager(); +- std::vector profiles = +- personal_data_manager->GetProfilesToSuggest(); +- ASSERT_EQ(2UL, profiles.size()); +- EXPECT_EQ(partial, *profiles[0]); +- EXPECT_EQ(complete, *profiles[1]); +- +- InvokePaymentRequestUI(); +- +- PaymentRequest* request = GetPaymentRequests().front(); +- +- // The complete profile should be selected. +- ASSERT_TRUE(request->state()->selected_shipping_profile()); +- EXPECT_EQ(complete, *request->state()->selected_shipping_profile()); +- +- // It should appear first in the shipping profiles. +- ASSERT_EQ(2UL, request->state()->shipping_profiles().size()); +- EXPECT_EQ(complete, *request->state()->shipping_profiles()[0]); +- EXPECT_EQ(partial, *request->state()->shipping_profiles()[1]); +- +- // And both should appear in the UI. +- OpenShippingAddressSectionScreen(); +- views::View* sheet = dialog_view()->GetViewByID( +- static_cast(DialogViewID::SHIPPING_ADDRESS_SHEET_LIST_VIEW)); +- ASSERT_EQ(2u, sheet->children().size()); +- const auto get_label = [sheet](size_t num) { +- constexpr int kId = static_cast(DialogViewID::PROFILE_LABEL_LINE_1); +- return static_cast(sheet->children()[num]->GetViewByID(kId)); +- }; +- EXPECT_EQ(u"John H. Doe", get_label(0)->GetText()); +- EXPECT_EQ(u"Jane A. Smith", get_label(1)->GetText()); +-} +- +-// The tests in this class correspond to the tests of the same name in +-// PaymentRequestProfileListTest, but with basic-card disabled. Parameterized +-// tests are not used because the test setup for both tests are too different. +-class PaymentRequestProfileListBasicCardDisabledTest +- : public PaymentRequestBrowserTestBase { +- protected: +- PaymentRequestProfileListBasicCardDisabledTest() { +- feature_list_.InitAndDisableFeature(::features::kPaymentRequestBasicCard); +- } +- +- private: +- base::test::ScopedFeatureList feature_list_; +-}; +- +-IN_PROC_BROWSER_TEST_F(PaymentRequestProfileListBasicCardDisabledTest, +- PrioritizeCompleteness) { + std::string payment_method_name; + InstallPaymentApp("a.com", "payment_request_success_responder.js", + &payment_method_name); +diff --git a/src/chrome/browser/ui/views/payments/shipping_address_editor_view_controller_browsertest.cc b/src/chrome/browser/ui/views/payments/shipping_address_editor_view_controller_browsertest.cc +index 8887e8aabce..0490e2a9bde +--- a/src/chrome/browser/ui/views/payments/shipping_address_editor_view_controller_browsertest.cc ++++ b/src/chrome/browser/ui/views/payments/shipping_address_editor_view_controller_browsertest.cc +@@ -281,8 +281,8 @@ IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest, + .WillOnce(QuitMessageLoop(&data_loop)); + views::View* editor_sheet = dialog_view()->GetViewByID( + static_cast(DialogViewID::SHIPPING_ADDRESS_EDITOR_SHEET)); +- editor_sheet->AcceleratorPressed( +- ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)); ++ EXPECT_TRUE(editor_sheet->AcceleratorPressed( ++ ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE))); + data_loop.Run(); + + personal_data_manager->RemoveObserver(&personal_data_observer_); +diff --git a/src/chrome/browser/ui/views/payments/shipping_option_view_controller_browsertest.cc b/src/chrome/browser/ui/views/payments/shipping_option_view_controller_browsertest.cc +index 8e79ed15e0b..662096b9964 +--- a/src/chrome/browser/ui/views/payments/shipping_option_view_controller_browsertest.cc ++++ b/src/chrome/browser/ui/views/payments/shipping_option_view_controller_browsertest.cc +@@ -5,147 +5,21 @@ + #include + + #include "base/strings/utf_string_conversions.h" +-#include "base/test/scoped_feature_list.h" + #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" + #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" + #include "components/autofill/core/browser/autofill_test_utils.h" + #include "components/autofill/core/browser/data_model/autofill_profile.h" + #include "components/autofill/core/browser/field_types.h" +-#include "content/public/common/content_features.h" + #include "content/public/test/browser_test.h" + #include "testing/gtest/include/gtest/gtest.h" + + namespace payments { + +-class PaymentRequestShippingOptionViewControllerTest +- : public PaymentRequestBrowserTestBase { +- public: +- PaymentRequestShippingOptionViewControllerTest( +- const PaymentRequestShippingOptionViewControllerTest&) = delete; +- PaymentRequestShippingOptionViewControllerTest& operator=( +- const PaymentRequestShippingOptionViewControllerTest&) = delete; +- +- protected: +- PaymentRequestShippingOptionViewControllerTest() { +- feature_list_.InitAndEnableFeature(::features::kPaymentRequestBasicCard); +- } +- +- private: +- base::test::ScopedFeatureList feature_list_; +-}; ++using PaymentRequestShippingOptionViewControllerTest = ++ PaymentRequestBrowserTestBase; + + IN_PROC_BROWSER_TEST_F(PaymentRequestShippingOptionViewControllerTest, + SelectingVariousShippingOptions) { +- NavigateTo("/payment_request_dynamic_shipping_test.html"); +- // In MI state, shipping is $5.00. +- autofill::AutofillProfile michigan = autofill::test::GetFullProfile2(); +- michigan.set_use_count(100U); +- AddAutofillProfile(michigan); +- // A Canadian address will have no shipping options. +- autofill::AutofillProfile canada = autofill::test::GetFullProfile(); +- canada.SetRawInfo(autofill::ADDRESS_HOME_COUNTRY, u"CA"); +- canada.set_use_count(50U); +- AddAutofillProfile(canada); +- +- InvokePaymentRequestUI(); +- +- // There is no shipping option section, because no address has been selected. +- PaymentRequest* request = GetPaymentRequests().front(); +- EXPECT_EQ(2U, request->state()->shipping_profiles().size()); +- EXPECT_EQ(nullptr, request->state()->selected_shipping_profile()); +- EXPECT_EQ(nullptr, dialog_view()->GetViewByID(static_cast( +- DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION))); +- EXPECT_EQ(nullptr, +- dialog_view()->GetViewByID(static_cast( +- DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION_BUTTON))); +- +- // Go to the shipping address screen and select the first address (MI state). +- OpenShippingAddressSectionScreen(); +- EXPECT_EQ(u"To see shipping methods and requirements, select an address", +- GetLabelText(DialogViewID::WARNING_LABEL)); +- +- ResetEventWaiterForSequence({DialogEvent::PROCESSING_SPINNER_SHOWN, +- DialogEvent::PROCESSING_SPINNER_HIDDEN, +- DialogEvent::SPEC_DONE_UPDATING, +- DialogEvent::BACK_NAVIGATION}); +- ClickOnChildInListViewAndWait( +- /* child_index=*/0, /*total_num_children=*/2, +- DialogViewID::SHIPPING_ADDRESS_SHEET_LIST_VIEW, +- /*wait_for_animation=*/false); +- // Wait for the animation here explicitly, otherwise +- // ClickOnChildInListViewAndWait tries to install an AnimationDelegate before +- // the animation is kicked off (since that's triggered off of the spec being +- // updated) and this hits a DCHECK. +- WaitForAnimation(); +- +- // Michigan address is selected and has standard shipping. +- std::vector shipping_address_labels = GetProfileLabelValues( +- DialogViewID::PAYMENT_SHEET_SHIPPING_ADDRESS_SECTION); +- EXPECT_EQ(u"Jane A. Smith", shipping_address_labels[0]); +- EXPECT_EQ(u"ACME, 123 Main Street, Unit 1, Greensdale, MI 48838", +- shipping_address_labels[1]); +- EXPECT_EQ(u"+1 310-555-7889", shipping_address_labels[2]); +- +- // The shipping option section exists, and the shipping option is shown. +- std::vector shipping_option_labels = +- GetShippingOptionLabelValues( +- DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION); +- EXPECT_EQ(u"Standard shipping in US", shipping_option_labels[0]); +- EXPECT_EQ(u"$5.00", shipping_option_labels[1]); +- +- // Go to the shipping address screen and select the second address (Canada). +- OpenShippingAddressSectionScreen(); +- ResetEventWaiterForSequence({DialogEvent::PROCESSING_SPINNER_SHOWN, +- DialogEvent::PROCESSING_SPINNER_HIDDEN, +- DialogEvent::SPEC_DONE_UPDATING}); +- ClickOnChildInListViewAndWait( +- /* child_index=*/1, /*total_num_children=*/2, +- DialogViewID::SHIPPING_ADDRESS_SHEET_LIST_VIEW, false); +- +- // Now no address is selected. +- EXPECT_EQ(nullptr, request->state()->selected_shipping_profile()); +- EXPECT_EQ(request->state()->shipping_profiles().back(), +- request->state()->selected_shipping_option_error_profile()); +- +- // The address selector has this error. +- EXPECT_EQ(u"We do not ship to this address", +- GetLabelText(DialogViewID::WARNING_LABEL)); +- +- // There is no a longer shipping option section, because no shipping options +- // are available for Canada. +- EXPECT_EQ(nullptr, dialog_view()->GetViewByID(static_cast( +- DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION))); +- EXPECT_EQ(nullptr, +- dialog_view()->GetViewByID(static_cast( +- DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION_BUTTON))); +-} +- +-// The tests in this class correspond to the tests of the same name in +-// PaymentRequestShippingOptionViewControllerTest, with basic-card disabled. +-// Parameterized tests are not used because the test setup for both tests are +-// too different. +-class PaymentRequestShippingOptionViewControllerBasicCardDisabledTest +- : public PaymentRequestBrowserTestBase { +- public: +- PaymentRequestShippingOptionViewControllerBasicCardDisabledTest( +- const PaymentRequestShippingOptionViewControllerBasicCardDisabledTest&) = +- delete; +- PaymentRequestShippingOptionViewControllerBasicCardDisabledTest& operator=( +- const PaymentRequestShippingOptionViewControllerBasicCardDisabledTest&) = +- delete; +- +- protected: +- PaymentRequestShippingOptionViewControllerBasicCardDisabledTest() { +- feature_list_.InitAndDisableFeature(::features::kPaymentRequestBasicCard); +- } +- +- private: +- base::test::ScopedFeatureList feature_list_; +-}; +- +-IN_PROC_BROWSER_TEST_F( +- PaymentRequestShippingOptionViewControllerBasicCardDisabledTest, +- SelectingVariousShippingOptions) { + // Installs two apps so that the Payment Request UI will be shown. + std::string a_method_name; + InstallPaymentApp("a.com", "payment_request_success_responder.js", +diff --git a/src/chrome/browser/ui/views/web_apps/pwa_confirmation_bubble_view.cc b/src/chrome/browser/ui/views/web_apps/pwa_confirmation_bubble_view.cc +index 1fd45db06a1..5660f45b521 +--- a/src/chrome/browser/ui/views/web_apps/pwa_confirmation_bubble_view.cc ++++ b/src/chrome/browser/ui/views/web_apps/pwa_confirmation_bubble_view.cc +@@ -167,6 +167,8 @@ PWAConfirmationBubbleView::PWAConfirmationBubbleView( + + chrome::RecordDialogCreation(chrome::DialogIdentifier::PWA_CONFIRMATION); + ++ SetDefaultButton(ui::DIALOG_BUTTON_CANCEL); ++ + SetHighlightedButton(highlight_button); + } + +diff --git a/src/chrome/browser/ui/webui/history/foreign_session_handler.cc b/src/chrome/browser/ui/webui/history/foreign_session_handler.cc +index 8faf9ee5fc6..b8eabf0e2bd +--- a/src/chrome/browser/ui/webui/history/foreign_session_handler.cc ++++ b/src/chrome/browser/ui/webui/history/foreign_session_handler.cc +@@ -149,15 +149,12 @@ void ForeignSessionHandler::RegisterProfilePrefs( + void ForeignSessionHandler::OpenForeignSessionTab( + content::WebUI* web_ui, + const std::string& session_string_value, +- int window_num, + SessionID tab_id, + const WindowOpenDisposition& disposition) { + sync_sessions::OpenTabsUIDelegate* open_tabs = GetOpenTabsUIDelegate(web_ui); + if (!open_tabs) + return; + +- // We don't actually care about |window_num|, this is just a sanity check. +- DCHECK_LE(0, window_num); + const ::sessions::SessionTab* tab; + if (!open_tabs->GetForeignTab(session_string_value, tab_id, &tab)) { + LOG(ERROR) << "Failed to load foreign tab."; +@@ -175,7 +172,7 @@ void ForeignSessionHandler::OpenForeignSessionTab( + void ForeignSessionHandler::OpenForeignSessionWindows( + content::WebUI* web_ui, + const std::string& session_string_value, +- int window_num) { ++ size_t window_num) { + sync_sessions::OpenTabsUIDelegate* open_tabs = GetOpenTabsUIDelegate(web_ui); + if (!open_tabs) + return; +@@ -187,14 +184,13 @@ void ForeignSessionHandler::OpenForeignSessionWindows( + "OpenTabsUIDelegate."; + return; + } +- std::vector::const_iterator iter_begin = +- windows.begin() + (window_num < 0 ? 0 : window_num); +- auto iter_end = +- window_num < 0 +- ? std::vector::const_iterator( +- windows.end()) +- : iter_begin + 1; + ++ // Bounds check `window_num` before using it anywhere. crbug.com/1408120 ++ CHECK_LT(window_num, windows.size()); ++ auto iter_begin = windows.begin() + window_num; ++ DCHECK(iter_begin != windows.end()) ++ << "Because we CHECKed that windows_num is less than the size."; ++ auto iter_end = iter_begin + 1; + SessionRestore::RestoreForeignSessionWindows(Profile::FromWebUI(web_ui), + iter_begin, iter_end); + +@@ -378,10 +374,10 @@ void ForeignSessionHandler::HandleOpenForeignSession( + const std::string& session_string_value = args->GetList()[0].GetString(); + + // Extract window number. +- int window_num = -1; ++ size_t window_num = 0; + if (num_args >= 2 && + (!args->GetList()[1].is_string() || +- !base::StringToInt(args->GetList()[1].GetString(), &window_num))) { ++ !base::StringToSizeT(args->GetList()[1].GetString(), &window_num))) { + LOG(ERROR) << "Failed to extract window number."; + return; + } +@@ -398,8 +394,7 @@ void ForeignSessionHandler::HandleOpenForeignSession( + SessionID tab_id = SessionID::FromSerializedValue(tab_id_value); + if (tab_id.is_valid()) { + WindowOpenDisposition disposition = webui::GetDispositionFromClick(args, 3); +- OpenForeignSessionTab(web_ui(), session_string_value, window_num, tab_id, +- disposition); ++ OpenForeignSessionTab(web_ui(), session_string_value, tab_id, disposition); + } else { + OpenForeignSessionWindows(web_ui(), session_string_value, window_num); + } +diff --git a/src/chrome/browser/ui/webui/history/foreign_session_handler.h b/src/chrome/browser/ui/webui/history/foreign_session_handler.h +index b4659c32f21..8bbd3929737 +--- a/src/chrome/browser/ui/webui/history/foreign_session_handler.h ++++ b/src/chrome/browser/ui/webui/history/foreign_session_handler.h +@@ -65,13 +65,12 @@ class ForeignSessionHandler : public content::WebUIMessageHandler { + + static void OpenForeignSessionTab(content::WebUI* web_ui, + const std::string& session_string_value, +- int window_num, + SessionID tab_id, + const WindowOpenDisposition& disposition); + + static void OpenForeignSessionWindows(content::WebUI* web_ui, + const std::string& session_string_value, +- int window_num); ++ size_t window_num); + + // Returns a pointer to the current session model associator or nullptr. + static sync_sessions::OpenTabsUIDelegate* GetOpenTabsUIDelegate( +diff --git a/src/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc b/src/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc +index 4b32cffd863..b16f343af21 +--- a/src/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc ++++ b/src/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc +@@ -258,11 +258,12 @@ void ClearBrowsingDataHandler::HandleClearBrowsingData( + base::Value::ConstListView data_type_list = args_list[1].GetList(); + for (const base::Value& type : data_type_list) { + const std::string pref_name = type.GetString(); +- BrowsingDataType data_type = ++ absl::optional data_type = + browsing_data::GetDataTypeFromDeletionPreference(pref_name); +- data_type_vector.push_back(data_type); ++ CHECK(data_type); ++ data_type_vector.push_back(*data_type); + +- switch (data_type) { ++ switch (*data_type) { + case BrowsingDataType::HISTORY: + if (prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory)) + remove_mask |= chrome_browsing_data_remover::DATA_TYPE_HISTORY; +diff --git a/src/chrome/test/BUILD.gn b/src/chrome/test/BUILD.gn +index 52e28622b8f..e42d49d2684 +--- a/src/chrome/test/BUILD.gn ++++ b/src/chrome/test/BUILD.gn +@@ -1766,6 +1766,7 @@ if (!is_android && !is_fuchsia) { + "../browser/performance_manager/page_load_tracker_decorator_browsertest.cc", + "../browser/performance_manager/policies/bfcache_policy_browsertest.cc", + "../browser/performance_manager/tab_properties_decorator_browsertest.cc", ++ "../browser/performance_timeline_browsertest.cc", + "../browser/permissions/permission_delegation_browsertest.cc", + "../browser/permissions/permission_manager_browsertest.cc", + "../browser/permissions/permission_request_manager_browsertest.cc", +@@ -6997,6 +6998,7 @@ test("unit_tests") { + "../browser/extensions/extension_test_message_listener_unittest.cc", + "../browser/extensions/extension_ui_util_unittest.cc", + "../browser/extensions/extension_user_script_loader_unittest.cc", ++ "../browser/extensions/extension_util_unittest.cc", + "../browser/extensions/extension_web_ui_unittest.cc", + "../browser/extensions/external_install_error_unittest.cc", + "../browser/extensions/external_policy_loader_unittest.cc", +diff --git a/src/chrome/test/data/extensions/platform_apps/app_view/shim/main.js b/src/chrome/test/data/extensions/platform_apps/app_view/shim/main.js +index 45e204b09a4..ed20285a245 +--- a/src/chrome/test/data/extensions/platform_apps/app_view/shim/main.js ++++ b/src/chrome/test/data/extensions/platform_apps/app_view/shim/main.js +@@ -207,6 +207,14 @@ function testAppViewEmbedSelfShouldFail(appToEmbed) { + }); + }; + ++function testCloseWithPendingEmbedRequest(appToEmbed) { ++ let appview = new AppView(); ++ document.body.appendChild(appview); ++ appview.connect(appToEmbed, { 'deferRequest': true }); ++ // The test continues on the C++ side. ++ embedder.test.succeed(); ++}; ++ + embedder.test.testList = { + 'testAppViewWithUndefinedDataShouldSucceed': + testAppViewWithUndefinedDataShouldSucceed, +@@ -215,7 +223,8 @@ embedder.test.testList = { + 'testAppViewMultipleConnects': testAppViewMultipleConnects, + 'testAppViewConnectFollowingPreviousConnect': + testAppViewConnectFollowingPreviousConnect, +- 'testAppViewEmbedSelfShouldFail': testAppViewEmbedSelfShouldFail ++ 'testAppViewEmbedSelfShouldFail': testAppViewEmbedSelfShouldFail, ++ 'testCloseWithPendingEmbedRequest': testCloseWithPendingEmbedRequest, + }; + + onload = function() { +diff --git a/src/chrome/test/data/extensions/platform_apps/app_view/shim/skeleton/main.js b/src/chrome/test/data/extensions/platform_apps/app_view/shim/skeleton/main.js +index 8bbdd6e9434..46875923343 +--- a/src/chrome/test/data/extensions/platform_apps/app_view/shim/skeleton/main.js ++++ b/src/chrome/test/data/extensions/platform_apps/app_view/shim/skeleton/main.js +@@ -2,9 +2,26 @@ + // Use of this source code is governed by a BSD-style license that can be + // found in the LICENSE file. + ++window.deferredRequest = null; ++window.continueEmbedding = (allowRequest) => { ++ if (window.deferredRequest) { ++ if (allowRequest) { ++ window.deferredRequest.allow('main.html'); ++ } else { ++ window.deferredRequest.deny(); ++ } ++ } ++}; ++ + chrome.app.runtime.onEmbedRequested.addListener(function(request) { + if (!request.embedderId) + request.deny(); ++ ++ if (request.data.deferRequest) { ++ window.deferredRequest = request; ++ return; ++ } ++ + if (!request.data.foo) { + request.allow('main.html'); + return; +diff --git a/src/chrome/test/data/extensions/resource_timing/24.png b/src/chrome/test/data/extensions/resource_timing/24.png +new file mode 100644 +index 0000000000000000000000000000000000000000..acb1f096913420374017add67c2e8903b897229a +GIT binary patch +literal 239 +zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1SIoCSFHz9jKx9jP7LeL$-D$|I14-?iy0WW +zg+Z8+Vb&awa`qBWUsv{9%wpnJTB~ljDgcEfOI#yLobz*YQ}ap~oQqNuOHxx5$}>wc +z6x=<11Hv2m#DR)pJY5_^Dj1V3rp@pWJ@VoC?d|W^$2nd+J>B8c@!974_tz-O{r&s# +z@&Et-6~yOiYd0_0ymYC;rX^28{P^@rjEseSpSZZOopAlXl4XUk+n0iiE4tlcORuiB-44$rjF6*2UngH&6PoMw* + +literal 0 +HcmV?d00001 + +diff --git a/src/chrome/test/data/extensions/resource_timing/fetch_resource/content_script.js b/src/chrome/test/data/extensions/resource_timing/fetch_resource/content_script.js +new file mode 100644 +index 00000000000..eb7974a65ab +--- /dev/null ++++ b/src/chrome/test/data/extensions/resource_timing/fetch_resource/content_script.js +@@ -0,0 +1,22 @@ ++// Copyright 2022 The Chromium Authors ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++// Add a button to the page that can fetch resource. ++const button = document.createElement('button'); ++button.id = 'fetchResourceButton'; ++button.innerText = 'fetch resource'; ++document.body.appendChild(button); ++ ++// This fetch runs in the isolated world. ++button.onclick = async () => { ++ await fetch('/extensions/resource_timing/24.png').then( ++ () => { window.domAutomationController.send(true); }).catch( ++ () => { window.domAutomationController.send(false); }); ++}; ++ ++// This is loaded as a script tag element into the DOM and the fetch runs in the ++// main world. ++async function fetchResource() { ++ await fetch('/extensions/resource_timing/24.png'); ++} +diff --git a/src/chrome/test/data/extensions/resource_timing/fetch_resource/manifest.json b/src/chrome/test/data/extensions/resource_timing/fetch_resource/manifest.json +new file mode 100644 +index 00000000000..c3185a4594d +--- /dev/null ++++ b/src/chrome/test/data/extensions/resource_timing/fetch_resource/manifest.json +@@ -0,0 +1,28 @@ ++{ ++ "name": "Fetch resource", ++ "version": "1", ++ "manifest_version": 3, ++ "web_accessible_resources": [ ++ { ++ "resources": [ ++ "content_script.js" ++ ], ++ "matches": [ ++ "*://*/*" ++ ] ++ } ++ ], ++ "content_scripts": [ ++ { ++ "js": [ ++ "content_script.js" ++ ], ++ "matches": [ ++ "*://*/*" ++ ] ++ } ++ ], ++ "permissions": [ ++ "tabs" ++ ] ++} +diff --git a/src/chrome/test/data/extensions/resource_timing/test-page.html b/src/chrome/test/data/extensions/resource_timing/test-page.html +new file mode 100644 +index 00000000000..2deb9e9b766 +--- /dev/null ++++ b/src/chrome/test/data/extensions/resource_timing/test-page.html +@@ -0,0 +1,29 @@ ++ ++ ++ ++ ++ Resource Fetched That Are Initiated from Content Script ++ ++ ++ ++ Such resource should not trigger performance timeline resource timing entry. ++ ++ ++ ++ +diff --git a/src/components/browsing_data/core/browsing_data_utils.cc b/src/components/browsing_data/core/browsing_data_utils.cc +index c6fdb552bdf..5e91ab5b32d +--- a/src/components/browsing_data/core/browsing_data_utils.cc ++++ b/src/components/browsing_data/core/browsing_data_utils.cc +@@ -17,6 +17,7 @@ + #include "components/browsing_data/core/pref_names.h" + #include "components/prefs/pref_service.h" + #include "components/strings/grit/components_strings.h" ++#include "third_party/abseil-cpp/absl/types/optional.h" + #include "ui/base/l10n/l10n_util.h" + + namespace browsing_data { +@@ -362,7 +363,7 @@ bool GetDeletionPreferenceFromDataType( + return false; + } + +-BrowsingDataType GetDataTypeFromDeletionPreference( ++absl::optional GetDataTypeFromDeletionPreference( + const std::string& pref_name) { + using DataTypeMap = base::flat_map; + static base::NoDestructor preference_to_datatype( +@@ -381,8 +382,10 @@ BrowsingDataType GetDataTypeFromDeletionPreference( + }); + + auto iter = preference_to_datatype->find(pref_name); +- DCHECK(iter != preference_to_datatype->end()); +- return iter->second; ++ if (iter != preference_to_datatype->end()) { ++ return iter->second; ++ } ++ return absl::nullopt; + } + + } // namespace browsing_data +diff --git a/src/components/browsing_data/core/browsing_data_utils.h b/src/components/browsing_data/core/browsing_data_utils.h +index 209d9601294..9bc3f2b55cb +--- a/src/components/browsing_data/core/browsing_data_utils.h ++++ b/src/components/browsing_data/core/browsing_data_utils.h +@@ -11,6 +11,7 @@ + #include "build/build_config.h" + #include "components/browsing_data/core/clear_browsing_data_tab.h" + #include "components/browsing_data/core/counters/browsing_data_counter.h" ++#include "third_party/abseil-cpp/absl/types/optional.h" + + namespace browsing_data { + +@@ -76,7 +77,8 @@ bool GetDeletionPreferenceFromDataType( + ClearBrowsingDataTab clear_browsing_data_tab, + std::string* out_pref); + +-BrowsingDataType GetDataTypeFromDeletionPreference( ++// Returns a BrowsingDataType if a type matching |pref_name| is found. ++absl::optional GetDataTypeFromDeletionPreference( + const std::string& pref_name); + + } // namespace browsing_data +diff --git a/src/components/crash/content/browser/crash_handler_host_linux.cc b/src/components/crash/content/browser/crash_handler_host_linux.cc +index d460d18686d..2c0f2b87c7c +--- a/src/components/crash/content/browser/crash_handler_host_linux.cc ++++ b/src/components/crash/content/browser/crash_handler_host_linux.cc +@@ -426,13 +426,28 @@ void CrashHandlerHostLinux::WriteDumpFile(BreakpadInfo* info, + + base::FilePath dumps_path("/tmp"); + base::PathService::Get(base::DIR_TEMP, &dumps_path); ++ ++#if BUILDFLAG(IS_OHOS) ++ dumps_path = dumps_path.Append("crashdmps"); ++ if (!base::PathExists(dumps_path)) { ++ base::CreateDirectory(dumps_path); ++ } ++#endif // BUILDFLAG(IS_OHOS) ++ ++#if !BUILDFLAG(IS_OHOS) + if (!info->upload) + dumps_path = dumps_path_; +- const std::string minidump_filename = +- base::StringPrintf("%s/chromium-%s-minidump-%016" PRIx64 ".dmp", +- dumps_path.value().c_str(), +- process_type_.c_str(), +- base::RandUint64()); ++#endif // BUILDFLAG(IS_OHOS) ++ ++#if BUILDFLAG(IS_OHOS) ++ const std::string minidump_filename = base::StringPrintf( ++ "%s/nweb-%s-minidump-%016" PRIx64 ".dmp", dumps_path.value().c_str(), ++ process_type_.c_str(), base::RandUint64()); ++#else ++ const std::string minidump_filename = base::StringPrintf( ++ "%s/chromium-%s-minidump-%016" PRIx64 ".dmp", dumps_path.value().c_str(), ++ process_type_.c_str(), base::RandUint64()); ++#endif // BUILDFLAG(IS_OHOS) + + if (!google_breakpad::WriteMinidump(minidump_filename.c_str(), + kMaxMinidumpFileSize, +diff --git a/src/components/crash/core/app/breakpad_linux.cc b/src/components/crash/core/app/breakpad_linux.cc +index 3f0f95a330b..382caf9a4c2 +--- a/src/components/crash/core/app/breakpad_linux.cc ++++ b/src/components/crash/core/app/breakpad_linux.cc +@@ -74,6 +74,11 @@ + #include // for getcontext(). + #endif + ++#if BUILDFLAG(IS_OHOS) ++#include "base/files/file_path.h" ++#include "base/files/file_util.h" ++#endif // BUILDFLAG(IS_OHOS) ++ + #if BUILDFLAG(IS_ANDROID) + #define STAT_STRUCT struct stat + #define FSTAT_FUNC fstat +@@ -824,6 +829,12 @@ void EnableCrashDumping(bool unattended) { + strncpy(g_crash_log_path, logfile_str.c_str(), crash_log_path_len); + } + DCHECK(!g_breakpad); ++#if BUILDFLAG(IS_OHOS) ++ dumps_path = dumps_path.Append("crashdmps"); ++ if (!base::PathExists(dumps_path)) { ++ base::CreateDirectory(dumps_path); ++ } ++#endif // BUILDFLAG(IS_OHOS) + MinidumpDescriptor minidump_descriptor(dumps_path.value()); + if (base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kFullMemoryCrashReport)) { +@@ -835,6 +846,11 @@ void EnableCrashDumping(bool unattended) { + unattended = true; // Android never uploads directly. + SetMinidumpSanitizationFields(&minidump_descriptor, sanitization_info); + #endif ++ ++#if BUILDFLAG(IS_OHOS) ++ unattended = true; // ohos never uploads directly. ++#endif // BUILDFLAG(IS_OHOS) ++ + if (unattended) { + g_breakpad = + new ExceptionHandler(minidump_descriptor, +@@ -1025,9 +1041,13 @@ void MicrodumpInfo::Initialize(const std::string& process_type, + // Non-Browser = Extension, Gpu, Plugins, Ppapi and Renderer + class NonBrowserCrashHandler : public google_breakpad::CrashGenerationClient { + public: ++#if BUILDFLAG(IS_OHOS) ++ NonBrowserCrashHandler() {} ++#else + NonBrowserCrashHandler() + : server_fd_( + base::GlobalDescriptors::GetInstance()->Get(kCrashDumpSignal)) {} ++#endif // BUILDFLAG(IS_OHOS) + + NonBrowserCrashHandler(const NonBrowserCrashHandler&) = delete; + NonBrowserCrashHandler& operator=(const NonBrowserCrashHandler&) = delete; +@@ -1037,6 +1057,14 @@ class NonBrowserCrashHandler : public google_breakpad::CrashGenerationClient { + bool RequestDump(const void* crash_context, + size_t crash_context_size) override { + int fds[2] = { -1, -1 }; ++ ++#if BUILDFLAG(IS_OHOS) ++ if (server_fd_ == 0) { ++ server_fd_ = ++ base::GlobalDescriptors::GetInstance()->Get(kCrashDumpSignal); ++ } ++#endif // BUILDFLAG(IS_OHOS) ++ + if (sys_socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) { + static const char msg[] = "Failed to create socket for crash dumping.\n"; + WriteLog(msg, sizeof(msg) - 1); +@@ -1118,7 +1146,11 @@ class NonBrowserCrashHandler : public google_breakpad::CrashGenerationClient { + + private: + // The pipe FD to the browser process, which will handle the crash dumping. ++#if BUILDFLAG(IS_OHOS) ++ int server_fd_ = 0; ++#else + const int server_fd_; ++#endif // BUILDFLAG(IS_OHOS) + }; + + void EnableNonBrowserCrashDumping() { +@@ -1580,7 +1612,9 @@ void HandleCrashDump(const BreakpadInfo& info) { + const char* exe_buf = nullptr; + + if (GetCrashReporterClient()->HandleCrashDump(info.filename, info.pid)) { ++#if !BUILDFLAG(IS_OHOS) + return; ++#endif // BUILDFLAG(IS_OHOS) + } + + #if BUILDFLAG(IS_CHROMEOS_ASH) +diff --git a/src/components/error_page/content/browser/DEPS b/src/components/error_page/content/browser/DEPS +index 3e18f37042a..1f9926f7b01 +--- a/src/components/error_page/content/browser/DEPS ++++ b/src/components/error_page/content/browser/DEPS +@@ -6,6 +6,7 @@ include_rules = [ + + specific_include_rules = { + ".*_browsertest\.cc": [ ++ "+content/public/common/content_features.h", + "+content/public/test", + "+content/shell/browser/shell.h", + "+content/shell/browser/shell_content_browser_client.h", +diff --git a/src/components/fullscreen_control_strings.grdp b/src/components/fullscreen_control_strings.grdp +index 269e155502c..53dc9b265c0 +--- a/src/components/fullscreen_control_strings.grdp ++++ b/src/components/fullscreen_control_strings.grdp +@@ -9,4 +9,15 @@ + + Press |$1Esc| to exit full screen + ++ ++ Download started. To see it, press |$1Esc|. ++ ++ ++ Press |$1Esc| to exit full screen and see download. ++ ++ ++ Press and hold |$1Esc| to exit full screen and see download. ++ + +diff --git a/src/components/fullscreen_control_strings_grdp/IDS_FULLSCREEN_HOLD_TO_SEE_DOWNLOADS_AND_EXIT.png.sha1 b/src/components/fullscreen_control_strings_grdp/IDS_FULLSCREEN_HOLD_TO_SEE_DOWNLOADS_AND_EXIT.png.sha1 +new file mode 100644 +index 00000000000..c8f25fc2fc0 +--- /dev/null ++++ b/src/components/fullscreen_control_strings_grdp/IDS_FULLSCREEN_HOLD_TO_SEE_DOWNLOADS_AND_EXIT.png.sha1 +@@ -0,0 +1 @@ ++deeb1505e3f559488bb35742d4d89a7ffb75d0ce +\ No newline at end of file +diff --git a/src/components/fullscreen_control_strings_grdp/IDS_FULLSCREEN_PRESS_TO_SEE_DOWNLOADS.png.sha1 b/src/components/fullscreen_control_strings_grdp/IDS_FULLSCREEN_PRESS_TO_SEE_DOWNLOADS.png.sha1 +new file mode 100644 +index 00000000000..a91f449a385 +--- /dev/null ++++ b/src/components/fullscreen_control_strings_grdp/IDS_FULLSCREEN_PRESS_TO_SEE_DOWNLOADS.png.sha1 +@@ -0,0 +1 @@ ++dafbed225d745b44ba1bf74f7e7c1b46b6178a03 +\ No newline at end of file +diff --git a/src/components/fullscreen_control_strings_grdp/IDS_FULLSCREEN_PRESS_TO_SEE_DOWNLOADS_AND_EXIT.png.sha1 b/src/components/fullscreen_control_strings_grdp/IDS_FULLSCREEN_PRESS_TO_SEE_DOWNLOADS_AND_EXIT.png.sha1 +new file mode 100644 +index 00000000000..0a2237fd5ed +--- /dev/null ++++ b/src/components/fullscreen_control_strings_grdp/IDS_FULLSCREEN_PRESS_TO_SEE_DOWNLOADS_AND_EXIT.png.sha1 +@@ -0,0 +1 @@ ++b4f0f17c687c548a7d783289a36cac8d7f268a6e +\ No newline at end of file +diff --git a/src/components/guest_view/browser/guest_view_base.cc b/src/components/guest_view/browser/guest_view_base.cc +index 920e0320b18..89e236ebf53 +--- a/src/components/guest_view/browser/guest_view_base.cc ++++ b/src/components/guest_view/browser/guest_view_base.cc +@@ -100,17 +100,20 @@ class GuestViewBase::OwnerContentsObserver : public WebContentsObserver { + if (destroyed_) + return; + ++ if (!IsGuestInitialized()) { ++ return; ++ } ++ + is_fullscreen_ = entered_fullscreen; + guest_->EmbedderFullscreenToggled(is_fullscreen_); + } + + void PrimaryMainFrameWasResized(bool width_changed) override { +- if (destroyed_ || !web_contents()->GetDelegate()) ++ if (destroyed_ || !IsGuestInitialized()) { + return; ++ } + +- bool current_fullscreen = +- web_contents()->GetDelegate()->IsFullscreenForTabOrPending( +- web_contents()); ++ bool current_fullscreen = web_contents()->IsFullscreen(); + if (is_fullscreen_ && !current_fullscreen) { + is_fullscreen_ = false; + guest_->EmbedderFullscreenToggled(is_fullscreen_); +@@ -121,7 +124,9 @@ class GuestViewBase::OwnerContentsObserver : public WebContentsObserver { + if (destroyed_) + return; + +- guest_->web_contents()->SetAudioMuted(muted); ++ if (IsGuestInitialized()) { ++ guest_->web_contents()->SetAudioMuted(muted); ++ } + } + + void RenderFrameDeleted(content::RenderFrameHost* rfh) override { +@@ -130,6 +135,8 @@ class GuestViewBase::OwnerContentsObserver : public WebContentsObserver { + } + + private: ++ bool IsGuestInitialized() { return guest_->web_contents(); } ++ + bool is_fullscreen_; + bool destroyed_; + raw_ptr guest_; +diff --git a/src/components/optimization_guide/core/base_model_executor.h b/src/components/optimization_guide/core/base_model_executor.h +index 78e064b4256..84dabb1e1d9 +--- a/src/components/optimization_guide/core/base_model_executor.h ++++ b/src/components/optimization_guide/core/base_model_executor.h +@@ -9,6 +9,7 @@ + #include "components/optimization_guide/core/execution_status.h" + #include "components/optimization_guide/core/tflite_model_executor.h" + #include "components/optimization_guide/core/tflite_op_resolver.h" ++#include "components/optimization_guide/machine_learning_tflite_buildflags.h" + #include "third_party/tflite_support/src/tensorflow_lite_support/cc/task/core/base_task_api.h" + + namespace optimization_guide { +@@ -41,6 +42,9 @@ class BaseModelExecutor : public TFLiteModelExecutor, + std::unique_ptr BuildModelExecutionTask( + base::MemoryMappedFile* model_file, + ExecutionStatus* out_status) override { ++#if BUILDFLAG(IS_OHOS) && !BUILDFLAG(BUILD_WITH_TFLITE_LIB) ++ return nullptr; ++#endif + std::unique_ptr tflite_engine = + std::make_unique( + std::make_unique()); +diff --git a/src/components/permissions/permission_request.cc b/src/components/permissions/permission_request.cc +index d154e01d32a..2685149b15a +--- a/src/components/permissions/permission_request.cc ++++ b/src/components/permissions/permission_request.cc +@@ -39,6 +39,10 @@ bool PermissionRequest::IsDuplicateOf(PermissionRequest* other_request) const { + requesting_origin() == other_request->requesting_origin(); + } + ++base::WeakPtr PermissionRequest::GetWeakPtr() { ++ return weak_factory_.GetWeakPtr(); ++} ++ + #if BUILDFLAG(IS_ANDROID) + std::u16string PermissionRequest::GetDialogMessageText() const { + int message_id = 0; +diff --git a/src/components/permissions/permission_request.h b/src/components/permissions/permission_request.h +index 94264968af0..cfdcfe1a513 +--- a/src/components/permissions/permission_request.h ++++ b/src/components/permissions/permission_request.h +@@ -8,6 +8,7 @@ + #include + + #include "base/callback.h" ++#include "base/memory/weak_ptr.h" + #include "build/build_config.h" + #include "components/content_settings/core/common/content_settings.h" + #include "components/content_settings/core/common/content_settings_types.h" +@@ -71,6 +72,9 @@ class PermissionRequest { + virtual std::u16string GetDialogMessageText() const; + #endif + ++ // Returns a weak pointer to this instance. ++ base::WeakPtr GetWeakPtr(); ++ + #if !BUILDFLAG(IS_ANDROID) + // Returns prompt icon appropriate for displaying on the chip button in the + // location bar. +@@ -141,6 +145,8 @@ class PermissionRequest { + // Called when the request is no longer in use so it can be deleted by the + // caller. + base::OnceClosure delete_callback_; ++ ++ base::WeakPtrFactory weak_factory_{this}; + }; + + } // namespace permissions +diff --git a/src/components/permissions/permission_request_manager.cc b/src/components/permissions/permission_request_manager.cc +index ae4216261e8..623035868a0 +--- a/src/components/permissions/permission_request_manager.cc ++++ b/src/components/permissions/permission_request_manager.cc +@@ -227,18 +227,25 @@ void PermissionRequestManager::AddRequest( + } + + // Don't re-add an existing request or one with a duplicate text request. +- PermissionRequest* existing_request = GetExistingRequest(request); +- if (existing_request) { ++ if (auto* existing_request = GetExistingRequest(request)) { ++ if (request == existing_request) { ++ return; ++ } ++ + // |request| is a duplicate. Add it to |duplicate_requests_| unless it's the + // same object as |existing_request| or an existing duplicate. +- if (request == existing_request) ++ auto iter = FindDuplicateRequestList(existing_request); ++ if (iter == duplicate_requests_.end()) { ++ duplicate_requests_.push_back({request->GetWeakPtr()}); + return; +- auto range = duplicate_requests_.equal_range(existing_request); +- for (auto it = range.first; it != range.second; ++it) { +- if (request == it->second) ++ } ++ ++ for (const auto& weak_request : (*iter)) { ++ if (weak_request && request == weak_request.get()) { + return; ++ } + } +- duplicate_requests_.insert(std::make_pair(existing_request, request)); ++ iter->push_back(request->GetWeakPtr()); + return; + } + +@@ -841,8 +848,9 @@ void PermissionRequestManager::CleanUpRequests() { + PermissionRequest* PermissionRequestManager::GetExistingRequest( + PermissionRequest* request) { + for (PermissionRequest* existing_request : requests_) { +- if (request->IsDuplicateOf(existing_request)) ++ if (request->IsDuplicateOf(existing_request)) { + return existing_request; ++ } + } + for (PermissionRequest* queued_request : queued_requests_) { + if (request->IsDuplicateOf(queued_request)) +@@ -851,6 +859,53 @@ PermissionRequest* PermissionRequestManager::GetExistingRequest( + return nullptr; + } + ++PermissionRequestManager::WeakPermissionRequestList::iterator ++PermissionRequestManager::FindDuplicateRequestList(PermissionRequest* request) { ++ for (auto request_list = duplicate_requests_.begin(); ++ request_list != duplicate_requests_.end(); ++request_list) { ++ for (auto iter = request_list->begin(); iter != request_list->end();) { ++ // Remove any requests that have been destroyed. ++ const auto& weak_request = (*iter); ++ if (!weak_request) { ++ iter = request_list->erase(iter); ++ continue; ++ } ++ ++ // The first valid request in the list will indicate whether all other ++ // members are duplicate or not. ++ if (weak_request->IsDuplicateOf(request)) { ++ return request_list; ++ } ++ ++ break; ++ } ++ } ++ ++ return duplicate_requests_.end(); ++} ++ ++PermissionRequestManager::WeakPermissionRequestList::iterator ++PermissionRequestManager::VisitDuplicateRequests( ++ DuplicateRequestVisitor visitor, ++ PermissionRequest* request) { ++ auto request_list = FindDuplicateRequestList(request); ++ if (request_list == duplicate_requests_.end()) { ++ return request_list; ++ } ++ ++ for (auto iter = request_list->begin(); iter != request_list->end();) { ++ if (auto& weak_request = (*iter)) { ++ visitor.Run(weak_request); ++ ++iter; ++ } else { ++ // Remove any requests that have been destroyed. ++ iter = request_list->erase(iter); ++ } ++ } ++ ++ return request_list; ++} ++ + void PermissionRequestManager::PermissionGrantedIncludingDuplicates( + PermissionRequest* request, + bool is_one_time) { +@@ -858,9 +913,14 @@ void PermissionRequestManager::PermissionGrantedIncludingDuplicates( + base::STLCount(queued_requests_, request)) + << "Only requests in [queued_[frame_]]requests_ can have duplicates"; + request->PermissionGranted(is_one_time); +- auto range = duplicate_requests_.equal_range(request); +- for (auto it = range.first; it != range.second; ++it) +- it->second->PermissionGranted(is_one_time); ++ VisitDuplicateRequests( ++ base::BindRepeating( ++ [](bool is_one_time, ++ const base::WeakPtr& weak_request) { ++ weak_request->PermissionGranted(is_one_time); ++ }, ++ is_one_time), ++ request); + } + + void PermissionRequestManager::PermissionDeniedIncludingDuplicates( +@@ -869,9 +929,12 @@ void PermissionRequestManager::PermissionDeniedIncludingDuplicates( + base::STLCount(queued_requests_, request)) + << "Only requests in [queued_]requests_ can have duplicates"; + request->PermissionDenied(); +- auto range = duplicate_requests_.equal_range(request); +- for (auto it = range.first; it != range.second; ++it) +- it->second->PermissionDenied(); ++ VisitDuplicateRequests( ++ base::BindRepeating( ++ [](const base::WeakPtr& weak_request) { ++ weak_request->PermissionDenied(); ++ }), ++ request); + } + + void PermissionRequestManager::CancelledIncludingDuplicates( +@@ -880,9 +943,12 @@ void PermissionRequestManager::CancelledIncludingDuplicates( + base::STLCount(queued_requests_, request)) + << "Only requests in [queued_]requests_ can have duplicates"; + request->Cancelled(); +- auto range = duplicate_requests_.equal_range(request); +- for (auto it = range.first; it != range.second; ++it) +- it->second->Cancelled(); ++ VisitDuplicateRequests( ++ base::BindRepeating( ++ [](const base::WeakPtr& weak_request) { ++ weak_request->Cancelled(); ++ }), ++ request); + } + + void PermissionRequestManager::RequestFinishedIncludingDuplicates( +@@ -890,13 +956,20 @@ void PermissionRequestManager::RequestFinishedIncludingDuplicates( + DCHECK_EQ(1, base::STLCount(requests_, request) + + base::STLCount(queued_requests_, request)) + << "Only requests in [queued_]requests_ can have duplicates"; ++ auto duplicate_list = VisitDuplicateRequests( ++ base::BindRepeating( ++ [](const base::WeakPtr& weak_request) { ++ weak_request->RequestFinished(); ++ }), ++ request); ++ ++ // Note: beyond this point, |request| has probably been deleted, any ++ // dereference of |request| must be done prior this point. + request->RequestFinished(); +- // Beyond this point, |request| has probably been deleted. +- auto range = duplicate_requests_.equal_range(request); +- for (auto it = range.first; it != range.second; ++it) +- it->second->RequestFinished(); + // Additionally, we can now remove the duplicates. +- duplicate_requests_.erase(request); ++ if (duplicate_list != duplicate_requests_.end()) { ++ duplicate_requests_.erase(duplicate_list); ++ } + } + + void PermissionRequestManager::AddObserver(Observer* observer) { +diff --git a/src/components/permissions/permission_request_manager.h b/src/components/permissions/permission_request_manager.h +index c5947489aa6..2abeb70d0c0 +--- a/src/components/permissions/permission_request_manager.h ++++ b/src/components/permissions/permission_request_manager.h +@@ -6,6 +6,7 @@ + #define COMPONENTS_PERMISSIONS_PERMISSION_REQUEST_MANAGER_H_ + + #include ++#include + #include + #include + #include +@@ -205,6 +206,9 @@ class PermissionRequestManager + private: + friend class test::PermissionRequestManagerTestApi; + friend class content::WebContentsUserData; ++ FRIEND_TEST_ALL_PREFIXES(PermissionRequestManagerTest, WeakDuplicateRequests); ++ FRIEND_TEST_ALL_PREFIXES(PermissionRequestManagerTest, ++ WeakDuplicateRequestsAccept); + + explicit PermissionRequestManager(content::WebContents* web_contents); + +@@ -264,6 +268,25 @@ class PermissionRequestManager + // request may or may not be the same object as |request|. + PermissionRequest* GetExistingRequest(PermissionRequest* request); + ++// Returns an iterator into |duplicate_requests_|, points the matching list, ++ // or duplicate_requests_.end() if no match. The matching list contains all ++ // the weak requests which are duplicate of the given |request| (see ++ // |IsDuplicateOf|) ++ using WeakPermissionRequestList = ++ std::list>>; ++ WeakPermissionRequestList::iterator FindDuplicateRequestList( ++ PermissionRequest* request); ++ ++ // Trigger |visitor| for each live weak request which matches the given ++ // request (see |IsDuplicateOf|) in the |duplicate_requests_|. Returns an ++ // iterator into |duplicate_requests_|, points the matching list, or ++ // duplicate_requests_.end() if no match. ++ using DuplicateRequestVisitor = ++ base::RepeatingCallback&)>; ++ WeakPermissionRequestList::iterator VisitDuplicateRequests( ++ DuplicateRequestVisitor visitor, ++ PermissionRequest* request); ++ + // Calls PermissionGranted on a request and all its duplicates. + void PermissionGrantedIncludingDuplicates(PermissionRequest* request, + bool is_one_time); +@@ -332,10 +355,8 @@ class PermissionRequestManager + // clear API like `Peek()` and `Pop()`, etc. + base::circular_deque queued_requests_; + +- // Maps from the first request of a kind to subsequent requests that were +- // duped against it. +- std::unordered_multimap +- duplicate_requests_; ++ // Stores the weak pointers of duplicated requests in a 2D list. ++ WeakPermissionRequestList duplicate_requests_; + + // Maps each PermissionRequest currently in |requests_| or |queued_requests_| + // to which RenderFrameHost it originated from. Note that no date is stored +diff --git a/src/components/permissions/permission_request_manager_unittest.cc b/src/components/permissions/permission_request_manager_unittest.cc +index 217ce22c44d..1136b9f8baf +--- a/src/components/permissions/permission_request_manager_unittest.cc ++++ b/src/components/permissions/permission_request_manager_unittest.cc +@@ -10,6 +10,7 @@ + #include "base/command_line.h" + #include "base/memory/raw_ptr.h" + #include "base/run_loop.h" ++#include "base/test/bind.h" + #include "base/test/metrics/histogram_tester.h" + #include "base/test/scoped_feature_list.h" + #include "base/threading/sequenced_task_runner_handle.h" +@@ -506,6 +507,89 @@ TEST_P(PermissionRequestManagerTest, SameRequestRejected) { + EXPECT_FALSE(prompt_factory_->is_visible()); + } + ++TEST_P(PermissionRequestManagerTest, WeakDuplicateRequests) { ++ manager_->AddRequest(web_contents()->GetMainFrame(), &request1_); ++ WaitForBubbleToBeShown(); ++ auto dupe_request_1 = request1_.CreateDuplicateRequest(); ++ auto dupe_request_2 = request1_.CreateDuplicateRequest(); ++ auto dupe_request_3 = request1_.CreateDuplicateRequest(); ++ auto dupe_request_4 = request1_.CreateDuplicateRequest(); ++ manager_->AddRequest(web_contents()->GetMainFrame(), ++ dupe_request_1.get()); ++ manager_->AddRequest(web_contents()->GetMainFrame(), ++ dupe_request_2.get()); ++ manager_->AddRequest(web_contents()->GetMainFrame(), ++ dupe_request_3.get()); ++ manager_->AddRequest(web_contents()->GetMainFrame(), ++ dupe_request_4.get()); ++ dupe_request_1.reset(); ++ dupe_request_3.reset(); ++ EXPECT_EQ(4ul, manager_->duplicate_requests_.front().size()); ++ EXPECT_EQ(1ul, manager_->duplicate_requests_.size()); ++ auto request_list = manager_->FindDuplicateRequestList(&request1_); ++ EXPECT_NE(request_list, manager_->duplicate_requests_.end()); ++ EXPECT_EQ(3ul, manager_->duplicate_requests_.front().size()); ++ dupe_request_4.reset(); ++ manager_->VisitDuplicateRequests( ++ base::BindRepeating( ++ [](const base::WeakPtr& weak_request) {}), ++ &request1_); ++ EXPECT_EQ(1ul, manager_->duplicate_requests_.front().size()); ++ EXPECT_EQ(1ul, manager_->duplicate_requests_.size()); ++ Accept(); ++ EXPECT_EQ(0ul, manager_->duplicate_requests_.size()); ++} ++ ++class QuicklyDeletedRequest : public PermissionRequest { ++ public: ++ QuicklyDeletedRequest(const GURL& requesting_origin, ++ RequestType request_type, ++ PermissionRequestGestureType gesture_type) ++ : PermissionRequest(requesting_origin, ++ request_type, ++ gesture_type == PermissionRequestGestureType::GESTURE, ++ base::BindLambdaForTesting( ++ [](ContentSetting result, ++ bool is_one_time) { NOTREACHED(); }), ++ base::NullCallback()) {} ++ ++ static std::unique_ptr CreateRequest( ++ MockPermissionRequest* request) { ++ return std::make_unique(request->requesting_origin(), ++ request->request_type(), ++ request->GetGestureType()); ++ } ++}; ++ ++TEST_P(PermissionRequestManagerTest, WeakDuplicateRequestsAccept) { ++ manager_->AddRequest(web_contents()->GetMainFrame(), &request1_); ++ WaitForBubbleToBeShown(); ++ manager_->AddRequest(web_contents()->GetMainFrame(), &request2_); ++ auto dupe_request_1 = QuicklyDeletedRequest::CreateRequest(&request1_); ++ auto dupe_request_2 = request1_.CreateDuplicateRequest(); ++ manager_->AddRequest(web_contents()->GetMainFrame(), ++ dupe_request_1.get()); ++ manager_->AddRequest(web_contents()->GetMainFrame(), ++ dupe_request_2.get()); ++ auto dupe_request_3 = QuicklyDeletedRequest::CreateRequest(&request2_); ++ auto dupe_request_4 = request2_.CreateDuplicateRequest(); ++ manager_->AddRequest(web_contents()->GetMainFrame(), ++ dupe_request_3.get()); ++ manager_->AddRequest(web_contents()->GetMainFrame(), ++ dupe_request_4.get()); ++ dupe_request_1.reset(); ++ dupe_request_3.reset(); ++ EXPECT_EQ(2ul, manager_->duplicate_requests_.size()); ++ EXPECT_EQ(2ul, manager_->duplicate_requests_.front().size()); ++ EXPECT_EQ(2ul, manager_->duplicate_requests_.back().size()); ++ WaitForBubbleToBeShown(); ++ Accept(); ++ EXPECT_EQ(1ul, manager_->duplicate_requests_.size()); ++ WaitForBubbleToBeShown(); ++ Accept(); ++ EXPECT_EQ(0ul, manager_->duplicate_requests_.size()); ++} ++ + TEST_P(PermissionRequestManagerTest, DuplicateRequest) { + manager_->AddRequest(web_contents()->GetMainFrame(), &request1_); + WaitForBubbleToBeShown(); +diff --git a/src/components/printing/browser/print_manager.cc b/src/components/printing/browser/print_manager.cc +index 37e4db4235e..674ec76a03a +--- a/src/components/printing/browser/print_manager.cc ++++ b/src/components/printing/browser/print_manager.cc +@@ -50,7 +50,7 @@ void PrintManager::PrintingFailed(int32_t cookie) { + if (!IsValidCookie(cookie)) + return; + +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + PdfWritingDone(0); + #endif + } +@@ -93,7 +93,7 @@ content::RenderFrameHost* PrintManager::GetCurrentTargetFrame() { + } + + void PrintManager::PrintingRenderFrameDeleted() { +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + PdfWritingDone(0); + #endif + } +diff --git a/src/components/printing/browser/print_manager.h b/src/components/printing/browser/print_manager.h +index f9db604a724..f60922d6c4a +--- a/src/components/printing/browser/print_manager.h ++++ b/src/components/printing/browser/print_manager.h +@@ -15,7 +15,7 @@ + #include "mojo/public/cpp/bindings/associated_remote.h" + #include "printing/buildflags/buildflags.h" + +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + #include + + #include "base/callback.h" +@@ -34,7 +34,7 @@ class PrintManager : public content::WebContentsObserver, + mojo::PendingAssociatedReceiver receiver, + content::RenderFrameHost* rfh); + +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + // TODO(timvolodine): consider introducing PrintManagerAndroid (crbug/500960) + using PdfWritingDoneCallback = + base::RepeatingCallback; +@@ -77,7 +77,7 @@ class PrintManager : public content::WebContentsObserver, + int cookie() const { return cookie_; } + void set_cookie(int cookie) { cookie_ = cookie; } + +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + PdfWritingDoneCallback pdf_writing_done_callback() const { + return pdf_writing_done_callback_; + } +@@ -94,7 +94,7 @@ class PrintManager : public content::WebContentsObserver, + content::RenderFrameHostReceiverSet + print_manager_host_receivers_; + +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + // Callback to execute when done writing pdf. + PdfWritingDoneCallback pdf_writing_done_callback_; + #endif +diff --git a/src/components/printing/browser/print_to_pdf/pdf_print_manager.cc b/src/components/printing/browser/print_to_pdf/pdf_print_manager.cc +index 66810a2a5f0..410fda1bb53 +--- a/src/components/printing/browser/print_to_pdf/pdf_print_manager.cc ++++ b/src/components/printing/browser/print_to_pdf/pdf_print_manager.cc +@@ -230,7 +230,7 @@ void PdfPrintManager::SetAccessibilityTree( + } + #endif + +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + void PdfPrintManager::PdfWritingDone(int page_count) {} + #endif + +diff --git a/src/components/printing/browser/print_to_pdf/pdf_print_manager.h b/src/components/printing/browser/print_to_pdf/pdf_print_manager.h +index 3326eea1fd8..14449b24683 +--- a/src/components/printing/browser/print_to_pdf/pdf_print_manager.h ++++ b/src/components/printing/browser/print_to_pdf/pdf_print_manager.h +@@ -93,7 +93,7 @@ class PdfPrintManager : public printing::PrintManager, + int32_t cookie, + const ui::AXTreeUpdate& accessibility_tree) override; + #endif +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + void PdfWritingDone(int page_count) override; + #endif + +diff --git a/src/components/printing/renderer/print_render_frame_helper.cc b/src/components/printing/renderer/print_render_frame_helper.cc +index ae23ffe05ba..da44581625d +--- a/src/components/printing/renderer/print_render_frame_helper.cc ++++ b/src/components/printing/renderer/print_render_frame_helper.cc +@@ -78,6 +78,10 @@ + #include "ui/accessibility/ax_tree_update.h" + #endif + ++#if BUILDFLAG(IS_OHOS) ++#include "content/common/frame.mojom.h" ++#endif // IS_OHOS ++ + using blink::web_pref::WebPreferences; + + namespace printing { +@@ -1236,6 +1240,12 @@ void PrintRenderFrameHelper::ScriptedPrint(bool user_initiated) { + // Detached documents can't be printed. + if (!web_frame->GetDocument().GetFrame()) + return; ++ ++#if BUILDFLAG(IS_OHOS) ++ if (delegate_->IsScriptedPrintEnabled()) { ++ return; ++ } ++#endif // IS_OHOS + + if (in_scripted_print_) + return; + diff --git a/src/components/renderer_context_menu/render_view_context_menu_base.cc b/src/components/renderer_context_menu/render_view_context_menu_base.cc +index 3f93f06532e..8c138e2e36a +--- a/src/components/renderer_context_menu/render_view_context_menu_base.cc ++++ b/src/components/renderer_context_menu/render_view_context_menu_base.cc +@@ -429,7 +429,6 @@ void RenderViewContextMenuBase::OnMenuWillShow(ui::SimpleMenuModel* source) { + // Ignore notifications from submenus. + if (source != &menu_model_) + return; +- + source_web_contents_->SetShowingContextMenu(true); + + NotifyMenuShown(); +diff --git a/src/components/viz/common/quads/compositor_frame_metadata.cc b/src/components/viz/common/quads/compositor_frame_metadata.cc +index 12685381b49..4f6b6df728d +--- a/src/components/viz/common/quads/compositor_frame_metadata.cc ++++ b/src/components/viz/common/quads/compositor_frame_metadata.cc +@@ -28,6 +28,9 @@ CompositorFrameMetadata::CompositorFrameMetadata( + page_scale_factor(other.page_scale_factor), + scrollable_viewport_size(other.scrollable_viewport_size), + content_color_usage(other.content_color_usage), ++#if BUILDFLAG(IS_OHOS) ++ is_scrolling(other.is_scrolling), ++#endif + may_contain_video(other.may_contain_video), + is_resourceless_software_draw_with_scroll_or_animation( + other.is_resourceless_software_draw_with_scroll_or_animation), +diff --git a/src/components/viz/common/quads/compositor_frame_metadata.h b/src/components/viz/common/quads/compositor_frame_metadata.h +index acd850f3f9c..247eaa598b4 +--- a/src/components/viz/common/quads/compositor_frame_metadata.h ++++ b/src/components/viz/common/quads/compositor_frame_metadata.h +@@ -80,6 +80,11 @@ class VIZ_COMMON_EXPORT CompositorFrameMetadata { + + gfx::ContentColorUsage content_color_usage = gfx::ContentColorUsage::kSRGB; + ++#if BUILDFLAG(IS_OHOS) ++ // Indicates whether the frame is generated by sliding ++ bool is_scrolling = false; ++#endif ++ + bool may_contain_video = false; + + bool may_throttle_if_undrawn_frames = true; +diff --git a/src/components/viz/host/host_display_client.cc b/src/components/viz/host/host_display_client.cc +index eac209e0a81..7d1a190a6da +--- a/src/components/viz/host/host_display_client.cc ++++ b/src/components/viz/host/host_display_client.cc +@@ -72,4 +72,10 @@ void HostDisplayClient::DidCompleteSwapWithNewSize(const gfx::Size& size) { + } + #endif + ++#if BUILDFLAG(IS_OHOS) ++void HostDisplayClient::DidCompleteSwapWithNewSizeOHOS(const gfx::Size& size) { ++ NOTIMPLEMENTED(); ++} ++#endif ++ + } // namespace viz +diff --git a/src/components/viz/host/host_display_client.h b/src/components/viz/host/host_display_client.h +index 7dc5f41a7da..ad58c2c420b +--- a/src/components/viz/host/host_display_client.h ++++ b/src/components/viz/host/host_display_client.h +@@ -52,6 +52,10 @@ class VIZ_HOST_EXPORT HostDisplayClient : public mojom::DisplayClient { + void DidCompleteSwapWithNewSize(const gfx::Size& size) override; + #endif + ++#if BUILDFLAG(IS_OHOS) ++ void DidCompleteSwapWithNewSizeOHOS(const gfx::Size& size) override; ++#endif ++ + mojo::Receiver receiver_{this}; + #if BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_WIN) + gfx::AcceleratedWidget widget_; +diff --git a/src/components/viz/host/host_frame_sink_manager.cc b/src/components/viz/host/host_frame_sink_manager.cc +index a0f46cac7ec..2c105ef4bb3 +--- a/src/components/viz/host/host_frame_sink_manager.cc ++++ b/src/components/viz/host/host_frame_sink_manager.cc +@@ -67,7 +67,7 @@ void HostFrameSinkManager::RegisterFrameSinkId( + DCHECK(client); + + FrameSinkData& data = frame_sink_data_map_[frame_sink_id]; +- DCHECK(!data.IsFrameSinkRegistered()); ++ CHECK(!data.IsFrameSinkRegistered()); + DCHECK(!data.has_created_compositor_frame_sink); + data.client = client; + data.report_activation = report_activation; +@@ -86,7 +86,7 @@ void HostFrameSinkManager::InvalidateFrameSinkId( + DCHECK(frame_sink_id.is_valid()); + + FrameSinkData& data = frame_sink_data_map_[frame_sink_id]; +- DCHECK(data.IsFrameSinkRegistered()); ++ CHECK(data.IsFrameSinkRegistered()); + + const bool destroy_synchronously = + data.has_created_compositor_frame_sink && data.wait_on_destruction; +@@ -226,14 +226,14 @@ bool HostFrameSinkManager::RegisterFrameSinkHierarchy( + return false; + } + ++ FrameSinkData& parent_data = iter->second; ++ CHECK(!base::Contains(parent_data.children, child_frame_sink_id)); ++ parent_data.children.push_back(child_frame_sink_id); ++ + // Register and store the parent. + frame_sink_manager_->RegisterFrameSinkHierarchy(parent_frame_sink_id, + child_frame_sink_id); + +- FrameSinkData& parent_data = iter->second; +- DCHECK(!base::Contains(parent_data.children, child_frame_sink_id)); +- parent_data.children.push_back(child_frame_sink_id); +- + return true; + } + +@@ -242,8 +242,9 @@ void HostFrameSinkManager::UnregisterFrameSinkHierarchy( + const FrameSinkId& child_frame_sink_id) { + // Unregister and clear the stored parent. + FrameSinkData& parent_data = frame_sink_data_map_[parent_frame_sink_id]; +- DCHECK(base::Contains(parent_data.children, child_frame_sink_id)); +- base::Erase(parent_data.children, child_frame_sink_id); ++ size_t num_erased = base::Erase(parent_data.children, child_frame_sink_id); ++ CHECK_EQ(num_erased, 1u); ++ + if (parent_data.IsEmpty()) + frame_sink_data_map_.erase(parent_frame_sink_id); + +diff --git a/src/components/viz/service/BUILD.gn b/src/components/viz/service/BUILD.gn +index a1d74b50e24..138e2f17131 +--- a/src/components/viz/service/BUILD.gn ++++ b/src/components/viz/service/BUILD.gn +@@ -336,6 +336,13 @@ viz_component("service") { + deps += [ ":service_jni_headers" ] + } + ++ if (is_ohos) { ++ sources += [ ++ "frame_sinks/external_begin_frame_source_ohos.cc", ++ "frame_sinks/external_begin_frame_source_ohos.h", ++ ] ++ } ++ + if (use_ozone) { + sources += [ + "display/overlay_processor_ozone.cc", +diff --git a/src/components/viz/service/display/display.cc b/src/components/viz/service/display/display.cc +index 9e0de84e820..45a47c2189b +--- a/src/components/viz/service/display/display.cc ++++ b/src/components/viz/service/display/display.cc +@@ -518,6 +518,12 @@ void Display::DisableSwapUntilResize( + std::move(no_pending_swaps_callback).Run(); + } + ++#if BUILDFLAG(IS_OHOS) ++void Display::SetShouldFrameSubmissionBeforeDraw(bool should) { ++ scheduler_->SetShouldFrameSubmissionBeforeDraw(should); ++} ++#endif ++ + void Display::SetColorMatrix(const skia::Matrix44& matrix) { + if (output_surface_) + output_surface_->set_color_matrix(matrix); +diff --git a/src/components/viz/service/display/display.h b/src/components/viz/service/display/display.h +index 4e559e75869..660fc6ae2be +--- a/src/components/viz/service/display/display.h ++++ b/src/components/viz/service/display/display.h +@@ -141,6 +141,10 @@ class VIZ_SERVICE_EXPORT Display : public DisplaySchedulerClient, + // may be run immediately. + void DisableSwapUntilResize(base::OnceClosure no_pending_swaps_callback); + ++#if BUILDFLAG(IS_OHOS) ++ void SetShouldFrameSubmissionBeforeDraw(bool should); ++#endif ++ + // Sets the color matrix that will be used to transform the output of this + // display. This is only supported for GPU compositing. + void SetColorMatrix(const skia::Matrix44& matrix); +diff --git a/src/components/viz/service/display/display_scheduler.cc b/src/components/viz/service/display/display_scheduler.cc +index 536160e4b10..26d2ea4126b +--- a/src/components/viz/service/display/display_scheduler.cc ++++ b/src/components/viz/service/display/display_scheduler.cc +@@ -122,6 +122,18 @@ void DisplayScheduler::OnDisplayDamaged(SurfaceId surface_id) { + base::AutoReset auto_reset(&inside_surface_damaged_, true); + + needs_draw_ = true; ++#if BUILDFLAG(IS_OHOS) ++ TRACE_EVENT1("viz", "DisplayScheduler::OnDisplayDamaged", "surface_id", ++ surface_id.ToString()); ++ if (wait_render_frame_submission_before_draw_ && ++ surface_id.frame_sink_id().client_id() != 0) { ++ TRACE_EVENT1("viz", ++ "DisplayScheduler::OnDisplayDamaged received render frame", ++ "surface_id", surface_id.ToString()); ++ wait_render_frame_submission_deadline_callback_.Cancel(); ++ wait_render_frame_submission_before_draw_ = false; ++ } ++#endif + MaybeStartObservingBeginFrames(); + UpdateHasPendingSurfaces(); + ScheduleBeginFrameDeadline(); +@@ -141,6 +153,26 @@ base::TimeDelta DisplayScheduler::GetDeadlineOffset( + return BeginFrameArgs::DefaultEstimatedDisplayDrawTime(interval); + } + ++#if BUILDFLAG(IS_OHOS) ++constexpr int WAIT_RENDER_FRAME_DEADLINE_INTERVAL_MILLISECONDS = 200; ++void DisplayScheduler::SetShouldFrameSubmissionBeforeDraw(bool should) { ++ wait_render_frame_submission_before_draw_ = should; ++ wait_render_frame_submission_deadline_callback_.Reset( ++ base::BindOnce(&DisplayScheduler::ResetShouldFrameSubmissionBeforeDraw, ++ weak_ptr_factory_.GetWeakPtr())); ++ ++ TRACE_EVENT0("viz", "DisplayScheduler::SetShouldFrameSubmissionBeforeDraw"); ++ task_runner_->PostDelayedTask( ++ FROM_HERE, wait_render_frame_submission_deadline_callback_.callback(), ++ base::Milliseconds(WAIT_RENDER_FRAME_DEADLINE_INTERVAL_MILLISECONDS)); ++} ++ ++void DisplayScheduler::ResetShouldFrameSubmissionBeforeDraw() { ++ TRACE_EVENT0("viz", "DisplayScheduler::ResetShouldFrameSubmissionBeforeDraw"); ++ wait_render_frame_submission_before_draw_ = false; ++} ++#endif ++ + // This is used to force an immediate swap before a resize. + void DisplayScheduler::ForceImmediateSwapIfPossible() { + TRACE_EVENT0("viz", "DisplayScheduler::ForceImmediateSwapIfPossible"); +@@ -245,7 +277,12 @@ bool DisplayScheduler::OnBeginFrame(const BeginFrameArgs& args) { + + // If we get another BeginFrame before the previous deadline, + // synchronously trigger the previous deadline before progressing. ++#if BUILDFLAG(IS_OHOS) ++ if (inside_begin_frame_deadline_interval_ && ++ !wait_render_frame_submission_before_draw_) ++#else + if (inside_begin_frame_deadline_interval_) ++#endif + OnBeginFrameDeadline(); + + // Schedule the deadline. +@@ -362,6 +399,13 @@ DisplayScheduler::AdjustedBeginFrameDeadlineMode() const { + + DisplayScheduler::BeginFrameDeadlineMode + DisplayScheduler::DesiredBeginFrameDeadlineMode() const { ++#if BUILDFLAG(IS_OHOS) ++ if (wait_render_frame_submission_before_draw_) { ++ TRACE_EVENT0("viz", "Wait for render frame submission before draw"); ++ return BeginFrameDeadlineMode::kNone; ++ } ++#endif ++ + if (output_surface_lost_) { + TRACE_EVENT_INSTANT0("viz", "Lost output surface", + TRACE_EVENT_SCOPE_THREAD); +diff --git a/src/components/viz/service/display/display_scheduler.h b/src/components/viz/service/display/display_scheduler.h +index 5e8c43c3b21..84dfc26b577 +--- a/src/components/viz/service/display/display_scheduler.h ++++ b/src/components/viz/service/display/display_scheduler.h +@@ -61,6 +61,11 @@ class VIZ_SERVICE_EXPORT DisplayScheduler + // DynamicBeginFrameDeadlineOffsetSource: + base::TimeDelta GetDeadlineOffset(base::TimeDelta interval) const override; + ++#if BUILDFLAG(IS_OHOS) ++ void SetShouldFrameSubmissionBeforeDraw(bool should) override; ++ void ResetShouldFrameSubmissionBeforeDraw(); ++#endif ++ + protected: + class BeginFrameObserver; + class BeginFrameRequestObserverImpl; +@@ -152,6 +157,12 @@ class VIZ_SERVICE_EXPORT DisplayScheduler + const absl::optional dynamic_scheduler_deadlines_percentile_; + + base::WeakPtrFactory weak_ptr_factory_{this}; ++ ++#if BUILDFLAG(IS_OHOS) ++private: ++ bool wait_render_frame_submission_before_draw_ = false; ++ base::CancelableOnceClosure wait_render_frame_submission_deadline_callback_; ++#endif + }; + + } // namespace viz +diff --git a/src/components/viz/service/display/display_scheduler_base.h b/src/components/viz/service/display/display_scheduler_base.h +index 4a8f64808cc..f0b55ec6cc6 +--- a/src/components/viz/service/display/display_scheduler_base.h ++++ b/src/components/viz/service/display/display_scheduler_base.h +@@ -54,6 +54,9 @@ class VIZ_SERVICE_EXPORT DisplaySchedulerBase + virtual void ReportFrameTime( + base::TimeDelta frame_time, + base::flat_set thread_ids) = 0; ++#if BUILDFLAG(IS_OHOS) ++ virtual void SetShouldFrameSubmissionBeforeDraw(bool should) = 0; ++#endif + + protected: + raw_ptr client_ = nullptr; +diff --git a/src/components/viz/service/display_embedder/compositor_gpu_thread.cc b/src/components/viz/service/display_embedder/compositor_gpu_thread.cc +index f935a02e822..983f8724a25 +--- a/src/components/viz/service/display_embedder/compositor_gpu_thread.cc ++++ b/src/components/viz/service/display_embedder/compositor_gpu_thread.cc +@@ -100,16 +100,17 @@ bool CompositorGpuThread::Initialize() { + StartWithOptions(std::move(thread_options)); + + // Wait until threas is started and Init() is executed in order to return +- // updated |init_succeded_|. ++ // updated |init_succeeded_|. + WaitUntilThreadStarted(); +- return init_succeded_; ++ return init_succeeded_; + } + + void CompositorGpuThread::Init() { + const auto& gpu_preferences = gpu_channel_manager_->gpu_preferences(); +- if (enable_watchdog_) { ++ if (enable_watchdog_ && gpu_channel_manager_->watchdog()) { + watchdog_thread_ = gpu::GpuWatchdogThread::Create( +- gpu_preferences.watchdog_starts_backgrounded, "GpuWatchdog_Compositor"); ++ gpu_preferences.watchdog_starts_backgrounded, ++ gpu_channel_manager_->watchdog(), "GpuWatchdog_Compositor"); + } + + // Create a new share group. Note that this share group is different from the +@@ -173,7 +174,7 @@ void CompositorGpuThread::Init() { + } + if (watchdog_thread_) + watchdog_thread_->OnInitComplete(); +- init_succeded_ = true; ++ init_succeeded_ = true; + } + + void CompositorGpuThread::CleanUp() { +diff --git a/src/components/viz/service/display_embedder/compositor_gpu_thread.h b/src/components/viz/service/display_embedder/compositor_gpu_thread.h +index 5cf2c6b21c0..4673e08688a +--- a/src/components/viz/service/display_embedder/compositor_gpu_thread.h ++++ b/src/components/viz/service/display_embedder/compositor_gpu_thread.h +@@ -71,7 +71,7 @@ class VIZ_SERVICE_EXPORT CompositorGpuThread + + raw_ptr gpu_channel_manager_; + const bool enable_watchdog_; +- bool init_succeded_ = false; ++ bool init_succeeded_ = false; + + scoped_refptr vulkan_context_provider_; + +diff --git a/src/components/viz/service/frame_sinks/compositor_frame_sink_support.cc b/src/components/viz/service/frame_sinks/compositor_frame_sink_support.cc +index 3a15976c2a9..62fcc47682c +--- a/src/components/viz/service/frame_sinks/compositor_frame_sink_support.cc ++++ b/src/components/viz/service/frame_sinks/compositor_frame_sink_support.cc +@@ -37,6 +37,12 @@ + namespace viz { + namespace { + ++#if BUILDFLAG(IS_OHOS) ++ static uint32_t g_firstScrollingFrame = 0; ++ static bool g_isScrolling = false; ++ constexpr int g_scrolledFrameCount = 30; ++#endif ++ + void RecordShouldSendBeginFrame(const std::string& reason) { + TRACE_EVENT1("viz", "ShouldNotSendBeginFrame", "reason", reason); + } +@@ -325,6 +331,15 @@ void CompositorFrameSinkSupport::OnSurfacePresented( + base::TimeTicks draw_start_timestamp, + const gfx::SwapTimings& swap_timings, + const gfx::PresentationFeedback& feedback) { ++#if BUILDFLAG(IS_OHOS) ++ if (g_firstScrollingFrame == frame_token) { ++ TRACE_EVENT1("viz", "CompositorFrameSinkSupport::OnSurfacePresented", ++ "sliding response end frame", frame_token); ++ LOG(DEBUG) << "CompositorFrameSinkSupport::OnSurfacePresented " ++ "sliding response end"; ++ } ++#endif ++ + DidPresentCompositorFrame(frame_token, draw_start_timestamp, swap_timings, + feedback); + } +@@ -529,6 +544,19 @@ SubmitResult CompositorFrameSinkSupport::MaybeSubmitCompositorFrame( + CHECK(callback_received_begin_frame_); + CHECK(callback_received_receive_ack_); + ++#if BUILDFLAG(IS_OHOS) ++ if (g_isScrolling == false && frame.metadata.is_scrolling == true) { ++ g_firstScrollingFrame = frame.metadata.frame_token; ++ g_isScrolling = true; ++ } ++ ++ if (g_isScrolling == true && frame.metadata.is_scrolling == false && ++ (uint32_t)(frame.metadata.frame_token - g_firstScrollingFrame) >= ++ g_scrolledFrameCount) { ++ g_isScrolling = false; ++ } ++#endif ++ + begin_frame_tracker_.ReceivedAck(frame.metadata.begin_frame_ack); + ++ack_pending_count_; + +diff --git a/src/components/viz/service/frame_sinks/external_begin_frame_source_ohos.cc b/src/components/viz/service/frame_sinks/external_begin_frame_source_ohos.cc +new file mode 100644 +index 00000000000..d00adacdbc9 +--- /dev/null ++++ b/src/components/viz/service/frame_sinks/external_begin_frame_source_ohos.cc +@@ -0,0 +1,110 @@ ++#include "components/viz/service/frame_sinks/external_begin_frame_source_ohos.h" ++#include ++#include ++ ++#include "base/bind.h" ++#include "base/logging.h" ++#include "base/threading/thread_task_runner_handle.h" ++#include "base/trace_event/trace_event.h" ++#include "ohos_adapter_helper.h" ++ ++namespace viz { ++using namespace OHOS::NWeb; ++ ++constexpr int VSYNC_PERIOD_MICROSECONDS = 16666; ++ ++class ExternalBeginFrameSourceOHOS::VSyncUserData { ++ public: ++ VSyncUserData(const scoped_refptr& current, ++ viz::ExternalBeginFrameSourceOHOS* weakPtr) ++ : current_(current), weakPtr_(weakPtr){ ++ LOG(INFO) << "VSyncUserData constructor!!!"; ++ }; ++ VSyncUserData(const VSyncUserData&) = delete; ++ VSyncUserData& operator=(const VSyncUserData&) = delete; ++ ~VSyncUserData() { ++ LOG(INFO) << "VSyncUserData destructor!!!"; ++ }; ++ ++ const scoped_refptr& current_; ++ base::WeakPtrFactory weakPtr_; ++}; ++ ++ExternalBeginFrameSourceOHOS::ExternalBeginFrameSourceOHOS(uint32_t restart_id) ++ : ExternalBeginFrameSource(this, restart_id), ++ vsync_notification_enabled_(false), ++ user_data_( ++ std::make_unique(base::ThreadTaskRunnerHandle::Get(), ++ this)), ++ vsync_adapter_(OhosAdapterHelper::GetInstance().GetVSyncAdapter()) { ++ TRACE_EVENT0("viz", ++ "ExternalBeginFrameSourceOHOS::ExternalBeginFrameSourceOHOS"); ++ LOG(INFO) << "ExternalBeginFrameSourceOHOS constructor!!!"; ++} ++ ++ExternalBeginFrameSourceOHOS::~ExternalBeginFrameSourceOHOS() { ++ LOG(INFO) << "ExternalBeginFrameSourceOHOS destructor!!!"; ++ SetEnabled(false); ++} ++ ++void ExternalBeginFrameSourceOHOS::SetDynamicBeginFrameDeadlineOffsetSource( ++ DynamicBeginFrameDeadlineOffsetSource* ++ dynamic_begin_frame_deadline_offset_source) { ++ TRACE_EVENT0( ++ "viz", ++ "ExternalBeginFrameSourceOHOS::SetDynamicBeginFrameDeadlineOffsetSource"); ++ begin_frame_args_generator_.set_dynamic_begin_frame_deadline_offset_source( ++ dynamic_begin_frame_deadline_offset_source); ++} ++ ++void ExternalBeginFrameSourceOHOS::OnVSync(int64_t timestamp, void* data) { ++ if (data == nullptr) { ++ LOG(ERROR) << "OnVSync data is nullptr"; ++ return; ++ } ++ VSyncUserData* userData = reinterpret_cast(data); ++ if (!userData->current_) { ++ LOG(ERROR) << "OnVSync data current is nullptr"; ++ return; ++ } ++ ++ userData->current_->PostTask( ++ FROM_HERE, base::BindOnce(&ExternalBeginFrameSourceOHOS::OnVSyncImpl, ++ userData->weakPtr_.GetWeakPtr(), timestamp)); ++} ++ ++void ExternalBeginFrameSourceOHOS::OnVSyncImpl(int64_t timestamp) { ++ if (!vsync_notification_enabled_) { ++ return; ++ } ++ ++ base::TimeDelta vsync_period(base::Microseconds(VSYNC_PERIOD_MICROSECONDS)); ++ base::TimeTicks frame_time = base::TimeTicks() + base::Nanoseconds(timestamp); ++ base::TimeTicks deadline = frame_time + vsync_period; ++ TRACE_EVENT2("viz", "ExternalBeginFrameSourceOHOS::OnVSyncImpl", "frame_time", ++ frame_time, "deadline", deadline); ++ auto begin_frame_args = begin_frame_args_generator_.GenerateBeginFrameArgs( ++ source_id(), frame_time, deadline, vsync_period); ++ OnBeginFrame(begin_frame_args); ++ ++ vsync_adapter_->RequestVsync(reinterpret_cast(user_data_.get()), ++ ExternalBeginFrameSourceOHOS::OnVSync); ++} ++ ++void ExternalBeginFrameSourceOHOS::OnNeedsBeginFrames(bool needs_begin_frames) { ++ SetEnabled(needs_begin_frames); ++} ++ ++void ExternalBeginFrameSourceOHOS::SetEnabled(bool enabled) { ++ if (vsync_notification_enabled_ == enabled) { ++ return; ++ } ++ TRACE_EVENT1("viz", "ExternalBeginFrameSourceOHOS::SetEnabled", "enabled", ++ enabled); ++ vsync_notification_enabled_ = enabled; ++ if (vsync_notification_enabled_) { ++ vsync_adapter_->RequestVsync(reinterpret_cast(user_data_.get()), ++ ExternalBeginFrameSourceOHOS::OnVSync); ++ } ++} ++} // namespace viz +diff --git a/src/components/viz/service/frame_sinks/external_begin_frame_source_ohos.h b/src/components/viz/service/frame_sinks/external_begin_frame_source_ohos.h +new file mode 100644 +index 00000000000..40e423037bb +--- /dev/null ++++ b/src/components/viz/service/frame_sinks/external_begin_frame_source_ohos.h +@@ -0,0 +1,46 @@ ++#ifndef COMPONENTS_VIZ_SERVICE_FRAME_SINKS_EXTERNAL_BEGIN_FRAME_SOURCE_OHOS_H_ ++#define COMPONENTS_VIZ_SERVICE_FRAME_SINKS_EXTERNAL_BEGIN_FRAME_SOURCE_OHOS_H_ ++ ++#include ++#include ++ ++#include "base/time/time.h" ++#include "components/viz/common/frame_sinks/begin_frame_source.h" ++#include "components/viz/service/viz_service_export.h" ++#include "graphic_adapter.h" ++ ++namespace viz { ++class VIZ_SERVICE_EXPORT ExternalBeginFrameSourceOHOS ++ : public ExternalBeginFrameSource, ++ public ExternalBeginFrameSourceClient { ++ public: ++ explicit ExternalBeginFrameSourceOHOS(uint32_t restart_id); ++ ~ExternalBeginFrameSourceOHOS() override; ++ ExternalBeginFrameSourceOHOS(const ExternalBeginFrameSourceOHOS&) = delete; ++ ExternalBeginFrameSourceOHOS& operator=(const ExternalBeginFrameSourceOHOS&) = ++ delete; ++ ++ // BeginFrameSource: ++ void SetDynamicBeginFrameDeadlineOffsetSource( ++ DynamicBeginFrameDeadlineOffsetSource* ++ dynamic_begin_frame_deadline_offset_source) override; ++ ++ static void OnVSync(int64_t timestamp, void* data); ++ void OnVSyncImpl(int64_t timestamp); ++ ++ private: ++ // ExternalBeginFrameSourceClient implementation. ++ void OnNeedsBeginFrames(bool needs_begin_frames) override; ++ ++ void SetEnabled(bool enabled); ++ ++ BeginFrameArgsGenerator begin_frame_args_generator_; ++ bool vsync_notification_enabled_; ++ ++ class VSyncUserData; ++ std::unique_ptr user_data_; ++ std::unique_ptr vsync_adapter_; ++}; ++} // namespace viz ++ ++#endif +\ No newline at end of file +diff --git a/src/components/viz/service/frame_sinks/frame_sink_manager_impl.cc b/src/components/viz/service/frame_sinks/frame_sink_manager_impl.cc +index af6699140ba..f5e4b72943f +--- a/src/components/viz/service/frame_sinks/frame_sink_manager_impl.cc ++++ b/src/components/viz/service/frame_sinks/frame_sink_manager_impl.cc +@@ -277,7 +277,7 @@ void FrameSinkManagerImpl::UnregisterFrameSinkHierarchy( + } + + auto iter = frame_sink_source_map_.find(parent_frame_sink_id); +- DCHECK(iter != frame_sink_source_map_.end()); ++ CHECK(iter != frame_sink_source_map_.end()); + + // Remove |child_frame_sink_id| from parents list of children. + auto& mapping = iter->second; +diff --git a/src/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.cc b/src/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.cc +index d272c371741..c80dac5e0ff +--- a/src/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.cc ++++ b/src/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.cc +@@ -29,6 +29,10 @@ + #include "components/viz/service/frame_sinks/external_begin_frame_source_android.h" + #endif + ++#if BUILDFLAG(IS_OHOS) ++#include "components/viz/service/frame_sinks/external_begin_frame_source_ohos.h" ++#endif ++ + namespace viz { + + // static +@@ -93,6 +97,9 @@ RootCompositorFrameSinkImpl::Create( + std::make_unique( + restart_id, params->refresh_rate, + /*requires_align_with_java=*/false); ++#elif BUILDFLAG(IS_OHOS) ++ external_begin_frame_source = ++ std::make_unique(restart_id); + #else + if (params->disable_frame_rate_limit) { + synthetic_begin_frame_source = +@@ -217,6 +224,19 @@ void RootCompositorFrameSinkImpl::DisableSwapUntilResize( + } + #endif + ++#if BUILDFLAG(IS_OHOS) ++void RootCompositorFrameSinkImpl::SetShouldFrameSubmissionBeforeDraw( ++ bool should, ++ SetShouldFrameSubmissionBeforeDrawCallback callback) { ++ TRACE_EVENT1( ++ "viz", "RootCompositorFrameSinkImpl::SetShouldFrameSubmissionBeforeDraw", ++ "should", should); ++ display_->SetShouldFrameSubmissionBeforeDraw(should); ++ if (callback) ++ std::move(callback).Run(); ++} ++#endif ++ + void RootCompositorFrameSinkImpl::Resize(const gfx::Size& size) { + if (!display_->resize_based_on_root_surface()) + display_->Resize(size); +@@ -526,10 +546,14 @@ void RootCompositorFrameSinkImpl::DisplayDidCompleteSwapWithSize( + display_client_->DidCompleteSwapWithSize(pixel_size); + // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch + // of lacros-chrome is complete. +-#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) ++#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) || BUILDFLAG(IS_OHOS) + if (display_client_ && pixel_size != last_swap_pixel_size_) { + last_swap_pixel_size_ = pixel_size; ++#if BUILDFLAG(IS_OHOS) ++ display_client_->DidCompleteSwapWithNewSizeOHOS(last_swap_pixel_size_); ++#else + display_client_->DidCompleteSwapWithNewSize(last_swap_pixel_size_); ++#endif + } + #else + NOTREACHED(); +diff --git a/src/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.h b/src/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.h +index 97d2f93b115..bc7d9152164 +--- a/src/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.h ++++ b/src/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.h +@@ -69,6 +69,11 @@ class VIZ_SERVICE_EXPORT RootCompositorFrameSinkImpl + void SetDisplayVisible(bool visible) override; + #if BUILDFLAG(IS_WIN) + void DisableSwapUntilResize(DisableSwapUntilResizeCallback callback) override; ++#endif ++#if BUILDFLAG(IS_OHOS) ++ void SetShouldFrameSubmissionBeforeDraw( ++ bool should, ++ SetShouldFrameSubmissionBeforeDrawCallback callback) override; + #endif + void Resize(const gfx::Size& size) override; + void SetDisplayColorMatrix(const gfx::Transform& color_matrix) override; +@@ -189,7 +194,7 @@ class VIZ_SERVICE_EXPORT RootCompositorFrameSinkImpl + + // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch + // of lacros-chrome is complete. +-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) ++#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) || BUILDFLAG(IS_OHOS) + gfx::Size last_swap_pixel_size_; + #endif + +diff --git a/src/content/browser/BUILD.gn b/src/content/browser/BUILD.gn +index 81479f4fb36..71405facd3b +--- a/src/content/browser/BUILD.gn ++++ b/src/content/browser/BUILD.gn +@@ -2234,10 +2234,9 @@ source_set("browser") { + "media/session/audio_focus_delegate_ohos.h", + ] + +- libs = [ +- "surface.z", +- "media_client.z", +- ] ++ deps += [ "//components/printing/common" ] ++ ++ libs = [ "nweb_ohos_adapter.z" ] + include_dirs = ohos_src_includes + lib_dirs = ohos_libs_dir + } +diff --git a/src/content/browser/child_process_launcher_helper_linux.cc b/src/content/browser/child_process_launcher_helper_linux.cc +index 062c9d21d9e..ddc35357de8 +--- a/src/content/browser/child_process_launcher_helper_linux.cc ++++ b/src/content/browser/child_process_launcher_helper_linux.cc +@@ -119,15 +119,18 @@ ChildProcessLauncherHelper::LaunchProcessOnLauncherThread( + argv_ss << argv_str[argv_str.size() - 1]; + constexpr int SHARED_FD_INDEX = 0; + constexpr int IPC_FD_INDEX = 1; ++ constexpr int CRASH_SIGNAL_FD_INDEX = 2; + int32_t shared_fd = options.fds_to_remap[SHARED_FD_INDEX].first; + int32_t ipc_fd = options.fds_to_remap[IPC_FD_INDEX].first; ++ int32_t crash_signal_fd = options.fds_to_remap[CRASH_SIGNAL_FD_INDEX].first; ++ + pid_t render_pid = 0; + if (app_mgr_client_adapter_ == nullptr) { + app_mgr_client_adapter_ = + OHOS::NWeb::OhosAdapterHelper::GetInstance().CreateAafwkAdapter(); + } + int ret = app_mgr_client_adapter_->StartRenderProcess( +- argv_ss.str(), ipc_fd, shared_fd, render_pid); ++ argv_ss.str(), ipc_fd, shared_fd, crash_signal_fd, render_pid); + if (ret != 0) { + LOG(ERROR) << "start render process error, ret=" << ret + << ", render pid=" << render_pid; +diff --git a/src/content/browser/child_process_security_policy_impl.cc b/src/content/browser/child_process_security_policy_impl.cc +index f20399d4536..a3f543f6a9f +--- a/src/content/browser/child_process_security_policy_impl.cc ++++ b/src/content/browser/child_process_security_policy_impl.cc +@@ -400,6 +400,22 @@ class ChildProcessSecurityPolicyImpl::SecurityState { + } + #endif + ++#if BUILDFLAG(IS_OHOS) ++ // Determine if the certain permissions have been granted to a datashare URI. ++ bool HasPermissionsForDatashareUri(const base::FilePath& file, ++ int permissions) { ++ DCHECK(!file.empty()); ++ DCHECK(file.IsDataShareUri()); ++ if (!permissions) ++ return false; ++ base::FilePath file_path = file.StripTrailingSeparators(); ++ FileMap::const_iterator it = file_permissions_.find(file_path); ++ if (it != file_permissions_.end()) ++ return (it->second & permissions) == permissions; ++ return false; ++ } ++#endif ++ + void GrantBindings(int bindings) { + enabled_bindings_ |= bindings; + } +@@ -465,6 +481,10 @@ class ChildProcessSecurityPolicyImpl::SecurityState { + #if BUILDFLAG(IS_ANDROID) + if (file.IsContentUri()) + return HasPermissionsForContentUri(file, permissions); ++#endif ++#if BUILDFLAG(IS_OHOS) ++ if (file.IsDataShareUri()) ++ return HasPermissionsForDatashareUri(file, permissions); + #endif + if (!permissions || file.empty() || !file.IsAbsolute()) + return false; +diff --git a/src/content/browser/compositor/viz_process_transport_factory.cc b/src/content/browser/compositor/viz_process_transport_factory.cc +index 8a1e93995b3..7cae640beae +--- a/src/content/browser/compositor/viz_process_transport_factory.cc ++++ b/src/content/browser/compositor/viz_process_transport_factory.cc +@@ -415,6 +415,10 @@ void VizProcessTransportFactory::OnEstablishedGpuChannel( + features::ShouldUseSetPresentDuration(); + #endif // BUILDFLAG(IS_WIN) + ++#if BUILDFLAG(IS_OHOS) ++ root_params->send_swap_size_notifications = true; ++#endif ++ + // Connects the viz process end of CompositorFrameSink message pipes. The + // browser compositor may request a new CompositorFrameSink on context loss, + // which will destroy the existing CompositorFrameSink. +diff --git a/src/content/browser/devtools/auction_worklet_devtools_agent_host.cc b/src/content/browser/devtools/auction_worklet_devtools_agent_host.cc +index 4513d63a496..e00a9a5282d +--- a/src/content/browser/devtools/auction_worklet_devtools_agent_host.cc ++++ b/src/content/browser/devtools/auction_worklet_devtools_agent_host.cc +@@ -89,7 +89,7 @@ AuctionWorkletDevToolsAgentHost::~AuctionWorkletDevToolsAgentHost() = default; + + void AuctionWorkletDevToolsAgentHost::WorkletDestroyed() { + worklet_ = nullptr; +- ForceDetachAllSessions(); ++ auto retain_this = ForceDetachAllSessionsImpl(); + GetRendererChannel()->SetRenderer(mojo::NullRemote(), mojo::NullReceiver(), + ChildProcessHost::kInvalidUniqueID); + } +diff --git a/src/content/browser/devtools/devtools_agent_host_impl.cc b/src/content/browser/devtools/devtools_agent_host_impl.cc +index 90bd78fe1ea..d529c62a208 +--- a/src/content/browser/devtools/devtools_agent_host_impl.cc ++++ b/src/content/browser/devtools/devtools_agent_host_impl.cc +@@ -345,12 +345,18 @@ bool DevToolsAgentHostImpl::Inspect() { + } + + void DevToolsAgentHostImpl::ForceDetachAllSessions() { +- scoped_refptr protect(this); ++ std::ignore = ForceDetachAllSessionsImpl(); ++} ++ ++scoped_refptr ++DevToolsAgentHostImpl::ForceDetachAllSessionsImpl() { ++ scoped_refptr retain_this(this); + while (!sessions_.empty()) { + DevToolsAgentHostClient* client = (*sessions_.begin())->GetClient(); + DetachClient(client); + client->AgentHostClosed(this); + } ++ return retain_this; + } + + void DevToolsAgentHostImpl::ForceDetachRestrictedSessions( +diff --git a/src/content/browser/devtools/devtools_agent_host_impl.h b/src/content/browser/devtools/devtools_agent_host_impl.h +index dab989d6b4e..a2bf1457e43 +--- a/src/content/browser/devtools/devtools_agent_host_impl.h ++++ b/src/content/browser/devtools/devtools_agent_host_impl.h +@@ -123,6 +123,10 @@ class CONTENT_EXPORT DevToolsAgentHostImpl : public DevToolsAgentHost { + DevToolsRendererChannel* GetRendererChannel() { return &renderer_channel_; } + + const std::vector& sessions() const { return sessions_; } ++ // Returns refptr retaining `this`. All other references may be removed ++ // at this point, so `this` will become invalid as soon as returned refptr ++ // gets destroyed. ++ [[nodiscard]] scoped_refptr ForceDetachAllSessionsImpl(); + + private: + friend class DevToolsAgentHost; // for static methods +diff --git a/src/content/browser/devtools/devtools_http_handler.cc b/src/content/browser/devtools/devtools_http_handler.cc +index 73248513b77..ff9aad0e92a +--- a/src/content/browser/devtools/devtools_http_handler.cc ++++ b/src/content/browser/devtools/devtools_http_handler.cc +@@ -10,6 +10,7 @@ + #include + + #include "base/bind.h" ++#include "base/command_line.h" + #include "base/compiler_specific.h" + #include "base/files/file_util.h" + #include "base/guid.h" +@@ -36,6 +37,7 @@ + #include "content/public/browser/devtools_manager_delegate.h" + #include "content/public/browser/devtools_socket_factory.h" + #include "content/public/common/content_client.h" ++#include "content/public/common/content_switches.h" + #include "content/public/common/url_constants.h" + #include "content/public/common/user_agent.h" + #include "net/base/escape.h" +@@ -719,6 +721,13 @@ void DevToolsHttpHandler::OnWebSocketRequest( + if (!thread_) + return; + ++ if (request.headers.count("origin") && ++ !remote_allow_origins_.count(request.headers.at("origin")) && ++ !remote_allow_origins_.count("*")) { ++ Send403(connection_id); ++ return; ++ } ++ + if (base::StartsWith(request.path, browser_guid_, + base::CompareCase::SENSITIVE)) { + scoped_refptr browser_agent = +@@ -790,6 +799,14 @@ DevToolsHttpHandler::DevToolsHttpHandler( + output_directory, debug_frontend_dir, browser_guid_, + delegate_->HasBundledFrontendResources())); + } ++ std::string remote_allow_origins = base::ToLowerASCII( ++ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( ++ switches::kRemoteAllowOrigins)); ++ ++ auto origins = ++ base::SplitString(remote_allow_origins, ",", base::TRIM_WHITESPACE, ++ base::SPLIT_WANT_NONEMPTY); ++ remote_allow_origins_.insert(origins.begin(), origins.end()); + } + + void DevToolsHttpHandler::ServerStarted( +@@ -820,6 +837,7 @@ void DevToolsHttpHandler::SendJson(int connection_id, + base::JSONWriter::Write(base::Value(message), &json_message); + + net::HttpServerResponseInfo response(status_code); ++ response.AddHeader("Content-Security-Policy", "frame-ancestors 'none'"); + response.SetBody(json_value + message, "application/json; charset=UTF-8"); + + thread_->task_runner()->PostTask( +@@ -848,6 +866,18 @@ void DevToolsHttpHandler::Send404(int connection_id) { + base::Unretained(server_wrapper_.get()), connection_id)); + } + ++void DevToolsHttpHandler::Send403(int connection_id) { ++ if (!thread_) { ++ return; ++ } ++ net::HttpServerResponseInfo response(net::HTTP_FORBIDDEN); ++ response.SetBody(std::string(), "text/html"); ++ thread_->task_runner()->PostTask( ++ FROM_HERE, base::BindOnce(&ServerWrapper::SendResponse, ++ base::Unretained(server_wrapper_.get()), ++ connection_id, response)); ++} ++ + void DevToolsHttpHandler::Send500(int connection_id, + const std::string& message) { + if (!thread_) +diff --git a/src/content/browser/devtools/devtools_http_handler.h b/src/content/browser/devtools/devtools_http_handler.h +index e12f1b54d0e..1110228d5c0 +--- a/src/content/browser/devtools/devtools_http_handler.h ++++ b/src/content/browser/devtools/devtools_http_handler.h +@@ -7,6 +7,7 @@ + + #include + #include ++#include + #include + + #include "base/files/file_path.h" +@@ -90,6 +91,7 @@ class DevToolsHttpHandler { + const std::string& data, + const std::string& mime_type); + void Send404(int connection_id); ++ void Send403(int connection_id); + void Send500(int connection_id, + const std::string& message); + void AcceptWebSocket(int connection_id, +@@ -106,6 +108,7 @@ class DevToolsHttpHandler { + base::Value SerializeDescriptor(scoped_refptr agent_host, + const std::string& host); + ++ std::set remote_allow_origins_; + // The thread used by the devtools handler to run server socket. + std::unique_ptr thread_; + std::string browser_guid_; +diff --git a/src/content/browser/devtools/protocol/network_handler.cc b/src/content/browser/devtools/protocol/network_handler.cc +index b89325cd536..d6246f0d9cb +--- a/src/content/browser/devtools/protocol/network_handler.cc ++++ b/src/content/browser/devtools/protocol/network_handler.cc +@@ -1248,7 +1248,7 @@ void NetworkHandler::SetRenderer(int render_process_host_id, + browser_context_ = nullptr; + } + host_ = frame_host; +- if (background_sync_restorer_ && storage_partition_) ++ if (background_sync_restorer_) + background_sync_restorer_->SetStoragePartition(storage_partition_); + } + +diff --git a/src/content/browser/devtools/render_frame_devtools_agent_host.cc b/src/content/browser/devtools/render_frame_devtools_agent_host.cc +index 2200e60394b..80a993c01f9 +--- a/src/content/browser/devtools/render_frame_devtools_agent_host.cc ++++ b/src/content/browser/devtools/render_frame_devtools_agent_host.cc +@@ -549,9 +549,9 @@ void RenderFrameDevToolsAgentHost::RenderFrameDeleted(RenderFrameHost* rfh) { + } + + void RenderFrameDevToolsAgentHost::DestroyOnRenderFrameGone() { +- scoped_refptr protect(this); ++ scoped_refptr retain_this; + if (IsAttached()) { +- ForceDetachAllSessions(); ++ retain_this = ForceDetachAllSessionsImpl(); + UpdateRawHeadersAccess(frame_host_); + } + ChangeFrameHostAndObservedProcess(nullptr); +diff --git a/src/content/browser/devtools/service_worker_devtools_agent_host.cc b/src/content/browser/devtools/service_worker_devtools_agent_host.cc +index 372b1b3407b..b21ee7bbb59 +--- a/src/content/browser/devtools/service_worker_devtools_agent_host.cc ++++ b/src/content/browser/devtools/service_worker_devtools_agent_host.cc +@@ -315,14 +315,11 @@ void ServiceWorkerDevToolsAgentHost::UpdateProcessHost() { + process_observation_.Observe(rph); + } + +-// TODO(caseq): this is only relevant for shutdown, where a RPH may +-// go along with StoragePartition and we won't receive any signals from +-// the DevToolsWorkerManager, so agents would be still attached and +-// may access the storage partition. This is meant to be a temporary +-// workaround, the proper fix is likely to have ServiceWorkerInstance +-// deleted in such case. + void ServiceWorkerDevToolsAgentHost::RenderProcessHostDestroyed( + RenderProcessHost* host) { ++ scoped_refptr retain_this; ++ if (context_wrapper_->process_manager()->IsShutdown()) ++ retain_this = ForceDetachAllSessionsImpl(); + GetRendererChannel()->SetRenderer(mojo::NullRemote(), mojo::NullReceiver(), + ChildProcessHost::kInvalidUniqueID); + process_observation_.Reset(); +diff --git a/src/content/browser/devtools/worker_devtools_agent_host.cc b/src/content/browser/devtools/worker_devtools_agent_host.cc +index dec63fe8c35..5c9c4e360fe +--- a/src/content/browser/devtools/worker_devtools_agent_host.cc ++++ b/src/content/browser/devtools/worker_devtools_agent_host.cc +@@ -87,7 +87,7 @@ void WorkerDevToolsAgentHost::ChildWorkerCreated( + } + + void WorkerDevToolsAgentHost::Disconnected() { +- ForceDetachAllSessions(); ++ auto retain_this = ForceDetachAllSessionsImpl(); + GetRendererChannel()->SetRenderer(mojo::NullRemote(), mojo::NullReceiver(), + ChildProcessHost::kInvalidUniqueID); + std::move(destroyed_callback_).Run(this); +diff --git a/src/content/browser/loader/file_url_loader_factory.cc b/src/content/browser/loader/file_url_loader_factory.cc +index 700ecae5009..c78443a2911 +--- a/src/content/browser/loader/file_url_loader_factory.cc ++++ b/src/content/browser/loader/file_url_loader_factory.cc +@@ -365,6 +365,297 @@ class FileURLDirectoryLoader + bool transfer_in_progress_ = false; + }; + ++#if BUILDFLAG(IS_OHOS) ++constexpr int32_t APPLICATION_API_10 = 10; ++ ++int32_t GetApplicationApiVersion() ++{ ++ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kOhosAppApiVersion)) { ++ LOG(ERROR) << "kOhosAppApiVersion not exist"; ++ return -1; ++ } ++ std::string apiVersion = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( ++ switches::kOhosAppApiVersion); ++ if (apiVersion.empty()) { ++ return -1; ++ } ++ return std::stoi(apiVersion); ++} ++ ++class ResourceURLLoader : public network::mojom::URLLoader { ++ public: ++ static void CreateAndStart( ++ const base::FilePath& profile_path, ++ const network::ResourceRequest& request, ++ network::mojom::FetchResponseType response_type, ++ mojo::PendingReceiver loader, ++ mojo::PendingRemote client_remote, ++ std::unique_ptr observer, ++ scoped_refptr extra_response_headers) { ++ auto* resource_url_loader = new ResourceURLLoader; ++ resource_url_loader->Start(profile_path, request, response_type, ++ std::move(loader), std::move(client_remote), ++ std::move(observer), ++ std::move(extra_response_headers)); ++ } ++ ++ ResourceURLLoader(const ResourceURLLoader&) = delete; ++ ResourceURLLoader& operator=(const ResourceURLLoader&) = delete; ++ ++ // network::mojom::URLLoader: ++ void FollowRedirect( ++ const std::vector& removed_headers, ++ const net::HttpRequestHeaders& modified_headers, ++ const net::HttpRequestHeaders& modified_cors_exempt_headers, ++ const absl::optional& new_url) override {} ++ void SetPriority(net::RequestPriority priority, ++ int32_t intra_priority_value) override {} ++ void PauseReadingBodyFromNet() override {} ++ void ResumeReadingBodyFromNet() override {} ++ ++ private: ++ ResourceURLLoader() = default; ++ ~ResourceURLLoader() override = default; ++ ++ void Start(const base::FilePath& profile_path, ++ const network::ResourceRequest& request, ++ network::mojom::FetchResponseType response_type, ++ mojo::PendingReceiver loader, ++ mojo::PendingRemote client_remote, ++ std::unique_ptr observer, ++ scoped_refptr extra_response_headers) { ++ auto head = network::mojom::URLResponseHead::New(); ++ head->request_start = base::TimeTicks::Now(); ++ head->response_start = base::TimeTicks::Now(); ++ head->response_type = response_type; ++ head->headers = extra_response_headers; ++ receiver_.Bind(std::move(loader)); ++ receiver_.set_disconnect_handler(base::BindOnce( ++ &ResourceURLLoader::OnMojoDisconnect, base::Unretained(this))); ++ client_.Bind(std::move(client_remote)); ++ ++ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kOhosHapPath)) { ++ LOG(ERROR) << "kOhosHapPath not exist"; ++ OnClientComplete(net::ERR_FAILED, std::move(observer)); ++ return; ++ } ++ std::string resourcesPath; ++ if (request.url.SchemeIs(url::kResourcesScheme)) { ++ resourcesPath = "resources/"; ++ resourcesPath += request.url.host() + request.url.path(); ++ } else if (request.url.SchemeIs(url::kFileScheme)) { ++ base::FilePath path; ++ if (!net::FileURLToFilePath(request.url, &path)) { ++ LOG(ERROR) << "url invalid: " << request.url.spec(); ++ OnClientComplete(net::ERR_FAILED, std::move(observer)); ++ return; ++ } ++ std::string strPath = path.MaybeAsASCII(); ++ size_t nPos = strPath.find("resources/"); ++ if (nPos == std::string::npos) { ++ LOG(ERROR) << "is not a file under the resources folder: " << request.url.spec(); ++ OnClientComplete(net::ERR_FILE_NOT_FOUND, std::move(observer)); ++ return; ++ } ++ resourcesPath = strPath.substr(nPos); ++ } else { ++ LOG(ERROR) << "url scheme error"; ++ OnClientComplete(net::ERR_FAILED, std::move(observer)); ++ return; ++ } ++ LOG(INFO) << "ResourceURLLoader url: " << request.url.spec() ++ << ", path: " << resourcesPath; ++ std::string hapPath = ++ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( ++ switches::kOhosHapPath); ++ mojo::ScopedDataPipeProducerHandle producer_handle; ++ mojo::ScopedDataPipeConsumerHandle consumer_handle; ++ if (mojo::CreateDataPipe(kDefaultFileUrlPipeSize, producer_handle, ++ consumer_handle) != MOJO_RESULT_OK) { ++ OnClientComplete(net::ERR_FAILED, std::move(observer)); ++ return; ++ } ++ if (observer) ++ observer->OnStart(); ++ size_t length = 0; ++ std::unique_ptr data; ++ auto resourceInstance = ++ OHOS::NWeb::OhosAdapterHelper::GetInstance().GetResourceAdapter( ++ hapPath); ++ mojo::DataPipeProducer::DataSource::ReadResult read_result; ++ if (!resourceInstance->GetRawFileData(resourcesPath, length, data, false)) { ++ LOG(ERROR) << "ResourceURLLoader GetRawFileData failed"; ++ read_result.result = MOJO_RESULT_NOT_FOUND; ++ if (observer) { ++ observer->OnRead(base::span(), &read_result); ++ observer->OnDone(); ++ } ++ client_->OnComplete(network::URLLoaderCompletionStatus( ++ ConvertMojoResultToNetError(read_result.result))); ++ client_.reset(); ++ MaybeDeleteSelf(); ++ return; ++ } ++ LOG(INFO) << "GetRawFileData length: " << length; ++ read_result.result = MOJO_RESULT_OK; ++ read_result.bytes_read = ++ length > net::kMaxBytesToSniff ? net::kMaxBytesToSniff : length; ++ std::vector initial_read_buffer; ++ char* dataPtr = reinterpret_cast(data.get()); ++ initial_read_buffer.insert(initial_read_buffer.end(), dataPtr, ++ dataPtr + length); ++ if (observer) ++ observer->OnRead(base::span(initial_read_buffer), &read_result); ++ ++ uint64_t initial_read_size = read_result.bytes_read; ++ std::string range_header; ++ net::HttpByteRange byte_range; ++ if (request.headers.GetHeader(net::HttpRequestHeaders::kRange, ++ &range_header)) { ++ // Handle a simple Range header for a single range. ++ std::vector ranges; ++ bool fail = false; ++ if (net::HttpUtil::ParseRangeHeader(range_header, &ranges) && ++ ranges.size() == 1) { ++ byte_range = ranges[0]; ++ if (!byte_range.ComputeBounds(length)) { ++ fail = true; ++ } ++ } else { ++ fail = true; ++ } ++ if (fail) { ++ OnClientComplete(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE, ++ std::move(observer)); ++ return; ++ } ++ } ++ uint64_t first_byte_to_send = 0; ++ uint64_t total_bytes_to_send = length; ++ if (byte_range.IsValid()) { ++ first_byte_to_send = byte_range.first_byte_position(); ++ total_bytes_to_send = ++ byte_range.last_byte_position() - first_byte_to_send + 1; ++ } ++ total_bytes_written_ = total_bytes_to_send; ++ head->content_length = base::saturated_cast(total_bytes_to_send); ++ ++ if (first_byte_to_send < initial_read_size) { ++ uint32_t write_size = std::min( ++ static_cast(initial_read_size - first_byte_to_send), ++ static_cast(total_bytes_to_send)); ++ const uint32_t expected_write_size = write_size; ++ MojoResult result = ++ producer_handle->WriteData(&initial_read_buffer[first_byte_to_send], ++ &write_size, MOJO_WRITE_DATA_FLAG_NONE); ++ if (result != MOJO_RESULT_OK || write_size != expected_write_size) { ++ OnFileWritten(std::move(observer), nullptr, result); ++ LOG(ERROR) << "ResourceURLLoader WriteData failed"; ++ return; ++ } ++ // Discount the bytes we just sent from the total range. ++ first_byte_to_send = initial_read_size; ++ total_bytes_to_send -= write_size; ++ } ++ const base::FilePath::CharType* resource_file_path = ++ FILE_PATH_LITERAL(resourcesPath.c_str()); ++ if (!net::GetMimeTypeFromFile(base::FilePath(resource_file_path), ++ &head->mime_type)) { ++ std::string new_type; ++ net::SniffMimeType( ++ base::StringPiece(initial_read_buffer.data(), read_result.bytes_read), ++ request.url, head->mime_type, ++ GetContentClient()->browser()->ForceSniffingFileUrlsForHtml() ++ ? net::ForceSniffFileUrlsForHtml::kEnabled ++ : net::ForceSniffFileUrlsForHtml::kDisabled, ++ &new_type); ++ head->mime_type.assign(new_type); ++ head->did_mime_sniff = true; ++ } ++ if (!head->headers) { ++ head->headers = ++ base::MakeRefCounted("HTTP/1.1 200 OK"); ++ } ++ LOG(INFO) << "ResourceURLLoader AddHeader mime_type " << head->mime_type; ++ head->headers->AddHeader(net::HttpRequestHeaders::kContentType, ++ head->mime_type); ++ client_->OnReceiveResponse(std::move(head), ++ mojo::ScopedDataPipeConsumerHandle()); ++ client_->OnStartLoadingResponseBody(std::move(consumer_handle)); ++ LOG(INFO) << "total_bytes_to_send: " << total_bytes_to_send; ++ if (total_bytes_to_send == 0) { ++ // There's definitely no more data, so we're already done. ++ OnFileWritten(std::move(observer), nullptr, MOJO_RESULT_OK); ++ return; ++ } ++ if (observer) ++ observer->OnSeekComplete(first_byte_to_send); ++ data_producer_ = ++ std::make_unique(std::move(producer_handle)); ++ base::StringPiece string_piece((char*)data.get() + first_byte_to_send, ++ total_bytes_to_send); ++ data_producer_->Write( ++ std::make_unique( ++ string_piece, mojo::StringDataSource::AsyncWritingMode:: ++ STRING_STAYS_VALID_UNTIL_COMPLETION), ++ base::BindOnce(&ResourceURLLoader::OnFileWritten, ++ base::Unretained(this), nullptr, std::move(data))); ++ } ++ ++ void OnMojoDisconnect() { ++ data_producer_.reset(); ++ receiver_.reset(); ++ client_.reset(); ++ MaybeDeleteSelf(); ++ } ++ ++ void OnClientComplete(net::Error net_error, ++ std::unique_ptr observer) { ++ client_->OnComplete(network::URLLoaderCompletionStatus(net_error)); ++ client_.reset(); ++ if (observer) { ++ if (net_error != net::OK) { ++ mojo::DataPipeProducer::DataSource::ReadResult result; ++ result.result = ConvertNetErrorToMojoResult(net_error); ++ observer->OnRead(base::span(), &result); ++ } ++ observer->OnDone(); ++ } ++ MaybeDeleteSelf(); ++ } ++ ++ void MaybeDeleteSelf() { ++ if (!receiver_.is_bound() && !client_.is_bound()) ++ delete this; ++ } ++ ++ void OnFileWritten(std::unique_ptr observer, ++ std::unique_ptr write_data, ++ MojoResult result) { ++ data_producer_.reset(); ++ if (observer) ++ observer->OnDone(); ++ ++ if (result == MOJO_RESULT_OK) { ++ network::URLLoaderCompletionStatus status(net::OK); ++ status.encoded_data_length = total_bytes_written_; ++ status.encoded_body_length = total_bytes_written_; ++ status.decoded_body_length = total_bytes_written_; ++ client_->OnComplete(status); ++ } else { ++ client_->OnComplete(network::URLLoaderCompletionStatus(net::ERR_FAILED)); ++ } ++ client_.reset(); ++ MaybeDeleteSelf(); ++ } ++ ++ std::unique_ptr data_producer_; ++ mojo::Receiver receiver_{this}; ++ mojo::Remote client_; ++ ++ uint64_t total_bytes_written_ = 0; ++}; ++#endif + class FileURLLoader : public network::mojom::URLLoader { + public: + static void CreateAndStart( +@@ -378,6 +669,19 @@ class FileURLLoader : public network::mojom::URLLoader { + LinkFollowingPolicy link_following_policy, + std::unique_ptr observer, + scoped_refptr extra_response_headers) { ++#if BUILDFLAG(IS_OHOS) ++ int32_t apiVersion = GetApplicationApiVersion(); ++ if (apiVersion > 0 && apiVersion < APPLICATION_API_10) { ++ LOG(INFO) << "application api version: " << apiVersion; ++ base::FilePath path; ++ base::File::Info info; ++ if (!net::FileURLToFilePath(request.url, &path) || !base::GetFileInfo(path, &info)) { ++ ResourceURLLoader::CreateAndStart(profile_path, request, response_type, std::move(loader), ++ std::move(client_remote), std::move(observer), std::move(extra_response_headers)); ++ return; ++ } ++ } ++#endif + // Owns itself. Will live as long as its URLLoader and URLLoaderClient + // bindings are alive - essentially until either the client gives up or all + // file data has been sent to it. +@@ -776,262 +1080,6 @@ class FileURLLoader : public network::mojom::URLLoader { + // to the URLLoaderClients (eg SimpleURLLoader). + uint64_t total_bytes_written_ = 0; + }; +- +-#if BUILDFLAG(IS_OHOS) +-class ResourceURLLoader : public network::mojom::URLLoader { +- public: +- static void CreateAndStart( +- const base::FilePath& profile_path, +- const network::ResourceRequest& request, +- network::mojom::FetchResponseType response_type, +- mojo::PendingReceiver loader, +- mojo::PendingRemote client_remote, +- std::unique_ptr observer, +- scoped_refptr extra_response_headers) { +- auto* resource_url_loader = new ResourceURLLoader; +- resource_url_loader->Start(profile_path, request, response_type, +- std::move(loader), std::move(client_remote), +- std::move(observer), +- std::move(extra_response_headers)); +- } +- +- ResourceURLLoader(const ResourceURLLoader&) = delete; +- ResourceURLLoader& operator=(const ResourceURLLoader&) = delete; +- +- // network::mojom::URLLoader: +- void FollowRedirect( +- const std::vector& removed_headers, +- const net::HttpRequestHeaders& modified_headers, +- const net::HttpRequestHeaders& modified_cors_exempt_headers, +- const absl::optional& new_url) override {} +- void SetPriority(net::RequestPriority priority, +- int32_t intra_priority_value) override {} +- void PauseReadingBodyFromNet() override {} +- void ResumeReadingBodyFromNet() override {} +- +- private: +- ResourceURLLoader() = default; +- ~ResourceURLLoader() override = default; +- +- void Start(const base::FilePath& profile_path, +- const network::ResourceRequest& request, +- network::mojom::FetchResponseType response_type, +- mojo::PendingReceiver loader, +- mojo::PendingRemote client_remote, +- std::unique_ptr observer, +- scoped_refptr extra_response_headers) { +- auto head = network::mojom::URLResponseHead::New(); +- head->request_start = base::TimeTicks::Now(); +- head->response_start = base::TimeTicks::Now(); +- head->response_type = response_type; +- head->headers = extra_response_headers; +- receiver_.Bind(std::move(loader)); +- receiver_.set_disconnect_handler(base::BindOnce( +- &ResourceURLLoader::OnMojoDisconnect, base::Unretained(this))); +- client_.Bind(std::move(client_remote)); +- +- if (!request.url.SchemeIs(url::kResourcesScheme) || +- !base::CommandLine::ForCurrentProcess()->HasSwitch( +- switches::kOhosHapPath)) { +- LOG(ERROR) << "url scheme error or kOhosHapPath not exist"; +- OnClientComplete(net::ERR_FAILED, std::move(observer)); +- return; +- } +- std::string hapPath = +- base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( +- switches::kOhosHapPath); +- std::string resourcesPath = "resources/"; +- resourcesPath = resourcesPath + request.url.host() + request.url.path(); +- LOG(INFO) << "ResourceURLLoader url: " << request.url.spec() +- << ", path: " << resourcesPath; +- mojo::ScopedDataPipeProducerHandle producer_handle; +- mojo::ScopedDataPipeConsumerHandle consumer_handle; +- if (mojo::CreateDataPipe(kDefaultFileUrlPipeSize, producer_handle, +- consumer_handle) != MOJO_RESULT_OK) { +- OnClientComplete(net::ERR_FAILED, std::move(observer)); +- return; +- } +- if (observer) +- observer->OnStart(); +- size_t length = 0; +- std::unique_ptr data; +- auto resourceInstance = +- OHOS::NWeb::OhosAdapterHelper::GetInstance().GetResourceAdapter( +- hapPath); +- mojo::DataPipeProducer::DataSource::ReadResult read_result; +- if (!resourceInstance->GetRawFileData(resourcesPath, length, data, false)) { +- LOG(ERROR) << "ResourceURLLoader GetRawFileData failed"; +- read_result.result = MOJO_RESULT_NOT_FOUND; +- if (observer) { +- observer->OnRead(base::span(), &read_result); +- observer->OnDone(); +- } +- client_->OnComplete(network::URLLoaderCompletionStatus( +- ConvertMojoResultToNetError(read_result.result))); +- client_.reset(); +- MaybeDeleteSelf(); +- return; +- } +- LOG(INFO) << "GetRawFileData length: " << length; +- read_result.result = MOJO_RESULT_OK; +- read_result.bytes_read = +- length > net::kMaxBytesToSniff ? net::kMaxBytesToSniff : length; +- std::vector initial_read_buffer; +- char* dataPtr = reinterpret_cast(data.get()); +- initial_read_buffer.insert(initial_read_buffer.end(), dataPtr, +- dataPtr + length); +- if (observer) +- observer->OnRead(base::span(initial_read_buffer), &read_result); +- +- uint64_t initial_read_size = read_result.bytes_read; +- std::string range_header; +- net::HttpByteRange byte_range; +- if (request.headers.GetHeader(net::HttpRequestHeaders::kRange, +- &range_header)) { +- // Handle a simple Range header for a single range. +- std::vector ranges; +- bool fail = false; +- if (net::HttpUtil::ParseRangeHeader(range_header, &ranges) && +- ranges.size() == 1) { +- byte_range = ranges[0]; +- if (!byte_range.ComputeBounds(length)) { +- fail = true; +- } +- } else { +- fail = true; +- } +- if (fail) { +- OnClientComplete(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE, +- std::move(observer)); +- return; +- } +- } +- uint64_t first_byte_to_send = 0; +- uint64_t total_bytes_to_send = length; +- if (byte_range.IsValid()) { +- first_byte_to_send = byte_range.first_byte_position(); +- total_bytes_to_send = +- byte_range.last_byte_position() - first_byte_to_send + 1; +- } +- total_bytes_written_ = total_bytes_to_send; +- head->content_length = base::saturated_cast(total_bytes_to_send); +- +- if (first_byte_to_send < initial_read_size) { +- uint32_t write_size = std::min( +- static_cast(initial_read_size - first_byte_to_send), +- static_cast(total_bytes_to_send)); +- const uint32_t expected_write_size = write_size; +- MojoResult result = +- producer_handle->WriteData(&initial_read_buffer[first_byte_to_send], +- &write_size, MOJO_WRITE_DATA_FLAG_NONE); +- if (result != MOJO_RESULT_OK || write_size != expected_write_size) { +- OnFileWritten(std::move(observer), nullptr, result); +- LOG(ERROR) << "ResourceURLLoader WriteData failed"; +- return; +- } +- // Discount the bytes we just sent from the total range. +- first_byte_to_send = initial_read_size; +- total_bytes_to_send -= write_size; +- } +- const base::FilePath::CharType* resource_file_path = +- FILE_PATH_LITERAL(resourcesPath.c_str()); +- if (!net::GetMimeTypeFromFile(base::FilePath(resource_file_path), +- &head->mime_type)) { +- std::string new_type; +- net::SniffMimeType( +- base::StringPiece(initial_read_buffer.data(), read_result.bytes_read), +- request.url, head->mime_type, +- GetContentClient()->browser()->ForceSniffingFileUrlsForHtml() +- ? net::ForceSniffFileUrlsForHtml::kEnabled +- : net::ForceSniffFileUrlsForHtml::kDisabled, +- &new_type); +- head->mime_type.assign(new_type); +- head->did_mime_sniff = true; +- } +- if (!head->headers) { +- head->headers = +- base::MakeRefCounted("HTTP/1.1 200 OK"); +- } +- LOG(INFO) << "ResourceURLLoader AddHeader mime_type " << head->mime_type; +- head->headers->AddHeader(net::HttpRequestHeaders::kContentType, +- head->mime_type); +- client_->OnReceiveResponse(std::move(head), +- mojo::ScopedDataPipeConsumerHandle()); +- client_->OnStartLoadingResponseBody(std::move(consumer_handle)); +- LOG(INFO) << "total_bytes_to_send: " << total_bytes_to_send; +- if (total_bytes_to_send == 0) { +- // There's definitely no more data, so we're already done. +- OnFileWritten(std::move(observer), nullptr, MOJO_RESULT_OK); +- return; +- } +- if (observer) +- observer->OnSeekComplete(first_byte_to_send); +- data_producer_ = +- std::make_unique(std::move(producer_handle)); +- base::StringPiece string_piece((char*)data.get() + first_byte_to_send, +- total_bytes_to_send); +- data_producer_->Write( +- std::make_unique( +- string_piece, mojo::StringDataSource::AsyncWritingMode:: +- STRING_STAYS_VALID_UNTIL_COMPLETION), +- base::BindOnce(&ResourceURLLoader::OnFileWritten, +- base::Unretained(this), nullptr, std::move(data))); +- } +- +- void OnMojoDisconnect() { +- data_producer_.reset(); +- receiver_.reset(); +- client_.reset(); +- MaybeDeleteSelf(); +- } +- +- void OnClientComplete(net::Error net_error, +- std::unique_ptr observer) { +- client_->OnComplete(network::URLLoaderCompletionStatus(net_error)); +- client_.reset(); +- if (observer) { +- if (net_error != net::OK) { +- mojo::DataPipeProducer::DataSource::ReadResult result; +- result.result = ConvertNetErrorToMojoResult(net_error); +- observer->OnRead(base::span(), &result); +- } +- observer->OnDone(); +- } +- MaybeDeleteSelf(); +- } +- +- void MaybeDeleteSelf() { +- if (!receiver_.is_bound() && !client_.is_bound()) +- delete this; +- } +- +- void OnFileWritten(std::unique_ptr observer, +- std::unique_ptr write_data, +- MojoResult result) { +- data_producer_.reset(); +- if (observer) +- observer->OnDone(); +- +- if (result == MOJO_RESULT_OK) { +- network::URLLoaderCompletionStatus status(net::OK); +- status.encoded_data_length = total_bytes_written_; +- status.encoded_body_length = total_bytes_written_; +- status.decoded_body_length = total_bytes_written_; +- client_->OnComplete(status); +- } else { +- client_->OnComplete(network::URLLoaderCompletionStatus(net::ERR_FAILED)); +- } +- client_.reset(); +- MaybeDeleteSelf(); +- } +- +- std::unique_ptr data_producer_; +- mojo::Receiver receiver_{this}; +- mojo::Remote client_; +- +- uint64_t total_bytes_written_ = 0; +-}; +-#endif + } // namespace + + FileURLLoaderFactory::FileURLLoaderFactory( +diff --git a/src/content/browser/media/audio_output_stream_broker.cc b/src/content/browser/media/audio_output_stream_broker.cc +index fac37f636cf..a7f041a2d12 +--- a/src/content/browser/media/audio_output_stream_broker.cc ++++ b/src/content/browser/media/audio_output_stream_broker.cc +@@ -16,8 +16,11 @@ + #include "media/audio/audio_logging.h" + #include "media/mojo/mojom/audio_data_pipe.mojom.h" + +-namespace content { ++#if BUILDFLAG(IS_OHOS) ++#include "base/logging.h" ++#endif + ++namespace content { + namespace { + + // Used in Media.Audio.Render.StreamBrokerDisconnectReason2 histogram, matches +@@ -71,12 +74,20 @@ AudioOutputStreamBroker::AudioOutputStreamBroker( + mojo::PendingRemote client) + : AudioStreamBroker(render_process_id, render_frame_id), + output_device_id_(output_device_id), ++#if !BUILDFLAG(IS_OHOS) + params_(params), ++#endif + group_id_(group_id), + deleter_(std::move(deleter)), + client_(std::move(client)), + observer_(render_process_id, render_frame_id, stream_id), + observer_receiver_(&observer_) { ++#if BUILDFLAG(IS_OHOS) ++ media::AudioParameters preParams = params; ++ preParams.set_render_process_id(render_process_id); ++ preParams.set_render_frame_id(render_frame_id); ++ params_ = preParams; ++#endif + DCHECK(client_); + DCHECK(deleter_); + DCHECK(group_id_); +diff --git a/src/content/browser/media/audio_output_stream_broker.h b/src/content/browser/media/audio_output_stream_broker.h +index 60a3dfef45d..107e54dc97f +--- a/src/content/browser/media/audio_output_stream_broker.h ++++ b/src/content/browser/media/audio_output_stream_broker.h +@@ -61,7 +61,11 @@ class CONTENT_EXPORT AudioOutputStreamBroker final : public AudioStreamBroker { + SEQUENCE_CHECKER(owning_sequence_); + + const std::string output_device_id_; ++#if BUILDFLAG(IS_OHOS) ++ media::AudioParameters params_; ++#else + const media::AudioParameters params_; ++#endif + const base::UnguessableToken group_id_; + + // Set while CreateStream() has been called, but not StreamCreated(). +diff --git a/src/content/browser/media/audio_stream_broker.h b/src/content/browser/media/audio_stream_broker.h +index 2290884e7a2..061459084b3 +--- a/src/content/browser/media/audio_stream_broker.h ++++ b/src/content/browser/media/audio_stream_broker.h +@@ -16,6 +16,10 @@ + #include "mojo/public/cpp/bindings/pending_remote.h" + #include "third_party/blink/public/mojom/media/renderer_audio_input_stream_factory.mojom.h" + ++#if BUILDFLAG(IS_OHOS) ++#include "content/public/browser/web_contents.h" ++#endif ++ + namespace base { + class UnguessableToken; + } +diff --git a/src/content/browser/media/forwarding_audio_stream_factory.cc b/src/content/browser/media/forwarding_audio_stream_factory.cc +index 20b4c9c02f2..2db5e7c7a44 +--- a/src/content/browser/media/forwarding_audio_stream_factory.cc ++++ b/src/content/browser/media/forwarding_audio_stream_factory.cc +@@ -48,7 +48,6 @@ void BindStreamFactoryFromUIThread( + } + + } // namespace +- + ForwardingAudioStreamFactory::Core::Core( + base::WeakPtr owner, + media::UserInputMonitorBase* user_input_monitor, +diff --git a/src/content/browser/media/ohos/ohos_media_player_renderer.cc b/src/content/browser/media/ohos/ohos_media_player_renderer.cc +index 80d5dc9c7a2..5cb76930877 +--- a/src/content/browser/media/ohos/ohos_media_player_renderer.cc ++++ b/src/content/browser/media/ohos/ohos_media_player_renderer.cc +@@ -95,17 +95,17 @@ void OHOSMediaPlayerRenderer::SetPlaybackRate(double playback_rate) { + if (playback_rate <= 0) { + media_player_->Pause(); + } else { +- OHOS::Media::PlaybackRateMode mode; ++ OHOS::NWeb::PlaybackRateMode mode; + if (playback_rate < 1) { +- mode = OHOS::Media::SPEED_FORWARD_0_75_X; ++ mode = OHOS::NWeb::PlaybackRateMode::SPEED_FORWARD_0_75_X; + } else if (playback_rate < 1.25) { +- mode = OHOS::Media::SPEED_FORWARD_1_00_X; ++ mode = OHOS::NWeb::PlaybackRateMode::SPEED_FORWARD_1_00_X; + } else if (playback_rate < 1.75) { +- mode = OHOS::Media::SPEED_FORWARD_1_25_X; ++ mode = OHOS::NWeb::PlaybackRateMode::SPEED_FORWARD_1_25_X; + } else if (playback_rate < 2) { +- mode = OHOS::Media::SPEED_FORWARD_1_75_X; ++ mode = OHOS::NWeb::PlaybackRateMode::SPEED_FORWARD_1_75_X; + } else { +- mode = OHOS::Media::SPEED_FORWARD_2_00_X; ++ mode = OHOS::NWeb::PlaybackRateMode::SPEED_FORWARD_2_00_X; + } + media_player_->SetPlaybackSpeed(mode); + media_player_->Start(); +diff --git a/src/content/browser/media/session/media_session_impl.h b/src/content/browser/media/session/media_session_impl.h +index 4c490fdb64c..b3fdbae04d8 +--- a/src/content/browser/media/session/media_session_impl.h ++++ b/src/content/browser/media/session/media_session_impl.h +@@ -321,6 +321,12 @@ class MediaSessionImpl : public MediaSession, + // Returns the Audio Focus request ID associated with this media session. + const base::UnguessableToken& GetRequestId() const; + ++#if BUILDFLAG(IS_OHOS) ++public: ++ int audioResumeInterval_ = 0; ++ bool audioExclusive_ = true; ++#endif ++ + private: + friend class content::WebContentsUserData; + friend class MediaSessionImplBrowserTest; +diff --git a/src/content/browser/network_context_client_base_impl.cc b/src/content/browser/network_context_client_base_impl.cc +index 6a1bef45a23..b3ab9749f31 +--- a/src/content/browser/network_context_client_base_impl.cc ++++ b/src/content/browser/network_context_client_base_impl.cc +@@ -20,6 +20,10 @@ + #include "base/android/content_uri_utils.h" + #endif + ++#if BUILDFLAG(IS_OHOS) ++#include "base/datashare_uri_utils.h" ++#endif ++ + namespace content { + + namespace { +@@ -49,8 +53,16 @@ void HandleFileUploadRequest( + } else { + files.emplace_back(file_path, file_flags); + } ++#else ++#if BUILDFLAG(IS_OHOS) ++ if (file_path.IsDataShareUri()) { ++ files.push_back(base::OpenDatashareUriForRead(file_path)); ++ } else { ++ files.emplace_back(file_path, file_flags); ++ } + #else + files.emplace_back(file_path, file_flags); ++#endif // BUILDFLAG(IS_OHOS) + #endif + if (!files.back().IsValid()) { + task_runner->PostTask( +diff --git a/src/content/browser/renderer_host/input/input_device_change_observer.cc b/src/content/browser/renderer_host/input/input_device_change_observer.cc +index 35a1020c10f..ceb31b55b69 +--- a/src/content/browser/renderer_host/input/input_device_change_observer.cc ++++ b/src/content/browser/renderer_host/input/input_device_change_observer.cc +@@ -9,7 +9,7 @@ + + #if BUILDFLAG(IS_WIN) + #include "ui/events/devices/input_device_observer_win.h" +-#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ++#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_OHOS) + #include "ui/events/devices/device_data_manager.h" + #elif BUILDFLAG(IS_ANDROID) + #include "ui/events/devices/input_device_observer_android.h" +@@ -21,7 +21,7 @@ InputDeviceChangeObserver::InputDeviceChangeObserver(RenderViewHostImpl* rvhi) { + render_view_host_impl_ = rvhi; + #if BUILDFLAG(IS_WIN) + ui::InputDeviceObserverWin::GetInstance()->AddObserver(this); +-#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ++#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_OHOS) + ui::DeviceDataManager::GetInstance()->AddObserver(this); + #elif BUILDFLAG(IS_ANDROID) + ui::InputDeviceObserverAndroid::GetInstance()->AddObserver(this); +@@ -31,7 +31,7 @@ InputDeviceChangeObserver::InputDeviceChangeObserver(RenderViewHostImpl* rvhi) { + InputDeviceChangeObserver::~InputDeviceChangeObserver() { + #if BUILDFLAG(IS_WIN) + ui::InputDeviceObserverWin::GetInstance()->RemoveObserver(this); +-#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ++#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_OHOS) + ui::DeviceDataManager::GetInstance()->RemoveObserver(this); + #elif BUILDFLAG(IS_ANDROID) + ui::InputDeviceObserverAndroid::GetInstance()->RemoveObserver(this); +diff --git a/src/content/browser/renderer_host/navigation_entry_impl.cc b/src/content/browser/renderer_host/navigation_entry_impl.cc +index 51e3d650bae..5848e9dc0c2 +--- a/src/content/browser/renderer_host/navigation_entry_impl.cc ++++ b/src/content/browser/renderer_host/navigation_entry_impl.cc +@@ -828,16 +828,13 @@ NavigationEntryImpl::ConstructCommonNavigationParams( + blink::mojom::NavigationType navigation_type, + base::TimeTicks navigation_start, + base::TimeTicks input_start) { +- blink::NavigationDownloadPolicy download_policy; +- if (IsViewSourceMode()) +- download_policy.SetDisallowed(blink::NavigationDownloadType::kViewSource); + // `base_url_for_data_url` is saved in NavigationEntry but should only be used + // by main frames, because loadData* navigations can only happen on the main + // frame. + bool is_for_main_frame = (root_node()->frame_entry == &frame_entry); + return blink::mojom::CommonNavigationParams::New( + dest_url, frame_entry.initiator_origin(), std::move(dest_referrer), +- GetTransitionType(), navigation_type, download_policy, ++ GetTransitionType(), navigation_type, blink::NavigationDownloadPolicy(), + // It's okay to pass false for `should_replace_entry` because we never + // replace an entry on session history / reload / restore navigation. New + // navigation that may use replacement create their CommonNavigationParams +diff --git a/src/content/browser/renderer_host/navigation_request.cc b/src/content/browser/renderer_host/navigation_request.cc +index 93dafabc7a0..08283c35486 +--- a/src/content/browser/renderer_host/navigation_request.cc ++++ b/src/content/browser/renderer_host/navigation_request.cc +@@ -1407,6 +1407,8 @@ NavigationRequest::NavigationRequest( + CHECK(!rfh_restored_from_back_forward_cache.WasInvalidated()); + ScopedCrashKeys crash_keys(*this); + ++ ComputeDownloadPolicy(); ++ + // There should be no navigations to about:newtab, about:version or other + // similar URLs (see https://crbug.com/1145717): + // +@@ -4312,7 +4314,13 @@ void NavigationRequest::CommitErrorPage( + } + } + ++ base::WeakPtr weak_self(weak_factory_.GetWeakPtr()); + ReadyToCommitNavigation(true /* is_error */); ++ // The caller above might result in the deletion of `this`. Return immediately ++ // if so. ++ if (!weak_self) { ++ return; ++ } + + // Use a separate cache shard, and no cookies, for error pages. + isolation_info_for_subresources_ = net::IsolationInfo::CreateTransient(); +@@ -7444,4 +7452,37 @@ std::string NavigationRequest::GetPrerenderEmbedderHistogramSuffix() { + return prerender_embedder_histogram_suffix_; + } + ++// The NavigationDownloadPolicy is currently computed by the renderer process. ++// The problem: not every navigation are initiated from the renderer. Most ++// fields from the bitfield can be computed from the browser process. This ++// function is a partial attempt at doing it. ++void NavigationRequest::ComputeDownloadPolicy() { ++ blink::NavigationDownloadPolicy& download_policy = ++ common_params_->download_policy; ++ ++ // [ViewSource] ++ if (GetNavigationEntry() && GetNavigationEntry()->IsViewSourceMode()) { ++ download_policy.SetDisallowed(blink::NavigationDownloadType::kViewSource); ++ } ++ ++ // [Sandbox] ++ if (base::FeatureList::IsEnabled( ++ features::kBrowserSideDownloadPolicySandbox) && ++ (commit_params_->frame_policy.sandbox_flags & ++ network::mojom::WebSandboxFlags::kDownloads) == ++ network::mojom::WebSandboxFlags::kDownloads) { ++ download_policy.SetDisallowed(blink::NavigationDownloadType::kSandbox); ++ } ++ ++ // TODO(arthursonzogni): Check if the following fields from the ++ // NavigationDownloadPolicy could be computed here from the browser process ++ // instead: ++ // ++ // [NoGesture] ++ // [OpenerCrossOrigin] ++ // [AdFrameNoGesture] ++ // [AdFrame] ++ // [Interstitial] ++} ++ + } // namespace content +diff --git a/src/content/browser/renderer_host/navigation_request.h b/src/content/browser/renderer_host/navigation_request.h +index 2d985bc9f49..afdd927c8a1 +--- a/src/content/browser/renderer_host/navigation_request.h ++++ b/src/content/browser/renderer_host/navigation_request.h +@@ -1488,6 +1488,14 @@ class CONTENT_EXPORT NavigationRequest + // 'prerender_frame_tree_node_id_' has an value assigned. + void MaybeAssignInvalidPrerenderFrameTreeNodeId(); + ++ // The NavigationDownloadPolicy is currently fully computed by the renderer ++ // process. It is left empty for browser side initiated navigation. This is a ++ // problem. This function is an incomplete attempt to start computing it from ++ // the browser process instead. ++ // TODO(https://crbug.com/1395742): Complete the implementation the browser ++ // side implementation. ++ void ComputeDownloadPolicy(); ++ + // Never null. The pointee node owns this navigation request instance. + FrameTreeNode* const frame_tree_node_; + +diff --git a/src/content/browser/renderer_host/navigation_request_browsertest.cc b/src/content/browser/renderer_host/navigation_request_browsertest.cc +index 5350838c820..61467989fe8 +--- a/src/content/browser/renderer_host/navigation_request_browsertest.cc ++++ b/src/content/browser/renderer_host/navigation_request_browsertest.cc +@@ -40,7 +40,9 @@ + #include "content/public/test/navigation_handle_observer.h" + #include "content/public/test/test_frame_navigation_observer.h" + #include "content/public/test/test_navigation_observer.h" ++#include "content/public/test/test_service.mojom.h" + #include "content/public/test/test_utils.h" ++#include "content/public/test/url_loader_interceptor.h" + #include "content/shell/browser/shell.h" + #include "content/shell/browser/shell_browser_context.h" + #include "content/shell/browser/shell_content_browser_client.h" +@@ -3387,4 +3389,83 @@ IN_PROC_BROWSER_TEST_F(CSPEmbeddedEnforcementBrowserTest, + } + } + ++// Tests that when trying to commit an error page for a failed navigation, but ++// the renderer process of the, the navigation won't commit and won't crash. ++// Regression test for https://crbug.com/1444360. ++IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest, ++ RendererCrashedBeforeCommitErrorPage) { ++ // Navigate to `url_a` first. ++ GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); ++ ASSERT_TRUE(NavigateToURL(shell(), url_a)); ++ ++ // Set up an URLLoaderInterceptor which will cause future navigations to fail. ++ auto url_loader_interceptor = std::make_unique( ++ base::BindRepeating([](URLLoaderInterceptor::RequestParams* params) { ++ network::URLLoaderCompletionStatus status; ++ status.error_code = net::ERR_NOT_IMPLEMENTED; ++ params->client->OnComplete(status); ++ return true; ++ })); ++ ++ // Do a navigation to `url_b1` that will fail and commit an error page. This ++ // is important so that the next error page navigation won't need to create a ++ // speculative RenderFrameHost (unless RenderDocument is enabled) and won't ++ // get cancelled earlier than commit time due to speculative RFH deletion. ++ GURL url_b1(embedded_test_server()->GetURL("b.com", "/title1.html")); ++ EXPECT_FALSE(NavigateToURL(shell(), url_b1)); ++ EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), url_b1); ++ EXPECT_TRUE( ++ shell()->web_contents()->GetMainFrame()->IsErrorDocument()); ++ ++ // For the next navigation, set up a throttle that will be used to wait for ++ // WillFailRequest() and then defer the navigation, so that we can crash the ++ // error page process first. ++ TestNavigationThrottleInstaller installer( ++ shell()->web_contents(), ++ NavigationThrottle::PROCEED /* will_start_result */, ++ NavigationThrottle::PROCEED /* will_redirect_result */, ++ NavigationThrottle::DEFER /* will_fail_result */, ++ NavigationThrottle::PROCEED /* will_process_result */); ++ ++ // Start a navigation to `url_b2` that will also fail, but before it commits ++ // an error page, cause the error page process to crash. ++ GURL url_b2(embedded_test_server()->GetURL("b.com", "/title2.html")); ++ TestNavigationManager manager(shell()->web_contents(), url_b2); ++ shell()->LoadURL(url_b2); ++ EXPECT_TRUE(manager.WaitForRequestStart()); ++ ++ // Resume the navigation and wait for WillFailRequest(). After this point, we ++ // will have picked the final RenderFrameHost & RenderProcessHost for the ++ // failed navigation. ++ manager.ResumeNavigation(); ++ installer.WaitForThrottleWillFail(); ++ ++ // Kill the error page process. This will cause for the navigation to `url_b2` ++ // to return early in `NavigationRequest::ReadyToCommitNavigation()` and not ++ // commit a new error page. ++ RenderProcessHost* process_to_kill = ++ manager.GetNavigationHandle()->GetRenderFrameHost()->GetProcess(); ++ ASSERT_TRUE(process_to_kill->IsInitializedAndNotDead()); ++ { ++ // Trigger a renderer kill by calling DoSomething() which will cause a bad ++ // message to be reported. ++ RenderProcessHostBadIpcMessageWaiter kill_waiter(process_to_kill); ++ mojo::Remote service; ++ process_to_kill->BindReceiver(service.BindNewPipeAndPassReceiver()); ++ service->DoSomething(base::DoNothing()); ++ EXPECT_EQ(bad_message::RPH_MOJO_PROCESS_ERROR, kill_waiter.Wait()); ++ } ++ ASSERT_FALSE(process_to_kill->IsInitializedAndNotDead()); ++ ++ // Resume the navigation, which won't commit. ++ if (!ShouldCreateNewHostForAllFrames()) { ++ installer.navigation_throttle()->ResumeNavigation(); ++ } ++ manager.WaitForNavigationFinished(); ++ EXPECT_FALSE(WaitForLoadStop(shell()->web_contents())); ++ ++ // The tab stayed at `url_b1` as the `url_b2` navigation didn't commit. ++ EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), url_b1); ++} ++ + } // namespace content +diff --git a/src/content/browser/renderer_host/render_frame_host_delegate.h b/src/content/browser/renderer_host/render_frame_host_delegate.h +index 2446566dfdf..3646321d852 +--- a/src/content/browser/renderer_host/render_frame_host_delegate.h ++++ b/src/content/browser/renderer_host/render_frame_host_delegate.h +@@ -146,6 +146,9 @@ class CONTENT_EXPORT RenderFrameHostDelegate { + const GURL& initiator_url, + blink::mojom::NavigationBlockedReason reason) {} + ++#if BUILDFLAG(IS_OHOS) ++ virtual void NotifyContextMenuWillShow() {} ++#endif + // Called when blink.mojom.LocalFrameHost::DidFinishLoad() is invoked. + virtual void OnDidFinishLoad(RenderFrameHostImpl* render_frame_host, + const GURL& url) {} +diff --git a/src/content/browser/renderer_host/render_frame_host_impl.cc b/src/content/browser/renderer_host/render_frame_host_impl.cc +index 518b6eca6e3..f0101b9b902 +--- a/src/content/browser/renderer_host/render_frame_host_impl.cc ++++ b/src/content/browser/renderer_host/render_frame_host_impl.cc +@@ -3104,7 +3104,7 @@ void RenderFrameHostImpl::RenderFrameCreated() { + // Initialize the RenderWidgetHost which marks it and the RenderViewHost as + // live before calling to the `delegate_`. + if (GetLocalRenderWidgetHost()) { +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || defined(OHOS_NWEB_EX) + GetLocalRenderWidgetHost()->SetForceEnableZoom( + delegate_->GetOrCreateWebPreferences().force_enable_zoom); + #endif // BUILDFLAG(IS_ANDROID) +@@ -5565,6 +5565,11 @@ void RenderFrameHostImpl::DidChangeBackgroundColor(SkColor background_color, + GetPage().DidChangeBackgroundColor(background_color, color_adjust); + } + ++#if BUILDFLAG(IS_OHOS) ++void RenderFrameHostImpl::NotifyContextMenuWillShow() { ++ delegate_->NotifyContextMenuWillShow(); ++} ++#endif + void RenderFrameHostImpl::SetCommitCallbackInterceptorForTesting( + CommitCallbackInterceptor* interceptor) { + // This DCHECK's aims to avoid unexpected replacement of an interceptor. +@@ -6360,7 +6365,6 @@ void RenderFrameHostImpl::ShowContextMenu( + GetProcess(), bad_message::RFH_NEGATIVE_SELECTION_START_OFFSET); + return; + } +- + delegate_->ShowContextMenu(*this, std::move(context_menu_client), + validated_params); + } +@@ -6633,13 +6637,8 @@ void RenderFrameHostImpl::GetCreateNewWindow(const GURL& target_url, WindowOpenD + GetCreateNewWindowCallback callback) { + bool effective_transient_activation_state = + allow_popup || frame_tree_node_->HasTransientUserActivation(); +- bool can_create_window = GetContentClient()->browser()->CanCreateWindow( +- this, target_url, disposition, effective_transient_activation_state); +- if (can_create_window) { +- std::move(callback).Run(mojom::CreateNewWindowStatus::kSuccess); +- } else { +- std::move(callback).Run(mojom::CreateNewWindowStatus::kBlocked); +- } ++ GetContentClient()->browser()->CanCreateWindow( ++ this, target_url, disposition, effective_transient_activation_state, std::move(callback)); + } + #endif + +diff --git a/src/content/browser/renderer_host/render_frame_host_impl.h b/src/content/browser/renderer_host/render_frame_host_impl.h +index 909acbecde9..744a40badc8 +--- a/src/content/browser/renderer_host/render_frame_host_impl.h ++++ b/src/content/browser/renderer_host/render_frame_host_impl.h +@@ -2020,6 +2020,10 @@ class CONTENT_EXPORT RenderFrameHostImpl + void DidChangeThemeColor(absl::optional theme_color) override; + void DidChangeBackgroundColor(SkColor background_color, + bool color_adjust) override; ++#if BUILDFLAG(IS_OHOS) ++ void NotifyContextMenuWillShow() override; ++#endif ++ + void DidFailLoadWithError(const GURL& url, int32_t error_code) override; + void DidFocusFrame() override; + void DidCallFocus() override; +diff --git a/src/content/browser/sandbox_ipc_linux.cc b/src/content/browser/sandbox_ipc_linux.cc +index f1d611c148b..a2847d468b0 +--- a/src/content/browser/sandbox_ipc_linux.cc ++++ b/src/content/browser/sandbox_ipc_linux.cc +@@ -141,6 +141,11 @@ void SandboxIPCHandler::HandleMakeSharedMemorySegment( + if (!iter.ReadBool(&executable)) + return; + base::ScopedFD shm_fd; ++#if BUILDFLAG(IS_OHOS) ++ base::subtle::PlatformSharedMemoryRegion region = ++ base::subtle::PlatformSharedMemoryRegion::CreateUnsafe(size); ++ shm_fd = region.PassPlatformHandle(); ++#else + if (executable) { + shm_fd = + base::subtle::PlatformSharedMemoryRegion::ExecutableRegion::CreateFD( +@@ -150,6 +155,7 @@ void SandboxIPCHandler::HandleMakeSharedMemorySegment( + base::subtle::PlatformSharedMemoryRegion::CreateUnsafe(size); + shm_fd = std::move(region.PassPlatformHandle().fd); + } ++#endif + base::Pickle reply; + SendRendererReply(fds, reply, shm_fd.get()); + // shm_fd will close the handle which is no longer needed by this process. +diff --git a/src/content/browser/web_contents/web_contents_impl.cc b/src/content/browser/web_contents/web_contents_impl.cc +index 5a153a55f38..6fc12d2ca74 +--- a/src/content/browser/web_contents/web_contents_impl.cc ++++ b/src/content/browser/web_contents/web_contents_impl.cc +@@ -1790,11 +1790,21 @@ void WebContentsImpl::SetUserAgentOverride( + return; + } + +-#if BUILDFLAG(IS_OHOS) ++#if defined(OHOS_NWEB_EX) + const base::CommandLine& command_line = + *base::CommandLine::ForCurrentProcess(); + if (command_line.HasSwitch(switches::kForBrowser)) { ++ user_agent_ = ua_override.ua_string_override; + UpdateOverridingUserAgent(); ++ ++ // DTS2023022711784 ++ // 子进程打开新窗口时,会先创建delayed_load_url_params_,等到加载url时直接使用 ++ // delayed_load_url_params_的值创建NavigationRequest。其override_user_agent默认值是 ++ // UA_OVERRIDE_FALSE,故这里也要更新。 ++ if (delayed_load_url_params_) { ++ delayed_load_url_params_->override_user_agent = ++ NavigationController::UA_OVERRIDE_TRUE; ++ } + } + #endif + +@@ -2818,6 +2828,17 @@ const blink::web_pref::WebPreferences WebContentsImpl::ComputeWebPreferences() { + #endif // BUILDFLAG(IS_ANDROID) + + GetContentClient()->browser()->OverrideWebkitPrefs(this, &prefs); ++ ++#if defined(OHOS_NWEB_EX) ++ if (command_line.HasSwitch(switches::kForBrowser)) { ++ bool is_win = ++ (user_agent_.find("Windows NT") != std::string::npos) && ++ (user_agent_.find("Win64") != std::string::npos || ++ user_agent_.find("WOW64") != std::string::npos); ++ prefs.viewport_meta_enabled = !is_win; ++ } ++#endif ++ + return prefs; + } + +@@ -2898,7 +2919,7 @@ void WebContentsImpl::OnWebPreferencesChanged() { + return; + updating_web_preferences_ = true; + SetWebPreferences(ComputeWebPreferences()); +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || defined(OHOS_NWEB_EX) + for (FrameTreeNode* node : primary_frame_tree_.Nodes()) { + RenderFrameHostImpl* rfh = node->current_frame_host(); + if (rfh->is_local_root()) { +@@ -3939,6 +3960,14 @@ FrameTree* WebContentsImpl::CreateNewWindow( + new_contents_impl->GetController().SetSessionStorageNamespace( + partition_id, session_storage_namespace); + ++#if BUILDFLAG(IS_OHOS) ++ if (delegate_) { ++ delegate_->WebContentsCreated(this, render_process_id, ++ opener->GetRoutingID(), params.frame_name, ++ params.target_url, new_contents_impl); ++ } ++#endif ++ + // If the new frame has a name, make sure any SiteInstances that can find + // this named frame have proxies for it. Must be called after + // SetSessionStorageNamespace, since this calls CreateRenderView, which uses +@@ -3978,11 +4007,13 @@ FrameTree* WebContentsImpl::CreateNewWindow( + AddWebContentsDestructionObserver(new_contents_impl); + } + ++#if !BUILDFLAG(IS_OHOS) + if (delegate_) { + delegate_->WebContentsCreated(this, render_process_id, + opener->GetRoutingID(), params.frame_name, + params.target_url, new_contents_impl); + } ++#endif + + observers_.NotifyObservers(&WebContentsObserver::DidOpenRequestedURL, + new_contents_impl, opener, params.target_url, +@@ -4787,7 +4818,6 @@ void WebContentsImpl::Replace(const std::u16string& word) { + auto* input_handler = GetFocusedFrameWidgetInputHandler(); + if (!input_handler) + return; +- + input_handler->Replace(word); + } + +@@ -6747,6 +6777,13 @@ void WebContentsImpl::ShowContextMenu( + context_menu_client_.Bind(std::move(context_menu_client)); + } + ++#if defined(OHOS_NWEB_EX) ++ if (base::CommandLine::ForCurrentProcess()->HasSwitch( ++ switches::kForBrowser)) { ++ SetShouldShowFreeCopy(params.is_selectable); ++ } ++#endif ++ + ContextMenuParams context_menu_params(params); + // Allow WebContentsDelegates to handle the context menu operation first. + if (delegate_ && +@@ -7003,6 +7040,12 @@ bool WebContentsImpl::IsShowingContextMenu() { + return showing_context_menu_; + } + ++#if BUILDFLAG(IS_OHOS) ++void WebContentsImpl::NotifyContextMenuWillShow() { ++ SetShowingContextMenu(false); ++} ++#endif ++ + void WebContentsImpl::SetShowingContextMenu(bool showing) { + OPTIONAL_TRACE_EVENT1("content", "WebContentsImpl::SetShowingContextMenu", + "showing", showing); +@@ -9332,6 +9375,33 @@ std::unique_ptr WebContentsImpl::StartPrerendering( + return nullptr; + } + ++#if defined (OHOS_NWEB_EX) ++void WebContentsImpl::SetForceEnableZoom(bool forceEnableZoom) { ++ if (force_enable_zoom_ != forceEnableZoom) { ++ force_enable_zoom_ = forceEnableZoom; ++ OnWebPreferencesChanged(); ++ } ++} ++ ++void WebContentsImpl::SelectAndCopy() { ++ auto* input_handler = GetFocusedFrameWidgetInputHandler(); ++ if (!input_handler) ++ return; ++ input_handler->SelectAndCopy(); ++} ++ ++void WebContentsImpl::SetShouldShowFreeCopy(bool is_selectable) { ++ is_selectable_ = is_selectable; ++} ++ ++void WebContentsImpl::SetEnableBlankTargetPopupIntercept(bool enableBlankTargetPopup) { ++ if (enable_blank_target_popup_intercept_ != enableBlankTargetPopup) { ++ enable_blank_target_popup_intercept_ = enableBlankTargetPopup; ++ OnWebPreferencesChanged(); ++ } ++} ++#endif ++ + // static + std::pair WebContentsImpl::GetAvailablePointerAndHoverTypes() { + // On Windows we have to temporarily allow blocking calls since +diff --git a/src/content/browser/web_contents/web_contents_impl.h b/src/content/browser/web_contents/web_contents_impl.h +index 21e4278efe2..f85aedc3da6 +--- a/src/content/browser/web_contents/web_contents_impl.h ++++ b/src/content/browser/web_contents/web_contents_impl.h +@@ -385,6 +385,24 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents, + bool GetTouchInsertHandleMenuShow() override { + return touch_insert_handle_menu_show_; + } ++ ++#if defined (OHOS_NWEB_EX) ++void SetForceEnableZoom(bool forceEnableZoom) override; ++ ++bool GetForceEnableZoom() override { ++ return force_enable_zoom_; ++} ++void SelectAndCopy() override; ++void SetShouldShowFreeCopy(bool is_selectable); ++ ++bool ShouldShowFreeCopy() override { return is_selectable_; }; ++ ++void SetEnableBlankTargetPopupIntercept(bool enableBlankTargetPopup) override; ++bool GetEnableBlankTargetPopupIntercept() override { ++ return enable_blank_target_popup_intercept_; ++} ++#endif // OHOS_NWEB_EX ++ + #endif + void UpdateTitleForEntry(NavigationEntry* entry, + const std::u16string& title) override; +@@ -602,6 +620,9 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents, + blink::mojom::NavigationBlockedReason reason) override; + void OnDidFinishLoad(RenderFrameHostImpl* render_frame_host, + const GURL& url) override; ++#if BUILDFLAG(IS_OHOS) ++ void NotifyContextMenuWillShow() override; ++#endif + void OnManifestUrlChanged(const PageImpl& page) override; + void RenderFrameCreated(RenderFrameHostImpl* render_frame_host) override; + void RenderFrameDeleted(RenderFrameHostImpl* render_frame_host) override; +@@ -2307,6 +2328,13 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents, + + VisibleTimeRequestTrigger visible_time_request_trigger_; + ++#if defined (OHOS_NWEB_EX) ++ bool force_enable_zoom_; ++ bool is_selectable_; ++ std::string user_agent_{""}; ++ bool enable_blank_target_popup_intercept_ = true; ++#endif // OHOS_NWEB_EX ++ + base::WeakPtrFactory loading_weak_factory_{this}; + base::WeakPtrFactory weak_factory_{this}; + }; +diff --git a/src/content/browser/xr/service/xr_runtime_manager_impl.h b/src/content/browser/xr/service/xr_runtime_manager_impl.h +index ce327d916e1..41ee4f47deb +--- a/src/content/browser/xr/service/xr_runtime_manager_impl.h ++++ b/src/content/browser/xr/service/xr_runtime_manager_impl.h +@@ -43,8 +43,8 @@ class CONTENT_EXPORT XRRuntimeManagerImpl + public device::VRDeviceProviderClient { + public: + friend base::RefCounted; +- static constexpr auto kRefCountPreference = +- base::subtle::kStartRefCountFromOneTag; ++ ++ REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE(); + + friend XRRuntimeManagerTest; + XRRuntimeManagerImpl(const XRRuntimeManagerImpl&) = delete; +diff --git a/src/content/child/assert_matching_enums.cc b/src/content/child/assert_matching_enums.cc +index 54dbe4fa199..effc1cc502f +--- a/src/content/child/assert_matching_enums.cc ++++ b/src/content/child/assert_matching_enums.cc +@@ -74,5 +74,9 @@ STATIC_ASSERT_ENUM(blink::kMenuSourceAdjustSelection, + ui::MENU_SOURCE_ADJUST_SELECTION); + STATIC_ASSERT_ENUM(blink::kMenuSourceAdjustSelectionReset, + ui::MENU_SOURCE_ADJUST_SELECTION_RESET); ++#if defined(OHOS_NWEB_EX) ++STATIC_ASSERT_ENUM(blink::kMenuSourceSelectAndCopy, ++ ui::MENU_SOURCE_SELECT_AND_COPY); ++#endif + + } // namespace content +diff --git a/src/content/child/child_process.cc b/src/content/child/child_process.cc +index 09818074cf7..3dab93dc8bd +--- a/src/content/child/child_process.cc ++++ b/src/content/child/child_process.cc +@@ -101,7 +101,7 @@ ChildProcess::ChildProcess(base::ThreadPriority io_thread_priority, + // We can't recover from failing to start the IO thread. + base::Thread::Options thread_options(base::MessagePumpType::IO, 0); + thread_options.priority = io_thread_priority; +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + // TODO(reveman): Remove this in favor of setting it explicitly for each type + // of process. + if (base::FeatureList::IsEnabled( +diff --git a/src/content/common/content_navigation_policy.cc b/src/content/common/content_navigation_policy.cc +index 65d1963ad5d..598aa0db12a +--- a/src/content/common/content_navigation_policy.cc ++++ b/src/content/common/content_navigation_policy.cc +@@ -159,7 +159,8 @@ const char kRenderDocumentLevelParameterName[] = "level"; + constexpr base::FeatureParam::Option + render_document_levels[] = { + {RenderDocumentLevel::kCrashedFrame, "crashed-frame"}, +- {RenderDocumentLevel::kSubframe, "subframe"}}; ++ {RenderDocumentLevel::kSubframe, "subframe"}, ++ {RenderDocumentLevel::kAllFrames, "all-frames"}}; + const base::FeatureParam render_document_level{ + &features::kRenderDocument, kRenderDocumentLevelParameterName, + RenderDocumentLevel::kCrashedFrame, &render_document_levels}; +@@ -178,6 +179,10 @@ bool ShouldCreateNewHostForSameSiteSubframe() { + return GetRenderDocumentLevel() >= RenderDocumentLevel::kSubframe; + } + ++bool ShouldCreateNewHostForAllFrames() { ++ return GetRenderDocumentLevel() >= RenderDocumentLevel::kAllFrames; ++} ++ + bool ShouldSkipEarlyCommitPendingForCrashedFrame() { + static bool skip_early_commit_pending_for_crashed_frame = + base::FeatureList::IsEnabled( +diff --git a/src/content/common/content_navigation_policy.h b/src/content/common/content_navigation_policy.h +index 72c09e51926..c1dc5a42729 +--- a/src/content/common/content_navigation_policy.h ++++ b/src/content/common/content_navigation_policy.h +@@ -75,8 +75,11 @@ enum class RenderDocumentLevel { + kCrashedFrame = 1, + // Also do not reuse RenderFrameHosts when navigating subframes. + kSubframe = 2, ++ // Do not reuse RenderFrameHosts when navigating any frame. ++ kAllFrames = 3, + }; + CONTENT_EXPORT bool ShouldCreateNewHostForSameSiteSubframe(); ++CONTENT_EXPORT bool ShouldCreateNewHostForAllFrames(); + CONTENT_EXPORT RenderDocumentLevel GetRenderDocumentLevel(); + CONTENT_EXPORT std::string GetRenderDocumentLevelName( + RenderDocumentLevel level); +diff --git a/src/content/public/browser/content_browser_client.cc b/src/content/public/browser/content_browser_client.cc +index 03b60ce3b17..0f2ae0ade73 +--- a/src/content/public/browser/content_browser_client.cc ++++ b/src/content/public/browser/content_browser_client.cc +@@ -135,7 +135,7 @@ bool ContentBrowserClient::IsExplicitNavigation(ui::PageTransition transition) { + } + + bool ContentBrowserClient::ShouldUseMobileFlingCurve() { +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + return true; + #else + return false; +@@ -580,6 +580,18 @@ bool ContentBrowserClient::CanCreateWindow( + return true; + } + ++#if BUILDFLAG(IS_OHOS) ++bool ContentBrowserClient::CanCreateWindow( ++ RenderFrameHost* opener, ++ const GURL& target_url, ++ WindowOpenDisposition disposition, ++ bool user_gesture, ++ content::mojom::FrameHost::GetCreateNewWindowCallback callback) { ++ std::move(callback).Run(mojom::CreateNewWindowStatus::kBlocked); ++ return false; ++} ++#endif ++ + SpeechRecognitionManagerDelegate* + ContentBrowserClient::CreateSpeechRecognitionManagerDelegate() { + return nullptr; +diff --git a/src/content/public/browser/content_browser_client.h b/src/content/public/browser/content_browser_client.h +index 936c1b875db..1f42e5e2d95 +--- a/src/content/public/browser/content_browser_client.h ++++ b/src/content/public/browser/content_browser_client.h +@@ -77,6 +77,10 @@ + #include "content/public/browser/posix_file_descriptor_info.h" + #endif + ++#if BUILDFLAG(IS_OHOS) ++#include "content/common/frame.mojom.h" ++#endif ++ + namespace net { + class SiteForCookies; + class IsolationInfo; +@@ -953,9 +957,8 @@ class CONTENT_EXPORT ContentBrowserClient { + RenderFrameHost* opener, + const GURL& target_url, + WindowOpenDisposition disposition, +- bool user_gesture) { +- return false; +- } ++ bool user_gesture, ++ content::mojom::FrameHost::GetCreateNewWindowCallback callback); + #endif + // Allows the embedder to return a delegate for the SpeechRecognitionManager. + // The delegate will be owned by the manager. It's valid to return nullptr. +diff --git a/src/content/public/browser/web_contents.h b/src/content/public/browser/web_contents.h +index 2ac5c5b0f7a..e6f7e496c91 +--- a/src/content/public/browser/web_contents.h ++++ b/src/content/public/browser/web_contents.h +@@ -598,6 +598,14 @@ class WebContents : public PageNavigator, + #if BUILDFLAG(IS_OHOS) + virtual void SetTouchInsertHandleMenuShow(bool show) = 0; + virtual bool GetTouchInsertHandleMenuShow() = 0; ++#if defined (OHOS_NWEB_EX) ++ virtual void SetForceEnableZoom(bool forceEnableZoom) = 0; ++ virtual bool GetForceEnableZoom() = 0; ++ virtual void SelectAndCopy() = 0; ++ virtual bool ShouldShowFreeCopy() = 0; ++ virtual void SetEnableBlankTargetPopupIntercept(bool enableBlankTargetPopup) = 0; ++ virtual bool GetEnableBlankTargetPopupIntercept() = 0; ++#endif // OHOS_NWEB_EX + #endif + + // Saves the given title to the navigation entry and does associated work. It +diff --git a/src/content/public/common/content_features.cc b/src/content/public/common/content_features.cc +index 45e215cd089..bd2cc47ce22 +--- a/src/content/public/common/content_features.cc ++++ b/src/content/public/common/content_features.cc +@@ -163,7 +163,7 @@ const base::Feature kBlockInsecurePrivateNetworkRequestsForNavigations{ + const base::Feature kBrowserUseDisplayThreadPriority { + "BrowserUseDisplayThreadPriority", + +-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_CHROMEOS_ASH) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_OHOS) + base::FEATURE_ENABLED_BY_DEFAULT + #else + base::FEATURE_DISABLED_BY_DEFAULT +@@ -178,6 +178,13 @@ const base::Feature kBrowserVerifiedUserActivationKeyboard{ + const base::Feature kBrowserVerifiedUserActivationMouse{ + "BrowserVerifiedUserActivationMouse", base::FEATURE_DISABLED_BY_DEFAULT}; + ++// Compute the NavigationDownloadPolicy bit about sandbox flags from the browser ++// process side. This is a fix for https://crbug.com/1357366. The feature flag ++// is used as a temporary kill switch in case it breaks something important on ++// stable. To be removed by M111. ++const base::Feature kBrowserSideDownloadPolicySandbox( ++ "BrowserSideDownloadPolicySandbox", base::FEATURE_ENABLED_BY_DEFAULT); ++ + // Enables code caching for inline scripts. + const base::Feature kCacheInlineScriptCode{"CacheInlineScriptCode", + base::FEATURE_ENABLED_BY_DEFAULT}; +diff --git a/src/content/public/common/content_features.h b/src/content/public/common/content_features.h +index 5116fd54817..00a5df008ea +--- a/src/content/public/common/content_features.h ++++ b/src/content/public/common/content_features.h +@@ -47,6 +47,7 @@ CONTENT_EXPORT extern const base::Feature kBrowserUseDisplayThreadPriority; + CONTENT_EXPORT extern const base::Feature + kBrowserVerifiedUserActivationKeyboard; + CONTENT_EXPORT extern const base::Feature kBrowserVerifiedUserActivationMouse; ++CONTENT_EXPORT extern const base::Feature kBrowserSideDownloadPolicySandbox; + CONTENT_EXPORT extern const base::Feature kCacheInlineScriptCode; + CONTENT_EXPORT extern const base::Feature kCanvas2DImageChromium; + CONTENT_EXPORT extern const base::Feature kCapabilityDelegationPaymentRequest; +diff --git a/src/content/public/common/content_switches.cc b/src/content/public/common/content_switches.cc +index 4ff10e78b59..f78dfb529cd +--- a/src/content/public/common/content_switches.cc ++++ b/src/content/public/common/content_switches.cc +@@ -682,6 +682,10 @@ const char kRemoteDebuggingPipe[] = "remote-debugging-pipe"; + // Enables remote debug over HTTP on the specified port. + const char kRemoteDebuggingPort[] = "remote-debugging-port"; + ++// Enables web socket connections from the specified origins only. '*' allows ++// any origin. ++const char kRemoteAllowOrigins[] = "remote-allow-origins"; ++ + const char kRendererClientId[] = "renderer-client-id"; + + // The contents of this flag are prepended to the renderer command line. +@@ -1000,10 +1004,12 @@ const char kEnableSpeechDispatcher[] = "enable-speech-dispatcher"; + + #if BUILDFLAG(IS_OHOS) + const char kOhosHapPath[] = "user-hap-path"; ++const char kOhosAppApiVersion[] = "user-api-version"; + const char kEnableMultiRendererProcess[] = "enable-multi-renderer-process"; + const char kForBrowser[] = "for-browser"; + const char kOhosCustomScheme[] = "ohos-custom-scheme"; + const char kOhosHanceSurface[] = "ohos-enhance-surface"; ++const char kOhosEnableDrDc[] = "ohos-enable-drdc"; + #endif + + #if BUILDFLAG(IS_WIN) +diff --git a/src/content/public/common/content_switches.h b/src/content/public/common/content_switches.h +index 786c839ecbf..85bcfa6460a +--- a/src/content/public/common/content_switches.h ++++ b/src/content/public/common/content_switches.h +@@ -189,6 +189,7 @@ CONTENT_EXPORT extern const char kQuotaChangeEventInterval[]; + CONTENT_EXPORT extern const char kRegisterPepperPlugins[]; + CONTENT_EXPORT extern const char kRemoteDebuggingPipe[]; + CONTENT_EXPORT extern const char kRemoteDebuggingPort[]; ++CONTENT_EXPORT extern const char kRemoteAllowOrigins[]; + CONTENT_EXPORT extern const char kRendererClientId[]; + extern const char kRendererCmdPrefix[]; + CONTENT_EXPORT extern const char kRendererProcess[]; +@@ -278,10 +279,12 @@ CONTENT_EXPORT extern const char kEnableSpeechDispatcher[]; + + #if BUILDFLAG(IS_OHOS) + CONTENT_EXPORT extern const char kOhosHapPath[]; ++CONTENT_EXPORT extern const char kOhosAppApiVersion[]; + CONTENT_EXPORT extern const char kEnableMultiRendererProcess[]; + CONTENT_EXPORT extern const char kForBrowser[]; + CONTENT_EXPORT extern const char kOhosCustomScheme[]; + CONTENT_EXPORT extern const char kOhosHanceSurface[]; ++CONTENT_EXPORT extern const char kOhosEnableDrDc[]; + #endif + + #if BUILDFLAG(IS_WIN) +diff --git a/src/content/public/renderer/render_frame.h b/src/content/public/renderer/render_frame.h +index faef76763f4..6a3e1d0c79f +--- a/src/content/public/renderer/render_frame.h ++++ b/src/content/public/renderer/render_frame.h +@@ -135,7 +135,9 @@ class CONTENT_EXPORT RenderFrame : public IPC::Listener, + // this process or a WebRemoteFrame placeholder for a frame in a different + // process. + static int GetRoutingIdForWebFrame(blink::WebFrame* web_frame); +- ++#if BUILDFLAG(IS_OHOS) ++ virtual void SetZoomLevel(float magnify_delta, const gfx::Point& anchor) {}; ++#endif // BUILDFLAG(IS_OHOS) + // Returns the RenderView associated with this frame. + virtual RenderView* GetRenderView() = 0; + +diff --git a/src/content/renderer/media/ohos/ohos_media_player_renderer_client.cc b/src/content/renderer/media/ohos/ohos_media_player_renderer_client.cc +index 06e1abfd414..67a045a8ea9 +--- a/src/content/renderer/media/ohos/ohos_media_player_renderer_client.cc ++++ b/src/content/renderer/media/ohos/ohos_media_player_renderer_client.cc +@@ -8,9 +8,9 @@ + #include + #include + +-#include + #include + #include "base/logging.h" ++#include "graphic_adapter.h" + #include "media/base/video_frame.h" + + namespace content { +@@ -144,7 +144,7 @@ void OHOSMediaPlayerRendererClient::OnFrameUpdate( + gfx::Rect visible_rect = gfx::Rect(0, 0, visible_width, visible_height); + gfx::Size natural_size = gfx::Size(visible_width, visible_height); + const base::TimeDelta kZero; +- if (src_format == PIXEL_FMT_YCBCR_420_SP) { ++ if (src_format == OHOS::NWeb::PixelFormatAdapter::PIXEL_FMT_YCBCR_420_SP) { + PaintNV12VideoFrame(coded_size, visible_rect, natural_size, mapped, + buffer_size, fd, fd_browser); + } else { +diff --git a/src/content/renderer/media/renderer_webmediaplayer_delegate.cc b/src/content/renderer/media/renderer_webmediaplayer_delegate.cc +index afa65f45cd3..c354d3ceca3 +--- a/src/content/renderer/media/renderer_webmediaplayer_delegate.cc ++++ b/src/content/renderer/media/renderer_webmediaplayer_delegate.cc +@@ -37,7 +37,11 @@ RendererWebMediaPlayerDelegate::RendererWebMediaPlayerDelegate( + content::GetContentClient()->renderer()->IsIdleMediaSuspendEnabled()), + tick_clock_(base::DefaultTickClock::GetInstance()) { + idle_cleanup_interval_ = base::Seconds(5); ++#if BUILDFLAG(IS_OHOS) ++ idle_timeout_ = base::Seconds(100000); ++#else + idle_timeout_ = base::Seconds(15); ++#endif + + is_low_end_ = base::SysInfo::IsLowEndDevice(); + idle_cleanup_timer_.SetTaskRunner( +diff --git a/src/content/renderer/render_frame_impl.cc b/src/content/renderer/render_frame_impl.cc +index de0071cde8c..342e9c7c31c +--- a/src/content/renderer/render_frame_impl.cc ++++ b/src/content/renderer/render_frame_impl.cc +@@ -2352,6 +2352,16 @@ void RenderFrameImpl::DidCommitAndDrawCompositorFrame() { + #endif + } + ++#if BUILDFLAG(IS_OHOS) ++void RenderFrameImpl::SetZoomLevel(float magnify_delta, const gfx::Point& anchor) { ++ auto web_frame_widget = GetLocalRootWebFrameWidget(); ++ if (!web_frame_widget) { ++ return; ++ } ++ web_frame_widget->SetZoomLevel(magnify_delta, anchor); ++} ++#endif // BUILDFLAG(IS_OHOS) ++ + RenderView* RenderFrameImpl::GetRenderView() { + return render_view_; + } +diff --git a/src/content/renderer/render_frame_impl.h b/src/content/renderer/render_frame_impl.h +index 6ccc7f89f9b..2f94debdd47 +--- a/src/content/renderer/render_frame_impl.h ++++ b/src/content/renderer/render_frame_impl.h +@@ -338,6 +338,9 @@ class CONTENT_EXPORT RenderFrameImpl + mojo::ScopedInterfaceEndpointHandle handle) override; + + // RenderFrame implementation: ++#if BUILDFLAG(IS_OHOS) ++ void SetZoomLevel(float magnify_delta, const gfx::Point& anchor) override; ++#endif // BUILDFLAG(IS_OHOS) + RenderView* GetRenderView() override; + RenderFrame* GetMainRenderFrame() override; + RenderAccessibility* GetRenderAccessibility() override; +diff --git a/src/content/renderer/render_remote_proxy.cc b/src/content/renderer/render_remote_proxy.cc +index f4b7435282c..188f7fbcaad +--- a/src/content/renderer/render_remote_proxy.cc ++++ b/src/content/renderer/render_remote_proxy.cc +@@ -22,7 +22,13 @@ std::condition_variable RenderRemoteProxy::browser_fd_cv_; + bool RenderRemoteProxy::is_browser_fd_received_{false}; + bool RenderRemoteProxy::is_for_test_{false}; + +-void RenderRemoteProxy::NotifyBrowserFd(int32_t ipcFd, int32_t sharedFd) { ++void RenderRemoteProxy::NotifyBrowserFd(int32_t ipcFd, ++ int32_t sharedFd ++#if BUILDFLAG(IS_OHOS) ++ , ++ int32_t crashFd ++#endif // BUILDFLAG(IS_OHOS) ++) { + base::GlobalDescriptors* g_fds = base::GlobalDescriptors::GetInstance(); + if (g_fds != nullptr) { + int new_ipc_fd; +@@ -46,6 +52,19 @@ void RenderRemoteProxy::NotifyBrowserFd(int32_t ipcFd, int32_t sharedFd) { + shared_fd_ = new_shared_fd; + close(sharedFd); + } ++ ++#if BUILDFLAG(IS_OHOS) ++ int new_crash_id; ++ if ((new_crash_id = dup(crashFd)) < 0) { ++ LOG(ERROR) << "crashFd duplicate error"; ++ g_fds->Set(kCrashDumpSignal, crashFd); ++ crash_id_ = crashFd; ++ } else { ++ g_fds->Set(kCrashDumpSignal, new_crash_id); ++ crash_id_ = new_crash_id; ++ close(crashFd); ++ } ++#endif // BUILDFLAG(IS_OHOS) + } + RenderRemoteProxy::is_browser_fd_received_ = true; + RenderRemoteProxy::browser_fd_cv_.notify_one(); +diff --git a/src/content/renderer/render_remote_proxy.h b/src/content/renderer/render_remote_proxy.h +index c6e3b98b25a..58e897937a0 +--- a/src/content/renderer/render_remote_proxy.h ++++ b/src/content/renderer/render_remote_proxy.h +@@ -9,6 +9,10 @@ + #include + #include "aafwk_render_scheduler_host_adapter.h" + ++// #if BUILDFLAG(IS_OHOS) ++#include "build/build_config.h" ++// #endif // BUILDFLAG(IS_OHOS) ++ + namespace base { + class CommandLine; + } +@@ -19,7 +23,13 @@ class RenderRemoteProxy : public OHOS::NWeb::AafwkRenderSchedulerHostAdapter { + RenderRemoteProxy() = default; + ~RenderRemoteProxy() = default; + +- virtual void NotifyBrowserFd(int32_t ipcFd, int32_t sharedFd) override; ++ virtual void NotifyBrowserFd(int32_t ipcFd, ++ int32_t sharedFd ++#if BUILDFLAG(IS_OHOS) ++ , ++ int32_t crashFd ++#endif // BUILDFLAG(IS_OHOS) ++ ) override; + + static void CreateAndRegist(const base::CommandLine& command_line); + static bool WaitForBrowserFd(); +@@ -27,6 +37,9 @@ class RenderRemoteProxy : public OHOS::NWeb::AafwkRenderSchedulerHostAdapter { + private: + int32_t ipc_fd_ = 0; + int32_t shared_fd_ = 0; ++#if BUILDFLAG(IS_OHOS) ++ int32_t crash_id_ = 0; ++#endif // BUILDFLAG(IS_OHOS) + + static std::mutex browser_fd_mtx_; + static std::condition_variable browser_fd_cv_; +diff --git a/src/content/renderer/render_thread_impl.cc b/src/content/renderer/render_thread_impl.cc +index 380b80337da..c39c126d781 +--- a/src/content/renderer/render_thread_impl.cc ++++ b/src/content/renderer/render_thread_impl.cc +@@ -689,7 +689,7 @@ void RenderThreadImpl::Init() { + } else if (command_line.HasSwitch(switches::kEnableLCDText)) { + is_lcd_text_enabled_ = true; + } else { +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + is_lcd_text_enabled_ = false; + #elif BUILDFLAG(IS_MAC) + is_lcd_text_enabled_ = IsSubpixelAntialiasingAvailable(); +diff --git a/src/content/renderer/render_view_impl.cc b/src/content/renderer/render_view_impl.cc +index 43d696a27fd..8812f0a6a70 +--- a/src/content/renderer/render_view_impl.cc ++++ b/src/content/renderer/render_view_impl.cc +@@ -282,10 +282,7 @@ WebView* RenderViewImpl::CreateView( + if (GetContentClient()->renderer()->AllowPopup()) + params->allow_popup = true; + #if BUILDFLAG(IS_OHOS) +- if (GetNewWindowWebView(creator_frame, request.Url(), policy, params->allow_popup)) { +- LOG(INFO) << "wait user create window."; +- usleep(100000); +- } ++ GetNewWindowWebView(creator_frame, request.Url(), policy, params->allow_popup); + #endif + + params->window_container_type = WindowFeaturesToContainerType(features); +diff --git a/src/content/shell/browser/shell_content_browser_client.cc b/src/content/shell/browser/shell_content_browser_client.cc +index 1bf23d38bae..932bc7aa38b +--- a/src/content/shell/browser/shell_content_browser_client.cc ++++ b/src/content/shell/browser/shell_content_browser_client.cc +@@ -110,7 +110,7 @@ bool g_enable_expect_ct_for_testing = false; + int GetCrashSignalFD(const base::CommandLine& command_line) { + return crashpad::CrashHandlerHost::Get()->GetDeathSignalSocket(); + } +-#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ++#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_OHOS) + int GetCrashSignalFD(const base::CommandLine& command_line) { + int fd; + pid_t pid; +@@ -502,7 +502,8 @@ void ShellContentBrowserClient::OverrideURLLoaderFactoryParams( + } + } + +-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || \ ++ BUILDFLAG(IS_OHOS) + void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( + const base::CommandLine& command_line, + int child_process_id, +diff --git a/src/extensions/browser/guest_view/app_view/app_view_guest.cc b/src/extensions/browser/guest_view/app_view/app_view_guest.cc +index e2f258b0364..e19868132bb +--- a/src/extensions/browser/guest_view/app_view/app_view_guest.cc ++++ b/src/extensions/browser/guest_view/app_view/app_view_guest.cc +@@ -241,6 +241,12 @@ void AppViewGuest::CompleteCreateWebContents( + const GURL& url, + const Extension* guest_extension, + WebContentsCreatedCallback callback) { ++ if (!owner_web_contents()) { ++ // The owner was destroyed before getting a response to the embedding ++ // request, so we can't proceed with creating a guest. ++ std::move(callback).Run(nullptr); ++ return; ++ } + if (!url.is_valid()) { + std::move(callback).Run(nullptr); + return; +diff --git a/src/gin/v8_initializer.cc b/src/gin/v8_initializer.cc +index 39acc81ec18..91d5a1b78af +--- a/src/gin/v8_initializer.cc ++++ b/src/gin/v8_initializer.cc +@@ -514,16 +514,18 @@ void V8Initializer::LoadV8Snapshot(V8SnapshotFileType snapshot_file_type) { + const char kSnapshotFileNameHap[] = "resources/rawfile/snapshot_blob.bin"; + // static + int V8Initializer::LoadV8SnapshotFromFileByHap(V8SnapshotFileType snapshot_file_type) { +- size_t length = 0; +- std::unique_ptr data; + auto resourceInstance = OHOS::NWeb::OhosAdapterHelper::GetInstance().GetResourceAdapter(); +- if (!resourceInstance->GetRawFileData(kSnapshotFileNameHap, length, data, true)) { ++ ++ std::unique_ptr fileMapper = nullptr; ++ if (!resourceInstance->GetRawFileMapper(kSnapshotFileNameHap, fileMapper, true)) { + LOG(FATAL) << "couldn't mmap snapshot_blob data file " << kSnapshotFileNameHap; + return 1; + } +- LOG(INFO) << "snapshot_blob data file length: " << length; ++ LOG(INFO) << "snapshot_blob data file length: " << fileMapper->GetDataLen(); ++ + std::unique_ptr mmapped_file = std::make_unique(); +- mmapped_file->SetDataAndLength(data, length); ++ mmapped_file->SetOhosFileMapper(fileMapper); ++ + g_mapped_snapshot = mmapped_file.release(); + g_snapshot_file_type = snapshot_file_type; + return 0; +diff --git a/src/gpu/command_buffer/client/implementation_base.cc b/src/gpu/command_buffer/client/implementation_base.cc +index 0492f62a9f7..fc7d4c21447 +--- a/src/gpu/command_buffer/client/implementation_base.cc ++++ b/src/gpu/command_buffer/client/implementation_base.cc +@@ -256,9 +256,9 @@ gpu::ContextResult ImplementationBase::Initialize( + return gpu::ContextResult::kSuccess; + } + +-void ImplementationBase::WaitForCmd() { ++bool ImplementationBase::WaitForCmd() { + TRACE_EVENT0("gpu", "ImplementationBase::WaitForCmd"); +- helper_->Finish(); ++ return helper_->Finish(); + } + + int32_t ImplementationBase::GetResultShmId() { +@@ -301,7 +301,10 @@ bool ImplementationBase::GetBucketContents(uint32_t bucket_id, + } + helper_->GetBucketData(bucket_id, offset, buffer.size(), + buffer.shm_id(), buffer.offset()); +- WaitForCmd(); ++ if (!WaitForCmd()) { ++ data->clear(); ++ return false; ++ } + } + uint32_t size_to_copy = std::min(size, buffer.size()); + memcpy(&(*data)[offset], buffer.address(), size_to_copy); +diff --git a/src/gpu/command_buffer/client/implementation_base.h b/src/gpu/command_buffer/client/implementation_base.h +index 9e1ec175552..25b19800fbd +--- a/src/gpu/command_buffer/client/implementation_base.h ++++ b/src/gpu/command_buffer/client/implementation_base.h +@@ -107,7 +107,7 @@ class GLES2_IMPL_EXPORT ImplementationBase + gpu::ContextResult Initialize(const SharedMemoryLimits& limits); + + // Waits for all commands to execute. +- void WaitForCmd(); ++ bool WaitForCmd(); + + // Gets the value of the result. + template +diff --git a/src/gpu/command_buffer/service/BUILD.gn b/src/gpu/command_buffer/service/BUILD.gn +index f47bc5bdcf4..9d86bb5b55f +--- a/src/gpu/command_buffer/service/BUILD.gn ++++ b/src/gpu/command_buffer/service/BUILD.gn +@@ -278,6 +278,17 @@ target(link_target_type, "gles2_sources") { + "wrapped_sk_image.h", + ] + ++ if (is_ohos) { ++ sources += [ ++ "shared_image_backing_factory_egl.h", ++ "shared_image_backing_factory_egl.cc", ++ "shared_image_backing_egl_image.cc", ++ "shared_image_backing_egl_image.h", ++ "shared_image_batch_access_manager.cc", ++ "shared_image_batch_access_manager.h", ++ ] ++ } ++ + if (use_dawn) { + sources += [ + "dawn_platform.cc", +@@ -448,7 +459,6 @@ target(link_target_type, "gles2_sources") { + "//third_party/dawn/src/dawn:dawncpp", + ] + } +- + if (is_android) { + if (!is_debug) { + # On Android optimize more since this component can be a bottleneck. +diff --git a/src/gpu/command_buffer/service/dxgi_shared_handle_manager.cc b/src/gpu/command_buffer/service/dxgi_shared_handle_manager.cc +index 55c421bef92..23e5058995f +--- a/src/gpu/command_buffer/service/dxgi_shared_handle_manager.cc ++++ b/src/gpu/command_buffer/service/dxgi_shared_handle_manager.cc +@@ -49,7 +49,8 @@ DXGISharedHandleState::DXGISharedHandleState( + gfx::DXGIHandleToken token, + base::win::ScopedHandle shared_handle, + Microsoft::WRL::ComPtr d3d11_texture) +- : base::subtle::RefCountedThreadSafeBase(kRefCountPreference), ++ : base::subtle::RefCountedThreadSafeBase( ++ base::subtle::GetRefCountPreference()), + manager_(std::move(manager)), + token_(std::move(token)), + shared_handle_(std::move(shared_handle)), +diff --git a/src/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc b/src/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc +index dc42984d822..7f313b5d443 +--- a/src/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc ++++ b/src/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc +@@ -2651,6 +2651,10 @@ error::Error GLES2DecoderPassthroughImpl::DoShaderBinary(GLsizei n, + GLenum binaryformat, + const void* binary, + GLsizei length) { ++#if 1 // No binary shader support. ++ InsertError(GL_INVALID_ENUM, "Invalid enum."); ++ return error::kNoError; ++#else + std::vector service_shaders(n, 0); + for (GLsizei i = 0; i < n; i++) { + service_shaders[i] = GetShaderServiceID(shaders[i], resources_); +@@ -2658,6 +2662,7 @@ error::Error GLES2DecoderPassthroughImpl::DoShaderBinary(GLsizei n, + api()->glShaderBinaryFn(n, service_shaders.data(), binaryformat, binary, + length); + return error::kNoError; ++#endif + } + + error::Error GLES2DecoderPassthroughImpl::DoShaderSource(GLuint shader, +diff --git a/src/gpu/command_buffer/service/raster_decoder.cc b/src/gpu/command_buffer/service/raster_decoder.cc +index d6593a76ac8..facc813458d +--- a/src/gpu/command_buffer/service/raster_decoder.cc ++++ b/src/gpu/command_buffer/service/raster_decoder.cc +@@ -2975,6 +2975,7 @@ void RasterDecoderImpl::DoReadbackARGBImagePixelsINTERNAL( + namespace { + struct YUVReadbackResult { + std::unique_ptr async_result; ++ bool finished = false; + }; + + void OnReadYUVImagePixelsDone( +@@ -2982,6 +2983,7 @@ void OnReadYUVImagePixelsDone( + std::unique_ptr async_result) { + YUVReadbackResult* context = reinterpret_cast(raw_ctx); + context->async_result = std::move(async_result); ++ context->finished = true; + } + } // namespace + +@@ -3155,6 +3157,10 @@ void RasterDecoderImpl::DoReadbackYUVImagePixelsINTERNAL( + // asynchronous by removing this flush and implementing a query that can + // signal back to client process. + gr_context()->flushAndSubmit(true); ++ ++ // The call above will sync up gpu and CPU, resulting in callback being run ++ // during flushAndSubmit. To prevent UAF make sure it indeed happened. ++ CHECK(yuv_result.finished); + if (!yuv_result.async_result) { + LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glReadbackYUVImagePixels", + "Failed to read pixels from SkImage"); +diff --git a/src/gpu/command_buffer/service/shared_image_factory.cc b/src/gpu/command_buffer/service/shared_image_factory.cc +index bd8e525afe7..ca071b07e19 +--- a/src/gpu/command_buffer/service/shared_image_factory.cc ++++ b/src/gpu/command_buffer/service/shared_image_factory.cc +@@ -73,6 +73,11 @@ + #include "gpu/command_buffer/service/shared_image_backing_scoped_hardware_buffer_fence_sync.h" + #endif + ++#if BUILDFLAG(IS_OHOS) ++#include "gpu/command_buffer/service/shared_image_backing_factory_egl.h" ++#include "gpu/command_buffer/service/shared_image_backing_scoped_hardware_buffer_fence_sync.h" ++#endif ++ + namespace gpu { + + #if BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CHROMEOS_ASH) && \ +@@ -161,7 +166,7 @@ SharedImageFactory::SharedImageFactory( + : nullptr); + factories_.push_back(std::move(gl_texture_backing_factory)); + +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + auto egl_backing_factory = std::make_unique( + gpu_preferences, workarounds, gpu_feature_info, + shared_image_manager->batch_access_manager()); +diff --git a/src/gpu/command_buffer/service/shared_image_manager.cc b/src/gpu/command_buffer/service/shared_image_manager.cc +index 3ffe6669a99..722b91f7248 +--- a/src/gpu/command_buffer/service/shared_image_manager.cc ++++ b/src/gpu/command_buffer/service/shared_image_manager.cc +@@ -21,7 +21,7 @@ + #include "gpu/command_buffer/service/shared_image_representation.h" + #include "ui/gl/trace_util.h" + +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + #include "gpu/command_buffer/service/shared_image_batch_access_manager.h" + #endif + +@@ -88,7 +88,7 @@ SharedImageManager::SharedImageManager(bool thread_safe, + DCHECK(!display_context_on_another_thread || thread_safe); + if (thread_safe) + lock_.emplace(); +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + batch_access_manager_ = std::make_unique(); + #endif + #if BUILDFLAG(IS_WIN) +@@ -433,7 +433,7 @@ scoped_refptr SharedImageManager::GetNativePixmap( + } + + bool SharedImageManager::BeginBatchReadAccess() { +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + return batch_access_manager_->BeginBatchReadAccess(); + #else + return true; +@@ -441,7 +441,7 @@ bool SharedImageManager::BeginBatchReadAccess() { + } + + bool SharedImageManager::EndBatchReadAccess() { +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + return batch_access_manager_->EndBatchReadAccess(); + #else + return true; +diff --git a/src/gpu/command_buffer/service/shared_image_manager.h b/src/gpu/command_buffer/service/shared_image_manager.h +index 2feaab4765d..02764123591 +--- a/src/gpu/command_buffer/service/shared_image_manager.h ++++ b/src/gpu/command_buffer/service/shared_image_manager.h +@@ -112,7 +112,7 @@ class GPU_GLES2_EXPORT SharedImageManager { + scoped_refptr GetNativePixmap(const gpu::Mailbox& mailbox); + + SharedImageBatchAccessManager* batch_access_manager() const { +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + return batch_access_manager_.get(); + #else + return nullptr; +@@ -138,7 +138,7 @@ class GPU_GLES2_EXPORT SharedImageManager { + + const bool display_context_on_another_thread_; + +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + std::unique_ptr batch_access_manager_; + #endif + +diff --git a/src/gpu/config/gpu_finch_features.cc b/src/gpu/config/gpu_finch_features.cc +index 23fc5ffbf06..bf6cf71fd50 +--- a/src/gpu/config/gpu_finch_features.cc ++++ b/src/gpu/config/gpu_finch_features.cc +@@ -22,6 +22,10 @@ + #include "ui/gfx/android/android_surface_control_compat.h" + #endif + ++#if BUILDFLAG(IS_OHOS) ++#include "content/public/common/content_switches.h" ++#endif ++ + namespace features { + namespace { + +@@ -155,7 +159,7 @@ const base::Feature kGpuProcessHighPriorityWin{ + // Use ThreadPriority::DISPLAY for GPU main, viz compositor and IO threads. + const base::Feature kGpuUseDisplayThreadPriority{ + "GpuUseDisplayThreadPriority", +-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_WIN) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_OHOS) + base::FEATURE_ENABLED_BY_DEFAULT + #else + base::FEATURE_DISABLED_BY_DEFAULT +@@ -338,6 +342,11 @@ bool IsDrDcEnabled() { + return false; + + return base::FeatureList::IsEnabled(kEnableDrDc); ++#elif BUILDFLAG(IS_OHOS) ++ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); ++ if (command_line) ++ return command_line->HasSwitch(::switches::kOhosEnableDrDc); ++ return false; + #else + return false; + #endif +diff --git a/src/gpu/ipc/common/gpu_watchdog_timeout.h b/src/gpu/ipc/common/gpu_watchdog_timeout.h +index 8e8a5459a94..408bbbe49fe +--- a/src/gpu/ipc/common/gpu_watchdog_timeout.h ++++ b/src/gpu/ipc/common/gpu_watchdog_timeout.h +@@ -43,6 +43,9 @@ constexpr int kInitFactor = 2; + constexpr int kInitFactor = 1; + #endif + ++// Software rasterizer runs slower than hardware accelerated. ++constexpr int kSoftwareRenderingFactor = 2; ++ + } // namespace gpu + + #endif // GPU_IPC_COMMON_GPU_WATCHDOG_TIMEOUT_H_ +diff --git a/src/gpu/ipc/service/gpu_init.cc b/src/gpu/ipc/service/gpu_init.cc +index 479b564caad..a254c305c54 +--- a/src/gpu/ipc/service/gpu_init.cc ++++ b/src/gpu/ipc/service/gpu_init.cc +@@ -262,9 +262,27 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line, + gl_use_swiftshader_ = true; + } + ++ if (!gl_use_swiftshader_) { ++ gl_use_swiftshader_ = EnableSwiftShaderIfNeeded( ++ command_line, gpu_feature_info_, ++ gpu_preferences_.disable_software_rasterizer, needs_more_info); ++ } ++ ++ if (gl_initialized && gl_use_swiftshader_ && ++ !gl::IsSoftwareGLImplementation(gl::GetGLImplementationParts())) { ++#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ++ VLOG(1) << "Quit GPU process launch to fallback to SwiftShader cleanly " ++ << "on Linux"; ++ return false; ++#else // !(BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) ++ SaveHardwareGpuInfoAndGpuFeatureInfo(); ++ gl::init::ShutdownGL(true); ++ gl_initialized = false; ++#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ++ } ++ + bool enable_watchdog = !gpu_preferences_.disable_gpu_watchdog && +- !command_line->HasSwitch(switches::kHeadless) && +- !gl_use_swiftshader_; ++ !command_line->HasSwitch(switches::kHeadless); + + // Disable the watchdog in debug builds because they tend to only be run by + // developers who will not appreciate the watchdog killing the GPU process. +@@ -305,7 +323,10 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line, + // consuming has completed, otherwise the process is liable to be aborted. + if (enable_watchdog && !delayed_watchdog_enable) { + watchdog_thread_ = GpuWatchdogThread::Create( +- gpu_preferences_.watchdog_starts_backgrounded, "GpuWatchdog"); ++ gpu_preferences_.watchdog_starts_backgrounded, ++ gl_use_swiftshader_ || ++ gl::IsSoftwareGLImplementation(gl::GetGLImplementationParts()), ++ "GpuWatchdog"); + watchdog_init.SetGpuWatchdogPtr(watchdog_thread_.get()); + + #if BUILDFLAG(IS_WIN) +@@ -366,24 +387,6 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line, + ->GetSupportedFormatsForTexturing(); + #endif + +- if (!gl_use_swiftshader_) { +- gl_use_swiftshader_ = EnableSwiftShaderIfNeeded( +- command_line, gpu_feature_info_, +- gpu_preferences_.disable_software_rasterizer, needs_more_info); +- } +- if (gl_initialized && gl_use_swiftshader_ && +- !gl::IsSoftwareGLImplementation(gl::GetGLImplementationParts())) { +-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) +- VLOG(1) << "Quit GPU process launch to fallback to SwiftShader cleanly " +- << "on Linux"; +- return false; +-#else +- SaveHardwareGpuInfoAndGpuFeatureInfo(); +- gl::init::ShutdownGL(true); +- gl_initialized = false; +-#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) +- } +- + if (!gl_initialized) { + // Pause watchdog. LoadLibrary in GLBindings may take long time. + if (watchdog_thread_) +@@ -467,8 +470,15 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line, + #else + SaveHardwareGpuInfoAndGpuFeatureInfo(); + gl::init::ShutdownGL(true); +- watchdog_thread_ = nullptr; +- watchdog_init.SetGpuWatchdogPtr(nullptr); ++ if (watchdog_thread_.get()) { ++ // Recreate watchdog for software rasterizer. ++ watchdog_thread_ = nullptr; ++ watchdog_init.SetGpuWatchdogPtr(nullptr); ++ watchdog_thread_ = GpuWatchdogThread::Create( ++ gpu_preferences_.watchdog_starts_backgrounded, ++ /*software_rendering=*/true, "GpuWatchdog"); ++ watchdog_init.SetGpuWatchdogPtr(watchdog_thread_.get()); ++ } + if (!gl::init::InitializeGLNoExtensionsOneOff(/*init_bindings*/ true)) { + VLOG(1) + << "gl::init::InitializeGLNoExtensionsOneOff with SwiftShader " +@@ -608,9 +618,7 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line, + UMA_HISTOGRAM_MEDIUM_TIMES("GPU.InitializeOneOffMediumTime", + initialize_one_off_time); + +- // Software GL is expected to run slowly, so disable the watchdog +- // in that case. +- // In SwiftShader case, the implementation is actually EGLGLES2. ++ bool recreate_watchdog = false; + if (!gl_use_swiftshader_ && command_line->HasSwitch(switches::kUseGL)) { + std::string use_gl = command_line->GetSwitchValueASCII(switches::kUseGL); + std::string use_angle = +@@ -621,19 +629,27 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line, + (use_angle == gl::kANGLEImplementationSwiftShaderName || + use_angle == gl::kANGLEImplementationSwiftShaderForWebGLName))) { + gl_use_swiftshader_ = true; ++ if (watchdog_thread_) { ++ recreate_watchdog = true; ++ } + } + } + if (gl_use_swiftshader_ || + gl::IsSoftwareGLImplementation(gl::GetGLImplementationParts())) { + gpu_info_.software_rendering = true; +- watchdog_thread_ = nullptr; +- watchdog_init.SetGpuWatchdogPtr(nullptr); + } else if (gl_disabled) { ++ DCHECK(!recreate_watchdog); + watchdog_thread_ = nullptr; + watchdog_init.SetGpuWatchdogPtr(nullptr); + } else if (enable_watchdog && delayed_watchdog_enable) { +- watchdog_thread_ = GpuWatchdogThread::Create( +- gpu_preferences_.watchdog_starts_backgrounded, "GpuWatchdog"); ++ recreate_watchdog = true; ++ } ++ if (recreate_watchdog) { ++ watchdog_thread_ = nullptr; ++ watchdog_init.SetGpuWatchdogPtr(nullptr); ++ watchdog_thread_ = ++ GpuWatchdogThread::Create(gpu_preferences_.watchdog_starts_backgrounded, ++ gpu_info_.software_rendering, "GpuWatchdog"); + watchdog_init.SetGpuWatchdogPtr(watchdog_thread_.get()); + } + +diff --git a/src/gpu/ipc/service/gpu_watchdog_thread.cc b/src/gpu/ipc/service/gpu_watchdog_thread.cc +index a35533be142..f98dfb587ff +--- a/src/gpu/ipc/service/gpu_watchdog_thread.cc ++++ b/src/gpu/ipc/service/gpu_watchdog_thread.cc +@@ -37,7 +37,7 @@ + + namespace gpu { + +-base::TimeDelta GetGpuWatchdogTimeout() { ++base::TimeDelta GetGpuWatchdogTimeout(bool software_rendering) { + std::string timeout_str = + base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( + switches::kGpuWatchdogTimeoutSeconds); +@@ -50,17 +50,21 @@ base::TimeDelta GetGpuWatchdogTimeout() { + << timeout_str; + } + ++ base::TimeDelta timeout = kGpuWatchdogTimeout; + #if BUILDFLAG(IS_WIN) + if (base::win::GetVersion() >= base::win::Version::WIN10) { + int num_of_processors = base::SysInfo::NumberOfProcessors(); + if (num_of_processors > 8) +- return (kGpuWatchdogTimeout - base::Seconds(10)); ++ timeout -= base::Seconds(10); + else if (num_of_processors <= 4) +- return kGpuWatchdogTimeout + base::Seconds(5); ++ timeout += base::Seconds(5); + } + #endif + +- return kGpuWatchdogTimeout; ++ if (software_rendering) { ++ timeout *= kSoftwareRenderingFactor; ++ } ++ return timeout; + } + + GpuWatchdogThread::GpuWatchdogThread(base::TimeDelta timeout, +@@ -142,9 +146,22 @@ std::unique_ptr GpuWatchdogThread::Create( + // static + std::unique_ptr GpuWatchdogThread::Create( + bool start_backgrounded, ++ bool software_rendering, ++ const std::string& thread_name) { ++ return Create(start_backgrounded, GetGpuWatchdogTimeout(software_rendering), ++ kInitFactor, kRestartFactor, /*test_mode=*/false, thread_name); ++} ++ ++// static ++std::unique_ptr GpuWatchdogThread::Create( ++ bool start_backgrounded, ++ const GpuWatchdogThread* existing_watchdog, + const std::string& thread_name) { +- return Create(start_backgrounded, GetGpuWatchdogTimeout(), kInitFactor, +- kRestartFactor, /*test_mode=*/false, thread_name); ++ DCHECK(existing_watchdog); ++ return Create(start_backgrounded, existing_watchdog->watchdog_timeout_, ++ existing_watchdog->watchdog_init_factor_, ++ existing_watchdog->watchdog_restart_factor_, ++ /*test_mode=*/false, thread_name); + } + + // Android Chrome goes to the background. Called from the gpu thread. +diff --git a/src/gpu/ipc/service/gpu_watchdog_thread.h b/src/gpu/ipc/service/gpu_watchdog_thread.h +index 19ae3eff20e..1f48a69a8ff +--- a/src/gpu/ipc/service/gpu_watchdog_thread.h ++++ b/src/gpu/ipc/service/gpu_watchdog_thread.h +@@ -84,6 +84,14 @@ class GPU_IPC_SERVICE_EXPORT GpuWatchdogThread + public: + static std::unique_ptr Create( + bool start_backgrounded, ++ bool software_rendering, ++ const std::string& thread_name); ++ ++ // Use the existing GpuWatchdogThread to create a second one. This is used ++ // for DrDC thread only. ++ static std::unique_ptr Create( ++ bool start_backgrounded, ++ const GpuWatchdogThread* existing_watchdog, + const std::string& thread_name); + + static std::unique_ptr Create( +diff --git a/src/ipc/ipc_message_utils.cc b/src/ipc/ipc_message_utils.cc +index 4afbae1e020..f53d672a526 +--- a/src/ipc/ipc_message_utils.cc ++++ b/src/ipc/ipc_message_utils.cc +@@ -946,7 +946,7 @@ void ParamTraits::Write( + const_cast(p).PassPlatformHandle(); + MachPortMac mach_port_mac(h.get()); + WriteParam(m, mach_port_mac); +-#elif BUILDFLAG(IS_ANDROID) ++#elif BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + m->WriteAttachment(new internal::PlatformFileAttachment( + base::ScopedFD(const_cast(p).PassPlatformHandle()))); + #elif BUILDFLAG(IS_POSIX) +@@ -1011,7 +1011,7 @@ bool ParamTraits::Read( + return false; + } + +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + *r = base::subtle::PlatformSharedMemoryRegion::Take( + base::ScopedFD( + static_cast(attachment.get()) +@@ -1058,7 +1058,7 @@ void ParamTraits::Log( + #elif BUILDFLAG(IS_MAC) + l->append("Mach port: "); + LogParam(p.GetPlatformHandle(), l); +-#elif BUILDFLAG(IS_ANDROID) ++#elif BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + l->append("FD: "); + LogParam(p.GetPlatformHandle(), l); + #elif BUILDFLAG(IS_POSIX) +diff --git a/src/media/audio/audio_manager_base.cc b/src/media/audio/audio_manager_base.cc +index 6ef348a6cb7..bd8bf26a91a +--- a/src/media/audio/audio_manager_base.cc ++++ b/src/media/audio/audio_manager_base.cc +@@ -33,7 +33,11 @@ namespace media { + + namespace { + ++#if BUILDFLAG(IS_OHOS) ++const int kStreamCloseDelaySeconds = 100000; ++#else + const int kStreamCloseDelaySeconds = 5; ++#endif + + // Default maximum number of output streams that can be open simultaneously + // for all platforms. +@@ -380,6 +384,15 @@ AudioOutputStream* AudioManagerBase::MakeAudioOutputStreamProxy( + // Turn off effects that weren't requested. + output_params.set_effects(params.effects() & output_params.effects()); + } ++ ++#if BUILDFLAG(IS_OHOS) ++ if (params.render_process_id() != output_params.render_process_id()) { ++ output_params.set_render_process_id(params.render_process_id()); ++ } ++ if (params.render_frame_id() != output_params.render_frame_id()) { ++ output_params.set_render_frame_id(params.render_frame_id()); ++ } ++#endif + + uma_stream_format = STREAM_FORMAT_PCM_LOW_LATENCY; + } else { +diff --git a/src/media/audio/ohos/ohos_audio_manager.cc b/src/media/audio/ohos/ohos_audio_manager.cc +index 9d3ba2ffb0c..979d0643137 +--- a/src/media/audio/ohos/ohos_audio_manager.cc ++++ b/src/media/audio/ohos/ohos_audio_manager.cc +@@ -6,6 +6,7 @@ + + #include "audio_system_manager_adapter.h" + #include "base/command_line.h" ++#include "base/logging.h" + #include "media/base/media_switches.h" + #include "ohos_adapter_helper.h" + +@@ -13,7 +14,7 @@ namespace media { + + constexpr int kDefaultSampleRate = 48000; + constexpr int kDefaultChannelCount = 2; +-constexpr int kMinimumOutputBufferSize = 512; ++constexpr int kMinimumOutputBufferSize = 2048; + static const char* AUDIO_MANAGER_NAME = "OHOS"; + + std::unique_ptr CreateAudioManager( +diff --git a/src/media/audio/ohos/ohos_audio_output_stream.cc b/src/media/audio/ohos/ohos_audio_output_stream.cc +index cbccfccd616..210b0b9d4d2 +--- a/src/media/audio/ohos/ohos_audio_output_stream.cc ++++ b/src/media/audio/ohos/ohos_audio_output_stream.cc +@@ -9,11 +9,59 @@ + + namespace media { + ++AudioRendererCallback::AudioRendererCallback(content::MediaSessionImpl* media_session) ++ : media_session_(media_session) {} ++ ++AudioRendererCallback::~AudioRendererCallback() {} ++ ++void AudioRendererCallback::OnSuspend() { ++ if (!media_session_) { ++ LOG(ERROR) << "AudioRendererCallback::OnSuspend media_session_ is null."; ++ return; ++ } ++ if (media_session_->audioResumeInterval_ > 0) { ++ intervalSinceLastSuspend_ = std::time(nullptr); ++ } ++} ++ ++void AudioRendererCallback::OnResume() { ++ LOG(DEBUG) << "AudioRendererCallback::OnResume audioResumeInterval is: " ++ << std::time(nullptr) - intervalSinceLastSuspend_; ++ if (!media_session_) { ++ LOG(ERROR) << "AudioRendererCallback::OnResume media_session_ is null."; ++ return; ++ } ++ if (media_session_->audioResumeInterval_ > 0 && ++ std::time(nullptr) - intervalSinceLastSuspend_ <= static_cast(media_session_->audioResumeInterval_) && ++ media_session_->IsSuspended()) { ++ media_session_->Resume(content::MediaSession::SuspendType::kSystem); ++ } ++} ++ ++bool AudioRendererCallback::GetSuspendFlag() { ++ return suspendFlag_; ++} ++ ++void AudioRendererCallback::SetSuspendFlag(bool flag) { ++ suspendFlag_ = flag; ++} ++ + OHOSAudioOutputStream::OHOSAudioOutputStream(OHOSAudioManager* manager, + const AudioParameters& parameters) + : manager_(manager), + parameters_(parameters), + audio_bus_(AudioBus::Create(parameters)) { ++ content::RenderFrameHost* renderFrameHost = ++ content::RenderFrameHost::FromID(parameters_.render_process_id(), parameters_.render_frame_id()); ++ content::WebContents* webContent = content::WebContents::FromRenderFrameHost(renderFrameHost); ++ if (!webContent) { ++ LOG(ERROR) << "AudioOutputStream get webContent failed."; ++ } else { ++ mediaSession_ = content::MediaSessionImpl::Get(webContent); ++ } ++ if (!mediaSession_) { ++ LOG(ERROR) << "AudioOutputStream get mediaSession failed."; ++ } + audio_renderer_ = + OhosAdapterHelper::GetInstance().CreateAudioRendererAdapter(); + sample_format_ = kSampleFormatS16; +@@ -62,9 +110,21 @@ void OHOSAudioOutputStream::Close() { + } + + void OHOSAudioOutputStream::Start(AudioSourceCallback* callback) { ++ LOG(DEBUG) << "OHOSAudioOutputStream::Start"; + DCHECK(!callback_); + DCHECK(reference_time_.is_null()); + DCHECK(!timer_.IsRunning()); ++ rendererCallback_->SetSuspendFlag(false); ++ if (!mediaSession_) { ++ LOG(ERROR) << "OHOSAudioOutputStream::Start mediaSession is null."; ++ return; ++ } ++ auto ret = audio_renderer_->SetAudoiRendererCallback(rendererCallback_, mediaSession_->audioExclusive_); ++ if (ret != AudioAdapterCode::AUDIO_OK) { ++ LOG(ERROR) << "OHOSAudioOutputStream::Start Set audio renderer callback failed."; ++ rendererCallback_.reset(); ++ return; ++ } + + if (StartRender()) { + callback_ = callback; +@@ -78,11 +138,16 @@ void OHOSAudioOutputStream::Start(AudioSourceCallback* callback) { + } + + void OHOSAudioOutputStream::Stop() { ++ LOG(DEBUG) << "OHOSAudioOutputStream::Stop"; + callback_ = nullptr; + if (!reference_time_.is_null()) { + reference_time_ = base::TimeTicks(); + } + timer_.Stop(); ++ if (rendererCallback_ && rendererCallback_->GetSuspendFlag()) { ++ LOG(DEBUG) << "OHOSAudioOutputStream::Stop cannot continue."; ++ return; ++ } + if (!audio_renderer_->Stop()) { + ReportError(); + } +@@ -113,10 +178,25 @@ bool OHOSAudioOutputStream::InitRender( + int32_t ret = audio_renderer_->Create(rendererOptions); + if (ret != 0) { + if (!audio_renderer_->Release()) { +- LOG(ERROR) << "ohos audio render release failed"; ++ LOG(ERROR) << "ohos audio render release failed."; + } + return false; + } ++ if (!mediaSession_) { ++ LOG(ERROR) << "OHOSAudioOutputStream::InitRender Get mediaSession failed."; ++ return false; ++ } ++ rendererCallback_ = std::make_shared(mediaSession_); ++ if (!rendererCallback_) { ++ LOG(ERROR) << "OHOSAudioOutputStream::InitRender Get rendererCallback failed."; ++ return false; ++ } ++ ret = audio_renderer_->SetAudoiRendererCallback(rendererCallback_, mediaSession_->audioExclusive_); ++ if (ret != AudioAdapterCode::AUDIO_OK) { ++ LOG(ERROR) << "OHOSAudioOutputStream::InitRender Set audio renderer callback failed."; ++ rendererCallback_.reset(); ++ return false; ++ } + return true; + } + +@@ -167,12 +247,31 @@ void OHOSAudioOutputStream::PumpSamples() { + audio_bus_->ToInterleaved( + frames_filled, + reinterpret_cast(audio_data_[active_buffer_index_])); +- const int num_filled_bytes = frames_filled * bytes_per_frame_; +- +- int32_t result = audio_renderer_->Write(audio_data_[active_buffer_index_], +- num_filled_bytes); +- if (result < 0) { +- ReportError(); ++ const size_t num_filled_bytes = frames_filled * bytes_per_frame_; ++ size_t bytesWritten = 0; ++ while (bytesWritten < num_filled_bytes) { ++ int32_t bytesSingle = audio_renderer_->Write(audio_data_[active_buffer_index_] + ++ bytesWritten, num_filled_bytes - bytesWritten); ++ if (bytesSingle <= 0) { ++ LOG(ERROR) << "Audio renderer write audio data failed."; ++ if (!audio_renderer_->IsRendererStateRunning()) { ++ rendererCallback_->SetSuspendFlag(true); ++ if (!mediaSession_) { ++ LOG(ERROR) << "Try to suspend audio but get mediaSession failed."; ++ ReportError(); ++ return; ++ } ++ if (mediaSession_->IsActive()) { ++ LOG(DEBUG) << "MediaSession is suspending the audio."; ++ mediaSession_->Suspend(content::MediaSession::SuspendType::kSystem); ++ } ++ } else { ++ ReportError(); ++ return; ++ } ++ break; ++ } ++ bytesWritten += bytesSingle; + } + + active_buffer_index_ = (active_buffer_index_ + 1) % kMaxNumOfBuffersInQueue; +diff --git a/src/media/audio/ohos/ohos_audio_output_stream.h b/src/media/audio/ohos/ohos_audio_output_stream.h +index 82135cac5c8..5ac1d100e93 +--- a/src/media/audio/ohos/ohos_audio_output_stream.h ++++ b/src/media/audio/ohos/ohos_audio_output_stream.h +@@ -6,8 +6,12 @@ + #define MEDIA_AUDIO_OHOS_AUDIO_OUTPUT_STREAM_H_ + + #include "audio_renderer_adapter.h" ++#include "base/feature_list.h" + #include "base/logging.h" + #include "base/timer/timer.h" ++#include "content/browser/media/audio_output_stream_broker.h" ++#include "content/browser/media/session/media_session_impl.h" ++#include "content/public/browser/web_contents.h" + #include "media/audio/ohos/ohos_audio_manager.h" + + namespace media { +@@ -15,6 +19,21 @@ using namespace OHOS::NWeb; + + class OHOSAudioManager; + ++class AudioRendererCallback : public AudioRendererCallbackAdapter { ++ public: ++ AudioRendererCallback(content::MediaSessionImpl* media_session); ++ ~AudioRendererCallback(); ++ void OnSuspend() override; ++ void OnResume() override; ++ bool GetSuspendFlag(); ++ void SetSuspendFlag(bool flag); ++ ++ private: ++ content::MediaSessionImpl* media_session_; ++ time_t intervalSinceLastSuspend_ = 0.0; ++ bool suspendFlag_ = false; ++}; ++ + class OHOSAudioOutputStream : public AudioOutputStream { + public: + static const int kMaxNumOfBuffersInQueue = 2; +@@ -91,6 +110,10 @@ class OHOSAudioOutputStream : public AudioOutputStream { + SampleFormat sample_format_; + + std::unique_ptr audio_renderer_; ++ ++ content::MediaSessionImpl* mediaSession_ = nullptr; ++ ++ std::shared_ptr rendererCallback_ = nullptr; + }; + + } // namespace media +diff --git a/src/media/base/audio_parameters.cc b/src/media/base/audio_parameters.cc +index 73660aeecf1..c87686d4444 +--- a/src/media/base/audio_parameters.cc ++++ b/src/media/base/audio_parameters.cc +@@ -172,7 +172,13 @@ bool AudioParameters::Equals(const AudioParameters& other) const { + channel_layout_ == other.channel_layout() && + channels_ == other.channels() && + frames_per_buffer_ == other.frames_per_buffer() && ++#if BUILDFLAG(IS_OHOS) ++ effects_ == other.effects() && mic_positions_ == other.mic_positions_ && ++ render_process_id_ == other.render_process_id() && ++ render_frame_id_ == other.render_frame_id(); ++#else + effects_ == other.effects() && mic_positions_ == other.mic_positions_; ++#endif + } + + bool AudioParameters::IsBitstreamFormat() const { +diff --git a/src/media/base/audio_parameters.h b/src/media/base/audio_parameters.h +index 5f61f806f8f..01f35761197 +--- a/src/media/base/audio_parameters.h ++++ b/src/media/base/audio_parameters.h +@@ -261,6 +261,14 @@ class MEDIA_SHMEM_EXPORT AudioParameters { + void set_effects(int effects) { effects_ = effects; } + int effects() const { return effects_; } + ++#if BUILDFLAG(IS_OHOS) ++ void set_render_process_id(int render_process_id) { render_process_id_ = render_process_id; } ++ int render_process_id() const { return render_process_id_; } ++ ++ void set_render_frame_id(int render_frame_id) { render_frame_id_ = render_frame_id; } ++ int render_frame_id() const { return render_frame_id_; } ++#endif ++ + void set_mic_positions(const std::vector& mic_positions) { + mic_positions_ = mic_positions; + } +@@ -286,6 +294,11 @@ class MEDIA_SHMEM_EXPORT AudioParameters { + int frames_per_buffer_; // Number of frames in a buffer. + int effects_; // Bitmask using PlatformEffectsMask. + ++#if BUILDFLAG(IS_OHOS) ++ int render_process_id_; ++ int render_frame_id_; ++#endif ++ + // Microphone positions using Cartesian coordinates: + // x: the horizontal dimension, with positive to the right from the camera's + // perspective. +diff --git a/src/media/base/audio_renderer_mixer.cc b/src/media/base/audio_renderer_mixer.cc +index 91ba595752d..0c1f9d5fa39 +--- a/src/media/base/audio_renderer_mixer.cc ++++ b/src/media/base/audio_renderer_mixer.cc +@@ -13,9 +13,17 @@ + #include "media/base/audio_renderer_mixer_input.h" + #include "media/base/audio_timestamp_helper.h" + ++#if BUILDFLAG(IS_OHOS) ++#include "base/logging.h" ++#endif ++ + namespace media { + ++#if BUILDFLAG(IS_OHOS) ++constexpr base::TimeDelta kPauseDelay = base::Seconds(0); ++#else + constexpr base::TimeDelta kPauseDelay = base::Seconds(10); ++#endif + + AudioRendererMixer::AudioRendererMixer(const AudioParameters& output_params, + scoped_refptr sink) +@@ -129,6 +137,9 @@ int AudioRendererMixer::Render(base::TimeDelta delay, + if (!aggregate_converter_.empty()) { + last_play_time_ = now; + } else if (now - last_play_time_ >= pause_delay_ && playing_) { ++#if BUILDFLAG(IS_OHOS) ++ LOG(DEBUG) << "AudioRendererMixer::Render Time to pause the sink to avoid wasting resources"; ++#endif + audio_sink_->Pause(); + playing_ = false; + } +diff --git a/src/media/base/ipc/media_param_traits.cc b/src/media/base/ipc/media_param_traits.cc +index 884ac079019..f9debd26860 +--- a/src/media/base/ipc/media_param_traits.cc ++++ b/src/media/base/ipc/media_param_traits.cc +@@ -28,6 +28,10 @@ void ParamTraits::Write(base::Pickle* m, + WriteParam(m, p.frames_per_buffer()); + WriteParam(m, p.channels()); + WriteParam(m, p.effects()); ++#if BUILDFLAG(IS_OHOS) ++ WriteParam(m, p.render_process_id()); ++ WriteParam(m, p.render_frame_id()); ++#endif + WriteParam(m, p.mic_positions()); + WriteParam(m, p.latency_tag()); + WriteParam(m, p.hardware_capabilities()); +@@ -38,7 +42,9 @@ bool ParamTraits::Read(const base::Pickle* m, + AudioParameters* r) { + AudioParameters::Format format; + ChannelLayout channel_layout; +- int sample_rate, frames_per_buffer, channels, effects; ++#if BUILDFLAG(IS_OHOS) ++ int sample_rate, frames_per_buffer, channels, effects, render_process_id, render_frame_id; ++#endif + std::vector mic_positions; + AudioLatency::LatencyType latency_tag; + absl::optional +@@ -48,6 +54,9 @@ bool ParamTraits::Read(const base::Pickle* m, + !ReadParam(m, iter, &sample_rate) || + !ReadParam(m, iter, &frames_per_buffer) || + !ReadParam(m, iter, &channels) || !ReadParam(m, iter, &effects) || ++#if BUILDFLAG(IS_OHOS) ++ !ReadParam(m, iter, &render_process_id) || !ReadParam(m, iter, &render_frame_id) || ++#endif + !ReadParam(m, iter, &mic_positions) || + !ReadParam(m, iter, &latency_tag) || + !ReadParam(m, iter, &hardware_capabilities)) { +@@ -64,6 +73,10 @@ bool ParamTraits::Read(const base::Pickle* m, + + r->set_channels_for_discrete(channels); + r->set_effects(effects); ++#if BUILDFLAG(IS_OHOS) ++ r->set_render_process_id(render_process_id); ++ r->set_render_frame_id(render_frame_id); ++#endif + r->set_mic_positions(mic_positions); + r->set_latency_tag(latency_tag); + +diff --git a/src/media/base/ohos/BUILD.gn b/src/media/base/ohos/BUILD.gn +index 0d19eac1234..60c80208671 +--- a/src/media/base/ohos/BUILD.gn ++++ b/src/media/base/ohos/BUILD.gn +@@ -28,10 +28,7 @@ if (is_ohos) { + "//media/base", + "//url", + ] +- libs = [ +- "surface.z", +- "media_client.z", +- ] ++ libs = [ "nweb_ohos_adapter.z" ] + include_dirs = ohos_src_includes + lib_dirs = ohos_libs_dir + } + diff --git a/src/media/base/ohos/ohos_media_player_bridge.cc b/src/media/base/ohos/ohos_media_player_bridge.cc +index 48db79d0265..4baa18054b0 +--- a/src/media/base/ohos/ohos_media_player_bridge.cc ++++ b/src/media/base/ohos/ohos_media_player_bridge.cc +@@ -4,10 +4,11 @@ + + #include "media/base/ohos/ohos_media_player_bridge.h" + +-#include ++#include + #include + #include "base/logging.h" + #include "base/threading/thread_task_runner_handle.h" ++#include "ohos_adapter_helper.h" + + namespace media { + +@@ -32,11 +33,6 @@ OHOSMediaPlayerBridge::OHOSMediaPlayerBridge( + seeking_on_playback_complete_(false) {} + + OHOSMediaPlayerBridge::~OHOSMediaPlayerBridge() { +- if (player_) { +- player_->Release(); +- player_ = nullptr; +- } +- + cached_buffers_.clear(); + } + +@@ -69,9 +65,9 @@ void OHOSMediaPlayerBridge::Prepare() { + return; + } + +- player_ = OHOS::Media::PlayerFactory::CreatePlayer(); ++ player_ = OHOS::NWeb::OhosAdapterHelper::GetInstance().CreatePlayerAdapter(); + if (!player_) { +- LOG(ERROR) << "media create player failed"; ++ LOG(ERROR) << "media create player_adapter failed"; + return; + } + +@@ -81,10 +77,10 @@ void OHOSMediaPlayerBridge::Prepare() { + return; + } + +- std::shared_ptr media_player_callback = +- std::make_shared(task_runner_, ++ std::unique_ptr media_player_callback = ++ std::make_unique(task_runner_, + weak_factory_.GetWeakPtr()); +- int32_t ret = player_->SetPlayerCallback(media_player_callback); ++ int32_t ret = player_->SetPlayerCallback(std::move(media_player_callback)); + if (ret != 0) { + LOG(ERROR) << "SetPlayerCallback error::ret=" << ret; + return; +@@ -100,18 +96,20 @@ void OHOSMediaPlayerBridge::Prepare() { + return; + } + +- consumer_surface_ = OHOS::Surface::CreateSurfaceAsConsumer(); ++ consumer_surface_ = OHOS::NWeb::OhosAdapterHelper::GetInstance() ++ .CreateConsumerSurfaceAdapter(); + if (consumer_surface_ == nullptr) { +- LOG(ERROR) << "media create surface failed"; ++ LOG(ERROR) << "media create consumer surface adapter failed"; + return; + } +- listener_ = new OHOSMediaPlayerListener( +- task_runner_, weak_factory_.GetWeakPtr(), consumer_surface_); +- consumer_surface_->RegisterConsumerListener(listener_); +- consumer_surface_->SetUserData(surfaceFormat, +- std::to_string(PIXEL_FMT_RGBA_8888)); ++ auto listener = std::make_unique( ++ task_runner_, weak_factory_.GetWeakPtr()); ++ consumer_surface_->RegisterConsumerListener(std::move(listener)); ++ consumer_surface_->SetUserData( ++ surfaceFormat, ++ std::to_string(OHOS::NWeb::PixelFormatAdapter::PIXEL_FMT_RGBA_8888)); + consumer_surface_->SetQueueSize(3); +- ret = player_->SetVideoSurface(consumer_surface_); ++ ret = player_->SetVideoSurface(consumer_surface_.get()); + if (ret != 0) { + LOG(ERROR) << "SetVideoSurface error::ret=" << ret; + consumer_surface_ = nullptr; +@@ -131,7 +129,7 @@ void OHOSMediaPlayerBridge::StartInternal() { + } + + void OHOSMediaPlayerBridge::Pause() { +- if (player_ && player_state_ == OHOS::Media::PLAYER_STARTED) { ++ if (player_ && player_state_ == OHOS::NWeb::PlayerAdapter::PLAYER_STARTED) { + int32_t ret = player_->Pause(); + if (ret != 0) { + LOG(ERROR) << "Pause error::ret=" << ret; +@@ -142,7 +140,7 @@ void OHOSMediaPlayerBridge::Pause() { + void OHOSMediaPlayerBridge::SeekTo(base::TimeDelta time) { + pending_seek_ = time; + +- if (player_state_ == OHOS::Media::PLAYER_PLAYBACK_COMPLETE) { ++ if (player_state_ == OHOS::NWeb::PlayerAdapter::PLAYER_PLAYBACK_COMPLETE) { + seeking_on_playback_complete_ = true; + return; + } +@@ -157,7 +155,7 @@ void OHOSMediaPlayerBridge::SeekTo(base::TimeDelta time) { + + void OHOSMediaPlayerBridge::SeekInternal(base::TimeDelta time) { + int32_t ret = player_->Seek(time.InMilliseconds(), +- OHOS::Media::PlayerSeekMode::SEEK_CLOSEST); ++ OHOS::NWeb::PlayerSeekMode::SEEK_CLOSEST); + if (ret != 0) { + LOG(ERROR) << "Seek error::ret=" << ret; + } +@@ -210,27 +208,24 @@ void OHOSMediaPlayerBridge::FinishPaint(int fd) { + return; + } + +-#if defined(RK3568) +- if (cached_buffers_.front()->GetBufferHandle()->fd != fd) { +- LOG(ERROR) << "match fd error render fd=" << fd << " browser fd=" +- << cached_buffers_.front()->GetBufferHandle()->fd; +- } +-#else +- if (cached_buffers_.front()->GetBufferHandle()->reserve[0] != fd) { +- LOG(ERROR) << "match fd error render fd=" << fd << " browser fd=" +- << cached_buffers_.front()->GetBufferHandle()->reserve[0]; +- } +-#endif +- OHOS::SurfaceError ret = +- consumer_surface_->ReleaseBuffer(cached_buffers_.front(), -1); +- if (ret != OHOS::SURFACE_ERROR_OK) { +- LOG(ERROR) << "release buffer fail, ret=" << ret; ++ if (cached_buffers_.front()) { ++ if (cached_buffers_.front()->GetFileDescriptor() != fd) { ++ LOG(ERROR) << "match fd error render fd=" << fd << " browser fd=" ++ << cached_buffers_.front()->GetFileDescriptor(); ++ } ++ int32_t ret = consumer_surface_->ReleaseBuffer( ++ std::move(cached_buffers_.front()), -1); ++ if (ret != OHOS::NWeb::GSErrorCode::GSERROR_OK) { ++ LOG(ERROR) << "release buffer fail, ret=" << ret; ++ } ++ } else { ++ LOG(ERROR) << "cached_buffers_.front() is nullptr"; + } + cached_buffers_.pop_front(); + } + + void OHOSMediaPlayerBridge::SetPlaybackSpeed( +- OHOS::Media::PlaybackRateMode mode) { ++ OHOS::NWeb::PlaybackRateMode mode) { + if (player_) { + int32_t ret = player_->SetPlaybackSpeed(mode); + if (ret != 0) { +@@ -248,18 +243,18 @@ void OHOSMediaPlayerBridge::OnError(int32_t error_code) { + } + + void OHOSMediaPlayerBridge::OnPlayerStateUpdate( +- OHOS::Media::PlayerStates player_state) { ++ OHOS::NWeb::PlayerAdapter::PlayerStates player_state) { + if (!player_) { + return; + } + +- if (player_state_ == OHOS::Media::PLAYER_PLAYBACK_COMPLETE && ++ if (player_state_ == OHOS::NWeb::PlayerAdapter::PlayerStates::PLAYER_PLAYBACK_COMPLETE && + player_state != player_state_) { + seeking_on_playback_complete_ = false; + } + + player_state_ = player_state; +- if (player_state == OHOS::Media::PLAYER_PREPARED) { ++ if (player_state == OHOS::NWeb::PlayerAdapter::PlayerStates::PLAYER_PREPARED) { + prepared_ = true; + + PropagateDuration(GetDuration()); +@@ -279,16 +274,16 @@ void OHOSMediaPlayerBridge::OnPlayerStateUpdate( + StartInternal(); + pending_play_ = false; + } +- } else if (player_state == OHOS::Media::PLAYER_STATE_ERROR || +- player_state == OHOS::Media::PLAYER_IDLE || +- player_state == OHOS::Media::PLAYER_INITIALIZED || +- player_state == OHOS::Media::PLAYER_PREPARING) { ++ } else if (player_state == OHOS::NWeb::PlayerAdapter::PlayerStates::PLAYER_STATE_ERROR || ++ player_state == OHOS::NWeb::PlayerAdapter::PlayerStates::PLAYER_IDLE || ++ player_state == OHOS::NWeb::PlayerAdapter::PlayerStates::PLAYER_INITIALIZED || ++ player_state == OHOS::NWeb::PlayerAdapter::PlayerStates::PLAYER_PREPARING) { + prepared_ = false; + } + } + + void OHOSMediaPlayerBridge::OnBufferAvailable( +- OHOS::sptr buffer) { ++ std::unique_ptr buffer) { + if (!task_runner_->BelongsToCurrentThread()) { + task_runner_->PostTask( + FROM_HERE, +@@ -297,15 +292,11 @@ void OHOSMediaPlayerBridge::OnBufferAvailable( + return; + } + +-#if defined(RK3568) +- int fd = buffer->GetBufferHandle()->fd; +-#else +- int fd = buffer->GetBufferHandle()->reserve[0]; +-#endif ++ int fd = buffer->GetFileDescriptor(); + if (fd <= 0) { + LOG(ERROR) << "surface buffer fd error fd:" << fd; +- OHOS::SurfaceError ret = consumer_surface_->ReleaseBuffer(buffer, -1); +- if (ret != OHOS::SURFACE_ERROR_OK) { ++ int32_t ret = consumer_surface_->ReleaseBuffer(std::move(buffer), -1); ++ if (ret != OHOS::NWeb::GSErrorCode::GSERROR_OK) { + LOG(ERROR) << "release buffer fail, ret=" << ret; + } + return; +@@ -328,7 +319,7 @@ void OHOSMediaPlayerBridge::OnBufferAvailable( + } else { + coded_height = (buffer->GetHeight() / step_height + 1) * step_height; + } +- if (buffer->GetFormat() == PIXEL_FMT_RGBA_8888) { ++ if (buffer->GetFormat() == OHOS::NWeb::PixelFormatAdapter::PIXEL_FMT_RGBA_8888) { + coded_width = buffer->GetStride() / argb_stride_step; + } else { + coded_width = buffer->GetStride(); +@@ -337,7 +328,7 @@ void OHOSMediaPlayerBridge::OnBufferAvailable( + buffer->GetWidth(), buffer->GetHeight(), + buffer->GetFormat()); + #endif +- cached_buffers_.push_back(buffer); ++ cached_buffers_.push_back(std::move(buffer)); + } + + int32_t OHOSMediaPlayerBridge::SetFdSource(const std::string& path) { +diff --git a/src/media/base/ohos/ohos_media_player_bridge.h b/src/media/base/ohos/ohos_media_player_bridge.h +index 523c51693a1..b545e7dd5c3 +--- a/src/media/base/ohos/ohos_media_player_bridge.h ++++ b/src/media/base/ohos/ohos_media_player_bridge.h +@@ -5,11 +5,11 @@ + #ifndef MEDIA_BASE_OHOS_MEDIA_PLAYER_BRIDGE_H_ + #define MEDIA_BASE_OHOS_MEDIA_PLAYER_BRIDGE_H_ + +-#include +-#include + #include + + #include "base/memory/weak_ptr.h" ++#include "graphic_adapter.h" ++#include "media_adapter.h" + #include "media/base/media_export.h" + #include "media/base/ohos/ohos_media_player_callback.h" + #include "media/base/ohos/ohos_media_player_listener.h" +@@ -72,12 +72,12 @@ class MEDIA_EXPORT OHOSMediaPlayerBridge { + void SetVolume(float volume); + base::TimeDelta GetMediaTime(); + void FinishPaint(int fd); +- void SetPlaybackSpeed(OHOS::Media::PlaybackRateMode mode); ++ void SetPlaybackSpeed(OHOS::NWeb::PlaybackRateMode mode); + + void OnEnd(); + void OnError(int32_t errorCode); +- void OnBufferAvailable(OHOS::sptr buffer); +- void OnPlayerStateUpdate(OHOS::Media::PlayerStates player_state); ++ void OnBufferAvailable(std::unique_ptr buffer); ++ void OnPlayerStateUpdate(OHOS::NWeb::PlayerAdapter::PlayerStates player_state); + + private: + int32_t SetFdSource(const std::string& path); +@@ -87,10 +87,9 @@ class MEDIA_EXPORT OHOSMediaPlayerBridge { + void PropagateDuration(base::TimeDelta duration); + + const std::string surfaceFormat = "SURFACE_FORMAT"; +- std::shared_ptr player_ = nullptr; +- std::deque> cached_buffers_; +- OHOS::sptr consumer_surface_ = nullptr; +- OHOS::sptr listener_; ++ std::unique_ptr player_ = nullptr; ++ std::deque> cached_buffers_; ++ std::unique_ptr consumer_surface_ = nullptr; + scoped_refptr task_runner_; + Client* client_; + GURL url_; +@@ -101,7 +100,7 @@ class MEDIA_EXPORT OHOSMediaPlayerBridge { + bool should_set_volume_on_prepare_; + base::TimeDelta duration_; + base::TimeDelta pending_seek_; +- OHOS::Media::PlayerStates player_state_; ++ OHOS::NWeb::PlayerAdapter::PlayerStates player_state_; + + // MediaPlayer is unable to handle Seek request when playback end. We should + // pending the SeekTo request until its playback state changed. +diff --git a/src/media/base/ohos/ohos_media_player_callback.cc b/src/media/base/ohos/ohos_media_player_callback.cc +index 4fe5ec01456..add1d07aaa1 +--- a/src/media/base/ohos/ohos_media_player_callback.cc ++++ b/src/media/base/ohos/ohos_media_player_callback.cc +@@ -16,15 +16,14 @@ OHOSMediaPlayerCallback::OHOSMediaPlayerCallback( + + OHOSMediaPlayerCallback::~OHOSMediaPlayerCallback() {} + +-void OHOSMediaPlayerCallback::OnError(OHOS::Media::PlayerErrorType errorType, +- int32_t errorCode) { +- LOG(ERROR) << "media player error code=" << errorCode; ++void OHOSMediaPlayerCallback::OnError(OHOS::NWeb::PlayerAdapterErrorType errorType) { ++ LOG(ERROR) << "media player error"; + int media_error_type = + OHOSMediaPlayerBridge::MediaErrorType::MEDIA_ERROR_INVALID_CODE; +- if (IsUnsupportType(errorCode)) { ++ if (errorType == OHOS::NWeb::PlayerAdapterErrorType::UNSUPPORT_TYPE) { + media_error_type = + OHOSMediaPlayerBridge::MediaErrorType::MEDIA_ERROR_FORMAT; +- } else if (IsFatalError(errorCode)) { ++ } else if (errorType == OHOS::NWeb::PlayerAdapterErrorType::FATAL_ERROR) { + media_error_type = + OHOSMediaPlayerBridge::MediaErrorType::MEDIA_ERROR_DECODE; + } +@@ -33,63 +32,27 @@ void OHOSMediaPlayerCallback::OnError(OHOS::Media::PlayerErrorType errorType, + media_error_type)); + } + +-void OHOSMediaPlayerCallback::OnInfo(OHOS::Media::PlayerOnInfoType type, +- int32_t extra, +- const OHOS::Media::Format& infoBody) { +- (void)infoBody; ++void OHOSMediaPlayerCallback::OnInfo(OHOS::NWeb::PlayerOnInfoType type, ++ int32_t extra) { + switch (type) { +- case OHOS::Media::INFO_TYPE_EOS: ++ case OHOS::NWeb::PlayerOnInfoType::INFO_TYPE_EOS: + task_runner_->PostTask( + FROM_HERE, + base::BindOnce(&OHOSMediaPlayerBridge::OnEnd, media_player_)); + break; +- case OHOS::Media::INFO_TYPE_STATE_CHANGE: ++ case OHOS::NWeb::PlayerOnInfoType::INFO_TYPE_STATE_CHANGE: + task_runner_->PostTask( + FROM_HERE, + base::BindOnce(&OHOSMediaPlayerBridge::OnPlayerStateUpdate, + media_player_, +- static_cast(extra))); ++ static_cast(extra))); + break; +- case OHOS::Media::INFO_TYPE_POSITION_UPDATE: ++ case OHOS::NWeb::PlayerOnInfoType::INFO_TYPE_POSITION_UPDATE: + break; +- case OHOS::Media::INFO_TYPE_MESSAGE: ++ case OHOS::NWeb::PlayerOnInfoType::INFO_TYPE_MESSAGE: + break; + default: + break; + } + } +- +-bool OHOSMediaPlayerCallback::IsUnsupportType(int32_t errorCode) { +- switch (errorCode) { +- case OHOS::Media::MSERR_UNSUPPORT: +- case OHOS::Media::MSERR_UNSUPPORT_AUD_SRC_TYPE: +- case OHOS::Media::MSERR_UNSUPPORT_AUD_CHANNEL_NUM: +- case OHOS::Media::MSERR_UNSUPPORT_AUD_ENC_TYPE: +- case OHOS::Media::MSERR_UNSUPPORT_AUD_PARAMS: +- case OHOS::Media::MSERR_UNSUPPORT_VID_SRC_TYPE: +- case OHOS::Media::MSERR_UNSUPPORT_VID_ENC_TYPE: +- case OHOS::Media::MSERR_UNSUPPORT_VID_PARAMS: +- case OHOS::Media::MSERR_UNSUPPORT_CONTAINER_TYPE: +- case OHOS::Media::MSERR_UNSUPPORT_PROTOCOL_TYPE: +- case OHOS::Media::MSERR_UNSUPPORT_VID_DEC_TYPE: +- case OHOS::Media::MSERR_UNSUPPORT_AUD_DEC_TYPE: +- return true; +- } +- return false; +-} +-bool OHOSMediaPlayerCallback::IsFatalError(int32_t errorCode) { +- switch (errorCode) { +- case OHOS::Media::MSERR_NO_MEMORY: +- case OHOS::Media::MSERR_SERVICE_DIED: +- case OHOS::Media::MSERR_CREATE_PLAYER_ENGINE_FAILED: +- case OHOS::Media::MSERR_CREATE_AVMETADATAHELPER_ENGINE_FAILED: +- case OHOS::Media::MSERR_AUD_DEC_FAILED: +- case OHOS::Media::MSERR_VID_DEC_FAILED: +- case OHOS::Media::MSERR_OPEN_FILE_FAILED: +- case OHOS::Media::MSERR_FILE_ACCESS_FAILED: +- return true; +- } +- return false; +-} +- + } // namespace media +diff --git a/src/media/base/ohos/ohos_media_player_callback.h b/src/media/base/ohos/ohos_media_player_callback.h +index 53cdd040374..1a4f703740e +--- a/src/media/base/ohos/ohos_media_player_callback.h ++++ b/src/media/base/ohos/ohos_media_player_callback.h +@@ -5,7 +5,6 @@ + #ifndef MEDIA_BASE_OHOS_MEDIA_PLAYER_CALLBACK_H_ + #define MEDIA_BASE_OHOS_MEDIA_PLAYER_CALLBACK_H_ + +-#include + #include "base/logging.h" + #include "base/task/single_thread_task_runner.h" + #include "media/base/ohos/ohos_media_player_bridge.h" +@@ -18,7 +17,7 @@ namespace media { + + class OHOSMediaPlayerBridge; + +-class OHOSMediaPlayerCallback : public OHOS::Media::PlayerCallback { ++class OHOSMediaPlayerCallback : public OHOS::NWeb::PlayerCallbackAdapter { + public: + OHOSMediaPlayerCallback( + const scoped_refptr& task_runner, +@@ -29,13 +28,8 @@ class OHOSMediaPlayerCallback : public OHOS::Media::PlayerCallback { + + virtual ~OHOSMediaPlayerCallback(); + +- void OnError(OHOS::Media::PlayerErrorType errorType, +- int32_t errorCode) override; +- void OnInfo(OHOS::Media::PlayerOnInfoType type, +- int32_t extra, +- const OHOS::Media::Format& infoBody = {}) override; +- bool IsUnsupportType(int32_t errorCode); +- bool IsFatalError(int32_t errorCode); ++ void OnError(OHOS::NWeb::PlayerAdapterErrorType errorType) override; ++ void OnInfo(OHOS::NWeb::PlayerOnInfoType type, int32_t extra) override; + + private: + scoped_refptr task_runner_; +diff --git a/src/media/base/ohos/ohos_media_player_listener.cc b/src/media/base/ohos/ohos_media_player_listener.cc +index 5e2e5db8770..3f33446b271 +--- a/src/media/base/ohos/ohos_media_player_listener.cc ++++ b/src/media/base/ohos/ohos_media_player_listener.cc +@@ -4,45 +4,23 @@ + + #include "media/base/ohos/ohos_media_player_listener.h" + +-#include + namespace media { + + OHOSMediaPlayerListener::OHOSMediaPlayerListener( + const scoped_refptr& task_runner, +- base::WeakPtr media_player, +- OHOS::sptr impl) +- : task_runner_(task_runner), media_player_(media_player), surface_(impl) { ++ base::WeakPtr media_player) ++ : task_runner_(task_runner), media_player_(media_player) { + DCHECK(task_runner_.get()); + DCHECK(media_player_); + } + + OHOSMediaPlayerListener::~OHOSMediaPlayerListener() {} + +-void OHOSMediaPlayerListener::OnBufferAvailable() { +- OHOS::sptr buffer; +- int32_t fence; +- OHOS::SurfaceError ret; +- auto surface_temp = surface_.promote(); +- if (surface_temp == nullptr) { +- LOG(ERROR) << "surface is null"; +- return; +- } +- +- ret = surface_temp->AcquireBuffer(buffer, fence, timestamp, damage); +- if (ret != OHOS::SURFACE_ERROR_OK) { +- LOG(ERROR) << "acquire buffer fail, ret=" << ret; +- return; +- } +- +- if (buffer->GetFormat() == PIXEL_FMT_RGBA_8888 || +- buffer->GetFormat() == PIXEL_FMT_YCBCR_420_SP) { +- task_runner_->PostTask( +- FROM_HERE, base::BindOnce(&OHOSMediaPlayerBridge::OnBufferAvailable, +- media_player_, buffer)); +- } else { +- LOG(ERROR) << "Unsupport format for:" << buffer->GetFormat(); +- surface_temp->ReleaseBuffer(buffer, -1); +- } ++void OHOSMediaPlayerListener::OnBufferAvailable( ++ std::unique_ptr buffer) { ++ task_runner_->PostTask( ++ FROM_HERE, base::BindOnce(&OHOSMediaPlayerBridge::OnBufferAvailable, ++ media_player_, std::move(buffer))); + } + + } // namespace media +diff --git a/src/media/base/ohos/ohos_media_player_listener.h b/src/media/base/ohos/ohos_media_player_listener.h +index b179af1d605..dfc8943a1da +--- a/src/media/base/ohos/ohos_media_player_listener.h ++++ b/src/media/base/ohos/ohos_media_player_listener.h +@@ -5,7 +5,6 @@ + #ifndef MEDIA_BASE_OHOS_MEDIA_PLAYER_LISTENER_H_ + #define MEDIA_BASE_OHOS_MEDIA_PLAYER_LISTENER_H_ + +-#include + #include "base/logging.h" + #include "base/task/single_thread_task_runner.h" + #include "media/base/ohos/ohos_media_player_bridge.h" +@@ -18,25 +17,21 @@ namespace media { + + class OHOSMediaPlayerBridge; + +-class OHOSMediaPlayerListener : public OHOS::IBufferConsumerListener { ++class OHOSMediaPlayerListener : public OHOS::NWeb::IBufferConsumerListenerAdapter { + public: + OHOSMediaPlayerListener( + const scoped_refptr& task_runner, +- base::WeakPtr media_player, +- OHOS::sptr impl); ++ base::WeakPtr media_player); + + OHOSMediaPlayerListener(const OHOSMediaPlayerListener&) = delete; + OHOSMediaPlayerListener& operator=(const OHOSMediaPlayerListener&) = delete; + + virtual ~OHOSMediaPlayerListener(); +- void OnBufferAvailable() override; ++ void OnBufferAvailable(std::unique_ptr buffer) override; + + private: + scoped_refptr task_runner_; + base::WeakPtr media_player_; +- OHOS::wptr surface_; +- int64_t timestamp; +- OHOS::Rect damage; + }; + + } // namespace media +diff --git a/src/media/filters/ffmpeg_demuxer.cc b/src/media/filters/ffmpeg_demuxer.cc +index bec86bb8ed6..7b7bf4583c3 +--- a/src/media/filters/ffmpeg_demuxer.cc ++++ b/src/media/filters/ffmpeg_demuxer.cc +@@ -1239,7 +1239,7 @@ void FFmpegDemuxer::OnOpenContextDone(bool result) { + return; + } + +-#if BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + if (glue_->detected_hls()) { + MEDIA_LOG(INFO, media_log_) + << GetDisplayName() << ": detected HLS manifest"; +diff --git a/src/media/video/gpu_memory_buffer_video_frame_pool.cc b/src/media/video/gpu_memory_buffer_video_frame_pool.cc +index d86f49a0ba7..12808ae0e7f +--- a/src/media/video/gpu_memory_buffer_video_frame_pool.cc ++++ b/src/media/video/gpu_memory_buffer_video_frame_pool.cc +@@ -707,6 +707,10 @@ void GpuMemoryBufferVideoFramePool::PoolImpl::CreateHardwareFrame( + scoped_refptr video_frame, + FrameReadyCB frame_ready_cb) { + DCHECK(media_task_runner_->BelongsToCurrentThread()); ++#if BUILDFLAG(IS_OHOS) ++ std::move(frame_ready_cb).Run(std::move(video_frame)); ++ return; ++#else + // Lazily initialize |output_format_| since VideoFrameOutputFormat() has to be + // called on the media_thread while this object might be instantiated on any. + const VideoPixelFormat pixel_format = video_frame->format(); +@@ -801,6 +805,7 @@ void GpuMemoryBufferVideoFramePool::PoolImpl::CreateHardwareFrame( + std::move(frame_ready_cb), passthrough); + if (frame_copy_requests_.size() == 1u) + StartCopy(); ++#endif + } + + bool GpuMemoryBufferVideoFramePool::PoolImpl::OnMemoryDump( +diff --git a/src/mojo/core/broker_host.cc b/src/mojo/core/broker_host.cc +index 2fd3728c740..9609beaf194 +--- a/src/mojo/core/broker_host.cc ++++ b/src/mojo/core/broker_host.cc +@@ -124,7 +124,7 @@ void BrokerHost::OnBufferRequest(uint32_t num_bytes) { + ExtractPlatformHandlesFromSharedMemoryRegionHandle( + region.PassPlatformHandle(), &h[0], &h[1]); + handles.emplace_back(std::move(h[0])); +-#if !BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_MAC) ++#if !BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_OHOS) + // Non-POSIX systems, as well as Android and Mac, only use a single handle + // to represent a writable region. + DCHECK(!h[1].is_valid()); +diff --git a/src/mojo/core/broker_posix.cc b/src/mojo/core/broker_posix.cc +index 07a4bc16388..adc9dd73131 +--- a/src/mojo/core/broker_posix.cc ++++ b/src/mojo/core/broker_posix.cc +@@ -115,7 +115,7 @@ base::WritableSharedMemoryRegion Broker::GetWritableSharedMemoryRegion( + return base::WritableSharedMemoryRegion(); + } + +-#if !BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_MAC) ++#if !BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_OHOS) + // Non-POSIX systems, as well as Android and Mac, only use a single handle to + // represent a writable region. + constexpr size_t kNumExpectedHandles = 1; +diff --git a/src/mojo/core/core.cc b/src/mojo/core/core.cc +index 8390a2d9a26..056f78ef397 +--- a/src/mojo/core/core.cc ++++ b/src/mojo/core/core.cc +@@ -22,6 +22,8 @@ + #include "base/threading/thread_task_runner_handle.h" + #include "base/time/time.h" + #include "base/trace_event/memory_dump_manager.h" ++#include "base/trace_event/trace_event.h" ++#include "base/trace_event/typed_macros.h" + #include "build/build_config.h" + #include "mojo/core/channel.h" + #include "mojo/core/configuration.h" +@@ -641,6 +643,8 @@ MojoResult Core::CreateDataPipe(const MojoCreateDataPipeOptions* options, + return MOJO_RESULT_INVALID_ARGUMENT; + } + ++ TRACE_EVENT("loading", "mojo::Core::CreateDataPipe", "capcaticy", create_options.element_num_bytes); ++ + base::subtle::PlatformSharedMemoryRegion ring_buffer_region = + base::WritableSharedMemoryRegion::TakeHandleForSerialization( + GetNodeController()->CreateSharedBuffer( +@@ -652,7 +656,7 @@ MojoResult Core::CreateDataPipe(const MojoCreateDataPipeOptions* options, + // consumer of this pipe, and it would be impossible to support such access + // control on Android anyway. + auto writable_region_handle = ring_buffer_region.PassPlatformHandle(); +-#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC) ++#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_OHOS) + // This isn't strictly necessary, but it does make the handle configuration + // consistent with regular UnsafeSharedMemoryRegions. + writable_region_handle.readonly_fd.reset(); +@@ -1015,7 +1019,7 @@ MojoResult Core::WrapPlatformSharedMemoryRegion( + MojoHandle* mojo_handle) { + DCHECK(size); + +-#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC) ++#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_OHOS) + if (access_mode == MOJO_PLATFORM_SHARED_MEMORY_REGION_ACCESS_MODE_WRITABLE) { + if (num_platform_handles != 2) + return MOJO_RESULT_INVALID_ARGUMENT; +@@ -1135,7 +1139,7 @@ MojoResult Core::UnwrapPlatformSharedMemoryRegion( + if (available_handle_storage_slots < 1) + return MOJO_RESULT_RESOURCE_EXHAUSTED; + *num_platform_handles = 1; +-#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC) ++#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_OHOS) + if (region.GetMode() == + base::subtle::PlatformSharedMemoryRegion::Mode::kWritable) { + if (available_handle_storage_slots < 2) +diff --git a/src/mojo/core/platform_handle_utils.cc b/src/mojo/core/platform_handle_utils.cc +index a446a74e354..3a069d80a27 +--- a/src/mojo/core/platform_handle_utils.cc ++++ b/src/mojo/core/platform_handle_utils.cc +@@ -36,7 +36,7 @@ void ExtractPlatformHandlesFromSharedMemoryRegionHandle( + // This is a Mach port. Same code as above and below, but separated for + // clarity. + *extracted_handle = PlatformHandle(std::move(handle)); +-#elif BUILDFLAG(IS_ANDROID) ++#elif BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + // This is a file descriptor. Same code as above, but separated for clarity. + *extracted_handle = PlatformHandle(std::move(handle)); + #else +@@ -58,7 +58,7 @@ CreateSharedMemoryRegionHandleFromPlatformHandles( + #elif BUILDFLAG(IS_MAC) + DCHECK(!readonly_handle.is_valid()); + return handle.TakeMachSendRight(); +-#elif BUILDFLAG(IS_ANDROID) ++#elif BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + DCHECK(!readonly_handle.is_valid()); + return handle.TakeFD(); + #else +diff --git a/src/mojo/core/shared_buffer_dispatcher.cc b/src/mojo/core/shared_buffer_dispatcher.cc +index dd9afb7f6af..b69c562f5e0 +--- a/src/mojo/core/shared_buffer_dispatcher.cc ++++ b/src/mojo/core/shared_buffer_dispatcher.cc +@@ -145,7 +145,7 @@ scoped_refptr SharedBufferDispatcher::Deserialize( + } + + PlatformHandle handles[2]; +-#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC) ++#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_OHOS) + if (serialized_state->access_mode == + MOJO_PLATFORM_SHARED_MEMORY_REGION_ACCESS_MODE_WRITABLE) { + if (num_platform_handles != 2) +@@ -258,7 +258,7 @@ MojoResult SharedBufferDispatcher::DuplicateBufferHandle( + } else if (region_.GetMode() == + base::subtle::PlatformSharedMemoryRegion::Mode::kWritable) { + auto handle = region_.PassPlatformHandle(); +-#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC) ++#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_OHOS) + // On POSIX systems excluding Android, Fuchsia, and OSX, we explicitly + // wipe out the secondary (read-only) FD from the platform handle to + // repurpose it for exclusive unsafe usage. +@@ -318,7 +318,7 @@ void SharedBufferDispatcher::StartSerialize(uint32_t* num_bytes, + *num_bytes = sizeof(SerializedState); + *num_ports = 0; + *num_platform_handles = 1; +-#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC) ++#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_OHOS) + if (region_.GetMode() == + base::subtle::PlatformSharedMemoryRegion::Mode::kWritable) { + *num_platform_handles = 2; +@@ -357,7 +357,7 @@ bool SharedBufferDispatcher::EndSerialize(void* destination, + serialized_state->padding = 0; + + auto region = std::move(region_); +-#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC) ++#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_OHOS) + if (region.GetMode() == + base::subtle::PlatformSharedMemoryRegion::Mode::kWritable) { + PlatformHandle platform_handles[2]; +diff --git a/src/mojo/public/cpp/system/platform_handle.cc b/src/mojo/public/cpp/system/platform_handle.cc +index 426b1578137..aa7cbb3d5e8 +--- a/src/mojo/public/cpp/system/platform_handle.cc ++++ b/src/mojo/public/cpp/system/platform_handle.cc +@@ -69,7 +69,7 @@ ScopedSharedBufferHandle WrapPlatformSharedMemoryRegion( + #elif BUILDFLAG(IS_MAC) + platform_handles[0].type = MOJO_PLATFORM_HANDLE_TYPE_MACH_PORT; + platform_handles[0].value = static_cast(handle.release()); +-#elif BUILDFLAG(IS_ANDROID) ++#elif BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + platform_handles[0].type = MOJO_PLATFORM_HANDLE_TYPE_FILE_DESCRIPTOR; + platform_handles[0].value = static_cast(handle.release()); + #else +@@ -134,7 +134,7 @@ base::subtle::PlatformSharedMemoryRegion UnwrapPlatformSharedMemoryRegion( + if (platform_handles[0].type != MOJO_PLATFORM_HANDLE_TYPE_MACH_PORT) + return base::subtle::PlatformSharedMemoryRegion(); + region_handle.reset(static_cast(platform_handles[0].value)); +-#elif BUILDFLAG(IS_ANDROID) ++#elif BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) + if (num_platform_handles != 1) + return base::subtle::PlatformSharedMemoryRegion(); + if (platform_handles[0].type != MOJO_PLATFORM_HANDLE_TYPE_FILE_DESCRIPTOR) +diff --git a/src/net/BUILD.gn b/src/net/BUILD.gn +index 4d66045a051..f4c1a2e3fec +--- a/src/net/BUILD.gn ++++ b/src/net/BUILD.gn +@@ -1179,6 +1179,8 @@ component("net") { + sources += [ + "cert/cert_verify_proc_ohos.cc", + "cert/cert_verify_proc_ohos.h", ++ "proxy_resolution/proxy_config_service_ohos.cc", ++ "proxy_resolution/proxy_config_service_ohos.h", + ] + } + +diff --git a/src/net/base/file_stream_context.cc b/src/net/base/file_stream_context.cc +index fabb36e39cf..029ce712dba +--- a/src/net/base/file_stream_context.cc ++++ b/src/net/base/file_stream_context.cc +@@ -21,6 +21,10 @@ + #include "base/android/content_uri_utils.h" + #endif + ++#if BUILDFLAG(IS_OHOS) ++#include "base/datashare_uri_utils.h" ++#endif ++ + namespace net { + + namespace { +@@ -173,6 +177,11 @@ FileStream::Context::OpenResult FileStream::Context::OpenFileImpl( + file = base::OpenContentUriForRead(path); + } else { + #endif // BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_OHOS) ++ if (path.IsDataShareUri()) { ++ file = base::OpenDatashareUriForRead(path); ++ } else { ++#endif + // FileStream::Context actually closes the file asynchronously, + // independently from FileStream's destructor. It can cause problems for + // users wanting to delete the file right after FileStream deletion. Thus +@@ -184,6 +193,9 @@ FileStream::Context::OpenResult FileStream::Context::OpenFileImpl( + #if BUILDFLAG(IS_ANDROID) + } + #endif // BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(IS_OHOS) ++ } ++#endif // BUILDFLAG(IS_OHOS) + if (!file.IsValid()) { + return OpenResult(base::File(), + IOResult::FromOSError(logging::GetLastSystemErrorCode())); +diff --git a/src/net/cert/cert_verify_proc_ohos.cc b/src/net/cert/cert_verify_proc_ohos.cc +index 1ef0335a116..3f983c0b883 +--- a/src/net/cert/cert_verify_proc_ohos.cc ++++ b/src/net/cert/cert_verify_proc_ohos.cc +@@ -2,10 +2,15 @@ + // Use of this source code is governed by a BSD-style license that can be + // found in the LICENSE file. + ++#include ++#include + #include + #include + #include ++ ++#include "base/command_line.h" + #include "base/logging.h" ++#include "content/public/common/content_switches.h" + #include "crypto/sha2.h" + #include "net/cert/asn1_util.h" + #include "net/cert/cert_net_fetcher.h" +@@ -16,6 +21,7 @@ + #include "net/cert/known_roots.h" + #include "net/cert/x509_certificate.h" + #include "net/cert/x509_util.h" ++#include "ohos_adapter_helper.h" + #include "openssl/err.h" + #include "openssl/ossl_typ.h" + #include "openssl/x509.h" +@@ -25,6 +31,8 @@ + + #define ROOT_CERT "/etc/ssl/certs/cacert.pem" + #define MIN_CERT_NUM 1 ++#define DER_ENCODED 0x30 ++constexpr int32_t APPLICATION_API_10 = 10; + namespace net { + // OH ignores the authType parameter to + // X509TrustManager.checkServerTrusted, so pass in a dummy value. See +@@ -55,9 +63,84 @@ void X509_d2i_free(X509* server_cert[], uint32_t server_cert_sum) { + } + } + ++X509* p2i_X509(const char *pem) { ++ BIO* bio = BIO_new_mem_buf(pem, strlen(pem)); ++ if (!bio) { ++ LOG(ERROR) << "Create x509 from PEM, BIO new memory buffer failed"; ++ return nullptr; ++ } ++ auto x509 = PEM_read_bio_X509(bio, nullptr, nullptr, nullptr); ++ if (x509 == nullptr) { ++ LOG(ERROR) << "Create x509 from PEM, x509 is null"; ++ BIO_free(bio); ++ return nullptr; ++ } ++ BIO_free(bio); ++ ++ return x509; ++} ++ ++int32_t GetApplicationApiVersion() { ++ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kOhosAppApiVersion)) { ++ LOG(ERROR) << "kOhosAppApiVersion not exist"; ++ return -1; ++ } ++ std::string apiVersion = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( ++ switches::kOhosAppApiVersion); ++ if (apiVersion.empty()) { ++ return -1; ++ } ++ return std::stoi(apiVersion); ++} ++ ++int GetVerifiedChain(X509_STORE_CTX* ctx, std::vector* verified_chain) { ++ uint8_t* cert_der = nullptr; ++ uint8_t* buf = nullptr; ++ X509* x509 = nullptr; ++ int cert_len = 0; ++ ++ verified_chain->reserve(1 + sk_X509_num(ctx->chain)); ++ for (unsigned long i = 0; i < sk_X509_num(ctx->chain); i++) { ++ x509 = sk_X509_value(ctx->chain, i); ++ cert_len = i2d_X509(x509, nullptr); ++ if (cert_len <= 0) { ++ LOG(ERROR) << "I2d_X509 get cert length, cert length is less than or equal to 0"; ++ return X509_V_ERR_UNSPECIFIED; ++ } ++ ++ buf = (uint8_t*)OPENSSL_malloc(cert_len); ++ if (buf == nullptr) { ++ LOG(ERROR) << "OPENSSL_malloc failed"; ++ return X509_V_ERR_UNSPECIFIED; ++ } ++ ++ // The buf pointer of the i2d_X509 function changed during the conversion process, ++ // and finally changed to buf = cert_der + cert_len; ++ cert_der = buf; ++ i2d_X509(x509, &buf); ++ ++ auto cert_der_span = base::make_span(cert_der, cert_len); ++ bssl::UniquePtr cert_buffer = net::x509_util::CreateCryptoBuffer(cert_der_span); ++ if (cert_buffer == nullptr) { ++ LOG(ERROR) << "Cert buffer is nullptr"; ++ OPENSSL_free(cert_der); ++ return X509_V_ERR_UNSPECIFIED; ++ } ++ ++ verified_chain->emplace_back(net::x509_util::CryptoBufferAsStringPiece(cert_buffer.get())); ++ ++ OPENSSL_free(cert_der); ++ cert_der = nullptr; ++ buf = nullptr; ++ } ++ ++ return X509_V_OK; ++} ++ + int CertChainVerify(X509* server_cert[], + int32_t server_cert_sum, +- X509_STORE* ca_store) { ++ X509_STORE* ca_store, ++ std::vector* verified_chain) { + uint32_t i; + STACK_OF(X509)* ca_stack = nullptr; + X509_STORE_CTX* ctx = nullptr; +@@ -92,6 +175,14 @@ int CertChainVerify(X509* server_cert[], + return error; + } + ++ if (GetVerifiedChain(ctx, verified_chain) != X509_V_OK) { ++ LOG(ERROR) << "Get verified chain failed"; ++ X509_d2i_free(server_cert, server_cert_sum); ++ X509_STORE_CTX_free(ctx); ++ X509_STORE_free(ca_store); ++ return X509_V_ERR_UNSPECIFIED; ++ } ++ + X509_STORE_CTX_free(ctx); + X509_d2i_free(server_cert, server_cert_sum); + X509_STORE_free(ca_store); +@@ -99,7 +190,7 @@ int CertChainVerify(X509* server_cert[], + return X509_V_OK; + } + +-int CertVerify(const std::vector& cert_bytes) { ++int CertVerify(const std::vector& cert_bytes, std::vector* verified_chain) { + uint32_t server_cert_sum; + const unsigned char* der_encoded_tmp = nullptr; + uint32_t i; +@@ -139,6 +230,9 @@ int CertVerify(const std::vector& cert_bytes) { + return X509_V_ERR_UNSPECIFIED; + } + ++ // Allow partial chains if at least one certificate is in trusted store ++ X509_STORE_set_flags(ca_store, X509_V_FLAG_PARTIAL_CHAIN); ++ + // Create X509_LOOKUP, the store_ctx member of this data structure is + // associated with the newly created certificate store ca_store + look_up = X509_STORE_add_lookup(ca_store, X509_LOOKUP_file()); +@@ -159,7 +253,55 @@ int CertVerify(const std::vector& cert_bytes) { + return X509_V_ERR_UNSPECIFIED; + } + +- return CertChainVerify(server_cert, server_cert_sum, ca_store); ++ // Add user cert to ca store ++ if (GetApplicationApiVersion() >= APPLICATION_API_10) { ++ X509* certTmp = nullptr; ++ auto RootCertDataAdapter = OHOS::NWeb::OhosAdapterHelper::GetInstance().GetRootCertDataAdapter(); ++ if (RootCertDataAdapter == nullptr) { ++ LOG(ERROR) << "Get cert info from cert manager, root cert data adapter is null"; ++ return X509_V_ERR_UNSPECIFIED; ++ } ++ auto certMaxSize = RootCertDataAdapter->GetCertMaxSize(); ++ uint8_t* certData = static_cast(malloc(certMaxSize)); ++ if (!certData) { ++ LOG(ERROR) << "Get cert info from cert manager, malloc cert store failed"; ++ return X509_V_ERR_UNSPECIFIED; ++ } ++ ++ auto userRootCertSum = RootCertDataAdapter->GetUserRootCertSum(); ++ for (i = 0; i < userRootCertSum; i++) { ++ memset(certData, 0, certMaxSize); ++ RootCertDataAdapter->GetUserRootCertData(i, certData); ++ if (*certData == DER_ENCODED) { ++ der_encoded_tmp = certData; ++ certTmp = d2i_X509(nullptr, &der_encoded_tmp, certMaxSize); ++ if (!certTmp) { ++ LOG(ERROR) << "Get cert info from cert manager, user cert der convert to X509 failed, user cert count = " << i; ++ continue; ++ } ++ } else if (*certData == '-') { ++ certTmp = p2i_X509((char*)certData); ++ if (!certTmp) { ++ LOG(ERROR) << "Get cert info from cert manager, user cert pem convert to X509 failed, user cert count = " << i; ++ continue; ++ } ++ } else { ++ LOG(ERROR) << "Get cert info from cert manager, cert format error, user cert count = " << i; ++ continue; ++ } ++ ++ auto ret = X509_STORE_add_cert(ca_store, certTmp); ++ if (!ret) { ++ LOG(ERROR) << "Get cert info from cert manager, add user cert to X509 store failed, ret = " ++ << ret << ", user cert count = " << i; ++ continue; ++ } ++ } ++ X509_free(certTmp); ++ free(certData); ++ } ++ ++ return CertChainVerify(server_cert, server_cert_sum, ca_store, verified_chain); + } + + // Starting at certs[start], this function searches |certs| for an issuer of +@@ -248,9 +390,7 @@ void X509CertChainVerify(const std::vector& cert_chain, + std::vector* verified_chain) { + *is_issued_by_known_root = false; + +- *status = CertVerify(cert_chain); +- +- verified_chain->assign(cert_chain.begin(), cert_chain.end()); ++ *status = CertVerify(cert_chain, verified_chain); + } + + // Uses X509CertChainVerify() to verify the certificates in |certs| for +diff --git a/src/net/http/http_network_session.cc b/src/net/http/http_network_session.cc +index a22f163deb9..f68672530e8 +--- a/src/net/http/http_network_session.cc ++++ b/src/net/http/http_network_session.cc +@@ -432,4 +432,11 @@ void HttpNetworkSession::OnMemoryPressure( + } + } + ++#if BUILDFLAG(IS_OHOS) ++void HttpNetworkSession::SetConnectTimeout(int seconds) { ++ normal_socket_pool_manager_->SetConnectTimeout(seconds); ++ websocket_socket_pool_manager_->SetConnectTimeout(seconds); ++} ++#endif ++ + } // namespace net +diff --git a/src/net/http/http_network_session.h b/src/net/http/http_network_session.h +index b0f82e9602f..0090404e211 +--- a/src/net/http/http_network_session.h ++++ b/src/net/http/http_network_session.h +@@ -296,6 +296,10 @@ class NET_EXPORT HttpNetworkSession { + CommonConnectJobParams CreateCommonConnectJobParams( + bool for_websockets = false); + ++#if BUILDFLAG(IS_OHOS) ++ void SetConnectTimeout(int seconds); ++#endif ++ + private: + friend class HttpNetworkSessionPeer; + +diff --git a/src/net/http/http_proxy_connect_job.cc b/src/net/http/http_proxy_connect_job.cc +index aa92b63bc33..dedd609f2c5 +--- a/src/net/http/http_proxy_connect_job.cc ++++ b/src/net/http/http_proxy_connect_job.cc +@@ -445,6 +445,9 @@ int HttpProxyConnectJob::DoTransportConnect() { + nested_connect_job_ = TransportConnectJob::CreateTransportConnectJob( + params_->transport_params(), priority(), socket_tag(), + common_connect_job_params(), this, &net_log()); ++#if BUILDFLAG(IS_OHOS) ++ nested_connect_job_->SetConnectTimeout(timeout_override_for_nested_job_); ++#endif + } else { + DCHECK_EQ(scheme, ProxyServer::SCHEME_HTTPS); + DCHECK(params_->ssl_params()); +@@ -824,4 +827,11 @@ SpdySessionKey HttpProxyConnectJob::CreateSpdySessionKey() const { + params_->ssl_params()->GetDirectConnectionParams()->secure_dns_policy()); + } + ++#if BUILDFLAG(IS_OHOS) ++void HttpProxyConnectJob::SetConnectTimeout(int timeout_override) { ++ timeout_override_for_nested_job_ = timeout_override; ++ timeout_override_ = base::TimeDelta(); ++} ++#endif ++ + } // namespace net +diff --git a/src/net/http/http_proxy_connect_job.h b/src/net/http/http_proxy_connect_job.h +index 732c28cb1e8..53fbcc382a9 +--- a/src/net/http/http_proxy_connect_job.h ++++ b/src/net/http/http_proxy_connect_job.h +@@ -152,6 +152,10 @@ class NET_EXPORT_PRIVATE HttpProxyConnectJob : public ConnectJob, + // Updates the field trial parameters used in calculating timeouts. + static void UpdateFieldTrialParametersForTesting(); + ++#if BUILDFLAG(IS_OHOS) ++ void SetConnectTimeout(int timeout_override) override; ++#endif ++ + private: + enum State { + STATE_BEGIN_CONNECT, +@@ -250,6 +254,11 @@ class NET_EXPORT_PRIVATE HttpProxyConnectJob : public ConnectJob, + // Time when the connection to the proxy was started. + base::TimeTicks connect_start_time_; + ++#if BUILDFLAG(IS_OHOS) ++ // Only for transport_connect_job ++ int timeout_override_for_nested_job_{0}; ++#endif ++ + base::WeakPtrFactory weak_ptr_factory_{this}; + }; + +diff --git a/src/net/proxy_resolution/proxy_config_service_ohos.cc b/src/net/proxy_resolution/proxy_config_service_ohos.cc +new file mode 100644 +index 00000000000..4380758551b +--- /dev/null ++++ b/src/net/proxy_resolution/proxy_config_service_ohos.cc +@@ -0,0 +1,495 @@ ++/* ++ * Copyright (c) 2023 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 ++ * ++ * 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, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++#include "net/proxy_resolution/proxy_config_service_ohos.h" ++ ++#include "base/bind.h" ++#include "base/callback.h" ++#include "base/check_op.h" ++#include "base/compiler_specific.h" ++#include "base/location.h" ++#include "base/logging.h" ++#include "base/memory/raw_ptr.h" ++#include "base/memory/ref_counted.h" ++#include "base/observer_list.h" ++#include "base/strings/string_tokenizer.h" ++#include "base/strings/string_util.h" ++#include "base/strings/stringprintf.h" ++#include "base/task/sequenced_task_runner.h" ++#include "net/base/host_port_pair.h" ++#include "net/base/proxy_server.h" ++#include "net/base/proxy_string_util.h" ++#include "net/proxy_resolution/proxy_config_with_annotation.h" ++#include "url/third_party/mozilla/url_parse.h" ++ ++namespace net { ++ ++namespace { ++ ++typedef ProxyConfigServiceOHOS::GetPropertyCallback GetPropertyCallback; ++ ++// Returns whether the provided string was successfully converted to a port. ++bool ConvertStringToPort(const std::string& port, int* output) { ++ url::Component component(0, port.size()); ++ int result = url::ParsePort(port.c_str(), component); ++ if (result == url::PORT_INVALID || result == url::PORT_UNSPECIFIED) ++ return false; ++ *output = result; ++ return true; ++} ++ ++ProxyServer ConstructProxyServer(ProxyServer::Scheme scheme, ++ const std::string& proxy_host, ++ const std::string& proxy_port) { ++ DCHECK(!proxy_host.empty()); ++ int port_as_int = 0; ++ if (proxy_port.empty()) ++ port_as_int = ProxyServer::GetDefaultPortForScheme(scheme); ++ else if (!ConvertStringToPort(proxy_port, &port_as_int)) ++ return ProxyServer(); ++ DCHECK(port_as_int > 0); ++ return ProxyServer( ++ scheme, HostPortPair(proxy_host, static_cast(port_as_int))); ++} ++ ++ProxyServer LookupProxy(const std::string& prefix, ++ const GetPropertyCallback& get_property, ++ ProxyServer::Scheme scheme) { ++ DCHECK(!prefix.empty()); ++ std::string proxy_host = get_property.Run(prefix + ".proxyHost"); ++ if (!proxy_host.empty()) { ++ std::string proxy_port = get_property.Run(prefix + ".proxyPort"); ++ return ConstructProxyServer(scheme, proxy_host, proxy_port); ++ } ++ ++ // Fall back to default proxy, if any. ++ proxy_host = get_property.Run("proxyHost"); ++ if (!proxy_host.empty()) { ++ std::string proxy_port = get_property.Run("proxyPort"); ++ return ConstructProxyServer(scheme, proxy_host, proxy_port); ++ } ++ return ProxyServer(); ++} ++ ++ProxyServer LookupSocksProxy(const GetPropertyCallback& get_property) { ++ std::string proxy_host = get_property.Run("socksProxyHost"); ++ if (!proxy_host.empty()) { ++ std::string proxy_port = get_property.Run("socksProxyPort"); ++ return ConstructProxyServer(ProxyServer::SCHEME_SOCKS5, proxy_host, ++ proxy_port); ++ } ++ return ProxyServer(); ++} ++ ++void AddBypassRules(const std::string& scheme, ++ const GetPropertyCallback& get_property, ++ ProxyBypassRules* bypass_rules) { ++ // The format of a hostname pattern is a list of hostnames that are separated ++ // by | and that use * as a wildcard. For example, setting the ++ // http.nonProxyHosts property to *.huawei.com|*.kernel.org will cause ++ // requests to http://developer.huawei.com to be made without a proxy. ++ std::string non_proxy_hosts = ++ get_property.Run(scheme + ".nonProxyHosts"); ++ if (non_proxy_hosts.empty()) ++ return; ++ base::StringTokenizer tokenizer(non_proxy_hosts, ","); ++ while (tokenizer.GetNext()) { ++ std::string token = tokenizer.token(); ++ std::string pattern; ++ base::TrimWhitespaceASCII(token, base::TRIM_ALL, &pattern); ++ if (pattern.empty()) ++ continue; ++ // '?' is not one of the specified pattern characters above. ++ DCHECK_EQ(std::string::npos, pattern.find('?')); ++ bypass_rules->AddRuleFromString(scheme + "://" + pattern); ++ } ++} ++ ++// Returns true if a valid proxy was found. ++bool GetProxyRules(const GetPropertyCallback& get_property, ++ ProxyConfig::ProxyRules* rules) { ++ // There is one intentional difference: by default Chromium uses the HTTP port (80) ++ // for HTTPS connections via proxy. This default is identical on other platforms. ++ // On the opposite, Java spec suggests to use HTTPS port (443) by default (the ++ // default value of https.proxyPort). ++ rules->type = ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME; ++ rules->proxies_for_http.SetSingleProxyServer( ++ LookupProxy("http", get_property, ProxyServer::SCHEME_HTTP)); ++ rules->proxies_for_https.SetSingleProxyServer( ++ LookupProxy("https", get_property, ProxyServer::SCHEME_HTTP)); ++ rules->proxies_for_ftp.SetSingleProxyServer( ++ LookupProxy("ftp", get_property, ProxyServer::SCHEME_HTTP)); ++ rules->fallback_proxies.SetSingleProxyServer(LookupSocksProxy(get_property)); ++ rules->bypass_rules.Clear(); ++ AddBypassRules("ftp", get_property, &rules->bypass_rules); ++ AddBypassRules("http", get_property, &rules->bypass_rules); ++ AddBypassRules("https", get_property, &rules->bypass_rules); ++ // We know a proxy was found if not all of the proxy lists are empty. ++ return !(rules->proxies_for_http.IsEmpty() && ++ rules->proxies_for_https.IsEmpty() && ++ rules->proxies_for_ftp.IsEmpty() && ++ rules->fallback_proxies.IsEmpty()); ++} ++ ++void GetLatestProxyConfigInternal(const GetPropertyCallback& get_property, ++ ProxyConfigWithAnnotation* config) { ++ ProxyConfig proxy_config; ++ proxy_config.set_from_system(true); ++ if (GetProxyRules(get_property, &proxy_config.proxy_rules())) { ++ *config = ++ ProxyConfigWithAnnotation(proxy_config, MISSING_TRAFFIC_ANNOTATION); ++ } else { ++ *config = ProxyConfigWithAnnotation::CreateDirect(); ++ } ++} ++ ++std::string GetProperty(const std::string& property) { ++ // Use OH network to get configuration information. ++ std::string host; ++ uint16_t port; ++ std::string exclusion; ++ std::string pac_url; ++ OHOS::NWeb::OhosAdapterHelper::GetInstance() ++ .GetNetProxyInstance().GetProperty(host, port, pac_url, exclusion); ++ ++ if (property == "http.proxyHost" || property == "https.proxyHost") { ++ return host; ++ } else if (property == "http.proxyPort" || property == "https.proxyPort") { ++ return std::to_string(port); ++ } else if (property == "http.nonProxyHosts" || property == "https.nonProxyHosts") { ++ return exclusion; ++ } ++ ++ return std::string(); ++} ++ ++void CreateStaticProxyConfig(const std::string& host, ++ int port, ++ const std::string& pac_url, ++ const std::vector& exclusion_list, ++ ProxyConfigWithAnnotation* config) { ++ ProxyConfig proxy_config; ++ if (!pac_url.empty()) { ++ proxy_config.set_pac_url(GURL(pac_url)); ++ proxy_config.set_pac_mandatory(false); ++ *config = ++ ProxyConfigWithAnnotation(proxy_config, MISSING_TRAFFIC_ANNOTATION); ++ } else if (port != 0) { ++ std::string rules = base::StringPrintf("%s:%d", host.c_str(), port); ++ proxy_config.proxy_rules().ParseFromString(rules); ++ proxy_config.proxy_rules().bypass_rules.Clear(); ++ ++ std::vector::const_iterator it; ++ for (it = exclusion_list.begin(); it != exclusion_list.end(); ++it) { ++ std::string pattern; ++ base::TrimWhitespaceASCII(*it, base::TRIM_ALL, &pattern); ++ if (pattern.empty()) ++ continue; ++ proxy_config.proxy_rules().bypass_rules.AddRuleFromString(pattern); ++ } ++ *config = ++ ProxyConfigWithAnnotation(proxy_config, MISSING_TRAFFIC_ANNOTATION); ++ } else { ++ *config = ProxyConfigWithAnnotation::CreateDirect(); ++ } ++} ++ ++std::string ParseOverrideRules( ++ const std::vector& ++ override_rules, ++ ProxyConfig::ProxyRules* proxy_rules) { ++ // If no rules were specified, use DIRECT for everything. ++ if (override_rules.empty()) { ++ DCHECK(proxy_rules->empty()); ++ return ""; ++ } ++ ++ // Otherwise use a proxy list per URL scheme. ++ proxy_rules->type = ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME; ++ ++ for (const auto& rule : override_rules) { ++ // Parse the proxy URL. ++ ProxyServer proxy_server = ++ ProxyUriToProxyServer(rule.proxy_url, ProxyServer::Scheme::SCHEME_HTTP); ++ if (!proxy_server.is_valid()) { ++ return "Invalid Proxy URL: " + rule.proxy_url; ++ } else if (proxy_server.is_quic()) { ++ return "Unsupported proxy scheme: " + rule.proxy_url; ++ } ++ ++ // Parse the URL scheme. ++ if (base::EqualsCaseInsensitiveASCII(rule.url_scheme, "http")) { ++ proxy_rules->proxies_for_http.AddProxyServer(proxy_server); ++ } else if (base::EqualsCaseInsensitiveASCII(rule.url_scheme, "https")) { ++ proxy_rules->proxies_for_https.AddProxyServer(proxy_server); ++ } else if (rule.url_scheme == "*") { ++ proxy_rules->fallback_proxies.AddProxyServer(proxy_server); ++ } else { ++ return "Unsupported URL scheme: " + rule.url_scheme; ++ } ++ } ++ ++ // If there is no per-URL scheme distinction simplify the ProxyRules. ++ if (proxy_rules->proxies_for_http.IsEmpty() && ++ proxy_rules->proxies_for_https.IsEmpty() && ++ !proxy_rules->fallback_proxies.IsEmpty()) { ++ proxy_rules->type = ProxyConfig::ProxyRules::Type::PROXY_LIST; ++ std::swap(proxy_rules->single_proxies, proxy_rules->fallback_proxies); ++ } ++ ++ return ""; ++} ++ ++std::string CreateOverrideProxyConfig( ++ const std::vector& ++ proxy_rules, ++ const std::vector& bypass_rules, ++ const bool reverse_bypass, ++ ProxyConfigWithAnnotation* config) { ++ ProxyConfig proxy_config; ++ auto result = ParseOverrideRules(proxy_rules, &proxy_config.proxy_rules()); ++ if (!result.empty()) { ++ return result; ++ } ++ ++ proxy_config.proxy_rules().reverse_bypass = reverse_bypass; ++ ++ for (const auto& bypass_rule : bypass_rules) { ++ if (!proxy_config.proxy_rules().bypass_rules.AddRuleFromString( ++ bypass_rule)) { ++ return "Invalid bypass rule " + bypass_rule; ++ } ++ } ++ *config = ProxyConfigWithAnnotation(proxy_config, MISSING_TRAFFIC_ANNOTATION); ++ return ""; ++} ++ ++} // namespace ++ ++class ProxyConfigServiceOHOS::Delegate ++ : public base::RefCountedThreadSafe { ++ public: ++ Delegate(const scoped_refptr& main_task_runner, ++ const GetPropertyCallback& get_property_callback) ++ : main_task_runner_(main_task_runner), ++ get_property_callback_(get_property_callback), ++ exclude_pac_url_(false), ++ has_proxy_override_(false) {} ++ ++ Delegate(const Delegate&) = delete; ++ Delegate& operator=(const Delegate&) = delete; ++ ++ void FetchInitialConfig() { ++ ProxyConfigWithAnnotation proxy_config; ++ GetLatestProxyConfigInternal(get_property_callback_, &proxy_config); ++ main_task_runner_->PostTask( ++ FROM_HERE, base::BindOnce(&Delegate::SetNewConfigInMainSequence, this, ++ proxy_config)); ++ } ++ ++ // Called only in the network sequence. ++ void AddObserver(Observer* observer) { ++ DCHECK(InMainSequence()); ++ observers_.AddObserver(observer); ++ } ++ ++ void RemoveObserver(Observer* observer) { ++ DCHECK(InMainSequence()); ++ observers_.RemoveObserver(observer); ++ } ++ ++ ConfigAvailability GetLatestProxyConfig(ProxyConfigWithAnnotation* config) { ++ DCHECK(InMainSequence()); ++ if (!config) ++ return ProxyConfigService::CONFIG_UNSET; ++ *config = proxy_config_; ++ return ProxyConfigService::CONFIG_VALID; ++ } ++ ++ // Called by NWEB adapter. ++ void ProxySettingsChanged() { ++ if (has_proxy_override_) ++ return; ++ ++ ProxyConfigWithAnnotation proxy_config; ++ GetLatestProxyConfigInternal(get_property_callback_, &proxy_config); ++ main_task_runner_->PostTask( ++ FROM_HERE, base::BindOnce(&Delegate::SetNewConfigInMainSequence, this, ++ proxy_config)); ++ } ++ ++ // Called by NWEB adapter. ++ void ProxySettingsChangedTo(const std::string& host, ++ int port, ++ const std::string& pac_url, ++ const std::vector& exclusion_list) { ++ if (has_proxy_override_) ++ return; ++ ++ ProxyConfigWithAnnotation proxy_config; ++ if (exclude_pac_url_) { ++ CreateStaticProxyConfig(host, port, "", exclusion_list, &proxy_config); ++ } else { ++ CreateStaticProxyConfig(host, port, pac_url, exclusion_list, ++ &proxy_config); ++ } ++ main_task_runner_->PostTask( ++ FROM_HERE, base::BindOnce(&Delegate::SetNewConfigInMainSequence, this, ++ proxy_config)); ++ } ++ ++ void set_exclude_pac_url(bool enabled) { ++ exclude_pac_url_ = enabled; ++ } ++ ++ // Called by NWEB adapter. ++ std::string SetProxyOverride( ++ const std::vector& proxy_rules, ++ const std::vector& bypass_rules, ++ const bool reverse_bypass, ++ base::OnceClosure callback) { ++ has_proxy_override_ = true; ++ ++ // Creates a new proxy config ++ ProxyConfigWithAnnotation proxy_config; ++ std::string result = CreateOverrideProxyConfig( ++ proxy_rules, bypass_rules, reverse_bypass, &proxy_config); ++ if (!result.empty()) { ++ return result; ++ } ++ ++ main_task_runner_->PostTaskAndReply( ++ FROM_HERE, ++ base::BindOnce(&Delegate::SetNewConfigInMainSequence, this, ++ proxy_config), ++ std::move(callback)); ++ ++ return ""; ++ } ++ ++ // Called by NWEB adapter. ++ void ClearProxyOverride(base::OnceClosure callback) { ++ if (!has_proxy_override_) { ++ std::move(callback).Run(); ++ return; ++ } ++ ++ ProxyConfigWithAnnotation proxy_config; ++ GetLatestProxyConfigInternal(get_property_callback_, &proxy_config); ++ main_task_runner_->PostTaskAndReply( ++ FROM_HERE, ++ base::BindOnce(&Delegate::SetNewConfigInMainSequence, this, ++ proxy_config), ++ std::move(callback)); ++ has_proxy_override_ = false; ++ } ++ ++ private: ++ friend class base::RefCountedThreadSafe; ++ ++ virtual ~Delegate() {} ++ ++ // Called on the network sequence. ++ void SetNewConfigInMainSequence( ++ const ProxyConfigWithAnnotation& proxy_config) { ++ DCHECK(InMainSequence()); ++ proxy_config_ = proxy_config; ++ for (auto& observer : observers_) { ++ observer.OnProxyConfigChanged(proxy_config, ++ ProxyConfigService::CONFIG_VALID); ++ } ++ } ++ ++ bool InMainSequence() const { ++ return main_task_runner_->RunsTasksInCurrentSequence(); ++ } ++ ++ base::ObserverList::Unchecked observers_; ++ scoped_refptr main_task_runner_; ++ GetPropertyCallback get_property_callback_; ++ ProxyConfigWithAnnotation proxy_config_; ++ bool exclude_pac_url_; ++ // This may only be accessed or modified on Nweb adapter ++ bool has_proxy_override_; ++}; ++ ++ProxyConfigServiceOHOS::ProxyConfigServiceOHOS( ++ const scoped_refptr& main_task_runner) ++ : delegate_(new Delegate(main_task_runner, ++ base::BindRepeating(&GetProperty))) { ++ delegate_->FetchInitialConfig(); ++ ++ OHOS::NWeb::OhosAdapterHelper::GetInstance() ++ .GetNetProxyInstance().RegNetProxyEvent([this](std::string &host, uint16_t &port, ++ const std::string &pac_url, ++ const std::vector &exclusionList) { ++ this->ProxySettingsChangedTo(host, port, pac_url, exclusionList); ++ }); ++} ++ ++ProxyConfigServiceOHOS::~ProxyConfigServiceOHOS() {} ++ ++void ProxyConfigServiceOHOS::set_exclude_pac_url(bool enabled) { ++ delegate_->set_exclude_pac_url(enabled); ++} ++ ++void ProxyConfigServiceOHOS::AddObserver(Observer* observer) { ++ delegate_->AddObserver(observer); ++} ++ ++void ProxyConfigServiceOHOS::RemoveObserver(Observer* observer) { ++ delegate_->RemoveObserver(observer); ++} ++ ++ProxyConfigService::ConfigAvailability ++ProxyConfigServiceOHOS::GetLatestProxyConfig( ++ ProxyConfigWithAnnotation* config) { ++ return delegate_->GetLatestProxyConfig(config); ++} ++ ++ProxyConfigServiceOHOS::ProxyConfigServiceOHOS( ++ const scoped_refptr& main_task_runner, ++ GetPropertyCallback get_property_callback) ++ : delegate_(new Delegate(main_task_runner, ++ get_property_callback)) { ++ delegate_->FetchInitialConfig(); ++} ++ ++void ProxyConfigServiceOHOS::ProxySettingsChangedTo( ++ const std::string& host, ++ int port, ++ const std::string& pac_url, ++ const std::vector& exclusion_list) { ++ delegate_->ProxySettingsChangedTo(host, port, pac_url, exclusion_list); ++} ++ ++void ProxyConfigServiceOHOS::ProxySettingsChanged() { ++ delegate_->ProxySettingsChanged(); ++} ++ ++std::string ProxyConfigServiceOHOS::SetProxyOverride( ++ const std::vector& proxy_rules, ++ const std::vector& bypass_rules, ++ const bool reverse_bypass, ++ base::OnceClosure callback) { ++ return delegate_->SetProxyOverride(proxy_rules, bypass_rules, reverse_bypass, ++ std::move(callback)); ++} ++ ++void ProxyConfigServiceOHOS::ClearProxyOverride(base::OnceClosure callback) { ++ delegate_->ClearProxyOverride(std::move(callback)); ++} ++ ++} // namespace net +diff --git a/src/net/proxy_resolution/proxy_config_service_ohos.h b/src/net/proxy_resolution/proxy_config_service_ohos.h +new file mode 100644 +index 00000000000..59a9798fd39 +--- /dev/null ++++ b/src/net/proxy_resolution/proxy_config_service_ohos.h +@@ -0,0 +1,118 @@ ++/* ++ * Copyright (c) 2023 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 ++ * ++ * 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, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++#ifndef NET_PROXY_RESOLUTION_PROXY_CONFIG_SERVICE_OHOS_H_ ++#define NET_PROXY_RESOLUTION_PROXY_CONFIG_SERVICE_OHOS_H_ ++ ++#include ++ ++#include "base/callback_forward.h" ++#include "base/compiler_specific.h" ++#include "base/memory/ref_counted.h" ++#include "net/base/net_export.h" ++#include "net/proxy_resolution/proxy_config_service.h" ++#include "ohos_adapter_helper.h" ++ ++namespace base { ++class SequencedTaskRunner; ++} ++ ++namespace net { ++ ++class ProxyConfigWithAnnotation; ++ ++class NET_EXPORT ProxyConfigServiceOHOS : public ProxyConfigService { ++ public: ++ // Callback that returns the value of the property identified by the provided ++ // key. If it was not found, an empty string is returned. Note that this ++ // interface does not let you distinguish an empty property from a ++ // non-existing property. ++ typedef base::RepeatingCallback ++ GetPropertyCallback; ++ ++ ProxyConfigServiceOHOS( ++ const scoped_refptr& main_task_runner); ++ ++ ProxyConfigServiceOHOS(const ProxyConfigServiceOHOS&) = delete; ++ ProxyConfigServiceOHOS& operator=(const ProxyConfigServiceOHOS&) = ++ delete; ++ ++ ~ProxyConfigServiceOHOS() override; ++ ++ // OHOS provides a local HTTP proxy that does PAC resolution. When this ++ // setting is enabled, the proxy config service ignores the PAC URL and uses ++ // the local proxy for all proxy resolution. ++ void set_exclude_pac_url(bool enabled); ++ ++ // ProxyConfigService: ++ // Called only on the network thread. ++ void AddObserver(Observer* observer) override; ++ void RemoveObserver(Observer* observer) override; ++ ConfigAvailability GetLatestProxyConfig( ++ ProxyConfigWithAnnotation* config) override; ++ ++ // Holds a single proxy_url and the scheme for which it should be used. ++ // If url_scheme is "*", this proxy will be used for all schemes. ++ // The proxy_url is a string in the format: [scheme://] host [:port] for ++ // a proxy or "direct://" for direct. Scheme is optional and will default to ++ // HTTP; port is optional and defaults to 80 for HTTP, 443 for HTTPS and QUIC, ++ // and 1080 for SOCKS. Host must be one of: ++ // - IPv6 literal with brackets ++ // - IPv4 literal ++ // - A label or labels separated by periods ++ struct ProxyOverrideRule { ++ ProxyOverrideRule(const std::string& url_scheme, ++ const std::string& proxy_url) ++ : url_scheme(url_scheme), proxy_url(proxy_url) {} ++ ++ std::string url_scheme; ++ std::string proxy_url; ++ }; ++ ++ // Receives a list of ProxyOverrideRule and a list of strings for bypass ++ // rules. Wildcards are accepted. URLs that match any pattern in any bypass ++ // rule will go to DIRECT. "" and "<-loopback>" are also accepted. ++ // If no errors were found, returns an empty string, otherwise an UTF-8 string ++ // with a description of the error that was found. ++ // Callback is called (asynchronously) if input was valid. ++ std::string SetProxyOverride( ++ const std::vector& proxy_rules, ++ const std::vector& bypass_rules, ++ const bool reverse_bypass, ++ base::OnceClosure callback); ++ void ClearProxyOverride(base::OnceClosure callback); ++ ++ private: ++ // friend class ProxyConfigServiceOHOSTestBase ++ class Delegate; ++ ++ // For tests. ++ ProxyConfigServiceOHOS( ++ const scoped_refptr& main_task_runner, ++ GetPropertyCallback get_property_callback); ++ ++ // For tests. ++ void ProxySettingsChanged(); ++ ++ void ProxySettingsChangedTo(const std::string& host, ++ int port, ++ const std::string& pac_url, ++ const std::vector& exclusion_list); ++ ++ scoped_refptr delegate_; ++}; ++ ++} // namespace net ++ ++#endif // NET_PROXY_RESOLUTION_PROXY_CONFIG_SERVICE_OHOS_H_ +diff --git a/src/net/socket/client_socket_pool.cc b/src/net/socket/client_socket_pool.cc +index 63bf2f8f439..60861fe2010 +--- a/src/net/socket/client_socket_pool.cc ++++ b/src/net/socket/client_socket_pool.cc +@@ -210,4 +210,14 @@ std::unique_ptr ClientSocketPool::CreateConnectJob( + group_id.secure_dns_policy(), common_connect_job_params_, delegate); + } + ++#if BUILDFLAG(IS_OHOS) ++void ClientSocketPool::SetConnectTimeout(int timeout_override) { ++ timeout_override_ = timeout_override; ++} ++ ++int ClientSocketPool::GetConnectTimeout() { ++ return timeout_override_; ++} ++#endif ++ + } // namespace net +diff --git a/src/net/socket/client_socket_pool.h b/src/net/socket/client_socket_pool.h +index 7556425d69c..57c8dcfea0a +--- a/src/net/socket/client_socket_pool.h ++++ b/src/net/socket/client_socket_pool.h +@@ -334,6 +334,10 @@ class NET_EXPORT ClientSocketPool : public LowerLayeredPool { + + static base::TimeDelta used_idle_socket_timeout(); + static void set_used_idle_socket_timeout(base::TimeDelta timeout); ++#if BUILDFLAG(IS_OHOS) ++ void SetConnectTimeout(int timeout_override); ++ int GetConnectTimeout(); ++#endif + + protected: + ClientSocketPool(bool is_for_websockets, +@@ -354,6 +358,9 @@ class NET_EXPORT ClientSocketPool : public LowerLayeredPool { + RequestPriority request_priority, + SocketTag socket_tag, + ConnectJob::Delegate* delegate); ++#if BUILDFLAG(IS_OHOS) ++ int timeout_override_{0}; ++#endif + + private: + const bool is_for_websockets_; +diff --git a/src/net/socket/client_socket_pool_base_unittest.cc b/src/net/socket/client_socket_pool_base_unittest.cc +index 548c1ca8492..9cac09d692b +--- a/src/net/socket/client_socket_pool_base_unittest.cc ++++ b/src/net/socket/client_socket_pool_base_unittest.cc +@@ -364,6 +364,10 @@ class TestConnectJob : public ConnectJob { + return nullptr; + } + ++#if defined(HW_BUILD_NETWORK) ++ void SetConnectTimeout(int timeout_override) override {} ++#endif ++ + private: + // From ConnectJob: + +diff --git a/src/net/socket/client_socket_pool_manager.h b/src/net/socket/client_socket_pool_manager.h +index 8e4652d7f07..64401860557 +--- a/src/net/socket/client_socket_pool_manager.h ++++ b/src/net/socket/client_socket_pool_manager.h +@@ -75,6 +75,9 @@ class NET_EXPORT_PRIVATE ClientSocketPoolManager { + + // Creates a Value summary of the state of the socket pools. + virtual std::unique_ptr SocketPoolInfoToValue() const = 0; ++#if BUILDFLAG(IS_OHOS) ++ virtual void SetConnectTimeout(int seconds) = 0; ++#endif + }; + + // A helper method that uses the passed in proxy information to initialize a +diff --git a/src/net/socket/client_socket_pool_manager_impl.cc b/src/net/socket/client_socket_pool_manager_impl.cc +index ed80c339cc1..dee5c7f559b +--- a/src/net/socket/client_socket_pool_manager_impl.cc ++++ b/src/net/socket/client_socket_pool_manager_impl.cc +@@ -86,6 +86,9 @@ ClientSocketPool* ClientSocketPoolManagerImpl::GetSocketPool( + pool_type_ == HttpNetworkSession::WEBSOCKET_SOCKET_POOL, + &common_connect_job_params_); + } ++#if BUILDFLAG(IS_OHOS) ++ new_pool->SetConnectTimeout(timeout_override_); ++#endif + + std::pair ret = + socket_pools_.insert(std::make_pair(proxy_server, std::move(new_pool))); +@@ -112,4 +115,13 @@ ClientSocketPoolManagerImpl::SocketPoolInfoToValue() const { + return std::move(list); + } + ++#if BUILDFLAG(IS_OHOS) ++void ClientSocketPoolManagerImpl::SetConnectTimeout(int seconds) { ++ timeout_override_ = seconds; ++ for (const auto& it : socket_pools_) { ++ it.second->SetConnectTimeout(seconds); ++ } ++} ++#endif ++ + } // namespace net +diff --git a/src/net/socket/client_socket_pool_manager_impl.h b/src/net/socket/client_socket_pool_manager_impl.h +index 51fe2795afe..b2dac10d029 +--- a/src/net/socket/client_socket_pool_manager_impl.h ++++ b/src/net/socket/client_socket_pool_manager_impl.h +@@ -49,6 +49,10 @@ class NET_EXPORT_PRIVATE ClientSocketPoolManagerImpl + // Creates a Value summary of the state of the socket pools. + std::unique_ptr SocketPoolInfoToValue() const override; + ++#if BUILDFLAG(IS_OHOS) ++ void SetConnectTimeout(int seconds) override; ++#endif ++ + private: + using SocketPoolMap = + std::map>; +@@ -60,7 +64,9 @@ class NET_EXPORT_PRIVATE ClientSocketPoolManagerImpl + const HttpNetworkSession::SocketPoolType pool_type_; + + SocketPoolMap socket_pools_; +- ++#if BUILDFLAG(IS_OHOS) ++ int timeout_override_{0}; ++#endif + THREAD_CHECKER(thread_checker_); + }; + +diff --git a/src/net/socket/connect_job.cc b/src/net/socket/connect_job.cc +index 0916443e7e4..889351b5fa6 +--- a/src/net/socket/connect_job.cc ++++ b/src/net/socket/connect_job.cc +@@ -106,7 +106,12 @@ void ConnectJob::ChangePriority(RequestPriority priority) { + } + + int ConnectJob::Connect() { +- if (!timeout_duration_.is_zero()) ++#if BUILDFLAG(IS_OHOS) ++ if (!timeout_override_.is_zero()) ++ timer_.Start(FROM_HERE, timeout_override_, this, &ConnectJob::OnTimeout); ++ else ++#endif ++ if (!timeout_duration_.is_zero()) + timer_.Start(FROM_HERE, timeout_duration_, this, &ConnectJob::OnTimeout); + + LogConnectStart(); +diff --git a/src/net/socket/connect_job.h b/src/net/socket/connect_job.h +index 70da15c61f7..e4e329dacc3 +--- a/src/net/socket/connect_job.h ++++ b/src/net/socket/connect_job.h +@@ -238,6 +238,10 @@ class NET_EXPORT_PRIVATE ConnectJob { + + const NetLogWithSource& net_log() const { return net_log_; } + ++#if BUILDFLAG(IS_OHOS) ++ virtual void SetConnectTimeout(int timeout_override) = 0; ++#endif ++ + protected: + const SocketTag& socket_tag() const { return socket_tag_; } + ClientSocketFactory* client_socket_factory() { +@@ -285,6 +289,10 @@ class NET_EXPORT_PRIVATE ConnectJob { + // TODO(mmenke): This should be private. + LoadTimingInfo::ConnectTiming connect_timing_; + ++#if BUILDFLAG(IS_OHOS) ++ base::TimeDelta timeout_override_ = base::TimeDelta(); ++#endif ++ + private: + virtual int ConnectInternal() = 0; + +diff --git a/src/net/socket/connect_job_unittest.cc b/src/net/socket/connect_job_unittest.cc +index 39a1329e207..cf70524bdb9 +--- a/src/net/socket/connect_job_unittest.cc ++++ b/src/net/socket/connect_job_unittest.cc +@@ -79,6 +79,10 @@ class TestConnectJob : public ConnectJob { + last_seen_priority_ = priority; + } + ++#if BUILDFLAG(IS_OHOS) ++ void SetConnectTimeout(int timeout_override) override {} ++#endif ++ + using ConnectJob::ResetTimer; + + // The priority seen during the most recent call to ChangePriorityInternal(). +diff --git a/src/net/socket/socks_connect_job.cc b/src/net/socket/socks_connect_job.cc +index 2c93200d9a2..bafd4fb224a +--- a/src/net/socket/socks_connect_job.cc ++++ b/src/net/socket/socks_connect_job.cc +@@ -159,6 +159,9 @@ int SOCKSConnectJob::DoTransportConnect() { + transport_connect_job_ = TransportConnectJob::CreateTransportConnectJob( + socks_params_->transport_params(), priority(), socket_tag(), + common_connect_job_params(), this, &net_log()); ++#if BUILDFLAG(IS_OHOS) ++ transport_connect_job_->SetConnectTimeout(timeout_override_for_nested_job_); ++#endif + return transport_connect_job_->Connect(); + } + +@@ -217,4 +220,11 @@ void SOCKSConnectJob::ChangePriorityInternal(RequestPriority priority) { + transport_connect_job_->ChangePriority(priority); + } + ++#if BUILDFLAG(IS_OHOS) ++void SOCKSConnectJob::SetConnectTimeout(int timeout_override) { ++ timeout_override_for_nested_job_ = timeout_override; ++ timeout_override_ = base::TimeDelta(); ++} ++#endif ++ + } // namespace net +diff --git a/src/net/socket/socks_connect_job.h b/src/net/socket/socks_connect_job.h +index 1d6e7db4c42..33e16b4a0e6 +--- a/src/net/socket/socks_connect_job.h ++++ b/src/net/socket/socks_connect_job.h +@@ -104,6 +104,10 @@ class NET_EXPORT_PRIVATE SOCKSConnectJob : public ConnectJob, + // Returns the handshake timeout used by SOCKSConnectJobs. + static base::TimeDelta HandshakeTimeoutForTesting(); + ++#if BUILDFLAG(IS_OHOS) ++ void SetConnectTimeout(int timeout_override) override; ++#endif ++ + private: + enum State { + STATE_TRANSPORT_CONNECT, +@@ -145,6 +149,10 @@ class NET_EXPORT_PRIVATE SOCKSConnectJob : public ConnectJob, + raw_ptr socks_socket_ptr_; + + ResolveErrorInfo resolve_error_info_; ++#if BUILDFLAG(IS_OHOS) ++ // Only for transport_connect_job ++ int timeout_override_for_nested_job_{0}; ++#endif + }; + + } // namespace net +diff --git a/src/net/socket/ssl_connect_job.cc b/src/net/socket/ssl_connect_job.cc +index 1c6456c0ed2..afb7715989a +--- a/src/net/socket/ssl_connect_job.cc ++++ b/src/net/socket/ssl_connect_job.cc +@@ -279,6 +279,9 @@ int SSLConnectJob::DoTransportConnect() { + nested_connect_job_ = TransportConnectJob::CreateTransportConnectJob( + params_->GetDirectConnectionParams(), priority(), socket_tag(), + common_connect_job_params(), this, &net_log()); ++#if BUILDFLAG(IS_OHOS) ++ nested_connect_job_->SetConnectTimeout(timeout_override_for_nested_job_); ++#endif + return nested_connect_job_->Connect(); + } + +@@ -308,6 +311,9 @@ int SSLConnectJob::DoSOCKSConnect() { + nested_connect_job_ = std::make_unique( + priority(), socket_tag(), common_connect_job_params(), + params_->GetSocksProxyConnectionParams(), this, &net_log()); ++#if BUILDFLAG(IS_OHOS) ++ nested_connect_job_->SetConnectTimeout(timeout_override_for_nested_job_); ++#endif + return nested_connect_job_->Connect(); + } + +@@ -332,6 +338,9 @@ int SSLConnectJob::DoTunnelConnect() { + nested_connect_job_ = std::make_unique( + priority(), socket_tag(), common_connect_job_params(), + params_->GetHttpProxyConnectionParams(), this, &net_log()); ++#if BUILDFLAG(IS_OHOS) ++ nested_connect_job_->SetConnectTimeout(timeout_override_for_nested_job_); ++#endif + return nested_connect_job_->Connect(); + } + +@@ -540,4 +549,11 @@ void SSLConnectJob::ChangePriorityInternal(RequestPriority priority) { + nested_connect_job_->ChangePriority(priority); + } + ++#if BUILDFLAG(IS_OHOS) ++void SSLConnectJob::SetConnectTimeout(int timeout_override) { ++ timeout_override_for_nested_job_ = timeout_override; ++ timeout_override_ = base::TimeDelta(); ++} ++#endif ++ + } // namespace net +diff --git a/src/net/socket/ssl_connect_job.h b/src/net/socket/ssl_connect_job.h +index 666dc024c9d..9938ddddf7c +--- a/src/net/socket/ssl_connect_job.h ++++ b/src/net/socket/ssl_connect_job.h +@@ -134,6 +134,10 @@ class NET_EXPORT_PRIVATE SSLConnectJob : public ConnectJob, + // connections regardless of whether or not there is a proxy in use. + static base::TimeDelta HandshakeTimeoutForTesting(); + ++#if BUILDFLAG(IS_OHOS) ++ void SetConnectTimeout(int timeout_override) override; ++#endif ++ + private: + enum State { + STATE_TRANSPORT_CONNECT, +@@ -205,6 +209,11 @@ class NET_EXPORT_PRIVATE SSLConnectJob : public ConnectJob, + // lifetime and the aliases can no longer be retrieved from there by by the + // time that the aliases are needed to be passed in SetSocket. + std::set dns_aliases_; ++ ++#if BUILDFLAG(IS_OHOS) ++ // Only for transport_connect_job ++ int timeout_override_for_nested_job_{0}; ++#endif + }; + + } // namespace net +diff --git a/src/net/socket/transport_client_socket_pool.cc b/src/net/socket/transport_client_socket_pool.cc +index b47590a7619..8d87d337f0f +--- a/src/net/socket/transport_client_socket_pool.cc ++++ b/src/net/socket/transport_client_socket_pool.cc +@@ -399,6 +399,9 @@ int TransportClientSocketPool::RequestSocketInternal(const GroupId& group_id, + return NetLogCreateConnectJobParams(false /* backup_job */, &group_id); + }); + ConnectJob* connect_job = owned_connect_job.get(); ++#if BUILDFLAG(IS_OHOS) ++ connect_job->SetConnectTimeout(timeout_override_); ++#endif + bool was_group_empty = group->IsEmpty(); + // Need to add the ConnectJob to the group before connecting, to ensure + // |group| is not empty. Otherwise, if the ConnectJob calls back into the +@@ -771,6 +774,9 @@ TransportClientSocketPool::TransportClientSocketPool( + + if (ssl_client_context_) + ssl_client_context_->AddObserver(this); ++#if BUILDFLAG(IS_OHOS) ++ timeout_override_ = 0; ++#endif + } + + void TransportClientSocketPool::OnSSLConfigChanged( +@@ -1565,6 +1571,9 @@ void TransportClientSocketPool::Group::OnBackupJobTimerFired( + return NetLogCreateConnectJobParams(true /* backup_job */, &group_id_); + }); + ConnectJob* backup_job = owned_backup_job.get(); ++#if BUILDFLAG(IS_OHOS) ++ backup_job->SetConnectTimeout(client_socket_pool_->GetConnectTimeout()); ++#endif + AddJob(std::move(owned_backup_job), false); + client_socket_pool_->connecting_socket_count_++; + int rv = backup_job->Connect(); +diff --git a/src/net/socket/transport_connect_job.cc b/src/net/socket/transport_connect_job.cc +index 05bf7109eb3..9aa0348020a +--- a/src/net/socket/transport_connect_job.cc ++++ b/src/net/socket/transport_connect_job.cc +@@ -485,4 +485,10 @@ void TransportConnectJob::ChangePriorityInternal(RequestPriority priority) { + } + } + ++#if BUILDFLAG(IS_OHOS) ++void TransportConnectJob::SetConnectTimeout(int timeout_override) { ++ timeout_override_ = base::Seconds(timeout_override); ++} ++#endif ++ + } // namespace net +diff --git a/src/net/socket/transport_connect_job.h b/src/net/socket/transport_connect_job.h +index 74532981434..be79fb134f5 +--- a/src/net/socket/transport_connect_job.h ++++ b/src/net/socket/transport_connect_job.h +@@ -140,6 +140,9 @@ class NET_EXPORT_PRIVATE TransportConnectJob : public ConnectJob { + bool HasEstablishedConnection() const override; + ConnectionAttempts GetConnectionAttempts() const override; + ResolveErrorInfo GetResolveErrorInfo() const override; ++#if BUILDFLAG(IS_OHOS) ++ void SetConnectTimeout(int timeout_override) override; ++#endif + + // Rolls |addrlist| forward until the first IPv4 address, if any. + // WARNING: this method should only be used to implement the prefer-IPv4 hack. +diff --git a/src/net/socket/websocket_transport_client_socket_pool.cc b/src/net/socket/websocket_transport_client_socket_pool.cc +index 9d9851b9396..9acb920eabb +--- a/src/net/socket/websocket_transport_client_socket_pool.cc ++++ b/src/net/socket/websocket_transport_client_socket_pool.cc +@@ -42,6 +42,9 @@ WebSocketTransportClientSocketPool::WebSocketTransportClientSocketPool( + handed_out_socket_count_(0), + flushing_(false) { + DCHECK(common_connect_job_params->websocket_endpoint_lock_manager); ++#if BUILDFLAG(IS_OHOS) ++ timeout_override_ = 0; ++#endif + } + + WebSocketTransportClientSocketPool::~WebSocketTransportClientSocketPool() { +@@ -109,7 +112,9 @@ int WebSocketTransportClientSocketPool::RequestSocket( + std::unique_ptr connect_job = + CreateConnectJob(group_id, params, proxy_server_, proxy_annotation_tag, + priority, SocketTag(), connect_job_delegate.get()); +- ++#if BUILDFLAG(IS_OHOS) ++ connect_job->SetConnectTimeout(timeout_override_); ++#endif + int result = connect_job_delegate->Connect(std::move(connect_job)); + + // Regardless of the outcome of |connect_job|, it will always be bound to +diff --git a/src/net/socket/websocket_transport_connect_job.cc b/src/net/socket/websocket_transport_connect_job.cc +index 8f4df0ae3e2..064b2e3c30d +--- a/src/net/socket/websocket_transport_connect_job.cc ++++ b/src/net/socket/websocket_transport_connect_job.cc +@@ -348,4 +348,10 @@ int WebSocketTransportConnectJob::ConnectInternal() { + void WebSocketTransportConnectJob::ChangePriorityInternal( + RequestPriority priority) {} + ++#if BUILDFLAG(IS_OHOS) ++void WebSocketTransportConnectJob::SetConnectTimeout(int timeout_override) { ++ timeout_override_ = base::Seconds(timeout_override); ++} ++#endif ++ + } // namespace net +diff --git a/src/net/socket/websocket_transport_connect_job.h b/src/net/socket/websocket_transport_connect_job.h +index 982b3796f2b..234f9cfa3a4 +--- a/src/net/socket/websocket_transport_connect_job.h ++++ b/src/net/socket/websocket_transport_connect_job.h +@@ -70,6 +70,10 @@ class NET_EXPORT_PRIVATE WebSocketTransportConnectJob : public ConnectJob { + bool HasEstablishedConnection() const override; + ResolveErrorInfo GetResolveErrorInfo() const override; + ++#if BUILDFLAG(IS_OHOS) ++ void SetConnectTimeout(int timeout_override) override; ++#endif ++ + private: + friend class WebSocketTransportConnectSubJob; + +diff --git a/src/net/url_request/url_request_context.cc b/src/net/url_request/url_request_context.cc +index 8cf3c0f234d..173d6ca6070 +--- a/src/net/url_request/url_request_context.cc ++++ b/src/net/url_request/url_request_context.cc +@@ -130,4 +130,16 @@ void URLRequestContext::AssertNoURLRequests() const { + } + } + ++#if BUILDFLAG(IS_OHOS) ++void URLRequestContext::SetConnectTimeout(int seconds) { ++ HttpTransactionFactory* transaction_factory = http_transaction_factory(); ++ if (!transaction_factory) ++ return; ++ HttpNetworkSession* network_session = transaction_factory->GetSession(); ++ if (!network_session) ++ return; ++ network_session->SetConnectTimeout(seconds); ++} ++#endif ++ + } // namespace net +diff --git a/src/net/url_request/url_request_context.h b/src/net/url_request/url_request_context.h +index b508fa27e49..92ea2f5e406 +--- a/src/net/url_request/url_request_context.h ++++ b/src/net/url_request/url_request_context.h +@@ -306,6 +306,10 @@ class NET_EXPORT URLRequestContext { + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); + } + ++#if BUILDFLAG(IS_OHOS) ++ void SetConnectTimeout(int seconds); ++#endif ++ + private: + // Ownership for these members are not defined here. Clients should either + // provide storage elsewhere or have a subclass take ownership. +diff --git a/src/ohos_nweb/BUILD.gn b/src/ohos_nweb/BUILD.gn +index 74afb6ce40d..09cbd9db64f +--- a/src/ohos_nweb/BUILD.gn ++++ b/src/ohos_nweb/BUILD.gn +@@ -21,7 +21,7 @@ import("//tools/grit/repack.gni") + component("nweb_hilog") { + sources = [ "src/nweb_hilog.h" ] + +- libs = [ "hilog" ] ++ libs = [ "nweb_ohos_adapter.z" ] + + include_dirs = ohos_src_includes + lib_dirs = ohos_libs_dir +@@ -43,14 +43,7 @@ config("cef_nweb_config") { + include_dirs += ohos_src_includes + + lib_dirs = ohos_libs_dir +- libs = [ +- "inputmethod_client.z", +- "ipc_core.z", +- "inputmethod_ability.z", +- "accesstoken_sdk.z", +- "nweb_ohos_adapter.z", +- "hisysevent.z", +- ] ++ libs = [ "nweb_ohos_adapter.z" ] + + defines = [ "USING_CHROMIUM_INCLUDES" ] + +@@ -223,7 +216,7 @@ component("nweb_sources") { + + public_deps = [ "//third_party/abseil-cpp:absl" ] + +- libs = [ "surface.z" ] ++ libs = [ "nweb_ohos_adapter.z" ] + } + + ################################################# +diff --git a/src/ohos_nweb/include/nweb.h b/src/ohos_nweb/include/nweb.h +index 761b46af696..f93b999c744 +--- a/src/ohos_nweb/include/nweb.h ++++ b/src/ohos_nweb/include/nweb.h +@@ -72,6 +72,7 @@ struct OHOS_NWEB_EXPORT NWebInitArgs { + std::list web_engine_args_to_delete; + bool multi_renderer_process = false; + bool is_enhance_surface = false; ++ bool is_popup = false; + }; + + struct OHOS_NWEB_EXPORT NWebCreateInfo { +@@ -107,7 +108,19 @@ struct OHOS_NWEB_EXPORT DragEvent { + DragAction action; + }; + ++enum class BlurReason : int32_t { ++ FOCUS_SWITCH = 0, ++ WINDOW_BLUR = 1, ++ FRAME_DESTROY = 2, ++}; ++ ++struct OHOS_NWEB_EXPORT NWebDOHConfig { ++ int doh_mode = -1; ++ std::string doh_config = ""; ++}; ++ + using WebState = std::shared_ptr>; ++using SetKeepScreenOn = std::function; + + class OHOS_NWEB_EXPORT NWeb : public std::enable_shared_from_this { + public: +@@ -123,12 +136,12 @@ class OHOS_NWEB_EXPORT NWeb : public std::enable_shared_from_this { + + /* focus event */ + virtual void OnFocus() const = 0; +- virtual void OnBlur() const = 0; ++ virtual void OnBlur(const BlurReason& blurReason) const = 0; + + /* event interface */ +- virtual void OnTouchPress(int32_t id, double x, double y) = 0; +- virtual void OnTouchRelease(int32_t id, double x = 0, double y = 0) = 0; +- virtual void OnTouchMove(int32_t id, double x, double y) = 0; ++ virtual void OnTouchPress(int32_t id, double x, double y, bool fromOverlay = false) = 0; ++ virtual void OnTouchRelease(int32_t id, double x = 0, double y = 0, bool fromOverlay = false) = 0; ++ virtual void OnTouchMove(int32_t id, double x, double y, bool fromOverlay = false) = 0; + virtual void OnTouchCancel() = 0; + virtual void OnNavigateBack() = 0; + virtual bool SendKeyEvent(int32_t keyCode, int32_t keyAction) = 0; +@@ -236,7 +249,8 @@ class OHOS_NWEB_EXPORT NWeb : public std::enable_shared_from_this { + */ + virtual void ExecuteJavaScript( + const std::string& code, +- std::shared_ptr> callback) const = 0; ++ std::shared_ptr>> callback, ++ bool extention) const = 0; + /** + * Gets the NWebPreference object used to control the settings for this + * NWeb. +@@ -510,10 +524,10 @@ class OHOS_NWEB_EXPORT NWeb : public std::enable_shared_from_this { + * + */ + virtual void ClearClientAuthenticationCache() = 0; +- ++ + /** + * set the locale name of current system setting.. +- * ++ * + * @param locale the locale name of current system setting. + */ + virtual void UpdateLocale(const std::string& language, const std::string& region) = 0; +@@ -527,7 +541,7 @@ class OHOS_NWEB_EXPORT NWeb : public std::enable_shared_from_this { + + /** + * get original url of the request. +- * ++ * + * @param data raw image data of the icon. + * @param width width of the icon. + * @param height height of the icon. +@@ -558,7 +572,7 @@ class OHOS_NWEB_EXPORT NWeb : public std::enable_shared_from_this { + * @param include_disk_files bool: if false, only the RAM cache is removed + */ + virtual void RemoveCache(bool include_disk_files) = 0; +- ++ + /** + * web has image or not. + * +@@ -591,21 +605,21 @@ class OHOS_NWEB_EXPORT NWeb : public std::enable_shared_from_this { + + /** + * Move page up. +- * ++ * + * @param top whether move to the top. + */ + virtual void PageUp(bool top) = 0; + + /** + * Move page down. +- * ++ * + * @param bottom whether move to the bottom. + */ + virtual void PageDown(bool bottom) = 0; + + /** + * Scroll to the position. +- * ++ * + * @param x horizontal coordinate. + * @param y vertical coordinate. + */ +@@ -613,7 +627,7 @@ class OHOS_NWEB_EXPORT NWeb : public std::enable_shared_from_this { + + /** + * Scroll by the delta distance. +- * ++ * + * @param delta_x horizontal offset. + * @param delta_y vertical offset. + */ +@@ -621,11 +635,79 @@ class OHOS_NWEB_EXPORT NWeb : public std::enable_shared_from_this { + + /** + * Slide scroll by the speed. +- * ++ * + * @param vx horizontal slide speed. + * @param vy vertical slide speed. + */ +- virtual void SlideScroll(float vx, float vy) = 0; ++ virtual void SlideScroll(float vx, float vy) = 0; ++ ++ /** ++ * Get current website certificate. ++ * ++ * @param certChainData current website certificate array. ++ * @param isSingleCert true if only get one certificate of current website, ++ * false if get certificate chain of the website. ++ * @return true if get certificate successfully, otherwise false. ++ */ ++ virtual bool GetCertChainDerData(std::vector& certChainData, bool isSingleCert) = 0; ++ ++ /** ++ * Set screen offset. ++ * ++ * @param x the offset in x direction. ++ * @param y the offset in y direction. ++ */ ++ virtual void SetScreenOffSet(double x, double y) = 0; ++ ++ /** ++ * Set audio muted. ++ * ++ * @param muted Aduio mute state. ++ */ ++ virtual void SetAudioMuted(bool muted) = 0; ++ ++ /** ++ * Set should frame submission before draw. ++ * ++ * @param should whether wait render frame submission. ++ */ ++ virtual void SetShouldFrameSubmissionBeforeDraw(bool should) = 0; ++ ++ /** ++ * Notify whether the popup window is initialized successfully. ++ * ++ * @param result whether success. ++ */ ++ virtual void NotifyPopupWindowResult(bool result) = 0; ++ ++ /** ++ * Set audio resume interval. ++ * ++ * @param resumeInterval Aduio resume interval. ++ */ ++ virtual void SetAudioResumeInterval(int32_t resumeInterval) = 0; ++ ++ /** ++ * Set audio exclusive state. ++ * ++ * @param audioExclusive Aduio exclusive state. ++ */ ++ virtual void SetAudioExclusive(bool audioExclusive) = 0; ++ ++ /** ++ * Rigest the keep srceen on interface. ++ * ++ * @param windowId the window id. ++ * @param SetKeepScreenOn the screenon handle. ++ */ ++ virtual void RegisterScreenLockFunction(int32_t windowId, const SetKeepScreenOn&& handle) = 0; ++ ++ /** ++ * UnRigest the keep srceen on interface. ++ * ++ * @param windowId the window id. ++ */ ++ virtual void UnRegisterScreenLockFunction(int32_t windowId) = 0; + }; + } // namespace OHOS::NWeb + +diff --git a/src/ohos_nweb/include/nweb_handler.h b/src/ohos_nweb/include/nweb_handler.h +index 9f1ba1ddf8b..be88ab03744 +--- a/src/ohos_nweb/include/nweb_handler.h ++++ b/src/ohos_nweb/include/nweb_handler.h +@@ -145,6 +145,11 @@ struct NWebCursorInfo { + std::unique_ptr buff = nullptr; + }; + ++struct TouchHandleHotZone { ++ double width = 0.0; ++ double height = 0.0; ++}; ++ + using FileSelectorCallback = NWebValueCallback&>; + + class OHOS_NWEB_EXPORT NWebHandler { +@@ -196,7 +201,7 @@ public: + * @param url The url to be loaded. + * @return true to cancel the loading, false to continue the loading. + */ +- virtual bool OnHandleInterceptUrlLoading(const std::string& url) { ++ virtual bool OnHandleInterceptUrlLoading(std::shared_ptr request) { + return false; + } + +@@ -310,7 +315,7 @@ public: + * geolocation + */ + virtual void OnGeolocationShow(const std::string& origin, +- NWebGeolocationCallbackInterface* callback) {} ++ std::shared_ptr callback) {} + + /** + * @brief Notify the host application that the web page wants to display a +@@ -544,6 +549,33 @@ public: + + virtual void OnSelectPopupMenu(std::shared_ptr params, + std::shared_ptr callback) {} ++ ++ /** ++ * @brief Called when the audio playing state on web page changed. ++ * @param playing Whether the audio is playing or not. ++ */ ++ virtual void OnAudioStateChanged(bool playing) {} ++ ++ /** ++ * @brief Called when the first content rendering of web page. ++ * @param navigationStartTick Absolute navigation start time, as TimeTicks. ++ * @param firstContentfulPaintMs Time to first contentful paint from ++ * navigation start. ++ */ ++ virtual void OnFirstContentfulPaint(long navigationStartTick, ++ long firstContentfulPaintMs) {} ++ ++ /** ++ * @brief Called when swap buffer completed with new size. ++ */ ++ virtual void OnCompleteSwapWithNewSize() {} ++ ++ /** ++ * @brief Called when resize not work. ++ */ ++ virtual void OnResizeNotWork() {} ++ ++ virtual void OnGetTouchHandleHotZone(TouchHandleHotZone& hotZone) {} + }; + } // namespace OHOS::NWeb + +diff --git a/src/ohos_nweb/include/nweb_preference.h b/src/ohos_nweb/include/nweb_preference.h +index 36b1ecac418..94d609e2b06 +--- a/src/ohos_nweb/include/nweb_preference.h ++++ b/src/ohos_nweb/include/nweb_preference.h +@@ -554,6 +554,18 @@ public: + * Put whether enable vertical scroll bar, default value is false. + */ + virtual void PutVerticalScrollBarAccess(bool flag) = 0; ++ ++ /** ++ * Get the color of scrollbar. ++ * ++ * @see PutScrollbarColor ++ */ ++ virtual uint32_t GetScrollBarColor() = 0; ++ ++ /** ++ * Put the UX color of scrollbar. ++ */ ++ virtual void PutScrollBarColor(uint32_t colorValue) = 0; + }; + } // namespace OHOS::NWeb + #endif // NWEB_PREFERENCE_H +diff --git a/src/ohos_nweb/include/nweb_url_resource_response.h b/src/ohos_nweb/include/nweb_url_resource_response.h +index f0b9fd6f388..1c48396b576 +--- a/src/ohos_nweb/include/nweb_url_resource_response.h ++++ b/src/ohos_nweb/include/nweb_url_resource_response.h +@@ -28,6 +28,12 @@ public: + virtual void Cancel() = 0; + }; + ++enum class NWebResponseDataType : int32_t { ++ NWEB_STRING_TYPE, ++ NWEB_FILE_TYPE, ++ NWEB_RESOURCE_URL_TYPE, ++}; ++ + class NWebUrlResourceResponse { + public: + /** +@@ -89,6 +95,7 @@ public: + input_stream_ = input_stream; + fd_ = 0; + isFileFd_ = false; ++ dataType_ = NWebResponseDataType::NWEB_STRING_TYPE; + } + + /** +@@ -193,26 +200,45 @@ public: + } + } + +- bool ResponseDataStatus() { ++ bool ResponseDataStatus() const ++ { + return isDataReady_; + } + +- bool ResponseIsFileHandle() { ++ bool ResponseIsFileHandle() const ++ { + return isFileFd_; + } + + void PutResponseFileHandle(int fd) + { ++ dataType_ = NWebResponseDataType::NWEB_FILE_TYPE; + fd_ = fd; + isFileFd_ = true; + input_stream_.clear(); + } + +- int ResponseFileHandle() ++ int ResponseFileHandle() const + { + return fd_; + } + ++ void PutResponseResourceUrl(const std::string& url) ++ { ++ resource_url_ = url; ++ dataType_ = NWebResponseDataType::NWEB_RESOURCE_URL_TYPE; ++ } ++ ++ std::string ResponseResourceUrl() ++ { ++ return resource_url_; ++ } ++ ++ NWebResponseDataType ResponseDataType() const ++ { ++ return dataType_; ++ } ++ + void PutResponseReadyCallback(std::shared_ptr readyCallback) + { + readyCallback_ = readyCallback; +@@ -225,7 +251,9 @@ private: + std::string reason_phrase_; + std::map response_headers_; + std::string input_stream_; +- int fd_; ++ int fd_ = -1; ++ std::string resource_url_; ++ NWebResponseDataType dataType_ = NWebResponseDataType::NWEB_STRING_TYPE; + bool isFileFd_ = false; + bool isDataReady_ = true; + std::shared_ptr readyCallback_; +diff --git a/src/ohos_nweb/include/nweb_value.h b/src/ohos_nweb/include/nweb_value.h +index 9120456d915..9852198dd2a +--- a/src/ohos_nweb/include/nweb_value.h ++++ b/src/ohos_nweb/include/nweb_value.h +@@ -37,7 +37,12 @@ public: + STRING, + BINARY, + DICTIONARY, +- LIST ++ LIST, ++ ERROR, ++ STRINGARRAY, ++ BOOLEANARRAY, ++ DOUBLEARRAY, ++ INT64ARRAY + }; + + explicit NWebValue(Type type) : type_(type) {} +diff --git a/src/ohos_nweb/include/nweb_web_message.h b/src/ohos_nweb/include/nweb_web_message.h +index 1d5abfea195..a4e951245d4 +--- a/src/ohos_nweb/include/nweb_web_message.h ++++ b/src/ohos_nweb/include/nweb_web_message.h +@@ -18,28 +18,54 @@ + + #include + +-#include "nweb_value.h" + #include "nweb_export.h" ++#include "nweb_value.h" + + namespace OHOS::NWeb { + class OHOS_NWEB_EXPORT NWebMessage : public NWebValue { +-public: +- explicit NWebMessage(NWebValue::Type type) : NWebValue(type){} ++ public: ++ explicit NWebMessage(NWebValue::Type type) : NWebValue(type) {} ++ ++ ~NWebMessage() = default; ++ ++ void SetBinary(std::vector& binary_data) { ++ binary_data_.reserve(binary_data.size()); ++ binary_data_ = binary_data; ++ } ++ ++ std::vector GetBinary() { return binary_data_; } + +- ~NWebMessage() = default; ++ std::string GetErrName() { return err_name_; } ++ std::string GetErrMsg() { return err_msg_; } ++ int64_t GetInt64() { return value_; } + +- void SetBinary(std::vector& binary_data) { +- binary_data_.reserve(binary_data.size()); +- binary_data_ = binary_data; +- } ++ void SetErrName(std::string name) { err_name_ = name; } ++ void SetErrMsg(std::string msg) { err_msg_ = msg; } ++ void SetInt64(int64_t value) { value_ = value; } + +- std::vector GetBinary() { +- return binary_data_; +- } ++ std::vector GetStringArray() { return string_arr_; } ++ void SetStringArray(std::vector string_arr) { ++ string_arr_ = string_arr; ++ } ++ std::vector GetBooleanArray() { return bool_arr_; } ++ void SetBooleanArray(std::vector bool_arr) { bool_arr_ = bool_arr; } ++ std::vector GetDoubleArray() { return double_arr_; } ++ void SetDoubleArray(std::vector double_arr) { ++ double_arr_ = double_arr; ++ } ++ std::vector GetInt64Array() { return int64_arr_; } ++ void SetInt64Array(std::vector int64_arr) { int64_arr_ = int64_arr; } + +-private: +- std::vector binary_data_; ++ private: ++ std::vector binary_data_; ++ std::string err_name_; ++ std::string err_msg_; ++ int64_t value_; ++ std::vector string_arr_; ++ std::vector bool_arr_; ++ std::vector double_arr_; ++ std::vector int64_arr_; + }; +-} ++} // namespace OHOS::NWeb + + #endif // NWEB_WEB_MESSAGE_H_ +diff --git a/src/ohos_nweb/src/cef_delegate/nweb_application.cc b/src/ohos_nweb/src/cef_delegate/nweb_application.cc +index 6ac4069fc63..6afa06b2441 +--- a/src/ohos_nweb/src/cef_delegate/nweb_application.cc ++++ b/src/ohos_nweb/src/cef_delegate/nweb_application.cc +@@ -24,6 +24,7 @@ + #include "content/public/browser/browser_thread.h" + #include "content/public/common/content_switches.h" + #include "nweb_handler_delegate.h" ++#include "nweb_impl.h" + + namespace OHOS::NWeb { + NWebApplication::NWebApplication( +@@ -130,6 +131,12 @@ void NWebApplication::OnBeforeChildProcessLaunch(CefRefPtr comma + command_line->AppendSwitchWithValue(::switches::kOhosHapPath, + CefCommandLine::GetGlobalCommandLine()->GetSwitchValue(::switches::kOhosHapPath).ToString()); + } ++ ++#ifdef OHOS_NWEB_EX ++ for (const auto& arg : NWebImpl::GetCommandLineArgsForNWebEx()) { ++ command_line->AppendSwitch(arg); ++ } ++#endif // OHOS_NWEB_EX + } + /* CefBrowserProcessHandler methods end */ + +@@ -162,7 +169,6 @@ void NWebApplication::CreateBrowser() { + // Specify CEF browser settings here. + CefBrowserSettings browser_settings; + PopulateCreateSettings(command_line, browser_settings); +- browser_settings.background_color = 0xffffffff; + preference_delegate_->ComputeBrowserSettings(browser_settings); + + if (command_line->HasSwitch(switches::kForTest)) { +diff --git a/src/ohos_nweb/src/cef_delegate/nweb_delegate.cc b/src/ohos_nweb/src/cef_delegate/nweb_delegate.cc +index 4fb5d7687f9..d5d25209a8e +--- a/src/ohos_nweb/src/cef_delegate/nweb_delegate.cc ++++ b/src/ohos_nweb/src/cef_delegate/nweb_delegate.cc +@@ -21,6 +21,7 @@ + #include "nweb_history_list_impl.h" + #include "nweb_render_handler.h" + ++#include "base/trace_event/trace_event.h" + #include "base/strings/utf_string_conversions.h" + #include "cef/include/base/cef_logging.h" + #include "cef/include/cef_app.h" +@@ -35,21 +36,107 @@ + + namespace OHOS::NWeb { + +-static const float maxZoomFactor = 10.0; ++void ConvertCefValueToNWebMessage(CefRefPtr src, std::shared_ptr dst) { ++ int type = src->GetType(); ++ LOG(INFO) << "OnMessage type:" << type; ++ switch (type) { ++ case VTYPE_STRING: { ++ dst->SetType(NWebValue::Type::STRING); ++ dst->SetString(src->GetString()); ++ break; ++ } ++ case VTYPE_BINARY: { ++ CefRefPtr binValue = src->GetBinary(); ++ size_t len = binValue->GetSize(); ++ std::vector arr(len); ++ binValue->GetData(&arr[0], len, 0); ++ dst->SetType(NWebValue::Type::BINARY); ++ dst->SetBinary(arr); ++ break; ++ } ++ case VTYPE_BOOL: { ++ dst->SetType(NWebValue::Type::BOOLEAN); ++ dst->SetBoolean(src->GetBool()); ++ break; ++ } ++ case VTYPE_DOUBLE: { ++ dst->SetType(NWebValue::Type::DOUBLE); ++ dst->SetDouble(src->GetDouble()); ++ break; ++ } ++ case VTYPE_INT: { ++ dst->SetType(NWebValue::Type::INTEGER); ++ dst->SetInt64(src->GetInt()); ++ break; ++ } ++ case VTYPE_DICTIONARY: { ++ CefRefPtr dict = src->GetDictionary(); ++ dst->SetType(NWebValue::Type::ERROR); ++ dst->SetErrName(dict->GetString("Error.name")); ++ dst->SetErrMsg(dict->GetString("Error.message")); ++ break; ++ } ++ case VTYPE_LIST: { ++ CefRefPtr listValue = src->GetList(); ++ size_t len = listValue->GetSize(); ++ std::vector string_arr; ++ std::vector bool_arr; ++ std::vector double_arr; ++ std::vector int64_arr; ++ CefValueType elem_type; ++ for (size_t i = 0; i < len; i++) { ++ CefRefPtr elem = listValue->GetValue(i); ++ if (elem->GetType() == VTYPE_STRING) { ++ elem_type = VTYPE_STRING; ++ string_arr.push_back(elem->GetString()); ++ }else if (elem->GetType() == VTYPE_BOOL) { ++ elem_type = VTYPE_BOOL; ++ bool_arr.push_back(elem->GetBool()); ++ } else if (elem->GetType() == VTYPE_DOUBLE) { ++ elem_type = VTYPE_DOUBLE; ++ double_arr.push_back(elem->GetDouble()); ++ } else if (elem->GetType() == VTYPE_INT) { ++ elem_type = VTYPE_INT; ++ int64_arr.push_back(elem->GetInt()); ++ } ++ } ++ if (elem_type == VTYPE_STRING) { ++ dst->SetType(NWebValue::Type::STRINGARRAY); ++ dst->SetStringArray(string_arr); ++ } else if (elem_type == VTYPE_BOOL) { ++ dst->SetType(NWebValue::Type::BOOLEANARRAY); ++ dst->SetBooleanArray(bool_arr); ++ } else if (elem_type == VTYPE_DOUBLE) { ++ dst->SetType(NWebValue::Type::DOUBLEARRAY); ++ dst->SetDoubleArray(double_arr); ++ } else if (elem_type == VTYPE_INT) { ++ dst->SetType(NWebValue::Type::INT64ARRAY); ++ dst->SetInt64Array(int64_arr); ++ } ++ break; ++ } ++ default: { ++ LOG(ERROR) << "OnMessage not support type"; ++ break; ++ } ++ } ++} + + class JavaScriptResultCallbackImpl : public CefJavaScriptResultCallback { + public: + JavaScriptResultCallbackImpl( +- std::shared_ptr> callback) ++ std::shared_ptr>> callback) + : callback_(callback){}; +- void OnJavaScriptExeResult(const CefString& result) override { ++ void OnJavaScriptExeResult(CefRefPtr result) override { + if (callback_ != nullptr) { +- callback_->OnReceiveValue(result.ToString()); ++ auto data = std::make_shared(NWebValue::Type::NONE); ++ ConvertCefValueToNWebMessage(result, data); ++ callback_->OnReceiveValue(data); + } + } + + private: +- std::shared_ptr> callback_; ++ std::shared_ptr>> callback_; + + IMPLEMENT_REFCOUNTING(JavaScriptResultCallbackImpl); + }; +@@ -60,22 +147,10 @@ class CefWebMessageReceiverImpl : public CefWebMessageReceiver { + std::shared_ptr>> callback) + : callback_(callback){}; + void OnMessage(CefRefPtr message) override { ++ LOG(INFO) << "OnMessage in nweb delegate"; + if (callback_ != nullptr) { + auto data = std::make_shared(NWebValue::Type::NONE); +- if (message->GetType() == VTYPE_STRING) { +- data->SetType(NWebValue::Type::STRING); +- data->SetString(message->GetString()); +- } else if (message->GetType() == VTYPE_BINARY) { +- CefRefPtr binValue = message->GetBinary(); +- size_t len = binValue->GetSize(); +- std::vector arr(len); +- binValue->GetData(&arr[0], len, 0); +- data->SetType(NWebValue::Type::BINARY); +- data->SetBinary(arr); +- } else { +- LOG(ERROR) << "OnMessage not support type"; +- return; +- } ++ ConvertCefValueToNWebMessage(message, data); + callback_->OnReceiveValue(data); + } + } +@@ -159,8 +234,30 @@ NWebDelegate::~NWebDelegate() { + } + } + +-bool NWebDelegate::Init(bool is_enhance_surface, void* window) { ++bool NWebDelegate::HasBackgroundColorWithInit(int32_t& backgroundColor) { ++ for (int i = 0; i < argc_; i++) { ++ if (argv_[i] == nullptr) { ++ continue; ++ } ++ ++ if (!strncmp(argv_[i], "--init-background-color=", strlen("--init-background-color="))) { ++ const char* value = argv_[i] + strlen("--init-background-color="); ++ backgroundColor = atoi(value); ++ LOG(INFO) << "HasBackgroundColorWithInit, background color = " << backgroundColor; ++ return true; ++ } ++ } ++ ++ return false; ++} ++ ++bool NWebDelegate::Init(bool is_enhance_surface, void* window, bool popup) { + preference_delegate_ = std::make_shared(); ++ int32_t backgroundColor; ++ if (preference_delegate_ && HasBackgroundColorWithInit(backgroundColor)) { ++ // background color should set when init in case of first white screen flash ++ preference_delegate_->SetBackgroundColor(backgroundColor); ++ } + find_delegate_ = std::make_shared(); + is_enhance_surface_ = is_enhance_surface; + display_manager_adapter_ = +@@ -192,7 +289,7 @@ bool NWebDelegate::Init(bool is_enhance_surface, void* window) { + } + + std::string url_for_init = ""; +- InitializeCef(url_for_init, is_enhance_surface_, window); ++ InitializeCef(url_for_init, is_enhance_surface_, window, popup); + + std::shared_ptr display = + display_manager_adapter_->GetDefaultDisplay(); +@@ -321,37 +418,55 @@ void NWebDelegate::RegisterRenderCb( + } + + void NWebDelegate::Resize(uint32_t width, uint32_t height) { ++ if (width == width_ && height == height_) { ++ render_handler_->OnResizeNotWork(); ++ return; ++ } ++ ++ TRACE_EVENT2("base", "NWebDelegate::Resize", "width", width, "height", ++ height); ++ width_ = width; ++ height_ = height; + if (render_handler_ != nullptr) { + render_handler_->Resize(width, height); + } ++ + auto browser = GetBrowser(); + if (browser != nullptr && browser->GetHost() != nullptr) { +- if (width != width_ || height != height_) { +- width_ = width; +- height_ = height; +- browser->GetHost()->WasResized(); +- } ++ browser->GetHost()->WasResized(); + } + } + +-void NWebDelegate::OnTouchPress(int32_t id, double x, double y) { ++void NWebDelegate::OnTouchPress(int32_t id, ++ double x, ++ double y, ++ bool from_overlay) { + if (event_handler_ != nullptr) { + event_handler_->OnTouchPress(id, x / default_virtual_pixel_ratio_, +- y / default_virtual_pixel_ratio_); ++ y / default_virtual_pixel_ratio_, ++ from_overlay); + } + } + +-void NWebDelegate::OnTouchRelease(int32_t id, double x, double y) { ++void NWebDelegate::OnTouchRelease(int32_t id, ++ double x, ++ double y, ++ bool from_overlay) { + if (event_handler_ != nullptr) { + event_handler_->OnTouchRelease(id, x / default_virtual_pixel_ratio_, +- y / default_virtual_pixel_ratio_); ++ y / default_virtual_pixel_ratio_, ++ from_overlay); + } + } + +-void NWebDelegate::OnTouchMove(int32_t id, double x, double y) { ++void NWebDelegate::OnTouchMove(int32_t id, ++ double x, ++ double y, ++ bool from_overlay) { + if (event_handler_ != nullptr) { + event_handler_->OnTouchMove(id, x / default_virtual_pixel_ratio_, +- y / default_virtual_pixel_ratio_); ++ y / default_virtual_pixel_ratio_, ++ from_overlay); + } + } + +@@ -364,7 +479,7 @@ void NWebDelegate::OnTouchCancel() { + bool NWebDelegate::SendKeyEvent(int32_t keyCode, int32_t keyAction) { + bool retVal = false; + if (event_handler_ != nullptr) { +- retVal = event_handler_->SendKeyEvent(keyCode, keyAction); ++ retVal = event_handler_->SendKeyEventFromAce(keyCode, keyAction); + } + return retVal; + } +@@ -449,6 +564,7 @@ int NWebDelegate::Load(const std::string& url) { + LOG(INFO) << "NWebDelegate::Load url=" << url; + auto browser = GetBrowser(); + if (browser == nullptr) { ++ LOG(ERROR) << "NWebDelegate::Load browser is nullptr"; + return NWEB_ERR; + } + browser->GetMainFrame()->LoadURL(CefString(url)); +@@ -600,12 +716,7 @@ int NWebDelegate::Zoom(float zoomFactor) const { + LOG(ERROR) << "JSAPI Zoom can not get browser"; + return NWEB_ERR; + } +- double curFactor = GetBrowser()->GetHost()->GetZoomLevel(); +- if (zoomFactor + curFactor > maxZoomFactor || zoomFactor + curFactor < 0) { +- LOG(ERROR) << "JSAPI Zoom can no more zoom"; +- return NWEB_ERR; +- } +- GetBrowser()->GetHost()->SetZoomLevel(zoomFactor + curFactor); ++ GetBrowser()->GetHost()->ZoomBy(zoomFactor, width_ / default_virtual_pixel_ratio_, height_ / default_virtual_pixel_ratio_); + return NWEB_OK; + } + +@@ -621,12 +732,7 @@ int NWebDelegate::ZoomIn() const { + LOG(ERROR) << "JSAPI ZoomIn can not get browser"; + return NWEB_ERR; + } +- double curFactor = GetBrowser()->GetHost()->GetZoomLevel(); +- if (zoom_in_factor_ + curFactor > maxZoomFactor) { +- LOG(ERROR) << "JSAPI ZoomIn can no more zoom in"; +- return NWEB_ERR; +- } +- GetBrowser()->GetHost()->SetZoomLevel(zoom_in_factor_ + curFactor); ++ GetBrowser()->GetHost()->ZoomBy(zoom_in_factor_, width_ / default_virtual_pixel_ratio_, height_ / default_virtual_pixel_ratio_); + return NWEB_OK; + } + +@@ -642,12 +748,7 @@ int NWebDelegate::ZoomOut() const { + LOG(ERROR) << "JSAPI ZoomOut can not get browser"; + return NWEB_ERR; + } +- double curFactor = GetBrowser()->GetHost()->GetZoomLevel(); +- if (zoom_in_factor_ + curFactor < 0) { +- LOG(ERROR) << "JSAPI ZoomOut can no more zoom out"; +- return NWEB_ERR; +- } +- GetBrowser()->GetHost()->SetZoomLevel(zoom_out_factor_ + curFactor); ++ GetBrowser()->GetHost()->ZoomBy(zoom_out_factor_, width_ / default_virtual_pixel_ratio_, height_ / default_virtual_pixel_ratio_); + return NWEB_OK; + } + @@ -686,21 +787,25 @@ void NWebDelegate::ExecuteJavaScript(const std::string& code) const { + + void NWebDelegate::ExecuteJavaScript( + const std::string& code, +- std::shared_ptr> callback) const { ++ std::shared_ptr>> callback, ++ bool extention) const { + LOG(INFO) << "NWebDelegate::ExecuteJavaScript with callback"; + + if (GetBrowser().get()) { + CefRefPtr JsResultCb = + new JavaScriptResultCallbackImpl(callback); +- GetBrowser()->GetHost()->ExecuteJavaScript(code, JsResultCb); ++ GetBrowser()->GetHost()->ExecuteJavaScript(code, JsResultCb, extention); + } + } + + void NWebDelegate::PutBackgroundColor(int color) const { +- LOG(INFO) << "NWebDelegate::PutBackgroundColor"; ++ LOG(INFO) << "NWebDelegate::PutBackgroundColor color: " << (uint32_t)color; + if (GetBrowser().get()) { + GetBrowser()->GetHost()->SetBackgroundColor(color); + } ++ if (preference_delegate_) { ++ preference_delegate_->SetBackgroundColor(color); ++ } + } + + void NWebDelegate::InitialScale(float scale) const { +@@ -748,7 +853,16 @@ void NWebDelegate::OnContinue() { + + void NWebDelegate::InitializeCef(std::string url, + bool is_enhance_surface, +- void* window) { ++ void* window, ++ bool popup) { ++ if (popup) { ++ LOG(DEBUG) << "pop windows"; ++ handler_delegate_ = NWebHandlerDelegate::Create( ++ preference_delegate_, render_handler_, event_handler_, find_delegate_, ++ is_enhance_surface, window); ++ is_ready_ = true; ++ return; ++ } + handler_delegate_ = NWebHandlerDelegate::Create( + preference_delegate_, render_handler_, event_handler_, find_delegate_, + is_enhance_surface, window); +@@ -845,6 +959,85 @@ void NWebDelegate::ClosePort(std::string& portHandle) { + GetBrowser()->GetHost()->ClosePort(handleCef); + } + ++void NWebDelegate::ConvertNWebMsgToCefValue(std::shared_ptr data, CefRefPtr message) { ++ switch (data->GetType()) { ++ case NWebValue::Type::STRING: { ++ message->SetString(data->GetString()); ++ break; ++ } ++ case NWebValue::Type::BINARY: { ++ std::vector vecBinary = data->GetBinary(); ++ CefRefPtr value = CefBinaryValue::Create(vecBinary.data(), vecBinary.size()); ++ message->SetBinary(value); ++ break; ++ } ++ case NWebValue::Type::BOOLEAN: { ++ message->SetBool(data->GetBoolean()); ++ break; ++ } ++ ++ case NWebValue::Type::DOUBLE: { ++ message->SetDouble(data->GetDouble()); ++ break; ++ } ++ ++ case NWebValue::Type::INTEGER: { ++ message->SetInt(data->GetInt64()); ++ break; ++ } ++ ++ case NWebValue::Type::STRINGARRAY: { ++ CefRefPtr value = CefListValue::Create(); ++ for (size_t i = 0; i < data->GetStringArray().size(); i++) { ++ CefString msgCef; ++ msgCef.FromString(data->GetStringArray()[i]); ++ value->SetString(i, msgCef); ++ } ++ message->SetList(value); ++ break; ++ } ++ ++ case NWebValue::Type::BOOLEANARRAY: { ++ CefRefPtr value = CefListValue::Create(); ++ for (size_t i = 0; i < data->GetBooleanArray().size(); i++) { ++ value->SetBool(i, data->GetBooleanArray()[i]); ++ } ++ message->SetList(value); ++ break; ++ } ++ case NWebValue::Type::DOUBLEARRAY: { ++ CefRefPtr value = CefListValue::Create(); ++ for (size_t i = 0; i < data->GetDoubleArray().size(); i++) { ++ value->SetDouble(i, data->GetDoubleArray()[i]); ++ } ++ message->SetList(value); ++ break; ++ } ++ ++ case NWebValue::Type::INT64ARRAY: { ++ CefRefPtr value = CefListValue::Create(); ++ for (size_t i = 0; i < data->GetInt64Array().size(); i++) { ++ value->SetInt(i, data->GetInt64Array()[i]); ++ } ++ message->SetList(value); ++ break; ++ } ++ ++ case NWebValue::Type::ERROR: { ++ CefRefPtr dict = CefDictionaryValue::Create(); ++ dict->SetString("Error.name", data->GetErrName()); ++ dict->SetString("Error.message", data->GetErrMsg()); ++ message->SetDictionary(dict); ++ break; ++ } ++ ++ default: { ++ LOG(ERROR) << "PostPortMessage not support type" << (int)data->GetType(); ++ break; ++ } ++ } ++} ++ + void NWebDelegate::PostPortMessage(std::string& portHandle, std::shared_ptr data) { + if (!GetBrowser().get()) { + LOG(ERROR) << "JSAPI PostPortMessage can not get browser"; +@@ -853,14 +1046,9 @@ void NWebDelegate::PostPortMessage(std::string& portHandle, std::shared_ptr message = CefValue::Create(); +- if (data->GetType() == NWebValue::Type::STRING) { +- message->SetString(data->GetString()); +- } else if (data->GetType() == NWebValue::Type::BINARY) { +- std::vector vecBinary = data->GetBinary(); +- CefRefPtr value = CefBinaryValue::Create(vecBinary.data(), vecBinary.size()); +- message->SetBinary(value); +- } ++ ConvertNWebMsgToCefValue(data, message); + + GetBrowser()->GetHost()->PostPortMessage(handleCef, message); + } +@@ -982,7 +1170,7 @@ const CefRefPtr NWebDelegate::GetBrowser() const { + } + + bool NWebDelegate::IsReady() { +- return GetBrowser() != nullptr; ++ return is_ready_ || GetBrowser() != nullptr; + } + + void NWebDelegate::RequestVisitedHistory() { +@@ -1251,4 +1439,138 @@ bool NWebDelegate::RestoreWebState(WebState state) { + auto web_state = CefBinaryValue::Create(state->data(), state->size()); + return GetBrowser()->GetHost()->RestoreWebState(web_state); + } ++ ++bool NWebDelegate::GetCertChainDerData(std::vector& certChainData, bool isSingleCert) { ++ if (!GetBrowser().get()) { ++ LOG(ERROR) << "GetCertChainDerData failed, browser is null"; ++ return false; ++ } ++ ++ CefRefPtr navigation = GetBrowser()->GetHost()->GetVisibleNavigationEntry(); ++ if (!navigation) { ++ LOG(ERROR) << "GetCertChainDerData failed, visible navigation entry is null"; ++ return false; ++ } ++ ++ CefRefPtr ssl = navigation->GetSSLStatus(); ++ if (!ssl) { ++ LOG(ERROR) << "GetCertChainDerData failed, ssl status is null"; ++ return false; ++ } ++ ++ CefRefPtr cert = ssl->GetX509Certificate(); ++ if (!cert) { ++ LOG(ERROR) << "GetCertChainDerData failed, cef x509cert is null"; ++ return false; ++ } ++ ++ return GetCertChainDerDataInner(cert, certChainData, isSingleCert); ++} ++ ++bool NWebDelegate::GetCertChainDerDataInner(CefRefPtr cert, ++ std::vector& certChainData, bool isSingleCert) { ++ CefX509Certificate::IssuerChainBinaryList der_chain_list; ++ cert->GetDEREncodedIssuerChain(der_chain_list); ++ der_chain_list.insert(der_chain_list.begin(), cert->GetDEREncoded()); ++ ++ LOG(INFO) << "GetCertChainDerData der_chain_list size = " << der_chain_list.size(); ++ for (size_t i = 0U; i < der_chain_list.size(); ++i) { ++ if (!der_chain_list[i].get()) { ++ LOG(ERROR) << "GetCertChainDerDataInner failed, der chain data is null, index = " << i; ++ continue; ++ } ++ ++ const size_t cert_data_size = der_chain_list[i]->GetSize(); ++ std::string cert_data_item; ++ cert_data_item.resize(cert_data_size); ++ der_chain_list[i]->GetData(const_cast(cert_data_item.data()), cert_data_size, 0); ++ certChainData.emplace_back(cert_data_item); ++ if (isSingleCert) { ++ LOG(INFO) << "get only one certificate of the current website"; ++ break; ++ } ++ } ++ ++ if (certChainData.size() == 0) { ++ LOG(INFO) << "GetCertChainDerData, no certificate data"; ++ return false; ++ } ++ ++ return true; ++} ++ ++void NWebDelegate::SetAudioMuted(bool muted) { ++ if (GetBrowser() == nullptr || GetBrowser()->GetHost() == nullptr) { ++ LOG(ERROR) << "SetAudioMuted can not get browser"; ++ return; ++ } ++ ++ GetBrowser()->GetHost()->SetAudioMuted(muted); ++} ++ ++void NWebDelegate::NotifyPopupWindowResult(bool result) { ++ if (handler_delegate_) { ++ handler_delegate_->NotifyPopupWindowResult(result); ++ } ++} ++ ++#if defined (OHOS_NWEB_EX) ++void NWebDelegate::SetForceEnableZoom(bool forceEnableZoom) { ++ LOG(INFO) << "NWebDelegate::SetForceEnableZoom " << forceEnableZoom; ++ if (GetBrowser().get()) { ++ GetBrowser()->SetForceEnableZoom(forceEnableZoom); ++ } ++} ++ ++bool NWebDelegate::GetForceEnableZoom() { ++ if (GetBrowser().get()) { ++ return GetBrowser()->GetForceEnableZoom(); ++ } ++ return false; ++} ++ ++void NWebDelegate::SelectAndCopy() { ++ if (GetBrowser().get()) { ++ GetBrowser()->SelectAndCopy(); ++ } ++} ++ ++bool NWebDelegate::ShouldShowFreeCopy() { ++ if (GetBrowser().get()) { ++ return GetBrowser()->ShouldShowFreeCopy(); ++ } ++ return false; ++} ++ ++void NWebDelegate::SetEnableBlankTargetPopupIntercept(bool enableBlankTargetPopup) { ++ LOG(INFO) << "NWebDelegate::SetEnableBlankTargetPopupIntercept " << enableBlankTargetPopup; ++ if (GetBrowser().get()) { ++ GetBrowser()->SetEnableBlankTargetPopupIntercept(enableBlankTargetPopup); ++ } ++} ++#endif ++ ++void NWebDelegate::SetShouldFrameSubmissionBeforeDraw(bool should) { ++ if (GetBrowser().get()) { ++ GetBrowser()->GetHost()->SetShouldFrameSubmissionBeforeDraw(should); ++ } ++} ++ ++void NWebDelegate::SetAudioResumeInterval(int32_t resumeInterval) { ++ if (GetBrowser() == nullptr || GetBrowser()->GetHost() == nullptr) { ++ LOG(ERROR) << "SetAudioResumeInterval can not get browser"; ++ return; ++ } ++ ++ GetBrowser()->GetHost()->SetAudioResumeInterval(resumeInterval); ++} ++ ++void NWebDelegate::SetAudioExclusive(bool audioExclusive) { ++ if (GetBrowser() == nullptr || GetBrowser()->GetHost() == nullptr) { ++ LOG(ERROR) << "SetAudioExclusive can not get browser"; ++ return; ++ } ++ ++ GetBrowser()->GetHost()->SetAudioExclusive(audioExclusive); ++} + } // namespace OHOS::NWeb +diff --git a/src/ohos_nweb/src/cef_delegate/nweb_delegate.h b/src/ohos_nweb/src/cef_delegate/nweb_delegate.h +index a188933f623..44945e1433f +--- a/src/ohos_nweb/src/cef_delegate/nweb_delegate.h ++++ b/src/ohos_nweb/src/cef_delegate/nweb_delegate.h +@@ -37,7 +37,7 @@ class NWebDelegate : public NWebDelegateInterface, public virtual CefRefCount { + public: + NWebDelegate(int argc, const char* argv[]); + ~NWebDelegate(); +- bool Init(bool is_enhance_surface, void* window); ++ bool Init(bool is_enhance_surface, void* window, bool popup); + + bool IsReady() override; + void OnDestroy(bool is_close_all) override; +@@ -54,16 +54,27 @@ class NWebDelegate : public NWebDelegateInterface, public virtual CefRefCount { + void RegisterRenderCb( + std::function render_update_cb) override; + +- void SetInputMethodClient( +- CefRefPtr client) override; ++ void SetInputMethodClient(CefRefPtr client) override; + + void Resize(uint32_t width, uint32_t height) override; +- void OnTouchPress(int32_t id, double x, double y) override; +- void OnTouchRelease(int32_t id, double x, double y) override; +- void OnTouchMove(int32_t id, double x, double y) override; ++ void OnTouchPress(int32_t id, ++ double x, ++ double y, ++ bool from_overlay) override; ++ void OnTouchRelease(int32_t id, ++ double x, ++ double y, ++ bool from_overlay) override; ++ void OnTouchMove(int32_t id, ++ double x, ++ double y, ++ bool from_overlay) override; + void OnTouchCancel() override; + bool SendKeyEvent(int32_t keyCode, int32_t keyAction) override; +- void SendMouseWheelEvent(double x, double y, double deltaX, double deltaY) override; ++ void SendMouseWheelEvent(double x, ++ double y, ++ double deltaX, ++ double deltaY) override; + void SendMouseEvent(int x, int y, int button, int action, int count) override; + void NotifyScreenInfoChanged(RotationType rotation, + OrientationType orientation) override; +@@ -87,7 +98,8 @@ class NWebDelegate : public NWebDelegateInterface, public virtual CefRefCount { + void ExecuteJavaScript(const std::string& code) const override; + void ExecuteJavaScript( + const std::string& code, +- std::shared_ptr> callback) const override; ++ std::shared_ptr>> callback, ++ bool extention) const override; + void PutBackgroundColor(int color) const override; + void InitialScale(float scale) const override; + void OnPause() override; +@@ -95,7 +107,9 @@ class NWebDelegate : public NWebDelegateInterface, public virtual CefRefCount { + std::shared_ptr GetPreference() const override; + std::string Title() override; + void CreateWebMessagePorts(std::vector& ports) override; +- void PostWebMessage(std::string& message, std::vector& ports, std::string& targetUri) override; ++ void PostWebMessage(std::string& message, ++ std::vector& ports, ++ std::string& targetUri) override; + void ClosePort(std::string& port_handle) override; + void PostPortMessage(std::string& port_handle, std::shared_ptr data) override; + void SetPortMessageCallback(std::string& port_handle, +@@ -168,6 +182,21 @@ class NWebDelegate : public NWebDelegateInterface, public virtual CefRefCount { + void SlideScroll(float vx, float vy) override; + WebState SerializeWebState() override; + bool RestoreWebState(WebState state) override; ++ bool GetCertChainDerData(std::vector& certChainData, bool isSingleCert) override; ++ void SetAudioMuted(bool muted) override; ++ void SetShouldFrameSubmissionBeforeDraw(bool should) override; ++ void SetAudioResumeInterval(int32_t resumeInterval) override; ++ void SetAudioExclusive(bool audioExclusive) override; ++ ++#if defined (OHOS_NWEB_EX) ++ void SetForceEnableZoom(bool forceEnableZoom) override; ++ bool GetForceEnableZoom() override; ++ void SelectAndCopy() override; ++ bool ShouldShowFreeCopy() override; ++ void SetEnableBlankTargetPopupIntercept(bool enableBlankTargetPopup) override; ++#endif ++ ++ void NotifyPopupWindowResult(bool result) override; + + public: + int argc_; +@@ -175,14 +204,18 @@ class NWebDelegate : public NWebDelegateInterface, public virtual CefRefCount { + + private: + void RunMessageLoop(); +- void InitializeCef(std::string url, bool is_enhance_surface, void* window); ++ void InitializeCef(std::string url, bool is_enhance_surface, void* window, bool popup); + const CefRefPtr GetBrowser() const; ++ void ConvertNWebMsgToCefValue(std::shared_ptr data, CefRefPtr message); + void RequestVisitedHistory(); + void SetVirtualPixelRatio(float ratio); ++ bool GetCertChainDerDataInner(CefRefPtr cert, ++ std::vector& certChainData, bool isSingleCert); ++ bool HasBackgroundColorWithInit(int32_t& backgroundColor); + + private: +- float zoom_in_factor_ = 2.0; +- float zoom_out_factor_ = -2.0; ++ float zoom_in_factor_ = 1.25f; ++ float zoom_out_factor_ = 0.8f; + float default_virtual_pixel_ratio_ = 2.0; + float intial_scale_ = 0; + bool has_requested_visited_history = false; +@@ -192,10 +225,10 @@ class NWebDelegate : public NWebDelegateInterface, public virtual CefRefCount { + std::shared_ptr event_handler_ = nullptr; + std::shared_ptr preference_delegate_ = nullptr; + std::shared_ptr find_delegate_ = nullptr; +- std::unique_ptr +- display_manager_adapter_ = nullptr; +- std::shared_ptr +- display_listener_ = nullptr; ++ std::unique_ptr display_manager_adapter_ = ++ nullptr; ++ std::shared_ptr display_listener_ = ++ nullptr; + // Members only accessed on the main thread. + bool hidden_ = false; + uint32_t width_ = 0; +@@ -204,6 +237,7 @@ class NWebDelegate : public NWebDelegateInterface, public virtual CefRefCount { + uint32_t nweb_id_; + #endif + bool is_enhance_surface_ = false; ++ bool is_ready_ = false; + }; + } // namespace OHOS::NWeb + #endif +diff --git a/src/ohos_nweb/src/cef_delegate/nweb_event_handler.cc b/src/ohos_nweb/src/cef_delegate/nweb_event_handler.cc +index 81e11228d08..428295788fb +--- a/src/ohos_nweb/src/cef_delegate/nweb_event_handler.cc ++++ b/src/ohos_nweb/src/cef_delegate/nweb_event_handler.cc +@@ -20,12 +20,14 @@ + #include "cef/include/internal/cef_types.h" + #include "cef/include/internal/cef_types_wrappers.h" + ++#include "base/trace_event/common/trace_event_common.h" + #include "ui/events/keycodes/keyboard_code_conversion_x.h" + #include "ui/events/keycodes/keysym_to_unicode.h" + + namespace OHOS::NWeb { + + constexpr double MAX_ZOOM_FACTOR = 10.0; ++constexpr double MIN_ZOOM_FACTOR = -10.0; + constexpr double ZOOM_FACTOR = 2.0; + + // static +@@ -38,7 +40,18 @@ std::shared_ptr NWebEventHandler::Create() { + return event_handler; + } + ++NWebEventHandler::NWebEventHandler() { ++ mmi_adapter_ = OHOS::NWeb::OhosAdapterHelper::GetInstance().CreateMMIAdapter(); ++ if (mmi_adapter_ == nullptr) { ++ LOG(ERROR) << "display_manager_adapter is nullptr"; ++ return; ++ } ++} ++ + void NWebEventHandler::OnDestroy() { ++ if (mmi_id_ > 0 && mmi_adapter_ != nullptr) { ++ mmi_adapter_->UnregisterMMIInputListener(mmi_id_); ++ } + browser_ = nullptr; + } + +@@ -46,7 +59,10 @@ void NWebEventHandler::SetBrowser(CefRefPtr browser) { + browser_ = browser; + } + +-void NWebEventHandler::OnTouchPress(int32_t id, double x, double y) { ++void NWebEventHandler::OnTouchPress(int32_t id, double x, double y, bool from_overlay) { ++ TRACE_EVENT0("input", ++ "NWebEventHandler::OnTouchPress sliding response begin"); ++ LOG(DEBUG) << "NWebEventHandler::OnTouchPress sliding response begin"; + CefTouchEvent touch_pressed; + touch_pressed.type = CEF_TET_PRESSED; + touch_pressed.pointer_type = CEF_POINTER_TYPE_TOUCH; +@@ -54,12 +70,16 @@ void NWebEventHandler::OnTouchPress(int32_t id, double x, double y) { + touch_pressed.x = x; + touch_pressed.y = y; + touch_pressed.modifiers = EVENTFLAG_NONE; ++ touch_pressed.from_overlay = from_overlay; + if (browser_ && browser_->GetHost()) { + browser_->GetHost()->SendTouchEvent(touch_pressed); + } + } + +-void NWebEventHandler::OnTouchMove(int32_t id, double x, double y) { ++void NWebEventHandler::OnTouchMove(int32_t id, ++ double x, ++ double y, ++ bool from_overlay) { + CefTouchEvent touch_move; + touch_move.type = CEF_TET_MOVED; + touch_move.pointer_type = CEF_POINTER_TYPE_TOUCH; +@@ -67,12 +87,16 @@ void NWebEventHandler::OnTouchMove(int32_t id, double x, double y) { + touch_move.x = x; + touch_move.y = y; + touch_move.modifiers = EVENTFLAG_NONE; ++ touch_move.from_overlay = from_overlay; + if (browser_ && browser_->GetHost()) { + browser_->GetHost()->SendTouchEvent(touch_move); + } + } + +-void NWebEventHandler::OnTouchRelease(int32_t id, double x, double y) { ++void NWebEventHandler::OnTouchRelease(int32_t id, ++ double x, ++ double y, ++ bool from_overlay) { + CefTouchEvent touch_end; + touch_end.type = CEF_TET_RELEASED; + touch_end.pointer_type = CEF_POINTER_TYPE_TOUCH; +@@ -80,6 +104,7 @@ void NWebEventHandler::OnTouchRelease(int32_t id, double x, double y) { + touch_end.x = x; + touch_end.y = y; + touch_end.modifiers = EVENTFLAG_NONE; ++ touch_end.from_overlay = from_overlay; + if (browser_ && browser_->GetHost()) { + browser_->GetHost()->SendTouchEvent(touch_end); + } +@@ -93,7 +118,24 @@ void NWebEventHandler::OnTouchCancel() { + } + } + ++void NWebEventHandler::SendKeyEventFromMMI(int32_t keyCode, int32_t keyAction) { ++ if (!isFocus_ || !NWebInputDelegate::IsMMIKeyEvent(keyCode)) { ++ return; ++ } ++ LOG(DEBUG) << "SendKeyEventFromMMI keyCode = " << keyCode << " keyAction = " << keyAction; ++ SendKeyEvent(keyCode, keyAction); ++} ++ ++bool NWebEventHandler::SendKeyEventFromAce(int32_t keyCode, int32_t keyAction) { ++ if (mmi_id_ >= 0 && NWebInputDelegate::IsMMIKeyEvent(keyCode)) { ++ return true; ++ } ++ LOG(DEBUG) << "SendKeyEventFromAce keyCode = " << keyCode << " keyAction = " << keyAction; ++ return SendKeyEvent(keyCode, keyAction); ++} ++ + bool NWebEventHandler::SendKeyEvent(int32_t keyCode, int32_t keyAction) { ++ LOG(DEBUG) << "SendKeyEvent keyCode = " << keyCode << " keyAction = " << keyAction; + CefKeyEvent keyEvent; + input_delegate_.SetModifiers(keyCode, keyAction); + keyEvent.windows_key_code = +@@ -138,19 +180,30 @@ void NWebEventHandler::SendMouseWheelEvent(double x, + if ((mouseEvent.modifiers & EVENTFLAG_CONTROL_DOWN) && (deltaY != 0)) { + double curFactor = browser_->GetHost()->GetZoomLevel(); + double tempZoomFactor = deltaY < 0 ? curFactor + ZOOM_FACTOR : curFactor - ZOOM_FACTOR; +- if (tempZoomFactor > MAX_ZOOM_FACTOR || tempZoomFactor < 0) { ++ if (tempZoomFactor > MAX_ZOOM_FACTOR || tempZoomFactor < MIN_ZOOM_FACTOR) { + LOG(ERROR) << "The mouse wheel event can no longer be zoomed in or out."; + return; + } + browser_->GetHost()->SetZoomLevel(tempZoomFactor); ++ return; ++ } ++ double horizontalDelta; ++ double verticalDelta; ++ if (mmi_id_ > 0 && (mouseEvent.modifiers & EVENTFLAG_SHIFT_DOWN)) { ++ horizontalDelta = deltaY * input_delegate_.GetMouseWheelRatio(); ++ verticalDelta = deltaX * input_delegate_.GetMouseWheelRatio(); + } else { +- browser_->GetHost()->SendMouseWheelEvent( +- mouseEvent, deltaX * input_delegate_.GetMouseWheelRatio(), +- deltaY * input_delegate_.GetMouseWheelRatio()); ++ horizontalDelta = deltaX * input_delegate_.GetMouseWheelRatio(); ++ verticalDelta = deltaY * input_delegate_.GetMouseWheelRatio(); + } ++ browser_->GetHost()->SendMouseWheelEvent(mouseEvent, horizontalDelta, verticalDelta); + } + +-void NWebEventHandler::SendMouseEvent(int x, int y, int button, int action, int count) { ++void NWebEventHandler::SendMouseEvent(int x, ++ int y, ++ int button, ++ int action, ++ int count) { + CefMouseEvent mouseEvent; + mouseEvent.x = x; + mouseEvent.y = y; +@@ -160,7 +213,8 @@ void NWebEventHandler::SendMouseEvent(int x, int y, int button, int action, int + + if (browser_ && browser_->GetHost()) { + if (NWebInputDelegate::IsMouseDown(action)) { +- browser_->GetHost()->SendMouseClickEvent(mouseEvent, buttonType, false, count); ++ browser_->GetHost()->SendMouseClickEvent(mouseEvent, buttonType, false, ++ count); + } else if (NWebInputDelegate::IsMouseUp(action)) { + browser_->GetHost()->SendMouseClickEvent(mouseEvent, buttonType, true, 1); + } else if (NWebInputDelegate::IsMouseMove(action)) { +diff --git a/src/ohos_nweb/src/cef_delegate/nweb_event_handler.h b/src/ohos_nweb/src/cef_delegate/nweb_event_handler.h +index 6df938dccae..01d8076620e +--- a/src/ohos_nweb/src/cef_delegate/nweb_event_handler.h ++++ b/src/ohos_nweb/src/cef_delegate/nweb_event_handler.h +@@ -19,31 +19,38 @@ + #include "cef/include/cef_client.h" + #include "nweb_input_delegate.h" + #include "nweb_inputmethod_handler.h" ++#include "nweb_key_event.h" ++#include "ohos_adapter_helper.h" + + namespace OHOS::NWeb { ++ + class NWebEventHandler { + public: + static std::shared_ptr Create(); + +- NWebEventHandler() = default; ++ NWebEventHandler(); + ~NWebEventHandler() = default; + void OnDestroy(); + + void SetBrowser(CefRefPtr browser); +- +- void OnTouchPress(int32_t id, double x, double y); +- void OnTouchMove(int32_t id, double x, double y); +- void OnTouchRelease(int32_t id, double x, double y); ++ void SetIsFocus(bool isFocus) { isFocus_ = isFocus; } ++ void OnTouchPress(int32_t id, double x, double y, bool from_overlay); ++ void OnTouchMove(int32_t id, double x, double y, bool from_overlay); ++ void OnTouchRelease(int32_t id, double x, double y, bool from_overlay); + void OnTouchCancel(); +- void OnKeyBack(); +- bool SendKeyEvent(int32_t keyCode, int32_t keyAction); ++ bool SendKeyEventFromAce(int32_t keyCode, int32_t keyAction); + void SendMouseWheelEvent(double x, double y, double deltaX, double deltaY); + void SendMouseEvent(int x, int y, int button, int action, int count); + + private: ++ void SendKeyEventFromMMI(int32_t keyCode, int32_t keyAction); ++ bool SendKeyEvent(int32_t keyCode, int32_t keyAction); + bool IsCharInputEvent(CefKeyEvent& keyEvent); + CefRefPtr browser_ = nullptr; + NWebInputDelegate input_delegate_; ++ std::unique_ptr mmi_adapter_ = nullptr; ++ int32_t mmi_id_ = -1; ++ bool isFocus_ = false; + }; + } // namespace OHOS::NWeb + +diff --git a/src/ohos_nweb/src/cef_delegate/nweb_file_selector_params_impl.cc b/src/ohos_nweb/src/cef_delegate/nweb_file_selector_params_impl.cc +index 0ab1c50d60a..36006311a98 +--- a/src/ohos_nweb/src/cef_delegate/nweb_file_selector_params_impl.cc ++++ b/src/ohos_nweb/src/cef_delegate/nweb_file_selector_params_impl.cc +@@ -63,6 +63,9 @@ void FileSelectorCallbackImpl::OnReceiveValue(std::vector& value) { + callback_->Cancel(); + } else { + for (auto& c : value) { ++ if (c.empty()) { ++ continue; ++ } + file_path_.push_back(CefString(c)); + } + callback_->Continue(0, file_path_); +diff --git a/src/ohos_nweb/src/cef_delegate/nweb_geolocation_callback.cc b/src/ohos_nweb/src/cef_delegate/nweb_geolocation_callback.cc +index 3a970446502..f27d5a35720 +--- a/src/ohos_nweb/src/cef_delegate/nweb_geolocation_callback.cc ++++ b/src/ohos_nweb/src/cef_delegate/nweb_geolocation_callback.cc +@@ -24,6 +24,10 @@ void NWebGeolocationCallback::GeolocationCallbackInvoke( + const std::string& origin, + bool allow, + bool retain) { ++ if (!browser_) { ++ LOG(ERROR) << "GeolocationCallbackInvoke browser_ is nullptr"; ++ return; ++ } + if (retain) { + if (allow) { + browser_->GetGeolocationPermissions()->Enabled(origin); +diff --git a/src/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc b/src/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc +index 3ee35ae243d..2e7719aaed4 +--- a/src/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc ++++ b/src/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc +@@ -15,7 +15,6 @@ + + #include "nweb_handler_delegate.h" + +-#include + #include + + #include "base/bind.h" +@@ -182,6 +181,7 @@ char* CopyCefStringToChar(const CefString& str) { + return result; + } + ++const char kOffScreenFrameRate[] = "off-screen-frame-rate"; + } // namespace + + // static +@@ -221,7 +221,7 @@ NWebHandlerDelegate::NWebHandlerDelegate( + access_fail_count_ = 0; + #endif + if (!is_enhance_surface_) { +- window_ = reinterpret_cast(window); ++ window_ = window; + } + } + +@@ -341,6 +341,10 @@ CefRefPtr NWebHandlerDelegate::GetContextMenuHandler() { + return this; + } + ++CefRefPtr NWebHandlerDelegate::GetMediaHandler() { ++ return this; ++} ++ + CefRefPtr NWebHandlerDelegate::GetCookieAccessFilter( + CefRefPtr browser, + CefRefPtr frame, +@@ -379,13 +383,34 @@ CefRefPtr NWebHandlerDelegate::GetFindHandler() { + CefRefPtr NWebHandlerDelegate::GetKeyboardHandler() { + return this; + } ++ ++CefRefPtr NWebHandlerDelegate::GetPrintHandler() { ++ return this; ++} + /* CefClient methods end */ + + /* CefLifeSpanHandler methods begin */ + void NWebHandlerDelegate::OnAfterCreated(CefRefPtr browser) { +- LOG(INFO) << "NWebHandlerDelegate::OnAfterCreated"; ++ LOG(INFO) << "NWebHandlerDelegate::OnAfterCreated IsPopup " << browser->IsPopup(); + CEF_REQUIRE_UI_THREAD(); +- ++ if (!main_browser_ && browser->IsPopup()) { ++ main_browser_ = browser; ++ if (preference_delegate_.get()) { ++ preference_delegate_->SetBrowser(main_browser_); ++ preference_delegate_->WebPreferencesChanged(); ++ } ++ if (event_handler_.get()) { ++ event_handler_->SetBrowser(main_browser_); ++ } ++ if (main_browser_ && main_browser_->GetHost()) { ++ if (preference_delegate_.get()) { ++ main_browser_->GetHost()->PutUserAgent(preference_delegate_->UserAgent()); ++ main_browser_->GetHost()->SetBackgroundColor(preference_delegate_->GetBackgroundColor()); ++ } ++ main_browser_->GetHost()->SetNativeWindow(window_); ++ } ++ return; ++ } + if (!main_browser_) { + main_browser_ = browser; + if (event_handler_.get()) { +@@ -433,7 +458,9 @@ void NWebHandlerDelegate::OnBeforeClose(CefRefPtr browser) { + releaseSurfaceListener_->ReleaseSurface(); + } + } else { +- DestoryNativeWindow(window_); ++ OHOS::NWeb::OhosAdapterHelper::GetInstance() ++ .GetWindowAdapterInstance() ++ .DestroyNativeWindow(window_); + window_ = nullptr; + } + +@@ -448,11 +475,25 @@ void NWebHandlerDelegate::OnBeforeClose(CefRefPtr browser) { + } + } + ++void NWebHandlerDelegate::NotifyPopupWindowResult(bool result) { ++ LOG(INFO) << "NWebHandlerDelegate::NotifyPopupWindowResult result: " << result; ++ if (!popupWindowCallback_) { ++ return; ++ } ++ if (result) { ++ popupWindowCallback_->Continue(); ++ } else { ++ popupWindowCallback_->Cancel(); ++ } ++ popupWindowCallback_ = nullptr; ++} ++ + bool NWebHandlerDelegate::OnPreBeforePopup(CefRefPtr browser, + CefRefPtr frame, + const CefString& target_url, + CefLifeSpanHandler::WindowOpenDisposition target_disposition, +- bool user_gesture) { ++ bool user_gesture, ++ CefRefPtr callback) { + LOG(INFO) << "NWebHandlerDelegate::OnPreBeforePopup"; + CEF_REQUIRE_UI_THREAD(); + if (!preference_delegate_.get() || !preference_delegate_->IsMultiWindowAccess()) { +@@ -461,11 +502,11 @@ bool NWebHandlerDelegate::OnPreBeforePopup(CefRefPtr browser, + if (nweb_handler_ == nullptr) { + return true; + } +- + switch (target_disposition) { + case WOD_NEW_WINDOW: + case WOD_NEW_POPUP: { + popIndex_++; ++ popupWindowCallback_ = callback; + std::shared_ptr handler = std::make_shared(popIndex_, true); + nweb_handler_->OnWindowNewByJS(target_url, true, user_gesture, handler); + return false; +@@ -473,9 +514,10 @@ bool NWebHandlerDelegate::OnPreBeforePopup(CefRefPtr browser, + case WOD_NEW_BACKGROUND_TAB: + case WOD_NEW_FOREGROUND_TAB: { + popIndex_++; ++ popupWindowCallback_ = callback; + std::shared_ptr handler = std::make_shared(popIndex_, true); + nweb_handler_->OnWindowNewByJS(target_url, false, user_gesture, handler); +- return true; ++ return false; + } + default: + break; +@@ -499,35 +541,49 @@ bool NWebHandlerDelegate::OnBeforePopup( + LOG(INFO) << "NWebHandlerDelegate::OnBeforePopup"; + CEF_REQUIRE_UI_THREAD(); + if (!preference_delegate_.get()) { ++ LOG(ERROR) << "NWebHandlerDelegate::OnBeforePopup preference_delegate is null"; + return true; + } + if (preference_delegate_->IsMultiWindowAccess()) { + switch (target_disposition) { + case WOD_NEW_WINDOW: +- case WOD_NEW_POPUP: { ++ case WOD_NEW_POPUP: ++ case WOD_NEW_BACKGROUND_TAB: ++ case WOD_NEW_FOREGROUND_TAB: { + if (nweb_handler_ == nullptr) { ++ LOG(ERROR) << "NWebHandlerDelegate::OnBeforePopup nweb_handler is null"; + return true; + } + std::shared_ptr handler = + std::make_shared(popIndex_, false); + nweb_handler_->OnWindowNewByJS(target_url, true, user_gesture, handler); + NWebImpl* nweb = NWebImpl::FromID(handler->GetNWebHandlerId()); +- if (nweb) { +- client = nweb->GetCefClient(); +- if (client) { +- return false; +- } ++ if (!nweb) { ++ LOG(ERROR) << "NWebHandlerDelegate::OnBeforePopup nweb is null"; ++ return true; + } +- return true; +- } +- case WOD_NEW_BACKGROUND_TAB: +- case WOD_NEW_FOREGROUND_TAB: { +- if (nweb_handler_ != nullptr) { +- std::shared_ptr handler = +- std::make_shared(popIndex_, false); +- nweb_handler_->OnWindowNewByJS(target_url, false, user_gesture, handler); ++ client = nweb->GetCefClient(); ++ if (!client) { ++ LOG(ERROR) << "NWebHandlerDelegate::OnBeforePopup client is null"; ++ return true; + } +- return true; ++ auto preference = nweb->GetPreference(); ++ if (preference) { ++ CefRefPtr command_line = ++ CefCommandLine::GetGlobalCommandLine(); ++ if (command_line->HasSwitch(kOffScreenFrameRate)) { ++ settings.windowless_frame_rate = ++ atoi(command_line->GetSwitchValue(kOffScreenFrameRate) ++ .ToString() ++ .c_str()); ++ } ++ static_cast(preference.get())->ComputeBrowserSettings(settings); ++ } else { ++ preference_delegate_->ComputeBrowserSettings(settings); ++ } ++ CefWindowHandle handle = kNullWindowHandle; ++ window_info.SetAsWindowless(handle); ++ return false; + } + default: + break; +@@ -606,6 +662,15 @@ void NWebHandlerDelegate::OnPageVisible(CefRefPtr browser, + } + } + ++void NWebHandlerDelegate::OnFirstContentfulPaint(long navigationStartTick, ++ long firstContentfulPaintMs) { ++ LOG(INFO) << "NWebHandlerDelegate::OnFirstContentfulPaint"; ++ if (nweb_handler_ != nullptr) { ++ nweb_handler_->OnFirstContentfulPaint(navigationStartTick, ++ firstContentfulPaintMs); ++ } ++} ++ + void NWebHandlerDelegate::OnDataResubmission(CefRefPtr browser, + CefRefPtr callback) { + LOG(INFO) << "NWebHandlerDelegate::OnDataResubmission"; +@@ -738,6 +803,12 @@ void NWebHandlerDelegate::OnRefreshAccessedHistory( + nweb_handler_->OnRefreshAccessedHistory(url.ToString(), isReload); + } + ++void NWebHandlerDelegate::OnAudioStateChanged(CefRefPtr browser, ++ bool audible) { ++ if (nweb_handler_ != nullptr) { ++ nweb_handler_->OnAudioStateChanged(audible); ++ } ++} + /* CefLoadHandler methods end */ + + /* CefRequestHandler methods begin */ +@@ -748,13 +819,22 @@ bool NWebHandlerDelegate::OnBeforeBrowse(CefRefPtr browser, + bool is_redirect) { + LOG(INFO) << "NWebHandlerDelegate::OnBeforeBrowse"; + (void)(browser); +- (void)(frame); +- (void)(user_gesture); +- (void)(is_redirect); + ++ if (!request) { ++ LOG(ERROR) << "NWebHandlerDelegate::OnBeforeBrowse request is null"; ++ return false; ++ } ++ ++ CefRequest::HeaderMap cef_request_headers; ++ request->GetHeaderMap(cef_request_headers); ++ std::map request_headers; ++ ConvertMapToHeaderMap(cef_request_headers, request_headers); ++ std::shared_ptr nweb_request = ++ std::make_shared( ++ request->GetMethod().ToString(), request_headers, ++ request->GetURL().ToString(), user_gesture, frame->IsMain(), is_redirect); + if (nweb_handler_ != nullptr) { +- return nweb_handler_->OnHandleInterceptUrlLoading( +- request->GetURL().ToString()); ++ return nweb_handler_->OnHandleInterceptUrlLoading(nweb_request); + } + return false; + } +@@ -947,7 +1027,7 @@ bool NWebHandlerDelegate::OnPreKeyEvent(CefRefPtr browser, + const CefKeyEvent& event, + CefEventHandle os_event, + bool* is_keyboard_shortcut) { +- LOG(INFO) << "NWebHandlerDelegate::OnPreKeyEvent type:" << event.type ++ LOG(DEBUG) << "NWebHandlerDelegate::OnPreKeyEvent type:" << event.type + << ", win:" << event.windows_key_code; + if (nweb_handler_ != nullptr) { + int32_t action = NWebInputDelegate::CefConverter("ohoskeyaction", event.type); +@@ -969,7 +1049,7 @@ bool NWebHandlerDelegate::OnPreKeyEvent(CefRefPtr browser, + bool NWebHandlerDelegate::OnKeyEvent(CefRefPtr browser, + const CefKeyEvent& event, + CefEventHandle os_event) { +- LOG(INFO) << "NWebHandlerDelegate::OnKeyEvent type:" << event.type ++ LOG(DEBUG) << "NWebHandlerDelegate::OnKeyEvent type:" << event.type + << ", win:" << event.windows_key_code; + if (nweb_handler_ != nullptr) { + int32_t action = NWebInputDelegate::CefConverter("ohoskeyaction", event.type); +@@ -1019,7 +1099,7 @@ CefRefPtr NWebHandlerDelegate::GetResourceHandler( + std::shared_ptr NWeb_request = + std::make_shared( + request->GetMethod().ToString(), request_headers, +- request->GetURL().ToString(), false, frame->IsMain()); ++ request->GetURL().ToString(), false, request->IsMainFrame()); + std::shared_ptr response; + if (nweb_handler_ != nullptr) { + response = nweb_handler_->OnHandleInterceptRequest(NWeb_request); +@@ -1033,6 +1113,46 @@ CefRefPtr NWebHandlerDelegate::GetResourceHandler( + } + /* CefResourceRequestHandler method end */ + ++/* CefPrintHandler method begin */ ++void NWebHandlerDelegate::OnPrintStart(CefRefPtr browser) { ++ LOG(INFO) << "NWebHandlerDelegate::OnPrintStart"; ++ if (main_browser_ && main_browser_->GetHost()) { ++ main_browser_->GetHost()->Print(); ++ } ++} ++ ++void NWebHandlerDelegate::OnPrintSettings(CefRefPtr browser, ++ CefRefPtr settings, ++ bool get_defaults) { ++ LOG(INFO) << "NWebHandlerDelegate::OnPrintSettings"; ++} ++ ++bool NWebHandlerDelegate::OnPrintDialog(CefRefPtr browser, ++ bool has_selection, ++ CefRefPtr callback) { ++ LOG(INFO) << "NWebHandlerDelegate::OnPrintDialog"; ++ return false; ++} ++ ++bool NWebHandlerDelegate::OnPrintJob(CefRefPtr browser, ++ const CefString& document_name, ++ const CefString& pdf_file_path, ++ CefRefPtr callback) { ++ LOG(INFO) << "NWebHandlerDelegate::OnPrintJob"; ++ return false; ++} ++ ++void NWebHandlerDelegate::OnPrintReset(CefRefPtr browser) { ++ LOG(INFO) << "NWebHandlerDelegate::OnPrintReset"; ++} ++ ++CefSize NWebHandlerDelegate::GetPdfPaperSize(CefRefPtr browser, ++ int device_units_per_inch) { ++ LOG(INFO) << "NWebHandlerDelegate::GetPdfPaperSize"; ++ return CefSize(); ++} ++/* CefPrintHandler method end */ ++ + /* CefDisplayHandler method begin */ + void NWebHandlerDelegate::OnTitleChange(CefRefPtr browser, + const CefString& title) { +@@ -1221,6 +1341,12 @@ bool NWebHandlerDelegate::OnSetFocus(CefRefPtr browser, + focusState_ = true; + nweb_handler_->OnFocus(); + } ++ if (event_handler_ != nullptr) { ++ event_handler_->SetIsFocus(true); ++ } ++ if (render_handler_ != nullptr) { ++ render_handler_->SetFocusStatus(true); ++ } + return false; + } + /* CefFocusHandler method end */ +@@ -1228,9 +1354,8 @@ bool NWebHandlerDelegate::OnSetFocus(CefRefPtr browser, + /* CefPermissionRequest method begin */ + void NWebHandlerDelegate::OnGeolocationShow(const CefString& origin) { + if (nweb_handler_ != nullptr) { +- // lifecycle wrapped by ace WebGeolocationOhos + if (callback_ == nullptr) { +- callback_ = new NWebGeolocationCallback(main_browser_); ++ callback_ = std::make_shared(main_browser_); + } + nweb_handler_->OnGeolocationShow(origin, callback_); + } +@@ -1297,6 +1422,7 @@ bool NWebHandlerDelegate::OnJSDialog(CefRefPtr browser, + + bool NWebHandlerDelegate::OnBeforeUnloadDialog( + CefRefPtr browser, ++ const CefString& url, + const CefString& message_text, + bool is_reload, + CefRefPtr callback) { +@@ -1305,7 +1431,7 @@ bool NWebHandlerDelegate::OnBeforeUnloadDialog( + } + std::shared_ptr js_result = + std::make_shared(callback); +- return nweb_handler_->OnBeforeUnloadByJS(std::string(), message_text, ++ return nweb_handler_->OnBeforeUnloadByJS(url, message_text, + js_result); + } + +@@ -1367,7 +1493,7 @@ void NWebHandlerDelegate::OnSelectPopupMenu( + if (!nweb_handler_ || !render_handler_) { + return; + } +- float ratio = render_handler_->GetVirtualPixelRatio(); ++ float ratio = render_handler_->GetCefDeviceRatio(); + std::shared_ptr param = + std::make_shared(); + if (!param) { +@@ -1417,7 +1543,7 @@ void NWebHandlerDelegate::CopyImageToClipboard(CefRefPtr image) { + int pixel_width = 0; + int pixel_height = 0; + CefRefPtr bitMap = +- image->GetAsBitmap(1, CEF_COLOR_TYPE_BGRA_8888, CEF_ALPHA_TYPE_OPAQUE, ++ image->GetAsBitmap(1, CEF_COLOR_TYPE_RGBA_8888, CEF_ALPHA_TYPE_OPAQUE, + pixel_width, pixel_height); + size_t bitMapSize = bitMap->GetSize(); + uint8_t* data = (uint8_t*)calloc((size_t)bitMapSize, sizeof(uint8_t)); +@@ -1690,6 +1816,8 @@ CefValueType TranslateCefType(NWebValue::Type type) { + return CefValueType::VTYPE_INVALID; + case NWebValue::Type::BINARY: + return CefValueType::VTYPE_BINARY; ++ default: ++ return CefValueType::VTYPE_INVALID; + } + } + +@@ -1737,6 +1865,9 @@ int NWebHandlerDelegate::NotifyJavaScriptResult( + nweb_javascript_callback_->GetJavaScriptResult(value_vector, method, + object_name); + ++ if (!ark_result) { ++ return 1; ++ } + ParseNWebValueToValue(ark_result, result); + return ark_result->error_; + } +@@ -1753,5 +1884,8 @@ bool NWebHandlerDelegate::GetFocusState() { + + void NWebHandlerDelegate::SetFocusState(bool focusState) { + focusState_ = focusState; ++ if (event_handler_ != nullptr) { ++ event_handler_->SetIsFocus(focusState); ++ } + } + } // namespace OHOS::NWeb +diff --git a/src/ohos_nweb/src/cef_delegate/nweb_handler_delegate.h b/src/ohos_nweb/src/cef_delegate/nweb_handler_delegate.h +index 551c62501c4..471331a6bd4 +--- a/src/ohos_nweb/src/cef_delegate/nweb_handler_delegate.h ++++ b/src/ohos_nweb/src/cef_delegate/nweb_handler_delegate.h +@@ -22,6 +22,7 @@ + #include "cef/include/cef_permission_request.h" + #include "cef/include/cef_resource_request_handler.h" + #include "cef/include/cef_dialog_handler.h" ++#include "cef/include/cef_media_handler.h" + + #include "nweb_event_handler.h" + #include "nweb_handler.h" +@@ -59,7 +60,9 @@ class NWebHandlerDelegate : public CefClient, + public CefContextMenuHandler, + public CefFindHandler, + public CefKeyboardHandler, +- public CefCookieAccessFilter { ++ public CefMediaHandler, ++ public CefCookieAccessFilter, ++ public CefPrintHandler { + public: + static CefRefPtr Create( + std::shared_ptr preference_delegate, +@@ -109,6 +112,7 @@ class NWebHandlerDelegate : public CefClient, + CefRefPtr GetJSDialogHandler() override; + CefRefPtr GetDialogHandler() override; + CefRefPtr GetContextMenuHandler() override; ++ CefRefPtr GetMediaHandler() override; + CefRefPtr GetCookieAccessFilter( + CefRefPtr browser, + CefRefPtr frame, +@@ -124,6 +128,7 @@ class NWebHandlerDelegate : public CefClient, + CefRefPtr result) override; + CefRefPtr GetFindHandler() override; + CefRefPtr GetKeyboardHandler() override; ++ CefRefPtr GetPrintHandler() override; + /* CefClient methods end */ + + /* CefLifeSpanHandler methods begin */ +@@ -147,7 +152,8 @@ class NWebHandlerDelegate : public CefClient, + CefRefPtr frame, + const CefString& target_url, + CefLifeSpanHandler::WindowOpenDisposition target_disposition, +- bool user_gesture) override; ++ bool user_gesture, ++ CefRefPtr callback) override; + /* CefLifeSpanHandler methods end */ + + /* CefLoadHandler methods begin */ +@@ -190,6 +196,9 @@ class NWebHandlerDelegate : public CefClient, + const CefString& url, + bool success) override; + ++ void OnFirstContentfulPaint(long navigationStartTick, ++ long firstContentfulPaintMs) override; ++ + void OnDataResubmission(CefRefPtr browser, + CefRefPtr callback) override; + /* CefLoadHandler methods end */ +@@ -328,6 +337,7 @@ class NWebHandlerDelegate : public CefClient, + bool& suppress_message) override; + + bool OnBeforeUnloadDialog(CefRefPtr browser, ++ const CefString& url, + const CefString& message_text, + bool is_reload, + CefRefPtr callback) override; +@@ -408,6 +418,27 @@ class NWebHandlerDelegate : public CefClient, + const CefCookie& cookie) override; + /* CefResourceRequestHandler methods end */ + ++ /* CefMediaHandler methods begin */ ++ void OnAudioStateChanged(CefRefPtr browser, ++ bool audible) override; ++ /* CefMediaHandler methods end */ ++ /* CefPrintHandler method begin */ ++ void OnPrintStart(CefRefPtr browser) override; ++ void OnPrintSettings(CefRefPtr browser, ++ CefRefPtr settings, ++ bool get_defaults) override; ++ bool OnPrintDialog(CefRefPtr browser, ++ bool has_selection, ++ CefRefPtr callback) override; ++ bool OnPrintJob(CefRefPtr browser, ++ const CefString& document_name, ++ const CefString& pdf_file_path, ++ CefRefPtr callback) override; ++ void OnPrintReset(CefRefPtr browser) override; ++ CefSize GetPdfPaperSize(CefRefPtr browser, ++ int device_units_per_inch) override; ++ /* CefPrintHandler method end */ ++ + const std::vector GetVisitedHistory(); + + #if defined(REPORT_SYS_EVENT) +@@ -422,6 +453,8 @@ class NWebHandlerDelegate : public CefClient, + + bool GetFocusState(); + void SetFocusState(bool focusState); ++ ++ void NotifyPopupWindowResult(bool result); + private: + void CopyImageToClipboard(CefRefPtr image); + // List of existing browser windows. Only accessed on the CEF UI thread. +@@ -448,10 +481,9 @@ class NWebHandlerDelegate : public CefClient, + std::shared_ptr + web_app_client_extension_listener_ = nullptr; + +- // lifecycle wrapped by ace WebGeolocationOhos +- NWebGeolocationCallback* callback_ = nullptr; ++ std::shared_ptr callback_ = nullptr; + bool is_enhance_surface_ = false; +- NativeWindow* window_ = nullptr; ++ void* window_ = nullptr; + + CefString image_cache_src_url_; + +@@ -472,6 +504,7 @@ class NWebHandlerDelegate : public CefClient, + #endif + + static int32_t popIndex_; ++ CefRefPtr popupWindowCallback_ = nullptr; + + #if defined(OHOS_NWEB_EX) + bool on_load_start_notified_ = false; +diff --git a/src/ohos_nweb/src/cef_delegate/nweb_input_delegate.cc b/src/ohos_nweb/src/cef_delegate/nweb_input_delegate.cc +index ee7f11ad260..4de835fe7fd +--- a/src/ohos_nweb/src/cef_delegate/nweb_input_delegate.cc ++++ b/src/ohos_nweb/src/cef_delegate/nweb_input_delegate.cc +@@ -16,10 +16,11 @@ + #include "nweb_input_delegate.h" + #include "cef/include/base/cef_logging.h" + #include "cef/include/internal/cef_types_wrappers.h" ++#include "mmi_keyevent_adapter.h" + #include "nweb_inputmethod_handler.h" + + using namespace OHOS::NWeb; +-using namespace OHOS::MMI; ++using OHOS::NWeb::MMIAdapter::KeyEvent; + + namespace OHOS::NWeb { + NWebInputEventHandle NWebInputDelegate::keyEventHandle_; +@@ -33,6 +34,8 @@ const int32_t MIDDLE_BUTTON = 4; + const int32_t BACK_BUTTON = 8; + const int32_t FORWARD_BUTTON = 16; + ++const std::vector mmiKeyEvent {}; ++ + const std::unordered_map keycodeConverter = { + {KeyEvent::KEYCODE_0, ui::VKEY_0}, + {KeyEvent::KEYCODE_1, ui::VKEY_1}, +@@ -467,8 +470,16 @@ uint32_t NWebInputDelegate::GetModifiers(cef_mouse_button_type_t button) { + result |= EVENTFLAG_FORWARD_MOUSE_BUTTON; + break; + default: +- LOG(INFO) << "invalid button type " << button; + break; + } + return result; + } ++ ++bool NWebInputDelegate::IsMMIKeyEvent(int32_t keyCode) { ++ auto item = find(mmiKeyEvent.begin(), mmiKeyEvent.end(), keyCode); ++ if (item == mmiKeyEvent.end()) { ++ return false; ++ } ++ return true; ++} ++ +diff --git a/src/ohos_nweb/src/cef_delegate/nweb_input_delegate.h b/src/ohos_nweb/src/cef_delegate/nweb_input_delegate.h +index 9ab19d09109..e4ef6f66c37 +--- a/src/ohos_nweb/src/cef_delegate/nweb_input_delegate.h ++++ b/src/ohos_nweb/src/cef_delegate/nweb_input_delegate.h +@@ -19,7 +19,6 @@ + #include + #include + #include "cef/include/internal/cef_types.h" +-#include "key_event.h" + #include "nweb_inputevent_handler.h" + #include "ui/events/keycodes/keyboard_codes_posix.h" + +@@ -32,6 +31,7 @@ class NWebInputDelegate { + virtual ~NWebInputDelegate() = default; + static int CefConverter(const std::string keyValue, int input); + static int OhosConverter(const std::string keyValue, int input); ++ static bool IsMMIKeyEvent(int32_t keyCode); + void SetModifiers(int keyCode, int keyAction); + uint32_t GetModifiers(); + uint32_t GetModifiers(cef_mouse_button_type_t button); +@@ -51,7 +51,7 @@ class NWebInputDelegate { + static bool KeyValueConvert(const std::string keyValue, + std::unordered_map& map); + static NWebInputEventHandle keyEventHandle_; +- float mouseWheelRatio_ = -5.0; ++ float mouseWheelRatio_ = -12.5; + }; + } // namespace OHOS::NWeb + +diff --git a/src/ohos_nweb/src/cef_delegate/nweb_inputmethod_client.h b/src/ohos_nweb/src/cef_delegate/nweb_inputmethod_client.h +index 8ce8c9fc736..d4ad3407cc2 +--- a/src/ohos_nweb/src/cef_delegate/nweb_inputmethod_client.h ++++ b/src/ohos_nweb/src/cef_delegate/nweb_inputmethod_client.h +@@ -22,13 +22,24 @@ + namespace OHOS::NWeb { + class NWebInputMethodClient: public virtual CefBaseRefCounted { + public: ++ enum class HideTextinputType { ++ FROM_KERNEL, ++ FROM_ONBLUR, ++ FROM_ONPAUSE, ++ }; ++ + virtual ~NWebInputMethodClient() = default; +- virtual void Attach(CefRefPtr browser, bool show_keyboard) = 0; ++ virtual void Attach(CefRefPtr browser, bool show_keyboard, cef_text_input_mode_t input_mode) = 0; + virtual void ShowTextInput() = 0; +- virtual void HideTextInput() = 0; ++ virtual void HideTextInput(uint32_t nweb_id = 0, HideTextinputType hideType = HideTextinputType::FROM_KERNEL) = 0; + virtual void OnTextSelectionChanged(CefRefPtr browser, + const CefString& selected_text, + const CefRange& selected_range) = 0; ++ virtual void OnCursorUpdate(const CefRect& rect) = 0; ++ virtual void OnSelectionChanged(CefRefPtr browser, ++ const CefString& text, ++ const CefRange& selected_range) = 0; ++ virtual void SetFocusStatus(bool focus_status) = 0; + }; + } + +diff --git a/src/ohos_nweb/src/cef_delegate/nweb_preference_delegate.cc b/src/ohos_nweb/src/cef_delegate/nweb_preference_delegate.cc +index 1042294b19a..d704bbed119 +--- a/src/ohos_nweb/src/cef_delegate/nweb_preference_delegate.cc ++++ b/src/ohos_nweb/src/cef_delegate/nweb_preference_delegate.cc +@@ -15,8 +15,6 @@ + + #include "ohos_nweb/src/cef_delegate/nweb_preference_delegate.h" + +-#include +-#include + #include "base/logging.h" + #include "cef/include/cef_command_line.h" + #include "cef/include/internal/cef_string.h" +@@ -29,6 +27,7 @@ + #include "base/feature_list.h" + #include "content/public/common/content_switches.h" + #include "net/base/load_flags.h" ++#include "ohos_adapter_helper.h" + #include "ohos_nweb/src/cef_delegate/nweb_application.h" + + namespace OHOS::NWeb { +@@ -51,13 +50,10 @@ int ConvertCacheMode(NWebPreference::CacheModeFlag flag) { + + const std::string ACCESS_LOCATION = "ohos.permission.INTERNET"; + NWebPreferenceDelegate::NWebPreferenceDelegate() { +- uint32_t tokenId = OHOS::IPCSkeleton::GetCallingTokenID(); +- has_internet_permission_ = +- OHOS::Security::AccessToken::AccessTokenKit::VerifyAccessToken( +- tokenId, ACCESS_LOCATION) == +- OHOS::Security::AccessToken::PERMISSION_GRANTED; ++ has_internet_permission_ = OhosAdapterHelper::GetInstance() ++ .GetAccessTokenAdapterInstance() ++ .VerifyAccessToken(ACCESS_LOCATION); + is_network_blocked_ = !has_internet_permission_; +- + SetBrowserSettingsToNetHelpers(); + } + +@@ -137,7 +133,7 @@ void NWebPreferenceDelegate::ComputeBrowserSettings( + // EnableRawFileAccessFromFileURLs() ? STATE_ENABLED : STATE_DISABLED; + browser_settings.force_dark_mode_enabled = + ForceDarkModeEnabled() ? STATE_ENABLED : STATE_DISABLED; +- browser_settings.dark_prefer_color_scheme_enabled = ++ browser_settings.dark_prefer_color_scheme_enabled = + DarkSchemeEnabled() ? STATE_ENABLED : STATE_DISABLED; + browser_settings.javascript_can_open_windows_automatically = + IsCreateWindowsByJavaScriptAllowed(); +@@ -157,14 +153,15 @@ void NWebPreferenceDelegate::ComputeBrowserSettings( + !IsHorizontalScrollBarAccess() ? STATE_ENABLED : STATE_DISABLED; + browser_settings.hide_vertical_scrollbars = + !IsVerticalScrollBarAccess() ? STATE_ENABLED : STATE_DISABLED; ++ browser_settings.viewport_meta_enabled = true; ++ browser_settings.contextmenu_customization_enabled = false; ++ browser_settings.scrollbar_color = GetScrollBarColor(); + CefRefPtr command_line = + CefCommandLine::GetGlobalCommandLine(); + if (command_line->HasSwitch(::switches::kForBrowser)) { +- bool is_win = +- (UserAgent().find("Windows NT") >= 0) && +- (UserAgent().find("Win64") >= 0 || UserAgent().find("WOW64") >= 0); +- browser_settings.viewport_meta_enabled = !is_win; ++ browser_settings.contextmenu_customization_enabled = true; + } ++ browser_settings.background_color = GetBackgroundColor(); + } + + void NWebPreferenceDelegate::SetBrowserSettingsToNetHelpers() { +@@ -320,6 +317,9 @@ void NWebPreferenceDelegate::PutUserAgent(std::string ua) { + } else { + user_agent_ = ua; + } ++ if (!browser_) { ++ return; ++ } + if (old_user_agent != user_agent_) { + browser_->GetHost()->PutUserAgent(ua); + } +@@ -392,7 +392,12 @@ void NWebPreferenceDelegate::PutMediaPlayGestureAccess(bool flag) { + + void NWebPreferenceDelegate::PutPinchSmoothMode(bool flag) { + pinch_smooth_mode_ = flag; +- LOG(ERROR) << "Put Pinch Smooth Mode:" << pinch_smooth_mode_; ++ LOG(INFO) << "Put Pinch Smooth Mode:" << pinch_smooth_mode_; ++ WebPreferencesChanged(); ++} ++ ++void NWebPreferenceDelegate::PutScrollBarColor(uint32_t colorValue) { ++ scrollbar_color_ = colorValue; + WebPreferencesChanged(); + } + +@@ -582,4 +587,16 @@ bool NWebPreferenceDelegate::IsHorizontalScrollBarAccess() { + bool NWebPreferenceDelegate::IsVerticalScrollBarAccess() { + return vertical_scrollBar_access_; + } ++ ++uint32_t NWebPreferenceDelegate::GetScrollBarColor() { ++ return scrollbar_color_; ++} ++ ++void NWebPreferenceDelegate::SetBackgroundColor(int32_t color) { ++ background_color_ = color; ++} ++ ++int32_t NWebPreferenceDelegate::GetBackgroundColor() const { ++ return background_color_; ++} + } // namespace OHOS::NWeb +diff --git a/src/ohos_nweb/src/cef_delegate/nweb_preference_delegate.h b/src/ohos_nweb/src/cef_delegate/nweb_preference_delegate.h +index 4c34798987b..042590179be +--- a/src/ohos_nweb/src/cef_delegate/nweb_preference_delegate.h ++++ b/src/ohos_nweb/src/cef_delegate/nweb_preference_delegate.h +@@ -69,6 +69,7 @@ class NWebPreferenceDelegate : public NWebPreference { + void PutMultiWindowAccess(bool flag) override; + void PutHorizontalScrollBarAccess(bool flag) override; + void PutVerticalScrollBarAccess(bool flag) override; ++ void PutScrollBarColor(uint32_t colorValue) override; + /* get methods*/ + bool EnableContentAccess() override; + bool EnableRawFileAccess() override; +@@ -107,6 +108,7 @@ class NWebPreferenceDelegate : public NWebPreference { + bool IsMultiWindowAccess() override; + bool IsHorizontalScrollBarAccess() override; + bool IsVerticalScrollBarAccess() override; ++ uint32_t GetScrollBarColor() override; + + bool RunningInsecureContentAllowed(); + bool UseStricMixedContentCheckingAllowed(); +@@ -114,7 +116,8 @@ class NWebPreferenceDelegate : public NWebPreference { + bool GetPinchSmoothMode() override; + + void PutHasInternetPermission(bool flag); +- ++ void SetBackgroundColor(int32_t color); ++ int32_t GetBackgroundColor() const; + private: + CefRefPtr browser_ = nullptr; + +@@ -156,7 +159,9 @@ class NWebPreferenceDelegate : public NWebPreference { + bool is_network_blocked_; + bool has_internet_permission_; + bool overload_mode_enabled_{true}; ++ uint32_t scrollbar_color_{0}; + CacheModeFlag cache_mode_flag_{CacheModeFlag::USE_DEFAULT}; ++ int32_t background_color_{0xffffffff}; + }; + } // namespace OHOS::NWeb + +diff --git a/src/ohos_nweb/src/cef_delegate/nweb_render_handler.cc b/src/ohos_nweb/src/cef_delegate/nweb_render_handler.cc +index 9f5601d4faf..b4619cf6826 +--- a/src/ohos_nweb/src/cef_delegate/nweb_render_handler.cc ++++ b/src/ohos_nweb/src/cef_delegate/nweb_render_handler.cc +@@ -144,6 +144,7 @@ bool NWebRenderHandler::GetScreenInfo(CefRefPtr browser, + screen_info.depth = 24; + screen_info.depth_per_component = 8; + ++ cef_device_ratio_ = screen_info.device_scale_factor; + return true; + } + +@@ -158,7 +159,7 @@ void NWebRenderHandler::OnPaint(CefRefPtr browser, + if (render_update_cb_ == nullptr) { + return; + } +- if (width != width_ || height != height_) { ++ if ((uint32_t)width != width_ || (uint32_t)height != height_) { + LOG(INFO) << "frame size(" << width << "*" << height + << ") is not identical to request size (" << width_ << "*" + << height_ << "), drop this frame"; +@@ -209,6 +210,14 @@ void NWebRenderHandler::OnTextSelectionChanged(CefRefPtr browser, + } + } + ++void NWebRenderHandler::OnSelectionChanged(CefRefPtr browser, ++ const CefString& text, ++ const CefRange& selected_range) { ++ if (inputmethod_client_) { ++ inputmethod_client_->OnSelectionChanged(browser, text, selected_range); ++ } ++} ++ + void NWebRenderHandler::OnVirtualKeyboardRequested( + CefRefPtr browser, + TextInputMode input_mode, +@@ -218,7 +227,7 @@ void NWebRenderHandler::OnVirtualKeyboardRequested( + + if (inputmethod_client_) { + if (input_mode != CEF_TEXT_INPUT_MODE_NONE) { +- inputmethod_client_->Attach(browser, show_keyboard); ++ inputmethod_client_->Attach(browser, show_keyboard, input_mode); + } else { + inputmethod_client_->HideTextInput(); + } +@@ -237,24 +246,24 @@ void NWebRenderHandler::GetTouchHandleSize( + << screen_info_.display_ratio; + return; + } +- if (screen_info_.display_ratio <= 1) { ++ if (auto handler = handler_.lock()) { ++ TouchHandleHotZone hot_zone; ++ handler->OnGetTouchHandleHotZone(hot_zone); ++ if (hot_zone.width > 0 && hot_zone.height > 0) { ++ size.width = static_cast(hot_zone.width) + 1; ++ size.height = static_cast(hot_zone.height) + 1; ++ } ++ } ++ LOG(INFO) << "GetTouchHandleSize " << size.width << " " << size.height; ++} ++ ++void NWebRenderHandler::OnCursorUpdate(CefRefPtr browser, ++ const CefRect& rect) { ++ if (!inputmethod_client_) { ++ LOG(ERROR) << "NWebRenderHandler::OnCursorUpdate inputmethod_client_ is nullptr"; + return; +- } else if (screen_info_.display_ratio > 1 && +- screen_info_.display_ratio < 1.7) { +- // rk +- size.width = 30 / screen_info_.display_ratio; +- size.height = 30 / screen_info_.display_ratio; +- } else if (screen_info_.display_ratio >= 1.7 && +- screen_info_.display_ratio < 2.5) { +- // wgr +- size.width = 40 / screen_info_.display_ratio; +- size.height = 40 / screen_info_.display_ratio; +- } else { +- // phone +- size.width = 60 / screen_info_.display_ratio; +- size.height = 60 / screen_info_.display_ratio; + } +- LOG(ERROR) << "GetTouchHandleSize " << size.width << " " << size.height; ++ inputmethod_client_->OnCursorUpdate(rect); + } + + std::shared_ptr NWebRenderHandler::GetTouchHandleState( +@@ -373,7 +382,25 @@ bool NWebRenderHandler::StartDragging(CefRefPtr browser, + return isNeedDrag; + } + ++void NWebRenderHandler::OnCompleteSwapWithNewSize() { ++ if (auto handler = handler_.lock()) { ++ handler->OnCompleteSwapWithNewSize(); ++ } ++} ++ ++void NWebRenderHandler::OnResizeNotWork() { ++ if (auto handler = handler_.lock()) { ++ handler->OnResizeNotWork(); ++ } ++} ++ + CefRefPtr NWebRenderHandler::GetDragData() { + return drag_data_; + } ++ ++void NWebRenderHandler::SetFocusStatus(bool focus_status) { ++ if (inputmethod_client_) { ++ inputmethod_client_->SetFocusStatus(focus_status); ++ } ++} + } // namespace OHOS::NWeb +diff --git a/src/ohos_nweb/src/cef_delegate/nweb_render_handler.h b/src/ohos_nweb/src/cef_delegate/nweb_render_handler.h +index 4d24b5caa46..4d3620c4603 +--- a/src/ohos_nweb/src/cef_delegate/nweb_render_handler.h ++++ b/src/ohos_nweb/src/cef_delegate/nweb_render_handler.h +@@ -49,16 +49,16 @@ class NWebRenderHandler : public CefRenderHandler { + void SetInputMethodClient(CefRefPtr client); + + /* CefRenderHandler method begin */ +- virtual void GetViewRect(CefRefPtr browser, +- CefRect& rect) override; ++ void GetViewRect(CefRefPtr browser, ++ CefRect& rect) override; + bool GetScreenInfo(CefRefPtr browser, + CefScreenInfo& screen_info) override; +- virtual void OnPaint(CefRefPtr browser, +- PaintElementType type, +- const RectList& dirty_rects, +- const void* buffer, +- int width, +- int height) override; ++ void OnPaint(CefRefPtr browser, ++ PaintElementType type, ++ const RectList& dirty_rects, ++ const void* buffer, ++ int width, ++ int height) override; + + void OnRootLayerChanged(CefRefPtr browser, + int height, +@@ -68,33 +68,42 @@ class NWebRenderHandler : public CefRenderHandler { + double x, + double y) override; + +- virtual void OnImeCompositionRangeChanged( +- CefRefPtr browser, +- const CefRange& selected_range, +- const RectList& character_bounds) override; ++ void OnImeCompositionRangeChanged(CefRefPtr browser, ++ const CefRange& selected_range, ++ const RectList& character_bounds) override; + +- virtual void OnTextSelectionChanged(CefRefPtr browser, +- const CefString& selected_text, +- const CefRange& selected_range) override; ++ void OnTextSelectionChanged(CefRefPtr browser, ++ const CefString& selected_text, ++ const CefRange& selected_range) override; + +- virtual void OnVirtualKeyboardRequested(CefRefPtr browser, +- TextInputMode input_mode, +- bool show_keyboard) override; ++ void OnSelectionChanged(CefRefPtr browser, ++ const CefString& text, ++ const CefRange& selected_range) override; ++ ++ void OnVirtualKeyboardRequested(CefRefPtr browser, ++ TextInputMode input_mode, ++ bool show_keyboard) override; + + void GetTouchHandleSize(CefRefPtr browser, + cef_horizontal_alignment_t orientation, + CefSize& size) override; +- void OnTouchSelectionChanged( +- const CefTouchHandleState& insert_handle, +- const CefTouchHandleState& start_selection_handle, +- const CefTouchHandleState& end_selection_handle, +- bool need_report) override; ++ void OnTouchSelectionChanged(const CefTouchHandleState& insert_handle, ++ const CefTouchHandleState& start_selection_handle, ++ const CefTouchHandleState& end_selection_handle, ++ bool need_report) override; + + bool StartDragging(CefRefPtr browser, + CefRefPtr drag_data, + DragOperationsMask allowed_ops, + int x, + int y) override; ++ ++ void OnCursorUpdate(CefRefPtr browser, ++ const CefRect& rect) override; ++ ++ void OnCompleteSwapWithNewSize() override; ++ ++ void OnResizeNotWork() override; + /* CefRenderHandler method end */ + + std::shared_ptr GetTouchHandleState( +@@ -103,7 +112,8 @@ class NWebRenderHandler : public CefRenderHandler { + CefRefPtr GetDragData(); + + float GetVirtualPixelRatio() const { return screen_info_.display_ratio; } +- ++ float GetCefDeviceRatio() const { return cef_device_ratio_; } ++ void SetFocusStatus(bool focus_status); + // Include the default reference counting implementation. + IMPLEMENT_REFCOUNTING(NWebRenderHandler); + +@@ -118,6 +128,7 @@ class NWebRenderHandler : public CefRenderHandler { + int content_height_ = 0; + int content_width_ = 0; + NWebScreenInfo screen_info_; ++ float cef_device_ratio_ = 1.0; + + std::weak_ptr handler_; + CefTouchHandleState insert_handle_; +diff --git a/src/ohos_nweb/src/cef_delegate/nweb_resource_handler.cc b/src/ohos_nweb/src/cef_delegate/nweb_resource_handler.cc +index 8c3e9622dfd..5596231a7df +--- a/src/ohos_nweb/src/cef_delegate/nweb_resource_handler.cc ++++ b/src/ohos_nweb/src/cef_delegate/nweb_resource_handler.cc +@@ -16,6 +16,9 @@ + #include "nweb_resource_handler.h" + #include + #include "base/logging.h" ++#include "base/command_line.h" ++#include "content/public/common/content_switches.h" ++#include "ohos_adapter_helper.h" + + namespace OHOS::NWeb { + +@@ -25,13 +28,13 @@ public: + ~NWebResourceReadyCallbackImpl() = default; + void Continue() override + { +- LOG(INFO) << "intecept NWebResourceReadyCallbackImpl::Continue"; ++ LOG(INFO) << "intercept NWebResourceReadyCallbackImpl::Continue"; + callback_->Continue(); + } + + void Cancel() override + { +- LOG(INFO) << "intecept NWebResourceReadyCallbackImpl::Cancel"; ++ LOG(INFO) << "intercept NWebResourceReadyCallbackImpl::Cancel"; + callback_->Cancel(); + } + private: +@@ -104,6 +107,7 @@ bool NWebResourceHandler::ReadFileData(void* data_out, int bytes_to_read, int& b + int fd = response_->ResponseFileHandle(); + if (fd <= 0) { + bytes_read = fd; ++ LOG(ERROR) << "intercept get fd invalid : " << fd; + return false; + } + int ret = read(fd, data_out, bytes_to_read); +@@ -124,6 +128,37 @@ bool NWebResourceHandler::ReadFileData(void* data_out, int bytes_to_read, int& b + return true; + } + ++bool NWebResourceHandler::ReadResourceData(void* data_out, int bytes_to_read, int& bytes_read) ++{ ++ bool has_data = false; ++ if (resource_data_len_ == 0) { ++ std::string resourceUrlHead("resource:/RAWFILE"); ++ std::string resourceUrl = response_->ResponseResourceUrl(); ++ if (resourceUrl.find(resourceUrlHead) == std::string::npos) { ++ LOG(ERROR) << "intercept find resource head fail : " << resourceUrl; ++ return has_data; ++ } ++ resourceUrl.erase(0, resourceUrlHead.length()); ++ std::string resourcePath = "resources/rawfile" + resourceUrl; ++ LOG(INFO) << "intercept Read Resource path : " << resourcePath; ++ std::string hapPath = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kOhosHapPath); ++ auto resourceInstance = OHOS::NWeb::OhosAdapterHelper::GetInstance().GetResourceAdapter(hapPath); ++ if (!resourceInstance->GetRawFileData(resourcePath, resource_data_len_, resource_data_, false)) { ++ LOG(ERROR) << "intercept Read Resource path fail : " << resourcePath; ++ return has_data; ++ } ++ } ++ unsigned char* dataPtr = reinterpret_cast(resource_data_.get()); ++ if (resource_data_offset_ < resource_data_len_) { ++ int transfer_size = std::min(bytes_to_read, static_cast(resource_data_len_ - resource_data_offset_)); ++ memcpy(data_out, dataPtr + resource_data_offset_, transfer_size); ++ resource_data_offset_ += transfer_size; ++ bytes_read = transfer_size; ++ has_data = true; ++ } ++ return has_data; ++} ++ + bool NWebResourceHandler::Read(void* data_out, + int bytes_to_read, + int& bytes_read, +@@ -132,18 +167,23 @@ bool NWebResourceHandler::Read(void* data_out, + bytes_read = -1; + return false; + } +- +- if (response_->ResponseIsFileHandle()) { +- return ReadFileData(data_out, bytes_to_read, bytes_read); +- } else { +- return ReadStringData(data_out, bytes_to_read, bytes_read); ++ switch (response_->ResponseDataType()) { ++ case NWebResponseDataType::NWEB_RESOURCE_URL_TYPE: ++ return ReadResourceData(data_out, bytes_to_read, bytes_read); ++ case NWebResponseDataType::NWEB_FILE_TYPE: ++ return ReadFileData(data_out, bytes_to_read, bytes_read); ++ case NWebResponseDataType::NWEB_STRING_TYPE: ++ return ReadStringData(data_out, bytes_to_read, bytes_read); ++ default: ++ break; + } ++ return false; + } + + void NWebResourceHandler::GetResponseHeaders(CefRefPtr response, + int64& response_length, + CefString& redirectUrl) { +- LOG(INFO) << "NWebResourceHandler::GetResponseHeaders"; ++ LOG(INFO) << "intercept NWebResourceHandler::GetResponseHeaders"; + if (response_ && response) { + response->SetMimeType(response_->ResponseMimeType()); + response->SetStatus(response_->ResponseStatusCode()); +@@ -155,10 +195,10 @@ void NWebResourceHandler::GetResponseHeaders(CefRefPtr response, + ConvertMapToHeaderMap(cef_request_headers, request_headers); + response->SetHeaderMap(cef_request_headers); + } +- if (response_->ResponseIsFileHandle()) { +- response_length = -1; +- } else { ++ if (response_->ResponseDataType() == NWebResponseDataType::NWEB_STRING_TYPE) { + response_length = data_.length(); ++ } else { ++ response_length = -1; + } + } + +@@ -171,6 +211,7 @@ void NWebResourceHandler::Cancel() { + if (fd <= 0) { + return; + } ++ response_->PutResponseFileHandle(-1); + close(fd); + } + /* CefResourceHandler method end */ +diff --git a/src/ohos_nweb/src/cef_delegate/nweb_resource_handler.h b/src/ohos_nweb/src/cef_delegate/nweb_resource_handler.h +index c6048a67224..03a4dc68bd6 +--- a/src/ohos_nweb/src/cef_delegate/nweb_resource_handler.h ++++ b/src/ohos_nweb/src/cef_delegate/nweb_resource_handler.h +@@ -56,9 +56,15 @@ class NWebResourceHandler : public CefResourceHandler { + bool ReadFileData(void* data_out, + int bytes_to_read, + int& bytes_read); ++ bool ReadResourceData(void* data_out, ++ int bytes_to_read, ++ int& bytes_read); + std::string data_; + size_t offset_ = 0; + std::shared_ptr response_; ++ std::unique_ptr resource_data_; ++ size_t resource_data_offset_ = 0; ++ size_t resource_data_len_ = 0; + }; + } + diff --git a/src/ohos_nweb/src/nweb_delegate_adapter.cc b/src/ohos_nweb/src/nweb_delegate_adapter.cc +index d770595faea..37d6e6e172f +--- a/src/ohos_nweb/src/nweb_delegate_adapter.cc ++++ b/src/ohos_nweb/src/nweb_delegate_adapter.cc +@@ -26,12 +26,13 @@ std::shared_ptr NWebDelegateAdapter::CreateNWebDelegate( + int argc, + const char* argv[], + bool is_enhance_surface, +- void* window) { ++ void* window, ++ bool popup) { + #if defined(USE_CEF) + std::shared_ptr delegate = + std::make_shared(argc, argv); + +- if (delegate == nullptr || !delegate->Init(is_enhance_surface, window)) { ++ if (delegate == nullptr || !delegate->Init(is_enhance_surface, window, popup)) { + WVLOG_I("FAIL to create nweb delegate instance"); + return nullptr; + } +diff --git a/src/ohos_nweb/src/nweb_delegate_adapter.h b/src/ohos_nweb/src/nweb_delegate_adapter.h +index 7fa0f7bd757..95e4640f9dc +--- a/src/ohos_nweb/src/nweb_delegate_adapter.h ++++ b/src/ohos_nweb/src/nweb_delegate_adapter.h +@@ -27,7 +27,8 @@ class OHOS_NWEB_EXPORT NWebDelegateAdapter { + int argc, + const char* argv[], + bool is_enhance_surface, +- void* window); ++ void* window, ++ bool popup); + }; + } + +diff --git a/src/ohos_nweb/src/nweb_delegate_interface.h b/src/ohos_nweb/src/nweb_delegate_interface.h +index ba7425c3ca4..d0a61b1a158 +--- a/src/ohos_nweb/src/nweb_delegate_interface.h ++++ b/src/ohos_nweb/src/nweb_delegate_interface.h +@@ -48,7 +48,7 @@ struct DelegateDragEvent { + using WebState = std::shared_ptr>; + + class NWebDelegateInterface +- : public std::enable_shared_from_this{ ++ : public std::enable_shared_from_this { + public: + virtual ~NWebDelegateInterface() = default; + +@@ -70,13 +70,29 @@ class NWebDelegateInterface + + /* event interface */ + virtual void Resize(uint32_t width, uint32_t height) = 0; +- virtual void OnTouchPress(int32_t id, double x, double y) = 0; +- virtual void OnTouchRelease(int32_t id, double x, double y) = 0; +- virtual void OnTouchMove(int32_t id, double x, double y) = 0; ++ virtual void OnTouchPress(int32_t id, ++ double x, ++ double y, ++ bool from_overlay) = 0; ++ virtual void OnTouchRelease(int32_t id, ++ double x, ++ double y, ++ bool from_overlay) = 0; ++ virtual void OnTouchMove(int32_t id, ++ double x, ++ double y, ++ bool from_overlay) = 0; + virtual void OnTouchCancel() = 0; + virtual bool SendKeyEvent(int32_t keyCode, int32_t keyAction) = 0; +- virtual void SendMouseWheelEvent(double x, double y, double deltaX, double deltaY) = 0; +- virtual void SendMouseEvent(int x, int y, int button, int action, int count) = 0; ++ virtual void SendMouseWheelEvent(double x, ++ double y, ++ double deltaX, ++ double deltaY) = 0; ++ virtual void SendMouseEvent(int x, ++ int y, ++ int button, ++ int action, ++ int count) = 0; + virtual void NotifyScreenInfoChanged(RotationType rotation, + OrientationType orientation) = 0; + +@@ -99,7 +115,8 @@ class NWebDelegateInterface + virtual void ExecuteJavaScript(const std::string& code) const = 0; + virtual void ExecuteJavaScript( + const std::string& code, +- std::shared_ptr> callback) const = 0; ++ std::shared_ptr>> callback, ++ bool extention) const = 0; + virtual void PutBackgroundColor(int color) const = 0; + virtual void InitialScale(float scale) const = 0; + virtual void OnPause() = 0; +@@ -107,7 +124,9 @@ class NWebDelegateInterface + virtual std::shared_ptr GetPreference() const = 0; + virtual std::string Title() = 0; + virtual void CreateWebMessagePorts(std::vector& ports) = 0; +- virtual void PostWebMessage(std::string& message, std::vector& ports, std::string& targetUri) = 0; ++ virtual void PostWebMessage(std::string& message, ++ std::vector& ports, ++ std::string& targetUri) = 0; + virtual void ClosePort(std::string& portHandle) = 0; + virtual void PostPortMessage(std::string& portHandle, std::shared_ptr data) = 0; + virtual void SetPortMessageCallback(std::string& portHandle, +@@ -155,7 +174,7 @@ class NWebDelegateInterface + + virtual void SetBrowserUserAgentString(const std::string& user_agent) = 0; + +- virtual void SendDragEvent(const DelegateDragEvent& dragEvent) const = 0; ++ virtual void SendDragEvent(const DelegateDragEvent& dragEvent) const = 0; + virtual std::string GetUrl() const = 0; + virtual const std::string GetOriginalUrl() = 0; + virtual bool GetFavicon(const void** data, size_t& width, size_t& height, +@@ -174,6 +193,21 @@ class NWebDelegateInterface + virtual void ScrollTo(float x, float y) = 0; + virtual void ScrollBy(float delta_x, float delta_y) = 0; + virtual void SlideScroll(float vx, float vy) = 0; ++ virtual bool GetCertChainDerData(std::vector& certChainData, bool isSingleCert) = 0; ++ virtual void SetAudioMuted(bool muted) = 0; ++ ++#if defined (OHOS_NWEB_EX) ++ virtual void SetForceEnableZoom(bool forceEnableZoom) = 0; ++ virtual bool GetForceEnableZoom() = 0; ++ virtual void SelectAndCopy() = 0; ++ virtual bool ShouldShowFreeCopy() = 0; ++ virtual void SetEnableBlankTargetPopupIntercept(bool enableBlankTargetPopup) = 0; ++#endif ++ ++ virtual void SetShouldFrameSubmissionBeforeDraw(bool should) = 0; ++ virtual void SetAudioResumeInterval(int32_t resumeInterval) = 0; ++ virtual void SetAudioExclusive(bool audioExclusive) = 0; ++ virtual void NotifyPopupWindowResult(bool result) = 0; + }; + } // namespace OHOS::NWeb + +diff --git a/src/ohos_nweb/src/nweb_hilog.h b/src/ohos_nweb/src/nweb_hilog.h +index dd8be9d8668..0d588f77f58 +--- a/src/ohos_nweb/src/nweb_hilog.h ++++ b/src/ohos_nweb/src/nweb_hilog.h +@@ -17,26 +17,29 @@ + #define NWEB_HILOG_H + + #if defined(OHOS_NWEB) +-#include "hilog/log.h" +-constexpr OHOS::HiviewDFX::HiLogLabel kLogLabel = {LOG_CORE, 0xD004500, "NWEB"}; ++#include "hilog_adapter.h" ++constexpr char logTag[] = "NWEB"; + + #define FUNC_LINE_FMT " %{public}s<%{public}d>: " + ++using OHOS::NWeb::HiLogAdapter; ++using OHOS::NWeb::LogLevelAdapter; ++ + #define WVLOG_D(fmt, ...) \ +- OHOS::HiviewDFX::HiLog::Debug(kLogLabel, FUNC_LINE_FMT fmt, __FUNCTION__, \ +- __LINE__, ##__VA_ARGS__) ++ HiLogAdapter::PrintLog(LogLevelAdapter::DEBUG, logTag, FUNC_LINE_FMT fmt, \ ++ __FUNCTION__, __LINE__, ##__VA_ARGS__) + #define WVLOG_I(fmt, ...) \ +- OHOS::HiviewDFX::HiLog::Info(kLogLabel, FUNC_LINE_FMT fmt, __FUNCTION__, \ +- __LINE__, ##__VA_ARGS__) ++ HiLogAdapter::PrintLog(LogLevelAdapter::INFO, logTag, FUNC_LINE_FMT fmt, \ ++ __FUNCTION__, __LINE__, ##__VA_ARGS__) + #define WVLOG_W(fmt, ...) \ +- OHOS::HiviewDFX::HiLog::Warn(kLogLabel, FUNC_LINE_FMT fmt, __FUNCTION__, \ +- __LINE__, ##__VA_ARGS__) ++ HiLogAdapter::PrintLog(LogLevelAdapter::WARN, logTag, FUNC_LINE_FMT fmt, \ ++ __FUNCTION__, __LINE__, ##__VA_ARGS__) + #define WVLOG_E(fmt, ...) \ +- OHOS::HiviewDFX::HiLog::Error(kLogLabel, FUNC_LINE_FMT fmt, __FUNCTION__, \ +- __LINE__, ##__VA_ARGS__) ++ HiLogAdapter::PrintLog(LogLevelAdapter::ERROR, logTag, FUNC_LINE_FMT fmt, \ ++ __FUNCTION__, __LINE__, ##__VA_ARGS__) + #define WVLOG_F(fmt, ...) \ +- OHOS::HiviewDFX::HiLog::Fatal(kLogLabel, FUNC_LINE_FMT fmt, __FUNCTION__, \ +- __LINE__, ##__VA_ARGS__) ++ HiLogAdapter::PrintLog(LogLevelAdapter::FATAL, logTag, FUNC_LINE_FMT fmt, \ ++ __FUNCTION__, __LINE__, ##__VA_ARGS__) + + #else // not OHOS_NWEB + +diff --git a/src/ohos_nweb/src/nweb_impl.cc b/src/ohos_nweb/src/nweb_impl.cc +index 4b7f7767700..f79bfc8d35e +--- a/src/ohos_nweb/src/nweb_impl.cc ++++ b/src/ohos_nweb/src/nweb_impl.cc +@@ -25,39 +25,45 @@ + + #include "base/lazy_instance.h" + #include "base/trace_event/common/trace_event_common.h" +-#include "ohos_adapter_helper.h" ++#include "cef/include/cef_app.h" ++#include "cef/libcef/browser/net_service/net_helpers.h" + #include "nweb_delegate_adapter.h" + #include "nweb_export.h" + #include "nweb_handler.h" + #include "nweb_hilog.h" ++#include "ohos_adapter_helper.h" ++ ++#include "services/device/wake_lock/power_save_blocker/nweb_screen_lock_tracker.h" + + #if defined(REPORT_SYS_EVENT) + #include "event_reporter.h" + #endif +- + namespace { + uint32_t g_nweb_count = 0; + const uint32_t kSurfaceMaxWidth = 7680; + const uint32_t kSurfaceMaxHeight = 7680; ++const int32_t kMaxResumeInterval = 60; + +-// For NWebEx ++#ifdef OHOS_NWEB_EX + bool g_browser_service_api_enabled = false; ++#endif // OHOS_NWEB_EX + + #if defined(REPORT_SYS_EVENT) +- // For maximum count of nweb instance +- uint32_t g_nweb_max_count = 0; ++// For maximum count of nweb instance ++uint32_t g_nweb_max_count = 0; + #endif +-} ++} // namespace + + namespace OHOS::NWeb { + +-// For NWebEx + typedef std::unordered_map> NWebMap; + base::LazyInstance::DestructorAtExit g_nweb_map = + LAZY_INSTANCE_INITIALIZER; + ++#ifdef OHOS_NWEB_EX + base::LazyInstance>::DestructorAtExit g_browser_args = + LAZY_INSTANCE_INITIALIZER; ++#endif // OHOS_NWEB_EX + + void NWebImpl::AddNWebToMap(uint32_t id, std::shared_ptr& nweb) { + if (nweb) { +@@ -77,26 +83,12 @@ NWebImpl* NWebImpl::FromID(int32_t nweb_id) { + return nullptr; + } + +-void NWebImpl::InitBrowserServiceApi(std::vector& browser_args) { +- auto args = g_browser_args.Pointer(); +- args->clear(); +- for (const std::string& arg : browser_args) { +- args->push_back(arg); +- } +- g_browser_service_api_enabled = true; +-} +- +-bool NWebImpl::GetBrowserServiceApiEnabled() { +- return g_browser_service_api_enabled; +-} +- + NWebImpl::NWebImpl(uint32_t id) : nweb_id_(id) {} + + NWebImpl::~NWebImpl() { + g_nweb_map.Get().erase(nweb_id_); + } + +- + bool NWebImpl::Init(const NWebCreateInfo& create_info) { + output_handler_ = NWebOutputHandler::Create( + create_info.width, create_info.height, create_info.output_render_frame); +@@ -117,6 +109,9 @@ bool NWebImpl::Init(const NWebCreateInfo& create_info) { + return false; + } + ++ OHOS::NWeb::OhosAdapterHelper::GetInstance() ++ .GetNetProxyInstance().StartListen(); ++ + return true; + } + +@@ -137,6 +132,9 @@ void NWebImpl::OnDestroy() { + input_handler_ = nullptr; + } + ++ OHOS::NWeb::OhosAdapterHelper::GetInstance() ++ .GetNetProxyInstance().StopListen(); ++ + #if defined(REPORT_SYS_EVENT) + // Report nweb instance count + ReportMultiInstanceStats(nweb_id_, g_nweb_count, g_nweb_max_count); +@@ -181,7 +179,7 @@ bool NWebImpl::SetVirtualDeviceRatio() { + uint32_t NWebImpl::NormalizeVirtualDeviceRatio(uint32_t length) { + float ratio = static_cast(length / device_pixel_ratio_) + * device_pixel_ratio_; +- return std::ceil(ratio); ++ return std::ceil(ratio); + } + + bool NWebImpl::InitWebEngine(const NWebCreateInfo& create_info) { +@@ -204,14 +202,13 @@ bool NWebImpl::InitWebEngine(const NWebCreateInfo& create_info) { + for (auto it = web_engine_args_.begin(); i < argc; ++i, ++it) { + argv[i] = it->c_str(); + } +- bool is_enhance_surface = create_info.init_args.is_enhance_surface; ++ is_enhance_surface_ = create_info.init_args.is_enhance_surface; + void* window = nullptr; +- if (is_enhance_surface) { ++ if (is_enhance_surface_) { + window = create_info.enhance_surface_info; + } else { +- window = +- reinterpret_cast(output_handler_->GetNativeWindowFromSurface( +- create_info.producer_surface)); ++ window = output_handler_->GetNativeWindowFromSurface( ++ create_info.producer_surface); + } + + if (window == nullptr) { +@@ -219,7 +216,8 @@ bool NWebImpl::InitWebEngine(const NWebCreateInfo& create_info) { + delete[] argv; + return false; + } +- nweb_delegate_ = NWebDelegateAdapter::CreateNWebDelegate(argc, argv, is_enhance_surface, window); ++ WVLOG_D("nweb create_info.init_args.is_popup: %{public}d", create_info.init_args.is_popup); ++ nweb_delegate_ = NWebDelegateAdapter::CreateNWebDelegate(argc, argv, is_enhance_surface_, window, create_info.init_args.is_popup); + if (nweb_delegate_ == nullptr) { + WVLOG_E("fail to create nweb delegate of web engine"); + delete[] argv; +@@ -241,7 +239,12 @@ bool NWebImpl::InitWebEngine(const NWebCreateInfo& create_info) { + nweb_delegate_->RegisterRenderCb(render_update_cb); + + inputmethod_handler_ = new NWebInputMethodHandler(); ++ if (!inputmethod_handler_) { ++ WVLOG_E("inputmethod_handler_ is nullptr"); ++ return false; ++ } + nweb_delegate_->SetInputMethodClient(inputmethod_handler_); ++ inputmethod_handler_->SetVirtualDeviceRatio(device_pixel_ratio_); + + #if defined(REPORT_SYS_EVENT) + nweb_delegate_->SetNWebId(nweb_id_); +@@ -254,23 +257,10 @@ bool NWebImpl::InitWebEngine(const NWebCreateInfo& create_info) { + void NWebImpl::InitWebEngineArgs(const NWebInitArgs& init_args) { + web_engine_args_.clear(); + +- WVLOG_E("===OH=== InitWebEngineArgs 60fps"); +- auto args = g_browser_args.Get(); +- for (const std::string& arg : args) { +- web_engine_args_.emplace_back(arg); +- } +- + web_engine_args_.emplace_back("/system/bin/web_render"); + web_engine_args_.emplace_back("--in-process-gpu"); + web_engine_args_.emplace_back("--disable-dev-shm-usage"); +-#ifdef GPU_RK3568 +- web_engine_args_.emplace_back("--disable-gpu"); +-#endif +-#ifdef RK3568 +- web_engine_args_.emplace_back("--off-screen-frame-rate=70"); +-#else + web_engine_args_.emplace_back("--off-screen-frame-rate=60"); +-#endif + web_engine_args_.emplace_back("--no-unsandboxed-zygote"); + web_engine_args_.emplace_back("--no-zygote"); + web_engine_args_.emplace_back("--enable-features=UseOzonePlatform"); +@@ -284,6 +274,14 @@ void NWebImpl::InitWebEngineArgs(const NWebInitArgs& init_args) { + web_engine_args_.emplace_back("--zygote-cmd-prefix=/system/bin/web_render"); + web_engine_args_.emplace_back("--remote-debugging-port=9222"); + web_engine_args_.emplace_back("--enable-touch-drag-drop"); ++ web_engine_args_.emplace_back("--gpu-rasterization-msaa-sample-count=1"); ++ // enable aggressive domstorage flushing to minimize data loss ++ // http://crbug.com/479767 ++ web_engine_args_.emplace_back("--enable-aggressive-domstorage-flushing"); ++ web_engine_args_.emplace_back("--ohos-enable-drdc"); ++#ifdef RK3568 ++ web_engine_args_.emplace_back("--num-raster-threads=1"); ++#endif + if (init_args.is_enhance_surface) { + WVLOG_I("is_enhance_surface is true"); + web_engine_args_.emplace_back("--ohos-enhance-surface"); +@@ -300,6 +298,12 @@ void NWebImpl::InitWebEngineArgs(const NWebInitArgs& init_args) { + if (init_args.multi_renderer_process) { + web_engine_args_.emplace_back("--enable-multi-renderer-process"); + } ++#ifdef OHOS_NWEB_EX ++ auto args = g_browser_args.Get(); ++ for (const std::string& arg : args) { ++ web_engine_args_.emplace_back(arg); ++ } ++#endif // OHOS_NWEB_EX + } + + void NWebImpl::PutDownloadCallback( +@@ -307,17 +311,6 @@ void NWebImpl::PutDownloadCallback( + nweb_delegate_->RegisterDownLoadListener(downloadListener); + } + +-void NWebImpl::PutWebAppClientExtensionCallback( +- std::shared_ptr +- web_app_client_extension_listener) { +- nweb_delegate_->RegisterWebAppClientExtensionListener( +- web_app_client_extension_listener); +-} +- +-void NWebImpl::RemoveWebAppClientExtensionCallback() { +- nweb_delegate_->UnRegisterWebAppClientExtensionListener(); +-} +- + void NWebImpl::SetNWebHandler(std::shared_ptr client) { + nweb_handle_ = client; + nweb_delegate_->RegisterNWebHandler(client); +@@ -341,28 +334,31 @@ void NWebImpl::Resize(uint32_t width, uint32_t height) { + output_handler_->Resize(width, height); + } + +-void NWebImpl::OnTouchPress(int32_t id, double x, double y) { ++void NWebImpl::OnTouchPress(int32_t id, double x, double y, bool from_overlay) { + if (input_handler_ == nullptr) { + return; + } + +- input_handler_->OnTouchPress(id, x, y); ++ input_handler_->OnTouchPress(id, x, y, from_overlay); + } + +-void NWebImpl::OnTouchRelease(int32_t id, double x, double y) { ++void NWebImpl::OnTouchRelease(int32_t id, ++ double x, ++ double y, ++ bool from_overlay) { + if (input_handler_ == nullptr) { + return; + } + +- input_handler_->OnTouchRelease(id, x, y); ++ input_handler_->OnTouchRelease(id, x, y, from_overlay); + } + +-void NWebImpl::OnTouchMove(int32_t id, double x, double y) { ++void NWebImpl::OnTouchMove(int32_t id, double x, double y, bool from_overlay) { + if (input_handler_ == nullptr) { + return; + } + +- input_handler_->OnTouchMove(id, x, y); ++ input_handler_->OnTouchMove(id, x, y, from_overlay); + } + + void NWebImpl::OnTouchCancel() { +@@ -386,7 +382,10 @@ bool NWebImpl::SendKeyEvent(int32_t keyCode, int32_t keyAction) { + return input_handler_->SendKeyEvent(keyCode, keyAction); + } + +-void NWebImpl::SendMouseWheelEvent(double x, double y, double deltaX, double deltaY) { ++void NWebImpl::SendMouseWheelEvent(double x, ++ double y, ++ double deltaX, ++ double deltaY) { + if (input_handler_ == nullptr) { + return; + } +@@ -544,7 +543,7 @@ void NWebImpl::OnPause() const { + if (inputmethod_handler_ == nullptr) { + return; + } +- inputmethod_handler_->HideTextInput(); ++ inputmethod_handler_->HideTextInput(nweb_id_, NWebInputMethodClient::HideTextinputType::FROM_ONPAUSE); + } + + void NWebImpl::OnContinue() const { +@@ -552,6 +551,7 @@ void NWebImpl::OnContinue() const { + return; + } + nweb_delegate_->OnContinue(); ++ inputmethod_handler_->Reattach(nweb_id_, NWebInputMethodHandler::ReattachType::FROM_CONTINUE); + } + + const std::shared_ptr NWebImpl::GetPreference() const { +@@ -569,7 +569,6 @@ std::string NWebImpl::Title() { + } + + void NWebImpl::CreateWebMessagePorts(std::vector& ports) { +- + if (nweb_delegate_ == nullptr) { + WVLOG_E("JSAPI nweb_delegate_ its null"); + return; +@@ -577,7 +576,9 @@ void NWebImpl::CreateWebMessagePorts(std::vector& ports) { + nweb_delegate_->CreateWebMessagePorts(ports); + } + +-void NWebImpl::PostWebMessage(std::string& message, std::vector& ports, std::string& targetUri) { ++void NWebImpl::PostWebMessage(std::string& message, ++ std::vector& ports, ++ std::string& targetUri) { + if (nweb_delegate_ == nullptr) { + WVLOG_E("JSAPI nweb_delegate_ its null"); + return; +@@ -696,11 +697,12 @@ void NWebImpl::SetNWebJavaScriptResultCallBack( + + void NWebImpl::ExecuteJavaScript( + const std::string& code, +- std::shared_ptr> callback) const { ++ std::shared_ptr>> callback, ++ bool extention) const { + if (nweb_delegate_ == nullptr) { + return; + } +- nweb_delegate_->ExecuteJavaScript(code, callback); ++ nweb_delegate_->ExecuteJavaScript(code, callback, extention); + } + + void NWebImpl::OnFocus() const { +@@ -708,32 +710,26 @@ void NWebImpl::OnFocus() const { + return; + } + nweb_delegate_->OnFocus(); +-} + +-void NWebImpl::OnBlur() const { +- if (nweb_delegate_ == nullptr) { +- return; +- } +- nweb_delegate_->OnBlur(); + if (inputmethod_handler_ == nullptr) { + return; + } +- inputmethod_handler_->HideTextInput(); ++ inputmethod_handler_->Reattach(nweb_id_, NWebInputMethodHandler::ReattachType::FROM_ONFOCUS); + } + +-void NWebImpl::ReloadOriginalUrl() const { ++void NWebImpl::OnBlur(const BlurReason& blurReason) const { + if (nweb_delegate_ == nullptr) { + return; + } +- +- nweb_delegate_->ReloadOriginalUrl(); +-} +- +-void NWebImpl::SetBrowserUserAgentString(const std::string& user_agent) { +- if (nweb_delegate_ == nullptr) { ++ nweb_delegate_->OnBlur(); ++ if (inputmethod_handler_ == nullptr) { + return; + } +- nweb_delegate_->SetBrowserUserAgentString(user_agent); ++ if (is_enhance_surface_ && blurReason == OHOS::NWeb::BlurReason::WINDOW_BLUR) { ++ return; ++ } ++ inputmethod_handler_->HideTextInput(nweb_id_, NWebInputMethodClient::HideTextinputType::FROM_ONBLUR); ++ inputmethod_handler_->SetFocusStatus(false); + } + + void NWebImpl::PutFindCallback(std::shared_ptr findListener) { +@@ -906,6 +902,134 @@ void NWebImpl::SlideScroll(float vx, float vy) { + return nweb_delegate_->SlideScroll(vx, vy); + } + ++bool NWebImpl::GetCertChainDerData(std::vector& certChainData, bool isSingleCert) { ++ if (nweb_delegate_ == nullptr) { ++ WVLOG_E("get cert chain data failed, nweb_delegate_ is null"); ++ return false; ++ } ++ return nweb_delegate_->GetCertChainDerData(certChainData, isSingleCert); ++} ++ ++void NWebImpl::SetScreenOffSet(double x, double y) { ++ if (inputmethod_handler_) { ++ inputmethod_handler_->SetScreenOffSet(x, y); ++ } ++} ++ ++void NWebImpl::SetAudioMuted(bool muted) { ++ WVLOG_D("SetAudioMuted invoked: %{public}s", (muted ? "true" : "false")); ++ if (nweb_delegate_) { ++ nweb_delegate_->SetAudioMuted(muted); ++ } ++} ++ ++void NWebImpl::SetAudioResumeInterval(int32_t resumeInterval) { ++ int32_t interval = resumeInterval > kMaxResumeInterval ? kMaxResumeInterval : resumeInterval; ++ if (nweb_delegate_) { ++ nweb_delegate_->SetAudioResumeInterval(interval); ++ } ++} ++ ++void NWebImpl::SetAudioExclusive(bool audioExclusive) { ++ if (nweb_delegate_) { ++ nweb_delegate_->SetAudioExclusive(audioExclusive); ++ } ++} ++ ++#if defined (OHOS_NWEB_EX) ++// static ++const std::vector& NWebImpl::GetCommandLineArgsForNWebEx() { ++ return g_browser_args.Get(); ++} ++ ++void NWebImpl::InitBrowserServiceApi(std::vector& browser_args) { ++ auto args = g_browser_args.Pointer(); ++ args->clear(); ++ for (const std::string& arg : browser_args) { ++ args->push_back(arg); ++ } ++ g_browser_service_api_enabled = true; ++} ++ ++bool NWebImpl::GetBrowserServiceApiEnabled() { ++ return g_browser_service_api_enabled; ++} ++ ++void NWebImpl::ReloadOriginalUrl() const { ++ if (nweb_delegate_ == nullptr) { ++ return; ++ } ++ ++ nweb_delegate_->ReloadOriginalUrl(); ++} ++ ++void NWebImpl::SetBrowserUserAgentString(const std::string& user_agent) { ++ if (nweb_delegate_ == nullptr) { ++ return; ++ } ++ nweb_delegate_->SetBrowserUserAgentString(user_agent); ++} ++ ++void NWebImpl::PutWebAppClientExtensionCallback( ++ std::shared_ptr ++ web_app_client_extension_listener) { ++ nweb_delegate_->RegisterWebAppClientExtensionListener( ++ web_app_client_extension_listener); ++} ++ ++void NWebImpl::RemoveWebAppClientExtensionCallback() { ++ nweb_delegate_->UnRegisterWebAppClientExtensionListener(); ++} ++ ++void NWebImpl::SelectAndCopy() const { ++ if (nweb_delegate_ == nullptr) { ++ return; ++ } ++ nweb_delegate_->SelectAndCopy(); ++} ++ ++bool NWebImpl::ShouldShowFreeCopy() const { ++ if (nweb_delegate_ == nullptr) { ++ return false; ++ } ++ return nweb_delegate_->ShouldShowFreeCopy(); ++} ++ ++void NWebImpl::SetForceEnableZoom(bool forceEnableZoom) const { ++ if (nweb_delegate_ == nullptr) { ++ return; ++ } ++ nweb_delegate_->SetForceEnableZoom(forceEnableZoom); ++} ++ ++bool NWebImpl::GetForceEnableZoom() const { ++ if (nweb_delegate_ == nullptr) { ++ return false; ++ } ++ return nweb_delegate_->GetForceEnableZoom(); ++} ++ ++void NWebImpl::SetEnableBlankTargetPopupIntercept(bool enableBlankTargetPopup) const { ++ if (nweb_delegate_ == nullptr) { ++ return; ++ } ++ nweb_delegate_->SetEnableBlankTargetPopupIntercept(enableBlankTargetPopup); ++} ++#endif //OHOS_NWEB_EX ++ ++void NWebImpl::SetShouldFrameSubmissionBeforeDraw(bool should) { ++ if (nweb_delegate_) { ++ nweb_delegate_->SetShouldFrameSubmissionBeforeDraw(should); ++ } ++} ++ ++void NWebImpl::RegisterScreenLockFunction(int32_t windowId, const SetKeepScreenOn&& handle) { ++ NWebScreenLockTracker::Instance().AddScreenLock(windowId, nweb_id_, handle); ++} ++ ++void NWebImpl::UnRegisterScreenLockFunction(int32_t windowId) { ++ NWebScreenLockTracker::Instance().RemoveScreenLock(windowId, nweb_id_); ++} + } // namespace OHOS::NWeb + + using namespace OHOS::NWeb; +@@ -947,3 +1071,16 @@ extern "C" OHOS_NWEB_EXPORT void GetNWeb(int32_t nweb_id, + nweb = it->second; + } + } ++ ++extern "C" OHOS_NWEB_EXPORT void SetHttpDns(const NWebDOHConfig& config) { ++ WVLOG_I("set http dns config mode:%{public}d config: %{public}s", ++ config.doh_mode, config.doh_config.c_str()); ++ net_service::NetHelpers::doh_mode = config.doh_mode; ++ net_service::NetHelpers::doh_config = config.doh_config; ++ ++ if (g_nweb_count != 0) { ++ CefApplyHttpDns(); ++ } else { ++ WVLOG_I("nweb hadn't initiated try to set http dns config later"); ++ } ++} +diff --git a/src/ohos_nweb/src/nweb_impl.h b/src/ohos_nweb/src/nweb_impl.h +index 2a6f2c2b7f6..bd41d526a8e +--- a/src/ohos_nweb/src/nweb_impl.h ++++ b/src/ohos_nweb/src/nweb_impl.h +@@ -40,13 +40,19 @@ class NWebImpl : public NWeb { + + /* event interface */ + void Resize(uint32_t width, uint32_t height) override; +- void OnTouchPress(int32_t id, double x, double y) override; +- void OnTouchRelease(int32_t id, double x, double y) override; +- void OnTouchMove(int32_t id, double x, double y) override; ++ void OnTouchPress(int32_t id, double x, double y, bool from_overlay) override; ++ void OnTouchRelease(int32_t id, ++ double x, ++ double y, ++ bool from_overlay) override; ++ void OnTouchMove(int32_t id, double x, double y, bool from_overlay) override; + void OnTouchCancel() override; + void OnNavigateBack() override; + bool SendKeyEvent(int32_t keyCode, int32_t keyAction) override; +- void SendMouseWheelEvent(double x, double y, double deltaX, double deltaY) override; ++ void SendMouseWheelEvent(double x, ++ double y, ++ double deltaX, ++ double deltaY) override; + void SendMouseEvent(int x, int y, int button, int action, int count) override; + + // public api +@@ -68,7 +74,8 @@ class NWebImpl : public NWeb { + void ExecuteJavaScript(const std::string& code) const override; + void ExecuteJavaScript( + const std::string& code, +- std::shared_ptr> callback) const override; ++ std::shared_ptr>> callback, ++ bool extention) const override; + void PutBackgroundColor(int color) const override; + void InitialScale(float scale) const override; + void OnPause() const override; +@@ -82,7 +89,9 @@ class NWebImpl : public NWeb { + const std::shared_ptr GetNWebHandler() const override; + std::string Title() override; + void CreateWebMessagePorts(std::vector& ports) override; +- void PostWebMessage(std::string& message, std::vector& ports, std::string& targetUri) override; ++ void PostWebMessage(std::string& message, ++ std::vector& ports, ++ std::string& targetUri) override; + void ClosePort(std::string& port_handle) override; + void PostPortMessage(std::string& port_handle, std::shared_ptr data) override; + void SetPortMessageCallback(std::string& port_handle, +@@ -111,7 +120,7 @@ class NWebImpl : public NWeb { + void SetNWebJavaScriptResultCallBack( + std::shared_ptr callback) override; + void OnFocus() const override; +- void OnBlur() const override; ++ void OnBlur(const BlurReason& blurReason) const override; + void StoreWebArchive( + const std::string& base_name, + bool auto_name, +@@ -138,23 +147,45 @@ class NWebImpl : public NWeb { + void ScrollTo(float x, float y) override; + void ScrollBy(float delta_x, float delta_y) override; + void SlideScroll(float vx, float vy) override; ++ bool GetCertChainDerData(std::vector& certChainData, bool isSingleCert) override; ++ void SetScreenOffSet(double x, double y) override; ++ void SetShouldFrameSubmissionBeforeDraw(bool should) override; ++ void RegisterScreenLockFunction(int32_t windowId, const SetKeepScreenOn&& handle) override; ++ void UnRegisterScreenLockFunction(int32_t windowId) override; + + // For NWebEx + static NWebImpl* FromID(int32_t nweb_id); +- void ReloadOriginalUrl() const; ++ std::string GetUrl() const override; ++ void SetAudioMuted(bool muted) override; ++ void SetAudioResumeInterval(int32_t resumeInterval) override; ++ void SetAudioExclusive(bool audioExclusive) override; ++ ++ CefRefPtr GetCefClient() const { ++ return nweb_delegate_ ? nweb_delegate_->GetCefClient() : nullptr; ++ } ++ void AddNWebToMap(uint32_t id, std::shared_ptr& nweb); ++ ++#if defined (OHOS_NWEB_EX) ++ static const std::vector& GetCommandLineArgsForNWebEx(); + static void InitBrowserServiceApi(std::vector& browser_args); + static bool GetBrowserServiceApiEnabled(); +- void SetBrowserUserAgentString(const std::string& user_agent); +- std::string GetUrl() const override; ++ + void PutWebAppClientExtensionCallback( + std::shared_ptr + web_app_client_extension_listener); + void RemoveWebAppClientExtensionCallback(); + +- CefRefPtr GetCefClient() const { +- return nweb_delegate_->GetCefClient(); ++ void ReloadOriginalUrl() const; ++ void SetBrowserUserAgentString(const std::string& user_agent); ++ void SetForceEnableZoom(bool forceEnableZoom) const; ++ bool GetForceEnableZoom() const; ++ void SelectAndCopy() const; ++ bool ShouldShowFreeCopy() const; ++ void SetEnableBlankTargetPopupIntercept(bool enableBlankTargetPopup) const; ++#endif // OHOS_NWEB_EX ++ void NotifyPopupWindowResult(bool result) override { ++ nweb_delegate_->NotifyPopupWindowResult(result); + } +- void AddNWebToMap(uint32_t id, std::shared_ptr& nweb); + private: + void ProcessInitArgs(const NWebInitArgs& init_args); + void InitWebEngineArgs(const NWebInitArgs& init_args); +@@ -172,6 +203,7 @@ class NWebImpl : public NWeb { + std::shared_ptr nweb_delegate_ = nullptr; + std::list web_engine_args_; + float device_pixel_ratio_ = 0.f; ++ bool is_enhance_surface_ = false; + }; + } // namespace OHOS::NWeb + +diff --git a/src/ohos_nweb/src/nweb_input_handler.cc b/src/ohos_nweb/src/nweb_input_handler.cc +index 3333952bfc3..7442f3b3ed3 +--- a/src/ohos_nweb/src/nweb_input_handler.cc ++++ b/src/ohos_nweb/src/nweb_input_handler.cc +@@ -41,11 +41,14 @@ void NWebInputHandler::OnDestroy() { + nweb_delegate_ = nullptr; + } + +-void NWebInputHandler::OnTouchPress(int32_t id, double x, double y) { ++void NWebInputHandler::OnTouchPress(int32_t id, ++ double x, ++ double y, ++ bool from_overlay) { + if (nweb_delegate_ == nullptr) { + return; + } +- nweb_delegate_->OnTouchPress(id, x, y); ++ nweb_delegate_->OnTouchPress(id, x, y, from_overlay); + + touch_press_id_map_[id] = true; + last_touch_start_x_ = x; +@@ -53,7 +56,10 @@ void NWebInputHandler::OnTouchPress(int32_t id, double x, double y) { + last_y_ = y; + } + +-void NWebInputHandler::OnTouchRelease(int32_t id, double x, double y) { ++void NWebInputHandler::OnTouchRelease(int32_t id, ++ double x, ++ double y, ++ bool from_overlay) { + if (nweb_delegate_ == nullptr) { + return; + } +@@ -61,17 +67,20 @@ void NWebInputHandler::OnTouchRelease(int32_t id, double x, double y) { + x = last_x_; + y = last_y_; + } +- nweb_delegate_->OnTouchRelease(id, x, y); ++ nweb_delegate_->OnTouchRelease(id, x, y, from_overlay); + CheckSlideNavigation(last_touch_start_x_, x); + touch_press_id_map_.erase(id); + } + +-void NWebInputHandler::OnTouchMove(int32_t id, double x, double y) { ++void NWebInputHandler::OnTouchMove(int32_t id, ++ double x, ++ double y, ++ bool from_overlay) { + if (nweb_delegate_ == nullptr) { + return; + } + +- nweb_delegate_->OnTouchMove(id, x, y); ++ nweb_delegate_->OnTouchMove(id, x, y, from_overlay); + last_x_ = x; + last_y_ = y; + } +@@ -101,14 +110,21 @@ bool NWebInputHandler::SendKeyEvent(int32_t keyCode, int32_t keyAction) { + return nweb_delegate_->SendKeyEvent(keyCode, keyAction); + } + +-void NWebInputHandler::SendMouseWheelEvent(double x, double y, double deltaX, double deltaY) { ++void NWebInputHandler::SendMouseWheelEvent(double x, ++ double y, ++ double deltaX, ++ double deltaY) { + if (nweb_delegate_ == nullptr) { + return; + } + nweb_delegate_->SendMouseWheelEvent(x, y, deltaX, deltaY); + } + +-void NWebInputHandler::SendMouseEvent(int x, int y, int button, int action, int count) { ++void NWebInputHandler::SendMouseEvent(int x, ++ int y, ++ int button, ++ int action, ++ int count) { + if (nweb_delegate_ == nullptr) { + return; + } +diff --git a/src/ohos_nweb/src/nweb_input_handler.h b/src/ohos_nweb/src/nweb_input_handler.h +index 94a8857352c..e4c8bc8d32d +--- a/src/ohos_nweb/src/nweb_input_handler.h ++++ b/src/ohos_nweb/src/nweb_input_handler.h +@@ -26,17 +26,16 @@ class NWebInputHandler { + static std::shared_ptr Create( + std::shared_ptr nweb_delegate); + +- NWebInputHandler( +- std::shared_ptr nweb_delegate); ++ NWebInputHandler(std::shared_ptr nweb_delegate); + ~NWebInputHandler() = default; + + bool Init(); + void OnDestroy(); + + /* event interface */ +- void OnTouchPress(int32_t id, double x, double y); +- void OnTouchRelease(int32_t id, double x, double y); +- void OnTouchMove(int32_t id, double x, double y); ++ void OnTouchPress(int32_t id, double x, double y, bool from_overlay); ++ void OnTouchRelease(int32_t id, double x, double y, bool from_overlay); ++ void OnTouchMove(int32_t id, double x, double y, bool from_overlay); + void OnTouchCancel(); + void OnNavigateBack(); + bool SendKeyEvent(int32_t keyCode, int32_t keyAction); +@@ -53,6 +52,6 @@ class NWebInputHandler { + double last_y_ = -1; + std::unordered_map touch_press_id_map_; + }; +-} ++} // namespace OHOS::NWeb + + #endif // NWEB_INPUT_HANDLER_H +diff --git a/src/ohos_nweb/src/nweb_inputmethod_handler.cc b/src/ohos_nweb/src/nweb_inputmethod_handler.cc +index e781746ea40..135092dedc7 +--- a/src/ohos_nweb/src/nweb_inputmethod_handler.cc ++++ b/src/ohos_nweb/src/nweb_inputmethod_handler.cc +@@ -15,8 +15,6 @@ + + #include "nweb_inputmethod_handler.h" + +-#include "input_method_utils.h" +- + #include "base/bind.h" + #include "base/callback.h" + #include "base/callback_helpers.h" +@@ -24,17 +22,18 @@ + #include "cef/include/cef_task.h" + #include "content/public/browser/browser_thread.h" + #include "libcef/browser/thread_util.h" ++#include "ohos_adapter_helper.h" + #include "ui/events/keycodes/keyboard_codes_posix.h" + + namespace OHOS::NWeb { +-using namespace OHOS::MiscServices; + + static constexpr char16_t DEL_CHAR = 127; + +-class OnTextChangedListenerImpl : public OnTextChangedListener { ++class OnTextChangedListenerImpl : public IMFTextListenerAdapter { + public: + OnTextChangedListenerImpl(NWebInputMethodHandler* handler) + : handler_(handler) {} ++ ~OnTextChangedListenerImpl() = default; + + // All following listenser callbacks should invoke call on UI thread + void InsertText(const std::u16string& text) override { +@@ -52,36 +51,38 @@ class OnTextChangedListenerImpl : public OnTextChangedListener { + handler_->DeleteBackward(length); + } + +- void SendKeyEventFromInputMethod(const KeyEvent& event) override { ++ void SendKeyEventFromInputMethod() override { + LOG(INFO) << "NWebInputMethodHandler::SendKeyEventFromInputMethod"; + } + +- void SendKeyboardInfo(const KeyboardInfo& info) override { +- auto status = info.GetKeyboardStatus(); +- if (status == KeyboardStatus::SHOW) { ++ void SendKeyboardStatus(const IMFAdapterKeyboardStatus& status) override { ++ if (status == IMFAdapterKeyboardStatus::SHOW) { + handler_->SetIMEStatus(true); +- } else if (status == KeyboardStatus::HIDE) { ++ } else if (status == IMFAdapterKeyboardStatus::HIDE) { + handler_->SetIMEStatus(false); +- } else if (status == KeyboardStatus::NONE) { +- handler_->SendEnterKeyEvent(); + } + } + ++ void SendFunctionKey(const IMFAdapterFunctionKey& functionKey) override ++ { ++ handler_->SendEnterKeyEvent(); ++ } ++ + void SetKeyboardStatus(bool status) override { + handler_->SetIMEStatus(status); + } + +- void MoveCursor(const Direction direction) override { +- if (direction == Direction::NONE) { ++ void MoveCursor(const IMFAdapterDirection direction) override { ++ if (direction == IMFAdapterDirection::NONE) { + LOG(ERROR) << "NWebInputMethodHandler::MoveCursor got none direction"; + return; + } + handler_->MoveCursor(direction); + } + +- void HandleSetSelection(int32_t start, int32_t end) override {}; +- void HandleExtendAction(int32_t action) override {}; +- void HandleSelect(int32_t keyCode, int32_t cursorMoveSkip) override {}; ++ void HandleSetSelection(int32_t start, int32_t end) override{}; ++ void HandleExtendAction(int32_t action) override{}; ++ void HandleSelect(int32_t keyCode, int32_t cursorMoveSkip) override{}; + + private: + NWebInputMethodHandler* handler_; +@@ -89,14 +90,15 @@ class OnTextChangedListenerImpl : public OnTextChangedListener { + + class InputMethodTask : public CefTask { + public: +- explicit InputMethodTask(base::OnceClosure closure) : closure_(std::move(closure)) {} ++ explicit InputMethodTask(base::OnceClosure closure) ++ : closure_(std::move(closure)) {} + + InputMethodTask(const InputMethodTask&) = delete; + InputMethodTask& operator=(const InputMethodTask&) = delete; + + virtual void Execute() override { + std::move(closure_).Run(); +- //closure_.Reset(); ++ // closure_.Reset(); + } + + private: +@@ -106,24 +108,109 @@ class InputMethodTask : public CefTask { + }; + + NWebInputMethodHandler::NWebInputMethodHandler() +- : selected_from_(0), selected_to_(0) {} ++ : selected_from_(0), selected_to_(0) { ++ inputmethod_adapter_ = OhosAdapterHelper::GetInstance().CreateIMFAdapter(); ++ if (inputmethod_adapter_ == nullptr) { ++ LOG(ERROR) << "inputmethod_adapter_ create failed"; ++ } ++} + + NWebInputMethodHandler::~NWebInputMethodHandler() {} + ++uint32_t NWebInputMethodHandler::lastAttachNWebId_ = 0; ++ + void NWebInputMethodHandler::Attach(CefRefPtr browser, +- bool show_keyboard) { ++ bool show_keyboard, ++ cef_text_input_mode_t input_mode) { ++ show_keyboard_ = show_keyboard; ++ input_mode_ = input_mode; + composing_text_.clear(); + browser_ = browser; ++ if (inputmethod_adapter_ == nullptr) { ++ LOG(ERROR) << "inputmethod_adapter_ is nullptr"; ++ return; ++ } + if (inputmethod_listener_ == nullptr) { +- inputmethod_listener_ = new OnTextChangedListenerImpl(this); ++ inputmethod_listener_ = std::make_shared(this); + } +- + if (show_keyboard && isAttached_) { +- LOG(INFO) << "Attach ShowCurrentInput" ; +- InputMethodController::GetInstance()->ShowCurrentInput(); ++ if (input_mode == CEF_TEXT_INPUT_MODE_NUMERIC) { ++ inputmethod_adapter_->ShowCurrentInput(IMFAdapterTextInputType::NUMBER); ++ } else { ++ inputmethod_adapter_->ShowCurrentInput(IMFAdapterTextInputType::TEXT); ++ } ++ } else { ++ if (!inputmethod_adapter_->Attach(inputmethod_listener_, show_keyboard)) { ++ LOG(ERROR) << "inputmethod_adapter_ attach failed"; ++ return; ++ } ++ isAttached_ = true; ++ lastAttachNWebId_ = nweb_Id_; ++ } ++ ++ if (focus_status_ && focus_rect_status_) { ++ IMFAdapterCursorInfo cursorInfo{ ++ .left = (focus_rect_.x + focus_rect_.width) * device_pixel_ratio_ + ++ offset_x_, ++ .top = focus_rect_.y * device_pixel_ratio_ + offset_y_, ++ .width = focus_rect_.width * device_pixel_ratio_, ++ .height = focus_rect_.height * device_pixel_ratio_}; ++ LOG(DEBUG) << "NWebInputMethodHandler::Attach cursorInfo.left = " ++ << cursorInfo.left << ", cursorInfo.top = " << cursorInfo.top ++ << ", cursorInfo.width = " << cursorInfo.width ++ << ", cursorInfo.height = " << cursorInfo.height; ++ if (inputmethod_adapter_) { ++ inputmethod_adapter_->OnCursorUpdate(cursorInfo); ++ } ++ } ++} ++ ++void NWebInputMethodHandler::Reattach(uint32_t nwebId, ReattachType type) { ++ nweb_Id_ = nwebId; ++ if (type == ReattachType::FROM_CONTINUE) { ++ if (!isNeedReattachOncontinue_) { ++ LOG(INFO) << "don't need reattach input method"; ++ return; ++ } ++ isNeedReattachOncontinue_ = false; ++ } ++ ++ if (type == ReattachType::FROM_ONFOCUS) { ++ if (!isNeedReattachOnfocus_) { ++ LOG(INFO) << "ReAttchOnfocus, don't need reattach input method"; ++ return; ++ } ++ isNeedReattachOnfocus_ = false; ++ } ++ ++ LOG(INFO) << "need to reattach input method, show_keyboard_ = " ++ << show_keyboard_ << ", \ ++ reattach type = " ++ << static_cast(type); ++ composing_text_.clear(); ++ if (inputmethod_listener_ == nullptr) { ++ inputmethod_listener_ = std::make_shared(this); ++ } ++ ++ if (!show_keyboard_ && !isAttached_) { ++ inputmethod_adapter_->HideTextInput(); ++ inputmethod_adapter_->Close(); ++ return; ++ } ++ ++ if (show_keyboard_ && isAttached_) { ++ if (input_mode_ == CEF_TEXT_INPUT_MODE_NUMERIC) { ++ inputmethod_adapter_->ShowCurrentInput(IMFAdapterTextInputType::NUMBER); ++ } else { ++ inputmethod_adapter_->ShowCurrentInput(IMFAdapterTextInputType::TEXT); ++ } + } else { +- InputMethodController::GetInstance()->Attach(inputmethod_listener_, show_keyboard); ++ if (!inputmethod_adapter_->Attach(inputmethod_listener_, show_keyboard_)) { ++ LOG(ERROR) << "inputmethod_adapter_ attach failed"; ++ return; ++ } + isAttached_ = true; ++ lastAttachNWebId_ = nwebId; + } + } + +@@ -131,14 +218,48 @@ void NWebInputMethodHandler::ShowTextInput() { + LOG(INFO) << "NWebInputMethodHandler::ShowTextInput"; + } + +-void NWebInputMethodHandler::HideTextInput() { ++void NWebInputMethodHandler::HideTextInput(uint32_t nwebId, HideTextinputType hideType) { ++ if (inputmethod_adapter_ == nullptr) { ++ LOG(ERROR) << "inputmethod_adapter_ is nullptr"; ++ return; ++ } + if (!isAttached_) { + LOG(INFO) << "keyboard is not attach"; ++ if (hideType != HideTextinputType::FROM_ONPAUSE) { ++ LOG(INFO) << "not from switch front and background, ingnore"; ++ return; ++ } ++ auto nowTime = std::chrono::high_resolution_clock::now(); ++ std::chrono::duration diff = ++ std::chrono::duration_cast( ++ nowTime - lastCloseInputMethodTime_); ++ // 100: received another hide textinput event in 100ms, we set ++ // isNeedReattachOncontinue_ flag. ++ if (diff.count() < 100) { ++ isNeedReattachOncontinue_ = true; ++ LOG(INFO) << "set isNeedReattachOncontinue_ flag, diff = " << diff.count() ++ << "ms"; ++ } + return; + } +- InputMethodController::GetInstance()->HideTextInput(); +- InputMethodController::GetInstance()->Close(); ++ ++ if (lastAttachNWebId_ == 0 || lastAttachNWebId_ == nwebId || ++ hideType == HideTextinputType::FROM_KERNEL) { ++ LOG(INFO) << "need to hide text input, hidetype = " ++ << static_cast(hideType); ++ inputmethod_adapter_->HideTextInput(); ++ inputmethod_adapter_->Close(); ++ } ++ ++ lastCloseInputMethodTime_ = std::chrono::high_resolution_clock::now(); + isAttached_ = false; ++ if (hideType == HideTextinputType::FROM_ONPAUSE) { ++ isNeedReattachOncontinue_ = true; ++ } ++ ++ if (hideType == HideTextinputType::FROM_ONBLUR) { ++ isNeedReattachOnfocus_ = true; ++ } + } + + void NWebInputMethodHandler::OnTextSelectionChanged( +@@ -157,6 +278,35 @@ void NWebInputMethodHandler::OnTextSelectionChanged( + composing_text_.clear(); + } + ++void NWebInputMethodHandler::OnCursorUpdate(const CefRect& rect) { ++ focus_rect_ = rect; ++ focus_rect_status_ = true; ++ if (focus_status_) { ++ IMFAdapterCursorInfo cursorInfo{ ++ .left = (rect.x + rect.width) * device_pixel_ratio_ + offset_x_, ++ .top = rect.y * device_pixel_ratio_ + offset_y_, ++ .width = rect.width * device_pixel_ratio_, ++ .height = rect.height * device_pixel_ratio_}; ++ LOG(DEBUG) << "NWebInputMethodHandler::OnCursorUpdate cursorInfo.left = " ++ << cursorInfo.left << ", cursorInfo.top = " << cursorInfo.top ++ << ", cursorInfo.width = " << cursorInfo.width ++ << ", cursorInfo.height = " << cursorInfo.height; ++ if (inputmethod_adapter_) { ++ inputmethod_adapter_->OnCursorUpdate(cursorInfo); ++ } ++ } ++} ++ ++void NWebInputMethodHandler::OnSelectionChanged( ++ CefRefPtr browser, ++ const CefString& text, ++ const CefRange& selected_range) { ++ if (inputmethod_adapter_) { ++ inputmethod_adapter_->OnSelectionChange( ++ text.ToString16(), selected_range.from, selected_range.to); ++ } ++} ++ + void NWebInputMethodHandler::SetIMEStatus(bool status) { + if (browser_ != nullptr && browser_->GetHost() != nullptr) { + CefRefPtr insert_task = new InputMethodTask(base::BindOnce( +@@ -222,7 +372,7 @@ void NWebInputMethodHandler::InsertTextHandlerOnUI(const std::u16string& text) { + } + composing_text_.append(text); + browser_->GetHost()->ImeCommitText(composing_text_, +- CefRange(UINT32_MAX, UINT32_MAX), 0); ++ CefRange(UINT32_MAX, UINT32_MAX), 0); + + // no selection + ime_text_composing_ = false; +@@ -234,7 +384,7 @@ void NWebInputMethodHandler::InsertTextHandlerOnUI(const std::u16string& text) { + browser_->GetHost()->SendKeyEvent(keyEvent); + } + +-void NWebInputMethodHandler::DeleteBackwardHandlerOnUI(int32_t length) { ++void NWebInputMethodHandler::DeleteForwardHandlerOnUI(int32_t length) { + CefKeyEvent keyEvent; + keyEvent.windows_key_code = ui::VKEY_DELETE; + keyEvent.native_key_code = static_cast(ScanKeyCode::DELETE_SCAN_CODE); +@@ -257,7 +407,7 @@ void NWebInputMethodHandler::DeleteBackwardHandlerOnUI(int32_t length) { + browser_->GetHost()->SendKeyEvent(keyEvent); + } + +-void NWebInputMethodHandler::DeleteForwardHandlerOnUI(int32_t length) { ++void NWebInputMethodHandler::DeleteBackwardHandlerOnUI(int32_t length) { + CefKeyEvent keyEvent; + keyEvent.windows_key_code = ui::VKEY_BACK; + keyEvent.native_key_code = static_cast(ScanKeyCode::BACKSPACE_SCAN_CODE); +@@ -304,27 +454,27 @@ void NWebInputMethodHandler::SendEnterKeyEvent() { + } + } + +-void NWebInputMethodHandler::MoveCursor(const Direction direction) { ++void NWebInputMethodHandler::MoveCursor(const IMFAdapterDirection direction) { + LOG(INFO) << "NWebInputMethodHandler::MoveCursor called"; + CefKeyEvent keyEvent; + + switch (direction) { +- case Direction::UP: { ++ case IMFAdapterDirection::UP: { + keyEvent.windows_key_code = ui::VKEY_UP; + keyEvent.native_key_code = static_cast(ScanKeyCode::UP_SCAN_CODE); + break; + } +- case Direction::LEFT: { ++ case IMFAdapterDirection::LEFT: { + keyEvent.windows_key_code = ui::VKEY_LEFT; + keyEvent.native_key_code = static_cast(ScanKeyCode::LEFT_SCAN_CODE); + break; + } +- case Direction::RIGHT: { ++ case IMFAdapterDirection::RIGHT: { + keyEvent.windows_key_code = ui::VKEY_RIGHT; + keyEvent.native_key_code = static_cast(ScanKeyCode::RIGHT_SCAN_CODE); + break; + } +- case Direction::DOWN: { ++ case IMFAdapterDirection::DOWN: { + keyEvent.windows_key_code = ui::VKEY_DOWN; + keyEvent.native_key_code = static_cast(ScanKeyCode::DOWN_SCAN_CODE); + break; +@@ -347,4 +497,48 @@ void NWebInputMethodHandler::MoveCursor(const Direction direction) { + browser_->GetHost()->SendKeyEvent(keyEvent); + } + } ++ ++void NWebInputMethodHandler::SetScreenOffSet(double x, double y) { ++ if (focus_status_) { ++ if (focus_rect_status_ && (offset_x_ != x || offset_y_ != y)) { ++ IMFAdapterCursorInfo cursorInfo{ ++ .left = (focus_rect_.x + focus_rect_.width) * device_pixel_ratio_ + x, ++ .top = focus_rect_.y * device_pixel_ratio_ + y, ++ .width = focus_rect_.width * device_pixel_ratio_, ++ .height = focus_rect_.height * device_pixel_ratio_}; ++ LOG(DEBUG) << "NWebInputMethodHandler::SetScreenOffSet cursorInfo.left = " ++ << cursorInfo.left << ", cursorInfo.top = " << cursorInfo.top ++ << ", cursorInfo.width = " << cursorInfo.width ++ << ", cursorInfo.height = " << cursorInfo.height; ++ if (inputmethod_adapter_) { ++ inputmethod_adapter_->OnCursorUpdate(cursorInfo); ++ } ++ } ++ } ++ offset_x_ = x; ++ offset_y_ = y; ++} ++ ++void NWebInputMethodHandler::SetVirtualDeviceRatio(float device_pixel_ratio) { ++ device_pixel_ratio_ = device_pixel_ratio; ++} ++ ++void NWebInputMethodHandler::SetFocusStatus(bool focus_status) { ++ if (focus_status && focus_rect_status_) { ++ IMFAdapterCursorInfo cursorInfo{ ++ .left = (focus_rect_.x + focus_rect_.width) * device_pixel_ratio_ + ++ offset_x_, ++ .top = focus_rect_.y * device_pixel_ratio_ + offset_y_, ++ .width = focus_rect_.width * device_pixel_ratio_, ++ .height = focus_rect_.height * device_pixel_ratio_}; ++ LOG(DEBUG) << "NWebInputMethodHandler::SetFocusStatus cursorInfo.left = " ++ << cursorInfo.left << ", cursorInfo.top = " << cursorInfo.top ++ << ", cursorInfo.width = " << cursorInfo.width ++ << ", cursorInfo.height = " << cursorInfo.height; ++ if (inputmethod_adapter_) { ++ inputmethod_adapter_->OnCursorUpdate(cursorInfo); ++ } ++ } ++ focus_status_ = focus_status; ++} + } // namespace OHOS::NWeb +diff --git a/src/ohos_nweb/src/nweb_inputmethod_handler.h b/src/ohos_nweb/src/nweb_inputmethod_handler.h +index de7a41abafc..827219cb593 +--- a/src/ohos_nweb/src/nweb_inputmethod_handler.h ++++ b/src/ohos_nweb/src/nweb_inputmethod_handler.h +@@ -17,31 +17,44 @@ + #define OHOS_NWEB_SRC_NWEB_INPUTMETHOD_HANDLER_H_ + #include + #include +-#include "input_method_controller.h" ++#include ++#include "imf_adapter.h" + + #include "cef_delegate/nweb_inputmethod_client.h" + + namespace OHOS::NWeb { + class NWebInputMethodHandler : public NWebInputMethodClient { + public: ++ enum class ReattachType { ++ FROM_ONFOCUS, ++ FROM_CONTINUE, ++ }; + NWebInputMethodHandler(); + ~NWebInputMethodHandler(); + NWebInputMethodHandler(const NWebInputMethodHandler&) = delete; + NWebInputMethodHandler& operator=(const NWebInputMethodHandler&) = delete; + +- void Attach(CefRefPtr browser, bool show_keyboard) override; ++ void Attach(CefRefPtr browser, bool show_keyboard, cef_text_input_mode_t input_mode) override; + void ShowTextInput() override; +- void HideTextInput() override; ++ void HideTextInput(uint32_t nwebId = 0, HideTextinputType hideType = HideTextinputType::FROM_KERNEL) override; + void OnTextSelectionChanged(CefRefPtr browser, + const CefString& selected_text, + const CefRange& selected_range) override; ++ void OnCursorUpdate(const CefRect& rect) override; ++ void OnSelectionChanged(CefRefPtr browser, ++ const CefString& text, ++ const CefRange& selected_range) override; ++ void SetFocusStatus(bool focus_status) override; + ++ void Reattach(uint32_t nwebId, ReattachType type); + void SetIMEStatus(bool status); + void InsertText(const std::u16string& text); + void DeleteBackward(int32_t length); + void DeleteForward(int32_t length); + void SendEnterKeyEvent(); +- void MoveCursor(const OHOS::MiscServices::Direction direction); ++ void MoveCursor(const IMFAdapterDirection direction); ++ void SetScreenOffSet(double x, double y); ++ void SetVirtualDeviceRatio(float device_pixel_ratio); + + private: + void SetIMEStatusOnUI(bool status); +@@ -56,9 +69,22 @@ class NWebInputMethodHandler : public NWebInputMethodClient { + std::u16string composing_text_; + int selected_from_; + int selected_to_; +- OHOS::sptr inputmethod_listener_ = +- nullptr; ++ CefRect focus_rect_; ++ double offset_x_ = 0; ++ double offset_y_ = 0; ++ float device_pixel_ratio_; ++ bool focus_status_ = false; ++ bool focus_rect_status_ = false; ++ std::unique_ptr inputmethod_adapter_ = nullptr; ++ std::shared_ptr inputmethod_listener_ = nullptr; + bool isAttached_ = false; ++ bool show_keyboard_ = false; ++ bool isNeedReattachOncontinue_ = false; ++ cef_text_input_mode_t input_mode_ = CEF_TEXT_INPUT_MODE_NONE; ++ std::chrono::high_resolution_clock::time_point lastCloseInputMethodTime_; ++ bool isNeedReattachOnfocus_ = false; ++ uint32_t nweb_Id_ = 0; ++ static uint32_t lastAttachNWebId_; + + IMPLEMENT_REFCOUNTING(NWebInputMethodHandler); + }; +diff --git a/src/ohos_nweb/src/nweb_output_handler.cc b/src/ohos_nweb/src/nweb_output_handler.cc +index f9abaef29ed..4b6f02489b8 +--- a/src/ohos_nweb/src/nweb_output_handler.cc ++++ b/src/ohos_nweb/src/nweb_output_handler.cc +@@ -24,8 +24,8 @@ + #include + #include + #include +-#include + #include "nweb_hilog.h" ++#include "ohos_adapter_helper.h" + + namespace OHOS::NWeb { + namespace { +@@ -112,7 +112,6 @@ void NWebOutputHandler::Resize(uint32_t width, uint32_t height) { + if (!dump_path_.empty() || dump_buf_ == nullptr) { + dump_buf_.reset(new char[frame_size_]); + } +- NativeWindowHandleOpt(window_, SET_BUFFER_GEOMETRY, width_, height_); + } + } + +@@ -254,9 +253,9 @@ void NWebOutputHandler::BmpDumpHelper::RgbaToRgb(char* buf, + if (i % 4 == 3) { + // check alpha value, if 0, set related color to white + if (buf[i] == 0) { +- *(p_rgb - 3) = 255; +- *(p_rgb - 2) = 255; +- *(p_rgb - 1) = 255; ++ *(p_rgb - 3) = 0xff; ++ *(p_rgb - 2) = 0xff; ++ *(p_rgb - 1) = 0xff; + } + continue; + } +@@ -310,9 +309,10 @@ bool NWebOutputHandler::IsSizeValid() + return (width_ > 0) && (height_ > 0); + } + +-NativeWindow* NWebOutputHandler::GetNativeWindowFromSurface(void* surface) { +- window_ = CreateNativeWindowFromSurface(surface); +- NativeWindowHandleOpt(window_, SET_BUFFER_GEOMETRY, width_, height_); ++void* NWebOutputHandler::GetNativeWindowFromSurface(void* surface) { ++ window_ = OHOS::NWeb::OhosAdapterHelper::GetInstance() ++ .GetWindowAdapterInstance() ++ .CreateNativeWindowFromSurface(surface); + return window_; + } + } // namespace OHOS::NWeb +diff --git a/src/ohos_nweb/src/nweb_output_handler.h b/src/ohos_nweb/src/nweb_output_handler.h +index 0b4f34e05a0..a6f1a3b90e7 +--- a/src/ohos_nweb/src/nweb_output_handler.h ++++ b/src/ohos_nweb/src/nweb_output_handler.h +@@ -21,8 +21,6 @@ + #include + #include + +-struct NativeWindow; +- + namespace OHOS::NWeb { + class NWebOutputHandler + : public std::enable_shared_from_this { +@@ -47,7 +45,7 @@ class NWebOutputHandler + void SetNWebId(uint32_t id); + bool IsSizeValid(); + +- NativeWindow* GetNativeWindowFromSurface(void* surface); ++ void* GetNativeWindowFromSurface(void* surface); + + private: + class BmpDumpHelper { +@@ -73,7 +71,7 @@ class NWebOutputHandler + uint32_t height_ = 0; + uint32_t frame_size_ = 0; + +- NativeWindow* window_ = nullptr; ++ void* window_ = nullptr; + + std::function output_frame_cb_; + +diff --git a/src/ohos_nweb/src/sysevent/event_reporter.cc b/src/ohos_nweb/src/sysevent/event_reporter.cc +index 3263a19fb7b..73392533cbc +--- a/src/ohos_nweb/src/sysevent/event_reporter.cc ++++ b/src/ohos_nweb/src/sysevent/event_reporter.cc +@@ -14,12 +14,12 @@ + */ + + #include "event_reporter.h" +-#include +- +-using namespace OHOS::HiviewDFX; ++#include "ohos_adapter_helper.h" + ++using OHOS::NWeb::HiSysEventAdapter; ++using OHOS::NWeb::OhosAdapterHelper; + namespace { +-//For page load statistics ++// For page load statistics + constexpr char PAGE_LOAD_STATISTICS[] = "PAGE_LOAD_STATISTICS"; + constexpr char CURRENT_INSTANCE_ID[] = "INSTANCE_ID"; + constexpr char ACCESS_SUM_COUNT[] = "ACCESS_SUM_COUNT"; +@@ -27,31 +27,41 @@ constexpr char ACCESS_SUCC_COUNT[] = "ACCESS_SUCC_COUNT"; + constexpr char ACCESS_FAIL_COUNT[] = "ACCESS_FAIL_COUNT"; + constexpr char ACCESS_FAIL_RATIO[] = "ACCESS_FAIL_RATIO"; + +-//For mutiple instance statistics ++// For mutiple instance statistics + constexpr char MULTI_INSTANCE_STATISTICS[] = "MULTI_INSTANCE_STATISTICS"; + constexpr char CURRENT_INSTANCE_COUNT[] = "INSTANCE_COUNT"; + constexpr char INSTANCE_MAX_COUNT[] = "MAX_COUNT"; + +-//For page load error info ++// For page load error info + constexpr char PAGE_LOAD_ERROR[] = "PAGE_LOAD_ERROR"; + constexpr char ERROR_TYPE[] = "ERROR_TYPE"; + constexpr char ERROR_CODE[] = "ERROR_CODE"; + constexpr char ERROR_DESC[] = "ERROR_DESC"; +-} ++} // namespace + +-void ReportPageLoadStats(int instanceId, int accessSumCount, int accessSuccCount, int accessFailCount) { +- float failRatio = float(accessFailCount)/accessSumCount; +- HiSysEvent::Write(HiSysEvent::Domain::WEBVIEW, PAGE_LOAD_STATISTICS, HiSysEvent::EventType::STATISTIC, +- CURRENT_INSTANCE_ID, instanceId, ACCESS_SUM_COUNT, accessSumCount, ACCESS_SUCC_COUNT, accessSuccCount, +- ACCESS_FAIL_COUNT, accessFailCount, ACCESS_FAIL_RATIO, failRatio); ++void ReportPageLoadStats(int instanceId, ++ int accessSumCount, ++ int accessSuccCount, ++ int accessFailCount) { ++ float failRatio = float(accessFailCount) / accessSumCount; ++ OhosAdapterHelper::GetInstance().GetHiSysEventAdapterInstance().Write( ++ PAGE_LOAD_STATISTICS, HiSysEventAdapter::EventType::STATISTIC, ++ {CURRENT_INSTANCE_ID, instanceId, ACCESS_SUM_COUNT, accessSumCount, ++ ACCESS_SUCC_COUNT, accessSuccCount, ACCESS_FAIL_COUNT, accessFailCount, ++ ACCESS_FAIL_RATIO, failRatio}); + } + + void ReportMultiInstanceStats(int instanceId, int nwebCount, int nwebMaxCount) { +- HiSysEvent::Write(HiSysEvent::Domain::WEBVIEW, MULTI_INSTANCE_STATISTICS, HiSysEvent::EventType::STATISTIC, +- CURRENT_INSTANCE_ID, instanceId, CURRENT_INSTANCE_COUNT, nwebCount, INSTANCE_MAX_COUNT, nwebMaxCount); ++ OhosAdapterHelper::GetInstance().GetHiSysEventAdapterInstance().Write( ++ MULTI_INSTANCE_STATISTICS, HiSysEventAdapter::EventType::STATISTIC, ++ {CURRENT_INSTANCE_ID, instanceId, CURRENT_INSTANCE_COUNT, nwebCount, ++ INSTANCE_MAX_COUNT, nwebMaxCount}); + } + +-void ReportPageLoadErrorInfo(int instanceId, const std::string errorType, int errorCode, const std::string errorDesc) { ++void ReportPageLoadErrorInfo(int instanceId, ++ const std::string errorType, ++ int errorCode, ++ const std::string errorDesc) { + std::string error_type = ""; + std::string error_desc = ""; + int error_code = errorCode; +@@ -61,7 +71,8 @@ void ReportPageLoadErrorInfo(int instanceId, const std::string errorType, int er + if (errorDesc != "") { + error_desc = errorDesc; + } +- HiSysEvent::Write(HiSysEvent::Domain::WEBVIEW, PAGE_LOAD_ERROR, HiSysEvent::EventType::FAULT, +- CURRENT_INSTANCE_ID, instanceId, ERROR_TYPE, error_type, ERROR_CODE, error_code, ERROR_DESC, error_desc); ++ OhosAdapterHelper::GetInstance().GetHiSysEventAdapterInstance().Write( ++ PAGE_LOAD_ERROR, HiSysEventAdapter::EventType::FAULT, ++ {CURRENT_INSTANCE_ID, instanceId, ERROR_TYPE, error_type, ERROR_CODE, ++ error_code, ERROR_DESC, error_desc}); + } +- +diff --git a/src/services/device/geolocation/BUILD.gn b/src/services/device/geolocation/BUILD.gn +index ab4f9d945d3..c0a017dd816 +--- a/src/services/device/geolocation/BUILD.gn ++++ b/src/services/device/geolocation/BUILD.gn +@@ -73,9 +73,7 @@ source_set("geolocation") { + include_dirs = ohos_src_includes + lib_dirs = ohos_libs_dir + libs = [ +- "locator_sdk.z", +- "ipc_core.z", +- "lbsservice_common.z", ++ "nweb_ohos_adapter.z", + ] + } + +diff --git a/src/services/device/geolocation/ohos/location_provider_ohos.cc b/src/services/device/geolocation/ohos/location_provider_ohos.cc +index a2b16ceddb3..f081cbbf127 +--- a/src/services/device/geolocation/ohos/location_provider_ohos.cc ++++ b/src/services/device/geolocation/ohos/location_provider_ohos.cc +@@ -6,10 +6,6 @@ + + #include + +-#include +-#include +-#include +- + #include "base/bind.h" + #include "base/memory/singleton.h" + +@@ -17,7 +13,7 @@ namespace device { + class GeolocationManager; + // LocationProviderOhos + LocationProviderOhos::LocationProviderOhos() { +- locator_callback_ = new LocationProviderCallback(); ++ locator_callback_ = std::make_shared(); + } + + LocationProviderOhos::~LocationProviderOhos() { +@@ -34,6 +30,10 @@ void LocationProviderOhos::SetUpdateCallback( + const LocationProviderUpdateCallback& callback) { + callback_ = callback; + ++ if (!locator_callback_) { ++ return; ++ } ++ + locator_callback_->SetUpdateCallback(base::BindRepeating( + &LocationProviderOhos::ProviderUpdateCallback, base::Unretained(this))); + } +@@ -53,9 +53,9 @@ void LocationProviderOhos::StopProvider() { + if (!is_running_) + return; + is_running_ = false; +- OHOS::sptr locator_call_back = +- locator_callback_; +- locator_->StopLocating(locator_call_back); ++ if (!locator_) ++ return; ++ locator_->StopLocating(locator_callback_); + } + + const mojom::Geoposition& LocationProviderOhos::GetPosition() { +@@ -67,7 +67,10 @@ void LocationProviderOhos::OnPermissionGranted() { + } + + void LocationProviderCallback::OnNewLocationAvailable( +- const std::unique_ptr& location) { ++ const std::unique_ptr& location) { ++ if (!location) ++ return; ++ + mojom::Geoposition position; + position.latitude = location->GetLatitude(); + position.longitude = location->GetLongitude(); +@@ -95,27 +98,25 @@ void LocationProviderOhos::RequestLocationUpdate(bool high_accuracy) { + LOG(INFO) << "LocationProviderOhos::RequestLocationUpdate"; + is_running_ = true; + CreateLocationManagerIfNeeded(); +- if (locator_ == nullptr) { ++ if (!locator_) { + LOG(ERROR) << "Locator is null. Can not get location"; + locator_callback_->OnErrorReport( + LocationProviderCallback::LOCATION_GET_FAILED); + return; + } + +- std::unique_ptr requestConfig = +- std::make_unique(); +- SetRequestConfig(requestConfig, high_accuracy); +- if (locator_->GetSwitchState() != 1) { ++ std::unique_ptr request_config = ++ OHOS::NWeb::LocationInstance::GetInstance().CreateLocationRequestConfig(); ++ SetRequestConfig(request_config, high_accuracy); ++ if (!locator_->IsLocationEnabled()) { + LOG(ERROR) << "geolocation setting is not turned on"; + locator_callback_->OnErrorReport( + LocationProviderCallback::LOCATION_GET_FAILED); + return; + } +- OHOS::sptr locator_call_back = +- locator_callback_; +- int ret = locator_->StartLocating(requestConfig, locator_call_back, "location.ILocator", +- 0, 0); +- if (ret != 0) { ++ ++ bool ret = locator_->StartLocating(request_config, locator_callback_); ++ if (!ret) { + LOG(ERROR) << "StartLocating failed. Can not get location"; + locator_callback_->OnErrorReport( + LocationProviderCallback::LOCATION_GET_FAILED); +@@ -126,21 +127,24 @@ void LocationProviderOhos::CreateLocationManagerIfNeeded() { + if (locator_ != nullptr) { + return; + } +- locator_ = std::make_unique( +- OHOS::Location::CommonUtils::GetRemoteObject( +- OHOS::LOCATION_LOCATOR_SA_ID, +- OHOS::Location::CommonUtils::InitDeviceId())); ++ locator_ = ++ OHOS::NWeb::LocationInstance::GetInstance().CreateLocationProxyAdapter(); + } + + void LocationProviderOhos::SetRequestConfig( +- std::unique_ptr& requestConfig, ++ std::unique_ptr& request_config, + bool high_accuracy) { +- requestConfig->SetPriority(OHOS::Location::PRIORITY_FAST_FIRST_FIX); +- requestConfig->SetScenario(OHOS::Location::SCENE_UNSET); +- requestConfig->SetTimeInterval(1); +- requestConfig->SetDistanceInterval(0); +- requestConfig->SetMaxAccuracy(50); +- requestConfig->SetFixNumber(0); ++ if (!request_config) ++ return; ++ ++ request_config->SetPriority( ++ OHOS::NWeb::LocationRequestConfig::Priority::PRIORITY_FAST_FIRST_FIX); ++ request_config->SetScenario( ++ OHOS::NWeb::LocationRequestConfig::Scenario::UNSET); ++ request_config->SetTimeInterval(1); ++ request_config->SetDistanceInterval(0); ++ request_config->SetMaxAccuracy(50); ++ request_config->SetFixNumber(0); + } + + void LocationProviderCallback::NewGeopositionReport( +@@ -150,37 +154,8 @@ void LocationProviderCallback::NewGeopositionReport( + callback_.Run(position); + } + +-int LocationProviderCallback::OnRemoteRequest(uint32_t code, +- OHOS::MessageParcel& data, +- OHOS::MessageParcel& reply, +- OHOS::MessageOption& option) { +- if (data.ReadInterfaceToken() != GetDescriptor()) { +- LOG(INFO) << "invalid token."; +- return -1; +- } +- switch (code) { +- case RECEIVE_LOCATION_INFO_EVENT: { +- std::unique_ptr location = +- OHOS::Location::Location::Unmarshalling(data); +- OnLocationReport(location); +- break; +- } +- case RECEIVE_ERROR_INFO_EVENT: { +- break; +- } +- case RECEIVE_LOCATION_STATUS_EVENT: { +- OnLocatingStatusChange(0); +- break; +- } +- default: { +- break; +- } +- } +- return 0; +-} +- + void LocationProviderCallback::OnLocationReport( +- const std::unique_ptr& location) { ++ const std::unique_ptr& location) { + OnNewLocationAvailable(location); + } + +diff --git a/src/services/device/geolocation/ohos/location_provider_ohos.h b/src/services/device/geolocation/ohos/location_provider_ohos.h +index 9e4adc912fa..2c5055c1420 +--- a/src/services/device/geolocation/ohos/location_provider_ohos.h ++++ b/src/services/device/geolocation/ohos/location_provider_ohos.h +@@ -7,21 +7,14 @@ + + #include + +-#include +-#include +-#include +-#include +-#include +-#include +- ++#include + #include "base/task/single_thread_task_runner.h" + #include "base/threading/thread_checker.h" + #include "services/device/public/cpp/geolocation/location_provider.h" + #include "services/device/public/mojom/geoposition.mojom.h" + + namespace device { +-class LocationProviderCallback +- : public OHOS::IRemoteStub { ++class LocationProviderCallback : public OHOS::NWeb::LocationCallbackAdapter { + public: + LocationProviderCallback() {} + ~LocationProviderCallback() = default; +@@ -36,17 +29,13 @@ class LocationProviderCallback + UpdateCallback; + + // ILocatorCallback implementation. +- virtual int OnRemoteRequest(uint32_t code, +- OHOS::MessageParcel& data, +- OHOS::MessageParcel& reply, +- OHOS::MessageOption& option) override; + void OnLocationReport( +- const std::unique_ptr& location) override; ++ const std::unique_ptr& location) override; + void OnLocatingStatusChange(const int status) override; + void OnErrorReport(const int errorCode) override; + + void OnNewLocationAvailable( +- const std::unique_ptr& location); ++ const std::unique_ptr& location); + void OnNewErrorAvailable(std::string message); + void SetUpdateCallback(const UpdateCallback& callback) { + callback_ = callback; +@@ -81,15 +70,15 @@ class LocationProviderOhos : public LocationProvider { + void RequestLocationUpdate(bool high_accuracy); + void CreateLocationManagerIfNeeded(); + void SetRequestConfig( +- std::unique_ptr& requestConfig, ++ std::unique_ptr& requestConfig, + bool high_accuracy); + +- std::unique_ptr locator_; ++ std::unique_ptr locator_; + + LocationProviderUpdateCallback callback_; + + bool is_running_ = false; +- OHOS::sptr locator_callback_ = nullptr; ++ std::shared_ptr locator_callback_ = nullptr; + }; + + } // namespace device +diff --git a/src/services/device/hid/hid_connection_impl.cc b/src/services/device/hid/hid_connection_impl.cc +index 131eee19f57..508114a7626 +--- a/src/services/device/hid/hid_connection_impl.cc ++++ b/src/services/device/hid/hid_connection_impl.cc +@@ -54,11 +54,12 @@ void HidConnectionImpl::OnInputReport( + scoped_refptr buffer, + size_t size) { + DCHECK(client_); +- uint8_t report_id = buffer->data()[0]; +- uint8_t* begin = &buffer->data()[1]; +- uint8_t* end = buffer->data().data() + size; +- std::vector data(begin, end); +- client_->OnInputReport(report_id, data); ++ DCHECK_GE(size, 1u); ++ std::vector data; ++ if (size > 1) { ++ data = std::vector(buffer->front() + 1, buffer->front() + size); ++ } ++ client_->OnInputReport(/*report_id=*/buffer->data()[0], data); + } + + void HidConnectionImpl::Read(ReadCallback callback) { +diff --git a/src/services/device/wake_lock/power_save_blocker/BUILD.gn b/src/services/device/wake_lock/power_save_blocker/BUILD.gn +index 3607914e52c..01d25e9fc01 +--- a/src/services/device/wake_lock/power_save_blocker/BUILD.gn ++++ b/src/services/device/wake_lock/power_save_blocker/BUILD.gn +@@ -74,7 +74,10 @@ source_set("power_save_blocker") { + } else if (is_win) { + sources += [ "power_save_blocker_win.cc" ] + } else if (is_ohos) { +- sources += [ "power_save_blocker_ohos.cc" ] ++ sources += [ ++ "power_save_blocker_ohos.cc", ++ "nweb_screen_lock_tracker.cc" ++ ] + import("//build/config/ohos/config.gni") + libs = [ "nweb_ohos_adapter.z" ] + include_dirs = ohos_src_includes +diff --git a/src/services/device/wake_lock/power_save_blocker/nweb_screen_lock_tracker.cc b/src/services/device/wake_lock/power_save_blocker/nweb_screen_lock_tracker.cc +new file mode 100755 +index 00000000000..3bf93a9934d +--- /dev/null ++++ b/src/services/device/wake_lock/power_save_blocker/nweb_screen_lock_tracker.cc +@@ -0,0 +1,88 @@ ++// Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "base/logging.h" ++#include "nweb_screen_lock_tracker.h" ++ ++NWebScreenLockTracker& NWebScreenLockTracker::Instance() { ++ static NWebScreenLockTracker tracker; ++ return tracker; ++} ++ ++void NWebScreenLockTracker::AddScreenLock(int32_t windowId, int32_t nwebId, const SetKeepScreenOn& handle) { ++ if (windowId < 0 || handle == nullptr) { ++ LOG(ERROR) << "invalid windowId or handle"; ++ return; ++ } ++ std::lock_guard lock(screen_lock_map_lock_); ++ std::unordered_map>::iterator iter; ++ iter = screen_lock_map_.find(windowId); ++ if (iter != screen_lock_map_.end()) { ++ LOG(DEBUG) << "nweb screen lock register nweb id = " << nwebId; ++ iter->second.emplace(nwebId, std::move(handle)); ++ return; ++ } ++ LOG(DEBUG) << "nweb screen lock register window id = " << windowId << "nweb id = " << nwebId; ++ std::unordered_map handle_iter; ++ handle_iter.emplace(nwebId, std::move(handle)); ++ screen_lock_map_.emplace(windowId, handle_iter); ++} ++ ++void NWebScreenLockTracker::RemoveScreenLock(int32_t windowId, int32_t nwebId) { ++ if (windowId < 0) { ++ LOG(ERROR) << "invalid windowId"; ++ return; ++ } ++ std::lock_guard lock(screen_lock_map_lock_); ++ std::unordered_map>::iterator iter; ++ iter = screen_lock_map_.find(windowId); ++ if (iter == screen_lock_map_.end()) { ++ LOG(ERROR) << "nweb screen lock unregister not found"; ++ return; ++ } ++ LOG(DEBUG) << "nweb screen lock unregister nweb id = " << nwebId; ++ iter->second.erase(nwebId); ++ if (iter->second.empty()) { ++ LOG(DEBUG) << "nweb screen lock unregister window id = " << windowId; ++ screen_lock_map_.erase(windowId); ++ } ++} ++ ++void NWebScreenLockTracker::Lock() { ++ std::lock_guard lock(screen_lock_map_lock_); ++ count_++; ++ if (count_ == 0) { ++ LOG(ERROR) << "nweb screen lock wrong, count_ = " << count_; ++ return; ++ } ++ if (is_screen_on_ != false) { ++ LOG(DEBUG) << "nweb screen lock ignore, count_ = " << count_; ++ return; ++ } ++ is_screen_on_ = true; ++ for (auto window_iter = screen_lock_map_.begin(); window_iter != screen_lock_map_.end(); ++window_iter) { ++ auto nweb_iter = window_iter->second.begin(); ++ LOG(DEBUG) << "nweb screen lock window id = " << window_iter->first << " nweb id = " << nweb_iter->first; ++ nweb_iter->second(true); ++ } ++} ++ ++void NWebScreenLockTracker::UnLock() { ++ std::lock_guard lock(screen_lock_map_lock_); ++ count_--; ++ if (count_ < 0) { ++ LOG(ERROR) << "nweb screen unlock wrong, count_ = " << count_; ++ return; ++ } ++ if (is_screen_on_ != true || count_ > 0) { ++ LOG(DEBUG) << "nweb screen unlock ignore, count_ = " << count_; ++ return; ++ } ++ is_screen_on_ = false; ++ for (auto window_iter = screen_lock_map_.begin(); window_iter != screen_lock_map_.end(); ++window_iter) { ++ auto nweb_iter = window_iter->second.begin(); ++ LOG(DEBUG) << "nweb screen unlock window id = " << window_iter->first << " nweb id = " << nweb_iter->first; ++ nweb_iter->second(false); ++ } ++} +\ No newline at end of file +diff --git a/src/services/device/wake_lock/power_save_blocker/nweb_screen_lock_tracker.h b/src/services/device/wake_lock/power_save_blocker/nweb_screen_lock_tracker.h +new file mode 100755 +index 00000000000..585b98b6168 +--- /dev/null ++++ b/src/services/device/wake_lock/power_save_blocker/nweb_screen_lock_tracker.h +@@ -0,0 +1,30 @@ ++// Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef NWEB_SCREEN_LOCK_TRACKER_H ++#define NWEB_SCREEN_LOCK_TRACKER_H ++ ++#define NWEB_EXPORT __attribute__((visibility("default"))) ++ ++#include ++#include ++ ++using SetKeepScreenOn = std::function; ++ ++class NWEB_EXPORT NWebScreenLockTracker { ++ public: ++ static NWebScreenLockTracker& Instance(); ++ void AddScreenLock(int32_t windowId, int32_t nwebId, const SetKeepScreenOn& handle); ++ void RemoveScreenLock(int32_t windowId, int32_t nwebId); ++ void Lock(); ++ void UnLock(); ++ ++ private: ++ std::mutex screen_lock_map_lock_; ++ std::unordered_map> screen_lock_map_; ++ uint32_t count_ = 0; ++ bool is_screen_on_ = false; ++}; ++ ++#endif // NWEB_SCREEN_LOCK_TRACKER_H +\ No newline at end of file +diff --git a/src/services/device/wake_lock/power_save_blocker/power_save_blocker_ohos.cc b/src/services/device/wake_lock/power_save_blocker/power_save_blocker_ohos.cc +index 560ade30734..3b1fcb15000 +--- a/src/services/device/wake_lock/power_save_blocker/power_save_blocker_ohos.cc ++++ b/src/services/device/wake_lock/power_save_blocker/power_save_blocker_ohos.cc +@@ -6,9 +6,8 @@ + + #include "base/memory/ref_counted.h" + #include "base/logging.h" +-#include "ohos_adapter_helper.h" ++#include "nweb_screen_lock_tracker.h" + +-using namespace OHOS::NWeb; + namespace device { + + class PowerSaveBlocker::Delegate +@@ -25,30 +24,16 @@ class PowerSaveBlocker::Delegate + private: + friend class base::RefCountedThreadSafe; + virtual ~Delegate() {} +- +- std::unique_ptr power_mgr_client_ = nullptr; +- std::shared_ptr lock_ = nullptr; + }; + +-PowerSaveBlocker::Delegate::Delegate() { +- power_mgr_client_ = +- OHOS::NWeb::OhosAdapterHelper::GetInstance().CreatePowerMgrClientAdapter(); +- if (power_mgr_client_ != nullptr) { +- lock_ = power_mgr_client_->CreateRunningLock( +- "nweb_lock", RunningLockAdapterType::SCREEN); +- } +-} ++PowerSaveBlocker::Delegate::Delegate() {} + + void PowerSaveBlocker::Delegate::ApplyBlock() { +- if (lock_ != nullptr) { +- lock_->Lock(0); +- } ++ NWebScreenLockTracker::Instance().Lock(); + } + + void PowerSaveBlocker::Delegate::RemoveBlock() { +- if (lock_ != nullptr) { +- lock_->UnLock(); +- } ++ NWebScreenLockTracker::Instance().UnLock(); + } + + PowerSaveBlocker::PowerSaveBlocker( +diff --git a/src/services/network/network_service.cc b/src/services/network/network_service.cc +index 3180e1147af..7623355b324 +--- a/src/services/network/network_service.cc ++++ b/src/services/network/network_service.cc +@@ -93,6 +93,9 @@ + #include "services/network/sct_auditing/sct_auditing_cache.h" + #endif + ++#if BUILDFLAG(IS_OHOS) ++#include "net/socket/client_socket_pool.h" ++#endif + namespace network { + + namespace { +@@ -397,6 +400,15 @@ std::unique_ptr NetworkService::CreateForTesting() { + + void NetworkService::RegisterNetworkContext(NetworkContext* network_context) { + DCHECK_EQ(0u, network_contexts_.count(network_context)); ++#if BUILDFLAG(IS_OHOS) ++ net::URLRequestContext* url_request_context = ++ network_context->url_request_context(); ++ if (url_request_context) { ++ LOG(INFO) << "Register network context and set network timeout " ++ << timeout_override_ << " second(s)"; ++ url_request_context->SetConnectTimeout(timeout_override_); ++ } ++#endif + network_contexts_.insert(network_context); + if (quic_disabled_) + network_context->DisableQuic(); +@@ -493,6 +505,18 @@ void NetworkService::ConfigureStubHostResolver( + host_resolver_manager_->SetInsecureDnsClientEnabled( + insecure_dns_client_enabled, additional_dns_types_enabled); + ++#if BUILDFLAG(IS_OHOS) ++ // Since the system dnsconfig is not obtained and null in OHOS, so override ++ // the full config with default. ++ net::DnsConfigOverrides overrides = ++ net::DnsConfigOverrides::CreateOverridingEverythingWithDefaults(); ++ overrides.secure_dns_mode = secure_dns_mode; ++ overrides.dns_over_https_servers = dns_over_https_servers; ++ ++ // Keep the dns_over_https_upgrade disabled in OHOS since we don't have ++ // available update providers. ++ overrides.allow_dns_over_https_upgrade = false; ++#else + // Configure DNS over HTTPS. + net::DnsConfigOverrides overrides; + overrides.dns_over_https_servers = dns_over_https_servers; +@@ -502,6 +526,7 @@ void NetworkService::ConfigureStubHostResolver( + overrides.disabled_upgrade_providers = + SplitString(features::kDnsOverHttpsUpgradeDisabledProvidersParam.Get(), + ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); ++#endif + + host_resolver_manager_->SetDnsConfigOverrides(overrides); + } +@@ -830,4 +855,17 @@ NetworkService* NetworkService::GetNetworkServiceForTesting() { + return g_network_service; + } + ++#if BUILDFLAG(IS_OHOS) ++void NetworkService::SetConnectTimeout(int seconds) { ++ LOG(INFO) << "Network service set network timeout " << seconds << " second(s)"; ++ timeout_override_ = seconds; ++ for (auto* network_context : network_contexts_) { ++ net::URLRequestContext* url_request_context = ++ network_context->url_request_context(); ++ if (url_request_context) { ++ url_request_context->SetConnectTimeout(seconds); ++ } ++ } ++} ++#endif + } // namespace network +diff --git a/src/services/network/network_service.h b/src/services/network/network_service.h +index 01609d0e485..2dad2e62668 +--- a/src/services/network/network_service.h ++++ b/src/services/network/network_service.h +@@ -273,6 +273,10 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkService + + static NetworkService* GetNetworkServiceForTesting(); + ++#if BUILDFLAG(IS_OHOS) ++ void SetConnectTimeout(int seconds) override; ++#endif ++ + private: + class DelayedDohProbeActivator; + +@@ -390,6 +394,10 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkService + // This is used only in tests. It avoids leaky SystemDnsConfigChangeNotifiers + // leaking stale listeners between tests. + std::unique_ptr mock_network_change_notifier_; ++ ++#if BUILDFLAG(IS_OHOS) ++ int timeout_override_ = 0; ++#endif + }; + + } // namespace network +diff --git a/src/services/network/public/mojom/network_service.mojom b/src/services/network/public/mojom/network_service.mojom +index 33800473528..f99a67aa0bc +--- a/src/services/network/public/mojom/network_service.mojom ++++ b/src/services/network/public/mojom/network_service.mojom +@@ -374,4 +374,10 @@ interface NetworkService { + // Extensions, etc. + ParseHeaders(url.mojom.Url url, HttpResponseHeaders headers) + => (ParsedHeaders parsed_headers); ++ ++ // #if BUILDFLAG(IS_OHOS) ++ [EnableIf=is_ohos] ++ SetConnectTimeout(int32 seconds); ++ // #endif ++ + }; +diff --git a/src/services/network/web_transport.cc b/src/services/network/web_transport.cc +index 4a632d169c2..20544e1855d +--- a/src/services/network/web_transport.cc ++++ b/src/services/network/web_transport.cc +@@ -178,7 +178,7 @@ class WebTransport::Stream final { + + ~Stream() { + auto* stream = incoming_ ? incoming_.get() : outgoing_.get(); +- if (!stream) { ++ if (!stream || transport_->closing_ || transport_->torn_down_) { + return; + } + stream->MaybeResetDueToStreamObjectGone(); +@@ -400,7 +400,10 @@ WebTransport::WebTransport( + transport_->Connect(); + } + +-WebTransport::~WebTransport() = default; ++WebTransport::~WebTransport() { ++ // Ensure that we ignore all callbacks while mid-destruction. ++ torn_down_ = true; ++} + + void WebTransport::SendDatagram(base::span data, + base::OnceCallback callback) { +diff --git a/src/services/network/web_transport_unittest.cc b/src/services/network/web_transport_unittest.cc +index 7d07726ee6f..f4d610ff5ea +--- a/src/services/network/web_transport_unittest.cc ++++ b/src/services/network/web_transport_unittest.cc +@@ -581,6 +581,51 @@ TEST_F(WebTransportTest, EchoOnUnidirectionalStreams) { + EXPECT_EQ(0u, resets_sent.size()); + } + ++TEST_F(WebTransportTest, DeleteClientWithStreamsOpen) { ++ base::RunLoop run_loop_for_handshake; ++ mojo::PendingRemote handshake_client; ++ TestHandshakeClient test_handshake_client( ++ handshake_client.InitWithNewPipeAndPassReceiver(), ++ run_loop_for_handshake.QuitClosure()); ++ ++ CreateWebTransport(GetURL("/echo"), ++ url::Origin::Create(GURL("https://example.org/")), ++ std::move(handshake_client)); ++ ++ run_loop_for_handshake.Run(); ++ ++ ASSERT_TRUE(test_handshake_client.has_seen_connection_establishment()); ++ ++ TestClient client(test_handshake_client.PassClientReceiver()); ++ mojo::Remote transport_remote( ++ test_handshake_client.PassTransport()); ++ ++ constexpr int kNumStreams = 10; ++ auto writable_for_outgoing = ++ std::make_unique(kNumStreams); ++ for (int i = 0; i < kNumStreams; i++) { ++ const MojoCreateDataPipeOptions options = { ++ sizeof(options), MOJO_CREATE_DATA_PIPE_FLAG_NONE, 1, 4 * 1024}; ++ mojo::ScopedDataPipeConsumerHandle readable_for_outgoing; ++ ASSERT_EQ(MOJO_RESULT_OK, ++ mojo::CreateDataPipe(&options, writable_for_outgoing[i], ++ readable_for_outgoing)); ++ base::RunLoop run_loop_for_stream_creation; ++ bool stream_created; ++ transport_remote->CreateStream( ++ std::move(readable_for_outgoing), ++ /*writable=*/{}, ++ base::BindLambdaForTesting([&](bool b, uint32_t /*id*/) { ++ stream_created = b; ++ run_loop_for_stream_creation.Quit(); ++ })); ++ run_loop_for_stream_creation.Run(); ++ ASSERT_TRUE(stream_created); ++ } ++ ++ // Keep the streams open so that they are closed via destructor. ++} ++ + // crbug.com/1129847: disabled because it is flaky. + TEST_F(WebTransportTest, DISABLED_EchoOnBidirectionalStream) { + base::RunLoop run_loop_for_handshake; +diff --git a/src/services/viz/privileged/mojom/compositing/display_private.mojom b/src/services/viz/privileged/mojom/compositing/display_private.mojom +index c301c518dd8..90b671215c1 +--- a/src/services/viz/privileged/mojom/compositing/display_private.mojom ++++ b/src/services/viz/privileged/mojom/compositing/display_private.mojom +@@ -25,6 +25,9 @@ interface DisplayPrivate { + [EnableIf=is_win, Sync] + DisableSwapUntilResize() => (); + ++ [EnableIf=is_ohos, Sync] ++ SetShouldFrameSubmissionBeforeDraw(bool should) => (); ++ + // Resizes the display. + Resize(gfx.mojom.Size size); + +@@ -108,6 +111,10 @@ interface DisplayClient { + [EnableIf=is_linux] + DidCompleteSwapWithNewSize(gfx.mojom.Size size); + ++ // Notifies that a swap has occurred with a new size in OHOS. ++ [EnableIf=is_ohos] ++ DidCompleteSwapWithNewSizeOHOS(gfx.mojom.Size size); ++ + // Notifies the client of the result of context creation attempt. On Android we can't + // fall back to SW in failure cases, so we need to handle this specifically. + [EnableIf=is_android] +diff --git a/src/services/viz/public/cpp/compositing/compositor_frame_metadata_mojom_traits.cc b/src/services/viz/public/cpp/compositing/compositor_frame_metadata_mojom_traits.cc +index 5c06a61985a..5877b99ce7b +--- a/src/services/viz/public/cpp/compositing/compositor_frame_metadata_mojom_traits.cc ++++ b/src/services/viz/public/cpp/compositing/compositor_frame_metadata_mojom_traits.cc +@@ -41,6 +41,11 @@ bool StructTraitscontent_color_usage)) + return false; ++ ++#if BUILDFLAG(IS_OHOS) ++ out->is_scrolling = data.is_scrolling(); ++#endif ++ + out->may_contain_video = data.may_contain_video(); + out->may_throttle_if_undrawn_frames = data.may_throttle_if_undrawn_frames(); + out->has_shared_element_resources = data.has_shared_element_resources(); +diff --git a/src/services/viz/public/cpp/compositing/compositor_frame_metadata_mojom_traits.h b/src/services/viz/public/cpp/compositing/compositor_frame_metadata_mojom_traits.h +index be2f79d1ed7..2ea8b24c384 +--- a/src/services/viz/public/cpp/compositing/compositor_frame_metadata_mojom_traits.h ++++ b/src/services/viz/public/cpp/compositing/compositor_frame_metadata_mojom_traits.h +@@ -52,6 +52,12 @@ struct StructTraits::max(); + + return kMaxFenceWaitTimeNs; + } +diff --git a/src/third_party/angle/src/tests/egl_tests/EGLRobustnessTest.cpp b/src/third_party/angle/src/tests/egl_tests/EGLRobustnessTest.cpp +index 4f314dc3513..4ada5bc3f99 +--- a/src/third_party/angle/src/tests/egl_tests/EGLRobustnessTest.cpp ++++ b/src/third_party/angle/src/tests/egl_tests/EGLRobustnessTest.cpp +@@ -12,6 +12,7 @@ + #include + + #include "test_utils/ANGLETest.h" ++#include "test_utils/gl_raii.h" + #include "util/OSWindow.h" + + using namespace angle; +@@ -50,14 +51,6 @@ class EGLRobustnessTest : public ANGLETest + + ASSERT_TRUE(eglInitialize(mDisplay, nullptr, nullptr) == EGL_TRUE); + +- const char *extensions = eglQueryString(mDisplay, EGL_EXTENSIONS); +- if (strstr(extensions, "EGL_EXT_create_context_robustness") == nullptr) +- { +- std::cout << "Test skipped due to missing EGL_EXT_create_context_robustness" +- << std::endl; +- return; +- } +- + int nConfigs = 0; + ASSERT_TRUE(eglGetConfigs(mDisplay, nullptr, 0, &nConfigs) == EGL_TRUE); + ASSERT_LE(1, nConfigs); +@@ -91,9 +84,9 @@ class EGLRobustnessTest : public ANGLETest + + void testTearDown() override + { +- eglDestroySurface(mDisplay, mWindow); +- eglDestroyContext(mDisplay, mContext); + eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); ++ eglDestroySurface(mDisplay, mWindow); ++ destroyContext(); + eglTerminate(mDisplay); + EXPECT_EGL_SUCCESS(); + +@@ -102,10 +95,22 @@ class EGLRobustnessTest : public ANGLETest + + void createContext(EGLint resetStrategy) + { +- const EGLint contextAttribs[] = {EGL_CONTEXT_CLIENT_VERSION, 2, +- EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, +- resetStrategy, EGL_NONE}; +- mContext = eglCreateContext(mDisplay, mConfig, EGL_NO_CONTEXT, contextAttribs); ++ std::vector contextAttribs = { ++ EGL_CONTEXT_CLIENT_VERSION, ++ 2, ++ }; ++ ++ if (IsEGLDisplayExtensionEnabled(mDisplay, "EGL_EXT_create_context_robustness")) ++ { ++ contextAttribs.push_back(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT); ++ contextAttribs.push_back(resetStrategy); ++ } ++ else ++ { ++ ASSERT_EQ(EGL_NO_RESET_NOTIFICATION_EXT, resetStrategy); ++ } ++ contextAttribs.push_back(EGL_NONE); ++ mContext = eglCreateContext(mDisplay, mConfig, EGL_NO_CONTEXT, contextAttribs.data()); + ASSERT_NE(EGL_NO_CONTEXT, mContext); + + eglMakeCurrent(mDisplay, mWindow, mWindow, mContext); +@@ -115,14 +120,26 @@ class EGLRobustnessTest : public ANGLETest + ASSERT_NE(nullptr, strstr(extensionString, "GL_ANGLE_instanced_arrays")); + } + +- void forceContextReset() ++ void destroyContext() ++ { ++ if (mContext != EGL_NO_CONTEXT) ++ { ++ eglDestroyContext(mDisplay, mContext); ++ mContext = EGL_NO_CONTEXT; ++ } ++ } ++ ++ void submitLongRunningTask() + { + // Cause a GPU reset by drawing 100,000,000 fullscreen quads + GLuint program = CompileProgram( + "attribute vec4 pos;\n" +- "void main() {gl_Position = pos;}\n", ++ "varying vec2 texcoord;\n" ++ "void main() {gl_Position = pos; texcoord = (pos.xy * 0.5) + 0.5;}\n", + "precision mediump float;\n" +- "void main() {gl_FragColor = vec4(1.0);}\n"); ++ "uniform sampler2D tex;\n" ++ "varying vec2 texcoord;\n" ++ "void main() {gl_FragColor = gl_FragColor = texture2D(tex, texcoord);}\n"); + ASSERT_NE(0u, program); + glUseProgram(program); + +@@ -148,13 +165,21 @@ class EGLRobustnessTest : public ANGLETest + glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, vertices); + glEnableVertexAttribArray(0); + ++ GLTexture texture; ++ glActiveTexture(GL_TEXTURE0); ++ glBindTexture(GL_TEXTURE_2D, texture); ++ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); ++ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); ++ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); ++ ++ GLint textureUniformLocation = glGetUniformLocation(program, "tex"); ++ glUniform1i(textureUniformLocation, 0); ++ + glViewport(0, 0, mOSWindow->getWidth(), mOSWindow->getHeight()); + glClearColor(1.0, 0.0, 0.0, 1.0); + glClear(GL_COLOR_BUFFER_BIT); + glDrawElementsInstancedANGLE(GL_TRIANGLES, kNumQuads * 6, GL_UNSIGNED_SHORT, indices.data(), + 10000); +- +- glFinish(); + } + + protected: +@@ -178,6 +203,8 @@ TEST_P(EGLRobustnessTest, NoErrorByDefault) + // Checks that the application gets no loss with NO_RESET_NOTIFICATION + TEST_P(EGLRobustnessTest, DISABLED_NoResetNotification) + { ++ ANGLE_SKIP_TEST_IF( ++ !IsEGLDisplayExtensionEnabled(mDisplay, "EGL_EXT_create_context_robustness")); + ANGLE_SKIP_TEST_IF(!mInitialized); + createContext(EGL_NO_RESET_NOTIFICATION_EXT); + +@@ -189,7 +216,8 @@ TEST_P(EGLRobustnessTest, DISABLED_NoResetNotification) + } + std::cout << "Causing a GPU reset, brace for impact." << std::endl; + +- forceContextReset(); ++ submitLongRunningTask(); ++ glFinish(); + ASSERT_TRUE(glGetGraphicsResetStatusEXT() == GL_NO_ERROR); + } + +@@ -200,6 +228,9 @@ TEST_P(EGLRobustnessTest, DISABLED_NoResetNotification) + // the computer is rebooted. + TEST_P(EGLRobustnessTest, DISABLED_ResettingDisplayWorks) + { ++ ANGLE_SKIP_TEST_IF( ++ !IsEGLDisplayExtensionEnabled(mDisplay, "EGL_EXT_create_context_robustness")); ++ + // Note that on Windows the OpenGL driver fails hard (popup that closes the application) + // on a TDR caused by D3D. Don't run D3D tests at the same time as the OpenGL tests. + ANGLE_SKIP_TEST_IF(IsWindows() && isGLRenderer()); +@@ -215,13 +246,24 @@ TEST_P(EGLRobustnessTest, DISABLED_ResettingDisplayWorks) + } + std::cout << "Causing a GPU reset, brace for impact." << std::endl; + +- forceContextReset(); ++ submitLongRunningTask(); ++ glFinish(); + ASSERT_TRUE(glGetGraphicsResetStatusEXT() != GL_NO_ERROR); + + recreateTestFixture(); + ASSERT_TRUE(glGetGraphicsResetStatusEXT() == GL_NO_ERROR); + } + ++// Test context destruction after recovering from a long running task. ++TEST_P(EGLRobustnessTest, DISABLED_LongRunningTaskVulkanShutdown) ++{ ++ ANGLE_SKIP_TEST_IF(!mInitialized); ++ ++ createContext(EGL_NO_RESET_NOTIFICATION_EXT); ++ submitLongRunningTask(); ++ destroyContext(); ++} ++ + GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EGLRobustnessTest); + ANGLE_INSTANTIATE_TEST(EGLRobustnessTest, + WithNoFixture(ES2_VULKAN()), +diff --git a/src/third_party/ashmem/BUILD.gn b/src/third_party/ashmem/BUILD.gn +index e5bd683bde7..fa347feb6ae +--- a/src/third_party/ashmem/BUILD.gn ++++ b/src/third_party/ashmem/BUILD.gn +@@ -2,13 +2,32 @@ + # Use of this source code is governed by a BSD-style license that can be + # found in the LICENSE file. + +-assert(is_android) ++assert(is_android || is_ohos) + +-source_set("ashmem") { +- sources = [ +- "ashmem-dev.c", +- "ashmem.h", +- ] ++if (is_android) { ++ source_set("ashmem") { ++ sources = [ ++ "ashmem-dev.c", ++ "ashmem.h", ++ ] + +- configs -= [ "//build/config/android:default_orderfile_instrumentation" ] ++ configs -= [ "//build/config/android:default_orderfile_instrumentation" ] ++ } ++} else if(is_ohos) { ++ import("//build/config/ohos/config.gni") ++ config("ohos_system_libs") { ++ libs = [ "nweb_ohos_adapter.z" ] ++ ++ include_dirs = ohos_src_includes ++ lib_dirs = ohos_libs_dir ++ } ++ ++ source_set("ashmem") { ++ sources = [ ++ "ohos_ashmem.cc", ++ "ashmem.h", ++ ] ++ ++ configs += [ ":ohos_system_libs" ] ++ } + } +diff --git a/src/third_party/ashmem/ohos_ashmem.cc b/src/third_party/ashmem/ohos_ashmem.cc +new file mode 100644 +index 00000000000..756ed614856 +--- /dev/null ++++ b/src/third_party/ashmem/ohos_ashmem.cc +@@ -0,0 +1,102 @@ ++/* ++ * Copyright (c) 2023 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 ++ * ++ * 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, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++#include "ashmem.h" ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "graphic_adapter.h" ++ ++#define ASHMEM_DEVICE "/dev/ashmem" ++ ++static pthread_once_t s_ashmem_dev_once = PTHREAD_ONCE_INIT; ++static dev_t s_ashmem_dev; ++ ++static void get_ashmem_dev() { ++ struct stat st; ++ if (stat(ASHMEM_DEVICE, &st) == 0 && S_ISCHR(st.st_mode)) { ++ s_ashmem_dev = st.st_dev; ++ LOG(INFO) << "get_ashmem_dev execute success"; ++ return; ++ } ++ ++ LOG_IF(FATAL, 1) << "get_ashmem_dev execute failed"; ++} ++ ++static int ashmem_dev_fd_check(int fd) { ++ pthread_once(&s_ashmem_dev_once, get_ashmem_dev); ++ ++ struct stat st; ++ if (fstat(fd, &st) == 0 && ++ S_ISCHR(st.st_mode) && ++ st.st_dev != 0 && ++ st.st_dev == s_ashmem_dev) { ++ return 1; ++ } ++ ++ LOG_IF(FATAL, 1) << "ashmem_dev_fd_check failed"; ++ return 0; ++} ++ ++static int ashmem_check_failure(int fd, int result) ++{ ++ if (result == -1 && errno == ENOTTY) { ++ return ashmem_dev_fd_check(fd); ++ } ++ return result; ++} ++ ++int ashmem_device_is_supported(void) { ++ return 1; ++} ++ ++int ashmem_create_region(const char* name, size_t size) { ++ // use OHOS implementation to avoid race. ++ return OHOS::NWeb::AshmemAdapter::AshmemCreate(name, size); ++} ++ ++int ashmem_set_prot_region(int fd, int prot) { ++ return ashmem_check_failure(fd, TEMP_FAILURE_RETRY(ioctl(fd, ASHMEM_SET_PROT_MASK, prot))); ++} ++ ++int ashmem_get_prot_region(int fd) { ++ return ashmem_check_failure(fd, TEMP_FAILURE_RETRY(ioctl(fd, ASHMEM_GET_PROT_MASK))); ++} ++ ++int ashmem_pin_region(int fd, size_t offset, size_t len) { ++ LOG(INFO) << "ashmem_pin_region"; ++ struct ashmem_pin pin = { static_cast(offset), static_cast(len) }; ++ return ashmem_check_failure(fd, TEMP_FAILURE_RETRY(ioctl(fd, ASHMEM_PIN, &pin))); ++} ++ ++int ashmem_unpin_region(int fd, size_t offset, size_t len) { ++ LOG(DEBUG) << "ashmem_unpin_region"; ++ struct ashmem_pin pin = { static_cast(offset), static_cast(len) }; ++ return ashmem_check_failure(fd, TEMP_FAILURE_RETRY(ioctl(fd, ASHMEM_UNPIN, &pin))); ++} ++ ++int ashmem_get_size_region(int fd) { ++ return ashmem_check_failure(fd, TEMP_FAILURE_RETRY(ioctl(fd, ASHMEM_GET_SIZE, NULL))); ++} +\ No newline at end of file +diff --git a/src/third_party/blink/common/context_menu_data/context_menu_mojom_traits.cc b/src/third_party/blink/common/context_menu_data/context_menu_mojom_traits.cc +index e42bcfcb867..b1f7b69644d +--- a/src/third_party/blink/common/context_menu_data/context_menu_mojom_traits.cc ++++ b/src/third_party/blink/common/context_menu_data/context_menu_mojom_traits.cc +@@ -41,6 +41,9 @@ bool StructTraitsmedia_flags = data.media_flags(); + out->spellcheck_enabled = data.spellcheck_enabled(); + out->is_editable = data.is_editable(); ++#if BUILDFLAG(IS_OHOS) ++ out->is_selectable = data.is_selectable(); ++#endif + out->writing_direction_default = data.writing_direction_default(); + out->writing_direction_left_to_right = data.writing_direction_left_to_right(); + out->writing_direction_right_to_left = data.writing_direction_right_to_left(); +diff --git a/src/third_party/blink/common/context_menu_data/context_menu_params_builder.cc b/src/third_party/blink/common/context_menu_data/context_menu_params_builder.cc +index e464ba68c32..f38c36a50b4 +--- a/src/third_party/blink/common/context_menu_data/context_menu_params_builder.cc ++++ b/src/third_party/blink/common/context_menu_data/context_menu_params_builder.cc +@@ -73,6 +73,7 @@ UntrustworthyContextMenuParams ContextMenuParamsBuilder::Build( + << ", input_field_type = " << params.input_field_type + << ", source_type = " << params.source_type + << ", media_type = " << params.media_type; ++ params.is_selectable = data.is_selectable; + #endif + + for (const auto& suggestion : data.dictionary_suggestions) +diff --git a/src/third_party/blink/common/context_menu_data/untrustworthy_context_menu_params.cc b/src/third_party/blink/common/context_menu_data/untrustworthy_context_menu_params.cc +index 52765e84e6d..11044e230cd +--- a/src/third_party/blink/common/context_menu_data/untrustworthy_context_menu_params.cc ++++ b/src/third_party/blink/common/context_menu_data/untrustworthy_context_menu_params.cc +@@ -17,6 +17,9 @@ UntrustworthyContextMenuParams::UntrustworthyContextMenuParams() + media_flags(0), + spellcheck_enabled(false), + is_editable(false), ++#if BUILDFLAG(IS_OHOS) ++ is_selectable(false), ++#endif + writing_direction_default( + blink::ContextMenuData::kCheckableMenuItemDisabled), + writing_direction_left_to_right( +@@ -27,7 +30,8 @@ UntrustworthyContextMenuParams::UntrustworthyContextMenuParams() + referrer_policy(network::mojom::ReferrerPolicy::kDefault), + source_type(ui::MENU_SOURCE_NONE), + input_field_type(blink::mojom::ContextMenuDataInputFieldType::kNone), +- selection_start_offset(0) {} ++ selection_start_offset(0) { ++} + + UntrustworthyContextMenuParams::UntrustworthyContextMenuParams( + const UntrustworthyContextMenuParams& other) { +@@ -76,6 +80,9 @@ void UntrustworthyContextMenuParams::Assign( + selection_rect = other.selection_rect; + selection_start_offset = other.selection_start_offset; + opened_from_highlight = other.opened_from_highlight; ++#if BUILDFLAG(IS_OHOS) ++ is_selectable = other.is_selectable; ++#endif + } + + UntrustworthyContextMenuParams::~UntrustworthyContextMenuParams() = default; +diff --git a/src/third_party/blink/common/features.cc b/src/third_party/blink/common/features.cc +index 446554b1497..58fbb4e5112 +--- a/src/third_party/blink/common/features.cc ++++ b/src/third_party/blink/common/features.cc +@@ -585,7 +585,7 @@ const base::Feature kBlinkHeapIncrementalMarkingStress{ + // compositor & IO threads. + const base::Feature kBlinkCompositorUseDisplayThreadPriority { + "BlinkCompositorUseDisplayThreadPriority", +-#if defined(OS_ANDROID) || BUILDFLAG(IS_CHROMEOS_ASH) || defined(OS_WIN) ++#if defined(OS_ANDROID) || BUILDFLAG(IS_CHROMEOS_ASH) || defined(OS_WIN) || defined(OS_OHOS) + base::FEATURE_ENABLED_BY_DEFAULT + #else + base::FEATURE_DISABLED_BY_DEFAULT +diff --git a/src/third_party/blink/common/messaging/string_message_codec.cc b/src/third_party/blink/common/messaging/string_message_codec.cc +index fbb5a2e555d..c7f766b9e1c +--- a/src/third_party/blink/common/messaging/string_message_codec.cc ++++ b/src/third_party/blink/common/messaging/string_message_codec.cc +@@ -4,6 +4,9 @@ + + #include "third_party/blink/public/common/messaging/string_message_codec.h" + ++#if BUILDFLAG(IS_OHOS) ++#include ++#endif + #include + + #include "base/containers/buffer_iterator.h" +@@ -34,10 +37,54 @@ const uint8_t kPaddingTag = '\0'; + // serialization_tag, see v8/src/objects/value-serializer.cc + const uint8_t kOneByteStringTag = '"'; + const uint8_t kTwoByteStringTag = 'c'; ++ ++#if BUILDFLAG(IS_OHOS) + const uint8_t kArrayBuffer = 'B'; + const uint8_t kArrayBufferTransferTag = 't'; ++const uint8_t kTrue = 'T'; ++const uint8_t kFalse = 'F'; ++const uint8_t kDouble = 'N'; ++const uint8_t kInt32 = 'I'; ++const uint8_t kUint32 = 'U'; ++// Error ++const uint8_t kError = 'r'; ++ ++// Beginning of a dense JS array. length:uint32_t ++// |length| elements, followed by properties as key/value pairs ++const uint8_t kBeginDenseJSArray = 'A'; ++// End of a dense JS array. numProperties:uint32_t length:uint32_t ++const uint8_t kEndDenseJSArray = '$'; ++ ++// Sub-tags only meaningful for error serialization. ++enum class ErrorTag : uint8_t { ++ // The error is a EvalError. No accompanying data. ++ kEvalErrorPrototype = 'E', ++ // The error is a RangeError. No accompanying data. ++ kRangeErrorPrototype = 'R', ++ // The error is a ReferenceError. No accompanying data. ++ kReferenceErrorPrototype = 'F', ++ // The error is a SyntaxError. No accompanying data. ++ kSyntaxErrorPrototype = 'S', ++ // The error is a TypeError. No accompanying data. ++ kTypeErrorPrototype = 'T', ++ // The error is a URIError. No accompanying data. ++ kUriErrorPrototype = 'U', ++ // Followed by message: string. ++ kMessage = 'm', ++ // Followed by a JS object: cause. ++ kCause = 'c', ++ // Followed by stack: string. ++ kStack = 's', ++ // The end of this error information. ++ kEnd = '.', ++}; ++#endif + + const uint32_t kVersion = 10; ++#if BUILDFLAG(IS_OHOS) ++const uint32_t kErrorVersion = 20; ++const uint32_t kLatestVersion = 14; ++#endif + + static size_t BytesNeededForUint32(uint32_t value) { + size_t result = 0; +@@ -92,12 +139,59 @@ bool ReadUint32(base::BufferIterator& iter, uint32_t* value) { + return true; + } + ++#if BUILDFLAG(IS_OHOS) ++template ++T ReadVarint(const uint8_t* position, const uint8_t* end) { ++ // Reads an unsigned integer as a base-128 varint. ++ // The number is written, 7 bits at a time, from the least significant to the ++ // most significant 7 bits. Each byte, except the last, has the MSB set. ++ // If the varint is larger than T, any more significant bits are discarded. ++ // See also https://developers.google.com/protocol-buffers/docs/encoding ++ static_assert(std::is_integral::value && std::is_unsigned::value, ++ "Only unsigned integer types can be read as varints."); ++ T value = 0; ++ unsigned shift = 0; ++ bool has_another_byte; ++ do { ++ if (position > end) ++ return value; ++ uint8_t byte = *position; ++ if ((shift < sizeof(T) * 8)) { ++ value |= static_cast(byte & 0x7F) << shift; ++ shift += 7; ++ } ++ has_another_byte = byte & 0x80; ++ position++; ++ } while (has_another_byte); ++ return value; ++} ++ ++template ++void WriteVarint(T value, std::vector* buffer) { ++ // Writes an unsigned integer as a base-128 varint. ++ // The number is written, 7 bits at a time, from the least significant to the ++ // most significant 7 bits. Each byte, except the last, has the MSB set. ++ // See also https://developers.google.com/protocol-buffers/docs/encoding ++ static_assert(std::is_integral::value && std::is_unsigned::value, ++ "Only unsigned integer types can be written as varints."); ++ uint8_t stack_buffer[sizeof(T) * 8 / 7 + 1]; ++ uint8_t* next_byte = &stack_buffer[0]; ++ do { ++ *next_byte = (value & 0x7F) | 0x80; ++ next_byte++; ++ value >>= 7; ++ } while (value); ++ *(next_byte - 1) &= 0x7F; ++ buffer->insert(buffer->end(), stack_buffer, next_byte); ++} ++ + bool ContainsOnlyLatin1(const std::u16string& data) { + char16_t x = 0; + for (char16_t c : data) + x |= c; + return !(x & 0xFF00); + } ++#endif + + } // namespace + +@@ -161,73 +255,297 @@ bool DecodeStringMessage(base::span encoded_data, + DLOG(WARNING) << "Unexpected tag: " << tag; + return false; + } +-TransferableMessage EncodeWebMessagePayload(const WebMessagePayload& payload) { ++ ++#if BUILDFLAG(IS_OHOS) ++void WriteString(const std::string& str, std::vector* buffer) { ++ WriteUint8(kOneByteStringTag, buffer); ++ WriteUint32(str.length(), buffer); ++ WriteBytes(str.c_str(), str.length(), buffer); ++} ++ ++void WriteHeader(std::vector* buffer) { ++ WriteUint8(kVersionTag, buffer); // 0xFF ---255 ++ WriteUint32(kErrorVersion, buffer); // 0xFF ---20 ++ WriteUint8(kVersionTag, buffer); // 0xFF ---255 ++ WriteUint32(kLatestVersion, buffer); // 0xFF ---14 ++} ++ ++void WriteU16string(const std::u16string& str, std::vector* buffer) { ++ if (ContainsOnlyLatin1(str)) { ++ std::string data_latin1(str.cbegin(), str.cend()); ++ WriteUint8(kOneByteStringTag, buffer); ++ WriteUint32(data_latin1.size(), buffer); ++ WriteBytes(data_latin1.c_str(), data_latin1.size(), buffer); ++ } else { ++ size_t num_bytes = str.size() * sizeof(char16_t); ++ if ((buffer->size() + 1 + BytesNeededForUint32(num_bytes)) & 1) ++ WriteUint8(kPaddingTag, buffer); ++ WriteUint8(kTwoByteStringTag, buffer); ++ WriteUint32(num_bytes, buffer); ++ WriteBytes(reinterpret_cast(str.data()), num_bytes, buffer); ++ } ++} ++ ++void WriteBool(const bool& value, std::vector* buffer) { ++ if (value) { ++ WriteUint8(kTrue, buffer); ++ } else { ++ WriteUint8(kFalse, buffer); ++ } ++} ++ ++void WriteDouble(const double& value, std::vector* buffer) { ++ WriteUint8(kDouble, buffer); ++ WriteBytes(reinterpret_cast(&value), sizeof(value), buffer); ++} ++ ++void WriteInt64(const int64_t& value, std::vector* buffer) { ++ if (INT_MIN <= value && value <= INT_MAX) { ++ WriteUint8(kInt32, buffer); ++ int32_t val = (int32_t)value; ++ using UnsignedT = typename std::make_unsigned::type; ++ WriteVarint( ++ (static_cast(val) << 1) ^ (val >> (8 * sizeof(int32_t) - 1)), ++ buffer); ++ } else if (INT_MAX < value && value <= UINT_MAX) { ++ WriteUint8(kUint32, buffer); ++ WriteUint32(value, buffer); ++ } else { ++ WriteDouble(value, buffer); ++ } ++} ++ ++ErrorTag ConvertToErrType(const std::u16string& name) { ++ std::map typeMap; ++ typeMap.insert(std::pair( ++ u"EvalError", ErrorTag::kEvalErrorPrototype)); ++ typeMap.insert(std::pair( ++ u"RangeError", ErrorTag::kRangeErrorPrototype)); ++ typeMap.insert(std::pair( ++ u"ReferenceError", ErrorTag::kReferenceErrorPrototype)); ++ typeMap.insert(std::pair( ++ u"SyntaxError", ErrorTag::kSyntaxErrorPrototype)); ++ typeMap.insert(std::pair( ++ u"TypeError", ErrorTag::kTypeErrorPrototype)); ++ typeMap.insert(std::pair( ++ u"URIError", ErrorTag::kUriErrorPrototype)); ++ for (auto iter = typeMap.begin(); iter != typeMap.end(); iter++) { ++ if (iter->first.compare(name) == 0) { ++ return iter->second; ++ } ++ } ++ return ErrorTag::kSyntaxErrorPrototype; ++} ++ ++void WriteError(const std::u16string& name, ++ const std::u16string& message, ++ std::vector* buffer) { ++ // tag ++ WriteUint8(kError, buffer); ++ // F -- kReferenceErrorPrototype ++ // convert name to error type ++ WriteUint8(static_cast(ConvertToErrType(name)), buffer); ++ // m -- Followed by message: string ++ WriteUint8(static_cast(ErrorTag::kMessage), buffer); ++ WriteU16string(message, buffer); ++ // s -- Followed by stack: string ++ WriteUint8(static_cast(ErrorTag::kStack), buffer); ++ WriteU16string(name + u": " + message, buffer); ++ // . -- The end of this error information. ++ WriteUint8(static_cast(ErrorTag::kEnd), buffer); ++} ++ ++void WriteArrayBuffer(std::vector& arrbuf, ++ TransferableMessage& message, ++ std::vector* buffer) { ++ WriteUint8(kArrayBufferTransferTag, buffer); ++ // Write at the first slot. ++ WriteUint32(0, buffer); ++ ++ mojo_base::BigBuffer big_buffer(arrbuf); ++ message.array_buffer_contents_array.push_back( ++ mojom::SerializedArrayBufferContents::New(std::move(big_buffer))); ++} ++ ++void WriteStringArray(std::vector& arr, ++ std::vector* buffer) { ++ WriteUint8(kBeginDenseJSArray, buffer); ++ uint32_t length = arr.size(); ++ WriteUint32(length, buffer); ++ for (uint32_t i = 0; i < length; i++) { ++ WriteU16string(arr[i], buffer); ++ } ++ WriteUint8(kEndDenseJSArray, buffer); ++ // end of the array tag ++ WriteUint32(0, buffer); ++ WriteUint32(length, buffer); ++} ++ ++void WriteBoolArray(std::vector& arr, std::vector* buffer) { ++ WriteUint8(kBeginDenseJSArray, buffer); ++ uint32_t length = arr.size(); ++ WriteUint32(length, buffer); ++ for (uint32_t i = 0; i < length; i++) { ++ WriteBool(arr[i], buffer); ++ } ++ WriteUint8(kEndDenseJSArray, buffer); ++ WriteUint32(0, buffer); ++ WriteUint32(length, buffer); ++} ++ ++void WriteDoubleArray(std::vector& arr, std::vector* buffer) { ++ WriteUint8(kBeginDenseJSArray, buffer); ++ uint32_t length = arr.size(); ++ WriteUint32(length, buffer); ++ for (uint32_t i = 0; i < length; i++) { ++ WriteDouble(arr[i], buffer); ++ } ++ WriteUint8(kEndDenseJSArray, buffer); ++ WriteUint32(0, buffer); ++ WriteUint32(length, buffer); ++} ++ ++void WriteInt64Array(std::vector& arr, std::vector* buffer) { ++ WriteUint8(kBeginDenseJSArray, buffer); ++ uint32_t length = arr.size(); ++ WriteUint32(length, buffer); ++ for (uint32_t i = 0; i < length; i++) { ++ WriteInt64(arr[i], buffer); ++ } ++ WriteUint8(kEndDenseJSArray, buffer); ++ WriteUint32(0, buffer); ++ WriteUint32(length, buffer); ++} ++#endif ++ ++// see src/v8/src/objects/value-serializer.cc for more details about the ++// serialization. ++#if BUILDFLAG(IS_OHOS) ++TransferableMessage EncodeWebMessagePayload( ++ struct WebMessagePort::Message& original) { + TransferableMessage message; + std::vector buffer; +- WriteUint8(kVersionTag, &buffer); +- WriteUint32(kVersion, &buffer); +- +- absl::visit( +- overloaded{ +- [&](const std::u16string& str) { +- if (ContainsOnlyLatin1(str)) { +- std::string data_latin1(str.cbegin(), str.cend()); +- WriteUint8(kOneByteStringTag, &buffer); +- WriteUint32(data_latin1.size(), &buffer); +- WriteBytes(data_latin1.c_str(), data_latin1.size(), &buffer); +- } else { +- size_t num_bytes = str.size() * sizeof(char16_t); +- if ((buffer.size() + 1 + BytesNeededForUint32(num_bytes)) & 1) +- WriteUint8(kPaddingTag, &buffer); +- WriteUint8(kTwoByteStringTag, &buffer); +- WriteUint32(num_bytes, &buffer); +- WriteBytes(reinterpret_cast(str.data()), num_bytes, +- &buffer); +- } +- }, +- [&](const std::vector& array_buffer) { +- WriteUint8(kArrayBufferTransferTag, &buffer); +- // Write at the first slot. +- WriteUint32(0, &buffer); +- +- mojo_base::BigBuffer big_buffer(array_buffer); +- message.array_buffer_contents_array.push_back( +- mojom::SerializedArrayBufferContents::New( +- std::move(big_buffer))); +- }}, +- payload); ++ WriteHeader(&buffer); + ++ switch (original.type_) { ++ case WebMessagePort::Message::MessageType::STRING: { ++ WriteU16string(original.data, &buffer); ++ break; ++ } ++ case WebMessagePort::Message::MessageType::INTEGER: { ++ WriteInt64(original.int64_value_, &buffer); ++ break; ++ } ++ case WebMessagePort::Message::MessageType::BOOLEAN: { ++ WriteBool(original.bool_value_, &buffer); ++ break; ++ } ++ case WebMessagePort::Message::MessageType::DOUBLE: { ++ WriteDouble(original.double_value_, &buffer); ++ break; ++ } ++ case WebMessagePort::Message::MessageType::BINARY: { ++ WriteArrayBuffer(original.array_buffer, message, &buffer); ++ break; ++ } ++ case WebMessagePort::Message::MessageType::ERROR: { ++ WriteError(original.err_name_, original.err_msg_, &buffer); ++ break; ++ } ++ case WebMessagePort::Message::MessageType::STRINGARRAY: { ++ WriteStringArray(original.string_arr_, &buffer); ++ break; ++ } ++ case WebMessagePort::Message::MessageType::BOOLEANARRAY: { ++ WriteBoolArray(original.bool_arr_, &buffer); ++ break; ++ } ++ case WebMessagePort::Message::MessageType::DOUBLEARRAY: { ++ WriteDoubleArray(original.double_arr_, &buffer); ++ break; ++ } ++ case WebMessagePort::Message::MessageType::INT64ARRAY: { ++ WriteInt64Array(original.int64_arr_, &buffer); ++ break; ++ case WebMessagePort::Message::MessageType::NONE: ++ case WebMessagePort::Message::MessageType::DICTIONARY: ++ case WebMessagePort::Message::MessageType::LIST: ++ break; ++ default: ++ break; ++ } ++ } + message.owned_encoded_message = std::move(buffer); + message.encoded_message = message.owned_encoded_message; + + return message; + } ++#endif + +-absl::optional DecodeToWebMessagePayload( +- const TransferableMessage& message) { +- base::BufferIterator iter(message.encoded_message); +- uint8_t tag = 0; ++#if BUILDFLAG(IS_OHOS) ++bool ReadOneByteString(base::BufferIterator& iter, ++ std::u16string& str) { ++ uint32_t num_bytes = 0; ++ if (!ReadUint32(iter, &num_bytes)) { ++ LOG(ERROR) << "ReadUint32 failed"; ++ return false; ++ } ++ auto span = iter.Span(num_bytes / sizeof(unsigned char)); ++ std::u16string result(span.begin(), span.end()); ++ str = result; ++ return true; ++} ++ ++bool ReadTwoByteString(base::BufferIterator& iter, ++ std::u16string& str) { ++ uint32_t num_bytes; ++ if (!ReadUint32(iter, &num_bytes)) { ++ LOG(ERROR) << "ReadUint32 failed"; ++ return false; ++ } ++ auto span = iter.Span(num_bytes / sizeof(char16_t)); ++ std::u16string result(span.begin(), span.end()); ++ str = result; ++ return true; ++} ++ ++bool ReadDouble(base::BufferIterator& iter, double& result) { ++ double value = 0; ++ uint8_t *p = reinterpret_cast(&value); ++ for (size_t i = 0; i < sizeof(double); i++) { ++ if (const uint8_t* ptr = iter.Object()) { ++ p[i] = *ptr; ++ } else { ++ LOG(ERROR) << "Read memory of the double value failed"; ++ return false; ++ } ++ } ++ result = value; ++ return true; ++} ++#endif + ++bool ReadHeaderTag(base::BufferIterator& iter, uint8_t& tag) { + // Discard the outer envelope, including trailer info if applicable. + if (!ReadUint8(iter, &tag)) +- return absl::nullopt; ++ return false; + if (tag == kVersionTag) { + uint32_t version = 0; + if (!ReadUint32(iter, &version)) +- return absl::nullopt; ++ return false; + static constexpr uint32_t kMinWireFormatVersionWithTrailer = 21; + if (version >= kMinWireFormatVersionWithTrailer) { + // In these versions, we expect kTrailerOffsetTag (0xFE) followed by an +- // offset and size. +- // See details in v8/serialization/serialization_tag.h ++ // offset and size. ++ // See details in v8/serialization/serialization_tag.h + auto span = iter.Span(1 + sizeof(uint64_t) + sizeof(uint32_t)); + if (span.empty() || span[0] != 0xFE) { + LOG(ERROR) << "Span is empty or span[0] not correct"; +- return absl::nullopt; ++ return false; + } + } + if (!ReadUint8(iter, &tag)) { +- return absl::nullopt; ++ return false; + } + } + +@@ -236,54 +554,419 @@ absl::optional DecodeToWebMessagePayload( + uint32_t version; + if (tag == kVersionTag && !ReadUint32(iter, &version)) { + LOG(ERROR) << "Read tag or version failed, tag:" << (int)tag; +- return absl::nullopt; ++ return false; + } + if (!ReadUint8(iter, &tag)) { + LOG(ERROR) << "ReadUint8 failed"; +- return absl::nullopt; ++ return false; + } + } ++ return true; ++} + ++#if BUILDFLAG(IS_OHOS) ++bool ReadU16string(base::BufferIterator& iter, ++ std::u16string& str) { ++ uint8_t tag = 0; ++ if (!ReadUint8(iter, &tag)) { ++ LOG(ERROR) << "read tag failed"; ++ return false; ++ } + switch (tag) { + case kOneByteStringTag: { +- // Use of unsigned char rather than char here matters, so that Latin-1 +- // characters are zero-extended rather than sign-extended +- uint32_t num_bytes; +- if (!ReadUint32(iter, &num_bytes)) { +- LOG(ERROR) << "ReadUint32 failed"; +- return absl::nullopt; ++ ReadOneByteString(iter, str); ++ break; ++ } ++ case kTwoByteStringTag: { ++ ReadTwoByteString(iter, str); ++ break; ++ } ++ default: ++ LOG(ERROR) << "not support tag:" << tag; ++ return false; ++ } ++ return true; ++} ++ ++// int32Ϊ�ɱ䳤���룬����һ��int32��ֱ�Ӵ�iter��ǰ������β���ɡ� ++bool ReadInt32(base::BufferIterator& iter, int32_t& result) { ++ auto span = iter.Span(iter.total_size() - iter.position()); ++ if (span.empty()) { ++ return false; ++ } ++ std::vector array_buf(span.begin(), span.end()); ++ uint32_t value = ++ ReadVarint(&array_buf[0], &array_buf[array_buf.size() - 1]); ++ // zigzag decode: ++ // https://stackoverflow.com/questions/4533076/google-protocol-buffers-zigzag-encoding ++ result = ++ static_cast((value >> 1) ^ -static_cast(value & 1)); ++ return true; ++} ++ ++// int32Ϊ�ɱ䳤���룬�����е�int32�޷�ֱ��ʹ�����淽ʽ��ȡ����Ϊ��ȡ������������һ��Ԫ�صı�־λ���߽�β�� ++bool ReadInt32InArray(base::BufferIterator& iter, ++ int32_t& result) { ++ int32_t value = 0; ++ const uint8_t* begin = iter.Object(); ++ if (begin == nullptr || (iter.total_size() - iter.position()) < 1) { ++ return false; ++ } ++ const uint8_t* current = begin; ++ while ((iter.total_size() - iter.position()) >= 1) { ++ current = iter.Object(); ++ if (*current == kEndDenseJSArray || *current == kInt32) { ++ value = ReadVarint(begin, --current); ++ // zigzag decode: ++ // https://stackoverflow.com/questions/4533076/google-protocol-buffers-zigzag-encoding ++ result = ++ static_cast((value >> 1) ^ -static_cast(value & 1)); ++ iter.Seek(iter.position() - 1); ++ return true; ++ } ++ } ++ return false; ++} ++ ++bool IsBoolElement(uint8_t element_tag) { ++ return element_tag == kTrue || element_tag == kFalse; ++} ++ ++bool IsStringElement(uint8_t element_tag) { ++ return element_tag == kOneByteStringTag || element_tag == kTwoByteStringTag; ++} ++ ++bool IsNumberElement(uint8_t element_tag) { ++ return element_tag == kDouble || element_tag == kInt32 || ++ element_tag == kUint32; ++} ++ ++bool ReadArray(base::BufferIterator& iter, ++ struct WebMessagePort::Message& decoded_msg) { ++ uint32_t len = 0; ++ if (!ReadUint32(iter, &len)) { // array length ++ LOG(ERROR) << "ReadUint32 failed"; ++ return false; ++ } ++ std::vector string_array; ++ std::vector boolean_array; ++ std::vector double_array; ++ std::vector int64_array; ++ uint8_t element_tag_first = 0; ++ uint8_t element_tag = 0; ++ bool support = true; ++ for (uint32_t i = 0; i < len; i++) { ++ if (!ReadUint8(iter, &element_tag)) { ++ LOG(ERROR) << "ReadUint8 failed"; ++ return false; ++ } ++ if (i == 0) { ++ element_tag_first = element_tag; ++ } ++ if (element_tag_first != element_tag) { ++ support = false; ++ decoded_msg.data = ++ u"This type not support, The elements in the array must be the same"; ++ decoded_msg.type_ = WebMessagePort::Message::MessageType::STRING; ++ return true; ++ } ++ switch (element_tag) { ++ case kOneByteStringTag: { ++ std::u16string value; ++ if (ReadOneByteString(iter, value)) { ++ string_array.push_back(value); ++ } else { ++ LOG(ERROR) << "ReadOneByteString failed"; ++ return false; ++ } ++ break; ++ } ++ case kTwoByteStringTag: { ++ std::u16string value; ++ if (ReadTwoByteString(iter, value)) { ++ string_array.push_back(value); ++ } else { ++ LOG(ERROR) << "ReadTwoByteString failed"; ++ return false; ++ } ++ break; ++ } ++ case kTrue: { ++ boolean_array.push_back(true); ++ break; ++ } ++ case kFalse: { ++ boolean_array.push_back(false); ++ break; ++ } ++ case kDouble: { ++ double value = 0.0; ++ if (ReadDouble(iter, value)) { ++ double_array.push_back(value); ++ } else { ++ LOG(ERROR) << "ReadDouble failed"; ++ return false; ++ } ++ break; ++ } ++ case kInt32: { ++ int32_t value = 0; ++ if (ReadInt32InArray(iter, value)) { ++ int64_array.push_back(value); ++ } else { ++ LOG(ERROR) << "ReadInt32InArray failed"; ++ return false; ++ } ++ break; ++ } ++ case kUint32: { ++ uint32_t value = 0; ++ if (ReadUint32(iter, &value)) { ++ int64_array.push_back(value); ++ } else { ++ LOG(ERROR) << "ReadUint32 failed"; ++ return false; ++ } ++ break; ++ } ++ default: { ++ decoded_msg.data = ++ u"This type not support, only string/number/boolean is supported " ++ u"for array elements"; ++ decoded_msg.type_ = WebMessagePort::Message::MessageType::STRING; ++ return true; + } +- auto span = iter.Span(num_bytes / sizeof(unsigned char)); +- std::u16string str(span.begin(), span.end()); +- return span.size_bytes() == num_bytes +- ? absl::make_optional(WebMessagePayload(std::move(str))) +- : absl::nullopt; + } ++ } ++ ++ while ((iter.total_size() - iter.position()) >= 1) { ++ if (!ReadUint8(iter, &element_tag)) { ++ LOG(ERROR) << "ReadUint8 failed"; ++ return false; ++ } ++ if (element_tag == kEndDenseJSArray) { ++ LOG(INFO) << "end tag of this array"; ++ break; ++ } ++ } ++ switch (element_tag_first) { ++ case kOneByteStringTag: + case kTwoByteStringTag: { +- uint32_t num_bytes; +- if (!ReadUint32(iter, &num_bytes)) { +- LOG(ERROR) << "ReadUint32 failed"; +- return absl::nullopt; ++ decoded_msg.string_arr_ = std::move(string_array); ++ decoded_msg.type_ = WebMessagePort::Message::MessageType::STRINGARRAY; ++ break; ++ } ++ case kTrue: ++ case kFalse: { ++ decoded_msg.bool_arr_ = std::move(boolean_array); ++ decoded_msg.type_ = WebMessagePort::Message::MessageType::BOOLEANARRAY; ++ break; ++ } ++ case kDouble: { ++ decoded_msg.double_arr_ = std::move(double_array); ++ decoded_msg.type_ = WebMessagePort::Message::MessageType::DOUBLEARRAY; ++ break; ++ } ++ case kInt32: ++ case kUint32: { ++ decoded_msg.int64_arr_ = std::move(int64_array); ++ decoded_msg.type_ = WebMessagePort::Message::MessageType::INT64ARRAY; ++ break; ++ } ++ } ++ return true; ++} ++ ++std::u16string GetProtoTypeName(ErrorTag tag) { ++ std::u16string name = u"Error"; ++ switch (tag) { ++ case ErrorTag::kEvalErrorPrototype: { ++ name = u"EvalError"; ++ break; ++ } ++ case ErrorTag::kRangeErrorPrototype: { ++ name = u"RangeError"; ++ break; ++ } ++ case ErrorTag::kReferenceErrorPrototype: { ++ name = u"ReferenceError"; ++ break; ++ } ++ case ErrorTag::kSyntaxErrorPrototype: { ++ name = u"SyntaxError"; ++ break; ++ } ++ case ErrorTag::kTypeErrorPrototype: { ++ name = u"TypeError"; ++ break; ++ } ++ case ErrorTag::kUriErrorPrototype: { ++ name = u"URIError"; ++ break; ++ } ++ default: { ++ break; ++ } ++ } ++ return name; ++} ++ ++bool ReadError(base::BufferIterator& iter, ++ struct WebMessagePort::Message& decoded_msg) { ++ bool done = false; ++ while (!done) { ++ uint8_t tag = 0; ++ if (!ReadUint8(iter, &tag)) { ++ LOG(ERROR) << "Read tag failed, not enough byte left"; ++ return false; ++ } ++ switch (static_cast(tag)) { ++ case ErrorTag::kStack: { ++ std::u16string stack_err; ++ ReadU16string(iter, stack_err); ++ break; + } +- auto span = iter.Span(num_bytes / sizeof(char16_t)); +- std::u16string str(span.begin(), span.end()); +- return span.size_bytes() == num_bytes +- ? absl::make_optional(WebMessagePayload(std::move(str))) +- : absl::nullopt; ++ case ErrorTag::kEvalErrorPrototype: ++ case ErrorTag::kRangeErrorPrototype: ++ case ErrorTag::kReferenceErrorPrototype: ++ case ErrorTag::kSyntaxErrorPrototype: ++ case ErrorTag::kTypeErrorPrototype: ++ case ErrorTag::kUriErrorPrototype: ++ decoded_msg.err_name_ = GetProtoTypeName(static_cast(tag)); ++ decoded_msg.type_ = WebMessagePort::Message::MessageType::ERROR; ++ break; ++ case ErrorTag::kMessage: { ++ std::u16string msg_err; ++ ReadU16string(iter, msg_err); ++ decoded_msg.err_msg_ = std::move(msg_err); ++ decoded_msg.type_ = WebMessagePort::Message::MessageType::ERROR; ++ break; ++ } ++ case ErrorTag::kCause: { ++ done = true; ++ break; ++ } ++ case ErrorTag::kEnd: { ++ done = true; ++ break; ++ } ++ default: ++ done = true; ++ break; ++ } ++ } ++ return true; ++} ++ ++// see src/v8/src/objects/value-serializer.cc for more details about the ++// deserialization. ++bool DecodeToWebMessagePayload(const TransferableMessage& message, ++ struct WebMessagePort::Message& decoded_msg) { ++ base::BufferIterator iter(message.encoded_message); ++ LOG(INFO) << "decoded start, iter total_size:" << iter.total_size(); ++ ++ uint8_t tag = 0; ++ if (!ReadHeaderTag(iter, tag)) { ++ LOG(ERROR) << "Read head tag failed, tag:" << (int)tag; ++ return false; ++ } ++ switch (tag) { ++ case kOneByteStringTag: { ++ std::u16string str; ++ if (ReadOneByteString(iter, str)) { ++ decoded_msg.data = std::move(str); ++ decoded_msg.type_ = WebMessagePort::Message::MessageType::STRING; ++ } else { ++ return false; ++ } ++ break; ++ } ++ case kTwoByteStringTag: { ++ std::u16string str; ++ if (ReadTwoByteString(iter, str)) { ++ decoded_msg.data = std::move(str); ++ decoded_msg.type_ = WebMessagePort::Message::MessageType::STRING; ++ } else { ++ return false; ++ } ++ break; + } + case kArrayBuffer: { + uint32_t num_bytes; + if (!ReadUint32(iter, &num_bytes)) +- return absl::nullopt; ++ return false; + auto span = iter.Span(num_bytes); + std::vector array_buf(span.begin(), span.end()); +- return span.size_bytes() == num_bytes +- ? absl::make_optional( +- WebMessagePayload(std::move(array_buf))) +- : absl::nullopt; ++ decoded_msg.array_buffer = std::move(array_buf); ++ decoded_msg.type_ = WebMessagePort::Message::MessageType::BINARY; ++ break; ++ } ++ case kTrue: { ++ decoded_msg.bool_value_ = true; ++ decoded_msg.type_ = WebMessagePort::Message::MessageType::BOOLEAN; ++ break; ++ } ++ case kFalse: { ++ decoded_msg.bool_value_ = false; ++ decoded_msg.type_ = WebMessagePort::Message::MessageType::BOOLEAN; ++ break; ++ } ++ case kDouble: { ++ double value = 0; ++ if (ReadDouble(iter, value)) { ++ decoded_msg.double_value_ = value; ++ decoded_msg.type_ = WebMessagePort::Message::MessageType::DOUBLE; ++ } else { ++ LOG(ERROR) << "ReadDouble error"; ++ return false; ++ } ++ break; ++ } ++ case kInt32: { ++ int32_t vaule = 0; ++ if (ReadInt32(iter, vaule)) { ++ decoded_msg.int64_value_ = vaule; ++ decoded_msg.type_ = WebMessagePort::Message::MessageType::INTEGER; ++ } else { ++ LOG(ERROR) << "ReadInt32 failed"; ++ return false; ++ } ++ break; + } ++ case kUint32: { ++ uint32_t value = 0; ++ if (ReadUint32(iter, &value)) { ++ decoded_msg.int64_value_ = value; ++ decoded_msg.type_ = WebMessagePort::Message::MessageType::INTEGER; ++ } else { ++ LOG(ERROR) << "ReadUint32 failed"; ++ return false; ++ } ++ break; ++ } ++ case kError: { ++ if (!ReadError(iter, decoded_msg)) { ++ LOG(ERROR) << "ReadError failed"; ++ return false; ++ } ++ break; ++ } ++ case kBeginDenseJSArray: { ++ if (!ReadArray(iter, decoded_msg)) { ++ LOG(ERROR) << "ReadArray failed"; ++ return false; ++ } ++ break; ++ } ++ default: ++ decoded_msg.data = ++ u"This type not support, only " ++ u"string/number/boolean/arraybuffer/array/error is supported"; ++ decoded_msg.type_ = WebMessagePort::Message::MessageType::STRING; ++ return true; + } +- LOG(ERROR) << "Unexpected tag:"<< tag; +- return absl::nullopt; ++ LOG(INFO) << "Decoded transfer message end"; ++ return true; + } ++#endif + } // namespace blink + diff --git a/src/third_party/blink/common/messaging/web_message_port.cc b/src/third_party/blink/common/messaging/web_message_port.cc +index 48dba36367f..86699a753be +--- a/src/third_party/blink/common/messaging/web_message_port.cc ++++ b/src/third_party/blink/common/messaging/web_message_port.cc +@@ -141,6 +141,7 @@ bool WebMessagePort::CanPostMessage() const { + } + + bool WebMessagePort::PostMessage(Message&& message) { ++ LOG(INFO) << "WebMessagePort::PostMessage start"; + if (!CanPostMessage()) + return false; + +@@ -158,11 +159,9 @@ bool WebMessagePort::PostMessage(Message&& message) { + // Build the message. + // TODO(chrisha): Finally kill off MessagePortChannel, once + // MessagePortDescriptor more thoroughly plays that role. ++ + blink::TransferableMessage transferable_message = +- blink::EncodeWebMessagePayload( +- message.array_buffer.size() != 0 ? +- WebMessagePayload(std::move(message.array_buffer)) : +- WebMessagePayload(std::move(message.data))); ++ blink::EncodeWebMessagePayload(message); + + transferable_message.ports = + blink::MessagePortChannel::CreateFromHandles(std::move(ports)); +@@ -235,21 +234,10 @@ bool WebMessagePort::Accept(mojo::Message* mojo_message) { + + // Decode the string portion of the message. + Message message; +- absl::optional optional_payload = +- blink::DecodeToWebMessagePayload(transferable_message); +- if (!optional_payload) { ++ if (!blink::DecodeToWebMessagePayload(transferable_message, message)) { + LOG(ERROR) << "WebMessagePort::Accept DecodeToWebMessagePayload failed"; + return true; + } +- auto& payload = optional_payload.value(); +- if (auto* str = absl::get_if(&payload)) { +- message.data = std::move(*str); +- } else if (auto* array_buffer = absl::get_if>(&payload)) { +- message.array_buffer = std::move(*array_buffer); +- } else { +- LOG(INFO) << "WebMessagePort::Accept Get string or arraybuffer failed"; +- return true; +- } + + // Convert raw handles to MessagePorts. + // TODO(chrisha): Kill off MessagePortChannel entirely! +diff --git a/src/third_party/blink/common/web_preferences/web_preferences.cc b/src/third_party/blink/common/web_preferences/web_preferences.cc +index 9b870d8a82f..dc43b37fe28 +--- a/src/third_party/blink/common/web_preferences/web_preferences.cc ++++ b/src/third_party/blink/common/web_preferences/web_preferences.cc +@@ -83,6 +83,8 @@ WebPreferences::WebPreferences() + #if BUILDFLAG(IS_OHOS) + hide_vertical_scrollbars(false), + hide_horizontal_scrollbars(false), ++ contextmenu_customization_enabled(false), ++ scrollbar_color(0), + #endif + accelerated_2d_canvas_enabled(false), + new_canvas_2d_api_enabled(false), +@@ -131,11 +133,7 @@ WebPreferences::WebPreferences() + #if defined(OS_ANDROID) || BUILDFLAG(IS_OHOS) + viewport_meta_enabled(true), + shrinks_viewport_contents_to_fit(true), +-#if BUILDFLAG(IS_OHOS) +- viewport_style(mojom::ViewportStyle::kDefault), +-#else + viewport_style(mojom::ViewportStyle::kMobile), +-#endif + always_show_context_menu_on_touch(false), + smooth_scroll_for_find_enabled(true), + main_frame_resizes_are_orientation_changes(true), +@@ -174,8 +172,12 @@ WebPreferences::WebPreferences() + fullscreen_supported(true), + #if !defined(OS_ANDROID) && !BUILDFLAG(IS_OHOS) + text_autosizing_enabled(false), ++#else ++#if BUILDFLAG(IS_OHOS) ++ text_autosizing_enabled(false), + #else + text_autosizing_enabled(true), ++#endif + font_scale_factor(1.0f), + device_scale_adjustment(1.0f), + force_enable_zoom(false), +diff --git a/src/third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc b/src/third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc +index 8546be13bbf..199fd632447 +--- a/src/third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc ++++ b/src/third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc +@@ -97,6 +97,11 @@ bool StructTraitshide_vertical_scrollbars = data.hide_vertical_scrollbars(); + out->hide_horizontal_scrollbars = data.hide_horizontal_scrollbars(); ++ out->contextmenu_customization_enabled = ++ data.contextmenu_customization_enabled(); ++ out->scrollbar_color = data.scrollbar_color(); ++ out->blank_target_popup_intercept_enabled = ++ data.blank_target_popup_intercept_enabled(); + #endif + out->accelerated_2d_canvas_enabled = data.accelerated_2d_canvas_enabled(); + out->new_canvas_2d_api_enabled = data.new_canvas_2d_api_enabled(); +diff --git a/src/third_party/blink/public/common/context_menu_data/context_menu_data.h b/src/third_party/blink/public/common/context_menu_data/context_menu_data.h +index d86b2fa2dcf..67628d1c567 +--- a/src/third_party/blink/public/common/context_menu_data/context_menu_data.h ++++ b/src/third_party/blink/public/common/context_menu_data/context_menu_data.h +@@ -117,6 +117,10 @@ struct ContextMenuData { + // Whether context is editable. + bool is_editable; + ++#if BUILDFLAG(IS_OHOS) ++ // Whether can be selectable. ++ bool is_selectable; ++#endif + // If this node is an input field, the type of that field. + blink::mojom::ContextMenuDataInputFieldType input_field_type; + +diff --git a/src/third_party/blink/public/common/context_menu_data/context_menu_mojom_traits.h b/src/third_party/blink/public/common/context_menu_data/context_menu_mojom_traits.h +index 60fd1775a61..60378ddd56b +--- a/src/third_party/blink/public/common/context_menu_data/context_menu_mojom_traits.h ++++ b/src/third_party/blink/public/common/context_menu_data/context_menu_mojom_traits.h +@@ -99,6 +99,12 @@ struct BLINK_COMMON_EXPORT + return r.is_editable; + } + ++#if BUILDFLAG(IS_OHOS) ++ static bool is_selectable(const blink::UntrustworthyContextMenuParams& r) { ++ return r.is_selectable; ++ } ++#endif ++ + static int writing_direction_default( + const blink::UntrustworthyContextMenuParams& r) { + return r.writing_direction_default; +diff --git a/src/third_party/blink/public/common/context_menu_data/untrustworthy_context_menu_params.h b/src/third_party/blink/public/common/context_menu_data/untrustworthy_context_menu_params.h +index 198294a2870..745e70a03a3 +--- a/src/third_party/blink/public/common/context_menu_data/untrustworthy_context_menu_params.h ++++ b/src/third_party/blink/public/common/context_menu_data/untrustworthy_context_menu_params.h +@@ -103,6 +103,10 @@ struct BLINK_COMMON_EXPORT UntrustworthyContextMenuParams { + // Whether context is editable. + bool is_editable; + ++ // Whether inner can selectable. ++#if BUILDFLAG(IS_OHOS) ++ bool is_selectable; ++#endif + // Writing direction menu items. + int writing_direction_default; + int writing_direction_left_to_right; +diff --git a/src/third_party/blink/public/common/input/web_menu_source_type.h b/src/third_party/blink/public/common/input/web_menu_source_type.h +index 7eb94383312..ee3a9f45f12 +--- a/src/third_party/blink/public/common/input/web_menu_source_type.h ++++ b/src/third_party/blink/public/common/input/web_menu_source_type.h +@@ -19,7 +19,12 @@ enum WebMenuSourceType { + kMenuSourceStylus, + kMenuSourceAdjustSelection, + kMenuSourceAdjustSelectionReset, ++#if defined(OHOS_NWEB_EX) ++ kMenuSourceSelectAndCopy, ++ kMenuSourceTypeLast = kMenuSourceSelectAndCopy ++#else + kMenuSourceTypeLast = kMenuSourceAdjustSelectionReset ++#endif + }; + + } // namespace blink +diff --git a/src/third_party/blink/public/common/messaging/string_message_codec.h b/src/third_party/blink/public/common/messaging/string_message_codec.h +index 48b0a5ad6de..6bde26dd393 +--- a/src/third_party/blink/public/common/messaging/string_message_codec.h ++++ b/src/third_party/blink/public/common/messaging/string_message_codec.h +@@ -15,6 +15,7 @@ + #include "third_party/blink/public/common/common_export.h" + #if BUILDFLAG(IS_OHOS) + #include "third_party/blink/public/common/messaging/transferable_message.h" ++#include "third_party/blink/public/common/messaging/web_message_port.h" + #endif + + namespace blink { +@@ -37,12 +38,13 @@ BLINK_COMMON_EXPORT bool DecodeStringMessage( + std::u16string* result); + + #if BUILDFLAG(IS_OHOS) +-using WebMessagePayload = absl::variant>; ++ + BLINK_COMMON_EXPORT TransferableMessage +-EncodeWebMessagePayload(const WebMessagePayload& payload); ++EncodeWebMessagePayload(struct WebMessagePort::Message& encoded_data); + +-BLINK_COMMON_EXPORT absl::optional DecodeToWebMessagePayload( +- const TransferableMessage& message); ++BLINK_COMMON_EXPORT bool DecodeToWebMessagePayload( ++ const TransferableMessage& encoded_data, ++ struct WebMessagePort::Message& decoded_data); + #endif + + } // namespace blink +diff --git a/src/third_party/blink/public/common/messaging/web_message_port.h b/src/third_party/blink/public/common/messaging/web_message_port.h +index 665c684870c..c036e470d78 +--- a/src/third_party/blink/public/common/messaging/web_message_port.h ++++ b/src/third_party/blink/public/common/messaging/web_message_port.h +@@ -189,13 +189,31 @@ struct BLINK_COMMON_EXPORT WebMessagePort::Message { + Message& operator=(Message&&); + ~Message(); + ++#if BUILDFLAG(IS_OHOS) ++ enum class MessageType : unsigned char { ++ NONE = 0, ++ BOOLEAN, ++ INTEGER, ++ DOUBLE, ++ STRING, ++ BINARY, ++ DICTIONARY, ++ LIST, ++ ERROR, ++ STRINGARRAY, ++ BOOLEANARRAY, ++ DOUBLEARRAY, ++ INT64ARRAY ++ }; ++#endif ++ + // Creates a message with the given |data|. + explicit Message(const std::u16string& data); + +- #if BUILDFLAG(IS_OHOS) ++#if BUILDFLAG(IS_OHOS) + // Creates a message with the given |array_buffer|. + explicit Message(std::vector array_buffer); +- #endif ++#endif + + // Creates a message with the given collection of |ports| to be transferred. + explicit Message(std::vector ports); +@@ -213,10 +231,20 @@ struct BLINK_COMMON_EXPORT WebMessagePort::Message { + // A UTF-16 message. + std::u16string data; + +- #if BUILDFLAG(IS_OHOS) ++#if BUILDFLAG(IS_OHOS) + // std::vector: the ArrayBuffer. + std::vector array_buffer; +- #endif ++ MessageType type_ = MessageType::NONE; ++ bool bool_value_; ++ double double_value_; ++ int64_t int64_value_; ++ std::vector string_arr_; ++ std::vector bool_arr_; ++ std::vector double_arr_; ++ std::vector int64_arr_; ++ std::u16string err_name_; ++ std::u16string err_msg_; ++#endif + + // Other message ports that are to be transmitted as part of this message. + std::vector ports; +diff --git a/src/third_party/blink/public/common/web_preferences/web_preferences.h b/src/third_party/blink/public/common/web_preferences/web_preferences.h +index f3c469e00b1..5585f8f80de +--- a/src/third_party/blink/public/common/web_preferences/web_preferences.h ++++ b/src/third_party/blink/public/common/web_preferences/web_preferences.h +@@ -97,6 +97,8 @@ struct BLINK_COMMON_EXPORT WebPreferences { + #if BUILDFLAG(IS_OHOS) + bool hide_vertical_scrollbars; + bool hide_horizontal_scrollbars; ++ bool contextmenu_customization_enabled; ++ uint32_t scrollbar_color; + #endif + bool accelerated_2d_canvas_enabled; + bool canvas_2d_layers_enabled = false; +@@ -261,6 +263,8 @@ struct BLINK_COMMON_EXPORT WebPreferences { + + // Don't accelerate small canvases to avoid crashes TODO(crbug.com/1004304) + bool disable_accelerated_small_canvases; ++ ++ bool blank_target_popup_intercept_enabled = true; + #endif // defined(OS_ANDROID) + + // Enable forcibly modifying content rendering to result in a light on dark +diff --git a/src/third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h b/src/third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h +index 178bcd6e601..b45ccf95e97 +--- a/src/third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h ++++ b/src/third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h +@@ -657,6 +657,11 @@ struct BLINK_COMMON_EXPORT StructTraits compositor_; ++ std::unique_ptr compositor_; + + const WebString initial_audio_output_device_id_; + +diff --git a/src/third_party/blink/public/web/web_frame_widget.h b/src/third_party/blink/public/web/web_frame_widget.h +index 2245c633bcf..64b9aede006 +--- a/src/third_party/blink/public/web/web_frame_widget.h ++++ b/src/third_party/blink/public/web/web_frame_widget.h +@@ -60,6 +60,10 @@ class WebFrameWidget : public WebWidget { + virtual void InitializeNonCompositing( + WebNonCompositedWidgetClient* client) = 0; + ++#if BUILDFLAG(IS_OHOS) ++ virtual void SetZoomLevel(float magnify_delta, const gfx::Point& anchor) {} ++#endif // BUILDFLAG(IS_OHOS) ++ + // Returns the local root of this WebFrameWidget. + virtual WebLocalFrame* LocalRoot() const = 0; + +diff --git a/src/third_party/blink/public/web/web_local_frame.h b/src/third_party/blink/public/web/web_local_frame.h +index 2ce14df1f69..1ab4b2285e7 +--- a/src/third_party/blink/public/web/web_local_frame.h ++++ b/src/third_party/blink/public/web/web_local_frame.h +@@ -894,6 +894,10 @@ class WebLocalFrame : public WebFrame { + CrossVariantMojoRemote + session_storage_area) = 0; + ++#if BUILDFLAG(IS_OHOS) ++ virtual void SelectClosetWordAndShowSelectionMenu() = 0; ++#endif ++ + protected: + explicit WebLocalFrame(mojom::TreeScopeType scope, + const LocalFrameToken& frame_token) +diff --git a/src/third_party/blink/public/web/web_settings.h b/src/third_party/blink/public/web/web_settings.h +index 9a924f0bb60..82b5b1d826c +--- a/src/third_party/blink/public/web/web_settings.h ++++ b/src/third_party/blink/public/web/web_settings.h +@@ -174,6 +174,9 @@ class WebSettings { + #if BUILDFLAG(IS_OHOS) + virtual void SetVerticalHideScrollbars(bool) = 0; + virtual void SetHorizontalHideScrollbars(bool) = 0; ++ virtual void SetContextMenuCustomization(bool) = 0; ++ virtual void SetScrollBarColor(uint32_t) = 0; ++ virtual void EnableBlankTargetPopupIntercept(bool) = 0; + #endif + virtual void SetPasswordEchoDurationInSeconds(double) = 0; + virtual void SetPasswordEchoEnabled(bool) = 0; +diff --git a/src/third_party/blink/renderer/bindings/core/v8/custom/v8_dev_tools_host_custom.cc b/src/third_party/blink/renderer/bindings/core/v8/custom/v8_dev_tools_host_custom.cc +index 6b5772d776e..dea4c0ff626 +--- a/src/third_party/blink/renderer/bindings/core/v8/custom/v8_dev_tools_host_custom.cc ++++ b/src/third_party/blink/renderer/bindings/core/v8/custom/v8_dev_tools_host_custom.cc +@@ -63,8 +63,13 @@ static bool PopulateContextMenuItems(v8::Isolate* isolate, + std::vector& items) { + v8::Local context = isolate->GetCurrentContext(); + for (uint32_t i = 0; i < item_array->Length(); ++i) { +- v8::Local item = +- item_array->Get(context, i).ToLocalChecked().As(); ++ v8::Local item_value = ++ item_array->Get(context, i).ToLocalChecked(); ++ if (!item_value->IsObject()) { ++ return false; ++ } ++ v8::Local item = item_value.As(); ++ + v8::Local type; + v8::Local id; + v8::Local label; +diff --git a/src/third_party/blink/renderer/bindings/core/v8/observable_array_exotic_object_handler.h b/src/third_party/blink/renderer/bindings/core/v8/observable_array_exotic_object_handler.h +index 1b31781f4b4..4b17428992c +--- a/src/third_party/blink/renderer/bindings/core/v8/observable_array_exotic_object_handler.h ++++ b/src/third_party/blink/renderer/bindings/core/v8/observable_array_exotic_object_handler.h +@@ -54,13 +54,17 @@ class ObservableArrayExoticObjectHandler { + const v8::FunctionCallbackInfo& info) { + v8::Isolate* isolate = info.GetIsolate(); + v8::Local current_context = isolate->GetCurrentContext(); +- v8::Local v8_target = info[0].As(); +- v8::Local v8_property = info[1]; +- v8::Local v8_desc_obj = info[2]; +- BackingListWrappable& backing_list = ToWrappableUnsafe(isolate, v8_target); + ExceptionState exception_state( +- isolate, ExceptionContext::Context::kNamedPropertyDefine, +- backing_list.ObservableArrayNameInIDL()); ++ isolate, ExceptionContext::Context::kOperationInvoke, ++ BackingListWrappable::ObservableArrayNameInIDL(), "defineProperty"); ++ if (!(info[0]->IsArray() && info[1]->IsName() && info[2]->IsObject())) { ++ exception_state.ThrowTypeError("Invalid argument."); ++ return; ++ } ++ v8::Local v8_target = info[0].As(); ++ v8::Local v8_property = info[1].As(); ++ v8::Local v8_desc_obj = info[2].As(); ++ BackingListWrappable& backing_list = ToWrappableOrDie(isolate, v8_target); + + V8PropertyDescriptorBag desc_bag; + V8ObjectToPropertyDescriptor(isolate, v8_desc_obj, desc_bag, +@@ -112,9 +116,7 @@ class ObservableArrayExoticObjectHandler { + desc.set_configurable(desc_bag.configurable); + if (desc_bag.has_enumerable) + desc.set_enumerable(desc_bag.enumerable); +- if (!v8_target +- ->DefineProperty(current_context, v8_property.As(), +- desc) ++ if (!v8_target->DefineProperty(current_context, v8_property, desc) + .To(&is_defined)) { + return; + } +@@ -124,9 +126,7 @@ class ObservableArrayExoticObjectHandler { + desc.set_configurable(desc_bag.configurable); + if (desc_bag.has_enumerable) + desc.set_enumerable(desc_bag.enumerable); +- if (!v8_target +- ->DefineProperty(current_context, v8_property.As(), +- desc) ++ if (!v8_target->DefineProperty(current_context, v8_property, desc) + .To(&is_defined)) { + return; + } +@@ -139,9 +139,16 @@ class ObservableArrayExoticObjectHandler { + const v8::FunctionCallbackInfo& info) { + v8::Isolate* isolate = info.GetIsolate(); + v8::Local current_context = isolate->GetCurrentContext(); ++ if (!(info[0]->IsArray() && info[1]->IsName())) { ++ ExceptionState exception_state( ++ isolate, ExceptionContext::Context::kOperationInvoke, ++ BackingListWrappable::ObservableArrayNameInIDL(), "deleteProperty"); ++ exception_state.ThrowTypeError("Invalid argument."); ++ return; ++ } + v8::Local v8_target = info[0].As(); +- v8::Local v8_property = info[1]; +- BackingListWrappable& backing_list = ToWrappableUnsafe(isolate, v8_target); ++ v8::Local v8_property = info[1].As(); ++ BackingListWrappable& backing_list = ToWrappableOrDie(isolate, v8_target); + + if (v8_property->IsString()) { + v8::Local v8_index; +@@ -154,7 +161,7 @@ class ObservableArrayExoticObjectHandler { + ScriptState* script_state = ScriptState::From(current_context); + ExceptionState exception_state( + isolate, ExceptionContext::Context::kIndexedPropertyDelete, +- backing_list.ObservableArrayNameInIDL()); ++ BackingListWrappable::ObservableArrayNameInIDL()); + if (!RunDeleteAlgorithm(script_state, backing_list, index, + exception_state)) { + return; +@@ -181,9 +188,16 @@ class ObservableArrayExoticObjectHandler { + static void TrapGet(const v8::FunctionCallbackInfo& info) { + v8::Isolate* isolate = info.GetIsolate(); + v8::Local current_context = isolate->GetCurrentContext(); ++ if (!(info[0]->IsArray() && info[1]->IsName())) { ++ ExceptionState exception_state( ++ isolate, ExceptionContext::Context::kOperationInvoke, ++ BackingListWrappable::ObservableArrayNameInIDL(), "get"); ++ exception_state.ThrowTypeError("Invalid argument."); ++ return; ++ } + v8::Local v8_target = info[0].As(); +- v8::Local v8_property = info[1]; +- BackingListWrappable& backing_list = ToWrappableUnsafe(isolate, v8_target); ++ v8::Local v8_property = info[1].As(); ++ BackingListWrappable& backing_list = ToWrappableOrDie(isolate, v8_target); + + if (v8_property->IsString()) { + v8::Local v8_index; +@@ -221,9 +235,17 @@ class ObservableArrayExoticObjectHandler { + const v8::FunctionCallbackInfo& info) { + v8::Isolate* isolate = info.GetIsolate(); + v8::Local current_context = isolate->GetCurrentContext(); ++ if (!(info[0]->IsArray() && info[1]->IsName())) { ++ ExceptionState exception_state( ++ isolate, ExceptionContext::Context::kOperationInvoke, ++ BackingListWrappable::ObservableArrayNameInIDL(), ++ "getOwnPropertyDescriptor"); ++ exception_state.ThrowTypeError("Invalid argument."); ++ return; ++ } + v8::Local v8_target = info[0].As(); +- v8::Local v8_property = info[1]; +- BackingListWrappable& backing_list = ToWrappableUnsafe(isolate, v8_target); ++ v8::Local v8_property = info[1].As(); ++ BackingListWrappable& backing_list = ToWrappableOrDie(isolate, v8_target); + + if (v8_property->IsString()) { + v8::Local v8_index; +@@ -258,9 +280,7 @@ class ObservableArrayExoticObjectHandler { + } + + v8::Local v8_value; +- if (!v8_target +- ->GetOwnPropertyDescriptor(current_context, +- v8_property.As()) ++ if (!v8_target->GetOwnPropertyDescriptor(current_context, v8_property) + .ToLocal(&v8_value)) { + return; + } +@@ -271,9 +291,16 @@ class ObservableArrayExoticObjectHandler { + static void TrapHas(const v8::FunctionCallbackInfo& info) { + v8::Isolate* isolate = info.GetIsolate(); + v8::Local current_context = isolate->GetCurrentContext(); ++ if (!(info[0]->IsArray() && info[1]->IsName())) { ++ ExceptionState exception_state( ++ isolate, ExceptionContext::Context::kOperationInvoke, ++ BackingListWrappable::ObservableArrayNameInIDL(), "has"); ++ exception_state.ThrowTypeError("Invalid argument."); ++ return; ++ } + v8::Local v8_target = info[0].As(); +- v8::Local v8_property = info[1]; +- BackingListWrappable& backing_list = ToWrappableUnsafe(isolate, v8_target); ++ v8::Local v8_property = info[1].As(); ++ BackingListWrappable& backing_list = ToWrappableOrDie(isolate, v8_target); + + if (v8_property->IsString()) { + v8::Local v8_index; +@@ -300,8 +327,15 @@ class ObservableArrayExoticObjectHandler { + static void TrapOwnKeys(const v8::FunctionCallbackInfo& info) { + v8::Isolate* isolate = info.GetIsolate(); + v8::Local current_context = isolate->GetCurrentContext(); ++ if (!info[0]->IsArray()) { ++ ExceptionState exception_state( ++ isolate, ExceptionContext::Context::kOperationInvoke, ++ BackingListWrappable::ObservableArrayNameInIDL(), "ownKeys"); ++ exception_state.ThrowTypeError("Invalid argument."); ++ return; ++ } + v8::Local v8_target = info[0].As(); +- BackingListWrappable& backing_list = ToWrappableUnsafe(isolate, v8_target); ++ BackingListWrappable& backing_list = ToWrappableOrDie(isolate, v8_target); + + // 2. Let length be handler.[[BackingList]]'s size. + // 3. Let keys be an empty list. +@@ -357,17 +391,24 @@ class ObservableArrayExoticObjectHandler { + static void TrapSet(const v8::FunctionCallbackInfo& info) { + v8::Isolate* isolate = info.GetIsolate(); + v8::Local current_context = isolate->GetCurrentContext(); ++ if (!(info[0]->IsArray() && info[1]->IsName())) { ++ ExceptionState exception_state( ++ isolate, ExceptionContext::Context::kOperationInvoke, ++ BackingListWrappable::ObservableArrayNameInIDL(), "set"); ++ exception_state.ThrowTypeError("Invalid argument."); ++ return; ++ } + v8::Local v8_target = info[0].As(); +- v8::Local v8_property = info[1]; ++ v8::Local v8_property = info[1].As(); + v8::Local v8_value = info[2]; +- BackingListWrappable& backing_list = ToWrappableUnsafe(isolate, v8_target); ++ BackingListWrappable& backing_list = ToWrappableOrDie(isolate, v8_target); + + if (v8_property->IsString()) { + v8::Local v8_index; + if (v8_property->ToArrayIndex(current_context).ToLocal(&v8_index)) { + ExceptionState exception_state( + isolate, ExceptionContext::Context::kIndexedPropertySet, +- backing_list.ObservableArrayNameInIDL()); ++ BackingListWrappable::ObservableArrayNameInIDL()); + uint32_t index = v8_index->Value(); + bool result = + DoSetTheIndexedValue(isolate, current_context, backing_list, index, +@@ -380,7 +421,7 @@ class ObservableArrayExoticObjectHandler { + V8AtomicString(isolate, "length"))) { + ExceptionState exception_state( + isolate, ExceptionContext::Context::kAttributeSet, +- backing_list.ObservableArrayNameInIDL(), "length"); ++ BackingListWrappable::ObservableArrayNameInIDL(), "length"); + bool result = DoSetTheLength(isolate, current_context, backing_list, + v8_value, exception_state); + V8SetReturnValue(info, result); +@@ -431,11 +472,11 @@ class ObservableArrayExoticObjectHandler { + } + + private: +- static BackingListWrappable& ToWrappableUnsafe(v8::Isolate* isolate, +- v8::Local target) { ++ static BackingListWrappable& ToWrappableOrDie(v8::Isolate* isolate, ++ v8::Local target) { + bindings::ObservableArrayBase* base = + bindings::ObservableArrayExoticObjectImpl:: +- ProxyTargetToObservableArrayBase(isolate, target); ++ ProxyTargetToObservableArrayBaseOrDie(isolate, target); + return *static_cast(base); + } + +diff --git a/src/third_party/blink/renderer/bindings/core/v8/observable_array_exotic_object_impl.cc b/src/third_party/blink/renderer/bindings/core/v8/observable_array_exotic_object_impl.cc +index 8672414aba4..88c2adf501a +--- a/src/third_party/blink/renderer/bindings/core/v8/observable_array_exotic_object_impl.cc ++++ b/src/third_party/blink/renderer/bindings/core/v8/observable_array_exotic_object_impl.cc +@@ -42,7 +42,7 @@ const WrapperTypeInfo& ObservableArrayExoticObjectImpl::wrapper_type_info_ = + + // static + bindings::ObservableArrayBase* +-ObservableArrayExoticObjectImpl::ProxyTargetToObservableArrayBase( ++ObservableArrayExoticObjectImpl::ProxyTargetToObservableArrayBaseOrDie( + v8::Isolate* isolate, + v8::Local v8_proxy_target) { + // See the implementation comment in ObservableArrayExoticObjectImpl::Wrap. +@@ -50,6 +50,8 @@ ObservableArrayExoticObjectImpl::ProxyTargetToObservableArrayBase( + V8PrivateProperty::GetSymbol(isolate, kV8ProxyTargetToV8WrapperKey); + v8::Local backing_list_wrapper = + private_property.GetOrUndefined(v8_proxy_target).ToLocalChecked(); ++ // Crash when author script managed to pass something else other than the ++ // right proxy target object. + CHECK(backing_list_wrapper->IsObject()); + return ToScriptWrappable(backing_list_wrapper.As()) + ->ToImpl(); +diff --git a/src/third_party/blink/renderer/bindings/core/v8/observable_array_exotic_object_impl.h b/src/third_party/blink/renderer/bindings/core/v8/observable_array_exotic_object_impl.h +index 4d262a4981c..8c56428c40e +--- a/src/third_party/blink/renderer/bindings/core/v8/observable_array_exotic_object_impl.h ++++ b/src/third_party/blink/renderer/bindings/core/v8/observable_array_exotic_object_impl.h +@@ -22,7 +22,7 @@ class CORE_EXPORT ObservableArrayExoticObjectImpl final + public: + // Returns the backing list object extracted from the proxy target object + // of type JS Array. +- static bindings::ObservableArrayBase* ProxyTargetToObservableArrayBase( ++ static bindings::ObservableArrayBase* ProxyTargetToObservableArrayBaseOrDie( + v8::Isolate* isolate, + v8::Local v8_proxy_target); + +diff --git a/src/third_party/blink/renderer/core/css/cssom/style_property_map.cc b/src/third_party/blink/renderer/core/css/cssom/style_property_map.cc +index 1163c1580af..b05b561e3a3 +--- a/src/third_party/blink/renderer/core/css/cssom/style_property_map.cc ++++ b/src/third_party/blink/renderer/core/css/cssom/style_property_map.cc +@@ -376,6 +376,17 @@ void StylePropertyMap::append( + + CSSValueList* current_value = nullptr; + if (const CSSValue* css_value = GetProperty(property_id)) { ++ if (!css_value->IsValueList()) { ++ // The standard doesn't seem to cover this explicitly ++ // (https://github.com/w3c/css-houdini-drafts/issues/823), ++ // but the only really reasonable solution seems to be ++ // to throw a TypeError. ++ // ++ // This covers e.g. system-wide CSS keywords, like inherit. ++ exception_state.ThrowTypeError( ++ "Cannot append to something that is not a list"); ++ return; ++ } + current_value = To(css_value)->Copy(); + } else { + current_value = CssValueListForPropertyID(property_id); +diff --git a/src/third_party/blink/renderer/core/dom/events/event_dispatcher.cc b/src/third_party/blink/renderer/core/dom/events/event_dispatcher.cc +index 0e3aab7a26a..f7ce838a77e +--- a/src/third_party/blink/renderer/core/dom/events/event_dispatcher.cc ++++ b/src/third_party/blink/renderer/core/dom/events/event_dispatcher.cc +@@ -359,13 +359,8 @@ inline void EventDispatcher::DispatchEventPostProcess( + // Call default event handlers. While the DOM does have a concept of + // preventing default handling, the detail of which handlers are called is an + // internal implementation detail and not part of the DOM. +-#if BUILDFLAG(IS_OHOS) +- if ((event_->type() == event_type_names::kClick || !event_->defaultPrevented()) +- && !event_->DefaultHandled() && is_trusted_or_click) { +-#elif + if (!event_->defaultPrevented() && !event_->DefaultHandled() && + is_trusted_or_click) { +-#endif + // Non-bubbling events call only one default event handler, the one for the + // target. + node_->DefaultEventHandler(*event_); +diff --git a/src/third_party/blink/renderer/core/editing/selection_controller.cc b/src/third_party/blink/renderer/core/editing/selection_controller.cc +index a9ad2a17a31..60108b3ba4f +--- a/src/third_party/blink/renderer/core/editing/selection_controller.cc ++++ b/src/third_party/blink/renderer/core/editing/selection_controller.cc +@@ -62,6 +62,10 @@ + #include "third_party/blink/renderer/core/paint/paint_layer.h" + #include "ui/gfx/geometry/point_conversions.h" + ++#if BUILDFLAG(IS_OHOS) ++#include "third_party/blink/renderer/core/input/context_menu_allowed_scope.h" ++#endif ++ + namespace blink { + + SelectionController::SelectionController(LocalFrame& frame) +@@ -75,6 +79,9 @@ SelectionController::SelectionController(LocalFrame& frame) + void SelectionController::Trace(Visitor* visitor) const { + visitor->Trace(frame_); + visitor->Trace(original_base_in_flat_tree_); ++#if defined(OHOS_NWEB_EX) ++ visitor->Trace(last_long_press_hit_test_result_); ++#endif + ExecutionContextLifecycleObserver::Trace(visitor); + } + +@@ -1350,4 +1357,96 @@ bool IsExtendingSelection(const MouseEventWithHitTestResults& event) { + template void SelectionController::UpdateSelectionForContextMenuEvent< + MouseEvent>(const MouseEvent*, const HitTestResult&, const PhysicalOffset&); + ++#if BUILDFLAG(IS_OHOS) ++void SelectionController::SetLastLongPressHitTestResult( ++ const HitTestResult& other) { ++ last_long_press_hit_test_result_ = HitTestResult(other); ++} ++ ++void SelectionController::NotifyContextMenuWillShow() { ++ if (frame_) { ++ frame_->NotifyContextMenuWillShow(); ++ } ++} ++ ++void SelectionController::FocusDocumentView() { ++ Page* page = frame_->GetPage(); ++ if (!page) ++ return; ++ page->GetFocusController().FocusDocumentView(frame_); ++} ++ ++bool SelectionController::ShowSelectionByLastLongPressHitTestResult() { ++#if defined(OHOS_NWEB_EX) ++ if (!Selection().IsAvailable()) ++ return false; ++ ++ if (last_long_press_hit_test_result_.IsLiveLink() && ++ SelectClosestWordFromLiveLink(last_long_press_hit_test_result_)) { ++ ContextMenuAllowedScope scope; ++ frame_->GetEventHandler().ShowNonLocatedContextMenu( ++ last_long_press_hit_test_result_.InnerElement(), ++ kMenuSourceSelectAndCopy); ++ return true; ++ } ++ Node* inner_node = last_long_press_hit_test_result_.InnerNode(); ++ if (!inner_node || !inner_node->GetLayoutObject()) { ++ return false; ++ } ++ inner_node->GetDocument().UpdateStyleAndLayoutTree(); ++ ++ const bool did_select = SelectClosestWordFromHitTestResult( ++ last_long_press_hit_test_result_, AppendTrailingWhitespace::kDontAppend, ++ SelectInputEventType::kTouch); ++ if (did_select) { ++ ContextMenuAllowedScope scope; ++ frame_->GetEventHandler().ShowNonLocatedContextMenu( ++ nullptr, kMenuSourceSelectAndCopy); ++ return true; ++ } ++ ++ if (!inner_node->isConnected() || !inner_node->GetLayoutObject()) { ++ return false; ++ } ++ SetCaretAtHitTestResult(last_long_press_hit_test_result_); ++#endif ++ return true; ++} ++ ++bool SelectionController::SelectClosestWordFromLiveLink( ++ const HitTestResult& result) { ++ Node* const inner_node = result.InnerNode(); ++ ++ if (!inner_node || !inner_node->GetLayoutObject()) ++ return false; ++ inner_node->GetDocument().UpdateStyleAndLayoutTree(); ++ ++ Element* url_element = result.URLElement(); ++ const PositionInFlatTreeWithAffinity pos = ++ CreateVisiblePosition(PositionWithAffinityOfHitTestResult(result)) ++ .ToPositionWithAffinity(); ++ bool isCreateFlatTreeByUrlElement = ++ pos.IsNotNull() && pos.AnchorNode()->IsDescendantOf(url_element); ++ bool isCreateFlatTreeByAnchorNode = ++ isCreateFlatTreeByUrlElement && pos.AnchorNode()->IsTextNode(); ++ ++ const SelectionInFlatTree& new_selection = ++ isCreateFlatTreeByAnchorNode ++ ? SelectionInFlatTree::Builder() ++ .SelectAllChildren(*pos.AnchorNode()) ++ .Build() ++ : isCreateFlatTreeByUrlElement ? SelectionInFlatTree::Builder() ++ .SelectAllChildren(*url_element) ++ .Build() ++ : SelectionInFlatTree(); ++ ++ return UpdateSelectionForMouseDownDispatchingSelectStart( ++ inner_node, ++ ExpandSelectionToRespectUserSelectAll(inner_node, new_selection), ++ SetSelectionOptions::Builder() ++ .SetGranularity(TextGranularity::kWord) ++ .SetShouldShowHandle(true) ++ .Build()); ++} ++#endif + } // namespace blink +diff --git a/src/third_party/blink/renderer/core/editing/selection_controller.h b/src/third_party/blink/renderer/core/editing/selection_controller.h +index 4988fbd13de..8daf330dd37 +--- a/src/third_party/blink/renderer/core/editing/selection_controller.h ++++ b/src/third_party/blink/renderer/core/editing/selection_controller.h +@@ -82,6 +82,17 @@ class CORE_EXPORT SelectionController final + return selection_state_ == SelectionState::kExtendedSelection; + } + ++#if BUILDFLAG(IS_OHOS) ++ void FocusDocumentView(); ++ bool ShowSelectionByLastLongPressHitTestResult(); ++ void SetLastLongPressHitTestResult(const HitTestResult&); ++ bool SelectClosestWordFromLiveLink(const HitTestResult& result); ++ const HitTestResult& GetHitTestResult() const { ++ return last_long_press_hit_test_result_; ++ } ++ void NotifyContextMenuWillShow(); ++#endif ++ + private: + friend class SelectionControllerTest; + +@@ -147,6 +158,9 @@ class CORE_EXPORT SelectionController final + kExtendedSelection + }; + SelectionState selection_state_; ++#if BUILDFLAG(IS_OHOS) ++ HitTestResult last_long_press_hit_test_result_; ++#endif + }; + + bool IsSelectionOverLink(const MouseEventWithHitTestResults&); +diff --git a/src/third_party/blink/renderer/core/exported/web_settings_impl.cc b/src/third_party/blink/renderer/core/exported/web_settings_impl.cc +index e690b6db1f0..d0a013558ed +--- a/src/third_party/blink/renderer/core/exported/web_settings_impl.cc ++++ b/src/third_party/blink/renderer/core/exported/web_settings_impl.cc +@@ -471,6 +471,18 @@ void WebSettingsImpl::SetVerticalHideScrollbars(bool enabled) { + void WebSettingsImpl::SetHorizontalHideScrollbars(bool enabled) { + settings_->SetHorizontalHideScrollbars(enabled); + } ++ ++void WebSettingsImpl::SetContextMenuCustomization(bool enabled) { ++ settings_->SetContextMenuCustomization(enabled); ++} ++ ++void WebSettingsImpl::SetScrollBarColor(uint32_t value) { ++ settings_->SetScrollBarColor(value); ++} ++ ++void WebSettingsImpl::EnableBlankTargetPopupIntercept(bool enabled) { ++ settings_->EnableBlankTargetPopupIntercept(enabled); ++} + #endif + + void WebSettingsImpl::SetMockGestureTapHighlightsEnabled(bool enabled) { +diff --git a/src/third_party/blink/renderer/core/exported/web_settings_impl.h b/src/third_party/blink/renderer/core/exported/web_settings_impl.h +index 30018f7be03..853ca4d0476 +--- a/src/third_party/blink/renderer/core/exported/web_settings_impl.h ++++ b/src/third_party/blink/renderer/core/exported/web_settings_impl.h +@@ -125,6 +125,9 @@ class CORE_EXPORT WebSettingsImpl final : public WebSettings { + #if BUILDFLAG(IS_OHOS) + void SetVerticalHideScrollbars(bool) override; + void SetHorizontalHideScrollbars(bool) override; ++ void SetContextMenuCustomization(bool) override; ++ void SetScrollBarColor(uint32_t) override; ++ void EnableBlankTargetPopupIntercept(bool) override; + #endif + void SetPasswordEchoDurationInSeconds(double) override; + void SetPasswordEchoEnabled(bool) override; +diff --git a/src/third_party/blink/renderer/core/exported/web_view_impl.cc b/src/third_party/blink/renderer/core/exported/web_view_impl.cc +index b4a7a145ddd..ac6d2863833 +--- a/src/third_party/blink/renderer/core/exported/web_view_impl.cc ++++ b/src/third_party/blink/renderer/core/exported/web_view_impl.cc +@@ -1485,6 +1485,9 @@ void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs, + #if BUILDFLAG(IS_OHOS) + settings->SetVerticalHideScrollbars(prefs.hide_vertical_scrollbars); + settings->SetHorizontalHideScrollbars(prefs.hide_horizontal_scrollbars); ++ settings->SetContextMenuCustomization( ++ prefs.contextmenu_customization_enabled); ++ settings->SetScrollBarColor(prefs.scrollbar_color); + #endif + + // Enable gpu-accelerated 2d canvas if requested on the command line. +@@ -1604,12 +1607,29 @@ void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs, + + // Needs to happen before SetDefaultPageScaleLimits below since that'll + // recalculate the final page scale limits and that depends on this setting. ++#if BUILDFLAG(IS_OHOS) ++ auto display_manager_adapter = ++ OHOS::NWeb::OhosAdapterHelper::GetInstance().CreateDisplayMgrAdapter(); ++ bool is_pc_device = ++ display_manager_adapter && (!display_manager_adapter->IsDefaultPortrait()); ++ if (is_pc_device) { ++ settings->SetShrinksViewportContentToFit(false); ++ // Needs to happen before SetIgnoreViewportTagScaleLimits below. ++ web_view->SetDefaultPageScaleLimits(1.f, 4.f); ++ } else { ++ settings->SetShrinksViewportContentToFit( ++ prefs.shrinks_viewport_contents_to_fit); ++ // Needs to happen before SetIgnoreViewportTagScaleLimits below. ++ web_view->SetDefaultPageScaleLimits(prefs.default_minimum_page_scale_factor, ++ prefs.default_maximum_page_scale_factor); ++ } ++#else + settings->SetShrinksViewportContentToFit( + prefs.shrinks_viewport_contents_to_fit); +- + // Needs to happen before SetIgnoreViewportTagScaleLimits below. + web_view->SetDefaultPageScaleLimits(prefs.default_minimum_page_scale_factor, + prefs.default_maximum_page_scale_factor); ++#endif + + settings->SetFullscreenSupported(prefs.fullscreen_supported); + settings->SetTextAutosizingEnabled(prefs.text_autosizing_enabled); +@@ -1653,6 +1673,8 @@ void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs, + prefs.reuse_global_for_unowned_main_frame); + settings->SetPreferHiddenVolumeControls(true); + settings->SetSpellCheckEnabledByDefault(prefs.spellcheck_enabled_by_default); ++ settings->EnableBlankTargetPopupIntercept( ++ prefs.blank_target_popup_intercept_enabled); + + RuntimeEnabledFeatures::SetVideoFullscreenOrientationLockEnabled( + prefs.video_fullscreen_orientation_lock_enabled); +@@ -1675,8 +1697,19 @@ void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs, + settings->SetAccessibilityAlwaysShowFocus(prefs.always_show_focus); + settings->SetAutoplayPolicy(prefs.autoplay_policy); + settings->SetViewportEnabled(prefs.viewport_enabled); ++ ++#if BUILDFLAG(IS_OHOS) ++ if (is_pc_device) { ++ settings->SetViewportMetaEnabled(false); ++ settings->SetViewportStyle(mojom::ViewportStyle::kDefault); ++ } else { ++ settings->SetViewportMetaEnabled(prefs.viewport_meta_enabled); ++ settings->SetViewportStyle(prefs.viewport_style); ++ } ++#else + settings->SetViewportMetaEnabled(prefs.viewport_meta_enabled); + settings->SetViewportStyle(prefs.viewport_style); ++#endif + + settings->SetLoadWithOverviewMode(prefs.initialize_at_minimum_page_scale); + settings->SetMainFrameResizesAreOrientationChanges( +diff --git a/src/third_party/blink/renderer/core/frame/local_frame.cc b/src/third_party/blink/renderer/core/frame/local_frame.cc +index 897202c75cb..c2c9db3b599 +--- a/src/third_party/blink/renderer/core/frame/local_frame.cc ++++ b/src/third_party/blink/renderer/core/frame/local_frame.cc +@@ -1020,6 +1020,11 @@ void LocalFrame::DidFocus() { + GetLocalFrameHostRemote().DidFocusFrame(); + } + ++#if BUILDFLAG(IS_OHOS) ++void LocalFrame::NotifyContextMenuWillShow() { ++ GetLocalFrameHostRemote().NotifyContextMenuWillShow(); ++} ++#endif + void LocalFrame::DidChangeThemeColor(bool update_theme_color_cache) { + if (Tree().Parent()) + return; +diff --git a/src/third_party/blink/renderer/core/frame/local_frame.h b/src/third_party/blink/renderer/core/frame/local_frame.h +index 588ef788f72..66a5c24ee22 +--- a/src/third_party/blink/renderer/core/frame/local_frame.h ++++ b/src/third_party/blink/renderer/core/frame/local_frame.h +@@ -223,6 +223,9 @@ class CORE_EXPORT LocalFrame final + void DidChangeThemeColor(bool update_theme_color_cache); + void DidChangeBackgroundColor(SkColor background_color, bool color_adjust); + ++#if BUILDFLAG(IS_OHOS) ++ void NotifyContextMenuWillShow(); ++#endif + // Returns false if detaching child frames reentrantly detached `this`. + bool DetachChildren(); + // After Document is attached, resets state related to document, and sets +diff --git a/src/third_party/blink/renderer/core/frame/local_frame_mojo_handler.cc b/src/third_party/blink/renderer/core/frame/local_frame_mojo_handler.cc +index 1dad20b8b5f..8494eed6140 +--- a/src/third_party/blink/renderer/core/frame/local_frame_mojo_handler.cc ++++ b/src/third_party/blink/renderer/core/frame/local_frame_mojo_handler.cc +@@ -202,9 +202,11 @@ v8::MaybeLocal CallMethodOnFrame(LocalFrame* local_frame, + v8::Local object; + v8::Local method; + if (!GetProperty(context, context->Global(), object_name).ToLocal(&object) || +- !GetProperty(context, object, method_name).ToLocal(&method)) { ++ !GetProperty(context, object, method_name).ToLocal(&method) || ++ !method->IsFunction()) { + return v8::MaybeLocal(); + } ++ CHECK(method->IsFunction()); + + return local_frame->DomWindow() + ->GetScriptController() +diff --git a/src/third_party/blink/renderer/core/frame/settings.h b/src/third_party/blink/renderer/core/frame/settings.h +index f2739a6a9e7..1472406af9c +--- a/src/third_party/blink/renderer/core/frame/settings.h ++++ b/src/third_party/blink/renderer/core/frame/settings.h +@@ -80,6 +80,30 @@ class CORE_EXPORT Settings { + bool GetHorizontalHideScrollbars() { + return hide_horizontal_scrollbars_; + } ++ ++ void SetContextMenuCustomization(bool contextmenu_customization_enabled) { ++ contextmenu_customization_enabled_ = contextmenu_customization_enabled; ++ } ++ ++ bool IsContextMenuCustomizationEnabled() { ++ return contextmenu_customization_enabled_; ++ } ++ ++ void SetScrollBarColor(uint32_t colorValue) { ++ scrollbar_color_ = colorValue; ++ } ++ ++ uint32_t GetScrollBarColor() { ++ return scrollbar_color_; ++ } ++ ++ void EnableBlankTargetPopupIntercept(bool enabled) { ++ blank_target_popup_intercept_enabled_ = enabled; ++ } ++ ++ bool IsBlankTargetPopupInterceptEnabled() const { ++ return blank_target_popup_intercept_enabled_; ++ } + #endif + + void SetDelegate(SettingsDelegate*); +@@ -96,6 +120,9 @@ class CORE_EXPORT Settings { + #if BUILDFLAG(IS_OHOS) + bool hide_vertical_scrollbars_ = true; + bool hide_horizontal_scrollbars_ = true; ++ bool contextmenu_customization_enabled_ = false; ++ uint32_t scrollbar_color_ = 0; ++ bool blank_target_popup_intercept_enabled_ = true; + #endif + }; + +diff --git a/src/third_party/blink/renderer/core/frame/visual_viewport.cc b/src/third_party/blink/renderer/core/frame/visual_viewport.cc +index cef756a8434..6da2ddbfe86 +--- a/src/third_party/blink/renderer/core/frame/visual_viewport.cc ++++ b/src/third_party/blink/renderer/core/frame/visual_viewport.cc +@@ -701,8 +701,10 @@ void VisualViewport::UpdateScrollbarLayer(ScrollbarOrientation orientation) { + cc_orientation, thumb_thickness, scrollbar_margin, + /*is_left_side_vertical_scrollbar*/ false); + scrollbar_layer->SetElementId(GetScrollbarElementId(orientation)); ++ #if !BUILDFLAG(IS_OHOS) + scrollbar_layer->SetScrollElementId(scroll_layer_->element_id()); + scrollbar_layer->SetIsDrawable(true); ++ #endif + } + + scrollbar_layer->SetBounds( +diff --git a/src/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc b/src/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc +index a3f26374f7c..2c989fb92b1 +--- a/src/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc ++++ b/src/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc +@@ -1058,6 +1058,7 @@ void WebFrameWidgetImpl::CancelDrag() { + if (!doing_drag_and_drop_) + return; + GetPage()->GetDragController().DragEnded(); ++ current_drag_data_ = nullptr; + doing_drag_and_drop_ = false; + } + +@@ -3028,11 +3029,18 @@ void WebFrameWidgetImpl::AddEditCommandForNextKeyEvent(const WebString& name, + } + + bool WebFrameWidgetImpl::HandleCurrentKeyboardEvent() { +- bool did_execute_command = false; ++ if (edit_commands_.IsEmpty()) { ++ return false; ++ } + WebLocalFrame* frame = FocusedWebLocalFrameInWidget(); + if (!frame) + frame = local_root_; +- for (const auto& command : edit_commands_) { ++ bool did_execute_command = false; ++ // Executing an edit command can run JS and we can end up reassigning ++ // `edit_commands_` so move it to a stack variable before iterating on it. ++ Vector edit_commands = ++ std::move(edit_commands_); ++ for (const auto& command : edit_commands) { + // In gtk and cocoa, it's possible to bind multiple edit commands to one + // key (but it's the exception). Once one edit command is not executed, it + // seems safest to not execute the rest. +@@ -4396,4 +4404,20 @@ void WebFrameWidgetImpl::NotifyZoomLevelChanged(LocalFrame* root) { + } + } + ++#if BUILDFLAG(IS_OHOS) ++void WebFrameWidgetImpl::SelectAndCopy() { ++ WebLocalFrame* local_frame = FocusedWebLocalFrameInWidget(); ++ if (!local_frame) ++ return; ++ local_frame->SelectClosetWordAndShowSelectionMenu(); ++} ++ ++void WebFrameWidgetImpl::SetZoomLevel(float magnify_delta, const gfx::Point& anchor) { ++ if (!widget_base_) { ++ return; ++ } ++ widget_base_->SetZoomLevel(magnify_delta, anchor); ++} ++#endif ++ + } // namespace blink +diff --git a/src/third_party/blink/renderer/core/frame/web_frame_widget_impl.h b/src/third_party/blink/renderer/core/frame/web_frame_widget_impl.h +index a3b37a55418..538eec58668 +--- a/src/third_party/blink/renderer/core/frame/web_frame_widget_impl.h ++++ b/src/third_party/blink/renderer/core/frame/web_frame_widget_impl.h +@@ -786,6 +786,10 @@ class CORE_EXPORT WebFrameWidgetImpl + SelectAroundCaretCallback callback) override; + #endif + ++#if BUILDFLAG(IS_OHOS) ++ void SelectAndCopy() override; ++ void SetZoomLevel(float magnify_delta, const gfx::Point& anchor) override; ++#endif + // PageWidgetEventHandler overrides: + WebInputEventResult HandleKeyEvent(const WebKeyboardEvent&) override; + void HandleMouseDown(LocalFrame&, const WebMouseEvent&) override; +diff --git a/src/third_party/blink/renderer/core/frame/web_local_frame_impl.cc b/src/third_party/blink/renderer/core/frame/web_local_frame_impl.cc +index 4b3d2914a1e..9d090d05b0f +--- a/src/third_party/blink/renderer/core/frame/web_local_frame_impl.cc ++++ b/src/third_party/blink/renderer/core/frame/web_local_frame_impl.cc +@@ -268,6 +268,8 @@ + #include "third_party/blink/renderer/core/layout/layout_font_accessor_win.h" + #endif + ++#include "third_party/blink/renderer/core/editing/selection_controller.h" ++ + namespace blink { + + namespace { +@@ -2899,4 +2901,17 @@ void WebLocalFrameImpl::ResetHasScrolledFocusedEditableIntoView() { + has_scrolled_focused_editable_node_into_rect_ = false; + } + ++#if BUILDFLAG(IS_OHOS) ++void WebLocalFrameImpl::SelectClosetWordAndShowSelectionMenu() { ++ if (!ViewImpl() || !ViewImpl()->GetPage()) ++ return; ++ ++ SelectionController& selection_controller = ++ GetFrame()->GetEventHandler().GetSelectionController(); ++ if (selection_controller.ShowSelectionByLastLongPressHitTestResult()) { ++ selection_controller.FocusDocumentView(); ++ } ++} ++#endif ++ + } // namespace blink +diff --git a/src/third_party/blink/renderer/core/frame/web_local_frame_impl.h b/src/third_party/blink/renderer/core/frame/web_local_frame_impl.h +index 2264b684a95..e8a8011eb56 +--- a/src/third_party/blink/renderer/core/frame/web_local_frame_impl.h ++++ b/src/third_party/blink/renderer/core/frame/web_local_frame_impl.h +@@ -519,6 +519,9 @@ class CORE_EXPORT WebLocalFrameImpl final + + void AddInspectorIssueImpl(mojom::blink::InspectorIssueCode code) override; + ++#if BUILDFLAG(IS_OHOS) ++ void SelectClosetWordAndShowSelectionMenu() override; ++#endif + private: + friend LocalFrameClientImpl; + +diff --git a/src/third_party/blink/renderer/core/html/html_anchor_element.cc b/src/third_party/blink/renderer/core/html/html_anchor_element.cc +index 1c39125d531..023dc9cdb32 +--- a/src/third_party/blink/renderer/core/html/html_anchor_element.cc ++++ b/src/third_party/blink/renderer/core/html/html_anchor_element.cc +@@ -65,6 +65,11 @@ + #include "third_party/blink/renderer/platform/weborigin/security_policy.h" + #include "ui/gfx/geometry/point_conversions.h" + ++#if BUILDFLAG(IS_OHOS) ++#include "base/command_line.h" ++#include "content/public/common/content_switches.h" ++#endif ++ + namespace blink { + + namespace { +@@ -411,6 +416,34 @@ void HTMLAnchorElement::SendPings(const KURL& destination_url) const { + } + } + ++#if BUILDFLAG(IS_OHOS) ++bool ShouldFixedTargetToTop(LocalFrame* frame) { ++ bool should_fixed_target_to_top = false; ++ if (!frame) ++ return should_fixed_target_to_top; ++ ++ if (frame->GetSettings() && ++ !frame->GetSettings()->IsBlankTargetPopupInterceptEnabled()) { ++ return false; ++ } ++ ++ if (frame->IsMainFrame()) { ++ should_fixed_target_to_top = true; ++ } else if (!frame->DomWindow()->IsSandboxed( ++ network::mojom::blink::WebSandboxFlags::kTopNavigation) || ++ !frame->DomWindow()->IsSandboxed( ++ network::mojom::blink::WebSandboxFlags:: ++ kTopNavigationByUserActivation)) { ++ LOG(INFO) << "ShouldFixedTargetToTop: the frame is not MainFrame. " ++ "The flag of 'allow-top-navigation' or " ++ "'allow-top-navigation-by-user-activation' is set."; ++ should_fixed_target_to_top = true; ++ } ++ ++ return should_fixed_target_to_top; ++} ++#endif ++ + void HTMLAnchorElement::HandleClick(Event& event) { + event.SetDefaultHandled(); + +@@ -516,6 +549,19 @@ void HTMLAnchorElement::HandleClick(Event& event) { + : mojom::blink::TriggeringEventInfo::kFromUntrustedEvent); + frame_request.SetInputStartTime(event.PlatformTimeStamp()); + ++#if BUILDFLAG(IS_OHOS) ++ AtomicString fixed_target; ++ if ((*base::CommandLine::ForCurrentProcess()) ++ .HasSwitch(switches::kForBrowser)) { ++ if (!frame->Tree().FindFrameByName(target)) { ++ if (ShouldFixedTargetToTop(frame)) { ++ LOG(WARNING) ++ << "HTMLAnchorElement::HandleClick has fixed target frame to _top"; ++ fixed_target = "_top"; ++ } ++ } ++ } ++#endif + frame->MaybeLogAdClickNavigation(); + + if (request.HasUserGesture() && HasImpression()) { +@@ -533,8 +579,17 @@ void HTMLAnchorElement::HandleClick(Event& event) { + frame_request.SetImpression(*impression); + } + ++#if BUILDFLAG(IS_OHOS) ++ if ((*base::CommandLine::ForCurrentProcess()) ++ .HasSwitch(switches::kForBrowser)) { ++ fixed_target = fixed_target.IsEmpty() ? target : fixed_target; ++ } else { ++ fixed_target = target; ++ } ++#endif ++ + Frame* target_frame = +- frame->Tree().FindOrCreateFrameForNavigation(frame_request, target).frame; ++ frame->Tree().FindOrCreateFrameForNavigation(frame_request, fixed_target).frame; + + // If hrefTranslate is enabled and set restrict processing it + // to same frame or navigations with noopener set. +diff --git a/src/third_party/blink/renderer/core/input/event_handler.cc b/src/third_party/blink/renderer/core/input/event_handler.cc +index 5196647f260..2fe4004bcc2 +--- a/src/third_party/blink/renderer/core/input/event_handler.cc ++++ b/src/third_party/blink/renderer/core/input/event_handler.cc +@@ -2058,6 +2058,15 @@ WebInputEventResult EventHandler::SendContextMenuEvent( + PhysicalOffset position_in_contents(v->ConvertFromRootFrame( + gfx::ToFlooredPoint(event.PositionInRootFrame()))); + HitTestRequest request(HitTestRequest::kActive); ++#if defined(OHOS_NWEB_EX) ++ int hit_test_flag = 0; ++ if (event.menu_source_type == kMenuSourceSelectAndCopy) { ++ hit_test_flag |= HitTestRequest::kReadOnly; ++ } else { ++ hit_test_flag |= HitTestRequest::kActive; ++ } ++ request = hit_test_flag; ++#endif + MouseEventWithHitTestResults mev = + frame_->GetDocument()->PerformMouseEventHitTest( + request, position_in_contents, event); +@@ -2181,6 +2190,15 @@ WebInputEventResult EventHandler::ShowNonLocatedContextMenu( + + // Use the focused node as the target for hover and active. + HitTestRequest request(HitTestRequest::kActive); ++#if defined(OHOS_NWEB_EX) ++ HitTestRequest::HitTestRequestType hit_test_request_type = 0; ++ if (source_type == kMenuSourceSelectAndCopy) { ++ hit_test_request_type |= HitTestRequest::kReadOnly; ++ } else { ++ hit_test_request_type |= HitTestRequest::kActive; ++ } ++ request = hit_test_request_type; ++#endif + HitTestLocation location(location_in_root_frame); + HitTestResult result(request, location); + result.SetInnerNode(focused_element ? static_cast(focused_element) +diff --git a/src/third_party/blink/renderer/core/input/gesture_manager.cc b/src/third_party/blink/renderer/core/input/gesture_manager.cc +index 5fd3e00d478..9436d2cbe3d +--- a/src/third_party/blink/renderer/core/input/gesture_manager.cc ++++ b/src/third_party/blink/renderer/core/input/gesture_manager.cc +@@ -400,10 +400,37 @@ WebInputEventResult GestureManager::HandleGestureLongPress( + } + + Node* inner_node = hit_test_result.InnerNode(); ++#if defined(OHOS_NWEB_EX) ++ bool is_contextmenu_customization_enabled = false; ++ if (frame_->GetSettings()) { ++ is_contextmenu_customization_enabled = ++ frame_->GetSettings()->IsContextMenuCustomizationEnabled(); ++ } ++ if (is_contextmenu_customization_enabled) { ++ if (hit_test_result.IsContentEditable() || ++ (inner_node && inner_node->IsTextNode() && ++ !hit_test_result.IsLiveLink())) { ++ if (inner_node && inner_node->GetLayoutObject() && ++ selection_controller_->HandleGestureLongPress(hit_test_result)) { ++ mouse_event_manager_->FocusDocumentView(); ++ } ++ } ++ selection_controller_->SetLastLongPressHitTestResult(hit_test_result); ++ // notify webContentImpl reset showing_context_menu_ status, to make sure ++ // update contextMenu ++ selection_controller_->NotifyContextMenuWillShow(); ++ } else { ++ if (inner_node && inner_node->GetLayoutObject() && ++ selection_controller_->HandleGestureLongPress(hit_test_result)) { ++ mouse_event_manager_->FocusDocumentView(); ++ } ++ } ++#else + if (inner_node && inner_node->GetLayoutObject() && + selection_controller_->HandleGestureLongPress(hit_test_result)) { + mouse_event_manager_->FocusDocumentView(); + } ++#endif + + if (frame_->GetSettings() && + frame_->GetSettings()->GetShowContextMenuOnMouseUp()) { +diff --git a/src/third_party/blink/renderer/core/loader/form_submission.cc b/src/third_party/blink/renderer/core/loader/form_submission.cc +index 45c516d4ad9..93e85db5a63 +--- a/src/third_party/blink/renderer/core/loader/form_submission.cc ++++ b/src/third_party/blink/renderer/core/loader/form_submission.cc +@@ -53,6 +53,12 @@ + #include "third_party/blink/renderer/platform/wtf/text/string_builder.h" + #include "third_party/blink/renderer/platform/wtf/text/text_encoding.h" + ++#if BUILDFLAG(IS_OHOS) ++#include "base/command_line.h" ++#include "content/public/common/content_switches.h" ++#include "third_party/blink/renderer/core/frame/settings.h" ++#endif ++ + namespace blink { + + static int64_t GenerateFormDataIdentifier() { +@@ -323,6 +329,23 @@ FormSubmission* FormSubmission::Create(HTMLFormElement* form, + frame_request.SetClientRedirectReason(reason); + frame_request.SetForm(form); + frame_request.SetTriggeringEventInfo(triggering_event_info); ++#if BUILDFLAG(IS_OHOS) ++ if ((*base::CommandLine::ForCurrentProcess()) ++ .HasSwitch(switches::kForBrowser)) { ++ bool blank_target_popup_intercept_enabled = true; ++ Settings* settings = form->GetDocument().GetFrame()->GetSettings(); ++ if (settings) { ++ blank_target_popup_intercept_enabled = ++ settings->IsBlankTargetPopupInterceptEnabled(); ++ } ++ if (blank_target_popup_intercept_enabled && ++ !form->GetDocument().GetFrame()->Tree().FindFrameByName( ++ target_or_base_target)) { ++ LOG(WARNING) << "FormSubmission::Navigate has fixed target frame to _top"; ++ target_or_base_target = "_top"; ++ } ++ } ++#endif + Frame* target_frame = + form->GetDocument() + .GetFrame() +diff --git a/src/third_party/blink/renderer/core/loader/resource/resource_loader_code_cache_test.cc b/src/third_party/blink/renderer/core/loader/resource/resource_loader_code_cache_test.cc +index c83d867ba24..283a926b95b +--- a/src/third_party/blink/renderer/core/loader/resource/resource_loader_code_cache_test.cc ++++ b/src/third_party/blink/renderer/core/loader/resource/resource_loader_code_cache_test.cc +@@ -104,12 +104,10 @@ class ResourceLoaderCodeCacheTest : public testing::Test { + std::vector serialized_data(kSerializedDataSize); + *reinterpret_cast(&serialized_data[0]) = outer_type; + if (source_text.has_value()) { +- DigestValue hash; +- CHECK(ComputeDigest(kHashAlgorithmSha256, +- static_cast(source_text->Bytes()), +- source_text->CharactersSizeInBytes(), hash)); +- CHECK_EQ(hash.size(), kSha256Bytes); +- memcpy(&serialized_data[kCachedMetadataTypeSize], hash.data(), ++ std::unique_ptr hash = ++ ParkableStringImpl::HashString(source_text->Impl()); ++ CHECK_EQ(hash->size(), kSha256Bytes); ++ memcpy(&serialized_data[kCachedMetadataTypeSize], hash->data(), + kSha256Bytes); + } + *reinterpret_cast( +@@ -281,6 +279,7 @@ TEST_F(ResourceLoaderCodeCacheTest, WebUICodeCacheHashCheckSuccess) { + // Now the metadata can be accessed. + scoped_refptr cached_metadata = + resource_->CacheHandler()->GetCachedMetadata(0); ++ EXPECT_TRUE(cached_metadata.get()); + EXPECT_EQ(cached_metadata->size(), cache_data.size()); + EXPECT_EQ(*(cached_metadata->Data() + 2), cache_data[2]); + +diff --git a/src/third_party/blink/renderer/core/page/chrome_client_impl_test.cc b/src/third_party/blink/renderer/core/page/chrome_client_impl_test.cc +index 67c6245beb8..11d3687f7eb +--- a/src/third_party/blink/renderer/core/page/chrome_client_impl_test.cc ++++ b/src/third_party/blink/renderer/core/page/chrome_client_impl_test.cc +@@ -161,7 +161,14 @@ TEST_F(FormSubmissionTest, FormGetSubmissionNewFrameUrlTest) { + ASSERT_TRUE(form_elem); + + SubmitForm(*form_elem); +- EXPECT_EQ("foo=bar", chrome_client_->GetLastUrl().Query()); ++#if BUILDFLAG(IS_OHOS) ++ if ((*base::CommandLine::ForCurrentProcess()) ++ .HasSwitch(switches::kForBrowser)) { ++ EXPECT_TRUE(chrome_client_->GetLastUrl().IsEmpty()); ++ } else { ++ EXPECT_EQ("foo=bar", chrome_client_->GetLastUrl().Query()); ++ } ++#endif + } + + class FakeColorChooserClient : public GarbageCollected, +diff --git a/src/third_party/blink/renderer/core/page/context_menu_controller.cc b/src/third_party/blink/renderer/core/page/context_menu_controller.cc +index a9b3ea4a725..d3590b5e9fa +--- a/src/third_party/blink/renderer/core/page/context_menu_controller.cc ++++ b/src/third_party/blink/renderer/core/page/context_menu_controller.cc +@@ -478,7 +478,6 @@ bool ContextMenuController::ShowContextMenu(LocalFrame* frame, + ContextMenuData data; + data.mouse_position = selected_frame->View()->FrameToViewport( + result.RoundedPointInInnerNodeFrame()); +- + data.edit_flags = ComputeEditFlags( + *selected_frame->GetDocument(), + To(page_->GetFocusController().FocusedOrMainFrame()) +@@ -858,6 +857,23 @@ bool ContextMenuController::ShowContextMenu(LocalFrame* frame, + if (!selected_web_frame || !selected_web_frame->Client()) + return false; + ++#if defined(OHOS_NWEB_EX) ++ bool contextmenu_customization_enabled = ++ page_->GetSettings().IsContextMenuCustomizationEnabled(); ++ if (contextmenu_customization_enabled && ++ source_type == kMenuSourceSelectAndCopy && data.selected_text.empty() && ++ !selected_frame->SelectedText().IsEmpty()) { ++ data.selected_text = selected_frame->SelectedText().Utf8(); ++ } ++ ++ data.is_selectable = false; ++ if (contextmenu_customization_enabled && result.InnerNode() && ++ result.InnerNode()->GetLayoutObject() && ++ result.InnerNode()->GetLayoutObject()->IsSelectable()) { ++ data.is_selectable = true; ++ } ++#endif ++ + selected_web_frame->ShowContextMenu( + context_menu_client_receiver_.BindNewEndpointAndPassRemote( + selected_web_frame->GetTaskRunner(TaskType::kInternalDefault)), +diff --git a/src/third_party/blink/renderer/core/page/create_window.cc b/src/third_party/blink/renderer/core/page/create_window.cc +index fd7b4f0b3fc..63eb37633c1 +--- a/src/third_party/blink/renderer/core/page/create_window.cc ++++ b/src/third_party/blink/renderer/core/page/create_window.cc +@@ -379,13 +379,9 @@ Frame* CreateNewWindow(LocalFrame& opener_frame, + + gfx::Rect rect = page->GetChromeClient().CalculateWindowRectWithAdjustment( + window_rect, frame, opener_frame); +-#if BUILDFLAG(IS_OHOS) +- (void)rect; +-#else + page->GetChromeClient().Show(opener_frame.GetLocalFrameToken(), + request.GetNavigationPolicy(), rect, + consumed_user_gesture); +-#endif + MaybeLogWindowOpen(opener_frame); + return &frame; + } +diff --git a/src/third_party/blink/renderer/core/paint/paint_layer_scrollable_area.cc b/src/third_party/blink/renderer/core/paint/paint_layer_scrollable_area.cc +index 6c219b6b439..3444508aa08 +--- a/src/third_party/blink/renderer/core/paint/paint_layer_scrollable_area.cc ++++ b/src/third_party/blink/renderer/core/paint/paint_layer_scrollable_area.cc +@@ -2626,6 +2626,7 @@ void PaintLayerScrollableArea::UpdateNeedsCompositedScrolling( + } + + bool PaintLayerScrollableArea::VisualViewportSuppliesScrollbars() const { ++#if !BUILDFLAG(IS_OHOS) + LocalFrame* frame = GetLayoutBox()->GetFrame(); + if (!frame || !frame->GetSettings()) + return false; +@@ -2637,6 +2638,9 @@ bool PaintLayerScrollableArea::VisualViewportSuppliesScrollbars() const { + const TopDocumentRootScrollerController& controller = + GetLayoutBox()->GetDocument().GetPage()->GlobalRootScrollerController(); + return controller.RootScrollerArea() == this; ++ ++#endif ++ return false; + } + + bool PaintLayerScrollableArea::ScheduleAnimation() { +@@ -2728,6 +2732,11 @@ Scrollbar* PaintLayerScrollableArea::ScrollbarManager::CreateScrollbar( + scrollbar = MakeGarbageCollected(ScrollableArea(), orientation, + style_source_element); + } ++#if BUILDFLAG(IS_OHOS) ++ uint32_t colorValue = ScrollableArea()->GetLayoutBox()->GetFrame() ++ ->GetSettings()->GetScrollBarColor(); ++ ScrollableArea()->SetScrollbarColor(colorValue); ++#endif + ScrollableArea()->GetLayoutBox()->GetDocument().View()->AddScrollbar( + scrollbar); + return scrollbar; +diff --git a/src/third_party/blink/renderer/core/scroll/scrollable_area.cc b/src/third_party/blink/renderer/core/scroll/scrollable_area.cc +index 2b35b341a04..7107ac62e69 +--- a/src/third_party/blink/renderer/core/scroll/scrollable_area.cc ++++ b/src/third_party/blink/renderer/core/scroll/scrollable_area.cc +@@ -596,6 +596,14 @@ bool ScrollableArea::HasOverlayScrollbars() const { + return h_scrollbar && h_scrollbar->IsOverlayScrollbar(); + } + ++#if BUILDFLAG(IS_OHOS) ++void ScrollableArea::SetScrollbarColor(SkColor colorValue) { ++ if (colorValue != scrollbar_color_) { ++ scrollbar_color_ = colorValue; ++ } ++} ++#endif ++ + void ScrollableArea::SetScrollbarOverlayColorTheme( + ScrollbarOverlayColorTheme overlay_theme) { + scrollbar_overlay_color_theme_ = overlay_theme; +diff --git a/src/third_party/blink/renderer/core/scroll/scrollable_area.h b/src/third_party/blink/renderer/core/scroll/scrollable_area.h +index af8b59c6b0f..961c8482df6 +--- a/src/third_party/blink/renderer/core/scroll/scrollable_area.h ++++ b/src/third_party/blink/renderer/core/scroll/scrollable_area.h +@@ -223,12 +223,20 @@ class CORE_EXPORT ScrollableArea : public GarbageCollectedMixin { + // overflow:overlay might be deprecated soon. + bool HasOverlayScrollbars() const; + void SetScrollbarOverlayColorTheme(ScrollbarOverlayColorTheme); ++ #if BUILDFLAG(IS_OHOS) ++ void SetScrollbarColor(SkColor); ++ #endif + void RecalculateScrollbarOverlayColorTheme(const Color& background_color); + ScrollbarOverlayColorTheme GetScrollbarOverlayColorTheme() const { + return static_cast( + scrollbar_overlay_color_theme_); + } + ++ #if BUILDFLAG(IS_OHOS) ++ SkColor GetScrollBarColor() const { ++ return static_cast(scrollbar_color_); ++ } ++ #endif + // This getter will create a MacScrollAnimator if it doesn't already exist, + // only on MacOS. + MacScrollbarAnimator* GetMacScrollbarAnimator() const; +@@ -660,7 +668,9 @@ class CORE_EXPORT ScrollableArea : public GarbageCollectedMixin { + unsigned scrollbar_captured_ : 1; + unsigned mouse_over_scrollbar_ : 1; + unsigned has_been_disposed_ : 1; +- ++#if BUILDFLAG(IS_OHOS) ++ SkColor scrollbar_color_ = SK_ColorTRANSPARENT; ++#endif + scoped_refptr compositor_task_runner_; + }; + +diff --git a/src/third_party/blink/renderer/core/scroll/scrollbar.cc b/src/third_party/blink/renderer/core/scroll/scrollbar.cc +index 78e92a3e23d..9dc48b50d30 +--- a/src/third_party/blink/renderer/core/scroll/scrollbar.cc ++++ b/src/third_party/blink/renderer/core/scroll/scrollbar.cc +@@ -102,6 +102,12 @@ ScrollbarOverlayColorTheme Scrollbar::GetScrollbarOverlayColorTheme() const { + : kScrollbarOverlayColorThemeDark; + } + ++#if BUILDFLAG(IS_OHOS) ++SkColor Scrollbar::GetScrollBarColor() const { ++ return scrollable_area_ ? scrollable_area_->GetScrollBarColor() : 0; ++} ++#endif ++ + bool Scrollbar::HasTickmarks() const { + return orientation_ == kVerticalScrollbar && scrollable_area_ && + scrollable_area_->HasTickmarks(); + diff --git a/src/third_party/blink/renderer/core/scroll/scrollbar.h b/src/third_party/blink/renderer/core/scroll/scrollbar.h +index b0be4488a58..9932fc9f9e3 +--- a/src/third_party/blink/renderer/core/scroll/scrollbar.h ++++ b/src/third_party/blink/renderer/core/scroll/scrollbar.h +@@ -78,6 +78,9 @@ class CORE_EXPORT Scrollbar : public GarbageCollected, + const gfx::Rect& FrameRect() const { return frame_rect_; } + + ScrollbarOverlayColorTheme GetScrollbarOverlayColorTheme() const; ++#if BUILDFLAG(IS_OHOS) ++ SkColor GetScrollBarColor() const; ++#endif + bool HasTickmarks() const; + Vector GetTickmarks() const; + bool IsScrollableAreaActive() const; +diff --git a/src/third_party/blink/renderer/core/scroll/scrollbar_theme_overlay.cc b/src/third_party/blink/renderer/core/scroll/scrollbar_theme_overlay.cc +index 9a1fe9ba117..5a8862fed8a +--- a/src/third_party/blink/renderer/core/scroll/scrollbar_theme_overlay.cc ++++ b/src/third_party/blink/renderer/core/scroll/scrollbar_theme_overlay.cc +@@ -199,7 +199,9 @@ void ScrollbarThemeOverlay::PaintThumb(GraphicsContext& context, + params.scrollbar_thumb.scrollbar_theme = + static_cast( + scrollbar.GetScrollbarOverlayColorTheme()); +- ++#if BUILDFLAG(IS_OHOS) ++ params.scrollbar_thumb.scrollbar_color = scrollbar.GetScrollBarColor(); ++#endif + // Horizontally flip the canvas if it is left vertical scrollbar. + if (scrollbar.IsLeftSideVerticalScrollbar()) { + canvas->save(); +diff --git a/src/third_party/blink/renderer/modules/mediastream/user_media_client.cc b/src/third_party/blink/renderer/modules/mediastream/user_media_client.cc +index fffd64d40b4..a6cc61bd7c7 +--- a/src/third_party/blink/renderer/modules/mediastream/user_media_client.cc ++++ b/src/third_party/blink/renderer/modules/mediastream/user_media_client.cc +@@ -166,7 +166,7 @@ void UserMediaClient::RequestUserMedia(UserMediaRequest* user_media_request) { + if (auto* window = user_media_request->GetWindow()) { + PeerConnectionTracker::From(*window).TrackGetUserMedia(user_media_request); + } +- ++ + user_media_request->set_has_transient_user_activation( + has_transient_user_activation); + pending_request_infos_.push_back( +diff --git a/src/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms.cc b/src/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms.cc +index 6ba8ad0328b..0ada9af7312 +--- a/src/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms.cc ++++ b/src/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms.cc +@@ -398,8 +398,9 @@ WebMediaPlayerMS::~WebMediaPlayerMS() { + SendLogMessage( + String::Format("%s() [delegate_id=%d]", __func__, delegate_id_)); + +- if (!web_stream_.IsNull()) ++ if (!web_stream_.IsNull()) { + web_stream_.RemoveObserver(this); ++ } + + // Destruct compositor resources in the proper order. + get_client()->SetCcLayer(nullptr); +@@ -408,17 +409,35 @@ WebMediaPlayerMS::~WebMediaPlayerMS() { + video_layer_->StopUsingProvider(); + } + +- if (frame_deliverer_) +- io_task_runner_->DeleteSoon(FROM_HERE, frame_deliverer_.release()); +- +- if (compositor_) +- compositor_->StopUsingProvider(); ++ if (frame_deliverer_) { ++ io_task_runner_->DeleteSoon(FROM_HERE, std::move(frame_deliverer_)); ++ } + +- if (video_frame_provider_) ++ if (video_frame_provider_) { + video_frame_provider_->Stop(); ++ } + +- if (audio_renderer_) ++ // This must be destroyed before `compositor_` since it will grab a couple of ++ // final metrics during destruction. ++ watch_time_reporter_.reset(); ++ ++ if (compositor_) { ++ // `compositor_` receives frames on `io_task_runner_` from ++ // `frame_deliverer_` and operates on the `compositor_task_runner_`, so ++ // must trampoline through both to ensure a safe destruction. ++ PostCrossThreadTask( ++ *io_task_runner_, FROM_HERE, ++ WTF::CrossThreadBindOnce( ++ [](scoped_refptr task_runner, ++ std::unique_ptr compositor) { ++ task_runner->DeleteSoon(FROM_HERE, std::move(compositor)); ++ }, ++ compositor_task_runner_, std::move(compositor_))); ++ } ++ ++ if (audio_renderer_) { + audio_renderer_->Stop(); ++ } + + media_log_->AddEvent(); + +@@ -459,7 +478,7 @@ WebMediaPlayer::LoadTiming WebMediaPlayerMS::Load( + + watch_time_reporter_.reset(); + +- compositor_ = base::MakeRefCounted( ++ compositor_ = std::make_unique( + compositor_task_runner_, io_task_runner_, web_stream_, + std::move(submitter_), surface_layer_mode_, weak_this_); + +@@ -482,7 +501,7 @@ WebMediaPlayer::LoadTiming WebMediaPlayerMS::Load( + frame_deliverer_ = std::make_unique( + weak_this_, + CrossThreadBindRepeating(&WebMediaPlayerMSCompositor::EnqueueFrame, +- compositor_), ++ CrossThreadUnretained(compositor_.get())), + media_task_runner_, worker_task_runner_, gpu_factories_); + video_frame_provider_ = renderer_factory_->GetVideoRenderer( + web_stream_, +@@ -825,7 +844,19 @@ void WebMediaPlayerMS::Pause() { + video_frame_provider_->Pause(); + + compositor_->StopRendering(); +- compositor_->ReplaceCurrentFrameWithACopy(); ++ ++ // Bounce this call off of video task runner to since there might still be ++ // frames passed on video task runner. ++ PostCrossThreadTask( ++ *io_task_runner_, FROM_HERE, ++ WTF::CrossThreadBindOnce( ++ [](scoped_refptr task_runner, ++ WTF::CrossThreadOnceClosure copy_cb) { ++ PostCrossThreadTask(*task_runner, FROM_HERE, std::move(copy_cb)); ++ }, ++ main_render_task_runner_, ++ WTF::CrossThreadBindOnce( ++ &WebMediaPlayerMS::ReplaceCurrentFrameWithACopy, weak_this_))); + + if (audio_renderer_) + audio_renderer_->Pause(); +@@ -840,6 +871,11 @@ void WebMediaPlayerMS::Pause() { + paused_ = true; + } + ++void WebMediaPlayerMS::ReplaceCurrentFrameWithACopy() { ++ DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); ++ compositor_->ReplaceCurrentFrameWithACopy(); ++} ++ + void WebMediaPlayerMS::Seek(double seconds) { + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); + } +@@ -1176,8 +1212,9 @@ void WebMediaPlayerMS::ActivateSurfaceLayerForVideo() { + PostCrossThreadTask( + *compositor_task_runner_, FROM_HERE, + CrossThreadBindOnce(&WebMediaPlayerMSCompositor::EnableSubmission, +- compositor_, bridge_->GetSurfaceId(), +- video_transformation_, IsInPictureInPicture())); ++ CrossThreadUnretained(compositor_.get()), ++ bridge_->GetSurfaceId(), video_transformation_, ++ IsInPictureInPicture())); + + // If the element is already in Picture-in-Picture mode, it means that it + // was set in this mode prior to this load, with a different +diff --git a/src/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms_compositor.cc b/src/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms_compositor.cc +index e48742fe4db..278c980abf9 +--- a/src/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms_compositor.cc ++++ b/src/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms_compositor.cc +@@ -187,18 +187,18 @@ WebMediaPlayerMSCompositor::WebMediaPlayerMSCompositor( + dropped_frame_count_(0), + stopped_(true), + render_started_(!stopped_) { ++ weak_this_ = weak_ptr_factory_.GetWeakPtr(); + if (surface_layer_mode != WebMediaPlayer::SurfaceLayerMode::kNever) { + submitter_ = std::move(submitter); + + PostCrossThreadTask( + *video_frame_compositor_task_runner_, FROM_HERE, + CrossThreadBindOnce(&WebMediaPlayerMSCompositor::InitializeSubmitter, +- weak_ptr_factory_.GetWeakPtr())); ++ weak_this_)); + update_submission_state_callback_ = base::BindPostTask( + video_frame_compositor_task_runner_, + ConvertToBaseRepeatingCallback(CrossThreadBindRepeating( +- &WebMediaPlayerMSCompositor::SetIsSurfaceVisible, +- weak_ptr_factory_.GetWeakPtr()))); ++ &WebMediaPlayerMSCompositor::SetIsSurfaceVisible, weak_this_))); + } + + HeapVector> video_components; +@@ -226,35 +226,15 @@ WebMediaPlayerMSCompositor::WebMediaPlayerMSCompositor( + } + + WebMediaPlayerMSCompositor::~WebMediaPlayerMSCompositor() { +- // Ensured by destructor traits. + DCHECK(video_frame_compositor_task_runner_->BelongsToCurrentThread()); +- +- if (submitter_) { +- video_frame_compositor_task_runner_->DeleteSoon(FROM_HERE, +- std::move(submitter_)); +- } else { +- DCHECK(!video_frame_provider_client_) +- << "Must call StopUsingProvider() before dtor!"; +- } +-} +- +-// static +-void WebMediaPlayerMSCompositorTraits::Destruct( +- const WebMediaPlayerMSCompositor* compositor) { +- if (!compositor->video_frame_compositor_task_runner_ +- ->BelongsToCurrentThread()) { +- PostCrossThreadTask( +- *compositor->video_frame_compositor_task_runner_, FROM_HERE, +- CrossThreadBindOnce(&WebMediaPlayerMSCompositorTraits::Destruct, +- CrossThreadUnretained(compositor))); +- return; ++ if (video_frame_provider_client_) { ++ video_frame_provider_client_->StopUsingProvider(); + } +- delete compositor; + } + + void WebMediaPlayerMSCompositor::InitializeSubmitter() { + DCHECK(video_frame_compositor_task_runner_->BelongsToCurrentThread()); +- submitter_->Initialize(this, /* is_media_stream = */ true); ++ submitter_->Initialize(this, /*is_media_stream=*/true); + } + + void WebMediaPlayerMSCompositor::SetIsSurfaceVisible( +@@ -297,7 +277,7 @@ void WebMediaPlayerMSCompositor::SetForceBeginFrames(bool enable) { + PostCrossThreadTask( + *video_frame_compositor_task_runner_, FROM_HERE, + CrossThreadBindOnce(&WebMediaPlayerMSCompositor::SetForceBeginFrames, +- weak_ptr_factory_.GetWeakPtr(), enable)); ++ weak_this_, enable)); + return; + } + +@@ -507,7 +487,7 @@ void WebMediaPlayerMSCompositor::StartRendering() { + PostCrossThreadTask( + *video_frame_compositor_task_runner_, FROM_HERE, + CrossThreadBindOnce(&WebMediaPlayerMSCompositor::StartRenderingInternal, +- WrapRefCounted(this))); ++ weak_this_)); + } + + void WebMediaPlayerMSCompositor::StopRendering() { +@@ -515,27 +495,7 @@ void WebMediaPlayerMSCompositor::StopRendering() { + PostCrossThreadTask( + *video_frame_compositor_task_runner_, FROM_HERE, + CrossThreadBindOnce(&WebMediaPlayerMSCompositor::StopRenderingInternal, +- WrapRefCounted(this))); +-} +- +-void WebMediaPlayerMSCompositor::ReplaceCurrentFrameWithACopy() { +- DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); +- // Bounce this call off of IO thread to since there might still be frames +- // passed on IO thread. +- io_task_runner_->PostTask( +- FROM_HERE, +- media::BindToCurrentLoop(WTF::Bind( +- &WebMediaPlayerMSCompositor::ReplaceCurrentFrameWithACopyInternal, +- WrapRefCounted(this)))); +-} +- +-void WebMediaPlayerMSCompositor::StopUsingProvider() { +- DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); +- PostCrossThreadTask( +- *video_frame_compositor_task_runner_, FROM_HERE, +- CrossThreadBindOnce( +- &WebMediaPlayerMSCompositor::StopUsingProviderInternal, +- WrapRefCounted(this))); ++ weak_this_)); + } + + bool WebMediaPlayerMSCompositor::MapTimestampsToRenderTimeTicks( +@@ -605,7 +565,7 @@ void WebMediaPlayerMSCompositor::RenderWithoutAlgorithm( + *video_frame_compositor_task_runner_, FROM_HERE, + CrossThreadBindOnce( + &WebMediaPlayerMSCompositor::RenderWithoutAlgorithmOnCompositor, +- WrapRefCounted(this), std::move(frame), is_copy)); ++ weak_this_, std::move(frame), is_copy)); + } + + void WebMediaPlayerMSCompositor::RenderWithoutAlgorithmOnCompositor( +@@ -697,9 +657,8 @@ void WebMediaPlayerMSCompositor::SetCurrentFrame( + PostCrossThreadTask( + *video_frame_compositor_task_runner_, FROM_HERE, + CrossThreadBindOnce(&WebMediaPlayerMSCompositor::CheckForFrameChanges, +- WrapRefCounted(this), is_first_frame, +- has_frame_size_changed, std::move(new_transform), +- std::move(new_opacity))); ++ weak_this_, is_first_frame, has_frame_size_changed, ++ std::move(new_transform), std::move(new_opacity))); + } + + void WebMediaPlayerMSCompositor::CheckForFrameChanges( +@@ -766,14 +725,7 @@ void WebMediaPlayerMSCompositor::StopRenderingInternal() { + video_frame_provider_client_->StopRendering(); + } + +-void WebMediaPlayerMSCompositor::StopUsingProviderInternal() { +- DCHECK(video_frame_compositor_task_runner_->BelongsToCurrentThread()); +- if (video_frame_provider_client_) +- video_frame_provider_client_->StopUsingProvider(); +- video_frame_provider_client_ = nullptr; +-} +- +-void WebMediaPlayerMSCompositor::ReplaceCurrentFrameWithACopyInternal() { ++void WebMediaPlayerMSCompositor::ReplaceCurrentFrameWithACopy() { + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); + scoped_refptr current_frame_ref; + { +diff --git a/src/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms_compositor.h b/src/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms_compositor.h +index 3a8cdef1cfb..549fccca2c5 +--- a/src/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms_compositor.h ++++ b/src/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms_compositor.h +@@ -23,7 +23,6 @@ + #include "third_party/blink/renderer/modules/mediastream/video_renderer_algorithm_wrapper.h" + #include "third_party/blink/renderer/modules/modules_export.h" + #include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h" +-#include "third_party/blink/renderer/platform/wtf/thread_safe_ref_counted.h" + + namespace base { + class SingleThreadTaskRunner; +@@ -45,7 +44,6 @@ class SurfaceId; + namespace blink { + class MediaStreamDescriptor; + class WebMediaPlayerMS; +-struct WebMediaPlayerMSCompositorTraits; + + // This class is designed to handle the work load on compositor thread for + // WebMediaPlayerMS. It will be instantiated on the main thread, but destroyed +@@ -57,9 +55,7 @@ struct WebMediaPlayerMSCompositorTraits; + // Otherwise, WebMediaPlayerMSCompositor will simply store the most recent + // frame, and submit it whenever asked by the compositor. + class MODULES_EXPORT WebMediaPlayerMSCompositor +- : public cc::VideoFrameProvider, +- public WTF::ThreadSafeRefCounted { ++ : public cc::VideoFrameProvider { + public: + using OnNewFramePresentedCB = base::OnceClosure; + +@@ -70,6 +66,7 @@ class MODULES_EXPORT WebMediaPlayerMSCompositor + std::unique_ptr submitter, + WebMediaPlayer::SurfaceLayerMode surface_layer_mode, + const base::WeakPtr& player); ++ ~WebMediaPlayerMSCompositor() override; + + WebMediaPlayerMSCompositor(const WebMediaPlayerMSCompositor&) = delete; + WebMediaPlayerMSCompositor& operator=(const WebMediaPlayerMSCompositor&) = +@@ -115,10 +112,6 @@ class MODULES_EXPORT WebMediaPlayerMSCompositor + void StopRendering(); + void ReplaceCurrentFrameWithACopy(); + +- // Tell |video_frame_provider_client_| to stop using this instance in +- // preparation for dtor. +- void StopUsingProvider(); +- + // Sets a hook to be notified when a new frame is presented, to fulfill a + // prending video.requestAnimationFrame() request. + // Can be called from any thread. +@@ -140,10 +133,7 @@ class MODULES_EXPORT WebMediaPlayerMSCompositor + void SetForceBeginFrames(bool enable); + + private: +- friend class WTF::ThreadSafeRefCounted; + friend class WebMediaPlayerMSTest; +- friend struct WebMediaPlayerMSCompositorTraits; + + // Struct used to keep information about frames pending in + // |rendering_frame_buffer_|. +@@ -154,8 +144,6 @@ class MODULES_EXPORT WebMediaPlayerMSCompositor + bool is_copy; + }; + +- ~WebMediaPlayerMSCompositor() override; +- + // Ran on the |video_frame_compositor_task_runner_| to initialize + // |submitter_| + void InitializeSubmitter(); +@@ -201,8 +189,6 @@ class MODULES_EXPORT WebMediaPlayerMSCompositor + + void StartRenderingInternal(); + void StopRenderingInternal(); +- void StopUsingProviderInternal(); +- void ReplaceCurrentFrameWithACopyInternal(); + + void SetAlgorithmEnabledForTesting(bool algorithm_enabled); + +@@ -292,15 +278,10 @@ class MODULES_EXPORT WebMediaPlayerMSCompositor + // |dropped_frame_count_|, and |render_started_|. + base::Lock current_frame_lock_; + ++ base::WeakPtr weak_this_; + base::WeakPtrFactory weak_ptr_factory_{this}; + }; + +-struct WebMediaPlayerMSCompositorTraits { +- // Ensure destruction occurs on main thread so that "Web" and other resources +- // are destroyed on the correct thread. +- static void Destruct(const WebMediaPlayerMSCompositor* player); +-}; +- + } // namespace blink + + #endif // THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIASTREAM_WEBMEDIAPLAYER_MS_COMPOSITOR_H_ +diff --git a/src/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc b/src/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc +index 1ea0690427a..a8dc8a5fa3b +--- a/src/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc ++++ b/src/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc +@@ -901,10 +901,11 @@ RTCPeerConnection::~RTCPeerConnection() { + } + + void RTCPeerConnection::Dispose() { +- // Promptly clears the handler's pointer to |this| ++ // Promptly clears the handler + // so that content/ doesn't access it in a lazy sweeping phase. ++ // Other references to the handler use a weak pointer, preventing access. + if (peer_handler_) { +- peer_handler_->CloseAndUnregister(); ++ peer_handler_.reset(); + } + } + +diff --git a/src/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection_handler.cc b/src/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection_handler.cc +index f51ec058691..ee37803fe9e +--- a/src/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection_handler.cc ++++ b/src/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection_handler.cc +@@ -838,6 +838,8 @@ class RTCPeerConnectionHandler::WebRtcSetDescriptionObserverImpl + if (handler_) { + handler_->OnModifySctpTransport(std::move(states.sctp_transport_state)); + } ++ // Since OnSessionDescriptionsUpdated can fire events, it may cause ++ // garbage collection. Ensure that handler_ is still valid. + if (handler_) { + handler_->OnModifyTransceivers( + states.signaling_state, std::move(states.transceiver_states), +@@ -1043,6 +1045,10 @@ class RTCPeerConnectionHandler::Observer + std::move(current_local_description), + std::move(pending_remote_description), + std::move(current_remote_description)); ++ } ++ // Since OnSessionDescriptionsUpdated can fire events, it may cause ++ // garbage collection. Ensure that handler_ is still valid. ++ if (handler_) { + handler_->OnIceCandidate(sdp, sdp_mid, sdp_mline_index, component, + address_family); + } +@@ -1156,6 +1162,8 @@ bool RTCPeerConnectionHandler::Initialize( + CHECK(!initialize_called_); + initialize_called_ = true; + ++ // Prevent garbage collection of client_ during processing. ++ auto* client_on_stack = client_; + peer_connection_tracker_ = PeerConnectionTracker::From(*frame); + + configuration_ = server_configuration; +@@ -1191,8 +1199,8 @@ bool RTCPeerConnectionHandler::Initialize( + peer_connection_tracker_->RegisterPeerConnection(this, configuration_, + options, frame_); + } +- +- return true; ++ // Gratuitous usage of client_on_stack to prevent compiler errors. ++ return !!client_on_stack; + } + + bool RTCPeerConnectionHandler::InitializeForTest( +@@ -2286,9 +2294,11 @@ void RTCPeerConnectionHandler::OnSessionDescriptionsUpdated( + pending_remote_description, + std::unique_ptr + current_remote_description) { ++ // Prevent garbage collection of client_ during processing. ++ auto* client_on_stack = client_; + if (!client_ || is_closed_) + return; +- client_->DidChangeSessionDescriptions( ++ client_on_stack->DidChangeSessionDescriptions( + pending_local_description + ? CreateWebKitSessionDescription(pending_local_description.get()) + : nullptr, +@@ -2606,8 +2616,12 @@ void RTCPeerConnectionHandler::OnIceCandidate(const String& sdp, + int sdp_mline_index, + int component, + int address_family) { ++ // In order to ensure that the RTCPeerConnection is not garbage collected ++ // from under the function, we keep a pointer to it on the stack. ++ auto* client_on_stack = client_; + DCHECK(task_runner_->RunsTasksInCurrentSequence()); + TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::OnIceCandidateImpl"); ++ // This line can cause garbage collection. + auto* platform_candidate = MakeGarbageCollected( + sdp, sdp_mid, sdp_mline_index); + if (peer_connection_tracker_) { +@@ -2627,7 +2641,7 @@ void RTCPeerConnectionHandler::OnIceCandidate(const String& sdp, + } + } + if (!is_closed_) +- client_->DidGenerateICECandidate(platform_candidate); ++ client_on_stack->DidGenerateICECandidate(platform_candidate); + } + + void RTCPeerConnectionHandler::OnIceCandidateError( +@@ -2639,7 +2653,6 @@ void RTCPeerConnectionHandler::OnIceCandidateError( + const String& error_text) { + DCHECK(task_runner_->RunsTasksInCurrentSequence()); + TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::OnIceCandidateError"); +- + if (peer_connection_tracker_) { + peer_connection_tracker_->TrackIceCandidateError( + this, address, port, host_candidate, url, error_code, error_text); +diff --git a/src/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection_handler_test.cc b/src/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection_handler_test.cc +index b5e655c4122..fb823f0549d +--- a/src/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection_handler_test.cc ++++ b/src/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection_handler_test.cc +@@ -1394,4 +1394,22 @@ TEST_F(RTCPeerConnectionHandlerTest, + EXPECT_TRUE(pc_handler_->HasSpeedLimitUmaListener()); + } + ++TEST_F(RTCPeerConnectionHandlerTest, CandidatesIgnoredWheHandlerDeleted) { ++ auto* observer = pc_handler_->observer(); ++ std::unique_ptr native_candidate( ++ mock_dependency_factory_->CreateIceCandidate("sdpMid", 1, kDummySdp)); ++ pc_handler_.reset(); ++ observer->OnIceCandidate(native_candidate.get()); ++} ++ ++TEST_F(RTCPeerConnectionHandlerTest, ++ CandidatesIgnoredWheHandlerDeletedFromEvent) { ++ auto* observer = pc_handler_->observer(); ++ std::unique_ptr native_candidate( ++ mock_dependency_factory_->CreateIceCandidate("sdpMid", 1, kDummySdp)); ++ EXPECT_CALL(*mock_client_, DidChangeSessionDescriptions(_, _, _, _)) ++ .WillOnce(testing::Invoke([&] { pc_handler_.reset(); })); ++ observer->OnIceCandidate(native_candidate.get()); ++} ++ + } // namespace blink +diff --git a/src/third_party/blink/renderer/platform/bindings/observable_array_base.cc b/src/third_party/blink/renderer/platform/bindings/observable_array_base.cc +index 3e91059c2ef..9cc6a0839ee +--- a/src/third_party/blink/renderer/platform/bindings/observable_array_base.cc ++++ b/src/third_party/blink/renderer/platform/bindings/observable_array_base.cc +@@ -24,12 +24,22 @@ v8::MaybeLocal ObservableArrayBase::GetProxyHandlerObject( + ScriptState* script_state) { + v8::Local v8_function_template = + GetProxyHandlerFunctionTemplate(script_state); ++ v8::Local v8_context = script_state->GetContext(); + v8::Local v8_function; +- if (!v8_function_template->GetFunction(script_state->GetContext()) +- .ToLocal(&v8_function)) { ++ if (!v8_function_template->GetFunction(v8_context).ToLocal(&v8_function)) { + return {}; + } +- return v8_function->NewInstance(script_state->GetContext()); ++ v8::Local v8_object; ++ if (!v8_function->NewInstance(v8_context).ToLocal(&v8_object)) { ++ return {}; ++ } ++ bool did_set_prototype = false; ++ if (!v8_object->SetPrototype(v8_context, v8::Null(script_state->GetIsolate())) ++ .To(&did_set_prototype)) { ++ return {}; ++ } ++ CHECK(did_set_prototype); ++ return v8_object; + } + + void ObservableArrayBase::Trace(Visitor* visitor) const { +diff --git a/src/third_party/blink/renderer/platform/bindings/parkable_string.cc b/src/third_party/blink/renderer/platform/bindings/parkable_string.cc +index e2c596659b7..ee2e985e540 +--- a/src/third_party/blink/renderer/platform/bindings/parkable_string.cc ++++ b/src/third_party/blink/renderer/platform/bindings/parkable_string.cc +@@ -10,6 +10,8 @@ + // https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md + #pragma clang max_tokens_here 760000 + ++#include ++ + #include "base/allocator/partition_allocator/oom.h" + #include "base/allocator/partition_allocator/partition_alloc.h" + #include "base/bind.h" +@@ -232,18 +234,26 @@ ParkableStringImpl::ParkableMetadata::ParkableMetadata( + is_8bit_(string.Is8Bit()), + length_(string.length()) {} + +-// static ++// static2 + std::unique_ptr + ParkableStringImpl::HashString(StringImpl* string) { + DigestValue digest_result; +- bool ok = ComputeDigest(kHashAlgorithmSha256, +- static_cast(string->Bytes()), +- string->CharactersSizeInBytes(), digest_result); ++ ++ Digestor digestor(kHashAlgorithmSha256); ++ digestor.Update(base::make_span(static_cast(string->Bytes()), ++ string->CharactersSizeInBytes())); ++ // Also include encoding in the digest, otherwise two strings with identical ++ // byte content but different encoding will be assumed equal, leading to ++ // crashes when one is replaced by the other one. ++ std::array is_8bit; ++ is_8bit[0] = string->Is8Bit(); ++ digestor.Update(is_8bit); ++ digestor.Finish(digest_result); + + // The only case where this can return false in BoringSSL is an allocation + // failure of the temporary data required for hashing. In this case, there + // is nothing better to do than crashing. +- if (!ok) { ++ if (digestor.has_failed()) { + // Don't know the exact size, the SHA256 spec hints at ~64 (block size) + // + 32 (digest) bytes. + base::TerminateBecauseOutOfMemory(64 + kDigestSize); +diff --git a/src/third_party/blink/renderer/platform/bindings/parkable_string.h b/src/third_party/blink/renderer/platform/bindings/parkable_string.h +index b9b48bfca03..2f6c9fcc889 +--- a/src/third_party/blink/renderer/platform/bindings/parkable_string.h ++++ b/src/third_party/blink/renderer/platform/bindings/parkable_string.h +@@ -55,6 +55,9 @@ class PLATFORM_EXPORT ParkableStringImpl final + constexpr static size_t kDigestSize = 32; // SHA256. + using SecureDigest = Vector; + // Computes a secure hash of a |string|, to be passed to |MakeParkable()|. ++ // ++ // TODO(lizeb): This is the "right" way of hashing a string. Move this code ++ // into WTF, and make sure it's the only way that is used. + static std::unique_ptr HashString(StringImpl* string); + + // Not all ParkableStringImpls are actually parkable. +diff --git a/src/third_party/blink/renderer/platform/bindings/parkable_string_test.cc b/src/third_party/blink/renderer/platform/bindings/parkable_string_test.cc +index 8a4fb9cb14e..6a207d113e6 +--- a/src/third_party/blink/renderer/platform/bindings/parkable_string_test.cc ++++ b/src/third_party/blink/renderer/platform/bindings/parkable_string_test.cc +@@ -3,6 +3,7 @@ + // found in the LICENSE file. + + #include ++#include + #include + + #include "base/bind.h" +@@ -1194,6 +1195,36 @@ TEST_P(ParkableStringTest, ReportTotalDiskTime) { + 1); + } + ++TEST_P(ParkableStringTest, EncodingAndDeduplication) { ++ size_t size_in_chars = 2 * kSizeKb * 1000 / sizeof(UChar); ++ Vector data_16(size_in_chars); ++ for (size_t i = 0; i < size_in_chars; ++i) { ++ data_16[i] = 0x2020; ++ } ++ String large_string_16 = String(&data_16[0], size_in_chars); ++ ++ ParkableString parkable_16(large_string_16.Impl()); ++ ASSERT_TRUE(parkable_16.Impl()->digest()); ++ ASSERT_TRUE(parkable_16.may_be_parked()); ++ ++ Vector data_8(2 * size_in_chars); ++ for (size_t i = 0; i < 2 * size_in_chars; ++i) { ++ data_8[i] = 0x20; ++ } ++ String large_string_8 = String(&data_8[0], 2 * size_in_chars); ++ ++ ParkableString parkable_8(large_string_8.Impl()); ++ ASSERT_TRUE(parkable_8.Impl()->digest()); ++ ASSERT_TRUE(parkable_8.may_be_parked()); ++ ++ // Same content, but the hash must be differnt because the encoding is. ++ EXPECT_EQ(0, memcmp(large_string_16.Bytes(), large_string_8.Bytes(), ++ large_string_8.CharactersSizeInBytes())); ++ EXPECT_EQ(parkable_16.CharactersSizeInBytes(), ++ parkable_8.CharactersSizeInBytes()); ++ EXPECT_NE(*parkable_16.Impl()->digest(), *parkable_8.Impl()->digest()); ++} ++ + class ParkableStringTestWithQueuedThreadPool : public ParkableStringTest { + public: + ParkableStringTestWithQueuedThreadPool() +diff --git a/src/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.cc b/src/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.cc +index dccc8866c4a..3508d188276 +--- a/src/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.cc ++++ b/src/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.cc +@@ -2280,6 +2280,13 @@ void ResourceFetcher::PopulateAndAddResourceTimingInfo( + Resource* resource, + scoped_refptr info, + base::TimeTicks response_end) { ++ // Resource timing entries that correspond to resources fetched by extensions ++ // are precluded. ++ if (resource->Options().world_for_csp.get() && ++ resource->Options().world_for_csp->IsIsolatedWorld()) { ++ return; ++ } ++ + const KURL& initial_url = + resource->GetResourceRequest().GetRedirectInfo().has_value() + ? resource->GetResourceRequest().GetRedirectInfo()->original_url +diff --git a/src/third_party/blink/renderer/platform/loader/fetch/script_cached_metadata_handler.cc b/src/third_party/blink/renderer/platform/loader/fetch/script_cached_metadata_handler.cc +index b1fc6d9ce84..647e1325fbe +--- a/src/third_party/blink/renderer/platform/loader/fetch/script_cached_metadata_handler.cc ++++ b/src/third_party/blink/renderer/platform/loader/fetch/script_cached_metadata_handler.cc +@@ -129,27 +129,25 @@ void ScriptCachedMetadataHandler::CommitToPersistentStorage( + void ScriptCachedMetadataHandlerWithHashing::Check( + CodeCacheHost* code_cache_host, + const ParkableString& source_text) { +- // If we already attempted to Check once and couldn't compute the hash, just +- // give up. +- if (hash_state_ == kFailedToCheck) +- return; +- +- DigestValue digest; +- const String& unparked = source_text.ToString(); +- if (!ComputeDigest(kHashAlgorithmSha256, +- static_cast(unparked.Bytes()), +- unparked.CharactersSizeInBytes(), digest)) { +- // Something went wrong computing the hash. We can't use the cached +- // metadata, but we don't need to clear it on disk. +- ClearCachedMetadata(code_cache_host, kClearLocally); +- hash_state_ = kFailedToCheck; +- return; ++ std::unique_ptr digest_holder; ++ const ParkableStringImpl::SecureDigest* digest; ++ // ParkableStrings have usually already computed the digest unless they're ++ // quite short (see ParkableStringManager::ShouldPark), so usually we can just ++ // use the pre-existing digest. ++ ParkableStringImpl* impl = source_text.Impl(); ++ if (impl && impl->may_be_parked()) { ++ digest = impl->digest(); ++ } else { ++ const String& unparked = source_text.ToString(); ++ digest_holder = ParkableStringImpl::HashString(unparked.Impl()); ++ digest = digest_holder.get(); + } +- CHECK_EQ(digest.size(), kSha256Bytes); ++ ++ CHECK_EQ(digest->size(), kSha256Bytes); + + if (hash_state_ != kUninitialized) { + // Compare the hash of the new source text with the one previously loaded. +- if (memcmp(digest.data(), hash_, kSha256Bytes) != 0) { ++ if (memcmp(digest->data(), hash_, kSha256Bytes) != 0) { + // If this handler was previously checked and is now being checked again + // with a different hash value, then something bad happened. We expect the + // handler to only be used with one script source text. +@@ -162,7 +160,7 @@ void ScriptCachedMetadataHandlerWithHashing::Check( + + // Remember the computed hash so that it can be used when saving data to + // persistent storage. +- memcpy(hash_, digest.data(), kSha256Bytes); ++ memcpy(hash_, digest->data(), kSha256Bytes); + hash_state_ = kChecked; + } + +@@ -174,9 +172,8 @@ void ScriptCachedMetadataHandlerWithHashing::SetSerializedCachedMetadata( + DCHECK(!cached_metadata_); + DCHECK_EQ(hash_state_, kUninitialized); + +- // kChecked and kFailedToCheck states guarantees that hash_ will never be +- // updated again. +- CHECK(hash_state_ != kChecked && hash_state_ != kFailedToCheck); ++ // The kChecked state guarantees that hash_ will never be updated again. ++ CHECK(hash_state_ != kChecked); + + const uint32_t kMetadataTypeSize = sizeof(uint32_t); + const uint32_t kHashingHeaderSize = kMetadataTypeSize + kSha256Bytes; +@@ -206,17 +203,12 @@ ScriptCachedMetadataHandlerWithHashing::GetCachedMetadata( + // okay for that metadata to possibly mismatch with the loaded script content, + // then you can pass kAllowUnchecked as the second parameter. + if (behavior == kCrashIfUnchecked) { +- CHECK(hash_state_ == kChecked || hash_state_ == kFailedToCheck); ++ CHECK(hash_state_ == kChecked); + } + + scoped_refptr result = + ScriptCachedMetadataHandler::GetCachedMetadata(data_type_id, behavior); + +- // The cached metadata should have been cleared if hash computation failed. +- if (hash_state_ == kFailedToCheck) { +- CHECK_EQ(result, nullptr); +- } +- + return result; + } + +diff --git a/src/third_party/blink/renderer/platform/loader/fetch/script_cached_metadata_handler.h b/src/third_party/blink/renderer/platform/loader/fetch/script_cached_metadata_handler.h +index 2353a3d5e65..eb073e76a2b +--- a/src/third_party/blink/renderer/platform/loader/fetch/script_cached_metadata_handler.h ++++ b/src/third_party/blink/renderer/platform/loader/fetch/script_cached_metadata_handler.h +@@ -112,12 +112,8 @@ class PLATFORM_EXPORT ScriptCachedMetadataHandlerWithHashing final + kUninitialized, // hash_ has not been written. + kDeserialized, // hash_ contains data from the code cache that has not yet + // been checked for matching the script text. +- +- // Terminal states: once hash_state_ reaches one of the following, neither +- // hash_state_ nor hash_ will ever change again. +- +- kChecked, // hash_ contains the hash of the script text. +- kFailedToCheck, // hash_ contains garbage. Computing the hash failed. ++ kChecked, // hash_ contains the hash of the script text. Neither ++ // hash_state_ nor hash_ will ever change again. + }; + HashState hash_state_ = kUninitialized; + }; +diff --git a/src/third_party/blink/renderer/platform/media/web_media_player_impl.cc b/src/third_party/blink/renderer/platform/media/web_media_player_impl.cc +index 67dead4867b..a8ff0933013 +--- a/src/third_party/blink/renderer/platform/media/web_media_player_impl.cc ++++ b/src/third_party/blink/renderer/platform/media/web_media_player_impl.cc +@@ -327,7 +327,7 @@ bool UsesAudioService(media::RendererType renderer_type) { + return renderer_type != media::RendererType::kMediaFoundation; + } + +-#if defined(OS_ANDROID) ++#if defined(OS_ANDROID) || BUILDFLAG(IS_OHOS) + + // These values are persisted to logs. Entries should not be renumbered and + // numeric values should never be reused. +@@ -1841,11 +1841,13 @@ void WebMediaPlayerImpl::OnError(media::PipelineStatus status) { + if (suppress_destruction_errors_) + return; + +-#if defined(OS_ANDROID) ++#if defined(OS_ANDROID) || BUILDFLAG(IS_OHOS) + // `mb_data_source_` may be nullptr if someone passes in a m3u8 as a data:// + // URL, since MediaPlayer doesn't support data:// URLs, fail playback now. + const bool found_hls = ++#if !BUILDFLAG(IS_OHOS) + base::FeatureList::IsEnabled(media::kHlsPlayer) && ++#endif // !BUILDFLAG(IS_OHOS) + status == media::PipelineStatus::DEMUXER_ERROR_DETECTED_HLS; + if (found_hls && mb_data_source_) { + demuxer_found_hls_ = true; +@@ -1881,8 +1883,13 @@ void WebMediaPlayerImpl::OnError(media::PipelineStatus status) { + "Media.WebMediaPlayerImpl.HLS.IsMixedContent", + frame_url_is_cryptographic && !manifest_url_is_cryptographic); + ++#if BUILDFLAG(IS_OHOS) ++ renderer_factory_selector_->SetBaseRendererType( ++ media::RendererType::kOHOSMediaPlayer); ++#else + renderer_factory_selector_->SetBaseRendererType( + media::RendererType::kMediaPlayer); ++#endif + + loaded_url_ = mb_data_source_->GetUrlAfterRedirects(); + DCHECK(data_source_); +@@ -2863,12 +2870,7 @@ void WebMediaPlayerImpl::StartPipeline() { + &WebMediaPlayerImpl::OnFirstFrame, weak_this_)))); + + #if defined(OS_ANDROID) || BUILDFLAG(IS_OHOS) +-#if defined(OS_ANDROID) +- if (demuxer_found_hls_ || +-#else +- if ( +-#endif +- renderer_factory_selector_->GetCurrentFactory() ++ if (demuxer_found_hls_ || renderer_factory_selector_->GetCurrentFactory() + ->GetRequiredMediaResourceType() == + media::MediaResource::Type::URL) { + // MediaPlayerRendererClientFactory is the only factory that a uses +diff --git a/src/third_party/blink/renderer/platform/theme/web_theme_engine_default.cc b/src/third_party/blink/renderer/platform/theme/web_theme_engine_default.cc +index 5f9f7da118a..2396b007372 +--- a/src/third_party/blink/renderer/platform/theme/web_theme_engine_default.cc ++++ b/src/third_party/blink/renderer/platform/theme/web_theme_engine_default.cc +@@ -143,6 +143,10 @@ static void GetNativeThemeExtraParams( + native_theme_extra_params->scrollbar_thumb.scrollbar_theme = + NativeThemeScrollbarOverlayColorTheme( + extra_params->scrollbar_thumb.scrollbar_theme); ++#if BUILDFLAG(IS_OHOS) ++ native_theme_extra_params->scrollbar_thumb.scrollbar_color = ++ extra_params->scrollbar_thumb.scrollbar_color; ++#endif + break; + case WebThemeEngine::kPartScrollbarDownArrow: + case WebThemeEngine::kPartScrollbarLeftArrow: +diff --git a/src/third_party/blink/renderer/platform/weborigin/kurl.cc b/src/third_party/blink/renderer/platform/weborigin/kurl.cc +index 19bc02e5771..593ea93dfb1 +--- a/src/third_party/blink/renderer/platform/weborigin/kurl.cc ++++ b/src/third_party/blink/renderer/platform/weborigin/kurl.cc +@@ -162,7 +162,11 @@ bool KURL::IsLocalFile() const { + // and including feed would allow feeds to potentially let someone's blog + // read the contents of the clipboard on a drag, even without a drop. + // Likewise with using the FrameLoader::shouldTreatURLAsLocal() function. ++#if BUILDFLAG(IS_OHOS) ++ return ProtocolIs(url::kFileScheme) || ProtocolIs(url::kResourcesScheme); ++#else + return ProtocolIs(url::kFileScheme); ++#endif + } + + bool ProtocolIsJavaScript(const String& url) { +diff --git a/src/third_party/blink/renderer/platform/widget/compositing/layer_tree_settings.cc b/src/third_party/blink/renderer/platform/widget/compositing/layer_tree_settings.cc +index d8976665cc2..0e33bc4e13c +--- a/src/third_party/blink/renderer/platform/widget/compositing/layer_tree_settings.cc ++++ b/src/third_party/blink/renderer/platform/widget/compositing/layer_tree_settings.cc +@@ -34,7 +34,7 @@ namespace { + const base::Feature kUnpremultiplyAndDitherLowBitDepthTiles = { + "UnpremultiplyAndDitherLowBitDepthTiles", base::FEATURE_ENABLED_BY_DEFAULT}; + +-#if defined(OS_ANDROID) ++#if defined(OS_ANDROID) || defined(OS_OHOS) + // With 32 bit pixels, this would mean less than 400kb per buffer. Much less + // than required for, say, nHD. + static const int kSmallScreenPixelThreshold = 1e5; +@@ -69,14 +69,32 @@ cc::ManagedMemoryPolicy GetGpuMemoryPolicy( + return actual; + } + +-#if defined(OS_ANDROID) ++ size_t physical_memory_mb = 0; ++#if !defined(OS_ANDROID) && !defined(OS_OHOS) ++ // Ignore what the system said and give all clients the same maximum ++ // allocation on desktop platforms. ++ actual.bytes_limit_when_visible = 512 * 1024 * 1024; ++ actual.priority_cutoff_when_visible = ++ gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; ++ ++ // For large monitors (4k), double the tile memory to avoid frequent out of ++ // memory problems. 4k could mean a screen width of anywhere from 3840 to 4096 ++ // (see https://en.wikipedia.org/wiki/4K_resolution). We use 3500 as a proxy ++ // for "large enough". ++ static const int kLargeDisplayThreshold = 3500; ++ int display_width = ++ std::round(initial_screen_size.width() * initial_device_scale_factor); ++ if (display_width >= kLargeDisplayThreshold) ++ actual.bytes_limit_when_visible *= 2; ++ ++ return actual; ++#elif defined(OS_ANDROID) + // We can't query available GPU memory from the system on Android. + // Physical memory is also mis-reported sometimes (eg. Nexus 10 reports + // 1262MB when it actually has 2GB, while Razr M has 1GB but only reports + // 128MB java heap size). First we estimate physical memory using both. + size_t dalvik_mb = base::SysInfo::DalvikHeapSizeMB(); + size_t physical_mb = base::SysInfo::AmountOfPhysicalMemoryMB(); +- size_t physical_memory_mb = 0; + if (base::SysInfo::IsLowEndDevice()) { + // TODO(crbug.com/742534): The code below appears to no longer work. + // |dalvik_mb| no longer follows the expected heuristic pattern, causing us +@@ -89,7 +107,9 @@ cc::ManagedMemoryPolicy GetGpuMemoryPolicy( + } else { + physical_memory_mb = std::max(dalvik_mb * 4, (physical_mb * 4) / 3); + } +- ++#elif defined(OS_OHOS) ++ physical_memory_mb = base::SysInfo::AmountOfPhysicalMemoryMB(); ++#endif + // Now we take a default of 1/8th of memory on high-memory devices, + // and gradually scale that back for low-memory devices (to be nicer + // to other apps so they don't get killed). Examples: +@@ -120,7 +140,7 @@ cc::ManagedMemoryPolicy GetGpuMemoryPolicy( + + actual.bytes_limit_when_visible = + actual.bytes_limit_when_visible * 1024 * 1024; +- // Clamp the observed value to a specific range on Android. ++ // Clamp the observed value to a specific range on Android or OHOS. + actual.bytes_limit_when_visible = std::max( + actual.bytes_limit_when_visible, static_cast(8 * 1024 * 1024)); + actual.bytes_limit_when_visible = +@@ -129,23 +149,7 @@ cc::ManagedMemoryPolicy GetGpuMemoryPolicy( + } + actual.priority_cutoff_when_visible = + gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING; +-#else +- // Ignore what the system said and give all clients the same maximum +- // allocation on desktop platforms. +- actual.bytes_limit_when_visible = 512 * 1024 * 1024; +- actual.priority_cutoff_when_visible = +- gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; + +- // For large monitors (4k), double the tile memory to avoid frequent out of +- // memory problems. 4k could mean a screen width of anywhere from 3840 to 4096 +- // (see https://en.wikipedia.org/wiki/4K_resolution). We use 3500 as a proxy +- // for "large enough". +- static const int kLargeDisplayThreshold = 3500; +- int display_width = +- std::round(initial_screen_size.width() * initial_device_scale_factor); +- if (display_width >= kLargeDisplayThreshold) +- actual.bytes_limit_when_visible *= 2; +-#endif + return actual; + } + +@@ -187,13 +191,15 @@ cc::LayerTreeSettings GenerateLayerTreeSettings( + // Synchronous compositing indicates WebView. + if (!platform->IsSynchronousCompositingEnabledForAndroidWebView()) + settings.prefer_raster_in_srgb = ::features::IsDynamicColorGamutEnabled(); ++#endif + +- // We can use a more aggressive limit on Android since decodes tend to take +- // longer on these devices. ++#if defined(OS_ANDROID) || defined(OS_OHOS) ++ // We can use a more aggressive limit on Android or OHOS since decodes tend ++ // to take longer on these devices. + settings.min_image_bytes_to_checker = 512 * 1024; // 512kB + + // Re-rasterization of checker-imaged content with software raster can be too +- // costly on Android. ++ // costly on Android or OHOS. + settings.only_checker_images_with_gpu_raster = true; + #endif + +@@ -214,7 +220,7 @@ cc::LayerTreeSettings GenerateLayerTreeSettings( + }; + + int default_tile_size = 256; +-#if defined(OS_ANDROID) ++#if defined(OS_ANDROID) || defined(OS_OHOS) + const gfx::Size screen_size = + gfx::ScaleToFlooredSize(initial_screen_size, initial_device_scale_factor); + int display_width = screen_size.width(); +@@ -436,7 +442,32 @@ cc::LayerTreeSettings GenerateLayerTreeSettings( + + // TODO(danakj): Only do this on low end devices. + settings.create_low_res_tiling = true; ++#elif defined(OS_OHOS) ++ bool using_low_memory_policy = ++ base::SysInfo::IsLowEndDevice() && !IsSmallScreen(screen_size); ++ if (using_low_memory_policy) { ++ // On low-end we want to be very careful about killing other ++ // apps. So initially we use 50% more memory to avoid flickering ++ // or raster-on-demand. ++ settings.max_memory_for_prepaint_percentage = 67; ++ } else { ++ // On other devices we have increased memory excessively to avoid ++ // raster-on-demand already, so now we reserve 50% _only_ to avoid ++ // raster-on-demand, and use 50% of the memory otherwise. ++ settings.max_memory_for_prepaint_percentage = 50; ++ } + ++ if (ui::IsOverlayScrollbarEnabled()) { ++ settings.scrollbar_animator = cc::LayerTreeSettings::AURA_OVERLAY; ++ settings.scrollbar_fade_delay = ui::kOverlayScrollbarFadeDelay; ++ settings.scrollbar_fade_duration = ui::kOverlayScrollbarFadeDuration; ++ settings.scrollbar_thinning_duration = ++ ui::kOverlayScrollbarThinningDuration; ++ settings.scrollbar_flash_after_any_scroll_update = true; ++ } ++ ++ // TODO(danakj): Only do this on low end devices. ++ settings.create_low_res_tiling = true; + #else // defined(OS_ANDROID) + bool using_low_memory_policy = base::SysInfo::IsLowEndDevice(); + +diff --git a/src/third_party/blink/renderer/platform/widget/input/frame_widget_input_handler_impl.cc b/src/third_party/blink/renderer/platform/widget/input/frame_widget_input_handler_impl.cc +index c25f20c8939..c386abb63c9 +--- a/src/third_party/blink/renderer/platform/widget/input/frame_widget_input_handler_impl.cc ++++ b/src/third_party/blink/renderer/platform/widget/input/frame_widget_input_handler_impl.cc +@@ -420,4 +420,18 @@ FrameWidgetInputHandlerImpl::HandlingState::~HandlingState() { + widget_->set_is_pasting(original_pasting_value_); + } + ++#if BUILDFLAG(IS_OHOS) ++void FrameWidgetInputHandlerImpl::SelectAndCopy() { ++ RunOnMainThread(base::BindOnce( ++ [](base::WeakPtr widget, ++ base::WeakPtr handler) { ++ DCHECK_EQ(!!widget, !!handler); ++ if (!widget) ++ return; ++ handler->SelectAndCopy(); ++ }, ++ widget_, main_thread_frame_widget_input_handler_)); ++} ++#endif ++ + } // namespace blink +diff --git a/src/third_party/blink/renderer/platform/widget/input/frame_widget_input_handler_impl.h b/src/third_party/blink/renderer/platform/widget/input/frame_widget_input_handler_impl.h +index e77913bf6bc..83cf0d9607f +--- a/src/third_party/blink/renderer/platform/widget/input/frame_widget_input_handler_impl.h ++++ b/src/third_party/blink/renderer/platform/widget/input/frame_widget_input_handler_impl.h +@@ -95,7 +95,9 @@ class PLATFORM_EXPORT FrameWidgetInputHandlerImpl + void MoveRangeSelectionExtent(const gfx::Point& extent) override; + void ScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect) override; + void MoveCaret(const gfx::Point& point) override; +- ++#if BUILDFLAG(IS_OHOS) ++ void SelectAndCopy() override; ++#endif + private: + enum class UpdateState { kNone, kIsPasting, kIsSelectingRange }; + +diff --git a/src/third_party/blink/renderer/platform/widget/input/input_handler_proxy.cc b/src/third_party/blink/renderer/platform/widget/input/input_handler_proxy.cc +index 469d6671d19..1b03af48b78 +--- a/src/third_party/blink/renderer/platform/widget/input/input_handler_proxy.cc ++++ b/src/third_party/blink/renderer/platform/widget/input/input_handler_proxy.cc +@@ -1135,7 +1135,12 @@ InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureScrollEnd( + // started? https://crbug.com/1082601. + input_handler_->RecordScrollEnd( + GestureScrollInputType(gesture_event.SourceDevice())); +- ++ ++#if BUILDFLAG(IS_OHOS) ++ //After dragging the scrollbar by hand, ++ //we need to call MouseLeave() to make the scrollbar FADE_OUT. ++ input_handler_->MouseLeave(); ++#endif + if (scroll_sequence_ignored_) { + DCHECK(!currently_active_gesture_device_.has_value()); + return DROP_EVENT; +@@ -1156,7 +1161,6 @@ InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureScrollEnd( + HandleScrollElasticityOverscroll(gesture_event, + cc::InputHandlerScrollResult()); + } +- + return DID_HANDLE; + } + +diff --git a/src/third_party/blink/renderer/platform/widget/input/widget_input_handler_manager.cc b/src/third_party/blink/renderer/platform/widget/input/widget_input_handler_manager.cc +index a80b1294a54..ce2cb7a66f6 +--- a/src/third_party/blink/renderer/platform/widget/input/widget_input_handler_manager.cc ++++ b/src/third_party/blink/renderer/platform/widget/input/widget_input_handler_manager.cc +@@ -1005,4 +1005,13 @@ void WidgetInputHandlerManager::ClearClient() { + input_event_queue_->ClearClient(); + } + ++#if BUILDFLAG(IS_OHOS) ++void WidgetInputHandlerManager::SetZoomLevel(float magnify_delta, const gfx::Point& anchor) { ++ if (!input_handler_proxy_) { ++ return; ++ } ++ input_handler_proxy_->SynchronouslyZoomBy(magnify_delta, anchor); ++} ++#endif // BUILDFLAG(IS_OHOS) ++ + } // namespace blink +diff --git a/src/third_party/blink/renderer/platform/widget/input/widget_input_handler_manager.h b/src/third_party/blink/renderer/platform/widget/input/widget_input_handler_manager.h +index 8418e93a901..ed33e5bc663 +--- a/src/third_party/blink/renderer/platform/widget/input/widget_input_handler_manager.h ++++ b/src/third_party/blink/renderer/platform/widget/input/widget_input_handler_manager.h +@@ -173,6 +173,10 @@ class PLATFORM_EXPORT WidgetInputHandlerManager final + + MainThreadEventQueue* input_event_queue() { return input_event_queue_.get(); } + ++#if BUILDFLAG(IS_OHOS) ++ void SetZoomLevel(float magnify_delta, const gfx::Point& anchor); ++#endif // BUILDFLAG(IS_OHOS) ++ + protected: + friend class base::RefCountedThreadSafe; + ~WidgetInputHandlerManager() override; +diff --git a/src/third_party/blink/renderer/platform/widget/widget_base.cc b/src/third_party/blink/renderer/platform/widget/widget_base.cc +index 7980b4b20fc..d90bec4d678 +--- a/src/third_party/blink/renderer/platform/widget/widget_base.cc ++++ b/src/third_party/blink/renderer/platform/widget/widget_base.cc +@@ -1645,4 +1645,13 @@ gfx::RectF WidgetBase::BlinkSpaceToDIPs(const gfx::RectF& rect) { + return gfx::ScaleRect(rect, reverse); + } + ++#if BUILDFLAG(IS_OHOS) ++void WidgetBase::SetZoomLevel(float magnify_delta, const gfx::Point& anchor) { ++ if (!widget_input_handler_manager_) { ++ return; ++ } ++ widget_input_handler_manager_->SetZoomLevel(magnify_delta, anchor); ++} ++#endif // BUILDFLAG(IS_OHOS) ++ + } // namespace blink +diff --git a/src/third_party/blink/renderer/platform/widget/widget_base.h b/src/third_party/blink/renderer/platform/widget/widget_base.h +index bf6f8f2ec42..43e9e151829 +--- a/src/third_party/blink/renderer/platform/widget/widget_base.h ++++ b/src/third_party/blink/renderer/platform/widget/widget_base.h +@@ -358,6 +358,10 @@ class PLATFORM_EXPORT WidgetBase : public mojom::blink::Widget, + return local_surface_id_from_parent_; + } + ++#if BUILDFLAG(IS_OHOS) ++ void SetZoomLevel(float magnify_delta, const gfx::Point& anchor); ++#endif // BUILDFLAG(IS_OHOS) ++ + private: + bool CanComposeInline(); + void UpdateTextInputStateInternal(bool show_virtual_keyboard, +diff --git a/src/third_party/blink/web_tests/external/wpt/css/css-typed-om/the-stylepropertymap/inline/append.tentative.html b/src/third_party/blink/web_tests/external/wpt/css/css-typed-om/the-stylepropertymap/inline/append.tentative.html +index ee9a9e4ddbc..f8087562236 +--- a/src/third_party/blink/web_tests/external/wpt/css/css-typed-om/the-stylepropertymap/inline/append.tentative.html ++++ b/src/third_party/blink/web_tests/external/wpt/css/css-typed-om/the-stylepropertymap/inline/append.tentative.html +@@ -56,4 +56,10 @@ test(t => { + assert_style_value_array_equals(result, [CSS.s(5), CSS.s(10), CSS.s(1), CSS.s(2)]); + }, 'StylePropertyMap.append is case-insensitive'); + ++// https://crbug.com/1417176 ++test(t => { ++ let styleMap = createInlineStyleMap(t, 'transition-duration: inherit'); ++ assert_throws_js(TypeError, () => styleMap.append('transition-duration', '1s')); ++}, 'StylePropertyMap.append rejects appending to CSS-wide keywords'); ++ + +diff --git a/src/third_party/blink/web_tests/http/tests/devtools/show-context-menu-expected.txt b/src/third_party/blink/web_tests/http/tests/devtools/show-context-menu-expected.txt +new file mode 100644 +index 00000000000..8e61d9ba97e +--- /dev/null ++++ b/src/third_party/blink/web_tests/http/tests/devtools/show-context-menu-expected.txt +@@ -0,0 +1,3 @@ ++Tests type checks in DevToolsHost.showContextMenuAtPoint ++ ++ +diff --git a/src/third_party/blink/web_tests/http/tests/devtools/show-context-menu.js b/src/third_party/blink/web_tests/http/tests/devtools/show-context-menu.js +new file mode 100644 +index 00000000000..418e17bd231 +--- /dev/null ++++ b/src/third_party/blink/web_tests/http/tests/devtools/show-context-menu.js +@@ -0,0 +1,10 @@ ++// Copyright 2023 The Chromium Authors ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++(async function() { ++ TestRunner.addResult(`Tests type checks in DevToolsHost.showContextMenuAtPoint\n`); ++ InspectorFrontendHost.showContextMenuAtPoint(1.1, 2.2, [0x41414141]); ++ TestRunner.completeTest(); ++})(); ++ +diff --git a/src/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc b/src/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc +index b7e8118d69c..067d44eb539 +--- a/src/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc ++++ b/src/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc +@@ -101,6 +101,10 @@ + #include "linux/sched.h" + #endif + ++//#if BUILDFLAG(IS_OHOS) ++#include "build/build_config.h" ++//#endif // BUILDFLAG(IS_OHOS) ++ + #ifndef PR_SET_PTRACER + #define PR_SET_PTRACER 0x59616d61 + #endif +@@ -383,6 +387,9 @@ void ExceptionHandler::SignalHandler(int sig, siginfo_t* info, void* uc) { + // be delivered to the appropriate handler. + if (handled) { + InstallDefaultHandler(sig); ++#if BUILDFLAG(IS_OHOS) ++ RestoreHandlersLocked(); ++#endif // BUILDFLAG(IS_OHOS) + } else { + RestoreHandlersLocked(); + } +diff --git a/src/third_party/breakpad/breakpad/src/client/linux/handler/minidump_descriptor.cc b/src/third_party/breakpad/breakpad/src/client/linux/handler/minidump_descriptor.cc +index bd94474e9ac..c62bba0f978 +--- a/src/third_party/breakpad/breakpad/src/client/linux/handler/minidump_descriptor.cc ++++ b/src/third_party/breakpad/breakpad/src/client/linux/handler/minidump_descriptor.cc +@@ -33,6 +33,12 @@ + + #include "common/linux/guid_creator.h" + ++#include "base/base_switches.h" ++#if BUILDFLAG(IS_OHOS) ++#include "base/strings/string_util.h" ++#include "base/strings/stringprintf.h" ++#endif // BUILDFLAG(IS_OHOS) ++ + namespace google_breakpad { + + //static +@@ -90,7 +96,13 @@ void MinidumpDescriptor::UpdatePath() { + } + + path_.clear(); ++ ++#if BUILDFLAG(IS_OHOS) ++ path_ = directory_ + "/nweb-browser-minidump-" + guid_str + ".dmp"; ++#else + path_ = directory_ + "/" + guid_str + ".dmp"; ++#endif // BUILDFLAG(IS_OHOS) ++ + c_path_ = path_.c_str(); + } + +diff --git a/src/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.cc b/src/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.cc +index 44430c4e960..cf32e8a5f9e +--- a/src/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.cc ++++ b/src/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.cc +@@ -53,6 +53,10 @@ + #include "google_breakpad/common/minidump_exception_linux.h" + #include "third_party/lss/linux_syscall_support.h" + ++#if defined(OSOHOS) ++#include "base/base_switches.h" ++#endif // defined(OSOHOS) ++ + using google_breakpad::elf::FileID; + + #if defined(__ANDROID__) +@@ -347,8 +351,13 @@ LinuxDumper::ElfFileIdentifierForMapping(const MappingInfo& mapping, + if (!mapped_file.data() || mapped_file.size() < SELFMAG) + return false; + ++#if BUILDFLAG(IS_OHOS) ++ bool success = true; ++#else + bool success = + FileID::ElfFileIdentifierFromMappedFile(mapped_file.data(), identifier); ++#endif // BUILDFLAG(IS_OHOS) ++ + if (success && member && filename_modified) { + mappings_[mapping_id]->name[my_strlen(mapping.name) - + sizeof(kDeletedSuffix) + 1] = '\0'; +diff --git a/src/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc b/src/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc +index e3ddb81a659..6fcc3d0a953 +--- a/src/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc ++++ b/src/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc +@@ -176,7 +176,7 @@ bool LinuxPtraceDumper::ReadRegisters(ThreadInfo* info, pid_t tid) { + return false; + } + +-#if !(defined(__ANDROID__) && defined(__ARM_EABI__)) ++#if !(defined(__ANDROID__) || defined(__ARM_EABI__)) + // When running an arm build on an arm64 device, attempting to get the + // floating point registers fails. On Android, the floating point registers + // aren't written to the cpu context anyway, so just don't get them here. +diff --git a/src/third_party/catapult/.vpython b/src/third_party/catapult/.vpython +index 56cc3a986dc..2a3172b783a +--- a/src/third_party/catapult/.vpython ++++ b/src/third_party/catapult/.vpython +@@ -45,7 +45,7 @@ wheel: < + > + wheel: < + name: "infra/python/wheels/werkzeug-py2_py3" +- version: "version:0.15.2" ++ version: "version:1.0.1" + > + wheel: < + name: "infra/python/wheels/click-py2_py3" +@@ -183,3 +183,10 @@ wheel: < + platform: "win_amd64" + > + > ++ ++# Used by: ++# telemetry/telemetry/internal/backends/chrome/remote_cast_browser_backend.py ++wheel: < ++ name: "infra/python/wheels/pexpect/${vpython_platform}" ++ version: "version:4.8.0.chromium.1" ++> +diff --git a/src/third_party/catapult/.vpython3 b/src/third_party/catapult/.vpython3 +index 37aed412253..d4a790afa9d +--- a/src/third_party/catapult/.vpython3 ++++ b/src/third_party/catapult/.vpython3 +@@ -31,18 +31,215 @@ python_version: "3.8" + # //telemetry/telemetry/internal/util/external_modules.py + wheel: < + name: "infra/python/wheels/numpy/${vpython_platform}" +- version: "version:1.20.3" +- # A newer version of numpy is required on ARM64, but it breaks older OS versions. ++ version: "version:1.2x.supported.1" ++> ++wheel: < ++ name: "infra/python/wheels/opencv_python/${vpython_platform}" ++ version: "version:4.5.3.56.chromium.4" ++ # There is currently no Linux arm/arm64 version in CIPD. + not_match_tag < +- platform: "macosx_11_0_arm64" ++ platform: "linux_aarch64" + > + > ++ ++# Used by: ++# vpython3 bin/run_py_test ++# This is used in pre-submit try jobs, which used to rely on gae-sdk from cipd, ++# and in post-submit cloud biulds, which used to rely on google/cloud-sdk ++# docker image. Both sources are out of date and do not support python 3. + wheel: < +- name: "infra/python/wheels/numpy/mac-arm64_cp38_cp38" +- version: "version:1.21.1" +- match_tag < +- platform: "macosx_11_0_arm64" +- > ++ name: "infra/python/wheels/appengine-python-standard-py3" ++ version: "version:0.3.1" ++> ++ ++wheel: < ++ name: "infra/python/wheels/frozendict-py3" ++ version: "version:2.0.6" ++> ++ ++wheel: < ++ name: "infra/python/wheels/google-auth-py2_py3" ++ version: "version:1.35.0" ++> ++ ++wheel: < ++ name: "infra/python/wheels/pytz-py2_py3" ++ version: "version:2021.1" ++> ++ ++wheel: < ++ name: "infra/python/wheels/mock-py3" ++ version: "version:4.0.3" ++> ++ ++wheel: < ++ name: "infra/python/wheels/ruamel_yaml-py3" ++ version: "version:0.17.16" ++> ++ ++wheel: < ++ name: "infra/python/wheels/pyasn1_modules-py2_py3" ++ version: "version:0.2.8" ++> ++ ++wheel: < ++ name: "infra/python/wheels/rsa-py3" ++ version: "version:4.7.2" ++> ++ ++wheel: < ++ name: "infra/python/wheels/cachetools-py3" ++ version: "version:4.2.2" ++> ++ ++wheel: < ++ name: "infra/python/wheels/pyasn1-py2_py3" ++ version: "version:0.4.8" ++> ++ ++wheel: < ++ name: "infra/python/wheels/charset_normalizer-py3" ++ version: "version:2.0.4" ++> ++ ++wheel: < ++ name: "infra/python/wheels/ruamel_yaml_clib/${vpython_platform}" ++ version: "version:0.2.6" ++> ++ ++wheel: < ++ name: "infra/python/wheels/httplib2-py3" ++ version: "version:0.19.1" ++> ++ ++wheel: < ++ name: "infra/python/wheels/pyparsing-py2_py3" ++ version: "version:2.4.7" ++> ++ ++wheel: < ++ name: "infra/python/wheels/google-api-python-client-py3" ++ version: "version:2.2.0" ++> ++ ++wheel: < ++ name: "infra/python/wheels/google-auth-httplib2-py2_py3" ++ version: "version:0.1.0" ++> ++ ++wheel: < ++ name: "infra/python/wheels/google-api-core-py3" ++ version: "version:1.31.5" ++> ++ ++wheel: < ++ name: "infra/python/wheels/googleapis-common-protos-py2_py3" ++ version: "version:1.52.0" ++> ++ ++wheel: < ++ name: "infra/python/wheels/uritemplate-py2_py3" ++ version: "version:3.0.0" ++> ++ ++wheel: < ++ name: "infra/python/wheels/webtest-py2_py3" ++ version: "version:2.0.35" ++> ++ ++wheel: < ++ name: "infra/python/wheels/webob-py2_py3" ++ version: "version:1.8.6" ++> ++ ++wheel: < ++ name: "infra/python/wheels/waitress-py2_py3" ++ version: "version:1.4.3" ++> ++ ++wheel: < ++ name: "infra/python/wheels/beautifulsoup4-py3" ++ version: "version:4.9.0" ++> ++ ++wheel: < ++ name: "infra/python/wheels/soupsieve-py2_py3" ++ version: "version:1.9.5" ++> ++ ++wheel: < ++ name: "infra/python/wheels/jinja2-py2_py3" ++ version: "version:2.10.1" ++> ++ ++wheel: < ++ name: "infra/python/wheels/markupsafe/${vpython_platform}" ++ version: "version:1.1.1" ++> ++ ++wheel: < ++ name: "infra/python/wheels/infra_libs-py2_py3" ++ version: "version:2.3.0" ++> ++ ++wheel: < ++ name: "infra/python/wheels/oauth2client-py2_py3" ++ version: "version:3.0.0" ++> ++ ++wheel: < ++ name: "infra/python/wheels/google-cloud-logging-py3" ++ version: "version:3.0.0" ++> ++ ++wheel: < ++ name: "infra/python/wheels/google-cloud-core-py3" ++ version: "version:2.2.2" ++> ++ ++wheel: < ++ name: "infra/python/wheels/google-cloud-audit-log-py2_py3" ++ version: "version:0.2.0" ++> ++ ++wheel: < ++ name: "infra/python/wheels/grpc-google-iam-v1-py3" ++ version: "version:0.12.3" ++> ++ ++wheel: < ++ name: "infra/python/wheels/proto-plus-py3" ++ version: "version:1.20.3" ++> ++ ++wheel: < ++ name: "infra/python/wheels/google-cloud-appengine-logging-py2_py3" ++ version: "version:1.1.1" ++> ++ ++wheel: < ++ name: "infra/python/wheels/grpcio/${vpython_platform}" ++ version: "version:1.44.0" ++> ++ ++wheel: < ++ name: "infra/python/wheels/flask-py2_py3" ++ version: "version:1.0.2" ++> ++ ++wheel: < ++ name: "infra/python/wheels/werkzeug-py2_py3" ++ version: "version:1.0.1" ++> ++ ++wheel: < ++ name: "infra/python/wheels/itsdangerous-py2_py3" ++ version: "version:1.1.0" ++> ++ ++wheel: < ++ name: "infra/python/wheels/click-py2_py3" ++ version: "version:7.0" + > + + # Used by: +@@ -60,10 +257,16 @@ wheel: < + + # Used by: + # build/android/pylib/local/emulator/avd.py +-# components/policy/test_support/policy_testserver.py + wheel: < +- name: "infra/python/wheels/protobuf-py2_py3" +- version: "version:3.6.1" ++ name: "infra/python/wheels/protobuf-py3" ++ version: "version:4.21.1" ++> ++ ++# Used by: ++# //third_party/catapult/telemetry/telemetry/internal/backends/chrome/remote_cast_browser_backend.py ++wheel: < ++ name: "infra/python/wheels/pexpect/${vpython_platform}" ++ version: "version:4.8.0.chromium.1" + > + + # TODO(https://crbug.com/898348): Add in necessary wheels as Python3 versions +@@ -92,14 +295,9 @@ wheel: < + > + wheel: < + name: "infra/python/wheels/requests-py2_py3" +- version: "version:2.13.0" ++ version: "version:2.26.0" + > + +-# Used by various python unit tests. +-wheel: < +- name: "infra/python/wheels/mock-py2_py3" +- version: "version:2.0.0" +-> + wheel: < + name: "infra/python/wheels/parameterized-py2_py3" + version: "version:0.7.1" +@@ -149,7 +347,7 @@ wheel: < + > + wheel: < + name: "infra/python/wheels/urllib3-py2_py3" +- version: "version:1.24.3" ++ version: "version:1.26.6" + > + wheel: < + name: "infra/python/wheels/blessings-py2_py3" +@@ -200,11 +398,6 @@ wheel: < + version: "version:16.8" + > + +-wheel: < +- name: "infra/python/wheels/pyparsing-py2_py3" +- version: "version:2.2.0" +-> +- + wheel: < + name: "infra/python/wheels/toml-py3" + version: "version:0.10.1" +@@ -222,7 +415,7 @@ wheel < + + wheel < + name: "infra/python/wheels/attrs-py2_py3" +- version: "version:20.3.0" ++ version: "version:21.4.0" + > + + wheel < +diff --git a/src/third_party/catapult/BUILD.gn b/src/third_party/catapult/BUILD.gn +index 04e01dc63fc..b3baf3d1f6c +--- a/src/third_party/catapult/BUILD.gn ++++ b/src/third_party/catapult/BUILD.gn +@@ -29,7 +29,6 @@ group("telemetry_chrome_test_support") { + "catapult_build/", + "dashboard/", + "dependency_manager/", +- "firefighter/", + "hooks/", + "infra/", + "netlog_viewer/", +@@ -60,10 +59,12 @@ group("telemetry_chrome_test_support") { + "third_party/certifi/", + "third_party/chai/", + "third_party/chardet/", ++ "third_party/click/", + "third_party/cloudstorage/", + "third_party/coverage/", + "third_party/d3/", + "third_party/depot_tools/", ++ "third_party/flask/", + "third_party/flot/", + "third_party/gae_ts_mon/", + "third_party/google-auth/", +@@ -74,9 +75,12 @@ group("telemetry_chrome_test_support") { + "third_party/idb/", + "third_party/idna/", + "third_party/ijson/", ++ "third_party/itsdangerous/", ++ "third_party/jinja2/", + "third_party/jquery/", + "third_party/jszip/", + "third_party/mapreduce/", ++ "third_party/markupsafe/", + "third_party/mocha/", + "third_party/mock/", + "third_party/mox3/", +@@ -89,7 +93,6 @@ group("telemetry_chrome_test_support") { + "third_party/pyasn1_modules/", + "third_party/pyfakefs/", + "third_party/pyparsing/", +- "third_party/pyserial/", + "third_party/python_gflags/", + "third_party/redux/", + "third_party/requests/", +@@ -97,13 +100,13 @@ group("telemetry_chrome_test_support") { + "third_party/rsa/", + "third_party/six/", + "third_party/snap-it/", +- "third_party/tsmon_client/", + "third_party/tsproxy/", + "third_party/uritemplate/", + "third_party/urllib3/", + "third_party/webapp2/", + "third_party/webencodings-0.5.1/", + "third_party/webtest/", ++ "third_party/werkzeug/", + ] + + data_deps += [ +diff --git a/src/third_party/catapult/CONTRIBUTING.md b/src/third_party/catapult/CONTRIBUTING.md +index fc690d39638..c4685d66f32 +--- a/src/third_party/catapult/CONTRIBUTING.md ++++ b/src/third_party/catapult/CONTRIBUTING.md +@@ -5,7 +5,7 @@ + # Code of Conduct + + We follow the [Chromium code of conduct]( +-https://chromium.googlesource.com/chromium/src/+/master/CODE_OF_CONDUCT.md) in ++https://chromium.googlesource.com/chromium/src/+/main/CODE_OF_CONDUCT.md) in + our our repos and organizations, mailing lists, and other communications. + + # Issues +@@ -34,7 +34,7 @@ You can then create a local branch, make and commit your change. + + ``` + cd catapult +-git checkout -t -b foo origin/master ++git checkout -t -b foo origin/main + ... edit files ... + git commit -a -m "New files" + ``` +@@ -57,7 +57,7 @@ Then, submit your changes through the commit queue by checking the "Commit" box. + Once everything is landed, you can cleanup your branch. + + ``` +-git checkout master ++git checkout main + git branch -D foo + ``` + +diff --git a/src/third_party/catapult/OWNERS b/src/third_party/catapult/OWNERS +index d8ecbdffbc3..8cfc97d7440 +--- a/src/third_party/catapult/OWNERS ++++ b/src/third_party/catapult/OWNERS +@@ -2,7 +2,6 @@ abennetts@google.com + bsheedy@chromium.org + dproy@chromium.org + fmmirzaei@google.com +-heiserya@google.com + johnchen@chromium.org + seanmccullough@google.com + wenbinzhang@google.com +diff --git a/src/third_party/catapult/PRESUBMIT.py b/src/third_party/catapult/PRESUBMIT.py +index 70bd88b87c1..1f0e8de0fc1 +--- a/src/third_party/catapult/PRESUBMIT.py ++++ b/src/third_party/catapult/PRESUBMIT.py +@@ -7,9 +7,12 @@ + See https://www.chromium.org/developers/how-tos/depottools/presubmit-scripts + for more details about the presubmit API built into depot_tools. + """ ++ + import re + import sys + ++USE_PYTHON3 = True ++ + _EXCLUDED_PATHS = ( + r'(.*[\\/])?\.git[\\/].*', + r'.+\.png$', +@@ -48,7 +51,8 @@ _EXCLUDED_PATHS = ( + + _GITHUB_BUG_ID_RE = re.compile(r'#[1-9]\d*') + _MONORAIL_BUG_ID_RE = re.compile(r'[1-9]\d*') +-_MONORAIL_PROJECT_NAMES = frozenset({'chromium', 'v8', 'angleproject', 'skia'}) ++_MONORAIL_PROJECT_NAMES = frozenset( ++ {'chromium', 'v8', 'angleproject', 'skia', 'dawn'}) + + def CheckChangeLogBug(input_api, output_api): + # Show a presubmit message if there is no Bug line or an empty Bug line. +@@ -126,7 +130,7 @@ def CheckChangeOnUpload(input_api, output_api): + results = CheckChange(input_api, output_api) + cwd = input_api.PresubmitLocalPath() + exit_code = input_api.subprocess.call( +- [input_api.python_executable, 'generate_telemetry_build.py', '--check'], ++ [input_api.python3_executable, 'generate_telemetry_build.py', '--check'], + cwd=cwd) + if exit_code != 0: + results.append(output_api.PresubmitError( +diff --git a/src/third_party/catapult/bin/run_dev_server b/src/third_party/catapult/bin/run_dev_server +index b1cb6c0a305..59bda1368e7 +--- a/src/third_party/catapult/bin/run_dev_server ++++ b/src/third_party/catapult/bin/run_dev_server +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env vpython + # Copyright (c) 2015 The Chromium Authors. All rights reserved. + # Use of this source code is governed by a BSD-style license that can be + # found in the LICENSE file. +diff --git a/src/third_party/catapult/bin/run_tests b/src/third_party/catapult/bin/run_tests +index 29e5fccc363..217def3971f +--- a/src/third_party/catapult/bin/run_tests ++++ b/src/third_party/catapult/bin/run_tests +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env vpython + # Copyright (c) 2015 The Chromium Authors. All rights reserved. + # Use of this source code is governed by a BSD-style license that can be + # found in the LICENSE file. +diff --git a/src/third_party/catapult/catapult_build/__init__.py b/src/third_party/catapult/catapult_build/__init__.py +index 5ec82ffc84c..d2a9b164252 +--- a/src/third_party/catapult/catapult_build/__init__.py ++++ b/src/third_party/catapult/catapult_build/__init__.py +@@ -20,10 +20,15 @@ def _UpdateSysPathIfNeeded(): + if sys.version_info.major == 2: + _AddToPathIfNeeded( + os.path.join(catapult_third_party_path, 'beautifulsoup4')) ++ _AddToPathIfNeeded( ++ os.path.join(catapult_third_party_path, 'html5lib-python')) + else: + _AddToPathIfNeeded( + os.path.join(catapult_third_party_path, 'beautifulsoup4-4.9.3', 'py3k')) +- _AddToPathIfNeeded(os.path.join(catapult_third_party_path, 'html5lib-python')) ++ _AddToPathIfNeeded( ++ os.path.join(catapult_third_party_path, 'html5lib-1.1')) ++ _AddToPathIfNeeded( ++ os.path.join(catapult_third_party_path, 'webencodings-0.5.1')) + _AddToPathIfNeeded(os.path.join(catapult_third_party_path, 'six')) + _AddToPathIfNeeded(os.path.join(catapult_third_party_path, 'Paste')) + _AddToPathIfNeeded(os.path.join(catapult_third_party_path, 'webapp2')) +diff --git a/src/third_party/catapult/catapult_build/appengine_dev_server.py b/src/third_party/catapult/catapult_build/appengine_dev_server.py +index 97a9c206650..ae3852eb3b1 +--- a/src/third_party/catapult/catapult_build/appengine_dev_server.py ++++ b/src/third_party/catapult/catapult_build/appengine_dev_server.py +@@ -50,10 +50,13 @@ def _AddTempDirToYamlPathArgs(temp_dir, args): + """Join `temp_dir` to the positional args, preserving the other args.""" + parser = argparse.ArgumentParser() + parser.add_argument('yaml_path', nargs='*') ++ parser.add_argument('--run_pinpoint', default=False, action='store_true') + options, remaining_args = parser.parse_known_args(args) + yaml_path_args = [ + os.path.join(temp_dir, yaml_path) for yaml_path in options.yaml_path + ] + if not yaml_path_args: ++ if options.run_pinpoint: ++ temp_dir += '/pinpoint.yaml' + yaml_path_args = [temp_dir] + return yaml_path_args + remaining_args + diff --git a/src/third_party/catapult/catapult_build/build_steps.py b/src/third_party/catapult/catapult_build/build_steps.py +index 84df5ac1e18..d79ef0d5e57 +--- a/src/third_party/catapult/catapult_build/build_steps.py ++++ b/src/third_party/catapult/catapult_build/build_steps.py +@@ -17,6 +17,8 @@ import sys + # environment. + # disabled (optional): List of platforms the test is disabled on. May contain + # 'win', 'mac', 'linux', or 'android'. ++# python_versions (optional): A list of ints specifying the Python versions to ++# run on. May contain "2" or "3". Defaults to running on both. + # outputs_presentation_json (optional): If True, pass in --presentation-json + # argument to the test executable to allow it to update the buildbot status + # page. More details here: +@@ -95,6 +97,7 @@ _CATAPULT_TESTS = [ + 'additional_args': ['--browser=reference',], + 'uses_sandbox_env': True, + 'disabled': ['android'], ++ 'python_versions': [3], + }, + { + 'name': 'Telemetry Tests with Stable Browser (Desktop)', +@@ -106,6 +109,7 @@ _CATAPULT_TESTS = [ + ], + 'uses_sandbox_env': True, + 'disabled': ['android'], ++ 'python_versions': [3], + }, + { + 'name': 'Telemetry Tests with Stable Browser (Android)', +@@ -117,7 +121,8 @@ _CATAPULT_TESTS = [ + '-v', + ], + 'uses_sandbox_env': True, +- 'disabled': ['win', 'mac', 'linux'] ++ 'disabled': ['win', 'mac', 'linux'], ++ 'python_versions': [3], + }, + { + 'name': 'Telemetry Integration Tests with Stable Browser', +@@ -129,6 +134,7 @@ _CATAPULT_TESTS = [ + ], + 'uses_sandbox_env': True, + 'disabled': ['android', 'linux'], # TODO(nedn): enable this on linux ++ 'python_versions': [3], + }, + { + 'name': 'Tracing Dev Server Tests', +@@ -203,6 +209,7 @@ def main(args=None): + '--app-engine-sdk-pythonpath', + help='PYTHONPATH to include app engine SDK path') + parser.add_argument('--platform', help='Platform name (linux, mac, or win)') ++ parser.add_argument('--platform_arch', help='Platform arch (intel or arm)') + parser.add_argument('--output-json', help='Output for buildbot status page') + parser.add_argument( + '--run_android_tests', default=True, help='Run Android tests') +@@ -218,23 +225,26 @@ def main(args=None): + action='store_true') + args = parser.parse_args(args) + +- dashboard_protos_path = os.path.join(args.api_path_checkout, 'dashboard', ++ dashboard_protos_folder = os.path.join(args.api_path_checkout, 'dashboard', + 'dashboard', 'proto') + dashboard_proto_files = [ +- os.path.join(dashboard_protos_path, p) ++ os.path.join(dashboard_protos_folder, p) + for p in ['sheriff.proto', 'sheriff_config.proto'] + ] + ++ dashboard_protos_path = os.path.join(args.api_path_checkout, 'dashboard') ++ + sheriff_proto_output_path = os.path.join(args.api_path_checkout, 'dashboard', + 'dashboard', 'sheriff_config') + dashboard_proto_output_path = os.path.join(args.api_path_checkout, +- 'dashboard', 'dashboard') ++ 'dashboard') + + tracing_protos_path = os.path.join(args.api_path_checkout, 'tracing', + 'tracing', 'proto') + tracing_proto_output_path = tracing_protos_path + tracing_proto_files = [os.path.join(tracing_protos_path, 'histogram.proto')] + ++ protoc_path = 'protoc' + + steps = [ + { +@@ -257,7 +267,7 @@ def main(args=None): + 'name': + 'Generate Sheriff Config protocol buffers', + 'cmd': [ +- 'protoc', ++ protoc_path, + '--proto_path', + dashboard_protos_path, + '--python_out', +@@ -268,7 +278,7 @@ def main(args=None): + 'name': + 'Generate Dashboard protocol buffers', + 'cmd': [ +- 'protoc', ++ protoc_path, + '--proto_path', + dashboard_protos_path, + '--python_out', +@@ -279,7 +289,7 @@ def main(args=None): + 'name': + 'Generate Tracing protocol buffers', + 'cmd': [ +- 'protoc', ++ protoc_path, + '--proto_path', + tracing_protos_path, + '--python_out', +@@ -336,6 +346,10 @@ def main(args=None): + if args.platform in test.get('disabled', []): + continue + ++ python_version = 3 if args.use_python3 else 2 ++ if python_version not in test.get('python_versions', [2, 3]): ++ continue ++ + # The test "Devil Python Tests" has two executables, run_py_tests and + # run_py3_tests. Those scripts define the vpython interpreter on shebang, + # and will quit when running on unexpected version. This script assumes one +@@ -379,6 +393,7 @@ def main(args=None): + if args.use_python3: + step['always_run'] = True + steps.append(step) ++ + with open(args.output_json, 'w') as outfile: + json.dump(steps, outfile) + +diff --git a/src/third_party/catapult/catapult_build/run_dev_server_tests.py b/src/third_party/catapult/catapult_build/run_dev_server_tests.py +index 2616efd70fc..025a50cd2b1 +--- a/src/third_party/catapult/catapult_build/run_dev_server_tests.py ++++ b/src/third_party/catapult/catapult_build/run_dev_server_tests.py +@@ -209,6 +209,7 @@ def RunTests(args, chrome_path): + '--enable-logging', '--v=1', + '--enable-features=ForceWebRequestProxyForTest', + '--force-device-scale-factor=1', ++ '--use-mock-keychain', + ] + if args.extra_chrome_args: + chrome_command.extend(args.extra_chrome_args.strip('"').split(' ')) +diff --git a/src/third_party/catapult/common/bin/update_chrome_reference_binaries.py b/src/third_party/catapult/common/bin/update_chrome_reference_binaries.py +index 2131aa66984..c4a388a9332 +--- a/src/third_party/catapult/common/bin/update_chrome_reference_binaries.py ++++ b/src/third_party/catapult/common/bin/update_chrome_reference_binaries.py +@@ -45,7 +45,8 @@ _CHROMIUM_SNAPSHOT_SEARCH_WINDOW = 10 + + # Remove a platform name from this list to disable updating it. + # Add one to enable updating it. (Must also update _PLATFORM_MAP.) +-_PLATFORMS_TO_UPDATE = ['mac_x86_64', 'win_x86', 'win_AMD64', 'linux_x86_64', ++_PLATFORMS_TO_UPDATE = ['mac_arm64', 'mac_x86_64', 'win_x86', ++ 'win_AMD64', 'linux_x86_64', + 'android_k_armeabi-v7a', 'android_l_arm64-v8a', + 'android_l_armeabi-v7a', 'android_n_armeabi-v7a', + 'android_n_arm64-v8a', 'android_n_bundle_armeabi-v7a', +@@ -53,7 +54,8 @@ _PLATFORMS_TO_UPDATE = ['mac_x86_64', 'win_x86', 'win_AMD64', 'linux_x86_64', + + # Add platforms here if you also want to update chromium binary for it. + # Must add chromium_info for it in _PLATFORM_MAP. +-_CHROMIUM_PLATFORMS = ['mac_x86_64', 'win_x86', 'win_AMD64', 'linux_x86_64'] ++_CHROMIUM_PLATFORMS = ['mac_arm64', 'mac_x86_64', 'win_x86', 'win_AMD64', ++ 'linux_x86_64'] + + # Remove a channel name from this list to disable updating it. + # Add one to enable updating it. +@@ -62,7 +64,8 @@ _CHANNELS_TO_UPDATE = ['stable', 'canary', 'dev'] + + # Omaha is Chrome's autoupdate server. It reports the current versions used + # by each platform on each channel. +-_OMAHA_PLATFORMS = { 'stable': ['mac', 'linux', 'win', 'android'], ++_OMAHA_PLATFORMS = { 'stable': ['mac_arm64', 'mac', 'linux', 'win', ++ 'win64', 'android'], + 'dev': ['linux'], 'canary': ['mac', 'win']} + + +@@ -85,6 +88,15 @@ _PLATFORM_MAP = {'mac_x86_64': UpdateInfo( + build_dir='Mac', + zip_name='chrome-mac.zip'), + zip_name='chrome-mac.zip'), ++ 'mac_arm64': UpdateInfo( ++ omaha='mac_arm64', ++ gs_folder='desktop-*', ++ gs_build='mac-arm64', ++ chromium_info=ChromiumInfo( ++ build_dir='Mac_Arm', ++ zip_name='chrome-mac.zip', ++ ), ++ zip_name='chrome-mac.zip'), + 'win_x86': UpdateInfo( + omaha='win', + gs_folder='desktop-*', +@@ -151,10 +163,8 @@ _PLATFORM_MAP = {'mac_x86_64': UpdateInfo( + gs_build='arm_64', + chromium_info=None, + zip_name='Monochrome.apks') +- + } + +- + VersionInfo = collections.namedtuple('VersionInfo', + 'version, branch_base_position') + +@@ -173,7 +183,7 @@ def _ChannelVersionsMap(channel): + def _OmahaReportVersionInfo(channel): + url ='https://omahaproxy.appspot.com/all?channel=%s' % channel + lines = six.moves.urllib.request.urlopen(url).readlines() +- return [l.split(',') for l in lines] ++ return [six.ensure_str(l).split(',') for l in lines] + + + def _OmahaVersionsMap(rows, channel): +@@ -229,8 +239,8 @@ def _FindClosestChromiumSnapshot(base_position, build_dir): + # positions between 123446 an 123466. We do this by getting all snapshots + # with prefix 12344*, 12345*, and 12346*. This may get a few more snapshots + # that we intended, but that's fine since we take the min distance anyways. +- min_position_prefix = min_position / 10; +- max_position_prefix = max_position / 10; ++ min_position_prefix = min_position // 10; ++ max_position_prefix = max_position // 10; + + available_positions = [] + for position_prefix in range(min_position_prefix, max_position_prefix + 1): +@@ -318,7 +328,7 @@ def _ModifyBuildIfNeeded(binary, location, platform): + if binary != 'chrome': + return + +- if platform == 'mac_x86_64': ++ if platform in ['mac_x86_64', 'mac_arm64']: + _RemoveKeystoneFromBuild(location) + return + +diff --git a/src/third_party/catapult/common/py_utils/py_utils/chrome_binaries.json b/src/third_party/catapult/common/py_utils/py_utils/chrome_binaries.json +index 03f0afd3476..04173ec6dae +--- a/src/third_party/catapult/common/py_utils/py_utils/chrome_binaries.json ++++ b/src/third_party/catapult/common/py_utils/py_utils/chrome_binaries.json +@@ -88,6 +88,12 @@ + "path_within_archive": "chrome-mac/Google Chrome.app/Contents/MacOS/Google Chrome", + "version_in_cs": "83.0.4103.97" + }, ++ "mac_arm64": { ++ "cloud_storage_hash": "8e5715ab04cdf366a20038b6d6aac2f41e12bbf0", ++ "download_path": "bin/reference_build/chrome-mac-arm64.zip", ++ "path_within_archive": "chrome-mac/Google Chrome.app/Contents/MacOS/Google Chrome", ++ "version_in_cs": "100.0.4896.75" ++ }, + "win_AMD64": { + "cloud_storage_hash": "e6515496ebab0d02a5294a008fe8bbf9dd3dbc0c", + "download_path": "bin\\reference_build\\chrome-win64-clang.zip", +@@ -154,6 +160,12 @@ + "path_within_archive": "chrome-mac/Chromium.app/Contents/MacOS/Chromium", + "version_in_cs": "83.0.4103.97" + }, ++ "mac_arm64": { ++ "cloud_storage_hash": "5fd942947943278bcf91b6f7ef85485ebfef3092", ++ "download_path": "bin/reference_build/chrome-mac-arm64.zip", ++ "path_within_archive": "chrome-mac/Chromium.app/Contents/MacOS/Chromium", ++ "version_in_cs": "100.0.4896.75" ++ }, + "win_AMD64": { + "cloud_storage_hash": "5e503f1bfeae37061ddc80ae1660a1c41594b188", + "download_path": "bin\\reference_build\\chrome-win.zip", +diff --git a/src/third_party/catapult/common/py_utils/py_utils/cloud_storage.py b/src/third_party/catapult/common/py_utils/py_utils/cloud_storage.py +index 128d92388aa..b9f155e18b1 +--- a/src/third_party/catapult/common/py_utils/py_utils/cloud_storage.py ++++ b/src/third_party/catapult/common/py_utils/py_utils/cloud_storage.py +@@ -144,13 +144,9 @@ def _RunCommand(args): + elif _IsRunningOnSwarming(): + gsutil_env = os.environ.copy() + +- if os.name == 'nt': +- # If Windows, prepend python. Python scripts aren't directly executable. +- args = [sys.executable, _GSUTIL_PATH] + args +- else: +- # Don't do it on POSIX, in case someone is using a shell script to redirect. +- args = [_GSUTIL_PATH] + args +- _EnsureExecutable(_GSUTIL_PATH) ++ # Always prepend executable to take advantage of vpython following advice of: ++ # https://chromium.googlesource.com/infra/infra/+/main/doc/users/vpython.md ++ args = [sys.executable, _GSUTIL_PATH] + args + + if args[0] not in ('help', 'hash', 'version') and not IsNetworkIOEnabled(): + raise CloudStorageIODisabled( +@@ -227,6 +223,39 @@ def List(bucket, prefix=None): + return [url[len(bucket_prefix):] for url in stdout.splitlines()] + + ++def ListFiles(bucket, path='', sort_by='name'): ++ """Returns files matching the given path in bucket. ++ ++ Args: ++ bucket: Name of cloud storage bucket to look at. ++ path: Path within the bucket to filter to. Path can include wildcards. ++ sort_by: 'name' (default), 'time' or 'size'. ++ ++ Returns: ++ A sorted list of files. ++ """ ++ bucket_prefix = 'gs://%s' % bucket ++ full_path = '%s/%s' % (bucket_prefix, path) ++ stdout = _RunCommand(['ls', '-l', '-d', full_path]) ++ ++ # Filter out directories and the summary line. ++ file_infos = [line.split(None, 2) for line in stdout.splitlines() ++ if len(line) > 0 and not line.startswith("TOTAL") ++ and not line.endswith('/')] ++ ++ # The first field in the info is size, the second is time, the third is name. ++ if sort_by == 'size': ++ file_infos.sort(key=lambda info: int(info[0])) ++ elif sort_by == 'time': ++ file_infos.sort(key=lambda info: info[1]) ++ elif sort_by == 'name': ++ file_infos.sort(key=lambda info: info[2]) ++ else: ++ raise ValueError("Wrong sort_by value: %s" % sort_by) ++ ++ return [url[len(bucket_prefix):] for _, _, url in file_infos] ++ ++ + def ListDirs(bucket, path=''): + """Returns only directories matching the given path in bucket. + +@@ -258,6 +287,7 @@ def ListDirs(bucket, path=''): + dirs.append(url[len(bucket_prefix):]) + return dirs + ++ + def Exists(bucket, remote_path): + try: + _RunCommand(['ls', 'gs://%s/%s' % (bucket, remote_path)]) +@@ -446,7 +476,7 @@ class CloudFilepath(): + @property + def view_url(self): + """Get a human viewable url for the cloud file.""" +- return 'https://console.developers.google.com/m/cloudstorage/b/%s/o/%s' % ( ++ return 'https://storage.cloud.google.com/%s/%s' % ( + self.bucket, self.remote_path) + + @property +diff --git a/src/third_party/catapult/common/py_utils/py_utils/cloud_storage_unittest.py b/src/third_party/catapult/common/py_utils/py_utils/cloud_storage_unittest.py +index 59125ee206c..fb326e74dea +--- a/src/third_party/catapult/common/py_utils/py_utils/cloud_storage_unittest.py ++++ b/src/third_party/catapult/common/py_utils/py_utils/cloud_storage_unittest.py +@@ -97,8 +97,8 @@ class CloudStorageFakeFsUnitTest(BaseFakeFsUnitTest): + local_path = 'test-local-path.html' + cloud_url = cloud_storage.Insert(cloud_storage.PUBLIC_BUCKET, + remote_path, local_path) +- self.assertEqual('https://console.developers.google.com/m/cloudstorage' +- '/b/chromium-telemetry/o/test-remote-path.html', ++ self.assertEqual('https://storage.cloud.google.com' ++ '/chromium-telemetry/test-remote-path.html', + cloud_url) + finally: + cloud_storage._RunCommand = orig_run_command +@@ -111,8 +111,8 @@ class CloudStorageFakeFsUnitTest(BaseFakeFsUnitTest): + local_path = 'test-local-path.html' + cloud_filepath = cloud_storage.Upload( + cloud_storage.PUBLIC_BUCKET, remote_path, local_path) +- self.assertEqual('https://console.developers.google.com/m/cloudstorage' +- '/b/chromium-telemetry/o/test-remote-path.html', ++ self.assertEqual('https://storage.cloud.google.com' ++ '/chromium-telemetry/test-remote-path.html', + cloud_filepath.view_url) + self.assertEqual('gs://chromium-telemetry/test-remote-path.html', + cloud_filepath.fetch_url) +@@ -200,6 +200,48 @@ class CloudStorageFakeFsUnitTest(BaseFakeFsUnitTest): + self.assertEqual(cloud_storage.ListDirs('bucket', 'foo*'), + ['/foo1/', '/foo2/']) + ++ @mock.patch('py_utils.cloud_storage._RunCommand') ++ def testListFilesSortByName(self, mock_run_command): ++ mock_run_command.return_value = '\n'.join([ ++ ' 11 2022-01-01T16:05:16Z gs://bucket/foo/c.txt', ++ ' 5 2022-03-03T16:05:16Z gs://bucket/foo/a.txt', ++ '', ++ ' gs://bucket/foo/bar/', ++ ' 1 2022-02-02T16:05:16Z gs://bucket/foo/bar/b.txt', ++ 'TOTAL: 3 objects, 17 bytes (17 B)', ++ ]) ++ ++ self.assertEqual(cloud_storage.ListFiles('bucket', 'foo/*', sort_by='name'), ++ ['/foo/a.txt', '/foo/bar/b.txt', '/foo/c.txt']) ++ ++ @mock.patch('py_utils.cloud_storage._RunCommand') ++ def testListFilesSortByTime(self, mock_run_command): ++ mock_run_command.return_value = '\n'.join([ ++ ' 11 2022-01-01T16:05:16Z gs://bucket/foo/c.txt', ++ ' 5 2022-03-03T16:05:16Z gs://bucket/foo/a.txt', ++ '', ++ ' gs://bucket/foo/bar/', ++ ' 1 2022-02-02T16:05:16Z gs://bucket/foo/bar/b.txt', ++ 'TOTAL: 3 objects, 17 bytes (17 B)', ++ ]) ++ ++ self.assertEqual(cloud_storage.ListFiles('bucket', 'foo/*', sort_by='time'), ++ ['/foo/c.txt', '/foo/bar/b.txt', '/foo/a.txt']) ++ ++ @mock.patch('py_utils.cloud_storage._RunCommand') ++ def testListFilesSortBySize(self, mock_run_command): ++ mock_run_command.return_value = '\n'.join([ ++ ' 11 2022-01-01T16:05:16Z gs://bucket/foo/c.txt', ++ ' 5 2022-03-03T16:05:16Z gs://bucket/foo/a.txt', ++ '', ++ ' gs://bucket/foo/bar/', ++ ' 1 2022-02-02T16:05:16Z gs://bucket/foo/bar/b.txt', ++ 'TOTAL: 3 objects, 17 bytes (17 B)', ++ ]) ++ ++ self.assertEqual(cloud_storage.ListFiles('bucket', 'foo/*', sort_by='size'), ++ ['/foo/bar/b.txt', '/foo/a.txt', '/foo/c.txt']) ++ + @mock.patch('py_utils.cloud_storage.subprocess.Popen') + def testSwarmingUsesExistingEnv(self, mock_popen): + os.environ['SWARMING_HEADLESS'] = '1' +diff --git a/src/third_party/catapult/dashboard/Makefile b/src/third_party/catapult/dashboard/Makefile +new file mode 100644 +index 00000000000..60ef9907f3f +--- /dev/null ++++ b/src/third_party/catapult/dashboard/Makefile +@@ -0,0 +1,19 @@ ++PROTOC=protoc ++ ++PY_PROTOS=dims_pb2.py pinpoint_chrome_health_results_pb2.py pinpoint_results_pb2.py sheriff_pb2.py sheriff_config_pb2.py ++ ++ ++all: $(PY_PROTOS) ../tracing/tracing/proto/histogram_pb2.py ++ ++ ++# We now depend on the tracing proto being defined. ++../tracing/tracing/proto/histogram_pb2.py: ++ $(MAKE) -C ../tracing/tracing/proto histogram_pb2.py ++ ++.PHONY: clean ../tracing/tracing/proto/histogram_pb2.py ++ ++%_pb2.py: dashboard/proto/%.proto ++ $(PROTOC) --python_out=. $< ++ ++clean: ++ rm -f $(PY_PROTOS); $(MAKE) -C ../tracing/tracing/proto clean +diff --git a/src/third_party/catapult/dashboard/OWNERS b/src/third_party/catapult/dashboard/OWNERS +index b90ddbab4ab..e7cb464e2b3 +--- a/src/third_party/catapult/dashboard/OWNERS ++++ b/src/third_party/catapult/dashboard/OWNERS +@@ -1,8 +1,6 @@ +-abennetts@google.com +-dberris@chromium.org +-fancl@chromium.org ++set noparent + +- +-# For WebRTC related changes: +-mbonadei@chromium.org +-jleconte@google.com +\ No newline at end of file ++fmmirzaei@google.com ++johnchen@chromium.org ++seanmccullough@google.com ++wenbinzhang@google.com +diff --git a/src/third_party/catapult/dashboard/PRESUBMIT.py b/src/third_party/catapult/dashboard/PRESUBMIT.py +index ba41a7a9d3a..5a5c3841907 +--- a/src/third_party/catapult/dashboard/PRESUBMIT.py ++++ b/src/third_party/catapult/dashboard/PRESUBMIT.py +@@ -1,11 +1,14 @@ + # Copyright 2015 The Chromium Authors. All rights reserved. + # Use of this source code is governed by a BSD-style license that can be + # found in the LICENSE file. ++# pylint: disable=invalid-name + + from __future__ import print_function + from __future__ import division + from __future__ import absolute_import + ++USE_PYTHON3 = True ++ + + def CheckChangeOnUpload(input_api, output_api): + return _CommonChecks(input_api, output_api) +@@ -27,7 +30,8 @@ def _CommonChecks(input_api, output_api): + output_api, + extra_paths_list=_GetPathsToPrepend(input_api), + files_to_skip=files_to_skip, +- pylintrc='pylintrc')) ++ pylintrc='pylintrc', ++ version='2.7')) + return results + + +diff --git a/src/third_party/catapult/dashboard/README.md b/src/third_party/catapult/dashboard/README.md +index af1d414bfaa..34ab9ef265d +--- a/src/third_party/catapult/dashboard/README.md ++++ b/src/third_party/catapult/dashboard/README.md +@@ -36,6 +36,75 @@ subprojects which are also hosted in that directory: + - `sheriff_config`: A standalone service for managing sheriff configurations + hosted in git repositories, accessed through luci-config. + ++## Dependencies ++ ++The dashboard has a few dependencies. Before running dashboard unit tests, ++be sure to following all instructions under this section. ++ ++### Google Cloud SDK ++ ++The dashboard requires Python modules from Google Cloud SDK to run. ++An easy way to install it is through cipd, using the following command. ++You only need to do this once. ++(You can replace `~/google-cloud-sdk` with another location if you prefer.) ++ ++``` ++echo infra/gae_sdk/python/all latest | cipd ensure -root ~/google-cloud-sdk -ensure-file - ++``` ++ ++Then run the following command to set `PYTHONPATH`. It is recommended to add ++this to your `.bashrc` or equivalent. ++ ++``` ++export PYTHONPATH=~/google-cloud-sdk ++``` ++ ++If you already have a non-empty `PYTHONPATH`, you can add the Cloud SDK location ++to it. However, dashboard does not require any additional Python libraries. ++It is recommended that your `PYTHONPATH` only contains the cloud SDK while ++testing the dashboard. ++ ++(Note: The official source for Google Cloud SDK is https://cloud.google.com/sdk, ++and you can install Python modules with ++`gcloud components install app-engine-python`. ++However, this method of installation has not been verified with the dashboard.) ++ ++### Compile Protobuf Definitions ++ ++The dashboard uses several protobuf (protocol buffer) definitions, which must be ++compiled into Python modules. First you need to install the protobuf compiler, ++and then use it to compile the protobuf definition files. ++ ++To install the protobuf compiler, use the following command. ++You only need to do this once. ++(You can replace `~/protoc` with another location if you prefer.) ++ ++``` ++echo infra/tools/protoc/linux-amd64 protobuf_version:v3.6.1 | cipd ensure -root ~/protoc -ensure-file - ++``` ++ ++Afterwards, run the following commands to compile the protobuf definitions. ++You need to do this whenever any of the protobuf definition files have changed. ++Modify the first line below if your catapult directory is at a different ++location. ++ ++``` ++catapult=~/chromium/src/third_party/catapult ++~/protoc/protoc --proto_path $catapult/dashboard --python_out $catapult/dashboard $catapult/dashboard/dashboard/proto/sheriff.proto $catapult/dashboard/dashboard/proto/sheriff_config.proto ++cp $catapult/dashboard/dashboard/proto/sheriff_pb2.py $catapult/dashboard/dashboard/sheriff_config/ ++cp $catapult/dashboard/dashboard/proto/sheriff_config_pb2.py $catapult/dashboard/dashboard/sheriff_config/ ++~/protoc/protoc --proto_path $catapult/tracing/tracing/proto --python_out $catapult/tracing/tracing/proto $catapult/tracing/tracing/proto/histogram.proto ++``` ++ ++## Unit Tests ++ ++First following the steps given in Dependencies section above. ++Then, run dashboard unit tests with: ++ ++``` ++dashboard/bin/run_py_tests ++``` ++ + ## Contact + + Bugs can be reported on the Chromium issue tracker using the `Speed>Dashboard` +diff --git a/src/third_party/catapult/dashboard/api-py3.yaml b/src/third_party/catapult/dashboard/api-py3.yaml +new file mode 100644 +index 00000000000..584bf3fa613 +--- /dev/null ++++ b/src/third_party/catapult/dashboard/api-py3.yaml +@@ -0,0 +1,28 @@ ++service: api ++ ++runtime: python39 ++entrypoint: gunicorn -b:$PORT dashboard.dispatcher:APP --worker-class gthread --threads 10 --timeout 60 ++app_engine_apis: true ++instance_class: F2 ++ ++automatic_scaling: ++ # We're setting the max concurrent request to 20, to allow AppEngine to scale ++ # the number of instances to handle API requests better. We're also going to ++ # keep around 10 instances at the ready to handle incoming requests better ++ # from a "cold start". ++ max_concurrent_requests: 20 ++ max_instances: 150 ++ max_pending_latency: automatic ++ min_instances: 10 ++ target_cpu_utilization: 0.8 ++ ++env_variables: ++ GAE_USE_SOCKETS_HTTPLIB: 'true' ++ ++inbound_services: ++- warmup ++ ++handlers: ++- url: /.+ ++ script: dashboard.dispatcher.APP ++ secure: always +diff --git a/src/third_party/catapult/dashboard/app-py3.yaml b/src/third_party/catapult/dashboard/app-py3.yaml +new file mode 100644 +index 00000000000..b64df021fe0 +--- /dev/null ++++ b/src/third_party/catapult/dashboard/app-py3.yaml +@@ -0,0 +1,73 @@ ++# Python Application Configuration ++# https://developers.google.com/appengine/docs/python/config/appconfig ++ ++runtime: python39 ++ ++entrypoint: gunicorn -b:$PORT dashboard.dispatcher:APP --worker-class gthread --threads 10 --timeout 60 ++app_engine_apis: true ++instance_class: F4 ++ ++automatic_scaling: ++ max_concurrent_requests: 80 ++ max_instances: 150 ++ max_pending_latency: automatic ++ min_instances: 1 ++ target_cpu_utilization: 0.8 ++ ++env_variables: ++ GAE_USE_SOCKETS_HTTPLIB: 'true' ++ ++inbound_services: ++- warmup ++ ++handlers: ++- url: /favicon.ico ++ static_files: dashboard/static/favicon.ico ++ upload: dashboard/static/favicon.ico ++ secure: always ++ ++- url: /dashboard/static/ ++ static_dir: dashboard/static/ ++ secure: always ++ ++- url: /dashboard/elements/(.*\.html)$ ++ static_files: dashboard/elements/\1 ++ upload: dashboard/elements/.*\.html$ ++ secure: always ++ ++- url: /components/(.*)/(.*\.(html|js|css))$ ++ static_files: polymer/components/\1/\2 ++ upload: polymer/components/.*/.*\.(html|js|css)$ ++ secure: always ++ ++- url: /tracing/(.*)/(.*\.(html|js|css))$ ++ static_files: tracing/\1/\2 ++ upload: tracing/.*/.*\.(html|js|css)$ ++ secure: always ++ ++- url: /flot/(.*\.js)$ ++ static_files: flot/\1 ++ upload: flot/.*\.js$ ++ secure: always ++ ++- url: /jquery/(.*\.js)$ ++ static_files: jquery/\1 ++ upload: jquery/.*\.js$ ++ secure: always ++ ++- url: /gl-matrix-min.js ++ static_files: gl-matrix-min.js ++ upload: gl-matrix-min.js ++ secure: always ++ ++# We need admin so only cron can trigger it. ++- url: /alert_groups_update ++ script: dashboard.dispatcher.APP ++ secure: always ++ login: admin ++ ++- url: /.* ++ script: dashboard.dispatcher.APP ++ secure: always ++ ++# Need to check how we want to add the scripts.yaml +diff --git a/src/third_party/catapult/dashboard/app.yaml b/src/third_party/catapult/dashboard/app.yaml +index c157a0a5f79..99e5f2b3f99 +--- a/src/third_party/catapult/dashboard/app.yaml ++++ b/src/third_party/catapult/dashboard/app.yaml +@@ -76,11 +76,6 @@ handlers: + upload: gl-matrix-min.js + secure: always + +-- url: /tsmon-client.js +- static_files: tsmon-client.js +- upload: tsmon-client.js +- secure: always +- + # We need admin so only cron can trigger it. + - url: /alert_groups_update + script: dashboard.dispatcher.APP +diff --git a/src/third_party/catapult/dashboard/appengine_config.py b/src/third_party/catapult/dashboard/appengine_config.py +index 3862b1895ba..65a6ff0ae23 +--- a/src/third_party/catapult/dashboard/appengine_config.py ++++ b/src/third_party/catapult/dashboard/appengine_config.py +@@ -11,50 +11,49 @@ from __future__ import print_function + from __future__ import division + from __future__ import absolute_import + +-import os ++import sys ++if sys.version_info.major == 2: ++ import os + +-from google.appengine.ext import vendor ++ from google.appengine.ext import vendor + +-import dashboard ++ import dashboard + +-# The names used below are special constant names which other code depends on. +-# pylint: disable=invalid-name ++ # The names used below are special constant names which other code depends on. ++ # pylint: disable=invalid-name + +-appstats_SHELL_OK = True +-appstats_CALC_RPC_COSTS = True ++ appstats_SHELL_OK = True ++ appstats_CALC_RPC_COSTS = True + +-# Allows remote_api from the peng team to support the crosbolt dashboard. +-remoteapi_CUSTOM_ENVIRONMENT_AUTHENTICATION = ('LOAS_PEER_USERNAME', +- ['chromeos-peng-performance']) ++ # Allows remote_api from the peng team to support the crosbolt dashboard. ++ remoteapi_CUSTOM_ENVIRONMENT_AUTHENTICATION = ('LOAS_PEER_USERNAME', ++ ['chromeos-peng-performance']) + ++ def webapp_add_wsgi_middleware(app): ++ # pylint: disable=import-outside-toplevel ++ from google.appengine.ext.appstats import recording ++ app = recording.appstats_wsgi_middleware(app) ++ return app + +-def webapp_add_wsgi_middleware(app): +- from google.appengine.ext.appstats import recording +- app = recording.appstats_wsgi_middleware(app) +- return app ++ # pylint: enable=invalid-name + ++ def _AddThirdPartyLibraries(): ++ """Registers the third party libraries with App Engine. + +-# pylint: enable=invalid-name ++ In order for third-party libraries to be available in the App Engine ++ runtime environment, they must be added with vendor.add. The directories ++ added this way must be inside the App Engine project directory. ++ """ ++ # The deploy script is expected to add links to third party libraries ++ # before deploying. If the directories aren't there (e.g. when running ++ # tests) then just ignore it. ++ for library_dir in dashboard.THIRD_PARTY_LIBRARIES_PY2: ++ if os.path.exists(library_dir): ++ vendor.add(os.path.join(os.path.dirname(__file__), library_dir)) + ++ _AddThirdPartyLibraries() + +-def _AddThirdPartyLibraries(): +- """Registers the third party libraries with App Engine. +- +- In order for third-party libraries to be available in the App Engine +- runtime environment, they must be added with vendor.add. The directories +- added this way must be inside the App Engine project directory. +- """ +- # The deploy script is expected to add links to third party libraries +- # before deploying. If the directories aren't there (e.g. when running tests) +- # then just ignore it. +- for library_dir in dashboard.THIRD_PARTY_LIBRARIES: +- if os.path.exists(library_dir): +- vendor.add(os.path.join(os.path.dirname(__file__), library_dir)) +- +- +-_AddThirdPartyLibraries() +- +-# This is at the bottom because datastore_hooks may depend on third_party +-# modules. +-from dashboard.common import datastore_hooks +-datastore_hooks.InstallHooks() ++ # This is at the bottom because datastore_hooks may depend on third_party ++ # modules. ++ from dashboard.common import datastore_hooks ++ datastore_hooks.InstallHooks() +diff --git a/src/third_party/catapult/dashboard/bin/deploy b/src/third_party/catapult/dashboard/bin/deploy +index dfb7dedf032..19834b8e020 +--- a/src/third_party/catapult/dashboard/bin/deploy ++++ b/src/third_party/catapult/dashboard/bin/deploy +@@ -52,7 +52,7 @@ def Main(args, extra_args): + os.mkdir(viewer_dir_path) + except OSError: + pass +- with open(viewer_html_path, 'w') as f: ++ with open(viewer_html_path, 'wb') as f: + from tracing_build import vulcanize_histograms_viewer + s = vulcanize_histograms_viewer.VulcanizeHistogramsViewer() + f.write(s.encode('utf-8')) +diff --git a/src/third_party/catapult/dashboard/bin/deploy-py3 b/src/third_party/catapult/dashboard/bin/deploy-py3 +new file mode 100644 +index 00000000000..e243a92f6e2 +--- /dev/null ++++ b/src/third_party/catapult/dashboard/bin/deploy-py3 +@@ -0,0 +1,107 @@ ++#!/usr/bin/python3 ++# Copyright 2022 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++import argparse ++import logging ++import os ++import subprocess ++import sys ++ ++ ++def _AddToPathIfNeeded(path): ++ if path not in sys.path: ++ sys.path.insert(0, path) ++ ++ ++def Main(args, extra_args): ++ if args.dry_run: ++ logging.info('Dry-run mode, not actually deploying anything.') ++ ++ dashboard_path = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) ++ _AddToPathIfNeeded(dashboard_path) ++ import dashboard ++ ++ catapult_path = os.path.dirname(dashboard_path) ++ _AddToPathIfNeeded(catapult_path) ++ ++ tracing_path = os.path.join(catapult_path, 'tracing') ++ _AddToPathIfNeeded(tracing_path) ++ ++ # Initialise the node_runner module to ensure that we have the right modules ++ # available even if we hadn't run the tests or the presubmit. ++ _AddToPathIfNeeded(os.path.join(catapult_path, 'common', 'py_utils')) ++ _AddToPathIfNeeded(os.path.join(catapult_path, 'common', 'node_runner')) ++ from node_runner import node_util ++ node_util.InitNode() ++ ++ try: ++ from dashboard_build import preprocess ++ from catapult_build import temp_deployment_dir ++ deployment_paths = dashboard.PathsForDeployment() ++ target_dir = args.target_dir if args.target_dir else None ++ with temp_deployment_dir.TempDeploymentDir( ++ deployment_paths, use_symlinks=not args.copy_files, ++ cleanup=not args.dry_run, reuse_path=target_dir) as tempdir: ++ logging.info('Temporary working directory: %s', tempdir) ++ viewer_dir_path = os.path.join(tempdir, 'vulcanized_histograms_viewer') ++ viewer_html_path = os.path.join(viewer_dir_path, ++ 'vulcanized_histograms_viewer.html') ++ try: ++ os.mkdir(viewer_dir_path) ++ except OSError: ++ pass ++ with open(viewer_html_path, 'wb') as f: ++ from tracing_build import vulcanize_histograms_viewer ++ s = vulcanize_histograms_viewer.VulcanizeHistogramsViewer() ++ f.write(s.encode('utf-8')) ++ ++ preprocess.PackPinpoint(catapult_path, tempdir, deployment_paths) ++ deployment_paths.append(viewer_dir_path) ++ logging.info('Deployment dir is at %s', tempdir) ++ ++ if not args.dry_run: ++ from catapult_build import appengine_deploy ++ appengine_deploy.Deploy(deployment_paths, extra_args, ++ os.environ.get('VERSION')) ++ if not extra_args: ++ logging.info( ++ 'Deploying dashboard, api, upload, and pinpoint services') ++ appengine_deploy.Deploy(deployment_paths, [ ++ 'api.yaml', 'app.yaml', 'upload.yaml', 'upload-processing.yaml', ++ 'pinpoint.yaml' ++ ], os.environ.get('VERSION')) ++ except RuntimeError as error: ++ logging.error('Encountered an error: %s', error) ++ sys.exit(1) ++ except subprocess.CalledProcessError as error: ++ logging.error('Failed: %s', error) ++ sys.exit(error.returncode) ++ ++ ++if __name__ == '__main__': ++ parser = argparse.ArgumentParser() ++ parser.add_argument( ++ '-n', ++ '--dry_run', ++ help='Create the deployment directory but do not actually deploy.', ++ action='store_true') ++ parser.add_argument( ++ '-t', ++ '--target_dir', ++ help='Specify the target directory, instead of creating a new one.') ++ parser.add_argument( ++ '-c', ++ '--copy_files', ++ help='Specify whether to copy files instead of symlinking.', ++ action='store_true') ++ args, extra_args = parser.parse_known_args() ++ ++ # Set up the logging from here. ++ logging.basicConfig( ++ stream=sys.stdout, ++ level=logging.INFO, ++ format='[%(asctime)s - %(levelname)s]:\t%(message)s') ++ logging.info('Starting deploy script.') ++ Main(args, extra_args) +diff --git a/src/third_party/catapult/dashboard/bin/dev_server b/src/third_party/catapult/dashboard/bin/dev_server +index 0b2523c03f7..53f54d9d0f1 +--- a/src/third_party/catapult/dashboard/bin/dev_server ++++ b/src/third_party/catapult/dashboard/bin/dev_server +@@ -1,4 +1,4 @@ +-#!/usr/bin/python ++#!/usr/bin/env vpython + # Copyright 2015 The Chromium Authors. All rights reserved. + # Use of this source code is governed by a BSD-style license that can be + # found in the LICENSE file. +diff --git a/src/third_party/catapult/dashboard/bin/run_py_tests b/src/third_party/catapult/dashboard/bin/run_py_tests +index ce153a77304..7023501f517 +--- a/src/third_party/catapult/dashboard/bin/run_py_tests ++++ b/src/third_party/catapult/dashboard/bin/run_py_tests +@@ -27,9 +27,33 @@ if __name__ == '__main__': + else: + install.InstallHooks() + ++ # PYTHONPATH points to a out-of-date cipd package. ++ if sys.version_info.major == 3 and 'PYTHONPATH' in os.environ: ++ os.environ.pop('PYTHONPATH') ++ + from catapult_build import run_with_typ + import dashboard +- return_code = run_with_typ.Run( +- os.path.join(_DASHBOARD_PATH, 'dashboard'), ++ if sys.version_info.major == 2: ++ root = 'dashboard' ++ return_code = run_with_typ.Run( ++ os.path.join(_DASHBOARD_PATH, root), + path=dashboard.PathsForTesting()) ++ else: ++ # The root will be 'dashboard' when all tests are running on python 3. ++ # Before all tests are passing, we will run tests in some sub-folders. ++ # This is a temporary solution which will exit if any sub-folder fails. ++ root = [ ++ 'dashboard/api', ++ 'dashboard/common', ++ 'dashboard/models', ++ 'dashboard/pinpoint', ++ 'dashboard/services' ++ ] ++ for r in root: ++ print('Running unit tests in %s', r) ++ return_code = run_with_typ.Run( ++ os.path.join(_DASHBOARD_PATH, r), ++ path=dashboard.PathsForTesting()) ++ if return_code: ++ break + sys.exit(return_code) +diff --git a/src/third_party/catapult/dashboard/bq_export/bq_export/export_options.py b/src/third_party/catapult/dashboard/bq_export/bq_export/export_options.py +index 70124d327cb..2cf97bb5b29 +--- a/src/third_party/catapult/dashboard/bq_export/bq_export/export_options.py ++++ b/src/third_party/catapult/dashboard/bq_export/bq_export/export_options.py +@@ -46,6 +46,8 @@ class BqExportOptions(PipelineOptions): + return _TimeRangeProvider(self.end_date, self.num_days) + + ++# TODO(https://crbug.com/1262292): Update after Python2 trybots retire. ++# pylint: disable=useless-object-inheritance + class _TimeRangeProvider(object): + """A ValueProvider-like based on the end_date and num_days ValueProviders. + +diff --git a/src/third_party/catapult/dashboard/bq_export/bq_export/split_by_timestamp.py b/src/third_party/catapult/dashboard/bq_export/bq_export/split_by_timestamp.py +index 575c4dbaac7..40a135202d1 +--- a/src/third_party/catapult/dashboard/bq_export/bq_export/split_by_timestamp.py ++++ b/src/third_party/catapult/dashboard/bq_export/bq_export/split_by_timestamp.py +@@ -48,6 +48,8 @@ class ReadTimestampRangeFromDatastore(beam.PTransform): + :timestamp_property: a str of the name of the timestamp property to filter + on. + """ ++ # TODO(https://crbug.com/1262292): Change to super() after Python2 trybots retire. ++ # pylint: disable=super-with-arguments + super(ReadTimestampRangeFromDatastore, self).__init__() + self._query_params = query_params + self._time_range_provider = time_range_provider +@@ -69,6 +71,8 @@ class ReadTimestampRangeFromDatastore(beam.PTransform): + class _QueryFn(beam.DoFn): + + def __init__(self, query_params, timestamp_property): ++ # TODO(https://crbug.com/1262292): Change to super() after Python2 trybots retire. ++ # pylint: disable=super-with-arguments + super(ReadTimestampRangeFromDatastore._QueryFn, self).__init__() + self._query_params = query_params + self._timestamp_property = timestamp_property +diff --git a/src/third_party/catapult/dashboard/bq_export/delete_upload_tokens.py b/src/third_party/catapult/dashboard/bq_export/delete_upload_tokens.py +index 6b462756d2d..a08ae18c64e +--- a/src/third_party/catapult/dashboard/bq_export/delete_upload_tokens.py ++++ b/src/third_party/catapult/dashboard/bq_export/delete_upload_tokens.py +@@ -37,6 +37,8 @@ class TokenSelectionOptions(PipelineOptions): + return _SelectionProvider(self.max_lifetime, self.reference_time) + + ++# TODO(https://crbug.com/1262292): Update after Python2 trybots retire. ++# pylint: disable=useless-object-inheritance + class _SelectionProvider(object): + + def __init__(self, max_lifetime, reference_time): +diff --git a/src/third_party/catapult/dashboard/cloudbuild-dashboard-push-on-green-py3.yaml b/src/third_party/catapult/dashboard/cloudbuild-dashboard-push-on-green-py3.yaml +new file mode 100644 +index 00000000000..8eeebb0a40a +--- /dev/null ++++ b/src/third_party/catapult/dashboard/cloudbuild-dashboard-push-on-green-py3.yaml +@@ -0,0 +1,94 @@ ++# These are the testing and deploy steps for the performance dashboard ++# services. We re-use the docker-compose files in the dev_dockerfiles directory ++# to ensure we're runing the same test and deploy cycle everytime. ++timeout: 1800s # Wait for 30 minutes for the whole process to finish. ++options: ++ diskSizeGb: 100 ++ machineType: 'N1_HIGHCPU_8' ++steps: ++- name: 'gcr.io/cloud-builders/docker' ++ entrypoint: 'bash' ++ args: ++ - '-c' ++ - | ++ docker pull gcr.io/$PROJECT_ID/dashboard-base:latest || exit 0 ++- name: 'gcr.io/cloud-builders/docker' ++ dir: 'dashboard/dev_dockerfiles' ++ args: [ ++ 'build', ++ '-t', 'dashboard-base:latest', ++ '-t', 'gcr.io/$PROJECT_ID/dashboard-base:latest', ++ '--cache-from', 'gcr.io/$PROJECT_ID/dashboard-base:latest', ++ '.' ++ ] ++- name: 'gcr.io/$PROJECT_ID/docker-compose' ++ dir: 'dashboard/dev_dockerfiles' ++ args: [ ++ 'run', 'python-unittest-dashboard-py3' ++ ] ++# We need to provide the auth token that the service account is using to the ++# container from which we're going to deploy the Dashboard services. ++- name: 'gcr.io/$PROJECT_ID/docker-compose' ++ dir: 'dashboard/dev_dockerfiles' ++ args: [ ++ 'run', 'cloudbuild-prepare-deployment-py3' ++ ] ++- name: 'gcr.io/cloud-builders/gcloud' ++ dir: 'deploy-dashboard' ++ args: [ ++ app, deploy, '--no-promote', '--version', 'cloud-build-${SHORT_SHA}-py3', ++ # We enumerate the files we need to deploy just for the dashboard. ++ # TODO(dberris): Figure out how we can include cron.yaml and dispatch.yaml ++ # from this automation. This fails in production with the service account ++ # used by cloud-build, so we've left it out for now. ++ # TODO(wenbinzhang): deploy other services when migration to python3 is done. ++ api-py3.yaml, ++ app-py3.yaml, ++ upload-processing-py3.yaml, ++ upload-py3.yaml, ++ pinpoint-py3.yaml, ++ ] ++# We check in the target versions to avoid unintended traffic changes. ++- name: 'gcr.io/cloud-builders/gcloud' ++ id: 'Set traffic for default service' ++ dir: 'deploy-dashboard' ++ args: [ ++ 'app', 'services', 'set-traffic', 'default', ++ '--splits=cloud-build-d7b50c8=.8,cloud-build-7398e8a=.2' ++ ] ++- name: 'gcr.io/cloud-builders/gcloud' ++ id: 'Set traffic for api service' ++ dir: 'deploy-dashboard' ++ args: [ ++ 'app', 'services', 'set-traffic', 'api', ++ '--splits=cloud-build-d7b50c8=.8,cloud-build-7398e8a=.2' ++ ] ++- name: 'gcr.io/cloud-builders/gcloud' ++ id: 'Set traffic for upload service' ++ dir: 'deploy-dashboard' ++ args: [ ++ 'app', 'services', 'set-traffic', 'upload', ++ '--splits=cloud-build-7398e8a-py3=1', ++ '--split-by=random' ++ ] ++- name: 'gcr.io/cloud-builders/gcloud' ++ id: 'Set traffic for upload-processing service' ++ dir: 'deploy-dashboard' ++ args: [ ++ 'app', 'services', 'set-traffic', 'upload-processing', ++ '--splits=cloud-build-7398e8a-py3=1' ++ ] ++- name: 'gcr.io/cloud-builders/gcloud' ++ id: 'Set traffic for pinpoint service' ++ dir: 'deploy-dashboard' ++ args: [ ++ 'app', 'services', 'set-traffic', 'pinpoint', ++ '--splits=cloud-build-7398e8a-py3=1' ++ ] ++- name: 'gcr.io/cloud-builders/gcloud' ++ entrypoint: '/bin/bash' ++ args: [ ++ '-x', '-e', 'dashboard/dev_dockerfiles/cleanup_versions.sh', ++ 'api', 'default', 'pinpoint', 'upload-processing', 'upload' ++ ] ++images: ['gcr.io/$PROJECT_ID/dashboard-base:latest'] +\ No newline at end of file +diff --git a/src/third_party/catapult/dashboard/cloudbuild-dashboard-push-on-green.yaml b/src/third_party/catapult/dashboard/cloudbuild-dashboard-push-on-green.yaml +index 2adf1b6d01b..b6dbd712ad4 +--- a/src/third_party/catapult/dashboard/cloudbuild-dashboard-push-on-green.yaml ++++ b/src/third_party/catapult/dashboard/cloudbuild-dashboard-push-on-green.yaml +@@ -33,12 +33,6 @@ steps: + args: [ + 'run', 'cloudbuild-prepare-deployment' + ] +-- name: 'gcr.io/cloud-builders/gcloud' +- entrypoint: '/bin/bash' +- args: [ +- '-x', '-e', 'dashboard/dev_dockerfiles/cleanup_versions.sh', +- 'api', 'default', 'pinpoint', 'upload-processing', 'upload' +- ] + - name: 'gcr.io/cloud-builders/gcloud' + dir: 'deploy-dashboard' + args: [ +diff --git a/src/third_party/catapult/dashboard/dashboard/Makefile b/src/third_party/catapult/dashboard/dashboard/Makefile +deleted file mode 100644 +index 9c8ddb8a6e5..00000000000 +--- a/src/third_party/catapult/dashboard/dashboard/Makefile ++++ /dev/null +@@ -1,18 +0,0 @@ +-PROTOC=protoc +- +-PY_PROTOS=dims_pb2.py pinpoint_chrome_health_results_pb2.py pinpoint_results_pb2.py sheriff_pb2.py sheriff_config_pb2.py +- +- +-all: $(PY_PROTOS) ../../tracing/tracing/proto/histogram_pb2.py +- +-# We now depend on the tracing proto being defined. +-../../tracing/tracing/proto/histogram_pb2.py: +- $(MAKE) -C ../../tracing/tracing/proto histogram_pb2.py +- +-.PHONY: clean ../../tracing/tracing/proto/histogram_pb2.py +- +-%_pb2.py: proto/%.proto +- $(PROTOC) -Iproto -I. --python_out=. $< +- +-clean: +- rm -f $(PY_PROTOS); $(MAKE) -C ../../tracing/tracing/proto clean +diff --git a/src/third_party/catapult/dashboard/dashboard/__init__.py b/src/third_party/catapult/dashboard/dashboard/__init__.py +index b2e7851d562..3eabce5266d +--- a/src/third_party/catapult/dashboard/dashboard/__init__.py ++++ b/src/third_party/catapult/dashboard/dashboard/__init__.py +@@ -14,65 +14,77 @@ _CATAPULT_PATH = os.path.abspath( + + # Directories in catapult/third_party required by dashboard. + THIRD_PARTY_LIBRARIES = [ +- 'apiclient', +- 'beautifulsoup4', +- 'cachetools', + 'certifi', +- 'chardet', + 'cloudstorage', + 'depot_tools', + 'flot', + 'gae_ts_mon', +- 'google-auth', + 'graphy', + 'html5lib-python', + 'idna', +- 'ijson', + 'jquery', + 'mapreduce', +- 'mock', +- 'oauth2client', + 'pipeline', + 'polymer', + 'polymer-svg-template', + 'polymer2/bower_components', + 'polymer2/bower_components/chopsui', +- 'pyasn1', +- 'pyasn1_modules', +- 'pyparsing', + 'redux/redux.min.js', + 'requests', + 'requests_toolbelt', +- 'rsa', + 'six', +- 'uritemplate', + 'urllib3', + 'webapp2', +- 'webtest', + ] + ++# Add third party libraries needed *copying* for python 2. When running in ++# python 3, those libraries should be installed either by pip or vpython. + THIRD_PARTY_LIBRARIES_PY2 = THIRD_PARTY_LIBRARIES + [ +- 'httplib2/python2/httplib2' ++ 'apiclient', ++ 'beautifulsoup4', ++ 'cachetools', ++ 'chardet', ++ 'click', ++ 'flask', ++ 'google-auth', ++ 'httplib2/python2/httplib2', ++ 'ijson', ++ 'itsdangerous', ++ 'jinja2', ++ 'markupsafe', ++ 'mock', ++ 'oauth2client', ++ 'pyasn1', ++ 'pyasn1_modules', ++ 'pyparsing', ++ 'rsa', ++ 'uritemplate', ++ 'webtest', ++ 'werkzeug', + ] + +-THIRD_PARTY_LIBRARIES_PY3 = THIRD_PARTY_LIBRARIES + [ +- 'httplib2/python3/httplib2' +-] ++THIRD_PARTY_LIBRARIES_PY3 = THIRD_PARTY_LIBRARIES + + # Files and directories in catapult/dashboard. + DASHBOARD_FILES = [ + 'api.yaml', ++ 'api-py3.yaml', # remove after py3 migration is finalized. + 'app.yaml', ++ 'app-py3.yaml', # remove after py3 migration is finalized. + 'appengine_config.py', + 'cron.yaml', + 'dashboard', + 'dispatch.yaml', + 'index.yaml', + 'pinpoint.yaml', ++ 'pinpoint-py3.yaml', # remove after py3 migration is finalized. + 'queue.yaml', ++ 'requirements.txt', + 'scripts.yaml', + 'upload-processing.yaml', ++ 'upload-processing-py3.yaml', # remove after py3 migration is finalized. + 'upload.yaml', ++ 'upload-py3.yaml', # remove after py3 migration is finalized. + ] + + TRACING_PATHS = [ +@@ -138,19 +150,26 @@ def _AllSdkThirdPartyLibraryPaths(): + appengine_path = os.path.join(sdk_bin_path, 'platform', 'google_appengine') + paths.append(appengine_path) + sys.path.insert(0, appengine_path) +- break + + try: +- import dev_appserver ++ # pylint: disable=import-outside-toplevel ++ if sys.version_info.major == 2: ++ import dev_appserver ++ else: ++ # dev_appserver is not ready for python 3. Try import google.appengine ++ # for validation purpose. ++ import google.appengine # pylint: disable=unused-import + except ImportError: + # TODO: Put the Cloud SDK in the path with the binary dependency manager. + # https://github.com/catapult-project/catapult/issues/2135 +- print('This script requires the Google Cloud SDK to be in PATH.') +- print('Install at https://cloud.google.com/sdk and then run') +- print('`gcloud components install app-engine-python`') ++ print('This script requires the Google Cloud SDK to be in PYTHONPATH.') ++ print( ++ 'See https://chromium.googlesource.com/catapult/+/HEAD/dashboard/README.md' ++ ) + sys.exit(1) + +- paths.extend(dev_appserver.EXTRA_PATHS) ++ if sys.version_info.major == 2: ++ paths.extend(dev_appserver.EXTRA_PATHS) + return paths + + +@@ -159,8 +178,7 @@ def _CatapultThirdPartyLibraryPaths(): + paths = [] + paths.append( + os.path.join(_CATAPULT_PATH, 'common', 'node_runner', 'node_runner', +- 'node_modules', '@chopsui', 'tsmon-client', +- 'tsmon-client.js')) ++ 'node_modules', '@chopsui')) + third_party_libraries = ( + THIRD_PARTY_LIBRARIES_PY3 if sys.version_info.major == 3 + else THIRD_PARTY_LIBRARIES_PY2) +diff --git a/src/third_party/catapult/dashboard/dashboard/add_histograms.py b/src/third_party/catapult/dashboard/dashboard/add_histograms.py +index fd26cee0d48..b37c0f7c77d +--- a/src/third_party/catapult/dashboard/dashboard/add_histograms.py ++++ b/src/third_party/catapult/dashboard/dashboard/add_histograms.py +@@ -6,7 +6,6 @@ from __future__ import print_function + from __future__ import division + from __future__ import absolute_import + +-import cloudstorage + import decimal + import ijson + import json +@@ -15,11 +14,20 @@ import six + import sys + import uuid + import zlib ++if six.PY2: ++ import cloudstorage ++else: ++ try: ++ import cloudstorage.cloudstorage as cloudstorage ++ except ImportError: ++ # This is a work around to fix the discrepency on file tree in tests. ++ import cloudstorage + + from google.appengine.api import taskqueue + from google.appengine.ext import ndb + + from dashboard import sheriff_config_client ++from dashboard.api import api_auth + from dashboard.api import api_request_handler + from dashboard.common import datastore_hooks + from dashboard.common import histogram_helpers +@@ -33,6 +41,8 @@ from tracing.value import histogram_set + from tracing.value.diagnostics import diagnostic + from tracing.value.diagnostics import reserved_infos + ++from flask import make_response, request ++ + TASK_QUEUE_NAME = 'histograms-queue' + + _RETRY_PARAMS = cloudstorage.RetryParams(backoff_factor=1.1) +@@ -40,60 +50,130 @@ _TASK_RETRY_LIMIT = 4 + _ZLIB_BUFFER_SIZE = 4096 + + +-def _CheckRequest(condition, msg): +- if not condition: +- raise api_request_handler.BadRequestError(msg) +- +- +-class DecompressFileWrapper(object): +- """A file-like object implementing inline decompression. +- +- This class wraps a file-like object and does chunk-based decoding of the data. +- We only implement the read() function supporting fixed-chunk reading, capped +- to a predefined constant buffer length. +- +- Example +- +- with open('filename', 'r') as input: +- decompressor = DecompressFileWrapper(input) +- while True: +- chunk = decompressor.read(4096) +- if len(chunk) == 0: +- break +- // handle the chunk with size <= 4096 +- """ +- +- def __init__(self, source_file, buffer_size=_ZLIB_BUFFER_SIZE): +- self.source_file = source_file +- self.decompressor = zlib.decompressobj() +- self.buffer_size = buffer_size +- +- def __enter__(self): +- return self ++def _CheckUser(): ++ if utils.IsDevAppserver(): ++ return ++ api_auth.Authorize() ++ if not utils.IsInternalUser(): ++ raise api_request_handler.ForbiddenError() + +- def read(self, size=None): # pylint: disable=invalid-name +- if size is None or size < 0: +- size = self.buffer_size + +- # We want to read chunks of data from the buffer, chunks at a time. +- temporary_buffer = self.decompressor.unconsumed_tail +- if len(temporary_buffer) < self.buffer_size / 2: +- raw_buffer = self.source_file.read(size) +- if raw_buffer != '': +- temporary_buffer += raw_buffer ++def AddHistogramsProcessPost(): ++ datastore_hooks.SetPrivilegedRequest() ++ token = None + +- if len(temporary_buffer) == 0: +- return u'' ++ try: ++ params = json.loads(request.get_data()) ++ gcs_file_path = params['gcs_file_path'] + +- decompressed_data = self.decompressor.decompress(temporary_buffer, size) +- return decompressed_data ++ token_id = params.get('upload_completion_token') ++ if token_id is not None: ++ token = upload_completion_token.Token.get_by_id(token_id) ++ upload_completion_token.Token.UpdateObjectState( ++ token, upload_completion_token.State.PROCESSING) + +- def close(self): # pylint: disable=invalid-name +- self.decompressor.flush() ++ try: ++ logging.debug('Loading %s', gcs_file_path) ++ gcs_file = cloudstorage.open( ++ gcs_file_path, 'r', retry_params=_RETRY_PARAMS) ++ with DecompressFileWrapper(gcs_file) as decompressing_file: ++ histogram_dicts = _LoadHistogramList(decompressing_file) ++ ++ gcs_file.close() ++ ++ logging.debug('flaskDebug: AddHistogramsProcessPost request path: %s', ++ request.path) ++ force_flask = 'add_histograms_flask/process' in request.path ++ ++ ProcessHistogramSet(histogram_dicts, token, force_flask) ++ finally: ++ cloudstorage.delete(gcs_file_path, retry_params=_RETRY_PARAMS) ++ ++ upload_completion_token.Token.UpdateObjectState( ++ token, upload_completion_token.State.COMPLETED) ++ return make_response('{}') ++ ++ except Exception as e: # pylint: disable=broad-except ++ logging.error('Error processing histograms: %s', str(e), exc_info=1) ++ upload_completion_token.Token.UpdateObjectState( ++ token, upload_completion_token.State.FAILED, str(e)) ++ return make_response(json.dumps({'error': str(e)})) ++ ++ ++def _GetCloudStorageBucket(): ++ if utils.IsStagingEnvironment(): ++ return 'chromeperf-staging-add-histograms-cache' ++ return 'add-histograms-cache' ++ ++ ++@api_request_handler.RequestHandlerDecoratorFactory(_CheckUser) ++def AddHistogramsPost(): ++ if utils.IsDevAppserver(): ++ # Don't require developers to zip the body. ++ # In prod, the data will be written to cloud storage and processed on the ++ # taskqueue, so the caller will not see any errors. In dev_appserver, ++ # process the data immediately so the caller will see errors. ++ # Also always create upload completion token for such requests. ++ token, token_info = _CreateUploadCompletionToken() ++ ProcessHistogramSet( ++ _LoadHistogramList(six.StringIO(request.get_data())), token) ++ token.UpdateState(upload_completion_token.State.COMPLETED) ++ return token_info + +- def __exit__(self, exception_type, exception_value, execution_traceback): +- self.close() +- return False ++ with timing.WallTimeLogger('decompress'): ++ try: ++ data_str = request.get_data() ++ # Try to decompress at most 100 bytes from the data, only to determine ++ # if we've been given compressed payload. ++ zlib.decompressobj().decompress(data_str, 100) ++ logging.info('Received compressed data.') ++ except zlib.error as e: ++ data_str = request.form['data'] ++ if not data_str: ++ six.raise_from( ++ api_request_handler.BadRequestError( ++ 'Missing or uncompressed data.'), e) ++ data_str = zlib.compress(six.ensure_binary(data_str)) ++ logging.info('Received uncompressed data.') ++ ++ if not data_str: ++ raise api_request_handler.BadRequestError('Missing "data" parameter') ++ ++ filename = uuid.uuid4() ++ params = {'gcs_file_path': '/%s/%s' % (_GetCloudStorageBucket(), filename)} ++ ++ gcs_file = cloudstorage.open( ++ params['gcs_file_path'], ++ 'w', ++ content_type='application/octet-stream', ++ retry_params=_RETRY_PARAMS) ++ gcs_file.write(data_str) ++ gcs_file.close() ++ ++ _, token_info = _CreateUploadCompletionToken(params['gcs_file_path']) ++ params['upload_completion_token'] = token_info['token'] ++ ++ retry_options = taskqueue.TaskRetryOptions( ++ task_retry_limit=_TASK_RETRY_LIMIT) ++ queue = taskqueue.Queue('default') ++ ++ # TODO(crbug/1393102): it is a hack for temp testing. Will remove ++ # after migration is done. ++ logging.debug('flaskDebug: AddHistogramsPost request path: %s', request.path) ++ if 'add_histograms_flask' in request.path: ++ logging.debug('flaskDebug: adding task to default for process in flask') ++ queue.add( ++ taskqueue.Task( ++ url='/add_histograms_flask/process', ++ payload=json.dumps(params), ++ retry_options=retry_options)) ++ else: ++ queue.add( ++ taskqueue.Task( ++ url='/add_histograms/process', ++ payload=json.dumps(params), ++ retry_options=retry_options)) ++ return token_info + + + def _LoadHistogramList(input_file): +@@ -134,123 +214,128 @@ def _LoadHistogramList(input_file): + return objects + + +-class AddHistogramsProcessHandler(request_handler.RequestHandler): ++if six.PY2: ++ class AddHistogramsProcessHandler(request_handler.RequestHandler): + +- def post(self): +- datastore_hooks.SetPrivilegedRequest() +- token = None ++ def post(self): ++ logging.debug('crbug/1298177 - add_histograms POST triggered') ++ datastore_hooks.SetPrivilegedRequest() ++ token = None + +- try: +- params = json.loads(self.request.body) +- gcs_file_path = params['gcs_file_path'] ++ try: ++ params = json.loads(self.request.body) ++ gcs_file_path = params['gcs_file_path'] + +- token_id = params.get('upload_completion_token') +- if token_id is not None: +- token = upload_completion_token.Token.get_by_id(token_id) +- upload_completion_token.Token.UpdateObjectState( +- token, upload_completion_token.State.PROCESSING) ++ token_id = params.get('upload_completion_token') ++ if token_id is not None: ++ token = upload_completion_token.Token.get_by_id(token_id) ++ upload_completion_token.Token.UpdateObjectState( ++ token, upload_completion_token.State.PROCESSING) + +- try: +- logging.debug('Loading %s', gcs_file_path) +- gcs_file = cloudstorage.open( +- gcs_file_path, 'r', retry_params=_RETRY_PARAMS) +- with DecompressFileWrapper(gcs_file) as decompressing_file: +- histogram_dicts = _LoadHistogramList(decompressing_file) ++ try: ++ logging.debug('Loading %s', gcs_file_path) ++ gcs_file = cloudstorage.open( ++ gcs_file_path, 'r', retry_params=_RETRY_PARAMS) ++ with DecompressFileWrapper(gcs_file) as decompressing_file: ++ histogram_dicts = _LoadHistogramList(decompressing_file) + +- gcs_file.close() ++ gcs_file.close() + +- ProcessHistogramSet(histogram_dicts, token) +- finally: +- cloudstorage.delete(gcs_file_path, retry_params=_RETRY_PARAMS) ++ ProcessHistogramSet(histogram_dicts, token) ++ finally: ++ cloudstorage.delete(gcs_file_path, retry_params=_RETRY_PARAMS) + +- upload_completion_token.Token.UpdateObjectState( +- token, upload_completion_token.State.COMPLETED) ++ upload_completion_token.Token.UpdateObjectState( ++ token, upload_completion_token.State.COMPLETED) + +- except Exception as e: # pylint: disable=broad-except +- logging.error('Error processing histograms: %s', str(e)) +- self.response.out.write(json.dumps({'error': str(e)})) ++ except Exception as e: # pylint: disable=broad-except ++ logging.error('Error processing histograms: %s', str(e)) ++ self.response.out.write(json.dumps({'error': str(e)})) + +- upload_completion_token.Token.UpdateObjectState( +- token, upload_completion_token.State.FAILED, str(e)) +- +- +-# pylint: disable=abstract-method +-class AddHistogramsHandler(api_request_handler.ApiRequestHandler): +- +- def _CheckUser(self): +- self._CheckIsInternalUser() +- +- def _CreateUploadCompletionToken(self, temporary_staging_file_path=None): +- token_info = { +- 'token': str(uuid.uuid4()), +- 'file': temporary_staging_file_path, +- } +- token = upload_completion_token.Token( +- id=token_info['token'], +- temporary_staging_file_path=temporary_staging_file_path, +- ) +- token.put() +- logging.info('Upload completion token created. Token id: %s', +- token_info['token']) +- return token, token_info +- +- def Post(self, *args, **kwargs): +- del args, kwargs # Unused. +- if utils.IsDevAppserver(): +- # Don't require developers to zip the body. +- # In prod, the data will be written to cloud storage and processed on the +- # taskqueue, so the caller will not see any errors. In dev_appserver, +- # process the data immediately so the caller will see errors. +- # Also always create upload completion token for such requests. +- token, token_info = self._CreateUploadCompletionToken() +- ProcessHistogramSet( +- _LoadHistogramList(six.StringIO(self.request.body)), token) +- token.UpdateState(upload_completion_token.State.COMPLETED) ++ upload_completion_token.Token.UpdateObjectState( ++ token, upload_completion_token.State.FAILED, str(e)) ++ ++ ++ # pylint: disable=abstract-method ++ class AddHistogramsHandler(api_request_handler.ApiRequestHandler): ++ ++ def _CheckUser(self): ++ self._CheckIsInternalUser() ++ ++ def Post(self, *args, **kwargs): ++ del args, kwargs # Unused. ++ if utils.IsDevAppserver(): ++ # Don't require developers to zip the body. ++ # In prod, the data will be written to cloud storage and processed on ++ # the taskqueue, so the caller will not see any errors. In ++ # dev_appserver, process the data immediately so the caller will see ++ # errors. Also, always create upload completion token for such requests. ++ token, token_info = _CreateUploadCompletionToken() ++ ProcessHistogramSet( ++ _LoadHistogramList(six.StringIO(self.request.body)), token) ++ token.UpdateState(upload_completion_token.State.COMPLETED) ++ return token_info ++ ++ with timing.WallTimeLogger('decompress'): ++ try: ++ data_str = self.request.body ++ ++ # Try to decompress at most 100 bytes from the data, only to determine ++ # if we've been given compressed payload. ++ zlib.decompressobj().decompress(data_str, 100) ++ logging.info('Received compressed data.') ++ except zlib.error as e: ++ data_str = self.request.get('data') ++ if not data_str: ++ six.raise_from( ++ api_request_handler.BadRequestError( ++ 'Missing or uncompressed data.'), e) ++ data_str = zlib.compress(data_str) ++ logging.info('Received uncompressed data.') ++ ++ if not data_str: ++ raise api_request_handler.BadRequestError('Missing "data" parameter') ++ ++ filename = uuid.uuid4() ++ params = { ++ 'gcs_file_path': '/%s/%s' % (_GetCloudStorageBucket(), filename) ++ } ++ ++ gcs_file = cloudstorage.open( ++ params['gcs_file_path'], ++ 'w', ++ content_type='application/octet-stream', ++ retry_params=_RETRY_PARAMS) ++ gcs_file.write(data_str) ++ gcs_file.close() ++ ++ _, token_info = _CreateUploadCompletionToken(params['gcs_file_path']) ++ params['upload_completion_token'] = token_info['token'] ++ ++ retry_options = taskqueue.TaskRetryOptions( ++ task_retry_limit=_TASK_RETRY_LIMIT) ++ queue = taskqueue.Queue('default') ++ queue.add( ++ taskqueue.Task( ++ url='/add_histograms/process', ++ payload=json.dumps(params), ++ retry_options=retry_options)) + return token_info + +- with timing.WallTimeLogger('decompress'): +- try: +- data_str = self.request.body +- +- # Try to decompress at most 100 bytes from the data, only to determine +- # if we've been given compressed payload. +- zlib.decompressobj().decompress(data_str, 100) +- logging.info('Received compressed data.') +- except zlib.error as e: +- data_str = self.request.get('data') +- if not data_str: +- six.raise_from( +- api_request_handler.BadRequestError( +- 'Missing or uncompressed data.'), e) +- data_str = zlib.compress(data_str) +- logging.info('Received uncompressed data.') +- +- if not data_str: +- raise api_request_handler.BadRequestError('Missing "data" parameter') +- +- filename = uuid.uuid4() +- params = {'gcs_file_path': '/add-histograms-cache/%s' % filename} +- +- gcs_file = cloudstorage.open( +- params['gcs_file_path'], +- 'w', +- content_type='application/octet-stream', +- retry_params=_RETRY_PARAMS) +- gcs_file.write(data_str) +- gcs_file.close() +- +- _, token_info = self._CreateUploadCompletionToken(params['gcs_file_path']) +- params['upload_completion_token'] = token_info['token'] +- +- retry_options = taskqueue.TaskRetryOptions( +- task_retry_limit=_TASK_RETRY_LIMIT) +- queue = taskqueue.Queue('default') +- queue.add( +- taskqueue.Task( +- url='/add_histograms/process', +- payload=json.dumps(params), +- retry_options=retry_options)) +- return token_info ++ ++def _CreateUploadCompletionToken(temporary_staging_file_path=None): ++ token_info = { ++ 'token': str(uuid.uuid4()), ++ 'file': temporary_staging_file_path, ++ } ++ token = upload_completion_token.Token( ++ id=token_info['token'], ++ temporary_staging_file_path=temporary_staging_file_path, ++ ) ++ token.put() ++ logging.info('Upload completion token created. Token id: %s', ++ token_info['token']) ++ return token, token_info + + + def _LogDebugInfo(histograms): +@@ -276,7 +361,9 @@ def _LogDebugInfo(histograms): + logging.info('No BUILD_URLS in data.') + + +-def ProcessHistogramSet(histogram_dicts, completion_token=None): ++def ProcessHistogramSet(histogram_dicts, ++ completion_token=None, ++ force_flask=False): + if not isinstance(histogram_dicts, list): + raise api_request_handler.BadRequestError( + 'HistogramSet JSON must be a list of dicts') +@@ -363,7 +450,8 @@ def ProcessHistogramSet(histogram_dicts, completion_token=None): + + with timing.WallTimeLogger('_CreateHistogramTasks'): + tasks = _CreateHistogramTasks(suite_key.id(), histograms, revision, +- benchmark_description, completion_token) ++ benchmark_description, completion_token, ++ force_flask) + + with timing.WallTimeLogger('_QueueHistogramTasks'): + _QueueHistogramTasks(tasks) +@@ -385,7 +473,13 @@ def _QueueHistogramTasks(tasks): + f.get_result() + + +-def _MakeTask(params): ++def _MakeTask(params, force_flask=False): ++ if force_flask: ++ logging.info('flaskDebug: _MakeTask for flask') ++ return taskqueue.Task( ++ url='/add_histograms_queue_flask', ++ payload=json.dumps(params), ++ _size_check=False) + return taskqueue.Task( + url='/add_histograms_queue', + payload=json.dumps(params), +@@ -396,7 +490,8 @@ def _CreateHistogramTasks(suite_path, + histograms, + revision, + benchmark_description, +- completion_token=None): ++ completion_token=None, ++ force_flask=False): + tasks = [] + duplicate_check = set() + measurement_add_futures = [] +@@ -419,7 +514,7 @@ def _CreateHistogramTasks(suite_path, + # need for processing each histogram per task. + task_dict = _MakeTaskDict(hist, test_path, revision, benchmark_description, + diagnostics, completion_token) +- tasks.append(_MakeTask([task_dict])) ++ tasks.append(_MakeTask([task_dict], force_flask)) + + if completion_token is not None: + measurement_add_futures.append( +@@ -551,3 +646,61 @@ def _PurgeHistogramBinData(histograms): + keys = list(dm.keys()) + for k in keys: + del dm[k] ++ ++ ++def _CheckRequest(condition, msg): ++ if not condition: ++ raise api_request_handler.BadRequestError(msg) ++ ++ ++# TODO(https://crbug.com/1262292): Update after Python2 trybots retire. ++# pylint: disable=useless-object-inheritance ++class DecompressFileWrapper(object): ++ """A file-like object implementing inline decompression. ++ ++ This class wraps a file-like object and does chunk-based decoding of the data. ++ We only implement the read() function supporting fixed-chunk reading, capped ++ to a predefined constant buffer length. ++ ++ Example ++ ++ with open('filename', 'r') as input: ++ decompressor = DecompressFileWrapper(input) ++ while True: ++ chunk = decompressor.read(4096) ++ if len(chunk) == 0: ++ break ++ // handle the chunk with size <= 4096 ++ """ ++ ++ def __init__(self, source_file, buffer_size=_ZLIB_BUFFER_SIZE): ++ self.source_file = source_file ++ self.decompressor = zlib.decompressobj() ++ self.buffer_size = buffer_size ++ ++ def __enter__(self): ++ return self ++ ++ def read(self, size=None): # pylint: disable=invalid-name ++ if size is None or size < 0: ++ size = self.buffer_size ++ ++ # We want to read chunks of data from the buffer, chunks at a time. ++ temporary_buffer = self.decompressor.unconsumed_tail ++ if len(temporary_buffer) < self.buffer_size / 2: ++ raw_buffer = self.source_file.read(size) ++ if raw_buffer: ++ temporary_buffer += raw_buffer ++ ++ if len(temporary_buffer) == 0: ++ return b'' ++ ++ decompressed_data = self.decompressor.decompress(temporary_buffer, size) ++ return decompressed_data ++ ++ def close(self): # pylint: disable=invalid-name ++ self.decompressor.flush() ++ ++ def __exit__(self, exception_type, exception_value, execution_traceback): ++ self.close() ++ return False +iff --git a/src/third_party/catapult/dashboard/dashboard/add_histograms_queue.py b/src/third_party/catapult/dashboard/dashboard/add_histograms_queue.py +index a4886aa3fea..b88d6291466 +--- a/src/third_party/catapult/dashboard/dashboard/add_histograms_queue.py ++++ b/src/third_party/catapult/dashboard/dashboard/add_histograms_queue.py +@@ -34,6 +34,8 @@ from tracing.value.diagnostics import diagnostic + from tracing.value.diagnostics import diagnostic_ref + from tracing.value.diagnostics import reserved_infos + ++from flask import request, make_response ++ + # Note: annotation names should shorter than add_point._MAX_COLUMN_NAME_LENGTH. + DIAGNOSTIC_NAMES_TO_ANNOTATION_NAMES = { + reserved_infos.CHROMIUM_COMMIT_POSITIONS.name: +@@ -83,72 +85,137 @@ def _CheckRequest(condition, msg): + raise BadRequestError(msg) + + +-class AddHistogramsQueueHandler(request_handler.RequestHandler): +- """Request handler to process a histogram and add it to the datastore. ++def AddHistogramsQueuePost(): ++ """Adds a single histogram or sparse shared diagnostic to the datastore. ++ ++ The |data| request parameter can be either a histogram or a sparse shared ++ diagnostic; the set of diagnostics that are considered sparse (meaning that ++ they don't normally change on every upload for a given benchmark from a ++ given bot) is shown in histogram_helpers.SPARSE_DIAGNOSTIC_TYPES. ++ ++ See https://goo.gl/lHzea6 for detailed information on the JSON format for ++ histograms and diagnostics. + + This request handler is intended to be used only by requests using the + task queue; it shouldn't be directly from outside. ++ ++ Request parameters: ++ data: JSON encoding of a histogram or shared diagnostic. ++ revision: a revision, given as an int. ++ test_path: the test path to which this diagnostic or histogram should be ++ attached. + """ ++ datastore_hooks.SetPrivilegedRequest(flask_flag=True) + +- def get(self): +- self.post() ++ params = json.loads(request.get_data()) + +- def post(self): +- """Adds a single histogram or sparse shared diagnostic to the datastore. ++ _PrewarmGets(params) + +- The |data| request parameter can be either a histogram or a sparse shared +- diagnostic; the set of diagnostics that are considered sparse (meaning that +- they don't normally change on every upload for a given benchmark from a +- given bot) is shown in histogram_helpers.SPARSE_DIAGNOSTIC_TYPES. ++ # Roughly, the processing of histograms and the processing of rows can be ++ # done in parallel since there are no dependencies. + +- See https://goo.gl/lHzea6 for detailed information on the JSON format for +- histograms and diagnostics. ++ histogram_futures = [] ++ token_state_futures = [] + +- Request parameters: +- data: JSON encoding of a histogram or shared diagnostic. +- revision: a revision, given as an int. +- test_path: the test path to which this diagnostic or histogram should be +- attached. ++ try: ++ for p in params: ++ histogram_futures.append((p, _ProcessRowAndHistogram(p))) ++ except Exception as e: # pylint: disable=broad-except ++ for param, futures_info in zip_longest(params, histogram_futures): ++ if futures_info is not None: ++ continue ++ token_state_futures.append( ++ upload_completion_token.Measurement.UpdateStateByPathAsync( ++ param.get('test_path'), param.get('token'), ++ upload_completion_token.State.FAILED, str(e))) ++ ndb.Future.wait_all(token_state_futures) ++ raise ++ ++ for info, futures in histogram_futures: ++ operation_state = upload_completion_token.State.COMPLETED ++ error_message = None ++ for f in futures: ++ exception = f.get_exception() ++ if exception is not None: ++ operation_state = upload_completion_token.State.FAILED ++ error_message = str(exception) ++ token_state_futures.append( ++ upload_completion_token.Measurement.UpdateStateByPathAsync( ++ info.get('test_path'), info.get('token'), operation_state, ++ error_message)) ++ ndb.Future.wait_all(token_state_futures) ++ return make_response('') ++ ++ ++if six.PY2: ++ ++ class AddHistogramsQueueHandler(request_handler.RequestHandler): ++ """Request handler to process a histogram and add it to the datastore. ++ ++ This request handler is intended to be used only by requests using the ++ task queue; it shouldn't be directly from outside. + """ +- datastore_hooks.SetPrivilegedRequest() +- +- params = json.loads(self.request.body) + +- _PrewarmGets(params) +- +- # Roughly, the processing of histograms and the processing of rows can be +- # done in parallel since there are no dependencies. +- +- histogram_futures = [] +- token_state_futures = [] +- +- try: +- for p in params: +- histogram_futures.append((p, _ProcessRowAndHistogram(p))) +- except Exception as e: # pylint: disable=broad-except +- for param, futures_info in zip_longest(params, histogram_futures): +- if futures_info is not None: +- continue ++ def get(self): ++ self.post() ++ ++ def post(self): ++ """Adds a single histogram or sparse shared diagnostic to the datastore. ++ ++ The |data| request parameter can be either a histogram or a sparse shared ++ diagnostic; the set of diagnostics that are considered sparse (meaning that ++ they don't normally change on every upload for a given benchmark from a ++ given bot) is shown in histogram_helpers.SPARSE_DIAGNOSTIC_TYPES. ++ ++ See https://goo.gl/lHzea6 for detailed information on the JSON format for ++ histograms and diagnostics. ++ ++ Request parameters: ++ data: JSON encoding of a histogram or shared diagnostic. ++ revision: a revision, given as an int. ++ test_path: the test path to which this diagnostic or histogram should be ++ attached. ++ """ ++ logging.debug('crbug/1298177 - add_histograms_queue POST triggered') ++ datastore_hooks.SetPrivilegedRequest() ++ ++ params = json.loads(self.request.body) ++ ++ _PrewarmGets(params) ++ ++ # Roughly, the processing of histograms and the processing of rows can be ++ # done in parallel since there are no dependencies. ++ ++ histogram_futures = [] ++ token_state_futures = [] ++ ++ try: ++ for p in params: ++ histogram_futures.append((p, _ProcessRowAndHistogram(p))) ++ except Exception as e: # pylint: disable=broad-except ++ for param, futures_info in zip_longest(params, histogram_futures): ++ if futures_info is not None: ++ continue ++ token_state_futures.append( ++ upload_completion_token.Measurement.UpdateStateByPathAsync( ++ param.get('test_path'), param.get('token'), ++ upload_completion_token.State.FAILED, str(e))) ++ ndb.Future.wait_all(token_state_futures) ++ raise ++ ++ for info, futures in histogram_futures: ++ operation_state = upload_completion_token.State.COMPLETED ++ error_message = None ++ for f in futures: ++ exception = f.get_exception() ++ if exception is not None: ++ operation_state = upload_completion_token.State.FAILED ++ error_message = str(exception) + token_state_futures.append( + upload_completion_token.Measurement.UpdateStateByPathAsync( +- param.get('test_path'), param.get('token'), +- upload_completion_token.State.FAILED, str(e))) ++ info.get('test_path'), info.get('token'), operation_state, ++ error_message)) + ndb.Future.wait_all(token_state_futures) +- raise +- +- for info, futures in histogram_futures: +- operation_state = upload_completion_token.State.COMPLETED +- error_message = None +- for f in futures: +- exception = f.get_exception() +- if exception is not None: +- operation_state = upload_completion_token.State.FAILED +- error_message = exception.message +- token_state_futures.append( +- upload_completion_token.Measurement.UpdateStateByPathAsync( +- info.get('test_path'), info.get('token'), operation_state, +- error_message)) +- ndb.Future.wait_all(token_state_futures) + + + def _GetStoryFromDiagnosticsDict(diagnostics): +@@ -415,6 +482,21 @@ def _MakeRowDict(revision, test_path, tracing_histogram, stat_name=None): + if trace_url_set and not is_summary: + d['supplemental_columns']['a_tracing_uri'] = list(trace_url_set)[-1] + ++ try: ++ bot_id_name = tracing_histogram.diagnostics.get( ++ reserved_infos.BOT_ID.name) ++ if bot_id_name: ++ d['supplemental_columns']['a_bot_id'] = list(bot_id_name) ++ except Exception as e: # pylint: disable=broad-except ++ logging.warning('bot_id failed. Error: %s', e) ++ try: ++ os_detail_vers = tracing_histogram.diagnostics.get( ++ reserved_infos.OS_DETAILED_VERSIONS.name) ++ if os_detail_vers: ++ d['supplemental_columns']['a_os_detail_vers'] = list(os_detail_vers) ++ except Exception as e: # pylint: disable=broad-except ++ logging.warning('os_detail_vers failed. Error: %s', e) ++ + for diag_name, annotation in DIAGNOSTIC_NAMES_TO_ANNOTATION_NAMES.items(): + revision_info = tracing_histogram.diagnostics.get(diag_name) + if not revision_info: +diff --git a/src/third_party/catapult/dashboard/dashboard/add_histograms_queue_test.py b/src/third_party/catapult/dashboard/dashboard/add_histograms_queue_test.py +index ec485b6fd51..e592d13428e +--- a/src/third_party/catapult/dashboard/dashboard/add_histograms_queue_test.py ++++ b/src/third_party/catapult/dashboard/dashboard/add_histograms_queue_test.py +@@ -79,6 +79,8 @@ TEST_OWNERS = { + class AddHistogramsQueueTest(testing_common.TestCase): + + def setUp(self): ++ # TODO(https://crbug.com/1262292): Change to super() after Python2 trybots retire. ++ # pylint: disable=super-with-arguments + super(AddHistogramsQueueTest, self).setUp() + app = webapp2.WSGIApplication([ + ('/add_histograms_queue', +@@ -618,6 +620,8 @@ class AddHistogramsQueueTest(testing_common.TestCase): + class AddHistogramsQueueTestWithUploadCompletionToken(testing_common.TestCase): + + def setUp(self): ++ # TODO(https://crbug.com/1262292): Change to super() after Python2 trybots retire. ++ # pylint: disable=super-with-arguments + super(AddHistogramsQueueTestWithUploadCompletionToken, self).setUp() + app = webapp2.WSGIApplication([ + ('/add_histograms_queue', +diff --git a/src/third_party/catapult/dashboard/dashboard/add_histograms_test.py b/src/third_party/catapult/dashboard/dashboard/add_histograms_test.py +index 8d22fb1b872..7b8bf4d1cfd +--- a/src/third_party/catapult/dashboard/dashboard/add_histograms_test.py ++++ b/src/third_party/catapult/dashboard/dashboard/add_histograms_test.py +@@ -122,6 +122,8 @@ def _CreateHistogram(name='hist', + return histograms + + ++# TODO(https://crbug.com/1262292): Update after Python2 trybots retire. ++# pylint: disable=useless-object-inheritance + class BufferedFakeFile(object): + + def __init__(self, data=str()): +@@ -163,6 +165,8 @@ class BufferedFakeFile(object): + class AddHistogramsBaseTest(testing_common.TestCase): + + def setUp(self): ++ # TODO(https://crbug.com/1262292): Change to super() after Python2 trybots retire. ++ # pylint: disable=super-with-arguments + super(AddHistogramsBaseTest, self).setUp() + app = webapp2.WSGIApplication([ + ('/add_histograms', add_histograms.AddHistogramsHandler), +@@ -1600,6 +1604,8 @@ class AddHistogramsTest(AddHistogramsBaseTest): + class AddHistogramsUploadCompleteonTokenTest(AddHistogramsBaseTest): + + def setUp(self): ++ # TODO(https://crbug.com/1262292): Change to super() after Python2 trybots retire. ++ # pylint: disable=super-with-arguments + super(AddHistogramsUploadCompleteonTokenTest, self).setUp() + + self._TrunOnUploadCompletionTokenExperiment() +@@ -1778,6 +1784,10 @@ class AddHistogramsUploadCompleteonTokenTest(AddHistogramsBaseTest): + self.assertEqual(len(measurements), 1) + self.assertEqual(measurements[0].monitored, True) + ++ # (crbug/1298177) The setup for Flask is not ready yet. We will force the test ++ # to run in the old setup for now. ++ @mock.patch.object(utils, 'IsRunningFlask', ++ mock.MagicMock(return_value=False)) + @mock.patch.object(utils, 'IsDevAppserver', mock.MagicMock(return_value=True)) + def testPost_DevAppserverSucceeds(self): + token_info = self.PostAddHistogram(self.histogram_data) +diff --git a/src/third_party/catapult/dashboard/dashboard/add_point.py b/src/third_party/catapult/dashboard/dashboard/add_point.py +index b7cf1299c39..2bf004d9d3a +--- a/src/third_party/catapult/dashboard/dashboard/add_point.py ++++ b/src/third_party/catapult/dashboard/dashboard/add_point.py +@@ -24,6 +24,8 @@ from dashboard.common import histogram_helpers + from dashboard.common import math_utils + from dashboard.models import graph_data + ++from flask import request, make_response ++ + _TASK_QUEUE_NAME = 'new-points-queue' + + # Number of rows to process per task queue task. This limits the task size +@@ -49,128 +51,252 @@ class BadRequestError(Exception): + """An error indicating that a 400 response status should be returned.""" + + +-class AddPointHandler(request_handler.RequestHandler): +- """URL endpoint to post data to the dashboard.""" +- +- def post(self): +- """Validates data parameter and add task to queue to process points. +- +- The row data comes from a "data" parameter, which is a JSON encoding of a +- list of dictionaries, each of which represents one performance result +- (one point in a graph) and associated data. +- +- [ +- { +- "master": "ChromiumPerf", +- "bot": "xp-release-dual-core", +- "test": "dromaeo/dom/modify", +- "revision": 123456789, +- "value": 24.66, +- "error": 2.33, +- "units": "ms", +- "supplemental_columns": { +- "d_median": 24234.12, +- "d_mean": 23.553, +- "r_webkit": 423340, +- ... +- }, ++def AddPointPost(): ++ """Validates data parameter and add task to queue to process points. ++ ++ The row data comes from a "data" parameter, which is a JSON encoding of a ++ list of dictionaries, each of which represents one performance result ++ (one point in a graph) and associated data. ++ ++ [ ++ { ++ "master": "ChromiumPerf", ++ "bot": "xp-release-dual-core", ++ "test": "dromaeo/dom/modify", ++ "revision": 123456789, ++ "value": 24.66, ++ "error": 2.33, ++ "units": "ms", ++ "supplemental_columns": { ++ "d_median": 24234.12, ++ "d_mean": 23.553, ++ "r_webkit": 423340, + ... + }, + ... +- ] +- +- In general, the required fields are "master", "bot", "test" (which together +- form the test path which identifies the series that this point belongs to), +- and "revision" and "value", which are the X and Y values for the point. +- +- This API also supports the Dashboard JSON v1.0 format (go/telemetry-json), +- the first producer of which is Telemetry. Telemetry provides lightweight +- serialization of values it produces, as JSON. If a dashboard JSON object is +- passed, it will be a single dict rather than a list, with the test, +- value, error, and units fields replaced by a chart_data field containing a +- Chart JSON dict (see design doc, and example below). Dashboard JSON v1.0 is +- processed by converting it into rows (which can be viewed as Dashboard JSON +- v0). +- +- { +- "master": "ChromiumPerf", +- , +- "chart_data": { +- "foo": { +- "bar": { +- "type": "scalar", +- "name": "foo.bar", +- "units": "ms", +- "value": 4.2, +- }, +- "summary": { +- "type": "list_of_scalar_values", +- "name": "foo", +- "units": "ms", +- "values": [4.2, 5.7, 6.8], +- "std": 1.30512, +- }, + }, +- } +- +- Request parameters: +- data: JSON encoding of a list of dictionaries. +- +- Outputs: +- Empty 200 response with if successful, +- 200 response with warning message if optional data is invalid, +- 403 response with error message if sender IP is not white-listed, +- 400 response with error message if required data is invalid. +- 500 with error message otherwise. +- """ +- datastore_hooks.SetPrivilegedRequest() +- try: +- api_auth.Authorize() +- except api_auth.ApiAuthException as error: +- logging.error('Auth error: %s', error) +- self.ReportError('User unauthorized.', 403) +- return ++ ... ++ ] ++ ++ In general, the required fields are "master", "bot", "test" (which together ++ form the test path which identifies the series that this point belongs to), ++ and "revision" and "value", which are the X and Y values for the point. ++ ++ This API also supports the Dashboard JSON v1.0 format (go/telemetry-json), ++ the first producer of which is Telemetry. Telemetry provides lightweight ++ serialization of values it produces, as JSON. If a dashboard JSON object is ++ passed, it will be a single dict rather than a list, with the test, ++ value, error, and units fields replaced by a chart_data field containing a ++ Chart JSON dict (see design doc, and example below). Dashboard JSON v1.0 is ++ processed by converting it into rows (which can be viewed as Dashboard JSON ++ v0). ++ ++ { ++ "master": "ChromiumPerf", ++ , ++ "chart_data": { ++ "foo": { ++ "bar": { ++ "type": "scalar", ++ "name": "foo.bar", ++ "units": "ms", ++ "value": 4.2, ++ }, ++ "summary": { ++ "type": "list_of_scalar_values", ++ "name": "foo", ++ "units": "ms", ++ "values": [4.2, 5.7, 6.8], ++ "std": 1.30512, ++ }, ++ }, ++ } + +- data_str = self.request.get('data') +- if not data_str: +- self.ReportError('Missing "data" parameter.', status=400) +- return ++ Request parameters: ++ data: JSON encoding of a list of dictionaries. + +- self.AddData(data_str) ++ Outputs: ++ Empty 200 response with if successful, ++ 200 response with warning message if optional data is invalid, ++ 403 response with error message if sender IP is not white-listed, ++ 400 response with error message if required data is invalid. ++ 500 with error message otherwise. ++ """ ++ datastore_hooks.SetPrivilegedRequest(flask_flag=True) ++ try: ++ api_auth.Authorize() ++ except api_auth.ApiAuthException as error: ++ logging.error('Auth error: %s', error) ++ return request_handler.RequestHandlerReportError('User unauthorized.', 403) + +- def AddData(self, data_str): +- try: +- data = json.loads(data_str) +- except ValueError: +- self.ReportError('Invalid JSON string.', status=400) +- return ++ data_str = request.values.get('data') ++ if not data_str: ++ return request_handler.RequestHandlerReportError( ++ 'Missing "data" parameter.', status=400) + +- logging.info('Received data: %s', data) ++ return AddData(data_str) + +- try: +- if isinstance(data, dict): +- if data.get('chart_data'): +- data = _DashboardJsonToRawRows(data) +- if not data: +- return # No data to add, bail out. +- else: +- self.ReportError( +- 'Data should be a list of rows or a Dashboard JSON v1.0 dict.', +- status=400) +- return +- +- if data: +- # We only need to validate the row ID for one point, since all points +- # being handled by this upload should have the same row ID. +- last_added_entity = _GetLastAddedEntityForRow(data[0]) +- _ValidateRowId(data[0], last_added_entity) +- +- for row_dict in data: +- ValidateRowDict(row_dict) +- _AddTasks(data) +- except BadRequestError as e: +- # If any of the data was invalid, abort immediately and return an error. +- self.ReportError(str(e), status=400) ++ ++def AddData(data_str): ++ try: ++ data = json.loads(data_str) ++ except ValueError: ++ return request_handler.RequestHandlerReportError( ++ 'Invalid JSON string.', status=400) ++ ++ logging.info('Received data: %s', data) ++ ++ try: ++ if isinstance(data, dict): ++ if data.get('chart_data'): ++ data = _DashboardJsonToRawRows(data) ++ if not data: ++ return make_response('') # No data to add, bail out. ++ else: ++ return request_handler.RequestHandlerReportError( ++ 'Data should be a list of rows or a Dashboard JSON v1.0 dict.', ++ status=400) ++ ++ if data: ++ # We only need to validate the row ID for one point, since all points ++ # being handled by this upload should have the same row ID. ++ last_added_entity = _GetLastAddedEntityForRow(data[0]) ++ _ValidateRowId(data[0], last_added_entity) ++ ++ for row_dict in data: ++ ValidateRowDict(row_dict) ++ _AddTasks(data) ++ return make_response('') ++ except BadRequestError as e: ++ # If any of the data was invalid, abort immediately and return an error. ++ return request_handler.RequestHandlerReportError(str(e), status=400) ++ ++ ++if six.PY2: ++ ++ class AddPointHandler(request_handler.RequestHandler): ++ """URL endpoint to post data to the dashboard.""" ++ ++ def post(self): ++ """Validates data parameter and add task to queue to process points. ++ ++ The row data comes from a "data" parameter, which is a JSON encoding of a ++ list of dictionaries, each of which represents one performance result ++ (one point in a graph) and associated data. ++ ++ [ ++ { ++ "master": "ChromiumPerf", ++ "bot": "xp-release-dual-core", ++ "test": "dromaeo/dom/modify", ++ "revision": 123456789, ++ "value": 24.66, ++ "error": 2.33, ++ "units": "ms", ++ "supplemental_columns": { ++ "d_median": 24234.12, ++ "d_mean": 23.553, ++ "r_webkit": 423340, ++ ... ++ }, ++ ... ++ }, ++ ... ++ ] ++ ++ In general, the required fields are "master", "bot", "test" (which together ++ form the test path which identifies the series that this point belongs to), ++ and "revision" and "value", which are the X and Y values for the point. ++ ++ This API also supports the Dashboard JSON v1.0 format (go/telemetry-json), ++ the first producer of which is Telemetry. Telemetry provides lightweight ++ serialization of values it produces, as JSON. If a dashboard JSON object is ++ passed, it will be a single dict rather than a list, with the test, ++ value, error, and units fields replaced by a chart_data field containing a ++ Chart JSON dict (see design doc, and example below). Dashboard JSON v1.0 is ++ processed by converting it into rows (which can be viewed as Dashboard JSON ++ v0). ++ ++ { ++ "master": "ChromiumPerf", ++ , ++ "chart_data": { ++ "foo": { ++ "bar": { ++ "type": "scalar", ++ "name": "foo.bar", ++ "units": "ms", ++ "value": 4.2, ++ }, ++ "summary": { ++ "type": "list_of_scalar_values", ++ "name": "foo", ++ "units": "ms", ++ "values": [4.2, 5.7, 6.8], ++ "std": 1.30512, ++ }, ++ }, ++ } ++ ++ Request parameters: ++ data: JSON encoding of a list of dictionaries. ++ ++ Outputs: ++ Empty 200 response with if successful, ++ 200 response with warning message if optional data is invalid, ++ 403 response with error message if sender IP is not white-listed, ++ 400 response with error message if required data is invalid. ++ 500 with error message otherwise. ++ """ ++ logging.debug('crbug/1298177 - add_point POST triggered') ++ datastore_hooks.SetPrivilegedRequest() ++ try: ++ api_auth.Authorize() ++ except api_auth.ApiAuthException as error: ++ logging.error('Auth error: %s', error) ++ self.ReportError('User unauthorized.', 403) ++ return ++ ++ data_str = self.request.get('data') ++ if not data_str: ++ self.ReportError('Missing "data" parameter.', status=400) ++ return ++ ++ self.AddData(data_str) ++ ++ def AddData(self, data_str): ++ try: ++ data = json.loads(data_str) ++ except ValueError: ++ self.ReportError('Invalid JSON string.', status=400) ++ return ++ ++ logging.info('Received data: %s', data) ++ ++ try: ++ if isinstance(data, dict): ++ if data.get('chart_data'): ++ data = _DashboardJsonToRawRows(data) ++ if not data: ++ return # No data to add, bail out. ++ else: ++ self.ReportError( ++ 'Data should be a list of rows or a Dashboard JSON v1.0 dict.', ++ status=400) ++ return ++ ++ if data: ++ # We only need to validate the row ID for one point, since all points ++ # being handled by this upload should have the same row ID. ++ last_added_entity = _GetLastAddedEntityForRow(data[0]) ++ _ValidateRowId(data[0], last_added_entity) ++ ++ for row_dict in data: ++ ValidateRowDict(row_dict) ++ _AddTasks(data) ++ except BadRequestError as e: ++ # If any of the data was invalid, abort immediately and return an error. ++ self.ReportError(str(e), status=400) + + + def _ValidateNameString(value, name): +@@ -696,6 +822,8 @@ def _IsAcceptableRowId(row_id, last_row_id): + return True + + ++# TODO(https://crbug.com/1262292): raise directly after Python2 trybots retire. ++# pylint: disable=inconsistent-return-statements + def GetAndValidateRowId(row_dict): + """Returns the integer ID for a new Row. + +@@ -830,10 +958,19 @@ def _CheckSupplementalColumn(name, value): + value = str(value) + + if name.startswith('a_'): +- # Annotation column, should be a short string. ++ # Annotation column, is typically a short string. ++ # Bot_ID lists can be long, truncate if exceed max length + if len(str(value)) > _STRING_COLUMN_MAX_LENGTH: +- logging.warning('Value for "%s" too long, max length is %d.', name, ++ logging.warning('Value for "%s" too long, truncated to max length %d.', ++ name, + _STRING_COLUMN_MAX_LENGTH) +- return None ++ if isinstance(value, list): ++ while len(str(value)) > _STRING_COLUMN_MAX_LENGTH: ++ value.pop() ++ elif isinstance(value, str): ++ value = value[:_STRING_COLUMN_MAX_LENGTH] ++ else: ++ logging.warning('Value for "%s" is not truncatable', name) ++ return None + + return value +diff --git a/src/third_party/catapult/dashboard/dashboard/add_point_queue.py b/src/third_party/catapult/dashboard/dashboard/add_point_queue.py +index a56564e9379..6be578a5f11 +--- a/src/third_party/catapult/dashboard/dashboard/add_point_queue.py ++++ b/src/third_party/catapult/dashboard/dashboard/add_point_queue.py +@@ -8,6 +8,7 @@ from __future__ import absolute_import + + import json + import logging ++import six + + from google.appengine.api import datastore_errors + from google.appengine.ext import ndb +@@ -23,74 +24,140 @@ from dashboard.common import utils + from dashboard.models import anomaly + from dashboard.models import graph_data + ++from flask import request, make_response + +-class AddPointQueueHandler(request_handler.RequestHandler): +- """Request handler to process points and add them to the datastore. + +- This request handler is intended to be used only by requests using the +- task queue; it shouldn't be directly from outside. +- """ +- +- def get(self): +- """A get request is the same a post request for this endpoint.""" +- self.post() +- +- def post(self): +- """Adds a set of points from the post data. ++def AddPointQueuePost(): ++ """Adds a set of points from the post data. + +- Request parameters: +- data: JSON encoding of a list of dictionaries. Each dictionary represents +- one point to add. For each dict, one Row entity will be added, and +- any required TestMetadata or Master or Bot entities will be created. ++ Request parameters: ++ data: JSON encoding of a list of dictionaries. Each dictionary represents ++ one point to add. For each dict, one Row entity will be added, and ++ any required TestMetadata or Master or Bot entities will be created. ++ """ ++ datastore_hooks.SetPrivilegedRequest(flask_flag=True) ++ ++ data = json.loads(request.values.get('data')) ++ _PrewarmGets(data) ++ ++ all_put_futures = [] ++ added_rows = [] ++ parent_tests = [] ++ for row_dict in data: ++ try: ++ new_row, parent_test, put_futures = _AddRow(row_dict) ++ added_rows.append(new_row) ++ parent_tests.append(parent_test) ++ all_put_futures.extend(put_futures) ++ ++ except add_point.BadRequestError as e: ++ logging.error('Could not add %s, it was invalid.', str(e)) ++ except datastore_errors.BadRequestError as e: ++ logging.info('While trying to store %s', row_dict) ++ logging.error('Datastore request failed: %s.', str(e)) ++ return request_handler.RequestHandlerReportError( ++ 'Datastore request failed: %s.' % str(e), status=400) ++ ++ ndb.Future.wait_all(all_put_futures) ++ ++ client = sheriff_config_client.GetSheriffConfigClient() ++ tests_keys = [] ++ for t in parent_tests: ++ reason = [] ++ subscriptions, _ = client.Match(t.test_path, check=True) ++ if not subscriptions: ++ reason.append('subscriptions') ++ if not t.has_rows: ++ reason.append('has_rows') ++ if IsRefBuild(t.key): ++ reason.append('RefBuild') ++ if reason: ++ logging.info('Skip test: %s reason=%s', t.key, ','.join(reason)) ++ continue ++ logging.info('Process test: %s', t.key) ++ tests_keys.append(t.key) ++ ++ # Updating of the cached graph revisions should happen after put because ++ # it requires the new row to have a timestamp, which happens upon put. ++ futures = [ ++ graph_revisions.AddRowsToCacheAsync(added_rows), ++ find_anomalies.ProcessTestsAsync(tests_keys) ++ ] ++ ndb.Future.wait_all(futures) ++ return make_response('') ++ ++ ++if six.PY2: ++ ++ class AddPointQueueHandler(request_handler.RequestHandler): ++ """Request handler to process points and add them to the datastore. ++ ++ This request handler is intended to be used only by requests using the ++ task queue; it shouldn't be directly from outside. + """ +- datastore_hooks.SetPrivilegedRequest() +- +- data = json.loads(self.request.get('data')) +- _PrewarmGets(data) +- +- all_put_futures = [] +- added_rows = [] +- parent_tests = [] +- for row_dict in data: +- try: +- new_row, parent_test, put_futures = _AddRow(row_dict) +- added_rows.append(new_row) +- parent_tests.append(parent_test) +- all_put_futures.extend(put_futures) +- +- except add_point.BadRequestError as e: +- logging.error('Could not add %s, it was invalid.', str(e)) +- except datastore_errors.BadRequestError as e: +- logging.info('While trying to store %s', row_dict) +- logging.error('Datastore request failed: %s.', str(e)) +- return +- +- ndb.Future.wait_all(all_put_futures) +- +- client = sheriff_config_client.GetSheriffConfigClient() +- tests_keys = [] +- for t in parent_tests: +- reason = [] +- subscriptions, _ = client.Match(t.test_path, check=True) +- if not subscriptions: +- reason.append('subscriptions') +- if not t.has_rows: +- reason.append('has_rows') +- if IsRefBuild(t.key): +- reason.append('RefBuild') +- if reason: +- logging.info('Skip test: %s reason=%s', t.key, ','.join(reason)) +- continue +- logging.info('Process test: %s', t.key) +- tests_keys.append(t.key) +- +- # Updating of the cached graph revisions should happen after put because +- # it requires the new row to have a timestamp, which happens upon put. +- futures = [ +- graph_revisions.AddRowsToCacheAsync(added_rows), +- find_anomalies.ProcessTestsAsync(tests_keys) +- ] +- ndb.Future.wait_all(futures) ++ ++ def get(self): ++ """A get request is the same a post request for this endpoint.""" ++ logging.debug('crbug/1298177 - add_point_queue GET triggered') ++ self.post() ++ ++ def post(self): ++ """Adds a set of points from the post data. ++ ++ Request parameters: ++ data: JSON encoding of a list of dictionaries. Each dictionary represents ++ one point to add. For each dict, one Row entity will be added, and ++ any required TestMetadata or Master or Bot entities will be created. ++ """ ++ logging.debug('crbug/1298177 - add_point_queue POST triggered') ++ datastore_hooks.SetPrivilegedRequest() ++ ++ data = json.loads(self.request.get('data')) ++ _PrewarmGets(data) ++ ++ all_put_futures = [] ++ added_rows = [] ++ parent_tests = [] ++ for row_dict in data: ++ try: ++ new_row, parent_test, put_futures = _AddRow(row_dict) ++ added_rows.append(new_row) ++ parent_tests.append(parent_test) ++ all_put_futures.extend(put_futures) ++ ++ except add_point.BadRequestError as e: ++ logging.error('Could not add %s, it was invalid.', str(e)) ++ except datastore_errors.BadRequestError as e: ++ logging.info('While trying to store %s', row_dict) ++ logging.error('Datastore request failed: %s.', str(e)) ++ return ++ ++ ndb.Future.wait_all(all_put_futures) ++ ++ client = sheriff_config_client.GetSheriffConfigClient() ++ tests_keys = [] ++ for t in parent_tests: ++ reason = [] ++ subscriptions, _ = client.Match(t.test_path, check=True) ++ if not subscriptions: ++ reason.append('subscriptions') ++ if not t.has_rows: ++ reason.append('has_rows') ++ if IsRefBuild(t.key): ++ reason.append('RefBuild') ++ if reason: ++ logging.info('Skip test: %s reason=%s', t.key, ','.join(reason)) ++ continue ++ logging.info('Process test: %s', t.key) ++ tests_keys.append(t.key) ++ ++ # Updating of the cached graph revisions should happen after put because ++ # it requires the new row to have a timestamp, which happens upon put. ++ futures = [ ++ graph_revisions.AddRowsToCacheAsync(added_rows), ++ find_anomalies.ProcessTestsAsync(tests_keys) ++ ] ++ ndb.Future.wait_all(futures) + + + def _PrewarmGets(data): +diff --git a/src/third_party/catapult/dashboard/dashboard/add_point_queue_test.py b/src/third_party/catapult/dashboard/dashboard/add_point_queue_test.py +index 78318055614..ca1e7de5297 +--- a/src/third_party/catapult/dashboard/dashboard/add_point_queue_test.py ++++ b/src/third_party/catapult/dashboard/dashboard/add_point_queue_test.py +@@ -17,6 +17,8 @@ from dashboard.models import graph_data + class GetOrCreateAncestorsTest(testing_common.TestCase): + + def setUp(self): ++ # TODO(https://crbug.com/1262292): Change to super() after Python2 trybots retire. ++ # pylint: disable=super-with-arguments + super(GetOrCreateAncestorsTest, self).setUp() + self.SetCurrentUser('foo@bar.com', is_admin=True) + +diff --git a/src/third_party/catapult/dashboard/dashboard/add_point_test.py b/src/third_party/catapult/dashboard/dashboard/add_point_test.py +index c5987b20d42..b7e74a5ad25 +--- a/src/third_party/catapult/dashboard/dashboard/add_point_test.py ++++ b/src/third_party/catapult/dashboard/dashboard/add_point_test.py +@@ -181,6 +181,8 @@ _UNITS_TO_DIRECTION_DICT = { + class AddPointTest(testing_common.TestCase): + + def setUp(self): ++ # TODO(https://crbug.com/1262292): Change to super() after Python2 trybots retire. ++ # pylint: disable=super-with-arguments + super(AddPointTest, self).setUp() + app = webapp2.WSGIApplication([('/add_point', add_point.AddPointHandler), + ('/add_point_queue', diff --git a/unrar/src/arcread.cpp b/unrar/src/arcread.cpp index 468d387a24721b651fde2745dd6c2434d9a140e0..51916a050dc2c4752db574f7f467ba02987bfd64 100644 --- a/unrar/src/arcread.cpp +++ b/unrar/src/arcread.cpp @@ -1442,7 +1442,9 @@ bool Archive::ReadSubData(Array *UnpData,File *DestFile,bool TestMode) { if (SubHead.UnpSize>0x1000000) { - // So huge allocation must never happen in valid archives. + // Prevent the excessive allocation. When reading to memory, normally + // this function operates with reasonably small blocks, such as + // the archive comment, NTFS ACL or "Zone.Identifier" NTFS stream. uiMsg(UIERROR_SUBHEADERUNKNOWN,FileName); return false; } diff --git a/unrar/src/extinfo.cpp b/unrar/src/extinfo.cpp index 5cb90a4080f670c1e1595be7a20e7934d6f0c2ad..bea64a22f86b1b08381494be28d6dc484dbc4a15 100644 --- a/unrar/src/extinfo.cpp +++ b/unrar/src/extinfo.cpp @@ -112,6 +112,69 @@ static bool LinkInPath(const wchar *Name) } +// Delete symbolic links in file path, if any, and replace them by directories. +// Prevents extracting files outside of destination folder with symlink chains. +bool LinksToDirs(const wchar *SrcName,const wchar *SkipPart,std::wstring &LastChecked) +{ + // Unlike Unix, Windows doesn't expand lnk1 in symlink targets like + // "lnk1/../dir", but converts the path to "dir". In Unix we need to call + // this function to prevent placing unpacked files outside of destination + // folder if previously we unpacked "dir/lnk1" -> "..", + // "dir/lnk2" -> "lnk1/.." and "dir/lnk2/anypath/poc.txt". + // We may still need this function to prevent abusing symlink chains + // in link source path if we remove detection of such chains + // in IsRelativeSymlinkSafe. This function seems to make other symlink + // related safety checks redundant, but for now we prefer to keep them too. + // + // 2022.12.01: the performance impact is minimized after adding the check + // against the previous path and enabling this verification only after + // extracting a symlink with ".." in target. So we enabled it for Windows + // as well for extra safety. +//#ifdef _UNIX + wchar Path[NM]; + if (wcslen(SrcName)>=ASIZE(Path)) + return false; // It should not be that long, skip. + wcsncpyz(Path,SrcName,ASIZE(Path)); + + size_t SkipLength=wcslen(SkipPart); + + if (SkipLength>0 && wcsncmp(Path,SkipPart,SkipLength)!=0) + SkipLength=0; // Parameter validation, not really needed now. + + // Do not check parts already checked in previous path to improve performance. + for (uint I=0;Path[I]!=0 && ISkipLength) + SkipLength=I; + + wchar *Name=Path; + if (SkipLength>0) + { + // Avoid converting symlinks in destination path part specified by user. + Name+=SkipLength; + while (IsPathDiv(*Name)) + Name++; + } + + for (wchar *s=Path+wcslen(Path)-1;s>Name;s--) + if (IsPathDiv(*s)) + { + *s=0; + FindData FD; + if (FindFile::FastFind(Path,&FD,true) && FD.IsLink) +#ifdef _WIN_ALL + if (!DelDir(Path)) +#else + if (!DelFile(Path)) +#endif + return false; // Couldn't delete the symlink to replace it with directory. + } + LastChecked=SrcName; +//#endif + return true; +} + + + bool IsRelativeSymlinkSafe(CommandData *Cmd,const wchar *SrcName,const wchar *PrepSrcName,const wchar *TargetName) { // Catch root dir based /path/file paths also as stuff like \\?\. @@ -131,10 +194,14 @@ bool IsRelativeSymlinkSafe(CommandData *Cmd,const wchar *SrcName,const wchar *Pr UpLevels++; TargetName++; } - // If link target includes "..", it must not have another links - // in the path, because they can bypass our safety check. For example, + // If link target includes "..", it must not have another links in its + // source path, because they can bypass our safety check. For example, // suppose we extracted "lnk1" -> "." first and "lnk1/lnk2" -> ".." next - // or "dir/lnk1" -> ".." first and "dir/lnk1/lnk2" -> ".." next. + // or "dir/lnk1" -> ".." first, "dir/lnk1/lnk2" -> ".." next and + // file "dir/lnk1/lnk2/poc.txt" last. + // Do not confuse with link chains in target, this is in link source path. + // It is important for Windows too, though this check can be omitted + // if LinksToDirs is invoked in Windows as well. if (UpLevels>0 && LinkInPath(PrepSrcName)) return false; @@ -160,15 +227,26 @@ bool IsRelativeSymlinkSafe(CommandData *Cmd,const wchar *SrcName,const wchar *Pr } -bool ExtractSymlink(CommandData *Cmd,ComprDataIO &DataIO,Archive &Arc,const wchar *LinkName) +bool ExtractSymlink(CommandData *Cmd,ComprDataIO &DataIO,Archive &Arc,const wchar *LinkName,bool &UpLink) { + // Returning true in Uplink indicates that link target might include ".." + // and enables additional checks. It is ok to falsely return true here, + // as it implies only the minor performance penalty. But we shall always + // return true for links with ".." in target for security reason. + + UpLink=true; // Assume the target might include potentially unsafe "..". +#if defined(SAVE_LINKS) && defined(_UNIX) || defined(_WIN_ALL) + if (Arc.Format==RARFMT50) // For RAR5 archives we can check RedirName for both Unix and Windows. + UpLink=wcsstr(Arc.FileHead.RedirName,L"..")!=NULL; +#endif + #if defined(SAVE_LINKS) && defined(_UNIX) // For RAR 3.x archives we process links even in test mode to skip link data. if (Arc.Format==RARFMT15) - return ExtractUnixLink30(Cmd,DataIO,Arc,LinkName); + return ExtractUnixLink30(Cmd,DataIO,Arc,LinkName,UpLink); if (Arc.Format==RARFMT50) return ExtractUnixLink50(Cmd,LinkName,&Arc.FileHead); -#elif defined _WIN_ALL +#elif defined(_WIN_ALL) // RAR 5.0 archives store link information in file header, so there is // no need to additionally test it if we do not create a file. if (Arc.Format==RARFMT50) diff --git a/unrar/src/extinfo.hpp b/unrar/src/extinfo.hpp index 2b0005daa21da4a10350180d2f05f182996772c1..9c42f7d502ec5c8f6e64be7dd3e272047eb06e3b 100644 --- a/unrar/src/extinfo.hpp +++ b/unrar/src/extinfo.hpp @@ -1,8 +1,9 @@ #ifndef _RAR_EXTINFO_ #define _RAR_EXTINFO_ +bool LinksToDirs(const wchar *SrcName,const wchar *SkipPart,std::wstring &LastChecked); bool IsRelativeSymlinkSafe(CommandData *Cmd,const wchar *SrcName,const wchar *PrepSrcName,const wchar *TargetName); -bool ExtractSymlink(CommandData *Cmd,ComprDataIO &DataIO,Archive &Arc,const wchar *LinkName); +bool ExtractSymlink(CommandData *Cmd,ComprDataIO &DataIO,Archive &Arc,const wchar *LinkName,bool &UpLink); #ifdef _UNIX void SetUnixOwner(Archive &Arc,const wchar *FileName); #endif diff --git a/unrar/src/extract.cpp b/unrar/src/extract.cpp index 2c264b107040130d2d4fd8172d4a34e52dee2a24..f12c2a39de7b7f5e6bb8ac09e641e33d8a54ce49 100644 --- a/unrar/src/extract.cpp +++ b/unrar/src/extract.cpp @@ -9,6 +9,12 @@ CmdExtract::CmdExtract(CommandData *Cmd) *DestFileName=0; TotalFileCount=0; + + // Common for all archives involved. Set here instead of DoExtract() + // to use in unrar.dll too. Allows to avoid LinksToDirs() calls + // and save CPU time in no symlinks including ".." in target were extracted. + UpLinkExtracted=false; + Unp=new Unpack(&DataIO); #ifdef RAR_SMP Unp->SetThreads(Cmd->Threads); @@ -99,6 +105,8 @@ void CmdExtract::ExtractArchiveInit(Archive &Arc) AnySolidDataUnpackedWell=false; StartTime.SetCurrentTime(); + + LastCheckedSymlink.clear(); } @@ -523,6 +531,10 @@ bool CmdExtract::ExtractCurrentFile(Archive &Arc,size_t HeaderSize,bool &Repeat) wcsncpyz(DestFileName,Cmd->DllDestName,ASIZE(DestFileName)); #endif + if (ExtrFile && Command!='P' && !Cmd->Test && !Cmd->AbsoluteLinks && + UpLinkExtracted) + ExtrFile=LinksToDirs(DestFileName,Cmd->ExtrPath,LastCheckedSymlink); + File CurFile; #if defined(CHROMIUM_UNRAR) // Since extraction is done in a sandbox, this must extract to the temp file @@ -655,10 +667,22 @@ bool CmdExtract::ExtractCurrentFile(Archive &Arc,size_t HeaderSize,bool &Repeat) if (Type==FSREDIR_HARDLINK || Type==FSREDIR_FILECOPY) { + wchar RedirName[NM]; + + // 2022.11.15: Might be needed when unpacking WinRAR 5.0 links with + // Unix RAR. WinRAR 5.0 used \ path separators here, when beginning + // from 5.10 even Windows version uses / internally and converts + // them to \ when reading FHEXTRA_REDIR. + // We must perform this conversion before ConvertPath call, + // so paths mixing different slashes like \dir1/dir2\file are + // processed correctly. + SlashToNative(Arc.FileHead.RedirName,RedirName,ASIZE(RedirName)); + + ConvertPath(RedirName,RedirName,ASIZE(RedirName)); + wchar NameExisting[NM]; - ExtrPrepareName(Arc,Arc.FileHead.RedirName,NameExisting,ASIZE(NameExisting)); + ExtrPrepareName(Arc,RedirName,NameExisting,ASIZE(NameExisting)); if (FileCreateMode && *NameExisting!=0) // *NameExisting can be 0 in case of excessive -ap switch. - if (Type==FSREDIR_HARDLINK) LinkSuccess=ExtractHardlink(DestFileName,NameExisting,ASIZE(NameExisting)); else LinkSuccess=ExtractFileCopy(CurFile,Arc.FileName,DestFileName,NameExisting,ASIZE(NameExisting)); @@ -667,7 +691,22 @@ bool CmdExtract::ExtractCurrentFile(Archive &Arc,size_t HeaderSize,bool &Repeat) if (Type==FSREDIR_UNIXSYMLINK || Type==FSREDIR_WINSYMLINK || Type==FSREDIR_JUNCTION) { if (FileCreateMode) - LinkSuccess=ExtractSymlink(Cmd,DataIO,Arc,DestFileName); + { + bool UpLink; + LinkSuccess=ExtractSymlink(Cmd,DataIO,Arc,DestFileName,UpLink); + UpLinkExtracted|=LinkSuccess && UpLink; + + // We do not actually need to reset the cache here if we cache + // only the single last checked path, because at this point + // it will always contain the link own path and link can't + // overwrite its parent folder. But if we ever decide to cache + // several already checked paths, we'll need to reset them here. + // Otherwise if no files were created in one of such paths, + // let's say because of file create error, it might be possible + // to overwrite the path with link and avoid checks. We keep this + // code here as a reminder in case of possible modifications. + LastCheckedSymlink.clear(); // Reset cache for safety reason. + } } else { @@ -848,8 +887,6 @@ void CmdExtract::UnstoreFile(ComprDataIO &DataIO,int64 DestUnpSize) bool CmdExtract::ExtractFileCopy(File &New,wchar *ArcName,wchar *NameNew,wchar *NameExisting,size_t NameExistingSize) { - SlashToNative(NameExisting,NameExisting,NameExistingSize); // Not needed for RAR 5.1+ archives. - File Existing; if (!Existing.WOpen(NameExisting)) { @@ -1105,6 +1142,8 @@ void CmdExtract::ExtrCreateDir(Archive &Arc,const wchar *ArcFileName) } if (!DirExist) { + if (!Cmd->AbsoluteLinks && UpLinkExtracted) + LinksToDirs(DestFileName,Cmd->ExtrPath,LastCheckedSymlink); CreatePath(DestFileName,true); MDCode=MakeDir(DestFileName,!Cmd->IgnoreGeneralAttr,Arc.FileHead.FileAttr); if (MDCode!=MKDIR_SUCCESS) @@ -1196,6 +1235,8 @@ bool CmdExtract::ExtrCreateFile(Archive &Arc,File &CurFile) MakeNameUsable(DestFileName,true); + if (!Cmd->AbsoluteLinks && UpLinkExtracted) + LinksToDirs(DestFileName,Cmd->ExtrPath,LastCheckedSymlink); CreatePath(DestFileName,true); if (FileCreate(Cmd,&CurFile,DestFileName,ASIZE(DestFileName),&UserReject,Arc.FileHead.UnpSize,&Arc.FileHead.mtime,true)) { diff --git a/unrar/src/extract.hpp b/unrar/src/extract.hpp index d38ff8658ecddc15bcaff4b46513e676626c90a4..834bf5e8bda9a0bda982719d6d19d76b97032299 100644 --- a/unrar/src/extract.hpp +++ b/unrar/src/extract.hpp @@ -52,6 +52,12 @@ class CmdExtract bool PrevProcessed; // If previous file was successfully extracted or tested. wchar DestFileName[NM]; bool PasswordCancelled; + bool UpLinkExtracted; // At least one symlink with ".." in target was extracted. + + // Last path checked for symlinks. We use it to improve the performance, + // so we do not check recently checked folders again. + std::wstring LastCheckedSymlink; + #if defined(_WIN_ALL) && !defined(SFX_MODULE) && !defined(SILENT) bool Fat32,NotFat32; #endif diff --git a/unrar/src/hardlinks.cpp b/unrar/src/hardlinks.cpp index 946a395279325f9b47264d46993e770d0d695785..4b980deefc9c3e1bcfaa3ef0f02b7d1e9008387e 100644 --- a/unrar/src/hardlinks.cpp +++ b/unrar/src/hardlinks.cpp @@ -1,7 +1,5 @@ bool ExtractHardlink(wchar *NameNew,wchar *NameExisting,size_t NameExistingSize) { - SlashToNative(NameExisting,NameExisting,NameExistingSize); // Not needed for RAR 5.1+ archives. - if (!FileExist(NameExisting)) { uiMsg(UIERROR_HLINKCREATE,NameNew); diff --git a/unrar/src/model.cpp b/unrar/src/model.cpp index 1ca9f03e9bcc54c1febbe5fb1820a312739b1ed0..18b0c134027e013e5a1826c108ef4a0e0b13b5dd 100644 --- a/unrar/src/model.cpp +++ b/unrar/src/model.cpp @@ -546,13 +546,15 @@ inline bool RARPPM_CONTEXT::decodeSymbol2(ModelPPM *Model) Model->Coder.SubRange.LowCount=HiCnt; Model->Coder.SubRange.HighCount=Model->Coder.SubRange.scale; i=NumStats-Model->NumMasked; - pps--; + + // 2022.12.02: we removed pps-- here and changed the code below to avoid + // "array subscript -1 is outside array bounds" warning in some compilers. do { - pps++; if (pps>=ps+ASIZE(ps)) // Extra safety check. return false; - Model->CharMask[(*pps)->Symbol]=Model->EscCount; + Model->CharMask[(*pps)->Symbol]=Model->EscCount; + pps++; } while ( --i ); psee2c->Summ += Model->Coder.SubRange.scale; Model->NumMasked = NumStats; diff --git a/unrar/src/os.hpp b/unrar/src/os.hpp index 51d547b0f68ba0840bcf37d9ace64a2a424acedf..40e194f3c8b5225866b78e15897670bb66b5e9ec 100644 --- a/unrar/src/os.hpp +++ b/unrar/src/os.hpp @@ -13,6 +13,8 @@ #endif #include +#include +#include #if defined(_WIN_ALL) || defined(_EMX) diff --git a/unrar/src/pathfn.cpp b/unrar/src/pathfn.cpp index 4c4d40626e8bef59ab416207c3650aeacc1c1d5c..30c8e95106df53f94b17cc75dc1b834fc3b366a5 100644 --- a/unrar/src/pathfn.cpp +++ b/unrar/src/pathfn.cpp @@ -31,11 +31,17 @@ wchar* ConvertPath(const wchar *SrcPath,wchar *DestPath,size_t DestSize) const wchar *s=DestPtr; if (s[0]!=0 && IsDriveDiv(s[1])) s+=2; - if (s[0]=='\\' && s[1]=='\\') + + // Skip UNC Windows \\server\share\ or Unix //server/share/ + if (IsPathDiv(s[0]) && IsPathDiv(s[1])) { - const wchar *Slash=wcschr(s+2,'\\'); - if (Slash!=NULL && (Slash=wcschr(Slash+1,'\\'))!=NULL) - s=Slash+1; + uint SlashCount=0; + for (const wchar *t=s+2;*t!=0;t++) + if (IsPathDiv(*t) && ++SlashCount==2) + { + s=t+1; // Found two more path separators after leading two. + break; + } } for (const wchar *t=s;*t!=0;t++) if (IsPathDiv(*t)) diff --git a/unrar/src/timefn.hpp b/unrar/src/timefn.hpp index 5271361644e089edc64f9a4bcec855cee423ccd5..49b61e85d6ec7f904d99586a7479bb89792e0db3 100644 --- a/unrar/src/timefn.hpp +++ b/unrar/src/timefn.hpp @@ -22,6 +22,17 @@ class RarTime // Internal time representation in 1/TICKS_PER_SECOND since 01.01.1601. // We use nanoseconds here to handle the high precision Unix time. + // It allows dates up to July 2185. + // + // If we'll ever need to extend the date range, we can define a lower + // precision Windows version of TICKS_PER_SECOND. But then Unix and Windows + // versions can differ in least significant digits of "lt" time output + // for Unix archives. + // Alternatively we can introduce 'bool HighPrecision' set to true + // in SetUnixNS() and TicksPerSecond() instead of constant above. + // It might be more reliable than defining TicksPerSecond variable, + // which wouldn't survive memset of any structure hosting RarTime. + // We would need to eliminate all such memsets in the entire code first. uint64 itime; public: // RarLocalTime::Reminder precision. Must be equal to TICKS_PER_SECOND. diff --git a/unrar/src/ulinks.cpp b/unrar/src/ulinks.cpp index 1656824f66eaeb0b0a3f901a037b9cd53faa1944..4bbe691c16f995fe1cdee27f15ed3179ee8da07e 100644 --- a/unrar/src/ulinks.cpp +++ b/unrar/src/ulinks.cpp @@ -45,7 +45,8 @@ static bool IsFullPath(const char *PathA) // Unix ASCII version. } -bool ExtractUnixLink30(CommandData *Cmd,ComprDataIO &DataIO,Archive &Arc,const wchar *LinkName) +static bool ExtractUnixLink30(CommandData *Cmd,ComprDataIO &DataIO,Archive &Arc, + const wchar *LinkName,bool &UpLink) { char Target[NM]; if (IsLink(Arc.FileHead.FileAttr)) @@ -75,13 +76,14 @@ bool ExtractUnixLink30(CommandData *Cmd,ComprDataIO &DataIO,Archive &Arc,const w if (!Cmd->AbsoluteLinks && (*TargetW==0 || IsFullPath(TargetW) || !IsRelativeSymlinkSafe(Cmd,Arc.FileHead.FileName,LinkName,TargetW))) return false; + UpLink=strstr(Target,"..")!=NULL; return UnixSymlink(Target,LinkName,&Arc.FileHead.mtime,&Arc.FileHead.atime); } return false; } -bool ExtractUnixLink50(CommandData *Cmd,const wchar *Name,FileHeader *hd) +static bool ExtractUnixLink50(CommandData *Cmd,const wchar *Name,FileHeader *hd) { char Target[NM]; WideToChar(hd->RedirName,Target,ASIZE(Target)); diff --git a/unrar/src/win32stm.cpp b/unrar/src/win32stm.cpp index eaa43be2d97188834d454365d58710607290bfa7..c78dd56b5507139e44e4d042988742a8489f045e 100644 --- a/unrar/src/win32stm.cpp +++ b/unrar/src/win32stm.cpp @@ -117,8 +117,12 @@ void ExtractStreams(Archive &Arc,const wchar *FileName,bool TestMode) if ((fd.FileAttr & FILE_ATTRIBUTE_READONLY)!=0) SetFileAttr(FileName,fd.FileAttr & ~FILE_ATTRIBUTE_READONLY); File CurFile; - if (CurFile.WCreate(FullName) && Arc.ReadSubData(NULL,&CurFile,false)) - CurFile.Close(); + + if (CurFile.WCreate(FullName)) + { + if (Arc.ReadSubData(NULL,&CurFile,false)) + CurFile.Close(); + } File HostFile; if (Found && HostFile.Open(FileName,FMF_OPENSHARED|FMF_UPDATE)) SetFileTime(HostFile.GetHandle(),&fd.ftCreationTime,&fd.ftLastAccessTime, diff --git a/zlib/contrib/tests/fuzzers/deflate_fuzzer.cc b/zlib/contrib/tests/fuzzers/deflate_fuzzer.cc index ad1a985c68334a6ea234ce852039d157a2f7f55d..5f8ddad427624f31b070c6685e612a27b49db426 100644 --- a/zlib/contrib/tests/fuzzers/deflate_fuzzer.cc +++ b/zlib/contrib/tests/fuzzers/deflate_fuzzer.cc @@ -23,35 +23,74 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { FuzzedDataProvider fdp(data, size); - int level = fdp.PickValueInArray({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + int level = fdp.PickValueInArray({-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); int windowBits = fdp.PickValueInArray({9, 10, 11, 12, 13, 14, 15}); int memLevel = fdp.PickValueInArray({1, 2, 3, 4, 5, 6, 7, 8, 9}); int strategy = fdp.PickValueInArray( {Z_DEFAULT_STRATEGY, Z_FILTERED, Z_HUFFMAN_ONLY, Z_RLE, Z_FIXED}); - std::vector src = fdp.ConsumeRemainingBytes(); + + if (fdp.ConsumeBool()) { + // Gzip wrapper. + windowBits += 16; + } else if (fdp.ConsumeBool()) { + // Raw deflate. + windowBits *= -1; + } else { + // Default: zlib wrapper. + } + + std::vector src; + std::vector compressed; + static const int kMinChunk = 1; + static const int kMaxChunk = 512 * 1024; z_stream stream; stream.zalloc = Z_NULL; stream.zfree = Z_NULL; - // Compress the data one byte at a time to exercise the streaming code. int ret = deflateInit2(&stream, level, Z_DEFLATED, windowBits, memLevel, strategy); ASSERT(ret == Z_OK); - std::vector compressed(src.size() * 2 + 1000); - stream.next_out = compressed.data(); - stream.avail_out = compressed.size(); - for (uint8_t b : src) { - stream.next_in = &b; - stream.avail_in = 1; + + // Stream with random-sized input and output buffers. + while (fdp.ConsumeBool()) { + std::vector src_chunk = fdp.ConsumeBytes( + fdp.ConsumeIntegralInRange(kMinChunk, kMaxChunk)); + std::vector out_chunk( + fdp.ConsumeIntegralInRange(kMinChunk, kMaxChunk)); + stream.next_in = src_chunk.data(); + stream.avail_in = src_chunk.size(); + stream.next_out = out_chunk.data(); + stream.avail_out = out_chunk.size(); ret = deflate(&stream, Z_NO_FLUSH); - ASSERT(ret == Z_OK); + ASSERT(ret == Z_OK || ret == Z_BUF_ERROR); + + src.insert(src.end(), src_chunk.begin(), src_chunk.end() - stream.avail_in); + compressed.insert(compressed.end(), out_chunk.begin(), + out_chunk.end() - stream.avail_out); } - stream.next_in = Z_NULL; - stream.avail_in = 0; - ret = deflate(&stream, Z_FINISH); - ASSERT(ret == Z_STREAM_END); - compressed.resize(compressed.size() - stream.avail_out); + // Finish up. + while (true) { + std::vector out_chunk( + fdp.ConsumeIntegralInRange(kMinChunk, kMaxChunk)); + stream.next_in = Z_NULL; + stream.avail_in = 0; + stream.next_out = out_chunk.data(); + stream.avail_out = out_chunk.size(); + ret = deflate(&stream, Z_FINISH); + compressed.insert(compressed.end(), out_chunk.begin(), + out_chunk.end() - stream.avail_out); + if (ret == Z_STREAM_END) { + break; + } + ASSERT(ret == Z_OK || Z_BUF_ERROR); + } + + // Check that the bound was correct. + // size_t deflate_bound = deflateBound(&stream, src.size()); + // TODO(crbug.com/40270738): This does not always hold. + // ASSERT(compressed.size() <= deflate_bound); + deflateEnd(&stream); // Verify that the data decompresses correctly. diff --git a/zlib/contrib/tests/utils_unittest.cc b/zlib/contrib/tests/utils_unittest.cc index 5745939f24f9d1a1607216c5285444b444625cc3..c149f2ed57d39589e2eb6cc8674453d2c4127532 100644 --- a/zlib/contrib/tests/utils_unittest.cc +++ b/zlib/contrib/tests/utils_unittest.cc @@ -1015,3 +1015,28 @@ TEST(ZlibTest, DeflateZFixedCorruption) { memcmp(zFixedCorruptionData, decompressed.data(), decompressed.size()), 0); } + +TEST(ZlibTest, GzipStored) { + // Check that deflating uncompressed blocks with a gzip header doesn't write + // out of bounds (crbug.com/325990053). + z_stream stream; + stream.zalloc = Z_NULL; + stream.zfree = Z_NULL; + static const int kGzipWrapper = 16; + int ret = deflateInit2(&stream, Z_NO_COMPRESSION, Z_DEFLATED, + 9 + kGzipWrapper, 9, Z_DEFAULT_STRATEGY); + ASSERT_EQ(ret, Z_OK); + + const std::vector src(512 * 1024); + stream.next_in = (unsigned char*)src.data(); + stream.avail_in = src.size(); + + std::vector out(1000); + stream.next_out = (unsigned char*)out.data(); + stream.avail_out = out.size(); + + ret = deflate(&stream, Z_NO_FLUSH); + ASSERT_EQ(ret, Z_OK); + + deflateEnd(&stream); +} \ No newline at end of file diff --git a/zlib/crc_folding.c b/zlib/crc_folding.c index 1b4f4e1d193871bd02d91d048e9f9ba268ec1ffb..1d54ee8d48cff60694e6d25537b8b13110208075 100644 --- a/zlib/crc_folding.c +++ b/zlib/crc_folding.c @@ -403,7 +403,7 @@ partial: } #endif - _mm_storeu_si128((__m128i *)dst, xmm_crc_part); + zmemcpy(dst, src, len); /* TODO: Possibly generate more efficient code. */ partial_fold(s, len, &xmm_crc0, &xmm_crc1, &xmm_crc2, &xmm_crc3, &xmm_crc_part); done: diff --git a/zlib/deflate.c b/zlib/deflate.c index 413590f2735d3c0efdacf8b6cb48d7bd141c077f..9c20f536ae62606c9e9115a598c6efc9f3ef2a8a 100644 --- a/zlib/deflate.c +++ b/zlib/deflate.c @@ -227,6 +227,8 @@ int ZEXPORT deflateInit_(strm, level, version, stream_size) /* To do: ignore strm->next_in if we use it as window */ } +#define WINDOW_PADDING 8 + /* ========================================================================= */ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, version, stream_size) @@ -239,7 +241,6 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, const char *version; int stream_size; { - unsigned window_padding = 8; deflate_state *s; int wrap = 1; static const char my_version[] = ZLIB_VERSION; @@ -331,11 +332,11 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, s->hash_shift = ((s->hash_bits + MIN_MATCH-1) / MIN_MATCH); s->window = (Bytef *) ZALLOC(strm, - s->w_size + window_padding, + s->w_size + WINDOW_PADDING, 2*sizeof(Byte)); /* Avoid use of unitialized values in the window, see crbug.com/1137613 and * crbug.com/1144420 */ - zmemzero(s->window, (s->w_size + window_padding) * (2 * sizeof(Byte))); + zmemzero(s->window, (s->w_size + WINDOW_PADDING) * (2 * sizeof(Byte))); s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); /* Avoid use of uninitialized value, see: * https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11360 @@ -1201,7 +1202,9 @@ int ZEXPORT deflateCopy(dest, source) zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state)); ds->strm = dest; - ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); + ds->window = (Bytef *) ZALLOC(dest, + ds->w_size + WINDOW_PADDING, + 2*sizeof(Byte)); ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, 4); @@ -1212,7 +1215,8 @@ int ZEXPORT deflateCopy(dest, source) return Z_MEM_ERROR; } /* following zmemcpy do not work for 16-bit MSDOS */ - zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); + zmemcpy(ds->window, ss->window, + (ds->w_size + WINDOW_PADDING) * 2 * sizeof(Byte)); zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos)); zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos)); zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); diff --git a/zlib/patches/0001-simd.patch b/zlib/patches/0001-simd.patch index 9434ca0cc4a68ca8f62057db2b5fe1f547065260..dccf5056064e9941c60ec579206c2d12103b7837 100644 --- a/zlib/patches/0001-simd.patch +++ b/zlib/patches/0001-simd.patch @@ -449,7 +449,7 @@ index 000000000000..48d77744aaf4 + } +#endif + -+ _mm_storeu_si128((__m128i *)dst, xmm_crc_part); ++ zmemcpy(dst, src, len); /* TODO: Possibly generate more efficient code. */ + partial_fold(s, len, &xmm_crc0, &xmm_crc1, &xmm_crc2, &xmm_crc3, + &xmm_crc_part); +done: