SDL  2.0
SDL_surface.c
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 #include "../SDL_internal.h"
22 
23 #include "SDL_video.h"
24 #include "SDL_sysvideo.h"
25 #include "SDL_blit.h"
26 #include "SDL_RLEaccel_c.h"
27 #include "SDL_pixels_c.h"
28 #include "SDL_yuv_c.h"
29 
30 
31 /* Check to make sure we can safely check multiplication of surface w and pitch and it won't overflow Sint64 */
32 SDL_COMPILE_TIME_ASSERT(surface_size_assumptions, sizeof(int) == sizeof(Sint32));
33 
34 /* Public routines */
35 
36 /*
37  * Calculate the pad-aligned scanline width of a surface
38  */
39 static Sint64
41 {
42  Sint64 pitch;
43 
44  /* Surface should be 4-byte aligned for speed */
45  pitch = (Sint64)width * SDL_BYTESPERPIXEL(format);
46  switch (SDL_BITSPERPIXEL(format)) {
47  case 1:
48  pitch = (pitch + 7) / 8;
49  break;
50  case 4:
51  pitch = (pitch + 1) / 2;
52  break;
53  default:
54  break;
55  }
56  pitch = (pitch + 3) & ~3; /* 4-byte aligning */
57  return pitch;
58 }
59 
60 /*
61  * Create an empty RGB surface of the appropriate depth using the given
62  * enum SDL_PIXELFORMAT_* format
63  */
66  Uint32 format)
67 {
68  Sint64 pitch;
70 
71  /* The flags are no longer used, make the compiler happy */
72  (void)flags;
73 
74  pitch = SDL_CalculatePitch(format, width);
75  if (pitch < 0 || pitch > SDL_MAX_SINT32) {
76  /* Overflow... */
78  return NULL;
79  }
80  /* Allocate the surface */
81  surface = (SDL_Surface *) SDL_calloc(1, sizeof(*surface));
82  if (surface == NULL) {
84  return NULL;
85  }
86 
87  surface->format = SDL_AllocFormat(format);
88  if (!surface->format) {
89  SDL_FreeSurface(surface);
90  return NULL;
91  }
92  surface->w = width;
93  surface->h = height;
94  surface->pitch = (int)pitch;
95  SDL_SetClipRect(surface, NULL);
96 
97  if (SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) {
98  SDL_Palette *palette =
99  SDL_AllocPalette((1 << surface->format->BitsPerPixel));
100  if (!palette) {
101  SDL_FreeSurface(surface);
102  return NULL;
103  }
104  if (palette->ncolors == 2) {
105  /* Create a black and white bitmap palette */
106  palette->colors[0].r = 0xFF;
107  palette->colors[0].g = 0xFF;
108  palette->colors[0].b = 0xFF;
109  palette->colors[1].r = 0x00;
110  palette->colors[1].g = 0x00;
111  palette->colors[1].b = 0x00;
112  }
113  SDL_SetSurfacePalette(surface, palette);
114  SDL_FreePalette(palette);
115  }
116 
117  /* Get the pixels */
118  if (surface->w && surface->h) {
119  /* Assumptions checked in surface_size_assumptions assert above */
120  Sint64 size = ((Sint64)surface->h * surface->pitch);
121  if (size < 0 || size > SDL_MAX_SINT32) {
122  /* Overflow... */
123  SDL_FreeSurface(surface);
124  SDL_OutOfMemory();
125  return NULL;
126  }
127 
128  surface->pixels = SDL_malloc((size_t)size);
129  if (!surface->pixels) {
130  SDL_FreeSurface(surface);
131  SDL_OutOfMemory();
132  return NULL;
133  }
134  /* This is important for bitmaps */
135  SDL_memset(surface->pixels, 0, surface->h * surface->pitch);
136  }
137 
138  /* Allocate an empty mapping */
139  surface->map = SDL_AllocBlitMap();
140  if (!surface->map) {
141  SDL_FreeSurface(surface);
142  return NULL;
143  }
144 
145  /* By default surface with an alpha mask are set up for blending */
146  if (surface->format->Amask) {
148  }
149 
150  /* The surface is ready to go */
151  surface->refcount = 1;
152  return surface;
153 }
154 
155 /*
156  * Create an empty RGB surface of the appropriate depth
157  */
158 SDL_Surface *
160  int width, int height, int depth,
161  Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
162 {
163  Uint32 format;
164 
165  /* Get the pixel format */
166  format = SDL_MasksToPixelFormatEnum(depth, Rmask, Gmask, Bmask, Amask);
167  if (format == SDL_PIXELFORMAT_UNKNOWN) {
168  SDL_SetError("Unknown pixel format");
169  return NULL;
170  }
171 
172  return SDL_CreateRGBSurfaceWithFormat(flags, width, height, depth, format);
173 }
174 
175 /*
176  * Create an RGB surface from an existing memory buffer
177  */
178 SDL_Surface *
180  int width, int height, int depth, int pitch,
181  Uint32 Rmask, Uint32 Gmask, Uint32 Bmask,
182  Uint32 Amask)
183 {
185 
186  surface = SDL_CreateRGBSurface(0, 0, 0, depth, Rmask, Gmask, Bmask, Amask);
187  if (surface != NULL) {
188  surface->flags |= SDL_PREALLOC;
189  surface->pixels = pixels;
190  surface->w = width;
191  surface->h = height;
192  surface->pitch = pitch;
193  SDL_SetClipRect(surface, NULL);
194  }
195  return surface;
196 }
197 
198 /*
199  * Create an RGB surface from an existing memory buffer using the given given
200  * enum SDL_PIXELFORMAT_* format
201  */
202 SDL_Surface *
204  int width, int height, int depth, int pitch,
205  Uint32 format)
206 {
208 
209  surface = SDL_CreateRGBSurfaceWithFormat(0, 0, 0, depth, format);
210  if (surface != NULL) {
211  surface->flags |= SDL_PREALLOC;
212  surface->pixels = pixels;
213  surface->w = width;
214  surface->h = height;
215  surface->pitch = pitch;
216  SDL_SetClipRect(surface, NULL);
217  }
218  return surface;
219 }
220 
221 int
223 {
224  if (!surface) {
225  return SDL_SetError("SDL_SetSurfacePalette() passed a NULL surface");
226  }
227  if (SDL_SetPixelFormatPalette(surface->format, palette) < 0) {
228  return -1;
229  }
230  SDL_InvalidateMap(surface->map);
231 
232  return 0;
233 }
234 
235 int
237 {
238  int flags;
239 
240  if (!surface) {
241  return -1;
242  }
243 
244  flags = surface->map->info.flags;
245  if (flag) {
246  surface->map->info.flags |= SDL_COPY_RLE_DESIRED;
247  } else {
248  surface->map->info.flags &= ~SDL_COPY_RLE_DESIRED;
249  }
250  if (surface->map->info.flags != flags) {
251  SDL_InvalidateMap(surface->map);
252  }
253  return 0;
254 }
255 
256 int
258 {
259  int flags;
260 
261  if (!surface) {
262  return SDL_InvalidParamError("surface");
263  }
264 
265  if (surface->format->palette && key >= ((Uint32) surface->format->palette->ncolors)) {
266  return SDL_InvalidParamError("key");
267  }
268 
269  if (flag & SDL_RLEACCEL) {
270  SDL_SetSurfaceRLE(surface, 1);
271  }
272 
273  flags = surface->map->info.flags;
274  if (flag) {
275  surface->map->info.flags |= SDL_COPY_COLORKEY;
276  surface->map->info.colorkey = key;
277  if (surface->format->palette) {
278  surface->format->palette->colors[surface->map->info.colorkey].a = SDL_ALPHA_TRANSPARENT;
279  ++surface->format->palette->version;
280  if (!surface->format->palette->version) {
281  surface->format->palette->version = 1;
282  }
283  }
284  } else {
285  if (surface->format->palette) {
286  surface->format->palette->colors[surface->map->info.colorkey].a = SDL_ALPHA_OPAQUE;
287  ++surface->format->palette->version;
288  if (!surface->format->palette->version) {
289  surface->format->palette->version = 1;
290  }
291  }
292  surface->map->info.flags &= ~SDL_COPY_COLORKEY;
293  }
294  if (surface->map->info.flags != flags) {
295  SDL_InvalidateMap(surface->map);
296  }
297 
298  return 0;
299 }
300 
301 SDL_bool
303 {
304  if (!surface) {
305  return SDL_FALSE;
306  }
307 
308  if (!(surface->map->info.flags & SDL_COPY_COLORKEY)) {
309  return SDL_FALSE;
310  }
311 
312  return SDL_TRUE;
313 }
314 
315 int
317 {
318  if (!surface) {
319  return SDL_InvalidParamError("surface");
320  }
321 
322  if (!(surface->map->info.flags & SDL_COPY_COLORKEY)) {
323  return SDL_SetError("Surface doesn't have a colorkey");
324  }
325 
326  if (key) {
327  *key = surface->map->info.colorkey;
328  }
329  return 0;
330 }
331 
332 /* This is a fairly slow function to switch from colorkey to alpha */
333 static void
335 {
336  int x, y;
337 
338  if (!surface) {
339  return;
340  }
341 
342  if (!(surface->map->info.flags & SDL_COPY_COLORKEY) ||
343  !surface->format->Amask) {
344  return;
345  }
346 
347  SDL_LockSurface(surface);
348 
349  switch (surface->format->BytesPerPixel) {
350  case 2:
351  {
352  Uint16 *row, *spot;
353  Uint16 ckey = (Uint16) surface->map->info.colorkey;
354  Uint16 mask = (Uint16) (~surface->format->Amask);
355 
356  /* Ignore alpha in colorkey comparison */
357  ckey &= mask;
358  row = (Uint16 *) surface->pixels;
359  for (y = surface->h; y--;) {
360  spot = row;
361  for (x = surface->w; x--;) {
362  if ((*spot & mask) == ckey) {
363  *spot &= mask;
364  }
365  ++spot;
366  }
367  row += surface->pitch / 2;
368  }
369  }
370  break;
371  case 3:
372  /* FIXME */
373  break;
374  case 4:
375  {
376  Uint32 *row, *spot;
377  Uint32 ckey = surface->map->info.colorkey;
378  Uint32 mask = ~surface->format->Amask;
379 
380  /* Ignore alpha in colorkey comparison */
381  ckey &= mask;
382  row = (Uint32 *) surface->pixels;
383  for (y = surface->h; y--;) {
384  spot = row;
385  for (x = surface->w; x--;) {
386  if ((*spot & mask) == ckey) {
387  *spot &= mask;
388  }
389  ++spot;
390  }
391  row += surface->pitch / 4;
392  }
393  }
394  break;
395  }
396 
397  SDL_UnlockSurface(surface);
398 
399  SDL_SetColorKey(surface, 0, 0);
401 }
402 
403 int
405 {
406  int flags;
407 
408  if (!surface) {
409  return -1;
410  }
411 
412  surface->map->info.r = r;
413  surface->map->info.g = g;
414  surface->map->info.b = b;
415 
416  flags = surface->map->info.flags;
417  if (r != 0xFF || g != 0xFF || b != 0xFF) {
418  surface->map->info.flags |= SDL_COPY_MODULATE_COLOR;
419  } else {
420  surface->map->info.flags &= ~SDL_COPY_MODULATE_COLOR;
421  }
422  if (surface->map->info.flags != flags) {
423  SDL_InvalidateMap(surface->map);
424  }
425  return 0;
426 }
427 
428 
429 int
431 {
432  if (!surface) {
433  return -1;
434  }
435 
436  if (r) {
437  *r = surface->map->info.r;
438  }
439  if (g) {
440  *g = surface->map->info.g;
441  }
442  if (b) {
443  *b = surface->map->info.b;
444  }
445  return 0;
446 }
447 
448 int
450 {
451  int flags;
452 
453  if (!surface) {
454  return -1;
455  }
456 
457  surface->map->info.a = alpha;
458 
459  flags = surface->map->info.flags;
460  if (alpha != 0xFF) {
461  surface->map->info.flags |= SDL_COPY_MODULATE_ALPHA;
462  } else {
463  surface->map->info.flags &= ~SDL_COPY_MODULATE_ALPHA;
464  }
465  if (surface->map->info.flags != flags) {
466  SDL_InvalidateMap(surface->map);
467  }
468  return 0;
469 }
470 
471 int
473 {
474  if (!surface) {
475  return -1;
476  }
477 
478  if (alpha) {
479  *alpha = surface->map->info.a;
480  }
481  return 0;
482 }
483 
484 int
486 {
487  int flags, status;
488 
489  if (!surface) {
490  return -1;
491  }
492 
493  status = 0;
494  flags = surface->map->info.flags;
495  surface->map->info.flags &=
497  switch (blendMode) {
498  case SDL_BLENDMODE_NONE:
499  break;
500  case SDL_BLENDMODE_BLEND:
501  surface->map->info.flags |= SDL_COPY_BLEND;
502  break;
503  case SDL_BLENDMODE_ADD:
504  surface->map->info.flags |= SDL_COPY_ADD;
505  break;
506  case SDL_BLENDMODE_MOD:
507  surface->map->info.flags |= SDL_COPY_MOD;
508  break;
509  default:
510  status = SDL_Unsupported();
511  break;
512  }
513 
514  if (surface->map->info.flags != flags) {
515  SDL_InvalidateMap(surface->map);
516  }
517 
518  return status;
519 }
520 
521 int
523 {
524  if (!surface) {
525  return -1;
526  }
527 
528  if (!blendMode) {
529  return 0;
530  }
531 
532  switch (surface->map->
533  info.flags & (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD)) {
534  case SDL_COPY_BLEND:
535  *blendMode = SDL_BLENDMODE_BLEND;
536  break;
537  case SDL_COPY_ADD:
538  *blendMode = SDL_BLENDMODE_ADD;
539  break;
540  case SDL_COPY_MOD:
541  *blendMode = SDL_BLENDMODE_MOD;
542  break;
543  default:
544  *blendMode = SDL_BLENDMODE_NONE;
545  break;
546  }
547  return 0;
548 }
549 
550 SDL_bool
552 {
553  SDL_Rect full_rect;
554 
555  /* Don't do anything if there's no surface to act on */
556  if (!surface) {
557  return SDL_FALSE;
558  }
559 
560  /* Set up the full surface rectangle */
561  full_rect.x = 0;
562  full_rect.y = 0;
563  full_rect.w = surface->w;
564  full_rect.h = surface->h;
565 
566  /* Set the clipping rectangle */
567  if (!rect) {
568  surface->clip_rect = full_rect;
569  return SDL_TRUE;
570  }
571  return SDL_IntersectRect(rect, &full_rect, &surface->clip_rect);
572 }
573 
574 void
576 {
577  if (surface && rect) {
578  *rect = surface->clip_rect;
579  }
580 }
581 
582 /*
583  * Set up a blit between two surfaces -- split into three parts:
584  * The upper part, SDL_UpperBlit(), performs clipping and rectangle
585  * verification. The lower part is a pointer to a low level
586  * accelerated blitting function.
587  *
588  * These parts are separated out and each used internally by this
589  * library in the optimimum places. They are exported so that if
590  * you know exactly what you are doing, you can optimize your code
591  * by calling the one(s) you need.
592  */
593 int
595  SDL_Surface * dst, SDL_Rect * dstrect)
596 {
597  /* Check to make sure the blit mapping is valid */
598  if ((src->map->dst != dst) ||
599  (dst->format->palette &&
600  src->map->dst_palette_version != dst->format->palette->version) ||
601  (src->format->palette &&
602  src->map->src_palette_version != src->format->palette->version)) {
603  if (SDL_MapSurface(src, dst) < 0) {
604  return (-1);
605  }
606  /* just here for debugging */
607 /* printf */
608 /* ("src = 0x%08X src->flags = %08X src->map->info.flags = %08x\ndst = 0x%08X dst->flags = %08X dst->map->info.flags = %08X\nsrc->map->blit = 0x%08x\n", */
609 /* src, dst->flags, src->map->info.flags, dst, dst->flags, */
610 /* dst->map->info.flags, src->map->blit); */
611  }
612  return (src->map->blit(src, srcrect, dst, dstrect));
613 }
614 
615 
616 int
618  SDL_Surface * dst, SDL_Rect * dstrect)
619 {
620  SDL_Rect fulldst;
621  int srcx, srcy, w, h;
622 
623  /* Make sure the surfaces aren't locked */
624  if (!src || !dst) {
625  return SDL_SetError("SDL_UpperBlit: passed a NULL surface");
626  }
627  if (src->locked || dst->locked) {
628  return SDL_SetError("Surfaces must not be locked during blit");
629  }
630 
631  /* If the destination rectangle is NULL, use the entire dest surface */
632  if (dstrect == NULL) {
633  fulldst.x = fulldst.y = 0;
634  fulldst.w = dst->w;
635  fulldst.h = dst->h;
636  dstrect = &fulldst;
637  }
638 
639  /* clip the source rectangle to the source surface */
640  if (srcrect) {
641  int maxw, maxh;
642 
643  srcx = srcrect->x;
644  w = srcrect->w;
645  if (srcx < 0) {
646  w += srcx;
647  dstrect->x -= srcx;
648  srcx = 0;
649  }
650  maxw = src->w - srcx;
651  if (maxw < w)
652  w = maxw;
653 
654  srcy = srcrect->y;
655  h = srcrect->h;
656  if (srcy < 0) {
657  h += srcy;
658  dstrect->y -= srcy;
659  srcy = 0;
660  }
661  maxh = src->h - srcy;
662  if (maxh < h)
663  h = maxh;
664 
665  } else {
666  srcx = srcy = 0;
667  w = src->w;
668  h = src->h;
669  }
670 
671  /* clip the destination rectangle against the clip rectangle */
672  {
673  SDL_Rect *clip = &dst->clip_rect;
674  int dx, dy;
675 
676  dx = clip->x - dstrect->x;
677  if (dx > 0) {
678  w -= dx;
679  dstrect->x += dx;
680  srcx += dx;
681  }
682  dx = dstrect->x + w - clip->x - clip->w;
683  if (dx > 0)
684  w -= dx;
685 
686  dy = clip->y - dstrect->y;
687  if (dy > 0) {
688  h -= dy;
689  dstrect->y += dy;
690  srcy += dy;
691  }
692  dy = dstrect->y + h - clip->y - clip->h;
693  if (dy > 0)
694  h -= dy;
695  }
696 
697  /* Switch back to a fast blit if we were previously stretching */
698  if (src->map->info.flags & SDL_COPY_NEAREST) {
699  src->map->info.flags &= ~SDL_COPY_NEAREST;
700  SDL_InvalidateMap(src->map);
701  }
702 
703  if (w > 0 && h > 0) {
704  SDL_Rect sr;
705  sr.x = srcx;
706  sr.y = srcy;
707  sr.w = dstrect->w = w;
708  sr.h = dstrect->h = h;
709  return SDL_LowerBlit(src, &sr, dst, dstrect);
710  }
711  dstrect->w = dstrect->h = 0;
712  return 0;
713 }
714 
715 int
717  SDL_Surface * dst, SDL_Rect * dstrect)
718 {
719  double src_x0, src_y0, src_x1, src_y1;
720  double dst_x0, dst_y0, dst_x1, dst_y1;
721  SDL_Rect final_src, final_dst;
722  double scaling_w, scaling_h;
723  int src_w, src_h;
724  int dst_w, dst_h;
725 
726  /* Make sure the surfaces aren't locked */
727  if (!src || !dst) {
728  return SDL_SetError("SDL_UpperBlitScaled: passed a NULL surface");
729  }
730  if (src->locked || dst->locked) {
731  return SDL_SetError("Surfaces must not be locked during blit");
732  }
733 
734  if (NULL == srcrect) {
735  src_w = src->w;
736  src_h = src->h;
737  } else {
738  src_w = srcrect->w;
739  src_h = srcrect->h;
740  }
741 
742  if (NULL == dstrect) {
743  dst_w = dst->w;
744  dst_h = dst->h;
745  } else {
746  dst_w = dstrect->w;
747  dst_h = dstrect->h;
748  }
749 
750  if (dst_w == src_w && dst_h == src_h) {
751  /* No scaling, defer to regular blit */
752  return SDL_BlitSurface(src, srcrect, dst, dstrect);
753  }
754 
755  scaling_w = (double)dst_w / src_w;
756  scaling_h = (double)dst_h / src_h;
757 
758  if (NULL == dstrect) {
759  dst_x0 = 0;
760  dst_y0 = 0;
761  dst_x1 = dst_w - 1;
762  dst_y1 = dst_h - 1;
763  } else {
764  dst_x0 = dstrect->x;
765  dst_y0 = dstrect->y;
766  dst_x1 = dst_x0 + dst_w - 1;
767  dst_y1 = dst_y0 + dst_h - 1;
768  }
769 
770  if (NULL == srcrect) {
771  src_x0 = 0;
772  src_y0 = 0;
773  src_x1 = src_w - 1;
774  src_y1 = src_h - 1;
775  } else {
776  src_x0 = srcrect->x;
777  src_y0 = srcrect->y;
778  src_x1 = src_x0 + src_w - 1;
779  src_y1 = src_y0 + src_h - 1;
780 
781  /* Clip source rectangle to the source surface */
782 
783  if (src_x0 < 0) {
784  dst_x0 -= src_x0 * scaling_w;
785  src_x0 = 0;
786  }
787 
788  if (src_x1 >= src->w) {
789  dst_x1 -= (src_x1 - src->w + 1) * scaling_w;
790  src_x1 = src->w - 1;
791  }
792 
793  if (src_y0 < 0) {
794  dst_y0 -= src_y0 * scaling_h;
795  src_y0 = 0;
796  }
797 
798  if (src_y1 >= src->h) {
799  dst_y1 -= (src_y1 - src->h + 1) * scaling_h;
800  src_y1 = src->h - 1;
801  }
802  }
803 
804  /* Clip destination rectangle to the clip rectangle */
805 
806  /* Translate to clip space for easier calculations */
807  dst_x0 -= dst->clip_rect.x;
808  dst_x1 -= dst->clip_rect.x;
809  dst_y0 -= dst->clip_rect.y;
810  dst_y1 -= dst->clip_rect.y;
811 
812  if (dst_x0 < 0) {
813  src_x0 -= dst_x0 / scaling_w;
814  dst_x0 = 0;
815  }
816 
817  if (dst_x1 >= dst->clip_rect.w) {
818  src_x1 -= (dst_x1 - dst->clip_rect.w + 1) / scaling_w;
819  dst_x1 = dst->clip_rect.w - 1;
820  }
821 
822  if (dst_y0 < 0) {
823  src_y0 -= dst_y0 / scaling_h;
824  dst_y0 = 0;
825  }
826 
827  if (dst_y1 >= dst->clip_rect.h) {
828  src_y1 -= (dst_y1 - dst->clip_rect.h + 1) / scaling_h;
829  dst_y1 = dst->clip_rect.h - 1;
830  }
831 
832  /* Translate back to surface coordinates */
833  dst_x0 += dst->clip_rect.x;
834  dst_x1 += dst->clip_rect.x;
835  dst_y0 += dst->clip_rect.y;
836  dst_y1 += dst->clip_rect.y;
837 
838  final_src.x = (int)SDL_floor(src_x0 + 0.5);
839  final_src.y = (int)SDL_floor(src_y0 + 0.5);
840  final_src.w = (int)SDL_floor(src_x1 + 1 + 0.5) - (int)SDL_floor(src_x0 + 0.5);
841  final_src.h = (int)SDL_floor(src_y1 + 1 + 0.5) - (int)SDL_floor(src_y0 + 0.5);
842 
843  final_dst.x = (int)SDL_floor(dst_x0 + 0.5);
844  final_dst.y = (int)SDL_floor(dst_y0 + 0.5);
845  final_dst.w = (int)SDL_floor(dst_x1 - dst_x0 + 1.5);
846  final_dst.h = (int)SDL_floor(dst_y1 - dst_y0 + 1.5);
847 
848  if (final_dst.w < 0)
849  final_dst.w = 0;
850  if (final_dst.h < 0)
851  final_dst.h = 0;
852 
853  if (dstrect)
854  *dstrect = final_dst;
855 
856  if (final_dst.w == 0 || final_dst.h == 0 ||
857  final_src.w <= 0 || final_src.h <= 0) {
858  /* No-op. */
859  return 0;
860  }
861 
862  return SDL_LowerBlitScaled(src, &final_src, dst, &final_dst);
863 }
864 
865 /**
866  * This is a semi-private blit function and it performs low-level surface
867  * scaled blitting only.
868  */
869 int
871  SDL_Surface * dst, SDL_Rect * dstrect)
872 {
873  static const Uint32 complex_copy_flags = (
877  );
878 
879  if (!(src->map->info.flags & SDL_COPY_NEAREST)) {
880  src->map->info.flags |= SDL_COPY_NEAREST;
881  SDL_InvalidateMap(src->map);
882  }
883 
884  if ( !(src->map->info.flags & complex_copy_flags) &&
885  src->format->format == dst->format->format &&
887  return SDL_SoftStretch( src, srcrect, dst, dstrect );
888  } else {
889  return SDL_LowerBlit( src, srcrect, dst, dstrect );
890  }
891 }
892 
893 /*
894  * Lock a surface to directly access the pixels
895  */
896 int
898 {
899  if (!surface->locked) {
900  /* Perform the lock */
901  if (surface->flags & SDL_RLEACCEL) {
902  SDL_UnRLESurface(surface, 1);
903  surface->flags |= SDL_RLEACCEL; /* save accel'd state */
904  }
905  }
906 
907  /* Increment the surface lock count, for recursive locks */
908  ++surface->locked;
909 
910  /* Ready to go.. */
911  return (0);
912 }
913 
914 /*
915  * Unlock a previously locked surface
916  */
917 void
919 {
920  /* Only perform an unlock if we are locked */
921  if (!surface->locked || (--surface->locked > 0)) {
922  return;
923  }
924 
925  /* Update RLE encoded surface with new data */
926  if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) {
927  surface->flags &= ~SDL_RLEACCEL; /* stop lying */
928  SDL_RLESurface(surface);
929  }
930 }
931 
932 /*
933  * Creates a new surface identical to the existing surface
934  */
935 SDL_Surface *
937 {
938  return SDL_ConvertSurface(surface, surface->format, surface->flags);
939 }
940 
941 /*
942  * Convert a surface into the specified pixel format.
943  */
944 SDL_Surface *
946  Uint32 flags)
947 {
948  SDL_Surface *convert;
949  Uint32 copy_flags;
950  SDL_Color copy_color;
951  SDL_Rect bounds;
952 
953  if (!surface) {
954  SDL_InvalidParamError("surface");
955  return NULL;
956  }
957  if (!format) {
958  SDL_InvalidParamError("format");
959  return NULL;
960  }
961 
962  /* Check for empty destination palette! (results in empty image) */
963  if (format->palette != NULL) {
964  int i;
965  for (i = 0; i < format->palette->ncolors; ++i) {
966  if ((format->palette->colors[i].r != 0xFF) ||
967  (format->palette->colors[i].g != 0xFF) ||
968  (format->palette->colors[i].b != 0xFF))
969  break;
970  }
971  if (i == format->palette->ncolors) {
972  SDL_SetError("Empty destination palette");
973  return (NULL);
974  }
975  }
976 
977  /* Create a new surface with the desired format */
978  convert = SDL_CreateRGBSurface(flags, surface->w, surface->h,
979  format->BitsPerPixel, format->Rmask,
980  format->Gmask, format->Bmask,
981  format->Amask);
982  if (convert == NULL) {
983  return (NULL);
984  }
985 
986  /* Copy the palette if any */
987  if (format->palette && convert->format->palette) {
988  SDL_memcpy(convert->format->palette->colors,
989  format->palette->colors,
990  format->palette->ncolors * sizeof(SDL_Color));
991  convert->format->palette->ncolors = format->palette->ncolors;
992  }
993 
994  /* Save the original copy flags */
995  copy_flags = surface->map->info.flags;
996  copy_color.r = surface->map->info.r;
997  copy_color.g = surface->map->info.g;
998  copy_color.b = surface->map->info.b;
999  copy_color.a = surface->map->info.a;
1000  surface->map->info.r = 0xFF;
1001  surface->map->info.g = 0xFF;
1002  surface->map->info.b = 0xFF;
1003  surface->map->info.a = 0xFF;
1004  surface->map->info.flags = 0;
1005  SDL_InvalidateMap(surface->map);
1006 
1007  /* Copy over the image data */
1008  bounds.x = 0;
1009  bounds.y = 0;
1010  bounds.w = surface->w;
1011  bounds.h = surface->h;
1012  SDL_LowerBlit(surface, &bounds, convert, &bounds);
1013 
1014  /* Clean up the original surface, and update converted surface */
1015  convert->map->info.r = copy_color.r;
1016  convert->map->info.g = copy_color.g;
1017  convert->map->info.b = copy_color.b;
1018  convert->map->info.a = copy_color.a;
1019  convert->map->info.flags =
1020  (copy_flags &
1024  surface->map->info.r = copy_color.r;
1025  surface->map->info.g = copy_color.g;
1026  surface->map->info.b = copy_color.b;
1027  surface->map->info.a = copy_color.a;
1028  surface->map->info.flags = copy_flags;
1029  SDL_InvalidateMap(surface->map);
1030  if (copy_flags & SDL_COPY_COLORKEY) {
1031  SDL_bool set_colorkey_by_color = SDL_FALSE;
1032 
1033  if (surface->format->palette) {
1034  if (format->palette &&
1035  surface->format->palette->ncolors <= format->palette->ncolors &&
1036  (SDL_memcmp(surface->format->palette->colors, format->palette->colors,
1037  surface->format->palette->ncolors * sizeof(SDL_Color)) == 0)) {
1038  /* The palette is identical, just set the same colorkey */
1039  SDL_SetColorKey(convert, 1, surface->map->info.colorkey);
1040  } else if (format->Amask) {
1041  /* The alpha was set in the destination from the palette */
1042  } else {
1043  set_colorkey_by_color = SDL_TRUE;
1044  }
1045  } else {
1046  set_colorkey_by_color = SDL_TRUE;
1047  }
1048 
1049  if (set_colorkey_by_color) {
1050  SDL_Surface *tmp;
1051  SDL_Surface *tmp2;
1052  int converted_colorkey = 0;
1053 
1054  /* Create a dummy surface to get the colorkey converted */
1055  tmp = SDL_CreateRGBSurface(0, 1, 1,
1056  surface->format->BitsPerPixel, surface->format->Rmask,
1057  surface->format->Gmask, surface->format->Bmask,
1058  surface->format->Amask);
1059 
1060  /* Share the palette, if any */
1061  if (surface->format->palette) {
1062  SDL_SetSurfacePalette(tmp, surface->format->palette);
1063  }
1064 
1065  SDL_FillRect(tmp, NULL, surface->map->info.colorkey);
1066 
1067  tmp->map->info.flags &= ~SDL_COPY_COLORKEY;
1068 
1069  /* Convertion of the colorkey */
1070  tmp2 = SDL_ConvertSurface(tmp, format, 0);
1071 
1072  /* Get the converted colorkey */
1073  SDL_memcpy(&converted_colorkey, tmp2->pixels, tmp2->format->BytesPerPixel);
1074 
1075  SDL_FreeSurface(tmp);
1076  SDL_FreeSurface(tmp2);
1077 
1078  /* Set the converted colorkey on the new surface */
1079  SDL_SetColorKey(convert, 1, converted_colorkey);
1080 
1081  /* This is needed when converting for 3D texture upload */
1082  SDL_ConvertColorkeyToAlpha(convert);
1083  }
1084  }
1085  SDL_SetClipRect(convert, &surface->clip_rect);
1086 
1087  /* Enable alpha blending by default if the new surface has an
1088  * alpha channel or alpha modulation */
1089  if ((surface->format->Amask && format->Amask) ||
1090  (copy_flags & SDL_COPY_MODULATE_ALPHA)) {
1092  }
1093  if ((copy_flags & SDL_COPY_RLE_DESIRED) || (flags & SDL_RLEACCEL)) {
1094  SDL_SetSurfaceRLE(convert, SDL_RLEACCEL);
1095  }
1096 
1097  /* We're ready to go! */
1098  return (convert);
1099 }
1100 
1101 SDL_Surface *
1103  Uint32 flags)
1104 {
1105  SDL_PixelFormat *fmt;
1106  SDL_Surface *convert = NULL;
1107 
1108  fmt = SDL_AllocFormat(pixel_format);
1109  if (fmt) {
1110  convert = SDL_ConvertSurface(surface, fmt, flags);
1111  SDL_FreeFormat(fmt);
1112  }
1113  return convert;
1114 }
1115 
1116 /*
1117  * Create a surface on the stack for quick blit operations
1118  */
1119 static SDL_INLINE SDL_bool
1121  void * pixels, int pitch, SDL_Surface * surface,
1122  SDL_PixelFormat * format, SDL_BlitMap * blitmap)
1123 {
1124  if (SDL_ISPIXELFORMAT_INDEXED(pixel_format)) {
1125  SDL_SetError("Indexed pixel formats not supported");
1126  return SDL_FALSE;
1127  }
1128  if (SDL_InitFormat(format, pixel_format) < 0) {
1129  return SDL_FALSE;
1130  }
1131 
1132  SDL_zerop(surface);
1133  surface->flags = SDL_PREALLOC;
1134  surface->format = format;
1135  surface->pixels = pixels;
1136  surface->w = width;
1137  surface->h = height;
1138  surface->pitch = pitch;
1139  /* We don't actually need to set up the clip rect for our purposes */
1140  /* SDL_SetClipRect(surface, NULL); */
1141 
1142  /* Allocate an empty mapping */
1143  SDL_zerop(blitmap);
1144  blitmap->info.r = 0xFF;
1145  blitmap->info.g = 0xFF;
1146  blitmap->info.b = 0xFF;
1147  blitmap->info.a = 0xFF;
1148  surface->map = blitmap;
1149 
1150  /* The surface is ready to go */
1151  surface->refcount = 1;
1152  return SDL_TRUE;
1153 }
1154 
1155 /*
1156  * Copy a block of pixels of one format to another format
1157  */
1159  Uint32 src_format, const void * src, int src_pitch,
1160  Uint32 dst_format, void * dst, int dst_pitch)
1161 {
1162  SDL_Surface src_surface, dst_surface;
1163  SDL_PixelFormat src_fmt, dst_fmt;
1164  SDL_BlitMap src_blitmap, dst_blitmap;
1165  SDL_Rect rect;
1166  void *nonconst_src = (void *) src;
1167 
1168  /* Check to make sure we are blitting somewhere, so we don't crash */
1169  if (!dst) {
1170  return SDL_InvalidParamError("dst");
1171  }
1172  if (!dst_pitch) {
1173  return SDL_InvalidParamError("dst_pitch");
1174  }
1175 
1176  if (SDL_ISPIXELFORMAT_FOURCC(src_format) && SDL_ISPIXELFORMAT_FOURCC(dst_format)) {
1177  return SDL_ConvertPixels_YUV_to_YUV(width, height, src_format, src, src_pitch, dst_format, dst, dst_pitch);
1178  } else if (SDL_ISPIXELFORMAT_FOURCC(src_format)) {
1179  return SDL_ConvertPixels_YUV_to_RGB(width, height, src_format, src, src_pitch, dst_format, dst, dst_pitch);
1180  } else if (SDL_ISPIXELFORMAT_FOURCC(dst_format)) {
1181  return SDL_ConvertPixels_RGB_to_YUV(width, height, src_format, src, src_pitch, dst_format, dst, dst_pitch);
1182  }
1183 
1184  /* Fast path for same format copy */
1185  if (src_format == dst_format) {
1186  int i;
1187  const int bpp = SDL_BYTESPERPIXEL(src_format);
1188  width *= bpp;
1189  for (i = height; i--;) {
1190  SDL_memcpy(dst, src, width);
1191  src = (const Uint8*)src + src_pitch;
1192  dst = (Uint8*)dst + dst_pitch;
1193  }
1194  return 0;
1195  }
1196 
1197  if (!SDL_CreateSurfaceOnStack(width, height, src_format, nonconst_src,
1198  src_pitch,
1199  &src_surface, &src_fmt, &src_blitmap)) {
1200  return -1;
1201  }
1202  if (!SDL_CreateSurfaceOnStack(width, height, dst_format, dst, dst_pitch,
1203  &dst_surface, &dst_fmt, &dst_blitmap)) {
1204  return -1;
1205  }
1206 
1207  /* Set up the rect and go! */
1208  rect.x = 0;
1209  rect.y = 0;
1210  rect.w = width;
1211  rect.h = height;
1212  return SDL_LowerBlit(&src_surface, &rect, &dst_surface, &rect);
1213 }
1214 
1215 /*
1216  * Free a surface created by the above function.
1217  */
1218 void
1220 {
1221  if (surface == NULL) {
1222  return;
1223  }
1224  if (surface->flags & SDL_DONTFREE) {
1225  return;
1226  }
1227  SDL_InvalidateMap(surface->map);
1228 
1229  if (--surface->refcount > 0) {
1230  return;
1231  }
1232  while (surface->locked > 0) {
1233  SDL_UnlockSurface(surface);
1234  }
1235  if (surface->flags & SDL_RLEACCEL) {
1236  SDL_UnRLESurface(surface, 0);
1237  }
1238  if (surface->format) {
1239  SDL_SetSurfacePalette(surface, NULL);
1240  SDL_FreeFormat(surface->format);
1241  surface->format = NULL;
1242  }
1243  if (!(surface->flags & SDL_PREALLOC)) {
1244  SDL_free(surface->pixels);
1245  }
1246  if (surface->map) {
1247  SDL_FreeBlitMap(surface->map);
1248  }
1249  SDL_free(surface);
1250 }
1251 
1252 /* vi: set ts=4 sw=4 expandtab: */
int SDL_GetColorKey(SDL_Surface *surface, Uint32 *key)
Gets the color key (transparent pixel) in a blittable surface.
Definition: SDL_surface.c:316
int SDL_ConvertPixels_YUV_to_YUV(int width, int height, Uint32 src_format, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch)
Definition: SDL_yuv.c:1810
Uint8 r
Definition: SDL_blit.h:70
#define SDL_COPY_MODULATE_COLOR
Definition: SDL_blit.h:34
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
void SDL_UnlockSurface(SDL_Surface *surface)
Definition: SDL_surface.c:918
Uint32 version
Definition: SDL_pixels.h:308
Uint8 b
Definition: SDL_blit.h:70
SDL_bool SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect)
Definition: SDL_surface.c:551
#define SDL_COPY_COLORKEY
Definition: SDL_blit.h:39
SDL_blit blit
Definition: SDL_blit.h:90
int SDL_SetSurfaceRLE(SDL_Surface *surface, int flag)
Sets the RLE acceleration hint for a surface.
Definition: SDL_surface.c:236
Uint8 g
Definition: SDL_pixels.h:298
GLenum GLenum dst
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
#define SDL_SoftStretch
#define SDL_ISPIXELFORMAT_INDEXED(format)
Definition: SDL_pixels.h:134
int SDL_LockSurface(SDL_Surface *surface)
Sets up a surface for directly accessing the pixels.
Definition: SDL_surface.c:897
SDL_Surface * SDL_ConvertSurfaceFormat(SDL_Surface *surface, Uint32 pixel_format, Uint32 flags)
Definition: SDL_surface.c:1102
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
Definition: SDL_blendmode.h:40
Uint8 BytesPerPixel
Definition: SDL_pixels.h:320
SDL_Rect rect
Definition: testrelative.c:27
Uint8 g
Definition: SDL_blit.h:70
#define SDL_MasksToPixelFormatEnum
SDL_Surface * SDL_ConvertSurface(SDL_Surface *surface, const SDL_PixelFormat *format, Uint32 flags)
Definition: SDL_surface.c:945
GLfloat GLfloat GLfloat GLfloat h
static SDL_INLINE SDL_bool SDL_CreateSurfaceOnStack(int width, int height, Uint32 pixel_format, void *pixels, int pitch, SDL_Surface *surface, SDL_PixelFormat *format, SDL_BlitMap *blitmap)
Definition: SDL_surface.c:1120
#define SDL_COPY_MOD
Definition: SDL_blit.h:38
EGLSurface surface
Definition: eglext.h:248
int SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b)
Set an additional color value used in blit operations.
Definition: SDL_surface.c:404
A collection of pixels used in software blitting.
Definition: SDL_surface.h:69
int SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha)
Set an additional alpha value used in blit operations.
Definition: SDL_surface.c:449
#define SDL_DONTFREE
Definition: SDL_surface.h:55
int SDL_UpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
Definition: SDL_surface.c:716
int SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode)
Set the blend mode used for blit operations.
Definition: SDL_surface.c:485
void SDL_UnRLESurface(SDL_Surface *surface, int recode)
uint16_t Uint16
Definition: SDL_stdinc.h:191
#define SDL_BlitSurface
Definition: SDL_surface.h:483
static void SDL_ConvertColorkeyToAlpha(SDL_Surface *surface)
Definition: SDL_surface.c:334
#define SDL_BYTESPERPIXEL(X)
Definition: SDL_pixels.h:128
Uint32 dst_palette_version
Definition: SDL_blit.h:96
Uint8 b
Definition: SDL_pixels.h:299
SDL_Surface * SDL_DuplicateSurface(SDL_Surface *surface)
Definition: SDL_surface.c:936
#define SDL_AllocFormat
#define SDL_COPY_RLE_COLORKEY
Definition: SDL_blit.h:42
#define SDL_MAX_SINT32
A signed 32-bit integer type.
Definition: SDL_stdinc.h:195
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
GLenum src
#define SDL_IntersectRect
#define SDL_floor
int SDL_LowerBlit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
Definition: SDL_surface.c:594
#define SDL_zerop(x)
Definition: SDL_stdinc.h:417
int SDL_SetColorKey(SDL_Surface *surface, int flag, Uint32 key)
Sets the color key (transparent pixel) in a blittable surface.
Definition: SDL_surface.c:257
int SDL_UpperBlit(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
Definition: SDL_surface.c:617
int SDL_ConvertPixels_YUV_to_RGB(int width, int height, Uint32 src_format, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch)
Definition: SDL_yuv.c:395
GLfloat GLfloat GLfloat alpha
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
#define SDL_COPY_ADD
Definition: SDL_blit.h:37
Uint32 colorkey
Definition: SDL_blit.h:69
Uint32 flags
Definition: SDL_surface.h:71
void SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect)
Definition: SDL_surface.c:575
Uint32 src_palette_version
Definition: SDL_blit.h:97
#define SDL_COPY_RLE_DESIRED
Definition: SDL_blit.h:41
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
void SDL_InvalidateMap(SDL_BlitMap *map)
Definition: SDL_pixels.c:972
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1572
#define SDL_COPY_NEAREST
Definition: SDL_blit.h:40
#define SDL_ALPHA_TRANSPARENT
Definition: SDL_pixels.h:47
SDL_Surface * SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth, Uint32 format)
Definition: SDL_surface.c:65
struct SDL_BlitMap * map
Definition: SDL_surface.h:88
#define SDL_memcpy
GLuint64 key
Definition: gl2ext.h:2192
Uint8 r
Definition: SDL_pixels.h:297
int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst)
Definition: SDL_pixels.c:991
void * pixels
Definition: SDL_surface.h:75
Uint8 a
Definition: SDL_pixels.h:300
uint8_t Uint8
Definition: SDL_stdinc.h:179
#define SDL_free
Uint8 BitsPerPixel
Definition: SDL_pixels.h:319
int SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette)
Set the palette used by a surface.
Definition: SDL_surface.c:222
int SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode)
Get the blend mode used for blit operations.
Definition: SDL_surface.c:522
static Sint64 SDL_CalculatePitch(Uint32 format, int width)
Definition: SDL_surface.c:40
int SDL_ConvertPixels(int width, int height, Uint32 src_format, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch)
Copy a block of pixels of one format to another format.
Definition: SDL_surface.c:1158
#define SDL_FreeFormat
#define SDL_memcmp
GLenum GLint GLuint mask
GLubyte GLubyte GLubyte GLubyte w
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
SDL_Surface * SDL_CreateRGBSurfaceWithFormatFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 format)
Definition: SDL_surface.c:203
int SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 *alpha)
Get the additional alpha value used in blit operations.
Definition: SDL_surface.c:472
int x
Definition: SDL_rect.h:66
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1572
int32_t Sint32
Definition: SDL_stdinc.h:197
int w
Definition: SDL_rect.h:67
GLsizeiptr size
#define SDL_AllocPalette
int SDL_InitFormat(SDL_PixelFormat *format, Uint32 pixel_format)
Definition: SDL_pixels.c:537
SDL_Rect clip_rect
Definition: SDL_surface.h:85
void SDL_FreeSurface(SDL_Surface *surface)
Definition: SDL_surface.c:1219
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
int SDL_RLESurface(SDL_Surface *surface)
SDL_Surface * dst
Definition: SDL_blit.h:88
#define NULL
Definition: begin_code.h:164
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
SDL_bool
Definition: SDL_stdinc.h:161
SDL_Color * colors
Definition: SDL_pixels.h:307
SDL_PixelFormat * format
Definition: SDL_surface.h:72
GLint GLint GLsizei GLsizei GLsizei depth
Definition: SDL_opengl.h:1572
#define SDL_FreePalette
#define SDL_SetError
SDL_Surface * SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
Definition: SDL_surface.c:159
GLbitfield flags
SDL_bool SDL_HasColorKey(SDL_Surface *surface)
Returns whether the surface has a color key.
Definition: SDL_surface.c:302
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
#define SDL_calloc
#define SDL_COPY_MODULATE_ALPHA
Definition: SDL_blit.h:35
int h
Definition: SDL_rect.h:67
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
#define SDL_COPY_RLE_ALPHAKEY
Definition: SDL_blit.h:43
uint32_t Uint32
Definition: SDL_stdinc.h:203
#define SDL_FillRect
SDL_COMPILE_TIME_ASSERT(surface_size_assumptions, sizeof(int)==sizeof(Sint32))
int SDL_LowerBlitScaled(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
Definition: SDL_surface.c:870
SDL_BlitMap * SDL_AllocBlitMap(void)
Definition: SDL_pixels.c:952
#define SDL_INLINE
Definition: begin_code.h:131
#define SDL_malloc
SDL_Palette * palette
Definition: SDL_pixels.h:318
#define SDL_ISPIXELFORMAT_FOURCC(format)
Definition: SDL_pixels.h:167
SDL_Surface * SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
Definition: SDL_surface.c:179
int64_t Sint64
Definition: SDL_stdinc.h:210
#define SDL_ALPHA_OPAQUE
Definition: SDL_pixels.h:46
int SDL_ConvertPixels_RGB_to_YUV(int width, int height, Uint32 src_format, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch)
Definition: SDL_yuv.c:784
GLboolean GLboolean g
GLboolean GLboolean GLboolean b
void SDL_FreeBlitMap(SDL_BlitMap *map)
Definition: SDL_pixels.c:1077
int SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b)
Get the additional color value used in blit operations.
Definition: SDL_surface.c:430
GLenum GLenum void * row
#define SDL_BITSPERPIXEL(X)
Definition: SDL_pixels.h:127
int y
Definition: SDL_rect.h:66
#define SDL_SetPixelFormatPalette
#define SDL_Unsupported()
Definition: SDL_error.h:53
#define SDL_COPY_BLEND
Definition: SDL_blit.h:36
SDL_BlitInfo info
Definition: SDL_blit.h:92
#define SDL_memset
#define SDL_PREALLOC
Definition: SDL_surface.h:53
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:64
#define SDL_RLEACCEL
Definition: SDL_surface.h:54
Uint8 a
Definition: SDL_blit.h:70