blob: 818daf660de8a4047d76a4db3dbb7cda84095391 [file] [log] [blame]
Pierre Ossmana2739342011-03-08 16:53:07 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
2 * Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB
DRCffe09d62011-08-17 02:27:59 +00003 * Copyright (C) 2011 D. R. Commander. All Rights Reserved.
Pierre Ossmana2739342011-03-08 16:53:07 +00004 *
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
DRCffe09d62011-08-17 02:27:59 +000024#include <stdlib.h>
Pierre Ossmana2739342011-03-08 16:53:07 +000025#include <rfb/Rect.h>
26#include <rfb/PixelFormat.h>
27
28namespace rfb {
29 typedef void (*transFnType)(void* table_,
Pierre Ossman654e3f92012-01-30 13:53:11 +000030 const PixelFormat& inPF, const void* inPtr,
Pierre Ossmana2739342011-03-08 16:53:07 +000031 int inStride,
32 const PixelFormat& outPF, void* outPtr,
33 int outStride, int width, int height);
34
35 class SMsgWriter;
Pierre Ossmana2739342011-03-08 16:53:07 +000036 class PixelBuffer;
Pierre Ossmana2739342011-03-08 16:53:07 +000037
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 Ossmanb6b4dc62014-01-20 15:05:21 +010046 // target pixel format.
Pierre Ossmana2739342011-03-08 16:53:07 +000047
Pierre Ossmanb6b4dc62014-01-20 15:05:21 +010048 void init(const PixelFormat& inPF, const PixelFormat& outPF);
Pierre Ossmana2739342011-03-08 16:53:07 +000049
Pierre Ossman62ea8a22011-07-15 08:26:18 +000050 const PixelFormat &getInPF() const;
Pierre Ossman62ea8a22011-07-15 08:26:18 +000051 const PixelFormat &getOutPF() const;
Pierre Ossmana2739342011-03-08 16:53:07 +000052
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 Ossman654e3f92012-01-30 13:53:11 +000057 void translatePixels(const void* inPtr, void* outPtr, int nPixels) const;
Pierre Ossmana2739342011-03-08 16:53:07 +000058
59 // Similar to translatePixels() but handles an arbitrary region of
60 // two pixel buffers.
Pierre Ossman654e3f92012-01-30 13:53:11 +000061 void translateRect(const void* inPtr, int inStride, Rect inRect,
Pierre Ossmana2739342011-03-08 16:53:07 +000062 void* outPtr, int outStride, Point outCoord) const;
63
DRCffe09d62011-08-17 02:27:59 +000064 bool willTransform(void);
65
Pierre Ossmana2739342011-03-08 16:53:07 +000066 private:
67 bool economic;
68
69 PixelFormat inPF;
Pierre Ossmana2739342011-03-08 16:53:07 +000070 PixelFormat outPF;
Pierre Ossmana2739342011-03-08 16:53:07 +000071
72 rdr::U8* table;
73 transFnType transFn;
74 };
75}
76#endif