void Painter::Clip( Canvas* c, IntCoord left, IntCoord bottom, IntCoord right, IntCoord top ) { XRectangle& r = rep->xclip[0]; IntCoord x, y; XDisplay* d = rep->display->rep()->display_; if (left > right) { x = right; r.width = left - right + 1; } else { x = left; r.width = right - left + 1; } if (bottom > top) { y = bottom; r.height = bottom - top + 1; } else { y = top; r.height = top - bottom + 1; } r.x = x; r.y = c->pheight() - 1 - y; if (r.x == 0 && r.y == 0 && r.width == c->pwidth() && r.height == c->pheight() ) { /* clipping to entire canvas is equivalent to no clipping at all */ NoClip(); } else { rep->clipped = true; XSetClipRectangles(d, rep->fillgc, 0, 0, rep->xclip, 1, Unsorted); XSetClipRectangles(d, rep->dashgc, 0, 0, rep->xclip, 1, Unsorted); } }
void CSurface8::SetBuffer(BYTE *pbyToBuf, int Wdt, int Hgt, int Pitch) { // release old Clear(); // set new this->Wdt = Wdt; this->Hgt = Hgt; this->Pitch = Pitch; this->Bits = pbyToBuf; NoClip(); }
C4Surface::C4Surface(C4AbstractApp * pApp, C4Window * pWindow): Wdt(0), Hgt(0) { Default(); fPrimary=true; this->pWindow=pWindow; // create rendering context #ifndef USE_CONSOLE pCtx = pGL->CreateContext(pWindow, pApp); #endif // reset clipping NoClip(); }
bool CSurface8::Create(int iWdt, int iHgt) { Clear(); // check size if (!iWdt || !iHgt) return false; Wdt=iWdt; Hgt=iHgt; // create pal pPal = new CStdPalette; if (!pPal) return false; Bits=new BYTE[Wdt*Hgt]; if (!Bits) return false; memset(Bits, 0, Wdt*Hgt); Pitch=Wdt; // update clipping NoClip(); return true; }
bool C4Surface::Create(int iWdt, int iHgt, int iFlags) { Clear(); Default(); // check size if (!iWdt || !iHgt) return false; Wdt=iWdt; Hgt=iHgt; // create texture: check gfx system if (!pDraw) return false; if (!pDraw->DeviceReady()) return false; // store color format that will be used #ifndef USE_CONSOLE Format=pGL->sfcFmt; #endif // create texture iTexSize = std::max(iWdt, iHgt); texture = std::make_unique<C4TexRef>(iWdt, iHgt, iFlags); // update clipping NoClip(); // success return true; }
bool CSurface8::Create(int iWdt, int iHgt, bool fOwnPal) { Clear(); // check size if (!iWdt || !iHgt) return false; Wdt = iWdt; Hgt = iHgt; // create/link to pal if (fOwnPal) { pPal = new CStdPalette; if (!pPal) return false; memcpy(pPal, &lpDDraw->Pal, sizeof(CStdPalette)); } else pPal = &lpDDraw->Pal; Bits = new BYTE[Wdt * Hgt]; if (!Bits) return false; ZeroMemory(Bits, Wdt * Hgt); Pitch = Wdt; // update clipping NoClip(); return true; }