M115 stage 2 - ozone

This commit is contained in:
Alexander Frick 2023-08-11 01:53:52 -05:00
parent c6bb636a65
commit 485b59d3f3
13 changed files with 141 additions and 1149 deletions

View file

@ -29,8 +29,8 @@ V8 Font Rendering Patch > https://github.com/saiarcot895/chromium-ubuntu-build/b
VAAPI Patch > https://github.com/saiarcot895/chromium-ubuntu-build/blob/master/debian/patches/enable-vaapi-on-linux.diff
- Modified by me.
VAAPI on Wayland Patch > https://github.com/ungoogled-software/ungoogled-chromium-archlinux/blob/master/ozone-add-va-api-support-to-wayland.patch
- From Arch AUR
~~ VAAPI on Wayland Patch > https://github.com/ungoogled-software/ungoogled-chromium-archlinux/blob/master/ozone-add-va-api-support-to-wayland.patch ~~ REMOVED
- From Arch AUR ~~
Use default search icon instead of search engine icon in omnibox patch > https://github.com/ungoogled-software/contrib/blob/master/tweaks/visual/default-search-icon.patch

View file

@ -117,6 +117,15 @@ group("assert_no_deps") {
# for no reason and is easy to mess up. See the comment at the top of
# //chrome/installer/util/BUILD.gn.
assert_no_deps = [ "//chrome/installer/util:strings" ]
if (is_fuchsia) {
assert_no_deps += [
# Chrome should use Perfetto instead of libtrace. Vulkan depends on
# trace-engine, but there should be no dependencies on trace-provider.
"//third_party/fuchsia-sdk/sdk/pkg/trace",
"//third_party/fuchsia-sdk/sdk/pkg/trace-provider-so",
]
}
}
if (!is_android && !is_mac) {
@ -533,13 +542,16 @@ if (is_win) {
":chrome_app_strings_bundle_data",
":chrome_resources",
":chrome_versioned_bundle_data",
":chromium_updater_privileged_helper",
"//base/allocator:early_zone_registration_mac",
"//build:branding_buildflags",
"//chrome/common:buildflags",
"//chrome/common:version_header",
]
if (enable_updater) {
deps += [ ":chromium_updater_privileged_helper" ]
}
if (enable_stripping) {
# At link time, preserve the global symbols specified in the .exports
# file. All other global symbols will be marked as private. The default
@ -688,13 +700,15 @@ if (is_win) {
}
}
bundle_data("chromium_updater_privileged_helper") {
sources = [ "$root_out_dir/$privileged_helper_name" ]
outputs = [
"{{bundle_contents_dir}}/Library/LaunchServices/{{source_file_part}}",
]
if (enable_updater) {
bundle_data("chromium_updater_privileged_helper") {
sources = [ "$root_out_dir/$privileged_helper_name" ]
outputs = [
"{{bundle_contents_dir}}/Library/LaunchServices/{{source_file_part}}",
]
public_deps = [ "//chrome/updater/mac:privileged_helper" ]
public_deps = [ "//chrome/updater/mac:privileged_helper" ]
}
}
action("clean_up_old_versions") {
@ -1182,7 +1196,10 @@ if (is_win) {
"-ObjC",
]
configs += [ "//build/config/compiler:wexit_time_destructors" ]
configs += [
"//build/config/compiler:enable_arc",
"//build/config/compiler:wexit_time_destructors",
]
}
mac_framework_bundle("chrome_framework") {

View file

@ -117,6 +117,15 @@ group("assert_no_deps") {
# for no reason and is easy to mess up. See the comment at the top of
# //chrome/installer/util/BUILD.gn.
assert_no_deps = [ "//chrome/installer/util:strings" ]
if (is_fuchsia) {
assert_no_deps += [
# Chrome should use Perfetto instead of libtrace. Vulkan depends on
# trace-engine, but there should be no dependencies on trace-provider.
"//third_party/fuchsia-sdk/sdk/pkg/trace",
"//third_party/fuchsia-sdk/sdk/pkg/trace-provider-so",
]
}
}
if (!is_android && !is_mac) {
@ -533,13 +542,16 @@ if (is_win) {
":chrome_app_strings_bundle_data",
":chrome_resources",
":chrome_versioned_bundle_data",
":chromium_updater_privileged_helper",
"//base/allocator:early_zone_registration_mac",
"//build:branding_buildflags",
"//chrome/common:buildflags",
"//chrome/common:version_header",
]
if (enable_updater) {
deps += [ ":chromium_updater_privileged_helper" ]
}
if (enable_stripping) {
# At link time, preserve the global symbols specified in the .exports
# file. All other global symbols will be marked as private. The default
@ -688,13 +700,15 @@ if (is_win) {
}
}
bundle_data("chromium_updater_privileged_helper") {
sources = [ "$root_out_dir/$privileged_helper_name" ]
outputs = [
"{{bundle_contents_dir}}/Library/LaunchServices/{{source_file_part}}",
]
if (enable_updater) {
bundle_data("chromium_updater_privileged_helper") {
sources = [ "$root_out_dir/$privileged_helper_name" ]
outputs = [
"{{bundle_contents_dir}}/Library/LaunchServices/{{source_file_part}}",
]
public_deps = [ "//chrome/updater/mac:privileged_helper" ]
public_deps = [ "//chrome/updater/mac:privileged_helper" ]
}
}
action("clean_up_old_versions") {
@ -1182,7 +1196,10 @@ if (is_win) {
"-ObjC",
]
configs += [ "//build/config/compiler:wexit_time_destructors" ]
configs += [
"//build/config/compiler:enable_arc",
"//build/config/compiler:wexit_time_destructors",
]
}
mac_framework_bundle("chrome_framework") {

View file

@ -279,6 +279,8 @@
<structure type="chrome_scaled_image" name="IDR_MIGRATE_ADDRESS_AVATAR50_X135_Y54_DARK" file="common/migrate_address_avatar50_x135_y54_dark.png" />
<structure type="chrome_scaled_image" name="IDR_PRIVACY_SANDBOX_CONFIRMATION_BANNER" file="common/privacy_sandbox_confirmation_banner.png" />
<structure type="chrome_scaled_image" name="IDR_PRIVACY_SANDBOX_CONFIRMATION_BANNER_DARK" file="common/privacy_sandbox_confirmation_banner_dark.png" />
<structure type="chrome_scaled_image" name="IDR_AUTOFILL_MANDATORY_REAUTH_OPT_IN" file="common/autofill_mandatory_reauth_opt_in.png" />
<structure type="chrome_scaled_image" name="IDR_AUTOFILL_MANDATORY_REAUTH_CONFIRMATION" file="common/autofill_mandatory_reauth_confirmation.png" />
</if>
<structure type="chrome_scaled_image" name="IDR_SCREEN_CAPTURE_NOTIFICATION_GRIP" file="screen_capture_notification_grip.png" />
<if expr="not is_android">
@ -360,12 +362,14 @@
<structure type="chrome_scaled_image" name="IDR_WEBSTORE_ICON_24" file="google_chrome/webstore_icon_24.png" />
<structure type="chrome_scaled_image" name="IDR_WEBSTORE_ICON_32" file="google_chrome/webstore_icon_32.png" />
<structure type="chrome_scaled_image" name="IDR_TRANSLATE_TAB_WORDMARK" file="google_chrome/translate_tab_wordmark.png" />
<structure type="chrome_scaled_image" name="IDR_TAILORED_SECURITY_UNCONSENTED_NOTIFICATION" file="google_chrome/safer_with_google_blue_shield.png" />
</if>
</if>
<if expr="not is_android">
<structure type="chrome_scaled_image" name="IDR_TAILORED_SECURITY_CONSENTED" file="common/safer_with_google_shield.png" />
<structure type="chrome_scaled_image" name="IDR_TAILORED_SECURITY_CONSENTED_DARK" file="common/safer_with_google_shield_dark.png" />
<structure type="chrome_scaled_image" name="IDR_TAILORED_SECURITY_UNCONSENTED" file="common/tailored_security_unconsented.png" />
<structure type="chrome_scaled_image" name="IDR_TAILORED_SECURITY_UNCONSENTED_UPDATED" file="common/safer_with_google_shield.png" />
</if>
</structures>
</release>

View file

@ -238,6 +238,12 @@ MEDIA_EXPORT extern const char kLacrosUseChromeosProtectedMedia[] =
"lacros-use-chromeos-protected-media";
MEDIA_EXPORT extern const char kLacrosUseChromeosProtectedAv1[] =
"lacros-use-chromeos-protected-av1";
// Allows remote attestation (RA) in dev mode for testing purpose. Usually RA
// is disabled in dev mode because it will always fail. However, there are cases
// in testing where we do want to go through the permission flow even in dev
// mode. This can be enabled by this flag.
const char kAllowRAInDevMode[] = "allow-ra-in-dev-mode";
#endif // BUILDFLAG(IS_CHROMEOS)
namespace autoplay {
@ -285,11 +291,10 @@ const char kCastStreamingForceEnableHardwareH264[] =
const char kCastStreamingForceEnableHardwareVp8[] =
"cast-streaming-force-enable-hardware-vp8";
// Disables the code path that makes Pepper use the MojoVideoDecoder for
// hardware accelerated video decoding. It overrides the value of the
// kUseMojoVideoDecoderForPepper feature flag.
const char kDisableUseMojoVideoDecoderForPepper[] =
"disable-use-mojo-video-decoder-for-pepper";
#if !BUILDFLAG(IS_ANDROID)
const char kCastMirroringTargetPlayoutDelay[] =
"cast-mirroring-target-playout-delay";
#endif // !BUILDFLAG(IS_ANDROID)
} // namespace switches
@ -534,7 +539,12 @@ BASE_FEATURE(kMemoryPressureBasedSourceBufferGC,
// hardware video decoders.
BASE_FEATURE(kUseMultiPlaneFormatForHardwareVideo,
"UseMultiPlaneFormatForHardwareVideo",
base::FEATURE_DISABLED_BY_DEFAULT);
#if BUILDFLAG(IS_ANDROID)
base::FEATURE_ENABLED_BY_DEFAULT
#else
base::FEATURE_DISABLED_BY_DEFAULT
#endif
);
// Enables creating single shared image and mailbox for multi-planar formats for
// software video decoders.
@ -569,6 +579,12 @@ BASE_FEATURE(kOpenscreenCastStreamingSession,
"OpenscreenCastStreamingSession",
base::FEATURE_DISABLED_BY_DEFAULT);
// Controls whether or not frame drops are included in the video bitrate
// calculation for the OpenscreenFrameSender backed VideoSender implementation.
BASE_FEATURE(kOpenscreenVideoBitrateFactorInFrameDrops,
"OpenscreenVideoBitrateFactorInFrameDrops",
base::FEATURE_ENABLED_BY_DEFAULT);
// Controls whether the Mirroring Service will fetch, analyze, and store
// information on the quality of the session using RTCP logs.
BASE_FEATURE(kEnableRtcpReporting,
@ -643,26 +659,13 @@ BASE_FEATURE(kGlobalMediaControlsCrOSUpdatedUI,
// If enabled, users can request Media Remoting without fullscreen-in-tab.
BASE_FEATURE(kMediaRemotingWithoutFullscreen,
"MediaRemotingWithoutFullscreen",
base::FEATURE_DISABLED_BY_DEFAULT);
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
base::FEATURE_ENABLED_BY_DEFAULT
#else
base::FEATURE_DISABLED_BY_DEFAULT
#endif
);
#endif
// Allow Global Media Controls in system tray of CrOS.
BASE_FEATURE(kGlobalMediaControlsForChromeOS,
"GlobalMediaControlsForChromeOS",
base::FEATURE_ENABLED_BY_DEFAULT);
constexpr base::FeatureParam<kCrosGlobalMediaControlsPinOptions>::Option
kCrosGlobalMediaControlsParamOptions[] = {
{kCrosGlobalMediaControlsPinOptions::kPin, "default-pinned"},
{kCrosGlobalMediaControlsPinOptions::kNotPin, "default-unpinned"},
{kCrosGlobalMediaControlsPinOptions::kHeuristic, "heuristic"}};
constexpr base::FeatureParam<kCrosGlobalMediaControlsPinOptions>
kCrosGlobalMediaControlsPinParam(
&kGlobalMediaControlsForChromeOS,
"CrosGlobalMediaControlsPinParam",
kCrosGlobalMediaControlsPinOptions::kHeuristic,
&kCrosGlobalMediaControlsParamOptions);
// Show picture-in-picture button in Global Media Controls.
BASE_FEATURE(kGlobalMediaControlsPictureInPicture,
@ -724,9 +727,10 @@ BASE_FEATURE(kVaapiVideoDecodeLinuxGL,
"VaapiVideoDecodeLinuxGL",
base::FEATURE_DISABLED_BY_DEFAULT);
// Temporary fix TODO: Alex313031
BASE_FEATURE(kVaapiVideoEncodeLinux,
"VaapiVideoEncoder",
base::FEATURE_ENABLED_BY_DEFAULT);
base::FEATURE_DISABLED_BY_DEFAULT);
// Ignore the non-intel driver blacklist for VaapiVideoDecoder implementations.
// Intended for manual usage only in order to gague the status of newer driver
@ -787,12 +791,23 @@ BASE_FEATURE(kVaapiH264TemporalLayerHWEncoding,
// Enable VP8 temporal layer encoding with HW encoder on ChromeOS.
BASE_FEATURE(kVaapiVp8TemporalLayerHWEncoding,
"VaapiVp8TemporalLayerEncoding",
base::FEATURE_DISABLED_BY_DEFAULT);
base::FEATURE_ENABLED_BY_DEFAULT);
// Enable VP9 k-SVC encoding with HW encoder for webrtc use case on ChromeOS.
BASE_FEATURE(kVaapiVp9kSVCHWEncoding,
"VaapiVp9kSVCHWEncoding",
base::FEATURE_ENABLED_BY_DEFAULT);
#endif // defined(ARCH_CPU_X86_FAMILY) && BUILDFLAG(IS_CHROMEOS)
#if defined(ARCH_CPU_ARM_FAMILY) && BUILDFLAG(IS_CHROMEOS)
// Enables the new V4L2StatefulVideoDecoder instead of V4L2VideoDecoder.
BASE_FEATURE(kV4L2FlatStatelessVideoDecoder,
"V4L2FlatStatelessVideoDecoder",
base::FEATURE_DISABLED_BY_DEFAULT);
// Enables the new V4L2StatefulVideoDecoder instead of V4L2VideoDecoder.
BASE_FEATURE(kV4L2FlatStatefulVideoDecoder,
"V4L2FlatStatefulVideoDecoder",
base::FEATURE_DISABLED_BY_DEFAULT);
#endif
// Inform video blitter of video color space.
BASE_FEATURE(kVideoBlitColorAccuracy,
@ -867,6 +882,11 @@ BASE_FEATURE(kLiveCaptionRightClick,
"LiveCaptionRightClick",
base::FEATURE_DISABLED_BY_DEFAULT);
// Enable or disable Live Caption support for WebAudio.
BASE_FEATURE(kLiveCaptionWebAudio,
"LiveCaptionWebAudio",
base::FEATURE_ENABLED_BY_DEFAULT);
// Live Caption runs system-wide on ChromeOS, as opposed to just in the browser.
BASE_FEATURE(kLiveCaptionSystemWideOnChromeOS,
"LiveCaptionSystemWideOnChromeOS",
@ -929,7 +949,7 @@ const base::FeatureParam<bool>
// while capturing a low-resolution tab.
BASE_FEATURE(kWebContentsCaptureHiDpi,
"WebContentsCaptureHiDPI",
base::FEATURE_DISABLED_BY_DEFAULT);
base::FEATURE_ENABLED_BY_DEFAULT);
// Enables handling of hardware media keys for controlling media.
BASE_FEATURE(kHardwareMediaKeyHandling,
@ -1041,11 +1061,13 @@ BASE_FEATURE(kUsePooledSharedImageVideoProvider,
"UsePooledSharedImageVideoProvider",
base::FEATURE_ENABLED_BY_DEFAULT);
// Historically we hardcoded sRGB for color space. This flags controls if we
// pass real color space to VideoFrame/SharedImages.
BASE_FEATURE(kUseRealColorSpaceForAndroidVideo,
"UseRealColorSpaceForAndroidVideo",
base::FEATURE_ENABLED_BY_DEFAULT);
// Allow the media pipeline to prioritize the software decoder provided by
// MediaCodec, instead of the built-in software decoders. This is only enabled
// for platforms which shows worse performance when using the built-in software
// decoders, e.g. Cast on ATV.
BASE_FEATURE(kAllowMediaCodecSoftwareDecoder,
"AllowMediaCodecSoftwareDecoder",
base::FEATURE_DISABLED_BY_DEFAULT);
#endif // BUILDFLAG(IS_ANDROID)
@ -1262,13 +1284,6 @@ const base::Feature MEDIA_EXPORT kUseOutOfProcessVideoEncoding{
"UseOutOfProcessVideoEncoding", base::FEATURE_DISABLED_BY_DEFAULT};
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
// Make the PepperVideoDecoderHost use the MojoVideoDecoder to talk to hardware
// decoders instead of using the GpuVideoDecodeAcceleratorHost. Note: this
// doesn't affect the PPB_VideoDecoder_Impl which will continue to use the
// GpuVideoDecodeAcceleratorHost for the PPB_VideoDecoder_Dev interface.
const base::Feature MEDIA_EXPORT kUseMojoVideoDecoderForPepper{
"UseMojoVideoDecoderForPepper", base::FEATURE_ENABLED_BY_DEFAULT};
// Use SequencedTaskRunner for MediaService.
BASE_FEATURE(kUseSequencedTaskRunnerForMediaService,
"UseSequencedTaskRunnerForMediaService",

View file

@ -29,8 +29,8 @@
#elif BUILDFLAG(USE_V4L2_CODEC) && \
(BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_ASH))
#include "media/gpu/v4l2/v4l2_device.h"
#include "media/gpu/v4l2/v4l2_slice_video_decode_accelerator.h"
#include "media/gpu/v4l2/v4l2_video_decode_accelerator.h"
#include "media/gpu/v4l2/legacy/v4l2_slice_video_decode_accelerator.h"
#include "media/gpu/v4l2/legacy/v4l2_video_decode_accelerator.h"
#include "ui/gl/gl_surface_egl.h"
#endif

View file

@ -1,168 +0,0 @@
// Copyright 2023 The Chromium Authors and Alex313031
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/gpu/vaapi/vaapi_picture_factory.h"
#include "base/containers/contains.h"
#include "build/build_config.h"
#include "media/gpu/vaapi/vaapi_wrapper.h"
#include "media/video/picture.h"
#include "ui/gl/gl_bindings.h"
#if BUILDFLAG(IS_OZONE)
#include "media/gpu/vaapi/vaapi_picture_native_pixmap_ozone.h"
#endif // BUILDFLAG(IS_OZONE)
#if BUILDFLAG(USE_VAAPI_X11)
#include "media/gpu/vaapi/vaapi_picture_native_pixmap_angle.h"
#endif // BUILDFLAG(USE_VAAPI_X11)
#if defined(USE_EGL)
#include "media/gpu/vaapi/vaapi_picture_native_pixmap_egl.h"
#endif
namespace media {
namespace {
template <typename PictureType>
std::unique_ptr<VaapiPicture> CreateVaapiPictureNativeImpl(
scoped_refptr<VaapiWrapper> vaapi_wrapper,
const MakeGLContextCurrentCallback& make_context_current_cb,
const BindGLImageCallback& bind_image_cb,
const PictureBuffer& picture_buffer,
const gfx::Size& visible_size,
uint32_t client_texture_id,
uint32_t service_texture_id) {
return std::make_unique<PictureType>(
std::move(vaapi_wrapper), make_context_current_cb, bind_image_cb,
picture_buffer.id(), picture_buffer.size(), visible_size,
service_texture_id, client_texture_id, picture_buffer.texture_target());
}
} // namespace
VaapiPictureFactory::VaapiPictureFactory() {
vaapi_impl_pairs_.insert(
std::make_pair(gl::kGLImplementationEGLGLES2,
VaapiPictureFactory::kVaapiImplementationDrm));
#if BUILDFLAG(USE_VAAPI_X11)
vaapi_impl_pairs_.insert(
std::make_pair(gl::kGLImplementationEGLANGLE,
VaapiPictureFactory::kVaapiImplementationAngle));
#elif BUILDFLAG(IS_OZONE)
vaapi_impl_pairs_.insert(
std::make_pair(gl::kGLImplementationEGLANGLE,
VaapiPictureFactory::kVaapiImplementationDrm));
#endif
DeterminePictureCreationAndDownloadingMechanism();
}
VaapiPictureFactory::~VaapiPictureFactory() = default;
std::unique_ptr<VaapiPicture> VaapiPictureFactory::Create(
scoped_refptr<VaapiWrapper> vaapi_wrapper,
const MakeGLContextCurrentCallback& make_context_current_cb,
const BindGLImageCallback& bind_image_cb,
const PictureBuffer& picture_buffer,
const gfx::Size& visible_size) {
// ARC++ sends |picture_buffer| with no texture_target().
DCHECK(picture_buffer.texture_target() == GetGLTextureTarget() ||
picture_buffer.texture_target() == 0u);
// |client_texture_ids| and |service_texture_ids| are empty from ARC++.
const uint32_t client_texture_id =
!picture_buffer.client_texture_ids().empty()
? picture_buffer.client_texture_ids()[0]
: 0;
const uint32_t service_texture_id =
!picture_buffer.service_texture_ids().empty()
? picture_buffer.service_texture_ids()[0]
: 0;
return CreateVaapiPictureNative(vaapi_wrapper, make_context_current_cb,
bind_image_cb, picture_buffer, visible_size,
client_texture_id, service_texture_id);
}
VaapiPictureFactory::VaapiImplementation
VaapiPictureFactory::GetVaapiImplementation(gl::GLImplementation gl_impl) {
if (base::Contains(vaapi_impl_pairs_, gl_impl))
return vaapi_impl_pairs_[gl_impl];
return kVaapiImplementationNone;
}
uint32_t VaapiPictureFactory::GetGLTextureTarget() {
#if BUILDFLAG(USE_VAAPI_X11)
return GL_TEXTURE_2D;
#else
return GL_TEXTURE_EXTERNAL_OES;
#endif
}
gfx::BufferFormat VaapiPictureFactory::GetBufferFormat() {
#if BUILDFLAG(IS_LINUX)
return gfx::BufferFormat::RGBX_8888;
#else
return gfx::BufferFormat::YUV_420_BIPLANAR;
#endif
}
void VaapiPictureFactory::DeterminePictureCreationAndDownloadingMechanism() {
switch (GetVaapiImplementation(gl::GetGLImplementation())) {
#if BUILDFLAG(IS_OZONE)
// We can be called without GL initialized, which is valid if we use Ozone.
case kVaapiImplementationNone:
create_picture_cb_ = base::BindRepeating(
&CreateVaapiPictureNativeImpl<VaapiPictureNativePixmapOzone>);
needs_vpp_for_downloading_ = true;
break;
#endif // BUILDFLAG(IS_OZONE)
#if BUILDFLAG(USE_VAAPI_X11)
case kVaapiImplementationAngle:
create_picture_cb_ = base::BindRepeating(
&CreateVaapiPictureNativeImpl<VaapiPictureNativePixmapAngle>);
// Neither VaapiTFPPicture or VaapiPictureNativePixmapAngle needs the VPP.
needs_vpp_for_downloading_ = false;
break;
#endif // BUILDFLAG(USE_VAAPI_X11)
case kVaapiImplementationDrm:
#if BUILDFLAG(IS_OZONE)
create_picture_cb_ = base::BindRepeating(
&CreateVaapiPictureNativeImpl<VaapiPictureNativePixmapOzone>);
needs_vpp_for_downloading_ = true;
break;
#elif defined(USE_EGL)
create_picture_cb_ = base::BindRepeating(
&CreateVaapiPictureNativeImpl<VaapiPictureNativePixmapEgl>);
needs_vpp_for_downloading_ = true;
break;
#else
// ozone or egl must be used to use the DRM implementation.
[[fallthrough]];
#endif
default:
NOTREACHED();
break;
}
}
bool VaapiPictureFactory::NeedsProcessingPipelineForDownloading() const {
return needs_vpp_for_downloading_;
}
std::unique_ptr<VaapiPicture> VaapiPictureFactory::CreateVaapiPictureNative(
scoped_refptr<VaapiWrapper> vaapi_wrapper,
const MakeGLContextCurrentCallback& make_context_current_cb,
const BindGLImageCallback& bind_image_cb,
const PictureBuffer& picture_buffer,
const gfx::Size& visible_size,
uint32_t client_texture_id,
uint32_t service_texture_id) {
CHECK(create_picture_cb_);
return create_picture_cb_.Run(
std::move(vaapi_wrapper), make_context_current_cb, bind_image_cb,
picture_buffer, visible_size, client_texture_id, service_texture_id);
}
} // namespace media

View file

@ -1,64 +0,0 @@
// Copyright 2023 The Chromium Authors and Alex313031
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/gpu/vaapi/vaapi_picture_native_pixmap.h"
#include "media/gpu/macros.h"
#include "media/gpu/vaapi/va_surface.h"
#include "media/gpu/vaapi/vaapi_wrapper.h"
namespace media {
VaapiPictureNativePixmap::VaapiPictureNativePixmap(
scoped_refptr<VaapiWrapper> vaapi_wrapper,
const MakeGLContextCurrentCallback& make_context_current_cb,
const BindGLImageCallback& bind_image_cb,
int32_t picture_buffer_id,
const gfx::Size& size,
const gfx::Size& visible_size,
uint32_t texture_id,
uint32_t client_texture_id,
uint32_t texture_target)
: VaapiPicture(std::move(vaapi_wrapper),
make_context_current_cb,
bind_image_cb,
picture_buffer_id,
size,
visible_size,
texture_id,
client_texture_id,
texture_target) {}
VaapiPictureNativePixmap::~VaapiPictureNativePixmap() = default;
bool VaapiPictureNativePixmap::DownloadFromSurface(
scoped_refptr<VASurface> va_surface) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (!vaapi_wrapper_->SyncSurface(va_surface->id())) {
VLOGF(1) << "Cannot sync VPP input surface";
return false;
}
if (!vaapi_wrapper_->BlitSurface(*va_surface, *va_surface_)) {
VLOGF(1) << "Cannot convert decoded image into output buffer";
return false;
}
// Sync target surface since the buffer is returning to client.
if (!vaapi_wrapper_->SyncSurface(va_surface_->id())) {
VLOGF(1) << "Cannot sync VPP output surface";
return false;
}
return true;
}
bool VaapiPictureNativePixmap::AllowOverlay() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return true;
}
VASurfaceID VaapiPictureNativePixmap::va_surface_id() const {
return va_surface_->id();
}
} // namespace media

View file

@ -561,12 +561,12 @@ void VaapiVideoDecodeAccelerator::InitiateSurfaceSetChange(
requested_visible_rect_ = visible_rect;
if (buffer_allocation_mode_ == BufferAllocationMode::kSuperReduced) {
// Add one to the reference frames for the one being currently egressed.
requested_num_reference_frames_ = num_reference_frames + 4;
requested_num_reference_frames_ = num_reference_frames + 1;
requested_num_pics_ = num_pics - num_reference_frames;
} else if (buffer_allocation_mode_ == BufferAllocationMode::kReduced) {
// Add one to the reference frames for the one being currently egressed,
// and an extra allocation for both |client_| and |decoder_|.
requested_num_reference_frames_ = num_reference_frames + 5;
requested_num_reference_frames_ = num_reference_frames + 2;
requested_num_pics_ = num_pics - num_reference_frames + 1;
} else {
requested_num_reference_frames_ = 0;

View file

@ -57,6 +57,7 @@
#include "net/dns/dns_udp_tracker.h"
#include "net/dns/dns_util.h"
#include "net/dns/host_cache.h"
#include "net/dns/host_resolver_internal_result.h"
#include "net/dns/public/dns_over_https_config.h"
#include "net/dns/public/dns_over_https_server_config.h"
#include "net/dns/public/dns_protocol.h"
@ -1078,31 +1079,36 @@ class DnsOverHttpsProbeRunner : public DnsProbeRunner {
probe_stats->probe_attempts[attempt_number].get();
const DnsResponse* response = attempt->GetResponse();
if (response) {
DnsResponseResultExtractor extractor(response);
HostCache::Entry results(ERR_FAILED, HostCache::Entry::SOURCE_UNKNOWN);
DnsResponseResultExtractor::ExtractionError extraction_error =
DnsResponseResultExtractor extractor(*response);
DnsResponseResultExtractor::ResultsOrError results =
extractor.ExtractDnsResults(
DnsQueryType::A,
/*original_domain_name=*/kDohProbeHostname,
/*request_port=*/0, &results);
/*request_port=*/0);
if (extraction_error ==
DnsResponseResultExtractor::ExtractionError::kOk &&
results.ip_endpoints() && !results.ip_endpoints()->empty()) {
// The DoH probe queries don't go through the standard DnsAttempt
// path, so the ServerStats have not been updated yet.
context_->RecordServerSuccess(
doh_server_index, true /* is_doh_server */, session_.get());
context_->RecordRtt(doh_server_index, true /* is_doh_server */,
base::TimeTicks::Now() - query_start_time, rv,
session_.get());
success = true;
if (!results.has_value()) {
return;
}
// Do not delete the ProbeStats and cancel the probe sequence. It will
// cancel itself on the next scheduled ContinueProbe() call if the
// server is still available. This way, the backoff schedule will be
// maintained if a server quickly becomes unavailable again before
// that scheduled call.
for (const auto& result : results.value()) {
if (result->type() == HostResolverInternalResult::Type::kData &&
!result->AsData().endpoints().empty()) {
// The DoH probe queries don't go through the standard DnsAttempt
// path, so the ServerStats have not been updated yet.
context_->RecordServerSuccess(
doh_server_index, /*is_doh_server=*/true, session_.get());
context_->RecordRtt(doh_server_index, /*is_doh_server=*/true,
base::TimeTicks::Now() - query_start_time, rv,
session_.get());
success = true;
// Do not delete the ProbeStats and cancel the probe sequence. It
// will cancel itself on the next scheduled ContinueProbe() call if
// the server is still available. This way, the backoff schedule
// will be maintained if a server quickly becomes unavailable again
// before that scheduled call.
return;
}
}
}
}

View file

@ -1,243 +0,0 @@
// Copyright 2023 The Chromium Authors and Alex313031
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.h"
#include <drm_fourcc.h>
#include <gbm.h>
#include <xf86drmMode.h>
#include <memory>
#include "base/files/platform_file.h"
#include "base/logging.h"
#include "base/posix/eintr_wrapper.h"
#include "base/trace_event/trace_event.h"
#include "ui/gfx/buffer_format_util.h"
#include "ui/gfx/buffer_usage_util.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/linux/drm_util_linux.h"
#include "ui/gfx/linux/gbm_device.h"
#include "ui/gfx/linux/gbm_util.h"
#include "ui/gfx/native_pixmap_handle.h"
#include "ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.h"
#include "ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.h"
#include "ui/ozone/public/ozone_platform.h"
namespace ui {
GbmPixmapWayland::GbmPixmapWayland(WaylandBufferManagerGpu* buffer_manager)
: buffer_manager_(buffer_manager),
buffer_id_(buffer_manager->AllocateBufferID()) {}
GbmPixmapWayland::~GbmPixmapWayland() {
// gfx::BufferUsage::SCANOUT_VDA_WRITE doesn't result in creation of
// wl_buffers.
if (created_wl_buffer_ && usage_ != gfx::BufferUsage::SCANOUT_VDA_WRITE)
buffer_manager_->DestroyBuffer(buffer_id_);
}
bool GbmPixmapWayland::InitializeBuffer(
gfx::AcceleratedWidget widget,
gfx::Size size,
gfx::BufferFormat format,
gfx::BufferUsage usage,
absl::optional<gfx::Size> visible_area_size) {
DCHECK(!visible_area_size ||
((visible_area_size.value().width() <= size.width()) &&
(visible_area_size.value().height() <= size.height())));
TRACE_EVENT0("wayland", "GbmPixmapWayland::InitializeBuffer");
widget_ = widget;
auto* gbm_device = buffer_manager_->GetGbmDevice();
if (!gbm_device)
return false;
const uint32_t fourcc_format = GetFourCCFormatFromBufferFormat(format);
const uint32_t gbm_flags = ui::BufferUsageToGbmFlags(usage);
auto modifiers = buffer_manager_->GetModifiersForBufferFormat(format);
// Create buffer object without format modifiers unless they are explicitly
// advertised by the Wayland compositor, via linux-dmabuf protocol.
if (modifiers.empty()) {
gbm_bo_ = gbm_device->CreateBuffer(fourcc_format, size, gbm_flags);
} else {
// When buffer |usage| implies on GBM_BO_USE_LINEAR, pass in
// DRM_FORMAT_MOD_LINEAR, i.e: no tiling, when creating gbm buffers,
// otherwise it fails to create BOs.
if (gbm_flags & GBM_BO_USE_LINEAR)
modifiers = {DRM_FORMAT_MOD_LINEAR};
gbm_bo_ = gbm_device->CreateBufferWithModifiers(fourcc_format, size,
gbm_flags, modifiers);
}
if (!gbm_bo_) {
LOG(ERROR) << "Cannot create bo with format= "
<< gfx::BufferFormatToString(format)
<< " and usage=" << gfx::BufferUsageToString(usage);
return false;
}
DVLOG(3) << "Created gbm bo. format= " << gfx::BufferFormatToString(format)
<< " usage=" << gfx::BufferUsageToString(usage);
visible_area_size_ = visible_area_size ? visible_area_size.value() : size;
return true;
}
bool GbmPixmapWayland::InitializeBufferFromHandle(
gfx::AcceleratedWidget widget,
gfx::Size size,
gfx::BufferFormat format,
gfx::NativePixmapHandle handle) {
TRACE_EVENT0("wayland", "GbmPixmapWayland::InitializeBufferFromHandle");
auto* gbm_device = buffer_manager_->GetGbmDevice();
if (!gbm_device)
return false;
widget_ = widget;
// Create a buffer object from handle.
gbm_bo_ = gbm_device->CreateBufferFromHandle(
GetFourCCFormatFromBufferFormat(format), size, std::move(handle));
if (!gbm_bo_) {
LOG(ERROR) << "Cannot create bo with format= "
<< gfx::BufferFormatToString(format);
return false;
}
DVLOG(3) << "Created gbm bo. format= " << gfx::BufferFormatToString(format);
visible_area_size_ = size;
return true;
}
bool GbmPixmapWayland::AreDmaBufFdsValid() const {
return gbm_bo_->AreFdsValid();
}
int GbmPixmapWayland::GetDmaBufFd(size_t plane) const {
return gbm_bo_->GetPlaneFd(plane);
}
uint32_t GbmPixmapWayland::GetDmaBufPitch(size_t plane) const {
return gbm_bo_->GetPlaneStride(plane);
}
size_t GbmPixmapWayland::GetDmaBufOffset(size_t plane) const {
return gbm_bo_->GetPlaneOffset(plane);
}
size_t GbmPixmapWayland::GetDmaBufPlaneSize(size_t plane) const {
return gbm_bo_->GetPlaneSize(plane);
}
size_t GbmPixmapWayland::GetNumberOfPlanes() const {
return gbm_bo_->GetNumPlanes();
}
bool GbmPixmapWayland::SupportsZeroCopyWebGPUImport() const {
// TODO(crbug.com/1258986): Figure out how to import multi-planar pixmap into
// WebGPU without copy.
return false;
}
uint64_t GbmPixmapWayland::GetBufferFormatModifier() const {
return gbm_bo_->GetFormatModifier();
}
gfx::BufferFormat GbmPixmapWayland::GetBufferFormat() const {
return gbm_bo_->GetBufferFormat();
}
gfx::Size GbmPixmapWayland::GetBufferSize() const {
return gbm_bo_->GetSize();
}
uint32_t GbmPixmapWayland::GetUniqueId() const {
return gbm_bo_->GetHandle();
}
bool GbmPixmapWayland::ScheduleOverlayPlane(
gfx::AcceleratedWidget widget,
const gfx::OverlayPlaneData& overlay_plane_data,
std::vector<gfx::GpuFence> acquire_fences,
std::vector<gfx::GpuFence> release_fences) {
DCHECK_NE(widget, gfx::kNullAcceleratedWidget);
if (!created_wl_buffer_)
CreateDmabufBasedWlBuffer();
widget_ = widget;
auto* surface = buffer_manager_->GetSurface(widget);
// This must never be hit.
DCHECK(surface);
GbmSurfacelessWayland* surfaceless =
static_cast<GbmSurfacelessWayland*>(surface);
DCHECK(surfaceless);
DCHECK(acquire_fences.empty() || acquire_fences.size() == 1u);
surfaceless->QueueWaylandOverlayConfig(
{overlay_plane_data,
acquire_fences.empty()
? nullptr
: std::make_unique<gfx::GpuFence>(std::move(acquire_fences[0])),
buffer_id_, surfaceless->surface_scale_factor()});
return true;
}
gfx::NativePixmapHandle GbmPixmapWayland::ExportHandle() {
gfx::NativePixmapHandle handle;
const size_t num_planes = gbm_bo_->GetNumPlanes();
std::vector<base::ScopedFD> scoped_fds(num_planes);
for (size_t i = 0; i < num_planes; ++i) {
scoped_fds[i] = base::ScopedFD(HANDLE_EINTR(dup(GetDmaBufFd(i))));
if (!scoped_fds[i].is_valid()) {
PLOG(ERROR) << "dup";
return gfx::NativePixmapHandle();
}
}
for (size_t i = 0; i < num_planes; ++i) {
handle.planes.emplace_back(GetDmaBufPitch(i), GetDmaBufOffset(i),
gbm_bo_->GetPlaneSize(i),
std::move(scoped_fds[i]));
}
handle.modifier = GetBufferFormatModifier();
return handle;
}
void GbmPixmapWayland::CreateDmabufBasedWlBuffer() {
uint64_t modifier = gbm_bo_->GetFormatModifier();
std::vector<uint32_t> strides;
std::vector<uint32_t> offsets;
std::vector<uint64_t> modifiers;
size_t plane_count = gbm_bo_->GetNumPlanes();
for (size_t i = 0; i < plane_count; ++i) {
strides.push_back(GetDmaBufPitch(i));
offsets.push_back(GetDmaBufOffset(i));
modifiers.push_back(modifier);
}
base::ScopedFD fd(HANDLE_EINTR(dup(GetDmaBufFd(0))));
if (!fd.is_valid()) {
PLOG(FATAL) << "dup";
return;
}
// The wl_buffer must be destroyed once this pixmap is destroyed.
created_wl_buffer_ = true;
// Asks Wayland to create a wl_buffer based on the |file| fd.
buffer_manager_->CreateDmabufBasedBuffer(
std::move(fd), visible_area_size_, strides, offsets, modifiers,
gbm_bo_->GetFormat(), plane_count, buffer_id_);
}
} // namespace ui

View file

@ -1,103 +0,0 @@
// Copyright 2023 The Chromium Authors and Alex313031
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_OZONE_PLATFORM_WAYLAND_GPU_GBM_PIXMAP_WAYLAND_H_
#define UI_OZONE_PLATFORM_WAYLAND_GPU_GBM_PIXMAP_WAYLAND_H_
#include <memory>
#include <vector>
#include "base/files/scoped_file.h"
#include "base/memory/raw_ptr.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/gfx/buffer_types.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/linux/gbm_buffer.h"
#include "ui/gfx/native_pixmap.h"
#include "ui/gfx/native_pixmap_handle.h"
#include "ui/gfx/native_widget_types.h"
namespace ui {
class WaylandBufferManagerGpu;
class GbmPixmapWayland : public gfx::NativePixmap {
public:
explicit GbmPixmapWayland(WaylandBufferManagerGpu* buffer_manager);
GbmPixmapWayland(const GbmPixmapWayland&) = delete;
GbmPixmapWayland& operator=(const GbmPixmapWayland&) = delete;
// Creates a buffer object and initializes the pixmap buffer.
// |visible_area_size| represents a 'visible size', i.e., a buffer
// of size |size| may actually contain visible data only in the
// subregion of size |visible_area_size|. If |visible_area_size| is
// not provided, |size| is used. If |widget| is provided, browser
// side wl_buffer is also created. Otherwise, this pixmap
// behaves as a staging pixmap and mustn't be scheduled as an overlay.
bool InitializeBuffer(
gfx::AcceleratedWidget widget,
gfx::Size size,
gfx::BufferFormat format,
gfx::BufferUsage usage,
absl::optional<gfx::Size> visible_area_size = absl::nullopt);
// Creates a buffer object from native pixmap handle and initializes the
// pixmap buffer. If |widget| is provided, browser side wl_buffer is also
// created. Otherwise, this pixmap behaves as a staging pixmap and mustn't be
// scheduled as an overlay.
bool InitializeBufferFromHandle(gfx::AcceleratedWidget widget,
gfx::Size size,
gfx::BufferFormat format,
gfx::NativePixmapHandle handle);
// gfx::NativePixmap overrides:
bool AreDmaBufFdsValid() const override;
int GetDmaBufFd(size_t plane) const override;
uint32_t GetDmaBufPitch(size_t plane) const override;
size_t GetDmaBufOffset(size_t plane) const override;
size_t GetDmaBufPlaneSize(size_t plane) const override;
size_t GetNumberOfPlanes() const override;
bool SupportsZeroCopyWebGPUImport() const override;
uint64_t GetBufferFormatModifier() const override;
gfx::BufferFormat GetBufferFormat() const override;
gfx::Size GetBufferSize() const override;
uint32_t GetUniqueId() const override;
bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
const gfx::OverlayPlaneData& overlay_plane_data,
std::vector<gfx::GpuFence> acquire_fences,
std::vector<gfx::GpuFence> release_fences) override;
gfx::NativePixmapHandle ExportHandle() override;
private:
~GbmPixmapWayland() override;
// Asks Wayland to create a dmabuf based wl_buffer.
void CreateDmabufBasedWlBuffer();
// gbm_bo wrapper for struct gbm_bo.
std::unique_ptr<GbmBuffer> gbm_bo_;
// Represents a connection to Wayland.
const raw_ptr<WaylandBufferManagerGpu> buffer_manager_;
// Represents widget this pixmap backs.
gfx::AcceleratedWidget widget_ = gfx::kNullAcceleratedWidget;
// A unique ID to identify the buffer for this pixmap.
const uint32_t buffer_id_;
// Size of the visible area of the buffer.
gfx::Size visible_area_size_;
// Says a wl_buffer has been created and must removed.
bool created_wl_buffer_ = false;
// Tells the usage of this pixmap.
gfx::BufferUsage usage_ = gfx::BufferUsage::SCANOUT;
};
} // namespace ui
#endif // UI_OZONE_PLATFORM_WAYLAND_GPU_GBM_PIXMAP_WAYLAND_H_

View file

@ -1,489 +0,0 @@
// Copyright 2023 The Chromium Authors and Alex313031
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/ozone/platform/wayland/ozone_platform_wayland.h"
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include <components/exo/wayland/protocol/aura-shell-client-protocol.h>
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_pump_type.h"
#include "base/no_destructor.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "ui/base/buildflags.h"
#include "ui/base/cursor/cursor_factory.h"
#include "ui/base/dragdrop/os_exchange_data_provider_factory_ozone.h"
#include "ui/base/ime/linux/input_method_auralinux.h"
#include "ui/base/ime/linux/linux_input_method_context_factory.h"
#include "ui/base/ui_base_features.h"
#include "ui/display/display_switches.h"
#include "ui/events/devices/device_data_manager.h"
#include "ui/events/event.h"
#include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
#include "ui/gfx/buffer_format_util.h"
#include "ui/gfx/linux/client_native_pixmap_dmabuf.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/ozone/common/base_keyboard_hook.h"
#include "ui/ozone/common/features.h"
#include "ui/ozone/platform/wayland/common/wayland_util.h"
#include "ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.h"
#include "ui/ozone/platform/wayland/gpu/wayland_gl_egl_utility.h"
#include "ui/ozone/platform/wayland/gpu/wayland_overlay_manager.h"
#include "ui/ozone/platform/wayland/gpu/wayland_surface_factory.h"
#include "ui/ozone/platform/wayland/host/wayland_buffer_manager_connector.h"
#include "ui/ozone/platform/wayland/host/wayland_buffer_manager_host.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
#include "ui/ozone/platform/wayland/host/wayland_event_source.h"
#include "ui/ozone/platform/wayland/host/wayland_exchange_data_provider.h"
#include "ui/ozone/platform/wayland/host/wayland_input_controller.h"
#include "ui/ozone/platform/wayland/host/wayland_input_method_context.h"
#include "ui/ozone/platform/wayland/host/wayland_menu_utils.h"
#include "ui/ozone/platform/wayland/host/wayland_output_manager.h"
#include "ui/ozone/platform/wayland/host/wayland_seat.h"
#include "ui/ozone/platform/wayland/host/wayland_window.h"
#include "ui/ozone/platform/wayland/host/wayland_window_manager.h"
#include "ui/ozone/platform/wayland/host/wayland_zaura_shell.h"
#include "ui/ozone/platform/wayland/wayland_utils.h"
#include "ui/ozone/public/gpu_platform_support_host.h"
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/platform_menu_utils.h"
#include "ui/ozone/public/system_input_injector.h"
#include "ui/platform_window/platform_window_init_properties.h"
#if BUILDFLAG(USE_XKBCOMMON)
#include "ui/events/ozone/layout/xkb/xkb_evdev_codes.h"
#include "ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h"
#else
#include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h"
#endif
#if BUILDFLAG(IS_CHROMEOS)
#include "ui/ozone/common/bitmap_cursor_factory.h"
#else
#include "ui/ozone/platform/wayland/host/wayland_cursor_factory.h"
#endif
#if BUILDFLAG(IS_LINUX)
#include "ui/ozone/platform/wayland/host/linux_ui_delegate_wayland.h"
#endif
#if defined(WAYLAND_GBM)
#include "ui/ozone/platform/wayland/gpu/drm_render_node_path_finder.h"
#endif
namespace ui {
namespace {
class OzonePlatformWayland : public OzonePlatform,
public OSExchangeDataProviderFactoryOzone {
public:
OzonePlatformWayland()
: old_synthesize_key_repeat_enabled_(
KeyEvent::IsSynthesizeKeyRepeatEnabled()) {
// Forcing the device scale factor on Wayland is not fully/well supported
// and is provided for test purposes only.
// See https://crbug.com/1241546
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kForceDeviceScaleFactor)) {
LOG(WARNING) << "--" << switches::kForceDeviceScaleFactor
<< " on Wayland is TEST ONLY. Use it at your own risk.";
}
// Disable key-repeat flag synthesizing. On Wayland, key repeat events are
// generated inside Chrome, and the flag is properly set.
// See also WaylandEventSource.
KeyEvent::SetSynthesizeKeyRepeatEnabled(false);
OSExchangeDataProviderFactoryOzone::SetInstance(this);
}
OzonePlatformWayland(const OzonePlatformWayland&) = delete;
OzonePlatformWayland& operator=(const OzonePlatformWayland&) = delete;
~OzonePlatformWayland() override {
KeyEvent::SetSynthesizeKeyRepeatEnabled(old_synthesize_key_repeat_enabled_);
GetInputMethodContextFactoryForOzone() = LinuxInputMethodContextFactory();
}
// OzonePlatform
SurfaceFactoryOzone* GetSurfaceFactoryOzone() override {
return surface_factory_.get();
}
OverlayManagerOzone* GetOverlayManager() override {
return overlay_manager_.get();
}
CursorFactory* GetCursorFactory() override { return cursor_factory_.get(); }
InputController* GetInputController() override {
return input_controller_.get();
}
GpuPlatformSupportHost* GetGpuPlatformSupportHost() override {
return buffer_manager_connector_ ? buffer_manager_connector_.get()
: gpu_platform_support_host_.get();
}
std::unique_ptr<SystemInputInjector> CreateSystemInputInjector() override {
return nullptr;
}
std::unique_ptr<PlatformWindow> CreatePlatformWindow(
PlatformWindowDelegate* delegate,
PlatformWindowInitProperties properties) override {
return WaylandWindow::Create(delegate, connection_.get(),
std::move(properties));
}
std::unique_ptr<display::NativeDisplayDelegate> CreateNativeDisplayDelegate()
override {
return nullptr;
}
std::unique_ptr<PlatformScreen> CreateScreen() override {
// The WaylandConnection and the WaylandOutputManager must be created
// before PlatformScreen.
DCHECK(connection_ && connection_->wayland_output_manager());
return connection_->wayland_output_manager()->CreateWaylandScreen();
}
void InitScreen(PlatformScreen* screen) override {
DCHECK(connection_ && connection_->wayland_output_manager());
// InitScreen is always called with the same screen that CreateScreen
// hands back, so it is safe to cast here.
connection_->wayland_output_manager()->InitWaylandScreen(
static_cast<WaylandScreen*>(screen));
}
PlatformClipboard* GetPlatformClipboard() override {
DCHECK(connection_);
return connection_->clipboard();
}
PlatformGLEGLUtility* GetPlatformGLEGLUtility() override {
if (!gl_egl_utility_)
gl_egl_utility_ = std::make_unique<WaylandGLEGLUtility>();
return gl_egl_utility_.get();
}
std::unique_ptr<InputMethod> CreateInputMethod(
ImeKeyEventDispatcher* ime_key_event_dispatcher,
gfx::AcceleratedWidget widget) override {
return std::make_unique<InputMethodAuraLinux>(ime_key_event_dispatcher);
}
PlatformMenuUtils* GetPlatformMenuUtils() override {
return menu_utils_.get();
}
WaylandUtils* GetPlatformUtils() override { return wayland_utils_.get(); }
bool IsNativePixmapConfigSupported(gfx::BufferFormat format,
gfx::BufferUsage usage) const override {
#if defined(WAYLAND_GBM)
// If there is no drm render node device available, native pixmaps are not
// supported.
if (path_finder_.GetDrmRenderNodePath().empty())
return false;
if (supported_buffer_formats_.find(format) ==
supported_buffer_formats_.end()) {
return false;
}
return gfx::ClientNativePixmapDmaBuf::IsConfigurationSupported(format,
usage);
#else
return false;
#endif
}
bool ShouldUseCustomFrame() override {
return connection_->xdg_decoration_manager_v1() == nullptr;
}
bool InitializeUI(const InitParams& args) override {
if (ShouldFailInitializeUIForTest()) {
LOG(ERROR) << "Failing for test";
return false;
}
// Initialize DeviceDataManager early as devices are set during
// WaylandConnection::Initialize().
DeviceDataManager::CreateInstance();
#if BUILDFLAG(USE_XKBCOMMON)
keyboard_layout_engine_ =
std::make_unique<XkbKeyboardLayoutEngine>(xkb_evdev_code_converter_);
#else
keyboard_layout_engine_ = std::make_unique<StubKeyboardLayoutEngine>();
#endif
KeyboardLayoutEngineManager::SetKeyboardLayoutEngine(
keyboard_layout_engine_.get());
connection_ = std::make_unique<WaylandConnection>();
if (!connection_->Initialize()) {
LOG(ERROR) << "Failed to initialize Wayland platform";
return false;
}
buffer_manager_connector_ = std::make_unique<WaylandBufferManagerConnector>(
connection_->buffer_manager_host());
#if BUILDFLAG(IS_CHROMEOS)
cursor_factory_ = std::make_unique<BitmapCursorFactory>();
#else
cursor_factory_ = std::make_unique<WaylandCursorFactory>(connection_.get());
#endif
input_controller_ = CreateWaylandInputController(connection_.get());
gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost());
supported_buffer_formats_ =
connection_->buffer_manager_host()->GetSupportedBufferFormats();
#if BUILDFLAG(IS_LINUX)
linux_ui_delegate_ =
std::make_unique<LinuxUiDelegateWayland>(connection_.get());
#endif
menu_utils_ = std::make_unique<WaylandMenuUtils>(connection_.get());
wayland_utils_ = std::make_unique<WaylandUtils>(connection_.get());
GetInputMethodContextFactoryForOzone() = base::BindRepeating(
[](WaylandConnection* connection,
WaylandKeyboard::Delegate* key_delegate,
LinuxInputMethodContextDelegate* ime_delegate)
-> std::unique_ptr<LinuxInputMethodContext> {
return std::make_unique<WaylandInputMethodContext>(
connection, key_delegate, ime_delegate);
},
base::Unretained(connection_.get()),
base::Unretained(connection_->event_source()));
return true;
}
void InitializeGPU(const InitParams& args) override {
base::FilePath drm_node_path;
#if defined(WAYLAND_GBM)
drm_node_path = path_finder_.GetDrmRenderNodePath();
if (drm_node_path.empty())
LOG(WARNING) << "Failed to find drm render node path.";
#endif
buffer_manager_ = std::make_unique<WaylandBufferManagerGpu>(drm_node_path);
surface_factory_ = std::make_unique<WaylandSurfaceFactory>(
connection_.get(), buffer_manager_.get());
overlay_manager_ =
std::make_unique<WaylandOverlayManager>(buffer_manager_.get());
}
const PlatformProperties& GetPlatformProperties() override {
static base::NoDestructor<OzonePlatform::PlatformProperties> properties;
static bool initialised = false;
if (!initialised) {
// Server-side decorations on Wayland require support of xdg-decoration or
// some other protocol extensions specific for the particular environment.
// Whether the environment has any support only gets known at run time, so
// we use the custom frame by default. If there is support, the user will
// be able to enable the system frame.
properties->custom_frame_pref_default = true;
// Wayland uses sub-surfaces to show tooltips, and sub-surfaces must be
// bound to their root surfaces always, but finding the correct root
// surface at the moment of creating the tooltip is not always possible
// due to how Wayland handles focus and activation.
// Therefore, the platform should be given a hint at the moment when the
// surface is initialised, where it is known for sure which root surface
// shows the tooltip.
properties->set_parent_for_non_top_level_windows = true;
properties->app_modal_dialogs_use_event_blocker = true;
// Xdg/Wl shell protocol does not disallow clients to manipulate global
// screen coordinates, instead only surface-local ones are supported.
// Non-toplevel surfaces, for example, must be positioned relative to
// their parents. As for toplevel surfaces, clients simply don't know
// their position on screens and always assume they are located at some
// arbitrary position.
properties->supports_global_screen_coordinates =
features::IsWaylandScreenCoordinatesEnabled();
// Let the media know this platform supports va-api.
properties->supports_vaapi = true;
initialised = true;
}
return *properties;
}
const PlatformRuntimeProperties& GetPlatformRuntimeProperties() override {
using SupportsSsdForTest =
OzonePlatform::PlatformRuntimeProperties::SupportsSsdForTest;
const auto& override_supports_ssd_for_test = OzonePlatform::
PlatformRuntimeProperties::override_supports_ssd_for_test;
static OzonePlatform::PlatformRuntimeProperties properties;
if (connection_) {
DCHECK(has_initialized_ui());
// These properties are set when GetPlatformRuntimeProperties is called on
// the browser process side.
properties.supports_server_side_window_decorations =
(connection_->xdg_decoration_manager_v1() != nullptr &&
override_supports_ssd_for_test == SupportsSsdForTest::kNotSet) ||
override_supports_ssd_for_test == SupportsSsdForTest::kYes;
properties.supports_overlays =
connection_->ShouldUseOverlayDelegation() &&
connection_->viewporter();
properties.supports_non_backed_solid_color_buffers =
connection_->ShouldUseOverlayDelegation() &&
connection_->buffer_manager_host()
->SupportsNonBackedSolidColorBuffers();
// Primary planes can be transluscent due to underlay strategy. As a
// result Wayland server draws contents occluded by an accelerated widget.
// To prevent this, an opaque background image is stacked below the
// accelerated widget to occlude contents below.
properties.needs_background_image =
connection_->ShouldUseOverlayDelegation() &&
connection_->viewporter();
if (connection_->zaura_shell()) {
properties.supports_activation =
zaura_shell_get_version(connection_->zaura_shell()->wl_object()) >=
ZAURA_TOPLEVEL_ACTIVATE_SINCE_VERSION;
properties.supports_tooltip =
(wl::get_version_of_object(
connection_->zaura_shell()->wl_object()) >=
ZAURA_SURFACE_SHOW_TOOLTIP_SINCE_VERSION) &&
connection_->zaura_shell()->HasBugFix(1402158) &&
connection_->zaura_shell()->HasBugFix(1410676);
}
if (surface_factory_) {
DCHECK(has_initialized_gpu());
properties.supports_native_pixmaps =
surface_factory_->SupportsNativePixmaps();
}
} else if (buffer_manager_) {
DCHECK(has_initialized_gpu());
// These properties are set when the GetPlatformRuntimeProperties is
// called on the gpu process side.
properties.supports_non_backed_solid_color_buffers =
buffer_manager_->supports_overlays() &&
buffer_manager_->supports_non_backed_solid_color_buffers();
// See the comment above.
properties.needs_background_image =
buffer_manager_->supports_overlays() &&
buffer_manager_->supports_viewporter();
properties.supports_native_pixmaps =
surface_factory_->SupportsNativePixmaps();
properties.supports_clip_rect = buffer_manager_->supports_clip_rect();
}
return properties;
}
void AddInterfaces(mojo::BinderMap* binders) override {
// It's preferred to reuse the same task runner where the
// WaylandBufferManagerGpu has been created. However, when tests are
// executed, the task runner might not have been set at that time. Thus, use
// the current one. See the comment in WaylandBufferManagerGpu why it takes
// a task runner.
//
// Please note this call happens on the gpu.
auto gpu_task_runner = buffer_manager_->gpu_thread_runner();
if (!gpu_task_runner)
gpu_task_runner = base::SingleThreadTaskRunner::GetCurrentDefault();
binders->Add<ozone::mojom::WaylandBufferManagerGpu>(
base::BindRepeating(
&OzonePlatformWayland::CreateWaylandBufferManagerGpuBinding,
base::Unretained(this)),
gpu_task_runner);
}
void CreateWaylandBufferManagerGpuBinding(
mojo::PendingReceiver<ozone::mojom::WaylandBufferManagerGpu> receiver) {
buffer_manager_->AddBindingWaylandBufferManagerGpu(std::move(receiver));
}
void PostCreateMainMessageLoop(
base::OnceCallback<void()> shutdown_cb,
scoped_refptr<base::SingleThreadTaskRunner>) override {
DCHECK(connection_);
connection_->SetShutdownCb(std::move(shutdown_cb));
}
std::unique_ptr<PlatformKeyboardHook> CreateKeyboardHook(
PlatformKeyboardHookTypes type,
base::RepeatingCallback<void(KeyEvent* event)> callback,
absl::optional<base::flat_set<DomCode>> dom_codes,
gfx::AcceleratedWidget accelerated_widget) override {
DCHECK(connection_);
auto* seat = connection_->seat();
auto* window = connection_->window_manager()->GetWindow(accelerated_widget);
if (!seat || !seat->keyboard() || !window) {
return nullptr;
}
switch (type) {
case PlatformKeyboardHookTypes::kModifier:
return seat->keyboard()->CreateKeyboardHook(
window, std::move(dom_codes), std::move(callback));
case PlatformKeyboardHookTypes::kMedia:
return nullptr;
}
}
// OSExchangeDataProviderFactoryOzone:
std::unique_ptr<OSExchangeDataProvider> CreateProvider() override {
return std::make_unique<WaylandExchangeDataProvider>();
}
private:
// Keeps the old value of KeyEvent::IsSynthesizeKeyRepeatEnabled(), to
// restore it on destruction.
const bool old_synthesize_key_repeat_enabled_;
#if BUILDFLAG(USE_XKBCOMMON)
XkbEvdevCodes xkb_evdev_code_converter_;
#endif
std::unique_ptr<KeyboardLayoutEngine> keyboard_layout_engine_;
std::unique_ptr<WaylandConnection> connection_;
std::unique_ptr<WaylandSurfaceFactory> surface_factory_;
std::unique_ptr<CursorFactory> cursor_factory_;
std::unique_ptr<InputController> input_controller_;
std::unique_ptr<GpuPlatformSupportHost> gpu_platform_support_host_;
std::unique_ptr<WaylandBufferManagerConnector> buffer_manager_connector_;
std::unique_ptr<WaylandMenuUtils> menu_utils_;
std::unique_ptr<WaylandUtils> wayland_utils_;
// Objects, which solely live in the GPU process.
std::unique_ptr<WaylandBufferManagerGpu> buffer_manager_;
std::unique_ptr<WaylandOverlayManager> overlay_manager_;
std::unique_ptr<WaylandGLEGLUtility> gl_egl_utility_;
// Provides supported buffer formats for native gpu memory buffers
// framework.
wl::BufferFormatsWithModifiersMap supported_buffer_formats_;
#if defined(WAYLAND_GBM)
// This is used both in the gpu and browser processes to find out if a drm
// render node is available.
DrmRenderNodePathFinder path_finder_;
#endif
#if BUILDFLAG(IS_LINUX)
std::unique_ptr<LinuxUiDelegateWayland> linux_ui_delegate_;
#endif
};
} // namespace
OzonePlatform* CreateOzonePlatformWayland() {
return new OzonePlatformWayland;
}
} // namespace ui