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 { ...@@ -51,6 +51,12 @@ class VIZ_SERVICE_EXPORT OutputSurface {
kOpenGL = 1, kOpenGL = 1,
kVulkan = 2, 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 { struct Capabilities {
Capabilities(); Capabilities();
Capabilities(const Capabilities& capabilities); Capabilities(const Capabilities& capabilities);
...@@ -75,12 +81,8 @@ class VIZ_SERVICE_EXPORT OutputSurface { ...@@ -75,12 +81,8 @@ class VIZ_SERVICE_EXPORT OutputSurface {
bool supports_commit_overlay_planes = false; bool supports_commit_overlay_planes = false;
// Whether this OutputSurface supports gpu vsync callbacks. // Whether this OutputSurface supports gpu vsync callbacks.
bool supports_gpu_vsync = false; bool supports_gpu_vsync = false;
// Whether this OutputSurface supports pre transform. If it is supported, // OutputSurface's orientation mode.
// the chrome will set the output surface size in hardware natural OrientationMode orientation_mode = OrientationMode::kLogic;
// 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;
// Whether this OutputSurface supports direct composition layers. // Whether this OutputSurface supports direct composition layers.
bool supports_dc_layers = false; bool supports_dc_layers = false;
// Whether this OutputSurface should skip DrawAndSwap(). This is true for // Whether this OutputSurface should skip DrawAndSwap(). This is true for
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include <vector> #include <vector>
#include "base/command_line.h" #include "base/command_line.h"
#include "base/feature_list.h"
#include "build/build_config.h"
#include "components/viz/common/switches.h" #include "components/viz/common/switches.h"
#include "components/viz/service/display_embedder/skia_output_surface_dependency.h" #include "components/viz/service/display_embedder/skia_output_surface_dependency.h"
#include "gpu/command_buffer/common/capabilities.h" #include "gpu/command_buffer/common/capabilities.h"
...@@ -34,14 +36,19 @@ SkiaOutputDeviceBufferQueue::SkiaOutputDeviceBufferQueue( ...@@ -34,14 +36,19 @@ SkiaOutputDeviceBufferQueue::SkiaOutputDeviceBufferQueue(
capabilities_.preserve_buffer_content = true; capabilities_.preserve_buffer_content = true;
capabilities_.only_invalidates_damage_rect = false; capabilities_.only_invalidates_damage_rect = false;
capabilities_.number_of_buffers = 3; capabilities_.number_of_buffers = 3;
#if defined(OS_ANDROID)
// TODO(crbug.com/1110443): This ifdef was added to unblock SkiaRenderer GL on capabilities_.orientation_mode = OutputSurface::OrientationMode::kHardware;
// Chrome OS, but theoretically, this should be true across all buffer queue // With vulkan and android surface control, if the chrome is launched in
// platforms. Remove this ifdef once we verify that supports_pre_transform // landscape mode, the chrome is always blank until chrome window is rotated
// does not cause any regressions on Android. // once. Workaround this problem by using logic rotation mode.
#if defined(OS_CHROMEOS) // TODO(https://crbug.com/1115065): use hardware orientation mode for vulkan,
capabilities_.supports_pre_transform = true; if (dependency_->GetSharedContextState()->GrContextIsVulkan() &&
#endif // defined(OS_CHROMEOS) 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 // Force the number of max pending frames to one when the switch
// "double-buffer-compositing" is passed. // "double-buffer-compositing" is passed.
......
...@@ -291,7 +291,7 @@ bool SkiaOutputDeviceVulkan::Initialize() { ...@@ -291,7 +291,7 @@ bool SkiaOutputDeviceVulkan::Initialize() {
capabilities_.preserve_buffer_content = true; capabilities_.preserve_buffer_content = true;
capabilities_.output_surface_origin = gfx::SurfaceOrigin::kTopLeft; capabilities_.output_surface_origin = gfx::SurfaceOrigin::kTopLeft;
capabilities_.supports_post_sub_buffer = true; 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 // 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 // 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 // assigned to true, so |number_of_buffers| will not be used for tracking
......
...@@ -230,7 +230,7 @@ void SkiaOutputSurfaceImpl::Reshape(const gfx::Size& size, ...@@ -230,7 +230,7 @@ void SkiaOutputSurfaceImpl::Reshape(const gfx::Size& size,
auto task = base::BindOnce(&SkiaOutputSurfaceImplOnGpu::Reshape, auto task = base::BindOnce(&SkiaOutputSurfaceImplOnGpu::Reshape,
base::Unretained(impl_on_gpu_.get()), size, base::Unretained(impl_on_gpu_.get()), size,
device_scale_factor, color_space, format, device_scale_factor, color_space, format,
use_stencil, pre_transform_); use_stencil, GetDisplayTransform());
ScheduleGpuTask(std::move(task), {}); ScheduleGpuTask(std::move(task), {});
color_space_ = color_space; color_space_ = color_space;
...@@ -259,12 +259,18 @@ void SkiaOutputSurfaceImpl::SetGpuVSyncCallback(GpuVSyncCallback callback) { ...@@ -259,12 +259,18 @@ void SkiaOutputSurfaceImpl::SetGpuVSyncCallback(GpuVSyncCallback callback) {
void SkiaOutputSurfaceImpl::SetDisplayTransformHint( void SkiaOutputSurfaceImpl::SetDisplayTransformHint(
gfx::OverlayTransform transform) { gfx::OverlayTransform transform) {
if (capabilities_.supports_pre_transform) display_transform_ = transform;
pre_transform_ = transform;
} }
gfx::OverlayTransform SkiaOutputSurfaceImpl::GetDisplayTransform() { 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() { SkCanvas* SkiaOutputSurfaceImpl::BeginPaintCurrentFrame() {
......
...@@ -254,7 +254,7 @@ class VIZ_SERVICE_EXPORT SkiaOutputSurfaceImpl : public SkiaOutputSurface { ...@@ -254,7 +254,7 @@ class VIZ_SERVICE_EXPORT SkiaOutputSurfaceImpl : public SkiaOutputSurface {
// The display transform relative to the hardware natural orientation, // The display transform relative to the hardware natural orientation,
// applied to the frame content. The transform can be rotations in 90 degree // applied to the frame content. The transform can be rotations in 90 degree
// increments or flips. // 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 // |gpu_task_scheduler_| holds a gpu::SingleTaskSequence, and helps schedule
// tasks on GPU as a single sequence. It is shared with OverlayProcessor so // 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