summaryrefslogtreecommitdiffstats
path: root/docs/submodules/sdnvpn
AgeCommit message (Expand)AuthorFilesLines
2017-09-28Update git submodulestomsou1-0/+0
2017-09-28Update git submodulesLinda Wang1-0/+0
2017-09-14Update git submodulestomsou1-0/+0
2017-09-12Update git submodulestomsou1-0/+0
2017-09-11Update git submodulestomsou1-0/+0
2017-09-07Update git submodulesjose.lausuch1-0/+0
2017-08-28Update git submodulesTim Irnich1-0/+0
2017-08-28Update git submodulesTim Irnich1-0/+0
2017-08-28
/*
 * QEMU graphical console -- opengl helper bits
 *
 * Copyright (c) 2014 Red Hat
 *
 * Authors:
 *    Gerd Hoffmann <kraxel@redhat.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "ui/console.h"
#include "ui/shader.h"

#include "shader/texture-blit-vert.h"
#include "shader/texture-blit-frag.h"

struct ConsoleGLState {
    GLint texture_blit_prog;
    GLint texture_blit_vao;
};

/* ---------------------------------------------------------------------- */

ConsoleGLState *console_gl_init_context(void)
{
    ConsoleGLState *gls = g_new0(ConsoleGLState, 1);

    gls->texture_blit_prog = qemu_gl_create_compile_link_program
        (texture_blit_vert_src, texture_blit_frag_src);
    if (!gls->texture_blit_prog) {
        exit(1);
    }

    gls->texture_blit_vao =
        qemu_gl_init_texture_blit(gls->texture_blit_prog);

    return gls;
}

void console_gl_fini_context(ConsoleGLState *gls)
{
    if (!gls) {
        return;
    }
    g_free(gls);
}

bool console_gl_check_format(DisplayChangeListener *dcl,
                             pixman_format_code_t format)
{
    switch (format) {
    case PIXMAN_BE_b8g8r8x8:
    case PIXMAN_BE_b8g8r8a8:
    case PIXMAN_r5g6b5:
        return true;
    default:
        return false;
    }
}

void surface_gl_create_texture(ConsoleGLState *gls,
                               DisplaySurface *surface)
{
    assert(gls);
    assert(surface_stride(surface) % surface_bytes_per_pixel(surface) == 0);

    switch (surface->format) {
    case PIXMAN_BE_b8g8r8x8:
    case PIXMAN_BE_b8g8r8a8:
        surface->glformat = GL_BGRA_EXT;
        surface->gltype = GL_UNSIGNED_BYTE;
        break;
    case PIXMAN_r5g6b5:
        surface->glformat = GL_RGB;
        surface->gltype = GL_UNSIGNED_SHORT_5_6_5;
        break;
    default:
        g_assert_not_reached();
    }

    glGenTextures(1, &surface->texture);
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, surface->texture);
    glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT,
                  surface_stride(surface) / surface_bytes_per_pixel(surface));
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
                 surface_width(surface),
                 surface_height(surface),
                 0, surface->glformat, surface->gltype,
                 surface_data(surface));

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
}

void surface_gl_update_texture(ConsoleGLState *gls,
                               DisplaySurface *surface,
                               int x, int y, int w, int h)
{
    uint8_t *data = (void *)surface_data(surface);

    assert(gls);

    glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT,
                  surface_stride(surface) / surface_bytes_per_pixel(surface));
    glTexSubImage2D(GL_TEXTURE_2D, 0,
                    x, y, w, h,
                    surface->glformat, surface->gltype,
                    data + surface_stride(surface) * y
                    + surface_bytes_per_pixel(surface) * x);
}

void surface_gl_render_texture(ConsoleGLState *gls,
                               DisplaySurface *surface)
{
    assert
2017-04-06Update git submodulesNikolas Hermanns1-0/+0
2017-04-05Update git submodulesNikolas Hermanns1-0/+0
2017-04-04Update git submodulesNikolas Hermanns1-0/+0
2017-04-03Update git submodulesNikolas Hermanns1-0/+0
2017-04-03Update git submodulesNikolas Hermanns1-0/+0
2017-04-03Update git submodulesNikolas Hermanns1-0/+0
2017-03-31Update git submodulesNikolas Hermanns1-0/+0
2017-03-31Update git submodulesNikolas Hermanns1-0/+0
2017-03-30Update git submodulestomsou1-0/+0