exo: Fix issues with viewports and transforms
The crop rectangle is set via the Wayland interface in post-transform
buffer coordinates. To generate UV coordinates, the crop rectangle must
be transformed by the inverse transform.
The forward transformation from "buffer" pixel space to target space
also turned out to be incorrect when there was a crop, there was no
viewport, and the buffer transformation was 90 or 270. The construction
of that transformation matrix now makes sense, unlike before.
The fixed up code shares a common buffer transformation matrix (rotating
in normalized coordinates around 0.5, 0.5), but that is all that can be
shared. The two transformations otherwise apply different scaling and
translations to get to their respective coordinate spaces otherwise.
Correct functionality was verified with a test app that sets a crop
rectangle while also setting/disabling the viewport rectangle, while
cycling through buffers at different rotations. The test app was run on
Chrome OS as well as under the Weston reference implementation.
BUG=751232
Change-Id: Ibca12b6d722891076db4cb053d133d128ee78889
Reviewed-on: https://chromium-review.googlesource.com/653494
Commit-Queue: Lloyd Pique <[email protected]>
Reviewed-by: David Reveman <[email protected]>
Cr-Commit-Position: refs/heads/master@{#502440}
diff --git a/components/exo/surface.h b/components/exo/surface.h
index f73180b..76f72b5 100644
--- a/components/exo/surface.h
+++ b/components/exo/surface.h
@@ -23,6 +23,7 @@
#include "ui/aura/window.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/native_widget_types.h"
+#include "ui/gfx/transform.h"
namespace base {
namespace trace_event {
@@ -260,6 +261,9 @@
// will be called.
void UpdateResource(LayerTreeFrameSinkHolder* frame_sink_holder);
+ // Updates buffer_transform_ to match the current buffer parameters.
+ void UpdateBufferTransform();
+
// Puts the current surface into a draw quad, and appends the draw quads into
// the |frame|.
void AppendContentsToFrame(const gfx::Point& origin,
@@ -341,6 +345,10 @@
// This is true if UpdateResources() should be called.
bool needs_update_resource_ = true;
+ // The current buffer transform matrix. It specifies the transformation from
+ // normalized buffer coordinates to post-tranform buffer coordinates.
+ gfx::Transform buffer_transform_;
+
// This is set when the compositing starts and passed to active frame
// callbacks when compositing successfully ends.
base::TimeTicks last_compositing_start_time_;