~glmark2-dev/glmark2/cel-shading

« back to all changes in this revision

Viewing changes to src/native-state-drm.h

  • Committer: Alexandros Frantzis
  • Date: 2013-03-04 19:02:58 UTC
  • mfrom: (260.1.8 canvas-generic)
  • Revision ID: alexandros.frantzis@canonical.com-20130304190258-035q8mulveyi2ori
CanvasGeneric: Replace custom Canvases with a customizable generic Canvas

The generic Canvas is customized by initializing it with a NativeState
(X11,DRM...) and a GLState (EGL,GLX). This separation of concerns makes
it easier to support new display systems.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2012 Linaro Limited
 
3
 * Copyright © 2013 Canonical Ltd
 
4
 *
 
5
 * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
 
6
 *
 
7
 * glmark2 is free software: you can redistribute it and/or modify it under the
 
8
 * terms of the GNU General Public License as published by the Free Software
 
9
 * Foundation, either version 3 of the License, or (at your option) any later
 
10
 * version.
 
11
 *
 
12
 * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
 
13
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
14
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
15
 * details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License along with
 
18
 * glmark2.  If not, see <http://www.gnu.org/licenses/>.
 
19
 *
 
20
 * Authors:
 
21
 *  Simon Que 
 
22
 *  Jesse Barker
 
23
 *  Alexandros Frantzis
 
24
 */
 
25
#ifndef GLMARK2_NATIVE_STATE_DRM_H_
 
26
#define GLMARK2_NATIVE_STATE_DRM_H_
 
27
 
 
28
#include "native-state.h"
 
29
#include <cstring>
 
30
#include <gbm.h>
 
31
#include <drm.h>
 
32
#include <xf86drm.h>
 
33
#include <xf86drmMode.h>
 
34
 
 
35
class NativeStateDRM : public NativeState
 
36
{
 
37
public:
 
38
    NativeStateDRM() :
 
39
        fd_(0),
 
40
        resources_(0),
 
41
        connector_(0),
 
42
        encoder_(0),
 
43
        mode_(0),
 
44
        dev_(0),
 
45
        surface_(0),
 
46
        bo_(0),
 
47
        fb_(0),
 
48
        crtc_set_(false) {}
 
49
    ~NativeStateDRM() { cleanup(); }
 
50
 
 
51
    bool init_display();
 
52
    void* display();
 
53
    bool create_window(WindowProperties const& properties);
 
54
    void* window(WindowProperties& properties);
 
55
    void visible(bool v);
 
56
    bool should_quit();
 
57
    void flip();
 
58
 
 
59
private:
 
60
    struct DRMFBState
 
61
    {
 
62
        int fd;
 
63
        gbm_bo* bo;
 
64
        uint32_t fb_id;
 
65
    };
 
66
 
 
67
    static void page_flip_handler(int fd, unsigned int frame, unsigned int sec,
 
68
                                  unsigned int usec, void* data);
 
69
    static void fb_destroy_callback(gbm_bo* bo, void* data);
 
70
    static void quit_handler(int signum);
 
71
    static bool should_quit_;
 
72
 
 
73
    DRMFBState* fb_get_from_bo(gbm_bo* bo);
 
74
    bool init_gbm();
 
75
    bool init();
 
76
    void cleanup();
 
77
 
 
78
    int fd_;
 
79
    drmModeRes* resources_;
 
80
    drmModeConnector* connector_;
 
81
    drmModeEncoder* encoder_;
 
82
    drmModeCrtcPtr crtc_;
 
83
    drmModeModeInfo* mode_;
 
84
    gbm_device* dev_;
 
85
    gbm_surface* surface_;
 
86
    gbm_bo* bo_;
 
87
    DRMFBState* fb_;
 
88
    bool crtc_set_;
 
89
};
 
90
 
 
91
#endif /* GLMARK2_NATIVE_STATE_DRM_H_ */