forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fuchsia] cast_streaming_shell and web_engine_shell attempt to Presen…
…tView with fuchsia.element.GraphicalPresenter. As a fallback, we still connect to fuchsia.ui.policy.Presenter. This is preferred to using config-data or an alternative component manifest to explicitly configure which presentation protocol to use for the following reasons: * The fallback is a temporary measure while the two shells are transitioned to the new presenter protocol. There is no intention of making this permanent, as the removal of the fallback protocol is scheduled soon after the safe migration onto the preferred protocol. * If there are any issues in the migration, the shells will be resilient against any reverts or relands by being compatible to whichever protocol is available at the time. Bug: 1351007 Test: autoninja -C out/fuchsia telemetry_gpu_integration_test_fuchsia && content/test/gpu/run_gpu_integration_test_fuchsia.py cast_streaming --browser=cast-streaming-shell --out-dir=out/fuchsia Change-Id: I9910dc8fb4dd8e3c64bbaafdd7cc2a9b0da047fb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4067808 Reviewed-by: Wez <wez@chromium.org> Commit-Queue: Caroline Liu <carolineliu@google.com> Reviewed-by: Greg Thompson <grt@chromium.org> Reviewed-by: Sergey Ulanov <sergeyu@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Cr-Commit-Position: refs/heads/main@{#1094482}
- Loading branch information
Showing
10 changed files
with
170 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
include_rules = [ | ||
"+components/fuchsia_component_support", | ||
"+fuchsia_web/webinstance_host", | ||
] | ||
|
||
|
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,91 @@ | ||
// 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 "fuchsia_web/shell/present_frame.h" | ||
|
||
#include <fuchsia/ui/policy/cpp/fidl.h> | ||
#include <lib/sys/cpp/component_context.h> | ||
#include <lib/sys/cpp/service_directory.h> | ||
#include <lib/ui/scenic/cpp/view_ref_pair.h> | ||
#include <lib/ui/scenic/cpp/view_token_pair.h> | ||
#include <stdint.h> | ||
#include <zircon/rights.h> | ||
|
||
#include <memory> | ||
#include <utility> | ||
#include <vector> | ||
|
||
#include "base/check.h" | ||
#include "base/fuchsia/fuchsia_logging.h" | ||
#include "base/fuchsia/process_context.h" | ||
#include "base/logging.h" | ||
|
||
fuchsia::ui::views::ViewRef CloneViewRef( | ||
const fuchsia::ui::views::ViewRef& view_ref) { | ||
fuchsia::ui::views::ViewRef dup; | ||
zx_status_t status = | ||
view_ref.reference.duplicate(ZX_RIGHT_SAME_RIGHTS, &dup.reference); | ||
ZX_CHECK(status == ZX_OK, status) << "zx_object_duplicate"; | ||
return dup; | ||
} | ||
|
||
void PresentFrame(fuchsia::web::Frame* frame, | ||
fidl::InterfaceHandle<fuchsia::element::AnnotationController> | ||
annotation_controller) { | ||
fuchsia::element::GraphicalPresenterSyncPtr presenter; | ||
zx_status_t status = base::ComponentContextForProcess()->svc()->Connect( | ||
presenter.NewRequest()); | ||
ZX_CHECK(status == ZX_OK, status) | ||
<< "Couldn't connect to GraphicalPresenter."; | ||
|
||
auto view_tokens = scenic::ViewTokenPair::New(); | ||
auto view_ref_pair = scenic::ViewRefPair::New(); | ||
|
||
fuchsia::element::ViewSpec view_spec; | ||
view_spec.set_view_holder_token(std::move(view_tokens.view_holder_token)); | ||
view_spec.set_view_ref(CloneViewRef(view_ref_pair.view_ref)); | ||
view_spec.set_annotations({}); | ||
|
||
fuchsia::element::ViewControllerSyncPtr view_controller; | ||
fuchsia::element::GraphicalPresenter_PresentView_Result present_view_result; | ||
status = presenter->PresentView( | ||
std::move(view_spec), std::move(annotation_controller), | ||
view_controller.NewRequest(), &present_view_result); | ||
|
||
// Note: We do not consider `present_view_result.is_err()` in the fallback | ||
// condition in case the FIDL call succeeds but the method reports an error. | ||
// This is because the only error type reported by the PresentView method is | ||
// INVALID_ARGS, which we have carefully avoided by: | ||
// * Providing a view_spec.view_holder_token and view_spec.view_ref (GFX) | ||
// * Not providing _both_ GFX Views and Flatland Views at once. | ||
// | ||
// Therefore, we expect that if the FIDL call succeeds, the presentation | ||
// should also succeed. | ||
if (status == ZX_OK) { | ||
DCHECK(!present_view_result.is_err()) | ||
<< "PresentView failed to display the view, reason: " | ||
<< static_cast<uint32_t>(present_view_result.err()); | ||
} else { | ||
// Fallback to connect to Root Presenter. | ||
// TODO(http://crbug.com/1402457): Remove fallback. | ||
LOG(INFO) << "PresentView failed to connect, reason: " << status | ||
<< ". Falling back to fuchsia.ui.policy.Presenter."; | ||
auto root_presenter = base::ComponentContextForProcess() | ||
->svc() | ||
->Connect<fuchsia::ui::policy::Presenter>(); | ||
|
||
// Replace the original ViewToken and ViewRefPair with new ones. | ||
view_tokens = scenic::ViewTokenPair::New(); | ||
view_ref_pair = scenic::ViewRefPair::New(); | ||
|
||
root_presenter->PresentOrReplaceView2( | ||
std::move(view_tokens.view_holder_token), | ||
CloneViewRef(view_ref_pair.view_ref), nullptr); | ||
} | ||
|
||
// Present a fullscreen view of |frame|. | ||
frame->CreateViewWithViewRef(std::move(view_tokens.view_token), | ||
std::move(view_ref_pair.control_ref), | ||
std::move(view_ref_pair.view_ref)); | ||
} |
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,18 @@ | ||
// 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 FUCHSIA_WEB_SHELL_PRESENT_FRAME_H_ | ||
#define FUCHSIA_WEB_SHELL_PRESENT_FRAME_H_ | ||
|
||
#include <fuchsia/element/cpp/fidl.h> | ||
#include <fuchsia/web/cpp/fidl.h> | ||
|
||
// Presents the given frame by setting up the necessary views, connecting to a | ||
// fuchsia view presentation protocol, and forwarding the given annotation | ||
// controller and annotations. | ||
void PresentFrame(fuchsia::web::Frame* frame, | ||
fidl::InterfaceHandle<fuchsia::element::AnnotationController> | ||
annotation_controller); | ||
|
||
#endif // FUCHSIA_WEB_SHELL_PRESENT_FRAME_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