Mir

Code review comment for lp://staging/~vanvugt/mir/displaybuffer-transform

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

+ class Transformation : public glm::mat2
+ {
+ public:
+ bool is_null() const { return const_mat() == glm::mat2(); }
+ void reset() { mat() = glm::mat2(); }
+ void orient(MirOrientation ori)
+ {
+ int cos, sin;
+ switch (ori)
+ {
+ case mir_orientation_normal: sin = 0; cos = 1; break;
+ case mir_orientation_left: sin = 1; cos = 0; break;
+ case mir_orientation_inverted: sin = 0; cos = -1; break;
+ case mir_orientation_right: sin = -1; cos = 0; break;
+ }
+ mat() = glm::mat2(cos, sin, -sin, cos) * mat();
+ }
+ void mirror(MirMirrorMode mode)
+ {
+ int x = 1, y = 1;
+ if (mode == mir_mirror_mode_horizontal)
+ x = -1;
+ else if (mode == mir_mirror_mode_vertical)
+ y = -1;
+ mat() = glm::mat2(x, 0, 0, y) * mat();
+ }
+ private:
+ glm::mat2 const& const_mat() const { return *this; }
+ glm::mat2& mat() { return *this; }
+ };

Doesn't look like something that belongs in a public header file.

Mostly it seems replaceable by a free function:

auto transform_for(MirOrientation orientation) -> glm::mat2;

review: Needs Fixing

« Back to merge proposal