* grub-core/video/fb/video_fb.c: Merge two blit functions
into one.
This commit is contained in:
		
							parent
							
								
									810f991b9e
								
							
						
					
					
						commit
						339eacce1b
					
				
					 2 changed files with 42 additions and 104 deletions
				
			
		|  | @ -1,3 +1,8 @@ | ||||||
|  | 2013-11-05  Vladimir Testov  <vladimir.testov@rosalab.ru> | ||||||
|  | 
 | ||||||
|  | 	* grub-core/video/fb/video_fb.c: Merge two blit functions | ||||||
|  | 	into one. | ||||||
|  | 
 | ||||||
| 2013-11-05  Vladimir Serbinenko  <phcoder@gmail.com> | 2013-11-05  Vladimir Serbinenko  <phcoder@gmail.com> | ||||||
| 
 | 
 | ||||||
| 	* grub-core/term/terminfo.c: Add sequences for home and end. | 	* grub-core/term/terminfo.c: Add sequences for home and end. | ||||||
|  |  | ||||||
|  | @ -753,13 +753,12 @@ grub_video_fb_fill_rect (grub_video_color_t color, int x, int y, | ||||||
|   return GRUB_ERR_NONE; |   return GRUB_ERR_NONE; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| grub_err_t | static inline grub_err_t __attribute__ ((always_inline)) | ||||||
| grub_video_fb_blit_bitmap (struct grub_video_bitmap *bitmap, | grub_video_fb_blit_source (struct grub_video_fbblit_info *source, | ||||||
|                            enum grub_video_blit_operators oper, int x, int y, |                            enum grub_video_blit_operators oper, int x, int y, | ||||||
|                            int offset_x, int offset_y, |                            int offset_x, int offset_y, | ||||||
|                            unsigned int width, unsigned int height) |                            unsigned int width, unsigned int height) | ||||||
| { | { | ||||||
|   struct grub_video_fbblit_info source; |  | ||||||
|   struct grub_video_fbblit_info target; |   struct grub_video_fbblit_info target; | ||||||
| 
 | 
 | ||||||
|   /* Make sure there is something to do.  */ |   /* Make sure there is something to do.  */ | ||||||
|  | @ -769,14 +768,14 @@ grub_video_fb_blit_bitmap (struct grub_video_bitmap *bitmap, | ||||||
|     return GRUB_ERR_NONE; |     return GRUB_ERR_NONE; | ||||||
|   if ((y >= (int)framebuffer.render_target->viewport.height) || (y + (int)height < 0)) |   if ((y >= (int)framebuffer.render_target->viewport.height) || (y + (int)height < 0)) | ||||||
|     return GRUB_ERR_NONE; |     return GRUB_ERR_NONE; | ||||||
|   if ((x + (int)bitmap->mode_info.width) < 0) |   if ((x + (int)source->mode_info->width) < 0) | ||||||
|     return GRUB_ERR_NONE; |     return GRUB_ERR_NONE; | ||||||
|   if ((y + (int)bitmap->mode_info.height) < 0) |   if ((y + (int)source->mode_info->height) < 0) | ||||||
|     return GRUB_ERR_NONE; |     return GRUB_ERR_NONE; | ||||||
|   if ((offset_x >= (int)bitmap->mode_info.width) |   if ((offset_x >= (int)source->mode_info->width) | ||||||
|       || (offset_x + (int)width < 0)) |       || (offset_x + (int)width < 0)) | ||||||
|     return GRUB_ERR_NONE; |     return GRUB_ERR_NONE; | ||||||
|   if ((offset_y >= (int)bitmap->mode_info.height) |   if ((offset_y >= (int)source->mode_info->height) | ||||||
|       || (offset_y + (int)height < 0)) |       || (offset_y + (int)height < 0)) | ||||||
|     return GRUB_ERR_NONE; |     return GRUB_ERR_NONE; | ||||||
| 
 | 
 | ||||||
|  | @ -815,36 +814,48 @@ grub_video_fb_blit_bitmap (struct grub_video_bitmap *bitmap, | ||||||
|   if ((y + height) > framebuffer.render_target->viewport.height) |   if ((y + height) > framebuffer.render_target->viewport.height) | ||||||
|     height = framebuffer.render_target->viewport.height - y; |     height = framebuffer.render_target->viewport.height - y; | ||||||
| 
 | 
 | ||||||
|   if ((offset_x + width) > bitmap->mode_info.width) |   if ((offset_x + width) > source->mode_info->width) | ||||||
|     width = bitmap->mode_info.width - offset_x; |     width = source->mode_info->width - offset_x; | ||||||
|   if ((offset_y + height) > bitmap->mode_info.height) |   if ((offset_y + height) > source->mode_info->height) | ||||||
|     height = bitmap->mode_info.height - offset_y; |     height = source->mode_info->height - offset_y; | ||||||
| 
 | 
 | ||||||
|   /* Limit drawing to source render target dimensions.  */ |   /* Limit drawing to source render target dimensions.  */ | ||||||
|   if (width > bitmap->mode_info.width) |   if (width > source->mode_info->width) | ||||||
|     width = bitmap->mode_info.width; |     width = source->mode_info->width; | ||||||
| 
 | 
 | ||||||
|   if (height > bitmap->mode_info.height) |   if (height > source->mode_info->height) | ||||||
|     height = bitmap->mode_info.height; |     height = source->mode_info->height; | ||||||
| 
 | 
 | ||||||
|   /* Add viewport offset.  */ |   /* Add viewport offset.  */ | ||||||
|   x += framebuffer.render_target->viewport.x; |   x += framebuffer.render_target->viewport.x; | ||||||
|   y += framebuffer.render_target->viewport.y; |   y += framebuffer.render_target->viewport.y; | ||||||
| 
 | 
 | ||||||
|   /* Use fbblit_info to encapsulate rendering.  */ |   /* Use fbblit_info to encapsulate rendering.  */ | ||||||
|   source.mode_info = &bitmap->mode_info; |  | ||||||
|   source.data = bitmap->data; |  | ||||||
|   target.mode_info = &framebuffer.render_target->mode_info; |   target.mode_info = &framebuffer.render_target->mode_info; | ||||||
|   target.data = framebuffer.render_target->data; |   target.data = framebuffer.render_target->data; | ||||||
| 
 | 
 | ||||||
|   /* Do actual blitting.  */ |   /* Do actual blitting.  */ | ||||||
|   dirty (y, height); |   dirty (y, height); | ||||||
|   grub_video_fb_dispatch_blit (&target, &source, oper, x, y, width, height, |   grub_video_fb_dispatch_blit (&target, source, oper, x, y, width, height, | ||||||
|                                offset_x, offset_y); |                                offset_x, offset_y); | ||||||
| 
 | 
 | ||||||
|   return GRUB_ERR_NONE; |   return GRUB_ERR_NONE; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | grub_err_t | ||||||
|  | grub_video_fb_blit_bitmap (struct grub_video_bitmap *bitmap, | ||||||
|  |                            enum grub_video_blit_operators oper, int x, int y, | ||||||
|  |                            int offset_x, int offset_y, | ||||||
|  |                            unsigned int width, unsigned int height) | ||||||
|  | { | ||||||
|  |   struct grub_video_fbblit_info source_info; | ||||||
|  |   source_info.mode_info = &bitmap->mode_info; | ||||||
|  |   source_info.data = bitmap->data; | ||||||
|  | 
 | ||||||
|  |   return grub_video_fb_blit_source (&source_info, oper, x, y, | ||||||
|  |                                     offset_x, offset_y, width, height); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| grub_err_t | grub_err_t | ||||||
| grub_video_fb_blit_render_target (struct grub_video_fbrender_target *source, | grub_video_fb_blit_render_target (struct grub_video_fbrender_target *source, | ||||||
|                                   enum grub_video_blit_operators oper, |                                   enum grub_video_blit_operators oper, | ||||||
|  | @ -852,89 +863,11 @@ grub_video_fb_blit_render_target (struct grub_video_fbrender_target *source, | ||||||
|                                   unsigned int width, unsigned int height) |                                   unsigned int width, unsigned int height) | ||||||
| { | { | ||||||
|   struct grub_video_fbblit_info source_info; |   struct grub_video_fbblit_info source_info; | ||||||
|   struct grub_video_fbblit_info target_info; |  | ||||||
| 
 |  | ||||||
|   /* Make sure there is something to do.  */ |  | ||||||
|   if ((width == 0) || (height == 0)) |  | ||||||
|     return GRUB_ERR_NONE; |  | ||||||
|   if ((x >= (int)framebuffer.render_target->viewport.width) || (x + (int)width < 0)) |  | ||||||
|     return GRUB_ERR_NONE; |  | ||||||
|   if ((y >= (int)framebuffer.render_target->viewport.height) || (y + (int)height < 0)) |  | ||||||
|     return GRUB_ERR_NONE; |  | ||||||
|   if ((x + (int)source->mode_info.width) < 0) |  | ||||||
|     return GRUB_ERR_NONE; |  | ||||||
|   if ((y + (int)source->mode_info.height) < 0) |  | ||||||
|     return GRUB_ERR_NONE; |  | ||||||
|   if ((offset_x >= (int)source->mode_info.width) |  | ||||||
|       || (offset_x + (int)width < 0)) |  | ||||||
|     return GRUB_ERR_NONE; |  | ||||||
|   if ((offset_y >= (int)source->mode_info.height) |  | ||||||
|       || (offset_y + (int)height < 0)) |  | ||||||
|     return GRUB_ERR_NONE; |  | ||||||
| 
 |  | ||||||
|   /* If we have negative coordinates, optimize drawing to minimum.  */ |  | ||||||
|   if (offset_x < 0) |  | ||||||
|     { |  | ||||||
|       width += offset_x; |  | ||||||
|       x -= offset_x; |  | ||||||
|       offset_x = 0; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|   if (offset_y < 0) |  | ||||||
|     { |  | ||||||
|       height += offset_y; |  | ||||||
|       y -= offset_y; |  | ||||||
|       offset_y = 0; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|   if (x < 0) |  | ||||||
|     { |  | ||||||
|       width += x; |  | ||||||
|       offset_x -= x; |  | ||||||
|       x = 0; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|   if (y < 0) |  | ||||||
|     { |  | ||||||
|       height += y; |  | ||||||
|       offset_y -= y; |  | ||||||
|       y = 0; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|   /* Do not allow drawing out of viewport.  */ |  | ||||||
|   if ((x + width) > framebuffer.render_target->viewport.width) |  | ||||||
|     width = framebuffer.render_target->viewport.width - x; |  | ||||||
|   if ((y + height) > framebuffer.render_target->viewport.height) |  | ||||||
|     height = framebuffer.render_target->viewport.height - y; |  | ||||||
| 
 |  | ||||||
|   if ((offset_x + width) > source->mode_info.width) |  | ||||||
|     width = source->mode_info.width - offset_x; |  | ||||||
|   if ((offset_y + height) > source->mode_info.height) |  | ||||||
|     height = source->mode_info.height - offset_y; |  | ||||||
| 
 |  | ||||||
|   /* Limit drawing to source render target dimensions.  */ |  | ||||||
|   if (width > source->mode_info.width) |  | ||||||
|     width = source->mode_info.width; |  | ||||||
| 
 |  | ||||||
|   if (height > source->mode_info.height) |  | ||||||
|     height = source->mode_info.height; |  | ||||||
| 
 |  | ||||||
|   /* Add viewport offset.  */ |  | ||||||
|   x += framebuffer.render_target->viewport.x; |  | ||||||
|   y += framebuffer.render_target->viewport.y; |  | ||||||
| 
 |  | ||||||
|   /* Use fbblit_info to encapsulate rendering.  */ |  | ||||||
|   source_info.mode_info = &source->mode_info; |   source_info.mode_info = &source->mode_info; | ||||||
|   source_info.data = source->data; |   source_info.data = source->data; | ||||||
|   target_info.mode_info = &framebuffer.render_target->mode_info; |  | ||||||
|   target_info.data = framebuffer.render_target->data; |  | ||||||
| 
 | 
 | ||||||
|   /* Do actual blitting.  */ |   return grub_video_fb_blit_source (&source_info, oper, x, y, | ||||||
|   dirty (y, height); |                                     offset_x, offset_y, width, height); | ||||||
|   grub_video_fb_dispatch_blit (&target_info, &source_info, oper, x, y, width, height, |  | ||||||
| 			       offset_x, offset_y); |  | ||||||
| 
 |  | ||||||
|   return GRUB_ERR_NONE; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| grub_err_t | grub_err_t | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue