blob: 7718c339ab554700426e7699f707b8c2252ce94c [file] [log] [blame]
Constantin Kaplinsky729598c2006-05-25 05:12:25 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18
19// -=- DeviceFrameBuffer.h
20//
21// The DeviceFrameBuffer class encapsulates the pixel data of a supplied
22// Device Context Handle (HDC)
23
24// *** THIS INTERFACE NEEDS TIDYING TO SEPARATE COORDINATE SYSTEMS BETTER ***
25
26#ifndef __RFB_WIN32_DEVICE_FRAME_BUFFER_H__
27#define __RFB_WIN32_DEVICE_FRAME_BUFFER_H__
28
29#include <windows.h>
30#include <rfb_win32/DIBSectionBuffer.h>
31#include <rfb/Cursor.h>
32#include <rfb/Region.h>
33#include <rfb/Exception.h>
34#include <rfb/Configuration.h>
35
36namespace rfb {
37
38 class VNCServer;
39
40 namespace win32 {
41
42 // -=- DeviceFrameBuffer interface
43
44 // DeviceFrameBuffer is passed an HDC referring to a window or to
45 // the entire display. It may also be passed a rectangle specifying
46 // the Device-relative coordinates of the actual rectangle to treat
47 // as the desktop.
48
49 // Coordinate systems start getting really annoying here. There are
50 // three different "origins" to which coordinates might be relative:
51 //
52 // Desktop - VNC coordinates, top-left always (0,0)
53 // Device - DC coordinates. Top-left *usually (0,0) but could be other.
54 // Window - coordinates relative to the specified sub-rectangle within
55 // the supplied DC.
56 // Screen - Coordinates relative to the entire Windows virtual screen.
57 // The virtual screen includes all monitors that are part of
58 // the Windows desktop.
59
60 // The data member is made to point to an internal mirror of the
61 // current display data. Individual rectangles or regions of the
62 // buffer can be brought up to date by calling the grab functions.
63
64 class DeviceFrameBuffer : public DIBSectionBuffer {
65 public:
66 DeviceFrameBuffer(HDC deviceContext, const Rect& area_=Rect());
67 virtual ~DeviceFrameBuffer();
68
69 // - FrameBuffer overrides
70
71 virtual void grabRect(const Rect &rect);
72 virtual void grabRegion(const Region &region);
73
74 // - DIBSectionBuffer overrides
75
76 virtual void setPF(const PixelFormat& pf);
77 virtual void setSize(int w, int h);
78
79 // - DeviceFrameBuffer specific methods
80
81 void setCursor(HCURSOR c, VNCServer* server);
82 void updateColourMap();
83
84 // Set whether grabRect should ignore errors or throw exceptions
85 // Only set this if you are sure you'll capture the errors some other way!
86 void setIgnoreGrabErrors(bool ie) {ignoreGrabErrors=ie;}
87
88 static BoolParameter useCaptureBlt;
89
90 protected:
91 // Translate supplied Desktop coordinates into Device-relative coordinates
92 // This translation may have been affected at start-time by the supplied sub-rect.
93 Point desktopToDevice(const Point p) const {return p.translate(deviceCoords.tl);}
94
95 HDC device;
96 DIBSectionBuffer cursorBm;
97 Cursor cursor;
98 Rect deviceCoords;
99 bool ignoreGrabErrors;
100 };
101
102 };
103
104};
105
106#endif // __RFB_WIN32_DEVICE_FRAME_BUFFER_H__