Date: | 2014-07-19 00:30:22 (9 years 8 months ago) |
---|---|
Author: | Maarten ter Huurne |
Commit: | 08ffbc76deed48fef6cf42bb27bf5e913667cd89 |
Message: | Use our own alpha blended rectangle outline instead of SDL_gfx I implemented it as four 1-pixel-wide filled rectangles. While this is not the fastest way to do it, I doubt this will have a significant impact on overall performance. Note that the proper way to clip a rectangle outline is to clip the outline's four lines individually, not clip the rectangle and then draw a smaller rectangle outline. This means that an optimized drawing routine would have to be aware of whether clipping occurs, complicating the code. |
Files: |
src/surface.cpp (2 diffs) |
Change Details
src/surface.cpp | ||
---|---|---|
25 | 25 | #include "surfacecollection.h" |
26 | 26 | #include "utilities.h" |
27 | 27 | |
28 | #include <SDL_gfxPrimitives.h> | |
29 | ||
30 | 28 | #include <algorithm> |
31 | 29 | #include <cassert> |
32 | 30 | #include <iostream> |
... | ... | |
161 | 159 | } |
162 | 160 | |
163 | 161 | void Surface::rectangle(SDL_Rect re, RGBAColor c) { |
164 | rectangleRGBA(raw, re.x, re.y, re.x + re.w - 1, re.y + re.h - 1, c.r, c.g, c.b, c.a); | |
162 | if (re.h >= 1) { | |
163 | // Top. | |
164 | box(SDL_Rect { re.x, re.y, re.w, 1 }, c); | |
165 | } | |
166 | if (re.h >= 2) { | |
167 | Sint16 ey = re.y + re.h - 1; | |
168 | // Bottom. | |
169 | box(SDL_Rect { re.x, ey, re.w, 1 }, c); | |
170 | ||
171 | Sint16 ex = re.x + re.w - 1; | |
172 | Sint16 sy = re.y + 1; | |
173 | Uint16 sh = re.h - 2; | |
174 | // Left. | |
175 | if (re.w >= 1) { | |
176 | box(SDL_Rect { re.x, sy, 1, sh }, c); | |
177 | } | |
178 | // Right. | |
179 | if (re.w >= 2) { | |
180 | box(SDL_Rect { ex, sy, 1, sh }, c); | |
181 | } | |
182 | } | |
165 | 183 | } |
166 | 184 | |
167 | 185 | void Surface::clearClipRect() { |
Branches:
install_locations
master
opkrun
packages