Skip to content

Commit

Permalink
Revert "Reland "display: Deduplicate display transform code with over…
Browse files Browse the repository at this point in the history
…lay transform code""

This reverts commit 0e7d45d.

Reason for revert: reland bypassed cq unintentionaly, more missing #includes

Original change's description:
> Reland "display: Deduplicate display transform code with overlay transform code"
> 
> This reverts commit cf6bd85.
> 
> Reason for revert: added missing #include
> 
> Original change's description:
> > Revert "display: Deduplicate display transform code with overlay transform code"
> > 
> > This reverts commit 4430b4c.
> > 
> > Reason for revert: Possible cause of this failure: https://ci.chromium.org/p/chromium/builders/ci/GPU%20Mac%20Builder/173997
> > 
> > Original change's description:
> > > display: Deduplicate display transform code with overlay transform code
> > > 
> > > Display rotation transforms are a subset of overlay transforms, so we can
> > > reuse OverlayTransformToTransform to compute display rotation matrices.
> > > 
> > > Bug: 1019015
> > > 
> > > Change-Id: I95d099323cb866ccc4b9cea404e1e6f8f2dfff65
> > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1913604
> > > Commit-Queue: Michael Spang <spang@chromium.org>
> > > Reviewed-by: Khushal <khushalsagar@chromium.org>
> > > Reviewed-by: Ken Buchanan <kenrb@chromium.org>
> > > Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org>
> > > Reviewed-by: Mitsuru Oshima (OOO - back on Dec 2nd) <oshima@chromium.org>
> > > Cr-Commit-Position: refs/heads/master@{#717832}
> > 
> > TBR=oshima@chromium.org,kenrb@chromium.org,spang@chromium.org,khushalsagar@chromium.org
> > 
> > Change-Id: I2757890a784f97adf30776c2b418fba2574f1759
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: 1019015
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1928380
> > Reviewed-by: Darren Shen <shend@chromium.org>
> > Commit-Queue: Darren Shen <shend@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#717846}
> 
> TBR=oshima@chromium.org,kenrb@chromium.org,spang@chromium.org,khushalsagar@chromium.org,shend@chromium.org
> 
> Change-Id: I8988120b1dd114fdc0f5e0d515b9fb90ffe3cbb5
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 1019015
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1931159
> Reviewed-by: Michael Spang <spang@chromium.org>
> Commit-Queue: Michael Spang <spang@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#718220}

TBR=oshima@chromium.org,kenrb@chromium.org,spang@chromium.org,khushalsagar@chromium.org,shend@chromium.org

Change-Id: I7fb92732ed342f1e6b7922e96faa77d69835335d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1019015
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1931129
Reviewed-by: Michael Spang <spang@chromium.org>
Commit-Queue: Michael Spang <spang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718226}
  • Loading branch information
mspang authored and Commit Bot committed Nov 22, 2019
1 parent 869cf72 commit e9ab1de
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 94 deletions.
4 changes: 2 additions & 2 deletions ash/display/window_tree_host_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "ash/shell_state.h"
#include "ash/system/status_area_widget.h"
#include "ash/system/unified/unified_system_tray.h"
#include "ash/utility/transformer_util.h"
#include "ash/wm/window_util.h"
#include "base/command_line.h"
#include "base/metrics/histogram.h"
Expand All @@ -47,7 +48,6 @@
#include "ui/compositor/compositor_switches.h"
#include "ui/display/display.h"
#include "ui/display/display_layout.h"
#include "ui/display/display_transform.h"
#include "ui/display/manager/display_configurator.h"
#include "ui/display/manager/display_layout_store.h"
#include "ui/display/manager/display_manager.h"
Expand Down Expand Up @@ -86,7 +86,7 @@ void SetDisplayPropertiesOnHost(AshWindowTreeHost* ash_host,
ash_host->SetRootWindowTransformer(std::move(transformer));

host->SetDisplayTransformHint(
display::DisplayRotationToOverlayTransform(effective_rotation));
DisplayRotationToOverlayTransform(effective_rotation));

// Just moving the display requires the full redraw.
// chrome-os-partner:33558.
Expand Down
22 changes: 20 additions & 2 deletions ash/utility/transformer_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <cmath>

#include "ui/display/display_transform.h"
#include "third_party/skia/include/core/SkMatrix44.h"
#include "ui/gfx/geometry/size_f.h"
#include "ui/gfx/transform.h"

Expand All @@ -26,8 +26,26 @@ display::Display::Rotation RotationBetween(
gfx::Transform CreateRotationTransform(display::Display::Rotation old_rotation,
display::Display::Rotation new_rotation,
const gfx::SizeF& size_to_rotate) {
return display::CreateRotationTransform(
gfx::Transform transform = display::Display::GetRotationTransform(
RotationBetween(old_rotation, new_rotation), size_to_rotate);

return transform;
}

gfx::OverlayTransform DisplayRotationToOverlayTransform(
display::Display::Rotation rotation) {
switch (rotation) {
case display::Display::ROTATE_0:
return gfx::OVERLAY_TRANSFORM_NONE;
case display::Display::ROTATE_90:
return gfx::OVERLAY_TRANSFORM_ROTATE_90;
case display::Display::ROTATE_180:
return gfx::OVERLAY_TRANSFORM_ROTATE_180;
case display::Display::ROTATE_270:
return gfx::OVERLAY_TRANSFORM_ROTATE_270;
}
NOTREACHED();
return gfx::OVERLAY_TRANSFORM_NONE;
}

} // namespace ash
5 changes: 5 additions & 0 deletions ash/utility/transformer_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "ash/ash_export.h"
#include "ui/display/display.h"
#include "ui/gfx/overlay_transform.h"

namespace gfx {
class SizeF;
Expand All @@ -22,6 +23,10 @@ ASH_EXPORT gfx::Transform CreateRotationTransform(
display::Display::Rotation new_rotation,
const gfx::SizeF& size_to_rotate);

// Maps display::Display::Rotation to gfx::OverlayTransform.
ASH_EXPORT gfx::OverlayTransform DisplayRotationToOverlayTransform(
display::Display::Rotation rotation);

} // namespace ash

#endif // ASH_TRANSFORMER_UTIL_H_
5 changes: 2 additions & 3 deletions chromecast/graphics/cast_window_manager_aura.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "ui/base/ime/init/input_method_factory.h"
#include "ui/base/ime/input_method.h"
#include "ui/display/display.h"
#include "ui/display/display_transform.h"
#include "ui/display/screen.h"
#include "ui/ozone/public/ozone_platform.h"
#include "ui/platform_window/platform_window_init_properties.h"
Expand All @@ -40,8 +39,8 @@ namespace {

gfx::Transform GetPrimaryDisplayRotationTransform() {
display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay();
return display::CreateRotationTransform(display.rotation(),
gfx::SizeF(display.size()));
return display::Display::GetRotationTransform(display.rotation(),
gfx::SizeF(display.size()));
}

gfx::Rect GetPrimaryDisplayHostBounds() {
Expand Down
32 changes: 29 additions & 3 deletions content/browser/renderer_host/compositor_impl_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
#include "third_party/skia/include/core/SkMallocPixelRef.h"
#include "ui/android/window_android.h"
#include "ui/display/display.h"
#include "ui/display/display_transform.h"
#include "ui/display/screen.h"
#include "ui/gfx/ca_layer_params.h"
#include "ui/gfx/swap_result.h"
Expand All @@ -96,6 +95,33 @@ NOINLINE void FatalSurfaceFailure() {
LOG(FATAL) << "Fatal surface initialization failure";
}

gfx::OverlayTransform RotationToDisplayTransform(
display::Display::Rotation rotation) {
// Note that the angle provided by |rotation| here is the opposite direction
// of the physical rotation of the device, which is the space in which the UI
// prepares the scene (see
// https://developer.android.com/reference/android/view/Display#getRotation()
// for details).
//
// The rotation which needs to be applied by the display compositor to allow
// the buffers produced by it to be used directly by the system compositor
// needs to be the inverse of this rotation. Since display::Rotation is in
// clockwise direction while gfx::OverlayTransform is anti-clockwise, directly
// mapping them below performs this inversion.
switch (rotation) {
case display::Display::ROTATE_0:
return gfx::OVERLAY_TRANSFORM_NONE;
case display::Display::ROTATE_90:
return gfx::OVERLAY_TRANSFORM_ROTATE_90;
case display::Display::ROTATE_180:
return gfx::OVERLAY_TRANSFORM_ROTATE_180;
case display::Display::ROTATE_270:
return gfx::OVERLAY_TRANSFORM_ROTATE_270;
}
NOTREACHED();
return gfx::OVERLAY_TRANSFORM_NONE;
}

gpu::SharedMemoryLimits GetCompositorContextSharedMemoryLimits(
gfx::NativeWindow window) {
const gfx::Size screen_size = display::Screen::GetScreen()
Expand Down Expand Up @@ -748,7 +774,7 @@ void CompositorImpl::OnDisplayMetricsChanged(const display::Display& display,
display::DisplayObserver::DisplayMetric::DISPLAY_METRIC_ROTATION) &&
display_private_) {
display_private_->SetDisplayTransformHint(
display::DisplayRotationToOverlayTransform(display.rotation()));
RotationToDisplayTransform(display.rotation()));
}
}

Expand Down Expand Up @@ -853,7 +879,7 @@ void CompositorImpl::InitializeVizLayerTreeFrameSink(
display_private_->SetSupportedRefreshRates(
root_window_->GetSupportedRefreshRates());
display_private_->SetDisplayTransformHint(
display::DisplayRotationToOverlayTransform(display_props.rotation()));
RotationToDisplayTransform(display_props.rotation()));
}

viz::LocalSurfaceIdAllocation CompositorImpl::GenerateLocalSurfaceId() {
Expand Down
5 changes: 2 additions & 3 deletions ui/aura/test/test_screen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/ime/input_method.h"
#include "ui/display/display_transform.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/native_widget_types.h"
Expand Down Expand Up @@ -118,8 +117,8 @@ void TestScreen::SetWorkAreaInsets(const gfx::Insets& insets) {

gfx::Transform TestScreen::GetRotationTransform() const {
display::Display display = GetPrimaryDisplay();
return display::CreateRotationTransform(display.rotation(),
gfx::SizeF(display.size()));
return display::Display::GetRotationTransform(display.rotation(),
gfx::SizeF(display.size()));
}

gfx::Transform TestScreen::GetUIScaleTransform() const {
Expand Down
2 changes: 0 additions & 2 deletions ui/display/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ jumbo_component("display") {
"display_observer.h",
"display_switches.cc",
"display_switches.h",
"display_transform.cc",
"display_transform.h",
"ios/screen_ios.mm",
"mac/display_link_mac.cc",
"mac/display_link_mac.h",
Expand Down
28 changes: 28 additions & 0 deletions ui/display/display.cc
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,34 @@ int Display::PanelRotationAsDegree() const {
return RotationToDegrees(panel_rotation_);
}

// static
gfx::Transform Display::GetRotationTransform(Rotation rotation,
const gfx::SizeF& size) {
// NB: Using gfx::Transform::Rotate() introduces very small errors here
// which are later exacerbated by use of gfx::EnclosingRect() in
// WindowTreeHost::GetTransformedRootWindowBoundsInPixels().
const gfx::Transform rotate_90(0.f, -1.f, 0.f, 0.f, //
1.f, 0.f, 0.f, 0.f, //
0.f, 0.f, 1.f, 0.f, //
0.f, 0.f, 0.f, 1.f);
const gfx::Transform rotate_180 = rotate_90 * rotate_90;
const gfx::Transform rotate_270 = rotate_180 * rotate_90;
gfx::Transform translation;
switch (rotation) {
case display::Display::ROTATE_0:
return translation;
case display::Display::ROTATE_90:
translation.Translate(size.height(), 0);
return translation * rotate_90;
case display::Display::ROTATE_180:
translation.Translate(size.width(), size.height());
return translation * rotate_180;
case display::Display::ROTATE_270:
translation.Translate(0, size.width());
return translation * rotate_270;
}
}

gfx::Insets Display::GetWorkAreaInsets() const {
return gfx::Insets(work_area_.y() - bounds_.y(), work_area_.x() - bounds_.x(),
bounds_.bottom() - work_area_.bottom(),
Expand Down
7 changes: 7 additions & 0 deletions ui/display/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "ui/display/types/display_constants.h"
#include "ui/gfx/color_space.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size_f.h"
#include "ui/gfx/transform.h"

namespace display {

Expand Down Expand Up @@ -165,6 +167,11 @@ class DISPLAY_EXPORT Display final {
void set_panel_rotation(Rotation rotation) { panel_rotation_ = rotation; }
int PanelRotationAsDegree() const;

// Returns an exact matrix representation of the transform that corrects for
// the display's rotation.
static gfx::Transform GetRotationTransform(Rotation rotation,
const gfx::SizeF& size);

TouchSupport touch_support() const { return touch_support_; }
void set_touch_support(TouchSupport support) { touch_support_ = support; }

Expand Down
44 changes: 0 additions & 44 deletions ui/display/display_transform.cc

This file was deleted.

30 changes: 0 additions & 30 deletions ui/display/display_transform.h

This file was deleted.

5 changes: 0 additions & 5 deletions ui/gfx/OWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ per-file screen*=oshima@chromium.org
# Canvas painting.
per-file canvas*=danakj@chromium.org

# Overlay transforms.
per-file overlay*=alexst@chromium.org
per-file overlay*=khushalsagar@chromium.org
per-file overlay*=spang@chromium.org

# Transform, interpolated transform and transform util.
per-file transform*=danakj@chromium.org
per-file transform*=vollick@chromium.org
Expand Down

0 comments on commit e9ab1de

Please sign in to comment.