Commit b11d0c34 authored by Peng Huang's avatar Peng Huang Committed by Commit Bot

Use hardware rotation for SkiaRenderer + SkiaOutputDeviceBufferQueue

For Android Surface control, we only use hardware rotation for GL, but
not vulkan, because a surface control bug.

Bug: 1110443
Change-Id: Iee26f1e86161a6122de2603049fd3a3d664b4ac0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2324499Reviewed-by: default avatarVasiliy Telezhnikov <vasilyt@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796917}
parent 82175cbd
......@@ -51,6 +51,12 @@ class VIZ_SERVICE_EXPORT OutputSurface {
kOpenGL = 1,
kVulkan = 2,
};
enum class OrientationMode {
kLogic, // The orientation same to logical screen orientation as seen by
// the user.
kHardware, // The orientation same to the hardware.
};
struct Capabilities {
Capabilities();
Capabilities(const Capabilities& capabilities);
......@@ -75,12 +81,8 @@ class VIZ_SERVICE_EXPORT OutputSurface {
bool supports_commit_overlay_planes = false;
// Whether this OutputSurface supports gpu vsync callbacks.
bool supports_gpu_vsync = false;
// Whether this OutputSurface supports pre transform. If it is supported,
// the chrome will set the output surface size in hardware natural
// orientation, and will render transformed content on back buffers based
// on the current system transform. So the OS presentation engine can
// present buffers onto the screen directly.
bool supports_pre_transform = false;
// OutputSurface's orientation mode.
OrientationMode orientation_mode = OrientationMode::kLogic;
// Whether this OutputSurface supports direct composition layers.
bool supports_dc_layers = false;
// Whether this OutputSurface should skip DrawAndSwap(). This is true for
......
......@@ -9,6 +9,8 @@
#include <vector>
#include "base/command_line.h"
#include "base/feature_list.h"
#include "build/build_config.h"
#include "components/viz/common/switches.h"
#include "components/viz/service/display_embedder/skia_output_surface_dependency.h"
#include "gpu/command_buffer/common/capabilities.h"
......@@ -34,14 +36,19 @@ SkiaOutputDeviceBufferQueue::SkiaOutputDeviceBufferQueue(
capabilities_.preserve_buffer_content = true;
capabilities_.only_invalidates_damage_rect = false;
capabilities_.number_of_buffers = 3;
// TODO(crbug.com/1110443): This ifdef was added to unblock SkiaRenderer GL on
// Chrome OS, but theoretically, this should be true across all buffer queue
// platforms. Remove this ifdef once we verify that supports_pre_transform
// does not cause any regressions on Android.
#if defined(OS_CHROMEOS)
capabilities_.supports_pre_transform = true;
#endif // defined(OS_CHROMEOS)
#if defined(OS_ANDROID)
capabilities_.orientation_mode = OutputSurface::OrientationMode::kHardware;
// With vulkan and android surface control, if the chrome is launched in
// landscape mode, the chrome is always blank until chrome window is rotated
// once. Workaround this problem by using logic rotation mode.
// TODO(https://crbug.com/1115065): use hardware orientation mode for vulkan,
if (dependency_->GetSharedContextState()->GrContextIsVulkan() &&
base::FeatureList::GetFieldTrial(features::kVulkan)) {
capabilities_.orientation_mode = OutputSurface::OrientationMode::kLogic;
}
#else
capabilities_.orientation_mode = OutputSurface::OrientationMode::kHardware;
#endif
// Force the number of max pending frames to one when the switch
// "double-buffer-compositing" is passed.
......
......@@ -291,7 +291,7 @@ bool SkiaOutputDeviceVulkan::Initialize() {
capabilities_.preserve_buffer_content = true;
capabilities_.output_surface_origin = gfx::SurfaceOrigin::kTopLeft;
capabilities_.supports_post_sub_buffer = true;
capabilities_.supports_pre_transform = true;
capabilities_.orientation_mode = OutputSurface::OrientationMode::kHardware;
// We don't know the number of buffers until the VulkanSwapChain is
// initialized, so set it to 0. Since |damage_area_from_skia_output_device| is
// assigned to true, so |number_of_buffers| will not be used for tracking
......
......@@ -230,7 +230,7 @@ void SkiaOutputSurfaceImpl::Reshape(const gfx::Size& size,
auto task = base::BindOnce(&SkiaOutputSurfaceImplOnGpu::Reshape,
base::Unretained(impl_on_gpu_.get()), size,
device_scale_factor, color_space, format,
use_stencil, pre_transform_);
use_stencil, GetDisplayTransform());
ScheduleGpuTask(std::move(task), {});
color_space_ = color_space;
......@@ -259,12 +259,18 @@ void SkiaOutputSurfaceImpl::SetGpuVSyncCallback(GpuVSyncCallback callback) {
void SkiaOutputSurfaceImpl::SetDisplayTransformHint(
gfx::OverlayTransform transform) {
if (capabilities_.supports_pre_transform)
pre_transform_ = transform;
display_transform_ = transform;
}
gfx::OverlayTransform SkiaOutputSurfaceImpl::GetDisplayTransform() {
return pre_transform_;
switch (capabilities_.orientation_mode) {
case OutputSurface::OrientationMode::kLogic:
return gfx::OverlayTransform::OVERLAY_TRANSFORM_NONE;
case OutputSurface::OrientationMode::kHardware:
return display_transform_;
default:
NOTREACHED();
}
}
SkCanvas* SkiaOutputSurfaceImpl::BeginPaintCurrentFrame() {
......
......@@ -254,7 +254,7 @@ class VIZ_SERVICE_EXPORT SkiaOutputSurfaceImpl : public SkiaOutputSurface {
// The display transform relative to the hardware natural orientation,
// applied to the frame content. The transform can be rotations in 90 degree
// increments or flips.
gfx::OverlayTransform pre_transform_ = gfx::OVERLAY_TRANSFORM_NONE;
gfx::OverlayTransform display_transform_ = gfx::OVERLAY_TRANSFORM_NONE;
// |gpu_task_scheduler_| holds a gpu::SingleTaskSequence, and helps schedule
// tasks on GPU as a single sequence. It is shared with OverlayProcessor so
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment