agg_renderer_base.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  1. //----------------------------------------------------------------------------
  2. // Anti-Grain Geometry - Version 2.4
  3. // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
  4. //
  5. // Permission to copy, use, modify, sell and distribute this software
  6. // is granted provided this copyright notice appears in all copies.
  7. // This software is provided "as is" without express or implied
  8. // warranty, and with no claim as to its suitability for any purpose.
  9. //
  10. //----------------------------------------------------------------------------
  11. // Contact: mcseem@antigrain.com
  12. // mcseemagg@yahoo.com
  13. // http://www.antigrain.com
  14. //----------------------------------------------------------------------------
  15. //
  16. // class renderer_base
  17. //
  18. //----------------------------------------------------------------------------
  19. #ifndef AGG_RENDERER_BASE_INCLUDED
  20. #define AGG_RENDERER_BASE_INCLUDED
  21. #include "agg_basics.h"
  22. #include "agg_rendering_buffer.h"
  23. namespace agg
  24. {
  25. //-----------------------------------------------------------renderer_base
  26. template<class PixelFormat> class renderer_base
  27. {
  28. public:
  29. typedef PixelFormat pixfmt_type;
  30. typedef typename pixfmt_type::color_type color_type;
  31. typedef typename pixfmt_type::row_data row_data;
  32. //--------------------------------------------------------------------
  33. renderer_base() : m_ren(0), m_clip_box(1, 1, 0, 0) {}
  34. explicit renderer_base(pixfmt_type& ren) :
  35. m_ren(&ren),
  36. m_clip_box(0, 0, ren.width() - 1, ren.height() - 1)
  37. {}
  38. void attach(pixfmt_type& ren)
  39. {
  40. m_ren = &ren;
  41. m_clip_box = rect_i(0, 0, ren.width() - 1, ren.height() - 1);
  42. }
  43. //--------------------------------------------------------------------
  44. const pixfmt_type& ren() const { return *m_ren; }
  45. pixfmt_type& ren() { return *m_ren; }
  46. //--------------------------------------------------------------------
  47. unsigned width() const { return m_ren->width(); }
  48. unsigned height() const { return m_ren->height(); }
  49. //--------------------------------------------------------------------
  50. bool clip_box(int x1, int y1, int x2, int y2)
  51. {
  52. rect_i cb(x1, y1, x2, y2);
  53. cb.normalize();
  54. if(cb.clip(rect_i(0, 0, width() - 1, height() - 1)))
  55. {
  56. m_clip_box = cb;
  57. return true;
  58. }
  59. m_clip_box.x1 = 1;
  60. m_clip_box.y1 = 1;
  61. m_clip_box.x2 = 0;
  62. m_clip_box.y2 = 0;
  63. return false;
  64. }
  65. //--------------------------------------------------------------------
  66. void reset_clipping(bool visibility)
  67. {
  68. if(visibility)
  69. {
  70. m_clip_box.x1 = 0;
  71. m_clip_box.y1 = 0;
  72. m_clip_box.x2 = width() - 1;
  73. m_clip_box.y2 = height() - 1;
  74. }
  75. else
  76. {
  77. m_clip_box.x1 = 1;
  78. m_clip_box.y1 = 1;
  79. m_clip_box.x2 = 0;
  80. m_clip_box.y2 = 0;
  81. }
  82. }
  83. //--------------------------------------------------------------------
  84. void clip_box_naked(int x1, int y1, int x2, int y2)
  85. {
  86. m_clip_box.x1 = x1;
  87. m_clip_box.y1 = y1;
  88. m_clip_box.x2 = x2;
  89. m_clip_box.y2 = y2;
  90. }
  91. //--------------------------------------------------------------------
  92. bool inbox(int x, int y) const
  93. {
  94. return x >= m_clip_box.x1 && y >= m_clip_box.y1 &&
  95. x <= m_clip_box.x2 && y <= m_clip_box.y2;
  96. }
  97. //--------------------------------------------------------------------
  98. const rect_i& clip_box() const { return m_clip_box; }
  99. int xmin() const { return m_clip_box.x1; }
  100. int ymin() const { return m_clip_box.y1; }
  101. int xmax() const { return m_clip_box.x2; }
  102. int ymax() const { return m_clip_box.y2; }
  103. //--------------------------------------------------------------------
  104. const rect_i& bounding_clip_box() const { return m_clip_box; }
  105. int bounding_xmin() const { return m_clip_box.x1; }
  106. int bounding_ymin() const { return m_clip_box.y1; }
  107. int bounding_xmax() const { return m_clip_box.x2; }
  108. int bounding_ymax() const { return m_clip_box.y2; }
  109. //--------------------------------------------------------------------
  110. void clear(const color_type& c)
  111. {
  112. unsigned y;
  113. if(width())
  114. {
  115. for(y = 0; y < height(); y++)
  116. {
  117. m_ren->copy_hline(0, y, width(), c);
  118. }
  119. }
  120. }
  121. //--------------------------------------------------------------------
  122. void fill(const color_type& c)
  123. {
  124. unsigned y;
  125. if(width())
  126. {
  127. for(y = 0; y < height(); y++)
  128. {
  129. m_ren->blend_hline(0, y, width(), c, cover_mask);
  130. }
  131. }
  132. }
  133. //--------------------------------------------------------------------
  134. void copy_pixel(int x, int y, const color_type& c)
  135. {
  136. if(inbox(x, y))
  137. {
  138. m_ren->copy_pixel(x, y, c);
  139. }
  140. }
  141. //--------------------------------------------------------------------
  142. void blend_pixel(int x, int y, const color_type& c, cover_type cover)
  143. {
  144. if(inbox(x, y))
  145. {
  146. m_ren->blend_pixel(x, y, c, cover);
  147. }
  148. }
  149. //--------------------------------------------------------------------
  150. color_type pixel(int x, int y) const
  151. {
  152. return inbox(x, y) ?
  153. m_ren->pixel(x, y) :
  154. color_type::no_color();
  155. }
  156. //--------------------------------------------------------------------
  157. void copy_hline(int x1, int y, int x2, const color_type& c)
  158. {
  159. if(x1 > x2) { int t = x2; x2 = x1; x1 = t; }
  160. if(y > ymax()) return;
  161. if(y < ymin()) return;
  162. if(x1 > xmax()) return;
  163. if(x2 < xmin()) return;
  164. if(x1 < xmin()) x1 = xmin();
  165. if(x2 > xmax()) x2 = xmax();
  166. m_ren->copy_hline(x1, y, x2 - x1 + 1, c);
  167. }
  168. //--------------------------------------------------------------------
  169. void copy_vline(int x, int y1, int y2, const color_type& c)
  170. {
  171. if(y1 > y2) { int t = y2; y2 = y1; y1 = t; }
  172. if(x > xmax()) return;
  173. if(x < xmin()) return;
  174. if(y1 > ymax()) return;
  175. if(y2 < ymin()) return;
  176. if(y1 < ymin()) y1 = ymin();
  177. if(y2 > ymax()) y2 = ymax();
  178. m_ren->copy_vline(x, y1, y2 - y1 + 1, c);
  179. }
  180. //--------------------------------------------------------------------
  181. void blend_hline(int x1, int y, int x2,
  182. const color_type& c, cover_type cover)
  183. {
  184. if(x1 > x2) { int t = x2; x2 = x1; x1 = t; }
  185. if(y > ymax()) return;
  186. if(y < ymin()) return;
  187. if(x1 > xmax()) return;
  188. if(x2 < xmin()) return;
  189. if(x1 < xmin()) x1 = xmin();
  190. if(x2 > xmax()) x2 = xmax();
  191. m_ren->blend_hline(x1, y, x2 - x1 + 1, c, cover);
  192. }
  193. //--------------------------------------------------------------------
  194. void blend_vline(int x, int y1, int y2,
  195. const color_type& c, cover_type cover)
  196. {
  197. if(y1 > y2) { int t = y2; y2 = y1; y1 = t; }
  198. if(x > xmax()) return;
  199. if(x < xmin()) return;
  200. if(y1 > ymax()) return;
  201. if(y2 < ymin()) return;
  202. if(y1 < ymin()) y1 = ymin();
  203. if(y2 > ymax()) y2 = ymax();
  204. m_ren->blend_vline(x, y1, y2 - y1 + 1, c, cover);
  205. }
  206. //--------------------------------------------------------------------
  207. void copy_bar(int x1, int y1, int x2, int y2, const color_type& c)
  208. {
  209. rect_i rc(x1, y1, x2, y2);
  210. rc.normalize();
  211. if(rc.clip(clip_box()))
  212. {
  213. int y;
  214. for(y = rc.y1; y <= rc.y2; y++)
  215. {
  216. m_ren->copy_hline(rc.x1, y, unsigned(rc.x2 - rc.x1 + 1), c);
  217. }
  218. }
  219. }
  220. //--------------------------------------------------------------------
  221. void blend_bar(int x1, int y1, int x2, int y2,
  222. const color_type& c, cover_type cover)
  223. {
  224. rect_i rc(x1, y1, x2, y2);
  225. rc.normalize();
  226. if(rc.clip(clip_box()))
  227. {
  228. int y;
  229. for(y = rc.y1; y <= rc.y2; y++)
  230. {
  231. m_ren->blend_hline(rc.x1,
  232. y,
  233. unsigned(rc.x2 - rc.x1 + 1),
  234. c,
  235. cover);
  236. }
  237. }
  238. }
  239. //--------------------------------------------------------------------
  240. void blend_solid_hspan(int x, int y, int len,
  241. const color_type& c,
  242. const cover_type* covers)
  243. {
  244. if(y > ymax()) return;
  245. if(y < ymin()) return;
  246. if(x < xmin())
  247. {
  248. len -= xmin() - x;
  249. if(len <= 0) return;
  250. covers += xmin() - x;
  251. x = xmin();
  252. }
  253. if(x + len > xmax())
  254. {
  255. len = xmax() - x + 1;
  256. if(len <= 0) return;
  257. }
  258. m_ren->blend_solid_hspan(x, y, len, c, covers);
  259. }
  260. //--------------------------------------------------------------------
  261. void blend_solid_vspan(int x, int y, int len,
  262. const color_type& c,
  263. const cover_type* covers)
  264. {
  265. if(x > xmax()) return;
  266. if(x < xmin()) return;
  267. if(y < ymin())
  268. {
  269. len -= ymin() - y;
  270. if(len <= 0) return;
  271. covers += ymin() - y;
  272. y = ymin();
  273. }
  274. if(y + len > ymax())
  275. {
  276. len = ymax() - y + 1;
  277. if(len <= 0) return;
  278. }
  279. m_ren->blend_solid_vspan(x, y, len, c, covers);
  280. }
  281. //--------------------------------------------------------------------
  282. void copy_color_hspan(int x, int y, int len, const color_type* colors)
  283. {
  284. if(y > ymax()) return;
  285. if(y < ymin()) return;
  286. if(x < xmin())
  287. {
  288. int d = xmin() - x;
  289. len -= d;
  290. if(len <= 0) return;
  291. colors += d;
  292. x = xmin();
  293. }
  294. if(x + len > xmax())
  295. {
  296. len = xmax() - x + 1;
  297. if(len <= 0) return;
  298. }
  299. m_ren->copy_color_hspan(x, y, len, colors);
  300. }
  301. //--------------------------------------------------------------------
  302. void copy_color_vspan(int x, int y, int len, const color_type* colors)
  303. {
  304. if(x > xmax()) return;
  305. if(x < xmin()) return;
  306. if(y < ymin())
  307. {
  308. int d = ymin() - y;
  309. len -= d;
  310. if(len <= 0) return;
  311. colors += d;
  312. y = ymin();
  313. }
  314. if(y + len > ymax())
  315. {
  316. len = ymax() - y + 1;
  317. if(len <= 0) return;
  318. }
  319. m_ren->copy_color_vspan(x, y, len, colors);
  320. }
  321. //--------------------------------------------------------------------
  322. void blend_color_hspan(int x, int y, int len,
  323. const color_type* colors,
  324. const cover_type* covers,
  325. cover_type cover = agg::cover_full)
  326. {
  327. if(y > ymax()) return;
  328. if(y < ymin()) return;
  329. if(x < xmin())
  330. {
  331. int d = xmin() - x;
  332. len -= d;
  333. if(len <= 0) return;
  334. if(covers) covers += d;
  335. colors += d;
  336. x = xmin();
  337. }
  338. if(x + len > xmax())
  339. {
  340. len = xmax() - x + 1;
  341. if(len <= 0) return;
  342. }
  343. m_ren->blend_color_hspan(x, y, len, colors, covers, cover);
  344. }
  345. //--------------------------------------------------------------------
  346. void blend_color_vspan(int x, int y, int len,
  347. const color_type* colors,
  348. const cover_type* covers,
  349. cover_type cover = agg::cover_full)
  350. {
  351. if(x > xmax()) return;
  352. if(x < xmin()) return;
  353. if(y < ymin())
  354. {
  355. int d = ymin() - y;
  356. len -= d;
  357. if(len <= 0) return;
  358. if(covers) covers += d;
  359. colors += d;
  360. y = ymin();
  361. }
  362. if(y + len > ymax())
  363. {
  364. len = ymax() - y + 1;
  365. if(len <= 0) return;
  366. }
  367. m_ren->blend_color_vspan(x, y, len, colors, covers, cover);
  368. }
  369. //--------------------------------------------------------------------
  370. rect_i clip_rect_area(rect_i& dst, rect_i& src, int wsrc, int hsrc) const
  371. {
  372. rect_i rc(0,0,0,0);
  373. rect_i cb = clip_box();
  374. ++cb.x2;
  375. ++cb.y2;
  376. if(src.x1 < 0)
  377. {
  378. dst.x1 -= src.x1;
  379. src.x1 = 0;
  380. }
  381. if(src.y1 < 0)
  382. {
  383. dst.y1 -= src.y1;
  384. src.y1 = 0;
  385. }
  386. if(src.x2 > wsrc) src.x2 = wsrc;
  387. if(src.y2 > hsrc) src.y2 = hsrc;
  388. if(dst.x1 < cb.x1)
  389. {
  390. src.x1 += cb.x1 - dst.x1;
  391. dst.x1 = cb.x1;
  392. }
  393. if(dst.y1 < cb.y1)
  394. {
  395. src.y1 += cb.y1 - dst.y1;
  396. dst.y1 = cb.y1;
  397. }
  398. if(dst.x2 > cb.x2) dst.x2 = cb.x2;
  399. if(dst.y2 > cb.y2) dst.y2 = cb.y2;
  400. rc.x2 = dst.x2 - dst.x1;
  401. rc.y2 = dst.y2 - dst.y1;
  402. if(rc.x2 > src.x2 - src.x1) rc.x2 = src.x2 - src.x1;
  403. if(rc.y2 > src.y2 - src.y1) rc.y2 = src.y2 - src.y1;
  404. return rc;
  405. }
  406. //--------------------------------------------------------------------
  407. template<class RenBuf>
  408. void copy_from(const RenBuf& src,
  409. const rect_i* rect_src_ptr = 0,
  410. int dx = 0,
  411. int dy = 0)
  412. {
  413. rect_i rsrc(0, 0, src.width(), src.height());
  414. if(rect_src_ptr)
  415. {
  416. rsrc.x1 = rect_src_ptr->x1;
  417. rsrc.y1 = rect_src_ptr->y1;
  418. rsrc.x2 = rect_src_ptr->x2 + 1;
  419. rsrc.y2 = rect_src_ptr->y2 + 1;
  420. }
  421. // Version with xdst, ydst (absolute positioning)
  422. //rect_i rdst(xdst, ydst, xdst + rsrc.x2 - rsrc.x1, ydst + rsrc.y2 - rsrc.y1);
  423. // Version with dx, dy (relative positioning)
  424. rect_i rdst(rsrc.x1 + dx, rsrc.y1 + dy, rsrc.x2 + dx, rsrc.y2 + dy);
  425. rect_i rc = clip_rect_area(rdst, rsrc, src.width(), src.height());
  426. if(rc.x2 > 0)
  427. {
  428. int incy = 1;
  429. if(rdst.y1 > rsrc.y1)
  430. {
  431. rsrc.y1 += rc.y2 - 1;
  432. rdst.y1 += rc.y2 - 1;
  433. incy = -1;
  434. }
  435. while(rc.y2 > 0)
  436. {
  437. m_ren->copy_from(src,
  438. rdst.x1, rdst.y1,
  439. rsrc.x1, rsrc.y1,
  440. rc.x2);
  441. rdst.y1 += incy;
  442. rsrc.y1 += incy;
  443. --rc.y2;
  444. }
  445. }
  446. }
  447. //--------------------------------------------------------------------
  448. template<class SrcPixelFormatRenderer>
  449. void blend_from(const SrcPixelFormatRenderer& src,
  450. const rect_i* rect_src_ptr = 0,
  451. int dx = 0,
  452. int dy = 0,
  453. cover_type cover = agg::cover_full)
  454. {
  455. rect_i rsrc(0, 0, src.width(), src.height());
  456. if(rect_src_ptr)
  457. {
  458. rsrc.x1 = rect_src_ptr->x1;
  459. rsrc.y1 = rect_src_ptr->y1;
  460. rsrc.x2 = rect_src_ptr->x2 + 1;
  461. rsrc.y2 = rect_src_ptr->y2 + 1;
  462. }
  463. // Version with xdst, ydst (absolute positioning)
  464. //rect_i rdst(xdst, ydst, xdst + rsrc.x2 - rsrc.x1, ydst + rsrc.y2 - rsrc.y1);
  465. // Version with dx, dy (relative positioning)
  466. rect_i rdst(rsrc.x1 + dx, rsrc.y1 + dy, rsrc.x2 + dx, rsrc.y2 + dy);
  467. rect_i rc = clip_rect_area(rdst, rsrc, src.width(), src.height());
  468. if(rc.x2 > 0)
  469. {
  470. int incy = 1;
  471. if(rdst.y1 > rsrc.y1)
  472. {
  473. rsrc.y1 += rc.y2 - 1;
  474. rdst.y1 += rc.y2 - 1;
  475. incy = -1;
  476. }
  477. while(rc.y2 > 0)
  478. {
  479. typename SrcPixelFormatRenderer::row_data rw = src.row(rsrc.y1);
  480. if(rw.ptr)
  481. {
  482. int x1src = rsrc.x1;
  483. int x1dst = rdst.x1;
  484. int len = rc.x2;
  485. if(rw.x1 > x1src)
  486. {
  487. x1dst += rw.x1 - x1src;
  488. len -= rw.x1 - x1src;
  489. x1src = rw.x1;
  490. }
  491. if(len > 0)
  492. {
  493. if(x1src + len-1 > rw.x2)
  494. {
  495. len -= x1src + len - rw.x2 - 1;
  496. }
  497. if(len > 0)
  498. {
  499. m_ren->blend_from(src,
  500. x1dst, rdst.y1,
  501. x1src, rsrc.y1,
  502. len,
  503. cover);
  504. }
  505. }
  506. }
  507. rdst.y1 += incy;
  508. rsrc.y1 += incy;
  509. --rc.y2;
  510. }
  511. }
  512. }
  513. //--------------------------------------------------------------------
  514. template<class SrcPixelFormatRenderer>
  515. void blend_from_color(const SrcPixelFormatRenderer& src,
  516. const color_type& color,
  517. const rect_i* rect_src_ptr = 0,
  518. int dx = 0,
  519. int dy = 0,
  520. cover_type cover = agg::cover_full)
  521. {
  522. rect_i rsrc(0, 0, src.width(), src.height());
  523. if(rect_src_ptr)
  524. {
  525. rsrc.x1 = rect_src_ptr->x1;
  526. rsrc.y1 = rect_src_ptr->y1;
  527. rsrc.x2 = rect_src_ptr->x2 + 1;
  528. rsrc.y2 = rect_src_ptr->y2 + 1;
  529. }
  530. // Version with xdst, ydst (absolute positioning)
  531. //rect_i rdst(xdst, ydst, xdst + rsrc.x2 - rsrc.x1, ydst + rsrc.y2 - rsrc.y1);
  532. // Version with dx, dy (relative positioning)
  533. rect_i rdst(rsrc.x1 + dx, rsrc.y1 + dy, rsrc.x2 + dx, rsrc.y2 + dy);
  534. rect_i rc = clip_rect_area(rdst, rsrc, src.width(), src.height());
  535. if(rc.x2 > 0)
  536. {
  537. int incy = 1;
  538. if(rdst.y1 > rsrc.y1)
  539. {
  540. rsrc.y1 += rc.y2 - 1;
  541. rdst.y1 += rc.y2 - 1;
  542. incy = -1;
  543. }
  544. while(rc.y2 > 0)
  545. {
  546. typename SrcPixelFormatRenderer::row_data rw = src.row(rsrc.y1);
  547. if(rw.ptr)
  548. {
  549. int x1src = rsrc.x1;
  550. int x1dst = rdst.x1;
  551. int len = rc.x2;
  552. if(rw.x1 > x1src)
  553. {
  554. x1dst += rw.x1 - x1src;
  555. len -= rw.x1 - x1src;
  556. x1src = rw.x1;
  557. }
  558. if(len > 0)
  559. {
  560. if(x1src + len-1 > rw.x2)
  561. {
  562. len -= x1src + len - rw.x2 - 1;
  563. }
  564. if(len > 0)
  565. {
  566. m_ren->blend_from_color(src,
  567. color,
  568. x1dst, rdst.y1,
  569. x1src, rsrc.y1,
  570. len,
  571. cover);
  572. }
  573. }
  574. }
  575. rdst.y1 += incy;
  576. rsrc.y1 += incy;
  577. --rc.y2;
  578. }
  579. }
  580. }
  581. //--------------------------------------------------------------------
  582. template<class SrcPixelFormatRenderer>
  583. void blend_from_lut(const SrcPixelFormatRenderer& src,
  584. const color_type* color_lut,
  585. const rect_i* rect_src_ptr = 0,
  586. int dx = 0,
  587. int dy = 0,
  588. cover_type cover = agg::cover_full)
  589. {
  590. rect_i rsrc(0, 0, src.width(), src.height());
  591. if(rect_src_ptr)
  592. {
  593. rsrc.x1 = rect_src_ptr->x1;
  594. rsrc.y1 = rect_src_ptr->y1;
  595. rsrc.x2 = rect_src_ptr->x2 + 1;
  596. rsrc.y2 = rect_src_ptr->y2 + 1;
  597. }
  598. // Version with xdst, ydst (absolute positioning)
  599. //rect_i rdst(xdst, ydst, xdst + rsrc.x2 - rsrc.x1, ydst + rsrc.y2 - rsrc.y1);
  600. // Version with dx, dy (relative positioning)
  601. rect_i rdst(rsrc.x1 + dx, rsrc.y1 + dy, rsrc.x2 + dx, rsrc.y2 + dy);
  602. rect_i rc = clip_rect_area(rdst, rsrc, src.width(), src.height());
  603. if(rc.x2 > 0)
  604. {
  605. int incy = 1;
  606. if(rdst.y1 > rsrc.y1)
  607. {
  608. rsrc.y1 += rc.y2 - 1;
  609. rdst.y1 += rc.y2 - 1;
  610. incy = -1;
  611. }
  612. while(rc.y2 > 0)
  613. {
  614. typename SrcPixelFormatRenderer::row_data rw = src.row(rsrc.y1);
  615. if(rw.ptr)
  616. {
  617. int x1src = rsrc.x1;
  618. int x1dst = rdst.x1;
  619. int len = rc.x2;
  620. if(rw.x1 > x1src)
  621. {
  622. x1dst += rw.x1 - x1src;
  623. len -= rw.x1 - x1src;
  624. x1src = rw.x1;
  625. }
  626. if(len > 0)
  627. {
  628. if(x1src + len-1 > rw.x2)
  629. {
  630. len -= x1src + len - rw.x2 - 1;
  631. }
  632. if(len > 0)
  633. {
  634. m_ren->blend_from_lut(src,
  635. color_lut,
  636. x1dst, rdst.y1,
  637. x1src, rsrc.y1,
  638. len,
  639. cover);
  640. }
  641. }
  642. }
  643. rdst.y1 += incy;
  644. rsrc.y1 += incy;
  645. --rc.y2;
  646. }
  647. }
  648. }
  649. private:
  650. pixfmt_type* m_ren;
  651. rect_i m_clip_box;
  652. };
  653. }
  654. #endif