1
//----------------------------------------------------------------------------
2
// Anti-Grain Geometry - Version 2.3
3
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
5
// Permission to copy, use, modify, sell and distribute this software
6
// is granted provided this copyright notice appears in all copies.
7
// This software is provided "as is" without express or implied
8
// warranty, and with no claim as to its suitability for any purpose.
10
//----------------------------------------------------------------------------
11
// Contact: mcseem@antigrain.com
12
// mcseemagg@yahoo.com
13
// http://www.antigrain.com
14
//----------------------------------------------------------------------------
16
// class rendering_buffer
18
//----------------------------------------------------------------------------
20
#ifndef AGG_RENDERING_BUFFER_INCLUDED
21
#define AGG_RENDERING_BUFFER_INCLUDED
23
#include "agg_basics.h"
28
//==========================================================row_ptr_cache
29
template<class T> class row_ptr_cache
32
//--------------------------------------------------------------------
38
row_data(int x1_, int x2_, const int8u* ptr_) :
39
x1(x1_), x2(x2_), ptr(ptr_) {}
42
//--------------------------------------------------------------------
49
span_data(int) : x(0), len(0), ptr(0) {}
50
span_data(int x_, unsigned len_, int8u* ptr_) :
51
x(x_), len(len_), ptr(ptr_) {}
54
//-------------------------------------------------------------------
60
//-------------------------------------------------------------------
71
//--------------------------------------------------------------------
72
row_ptr_cache(T* buf, unsigned width, unsigned height, int stride) :
80
attach(buf, width, height, stride);
83
//--------------------------------------------------------------------
84
void attach(T* buf, unsigned width, unsigned height, int stride)
90
if(height > m_max_height)
93
m_rows = new T* [m_max_height = height];
100
row_ptr = m_buf - int(height - 1) * stride;
112
//--------------------------------------------------------------------
113
T* buf() { return m_buf; }
114
const T* buf() const { return m_buf; }
115
unsigned width() const { return m_width; }
116
unsigned height() const { return m_height; }
117
int stride() const { return m_stride; }
118
unsigned stride_abs() const
120
return (m_stride < 0) ?
121
unsigned(-m_stride) :
125
//--------------------------------------------------------------------
126
T* row(unsigned y) { return m_rows[y]; }
127
const T* row(unsigned y) const { return m_rows[y]; }
129
T* next_row(void* p) { return (T*)p + m_stride; }
130
const T* next_row(const void* p) const { return (T*)p + m_stride; }
132
T const* const* rows() const { return m_rows; }
134
//--------------------------------------------------------------------
135
void copy_from(const row_ptr_cache<T>& mtx)
137
unsigned h = height();
138
if(mtx.height() < h) h = mtx.height();
140
unsigned l = stride_abs();
141
if(mtx.stride_abs() < l) l = mtx.stride_abs();
146
for (y = 0; y < h; y++)
148
memcpy(row(y), mtx.row(y), l);
152
//--------------------------------------------------------------------
156
for(y = 0; y < height(); y++)
160
for(x = 0; x < stride_abs(); x++)
169
//--------------------------------------------------------------------
171
row_ptr_cache(const row_ptr_cache<T>&);
172
const row_ptr_cache<T>& operator = (const row_ptr_cache<T>&);
175
//--------------------------------------------------------------------
176
T* m_buf; // Pointer to renrdering buffer
177
T** m_rows; // Pointers to each row of the buffer
178
unsigned m_width; // Width in pixels
179
unsigned m_height; // Height in pixels
180
int m_stride; // Number of bytes per row. Can be < 0
181
unsigned m_max_height; // The maximal height (currently allocated)
186
//========================================================rendering_buffer
187
typedef row_ptr_cache<int8u> rendering_buffer;