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