Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. |
Pierre Ossman | 316a324 | 2014-01-15 12:40:20 +0100 | [diff] [blame] | 2 | * Copyright 2014 Pierre Ossman for Cendio AB |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 3 | * |
| 4 | * This is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This software is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this software; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 17 | * USA. |
| 18 | */ |
| 19 | #include <stdio.h> |
Pierre Ossman | 316a324 | 2014-01-15 12:40:20 +0100 | [diff] [blame] | 20 | #include <rfb/encodings.h> |
Pierre Ossman | 1412789 | 2015-11-12 13:17:42 +0100 | [diff] [blame] | 21 | #include <rfb/Region.h> |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 22 | #include <rfb/Decoder.h> |
| 23 | #include <rfb/RawDecoder.h> |
Pierre Ossman | d704e4a | 2014-01-31 11:21:51 +0100 | [diff] [blame] | 24 | #include <rfb/CopyRectDecoder.h> |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 25 | #include <rfb/RREDecoder.h> |
| 26 | #include <rfb/HextileDecoder.h> |
| 27 | #include <rfb/ZRLEDecoder.h> |
| 28 | #include <rfb/TightDecoder.h> |
| 29 | |
| 30 | using namespace rfb; |
| 31 | |
Pierre Ossman | 570cd5c | 2015-11-12 13:07:42 +0100 | [diff] [blame] | 32 | Decoder::Decoder(enum DecoderFlags flags) : flags(flags) |
Pierre Ossman | 4aba19e | 2014-01-29 16:42:48 +0100 | [diff] [blame] | 33 | { |
| 34 | } |
| 35 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 36 | Decoder::~Decoder() |
| 37 | { |
| 38 | } |
| 39 | |
Pierre Ossman | 1412789 | 2015-11-12 13:17:42 +0100 | [diff] [blame] | 40 | void Decoder::getAffectedRegion(const Rect& rect, const void* buffer, |
Pierre Ossman | b14a6bc | 2018-06-18 15:44:26 +0200 | [diff] [blame] | 41 | size_t buflen, const ServerParams& server, |
Pierre Ossman | 1412789 | 2015-11-12 13:17:42 +0100 | [diff] [blame] | 42 | Region* region) |
| 43 | { |
| 44 | region->reset(rect); |
| 45 | } |
| 46 | |
Pierre Ossman | e6ad445 | 2015-11-13 10:47:28 +0100 | [diff] [blame] | 47 | bool Decoder::doRectsConflict(const Rect& rectA, const void* bufferA, |
| 48 | size_t buflenA, const Rect& rectB, |
| 49 | const void* bufferB, size_t buflenB, |
Pierre Ossman | b14a6bc | 2018-06-18 15:44:26 +0200 | [diff] [blame] | 50 | const ServerParams& server) |
Pierre Ossman | e6ad445 | 2015-11-13 10:47:28 +0100 | [diff] [blame] | 51 | { |
| 52 | return false; |
| 53 | } |
| 54 | |
Peter Åstrand | 98fe98c | 2010-02-10 07:43:02 +0000 | [diff] [blame] | 55 | bool Decoder::supported(int encoding) |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 56 | { |
Pierre Ossman | 316a324 | 2014-01-15 12:40:20 +0100 | [diff] [blame] | 57 | switch (encoding) { |
| 58 | case encodingRaw: |
Pierre Ossman | d704e4a | 2014-01-31 11:21:51 +0100 | [diff] [blame] | 59 | case encodingCopyRect: |
Pierre Ossman | 316a324 | 2014-01-15 12:40:20 +0100 | [diff] [blame] | 60 | case encodingRRE: |
| 61 | case encodingHextile: |
| 62 | case encodingZRLE: |
| 63 | case encodingTight: |
| 64 | return true; |
| 65 | default: |
| 66 | return false; |
| 67 | } |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 68 | } |
| 69 | |
Pierre Ossman | 8635062 | 2015-11-10 13:02:12 +0100 | [diff] [blame] | 70 | Decoder* Decoder::createDecoder(int encoding) |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 71 | { |
Pierre Ossman | 316a324 | 2014-01-15 12:40:20 +0100 | [diff] [blame] | 72 | switch (encoding) { |
| 73 | case encodingRaw: |
Pierre Ossman | 8635062 | 2015-11-10 13:02:12 +0100 | [diff] [blame] | 74 | return new RawDecoder(); |
Pierre Ossman | d704e4a | 2014-01-31 11:21:51 +0100 | [diff] [blame] | 75 | case encodingCopyRect: |
Pierre Ossman | 8635062 | 2015-11-10 13:02:12 +0100 | [diff] [blame] | 76 | return new CopyRectDecoder(); |
Pierre Ossman | 316a324 | 2014-01-15 12:40:20 +0100 | [diff] [blame] | 77 | case encodingRRE: |
Pierre Ossman | 8635062 | 2015-11-10 13:02:12 +0100 | [diff] [blame] | 78 | return new RREDecoder(); |
Pierre Ossman | 316a324 | 2014-01-15 12:40:20 +0100 | [diff] [blame] | 79 | case encodingHextile: |
Pierre Ossman | 8635062 | 2015-11-10 13:02:12 +0100 | [diff] [blame] | 80 | return new HextileDecoder(); |
Pierre Ossman | 316a324 | 2014-01-15 12:40:20 +0100 | [diff] [blame] | 81 | case encodingZRLE: |
Pierre Ossman | 8635062 | 2015-11-10 13:02:12 +0100 | [diff] [blame] | 82 | return new ZRLEDecoder(); |
Pierre Ossman | 316a324 | 2014-01-15 12:40:20 +0100 | [diff] [blame] | 83 | case encodingTight: |
Pierre Ossman | 8635062 | 2015-11-10 13:02:12 +0100 | [diff] [blame] | 84 | return new TightDecoder(); |
Pierre Ossman | 316a324 | 2014-01-15 12:40:20 +0100 | [diff] [blame] | 85 | default: |
| 86 | return NULL; |
| 87 | } |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 88 | } |