diff --git a/project/include/LimeThread.h b/project/include/LimeThread.h index 63283e872..c5e041c22 100644 --- a/project/include/LimeThread.h +++ b/project/include/LimeThread.h @@ -1,32 +1,36 @@ #ifndef LIME_THREAD_H #define LIME_THREAD_H -#ifndef HX_WINDOWS -#ifndef EPPC -#include -#endif -#else -#include -#undef min -#undef max -#endif -namespace lime -{ -#ifndef HX_WINDOWS -#ifdef EPPC -typedef int ThreadId; -#else -typedef pthread_t ThreadId; -#endif -#else -typedef DWORD ThreadId; -#endif + #ifndef HX_WINDOWS + #ifndef EPPC + #include + #endif + #else + #include + #undef min + #undef max + #endif -ThreadId GetThreadId(); -bool IsMainThread(); -void SetMainThread(); -} +namespace lime { -#endif + #ifndef HX_WINDOWS + #ifdef EPPC + typedef int ThreadId; + #else + typedef pthread_t ThreadId; + #endif + #else + typedef DWORD ThreadId; + #endif + + ThreadId GetThreadId(); + bool IsMainThread(); + void SetMainThread(); + + +} //namespace lime + + +#endif //LIME_THREAD_H diff --git a/project/include/platform/tizen/TizenApplication.h b/project/include/platform/tizen/TizenApplication.h index 2fd86a636..dd5c46071 100644 --- a/project/include/platform/tizen/TizenApplication.h +++ b/project/include/platform/tizen/TizenApplication.h @@ -11,12 +11,13 @@ #include #include #include +//#include namespace lime { - class TizenApplication : public Tizen::App::UiApp, public Tizen::System::IScreenEventListener, public Tizen::Ui::IKeyEventListener, public Tizen::Base::Runtime::ITimerEventListener, public Tizen::Ui::ITouchEventListener { + class TizenApplication : public Tizen::App::UiApp, public Tizen::System::IScreenEventListener, public Tizen::Ui::IKeyEventListener, public Tizen::Base::Runtime::ITimerEventListener, public Tizen::Ui::ITouchEventListener /*, public Tizen::Uix::Sensor::ISensorEventListener*/ { public: @@ -31,6 +32,7 @@ namespace lime { //virtual bool OnAppWillTerminate (void); virtual void OnBackground (void); virtual void OnBatteryLevelChanged (Tizen::System::BatteryLevel batteryLevel); + //virtual void OnDataReceived (Tizen::Uix::Sensor::SensorType sensorType, Tizen::Uix::Sensor::SensorData& sensorData, result r); virtual void OnForeground (void); virtual void OnLowMemory (void); virtual void OnKeyLongPressed (const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode); @@ -55,6 +57,7 @@ namespace lime { Tizen::Graphics::Opengl::EGLConfig mEGLConfig; Tizen::Graphics::Opengl::EGLContext mEGLContext; Tizen::Ui::Controls::Form* mForm; + //Tizen::Uix::Sensor::SensorManager* mSensorManager; Tizen::Base::Runtime::Timer* mTimer; }; diff --git a/project/src/common/ExternalInterface.cpp b/project/src/common/ExternalInterface.cpp index ed6880059..41d4cab39 100644 --- a/project/src/common/ExternalInterface.cpp +++ b/project/src/common/ExternalInterface.cpp @@ -3691,6 +3691,67 @@ value lime_bitmap_data_dump_bits(value inSurface) DEFINE_PRIM(lime_bitmap_data_dump_bits,1); +value lime_surface_get_base(value inSurface) +{ + Surface *surf; + if (AbstractToObject(inSurface,surf)) + { + return alloc_int((intptr_t)surf->GetBase()); + } + return alloc_null(); +} +DEFINE_PRIM(lime_surface_get_base,1); + + +value lime_surface_get_stride(value inSurface) +{ + Surface *surf; + if (AbstractToObject(inSurface,surf)) + { + return alloc_int(surf->GetStride()); + } + return alloc_null(); +} +DEFINE_PRIM(lime_surface_get_stride,1); + + +value lime_surface_begin_render(value inSurface, value inRect) +{ + Surface *surf; + if (AbstractToObject(inSurface,surf)) + { + Rect rect; + FromValue(rect,inRect); + surf->BeginRender(rect); + } + return alloc_null(); +} +DEFINE_PRIM(lime_surface_begin_render,2); + + +value lime_surface_end_render(value inSurface) +{ + Surface *surf; + if (AbstractToObject(inSurface,surf)) + { + surf->EndRender(); + } + return alloc_null(); +} +DEFINE_PRIM(lime_surface_end_render,1); + + +/*value lime_surface_get_pixel_format(value inSurface) +{ + Surface *surf; + if (AbstractToObject(inSurface,surf)) + { + return alloc_int(surf->GetStride()); + } + return alloc_null(); +}*/ + + // --- Video -------------------------------------------------- diff --git a/project/src/common/Thread.cpp b/project/src/common/Thread.cpp index eefc49461..ad45105df 100644 --- a/project/src/common/Thread.cpp +++ b/project/src/common/Thread.cpp @@ -1,30 +1,31 @@ #include -namespace lime -{ -ThreadId GetThreadId() -{ - #ifdef HX_WINDOWS - return GetCurrentThreadId(); - #else - return pthread_self(); - #endif -} +namespace lime { + static ThreadId sMainThread = 0; + ThreadId GetThreadId() { -static ThreadId sMainThread = 0; + #ifdef HX_WINDOWS + return GetCurrentThreadId(); + #else + return pthread_self(); + #endif -void SetMainThread() -{ - sMainThread = GetThreadId(); -} + } -bool IsMainThread() -{ - return sMainThread==GetThreadId(); -} + bool IsMainThread() { + + return sMainThread == GetThreadId(); + + } + + void SetMainThread() { + + sMainThread = GetThreadId(); + + } } // end namespace lime diff --git a/project/src/platform/android/JNI.cpp b/project/src/platform/android/JNI.cpp index 7ac6c153a..f04e47dcf 100644 --- a/project/src/platform/android/JNI.cpp +++ b/project/src/platform/android/JNI.cpp @@ -1193,7 +1193,7 @@ DEFINE_PRIM(lime_jni_call_member,3); value lime_jni_get_env() { JNIEnv *env = GetEnv(); - return alloc_int((int)env); + return alloc_int((intptr_t)env); } DEFINE_PRIM(lime_jni_get_env,0); diff --git a/project/src/platform/mac/System.mm b/project/src/platform/mac/System.mm index d7d55b54e..df43e1916 100644 --- a/project/src/platform/mac/System.mm +++ b/project/src/platform/mac/System.mm @@ -5,71 +5,86 @@ #include #include + namespace lime { -bool LaunchBrowser(const char *inUtf8URL) -{ - #ifndef OBJC_ARC - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - #endif - NSString *str = [[NSString alloc] initWithUTF8String:inUtf8URL]; - [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString: str]]; - #ifndef OBJC_ARC - [str release]; - [pool drain]; - #endif - return true; -} + bool LaunchBrowser(const char *inUtf8URL) { -std::string CapabilitiesGetLanguage() -{ - #ifndef OBJC_ARC - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - #endif - NSString *language = [[NSLocale preferredLanguages] objectAtIndex:0]; - std::string result = (language?[language UTF8String]:""); - #ifndef OBJC_ARC - [pool drain]; - #endif - return result; -} + #ifndef OBJC_ARC + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + #endif -double CapabilitiesGetScreenDPI() -{ - #ifndef OBJC_ARC - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - #endif - - NSScreen *screen = [NSScreen mainScreen]; - NSDictionary *description = [screen deviceDescription]; - NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue]; - CGSize displayPhysicalSize = CGDisplayScreenSize( - [[description objectForKey:@"NSScreenNumber"] unsignedIntValue]); - double result = ((displayPixelSize.width / displayPhysicalSize.width) + (displayPixelSize.height / displayPhysicalSize.height)) * 0.5 * 25.4; - - #ifndef OBJC_ARC - [pool drain]; - #endif - return result; -} + NSString *str = [[NSString alloc] initWithUTF8String:inUtf8URL]; + [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString: str]]; + + #ifndef OBJC_ARC + [str release]; + [pool drain]; + #endif -double CapabilitiesGetPixelAspectRatio() { - #ifndef OBJC_ARC - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - #endif - - NSScreen *screen = [NSScreen mainScreen]; - NSDictionary *description = [screen deviceDescription]; - NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue]; - CGSize displayPhysicalSize = CGDisplayScreenSize( - [[description objectForKey:@"NSScreenNumber"] unsignedIntValue]); - double result = (displayPixelSize.width / displayPhysicalSize.width) / (displayPixelSize.height / displayPhysicalSize.height); - - #ifndef OBJC_ARC - [pool drain]; - #endif - return result; -} + return true; + + } + + std::string CapabilitiesGetLanguage() { + + #ifndef OBJC_ARC + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + #endif + + NSString *language = [[NSLocale preferredLanguages] objectAtIndex:0]; + std::string result = (language?[language UTF8String]:""); + + #ifndef OBJC_ARC + [pool drain]; + #endif + + return result; + + } + + double CapabilitiesGetScreenDPI() { + + #ifndef OBJC_ARC + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + #endif + + NSScreen *screen = [NSScreen mainScreen]; + NSDictionary *description = [screen deviceDescription]; + NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue]; + CGSize displayPhysicalSize = + CGDisplayScreenSize( [[description objectForKey:@"NSScreenNumber"] unsignedIntValue] ); + double result = ((displayPixelSize.width / displayPhysicalSize.width) + (displayPixelSize.height / displayPhysicalSize.height)) * 0.5 * 25.4; + + #ifndef OBJC_ARC + [pool drain]; + #endif + + return result; + + } + + double CapabilitiesGetPixelAspectRatio() { + + #ifndef OBJC_ARC + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + #endif + + NSScreen *screen = [NSScreen mainScreen]; + NSDictionary *description = [screen deviceDescription]; + NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue]; + CGSize displayPhysicalSize = + CGDisplayScreenSize( [[description objectForKey:@"NSScreenNumber"] unsignedIntValue] ); + + double result = (displayPixelSize.width / displayPhysicalSize.width) / (displayPixelSize.height / displayPhysicalSize.height); + + #ifndef OBJC_ARC + [pool drain]; + #endif + + return result; + + } std::string FileDialogOpen( const std::string &title, const std::string &text, const std::vector &fileTypes ) { diff --git a/project/src/platform/tizen/System.cpp b/project/src/platform/tizen/System.cpp index 6f5b8df70..7b602e9ec 100644 --- a/project/src/platform/tizen/System.cpp +++ b/project/src/platform/tizen/System.cpp @@ -14,7 +14,7 @@ namespace lime { double CapabilitiesGetScreenDPI () { - return 200; + return 306; } @@ -72,23 +72,6 @@ namespace lime { } - bool ClearUserPreference (const char *inId) { - - return true; - - /*JNIEnv *env = GetEnv(); - jclass cls = FindClass("org/haxe/lime/GameActivity"); - jmethodID mid = env->GetStaticMethodID(cls, "clearUserPreference", "(Ljava/lang/String;)V"); - if (mid == 0) - return false; - - jstring jInId = env->NewStringUTF( inId ); - env->CallStaticVoidMethod(cls, mid, jInId ); - return true;*/ - - } - - std::string FileDialogFolder (const std::string &title, const std::string &text) { return ""; @@ -110,86 +93,9 @@ namespace lime { } - bool GetAcceleration (double &outX, double &outY, double &outZ) { - - //if (gFixedOrientation == 3 || gFixedOrientation == 4) { - - outX = 0; - outY = 0; - outZ = 1; - - //} - - /*int result = accelerometer_read_forces (&outX, &outY, &outZ); - - if (getenv ("FORCE_PORTRAIT") != NULL) { - - int cache = outX; - outX = outY; - outY = -cache; - - } - - outZ = -outZ;*/ - - return true; - - } - - - std::string GetUserPreference (const char *inId) { - - return ""; - - /*JNIEnv *env = GetEnv(); - jclass cls = FindClass("org/haxe/lime/GameActivity"); - jmethodID mid = env->GetStaticMethodID(cls, "getUserPreference", "(Ljava/lang/String;)Ljava/lang/String;"); - if (mid == 0) - { - return std::string(""); - } - - jstring jInId = env->NewStringUTF(inId); - jstring jPref = (jstring) env->CallStaticObjectMethod(cls, mid, jInId); - env->DeleteLocalRef(jInId); - const char *nativePref = env->GetStringUTFChars(jPref, 0); - std::string result(nativePref); - env->ReleaseStringUTFChars(jPref, nativePref); - return result;*/ - - } - - void HapticVibrate (int period, int duration) { - - } - - - bool LaunchBrowser (const char *inUtf8URL) { - - return false; - - } - - - bool SetUserPreference (const char *inId, const char *inPreference) { - - /*JNIEnv *env = GetEnv(); - jclass cls = FindClass("org/haxe/lime/GameActivity"); - jmethodID mid = env->GetStaticMethodID(cls, "setUserPreference", "(Ljava/lang/String;Ljava/lang/String;)V"); - if (mid == 0) - return false; - - jstring jInId = env->NewStringUTF( inId ); - jstring jPref = env->NewStringUTF ( inPreference ); - env->CallStaticVoidMethod(cls, mid, jInId, jPref ); - env->DeleteLocalRef(jInId); - env->DeleteLocalRef(jPref); - return true;*/ - - return true; } diff --git a/project/src/platform/tizen/TizenApplication.cpp b/project/src/platform/tizen/TizenApplication.cpp index 9b3bbf7bb..d465d854b 100644 --- a/project/src/platform/tizen/TizenApplication.cpp +++ b/project/src/platform/tizen/TizenApplication.cpp @@ -8,6 +8,9 @@ namespace lime { int gFixedOrientation = -1; + //double mAccelX; + //double mAccelY; + //double mAccelZ; int mSingleTouchID; FrameCreationCallback sgCallback; unsigned int sgFlags; @@ -63,6 +66,9 @@ namespace lime { TizenApplication::TizenApplication (void) { + //mAccelX = 0; + //mAccelY = 0; + //mAccelZ = 0; mEGLDisplay = EGL_NO_DISPLAY; mEGLSurface = EGL_NO_SURFACE; mEGLConfig = null; @@ -86,6 +92,14 @@ namespace lime { } + /*if (mSensorManager) { + + mSensorManager->RemoveSensorListener (*this); + delete mSensorManager; + mSensorManager = null; + + }*/ + Event close (etQuit); sgTizenFrame->HandleEvent (close); @@ -129,7 +143,20 @@ namespace lime { mForm->AddTouchEventListener (*this); mForm->SetMultipointTouchEnabled (true); - bool ok = limeEGLCreate (mForm, sgWidth, sgHeight, 2, (sgFlags & wfDepthBuffer) ? 16 : 0, (sgFlags & wfStencilBuffer) ? 8 : 0, 0); + /*long interval = 0L; + mSensorManager = new Tizen::Uix::Sensor::SensorManager (); + mSensorManager->Construct (); + mSensorManager->GetMinInterval (Tizen::Uix::Sensor::SENSOR_TYPE_ACCELERATION, interval); + + if (interval < 50) { + + interval = 50; + + } + + mSensorManager->AddSensorListener (*this, Tizen::Uix::Sensor::SENSOR_TYPE_ACCELERATION, interval, true);*/ + + bool ok = limeEGLCreate (mForm, sgWidth, sgHeight, 1, (sgFlags & wfDepthBuffer) ? 16 : 0, (sgFlags & wfStencilBuffer) ? 8 : 0, 0); mTimer = new (std::nothrow) Tizen::Base::Runtime::Timer; mTimer->Construct (*this); @@ -147,7 +174,7 @@ namespace lime { bool TizenApplication::OnAppTerminating (Tizen::App::AppRegistry& appRegistry, bool forcedTermination) { Cleanup (); - + return true; } @@ -173,6 +200,17 @@ namespace lime { void TizenApplication::OnBatteryLevelChanged (Tizen::System::BatteryLevel batteryLevel) {} + //void OnDataReceived (Tizen::Uix::Sensor::SensorType sensorType, Tizen::Uix::Sensor::SensorData& sensorData, result r) { + + //Tizen::Uix::Sensor::AccelerationSensorData& data = static_cast(sensorData); + + //mAccelX = -data.x; + //mAccelY = -data.y; + //mAccelZ = -data.z; + + //} + + void TizenApplication::OnForeground (void) { Event activate (etActivate); @@ -314,4 +352,100 @@ namespace lime { } + bool ClearUserPreference (const char *inId) { + + result r = E_SUCCESS; + + Tizen::App::AppRegistry* appRegistry = Tizen::App::AppRegistry::GetInstance (); + r = appRegistry->Remove (inId); + + return (r == E_SUCCESS); + + } + + + bool GetAcceleration (double &outX, double &outY, double &outZ) { + + //if (gFixedOrientation == 3 || gFixedOrientation == 4) { + + //outX = mAccelX; + //outY = mAccelY; + //outZ = mAccelZ; + outX = 0; + outY = 0; + outZ = 1; + return true; + + //} + + /*int result = accelerometer_read_forces (&outX, &outY, &outZ); + + if (getenv ("FORCE_PORTRAIT") != NULL) { + + int cache = outX; + outX = outY; + outY = -cache; + + } + + outZ = -outZ;*/ + + } + + + std::string GetUserPreference (const char *inId) { + + Tizen::Base::String value; + result r = E_SUCCESS; + + Tizen::App::AppRegistry* appRegistry = Tizen::App::AppRegistry::GetInstance (); + r = appRegistry->Get (inId, value); + + if (r == E_SUCCESS) { + + std::wstring dir = std::wstring (value.GetPointer ()); + return std::string (dir.begin (), dir.end ()); + + } + + return ""; + + } + + + bool LaunchBrowser (const char *inUtf8URL) { + + Tizen::Base::String uri = Tizen::Base::String(inUtf8URL); + Tizen::App::AppControl* pAc = Tizen::App::AppManager::FindAppControlN (L"tizen.internet", L"http://tizen.org/appcontrol/operation/view"); + + if (pAc) { + + pAc->Start (&uri, null, null, null); + delete pAc; + + } + + return true; + + } + + + bool SetUserPreference (const char *inId, const char *inPreference) { + + result r = E_SUCCESS; + + Tizen::App::AppRegistry* appRegistry = Tizen::App::AppRegistry::GetInstance (); + r = appRegistry->Set (inId, inPreference); + + if (r != E_SUCCESS) { + + r = appRegistry->Add (inId, inPreference); + + } + + return (r == E_SUCCESS); + + } + + } diff --git a/project/src/renderer/common/BitmapCache.cpp b/project/src/renderer/common/BitmapCache.cpp index fecf0c9a4..dfd02c89d 100644 --- a/project/src/renderer/common/BitmapCache.cpp +++ b/project/src/renderer/common/BitmapCache.cpp @@ -121,8 +121,8 @@ namespace lime { bool BitmapCache::StillGood (const Transform &inTransform, const Rect &inVisiblePixels, BitmapCache *inMask) { // TODO: Need to break the cache for certain operations, for quality? - //if (!mMatrix.IsIntTranslation (*inTransform.mMatrix, mTX, mTY) || mScale9 != *inTransform.mScale9) - //return false; + if (!mMatrix.IsIntTranslation (*inTransform.mMatrix, mTX, mTY) || mScale9 != *inTransform.mScale9) + return false; if (inMask) {