Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fake_renderable.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_FAKE_RENDERABLE_H_
20 #define MIR_TEST_DOUBLES_FAKE_RENDERABLE_H_
21 
23 #define GLM_FORCE_RADIANS
24 #include <glm/gtc/matrix_transform.hpp>
25 #include <gmock/gmock.h>
26 
27 namespace mir
28 {
29 namespace test
30 {
31 namespace doubles
32 {
33 
35 {
36 public:
37  FakeRenderable(int x, int y, int width, int height,
38  float opacity=1.0f,
39  bool rectangular=true,
40  bool visible=true,
41  bool posted=true)
42  : rect{{x, y}, {width, height}},
43  opacity(opacity),
44  rectangular(rectangular),
45  visible_(visible),
46  posted(posted)
47  {
48  }
49 
50  float alpha() const override
51  {
52  return opacity;
53  }
54 
55  glm::mat4 transformation() const override
56  {
57  return glm::mat4();
58  }
59 
60  bool visible() const override
61  {
62  return visible_ && posted;
63  }
64 
65  bool shaped() const override
66  {
67  return !rectangular;
68  }
69 
70  void set_buffer(std::shared_ptr<graphics::Buffer> b)
71  {
72  buf = b;
73  }
74 
75  std::shared_ptr<graphics::Buffer> buffer(void const*) const override
76  {
77  return buf;
78  }
79 
80  bool alpha_enabled() const override
81  {
82  return shaped() || alpha() < 1.0f;
83  }
84 
86  {
87  return rect;
88  }
89 
90  int buffers_ready_for_compositor() const override
91  {
92  return 1;
93  }
94 
95 private:
96  std::shared_ptr<graphics::Buffer> buf;
98  float opacity;
99  bool rectangular;
100  bool visible_;
101  bool posted;
102 };
103 
104 } // namespace doubles
105 } // namespace test
106 } // namespace mir
107 #endif // MIR_TEST_DOUBLES_FAKE_RENDERABLE_H_
Definition: fake_renderable.h:34
bool shaped() const override
Definition: fake_renderable.h:65
float alpha() const override
Definition: fake_renderable.h:50
width
Definition: fake_renderable.h:42
Definition: dimensions.h:35
void set_buffer(std::shared_ptr< graphics::Buffer > b)
Definition: fake_renderable.h:70
FakeRenderable(int x, int y, int width, int height, float opacity=1.0f, bool rectangular=true, bool visible=true, bool posted=true)
Definition: fake_renderable.h:37
bool visible() const override
TODO: Its a bit questionable that we have this member function, why not just trim the renderable from...
Definition: fake_renderable.h:60
posted(posted)
Definition: fake_renderable.h:46
Definition: dimensions.h:35
Definition: renderable.h:33
height
Definition: fake_renderable.h:42
Definition: rectangle.h:33
std::shared_ptr< graphics::Buffer > buffer(void const *) const override
Return the next buffer that should be composited/rendered.
Definition: fake_renderable.h:75
int buffers_ready_for_compositor() const override
Definition: fake_renderable.h:90
geometry::Rectangle screen_position() const override
Definition: fake_renderable.h:85
bool alpha_enabled() const override
Definition: fake_renderable.h:80
glm::mat4 transformation() const override
Transformation returns the transformation matrix that should be applied to the surface.
Definition: fake_renderable.h:55

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Apr 11 21:14:53 UTC 2014