Subversion Repositories Kolibri OS

Rev

Rev 4517 | Rev 4525 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4517 Rev 4523
Line 1... Line 1...
1
#include 
1
#include 
2
#include 
2
#include 
3
#include 
3
#include 
Line 4... Line 4...
4
 
4
 
-
 
5
#include "render.h"
5
#include "render.h"
6
#include 
Line -... Line 7...
-
 
7
#include 
-
 
8
 
-
 
9
static int drm_ioctl(int fd, unsigned long request, void *arg)
-
 
10
{
-
 
11
    ioctl_t  io;
-
 
12
 
-
 
13
    io.handle   = fd;
-
 
14
    io.io_code  = request;
-
 
15
    io.input    = arg;
-
 
16
    io.inp_size = 64;
-
 
17
    io.output   = NULL;
-
 
18
    io.out_size = 0;
-
 
19
 
-
 
20
    return call_service(&io);
6
#include 
21
}
7
 
22
 
8
void render_swap_and_blit(struct render *render)
23
void render_swap_and_blit(struct render *render)
-
 
24
{
Line 9... Line 25...
9
{
25
    char proc_info[1024];
10
    char proc_info[1024];
26
    struct drm_i915_mask_update update;
11
 
27
 
Line 12... Line 28...
12
    EGLContext context;
28
    EGLContext context;
13
    EGLSurface draw, read;
29
    EGLSurface draw, read;
14
    int winx, winy;
30
    int winx, winy, winw, winh;
15
 
31
 
Line 16... Line 32...
16
    float dst_xscale, dst_yscale;
32
    float xscale, yscale;
17
    float *vertices  = render->vertices;
33
    float *vertices  = render->vertices;
Line 18... Line 34...
18
    float *texcoords = render->texcoords;
34
    float *texcoords = render->tc_src;
Line 19... Line 35...
19
    int r, b;
35
    int r, b;
20
 
36
 
-
 
37
    if(render == NULL)
-
 
38
        return;
Line 21... Line 39...
21
    if(render == NULL)
39
 
22
        return;
40
    get_proc_info(proc_info);
23
 
41
 
Line 48... Line 66...
48
    glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float),render->texcoords);
66
    glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float),render->texcoords);
49
    glEnableVertexAttribArray(1);
67
    glEnableVertexAttribArray(1);
Line 50... Line 68...
50
 
68
 
Line -... Line 69...
-
 
69
#endif
-
 
70
 
-
 
71
    update.handle = render->mask_handle;
-
 
72
    update.bo_map = (int)render->mask_buffer;
51
#endif
73
    drm_ioctl(render->fd, SRV_MASK_UPDATE, &update);
52
 
74
 
53
    glActiveTexture(GL_TEXTURE0);
75
    glActiveTexture(GL_TEXTURE0);
54
    glBindTexture(GL_TEXTURE_2D, render->tx_buffers[render->back_buffer]);
76
    glBindTexture(GL_TEXTURE_2D, render->tx_buffers[render->back_buffer]);
55
    glTexParameteri(GL_TEXTURE_2D,
77
    glTexParameteri(GL_TEXTURE_2D,
56
                  GL_TEXTURE_MIN_FILTER,
78
                  GL_TEXTURE_MIN_FILTER,
57
                  GL_NEAREST);
79
                  GL_NEAREST);
58
    glTexParameteri(GL_TEXTURE_2D,
80
    glTexParameteri(GL_TEXTURE_2D,
Line -... Line 81...
-
 
81
                  GL_TEXTURE_MAG_FILTER,
59
                  GL_TEXTURE_MAG_FILTER,
82
                  GL_NEAREST);
60
                  GL_NEAREST);
83
 
Line 61... Line 84...
61
 
84
 
62
    dst_xscale = 1.0/render->scr_width;
85
    xscale = 1.0/render->scr_width;
Line 63... Line 86...
63
    dst_yscale = 1.0/render->scr_height;
86
    yscale = 1.0/render->scr_height;
Line 64... Line 87...
64
 
87
 
65
    r = winx + render->dx + render->width;
88
    r = winx + render->dx + render->width;
Line 66... Line 89...
66
    b = winy + render->dy + render->height;
89
    b = winy + render->dy + render->height;
67
 
90
 
Line 68... Line 91...
68
    float t0, t1, t2, t5;
91
    float t0, t1, t2, t5;
69
 
92
 
70
    vertices[0]     = t0 = 2*(winx+render->dx)*dst_xscale - 1.0;
93
    vertices[0]     = t0 = 2*(winx+render->dx)*xscale - 1.0;
71
    vertices[1 * 2] = t2 = 2*r*dst_xscale - 1.0;
94
    vertices[1 * 2] = t2 = 2*r*xscale - 1.0;
Line 72... Line 95...
72
 
95
 
73
    vertices[2 * 2] = t2;
96
    vertices[2 * 2] = t2;
Line 85... Line 108...
85
    texcoords[2*2]  = 1.0;
108
    texcoords[2*2]  = 1.0;
86
    texcoords[2*2+1]= 1.0;
109
    texcoords[2*2+1]= 1.0;
87
    texcoords[3*2]  = 0.0;
110
    texcoords[3*2]  = 0.0;
88
    texcoords[3*2+1]= 1.0;
111
    texcoords[3*2+1]= 1.0;
Line -... Line 112...
-
 
112
 
-
 
113
    texcoords = render->tc_mask;
-
 
114
 
-
 
115
    xscale = 1.0/winw;
-
 
116
    yscale = 1.0/winh;
-
 
117
 
-
 
118
    texcoords[0]    = render->dx * xscale;
-
 
119
    texcoords[1]    = render->dy * yscale;
-
 
120
    texcoords[1*2]  = (render->dx+render->width)*xscale;
-
 
121
    texcoords[1*2+1]= render->dy * yscale;
-
 
122
    texcoords[2*2]  = (render->dx+render->width)*xscale;
-
 
123
    texcoords[2*2+1]= (render->dy+render->height)*yscale;
-
 
124
    texcoords[3*2]  = render->dx * xscale;
-
 
125
    texcoords[3*2+1]= (render->dy+render->height)*yscale;
-
 
126
 
89
 
127
 
-
 
128
    glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
Line 90... Line 129...
90
    glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
129
    glFlush();
91
 
130
 
92
//    glDisableVertexAttribArray(0);
131
//    glDisableVertexAttribArray(0);
93
//    glDisableVertexAttribArray(1);
132
//    glDisableVertexAttribArray(1);