void miMarkUnrealizedWindow(WindowPtr pChild, WindowPtr pWin, Bool fromConfigure) { if ((pChild != pWin) || fromConfigure) { REGION_EMPTY(pChild->drawable.pScreen, &pChild->clipList); if (pChild->drawable.pScreen->ClipNotify) (* pChild->drawable.pScreen->ClipNotify)(pChild, 0, 0); REGION_EMPTY(pChild->drawable.pScreen, &pChild->borderClip); } }
/** * Append given rectangle to the client's list of dirty regions. */ void fn_client_add_rect(AIO_SLOT *slot, FB_RECT *rect) { CL_SLOT *cl = (CL_SLOT *)slot; RegionRec add_region; BoxRec add_rect; int stored; int dx, dy; if (!cl->connected || cl->newfbsize_pending) return; /* If the framebuffer geometry has been changed, then we don't care about pending pixel updates any more, because all clients will want to update the whole framebuffer. */ if (g_screen_info.width != cl->fb_width || g_screen_info.height != cl->fb_height) { cl->newfbsize_pending = 1; REGION_EMPTY(&cl->pending_region); REGION_EMPTY(&cl->copy_region); return; } add_rect.x1 = rect->x; add_rect.y1 = rect->y; add_rect.x2 = add_rect.x1 + rect->w; add_rect.y2 = add_rect.y1 + rect->h; REGION_INIT(&add_region, &add_rect, 4); /* FIXME: Currently, CopyRect is stored in copy_region only if there were no other non-CopyRect updates pending for this client. Normally, that's ok, because VNC servers send CopyRect rectangles before non-CopyRect ones, but of course more elegant and efficient handling could be possible to implement here. */ stored = 0; if (rect->enc == RFB_ENCODING_COPYRECT && cl->enc_enable[RFB_ENCODING_COPYRECT] && !REGION_NOTEMPTY(&cl->pending_region)) { dx = rect->x - rect->src_x; dy = rect->y - rect->src_y; if (!REGION_NOTEMPTY(&cl->copy_region) || (dx == cl->copy_dx && dy == cl->copy_dy)) { REGION_UNION(&cl->copy_region, &cl->copy_region, &add_region); cl->copy_dx = dx; cl->copy_dy = dy; stored = 1; } } if (!stored) REGION_UNION(&cl->pending_region, &cl->pending_region, &add_region); REGION_UNINIT(&add_region); }
static void update_screen(struct omap_screen_info *omaps) { BoxPtr tmp; int i; if (region_is_null(omaps)) return; if (!omaps->block_updates) { /* Remove the video region from our active area. */ if (omaps->video_region && REGION_NOTEMPTY(omaps->screen->pScreen, omaps->video_region) && RECT_IN_REGION(omaps->screen->pScreen, omaps->video_region, &omaps->dirty_area)) { REGION_INIT(omaps->screen->pScreen, omaps->tmp_region, &omaps->dirty_area, 1); REGION_SUBTRACT(omaps->screen->pScreen, omaps->tmp_region, omaps->tmp_region, omaps->video_region); tmp = REGION_RECTS(omaps->tmp_region); for (i = 0; i < REGION_NUM_RECTS(omaps->tmp_region); i++, tmp++) push_box(omaps, tmp); REGION_EMPTY(omaps->screen->pScreen, omaps->tmp_region); } else { push_box(omaps, &omaps->dirty_area); } } reset_damage(omaps); }
static int MGASetPortAttributeOverlay( ScrnInfoPtr pScrn, Atom attribute, INT32 value, pointer data ) { MGAPtr pMga = MGAPTR(pScrn); MGAPortPrivPtr pPriv = pMga->portPrivate; CHECK_DMA_QUIESCENT(pMga, pScrn); if(attribute == xvBrightness) { if((value < -128) || (value > 127)) return BadValue; pPriv->brightness = value; OUTREG(MGAREG_BESLUMACTL, ((pPriv->brightness & 0xff) << 16) | (pPriv->contrast & 0xff)); } else if(attribute == xvContrast) { if((value < 0) || (value > 255)) return BadValue; pPriv->contrast = value; OUTREG(MGAREG_BESLUMACTL, ((pPriv->brightness & 0xff) << 16) | (pPriv->contrast & 0xff)); } else if(attribute == xvColorKey) { pPriv->colorKey = value; outMGAdac(0x55, (pPriv->colorKey & pScrn->mask.red) >> pScrn->offset.red); outMGAdac(0x56, (pPriv->colorKey & pScrn->mask.green) >> pScrn->offset.green); outMGAdac(0x57, (pPriv->colorKey & pScrn->mask.blue) >> pScrn->offset.blue); REGION_EMPTY(pScrn->pScreen, &pPriv->clip); } else if(attribute == xvDoubleBuffer) {
static void MGAStopVideo(ScrnInfoPtr pScrn, pointer data, Bool shutdown) { MGAPtr pMga = MGAPTR(pScrn); MGAPortPrivPtr pPriv = pMga->portPrivate; if(pMga->TexturedVideo) return; REGION_EMPTY(pScrn->pScreen, &pPriv->clip); if(shutdown) { if(pPriv->videoStatus & CLIENT_VIDEO_ON) OUTREG(MGAREG_BESCTL, 0); if(pPriv->linear) { xf86FreeOffscreenLinear(pPriv->linear); pPriv->linear = NULL; } pPriv->videoStatus = 0; } else { if(pPriv->videoStatus & CLIENT_VIDEO_ON) { pPriv->videoStatus |= OFF_TIMER; pPriv->offTime = currentTime.milliseconds + OFF_DELAY; } } }
static int sna_video_overlay_stop(ClientPtr client, XvPortPtr port, DrawablePtr draw) { struct sna_video *video = port->devPriv.ptr; struct sna *sna = video->sna; struct drm_intel_overlay_put_image request; DBG(("%s()\n", __FUNCTION__)); REGION_EMPTY(scrn->pScreen, &video->clip); request.flags = 0; (void)drmIoctl(sna->kgem.fd, DRM_IOCTL_I915_OVERLAY_PUT_IMAGE, &request); if (video->bo) kgem_bo_destroy(&sna->kgem, video->bo); video->bo = NULL; sna_video_free_buffers(video); sna_window_set_port((WindowPtr)draw, NULL); return Success; }
static int SIS6326SetPortAttribute(ScrnInfoPtr pScrn, Atom attribute, INT32 value, pointer data) { SISPortPrivPtr pPriv = (SISPortPrivPtr)data; if(attribute == xvBrightness) { if((value < -128) || (value > 127)) return BadValue; pPriv->brightness = value; } else if(attribute == xvContrast) { if((value < 0) || (value > 7)) return BadValue; pPriv->contrast = value; } else if(attribute == xvColorKey) { pPriv->colorKey = value; REGION_EMPTY(pScrn->pScreen, &pPriv->clip); } else if (attribute == xvAutopaintColorKey) { if((value < 0) || (value > 1)) return BadValue; pPriv->autopaintColorKey = value; } else if(attribute == xvDisableGfx) { if((value < 0) || (value > 1)) return BadValue; pPriv->disablegfx = value; } else if (attribute == xvSetDefaults) { SIS6326SetPortDefaults(pScrn, pPriv); } else return BadMatch; return Success; }
static void CHIPSStopVideo(ScrnInfoPtr pScrn, pointer data, Bool shadow) { CHIPSPortPrivPtr pPriv = (CHIPSPortPrivPtr)data; CHIPSPtr cPtr = CHIPSPTR(pScrn); unsigned char mr3c, tmp; REGION_EMPTY(pScrn->pScreen, &pPriv->clip); if (cPtr->Flags & ChipsAccelSupport) CHIPSHiQVSync(pScrn); if(shadow) { if(pPriv->videoStatus & CLIENT_VIDEO_ON) { mr3c = cPtr->readMR(cPtr, 0x3C); cPtr->writeMR(cPtr, 0x3C, (mr3c & 0xFE)); tmp = cPtr->readXR(cPtr, 0xD0); cPtr->writeXR(cPtr, 0xD0, (tmp & 0xf)); } if(pPriv->linear) { xf86FreeOffscreenLinear(pPriv->linear); pPriv->linear = NULL; } pPriv->videoStatus = 0; } else { if(pPriv->videoStatus & CLIENT_VIDEO_ON) { pPriv->videoStatus |= OFF_TIMER; pPriv->offTime = currentTime.milliseconds + OFF_DELAY; cPtr->VideoTimerCallback = CHIPSVideoTimerCallback; } } }
static isc_result_t list_fromwire(isccc_region_t *source, isccc_sexpr_t **listp) { isccc_sexpr_t *list, *value; isc_result_t result; list = NULL; while (!REGION_EMPTY(*source)) { value = NULL; result = value_fromwire(source, &value); if (result != ISC_R_SUCCESS) { isccc_sexpr_free(&list); return (result); } if (isccc_sexpr_addtolist(&list, value) == NULL) { isccc_sexpr_free(&value); isccc_sexpr_free(&list); return (result); } } *listp = list; return (ISC_R_SUCCESS); }
static void _glitz_fbo_attach_notify (void *abstract_drawable, glitz_surface_t *surface) { glitz_fbo_drawable_t *drawable = (glitz_fbo_drawable_t *) abstract_drawable; glitz_texture_t *texture; GLITZ_GL_DRAWABLE (drawable->other); texture = &surface->texture; if (!TEXTURE_ALLOCATED (texture)) { drawable->other->backend->push_current (drawable->other, NULL, GLITZ_ANY_CONTEXT_CURRENT, NULL); glitz_texture_allocate (gl, texture); drawable->other->backend->pop_current (drawable->other); if (!TEXTURE_ALLOCATED (texture)) return; } REGION_EMPTY (&surface->drawable_damage); }
static isc_result_t table_fromwire(isccc_region_t *source, isccc_region_t *secret, isc_uint32_t algorithm, isccc_sexpr_t **alistp) { char key[256]; isc_uint32_t len; isc_result_t result; isccc_sexpr_t *alist, *value; isc_boolean_t first_tag; unsigned char *checksum_rstart; REQUIRE(alistp != NULL && *alistp == NULL); checksum_rstart = NULL; first_tag = ISC_TRUE; alist = isccc_alist_create(); if (alist == NULL) return (ISC_R_NOMEMORY); while (!REGION_EMPTY(*source)) { GET8(len, source->rstart); if (REGION_SIZE(*source) < len) { result = ISC_R_UNEXPECTEDEND; goto bad; } GET_MEM(key, len, source->rstart); key[len] = '\0'; /* Ensure NUL termination. */ value = NULL; result = value_fromwire(source, &value); if (result != ISC_R_SUCCESS) goto bad; if (isccc_alist_define(alist, key, value) == NULL) { result = ISC_R_NOMEMORY; goto bad; } if (first_tag && secret != NULL && strcmp(key, "_auth") == 0) checksum_rstart = source->rstart; first_tag = ISC_FALSE; } if (secret != NULL) { if (checksum_rstart != NULL) result = verify(alist, checksum_rstart, (unsigned int) (source->rend - checksum_rstart), algorithm, secret); else result = ISCCC_R_BADAUTH; } else result = ISC_R_SUCCESS; bad: if (result == ISC_R_SUCCESS) *alistp = alist; else isccc_sexpr_free(&alist); return (result); }
/** * Called by the RFB encoder thread to unlock access to 0th screen_buffer. */ void vncspuUnlockFrameBuffer(void) { CRASSERT(vnc_spu.serverBuffer); /* put server buffer into empty queue */ vnc_spu.serverBuffer->regionSent = GL_TRUE; REGION_EMPTY(&vnc_spu.serverBuffer->dirtyRegion); #if DB crDebug("Putting sent buffer %p into empty queue", (void *) vnc_spu.serverBuffer); #endif EnqueueBuffer(vnc_spu.serverBuffer, &vnc_spu.emptyQueue); vnc_spu.serverBuffer = NULL; }
static Bool KdCreateWindow (WindowPtr pWin) { #ifndef PHOENIX if (!pWin->parent) { KdScreenPriv(pWin->drawable.pScreen); if (!pScreenPriv->enabled) { REGION_EMPTY (pWin->drawable.pScreen, &pWin->borderClip); REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList); } } #endif return fbCreateWindow (pWin); }
static int CHIPSSetPortAttribute( ScrnInfoPtr pScrn, Atom attribute, INT32 value, pointer data ){ CHIPSPortPrivPtr pPriv = (CHIPSPortPrivPtr)data; CHIPSPtr cPtr = CHIPSPTR(pScrn); if (cPtr->Flags & ChipsAccelSupport) CHIPSHiQVSync(pScrn); if(attribute == xvColorKey) { int red, green, blue; pPriv->colorKey = value; switch (pScrn->depth) { case 8: cPtr->writeMR(cPtr, 0x3D, 0x00); cPtr->writeMR(cPtr, 0x3E, 0x00); cPtr->writeMR(cPtr, 0x3F, (pPriv->colorKey & 0xFF)); break; default: red = (pPriv->colorKey & pScrn->mask.red) >> pScrn->offset.red; green = (pPriv->colorKey & pScrn->mask.green) >> pScrn->offset.green; blue = (pPriv->colorKey & pScrn->mask.blue) >> pScrn->offset.blue; switch (pScrn->depth) { case 15: cPtr->writeMR(cPtr, 0x3D, (red << 3)); cPtr->writeMR(cPtr, 0x3E, (green << 3)); cPtr->writeMR(cPtr, 0x3F, (blue << 3)); break; case 16: cPtr->writeMR(cPtr, 0x3D, (red << 3)); cPtr->writeMR(cPtr, 0x3E, (green << 2)); cPtr->writeMR(cPtr, 0x3F, (blue << 3)); break; case 24: cPtr->writeMR(cPtr, 0x3D, red); cPtr->writeMR(cPtr, 0x3E, green); cPtr->writeMR(cPtr, 0x3F, blue); break; } } REGION_EMPTY(pScrn->pScreen, &pPriv->clip); } else return BadMatch;
int ProcXFixesExpandRegion (ClientPtr client) { RegionPtr pSource, pDestination; int ret = Success; REQUEST (xXFixesExpandRegionReq); BoxPtr pTmp; BoxPtr pSrc; int nBoxes; int i; REQUEST_SIZE_MATCH (xXFixesExpandRegionReq); VERIFY_REGION(pSource, stuff->source, client, DixReadAccess); VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess); nBoxes = REGION_NUM_RECTS(pSource); pSrc = REGION_RECTS(pSource); if (nBoxes) { pTmp = xalloc (nBoxes * sizeof (BoxRec)); if (!pTmp) return BadAlloc; for (i = 0; i < nBoxes; i++) { pTmp[i].x1 = pSrc[i].x1 - stuff->left; pTmp[i].x2 = pSrc[i].x2 + stuff->right; pTmp[i].y1 = pSrc[i].y1 - stuff->top; pTmp[i].y2 = pSrc[i].y2 + stuff->bottom; } REGION_EMPTY (pScreen, pDestination); for (i = 0; i < nBoxes; i++) { RegionRec r; REGION_INIT (pScreen, &r, &pTmp[i], 0); REGION_UNION (pScreen, pDestination, pDestination, &r); } xfree(pTmp); } if (ret == Success) ret = client->noClientException; return ret; }
static __inline Bool miClipPictureReg (RegionPtr pRegion, RegionPtr pClip, int dx, int dy) { if (REGION_NUM_RECTS(pRegion) == 1 && REGION_NUM_RECTS(pClip) == 1) { BoxPtr pRbox = REGION_RECTS(pRegion); BoxPtr pCbox = REGION_RECTS(pClip); int v; if (pRbox->x1 < (v = pCbox->x1 + dx)) pRbox->x1 = BOUND(v); if (pRbox->x2 > (v = pCbox->x2 + dx)) pRbox->x2 = BOUND(v); if (pRbox->y1 < (v = pCbox->y1 + dy)) pRbox->y1 = BOUND(v); if (pRbox->y2 > (v = pCbox->y2 + dy)) pRbox->y2 = BOUND(v); if (pRbox->x1 >= pRbox->x2 || pRbox->y1 >= pRbox->y2) { REGION_EMPTY(pScreen, pRegion); } } else { REGION_TRANSLATE(pScreen, pRegion, dx, dy); if (!REGION_INTERSECT (pScreen, pRegion, pRegion, pClip)) return FALSE; REGION_TRANSLATE(pScreen, pRegion, -dx, -dy); } return TRUE; }
Bool xglSyncSurface (DrawablePtr pDrawable) { RegionPtr pRegion; XGL_DRAWABLE_PIXMAP (pDrawable); XGL_PIXMAP_PRIV (pPixmap); if (!pPixmapPriv->surface) { if (!xglCreatePixmapSurface (pPixmap)) return FALSE; } pRegion = DamageRegion (pPixmapPriv->pDamage); if (REGION_NOTEMPTY (pDrawable->pScreen, pRegion)) { glitz_pixel_format_t format; BoxPtr pBox; BoxPtr pExt; int nBox; xglUnmapPixmapBits (pPixmap); nBox = REGION_NUM_RECTS (pRegion); pBox = REGION_RECTS (pRegion); pExt = REGION_EXTENTS (pDrawable->pScreen, pRegion); format.fourcc = pPixmapPriv->pVisual->format.surface->color.fourcc; format.masks = pPixmapPriv->pVisual->pPixel->masks; format.xoffset = pExt->x1; if (pPixmapPriv->stride < 0) { format.skip_lines = pPixmap->drawable.height - pExt->y2; format.bytes_per_line = -pPixmapPriv->stride; format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP; } else { format.skip_lines = pExt->y1; format.bytes_per_line = pPixmapPriv->stride; format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN; } glitz_surface_set_clip_region (pPixmapPriv->surface, 0, 0, (glitz_box_t *) pBox, nBox); glitz_set_pixels (pPixmapPriv->surface, pExt->x1, pExt->y1, pExt->x2 - pExt->x1, pExt->y2 - pExt->y1, &format, pPixmapPriv->buffer); glitz_surface_set_clip_region (pPixmapPriv->surface, 0, 0, NULL, 0); REGION_EMPTY (pDrawable->pScreen, pRegion); } return TRUE; }
/** * Handle an incoming rfbFramebufferUpdateRequest message. * Determine the dirty regions and send pixel rect data to the client. */ static void rf_client_updatereq(void) { CL_SLOT *cl = (CL_SLOT *)cur_slot; RegionRec tmp_region; BoxRec rect; /*crDebug("Got Update request from %s", cur_slot->name);*/ #ifdef NETLOGGER if (vnc_spu.netlogger_url) { cl->serial_number++; NL_info("vncspu", "spu.fbrequest.receive", "NODE=s NUMBER=i", vnc_spu.hostname, cl->serial_number); } #endif /* the requested region of interest */ rect.x1 = buf_get_CARD16(&cur_slot->readbuf[1]); rect.y1 = buf_get_CARD16(&cur_slot->readbuf[3]); rect.x2 = rect.x1 + buf_get_CARD16(&cur_slot->readbuf[5]); rect.y2 = rect.y1 + buf_get_CARD16(&cur_slot->readbuf[7]); /* Make sure the rectangle bounds fit the framebuffer. */ if (rect.x1 > cl->fb_width) rect.x1 = cl->fb_width; if (rect.y1 > cl->fb_height) rect.y1 = cl->fb_height; if (rect.x2 > cl->fb_width) rect.x2 = cl->fb_width; if (rect.y2 > cl->fb_height) rect.y2 = cl->fb_height; cl->update_rect = rect; cl->update_requested = 1; cl->num_update_requests++; if (!cur_slot->readbuf[0]) { log_write(LL_DEBUG, "Received framebuffer update request (full) from %s", cur_slot->name); if (!cl->newfbsize_pending) { REGION_INIT(&tmp_region, &rect, 1); #if 0 /* Disabling this code prevents the region from outside the GL * window (garbage) from being sent to the viewer. */ REGION_UNION(&cl->pending_region, &cl->pending_region, &tmp_region); #endif REGION_UNION(&cl->pending_region, &cl->pending_region, &cl->copy_region); REGION_EMPTY(&cl->copy_region); REGION_UNINIT(&tmp_region); } } else { log_write(LL_DEBUG, "Received framebuffer update request from %s", cur_slot->name); } if (!cl->update_in_progress) { int k = (cl->newfbsize_pending || cl->new_cliprects || REGION_NOTEMPTY(&cl->copy_region) || vncspuWaitDirtyRects(&cl->pending_region, &cl->update_rect, cl->serial_number)); if (k) { send_update(); } } aio_setread(rf_client_msg, NULL, 1); }
static void send_update(void) { CL_SLOT *cl = (CL_SLOT *)cur_slot; BoxRec fb_rect; RegionRec fb_region, clip_region, outer_region; CARD8 msg_hdr[4] = { 0, 0, 0, 1 }; CARD8 rect_hdr[12]; int num_copy_rects, num_pending_rects, num_all_rects; int raw_bytes = 0, hextile_bytes = 0; int i, idx, rev_order; static int counter = 0; #ifdef NETLOGGER aio_set_serial_number(&cl->s, cl->serial_number); #endif counter++; vncspuLog(1, "Begin send update %d", counter); CRASSERT(vnc_spu.serverBuffer); /*crDebug("Enter send_update to %s", cur_slot->name);*/ /* check if clipping has changed since we got the pixels and update * the pending region if needed. */ if (NewClip) { /*crDebug("Getting updated cliprects");*/ vncspuGetScreenRects(&cl->pending_region); num_pending_rects = REGION_NUM_RECTS(&cl->pending_region); /*crDebug("Now, %d rects", num_pending_rects);*/ if (num_pending_rects == 0 && cl->enable_frame_sync) { /* always need to send _something_ for framesync to work */ BoxRec b; b.x1 = 0; b.y1 = 0; b.x2 = 1; b.y2 = 1; REGION_UNINIT(&cl->pending_region); REGION_INIT(&cl->pending_region, &b, 1); } NewClip = 0; } /*PrintRegion("Sending", &cl->pending_region);*/ /* Process framebuffer size change. */ if (cl->newfbsize_pending) { /* Update framebuffer size, clear newfbsize_pending flag. */ cl->fb_width = g_screen_info.width; cl->fb_height = g_screen_info.height; cl->newfbsize_pending = 0; log_write(LL_DEBUG, "Applying new framebuffer size (%dx%d) to %s", (int)cl->fb_width, (int)cl->fb_height, cur_slot->name); /* In any case, mark all the framebuffer contents as changed. */ fb_rect.x1 = 0; fb_rect.y1 = 0; fb_rect.x2 = cl->fb_width; fb_rect.y2 = cl->fb_height; REGION_INIT(&fb_region, &fb_rect, 1); REGION_COPY(&cl->pending_region, &fb_region); REGION_UNINIT(&fb_region); REGION_EMPTY(&cl->copy_region); /* If NewFBSize is supported by the client, send only NewFBSize pseudo-rectangle, pixel data will be sent in the next update. */ if (cl->enable_newfbsize) { send_newfbsize(); vncspuUnlockFrameBuffer(); return; } } else { /* Exclude CopyRect areas covered by pending_region. */ REGION_SUBTRACT(&cl->copy_region, &cl->copy_region, &cl->pending_region); } #if 00 if (cl->enable_cliprects_enc && cl->new_cliprects) { send_new_cliprects(); vncspuUnlockFrameBuffer(); cl->new_cliprects = 0; return; } #endif /* Clip regions to the rectangle requested by the client. */ REGION_INIT(&clip_region, &cl->update_rect, 1); REGION_INTERSECT(&cl->pending_region, &cl->pending_region, &clip_region); if (REGION_NOTEMPTY(&cl->copy_region)) { REGION_INTERSECT(&cl->copy_region, &cl->copy_region, &clip_region); REGION_INIT(&outer_region, NullBox, 8); REGION_COPY(&outer_region, &cl->copy_region); REGION_TRANSLATE(&clip_region, cl->copy_dx, cl->copy_dy); REGION_INTERSECT(&cl->copy_region, &cl->copy_region, &clip_region); REGION_SUBTRACT(&outer_region, &outer_region, &cl->copy_region); REGION_UNION(&cl->pending_region, &cl->pending_region, &outer_region); REGION_UNINIT(&outer_region); } REGION_UNINIT(&clip_region); /* Reduce the number of rectangles if possible. */ if (cl->enc_prefer == RFB_ENCODING_TIGHT && cl->enable_lastrect) { region_pack(&cl->pending_region, 32); } else { region_pack(&cl->pending_region, 12); } /* Compute the number of rectangles in regions. */ num_pending_rects = REGION_NUM_RECTS(&cl->pending_region); num_copy_rects = REGION_NUM_RECTS(&cl->copy_region); num_all_rects = num_pending_rects + num_copy_rects; if (num_all_rects == 0) { vncspuUnlockFrameBuffer(); return; } log_write(LL_DEBUG, "Sending framebuffer update (min %d rects) to %s", num_all_rects, cur_slot->name); /* Prepare and send FramebufferUpdate message header. */ /* FIXME: Enable Tight encoding even if LastRect is not supported. */ /* FIXME: Do not send LastRect if all the rectangles are CopyRect. */ if (cl->enc_prefer == RFB_ENCODING_TIGHT && cl->enable_lastrect) { buf_put_CARD16(&msg_hdr[2], 0xFFFF); } else { buf_put_CARD16(&msg_hdr[2], num_all_rects); } aio_write(NULL, msg_hdr, 4); /* Determine the order in which CopyRect rectangles should be sent. */ rev_order = (cl->copy_dy > 0 || (cl->copy_dy == 0 && cl->copy_dx > 0)); /* For each CopyRect rectangle: */ for (i = 0; i < num_copy_rects; i++) { FB_RECT rect; AIO_BLOCK *block; idx = (rev_order) ? num_copy_rects - i - 1 : i; rect.x = REGION_RECTS(&cl->copy_region)[idx].x1; rect.y = REGION_RECTS(&cl->copy_region)[idx].y1; rect.w = REGION_RECTS(&cl->copy_region)[idx].x2 - rect.x; rect.h = REGION_RECTS(&cl->copy_region)[idx].y2 - rect.y; rect.src_x = rect.x - cl->copy_dx; rect.src_y = rect.y - cl->copy_dy; rect.enc = RFB_ENCODING_COPYRECT; log_write(LL_DEBUG, "Sending CopyRect rectangle %dx%d at %d,%d to %s", (int)rect.w, (int)rect.h, (int)rect.x, (int)rect.y, cur_slot->name); /* Prepare the CopyRect rectangle. */ block = rfb_encode_copyrect_block(cl, &rect); /* Send the rectangle. FIXME: Check for block == NULL? */ aio_write_nocopy(NULL, block); } if (cl->enc_prefer == RFB_ENCODING_TIGHT) { /* needed for successful caching of zlib-compressed data (tight) */ rfb_reset_tight_encoder(cl); } if (num_pending_rects) { /* Lock around fb access so other thread doesn't change contents while * we're encoding. */ #ifdef NETLOGGER if (vnc_spu.netlogger_url) { NL_info("vncspu", "spu.encode.begin", "NODE=s NUMBER=i", vnc_spu.hostname, cl->serial_number); } #endif /* For each of the usual pending rectangles: */ for (i = 0; i < num_pending_rects; i++) { FB_RECT rect; AIO_BLOCK *block; /* crDebug("sending rect %d of %d: %d, %d .. %d, %d", i, num_pending_rects, REGION_RECTS(&cl->pending_region)[i].x1, REGION_RECTS(&cl->pending_region)[i].y1, REGION_RECTS(&cl->pending_region)[i].x2, REGION_RECTS(&cl->pending_region)[i].y2); */ rect.x = REGION_RECTS(&cl->pending_region)[i].x1; rect.y = REGION_RECTS(&cl->pending_region)[i].y1; rect.w = REGION_RECTS(&cl->pending_region)[i].x2 - rect.x; rect.h = REGION_RECTS(&cl->pending_region)[i].y2 - rect.y; log_write(LL_DEBUG, "Sending rectangle %dx%d at %d,%d to %s enc 0x%x", (int)rect.w, (int)rect.h, (int)rect.x, (int)rect.y, cur_slot->name, cl->enc_prefer); if (cl->enc_prefer == RFB_ENCODING_TIGHT && cl->enable_lastrect) { /* Use Tight encoding */ rect.enc = RFB_ENCODING_TIGHT; /* lock to prevent glReadPixels in other thread changing data */ rfb_encode_tight(cl, &rect); continue; /* Important! */ } else if (cl->enc_prefer == RFB_ENCODING_RAW24) { rect.enc = RFB_ENCODING_RAW24; block = rfb_encode_raw24_block(cl, &rect); } else if ( cl->enc_prefer != RFB_ENCODING_RAW && cl->enc_enable[RFB_ENCODING_HEXTILE] ) { /* Use Hextile encoding */ rect.enc = RFB_ENCODING_HEXTILE; block = rfb_encode_hextile_block(cl, &rect); if (block != NULL) { hextile_bytes += block->data_size; raw_bytes += rect.w * rect.h * (cl->format.bits_pixel / 8); } } else { /* Use Raw encoding */ rect.enc = RFB_ENCODING_RAW; if (vnc_spu.half_rez) { block = rfb_encode_raw_block_halfrez(cl, &rect); } else { block = rfb_encode_raw_block(cl, &rect); } } /* Send the rectangle. FIXME: Check for block == NULL? */ aio_write_nocopy(NULL, block); } } /* if num_pending_rects */ REGION_EMPTY(&cl->pending_region); REGION_EMPTY(&cl->copy_region); /* Send LastRect marker. */ if (cl->enc_prefer == RFB_ENCODING_TIGHT && cl->enable_lastrect) { FB_RECT rect; rect.x = rect.y = rect.w = rect.h = 0; rect.enc = RFB_ENCODING_LASTRECT; put_rect_header(rect_hdr, &rect); aio_write(NULL, rect_hdr, 12); } /* Set the last block's callback function */ /* All prev blocks had NULL callbacks */ assert(cur_slot->outqueue_last); if (cur_slot->outqueue_last) { cur_slot->outqueue_last->func = wf_client_update_finished; } /* Something has been queued for sending. */ cl->update_in_progress = 1; cl->update_requested = 0; #ifdef NETLOGGER if (vnc_spu.netlogger_url) { NL_info("vncspu", "spu.encode.end", "NODE=s NUMBER=i", vnc_spu.hostname, cl->serial_number); } aio_set_serial_number(&cl->s, 0); #endif vncspuUnlockFrameBuffer(); /* encoder done with buffer */ /*crDebug("Leave send_update");*/ vncspuLog(1, "End send update %d", counter); }
Bool miComputeCompositeRegion (RegionPtr pRegion, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height) { int v; pRegion->extents.x1 = xDst; v = xDst + width; pRegion->extents.x2 = BOUND(v); pRegion->extents.y1 = yDst; v = yDst + height; pRegion->extents.y2 = BOUND(v); pRegion->data = 0; /* Check for empty operation */ if (pRegion->extents.x1 >= pRegion->extents.x2 || pRegion->extents.y1 >= pRegion->extents.y2) { REGION_EMPTY (pDst->pDrawable->pScreen, pRegion); return TRUE; } /* clip against src */ if (!miClipPictureSrc (pRegion, pSrc, xDst - xSrc, yDst - ySrc)) { REGION_UNINIT (pScreen, pRegion); return FALSE; } if (pSrc->alphaMap) { if (!miClipPictureSrc (pRegion, pSrc->alphaMap, xDst - (xSrc + pSrc->alphaOrigin.x), yDst - (ySrc + pSrc->alphaOrigin.y))) { REGION_UNINIT (pScreen, pRegion); return FALSE; } } /* clip against mask */ if (pMask) { if (!miClipPictureSrc (pRegion, pMask, xDst - xMask, yDst - yMask)) { REGION_UNINIT (pScreen, pRegion); return FALSE; } if (pMask->alphaMap) { if (!miClipPictureSrc (pRegion, pMask->alphaMap, xDst - (xMask + pMask->alphaOrigin.x), yDst - (yMask + pMask->alphaOrigin.y))) { REGION_UNINIT (pScreen, pRegion); return FALSE; } } } if (!miClipPictureReg (pRegion, pDst->pCompositeClip, 0, 0)) { REGION_UNINIT (pScreen, pRegion); return FALSE; } if (pDst->alphaMap) { if (!miClipPictureReg (pRegion, pDst->alphaMap->pCompositeClip, -pDst->alphaOrigin.x, -pDst->alphaOrigin.y)) { REGION_UNINIT (pScreen, pRegion); return FALSE; } } return TRUE; }
/** * Get current clip rects intersected with dirty regions for whole screen. */ void vncspuGetScreenRects(RegionPtr reg) { REGION_EMPTY(reg); crHashtableWalk(vnc_spu.windowTable, WindowDirtyUnionCB, reg); }
/* *----------------------------------------------------------------------- * RootlessComputeClips -- * Recompute the clipList, borderClip, exposed and borderExposed * regions for pParent and its children. Only viewable windows are * taken into account. * * Results: * None. * * Side Effects: * clipList, borderClip, exposed and borderExposed are altered. * A VisibilityNotify event may be generated on the parent window. * *----------------------------------------------------------------------- */ static void RootlessComputeClips (WindowPtr pParent, ScreenPtr pScreen, RegionPtr universe, VTKind kind, RegionPtr exposed) { int dx, dy; RegionRec childUniverse; register WindowPtr pChild; int oldVis, newVis; BoxRec borderSize; RegionRec childUnion; Bool overlap; RegionPtr borderVisible; Bool resized; /* * Figure out the new visibility of this window. * The extent of the universe should be the same as the extent of * the borderSize region. If the window is unobscured, this rectangle * will be completely inside the universe (the universe will cover it * completely). If the window is completely obscured, none of the * universe will cover the rectangle. */ borderSize.x1 = pParent->drawable.x - wBorderWidth(pParent); borderSize.y1 = pParent->drawable.y - wBorderWidth(pParent); dx = (int) pParent->drawable.x + (int) pParent->drawable.width + wBorderWidth(pParent); if (dx > 32767) dx = 32767; borderSize.x2 = dx; dy = (int) pParent->drawable.y + (int) pParent->drawable.height + wBorderWidth(pParent); if (dy > 32767) dy = 32767; borderSize.y2 = dy; oldVis = pParent->visibility; switch (RECT_IN_REGION( pScreen, universe, &borderSize)) { case rgnIN: newVis = VisibilityUnobscured; break; case rgnPART: newVis = VisibilityPartiallyObscured; { RegionPtr pBounding; if ((pBounding = wBoundingShape (pParent))) { switch (RootlessShapedWindowIn (pScreen, universe, pBounding, &borderSize, pParent->drawable.x, pParent->drawable.y)) { case rgnIN: newVis = VisibilityUnobscured; break; case rgnOUT: newVis = VisibilityFullyObscured; break; } } } break; default: newVis = VisibilityFullyObscured; break; } pParent->visibility = newVis; if (oldVis != newVis && ((pParent->eventMask | wOtherEventMasks(pParent)) & VisibilityChangeMask)) SendVisibilityNotify(pParent); dx = pParent->drawable.x - pParent->valdata->before.oldAbsCorner.x; dy = pParent->drawable.y - pParent->valdata->before.oldAbsCorner.y; /* * avoid computations when dealing with simple operations */ switch (kind) { case VTMap: case VTStack: case VTUnmap: break; case VTMove: if ((oldVis == newVis) && ((oldVis == VisibilityFullyObscured) || (oldVis == VisibilityUnobscured))) { pChild = pParent; while (1) { if (pChild->viewable) { if (pChild->visibility != VisibilityFullyObscured) { REGION_TRANSLATE( pScreen, &pChild->borderClip, dx, dy); REGION_TRANSLATE( pScreen, &pChild->clipList, dx, dy); pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER; if (pScreen->ClipNotify) (* pScreen->ClipNotify) (pChild, dx, dy); } if (pChild->valdata) { REGION_NULL(pScreen, &pChild->valdata->after.borderExposed); if (HasParentRelativeBorder(pChild)) { REGION_SUBTRACT(pScreen, &pChild->valdata->after.borderExposed, &pChild->borderClip, &pChild->winSize); } REGION_NULL(pScreen, &pChild->valdata->after.exposed); } if (pChild->firstChild) { pChild = pChild->firstChild; continue; } } while (!pChild->nextSib && (pChild != pParent)) pChild = pChild->parent; if (pChild == pParent) break; pChild = pChild->nextSib; } return; } /* fall through */ default: /* * To calculate exposures correctly, we have to translate the old * borderClip and clipList regions to the window's new location so there * is a correspondence between pieces of the new and old clipping regions. */ if (dx || dy) { /* * We translate the old clipList because that will be exposed or copied * if gravity is right. */ REGION_TRANSLATE( pScreen, &pParent->borderClip, dx, dy); REGION_TRANSLATE( pScreen, &pParent->clipList, dx, dy); } break; case VTBroken: REGION_EMPTY (pScreen, &pParent->borderClip); REGION_EMPTY (pScreen, &pParent->clipList); break; } borderVisible = pParent->valdata->before.borderVisible; resized = pParent->valdata->before.resized; REGION_NULL(pScreen, &pParent->valdata->after.borderExposed); REGION_NULL(pScreen, &pParent->valdata->after.exposed); /* * Since the borderClip must not be clipped by the children, we do * the border exposure first... * * 'universe' is the window's borderClip. To figure the exposures, remove * the area that used to be exposed from the new. * This leaves a region of pieces that weren't exposed before. */ if (HasBorder (pParent)) { if (borderVisible) { /* * when the border changes shape, the old visible portions * of the border will be saved by DIX in borderVisible -- * use that region and destroy it */ REGION_SUBTRACT( pScreen, exposed, universe, borderVisible); REGION_DESTROY( pScreen, borderVisible); } else { REGION_SUBTRACT( pScreen, exposed, universe, &pParent->borderClip); } if (HasParentRelativeBorder(pParent) && (dx || dy)) { REGION_SUBTRACT( pScreen, &pParent->valdata->after.borderExposed, universe, &pParent->winSize); } else { REGION_SUBTRACT( pScreen, &pParent->valdata->after.borderExposed, exposed, &pParent->winSize); } REGION_COPY( pScreen, &pParent->borderClip, universe); /* * To get the right clipList for the parent, and to make doubly sure * that no child overlaps the parent's border, we remove the parent's * border from the universe before proceeding. */ REGION_INTERSECT( pScreen, universe, universe, &pParent->winSize); } else REGION_COPY( pScreen, &pParent->borderClip, universe); if ((pChild = pParent->firstChild) && pParent->mapped) { REGION_NULL(pScreen, &childUniverse); REGION_NULL(pScreen, &childUnion); if ((pChild->drawable.y < pParent->lastChild->drawable.y) || ((pChild->drawable.y == pParent->lastChild->drawable.y) && (pChild->drawable.x < pParent->lastChild->drawable.x))) { for (; pChild; pChild = pChild->nextSib) { if (pChild->viewable) REGION_APPEND( pScreen, &childUnion, &pChild->borderSize); } } else { for (pChild = pParent->lastChild; pChild; pChild = pChild->prevSib) { if (pChild->viewable) REGION_APPEND( pScreen, &childUnion, &pChild->borderSize); } } REGION_VALIDATE( pScreen, &childUnion, &overlap); for (pChild = pParent->firstChild; pChild; pChild = pChild->nextSib) { if (pChild->viewable) { /* * If the child is viewable, we want to remove its extents * from the current universe, but we only re-clip it if * it's been marked. */ if (pChild->valdata) { /* * Figure out the new universe from the child's * perspective and recurse. */ REGION_INTERSECT( pScreen, &childUniverse, universe, &pChild->borderSize); RootlessComputeClips (pChild, pScreen, &childUniverse, kind, exposed); } /* * Once the child has been processed, we remove its extents * from the current universe, thus denying its space to any * other sibling. */ if (overlap) REGION_SUBTRACT( pScreen, universe, universe, &pChild->borderSize); } } if (!overlap) REGION_SUBTRACT( pScreen, universe, universe, &childUnion); REGION_UNINIT( pScreen, &childUnion); REGION_UNINIT( pScreen, &childUniverse); } /* if any children */ /* * 'universe' now contains the new clipList for the parent window. * * To figure the exposure of the window we subtract the old clip from the * new, just as for the border. */ if (oldVis == VisibilityFullyObscured || oldVis == VisibilityNotViewable) { REGION_COPY( pScreen, &pParent->valdata->after.exposed, universe); } else if (newVis != VisibilityFullyObscured && newVis != VisibilityNotViewable) { REGION_SUBTRACT( pScreen, &pParent->valdata->after.exposed, universe, &pParent->clipList); } /* * One last thing: backing storage. We have to try to save what parts of * the window are about to be obscured. We can just subtract the universe * from the old clipList and get the areas that were in the old but aren't * in the new and, hence, are about to be obscured. */ if (pParent->backStorage && !resized) { REGION_SUBTRACT( pScreen, exposed, &pParent->clipList, universe); (* pScreen->SaveDoomedAreas)(pParent, exposed, dx, dy); } /* HACK ALERT - copying contents of regions, instead of regions */ { RegionRec tmp; tmp = pParent->clipList; pParent->clipList = *universe; *universe = tmp; } #ifdef NOTDEF REGION_COPY( pScreen, &pParent->clipList, universe); #endif pParent->drawable.serialNumber = NEXT_SERIAL_NUMBER; if (pScreen->ClipNotify) (* pScreen->ClipNotify) (pParent, dx, dy); }
// fixme this is ugly // Xprint/ValTree.c doesn't work, but maybe that method can? int RootlessMiValidateTree (WindowPtr pRoot, /* Parent to validate */ WindowPtr pChild, /* First child of pRoot that was * affected */ VTKind kind /* What kind of configuration caused call */) { RegionRec childClip; /* The new borderClip for the current * child */ RegionRec exposed; /* For intermediate calculations */ register ScreenPtr pScreen; register WindowPtr pWin; pScreen = pRoot->drawable.pScreen; if (pChild == NullWindow) pChild = pRoot->firstChild; REGION_NULL(pScreen, &childClip); REGION_NULL(pScreen, &exposed); if (REGION_BROKEN (pScreen, &pRoot->clipList) && !REGION_BROKEN (pScreen, &pRoot->borderClip)) { // fixme this might not work, but hopefully doesn't happen anyway. kind = VTBroken; REGION_EMPTY (pScreen, &pRoot->clipList); ErrorF("ValidateTree: BUSTED!\n"); } /* * Recursively compute the clips for all children of the root. * They don't clip against each other or the root itself, so * childClip is always reset to that child's size. */ for (pWin = pChild; pWin != NullWindow; pWin = pWin->nextSib) { if (pWin->viewable) { if (pWin->valdata) { REGION_COPY( pScreen, &childClip, &pWin->borderSize); RootlessComputeClips (pWin, pScreen, &childClip, kind, &exposed); } else if (pWin->visibility == VisibilityNotViewable) { RootlessTreeObscured(pWin); } } else { if (pWin->valdata) { REGION_EMPTY( pScreen, &pWin->clipList); if (pScreen->ClipNotify) (* pScreen->ClipNotify) (pWin, 0, 0); REGION_EMPTY( pScreen, &pWin->borderClip); pWin->valdata = (ValidatePtr)NULL; } } } REGION_UNINIT(pScreen, &childClip); /* The root is never clipped by its children, so nothing on the root is ever exposed by moving or mapping its children. */ REGION_NULL(pScreen, &pRoot->valdata->after.exposed); REGION_NULL(pScreen, &pRoot->valdata->after.borderExposed); return 1; }
static void xf86SetRootClip (ScreenPtr pScreen, Bool enable) { #if XORG < 19 WindowPtr pWin = WindowTable[pScreen->myNum]; #else WindowPtr pWin = pScreen->root; #endif WindowPtr pChild; Bool WasViewable = (Bool)(pWin->viewable); Bool anyMarked = FALSE; #if XORG < 110 RegionPtr pOldClip = NULL, bsExposed; #ifdef DO_SAVE_UNDERS Bool dosave = FALSE; #endif #endif WindowPtr pLayerWin; BoxRec box; if (WasViewable) { for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) { (void) (*pScreen->MarkOverlappedWindows)(pChild, pChild, &pLayerWin); } (*pScreen->MarkWindow) (pWin); anyMarked = TRUE; if (pWin->valdata) { if (HasBorder (pWin)) { RegionPtr borderVisible; borderVisible = REGION_CREATE(pScreen, NullBox, 1); REGION_SUBTRACT(pScreen, borderVisible, &pWin->borderClip, &pWin->winSize); pWin->valdata->before.borderVisible = borderVisible; } pWin->valdata->before.resized = TRUE; } } /* * Use REGION_BREAK to avoid optimizations in ValidateTree * that assume the root borderClip can't change well, normally * it doesn't...) */ if (enable) { box.x1 = 0; 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); if (WasViewable) REGION_RESET(pScreen, &pWin->borderClip, &box); pWin->drawable.width = pScreen->width; pWin->drawable.height = pScreen->height; REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList); } else { REGION_EMPTY(pScreen, &pWin->borderClip); REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList); } ResizeChildrenWinSize (pWin, 0, 0, 0, 0); if (WasViewable) { #if XORG < 110 if (pWin->backStorage) { pOldClip = REGION_CREATE(pScreen, NullBox, 1); REGION_COPY(pScreen, pOldClip, &pWin->clipList); } #endif if (pWin->firstChild) { anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin->firstChild, pWin->firstChild, (WindowPtr *)NULL); } else { (*pScreen->MarkWindow) (pWin); anyMarked = TRUE; } #if XORG < 110 && defined(DO_SAVE_UNDERS) if (DO_SAVE_UNDERS(pWin)) { dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pLayerWin); } #endif /* DO_SAVE_UNDERS */ if (anyMarked) (*pScreen->ValidateTree)(pWin, NullWindow, VTOther); } #if XORG < 110 if (pWin->backStorage && ((pWin->backingStore == Always) || WasViewable)) { if (!WasViewable) pOldClip = &pWin->clipList; /* a convenient empty region */ bsExposed = (*pScreen->TranslateBackingStore) (pWin, 0, 0, pOldClip, pWin->drawable.x, pWin->drawable.y); if (WasViewable) REGION_DESTROY(pScreen, pOldClip); if (bsExposed) { RegionPtr valExposed = NullRegion; if (pWin->valdata) valExposed = &pWin->valdata->after.exposed; (*pScreen->WindowExposures) (pWin, valExposed, bsExposed); if (valExposed) REGION_EMPTY(pScreen, valExposed); REGION_DESTROY(pScreen, bsExposed); } } #endif if (WasViewable) { if (anyMarked) (*pScreen->HandleExposures)(pWin); #if XORG < 110 && defined(DO_SAVE_UNDERS) if (dosave) (*pScreen->PostChangeSaveUnder)(pLayerWin, pLayerWin); #endif /* DO_SAVE_UNDERS */ if (anyMarked && pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pWin, NullWindow, VTOther); } if (pWin->realized) WindowsRestructured (); FlushAllOutput (); }
static void rf_client_encodings_data(void) { CL_SLOT *cl = (CL_SLOT *)cur_slot; int i; int preferred_enc_set = 0; CARD32 enc; /* Reset encoding list (always enable raw encoding) */ cl->enc_enable[RFB_ENCODING_RAW] = 1; cl->enc_prefer = RFB_ENCODING_RAW; cl->compress_level = -1; cl->jpeg_quality = -1; cl->enable_lastrect = 0; cl->enable_newfbsize = 0; cl->enable_cliprects_enc = 0; cl->enable_frame_sync = 0; for (i = 1; i < NUM_ENCODINGS; i++) cl->enc_enable[i] = 0; /* Read and store encoding list supplied by the client */ for (i = 0; i < (int)cl->temp_count; i++) { enc = buf_get_CARD32(&cur_slot->readbuf[i * sizeof(CARD32)]); if (!preferred_enc_set) { if ( enc == RFB_ENCODING_RAW || enc == RFB_ENCODING_HEXTILE || enc == RFB_ENCODING_RAW24 || enc == RFB_ENCODING_TIGHT ) { cl->enc_prefer = enc; preferred_enc_set = 1; } } if (enc >= 0 && enc < NUM_ENCODINGS) { cl->enc_enable[enc] = 1; } else if (enc >= RFB_ENCODING_COMPESSLEVEL0 && enc <= RFB_ENCODING_COMPESSLEVEL9 && cl->compress_level == -1) { cl->compress_level = (int)(enc - RFB_ENCODING_COMPESSLEVEL0); log_write(LL_DETAIL, "Compression level %d requested by client %s", cl->compress_level, cur_slot->name); } else if (enc >= RFB_ENCODING_QUALITYLEVEL0 && enc <= RFB_ENCODING_QUALITYLEVEL9 && cl->jpeg_quality == -1) { cl->jpeg_quality = (int)(enc - RFB_ENCODING_QUALITYLEVEL0); log_write(LL_DETAIL, "JPEG quality level %d requested by client %s", cl->jpeg_quality, cur_slot->name); } else if (enc == RFB_ENCODING_LASTRECT) { log_write(LL_DETAIL, "Client %s supports LastRect markers", cur_slot->name); cl->enable_lastrect = 1; } else if (enc == RFB_ENCODING_NEWFBSIZE) { cl->enable_newfbsize = 1; log_write(LL_DETAIL, "Client %s supports desktop geometry changes", cur_slot->name); } else if (enc == RFB_ENCODING_CLIPRECTS) { cl->enable_cliprects_enc = 1; log_write(LL_DETAIL, "Client %s supports cliprects", cur_slot->name); } else if (enc == RFB_ENCODING_HALF_REZ) { vnc_spu.half_rez = 1; log_write(LL_DETAIL, "Client %s supports half rez", cur_slot->name); } else if (enc == RFB_ENCODING_FRAME_SYNC) { cl->enable_frame_sync = 1; vnc_spu.frame_drop = 0; /* can't drop frames if trying to sync! */ crDebug("Frame sync requested by client, disabling frame_drop"); log_write(LL_DETAIL, "Client %s supports frame sync encoding", cur_slot->name); } } if (cl->compress_level < 0) cl->compress_level = 6; /* default compression level */ /* CopyRect was pending but the client does not want it any more. */ if (!cl->enc_enable[RFB_ENCODING_COPYRECT] && REGION_NOTEMPTY(&cl->copy_region)) { REGION_UNION(&cl->pending_region, &cl->pending_region, &cl->copy_region); REGION_EMPTY(&cl->copy_region); } crDebug("In rf_client_encodings_data(), cl->enc_prefer=0x%x pixel_size=%d", cl->enc_prefer, vnc_spu.pixel_size); if (cl->enc_prefer == RFB_ENCODING_RAW24) { if (vnc_spu.pixel_size == 0 || vnc_spu.pixel_size == 24) { /* not set, or already 24bpp */ vnc_spu.pixel_size = 24; log_write(LL_DETAIL, "Using Raw24 encoding for client %s", cur_slot->name); } else if (vnc_spu.pixel_size == 32) { /* revert to regular 32bpp raw */ cl->enc_prefer = RFB_ENCODING_RAW; log_write(LL_DETAIL, "Using Raw (32) encoding for client %s", cur_slot->name); } } else { vnc_spu.pixel_size = 32; } if (cl->enc_prefer == RFB_ENCODING_TIGHT) if (cl->jpeg_quality < 0) cl->jpeg_quality = 6; /* default quality */ log_write(LL_DETAIL, "Using encoding %s (0x%x)", encoding_string(cl->enc_prefer), cl->enc_prefer); crDebug("VNC SPU: Using %s encoding (0x%x) for new client", encoding_string(cl->enc_prefer), cl->enc_prefer); if (cl->enc_prefer == RFB_ENCODING_TIGHT) { crDebug("VNC SPU: Tight jpeg quality level %d, compression level %d", cl->jpeg_quality, cl->compress_level); crDebug("VNC SPU: Force JPEG encoding: %d", opt_force_tight_jpeg); } crDebug("VNC SPU: pixel_size = %d", vnc_spu.pixel_size); aio_setread(rf_client_msg, NULL, 1); }
void KdSetRootClip (ScreenPtr pScreen, BOOL enable) { #ifndef FB_OLD_SCREEN WindowPtr pWin = WindowTable[pScreen->myNum]; WindowPtr pChild; Bool WasViewable; Bool anyMarked = FALSE; RegionPtr pOldClip = 0, bsExposed; #ifdef DO_SAVE_UNDERS Bool dosave = FALSE; #endif WindowPtr pLayerWin; BoxRec box; if (!pWin) return; WasViewable = (Bool)(pWin->viewable); if (WasViewable) { for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) { (void) (*pScreen->MarkOverlappedWindows)(pChild, pChild, &pLayerWin); } (*pScreen->MarkWindow) (pWin); anyMarked = TRUE; if (pWin->valdata) { if (HasBorder (pWin)) { RegionPtr borderVisible; borderVisible = REGION_CREATE(pScreen, NullBox, 1); REGION_SUBTRACT(pScreen, borderVisible, &pWin->borderClip, &pWin->winSize); pWin->valdata->before.borderVisible = borderVisible; } pWin->valdata->before.resized = TRUE; } } if (enable) { box.x1 = 0; box.y1 = 0; box.x2 = pScreen->width; box.y2 = pScreen->height; pWin->drawable.width = pScreen->width; pWin->drawable.height = pScreen->height; REGION_INIT (pScreen, &pWin->winSize, &box, 1); REGION_INIT (pScreen, &pWin->borderSize, &box, 1); REGION_RESET(pScreen, &pWin->borderClip, &box); REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList); } else { REGION_EMPTY(pScreen, &pWin->borderClip); REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList); } ResizeChildrenWinSize (pWin, 0, 0, 0, 0); if (WasViewable) { if (pWin->backStorage) { pOldClip = REGION_CREATE(pScreen, NullBox, 1); REGION_COPY(pScreen, pOldClip, &pWin->clipList); } if (pWin->firstChild) { anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin->firstChild, pWin->firstChild, (WindowPtr *)NULL); } else { (*pScreen->MarkWindow) (pWin); anyMarked = TRUE; } #ifdef DO_SAVE_UNDERS if (DO_SAVE_UNDERS(pWin)) { dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pLayerWin); } #endif /* DO_SAVE_UNDERS */ if (anyMarked) (*pScreen->ValidateTree)(pWin, NullWindow, VTOther); } if (pWin->backStorage && ((pWin->backingStore == Always) || WasViewable)) { if (!WasViewable) pOldClip = &pWin->clipList; /* a convenient empty region */ bsExposed = (*pScreen->TranslateBackingStore) (pWin, 0, 0, pOldClip, pWin->drawable.x, pWin->drawable.y); if (WasViewable) REGION_DESTROY(pScreen, pOldClip); if (bsExposed) { RegionPtr valExposed = NullRegion; if (pWin->valdata) valExposed = &pWin->valdata->after.exposed; (*pScreen->WindowExposures) (pWin, valExposed, bsExposed); if (valExposed) REGION_EMPTY(pScreen, valExposed); REGION_DESTROY(pScreen, bsExposed); } } if (WasViewable) { if (anyMarked) (*pScreen->HandleExposures)(pWin); #ifdef DO_SAVE_UNDERS if (dosave) (*pScreen->PostChangeSaveUnder)(pLayerWin, pLayerWin); #endif /* DO_SAVE_UNDERS */ if (anyMarked && pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pWin, NullWindow, VTOther); } if (pWin->realized) WindowsRestructured (); #endif /* !FB_OLD_SCREEN */ }