Dirty

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)
 Mark a tile given by its index 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 () 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.
TileIndex TerraformerState::tile_table [TERRAFORMER_TILE_TABLE_SIZE]
 Dirty tiles, i.e. at least one corner changed.

Detailed Description

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 normaly uninteressted 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 uninteressted, 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".

See also:
VideoDriver::MakeDirty
_invalid_rect
_screen

Function Documentation

void MarkAllViewportsDirty ( int  left,
int  top,
int  right,
int  bottom 
)

Mark all viewports that display an area as dirty (in need of repaint).

Parameters:
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 1628 of file viewport.cpp.

References MarkViewportDirty(), Window::viewport, and ViewPort::width.

Referenced by ViewportSign::MarkDirty(), MarkSingleVehicleDirty(), MarkTileDirtyByTile(), SetSelectionTilesDirty(), and VehicleMove().

static void MarkCanalsAndRiversAroundDirty ( TileIndex  tile  )  [static]

Marks the tiles around a tile as dirty, if they are canals or rivers.

Parameters:
tile The center of the tile where all other tiles are marked as dirty

Definition at line 79 of file water_cmd.cpp.

References DIR_BEGIN, DIR_END, MarkTileDirtyIfCanalOrRiver(), and TileOffsByDir().

Referenced by CmdBuildCanal(), DoBuildLock(), DoFloodTile(), and RemoveLock().

virtual void Vehicle::MarkDirty (  )  [inline, virtual, inherited]

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 Aircraft, RoadVehicle, Ship, and Train.

Definition at line 271 of file vehicle_base.h.

Referenced by Vehicle::BeginLoading(), CmdStartStopVehicle(), Vehicle::HandleBreakdown(), and LoadUnloadVehicle().

void MarkTileDirtyByTile ( TileIndex  tile  ) 

Mark a tile given by its index dirty for repaint.

Parameters:
tile The tile to mark dirty.

Definition at line 1645 of file viewport.cpp.

References GetTileZ(), MarkAllViewportsDirty(), RemapCoords(), TILE_SIZE, TileX(), and TileY().

Referenced by AddAnimatedTile(), AnimationBase< HouseAnimationBase, HouseSpec, Town, GetSimpleHouseCallback >::AnimateTile(), AnimateTile_Town(), BuildObject(), ClearMakeHouseTile(), ClearPathReservation(), CmdBuildBridge(), CmdBuildCanal(), CmdBuildRailWaypoint(), CmdBuildRoad(), CmdBuildRoadDepot(), CmdBuildRoadStop(), CmdBuildShipDepot(), CmdBuildSingleRail(), CmdBuildSingleSignal(), CmdBuildTrainDepot(), CmdConvertRail(), CmdPlantTree(), CmdRemoveSingleRail(), CmdRemoveSingleSignal(), CmdTerraformLand(), DeleteAnimatedTile(), DoBuildLock(), DoClearBridge(), DoDryUp(), DoFloodTile(), FloodHalftile(), FreeTrainTrackReservation(), GenerateDesertArea(), GenerateRockyArea(), IncreaseAnimationStage(), MakeSingleHouseBigger(), MarkTileDirtyIfCanalOrRiver(), Station::MarkTilesDirty(), MaybeBarCrossingWithSound(), NPFMarkTile(), BuildRoadToolbarWindow::OnKeyPress(), BuildRailToolbarWindow::OnKeyPress(), RemoveDock(), RemoveRoad(), CYapfReserveTrack< Types >::ReserveRailStationPlatform(), SetRailStationPlatformReservation(), SetRedErrorSquare(), SetSelectionTilesDirty(), SetWaterClassDependingOnSurroundings(), TileLoopClearAlps(), TownActionBuildStatue(), TryPathReserve(), TryReserveRailTrack(), UnreserveRailTrack(), UpdateLevelCrossing(), UpdateSignalsAroundSegment(), and VehicleEnterDepot().

static void MarkViewportDirty ( const ViewPort vp,
int  left,
int  top,
int  right,
int  bottom 
) [static]

Marks a viewport as dirty for repaint if it displays (a part of) the area the needs to be repainted.

Parameters:
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 1596 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().

void MarkWholeScreenDirty (  ) 
static void SetSelectionTilesDirty (  )  [static]
static void TerraformAddDirtyTile ( TerraformerState ts,
TileIndex  tile 
) [static]

Adds a tile to the "tile_table" in a TerraformerState.

Parameters:
ts TerraformerState.
tile Tile.

Definition at line 118 of file terraform_cmd.cpp.

References TerraformerState::tile_table, and TerraformerState::tile_table_count.

Referenced by TerraformAddDirtyTileAround().

static void TerraformAddDirtyTileAround ( TerraformerState ts,
TileIndex  tile 
) [static]

Adds all tiles that incident with the north corner of a specific tile to the "tile_table" in a TerraformerState.

Parameters:
ts TerraformerState.
tile Tile.

Definition at line 138 of file terraform_cmd.cpp.

References TerraformAddDirtyTile(), TileDiffXY(), TileX(), and TileY().

Referenced by TerraformTileHeight().


Variable Documentation

Rect _invalid_rect [static]

The rect for repaint.

This rectangle defines the area which should be repaint by the video driver.

Definition at line 106 of file gfx.cpp.

TileIndex TerraformerState::tile_table[TERRAFORMER_TILE_TABLE_SIZE] [inherited]

Dirty tiles, i.e. at least one corner changed.

This array contains the tiles which are or will be marked as dirty.

Definition at line 55 of file terraform_cmd.cpp.

Referenced by CmdTerraformLand(), and TerraformAddDirtyTile().


Generated on Mon May 9 05:19:32 2011 for OpenTTD by  doxygen 1.6.1