Debian Codegraph @

common/2d/pixel.cpp

raw
1 /*
2 * Portions of this file are copyright Rebirth contributors and licensed as
3 * described in COPYING.txt.
4 * Portions of this file are copyright Parallax Software and licensed
5 * according to the Parallax license below.
6 * See COPYING.txt for license details.
7
8 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
9 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
10 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
11 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
12 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
13 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
14 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
15 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
16 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
17 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
18 */
19
20 /*
21 *
22 * Graphical routines for setting a pixel.
23 *
24 */
25
26 #include "u_mem.h"
27 #include "gr.h"
28 #if DXX_USE_OGL
29 #include "ogl_init.h"
30 #endif
31
32 namespace dcx {
33
34 void gr_upixel(grs_bitmap &cv_bitmap, const unsigned x, const unsigned y, const color_palette_index color)
35 {
36 switch (cv_bitmap.get_type())
37 {
38 #if DXX_USE_OGL
39 case bm_mode::ogl:
40 ogl_upixelc(cv_bitmap, x, y, color);
41 return;
42 #endif
43 case bm_mode::linear:
44 cv_bitmap.get_bitmap_data()[cv_bitmap.bm_rowsize * y + x] = color;
45 return;
46 case bm_mode::ilbm:
47 case bm_mode::rgb15:
48 break;
49 }
50 }
51
52 void gr_pixel(grs_bitmap &cv_bitmap, const unsigned x, const unsigned y, const color_palette_index color)
53 {
54 if (unlikely(x >= cv_bitmap.bm_w || y >= cv_bitmap.bm_h))
55 return;
56 gr_upixel(cv_bitmap, x, y, color);
57 }
58
59 namespace {
60
61 #if !DXX_USE_OGL
62 #define gr_bm_upixel(C,B,X,Y,C2) gr_bm_upixel(B,X,Y,C2)
63 #endif
64 static inline void gr_bm_upixel(grs_canvas &canvas, grs_bitmap &bm, const uint_fast32_t x, const uint_fast32_t y, const color_palette_index color)
65 {
66 switch (bm.get_type())
67 {
68 #if DXX_USE_OGL
69 case bm_mode::ogl:
70 ogl_upixelc(canvas.cv_bitmap, bm.bm_x + x, bm.bm_y + y, color);
71 return;
72 #endif
73 case bm_mode::linear:
74 bm.get_bitmap_data()[bm.bm_rowsize*y+x] = color;
75 return;
76 case bm_mode::rgb15:
77 case bm_mode::ilbm:
78 break;
79 }
80 }
81
82 }
83
84 void gr_bm_pixel(grs_canvas &canvas, grs_bitmap &bm, const uint_fast32_t x, const uint_fast32_t y, const color_palette_index color)
85 {
86 if (unlikely(x >= bm.bm_w || y >= bm.bm_h))
87 return;
88 gr_bm_upixel(canvas, bm, x, y, color);
89 }
90
91 }