← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~nomeata/widelands/draw-line-clip into lp:widelands

 

Joachim Breitner has proposed merging lp:~nomeata/widelands/draw-line-clip into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~nomeata/widelands/draw-line-clip/+merge/81362

This makes the plot widget in OpenGL fast again.
-- 
https://code.launchpad.net/~nomeata/widelands/draw-line-clip/+merge/81362
Your team Widelands Developers is requested to review the proposed merge of lp:~nomeata/widelands/draw-line-clip into lp:widelands.
=== modified file 'src/graphic/render/gl_surface_screen.cc'
--- src/graphic/render/gl_surface_screen.cc	2011-02-21 18:04:56 +0000
+++ src/graphic/render/gl_surface_screen.cc	2011-11-05 15:58:25 +0000
@@ -230,15 +230,8 @@
 		 int32_t y1,
 		 int32_t x2,
 		 int32_t y2,
-		 RGBColor color,
-		 const Rect * clip)
+		 RGBColor color)
 {
-	if (clip) {
-		glPushAttrib(GL_ENABLE_BIT | GL_SCISSOR_BIT);
-		glScissor
-			(clip->x, g_gr->get_yres() - clip->y - clip->h, clip->w, clip->h);
-		glEnable(GL_SCISSOR_TEST);
-	}
 	glDisable(GL_BLEND);
 	glDisable(GL_TEXTURE_2D);
 	glBegin(GL_LINES); {
@@ -246,9 +239,6 @@
 		glVertex2f(x1 + 0.5f, y1 + 0.5f);
 		glVertex2f(x2 + 0.5f, y2 + 0.5f);
 	} glEnd();
-	if (clip) {
-		glPopAttrib();
-	}
 }
 
 /**

=== modified file 'src/graphic/render/gl_surface_screen.h'
--- src/graphic/render/gl_surface_screen.h	2011-02-20 16:42:42 +0000
+++ src/graphic/render/gl_surface_screen.h	2011-11-05 15:58:25 +0000
@@ -57,7 +57,7 @@
 	virtual void draw_line
 		(int32_t x1, int32_t y1,
 		 int32_t x2, int32_t y2,
-		 RGBColor, Rect const * clip = 0);
+		 RGBColor);
 
 	virtual void blit(Point, PictureID, Rect srcrc, Composite cm);
 	virtual void fast_blit(PictureID);

=== modified file 'src/graphic/render/render_sdl.cc'
--- src/graphic/render/render_sdl.cc	2010-12-04 23:11:18 +0000
+++ src/graphic/render/render_sdl.cc	2011-11-05 15:58:25 +0000
@@ -204,8 +204,7 @@
 		 int32_t y1,
 		 int32_t x2,
 		 int32_t y2,
-		 RGBColor color,
-		 const Rect * clip)
+		 RGBColor color)
 {
 	int32_t dx = x2 - x1;      /* the horizontal distance of the line */
 	int32_t dy = y2 - y1;      /* the vertical distance of the line */
@@ -217,7 +216,7 @@
 	uint32_t y = dxabs / 2;
 	Point p(x1, y1);
 
-	draw_pixel(p, *clip, color);
+        set_pixel(p.x, p.y, color.map(format()));
 
 	if (dxabs >= dyabs) //  the line is more horizontal than vertical
 		for (uint32_t i = 0; i < dxabs; ++i) {
@@ -229,7 +228,7 @@
 			}
 
 			p.x += sdx;
-			draw_pixel(p, *clip, color);
+			set_pixel(p.x, p.y, color.map(format()));
 		}
 	else                //  the line is more vertical than horizontal
 		for (uint32_t i = 0; i < dyabs; ++i) {
@@ -241,7 +240,7 @@
 			}
 
 			p.y += sdy;
-			draw_pixel(p, *clip, color);
+			set_pixel(p.x, p.y, color.map(format()));
 		}
 }
 

=== modified file 'src/graphic/render/surface_sdl.h'
--- src/graphic/render/surface_sdl.h	2010-11-27 16:23:39 +0000
+++ src/graphic/render/surface_sdl.h	2011-11-05 15:58:25 +0000
@@ -80,7 +80,7 @@
 	void draw_line
 		(int32_t x1, int32_t y1,
 		 int32_t x2, int32_t y2,
-		 RGBColor, Rect const * clip = 0);
+		 RGBColor);
 
 	void blit(Point, PictureID, Rect srcrc, Composite cm);
 	void fast_blit(PictureID);

=== modified file 'src/graphic/rendertarget.cc'
--- src/graphic/rendertarget.cc	2010-11-27 16:23:39 +0000
+++ src/graphic/rendertarget.cc	2011-11-05 15:58:25 +0000
@@ -141,14 +141,9 @@
 	(int32_t const x1, int32_t const y1, int32_t const x2, int32_t const y2,
 	 RGBColor const color)
 {
-	Rect clipr = Rect
-		(Point(m_rect.x + m_offset.x, m_rect.y + m_offset.y),
-		 m_rect.w, m_rect.h);
-
 	m_surface->draw_line
 		(x1 + m_offset.x + m_rect.x, y1 + m_offset.y + m_rect.y,
-		 x2 + m_offset.x + m_rect.x, y2 + m_offset.y + m_rect.y, color,
-		 &clipr);
+		 x2 + m_offset.x + m_rect.x, y2 + m_offset.y + m_rect.y, color);
 }
 
 /**

=== modified file 'src/graphic/surface.h'
--- src/graphic/surface.h	2010-11-27 13:30:37 +0000
+++ src/graphic/surface.h	2011-11-05 15:58:25 +0000
@@ -60,8 +60,7 @@
 		 int32_t y1,
 		 int32_t x2,
 		 int32_t y2,
-		 RGBColor color,
-		 Rect const * clip = 0)
+		 RGBColor color)
 	{
 		throw wexception("draw_line() not implemented");
 	}


Follow ups