Browse Source

Merge branch 'regions' of https://github.com/CendioOssman/tigervnc

tags/v1.10.90
Pierre Ossman 3 years ago
parent
commit
b8a24f055f

+ 0
- 1
.gitignore View File

@@ -7,7 +7,6 @@

CMakeFiles
CMakeCache.txt
*.cmake
Makefile
Makefile.in
config.h

+ 1
- 1
.travis.yml View File

@@ -31,7 +31,7 @@ matrix:
export mingw64="$msys2 -mingw64 -full-path -here -c "\"\$@"\" --"
export msys2+=" -msys2 -c "\"\$@"\" --"
$msys2 pacman --sync --noconfirm --needed mingw-w64-x86_64-toolchain
$msys2 pacman --sync --noconfirm --needed mingw-w64-x86_64-fltk mingw-w64-x86_64-libjpeg-turbo mingw-w64-x86_64-gnutls
$msys2 pacman --sync --noconfirm --needed mingw-w64-x86_64-fltk mingw-w64-x86_64-libjpeg-turbo mingw-w64-x86_64-gnutls mingw-w64-x86_64-pixman
taskkill //IM gpg-agent.exe //F # https://travis-ci.community/t/4967
export PATH=/C/tools/msys64/mingw64/bin:$PATH
export MAKE=mingw32-make # so that Autotools can find it

+ 2
- 0
BUILDING.txt View File

@@ -11,6 +11,8 @@ Build Requirements (All Systems)

-- zlib

-- pixman

-- FLTK 1.3.3 or later

-- If building TLS support:

+ 3
- 0
CMakeLists.txt View File

@@ -137,6 +137,9 @@ endif()
# Check for zlib
find_package(ZLIB REQUIRED)

# Check for pixman
find_package(Pixman REQUIRED)

# Check for gettext
option(ENABLE_NLS "Enable translation of program messages" ON)
if(ENABLE_NLS)

+ 40
- 0
cmake/Modules/FindPixman.cmake View File

@@ -0,0 +1,40 @@
# - Find Pixman
# Find the Pixman libraries
#
# This module defines the following variables:
# PIXMAN_FOUND - true if PIXMAN_INCLUDE_DIR & PIXMAN_LIBRARY are found
# PIXMAN_LIBRARIES - Set when PIXMAN_LIBRARY is found
# PIXMAN_INCLUDE_DIRS - Set when PIXMAN_INCLUDE_DIR is found
#
# PIXMAN_INCLUDE_DIR - where to find pixman.h, etc.
# PIXMAN_LIBRARY - the Pixman library
#

#=============================================================================
# Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================

find_path(PIXMAN_INCLUDE_DIR NAMES pixman.h PATH_SUFFIXES pixman-1)

find_library(PIXMAN_LIBRARY NAMES pixman-1)

find_package_handle_standard_args(pixman-1 DEFAULT_MSG PIXMAN_LIBRARY PIXMAN_INCLUDE_DIR)

if(PIXMAN-1_FOUND)
set(PIXMAN_LIBRARIES ${PIXMAN_LIBRARY})
set(PIXMAN_INCLUDE_DIRS ${PIXMAN_INCLUDE_DIR})
endif()

mark_as_advanced(PIXMAN_INCLUDE_DIR PIXMAN_LIBRARY)

+ 1
- 0
cmake/StaticBuild.cmake View File

@@ -20,6 +20,7 @@ if(BUILD_STATIC)

set(JPEG_LIBRARIES "-Wl,-Bstatic -ljpeg -Wl,-Bdynamic")
set(ZLIB_LIBRARIES "-Wl,-Bstatic -lz -Wl,-Bdynamic")
set(PIXMAN_LIBRARY "-Wl,-Bstatic -lpixman-1 -Wl,-Bdynamic")

# gettext is included in libc on many unix systems
if(NOT LIBC_HAS_DGETTEXT)

+ 1
- 2
common/CMakeLists.txt View File

@@ -1,7 +1,6 @@
add_subdirectory(os)
add_subdirectory(rdr)
add_subdirectory(network)
add_subdirectory(Xregion)
add_subdirectory(rfb)

# For any convenience libraries that are linked into libvnc.so, we need to
@@ -10,6 +9,6 @@ add_subdirectory(rfb)
# is passed (additionally, libvnc is not used on Windows.)

if(NOT WIN32)
set_target_properties(os rdr network Xregion rfb
set_target_properties(os rdr network rfb
PROPERTIES COMPILE_FLAGS -fPIC)
endif()

+ 0
- 6
common/Xregion/CMakeLists.txt View File

@@ -1,6 +0,0 @@
add_library(Xregion STATIC
Region.c)

if(UNIX)
libtool_create_control_file(Xregion)
endif()

+ 0
- 1612
common/Xregion/Region.c
File diff suppressed because it is too large
View File


+ 0
- 50
common/Xregion/Xlib.h View File

@@ -1,50 +0,0 @@
/*

Copyright 1985, 1986, 1987, 1991, 1998 The Open Group

Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.

*/


/*
* Xlib.h - Header definition and support file for the C subroutine
* interface library (Xlib) to the X Window System Protocol (V11).
* Structures and symbols starting with "_" are private to the library.
*/
#ifndef _X11_XLIB_H_
#define _X11_XLIB_H_

#define NeedFunctionPrototypes 1

#define Bool int

typedef struct {
short x, y;
} XPoint;

typedef struct {
short x, y;
unsigned short width, height;
} XRectangle;


#endif /* _X11_XLIB_H_ */

+ 0
- 48
common/Xregion/Xlibint.h View File

@@ -1,48 +0,0 @@

/*

Copyright 1984, 1985, 1987, 1989, 1998 The Open Group

Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.

*/

#ifndef _X11_XLIBINT_H_
#define _X11_XLIBINT_H_ 1

/*
* Xlibint.h - Header definition and support file for the internal
* support routines used by the C subroutine interface
* library (Xlib) to the X Window System.
*
* Warning, there be dragons here....
*/

#include <stdlib.h>

#define Xfree(ptr) free((ptr))
#define Xmalloc(size) malloc((size))
#define Xrealloc(ptr, size) realloc((ptr), (size))
#define Xcalloc(nelem, elsize) calloc((nelem), (elsize))

#endif /* _X11_XLIBINT_H_ */

+ 0
- 190
common/Xregion/Xregion.h View File

@@ -1,190 +0,0 @@
/************************************************************************

Copyright 1987, 1998 The Open Group

Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.


Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.

All Rights Reserved

Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.

DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.

************************************************************************/

#ifndef _X11_XREGION_H_
#define _X11_XREGION_H_

typedef struct {
short x1, x2, y1, y2;
} Box, BOX, BoxRec, *BoxPtr;

typedef struct {
short x, y, width, height;
}RECTANGLE, RectangleRec, *RectanglePtr;

#define TRUE 1
#define FALSE 0
#define MAXSHORT 32767
#define MINSHORT -MAXSHORT
#ifndef MAX
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif


/*
* clip region
*/

typedef struct _XRegion {
long size;
long numRects;
BOX *rects;
BOX extents;
} REGION;

/* Xutil.h contains the declaration:
* typedef struct _XRegion *Region;
*/

/* 1 if two BOXs overlap.
* 0 if two BOXs do not overlap.
* Remember, x2 and y2 are not in the region
*/
#define EXTENTCHECK(r1, r2) \
((r1)->x2 > (r2)->x1 && \
(r1)->x1 < (r2)->x2 && \
(r1)->y2 > (r2)->y1 && \
(r1)->y1 < (r2)->y2)

/*
* update region extents
*/
#define EXTENTS(r,idRect){\
if((r)->x1 < (idRect)->extents.x1)\
(idRect)->extents.x1 = (r)->x1;\
if((r)->y1 < (idRect)->extents.y1)\
(idRect)->extents.y1 = (r)->y1;\
if((r)->x2 > (idRect)->extents.x2)\
(idRect)->extents.x2 = (r)->x2;\
if((r)->y2 > (idRect)->extents.y2)\
(idRect)->extents.y2 = (r)->y2;\
}

/*
* Check to see if there is enough memory in the present region.
*/
#define MEMCHECK(reg, rect, firstrect){\
if ((reg)->numRects >= ((reg)->size - 1)){\
BoxPtr tmpRect = Xrealloc ((firstrect), \
(2 * (sizeof(BOX)) * ((reg)->size))); \
if (tmpRect == NULL) \
return(0);\
(firstrect) = tmpRect; \
(reg)->size *= 2;\
(rect) = &(firstrect)[(reg)->numRects];\
}\
}

/* this routine checks to see if the previous rectangle is the same
* or subsumes the new rectangle to add.
*/

#define CHECK_PREVIOUS(Reg, R, Rx1, Ry1, Rx2, Ry2)\
(!(((Reg)->numRects > 0)&&\
((R-1)->y1 == (Ry1)) &&\
((R-1)->y2 == (Ry2)) &&\
((R-1)->x1 <= (Rx1)) &&\
((R-1)->x2 >= (Rx2))))

/* add a rectangle to the given Region */
#define ADDRECT(reg, r, rx1, ry1, rx2, ry2){\
if (((rx1) < (rx2)) && ((ry1) < (ry2)) &&\
CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
(r)->x1 = (rx1);\
(r)->y1 = (ry1);\
(r)->x2 = (rx2);\
(r)->y2 = (ry2);\
EXTENTS((r), (reg));\
(reg)->numRects++;\
(r)++;\
}\
}



/* add a rectangle to the given Region */
#define ADDRECTNOX(reg, r, rx1, ry1, rx2, ry2){\
if ((rx1 < rx2) && (ry1 < ry2) &&\
CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
(r)->x1 = (rx1);\
(r)->y1 = (ry1);\
(r)->x2 = (rx2);\
(r)->y2 = (ry2);\
(reg)->numRects++;\
(r)++;\
}\
}

#define EMPTY_REGION(pReg) pReg->numRects = 0

#define REGION_NOT_EMPTY(pReg) pReg->numRects

#define INBOX(r, x, y) \
( ( ((r).x2 > x)) && \
( ((r).x1 <= x)) && \
( ((r).y2 > y)) && \
( ((r).y1 <= y)) )

/*
* number of points to buffer before sending them off
* to scanlines() : Must be an even number
*/
#define NUMPTSTOBUFFER 200

/*
* used to allocate buffers for points and link
* the buffers together
*/
typedef struct _POINTBLOCK {
XPoint pts[NUMPTSTOBUFFER];
struct _POINTBLOCK *next;
} POINTBLOCK;

#endif /* _X11_XREGION_H_ */

+ 0
- 167
common/Xregion/Xutil.h View File

@@ -1,167 +0,0 @@

/***********************************************************

Copyright 1987, 1998 The Open Group

Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.


Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.

All Rights Reserved

Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.

DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.

******************************************************************/

#ifndef _X11_XUTIL_H_
#define _X11_XUTIL_H_

/* You must include <X11/Xlib.h> before including this file */
#include "Xlib.h"

/****** Avoid symbol clash with "real" libX11 ******/
#define XClipBox vncXClipBox
#define XCreateRegion vncXCreateRegion
#define XDestroyRegion vncXDestroyRegion
#define XEmptyRegion vncXEmptyRegion
#define XEqualRegion vncXEqualRegion
#define XIntersectRegion vncXIntersectRegion
#define XOffsetRegion vncXOffsetRegion
#define XPointInRegion vncXPointInRegion
#define XPolygonRegion vncXPolygonRegion
#define XRectInRegion vncXRectInRegion
#define XShrinkRegion vncXShrinkRegion
#define XSubtractRegion vncXSubtractRegion
#define XUnionRectWithRegion vncXUnionRectWithRegion
#define XUnionRegion vncXUnionRegion
#define XXorRegion vncXXorRegion

/*
* opaque reference to Region data type
*/
typedef struct _XRegion *Region;

/* Return values from XRectInRegion() */

#define RectangleOut 0
#define RectangleIn 1
#define RectanglePart 2

extern int XClipBox(
Region /* r */,
XRectangle* /* rect_return */
);

extern Region XCreateRegion(
void
);

extern int XDestroyRegion(
Region /* r */
);

extern int XEmptyRegion(
Region /* r */
);

extern int XEqualRegion(
Region /* r1 */,
Region /* r2 */
);

extern int XIntersectRegion(
Region /* sra */,
Region /* srb */,
Region /* dr_return */
);

extern int XOffsetRegion(
Region /* r */,
int /* dx */,
int /* dy */
);

extern Bool XPointInRegion(
Region /* r */,
int /* x */,
int /* y */
);

extern Region XPolygonRegion(
XPoint* /* points */,
int /* n */,
int /* fill_rule */
);

extern int XRectInRegion(
Region /* r */,
int /* x */,
int /* y */,
unsigned int /* width */,
unsigned int /* height */
);

extern int XShrinkRegion(
Region /* r */,
int /* dx */,
int /* dy */
);

extern int XSubtractRegion(
Region /* sra */,
Region /* srb */,
Region /* dr_return */
);

extern int XUnionRectWithRegion(
XRectangle* /* rectangle */,
Region /* src_region */,
Region /* dest_region_return */
);

extern int XUnionRegion(
Region /* sra */,
Region /* srb */,
Region /* dr_return */
);

extern int XXorRegion(
Region /* sra */,
Region /* srb */,
Region /* dr_return */
);

#endif /* _X11_XUTIL_H_ */

+ 2
- 2
common/rfb/CMakeLists.txt View File

@@ -1,4 +1,4 @@
include_directories(${CMAKE_SOURCE_DIR}/common ${JPEG_INCLUDE_DIR})
include_directories(${CMAKE_SOURCE_DIR}/common ${JPEG_INCLUDE_DIR} ${PIXMAN_INCLUDE_DIR})

set(RFB_SOURCES
Blacklist.cxx
@@ -73,7 +73,7 @@ if(WIN32)
set(RFB_SOURCES ${RFB_SOURCES} WinPasswdValidator.cxx)
endif(WIN32)

set(RFB_LIBRARIES ${JPEG_LIBRARIES} os rdr Xregion)
set(RFB_LIBRARIES ${JPEG_LIBRARIES} ${PIXMAN_LIBRARY} os rdr)

if(UNIX AND NOT APPLE)
set(RFB_SOURCES ${RFB_SOURCES} UnixPasswordValidator.cxx

+ 2
- 10
common/rfb/ComparingUpdateTracker.cxx View File

@@ -120,8 +120,6 @@ void ComparingUpdateTracker::compareRect(const Rect& r, Region* newChanged)
rdr::U8* oldData = oldFb.getBufferRW(r, &oldStride);
int oldStrideBytes = oldStride * bytesPerPixel;

std::vector<Rect> changedBlocks;

for (int blockTop = r.tl.y; blockTop < r.br.y; blockTop += BLOCK_SIZE)
{
// Get a strip of the source buffer
@@ -146,8 +144,8 @@ void ComparingUpdateTracker::compareRect(const Rect& r, Region* newChanged)
if (memcmp(oldPtr, newPtr, blockWidthInBytes) != 0)
{
// A block has changed - copy the remainder to the oldFb
changedBlocks.push_back(Rect(blockLeft, blockTop,
blockRight, blockBottom));
newChanged->assign_union(Region(Rect(blockLeft, blockTop,
blockRight, blockBottom)));
for (int y2 = y; y2 < blockBottom; y2++)
{
memcpy(oldPtr, newPtr, blockWidthInBytes);
@@ -169,12 +167,6 @@ void ComparingUpdateTracker::compareRect(const Rect& r, Region* newChanged)
}

oldFb.commitBufferRW(r);

if (!changedBlocks.empty()) {
Region temp;
temp.setOrderedRects(changedBlocks);
newChanged->assign_union(temp);
}
}

void ComparingUpdateTracker::logStats()

+ 52
- 121
common/rfb/Region.cxx View File

@@ -1,4 +1,5 @@
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
* Copyright 2016-2020 Pierre Ossman for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -16,189 +17,115 @@
* USA.
*/

// Cross-platform Region class based on the X11 region implementation. Note
// that for efficiency this code manipulates the Xlib region structure
// directly. Apart from the layout of the structure, there is one other key
// assumption made: a Region returned from XCreateRegion must always have its
// rects member allocated so that there is space for at least one rectangle.
//

#include <rfb/Region.h>
#include <rfb/LogWriter.h>
#include <assert.h>
#include <stdio.h>

extern "C" {
#include <Xregion/Xlibint.h>
#include <Xregion/Xutil.h>
#include <Xregion/Xregion.h>
#include <pixman.h>
}

static rfb::LogWriter vlog("Region");

// A _RectRegion must never be passed as a return parameter to the Xlib region
// operations. This is because for efficiency its "rects" member has not been
// allocated with Xmalloc. It is however safe to pass it as an input
// parameter.

class _RectRegion {
public:
_RectRegion(const rfb::Rect& r) {
region.rects = &region.extents;
region.numRects = 1;
region.extents.x1 = r.tl.x;
region.extents.y1 = r.tl.y;
region.extents.x2 = r.br.x;
region.extents.y2 = r.br.y;
region.size = 1;
if (r.is_empty())
region.numRects = 0;
}
REGION region;
};


rfb::Region::Region() {
xrgn = XCreateRegion();
assert(xrgn);
rgn = new struct pixman_region16;
pixman_region_init(rgn);
}

rfb::Region::Region(const Rect& r) {
xrgn = XCreateRegion();
assert(xrgn);
reset(r);
rgn = new struct pixman_region16;
pixman_region_init_rect(rgn, r.tl.x, r.tl.y, r.width(), r.height());
}

rfb::Region::Region(const rfb::Region& r) {
xrgn = XCreateRegion();
assert(xrgn);
XUnionRegion(xrgn, r.xrgn, xrgn);
rgn = new struct pixman_region16;
pixman_region_init(rgn);
pixman_region_copy(rgn, r.rgn);
}

rfb::Region::~Region() {
XDestroyRegion(xrgn);
pixman_region_fini(rgn);
delete rgn;
}

rfb::Region& rfb::Region::operator=(const rfb::Region& r) {
clear();
XUnionRegion(xrgn, r.xrgn, xrgn);
pixman_region_copy(rgn, r.rgn);
return *this;
}

void rfb::Region::clear() {
xrgn->numRects = 0;
xrgn->extents.x1 = 0;
xrgn->extents.y1 = 0;
xrgn->extents.x2 = 0;
xrgn->extents.y2 = 0;
// pixman_region_clear() isn't available on some older systems
pixman_region_fini(rgn);
pixman_region_init(rgn);
}

void rfb::Region::reset(const Rect& r) {
if (r.is_empty()) {
clear();
} else {
xrgn->numRects = 1;
xrgn->rects[0].x1 = xrgn->extents.x1 = r.tl.x;
xrgn->rects[0].y1 = xrgn->extents.y1 = r.tl.y;
xrgn->rects[0].x2 = xrgn->extents.x2 = r.br.x;
xrgn->rects[0].y2 = xrgn->extents.y2 = r.br.y;
}
pixman_region_fini(rgn);
pixman_region_init_rect(rgn, r.tl.x, r.tl.y, r.width(), r.height());
}

void rfb::Region::translate(const Point& delta) {
XOffsetRegion(xrgn, delta.x, delta.y);
}

void rfb::Region::setOrderedRects(const std::vector<Rect>& rects) {
clear();
std::vector<Rect>::const_iterator i;
for (i=rects.begin(); i != rects.end(); i++) {
_RectRegion rr(*i);
XUnionRegion(xrgn, &rr.region, xrgn);
}
}

void rfb::Region::setExtentsAndOrderedRects(const ShortRect* extents,
int nRects, const ShortRect* rects)
{
if (xrgn->size < nRects)
{
BOX* prevRects = xrgn->rects;
xrgn->rects = (BOX*)Xrealloc((char*)xrgn->rects, nRects * sizeof(BOX));
if (!xrgn->rects) {
vlog.error("Xrealloc failed");
Xfree(prevRects);
return;
}
xrgn->size = nRects;
}

xrgn->numRects = nRects;
xrgn->extents.x1 = extents->x1;
xrgn->extents.y1 = extents->y1;
xrgn->extents.x2 = extents->x2;
xrgn->extents.y2 = extents->y2;
for (int i = 0; i < nRects; i++) {
xrgn->rects[i].x1 = rects[i].x1;
xrgn->rects[i].y1 = rects[i].y1;
xrgn->rects[i].x2 = rects[i].x2;
xrgn->rects[i].y2 = rects[i].y2;
}
pixman_region_translate(rgn, delta.x, delta.y);
}

void rfb::Region::assign_intersect(const rfb::Region& r) {
XIntersectRegion(xrgn, r.xrgn, xrgn);
pixman_region_intersect(rgn, rgn, r.rgn);
}

void rfb::Region::assign_union(const rfb::Region& r) {
XUnionRegion(xrgn, r.xrgn, xrgn);
pixman_region_union(rgn, rgn, r.rgn);
}

void rfb::Region::assign_subtract(const rfb::Region& r) {
XSubtractRegion(xrgn, r.xrgn, xrgn);
pixman_region_subtract(rgn, rgn, r.rgn);
}

rfb::Region rfb::Region::intersect(const rfb::Region& r) const {
rfb::Region ret;
XIntersectRegion(xrgn, r.xrgn, ret.xrgn);
pixman_region_intersect(ret.rgn, rgn, r.rgn);
return ret;
}

rfb::Region rfb::Region::union_(const rfb::Region& r) const {
rfb::Region ret;
XUnionRegion(xrgn, r.xrgn, ret.xrgn);
pixman_region_union(ret.rgn, rgn, r.rgn);
return ret;
}

rfb::Region rfb::Region::subtract(const rfb::Region& r) const {
rfb::Region ret;
XSubtractRegion(xrgn, r.xrgn, ret.xrgn);
pixman_region_subtract(ret.rgn, rgn, r.rgn);
return ret;
}

bool rfb::Region::equals(const rfb::Region& r) const {
return XEqualRegion(xrgn, r.xrgn);
return pixman_region_equal(rgn, r.rgn);
}

int rfb::Region::numRects() const {
return xrgn->numRects;
return pixman_region_n_rects(rgn);
}

bool rfb::Region::get_rects(std::vector<Rect>* rects,
bool left2right, bool topdown) const
{
int nRects = xrgn->numRects;
int xInc = left2right ? 1 : -1;
int yInc = topdown ? 1 : -1;
int i = topdown ? 0 : nRects-1;
int nRects;
const pixman_box16_t* boxes;
int xInc, yInc, i;

boxes = pixman_region_rectangles(rgn, &nRects);

rects->clear();
rects->reserve(nRects);

xInc = left2right ? 1 : -1;
yInc = topdown ? 1 : -1;
i = topdown ? 0 : nRects-1;

while (nRects > 0) {
int firstInNextBand = i;
int nRectsInBand = 0;

while (nRects > 0 && xrgn->rects[firstInNextBand].y1 == xrgn->rects[i].y1)
while (nRects > 0 && boxes[firstInNextBand].y1 == boxes[i].y1)
{
firstInNextBand += yInc;
nRects--;
@@ -209,8 +136,7 @@ bool rfb::Region::get_rects(std::vector<Rect>* rects,
i = firstInNextBand - yInc;

while (nRectsInBand > 0) {
Rect r(xrgn->rects[i].x1, xrgn->rects[i].y1,
xrgn->rects[i].x2, xrgn->rects[i].y2);
Rect r(boxes[i].x1, boxes[i].y1, boxes[i].x2, boxes[i].y2);
rects->push_back(r);
i += xInc;
nRectsInBand--;
@@ -223,22 +149,27 @@ bool rfb::Region::get_rects(std::vector<Rect>* rects,
}

rfb::Rect rfb::Region::get_bounding_rect() const {
return Rect(xrgn->extents.x1, xrgn->extents.y1,
xrgn->extents.x2, xrgn->extents.y2);
const pixman_box16_t* extents;
extents = pixman_region_extents(rgn);
return Rect(extents->x1, extents->y1, extents->x2, extents->y2);
}


void rfb::Region::debug_print(const char* prefix) const
{
Rect extents;
std::vector<Rect> rects;
std::vector<Rect>::const_iterator iter;

extents = get_bounding_rect();
get_rects(&rects);

vlog.debug("%s num rects %3ld extents %3d,%3d %3dx%3d",
prefix, xrgn->numRects, xrgn->extents.x1, xrgn->extents.y1,
xrgn->extents.x2-xrgn->extents.x1,
xrgn->extents.y2-xrgn->extents.y1);
prefix, (long)rects.size(), extents.tl.x, extents.tl.y,
extents.width(), extents.height());

for (int i = 0; i < xrgn->numRects; i++) {
for (iter = rects.begin(); iter != rects.end(); ++iter) {
vlog.debug(" rect %3d,%3d %3dx%3d",
xrgn->rects[i].x1, xrgn->rects[i].y1,
xrgn->rects[i].x2-xrgn->rects[i].x1,
xrgn->rects[i].y2-xrgn->rects[i].y1);
iter->tl.x, iter->tl.y, iter->width(), iter->height());
}
}

+ 4
- 10
common/rfb/Region.h View File

@@ -1,4 +1,5 @@
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
* Copyright 2016-2020 Pierre Ossman for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -16,7 +17,7 @@
* USA.
*/

// Cross-platform Region class based on the X11 region implementation
// Region class wrapper around pixman's region operations

#ifndef __RFB_REGION_INCLUDED__
#define __RFB_REGION_INCLUDED__
@@ -24,14 +25,10 @@
#include <rfb/Rect.h>
#include <vector>

struct _XRegion;
struct pixman_region16;

namespace rfb {

struct ShortRect {
short x1, y1, x2, y2;
};

class Region {
public:
// Create an empty region
@@ -49,9 +46,6 @@ namespace rfb {
void clear();
void reset(const Rect& r);
void translate(const rfb::Point& delta);
void setOrderedRects(const std::vector<Rect>& rects);
void setExtentsAndOrderedRects(const ShortRect* extents, int nRects,
const ShortRect* rects);

void assign_intersect(const Region& r);
void assign_union(const Region& r);
@@ -75,7 +69,7 @@ namespace rfb {

protected:

struct _XRegion* xrgn;
struct pixman_region16* rgn;
};

};

+ 1
- 2
unix/xserver/hw/vnc/Makefile.am View File

@@ -5,9 +5,8 @@ RFB_LIB=$(TIGERVNC_BUILDDIR)/common/rfb/librfb.la
RDR_LIB=$(TIGERVNC_BUILDDIR)/common/rdr/librdr.la
OS_LIB=$(TIGERVNC_BUILDDIR)/common/os/libos.la
NETWORK_LIB=$(TIGERVNC_BUILDDIR)/common/network/libnetwork.la
XREGION_LIB=$(TIGERVNC_BUILDDIR)/common/Xregion/libXregion.la
UNIXCOMMON_LIB=$(TIGERVNC_BUILDDIR)/unix/common/libunixcommon.la
COMMON_LIBS=$(NETWORK_LIB) $(RFB_LIB) $(RDR_LIB) $(XREGION_LIB) $(OS_LIB) $(UNIXCOMMON_LIB)
COMMON_LIBS=$(NETWORK_LIB) $(RFB_LIB) $(RDR_LIB) $(OS_LIB) $(UNIXCOMMON_LIB)

noinst_LTLIBRARIES = libvnccommon.la


+ 13
- 17
unix/xserver/hw/vnc/vncExtInit.cc View File

@@ -150,9 +150,6 @@ void vncExtensionInit(void)
if (vncGetScreenCount() > MAXSCREENS)
vncFatalError("vncExtensionInit: too many screens\n");

if (sizeof(ShortRect) != sizeof(struct UpdateRect))
vncFatalError("vncExtensionInit: Incompatible ShortRect size\n");

vncAddExtension();

vncSelectionInit();
@@ -372,25 +369,24 @@ void vncSetLEDState(unsigned long leds)
desktop[scr]->setLEDState(state);
}

void vncAddChanged(int scrIdx, const struct UpdateRect *extents,
int nRects, const struct UpdateRect *rects)
void vncAddChanged(int scrIdx, int nRects,
const struct UpdateRect *rects)
{
Region reg;

reg.setExtentsAndOrderedRects((const ShortRect*)extents,
nRects, (const ShortRect*)rects);
desktop[scrIdx]->add_changed(reg);
for (int i = 0;i < nRects;i++) {
desktop[scrIdx]->add_changed(Region(Rect(rects[i].x1, rects[i].y1,
rects[i].x2, rects[i].y2)));
}
}

void vncAddCopied(int scrIdx, const struct UpdateRect *extents,
int nRects, const struct UpdateRect *rects,
void vncAddCopied(int scrIdx, int nRects,
const struct UpdateRect *rects,
int dx, int dy)
{
Region reg;
reg.setExtentsAndOrderedRects((const ShortRect*)extents,
nRects, (const ShortRect*)rects);
desktop[scrIdx]->add_copied(reg, rfb::Point(dx, dy));
for (int i = 0;i < nRects;i++) {
desktop[scrIdx]->add_copied(Region(Rect(rects[i].x1, rects[i].y1,
rects[i].x2, rects[i].y2)),
Point(dx, dy));
}
}

void vncSetCursor(int width, int height, int hotX, int hotY,

+ 4
- 4
unix/xserver/hw/vnc/vncExtInit.h View File

@@ -73,10 +73,10 @@ struct UpdateRect {
short x1, y1, x2, y2;
};

void vncAddChanged(int scrIdx, const struct UpdateRect *extents,
int nRects, const struct UpdateRect *rects);
void vncAddCopied(int scrIdx, const struct UpdateRect *extents,
int nRects, const struct UpdateRect *rects,
void vncAddChanged(int scrIdx, int nRects,
const struct UpdateRect *rects);
void vncAddCopied(int scrIdx, int nRects,
const struct UpdateRect *rects,
int dx, int dy);

void vncSetCursor(int width, int height, int hotX, int hotY,

+ 123
- 125
unix/xserver/hw/vnc/vncHooks.c View File

@@ -337,12 +337,11 @@ static inline void add_changed(ScreenPtr pScreen, RegionPtr reg)
vncHooksScreenPtr vncHooksScreen = vncHooksScreenPrivate(pScreen);
if (vncHooksScreen->ignoreHooks)
return;
if (REGION_NIL(reg))
if (RegionNil(reg))
return;
vncAddChanged(pScreen->myNum,
(const struct UpdateRect*)REGION_EXTENTS(pScreen, reg),
REGION_NUM_RECTS(reg),
(const struct UpdateRect*)REGION_RECTS(reg));
RegionNumRects(reg),
(const struct UpdateRect*)RegionRects(reg));
}

static inline void add_copied(ScreenPtr pScreen, RegionPtr dst,
@@ -351,12 +350,11 @@ static inline void add_copied(ScreenPtr pScreen, RegionPtr dst,
vncHooksScreenPtr vncHooksScreen = vncHooksScreenPrivate(pScreen);
if (vncHooksScreen->ignoreHooks)
return;
if (REGION_NIL(dst))
if (RegionNil(dst))
return;
vncAddCopied(pScreen->myNum,
(const struct UpdateRect*)REGION_EXTENTS(pScreen, dst),
REGION_NUM_RECTS(dst),
(const struct UpdateRect*)REGION_RECTS(dst), dx, dy);
RegionNumRects(dst),
(const struct UpdateRect*)RegionRects(dst), dx, dy);
}

static inline Bool is_visible(DrawablePtr drawable)
@@ -478,15 +476,15 @@ static void vncHooksCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,

SCREEN_PROLOGUE(pWin->drawable.pScreen, CopyWindow);

REGION_NULL(pScreen, &copied);
REGION_COPY(pScreen, &copied, pOldRegion);
RegionNull(&copied);
RegionCopy(&copied, pOldRegion);

screen_box.x1 = 0;
screen_box.y1 = 0;
screen_box.x2 = pScreen->width;
screen_box.y2 = pScreen->height;

REGION_INIT(pScreen, &screen_rgn, &screen_box, 1);
RegionInitBoxes(&screen_rgn, &screen_box, 1);

dx = pWin->drawable.x - ptOldOrg.x;
dy = pWin->drawable.y - ptOldOrg.y;
@@ -495,17 +493,17 @@ static void vncHooksCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,
// We also need to copy with changes to the Window's clipping region.
// Finally, make sure we don't get copies to or from regions outside
// the framebuffer.
REGION_INTERSECT(pScreen, &copied, &copied, &screen_rgn);
REGION_TRANSLATE(pScreen, &copied, dx, dy);
REGION_INTERSECT(pScreen, &copied, &copied, &screen_rgn);
REGION_INTERSECT(pScreen, &copied, &copied, &pWin->borderClip);
RegionIntersect(&copied, &copied, &screen_rgn);
RegionTranslate(&copied, dx, dy);
RegionIntersect(&copied, &copied, &screen_rgn);
RegionIntersect(&copied, &copied, &pWin->borderClip);

(*pScreen->CopyWindow) (pWin, ptOldOrg, pOldRegion);

add_copied(pScreen, &copied, dx, dy);

REGION_UNINIT(pScreen, &copied);
REGION_UNINIT(pScreen, &screen_rgn);
RegionUninit(&copied);
RegionUninit(&screen_rgn);

SCREEN_EPILOGUE(CopyWindow);
}
@@ -526,8 +524,8 @@ static void vncHooksClearToBackground(WindowPtr pWin, int x, int y, int w,
box.x2 = w ? (box.x1 + w) : (pWin->drawable.x + pWin->drawable.width);
box.y2 = h ? (box.y1 + h) : (pWin->drawable.y + pWin->drawable.height);

REGION_INIT(pScreen, &reg, &box, 0);
REGION_INTERSECT(pScreen, &reg, &reg, &pWin->clipList);
RegionInitBoxes(&reg, &box, 1);
RegionIntersect(&reg, &reg, &pWin->clipList);

(*pScreen->ClearToBackground) (pWin, x, y, w, h, generateExposures);

@@ -535,7 +533,7 @@ static void vncHooksClearToBackground(WindowPtr pWin, int x, int y, int w,
add_changed(pScreen, &reg);
}

REGION_UNINIT(pScreen, &reg);
RegionUninit(&reg);

SCREEN_EPILOGUE(ClearToBackground);
}
@@ -690,19 +688,19 @@ static void vncHooksComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask,
box.y1 = max(pDst->pDrawable->y + yDst, 0);
box.x2 = box.x1 + width;
box.y2 = box.y1 + height;
REGION_INIT(pScreen, &changed, &box, 0);
RegionInitBoxes(&changed, &box, 1);

box.x1 = 0;
box.y1 = 0;
box.x2 = pScreen->width;
box.y2 = pScreen->height;
REGION_INIT(pScreen, &fbreg, &box, 0);
RegionInitBoxes(&fbreg, &box, 1);

REGION_INTERSECT(pScreen, &changed, &changed, &fbreg);
RegionIntersect(&changed, &changed, &fbreg);

REGION_UNINIT(pScreen, &fbreg);
RegionUninit(&fbreg);
} else {
REGION_NULL(pScreen, &changed);
RegionNull(&changed);
}


@@ -711,7 +709,7 @@ static void vncHooksComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask,

add_changed(pScreen, &changed);

REGION_UNINIT(pScreen, &changed);
RegionUninit(&changed);

RENDER_EPILOGUE(Composite);
}
@@ -793,27 +791,27 @@ static void vncHooksGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
RegionRec fbreg;

changed = GlyphsToRegion(pScreen, nlists, lists, glyphs);
REGION_TRANSLATE(pScreen, changed,
RegionTranslate(changed,
pDst->pDrawable->x, pDst->pDrawable->y);

fbbox.x1 = 0;
fbbox.y1 = 0;
fbbox.x2 = pScreen->width;
fbbox.y2 = pScreen->height;
REGION_INIT(pScreen, &fbreg, &fbbox, 0);
RegionInitBoxes(&fbreg, &fbbox, 1);

REGION_INTERSECT(pScreen, changed, changed, &fbreg);
RegionIntersect(changed, changed, &fbreg);

REGION_UNINIT(pScreen, &fbreg);
RegionUninit(&fbreg);
} else {
changed = REGION_CREATE(pScreen, NullBox, 0);
changed = RegionCreate(NullBox, 0);
}

(*ps->Glyphs)(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlists, lists, glyphs);

add_changed(pScreen, changed);

REGION_DESTROY(pScreen, changed);
RegionDestroy(changed);

RENDER_EPILOGUE(Glyphs);
}
@@ -828,14 +826,14 @@ static void vncHooksCompositeRects(CARD8 op, PicturePtr pDst,
if (is_visible(pDst->pDrawable)) {
changed = RECTS_TO_REGION(pScreen, nRect, rects, CT_NONE);
} else {
changed = REGION_CREATE(pScreen, NullBox, 0);
changed = RegionCreate(NullBox, 0);
}

(*ps->CompositeRects)(op, pDst, color, nRect, rects);

add_changed(pScreen, changed);

REGION_DESTROY(pScreen, changed);
RegionDestroy(changed);

RENDER_EPILOGUE(CompositeRects);
}
@@ -883,26 +881,26 @@ static void vncHooksTrapezoids(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
box.y1 += pDst->pDrawable->y;
box.x2 += pDst->pDrawable->x;
box.y2 += pDst->pDrawable->y;
REGION_INIT(pScreen, &changed, &box, 0);
RegionInitBoxes(&changed, &box, 1);

box.x1 = 0;
box.y1 = 0;
box.x2 = pScreen->width;
box.y2 = pScreen->height;
REGION_INIT(pScreen, &fbreg, &box, 0);
RegionInitBoxes(&fbreg, &box, 1);

REGION_INTERSECT(pScreen, &changed, &changed, &fbreg);
RegionIntersect(&changed, &changed, &fbreg);

REGION_UNINIT(pScreen, &fbreg);
RegionUninit(&fbreg);
} else {
REGION_NULL(pScreen, &changed);
RegionNull(&changed);
}

(*ps->Trapezoids)(op, pSrc, pDst, maskFormat, xSrc, ySrc, ntrap, traps);

add_changed(pScreen, &changed);

REGION_UNINIT(pScreen, &changed);
RegionUninit(&changed);

RENDER_EPILOGUE(Trapezoids);
}
@@ -948,26 +946,26 @@ static void vncHooksTriangles(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
box.y1 += pDst->pDrawable->y;
box.x2 += pDst->pDrawable->x;
box.y2 += pDst->pDrawable->y;
REGION_INIT(pScreen, &changed, &box, 0);
RegionInitBoxes(&changed, &box, 1);

box.x1 = 0;
box.y1 = 0;
box.x2 = pScreen->width;
box.y2 = pScreen->height;
REGION_INIT(pScreen, &fbreg, &box, 0);
RegionInitBoxes(&fbreg, &box, 1);

REGION_INTERSECT(pScreen, &changed, &changed, &fbreg);
RegionIntersect(&changed, &changed, &fbreg);

REGION_UNINIT(pScreen, &fbreg);
RegionUninit(&fbreg);
} else {
REGION_NULL(pScreen, &changed);
RegionNull(&changed);
}

(*ps->Triangles)(op, pSrc, pDst, maskFormat, xSrc, ySrc, ntri, tris);

add_changed(pScreen, &changed);

REGION_UNINIT(pScreen, &changed);
RegionUninit(&changed);

RENDER_EPILOGUE(Triangles);
}
@@ -1006,26 +1004,26 @@ static void vncHooksTriStrip(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
box.y1 += pDst->pDrawable->y;
box.x2 += pDst->pDrawable->x;
box.y2 += pDst->pDrawable->y;
REGION_INIT(pScreen, &changed, &box, 0);
RegionInitBoxes(&changed, &box, 1);

box.x1 = 0;
box.y1 = 0;
box.x2 = pScreen->width;
box.y2 = pScreen->height;
REGION_INIT(pScreen, &fbreg, &box, 0);
RegionInitBoxes(&fbreg, &box, 1);

REGION_INTERSECT(pScreen, &changed, &changed, &fbreg);
RegionIntersect(&changed, &changed, &fbreg);

REGION_UNINIT(pScreen, &fbreg);
RegionUninit(&fbreg);
} else {
REGION_NULL(pScreen, &changed);
RegionNull(&changed);
}

(*ps->TriStrip)(op, pSrc, pDst, maskFormat, xSrc, ySrc, npoint, points);

add_changed(pScreen, &changed);

REGION_UNINIT(pScreen, &changed);
RegionUninit(&changed);

RENDER_EPILOGUE(TriStrip);
}
@@ -1064,26 +1062,26 @@ static void vncHooksTriFan(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
box.y1 += pDst->pDrawable->y;
box.x2 += pDst->pDrawable->x;
box.y2 += pDst->pDrawable->y;
REGION_INIT(pScreen, &changed, &box, 0);
RegionInitBoxes(&changed, &box, 1);

box.x1 = 0;
box.y1 = 0;
box.x2 = pScreen->width;
box.y2 = pScreen->height;
REGION_INIT(pScreen, &fbreg, &box, 0);
RegionInitBoxes(&fbreg, &box, 1);

REGION_INTERSECT(pScreen, &changed, &changed, &fbreg);
RegionIntersect(&changed, &changed, &fbreg);

REGION_UNINIT(pScreen, &fbreg);
RegionUninit(&fbreg);
} else {
REGION_NULL(pScreen, &changed);
RegionNull(&changed);
}

(*ps->TriFan)(op, pSrc, pDst, maskFormat, xSrc, ySrc, npoint, points);

add_changed(pScreen, &changed);

REGION_UNINIT(pScreen, &changed);
RegionUninit(&changed);

RENDER_EPILOGUE(TriFan);
}
@@ -1261,17 +1259,17 @@ static void vncHooksFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nInit,

GC_OP_PROLOGUE(pGC, FillSpans);

REGION_NULL(pGC->pScreen, &reg);
REGION_COPY(pGC->pScreen, &reg, pGC->pCompositeClip);
RegionNull(&reg);
RegionCopy(&reg, pGC->pCompositeClip);

if (pDrawable->type == DRAWABLE_WINDOW)
REGION_INTERSECT(pScreen, &reg, &reg, &((WindowPtr)pDrawable)->borderClip);
RegionIntersect(&reg, &reg, &((WindowPtr)pDrawable)->borderClip);

(*pGC->ops->FillSpans) (pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted);

add_changed(pGC->pScreen, &reg);

REGION_UNINIT(pGC->pScreen, &reg);
RegionUninit(&reg);

GC_OP_EPILOGUE(pGC);
}
@@ -1287,17 +1285,17 @@ static void vncHooksSetSpans(DrawablePtr pDrawable, GCPtr pGC, char *psrc,

GC_OP_PROLOGUE(pGC, SetSpans);

REGION_NULL(pGC->pScreen, &reg);
REGION_COPY(pGC->pScreen, &reg, pGC->pCompositeClip);
RegionNull(&reg);
RegionCopy(&reg, pGC->pCompositeClip);

if (pDrawable->type == DRAWABLE_WINDOW)
REGION_INTERSECT(pScreen, &reg, &reg, &((WindowPtr)pDrawable)->borderClip);
RegionIntersect(&reg, &reg, &((WindowPtr)pDrawable)->borderClip);

(*pGC->ops->SetSpans) (pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted);

add_changed(pGC->pScreen, &reg);

REGION_UNINIT(pGC->pScreen, &reg);
RegionUninit(&reg);

GC_OP_EPILOGUE(pGC);
}
@@ -1318,15 +1316,15 @@ static void vncHooksPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
box.x2 = box.x1 + w;
box.y2 = box.y1 + h;

REGION_INIT(pGC->pScreen, &reg, &box, 0);
REGION_INTERSECT(pGC->pScreen, &reg, &reg, pGC->pCompositeClip);
RegionInitBoxes(&reg, &box, 1);
RegionIntersect(&reg, &reg, pGC->pCompositeClip);

(*pGC->ops->PutImage) (pDrawable, pGC, depth, x, y, w, h, leftPad, format,
pBits);

add_changed(pGC->pScreen, &reg);

REGION_UNINIT(pGC->pScreen, &reg);
RegionUninit(&reg);

GC_OP_EPILOGUE(pGC);
}
@@ -1347,7 +1345,7 @@ static RegionPtr vncHooksCopyArea(DrawablePtr pSrc, DrawablePtr pDst,

// Apparently this happens now and then...
if ((w == 0) || (h == 0))
REGION_NULL(pGC->pScreen, &dst);
RegionNull(&dst);
else {
BoxRec box;

@@ -1356,10 +1354,10 @@ static RegionPtr vncHooksCopyArea(DrawablePtr pSrc, DrawablePtr pDst,
box.x2 = box.x1 + w;
box.y2 = box.y1 + h;

REGION_INIT(pGC->pScreen, &dst, &box, 0);
RegionInitBoxes(&dst, &box, 1);
}

REGION_INTERSECT(pGC->pScreen, &dst, &dst, pGC->pCompositeClip);
RegionIntersect(&dst, &dst, pGC->pCompositeClip);

// The source of the data has to be something that's on screen.
if (is_visible(pSrc)) {
@@ -1370,24 +1368,24 @@ static RegionPtr vncHooksCopyArea(DrawablePtr pSrc, DrawablePtr pDst,
box.x2 = box.x1 + w;
box.y2 = box.y1 + h;

REGION_INIT(pGC->pScreen, &src, &box, 0);
RegionInitBoxes(&src, &box, 1);

if ((pSrc->type == DRAWABLE_WINDOW) &&
REGION_NOTEMPTY(pScreen, &((WindowPtr)pSrc)->clipList)) {
REGION_INTERSECT(pScreen, &src, &src, &((WindowPtr)pSrc)->clipList);
RegionNotEmpty(&((WindowPtr)pSrc)->clipList)) {
RegionIntersect(&src, &src, &((WindowPtr)pSrc)->clipList);
}

REGION_TRANSLATE(pScreen, &src,
RegionTranslate(&src,
dstx + pDst->x - srcx - pSrc->x,
dsty + pDst->y - srcy - pSrc->y);
} else {
REGION_NULL(pGC->pScreen, &src);
RegionNull(&src);
}

REGION_NULL(pGC->pScreen, &changed);
RegionNull(&changed);

REGION_SUBTRACT(pScreen, &changed, &dst, &src);
REGION_INTERSECT(pScreen, &dst, &dst, &src);
RegionSubtract(&changed, &dst, &src);
RegionIntersect(&dst, &dst, &src);

ret = (*pGC->ops->CopyArea) (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty);

@@ -1397,9 +1395,9 @@ static RegionPtr vncHooksCopyArea(DrawablePtr pSrc, DrawablePtr pDst,

add_changed(pGC->pScreen, &changed);

REGION_UNINIT(pGC->pScreen, &dst);
REGION_UNINIT(pGC->pScreen, &src);
REGION_UNINIT(pGC->pScreen, &changed);
RegionUninit(&dst);
RegionUninit(&src);
RegionUninit(&changed);

GC_OP_EPILOGUE(pGC);

@@ -1426,15 +1424,15 @@ static RegionPtr vncHooksCopyPlane(DrawablePtr pSrc, DrawablePtr pDst,
box.x2 = box.x1 + w;
box.y2 = box.y1 + h;

REGION_INIT(pGC->pScreen, &reg, &box, 0);
REGION_INTERSECT(pGC->pScreen, &reg, &reg, pGC->pCompositeClip);
RegionInitBoxes(&reg, &box, 1);
RegionIntersect(&reg, &reg, pGC->pCompositeClip);

ret = (*pGC->ops->CopyPlane) (pSrc, pDst, pGC, srcx, srcy, w, h,
dstx, dsty, plane);

add_changed(pGC->pScreen, &reg);

REGION_UNINIT(pGC->pScreen, &reg);
RegionUninit(&reg);

GC_OP_EPILOGUE(pGC);

@@ -1490,14 +1488,14 @@ static void vncHooksPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode,
box.x2 = maxX + 1 + pDrawable->x;
box.y2 = maxY + 1 + pDrawable->y;

REGION_INIT(pGC->pScreen, &reg, &box, 0);
REGION_INTERSECT(pGC->pScreen, &reg, &reg, pGC->pCompositeClip);
RegionInitBoxes(&reg, &box, 1);
RegionIntersect(&reg, &reg, pGC->pCompositeClip);

(*pGC->ops->PolyPoint) (pDrawable, pGC, mode, npt, pts);

add_changed(pGC->pScreen, &reg);

REGION_UNINIT(pGC->pScreen, &reg);
RegionUninit(&reg);

out:
GC_OP_EPILOGUE(pGC);
@@ -1617,13 +1615,13 @@ static void vncHooksPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode,
}

reg = RECTS_TO_REGION(pGC->pScreen, nRegRects, regRects, CT_NONE);
REGION_INTERSECT(pGC->pScreen, reg, reg, pGC->pCompositeClip);
RegionIntersect(reg, reg, pGC->pCompositeClip);

(*pGC->ops->Polylines) (pDrawable, pGC, mode, npt, ppts);

add_changed(pGC->pScreen, reg);

REGION_DESTROY(pGC->pScreen, reg);
RegionDestroy(reg);

out:
GC_OP_EPILOGUE(pGC);
@@ -1702,13 +1700,13 @@ static void vncHooksPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
}

reg = RECTS_TO_REGION(pGC->pScreen, nRegRects, regRects, CT_NONE);
REGION_INTERSECT(pGC->pScreen, reg, reg, pGC->pCompositeClip);
RegionIntersect(reg, reg, pGC->pCompositeClip);

(*pGC->ops->PolySegment) (pDrawable, pGC, nseg, segs);

add_changed(pGC->pScreen, reg);

REGION_DESTROY(pGC->pScreen, reg);
RegionDestroy(reg);

out:
GC_OP_EPILOGUE(pGC);
@@ -1791,13 +1789,13 @@ static void vncHooksPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nrects,
}

reg = RECTS_TO_REGION(pGC->pScreen, nRegRects, regRects, CT_NONE);
REGION_INTERSECT(pGC->pScreen, reg, reg, pGC->pCompositeClip);
RegionIntersect(reg, reg, pGC->pCompositeClip);

(*pGC->ops->PolyRectangle) (pDrawable, pGC, nrects, rects);

add_changed(pGC->pScreen, reg);

REGION_DESTROY(pGC->pScreen, reg);
RegionDestroy(reg);

out:
GC_OP_EPILOGUE(pGC);
@@ -1866,13 +1864,13 @@ static void vncHooksPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs,
}

reg = RECTS_TO_REGION(pGC->pScreen, nRegRects, regRects, CT_NONE);
REGION_INTERSECT(pGC->pScreen, reg, reg, pGC->pCompositeClip);
RegionIntersect(reg, reg, pGC->pCompositeClip);

(*pGC->ops->PolyArc) (pDrawable, pGC, narcs, arcs);

add_changed(pGC->pScreen, reg);

REGION_DESTROY(pGC->pScreen, reg);
RegionDestroy(reg);

out:
GC_OP_EPILOGUE(pGC);
@@ -1929,14 +1927,14 @@ static void vncHooksFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape,
box.x2 = maxX + 1 + pDrawable->x;
box.y2 = maxY + 1 + pDrawable->y;

REGION_INIT(pGC->pScreen, &reg, &box, 0);
REGION_INTERSECT(pGC->pScreen, &reg, &reg, pGC->pCompositeClip);
RegionInitBoxes(&reg, &box, 1);
RegionIntersect(&reg, &reg, pGC->pCompositeClip);

(*pGC->ops->FillPolygon) (pDrawable, pGC, shape, mode, count, pts);

add_changed(pGC->pScreen, &reg);

REGION_UNINIT(pGC->pScreen, &reg);
RegionUninit(&reg);

out:
GC_OP_EPILOGUE(pGC);
@@ -1995,13 +1993,13 @@ static void vncHooksPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrects,
}

reg = RECTS_TO_REGION(pGC->pScreen, nRegRects, regRects, CT_NONE);
REGION_INTERSECT(pGC->pScreen, reg, reg, pGC->pCompositeClip);
RegionIntersect(reg, reg, pGC->pCompositeClip);

(*pGC->ops->PolyFillRect) (pDrawable, pGC, nrects, rects);

add_changed(pGC->pScreen, reg);

REGION_DESTROY(pGC->pScreen, reg);
RegionDestroy(reg);

out:
GC_OP_EPILOGUE(pGC);
@@ -2070,13 +2068,13 @@ static void vncHooksPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int narcs,
}

reg = RECTS_TO_REGION(pGC->pScreen, nRegRects, regRects, CT_NONE);
REGION_INTERSECT(pGC->pScreen, reg, reg, pGC->pCompositeClip);
RegionIntersect(reg, reg, pGC->pCompositeClip);

(*pGC->ops->PolyFillArc) (pDrawable, pGC, narcs, arcs);

add_changed(pGC->pScreen, reg);

REGION_DESTROY(pGC->pScreen, reg);
RegionDestroy(reg);

out:
GC_OP_EPILOGUE(pGC);
@@ -2121,14 +2119,14 @@ static int vncHooksPolyText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y,

GetTextBoundingRect(pDrawable, pGC->font, x, y, count, &box);

REGION_INIT(pGC->pScreen, &reg, &box, 0);
REGION_INTERSECT(pGC->pScreen, &reg, &reg, pGC->pCompositeClip);
RegionInitBoxes(&reg, &box, 1);
RegionIntersect(&reg, &reg, pGC->pCompositeClip);

ret = (*pGC->ops->PolyText8) (pDrawable, pGC, x, y, count, chars);

add_changed(pGC->pScreen, &reg);

REGION_UNINIT(pGC->pScreen, &reg);
RegionUninit(&reg);

out:
GC_OP_EPILOGUE(pGC);
@@ -2155,14 +2153,14 @@ static int vncHooksPolyText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y,

GetTextBoundingRect(pDrawable, pGC->font, x, y, count, &box);

REGION_INIT(pGC->pScreen, &reg, &box, 0);
REGION_INTERSECT(pGC->pScreen, &reg, &reg, pGC->pCompositeClip);
RegionInitBoxes(&reg, &box, 1);
RegionIntersect(&reg, &reg, pGC->pCompositeClip);

ret = (*pGC->ops->PolyText16) (pDrawable, pGC, x, y, count, chars);

add_changed(pGC->pScreen, &reg);

REGION_UNINIT(pGC->pScreen, &reg);
RegionUninit(&reg);

out:
GC_OP_EPILOGUE(pGC);
@@ -2188,14 +2186,14 @@ static void vncHooksImageText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y,

GetTextBoundingRect(pDrawable, pGC->font, x, y, count, &box);

REGION_INIT(pGC->pScreen, &reg, &box, 0);
REGION_INTERSECT(pGC->pScreen, &reg, &reg, pGC->pCompositeClip);
RegionInitBoxes(&reg, &box, 1);
RegionIntersect(&reg, &reg, pGC->pCompositeClip);

(*pGC->ops->ImageText8) (pDrawable, pGC, x, y, count, chars);

add_changed(pGC->pScreen, &reg);

REGION_UNINIT(pGC->pScreen, &reg);
RegionUninit(&reg);

out:
GC_OP_EPILOGUE(pGC);
@@ -2219,14 +2217,14 @@ static void vncHooksImageText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y,

GetTextBoundingRect(pDrawable, pGC->font, x, y, count, &box);

REGION_INIT(pGC->pScreen, &reg, &box, 0);
REGION_INTERSECT(pGC->pScreen, &reg, &reg, pGC->pCompositeClip);
RegionInitBoxes(&reg, &box, 1);
RegionIntersect(&reg, &reg, pGC->pCompositeClip);

(*pGC->ops->ImageText16) (pDrawable, pGC, x, y, count, chars);

add_changed(pGC->pScreen, &reg);

REGION_UNINIT(pGC->pScreen, &reg);
RegionUninit(&reg);

out:
GC_OP_EPILOGUE(pGC);
@@ -2251,14 +2249,14 @@ static void vncHooksImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x,

GetTextBoundingRect(pDrawable, pGC->font, x, y, nglyph, &box);

REGION_INIT(pGC->pScreen, &reg, &box, 0);
REGION_INTERSECT(pGC->pScreen, &reg, &reg, pGC->pCompositeClip);
RegionInitBoxes(&reg, &box, 1);
RegionIntersect(&reg, &reg, pGC->pCompositeClip);

(*pGC->ops->ImageGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);

add_changed(pGC->pScreen, &reg);

REGION_UNINIT(pGC->pScreen, &reg);
RegionUninit(&reg);

out:
GC_OP_EPILOGUE(pGC);
@@ -2283,14 +2281,14 @@ static void vncHooksPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x,

GetTextBoundingRect(pDrawable, pGC->font, x, y, nglyph, &box);

REGION_INIT(pGC->pScreen, &reg, &box, 0);
REGION_INTERSECT(pGC->pScreen, &reg, &reg, pGC->pCompositeClip);
RegionInitBoxes(&reg, &box, 1);
RegionIntersect(&reg, &reg, pGC->pCompositeClip);

(*pGC->ops->PolyGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);

add_changed(pGC->pScreen, &reg);

REGION_UNINIT(pGC->pScreen, &reg);
RegionUninit(&reg);

out:
GC_OP_EPILOGUE(pGC);
@@ -2313,14 +2311,14 @@ static void vncHooksPushPixels(GCPtr pGC, PixmapPtr pBitMap,
box.x2 = box.x1 + w;
box.y2 = box.y1 + h;

REGION_INIT(pGC->pScreen, &reg, &box, 0);
REGION_INTERSECT(pGC->pScreen, &reg, &reg, pGC->pCompositeClip);
RegionInitBoxes(&reg, &box, 1);
RegionIntersect(&reg, &reg, pGC->pCompositeClip);

(*pGC->ops->PushPixels) (pGC, pBitMap, pDrawable, w, h, x, y);

add_changed(pGC->pScreen, &reg);

REGION_UNINIT(pGC->pScreen, &reg);
RegionUninit(&reg);

GC_OP_EPILOGUE(pGC);
}

+ 9
- 9
unix/xserver/hw/vnc/xvnc.c View File

@@ -943,8 +943,8 @@ xf86SetRootClip (ScreenPtr pScreen, Bool enable)
{
RegionPtr borderVisible;

borderVisible = REGION_CREATE(pScreen, NullBox, 1);
REGION_SUBTRACT(pScreen, borderVisible,
borderVisible = RegionCreate(NullBox, 1);
RegionSubtract(borderVisible,
&pWin->borderClip, &pWin->winSize);
pWin->valdata->before.borderVisible = borderVisible;
}
@@ -953,7 +953,7 @@ xf86SetRootClip (ScreenPtr pScreen, Bool enable)
}
/*
* Use REGION_BREAK to avoid optimizations in ValidateTree
* Use RegionBreak to avoid optimizations in ValidateTree
* that assume the root borderClip can't change well, normally
* it doesn't...)
*/
@@ -963,18 +963,18 @@ xf86SetRootClip (ScreenPtr pScreen, Bool enable)
box.y1 = 0;
box.x2 = pScreen->width;
box.y2 = pScreen->height;
REGION_INIT (pScreen, &pWin->winSize, &box, 1);
REGION_INIT (pScreen, &pWin->borderSize, &box, 1);
RegionInit(&pWin->winSize, &box, 1);
RegionInit(&pWin->borderSize, &box, 1);
if (WasViewable)
REGION_RESET(pScreen, &pWin->borderClip, &box);
RegionReset(&pWin->borderClip, &box);
pWin->drawable.width = pScreen->width;
pWin->drawable.height = pScreen->height;
REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
RegionBreak(&pWin->clipList);
}
else
{
REGION_EMPTY(pScreen, &pWin->borderClip);
REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
RegionEmpty(&pWin->borderClip);
RegionBreak(&pWin->clipList);
}
ResizeChildrenWinSize (pWin, 0, 0, 0, 0);

Loading…
Cancel
Save