~ubuntu-branches/ubuntu/utopic/mir/utopic-proposed

« back to all changes in this revision

Viewing changes to src/platform/graphics/android/display_buffer.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2014-03-10 19:28:46 UTC
  • mto: This revision was merged to the branch mainline in revision 63.
  • Revision ID: package-import@ubuntu.com-20140310192846-rq9qm3ec26yrelo2
Tags: upstream-0.1.6+14.04.20140310
ImportĀ upstreamĀ versionĀ 0.1.6+14.04.20140310

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include <boost/throw_exception.hpp>
25
25
#include <stdexcept>
26
26
#include <algorithm>
 
27
#include <sstream>
27
28
 
28
29
namespace mg=mir::graphics;
29
30
namespace mga=mir::graphics::android;
38
39
      display_device{display_device},
39
40
      native_window{native_window},
40
41
      gl_context{shared_gl_context, std::bind(mga::create_window_surface, std::placeholders::_1, std::placeholders::_2, native_window.get())},
41
 
      rotation{mir_orientation_normal}
 
42
      current_configuration{
 
43
          mg::DisplayConfigurationOutputId{1},
 
44
          mg::DisplayConfigurationCardId{0},
 
45
          mg::DisplayConfigurationOutputType::lvds,
 
46
          {
 
47
              fb_bundle->fb_format()
 
48
          },
 
49
          {mg::DisplayConfigurationMode{fb_bundle->fb_size(),0.0f}},
 
50
          0,
 
51
          geom::Size{0,0}, //could use DPI information to fill this
 
52
          true,
 
53
          true,
 
54
          geom::Point{0,0},
 
55
          0,
 
56
          fb_bundle->fb_format(),
 
57
          mir_power_mode_on,
 
58
          mir_orientation_normal}
42
59
{
43
60
}
44
61
 
48
65
    int width = size.width.as_int();
49
66
    int height = size.height.as_int();
50
67
 
51
 
    if (rotation == mir_orientation_left || rotation == mir_orientation_right)
 
68
    if (current_configuration.orientation == mir_orientation_left
 
69
        || current_configuration.orientation == mir_orientation_right)
 
70
    {
52
71
        std::swap(width, height);
 
72
    }
53
73
 
54
74
    return {{0,0}, {width,height}};
55
75
}
111
131
     * and let the renderer do it.
112
132
     * If and when we choose to implement HWC rotation, this may change.
113
133
     */
114
 
    return rotation;
115
 
}
116
 
 
117
 
void mga::DisplayBuffer::orient(MirOrientation rot)
118
 
{
119
 
    rotation = rot;
 
134
    return current_configuration.orientation;
 
135
}
 
136
 
 
137
mg::DisplayConfigurationOutput mga::DisplayBuffer::configuration() const
 
138
{
 
139
    return mg::DisplayConfigurationOutput(current_configuration);
 
140
}
 
141
 
 
142
void mga::DisplayBuffer::configure(DisplayConfigurationOutput const& new_configuration)
 
143
{
 
144
    //power mode
 
145
    MirPowerMode intended_power_mode = new_configuration.power_mode;
 
146
    if ((intended_power_mode == mir_power_mode_standby) ||
 
147
        (intended_power_mode == mir_power_mode_suspend))
 
148
    {
 
149
        intended_power_mode = mir_power_mode_off;
 
150
    }
 
151
 
 
152
    if (intended_power_mode != current_configuration.power_mode)
 
153
    {
 
154
        display_device->mode(intended_power_mode);
 
155
        current_configuration.power_mode = intended_power_mode;
 
156
    }
 
157
 
 
158
    //If the hardware can rotate for us, we report normal orientation. If it can't
 
159
    //we preserve this orientation change so the compositor can rotate everything in GL 
 
160
    if (display_device->apply_orientation(new_configuration.orientation))
 
161
    {
 
162
        current_configuration.orientation = mir_orientation_normal;
 
163
    }
 
164
    else
 
165
    {
 
166
        current_configuration.orientation = new_configuration.orientation;
 
167
    }
 
168
 
 
169
    //do not allow fb format reallocation
 
170
    if (new_configuration.current_format != current_configuration.current_format)
 
171
    {
 
172
        std::stringstream err_msg; 
 
173
        err_msg << std::string("could not change display buffer format to request: ")
 
174
                << new_configuration.current_format;
 
175
        BOOST_THROW_EXCEPTION(std::runtime_error(err_msg.str()));
 
176
    }
120
177
}