Return-Path: X-Original-To: apmail-incubator-ooo-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-ooo-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6B4C17155 for ; Sun, 16 Oct 2011 04:14:01 +0000 (UTC) Received: (qmail 54890 invoked by uid 500); 16 Oct 2011 04:14:00 -0000 Delivered-To: apmail-incubator-ooo-commits-archive@incubator.apache.org Received: (qmail 54735 invoked by uid 500); 16 Oct 2011 04:13:59 -0000 Mailing-List: contact ooo-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ooo-dev@incubator.apache.org Delivered-To: mailing list ooo-commits@incubator.apache.org Received: (qmail 54717 invoked by uid 99); 16 Oct 2011 04:13:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 16 Oct 2011 04:13:52 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_FILL_THIS_FORM_SHORT X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 16 Oct 2011 04:13:49 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id D9F2E2388A32; Sun, 16 Oct 2011 04:13:28 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1184758 [5/17] - in /incubator/ooo/trunk/main: ./ agg/inc/ agg/source/ solenv/config/ Date: Sun, 16 Oct 2011 04:13:21 -0000 To: ooo-commits@incubator.apache.org From: pfg@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111016041328.D9F2E2388A32@eris.apache.org> Modified: incubator/ooo/trunk/main/agg/inc/agg_pixfmt_gray.h URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_pixfmt_gray.h?rev=1184758&r1=1184757&r2=1184758&view=diff ============================================================================== --- incubator/ooo/trunk/main/agg/inc/agg_pixfmt_gray.h (original) +++ incubator/ooo/trunk/main/agg/inc/agg_pixfmt_gray.h Sun Oct 16 04:13:16 2011 @@ -1,5 +1,5 @@ //---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.3 +// Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software @@ -38,10 +38,10 @@ namespace agg typedef ColorT color_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; - enum { base_shift = color_type::base_shift }; + enum base_scale_e { base_shift = color_type::base_shift }; static AGG_INLINE void blend_pix(value_type* p, unsigned cv, - unsigned alpha, unsigned) + unsigned alpha, unsigned cover=0) { *p = (value_type)((((cv - calc_type(*p)) * alpha) + (calc_type(*p) << base_shift)) >> base_shift); } @@ -54,7 +54,7 @@ namespace agg typedef ColorT color_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; - enum { base_shift = color_type::base_shift }; + enum base_scale_e { base_shift = color_type::base_shift }; static AGG_INLINE void blend_pix(value_type* p, unsigned cv, unsigned alpha, unsigned cover) @@ -63,6 +63,12 @@ namespace agg cover = (cover + 1) << (base_shift - 8); *p = (value_type)((*p * alpha + cv * cover) >> base_shift); } + + static AGG_INLINE void blend_pix(value_type* p, unsigned cv, + unsigned alpha) + { + *p = (value_type)(((*p * (color_type::base_mask - alpha)) >> base_shift) + cv); + } }; @@ -105,20 +111,26 @@ namespace agg - //======================================================pixel_formats_gray - template - class pixel_formats_gray + //=================================================pixfmt_alpha_blend_gray + template + class pixfmt_alpha_blend_gray { public: - typedef rendering_buffer::row_data row_data; - typedef typename Blender::color_type color_type; - typedef typename color_type::value_type value_type; - typedef typename color_type::calc_type calc_type; - enum + typedef RenBuf rbuf_type; + typedef typename rbuf_type::row_data row_data; + typedef Blender blender_type; + typedef typename blender_type::color_type color_type; + typedef int order_type; // A fake one + typedef typename color_type::value_type value_type; + typedef typename color_type::calc_type calc_type; + enum base_scale_e { base_shift = color_type::base_shift, - base_size = color_type::base_size, - base_mask = color_type::base_mask + base_scale = color_type::base_scale, + base_mask = color_type::base_mask, + pix_width = sizeof(value_type), + pix_step = Step, + pix_offset = Offset }; private: @@ -141,59 +153,94 @@ namespace agg } } - //-------------------------------------------------------------------- - static AGG_INLINE void copy_or_blend_opaque_pix(value_type* p, - const color_type& c, - unsigned cover) + + static AGG_INLINE void copy_or_blend_pix(value_type* p, + const color_type& c) { - if(cover == 255) - { - *p = c.v; - } - else + if (c.a) { - Blender::blend_pix(p, c.v, (cover + 1) << (base_shift - 8), cover); + if(c.a == base_mask) + { + *p = c.v; + } + else + { + Blender::blend_pix(p, c.v, c.a); + } } } + public: //-------------------------------------------------------------------- - pixel_formats_gray(rendering_buffer& rb) : + explicit pixfmt_alpha_blend_gray(rbuf_type& rb) : m_rbuf(&rb) {} + void attach(rbuf_type& rb) { m_rbuf = &rb; } + //-------------------------------------------------------------------- + template + bool attach(PixFmt& pixf, int x1, int y1, int x2, int y2) + { + rect_i r(x1, y1, x2, y2); + if(r.clip(rect_i(0, 0, pixf.width()-1, pixf.height()-1))) + { + int stride = pixf.stride(); + m_rbuf->attach(pixf.pix_ptr(r.x1, stride < 0 ? r.y2 : r.y1), + (r.x2 - r.x1) + 1, + (r.y2 - r.y1) + 1, + stride); + return true; + } + return false; + } //-------------------------------------------------------------------- AGG_INLINE unsigned width() const { return m_rbuf->width(); } AGG_INLINE unsigned height() const { return m_rbuf->height(); } + AGG_INLINE int stride() const { return m_rbuf->stride(); } //-------------------------------------------------------------------- - AGG_INLINE color_type pixel(int x, int y) const + int8u* row_ptr(int y) { return m_rbuf->row_ptr(y); } + const int8u* row_ptr(int y) const { return m_rbuf->row_ptr(y); } + row_data row(int y) const { return m_rbuf->row(y); } + + const int8u* pix_ptr(int x, int y) const { - value_type* p = (value_type*)m_rbuf->row(y) + x * Step + Offset; - return color_type(*p); + return m_rbuf->row_ptr(y) + x * Step + Offset; + } + + int8u* pix_ptr(int x, int y) + { + return m_rbuf->row_ptr(y) + x * Step + Offset; } //-------------------------------------------------------------------- - row_data span(int x, int y) const + AGG_INLINE static void make_pix(int8u* p, const color_type& c) { - return row_data(x, - width() - 1, - m_rbuf->row(y) + - x * Step * sizeof(value_type) + - Offset * sizeof(value_type)); + *(value_type*)p = c.v; + } + + //-------------------------------------------------------------------- + AGG_INLINE color_type pixel(int x, int y) const + { + value_type* p = (value_type*)m_rbuf->row_ptr(y) + x * Step + Offset; + return color_type(*p); } //-------------------------------------------------------------------- AGG_INLINE void copy_pixel(int x, int y, const color_type& c) { - *((value_type*)m_rbuf->row(y) + x * Step + Offset) = c.v; + *((value_type*)m_rbuf->row_ptr(x, y, 1) + x * Step + Offset) = c.v; } //-------------------------------------------------------------------- AGG_INLINE void blend_pixel(int x, int y, const color_type& c, int8u cover) { - copy_or_blend_pix((value_type*)m_rbuf->row(y) + x * Step + Offset, c, cover); + copy_or_blend_pix((value_type*) + m_rbuf->row_ptr(x, y, 1) + x * Step + Offset, + c, + cover); } @@ -202,7 +249,9 @@ namespace agg unsigned len, const color_type& c) { - value_type* p = (value_type*)m_rbuf->row(y) + x * Step + Offset; + value_type* p = (value_type*) + m_rbuf->row_ptr(x, y, len) + x * Step + Offset; + do { *p = c.v; @@ -217,11 +266,12 @@ namespace agg unsigned len, const color_type& c) { - value_type* p = (value_type*)m_rbuf->row(y) + x * Step + Offset; do { + value_type* p = (value_type*) + m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset; + *p = c.v; - p = (value_type*)m_rbuf->next_row(p); } while(--len); } @@ -235,7 +285,9 @@ namespace agg { if (c.a) { - value_type* p = (value_type*)m_rbuf->row(y) + x * Step + Offset; + value_type* p = (value_type*) + m_rbuf->row_ptr(x, y, len) + x * Step + Offset; + calc_type alpha = (calc_type(c.a) * (cover + 1)) >> 8; if(alpha == base_mask) { @@ -267,14 +319,16 @@ namespace agg { if (c.a) { - value_type* p = (value_type*)m_rbuf->row(y) + x * Step + Offset; + value_type* p; calc_type alpha = (calc_type(c.a) * (cover + 1)) >> 8; if(alpha == base_mask) { do { + p = (value_type*) + m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset; + *p = c.v; - p = (value_type*)m_rbuf->next_row(p); } while(--len); } @@ -282,8 +336,10 @@ namespace agg { do { + p = (value_type*) + m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset; + Blender::blend_pix(p, c.v, alpha, cover); - p = (value_type*)m_rbuf->next_row(p); } while(--len); } @@ -299,7 +355,9 @@ namespace agg { if (c.a) { - value_type* p = (value_type*)m_rbuf->row(y) + x * Step + Offset; + value_type* p = (value_type*) + m_rbuf->row_ptr(x, y, len) + x * Step + Offset; + do { calc_type alpha = (calc_type(c.a) * (calc_type(*covers) + 1)) >> 8; @@ -327,10 +385,13 @@ namespace agg { if (c.a) { - value_type* p = (value_type*)m_rbuf->row(y) + x * Step + Offset; do { calc_type alpha = (calc_type(c.a) * (calc_type(*covers) + 1)) >> 8; + + value_type* p = (value_type*) + m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset; + if(alpha == base_mask) { *p = c.v; @@ -339,7 +400,6 @@ namespace agg { Blender::blend_pix(p, c.v, alpha, *covers); } - p = (value_type*)m_rbuf->next_row(p); ++covers; } while(--len); @@ -348,13 +408,49 @@ namespace agg //-------------------------------------------------------------------- + void copy_color_hspan(int x, int y, + unsigned len, + const color_type* colors) + { + value_type* p = (value_type*) + m_rbuf->row_ptr(x, y, len) + x * Step + Offset; + + do + { + *p = colors->v; + p += Step; + ++colors; + } + while(--len); + } + + + //-------------------------------------------------------------------- + void copy_color_vspan(int x, int y, + unsigned len, + const color_type* colors) + { + do + { + value_type* p = (value_type*) + m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset; + *p = colors->v; + ++colors; + } + while(--len); + } + + + //-------------------------------------------------------------------- void blend_color_hspan(int x, int y, unsigned len, const color_type* colors, const int8u* covers, int8u cover) { - value_type* p = (value_type*)m_rbuf->row(y) + x * Step + Offset; + value_type* p = (value_type*) + m_rbuf->row_ptr(x, y, len) + x * Step + Offset; + if(covers) { do @@ -376,7 +472,7 @@ namespace agg } else { - copy_or_blend_pix(p, *colors, 255); + copy_or_blend_pix(p, *colors); } p += Step; ++colors; @@ -404,13 +500,15 @@ namespace agg const int8u* covers, int8u cover) { - value_type* p = (value_type*)m_rbuf->row(y) + x * Step + Offset; + value_type* p; if(covers) { do { + p = (value_type*) + m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset; + copy_or_blend_pix(p, *colors++, *covers++); - p = (value_type*)m_rbuf->next_row(p); } while(--len); } @@ -420,15 +518,17 @@ namespace agg { do { + p = (value_type*) + m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset; + if(colors->a == base_mask) { *p = colors->v; } else { - copy_or_blend_pix(p, *colors, 255); + copy_or_blend_pix(p, *colors); } - p = (value_type*)m_rbuf->next_row(p); ++colors; } while(--len); @@ -437,8 +537,10 @@ namespace agg { do { + p = (value_type*) + m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset; + copy_or_blend_pix(p, *colors++, cover); - p = (value_type*)m_rbuf->next_row(p); } while(--len); } @@ -446,82 +548,23 @@ namespace agg } //-------------------------------------------------------------------- - void blend_opaque_color_hspan(int x, int y, - unsigned len, - const color_type* colors, - const int8u* covers, - int8u cover) + template void for_each_pixel(Function f) { - value_type* p = (value_type*)m_rbuf->row(y) + x * Step + Offset; - if(covers) - { - do - { - copy_or_blend_opaque_pix(p, *colors++, *covers++); - p += Step; - } - while(--len); - } - else + unsigned y; + for(y = 0; y < height(); ++y) { - if(cover == 255) - { - do - { - *p = colors->v; - p += Step; - ++colors; - } - while(--len); - } - else + row_data r = m_rbuf->row(y); + if(r.ptr) { - do - { - copy_or_blend_opaque_pix(p, *colors++, cover); - p += Step; - } - while(--len); - } - } - } + unsigned len = r.x2 - r.x1 + 1; + value_type* p = (value_type*) + m_rbuf->row_ptr(r.x1, y, len) + r.x1 * Step + Offset; - //-------------------------------------------------------------------- - void blend_opaque_color_vspan(int x, int y, - unsigned len, - const color_type* colors, - const int8u* covers, - int8u cover) - { - value_type* p = (value_type*)m_rbuf->row(y) + x * Step + Offset; - if(covers) - { - do - { - copy_or_blend_opaque_pix(p, *colors++, *covers++); - p = (value_type*)m_rbuf->next_row(p); - } - while(--len); - } - else - { - if(cover == 255) - { - do - { - *p = colors->v; - p = (value_type*)m_rbuf->next_row(p); - ++colors; - } - while(--len); - } - else - { - do + do { - copy_or_blend_opaque_pix(p, *colors++, cover); - p = (value_type*)m_rbuf->next_row(p); + f(p); + p += Step; } while(--len); } @@ -529,23 +572,6 @@ namespace agg } //-------------------------------------------------------------------- - template void for_each_pixel(Function f) - { - unsigned y; - for(y = 0; y < height(); ++y) - { - unsigned len = width(); - value_type* p = (value_type*)m_rbuf->row(y) + Offset; - do - { - f(p); - p += Step; - } - while(--len); - } - } - - //-------------------------------------------------------------------- template void apply_gamma_dir(const GammaLut& g) { for_each_pixel(apply_gamma_dir_gray(g)); @@ -558,18 +584,75 @@ namespace agg } //-------------------------------------------------------------------- - void copy_from(const rendering_buffer& from, + template + void copy_from(const RenBuf2& from, int xdst, int ydst, int xsrc, int ysrc, unsigned len) { - memmove((value_type*)m_rbuf->row(ydst) + xdst, - (value_type*)from.row(ysrc) + xsrc, - sizeof(value_type) * len); + const int8u* p = from.row_ptr(ysrc); + if(p) + { + memmove(m_rbuf->row_ptr(xdst, ydst, len) + xdst * pix_width, + p + xsrc * pix_width, + len * pix_width); + } + } + + //-------------------------------------------------------------------- + template + void blend_from_color(const SrcPixelFormatRenderer& from, + const color_type& color, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len, + int8u cover) + { + typedef typename SrcPixelFormatRenderer::value_type src_value_type; + const src_value_type* psrc = (src_value_type*)from.row_ptr(ysrc); + if(psrc) + { + value_type* pdst = + (value_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst; + do + { + copy_or_blend_pix(pdst, + color, + (*psrc * cover + base_mask) >> base_shift); + ++psrc; + ++pdst; + } + while(--len); + } + } + + //-------------------------------------------------------------------- + template + void blend_from_lut(const SrcPixelFormatRenderer& from, + const color_type* color_lut, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len, + int8u cover) + { + typedef typename SrcPixelFormatRenderer::value_type src_value_type; + const src_value_type* psrc = (src_value_type*)from.row_ptr(ysrc); + if(psrc) + { + value_type* pdst = + (value_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst; + do + { + copy_or_blend_pix(pdst, color_lut[*psrc], cover); + ++psrc; + ++pdst; + } + while(--len); + } } private: - rendering_buffer* m_rbuf; + rbuf_type* m_rbuf; }; typedef blender_gray blender_gray8; @@ -577,126 +660,10 @@ namespace agg typedef blender_gray blender_gray16; typedef blender_gray_pre blender_gray16_pre; - typedef pixel_formats_gray pixfmt_gray8; //----pixfmt_gray8 - - typedef pixel_formats_gray pixfmt_gray8_rgb24r; //----pixfmt_gray8_rgb24r - typedef pixel_formats_gray pixfmt_gray8_rgb24g; //----pixfmt_gray8_rgb24g - typedef pixel_formats_gray pixfmt_gray8_rgb24b; //----pixfmt_gray8_rgb24b - - typedef pixel_formats_gray pixfmt_gray8_bgr24r; //----pixfmt_gray8_bgr24r - typedef pixel_formats_gray pixfmt_gray8_bgr24g; //----pixfmt_gray8_bgr24g - typedef pixel_formats_gray pixfmt_gray8_bgr24b; //----pixfmt_gray8_bgr24b - - typedef pixel_formats_gray pixfmt_gray8_rgba32r; //----pixfmt_gray8_rgba32r - typedef pixel_formats_gray pixfmt_gray8_rgba32g; //----pixfmt_gray8_rgba32g - typedef pixel_formats_gray pixfmt_gray8_rgba32b; //----pixfmt_gray8_rgba32b - typedef pixel_formats_gray pixfmt_gray8_rgba32a; //----pixfmt_gray8_rgba32a - - typedef pixel_formats_gray pixfmt_gray8_argb32r; //----pixfmt_gray8_argb32r - typedef pixel_formats_gray pixfmt_gray8_argb32g; //----pixfmt_gray8_argb32g - typedef pixel_formats_gray pixfmt_gray8_argb32b; //----pixfmt_gray8_argb32b - typedef pixel_formats_gray pixfmt_gray8_argb32a; //----pixfmt_gray8_argb32a - - typedef pixel_formats_gray pixfmt_gray8_bgra32r; //----pixfmt_gray8_bgra32r - typedef pixel_formats_gray pixfmt_gray8_bgra32g; //----pixfmt_gray8_bgra32g - typedef pixel_formats_gray pixfmt_gray8_bgra32b; //----pixfmt_gray8_bgra32b - typedef pixel_formats_gray pixfmt_gray8_bgra32a; //----pixfmt_gray8_bgra32a - - typedef pixel_formats_gray pixfmt_gray8_abgr32r; //----pixfmt_gray8_abgr32r - typedef pixel_formats_gray pixfmt_gray8_abgr32g; //----pixfmt_gray8_abgr32g - typedef pixel_formats_gray pixfmt_gray8_abgr32b; //----pixfmt_gray8_abgr32b - typedef pixel_formats_gray pixfmt_gray8_abgr32a; //----pixfmt_gray8_abgr32a - - typedef pixel_formats_gray pixfmt_gray8_pre; //----pixfmt_gray8_pre - - typedef pixel_formats_gray pixfmt_gray8_pre_rgb24r; //----pixfmt_gray8_pre_rgb24r - typedef pixel_formats_gray pixfmt_gray8_pre_rgb24g; //----pixfmt_gray8_pre_rgb24g - typedef pixel_formats_gray pixfmt_gray8_pre_rgb24b; //----pixfmt_gray8_pre_rgb24b - - typedef pixel_formats_gray pixfmt_gray8_pre_bgr24r; //----pixfmt_gray8_pre_bgr24r - typedef pixel_formats_gray pixfmt_gray8_pre_bgr24g; //----pixfmt_gray8_pre_bgr24g - typedef pixel_formats_gray pixfmt_gray8_pre_bgr24b; //----pixfmt_gray8_pre_bgr24b - - typedef pixel_formats_gray pixfmt_gray8_pre_rgba32r; //----pixfmt_gray8_pre_rgba32r - typedef pixel_formats_gray pixfmt_gray8_pre_rgba32g; //----pixfmt_gray8_pre_rgba32g - typedef pixel_formats_gray pixfmt_gray8_pre_rgba32b; //----pixfmt_gray8_pre_rgba32b - typedef pixel_formats_gray pixfmt_gray8_pre_rgba32a; //----pixfmt_gray8_pre_rgba32a - - typedef pixel_formats_gray pixfmt_gray8_pre_argb32r; //----pixfmt_gray8_pre_argb32r - typedef pixel_formats_gray pixfmt_gray8_pre_argb32g; //----pixfmt_gray8_pre_argb32g - typedef pixel_formats_gray pixfmt_gray8_pre_argb32b; //----pixfmt_gray8_pre_argb32b - typedef pixel_formats_gray pixfmt_gray8_pre_argb32a; //----pixfmt_gray8_pre_argb32a - - typedef pixel_formats_gray pixfmt_gray8_pre_bgra32r; //----pixfmt_gray8_pre_bgra32r - typedef pixel_formats_gray pixfmt_gray8_pre_bgra32g; //----pixfmt_gray8_pre_bgra32g - typedef pixel_formats_gray pixfmt_gray8_pre_bgra32b; //----pixfmt_gray8_pre_bgra32b - typedef pixel_formats_gray pixfmt_gray8_pre_bgra32a; //----pixfmt_gray8_pre_bgra32a - - typedef pixel_formats_gray pixfmt_gray8_pre_abgr32r; //----pixfmt_gray8_pre_abgr32r - typedef pixel_formats_gray pixfmt_gray8_pre_abgr32g; //----pixfmt_gray8_pre_abgr32g - typedef pixel_formats_gray pixfmt_gray8_pre_abgr32b; //----pixfmt_gray8_pre_abgr32b - typedef pixel_formats_gray pixfmt_gray8_pre_abgr32a; //----pixfmt_gray8_pre_abgr32a - - typedef pixel_formats_gray pixfmt_gray16; //----pixfmt_gray16 - - typedef pixel_formats_gray pixfmt_gray16_rgb48r; //----pixfmt_gray16_rgb48r - typedef pixel_formats_gray pixfmt_gray16_rgb48g; //----pixfmt_gray16_rgb48g - typedef pixel_formats_gray pixfmt_gray16_rgb48b; //----pixfmt_gray16_rgb48b - - typedef pixel_formats_gray pixfmt_gray16_bgr48r; //----pixfmt_gray16_bgr48r - typedef pixel_formats_gray pixfmt_gray16_bgr48g; //----pixfmt_gray16_bgr48g - typedef pixel_formats_gray pixfmt_gray16_bgr48b; //----pixfmt_gray16_bgr48b - - typedef pixel_formats_gray pixfmt_gray16_rgba64r; //----pixfmt_gray16_rgba64r - typedef pixel_formats_gray pixfmt_gray16_rgba64g; //----pixfmt_gray16_rgba64g - typedef pixel_formats_gray pixfmt_gray16_rgba64b; //----pixfmt_gray16_rgba64b - typedef pixel_formats_gray pixfmt_gray16_rgba64a; //----pixfmt_gray16_rgba64a - - typedef pixel_formats_gray pixfmt_gray16_argb64r; //----pixfmt_gray16_argb64r - typedef pixel_formats_gray pixfmt_gray16_argb64g; //----pixfmt_gray16_argb64g - typedef pixel_formats_gray pixfmt_gray16_argb64b; //----pixfmt_gray16_argb64b - typedef pixel_formats_gray pixfmt_gray16_argb64a; //----pixfmt_gray16_argb64a - - typedef pixel_formats_gray pixfmt_gray16_bgra64r; //----pixfmt_gray16_bgra64r - typedef pixel_formats_gray pixfmt_gray16_bgra64g; //----pixfmt_gray16_bgra64g - typedef pixel_formats_gray pixfmt_gray16_bgra64b; //----pixfmt_gray16_bgra64b - typedef pixel_formats_gray pixfmt_gray16_bgra64a; //----pixfmt_gray16_bgra64a - - typedef pixel_formats_gray pixfmt_gray16_abgr64r; //----pixfmt_gray16_abgr64r - typedef pixel_formats_gray pixfmt_gray16_abgr64g; //----pixfmt_gray16_abgr64g - typedef pixel_formats_gray pixfmt_gray16_abgr64b; //----pixfmt_gray16_abgr64b - typedef pixel_formats_gray pixfmt_gray16_abgr64a; //----pixfmt_gray16_abgr64a - - typedef pixel_formats_gray pixfmt_gray16_pre; //----pixfmt_gray16_pre - - typedef pixel_formats_gray pixfmt_gray16_pre_rgb48r; //----pixfmt_gray16_pre_rgb48r - typedef pixel_formats_gray pixfmt_gray16_pre_rgb48g; //----pixfmt_gray16_pre_rgb48g - typedef pixel_formats_gray pixfmt_gray16_pre_rgb48b; //----pixfmt_gray16_pre_rgb48b - - typedef pixel_formats_gray pixfmt_gray16_pre_bgr48r; //----pixfmt_gray16_pre_bgr48r - typedef pixel_formats_gray pixfmt_gray16_pre_bgr48g; //----pixfmt_gray16_pre_bgr48g - typedef pixel_formats_gray pixfmt_gray16_pre_bgr48b; //----pixfmt_gray16_pre_bgr48b - - typedef pixel_formats_gray pixfmt_gray16_pre_rgba64r; //----pixfmt_gray16_pre_rgba64r - typedef pixel_formats_gray pixfmt_gray16_pre_rgba64g; //----pixfmt_gray16_pre_rgba64g - typedef pixel_formats_gray pixfmt_gray16_pre_rgba64b; //----pixfmt_gray16_pre_rgba64b - typedef pixel_formats_gray pixfmt_gray16_pre_rgba64a; //----pixfmt_gray16_pre_rgba64a - - typedef pixel_formats_gray pixfmt_gray16_pre_argb64r; //----pixfmt_gray16_pre_argb64r - typedef pixel_formats_gray pixfmt_gray16_pre_argb64g; //----pixfmt_gray16_pre_argb64g - typedef pixel_formats_gray pixfmt_gray16_pre_argb64b; //----pixfmt_gray16_pre_argb64b - typedef pixel_formats_gray pixfmt_gray16_pre_argb64a; //----pixfmt_gray16_pre_argb64a - - typedef pixel_formats_gray pixfmt_gray16_pre_bgra64r; //----pixfmt_gray16_pre_bgra64r - typedef pixel_formats_gray pixfmt_gray16_pre_bgra64g; //----pixfmt_gray16_pre_bgra64g - typedef pixel_formats_gray pixfmt_gray16_pre_bgra64b; //----pixfmt_gray16_pre_bgra64b - typedef pixel_formats_gray pixfmt_gray16_pre_bgra64a; //----pixfmt_gray16_pre_bgra64a - - typedef pixel_formats_gray pixfmt_gray16_pre_abgr64r; //----pixfmt_gray16_pre_abgr64r - typedef pixel_formats_gray pixfmt_gray16_pre_abgr64g; //----pixfmt_gray16_pre_abgr64g - typedef pixel_formats_gray pixfmt_gray16_pre_abgr64b; //----pixfmt_gray16_pre_abgr64b - typedef pixel_formats_gray pixfmt_gray16_pre_abgr64a; //----pixfmt_gray16_pre_abgr64a - + typedef pixfmt_alpha_blend_gray pixfmt_gray8; //----pixfmt_gray8 + typedef pixfmt_alpha_blend_gray pixfmt_gray8_pre; //----pixfmt_gray8_pre + typedef pixfmt_alpha_blend_gray pixfmt_gray16; //----pixfmt_gray16 + typedef pixfmt_alpha_blend_gray pixfmt_gray16_pre; //----pixfmt_gray16_pre } #endif Modified: incubator/ooo/trunk/main/agg/inc/agg_pixfmt_rgb.h URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_pixfmt_rgb.h?rev=1184758&r1=1184757&r2=1184758&view=diff ============================================================================== --- incubator/ooo/trunk/main/agg/inc/agg_pixfmt_rgb.h (original) +++ incubator/ooo/trunk/main/agg/inc/agg_pixfmt_rgb.h Sun Oct 16 04:13:16 2011 @@ -1,5 +1,5 @@ //---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.3 +// Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software @@ -80,13 +80,13 @@ namespace agg typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; - enum { base_shift = color_type::base_shift }; + enum base_scale_e { base_shift = color_type::base_shift }; //-------------------------------------------------------------------- static AGG_INLINE void blend_pix(value_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, - unsigned) + unsigned cover=0) { p[Order::R] += (value_type)(((cr - p[Order::R]) * alpha) >> base_shift); p[Order::G] += (value_type)(((cg - p[Order::G]) * alpha) >> base_shift); @@ -102,7 +102,7 @@ namespace agg typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; - enum { base_shift = color_type::base_shift }; + enum base_scale_e { base_shift = color_type::base_shift }; //-------------------------------------------------------------------- static AGG_INLINE void blend_pix(value_type* p, @@ -116,6 +116,18 @@ namespace agg p[Order::G] = (value_type)((p[Order::G] * alpha + cg * cover) >> base_shift); p[Order::B] = (value_type)((p[Order::B] * alpha + cb * cover) >> base_shift); } + + //-------------------------------------------------------------------- + static AGG_INLINE void blend_pix(value_type* p, + unsigned cr, unsigned cg, unsigned cb, + unsigned alpha) + { + alpha = color_type::base_mask - alpha; + p[Order::R] = (value_type)(((p[Order::R] * alpha) >> base_shift) + cr); + p[Order::G] = (value_type)(((p[Order::G] * alpha) >> base_shift) + cg); + p[Order::B] = (value_type)(((p[Order::B] * alpha) >> base_shift) + cb); + } + }; @@ -129,7 +141,7 @@ namespace agg typedef Gamma gamma_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; - enum { base_shift = color_type::base_shift }; + enum base_scale_e { base_shift = color_type::base_shift }; //-------------------------------------------------------------------- blender_rgb_gamma() : m_gamma(0) {} @@ -139,7 +151,7 @@ namespace agg AGG_INLINE void blend_pix(value_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, - unsigned) + unsigned cover=0) { calc_type r = m_gamma->dir(p[Order::R]); calc_type g = m_gamma->dir(p[Order::G]); @@ -156,20 +168,23 @@ namespace agg - //==================================================pixel_formats_rgb - template class pixel_formats_rgb + //==================================================pixfmt_alpha_blend_rgb + template class pixfmt_alpha_blend_rgb { public: - typedef rendering_buffer::row_data row_data; - typedef typename Blender::color_type color_type; - typedef typename Blender::order_type order_type; + typedef RenBuf rbuf_type; + typedef Blender blender_type; + typedef typename rbuf_type::row_data row_data; + typedef typename blender_type::color_type color_type; + typedef typename blender_type::order_type order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; - enum + enum base_scale_e { base_shift = color_type::base_shift, - base_size = color_type::base_size, - base_mask = color_type::base_mask + base_scale = color_type::base_scale, + base_mask = color_type::base_mask, + pix_width = sizeof(value_type) * 3 }; private: @@ -195,28 +210,48 @@ namespace agg } //-------------------------------------------------------------------- - AGG_INLINE void copy_or_blend_opaque_pix(value_type* p, - const color_type& c, - unsigned cover) + AGG_INLINE void copy_or_blend_pix(value_type* p, + const color_type& c) { - if(cover == 255) - { - p[order_type::R] = c.r; - p[order_type::G] = c.g; - p[order_type::B] = c.b; - } - else + if (c.a) { - m_blender.blend_pix(p, c.r, c.g, c.b, (cover + 1) << (base_shift - 8), cover); + if(c.a == base_mask) + { + p[order_type::R] = c.r; + p[order_type::G] = c.g; + p[order_type::B] = c.b; + } + else + { + m_blender.blend_pix(p, c.r, c.g, c.b, c.a); + } } } public: //-------------------------------------------------------------------- - pixel_formats_rgb(rendering_buffer& rb) : + explicit pixfmt_alpha_blend_rgb(rbuf_type& rb) : m_rbuf(&rb) {} + void attach(rbuf_type& rb) { m_rbuf = &rb; } + + //-------------------------------------------------------------------- + template + bool attach(PixFmt& pixf, int x1, int y1, int x2, int y2) + { + rect_i r(x1, y1, x2, y2); + if(r.clip(rect_i(0, 0, pixf.width()-1, pixf.height()-1))) + { + int stride = pixf.stride(); + m_rbuf->attach(pixf.pix_ptr(r.x1, stride < 0 ? r.y2 : r.y1), + (r.x2 - r.x1) + 1, + (r.y2 - r.y1) + 1, + stride); + return true; + } + return false; + } //-------------------------------------------------------------------- Blender& blender() { return m_blender; } @@ -224,28 +259,45 @@ namespace agg //-------------------------------------------------------------------- AGG_INLINE unsigned width() const { return m_rbuf->width(); } AGG_INLINE unsigned height() const { return m_rbuf->height(); } + AGG_INLINE int stride() const { return m_rbuf->stride(); } //-------------------------------------------------------------------- - AGG_INLINE color_type pixel(int x, int y) const + AGG_INLINE int8u* row_ptr(int y) { return m_rbuf->row_ptr(y); } + AGG_INLINE const int8u* row_ptr(int y) const { return m_rbuf->row_ptr(y); } + AGG_INLINE row_data row(int y) const { return m_rbuf->row(y); } + + //-------------------------------------------------------------------- + AGG_INLINE int8u* pix_ptr(int x, int y) + { + return m_rbuf->row_ptr(y) + x * pix_width; + } + + AGG_INLINE const int8u* pix_ptr(int x, int y) const + { + return m_rbuf->row_ptr(y) + x * pix_width; + } + + //-------------------------------------------------------------------- + AGG_INLINE static void make_pix(int8u* p, const color_type& c) { - value_type* p = (value_type*)m_rbuf->row(y) + x + x + x; - return color_type(p[order_type::R], - p[order_type::G], - p[order_type::B]); + ((value_type*)p)[order_type::R] = c.r; + ((value_type*)p)[order_type::G] = c.g; + ((value_type*)p)[order_type::B] = c.b; } //-------------------------------------------------------------------- - row_data span(int x, int y) const + AGG_INLINE color_type pixel(int x, int y) const { - return row_data(x, - width() - 1, - m_rbuf->row(y) + x * 3 * sizeof(value_type)); + value_type* p = (value_type*)m_rbuf->row_ptr(y) + x + x + x; + return color_type(p[order_type::R], + p[order_type::G], + p[order_type::B]); } //-------------------------------------------------------------------- AGG_INLINE void copy_pixel(int x, int y, const color_type& c) { - value_type* p = (value_type*)m_rbuf->row(y) + x + x + x; + value_type* p = (value_type*)m_rbuf->row_ptr(x, y, 1) + x + x + x; p[order_type::R] = c.r; p[order_type::G] = c.g; p[order_type::B] = c.b; @@ -254,7 +306,7 @@ namespace agg //-------------------------------------------------------------------- AGG_INLINE void blend_pixel(int x, int y, const color_type& c, int8u cover) { - copy_or_blend_pix((value_type*)m_rbuf->row(y) + x + x + x, c, cover); + copy_or_blend_pix((value_type*)m_rbuf->row_ptr(x, y, 1) + x + x + x, c, cover); } @@ -263,7 +315,7 @@ namespace agg unsigned len, const color_type& c) { - value_type* p = (value_type*)m_rbuf->row(y) + x + x + x; + value_type* p = (value_type*)m_rbuf->row_ptr(x, y, len) + x + x + x; do { p[order_type::R] = c.r; @@ -280,13 +332,13 @@ namespace agg unsigned len, const color_type& c) { - value_type* p = (value_type*)m_rbuf->row(y) + x + x + x; do { + value_type* p = (value_type*) + m_rbuf->row_ptr(x, y++, 1) + x + x + x; p[order_type::R] = c.r; p[order_type::G] = c.g; p[order_type::B] = c.b; - p = (value_type*)m_rbuf->next_row(p); } while(--len); } @@ -300,7 +352,9 @@ namespace agg { if (c.a) { - value_type* p = (value_type*)m_rbuf->row(y) + x + x + x; + value_type* p = (value_type*) + m_rbuf->row_ptr(x, y, len) + x + x + x; + calc_type alpha = (calc_type(c.a) * (calc_type(cover) + 1)) >> 8; if(alpha == base_mask) { @@ -334,16 +388,18 @@ namespace agg { if (c.a) { - value_type* p = (value_type*)m_rbuf->row(y) + x + x + x; + value_type* p; calc_type alpha = (calc_type(c.a) * (cover + 1)) >> 8; if(alpha == base_mask) { do { + p = (value_type*) + m_rbuf->row_ptr(x, y++, 1) + x + x + x; + p[order_type::R] = c.r; p[order_type::G] = c.g; p[order_type::B] = c.b; - p = (value_type*)m_rbuf->next_row(p); } while(--len); } @@ -351,8 +407,10 @@ namespace agg { do { + p = (value_type*) + m_rbuf->row_ptr(x, y++, 1) + x + x + x; + m_blender.blend_pix(p, c.r, c.g, c.b, alpha, cover); - p = (value_type*)m_rbuf->next_row(p); } while(--len); } @@ -368,7 +426,9 @@ namespace agg { if (c.a) { - value_type* p = (value_type*)m_rbuf->row(y) + x + x + x; + value_type* p = (value_type*) + m_rbuf->row_ptr(x, y, len) + x + x + x; + do { calc_type alpha = (calc_type(c.a) * (calc_type(*covers) + 1)) >> 8; @@ -398,9 +458,11 @@ namespace agg { if (c.a) { - value_type* p = (value_type*)m_rbuf->row(y) + x + x + x; do { + value_type* p = (value_type*) + m_rbuf->row_ptr(x, y++, 1) + x + x + x; + calc_type alpha = (calc_type(c.a) * (calc_type(*covers) + 1)) >> 8; if(alpha == base_mask) { @@ -412,7 +474,6 @@ namespace agg { m_blender.blend_pix(p, c.r, c.g, c.b, alpha, *covers); } - p = (value_type*)m_rbuf->next_row(p); ++covers; } while(--len); @@ -421,13 +482,53 @@ namespace agg //-------------------------------------------------------------------- + void copy_color_hspan(int x, int y, + unsigned len, + const color_type* colors) + { + value_type* p = (value_type*) + m_rbuf->row_ptr(x, y, len) + x + x + x; + + do + { + p[order_type::R] = colors->r; + p[order_type::G] = colors->g; + p[order_type::B] = colors->b; + ++colors; + p += 3; + } + while(--len); + } + + + //-------------------------------------------------------------------- + void copy_color_vspan(int x, int y, + unsigned len, + const color_type* colors) + { + do + { + value_type* p = (value_type*) + m_rbuf->row_ptr(x, y++, 1) + x + x + x; + p[order_type::R] = colors->r; + p[order_type::G] = colors->g; + p[order_type::B] = colors->b; + ++colors; + } + while(--len); + } + + + //-------------------------------------------------------------------- void blend_color_hspan(int x, int y, unsigned len, const color_type* colors, const int8u* covers, int8u cover) { - value_type* p = (value_type*)m_rbuf->row(y) + x + x + x; + value_type* p = (value_type*) + m_rbuf->row_ptr(x, y, len) + x + x + x; + if(covers) { do @@ -443,18 +544,8 @@ namespace agg { do { - if(colors->a == base_mask) - { - p[order_type::R] = colors->r; - p[order_type::G] = colors->g; - p[order_type::B] = colors->b; - } - else - { - copy_or_blend_pix(p, *colors, 255); - } + copy_or_blend_pix(p, *colors++); p += 3; - ++colors; } while(--len); } @@ -479,13 +570,15 @@ namespace agg const int8u* covers, int8u cover) { - value_type* p = (value_type*)m_rbuf->row(y) + x + x + x; + value_type* p; if(covers) { do { + p = (value_type*) + m_rbuf->row_ptr(x, y++, 1) + x + x + x; + copy_or_blend_pix(p, *colors++, *covers++); - p = (value_type*)m_rbuf->next_row(p); } while(--len); } @@ -495,18 +588,10 @@ namespace agg { do { - if(colors->a == base_mask) - { - p[order_type::R] = colors->r; - p[order_type::G] = colors->g; - p[order_type::B] = colors->b; - } - else - { - copy_or_blend_pix(p, *colors, 255); - } - p = (value_type*)m_rbuf->next_row(p); - ++colors; + p = (value_type*) + m_rbuf->row_ptr(x, y++, 1) + x + x + x; + + copy_or_blend_pix(p, *colors++); } while(--len); } @@ -514,51 +599,31 @@ namespace agg { do { + p = (value_type*) + m_rbuf->row_ptr(x, y++, 1) + x + x + x; + copy_or_blend_pix(p, *colors++, cover); - p = (value_type*)m_rbuf->next_row(p); } while(--len); } } } - //-------------------------------------------------------------------- - void blend_opaque_color_hspan(int x, int y, - unsigned len, - const color_type* colors, - const int8u* covers, - int8u cover) + template void for_each_pixel(Function f) { - value_type* p = (value_type*)m_rbuf->row(y) + x + x + x; - if(covers) - { - do - { - copy_or_blend_opaque_pix(p, *colors++, *covers++); - p += 3; - } - while(--len); - } - else + unsigned y; + for(y = 0; y < height(); ++y) { - if(cover == 255) - { - do - { - p[order_type::R] = colors->r; - p[order_type::G] = colors->g; - p[order_type::B] = colors->b; - p += 3; - ++colors; - } - while(--len); - } - else + row_data r = m_rbuf->row(y); + if(r.ptr) { - do + unsigned len = r.x2 - r.x1 + 1; + value_type* p = (value_type*) + m_rbuf->row_ptr(r.x1, y, len) + r.x1 * 3; + do { - copy_or_blend_opaque_pix(p, *colors++, cover); + f(p); p += 3; } while(--len); @@ -566,44 +631,91 @@ namespace agg } } + //-------------------------------------------------------------------- + template void apply_gamma_dir(const GammaLut& g) + { + for_each_pixel(apply_gamma_dir_rgb(g)); + } //-------------------------------------------------------------------- - void blend_opaque_color_vspan(int x, int y, - unsigned len, - const color_type* colors, - const int8u* covers, - int8u cover) + template void apply_gamma_inv(const GammaLut& g) { - value_type* p = (value_type*)m_rbuf->row(y) + x + x + x; - if(covers) + for_each_pixel(apply_gamma_inv_rgb(g)); + } + + //-------------------------------------------------------------------- + template + void copy_from(const RenBuf2& from, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len) + { + const int8u* p = from.row_ptr(ysrc); + if(p) { - do - { - copy_or_blend_opaque_pix(p, *colors++, *covers++); - p = (value_type*)m_rbuf->next_row(p); - } - while(--len); + memmove(m_rbuf->row_ptr(xdst, ydst, len) + xdst * pix_width, + p + xsrc * pix_width, + len * pix_width); } - else + } + + + //-------------------------------------------------------------------- + template + void blend_from(const SrcPixelFormatRenderer& from, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len, + int8u cover) + { + typedef typename SrcPixelFormatRenderer::order_type src_order; + + const value_type* psrc = (const value_type*)from.row_ptr(ysrc); + if(psrc) { + psrc += xsrc * 4; + value_type* pdst = + (value_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst * 3; + if(cover == 255) { do { - p[order_type::R] = colors->r; - p[order_type::G] = colors->g; - p[order_type::B] = colors->b; - p = (value_type*)m_rbuf->next_row(p); - ++colors; + value_type alpha = psrc[src_order::A]; + if(alpha) + { + if(alpha == base_mask) + { + pdst[order_type::R] = psrc[src_order::R]; + pdst[order_type::G] = psrc[src_order::G]; + pdst[order_type::B] = psrc[src_order::B]; + } + else + { + m_blender.blend_pix(pdst, + psrc[src_order::R], + psrc[src_order::G], + psrc[src_order::B], + alpha); + } + } + psrc += 4; + pdst += 3; } while(--len); } else { + color_type color; do { - copy_or_blend_opaque_pix(p, *colors++, cover); - p = (value_type*)m_rbuf->next_row(p); + color.r = psrc[src_order::R]; + color.g = psrc[src_order::G]; + color.b = psrc[src_order::B]; + color.a = psrc[src_order::A]; + copy_or_blend_pix(pdst, color, cover); + psrc += 4; + pdst += 3; } while(--len); } @@ -611,107 +723,95 @@ namespace agg } //-------------------------------------------------------------------- - template void for_each_pixel(Function f) - { - unsigned y; - for(y = 0; y < height(); ++y) + template + void blend_from_color(const SrcPixelFormatRenderer& from, + const color_type& color, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len, + int8u cover) + { + typedef typename SrcPixelFormatRenderer::value_type src_value_type; + const src_value_type* psrc = (src_value_type*)from.row_ptr(ysrc); + if(psrc) { - unsigned len = width(); - value_type* p = (value_type*)m_rbuf->row(y); - do + value_type* pdst = + (value_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst * 3; + do { - f(p); - p += 3; + copy_or_blend_pix(pdst, + color, + (*psrc * cover + base_mask) >> base_shift); + ++psrc; + pdst += 3; } while(--len); } } //-------------------------------------------------------------------- - template void apply_gamma_dir(const GammaLut& g) - { - for_each_pixel(apply_gamma_dir_rgb(g)); - } - - //-------------------------------------------------------------------- - template void apply_gamma_inv(const GammaLut& g) - { - for_each_pixel(apply_gamma_inv_rgb(g)); - } - - //-------------------------------------------------------------------- - void copy_from(const rendering_buffer& from, - int xdst, int ydst, - int xsrc, int ysrc, - unsigned len) - { - memmove((value_type*)m_rbuf->row(ydst) + xdst * 3, - (const value_type*)from.row(ysrc) + xsrc * 3, - sizeof(value_type) * 3 * len); - } - - - //-------------------------------------------------------------------- template - void blend_from(const SrcPixelFormatRenderer& from, - const int8u* psrc_, - int xdst, int ydst, - int xsrc, int ysrc, - unsigned len) - { - typedef typename SrcPixelFormatRenderer::order_type src_order; - - const value_type* psrc = (const value_type*)psrc_; - value_type* pdst = (value_type*)m_rbuf->row(ydst) + xdst * 3; - do + void blend_from_lut(const SrcPixelFormatRenderer& from, + const color_type* color_lut, + int xdst, int ydst, + int xsrc, int ysrc, + unsigned len, + int8u cover) + { + typedef typename SrcPixelFormatRenderer::value_type src_value_type; + const src_value_type* psrc = (src_value_type*)from.row_ptr(ysrc); + if(psrc) { - value_type alpha = psrc[src_order::A]; - if(alpha) + value_type* pdst = + (value_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst * 3; + + if(cover == 255) { - if(alpha == base_mask) + do { - pdst[order_type::R] = psrc[src_order::R]; - pdst[order_type::G] = psrc[src_order::G]; - pdst[order_type::B] = psrc[src_order::B]; + const color_type& color = color_lut[*psrc]; + m_blender.blend_pix(pdst, + color.r, color.g, color.b, color.a); + ++psrc; + pdst += 3; } - else + while(--len); + } + else + { + do { - m_blender.blend_pix(pdst, - psrc[src_order::R], - psrc[src_order::G], - psrc[src_order::B], - alpha, - 255); + copy_or_blend_pix(pdst, color_lut[*psrc], cover); + ++psrc; + pdst += 3; } + while(--len); } - psrc += 4; - pdst += 3; } - while(--len); } private: - rendering_buffer* m_rbuf; - Blender m_blender; + rbuf_type* m_rbuf; + Blender m_blender; }; - typedef pixel_formats_rgb > pixfmt_rgb24; //----pixfmt_rgb24 - typedef pixel_formats_rgb > pixfmt_bgr24; //----pixfmt_bgr24 - typedef pixel_formats_rgb > pixfmt_rgb48; //----pixfmt_rgb48 - typedef pixel_formats_rgb > pixfmt_bgr48; //----pixfmt_bgr48 - - typedef pixel_formats_rgb > pixfmt_rgb24_pre; //----pixfmt_rgb24_pre - typedef pixel_formats_rgb > pixfmt_bgr24_pre; //----pixfmt_bgr24_pre - typedef pixel_formats_rgb > pixfmt_rgb48_pre; //----pixfmt_rgb48_pre - typedef pixel_formats_rgb > pixfmt_bgr48_pre; //----pixfmt_bgr48_pre + typedef pixfmt_alpha_blend_rgb, rendering_buffer> pixfmt_rgb24; //----pixfmt_rgb24 + typedef pixfmt_alpha_blend_rgb, rendering_buffer> pixfmt_bgr24; //----pixfmt_bgr24 + typedef pixfmt_alpha_blend_rgb, rendering_buffer> pixfmt_rgb48; //----pixfmt_rgb48 + typedef pixfmt_alpha_blend_rgb, rendering_buffer> pixfmt_bgr48; //----pixfmt_bgr48 + + typedef pixfmt_alpha_blend_rgb, rendering_buffer> pixfmt_rgb24_pre; //----pixfmt_rgb24_pre + typedef pixfmt_alpha_blend_rgb, rendering_buffer> pixfmt_bgr24_pre; //----pixfmt_bgr24_pre + typedef pixfmt_alpha_blend_rgb, rendering_buffer> pixfmt_rgb48_pre; //----pixfmt_rgb48_pre + typedef pixfmt_alpha_blend_rgb, rendering_buffer> pixfmt_bgr48_pre; //----pixfmt_bgr48_pre //-----------------------------------------------------pixfmt_rgb24_gamma template class pixfmt_rgb24_gamma : - public pixel_formats_rgb > + public pixfmt_alpha_blend_rgb, rendering_buffer> { public: pixfmt_rgb24_gamma(rendering_buffer& rb, const Gamma& g) : - pixel_formats_rgb >(rb) + pixfmt_alpha_blend_rgb, rendering_buffer>(rb) { this->blender().gamma(g); } @@ -719,11 +819,11 @@ namespace agg //-----------------------------------------------------pixfmt_bgr24_gamma template class pixfmt_bgr24_gamma : - public pixel_formats_rgb > + public pixfmt_alpha_blend_rgb, rendering_buffer> { public: pixfmt_bgr24_gamma(rendering_buffer& rb, const Gamma& g) : - pixel_formats_rgb >(rb) + pixfmt_alpha_blend_rgb, rendering_buffer>(rb) { this->blender().gamma(g); } @@ -731,11 +831,11 @@ namespace agg //-----------------------------------------------------pixfmt_rgb48_gamma template class pixfmt_rgb48_gamma : - public pixel_formats_rgb > + public pixfmt_alpha_blend_rgb, rendering_buffer> { public: pixfmt_rgb48_gamma(rendering_buffer& rb, const Gamma& g) : - pixel_formats_rgb >(rb) + pixfmt_alpha_blend_rgb, rendering_buffer>(rb) { this->blender().gamma(g); } @@ -743,11 +843,11 @@ namespace agg //-----------------------------------------------------pixfmt_bgr48_gamma template class pixfmt_bgr48_gamma : - public pixel_formats_rgb > + public pixfmt_alpha_blend_rgb, rendering_buffer> { public: pixfmt_bgr48_gamma(rendering_buffer& rb, const Gamma& g) : - pixel_formats_rgb >(rb) + pixfmt_alpha_blend_rgb, rendering_buffer>(rb) { this->blender().gamma(g); }