代码拉取完成,页面将自动刷新
同步操作将从 韦东山/100ask_imx6ull qemu模拟器源码 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/*
* QEMU SDL display driver
*
* Copyright (c) 2003 Fabrice Bellard
*
* 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.
*/
/* Ported SDL 1.2 code to 2.0 by Dave Airlie. */
#include "qemu/osdep.h"
#include "ui/console.h"
#include "ui/input.h"
#include "ui/sdl2.h"
void sdl2_2d_update(DisplayChangeListener *dcl,
int x, int y, int w, int h)
{
struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl);
DisplaySurface *surf = qemu_console_surface(dcl->con);
SDL_Rect rect;
size_t surface_data_offset;
uint8_t *surf_data;
uint8_t tmp;
assert(!scon->opengl);
if (!surf) {
return;
}
if (!scon->texture) {
return;
}
surf_data = surface_data(surf);
tmp = *surf_data;
tmp = tmp;
surface_data_offset = surface_bytes_per_pixel(surf) * x +
surface_stride(surf) * y;
rect.x = x;
rect.y = y;
rect.w = w;
rect.h = h;
SDL_UpdateTexture(scon->texture, &rect,
surface_data(surf) + surface_data_offset,
surface_stride(surf));
SDL_RenderClear(scon->real_renderer);
SDL_RenderCopy(scon->real_renderer, scon->texture, NULL, NULL);
SDL_RenderPresent(scon->real_renderer);
}
/* 100ask */
int sdl2_2d_dpy_gfx_hide_or_show(DisplayChangeListener *dcl)
{
struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl);
scon->hidden = !scon->hidden;
if (scon->real_window) {
if (scon->hidden) {
SDL_HideWindow(scon->real_window);
} else {
SDL_ShowWindow(scon->real_window);
}
}
qemu_console_set_hidden(dcl->con, scon->hidden);
return !scon->hidden;
}
int sdl2_2d_dpy_gfx_is_visible(DisplayChangeListener *dcl)
{
struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl);
return !scon->hidden;
}
/* 100ask */
void sdl2_2d_update_image(DisplayChangeListener *dcl, const char *file,
int x, int y, int w, int h)
{
struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl);
DisplaySurface *surf = qemu_console_surface(dcl->con);
SDL_Rect rect;
SDL_Texture * texture;
SDL_Surface * image;
//uint8_t *win_data;
uint8_t *surf_data;
//uint32_t len;
//SDL_Surface *win_surf;
assert(!scon->opengl);
if (!surf) {
return;
}
if (!scon->texture) {
return;
}
#ifdef CONFIG_SDL_IMAGE
image = = IMG_Load(file);
#else
image = SDL_LoadBMP(file);
if (image) {
uint32_t colorkey = SDL_MapRGB(image->format, 255, 255, 255);
SDL_SetColorKey(image, SDL_TRUE, colorkey);
}
#endif
if (!image) {
return;
}
rect.x = x;
rect.y = y;
rect.w = w;
rect.h = h;
texture = SDL_CreateTextureFromSurface(scon->real_renderer, image);
SDL_RenderClear(scon->real_renderer);
SDL_RenderCopy(scon->real_renderer, texture, NULL, &rect);
SDL_RenderPresent(scon->real_renderer);
/*
win_surf = SDL_GetWindowSurface(scon->real_window);
SDL_LockSurface(win_surf);
win_data = (uint8_t *)win_surf->pixels;
surf_data = surface_data(surf);
len = surface_stride(surf) * surface_height(surf);
memcpy(surf_data, win_data, len);
SDL_UnlockSurface(win_surf);
*/
surf_data = surface_data(surf);
SDL_RenderReadPixels(scon->real_renderer, NULL, 0, (void *)surf_data, surface_stride(surf));
SDL_DestroyTexture(texture);
}
void sdl2_2d_switch(DisplayChangeListener *dcl,
DisplaySurface *new_surface)
{
struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl);
DisplaySurface *old_surface = scon->surface;
int format = 0;
assert(!scon->opengl);
scon->surface = new_surface;
if (scon->texture) {
SDL_DestroyTexture(scon->texture);
scon->texture = NULL;
}
if (!new_surface) {
sdl2_window_destroy(scon);
return;
}
if (!scon->real_window) {
sdl2_window_create(scon);
} else if (old_surface &&
((surface_width(old_surface) != surface_width(new_surface)) ||
(surface_height(old_surface) != surface_height(new_surface)))) {
sdl2_window_resize(scon);
}
SDL_RenderSetLogicalSize(scon->real_renderer,
surface_width(new_surface),
surface_height(new_surface));
switch (surface_format(scon->surface)) {
case PIXMAN_x1r5g5b5:
format = SDL_PIXELFORMAT_ARGB1555;
break;
case PIXMAN_r5g6b5:
format = SDL_PIXELFORMAT_RGB565;
break;
case PIXMAN_a8r8g8b8:
case PIXMAN_x8r8g8b8:
format = SDL_PIXELFORMAT_ARGB8888;
break;
case PIXMAN_a8b8g8r8:
case PIXMAN_x8b8g8r8:
format = SDL_PIXELFORMAT_ABGR8888;
break;
case PIXMAN_r8g8b8a8:
case PIXMAN_r8g8b8x8:
format = SDL_PIXELFORMAT_RGBA8888;
break;
case PIXMAN_b8g8r8x8:
format = SDL_PIXELFORMAT_BGRX8888;
break;
case PIXMAN_b8g8r8a8:
format = SDL_PIXELFORMAT_BGRA8888;
break;
default:
g_assert_not_reached();
}
scon->texture = SDL_CreateTexture(scon->real_renderer, format,
SDL_TEXTUREACCESS_STREAMING,
surface_width(new_surface),
surface_height(new_surface));
sdl2_2d_redraw(scon);
}
void sdl2_2d_refresh(DisplayChangeListener *dcl)
{
struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl);
assert(!scon->opengl);
graphic_hw_update(dcl->con);
sdl2_poll_events(scon);
}
void sdl2_2d_redraw(struct sdl2_console *scon)
{
assert(!scon->opengl);
if (!scon->surface) {
return;
}
sdl2_2d_update(&scon->dcl, 0, 0,
surface_width(scon->surface),
surface_height(scon->surface));
}
bool sdl2_2d_check_format(DisplayChangeListener *dcl,
pixman_format_code_t format)
{
/*
* We let SDL convert for us a few more formats than,
* the native ones. Thes are the ones I have tested.
*/
return (format == PIXMAN_x8r8g8b8 ||
format == PIXMAN_a8r8g8b8 ||
format == PIXMAN_a8b8g8r8 ||
format == PIXMAN_x8b8g8r8 ||
format == PIXMAN_b8g8r8x8 ||
format == PIXMAN_b8g8r8a8 ||
format == PIXMAN_r8g8b8x8 ||
format == PIXMAN_r8g8b8a8 ||
format == PIXMAN_x1r5g5b5 ||
format == PIXMAN_r5g6b5);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。