//--------------------------------------------------------- void CVIEW_Map_Control::On_Key_Down(wxKeyEvent &event) { if( m_pMap->Find_Layer(Get_Active_Layer()) && Get_Active_Layer()->Edit_On_Key_Down(event.GetKeyCode()) ) { return; } switch( event.GetKeyCode() ) { default: event.Skip(); break; case WXK_PAGEUP: _Zoom(m_pMap->Get_Extent().Get_Center(), true); break; case WXK_PAGEDOWN: _Zoom(m_pMap->Get_Extent().Get_Center(), false); break; case WXK_LEFT: _Move(wxPoint(-10, 0)); break; case WXK_RIGHT: _Move(wxPoint( 10, 0)); break; case WXK_UP: _Move(wxPoint( 0, -10)); break; case WXK_DOWN: _Move(wxPoint( 0, 10)); break; case WXK_F2: m_pMap->SaveAs_Image(); break; case 'C': if( event.GetModifiers() == wxMOD_CONTROL ) { m_pMap->SaveAs_Image_Clipboard(false); } else if( event.GetModifiers() == wxMOD_ALT ) { m_pMap->SaveAs_Image_Clipboard(GetClientSize().x, GetClientSize().y, -1); } break; case 'L': if( event.GetModifiers() == wxMOD_CONTROL ) { m_pMap->SaveAs_Image_Clipboard(true); } } }
void SymbolTable::EvalFunctionReferenceClosure() { for (auto & func : Functions) { List<String> funcList; EnumerableHashSet<String> funcSet; for (auto & ref : func.Value->ReferencedFunctions) { funcList.Add(ref); funcSet.Add(ref); } for (int i = 0; i < funcList.Count(); i++) { RefPtr<FunctionSymbol> funcSym; if (Functions.TryGetValue(funcList[i], funcSym)) { for (auto rfunc : funcSym->ReferencedFunctions) { if (funcSet.Add(rfunc)) funcList.Add(rfunc); } } } func.Value->ReferencedFunctions = _Move(funcSet); } }
List<String>& PipelineSymbol::GetWorldTopologyOrder() { if (WorldTopologyOrder.Count() != 0) return WorldTopologyOrder; List<String> rs; HashSet<String> rsSet; bool changed = true; while (changed) { changed = false; for (auto & w : WorldDependency) { if (!rsSet.Contains(w.Key)) { bool canAdd = true; for (auto & dw : w.Value) if (!rsSet.Contains(dw)) { canAdd = false; break; } if (canAdd) { rsSet.Add(w.Key); rs.Add(w.Key); changed = true; } } } } WorldTopologyOrder = _Move(rs); return WorldTopologyOrder; }
//--------------------------------------------------------- void CVIEW_Map_Control::On_Mouse_MUp(wxMouseEvent &event) { if( HasCapture() ) { ReleaseMouse(); } _Draw_Inverse(m_Mouse_Down, event.GetPosition()); m_Drag_Mode = TOOL_INTERACTIVE_DRAG_NONE; switch( m_Mode ) { //----------------------------------------------------- case MAP_MODE_SELECT: break; //----------------------------------------------------- case MAP_MODE_DISTANCE: break; //----------------------------------------------------- case MAP_MODE_ZOOM: break; //----------------------------------------------------- case MAP_MODE_PAN: break; //----------------------------------------------------- case MAP_MODE_PAN_DOWN: Set_Mode(MAP_MODE_ZOOM); _Move(m_Mouse_Down, event.GetPosition()); break; } }
//--------------------------------------------------------- void CVIEW_Map_Control::On_Mouse_LUp(wxMouseEvent &event) { if( HasCapture() ) { ReleaseMouse(); } //----------------------------------------------------- if( m_Mode != MAP_MODE_SELECT && (event.ControlDown() || event.AltDown()) ) // clipboard copy ? { return; } //----------------------------------------------------- _Draw_Inverse(m_Mouse_Down, event.GetPosition()); m_Drag_Mode = TOOL_INTERACTIVE_DRAG_NONE; switch( m_Mode ) { //----------------------------------------------------- case MAP_MODE_SELECT: if( g_pTool ) { g_pTool->Execute(_Get_Client2World(event.GetPosition()), TOOL_INTERACTIVE_LUP, GET_KEYS(event)); } else if( m_pMap->Find_Layer(Get_Active_Layer()) ) { Get_Active_Layer()->Edit_On_Mouse_Up(_Get_Client2World(event.GetPosition()), _Get_Client2World(1.0), GET_KEYS(event)|TOOL_INTERACTIVE_KEY_LEFT); } break; //----------------------------------------------------- case MAP_MODE_DISTANCE: _Distance_Add(event.GetPosition()); break; //----------------------------------------------------- case MAP_MODE_ZOOM: _Zoom(m_Mouse_Down, event.GetPosition()); break; //----------------------------------------------------- case MAP_MODE_PAN: break; //----------------------------------------------------- case MAP_MODE_PAN_DOWN: Set_Mode(MAP_MODE_PAN); _Move(m_Mouse_Down, event.GetPosition()); break; } }
bool SdfNamespaceEdit_Namespace::Apply( const SdfNamespaceEdit& edit, std::string* whyNot) { // If newPath is empty we want to remove the object. if (edit.newPath.IsEmpty()) { return _Remove(edit.currentPath, whyNot); } else if (edit.currentPath != edit.newPath) { return _Move(edit.currentPath, edit.newPath, whyNot); } else { // Reorder -- Ignore the reorder in our virtual namespace. return true; } }
void statusbar_set_statustext(const char *text, int text_time) { video_canvas_t *canvas; for (canvas = canvaslist; canvas; canvas = canvas->next) { struct Window *window; struct TextExtent te; int x, width, height, max_chars; int basex, basey; if (!canvas->os->has_statusbar || canvas->waiting_for_resize) continue; window = canvas->os->window; width = window->Width - window->BorderLeft - window->BorderRight; height = window->Height - window->BorderTop - window->BorderBottom - statusbar_get_status_height(); basex = window->BorderLeft; basey = window->BorderTop; if (canvas->os->font) { SetFont(window->RPort, canvas->os->font); } /* else we use system default font */ x = width - (canvas->os->disk_width * enabled_drives) - (tape_enabled ? canvas->os->tape_width : 0); SetAPen(window->RPort, 0); SetBPen(window->RPort, 0); _RectFill(window->RPort, 0, height, x - 1, height + statusbar_get_status_height() - 1); max_chars = TextFit(window->RPort, text, strlen(text), &te, NULL, 1, x - (7 * 2), 20); SetAPen(window->RPort, canvas->os->pens[b_black]); _Move(window->RPort, 7, height + 13); Text(window->RPort, text, max_chars /* strlen(text) */); } statusbar_statustext_time=text_time; }
void ShaderSymbol::SortComponents(List<ShaderComponentSymbol*>& comps) { comps.Sort([&](ShaderComponentSymbol*c0, ShaderComponentSymbol*c1) { return c0->Implementations.First()->SyntaxNode->Position < c1->Implementations.First()->SyntaxNode->Position; }); HashSet<ShaderComponentSymbol*> allSymbols, addedSymbols; for (auto & comp : comps) allSymbols.Add(comp); List<ShaderComponentSymbol*> sorted; bool changed = true; while (changed) { changed = false; for (auto & comp : comps) { if (!addedSymbols.Contains(comp)) { bool isFirst = true; for (auto & impl : comp->Implementations) for (auto & dep : impl->DependentComponents) if (allSymbols.Contains(dep) && !addedSymbols.Contains(dep)) { isFirst = false; goto loopEnd; } loopEnd:; if (isFirst) { addedSymbols.Add(comp); sorted.Add(comp); changed = true; } } } } comps = _Move(sorted); }
//--------------------------------------------------------- bool CVIEW_Map_Control::_Move(const wxPoint &Move) { wxPoint A(Move), B(0, 0); return( _Move(A, B) ); }
void KariudoKen::Move() { Animate(); _Move(); }
int ChoiceForm::AutotuneHelper(HashSet<String> & selectedChoices, EnumerableDictionary<String, Spire::Compiler::ShaderChoiceValue>& currentChoices, float timeBudget, bool countOnly) { auto choices = choiceControl->GetChoices(currentShaderName, currentChoices); List<Spire::Compiler::ShaderChoice> filteredChoices; for (auto & choice : choices) if (!currentChoices.ContainsKey(choice.ChoiceName)) filteredChoices.Add(choice); choices = _Move(filteredChoices); // find first non-trivial choice Spire::Compiler::ShaderChoice * currentChoice = nullptr; for (auto & choice : choices) { if (choice.Options.Count() > 1 && selectedChoices.Contains(choice.ChoiceName)) { currentChoice = &choice; break; } } if (currentChoice) { int count = 0; for (auto & opt : currentChoice->Options) { EnumerableDictionary<String, Spire::Compiler::ShaderChoiceValue> newChoices = currentChoices; newChoices[currentChoice->ChoiceName] = opt; count += AutotuneHelper(selectedChoices, newChoices, timeBudget, countOnly); } return count; } else { if (!countOnly) { printf("Testing shader variant..."); // compile and evaluate auto schedule = GenerateSchedule(currentChoices, EnumerableDictionary<String, EnumerableDictionary<String, String>>()); choiceControl->RecompileShader(currentShaderName, schedule); // render 1000 frames and measure time float minTime = 1e30f; for (int f = 0; f < 20; f++) { glFinish(); auto timeP = CoreLib::Diagnostics::PerformanceCounter::Start(); for (int i = 0; i < 10; i++) { choiceControl->RenderFrame(); } glFinish(); auto time = (float)CoreLib::Diagnostics::PerformanceCounter::ToSeconds(CoreLib::Diagnostics::PerformanceCounter::End(timeP)) * 100.0f; if (time < minTime) minTime = time; } choiceControl->UpdateWindow(); auto frameData = ReadFrameData(choiceControl->RenderFrame()); float error = MeasureError(referenceFrame, frameData); float value = 0; if (minTime < timeBudget) value = error; else value = 20.0f + minTime; if (value < currentBestValue) { currentBestValue = value; currentBestChoices = currentChoices; } autotuningLog << minTime << L"," << error<<EndLine; printf("%f ms, error: %f\n", minTime, error); } return 1; } }
bool Shape::MoveRight(const Panel* panel) { return _Move(panel, 0, 1); }
bool CVIEW_Map_Control::_Move(wxPoint ptMove) { return( _Move(ptMove, wxPoint(0, 0)) ); }
bool Shape::MoveDown(const Panel* panel) { return _Move(panel, 1, 0); }
void statusbar_refresh(int drive_number) { video_canvas_t *canvas; int i; if (drive_number == REFRESH_ALL) { enabled_drives = 0; for (i=0; i<DRIVE_NUM; i++) { if (status_enabled & (1 << i)) { status_map[enabled_drives++] = i; } } } for (canvas = canvaslist; canvas; canvas = canvas->next) { struct Window *window; char str[32]; int x, width, height; int basex, basey; if (!canvas->os->has_statusbar || canvas->waiting_for_resize) continue; window = canvas->os->window; width = window->Width - window->BorderLeft - window->BorderRight; height = window->Height - window->BorderTop - window->BorderBottom - statusbar_get_status_height(); basex = window->BorderLeft; basey = window->BorderTop; if (canvas->os->font) { SetFont(window->RPort, canvas->os->font); } /* else we use system default font */ if (drive_number == REFRESH_ALL) { x = width - (canvas->os->disk_width * enabled_drives) - (tape_enabled ? canvas->os->tape_width : 0); SetAPen(window->RPort, 0); SetBPen(window->RPort, 0); _RectFill(window->RPort, 0, height, x - 1, height + statusbar_get_status_height() - 1); } for (i=0; i<enabled_drives; i++) { int drive = status_map[i]; if ((drive_number != REFRESH_ALL) && (drive_number != drive)) continue; sprintf(str, "%2d: %2d.%01d", drive + 8, (int)status_track[drive], (int)(status_track[drive] * 10 - (int)status_track[drive] * 10)); x = width - (canvas->os->disk_width * (enabled_drives - i)); SetAPen(window->RPort, 0); SetBPen(window->RPort, 0); _RectFill(window->RPort, x, height, x + canvas->os->disk_width - 1, height + statusbar_get_status_height() - 1); SetAPen(window->RPort, canvas->os->pens[b_black]); _Move(window->RPort, x, height + 13); Text(window->RPort, str, strlen(str)); x += canvas->os->disk_width - (10 + 7); SetAPen(window->RPort, canvas->os->pens[(status_led[drive] ? (drive_active_led[drive] ? b_green : b_red) : b_black)]); _RectFill(window->RPort, x, height + 4, x + 10, height + 14); } if ((tape_enabled) && ((drive_number == REFRESH_ALL) || (drive_number == TAPE_NUM))) { int motor_color; int record_led; /* motor */ if (tape_motor) { motor_color = b_yellow; } else { motor_color = b_grey; } x = width - (canvas->os->disk_width * enabled_drives) - (tape_enabled ? canvas->os->tape_width : 0); SetAPen(window->RPort, 0); SetBPen(window->RPort, 0); _RectFill(window->RPort, x, height, x + canvas->os->tape_width - 1, height + statusbar_get_status_height() - 1); SetAPen(window->RPort, canvas->os->pens[motor_color]); _RectFill(window->RPort, x, height + 4, x + 10, height + 14); /* control */ record_led = b_black; switch (tape_control) { case DATASETTE_CONTROL_STOP: SetAPen(window->RPort, canvas->os->pens[b_black]); _RectFill(window->RPort, x + 2, height + 4 + 2, x + 10 - 2, height + 14 - 2); break; case DATASETTE_CONTROL_RECORD: record_led = b_red; case DATASETTE_CONTROL_START: SetAPen(window->RPort, canvas->os->pens[b_black]); LINE(x + 2, height + 4 + 2, x + 2, height + 14 - 2); LINE(x + 3, height + 4 + 3, x + 3, height + 14 - 3); LINE(x + 4, height + 4 + 4, x + 4, height + 14 - 4); LINE(x + 5, height + 4 + 5, x + 5, height + 14 - 5); break; case DATASETTE_CONTROL_REWIND: SetAPen(window->RPort, canvas->os->pens[b_black]); LINE(x + 5, height + 4 + 2, x + 2, height + 4 + 5); LINE(x + 2, height + 4 + 5, x + 5, height + 14 - 2); LINE(x + 5 + 3, height + 4 + 2, x + 2 + 3, height + 4 + 5); LINE(x + 2 + 3, height + 4 + 5, x + 5 + 3, height + 14 - 2); break; case DATASETTE_CONTROL_FORWARD: SetAPen(window->RPort, canvas->os->pens[b_black]); LINE(x + 2, height + 4 + 2, x + 5, height + 4 + 5); LINE(x + 5, height + 4 + 5, x + 2, height + 14 - 2); LINE(x + 2 + 3, height + 4 + 2, x + 5 + 3, height + 4 + 5); LINE(x + 5 + 3, height + 4 + 5, x + 2 + 3, height + 14 - 2); break; } SetAPen(window->RPort, canvas->os->pens[record_led]); _RectFill(window->RPort, x + 2 + 14, height + 4 + 2, x + 10 - 2 + 14, height + 14 - 2); /* counter */ sprintf(str, "%03d", tape_counter); SetAPen(window->RPort, canvas->os->pens[b_black]); _Move(window->RPort, x + 28, height + 13); Text(window->RPort, str, strlen(str)); } } }
void ShaderIR::EliminateDeadCode() { // mark entry points auto MarkUsing = [&](String compName, String userWorld) { if (auto defs = DefinitionsByComponent.TryGetValue(compName)) { if (auto def = defs->TryGetValue(userWorld)) (*def)->IsEntryPoint = true; else { for (auto & world : Shader->Pipeline->WorldDependency[userWorld]()) { if (auto def2 = defs->TryGetValue(world)) { (*def2)->IsEntryPoint = true; break; } } } } }; for (auto & impOp : Shader->Pipeline->SyntaxNode->ImportOperators) for (auto & ref : impOp->Usings) MarkUsing(ref.Content, impOp->DestWorld.Content); for (auto & w : Shader->Pipeline->SyntaxNode->Worlds) for (auto & ref : w->Usings) MarkUsing(ref.Content, w->Name.Content); for (auto & comp : Definitions) if (comp->Implementation->ExportWorlds.Contains(comp->World) || Shader->Pipeline->IsAbstractWorld(comp->World) && (comp->Implementation->SyntaxNode->LayoutAttributes.ContainsKey(L"Pinned") || Shader->Pipeline->Worlds[comp->World]().SyntaxNode->LayoutAttributes.ContainsKey(L"Pinned"))) { comp->IsEntryPoint = true; } List<ComponentDefinitionIR*> workList; HashSet<ComponentDefinitionIR*> referencedDefs; for (auto & def : Definitions) { if (def->IsEntryPoint) { if (referencedDefs.Add(def.Ptr())) workList.Add(def.Ptr()); } } for (int i = 0; i < workList.Count(); i++) { auto def = workList[i]; for (auto & dep : def->Dependency) { if (referencedDefs.Add(dep)) workList.Add(dep); } } List<RefPtr<ComponentDefinitionIR>> newDefinitions; for (auto & def : Definitions) { if (referencedDefs.Contains(def.Ptr())) { newDefinitions.Add(def); EnumerableHashSet<ComponentDefinitionIR*> newSet; for (auto & comp : def->Users) if (referencedDefs.Contains(comp)) { newSet.Add(comp); } def->Users = newSet; newSet.Clear(); for (auto & comp : def->Dependency) if (referencedDefs.Contains(comp)) { newSet.Add(comp); } def->Dependency = newSet; } } Definitions = _Move(newDefinitions); for (auto & kv : DefinitionsByComponent) { for (auto & def : kv.Value) if (!referencedDefs.Contains(def.Value)) kv.Value.Remove(def.Key); } }
bool PCL5Driver::NextBand(BBitmap* bitmap, BPoint* offset) { DBGMSG(("> nextBand\n")); try { BRect bounds = bitmap->Bounds(); RECT rc; rc.left = (int)bounds.left; rc.top = (int)bounds.top; rc.right = (int)bounds.right; rc.bottom = (int)bounds.bottom; int height = rc.bottom - rc.top + 1; int x = (int)offset->x; int y = (int)offset->y; int pageHeight = GetPageHeight(); if (y + height > pageHeight) height = pageHeight - y; rc.bottom = height - 1; DBGMSG(("height = %d\n", height)); DBGMSG(("x = %d\n", x)); DBGMSG(("y = %d\n", y)); if (get_valid_rect(bitmap, &rc)) { DBGMSG(("validate rect = %d, %d, %d, %d\n", rc.left, rc.top, rc.right, rc.bottom)); x = rc.left; y += rc.top; int width = rc.right - rc.left + 1; int widthByte = (width + 7) / 8; // byte boundary int height = rc.bottom - rc.top + 1; int in_size = widthByte; int out_size = (widthByte * 6 + 4) / 5; int delta = bitmap->BytesPerRow(); DBGMSG(("width = %d\n", width)); DBGMSG(("widthByte = %d\n", widthByte)); DBGMSG(("height = %d\n", height)); DBGMSG(("in_size = %d\n", in_size)); DBGMSG(("out_size = %d\n", out_size)); DBGMSG(("delta = %d\n", delta)); DBGMSG(("renderobj->Get_pixel_depth() = %d\n", fHalftone->GetPixelDepth())); uchar* ptr = static_cast<uchar*>(bitmap->Bits()) + rc.top * delta + (rc.left * fHalftone->GetPixelDepth()) / 8; int compressionMethod; int compressedSize; const uchar* buffer; uchar* in_buffer = new uchar[in_size]; uchar* out_buffer = new uchar[out_size]; auto_ptr<uchar> _in_buffer (in_buffer); auto_ptr<uchar> _out_buffer(out_buffer); DBGMSG(("move\n")); _Move(x, y); _StartRasterGraphics(width, height); const bool color = GetJobData()->GetColor() == JobData::kColor; const int num_planes = color ? 3 : 1; if (color) { fHalftone->SetPlanes(Halftone::kPlaneRGB1); fHalftone->SetBlackValue(Halftone::kLowValueMeansBlack); } for (int i = rc.top; i <= rc.bottom; i++) { for (int plane = 0; plane < num_planes; plane ++) { fHalftone->Dither(in_buffer, ptr, x, y, width); compressedSize = pack_bits(out_buffer, in_buffer, in_size); if (compressedSize + _BytesToEnterCompressionMethod(2) < in_size + _BytesToEnterCompressionMethod(0)) { compressionMethod = 2; // back bits buffer = out_buffer; } else { compressionMethod = 0; // uncompressed buffer = in_buffer; compressedSize = in_size; } _RasterGraphics( compressionMethod, buffer, compressedSize, plane == num_planes - 1); } ptr += delta; y++; } _EndRasterGraphics(); } else DBGMSG(("band bitmap is clean.\n")); if (y >= pageHeight) { offset->x = -1.0; offset->y = -1.0; } else offset->y += height; DBGMSG(("< nextBand\n")); return true; } catch (TransportException& err) { BAlert* alert = new BAlert("", err.What(), "OK"); alert->Go(); return false; } }
bool Shape::MoveLeft(const Panel* panel) { return _Move(panel, 0, -1); }