Atlas - SDL_drawpoint.c

Home / ext / SDL / src / render / software Lines: 1 | Size: 3094 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
1/* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2025 Sam Lantinga <[email protected]> 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#ifdef SDL_VIDEO_RENDER_SW 24 25#include "SDL_draw.h" 26#include "SDL_drawpoint.h" 27 28bool SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color) 29{ 30 CHECK_PARAM(!SDL_SurfaceValid(dst)) { 31 return SDL_InvalidParamError("SDL_DrawPoint(): dst"); 32 } 33 34 // This function doesn't work on surfaces < 8 bpp 35 if (dst->fmt->bits_per_pixel < 8) { 36 return SDL_SetError("SDL_DrawPoint(): Unsupported surface format"); 37 } 38 39 // Perform clipping 40 if (x < dst->clip_rect.x || y < dst->clip_rect.y || 41 x >= (dst->clip_rect.x + dst->clip_rect.w) || 42 y >= (dst->clip_rect.y + dst->clip_rect.h)) { 43 return true; 44 } 45 46 switch (dst->fmt->bytes_per_pixel) { 47 case 1: 48 DRAW_FASTSETPIXELXY1(x, y); 49 break; 50 case 2: 51 DRAW_FASTSETPIXELXY2(x, y); 52 break; 53 case 3: 54 return SDL_Unsupported(); 55 case 4: 56 DRAW_FASTSETPIXELXY4(x, y); 57 break; 58 } 59 return true; 60} 61 62bool SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count, Uint32 color) 63{ 64 int minx, miny; 65 int maxx, maxy; 66 int i; 67 int x, y; 68 69 CHECK_PARAM(!SDL_SurfaceValid(dst)) { 70 return SDL_InvalidParamError("SDL_DrawPoints(): dst"); 71 } 72 73 // This function doesn't work on surfaces < 8 bpp 74 if (dst->fmt->bits_per_pixel < 8) { 75 return SDL_SetError("SDL_DrawPoints(): Unsupported surface format"); 76 } 77 78 minx = dst->clip_rect.x; 79 maxx = dst->clip_rect.x + dst->clip_rect.w - 1; 80 miny = dst->clip_rect.y; 81 maxy = dst->clip_rect.y + dst->clip_rect.h - 1; 82 83 for (i = 0; i < count; ++i) { 84 x = points[i].x; 85 y = points[i].y; 86 87 if (x < minx || x > maxx || y < miny || y > maxy) { 88 continue; 89 } 90 91 switch (dst->fmt->bytes_per_pixel) { 92 case 1: 93 DRAW_FASTSETPIXELXY1(x, y); 94 break; 95 case 2: 96 DRAW_FASTSETPIXELXY2(x, y); 97 break; 98 case 3: 99 return SDL_Unsupported(); 100 case 4: 101 DRAW_FASTSETPIXELXY4(x, y); 102 break; 103 } 104 } 105 return true; 106} 107 108#endif // SDL_VIDEO_RENDER_SW 109
[FILE END]
(C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.