Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. |
Pierre Ossman | 6ea6e1a | 2014-02-12 16:33:43 +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 | // |
| 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 | |
| 31 | class Cursor : public ManagedPixelBuffer { |
| 32 | public: |
| 33 | Cursor() {} |
| 34 | rdr::U8Array mask; |
| 35 | Point hotspot; |
| 36 | |
| 37 | int maskLen() { return (width() + 7) / 8 * height(); } |
| 38 | |
| 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. |
| 49 | rdr::U8* getBitmap(Pixel* pix0, Pixel* pix1); |
| 50 | |
| 51 | // crop() crops the cursor down to the smallest possible size, based on the |
| 52 | // mask. |
| 53 | void crop(); |
| 54 | }; |
| 55 | |
Pierre Ossman | 6ea6e1a | 2014-02-12 16:33:43 +0100 | [diff] [blame^] | 56 | class RenderedCursor : public PixelBuffer { |
| 57 | public: |
| 58 | RenderedCursor(); |
| 59 | |
| 60 | Rect getEffectiveRect() const { return buffer.getRect(offset); } |
| 61 | |
| 62 | virtual const rdr::U8* getBuffer(const Rect& r, int* stride); |
| 63 | |
| 64 | void update(PixelBuffer* framebuffer, Cursor* cursor, const Point& pos); |
| 65 | |
| 66 | protected: |
| 67 | ManagedPixelBuffer buffer; |
| 68 | Point offset; |
| 69 | }; |
| 70 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 71 | } |
| 72 | #endif |