/* Run self-tests for all required public key algorithms. Return 0 on success. */ static int run_pubkey_selftests (int extended) { static int algos[] = { GCRY_PK_RSA, GCRY_PK_DSA, /* GCRY_PK_ECDSA is not enabled in fips mode. */ 0 }; int idx; gpg_error_t err; int anyerr = 0; for (idx=0; algos[idx]; idx++) { err = _gcry_pk_selftest (algos[idx], extended, reporter); reporter ("pubkey", algos[idx], NULL, err? gpg_strerror (err):NULL); if (err) anyerr = 1; } return anyerr; }
void TransferFunctionAlphaWidget::updateTooltip(AlphaPoint point) { QString tip = QString("alpha(%1)=%2").arg(point.position).arg(double(point.value)/255, 0, 'f', 2); this->setToolTip(tip); reporter()->sendVolatile(tip); }
bool GLLibraryEGL::EnsureInitialized(bool forceAccel, nsACString* const out_failureId) { if (mInitialized) { return true; } mozilla::ScopedGfxFeatureReporter reporter("EGL"); #ifdef MOZ_B2G if (!sCurrentContext.init()) MOZ_CRASH("GFX: Tls init failed"); #endif #ifdef XP_WIN if (!mEGLLibrary) { // On Windows, the GLESv2, EGL and DXSDK libraries are shipped with libxul and // we should look for them there. We have to load the libs in this // order, because libEGL.dll depends on libGLESv2.dll which depends on the DXSDK // libraries. This matters especially for WebRT apps which are in a different directory. // See bug 760323 and bug 749459 // Also note that we intentionally leak the libs we load. do { // Windows 8.1 has d3dcompiler_47.dll in the system directory. // Try it first. Note that _46 will never be in the system // directory and we ship with at least _43. So there is no point // trying _46 and _43 in the system directory. if (LoadLibrarySystem32(L"d3dcompiler_47.dll")) break; #ifdef MOZ_D3DCOMPILER_VISTA_DLL if (LoadLibraryForEGLOnWindows(NS_LITERAL_STRING(NS_STRINGIFY(MOZ_D3DCOMPILER_VISTA_DLL)))) break; #endif #ifdef MOZ_D3DCOMPILER_XP_DLL if (LoadLibraryForEGLOnWindows(NS_LITERAL_STRING(NS_STRINGIFY(MOZ_D3DCOMPILER_XP_DLL)))) break; #endif MOZ_ASSERT(false, "d3dcompiler DLL loading failed."); } while (false); LoadLibraryForEGLOnWindows(NS_LITERAL_STRING("libGLESv2.dll")); mEGLLibrary = LoadLibraryForEGLOnWindows(NS_LITERAL_STRING("libEGL.dll")); if (!mEGLLibrary) return false; } #else // !Windows // On non-Windows (Android) we use system copies of libEGL. We look for // the APITrace lib, libEGL.so, and libEGL.so.1 in that order. #if defined(ANDROID) if (!mEGLLibrary) mEGLLibrary = LoadApitraceLibrary(); #endif if (!mEGLLibrary) { printf_stderr("Attempting load of libEGL.so\n"); mEGLLibrary = PR_LoadLibrary("libEGL.so"); } #if defined(XP_UNIX) if (!mEGLLibrary) { mEGLLibrary = PR_LoadLibrary("libEGL.so.1"); } #endif if (!mEGLLibrary) { NS_WARNING("Couldn't load EGL LIB."); return false; } #endif // !Windows #define SYMBOL(name) \ { (PRFuncPtr*) &mSymbols.f##name, { "egl" #name, nullptr } } GLLibraryLoader::SymLoadStruct earlySymbols[] = { SYMBOL(GetDisplay), SYMBOL(Terminate), SYMBOL(GetCurrentSurface), SYMBOL(GetCurrentContext), SYMBOL(MakeCurrent), SYMBOL(DestroyContext), SYMBOL(CreateContext), SYMBOL(DestroySurface), SYMBOL(CreateWindowSurface), SYMBOL(CreatePbufferSurface), SYMBOL(CreatePixmapSurface), SYMBOL(BindAPI), SYMBOL(Initialize), SYMBOL(ChooseConfig), SYMBOL(GetError), SYMBOL(GetConfigs), SYMBOL(GetConfigAttrib), SYMBOL(WaitNative), SYMBOL(GetProcAddress), SYMBOL(SwapBuffers), SYMBOL(CopyBuffers), SYMBOL(QueryString), SYMBOL(QueryContext), SYMBOL(BindTexImage), SYMBOL(ReleaseTexImage), SYMBOL(QuerySurface), { nullptr, { nullptr } } }; if (!GLLibraryLoader::LoadSymbols(mEGLLibrary, &earlySymbols[0])) { NS_WARNING("Couldn't find required entry points in EGL library (early init)"); return false; } GLLibraryLoader::SymLoadStruct optionalSymbols[] = { // On Android 4.3 and up, certain features like ANDROID_native_fence_sync // can only be queried by using a special eglQueryString. { (PRFuncPtr*) &mSymbols.fQueryStringImplementationANDROID, { "_Z35eglQueryStringImplementationANDROIDPvi", nullptr } }, { nullptr, { nullptr } } }; // Do not warn about the failure to load this - see bug 1092191 Unused << GLLibraryLoader::LoadSymbols(mEGLLibrary, &optionalSymbols[0], nullptr, nullptr, false); #if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 18 MOZ_RELEASE_ASSERT(mSymbols.fQueryStringImplementationANDROID, "GFX: Couldn't find eglQueryStringImplementationANDROID"); #endif InitClientExtensions(); const auto lookupFunction = (GLLibraryLoader::PlatformLookupFunction)mSymbols.fGetProcAddress; // Client exts are ready. (But not display exts!) if (IsExtensionSupported(ANGLE_platform_angle_d3d)) { GLLibraryLoader::SymLoadStruct d3dSymbols[] = { { (PRFuncPtr*)&mSymbols.fGetPlatformDisplayEXT, { "eglGetPlatformDisplayEXT", nullptr } }, { nullptr, { nullptr } } }; bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary, &d3dSymbols[0], lookupFunction); if (!success) { NS_ERROR("EGL supports ANGLE_platform_angle_d3d without exposing its functions!"); MarkExtensionUnsupported(ANGLE_platform_angle_d3d); mSymbols.fGetPlatformDisplayEXT = nullptr; } } // Check the ANGLE support the system has nsCOMPtr<nsIGfxInfo> gfxInfo = do_GetService("@mozilla.org/gfx/info;1"); mIsANGLE = IsExtensionSupported(ANGLE_platform_angle); EGLDisplay chosenDisplay = nullptr; if (IsExtensionSupported(ANGLE_platform_angle_d3d)) { bool accelAngleSupport = IsAccelAngleSupported(gfxInfo, out_failureId); bool shouldTryAccel = forceAccel || accelAngleSupport; bool shouldTryWARP = !forceAccel; // Only if ANGLE not supported or fails // If WARP preferred, will override ANGLE support if (gfxPrefs::WebGLANGLEForceWARP()) { shouldTryWARP = true; shouldTryAccel = false; } // Hardware accelerated ANGLE path (supported or force accel) if (shouldTryAccel) { chosenDisplay = GetAndInitDisplayForAccelANGLE(*this); } // Fallback to a WARP display if ANGLE fails, or if WARP is forced if (!chosenDisplay && shouldTryWARP) { chosenDisplay = GetAndInitWARPDisplay(*this, EGL_DEFAULT_DISPLAY); if (!chosenDisplay) { if (out_failureId->IsEmpty()) { *out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_WARP_FALLBACK"); } NS_ERROR("Fallback WARP context failed to initialize."); return false; } mIsWARP = true; } } else { chosenDisplay = GetAndInitDisplay(*this, EGL_DEFAULT_DISPLAY); } if (!chosenDisplay) { if (out_failureId->IsEmpty()) { *out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_NO_DISPLAY"); } NS_WARNING("Failed to initialize a display."); return false; } mEGLDisplay = chosenDisplay; InitDisplayExtensions(); //////////////////////////////////// // Alright, load display exts. if (IsExtensionSupported(KHR_lock_surface)) { GLLibraryLoader::SymLoadStruct lockSymbols[] = { { (PRFuncPtr*) &mSymbols.fLockSurface, { "eglLockSurfaceKHR", nullptr } }, { (PRFuncPtr*) &mSymbols.fUnlockSurface, { "eglUnlockSurfaceKHR", nullptr } }, { nullptr, { nullptr } } }; bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary, &lockSymbols[0], lookupFunction); if (!success) { NS_ERROR("EGL supports KHR_lock_surface without exposing its functions!"); MarkExtensionUnsupported(KHR_lock_surface); mSymbols.fLockSurface = nullptr; mSymbols.fUnlockSurface = nullptr; } } if (IsExtensionSupported(ANGLE_surface_d3d_texture_2d_share_handle)) { GLLibraryLoader::SymLoadStruct d3dSymbols[] = { { (PRFuncPtr*) &mSymbols.fQuerySurfacePointerANGLE, { "eglQuerySurfacePointerANGLE", nullptr } }, { nullptr, { nullptr } } }; bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary, &d3dSymbols[0], lookupFunction); if (!success) { NS_ERROR("EGL supports ANGLE_surface_d3d_texture_2d_share_handle without exposing its functions!"); MarkExtensionUnsupported(ANGLE_surface_d3d_texture_2d_share_handle); mSymbols.fQuerySurfacePointerANGLE = nullptr; } } if (IsExtensionSupported(KHR_fence_sync)) { GLLibraryLoader::SymLoadStruct syncSymbols[] = { { (PRFuncPtr*) &mSymbols.fCreateSync, { "eglCreateSyncKHR", nullptr } }, { (PRFuncPtr*) &mSymbols.fDestroySync, { "eglDestroySyncKHR", nullptr } }, { (PRFuncPtr*) &mSymbols.fClientWaitSync, { "eglClientWaitSyncKHR", nullptr } }, { (PRFuncPtr*) &mSymbols.fGetSyncAttrib, { "eglGetSyncAttribKHR", nullptr } }, { nullptr, { nullptr } } }; bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary, &syncSymbols[0], lookupFunction); if (!success) { NS_ERROR("EGL supports KHR_fence_sync without exposing its functions!"); MarkExtensionUnsupported(KHR_fence_sync); mSymbols.fCreateSync = nullptr; mSymbols.fDestroySync = nullptr; mSymbols.fClientWaitSync = nullptr; mSymbols.fGetSyncAttrib = nullptr; } } if (IsExtensionSupported(KHR_image) || IsExtensionSupported(KHR_image_base)) { GLLibraryLoader::SymLoadStruct imageSymbols[] = { { (PRFuncPtr*) &mSymbols.fCreateImage, { "eglCreateImageKHR", nullptr } }, { (PRFuncPtr*) &mSymbols.fDestroyImage, { "eglDestroyImageKHR", nullptr } }, { nullptr, { nullptr } } }; bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary, &imageSymbols[0], lookupFunction); if (!success) { NS_ERROR("EGL supports KHR_image(_base) without exposing its functions!"); MarkExtensionUnsupported(KHR_image); MarkExtensionUnsupported(KHR_image_base); MarkExtensionUnsupported(KHR_image_pixmap); mSymbols.fCreateImage = nullptr; mSymbols.fDestroyImage = nullptr; } } else { MarkExtensionUnsupported(KHR_image_pixmap); } if (IsExtensionSupported(ANDROID_native_fence_sync)) { GLLibraryLoader::SymLoadStruct nativeFenceSymbols[] = { { (PRFuncPtr*) &mSymbols.fDupNativeFenceFDANDROID, { "eglDupNativeFenceFDANDROID", nullptr } }, { nullptr, { nullptr } } }; bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary, &nativeFenceSymbols[0], lookupFunction); if (!success) { NS_ERROR("EGL supports ANDROID_native_fence_sync without exposing its functions!"); MarkExtensionUnsupported(ANDROID_native_fence_sync); mSymbols.fDupNativeFenceFDANDROID = nullptr; } } mInitialized = true; reporter.SetSuccessful(); return true; }
bool WGLLibrary::EnsureInitialized(bool aUseMesaLlvmPipe) { if (mInitialized) return true; mozilla::ScopedGfxFeatureReporter reporter("WGL", aUseMesaLlvmPipe); const char* libGLFilename = aUseMesaLlvmPipe ? "mesallvmpipe.dll" : "Opengl32.dll"; if (!mOGLLibrary) { mOGLLibrary = PR_LoadLibrary(libGLFilename); if (!mOGLLibrary) { NS_WARNING("Couldn't load OpenGL library."); return false; } } mUseDoubleBufferedWindows = PR_GetEnv("MOZ_WGL_DB") != nullptr; GLLibraryLoader::SymLoadStruct earlySymbols[] = { { (PRFuncPtr*) &fCreateContext, { "wglCreateContext", NULL } }, { (PRFuncPtr*) &fMakeCurrent, { "wglMakeCurrent", NULL } }, { (PRFuncPtr*) &fGetProcAddress, { "wglGetProcAddress", NULL } }, { (PRFuncPtr*) &fDeleteContext, { "wglDeleteContext", NULL } }, { (PRFuncPtr*) &fGetCurrentContext, { "wglGetCurrentContext", NULL } }, { (PRFuncPtr*) &fGetCurrentDC, { "wglGetCurrentDC", NULL } }, { (PRFuncPtr*) &fShareLists, { "wglShareLists", NULL } }, { NULL, { NULL } } }; if (!GLLibraryLoader::LoadSymbols(mOGLLibrary, &earlySymbols[0])) { NS_WARNING("Couldn't find required entry points in OpenGL DLL (early init)"); return false; } // This is ridiculous -- we have to actually create a context to // get the OpenGL ICD to load. mWindow = CreateDummyWindow(&mWindowDC); NS_ENSURE_TRUE(mWindow, false); // create rendering context mWindowGLContext = fCreateContext(mWindowDC); NS_ENSURE_TRUE(mWindowGLContext, false); HGLRC curCtx = fGetCurrentContext(); HDC curDC = fGetCurrentDC(); if (!fMakeCurrent((HDC)mWindowDC, (HGLRC)mWindowGLContext)) { NS_WARNING("wglMakeCurrent failed"); return false; } // Now we can grab all the other symbols that we couldn't without having // a context current. GLLibraryLoader::SymLoadStruct pbufferSymbols[] = { { (PRFuncPtr*) &fCreatePbuffer, { "wglCreatePbufferARB", "wglCreatePbufferEXT", NULL } }, { (PRFuncPtr*) &fDestroyPbuffer, { "wglDestroyPbufferARB", "wglDestroyPbufferEXT", NULL } }, { (PRFuncPtr*) &fGetPbufferDC, { "wglGetPbufferDCARB", "wglGetPbufferDCEXT", NULL } }, { (PRFuncPtr*) &fBindTexImage, { "wglBindTexImageARB", "wglBindTexImageEXT", NULL } }, { (PRFuncPtr*) &fReleaseTexImage, { "wglReleaseTexImageARB", "wglReleaseTexImageEXT", NULL } }, { NULL, { NULL } } }; GLLibraryLoader::SymLoadStruct pixFmtSymbols[] = { { (PRFuncPtr*) &fChoosePixelFormat, { "wglChoosePixelFormatARB", "wglChoosePixelFormatEXT", NULL } }, { (PRFuncPtr*) &fGetPixelFormatAttribiv, { "wglGetPixelFormatAttribivARB", "wglGetPixelFormatAttribivEXT", NULL } }, { NULL, { NULL } } }; if (!GLLibraryLoader::LoadSymbols(mOGLLibrary, &pbufferSymbols[0], (GLLibraryLoader::PlatformLookupFunction)fGetProcAddress)) { // this isn't an error, just means that pbuffers aren't supported fCreatePbuffer = nullptr; } if (!GLLibraryLoader::LoadSymbols(mOGLLibrary, &pixFmtSymbols[0], (GLLibraryLoader::PlatformLookupFunction)fGetProcAddress)) { // this isn't an error, just means that we don't have the pixel format extension fChoosePixelFormat = nullptr; } GLLibraryLoader::SymLoadStruct extensionsSymbols[] = { { (PRFuncPtr *) &fGetExtensionsString, { "wglGetExtensionsStringARB", NULL} }, { NULL, { NULL } } }; GLLibraryLoader::SymLoadStruct robustnessSymbols[] = { { (PRFuncPtr *) &fCreateContextAttribs, { "wglCreateContextAttribsARB", NULL} }, { NULL, { NULL } } }; if (GLLibraryLoader::LoadSymbols(mOGLLibrary, &extensionsSymbols[0], (GLLibraryLoader::PlatformLookupFunction)fGetProcAddress)) { const char *wglExts = fGetExtensionsString(mWindowDC); if (wglExts && HasExtension(wglExts, "WGL_ARB_create_context")) { GLLibraryLoader::LoadSymbols(mOGLLibrary, &robustnessSymbols[0], (GLLibraryLoader::PlatformLookupFunction)fGetProcAddress); if (HasExtension(wglExts, "WGL_ARB_create_context_robustness")) { mHasRobustness = true; } } } // reset back to the previous context, just in case fMakeCurrent(curDC, curCtx); if (mHasRobustness) { fDeleteContext(mWindowGLContext); int attribs[] = { LOCAL_WGL_CONTEXT_FLAGS_ARB, LOCAL_WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB, LOCAL_WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, LOCAL_WGL_LOSE_CONTEXT_ON_RESET_ARB, 0 }; mWindowGLContext = fCreateContextAttribs(mWindowDC, NULL, attribs); if (!mWindowGLContext) { mHasRobustness = false; mWindowGLContext = fCreateContext(mWindowDC); } } mInitialized = true; GLContext::ContextFlags flag = GLContext::ContextFlagsNone; if (aUseMesaLlvmPipe) { mLibType = WGLLibrary::MESA_LLVMPIPE_LIB; flag = GLContext::ContextFlagsMesaLLVMPipe; } // Call this to create the global GLContext instance, // and to check for errors. Note that this must happen /after/ // setting mInitialized to TRUE, or an infinite loop results. if (GLContextProviderWGL::GetGlobalContext(flag) == nullptr) { mInitialized = false; return false; } reporter.SetSuccessful(); return true; }
void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile ) { m_outputDirectory = m_outputDirectoryName->GetValue(); // Create output directory if it does not exist (also transform it in // absolute form). Bail if it fails wxFileName outputDir = wxFileName::DirName( m_outputDirectory ); wxString boardFilename = m_board->GetFileName(); WX_TEXT_CTRL_REPORTER reporter( m_messagesBox ); if( !EnsureOutputDirectory( &outputDir, boardFilename, &reporter ) ) { wxString msg; msg.Printf( _( "Could not write plot files to folder \"%s\"." ), GetChars( outputDir.GetPath() ) ); DisplayError( this, msg ); return; } m_printMirror = m_printMirrorOpt->GetValue(); m_printBW = m_ModeColorOption->GetSelection(); SetPenWidth(); // Build layers mask LAYER_MSK printMaskLayer = NO_LAYERS; for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer ) { if( m_boxSelectLayer[layer] && m_boxSelectLayer[layer]->GetValue() ) printMaskLayer |= GetLayerMask( layer ); } wxString msg; for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer ) { LAYER_MSK currlayer_mask = GetLayerMask( layer ); if( (printMaskLayer & currlayer_mask ) == 0 ) continue; wxString suffix = m_board->GetStandardLayerName( layer ); if( aOnlyOneFile ) { m_printMaskLayer = printMaskLayer; suffix = wxT( "brd" ); } else { m_printMaskLayer = currlayer_mask; suffix = m_board->GetStandardLayerName( layer ); } wxFileName fn(boardFilename); BuildPlotFileName( &fn, outputDir.GetPath(), suffix, SVGFileExtension ); if( m_PrintBoardEdgesCtrl->IsChecked() ) m_printMaskLayer |= EDGE_LAYER; if( CreateSVGFile( fn.GetFullPath() ) ) msg.Printf( _( "Plot: %s OK\n" ), GetChars( fn.GetFullPath() ) ); else // Error msg.Printf( _( "** Unable to create %s **\n" ), GetChars( fn.GetFullPath() ) ); m_messagesBox->AppendText( msg ); if( aOnlyOneFile ) break; } }
int main(void) { InitPeripherals(); mRedOFF; mGreenOFF; mBlueOFF; // startup blink const float kShortDelay = 0.1; const float kLongDelay = 0.3; mRedON; mGreenON; mBlueON; DelaySeconds(kShortDelay); mRedOFF; mGreenOFF; mBlueOFF; DelaySeconds(kLongDelay); mRedON; mGreenON; mBlueON; DelaySeconds(kShortDelay); mRedOFF; mGreenOFF; mBlueOFF; DelaySeconds(kLongDelay); mRedON; mGreenON; mBlueON; DelaySeconds(kShortDelay); mRedOFF; mGreenOFF; mBlueOFF; DelaySeconds(kLongDelay); UsbInterface usb = UsbInterface(); usb.Init(); PersistentMemory mem; DelaySeconds(1.0f); ZigbeeInterface zig = ZigbeeInterface(); DelaySeconds(0.05f); zig.Init(mem); error_reporting_com1 = &usb; error_reporting_com2 = &zig; Mpu60XXImu imu(mem); GyroAccelDriftUkfIo est; BatteryMonitor battery(mem); battery_ptr = &battery; MotorHal motor_hal(mem); motor_hal_ptr = &motor_hal; // Get_pos addition: InitPositionSensor(); tim1_set_position_callback_2(get_position); QuatPD pd(mem); PulsingCoaxControllerQuat uav(mem, pd, imu, est, motor_hal); CoaxOpenController open_controller(mem); CoaxOpenAttitudeController open_attitude_controller(mem, est); monitor = LoopMonitor(mem); UavReporter reporter(mem, imu, est, motor_hal, battery, uav, open_attitude_controller, pd, monitor); StateMachine state_machine; mem.Freeze(); // freeze memory to make writes possible imu.InitFromMemory(); //imu.DefaultAccelSensitivity(1); // overwrite scale for off-datasheet fix imu.flip_z = 1; // flip z-axis direction for upside-down imu #ifdef STREAM_IMU_RAW imu_raw_msg_logger_init(imu); #endif monitor.InitFromMemory(); PlayTimebase(); imu.StartRead(); DelayMilliseconds(10); tim1_init(); tim1_set_supply_volts(3.7f); ////////////////////////////////////////////////////////////////////////////// // Main Loop while(1) { monitor.Profile(0); //////////////////////////////////////////////////////////////////////////// // Get IMU Data and Start New Measurement while(!imu.FinishRead()) {}; #ifdef STREAM_IMU_RAW imu_raw_msg_logger_push(); #endif DelayMicroseconds(50); // this seems to be critical (?!?) imu.StartRead(); monitor.Profile(1); //////////////////////////////////////////////////////////////////////////// // Update Estimator with Measurement est.Update(imu.time, imu.w, imu.a); //////////////////////////////////////////////////////////////////////////// // Control // update control laws uav.Update(); open_controller.Update(); open_attitude_controller.Update(); // map controllers to outputs based on state enum control_state state = state_machine.get_state(); // in STOP state, send active kill messages to motors if(state == kStop) { mGreenOFF; mAmberON; motor_hal.set_top_cmd_volts(0); motor_hal.set_top_cmd_volts_pulse_amp(0); motor_hal.set_top_cmd_pulse_phase(0); motor_hal.set_bottom_cmd_volts(0); } // in STANDBY state, send no motor commands except on entry else if(state == kStandby) { mGreenOFF; mAmberOFF; if(state_machine.get_standby_needs_init()) { motor_hal.set_top_cmd_volts(0); motor_hal.set_top_cmd_volts_pulse_amp(0); motor_hal.set_top_cmd_pulse_phase(0); motor_hal.set_bottom_cmd_volts(0); state_machine.clear_standby_needs_init(); } } // in QUAT state, send motor commands according to quat control law else if(state == kQuat) { mGreenON; mAmberOFF; motor_hal.set_top_cmd_volts(uav.top_mean); motor_hal.set_top_cmd_volts_pulse_amp(uav.top_pulse_amp); motor_hal.set_top_cmd_pulse_phase(uav.top_pulse_phase); motor_hal.set_bottom_cmd_volts(uav.bottom_mean); } // in OPEN state, send motor command according to open motor control commands else if(state == kOpen) { mGreenON; mAmberOFF; motor_hal.set_top_cmd_volts(open_controller.top_mean); motor_hal.set_top_cmd_volts_pulse_amp(open_controller.top_pulse_amp); motor_hal.set_top_cmd_pulse_phase(open_controller.top_pulse_phase); motor_hal.set_bottom_cmd_volts(open_controller.bottom_mean); } // in OPEN ATTITUDE state, send motor command according to open motor control commands else if(state == kOpenAttitude) { mGreenON; mAmberOFF; motor_hal.set_top_cmd_volts(open_attitude_controller.top_mean); motor_hal.set_top_cmd_volts_pulse_amp(open_attitude_controller.top_pulse_amp); motor_hal.set_top_cmd_pulse_phase(open_attitude_controller.top_pulse_phase); motor_hal.set_bottom_cmd_volts(open_attitude_controller.bottom_mean); } monitor.Profile(2); //////////////////////////////////////////////////////////////////////////// // Packet Communication uint8_t is_data; // 1 iff data received uint8_t *rx_data; // temporary pointer to received type+data bytes uint8_t rx_length; // number of received type+data bytes //////////////////////////////////////////////////////////////////////////// // USB Input is_data = 0; usb.GetBytes(); while(usb.PeekPacket(&rx_data, &rx_length)) { zig.ReadMsg(usb, rx_data, rx_length); imu.ReadMsg(usb, rx_data, rx_length); est.ReadMsg(usb, rx_data, rx_length); mem.ReadMsg(usb, rx_data, rx_length); uav.ReadMsg(usb, rx_data, rx_length); open_controller.ReadMsg( usb, rx_data, rx_length); open_attitude_controller.ReadMsg( usb, rx_data, rx_length); pd.ReadMsg( usb, rx_data, rx_length); monitor.ReadMsg( usb, rx_data, rx_length); motor_hal.ReadMsg(usb, rx_data, rx_length); battery.ReadMsg( usb, rx_data, rx_length); reporter.ReadMsg( usb, rx_data, rx_length); state_machine.ReadMsg(usb, rx_data, rx_length); usb.DropPacket(); is_data = 1; } // while peek... if(is_data) { usb.SendNow(); } //////////////////////////////////////////////////////////////////////////// // Radio Input is_data = 0; zig.GetBytes(); while(zig.PeekPacket(&rx_data, &rx_length)) { #ifdef STREAM_IMU_RAW if(rx_data[0] == kTypeQuatPilot || rx_data[0] == kTypeQuatFullObsPilot || rx_data[0] == kTypeOpenPilot || rx_data[0] == kTypeOpenAttitudePilot) { imu_raw_msg_logger_send(zig); } #endif zig.ReadMsg(zig, rx_data, rx_length); imu.ReadMsg(zig, rx_data, rx_length); est.ReadMsg(zig, rx_data, rx_length); mem.ReadMsg(zig, rx_data, rx_length); uav.ReadMsg(zig, rx_data, rx_length); open_controller.ReadMsg( zig, rx_data, rx_length); open_attitude_controller.ReadMsg( zig, rx_data, rx_length); pd.ReadMsg( zig, rx_data, rx_length); monitor.ReadMsg( zig, rx_data, rx_length); motor_hal.ReadMsg(zig, rx_data, rx_length); battery.ReadMsg( zig, rx_data, rx_length); reporter.ReadMsg( zig, rx_data, rx_length); state_machine.ReadMsg(zig, rx_data, rx_length); zig.DropPacket(); is_data = 1; } // while peek... monitor.Profile(3); if(is_data) { zig.SendNow(); } monitor.Profile(4); monitor.Profile(5); //////////////////////////////////////////////////////////////////////////// // Throttle main loop to main_freq monitor.EndMainLoop(); monitor.Profile(6); //monitor.SendProfile(usb); //usb.SendNow(); } // while(1) return(0); }
bool GLLibraryEGL::EnsureInitialized() { if (mInitialized) { return true; } mozilla::ScopedGfxFeatureReporter reporter("EGL"); #ifdef MOZ_B2G if (!sCurrentContext.init()) MOZ_CRASH("Tls init failed"); #endif #ifdef XP_WIN if (!mEGLLibrary) { // On Windows, the GLESv2, EGL and DXSDK libraries are shipped with libxul and // we should look for them there. We have to load the libs in this // order, because libEGL.dll depends on libGLESv2.dll which depends on the DXSDK // libraries. This matters especially for WebRT apps which are in a different directory. // See bug 760323 and bug 749459 // Also note that we intentionally leak the libs we load. do { // Windows 8.1 has d3dcompiler_47.dll in the system directory. // Try it first. Note that _46 will never be in the system // directory and we ship with at least _43. So there is no point // trying _46 and _43 in the system directory. if (LoadLibrarySystem32(L"d3dcompiler_47.dll")) break; #ifdef MOZ_D3DCOMPILER_VISTA_DLL if (LoadLibraryForEGLOnWindows(NS_LITERAL_STRING(NS_STRINGIFY(MOZ_D3DCOMPILER_VISTA_DLL)))) break; #endif #ifdef MOZ_D3DCOMPILER_XP_DLL if (LoadLibraryForEGLOnWindows(NS_LITERAL_STRING(NS_STRINGIFY(MOZ_D3DCOMPILER_XP_DLL)))) break; #endif MOZ_ASSERT(false, "d3dcompiler DLL loading failed."); } while (false); LoadLibraryForEGLOnWindows(NS_LITERAL_STRING("libGLESv2.dll")); mEGLLibrary = LoadLibraryForEGLOnWindows(NS_LITERAL_STRING("libEGL.dll")); if (!mEGLLibrary) return false; } #else // !Windows // On non-Windows (Android) we use system copies of libEGL. We look for // the APITrace lib, libEGL.so, and libEGL.so.1 in that order. #if defined(ANDROID) if (!mEGLLibrary) mEGLLibrary = LoadApitraceLibrary(); #endif if (!mEGLLibrary) { printf_stderr("Attempting load of libEGL.so\n"); mEGLLibrary = PR_LoadLibrary("libEGL.so"); } #if defined(XP_UNIX) if (!mEGLLibrary) { mEGLLibrary = PR_LoadLibrary("libEGL.so.1"); } #endif if (!mEGLLibrary) { NS_WARNING("Couldn't load EGL LIB."); return false; } #endif // !Windows #define SYMBOL(name) \ { (PRFuncPtr*) &mSymbols.f##name, { "egl" #name, nullptr } } GLLibraryLoader::SymLoadStruct earlySymbols[] = { SYMBOL(GetDisplay), SYMBOL(Terminate), SYMBOL(GetCurrentSurface), SYMBOL(GetCurrentContext), SYMBOL(MakeCurrent), SYMBOL(DestroyContext), SYMBOL(CreateContext), SYMBOL(DestroySurface), SYMBOL(CreateWindowSurface), SYMBOL(CreatePbufferSurface), SYMBOL(CreatePixmapSurface), SYMBOL(BindAPI), SYMBOL(Initialize), SYMBOL(ChooseConfig), SYMBOL(GetError), SYMBOL(GetConfigs), SYMBOL(GetConfigAttrib), SYMBOL(WaitNative), SYMBOL(GetProcAddress), SYMBOL(SwapBuffers), SYMBOL(CopyBuffers), SYMBOL(QueryString), SYMBOL(QueryContext), SYMBOL(BindTexImage), SYMBOL(ReleaseTexImage), SYMBOL(QuerySurface), { nullptr, { nullptr } } }; if (!GLLibraryLoader::LoadSymbols(mEGLLibrary, &earlySymbols[0])) { NS_WARNING("Couldn't find required entry points in EGL library (early init)"); return false; } GLLibraryLoader::SymLoadStruct optionalSymbols[] = { // On Android 4.3 and up, certain features like ANDROID_native_fence_sync // can only be queried by using a special eglQueryString. { (PRFuncPtr*) &mSymbols.fQueryStringImplementationANDROID, { "_Z35eglQueryStringImplementationANDROIDPvi", nullptr } }, { nullptr, { nullptr } } }; // Do not warn about the failure to load this - see bug 1092191 GLLibraryLoader::LoadSymbols(mEGLLibrary, &optionalSymbols[0], nullptr, nullptr, false); #if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 18 MOZ_RELEASE_ASSERT(mSymbols.fQueryStringImplementationANDROID, "Couldn't find eglQueryStringImplementationANDROID"); #endif //Initialize client extensions InitExtensionsFromDisplay(EGL_NO_DISPLAY); GLLibraryLoader::PlatformLookupFunction lookupFunction = (GLLibraryLoader::PlatformLookupFunction)mSymbols.fGetProcAddress; #ifdef XP_WIN if (IsExtensionSupported(ANGLE_platform_angle_d3d)) { GLLibraryLoader::SymLoadStruct d3dSymbols[] = { { (PRFuncPtr*)&mSymbols.fGetPlatformDisplayEXT, { "eglGetPlatformDisplayEXT", nullptr } }, { nullptr, { nullptr } } }; bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary, &d3dSymbols[0], lookupFunction); if (!success) { NS_ERROR("EGL supports ANGLE_platform_angle_d3d without exposing its functions!"); MarkExtensionUnsupported(ANGLE_platform_angle_d3d); mSymbols.fGetPlatformDisplayEXT = nullptr; } } #endif mEGLDisplay = GetAndInitDisplay(*this, EGL_DEFAULT_DISPLAY); const char* vendor = (char*)fQueryString(mEGLDisplay, LOCAL_EGL_VENDOR); if (vendor && (strstr(vendor, "TransGaming") != 0 || strstr(vendor, "Google Inc.") != 0)) { mIsANGLE = true; } if (mIsANGLE) { EGLDisplay newDisplay = EGL_NO_DISPLAY; // D3D11 ANGLE only works with OMTC; there's a bug in the non-OMTC layer // manager, and it's pointless to try to fix it. We also don't try // D3D11 ANGLE if the layer manager is prefering D3D9 (hrm, do we care?) if (gfxPrefs::LayersOffMainThreadCompositionEnabled() && !gfxPrefs::LayersPreferD3D9()) { if (gfxPrefs::WebGLANGLEForceD3D11()) { newDisplay = GetAndInitDisplay(*this, LOCAL_EGL_D3D11_ONLY_DISPLAY_ANGLE); } else if (gfxPrefs::WebGLANGLETryD3D11() && gfxPlatform::CanUseDirect3D11ANGLE()) { newDisplay = GetAndInitDisplay(*this, LOCAL_EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE); } } if (newDisplay != EGL_NO_DISPLAY) { DebugOnly<EGLBoolean> success = fTerminate(mEGLDisplay); MOZ_ASSERT(success == LOCAL_EGL_TRUE); mEGLDisplay = newDisplay; vendor = (char*)fQueryString(mEGLDisplay, LOCAL_EGL_VENDOR); } } InitExtensionsFromDisplay(mEGLDisplay); if (IsExtensionSupported(KHR_lock_surface)) { GLLibraryLoader::SymLoadStruct lockSymbols[] = { { (PRFuncPtr*) &mSymbols.fLockSurface, { "eglLockSurfaceKHR", nullptr } }, { (PRFuncPtr*) &mSymbols.fUnlockSurface, { "eglUnlockSurfaceKHR", nullptr } }, { nullptr, { nullptr } } }; bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary, &lockSymbols[0], lookupFunction); if (!success) { NS_ERROR("EGL supports KHR_lock_surface without exposing its functions!"); MarkExtensionUnsupported(KHR_lock_surface); mSymbols.fLockSurface = nullptr; mSymbols.fUnlockSurface = nullptr; } } if (IsExtensionSupported(ANGLE_surface_d3d_texture_2d_share_handle)) { GLLibraryLoader::SymLoadStruct d3dSymbols[] = { { (PRFuncPtr*) &mSymbols.fQuerySurfacePointerANGLE, { "eglQuerySurfacePointerANGLE", nullptr } }, { nullptr, { nullptr } } }; bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary, &d3dSymbols[0], lookupFunction); if (!success) { NS_ERROR("EGL supports ANGLE_surface_d3d_texture_2d_share_handle without exposing its functions!"); MarkExtensionUnsupported(ANGLE_surface_d3d_texture_2d_share_handle); mSymbols.fQuerySurfacePointerANGLE = nullptr; } } //XXX: use correct extension name if (IsExtensionSupported(ANGLE_surface_d3d_texture_2d_share_handle)) { GLLibraryLoader::SymLoadStruct d3dSymbols[] = { { (PRFuncPtr*)&mSymbols.fSurfaceReleaseSyncANGLE, { "eglSurfaceReleaseSyncANGLE", nullptr } }, { nullptr, { nullptr } } }; bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary, &d3dSymbols[0], lookupFunction); if (!success) { NS_ERROR("EGL supports ANGLE_surface_d3d_texture_2d_share_handle without exposing its functions!"); MarkExtensionUnsupported(ANGLE_surface_d3d_texture_2d_share_handle); mSymbols.fSurfaceReleaseSyncANGLE = nullptr; } } if (IsExtensionSupported(KHR_fence_sync)) { GLLibraryLoader::SymLoadStruct syncSymbols[] = { { (PRFuncPtr*) &mSymbols.fCreateSync, { "eglCreateSyncKHR", nullptr } }, { (PRFuncPtr*) &mSymbols.fDestroySync, { "eglDestroySyncKHR", nullptr } }, { (PRFuncPtr*) &mSymbols.fClientWaitSync, { "eglClientWaitSyncKHR", nullptr } }, { (PRFuncPtr*) &mSymbols.fGetSyncAttrib, { "eglGetSyncAttribKHR", nullptr } }, { nullptr, { nullptr } } }; bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary, &syncSymbols[0], lookupFunction); if (!success) { NS_ERROR("EGL supports KHR_fence_sync without exposing its functions!"); MarkExtensionUnsupported(KHR_fence_sync); mSymbols.fCreateSync = nullptr; mSymbols.fDestroySync = nullptr; mSymbols.fClientWaitSync = nullptr; mSymbols.fGetSyncAttrib = nullptr; } } if (IsExtensionSupported(KHR_image) || IsExtensionSupported(KHR_image_base)) { GLLibraryLoader::SymLoadStruct imageSymbols[] = { { (PRFuncPtr*) &mSymbols.fCreateImage, { "eglCreateImageKHR", nullptr } }, { (PRFuncPtr*) &mSymbols.fDestroyImage, { "eglDestroyImageKHR", nullptr } }, { nullptr, { nullptr } } }; bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary, &imageSymbols[0], lookupFunction); if (!success) { NS_ERROR("EGL supports KHR_image(_base) without exposing its functions!"); MarkExtensionUnsupported(KHR_image); MarkExtensionUnsupported(KHR_image_base); MarkExtensionUnsupported(KHR_image_pixmap); mSymbols.fCreateImage = nullptr; mSymbols.fDestroyImage = nullptr; } } else { MarkExtensionUnsupported(KHR_image_pixmap); } if (IsExtensionSupported(ANDROID_native_fence_sync)) { GLLibraryLoader::SymLoadStruct nativeFenceSymbols[] = { { (PRFuncPtr*) &mSymbols.fDupNativeFenceFDANDROID, { "eglDupNativeFenceFDANDROID", nullptr } }, { nullptr, { nullptr } } }; bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary, &nativeFenceSymbols[0], lookupFunction); if (!success) { NS_ERROR("EGL supports ANDROID_native_fence_sync without exposing its functions!"); MarkExtensionUnsupported(ANDROID_native_fence_sync); mSymbols.fDupNativeFenceFDANDROID = nullptr; } } mInitialized = true; reporter.SetSuccessful(); return true; }
void SessionStorageServiceImpl::onSessionChanged() { reporter()->setLoggingFolder(this->getSubFolder("Logs/")); }
void DIALOG_PLOT_SCHEMATIC::CreateDXFFile( bool aPlotAll, bool aPlotFrameRef ) { SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) m_parent; SCH_SCREEN* screen = schframe->GetScreen(); SCH_SHEET_PATH* sheetpath; SCH_SHEET_PATH oldsheetpath = schframe->GetCurrentSheet(); /* When printing all pages, the printed page is not the current page. * In complex hierarchies, we must setup references and others parameters * in the printed SCH_SCREEN * because in complex hierarchies a SCH_SCREEN (a schematic drawings) * is shared between many sheets */ SCH_SHEET_LIST SheetList( NULL ); sheetpath = SheetList.GetFirst(); SCH_SHEET_PATH list; WX_TEXT_CTRL_REPORTER reporter(m_MessagesBox); while( true ) { if( aPlotAll ) { if( sheetpath == NULL ) break; list.Clear(); if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) ) { schframe->SetCurrentSheet( list ); schframe->GetCurrentSheet().UpdateAllScreenReferences(); schframe->SetSheetNumberAndCount(); screen = schframe->GetCurrentSheet().LastScreen(); } else // Should not happen { return; } sheetpath = SheetList.GetNext(); } wxPoint plot_offset; wxString msg; try { wxString fname = schframe->GetUniqueFilenameForCurrentSheet(); wxString ext = DXF_PLOTTER::GetDefaultFileExtension(); wxFileName plotFileName = createPlotFileName( m_outputDirectoryName, fname, ext, &reporter ); if( PlotOneSheetDXF( plotFileName.GetFullPath(), screen, plot_offset, 1.0, aPlotFrameRef ) ) { msg.Printf( _( "Plot: '%s' OK\n" ), GetChars( plotFileName.GetFullPath() ) ); } else // Error { msg.Printf( _( "Unable to create '%s'\n" ), GetChars( plotFileName.GetFullPath() ) ); } m_MessagesBox->AppendText( msg ); } catch( IO_ERROR& e ) { msg.Printf( wxT( "DXF Plotter Exception : '%s'"), GetChars( e.errorText ) ); m_MessagesBox->AppendText( msg ); schframe->SetCurrentSheet( oldsheetpath ); schframe->GetCurrentSheet().UpdateAllScreenReferences(); schframe->SetSheetNumberAndCount(); return; } if( !aPlotAll ) { break; } } schframe->SetCurrentSheet( oldsheetpath ); schframe->GetCurrentSheet().UpdateAllScreenReferences(); schframe->SetSheetNumberAndCount(); }
int main(int argc, char **argv) { int status; struct sched_param thread_param; int i; int retval = FAILURE; int core; int nthreads; /* Make sure we see all message, even those on stdout. */ setvbuf(stdout, NULL, _IONBF, 0); /* get the number of processors */ num_processors = sysconf(_SC_NPROCESSORS_ONLN); /* calculate the number of inversion groups to run */ ngroups = num_processors == 1 ? 1 : num_processors - 1; /* process command line arguments */ process_command_line(argc, argv); /* lock memory */ if (lockall) if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1) { error("mlockall failed\n"); return FAILURE; } /* boost main's priority (so we keep running) :) */ prio_min = sched_get_priority_min(policy); thread_param.sched_priority = MAIN_PRIO(); status = pthread_setschedparam(pthread_self(), policy, &thread_param); if (status) { error("main: boosting to max priority: 0x%x\n", status); return FAILURE; } /* block unwanted signals */ block_signals(); /* allocate our groups array */ groups = calloc(ngroups, sizeof(struct group_parameters)); if (groups == NULL) { error("main: failed to allocate %d groups\n", ngroups); return FAILURE; } /* set up CPU affinity masks */ if (set_cpu_affinity(&test_cpu_mask, &admin_cpu_mask)) return FAILURE; nthreads = ngroups * NUM_TEST_THREADS + NUM_ADMIN_THREADS; /* set up our ready barrier */ if (barrier_init(&all_threads_ready, NULL, nthreads, "all_threads_ready")) return FAILURE; /* set up our done barrier */ if (barrier_init(&all_threads_done, NULL, nthreads, "all_threads_done")) return FAILURE; /* create the groups */ info("Creating %d test groups\n", ngroups); for (core = 0; core < num_processors; core++) if (CPU_ISSET(core, &test_cpu_mask)) break; for (i = 0; i < ngroups; i++) { groups[i].id = i; groups[i].cpu = core++; if (core >= num_processors) core = 0; if (create_group(&groups[i]) != SUCCESS) return FAILURE; } /* prompt if requested */ if (prompt) { printf("Press return to start test: "); getchar(); } /* report */ banner(); start = time(NULL); /* turn loose the threads */ info("Releasing all threads\n"); status = pthread_barrier_wait(&all_threads_ready); if (status && status != PTHREAD_BARRIER_SERIAL_THREAD) { error("main: pthread_barrier_wait(all_threads_ready): 0x%x\n", status); set_shutdown_flag(); return FAILURE; } reporter(NULL); if (!quiet) { fputs(DOWN_ONE, stdout); printf("Stopping test\n"); } set_shutdown_flag(); /* wait for all threads to notice the shutdown flag */ if (have_errors == 0 && interrupted == 0) { info("waiting for all threads to complete\n"); status = pthread_barrier_wait(&all_threads_done); if (status && status != PTHREAD_BARRIER_SERIAL_THREAD) { error ("main: pthread_barrier_wait(all_threads_ready): 0x%x\n", status); return FAILURE; } info("All threads terminated!\n"); retval = SUCCESS; } else kill(0, SIGTERM); finish = time(NULL); summary(); if (lockall) munlockall(); exit(retval); }
MainWindow::MainWindow() : mFullScreenAction(NULL), mStandard3DViewActions(new QActionGroup(this)), mControlPanel(NULL), mDockWidgets(new DynamicMainWindowWidgets(this)), mActions(NULL) { this->setObjectName("MainWindow"); mServices = VisServices::create(logicManager()->getPluginContext()); mLayoutInteractor.reset(new LayoutInteractor()); this->setCentralWidget(viewService()->getLayoutWidget(this, 0)); mActions = new MainWindowActions(mServices, this); this->createActions(); this->createMenus(); this->createToolBars(); this->setStatusBar(new StatusBar()); reporter()->setAudioSource(AudioPtr(new AudioImpl())); connect(stateService().get(), &StateService::applicationStateChanged, this, &MainWindow::onApplicationStateChangedSlot); connect(stateService().get(), &StateService::workflowStateChanged, this, &MainWindow::onWorkflowStateChangedSlot); connect(stateService().get(), &StateService::workflowStateAboutToChange, this, &MainWindow::saveDesktopSlot); this->updateWindowTitle(); this->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North); this->addAsDockWidget(new PlaybackWidget(this), "Browsing"); this->addAsDockWidget(new VideoConnectionWidget(mServices, this), "Utility"); this->addAsDockWidget(new EraserWidget(mServices->patientModelService, mServices->visualizationService, this), "Properties"); this->addAsDockWidget(new MetricWidget(mServices->visualizationService, mServices->patientModelService, this), "Utility"); this->addAsDockWidget(new SlicePropertiesWidget(mServices->patientModelService, mServices->visualizationService, this), "Properties"); this->addAsDockWidget(new VolumePropertiesWidget(mServices->patientModelService, mServices->visualizationService, this), "Properties"); this->addAsDockWidget(new MeshInfoWidget(mServices->patientModelService, mServices->visualizationService, this), "Properties"); this->addAsDockWidget(new StreamPropertiesWidget(mServices->patientModelService, mServices->visualizationService, this), "Properties"); this->addAsDockWidget(new TrackPadWidget(this), "Utility"); this->addAsDockWidget(new ToolPropertiesWidget(this), "Properties"); this->addAsDockWidget(new NavigationWidget(this), "Properties"); this->addAsDockWidget(new ConsoleWidget(this, "ConsoleWidget", "Console"), "Utility"); this->addAsDockWidget(new ConsoleWidget(this, "ConsoleWidget2", "Extra Console"), "Utility"); // this->addAsDockWidget(new ConsoleWidgetCollection(this, "ConsoleWidgets", "Consoles"), "Utility"); this->addAsDockWidget(new FrameTreeWidget(mServices->patientModelService, this), "Browsing"); this->addAsDockWidget(new ToolManagerWidget(this), "Debugging"); this->addAsDockWidget(new PluginFrameworkWidget(this), "Browsing"); this->addAsDockWidget(new AllFiltersWidget(VisServices::create(logicManager()->getPluginContext()), this), "Algorithms"); connect(patientService().get(), &PatientModelService::patientChanged, this, &MainWindow::patientChangedSlot); connect(qApp, &QApplication::focusChanged, this, &MainWindow::focusChanged); this->setupGUIExtenders(); // window menu must be created after all dock widgets are created QMenu* popupMenu = this->createPopupMenu(); popupMenu->setTitle("Window"); this->menuBar()->insertMenu(mHelpMenuAction, popupMenu); // Restore saved window states // Must be done after all DockWidgets are created if (restoreGeometry(settings()->value("mainWindow/geometry").toByteArray())) { this->show(); } else { this->showMaximized(); } if (settings()->value("gui/fullscreen").toBool()) this->setWindowState(this->windowState() | Qt::WindowFullScreen); }
void PatientLandMarksWidget::setTargetLandmark(QString uid, Vector3D p_target) { mServices->patient()->getPatientLandmarks()->setLandmark(Landmark(uid, p_target)); reporter()->playSampleSound(); }
// SamplerIntegrator Method Definitions void SamplerIntegrator::Render(const Scene &scene) { ProfilePhase p(Prof::IntegratorRender); Preprocess(scene, *sampler); // Render image tiles in parallel // Compute number of tiles, _nTiles_, to use for parallel rendering Bounds2i sampleBounds = camera->film->GetSampleBounds(); Vector2i sampleExtent = sampleBounds.Diagonal(); const int tileSize = 16; Point2i nTiles((sampleExtent.x + tileSize - 1) / tileSize, (sampleExtent.y + tileSize - 1) / tileSize); ProgressReporter reporter(nTiles.x * nTiles.y, "Rendering"); { StatTimer timer(&renderingTime); ParallelFor2D([&](Point2i tile) { // Render section of image corresponding to _tile_ // Allocate _MemoryArena_ for tile MemoryArena arena; // Get sampler instance for tile int seed = tile.y * nTiles.x + tile.x; std::unique_ptr<Sampler> tileSampler = sampler->Clone(seed); // Compute sample bounds for tile int x0 = sampleBounds.pMin.x + tile.x * tileSize; int x1 = std::min(x0 + tileSize, sampleBounds.pMax.x); int y0 = sampleBounds.pMin.y + tile.y * tileSize; int y1 = std::min(y0 + tileSize, sampleBounds.pMax.y); Bounds2i tileBounds(Point2i(x0, y0), Point2i(x1, y1)); // Get _FilmTile_ for tile std::unique_ptr<FilmTile> filmTile = camera->film->GetFilmTile(tileBounds); // Loop over pixels in tile to render them for (Point2i pixel : tileBounds) { { ProfilePhase pp(Prof::StartPixel); tileSampler->StartPixel(pixel); } do { // Initialize _CameraSample_ for current sample CameraSample cameraSample = tileSampler->GetCameraSample(pixel); // Generate camera ray for current sample RayDifferential ray; Float rayWeight = camera->GenerateRayDifferential(cameraSample, &ray); ray.ScaleDifferentials( 1 / std::sqrt((Float)tileSampler->samplesPerPixel)); ++nCameraRays; // Evaluate radiance along camera ray Spectrum L(0.f); if (rayWeight > 0) L = Li(ray, scene, *tileSampler, arena); // Issue warning if unexpected radiance value returned if (L.HasNaNs()) { Error( "Not-a-number radiance value returned " "for image sample. Setting to black."); L = Spectrum(0.f); } else if (L.y() < -1e-5) { Error( "Negative luminance value, %f, returned " "for image sample. Setting to black.", L.y()); L = Spectrum(0.f); } else if (std::isinf(L.y())) { Error( "Infinite luminance value returned " "for image sample. Setting to black."); L = Spectrum(0.f); } // Add camera ray's contribution to image filmTile->AddSample(cameraSample.pFilm, L, rayWeight); // Free _MemoryArena_ memory from computing image sample // value arena.Reset(); } while (tileSampler->StartNextSample()); } // Merge image tile into _Film_ camera->film->MergeFilmTile(std::move(filmTile)); reporter.Update(); }, nTiles); reporter.Done(); } // Save final image after rendering camera->film->WriteImage(); }
void SyncSourceFeedback::run(executor::TaskExecutor* executor, BackgroundSync* bgsync) { Client::initThread("SyncSourceFeedback"); HostAndPort syncTarget; // keepAliveInterval indicates how frequently to forward progress in the absence of updates. Milliseconds keepAliveInterval(0); while (true) { // breaks once _shutdownSignaled is true auto txn = cc().makeOperationContext(); if (keepAliveInterval == Milliseconds(0)) { keepAliveInterval = calculateKeepAliveInterval(txn.get(), _mtx); } { // Take SyncSourceFeedback lock before calling into ReplicationCoordinator // to avoid deadlock because ReplicationCoordinator could conceivably calling back into // this class. stdx::unique_lock<stdx::mutex> lock(_mtx); while (!_positionChanged && !_shutdownSignaled) { if (_cond.wait_for(lock, keepAliveInterval.toSystemDuration()) == stdx::cv_status::timeout) { MemberState state = ReplicationCoordinator::get(txn.get())->getMemberState(); if (!(state.primary() || state.startup())) { break; } } } if (_shutdownSignaled) { break; } _positionChanged = false; } { stdx::lock_guard<stdx::mutex> lock(_mtx); MemberState state = ReplicationCoordinator::get(txn.get())->getMemberState(); if (state.primary() || state.startup()) { continue; } } const HostAndPort target = bgsync->getSyncTarget(); // Log sync source changes. if (target.empty()) { if (syncTarget != target) { syncTarget = target; } // Loop back around again; the keepalive functionality will cause us to retry continue; } if (syncTarget != target) { LOG(1) << "setting syncSourceFeedback to " << target; syncTarget = target; // Update keepalive value from config. auto oldKeepAliveInterval = keepAliveInterval; keepAliveInterval = calculateKeepAliveInterval(txn.get(), _mtx); if (oldKeepAliveInterval != keepAliveInterval) { LOG(1) << "new syncSourceFeedback keep alive duration = " << keepAliveInterval << " (previously " << oldKeepAliveInterval << ")"; } } Reporter reporter( executor, makePrepareReplSetUpdatePositionCommandFn(txn.get(), _mtx, syncTarget, bgsync), syncTarget, keepAliveInterval); { stdx::lock_guard<stdx::mutex> lock(_mtx); _reporter = &reporter; } ON_BLOCK_EXIT([this]() { stdx::lock_guard<stdx::mutex> lock(_mtx); _reporter = nullptr; }); auto status = _updateUpstream(txn.get(), bgsync); if (!status.isOK()) { LOG(1) << "The replication progress command (replSetUpdatePosition) failed and will be " "retried: " << status; } } }
void LandmarkPatientRegistrationWidget::setTargetLandmark(QString uid, Vector3D p_target) { mServices.patientModelService->getPatientLandmarks()->setLandmark(Landmark(uid, p_target)); reporter()->playSampleSound(); }
bool CompositorD3D11::Initialize() { bool force = gfxPrefs::LayersAccelerationForceEnabled(); ScopedGfxFeatureReporter reporter("D3D11 Layers", force); if (!gfxPlatform::CanUseDirect3D11()) { NS_WARNING("Direct3D 11-accelerated layers are not supported on this system."); return false; } HRESULT hr; mDevice = gfxWindowsPlatform::GetPlatform()->GetD3D11Device(); if (!mDevice) { return false; } mDevice->GetImmediateContext(byRef(mContext)); if (!mContext) { return false; } mFeatureLevel = mDevice->GetFeatureLevel(); mHwnd = (HWND)mWidget->GetNativeData(NS_NATIVE_WINDOW); memset(&mVSConstants, 0, sizeof(VertexShaderConstants)); int referenceCount = 0; UINT size = sizeof(referenceCount); // If this isn't there yet it'll fail, count will remain 0, which is correct. mDevice->GetPrivateData(sLayerManagerCount, &size, &referenceCount); referenceCount++; mDevice->SetPrivateData(sLayerManagerCount, sizeof(referenceCount), &referenceCount); size = sizeof(DeviceAttachmentsD3D11*); if (FAILED(mDevice->GetPrivateData(sDeviceAttachmentsD3D11, &size, &mAttachments))) { mAttachments = new DeviceAttachmentsD3D11; mDevice->SetPrivateData(sDeviceAttachmentsD3D11, sizeof(mAttachments), &mAttachments); D3D11_INPUT_ELEMENT_DESC layout[] = { { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; hr = mDevice->CreateInputLayout(layout, sizeof(layout) / sizeof(D3D11_INPUT_ELEMENT_DESC), LayerQuadVS, sizeof(LayerQuadVS), byRef(mAttachments->mInputLayout)); if (FAILED(hr)) { return false; } Vertex vertices[] = { {{0.0, 0.0}}, {{1.0, 0.0}}, {{0.0, 1.0}}, {{1.0, 1.0}} }; CD3D11_BUFFER_DESC bufferDesc(sizeof(vertices), D3D11_BIND_VERTEX_BUFFER); D3D11_SUBRESOURCE_DATA data; data.pSysMem = (void*)vertices; hr = mDevice->CreateBuffer(&bufferDesc, &data, byRef(mAttachments->mVertexBuffer)); if (FAILED(hr)) { return false; } if (!CreateShaders()) { return false; } CD3D11_BUFFER_DESC cBufferDesc(sizeof(VertexShaderConstants), D3D11_BIND_CONSTANT_BUFFER, D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE); hr = mDevice->CreateBuffer(&cBufferDesc, nullptr, byRef(mAttachments->mVSConstantBuffer)); if (FAILED(hr)) { return false; } cBufferDesc.ByteWidth = sizeof(PixelShaderConstants); hr = mDevice->CreateBuffer(&cBufferDesc, nullptr, byRef(mAttachments->mPSConstantBuffer)); if (FAILED(hr)) { return false; } CD3D11_RASTERIZER_DESC rastDesc(D3D11_DEFAULT); rastDesc.CullMode = D3D11_CULL_NONE; rastDesc.ScissorEnable = TRUE; hr = mDevice->CreateRasterizerState(&rastDesc, byRef(mAttachments->mRasterizerState)); if (FAILED(hr)) { return false; } CD3D11_SAMPLER_DESC samplerDesc(D3D11_DEFAULT); hr = mDevice->CreateSamplerState(&samplerDesc, byRef(mAttachments->mLinearSamplerState)); if (FAILED(hr)) { return false; } samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT; hr = mDevice->CreateSamplerState(&samplerDesc, byRef(mAttachments->mPointSamplerState)); if (FAILED(hr)) { return false; } CD3D11_BLEND_DESC blendDesc(D3D11_DEFAULT); D3D11_RENDER_TARGET_BLEND_DESC rtBlendPremul = { TRUE, D3D11_BLEND_ONE, D3D11_BLEND_INV_SRC_ALPHA, D3D11_BLEND_OP_ADD, D3D11_BLEND_ONE, D3D11_BLEND_INV_SRC_ALPHA, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL }; blendDesc.RenderTarget[0] = rtBlendPremul; hr = mDevice->CreateBlendState(&blendDesc, byRef(mAttachments->mPremulBlendState)); if (FAILED(hr)) { return false; } D3D11_RENDER_TARGET_BLEND_DESC rtBlendNonPremul = { TRUE, D3D11_BLEND_SRC_ALPHA, D3D11_BLEND_INV_SRC_ALPHA, D3D11_BLEND_OP_ADD, D3D11_BLEND_ONE, D3D11_BLEND_INV_SRC_ALPHA, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL }; blendDesc.RenderTarget[0] = rtBlendNonPremul; hr = mDevice->CreateBlendState(&blendDesc, byRef(mAttachments->mNonPremulBlendState)); if (FAILED(hr)) { return false; } if (gfxPrefs::ComponentAlphaEnabled()) { D3D11_RENDER_TARGET_BLEND_DESC rtBlendComponent = { TRUE, D3D11_BLEND_ONE, D3D11_BLEND_INV_SRC1_COLOR, D3D11_BLEND_OP_ADD, D3D11_BLEND_ONE, D3D11_BLEND_INV_SRC_ALPHA, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL }; blendDesc.RenderTarget[0] = rtBlendComponent; hr = mDevice->CreateBlendState(&blendDesc, byRef(mAttachments->mComponentBlendState)); if (FAILED(hr)) { return false; } } D3D11_RENDER_TARGET_BLEND_DESC rtBlendDisabled = { FALSE, D3D11_BLEND_SRC_ALPHA, D3D11_BLEND_INV_SRC_ALPHA, D3D11_BLEND_OP_ADD, D3D11_BLEND_ONE, D3D11_BLEND_INV_SRC_ALPHA, D3D11_BLEND_OP_ADD, D3D11_COLOR_WRITE_ENABLE_ALL }; blendDesc.RenderTarget[0] = rtBlendDisabled; hr = mDevice->CreateBlendState(&blendDesc, byRef(mAttachments->mDisabledBlendState)); if (FAILED(hr)) { return false; } } nsRefPtr<IDXGIDevice> dxgiDevice; nsRefPtr<IDXGIAdapter> dxgiAdapter; mDevice->QueryInterface(dxgiDevice.StartAssignment()); dxgiDevice->GetAdapter(getter_AddRefs(dxgiAdapter)); #ifdef MOZ_METRO if (IsRunningInWindowsMetro()) { nsRefPtr<IDXGIFactory2> dxgiFactory; dxgiAdapter->GetParent(IID_PPV_ARGS(dxgiFactory.StartAssignment())); nsIntRect rect; mWidget->GetClientBounds(rect); DXGI_SWAP_CHAIN_DESC1 swapDesc = { 0 }; // Automatically detect the width and the height from the winrt CoreWindow swapDesc.Width = rect.width; swapDesc.Height = rect.height; // This is the most common swapchain format swapDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; swapDesc.Stereo = false; // Don't use multi-sampling swapDesc.SampleDesc.Count = 1; swapDesc.SampleDesc.Quality = 0; swapDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; // Use double buffering to enable flip swapDesc.BufferCount = 2; swapDesc.Scaling = DXGI_SCALING_NONE; // All Metro style apps must use this SwapEffect swapDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; swapDesc.Flags = 0; /** * Create a swap chain, this swap chain will contain the backbuffer for * the window we draw to. The front buffer is the full screen front * buffer. */ nsRefPtr<IDXGISwapChain1> swapChain1; hr = dxgiFactory->CreateSwapChainForCoreWindow( dxgiDevice, (IUnknown *)mWidget->GetNativeData(NS_NATIVE_ICOREWINDOW), &swapDesc, nullptr, getter_AddRefs(swapChain1)); if (FAILED(hr)) { return false; } mSwapChain = swapChain1; } else #endif { nsRefPtr<IDXGIFactory> dxgiFactory; dxgiAdapter->GetParent(IID_PPV_ARGS(dxgiFactory.StartAssignment())); DXGI_SWAP_CHAIN_DESC swapDesc; ::ZeroMemory(&swapDesc, sizeof(swapDesc)); swapDesc.BufferDesc.Width = 0; swapDesc.BufferDesc.Height = 0; swapDesc.BufferDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; swapDesc.BufferDesc.RefreshRate.Numerator = 60; swapDesc.BufferDesc.RefreshRate.Denominator = 1; swapDesc.SampleDesc.Count = 1; swapDesc.SampleDesc.Quality = 0; swapDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; swapDesc.BufferCount = 1; swapDesc.OutputWindow = mHwnd; swapDesc.Windowed = TRUE; swapDesc.Flags = 0; /** * Create a swap chain, this swap chain will contain the backbuffer for * the window we draw to. The front buffer is the full screen front * buffer. */ hr = dxgiFactory->CreateSwapChain(dxgiDevice, &swapDesc, byRef(mSwapChain)); if (FAILED(hr)) { return false; } // We need this because we don't want DXGI to respond to Alt+Enter. dxgiFactory->MakeWindowAssociation(swapDesc.OutputWindow, DXGI_MWA_NO_WINDOW_CHANGES); } reporter.SetSuccessful(); return true; }
int main(int argc, char** argv) { int world_rank, world_size; int num_editors, num_partitions, **colorMatrix; if (argc != 2) { printf("Error in reading command line arguments!\n"); return 0; } MPI_Init(NULL, NULL); MPI_Barrier(MPI_COMM_WORLD); stime = MPI_Wtime(); MPI_Comm_rank(MPI_COMM_WORLD, &world_rank); MPI_Comm_size(MPI_COMM_WORLD, &world_size); if (world_rank == 0) fprintf(stderr, "START TIME: %lf\n", MPI_Wtime()); //News Datatype const int dt_num = 3; MPI_Datatype dt_type[3] = {MPI_UNSIGNED, MPI_UNSIGNED, MPI_DOUBLE}; int dt_blocklen[3] = {1,1,1}; MPI_Datatype dt_news; MPI_Aint offset[3]; offset[0] = offsetof(newsitem, event); offset[1] = offsetof(newsitem, area); offset[2] = offsetof(newsitem, time_stamp); MPI_Type_create_struct(dt_num, dt_blocklen, offset, dt_type, &dt_news); MPI_Type_commit(&dt_news); MPI_Comm editors_comm, org_comm, news_source_comm, editor_partition_comm; informant_rank = 0; editor_rank = 0; if (!readConfig(argv[1], &colorMatrix, &num_editors, &num_partitions, world_size)) { printf("Error in reading configuration file! \n"); return 0; } if (world_rank == 0) MPI_Comm_split(MPI_COMM_WORLD, MPI_UNDEFINED, world_rank, &editors_comm); else if (world_rank <= num_editors) MPI_Comm_split(MPI_COMM_WORLD, 1, world_rank, &editors_comm); else MPI_Comm_split(MPI_COMM_WORLD, MPI_UNDEFINED, world_rank, &editors_comm); int* org_color = (int*) malloc(sizeof(int)*world_size); org_color[0] = MPI_UNDEFINED; int num_reporters_per_editor; int current_reporter_index = num_editors + 1; int i, j; for (i = 0; i < num_editors; i++) { num_reporters_per_editor = 0; org_color[i+1] = i; for (j = 0; j < num_partitions; j++) num_reporters_per_editor += colorMatrix[j][i]; for (j = 0; j < num_reporters_per_editor; j++) { org_color[current_reporter_index] = i; current_reporter_index++; } } MPI_Comm_split(MPI_COMM_WORLD, org_color[world_rank], world_rank, &org_comm); org_color[0] = 0; for (i = 1; i <= num_editors; i++) org_color[i] = MPI_UNDEFINED; for(i = num_editors + 1; i < world_size; i++) org_color[i] = 0; MPI_Comm_split(MPI_COMM_WORLD, org_color[world_rank], world_rank, &news_source_comm); int *reporters_area = (int*) malloc((world_size - num_editors - 1) * sizeof(int)); org_color[0] = MPI_UNDEFINED; for (i = 1; i <= num_editors; i++) org_color[i] = MPI_UNDEFINED; current_reporter_index = num_editors + 1; int current_color = 0; for (i = 0; i < num_editors; i++) { for (j = 0; j < num_partitions; j++) { for (int k = 0; k < colorMatrix[j][i]; k++) { org_color[current_reporter_index] = current_color; reporters_area[current_reporter_index - num_editors - 1] = j; current_reporter_index ++; } current_color ++; } } MPI_Comm_split(MPI_COMM_WORLD, org_color[world_rank], world_rank, &editor_partition_comm); int editor_rank; if (world_rank == 0) informant(news_source_comm, reporters_area, num_partitions, dt_news); else if (world_rank <= num_editors) editor(editors_comm, org_comm, dt_news); else reporter(org_comm, news_source_comm, editor_partition_comm, dt_news); MPI_Finalize(); return 0; }
MainWindow::~MainWindow() { viewService()->deactivateLayout(); reporter()->setAudioSource(AudioPtr()); // important! QSound::play fires a thread, causes segfault during shutdown mServiceListener.reset(); }
bool GLLibraryEGL::EnsureInitialized() { if (mInitialized) { return true; } mozilla::ScopedGfxFeatureReporter reporter("EGL"); #ifdef MOZ_B2G if (!sCurrentContext.init()) MOZ_CRASH("Tls init failed"); #endif #ifdef XP_WIN #ifdef MOZ_WEBGL if (!mEGLLibrary) { // On Windows, the GLESv2, EGL and DXSDK libraries are shipped with libxul and // we should look for them there. We have to load the libs in this // order, because libEGL.dll depends on libGLESv2.dll which depends on the DXSDK // libraries. This matters especially for WebRT apps which are in a different directory. // See bug 760323 and bug 749459 // Also note that we intentionally leak the libs we load. do { // Windows 8.1 has d3dcompiler_47.dll in the system directory. // Try it first. Note that _46 will never be in the system // directory and we ship with at least _43. So there is no point // trying _46 and _43 in the system directory. if (LoadLibrarySystem32(L"d3dcompiler_47.dll")) break; #ifdef MOZ_D3DCOMPILER_VISTA_DLL if (LoadLibraryForEGLOnWindows(NS_LITERAL_STRING(NS_STRINGIFY(MOZ_D3DCOMPILER_VISTA_DLL)))) break; #endif #ifdef MOZ_D3DCOMPILER_XP_DLL if (LoadLibraryForEGLOnWindows(NS_LITERAL_STRING(NS_STRINGIFY(MOZ_D3DCOMPILER_XP_DLL)))) break; #endif MOZ_ASSERT(false, "d3dcompiler DLL loading failed."); } while (false); LoadLibraryForEGLOnWindows(NS_LITERAL_STRING("libGLESv2.dll")); mEGLLibrary = LoadLibraryForEGLOnWindows(NS_LITERAL_STRING("libEGL.dll")); if (!mEGLLibrary) return false; } #endif // MOZ_WEBGL #else // !Windows // On non-Windows (Android) we use system copies of libEGL. We look for // the APITrace lib, libEGL.so, and libEGL.so.1 in that order. #if defined(ANDROID) if (!mEGLLibrary) mEGLLibrary = LoadApitraceLibrary(); #endif if (!mEGLLibrary) { printf_stderr("Attempting load of libEGL.so\n"); mEGLLibrary = PR_LoadLibrary("libEGL.so"); } #if defined(XP_UNIX) if (!mEGLLibrary) { mEGLLibrary = PR_LoadLibrary("libEGL.so.1"); } #endif if (!mEGLLibrary) { NS_WARNING("Couldn't load EGL LIB."); return false; } #endif // !Windows #define SYMBOL(name) \ { (PRFuncPtr*) &mSymbols.f##name, { "egl" #name, nullptr } } GLLibraryLoader::SymLoadStruct earlySymbols[] = { SYMBOL(GetDisplay), SYMBOL(GetCurrentSurface), SYMBOL(GetCurrentContext), SYMBOL(MakeCurrent), SYMBOL(DestroyContext), SYMBOL(CreateContext), SYMBOL(DestroySurface), SYMBOL(CreateWindowSurface), SYMBOL(CreatePbufferSurface), SYMBOL(CreatePixmapSurface), SYMBOL(BindAPI), SYMBOL(Initialize), SYMBOL(ChooseConfig), SYMBOL(GetError), SYMBOL(GetConfigs), SYMBOL(GetConfigAttrib), SYMBOL(WaitNative), SYMBOL(GetProcAddress), SYMBOL(SwapBuffers), SYMBOL(CopyBuffers), SYMBOL(QueryString), SYMBOL(QueryContext), SYMBOL(BindTexImage), SYMBOL(ReleaseTexImage), SYMBOL(QuerySurface), { nullptr, { nullptr } } }; if (!GLLibraryLoader::LoadSymbols(mEGLLibrary, &earlySymbols[0])) { NS_WARNING("Couldn't find required entry points in EGL library (early init)"); return false; } GLLibraryLoader::SymLoadStruct optionalSymbols[] = { // On Android 4.3 and up, certain features like ANDROID_native_fence_sync // can only be queried by using a special eglQueryString. { (PRFuncPtr*) &mSymbols.fQueryStringImplementationANDROID, { "_Z35eglQueryStringImplementationANDROIDPvi", nullptr } }, { nullptr, { nullptr } } }; GLLibraryLoader::LoadSymbols(mEGLLibrary, &optionalSymbols[0]); #if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 18 MOZ_RELEASE_ASSERT(mSymbols.fQueryStringImplementationANDROID, "Couldn't find eglQueryStringImplementationANDROID"); #endif mEGLDisplay = fGetDisplay(EGL_DEFAULT_DISPLAY); if (!fInitialize(mEGLDisplay, nullptr, nullptr)) return false; const char *vendor = (const char*) fQueryString(mEGLDisplay, LOCAL_EGL_VENDOR); if (vendor && (strstr(vendor, "TransGaming") != 0 || strstr(vendor, "Google Inc.") != 0)) { mIsANGLE = true; } InitExtensions(); GLLibraryLoader::PlatformLookupFunction lookupFunction = (GLLibraryLoader::PlatformLookupFunction)mSymbols.fGetProcAddress; if (IsExtensionSupported(KHR_lock_surface)) { GLLibraryLoader::SymLoadStruct lockSymbols[] = { { (PRFuncPtr*) &mSymbols.fLockSurface, { "eglLockSurfaceKHR", nullptr } }, { (PRFuncPtr*) &mSymbols.fUnlockSurface, { "eglUnlockSurfaceKHR", nullptr } }, { nullptr, { nullptr } } }; bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary, &lockSymbols[0], lookupFunction); if (!success) { NS_ERROR("EGL supports KHR_lock_surface without exposing its functions!"); MarkExtensionUnsupported(KHR_lock_surface); mSymbols.fLockSurface = nullptr; mSymbols.fUnlockSurface = nullptr; } } if (IsExtensionSupported(ANGLE_surface_d3d_texture_2d_share_handle)) { GLLibraryLoader::SymLoadStruct d3dSymbols[] = { { (PRFuncPtr*) &mSymbols.fQuerySurfacePointerANGLE, { "eglQuerySurfacePointerANGLE", nullptr } }, { nullptr, { nullptr } } }; bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary, &d3dSymbols[0], lookupFunction); if (!success) { NS_ERROR("EGL supports ANGLE_surface_d3d_texture_2d_share_handle without exposing its functions!"); MarkExtensionUnsupported(ANGLE_surface_d3d_texture_2d_share_handle); mSymbols.fQuerySurfacePointerANGLE = nullptr; } } if (IsExtensionSupported(KHR_fence_sync)) { GLLibraryLoader::SymLoadStruct syncSymbols[] = { { (PRFuncPtr*) &mSymbols.fCreateSync, { "eglCreateSyncKHR", nullptr } }, { (PRFuncPtr*) &mSymbols.fDestroySync, { "eglDestroySyncKHR", nullptr } }, { (PRFuncPtr*) &mSymbols.fClientWaitSync, { "eglClientWaitSyncKHR", nullptr } }, { (PRFuncPtr*) &mSymbols.fGetSyncAttrib, { "eglGetSyncAttribKHR", nullptr } }, { nullptr, { nullptr } } }; bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary, &syncSymbols[0], lookupFunction); if (!success) { NS_ERROR("EGL supports KHR_fence_sync without exposing its functions!"); MarkExtensionUnsupported(KHR_fence_sync); mSymbols.fCreateSync = nullptr; mSymbols.fDestroySync = nullptr; mSymbols.fClientWaitSync = nullptr; mSymbols.fGetSyncAttrib = nullptr; } } if (IsExtensionSupported(KHR_image) || IsExtensionSupported(KHR_image_base)) { GLLibraryLoader::SymLoadStruct imageSymbols[] = { { (PRFuncPtr*) &mSymbols.fCreateImage, { "eglCreateImageKHR", nullptr } }, { (PRFuncPtr*) &mSymbols.fDestroyImage, { "eglDestroyImageKHR", nullptr } }, { nullptr, { nullptr } } }; bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary, &imageSymbols[0], lookupFunction); if (!success) { NS_ERROR("EGL supports KHR_image(_base) without exposing its functions!"); MarkExtensionUnsupported(KHR_image); MarkExtensionUnsupported(KHR_image_base); MarkExtensionUnsupported(KHR_image_pixmap); mSymbols.fCreateImage = nullptr; mSymbols.fDestroyImage = nullptr; } } else { MarkExtensionUnsupported(KHR_image_pixmap); } mInitialized = true; reporter.SetSuccessful(); return true; }
MainWindow::MainWindow() : mFullScreenAction(NULL), mStandard3DViewActions(new QActionGroup(this)), mControlPanel(NULL), mDockWidgets(new DynamicMainWindowWidgets(this)), mActions(NULL) { this->setObjectName("MainWindow"); mServices = VisServices::create(logicManager()->getPluginContext()); mLayoutInteractor.reset(new LayoutInteractor()); this->setCentralWidget(viewService()->createLayoutWidget(this, 0)); mActions = new MainWindowActions(mServices, this); this->createActions(); this->createMenus(); this->createToolBars(); this->setStatusBar(new StatusBar()); reporter()->setAudioSource(AudioPtr(new AudioImpl())); connect(stateService().get(), &StateService::applicationStateChanged, this, &MainWindow::onApplicationStateChangedSlot); connect(stateService().get(), &StateService::workflowStateChanged, this, &MainWindow::onWorkflowStateChangedSlot); connect(stateService().get(), &StateService::workflowStateAboutToChange, this, &MainWindow::saveDesktopSlot); this->updateWindowTitle(); this->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North); this->addAsDockWidget(new PlaybackWidget(this), "Browsing"); this->addAsDockWidget(new VideoConnectionWidget(mServices, this), "Utility"); this->addAsDockWidget(new EraserWidget(mServices->patient(), mServices->view(), this), "Properties"); this->addAsDockWidget(new MetricWidget(mServices->view(), mServices->patient(), this), "Utility"); this->addAsDockWidget(new SlicePropertiesWidget(mServices->patient(), mServices->view(), this), "Properties"); this->addAsDockWidget(new VolumePropertiesWidget(mServices, this), "Properties"); this->addAsDockWidget(new ActiveMeshPropertiesWidget(mServices, this), "Properties"); this->addAsDockWidget(new StreamPropertiesWidget(mServices->patient(), mServices->view(), this), "Properties"); this->addAsDockWidget(new TrackPadWidget(this), "Utility"); this->addAsDockWidget(new ActiveToolPropertiesWidget(mServices->tracking(), mServices->spaceProvider(), this), "Properties"); this->addAsDockWidget(new NavigationWidget(this), "Properties"); this->addAsDockWidget(new ConsoleWidget(this, "ConsoleWidget", "Console"), "Utility"); this->addAsDockWidget(new ConsoleWidget(this, "ConsoleWidget2", "Extra Console"), "Utility"); // this->addAsDockWidget(new ConsoleWidgetCollection(this, "ConsoleWidgets", "Consoles"), "Utility"); this->addAsDockWidget(new FrameTreeWidget(mServices->patient(), this), "Browsing"); this->addAsDockWidget(new ToolManagerWidget(this), "Debugging"); this->addAsDockWidget(new PluginFrameworkWidget(this), "Browsing"); this->addAsDockWidget(new FiltersWidget(VisServices::create(logicManager()->getPluginContext()), this), "Algorithms"); this->addAsDockWidget(new ClippingPropertiesWidget(mServices, this), "Properties"); this->addAsDockWidget(new BrowserWidget(this, mServices), "Browsing"); connect(patientService().get(), &PatientModelService::patientChanged, this, &MainWindow::patientChangedSlot); connect(qApp, &QApplication::focusChanged, this, &MainWindow::focusChanged); this->setupGUIExtenders(); // window menu must be created after all dock widgets are created QMenu* popupMenu = this->createPopupMenu(); popupMenu->setTitle("Window"); this->menuBar()->insertMenu(mHelpMenuAction, popupMenu); // show after window has been initialized QTimer::singleShot(0, this, SLOT(delayedShow())); }
bool GLXLibrary::EnsureInitialized(LibType libType) { if (mInitialized) { return true; } // Don't repeatedly try to initialize. if (mTriedInitializing) { return false; } mTriedInitializing = true; // Force enabling s3 texture compression. (Bug 774134) PR_SetEnv("force_s3tc_enable=true"); if (!mOGLLibrary) { const char* libGLfilename = nullptr; bool forceFeatureReport = false; switch (libType) { case MESA_LLVMPIPE_LIB: libGLfilename = "mesallvmpipe.so"; forceFeatureReport = true; break; case OPENGL_LIB: // see e.g. bug 608526: it is intrinsically interesting to know whether we have dynamically linked to libGL.so.1 // because at least the NVIDIA implementation requires an executable stack, which causes mprotect calls, // which trigger glibc bug http://sourceware.org/bugzilla/show_bug.cgi?id=12225 #ifdef __OpenBSD__ libGLfilename = "libGL.so"; #else libGLfilename = "libGL.so.1"; #endif break; default: MOZ_CRASH("Invalid GLX library type."); } ScopedGfxFeatureReporter reporter(libGLfilename, forceFeatureReport); mOGLLibrary = PR_LoadLibrary(libGLfilename); if (!mOGLLibrary) { NS_WARNING("Couldn't load OpenGL shared library."); return false; } reporter.SetSuccessful(); } if (PR_GetEnv("MOZ_GLX_DEBUG")) { mDebug = true; } GLLibraryLoader::SymLoadStruct symbols[] = { /* functions that were in GLX 1.0 */ { (PRFuncPtr*) &xDestroyContextInternal, { "glXDestroyContext", nullptr } }, { (PRFuncPtr*) &xMakeCurrentInternal, { "glXMakeCurrent", nullptr } }, { (PRFuncPtr*) &xSwapBuffersInternal, { "glXSwapBuffers", nullptr } }, { (PRFuncPtr*) &xQueryVersionInternal, { "glXQueryVersion", nullptr } }, { (PRFuncPtr*) &xGetCurrentContextInternal, { "glXGetCurrentContext", nullptr } }, { (PRFuncPtr*) &xWaitGLInternal, { "glXWaitGL", nullptr } }, { (PRFuncPtr*) &xWaitXInternal, { "glXWaitX", nullptr } }, /* functions introduced in GLX 1.1 */ { (PRFuncPtr*) &xQueryExtensionsStringInternal, { "glXQueryExtensionsString", nullptr } }, { (PRFuncPtr*) &xGetClientStringInternal, { "glXGetClientString", nullptr } }, { (PRFuncPtr*) &xQueryServerStringInternal, { "glXQueryServerString", nullptr } }, { nullptr, { nullptr } } }; GLLibraryLoader::SymLoadStruct symbols13[] = { /* functions introduced in GLX 1.3 */ { (PRFuncPtr*) &xChooseFBConfigInternal, { "glXChooseFBConfig", nullptr } }, { (PRFuncPtr*) &xGetFBConfigAttribInternal, { "glXGetFBConfigAttrib", nullptr } }, // WARNING: xGetFBConfigs not set in symbols13_ext { (PRFuncPtr*) &xGetFBConfigsInternal, { "glXGetFBConfigs", nullptr } }, // WARNING: symbols13_ext sets xCreateGLXPixmapWithConfig instead { (PRFuncPtr*) &xCreatePixmapInternal, { "glXCreatePixmap", nullptr } }, { (PRFuncPtr*) &xDestroyPixmapInternal, { "glXDestroyPixmap", nullptr } }, { (PRFuncPtr*) &xCreateNewContextInternal, { "glXCreateNewContext", nullptr } }, { nullptr, { nullptr } } }; GLLibraryLoader::SymLoadStruct symbols13_ext[] = { /* extension equivalents for functions introduced in GLX 1.3 */ // GLX_SGIX_fbconfig extension { (PRFuncPtr*) &xChooseFBConfigInternal, { "glXChooseFBConfigSGIX", nullptr } }, { (PRFuncPtr*) &xGetFBConfigAttribInternal, { "glXGetFBConfigAttribSGIX", nullptr } }, // WARNING: no xGetFBConfigs equivalent in extensions // WARNING: different from symbols13: { (PRFuncPtr*) &xCreateGLXPixmapWithConfigInternal, { "glXCreateGLXPixmapWithConfigSGIX", nullptr } }, { (PRFuncPtr*) &xDestroyPixmapInternal, { "glXDestroyGLXPixmap", nullptr } }, // not from ext { (PRFuncPtr*) &xCreateNewContextInternal, { "glXCreateContextWithConfigSGIX", nullptr } }, { nullptr, { nullptr } } }; GLLibraryLoader::SymLoadStruct symbols14[] = { /* functions introduced in GLX 1.4 */ { (PRFuncPtr*) &xGetProcAddressInternal, { "glXGetProcAddress", nullptr } }, { nullptr, { nullptr } } }; GLLibraryLoader::SymLoadStruct symbols14_ext[] = { /* extension equivalents for functions introduced in GLX 1.4 */ // GLX_ARB_get_proc_address extension { (PRFuncPtr*) &xGetProcAddressInternal, { "glXGetProcAddressARB", nullptr } }, { nullptr, { nullptr } } }; GLLibraryLoader::SymLoadStruct symbols_texturefrompixmap[] = { { (PRFuncPtr*) &xBindTexImageInternal, { "glXBindTexImageEXT", nullptr } }, { (PRFuncPtr*) &xReleaseTexImageInternal, { "glXReleaseTexImageEXT", nullptr } }, { nullptr, { nullptr } } }; GLLibraryLoader::SymLoadStruct symbols_robustness[] = { { (PRFuncPtr*) &xCreateContextAttribsInternal, { "glXCreateContextAttribsARB", nullptr } }, { nullptr, { nullptr } } }; if (!GLLibraryLoader::LoadSymbols(mOGLLibrary, &symbols[0])) { NS_WARNING("Couldn't find required entry point in OpenGL shared library"); return false; } Display *display = DefaultXDisplay(); int screen = DefaultScreen(display); if (!xQueryVersion(display, &mGLXMajorVersion, &mGLXMinorVersion)) { mGLXMajorVersion = 0; mGLXMinorVersion = 0; return false; } if (!GLXVersionCheck(1, 1)) // Not possible to query for extensions. return false; const char *clientVendor = xGetClientString(display, LOCAL_GLX_VENDOR); const char *serverVendor = xQueryServerString(display, screen, LOCAL_GLX_VENDOR); const char *extensionsStr = xQueryExtensionsString(display, screen); GLLibraryLoader::SymLoadStruct *sym13; if (!GLXVersionCheck(1, 3)) { // Even if we don't have 1.3, we might have equivalent extensions // (as on the Intel X server). if (!HasExtension(extensionsStr, "GLX_SGIX_fbconfig")) { return false; } sym13 = symbols13_ext; } else { sym13 = symbols13; } if (!GLLibraryLoader::LoadSymbols(mOGLLibrary, sym13)) { NS_WARNING("Couldn't find required entry point in OpenGL shared library"); return false; } GLLibraryLoader::SymLoadStruct *sym14; if (!GLXVersionCheck(1, 4)) { // Even if we don't have 1.4, we might have equivalent extensions // (as on the Intel X server). if (!HasExtension(extensionsStr, "GLX_ARB_get_proc_address")) { return false; } sym14 = symbols14_ext; } else { sym14 = symbols14; } if (!GLLibraryLoader::LoadSymbols(mOGLLibrary, sym14)) { NS_WARNING("Couldn't find required entry point in OpenGL shared library"); return false; } if (HasExtension(extensionsStr, "GLX_EXT_texture_from_pixmap") && GLLibraryLoader::LoadSymbols(mOGLLibrary, symbols_texturefrompixmap, (GLLibraryLoader::PlatformLookupFunction)&xGetProcAddress)) { #ifdef MOZ_WIDGET_GTK mUseTextureFromPixmap = gfxPlatformGtk::GetPlatform()->UseXRender(); #else mUseTextureFromPixmap = true; #endif } else { mUseTextureFromPixmap = false; NS_WARNING("Texture from pixmap disabled"); } if (HasExtension(extensionsStr, "GLX_ARB_create_context_robustness") && GLLibraryLoader::LoadSymbols(mOGLLibrary, symbols_robustness)) { mHasRobustness = true; } mIsATI = serverVendor && DoesStringMatch(serverVendor, "ATI"); mIsNVIDIA = serverVendor && DoesStringMatch(serverVendor, "NVIDIA Corporation"); mClientIsMesa = clientVendor && DoesStringMatch(clientVendor, "Mesa"); mInitialized = true; mLibType = libType; return true; }
bool GLLibraryEGL::EnsureInitialized() { if (mInitialized) { return true; } mozilla::ScopedGfxFeatureReporter reporter("EGL"); #ifdef XP_WIN #ifdef MOZ_WEBGL if (!mEGLLibrary) { // On Windows, the GLESv2, EGL and DXSDK libraries are shipped with libxul and // we should look for them there. We have to load the libs in this // order, because libEGL.dll depends on libGLESv2.dll which depends on the DXSDK // libraries. This matters especially for WebRT apps which are in a different directory. // See bug 760323 and bug 749459 #ifndef MOZ_D3DX9_DLL #error MOZ_D3DX9_DLL should have been defined by the Makefile #endif LoadLibraryForEGLOnWindows(NS_LITERAL_STRING(NS_STRINGIFY(MOZ_D3DX9_DLL))); // intentionally leak the D3DX9_DLL library #ifndef MOZ_D3DCOMPILER_DLL #error MOZ_D3DCOMPILER_DLL should have been defined by the Makefile #endif LoadLibraryForEGLOnWindows(NS_LITERAL_STRING(NS_STRINGIFY(MOZ_D3DCOMPILER_DLL))); // intentionally leak the D3DCOMPILER_DLL library LoadLibraryForEGLOnWindows(NS_LITERAL_STRING("libGLESv2.dll")); // intentionally leak the libGLESv2.dll library mEGLLibrary = LoadLibraryForEGLOnWindows(NS_LITERAL_STRING("libEGL.dll")); if (!mEGLLibrary) return false; } #endif // MOZ_WEBGL #else // !Windows // On non-Windows (Android) we use system copies of libEGL. We look for // the APITrace lib, libEGL.so, and libEGL.so.1 in that order. #if defined(ANDROID) if (!mEGLLibrary) mEGLLibrary = LoadApitraceLibrary(); #endif if (!mEGLLibrary) { printf_stderr("Attempting load of libEGL.so\n"); mEGLLibrary = PR_LoadLibrary("libEGL.so"); } #if defined(XP_UNIX) if (!mEGLLibrary) { mEGLLibrary = PR_LoadLibrary("libEGL.so.1"); } #endif if (!mEGLLibrary) { NS_WARNING("Couldn't load EGL LIB."); return false; } #endif // !Windows #define SYMBOL(name) \ { (PRFuncPtr*) &mSymbols.f##name, { "egl" #name, NULL } } GLLibraryLoader::SymLoadStruct earlySymbols[] = { SYMBOL(GetDisplay), SYMBOL(GetCurrentSurface), SYMBOL(GetCurrentContext), SYMBOL(MakeCurrent), SYMBOL(DestroyContext), SYMBOL(CreateContext), SYMBOL(DestroySurface), SYMBOL(CreateWindowSurface), SYMBOL(CreatePbufferSurface), SYMBOL(CreatePixmapSurface), SYMBOL(BindAPI), SYMBOL(Initialize), SYMBOL(ChooseConfig), SYMBOL(GetError), SYMBOL(GetConfigs), SYMBOL(GetConfigAttrib), SYMBOL(WaitNative), SYMBOL(GetProcAddress), SYMBOL(SwapBuffers), SYMBOL(CopyBuffers), SYMBOL(QueryString), SYMBOL(QueryContext), SYMBOL(BindTexImage), SYMBOL(ReleaseTexImage), SYMBOL(QuerySurface), { NULL, { NULL } } }; if (!GLLibraryLoader::LoadSymbols(mEGLLibrary, &earlySymbols[0])) { NS_WARNING("Couldn't find required entry points in EGL library (early init)"); return false; } #if defined(MOZ_X11) && defined(MOZ_EGL_XRENDER_COMPOSITE) mEGLDisplay = fGetDisplay((EGLNativeDisplayType) gdk_x11_get_default_xdisplay()); #else mEGLDisplay = fGetDisplay(EGL_DEFAULT_DISPLAY); #endif if (!fInitialize(mEGLDisplay, NULL, NULL)) return false; const char *vendor = (const char*) fQueryString(mEGLDisplay, LOCAL_EGL_VENDOR); if (vendor && (strstr(vendor, "TransGaming") != 0 || strstr(vendor, "Google Inc.") != 0)) { mIsANGLE = true; } InitExtensions(); GLLibraryLoader::PlatformLookupFunction lookupFunction = (GLLibraryLoader::PlatformLookupFunction)mSymbols.fGetProcAddress; if (IsExtensionSupported(KHR_lock_surface)) { GLLibraryLoader::SymLoadStruct lockSymbols[] = { { (PRFuncPtr*) &mSymbols.fLockSurface, { "eglLockSurfaceKHR", nullptr } }, { (PRFuncPtr*) &mSymbols.fUnlockSurface, { "eglUnlockSurfaceKHR", nullptr } }, { nullptr, { nullptr } } }; bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary, &lockSymbols[0], lookupFunction); if (!success) { NS_ERROR("EGL supports KHR_lock_surface without exposing its functions!"); MarkExtensionUnsupported(KHR_lock_surface); mSymbols.fLockSurface = nullptr; mSymbols.fUnlockSurface = nullptr; } } if (IsExtensionSupported(ANGLE_surface_d3d_texture_2d_share_handle)) { GLLibraryLoader::SymLoadStruct d3dSymbols[] = { { (PRFuncPtr*) &mSymbols.fQuerySurfacePointerANGLE, { "eglQuerySurfacePointerANGLE", nullptr } }, { nullptr, { nullptr } } }; bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary, &d3dSymbols[0], lookupFunction); if (!success) { NS_ERROR("EGL supports ANGLE_surface_d3d_texture_2d_share_handle without exposing its functions!"); MarkExtensionUnsupported(ANGLE_surface_d3d_texture_2d_share_handle); mSymbols.fQuerySurfacePointerANGLE = nullptr; } } if (IsExtensionSupported(KHR_fence_sync)) { GLLibraryLoader::SymLoadStruct syncSymbols[] = { { (PRFuncPtr*) &mSymbols.fCreateSync, { "eglCreateSyncKHR", nullptr } }, { (PRFuncPtr*) &mSymbols.fDestroySync, { "eglDestroySyncKHR", nullptr } }, { (PRFuncPtr*) &mSymbols.fClientWaitSync, { "eglClientWaitSyncKHR", nullptr } }, { (PRFuncPtr*) &mSymbols.fGetSyncAttrib, { "eglGetSyncAttribKHR", nullptr } }, { nullptr, { nullptr } } }; bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary, &syncSymbols[0], lookupFunction); if (!success) { NS_ERROR("EGL supports KHR_fence_sync without exposing its functions!"); MarkExtensionUnsupported(KHR_fence_sync); mSymbols.fCreateSync = nullptr; mSymbols.fDestroySync = nullptr; mSymbols.fClientWaitSync = nullptr; mSymbols.fGetSyncAttrib = nullptr; } } mInitialized = true; reporter.SetSuccessful(); return true; }
void DIALOG_PLOT_SCHEMATIC::createSVGFile( bool aPrintAll, bool aPrintFrameRef ) { wxString msg; if( aPrintAll ) { SCH_SHEET_PATH* sheetpath; SCH_SHEET_PATH oldsheetpath = m_parent->GetCurrentSheet(); SCH_SHEET_LIST SheetList( NULL ); sheetpath = SheetList.GetFirst(); SCH_SHEET_PATH list; WX_TEXT_CTRL_REPORTER reporter(m_MessagesBox); for( ; ; ) { if( sheetpath == NULL ) { break; } SCH_SCREEN* screen; list.Clear(); if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) ) { m_parent->SetCurrentSheet( list ); m_parent->GetCurrentSheet().UpdateAllScreenReferences(); m_parent->SetSheetNumberAndCount(); screen = m_parent->GetCurrentSheet().LastScreen(); } else // Should not happen { return; } sheetpath = SheetList.GetNext(); try { wxString fname = m_parent->GetUniqueFilenameForCurrentSheet(); wxString ext = SVG_PLOTTER::GetDefaultFileExtension(); wxFileName plotFileName = createPlotFileName( m_outputDirectoryName, fname, ext, &reporter ); bool success = plotOneSheetSVG( m_parent, plotFileName.GetFullPath(), screen, getModeColor() ? false : true, aPrintFrameRef ); if( !success ) { msg.Printf( _( "Error creating file '%s'\n" ), GetChars( plotFileName.GetFullPath() ) ); } else { msg.Printf( _( "File '%s' OK\n" ), GetChars( plotFileName.GetFullPath() ) ); } m_MessagesBox->AppendText( msg ); } catch( const IO_ERROR& e ) { // Cannot plot SVG file msg.Printf( wxT( "SVG Plotter Exception : '%s'" ), GetChars( e.errorText ) ); m_MessagesBox->AppendText( msg ); m_parent->SetCurrentSheet( oldsheetpath ); m_parent->GetCurrentSheet().UpdateAllScreenReferences(); m_parent->SetSheetNumberAndCount(); return; } } m_parent->SetCurrentSheet( oldsheetpath ); m_parent->GetCurrentSheet().UpdateAllScreenReferences(); m_parent->SetSheetNumberAndCount(); } else // Print current sheet { SCH_SCREEN* screen = (SCH_SCREEN*) m_parent->GetScreen(); try { wxString fname = screen->GetFileName(); wxString ext = SVG_PLOTTER::GetDefaultFileExtension(); wxFileName fn = createPlotFileName( m_outputDirectoryName, fname, ext ); bool success = plotOneSheetSVG( m_parent, fn.GetFullPath(), screen, getModeColor() ? false : true, aPrintFrameRef ); if( success ) { msg.Printf( _( "Plot: <%s> OK\n" ), GetChars( fn.GetFullPath() ) ); } else // Error { msg.Printf( _( "Unable to create <%s>\n" ), GetChars( fn.GetFullPath() ) ); } m_MessagesBox->AppendText( msg ); } catch( const IO_ERROR& e ) { // Cannot plot SVG file msg.Printf( wxT( "SVG Plotter Exception : <%s>"), GetChars( e.errorText ) ); m_MessagesBox->AppendText( msg ); return; } } }
void WorkerThread::_PerformInstall(BMenu* srcMenu, BMenu* targetMenu) { CALLED(); BPath targetDirectory; BPath srcDirectory; BPath trashPath; BPath testPath; BDirectory targetDir; BDiskDevice device; BPartition* partition; BVolume targetVolume; status_t err = B_OK; int32 entries = 0; entry_ref testRef; const char* mountError = B_TRANSLATE("The disk can't be mounted. Please " "choose a different disk."); BMessenger messenger(fWindow); ProgressReporter reporter(messenger, new BMessage(MSG_STATUS_MESSAGE)); CopyEngine engine(&reporter); BList unzipEngines; PartitionMenuItem* targetItem = (PartitionMenuItem*)targetMenu->FindMarked(); PartitionMenuItem* srcItem = (PartitionMenuItem*)srcMenu->FindMarked(); if (!srcItem || !targetItem) { ERR("bad menu items\n"); goto error; } // check if target is initialized // ask if init or mount as is if (fDDRoster.GetPartitionWithID(targetItem->ID(), &device, &partition) == B_OK) { if (!partition->IsMounted()) { if ((err = partition->Mount()) < B_OK) { _SetStatusMessage(mountError); ERR("BPartition::Mount"); goto error; } } if ((err = partition->GetVolume(&targetVolume)) != B_OK) { ERR("BPartition::GetVolume"); goto error; } if ((err = partition->GetMountPoint(&targetDirectory)) != B_OK) { ERR("BPartition::GetMountPoint"); goto error; } } else if (fDDRoster.GetDeviceWithID(targetItem->ID(), &device) == B_OK) { if (!device.IsMounted()) { if ((err = device.Mount()) < B_OK) { _SetStatusMessage(mountError); ERR("BDiskDevice::Mount"); goto error; } } if ((err = device.GetVolume(&targetVolume)) != B_OK) { ERR("BDiskDevice::GetVolume"); goto error; } if ((err = device.GetMountPoint(&targetDirectory)) != B_OK) { ERR("BDiskDevice::GetMountPoint"); goto error; } } else goto error; // shouldn't happen // check if target has enough space if ((fSpaceRequired > 0 && targetVolume.FreeBytes() < fSpaceRequired) && ((new BAlert("", B_TRANSLATE("The destination disk may not have " "enough space. Try choosing a different disk or choose to not " "install optional items."), B_TRANSLATE("Try installing anyway"), B_TRANSLATE("Cancel"), 0, B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() != 0)) { goto error; } if (fDDRoster.GetPartitionWithID(srcItem->ID(), &device, &partition) == B_OK) { if ((err = partition->GetMountPoint(&srcDirectory)) != B_OK) { ERR("BPartition::GetMountPoint"); goto error; } } else if (fDDRoster.GetDeviceWithID(srcItem->ID(), &device) == B_OK) { if ((err = device.GetMountPoint(&srcDirectory)) != B_OK) { ERR("BDiskDevice::GetMountPoint"); goto error; } } else goto error; // shouldn't happen // check not installing on itself if (strcmp(srcDirectory.Path(), targetDirectory.Path()) == 0) { _SetStatusMessage(B_TRANSLATE("You can't install the contents of a " "disk onto itself. Please choose a different disk.")); goto error; } // check not installing on boot volume if ((strncmp(BOOT_PATH, targetDirectory.Path(), strlen(BOOT_PATH)) == 0) && ((new BAlert("", B_TRANSLATE("Are you sure you want to install " "onto the current boot disk? The Installer will have to reboot " "your machine if you proceed."), B_TRANSLATE("OK"), B_TRANSLATE("Cancel"), 0, B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() != 0)) { _SetStatusMessage("Installation stopped."); goto error; } // check if target volume's trash dir has anything in it // (target volume w/ only an empty trash dir is considered // an empty volume) if (find_directory(B_TRASH_DIRECTORY, &trashPath, false, &targetVolume) == B_OK && targetDir.SetTo(trashPath.Path()) == B_OK) { while (targetDir.GetNextRef(&testRef) == B_OK) { // Something in the Trash entries++; break; } } targetDir.SetTo(targetDirectory.Path()); // check if target volume otherwise has any entries while (entries == 0 && targetDir.GetNextRef(&testRef) == B_OK) { if (testPath.SetTo(&testRef) == B_OK && testPath != trashPath) entries++; } if (entries != 0 && ((new BAlert("", B_TRANSLATE("The target volume is not empty. Are " "you sure you want to install anyway?\n\nNote: The 'system' folder " "will be a clean copy from the source volume, all other folders " "will be merged, whereas files and links that exist on both the " "source and target volume will be overwritten with the source " "volume version."), B_TRANSLATE("Install anyway"), B_TRANSLATE("Cancel"), 0, B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() != 0)) { // TODO: Would be cool to offer the option here to clean additional // folders at the user's choice (like /boot/common and /boot/develop). err = B_CANCELED; goto error; } // Begin actual installation _LaunchInitScript(targetDirectory); // Create the default indices which should always be present on a proper // boot volume. We don't care if the source volume does not have them. // After all, the user might be re-installing to another drive and may // want problems fixed along the way... err = _CreateDefaultIndices(targetDirectory); if (err != B_OK) goto error; // Mirror all the indices which are present on the source volume onto // the target volume. err = _MirrorIndices(srcDirectory, targetDirectory); if (err != B_OK) goto error; // Let the engine collect information for the progress bar later on engine.ResetTargets(srcDirectory.Path()); err = engine.CollectTargets(srcDirectory.Path(), fCancelSemaphore); if (err != B_OK) goto error; // Collect selected packages also if (fPackages) { BPath pkgRootDir(srcDirectory.Path(), PACKAGES_DIRECTORY); int32 count = fPackages->CountItems(); for (int32 i = 0; i < count; i++) { Package *p = static_cast<Package*>(fPackages->ItemAt(i)); BPath packageDir(pkgRootDir.Path(), p->Folder()); err = engine.CollectTargets(packageDir.Path(), fCancelSemaphore); if (err != B_OK) goto error; } } // collect information about all zip packages err = _ProcessZipPackages(srcDirectory.Path(), targetDirectory.Path(), &reporter, unzipEngines); if (err != B_OK) goto error; reporter.StartTimer(); // copy source volume err = engine.CopyFolder(srcDirectory.Path(), targetDirectory.Path(), fCancelSemaphore); if (err != B_OK) goto error; // copy selected packages if (fPackages) { BPath pkgRootDir(srcDirectory.Path(), PACKAGES_DIRECTORY); int32 count = fPackages->CountItems(); for (int32 i = 0; i < count; i++) { Package *p = static_cast<Package*>(fPackages->ItemAt(i)); BPath packageDir(pkgRootDir.Path(), p->Folder()); err = engine.CopyFolder(packageDir.Path(), targetDirectory.Path(), fCancelSemaphore); if (err != B_OK) goto error; } } // Extract all zip packages. If an error occured, delete the rest of // the engines, but stop extracting. for (int32 i = 0; i < unzipEngines.CountItems(); i++) { UnzipEngine* engine = reinterpret_cast<UnzipEngine*>( unzipEngines.ItemAtFast(i)); if (err == B_OK) err = engine->UnzipPackage(); delete engine; } if (err != B_OK) goto error; _LaunchFinishScript(targetDirectory); BMessenger(fWindow).SendMessage(MSG_INSTALL_FINISHED); return; error: BMessage statusMessage(MSG_RESET); if (err == B_CANCELED) _SetStatusMessage(B_TRANSLATE("Installation canceled.")); else statusMessage.AddInt32("error", err); ERR("_PerformInstall failed"); BMessenger(fWindow).SendMessage(&statusMessage); }
/* Run an integrity check on the binary. Returns 0 on success. */ static int check_binary_integrity (void) { #ifdef ENABLE_HMAC_BINARY_CHECK gpg_error_t err; Dl_info info; unsigned char digest[32]; int dlen; char *fname = NULL; const char key[] = "What am I, a doctor or a moonshuttle conductor?"; if (!dladdr ("gcry_check_version", &info)) err = gpg_error_from_syserror (); else { dlen = _gcry_hmac256_file (digest, sizeof digest, info.dli_fname, key, strlen (key)); if (dlen < 0) err = gpg_error_from_syserror (); else if (dlen != 32) err = gpg_error (GPG_ERR_INTERNAL); else { fname = xtrymalloc (strlen (info.dli_fname) + 1 + 5 + 1 ); if (!fname) err = gpg_error_from_syserror (); else { FILE *fp; char *p; /* Prefix the basename with a dot. */ strcpy (fname, info.dli_fname); p = strrchr (fname, '/'); if (p) p++; else p = fname; memmove (p+1, p, strlen (p)+1); *p = '.'; strcat (fname, ".hmac"); /* Open the file. */ fp = fopen (fname, "r"); if (!fp) err = gpg_error_from_syserror (); else { /* A buffer of 64 bytes plus one for a LF and one to detect garbage. */ unsigned char buffer[64+1+1]; const unsigned char *s; int n; /* The HMAC files consists of lowercase hex digits with an optional trailing linefeed or optional with two trailing spaces. The latter format allows the use of the usual sha1sum format. Fail if there is any garbage. */ err = gpg_error (GPG_ERR_SELFTEST_FAILED); n = fread (buffer, 1, sizeof buffer, fp); if (n == 64 || (n == 65 && buffer[64] == '\n') || (n == 66 && buffer[64] == ' ' && buffer[65] == ' ')) { buffer[64] = 0; for (n=0, s= buffer; n < 32 && loxdigit_p (s) && loxdigit_p (s+1); n++, s += 2) buffer[n] = loxtoi_2 (s); if ( n == 32 && !memcmp (digest, buffer, 32) ) err = 0; } fclose (fp); } } } } reporter ("binary", 0, fname, err? gpg_strerror (err):NULL); #ifdef HAVE_SYSLOG if (err) syslog (LOG_USER|LOG_ERR, "Libgcrypt error: " "integrity check using `%s' failed: %s", fname? fname:"[?]", gpg_strerror (err)); #endif /*HAVE_SYSLOG*/ xfree (fname); return !!err; #else return 0; #endif }
bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName ) { wxString filetypes; wxArrayString filenamesList; wxFileName filename = aFullFileName; wxString currentPath; if( !filename.IsOk() ) { /* Standard gerber filetypes * (See http://en.wikipedia.org/wiki/Gerber_File) * the .gbr (.pho in legacy files) extension is the default used in Pcbnew * However there are a lot of other extensions used for gerber files * Because the first letter is usually g, we accept g* as extension * (Mainly internal copper layers do not have specific extension, * and filenames are like *.g1, *.g2 *.gb1 ...). * Now (2014) Ucamco (the company which manages the Gerber format) encourages * use of .gbr only and the Gerber X2 file format. */ filetypes = _( "Gerber files (.g* .lgr .pho)" ); filetypes << wxT("|"); filetypes += wxT("*.g*;*.G*;*.pho;*.PHO" ); filetypes << wxT("|"); /* Special gerber filetypes */ filetypes += _( "Top layer (*.GTL)|*.GTL;*.gtl|" ); filetypes += _( "Bottom layer (*.GBL)|*.GBL;*.gbl|" ); filetypes += _( "Bottom solder resist (*.GBS)|*.GBS;*.gbs|" ); filetypes += _( "Top solder resist (*.GTS)|*.GTS;*.gts|" ); filetypes += _( "Bottom overlay (*.GBO)|*.GBO;*.gbo|" ); filetypes += _( "Top overlay (*.GTO)|*.GTO;*.gto|" ); filetypes += _( "Bottom paste (*.GBP)|*.GBP;*.gbp|" ); filetypes += _( "Top paste (*.GTP)|*.GTP;*.gtp|" ); filetypes += _( "Keep-out layer (*.GKO)|*.GKO;*.gko|" ); filetypes += _( "Mechanical layers (*.GMx)|*.GM1;*.gm1;*.GM2;*.gm2;*.GM3;*.gm3|" ); filetypes += _( "Top Pad Master (*.GPT)|*.GPT;*.gpt|" ); filetypes += _( "Bottom Pad Master (*.GPB)|*.GPB;*.gpb|" ); // All filetypes filetypes += AllFilesWildcard; // Use the current working directory if the file name path does not exist. if( filename.DirExists() ) currentPath = filename.GetPath(); else { currentPath = m_mruPath; // On wxWidgets 3.1 (bug?) the path in wxFileDialog is ignored when // finishing by the dir separator. Remove it if any: if( currentPath.EndsWith( '\\' ) || currentPath.EndsWith( '/' ) ) currentPath.RemoveLast(); } wxFileDialog dlg( this, _( "Open Gerber File" ), currentPath, filename.GetFullName(), filetypes, wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE | wxFD_CHANGE_DIR ); if( dlg.ShowModal() == wxID_CANCEL ) return false; dlg.GetPaths( filenamesList ); // @todo Take a closer look at the CWD switching here. The current working directory // gets changed by wxFileDialog because the wxFD_CHANGE_DIR flag is set. Is this the // appropriate behavior? The current working directory is not returned to the previous // value so this may be an issue elsewhere. currentPath = wxGetCwd(); m_mruPath = currentPath; } else { filenamesList.Add( aFullFileName ); currentPath = filename.GetPath(); m_mruPath = currentPath; } // Set the busy cursor wxBusyCursor wait; // Read gerber files: each file is loaded on a new GerbView layer bool success = true; int layer = GetActiveLayer(); // Manage errors when loading files wxString msg; WX_STRING_REPORTER reporter( &msg ); for( unsigned ii = 0; ii < filenamesList.GetCount(); ii++ ) { filename = filenamesList[ii]; if( !filename.IsAbsolute() ) filename.SetPath( currentPath ); m_lastFileName = filename.GetFullPath(); SetActiveLayer( layer, false ); if( Read_GERBER_File( filename.GetFullPath() ) ) { UpdateFileHistory( m_lastFileName ); layer = getNextAvailableLayer( layer ); if( layer == NO_AVAILABLE_LAYERS && ii < filenamesList.GetCount()-1 ) { success = false; reporter.Report( MSG_NO_MORE_LAYER, REPORTER::RPT_ERROR ); // Report the name of not loaded files: ii += 1; while( ii < filenamesList.GetCount() ) { filename = filenamesList[ii++]; wxString txt; txt.Printf( MSG_NOT_LOADED, GetChars( filename.GetFullName() ) ); reporter.Report( txt, REPORTER::RPT_ERROR ); } break; } SetActiveLayer( layer, false ); } } if( !success ) { HTML_MESSAGE_BOX mbox( this, _( "Errors" ) ); mbox.ListSet( msg ); mbox.ShowModal(); } Zoom_Automatique( false ); // Synchronize layers tools with actual active layer: ReFillLayerWidget(); SetActiveLayer( GetActiveLayer() ); m_LayersManager->UpdateLayerIcons(); syncLayerBox(); return success; }
bool GLLibraryEGL::EnsureInitialized() { nsresult rv; if (mInitialized) { return true; } mozilla::ScopedGfxFeatureReporter reporter("EGL"); #ifdef XP_WIN if (!mEGLLibrary) { // On Windows, the GLESv2 and EGL libraries are shipped with libxul and // we should look for them there. We have to load the libs in this // order, because libEGL.dll depends on libGLESv2.dll. nsCOMPtr<nsIFile> libraryFile; nsCOMPtr<nsIProperties> dirService = do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID); if (!dirService) return false; rv = dirService->Get(NS_GRE_DIR, NS_GET_IID(nsIFile), getter_AddRefs(libraryFile)); if (NS_FAILED(rv)) return false; libraryFile->Append(NS_LITERAL_STRING("libGLESv2.dll")); PRLibrary* glesv2lib = nsnull; libraryFile->Load(&glesv2lib); // Intentionally leak glesv2lib libraryFile->SetLeafName(NS_LITERAL_STRING("libEGL.dll")); rv = libraryFile->Load(&mEGLLibrary); if (NS_FAILED(rv)) { NS_WARNING("Couldn't load libEGL.dll, canvas3d will be disabled."); return false; } } #else // !Windows // On non-Windows (Android) we use system copies of libEGL. We look for // the APITrace lib, libEGL.so, and libEGL.so.1 in that order. #if defined(ANDROID) if (!mEGLLibrary) mEGLLibrary = LoadApitraceLibrary(); #endif if (!mEGLLibrary) { printf_stderr("Attempting load of libEGL.so\n"); mEGLLibrary = PR_LoadLibrary("libEGL.so"); } #if defined(XP_UNIX) if (!mEGLLibrary) { mEGLLibrary = PR_LoadLibrary("libEGL.so.1"); } #endif if (!mEGLLibrary) { NS_WARNING("Couldn't load EGL LIB."); return false; } #endif // !Windows #define SYMBOL(name) \ { (PRFuncPtr*) &mSymbols.f##name, { "egl" #name, NULL } } GLLibraryLoader::SymLoadStruct earlySymbols[] = { SYMBOL(GetDisplay), SYMBOL(GetCurrentSurface), SYMBOL(GetCurrentContext), SYMBOL(MakeCurrent), SYMBOL(DestroyContext), SYMBOL(CreateContext), SYMBOL(DestroySurface), SYMBOL(CreateWindowSurface), SYMBOL(CreatePbufferSurface), SYMBOL(CreatePixmapSurface), SYMBOL(BindAPI), SYMBOL(Initialize), SYMBOL(ChooseConfig), SYMBOL(GetError), SYMBOL(GetConfigs), SYMBOL(GetConfigAttrib), SYMBOL(WaitNative), SYMBOL(GetProcAddress), SYMBOL(SwapBuffers), SYMBOL(CopyBuffers), SYMBOL(QueryString), SYMBOL(QueryContext), SYMBOL(BindTexImage), SYMBOL(ReleaseTexImage), SYMBOL(QuerySurface), { NULL, { NULL } } }; if (!GLLibraryLoader::LoadSymbols(mEGLLibrary, &earlySymbols[0])) { NS_WARNING("Couldn't find required entry points in EGL library (early init)"); return false; } #if defined(MOZ_X11) && defined(MOZ_EGL_XRENDER_COMPOSITE) mEGLDisplay = fGetDisplay((EGLNativeDisplayType) gdk_x11_get_default_xdisplay()); #else mEGLDisplay = fGetDisplay(EGL_DEFAULT_DISPLAY); #endif if (!fInitialize(mEGLDisplay, NULL, NULL)) return false; const char *vendor = (const char*) fQueryString(mEGLDisplay, LOCAL_EGL_VENDOR); if (vendor && (strstr(vendor, "TransGaming") != 0 || strstr(vendor, "Google Inc.") != 0)) { mIsANGLE = true; } const char *extensions = (const char*) fQueryString(mEGLDisplay, LOCAL_EGL_EXTENSIONS); if (!extensions) extensions = ""; printf_stderr("Extensions: %s 0x%02x\n", extensions, extensions[0]); printf_stderr("Extensions length: %d\n", strlen(extensions)); // note the extra space -- this ugliness tries to match // EGL_KHR_image in the middle of the string, or right at the // end. It's a prefix for other extensions, so we have to do // this... bool hasKHRImage = false; if (strstr(extensions, "EGL_KHR_image ") || (strlen(extensions) >= strlen("EGL_KHR_image") && strcmp(extensions+(strlen(extensions)-strlen("EGL_KHR_image")), "EGL_KHR_image"))) { hasKHRImage = true; } if (strstr(extensions, "EGL_KHR_image_base")) { mHave_EGL_KHR_image_base = true; } if (strstr(extensions, "EGL_KHR_image_pixmap")) { mHave_EGL_KHR_image_pixmap = true; } if (strstr(extensions, "EGL_KHR_gl_texture_2D_image")) { mHave_EGL_KHR_gl_texture_2D_image = true; } if (strstr(extensions, "EGL_KHR_lock_surface")) { mHave_EGL_KHR_lock_surface = true; } if (hasKHRImage) { GLLibraryLoader::SymLoadStruct khrSymbols[] = { { (PRFuncPtr*) &mSymbols.fCreateImageKHR, { "eglCreateImageKHR", NULL } }, { (PRFuncPtr*) &mSymbols.fDestroyImageKHR, { "eglDestroyImageKHR", NULL } }, { (PRFuncPtr*) &mSymbols.fImageTargetTexture2DOES, { "glEGLImageTargetTexture2DOES", NULL } }, { NULL, { NULL } } }; GLLibraryLoader::LoadSymbols(mEGLLibrary, &khrSymbols[0], (GLLibraryLoader::PlatformLookupFunction)mSymbols.fGetProcAddress); } if (mHave_EGL_KHR_lock_surface) { GLLibraryLoader::SymLoadStruct lockSymbols[] = { { (PRFuncPtr*) &mSymbols.fLockSurfaceKHR, { "eglLockSurfaceKHR", NULL } }, { (PRFuncPtr*) &mSymbols.fUnlockSurfaceKHR, { "eglUnlockSurfaceKHR", NULL } }, { NULL, { NULL } } }; GLLibraryLoader::LoadSymbols(mEGLLibrary, &lockSymbols[0], (GLLibraryLoader::PlatformLookupFunction)mSymbols.fGetProcAddress); if (!mSymbols.fLockSurfaceKHR) { mHave_EGL_KHR_lock_surface = false; } } if (!mSymbols.fCreateImageKHR) { mHave_EGL_KHR_image_base = false; mHave_EGL_KHR_image_pixmap = false; mHave_EGL_KHR_gl_texture_2D_image = false; } if (!mSymbols.fImageTargetTexture2DOES) { mHave_EGL_KHR_gl_texture_2D_image = false; } if (strstr(extensions, "EGL_ANGLE_surface_d3d_texture_2d_share_handle")) { GLLibraryLoader::SymLoadStruct d3dSymbols[] = { { (PRFuncPtr*) &mSymbols.fQuerySurfacePointerANGLE, { "eglQuerySurfacePointerANGLE", NULL } }, { NULL, { NULL } } }; GLLibraryLoader::LoadSymbols(mEGLLibrary, &d3dSymbols[0], (GLLibraryLoader::PlatformLookupFunction)mSymbols.fGetProcAddress); if (mSymbols.fQuerySurfacePointerANGLE) { mHave_EGL_ANGLE_surface_d3d_texture_2d_share_handle = true; } } if (strstr(extensions, "EGL_EXT_create_context_robustness")) { mHasRobustness = true; } mInitialized = true; reporter.SetSuccessful(); return true; }
bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName ) { wxString filetypes; wxArrayString filenamesList; wxFileName filename = aFullFileName; wxString currentPath; if( !filename.IsOk() ) { filetypes = DrillFileWildcard(); filetypes << wxT( "|" ); /* All filetypes */ filetypes += wxGetTranslation( AllFilesWildcard ); /* Use the current working directory if the file name path does not exist. */ if( filename.DirExists() ) currentPath = filename.GetPath(); else currentPath = m_mruPath; wxFileDialog dlg( this, _( "Open Drill File" ), currentPath, filename.GetFullName(), filetypes, wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE | wxFD_CHANGE_DIR ); if( dlg.ShowModal() == wxID_CANCEL ) return false; dlg.GetPaths( filenamesList ); currentPath = wxGetCwd(); m_mruPath = currentPath; } else { filenamesList.Add( aFullFileName ); currentPath = filename.GetPath(); m_mruPath = currentPath; } // Read Excellon drill files: each file is loaded on a new GerbView layer bool success = true; int layer = GetActiveLayer(); // Manage errors when loading files wxString msg; WX_STRING_REPORTER reporter( &msg ); for( unsigned ii = 0; ii < filenamesList.GetCount(); ii++ ) { filename = filenamesList[ii]; if( !filename.IsAbsolute() ) filename.SetPath( currentPath ); m_lastFileName = filename.GetFullPath(); SetActiveLayer( layer, false ); if( Read_EXCELLON_File( filename.GetFullPath() ) ) { // Update the list of recent drill files. UpdateFileHistory( filename.GetFullPath(), &m_drillFileHistory ); layer = getNextAvailableLayer( layer ); if( layer == NO_AVAILABLE_LAYERS && ii < filenamesList.GetCount()-1 ) { success = false; reporter.Report( MSG_NO_MORE_LAYER, REPORTER::RPT_ERROR ); // Report the name of not loaded files: ii += 1; while( ii < filenamesList.GetCount() ) { filename = filenamesList[ii++]; wxString txt; txt.Printf( MSG_NOT_LOADED, GetChars( filename.GetFullName() ) ); reporter.Report( txt, REPORTER::RPT_ERROR ); } break; } SetActiveLayer( layer, false ); } } if( !success ) { HTML_MESSAGE_BOX mbox( this, _( "Errors" ) ); mbox.ListSet( msg ); mbox.ShowModal(); } Zoom_Automatique( false ); // Synchronize layers tools with actual active layer: ReFillLayerWidget(); SetActiveLayer( GetActiveLayer() ); m_LayersManager->UpdateLayerIcons(); syncLayerBox(); return success; }
bool ConvolutionFilterShell::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList) { if (pInArgList == NULL || pOutArgList == NULL) { return false; } if (!extractInputArgs(pInArgList)) { return false; } if (!populateKernel() || mInput.mKernel.Nrows() % 2 == 0 || mInput.mKernel.Ncols() % 2 == 0) { mProgress.report("Invalid kernel.", 0, ERRORS, true); return false; } BitMaskIterator iterChecker((mpAoi == NULL) ? NULL : mpAoi->getSelectedPoints(), 0, 0, mInput.mpDescriptor->getColumnCount() - 1, mInput.mpDescriptor->getRowCount() - 1); EncodingType resultType = mInput.mForceFloat ? EncodingType(FLT8BYTES) : mInput.mpDescriptor->getDataType(); if (resultType == INT4SCOMPLEX) { resultType = INT4SBYTES; } else if (resultType == FLT8COMPLEX) { resultType = FLT8BYTES; } if (!isBatch()) { RasterElement* pResult = static_cast<RasterElement*>( Service<ModelServices>()->getElement(mResultName, TypeConverter::toString<RasterElement>(), NULL)); if (pResult != NULL) { if (QMessageBox::question(Service<DesktopServices>()->getMainWidget(), "Result data set exists", "The result data set already exists. Would you like to replace it?", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::No) { return false; } Service<ModelServices>()->destroyElement(pResult); } } mProgress.report("Begin convolution matrix execution.", 0, NORMAL); ModelResource<RasterElement> pResult(RasterUtilities::createRasterElement( mResultName, iterChecker.getNumSelectedRows(), iterChecker.getNumSelectedColumns(), mInput.mBands.size(), resultType, mInput.mpDescriptor->getInterleaveFormat(), mInput.mpDescriptor->getProcessingLocation() == IN_MEMORY)); pResult->copyClassification(mInput.mpRaster); pResult->getMetadata()->merge(mInput.mpDescriptor->getMetadata()); //copy original metadata //chip metadata by bands vector<DimensionDescriptor> orgBands = mInput.mpDescriptor->getBands(); vector<DimensionDescriptor> newBands; newBands.reserve(mInput.mBands.size()); for (unsigned int index = 0; index < mInput.mBands.size(); ++index) { unsigned int selectedBand = mInput.mBands[index]; if (selectedBand < orgBands.size()) { newBands.push_back(orgBands[selectedBand]); } } RasterUtilities::chipMetadata(pResult->getMetadata(), mInput.mpDescriptor->getRows(), mInput.mpDescriptor->getColumns(), newBands); mInput.mpResult = pResult.get(); if (mInput.mpResult == NULL) { mProgress.report("Unable to create result data set.", 0, ERRORS, true); return false; } mInput.mpAbortFlag = &mAborted; mInput.mpIterCheck = &iterChecker; ConvolutionFilterThreadOutput outputData; mta::ProgressObjectReporter reporter("Convolving", mProgress.getCurrentProgress()); mta::MultiThreadedAlgorithm<ConvolutionFilterThreadInput, ConvolutionFilterThreadOutput, ConvolutionFilterThread> alg(mta::getNumRequiredThreads(iterChecker.getNumSelectedRows()), mInput, outputData, &reporter); switch(alg.run()) { case mta::SUCCESS: if (!isAborted()) { mProgress.report("Convolution filter complete.", 100, NORMAL); SpatialDataView* pView = displayResult(); if (Service<ApplicationServices>()->isInteractive() && pView == NULL) { return false; } pOutArgList->setPlugInArgValue("View", pView); pResult.release(); mProgress.upALevel(); return true; } // fall through case mta::ABORT: mProgress.report("Convolution filter aborted.", 0, ABORT, true); return false; case mta::FAILURE: mProgress.report("Convolution filter failed.", 0, ERRORS, true); return false; default: VERIFY(false); // can't happen } }
void BDPTIntegrator::Render(const Scene &scene) { std::unique_ptr<LightDistribution> lightDistribution = CreateLightSampleDistribution(lightSampleStrategy, scene); // Compute a reverse mapping from light pointers to offsets into the // scene lights vector (and, equivalently, offsets into // lightDistr). Added after book text was finalized; this is critical // to reasonable performance with 100s+ of light sources. std::unordered_map<const Light *, size_t> lightToIndex; for (size_t i = 0; i < scene.lights.size(); ++i) lightToIndex[scene.lights[i].get()] = i; // Partition the image into tiles Film *film = camera->film; const Bounds2i sampleBounds = film->GetSampleBounds(); const Vector2i sampleExtent = sampleBounds.Diagonal(); const int tileSize = 16; const int nXTiles = (sampleExtent.x + tileSize - 1) / tileSize; const int nYTiles = (sampleExtent.y + tileSize - 1) / tileSize; ProgressReporter reporter(nXTiles * nYTiles, "Rendering"); // Allocate buffers for debug visualization const int bufferCount = (1 + maxDepth) * (6 + maxDepth) / 2; std::vector<std::unique_ptr<Film>> weightFilms(bufferCount); if (visualizeStrategies || visualizeWeights) { for (int depth = 0; depth <= maxDepth; ++depth) { for (int s = 0; s <= depth + 2; ++s) { int t = depth + 2 - s; if (t == 0 || (s == 1 && t == 1)) continue; std::string filename = StringPrintf("bdpt_d%02i_s%02i_t%02i.exr", depth, s, t); weightFilms[BufferIndex(s, t)] = std::unique_ptr<Film>(new Film( film->fullResolution, Bounds2f(Point2f(0, 0), Point2f(1, 1)), std::unique_ptr<Filter>(CreateBoxFilter(ParamSet())), film->diagonal * 1000, filename, 1.f)); } } } // Render and write the output image to disk if (scene.lights.size() > 0) { ParallelFor2D([&](const Point2i tile) { // Render a single tile using BDPT MemoryArena arena; int seed = tile.y * nXTiles + tile.x; std::unique_ptr<Sampler> tileSampler = sampler->Clone(seed); int x0 = sampleBounds.pMin.x + tile.x * tileSize; int x1 = std::min(x0 + tileSize, sampleBounds.pMax.x); int y0 = sampleBounds.pMin.y + tile.y * tileSize; int y1 = std::min(y0 + tileSize, sampleBounds.pMax.y); Bounds2i tileBounds(Point2i(x0, y0), Point2i(x1, y1)); std::unique_ptr<FilmTile> filmTile = camera->film->GetFilmTile(tileBounds); for (Point2i pPixel : tileBounds) { tileSampler->StartPixel(pPixel); if (!InsideExclusive(pPixel, pixelBounds)) continue; do { // Generate a single sample using BDPT Point2f pFilm = (Point2f)pPixel + tileSampler->Get2D(); // Trace the camera subpath Vertex *cameraVertices = arena.Alloc<Vertex>(maxDepth + 2); Vertex *lightVertices = arena.Alloc<Vertex>(maxDepth + 1); int nCamera = GenerateCameraSubpath( scene, *tileSampler, arena, maxDepth + 2, *camera, pFilm, cameraVertices); // Get a distribution for sampling the light at the // start of the light subpath. Because the light path // follows multiple bounces, basing the sampling // distribution on any of the vertices of the camera // path is unlikely to be a good strategy. We use the // PowerLightDistribution by default here, which // doesn't use the point passed to it. const Distribution1D *lightDistr = lightDistribution->Lookup(cameraVertices[0].p()); // Now trace the light subpath int nLight = GenerateLightSubpath( scene, *tileSampler, arena, maxDepth + 1, cameraVertices[0].time(), *lightDistr, lightToIndex, lightVertices); // Execute all BDPT connection strategies Spectrum L(0.f); for (int t = 1; t <= nCamera; ++t) { for (int s = 0; s <= nLight; ++s) { int depth = t + s - 2; if ((s == 1 && t == 1) || depth < 0 || depth > maxDepth) continue; // Execute the $(s, t)$ connection strategy and // update _L_ Point2f pFilmNew = pFilm; Float misWeight = 0.f; Spectrum Lpath = ConnectBDPT( scene, lightVertices, cameraVertices, s, t, *lightDistr, lightToIndex, *camera, *tileSampler, &pFilmNew, &misWeight); VLOG(2) << "Connect bdpt s: " << s <<", t: " << t << ", Lpath: " << Lpath << ", misWeight: " << misWeight; if (visualizeStrategies || visualizeWeights) { Spectrum value; if (visualizeStrategies) value = misWeight == 0 ? 0 : Lpath / misWeight; if (visualizeWeights) value = Lpath; weightFilms[BufferIndex(s, t)]->AddSplat( pFilmNew, value); } if (t != 1) L += Lpath; else film->AddSplat(pFilmNew, Lpath); } } VLOG(2) << "Add film sample pFilm: " << pFilm << ", L: " << L << ", (y: " << L.y() << ")"; filmTile->AddSample(pFilm, L); arena.Reset(); } while (tileSampler->StartNextSample()); } film->MergeFilmTile(std::move(filmTile)); reporter.Update(); }, Point2i(nXTiles, nYTiles)); reporter.Done(); } film->WriteImage(1.0f / sampler->samplesPerPixel); // Write buffers for debug visualization if (visualizeStrategies || visualizeWeights) { const Float invSampleCount = 1.0f / sampler->samplesPerPixel; for (size_t i = 0; i < weightFilms.size(); ++i) if (weightFilms[i]) weightFilms[i]->WriteImage(invSampleCount); } }