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