remove obsolete files

This commit is contained in:
mgthepro
2022-07-31 12:49:57 +02:00
parent 117076fd71
commit de846fb71e
3631 changed files with 0 additions and 9433291 deletions

View File

@@ -1,444 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/* This file is #included twice to support int and float versions with the same code. */
SDL_bool
SDL_HASINTERSECTION(const RECTTYPE * A, const RECTTYPE * B)
{
SCALARTYPE Amin, Amax, Bmin, Bmax;
if (!A) {
SDL_InvalidParamError("A");
return SDL_FALSE;
} else if (!B) {
SDL_InvalidParamError("B");
return SDL_FALSE;
} else if (SDL_RECTEMPTY(A) || SDL_RECTEMPTY(B)) {
return SDL_FALSE; /* Special cases for empty rects */
}
/* Horizontal intersection */
Amin = A->x;
Amax = Amin + A->w;
Bmin = B->x;
Bmax = Bmin + B->w;
if (Bmin > Amin) {
Amin = Bmin;
}
if (Bmax < Amax) {
Amax = Bmax;
}
if (Amax <= Amin) {
return SDL_FALSE;
}
/* Vertical intersection */
Amin = A->y;
Amax = Amin + A->h;
Bmin = B->y;
Bmax = Bmin + B->h;
if (Bmin > Amin) {
Amin = Bmin;
}
if (Bmax < Amax) {
Amax = Bmax;
}
if (Amax <= Amin) {
return SDL_FALSE;
}
return SDL_TRUE;
}
SDL_bool
SDL_INTERSECTRECT(const RECTTYPE * A, const RECTTYPE * B, RECTTYPE * result)
{
SCALARTYPE Amin, Amax, Bmin, Bmax;
if (!A) {
SDL_InvalidParamError("A");
return SDL_FALSE;
} else if (!B) {
SDL_InvalidParamError("B");
return SDL_FALSE;
} else if (!result) {
SDL_InvalidParamError("result");
return SDL_FALSE;
} else if (SDL_RECTEMPTY(A) || SDL_RECTEMPTY(B)) { /* Special cases for empty rects */
result->w = 0;
result->h = 0;
return SDL_FALSE;
}
/* Horizontal intersection */
Amin = A->x;
Amax = Amin + A->w;
Bmin = B->x;
Bmax = Bmin + B->w;
if (Bmin > Amin) {
Amin = Bmin;
}
result->x = Amin;
if (Bmax < Amax) {
Amax = Bmax;
}
result->w = Amax - Amin;
/* Vertical intersection */
Amin = A->y;
Amax = Amin + A->h;
Bmin = B->y;
Bmax = Bmin + B->h;
if (Bmin > Amin) {
Amin = Bmin;
}
result->y = Amin;
if (Bmax < Amax) {
Amax = Bmax;
}
result->h = Amax - Amin;
return !SDL_RECTEMPTY(result);
}
void
SDL_UNIONRECT(const RECTTYPE * A, const RECTTYPE * B, RECTTYPE * result)
{
SCALARTYPE Amin, Amax, Bmin, Bmax;
if (!A) {
SDL_InvalidParamError("A");
return;
} else if (!B) {
SDL_InvalidParamError("B");
return;
} else if (!result) {
SDL_InvalidParamError("result");
return;
} else if (SDL_RECTEMPTY(A)) { /* Special cases for empty Rects */
if (SDL_RECTEMPTY(B)) { /* A and B empty */
SDL_zerop(result);
} else { /* A empty, B not empty */
*result = *B;
}
return;
} else if (SDL_RECTEMPTY(B)) { /* A not empty, B empty */
*result = *A;
return;
}
/* Horizontal union */
Amin = A->x;
Amax = Amin + A->w;
Bmin = B->x;
Bmax = Bmin + B->w;
if (Bmin < Amin) {
Amin = Bmin;
}
result->x = Amin;
if (Bmax > Amax) {
Amax = Bmax;
}
result->w = Amax - Amin;
/* Vertical union */
Amin = A->y;
Amax = Amin + A->h;
Bmin = B->y;
Bmax = Bmin + B->h;
if (Bmin < Amin) {
Amin = Bmin;
}
result->y = Amin;
if (Bmax > Amax) {
Amax = Bmax;
}
result->h = Amax - Amin;
}
SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE * points, int count, const RECTTYPE * clip,
RECTTYPE * result)
{
SCALARTYPE minx = 0;
SCALARTYPE miny = 0;
SCALARTYPE maxx = 0;
SCALARTYPE maxy = 0;
SCALARTYPE x, y;
int i;
if (!points) {
SDL_InvalidParamError("points");
return SDL_FALSE;
} else if (count < 1) {
SDL_InvalidParamError("count");
return SDL_FALSE;
}
if (clip) {
SDL_bool added = SDL_FALSE;
const SCALARTYPE clip_minx = clip->x;
const SCALARTYPE clip_miny = clip->y;
const SCALARTYPE clip_maxx = clip->x+clip->w-1;
const SCALARTYPE clip_maxy = clip->y+clip->h-1;
/* Special case for empty rectangle */
if (SDL_RECTEMPTY(clip)) {
return SDL_FALSE;
}
for (i = 0; i < count; ++i) {
x = points[i].x;
y = points[i].y;
if (x < clip_minx || x > clip_maxx ||
y < clip_miny || y > clip_maxy) {
continue;
}
if (!added) {
/* Special case: if no result was requested, we are done */
if (result == NULL) {
return SDL_TRUE;
}
/* First point added */
minx = maxx = x;
miny = maxy = y;
added = SDL_TRUE;
continue;
}
if (x < minx) {
minx = x;
} else if (x > maxx) {
maxx = x;
}
if (y < miny) {
miny = y;
} else if (y > maxy) {
maxy = y;
}
}
if (!added) {
return SDL_FALSE;
}
} else {
/* Special case: if no result was requested, we are done */
if (result == NULL) {
return SDL_TRUE;
}
/* No clipping, always add the first point */
minx = maxx = points[0].x;
miny = maxy = points[0].y;
for (i = 1; i < count; ++i) {
x = points[i].x;
y = points[i].y;
if (x < minx) {
minx = x;
} else if (x > maxx) {
maxx = x;
}
if (y < miny) {
miny = y;
} else if (y > maxy) {
maxy = y;
}
}
}
if (result) {
result->x = minx;
result->y = miny;
result->w = (maxx-minx)+1;
result->h = (maxy-miny)+1;
}
return SDL_TRUE;
}
/* Use the Cohen-Sutherland algorithm for line clipping */
static int
COMPUTEOUTCODE(const RECTTYPE * rect, SCALARTYPE x, SCALARTYPE y)
{
int code = 0;
if (y < rect->y) {
code |= CODE_TOP;
} else if (y >= rect->y + rect->h) {
code |= CODE_BOTTOM;
}
if (x < rect->x) {
code |= CODE_LEFT;
} else if (x >= rect->x + rect->w) {
code |= CODE_RIGHT;
}
return code;
}
SDL_bool
SDL_INTERSECTRECTANDLINE(const RECTTYPE * rect, SCALARTYPE *X1, SCALARTYPE *Y1, SCALARTYPE *X2,
SCALARTYPE *Y2)
{
SCALARTYPE x = 0;
SCALARTYPE y = 0;
SCALARTYPE x1, y1;
SCALARTYPE x2, y2;
SCALARTYPE rectx1;
SCALARTYPE recty1;
SCALARTYPE rectx2;
SCALARTYPE recty2;
int outcode1, outcode2;
if (!rect) {
SDL_InvalidParamError("rect");
return SDL_FALSE;
} else if (!X1) {
SDL_InvalidParamError("X1");
return SDL_FALSE;
} else if (!Y1) {
SDL_InvalidParamError("Y1");
return SDL_FALSE;
} else if (!X2) {
SDL_InvalidParamError("X2");
return SDL_FALSE;
} else if (!Y2) {
SDL_InvalidParamError("Y2");
return SDL_FALSE;
} else if (SDL_RECTEMPTY(rect)) {
return SDL_FALSE; /* Special case for empty rect */
}
x1 = *X1;
y1 = *Y1;
x2 = *X2;
y2 = *Y2;
rectx1 = rect->x;
recty1 = rect->y;
rectx2 = rect->x + rect->w - 1;
recty2 = rect->y + rect->h - 1;
/* Check to see if entire line is inside rect */
if (x1 >= rectx1 && x1 <= rectx2 && x2 >= rectx1 && x2 <= rectx2 &&
y1 >= recty1 && y1 <= recty2 && y2 >= recty1 && y2 <= recty2) {
return SDL_TRUE;
}
/* Check to see if entire line is to one side of rect */
if ((x1 < rectx1 && x2 < rectx1) || (x1 > rectx2 && x2 > rectx2) ||
(y1 < recty1 && y2 < recty1) || (y1 > recty2 && y2 > recty2)) {
return SDL_FALSE;
}
if (y1 == y2) { /* Horizontal line, easy to clip */
if (x1 < rectx1) {
*X1 = rectx1;
} else if (x1 > rectx2) {
*X1 = rectx2;
}
if (x2 < rectx1) {
*X2 = rectx1;
} else if (x2 > rectx2) {
*X2 = rectx2;
}
return SDL_TRUE;
}
if (x1 == x2) { /* Vertical line, easy to clip */
if (y1 < recty1) {
*Y1 = recty1;
} else if (y1 > recty2) {
*Y1 = recty2;
}
if (y2 < recty1) {
*Y2 = recty1;
} else if (y2 > recty2) {
*Y2 = recty2;
}
return SDL_TRUE;
}
/* More complicated Cohen-Sutherland algorithm */
outcode1 = COMPUTEOUTCODE(rect, x1, y1);
outcode2 = COMPUTEOUTCODE(rect, x2, y2);
while (outcode1 || outcode2) {
if (outcode1 & outcode2) {
return SDL_FALSE;
}
if (outcode1) {
if (outcode1 & CODE_TOP) {
y = recty1;
x = x1 + ((x2 - x1) * (y - y1)) / (y2 - y1);
} else if (outcode1 & CODE_BOTTOM) {
y = recty2;
x = x1 + ((x2 - x1) * (y - y1)) / (y2 - y1);
} else if (outcode1 & CODE_LEFT) {
x = rectx1;
y = y1 + ((y2 - y1) * (x - x1)) / (x2 - x1);
} else if (outcode1 & CODE_RIGHT) {
x = rectx2;
y = y1 + ((y2 - y1) * (x - x1)) / (x2 - x1);
}
x1 = x;
y1 = y;
outcode1 = COMPUTEOUTCODE(rect, x, y);
} else {
if (outcode2 & CODE_TOP) {
y = recty1;
x = x1 + ((x2 - x1) * (y - y1)) / (y2 - y1);
} else if (outcode2 & CODE_BOTTOM) {
y = recty2;
x = x1 + ((x2 - x1) * (y - y1)) / (y2 - y1);
} else if (outcode2 & CODE_LEFT) {
/* If this assertion ever fires, here's the static analysis that warned about it:
http://buildbot.libsdl.org/sdl-static-analysis/sdl-macosx-static-analysis/sdl-macosx-static-analysis-1101/report-b0d01a.html#EndPath */
SDL_assert(x2 != x1); /* if equal: division by zero. */
x = rectx1;
y = y1 + ((y2 - y1) * (x - x1)) / (x2 - x1);
} else if (outcode2 & CODE_RIGHT) {
/* If this assertion ever fires, here's the static analysis that warned about it:
http://buildbot.libsdl.org/sdl-static-analysis/sdl-macosx-static-analysis/sdl-macosx-static-analysis-1101/report-39b114.html#EndPath */
SDL_assert(x2 != x1); /* if equal: division by zero. */
x = rectx2;
y = y1 + ((y2 - y1) * (x - x1)) / (x2 - x1);
}
x2 = x;
y2 = y;
outcode2 = COMPUTEOUTCODE(rect, x, y);
}
}
*X1 = x1;
*Y1 = y1;
*X2 = x2;
*Y2 = y2;
return SDL_TRUE;
}
#undef RECTTYPE
#undef POINTTYPE
#undef SCALARTYPE
#undef COMPUTEOUTCODE
#undef SDL_HASINTERSECTION
#undef SDL_INTERSECTRECT
#undef SDL_RECTEMPTY
#undef SDL_UNIONRECT
#undef SDL_ENCLOSEPOINTS
#undef SDL_INTERSECTRECTANDLINE
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,431 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_BAPP_H
#define SDL_BAPP_H
#include <Path.h>
#include <InterfaceKit.h>
#include <LocaleRoster.h>
#if SDL_VIDEO_OPENGL
#include <OpenGLKit.h>
#endif
#include "../../video/haiku/SDL_bkeyboard.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "../../SDL_internal.h"
#include "SDL_video.h"
/* Local includes */
#include "../../events/SDL_events_c.h"
#include "../../video/haiku/SDL_bframebuffer.h"
#ifdef __cplusplus
}
#endif
#include <vector>
/* Forward declarations */
class SDL_BWin;
/* Message constants */
enum ToSDL {
/* Intercepted by BWindow on its way to BView */
BAPP_MOUSE_MOVED,
BAPP_MOUSE_BUTTON,
BAPP_MOUSE_WHEEL,
BAPP_KEY,
BAPP_REPAINT, /* from _UPDATE_ */
/* From BWindow */
BAPP_MAXIMIZE, /* from B_ZOOM */
BAPP_MINIMIZE,
BAPP_RESTORE, /* TODO: IMPLEMENT! */
BAPP_SHOW,
BAPP_HIDE,
BAPP_MOUSE_FOCUS, /* caused by MOUSE_MOVE */
BAPP_KEYBOARD_FOCUS, /* from WINDOW_ACTIVATED */
BAPP_WINDOW_CLOSE_REQUESTED,
BAPP_WINDOW_MOVED,
BAPP_WINDOW_RESIZED,
BAPP_SCREEN_CHANGED
};
/* Create a descendant of BApplication */
class SDL_BApp : public BApplication {
public:
SDL_BApp(const char* signature) :
BApplication(signature) {
#if SDL_VIDEO_OPENGL
_current_context = NULL;
#endif
}
virtual ~SDL_BApp() {
}
virtual void RefsReceived(BMessage* message) {
char filePath[512];
entry_ref entryRef;
for (int32 i = 0; message->FindRef("refs", i, &entryRef) == B_OK; i++) {
BPath referencePath = BPath(&entryRef);
SDL_SendDropFile(NULL, referencePath.Path());
}
return;
}
/* Event-handling functions */
virtual void MessageReceived(BMessage* message) {
/* Sort out SDL-related messages */
switch ( message->what ) {
case BAPP_MOUSE_MOVED:
_HandleMouseMove(message);
break;
case BAPP_MOUSE_BUTTON:
_HandleMouseButton(message);
break;
case BAPP_MOUSE_WHEEL:
_HandleMouseWheel(message);
break;
case BAPP_KEY:
_HandleKey(message);
break;
case BAPP_REPAINT:
_HandleBasicWindowEvent(message, SDL_WINDOWEVENT_EXPOSED);
break;
case BAPP_MAXIMIZE:
_HandleBasicWindowEvent(message, SDL_WINDOWEVENT_MAXIMIZED);
break;
case BAPP_MINIMIZE:
_HandleBasicWindowEvent(message, SDL_WINDOWEVENT_MINIMIZED);
break;
case BAPP_SHOW:
_HandleBasicWindowEvent(message, SDL_WINDOWEVENT_SHOWN);
break;
case BAPP_HIDE:
_HandleBasicWindowEvent(message, SDL_WINDOWEVENT_HIDDEN);
break;
case BAPP_MOUSE_FOCUS:
_HandleMouseFocus(message);
break;
case BAPP_KEYBOARD_FOCUS:
_HandleKeyboardFocus(message);
break;
case BAPP_WINDOW_CLOSE_REQUESTED:
_HandleBasicWindowEvent(message, SDL_WINDOWEVENT_CLOSE);
break;
case BAPP_WINDOW_MOVED:
_HandleWindowMoved(message);
break;
case BAPP_WINDOW_RESIZED:
_HandleWindowResized(message);
break;
case B_LOCALE_CHANGED:
SDL_SendLocaleChangedEvent();
break;
case BAPP_SCREEN_CHANGED:
/* TODO: Handle screen resize or workspace change */
break;
default:
BApplication::MessageReceived(message);
break;
}
}
/* Window creation/destruction methods */
int32 GetID(SDL_Window *win) {
int32 i;
for(i = 0; i < _GetNumWindowSlots(); ++i) {
if( GetSDLWindow(i) == NULL ) {
_SetSDLWindow(win, i);
return i;
}
}
/* Expand the vector if all slots are full */
if( i == _GetNumWindowSlots() ) {
_PushBackWindow(win);
return i;
}
/* TODO: error handling */
return 0;
}
/* FIXME: Bad coding practice, but I can't include SDL_BWin.h here. Is
there another way to do this? */
void ClearID(SDL_BWin *bwin); /* Defined in SDL_BeApp.cc */
SDL_Window *GetSDLWindow(int32 winID) {
return _window_map[winID];
}
#if SDL_VIDEO_OPENGL
BGLView *GetCurrentContext() {
return _current_context;
}
void SetCurrentContext(BGLView *newContext) {
if(_current_context)
_current_context->UnlockGL();
_current_context = newContext;
if (_current_context)
_current_context->LockGL();
}
#endif
private:
/* Event management */
void _HandleBasicWindowEvent(BMessage *msg, int32 sdlEventType) {
SDL_Window *win;
int32 winID;
if(
!_GetWinID(msg, &winID)
) {
return;
}
win = GetSDLWindow(winID);
SDL_SendWindowEvent(win, sdlEventType, 0, 0);
}
void _HandleMouseMove(BMessage *msg) {
SDL_Window *win;
int32 winID;
int32 x = 0, y = 0;
if(
!_GetWinID(msg, &winID) ||
msg->FindInt32("x", &x) != B_OK || /* x movement */
msg->FindInt32("y", &y) != B_OK /* y movement */
) {
return;
}
win = GetSDLWindow(winID);
// Simple relative mode support for mouse.
if (SDL_GetMouse()->relative_mode) {
int winWidth, winHeight, winPosX, winPosY;
SDL_GetWindowSize(win, &winWidth, &winHeight);
SDL_GetWindowPosition(win, &winPosX, &winPosY);
int dx = x - (winWidth / 2);
int dy = y - (winHeight / 2);
SDL_SendMouseMotion(win, 0, SDL_GetMouse()->relative_mode, dx, dy);
set_mouse_position((winPosX + winWidth / 2), (winPosY + winHeight / 2));
if (!be_app->IsCursorHidden())
be_app->HideCursor();
} else {
SDL_SendMouseMotion(win, 0, 0, x, y);
if (SDL_ShowCursor(-1) && be_app->IsCursorHidden())
be_app->ShowCursor();
}
}
void _HandleMouseButton(BMessage *msg) {
SDL_Window *win;
int32 winID;
int32 button, state; /* left/middle/right, pressed/released */
if(
!_GetWinID(msg, &winID) ||
msg->FindInt32("button-id", &button) != B_OK ||
msg->FindInt32("button-state", &state) != B_OK
) {
return;
}
win = GetSDLWindow(winID);
SDL_SendMouseButton(win, 0, state, button);
}
void _HandleMouseWheel(BMessage *msg) {
SDL_Window *win;
int32 winID;
int32 xTicks, yTicks;
if(
!_GetWinID(msg, &winID) ||
msg->FindInt32("xticks", &xTicks) != B_OK ||
msg->FindInt32("yticks", &yTicks) != B_OK
) {
return;
}
win = GetSDLWindow(winID);
SDL_SendMouseWheel(win, 0, xTicks, -yTicks, SDL_MOUSEWHEEL_NORMAL);
}
void _HandleKey(BMessage *msg) {
int32 scancode, state; /* scancode, pressed/released */
if(
msg->FindInt32("key-state", &state) != B_OK ||
msg->FindInt32("key-scancode", &scancode) != B_OK
) {
return;
}
/* Make sure this isn't a repeated event (key pressed and held) */
if(state == SDL_PRESSED && HAIKU_GetKeyState(scancode) == SDL_PRESSED) {
return;
}
HAIKU_SetKeyState(scancode, state);
SDL_SendKeyboardKey(state, HAIKU_GetScancodeFromBeKey(scancode));
if (state == SDL_PRESSED && SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
const int8 *keyUtf8;
ssize_t count;
if (msg->FindData("key-utf8", B_INT8_TYPE, (const void**)&keyUtf8, &count) == B_OK) {
char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];
SDL_zeroa(text);
SDL_memcpy(text, keyUtf8, count);
SDL_SendKeyboardText(text);
}
}
}
void _HandleMouseFocus(BMessage *msg) {
SDL_Window *win;
int32 winID;
bool bSetFocus; /* If false, lose focus */
if(
!_GetWinID(msg, &winID) ||
msg->FindBool("focusGained", &bSetFocus) != B_OK
) {
return;
}
win = GetSDLWindow(winID);
if(bSetFocus) {
SDL_SetMouseFocus(win);
} else if(SDL_GetMouseFocus() == win) {
/* Only lose all focus if this window was the current focus */
SDL_SetMouseFocus(NULL);
}
}
void _HandleKeyboardFocus(BMessage *msg) {
SDL_Window *win;
int32 winID;
bool bSetFocus; /* If false, lose focus */
if(
!_GetWinID(msg, &winID) ||
msg->FindBool("focusGained", &bSetFocus) != B_OK
) {
return;
}
win = GetSDLWindow(winID);
if(bSetFocus) {
SDL_SetKeyboardFocus(win);
} else if(SDL_GetKeyboardFocus() == win) {
/* Only lose all focus if this window was the current focus */
SDL_SetKeyboardFocus(NULL);
}
}
void _HandleWindowMoved(BMessage *msg) {
SDL_Window *win;
int32 winID;
int32 xPos, yPos;
/* Get the window id and new x/y position of the window */
if(
!_GetWinID(msg, &winID) ||
msg->FindInt32("window-x", &xPos) != B_OK ||
msg->FindInt32("window-y", &yPos) != B_OK
) {
return;
}
win = GetSDLWindow(winID);
SDL_SendWindowEvent(win, SDL_WINDOWEVENT_MOVED, xPos, yPos);
}
void _HandleWindowResized(BMessage *msg) {
SDL_Window *win;
int32 winID;
int32 w, h;
/* Get the window id ]and new x/y position of the window */
if(
!_GetWinID(msg, &winID) ||
msg->FindInt32("window-w", &w) != B_OK ||
msg->FindInt32("window-h", &h) != B_OK
) {
return;
}
win = GetSDLWindow(winID);
SDL_SendWindowEvent(win, SDL_WINDOWEVENT_RESIZED, w, h);
}
bool _GetWinID(BMessage *msg, int32 *winID) {
return msg->FindInt32("window-id", winID) == B_OK;
}
/* Vector functions: Wraps vector stuff in case we need to change
implementation */
void _SetSDLWindow(SDL_Window *win, int32 winID) {
_window_map[winID] = win;
}
int32 _GetNumWindowSlots() {
return _window_map.size();
}
void _PopBackWindow() {
_window_map.pop_back();
}
void _PushBackWindow(SDL_Window *win) {
_window_map.push_back(win);
}
/* Members */
std::vector<SDL_Window*> _window_map; /* Keeps track of SDL_Windows by index-id */
#if SDL_VIDEO_OPENGL
BGLView *_current_context;
#endif
};
#endif

View File

@@ -1,200 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_NGAGE
/* Being a ngage driver, there's no event stream. We just define stubs for
most of the API. */
#ifdef __cplusplus
extern "C" {
#endif
#include "../../events/SDL_events_c.h"
#include "../../events/SDL_keyboard_c.h"
#ifdef __cplusplus
}
#endif
#include "SDL_ngagevideo.h"
#include "SDL_ngageevents_c.h"
int HandleWsEvent(_THIS, const TWsEvent& aWsEvent);
void
NGAGE_PumpEvents(_THIS)
{
SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata;
while (phdata->NGAGE_WsEventStatus != KRequestPending)
{
phdata->NGAGE_WsSession.GetEvent(phdata->NGAGE_WsEvent);
HandleWsEvent(_this, phdata->NGAGE_WsEvent);
phdata->NGAGE_WsEventStatus = KRequestPending;
phdata->NGAGE_WsSession.EventReady(&phdata->NGAGE_WsEventStatus);
}
}
/*****************************************************************************/
/* Internal */
/*****************************************************************************/
#include <bautils.h>
#include <hal.h>
extern void DisableKeyBlocking(_THIS);
extern void RedrawWindowL(_THIS);
TBool isCursorVisible = EFalse;
static SDL_Scancode ConvertScancode(_THIS, int key)
{
SDL_Keycode keycode;
switch(key)
{
case EStdKeyBackspace: // Clear key
keycode = SDLK_BACKSPACE;
break;
case 0x31: // 1
keycode = SDLK_1;
break;
case 0x32: // 2
keycode = SDLK_2;
break;
case 0x33: // 3
keycode = SDLK_3;
break;
case 0x34: // 4
keycode = SDLK_4;
break;
case 0x35: // 5
keycode = SDLK_5;
break;
case 0x36: // 6
keycode = SDLK_6;
break;
case 0x37: // 7
keycode = SDLK_7;
break;
case 0x38: // 8
keycode = SDLK_8;
break;
case 0x39: // 9
keycode = SDLK_9;
break;
case 0x30: // 0
keycode = SDLK_0;
break;
case 0x2a: // Asterisk
keycode = SDLK_ASTERISK;
break;
case EStdKeyHash: // Hash
keycode = SDLK_HASH;
break;
case EStdKeyDevice0: // Left softkey
keycode = SDLK_SOFTLEFT;
break;
case EStdKeyDevice1: // Right softkey
keycode = SDLK_SOFTRIGHT;
break;
case EStdKeyApplication0: // Call softkey
keycode = SDLK_CALL;
break;
case EStdKeyApplication1: // End call softkey
keycode = SDLK_ENDCALL;
break;
case EStdKeyDevice3: // Middle softkey
keycode = SDLK_SELECT;
break;
case EStdKeyUpArrow: // Up arrow
keycode = SDLK_UP;
break;
case EStdKeyDownArrow: // Down arrow
keycode = SDLK_DOWN;
break;
case EStdKeyLeftArrow: // Left arrow
keycode = SDLK_LEFT;
break;
case EStdKeyRightArrow: // Right arrow
keycode = SDLK_RIGHT;
break;
default:
keycode = SDLK_UNKNOWN;
break;
}
return SDL_GetScancodeFromKey(keycode);
}
int HandleWsEvent(_THIS, const TWsEvent& aWsEvent)
{
SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata;
int posted = 0;
switch (aWsEvent.Type())
{
case EEventKeyDown: /* Key events */
SDL_SendKeyboardKey(SDL_PRESSED, ConvertScancode(_this, aWsEvent.Key()->iScanCode));
break;
case EEventKeyUp: /* Key events */
SDL_SendKeyboardKey(SDL_RELEASED, ConvertScancode(_this, aWsEvent.Key()->iScanCode));
break;
case EEventFocusGained: /* SDL window got focus */
phdata->NGAGE_IsWindowFocused = ETrue;
/* Draw window background and screen buffer */
DisableKeyBlocking(_this);
RedrawWindowL(_this);
break;
case EEventFocusLost: /* SDL window lost focus */
{
phdata->NGAGE_IsWindowFocused = EFalse;
RWsSession s;
s.Connect();
RWindowGroup g(s);
g.Construct(TUint32(&g), EFalse);
g.EnableReceiptOfFocus(EFalse);
RWindow w(s);
w.Construct(g, TUint32(&w));
w.SetExtent(TPoint(0, 0), phdata->NGAGE_WsWindow.Size());
w.SetOrdinalPosition(0);
w.Activate();
w.Close();
g.Close();
s.Close();
break;
}
case EEventModifiersChanged:
break;
default:
break;
}
return posted;
}
#endif /* SDL_VIDEO_DRIVER_NGAGE */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,28 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#include "SDL_ngagevideo.h"
extern void NGAGE_PumpEvents(_THIS);
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,431 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_NGAGE
#include <SDL.h>
#include "../SDL_sysvideo.h"
#include "SDL_ngagevideo.h"
#include "SDL_ngageframebuffer_c.h"
#define NGAGE_SURFACE "NGAGE_FrameBuffer"
/* For 12 bit screen HW. Table for fast conversion from 8 bit to 12 bit
*
* TUint16 is enough, but using TUint32 so we can use better instruction
* selection on ARMI.
*/
static TUint32 NGAGE_HWPalette_256_to_Screen[256];
int GetBpp(TDisplayMode displaymode);
void DirectUpdate(_THIS, int numrects, SDL_Rect *rects);
void DrawBackground(_THIS);
void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer);
void RedrawWindowL(_THIS);
int SDL_NGAGE_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
{
SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata;
SDL_Surface *surface;
const Uint32 surface_format = SDL_PIXELFORMAT_RGB444;
int w, h;
/* Free the old framebuffer surface */
SDL_NGAGE_DestroyWindowFramebuffer(_this, window);
/* Create a new one */
SDL_GetWindowSize(window, &w, &h);
surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format);
if (! surface) {
return -1;
}
/* Save the info and return! */
SDL_SetWindowData(window, NGAGE_SURFACE, surface);
*format = surface_format;
*pixels = surface->pixels;
*pitch = surface->pitch;
/* Initialise Epoc frame buffer */
TDisplayMode displayMode = phdata->NGAGE_WsScreen->DisplayMode();
TScreenInfoV01 screenInfo;
TPckg<TScreenInfoV01> sInfo(screenInfo);
UserSvr::ScreenInfo(sInfo);
phdata->NGAGE_ScreenSize = screenInfo.iScreenSize;
phdata->NGAGE_DisplayMode = displayMode;
phdata->NGAGE_HasFrameBuffer = screenInfo.iScreenAddressValid;
phdata->NGAGE_FrameBuffer = phdata->NGAGE_HasFrameBuffer ? (TUint8*) screenInfo.iScreenAddress : NULL;
phdata->NGAGE_BytesPerPixel = ((GetBpp(displayMode)-1) / 8) + 1;
phdata->NGAGE_BytesPerScanLine = screenInfo.iScreenSize.iWidth * phdata->NGAGE_BytesPerPixel;
phdata->NGAGE_BytesPerScreen = phdata->NGAGE_BytesPerScanLine * phdata->NGAGE_ScreenSize.iHeight;
SDL_Log("Screen width %d", screenInfo.iScreenSize.iWidth);
SDL_Log("Screen height %d", screenInfo.iScreenSize.iHeight);
SDL_Log("Screen dmode %d", displayMode);
SDL_Log("Screen valid %d", screenInfo.iScreenAddressValid);
SDL_Log("Bytes per pixel %d", phdata->NGAGE_BytesPerPixel);
SDL_Log("Bytes per scan line %d", phdata->NGAGE_BytesPerScanLine);
SDL_Log("Bytes per screen %d", phdata->NGAGE_BytesPerScreen);
/* It seems that in SA1100 machines for 8bpp displays there is a 512
* palette table at the beginning of the frame buffer.
*
* In 12 bpp machines the table has 16 entries.
*/
if (phdata->NGAGE_HasFrameBuffer && GetBpp(displayMode) == 8)
{
phdata->NGAGE_FrameBuffer += 512;
}
else
{
phdata->NGAGE_FrameBuffer += 32;
}
#if 0
if (phdata->NGAGE_HasFrameBuffer && GetBpp(displayMode) == 12)
{
phdata->NGAGE_FrameBuffer += 16 * 2;
}
if (phdata->NGAGE_HasFrameBuffer && GetBpp(displayMode) == 16)
{
phdata->NGAGE_FrameBuffer += 16 * 2;
}
#endif
// Get draw device for updating the screen
TScreenInfoV01 screenInfo2;
NGAGE_Runtime::GetScreenInfo(screenInfo2);
TRAPD(status, phdata->NGAGE_DrawDevice = CFbsDrawDevice::NewScreenDeviceL(screenInfo2, displayMode));
User::LeaveIfError(status);
/* Activate events for me */
phdata->NGAGE_WsEventStatus = KRequestPending;
phdata->NGAGE_WsSession.EventReady(&phdata->NGAGE_WsEventStatus);
SDL_Log("SDL:WsEventStatus");
User::WaitForRequest(phdata->NGAGE_WsEventStatus);
phdata->NGAGE_RedrawEventStatus = KRequestPending;
phdata->NGAGE_WsSession.RedrawReady(&phdata->NGAGE_RedrawEventStatus);
SDL_Log("SDL:RedrawEventStatus");
User::WaitForRequest(phdata->NGAGE_RedrawEventStatus);
phdata->NGAGE_WsWindow.PointerFilter(EPointerFilterDrag, 0);
phdata->NGAGE_ScreenOffset = TPoint(0, 0);
SDL_Log("SDL:DrawBackground");
DrawBackground(_this); // Clear screen
return 0;
}
int SDL_NGAGE_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects)
{
static int frame_number;
SDL_Surface *surface;
surface = (SDL_Surface *) SDL_GetWindowData(window, NGAGE_SURFACE);
if (! surface)
{
return SDL_SetError("Couldn't find ngage surface for window");
}
/* Send the data to the display */
if (SDL_getenv("SDL_VIDEO_NGAGE_SAVE_FRAMES"))
{
char file[128];
SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp",
(int)SDL_GetWindowID(window), ++frame_number);
SDL_SaveBMP(surface, file);
}
DirectUpdate(_this, numrects, (SDL_Rect*)rects);
return 0;
}
void SDL_NGAGE_DestroyWindowFramebuffer(_THIS, SDL_Window * window)
{
SDL_Surface *surface;
surface = (SDL_Surface *) SDL_SetWindowData(window, NGAGE_SURFACE, NULL);
SDL_FreeSurface(surface);
}
/*****************************************************************************/
/* Runtime */
/*****************************************************************************/
#include <e32svr.h>
#include <hal_data.h>
#include <hal.h>
EXPORT_C void NGAGE_Runtime::GetScreenInfo(TScreenInfoV01& screenInfo2)
{
TPckg<TScreenInfoV01> sInfo2(screenInfo2);
UserSvr::ScreenInfo(sInfo2);
}
/*****************************************************************************/
/* Internal */
/*****************************************************************************/
int GetBpp(TDisplayMode displaymode)
{
return TDisplayModeUtils::NumDisplayModeBitsPerPixel(displaymode);
}
void DrawBackground(_THIS)
{
SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata;
/* Draw background */
TUint16* screenBuffer = (TUint16*)phdata->NGAGE_FrameBuffer;
/* Draw black background */
Mem::FillZ(screenBuffer, phdata->NGAGE_BytesPerScreen);
}
void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer)
{
SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata;
SDL_Surface *screen = (SDL_Surface*)SDL_GetWindowData(_this->windows, NGAGE_SURFACE);
TInt i;
//const TInt sourceNumBytesPerPixel = ((screen->format->BitsPerPixel-1) >> 3) + 1;
TDisplayMode displayMode = phdata->NGAGE_DisplayMode;
const TInt sourceNumBytesPerPixel = ((GetBpp(displayMode)-1) / 8) + 1;
//
const TPoint fixedOffset = phdata->NGAGE_ScreenOffset;
const TInt screenW = screen->w;
const TInt screenH = screen->h;
const TInt sourceScanlineLength = screenW;
const TInt targetScanlineLength = phdata->NGAGE_ScreenSize.iWidth;
/* Render the rectangles in the list */
for (i = 0; i < numrects; ++i)
{
const SDL_Rect& currentRect = rects[i];
SDL_Rect rect2;
rect2.x = currentRect.x;
rect2.y = currentRect.y;
rect2.w = currentRect.w;
rect2.h = currentRect.h;
if (rect2.w <= 0 || rect2.h <= 0) /* Sanity check */
{
continue;
}
/* All variables are measured in pixels */
/* Check rects validity, i.e. upper and lower bounds */
TInt maxX = Min(screenW - 1, rect2.x + rect2.w - 1);
TInt maxY = Min(screenH - 1, rect2.y + rect2.h - 1);
if (maxX < 0 || maxY < 0) /* sanity check */
{
continue;
}
/* Clip from bottom */
maxY = Min(maxY, phdata->NGAGE_ScreenSize.iHeight-1);
/* TODO: Clip from the right side */
const TInt sourceRectWidth = maxX - rect2.x + 1;
const TInt sourceRectWidthInBytes = sourceRectWidth * sourceNumBytesPerPixel;
const TInt sourceRectHeight = maxY - rect2.y + 1;
const TInt sourceStartOffset = rect2.x + rect2.y * sourceScanlineLength;
const TUint skipValue = 1; /* 1 = No skip */
TInt targetStartOffset = fixedOffset.iX + rect2.x + (fixedOffset.iY +rect2.y) * targetScanlineLength;
switch (screen->format->BitsPerPixel)
{
case 12:
{
TUint16* bitmapLine = (TUint16*)screen->pixels + sourceStartOffset;
TUint16* screenMemory = screenBuffer + targetStartOffset;
if (skipValue == 1)
{
for(TInt y = 0 ; y < sourceRectHeight ; y++)
{
Mem::Copy(screenMemory, bitmapLine, sourceRectWidthInBytes);
bitmapLine += sourceScanlineLength;
screenMemory += targetScanlineLength;
}
}
else
{
for(TInt y = 0 ; y < sourceRectHeight ; y++)
{
TUint16* bitmapPos = bitmapLine; /* 2 bytes per pixel */
TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */
for(TInt x = 0 ; x < sourceRectWidth ; x++)
{
__ASSERT_DEBUG(screenMemory < (screenBuffer + phdata->NGAGE_ScreenSize.iWidth * phdata->NGAGE_ScreenSize.iHeight), User::Panic(_L("SDL"), KErrCorrupt));
__ASSERT_DEBUG(screenMemory >= screenBuffer, User::Panic(_L("SDL"), KErrCorrupt));
__ASSERT_DEBUG(bitmapLine < ((TUint16*)screen->pixels + (screen->w * screen->h)), User::Panic(_L("SDL"), KErrCorrupt));
__ASSERT_DEBUG(bitmapLine >= (TUint16*)screen->pixels, User::Panic(_L("SDL"), KErrCorrupt));
*screenMemoryLinePos++ = *bitmapPos;
bitmapPos += skipValue;
}
bitmapLine += sourceScanlineLength;
screenMemory += targetScanlineLength;
}
}
}
break;
// 256 color paletted mode: 8 bpp --> 12 bpp
default:
{
if(phdata->NGAGE_BytesPerPixel <= 2)
{
TUint8* bitmapLine = (TUint8*)screen->pixels + sourceStartOffset;
TUint16* screenMemory = screenBuffer + targetStartOffset;
for(TInt y = 0 ; y < sourceRectHeight ; y++)
{
TUint8* bitmapPos = bitmapLine; /* 1 byte per pixel */
TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */
/* Convert each pixel from 256 palette to 4k color values */
for(TInt x = 0 ; x < sourceRectWidth ; x++)
{
__ASSERT_DEBUG(screenMemoryLinePos < (screenBuffer + (phdata->NGAGE_ScreenSize.iWidth * phdata->NGAGE_ScreenSize.iHeight)), User::Panic(_L("SDL"), KErrCorrupt));
__ASSERT_DEBUG(screenMemoryLinePos >= screenBuffer, User::Panic(_L("SDL"), KErrCorrupt));
__ASSERT_DEBUG(bitmapPos < ((TUint8*)screen->pixels + (screen->w * screen->h)), User::Panic(_L("SDL"), KErrCorrupt));
__ASSERT_DEBUG(bitmapPos >= (TUint8*)screen->pixels, User::Panic(_L("SDL"), KErrCorrupt));
*screenMemoryLinePos++ = NGAGE_HWPalette_256_to_Screen[*bitmapPos++];
}
bitmapLine += sourceScanlineLength;
screenMemory += targetScanlineLength;
}
}
else
{
TUint8* bitmapLine = (TUint8*)screen->pixels + sourceStartOffset;
TUint32* screenMemory = reinterpret_cast<TUint32*>(screenBuffer + targetStartOffset);
for(TInt y = 0 ; y < sourceRectHeight ; y++)
{
TUint8* bitmapPos = bitmapLine; /* 1 byte per pixel */
TUint32* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */
/* Convert each pixel from 256 palette to 4k color values */
for(TInt x = 0 ; x < sourceRectWidth ; x++)
{
__ASSERT_DEBUG(screenMemoryLinePos < (reinterpret_cast<TUint32*>(screenBuffer) + (phdata->NGAGE_ScreenSize.iWidth * phdata->NGAGE_ScreenSize.iHeight)), User::Panic(_L("SDL"), KErrCorrupt));
__ASSERT_DEBUG(screenMemoryLinePos >= reinterpret_cast<TUint32*>(screenBuffer), User::Panic(_L("SDL"), KErrCorrupt));
__ASSERT_DEBUG(bitmapPos < ((TUint8*)screen->pixels + (screen->w * screen->h)), User::Panic(_L("SDL"), KErrCorrupt));
__ASSERT_DEBUG(bitmapPos >= (TUint8*)screen->pixels, User::Panic(_L("SDL"), KErrCorrupt));
*screenMemoryLinePos++ = NGAGE_HWPalette_256_to_Screen[*bitmapPos++];
}
bitmapLine += sourceScanlineLength;
screenMemory += targetScanlineLength;
}
}
}
}
}
}
void DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
{
SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata;
if (! phdata->NGAGE_IsWindowFocused)
{
SDL_PauseAudio(1);
SDL_Delay(1000);
return;
}
SDL_PauseAudio(0);
TUint16* screenBuffer = (TUint16*)phdata->NGAGE_FrameBuffer;
#if 0
if (phdata->NGAGE_ScreenOrientation == CFbsBitGc::EGraphicsOrientationRotated270)
{
// ...
}
else
#endif
{
DirectDraw(_this, numrects, rects, screenBuffer);
}
//TRect rect2 = TRect(phdata->NGAGE_WsWindow.Size());
for (int i = 0; i < numrects; ++i)
{
TInt aAx = rects[i].x;
TInt aAy = rects[i].y;
TInt aBx = rects[i].w;
TInt aBy = rects[i].h;
TRect rect2 = TRect(aAx, aAy, aBx, aBy);
phdata->NGAGE_DrawDevice->UpdateRegion(rect2); /* Should we update rects parameter area only? */
phdata->NGAGE_DrawDevice->Update();
}
}
void RedrawWindowL(_THIS)
{
SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata;
SDL_Surface *screen = (SDL_Surface*)SDL_GetWindowData(_this->windows, NGAGE_SURFACE);
int w = screen->w;
int h = screen->h;
if (phdata->NGAGE_ScreenOrientation == CFbsBitGc::EGraphicsOrientationRotated270) {
w = screen->h;
h = screen->w;
}
if ((w < phdata->NGAGE_ScreenSize.iWidth)
|| (h < phdata->NGAGE_ScreenSize.iHeight)) {
DrawBackground(_this);
}
/* Tell the system that something has been drawn */
TRect rect = TRect(phdata->NGAGE_WsWindow.Size());
phdata->NGAGE_WsWindow.Invalidate(rect);
/* Draw current buffer */
SDL_Rect fullScreen;
fullScreen.x = 0;
fullScreen.y = 0;
fullScreen.w = screen->w;
fullScreen.h = screen->h;
DirectUpdate(_this, 1, &fullScreen);
}
#endif /* SDL_VIDEO_DRIVER_NGAGE */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,38 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
extern int SDL_NGAGE_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch);
extern int SDL_NGAGE_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects);
extern void SDL_NGAGE_DestroyWindowFramebuffer(_THIS, SDL_Window * window);
/****************************************************************************/
/* Runtime */
/****************************************************************************/
class NGAGE_Runtime
{
public:
IMPORT_C static void GetScreenInfo(TScreenInfoV01& screenInfo2);
};
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,192 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include <stdlib.h>
#ifdef NULL
#undef NULL
#endif
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_NGAGE
#ifdef __cplusplus
extern "C" {
#endif
#include "SDL_video.h"
#include "../SDL_sysvideo.h"
#include "../SDL_pixels_c.h"
#include "../../events/SDL_events_c.h"
#ifdef __cplusplus
}
#endif
#include "SDL_ngagevideo.h"
#include "SDL_ngagewindow.h"
#include "SDL_ngageevents_c.h"
#include "SDL_ngageframebuffer_c.h"
#define NGAGEVID_DRIVER_NAME "ngage"
/* Initialization/Query functions */
static int NGAGE_VideoInit(_THIS);
static int NGAGE_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
static void NGAGE_VideoQuit(_THIS);
/* NGAGE driver bootstrap functions */
static void
NGAGE_DeleteDevice(SDL_VideoDevice * device)
{
SDL_VideoData *phdata = (SDL_VideoData*)device->driverdata;
if (phdata)
{
/* Free Epoc resources */
/* Disable events for me */
if (phdata->NGAGE_WsEventStatus != KRequestPending)
{
phdata->NGAGE_WsSession.EventReadyCancel();
}
if (phdata->NGAGE_RedrawEventStatus != KRequestPending)
{
phdata->NGAGE_WsSession.RedrawReadyCancel();
}
free(phdata->NGAGE_DrawDevice);
if (phdata->NGAGE_WsWindow.WsHandle())
{
phdata->NGAGE_WsWindow.Close();
}
if (phdata->NGAGE_WsWindowGroup.WsHandle())
{
phdata->NGAGE_WsWindowGroup.Close();
}
delete phdata->NGAGE_WindowGc;
phdata->NGAGE_WindowGc = NULL;
delete phdata->NGAGE_WsScreen;
phdata->NGAGE_WsScreen = NULL;
if (phdata->NGAGE_WsSession.WsHandle())
{
phdata->NGAGE_WsSession.Close();
}
SDL_free(phdata);
phdata = NULL;
}
if (device)
{
SDL_free(device);
device = NULL;
}
}
static SDL_VideoDevice *
NGAGE_CreateDevice(int devindex)
{
SDL_VideoDevice *device;
SDL_VideoData *phdata;
/* Initialize all variables that we clean on shutdown */
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
if (!device) {
SDL_OutOfMemory();
return (0);
}
/* Initialize internal N-Gage specific data */
phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
if (! phdata)
{
SDL_OutOfMemory();
SDL_free(device);
return (0);
}
/* General video */
device->VideoInit = NGAGE_VideoInit;
device->VideoQuit = NGAGE_VideoQuit;
device->SetDisplayMode = NGAGE_SetDisplayMode;
device->PumpEvents = NGAGE_PumpEvents;
device->CreateWindowFramebuffer = SDL_NGAGE_CreateWindowFramebuffer;
device->UpdateWindowFramebuffer = SDL_NGAGE_UpdateWindowFramebuffer;
device->DestroyWindowFramebuffer = SDL_NGAGE_DestroyWindowFramebuffer;
device->free = NGAGE_DeleteDevice;
/* "Window" */
device->CreateSDLWindow = NGAGE_CreateWindow;
device->DestroyWindow = NGAGE_DestroyWindow;
/* N-Gage specific data */
device->driverdata = phdata;
return device;
}
VideoBootStrap NGAGE_bootstrap = {
NGAGEVID_DRIVER_NAME, "SDL ngage video driver",
NGAGE_CreateDevice
};
int
NGAGE_VideoInit(_THIS)
{
SDL_DisplayMode mode;
/* Use 12-bpp desktop mode */
mode.format = SDL_PIXELFORMAT_RGB444;
mode.w = 176;
mode.h = 208;
mode.refresh_rate = 0;
mode.driverdata = NULL;
if (SDL_AddBasicVideoDisplay(&mode) < 0) {
return -1;
}
SDL_zero(mode);
SDL_AddDisplayMode(&_this->displays[0], &mode);
/* We're done! */
return 0;
}
static int
NGAGE_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
{
return 0;
}
void
NGAGE_VideoQuit(_THIS)
{
}
#endif /* SDL_VIDEO_DRIVER_NGAGE */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,75 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#ifndef _SDL_ngagevideo_h
#define _SDL_ngagevideo_h
#include "../SDL_sysvideo.h"
#include <e32std.h>
#include <e32svr.h>
#include <bitdev.h>
#include <w32std.h>
#include <bitdraw.h> // CFbsDrawDevice
#define _THIS SDL_VideoDevice *_this
typedef struct SDL_VideoData
{
/* Epoc window server info */
RWsSession NGAGE_WsSession;
RWindowGroup NGAGE_WsWindowGroup;
TInt NGAGE_WsWindowGroupID;
RWindow NGAGE_WsWindow;
CWsScreenDevice* NGAGE_WsScreen;
CWindowGc* NGAGE_WindowGc;
TRequestStatus NGAGE_WsEventStatus;
TRequestStatus NGAGE_RedrawEventStatus;
TWsEvent NGAGE_WsEvent;
//TWsRedrawEvent NGAGE_RedrawEvent;
CFbsDrawDevice* NGAGE_DrawDevice;
TBool NGAGE_IsWindowFocused; /* Not used yet */
/* Screen hardware frame buffer info */
TBool NGAGE_HasFrameBuffer;
TInt NGAGE_BytesPerPixel;
TInt NGAGE_BytesPerScanLine;
TInt NGAGE_BytesPerScreen;
TDisplayMode NGAGE_DisplayMode;
TSize NGAGE_ScreenSize;
TUint8* NGAGE_FrameBuffer;
TPoint NGAGE_ScreenOffset;
CFbsBitGc::TGraphicsOrientation NGAGE_ScreenOrientation;
/* Simulate double screen height */
//TInt NGAGE_ScreenXScaleValue;
//TInt NGAGE_ScreenYScaleValue;
} SDL_VideoData;
#endif /* _SDL_ngagevideo_h */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,129 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_NGAGE
#include "../SDL_sysvideo.h"
#include "SDL_ngagewindow.h"
const TUint32 WindowClientHandle = 9210;
void DisableKeyBlocking(_THIS);
void ConstructWindowL(_THIS);
int
NGAGE_CreateWindow(_THIS, SDL_Window* window)
{
NGAGE_Window* ngage_window = (NGAGE_Window*)SDL_calloc(1, sizeof(NGAGE_Window));
if (!ngage_window) {
return SDL_OutOfMemory();
}
window->driverdata = ngage_window;
if (window->x == SDL_WINDOWPOS_UNDEFINED) {
window->x = 0;
}
if (window->y == SDL_WINDOWPOS_UNDEFINED) {
window->y = 0;
}
ngage_window->sdl_window = window;
ConstructWindowL(_this);
return 0;
}
void
NGAGE_DestroyWindow(_THIS, SDL_Window* window)
{
NGAGE_Window* ngage_window = (NGAGE_Window*)window->driverdata;
if (ngage_window) {
SDL_free(ngage_window);
}
window->driverdata = NULL;
}
/*****************************************************************************/
/* Internal */
/*****************************************************************************/
void DisableKeyBlocking(_THIS)
{
SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata;
TRawEvent event;
event.Set((TRawEvent::TType) /*EDisableKeyBlock*/ 51);
phdata->NGAGE_WsSession.SimulateRawEvent(event);
}
void ConstructWindowL(_THIS)
{
SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata;
TInt error;
error = phdata->NGAGE_WsSession.Connect();
User::LeaveIfError(error);
phdata->NGAGE_WsScreen=new(ELeave) CWsScreenDevice(phdata->NGAGE_WsSession);
User::LeaveIfError(phdata->NGAGE_WsScreen->Construct());
User::LeaveIfError(phdata->NGAGE_WsScreen->CreateContext(phdata->NGAGE_WindowGc));
phdata->NGAGE_WsWindowGroup=RWindowGroup(phdata->NGAGE_WsSession);
User::LeaveIfError(phdata->NGAGE_WsWindowGroup.Construct(WindowClientHandle));
phdata->NGAGE_WsWindowGroup.SetOrdinalPosition(0);
RProcess thisProcess;
TParse exeName;
exeName.Set(thisProcess.FileName(), NULL, NULL);
TBuf<32> winGroupName;
winGroupName.Append(0);
winGroupName.Append(0);
winGroupName.Append(0); // UID
winGroupName.Append(0);
winGroupName.Append(exeName.Name()); // Caption
winGroupName.Append(0);
winGroupName.Append(0); // DOC name
phdata->NGAGE_WsWindowGroup.SetName(winGroupName);
phdata->NGAGE_WsWindow=RWindow(phdata->NGAGE_WsSession);
User::LeaveIfError(phdata->NGAGE_WsWindow.Construct(phdata->NGAGE_WsWindowGroup,WindowClientHandle - 1));
phdata->NGAGE_WsWindow.SetBackgroundColor(KRgbWhite);
phdata->NGAGE_WsWindow.Activate();
phdata->NGAGE_WsWindow.SetSize(phdata->NGAGE_WsScreen->SizeInPixels());
phdata->NGAGE_WsWindow.SetVisible(ETrue);
phdata->NGAGE_WsWindowGroupID = phdata->NGAGE_WsWindowGroup.Identifier();
phdata->NGAGE_IsWindowFocused = EFalse;
DisableKeyBlocking(_this);
}
#endif /* SDL_VIDEO_DRIVER_NGAGE */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,45 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef _SDL_ngagewindow_h
#define _SDL_ngagewindow_h
#include "../SDL_sysvideo.h"
#include "SDL_syswm.h"
#include "SDL_ngagevideo.h"
typedef struct {
SDL_Window* sdl_window;
} NGAGE_Window;
extern int
NGAGE_CreateWindow(_THIS, SDL_Window* window);
extern void
NGAGE_DestroyWindow(_THIS, SDL_Window* window);
#endif /* _SDL_ngagewindow */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,88 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_RISCOS
#include "../../events/SDL_mouse_c.h"
#include <kernel.h>
static SDL_Cursor *
RISCOS_CreateDefaultCursor()
{
SDL_Cursor *cursor;
cursor = SDL_calloc(1, sizeof(*cursor));
if (cursor) {
/* NULL is used to indicate the default cursor */
cursor->driverdata = NULL;
} else {
SDL_OutOfMemory();
}
return cursor;
}
static void
RISCOS_FreeCursor(SDL_Cursor * cursor)
{
SDL_free(cursor);
}
static int
RISCOS_ShowCursor(SDL_Cursor * cursor)
{
if (cursor) {
/* Turn the mouse pointer on */
_kernel_osbyte(106, 1, 0);
} else {
/* Turn the mouse pointer off */
_kernel_osbyte(106, 0, 0);
}
return 0;
}
int
RISCOS_InitMouse(_THIS)
{
SDL_Mouse *mouse = SDL_GetMouse();
/* mouse->CreateCursor = RISCOS_CreateCursor; */
/* mouse->CreateSystemCursor = RISCOS_CreateSystemCursor; */
mouse->ShowCursor = RISCOS_ShowCursor;
mouse->FreeCursor = RISCOS_FreeCursor;
/* mouse->WarpMouse = RISCOS_WarpMouse; */
/* mouse->WarpMouseGlobal = RISCOS_WarpMouseGlobal; */
/* mouse->SetRelativeMouseMode = RISCOS_SetRelativeMouseMode; */
/* mouse->CaptureMouse = RISCOS_CaptureMouse; */
/* mouse->GetGlobalMouseState = RISCOS_GetGlobalMouseState; */
SDL_SetDefaultCursor(RISCOS_CreateDefaultCursor());
return 0;
}
#endif /* SDL_VIDEO_DRIVER_RISCOS */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,30 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#ifndef SDL_riscosmouse_h_
#define SDL_riscosmouse_h_
extern int RISCOS_InitMouse(_THIS);
#endif /* SDL_riscosmouse_h_ */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,235 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_VITA && SDL_VIDEO_VITA_PIB
#include <stdlib.h>
#include <string.h>
#include "SDL_error.h"
#include "SDL_log.h"
#include "SDL_vitavideo.h"
#include "SDL_vitagles_c.h"
/*****************************************************************************/
/* SDL OpenGL/OpenGL ES functions */
/*****************************************************************************/
#define EGLCHK(stmt) \
do { \
EGLint err; \
\
stmt; \
err = eglGetError(); \
if (err != EGL_SUCCESS) { \
SDL_SetError("EGL error %d", err); \
return 0; \
} \
} while (0)
void
VITA_GLES_KeyboardCallback(ScePigletPreSwapData *data)
{
SceCommonDialogUpdateParam commonDialogParam;
SDL_zero(commonDialogParam);
commonDialogParam.renderTarget.colorFormat = data->colorFormat;
commonDialogParam.renderTarget.surfaceType = data->surfaceType;
commonDialogParam.renderTarget.colorSurfaceData = data->colorSurfaceData;
commonDialogParam.renderTarget.depthSurfaceData = data->depthSurfaceData;
commonDialogParam.renderTarget.width = data->width;
commonDialogParam.renderTarget.height = data->height;
commonDialogParam.renderTarget.strideInPixels = data->strideInPixels;
commonDialogParam.displaySyncObject = data->displaySyncObject;
sceCommonDialogUpdate(&commonDialogParam);
}
int
VITA_GLES_LoadLibrary(_THIS, const char *path)
{
pibInit(PIB_SHACCCG | PIB_GET_PROC_ADDR_CORE);
return 0;
}
void *
VITA_GLES_GetProcAddress(_THIS, const char *proc)
{
return eglGetProcAddress(proc);
}
void
VITA_GLES_UnloadLibrary(_THIS)
{
eglTerminate(_this->gl_data->display);
}
static EGLint width = 960;
static EGLint height = 544;
SDL_GLContext
VITA_GLES_CreateContext(_THIS, SDL_Window * window)
{
SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
EGLint attribs[32];
EGLDisplay display;
EGLContext context;
EGLSurface surface;
EGLConfig config;
EGLint num_configs;
PFNEGLPIGLETVITASETPRESWAPCALLBACKSCEPROC preSwapCallback;
int i;
const EGLint contextAttribs[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
EGLCHK(display = eglGetDisplay(0));
EGLCHK(eglInitialize(display, NULL, NULL));
wdata->uses_gles = SDL_TRUE;
window->flags |= SDL_WINDOW_FULLSCREEN;
EGLCHK(eglBindAPI(EGL_OPENGL_ES_API));
i = 0;
attribs[i++] = EGL_RED_SIZE;
attribs[i++] = 8;
attribs[i++] = EGL_GREEN_SIZE;
attribs[i++] = 8;
attribs[i++] = EGL_BLUE_SIZE;
attribs[i++] = 8;
attribs[i++] = EGL_DEPTH_SIZE;
attribs[i++] = 0;
attribs[i++] = EGL_ALPHA_SIZE;
attribs[i++] = 8;
attribs[i++] = EGL_STENCIL_SIZE;
attribs[i++] = 0;
attribs[i++] = EGL_SURFACE_TYPE;
attribs[i++] = 5;
attribs[i++] = EGL_RENDERABLE_TYPE;
attribs[i++] = EGL_OPENGL_ES2_BIT;
attribs[i++] = EGL_CONFORMANT;
attribs[i++] = EGL_OPENGL_ES2_BIT;
attribs[i++] = EGL_NONE;
EGLCHK(eglChooseConfig(display, attribs, &config, 1, &num_configs));
if (num_configs == 0)
{
SDL_SetError("No valid EGL configs for requested mode");
return 0;
}
EGLCHK(surface = eglCreateWindowSurface(display, config, VITA_WINDOW_960X544, NULL));
EGLCHK(context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs));
EGLCHK(eglMakeCurrent(display, surface, surface, context));
EGLCHK(eglQuerySurface(display, surface, EGL_WIDTH, &width));
EGLCHK(eglQuerySurface(display, surface, EGL_HEIGHT, &height));
_this->gl_data->display = display;
_this->gl_data->context = context;
_this->gl_data->surface = surface;
preSwapCallback = (PFNEGLPIGLETVITASETPRESWAPCALLBACKSCEPROC) eglGetProcAddress("eglPigletVitaSetPreSwapCallbackSCE");
preSwapCallback(VITA_GLES_KeyboardCallback);
return context;
}
int
VITA_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
{
if (!eglMakeCurrent(_this->gl_data->display, _this->gl_data->surface,
_this->gl_data->surface, _this->gl_data->context))
{
return SDL_SetError("Unable to make EGL context current");
}
return 0;
}
int
VITA_GLES_SetSwapInterval(_THIS, int interval)
{
EGLBoolean status;
status = eglSwapInterval(_this->gl_data->display, interval);
if (status == EGL_TRUE) {
/* Return success to upper level */
_this->gl_data->swapinterval = interval;
return 0;
}
/* Failed to set swap interval */
return SDL_SetError("Unable to set the EGL swap interval");
}
int
VITA_GLES_GetSwapInterval(_THIS)
{
return _this->gl_data->swapinterval;
}
int
VITA_GLES_SwapWindow(_THIS, SDL_Window * window)
{
if (!eglSwapBuffers(_this->gl_data->display, _this->gl_data->surface)) {
return SDL_SetError("eglSwapBuffers() failed");
}
return 0;
}
void
VITA_GLES_DeleteContext(_THIS, SDL_GLContext context)
{
SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
EGLBoolean status;
if (phdata->egl_initialized != SDL_TRUE) {
SDL_SetError("VITA: GLES initialization failed, no OpenGL ES support");
return;
}
/* Check if OpenGL ES connection has been initialized */
if (_this->gl_data->display != EGL_NO_DISPLAY) {
if (context != EGL_NO_CONTEXT) {
status = eglDestroyContext(_this->gl_data->display, context);
if (status != EGL_TRUE) {
/* Error during OpenGL ES context destroying */
SDL_SetError("VITA: OpenGL ES context destroy error");
return;
}
}
}
return;
}
#endif /* SDL_VIDEO_DRIVER_VITA */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,57 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_vitagles_c_h_
#define SDL_vitagles_c_h_
#include <pib.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include "SDL_vitavideo.h"
typedef struct SDL_GLDriverData {
EGLDisplay display;
EGLContext context;
EGLSurface surface;
uint32_t swapinterval;
}SDL_GLDriverData;
extern void * VITA_GLES_GetProcAddress(_THIS, const char *proc);
extern int VITA_GLES_MakeCurrent(_THIS,SDL_Window * window, SDL_GLContext context);
extern void VITA_GLES_SwapBuffers(_THIS);
extern int VITA_GLES_SwapWindow(_THIS, SDL_Window * window);
extern SDL_GLContext VITA_GLES_CreateContext(_THIS, SDL_Window * window);
extern int VITA_GLES_LoadLibrary(_THIS, const char *path);
extern void VITA_GLES_UnloadLibrary(_THIS);
extern int VITA_GLES_SetSwapInterval(_THIS, int interval);
extern int VITA_GLES_GetSwapInterval(_THIS);
#endif /* SDL_vitagles_c_h_ */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,103 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_VITA && SDL_VIDEO_VITA_PVR
#include <stdlib.h>
#include <string.h>
#include <psp2/kernel/modulemgr.h>
#include <gpu_es4/psp2_pvr_hint.h>
#include "SDL_error.h"
#include "SDL_log.h"
#include "SDL_vitavideo.h"
#include "../SDL_egl_c.h"
#include "SDL_vitagles_pvr_c.h"
#define MAX_PATH 256 // vita limits are somehow wrong
int
VITA_GLES_LoadLibrary(_THIS, const char *path)
{
PVRSRV_PSP2_APPHINT hint;
char* override = SDL_getenv("VITA_MODULE_PATH");
char* skip_init = SDL_getenv("VITA_PVR_SKIP_INIT");
char* default_path = "app0:module";
char target_path[MAX_PATH];
if (skip_init == NULL) // we don't care about actual value
{
if (override != NULL)
{
default_path = override;
}
sceKernelLoadStartModule("vs0:sys/external/libfios2.suprx", 0, NULL, 0, NULL, NULL);
sceKernelLoadStartModule("vs0:sys/external/libc.suprx", 0, NULL, 0, NULL, NULL);
SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libgpu_es4_ext.suprx");
sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL);
SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libIMGEGL.suprx");
sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL);
PVRSRVInitializeAppHint(&hint);
SDL_snprintf(hint.szGLES1, MAX_PATH, "%s/%s", default_path, "libGLESv1_CM.suprx");
SDL_snprintf(hint.szGLES2, MAX_PATH, "%s/%s", default_path, "libGLESv2.suprx");
SDL_snprintf(hint.szWindowSystem, MAX_PATH, "%s/%s", default_path, "libpvrPSP2_WSEGL.suprx");
PVRSRVCreateVirtualAppHint(&hint);
}
return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType) 0, 0);
}
SDL_GLContext
VITA_GLES_CreateContext(_THIS, SDL_Window * window)
{
return SDL_EGL_CreateContext(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
}
int
VITA_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
{
if (window && context) {
return SDL_EGL_MakeCurrent(_this, ((SDL_WindowData *) window->driverdata)->egl_surface, context);
} else {
return SDL_EGL_MakeCurrent(_this, NULL, NULL);
}
}
int
VITA_GLES_SwapWindow(_THIS, SDL_Window * window)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
if (videodata->ime_active) {
sceImeUpdate();
}
return SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
}
#endif /* SDL_VIDEO_DRIVER_VITA && SDL_VIDEO_VITA_PVR */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,35 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_vitagles_pvr_c_h_
#define SDL_vitagles_pvr_c_h_
#include "SDL_vitavideo.h"
extern int VITA_GLES_MakeCurrent(_THIS,SDL_Window * window, SDL_GLContext context);
extern int VITA_GLES_SwapWindow(_THIS, SDL_Window * window);
extern SDL_GLContext VITA_GLES_CreateContext(_THIS, SDL_Window * window);
extern int VITA_GLES_LoadLibrary(_THIS, const char *path);
#endif /* SDL_vitagles_pvr_c_h_ */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1,372 +0,0 @@
// Copyright 2016 Adrien Descamps
// // Distributed under BSD 3-Clause License
#include <lsxintrin.h>
#if YUV_FORMAT == YUV_FORMAT_420
#define READ_Y(y_ptr) \
y = __lsx_vld(y_ptr, 0); \
#define READ_UV \
u_temp = __lsx_vld(u_ptr, 0); \
v_temp = __lsx_vld(v_ptr, 0); \
#else
#error READ_UV unimplemented
#endif
#define PACK_RGBA_32(R1, R2, G1, G2, B1, B2, A1, A2, RGB1, RGB2, \
RGB3, RGB4, RGB5, RGB6, RGB7, RGB8) \
{ \
__m128i ab_l, ab_h, gr_l, gr_h; \
ab_l = __lsx_vilvl_b(B1, A1); \
ab_h = __lsx_vilvh_b(B1, A1); \
gr_l = __lsx_vilvl_b(R1, G1); \
gr_h = __lsx_vilvh_b(R1, G1); \
RGB1 = __lsx_vilvl_h(gr_l, ab_l); \
RGB2 = __lsx_vilvh_h(gr_l, ab_l); \
RGB3 = __lsx_vilvl_h(gr_h, ab_h); \
RGB4 = __lsx_vilvh_h(gr_h, ab_h); \
ab_l = __lsx_vilvl_b(B2, A2); \
ab_h = __lsx_vilvh_b(B2, A2); \
gr_l = __lsx_vilvl_b(R2, G2); \
gr_h = __lsx_vilvh_b(R2, G2); \
RGB5 = __lsx_vilvl_h(gr_l, ab_l); \
RGB6 = __lsx_vilvh_h(gr_l, ab_l); \
RGB7 = __lsx_vilvl_h(gr_h, ab_h); \
RGB8 = __lsx_vilvh_h(gr_h, ab_h); \
}
#define PACK_RGB24_32_STEP(R, G, B, RGB1, RGB2, RGB3) \
RGB1 = __lsx_vilvl_b(G, R); \
RGB1 = __lsx_vshuf_b(B, RGB1, mask1); \
RGB2 = __lsx_vshuf_b(B, G, mask2); \
RGB2 = __lsx_vshuf_b(R, RGB2, mask3); \
RGB3 = __lsx_vshuf_b(R, B, mask4); \
RGB3 = __lsx_vshuf_b(G, RGB3, mask5); \
#define PACK_RGB24_32(R1, R2, G1, G2, B1, B2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6) \
PACK_RGB24_32_STEP(R1, G1, B1, RGB1, RGB2, RGB3); \
PACK_RGB24_32_STEP(R2, G2, B2, RGB4, RGB5, RGB6); \
#if RGB_FORMAT == RGB_FORMAT_RGB24
#define PACK_PIXEL \
__m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6; \
__m128i rgb_7, rgb_8, rgb_9, rgb_10, rgb_11, rgb_12; \
PACK_RGB24_32(r_8_11, r_8_12, g_8_11, g_8_12, b_8_11, b_8_12, \
rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6) \
PACK_RGB24_32(r_8_21, r_8_22, g_8_21, g_8_22, b_8_21, b_8_22, \
rgb_7, rgb_8, rgb_9, rgb_10, rgb_11, rgb_12) \
#elif RGB_FORMAT == RGB_FORMAT_RGBA
#define PACK_PIXEL \
__m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8; \
__m128i rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16; \
__m128i a = __lsx_vldi(0xFF); \
PACK_RGBA_32(r_8_11, r_8_12, g_8_11, g_8_12, b_8_11, b_8_12, a, a, \
rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8) \
PACK_RGBA_32(r_8_21, r_8_22, g_8_21, g_8_22, b_8_21, b_8_22, a, a, \
rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16) \
#elif RGB_FORMAT == RGB_FORMAT_BGRA
#define PACK_PIXEL \
__m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8; \
__m128i rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16; \
__m128i a = __lsx_vldi(0xFF); \
PACK_RGBA_32(b_8_11, b_8_12, g_8_11, g_8_12, r_8_11, r_8_12, a, a, \
rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8) \
PACK_RGBA_32(b_8_21, b_8_22, g_8_21, g_8_22, r_8_21, r_8_22, a, a, \
rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16) \
#elif RGB_FORMAT == RGB_FORMAT_ARGB
#define PACK_PIXEL \
__m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8; \
__m128i rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16; \
__m128i a = __lsx_vldi(0xFF); \
PACK_RGBA_32(a, a, r_8_11, r_8_12, g_8_11, g_8_12, b_8_11, b_8_12, \
rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8) \
PACK_RGBA_32(a, a, r_8_21, r_8_22, g_8_21, g_8_22, b_8_21, b_8_22, \
rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16) \
#elif RGB_FORMAT == RGB_FORMAT_ABGR
#define PACK_PIXEL \
__m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8; \
__m128i rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16; \
__m128i a = __lsx_vldi(0xFF); \
PACK_RGBA_32(a, a, b_8_11, b_8_12, g_8_11, g_8_12, r_8_11, r_8_12, \
rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8) \
PACK_RGBA_32(a, a, b_8_21, b_8_22, g_8_21, g_8_22, r_8_21, r_8_22, \
rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16) \
#else
#error PACK_PIXEL unimplemented
#endif
#define LSX_ST_UB2(in0, in1, pdst, stride) \
{ \
__lsx_vst(in0, pdst, 0); \
__lsx_vst(in1, pdst + stride, 0); \
}
#if RGB_FORMAT == RGB_FORMAT_RGB24 \
#define SAVE_LINE1 \
LSX_ST_UB2(rgb_1, rgb_2, rgb_ptr1, 16); \
LSX_ST_UB2(rgb_3, rgb_4, rgb_ptr1 + 32, 16); \
LSX_ST_UB2(rgb_5, rgb_6, rgb_ptr1 + 64, 16); \
#define SAVE_LINE2 \
LSX_ST_UB2(rgb_7, rgb_8, rgb_ptr2, 16); \
LSX_ST_UB2(rgb_9, rgb_10, rgb_ptr2 + 32, 16); \
LSX_ST_UB2(rgb_11, rgb_12, rgb_ptr2 + 64, 16); \
#elif RGB_FORMAT == RGB_FORMAT_RGBA || RGB_FORMAT == RGB_FORMAT_BGRA || \
RGB_FORMAT == RGB_FORMAT_ARGB || RGB_FORMAT == RGB_FORMAT_ABGR \
#define SAVE_LINE1 \
LSX_ST_UB2(rgb_1, rgb_2, rgb_ptr1, 16); \
LSX_ST_UB2(rgb_3, rgb_4, rgb_ptr1 + 32, 16); \
LSX_ST_UB2(rgb_5, rgb_6, rgb_ptr1 + 64, 16); \
LSX_ST_UB2(rgb_7, rgb_8, rgb_ptr1 + 96, 16); \
#define SAVE_LINE2 \
LSX_ST_UB2(rgb_9, rgb_10, rgb_ptr2, 16); \
LSX_ST_UB2(rgb_11, rgb_12, rgb_ptr2 + 32, 16); \
LSX_ST_UB2(rgb_13, rgb_14, rgb_ptr2 + 64, 16); \
LSX_ST_UB2(rgb_15, rgb_16, rgb_ptr2 + 96, 16); \
#else
#error SAVE_LINE unimplemented
#endif
// = u*vr g=u*ug+v*vg b=u*ub
#define UV2RGB_16(U, V, R1, G1, B1, R2, G2, B2) \
r_temp = __lsx_vmul_h(V, v2r); \
g_temp = __lsx_vmul_h(U, u2g); \
g_temp = __lsx_vmadd_h(g_temp, V, v2g); \
b_temp = __lsx_vmul_h(U, u2b); \
R1 = __lsx_vilvl_h(r_temp, r_temp); \
G1 = __lsx_vilvl_h(g_temp, g_temp); \
B1 = __lsx_vilvl_h(b_temp, b_temp); \
R2 = __lsx_vilvh_h(r_temp, r_temp); \
G2 = __lsx_vilvh_h(g_temp, g_temp); \
B2 = __lsx_vilvh_h(b_temp, b_temp); \
// Y=(Y-shift)*shift R=(Y+R)>>6,G=(Y+G)>>6,B=(B+Y)>>6
#define ADD_Y2RGB_16(Y1, Y2, R1, G1, B1, R2, G2, B2) \
Y1 = __lsx_vsub_h(Y1, shift); \
Y2 = __lsx_vsub_h(Y2, shift); \
Y1 = __lsx_vmul_h(Y1, yf); \
Y2 = __lsx_vmul_h(Y2, yf); \
R1 = __lsx_vadd_h(R1, Y1); \
G1 = __lsx_vadd_h(G1, Y1); \
B1 = __lsx_vadd_h(B1, Y1); \
R2 = __lsx_vadd_h(R2, Y2); \
G2 = __lsx_vadd_h(G2, Y2); \
B2 = __lsx_vadd_h(B2, Y2); \
R1 = __lsx_vsrai_h(R1, PRECISION); \
G1 = __lsx_vsrai_h(G1, PRECISION); \
B1 = __lsx_vsrai_h(B1, PRECISION); \
R2 = __lsx_vsrai_h(R2, PRECISION); \
G2 = __lsx_vsrai_h(G2, PRECISION); \
B2 = __lsx_vsrai_h(B2, PRECISION); \
#define CLIP(in0, in1, in2, in3, in4, in5) \
{ \
in0 = __lsx_vmaxi_h(in0, 0); \
in1 = __lsx_vmaxi_h(in1, 0); \
in2 = __lsx_vmaxi_h(in2, 0); \
in3 = __lsx_vmaxi_h(in3, 0); \
in4 = __lsx_vmaxi_h(in4, 0); \
in5 = __lsx_vmaxi_h(in5, 0); \
in0 = __lsx_vsat_hu(in0, 7); \
in1 = __lsx_vsat_hu(in1, 7); \
in2 = __lsx_vsat_hu(in2, 7); \
in3 = __lsx_vsat_hu(in3, 7); \
in4 = __lsx_vsat_hu(in4, 7); \
in5 = __lsx_vsat_hu(in5, 7); \
}
#define YUV2RGB_32 \
__m128i y, u_temp, v_temp; \
__m128i r_8_11, g_8_11, b_8_11, r_8_21, g_8_21, b_8_21; \
__m128i r_8_12, g_8_12, b_8_12, r_8_22, g_8_22, b_8_22; \
__m128i u, v, r_temp, g_temp, b_temp; \
__m128i r_1, g_1, b_1, r_2, g_2, b_2; \
__m128i y_1, y_2; \
__m128i r_uv_1, g_uv_1, b_uv_1, r_uv_2, g_uv_2, b_uv_2; \
\
READ_UV \
\
/* process first 16 pixels of first line */ \
u = __lsx_vilvl_b(zero, u_temp); \
v = __lsx_vilvl_b(zero, v_temp); \
u = __lsx_vsub_h(u, bias); \
v = __lsx_vsub_h(v, bias); \
UV2RGB_16(u, v, r_1, g_1, b_1, r_2, g_2, b_2); \
r_uv_1 = r_1; g_uv_1 = g_1; b_uv_1 = b_1; \
r_uv_2 = r_2; g_uv_2 = g_2; b_uv_2 = b_2; \
READ_Y(y_ptr1) \
y_1 = __lsx_vilvl_b(zero, y); \
y_2 = __lsx_vilvh_b(zero, y); \
ADD_Y2RGB_16(y_1, y_2, r_1, g_1, b_1, r_2, g_2, b_2) \
CLIP(r_1, g_1, b_1, r_2, g_2, b_2); \
r_8_11 = __lsx_vpickev_b(r_2, r_1); \
g_8_11 = __lsx_vpickev_b(g_2, g_1); \
b_8_11 = __lsx_vpickev_b(b_2, b_1); \
\
/* process first 16 pixels of second line */ \
r_1 = r_uv_1; g_1 = g_uv_1; b_1 = b_uv_1; \
r_2 = r_uv_2; g_2 = g_uv_2; b_2 = b_uv_2; \
\
READ_Y(y_ptr2) \
y_1 = __lsx_vilvl_b(zero, y); \
y_2 = __lsx_vilvh_b(zero, y); \
ADD_Y2RGB_16(y_1, y_2, r_1, g_1, b_1, r_2, g_2, b_2) \
CLIP(r_1, g_1, b_1, r_2, g_2, b_2); \
r_8_21 = __lsx_vpickev_b(r_2, r_1); \
g_8_21 = __lsx_vpickev_b(g_2, g_1); \
b_8_21 = __lsx_vpickev_b(b_2, b_1); \
\
/* process last 16 pixels of first line */ \
u = __lsx_vilvh_b(zero, u_temp); \
v = __lsx_vilvh_b(zero, v_temp); \
u = __lsx_vsub_h(u, bias); \
v = __lsx_vsub_h(v, bias); \
UV2RGB_16(u, v, r_1, g_1, b_1, r_2, g_2, b_2); \
r_uv_1 = r_1; g_uv_1 = g_1; b_uv_1 = b_1; \
r_uv_2 = r_2; g_uv_2 = g_2; b_uv_2 = b_2; \
READ_Y(y_ptr1 + 16 * y_pixel_stride) \
y_1 = __lsx_vilvl_b(zero, y); \
y_2 = __lsx_vilvh_b(zero, y); \
ADD_Y2RGB_16(y_1, y_2, r_1, g_1, b_1, r_2, g_2, b_2) \
CLIP(r_1, g_1, b_1, r_2, g_2, b_2); \
r_8_12 = __lsx_vpickev_b(r_2, r_1); \
g_8_12 = __lsx_vpickev_b(g_2, g_1); \
b_8_12 = __lsx_vpickev_b(b_2, b_1); \
\
/* process last 16 pixels of second line */ \
r_1 = r_uv_1; g_1 = g_uv_1; b_1 = b_uv_1; \
r_2 = r_uv_2; g_2 = g_uv_2; b_2 = b_uv_2; \
\
READ_Y(y_ptr2 + 16 * y_pixel_stride) \
y_1 = __lsx_vilvl_b(zero, y); \
y_2 = __lsx_vilvh_b(zero, y); \
ADD_Y2RGB_16(y_1, y_2, r_1, g_1, b_1, r_2, g_2, b_2) \
CLIP(r_1, g_1, b_1, r_2, g_2, b_2); \
r_8_22 = __lsx_vpickev_b(r_2, r_1); \
g_8_22 = __lsx_vpickev_b(g_2, g_1); \
b_8_22 = __lsx_vpickev_b(b_2, b_1); \
\
void LSX_FUNCTION_NAME(uint32_t width, uint32_t height, const uint8_t *Y,
const uint8_t *U, const uint8_t *V, uint32_t Y_stride,
uint32_t UV_stride, uint8_t *RGB, uint32_t RGB_stride,
YCbCrType yuv_type)
{
const YUV2RGBParam *const param = &(YUV2RGB[yuv_type]);
#if YUV_FORMAT == YUV_FORMAT_420
const int y_pixel_stride = 1;
const int uv_pixel_stride = 1;
const int uv_x_sample_interval = 2;
const int uv_y_sample_interval = 2;
#endif
#if RGB_FORMAT == RGB_FORMAT_RGB565
const int rgb_pixel_stride = 2;
#elif RGB_FORMAT == RGB_FORMAT_RGB24
const int rgb_pixel_stride = 3;
__m128i mask1 = {0x0504110302100100, 0x0A14090813070612};
__m128i mask2 = {0x1808170716061505, 0x00000000000A1909};
__m128i mask3 = {0x0504170302160100, 0x0A1A090819070618};
__m128i mask4 = {0x1E0D1D0C1C0B1B0A, 0x00000000000F1F0E};
__m128i mask5 = {0x05041C03021B0100, 0x0A1F09081E07061D};
#elif RGB_FORMAT == RGB_FORMAT_RGBA || RGB_FORMAT_BGRA || \
RGB_FORMAT == RGB_FORMAT_ARGB || RGB_FORMAT_ABGR
const int rgb_pixel_stride = 4;
#else
#error Unknown RGB pixel size
#endif
uint32_t xpos, ypos;
__m128i v2r = __lsx_vreplgr2vr_h(param->v_r_factor);
__m128i v2g = __lsx_vreplgr2vr_h(param->v_g_factor);
__m128i u2g = __lsx_vreplgr2vr_h(param->u_g_factor);
__m128i u2b = __lsx_vreplgr2vr_h(param->u_b_factor);
__m128i bias = __lsx_vreplgr2vr_h(128);
__m128i shift = __lsx_vreplgr2vr_h(param->y_shift);
__m128i yf = __lsx_vreplgr2vr_h(param->y_factor);
__m128i zero = __lsx_vldi(0);
if (width >= 32) {
for (ypos = 0; ypos < (height - (uv_y_sample_interval - 1)); ypos += uv_y_sample_interval) {
const uint8_t *y_ptr1 = Y + ypos * Y_stride,
*y_ptr2 = Y + (ypos + 1) * Y_stride,
*u_ptr = U + (ypos/uv_y_sample_interval) * UV_stride,
*v_ptr = V + (ypos/uv_y_sample_interval) * UV_stride;
uint8_t *rgb_ptr1 = RGB + ypos * RGB_stride,
*rgb_ptr2 = RGB + (ypos + 1) * RGB_stride;
for (xpos = 0; xpos < (width - 31); xpos += 32){
YUV2RGB_32
{
PACK_PIXEL
SAVE_LINE1
if (uv_y_sample_interval > 1)
{
SAVE_LINE2
}
}
y_ptr1 += 32 * y_pixel_stride;
y_ptr2 += 32 * y_pixel_stride;
u_ptr += 32 * uv_pixel_stride/uv_x_sample_interval;
v_ptr += 32 * uv_pixel_stride/uv_x_sample_interval;
rgb_ptr1 += 32 * rgb_pixel_stride;
rgb_ptr2 += 32 * rgb_pixel_stride;
}
}
if (uv_y_sample_interval == 2 && ypos == (height - 1)) {
const uint8_t *y_ptr = Y + ypos * Y_stride,
*u_ptr = U + (ypos/uv_y_sample_interval) * UV_stride,
*v_ptr = V + (ypos/uv_y_sample_interval) * UV_stride;
uint8_t *rgb_ptr = RGB + ypos * RGB_stride;
STD_FUNCTION_NAME(width, 1, y_ptr, u_ptr, v_ptr, Y_stride, UV_stride, rgb_ptr, RGB_stride, yuv_type);
}
}
{
int converted = (width & ~31);
if (converted != width)
{
const uint8_t *y_ptr = Y + converted * y_pixel_stride,
*u_ptr = U + converted * uv_pixel_stride / uv_x_sample_interval,
*v_ptr = V + converted * uv_pixel_stride / uv_x_sample_interval;
uint8_t *rgb_ptr = RGB + converted * rgb_pixel_stride;
STD_FUNCTION_NAME(width-converted, height, y_ptr, u_ptr, v_ptr, Y_stride, UV_stride, rgb_ptr, RGB_stride, yuv_type);
}
}
}
#undef LSX_FUNCTION_NAME
#undef STD_FUNCTION_NAME
#undef YUV_FORMAT
#undef RGB_FORMAT
#undef LSX_ALIGNED
#undef LSX_ST_UB2
#undef UV2RGB_16
#undef ADD_Y2RGB_16
#undef PACK_RGB24_32_STEP
#undef PACK_RGB24_32
#undef PACK_PIXEL
#undef PACK_RGBA_32
#undef SAVE_LINE1
#undef SAVE_LINE2
#undef READ_Y
#undef READ_UV
#undef YUV2RGB_32