Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. |
Pierre Ossman | 6a1a0d0 | 2017-02-19 15:48:17 +0100 | [diff] [blame] | 2 | * Copyright 2014-2017 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 | // |
| 20 | // Cursor - structure containing information describing |
| 21 | // the current cursor shape |
| 22 | // |
| 23 | |
| 24 | #ifndef __RFB_CURSOR_H__ |
| 25 | #define __RFB_CURSOR_H__ |
| 26 | |
| 27 | #include <rfb/PixelBuffer.h> |
| 28 | |
| 29 | namespace rfb { |
| 30 | |
Pierre Ossman | 6a1a0d0 | 2017-02-19 15:48:17 +0100 | [diff] [blame] | 31 | class Cursor { |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 32 | public: |
Pierre Ossman | 6a1a0d0 | 2017-02-19 15:48:17 +0100 | [diff] [blame] | 33 | Cursor(int width, int height, const Point& hotspot, const rdr::U8* data); |
| 34 | Cursor(const Cursor& other); |
| 35 | ~Cursor(); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 36 | |
Pierre Ossman | 6a1a0d0 | 2017-02-19 15:48:17 +0100 | [diff] [blame] | 37 | int width() const { return width_; }; |
| 38 | int height() const { return height_; }; |
| 39 | const Point& hotspot() const { return hotspot_; }; |
| 40 | const rdr::U8* getBuffer() const { return data; }; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 41 | |
Pierre Ossman | 6a1a0d0 | 2017-02-19 15:48:17 +0100 | [diff] [blame] | 42 | // getBitmap() returns a monochrome version of the cursor |
| 43 | rdr::U8* getBitmap() const; |
| 44 | // getMask() returns a simple mask version of the alpha channel |
| 45 | rdr::U8* getMask() const; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 46 | |
| 47 | // crop() crops the cursor down to the smallest possible size, based on the |
| 48 | // mask. |
| 49 | void crop(); |
Pierre Ossman | 6a1a0d0 | 2017-02-19 15:48:17 +0100 | [diff] [blame] | 50 | |
| 51 | protected: |
| 52 | int width_, height_; |
| 53 | Point hotspot_; |
| 54 | rdr::U8* data; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 55 | }; |
| 56 | |
Pierre Ossman | 6ea6e1a | 2014-02-12 16:33:43 +0100 | [diff] [blame] | 57 | class RenderedCursor : public PixelBuffer { |
| 58 | public: |
| 59 | RenderedCursor(); |
| 60 | |
| 61 | Rect getEffectiveRect() const { return buffer.getRect(offset); } |
| 62 | |
Pierre Ossman | d4f718d | 2014-02-13 14:37:25 +0100 | [diff] [blame] | 63 | virtual const rdr::U8* getBuffer(const Rect& r, int* stride) const; |
Pierre Ossman | 6ea6e1a | 2014-02-12 16:33:43 +0100 | [diff] [blame] | 64 | |
| 65 | void update(PixelBuffer* framebuffer, Cursor* cursor, const Point& pos); |
| 66 | |
| 67 | protected: |
| 68 | ManagedPixelBuffer buffer; |
| 69 | Point offset; |
| 70 | }; |
| 71 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 72 | } |
| 73 | #endif |