Changeset - r19180:f1705a610ae7
[Not reviewed]
master
0 3 0
rubidium - 13 years ago 2012-03-25 19:30:05
rubidium@openttd.org
(svn r24068) -Change/fix [FS#5103]: significantly reduce the area that is redrawn for text effects (Rhamphoryncus)
3 files changed with 26 insertions and 13 deletions:
0 comments (0 inline, 0 general)
src/texteff.cpp
Show inline comments
 
@@ -86,15 +86,15 @@ void MoveAllTextEffects()
 

	
 
		if (te->duration-- == 0) {
 
			te->Reset();
 
			continue;
 
		}
 

	
 
		te->MarkDirty();
 
		te->MarkDirty(ZOOM_LVL_OUT_8X);
 
		te->top -= ZOOM_LVL_BASE;
 
		te->MarkDirty();
 
		te->MarkDirty(ZOOM_LVL_OUT_8X);
 
	}
 
}
 

	
 
void InitTextEffects()
 
{
 
	_text_effects.Reset();
src/viewport.cpp
Show inline comments
 
@@ -141,12 +141,14 @@ struct ViewportDrawer {
 
	int foundation[FOUNDATION_PART_END];             ///< Foundation sprites (index into parent_sprites_to_draw).
 
	FoundationPart foundation_part;                  ///< Currently active foundation for ground sprite drawing.
 
	int *last_foundation_child[FOUNDATION_PART_END]; ///< Tail of ChildSprite list of the foundations. (index into child_screen_sprites_to_draw)
 
	Point foundation_offset[FOUNDATION_PART_END];    ///< Pixel offset for ground sprites on the foundations.
 
};
 

	
 
static void MarkViewportDirty(const ViewPort *vp, int left, int top, int right, int bottom);
 

	
 
static ViewportDrawer _vd;
 

	
 
TileHighlightData _thd;
 
static TileInfo *_cur_ti;
 
bool _draw_bounding_boxes = false;
 
bool _draw_dirty_blocks = false;
 
@@ -1242,26 +1244,37 @@ void ViewportSign::UpdatePosition(int ce
 

	
 
	this->MarkDirty();
 
}
 

	
 
/**
 
 * Mark the sign dirty in all viewports.
 
 * @param maxzoom Maximum %ZoomLevel at which the text is visible.
 
 *
 
 * @ingroup dirty
 
 */
 
void ViewportSign::MarkDirty() const
 
void ViewportSign::MarkDirty(ZoomLevel maxzoom) const
 
{
 
	/* We use ZOOM_LVL_MAX here, as every viewport can have another zoom,
 
	 *  and there is no way for us to know which is the biggest. So make the
 
	 *  biggest area dirty, and we are safe for sure.
 
	 * We also add 1 to make sure the whole thing is redrawn. */
 
	MarkAllViewportsDirty(
 
		this->center - ScaleByZoom(this->width_normal / 2 + 1, ZOOM_LVL_MAX),
 
		this->top    - ScaleByZoom(1, ZOOM_LVL_MAX),
 
		this->center + ScaleByZoom(this->width_normal / 2 + 1, ZOOM_LVL_MAX),
 
		this->top    + ScaleByZoom(VPSM_TOP + FONT_HEIGHT_NORMAL + VPSM_BOTTOM + 1, ZOOM_LVL_MAX));
 
	Rect zoomlevels[ZOOM_LVL_COUNT];
 

	
 
	for (ZoomLevel zoom = ZOOM_LVL_BEGIN; zoom != ZOOM_LVL_END; zoom++) {
 
		/* FIXME: This doesn't switch to width_small when appropriate. */
 
		zoomlevels[zoom].left   = this->center - ScaleByZoom(this->width_normal / 2 + 1, zoom);
 
		zoomlevels[zoom].top    = this->top    - ScaleByZoom(1, zoom);
 
		zoomlevels[zoom].right  = this->center + ScaleByZoom(this->width_normal / 2 + 1, zoom);
 
		zoomlevels[zoom].bottom = this->top    + ScaleByZoom(VPSM_TOP + FONT_HEIGHT_NORMAL + VPSM_BOTTOM + 1, zoom);
 
	}
 

	
 
	Window *w;
 
	FOR_ALL_WINDOWS_FROM_BACK(w) {
 
		ViewPort *vp = w->viewport;
 
		if (vp != NULL && vp->zoom <= maxzoom) {
 
			assert(vp->width != 0);
 
			Rect &zl = zoomlevels[vp->zoom];
 
			MarkViewportDirty(vp, zl.left, zl.top, zl.right, zl.bottom);
 
		}
 
	}
 
}
 

	
 
static void ViewportDrawTileSprites(const TileSpriteToDrawVector *tstdv)
 
{
 
	const TileSpriteToDraw *tsend = tstdv->End();
 
	for (const TileSpriteToDraw *ts = tstdv->Begin(); ts != tsend; ++ts) {
src/viewport_type.h
Show inline comments
 
@@ -45,13 +45,13 @@ struct ViewportSign {
 
	int32 center;        ///< The center position of the sign
 
	int32 top;           ///< The top of the sign
 
	uint16 width_normal; ///< The width when not zoomed out (normal font)
 
	uint16 width_small;  ///< The width when zoomed out (small font)
 

	
 
	void UpdatePosition(int center, int top, StringID str);
 
	void MarkDirty() const;
 
	void MarkDirty(ZoomLevel maxzoom = ZOOM_LVL_MAX) const;
 
};
 

	
 
/**
 
 * Directions of zooming.
 
 * @see DoZoomInOutWindow
 
 */
0 comments (0 inline, 0 general)