blob: 6c6db7eea4407ed44721579097d3ddfa3a4c1c48 [file] [log] [blame]
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
Pierre Ossman6a1a0d02017-02-19 15:48:17 +01002 * Copyright 2014-2017 Pierre Ossman for Cendio AB
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00003 *
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
29namespace rfb {
30
Pierre Ossman6a1a0d02017-02-19 15:48:17 +010031 class Cursor {
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000032 public:
Pierre Ossman6a1a0d02017-02-19 15:48:17 +010033 Cursor(int width, int height, const Point& hotspot, const rdr::U8* data);
34 Cursor(const Cursor& other);
35 ~Cursor();
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000036
Pierre Ossman6a1a0d02017-02-19 15:48:17 +010037 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 Kaplinskya2adc8d2006-05-25 05:01:55 +000041
Pierre Ossman6a1a0d02017-02-19 15:48:17 +010042 // 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 Kaplinskya2adc8d2006-05-25 05:01:55 +000046
47 // crop() crops the cursor down to the smallest possible size, based on the
48 // mask.
49 void crop();
Pierre Ossman6a1a0d02017-02-19 15:48:17 +010050
51 protected:
52 int width_, height_;
53 Point hotspot_;
54 rdr::U8* data;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000055 };
56
Pierre Ossman6ea6e1a2014-02-12 16:33:43 +010057 class RenderedCursor : public PixelBuffer {
58 public:
59 RenderedCursor();
60
61 Rect getEffectiveRect() const { return buffer.getRect(offset); }
62
Pierre Ossmand4f718d2014-02-13 14:37:25 +010063 virtual const rdr::U8* getBuffer(const Rect& r, int* stride) const;
Pierre Ossman6ea6e1a2014-02-12 16:33:43 +010064
65 void update(PixelBuffer* framebuffer, Cursor* cursor, const Point& pos);
66
67 protected:
68 ManagedPixelBuffer buffer;
69 Point offset;
70 };
71
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000072}
73#endif