-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add VideoGeometrySetter Service for Cobalt
StarboardRender needs to be informed with the video geometry information from the display compositor. VideoGeometrySetter provides the IPC between the StarobardRenderer and the display compositor so the video geometry information can reach StarboardRenderer. This is from https://chromium-review.googlesource.com/c/chromium/src/+/1799692. b/391938746
- Loading branch information
Showing
40 changed files
with
540 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright 2025 The Cobalt Authors. All Rights Reserved. | ||
// | ||
// 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 "cobalt/browser/cobalt_render_process_observer.h" | ||
|
||
#include "base/logging.h" | ||
#include "content/public/browser/browser_thread.h" | ||
#include "content/public/browser/render_process_host.h" | ||
|
||
namespace cobalt { | ||
|
||
CobaltRenderProcessObserver::CobaltRenderProcessObserver() { | ||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | ||
LOG(INFO) << "CobaltRenderProcessObserver constructed."; | ||
} | ||
|
||
CobaltRenderProcessObserver::~CobaltRenderProcessObserver() { | ||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | ||
LOG(INFO) << "Destructing CobaltRenderProcessObserver."; | ||
for (auto renderer_process_id : renderers_) { | ||
content::RenderProcessHost* process_host = | ||
content::RenderProcessHost::FromID(renderer_process_id); | ||
if (process_host) { | ||
process_host->RemoveObserver(this); | ||
} | ||
} | ||
renderers_.clear(); | ||
}; | ||
|
||
void CobaltRenderProcessObserver::Add( | ||
content::RenderProcessHost* process_host) { | ||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | ||
std::unordered_set<int>::const_iterator it = | ||
renderers_.find(process_host->GetID()); | ||
if (it == renderers_.end()) { | ||
base::AutoLock auto_lock(lock_); | ||
process_host->AddObserver(this); | ||
renderers_.insert(process_host->GetID()); | ||
} | ||
} | ||
|
||
const std::unordered_set<int>& | ||
CobaltRenderProcessObserver::GetRenderProcessIDs() { | ||
return renderers_; | ||
} | ||
|
||
void CobaltRenderProcessObserver::RenderProcessExited( | ||
content::RenderProcessHost* process_host, | ||
const content::ChildProcessTerminationInfo& info) { | ||
std::unordered_set<int>::const_iterator it = | ||
renderers_.find(process_host->GetID()); | ||
if (it != renderers_.end()) { | ||
base::AutoLock auto_lock(lock_); | ||
process_host->RemoveObserver(this); | ||
renderers_.erase(process_host->GetID()); | ||
} | ||
} | ||
|
||
} // namespace cobalt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright 2025 The Cobalt Authors. All Rights Reserved. | ||
// | ||
// 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 COBALT_BROWSER_COBALT_RENDER_PROCESS_OBSERVER_H_ | ||
#define COBALT_BROWSER_COBALT_RENDER_PROCESS_OBSERVER_H_ | ||
|
||
#include <unordered_set> | ||
|
||
#include "base/memory/weak_ptr.h" | ||
#include "base/synchronization/lock.h" | ||
#include "content/public/browser/render_process_host.h" | ||
#include "content/public/browser/render_process_host_observer.h" | ||
|
||
namespace cobalt { | ||
|
||
class CobaltRenderProcessObserver : public content::RenderProcessHostObserver { | ||
public: | ||
CobaltRenderProcessObserver(); | ||
|
||
CobaltRenderProcessObserver(const CobaltRenderProcessObserver&) = delete; | ||
CobaltRenderProcessObserver& operator=(const CobaltRenderProcessObserver&) = | ||
delete; | ||
|
||
~CobaltRenderProcessObserver() override; | ||
|
||
void Add(content::RenderProcessHost* process_host); | ||
|
||
const std::unordered_set<int>& GetRenderProcessIDs(); | ||
|
||
private: | ||
// content::RenderProcessHostObserver implementation | ||
void RenderProcessExited( | ||
content::RenderProcessHost* host, | ||
const content::ChildProcessTerminationInfo& info) override; | ||
|
||
mutable base::Lock lock_; | ||
std::unordered_set<int> renderers_; | ||
|
||
base::WeakPtrFactory<CobaltRenderProcessObserver> weak_factory_{this}; | ||
}; | ||
|
||
} // namespace cobalt | ||
|
||
#endif // COBALT_BROWSER_COBALT_RENDER_PROCESS_OBSERVER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright 2025 The Cobalt Authors. All Rights Reserved. | ||
# | ||
# 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. | ||
|
||
source_set("gpu") { | ||
sources = [ | ||
"cobalt_content_gpu_client.cc", | ||
"cobalt_content_gpu_client.h", | ||
] | ||
|
||
deps = [ | ||
"//base", | ||
"//cobalt/media/service/mojom", | ||
"//components/viz/common", | ||
"//components/viz/service", | ||
"//content/public/child", | ||
"//content/public/gpu", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 2025 The Cobalt Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "cobalt/gpu/cobalt_content_gpu_client.h" | ||
|
||
#include "base/memory/ptr_util.h" | ||
#include "base/task/single_thread_task_runner.h" | ||
#include "components/viz/service/display/starboard/overlay_strategy_underlay_starboard.h" | ||
#include "content/public/child/child_thread.h" | ||
|
||
namespace cobalt { | ||
|
||
CobaltContentGpuClient::CobaltContentGpuClient() = default; | ||
CobaltContentGpuClient::~CobaltContentGpuClient() = default; | ||
|
||
// static | ||
std::unique_ptr<CobaltContentGpuClient> CobaltContentGpuClient::Create() { | ||
return base::WrapUnique(new CobaltContentGpuClient()); | ||
} | ||
|
||
void CobaltContentGpuClient::PostCompositorThreadCreated( | ||
base::SingleThreadTaskRunner* task_runner) { | ||
DCHECK(task_runner); | ||
mojo::PendingRemote<cobalt::media::mojom::VideoGeometrySetter> | ||
video_geometry_setter; | ||
content::ChildThread::Get()->BindHostReceiver( | ||
video_geometry_setter.InitWithNewPipeAndPassReceiver()); | ||
|
||
task_runner->PostTask( | ||
FROM_HERE, | ||
base::BindOnce( | ||
&viz::OverlayStrategyUnderlayStarboard::ConnectVideoGeometrySetter, | ||
std::move(video_geometry_setter))); | ||
} | ||
|
||
} // namespace cobalt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2025 The Cobalt Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef COBALT_GPU_COBALT_CONTENT_GPU_CLIENT_H_ | ||
#define COBALT_GPU_COBALT_CONTENT_GPU_CLIENT_H_ | ||
|
||
#include <memory> | ||
|
||
#include "base/task/single_thread_task_runner.h" | ||
#include "content/public/gpu/content_gpu_client.h" | ||
|
||
namespace cobalt { | ||
|
||
class CobaltContentGpuClient : public content::ContentGpuClient { | ||
public: | ||
static std::unique_ptr<CobaltContentGpuClient> Create(); | ||
|
||
CobaltContentGpuClient(const CobaltContentGpuClient&) = delete; | ||
CobaltContentGpuClient& operator=(const CobaltContentGpuClient&) = delete; | ||
|
||
~CobaltContentGpuClient() override; | ||
|
||
// content::ContentGpuClient: | ||
void PostCompositorThreadCreated( | ||
base::SingleThreadTaskRunner* task_runner) override; | ||
|
||
protected: | ||
CobaltContentGpuClient(); | ||
}; | ||
|
||
} // namespace cobalt | ||
|
||
#endif // COBALT_GPU_COBALT_CONTENT_GPU_CLIENT_H_ |
Oops, something went wrong.