summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmakefile.voodoo3
-rw-r--r--src/KeySend.cpp99
-rw-r--r--src/KeySend.h24
-rw-r--r--src/Main.cxx63
-rw-r--r--src/SourceWin32.cxx214
-rw-r--r--src/classes.cpp4047
-rw-r--r--src/classes.h6
-rw-r--r--vnchooks.dllbin0 -> 131000 bytes
8 files changed, 332 insertions, 4124 deletions
diff --git a/makefile.voodoo b/makefile.voodoo
index 544daf7..2d7f4b9 100755
--- a/makefile.voodoo
+++ b/makefile.voodoo
@@ -19,7 +19,8 @@ LDADD += -lgdi32 -luser32 -lversion libscreenhooks.a
OBJECTS += \
src/videodriver.o \
- src/videodrivercheck.o
+ src/videodrivercheck.o \
+ src/KeySend.o
SOURCE = SourceWin32.cxx
diff --git a/src/KeySend.cpp b/src/KeySend.cpp
new file mode 100644
index 0000000..cfd7f3c
--- /dev/null
+++ b/src/KeySend.cpp
@@ -0,0 +1,99 @@
+#include <windows.h>
+#include <winuser.h>
+#include <stdio.h>
+
+#include "KeySend.h"
+
+CKeySend::CKeySend()
+{
+}
+
+CKeySend::~CKeySend()
+{
+}
+
+
+void CKeySend::SendKeyDown(unsigned char bVk)
+{
+ BYTE bScan = LOBYTE(::MapVirtualKey(bVk, 0));
+ DWORD dwFlags = (IsVkExtended(bVk) ? KEYEVENTF_EXTENDEDKEY : 0 );
+ KeyboardEvent(bVk,bScan,dwFlags);
+}
+
+void CKeySend::SendKeyUp(unsigned char bVk)
+{
+ BYTE bScan = LOBYTE(::MapVirtualKey(bVk, 0));
+ DWORD dwFlags = (IsVkExtended(bVk) ? KEYEVENTF_EXTENDEDKEY : 0 ) | KEYEVENTF_KEYUP;
+ KeyboardEvent(bVk,bScan,dwFlags);
+}
+
+void CKeySend::KeyboardEvent(unsigned char bVk, unsigned char bScan, unsigned long dwFlags)
+{
+ ::keybd_event(bVk, bScan, dwFlags, 0);
+}
+
+bool CKeySend::IsVkExtended(unsigned char bVk)
+{
+ bool bExtended = false;
+ if( (bVk == VK_UP ) ||
+ (bVk == VK_DOWN ) ||
+ (bVk == VK_LEFT ) ||
+ (bVk == VK_RIGHT ) ||
+ (bVk == VK_HOME ) ||
+ (bVk == VK_END ) ||
+ (bVk == VK_PRIOR ) ||
+ (bVk == VK_NEXT ) ||
+ (bVk == VK_INSERT ) ||
+ (bVk == VK_DELETE ) ||
+ (bVk == VK_UP ) )
+ {
+ bExtended = true;
+ }
+ return bExtended;
+
+}
+
+int CKeySend::MapDfbKeyEventToVK(unsigned short symbol)
+{
+ switch(symbol)
+ {
+ case 0xF000 : return VK_LEFT;
+ case 0xF001 : return VK_RIGHT;
+ case 0xF002 : return VK_UP;
+ case 0xF003 : return VK_DOWN;
+ case 0xF00b : return VK_RETURN;
+
+ case 0xF046 : return VK_PRIOR; //p+
+ case 0xF047 : return VK_NEXT; //p-
+
+ case 0xF050 : return -1; // play
+ case 0xF05A : return -1; // FF
+ case 0xF059 : return -1; // rew
+ case 0xF052 : return -1; // stop
+ case 0xF056 : return -1; // REC
+
+ case 0xF05B : return VK_BACK; // back key
+
+ case 0xF042 : return -1; // Red
+ case 0xF043 : return -1; // Green
+ case 0xF045 : return -1; // Blue
+
+ case 0xF011 : return -1; // options
+ case 0xF032 : return -1; // teletext
+ case 0xF014 : return -1; // info
+
+ case 0x0030 : return 0x30; // 0-9
+ case 0x0031 : return 0x31; // 0-9
+ case 0x0032 : return 0x32; // 0-9
+ case 0x0033 : return 0x33; // 0-9
+ case 0x0034 : return 0x34; // 0-9
+ case 0x0035 : return 0x35; // 0-9
+ case 0x0036 : return 0x36; // 0-9
+ case 0x0037 : return 0x37; // 0-9
+ case 0x0038 : return 0x38; // 0-9
+ case 0x0039 : return 0x39; // 0-9
+ default:
+ return -1;
+ }
+ return -1;
+}
diff --git a/src/KeySend.h b/src/KeySend.h
new file mode 100644
index 0000000..463875b
--- /dev/null
+++ b/src/KeySend.h
@@ -0,0 +1,24 @@
+#ifndef __KEYSEND_f493f2a0_8f4b_11df_a4ee_0800200c9a66__
+#define __KEYSEND_f493f2a0_8f4b_11df_a4ee_0800200c9a66__
+
+
+class CKeySend
+{
+public:
+ CKeySend();
+ ~CKeySend();
+
+public:
+ static void SendKeyDown(unsigned char bVk);
+ static void SendKeyUp(unsigned char bVk);
+ static void KeyboardEvent(unsigned char bVk, unsigned char bScan, unsigned long dwFlags);
+
+public:
+ static int MapDfbKeyEventToVK(unsigned short symbol);
+
+private:
+ static bool IsVkExtended(unsigned char bVk);
+};
+
+
+#endif
diff --git a/src/Main.cxx b/src/Main.cxx
index 10013d8..20e7d2c 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -3,7 +3,7 @@ namespace PluggIt {
D_DEBUG_DOMAIN( PluggIt_Main, "PluggIt/Main", "PluggIt Main" );
D_DEBUG_DOMAIN( PluggIt_View, "PluggIt/View", "PluggIt View" );
-class Main extends View
+class Main extends View, Runnable
{
class Config {
public DFBDimension m_size;
@@ -73,7 +73,26 @@ class Main extends View
initDFB();
initSource();
- run();
+ Thread *thread = new Thread( this, "Main" );
+
+ thread->start();
+
+ while (true) {
+ DFBEvent event;
+
+ m_events.WaitForEvent();
+
+ m_events.GetEvent( &event );
+
+ switch (event.clazz) {
+ case DFEC_WINDOW:
+ handleWindowEvent( &event.window );
+ break;
+
+ default:
+ break;
+ }
+ }
}
catch (DFBException *e) {
cerr << endl;
@@ -87,6 +106,32 @@ class Main extends View
}
}
+ public void handleWindowEvent( const DFBWindowEvent *event ) {
+ int key = -1;
+ bool up = false;
+
+ switch (event->type) {
+ case DWET_KEYUP:
+ up = true;
+
+ case DWET_KEYDOWN:
+ key = CKeySend::MapDfbKeyEventToVK( event->key_symbol );
+ break;
+
+ default:
+ break;
+ }
+
+ if (key != -1) {
+ D_INFO( "Sending key %d (%s)\n", key, up ? "up" : "down" );
+
+ if (up)
+ CKeySend::SendKeyUp( key );
+ else
+ CKeySend::SendKeyDown( key );
+ }
+ }
+
private void initDFB() {
D_DEBUG_AT( PluggIt_Main, "%s()\n", __FUNCTION__ );
@@ -122,7 +167,19 @@ class Main extends View
}
private void run() {
- m_source->MainLoop();
+ try {
+ m_source->MainLoop();
+ }
+ catch (DFBException *e) {
+ cerr << endl;
+ cerr << "Caught exception!" << endl;
+ cerr << " ==> " << e << endl;
+ }
+ catch (Exception *e) {
+ cerr << endl;
+ cerr << "Caught exception!" << endl;
+ cerr << " ==> " << e << endl;
+ }
}
public virtual void config( DFBDimension &source_resolution ) {
diff --git a/src/SourceWin32.cxx b/src/SourceWin32.cxx
index 25ac45b..620bb01 100644
--- a/src/SourceWin32.cxx
+++ b/src/SourceWin32.cxx
@@ -5,7 +5,13 @@ D_DEBUG_DOMAIN( PluggIt_SourceWin32, "PluggIt/SourceWin32", "PluggIt Source Win3
#include "ScreenHooks.h"
-const UINT specIpcCode = RegisterWindowMessage("HOOK.MESSAGE.CODE");
+// Constants
+const UINT RFB_SCREEN_UPDATE = RegisterWindowMessage("WinVNC.Update.DrawRect");
+const UINT RFB_COPYRECT_UPDATE = RegisterWindowMessage("WinVNC.Update.CopyRect");
+const UINT RFB_MOUSE_UPDATE = RegisterWindowMessage("WinVNC.Update.Mouse");
+const char szDesktopSink[] = "WinVNC desktop sink";
+
+typedef BOOL (*SetHooksFn)(DWORD thread_id,UINT UpdateMsg,UINT CopyMsg,UINT MouseMsg,BOOL ddihook);
class SourceWin32 extends Source, Runnable
@@ -41,6 +47,9 @@ class SourceWin32 extends Source, Runnable
private pthread_cond_t m_cond;
+ SetHooksFn SetHooks;
+
+
public class Config extends Source::Config {
friend class SourceWin32;
@@ -168,48 +177,6 @@ class SourceWin32 extends Source, Runnable
pthread_cond_init( &m_cond, NULL );
- if (!m_using_driver) {
- HWND w;
-
- WNDCLASSEX wndClass;
-
- ZeroMemory( &wndClass, sizeof(wndClass) );
-
- wndClass.cbSize = sizeof(wndClass);
- wndClass.style = CS_HREDRAW | CS_VREDRAW;
- wndClass.lpfnWndProc = MsgWndProc;
- wndClass.cbClsExtra = 0;
- wndClass.cbWndExtra = 0;
- wndClass.hInstance = GetModuleHandle(NULL);
- wndClass.hIcon = NULL;
- wndClass.hIconSm = NULL;
- wndClass.hCursor = LoadCursor( NULL, IDC_UPARROW );
- wndClass.hbrBackground = (HBRUSH) GetStockObject( NULL_BRUSH );
- wndClass.lpszMenuName = NULL;
- wndClass.lpszClassName = "MsgWindow";
-
- if (!RegisterClassEx( &wndClass ))
- throw new Exception( "RegisterClassEx() failed!" );
-
-
- w = CreateWindowEx( 0,
- "MsgWindow",
- "MsgWindow",
- WS_POPUP,// | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_BORDER,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- 1,
- 1,
- NULL,
- NULL,
- GetModuleHandle(NULL),
- this );
-
- if (!setHook( w ))
- throw new Exception( "Failed to set hooks!" );
- }
-
-
/* Create the thread object. */
m_thread = new Thread( this, "SourceWin32" );
@@ -318,19 +285,19 @@ class SourceWin32 extends Source, Runnable
long long last_time = direct_clock_get_abs_millis();
while (!m_thread->isInterrupted()) {
- if (((const Config&)m_config).m_updating) {
+/* if (((const Config&)m_config).m_updating) {
usleep( 100000 );
queueUpdate( 0, 0, m_size.w - 1, m_size.h - 1 );
pthread_mutex_lock( &m_lock );
}
- else {
+ else*/ {
pthread_mutex_lock( &m_lock );
if (m_updates.num_regions() == 0)
- usleep( 10000 );
- //pthread_cond_wait( &m_cond, &m_lock );
+ //usleep( 10000 );
+ pthread_cond_wait( &m_cond, &m_lock );
}
if (direct_clock_get_abs_millis() - last_time > 2000) {
@@ -339,7 +306,7 @@ class SourceWin32 extends Source, Runnable
m_size.w - 1,
m_size.h - 1 );
- m_updates.addRegion( region );
+ //m_updates.addRegion( region );
last_time = direct_clock_get_abs_millis();
}
@@ -378,9 +345,9 @@ class SourceWin32 extends Source, Runnable
m_updates.addRegion( damage );
- pthread_mutex_unlock( &m_lock );
-
pthread_cond_signal( &m_cond );
+
+ pthread_mutex_unlock( &m_lock );
}
private bool flushUpdates( vector<DFBRectangle_C> &rects ) {
@@ -600,37 +567,49 @@ class SourceWin32 extends Source, Runnable
/**********************************************************************************************************************/
- static LRESULT CALLBACK MsgWndProc( HWND hwnd, // handle to window
- UINT uMsg, // message identifier
- WPARAM wParam, // first message parameter
- LPARAM lParam ) // second message parameter
+ static LRESULT CALLBACK DesktopWndProc( HWND hwnd, // handle to window
+ UINT uMsg, // message identifier
+ WPARAM wParam, // first message parameter
+ LPARAM lParam ) // second message parameter
{
- static SourceWin32 *thiz;
- CREATESTRUCT *create;
+ PCOPYDATASTRUCT CDS;
+ SourceWin32 *thiz = (SourceWin32*)GetWindowLong(hwnd, GWL_USERDATA);
switch (uMsg) {
- case WM_CREATE:
- create = reinterpret_cast<LPCREATESTRUCT>( lParam );
- thiz = reinterpret_cast<SourceWin32 *>( create->lpCreateParams );
- break;
-
case WM_DESTROY:
PostQuitMessage( 0 );
break;
- default:
- if (uMsg == specIpcCode) {
- int x1 = wParam >> 16;
- int y1 = wParam & 0xffff;
- int x2 = lParam >> 16;
- int y2 = lParam & 0xffff;
+ case WM_COPYDATA:
+ CDS = (PCOPYDATASTRUCT) lParam;
+
+ if (CDS->dwData==112233) {
+ DWORD mysize = CDS->cbData;
+ char mytext[1024];
+ char *myptr;
+ char split[4][6];
+
+ strcpy( mytext, (LPCSTR) CDS->lpData );
- if (x1 < x2 && y1 < y2)
- thiz->queueUpdate( x1, y1, x2 - 1, y2 - 1 );
+ myptr = mytext;
+
+ for (int j =0; j<(mysize/20);j++) {
+ for (int i=0;i<4;i++) {
+ strcpy(split[i]," ");
+ strncpy(split[i],myptr,4);
+ myptr = myptr+5;
+ }
+
+ thiz->queueUpdate( atoi(split[0]),
+ atoi(split[1]),
+ atoi(split[2]) - 1,
+ atoi(split[3]) - 1 );
+ }
- break;
}
+ break;
+ default:
return DefWindowProc( hwnd, uMsg, wParam, lParam );
}
@@ -638,13 +617,102 @@ class SourceWin32 extends Source, Runnable
}
public virtual int MainLoop() {
+
+ if (!m_using_driver) {
+ HMODULE hModule;
+ char szCurrentDir[MAX_PATH];
+
+ if (GetModuleFileName(NULL, szCurrentDir, MAX_PATH)) {
+ char* p = strrchr(szCurrentDir, '\\');
+ if (p == NULL) return 0;
+ *p = '\0';
+ strcat (szCurrentDir,"\\vnchooks.dll");
+ }
+
+ hModule = LoadLibrary( szCurrentDir );
+ if (!hModule)
+ throw new Exception( "Failed to load vnchooks.dll!" );
+
+ SetHooks = (SetHooksFn) GetProcAddress( hModule, "SetHooks" );
+
+
+
+
+
+ HWND w;
+
+ WNDCLASSEX wndClass;
+
+ ZeroMemory( &wndClass, sizeof(wndClass) );
+
+ wndClass.cbSize = sizeof(wndClass);
+ wndClass.style = 0;
+ wndClass.lpfnWndProc = DesktopWndProc;
+ wndClass.cbClsExtra = 0;
+ wndClass.cbWndExtra = 0;
+ wndClass.hInstance = GetModuleHandle(NULL);
+ wndClass.hIcon = NULL;
+ wndClass.hIconSm = NULL;
+ wndClass.hCursor = NULL;
+ wndClass.hbrBackground = (HBRUSH) GetStockObject( WHITE_BRUSH );
+ wndClass.lpszMenuName = NULL;
+ wndClass.lpszClassName = szDesktopSink;
+
+ if (!RegisterClassEx( &wndClass ))
+ throw new Exception( "RegisterClassEx() failed!" );
+
+
+ w = CreateWindowEx( 0,
+ szDesktopSink,
+ "WinVNC",
+ WS_OVERLAPPEDWINDOW,
+ CW_USEDEFAULT,
+ CW_USEDEFAULT,
+ 400, 200,
+ NULL,
+ NULL,
+ GetModuleHandle(NULL),
+ NULL );
+ if (!w)
+ throw new Exception( "Failed to create hook window!" );
+
+ // Set the "this" pointer for the window
+ SetWindowLong( w, GWL_USERDATA, (long)this);
+
+ if (!SetHooks(
+ GetCurrentThreadId(),
+ RFB_SCREEN_UPDATE,
+ RFB_COPYRECT_UPDATE,
+ RFB_MOUSE_UPDATE, false
+ ))
+ throw new Exception( "Failed to set hooks!" );
+ }
+
+
MSG msg;
- while (GetMessage( &msg, 0, 0, 0 )) {
- TranslateMessage( &msg );
- DispatchMessage( &msg );
+ printf( " -> RFB_SCREEN_UPDATE = %u\n", RFB_SCREEN_UPDATE );
+ printf( " -> RFB_COPYRECT_UPDATE = %u\n", RFB_COPYRECT_UPDATE );
+
+ while (WaitMessage()/*GetMessage( &msg, 0, 0, 0 )*/) {
+ printf( " -> Dispatching event (id %u)...\n", msg.message );
+
+ if (PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE)) {
+ if (msg.message == RFB_SCREEN_UPDATE) {
+ queueUpdate( (SHORT)LOWORD(msg.wParam),
+ (SHORT)HIWORD(msg.wParam),
+ (SHORT)LOWORD(msg.lParam) - 1,
+ (SHORT)HIWORD(msg.lParam) - 1 );
+ }
+ else {
+ TranslateMessage( &msg );
+ DispatchMessage( &msg );
+ }
+ }
}
+ printf( " -> EXIT!\n" );
+
return 0;
}
};
diff --git a/src/classes.cpp b/src/classes.cpp
deleted file mode 100644
index a0ecb67..0000000
--- a/src/classes.cpp
+++ /dev/null
@@ -1,4047 +0,0 @@
-# 1 "classes.h"
-#define DIRECT_ENABLE_DEBUG
-
-
-#include <iostream>
-#include <vector>
-
-using namespace std;
-
-
-/*
- * ++DFB
- */
-#include <++dfb.h>
-
-
-
-/*
- * Direct
- */
-extern "C" {
-#include <stdarg.h>
-
-#include <direct/clock.h>
-#include <direct/debug.h>
-#include <direct/memcpy.h>
-#include <direct/messages.h>
-#include <direct/thread.h>
-#include <direct/util.h>
-
-#include <gfx/convert.h>
-}
-
-
-/*
- * Win32
- */
-#ifdef __WIN32__
-#define CreateWindow CreateWindowWin32
-#include <windows.h>
-#include <wingdi.h>
-#include <winuser.h>
-#include "videodriver.h"
-#undef CreateWindow
-
-#else
-
-/*
- * X11
- */
-extern "C" {
-#include <X11/Xlib.h> /* fundamentals X datas structures */
-#include <X11/Xutil.h> /* datas definitions for various functions */
-#include <X11/keysym.h> /* for a perfect use of keyboard events */
-#include <X11/Xatom.h>
-#include <X11/cursorfont.h>
-
-#include <X11/extensions/XShm.h>
-#include <X11/extensions/Xdamage.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-}
-
-#endif
-
-class Exception;
-class OutOfMemoryException;
-class Clock;
-class FPS;
-class Options;
-class Random;
-class Updates;
-class Runnable;
-class Thread;
-class Scaler;
-class View;
-class Source;
-class SourceWin32;
-class Main;
-# 1 "Exception.cxx"
-# 1 "<built-in>"
-# 1 "<command-line>"
-# 1 "Exception.cxx"
-namespace PluggIt {
-
-class Exception
-{
- private: string m_message;
-
-
- public: Exception( string message ) {
- m_message = message;
- }
-
- public: Exception( const char *format, ... ) D_FORMAT_PRINTF(2) {
- va_list args;
- int len;
- char buf[200];
- char *ptr = buf;
-
- va_start( args, format );
- len = vsnprintf( buf, sizeof(buf), format, args );
- va_end( args );
-
- if (len < 0)
- abort();
-
- if (len >= (int)sizeof(buf)) {
- ptr = (char*) malloc( len+1 );
- if (!ptr)
- abort();
-
- va_start( args, format );
- len = vsnprintf( ptr, len+1, format, args );
- va_end( args );
-
- if (len < 0) {
- free( ptr );
- abort();
- }
- }
-
- m_message = string( ptr );
-
- if (ptr != buf)
- free( ptr );
- }
-
- public: string getMessage() {
- return m_message;
- }
-
-
- friend std::ostream &operator << (std::ostream &stream, Exception *ex) {
- stream << ex->getMessage();
-
- return stream;
- }
-};
-
-}
-# 1 "OutOfMemoryException.cxx"
-# 1 "<built-in>"
-# 1 "<command-line>"
-# 1 "OutOfMemoryException.cxx"
-namespace PluggIt {
-
-class OutOfMemoryException :public Exception
-{
- public: OutOfMemoryException() : Exception( "Out of memory!" ) {
- }
-};
-
-}
-# 1 "Clock.cxx"
-# 1 "<built-in>"
-# 1 "<command-line>"
-# 1 "Clock.cxx"
-namespace PluggIt {
-
-class Clock
-{
- private: long long base;
- private: char str[20];
-
- public: Clock() {
- Reset();
- }
-
- public: void Reset() {
- base = direct_clock_get_micros();
- }
-
- public: float GetTime() {
- return (direct_clock_get_micros() - base) / 1000000.0f;
- }
-
- public: const char *GetString() {
- float time = GetTime();
- int seconds = (int) time;
- int minutes = seconds / 60;
-
- snprintf( str, sizeof(str), "%02d:%02d", minutes, seconds );
-
- return str;
- }
-};
-
-}
-# 1 "FPS.cxx"
-# 1 "<built-in>"
-# 1 "<command-line>"
-# 1 "FPS.cxx"
-namespace PluggIt {
-
-class FPS
-{
- private: int frames;
- private: char str[20];
-
- private: Clock clock;
-
-
- public: FPS() {
- Reset();
- }
-
- public: void Reset() {
- frames = 0;
- str[0] = 0;
-
- clock.Reset();
- }
-
- public: void Count( float interval ) {
- float time = clock.GetTime();
-
- frames++;
-
- if (time >= interval) {
- float fps = frames / time;
-
- snprintf( str, sizeof(str), "%.1f", fps );
-
- frames = 0;
- clock.Reset();
- }
- }
-
- public: const char *GetFPS() {
- return str;
- }
-};
-
-}
-# 1 "Options.cxx"
-# 1 "<built-in>"
-# 1 "<command-line>"
-# 1 "Options.cxx"
-namespace PluggIt {
-
-static const DirectFBPixelFormatNames(m_formats);
-
-class Options
-{
- class Option {
- friend class Options;
-
- protected: const char *m_short_name;
- protected: const char *m_long_name;
- protected: const char *m_arg_name;
- protected: const char *m_arg_desc;
- protected: bool m_need_arg;
-
- public: Option( const char *short_name,
- const char *long_name,
- const char *arg_name,
- const char *arg_desc )
- {
- m_short_name = short_name;
- m_long_name = long_name;
- m_arg_name = arg_name;
- m_arg_desc = arg_desc;
- m_need_arg = true;
- }
-
- public: virtual bool Parse( const char *arg ) = 0;
- };
-
- public: class OptionBool :public Option {
- private: bool &m_value;
-
- public: OptionBool( const char *short_name,
- const char *long_name,
- const char *arg_name,
- const char *arg_desc,
- bool &value ) : Option( short_name, long_name, arg_name, arg_desc ), m_value( value )
- {
- m_need_arg = false;
- }
-
- public: virtual bool Parse( const char *arg ) {
- m_value = true;
-
- return true;
- }
- };
-
- public: class OptionLong :public Option {
- private: long &m_value;
- private: int m_base;
-
- public: OptionLong( const char *short_name,
- const char *long_name,
- const char *arg_name,
- const char *arg_desc,
- long &value,
- int base = 10 ) : Option( short_name, long_name, arg_name, arg_desc ), m_value( value )
- {
- m_base = base;
- }
-
- public: virtual bool Parse( const char *arg ) {
- long ret;
- char *end;
-
- ret = strtol( arg, &end, m_base );
-
- if (*end) {
- D_ERROR( "Option/Long: Invalid argument to '%s' or '%s'!\n", m_short_name, m_long_name );
- return false;
- }
-
- m_value = ret;
-
- return true;
- }
- };
-
- public: class OptionULong :public Option {
- private: unsigned long &m_value;
- private: int m_base;
-
- public: OptionULong( const char *short_name,
- const char *long_name,
- const char *arg_name,
- const char *arg_desc,
- unsigned long &value,
- int base = 10 ) : Option( short_name, long_name, arg_name, arg_desc ), m_value( value )
- {
- m_base = base;
- }
-
- public: virtual bool Parse( const char *arg ) {
- unsigned long ret;
- char *end;
-
- ret = strtoul( arg, &end, m_base );
-
- if (*end) {
- D_ERROR( "Option/ULong: Invalid argument to '%s' or '%s'!\n", m_short_name, m_long_name );
- return false;
- }
-
- m_value = ret;
-
- return true;
- }
- };
-
- public: class OptionFormat :public Option {
- private: DFBSurfacePixelFormat &m_value;
-
- public: OptionFormat( const char *short_name,
- const char *long_name,
- const char *arg_name,
- const char *arg_desc,
- DFBSurfacePixelFormat &value ) : Option( short_name, long_name, arg_name, arg_desc ), m_value( value )
- {
- }
-
- public: virtual bool Parse( const char *arg ) {
- unsigned int i;
-
- for (i=0; i<D_ARRAY_SIZE(m_formats); i++) {
- if (!strcasecmp( m_formats[i].name, arg )) {
- m_value = m_formats[i].format;
-
- return true;
- }
- }
-
- D_ERROR( "Option/Format: Unknown format '%s' passed to '%s' or '%s'!\n", arg, m_short_name, m_long_name );
-
- return false;
- }
- };
-
- public: class OptionString :public Option {
- private: std::string &m_value;
-
- public: OptionString( const char *short_name,
- const char *long_name,
- const char *arg_name,
- const char *arg_desc,
- std::string &value ) : Option( short_name, long_name, arg_name, arg_desc ), m_value( value )
- {
- }
-
- public: virtual bool Parse( const char *arg ) {
- m_value = arg;
- return true;
- }
- };
-
- public: class OptionPoint :public Option {
- private: DFBPoint &m_value;
-
- public: OptionPoint( const char *short_name,
- const char *long_name,
- const char *arg_name,
- const char *arg_desc,
- DFBPoint &value ) : Option( short_name, long_name, arg_name, arg_desc ), m_value( value )
- {
- }
-
- public: virtual bool Parse( const char *arg ) {
- if (sscanf( arg, "%d,%d", &m_value.x, &m_value.y ) != 2) {
- D_ERROR( "Option/Point: Invalid argument to '%s' or '%s'!\n", m_short_name, m_long_name );
- return false;
- }
-
- return true;
- }
- };
-
- public: class OptionDimension :public Option {
- private: DFBDimension &m_value;
-
- public: OptionDimension( const char *short_name,
- const char *long_name,
- const char *arg_name,
- const char *arg_desc,
- DFBDimension &value ) : Option( short_name, long_name, arg_name, arg_desc ), m_value( value )
- {
- }
-
- public: virtual bool Parse( const char *arg ) {
- if (sscanf( arg, "%dx%d", &m_value.w, &m_value.h ) != 2) {
- D_ERROR( "Option/Dimension: Invalid argument to '%s' or '%s'!\n", m_short_name, m_long_name );
- return false;
- }
-
- return true;
- }
- };
-
-
-
- private: vector<Option*> m_options;
-
- public: void addOption( Option *option ) {
- m_options.push_back( option );
- }
-
- public: bool parseCommandLine( int argc, char *argv[] ) {
- int n;
-
- for (n = 1; n < argc; n++) {
- bool ok = false;
- const char *arg = argv[n];
-
- if (strcmp (arg, "-h") == 0 || strcmp (arg, "--help") == 0) {
- printUsage (argv[0]);
- return false;
- }
-
- if (strcmp (arg, "-v") == 0 || strcmp (arg, "--version") == 0) {
-
- return false;
- }
-
- vector<Option*>::iterator itr = m_options.begin();
-
- for (; itr != m_options.end(); itr++) {
- Option *option = *itr;
-
- if (!strcmp (arg, option->m_short_name) || !strcmp (arg, option->m_long_name)) {
- if (option->m_need_arg && ++n == argc) {
- printUsage (argv[0]);
- return false;
- }
-
- if (!option->Parse( argv[n] ))
- return false;
-
- ok = true;
-
- break;
- }
- }
-
- if (!ok) {
- printUsage (argv[0]);
- return false;
- }
- }
-
- return true;
- }
-
- public: void printUsage( const char *prg_name ) {
-
- fprintf (stderr, "Usage: %s [options]\n\n", prg_name);
- fprintf (stderr, "Options:\n");
- fprintf (stderr, " -h --help Show this help message\n");
- fprintf (stderr, " -v --version Print version information\n");
-
-
- vector<Option*>::const_iterator itr = m_options.begin();
-
- for (; itr != m_options.end(); itr++) {
- const Option *option = *itr;
-
- fprintf( stderr, " %-3s %-16s %-12s %s\n",
- option->m_short_name, option->m_long_name, option->m_arg_name, option->m_arg_desc );
- }
-
- fprintf( stderr, "\n" );
- }
-};
-
-}
-# 1 "Random.cxx"
-# 1 "<built-in>"
-# 1 "<command-line>"
-# 1 "Random.cxx"
-namespace PluggIt {
-
-class Random
-{
- public: static float nextFloat( float min, float max ) {
- return min + rand() * (max - min) / (float) RAND_MAX;
- }
-};
-
-}
-# 1 "Updates.cxx"
-# 1 "<built-in>"
-# 1 "<command-line>"
-# 1 "Updates.cxx"
-namespace PluggIt {
-
-class Updates
-{
- private: DFBUpdates m_updates;
- private: DFBRegion *m_regions;
-
- public: Updates( unsigned int max_regions = 8 ) {
- m_regions = (DFBRegion*) D_CALLOC( max_regions ?: 1, sizeof(DFBRegion) );
-
- dfb_updates_init( &m_updates, m_regions, max_regions );
- }
-
- virtual ~Updates() {
- dfb_updates_deinit( &m_updates );
-
- D_FREE( m_regions );
- }
-
-
- public: void addRegion( const DFBRegion &region ) {
- dfb_updates_add( &m_updates, &region );
- }
-
- public: DFBRegion bounding() const {
- return m_updates.bounding;
- }
-
- public: void get_rectangles( DFBRectangle *ret_rects, int *ret_num ) {
- dfb_updates_get_rectangles( &m_updates, ret_rects, ret_num );
- }
-
- public: unsigned int num_regions() const {
- return m_updates.num_regions;
- }
-
- public: void reset() {
- dfb_updates_reset( &m_updates );
- }
-
-
- public: void GetRectangles( vector<DFBRectangle_C> &rects ) {
- D_MAGIC_ASSERT( &m_updates, DFBUpdates );
- D_ASSERT( m_updates.regions != NULL );
- D_ASSERT( m_updates.num_regions >= 0 );
- D_ASSERT( m_updates.num_regions <= m_updates.max_regions );
-
- switch (m_updates.num_regions) {
- case 0:
- break;
-
- default: {
- int n, d, total, bounding;
-
- dfb_updates_stat( &m_updates, &total, &bounding );
-
- n = m_updates.max_regions - m_updates.num_regions + 1;
- d = n + 1;
-
-
- if (total < bounding * n / d) {
- for (n=0; n<m_updates.num_regions; n++)
- rects.push_back( DFBRectangle( m_updates.regions[n] ) );
-
- break;
- }
- }
-
-
- case 1:
- rects.push_back( DFBRectangle( m_updates.bounding ) );
- break;
- }
- }
-};
-
-}
-# 1 "Runnable.cxx"
-# 1 "<built-in>"
-# 1 "<command-line>"
-# 1 "Runnable.cxx"
-namespace PluggIt {
-
-class Runnable
-{
- public: virtual void run() = 0;
-};
-
-}
-# 1 "Thread.cxx"
-# 1 "<built-in>"
-# 1 "<command-line>"
-# 1 "Thread.cxx"
-namespace PluggIt {
-
-class Thread
-{
- private: Runnable *m_target;
- private: string m_name;
-
- private: DirectThread *m_thread;
- private: volatile bool m_interrupted;
-
-
- public: Thread( Runnable *target, string name = "" ) {
- m_target = target;
- m_name = name;
-
- m_thread = NULL;
- m_interrupted = false;
- }
-
- virtual ~Thread() {
- if (m_thread)
- direct_thread_destroy( m_thread );
- }
-
- public: bool start() {
- if (m_thread)
- return false;
-
- m_thread = direct_thread_create( DTT_DEFAULT, main, m_target, m_name.c_str() );
-
- return m_thread != NULL;
- }
-
- public: bool interrupt() {
- if (!m_thread)
- return false;
-
- m_interrupted = true;
-
- return true;
- }
-
- public: bool isInterrupted() {
- return m_interrupted;
- }
-
- public: bool join() {
- if (!m_thread)
- return false;
-
- direct_thread_join( m_thread );
- direct_thread_destroy( m_thread );
-
- m_thread = NULL;
- m_interrupted = false;
-
- return true;
- }
-
-
- private: static void *main( DirectThread *thread, void *arg ) {
- Runnable *target = (Runnable*) arg;
-
- target->run();
-
- return NULL;
- }
-};
-
-}
-# 1 "Scaler.cxx"
-# 1 "<built-in>"
-# 1 "<command-line>"
-# 1 "Scaler.cxx"
-namespace PluggIt {
-
-D_DEBUG_DOMAIN( PluggIt_Scaler, "PluggIt/Scaler", "PluggIt Scaler" );
-
-
-typedef struct {
- DFBRegion clip;
- const void *colors;
- unsigned long protect;
- unsigned long key;
-} StretchCtx;
-
-typedef void (*StretchHVx)( void *dst,
- int dpitch,
- const void *src,
- int spitch,
- int width,
- int height,
- int dst_width,
- int dst_height,
- const StretchCtx *ctx );
-# 47 "Scaler.cxx"
-# 1 "stretch_up_down_16.h" 1
-# 20 "stretch_up_down_16.h"
-# 1 "stretch_hvx_N.h" 1
-# 9 "stretch_hvx_N.h"
-static void stretch_hvx_RGB16_up____DSPF_RGB16
-# 1 "stretch_hvx_16.h" 1
-# 35 "stretch_hvx_16.h"
- ( void *dst,
- int dpitch,
- const void *src,
- int spitch,
- int width,
- int height,
- int dst_width,
- int dst_height,
- const StretchCtx *ctx )
-{
- long x, y, r = 0;
- long head = ((((unsigned long) dst) & 2) >> 1) ^ (ctx->clip.x1 & 1);
- long cw = ctx->clip.x2 - ctx->clip.x1 + 1;
- long ch = ctx->clip.y2 - ctx->clip.y1 + 1;
- long tail = (cw - head) & 1;
- long w2 = (cw - head) / 2;
- long hfraq = ((long)(width - 1) << 18) / (long)(dst_width);
- long vfraq = ((long)(height - 1) << 18) / (long)(dst_height);
- long dp4 = dpitch / 4;
- long point0 = 0 + ctx->clip.x1 * hfraq;
- long point = point0;
- long line = 0 + ctx->clip.y1 * vfraq;
- long ratios[cw];
- u32 *dst32;
-
-
-
-
-
-
- u32 _lbT[w2+8];
- u32 _lbB[w2+8];
-
- u32 *lbX;
- u32 *lbT = (u32*)((((unsigned long)(&_lbT[0])) + 31) & ~31);
- u32 *lbB = (u32*)((((unsigned long)(&_lbB[0])) + 31) & ~31);
-
- long lineT = -2000;
-
- for (x=0; x<cw; x++) {
- ratios[x] = ( ((point) & 0x3ffff) >> (18-6) );
-
- point += hfraq;
- }
-
- do {} while (0);
-
-
- dst = (void*)((char*) dst + ctx->clip.x1 * 2 + ctx->clip.y1 * dpitch);
-
- dst32 = (u32*) dst;
-
- if (head) {
- u32 dpT, dpB, L, R;
-
- u16 *dst16 = (u16*) dst;
-
- point = point0;
-
- for (y=0; y<ch; y++) {
- long X = ( ((line) & 0x3ffff) >> (18-5) );
-
- const u16 *srcT = (const u16 *)((char*) src + spitch * ( (((line)) >> 18) ));
- const u16 *srcB = (const u16 *)((char*) src + spitch * ( (((line)) >> 18) + 1 ));
-
-
-
-
- long pl = ( (((point)) >> 18) );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
- L = (srcT[pl]);
- R = (srcT[pl+1]);
-
- dpT = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6))) >> 6;
-
- L = (srcB[pl]);
- R = (srcB[pl+1]);
-
- dpB = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6))) >> 6;
-# 138 "stretch_hvx_16.h"
- dst16[0] = ((((((dpB & 0xf81f) - (dpT & 0xf81f))*X) >> 5) + (dpT & 0xf81f)) & 0xf81f) +
- ((((((dpB>>5) & (0x07e0>>5)) - ((dpT>>5) & (0x07e0>>5)))*X) + (dpT & 0x07e0)) & 0x07e0);
-
-
- dst16 += dpitch / 2;
- line += vfraq;
- }
-
-
- point0 += hfraq;
- dst32 = (u32*)((char*) dst + 2);
-
-
- line = 0 + ctx->clip.y1 * vfraq;
- }
-
-
-
-
- for (y=0; y<ch; y++) {
- long X;
- long nlT = ( (((line)) >> 18) );
-
- D_ASSERT( nlT >= 0 );
- D_ASSERT( nlT < height-1 );
-
-
-
-
- if (nlT != lineT) {
- u32 L, R, dpT, dpB;
- const u16 *srcT = (const u16 *)((char*) src + spitch * nlT);
- const u16 *srcB = (const u16 *)((char*) src + spitch * (nlT + 1));
- long diff = nlT - lineT;
-
- if (diff > 1) {
-
-
-
- for (x=0, r=head, point=point0; x<w2; x++) {
-
-
-
- long pl = ( (((point)) >> 18) );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
- L = (srcT[pl]);
- R = (srcT[pl+1]);
-
- dpT = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6)))
-
-
-
- >> 6;
-
-
- L = (srcB[pl]);
- R = (srcB[pl+1]);
-
- dpB = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6)))
-
-
-
- >> 6;
-
-
- point += hfraq;
- r++;
-
-
- pl = ( (((point)) >> 18) );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
-
- L = (srcT[pl]);
- R = (srcT[pl+1]);
-
- dpT |= (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6)))
-
-
-
- << (16-6);
-
-
- L = (srcB[pl]);
- R = (srcB[pl+1]);
-
- dpB |= (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6)))
-
-
-
- << (16-6);
-
-
- point += hfraq;
- r++;
-
-
- lbT[x] = dpT;
- lbB[x] = dpB;
- }
- }
- else {
-
- lbX = lbT;
- lbT = lbB;
- lbB = lbX;
-
-
-
-
- for (x=0, r=head, point=point0; x<w2; x++) {
-
-
-
- long pl = ( (((point)) >> 18) );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
- L = (srcB[pl]);
- R = (srcB[pl+1]);
-
- dpB = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6)))
-
-
-
- >> 6;
-
-
- point += hfraq;
- r++;
-
-
- pl = ( (((point)) >> 18) );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
-
- L = (srcB[pl]);
- R = (srcB[pl+1]);
-
- dpB |= (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6)))
-
-
-
- << (16-6);
-
-
- point += hfraq;
- r++;
-
-
- lbB[x] = dpB;
- }
- }
-
- lineT = nlT;
- }
-
-
-
-
- X = ( ((line) & 0x3ffff) >> (18-5) );
-
- for (x=0; x<w2; x++) {
-# 371 "stretch_hvx_16.h"
- dst32[x] = ((((((lbB[x] & ((0x07e0<<16) | 0xf81f)) - (lbT[x] & ((0x07e0<<16) | 0xf81f)))*X) >> 5) + (lbT[x] & ((0x07e0<<16) | 0xf81f))) & ((0x07e0<<16) | 0xf81f)) +
- ((((((lbB[x]>>5) & (((0xf81f<<16) | 0x07e0)>>5)) - ((lbT[x]>>5) & (((0xf81f<<16) | 0x07e0)>>5)))*X) + (lbT[x] & ((0xf81f<<16) | 0x07e0))) & ((0xf81f<<16) | 0x07e0));
-
-
- }
-
- dst32 += dp4;
- line += vfraq;
- }
-
- if (tail) {
- u32 dpT, dpB, L, R;
-
- u16 *dst16 = (u16*)((char*) dst + cw * 2 - 2);
-
-
- line = 0 + ctx->clip.y1 * vfraq;
-
- for (y=0; y<ch; y++) {
- long X = ( ((line) & 0x3ffff) >> (18-5) );
-
- const u16 *srcT = (const u16 *)((char*) src + spitch * ( (((line)) >> 18) ));
- const u16 *srcB = (const u16 *)((char*) src + spitch * ( (((line)) >> 18) + 1 ));
-
-
-
-
- long pl = ( (((point)) >> 18) );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
- L = (srcT[pl]);
- R = (srcT[pl+1]);
-
- dpT = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6))) >> 6;
-
- L = (srcB[pl]);
- R = (srcB[pl+1]);
-
- dpB = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6))) >> 6;
-# 434 "stretch_hvx_16.h"
- dst16[0] = ((((((dpB & 0xf81f) - (dpT & 0xf81f))*X) >> 5) + (dpT & 0xf81f)) & 0xf81f) +
- ((((((dpB>>5) & (0x07e0>>5)) - ((dpT>>5) & (0x07e0>>5)))*X) + (dpT & 0x07e0)) & 0x07e0);
-
-
- dst16 += dpitch / 2;
- line += vfraq;
- }
- }
-}
-# 11 "stretch_hvx_N.h" 2
-# 20 "stretch_hvx_N.h"
-static void stretch_hvx_RGB16_up____DSPF_RGB32
-# 1 "stretch_hvx_16.h" 1
-# 35 "stretch_hvx_16.h"
- ( void *dst,
- int dpitch,
- const void *src,
- int spitch,
- int width,
- int height,
- int dst_width,
- int dst_height,
- const StretchCtx *ctx )
-{
- long x, y, r = 0;
- long head = ((((unsigned long) dst) & 2) >> 1) ^ (ctx->clip.x1 & 1);
- long cw = ctx->clip.x2 - ctx->clip.x1 + 1;
- long ch = ctx->clip.y2 - ctx->clip.y1 + 1;
- long tail = (cw - head) & 1;
- long w2 = (cw - head) / 2;
- long hfraq = ((long)(width - 1) << 18) / (long)(dst_width);
- long vfraq = ((long)(height - 1) << 18) / (long)(dst_height);
- long dp4 = dpitch / 4;
- long point0 = 0 + ctx->clip.x1 * hfraq;
- long point = point0;
- long line = 0 + ctx->clip.y1 * vfraq;
- long ratios[cw];
- u32 *dst32;
-
-
-
-
-
-
- u32 _lbT[w2+8];
- u32 _lbB[w2+8];
-
- u32 *lbX;
- u32 *lbT = (u32*)((((unsigned long)(&_lbT[0])) + 31) & ~31);
- u32 *lbB = (u32*)((((unsigned long)(&_lbB[0])) + 31) & ~31);
-
- long lineT = -2000;
-
- for (x=0; x<cw; x++) {
- ratios[x] = ( ((point) & 0x3ffff) >> (18-6) );
-
- point += hfraq;
- }
-
- do {} while (0);
-
-
- dst = (void*)((char*) dst + ctx->clip.x1 * 2 + ctx->clip.y1 * dpitch);
-
- dst32 = (u32*) dst;
-
- if (head) {
- u32 dpT, dpB, L, R;
-
- u16 *dst16 = (u16*) dst;
-
- point = point0;
-
- for (y=0; y<ch; y++) {
- long X = ( ((line) & 0x3ffff) >> (18-5) );
-
- const u32 *srcT = (const u32 *)((char*) src + spitch * ( (((line)) >> 18) ));
- const u32 *srcB = (const u32 *)((char*) src + spitch * ( (((line)) >> 18) + 1 ));
-
-
-
-
- long pl = ( (((point)) >> 18) );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
- L = ( (((((srcT[pl]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcT[pl]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcT[pl]) & 0x0000ff))&0xF8) >> 3) );
- R = ( (((((srcT[pl+1]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcT[pl+1]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcT[pl+1]) & 0x0000ff))&0xF8) >> 3) );
-
- dpT = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6))) >> 6;
-
- L = ( (((((srcB[pl]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcB[pl]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcB[pl]) & 0x0000ff))&0xF8) >> 3) );
- R = ( (((((srcB[pl+1]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcB[pl+1]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcB[pl+1]) & 0x0000ff))&0xF8) >> 3) );
-
- dpB = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6))) >> 6;
-# 138 "stretch_hvx_16.h"
- dst16[0] = ((((((dpB & 0xf81f) - (dpT & 0xf81f))*X) >> 5) + (dpT & 0xf81f)) & 0xf81f) +
- ((((((dpB>>5) & (0x07e0>>5)) - ((dpT>>5) & (0x07e0>>5)))*X) + (dpT & 0x07e0)) & 0x07e0);
-
-
- dst16 += dpitch / 2;
- line += vfraq;
- }
-
-
- point0 += hfraq;
- dst32 = (u32*)((char*) dst + 2);
-
-
- line = 0 + ctx->clip.y1 * vfraq;
- }
-
-
-
-
- for (y=0; y<ch; y++) {
- long X;
- long nlT = ( (((line)) >> 18) );
-
- D_ASSERT( nlT >= 0 );
- D_ASSERT( nlT < height-1 );
-
-
-
-
- if (nlT != lineT) {
- u32 L, R, dpT, dpB;
- const u32 *srcT = (const u32 *)((char*) src + spitch * nlT);
- const u32 *srcB = (const u32 *)((char*) src + spitch * (nlT + 1));
- long diff = nlT - lineT;
-
- if (diff > 1) {
-
-
-
- for (x=0, r=head, point=point0; x<w2; x++) {
-
-
-
- long pl = ( (((point)) >> 18) );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
- L = ( (((((srcT[pl]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcT[pl]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcT[pl]) & 0x0000ff))&0xF8) >> 3) );
- R = ( (((((srcT[pl+1]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcT[pl+1]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcT[pl+1]) & 0x0000ff))&0xF8) >> 3) );
-
- dpT = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6)))
-
-
-
- >> 6;
-
-
- L = ( (((((srcB[pl]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcB[pl]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcB[pl]) & 0x0000ff))&0xF8) >> 3) );
- R = ( (((((srcB[pl+1]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcB[pl+1]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcB[pl+1]) & 0x0000ff))&0xF8) >> 3) );
-
- dpB = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6)))
-
-
-
- >> 6;
-
-
- point += hfraq;
- r++;
-
-
- pl = ( (((point)) >> 18) );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
-
- L = ( (((((srcT[pl]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcT[pl]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcT[pl]) & 0x0000ff))&0xF8) >> 3) );
- R = ( (((((srcT[pl+1]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcT[pl+1]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcT[pl+1]) & 0x0000ff))&0xF8) >> 3) );
-
- dpT |= (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6)))
-
-
-
- << (16-6);
-
-
- L = ( (((((srcB[pl]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcB[pl]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcB[pl]) & 0x0000ff))&0xF8) >> 3) );
- R = ( (((((srcB[pl+1]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcB[pl+1]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcB[pl+1]) & 0x0000ff))&0xF8) >> 3) );
-
- dpB |= (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6)))
-
-
-
- << (16-6);
-
-
- point += hfraq;
- r++;
-
-
- lbT[x] = dpT;
- lbB[x] = dpB;
- }
- }
- else {
-
- lbX = lbT;
- lbT = lbB;
- lbB = lbX;
-
-
-
-
- for (x=0, r=head, point=point0; x<w2; x++) {
-
-
-
- long pl = ( (((point)) >> 18) );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
- L = ( (((((srcB[pl]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcB[pl]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcB[pl]) & 0x0000ff))&0xF8) >> 3) );
- R = ( (((((srcB[pl+1]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcB[pl+1]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcB[pl+1]) & 0x0000ff))&0xF8) >> 3) );
-
- dpB = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6)))
-
-
-
- >> 6;
-
-
- point += hfraq;
- r++;
-
-
- pl = ( (((point)) >> 18) );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
-
- L = ( (((((srcB[pl]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcB[pl]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcB[pl]) & 0x0000ff))&0xF8) >> 3) );
- R = ( (((((srcB[pl+1]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcB[pl+1]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcB[pl+1]) & 0x0000ff))&0xF8) >> 3) );
-
- dpB |= (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6)))
-
-
-
- << (16-6);
-
-
- point += hfraq;
- r++;
-
-
- lbB[x] = dpB;
- }
- }
-
- lineT = nlT;
- }
-
-
-
-
- X = ( ((line) & 0x3ffff) >> (18-5) );
-
- for (x=0; x<w2; x++) {
-# 371 "stretch_hvx_16.h"
- dst32[x] = ((((((lbB[x] & ((0x07e0<<16) | 0xf81f)) - (lbT[x] & ((0x07e0<<16) | 0xf81f)))*X) >> 5) + (lbT[x] & ((0x07e0<<16) | 0xf81f))) & ((0x07e0<<16) | 0xf81f)) +
- ((((((lbB[x]>>5) & (((0xf81f<<16) | 0x07e0)>>5)) - ((lbT[x]>>5) & (((0xf81f<<16) | 0x07e0)>>5)))*X) + (lbT[x] & ((0xf81f<<16) | 0x07e0))) & ((0xf81f<<16) | 0x07e0));
-
-
- }
-
- dst32 += dp4;
- line += vfraq;
- }
-
- if (tail) {
- u32 dpT, dpB, L, R;
-
- u16 *dst16 = (u16*)((char*) dst + cw * 2 - 2);
-
-
- line = 0 + ctx->clip.y1 * vfraq;
-
- for (y=0; y<ch; y++) {
- long X = ( ((line) & 0x3ffff) >> (18-5) );
-
- const u32 *srcT = (const u32 *)((char*) src + spitch * ( (((line)) >> 18) ));
- const u32 *srcB = (const u32 *)((char*) src + spitch * ( (((line)) >> 18) + 1 ));
-
-
-
-
- long pl = ( (((point)) >> 18) );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
- L = ( (((((srcT[pl]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcT[pl]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcT[pl]) & 0x0000ff))&0xF8) >> 3) );
- R = ( (((((srcT[pl+1]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcT[pl+1]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcT[pl+1]) & 0x0000ff))&0xF8) >> 3) );
-
- dpT = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6))) >> 6;
-
- L = ( (((((srcB[pl]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcB[pl]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcB[pl]) & 0x0000ff))&0xF8) >> 3) );
- R = ( (((((srcB[pl+1]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcB[pl+1]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcB[pl+1]) & 0x0000ff))&0xF8) >> 3) );
-
- dpB = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6))) >> 6;
-# 434 "stretch_hvx_16.h"
- dst16[0] = ((((((dpB & 0xf81f) - (dpT & 0xf81f))*X) >> 5) + (dpT & 0xf81f)) & 0xf81f) +
- ((((((dpB>>5) & (0x07e0>>5)) - ((dpT>>5) & (0x07e0>>5)))*X) + (dpT & 0x07e0)) & 0x07e0);
-
-
- dst16 += dpitch / 2;
- line += vfraq;
- }
- }
-}
-# 22 "stretch_hvx_N.h" 2
-# 21 "stretch_up_down_16.h" 2
-# 49 "stretch_up_down_16.h"
-# 1 "stretch_hvx_N.h" 1
-# 9 "stretch_hvx_N.h"
-static void stretch_hvx_RGB16_down____DSPF_RGB16
-# 1 "stretch_hvx_16.h" 1
-# 35 "stretch_hvx_16.h"
- ( void *dst,
- int dpitch,
- const void *src,
- int spitch,
- int width,
- int height,
- int dst_width,
- int dst_height,
- const StretchCtx *ctx )
-{
- long x, y, r = 0;
- long head = ((((unsigned long) dst) & 2) >> 1) ^ (ctx->clip.x1 & 1);
- long cw = ctx->clip.x2 - ctx->clip.x1 + 1;
- long ch = ctx->clip.y2 - ctx->clip.y1 + 1;
- long tail = (cw - head) & 1;
- long w2 = (cw - head) / 2;
- long hfraq = ((long)(width - 0) << 18) / (long)(dst_width);
- long vfraq = ((long)(height - 0) << 18) / (long)(dst_height);
- long dp4 = dpitch / 4;
- long point0 = hfraq + ctx->clip.x1 * hfraq;
- long point = point0;
- long line = vfraq + ctx->clip.y1 * vfraq;
- long ratios[cw];
- u32 *dst32;
-
-
-
-
-
-
- u32 _lbT[w2+8];
- u32 _lbB[w2+8];
-
- u32 *lbX;
- u32 *lbT = (u32*)((((unsigned long)(&_lbT[0])) + 31) & ~31);
- u32 *lbB = (u32*)((((unsigned long)(&_lbB[0])) + 31) & ~31);
-
- long lineT = -2000;
-
- for (x=0; x<cw; x++) {
- ratios[x] = ( (((((point)) & 0x3ffff) ? : 0x40000) << 6) / (hfraq) );
-
- point += hfraq;
- }
-
- do {} while (0);
-
-
- dst = (void*)((char*) dst + ctx->clip.x1 * 2 + ctx->clip.y1 * dpitch);
-
- dst32 = (u32*) dst;
-
- if (head) {
- u32 dpT, dpB, L, R;
-
- u16 *dst16 = (u16*) dst;
-
- point = point0;
-
- for (y=0; y<ch; y++) {
- long X = ( (((((line)) & 0x3ffff) ? : 0x40000) << 5) / (vfraq) );
-
- const u16 *srcT = (const u16 *)((char*) src + spitch * ( (((line)-1) >> 18) - 1 ));
- const u16 *srcB = (const u16 *)((char*) src + spitch * ( (((line)-1) >> 18) ));
-
-
-
-
- long pl = ( (((point)-1) >> 18) - 1 );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
- L = (srcT[pl]);
- R = (srcT[pl+1]);
-
- dpT = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6))) >> 6;
-
- L = (srcB[pl]);
- R = (srcB[pl+1]);
-
- dpB = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6))) >> 6;
-# 138 "stretch_hvx_16.h"
- dst16[0] = ((((((dpB & 0xf81f) - (dpT & 0xf81f))*X) >> 5) + (dpT & 0xf81f)) & 0xf81f) +
- ((((((dpB>>5) & (0x07e0>>5)) - ((dpT>>5) & (0x07e0>>5)))*X) + (dpT & 0x07e0)) & 0x07e0);
-
-
- dst16 += dpitch / 2;
- line += vfraq;
- }
-
-
- point0 += hfraq;
- dst32 = (u32*)((char*) dst + 2);
-
-
- line = vfraq + ctx->clip.y1 * vfraq;
- }
-
-
-
-
- for (y=0; y<ch; y++) {
- long X;
- long nlT = ( (((line)-1) >> 18) - 1 );
-
- D_ASSERT( nlT >= 0 );
- D_ASSERT( nlT < height-1 );
-
-
-
-
- if (nlT != lineT) {
- u32 L, R, dpT, dpB;
- const u16 *srcT = (const u16 *)((char*) src + spitch * nlT);
- const u16 *srcB = (const u16 *)((char*) src + spitch * (nlT + 1));
- long diff = nlT - lineT;
-
- if (diff > 1) {
-
-
-
- for (x=0, r=head, point=point0; x<w2; x++) {
-
-
-
- long pl = ( (((point)-1) >> 18) - 1 );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
- L = (srcT[pl]);
- R = (srcT[pl+1]);
-
- dpT = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6)))
-
-
-
- >> 6;
-
-
- L = (srcB[pl]);
- R = (srcB[pl+1]);
-
- dpB = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6)))
-
-
-
- >> 6;
-
-
- point += hfraq;
- r++;
-
-
- pl = ( (((point)-1) >> 18) - 1 );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
-
- L = (srcT[pl]);
- R = (srcT[pl+1]);
-
- dpT |= (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6)))
-
-
-
- << (16-6);
-
-
- L = (srcB[pl]);
- R = (srcB[pl+1]);
-
- dpB |= (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6)))
-
-
-
- << (16-6);
-
-
- point += hfraq;
- r++;
-
-
- lbT[x] = dpT;
- lbB[x] = dpB;
- }
- }
- else {
-
- lbX = lbT;
- lbT = lbB;
- lbB = lbX;
-
-
-
-
- for (x=0, r=head, point=point0; x<w2; x++) {
-
-
-
- long pl = ( (((point)-1) >> 18) - 1 );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
- L = (srcB[pl]);
- R = (srcB[pl+1]);
-
- dpB = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6)))
-
-
-
- >> 6;
-
-
- point += hfraq;
- r++;
-
-
- pl = ( (((point)-1) >> 18) - 1 );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
-
- L = (srcB[pl]);
- R = (srcB[pl+1]);
-
- dpB |= (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6)))
-
-
-
- << (16-6);
-
-
- point += hfraq;
- r++;
-
-
- lbB[x] = dpB;
- }
- }
-
- lineT = nlT;
- }
-
-
-
-
- X = ( (((((line)) & 0x3ffff) ? : 0x40000) << 5) / (vfraq) );
-
- for (x=0; x<w2; x++) {
-# 371 "stretch_hvx_16.h"
- dst32[x] = ((((((lbB[x] & ((0x07e0<<16) | 0xf81f)) - (lbT[x] & ((0x07e0<<16) | 0xf81f)))*X) >> 5) + (lbT[x] & ((0x07e0<<16) | 0xf81f))) & ((0x07e0<<16) | 0xf81f)) +
- ((((((lbB[x]>>5) & (((0xf81f<<16) | 0x07e0)>>5)) - ((lbT[x]>>5) & (((0xf81f<<16) | 0x07e0)>>5)))*X) + (lbT[x] & ((0xf81f<<16) | 0x07e0))) & ((0xf81f<<16) | 0x07e0));
-
-
- }
-
- dst32 += dp4;
- line += vfraq;
- }
-
- if (tail) {
- u32 dpT, dpB, L, R;
-
- u16 *dst16 = (u16*)((char*) dst + cw * 2 - 2);
-
-
- line = vfraq + ctx->clip.y1 * vfraq;
-
- for (y=0; y<ch; y++) {
- long X = ( (((((line)) & 0x3ffff) ? : 0x40000) << 5) / (vfraq) );
-
- const u16 *srcT = (const u16 *)((char*) src + spitch * ( (((line)-1) >> 18) - 1 ));
- const u16 *srcB = (const u16 *)((char*) src + spitch * ( (((line)-1) >> 18) ));
-
-
-
-
- long pl = ( (((point)-1) >> 18) - 1 );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
- L = (srcT[pl]);
- R = (srcT[pl+1]);
-
- dpT = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6))) >> 6;
-
- L = (srcB[pl]);
- R = (srcB[pl+1]);
-
- dpB = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6))) >> 6;
-# 434 "stretch_hvx_16.h"
- dst16[0] = ((((((dpB & 0xf81f) - (dpT & 0xf81f))*X) >> 5) + (dpT & 0xf81f)) & 0xf81f) +
- ((((((dpB>>5) & (0x07e0>>5)) - ((dpT>>5) & (0x07e0>>5)))*X) + (dpT & 0x07e0)) & 0x07e0);
-
-
- dst16 += dpitch / 2;
- line += vfraq;
- }
- }
-}
-# 11 "stretch_hvx_N.h" 2
-# 20 "stretch_hvx_N.h"
-static void stretch_hvx_RGB16_down____DSPF_RGB32
-# 1 "stretch_hvx_16.h" 1
-# 35 "stretch_hvx_16.h"
- ( void *dst,
- int dpitch,
- const void *src,
- int spitch,
- int width,
- int height,
- int dst_width,
- int dst_height,
- const StretchCtx *ctx )
-{
- long x, y, r = 0;
- long head = ((((unsigned long) dst) & 2) >> 1) ^ (ctx->clip.x1 & 1);
- long cw = ctx->clip.x2 - ctx->clip.x1 + 1;
- long ch = ctx->clip.y2 - ctx->clip.y1 + 1;
- long tail = (cw - head) & 1;
- long w2 = (cw - head) / 2;
- long hfraq = ((long)(width - 0) << 18) / (long)(dst_width);
- long vfraq = ((long)(height - 0) << 18) / (long)(dst_height);
- long dp4 = dpitch / 4;
- long point0 = hfraq + ctx->clip.x1 * hfraq;
- long point = point0;
- long line = vfraq + ctx->clip.y1 * vfraq;
- long ratios[cw];
- u32 *dst32;
-
-
-
-
-
-
- u32 _lbT[w2+8];
- u32 _lbB[w2+8];
-
- u32 *lbX;
- u32 *lbT = (u32*)((((unsigned long)(&_lbT[0])) + 31) & ~31);
- u32 *lbB = (u32*)((((unsigned long)(&_lbB[0])) + 31) & ~31);
-
- long lineT = -2000;
-
- for (x=0; x<cw; x++) {
- ratios[x] = ( (((((point)) & 0x3ffff) ? : 0x40000) << 6) / (hfraq) );
-
- point += hfraq;
- }
-
- do {} while (0);
-
-
- dst = (void*)((char*) dst + ctx->clip.x1 * 2 + ctx->clip.y1 * dpitch);
-
- dst32 = (u32*) dst;
-
- if (head) {
- u32 dpT, dpB, L, R;
-
- u16 *dst16 = (u16*) dst;
-
- point = point0;
-
- for (y=0; y<ch; y++) {
- long X = ( (((((line)) & 0x3ffff) ? : 0x40000) << 5) / (vfraq) );
-
- const u32 *srcT = (const u32 *)((char*) src + spitch * ( (((line)-1) >> 18) - 1 ));
- const u32 *srcB = (const u32 *)((char*) src + spitch * ( (((line)-1) >> 18) ));
-
-
-
-
- long pl = ( (((point)-1) >> 18) - 1 );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
- L = ( (((((srcT[pl]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcT[pl]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcT[pl]) & 0x0000ff))&0xF8) >> 3) );
- R = ( (((((srcT[pl+1]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcT[pl+1]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcT[pl+1]) & 0x0000ff))&0xF8) >> 3) );
-
- dpT = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6))) >> 6;
-
- L = ( (((((srcB[pl]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcB[pl]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcB[pl]) & 0x0000ff))&0xF8) >> 3) );
- R = ( (((((srcB[pl+1]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcB[pl+1]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcB[pl+1]) & 0x0000ff))&0xF8) >> 3) );
-
- dpB = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6))) >> 6;
-# 138 "stretch_hvx_16.h"
- dst16[0] = ((((((dpB & 0xf81f) - (dpT & 0xf81f))*X) >> 5) + (dpT & 0xf81f)) & 0xf81f) +
- ((((((dpB>>5) & (0x07e0>>5)) - ((dpT>>5) & (0x07e0>>5)))*X) + (dpT & 0x07e0)) & 0x07e0);
-
-
- dst16 += dpitch / 2;
- line += vfraq;
- }
-
-
- point0 += hfraq;
- dst32 = (u32*)((char*) dst + 2);
-
-
- line = vfraq + ctx->clip.y1 * vfraq;
- }
-
-
-
-
- for (y=0; y<ch; y++) {
- long X;
- long nlT = ( (((line)-1) >> 18) - 1 );
-
- D_ASSERT( nlT >= 0 );
- D_ASSERT( nlT < height-1 );
-
-
-
-
- if (nlT != lineT) {
- u32 L, R, dpT, dpB;
- const u32 *srcT = (const u32 *)((char*) src + spitch * nlT);
- const u32 *srcB = (const u32 *)((char*) src + spitch * (nlT + 1));
- long diff = nlT - lineT;
-
- if (diff > 1) {
-
-
-
- for (x=0, r=head, point=point0; x<w2; x++) {
-
-
-
- long pl = ( (((point)-1) >> 18) - 1 );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
- L = ( (((((srcT[pl]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcT[pl]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcT[pl]) & 0x0000ff))&0xF8) >> 3) );
- R = ( (((((srcT[pl+1]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcT[pl+1]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcT[pl+1]) & 0x0000ff))&0xF8) >> 3) );
-
- dpT = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6)))
-
-
-
- >> 6;
-
-
- L = ( (((((srcB[pl]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcB[pl]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcB[pl]) & 0x0000ff))&0xF8) >> 3) );
- R = ( (((((srcB[pl+1]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcB[pl+1]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcB[pl+1]) & 0x0000ff))&0xF8) >> 3) );
-
- dpB = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6)))
-
-
-
- >> 6;
-
-
- point += hfraq;
- r++;
-
-
- pl = ( (((point)-1) >> 18) - 1 );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
-
- L = ( (((((srcT[pl]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcT[pl]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcT[pl]) & 0x0000ff))&0xF8) >> 3) );
- R = ( (((((srcT[pl+1]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcT[pl+1]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcT[pl+1]) & 0x0000ff))&0xF8) >> 3) );
-
- dpT |= (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6)))
-
-
-
- << (16-6);
-
-
- L = ( (((((srcB[pl]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcB[pl]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcB[pl]) & 0x0000ff))&0xF8) >> 3) );
- R = ( (((((srcB[pl+1]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcB[pl+1]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcB[pl+1]) & 0x0000ff))&0xF8) >> 3) );
-
- dpB |= (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6)))
-
-
-
- << (16-6);
-
-
- point += hfraq;
- r++;
-
-
- lbT[x] = dpT;
- lbB[x] = dpB;
- }
- }
- else {
-
- lbX = lbT;
- lbT = lbB;
- lbB = lbX;
-
-
-
-
- for (x=0, r=head, point=point0; x<w2; x++) {
-
-
-
- long pl = ( (((point)-1) >> 18) - 1 );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
- L = ( (((((srcB[pl]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcB[pl]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcB[pl]) & 0x0000ff))&0xF8) >> 3) );
- R = ( (((((srcB[pl+1]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcB[pl+1]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcB[pl+1]) & 0x0000ff))&0xF8) >> 3) );
-
- dpB = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6)))
-
-
-
- >> 6;
-
-
- point += hfraq;
- r++;
-
-
- pl = ( (((point)-1) >> 18) - 1 );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
-
- L = ( (((((srcB[pl]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcB[pl]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcB[pl]) & 0x0000ff))&0xF8) >> 3) );
- R = ( (((((srcB[pl+1]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcB[pl+1]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcB[pl+1]) & 0x0000ff))&0xF8) >> 3) );
-
- dpB |= (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6)))
-
-
-
- << (16-6);
-
-
- point += hfraq;
- r++;
-
-
- lbB[x] = dpB;
- }
- }
-
- lineT = nlT;
- }
-
-
-
-
- X = ( (((((line)) & 0x3ffff) ? : 0x40000) << 5) / (vfraq) );
-
- for (x=0; x<w2; x++) {
-# 371 "stretch_hvx_16.h"
- dst32[x] = ((((((lbB[x] & ((0x07e0<<16) | 0xf81f)) - (lbT[x] & ((0x07e0<<16) | 0xf81f)))*X) >> 5) + (lbT[x] & ((0x07e0<<16) | 0xf81f))) & ((0x07e0<<16) | 0xf81f)) +
- ((((((lbB[x]>>5) & (((0xf81f<<16) | 0x07e0)>>5)) - ((lbT[x]>>5) & (((0xf81f<<16) | 0x07e0)>>5)))*X) + (lbT[x] & ((0xf81f<<16) | 0x07e0))) & ((0xf81f<<16) | 0x07e0));
-
-
- }
-
- dst32 += dp4;
- line += vfraq;
- }
-
- if (tail) {
- u32 dpT, dpB, L, R;
-
- u16 *dst16 = (u16*)((char*) dst + cw * 2 - 2);
-
-
- line = vfraq + ctx->clip.y1 * vfraq;
-
- for (y=0; y<ch; y++) {
- long X = ( (((((line)) & 0x3ffff) ? : 0x40000) << 5) / (vfraq) );
-
- const u32 *srcT = (const u32 *)((char*) src + spitch * ( (((line)-1) >> 18) - 1 ));
- const u32 *srcB = (const u32 *)((char*) src + spitch * ( (((line)-1) >> 18) ));
-
-
-
-
- long pl = ( (((point)-1) >> 18) - 1 );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
- L = ( (((((srcT[pl]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcT[pl]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcT[pl]) & 0x0000ff))&0xF8) >> 3) );
- R = ( (((((srcT[pl+1]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcT[pl+1]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcT[pl+1]) & 0x0000ff))&0xF8) >> 3) );
-
- dpT = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6))) >> 6;
-
- L = ( (((((srcB[pl]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcB[pl]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcB[pl]) & 0x0000ff))&0xF8) >> 3) );
- R = ( (((((srcB[pl+1]) & 0xff0000) >> 16)&0xF8) << 8) | (((((srcB[pl+1]) & 0x00ff00) >> 8)&0xFC) << 3) | (((((srcB[pl+1]) & 0x0000ff))&0xF8) >> 3) );
-
- dpB = (((((R & 0xf81f)-(L & 0xf81f))*ratios[r] + ((L & 0xf81f)<<6)) & (0xf81f<<6)) +
- ((((R & 0x07e0)-(L & 0x07e0))*ratios[r] + ((L & 0x07e0)<<6)) & (0x07e0<<6))) >> 6;
-# 434 "stretch_hvx_16.h"
- dst16[0] = ((((((dpB & 0xf81f) - (dpT & 0xf81f))*X) >> 5) + (dpT & 0xf81f)) & 0xf81f) +
- ((((((dpB>>5) & (0x07e0>>5)) - ((dpT>>5) & (0x07e0>>5)))*X) + (dpT & 0x07e0)) & 0x07e0);
-
-
- dst16 += dpitch / 2;
- line += vfraq;
- }
- }
-}
-# 22 "stretch_hvx_N.h" 2
-# 50 "stretch_up_down_16.h" 2
-# 48 "Scaler.cxx" 2
-# 73 "Scaler.cxx"
-# 1 "stretch_up_down_32.h" 1
-# 20 "stretch_up_down_32.h"
-# 1 "stretch_hvx_N.h" 1
-# 9 "stretch_hvx_N.h"
-static void stretch_hvx_ARGB_up____DSPF_ARGB
-# 1 "stretch_hvx_32.h" 1
-# 11 "stretch_hvx_32.h"
- ( void *dst,
- int dpitch,
- const void *src,
- int spitch,
- int width,
- int height,
- int dst_width,
- int dst_height,
- const StretchCtx *ctx )
-{
- long x, y = 0;
- long cw = ctx->clip.x2 - ctx->clip.x1 + 1;
- long ch = ctx->clip.y2 - ctx->clip.y1 + 1;
- long hfraq = ((long)(width - 1) << 18) / (long)(dst_width);
- long vfraq = ((long)(height - 1) << 18) / (long)(dst_height);
- long dp4 = dpitch / 4;
- long point0 = 0 + ctx->clip.x1 * hfraq;
- long point = point0;
- long line = 0 + ctx->clip.y1 * vfraq;
- long ratios[cw];
- u32 *dst32;
-
-
-
-
-
- u32 _lbT[cw+8];
- u32 _lbB[cw+8];
-
- u32 *lbX;
- u32 *lbT = (u32*)((((unsigned long)(&_lbT[0])) + 31) & ~31);
- u32 *lbB = (u32*)((((unsigned long)(&_lbB[0])) + 31) & ~31);
-
- long lineT = -2000;
-
- for (x=0; x<cw; x++) {
- ratios[x] = ( ((point) & 0x3ffff) >> (18-8) );
-
- point += hfraq;
- }
-
- do {} while (0);
-
- dst = (void*)((char*) dst + ctx->clip.x1 * 4 + ctx->clip.y1 * dpitch);
-
- dst32 = (u32*) dst;
-
-
-
-
- for (y=0; y<ch; y++) {
- long X;
- long nlT = ( (((line)) >> 18) );
-
- D_ASSERT( nlT >= 0 );
- D_ASSERT( nlT < height-1 );
-
-
-
-
- if (nlT != lineT) {
- u32 L, R;
- const u32 *srcT = (const u32 *)((const char*) src + spitch * nlT);
- const u32 *srcB = (const u32 *)((const char*) src + spitch * (nlT + 1));
- long diff = nlT - lineT;
-
- if (diff > 1) {
-
-
-
- for (x=0, point=point0; x<cw; x++, point += hfraq) {
- long pl = ( (((point)) >> 18) );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
-
- L = (srcT[pl]);
- R = (srcT[pl+1]);
-
- lbT[x]= ((((((R & 0x00ff00ff) - (L & 0x00ff00ff))*ratios[x]) >> 8) + (L & 0x00ff00ff)) & 0x00ff00ff) +
- ((((((R>>8) & 0x00ff00ff) - ((L>>8) & 0x00ff00ff))*ratios[x]) + (L & 0xff00ff00)) & 0xff00ff00);
-
- L = (srcB[pl]);
- R = (srcB[pl+1]);
-
- lbB[x] = ((((((R & 0x00ff00ff) - (L & 0x00ff00ff))*ratios[x]) >> 8) + (L & 0x00ff00ff)) & 0x00ff00ff) +
- ((((((R>>8) & 0x00ff00ff) - ((L>>8) & 0x00ff00ff))*ratios[x]) + (L & 0xff00ff00)) & 0xff00ff00);
- }
- }
- else {
-
- lbX = lbT;
- lbT = lbB;
- lbB = lbX;
-
-
-
-
- for (x=0, point=point0; x<cw; x++, point += hfraq) {
- long pl = ( (((point)) >> 18) );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
-
- L = (srcB[pl]);
- R = (srcB[pl+1]);
-
- lbB[x] = ((((((R & 0x00ff00ff) - (L & 0x00ff00ff))*ratios[x]) >> 8) + (L & 0x00ff00ff)) & 0x00ff00ff) +
- ((((((R>>8) & 0x00ff00ff) - ((L>>8) & 0x00ff00ff))*ratios[x]) + (L & 0xff00ff00)) & 0xff00ff00);
- }
- }
-
- lineT = nlT;
- }
-
-
-
-
- X = ( ((line) & 0x3ffff) >> (18-8) );
-
- for (x=0; x<cw; x++) {
-# 149 "stretch_hvx_32.h"
- dst32[x] = ((((((lbB[x] & 0x00ff00ff) - (lbT[x] & 0x00ff00ff))*X) >> 8) + (lbT[x] & 0x00ff00ff)) & 0x00ff00ff) +
- ((((((lbB[x]>>8) & 0x00ff00ff) - ((lbT[x]>>8) & 0x00ff00ff))*X) + (lbT[x] & 0xff00ff00)) & 0xff00ff00);
-
- }
-
- dst32 += dp4;
- line += vfraq;
- }
-}
-# 11 "stretch_hvx_N.h" 2
-# 33 "stretch_hvx_N.h"
-static void stretch_hvx_ARGB_up____DSPF_RGB32
-# 1 "stretch_hvx_32.h" 1
-# 11 "stretch_hvx_32.h"
- ( void *dst,
- int dpitch,
- const void *src,
- int spitch,
- int width,
- int height,
- int dst_width,
- int dst_height,
- const StretchCtx *ctx )
-{
- long x, y = 0;
- long cw = ctx->clip.x2 - ctx->clip.x1 + 1;
- long ch = ctx->clip.y2 - ctx->clip.y1 + 1;
- long hfraq = ((long)(width - 1) << 18) / (long)(dst_width);
- long vfraq = ((long)(height - 1) << 18) / (long)(dst_height);
- long dp4 = dpitch / 4;
- long point0 = 0 + ctx->clip.x1 * hfraq;
- long point = point0;
- long line = 0 + ctx->clip.y1 * vfraq;
- long ratios[cw];
- u32 *dst32;
-
-
-
-
-
- u32 _lbT[cw+8];
- u32 _lbB[cw+8];
-
- u32 *lbX;
- u32 *lbT = (u32*)((((unsigned long)(&_lbT[0])) + 31) & ~31);
- u32 *lbB = (u32*)((((unsigned long)(&_lbB[0])) + 31) & ~31);
-
- long lineT = -2000;
-
- for (x=0; x<cw; x++) {
- ratios[x] = ( ((point) & 0x3ffff) >> (18-8) );
-
- point += hfraq;
- }
-
- do {} while (0);
-
- dst = (void*)((char*) dst + ctx->clip.x1 * 4 + ctx->clip.y1 * dpitch);
-
- dst32 = (u32*) dst;
-
-
-
-
- for (y=0; y<ch; y++) {
- long X;
- long nlT = ( (((line)) >> 18) );
-
- D_ASSERT( nlT >= 0 );
- D_ASSERT( nlT < height-1 );
-
-
-
-
- if (nlT != lineT) {
- u32 L, R;
- const u32 *srcT = (const u32 *)((const char*) src + spitch * nlT);
- const u32 *srcB = (const u32 *)((const char*) src + spitch * (nlT + 1));
- long diff = nlT - lineT;
-
- if (diff > 1) {
-
-
-
- for (x=0, point=point0; x<cw; x++, point += hfraq) {
- long pl = ( (((point)) >> 18) );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
-
- L = ((srcT[pl]) | 0xff000000);
- R = ((srcT[pl+1]) | 0xff000000);
-
- lbT[x]= ((((((R & 0x00ff00ff) - (L & 0x00ff00ff))*ratios[x]) >> 8) + (L & 0x00ff00ff)) & 0x00ff00ff) +
- ((((((R>>8) & 0x00ff00ff) - ((L>>8) & 0x00ff00ff))*ratios[x]) + (L & 0xff00ff00)) & 0xff00ff00);
-
- L = ((srcB[pl]) | 0xff000000);
- R = ((srcB[pl+1]) | 0xff000000);
-
- lbB[x] = ((((((R & 0x00ff00ff) - (L & 0x00ff00ff))*ratios[x]) >> 8) + (L & 0x00ff00ff)) & 0x00ff00ff) +
- ((((((R>>8) & 0x00ff00ff) - ((L>>8) & 0x00ff00ff))*ratios[x]) + (L & 0xff00ff00)) & 0xff00ff00);
- }
- }
- else {
-
- lbX = lbT;
- lbT = lbB;
- lbB = lbX;
-
-
-
-
- for (x=0, point=point0; x<cw; x++, point += hfraq) {
- long pl = ( (((point)) >> 18) );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
-
- L = ((srcB[pl]) | 0xff000000);
- R = ((srcB[pl+1]) | 0xff000000);
-
- lbB[x] = ((((((R & 0x00ff00ff) - (L & 0x00ff00ff))*ratios[x]) >> 8) + (L & 0x00ff00ff)) & 0x00ff00ff) +
- ((((((R>>8) & 0x00ff00ff) - ((L>>8) & 0x00ff00ff))*ratios[x]) + (L & 0xff00ff00)) & 0xff00ff00);
- }
- }
-
- lineT = nlT;
- }
-
-
-
-
- X = ( ((line) & 0x3ffff) >> (18-8) );
-
- for (x=0; x<cw; x++) {
-# 149 "stretch_hvx_32.h"
- dst32[x] = ((((((lbB[x] & 0x00ff00ff) - (lbT[x] & 0x00ff00ff))*X) >> 8) + (lbT[x] & 0x00ff00ff)) & 0x00ff00ff) +
- ((((((lbB[x]>>8) & 0x00ff00ff) - ((lbT[x]>>8) & 0x00ff00ff))*X) + (lbT[x] & 0xff00ff00)) & 0xff00ff00);
-
- }
-
- dst32 += dp4;
- line += vfraq;
- }
-}
-# 35 "stretch_hvx_N.h" 2
-# 21 "stretch_up_down_32.h" 2
-# 49 "stretch_up_down_32.h"
-# 1 "stretch_hvx_N.h" 1
-# 9 "stretch_hvx_N.h"
-static void stretch_hvx_ARGB_down____DSPF_ARGB
-# 1 "stretch_hvx_32.h" 1
-# 11 "stretch_hvx_32.h"
- ( void *dst,
- int dpitch,
- const void *src,
- int spitch,
- int width,
- int height,
- int dst_width,
- int dst_height,
- const StretchCtx *ctx )
-{
- long x, y = 0;
- long cw = ctx->clip.x2 - ctx->clip.x1 + 1;
- long ch = ctx->clip.y2 - ctx->clip.y1 + 1;
- long hfraq = ((long)(width - 0) << 18) / (long)(dst_width);
- long vfraq = ((long)(height - 0) << 18) / (long)(dst_height);
- long dp4 = dpitch / 4;
- long point0 = hfraq + ctx->clip.x1 * hfraq;
- long point = point0;
- long line = vfraq + ctx->clip.y1 * vfraq;
- long ratios[cw];
- u32 *dst32;
-
-
-
-
-
- u32 _lbT[cw+8];
- u32 _lbB[cw+8];
-
- u32 *lbX;
- u32 *lbT = (u32*)((((unsigned long)(&_lbT[0])) + 31) & ~31);
- u32 *lbB = (u32*)((((unsigned long)(&_lbB[0])) + 31) & ~31);
-
- long lineT = -2000;
-
- for (x=0; x<cw; x++) {
- ratios[x] = ( (((((point)) & 0x3ffff) ? : 0x40000) << 8) / (hfraq) );
-
- point += hfraq;
- }
-
- do {} while (0);
-
- dst = (void*)((char*) dst + ctx->clip.x1 * 4 + ctx->clip.y1 * dpitch);
-
- dst32 = (u32*) dst;
-
-
-
-
- for (y=0; y<ch; y++) {
- long X;
- long nlT = ( (((line)-1) >> 18) - 1 );
-
- D_ASSERT( nlT >= 0 );
- D_ASSERT( nlT < height-1 );
-
-
-
-
- if (nlT != lineT) {
- u32 L, R;
- const u32 *srcT = (const u32 *)((const char*) src + spitch * nlT);
- const u32 *srcB = (const u32 *)((const char*) src + spitch * (nlT + 1));
- long diff = nlT - lineT;
-
- if (diff > 1) {
-
-
-
- for (x=0, point=point0; x<cw; x++, point += hfraq) {
- long pl = ( (((point)-1) >> 18) - 1 );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
-
- L = (srcT[pl]);
- R = (srcT[pl+1]);
-
- lbT[x]= ((((((R & 0x00ff00ff) - (L & 0x00ff00ff))*ratios[x]) >> 8) + (L & 0x00ff00ff)) & 0x00ff00ff) +
- ((((((R>>8) & 0x00ff00ff) - ((L>>8) & 0x00ff00ff))*ratios[x]) + (L & 0xff00ff00)) & 0xff00ff00);
-
- L = (srcB[pl]);
- R = (srcB[pl+1]);
-
- lbB[x] = ((((((R & 0x00ff00ff) - (L & 0x00ff00ff))*ratios[x]) >> 8) + (L & 0x00ff00ff)) & 0x00ff00ff) +
- ((((((R>>8) & 0x00ff00ff) - ((L>>8) & 0x00ff00ff))*ratios[x]) + (L & 0xff00ff00)) & 0xff00ff00);
- }
- }
- else {
-
- lbX = lbT;
- lbT = lbB;
- lbB = lbX;
-
-
-
-
- for (x=0, point=point0; x<cw; x++, point += hfraq) {
- long pl = ( (((point)-1) >> 18) - 1 );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
-
- L = (srcB[pl]);
- R = (srcB[pl+1]);
-
- lbB[x] = ((((((R & 0x00ff00ff) - (L & 0x00ff00ff))*ratios[x]) >> 8) + (L & 0x00ff00ff)) & 0x00ff00ff) +
- ((((((R>>8) & 0x00ff00ff) - ((L>>8) & 0x00ff00ff))*ratios[x]) + (L & 0xff00ff00)) & 0xff00ff00);
- }
- }
-
- lineT = nlT;
- }
-
-
-
-
- X = ( (((((line)) & 0x3ffff) ? : 0x40000) << 8) / (vfraq) );
-
- for (x=0; x<cw; x++) {
-# 149 "stretch_hvx_32.h"
- dst32[x] = ((((((lbB[x] & 0x00ff00ff) - (lbT[x] & 0x00ff00ff))*X) >> 8) + (lbT[x] & 0x00ff00ff)) & 0x00ff00ff) +
- ((((((lbB[x]>>8) & 0x00ff00ff) - ((lbT[x]>>8) & 0x00ff00ff))*X) + (lbT[x] & 0xff00ff00)) & 0xff00ff00);
-
- }
-
- dst32 += dp4;
- line += vfraq;
- }
-}
-# 11 "stretch_hvx_N.h" 2
-# 33 "stretch_hvx_N.h"
-static void stretch_hvx_ARGB_down____DSPF_RGB32
-# 1 "stretch_hvx_32.h" 1
-# 11 "stretch_hvx_32.h"
- ( void *dst,
- int dpitch,
- const void *src,
- int spitch,
- int width,
- int height,
- int dst_width,
- int dst_height,
- const StretchCtx *ctx )
-{
- long x, y = 0;
- long cw = ctx->clip.x2 - ctx->clip.x1 + 1;
- long ch = ctx->clip.y2 - ctx->clip.y1 + 1;
- long hfraq = ((long)(width - 0) << 18) / (long)(dst_width);
- long vfraq = ((long)(height - 0) << 18) / (long)(dst_height);
- long dp4 = dpitch / 4;
- long point0 = hfraq + ctx->clip.x1 * hfraq;
- long point = point0;
- long line = vfraq + ctx->clip.y1 * vfraq;
- long ratios[cw];
- u32 *dst32;
-
-
-
-
-
- u32 _lbT[cw+8];
- u32 _lbB[cw+8];
-
- u32 *lbX;
- u32 *lbT = (u32*)((((unsigned long)(&_lbT[0])) + 31) & ~31);
- u32 *lbB = (u32*)((((unsigned long)(&_lbB[0])) + 31) & ~31);
-
- long lineT = -2000;
-
- for (x=0; x<cw; x++) {
- ratios[x] = ( (((((point)) & 0x3ffff) ? : 0x40000) << 8) / (hfraq) );
-
- point += hfraq;
- }
-
- do {} while (0);
-
- dst = (void*)((char*) dst + ctx->clip.x1 * 4 + ctx->clip.y1 * dpitch);
-
- dst32 = (u32*) dst;
-
-
-
-
- for (y=0; y<ch; y++) {
- long X;
- long nlT = ( (((line)-1) >> 18) - 1 );
-
- D_ASSERT( nlT >= 0 );
- D_ASSERT( nlT < height-1 );
-
-
-
-
- if (nlT != lineT) {
- u32 L, R;
- const u32 *srcT = (const u32 *)((const char*) src + spitch * nlT);
- const u32 *srcB = (const u32 *)((const char*) src + spitch * (nlT + 1));
- long diff = nlT - lineT;
-
- if (diff > 1) {
-
-
-
- for (x=0, point=point0; x<cw; x++, point += hfraq) {
- long pl = ( (((point)-1) >> 18) - 1 );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
-
- L = ((srcT[pl]) | 0xff000000);
- R = ((srcT[pl+1]) | 0xff000000);
-
- lbT[x]= ((((((R & 0x00ff00ff) - (L & 0x00ff00ff))*ratios[x]) >> 8) + (L & 0x00ff00ff)) & 0x00ff00ff) +
- ((((((R>>8) & 0x00ff00ff) - ((L>>8) & 0x00ff00ff))*ratios[x]) + (L & 0xff00ff00)) & 0xff00ff00);
-
- L = ((srcB[pl]) | 0xff000000);
- R = ((srcB[pl+1]) | 0xff000000);
-
- lbB[x] = ((((((R & 0x00ff00ff) - (L & 0x00ff00ff))*ratios[x]) >> 8) + (L & 0x00ff00ff)) & 0x00ff00ff) +
- ((((((R>>8) & 0x00ff00ff) - ((L>>8) & 0x00ff00ff))*ratios[x]) + (L & 0xff00ff00)) & 0xff00ff00);
- }
- }
- else {
-
- lbX = lbT;
- lbT = lbB;
- lbB = lbX;
-
-
-
-
- for (x=0, point=point0; x<cw; x++, point += hfraq) {
- long pl = ( (((point)-1) >> 18) - 1 );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
-
- L = ((srcB[pl]) | 0xff000000);
- R = ((srcB[pl+1]) | 0xff000000);
-
- lbB[x] = ((((((R & 0x00ff00ff) - (L & 0x00ff00ff))*ratios[x]) >> 8) + (L & 0x00ff00ff)) & 0x00ff00ff) +
- ((((((R>>8) & 0x00ff00ff) - ((L>>8) & 0x00ff00ff))*ratios[x]) + (L & 0xff00ff00)) & 0xff00ff00);
- }
- }
-
- lineT = nlT;
- }
-
-
-
-
- X = ( (((((line)) & 0x3ffff) ? : 0x40000) << 8) / (vfraq) );
-
- for (x=0; x<cw; x++) {
-# 149 "stretch_hvx_32.h"
- dst32[x] = ((((((lbB[x] & 0x00ff00ff) - (lbT[x] & 0x00ff00ff))*X) >> 8) + (lbT[x] & 0x00ff00ff)) & 0x00ff00ff) +
- ((((((lbB[x]>>8) & 0x00ff00ff) - ((lbT[x]>>8) & 0x00ff00ff))*X) + (lbT[x] & 0xff00ff00)) & 0xff00ff00);
-
- }
-
- dst32 += dp4;
- line += vfraq;
- }
-}
-# 35 "stretch_hvx_N.h" 2
-# 50 "stretch_up_down_32.h" 2
-# 74 "Scaler.cxx" 2
-# 99 "Scaler.cxx"
-# 1 "stretch_up_down_32.h" 1
-# 20 "stretch_up_down_32.h"
-# 1 "stretch_hvx_N.h" 1
-# 9 "stretch_hvx_N.h"
-static void stretch_hvx_RGB32_up____DSPF_RGB32
-# 1 "stretch_hvx_32.h" 1
-# 11 "stretch_hvx_32.h"
- ( void *dst,
- int dpitch,
- const void *src,
- int spitch,
- int width,
- int height,
- int dst_width,
- int dst_height,
- const StretchCtx *ctx )
-{
- long x, y = 0;
- long cw = ctx->clip.x2 - ctx->clip.x1 + 1;
- long ch = ctx->clip.y2 - ctx->clip.y1 + 1;
- long hfraq = ((long)(width - 1) << 18) / (long)(dst_width);
- long vfraq = ((long)(height - 1) << 18) / (long)(dst_height);
- long dp4 = dpitch / 4;
- long point0 = 0 + ctx->clip.x1 * hfraq;
- long point = point0;
- long line = 0 + ctx->clip.y1 * vfraq;
- long ratios[cw];
- u32 *dst32;
-
-
-
-
-
- u32 _lbT[cw+8];
- u32 _lbB[cw+8];
-
- u32 *lbX;
- u32 *lbT = (u32*)((((unsigned long)(&_lbT[0])) + 31) & ~31);
- u32 *lbB = (u32*)((((unsigned long)(&_lbB[0])) + 31) & ~31);
-
- long lineT = -2000;
-
- for (x=0; x<cw; x++) {
- ratios[x] = ( ((point) & 0x3ffff) >> (18-8) );
-
- point += hfraq;
- }
-
- do {} while (0);
-
- dst = (void*)((char*) dst + ctx->clip.x1 * 4 + ctx->clip.y1 * dpitch);
-
- dst32 = (u32*) dst;
-
-
-
-
- for (y=0; y<ch; y++) {
- long X;
- long nlT = ( (((line)) >> 18) );
-
- D_ASSERT( nlT >= 0 );
- D_ASSERT( nlT < height-1 );
-
-
-
-
- if (nlT != lineT) {
- u32 L, R;
- const u32 *srcT = (const u32 *)((const char*) src + spitch * nlT);
- const u32 *srcB = (const u32 *)((const char*) src + spitch * (nlT + 1));
- long diff = nlT - lineT;
-
- if (diff > 1) {
-
-
-
- for (x=0, point=point0; x<cw; x++, point += hfraq) {
- long pl = ( (((point)) >> 18) );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
-
- L = (srcT[pl]);
- R = (srcT[pl+1]);
-
- lbT[x]= ((((((R & 0x00ff00ff) - (L & 0x00ff00ff))*ratios[x]) >> 8) + (L & 0x00ff00ff)) & 0x00ff00ff) +
- ((((((R>>8) & 0x00ff00ff) - ((L>>8) & 0x00ff00ff))*ratios[x]) + (L & 0x0000ff00)) & 0x0000ff00);
-
- L = (srcB[pl]);
- R = (srcB[pl+1]);
-
- lbB[x] = ((((((R & 0x00ff00ff) - (L & 0x00ff00ff))*ratios[x]) >> 8) + (L & 0x00ff00ff)) & 0x00ff00ff) +
- ((((((R>>8) & 0x00ff00ff) - ((L>>8) & 0x00ff00ff))*ratios[x]) + (L & 0x0000ff00)) & 0x0000ff00);
- }
- }
- else {
-
- lbX = lbT;
- lbT = lbB;
- lbB = lbX;
-
-
-
-
- for (x=0, point=point0; x<cw; x++, point += hfraq) {
- long pl = ( (((point)) >> 18) );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
-
- L = (srcB[pl]);
- R = (srcB[pl+1]);
-
- lbB[x] = ((((((R & 0x00ff00ff) - (L & 0x00ff00ff))*ratios[x]) >> 8) + (L & 0x00ff00ff)) & 0x00ff00ff) +
- ((((((R>>8) & 0x00ff00ff) - ((L>>8) & 0x00ff00ff))*ratios[x]) + (L & 0x0000ff00)) & 0x0000ff00);
- }
- }
-
- lineT = nlT;
- }
-
-
-
-
- X = ( ((line) & 0x3ffff) >> (18-8) );
-
- for (x=0; x<cw; x++) {
-# 149 "stretch_hvx_32.h"
- dst32[x] = ((((((lbB[x] & 0x00ff00ff) - (lbT[x] & 0x00ff00ff))*X) >> 8) + (lbT[x] & 0x00ff00ff)) & 0x00ff00ff) +
- ((((((lbB[x]>>8) & 0x00ff00ff) - ((lbT[x]>>8) & 0x00ff00ff))*X) + (lbT[x] & 0x0000ff00)) & 0x0000ff00);
-
- }
-
- dst32 += dp4;
- line += vfraq;
- }
-}
-# 11 "stretch_hvx_N.h" 2
-# 21 "stretch_up_down_32.h" 2
-# 49 "stretch_up_down_32.h"
-# 1 "stretch_hvx_N.h" 1
-# 9 "stretch_hvx_N.h"
-static void stretch_hvx_RGB32_down____DSPF_RGB32
-# 1 "stretch_hvx_32.h" 1
-# 11 "stretch_hvx_32.h"
- ( void *dst,
- int dpitch,
- const void *src,
- int spitch,
- int width,
- int height,
- int dst_width,
- int dst_height,
- const StretchCtx *ctx )
-{
- long x, y = 0;
- long cw = ctx->clip.x2 - ctx->clip.x1 + 1;
- long ch = ctx->clip.y2 - ctx->clip.y1 + 1;
- long hfraq = ((long)(width - 0) << 18) / (long)(dst_width);
- long vfraq = ((long)(height - 0) << 18) / (long)(dst_height);
- long dp4 = dpitch / 4;
- long point0 = hfraq + ctx->clip.x1 * hfraq;
- long point = point0;
- long line = vfraq + ctx->clip.y1 * vfraq;
- long ratios[cw];
- u32 *dst32;
-
-
-
-
-
- u32 _lbT[cw+8];
- u32 _lbB[cw+8];
-
- u32 *lbX;
- u32 *lbT = (u32*)((((unsigned long)(&_lbT[0])) + 31) & ~31);
- u32 *lbB = (u32*)((((unsigned long)(&_lbB[0])) + 31) & ~31);
-
- long lineT = -2000;
-
- for (x=0; x<cw; x++) {
- ratios[x] = ( (((((point)) & 0x3ffff) ? : 0x40000) << 8) / (hfraq) );
-
- point += hfraq;
- }
-
- do {} while (0);
-
- dst = (void*)((char*) dst + ctx->clip.x1 * 4 + ctx->clip.y1 * dpitch);
-
- dst32 = (u32*) dst;
-
-
-
-
- for (y=0; y<ch; y++) {
- long X;
- long nlT = ( (((line)-1) >> 18) - 1 );
-
- D_ASSERT( nlT >= 0 );
- D_ASSERT( nlT < height-1 );
-
-
-
-
- if (nlT != lineT) {
- u32 L, R;
- const u32 *srcT = (const u32 *)((const char*) src + spitch * nlT);
- const u32 *srcB = (const u32 *)((const char*) src + spitch * (nlT + 1));
- long diff = nlT - lineT;
-
- if (diff > 1) {
-
-
-
- for (x=0, point=point0; x<cw; x++, point += hfraq) {
- long pl = ( (((point)-1) >> 18) - 1 );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
-
- L = (srcT[pl]);
- R = (srcT[pl+1]);
-
- lbT[x]= ((((((R & 0x00ff00ff) - (L & 0x00ff00ff))*ratios[x]) >> 8) + (L & 0x00ff00ff)) & 0x00ff00ff) +
- ((((((R>>8) & 0x00ff00ff) - ((L>>8) & 0x00ff00ff))*ratios[x]) + (L & 0x0000ff00)) & 0x0000ff00);
-
- L = (srcB[pl]);
- R = (srcB[pl+1]);
-
- lbB[x] = ((((((R & 0x00ff00ff) - (L & 0x00ff00ff))*ratios[x]) >> 8) + (L & 0x00ff00ff)) & 0x00ff00ff) +
- ((((((R>>8) & 0x00ff00ff) - ((L>>8) & 0x00ff00ff))*ratios[x]) + (L & 0x0000ff00)) & 0x0000ff00);
- }
- }
- else {
-
- lbX = lbT;
- lbT = lbB;
- lbB = lbX;
-
-
-
-
- for (x=0, point=point0; x<cw; x++, point += hfraq) {
- long pl = ( (((point)-1) >> 18) - 1 );
- do {} while (0);
-
- D_ASSERT( pl >= 0 );
- D_ASSERT( pl < width-1 );
-
- L = (srcB[pl]);
- R = (srcB[pl+1]);
-
- lbB[x] = ((((((R & 0x00ff00ff) - (L & 0x00ff00ff))*ratios[x]) >> 8) + (L & 0x00ff00ff)) & 0x00ff00ff) +
- ((((((R>>8) & 0x00ff00ff) - ((L>>8) & 0x00ff00ff))*ratios[x]) + (L & 0x0000ff00)) & 0x0000ff00);
- }
- }
-
- lineT = nlT;
- }
-
-
-
-
- X = ( (((((line)) & 0x3ffff) ? : 0x40000) << 8) / (vfraq) );
-
- for (x=0; x<cw; x++) {
-# 149 "stretch_hvx_32.h"
- dst32[x] = ((((((lbB[x] & 0x00ff00ff) - (lbT[x] & 0x00ff00ff))*X) >> 8) + (lbT[x] & 0x00ff00ff)) & 0x00ff00ff) +
- ((((((lbB[x]>>8) & 0x00ff00ff) - ((lbT[x]>>8) & 0x00ff00ff))*X) + (lbT[x] & 0x0000ff00)) & 0x0000ff00);
-
- }
-
- dst32 += dp4;
- line += vfraq;
- }
-}
-# 11 "stretch_hvx_N.h" 2
-# 50 "stretch_up_down_32.h" 2
-# 100 "Scaler.cxx" 2
-# 112 "Scaler.cxx"
-class Scaler
-{
-
- public: Scaler() {
- }
-
- public: void scale( DFBSurfacePixelFormat format,
- void *dst,
- int dpitch,
- const void *src,
- int spitch,
- int width,
- int height,
- int dst_width,
- int dst_height,
- const DFBRegion &clip )
- {
- D_DEBUG_AT( PluggIt_Scaler, "%s( %s, %p [%d], %p [%d], %dx%d -> %dx%d, clip %4d,%4d-%4dx%4d )\n",
- __FUNCTION__, dfb_pixelformat_name( format ), dst, dpitch, src, spitch, width, height,
- dst_width, dst_height, DFB_RECTANGLE_VALS_FROM_REGION( &clip ) );
-
-
- StretchCtx ctx;
-
- ctx.clip = clip;
-
- switch (format) {
- case DSPF_RGB16:
- if (width <= dst_width || height <= dst_height)
- stretch_hvx_RGB16_up____DSPF_RGB32( dst, dpitch, src, spitch, width, height, dst_width, dst_height, &ctx );
- else
- stretch_hvx_RGB16_down____DSPF_RGB32( dst, dpitch, src, spitch, width, height, dst_width, dst_height, &ctx );
- break;
-
- case DSPF_RGB32:
- if (width <= dst_width || height <= dst_height)
- stretch_hvx_RGB32_up____DSPF_RGB32( dst, dpitch, src, spitch, width, height, dst_width, dst_height, &ctx );
- else
- stretch_hvx_RGB32_down____DSPF_RGB32( dst, dpitch, src, spitch, width, height, dst_width, dst_height, &ctx );
- break;
-
- case DSPF_ARGB:
- if (width <= dst_width || height <= dst_height)
- stretch_hvx_ARGB_up____DSPF_RGB32( dst, dpitch, src, spitch, width, height, dst_width, dst_height, &ctx );
- else
- stretch_hvx_ARGB_down____DSPF_RGB32( dst, dpitch, src, spitch, width, height, dst_width, dst_height, &ctx );
- break;
-
- default:
- D_UNIMPLEMENTED();
- break;
- }
- }
-};
-
-
-
-}
-# 1 "View.cxx"
-# 1 "<built-in>"
-# 1 "<command-line>"
-# 1 "View.cxx"
-namespace PluggIt {
-
-class View
-{
- public: virtual void config( DFBDimension &size ) = 0;
-
- public: virtual void update( const vector<DFBRectangle_C> &rects,
- void *ptr,
- int pitch ) = 0;
-};
-
-}
-# 1 "Source.cxx"
-# 1 "<built-in>"
-# 1 "<command-line>"
-# 1 "Source.cxx"
-namespace PluggIt {
-
-class Source
-{
- protected: class Config {
- protected: Config() {}
- };
-
-
- protected: View *m_view;
- protected: const Config &m_config;
-
- public: Source( View *view, const Config &config ) : m_config(config) {
- m_view = view;
- }
-
-
- public: virtual int MainLoop() = 0;
-};
-
-}
-# 1 "SourceWin32.cxx"
-# 1 "<built-in>"
-# 1 "<command-line>"
-# 1 "SourceWin32.cxx"
-namespace PluggIt {
-
-D_DEBUG_DOMAIN( PluggIt_SourceWin32, "PluggIt/SourceWin32", "PluggIt Source Win32" );
-
-
-# 1 "ScreenHooks.h" 1
-# 28 "ScreenHooks.h"
-extern "C"
-{
- __attribute__((dllexport)) bool setHook(HWND targedWinHwnd);
- __attribute__((dllexport)) bool unsetHook();
-}
-# 7 "SourceWin32.cxx" 2
-
-const UINT specIpcCode = RegisterWindowMessage("HOOK.MESSAGE.CODE");
-
-
-class SourceWin32 :public Source, Runnable
-{
- private: HINSTANCE m_hInstance;
-
- private: HWND m_root;
- private: HWND m_window;
-
- private: DFBPoint m_position;
- private: DFBDimension m_size;
-
- private: HBITMAP m_bitmap;
- private: void *m_pixels;
- private: int m_pitch;
-
- private: HBITMAP m_bitmap2;
- private: void *m_pixels2;
- private: int m_pitch2;
-
- private: HDC m_window_dc;
- private: HDC m_bitmap_dc;
- private: HDC m_bitmap_dc2;
-
- private: Thread *m_thread;
-
- private: Updates m_updates;
-
- private: VIDEODRIVER m_driver;
- private: bool m_using_driver;
-
- private: pthread_mutex_t m_lock;
- private: pthread_cond_t m_cond;
-
-
- public: class Config :public Source::Config {
- friend class SourceWin32;
-
- public: typedef enum {
- WINDOW_SELECTION_NONE,
- WINDOW_SELECTION_TITLE,
- WINDOW_SELECTION_INTERACTIVE
- } WindowSelection;
-
- private: WindowSelection m_selection;
- private: std::string m_title;
- private: bool m_updating;
- private: bool m_use_driver;
-
-
- public: Config( WindowSelection selection,
- const std::string &title = std::string(),
- bool updating = false, bool use_driver = true )
- {
- m_selection = selection;
- m_title = title;
- m_updating = updating;
- m_use_driver = use_driver;
- }
- };
-
-
- public: SourceWin32( View *view, const Config &config ) : Source( view, config ), m_updates(16) {
- D_DEBUG_AT( PluggIt_SourceWin32, "%s( %p )\n", __FUNCTION__, view );
-
- m_hInstance = GetModuleHandle( NULL );
-
- D_DEBUG_AT( PluggIt_SourceWin32, " -> hInstance %p\n", m_hInstance );
-
-
- m_root = GetDesktopWindow();
-
- switch (config.m_selection) {
- case Config::WINDOW_SELECTION_NONE:
- m_window = m_root;
- break;
-
- case Config::WINDOW_SELECTION_TITLE:
- m_window = findWindow( config.m_title );
- if (m_window == 0)
- throw new Exception( "Could not find window with title containing '%s'\n", config.m_title.c_str() );
- break;
-
- case Config::WINDOW_SELECTION_INTERACTIVE:
- pickWindow();
- if (m_window == 0)
- throw new Exception( "Could not interactively pick a window\n" );
- break;
-
- default:
- throw new Exception( "Invalid window selection method\n" );
- }
-
-
- RECT rect;
-
- GetClientRect( m_window, &rect );
-
- m_position.x = rect.left;
- m_position.y = rect.top;
-
- m_size.w = rect.right - rect.left;
- m_size.h = rect.bottom - rect.top;
-
- queueUpdate( 0, 0, m_size.w - 1, m_size.h - 1 );
-
-
- std::string t = getWindowTitle( m_window );
-
- D_INFO( "Source/Win32: Window %d,%d-%ux%u, name '%s'\n",
- m_position.x, m_position.y, m_size.w, m_size.h, t.c_str() );
-
- if (config.m_use_driver)
- m_driver.VIDEODRIVER_start( m_position.x, m_position.y, m_size.w, m_size.h );
-
- m_using_driver = m_driver.mypchangebuf != NULL;
-
- m_view->config( m_size );
-
-
- m_window_dc = GetDC( m_window );
- m_bitmap_dc = CreateCompatibleDC( m_window_dc );
- m_bitmap_dc2 = CreateCompatibleDC( m_window_dc );
-
-
- BITMAPINFO bitmap_info = {{
- biSize: sizeof(BITMAPINFOHEADER),
- biWidth: m_size.w,
- biHeight: m_size.h,
- biPlanes: 1,
- biBitCount: 32,
- biCompression: BI_RGB,
- biSizeImage: 0,
- biXPelsPerMeter: 0,
- biYPelsPerMeter: 0,
- biClrUsed: 0,
- biClrImportant: 0,
- }};
-
- m_bitmap = CreateDIBSection( m_window_dc, &bitmap_info, DIB_RGB_COLORS, &m_pixels, NULL, 0 );
- m_bitmap2 = CreateDIBSection( m_window_dc, &bitmap_info, DIB_RGB_COLORS, &m_pixels2, NULL, 0 );
-
-
- BITMAP bitmap;
-
- GetObject( m_bitmap, sizeof(BITMAP), &bitmap );
-
- m_pitch = bitmap.bmWidthBytes;
-
- GetObject( m_bitmap2, sizeof(BITMAP), &bitmap );
-
- m_pitch2 = bitmap.bmWidthBytes;
-
-
- SelectObject( m_bitmap_dc, m_bitmap );
- SelectObject( m_bitmap_dc2, m_bitmap2 );
-
-
- pthread_mutex_init( &m_lock, NULL );
- pthread_cond_init( &m_cond, NULL );
-
-
- if (!m_using_driver) {
- HWND w;
-
- WNDCLASSEX wndClass;
-
- ZeroMemory( &wndClass, sizeof(wndClass) );
-
- wndClass.cbSize = sizeof(wndClass);
- wndClass.style = CS_HREDRAW | CS_VREDRAW;
- wndClass.lpfnWndProc = MsgWndProc;
- wndClass.cbClsExtra = 0;
- wndClass.cbWndExtra = 0;
- wndClass.hInstance = GetModuleHandle(NULL);
- wndClass.hIcon = NULL;
- wndClass.hIconSm = NULL;
- wndClass.hCursor = LoadCursor( NULL, IDC_UPARROW );
- wndClass.hbrBackground = (HBRUSH) GetStockObject( NULL_BRUSH );
- wndClass.lpszMenuName = NULL;
- wndClass.lpszClassName = "MsgWindow";
-
- if (!RegisterClassEx( &wndClass ))
- throw new Exception( "RegisterClassEx() failed!" );
-
-
- w = CreateWindowEx( 0,
- "MsgWindow",
- "MsgWindow",
- WS_POPUP,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- 1,
- 1,
- NULL,
- NULL,
- GetModuleHandle(NULL),
- this );
-
- if (!setHook( w ))
- throw new Exception( "Failed to set hooks!" );
- }
-
-
-
- m_thread = new Thread( this, "SourceWin32" );
-
- m_thread->start();
- }
-
- virtual ~SourceWin32() {
- m_thread->interrupt();
- m_thread->join();
- delete m_thread;
-
- pthread_mutex_destroy( &m_lock );
- pthread_cond_destroy( &m_cond );
-
- DeleteDC( m_window_dc );
- DeleteDC( m_bitmap_dc );
- DeleteDC( m_bitmap_dc2 );
-
- DeleteObject( m_bitmap );
- DeleteObject( m_bitmap2 );
- }
-
- private: void addRect( const RECT &rect ) {
- if (rect.left >= rect.right)
- return;
-
- if (rect.top >= rect.bottom)
- return;
-
- DFBRegion region( rect.left,
- rect.top,
- rect.right - 1,
- rect.bottom - 1 );
-
- m_updates.addRegion( region );
- }
-
- private: void run() {
- if (m_using_driver) {
- D_ASSERT( m_driver.mypchangebuf != NULL );
-
- unsigned int counter = m_driver.mypchangebuf->counter;
- unsigned int i;
-
- long long last_time = direct_clock_get_abs_millis();
-
- D_DEBUG_AT( PluggIt_SourceWin32, "%s()\n", __FUNCTION__ );
-
- while (!m_thread->isInterrupted()) {
- if (m_driver.mypchangebuf->counter < 1 ||
- m_driver.mypchangebuf->counter >= MAXCHANGES_BUF ||
- counter == m_driver.mypchangebuf->counter)
- usleep( 10000 );
-
- if (counter != m_driver.mypchangebuf->counter) {
- D_DEBUG_AT( PluggIt_SourceWin32, " -> counter: %d -> %d\n", counter, m_driver.mypchangebuf->counter );
-
- if (counter < m_driver.mypchangebuf->counter) {
- for (i=counter+1; i<=m_driver.mypchangebuf->counter; i++) {
- addRect( m_driver.mypchangebuf->pointrect[i].rect );
- }
- }
- else if (counter > m_driver.mypchangebuf->counter) {
- for (i=counter+1; i<MAXCHANGES_BUF; i++) {
- addRect( m_driver.mypchangebuf->pointrect[i].rect );
- }
- for (i=1; i<=m_driver.mypchangebuf->counter; i++) {
- addRect( m_driver.mypchangebuf->pointrect[i].rect );
- }
- }
-
- counter = m_driver.mypchangebuf->counter;
- }
-
- if (direct_clock_get_abs_millis() - last_time > 2000) {
- DFBRegion region( 0,
- 0,
- m_size.w - 1,
- m_size.h - 1 );
-
- m_updates.addRegion( region );
-
- last_time = direct_clock_get_abs_millis();
- }
-
- if (m_updates.num_regions() > 0) {
- vector<DFBRectangle_C> rects;
-
- m_updates.GetRectangles( rects );
-
-
- const DFBRegion &bounding = m_updates.bounding();
-
- D_DEBUG_AT( PluggIt_SourceWin32, " -> %4d,%4d-%4dx%4d (%d regions, %d rectangles)\n",
- DFB_RECTANGLE_VALS_FROM_REGION( &bounding ), m_updates.num_regions(), rects.size() );
-
- m_updates.reset();
-
- flushUpdates( rects );
- }
- }
- }
- else {
- D_DEBUG_AT( PluggIt_SourceWin32, "%s()\n", __FUNCTION__ );
-
- long long last_time = direct_clock_get_abs_millis();
-
- while (!m_thread->isInterrupted()) {
- if (((const Config&)m_config).m_updating) {
- usleep( 100000 );
-
- queueUpdate( 0, 0, m_size.w - 1, m_size.h - 1 );
-
- pthread_mutex_lock( &m_lock );
- }
- else {
- pthread_mutex_lock( &m_lock );
-
- if (m_updates.num_regions() == 0)
- usleep( 10000 );
-
- }
-
- if (direct_clock_get_abs_millis() - last_time > 2000) {
- DFBRegion region( 0,
- 0,
- m_size.w - 1,
- m_size.h - 1 );
-
- m_updates.addRegion( region );
-
- last_time = direct_clock_get_abs_millis();
- }
-
-
- vector<DFBRectangle_C> rects;
-
- if (m_updates.num_regions() > 0) {
- m_updates.GetRectangles( rects );
-
-
- const DFBRegion &bounding = m_updates.bounding();
-
- D_DEBUG_AT( PluggIt_SourceWin32, " -> %4d,%4d-%4dx%4d (%d regions, %d rectangles)\n",
- DFB_RECTANGLE_VALS_FROM_REGION( &bounding ), m_updates.num_regions(), rects.size() );
-
- m_updates.reset();
- }
-
- pthread_mutex_unlock( &m_lock );
-
- if (!rects.empty())
- flushUpdates( rects );
- }
- }
- }
-
-
-
- private: void queueUpdate( int x1, int y1, int x2, int y2 ) {
- D_DEBUG_AT( PluggIt_SourceWin32, "%s( %d,%d-%dx%d )\n", __FUNCTION__, x1, y1, x2 - x1 + 1, y2 - y1 + 1 );
-
- pthread_mutex_lock( &m_lock );
-
- DFBRegion damage( x1, y1, x2, y2 );
-
- m_updates.addRegion( damage );
-
- pthread_mutex_unlock( &m_lock );
-
- pthread_cond_signal( &m_cond );
- }
-
- private: bool flushUpdates( vector<DFBRectangle_C> &rects ) {
- D_DEBUG_AT( PluggIt_SourceWin32, "%s()\n", __FUNCTION__ );
-
- if (m_using_driver) {
- m_view->update( rects, m_driver.myframebuffer, m_pitch );
- }
- else {
- for (unsigned int i=0; i<rects.size(); i++) {
- BitBlt( m_bitmap_dc,
- rects[i].x,
- rects[i].y,
- rects[i].w,
- rects[i].h,
- m_window_dc,
- rects[i].x,
- rects[i].y,
- SRCCOPY );
- }
-
- m_view->update( rects, (void*)((char*) m_pixels + m_pitch * (m_size.h - 1)), - m_pitch );
- }
-
- D_DEBUG_AT( PluggIt_SourceWin32, " -> flush done\n" );
-
- return true;
- }
-
-
-
-
-
- private: static std::string getWindowTitle( HWND window ) {
- char buf[1024] = { 0 };
-
- GetWindowText( window, buf, sizeof(buf) );
-
- D_DEBUG_AT( PluggIt_SourceWin32, "%s( %p ) -> '%s'\n", __FUNCTION__, window, buf );
-
- return buf;
- }
-
-
-
-
- class EnumContext {
- public: const std::string &title;
- public: HWND window;
-
- public: EnumContext( const std::string &title ) : title(title), window(0) {}
- };
-
- private: static BOOL CALLBACK enumWindowsProc( HWND hwnd,
- LPARAM lParam )
- {
- EnumContext *ctx = reinterpret_cast<EnumContext *>( lParam );
-
- D_DEBUG_AT( PluggIt_SourceWin32, "%s( %p )\n", __FUNCTION__, hwnd );
-
- std::string title = getWindowTitle( hwnd );
-
- if (title == ctx->title || title.find( ctx->title ) < title.size())
- ctx->window = hwnd;
-
- return ctx->window == NULL;
- }
-
- private: HWND findWindow( const std::string &title ) {
- D_DEBUG_AT( PluggIt_SourceWin32, "%s( %s )\n", __FUNCTION__, title.c_str() );
-
- EnumContext ctx( title );
-
- EnumWindows( enumWindowsProc, reinterpret_cast<LPARAM>( &ctx ) );
-
- return ctx.window;
- }
-
-
-
-
- static LRESULT CALLBACK WndProc( HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam )
- {
- static SourceWin32 *thiz;
- POINT point;
- CREATESTRUCT *create;
-
- switch (uMsg) {
- case WM_CREATE:
- create = reinterpret_cast<LPCREATESTRUCT>( lParam );
- thiz = reinterpret_cast<SourceWin32 *>( create->lpCreateParams );
-
- SetCursor( LoadCursor( NULL, IDC_CROSS ) );
- break;
-
- case WM_LBUTTONDOWN:
- ShowWindow( hwnd, SW_HIDE );
-
-
- GetCursorPos( &point );
-
- D_DEBUG_AT( PluggIt_SourceWin32, " -> Cursor position is %ld,%ld\n", point.x, point.y );
-
-
- thiz->m_window = WindowFromPoint( point );
- if (thiz->m_window) {
- HWND parent;
-
- while ((parent = GetParent( thiz->m_window )) != NULL)
- thiz->m_window = parent;
- }
-
- D_DEBUG_AT( PluggIt_SourceWin32, " -> Window at cursor is %p: %s\n",
- thiz->m_window, getWindowTitle( thiz->m_window ).c_str() );
-
- DestroyWindow( hwnd );
- break;
-
- case WM_TIMER:
- if (wParam == 666)
- DestroyWindow( hwnd );
- break;
-
- case WM_DESTROY:
- KillTimer( hwnd, 666 );
- PostQuitMessage( 0 );
- break;
-
- default:
- SetTimer( hwnd, 666, 5000, NULL );
-
- return DefWindowProc( hwnd, uMsg, wParam, lParam );
- }
-
- return 0;
- }
-
- private: void pickWindow() {
- D_DEBUG_AT( PluggIt_SourceWin32, "%s()\n", __FUNCTION__ );
-
- HDC hdc;
-
- hdc = GetDC( NULL );
- if (!hdc)
- throw new Exception( "GetDC() returned NULL" );
-
- RECT rect;
-
- GetClipBox( hdc, &rect );
-
- D_DEBUG_AT( PluggIt_SourceWin32, " -> Desktop size: %ldx%ld\n",
- rect.right - rect.left, rect.bottom - rect.top );
-
- ReleaseDC( NULL, hdc );
-
-
-
- WNDCLASSEX wndClass;
-
- ZeroMemory( &wndClass, sizeof(wndClass) );
-
- wndClass.cbSize = sizeof(wndClass);
- wndClass.style = CS_HREDRAW | CS_VREDRAW;
- wndClass.lpfnWndProc = WndProc;
- wndClass.cbClsExtra = 0;
- wndClass.cbWndExtra = 0;
- wndClass.hInstance = m_hInstance;
- wndClass.hIcon = NULL;
- wndClass.hIconSm = NULL;
- wndClass.hCursor = LoadCursor( NULL, IDC_UPARROW );
- wndClass.hbrBackground = (HBRUSH) GetStockObject( NULL_BRUSH );
- wndClass.lpszMenuName = NULL;
- wndClass.lpszClassName = "GrabWindow";
-
- if (!RegisterClassEx( &wndClass ))
- throw new Exception( "RegisterClassEx() failed!\n" );
-
-
- AdjustWindowRect( &rect, WS_CAPTION, FALSE );
-
-
- HWND grabwin;
-
- grabwin = CreateWindowEx( 0,
- "GrabWindow",
- "GrabWindow",
- WS_POPUP,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- rect.right - rect.left,
- rect.bottom - rect.top,
- NULL,
- NULL,
- m_hInstance,
- this );
-
- SetWindowLong( grabwin, GWL_EXSTYLE,
- GetWindowLong( grabwin, GWL_EXSTYLE ) | WS_EX_TRANSPARENT | WS_EX_TOPMOST );
-
- ShowWindow( grabwin, SW_SHOW );
-
-
-
- MSG msg;
-
- while (GetMessage( &msg, 0, 0, 0 )) {
- TranslateMessage( &msg );
-
- D_DEBUG_AT( PluggIt_SourceWin32, " -> Dispatching event (id %u)...\n", msg.message );
-
- DispatchMessage( &msg );
- }
- }
-
-
-
- static LRESULT CALLBACK MsgWndProc( HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam )
- {
- static SourceWin32 *thiz;
- CREATESTRUCT *create;
-
- switch (uMsg) {
- case WM_CREATE:
- create = reinterpret_cast<LPCREATESTRUCT>( lParam );
- thiz = reinterpret_cast<SourceWin32 *>( create->lpCreateParams );
- break;
-
- case WM_DESTROY:
- PostQuitMessage( 0 );
- break;
-
- default:
- if (uMsg == specIpcCode) {
- int x1 = wParam >> 16;
- int y1 = wParam & 0xffff;
- int x2 = lParam >> 16;
- int y2 = lParam & 0xffff;
-
- if (x1 < x2 && y1 < y2)
- thiz->queueUpdate( x1, y1, x2 - 1, y2 - 1 );
-
- break;
- }
-
- return DefWindowProc( hwnd, uMsg, wParam, lParam );
- }
-
- return 0;
- }
-
- public: virtual int MainLoop() {
- MSG msg;
-
- while (GetMessage( &msg, 0, 0, 0 )) {
- TranslateMessage( &msg );
- DispatchMessage( &msg );
- }
-
- return 0;
- }
-};
-
-}
-# 1 "Main.cxx"
-# 1 "<built-in>"
-# 1 "<command-line>"
-# 1 "Main.cxx"
-namespace PluggIt {
-
-D_DEBUG_DOMAIN( PluggIt_Main, "PluggIt/Main", "PluggIt Main" );
-D_DEBUG_DOMAIN( PluggIt_View, "PluggIt/View", "PluggIt View" );
-
-class Main :public View
-{
- class Config {
- public: DFBDimension m_size;
- public: DFBPoint m_offset;
- public: DFBDimension m_resolution;
- public: DFBSurfacePixelFormat m_format;
- public: std::string m_title;
- public: bool m_interactive;
- public: bool m_updating;
- public: bool m_use_driver;
-
- public: Config() :
- m_format(DSPF_UNKNOWN),
- m_interactive(false),
- m_updating(false)
- {
- }
- };
-
-
- private: Config m_config;
- private: Options m_options;
- private: Scaler m_scaler;
-
- private: IDirectFB m_dfb;
- private: IDirectFBDisplayLayer m_layer;
- private: IDirectFBWindow m_window;
- private: IDirectFBSurface m_surface;
- private: IDirectFBEventBuffer m_events;
-
- private: Source *m_source;
-
- private: DFBDimension m_source_resolution;
-
- private: DFBDimension m_view_size;
- private: DFBDimension m_view_resolution;
- private: bool m_view_visible;
- private: DFBSurfacePixelFormat m_view_format;
-
-
- public: Main() :
- m_source(NULL),
- m_view_visible(false)
- {
- D_DEBUG_AT( PluggIt_Main, "%s()\n", __FUNCTION__ );
-
- m_options.addOption( new Options::OptionDimension( "-s", "--size", "<width>x<height>", "Size of view", m_config.m_size ) );
- m_options.addOption( new Options::OptionPoint ( "-o", "--offset", "<x>,<y>", "Offset of view", m_config.m_offset ) );
- m_options.addOption( new Options::OptionDimension( "-r", "--resolution", "<X>x<Y>", "Resolution of view", m_config.m_resolution ) );
- m_options.addOption( new Options::OptionFormat ( "-f", "--format", "<pixelformat>", "Pixel format of view", m_config.m_format ) );
- m_options.addOption( new Options::OptionString ( "-t", "--title", "<string>", "Title of window to show", m_config.m_title ) );
- m_options.addOption( new Options::OptionBool ( "-i", "--interactive", "", "Use interactive window picking", m_config.m_interactive ) );
- m_options.addOption( new Options::OptionBool ( "-u", "--updating", "", "Update continuously", m_config.m_updating ) );
- m_options.addOption( new Options::OptionBool ( "-d", "--driver", "", "Use driver mode", m_config.m_use_driver ) );
- }
-
- public: void main( int argc, char *argv[] ) {
- D_DEBUG_AT( PluggIt_Main, "%s()\n", __FUNCTION__ );
-
- try {
-
- DirectFB::Init( &argc, &argv );
-
- if (!m_options.parseCommandLine( argc, argv ))
- return;
-
- initDFB();
- initSource();
-
- run();
- }
- catch (DFBException *e) {
- cerr << endl;
- cerr << "Caught exception!" << endl;
- cerr << " ==> " << e << endl;
- }
- catch (Exception *e) {
- cerr << endl;
- cerr << "Caught exception!" << endl;
- cerr << " ==> " << e << endl;
- }
- }
-
- private: void initDFB() {
- D_DEBUG_AT( PluggIt_Main, "%s()\n", __FUNCTION__ );
-
-
- m_dfb = DirectFB::Create();
-
- m_layer = m_dfb.GetDisplayLayer( DLID_PRIMARY );
-
- m_events = m_dfb.CreateEventBuffer();
- }
-
- private: void initSource() {
- D_DEBUG_AT( PluggIt_Main, "%s()\n", __FUNCTION__ );
-
-
- SourceWin32::Config config( m_config.m_interactive ?
- SourceWin32::Config::WINDOW_SELECTION_INTERACTIVE :
- (m_config.m_title.size() > 0 ?
- SourceWin32::Config::WINDOW_SELECTION_TITLE :
- SourceWin32::Config::WINDOW_SELECTION_NONE), m_config.m_title,
- m_config.m_updating, m_config.m_use_driver );
-
- m_source = new SourceWin32( this, config );
-# 122 "Main.cxx"
- }
-
- private: void run() {
- m_source->MainLoop();
- }
-
- public: virtual void config( DFBDimension &source_resolution ) {
- D_DEBUG_AT( PluggIt_View, "%s( %u, %u )\n", __FUNCTION__, source_resolution.w, source_resolution.h );
-
-
- if (m_source_resolution == source_resolution) {
- D_DEBUG_AT( PluggIt_View, " -> unchanged source size\n" );
- return;
- }
-
- m_source_resolution = source_resolution;
-
-
-
- DFBDimension resolution = m_config.m_resolution;
-
- if (!resolution.w) {
- if (!resolution.h) {
- resolution = source_resolution;
-
- D_DEBUG_AT( PluggIt_View, " -> no width/height\n" );
- }
- else {
- resolution.w = resolution.h * source_resolution.w / source_resolution.h;
-
- D_DEBUG_AT( PluggIt_View, " -> no width\n" );
- }
- }
- else if (!resolution.h) {
- resolution.h = resolution.w * source_resolution.h / source_resolution.w;
-
- D_DEBUG_AT( PluggIt_View, " -> no height\n" );
- }
-
- D_DEBUG_AT( PluggIt_View, " -> resolution %ux%u\n", resolution.w, resolution.h );
-
-
-
- DFBDimension size = m_config.m_size;
-
- if (!size.w) {
- if (!size.h) {
- size = resolution;
-
- D_DEBUG_AT( PluggIt_View, " -> no width/height\n" );
- }
- else {
- size.w = size.h * resolution.w / resolution.h;
-
- D_DEBUG_AT( PluggIt_View, " -> no width\n" );
- }
- }
- else if (!size.h) {
- size.h = size.w * resolution.h / resolution.w;
-
- D_DEBUG_AT( PluggIt_View, " -> no height\n" );
- }
-
- D_DEBUG_AT( PluggIt_View, " -> %ux%u\n", size.w, size.h );
-
-
- if (m_view_resolution == resolution)
- D_DEBUG_AT( PluggIt_View, " -> unchanged view resolution\n" );
-
- if (m_view_size == size) {
- D_DEBUG_AT( PluggIt_View, " -> unchanged view size\n" );
- return;
- }
-
- if (m_window)
- m_window.Resize( size.w, size.h );
- else {
-
- DFBWindowDescription desc;
-
- desc.flags = (DFBWindowDescriptionFlags)( DWDESC_POSX | DWDESC_POSY |
- DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_PIXELFORMAT );
- desc.posx = 0;
- desc.posy = 0;
- desc.width = size.w;
- desc.height = size.h;
- desc.pixelformat = m_config.m_format;
-
- m_window = m_layer.CreateWindow( desc );
-
- m_surface = m_window.GetSurface();
-
- m_view_format = m_surface.GetPixelFormat();
-
- m_window.AttachEventBuffer( m_events );
- }
-
- m_view_size = size;
- m_view_resolution = resolution;
-
-
- D_DEBUG_AT( PluggIt_View, " -> view size %4ux%4u\n", m_view_size.w, m_view_size.h );
- D_DEBUG_AT( PluggIt_View, " -> view resolution %4ux%4u\n", m_view_resolution.w, m_view_resolution.h );
- D_DEBUG_AT( PluggIt_View, " -> source resolution %4ux%4u\n", m_source_resolution.w, m_source_resolution.h );
- }
-
- public: virtual void update( const vector<DFBRectangle_C> &rects,
- void *ptr,
- int pitch )
- {
- unsigned int i;
- DFBRegion clip( m_view_size );
- const DFBPoint &offset = m_config.m_offset;
- bool first = true;
- DFBRegion flip;
-
- D_DEBUG_AT( PluggIt_View, "%s( [%u], %p, %d )\n", __FUNCTION__, rects.size(), ptr, pitch );
-
- D_ASSERT( rects.size() > 0 );
- D_ASSERT( ptr != NULL );
-
-
-
- if (m_source_resolution == m_view_resolution) {
- D_DEBUG_AT( PluggIt_View, " -> unscaled %4dx%4d\n",
- m_source_resolution.w, m_source_resolution.h );
-
- if (m_view_format == DSPF_RGB16) {
- int tp = ((m_view_size.w * 2) + 7) & ~7;
- void *tmp = malloc( tp * m_view_size.h );
-
- for (i=0; i<rects.size(); i++) {
- D_DEBUG_AT( PluggIt_View, " -> [%2d] %4d,%4d-%4dx%4d (original)\n",
- i, DFB_RECTANGLE_VALS( &rects[i] ) );
-
- DFBRegion region( DFBRectangle(rects[i]) - offset );
-
- D_DEBUG_AT( PluggIt_View, " -> %4d,%4d-%4dx%4d (translated)\n",
- DFB_RECTANGLE_VALS_FROM_REGION( &region ) );
-
- ptr = (void*)((char*) ptr + offset.x * 4 + offset.y * pitch);
-
-
- if (dfb_region_region_intersect( &region, &clip )) {
- D_DEBUG_AT( PluggIt_View, " -> %4d,%4d-%4dx%4d (clipped update)\n",
- DFB_RECTANGLE_VALS_FROM_REGION( &region ) );
-
- DFBRectangle rect( region );
-
- dfb_convert_to_rgb16( DSPF_RGB32,
- (void*)((char*) ptr + rect.x * 4 + rect.y * pitch), pitch,
- m_view_size.h, (u16*) tmp, tp, rect.w, rect.h );
-
- m_surface.Write( (char*) tmp + DFB_BYTES_PER_LINE( m_view_format, region.x1 ) + region.y1 * tp, tp, &rect );
-
- if (first) {
- first = false;
- flip = region;
- }
- else
- flip.unionWith( region );
-
- }
- }
-
- free( tmp );
- }
- else {
- for (i=0; i<rects.size(); i++) {
- D_DEBUG_AT( PluggIt_View, " -> [%2d] %4d,%4d-%4dx%4d (original)\n",
- i, DFB_RECTANGLE_VALS( &rects[i] ) );
-
- DFBRegion region( DFBRectangle(rects[i]) - offset );
-
- D_DEBUG_AT( PluggIt_View, " -> %4d,%4d-%4dx%4d (translated)\n",
- DFB_RECTANGLE_VALS_FROM_REGION( &region ) );
-
- ptr = (void*)((char*) ptr + offset.x * 4 + offset.y * pitch);
-
-
- if (dfb_region_region_intersect( &region, &clip )) {
- D_DEBUG_AT( PluggIt_View, " -> %4d,%4d-%4dx%4d (clipped update)\n",
- DFB_RECTANGLE_VALS_FROM_REGION( &region ) );
-
- DFBRectangle rect( region );
-
- if (m_view_format == DSPF_ARGB) {
- u32 *p = (u32*)((char*) ptr + rect.x * 4 + rect.y * pitch);
-
- for (int y=0; y<rect.h; y++) {
- for (int x=0; x<rect.w; x++)
- p[x] |= 0xff000000;
-
- p = (u32*)((char*) p + pitch);
- }
- }
-
- D_DEBUG_AT( PluggIt_View, " -> Write...\n" );
- m_surface.Write( (char*) ptr + DFB_BYTES_PER_LINE( m_view_format, region.x1 ) + region.y1 * pitch, pitch, &rect );
- D_DEBUG_AT( PluggIt_View, " -> Write done.\n" );
-
- if (first) {
- first = false;
- flip = region;
- }
- else
- flip.unionWith( region );
-
- }
- }
- }
- }
- else {
- int tp = ((m_view_size.w * 4) + 7) & ~7;
- void *tmp = malloc( tp * m_view_size.h );
-
- D_DEBUG_AT( PluggIt_View, " -> scaled %4dx%4d => %4dx%4d\n",
- m_source_resolution.w, m_source_resolution.h,
- m_view_resolution.w, m_view_resolution.h );
-
- for (i=0; i<rects.size(); i++) {
- D_DEBUG_AT( PluggIt_View, " -> [%2d] %4d,%4d-%4dx%4d (original)\n",
- i, DFB_RECTANGLE_VALS( &rects[i] ) );
-
- DFBRegion region( DFBRectangle(rects[i]) - offset );
-
- D_DEBUG_AT( PluggIt_View, " -> %4d,%4d-%4dx%4d (translated)\n",
- DFB_RECTANGLE_VALS_FROM_REGION( &region ) );
-
- ptr = (void*)((char*) ptr + offset.x * 4 + offset.y * pitch);
-
-
- region.x1 = region.x1 * m_view_resolution.w / m_source_resolution.w;
- region.y1 = region.y1 * m_view_resolution.h / m_source_resolution.h;
- region.x2 = region.x2 * m_view_resolution.w / m_source_resolution.w;
- region.y2 = region.y2 * m_view_resolution.h / m_source_resolution.h;
-
- if (region.x1 > 0)
- region.x1--;
-
- if (region.y1 > 0)
- region.y1--;
-
- if (region.x2 < m_view_resolution.w-1)
- region.x2++;
- if (region.x2 < m_view_resolution.w-1)
- region.x2++;
-
- if (region.y2 < m_view_resolution.h-1)
- region.y2++;
- if (region.y2 < m_view_resolution.h-1)
- region.y2++;
-
- D_DEBUG_AT( PluggIt_View, " -> %4d,%4d-%4dx%4d (scaled)\n",
- DFB_RECTANGLE_VALS_FROM_REGION( &region ) );
-
-
- if (dfb_region_region_intersect( &region, &clip )) {
- D_DEBUG_AT( PluggIt_View, " -> %4d,%4d-%4dx%4d (clipped)\n",
- DFB_RECTANGLE_VALS_FROM_REGION( &region ) );
-
- DFBRectangle rect( region );
-
- m_scaler.scale( m_view_format, tmp, tp, ptr, pitch,
- m_source_resolution.w, m_source_resolution.h,
- m_view_resolution.w, m_view_resolution.h, region );
-
- m_surface.Write( (char*) tmp + DFB_BYTES_PER_LINE( m_view_format, region.x1 ) + region.y1 * tp, tp, &rect );
-
- if (first) {
- first = false;
- flip = region;
- }
- else
- flip.unionWith( region );
-
- }
- }
-
- free( tmp );
- }
-
- m_surface.Flip( &flip );
-
- if (!m_view_visible) {
- m_window.SetOpacity( 0xff );
-
- m_view_visible = true;
- }
- }
-};
-
-}
-extern "C" {
-# 1 "main.c"
-# 1 "<built-in>"
-# 1 "<command-line>"
-# 1 "main.c"
-
-int
-main( int argc, char *argv[] )
-{
- PluggIt::Main *main = new PluggIt::Main();
-
- main->main( argc, argv );
-
- delete main;
-}
-}
diff --git a/src/classes.h b/src/classes.h
index 4809afb..8f81e90 100644
--- a/src/classes.h
+++ b/src/classes.h
@@ -32,6 +32,12 @@ extern "C" {
/*
+ * PluggIt
+ */
+#include "KeySend.h"
+
+
+/*
* Win32
*/
#ifdef __WIN32__
diff --git a/vnchooks.dll b/vnchooks.dll
new file mode 100644
index 0000000..ca80568
--- /dev/null
+++ b/vnchooks.dll
Binary files differ