Logo
  • Main Page
  • Related Pages
  • Modules
  • Classes
  • Files

mmsfb_blit_argb3565_to_argb3565.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2007 Stefan Schwarzer, Jens Schneider,             *
00003  *                           Matthias Hardt, Guido Madaus                  *
00004  *                                                                         *
00005  *   Copyright (C) 2007-2008 BerLinux Solutions GbR                        *
00006  *                           Stefan Schwarzer & Guido Madaus               *
00007  *                                                                         *
00008  *   Copyright (C) 2009-2013 BerLinux Solutions GmbH                       *
00009  *                                                                         *
00010  *   Authors:                                                              *
00011  *      Stefan Schwarzer   <stefan.schwarzer@diskohq.org>,                 *
00012  *      Matthias Hardt     <matthias.hardt@diskohq.org>,                   *
00013  *      Jens Schneider     <jens.schneider@diskohq.org>,                   *
00014  *      Guido Madaus       <guido.madaus@diskohq.org>,                     *
00015  *      Patrick Helterhoff <patrick.helterhoff@diskohq.org>,               *
00016  *      René Bählkow       <rene.baehlkow@diskohq.org>                     *
00017  *                                                                         *
00018  *   This library is free software; you can redistribute it and/or         *
00019  *   modify it under the terms of the GNU Lesser General Public            *
00020  *   License version 2.1 as published by the Free Software Foundation.     *
00021  *                                                                         *
00022  *   This library is distributed in the hope that it will be useful,       *
00023  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00024  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00025  *   Lesser General Public License for more details.                       *
00026  *                                                                         *
00027  *   You should have received a copy of the GNU Lesser General Public      *
00028  *   License along with this library; if not, write to the                 *
00029  *   Free Software Foundation, Inc.,                                       *
00030  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
00031  **************************************************************************/
00032 
00033 #include "mmsgui/fb/mmsfbconv.h"
00034 
00035 #ifdef __HAVE_PF_ARGB3565__
00036 
00037 #include <cstring>
00038 #include "mmstools/mmstools.h"
00039 
00040 void mmsfb_blit_argb3565_to_argb3565(MMSFBSurfacePlanes *src_planes, int src_height, int sx, int sy, int sw, int sh,
00041                                      MMSFBSurfacePlanes *dst_planes, int dst_height, int dx, int dy) {
00042     // first time?
00043     static bool firsttime = true;
00044     if (firsttime) {
00045         printf("DISKO: Using accelerated copy ARGB3565 to ARGB3565.\n");
00046         firsttime = false;
00047     }
00048 
00049     // SRC: point to the first plane (RGB16/RGB565 format)
00050     unsigned short int *src = (unsigned short int *)src_planes->ptr;
00051     int src_pitch = src_planes->pitch;
00052 
00053     // SRC: point to the second plane (3 bit alpha (2 pixels per byte, 4 bit per pixel))
00054     unsigned char *src_a;
00055     int src_a_pitch;
00056     if (src_planes->ptr2) {
00057         // plane pointer given
00058         src_a = (unsigned char *)src_planes->ptr2;
00059         src_a_pitch = src_planes->pitch2;
00060     }
00061     else {
00062         // calc plane pointer (after the first plane)
00063         src_a = ((unsigned char *)src_planes->ptr) + src_planes->pitch * src_height;
00064         src_a_pitch = src_planes->pitch / 4;
00065     }
00066 
00067     // DST: point to the first plane (RGB16/RGB565 format)
00068     unsigned short int *dst = (unsigned short int *)dst_planes->ptr;
00069     int dst_pitch = dst_planes->pitch;
00070 
00071     // DST: point to the second plane (3 bit alpha (2 pixels per byte, 4 bit per pixel))
00072     unsigned char *dst_a;
00073     int dst_a_pitch;
00074     if (dst_planes->ptr2) {
00075         // plane pointer given
00076         dst_a = (unsigned char *)dst_planes->ptr2;
00077         dst_a_pitch = dst_planes->pitch2;
00078     }
00079     else {
00080         // calc plane pointer (after the first plane)
00081         dst_a = ((unsigned char *)dst_planes->ptr) + dst_planes->pitch * dst_height;
00082         dst_a_pitch = dst_planes->pitch / 4;
00083     }
00084 
00085     // working for first plane (RGB16/RGB565 format)
00086     ////////////////////////////////////////////////
00087     int src_pitch_pix = src_pitch >> 1;
00088     int dst_pitch_pix = dst_pitch >> 1;
00089     src+= sx + sy * src_pitch_pix;
00090     dst+= dx + dy * dst_pitch_pix;
00091 
00092     // check the surface range
00093     if (dst_pitch_pix - dx < sw - sx)
00094         sw = dst_pitch_pix - dx - sx;
00095     if (dst_height - dy < sh - sy)
00096         sh = dst_height - dy - sy;
00097     if ((sw <= 0)||(sh <= 0))
00098         return;
00099 
00100     unsigned short int *src_end = src + src_pitch_pix * sh;
00101 
00102     // for all lines
00103     while (src < src_end) {
00104         // copy the line
00105         memcpy(dst, src, sw << 1);
00106 
00107         // go to the next line
00108         src+= src_pitch_pix;
00109         dst+= dst_pitch_pix;
00110     }
00111 
00112 
00113     // working for second plane (3 bit alpha (2 pixels per byte, 4 bit per pixel))
00114     //////////////////////////////////////////////////////////////////////////////
00115     src_a+= (sx >> 1) + sy * src_a_pitch;
00116     dst_a+= (dx >> 1) + dy * dst_a_pitch;
00117 
00118     // check odd/even
00119     bool odd_left   = (dx & 0x01);
00120     bool odd_right  = ((dx + sw) & 0x01);
00121 
00122     //TODO: not even...
00123 
00124 
00125 
00126     // calc even positions...
00127     if (odd_left) {
00128         // odd left
00129         dx++;
00130         sw--;
00131         src_a++;
00132         dst_a++;
00133     }
00134 
00135     if (odd_right) {
00136         // odd right
00137         sw--;
00138     }
00139 
00140     // now we are even aligned and can go through a optimized loop
00141     ////////////////////////////////////////////////////////////////////////
00142     src_end = (unsigned short int *)(src_a + src_a_pitch * sh);
00143 
00144     // for all lines
00145     while (src_a < (unsigned char *)src_end) {
00146         // copy the line
00147         memcpy(dst_a, src_a, sw >> 1);
00148 
00149         // go to the next line
00150         src_a+= src_a_pitch;
00151         dst_a+= dst_a_pitch;
00152     }
00153 }
00154 
00155 #endif

Generated by doxygen