Pierre Ossman | a273934 | 2011-03-08 16:53:07 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. |
| 2 | * Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB |
DRC | ffe09d6 | 2011-08-17 02:27:59 +0000 | [diff] [blame] | 3 | * Copyright (C) 2011 D. R. Commander. All Rights Reserved. |
Pierre Ossman | a273934 | 2011-03-08 16:53:07 +0000 | [diff] [blame] | 4 | * |
| 5 | * This is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This software is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this software; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 18 | * USA. |
| 19 | */ |
| 20 | |
| 21 | #ifndef __RFB_PIXELTRANSFORMER_H__ |
| 22 | #define __RFB_PIXELTRANSFORMER_H__ |
| 23 | |
DRC | ffe09d6 | 2011-08-17 02:27:59 +0000 | [diff] [blame] | 24 | #include <stdlib.h> |
Pierre Ossman | a273934 | 2011-03-08 16:53:07 +0000 | [diff] [blame] | 25 | #include <rfb/Rect.h> |
| 26 | #include <rfb/PixelFormat.h> |
| 27 | |
| 28 | namespace rfb { |
| 29 | typedef void (*transFnType)(void* table_, |
Pierre Ossman | 654e3f9 | 2012-01-30 13:53:11 +0000 | [diff] [blame] | 30 | const PixelFormat& inPF, const void* inPtr, |
Pierre Ossman | a273934 | 2011-03-08 16:53:07 +0000 | [diff] [blame] | 31 | int inStride, |
| 32 | const PixelFormat& outPF, void* outPtr, |
| 33 | int outStride, int width, int height); |
| 34 | |
| 35 | class SMsgWriter; |
Pierre Ossman | a273934 | 2011-03-08 16:53:07 +0000 | [diff] [blame] | 36 | class PixelBuffer; |
Pierre Ossman | a273934 | 2011-03-08 16:53:07 +0000 | [diff] [blame] | 37 | |
| 38 | class PixelTransformer { |
| 39 | public: |
| 40 | |
| 41 | PixelTransformer(bool econ=false); |
| 42 | virtual ~PixelTransformer(); |
| 43 | |
| 44 | // init() is called to initialise the translation tables. The inPF and |
| 45 | // inCM arguments give the source format details, outPF gives the |
Pierre Ossman | b6b4dc6 | 2014-01-20 15:05:21 +0100 | [diff] [blame] | 46 | // target pixel format. |
Pierre Ossman | a273934 | 2011-03-08 16:53:07 +0000 | [diff] [blame] | 47 | |
Pierre Ossman | b6b4dc6 | 2014-01-20 15:05:21 +0100 | [diff] [blame] | 48 | void init(const PixelFormat& inPF, const PixelFormat& outPF); |
Pierre Ossman | a273934 | 2011-03-08 16:53:07 +0000 | [diff] [blame] | 49 | |
Pierre Ossman | 62ea8a2 | 2011-07-15 08:26:18 +0000 | [diff] [blame] | 50 | const PixelFormat &getInPF() const; |
Pierre Ossman | 62ea8a2 | 2011-07-15 08:26:18 +0000 | [diff] [blame] | 51 | const PixelFormat &getOutPF() const; |
Pierre Ossman | a273934 | 2011-03-08 16:53:07 +0000 | [diff] [blame] | 52 | |
| 53 | // translatePixels() translates the given number of pixels from inPtr, |
| 54 | // putting it into the buffer pointed to by outPtr. The pixels at inPtr |
| 55 | // should be in the format given by inPF to init(), and the translated |
| 56 | // pixels will be in the format given by the outPF argument to init(). |
Pierre Ossman | 654e3f9 | 2012-01-30 13:53:11 +0000 | [diff] [blame] | 57 | void translatePixels(const void* inPtr, void* outPtr, int nPixels) const; |
Pierre Ossman | a273934 | 2011-03-08 16:53:07 +0000 | [diff] [blame] | 58 | |
| 59 | // Similar to translatePixels() but handles an arbitrary region of |
| 60 | // two pixel buffers. |
Pierre Ossman | 654e3f9 | 2012-01-30 13:53:11 +0000 | [diff] [blame] | 61 | void translateRect(const void* inPtr, int inStride, Rect inRect, |
Pierre Ossman | a273934 | 2011-03-08 16:53:07 +0000 | [diff] [blame] | 62 | void* outPtr, int outStride, Point outCoord) const; |
| 63 | |
DRC | ffe09d6 | 2011-08-17 02:27:59 +0000 | [diff] [blame] | 64 | bool willTransform(void); |
| 65 | |
Pierre Ossman | a273934 | 2011-03-08 16:53:07 +0000 | [diff] [blame] | 66 | private: |
| 67 | bool economic; |
| 68 | |
| 69 | PixelFormat inPF; |
Pierre Ossman | a273934 | 2011-03-08 16:53:07 +0000 | [diff] [blame] | 70 | PixelFormat outPF; |
Pierre Ossman | a273934 | 2011-03-08 16:53:07 +0000 | [diff] [blame] | 71 | |
| 72 | rdr::U8* table; |
| 73 | transFnType transFn; |
| 74 | }; |
| 75 | } |
| 76 | #endif |