20 #ifndef AGG_RENDERING_BUFFER_INCLUDED 21 #define AGG_RENDERING_BUFFER_INCLUDED 24 #include "agg_array.h" 46 row_accessor(T* buf,
unsigned width,
unsigned height,
int stride) :
53 attach(buf, width, height, stride);
58 void attach(T* buf,
unsigned width,
unsigned height,
int stride)
60 m_buf = m_start = buf;
66 m_start = m_buf - (AGG_INT64)(height - 1) * stride;
71 AGG_INLINE T* buf() {
return m_buf; }
72 AGG_INLINE
const T* buf()
const {
return m_buf; }
73 AGG_INLINE
unsigned width()
const {
return m_width; }
74 AGG_INLINE
unsigned height()
const {
return m_height; }
75 AGG_INLINE
int stride()
const {
return m_stride; }
76 AGG_INLINE
unsigned stride_abs()
const 78 return (m_stride < 0) ? unsigned(-m_stride) : unsigned(m_stride);
82 AGG_INLINE T* row_ptr(
int,
int y,
unsigned)
84 return m_start + y * (AGG_INT64)m_stride;
86 AGG_INLINE T* row_ptr(
int y) {
return m_start + y * (AGG_INT64)m_stride; }
87 AGG_INLINE
const T* row_ptr(
int y)
const {
return m_start + y * (AGG_INT64)m_stride; }
88 AGG_INLINE row_data row (
int y)
const 90 return row_data(0, m_width-1, row_ptr(y));
94 template<
class RenBuf>
95 void copy_from(
const RenBuf& src)
97 unsigned h = height();
98 if(src.height() < h) h = src.height();
100 unsigned l = stride_abs();
101 if(src.stride_abs() < l) l = src.stride_abs();
106 unsigned w = width();
107 for (y = 0; y < h; y++)
109 std::memcpy(row_ptr(0, y, w), src.row_ptr(y), l);
117 unsigned w = width();
118 unsigned stride = stride_abs();
119 for(y = 0; y < height(); y++)
121 T* p = row_ptr(0, y, w);
123 for(x = 0; x < stride; x++)
159 row_ptr_cache(T* buf,
unsigned width,
unsigned height,
int stride) :
166 attach(buf, width, height, stride);
170 void attach(T* buf,
unsigned width,
unsigned height,
int stride)
176 if(height > m_rows.size())
178 m_rows.resize(height);
185 row_ptr = m_buf - (AGG_INT64)(height - 1) * stride;
188 T** rows = &m_rows[0];
198 AGG_INLINE T* buf() {
return m_buf; }
199 AGG_INLINE
const T* buf()
const {
return m_buf; }
200 AGG_INLINE
unsigned width()
const {
return m_width; }
201 AGG_INLINE
unsigned height()
const {
return m_height; }
202 AGG_INLINE
int stride()
const {
return m_stride; }
203 AGG_INLINE
unsigned stride_abs()
const 205 return (m_stride < 0) ? unsigned(-m_stride) : unsigned(m_stride);
209 AGG_INLINE T* row_ptr(
int,
int y,
unsigned)
213 AGG_INLINE T* row_ptr(
int y) {
return m_rows[y]; }
214 AGG_INLINE
const T* row_ptr(
int y)
const {
return m_rows[y]; }
215 AGG_INLINE row_data row (
int y)
const 217 return row_data(0, m_width-1, m_rows[y]);
221 T
const*
const* rows()
const {
return &m_rows[0]; }
224 template<
class RenBuf>
225 void copy_from(
const RenBuf& src)
227 unsigned h = height();
228 if(src.height() < h) h = src.height();
230 unsigned l = stride_abs();
231 if(src.stride_abs() < l) l = src.stride_abs();
236 unsigned w = width();
237 for (y = 0; y < h; y++)
239 std::memcpy(row_ptr(0, y, w), src.row_ptr(y), l);
247 unsigned w = width();
248 unsigned stride = stride_abs();
249 for(y = 0; y < height(); y++)
251 T* p = row_ptr(0, y, w);
253 for(x = 0; x < stride; x++)
291 #ifdef AGG_RENDERING_BUFFER