* long overdue update to AGG 2.4
* removed the useless parts of AGG (which are only needed for the interactive examples) * make sure to jam -a libagg.a to solve any linking issues git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17838 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// Anti-Grain Geometry - Version 2.2
|
||||
// Copyright (C) 2002-2004 Maxim Shemanarev (http://www.antigrain.com)
|
||||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
@@ -22,7 +22,7 @@
|
||||
#define AGG_TRANS_VIEWPORT_INCLUDED
|
||||
|
||||
#include <string.h>
|
||||
#include "agg_basics.h"
|
||||
#include "agg_trans_affine.h"
|
||||
|
||||
|
||||
namespace agg
|
||||
@@ -51,6 +51,7 @@ namespace agg
|
||||
m_device_x2(1.0),
|
||||
m_device_y2(1.0),
|
||||
m_aspect(aspect_ratio_stretch),
|
||||
m_is_valid(true),
|
||||
m_align_x(0.5),
|
||||
m_align_y(0.5),
|
||||
m_wx1(0.0),
|
||||
@@ -123,6 +124,7 @@ namespace agg
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
bool is_valid() const { return m_is_valid; }
|
||||
double align_x() const { return m_align_x; }
|
||||
double align_y() const { return m_align_y; }
|
||||
aspect_ratio_e aspect_ratio() const { return m_aspect; }
|
||||
@@ -134,6 +136,13 @@ namespace agg
|
||||
*y = (*y - m_wy1) * m_ky + m_dy1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
void transform_scale_only(double* x, double* y) const
|
||||
{
|
||||
*x *= m_kx;
|
||||
*y *= m_ky;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
void inverse_transform(double* x, double* y) const
|
||||
{
|
||||
@@ -141,6 +150,17 @@ namespace agg
|
||||
*y = (*y - m_dy1) / m_ky + m_wy1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
void inverse_transform_scale_only(double* x, double* y) const
|
||||
{
|
||||
*x /= m_kx;
|
||||
*y /= m_ky;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
double device_dx() const { return m_dx1 - m_wx1 * m_kx; }
|
||||
double device_dy() const { return m_dy1 - m_wy1 * m_ky; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
double scale_x() const
|
||||
{
|
||||
@@ -159,76 +179,35 @@ namespace agg
|
||||
return (m_kx + m_ky) * 0.5;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
trans_affine to_affine() const
|
||||
{
|
||||
trans_affine mtx = trans_affine_translation(-m_wx1, -m_wy1);
|
||||
mtx *= trans_affine_scaling(m_kx, m_ky);
|
||||
mtx *= trans_affine_translation(m_dx1, m_dy1);
|
||||
return mtx;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
trans_affine to_affine_scale_only() const
|
||||
{
|
||||
return trans_affine_scaling(m_kx, m_ky);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
unsigned byte_size() const
|
||||
{
|
||||
return
|
||||
sizeof(m_world_x1) +
|
||||
sizeof(m_world_y1) +
|
||||
sizeof(m_world_x2) +
|
||||
sizeof(m_world_y2) +
|
||||
sizeof(m_device_x1) +
|
||||
sizeof(m_device_y1) +
|
||||
sizeof(m_device_x2) +
|
||||
sizeof(m_device_y2) +
|
||||
sizeof(m_aspect) +
|
||||
sizeof(m_align_x) +
|
||||
sizeof(m_align_y) +
|
||||
sizeof(m_wx1) +
|
||||
sizeof(m_wy1) +
|
||||
sizeof(m_wx2) +
|
||||
sizeof(m_wy2) +
|
||||
sizeof(m_dx1) +
|
||||
sizeof(m_dy1) +
|
||||
sizeof(m_kx) +
|
||||
sizeof(m_ky);
|
||||
return sizeof(*this);
|
||||
}
|
||||
|
||||
void serialize(int8u* ptr) const
|
||||
{
|
||||
memcpy(ptr, &m_world_x1, sizeof(m_world_x1)); ptr += sizeof(m_world_x1);
|
||||
memcpy(ptr, &m_world_y1, sizeof(m_world_y1)); ptr += sizeof(m_world_y1);
|
||||
memcpy(ptr, &m_world_x2, sizeof(m_world_x2)); ptr += sizeof(m_world_x2);
|
||||
memcpy(ptr, &m_world_y2, sizeof(m_world_y2)); ptr += sizeof(m_world_y2);
|
||||
memcpy(ptr, &m_device_x1, sizeof(m_device_x1)); ptr += sizeof(m_device_x1);
|
||||
memcpy(ptr, &m_device_y1, sizeof(m_device_y1)); ptr += sizeof(m_device_y1);
|
||||
memcpy(ptr, &m_device_x2, sizeof(m_device_x2)); ptr += sizeof(m_device_x2);
|
||||
memcpy(ptr, &m_device_y2, sizeof(m_device_y2)); ptr += sizeof(m_device_y2);
|
||||
memcpy(ptr, &m_aspect, sizeof(m_aspect)); ptr += sizeof(m_aspect);
|
||||
memcpy(ptr, &m_align_x, sizeof(m_align_x)); ptr += sizeof(m_align_x);
|
||||
memcpy(ptr, &m_align_y, sizeof(m_align_y)); ptr += sizeof(m_align_y);
|
||||
memcpy(ptr, &m_wx1, sizeof(m_wx1)); ptr += sizeof(m_wx1);
|
||||
memcpy(ptr, &m_wy1, sizeof(m_wy1)); ptr += sizeof(m_wy1);
|
||||
memcpy(ptr, &m_wx2, sizeof(m_wx2)); ptr += sizeof(m_wx2);
|
||||
memcpy(ptr, &m_wy2, sizeof(m_wy2)); ptr += sizeof(m_wy2);
|
||||
memcpy(ptr, &m_dx1, sizeof(m_dx1)); ptr += sizeof(m_dx1);
|
||||
memcpy(ptr, &m_dy1, sizeof(m_dy1)); ptr += sizeof(m_dy1);
|
||||
memcpy(ptr, &m_kx, sizeof(m_kx)); ptr += sizeof(m_kx);
|
||||
memcpy(ptr, &m_ky, sizeof(m_ky)); ptr += sizeof(m_ky);
|
||||
memcpy(ptr, this, sizeof(*this));
|
||||
}
|
||||
|
||||
void deserialize(const int8u* ptr)
|
||||
{
|
||||
memcpy(&m_world_x1, ptr, sizeof(m_world_x1)); ptr += sizeof(m_world_x1);
|
||||
memcpy(&m_world_y1, ptr, sizeof(m_world_y1)); ptr += sizeof(m_world_y1);
|
||||
memcpy(&m_world_x2, ptr, sizeof(m_world_x2)); ptr += sizeof(m_world_x2);
|
||||
memcpy(&m_world_y2, ptr, sizeof(m_world_y2)); ptr += sizeof(m_world_y2);
|
||||
memcpy(&m_device_x1, ptr, sizeof(m_device_x1)); ptr += sizeof(m_device_x1);
|
||||
memcpy(&m_device_y1, ptr, sizeof(m_device_y1)); ptr += sizeof(m_device_y1);
|
||||
memcpy(&m_device_x2, ptr, sizeof(m_device_x2)); ptr += sizeof(m_device_x2);
|
||||
memcpy(&m_device_y2, ptr, sizeof(m_device_y2)); ptr += sizeof(m_device_y2);
|
||||
memcpy(&m_aspect, ptr, sizeof(m_aspect)); ptr += sizeof(m_aspect);
|
||||
memcpy(&m_align_x, ptr, sizeof(m_align_x)); ptr += sizeof(m_align_x);
|
||||
memcpy(&m_align_y, ptr, sizeof(m_align_y)); ptr += sizeof(m_align_y);
|
||||
memcpy(&m_wx1, ptr, sizeof(m_wx1)); ptr += sizeof(m_wx1);
|
||||
memcpy(&m_wy1, ptr, sizeof(m_wy1)); ptr += sizeof(m_wy1);
|
||||
memcpy(&m_wx2, ptr, sizeof(m_wx2)); ptr += sizeof(m_wx2);
|
||||
memcpy(&m_wy2, ptr, sizeof(m_wy2)); ptr += sizeof(m_wy2);
|
||||
memcpy(&m_dx1, ptr, sizeof(m_dx1)); ptr += sizeof(m_dx1);
|
||||
memcpy(&m_dy1, ptr, sizeof(m_dy1)); ptr += sizeof(m_dy1);
|
||||
memcpy(&m_kx, ptr, sizeof(m_kx)); ptr += sizeof(m_kx);
|
||||
memcpy(&m_ky, ptr, sizeof(m_ky)); ptr += sizeof(m_ky);
|
||||
memcpy(this, ptr, sizeof(*this));
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -243,6 +222,7 @@ namespace agg
|
||||
double m_device_x2;
|
||||
double m_device_y2;
|
||||
aspect_ratio_e m_aspect;
|
||||
bool m_is_valid;
|
||||
double m_align_x;
|
||||
double m_align_y;
|
||||
double m_wx1;
|
||||
@@ -260,6 +240,24 @@ namespace agg
|
||||
//-----------------------------------------------------------------------
|
||||
inline void trans_viewport::update()
|
||||
{
|
||||
const double epsilon = 1e-30;
|
||||
if(fabs(m_world_x1 - m_world_x2) < epsilon ||
|
||||
fabs(m_world_y1 - m_world_y2) < epsilon ||
|
||||
fabs(m_device_x1 - m_device_x2) < epsilon ||
|
||||
fabs(m_device_y1 - m_device_y2) < epsilon)
|
||||
{
|
||||
m_wx1 = m_world_x1;
|
||||
m_wy1 = m_world_y1;
|
||||
m_wx2 = m_world_x1 + 1.0;
|
||||
m_wy2 = m_world_y2 + 1.0;
|
||||
m_dx1 = m_device_x1;
|
||||
m_dy1 = m_device_y1;
|
||||
m_kx = 1.0;
|
||||
m_ky = 1.0;
|
||||
m_is_valid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
double world_x1 = m_world_x1;
|
||||
double world_y1 = m_world_y1;
|
||||
double world_x2 = m_world_x2;
|
||||
@@ -295,6 +293,7 @@ namespace agg
|
||||
m_dy1 = device_y1;
|
||||
m_kx = (device_x2 - device_x1) / (world_x2 - world_x1);
|
||||
m_ky = (device_y2 - device_y1) / (world_y2 - world_y1);
|
||||
m_is_valid = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user