Author: vince
Date: Thu Dec 22 17:53:15 2011
New Revision: 13328
URL:
http://source.netsurf-browser.org?rev=13328&view=rev
Log:
Move short circuit of 1x1 bitmap plotting to common image content hander helper
Modified:
branches/vince/netsurf-cairo/Docs/BUILDING-GTK
branches/vince/netsurf-cairo/content/content.h
branches/vince/netsurf-cairo/desktop/plot_style.h
branches/vince/netsurf-cairo/image/gif.c
branches/vince/netsurf-cairo/image/image.c
branches/vince/netsurf-cairo/image/image.h
branches/vince/netsurf-cairo/image/image_cache.c
branches/vince/netsurf-cairo/render/html_redraw.c
Modified: branches/vince/netsurf-cairo/Docs/BUILDING-GTK
URL:
http://source.netsurf-browser.org/branches/vince/netsurf-cairo/Docs/BUILD...
==============================================================================
--- branches/vince/netsurf-cairo/Docs/BUILDING-GTK (original)
+++ branches/vince/netsurf-cairo/Docs/BUILDING-GTK Thu Dec 22 17:53:15 2011
@@ -67,7 +67,7 @@
Debian-like OS:
$ apt-get install libglade2-dev libcurl3-dev libxml2-dev libmng-dev
- $ apt-get install librsvg2-dev liblcms1-dev
+ $ apt-get install librsvg2-dev liblcms1-dev libjpeg-dev
Recent OS versions might need libcurl4-dev instead of libcurl3-dev but
note that when it has not been built with OpenSSL, the SSL_CTX is not
Modified: branches/vince/netsurf-cairo/content/content.h
URL:
http://source.netsurf-browser.org/branches/vince/netsurf-cairo/content/co...
==============================================================================
--- branches/vince/netsurf-cairo/content/content.h (original)
+++ branches/vince/netsurf-cairo/content/content.h Thu Dec 22 17:53:15 2011
@@ -112,25 +112,25 @@
struct content_rfc5988_link *rfc5988_link;
};
-
+/** parameters to content redraw */
struct content_redraw_data {
- int x; /** coordinate for top-left of redraw */
- int y; /** coordinate for top-left of redraw */
+ int x; /**< coordinate for top-left of redraw */
+ int y; /**< coordinate for top-left of redraw */
/** dimensions to render content at
* (for scaling contents with intrinsic dimensions) */
- int width; /* horizontal */
- int height; /* vertical */
-
- /** the background colour */
+ int width; /**< horizontal dimension */
+ int height; /**< vertical dimension */
+
+ /** The background colour */
colour background_colour;
/** Scale for redraw
* (for scaling contents without intrinsic dimensions) */
- float scale; /* scale factor */
-
- bool repeat_x; /* whether content is tiled in x direction */
- bool repeat_y; /* whether content is tiled in y direction */
+ float scale; /**< Scale factor for redraw */
+
+ bool repeat_x; /**< whether content is tiled in x direction */
+ bool repeat_y; /**< whether content is tiled in y direction */
};
/* The following are for hlcache */
Modified: branches/vince/netsurf-cairo/desktop/plot_style.h
URL:
http://source.netsurf-browser.org/branches/vince/netsurf-cairo/desktop/pl...
==============================================================================
--- branches/vince/netsurf-cairo/desktop/plot_style.h (original)
+++ branches/vince/netsurf-cairo/desktop/plot_style.h Thu Dec 22 17:53:15 2011
@@ -64,10 +64,15 @@
(((((c0 >> 8) & 0xff) + ((c1 >> 8) & 0xff)) >> 1) << 8)
| \
((((c0 & 0xff) + (c1 & 0xff)) >> 1) << 0)
+/* get a bitmap pixel (image/bitmap.h) into a plot colour */
+#define pixel_to_colour(b) \
+ b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24)
+
/**
* Colour type: XBGR
*/
typedef uint32_t colour;
+
/**
* Magical transparent value
*/
Modified: branches/vince/netsurf-cairo/image/gif.c
URL:
http://source.netsurf-browser.org/branches/vince/netsurf-cairo/image/gif....
==============================================================================
--- branches/vince/netsurf-cairo/image/gif.c (original)
+++ branches/vince/netsurf-cairo/image/gif.c Thu Dec 22 17:53:15 2011
@@ -39,6 +39,7 @@
#include "content/hlcache.h"
#include "desktop/options.h"
#include "desktop/plotters.h"
+#include "image/image.h"
#include "image/bitmap.h"
#include "image/gif.h"
#include "utils/log.h"
@@ -337,7 +338,6 @@
const struct rect *clip, const struct redraw_context *ctx)
{
nsgif_content *gif = (nsgif_content *) c;
- bitmap_flags_t flags = BITMAPF_NONE;
if (gif->current_frame != gif->gif->decoded_frame) {
if (nsgif_get_frame(gif) != GIF_OK) {
@@ -345,16 +345,7 @@
}
}
- if ((data->width == -1) && (data->height == -1))
- return true;
-
- if (data->repeat_x)
- flags |= BITMAPF_REPEAT_X;
- if (data->repeat_y)
- flags |= BITMAPF_REPEAT_Y;
-
- return ctx->plot->bitmap(data->x, data->y, data->width, data->height,
- gif->gif->frame_image, data->background_colour, flags);
+ return image_bitmap_plot(gif->gif->frame_image, data, clip, ctx);
}
Modified: branches/vince/netsurf-cairo/image/image.c
URL:
http://source.netsurf-browser.org/branches/vince/netsurf-cairo/image/imag...
==============================================================================
--- branches/vince/netsurf-cairo/image/image.c (original)
+++ branches/vince/netsurf-cairo/image/image.c Thu Dec 22 17:53:15 2011
@@ -22,8 +22,11 @@
#include <string.h>
#include "utils/errors.h"
+#include "utils/config.h"
+#include "utils/log.h"
+#include "desktop/plotters.h"
+#include "image/bitmap.h"
-#include "image/image.h"
#include "image/bmp.h"
#include "image/gif.h"
#include "image/ico.h"
@@ -35,7 +38,7 @@
#include "image/svg.h"
#include "image/webp.h"
-#include "utils/config.h"
+#include "image/image.h"
/**
* Initialise image content handlers
@@ -114,3 +117,60 @@
return NSERROR_OK;
}
+
+bool image_bitmap_plot(struct bitmap *bitmap,
+ struct content_redraw_data *data,
+ const struct rect *clip,
+ const struct redraw_context *ctx)
+{
+ bitmap_flags_t flags = BITMAPF_NONE;
+
+ int width;
+ int height;
+ unsigned char *pixel;
+ plot_style_t fill_style;
+ struct rect area;
+
+ if (bitmap_get_opaque(bitmap)) {
+ width = bitmap_get_width(bitmap);
+ if (width == 1) {
+ height = bitmap_get_height(bitmap);
+ if (height == 1) {
+ /* optimise 1x1 bitmap plot */
+ pixel = bitmap_get_buffer(bitmap);
+ fill_style.fill_colour = pixel_to_colour(pixel);
+
+ area = *clip;
+
+ if (data->repeat_x != true) {
+ area.x0 = data->x;
+ area.x1 = data->x + data->width;
+ }
+
+ if (data->repeat_y != true) {
+ area.y0 = data->y;
+ area.y1 = data->y + data->height;
+ }
+
+ fill_style.stroke_type = PLOT_OP_TYPE_NONE;
+ fill_style.fill_type = PLOT_OP_TYPE_SOLID;
+ LOG(("area %d,%d -> %d,%d", area.x0, area.y0, area.x1, area.y1));
+ return ctx->plot->rectangle(area.x0, area.y0,
+ area.x1, area.y1,
+ &fill_style);
+
+ }
+ }
+ }
+
+ /* do the plot */
+ if (data->repeat_x)
+ flags |= BITMAPF_REPEAT_X;
+ if (data->repeat_y)
+ flags |= BITMAPF_REPEAT_Y;
+
+ return ctx->plot->bitmap(data->x, data->y, data->width, data->height,
+ bitmap, data->background_colour, flags);
+
+
+}
Modified: branches/vince/netsurf-cairo/image/image.h
URL:
http://source.netsurf-browser.org/branches/vince/netsurf-cairo/image/imag...
==============================================================================
--- branches/vince/netsurf-cairo/image/image.h (original)
+++ branches/vince/netsurf-cairo/image/image.h Thu Dec 22 17:53:15 2011
@@ -25,6 +25,19 @@
#include "utils/errors.h"
+/** Initialise the content handlers for image types.
+ */
nserror image_init(void);
+/** Common image content handler bitmap plot call.
+ *
+ * This plots the specified bitmap controlled by the redraw context
+ * and specific content redraw data. It is a helper specifically
+ * provided for image content handlers redraw callback.
+ */
+bool image_bitmap_plot(struct bitmap *bitmap,
+ struct content_redraw_data *data,
+ const struct rect *clip,
+ const struct redraw_context *ctx);
+
#endif
Modified: branches/vince/netsurf-cairo/image/image_cache.c
URL:
http://source.netsurf-browser.org/branches/vince/netsurf-cairo/image/imag...
==============================================================================
--- branches/vince/netsurf-cairo/image/image_cache.c (original)
+++ branches/vince/netsurf-cairo/image/image_cache.c Thu Dec 22 17:53:15 2011
@@ -22,13 +22,12 @@
#include <stdbool.h>
#include <string.h>
-#include "utils/errors.h"
-#include "utils/utils.h"
+#include "utils/schedule.h"
#include "utils/log.h"
-#include "utils/config.h"
-#include "utils/schedule.h"
#include "content/content_protected.h"
+
#include "image/image_cache.h"
+#include "image/image.h"
/** Age of an entry within the cache
*
@@ -712,7 +711,6 @@
const struct rect *clip,
const struct redraw_context *ctx)
{
- bitmap_flags_t flags = BITMAPF_NONE;
struct image_cache_entry_s *centry;
/* get the cache entry */
@@ -746,14 +744,7 @@
centry->redraw_count++;
centry->redraw_age = image_cache->current_age;
- /* do the plot */
- if (data->repeat_x)
- flags |= BITMAPF_REPEAT_X;
- if (data->repeat_y)
- flags |= BITMAPF_REPEAT_Y;
-
- return ctx->plot->bitmap(data->x, data->y, data->width, data->height,
- centry->bitmap, data->background_colour, flags);
+ return image_bitmap_plot(centry->bitmap, data, clip, ctx);
}
void image_cache_destroy(struct content *content)
Modified: branches/vince/netsurf-cairo/render/html_redraw.c
URL:
http://source.netsurf-browser.org/branches/vince/netsurf-cairo/render/htm...
==============================================================================
--- branches/vince/netsurf-cairo/render/html_redraw.c (original)
+++ branches/vince/netsurf-cairo/render/html_redraw.c Thu Dec 22 17:53:15 2011
@@ -2173,6 +2173,7 @@
width = content_get_width(background->background);
height = content_get_height(background->background);
+ /* ensure clip area only as large as required */
if (!repeat_x) {
if (r.x0 < x)
r.x0 = x;