blob: 2692c18a71a38aab2bc877a0ed2ad503f01d0d39 [file] [log] [blame]
Constantin Kaplinsky2c019832008-05-30 11:02:04 +00001/* Copyright (C) 2007-2008 Constantin Kaplinsky. All Rights Reserved.
Constantin Kaplinskyb3530d42007-12-26 19:17:02 +00002 *
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//
20// XPixelBuffer.cxx
21//
22
Constantin Kaplinsky429ea962008-06-02 11:56:57 +000023#include <vector>
24#include <rfb/Region.h>
Constantin Kaplinsky936c3692007-12-27 08:42:53 +000025#include <X11/Xlib.h>
Constantin Kaplinskyb3530d42007-12-26 19:17:02 +000026#include <x0vncserver/XPixelBuffer.h>
27
Constantin Kaplinsky936c3692007-12-27 08:42:53 +000028using namespace rfb;
29
30XPixelBuffer::XPixelBuffer(Display *dpy, Image* image,
31 int offsetLeft, int offsetTop,
32 const PixelFormat& pf, ColourMap* cm)
33 : FullFramePixelBuffer(pf, image->xim->width, image->xim->height,
34 (rdr::U8 *)image->xim->data, cm),
35 m_dpy(dpy),
36 m_image(image),
37 m_offsetLeft(offsetLeft),
38 m_offsetTop(offsetTop),
39 m_stride(image->xim->bytes_per_line * 8 / image->xim->bits_per_pixel)
Constantin Kaplinskyb3530d42007-12-26 19:17:02 +000040{
Constantin Kaplinsky429ea962008-06-02 11:56:57 +000041 // Get initial screen image.
42 m_image->get(DefaultRootWindow(m_dpy), m_offsetLeft, m_offsetTop);
Constantin Kaplinskyb3530d42007-12-26 19:17:02 +000043}
44
Constantin Kaplinsky936c3692007-12-27 08:42:53 +000045XPixelBuffer::~XPixelBuffer()
46{
47}
48
49void
50XPixelBuffer::grabRegion(const rfb::Region& region)
51{
Constantin Kaplinsky429ea962008-06-02 11:56:57 +000052 std::vector<Rect> rects;
53 std::vector<Rect>::const_iterator i;
54 region.get_rects(&rects);
55 for (i = rects.begin(); i != rects.end(); i++) {
56 grabRect(*i);
57 }
Constantin Kaplinsky936c3692007-12-27 08:42:53 +000058}
59