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
2525#include "surfacecollection.h"
2626#include "utilities.h"
2727
28#include <SDL_gfxPrimitives.h>
29
3028#include <algorithm>
3129#include <cassert>
3230#include <iostream>
...... 
161159}
162160
163161void 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    }
165183}
166184
167185void Surface::clearClipRect() {

Archive Download the corresponding diff file



interactive