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