endif
ifeq ($(CONF_HD), 1)
CPPFLAGS += -DCONF_HD=1
- OBJS += platform/sdlvhildon.o
+ LDLIBS += -lSDL_haa
CONF_EXIT_BUTTON ?= 1
endif
ifeq ($(CONF_HGW), 1)
+drnoksnes (1.2.6) unstable; urgency=low
+
+ * Using SDL_haa for scaling in Fremantle now.
+
+ -- Javier S. Pedro <maemo@javispedro.com> Thu, 21 Jan 2010 18:44:34 +0100
+
drnoksnes (1.2.5) unstable; urgency=low
* Changed a lot of the build system.
float ScaleX, ScaleY;
} GUI;
void S9xVideoToggleFullscreen();
-void S9xVideoOutputFocus(bool hasFocus);
// Audio output
void S9xInitAudioOutput();
+++ /dev/null
-#ifndef _PLATFORM_SCALER_H_
-#define _PLATFORM_SCALER_H_
-
-class Scaler
-{
-public:
- Scaler() { };
- virtual ~Scaler() { };
-
- virtual const char * getName() const = 0;
-
- virtual uint8* getDrawBuffer() const = 0;
- virtual unsigned int getDrawBufferPitch() const = 0;
- virtual void getRenderedGUIArea(unsigned short & x, unsigned short & y,
- unsigned short & w, unsigned short & h)
- const = 0;
- virtual void getRatio(float & x, float & y) const = 0;
- virtual void prepare() = 0;
- virtual void finish() = 0;
- virtual void pause() = 0;
- virtual void resume() = 0;
-};
-
-class ScalerFactory
-{
-public:
- ScalerFactory() { };
- virtual ~ScalerFactory() { };
- virtual const char * getName() const = 0;
- virtual bool canEnable(int bpp, int w, int h) const = 0;
- virtual Scaler* instantiate(SDL_Surface* screen, int w, int h) const = 0;
-};
-
-const ScalerFactory* searchForScaler(int bpp, int w, int h);
-
-#endif
#include "platform.h"
#include "snes9x.h"
#include "display.h"
+#include "sdlv.h" // Dispatching video-related events
struct TouchButton {
unsigned short mask;
{
switch (event.type)
{
- case SDL_KEYDOWN:
- if (Config.action[event.key.keysym.scancode])
- S9xDoAction(Config.action[event.key.keysym.scancode]);
- joypads[0] |= Config.joypad1Mapping[event.key.keysym.scancode];
- break;
- case SDL_KEYUP:
- joypads[0] &= ~Config.joypad1Mapping[event.key.keysym.scancode];
- break;
- case SDL_MOUSEBUTTONUP:
- case SDL_MOUSEBUTTONDOWN:
- processMouse(event.button.x, event.button.y,
- (event.button.state == SDL_PRESSED) ? 1 : - 1);
- break;
- case SDL_MOUSEMOTION:
- processMouse(event.motion.x, event.motion.y);
- break;
- case SDL_ACTIVEEVENT:
- if (event.active.state & SDL_APPINPUTFOCUS) {
- S9xVideoOutputFocus(event.active.gain);
- }
- break;
- case SDL_QUIT:
- Config.quitting = true;
- break;
+ case SDL_KEYDOWN:
+ if (Config.action[event.key.keysym.scancode])
+ S9xDoAction(Config.action[event.key.keysym.scancode]);
+ joypads[0] |= Config.joypad1Mapping[event.key.keysym.scancode];
+ break;
+ case SDL_KEYUP:
+ joypads[0] &= ~Config.joypad1Mapping[event.key.keysym.scancode];
+ break;
+ case SDL_MOUSEBUTTONUP:
+ case SDL_MOUSEBUTTONDOWN:
+ processMouse(event.button.x, event.button.y,
+ (event.button.state == SDL_PRESSED) ? 1 : - 1);
+ break;
+ case SDL_MOUSEMOTION:
+ processMouse(event.motion.x, event.motion.y);
+ break;
+ case SDL_QUIT:
+ Config.quitting = true;
+ break;
+ case SDL_ACTIVEEVENT:
+ case SDL_SYSWMEVENT:
+ processVideoEvent(event);
+ break;
}
}
#include "gfx.h"
#include "ppu.h"
#include "sdlv.h"
-#include "scaler.h"
#define DIE(format, ...) do { \
fprintf(stderr, "Died at %s:%d: ", __FILE__, __LINE__ ); \
static bool gotWindowSize, gotScreenSize;
/** The current scaler object */
-static Scaler* scaler;
+Scaler* scaler;
static void calculateScreenSize()
{
GUI.Height = gameHeight;
#endif
#if CONF_EXIT_BUTTON
- exitReset();
+ ExitBtnReset();
#endif
// Safeguard
SDL_ShowCursor(SDL_DISABLE);
-#if CONF_HD
- hdSetupFullscreen(Config.fullscreen);
-#endif
-
scaler = sFactory->instantiate(screen, gameWidth, gameHeight);
// We get pitch surface values from SDL
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
DIE("SDL_InitSubSystem(VIDEO): %s", SDL_GetError());
-#if CONF_HD
- hdSetup();
-#endif
-
setupVideoSurface();
drawOnscreenControls();
}
drawOnscreenControls();
}
-void S9xVideoOutputFocus(bool hasFocus)
+void processVideoEvent(const SDL_Event& event)
{
-#if MAEMO
- if (scaler) {
- if (hasFocus) {
- scaler->resume();
- } else {
- scaler->pause();
- }
- }
-#endif
+ if (scaler)
+ scaler->filter(event);
}
// This is here for completeness, but palette mode is useless on N8x0
scaler->finish();
#if CONF_EXIT_BUTTON
- if (exitRequiresDraw()) {
+ if (ExitBtnRequiresDraw()) {
scaler->pause();
- exitDraw(screen);
- SDL_Flip(screen);
+ ExitBtnDraw(screen);
scaler->resume();
}
#endif
#include <SDL.h>
-extern SDL_Surface* screen;
-
-#if CONF_HD
-# include <SDL_syswm.h>
-# include <X11/Xatom.h>
-# define HDATOM(X) hdAtomsValues[ ATOM ## X ]
-
-enum hdAtoms {
- ATOM_HILDON_NON_COMPOSITED_WINDOW = 0,
- ATOM_HILDON_STACKABLE_WINDOW,
- ATOM_NET_WM_STATE,
- ATOM_NET_WM_STATE_FULLSCREEN,
- ATOM_NET_WM_WINDOW_TYPE,
- ATOM_NET_WM_WINDOW_TYPE_NORMAL,
- ATOM_NET_WM_WINDOW_TYPE_DIALOG,
- ATOM_HILDON_WM_WINDOW_TYPE_ANIMATION_ACTOR,
- ATOM_HILDON_ANIMATION_CLIENT_READY,
- ATOM_HILDON_ANIMATION_CLIENT_MESSAGE_SHOW,
- ATOM_HILDON_ANIMATION_CLIENT_MESSAGE_POSITION,
- ATOM_HILDON_ANIMATION_CLIENT_MESSAGE_ROTATION,
- ATOM_HILDON_ANIMATION_CLIENT_MESSAGE_SCALE,
- ATOM_HILDON_ANIMATION_CLIENT_MESSAGE_ANCHOR,
- ATOM_HILDON_ANIMATION_CLIENT_MESSAGE_PARENT,
- ATOM_HILDON_WM_WINDOW_TYPE_REMOTE_TEXTURE,
- ATOM_HILDON_TEXTURE_CLIENT_MESSAGE_SHM,
- ATOM_HILDON_TEXTURE_CLIENT_MESSAGE_DAMAGE,
- ATOM_HILDON_TEXTURE_CLIENT_MESSAGE_SHOW,
- ATOM_HILDON_TEXTURE_CLIENT_MESSAGE_POSITION,
- ATOM_HILDON_TEXTURE_CLIENT_MESSAGE_OFFSET,
- ATOM_HILDON_TEXTURE_CLIENT_MESSAGE_SCALE,
- ATOM_HILDON_TEXTURE_CLIENT_MESSAGE_PARENT,
- ATOM_HILDON_TEXTURE_CLIENT_READY,
- ATOM_COUNT
+class Scaler
+{
+public:
+ Scaler() { };
+ virtual ~Scaler() { };
+
+ virtual const char * getName() const = 0;
+
+ virtual uint8* getDrawBuffer() const = 0;
+ virtual unsigned int getDrawBufferPitch() const = 0;
+ virtual void getRenderedGUIArea(unsigned short& x, unsigned short& y,
+ unsigned short& w, unsigned short& h)
+ const = 0;
+ virtual void getRatio(float& x, float& y) const = 0;
+
+ virtual void prepare() = 0;
+ virtual void finish() = 0;
+ virtual void pause() = 0;
+ virtual void resume() = 0;
+ virtual bool filter(const SDL_Event& event) = 0;
};
-extern Atom hdAtomsValues[];
+class ScalerFactory
+{
+public:
+ ScalerFactory() { };
+ virtual ~ScalerFactory() { };
+ virtual const char * getName() const = 0;
+ virtual bool canEnable(int bpp, int w, int h) const = 0;
+ virtual Scaler* instantiate(SDL_Surface* screen, int w, int h) const = 0;
+};
-extern SDL_SysWMinfo WMinfo;
+const ScalerFactory* searchForScaler(int bpp, int w, int h);
-void hdSetup();
-void hdSetNonCompositing(bool enable);
-void hdSetupFullscreen(bool enable);
+/** SDL screen */
+extern SDL_Surface* screen;
+/** The current scaler object */
+extern Scaler* scaler;
-#endif
+void processVideoEvent(const SDL_Event& event);
-#if defined(MAEMO) && MAEMO_VERSION >= 5
-void exitReset();
-bool exitRequiresDraw();
-void exitDraw(SDL_Surface* where);
+#if CONF_EXIT_BUTTON
+void ExitBtnReset();
+bool ExitBtnRequiresDraw();
+void ExitBtnDraw(SDL_Surface* where);
#endif
#endif
#include "platform.h"
#include "sdlv.h"
+#define BACK_BUTTON_IMG_PATH \
+ "/usr/share/icons/hicolor/scalable/hildon/general_overlay_back.png"
+
#define DIE(format, ...) do { \
fprintf(stderr, "Died at %s:%d: ", __FILE__, __LINE__ ); \
fprintf(stderr, format "\n", ## __VA_ARGS__); \
static unsigned long frameCounter = 0;
-void exitReset()
+void ExitBtnReset()
{
frameCounter = 0;
if (!buttonSrf) {
- buttonSrf = IMG_Load("/usr/share/icons/hicolor/scalable/hildon/general_overlay_back.png");
+ buttonSrf = IMG_Load(BACK_BUTTON_IMG_PATH);
}
buttonRect.x = GUI.Width - buttonSrf->w;
buttonRect.h = buttonSrf->h;
}
-bool exitRequiresDraw()
+bool ExitBtnRequiresDraw()
{
if (!Config.fullscreen) return false;
if (frameCounter > totalAnimLen) {
};
-void exitDraw(SDL_Surface* where)
+void ExitBtnDraw(SDL_Surface* where)
{
SDL_BlitSurface(buttonSrf, 0, where, &buttonRect);
+ SDL_UpdateRects(where, 1, &buttonRect);
};
+++ /dev/null
-#if CONF_HD
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/Xatom.h>
-#include <SDL.h>
-#include <SDL_syswm.h>
-
-#include "sdlv.h"
-#include "hgw.h"
-
-#define DIE(format, ...) do { \
- fprintf(stderr, "Died at %s:%d: ", __FILE__, __LINE__ ); \
- fprintf(stderr, format "\n", ## __VA_ARGS__); \
- abort(); \
- } while (0);
-
-static const char * hdAtomNames[] = {
- "_HILDON_NON_COMPOSITED_WINDOW",
- "_HILDON_STACKABLE_WINDOW",
- "_NET_WM_STATE",
- "_NET_WM_STATE_FULLSCREEN",
- "_NET_WM_WINDOW_TYPE",
- "_NET_WM_WINDOW_TYPE_NORMAL",
- "_NET_WM_WINDOW_TYPE_DIALOG",
- "_HILDON_WM_WINDOW_TYPE_ANIMATION_ACTOR",
- "_HILDON_ANIMATION_CLIENT_READY",
- "_HILDON_ANIMATION_CLIENT_MESSAGE_SHOW",
- "_HILDON_ANIMATION_CLIENT_MESSAGE_POSITION",
- "_HILDON_ANIMATION_CLIENT_MESSAGE_ROTATION",
- "_HILDON_ANIMATION_CLIENT_MESSAGE_SCALE",
- "_HILDON_ANIMATION_CLIENT_MESSAGE_ANCHOR",
- "_HILDON_ANIMATION_CLIENT_MESSAGE_PARENT",
- "_HILDON_WM_WINDOW_TYPE_REMOTE_TEXTURE",
- "_HILDON_TEXTURE_CLIENT_MESSAGE_SHM",
- "_HILDON_TEXTURE_CLIENT_MESSAGE_DAMAGE",
- "_HILDON_TEXTURE_CLIENT_MESSAGE_SHOW",
- "_HILDON_TEXTURE_CLIENT_MESSAGE_POSITION",
- "_HILDON_TEXTURE_CLIENT_MESSAGE_OFFSET",
- "_HILDON_TEXTURE_CLIENT_MESSAGE_SCALE",
- "_HILDON_TEXTURE_CLIENT_MESSAGE_PARENT",
- "_HILDON_TEXTURE_CLIENT_READY",
- ""
-};
-
-static bool hd_ok = false;
-
-Atom hdAtomsValues[ATOM_COUNT];
-
-SDL_SysWMinfo WMinfo;
-
-static void hd_setup_stackable_window();
-
-void hdSetup()
-{
- SDL_VERSION(&WMinfo.version);
- if (!SDL_GetWMInfo(&WMinfo)) {
- DIE("Bad SDL version");
- }
-
- Display * display = WMinfo.info.x11.display;
-
- if (!hd_ok) {
- XInternAtoms(display, (char**)hdAtomNames, ATOM_COUNT, True, hdAtomsValues);
-
- if (HDATOM(_HILDON_NON_COMPOSITED_WINDOW) == None) {
- printf("Hildon Desktop seems not be loaded, since %s is not defined",
- "_HILDON_NON_COMPOSITED_WINDOW");
- return;
- }
-
- if (hgwLaunched || true) {
- hd_setup_stackable_window();
- }
-
- hd_ok = true;
- }
-};
-
-/** Enables or disables the Hildon NonCompositedWindow property */
-void hdSetNonCompositing(bool enable)
-{
- Display *display;
- Window window;
- int one = 1;
-
- WMinfo.info.x11.lock_func();
- display = WMinfo.info.x11.display;
- window = WMinfo.info.x11.fswindow;
-
- if (enable) {
- XUnmapWindow(display, window);
- XChangeProperty(display, window, HDATOM(_HILDON_NON_COMPOSITED_WINDOW),
- XA_INTEGER, 32, PropModeReplace,
- (unsigned char *) &one, 1);
- XMapWindow(display, window);
- } else {
- XDeleteProperty(display, window,
- HDATOM(_HILDON_NON_COMPOSITED_WINDOW));
- }
-
- WMinfo.info.x11.unlock_func();
-}
-
-static Atom get_window_type(Display *dpy, Window win)
-{
- Atom window_type = None;
- Atom actual_type;
- int actual_format;
- unsigned long nitems, bytes_after;
- unsigned char *prop_return = NULL;
-
- if(Success == XGetWindowProperty(dpy, win, HDATOM(_NET_WM_WINDOW_TYPE),
- 0L, sizeof(Atom),
- False, XA_ATOM, &actual_type,
- &actual_format, &nitems, &bytes_after,
- &prop_return) && prop_return) {
- window_type = *(Atom *)prop_return;
- XFree(prop_return);
- }
-
- return window_type;
-}
-
-static Window find_launcher_window(Display *display, Window start)
-{
- Window root, parent, *children;
- unsigned int count, i;
-
- if (XQueryTree(display, start, &root, &parent, &children, &count)) {
- XClassHint class_hints;
- for (i = 0; i < count; i++) {
- Window cur = children[i];
- Window sub = find_launcher_window(display, cur);
- if (sub) return sub;
-
- if (XGetClassHint(display, cur, &class_hints)) {
- if (strcasecmp(class_hints.res_class, "drnoksnes_startup") == 0) {
- XFree(class_hints.res_name);
- XFree(class_hints.res_class);
-
- if (get_window_type(display, cur) !=
- HDATOM(_NET_WM_WINDOW_TYPE_NORMAL)) {
- continue;
- }
-
- XFree(children);
-
- return cur;
- }
- XFree(class_hints.res_name);
- XFree(class_hints.res_class);
- }
- }
- XFree(children);
- }
-
- return 0;
-}
-
-/** Finds the drnoksnes_startup window. */
-static Window find_launcher_window(Display *display)
-{
- return find_launcher_window(display,
- RootWindow(display, DefaultScreen(display)));
-}
-
-/** Converts the aux SDL windows into tops of the HildonWindowStack */
-static void hd_setup_stackable_window()
-{
- Display *display;
- Window window;
- Atom atom;
- XWMHints *hints;
- XClassHint *chint;
- XSetWindowAttributes xattr;
- int one = 1;
-
-#if 0
- WMinfo.info.x11.lock_func();
- display = WMinfo.info.x11.display;
-
- Window launcher = find_launcher_window(display);
-
- if (!launcher) {
- printf("HD: Games startup window was not found\n");
- return;
- }
-
- hints = XGetWMHints(display, launcher);
- //hints->input = True;
- hints->flags = (hints->flags & WindowGroupHint)/* | InputHint*/;
-
- chint = XAllocClassHint();
- chint->res_name = chint->res_class = strdup("drnoksnes");
-
- window = WMinfo.info.x11.fswindow;
- XSetTransientForHint(display, window, launcher);
- XSetWMHints(display, window, hints);
- XSetClassHint(display, window, chint);
- atom = HDATOM(_NET_WM_WINDOW_TYPE_NORMAL);
- XChangeProperty(display, window, HDATOM(_NET_WM_WINDOW_TYPE),
- XA_ATOM, 32, PropModeReplace,
- (unsigned char *) &atom, 1);
- xattr.override_redirect = False;
- XChangeWindowAttributes(display, window, CWOverrideRedirect, &xattr);
- atom = HDATOM(_NET_WM_STATE_FULLSCREEN);
- XChangeProperty(display, window, HDATOM(_NET_WM_STATE),
- XA_ATOM, 32, PropModeReplace,
- (unsigned char *) &atom, 1);
- XChangeProperty(display, window, HDATOM(_HILDON_STACKABLE_WINDOW),
- XA_INTEGER, 32, PropModeReplace,
- (unsigned char *) &one, 1);
-
- free(chint->res_name);
- XFree(chint);
- XFree(hints);
-
- WMinfo.info.x11.unlock_func();
-#endif
-}
-
-void hdSetupFullscreen(bool enable)
-{
- Display *display = WMinfo.info.x11.display;
- Window window = WMinfo.info.x11.wmwindow;
-
-#if 0
- WMinfo.info.x11.lock_func();
-
- /* So we hide the SDL nonfullscreen window when in fullscreen mode. */
- if (enable) {
- XUnmapWindow(display, window);
- } else {
- XMapWindow(display, window);
- }
-
- WMinfo.info.x11.unlock_func();
-#endif
-}
-
-#endif
# include <X11/extensions/Xsp.h>
#endif
#if CONF_HD
-# include <X11/Xatom.h>
-# include <sys/ipc.h>
-# include <sys/shm.h>
+# include <SDL_haa.h>
#endif
#include "snes9x.h"
#include "display.h"
#include "platform.h"
-#include "scaler.h"
#include "sdlv.h"
#define DIE(format, ...) do { \
virtual void pause() { };
virtual void resume() { };
+
+ virtual bool filter(const SDL_Event& event) { return false; };
};
const DummyScaler::Factory DummyScaler::factory;
void pause() { };
void resume() { };
+
+ bool filter(const SDL_Event& event) { return false; };
};
const SWScaler::Factory SWScaler::factory;
void pause() { };
void resume() { };
+ bool filter(const SDL_Event& event) { return false; };
};
const ARMScaler::Factory ARMScaler::factory;
#endif
#if CONF_HD
-
-class HDScalerBase : public Scaler
+class HAAScalerBase : public Scaler
{
- SDL_Surface * m_screen;
+ SDL_Surface *m_screen;
SDL_Rect m_area;
+ HAA_Actor *actor;
const int m_w, m_h, m_Bpp;
const float ratio_x, ratio_y;
- // SDL/X11 stuff we save for faster access.
- Display* display;
- Window window;
-
- // Shared memory segment info.
- key_t shmkey;
- int shmid;
- void *shmaddr;
-
-private:
- /** Sends a message to hildon-desktop.
- * This function comes mostly straight from libhildon.
- */
- void sendMessage(Atom message_type,
- uint32 l0, uint32 l1, uint32 l2, uint32 l3, uint32 l4)
- {
- XEvent event = { 0 };
-
- event.xclient.type = ClientMessage;
- event.xclient.window = window;
- event.xclient.message_type = message_type;
- event.xclient.format = 32;
- event.xclient.data.l[0] = l0;
- event.xclient.data.l[1] = l1;
- event.xclient.data.l[2] = l2;
- event.xclient.data.l[3] = l3;
- event.xclient.data.l[4] = l4;
-
- XSendEvent (display, window, True,
- StructureNotifyMask,
- (XEvent *)&event);
- }
-
- /** Sends all configuration parameters for the remote texture. */
- void reconfigure()
- {
- Window parent;
- int yoffset = 0;
- if (Config.fullscreen) {
- parent = WMinfo.info.x11.fswindow;
- } else {
- parent = WMinfo.info.x11.wmwindow;
- yoffset = 60; // Hardcode the title bar size for now.
- }
-
- sendMessage(HDATOM(_HILDON_TEXTURE_CLIENT_MESSAGE_SHM),
- (uint32) shmkey, m_w, m_h, m_Bpp, 0);
- sendMessage(HDATOM(_HILDON_TEXTURE_CLIENT_MESSAGE_PARENT),
- (uint32) parent, 0, 0, 0, 0);
- sendMessage(HDATOM(_HILDON_TEXTURE_CLIENT_MESSAGE_POSITION),
- m_area.x, yoffset + m_area.y, m_area.w, m_area.h, 0);
- sendMessage(HDATOM(_HILDON_TEXTURE_CLIENT_MESSAGE_SCALE),
- ratio_x * (1 << 16), ratio_y * (1 << 16), 0, 0, 0);
- sendMessage(HDATOM(_HILDON_TEXTURE_CLIENT_MESSAGE_SHOW),
- 1, 255, 0, 0, 0);
- }
-
protected:
- HDScalerBase(SDL_Surface* screen, int w, int h, float r_x, float r_y)
+ HAAScalerBase(SDL_Surface* screen, int w, int h, float r_x, float r_y)
: m_screen(screen), m_w(w), m_h(h),
m_Bpp(m_screen->format->BitsPerPixel / 8),
ratio_x(r_x), ratio_y(r_y)
{
centerRectangle(m_area, GUI.Width, GUI.Height, w * r_x, h * r_y);
- // What we're going to do:
- // - Create a new window that we're going to manage
- // - Set up that window as a Hildon Remote Texture
- // - Render to that new window, instead of the SDL window ("screen").
- // Yet another load of uglyness, but hey.
-
// Clear the SDL screen with black, just in case it gets drawn.
SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
- display = WMinfo.info.x11.display;
-
- // The parent window needs to be mapped, so we sync it.
- XSync(display, True);
-
- // Create our alternative window.
- const int blackColor = BlackPixel(display, DefaultScreen(display));
- window = XCreateSimpleWindow(display, DefaultRootWindow(display),
- 0, 0, m_w, m_h, 0, blackColor, blackColor);
- XStoreName(display, window, "DrNokSnes Video output window");
- Atom atom = HDATOM(_HILDON_WM_WINDOW_TYPE_REMOTE_TEXTURE);
- XChangeProperty(display, window, HDATOM(_NET_WM_WINDOW_TYPE),
- XA_ATOM, 32, PropModeReplace,
- (unsigned char *) &atom, 1);
- XSelectInput(display, window, PropertyChangeMask | StructureNotifyMask);
- XMapWindow(display, window);
-
- // Wait for "ready" property, set up by hildon-desktop after a while
- // For now, loop here. In the future, merge with main event loop.
- bool ready = false;
- while (!ready) {
- XEvent e;
- XNextEvent(display, &e);
- switch(e.type) {
- case PropertyNotify:
- if (e.xproperty.atom ==
- HDATOM(_HILDON_TEXTURE_CLIENT_READY)) {
- ready = true;
- }
- break;
- default:
- break;
- }
- }
-
- // Create a shared memory segment with hildon-desktop
- shmkey = ftok(S9xGetFilename(FILE_ROM), 'v');
- shmid = shmget(shmkey, m_w * m_h * m_Bpp, IPC_CREAT | 0777);
- if (shmid < 0) {
- DIE("Failed to create shared memory");
- }
- shmaddr = shmat(shmid, 0, 0);
- if (shmaddr == (void*)-1) {
- DIE("Failed to attach shared memory");
- }
-
- // Send all configuration events to hildon-desktop
- reconfigure();
+ HAA_Init(m_screen->flags & SDL_FULLSCREEN);
+ actor = HAA_CreateActor(0, m_w, m_h, m_screen->format->BitsPerPixel);
+ HAA_SetPosition(actor, m_area.x, m_area.y + 60);
+ HAA_SetScale(actor, r_x, r_y);
+ HAA_Show(actor);
}
public:
- virtual ~HDScalerBase()
- {
- // Hide, unparent and deattach the remote texture
- sendMessage(HDATOM(_HILDON_TEXTURE_CLIENT_MESSAGE_SHOW),
- 0, 255, 0, 0, 0);
- sendMessage(HDATOM(_HILDON_TEXTURE_CLIENT_MESSAGE_PARENT),
- 0, 0, 0, 0, 0);
- sendMessage(HDATOM(_HILDON_TEXTURE_CLIENT_MESSAGE_SHM),
- 0, 0, 0, 0, 0);
- XFlush(display);
- // Destroy our managed window and shared memory segment
- XDestroyWindow(display, window);
- XSync(display, True);
- shmdt(shmaddr);
- shmctl(shmid, IPC_RMID, 0);
+ virtual ~HAAScalerBase()
+ {
+ HAA_FreeActor(actor);
+ HAA_Quit();
};
- virtual uint8* getDrawBuffer() const
+ uint8* getDrawBuffer() const
{
- return reinterpret_cast<uint8*>(shmaddr);
+ return reinterpret_cast<uint8*>(actor->surface->pixels);
};
- virtual unsigned int getDrawBufferPitch() const
+ unsigned int getDrawBufferPitch() const
{
- return m_w * m_Bpp;
+ return actor->surface->pitch;
};
- virtual void getRenderedGUIArea(unsigned short & x, unsigned short & y,
+ void getRenderedGUIArea(unsigned short & x, unsigned short & y,
unsigned short & w, unsigned short & h) const
{
x = m_area.x; y = m_area.y; w = m_area.w; h = m_area.h;
};
- virtual void getRatio(float & x, float & y) const
+ void getRatio(float & x, float & y) const
{
x = ratio_x; y = ratio_y;
};
- virtual void prepare()
+ void prepare()
{
};
- virtual void finish()
+ void finish()
{
- // Send a damage event to hildon-desktop.
- sendMessage(HDATOM(_HILDON_TEXTURE_CLIENT_MESSAGE_DAMAGE),
- 0, 0, m_w, m_h, 0);
- XSync(display, False);
+ HAA_Flip(actor);
};
- virtual void pause() { };
- virtual void resume() { };
-};
-
-class HDFillScaler : public HDScalerBase
-{
- HDFillScaler(SDL_Surface* screen, int w, int h)
- : HDScalerBase(screen, w, h,
- GUI.Width / (float)w, GUI.Height / (float)h)
- {
- }
+ void pause() { };
+ void resume() { };
-public:
- class Factory : public ScalerFactory
+ bool filter(const SDL_Event& event)
{
- const char * getName() const
- {
- return "hdfill";
- }
-
- bool canEnable(int bpp, int w, int h) const
- {
- return true;
- }
-
- Scaler* instantiate(SDL_Surface* screen, int w, int h) const
- {
- return new HDFillScaler(screen, w, h-20);
- }
+ return HAA_FilterEvent(&event) == 0;
};
-
- static const Factory factory;
-
- virtual const char * getName() const
- {
- return "hildon-desktop fill screen scaling";
- }
};
-const HDFillScaler::Factory HDFillScaler::factory;
-class HDSquareScaler : public HDScalerBase
+class HAAFillScaler : public HAAScalerBase
{
- HDSquareScaler(SDL_Surface* screen, int w, int h, float ratio)
- : HDScalerBase(screen, w, h, ratio, ratio)
+ HAAFillScaler(SDL_Surface* screen, int w, int h)
+ : HAAScalerBase(screen, w, h,
+ GUI.Width / (float)w, GUI.Height / (float)h)
{
}
{
const char * getName() const
{
- return "hdsq";
+ return "haafill";
}
bool canEnable(int bpp, int w, int h) const
Scaler* instantiate(SDL_Surface* screen, int w, int h) const
{
- return new HDSquareScaler(screen, w, h,
- fminf(GUI.Width / (float)w, GUI.Height / (float)h));
- }
- };
-
- static const Factory factory;
-
- virtual const char * getName() const
- {
- return "hildon-desktop square screen scaling";
- }
-};
-const HDSquareScaler::Factory HDSquareScaler::factory;
-
-class HDDummy : public DummyScaler
-{
- HDDummy(SDL_Surface* screen, int w, int h)
- : DummyScaler(screen, w, h)
- {
- hdSetNonCompositing(true);
- }
-
-public:
- ~HDDummy()
- {
- hdSetNonCompositing(false);
- };
-
- class Factory : public ScalerFactory
- {
- const char * getName() const
- {
- return "hddummy";
- }
-
- bool canEnable(int bpp, int w, int h) const
- {
- return Config.fullscreen; // This makes sense only in fullscreen
- }
-
- Scaler* instantiate(SDL_Surface* screen, int w, int h) const
- {
- return new HDDummy(screen, w, h);
+ return new HAAFillScaler(screen, w, h-20);
}
};
const char * getName() const
{
- return "compositor disabled and no scaling";
+ return "HAA fill screen scaling";
}
};
-const HDDummy::Factory HDDummy::factory;
+const HAAFillScaler::Factory HAAFillScaler::factory;
-class HDSW : public SWScaler
+class HAASquareScaler : public HAAScalerBase
{
- HDSW(SDL_Surface* screen, int w, int h)
- : SWScaler(screen, w, h)
+ HAASquareScaler(SDL_Surface* screen, int w, int h, float ratio)
+ : HAAScalerBase(screen, w, h, ratio, ratio)
{
- hdSetNonCompositing(true);
}
-
-public:
- ~HDSW()
- {
- hdSetNonCompositing(false);
- };
-
- class Factory : public ScalerFactory
- {
- const char * getName() const
- {
- return "hdsoft2x";
- }
-
- bool canEnable(int bpp, int w, int h) const
- {
- return Config.fullscreen; // This makes sense only in fullscreen
- }
- Scaler* instantiate(SDL_Surface* screen, int w, int h) const
- {
- return new HDSW(screen, w, h);
- }
- };
-
- static const Factory factory;
-
- const char * getName() const
- {
- return "compositor disabled and software 2x scaling";
- }
-};
-const HDSW::Factory HDSW::factory;
-
-#ifdef __arm__
-class HDARM : public ARMScaler
-{
- HDARM(SDL_Surface* screen, int w, int h)
- : ARMScaler(screen, w, h)
- {
- hdSetNonCompositing(true);
- }
-
public:
- ~HDARM()
- {
- hdSetNonCompositing(false);
- };
-
class Factory : public ScalerFactory
{
const char * getName() const
{
- return "hdarm2x";
+ return "haasq";
}
bool canEnable(int bpp, int w, int h) const
{
- return Config.fullscreen; // This makes sense only in fullscreen
+ return true;
}
Scaler* instantiate(SDL_Surface* screen, int w, int h) const
{
- return new HDARM(screen, w, h);
+ return new HAASquareScaler(screen, w, h,
+ fminf(GUI.Width / (float)w, GUI.Height / (float)h));
}
};
const char * getName() const
{
- return "compositor disabled and software ARM 2x scaling";
+ return "HAA square screen scaling";
}
};
-const HDARM::Factory HDARM::factory;
-#endif /* __arm__ */
+const HAASquareScaler::Factory HAASquareScaler::factory;
+
#endif /* CONF_HD */
#if CONF_XSP
{
m_should_enable = true; // Will enable later
};
+
+ bool filter(const SDL_Event& event)
+ {
+ if (event.type == SDL_ACTIVEEVENT) {
+ if (scaler && (event.active.state & SDL_APPINPUTFOCUS)) {
+ if (event.active.gain)
+ scaler->resume();
+ else
+ scaler->pause();
+
+ return true;
+ }
+ }
+
+ return false;
+ };
};
const XSPScaler::Factory XSPScaler::factory;
#endif
static const ScalerFactory* scalers[] = {
/* More useful scalers come first */
-#if CONF_HD && defined(__arm__)
- &HDARM::factory, /* non-composited arm 2x scaling */
-#endif
-#if CONF_HD
- &HDSquareScaler::factory, /* h-d assisted square scaling */
- &HDSW::factory, /* non-composited soft 2x scaling */
-#endif
#if CONF_XSP
&XSPScaler::factory, /* n8x0 pixel doubling */
#endif
#ifdef __arm__
&ARMScaler::factory, /* arm 2x scaling */
#endif
- &SWScaler::factory, /* soft 2x scaling */
#if CONF_HD
- &HDDummy::factory, /* non composited */
+ &HAASquareScaler::factory, /* n900 animation actor scaling */
#endif
+ &SWScaler::factory, /* soft 2x scaling */
&DummyScaler::factory, /* failsafe */
/* The following scalers will not be automatically enabled, no matter what */
#if CONF_HD
- &HDFillScaler::factory,
+ &HAAFillScaler::factory,
#endif
};