Remove plotter table global. Pass a redraw context around redraw functions. Knockout could be handled better. Note: untested on most front ends.

svn path=/trunk/netsurf/; revision=12543
This commit is contained in:
Michael Drake 2011-06-30 15:48:07 +00:00
parent a5dc6b9e66
commit eddae6af06
85 changed files with 739 additions and 477 deletions

View File

@ -61,7 +61,8 @@ static bool amiga_dt_anim_convert(struct content *c);
static void amiga_dt_anim_reformat(struct content *c, int width, int height);
static void amiga_dt_anim_destroy(struct content *c);
static bool amiga_dt_anim_redraw(struct content *c,
struct content_redraw_data *data, const struct rect *clip);
struct content_redraw_data *data, const struct rect *clip,
const struct redraw_context *ctx);
static void amiga_dt_anim_open(struct content *c, struct browser_window *bw,
struct content *page, struct box *box,
struct object_params *params);
@ -250,7 +251,8 @@ void amiga_dt_anim_destroy(struct content *c)
}
bool amiga_dt_anim_redraw(struct content *c,
struct content_redraw_data *data, const struct rect *clip)
struct content_redraw_data *data, const struct rect *clip,
const struct redraw_context *ctx)
{
amiga_dt_anim_content *plugin = (amiga_dt_anim_content *) c;
@ -263,7 +265,7 @@ bool amiga_dt_anim_redraw(struct content *c,
if (data->repeat_y)
flags |= BITMAPF_REPEAT_Y;
return plot.bitmap(data->x, data->y, data->width, data->height,
return ctx->plot->bitmap(data->x, data->y, data->width, data->height,
c->bitmap, data->background_colour, flags);
}

View File

@ -54,7 +54,8 @@ static nserror amiga_dt_picture_create(const content_handler *handler,
static bool amiga_dt_picture_convert(struct content *c);
static void amiga_dt_picture_destroy(struct content *c);
static bool amiga_dt_picture_redraw(struct content *c,
struct content_redraw_data *data, const struct rect *clip);
struct content_redraw_data *data, const struct rect *clip,
const struct redraw_context *ctx);
static nserror amiga_dt_picture_clone(const struct content *old, struct content **newc);
static content_type amiga_dt_picture_content_type(lwc_string *mime_type);
@ -220,7 +221,8 @@ void amiga_dt_picture_destroy(struct content *c)
}
bool amiga_dt_picture_redraw(struct content *c,
struct content_redraw_data *data, const struct rect *clip)
struct content_redraw_data *data, const struct rect *clip,
const struct redraw_context *ctx)
{
LOG(("amiga_dt_picture_redraw"));
bitmap_flags_t flags = BITMAPF_NONE;
@ -230,7 +232,7 @@ bool amiga_dt_picture_redraw(struct content *c,
if (data->repeat_y)
flags |= BITMAPF_REPEAT_Y;
return plot.bitmap(data->x, data->y, data->width, data->height,
return ctx->plot->bitmap(data->x, data->y, data->width, data->height,
c->bitmap, data->background_colour, flags);
}

View File

@ -50,7 +50,8 @@ static nserror amiga_dt_sound_create(const content_handler *handler,
static bool amiga_dt_sound_convert(struct content *c);
static void amiga_dt_sound_destroy(struct content *c);
static bool amiga_dt_sound_redraw(struct content *c,
struct content_redraw_data *data, const struct rect *clip);
struct content_redraw_data *data, const struct rect *clip,
const struct redraw_context *ctx);
static void amiga_dt_sound_open(struct content *c, struct browser_window *bw,
struct content *page, struct box *box,
struct object_params *params);
@ -193,7 +194,8 @@ void amiga_dt_sound_destroy(struct content *c)
}
bool amiga_dt_sound_redraw(struct content *c,
struct content_redraw_data *data, const struct rect *clip)
struct content_redraw_data *data, const struct rect *clip,
const struct redraw_context *ctx)
{
plot_style_t pstyle = {
.fill_type = PLOT_OP_TYPE_SOLID,
@ -206,10 +208,10 @@ bool amiga_dt_sound_redraw(struct content *c,
/* this should be some sort of play/stop control */
plot.rectangle(data->x, data->y, data->x + data->width,
ctx->plot->rectangle(data->x, data->y, data->x + data->width,
data->y + data->height, &pstyle);
return plot.text(data->x, data->y+20,
return ctx->plot->text(data->x, data->y+20,
lwc_string_data(content__get_mime_type(c)),
lwc_string_length(content__get_mime_type(c)),
plot_style_font);

View File

@ -3194,6 +3194,10 @@ void ami_do_redraw_limits(struct gui_window *g, struct browser_window *bw,
struct rect clip;
struct RastPort *temprp;
int posx, posy;
struct redraw_context ctx = {
.interactive = true,
.plot = &amiplot
};
if(!g) return;
if(browser_window_redraw_ready(bw) == false) return;
@ -3228,7 +3232,6 @@ void ami_do_redraw_limits(struct gui_window *g, struct browser_window *bw,
if((x1-x0)+(xoffset+x0-sx)>(width)) x1 = (width-(x0-sx)+x0);
if((y1-y0)+(yoffset+y0-sy)>(height)) y1 = (height-(y0-sy)+y0);
plot = amiplot;
glob = &browserglob;
if(option_direct_render == false)
@ -3252,7 +3255,7 @@ void ami_do_redraw_limits(struct gui_window *g, struct browser_window *bw,
posy = bbox->Top - sy;
}
if(browser_window_redraw(bw, posx, posy, &clip))
if(browser_window_redraw(bw, posx, posy, &clip, &ctx))
{
ami_clearclipreg(&browserglob);
@ -3404,8 +3407,11 @@ void ami_do_redraw(struct gui_window_2 *g)
else
{
struct rect clip;
struct redraw_context ctx = {
.interactive = true,
.plot = &amiplot
};
plot = amiplot;
glob = &browserglob;
if(option_direct_render == false)
@ -3425,7 +3431,7 @@ void ami_do_redraw(struct gui_window_2 *g)
clip.y1 = bbox->Top + bbox->Height;
}
if(browser_window_redraw(g->bw, clip.x0 - hcurrent, clip.y0 - vcurrent, &clip))
if(browser_window_redraw(g->bw, clip.x0 - hcurrent, clip.y0 - vcurrent, &clip, &ctx))
{
ami_clearclipreg(&browserglob);

View File

@ -157,6 +157,10 @@ void ami_history_redraw(struct history_window *hw)
{
struct IBox *bbox;
ULONG xs,ys;
struct redraw_context ctx = {
.interactive = true,
.plot = &amiplot
};
GetAttr(SPACE_AreaBox,hw->objects[GID_BROWSER],(ULONG *)&bbox);
GetAttr(SCROLLER_Top,hw->objects[OID_HSCROLL],(ULONG *)&xs);
@ -168,7 +172,7 @@ void ami_history_redraw(struct history_window *hw)
RectFill(glob->rp, 0, 0, bbox->Width - 1, bbox->Height - 1);
history_redraw_rectangle(history_current, xs, ys,
bbox->Width + xs, bbox->Height + ys, 0, 0);
bbox->Width + xs, bbox->Height + ys, 0, 0, &ctx);
glob = &browserglob;

View File

@ -64,7 +64,8 @@ static nserror amiga_icon_create(const content_handler *handler,
static bool amiga_icon_convert(struct content *c);
static void amiga_icon_destroy(struct content *c);
static bool amiga_icon_redraw(struct content *c,
struct content_redraw_data *data, const struct rect *clip);
struct content_redraw_data *data, const struct rect *clip,
const struct redraw_context *ctx);
static nserror amiga_icon_clone(const struct content *old,
struct content **newc);
static content_type amiga_icon_content_type(lwc_string *mime_type);
@ -286,7 +287,8 @@ void amiga_icon_destroy(struct content *c)
*/
bool amiga_icon_redraw(struct content *c,
struct content_redraw_data *data, const struct rect *clip)
struct content_redraw_data *data, const struct rect *clip,
const struct redraw_context *ctx)
{
bitmap_flags_t flags = BITMAPF_NONE;
@ -295,7 +297,7 @@ bool amiga_icon_redraw(struct content *c,
if (data->repeat_y)
flags |= BITMAPF_REPEAT_Y;
return plot.bitmap(data->x, data->y, data->width, data->height,
return ctx->plot->bitmap(data->x, data->y, data->width, data->height,
c->bitmap, data->background_colour, flags);
}

View File

@ -46,7 +46,8 @@ static bool amiga_plugin_hack_convert(struct content *c);
static void amiga_plugin_hack_reformat(struct content *c, int width, int height);
static void amiga_plugin_hack_destroy(struct content *c);
static bool amiga_plugin_hack_redraw(struct content *c,
struct content_redraw_data *data, const struct rect *clip);
struct content_redraw_data *data, const struct rect *clip,
const struct redraw_context *ctx);
static void amiga_plugin_hack_open(struct content *c, struct browser_window *bw,
struct content *page, struct box *box,
struct object_params *params);
@ -143,7 +144,8 @@ void amiga_plugin_hack_destroy(struct content *c)
}
bool amiga_plugin_hack_redraw(struct content *c,
struct content_redraw_data *data, const struct rect *clip)
struct content_redraw_data *data, const struct rect *clip,
const struct redraw_context *ctx)
{
plot_style_t pstyle = {
.fill_type = PLOT_OP_TYPE_SOLID,
@ -154,10 +156,10 @@ bool amiga_plugin_hack_redraw(struct content *c,
LOG(("amiga_plugin_hack_redraw"));
plot.rectangle(data->x, data->y, data->x + data->width,
ctx->plot->rectangle(data->x, data->y, data->x + data->width,
data->y + data->height, &pstyle);
return plot.text(data->x, data->y+20,
return ctx->plot->text(data->x, data->y+20,
lwc_string_data(content__get_mime_type(c)),
lwc_string_length(content__get_mime_type(c)),
plot_style_font);

View File

@ -42,6 +42,10 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap,
struct BitScaleArgs bsa;
int plot_width;
int plot_height;
struct redraw_context ctx = {
.interactive = false,
.plot = &amiplot
};
plot_width = MIN(content_get_width(content), 1024);
plot_height = ((plot_width * bitmap->height) + (bitmap->width / 2)) /
@ -55,9 +59,8 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap,
bitmap->nativebmheight = bitmap->height;
ami_clearclipreg(&browserglob);
current_redraw_browser = curbw;
plot = amiplot;
thumbnail_redraw(content, plot_width, plot_height);
thumbnail_redraw(content, plot_width, plot_height, &ctx);
current_redraw_browser = NULL;

View File

@ -1235,6 +1235,10 @@ void ami_tree_redraw_request(int x, int y, int width, int height, void *data)
struct treeview_window *twin = data;
struct IBox *bbox;
int pos_x, pos_y;
struct redraw_context ctx = {
.interactive = true,
.plot = &amiplot
};
if(!twin->win) return;
// if(tree_get_redraw(twin->tree) == false) return;
@ -1249,7 +1253,7 @@ void ami_tree_redraw_request(int x, int y, int width, int height, void *data)
if(x - pos_x + width > bbox->Width) width = bbox->Width - (x - pos_x);
if(y - pos_y + height > bbox->Height) height = bbox->Height - (y - pos_y);
tree_draw(twin->tree, -pos_x, -pos_y, x, y, width, height);
tree_draw(twin->tree, -pos_x, -pos_y, x, y, width, height, &ctx);
BltBitMapRastPort(twin->globals.bm, x - pos_x, y - pos_y, twin->win->RPort,
bbox->Left + x - pos_x, bbox->Top + y - pos_y, width, height, 0x0C0);

View File

@ -903,6 +903,11 @@ static void browser_redraw_content( struct gui_window * gw, int xoff, int yoff )
CMP_BROWSER b = gw->browser;
struct rect clip;
struct redraw_context ctx = {
.interactive = true,
.plot = &atari_plotters
};
LOG(("%s : %d,%d - %d,%d\n", b->bw->name, b->redraw.area.x0,
b->redraw.area.y0, b->redraw.area.x1, b->redraw.area.y1
));
@ -915,7 +920,7 @@ static void browser_redraw_content( struct gui_window * gw, int xoff, int yoff )
a.y1 = b->redraw.area.y1;
browser_window_redraw( b->bw, -b->scroll.current.x,
-b->scroll.current.y, &a );
-b->scroll.current.y, &a, &ctx );
current_redraw_browser = NULL;
}

View File

@ -238,7 +238,7 @@ static bool plot_path(const float *p, unsigned int n, colour fill, float width,
struct plotter_table plot = {
const struct plotter_table atari_plotter = {
.rectangle = plot_rectangle,
.line = plot_line,
.polygon = plot_polygon,

View File

@ -24,6 +24,8 @@
struct rect;
extern const struct plotter_table atari_plotters;
int atari_plotter_init( char*, char * );
int atari_plotter_finalise( void );
void plot_set_knockout( int set );

View File

@ -312,6 +312,11 @@ void atari_treeview_redraw( NSTREEVIEW tv)
GRECT work;
WindGetGrect( tv->window, WF_WORKXYWH, &work );
struct redraw_context ctx = {
.interactive = true,
.plot = &atari_plotters
};
plotter->resize(plotter, work.g_w, work.g_h);
plotter->move(plotter, work.g_x, work.g_y );
@ -339,7 +344,7 @@ void atari_treeview_redraw( NSTREEVIEW tv)
if (rc_intersect((GRECT *)&tv->rdw_area,(GRECT *)&todo)) {
tree_draw(tv->tree, -tv->window->xpos*16, -tv->window->ypos*16,
todo[0], todo[1], todo[2], todo[3]
todo[0], todo[1], todo[2], todo[3], &ctx
);
}
if (wind_get(tv->window->handle, WF_NEXTXYWH,

View File

@ -1384,6 +1384,11 @@ gboolean nsbeos_history_expose_event(beosWidget *widget,
struct beos_history_window *hw = (struct beos_history_window *)g;
struct browser_window *bw = nsbeos_get_browser_for_gui(hw->g->top_level);
struct redraw_context ctx = {
.interactive = true,
.plot = &nsbeos_plotters
};
current_widget = widget;
current_drawable = widget->window;
current_gc = gdk_gc_new(current_drawable);
@ -1392,7 +1397,7 @@ gboolean nsbeos_history_expose_event(beosWidget *widget,
#endif
plot = nsbeos_plotters;
history_redraw(bw->history);
history_redraw(bw->history, &ctx);
g_object_unref(current_gc);
#ifdef CAIRO_VERSION

View File

@ -71,6 +71,11 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap,
int big_height;
int depth;
struct redraw_context ctx = {
.interactive = false,
.plot = &nsbeos_plotters
};
assert(content);
assert(bitmap);
@ -116,10 +121,8 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap,
/* impose our view on the content... */
nsbeos_current_gc_set(view);
plot = nsbeos_plotters;
/* render the content */
thumbnail_redraw(content, big_width, big_height);
thumbnail_redraw(content, big_width, big_height, &ctx);
view->Sync();
view->UnlockLooper();

View File

@ -920,6 +920,11 @@ void nsbeos_window_expose_event(BView *view, gui_window *g, BMessage *message)
float scale = g->bw->scale;
struct rect clip;
struct redraw_context ctx = {
.interactive = true,
.plot = &nsbeos_plotters
};
assert(g);
assert(g->bw);
@ -947,7 +952,6 @@ void nsbeos_window_expose_event(BView *view, gui_window *g, BMessage *message)
if (view->Window())
view->Window()->BeginViewTransaction();
plot = nsbeos_plotters;
current_redraw_browser = g->bw;
clip.x0 = (int)updateRect.left;
@ -955,7 +959,7 @@ void nsbeos_window_expose_event(BView *view, gui_window *g, BMessage *message)
clip.x1 = (int)updateRect.right + 1;
clip.y1 = (int)updateRect.bottom + 1;
browser_window_redraw(g->bw, 0, 0, &clip);
browser_window_redraw(g->bw, 0, 0, &clip, &ctx);
current_redraw_browser = NULL;

View File

@ -147,6 +147,11 @@ static inline NSRect cocoa_get_caret_rect( BrowserView *view )
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
current_redraw_browser = browser;
struct redraw_context ctx = {
.interactive = true,
.plot = &cocoa_plotters
};
const NSRect *rects = NULL;
NSInteger count = 0;
@ -160,7 +165,7 @@ static inline NSRect cocoa_get_caret_rect( BrowserView *view )
.y1 = cocoa_pt_to_px( NSMaxY( rects[i] ) )
};
browser_window_redraw(browser, 0, 0, &clip);
browser_window_redraw(browser, 0, 0, &clip, &ctx);
}
current_redraw_browser = NULL;

View File

@ -56,10 +56,15 @@
{
[[NSColor clearColor] set];
[NSBezierPath fillRect: rect];
struct redraw_context ctx = {
.interactive = true,
.plot = &cocoa_plotters
};
cocoa_set_clip( rect );
history_redraw( browser->history );
history_redraw( browser->history, &ctx );
}
- (void) mouseUp: (NSEvent *)theEvent;

View File

@ -19,6 +19,7 @@
#import "cocoa/Tree.h"
#import "cocoa/coordinates.h"
#import "cocoa/font.h"
#import "cocoa/plotter.h"
#import "desktop/tree.h"
@ -124,8 +125,13 @@ static void tree_get_window_dimensions( int *width, int *height, void *data )
- (void) drawRect: (NSRect) rect inView: (NSView *) view;
{
struct redraw_context ctx = {
.interactive = true,
.plot = &cocoa_plotters
};
tree_draw( tree, 0, 0, cocoa_pt_to_px( NSMinX( rect ) ), cocoa_pt_to_px( NSMinY( rect )),
cocoa_pt_to_px( NSWidth( rect ) ), cocoa_pt_to_px( NSHeight( rect ) ) );
cocoa_pt_to_px( NSWidth( rect ) ), cocoa_pt_to_px( NSHeight( rect ) ), &ctx );
}
- (void) mouseAction: (browser_mouse_state)state atPoint: (NSPoint)point;

View File

@ -42,7 +42,7 @@ static nserror apple_image_create(const content_handler *handler,
static bool apple_image_convert(struct content *c);
static void apple_image_destroy(struct content *c);
static bool apple_image_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip);
const struct rect *clip, const struct redraw_context *ctx);
static nserror apple_image_clone(const struct content *old,
struct content **newc);
static content_type apple_image_content_type(lwc_string *mime_type);
@ -244,7 +244,7 @@ content_type apple_image_content_type(lwc_string *mime_type)
*/
bool apple_image_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip)
const struct rect *clip, const struct redraw_context *ctx)
{
bitmap_flags_t flags = BITMAPF_NONE;
@ -253,7 +253,7 @@ bool apple_image_redraw(struct content *c, struct content_redraw_data *data,
if (data->repeat_y)
flags |= BITMAPF_REPEAT_Y;
return plot.bitmap(data->x, data->y, data->width, data->height,
return ctx->plot->bitmap(data->x, data->y, data->width, data->height,
c->bitmap, data->background_colour, flags);
}

View File

@ -23,6 +23,8 @@
#import "desktop/plot_style.h"
#import "cocoa/coordinates.h"
extern const struct plotter_table cocoa_plotters;
NSColor *cocoa_convert_colour( colour clr );
void cocoa_update_scale_factor( void );

View File

@ -296,7 +296,7 @@ static bool plot_bitmap(int x, int y, int width, int height,
return true;
}
struct plotter_table plot = {
const struct plotter_table cocoa_plotters = {
.clip = plot_clip,
.arc = plot_arc,
.disc = plot_disc,

View File

@ -30,6 +30,12 @@ bool thumbnail_create(struct hlcache_handle *content, struct bitmap *bitmap,
{
int bwidth = bitmap_get_width( bitmap );
int bheight = bitmap_get_height( bitmap );
struct redraw_context ctx = {
.interactive = false,
.plot = &cocoa_plotters
};
CGColorSpaceRef cspace = CGColorSpaceCreateWithName( kCGColorSpaceGenericRGB );
CGContextRef bitmapContext = CGBitmapContextCreate( bitmap_get_buffer( bitmap ),
bwidth, bheight,
@ -46,7 +52,7 @@ bool thumbnail_create(struct hlcache_handle *content, struct bitmap *bitmap,
[NSGraphicsContext setCurrentContext: [NSGraphicsContext graphicsContextWithGraphicsPort: bitmapContext flipped: YES]];
thumbnail_redraw( content, width, height );
thumbnail_redraw( content, width, height, &ctx );
[NSGraphicsContext setCurrentContext: nil];
CGContextRelease( bitmapContext );

View File

@ -490,7 +490,7 @@ void content__request_redraw(struct content *c,
*/
bool content_redraw(hlcache_handle *h, struct content_redraw_data *data,
const struct rect *clip)
const struct rect *clip, const struct redraw_context *ctx)
{
struct content *c = hlcache_handle_get_content(h);
@ -506,7 +506,7 @@ bool content_redraw(hlcache_handle *h, struct content_redraw_data *data,
return true;
}
return c->handler->redraw(c, data, clip);
return c->handler->redraw(c, data, clip, ctx);
}

View File

@ -33,6 +33,7 @@
#include "utils/config.h"
#include "utils/errors.h"
#include "utils/http.h"
#include "utils/types.h"
#include "content/content_factory.h"
#include "content/content_type.h"
#include "desktop/mouse.h"
@ -45,6 +46,8 @@ struct llcache_handle;
struct hlcache_handle;
struct object_params;
struct rect;
struct redraw_context;
/** Status of a content */
typedef enum {
@ -149,7 +152,7 @@ void content_mouse_track(struct hlcache_handle *h, struct browser_window *bw,
void content_mouse_action(struct hlcache_handle *h, struct browser_window *bw,
browser_mouse_state mouse, int x, int y);
bool content_redraw(struct hlcache_handle *h, struct content_redraw_data *data,
const struct rect *clip);
const struct rect *clip, const struct redraw_context *ctx);
void content_open(struct hlcache_handle *h, struct browser_window *bw,
struct content *page, struct box *box,
struct object_params *params);

View File

@ -36,6 +36,8 @@
struct bitmap;
struct content;
struct rect;
struct redraw_context;
struct content_handler {
nserror (*create)(const content_handler *handler,
@ -55,7 +57,8 @@ struct content_handler {
void (*mouse_action)(struct content *c, struct browser_window *bw,
browser_mouse_state mouse, int x, int y);
bool (*redraw)(struct content *c, struct content_redraw_data *data,
const struct rect *clip);
const struct rect *clip,
const struct redraw_context *ctx);
void (*open)(struct content *c, struct browser_window *bw,
struct content *page,
struct box *box,

View File

@ -94,8 +94,9 @@ static void browser_window_mouse_drag_end(struct browser_window *bw,
/* exported interface, documented in browser.h */
bool browser_window_redraw(struct browser_window *bw, int x, int y,
const struct rect *clip)
const struct rect *clip, const struct redraw_context *ctx)
{
struct redraw_context new_ctx = *ctx;
int width = 0;
int height = 0;
bool plot_ok = true;
@ -109,17 +110,20 @@ bool browser_window_redraw(struct browser_window *bw, int x, int y,
if (bw->current_content == NULL) {
/* Browser window has no content, render blank fill */
plot.clip(clip);
return plot.rectangle(clip->x0, clip->y0, clip->x1, clip->y1,
ctx->plot->clip(clip);
return ctx->plot->rectangle(clip->x0, clip->y0,
clip->x1, clip->y1,
plot_style_fill_white);
}
/* Browser window has content */
if (bw->browser_window_type != BROWSER_WINDOW_IFRAME &&
plot.option_knockout)
knockout_plot_start(&plot);
ctx->plot->option_knockout) {
knockout_plot_start(ctx, &new_ctx);
}
plot.clip(clip);
/* Browser window has content */
new_ctx.plot->clip(clip);
content_type = content_get_type(bw->current_content);
if (content_type != CONTENT_HTML && content_type != CONTENT_TEXTPLAIN) {
@ -129,7 +133,7 @@ bool browser_window_redraw(struct browser_window *bw, int x, int y,
/* Non-HTML may not fill viewport to extents, so plot white
* background fill */
plot_ok &= plot.rectangle(clip->x0, clip->y0,
plot_ok &= new_ctx.plot->rectangle(clip->x0, clip->y0,
clip->x1, clip->y1, plot_style_fill_white);
}
@ -145,11 +149,12 @@ bool browser_window_redraw(struct browser_window *bw, int x, int y,
data.repeat_y = false;
/* Render the content */
plot_ok &= content_redraw(bw->current_content, &data, clip);
plot_ok &= content_redraw(bw->current_content, &data, clip, &new_ctx);
if (bw->browser_window_type != BROWSER_WINDOW_IFRAME &&
plot.option_knockout)
ctx->plot->option_knockout) {
knockout_plot_end();
}
return plot_ok;
}

View File

@ -268,6 +268,7 @@ bool browser_window_stop_available(struct browser_window *bw);
* \param x coordinate for top-left of redraw
* \param y coordinate for top-left of redraw
* \param clip clip rectangle coordinates
* \param ctx redraw context
* \return true if successful, false otherwise
*
* The clip rectangle is guaranteed to be filled to its extents, so there is
@ -280,7 +281,7 @@ bool browser_window_stop_available(struct browser_window *bw);
* Units for x, y and clip are pixels.
*/
bool browser_window_redraw(struct browser_window *bw, int x, int y,
const struct rect *clip);
const struct rect *clip, const struct redraw_context *ctx);
/**
* Check whether browser window is ready for redraw

View File

@ -89,7 +89,7 @@ static int history_layout_subtree(struct history *history,
static bool history_redraw_entry(struct history *history,
struct history_entry *entry,
int x0, int y0, int x1, int y1,
int x, int y, bool clip);
int x, int y, bool clip, const struct redraw_context *ctx);
static struct history_entry *history_find_position(struct history_entry *entry,
int x, int y);
static bool history_enumerate_entry(const struct history *history,
@ -558,40 +558,39 @@ void history_size(struct history *history, int *width, int *height)
/**
* Redraw a history.
*
* \param history history to render
*
* The current plotter is used.
* \param history history to render
* \param ctx current redraw context
*/
bool history_redraw(struct history *history)
bool history_redraw(struct history *history, const struct redraw_context *ctx)
{
if (!history->start)
return true;
return history_redraw_entry(history, history->start, 0, 0, 0, 0, 0, 0, false);
return history_redraw_entry(history, history->start, 0, 0, 0, 0, 0, 0,
false, ctx);
}
/**
* Redraw part of a history.
*
* \param history history to render
* \param x0 left X co-ordinate of redraw area
* \param y0 top Y co-ordinate of redraw area
* \param x1 right X co-ordinate of redraw area
* \param y1 lower Y co-ordinate of redraw area
* \param x start X co-ordinate on plot canvas
* \param y start Y co-ordinate on plot canvas
*
* The current plotter is used.
* \param history history to render
* \param x0 left X co-ordinate of redraw area
* \param y0 top Y co-ordinate of redraw area
* \param x1 right X co-ordinate of redraw area
* \param y1 lower Y co-ordinate of redraw area
* \param x start X co-ordinate on plot canvas
* \param y start Y co-ordinate on plot canvas
* \param ctx current redraw context
*/
bool history_redraw_rectangle(struct history *history,
int x0, int y0, int x1, int y1,
int x, int y)
int x, int y, const struct redraw_context *ctx)
{
if (!history->start)
return true;
return history_redraw_entry(history, history->start,
x0, y0, x1, y1, x, y, true);
x0, y0, x1, y1, x, y, true, ctx);
}
/**
@ -599,13 +598,15 @@ bool history_redraw_rectangle(struct history *history,
*
* \param history history containing the entry
* \param history_entry entry to render
* \param ctx current redraw context
*/
bool history_redraw_entry(struct history *history,
struct history_entry *entry,
int x0, int y0, int x1, int y1,
int x, int y, bool clip)
int x, int y, bool clip, const struct redraw_context *ctx)
{
const struct plotter_table *plot = ctx->plot;
size_t char_offset;
int actual_x;
struct history_entry *child;
@ -626,14 +627,14 @@ bool history_redraw_entry(struct history *history,
rect.y0 = y0 + yoffset;
rect.x1 = x1 + xoffset;
rect.y1 = y1 + yoffset;
if(!plot.clip(&rect))
if(!plot->clip(&rect))
return false;
}
if (!plot.bitmap(entry->x + xoffset, entry->y + yoffset, WIDTH, HEIGHT,
if (!plot->bitmap(entry->x + xoffset, entry->y + yoffset, WIDTH, HEIGHT,
entry->bitmap, 0xffffff, 0))
return false;
if (!plot.rectangle(entry->x - 1 + xoffset,
if (!plot->rectangle(entry->x - 1 + xoffset,
entry->y - 1 + yoffset,
entry->x + xoffset + WIDTH,
entry->y + yoffset + HEIGHT,
@ -649,29 +650,30 @@ bool history_redraw_entry(struct history *history,
fstyle.foreground = c;
fstyle.weight = entry == history->current ? 900 : 400;
if (!plot.text(entry->x + xoffset, entry->y + HEIGHT + 12 + yoffset,
if (!plot->text(entry->x + xoffset, entry->y + HEIGHT + 12 + yoffset,
entry->page.title, char_offset, &fstyle))
return false;
for (child = entry->forward; child; child = child->next) {
if (!plot.line(entry->x + WIDTH + xoffset,
if (!plot->line(entry->x + WIDTH + xoffset,
entry->y + HEIGHT / 2 + yoffset,
entry->x + WIDTH + tailsize + xoffset,
entry->y + HEIGHT / 2 + yoffset,
plot_style_stroke_history))
return false;
if (!plot.line(entry->x + WIDTH + tailsize + xoffset,
if (!plot->line(entry->x + WIDTH + tailsize + xoffset,
entry->y + HEIGHT / 2 + yoffset,
child->x - tailsize +xoffset,
child->y + HEIGHT / 2 + yoffset,
plot_style_stroke_history))
return false;
if (!plot.line(child->x - tailsize + xoffset,
if (!plot->line(child->x - tailsize + xoffset,
child->y + HEIGHT / 2 + yoffset,
child->x + xoffset, child->y + HEIGHT / 2 + yoffset,
plot_style_stroke_history))
return false;
if (!history_redraw_entry(history, child, x0, y0, x1, y1, x, y, clip))
if (!history_redraw_entry(history, child, x0, y0, x1, y1, x, y,
clip, ctx))
return false;
}

View File

@ -41,9 +41,10 @@ void history_forward(struct browser_window *bw, struct history *history);
bool history_back_available(struct history *history);
bool history_forward_available(struct history *history);
void history_size(struct history *history, int *width, int *height);
bool history_redraw(struct history *history);
bool history_redraw(struct history *history, const struct redraw_context *ctx);
bool history_redraw_rectangle(struct history *history,
int x0, int y0, int x1, int y1, int x, int y);
int x0, int y0, int x1, int y1, int x, int y,
const struct redraw_context *ctx);
bool history_click(struct browser_window *bw, struct history *history,
int x, int y, bool new_window);
const char *history_position_url(struct history *history, int x, int y);

View File

@ -80,7 +80,6 @@ struct knockout_box;
struct knockout_entry;
static void knockout_set_plotters(void);
static void knockout_calculate(int x0, int y0, int x1, int y1, struct knockout_box *box);
static bool knockout_plot_fill_recursive(struct knockout_box *box, plot_style_t *plot_style);
static bool knockout_plot_bitmap_recursive(struct knockout_box *box,
@ -228,15 +227,18 @@ static int nested_depth = 0;
/**
* Start a knockout plotting session
*
* \param plotter the plotter to use
* \param ctx the redraw context with real plotter table
* \param knk_ctx updated to copy of ctx, with plotter table replaced
* \return true on success, false otherwise
*/
bool knockout_plot_start(struct plotter_table *plotter)
bool knockout_plot_start(const struct redraw_context *ctx,
struct redraw_context *knk_ctx)
{
/* check if we're recursing */
if (nested_depth++ > 0) {
/* we should already have the knockout renderer as default */
assert(plotter->rectangle == knockout_plotters.rectangle);
assert(ctx->plot->rectangle == knockout_plotters.rectangle);
*knk_ctx = *ctx;
return true;
}
@ -244,9 +246,12 @@ bool knockout_plot_start(struct plotter_table *plotter)
if (knockout_entry_cur > 0)
knockout_plot_end();
/* take over the plotter */
real_plot = *plotter;
knockout_set_plotters();
/* get copy of real plotter table */
real_plot = *(ctx->plot);
/* set up knockout rendering context */
*knk_ctx = *ctx;
knk_ctx->plot = &knockout_plotters;
return true;
}
@ -286,13 +291,10 @@ bool knockout_plot_flush(void)
knockout_polygon_cur, KNOCKOUT_POLYGONS));
#endif
/* release our plotter */
plot = real_plot;
for (i = 0; i < knockout_entry_cur; i++) {
switch (knockout_entries[i].type) {
case KNOCKOUT_PLOT_RECTANGLE:
success &= plot.rectangle(
success &= real_plot.rectangle(
knockout_entries[i].data.rectangle.x0,
knockout_entries[i].data.rectangle.y0,
knockout_entries[i].data.rectangle.x1,
@ -300,7 +302,7 @@ bool knockout_plot_flush(void)
&knockout_entries[i].data.rectangle.plot_style);
break;
case KNOCKOUT_PLOT_LINE:
success &= plot.line(
success &= real_plot.line(
knockout_entries[i].data.line.x0,
knockout_entries[i].data.line.y0,
knockout_entries[i].data.line.x1,
@ -308,7 +310,7 @@ bool knockout_plot_flush(void)
&knockout_entries[i].data.line.plot_style);
break;
case KNOCKOUT_PLOT_POLYGON:
success &= plot.polygon(
success &= real_plot.polygon(
knockout_entries[i].data.polygon.p,
knockout_entries[i].data.polygon.n,
&knockout_entries[i].data.polygon.plot_style);
@ -319,7 +321,7 @@ bool knockout_plot_flush(void)
success &= knockout_plot_fill_recursive(box,
&knockout_entries[i].data.fill.plot_style);
else if (!knockout_entries[i].box->deleted)
success &= plot.rectangle(
success &= real_plot.rectangle(
knockout_entries[i].data.fill.x0,
knockout_entries[i].data.fill.y0,
knockout_entries[i].data.fill.x1,
@ -327,11 +329,11 @@ bool knockout_plot_flush(void)
&knockout_entries[i].data.fill.plot_style);
break;
case KNOCKOUT_PLOT_CLIP:
success &= plot.clip(
success &= real_plot.clip(
&knockout_entries[i].data.clip);
break;
case KNOCKOUT_PLOT_TEXT:
success &= plot.text(
success &= real_plot.text(
knockout_entries[i].data.text.x,
knockout_entries[i].data.text.y,
knockout_entries[i].data.text.text,
@ -339,14 +341,14 @@ bool knockout_plot_flush(void)
&knockout_entries[i].data.text.font_style);
break;
case KNOCKOUT_PLOT_DISC:
success &= plot.disc(
success &= real_plot.disc(
knockout_entries[i].data.disc.x,
knockout_entries[i].data.disc.y,
knockout_entries[i].data.disc.radius,
&knockout_entries[i].data.disc.plot_style);
break;
case KNOCKOUT_PLOT_ARC:
success &= plot.arc(
success &= real_plot.arc(
knockout_entries[i].data.arc.x,
knockout_entries[i].data.arc.y,
knockout_entries[i].data.arc.radius,
@ -360,7 +362,7 @@ bool knockout_plot_flush(void)
success &= knockout_plot_bitmap_recursive(box,
&knockout_entries[i]);
} else if (!knockout_entries[i].box->deleted) {
success &= plot.bitmap(
success &= real_plot.bitmap(
knockout_entries[i].data.
bitmap.x,
knockout_entries[i].data.
@ -378,11 +380,11 @@ bool knockout_plot_flush(void)
}
break;
case KNOCKOUT_PLOT_GROUP_START:
success &= plot.group_start(
success &= real_plot.group_start(
knockout_entries[i].data.group_start.name);
break;
case KNOCKOUT_PLOT_GROUP_END:
success &= plot.group_end();
success &= real_plot.group_end();
break;
}
}
@ -392,26 +394,10 @@ bool knockout_plot_flush(void)
knockout_polygon_cur = 0;
knockout_list = NULL;
/* re-instate knockout plotters if we are still active */
if (nested_depth > 0)
knockout_set_plotters();
return success;
}
/**
* Override the current plotters with the knockout plotters
*/
void knockout_set_plotters(void)
{
plot = knockout_plotters;
if (!real_plot.group_start)
plot.group_start = NULL;
if (!real_plot.group_end)
plot.group_end = NULL;
}
/**
* Knockout a section of previous rendering
*
@ -548,7 +534,7 @@ bool knockout_plot_fill_recursive(struct knockout_box *box, plot_style_t *plot_s
if (parent->child)
knockout_plot_fill_recursive(parent->child, plot_style);
else
success &= plot.rectangle(parent->bbox.x0,
success &= real_plot.rectangle(parent->bbox.x0,
parent->bbox.y0,
parent->bbox.x1,
parent->bbox.y1,
@ -570,8 +556,8 @@ bool knockout_plot_bitmap_recursive(struct knockout_box *box,
if (parent->child)
knockout_plot_bitmap_recursive(parent->child, entry);
else {
success &= plot.clip(&parent->bbox);
success &= plot.bitmap(entry->data.bitmap.x,
success &= real_plot.clip(&parent->bbox);
success &= real_plot.bitmap(entry->data.bitmap.x,
entry->data.bitmap.y,
entry->data.bitmap.width,
entry->data.bitmap.height,
@ -810,6 +796,10 @@ bool knockout_plot_bitmap(int x, int y, int width, int height,
bool knockout_plot_group_start(const char *name)
{
if (real_plot.group_start == NULL) {
return true;
}
knockout_entries[knockout_entry_cur].data.group_start.name = name;
knockout_entries[knockout_entry_cur].type = KNOCKOUT_PLOT_GROUP_START;
if (++knockout_entry_cur >= KNOCKOUT_ENTRIES)
@ -819,6 +809,10 @@ bool knockout_plot_group_start(const char *name)
bool knockout_plot_group_end(void)
{
if (real_plot.group_end == NULL) {
return true;
}
knockout_entries[knockout_entry_cur].type = KNOCKOUT_PLOT_GROUP_END;
if (++knockout_entry_cur >= KNOCKOUT_ENTRIES)
knockout_plot_flush();

View File

@ -26,7 +26,8 @@
#include "desktop/plotters.h"
bool knockout_plot_start(struct plotter_table *plotter);
bool knockout_plot_start(const struct redraw_context *ctx,
struct redraw_context *knk_ctx);
bool knockout_plot_end(void);
extern const struct plotter_table knockout_plotters;

View File

@ -27,7 +27,6 @@
#include "css/css.h"
#include "content/content.h"
#include "desktop/plot_style.h"
#include "utils/types.h"
struct bitmap;
@ -137,9 +136,6 @@ struct plotter_table {
bool option_knockout; /**< set if knockout rendering is required */
};
/** Current plotters, must be assigned before use. */
extern struct plotter_table plot;
enum path_command {
PLOTTER_PATH_MOVE,
PLOTTER_PATH_CLOSE,

View File

@ -34,6 +34,7 @@
#include "render/box.h"
#include "utils/log.h"
#include "utils/talloc.h"
#include "utils/types.h"
/* Default print settings */
#define DEFAULT_PAGE_WIDTH 595
@ -123,8 +124,11 @@ bool print_draw_next_page(const struct printer *printer,
{
struct rect clip;
struct content_redraw_data data;
plot = *(printer->plotter);
struct redraw_context ctx = {
.interactive = false,
.plot = printer->plotter
};
html_redraw_printing_top_cropped = INT_MAX;
clip.x0 = 0;
@ -145,7 +149,7 @@ bool print_draw_next_page(const struct printer *printer,
html_redraw_printing_border = clip.y1;
printer->print_next_page();
if (!content_redraw(printed_content, &data, &clip))
if (!content_redraw(printed_content, &data, &clip, &ctx))
return false;
done_height += page_content_height -

View File

@ -139,13 +139,17 @@ void scrollbar_destroy(struct scrollbar *s)
* \param y1 bottom border of the outline
* \param c base colour of the outline, the other colours are created by
* lightening or darkening this one
* \param ctx current redraw context
* \param inset true for inset outline, false for an outset one
* \return
*/
static inline bool scrollbar_redraw_scrollbar_rectangle(int x0, int y0,
int x1, int y1, colour c, bool inset)
int x1, int y1, colour c, bool inset,
const struct redraw_context *ctx)
{
const struct plotter_table *plot = ctx->plot;
static plot_style_t c0 = {
.stroke_type = PLOT_OP_TYPE_SOLID,
.stroke_width = 1,
@ -171,12 +175,12 @@ static inline bool scrollbar_redraw_scrollbar_rectangle(int x0, int y0,
c2.stroke_colour = blend_colour(c0.stroke_colour, c1.stroke_colour);
/* Plot the outline */
if (!plot.line(x0, y0, x1, y0, &c0)) return false;
if (!plot.line(x1, y0, x1, y1 + 1, &c1)) return false;
if (!plot.line(x1, y0, x1, y0 + 1, &c2)) return false;
if (!plot.line(x1, y1, x0, y1, &c1)) return false;
if (!plot.line(x0, y1, x0, y0, &c0)) return false;
if (!plot.line(x0, y1, x0, y1 + 1, &c2)) return false;
if (!plot->line(x0, y0, x1, y0, &c0)) return false;
if (!plot->line(x1, y0, x1, y1 + 1, &c1)) return false;
if (!plot->line(x1, y0, x1, y0 + 1, &c2)) return false;
if (!plot->line(x1, y1, x0, y1, &c1)) return false;
if (!plot->line(x0, y1, x0, y0, &c0)) return false;
if (!plot->line(x0, y1, x0, y1 + 1, &c2)) return false;
return true;
}
@ -186,8 +190,10 @@ static inline bool scrollbar_redraw_scrollbar_rectangle(int x0, int y0,
* Exported function. Documented in scrollbar.h
*/
bool scrollbar_redraw(struct scrollbar *s, int x, int y,
const struct rect *clip, float scale)
const struct rect *clip, float scale,
const struct redraw_context *ctx)
{
const struct plotter_table *plot = ctx->plot;
int w = SCROLLBAR_WIDTH;
int bar_pos, bar_c0, bar_c1;
int v[6]; /* array of triangle vertices */
@ -237,17 +243,17 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
/* scrollbar outline */
if (!scrollbar_redraw_scrollbar_rectangle(x0, y0, x1, y1,
scrollbar_widget_bg_colour, true))
scrollbar_widget_bg_colour, true, ctx))
return false;
/* left arrow icon border */
if (!scrollbar_redraw_scrollbar_rectangle(x0 + 1,
y0 + 1,
x0 + w - 2,
y1 - 1,
scrollbar_widget_fg_colour, false))
scrollbar_widget_fg_colour, false, ctx))
return false;
/* left arrow icon background */
if (!plot.rectangle(x0 + 2,
if (!plot->rectangle(x0 + 2,
y0 + 2,
x0 + w - 2,
y1 - 1,
@ -260,10 +266,10 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
v[3] = y0 + w / 4;
v[4] = x0 + w * 3 / 4;
v[5] = y0 + w * 3 / 4;
if (!plot.polygon(v, 3, &pstyle_scrollbar_widget_arrow_colour))
if (!plot->polygon(v, 3, &pstyle_scrollbar_widget_arrow_colour))
return false;
/* scrollbar well background */
if (!plot.rectangle(x0 + w - 1,
if (!plot->rectangle(x0 + w - 1,
y0 + 1,
x1 - w + 2,
y1,
@ -274,9 +280,9 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
y0 + 1,
bar_c1,
y1 - 1,
scrollbar_widget_fg_colour, false))
scrollbar_widget_fg_colour, false, ctx))
return false;
if (!plot.rectangle(bar_c0 + 1,
if (!plot->rectangle(bar_c0 + 1,
y0 + 2,
bar_c1,
y1 - 1,
@ -287,10 +293,10 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
y0 + 1,
x1 - 1,
y1 - 1,
scrollbar_widget_fg_colour, false))
scrollbar_widget_fg_colour, false, ctx))
return false;
/* right arrow icon background */
if (!plot.rectangle(x1 - w + 3,
if (!plot->rectangle(x1 - w + 3,
y0 + 2,
x1 - 1,
y1 - 1,
@ -303,7 +309,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
v[3] = y0 + w / 4;
v[4] = x1 - w * 3 / 4 + 1;
v[5] = y0 + w * 3 / 4;
if (!plot.polygon(v, 3, &pstyle_scrollbar_widget_arrow_colour))
if (!plot->polygon(v, 3, &pstyle_scrollbar_widget_arrow_colour))
return false;
} else {
/* scrollbar is vertical */
@ -311,7 +317,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
/* outline */
if (!scrollbar_redraw_scrollbar_rectangle(x0, y0, x1, y1,
scrollbar_widget_bg_colour,
true))
true, ctx))
return false;
/* top arrow background */
if (!scrollbar_redraw_scrollbar_rectangle(x0 + 1,
@ -319,9 +325,9 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
x1 - 1,
y0 + w - 2,
scrollbar_widget_fg_colour,
false))
false, ctx))
return false;
if (!plot.rectangle(x0 + 2,
if (!plot->rectangle(x0 + 2,
y0 + 2,
x1 - 1,
y0 + w - 2,
@ -334,10 +340,10 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
v[3] = y0 + w * 3 / 4;
v[4] = x0 + w * 3 / 4;
v[5] = y0 + w * 3 / 4;
if (!plot.polygon(v, 3, &pstyle_scrollbar_widget_arrow_colour))
if (!plot->polygon(v, 3, &pstyle_scrollbar_widget_arrow_colour))
return false;
/* scrollbar well background */
if (!plot.rectangle(x0 + 1,
if (!plot->rectangle(x0 + 1,
y0 + w - 1,
x1,
y1 - w + 2,
@ -348,9 +354,9 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
bar_c0,
x1 - 1,
bar_c1,
scrollbar_widget_fg_colour, false))
scrollbar_widget_fg_colour, false, ctx))
return false;
if (!plot.rectangle(x0 + 2,
if (!plot->rectangle(x0 + 2,
bar_c0 + 1,
x1 - 1,
bar_c1,
@ -361,9 +367,9 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
y1 - w + 2,
x1 - 1,
y1 - 1,
scrollbar_widget_fg_colour, false))
scrollbar_widget_fg_colour, false, ctx))
return false;
if (!plot.rectangle(x0 + 2,
if (!plot->rectangle(x0 + 2,
y1 - w + 3,
x1 - 1,
y1 - 1,
@ -376,7 +382,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
v[3] = y1 - w * 3 / 4 + 1;
v[4] = x0 + w * 3 / 4;
v[5] = y1 - w * 3 / 4 + 1;
if (!plot.polygon(v, 3, &pstyle_scrollbar_widget_arrow_colour))
if (!plot->polygon(v, 3, &pstyle_scrollbar_widget_arrow_colour))
return false;
}

View File

@ -93,10 +93,12 @@ void scrollbar_destroy(struct scrollbar *s);
* \param y the Y coordinate to draw the scrollbar at
* \param clip the clipping rectangle
* \param scale scale for the redraw
* \param ctx current redraw context
* \return true on succes false otherwise
*/
bool scrollbar_redraw(struct scrollbar *s, int x, int y,
const struct rect *clip, float scale);
const struct rect *clip, float scale,
const struct redraw_context *ctx);
/**
* Set the scroll value of the scrollbar.

View File

@ -720,14 +720,16 @@ bool textarea_reflow(struct text_area *ta, unsigned int line)
* Handle redraw requests for text areas
*
* \param redraw Redraw request block
* \param x0 left X coordinate of redraw area
* \param y0 top Y coordinate of redraw area
* \param x1 right X coordinate of redraw area
* \param y1 bottom Y coordinate of redraw area
* \param x0 left X coordinate of redraw area
* \param y0 top Y coordinate of redraw area
* \param x1 right X coordinate of redraw area
* \param y1 bottom Y coordinate of redraw area
* \param ctx current redraw context
*/
void textarea_redraw(struct text_area *ta, int x, int y,
const struct rect *clip)
const struct rect *clip, const struct redraw_context *ctx)
{
const struct plotter_table *plot = ctx->plot;
int line0, line1, line;
int chars, offset, text_y_offset, text_y_offset_baseline;
unsigned int c_pos, c_len, b_start, b_end, line_len;
@ -775,9 +777,9 @@ void textarea_redraw(struct text_area *ta, int x, int y,
if (r.y1 > y + ta->vis_height)
r.y1 = y + ta->vis_height;
plot.clip(&r);
plot.rectangle(r.x0, r.y0, r.x1, r.y1, &plot_style_fill_bg);
plot.rectangle(x, y,
plot->clip(&r);
plot->rectangle(r.x0, r.y0, r.x1, r.y1, &plot_style_fill_bg);
plot->rectangle(x, y,
x + ta->vis_width - 1, y + ta->vis_height - 1,
&pstyle_stroke_border);
@ -785,7 +787,7 @@ void textarea_redraw(struct text_area *ta, int x, int y,
r.x0 = x + MARGIN_LEFT;
if (r.x1 > x + ta->vis_width - MARGIN_RIGHT)
r.x1 = x + ta->vis_width - MARGIN_RIGHT;
plot.clip(&r);
plot->clip(&r);
if (line0 > 0)
c_pos = utf8_bounded_length(ta->text,
@ -869,7 +871,7 @@ void textarea_redraw(struct text_area *ta, int x, int y,
b_start]),
b_end, &r.x1);
r.x1 += r.x0;
plot.rectangle(r.x0 - ta->scroll_x, y +
plot->rectangle(r.x0 - ta->scroll_x, y +
line * ta->line_height +
1 - ta->scroll_y + text_y_offset,
r.x1 - ta->scroll_x,
@ -887,7 +889,7 @@ void textarea_redraw(struct text_area *ta, int x, int y,
(ta->flags & TEXTAREA_READONLY) ?
READONLY_BG : BACKGROUND_COL,
plot.text(x + MARGIN_LEFT - ta->scroll_x,
plot->text(x + MARGIN_LEFT - ta->scroll_x,
r.y0 - ta->scroll_y,
ta->text + ta->lines[line].b_start,
ta->lines[line].b_length,
@ -904,7 +906,7 @@ void textarea_redraw(struct text_area *ta, int x, int y,
y += ta->caret_y + text_y_offset;
if (y + caret_height >= clip->y0 && y <= clip->y1)
/* Caret in vertical clip range; plot */
plot.line(x + ta->caret_x, y + ta->caret_y,
plot->line(x + ta->caret_x, y + ta->caret_y,
x + ta->caret_x,
y + ta->caret_y + ta->line_height,
&pstyle_stroke_caret);

View File

@ -47,7 +47,7 @@ int textarea_get_text(struct text_area *ta, char *buf, unsigned int len);
bool textarea_set_caret(struct text_area *ta, int caret);
int textarea_get_caret(struct text_area *ta);
void textarea_redraw(struct text_area *ta, int x, int y,
const struct rect *clip);
const struct rect *clip, const struct redraw_context *ctx);
bool textarea_keypress(struct text_area *ta, uint32_t key);
bool textarea_mouse_action(struct text_area *ta, browser_mouse_state mouse,
int x, int y);

View File

@ -57,8 +57,9 @@ static float thumbnail_get_redraw_scale(struct hlcache_handle *content,
/* exported interface, documented in thumbnail.h */
bool thumbnail_redraw(struct hlcache_handle *content,
int width, int height)
int width, int height, const struct redraw_context *ctx)
{
struct redraw_context new_ctx = *ctx;
struct rect clip;
struct content_redraw_data data;
float scale;
@ -66,8 +67,8 @@ bool thumbnail_redraw(struct hlcache_handle *content,
assert(content);
if (plot.option_knockout)
knockout_plot_start(&plot);
if (ctx->plot->option_knockout)
knockout_plot_start(ctx, &new_ctx);
/* No selection */
current_redraw_browser = NULL;
@ -78,10 +79,10 @@ bool thumbnail_redraw(struct hlcache_handle *content,
clip.x1 = width;
clip.y1 = height;
plot.clip(&clip);
new_ctx.plot->clip(&clip);
/* Plot white background */
plot_ok &= plot.rectangle(clip.x0, clip.y0, clip.x1, clip.y1,
plot_ok &= new_ctx.plot->rectangle(clip.x0, clip.y0, clip.x1, clip.y1,
plot_style_fill_white);
/* Find the scale we're using */
@ -99,9 +100,9 @@ bool thumbnail_redraw(struct hlcache_handle *content,
data.repeat_y = false;
/* Render the content */
plot_ok &= content_redraw(content, &data, &clip);
plot_ok &= content_redraw(content, &data, &clip, &new_ctx);
if (plot.option_knockout)
if (ctx->plot->option_knockout)
knockout_plot_end();
return plot_ok;

View File

@ -24,6 +24,7 @@
#define _NETSURF_DESKTOP_THUMBNAIL_H_
#include <stdbool.h>
#include "utils/types.h"
struct hlcache_handle;
struct bitmap;
@ -37,6 +38,7 @@ struct bitmap;
* \param content The content to redraw for thumbnail
* \param width The thumbnail width
* \param height The thumbnail height
* \param ctx current redraw context
* \return true if successful, false otherwise
*
* The thumbnail is guaranteed to be filled to its width/height extents, so
@ -45,7 +47,7 @@ struct bitmap;
* Units for width and height are pixels.
*/
bool thumbnail_redraw(struct hlcache_handle *content,
int width, int height);
int width, int height, const struct redraw_context *ctx);
/* In platform specific thumbnail.c. */

View File

@ -1570,14 +1570,17 @@ struct node *tree_node_get_next(struct node *node)
/**
* Draws an element's expansion icon
*
* \param tree the tree to draw the expansion for
* \param element the element to draw the expansion for
* \param tree the tree to draw the expansion for
* \param element the element to draw the expansion for
* \param tree_x X coordinate of the tree
* \param tree_y Y coordinate of the tree
* \param ctx current redraw context
*/
static void tree_draw_node_expansion_toggle(struct tree *tree,
struct node *node, int tree_x, int tree_y)
struct node *node, int tree_x, int tree_y,
const struct redraw_context *ctx)
{
const struct plotter_table *plot = ctx->plot;
int x, y;
assert(tree != NULL);
@ -1586,15 +1589,15 @@ static void tree_draw_node_expansion_toggle(struct tree *tree,
if ((node->child != NULL) || (node->data.next != NULL)) {
x = tree_x + node->box.x - (NODE_INSTEP / 2) - 4;
y = tree_y + node->box.y + (TREE_LINE_HEIGHT - 9) / 2;
plot.rectangle(x, y, x + 9, y + 9,
plot->rectangle(x, y, x + 9, y + 9,
&plot_style_fill_tree_furniture);
plot.rectangle(x , y, x + 8, y + 8,
&plot_style_stroke_tree_furniture);
plot.line(x + 2, y + 4, x + 7, y + 4,
&plot_style_stroke_tree_furniture);
plot->rectangle(x , y, x + 8, y + 8,
&plot_style_stroke_tree_furniture);
plot->line(x + 2, y + 4, x + 7, y + 4,
&plot_style_stroke_tree_furniture);
if (!node->expanded)
plot.line(x + 4, y + 2, x + 4, y + 7,
&plot_style_stroke_tree_furniture);
plot->line(x + 4, y + 2, x + 4, y + 7,
&plot_style_stroke_tree_furniture);
}
@ -1609,12 +1612,13 @@ static void tree_draw_node_expansion_toggle(struct tree *tree,
* \param tree_x X coordinate to draw the tree at (wrt plot origin)
* \param tree_y Y coordinate to draw the tree at (wrt plot origin)
* \param clip clipping rectangle (wrt plot origin)
* \param ctx current redraw context
*/
static void tree_draw_node_element(struct tree *tree,
struct node_element *element, int tree_x, int tree_y,
const struct rect *clip)
const struct rect *clip, const struct redraw_context *ctx)
{
const struct plotter_table *plot = ctx->plot;
struct bitmap *bitmap = NULL;
int x, y, width;
bool selected = false;
@ -1657,7 +1661,7 @@ static void tree_draw_node_element(struct tree *tree,
/* Valid clip rectangles only */
struct content_redraw_data data;
plot.clip(&c);
plot->clip(&c);
data.x = x;
data.y = y + icon_inset;
@ -1669,10 +1673,10 @@ static void tree_draw_node_element(struct tree *tree,
data.repeat_x = false;
data.repeat_y = false;
content_redraw(icon, &data, &c);
content_redraw(icon, &data, &c, ctx);
/* Restore previous clipping area */
plot.clip(clip);
plot->clip(clip);
}
}
@ -1689,14 +1693,14 @@ static void tree_draw_node_element(struct tree *tree,
if (selected) {
fstyle = &plot_fstyle_selected;
plot.rectangle(x, y, x + width,
plot->rectangle(x, y, x + width,
y + element->box.height,
&plot_style_fill_tree_selected);
} else {
fstyle = &plot_fstyle;
}
plot.text(x + 4, y + (TREE_LINE_HEIGHT * 3 + 2) / 4,
plot->text(x + 4, y + (TREE_LINE_HEIGHT * 3 + 2) / 4,
element->text, strlen(element->text),
fstyle);
break;
@ -1704,11 +1708,11 @@ static void tree_draw_node_element(struct tree *tree,
bitmap = element->bitmap;
if (bitmap == NULL)
break;
plot.bitmap(x, y, element->box.width - 1,
plot->bitmap(x, y, element->box.width - 1,
element->box.height - 2,
bitmap, 0xFFFFFF, BITMAPF_NONE);
if (!(tree->flags & TREE_NO_FURNITURE))
plot.rectangle(x, y, x + element->box.width - 1,
plot->rectangle(x, y, x + element->box.width - 1,
y + element->box.height - 3,
&plot_style_stroke_tree_furniture);
@ -1726,10 +1730,13 @@ static void tree_draw_node_element(struct tree *tree,
* \param tree_x X coordinate to draw the tree at (wrt plot origin)
* \param tree_y Y coordinate to draw the tree at (wrt plot origin)
* \param clip clipping rectangle (wrt plot origin)
* \param ctx current redraw context
*/
static void tree_draw_node(struct tree *tree, struct node *node,
int tree_x, int tree_y, struct rect clip)
int tree_x, int tree_y, struct rect clip,
const struct redraw_context *ctx)
{
const struct plotter_table *plot = ctx->plot;
struct node_element *element;
struct node *parent;
int x0, y0, x1, y1;
@ -1766,7 +1773,7 @@ static void tree_draw_node(struct tree *tree, struct node *node,
}
/* Set up the clipping area */
plot.clip(&clip);
plot->clip(&clip);
/* Draw node's furniture */
if (!(tree->flags & TREE_NO_FURNITURE)) {
@ -1777,7 +1784,7 @@ static void tree_draw_node(struct tree *tree, struct node *node,
x0 = x1 = tree_x + node->box.x - (NODE_INSTEP / 2);
y0 = tree_y + node->previous->box.y;
y1 = tree_y + node->box.y + (TREE_LINE_HEIGHT / 2);
plot.line(x0, y0, x1, y1,
plot->line(x0, y0, x1, y1,
&plot_style_stroke_tree_furniture);
}
if (node->next != NULL) {
@ -1786,7 +1793,7 @@ static void tree_draw_node(struct tree *tree, struct node *node,
x0 = x1 = tree_x + node->box.x - (NODE_INSTEP / 2);
y0 = tree_y + node->box.y + (TREE_LINE_HEIGHT / 2);
y1 = tree_y + node->next->box.y;
plot.line(x0, y0, x1, y1,
plot->line(x0, y0, x1, y1,
&plot_style_stroke_tree_furniture);
}
@ -1798,7 +1805,7 @@ static void tree_draw_node(struct tree *tree, struct node *node,
y0 = tree_y + parent->data.box.y +
parent->data.box.height;
y1 = y0 + (TREE_LINE_HEIGHT / 2);
plot.line(x0, y0, x1, y1,
plot->line(x0, y0, x1, y1,
&plot_style_stroke_tree_furniture);
}
/* Line from expansion toggle to icon */
@ -1806,9 +1813,10 @@ static void tree_draw_node(struct tree *tree, struct node *node,
x1 = x0 + (NODE_INSTEP / 2) - 2;
y0 = y1 = tree_y + node->data.box.y + node->data.box.height -
(TREE_LINE_HEIGHT / 2);
plot.line(x0, y0, x1, y1, &plot_style_stroke_tree_furniture);
plot->line(x0, y0, x1, y1, &plot_style_stroke_tree_furniture);
tree_draw_node_expansion_toggle(tree, node, tree_x, tree_y);
tree_draw_node_expansion_toggle(tree, node,
tree_x, tree_y, ctx);
}
/* Draw node's element(s)
@ -1818,12 +1826,12 @@ static void tree_draw_node(struct tree *tree, struct node *node,
element = element->next) {
/* Draw each element of expanded node */
tree_draw_node_element(tree, element, tree_x, tree_y,
&clip);
&clip, ctx);
}
} else {
/* Draw main title element of node */
tree_draw_node_element(tree, &node->data, tree_x, tree_y,
&clip);
&clip, ctx);
}
}
@ -1836,9 +1844,11 @@ static void tree_draw_node(struct tree *tree, struct node *node,
* \param tree_x X coordinate to draw the tree at (wrt plot origin)
* \param tree_y Y coordinate to draw the tree at (wrt plot origin)
* \param clip clipping rectangle (wrt plot origin)
* \param ctx current redraw context
*/
static void tree_draw_tree(struct tree *tree, struct node *node,
int tree_x, int tree_y, struct rect clip)
int tree_x, int tree_y, struct rect clip,
const struct redraw_context *ctx)
{
struct node *child;
@ -1858,11 +1868,11 @@ static void tree_draw_tree(struct tree *tree, struct node *node,
return;
/* Draw current child */
tree_draw_node(tree, child, tree_x, tree_y, clip);
tree_draw_node(tree, child, tree_x, tree_y, clip, ctx);
/* And its children */
if ((child->child != NULL) && (child->expanded)) {
/* Child has children and they are visible */
tree_draw_tree(tree, child, tree_x, tree_y, clip);
tree_draw_tree(tree, child, tree_x, tree_y, clip, ctx);
}
}
}
@ -1878,35 +1888,38 @@ static void tree_draw_tree(struct tree *tree, struct node *node,
* \param clip_y minimum y of the clipping rectangle (wrt tree origin)
* \param clip_width width of the clipping rectangle
* \param clip_height height of the clipping rectangle
* \param ctx current redraw context
*/
void tree_draw(struct tree *tree, int x, int y,
int clip_x, int clip_y, int clip_width, int clip_height)
int clip_x, int clip_y, int clip_width, int clip_height,
const struct redraw_context *ctx)
{
struct redraw_context new_ctx = *ctx;
struct rect clip;
assert(tree != NULL);
assert(tree->root != NULL);
/* Start knockout rendering if it's available for this plotter */
if (plot.option_knockout)
knockout_plot_start(&plot);
if (ctx->plot->option_knockout)
knockout_plot_start(ctx, &new_ctx);
/* Set up clip rectangle */
clip.x0 = x + clip_x;
clip.y0 = y + clip_y;
clip.x1 = clip.x0 + clip_width;
clip.y1 = clip.y0 + clip_height;
plot.clip(&clip);
new_ctx.plot->clip(&clip);
/* Flat fill extents of clipping area */
plot.rectangle(clip.x0, clip.y0, clip.x1, clip.y1,
new_ctx.plot->rectangle(clip.x0, clip.y0, clip.x1, clip.y1,
&plot_style_fill_tree_background);
/* don't draw empty trees or trees with redraw flag set to false */
if (tree->root->child != NULL && tree->redraw) {
/* Draw the tree */
tree_draw_tree(tree, tree->root, x, y, clip);
tree_draw_tree(tree, tree->root, x, y, clip, &new_ctx);
/* Draw textarea, if present */
if (tree->editing != NULL) {
@ -1914,12 +1927,12 @@ void tree_draw(struct tree *tree, int x, int y,
y = y + tree->editing->box.y;
if (tree->editing->type == NODE_ELEMENT_TEXT_PLUS_ICON)
x += NODE_INSTEP;
textarea_redraw(tree->textarea, x, y, &clip);
textarea_redraw(tree->textarea, x, y, &clip, &new_ctx);
}
}
/* Rendering complete */
if (plot.option_knockout)
if (ctx->plot->option_knockout)
knockout_plot_end();
}

View File

@ -177,7 +177,8 @@ struct node *tree_node_get_child(struct node *node);
struct node *tree_node_get_next(struct node *node);
void tree_draw(struct tree *tree, int x, int y,
int clip_x, int clip_y, int clip_width, int clip_height);
int clip_x, int clip_y, int clip_width, int clip_height,
const struct redraw_context *ctx);
struct node_element *tree_node_find_element(struct node *node,
unsigned int flag, struct node_element *after);

View File

@ -29,10 +29,10 @@
#include "utils/log.h"
#include "desktop/browser.h"
#include "desktop/plotters.h"
#include "framebuffer/gui.h"
#include "framebuffer/fbtk.h"
#include "framebuffer/framebuffer.h"
#include "framebuffer/image_data.h"
#include "widget.h"
@ -109,7 +109,7 @@ fb_redraw_text(fbtk_widget_t *widget, fbtk_callback_info *cbi )
* system for the baseline is to the "higher value
* pixel co-ordinate" due to this the + 1 is neccessary.
*/
plot.text(bbox.x0 + padding,
fb_plotters.text(bbox.x0 + padding,
bbox.y0 + (((fh * 3) + 3)/4) + padding + 1,
widget->u.text.text,
strlen(widget->u.text.text),
@ -207,7 +207,7 @@ fb_redraw_text_button(fbtk_widget_t *widget, fbtk_callback_info *cbi )
* system for the baseline is to the "higher value
* pixel co-ordinate" due to this the + 1 is neccessary.
*/
plot.text(bbox.x0 + border,
fb_plotters.text(bbox.x0 + border,
bbox.y0 + (((fh * 3) + 3)/4) + border + 1,
widget->u.text.text,
strlen(widget->u.text.text),

View File

@ -30,7 +30,6 @@
#include "utils/log.h"
#include "desktop/browser.h"
#include "desktop/plotters.h"
#include "framebuffer/gui.h"
#include "framebuffer/fbtk.h"
@ -342,7 +341,7 @@ framebuffer_plot_clip(const struct rect *clip)
return nsfb_plot_set_clip(nsfb, &nsfb_clip);
}
struct plotter_table plot = {
const struct plotter_table fb_plotters = {
.clip = framebuffer_plot_clip,
.arc = framebuffer_plot_arc,
.disc = framebuffer_plot_disc,

View File

@ -1,5 +1,7 @@
#include "desktop/plotters.h"
extern const struct plotter_table fb_plotters;
nsfb_t *framebuffer_initialise(const char *fename, int width, int height, int bpp);
void framebuffer_finalise(void);
bool framebuffer_set_cursor(struct bitmap *bm);

View File

@ -307,6 +307,10 @@ fb_redraw(fbtk_widget_t *widget,
int x;
int y;
struct rect clip;
struct redraw_context ctx = {
.interactive = true,
.plot = &fb_plotters
};
LOG(("%d,%d to %d,%d",
bwidget->redraw_box.x0,
@ -336,7 +340,7 @@ fb_redraw(fbtk_widget_t *widget,
browser_window_redraw(bw,
(x - bwidget->scrollx) / bw->scale,
(y - bwidget->scrolly) / bw->scale,
&clip);
&clip, &ctx);
current_redraw_browser = NULL;

View File

@ -61,6 +61,11 @@ localhistory_redraw(fbtk_widget_t *widget, fbtk_callback_info *cbi)
struct gui_localhistory *glh = cbi->context;
nsfb_bbox_t rbox;
struct redraw_context ctx = {
.interactive = true,
.plot = &fb_plotters
};
rbox.x0 = fbtk_get_absx(widget);
rbox.y0 = fbtk_get_absy(widget);
@ -76,7 +81,7 @@ localhistory_redraw(fbtk_widget_t *widget, fbtk_callback_info *cbi)
glh->scrolly,
fbtk_get_width(widget) + glh->scrollx,
fbtk_get_height(widget) + glh->scrolly,
0, 0);
0, 0, &ctx);
nsfb_update(fbtk_get_nsfb(widget), &rbox);

View File

@ -1507,21 +1507,25 @@ static gboolean nsgtk_history_expose_event(GtkWidget *widget,
struct browser_window *bw =
gui_window_get_browser_window(hw->g->top_level);
struct redraw_context ctx = {
.interactive = true,
.plot = &nsgtk_plotters
};
current_widget = widget;
current_drawable = widget->window;
current_gc = gdk_gc_new(current_drawable);
#ifdef CAIRO_VERSION
current_cr = gdk_cairo_create(current_drawable);
#endif
plot = nsgtk_plotters;
clip.x0 = event->area.x;
clip.y0 = event->area.y;
clip.x1 = event->area.x + event->area.width;
clip.y1 = event->area.y + event->area.height;
plot.clip(&clip);
ctx.plot->clip(&clip);
history_redraw(bw->history);
history_redraw(bw->history, &ctx);
current_widget = NULL;
g_object_unref(current_gc);

View File

@ -61,6 +61,11 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap,
GdkPixbuf *big;
double scale;
struct redraw_context ctx = {
.interactive = false,
.plot = &nsgtk_plotters
};
assert(content);
assert(bitmap);
@ -95,9 +100,6 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap,
gdk_drawable_set_colormap(pixmap, gdk_colormap_get_system());
/* set the plotting functions up */
plot = nsgtk_plotters;
/* set to plot to pixmap */
current_drawable = pixmap;
current_gc = gdk_gc_new(current_drawable);
@ -106,7 +108,7 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap,
#endif
/* render the content */
thumbnail_redraw(content, cwidth, cheight);
thumbnail_redraw(content, cwidth, cheight, &ctx);
/* get the pixbuf we rendered the content into */
big = gdk_pixbuf_get_from_drawable(NULL, pixmap, NULL, 0, 0, 0, 0,

View File

@ -168,6 +168,10 @@ gboolean nsgtk_tree_window_expose_event(GtkWidget *widget,
GdkEventExpose *event, gpointer g)
{
struct tree *tree = (struct tree *) g;
struct redraw_context ctx = {
.interactive = true,
.plot = &nsgtk_plotters
};
int x, y, width, height;
x = event->area.x;
@ -181,17 +185,15 @@ gboolean nsgtk_tree_window_expose_event(GtkWidget *widget,
#ifdef CAIRO_VERSION
current_cr = gdk_cairo_create(current_drawable);
#endif
plot = nsgtk_plotters;
current_widget = widget;
current_drawable = widget->window;
current_gc = gdk_gc_new(current_drawable);
#ifdef CAIRO_VERSION
current_cr = gdk_cairo_create(current_drawable);
#endif
plot = nsgtk_plotters;
tree_set_redraw(tree, true);
tree_draw(tree, 0, 0, x, y, width, height);
tree_draw(tree, 0, 0, x, y, width, height, &ctx);
current_widget = NULL;
g_object_unref(current_gc);

View File

@ -158,6 +158,10 @@ static gboolean nsgtk_window_expose_event(GtkWidget *widget,
struct gui_window *g = data;
struct gui_window *z;
struct rect clip;
struct redraw_context ctx = {
.interactive = true,
.plot = &nsgtk_plotters
};
assert(g);
assert(g->bw);
@ -175,7 +179,6 @@ static gboolean nsgtk_window_expose_event(GtkWidget *widget,
current_cr = gdk_cairo_create(current_drawable);
#endif
plot = nsgtk_plotters;
current_redraw_browser = g->bw;
clip.x0 = event->area.x;
@ -183,7 +186,7 @@ static gboolean nsgtk_window_expose_event(GtkWidget *widget,
clip.x1 = event->area.x + event->area.width;
clip.y1 = event->area.y + event->area.height;
browser_window_redraw(g->bw, 0, 0, &clip);
browser_window_redraw(g->bw, 0, 0, &clip, &ctx);
current_redraw_browser = NULL;

View File

@ -198,7 +198,7 @@ static bool nsbmp_convert(struct content *c)
}
static bool nsbmp_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip)
const struct rect *clip, const struct redraw_context *ctx)
{
nsbmp_content *bmp = (nsbmp_content *) c;
bitmap_flags_t flags = BITMAPF_NONE;
@ -214,7 +214,7 @@ static bool nsbmp_redraw(struct content *c, struct content_redraw_data *data,
if (data->repeat_y)
flags |= BITMAPF_REPEAT_Y;
return plot.bitmap(data->x, data->y, data->width, data->height,
return ctx->plot->bitmap(data->x, data->y, data->width, data->height,
c->bitmap, data->background_colour, flags);
}

View File

@ -339,7 +339,7 @@ static gif_result nsgif_get_frame(struct content *c)
}
static bool nsgif_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip)
const struct rect *clip, const struct redraw_context *ctx)
{
nsgif_content *gif = (nsgif_content *) c;
bitmap_flags_t flags = BITMAPF_NONE;
@ -358,7 +358,7 @@ static bool nsgif_redraw(struct content *c, struct content_redraw_data *data,
if (data->repeat_y)
flags |= BITMAPF_REPEAT_Y;
return plot.bitmap(data->x, data->y, data->width, data->height,
return ctx->plot->bitmap(data->x, data->y, data->width, data->height,
c->bitmap, data->background_colour, flags);
}

View File

@ -158,7 +158,7 @@ static bool nsico_convert(struct content *c)
static bool nsico_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip)
const struct rect *clip, const struct redraw_context *ctx)
{
nsico_content *ico = (nsico_content *) c;
struct bmp_image *bmp = ico_find(ico->ico, data->width, data->height);
@ -175,7 +175,7 @@ static bool nsico_redraw(struct content *c, struct content_redraw_data *data,
if (data->repeat_y)
flags |= BITMAPF_REPEAT_Y;
return plot.bitmap(data->x, data->y, data->width, data->height,
return ctx->plot->bitmap(data->x, data->y, data->width, data->height,
c->bitmap, data->background_colour, flags);
}

View File

@ -39,6 +39,7 @@
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/talloc.h"
#include "utils/types.h"
#include "utils/utils.h"
#define JPEG_INTERNAL_OPTIONS
@ -278,7 +279,7 @@ static void nsjpeg_destroy(struct content *c)
* Redraw a CONTENT_JPEG with appropriate tiling.
*/
static bool nsjpeg_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip)
const struct rect *clip, const struct redraw_context *ctx)
{
bitmap_flags_t flags = BITMAPF_NONE;
@ -287,7 +288,7 @@ static bool nsjpeg_redraw(struct content *c, struct content_redraw_data *data,
if (data->repeat_y)
flags |= BITMAPF_REPEAT_Y;
return plot.bitmap(data->x, data->y, data->width, data->height,
return ctx->plot->bitmap(data->x, data->y, data->width, data->height,
c->bitmap, data->background_colour, flags);
}

View File

@ -68,7 +68,7 @@ static bool nsmng_process_data(struct content *c, const char *data,
static bool nsmng_convert(struct content *c);
static void nsmng_destroy(struct content *c);
static bool nsmng_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip);
const struct rect *clip, const struct redraw_context *ctx);
static nserror nsmng_clone(const struct content *old, struct content **newc);
static content_type nsmng_content_type(lwc_string *mime_type);
@ -686,7 +686,7 @@ void nsmng_destroy(struct content *c)
bool nsmng_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip)
const struct rect *clip, const struct redraw_context *ctx)
{
nsmng_content *mng = (nsmng_content *) c;
bool ret;
@ -705,7 +705,7 @@ bool nsmng_redraw(struct content *c, struct content_redraw_data *data,
if (data->repeat_y)
flags |= BITMAPF_REPEAT_Y;
ret = plot.bitmap(data->x, data->y, data->width, data->height,
ret = ctx->plot->bitmap(data->x, data->y, data->width, data->height,
c->bitmap, data->background_colour, flags);
/* Check if we need to restart the animation

View File

@ -51,7 +51,7 @@ static nserror nssprite_create(const content_handler *handler,
static bool nssprite_convert(struct content *c);
static void nssprite_destroy(struct content *c);
static bool nssprite_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip);
const struct rect *clip, const struct redraw_context *ctx);
static nserror nssprite_clone(const struct content *old, struct content **newc);
static content_type nssprite_content_type(lwc_string *mime_type);
@ -239,7 +239,7 @@ void nssprite_destroy(struct content *c)
*/
bool nssprite_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip)
const struct rect *clip, const struct redraw_context *ctx)
{
bitmap_flags_t flags = BITMAPF_NONE;
@ -248,7 +248,7 @@ bool nssprite_redraw(struct content *c, struct content_redraw_data *data,
if (data->repeat_y)
flags |= BITMAPF_REPEAT_Y;
return plot.bitmap(data->x, data->y, data->width, data->height,
return ctx->plot->bitmap(data->x, data->y, data->width, data->height,
c->bitmap, data->background_colour, flags);
}

View File

@ -363,7 +363,7 @@ static void nspng_destroy(struct content *c)
static bool nspng_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip)
const struct rect *clip, const struct redraw_context *ctx)
{
nspng_content *png_c = (nspng_content *) c;
bitmap_flags_t flags = BITMAPF_NONE;
@ -375,7 +375,7 @@ static bool nspng_redraw(struct content *c, struct content_redraw_data *data,
if (data->repeat_y)
flags |= BITMAPF_REPEAT_Y;
return plot.bitmap(data->x, data->y, data->width, data->height,
return ctx->plot->bitmap(data->x, data->y, data->width, data->height,
png_c->bitmap, data->background_colour, flags);
}

View File

@ -230,7 +230,7 @@ static bool rsvg_convert(struct content *c)
}
static bool rsvg_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip)
const struct rect *clip, const struct redraw_context *ctx)
{
bitmap_flags_t flags = BITMAPF_NONE;
@ -241,7 +241,7 @@ static bool rsvg_redraw(struct content *c, struct content_redraw_data *data,
if (data->repeat_y)
flags |= BITMAPF_REPEAT_Y;
return plot.bitmap(data->x, data->y, data->width, data->height,
return ctx->plot->bitmap(data->x, data->y, data->width, data->height,
c->bitmap, data->background_colour, flags);
}

View File

@ -52,7 +52,7 @@ static bool svg_convert(struct content *c);
static void svg_destroy(struct content *c);
static void svg_reformat(struct content *c, int width, int height);
static bool svg_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip);
const struct rect *clip, const struct redraw_context *ctx);
static nserror svg_clone(const struct content *old, struct content **newc);
static content_type svg_content_type(lwc_string *mime_type);
@ -217,7 +217,8 @@ void svg_reformat(struct content *c, int width, int height)
static bool svg_redraw_internal(struct content *c, int x, int y,
int width, int height, const struct rect *clip,
float scale, colour background_colour)
const struct redraw_context *ctx, float scale,
colour background_colour)
{
svg_content *svg = (svg_content *) c;
float transform[6];
@ -243,7 +244,7 @@ static bool svg_redraw_internal(struct content *c, int x, int y,
for (i = 0; i != diagram->shape_count; i++) {
if (diagram->shape[i].path) {
ok = plot.path(diagram->shape[i].path,
ok = ctx->plot->path(diagram->shape[i].path,
diagram->shape[i].path_length,
BGR(diagram->shape[i].fill),
diagram->shape[i].stroke_width,
@ -264,7 +265,7 @@ static bool svg_redraw_internal(struct content *c, int x, int y,
fstyle.foreground = 0x000000;
fstyle.size = (8 * FONT_SIZE_SCALE) * scale;
ok = plot.text(px, py,
ok = ctx->plot->text(px, py,
diagram->shape[i].text,
strlen(diagram->shape[i].text),
&fstyle);
@ -284,7 +285,7 @@ static bool svg_redraw_internal(struct content *c, int x, int y,
*/
bool svg_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip)
const struct rect *clip, const struct redraw_context *ctx)
{
int x = data->x;
int y = data->y;
@ -297,8 +298,10 @@ bool svg_redraw(struct content *c, struct content_redraw_data *data,
if ((data->repeat_x == false) && (data->repeat_y == false)) {
/* Simple case: SVG is not tiled */
return svg_redraw_internal(c, x, y, data->width, data->height,
clip, data->scale, data->background_colour);
return svg_redraw_internal(c, x, y,
data->width, data->height,
clip, ctx, data->scale,
data->background_colour);
} else {
/* Tiled redraw required. SVG repeats to extents of clip
* rectangle, in x, y or both directions */
@ -325,7 +328,7 @@ bool svg_redraw(struct content *c, struct content_redraw_data *data,
for (x = x0; x < x1; x += data->width) {
if (!svg_redraw_internal(c, x, y,
data->width, data->height,
clip, data->scale,
clip, ctx, data->scale,
data->background_colour)) {
return false;
}

View File

@ -48,7 +48,7 @@ static nserror webp_create(const content_handler *handler,
static bool webp_convert(struct content *c);
static void webp_destroy(struct content *c);
static bool webp_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip);
const struct rect *clip, const struct redraw_context *ctx);
static nserror webp_clone(const struct content *old, struct content **newc);
static content_type webp_content_type(lwc_string *mime_type);
@ -212,7 +212,7 @@ void webp_destroy(struct content *c)
*/
bool webp_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip)
const struct rect *clip, const struct redraw_context *ctx)
{
bitmap_flags_t flags = BITMAPF_NONE;
@ -221,7 +221,7 @@ bool webp_redraw(struct content *c, struct content_redraw_data *data,
if (data->repeat_y)
flags |= BITMAPF_REPEAT_Y;
return plot.bitmap(data->x, data->y, data->width, data->height,
return ctx->plot->bitmap(data->x, data->y, data->width, data->height,
c->bitmap, data->background_colour, flags);
}

View File

@ -27,6 +27,7 @@
#include "utils/log.h"
#include "monkey/browser.h"
#include "monkey/plot.h"
static uint32_t win_ctr = 0;
@ -466,6 +467,10 @@ monkey_window_handle_redraw(int argc, char **argv)
{
struct gui_window *gw;
struct rect clip;
struct redraw_context ctx = {
.interactive = true,
.plot = &monkey_plotters
};
if (argc != 3 && argc != 7) {
fprintf(stdout, "ERROR WINDOW REDRAW ARGS BAD");
@ -492,7 +497,7 @@ monkey_window_handle_redraw(int argc, char **argv)
}
LOG(("Issue redraw"));
browser_window_redraw(gw->bw, gw->scrollx, gw->scrolly, &clip);
browser_window_redraw(gw->bw, gw->scrollx, gw->scrolly, &clip, &ctx);
}
static void

View File

@ -83,7 +83,7 @@ monkey_plot_clip(const struct rect *clip)
return true;
}
struct plotter_table plot = {
const struct plotter_table monkey_plotters = {
.clip = monkey_plot_clip,
.arc = monkey_plot_arc,
.disc = monkey_plot_disc,

View File

@ -977,15 +977,15 @@ void form_free_select_menu(struct form_control *control)
* \param x the X coordinate to draw the menu at
* \param x the Y coordinate to draw the menu at
* \param scale current redraw scale
* \param clip_x0 minimum x of clipping rectangle
* \param clip_y0 minimum y of clipping rectangle
* \param clip_x1 maximum x of clipping rectangle
* \param clip_y1 maximum y of clipping rectangle
* \param clip clipping rectangle
* \param ctx current redraw context
* \return true on success, false otherwise
*/
bool form_redraw_select_menu(struct form_control *control, int x, int y,
float scale, const struct rect *clip)
float scale, const struct rect *clip,
const struct redraw_context *ctx)
{
const struct plotter_table *plot = ctx->plot;
struct box *box;
struct form_select_menu *menu = control->data.select.menu;
struct form_option *option;
@ -1038,9 +1038,9 @@ bool form_redraw_select_menu(struct form_control *control, int x, int y,
r.y0 = y0;
r.x1 = x1 + 1;
r.y1 = y1 + 1;
if (!plot.clip(&r))
if (!plot->clip(&r))
return false;
if (!plot.rectangle(x0, y0, x1, y1 ,plot_style_stroke_darkwbasec))
if (!plot->rectangle(x0, y0, x1, y1 ,plot_style_stroke_darkwbasec))
return false;
@ -1054,9 +1054,9 @@ bool form_redraw_select_menu(struct form_control *control, int x, int y,
r.y0 = y0;
r.x1 = x1 + 1;
r.y1 = y1 + 1;
if (!plot.clip(&r))
if (!plot->clip(&r))
return false;
if (!plot.rectangle(x0, y0, x1 + 1, y1 + 1,
if (!plot->rectangle(x0, y0, x1 + 1, y1 + 1,
plot_style_fill_lightwbasec))
return false;
option = control->data.select.items;
@ -1078,7 +1078,7 @@ bool form_redraw_select_menu(struct form_control *control, int x, int y,
if (option->selected) {
y2 = y + item_y - scroll;
y3 = y + item_y + line_height_with_spacing - scroll;
if (!plot.rectangle(x0, (y0 > y2 ? y0 : y2),
if (!plot->rectangle(x0, (y0 > y2 ? y0 : y2),
scrollbar_x + 1,
(y3 < y1 + 1 ? y3 : y1 + 1),
&plot_style_fill_selected))
@ -1086,7 +1086,7 @@ bool form_redraw_select_menu(struct form_control *control, int x, int y,
}
y2 = text_pos_offset + item_y;
if (!plot.text(text_x, y2, option->text,
if (!plot->text(text_x, y2, option->text,
strlen(option->text), &plot_fstyle_entry))
return false;
@ -1097,7 +1097,7 @@ bool form_redraw_select_menu(struct form_control *control, int x, int y,
if (!scrollbar_redraw(menu->scrollbar,
x_cp + menu->width - SCROLLBAR_WIDTH,
y_cp,
clip, scale))
clip, scale, ctx))
return false;
return true;

View File

@ -161,7 +161,8 @@ void form_select_menu_callback(void *client_data,
int x, int y, int width, int height);
void form_free_select_menu(struct form_control *control);
bool form_redraw_select_menu(struct form_control *control, int x, int y,
float scale, const struct rect *clip);
float scale, const struct rect *clip,
const struct redraw_context *ctx);
bool form_clip_inside_select_menu(struct form_control *control, float scale,
const struct rect *clip);
const char *form_select_mouse_action(struct form_control *control,

View File

@ -158,7 +158,8 @@ bool text_redraw(const char *utf8_text, size_t utf8_len,
const struct rect *clip,
int height,
float scale,
bool excluded);
bool excluded,
const struct redraw_context *ctx);
xmlDoc *html_get_document(struct hlcache_handle *h);
struct box *html_get_box_tree(struct hlcache_handle *h);

View File

@ -104,7 +104,7 @@ void html_set_status(html_content *c, const char *extra);
/* in render/html_redraw.c */
bool html_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip);
const struct rect *clip, const struct redraw_context *ctx);
/* in render/html_interaction.c */
void html_mouse_track(struct content *c, struct browser_window *bw,

File diff suppressed because it is too large Load Diff

View File

@ -103,7 +103,7 @@ static void textplain_mouse_action(struct content *c, struct browser_window *bw,
static void textplain_reformat(struct content *c, int width, int height);
static void textplain_destroy(struct content *c);
static bool textplain_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip);
const struct rect *clip, const struct redraw_context *ctx);
static nserror textplain_clone(const struct content *old,
struct content **newc);
static content_type textplain_content_type(lwc_string *mime_type);
@ -669,16 +669,18 @@ void textplain_mouse_action(struct content *c, struct browser_window *bw,
* \param c content of type CONTENT_TEXTPLAIN
* \param data redraw data for this content redraw
* \param clip current clip region
* \param ctx current redraw context
* \return true if successful, false otherwise
*
* x, y, clip_[xy][01] are in target coordinates.
*/
bool textplain_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip)
const struct rect *clip, const struct redraw_context *ctx)
{
textplain_content *text = (textplain_content *) c;
struct browser_window *bw = current_redraw_browser;
const struct plotter_table *plot = ctx->plot;
char *utf8_data = text->utf8_data;
long lineno;
int x = data->x;
@ -703,7 +705,7 @@ bool textplain_redraw(struct content *c, struct content_redraw_data *data,
if (line1 < line0)
line1 = line0;
if (!plot.rectangle(clip->x0, clip->y0, clip->x1, clip->y1,
if (!plot->rectangle(clip->x0, clip->y0, clip->x1, clip->y1,
plot_style_fill_white))
return false;
@ -745,7 +747,8 @@ bool textplain_redraw(struct content *c, struct content_redraw_data *data,
line[lineno].start + offset, 0,
&textplain_style,
tx, y + (lineno * scaled_line_height),
clip, line_height, data->scale, false))
clip, line_height, data->scale, false,
ctx))
return false;
if (next_offset >= length)
@ -787,7 +790,7 @@ bool textplain_redraw(struct content *c, struct content_redraw_data *data,
if (highlighted) {
int sy = y + (lineno * scaled_line_height);
if (!plot.rectangle(tx, sy,
if (!plot->rectangle(tx, sy,
ntx, sy + scaled_line_height,
plot_style_highlight))
return false;

View File

@ -111,7 +111,7 @@ static nserror artworks_create(const content_handler *handler,
static bool artworks_convert(struct content *c);
static void artworks_destroy(struct content *c);
static bool artworks_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip);
const struct rect *clip, const struct redraw_context *ctx);
static nserror artworks_clone(const struct content *old, struct content **newc);
static content_type artworks_content_type(lwc_string *mime_type);
@ -330,7 +330,7 @@ void artworks_destroy(struct content *c)
*/
bool artworks_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip)
const struct rect *clip, const struct redraw_context *ctx)
{
static const ns_os_vdu_var_list vars = {
os_MODEVAR_XEIG_FACTOR,
@ -353,7 +353,7 @@ bool artworks_redraw(struct content *c, struct content_redraw_data *data,
int clip_x1 = clip->x1;
int clip_y1 = clip->y1;
if (plot.flush && !plot.flush())
if (ctx->plot->flush && !ctx->plot->flush())
return false;
/* pick up render addresses again in case they've changed

View File

@ -51,7 +51,7 @@ static nserror draw_create(const content_handler *handler,
static bool draw_convert(struct content *c);
static void draw_destroy(struct content *c);
static bool draw_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip);
const struct rect *clip, const struct redraw_context *ctx);
static nserror draw_clone(const struct content *old, struct content **newc);
static content_type draw_content_type(lwc_string *mime_type);
@ -207,7 +207,7 @@ void draw_destroy(struct content *c)
*/
bool draw_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip)
const struct rect *clip, const struct redraw_context *ctx)
{
draw_content *draw = (draw_content *) c;
os_trfm matrix;
@ -216,7 +216,7 @@ bool draw_redraw(struct content *c, struct content_redraw_data *data,
const void *src_data;
os_error *error;
if (plot.flush && !plot.flush())
if (ctx->plot->flush && !ctx->plot->flush())
return false;
if (!c->width || !c->height)

View File

@ -53,7 +53,7 @@ static nserror sprite_create(const content_handler *handler,
static bool sprite_convert(struct content *c);
static void sprite_destroy(struct content *c);
static bool sprite_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip);
const struct rect *clip, const struct redraw_context *ctx);
static nserror sprite_clone(const struct content *old, struct content **newc);
static content_type sprite_content_type(lwc_string *mime_type);
@ -207,11 +207,11 @@ void sprite_destroy(struct content *c)
*/
bool sprite_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip)
const struct rect *clip, const struct redraw_context *ctx)
{
sprite_content *sprite = (sprite_content *) c;
if (plot.flush && !plot.flush())
if (ctx->plot->flush && !ctx->plot->flush())
return false;
return image_redraw(sprite->data,

View File

@ -582,6 +582,10 @@ void ro_gui_url_bar_redraw(struct url_bar *url_bar, wimp_draw *redraw)
xwimp_plot_icon(&icon);
} else {
struct content_redraw_data data;
struct redraw_context ctx = {
.interactive = true,
.plot = &ro_plotters
};
xwimp_set_colour(wimp_COLOUR_WHITE);
xos_plot(os_MOVE_TO,
@ -611,7 +615,7 @@ void ro_gui_url_bar_redraw(struct url_bar *url_bar, wimp_draw *redraw)
data.repeat_x = false;
data.repeat_y = false;
content_redraw(url_bar->favicon_content, &data, &clip);
content_redraw(url_bar->favicon_content, &data, &clip, &ctx);
}
}

View File

@ -139,8 +139,10 @@ void ro_gui_history_redraw(wimp_draw *redraw)
{
osbool more;
os_error *error;
plot = ro_plotters;
struct redraw_context ctx = {
.interactive = true,
.plot = &ro_plotters
};
error = xwimp_redraw_window(redraw, &more);
if (error) {
@ -152,7 +154,7 @@ void ro_gui_history_redraw(wimp_draw *redraw)
while (more) {
ro_plot_origin_x = redraw->box.x0 - redraw->xscroll;
ro_plot_origin_y = redraw->box.y1 - redraw->yscroll;
history_redraw(history_current);
history_redraw(history_current, &ctx);
error = xwimp_get_rectangle(redraw, &more);
if (error) {
LOG(("xwimp_get_rectangle: 0x%x: %s",

View File

@ -618,8 +618,6 @@ bool print_document(struct gui_window *g, const char *filename)
goto error;
}
plot = ro_plotters;
plot.option_knockout = false;
ro_gui_current_redraw_gui = g;
current_redraw_browser = NULL; /* we don't want to print the
selection */
@ -689,6 +687,11 @@ bool print_document(struct gui_window *g, const char *filename)
while (more) {
struct content_redraw_data data;
/* TODO: turn knockout off for print */
struct redraw_context ctx = {
.interactive = false,
.plot = &ro_plotters
};
LOG(("redrawing area: [(%d, %d), (%d, %d)]",
b.x0, b.y0, b.x1, b.y1));
@ -706,7 +709,7 @@ bool print_document(struct gui_window *g, const char *filename)
data.repeat_x = false;
data.repeat_y = false;
if (!content_redraw(h, &data, &clip)) {
if (!content_redraw(h, &data, &clip, &ctx)) {
error_message = "redraw error";
goto error;
}
@ -805,6 +808,10 @@ const char *print_declare_fonts(hlcache_handle *h)
struct content_redraw_data data;
const char *error_message = 0;
os_error *error;
struct redraw_context ctx = {
.interactive = false,
.plot = &print_fonts_plotters
};
free(print_fonts_list);
print_fonts_list = 0;
@ -823,8 +830,7 @@ const char *print_declare_fonts(hlcache_handle *h)
data.repeat_x = false;
data.repeat_y = false;
plot = print_fonts_plotters;
if (!content_redraw(h, &data, &clip)) {
if (!content_redraw(h, &data, &clip, &ctx)) {
if (print_fonts_error)
return print_fonts_error;
return "Declaring fonts failed.";

View File

@ -93,6 +93,10 @@ bool save_as_draw(hlcache_handle *h, const char *path)
struct content_redraw_data data;
size_t drawfile_size;
os_error *error;
struct redraw_context ctx = {
.interactive = true,
.plot = &ro_plotters
};
ro_save_draw_diagram = pencil_create();
if (!ro_save_draw_diagram) {
@ -115,8 +119,7 @@ bool save_as_draw(hlcache_handle *h, const char *path)
data.repeat_x = false;
data.repeat_y = false;
plot = ro_save_draw_plotters;
if (!content_redraw(h, &data, &clip)) {
if (!content_redraw(h, &data, &clip, &ctx)) {
pencil_free(ro_save_draw_diagram);
return false;
}

View File

@ -86,6 +86,10 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap,
osspriteop_area *sprite_area = NULL;
osspriteop_header *sprite_header = NULL;
_kernel_oserror *error;
struct redraw_context ctx = {
.interactive = false,
.plot = &ro_plotters
};
assert(content);
assert(bitmap);
@ -110,7 +114,6 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap,
}
/* set up the plotters */
plot = ro_plotters;
ro_plot_origin_x = 0;
ro_plot_origin_y = bitmap->height * 2;
@ -125,7 +128,7 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap,
colourtrans_set_gcol(os_COLOUR_WHITE, colourtrans_SET_BG_GCOL,
os_ACTION_OVERWRITE, 0);
thumbnail_redraw(content, bitmap->width, bitmap->height);
thumbnail_redraw(content, bitmap->width, bitmap->height, &ctx);
thumbnail_restore_output(save_area);
rufl_invalidate_cache();

View File

@ -357,8 +357,6 @@ void ro_treeview_redraw(wimp_draw *redraw)
*/
}
plot = ro_plotters;
error = xwimp_redraw_window(redraw, &more);
if (error) {
LOG(("xwimp_redraw_window: 0x%x: %s",
@ -380,7 +378,11 @@ void ro_treeview_redraw(wimp_draw *redraw)
void ro_treeview_redraw_loop(wimp_draw *redraw, ro_treeview *tv, osbool more)
{
os_error *error;
os_error *error;
struct redraw_context ctx = {
.interactive = true,
.plot = &ro_plotters
};
while (more) {
ro_plot_origin_x = redraw->box.x0 - redraw->xscroll;
@ -394,7 +396,8 @@ void ro_treeview_redraw_loop(wimp_draw *redraw, ro_treeview *tv, osbool more)
((ro_plot_origin_y+tv->origin.y)
-redraw->clip.y1)/2,
(redraw->clip.x1 - redraw->clip.x0)/2,
(redraw->clip.y1 - redraw->clip.y0)/2);
(redraw->clip.y1 - redraw->clip.y0)/2,
&ctx);
/* Put the graphcis window back how the Wimp set it. */
clip.x0 = (redraw->clip.x0 - ro_plot_origin_x) / 2;

View File

@ -1665,6 +1665,10 @@ void ro_gui_window_redraw(wimp_draw *redraw)
osbool more;
struct gui_window *g = (struct gui_window *)ro_gui_wimp_event_get_user_data(redraw->w);
os_error *error;
struct redraw_context ctx = {
.interactive = true,
.plot = &ro_plotters
};
/* We can't render locked contents. If the browser window is not
* ready for redraw, do nothing. Else, in the case of buffered
@ -1672,7 +1676,6 @@ void ro_gui_window_redraw(wimp_draw *redraw)
if (!browser_window_redraw_ready(g->bw))
return;
plot = ro_plotters;
ro_gui_current_redraw_gui = g;
current_redraw_browser = g->bw;
@ -1705,7 +1708,7 @@ void ro_gui_window_redraw(wimp_draw *redraw)
if (ro_gui_current_redraw_gui->option.buffer_everything)
ro_gui_buffer_open(redraw);
browser_window_redraw(g->bw, 0, 0, &clip);
browser_window_redraw(g->bw, 0, 0, &clip, &ctx);
if (ro_gui_current_redraw_gui->option.buffer_everything)
ro_gui_buffer_close();
@ -4317,6 +4320,10 @@ void ro_gui_window_update_boxes(void)
struct update_box *cur;
struct gui_window *g;
const union content_msg_data *data;
struct redraw_context ctx = {
.interactive = true,
.plot = &ro_plotters
};
for (cur = pending_updates; cur != NULL; cur = cur->next) {
g = cur->g;
@ -4344,7 +4351,6 @@ void ro_gui_window_update_boxes(void)
ro_gui_current_redraw_gui = g;
current_redraw_browser = g->bw;
plot = ro_plotters;
ro_plot_origin_x = update.box.x0 - update.xscroll;
ro_plot_origin_y = update.box.y1 - update.yscroll;
@ -4357,7 +4363,7 @@ void ro_gui_window_update_boxes(void)
if (use_buffer)
ro_gui_buffer_open(&update);
browser_window_redraw(g->bw, 0, 0, &clip);
browser_window_redraw(g->bw, 0, 0, &clip, &ctx);
if (use_buffer)
ro_gui_buffer_close();

View File

@ -23,10 +23,23 @@
#ifndef _NETSURF_UTILS_TYPES_H_
#define _NETSURF_UTILS_TYPES_H_
struct plotter_table;
/* Rectangle coordinates */
struct rect {
int x0, y0; /* Top left */
int x1, y1; /* Bottom right */
};
/* Redraw context */
struct redraw_context {
/** Redraw to show interactive features, such as active selections
* etc. Should be off for printing. */
bool interactive;
/** Current plotters, must be assigned before use. */
const struct plotter_table *plot;
};
#endif

View File

@ -305,6 +305,10 @@ nsws_drawable_paint(struct gui_window *gw, HWND hwnd)
{
struct rect clip;
PAINTSTRUCT ps;
struct redraw_context ctx = {
.interactive = true,
.plot = &win_plotters
};
BeginPaint(hwnd, &ps);
@ -319,7 +323,7 @@ nsws_drawable_paint(struct gui_window *gw, HWND hwnd)
browser_window_redraw(gw->bw,
-gw->scrollx / gw->bw->scale,
-gw->scrolly / gw->bw->scale,
&clip);
&clip, &ctx);
}
EndPaint(hwnd, &ps);

View File

@ -78,7 +78,11 @@ static void nsws_localhistory_scroll_check(struct nsws_localhistory *l, struct g
static void nsws_localhistory_up(struct nsws_localhistory *l, struct gui_window *gw)
{
HDC tmp_hdc;
HDC tmp_hdc;
struct redraw_context ctx = {
.interactive = true,
.plot = &win_plotters
};
LOG(("gui window %p", gw));
@ -90,7 +94,7 @@ static void nsws_localhistory_up(struct nsws_localhistory *l, struct gui_window
tmp_hdc = plot_hdc;
plot_hdc = GetDC(l->hwnd);
history_redraw(gw->bw->history);
history_redraw(gw->bw->history, &ctx);
ReleaseDC(l->hwnd, plot_hdc);
@ -268,6 +272,11 @@ nsws_localhistory_event_callback(HWND hwnd, UINT msg,
case WM_PAINT: {
PAINTSTRUCT ps;
HDC hdc, tmp_hdc;
struct redraw_context ctx = {
.interactive = true,
.plot = &win_plotters
};
hdc = BeginPaint(hwnd, &ps);
if (gw->bw != NULL) {
/* set global HDC for the plotters */
@ -280,7 +289,7 @@ nsws_localhistory_event_callback(HWND hwnd, UINT msg,
gw->localhistory->hscroll + (ps.rcPaint.right - ps.rcPaint.left),
gw->localhistory->vscroll + (ps.rcPaint.bottom - ps.rcPaint.top),
ps.rcPaint.left,
ps.rcPaint.top);
ps.rcPaint.top, &ctx);
plot_hdc = tmp_hdc;

View File

@ -846,7 +846,7 @@ static bool path(const float *p, unsigned int n, colour fill, float width,
return true;
}
struct plotter_table plot = {
const struct plotter_table win_plotters = {
.rectangle = rectangle,
.line = line,
.polygon = polygon,

View File

@ -18,6 +18,8 @@
#include <windows.h>
#include "desktop/gui.h"
extern const struct plotter_table win_plotters;
extern HDC plot_hdc;

View File

@ -38,6 +38,10 @@ thumbnail_create(hlcache_handle *content,
int width;
int height;
HDC hdc, bufferdc, minidc;
struct redraw_context ctx = {
.interactive = false,
.plot = &win_plotters
};
struct bitmap *fsbitmap;
@ -67,7 +71,7 @@ thumbnail_create(hlcache_handle *content,
hdc = plot_hdc;
plot_hdc = bufferdc;
thumbnail_redraw(content, width, height);
thumbnail_redraw(content, width, height, &ctx);
plot_hdc = hdc;
/* scale bitmap bufferbm into minibm */