~kdub/mir/mali-client-render-support

« back to all changes in this revision

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

  • Committer: Kevin DuBois
  • Date: 2013-11-05 21:44:14 UTC
  • mfrom: (1062.1.137 dev)
  • Revision ID: kevin.dubois@canonical.com-20131105214414-d32r52joqrs8tsmo
merge dev branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2012 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_DRIVER_INTERPRETER_H_
 
20
#define MIR_TEST_DOUBLES_STUB_DRIVER_INTERPRETER_H_
 
21
 
 
22
#include "mir/graphics/android/android_driver_interpreter.h"
 
23
 
 
24
namespace mir
 
25
{
 
26
namespace test
 
27
{
 
28
namespace doubles
 
29
{
 
30
 
 
31
class StubDriverInterpreter : public graphics::android::AndroidDriverInterpreter
 
32
{
 
33
public:
 
34
    StubDriverInterpreter(mir::geometry::Size sz, int visual_id)
 
35
     : sz{sz},
 
36
       visual_id{visual_id}
 
37
    {
 
38
    }
 
39
 
 
40
    StubDriverInterpreter()
 
41
     : StubDriverInterpreter(mir::geometry::Size{44,22}, 5)
 
42
    {
 
43
    }
 
44
 
 
45
    mir::graphics::NativeBuffer* driver_requests_buffer()
 
46
    {
 
47
        return nullptr;
 
48
    }
 
49
    void driver_returns_buffer(ANativeWindowBuffer*, int)
 
50
    {
 
51
    }
 
52
    void dispatch_driver_request_format(int) 
 
53
    {
 
54
    }
 
55
    int driver_requests_info(int index) const
 
56
    {
 
57
        if (index == NATIVE_WINDOW_WIDTH)
 
58
            return sz.width.as_uint32_t();
 
59
        if (index == NATIVE_WINDOW_HEIGHT)
 
60
            return sz.height.as_uint32_t();
 
61
        if (index == NATIVE_WINDOW_FORMAT)
 
62
            return visual_id;
 
63
        return 0;
 
64
    }
 
65
    void sync_to_display(bool)
 
66
    {
 
67
    }
 
68
private:
 
69
    mir::geometry::Size sz;
 
70
    int visual_id;
 
71
};
 
72
}
 
73
}
 
74
}
 
75
#endif /* MIR_TEST_DOUBLES_STUB_BUFFER_H_ */