//----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- std::string CVProjectUtil::ConstructPath( const std::string &srcDst, const std::string &type, const std::string &file, const std::string &ext, bool enforceExtension ) const { try { // See if an extension was supplied in file, use it if supplied std::string newFile( File( file ) ); std::string newExt( ext ); boost::replace_all( newFile, "\\", "/" ); boost::smatch match; if ( boost::regex_match( newFile, match, boost::regex( "([^\\.]+)\\.([^/\\.]+)" ) ) ) { newFile.assign( match[ 1 ].first, match[ 1 ].second ); if ( !enforceExtension || newExt.empty() ) { newExt.assign( match[ 2 ].first, match[ 2 ].second ); } } if ( newExt.empty() ) { newExt = "unk"; } if ( m_game.size() ) { return FullPath( std::string( m_prefix + "/" + srcDst + ( m_game.size() ? std::string( "/" ) + m_game : "" ) + "/" + type + ( ( type == m_subType ) ? ( "" ) : ( "/" + m_subType ) ) + ( m_path.size() ? std::string( "/" ) + m_path : "" ) + "/" + newFile + "." + newExt ) ); } return FullPath( std::string( m_prefix + ( m_game.size() ? std::string( "/" ) + m_game : "" ) + ( m_path.size() ? std::string( "/" ) + m_path : "" ) + "/" + newFile + "." + newExt ) ); } catch ( ... ) { } return std::string(); }
void CommonUniformElimPass::GenACLoadRepl(const ir::Instruction* ptrInst, std::vector<std::unique_ptr<ir::Instruction>>* newInsts, uint32_t* resultId) { // Build and append Load const uint32_t ldResultId = TakeNextId(); const uint32_t varId = ptrInst->GetSingleWordInOperand(kAccessChainPtrIdInIdx); const ir::Instruction* varInst = def_use_mgr_->GetDef(varId); assert(varInst->opcode() == SpvOpVariable); const uint32_t varPteTypeId = GetPointeeTypeId(varInst); std::vector<ir::Operand> load_in_operands; load_in_operands.push_back( ir::Operand(spv_operand_type_t::SPV_OPERAND_TYPE_ID, std::initializer_list<uint32_t>{varId})); std::unique_ptr<ir::Instruction> newLoad(new ir::Instruction(SpvOpLoad, varPteTypeId, ldResultId, load_in_operands)); def_use_mgr_->AnalyzeInstDefUse(&*newLoad); newInsts->emplace_back(std::move(newLoad)); // Build and append Extract const uint32_t extResultId = TakeNextId(); const uint32_t ptrPteTypeId = GetPointeeTypeId(ptrInst); std::vector<ir::Operand> ext_in_opnds; ext_in_opnds.push_back( ir::Operand(spv_operand_type_t::SPV_OPERAND_TYPE_ID, std::initializer_list<uint32_t>{ldResultId})); uint32_t iidIdx = 0; ptrInst->ForEachInId([&iidIdx, &ext_in_opnds, this](const uint32_t *iid) { if (iidIdx > 0) { const ir::Instruction* cInst = def_use_mgr_->GetDef(*iid); uint32_t val = cInst->GetSingleWordInOperand(kConstantValueInIdx); ext_in_opnds.push_back( ir::Operand(spv_operand_type_t::SPV_OPERAND_TYPE_LITERAL_INTEGER, std::initializer_list<uint32_t>{val})); } ++iidIdx; }); std::unique_ptr<ir::Instruction> newExt(new ir::Instruction( SpvOpCompositeExtract, ptrPteTypeId, extResultId, ext_in_opnds)); def_use_mgr_->AnalyzeInstDefUse(&*newExt); newInsts->emplace_back(std::move(newExt)); *resultId = extResultId; }
BOOL CotMapCtrl::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) { if(!m_pGeomap) return FALSE; double dblRatio = 1; long lSceenWidth,lSceenHeight; GEOMETRY::geom::Coordinate point; CRect rect; GetClientRect(&rect); lSceenWidth = rect.Width(); lSceenHeight = rect.Height(); Display::IDisplayPtr pDispaly = m_pGeomap->GetDisplay(); if (!m_bTimer) { m_srcEnvelop = m_pGeomap->GetViewEnvelope(); SetTimer(1,300,NULL); m_dblScale = pDispaly->GetDisplayTransformation().GetScale(); m_srcScale = m_dblScale; m_bTimer = true; } m_bMouseWheel = true; HDC hMemDC = ::CreateCompatibleDC(m_hClientDC); HBITMAP hOldBitmap,hBitmap = ::CreateCompatibleBitmap(m_hClientDC,m_lSizeX,m_lSizeY); hOldBitmap = (HBITMAP)::SelectObject(hMemDC,hBitmap); //绘制背景 HBRUSH hbrush = ::CreateSolidBrush( RGB(255,255,255)); ::FillRect(hMemDC , &rect , hbrush ); ::DeleteObject( hbrush ); double xmin,xmax,ymin,ymax; if (zDelta > 0) //放大 { dblRatio = 0.8; m_dblScale *= dblRatio; m_pGeomap->GetViewEnvelope().centre(point); xmin = point.x - lSceenWidth/2.0*m_dblScale; xmax = point.x + lSceenWidth/2.0*m_dblScale; ymin = point.y - lSceenHeight/2.0*m_dblScale; ymax = point.y + lSceenHeight/2.0*m_dblScale; GEOMETRY::geom::Envelope newExt(xmin,xmax,ymin,ymax); //改变地图的显示范围 m_pGeomap->GetDisplay()->GetDisplayTransformation().FitViewBound(newExt); CRect srcRect,destRect; CalSrcRect(newExt,srcRect); //如果目标范围比原始范围小,则目标矩形是整个View的客户区 if(newExt.getMaxX()<=m_srcEnvelop.getMaxX() && newExt.getMinX()>=m_srcEnvelop.getMinX() && newExt.getMaxY()<=m_srcEnvelop.getMaxY() && newExt.getMinY()>=m_srcEnvelop.getMinY()) { destRect = rect; } else { GEOMETRY::geom::Envelope srcExtent =m_srcEnvelop; CalDestRect(srcExtent,newExt,destRect); } ::SetStretchBltMode(hMemDC,MAXSTRETCHBLTMODE); ::StretchBlt(hMemDC,destRect.left,destRect.top,destRect.Width(),destRect.Height(),(HDC)pDispaly->GetDrawDC()->GetSafeHdc(),srcRect.left,srcRect.top,srcRect.Width(),srcRect.Height(),SRCCOPY); //::BitBlt(m_hMemDC,0,0,m_lSizeX,m_lSizeY,hMemDC,0,0,SRCCOPY); ::BitBlt(m_hClientDC,0,0,m_lSizeX,m_lSizeY,hMemDC,0,0,SRCCOPY); } else if (zDelta < 0) //缩小 { dblRatio = 1.2; m_dblScale *= dblRatio; m_pGeomap->GetViewEnvelope().centre(point); xmin = point.x - lSceenWidth/2.0*m_dblScale; xmax = point.x + lSceenWidth/2.0*m_dblScale; ymin = point.y - lSceenHeight/2.0*m_dblScale; ymax = point.y + lSceenHeight/2.0*m_dblScale; GEOMETRY::geom::Envelope newExt(xmin,xmax,ymin,ymax); //改变地图的显示范围 m_pGeomap->GetDisplay()->GetDisplayTransformation().FitViewBound(newExt); CRect srcRect,destRect; CalSrcRect(m_pGeomap->GetViewEnvelope(),srcRect); //如果目标范围比原始范围小,则目标矩形是整个View的客户区 if(newExt.getMaxX()<=m_srcEnvelop.getMaxX() && newExt.getMinX()>=m_srcEnvelop.getMinX() && newExt.getMaxY()<=m_srcEnvelop.getMaxY() &&newExt.getMinY()>=m_srcEnvelop.getMinY()) { destRect = rect; } else { GEOMETRY::geom::Envelope srcExtent =m_srcEnvelop; CalDestRect(srcExtent,newExt,destRect); } ::SetStretchBltMode(hMemDC,MAXSTRETCHBLTMODE); ::StretchBlt(hMemDC,destRect.left,destRect.top,destRect.Width(),destRect.Height(),(HDC)pDispaly->GetDrawDC()->GetSafeHdc(),srcRect.left,srcRect.top,srcRect.Width(),srcRect.Height(),SRCCOPY); ::BitBlt(m_hClientDC,0,0,m_lSizeX,m_lSizeY,hMemDC,0,0,SRCCOPY); } ::SelectObject(hMemDC,hOldBitmap); ::DeleteObject(hBitmap); ::DeleteDC(hMemDC); return COleControl::OnMouseWheel(nFlags, zDelta, pt); }