1/* 2 * Copyright 1999 Mark Vojkovich 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 19 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 * SOFTWARE. 21 */ 22 23#include "nv_include.h" 24#include "nv_type.h" 25#include "shadowfb.h" 26#include "servermd.h" 27 28#define MIN(a, b) (((a) < (b)) ? (a) : (b)) 29#define MAX(a, b) (((a) > (b)) ? (a) : (b)) 30 31void 32NVRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) 33{ 34 NVPtr pNv = NVPTR(pScrn); 35 int x1, y1, x2, y2, width, height, cpp, FBPitch; 36 unsigned char *src, *dst; 37 38 cpp = pScrn->bitsPerPixel >> 3; 39 FBPitch = pScrn->displayWidth * cpp; 40 41 nouveau_bo_map(pNv->scanout, NOUVEAU_BO_WR, pNv->client); 42 while(num--) { 43 x1 = MAX(pbox->x1, 0); 44 y1 = MAX(pbox->y1, 0); 45 x2 = MIN(pbox->x2, pScrn->virtualX); 46 y2 = MIN(pbox->y2, pScrn->virtualY); 47 width = (x2 - x1) * cpp; 48 height = y2 - y1; 49 50 if (width > 0 && height > 0) { 51 src = pNv->ShadowPtr + (y1 * pNv->ShadowPitch) + (x1 * cpp); 52 dst = pNv->scanout->map + (y1 * FBPitch) + (x1 * cpp); 53 54 while(height--) { 55 memcpy(dst, src, width); 56 dst += FBPitch; 57 src += pNv->ShadowPitch; 58 } 59 } 60 61 pbox++; 62 } 63} 64