140 if (start.
X < cliprect.
X) sflag |= OFF_LEFT;
141 if (start.
Y < cliprect.
Y) sflag |= OFF_TOP;
142 if (start.
X >= cliprect.
X+cliprect.
Width) sflag |= OFF_RIGHT;
143 if (start.
Y >= cliprect.
Y+cliprect.
Height) sflag |= OFF_BOTTOM;
144 if (end.
X < cliprect.
X) dflag |= OFF_LEFT;
145 if (end.
Y < cliprect.
Y) dflag |= OFF_TOP;
146 if (end.
X >= cliprect.
X+cliprect.
Width) dflag |= OFF_RIGHT;
147 if (end.
Y >= cliprect.
Y+cliprect.
Height) dflag |= OFF_BOTTOM;
152 if ((sflag & dflag) != 0)
return(
false);
159 if (sflag & OFF_LEFT) start.
X = cliprect.
X;
160 if (sflag & OFF_RIGHT) start.
X = cliprect.
X+cliprect.
Width-1;
161 if (sflag & OFF_TOP) start.
Y = cliprect.
Y;
162 if (sflag & OFF_BOTTOM) start.
Y = cliprect.
Y+cliprect.
Height-1;
165 if (dflag & OFF_LEFT) end.
X = cliprect.
X;
166 if (dflag & OFF_RIGHT) end.
X = cliprect.
X+cliprect.
Width-1;
167 if (dflag & OFF_TOP) end.
Y = cliprect.
Y;
168 if (dflag & OFF_BOTTOM) end.
Y = cliprect.
Y+cliprect.
Height-1;
175 if (start.
X != end.
X) start.
Y = end.
Y;
181 if (start.
X > end.
X || start.
Y > end.
Y) {
187 void * buffer =
Lock(start);
188 if (buffer !=
NULL) {
190 if (start.
Y == end.
Y) {
192 memset(buffer, color, (end.
X-start.
X)+1);
194 for (
int x = 0; x <= end.
X-start.
X; x++) {
195 ((
short *)buffer)[x] = (short)color;
199 for (
int y = 0; y <= end.
Y-start.
Y; y++) {
201 *(
char*)buffer = (
char)color;
203 *(
short*)buffer = (
short)color;
205 buffer = (
void*)(((
char*)buffer) +
Stride());
292 void * pointer = ((
Surface*)
this)->Lock(point);
293 if (pointer !=
NULL) {
295 color = *((
unsigned short*)pointer);
297 color = *((
unsigned char*)pointer);
324 void * pointer =
Lock(point);
325 if (pointer !=
NULL) {
327 *((
unsigned short*)pointer) = (
unsigned short)color;
329 *((
unsigned char*)pointer) = (
unsigned char)color;
384 if (!fillrect.
Is_Valid())
return(
false);
395 if (!crect.
Is_Valid())
return(
false);
398 if (buffer !=
NULL) {
400 for (
int y = 0; y < crect.
Height; y++) {
401 memset(buffer, color, crect.
Width);
402 buffer = ((
char *)buffer) +
Stride();
405 for (
int y = 0; y < crect.
Height; y++) {
406 for (
int x = 0; x < crect.
Width; x++) {
407 ((
unsigned short*)buffer)[x] = (
unsigned short)color;
409 buffer = ((
char *)buffer) +
Stride();
465 bool result =
Blit_From(drect, source, srect, trans);
527 Rect drect = destrect;
528 Rect srect = sourcerect;
534 if (
Blit_Clip(drect, dcliprect, srect, scliprect)) {
537 return(
Blit_Trans(*
this, drect, source, srect));
539 return(
Blit_Plain(*
this, drect, source, srect));
604 int rightspill = (drect.
X+drect.
Width) - dwindow.
Width;
605 if (rightspill > 0) {
606 srect.
Width -= rightspill;
607 drect.
Width -= rightspill;
610 if (bottomspill > 0) {
611 srect.
Height -= bottomspill;
612 drect.
Height -= bottomspill;
635 rightspill = (srect.
X+srect.
Width) - swindow.
Width;
636 if (rightspill > 0) {
637 srect.
Width -= rightspill;
638 drect.
Width -= rightspill;
641 if (bottomspill > 0) {
642 srect.
Height -= bottomspill;
643 drect.
Height -= bottomspill;
716 if (!
Blit_Clip(drect, dwindow, srect, swindow)) {
727 if (srect.
Y < drect.
Y || (srect.
Y == drect.
Y && srect.
X < drect.
X)) {
737 dbuffer = dest.
Lock(drect.Point());
738 if (dbuffer ==
NULL)
return(
false);
740 if (sbuffer ==
NULL) {
804 if (!
Blit_Clip(drect, dcliprect, srect, scliprect)) {
815 if (srect.
Y < drect.
Y || (srect.
Y == drect.
Y && srect.
X < drect.
X)) {
826 if (dbuffer ==
NULL)
return(
false);
828 if (sbuffer ==
NULL) {
bool Bit_Blit(Surface &dest, Rect const &destrect, Surface const &source, Rect const &sourcerect, Blitter const &blitter)
virtual Rect Get_Rect(void) const
virtual bool Unlock(void) const =0
virtual void * Lock(Point2D point=Point2D(0, 0)) const =0
virtual int Bytes_Per_Pixel(void) const =0
Surface(int width, int height)
TPoint2D< T > const Bias_To(TRect< T > const &rect) const
TRect< T > const Bias_To(TRect< T > const &rect) const
bool Is_Valid(void) const
bool Is_Overlapping(TRect< T > const &rect) const
TPoint2D< T > Top_Left(void) const
TRect< T > const Intersect(TRect< T > const &rectangle, T *x=NULL, T *y=NULL) const
virtual bool Draw_Rect(Rect const &rect, int color)
virtual bool Draw_Line(Point2D const &startpoint, Point2D const &endpoint, int color)
virtual int Bytes_Per_Pixel(void) const =0
static bool Blit_Plain(Surface &dest, Rect const &destrect, Surface const &source, Rect const &sourcerect)
virtual int Stride(void) const =0
virtual bool Unlock(void) const
virtual bool Blit_From(Rect const &dcliprect, Rect const &destrect, Surface const &source, Rect const &scliprect, Rect const &sourcerect, bool trans=false)
virtual void * Lock(Point2D=Point2D(0, 0)) const
virtual int Get_Pixel(Point2D const &point) const
static bool Blit_Trans(Surface &dest, Rect const &destrect, Surface const &source, Rect const &sourcerect)
virtual bool Put_Pixel(Point2D const &point, int color)
virtual bool Fill(int color)
static bool Prep_For_Blit(Surface &dest, Rect &drect, Surface const &source, Rect &srect, bool &overlapped, void *&dbuffer, void *&sbuffer)
virtual bool Fill_Rect(Rect const &rect, int color)
bool Blit_Clip(Rect &drect, Rect const &dwindow, Rect &srect, Rect const &swindow)
bool Blit_Clip(Rect &drect, Rect const &dwindow, Rect &srect, Rect const &swindow)