EXPORT_C void dWorldSetAutoEnableDepthSF1 (dxWorld */*world*/, int autodepth) { if (autodepth > 0) GetGlobalData()->autoEnableDepth = autodepth; else GetGlobalData()->autoEnableDepth = 0; }
CMemDC::CMemDC(CDC& dc, CWnd* pWnd) : m_dc(dc), m_bMemDC(FALSE), m_hBufferedPaint(NULL), m_pOldBmp(NULL) { ASSERT_VALID(pWnd); pWnd->GetClientRect(m_rect); m_rect.right += pWnd->GetScrollPos(SB_HORZ); m_rect.bottom += pWnd->GetScrollPos(SB_VERT); HDC hdcPaint = NULL; if (!GetGlobalData()->m_bBufferedPaintInited) { BufferedPaintInit(); GetGlobalData()->m_bBufferedPaintInited = TRUE; } m_hBufferedPaint = BeginBufferedPaint(dc.GetSafeHdc(), m_rect, BPBF_TOPDOWNDIB, NULL, &hdcPaint); if (m_hBufferedPaint != NULL && hdcPaint != NULL) { m_bMemDC = TRUE; m_dcMem.Attach(hdcPaint); } }
void C_thread::CreateThread(E_PRIORITY priority){ quit_request = false; KillThread(); status = STATUS_STARTING; RThread1 *tp = new(true) RThread1; tp->owner = (C_thread_access*)this; #ifndef __SYMBIAN_3RD__ tp->gd = GetGlobalData(); #endif imp = tp; //make unique thread name Cstr_w tname; tname<<L"Thread-" <<GetTickTime(); tp->Create(TPtrC((const word*)(const wchar*)tname, tname.Length()), ThreadProcThunk, 8192, NULL, tp); TThreadPriority pr; switch(priority){ case PRIORITY_VERY_LOW: pr = EPriorityMuchLess; break; case PRIORITY_LOW: pr = EPriorityLess; break; default: assert(0); case PRIORITY_NORMAL: pr = EPriorityNormal; break; case PRIORITY_HIGH: pr = EPriorityMore; break; case PRIORITY_VERY_HIGH: //pr = EPriorityRealTime; pr = EPriorityAbsoluteHigh; break; } tp->SetPriority(pr); tp->Resume(); }
MemoryBlock::MemoryBlock(size_t size) { if(GetGlobalData().getCachingEnabled()) { /*std::cout << "MemoryBlock CTor: size = " << size << std::endl; std::cout << "cachesize = " << cache_.size() << std::endl; for (const auto& i : cache_) std::cout << i.first << "; " << *(i.second.second) << std::endl;*/ auto it = GetGlobalDataInternal().cache_.find(size); if(it != GetGlobalDataInternal().cache_.end()) { this->size = size; ownData = true; refCount = (*it).second.second; data_ = (*it).second.first; (*refCount)++; GetGlobalDataInternal().cache_.erase(it); } else { allocate(size); } } else { allocate(size); } //std::cout << "#### totalAllocatedBytes = " << totalAllocatedBytes << std::endl; }
BOOL CALLBACK ConfigureProc(HWND dlg,UINT message,WPARAM wParam,LPARAM lParam) { static ConfContext *Context; DWORD state; switch(message) { case WM_INITDIALOG : Context = (ConfContext*)((HostData*)lParam)->ProcData->Context; SetGlobalData(dlg,Context); return FALSE; break; case WM_COMMAND: switch LOWORD(wParam) { case IDOK: GetGlobalData(dlg,Context); EndDialog(dlg,IDOK); return TRUE; case IDCANCEL: EndDialog(dlg,IDCANCEL); return TRUE; break; case IDC_START_SERVER: if(HIWORD(wParam)==BN_CLICKED) { state = SendDlgItemMessage(dlg,IDC_START_SERVER,BM_GETCHECK,0,0); if(state==BST_CHECKED) { EnableWindow(GetDlgItem(dlg,IDC_EDIT_DISPLAY),FALSE); } else { EnableWindow(GetDlgItem(dlg,IDC_EDIT_DISPLAY),TRUE); } return TRUE; } } } return FALSE; }
int main() { // 获取全局数据 GetGlobalData(); getchar(); return 0; }
CMemDC::CMemDC(CDC& dc, const CRect& rect) : m_dc(dc), m_bMemDC(FALSE), m_hBufferedPaint(NULL), m_pOldBmp(NULL), m_rect(rect) { ASSERT(!m_rect.IsRectEmpty()); HDC hdcPaint = NULL; if (!GetGlobalData()->m_bBufferedPaintInited) { BufferedPaintInit(); GetGlobalData()->m_bBufferedPaintInited = TRUE; } m_hBufferedPaint = BeginBufferedPaint(dc.GetSafeHdc(), m_rect, BPBF_TOPDOWNDIB, NULL, &hdcPaint); if (m_hBufferedPaint != NULL && hdcPaint != NULL) { m_bMemDC = TRUE; m_dcMem.Attach(hdcPaint); } }
//------------------------------------------------------------------------- nsresult nsClipboard::GetNativeDataOffClipboard(nsIWidget * aWindow, UINT /*aIndex*/, UINT aFormat, void ** aData, PRUint32 * aLen) { HGLOBAL hglb; nsresult result = NS_ERROR_FAILURE; HWND nativeWin = nullptr;//(HWND)aWindow->GetNativeData(NS_NATIVE_WINDOW); if (::OpenClipboard(nativeWin)) { hglb = ::GetClipboardData(aFormat); result = GetGlobalData(hglb, aData, aLen); ::CloseClipboard(); } return result; }
bool TaskReceive( net_task &task,IAgent* agent, DWORD sessionId, IGenericStream* inStream ) { bool ret = false; __try{ ret = GetGlobalData( agent, sessionId ) && task.receive( inStream ) ; } __except( EXCEPTION_EXECUTE_HANDLER ) { Msg( "accept!" ); return ret; } FPU::m64r(); return ret; }
BOOL CTTMultiPaneFrameWnd::CreateEx(DWORD dwStyleEx, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, CCreateContext* pContext) { dwStyle |= WS_POPUP; if (pParentWnd != NULL && pParentWnd->GetExStyle() & WS_EX_LAYOUTRTL) { dwStyleEx |= WS_EX_LAYOUTRTL; } m_hParentWnd = pParentWnd != NULL ? pParentWnd->m_hWnd : NULL; if (!CWnd::CreateEx(dwStyleEx, GetGlobalData()->RegisterWindowClass(_T("Afx:MiniFrame")), lpszWindowName, dwStyle, rect, pParentWnd, 0, pContext)) { return FALSE; } if (pParentWnd != NULL) { if (DYNAMIC_DOWNCAST(CFrameWnd, pParentWnd) == NULL) { TRACE0("Minframe parent must be derived from CFrameWnd. Creation failed.\n"); return FALSE; } // register with dock manager CDockingManager* pDockManager = m_pDockManager != NULL ? m_pDockManager : afxGlobalUtils.GetDockingManager(pParentWnd); ASSERT_VALID(pDockManager); if (pDockManager == NULL) { TRACE0("Minframe parent must be connected to dock manager. Creation failed.\n"); return FALSE; } pDockManager->AddMiniFrame(this); } m_dragFrameImpl.Init(this); return TRUE; }
//------------------------------------------------------------------------- // If aFormat is CF_DIBV5, aMIMEImageFormat must be a type for which we have // an image encoder (e.g. image/png). // For other values of aFormat, it is OK to pass null for aMIMEImageFormat. nsresult nsClipboard::GetNativeDataOffClipboard(IDataObject * aDataObject, UINT aIndex, UINT aFormat, const char * aMIMEImageFormat, void ** aData, PRUint32 * aLen) { nsresult result = NS_ERROR_FAILURE; *aData = nullptr; *aLen = 0; if ( !aDataObject ) return result; UINT format = aFormat; HRESULT hres = S_FALSE; // XXX at the moment we only support global memory transfers // It is here where we will add support for native images // and IStream FORMATETC fe; STGMEDIUM stm; hres = FillSTGMedium(aDataObject, format, &fe, &stm, TYMED_HGLOBAL); // Currently this is only handling TYMED_HGLOBAL data // For Text, Dibs, Files, and generic data (like HTML) if (S_OK == hres) { static CLIPFORMAT fileDescriptorFlavorA = ::RegisterClipboardFormat( CFSTR_FILEDESCRIPTORA ); static CLIPFORMAT fileDescriptorFlavorW = ::RegisterClipboardFormat( CFSTR_FILEDESCRIPTORW ); static CLIPFORMAT fileFlavor = ::RegisterClipboardFormat( CFSTR_FILECONTENTS ); static CLIPFORMAT preferredDropEffect = ::RegisterClipboardFormat(CFSTR_PREFERREDDROPEFFECT); switch (stm.tymed) { case TYMED_HGLOBAL: { switch (fe.cfFormat) { case CF_TEXT: { // Get the data out of the global data handle. The size we return // should not include the null because the other platforms don't // use nulls, so just return the length we get back from strlen(), // since we know CF_TEXT is null terminated. Recall that GetGlobalData() // returns the size of the allocated buffer, not the size of the data // (on 98, these are not the same) so we can't use that. PRUint32 allocLen = 0; if ( NS_SUCCEEDED(GetGlobalData(stm.hGlobal, aData, &allocLen)) ) { *aLen = strlen ( reinterpret_cast<char*>(*aData) ); result = NS_OK; } } break; case CF_UNICODETEXT: { // Get the data out of the global data handle. The size we return // should not include the null because the other platforms don't // use nulls, so just return the length we get back from strlen(), // since we know CF_UNICODETEXT is null terminated. Recall that GetGlobalData() // returns the size of the allocated buffer, not the size of the data // (on 98, these are not the same) so we can't use that. PRUint32 allocLen = 0; if ( NS_SUCCEEDED(GetGlobalData(stm.hGlobal, aData, &allocLen)) ) { *aLen = NS_strlen(reinterpret_cast<PRUnichar*>(*aData)) * 2; result = NS_OK; } } break; case CF_DIBV5: if (aMIMEImageFormat) { PRUint32 allocLen = 0; unsigned char * clipboardData; if (NS_SUCCEEDED(GetGlobalData(stm.hGlobal, (void **)&clipboardData, &allocLen))) { nsImageFromClipboard converter; nsIInputStream * inputStream; converter.GetEncodedImageStream(clipboardData, aMIMEImageFormat, &inputStream); // addrefs for us, don't release if ( inputStream ) { *aData = inputStream; *aLen = sizeof(nsIInputStream*); result = NS_OK; } } } break; case CF_HDROP : { // in the case of a file drop, multiple files are stashed within a // single data object. In order to match mozilla's D&D apis, we // just pull out the file at the requested index, pretending as // if there really are multiple drag items. HDROP dropFiles = (HDROP) GlobalLock(stm.hGlobal); UINT numFiles = ::DragQueryFileW(dropFiles, 0xFFFFFFFF, NULL, 0); NS_ASSERTION ( numFiles > 0, "File drop flavor, but no files...hmmmm" ); NS_ASSERTION ( aIndex < numFiles, "Asked for a file index out of range of list" ); if (numFiles > 0) { UINT fileNameLen = ::DragQueryFileW(dropFiles, aIndex, nullptr, 0); PRUnichar* buffer = reinterpret_cast<PRUnichar*>(nsMemory::Alloc((fileNameLen + 1) * sizeof(PRUnichar))); if ( buffer ) { ::DragQueryFileW(dropFiles, aIndex, buffer, fileNameLen + 1); *aData = buffer; *aLen = fileNameLen * sizeof(PRUnichar); result = NS_OK; } else result = NS_ERROR_OUT_OF_MEMORY; } GlobalUnlock (stm.hGlobal) ; } break; default: { if ( fe.cfFormat == fileDescriptorFlavorA || fe.cfFormat == fileDescriptorFlavorW || fe.cfFormat == fileFlavor ) { NS_WARNING ( "Mozilla doesn't yet understand how to read this type of file flavor" ); } else { // Get the data out of the global data handle. The size we return // should not include the null because the other platforms don't // use nulls, so just return the length we get back from strlen(), // since we know CF_UNICODETEXT is null terminated. Recall that GetGlobalData() // returns the size of the allocated buffer, not the size of the data // (on 98, these are not the same) so we can't use that. // // NOTE: we are assuming that anything that falls into this default case // is unicode. As we start to get more kinds of binary data, this // may become an incorrect assumption. Stay tuned. PRUint32 allocLen = 0; if ( NS_SUCCEEDED(GetGlobalData(stm.hGlobal, aData, &allocLen)) ) { if ( fe.cfFormat == CF_HTML ) { // CF_HTML is actually UTF8, not unicode, so disregard the assumption // above. We have to check the header for the actual length, and we'll // do that in FindPlatformHTML(). For now, return the allocLen. This // case is mostly to ensure we don't try to call strlen on the buffer. *aLen = allocLen; } else if (fe.cfFormat == preferredDropEffect) { // As per the MSDN doc entitled: "Shell Clipboard Formats" // CFSTR_PREFERREDDROPEFFECT should return a DWORD // Reference: http://msdn.microsoft.com/en-us/library/bb776902(v=vs.85).aspx NS_ASSERTION(allocLen == sizeof(DWORD), "CFSTR_PREFERREDDROPEFFECT should return a DWORD"); *aLen = allocLen; } else { *aLen = NS_strlen(reinterpret_cast<PRUnichar*>(*aData)) * sizeof(PRUnichar); } result = NS_OK; } } } break; } // switch } break; case TYMED_GDI: { #ifdef DEBUG PR_LOG(gWin32ClipboardLog, PR_LOG_ALWAYS, ("*********************** TYMED_GDI\n")); #endif } break; default: break; } //switch ReleaseStgMedium(&stm); } return result; }
PFN_EXECUTE_CMD GetKrnlnFuncAddr(FuncIndex index) { return (PFN_EXECUTE_CMD) GetGlobalData((int)index); }
static void processIslandsFast (dxWorld * world, dReal stepsize, int maxiterations) { dxBody *b, *bb, **body; dxJoint *j, **joint; // nothing to do if no bodies if (world->nb <= 0) return; dInternalHandleAutoDisabling (world,stepsize); // make arrays for body and joint lists (for a single island) to go into body = (dxBody **) ALLOCA (world->nb * sizeof (dxBody *)); joint = (dxJoint **) ALLOCA (world->nj * sizeof (dxJoint *)); int bcount = 0; // number of bodies in `body' int jcount = 0; // number of joints in `joint' int tbcount = 0; int tjcount = 0; // set all body/joint tags to 0 for (b = world->firstbody; b; b = (dxBody *) b->next) b->tag = 0; for (j = world->firstjoint; j; j = (dxJoint *) j->next) j->tag = 0; // allocate a stack of unvisited bodies in the island. the maximum size of // the stack can be the lesser of the number of bodies or joints, because // new bodies are only ever added to the stack by going through untagged // joints. all the bodies in the stack must be tagged! int stackalloc = (world->nj < world->nb) ? world->nj : world->nb; dxBody **stack = (dxBody **) ALLOCA (stackalloc * sizeof (dxBody *)); int *autostack = (int *) ALLOCA (stackalloc * sizeof (int)); for (bb = world->firstbody; bb; bb = (dxBody *) bb->next) { // get bb = the next enabled, untagged body, and tag it if (bb->tag || (bb->flags & dxBodyDisabled)) continue; bb->tag = 1; // tag all bodies and joints starting from bb. int stacksize = 0; int firsttime = 1; int autoDepth = GetGlobalData()->autoEnableDepth; b = bb; body[0] = bb; bcount = 1; jcount = 0; while (stacksize > 0 || firsttime) { if (!firsttime) { b = stack[--stacksize]; // pop body off stack autoDepth = autostack[stacksize]; body[bcount++] = b; // put body on body list } else { firsttime = 0; } // traverse and tag all body's joints, add untagged connected bodies // to stack for (dxJointNode * n = b->firstjoint; n; n = n->next) { if (!n->joint->tag) { int thisDepth = GetGlobalData()->autoEnableDepth; n->joint->tag = 1; joint[jcount++] = n->joint; if (n->body && !n->body->tag) { if (n->body->flags & dxBodyDisabled) thisDepth = autoDepth - 1; if (thisDepth < 0) continue; n->body->flags &= ~dxBodyDisabled; n->body->tag = 1; autostack[stacksize] = thisDepth; stack[stacksize++] = n->body; } } } } // now do something with body and joint lists dInternalStepIslandFast (world, body, bcount, joint, jcount, stepsize, maxiterations); // what we've just done may have altered the body/joint tag values. // we must make sure that these tags are nonzero. // also make sure all bodies are in the enabled state. int i; for (i = 0; i < bcount; i++) { body[i]->tag = 1; body[i]->flags &= ~dxBodyDisabled; } for (i = 0; i < jcount; i++) joint[i]->tag = 1; tbcount += bcount; tjcount += jcount; } }
EXPORT_C int dWorldGetAutoEnableDepthSF1 (dxWorld */*world*/) { return GetGlobalData()->autoEnableDepth; }
static GlobalData& GetGlobalDataInternal() { return (GlobalData&) GetGlobalData(); }
void CMenuButton::OnSysColorChange() { __super::OnSysColorChange(); GetGlobalData()->UpdateSysColors(); }