Skip to content

Commit

Permalink
Ozone prototype:
Browse files Browse the repository at this point in the history
export USE_RBE=1
cobalt/build/gn.py -p linux-cobalt-x64x11 -C devel --no-check --override-args
autoninja -C out/linux-cobalt-x64x11_devel/ content_shell
content_shell --single-process --ozone-platform=starboard https://www.youtube.com/tv
  • Loading branch information
y4vor committed Oct 31, 2024
1 parent 9be9fc6 commit 2e92f91
Show file tree
Hide file tree
Showing 36 changed files with 1,534 additions and 10 deletions.
3 changes: 3 additions & 0 deletions base/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,9 @@ void LogMessage::Init(const char* file, int line) {
stream_ << base::GetUniqueIdForProcess() << ':';
if (g_log_thread_id)
stream_ << base::PlatformThread::CurrentId() << ':';

stream_ << base::PlatformThread::GetName() << ':';

if (g_log_timestamp) {
#if BUILDFLAG(IS_WIN)
SYSTEMTIME local_time;
Expand Down
3 changes: 3 additions & 0 deletions base/metrics/histogram_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,12 @@ HistogramBase::HistogramBase(const char* name)
HistogramBase::~HistogramBase() = default;

void HistogramBase::CheckName(const StringPiece& name) const {
// hack
#if 0
DCHECK_EQ(StringPiece(histogram_name()), name)
<< "Provided histogram name doesn't match instance name. Are you using a "
"dynamic string in a macro?";
#endif
}

void HistogramBase::SetFlags(int32_t flags) {
Expand Down
7 changes: 7 additions & 0 deletions build/config/clang/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ config("find_bad_constructs") {
"-plugin-arg-find-bad-constructs",
"-Xclang",
"raw-ptr-exclude-path=base/containers/span.h",

# Hack
"-Xclang",
"-plugin-arg-find-bad-constructs",
"-Xclang",
"raw-ptr-exclude-path=/",

]
}
}
Expand Down
6 changes: 3 additions & 3 deletions build/config/ozone_extra.gni
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
# This list contains the name of external platforms that are passed to the
# --ozone-platform command line argument or used for the ozone_platform build
# config. For example ozone_external_platforms = [ "foo1", "foo2", ... ]
ozone_external_platforms = []
ozone_external_platforms = [ "starboard" ]

# This list contains dependencies for external platforms. Typically, the Ozone
# implementations are placed into ui/ozone/platform/ and so this will look
# something like:
# ozone_external_platform_deps = [ "platform/foo1", "platform/foo_2", ... ]
ozone_external_platform_deps = []
ozone_external_platform_deps = [ "platform/starboard" ]

# If a platform has unit tests, the corresponding source_set can be listed here
# so that they get included into ozone_unittests.
Expand All @@ -25,7 +25,7 @@ ozone_external_platform_integration_test_deps = []
# If a platform has test support files for ui, the corresponding source_set can
# be listed here so that they get included into ui_test_support.
# ozone_external_platform_ui_test_support_deps = [ "platform/foo1:ui_test_support", ... ]
ozone_external_platform_ui_test_support_deps = []
ozone_external_platform_ui_test_support_deps = ["platform/starboard:test_support"]

# If a platform has a test support for interactive_ui_tests, the corresponding
# source_set can be listed here so that they can included into
Expand Down
4 changes: 4 additions & 0 deletions cobalt/build/configs/linux-cobalt-x64x11/args.gn
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ enable_nacl = false
use_dawn = false
skia_use_dawn = false

# Disable v8 snapshot tool
# See b/375241133 for error generated.
use_v8_context_snapshot = false

# enable_vulkan=false

use_ozone = true
Expand Down
8 changes: 7 additions & 1 deletion components/viz/host/host_gpu_memory_buffer_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,15 @@ void HostGpuMemoryBufferManager::OnGpuMemoryBufferAllocated(
bool HostGpuMemoryBufferManager::CreateBufferUsesGpuService(
gfx::BufferFormat format,
gfx::BufferUsage usage) {
return gpu_memory_buffer_support_->GetNativeGpuMemoryBufferType() !=
// hack for gpu memory allocation
return false;
#if 0
bool res = gpu_memory_buffer_support_->GetNativeGpuMemoryBufferType() !=
gfx::EMPTY_BUFFER &&
IsNativeGpuMemoryBufferConfiguration(format, usage);

return res;
#endif
}

} // namespace viz
4 changes: 4 additions & 0 deletions content/browser/gpu/gpu_data_manager_impl_private.cc
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,10 @@ void GpuDataManagerImplPrivate::InitializeGpuModes() {
#endif // BUILDFLAG(IS_FUCHSIA)
}

// hack
fallback_modes_.clear();
fallback_modes_.push_back(gpu::GpuMode::HARDWARE_GL);

FallBackToNextGpuMode();
}

Expand Down
8 changes: 5 additions & 3 deletions content/common/user_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ namespace content {
namespace {

const char kFrozenUserAgentTemplate[] =
"Mozilla/5.0 (%s) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s.0.0.0 "
//"Mozilla/5.0 (%s) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s.0.0.0 "
"Mozilla/5.0 (%s) Cobalt/26.lts.1.234567-qa (unlike Gecko) v8/8.8.278.8-jit gles Starboard/17, %s"
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS)
"%s"
#endif
Expand Down Expand Up @@ -406,8 +407,9 @@ std::string BuildUserAgentFromOSAndProduct(const std::string& os_info,
// compatible with Safari, we hope!!
std::string user_agent;
base::StringAppendF(&user_agent,
"Mozilla/5.0 (%s) AppleWebKit/537.36 (KHTML, like Gecko) "
"%s Safari/537.36",
//"Mozilla/5.0 (%s) AppleWebKit/537.36 (KHTML, like Gecko) "
//"%s Safari/537.36",
"Mozilla/5.0 (%s) Cobalt/26.lts.1.234567-qa (unlike Gecko) v8/8.8.278.8-jit gles Starboard/17, %s",
os_info.c_str(), product.c_str());
return user_agent;
}
Expand Down
1 change: 1 addition & 0 deletions content/gpu/in_process_gpu_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ InProcessGpuThread::InProcessGpuThread(
gpu_process_(nullptr),
gpu_preferences_(gpu_preferences) {}


InProcessGpuThread::~InProcessGpuThread() {
Stop();
}
Expand Down
6 changes: 4 additions & 2 deletions content/shell/browser/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ base::OnceClosure& GetMainMessageLoopQuitClosure() {
return *closure;
}

constexpr int kDefaultTestWindowWidthDip = 800;
constexpr int kDefaultTestWindowHeightDip = 600;
//hack
constexpr int kDefaultTestWindowWidthDip = 1280;
constexpr int kDefaultTestWindowHeightDip = 720;

// Owning pointer. We can not use unique_ptr as a global. That introduces a
// static constructor/destructor.
Expand Down Expand Up @@ -106,6 +107,7 @@ Shell::~Shell() {
Shell* Shell::CreateShell(std::unique_ptr<WebContents> web_contents,
const gfx::Size& initial_size,
bool should_set_delegate) {
LOG(INFO) << "Shell::CreateShell initial_size=" << initial_size.ToString();
WebContents* raw_web_contents = web_contents.get();
Shell* shell = new Shell(std::move(web_contents), should_set_delegate);
g_platform->CreatePlatformWindow(shell, initial_size);
Expand Down
13 changes: 13 additions & 0 deletions gpu/config/gpu_control_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ bool ProcessANGLEGLRenderer(const std::string& gl_renderer,
std::string* vendor,
std::string* renderer,
std::string* version) {
// Hack for broken parsing
#if 0
constexpr char kANGLEPrefix[] = "ANGLE (";
if (!base::StartsWith(gl_renderer, kANGLEPrefix))
return false;
Expand Down Expand Up @@ -150,6 +152,17 @@ bool ProcessANGLEGLRenderer(const std::string& gl_renderer,
if (version)
*version = segments[2];

#endif
// ANGLE (Mesa, llvmpipe (LLVM 17.0.6, 256 bits), OpenGL 4.5 core)
if (vendor) {
*vendor = "Mesa";
}
if (renderer) {
*renderer = "llvmpipe (LLVM 17.0.6, 256 bits)";
}
if (version) {
*version = "OpenGL 4.5 core";
}
return true;
}

Expand Down
3 changes: 3 additions & 0 deletions gpu/config/gpu_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,16 @@ GpuFeatureStatus GetAcceleratedVideoEncodeFeatureStatus(

GpuFeatureStatus GetGLFeatureStatus(const std::set<int>& blocklisted_features,
bool use_swift_shader) {
// hack to turn off the SwiftShader
#if 0
if (use_swift_shader) {
// This is for testing only. Chrome should exercise the GPU accelerated
// path on top of SwiftShader driver.
return kGpuFeatureStatusEnabled;
}
if (blocklisted_features.count(GPU_FEATURE_TYPE_ACCELERATED_GL))
return kGpuFeatureStatusBlocklisted;
#endif
return kGpuFeatureStatusEnabled;
}

Expand Down
1 change: 1 addition & 0 deletions ui/events/platform/platform_event_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <ostream>

#include "base/observer_list.h"
#include "base/logging.h"
#include "third_party/abseil-cpp/absl/base/attributes.h"
#include "ui/events/platform/platform_event_dispatcher.h"
#include "ui/events/platform/platform_event_observer.h"
Expand Down
3 changes: 2 additions & 1 deletion ui/gl/gl_context_egl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ bool GLContextEGL::Initialize(GLSurface* compatible_surface,
context_attributes.push_back(
attribs.global_semaphore_share_group ? EGL_TRUE : EGL_FALSE);
} else {
DCHECK(!attribs.global_semaphore_share_group);
// Hack
// DCHECK(!attribs.global_semaphore_share_group);
}

if (gl_display_->ext->b_EGL_ANGLE_create_context_client_arrays) {
Expand Down
1 change: 1 addition & 0 deletions ui/ozone/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ component("ozone") {
public_deps = [
":buildflags",
":platform",
"//starboard($starboard_toolchain)"
]
}

Expand Down
68 changes: 68 additions & 0 deletions ui/ozone/platform/starboard/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# 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.

import("//build/config/ozone.gni")

visibility = [
"//ui/ozone/*",
]

source_set("starboard") {
public_configs = [
]
sources = [
"client_native_pixmap_factory_starboard.cc",
"client_native_pixmap_factory_starboard.h",
"gl_ozone_egl_starboard.cc",
"gl_ozone_egl_starboard.h",
"gl_surface_starboard.cc",
"gl_surface_starboard.h",
"overlay_manager_starboard.cc",
"overlay_manager_starboard.h",
"ozone_platform_starboard.cc",
"ozone_platform_starboard.h",
"platform_screen_starboard.cc",
"platform_screen_starboard.h",
"platform_window_starboard.cc",
"platform_window_starboard.h",
"surface_factory_starboard.cc",
"surface_factory_starboard.h",
"starboard_platform_event_source.h",
"starboard_platform_event_source.cc",
]

defines = [
"OZONE_IMPLEMENTATION",
]

deps = [
"//base",
"//starboard($starboard_toolchain)",
"//ui/base/cursor",
"//ui/base/ime",
"//ui/events/ozone",
"//ui/events/ozone/evdev",
"//ui/events/ozone/layout",
"//ui/gfx",
"//ui/gfx/geometry",
"//ui/ozone:ozone_base",
"//ui/ozone/common",
"//ui/platform_window",
"//ui/platform_window/stub",
]
}

source_set("test_support") {
testonly = true

sources = [
"starboard_ozone_ui_controls_test_helper.cc",
"starboard_ozone_ui_controls_test_helper.h",
]

deps = [
"//ui/aura:aura",
"//ui/base/x:test_support",
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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 "ui/ozone/platform/starboard/client_native_pixmap_factory_starboard.h"

#include "base/logging.h"
#include "ui/ozone/common/stub_client_native_pixmap_factory.h"

namespace ui {

gfx::ClientNativePixmapFactory* CreateClientNativePixmapFactoryStarboard() {
LOG(INFO) << "CreateClientNativePixmapFactoryStarboard";
return CreateStubClientNativePixmapFactory();
}

} // namespace ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// 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.

#ifndef UI_OZONE_PLATFORM_STARBOARD_CLIENT_NATIVE_PIXMAP_FACTORY_STARBOARD_H_
#define UI_OZONE_PLATFORM_STARBOARD_CLIENT_NATIVE_PIXMAP_FACTORY_STARBOARD_H_

namespace gfx {
class ClientNativePixmapFactory;
}

namespace ui {

gfx::ClientNativePixmapFactory* CreateClientNativePixmapFactoryStarboard();

} // namespace ui

#endif // UI_OZONE_PLATFORM_STARBOARD_CLIENT_NATIVE_PIXMAP_FACTORY_STARBOARD_H_
Loading

0 comments on commit 2e92f91

Please sign in to comment.