⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 r2d_vertical_lcd_i.c

📁 MMI层OBJ不能完全编译
💻 C
📖 第 1 页 / 共 5 页
字号:
        p_src_start+=(rect_width-1)*src_offset;
        p_dst_start+=(rect_width-1)*dst_offset;
      }
	  else
		x=r2d_get_xmin(dst_rectangle);

      if (v_direction==-1)
      {
        p_src_start+=nb_rows-1;
        p_dst_start+=nb_rows-1;

      }

      //printf("dst_start=%08X contains %08X\n",p_dst_start,*p_dst_start);
      while(xnb!=0)
      {
        p_dst_current=p_dst_start;
        p_src_current=p_src_start;

        ynb=nb_rows; // Not using - 1 since not different processing of ending word
        // (which is here a pixel instead of being only a memory word)
        
        
        
        //printf("src_current=%08X, dst_current=%08X\n",src_current,dst_current);
        //printf("new column\n dst=%08X\n",p_dst_current);
        
		if (v_direction==-1)
		{
			while(ynb!=0)
			{
            
              value=*p_dst_current;
              *p_dst_current--=dop(value,*p_src_current--);
			  y--;
            
              ynb--;
			}
		}
		else
		{
			while(ynb!=0)
			{
            
              value=*p_dst_current;
              *p_dst_current++=dop(value,*p_src_current++);
			  y++;
           
              ynb--;
			}
		}

        
          
        if (h_direction==-1)
        {
          p_src_start-=src_offset;
          p_dst_start-=dst_offset;
		  x--;
        }
        else
        {
          p_src_start+=src_offset;
          p_dst_start+=dst_offset;
		  x++;
        }

        xnb--;
      }

      
      
   
  }
end_blit_c:ynb=0; 
}


#undef r2d_shift_pixel_down_and_write
#undef r2d_shift_pixel_up_and_write

#define r2d_shift_pixel_down_and_write(dst,src) {\
               dst##value =r2d_convert_from_lcd_to_color(use_foreground_color,\
			   src##_current & R2D_PIXEL_MASK,src_gc,dst_gc,x,y); \
               dst##value =dop(*p_dst_current,dst##value); \
               *p_##dst##_current++=dst##value;\
               src##_current=R2D_PIXEL_DOWN_OUT(src##_current); \
               src##counter--; \
               if (src##counter==0) \
               { \
                 src##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \
                 src##_current=*++p_##src##_current;  \
               } \
               }


#define r2d_shift_pixel_up_and_write(dst,src) {\
               dst##value =r2d_convert_from_lcd_to_color(use_foreground_color,\
			   src##_current & R2D_PIXEL_MASK,src_gc,dst_gc,x,y); \
               dst##value =dop(*p_dst_current,dst##value); \
               *p_##dst##_current--=dst##value;\
               src##_current=R2D_PIXEL_UP_OUT(src##_current); \
               src##counter--; \
               if (src##counter==0) \
               { \
                 src##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \
                 src##_current=*--p_##src##_current;  \
               } \
               }

// Requires shapes in graphic context coordinates
void           r2d_blit_lcd_to_color(T_R2D_GC_PTR src_gc,T_R2D_GC_PTR dst_gc,
                             T_R2D_SHAPE_PTR src_rectangle, 
							 T_R2D_SHAPE_PTR dst_rectangle,
							 R2D_BOOLEAN use_foreground_color)
{
    UINT32 *p_src,*p_dst,*p_src_current,*p_dst_current,*p_src_start,*p_dst_start;
    INT16 rect_width,rect_height,src_x,src_y,dst_x,dst_y;
    INT16 src_offset,dst_offset,src_height,dst_height;
    INT16 xnb,ynb,src_nb_rows,dst_nb_rows;
    INT16 src_dy,dst_dy,end_dst_dy,end_src_dy; // distance from word boundary
//    INT16 shift; // relative position (modulo a memory word) between both rectangles
    // in bits
    INT16 current_src_dy;//,current_dst_dy;
    INT16 temp,srccounter;//,dstcounter;


    register UINT32 dstvalue;//,dst_current;
    register UINT32 src_current;//,srcvalue;
    INT32  h_direction,v_direction;
	INT16 x,y;
    T_R2D_DRAWING_MODE mode;
	T_R2D_DRAWING_OP dop;

    dop=((T_R2D_GC*)dst_gc)->drawing_op;


    

    {

    p_src=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))->p_memory_words;
    p_dst=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->p_memory_words;

    rect_width=r2d_get_xmax(src_rectangle)-r2d_get_xmin(src_rectangle);
    rect_height=r2d_get_ymax(src_rectangle)-r2d_get_ymin(src_rectangle);

	if ((rect_width<=0) || (rect_height<=0))
		goto end_blit_d;

    mode=IND_r2d_get_drawing_mode(dst_gc);

    
    src_x=r2d_get_xmin(src_rectangle);
    src_y=r2d_get_ymin(src_rectangle);

    dst_x=r2d_get_xmin(dst_rectangle);
    dst_y=r2d_get_ymin(dst_rectangle);

    src_dy=src_y & R2D_WORD_POSITION_MASK;
	dst_dy=dst_y & R2D_WORD_POSITION_MASK;
	
    // Clipping convention such end_dst_dy is the first y position which must not
    // be copied at the end of a column
    end_dst_dy=(r2d_get_ymax(dst_rectangle)-1) & R2D_WORD_POSITION_MASK;
	end_src_dy=(r2d_get_ymax(src_rectangle)-1) & R2D_WORD_POSITION_MASK ;
	
    // Number of rows is word containing last point - word containing first point
    // + 1
    src_nb_rows=R2D_ALIGNED_MWLENGTH(r2d_get_ymax(src_rectangle)-1)-R2D_ALIGNED_MWLENGTH(src_y) + 1;
    
    dst_nb_rows=(r2d_get_ymax(dst_rectangle))-(dst_y);
    //printf("nb_rows %d\n",nb_rows);
    
    h_direction=1;
    v_direction=1;
    if (((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))==
       ((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer)))
      r2d_check_rectangle_overlap(src_x,src_y,dst_x,dst_y,
      rect_width,rect_height,&h_direction,&v_direction);

    //printf("h,v=%d,%d\n",h_direction,v_direction);


      
#if (R2D_REFRESH == R2D_VERTICAL)      
      src_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))->height;
      dst_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->height;
#else
	  src_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))->width;
      dst_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->width;
#endif
   
      src_offset=R2D_ALIGNED_MWLENGTH(src_height);
      dst_offset=dst_height;

      //printf("%08X,dst offset=%08X\n",p_dst,dst_offset);

      p_src_start=p_src
        +((src_x*src_offset+(src_y>>R2D_PIXELS_PER_MEMORY_WORD)));
      p_dst_start=p_dst
        +((dst_x*dst_offset+(dst_y)));

      xnb=rect_width;

      //printf("start %08X contains %08X\n",p_dst_start,*p_dst_start);

      if (h_direction==-1)
      {
		x=r2d_get_xmax(dst_rectangle)-1;
        p_src_start+=(rect_width-1)*src_offset;
        p_dst_start+=(rect_width-1)*dst_offset;
      }
	  else
		  x=r2d_get_xmin(dst_rectangle);

      if (v_direction==-1)
      {
        p_src_start+=src_nb_rows-1;
        p_dst_start+=dst_nb_rows-1;

        temp=src_dy;
        src_dy=end_src_dy;
        end_src_dy=temp;

      }

      //printf("dst_start=%08X contains %08X\n",p_dst_start,*p_dst_start);
      while(xnb!=0)
      {
        p_dst_current=p_dst_start;
        p_src_current=p_src_start;

        ynb=dst_nb_rows; // No -1 since no different processing for last word
        
        if (v_direction==-1)
        {
           current_src_dy=(1<<R2D_PIXELS_PER_MEMORY_WORD)-1;
		   y=r2d_get_ymax(dst_rectangle)-1;
        }
        else
        {
           current_src_dy=0;
		   y=r2d_get_ymin(dst_rectangle);
        }
        
        srccounter=(1<<R2D_PIXELS_PER_MEMORY_WORD);
        
        src_current=*p_src_current;
        //printf("src_current=%08X, dst_current=%08X\n",src_current,dst_current);
        temp=0;
        //printf("new column\n dst=%08X\n",p_dst_current);
        
        //printf("src_dy=%d\n",src_dy);

		if (v_direction==-1)
		{
			while(current_src_dy!=src_dy)
			{
            
              //printf("current_src_dy=%d\n",current_src_dy);
              r2d_shift_pixel_up(temp,src_current,srccounter,p_src_current);
              current_src_dy--;
			  
              //printf("src_current=%08X\n",src_current);
            
			}
			//printf("src_current=%08X, dst_current=%08X, dstvalue=%08X\n dstcounter=%08X, srccounter=%08X\n",
        //src_current,dst_current,dstvalue,dstcounter,srccounter);
            while(ynb!=0)
			{
            
              r2d_shift_pixel_up_and_write(dst,src);
			  y--;
            
              ynb--;

			}
		}
		else
		{
			while(current_src_dy!=src_dy)
			{
            
              r2d_shift_pixel_down(temp,src_current,srccounter,p_src_current);
              current_src_dy++;
			  
            
			}
			//printf("src_current=%08X, dst_current=%08X, dstvalue=%08X\n dstcounter=%08X, srccounter=%08X\n",
        //src_current,dst_current,dstvalue,dstcounter,srccounter);
           while(ynb!=0)
		   {
            
              r2d_shift_pixel_down_and_write(dst,src);
			  y++;
            
            ynb--;

		   }
		}

        
        
        
          
        if (h_direction==-1)
        {
          p_src_start-=src_offset;
          p_dst_start-=dst_offset;
		  x--;
        }
        else
        {
          p_src_start+=src_offset;
          p_dst_start+=dst_offset;
		  x++;
        }

        xnb--;
      }

      
      
    
  }
end_blit_d:ynb=0;
}



#undef r2d_shift_pixel_down_and_write
#undef r2d_shift_pixel_up_and_write

#define r2d_shift_pixel_down_and_write(dst,src) {\
               dst##value =R2D_PIXEL_DOWN_OUT(dst##value); \
               src##_current=r2d_convert_from_color_to_lcd(use_foreground_color,\
			   *p_##src##_current++,src_gc,dst_gc,x,y); \
               dst##value|=dop((dst##_current & R2D_PIXEL_MASK), \
               src##_current) \
               << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH) ; \
               dst##_current=R2D_PIXEL_DOWN_OUT(dst##_current); \
               dst##counter--; \
               if (dst##counter==0) \
               { \
                 dst##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \
               } \
               }


#define r2d_shift_pixel_up_and_write(dst,src) {\
               dst##value =R2D_PIXEL_UP_OUT(dst##value); \
               src##_current=r2d_convert_from_color_to_lcd(use_foreground_color,\
			   *p_##src##_current--,src_gc,dst_gc,x,y); \
               dst##value |=dop( \
               (dst##_current >> ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) & R2D_PIXEL_MASK, \
               src##_current); \
               dst##_current=R2D_PIXEL_UP_OUT(dst##_current); \
               dst##counter--; \
               if (dst##counter==0) \
               { \
                 dst##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \
               } \
               }

// Requires shapes in graphic context coordinates
void           r2d_blit_color_to_lcd(T_R2D_GC_PTR src_gc,T_R2D_GC_PTR dst_gc,
                             T_R2D_SHAPE_PTR src_rectangle, 
							 T_R2D_SHAPE_PTR dst_rectangle,
							 R2D_BOOLEAN use_foreground_color)
{
    UINT32 *p_src,*p_dst,*p_src_current,*p_dst_current,*p_src_start,*p_dst_start;
    INT16 rect_width,rect_height,src_x,src_y,dst_x,dst_y;
    INT16 src_offset,dst_offset,src_height,dst_height;
    INT16 xnb,ynb,dst_nb_rows,src_nb_rows;
    INT16 src_dy,dst_dy,end_dst_dy,end_src_dy; // distance from word boundary
//    INT16 shift; // relative position (modulo a memory word) between both rectangles
    // in bits
    INT16 current_dst_dy;//,current_src_dy;
    INT16 temp,dstcounter,srccounter;


    register UINT32 dstvalue,dst_current;
    register UINT32 src_current;//,srcvalue;
    INT32  h_direction,v_direction;
	INT16 x,y;
    T_R2D_DRAWING_MODE mode;
    T_R2D_DRAWING_OP dop;
	BOOLEAN compensate=TRUE;

    dop=((T_R2D_GC*)dst_gc)->drawing_op;


    

     {

    p_src=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))->p_memory_words;
    p_dst=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->p_memory_words;

    rect_width=r2d_get_xmax(src_rectangle)-r2d_get_xmin(src_rectangle);
    rect_height=r2d_get_ymax(src_rectangle)-r2d_get_ymin(src_rectangle);

	if ((rect_width<=0) || (rect_height<=0))
		goto end_blit_e;

    mode=IND_r2d_get_drawing_mode(dst_gc);

    
    src_x=r2d_get_xmin(src_rectangle);
    src_y=r2d_get_ymin(src_rectangle);

    dst_x=r2d_get_xmin(dst_rectangle);
    dst_y=r2d_get_ymin(dst_rectangle);

    src_dy=src_y & R2D_WORD_POSITION_MASK;
	dst_dy=dst_y & R2D_WORD_POSITION_MASK;
	
    // Clipping convention such end_dst_dy is the first y position which must not
    // be copied at the end of a column
    end_dst_dy=(r2d_get_ymax(dst_rectangle)-1) & R2D_WORD_POSITION_MASK ;
	end_src_dy=(r2d_get_ymax(src_rectangle)-1) & R2

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -