zenilib: zenilib/jni/external/sdl/src/render/software/SDL_drawpoint.c Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_drawpoint.c
Go to the documentation of this file.
1 /*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2013 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_config.h"
22
23 #if !SDL_RENDER_DISABLED
24
25 #include "SDL_draw.h"
26 #include "SDL_drawpoint.h"
27
28
29 int
30 SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color)
31 {
32 if (!dst) {
33 return SDL_SetError("Passed NULL destination surface");
34 }
35
36 /* This function doesn't work on surfaces < 8 bpp */
37 if (dst->format->BitsPerPixel < 8) {
38 return SDL_SetError("SDL_DrawPoint(): Unsupported surface format");
39 }
40
41 /* Perform clipping */
42 if (x < dst->clip_rect.x || y < dst->clip_rect.y ||
43 x >= (dst->clip_rect.x + dst->clip_rect.w) ||
44 y >= (dst->clip_rect.y + dst->clip_rect.h)) {
45 return 0;
46 }
47
48 switch (dst->format->BytesPerPixel) {
49 case 1:
50 DRAW_FASTSETPIXELXY1(x, y);
51 break;
52 case 2:
53 DRAW_FASTSETPIXELXY2(x, y);
54 break;
55 case 3:
56 return SDL_Unsupported();
57 case 4:
58 DRAW_FASTSETPIXELXY4(x, y);
59 break;
60 }
61 return 0;
62 }
63
64 int
65 SDL_DrawPoints(SDL_Surface * dst, const SDL_Point * points, int count,
66 Uint32 color)
67 {
68 int minx, miny;
69 int maxx, maxy;
70 int i;
71 int x, y;
72
73 if (!dst) {
74 return SDL_SetError("Passed NULL destination surface");
75 }
76
77 /* This function doesn't work on surfaces < 8 bpp */
78 if (dst->format->BitsPerPixel < 8) {
79 return SDL_SetError("SDL_DrawPoints(): Unsupported surface format");
80 }
81
82 minx = dst->clip_rect.x;
83 maxx = dst->clip_rect.x + dst->clip_rect.w - 1;
84 miny = dst->clip_rect.y;
85 maxy = dst->clip_rect.y + dst->clip_rect.h - 1;
86
87 for (i = 0; i < count; ++i) {
88 x = points[i].x;
89 y = points[i].y;
90
91 if (x < minx || x > maxx || y < miny || y > maxy) {
92 continue;
93 }
94
95 switch (dst->format->BytesPerPixel) {
96 case 1:
97 DRAW_FASTSETPIXELXY1(x, y);
98 break;
99 case 2:
100 DRAW_FASTSETPIXELXY2(x, y);
101 break;
102 case 3:
103 return SDL_Unsupported();
104 case 4:
105 DRAW_FASTSETPIXELXY4(x, y);
106 break;
107 }
108 }
109 return 0;
110 }
111
112 #endif /* !SDL_RENDER_DISABLED */
113
114 /* vi: set ts=4 sw=4 expandtab: */
color
GLuint color
Definition: glew.h:7185
SDL_PixelFormat::BytesPerPixel
Uint8 BytesPerPixel
Definition: SDL_pixels.h:277
DRAW_FASTSETPIXELXY1
#define DRAW_FASTSETPIXELXY1(x, y)
Definition: SDL_draw.h:42
DRAW_FASTSETPIXELXY4
#define DRAW_FASTSETPIXELXY4(x, y)
Definition: SDL_draw.h:44
x
EGLSurface EGLint x
Definition: eglext.h:293
SDL_Point
The structure that defines a point.
Definition: SDL_rect.h:47
SDL_Surface
A collection of pixels used in software blitting.
Definition: SDL_surface.h:69
SDL_config.h
Uint32
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:145
SDL_Point::x
int x
Definition: SDL_rect.h:49
dst
GLenum GLenum dst
Definition: glew.h:2396
SDL_Point::y
int y
Definition: SDL_rect.h:50
SDL_PixelFormat::BitsPerPixel
Uint8 BitsPerPixel
Definition: SDL_pixels.h:276
SDL_drawpoint.h
count
GLint GLsizei count
Definition: gl2ext.h:1011
SDL_SetError
DECLSPEC int SDLCALL SDL_SetError(const char *fmt,...)
Definition: SDL_error.c:53
SDL_Rect::x
int x
Definition: SDL_rect.h:65
SDL_Rect::w
int w
Definition: SDL_rect.h:66
SDL_Surface::clip_rect
SDL_Rect clip_rect
Definition: SDL_surface.h:85
y
EGLSurface EGLint EGLint y
Definition: eglext.h:293
DRAW_FASTSETPIXELXY2
#define DRAW_FASTSETPIXELXY2(x, y)
Definition: SDL_draw.h:43
SDL_Surface::format
SDL_PixelFormat * format
Definition: SDL_surface.h:72
SDL_DrawPoints
int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count, Uint32 color)
Definition: SDL_drawpoint.c:65
SDL_Rect::h
int h
Definition: SDL_rect.h:66
points
GLuint GLdouble GLdouble GLint GLint const GLdouble * points
Definition: glew.h:3337
i
int i
Definition: pngrutil.c:1377
SDL_draw.h
SDL_Rect::y
int y
Definition: SDL_rect.h:65
SDL_Unsupported
#define SDL_Unsupported()
Definition: SDL_error.h:53
SDL_DrawPoint
int SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color)
Definition: SDL_drawpoint.c:30