Просмотр исходного кода

Merge branch 'master' of https://github.com/RT-Thread-packages/gui_engine

yangfasheng 7 лет назад
Родитель
Сommit
5b63dd726a
3 измененных файлов с 21 добавлено и 23 удалено
  1. 8 8
      src/dc_blend.c
  2. 1 0
      src/dc_buffer.c
  3. 12 15
      src/image_png.c

+ 8 - 8
src/dc_blend.c

@@ -805,7 +805,7 @@ rtgui_dc_blend_point(struct rtgui_dc * dst, int x, int y, enum RTGUI_BLENDMODE b
             return;
             return;
     }
     }
 
 
-    if (blendMode == RTGUI_BLENDMODE_BLEND || blendMode == RTGUI_BLENDMODE_ADD)
+    if (blendMode == RTGUI_BLENDMODE_ADD || blendMode == RTGUI_BLENDMODE_MOD)
     {
     {
         r = DRAW_MUL(r, a);
         r = DRAW_MUL(r, a);
         g = DRAW_MUL(g, a);
         g = DRAW_MUL(g, a);
@@ -846,7 +846,7 @@ rtgui_dc_blend_points(struct rtgui_dc *dst, const rtgui_point_t *points, int cou
     /* we do not support pixel DC */
     /* we do not support pixel DC */
     if (_dc_get_pixel(dst, 0, 0) == RT_NULL) return;
     if (_dc_get_pixel(dst, 0, 0) == RT_NULL) return;
 
 
-    if (blendMode == RTGUI_BLENDMODE_BLEND || blendMode == RTGUI_BLENDMODE_ADD)
+    if (blendMode == RTGUI_BLENDMODE_ADD || blendMode == RTGUI_BLENDMODE_MOD)
     {
     {
         r = DRAW_MUL(r, a);
         r = DRAW_MUL(r, a);
         g = DRAW_MUL(g, a);
         g = DRAW_MUL(g, a);
@@ -928,7 +928,7 @@ _dc_blend_line_rgb565(struct rtgui_dc * dst, int x1, int y1, int x2, int y2,
 {
 {
     unsigned r, g, b, a, inva;
     unsigned r, g, b, a, inva;
 
 
-    if (blendMode == RTGUI_BLENDMODE_BLEND || blendMode == RTGUI_BLENDMODE_ADD)
+    if (blendMode == RTGUI_BLENDMODE_ADD || blendMode == RTGUI_BLENDMODE_MOD)
     {
     {
         r = DRAW_MUL(_r, _a);
         r = DRAW_MUL(_r, _a);
         g = DRAW_MUL(_g, _a);
         g = DRAW_MUL(_g, _a);
@@ -1033,7 +1033,7 @@ _dc_blend_line_bgr565(struct rtgui_dc * dst, int x1, int y1, int x2, int y2,
 {
 {
     unsigned r, g, b, a, inva;
     unsigned r, g, b, a, inva;
 
 
-    if (blendMode == RTGUI_BLENDMODE_BLEND || blendMode == RTGUI_BLENDMODE_ADD)
+    if (blendMode == RTGUI_BLENDMODE_ADD || blendMode == RTGUI_BLENDMODE_MOD)
     {
     {
         r = DRAW_MUL(_r, _a);
         r = DRAW_MUL(_r, _a);
         g = DRAW_MUL(_g, _a);
         g = DRAW_MUL(_g, _a);
@@ -1138,7 +1138,7 @@ _dc_blend_line_rgb888(struct rtgui_dc * dst, int x1, int y1, int x2, int y2,
 {
 {
     unsigned r, g, b, a, inva;
     unsigned r, g, b, a, inva;
 
 
-    if (blendMode == RTGUI_BLENDMODE_BLEND || blendMode == RTGUI_BLENDMODE_ADD)
+    if (blendMode == RTGUI_BLENDMODE_ADD || blendMode == RTGUI_BLENDMODE_MOD)
     {
     {
         r = DRAW_MUL(_r, _a);
         r = DRAW_MUL(_r, _a);
         g = DRAW_MUL(_g, _a);
         g = DRAW_MUL(_g, _a);
@@ -1288,7 +1288,7 @@ _dc_blend_line_argb8888(struct rtgui_dc * dst, int x1, int y1, int x2, int y2,
 {
 {
     unsigned r, g, b, a, inva;
     unsigned r, g, b, a, inva;
 
 
-    if (blendMode == RTGUI_BLENDMODE_BLEND || blendMode == RTGUI_BLENDMODE_ADD)
+    if (blendMode == RTGUI_BLENDMODE_ADD || blendMode == RTGUI_BLENDMODE_MOD)
     {
     {
         r = DRAW_MUL(_r, _a);
         r = DRAW_MUL(_r, _a);
         g = DRAW_MUL(_g, _a);
         g = DRAW_MUL(_g, _a);
@@ -1819,7 +1819,7 @@ rtgui_dc_blend_fill_rects(struct rtgui_dc * dst, const rtgui_rect_t *rects, int
     b = RTGUI_RGB_B(color);
     b = RTGUI_RGB_B(color);
     a = RTGUI_RGB_A(color);
     a = RTGUI_RGB_A(color);
 
 
-    if (blendMode == RTGUI_BLENDMODE_BLEND || blendMode == RTGUI_BLENDMODE_ADD)
+    if (blendMode == RTGUI_BLENDMODE_ADD || blendMode == RTGUI_BLENDMODE_MOD)
     {
     {
         r = DRAW_MUL(r, a);
         r = DRAW_MUL(r, a);
         g = DRAW_MUL(g, a);
         g = DRAW_MUL(g, a);
@@ -2544,7 +2544,7 @@ void _murphyWideline(_MurphyIterator *m, rt_int16_t x1, rt_int16_t y1, rt_int16_
     float offset = (float)width / 2.f;
     float offset = (float)width / 2.f;
 
 
     rt_int16_t temp;
     rt_int16_t temp;
-    rt_int16_t ptx, pty, ml1x, ml1y, ml2x, ml2y, ml1bx, ml1by, ml2bx, ml2by;
+    rt_int16_t ptx, pty, ml1x = 0, ml1y = 0, ml2x = 0, ml2y = 0, ml1bx = 0, ml1by = 0, ml2bx = 0, ml2by = 0;
 
 
     int d0, d1;     /* difference terms d0=perpendicular to line, d1=along line */
     int d0, d1;     /* difference terms d0=perpendicular to line, d1=along line */
 
 

+ 1 - 0
src/dc_buffer.c

@@ -87,6 +87,7 @@ struct rtgui_dc *rtgui_dc_buffer_create_pixformat(rt_uint8_t pixel_format, int w
         dc->gc.background = default_background;
         dc->gc.background = default_background;
         dc->gc.font = rtgui_font_default();
         dc->gc.font = rtgui_font_default();
         dc->gc.textalign = RTGUI_ALIGN_LEFT | RTGUI_ALIGN_TOP;
         dc->gc.textalign = RTGUI_ALIGN_LEFT | RTGUI_ALIGN_TOP;
+        dc->gc.textstyle = RTGUI_TEXTSTYLE_NORMAL;
         dc->pixel_format = pixel_format;
         dc->pixel_format = pixel_format;
         dc->pixel_alpha = 255;
         dc->pixel_alpha = 255;
 
 

+ 12 - 15
src/image_png.c

@@ -583,7 +583,7 @@ static void rtgui_image_png_blit(struct rtgui_image *image, struct rtgui_dc *dc,
 
 
     if ((dc->type == RTGUI_DC_CLIENT) || (dc->type == RTGUI_DC_HW && hw_driver->framebuffer == RT_NULL))
     if ((dc->type == RTGUI_DC_CLIENT) || (dc->type == RTGUI_DC_HW && hw_driver->framebuffer == RT_NULL))
     {
     {
-        int dx, dy, start_x;
+        int dx, dy, start_x, start_y;
         rtgui_rect_t r;
         rtgui_rect_t r;
         rtgui_color_t *pixel;
         rtgui_color_t *pixel;
         rt_uint8_t alpha;
         rt_uint8_t alpha;
@@ -605,21 +605,18 @@ static void rtgui_image_png_blit(struct rtgui_image *image, struct rtgui_dc *dc,
         }
         }
 
 
         start_x = x;
         start_x = x;
-        for (; y < rect->y1 + h; ++y)
+        start_y = y;
+        for (; y < start_y + h; ++y)
         {
         {
-            for (x = start_x; x < rect->x1 + w; ++x)
+            for (x = start_x; x < start_x + w; ++x)
             {
             {
-                if (y - rect->y1 < 0 || x - rect->x1 < 0)
-                    continue;
-
-                pixel = (rtgui_color_t*)((rt_uint8_t*)image->data + (y - rect->y1) * image->w * 4 +
-                                         (x - rect->x1) * 4);
+                pixel = (rtgui_color_t*)((rt_uint8_t*)image->data + y * image->w * 4 + x * 4);
 
 
                 alpha = RTGUI_RGB_A(*pixel);
                 alpha = RTGUI_RGB_A(*pixel);
                 if (alpha == 0) continue;
                 if (alpha == 0) continue;
                 if (alpha == 0xff)
                 if (alpha == 0xff)
                 {
                 {
-                    rtgui_dc_draw_color_point(dc, x, y, *pixel);
+                    rtgui_dc_draw_color_point(dc, x + rect->x1, y + rect->y1, *pixel);
                 }
                 }
                 else
                 else
                 {
                 {
@@ -627,26 +624,26 @@ static void rtgui_image_png_blit(struct rtgui_image *image, struct rtgui_dc *dc,
 
 
                     /* draw an alpha blending point */
                     /* draw an alpha blending point */
                     if (hw_driver->framebuffer != RT_NULL)
                     if (hw_driver->framebuffer != RT_NULL)
-                        rtgui_dc_blend_point(dc, x, y, RTGUI_BLENDMODE_BLEND,
+                        rtgui_dc_blend_point(dc, x + rect->x1, y + rect->y1, RTGUI_BLENDMODE_BLEND,
                                              RTGUI_RGB_R(*pixel), RTGUI_RGB_G(*pixel), RTGUI_RGB_B(*pixel), RTGUI_RGB_A(*pixel));
                                              RTGUI_RGB_R(*pixel), RTGUI_RGB_G(*pixel), RTGUI_RGB_B(*pixel), RTGUI_RGB_A(*pixel));
                     else
                     else
                     {
                     {
-                        x = x + dx;
-                        y = y + dy;
+                        int hx = x + rect->x1 + dx;
+                        int hy = y + rect->y1 + dy;
 
 
                         if (dc->type == RTGUI_DC_CLIENT)
                         if (dc->type == RTGUI_DC_CLIENT)
                         {
                         {
-                            if (rtgui_region_contains_point(&(owner->clip), x, y, &r) != RT_EOK)
+                            if (rtgui_region_contains_point(&(owner->clip), hx, hy, &r) != RT_EOK)
                                 continue ;
                                 continue ;
                         }
                         }
 
 
                         /* get background pixel */
                         /* get background pixel */
-                        hw_driver->ops->get_pixel(&bc, x, y);
+                        hw_driver->ops->get_pixel(&bc, hx, hy);
                         /* alpha blending */
                         /* alpha blending */
                         fc = RTGUI_RGB(blending(RTGUI_RGB_R(bc), RTGUI_RGB_R(*pixel),  alpha),
                         fc = RTGUI_RGB(blending(RTGUI_RGB_R(bc), RTGUI_RGB_R(*pixel),  alpha),
                                        blending(RTGUI_RGB_G(bc), RTGUI_RGB_G(*pixel),  alpha),
                                        blending(RTGUI_RGB_G(bc), RTGUI_RGB_G(*pixel),  alpha),
                                        blending(RTGUI_RGB_B(bc), RTGUI_RGB_B(*pixel),  alpha));
                                        blending(RTGUI_RGB_B(bc), RTGUI_RGB_B(*pixel),  alpha));
-                        hw_driver->ops->set_pixel(&fc, x, y);
+                        hw_driver->ops->set_pixel(&fc, hx, hy);
                     }
                     }
                 }
                 }
             }
             }