blob: 560e4d818525605dce043b84a4976c6f8409b514 [file] [log] [blame]
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
Pierre Ossman6ea6e1a2014-02-12 16:33:43 +01002 * Copyright 2014 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
31 class Cursor : public ManagedPixelBuffer {
32 public:
33 Cursor() {}
34 rdr::U8Array mask;
35 Point hotspot;
36
Pierre Ossmand4f718d2014-02-13 14:37:25 +010037 int maskLen() const { return (width() + 7) / 8 * height(); }
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000038
39 // setSize() resizes the cursor. The contents of the data and mask are
40 // undefined after this call.
41 virtual void setSize(int w, int h);
42
43 // drawOutline() adds an outline to the cursor in the given colour.
44 void drawOutline(const Pixel& c);
45
46 // getBitmap() tests whether the cursor is monochrome, and if so returns a
47 // bitmap together with background and foreground colours. The size and
48 // layout of the bitmap are the same as the mask.
Pierre Ossmand4f718d2014-02-13 14:37:25 +010049 rdr::U8* getBitmap(Pixel* pix0, Pixel* pix1) const;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000050
51 // crop() crops the cursor down to the smallest possible size, based on the
52 // mask.
53 void crop();
54 };
55
Pierre Ossman6ea6e1a2014-02-12 16:33:43 +010056 class RenderedCursor : public PixelBuffer {
57 public:
58 RenderedCursor();
59
60 Rect getEffectiveRect() const { return buffer.getRect(offset); }
61
Pierre Ossmand4f718d2014-02-13 14:37:25 +010062 virtual const rdr::U8* getBuffer(const Rect& r, int* stride) const;
Pierre Ossman6ea6e1a2014-02-12 16:33:43 +010063
64 void update(PixelBuffer* framebuffer, Cursor* cursor, const Point& pos);
65
66 protected:
67 ManagedPixelBuffer buffer;
68 Point offset;
69 };
70
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000071}
72#endif