2012-03-06 23:49:15 +04:00
|
|
|
/*
|
|
|
|
Copyright 2005-2012 Jay Sorg
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
Xserver drawing ops and funcs
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "rdp.h"
|
|
|
|
#include "gcops.h"
|
2012-05-16 03:48:25 +04:00
|
|
|
#include "rdpdraw.h"
|
|
|
|
|
|
|
|
#include "rdpCopyArea.h"
|
|
|
|
#include "rdpPolyFillRect.h"
|
|
|
|
#include "rdpPutImage.h"
|
|
|
|
#include "rdpPolyRectangle.h"
|
|
|
|
#include "rdpPolylines.h"
|
|
|
|
#include "rdpPolySegment.h"
|
2012-05-16 05:21:13 +04:00
|
|
|
#include "rdpFillSpans.h"
|
|
|
|
#include "rdpSetSpans.h"
|
|
|
|
#include "rdpCopyPlane.h"
|
2012-05-16 10:43:38 +04:00
|
|
|
#include "rdpPolyPoint.h"
|
|
|
|
#include "rdpPolyArc.h"
|
|
|
|
#include "rdpFillPolygon.h"
|
|
|
|
#include "rdpPolyFillArc.h"
|
|
|
|
#include "rdpPolyText8.h"
|
|
|
|
#include "rdpPolyText16.h"
|
|
|
|
#include "rdpImageText8.h"
|
|
|
|
#include "rdpImageText16.h"
|
|
|
|
#include "rdpImageGlyphBlt.h"
|
|
|
|
#include "rdpPolyGlyphBlt.h"
|
|
|
|
#include "rdpPushPixels.h"
|
2012-03-06 23:49:15 +04:00
|
|
|
|
2012-05-16 21:14:24 +04:00
|
|
|
#define LOG_LEVEL 1
|
|
|
|
#define LLOG(_level, _args) \
|
|
|
|
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
|
|
|
|
#define LLOGLN(_level, _args) \
|
|
|
|
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
|
|
|
|
|
2012-03-06 23:49:15 +04:00
|
|
|
extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
|
2012-03-08 09:02:41 +04:00
|
|
|
extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */
|
2012-03-15 04:16:42 +04:00
|
|
|
extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */
|
|
|
|
extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */
|
2012-03-06 23:49:15 +04:00
|
|
|
extern int g_Bpp; /* from rdpmain.c */
|
|
|
|
extern ScreenPtr g_pScreen; /* from rdpmain.c */
|
2012-05-16 21:14:24 +04:00
|
|
|
extern Bool g_wrapPixmap; /* from rdpmain.c */
|
2012-07-31 22:18:41 +04:00
|
|
|
extern WindowPtr g_invalidate_window; /* in rdpmain.c */
|
|
|
|
extern int g_use_rail; /* in rdpmain.c */
|
2012-08-10 09:19:10 +04:00
|
|
|
extern int g_do_dirty_os; /* in rdpmain.c */
|
2012-03-06 23:49:15 +04:00
|
|
|
|
|
|
|
ColormapPtr g_rdpInstalledColormap;
|
|
|
|
|
2012-08-10 09:19:10 +04:00
|
|
|
static int g_doing_font = 0;
|
|
|
|
|
2012-05-16 03:48:25 +04:00
|
|
|
GCFuncs g_rdpGCFuncs =
|
2012-03-06 23:49:15 +04:00
|
|
|
{
|
|
|
|
rdpValidateGC, rdpChangeGC, rdpCopyGC, rdpDestroyGC, rdpChangeClip,
|
|
|
|
rdpDestroyClip, rdpCopyClip
|
|
|
|
};
|
|
|
|
|
2012-05-16 03:48:25 +04:00
|
|
|
GCOps g_rdpGCOps =
|
2012-03-06 23:49:15 +04:00
|
|
|
{
|
|
|
|
rdpFillSpans, rdpSetSpans, rdpPutImage, rdpCopyArea, rdpCopyPlane,
|
|
|
|
rdpPolyPoint, rdpPolylines, rdpPolySegment, rdpPolyRectangle,
|
|
|
|
rdpPolyArc, rdpFillPolygon, rdpPolyFillRect, rdpPolyFillArc,
|
|
|
|
rdpPolyText8, rdpPolyText16, rdpImageText8, rdpImageText16,
|
|
|
|
rdpImageGlyphBlt, rdpPolyGlyphBlt, rdpPushPixels
|
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
/* return 0, draw nothing */
|
|
|
|
/* return 1, draw with no clip */
|
|
|
|
/* return 2, draw using clip */
|
2012-05-16 03:48:25 +04:00
|
|
|
int
|
2012-03-06 23:49:15 +04:00
|
|
|
rdp_get_clip(RegionPtr pRegion, DrawablePtr pDrawable, GCPtr pGC)
|
|
|
|
{
|
|
|
|
WindowPtr pWindow;
|
|
|
|
RegionPtr temp;
|
|
|
|
BoxRec box;
|
|
|
|
int rv;
|
|
|
|
|
|
|
|
rv = 0;
|
2012-05-16 21:14:24 +04:00
|
|
|
if (pDrawable->type == DRAWABLE_PIXMAP)
|
|
|
|
{
|
|
|
|
switch (pGC->clientClipType)
|
|
|
|
{
|
|
|
|
case CT_NONE:
|
|
|
|
rv = 1;
|
|
|
|
break;
|
|
|
|
case CT_REGION:
|
|
|
|
rv = 2;
|
|
|
|
RegionCopy(pRegion, pGC->clientClip);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rdpLog("unimp clip type %d\n", pGC->clientClipType);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (rv == 2) /* check if the clip is the entire pixmap */
|
|
|
|
{
|
|
|
|
box.x1 = 0;
|
|
|
|
box.y1 = 0;
|
|
|
|
box.x2 = pDrawable->width;
|
|
|
|
box.y2 = pDrawable->height;
|
|
|
|
if (RegionContainsRect(pRegion, &box) == rgnIN)
|
|
|
|
{
|
|
|
|
rv = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (pDrawable->type == DRAWABLE_WINDOW)
|
2012-03-06 23:49:15 +04:00
|
|
|
{
|
|
|
|
pWindow = (WindowPtr)pDrawable;
|
|
|
|
if (pWindow->viewable)
|
|
|
|
{
|
|
|
|
if (pGC->subWindowMode == IncludeInferiors)
|
|
|
|
{
|
|
|
|
temp = &pWindow->borderClip;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
temp = &pWindow->clipList;
|
|
|
|
}
|
2012-03-08 09:02:41 +04:00
|
|
|
if (RegionNotEmpty(temp))
|
2012-03-06 23:49:15 +04:00
|
|
|
{
|
|
|
|
switch (pGC->clientClipType)
|
|
|
|
{
|
|
|
|
case CT_NONE:
|
|
|
|
rv = 2;
|
2012-03-08 09:02:41 +04:00
|
|
|
RegionCopy(pRegion, temp);
|
2012-03-06 23:49:15 +04:00
|
|
|
break;
|
|
|
|
case CT_REGION:
|
|
|
|
rv = 2;
|
2012-03-08 09:02:41 +04:00
|
|
|
RegionCopy(pRegion, pGC->clientClip);
|
|
|
|
RegionTranslate(pRegion,
|
|
|
|
pDrawable->x + pGC->clipOrg.x,
|
|
|
|
pDrawable->y + pGC->clipOrg.y);
|
|
|
|
RegionIntersect(pRegion, pRegion, temp);
|
2012-03-06 23:49:15 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rdpLog("unimp clip type %d\n", pGC->clientClipType);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (rv == 2) /* check if the clip is the entire screen */
|
|
|
|
{
|
|
|
|
box.x1 = 0;
|
|
|
|
box.y1 = 0;
|
|
|
|
box.x2 = g_rdpScreen.width;
|
|
|
|
box.y2 = g_rdpScreen.height;
|
2012-03-08 09:02:41 +04:00
|
|
|
if (RegionContainsRect(pRegion, &box) == rgnIN)
|
2012-03-06 23:49:15 +04:00
|
|
|
{
|
|
|
|
rv = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
2012-05-16 10:43:38 +04:00
|
|
|
void
|
2012-03-06 23:49:15 +04:00
|
|
|
GetTextBoundingBox(DrawablePtr pDrawable, FontPtr font, int x, int y,
|
|
|
|
int n, BoxPtr pbox)
|
|
|
|
{
|
|
|
|
int maxAscent;
|
|
|
|
int maxDescent;
|
|
|
|
int maxCharWidth;
|
|
|
|
|
|
|
|
if (FONTASCENT(font) > FONTMAXBOUNDS(font, ascent))
|
|
|
|
{
|
|
|
|
maxAscent = FONTASCENT(font);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
maxAscent = FONTMAXBOUNDS(font, ascent);
|
|
|
|
}
|
|
|
|
if (FONTDESCENT(font) > FONTMAXBOUNDS(font, descent))
|
|
|
|
{
|
|
|
|
maxDescent = FONTDESCENT(font);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
maxDescent = FONTMAXBOUNDS(font, descent);
|
|
|
|
}
|
|
|
|
if (FONTMAXBOUNDS(font, rightSideBearing) >
|
|
|
|
FONTMAXBOUNDS(font, characterWidth))
|
|
|
|
{
|
|
|
|
maxCharWidth = FONTMAXBOUNDS(font, rightSideBearing);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
maxCharWidth = FONTMAXBOUNDS(font, characterWidth);
|
|
|
|
}
|
|
|
|
pbox->x1 = pDrawable->x + x;
|
|
|
|
pbox->y1 = pDrawable->y + y - maxAscent;
|
|
|
|
pbox->x2 = pbox->x1 + maxCharWidth * n;
|
|
|
|
pbox->y2 = pbox->y1 + maxAscent + maxDescent;
|
|
|
|
if (FONTMINBOUNDS(font, leftSideBearing) < 0)
|
|
|
|
{
|
|
|
|
pbox->x1 += FONTMINBOUNDS(font, leftSideBearing);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
#define GC_FUNC_PROLOGUE(_pGC) \
|
|
|
|
{ \
|
2012-03-08 09:02:41 +04:00
|
|
|
priv = (rdpGCPtr)(dixGetPrivateAddr(&(_pGC->devPrivates), &g_rdpGCIndex)); \
|
2012-03-06 23:49:15 +04:00
|
|
|
(_pGC)->funcs = priv->funcs; \
|
|
|
|
if (priv->ops != 0) \
|
|
|
|
{ \
|
|
|
|
(_pGC)->ops = priv->ops; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
#define GC_FUNC_EPILOGUE(_pGC) \
|
|
|
|
{ \
|
|
|
|
priv->funcs = (_pGC)->funcs; \
|
|
|
|
(_pGC)->funcs = &g_rdpGCFuncs; \
|
|
|
|
if (priv->ops != 0) \
|
|
|
|
{ \
|
|
|
|
priv->ops = (_pGC)->ops; \
|
|
|
|
(_pGC)->ops = &g_rdpGCOps; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
static void
|
|
|
|
rdpValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr d)
|
|
|
|
{
|
|
|
|
rdpGCRec* priv;
|
2012-05-16 21:14:24 +04:00
|
|
|
int wrap;
|
2012-03-06 23:49:15 +04:00
|
|
|
RegionPtr pRegion;
|
|
|
|
|
2012-05-16 21:14:24 +04:00
|
|
|
LLOGLN(10, ("rdpValidateGC:"));
|
2012-03-06 23:49:15 +04:00
|
|
|
GC_FUNC_PROLOGUE(pGC);
|
|
|
|
pGC->funcs->ValidateGC(pGC, changes, d);
|
2012-05-16 21:14:24 +04:00
|
|
|
if (g_wrapPixmap)
|
2012-03-06 23:49:15 +04:00
|
|
|
{
|
2012-05-16 21:14:24 +04:00
|
|
|
wrap = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wrap = (d->type == DRAWABLE_WINDOW) && ((WindowPtr)d)->viewable;
|
|
|
|
if (wrap)
|
2012-03-06 23:49:15 +04:00
|
|
|
{
|
2012-05-16 21:14:24 +04:00
|
|
|
if (pGC->subWindowMode == IncludeInferiors)
|
|
|
|
{
|
|
|
|
pRegion = &(((WindowPtr)d)->borderClip);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pRegion = &(((WindowPtr)d)->clipList);
|
|
|
|
}
|
|
|
|
wrap = RegionNotEmpty(pRegion);
|
2012-03-06 23:49:15 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
priv->ops = 0;
|
2012-05-16 21:14:24 +04:00
|
|
|
if (wrap)
|
2012-03-06 23:49:15 +04:00
|
|
|
{
|
|
|
|
priv->ops = pGC->ops;
|
|
|
|
}
|
|
|
|
GC_FUNC_EPILOGUE(pGC);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
static void
|
|
|
|
rdpChangeGC(GCPtr pGC, unsigned long mask)
|
|
|
|
{
|
|
|
|
rdpGCRec* priv;
|
|
|
|
|
2012-07-31 22:18:41 +04:00
|
|
|
LLOGLN(10, ("in rdpChangeGC"));
|
2012-03-06 23:49:15 +04:00
|
|
|
GC_FUNC_PROLOGUE(pGC);
|
|
|
|
pGC->funcs->ChangeGC(pGC, mask);
|
|
|
|
GC_FUNC_EPILOGUE(pGC);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
static void
|
|
|
|
rdpCopyGC(GCPtr src, unsigned long mask, GCPtr dst)
|
|
|
|
{
|
|
|
|
rdpGCRec* priv;
|
|
|
|
|
2012-07-31 22:18:41 +04:00
|
|
|
LLOGLN(10, ("in rdpCopyGC"));
|
2012-03-06 23:49:15 +04:00
|
|
|
GC_FUNC_PROLOGUE(dst);
|
|
|
|
dst->funcs->CopyGC(src, mask, dst);
|
|
|
|
GC_FUNC_EPILOGUE(dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
static void
|
|
|
|
rdpDestroyGC(GCPtr pGC)
|
|
|
|
{
|
|
|
|
rdpGCRec* priv;
|
|
|
|
|
2012-07-31 22:18:41 +04:00
|
|
|
LLOGLN(10, ("in rdpDestroyGC"));
|
2012-03-06 23:49:15 +04:00
|
|
|
GC_FUNC_PROLOGUE(pGC);
|
|
|
|
pGC->funcs->DestroyGC(pGC);
|
|
|
|
GC_FUNC_EPILOGUE(pGC);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
static void
|
|
|
|
rdpChangeClip(GCPtr pGC, int type, pointer pValue, int nrects)
|
|
|
|
{
|
|
|
|
rdpGCRec* priv;
|
|
|
|
|
2012-08-10 09:19:10 +04:00
|
|
|
LLOGLN(10, ("in rdpChangeClip"));
|
2012-03-06 23:49:15 +04:00
|
|
|
GC_FUNC_PROLOGUE(pGC);
|
|
|
|
pGC->funcs->ChangeClip(pGC, type, pValue, nrects);
|
|
|
|
GC_FUNC_EPILOGUE(pGC);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
static void
|
|
|
|
rdpDestroyClip(GCPtr pGC)
|
|
|
|
{
|
|
|
|
rdpGCRec* priv;
|
|
|
|
|
2012-07-31 22:18:41 +04:00
|
|
|
LLOGLN(10, ("in rdpDestroyClip"));
|
2012-03-06 23:49:15 +04:00
|
|
|
GC_FUNC_PROLOGUE(pGC);
|
|
|
|
pGC->funcs->DestroyClip(pGC);
|
|
|
|
GC_FUNC_EPILOGUE(pGC);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
static void
|
|
|
|
rdpCopyClip(GCPtr dst, GCPtr src)
|
|
|
|
{
|
|
|
|
rdpGCRec* priv;
|
|
|
|
|
2012-07-31 22:18:41 +04:00
|
|
|
LLOGLN(0, ("in rdpCopyClip"));
|
2012-03-06 23:49:15 +04:00
|
|
|
GC_FUNC_PROLOGUE(dst);
|
|
|
|
dst->funcs->CopyClip(dst, src);
|
|
|
|
GC_FUNC_EPILOGUE(dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
#define GC_OP_PROLOGUE(_pGC) \
|
|
|
|
{ \
|
2012-03-08 09:02:41 +04:00
|
|
|
priv = (rdpGCPtr)dixGetPrivateAddr(&(pGC->devPrivates), &g_rdpGCIndex); \
|
2012-03-06 23:49:15 +04:00
|
|
|
oldFuncs = _pGC->funcs; \
|
|
|
|
(_pGC)->funcs = priv->funcs; \
|
|
|
|
(_pGC)->ops = priv->ops; \
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
#define GC_OP_EPILOGUE(_pGC) \
|
|
|
|
{ \
|
|
|
|
priv->ops = (_pGC)->ops; \
|
|
|
|
(_pGC)->funcs = oldFuncs; \
|
|
|
|
(_pGC)->ops = &g_rdpGCOps; \
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
Bool
|
|
|
|
rdpCloseScreen(int i, ScreenPtr pScreen)
|
|
|
|
{
|
2012-07-31 22:18:41 +04:00
|
|
|
LLOGLN(10, ("in rdpCloseScreen"));
|
2012-03-06 23:49:15 +04:00
|
|
|
pScreen->CloseScreen = g_rdpScreen.CloseScreen;
|
|
|
|
pScreen->CreateGC = g_rdpScreen.CreateGC;
|
2012-03-08 09:02:41 +04:00
|
|
|
//pScreen->PaintWindowBackground = g_rdpScreen.PaintWindowBackground;
|
|
|
|
//pScreen->PaintWindowBorder = g_rdpScreen.PaintWindowBorder;
|
2012-03-06 23:49:15 +04:00
|
|
|
pScreen->CopyWindow = g_rdpScreen.CopyWindow;
|
|
|
|
pScreen->ClearToBackground = g_rdpScreen.ClearToBackground;
|
|
|
|
pScreen->RestoreAreas = g_rdpScreen.RestoreAreas;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-08-10 09:19:10 +04:00
|
|
|
/******************************************************************************/
|
|
|
|
int
|
|
|
|
draw_item_add(rdpPixmapRec* priv, struct rdp_draw_item* di)
|
|
|
|
{
|
|
|
|
if (priv->draw_item_tail == 0)
|
|
|
|
{
|
|
|
|
priv->draw_item_tail = di;
|
|
|
|
priv->draw_item_head = di;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
di->prev = priv->draw_item_tail;
|
|
|
|
priv->draw_item_tail->next = di;
|
|
|
|
priv->draw_item_tail = di;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
int
|
|
|
|
draw_item_remove(rdpPixmapRec* priv, struct rdp_draw_item* di)
|
|
|
|
{
|
|
|
|
if (di->prev != 0)
|
|
|
|
{
|
|
|
|
di->prev->next = di->next;
|
|
|
|
}
|
|
|
|
if (di->next != 0)
|
|
|
|
{
|
|
|
|
di->next->prev = di->prev;
|
|
|
|
}
|
|
|
|
if (priv->draw_item_head == di)
|
|
|
|
{
|
|
|
|
priv->draw_item_head = di->next;
|
|
|
|
}
|
|
|
|
if (priv->draw_item_tail == di)
|
|
|
|
{
|
|
|
|
priv->draw_item_tail = di->prev;
|
|
|
|
}
|
2012-08-16 02:40:17 +04:00
|
|
|
if (di->type == RDI_LINE)
|
|
|
|
{
|
|
|
|
if (di->u.line.segs != 0)
|
|
|
|
{
|
2012-08-17 10:23:18 +04:00
|
|
|
g_free(di->u.line.segs);
|
2012-08-16 02:40:17 +04:00
|
|
|
}
|
|
|
|
}
|
2012-08-10 09:19:10 +04:00
|
|
|
RegionDestroy(di->reg);
|
2012-08-16 02:40:17 +04:00
|
|
|
g_free(di);
|
2012-08-10 09:19:10 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
int
|
|
|
|
draw_item_remove_all(rdpPixmapRec* priv)
|
|
|
|
{
|
|
|
|
struct rdp_draw_item* di;
|
|
|
|
|
|
|
|
di = priv->draw_item_head;
|
|
|
|
while (di != 0)
|
|
|
|
{
|
|
|
|
draw_item_remove(priv, di);
|
|
|
|
di = priv->draw_item_head;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
int
|
|
|
|
draw_item_pack(rdpPixmapRec* priv)
|
|
|
|
{
|
|
|
|
struct rdp_draw_item* di;
|
|
|
|
struct rdp_draw_item* di_prev;
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
/* look for repeating draw types */
|
|
|
|
if (priv->draw_item_head != 0)
|
|
|
|
{
|
|
|
|
if (priv->draw_item_head->next != 0)
|
|
|
|
{
|
|
|
|
di_prev = priv->draw_item_head;
|
|
|
|
di = priv->draw_item_head->next;
|
|
|
|
while (di != 0)
|
|
|
|
{
|
|
|
|
if ((di_prev->type == RDI_IMGLL) && (di->type == RDI_IMGLL))
|
|
|
|
{
|
|
|
|
LLOGLN(10, ("draw_item_pack: packing RDI_IMGLL"));
|
|
|
|
RegionUnion(di_prev->reg, di_prev->reg, di->reg);
|
|
|
|
draw_item_remove(priv, di);
|
|
|
|
di = di_prev->next;
|
|
|
|
}
|
|
|
|
else if ((di_prev->type == RDI_IMGLY) && (di->type == RDI_IMGLY))
|
|
|
|
{
|
|
|
|
LLOGLN(10, ("draw_item_pack: packing RDI_IMGLY"));
|
|
|
|
RegionUnion(di_prev->reg, di_prev->reg, di->reg);
|
|
|
|
draw_item_remove(priv, di);
|
|
|
|
di = di_prev->next;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
di_prev = di;
|
|
|
|
di = di_prev->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if 1
|
|
|
|
/* subtract regions */
|
|
|
|
if (priv->draw_item_tail != 0)
|
|
|
|
{
|
|
|
|
if (priv->draw_item_tail->prev != 0)
|
|
|
|
{
|
|
|
|
di = priv->draw_item_tail;
|
|
|
|
while (di->prev != 0)
|
|
|
|
{
|
2012-08-16 02:40:17 +04:00
|
|
|
/* skip subtract flag
|
|
|
|
* draw items like line can't be used to clear(subtract) previous
|
|
|
|
* draw items since they are not opaque
|
|
|
|
* eg they can not be the 'S' in 'D = M - S'
|
|
|
|
* the region for line draw items is the clip region */
|
|
|
|
if ((di->flags & 1) == 0)
|
2012-08-10 09:19:10 +04:00
|
|
|
{
|
2012-08-16 02:40:17 +04:00
|
|
|
di_prev = di->prev;
|
|
|
|
while (di_prev != 0)
|
|
|
|
{
|
|
|
|
/* D = M - S */
|
|
|
|
RegionSubtract(di_prev->reg, di_prev->reg, di->reg);
|
|
|
|
di_prev = di_prev->prev;
|
|
|
|
}
|
2012-08-10 09:19:10 +04:00
|
|
|
}
|
|
|
|
di = di->prev;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if 1
|
|
|
|
/* remove draw items with empty regions */
|
|
|
|
di = priv->draw_item_head;
|
|
|
|
di_prev = 0;
|
|
|
|
while (di != 0)
|
|
|
|
{
|
|
|
|
if (!RegionNotEmpty(di->reg))
|
|
|
|
{
|
|
|
|
LLOGLN(10, ("draw_item_pack: removing empty item type %d", di->type));
|
|
|
|
draw_item_remove(priv, di);
|
|
|
|
di = di_prev == 0 ? priv->draw_item_head : di_prev->next;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
di_prev = di;
|
|
|
|
di = di->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
int
|
2012-08-16 02:40:17 +04:00
|
|
|
draw_item_add_img_region(rdpPixmapRec* priv, RegionPtr reg, int opcode,
|
|
|
|
int type)
|
2012-08-10 09:19:10 +04:00
|
|
|
{
|
|
|
|
struct rdp_draw_item* di;
|
|
|
|
|
2012-08-16 02:40:17 +04:00
|
|
|
di = (struct rdp_draw_item*)g_malloc(sizeof(struct rdp_draw_item), 1);
|
2012-08-10 09:19:10 +04:00
|
|
|
di->type = type;
|
|
|
|
di->reg = RegionCreate(NullBox, 0);
|
|
|
|
RegionCopy(di->reg, reg);
|
2012-08-16 02:40:17 +04:00
|
|
|
di->u.img.opcode = opcode;
|
2012-08-10 09:19:10 +04:00
|
|
|
draw_item_add(priv, di);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
int
|
|
|
|
draw_item_add_fill_region(rdpPixmapRec* priv, RegionPtr reg, int color,
|
|
|
|
int opcode)
|
|
|
|
{
|
|
|
|
struct rdp_draw_item* di;
|
|
|
|
|
2012-08-16 02:40:17 +04:00
|
|
|
di = (struct rdp_draw_item*)g_malloc(sizeof(struct rdp_draw_item), 1);
|
2012-08-10 09:19:10 +04:00
|
|
|
di->type = RDI_FILL;
|
2012-08-16 02:40:17 +04:00
|
|
|
di->u.fill.fg_color = color;
|
|
|
|
di->u.fill.opcode = opcode;
|
|
|
|
di->reg = RegionCreate(NullBox, 0);
|
|
|
|
RegionCopy(di->reg, reg);
|
|
|
|
draw_item_add(priv, di);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
int
|
|
|
|
draw_item_add_line_region(rdpPixmapRec* priv, RegionPtr reg, int color,
|
|
|
|
int opcode, int width, xSegment* segs, int nseg,
|
|
|
|
int is_segment)
|
|
|
|
{
|
|
|
|
struct rdp_draw_item* di;
|
|
|
|
|
|
|
|
LLOGLN(10, ("draw_item_add_line_region:"));
|
|
|
|
di = (struct rdp_draw_item*)g_malloc(sizeof(struct rdp_draw_item), 1);
|
|
|
|
di->type = RDI_LINE;
|
|
|
|
di->u.line.fg_color = color;
|
|
|
|
di->u.line.opcode = opcode;
|
|
|
|
di->u.line.width = width;
|
|
|
|
di->u.line.segs = (xSegment*)g_malloc(sizeof(xSegment) * nseg, 1);
|
|
|
|
memcpy(di->u.line.segs, segs, sizeof(xSegment) * nseg);
|
|
|
|
di->u.line.nseg = nseg;
|
|
|
|
if (is_segment)
|
|
|
|
{
|
|
|
|
di->u.line.flags = 1;
|
|
|
|
}
|
2012-08-10 09:19:10 +04:00
|
|
|
di->reg = RegionCreate(NullBox, 0);
|
2012-08-16 02:40:17 +04:00
|
|
|
di->flags |= 1;
|
2012-08-10 09:19:10 +04:00
|
|
|
RegionCopy(di->reg, reg);
|
|
|
|
draw_item_add(priv, di);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-03-06 23:49:15 +04:00
|
|
|
/******************************************************************************/
|
|
|
|
PixmapPtr
|
2012-03-08 09:02:41 +04:00
|
|
|
rdpCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
|
|
|
|
unsigned usage_hint)
|
2012-03-06 23:49:15 +04:00
|
|
|
{
|
|
|
|
PixmapPtr rv;
|
2012-03-15 04:16:42 +04:00
|
|
|
rdpPixmapRec* priv;
|
2012-05-16 21:14:24 +04:00
|
|
|
int org_width;
|
2012-03-06 23:49:15 +04:00
|
|
|
|
2012-05-16 21:14:24 +04:00
|
|
|
org_width = width;
|
2012-05-18 05:48:28 +04:00
|
|
|
/* width must be a multiple of 4 in rdp */
|
2012-05-16 21:14:24 +04:00
|
|
|
width = (width + 3) & ~3;
|
2012-08-10 09:19:10 +04:00
|
|
|
LLOGLN(10, ("rdpCreatePixmap: width %d org_width %d depth %d screen depth %d",
|
|
|
|
width, org_width, depth, g_rdpScreen.depth));
|
2012-03-06 23:49:15 +04:00
|
|
|
pScreen->CreatePixmap = g_rdpScreen.CreatePixmap;
|
2012-03-08 09:02:41 +04:00
|
|
|
rv = pScreen->CreatePixmap(pScreen, width, height, depth, usage_hint);
|
2012-03-15 04:16:42 +04:00
|
|
|
priv = GETPIXPRIV(rv);
|
2012-05-20 06:25:08 +04:00
|
|
|
priv->rdpindex = -1;
|
2012-08-10 09:19:10 +04:00
|
|
|
if ((rv->drawable.depth >= g_rdpScreen.depth) &&
|
2012-05-20 06:25:08 +04:00
|
|
|
(org_width > 1) && (height > 1))
|
2012-05-18 05:48:28 +04:00
|
|
|
{
|
2012-05-20 06:25:08 +04:00
|
|
|
priv->allocBytes = width * height * g_Bpp;
|
|
|
|
priv->rdpindex = rdpup_add_os_bitmap(rv, priv);
|
|
|
|
if (priv->rdpindex >= 0)
|
|
|
|
{
|
|
|
|
priv->status = 1;
|
|
|
|
rdpup_create_os_surface(priv->rdpindex, width, height);
|
|
|
|
}
|
2012-05-18 05:48:28 +04:00
|
|
|
}
|
2012-05-16 21:14:24 +04:00
|
|
|
pScreen->ModifyPixmapHeader(rv, org_width, 0, 0, 0, 0, 0);
|
2012-05-18 05:48:28 +04:00
|
|
|
pScreen->CreatePixmap = rdpCreatePixmap;
|
2012-03-06 23:49:15 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-08-16 02:40:17 +04:00
|
|
|
extern struct rdpup_os_bitmap* g_os_bitmaps;
|
|
|
|
|
2012-03-06 23:49:15 +04:00
|
|
|
/******************************************************************************/
|
|
|
|
Bool
|
|
|
|
rdpDestroyPixmap(PixmapPtr pPixmap)
|
|
|
|
{
|
|
|
|
Bool rv;
|
|
|
|
ScreenPtr pScreen;
|
2012-03-15 04:16:42 +04:00
|
|
|
rdpPixmapRec* priv;
|
2012-03-06 23:49:15 +04:00
|
|
|
|
2012-05-18 05:48:28 +04:00
|
|
|
LLOGLN(10, ("rdpDestroyPixmap:"));
|
2012-03-15 04:16:42 +04:00
|
|
|
priv = GETPIXPRIV(pPixmap);
|
2012-05-18 05:48:28 +04:00
|
|
|
LLOGLN(10, ("status %d refcnt %d", priv->status, pPixmap->refcnt));
|
|
|
|
if (pPixmap->refcnt < 2)
|
|
|
|
{
|
2012-05-20 06:25:08 +04:00
|
|
|
if (XRDP_IS_OS(priv))
|
2012-05-18 05:48:28 +04:00
|
|
|
{
|
2012-05-20 06:25:08 +04:00
|
|
|
rdpup_remove_os_bitmap(priv->rdpindex);
|
|
|
|
rdpup_delete_os_surface(priv->rdpindex);
|
2012-08-10 09:19:10 +04:00
|
|
|
draw_item_remove_all(priv);
|
2012-05-18 05:48:28 +04:00
|
|
|
}
|
|
|
|
}
|
2012-03-06 23:49:15 +04:00
|
|
|
pScreen = pPixmap->drawable.pScreen;
|
|
|
|
pScreen->DestroyPixmap = g_rdpScreen.DestroyPixmap;
|
|
|
|
rv = pScreen->DestroyPixmap(pPixmap);
|
|
|
|
pScreen->DestroyPixmap = rdpDestroyPixmap;
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-03-15 04:16:42 +04:00
|
|
|
/******************************************************************************/
|
|
|
|
Bool
|
|
|
|
rdpCreateWindow(WindowPtr pWindow)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
rdpWindowRec* priv;
|
|
|
|
Bool rv;
|
|
|
|
|
2012-07-31 22:18:41 +04:00
|
|
|
LLOGLN(10, ("rdpCreateWindow:"));
|
2012-03-15 04:16:42 +04:00
|
|
|
priv = GETWINPRIV(pWindow);
|
2012-07-31 22:18:41 +04:00
|
|
|
LLOGLN(10, (" %p status %d", priv, priv->status));
|
2012-03-15 04:16:42 +04:00
|
|
|
pScreen = pWindow->drawable.pScreen;
|
|
|
|
pScreen->CreateWindow = g_rdpScreen.CreateWindow;
|
|
|
|
rv = pScreen->CreateWindow(pWindow);
|
|
|
|
pScreen->CreateWindow = rdpCreateWindow;
|
2012-07-31 22:18:41 +04:00
|
|
|
if (g_use_rail)
|
|
|
|
{
|
|
|
|
}
|
2012-03-15 04:16:42 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
Bool
|
|
|
|
rdpDestroyWindow(WindowPtr pWindow)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
rdpWindowRec* priv;
|
|
|
|
Bool rv;
|
|
|
|
|
2012-07-31 22:18:41 +04:00
|
|
|
LLOGLN(10, ("rdpDestroyWindow:"));
|
2012-03-15 04:16:42 +04:00
|
|
|
priv = GETWINPRIV(pWindow);
|
|
|
|
pScreen = pWindow->drawable.pScreen;
|
|
|
|
pScreen->DestroyWindow = g_rdpScreen.DestroyWindow;
|
|
|
|
rv = pScreen->DestroyWindow(pWindow);
|
|
|
|
pScreen->DestroyWindow = rdpDestroyWindow;
|
2012-07-31 22:18:41 +04:00
|
|
|
if (g_use_rail)
|
|
|
|
{
|
|
|
|
}
|
2012-03-15 04:16:42 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-03-06 23:49:15 +04:00
|
|
|
/******************************************************************************/
|
2012-06-02 02:06:53 +04:00
|
|
|
Bool
|
|
|
|
rdpPositionWindow(WindowPtr pWindow, int x, int y)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
rdpWindowRec* priv;
|
|
|
|
Bool rv;
|
|
|
|
|
2012-07-31 22:18:41 +04:00
|
|
|
LLOGLN(10, ("rdpPositionWindow:"));
|
2012-06-02 02:06:53 +04:00
|
|
|
priv = GETWINPRIV(pWindow);
|
|
|
|
pScreen = pWindow->drawable.pScreen;
|
|
|
|
pScreen->PositionWindow = g_rdpScreen.PositionWindow;
|
|
|
|
rv = pScreen->PositionWindow(pWindow, x, y);
|
|
|
|
pScreen->PositionWindow = rdpPositionWindow;
|
2012-07-31 22:18:41 +04:00
|
|
|
if (g_use_rail)
|
|
|
|
{
|
|
|
|
if (priv->status == 1)
|
|
|
|
{
|
|
|
|
LLOGLN(10, ("rdpPositionWindow:"));
|
|
|
|
LLOGLN(10, (" x %d y %d", x, y));
|
|
|
|
}
|
|
|
|
}
|
2012-06-02 02:06:53 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
Bool
|
|
|
|
rdpRealizeWindow(WindowPtr pWindow)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
rdpWindowRec* priv;
|
|
|
|
Bool rv;
|
|
|
|
|
2012-08-17 10:23:18 +04:00
|
|
|
LLOGLN(10, ("rdpRealizeWindow:"));
|
2012-06-02 02:06:53 +04:00
|
|
|
priv = GETWINPRIV(pWindow);
|
|
|
|
pScreen = pWindow->drawable.pScreen;
|
|
|
|
pScreen->RealizeWindow = g_rdpScreen.RealizeWindow;
|
|
|
|
rv = pScreen->RealizeWindow(pWindow);
|
|
|
|
pScreen->RealizeWindow = rdpRealizeWindow;
|
2012-07-31 22:18:41 +04:00
|
|
|
if (g_use_rail)
|
|
|
|
{
|
|
|
|
if ((pWindow != g_invalidate_window) && (pWindow->parent != 0))
|
|
|
|
{
|
|
|
|
if (XR_IS_ROOT(pWindow->parent))
|
|
|
|
{
|
|
|
|
LLOGLN(10, ("rdpRealizeWindow:"));
|
|
|
|
LLOGLN(10, (" pWindow %p id 0x%x pWindow->parent %p id 0x%x x %d "
|
|
|
|
"y %d width %d height %d",
|
|
|
|
pWindow, pWindow->drawable.id,
|
|
|
|
pWindow->parent, pWindow->parent->drawable.id,
|
|
|
|
pWindow->drawable.x, pWindow->drawable.y,
|
|
|
|
pWindow->drawable.width, pWindow->drawable.height));
|
|
|
|
priv->status = 1;
|
|
|
|
rdpup_create_window(pWindow, priv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-06-02 02:06:53 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
Bool
|
|
|
|
rdpUnrealizeWindow(WindowPtr pWindow)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
rdpWindowRec* priv;
|
|
|
|
Bool rv;
|
|
|
|
|
2012-08-17 10:23:18 +04:00
|
|
|
LLOGLN(10, ("rdpUnrealizeWindow:"));
|
2012-06-02 02:06:53 +04:00
|
|
|
priv = GETWINPRIV(pWindow);
|
|
|
|
pScreen = pWindow->drawable.pScreen;
|
|
|
|
pScreen->UnrealizeWindow = g_rdpScreen.UnrealizeWindow;
|
|
|
|
rv = pScreen->UnrealizeWindow(pWindow);
|
|
|
|
pScreen->UnrealizeWindow = rdpUnrealizeWindow;
|
2012-07-31 22:18:41 +04:00
|
|
|
if (g_use_rail)
|
|
|
|
{
|
|
|
|
if (priv->status == 1)
|
|
|
|
{
|
|
|
|
LLOGLN(10, ("rdpUnrealizeWindow:"));
|
|
|
|
priv->status = 0;
|
|
|
|
rdpup_delete_window(pWindow, priv);
|
|
|
|
}
|
|
|
|
}
|
2012-06-02 02:06:53 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
Bool
|
|
|
|
rdpChangeWindowAttributes(WindowPtr pWindow, unsigned long mask)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
rdpWindowRec* priv;
|
|
|
|
Bool rv;
|
|
|
|
|
2012-07-31 22:18:41 +04:00
|
|
|
LLOGLN(10, ("rdpChangeWindowAttributes:"));
|
2012-06-02 02:06:53 +04:00
|
|
|
priv = GETWINPRIV(pWindow);
|
|
|
|
pScreen = pWindow->drawable.pScreen;
|
|
|
|
pScreen->ChangeWindowAttributes = g_rdpScreen.ChangeWindowAttributes;
|
|
|
|
rv = pScreen->ChangeWindowAttributes(pWindow, mask);
|
|
|
|
pScreen->ChangeWindowAttributes = rdpChangeWindowAttributes;
|
2012-07-31 22:18:41 +04:00
|
|
|
if (g_use_rail)
|
|
|
|
{
|
|
|
|
}
|
2012-06-02 02:06:53 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
void
|
|
|
|
rdpWindowExposures(WindowPtr pWindow, RegionPtr pRegion, RegionPtr pBSRegion)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
rdpWindowRec* priv;
|
|
|
|
|
2012-07-31 22:18:41 +04:00
|
|
|
LLOGLN(10, ("rdpWindowExposures:"));
|
2012-06-02 02:06:53 +04:00
|
|
|
priv = GETWINPRIV(pWindow);
|
|
|
|
pScreen = pWindow->drawable.pScreen;
|
|
|
|
pScreen->WindowExposures = g_rdpScreen.WindowExposures;
|
|
|
|
pScreen->WindowExposures(pWindow, pRegion, pBSRegion);
|
2012-07-31 22:18:41 +04:00
|
|
|
if (g_use_rail)
|
|
|
|
{
|
|
|
|
}
|
2012-06-02 02:06:53 +04:00
|
|
|
pScreen->WindowExposures = rdpWindowExposures;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
2012-03-06 23:49:15 +04:00
|
|
|
Bool
|
|
|
|
rdpCreateGC(GCPtr pGC)
|
|
|
|
{
|
|
|
|
rdpGCRec* priv;
|
|
|
|
Bool rv;
|
|
|
|
|
2012-07-31 22:18:41 +04:00
|
|
|
LLOGLN(10, ("in rdpCreateGC\n"));
|
2012-03-15 04:16:42 +04:00
|
|
|
priv = GETGCPRIV(pGC);
|
|
|
|
g_pScreen->CreateGC = g_rdpScreen.CreateGC;
|
|
|
|
rv = g_pScreen->CreateGC(pGC);
|
|
|
|
if (rv)
|
2012-03-06 23:49:15 +04:00
|
|
|
{
|
2012-03-15 04:16:42 +04:00
|
|
|
priv->funcs = pGC->funcs;
|
|
|
|
priv->ops = 0;
|
|
|
|
pGC->funcs = &g_rdpGCFuncs;
|
2012-03-06 23:49:15 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-03-15 04:16:42 +04:00
|
|
|
rdpLog("error in rdpCreateGC, CreateGC failed\n");
|
2012-03-06 23:49:15 +04:00
|
|
|
}
|
2012-03-15 04:16:42 +04:00
|
|
|
g_pScreen->CreateGC = rdpCreateGC;
|
2012-03-06 23:49:15 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
void
|
|
|
|
rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion)
|
|
|
|
{
|
|
|
|
RegionRec reg;
|
|
|
|
RegionRec clip;
|
|
|
|
int dx;
|
|
|
|
int dy;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int num_clip_rects;
|
|
|
|
int num_reg_rects;
|
|
|
|
BoxRec box1;
|
|
|
|
BoxRec box2;
|
|
|
|
|
2012-07-31 22:18:41 +04:00
|
|
|
LLOGLN(10, ("in rdpCopyWindow"));
|
2012-03-08 09:02:41 +04:00
|
|
|
RegionInit(®, NullBox, 0);
|
|
|
|
RegionCopy(®, pOldRegion);
|
2012-03-06 23:49:15 +04:00
|
|
|
g_pScreen->CopyWindow = g_rdpScreen.CopyWindow;
|
|
|
|
g_pScreen->CopyWindow(pWin, ptOldOrg, pOldRegion);
|
2012-03-08 09:02:41 +04:00
|
|
|
RegionInit(&clip, NullBox, 0);
|
|
|
|
RegionCopy(&clip, &pWin->borderClip);
|
2012-03-06 23:49:15 +04:00
|
|
|
dx = pWin->drawable.x - ptOldOrg.x;
|
|
|
|
dy = pWin->drawable.y - ptOldOrg.y;
|
|
|
|
rdpup_begin_update();
|
|
|
|
num_clip_rects = REGION_NUM_RECTS(&clip);
|
|
|
|
num_reg_rects = REGION_NUM_RECTS(®);
|
|
|
|
/* should maybe sort the rects instead of checking dy < 0 */
|
|
|
|
/* If we can depend on the rects going from top to bottom, left
|
|
|
|
to right we are ok */
|
|
|
|
if (dy < 0 || (dy == 0 && dx < 0))
|
|
|
|
{
|
|
|
|
for (j = 0; j < num_clip_rects; j++)
|
|
|
|
{
|
|
|
|
box1 = REGION_RECTS(&clip)[j];
|
|
|
|
rdpup_set_clip(box1.x1, box1.y1, box1.x2 - box1.x1, box1.y2 - box1.y1);
|
|
|
|
for (i = 0; i < num_reg_rects; i++)
|
|
|
|
{
|
|
|
|
box2 = REGION_RECTS(®)[i];
|
|
|
|
rdpup_screen_blt(box2.x1 + dx, box2.y1 + dy, box2.x2 - box2.x1,
|
|
|
|
box2.y2 - box2.y1, box2.x1, box2.y1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (j = num_clip_rects - 1; j >= 0; j--)
|
|
|
|
{
|
|
|
|
box1 = REGION_RECTS(&clip)[j];
|
|
|
|
rdpup_set_clip(box1.x1, box1.y1, box1.x2 - box1.x1, box1.y2 - box1.y1);
|
|
|
|
for (i = num_reg_rects - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
box2 = REGION_RECTS(®)[i];
|
|
|
|
rdpup_screen_blt(box2.x1 + dx, box2.y1 + dy, box2.x2 - box2.x1,
|
|
|
|
box2.y2 - box2.y1, box2.x1, box2.y1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rdpup_reset_clip();
|
|
|
|
rdpup_end_update();
|
2012-03-08 09:02:41 +04:00
|
|
|
RegionUninit(®);
|
|
|
|
RegionUninit(&clip);
|
2012-03-06 23:49:15 +04:00
|
|
|
g_pScreen->CopyWindow = rdpCopyWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
void
|
|
|
|
rdpClearToBackground(WindowPtr pWin, int x, int y, int w, int h,
|
|
|
|
Bool generateExposures)
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
BoxRec box;
|
|
|
|
RegionRec reg;
|
|
|
|
|
2012-07-31 22:18:41 +04:00
|
|
|
LLOGLN(10, ("in rdpClearToBackground"));
|
2012-03-06 23:49:15 +04:00
|
|
|
g_pScreen->ClearToBackground = g_rdpScreen.ClearToBackground;
|
|
|
|
g_pScreen->ClearToBackground(pWin, x, y, w, h, generateExposures);
|
|
|
|
if (!generateExposures)
|
|
|
|
{
|
|
|
|
if (w > 0 && h > 0)
|
|
|
|
{
|
|
|
|
box.x1 = x;
|
|
|
|
box.y1 = y;
|
|
|
|
box.x2 = box.x1 + w;
|
|
|
|
box.y2 = box.y1 + h;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
box.x1 = pWin->drawable.x;
|
|
|
|
box.y1 = pWin->drawable.y;
|
|
|
|
box.x2 = box.x1 + pWin->drawable.width;
|
|
|
|
box.y2 = box.y1 + pWin->drawable.height;
|
|
|
|
}
|
2012-03-08 09:02:41 +04:00
|
|
|
RegionInit(®, &box, 0);
|
|
|
|
RegionIntersect(®, ®, &pWin->clipList);
|
2012-03-06 23:49:15 +04:00
|
|
|
rdpup_begin_update();
|
|
|
|
for (j = REGION_NUM_RECTS(®) - 1; j >= 0; j--)
|
|
|
|
{
|
|
|
|
box = REGION_RECTS(®)[j];
|
2012-05-16 03:48:25 +04:00
|
|
|
rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
|
2012-03-06 23:49:15 +04:00
|
|
|
}
|
|
|
|
rdpup_end_update();
|
2012-03-08 09:02:41 +04:00
|
|
|
RegionUninit(®);
|
2012-03-06 23:49:15 +04:00
|
|
|
}
|
|
|
|
g_pScreen->ClearToBackground = rdpClearToBackground;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
RegionPtr
|
|
|
|
rdpRestoreAreas(WindowPtr pWin, RegionPtr prgnExposed)
|
|
|
|
{
|
|
|
|
RegionRec reg;
|
|
|
|
RegionPtr rv;
|
|
|
|
int j;
|
|
|
|
BoxRec box;
|
|
|
|
|
2012-07-31 22:18:41 +04:00
|
|
|
LLOGLN(10, ("in rdpRestoreAreas"));
|
2012-03-08 09:02:41 +04:00
|
|
|
RegionInit(®, NullBox, 0);
|
|
|
|
RegionCopy(®, prgnExposed);
|
2012-03-06 23:49:15 +04:00
|
|
|
g_pScreen->RestoreAreas = g_rdpScreen.RestoreAreas;
|
|
|
|
rv = g_pScreen->RestoreAreas(pWin, prgnExposed);
|
|
|
|
rdpup_begin_update();
|
|
|
|
for (j = REGION_NUM_RECTS(®) - 1; j >= 0; j--)
|
|
|
|
{
|
|
|
|
box = REGION_RECTS(®)[j];
|
2012-05-16 03:48:25 +04:00
|
|
|
rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
|
2012-03-06 23:49:15 +04:00
|
|
|
}
|
|
|
|
rdpup_end_update();
|
2012-03-08 09:02:41 +04:00
|
|
|
RegionUninit(®);
|
2012-03-06 23:49:15 +04:00
|
|
|
g_pScreen->RestoreAreas = rdpRestoreAreas;
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
void
|
|
|
|
rdpInstallColormap(ColormapPtr pmap)
|
|
|
|
{
|
|
|
|
ColormapPtr oldpmap;
|
|
|
|
|
|
|
|
oldpmap = g_rdpInstalledColormap;
|
|
|
|
if (pmap != oldpmap)
|
|
|
|
{
|
|
|
|
if (oldpmap != (ColormapPtr)None)
|
|
|
|
{
|
|
|
|
WalkTree(pmap->pScreen, TellLostMap, (char*)&oldpmap->mid);
|
|
|
|
}
|
|
|
|
/* Install pmap */
|
|
|
|
g_rdpInstalledColormap = pmap;
|
|
|
|
WalkTree(pmap->pScreen, TellGainedMap, (char*)&pmap->mid);
|
|
|
|
/*rfbSetClientColourMaps(0, 0);*/
|
|
|
|
}
|
|
|
|
/*g_rdpScreen.InstallColormap(pmap);*/
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
void
|
|
|
|
rdpUninstallColormap(ColormapPtr pmap)
|
|
|
|
{
|
|
|
|
ColormapPtr curpmap;
|
|
|
|
|
|
|
|
curpmap = g_rdpInstalledColormap;
|
|
|
|
if (pmap == curpmap)
|
|
|
|
{
|
|
|
|
if (pmap->mid != pmap->pScreen->defColormap)
|
|
|
|
{
|
2012-03-08 09:02:41 +04:00
|
|
|
//curpmap = (ColormapPtr)LookupIDByType(pmap->pScreen->defColormap,
|
|
|
|
// RT_COLORMAP);
|
|
|
|
//pmap->pScreen->InstallColormap(curpmap);
|
2012-03-06 23:49:15 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
int
|
|
|
|
rdpListInstalledColormaps(ScreenPtr pScreen, Colormap* pmaps)
|
|
|
|
{
|
|
|
|
*pmaps = g_rdpInstalledColormap->mid;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
void
|
|
|
|
rdpStoreColors(ColormapPtr pmap, int ndef, xColorItem* pdefs)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
Bool
|
|
|
|
rdpSaveScreen(ScreenPtr pScreen, int on)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
/* it looks like all the antialias draws go through here */
|
|
|
|
void
|
|
|
|
rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
|
|
|
|
INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst,
|
|
|
|
INT16 yDst, CARD16 width, CARD16 height)
|
|
|
|
{
|
|
|
|
BoxRec box;
|
|
|
|
PictureScreenPtr ps;
|
|
|
|
RegionRec reg1;
|
|
|
|
RegionRec reg2;
|
|
|
|
DrawablePtr p;
|
2012-08-10 09:19:10 +04:00
|
|
|
int dirty_type;
|
2012-03-06 23:49:15 +04:00
|
|
|
int j;
|
|
|
|
int num_clips;
|
2012-08-10 09:19:10 +04:00
|
|
|
int post_process;
|
|
|
|
int reset_surface;
|
2012-05-18 05:48:28 +04:00
|
|
|
int got_id;
|
2012-08-10 09:19:10 +04:00
|
|
|
int lx;
|
|
|
|
int ly;
|
2012-05-18 05:48:28 +04:00
|
|
|
WindowPtr pDstWnd;
|
|
|
|
PixmapPtr pDstPixmap;
|
|
|
|
rdpPixmapRec* pDstPriv;
|
2012-08-10 09:19:10 +04:00
|
|
|
rdpPixmapRec* pDirtyPriv;
|
2012-05-18 05:48:28 +04:00
|
|
|
struct image_data id;
|
2012-03-06 23:49:15 +04:00
|
|
|
|
2012-05-18 05:48:28 +04:00
|
|
|
LLOGLN(10, ("rdpComposite:"));
|
2012-03-06 23:49:15 +04:00
|
|
|
ps = GetPictureScreen(g_pScreen);
|
|
|
|
ps->Composite = g_rdpScreen.Composite;
|
|
|
|
ps->Composite(op, pSrc, pMask, pDst, xSrc, ySrc,
|
|
|
|
xMask, yMask, xDst, yDst, width, height);
|
2012-05-18 05:48:28 +04:00
|
|
|
ps->Composite = rdpComposite;
|
|
|
|
|
2012-03-06 23:49:15 +04:00
|
|
|
p = pDst->pDrawable;
|
2012-05-18 05:48:28 +04:00
|
|
|
|
2012-08-10 09:19:10 +04:00
|
|
|
dirty_type = 0;
|
|
|
|
pDirtyPriv = 0;
|
|
|
|
post_process = 0;
|
|
|
|
reset_surface = 0;
|
2012-05-18 05:48:28 +04:00
|
|
|
got_id = 0;
|
|
|
|
if (p->type == DRAWABLE_PIXMAP)
|
2012-03-06 23:49:15 +04:00
|
|
|
{
|
2012-05-18 05:48:28 +04:00
|
|
|
pDstPixmap = (PixmapPtr)p;
|
|
|
|
pDstPriv = GETPIXPRIV(pDstPixmap);
|
|
|
|
if (XRDP_IS_OS(pDstPriv))
|
2012-03-06 23:49:15 +04:00
|
|
|
{
|
2012-08-10 09:19:10 +04:00
|
|
|
post_process = 1;
|
|
|
|
if (g_do_dirty_os)
|
|
|
|
{
|
|
|
|
LLOGLN(10, ("rdpComposite: gettig dirty"));
|
|
|
|
pDstPriv->is_dirty = 1;
|
|
|
|
dirty_type = g_doing_font ? RDI_IMGLL : RDI_IMGLY;
|
|
|
|
pDirtyPriv = pDstPriv;
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rdpup_switch_os_surface(pDstPriv->rdpindex);
|
|
|
|
reset_surface = 1;
|
|
|
|
rdpup_get_pixmap_image_rect(pDstPixmap, &id);
|
|
|
|
got_id = 1;
|
|
|
|
LLOGLN(10, ("rdpComposite: offscreen"));
|
|
|
|
}
|
2012-05-18 05:48:28 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (p->type == DRAWABLE_WINDOW)
|
|
|
|
{
|
|
|
|
pDstWnd = (WindowPtr)p;
|
|
|
|
if (pDstWnd->viewable)
|
2012-03-06 23:49:15 +04:00
|
|
|
{
|
2012-08-10 09:19:10 +04:00
|
|
|
post_process = 1;
|
2012-05-18 05:48:28 +04:00
|
|
|
rdpup_get_screen_image_rect(&id);
|
|
|
|
got_id = 1;
|
2012-08-10 09:19:10 +04:00
|
|
|
LLOGLN(10, ("rdpComposite: screen"));
|
2012-03-06 23:49:15 +04:00
|
|
|
}
|
|
|
|
}
|
2012-05-18 05:48:28 +04:00
|
|
|
}
|
2012-08-10 09:19:10 +04:00
|
|
|
if (!post_process)
|
2012-05-18 05:48:28 +04:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pDst->clientClipType == CT_REGION)
|
|
|
|
{
|
|
|
|
box.x1 = p->x + xDst;
|
|
|
|
box.y1 = p->y + yDst;
|
|
|
|
box.x2 = box.x1 + width;
|
|
|
|
box.y2 = box.y1 + height;
|
|
|
|
RegionInit(®1, &box, 0);
|
|
|
|
RegionInit(®2, NullBox, 0);
|
|
|
|
RegionCopy(®2, pDst->clientClip);
|
2012-08-10 09:19:10 +04:00
|
|
|
lx = p->x + pDst->clipOrigin.x;
|
|
|
|
ly = p->y + pDst->clipOrigin.y;
|
|
|
|
RegionTranslate(®2, lx, ly);
|
2012-05-18 05:48:28 +04:00
|
|
|
RegionIntersect(®1, ®1, ®2);
|
2012-08-10 09:19:10 +04:00
|
|
|
if (dirty_type != 0)
|
2012-03-06 23:49:15 +04:00
|
|
|
{
|
2012-08-16 02:40:17 +04:00
|
|
|
draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type);
|
2012-08-10 09:19:10 +04:00
|
|
|
}
|
|
|
|
else if (got_id)
|
|
|
|
{
|
|
|
|
num_clips = REGION_NUM_RECTS(®1);
|
|
|
|
if (num_clips > 0)
|
2012-05-18 05:48:28 +04:00
|
|
|
{
|
2012-08-10 09:19:10 +04:00
|
|
|
rdpup_begin_update();
|
|
|
|
for (j = num_clips - 1; j >= 0; j--)
|
|
|
|
{
|
|
|
|
box = REGION_RECTS(®1)[j];
|
|
|
|
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
|
|
|
|
}
|
|
|
|
rdpup_end_update();
|
2012-05-18 05:48:28 +04:00
|
|
|
}
|
2012-03-06 23:49:15 +04:00
|
|
|
}
|
2012-05-18 05:48:28 +04:00
|
|
|
RegionUninit(®1);
|
|
|
|
RegionUninit(®2);
|
2012-03-06 23:49:15 +04:00
|
|
|
}
|
2012-05-18 05:48:28 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
box.x1 = p->x + xDst;
|
|
|
|
box.y1 = p->y + yDst;
|
|
|
|
box.x2 = box.x1 + width;
|
|
|
|
box.y2 = box.y1 + height;
|
2012-08-10 09:19:10 +04:00
|
|
|
if (dirty_type != 0)
|
|
|
|
{
|
|
|
|
RegionInit(®1, &box, 0);
|
2012-08-16 02:40:17 +04:00
|
|
|
draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type);
|
2012-08-10 09:19:10 +04:00
|
|
|
RegionUninit(®1);
|
|
|
|
}
|
|
|
|
else if (got_id)
|
|
|
|
{
|
|
|
|
rdpup_begin_update();
|
|
|
|
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
|
|
|
|
rdpup_end_update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (reset_surface)
|
|
|
|
{
|
|
|
|
rdpup_switch_os_surface(-1);
|
2012-05-18 05:48:28 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
void
|
|
|
|
rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
|
|
|
|
PictFormatPtr maskFormat,
|
|
|
|
INT16 xSrc, INT16 ySrc, int nlists, GlyphListPtr lists,
|
|
|
|
GlyphPtr* glyphs)
|
|
|
|
{
|
|
|
|
PictureScreenPtr ps;
|
|
|
|
int index;
|
|
|
|
|
|
|
|
LLOGLN(10, ("rdpGlyphs:"));
|
|
|
|
LLOGLN(10, ("rdpGlyphs: nlists %d len %d", nlists, lists->len));
|
2012-07-27 08:37:03 +04:00
|
|
|
rdpup_set_hints(1, 1);
|
2012-08-10 09:19:10 +04:00
|
|
|
g_doing_font = 1;
|
2012-05-18 05:48:28 +04:00
|
|
|
for (index = 0; index < lists->len; index++)
|
|
|
|
{
|
|
|
|
LLOGLN(10, (" index %d size %d refcnt %d width %d height %d",
|
2012-05-20 06:25:08 +04:00
|
|
|
index, (int)(glyphs[index]->size), (int)(glyphs[index]->refcnt),
|
2012-05-18 05:48:28 +04:00
|
|
|
glyphs[index]->info.width, glyphs[index]->info.height));
|
|
|
|
}
|
|
|
|
ps = GetPictureScreen(g_pScreen);
|
|
|
|
ps->Glyphs = g_rdpScreen.Glyphs;
|
|
|
|
ps->Glyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc,
|
|
|
|
nlists, lists, glyphs);
|
|
|
|
ps->Glyphs = rdpGlyphs;
|
2012-07-27 08:37:03 +04:00
|
|
|
rdpup_set_hints(0, 1);
|
2012-08-10 09:19:10 +04:00
|
|
|
g_doing_font = 0;
|
2012-05-18 05:48:28 +04:00
|
|
|
LLOGLN(10, ("rdpGlyphs: out"));
|
2012-03-06 23:49:15 +04:00
|
|
|
}
|