25#ifndef AGG_BASICS_INCLUDED
26#define AGG_BASICS_INCLUDED
32#ifdef AGG_CUSTOM_ALLOCATOR
33#include "agg_allocator.h"
46 static T* allocate(
unsigned num) {
50 static void deallocate(
T* ptr,
unsigned) {
65 static T* allocate() {
69 static void deallocate(
T* ptr) {
83#define AGG_INT8 signed char
87#define AGG_INT8U unsigned char
91#define AGG_INT16 short
95#define AGG_INT16U unsigned short
103#define AGG_INT32U unsigned
107#if defined(_MSC_VER) || defined(__BORLANDC__)
108#define AGG_INT64 signed __int64
110#define AGG_INT64 signed long long
115#if defined(_MSC_VER) || defined(__BORLANDC__)
116#define AGG_INT64U unsigned __int64
118#define AGG_INT64U unsigned long long
124#pragma warning(disable : 4786)
128#define AGG_INLINE __forceinline
130#define AGG_INLINE inline
135typedef AGG_INT8 int8;
136typedef AGG_INT8U int8u;
137typedef AGG_INT16 int16;
138typedef AGG_INT16U int16u;
139typedef AGG_INT32 int32;
140typedef AGG_INT32U int32u;
141typedef AGG_INT64 int64;
142typedef AGG_INT64U int64u;
144#if defined(AGG_FISTP)
146#pragma warning(disable : 4035)
147AGG_INLINE
int iround(
double v)
150 __asm fld qword ptr[v] __asm fistp dword ptr[t] __asm mov eax, dword ptr[t]
152AGG_INLINE
unsigned uround(
double v)
155 __asm fld qword ptr[v] __asm fistp dword ptr[t] __asm mov eax, dword ptr[t]
158AGG_INLINE
unsigned ufloor(
double v)
160 return unsigned(floor(v));
162AGG_INLINE
unsigned uceil(
double v)
164 return unsigned(ceil(v));
166#elif defined(AGG_QIFIST)
167AGG_INLINE
int iround(
double v) {
170AGG_INLINE
int uround(
double v) {
173AGG_INLINE
unsigned ufloor(
double v) {
174 return unsigned(floor(v));
176AGG_INLINE
unsigned uceil(
double v) {
177 return unsigned(ceil(v));
181AGG_INLINE
int iround(
double v) {
182 return int((v < 0.0) ? v - 0.5 : v + 0.5);
185AGG_INLINE
int uround(
double v) {
186 return unsigned(v + 0.5);
189AGG_INLINE
unsigned ufloor(
double v) {
193AGG_INLINE
unsigned uceil(
double v) {
194 return unsigned(ceil(v));
202 AGG_INLINE
static int iround(
double v) {
205 return agg::iround(
v);
210template <
unsigned Shift>
212 AGG_INLINE
static unsigned mul(
unsigned a,
unsigned b) {
213 register unsigned q = a *
b + (1 << (
Shift - 1));
222 cover_size = 1 << cover_shift,
223 cover_mask = cover_size - 1,
225 cover_full = cover_mask
234enum poly_subpixel_scale_e {
235 poly_subpixel_shift = 8,
236 poly_subpixel_scale = 1 << poly_subpixel_shift,
237 poly_subpixel_mask = poly_subpixel_scale - 1,
247const double pi = 3.14159265358979323846;
250inline double deg2rad(
double deg) {
251 return deg * pi / 180.0;
255inline double rad2deg(
double rad) {
256 return rad * 180.0 / pi;
297 if (x2 >
r.x2) x2 =
r.x2;
298 if (y2 >
r.y2) y2 =
r.y2;
299 if (x1 <
r.x1) x1 =
r.x1;
300 if (y1 <
r.y1) y1 =
r.y1;
301 return x1 <= x2 && y1 <= y2;
304 bool is_valid()
const {
305 return x1 <= x2 && y1 <= y2;
308 bool hit_test(
T x,
T y)
const {
323 if (
r.x2 >
r2.x2)
r.x2 =
r2.x2;
324 if (
r.y2 >
r2.y2)
r.y2 =
r2.y2;
325 if (
r.x1 <
r2.x1)
r.x1 =
r2.x1;
326 if (
r.y1 <
r2.y1)
r.y1 =
r2.y1;
332inline Rect unite_rectangles(
const Rect& r1,
const Rect& r2) {
334 if (r.x2 < r2.x2) r.x2 = r2.x2;
335 if (r.y2 < r2.y2) r.y2 = r2.y2;
336 if (r.x1 > r2.x1) r.x1 = r2.x1;
337 if (r.y1 > r2.y1) r.y1 = r2.y1;
341typedef rect_base<int> rect_i;
342typedef rect_base<float> rect_f;
343typedef rect_base<double> rect_d;
346enum path_commands_e {
348 path_cmd_move_to = 1,
349 path_cmd_line_to = 2,
354 path_cmd_ubspline = 7,
355 path_cmd_end_poly = 0x0F,
362 path_flags_ccw = 0x10,
363 path_flags_cw = 0x20,
364 path_flags_close = 0x40,
365 path_flags_mask = 0xF0
369inline bool is_vertex(
unsigned c) {
370 return c >= path_cmd_move_to && c < path_cmd_end_poly;
374inline bool is_drawing(
unsigned c) {
375 return c >= path_cmd_line_to && c < path_cmd_end_poly;
379inline bool is_stop(
unsigned c) {
380 return c == path_cmd_stop;
384inline bool is_move_to(
unsigned c) {
385 return c == path_cmd_move_to;
389inline bool is_line_to(
unsigned c) {
390 return c == path_cmd_line_to;
394inline bool is_curve(
unsigned c) {
395 return c == path_cmd_curve3 || c == path_cmd_curve4;
399inline bool is_curve3(
unsigned c) {
400 return c == path_cmd_curve3;
404inline bool is_curve4(
unsigned c) {
405 return c == path_cmd_curve4;
409inline bool is_end_poly(
unsigned c) {
410 return (c & path_cmd_mask) == path_cmd_end_poly;
414inline bool is_close(
unsigned c) {
415 return (c & ~(path_flags_cw | path_flags_ccw)) == (path_cmd_end_poly | path_flags_close);
419inline bool is_next_poly(
unsigned c) {
420 return is_stop(c) || is_move_to(c) || is_end_poly(c);
424inline bool is_cw(
unsigned c) {
425 return (c & path_flags_cw) != 0;
429inline bool is_ccw(
unsigned c) {
430 return (c & path_flags_ccw) != 0;
434inline bool is_oriented(
unsigned c) {
435 return (c & (path_flags_cw | path_flags_ccw)) != 0;
439inline bool is_closed(
unsigned c) {
440 return (c & path_flags_close) != 0;
444inline unsigned get_close_flag(
unsigned c) {
445 return c & path_flags_close;
449inline unsigned clear_orientation(
unsigned c) {
450 return c & ~(path_flags_cw | path_flags_ccw);
454inline unsigned get_orientation(
unsigned c) {
455 return c & (path_flags_cw | path_flags_ccw);
459inline unsigned set_orientation(
unsigned c,
unsigned o) {
460 return clear_orientation(c) | o;
Definition agg_array.h:259
Definition agg_basics.h:517
Definition agg_basics.h:211
Definition agg_basics.h:64
Definition agg_basics.h:45
Definition agg_basics.h:465
Definition agg_basics.h:261
Definition agg_basics.h:503
Definition agg_basics.h:201
Definition agg_basics.h:484