"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Graphics/Renderer/renderer.cpp" between
TeXmacs-1.99.4-src.tar.gz and TeXmacs-1.99.5-src.tar.gz

About: GNU TeXmacs is a what-you-see-is-what-you-get scientific text editor, which was both inspired by TeX and GNU Emacs.

renderer.cpp  (TeXmacs-1.99.4-src):renderer.cpp  (TeXmacs-1.99.5-src)
skipping to change at line 18 skipping to change at line 18
* It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
* in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>. * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
******************************************************************************/ ******************************************************************************/
#include "renderer.hpp" #include "renderer.hpp"
#include "gui.hpp" #include "gui.hpp"
#include "rectangles.hpp" #include "rectangles.hpp"
#include "image_files.hpp" #include "image_files.hpp"
#include "frame.hpp" #include "frame.hpp"
int std_shrinkf= 5; int std_shrinkf = 5;
bool retina_manual= false;
bool retina_iman = false;
int retina_factor= 1;
int retina_icons = 1;
double retina_scale = 1.0;
/****************************************************************************** /******************************************************************************
* Constructors and handles * Constructors and handles
******************************************************************************/ ******************************************************************************/
renderer_rep::renderer_rep (bool screen_flag): renderer_rep::renderer_rep (bool screen_flag):
ox (0), oy (0), cx1 (0), cy1 (0), cx2 (0), cy2 (0), ox (0), oy (0), cx1 (0), cy1 (0), cx2 (0), cy2 (0),
is_screen (screen_flag), is_screen (screen_flag),
zoomf (std_shrinkf), shrinkf (1), pixel (PIXEL), brushpx (-1), thicken (0), zoomf (std_shrinkf), shrinkf (1),
pixel (PIXEL), retina_pixel (PIXEL),
brushpx (-1), thicken (0),
master (NULL), cur_page (0) {} master (NULL), cur_page (0) {}
renderer_rep::~renderer_rep () {} renderer_rep::~renderer_rep () {}
bool bool
renderer_rep::is_started () { renderer_rep::is_started () {
return true; return true;
} }
void* void*
skipping to change at line 133 skipping to change at line 140
//cx1= (SI) ::floor (cx1 * zoomf); //cx1= (SI) ::floor (cx1 * zoomf);
//cx2= (SI) ::floor (cx2 * zoomf); //cx2= (SI) ::floor (cx2 * zoomf);
//cy1= (SI) ::ceil (cy1 * zoomf); //cy1= (SI) ::ceil (cy1 * zoomf);
//cy2= (SI) ::ceil (cy2 * zoomf); //cy2= (SI) ::ceil (cy2 * zoomf);
cx1= (SI) tm_round (cx1 * zoomf); cx1= (SI) tm_round (cx1 * zoomf);
cx2= (SI) tm_round (cx2 * zoomf); cx2= (SI) tm_round (cx2 * zoomf);
cy1= (SI) tm_round (cy1 * zoomf); cy1= (SI) tm_round (cy1 * zoomf);
cy2= (SI) tm_round (cy2 * zoomf); cy2= (SI) tm_round (cy2 * zoomf);
zoomf = zoom; zoomf = zoom;
shrinkf= (int) tm_round (std_shrinkf / zoomf); shrinkf= (int) tm_round (std_shrinkf / zoomf);
pixel = (SI) tm_round ((std_shrinkf * PIXEL) / zoomf);
thicken= (shrinkf >> 1) * PIXEL; thicken= (shrinkf >> 1) * PIXEL;
pixel = (SI) tm_round ((std_shrinkf * PIXEL) / zoomf);
retina_pixel= pixel;
ox = (SI) tm_round (ox / zoomf); ox = (SI) tm_round (ox / zoomf);
oy = (SI) tm_round (oy / zoomf); oy = (SI) tm_round (oy / zoomf);
//cx1= (SI) ::floor (cx1 / zoomf); //cx1= (SI) ::floor (cx1 / zoomf);
//cx2= (SI) ::floor (cx2 / zoomf); //cx2= (SI) ::floor (cx2 / zoomf);
//cy1= (SI) ::ceil (cy1 / zoomf); //cy1= (SI) ::ceil (cy1 / zoomf);
//cy2= (SI) ::ceil (cy2 / zoomf); //cy2= (SI) ::ceil (cy2 / zoomf);
cx1= (SI) tm_round (cx1 / zoomf); cx1= (SI) tm_round (cx1 / zoomf);
cx2= (SI) tm_round (cx2 / zoomf); cx2= (SI) tm_round (cx2 / zoomf);
cy1= (SI) tm_round (cy1 / zoomf); cy1= (SI) tm_round (cy1 / zoomf);
cy2= (SI) tm_round (cy2 / zoomf); cy2= (SI) tm_round (cy2 / zoomf);
skipping to change at line 244 skipping to change at line 252
rx= ((SI) (( x + 0.5) * pixel)) - ox; rx= ((SI) (( x + 0.5) * pixel)) - ox;
ry= ((SI) (((-y) + 0.5) * pixel)) - oy; ry= ((SI) (((-y) + 0.5) * pixel)) - oy;
} }
void void
renderer_rep::decode (SI x, SI y, double& rx, double& ry) { renderer_rep::decode (SI x, SI y, double& rx, double& ry) {
rx= ((double) (x + ox)) / pixel - 0.5; rx= ((double) (x + ox)) / pixel - 0.5;
ry= -(((double) (y + oy)) / pixel - 0.5); ry= -(((double) (y + oy)) / pixel - 0.5);
} }
#define RND(x) (((x)>=0)?(((x)/pixel)*pixel):((((x)-pixel+1)/pixel)*pixel)) #define RND(x) (((x)>=0)?(((x)/retina_pixel)*retina_pixel):((((x)-retina_pixel+1 )/retina_pixel)*retina_pixel))
void void
renderer_rep::round (SI& x, SI& y) { renderer_rep::round (SI& x, SI& y) {
x= RND (x+ ox)- ox; x= RND (x+ ox)- ox;
y= RND (y+ oy)- oy; y= RND (y+ oy)- oy;
} }
void void
renderer_rep::inner_round (SI& x1, SI& y1, SI& x2, SI& y2) { renderer_rep::inner_round (SI& x1, SI& y1, SI& x2, SI& y2) {
x1= RND (x1+ox+pixel-1) - ox; x1= RND (x1+ox+pixel-1) - ox;
skipping to change at line 331 skipping to change at line 339
brush brush
renderer_rep::get_brush () { renderer_rep::get_brush () {
return brush (get_pencil () -> get_brush ()); return brush (get_pencil () -> get_brush ());
} }
bool is_percentage (tree t, string s= "%"); bool is_percentage (tree t, string s= "%");
double as_percentage (tree t); double as_percentage (tree t);
void void
renderer_rep::clear_pattern (SI x1, SI y1, SI x2, SI y2) { renderer_rep::clear_pattern (SI mx1, SI my1, SI mx2, SI my2,
SI x1, SI y1, SI x2, SI y2) {
brush b= get_background (); brush b= get_background ();
brush_kind kind= b->get_type (); brush_kind kind= b->get_type ();
if (kind == brush_none); if (kind == brush_none);
else if (kind == brush_color) else if (kind == brush_color)
clear (x1, y1, x2, y2); clear (x1, y1, x2, y2);
else if (kind == brush_pattern && is_func (b->get_pattern (), PATTERN)) { else if (kind == brush_pattern && is_func (b->get_pattern (), PATTERN)) {
tree pattern= b->get_pattern (); tree pattern= b->get_pattern ();
int pattern_alpha= b->get_alpha (); int pattern_alpha= b->get_alpha ();
outer_round (x1, y1, x2, y2); outer_round (x1, y1, x2, y2);
//cout << "A: " << x1 << ", " << y1 << ", " << x2 << ", " << y2 << "\n"; //cout << "A: " << x1 << ", " << y1 << ", " << x2 << ", " << y2 << "\n";
//cout << "A: " << x/pixel1 << ", " << y1 << ", " << x2 << ", " << y2 << "\n "; //cout << "A: " << x/pixel1 << ", " << y1 << ", " << x2 << ", " << y2 << "\n ";
SI cx1, cy1, cx2, cy2; SI cx1, cy1, cx2, cy2;
get_clipping (cx1, cy1, cx2, cy2); get_clipping (cx1, cy1, cx2, cy2);
extra_clipping (x1, y1, x2, y2); extra_clipping (x1, y1, x2, y2);
url u= as_string (pattern[0]); url u= b->get_pattern_url ();
int imw_pt, imh_pt; int imw_pt, imh_pt;
image_size (u, imw_pt, imh_pt); image_size (u, imw_pt, imh_pt);
double pt= ((double) 600*PIXEL) / 72.0; double pt= ((double) 600*PIXEL) / 72.0;
SI imw= (SI) (((double) imw_pt) * pt); SI imw= (SI) (((double) imw_pt) * pt);
SI imh= (SI) (((double) imh_pt) * pt); SI imh= (SI) (((double) imh_pt) * pt);
double ratio= ((double) max (imw_pt, 1)) / ((double) max (imh_pt, 1));
SI w= x2 - x1, h= y2 - y1; bool flag= false;
SI w= mx2 - mx1, h= my2 - my1;
if (pattern[1] == "") w= imw; if (pattern[1] == "") w= imw;
else if (is_int (pattern[1])) w= as_int (pattern[1]); else if (is_int (pattern[1])) w= as_int (pattern[1]);
else if (is_percentage (pattern[1])) else if (is_percentage (pattern[1]))
w= (SI) (as_percentage (pattern[1]) * ((double) w)); w= (SI) (as_percentage (pattern[1]) * ((double) w));
else if (is_percentage (pattern[1], "@")) else flag= true;
w= (SI) (as_percentage (pattern[1]) * ((double) h));
if (pattern[1] == "") h= imh; if (pattern[1] == "") h= imh;
else if (is_int (pattern[2])) h= as_int (pattern[2]); else if (is_int (pattern[2])) h= as_int (pattern[2]);
else if (is_percentage (pattern[2])) else if (is_percentage (pattern[2]))
h= (SI) (as_percentage (pattern[2]) * ((double) h)); h= (SI) (as_percentage (pattern[2]) * ((double) h));
else if (is_percentage (pattern[2], "@")) else if (is_percentage (pattern[2], "@"))
h= (SI) (as_percentage (pattern[2]) * ((double) w)); h= (SI) (as_percentage (pattern[2]) * ((double) w) / ratio);
if (flag && is_percentage (pattern[1], "@"))
w= (SI) (as_percentage (pattern[1]) * ((double) h) * ratio);
w= ((w + pixel - 1) / pixel) * pixel; w= ((w + pixel - 1) / pixel) * pixel;
h= ((h + pixel - 1) / pixel) * pixel; h= ((h + pixel - 1) / pixel) * pixel;
SI sx= 0; //is_percentage (pattern[1])? 0: ox; SI sx= -mx1;
SI sy= 0; //is_percentage (pattern[2])? 0: oy; SI sy= -my2;
if (is_percentage (pattern[1]) || is_percentage (pattern[1], "@")) sx= -x1;
if (is_percentage (pattern[2]) || is_percentage (pattern[2], "@")) sy= -y1;
scalable im= load_scalable_image (u, w, h, pixel); scalable im= load_scalable_image (u, w, h, pixel);
for (int i= ((x1+sx)/w) - 1; i <= ((x2+sx)/w) + 1; i++) for (int i= ((x1+sx)/w) - 1; i <= ((x2+sx)/w) + 1; i++)
for (int j= ((y1+sy)/h) - 1; j <= ((y2+sy)/h) + 1; j++) { for (int j= ((y1+sy)/h) - 1; j <= ((y2+sy)/h) + 1; j++) {
SI X1= i*w - sx, Y1= j*h - sy; SI X1= i*w - sx, Y1= j*h - sy;
SI X2= (i+1)*w - sx, Y2= (j+1)*h - sy; SI X2= (i+1)*w - sx, Y2= (j+1)*h - sy;
if (X1 < x2 && X2 > x1 && Y1 < y2 && Y2 > y1) if (X1 < x2 && X2 > x1 && Y1 < y2 && Y2 > y1)
draw_scalable (im, X1, Y1, pattern_alpha); draw_scalable (im, X1, Y1, pattern_alpha);
} }
set_clipping (cx1, cy1, cx2, cy2, true); set_clipping (cx1, cy1, cx2, cy2, true);
} }
else clear (x1, y1, x2, y2); else clear (x1, y1, x2, y2);
} }
void
renderer_rep::clear_pattern (SI x1, SI y1, SI x2, SI y2) {
clear_pattern (x1, y1, x2, y2, x1, y1, x2, y2);
}
#undef RND #undef RND
void void
renderer_rep::draw_scalable (scalable im, SI x, SI y, int alpha) { renderer_rep::draw_scalable (scalable im, SI x, SI y, int alpha) {
im->draw (this, x, y, alpha); im->draw (this, x, y, alpha);
} }
/****************************************************************************** /******************************************************************************
* Drawing selections using alpha transparency * Drawing selections using alpha transparency
******************************************************************************/ ******************************************************************************/
skipping to change at line 427 skipping to change at line 442
set_pencil (fg); set_pencil (fg);
draw_rectangles (::simplify (out)); draw_rectangles (::simplify (out));
} }
/****************************************************************************** /******************************************************************************
* Images * Images
******************************************************************************/ ******************************************************************************/
renderer renderer
renderer_rep::shadow (picture& pic, SI x1, SI y1, SI x2, SI y2) { renderer_rep::shadow (picture& pic, SI x1, SI y1, SI x2, SI y2) {
//cout << "Shadow " << x1/PIXEL << ", " << y1/PIXEL
// << "; " << x2/PIXEL << ", " << y2/PIXEL << "\n";
SI x0= 0, y0= 0; SI x0= 0, y0= 0;
decode (x0, y0); decode (x0, y0);
outer_round (x1, y1, x2, y2); outer_round (x1, y1, x2, y2);
decode (x1, y1); decode (x1, y1);
decode (x2, y2); decode (x2, y2);
x2= max (x1, x2); x2= max (x1, x2);
y2= min (y1, y2); y2= min (y1, y2);
pic= native_picture (x2-x1, y1-y2, x0 - x1, (y1 - y2 - 1) - (y0 - y2)); pic= native_picture (x2-x1, y1-y2, x0 - x1, (y1 - y2 - 1) - (y0 - y2));
renderer ren= picture_renderer (pic, zoomf); renderer ren= picture_renderer (pic, zoomf);
ren->ox = ox; ren->ox = ox;
ren->oy = oy; ren->oy = oy;
ren->cx1= cx1; ren->cx1= cx1;
ren->cy1= cy1; ren->cy1= cy1;
ren->cx2= cx2; ren->cx2= cx2;
ren->cy2= cy2; ren->cy2= cy2;
ren->is_screen= is_screen; ren->is_screen= is_screen;
ren->zoomf= zoomf; ren->zoomf= zoomf;
ren->shrinkf= shrinkf; ren->shrinkf= shrinkf;
ren->pixel= pixel; ren->pixel= pixel;
ren->retina_pixel= retina_pixel;
ren->brushpx= brushpx; ren->brushpx= brushpx;
ren->thicken= thicken; ren->thicken= thicken;
int x1b= x0 - pic->get_origin_x (); int x1b= x0 - pic->get_origin_x ();
int y2b= y0 + pic->get_origin_y () - (pic->get_height () - 1); int y2b= y0 + pic->get_origin_y () - (pic->get_height () - 1);
ren->ox -= x1b * pixel; ren->ox -= x1b * pixel;
ren->oy += y2b * pixel; ren->oy += y2b * pixel;
ren->cx1 -= x1b * pixel; ren->cx1 -= x1b * pixel;
ren->cy1 += y2b * pixel; ren->cy1 += y2b * pixel;
ren->cx2 -= x1b * pixel; ren->cx2 -= x1b * pixel;
ren->cy2 += y2b * pixel; ren->cy2 += y2b * pixel;
return ren; return ren;
} }
renderer renderer
renderer_rep::shadow (scalable& im , SI x1, SI y1, SI x2, SI y2) { renderer_rep::shadow (scalable& im , SI x1, SI y1, SI x2, SI y2) {
(void) im; (void) x1; (void) y1; (void) x2; (void) y2; (void) im; (void) x1; (void) y1; (void) x2; (void) y2;
FAILED ("shadowing is not supported"); FAILED ("shadowing is not supported");
return NULL;
} }
void void
renderer_rep::draw_picture (picture p, SI x, SI y, int alpha) { renderer_rep::draw_picture (picture p, SI x, SI y, int alpha) {
(void) p; (void) x; (void) y; (void) alpha; (void) p; (void) x; (void) y; (void) alpha;
FAILED ("rendering pictures is not supported"); FAILED ("rendering pictures is not supported");
} }
renderer renderer
scalable_renderer (scalable im) { scalable_renderer (scalable im) {
 End of changes. 16 change blocks. 
14 lines changed or deleted 33 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS