OpenTTD
|
Handles the repaint of some part of the screen. More...
Functions | |
void | MarkWholeScreenDirty () |
This function mark the whole screen as dirty. | |
static void | TerraformAddDirtyTile (TerraformerState *ts, TileIndex tile) |
Adds a tile to the "tile_table" in a TerraformerState. | |
static void | TerraformAddDirtyTileAround (TerraformerState *ts, TileIndex tile) |
Adds all tiles that incident with the north corner of a specific tile to the "tile_table" in a TerraformerState. | |
virtual void | Vehicle::MarkDirty () |
Marks the vehicles to be redrawn and updates cached variables. | |
static void | MarkViewportDirty (const ViewPort *vp, int left, int top, int right, int bottom) |
Marks a viewport as dirty for repaint if it displays (a part of) the area the needs to be repainted. | |
void | MarkAllViewportsDirty (int left, int top, int right, int bottom) |
Mark all viewports that display an area as dirty (in need of repaint). | |
void | MarkTileDirtyByTile (TileIndex tile, int bridge_level_offset) |
Mark a tile given by its index dirty for repaint. | |
void | MarkTileDirtyByTileOutsideMap (int x, int y) |
Mark a (virtual) tile outside the map dirty for repaint. | |
static void | SetSelectionTilesDirty () |
Marks the selected tiles as dirty. | |
static void | MarkCanalsAndRiversAroundDirty (TileIndex tile) |
Marks the tiles around a tile as dirty, if they are canals or rivers. | |
void | Station::MarkTilesDirty (bool cargo_change) const |
Marks the tiles of the station as dirty. | |
void | ViewportSign::MarkDirty (ZoomLevel maxzoom=ZOOM_LVL_MAX) const |
Mark the sign dirty in all viewports. | |
void | Window::SetDirty () const |
Mark entire window as dirty (in need of re-paint) |
Variables | |
static Rect | _invalid_rect |
The rect for repaint. |
Handles the repaint of some part of the screen.
Some places in the code are called functions which makes something "dirty". This has nothing to do with making a Tile or Window darker or less visible. This term comes from memory caching and is used to define an object must be repaint. If some data of an object (like a Tile, Window, Vehicle, whatever) are changed which are so extensive the object must be repaint its marked as "dirty". The video driver repaint this object instead of the whole screen (this is btw. also possible if needed). This is used to avoid a flickering of the screen by the video driver constantly repainting it.
This whole mechanism is controlled by an rectangle defined in _invalid_rect. This rectangle defines the area on the screen which must be repaint. If a new object needs to be repainted this rectangle is extended to 'catch' the object on the screen. At some point (which is normally uninteresting for patch writers) this rectangle is send to the video drivers method VideoDriver::MakeDirty and it is truncated back to an empty rectangle. At some later point (which is uninteresting, too) the video driver repaints all these saved rectangle instead of the whole screen and drop the rectangle informations. Then a new round begins by marking objects "dirty".
void MarkAllViewportsDirty | ( | int | left, |
int | top, | ||
int | right, | ||
int | bottom | ||
) |
Mark all viewports that display an area as dirty (in need of repaint).
left | Left edge of area to repaint. (viewport coordinates, that is wrt. ZOOM_LVL_NORMAL) |
top | Top edge of area to repaint. (viewport coordinates, that is wrt. ZOOM_LVL_NORMAL) |
right | Right edge of area to repaint. (viewport coordinates, that is wrt. ZOOM_LVL_NORMAL) |
bottom | Bottom edge of area to repaint. (viewport coordinates, that is wrt. ZOOM_LVL_NORMAL) |
Definition at line 1872 of file viewport.cpp.
References MarkViewportDirty(), Window::viewport, and ViewPort::width.
Referenced by MarkTileDirtyByTile(), MarkTileDirtyByTileOutsideMap(), and SetSelectionTilesDirty().
|
static |
Marks the tiles around a tile as dirty, if they are canals or rivers.
tile | The center of the tile where all other tiles are marked as dirty |
Definition at line 85 of file water_cmd.cpp.
References DIR_BEGIN, DIR_END, MarkTileDirtyIfCanalOrRiver(), and TileOffsByDir().
Referenced by CmdBuildCanal(), DoBuildLock(), DoFloodTile(), and RemoveLock().
void ViewportSign::MarkDirty | ( | ZoomLevel | maxzoom = ZOOM_LVL_MAX | ) | const |
Mark the sign dirty in all viewports.
maxzoom | Maximum ZoomLevel at which the text is visible. |
Definition at line 1341 of file viewport.cpp.
References ViewportSign::center, FONT_HEIGHT_NORMAL, MarkViewportDirty(), ScaleByZoom(), Window::viewport, VPSM_BOTTOM, VPSM_TOP, ViewPort::width, ViewportSign::width_normal, ViewPort::zoom, ZOOM_LVL_BEGIN, ZOOM_LVL_COUNT, and ZOOM_LVL_END.
Referenced by CmdRenameSign(), TextEffect::Reset(), and ViewportSign::UpdatePosition().
|
inlinevirtual |
Marks the vehicles to be redrawn and updates cached variables.
This method marks the area of the vehicle on the screen as dirty. It can be use to repaint the vehicle.
Reimplemented in Train, RoadVehicle, Aircraft, and Ship.
Definition at line 363 of file vehicle_base.h.
Referenced by Vehicle::BeginLoading(), CmdRefitVehicle(), CmdStartStopVehicle(), Vehicle::HandleBreakdown(), Vehicle::LeaveStation(), LoadUnloadVehicle(), RunVehicleDayProc(), and VehicleEnterDepot().
void MarkTileDirtyByTile | ( | TileIndex | tile, |
int | bridge_level_offset | ||
) |
Mark a tile given by its index dirty for repaint.
tile | The tile to mark dirty. |
bridge_level_offset | Height of bridge on tile to also mark dirty. (Height level relative to north corner.) |
Definition at line 1904 of file viewport.cpp.
References MarkAllViewportsDirty(), MAX_TILE_EXTENT_BOTTOM, MAX_TILE_EXTENT_LEFT, MAX_TILE_EXTENT_RIGHT, MAX_TILE_EXTENT_TOP, RemapCoords(), TILE_HEIGHT, TILE_SIZE, TilePixelHeight(), TileX(), and TileY().
Referenced by AddAnimatedTile(), AnimationBase< IndustryAnimationBase, IndustryTileSpec, Industry, int, GetSimpleIndustryCallback >::AnimateTile(), AnimateTile_Town(), BuildObject(), CheckTrainStayInDepot(), ClearMakeHouseTile(), ClearPathReservation(), CmdBuildCanal(), CmdBuildRailWaypoint(), CmdBuildRoad(), CmdBuildRoadDepot(), CmdBuildRoadStop(), CmdBuildShipDepot(), CmdBuildSingleRail(), CmdBuildSingleSignal(), CmdBuildTrainDepot(), CmdConvertRail(), CmdPlantTree(), CmdRemoveSingleRail(), CmdRemoveSingleSignal(), CmdTerraformLand(), DeleteAnimatedTile(), DoBuildLock(), DoClearBridge(), DoDryUp(), DoFloodTile(), DoTriggerIndustryTile(), FloodHalftile(), FreeTrainTrackReservation(), GenerateDesertArea(), GenerateRockyArea(), IncreaseAnimationStage(), MakeSingleHouseBigger(), MarkBridgeDirty(), MarkTileDirtyIfCanalOrRiver(), Station::MarkTilesDirty(), MaybeBarCrossingWithSound(), NPFMarkTile(), BuildRoadToolbarWindow::OnHotkey(), BuildRailToolbarWindow::OnHotkey(), RemoveDock(), RemoveRoad(), CYapfReserveTrack< Types >::ReserveRailStationPlatform(), SetRailStationPlatformReservation(), SetRedErrorSquare(), SetSelectionTilesDirty(), SetWaterClassDependingOnSurroundings(), TileLoopClearAlps(), TownActionBuildStatue(), TrainController(), TriggerStationRandomisation(), TryPathReserve(), TryReserveRailTrack(), UnreserveRailTrack(), UpdateLevelCrossing(), UpdateSignalsAroundSegment(), and VehicleEnterDepot().
void MarkTileDirtyByTileOutsideMap | ( | int | x, |
int | y | ||
) |
Mark a (virtual) tile outside the map dirty for repaint.
Definition at line 1920 of file viewport.cpp.
References MarkAllViewportsDirty(), MAX_TILE_EXTENT_BOTTOM, MAX_TILE_EXTENT_LEFT, MAX_TILE_EXTENT_RIGHT, RemapCoords(), TILE_SIZE, and TilePixelHeightOutsideMap().
Referenced by CmdTerraformLand().
|
static |
Marks a viewport as dirty for repaint if it displays (a part of) the area the needs to be repainted.
vp | The viewport to mark as dirty |
left | Left edge of area to repaint |
top | Top edge of area to repaint |
right | Right edge of area to repaint |
bottom | Bottom edge of area to repaint |
Definition at line 1836 of file viewport.cpp.
References ViewPort::left, max(), SetDirtyBlocks(), ViewPort::top, UnScaleByZoom(), UnScaleByZoomLower(), ViewPort::virtual_height, ViewPort::virtual_left, ViewPort::virtual_top, ViewPort::virtual_width, and ViewPort::zoom.
Referenced by MarkAllViewportsDirty(), and ViewportSign::MarkDirty().
void MarkWholeScreenDirty | ( | ) |
This function mark the whole screen as dirty.
This results in repainting the whole screen. Use this with care as this function will break the idea about marking only parts of the screen as 'dirty'.
Definition at line 1461 of file gfx.cpp.
References SetDirtyBlocks().
Referenced by ChangeOwnershipOfCompanyItems(), CleanupGeneration(), CmdCompanyCtrl(), CmdRenameCompany(), CmdRenameEngine(), CmdRenamePresident(), CmdRenameVehicle(), CmdSetCompanyColour(), CmdSetCompanyManagerFace(), DoScanNewGRFFiles(), FlatEmptyWorld(), GameSizeChanged(), GenerateCompanyName(), HandleMouseEvents(), IConsoleResize(), IConsoleSwitch(), LoadHeightmap(), VideoDriver_Win32::MainLoop(), MenuClickCompany(), MenuClickSettings(), TransparenciesWindow::OnClick(), BuildTreesWindow::OnClick(), SpriteAlignerWindow::OnClick(), CompanyWindow::OnClick(), GameOptionsWindow::OnDropdownSelect(), MainWindow::OnHotkey(), IConsoleWindow::OnKeyPress(), CustomCurrencyWindow::OnQueryTextFinished(), ReInitAllWindows(), ReinitGuiAfterToggleElrail(), ReloadNewGRFData(), ResetLandscapeConfirmationCallback(), ResetRestoreAllTransparency(), ScanNewGRFFiles(), SetLocalCompany(), VideoDriver_SDL::Start(), VideoDriver_Win32::Start(), ToggleBoundingBoxes(), ToggleDirtyBlocks(), and Town::~Town().
|
static |
Marks the selected tiles as dirty.
This function marks the selected tiles as dirty for repaint
Definition at line 1937 of file viewport.cpp.
References Clamp(), TileHighlightData::diagonal, GetTileMaxPixelZ(), GetTilePixelZ(), MapMaxX(), MapMaxY(), MapSizeX(), MapSizeY(), MarkAllViewportsDirty(), MarkTileDirtyByTile(), TileHighlightData::offs, TileHighlightData::outersize, TileHighlightData::pos, RemapCoords(), TileHighlightData::size, TILE_HEIGHT, TILE_PIXELS, TILE_SIZE, TileVirtXY(), and TileXY().
Referenced by SetObjectToPlace(), and UpdateTileSelection().
|
static |
Adds a tile to the "tile_table" in a TerraformerState.
ts | TerraformerState. |
tile | Tile. |
Definition at line 74 of file terraform_cmd.cpp.
References TerraformerState::dirty_tiles.
Referenced by TerraformAddDirtyTileAround().
|
static |
Adds all tiles that incident with the north corner of a specific tile to the "tile_table" in a TerraformerState.
ts | TerraformerState. |
tile | Tile. |
Definition at line 86 of file terraform_cmd.cpp.
References TerraformAddDirtyTile(), TileDiffXY(), TileX(), and TileY().
Referenced by TerraformTileHeight().