~afrantzis/mir/offscreen-display-wip

« back to all changes in this revision

Viewing changes to include/test/mir_test_doubles/stub_display_buffer_factory.h

  • Committer: Tarmac
  • Author(s): Kevin DuBois
  • Date: 2013-11-06 10:43:44 UTC
  • mfrom: (1116.3.65 offscreen-display)
  • Revision ID: tarmac-20131106104344-624ikxb3cx98t25q
android: clean up mga::DisplayBuffer and mga::DisplayBufferFactory

Our construction of mga::Display was not suitable for android multimonitor, plus our tests in this area were tangled.

Approved by Alan Griffiths, Alexandros Frantzis, Daniel van Vugt, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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: Kevin DuBois <kevin.dubois@canonical.com>
 
17
 */
 
18
 
 
19
#ifndef MIR_TEST_DOUBLES_STUB_DISPLAY_BUFFER_FACTORY_H_
 
20
#define MIR_TEST_DOUBLES_STUB_DISPLAY_BUFFER_FACTORY_H_
 
21
 
 
22
#include "src/server/graphics/android/android_display_buffer_factory.h"
 
23
#include "stub_display_buffer.h"
 
24
#include "stub_display_device.h"
 
25
#include <gmock/gmock.h>
 
26
 
 
27
namespace mir
 
28
{
 
29
namespace test
 
30
{
 
31
namespace doubles
 
32
{
 
33
struct StubDisplayBufferFactory : public graphics::android::AndroidDisplayBufferFactory
 
34
{
 
35
    StubDisplayBufferFactory(std::shared_ptr<graphics::android::DisplayDevice> const& stub_dev, geometry::Size sz)
 
36
        : stub_dev(stub_dev), sz(sz)
 
37
    {
 
38
    }
 
39
 
 
40
    StubDisplayBufferFactory()
 
41
        : StubDisplayBufferFactory(std::make_shared<StubDisplayDevice>(), geometry::Size{0,0})
 
42
    {
 
43
    }
 
44
 
 
45
    StubDisplayBufferFactory(geometry::Size sz)
 
46
        : StubDisplayBufferFactory(std::make_shared<StubDisplayDevice>(), sz)
 
47
    {
 
48
    }
 
49
 
 
50
    StubDisplayBufferFactory(std::shared_ptr<graphics::android::DisplayDevice> const& stub_dev)
 
51
        : stub_dev(stub_dev), sz(geometry::Size{0,0})
 
52
    {
 
53
    }
 
54
 
 
55
    std::unique_ptr<graphics::DisplayBuffer> create_display_buffer(
 
56
        std::shared_ptr<graphics::android::DisplayDevice> const&,
 
57
        EGLDisplay, EGLConfig, EGLContext)
 
58
    {
 
59
        return std::unique_ptr<graphics::DisplayBuffer>(
 
60
                new StubDisplayBuffer(geometry::Rectangle{{0,0},sz}));
 
61
    }
 
62
    
 
63
    std::shared_ptr<graphics::android::DisplayDevice> create_display_device()
 
64
    {
 
65
        return stub_dev;
 
66
    }
 
67
 
 
68
    std::shared_ptr<graphics::android::DisplayDevice> const stub_dev;
 
69
    geometry::Size sz;
 
70
};
 
71
}
 
72
}
 
73
} // namespace mir
 
74
 
 
75
#endif /* MIR_TEST_DOUBLES_STUB_DISPLAY_BUFFER_FACTORY_H_ */