Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
stub_compositing_criteria.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
17  */
18 
19 #ifndef MIR_TEST_DOUBLES_STUB_COMPOSITING_CRITERIA_H_
20 #define MIR_TEST_DOUBLES_STUB_COMPOSITING_CRITERIA_H_
21 
23 #include <glm/gtc/matrix_transform.hpp>
24 #include <gmock/gmock.h>
25 
26 namespace mir
27 {
28 namespace test
29 {
30 namespace doubles
31 {
32 
34 {
35 public:
36  StubCompositingCriteria(int x, int y, int width, int height,
37  float opacity=1.0f,
38  bool rectangular=true,
39  bool visible=true,
40  bool posted=true)
41  : rect{{x, y}, {width, height}},
45  posted(posted)
46  {
47  const glm::mat4 ident;
48  glm::vec3 size(width, height, 0.0f);
49  glm::vec3 pos(x + width / 2, y + height / 2, 0.0f);
50  trans = glm::scale( glm::translate(ident, pos), size);
51  }
52 
53  float alpha() const override
54  {
55  return opacity;
56  }
57 
58  glm::mat4 const& transformation() const override
59  {
60  return trans;
61  }
62 
63  bool should_be_rendered_in(const mir::geometry::Rectangle &r) const override
64  {
65  return visible && posted && rect.overlaps(r);
66  }
67 
68  bool shaped() const override
69  {
70  return !rectangular;
71  }
72 
73 private:
75  glm::mat4 trans;
76  float opacity;
78  bool visible;
79  bool posted;
80 };
81 
82 } // namespace doubles
83 } // namespace test
84 } // namespace mir
85 #endif // MIR_TEST_DOUBLES_STUB_COMPOSITING_CRITERIA_H_

Copyright © 2012,2013 Canonical Ltd.
Generated on Wed Oct 30 18:52:19 UTC 2013