~vanvugt/mir/vbox

« back to all changes in this revision

Viewing changes to tests/acceptance-tests/staging/test_buffer_stream_arrangement.cpp

  • Committer: Tarmac
  • Author(s): Kevin DuBois
  • Date: 2016-11-01 16:49:08 UTC
  • mfrom: (3789.3.9 sizing-clarifications)
  • Revision ID: tarmac-20161101164908-7i53del1c0bpa2wd
api: add the ability to set and get the the physical size of MirBufferStream. Also add a distinction between the physical and logical size to the staged api, mir_surface_spec_add_buffer_stream. 

Previously, the physical and logical sizes were fixed (at steady state, they were the same. around resize events, the physical size would vary before reaching steady-state, and cause headaches). This cleans things up as per the friday discussion.

Note: mir_surface_spec_add_buffer_stream and mir_surface_spec_add_presentation_chain are currently gated, and will be removed in favor of mir_surface_spec_add_render_surface when RS work is published. mir_surface_spec_set_buffer_streams will be deprecated and removed.

Approved by mir-ci-bot, Cemil Azizoglu, Chris Halse Rogers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2015 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: Kevin DuBois <kevin.dubois@canonical.com>
 
17
 */
 
18
 
 
19
#include "../buffer_stream_arrangement.h"
 
20
#include "mir_toolkit/mir_presentation_chain.h"
 
21
#include <gmock/gmock.h>
 
22
 
 
23
namespace mt = mir::test;
 
24
namespace geom = mir::geometry;
 
25
using namespace std::literals::chrono_literals;
 
26
using namespace testing;
 
27
 
 
28
typedef mt::BufferStreamArrangementBase BufferStreamArrangementStaging;
 
29
TEST_F(BufferStreamArrangementStaging, can_set_stream_logical_and_physical_size)
 
30
{
 
31
    geom::Size logical_size { 233, 111 };
 
32
    geom::Size physical_size { 133, 222 };
 
33
    mt::Stream stream(connection, physical_size, { {0, 0}, logical_size } );
 
34
 
 
35
    auto change_spec = mir_connection_create_spec_for_changes(connection);
 
36
    mir_surface_spec_add_buffer_stream(change_spec, 0, 0, logical_size.width.as_int(), logical_size.height.as_int(), stream.handle());
 
37
    mir_surface_apply_spec(surface, change_spec);
 
38
    mir_surface_spec_release(change_spec);
 
39
 
 
40
    std::vector<mt::RelativeRectangle> positions { { {0,0}, logical_size, physical_size } };
 
41
    EXPECT_TRUE(ordering->wait_for_positions_within(positions, 5s))
 
42
         << "timed out waiting to see the compositor post the streams in the right arrangement";
 
43
}
 
44
 
 
45
TEST_F(BufferStreamArrangementStaging, can_setting_stream_physical_size_doesnt_affect_logical)
 
46
{
 
47
    geom::Size logical_size { 233, 111 };
 
48
    geom::Size original_physical_size { 133, 222 };
 
49
    geom::Size changed_physical_size { 133, 222 };
 
50
    mt::Stream stream(connection, original_physical_size, { {0, 0}, logical_size } );
 
51
 
 
52
    auto change_spec = mir_connection_create_spec_for_changes(connection);
 
53
    mir_surface_spec_add_buffer_stream(change_spec, 0, 0, logical_size.width.as_int(), logical_size.height.as_int(), stream.handle());
 
54
    mir_surface_apply_spec(surface, change_spec);
 
55
    mir_surface_spec_release(change_spec);
 
56
 
 
57
    stream.set_size(changed_physical_size);
 
58
    //submits the original_buffer_size buffer, getting changed_physical_size buffer as current
 
59
    stream.swap_buffers();
 
60
    //submits the changed_buffer_size buffer so server can see
 
61
    stream.swap_buffers();
 
62
 
 
63
    std::vector<mt::RelativeRectangle> positions { { {0,0}, logical_size, changed_physical_size } };
 
64
    EXPECT_TRUE(ordering->wait_for_positions_within(positions, 5s))
 
65
         << "timed out waiting to see the compositor post the streams in the right arrangement";
 
66
}
 
67
 
 
68
TEST_F(BufferStreamArrangementStaging, stream_size_reflects_current_buffer_physical_size)
 
69
{
 
70
    geom::Size logical_size { 233, 111 };
 
71
    geom::Size original_physical_size { 133, 222 };
 
72
    geom::Size changed_physical_size { 133, 222 };
 
73
    mt::Stream stream(connection, original_physical_size, { {0, 0}, logical_size } );
 
74
 
 
75
    auto change_spec = mir_connection_create_spec_for_changes(connection);
 
76
    mir_surface_spec_add_buffer_stream(change_spec, 0, 0, logical_size.width.as_int(), logical_size.height.as_int(), stream.handle());
 
77
    mir_surface_apply_spec(surface, change_spec);
 
78
    mir_surface_spec_release(change_spec);
 
79
 
 
80
    EXPECT_THAT(stream.physical_size(), Eq(original_physical_size));
 
81
    streams.back()->set_size(changed_physical_size);
 
82
    EXPECT_THAT(stream.physical_size(), Eq(changed_physical_size));
 
83
    streams.back()->swap_buffers();
 
84
    EXPECT_THAT(stream.physical_size(), Eq(changed_physical_size));
 
85
}