From 3376f7f50ff774030596a2e84dd9f72920ee449c Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Thu, 27 Jan 2011 11:43:48 +0000 Subject: Implemented resolution-independent rendering for the browser view. Still needs to be implemented for the other views. svn path=/trunk/netsurf/; revision=11507 --- cocoa/plotter.h | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) (limited to 'cocoa/plotter.h') diff --git a/cocoa/plotter.h b/cocoa/plotter.h index 1b3f1e1be..e756a26f6 100644 --- a/cocoa/plotter.h +++ b/cocoa/plotter.h @@ -19,6 +19,80 @@ #ifndef COCOA_PLOTTER_H #define COCOA_PLOTTER_H +#import +#import "desktop/plot_style.h" + NSColor *cocoa_convert_colour( colour clr ); +void cocoa_update_scale_factor( void ); + +extern CGFloat cocoa_scale_factor; + +static inline CGFloat cocoa_px_to_pt( int location ) __attribute__((always_inline,pure)); +static inline CGFloat cocoa_px_to_pt_f( CGFloat location ) __attribute__((always_inline,pure)); +static inline int cocoa_pt_to_px( CGFloat location ) __attribute__((always_inline,pure)); +static inline NSPoint cocoa_point( int x, int y ) __attribute__((always_inline,pure)); +static inline NSSize cocoa_size( int w, int h ) __attribute__((always_inline,pure)); +static inline NSSize cocoa_scaled_size( float scale, int w, int h ) __attribute__((always_inline,pure)); +static inline NSRect cocoa_rect( int x0, int y0, int x1, int y1 ) __attribute__((always_inline,pure)); +static inline NSRect cocoa_rect_wh( int x, int y, int w, int h ) __attribute__((always_inline,pure)); +static inline NSRect cocoa_scaled_rect_wh( float scale, int x, int y, int w, int h ) __attribute__((always_inline,pure)); + +static inline CGFloat cocoa_px_to_pt( int location ) +{ + return ((CGFloat)location) * cocoa_scale_factor; +} + +static inline CGFloat cocoa_px_to_pt_f( CGFloat location ) +{ + return floor( location ) * cocoa_scale_factor; +} + +static inline int cocoa_pt_to_px( CGFloat location ) +{ + return location / cocoa_scale_factor; +} + +static inline NSPoint cocoa_point( int x, int y ) +{ + return NSMakePoint( cocoa_px_to_pt( x ), cocoa_px_to_pt( y ) ); +} + +static inline NSSize cocoa_size( int w, int h ) +{ + return NSMakeSize( cocoa_px_to_pt( w ), cocoa_px_to_pt( h ) ); +} + +static inline NSSize cocoa_scaled_size( float scale, int w, int h ) +{ + return NSMakeSize( cocoa_px_to_pt_f( scale * w ), cocoa_px_to_pt_f( scale * h ) ); +} + +static inline NSRect cocoa_rect( int x0, int y0, int x1, int y1 ) +{ + const NSRect result = { + .origin = cocoa_point( x0, y0 ), + .size = cocoa_size( x1 - x0, y1 - y0 ) + }; + return result; +} + +static inline NSRect cocoa_rect_wh( int x, int y, int w, int h ) +{ + const NSRect result = { + .origin = cocoa_point( x, y ), + .size = cocoa_size( w, h ) + }; + return result; +} + +static inline NSRect cocoa_scaled_rect_wh( float scale, int x, int y, int w, int h ) +{ + const NSRect result = { + .origin = NSMakePoint( cocoa_px_to_pt_f( scale * x ), cocoa_px_to_pt_f( scale * y ) ), + .size = cocoa_scaled_size( scale, w, h ) + }; + return result; +} + #endif -- cgit v1.2.3