author | Francesco Abbate <francesco.bbt@gmail.com> | 2010年08月23日 23:11:38 +0200 |
---|---|---|
committer | Francesco Abbate <francesco.bbt@gmail.com> | 2010年08月23日 23:11:38 +0200 |
commit | d73491e40e2121d5e7ecb189bb0d32ebf3c59b40 (patch) | |
tree | 205bc9c03131ea1de25067e81f26cc7f42517b5c | |
parent | fa2caafa71b81c34fccce6d16ae99ed47cf6f09f (diff) | |
download | gsl-shell-d73491e40e2121d5e7ecb189bb0d32ebf3c59b40.tar.gz |
-rw-r--r-- | agg-plot/agg_platform_support_x11.cpp | 11 | ||||
-rw-r--r-- | agg-plot/platform_support_ext.h | 10 | ||||
-rw-r--r-- | agg-plot/window-cpp.h | 1 | ||||
-rw-r--r-- | agg-plot/window.cpp | 40 |
diff --git a/agg-plot/agg_platform_support_x11.cpp b/agg-plot/agg_platform_support_x11.cpp index 8e3ef2f5..4eec5814 100644 --- a/agg-plot/agg_platform_support_x11.cpp +++ b/agg-plot/agg_platform_support_x11.cpp @@ -44,9 +44,7 @@ void my_color_conv(RenBufDst* dst, const RenBufSrc* src, CopyRow copy_row_functo for(unsigned int y = 0; y < height; y++) { - copy_row_functor(dst->row_ptr(0, y, width), - src->row_ptr(y), - width); + copy_row_functor(dst->row_ptr(0, y, width), src->row_ptr(y), width); } } @@ -79,11 +77,11 @@ public: private: //-------------------------------------------------------------------- - const T* m_buf; // Pointer to renrdering buffer + const T* m_buf; // Pointer to renrdering buffer unsigned m_width; // Width in pixels unsigned m_height; // Height in pixels int m_stride; // Number of bytes per row. Can be < 0 - const T* m_start; // Pointer to first pixel depending on stride + const T* m_start; // Pointer to first pixel depending on stride }; namespace agg @@ -322,7 +320,8 @@ namespace agg unsigned char* buf_tmp = new unsigned char[row_len * h]; const unsigned char *src_start = src->row_ptr(m_flip_y ? y + h - 1 : y); - row_accessor_ro<unsigned char> src_box(src_start + 3*x, w, h, src->stride()); + const unsigned int pix_width = m_bpp / 8; + row_accessor_ro<unsigned char> src_box(src_start + pix_width * x, w, h, src->stride()); rendering_buffer rbuf_tmp; rbuf_tmp.attach(buf_tmp, w, h, m_flip_y ? -row_len : row_len); diff --git a/agg-plot/platform_support_ext.h b/agg-plot/platform_support_ext.h index ed9cd8fd..5572ba6d 100644 --- a/agg-plot/platform_support_ext.h +++ b/agg-plot/platform_support_ext.h @@ -4,11 +4,11 @@ #include "agg_basics.h" #include "platform/agg_platform_support.h" -extern void platform_support_prepare (); -extern void platform_support_lock (agg::platform_support *app); -extern void platform_support_unlock (agg::platform_support *app); -extern bool platform_support_is_mapped (agg::platform_support *app); -extern void platform_support_close_window (agg::platform_support *app); +extern void platform_support_prepare (); +extern void platform_support_lock (agg::platform_support *app); +extern void platform_support_unlock (agg::platform_support *app); +extern bool platform_support_is_mapped (agg::platform_support *app); +extern void platform_support_close_window (agg::platform_support *app); extern void platform_support_update_region (agg::platform_support *app, const agg::rect_base<int>& r); diff --git a/agg-plot/window-cpp.h b/agg-plot/window-cpp.h index 78d16ec0..e50c4a30 100644 --- a/agg-plot/window-cpp.h +++ b/agg-plot/window-cpp.h @@ -39,6 +39,7 @@ public: }; private: + void draw_slot_by_ref(ref& ref, bool dirty); void draw_rec(ref::node *n); void cleanup_tree_rec (lua_State *L, int window_index, ref::node* n); diff --git a/agg-plot/window.cpp b/agg-plot/window.cpp index 7099dd21..85fdab76 100644 --- a/agg-plot/window.cpp +++ b/agg-plot/window.cpp @@ -96,12 +96,7 @@ window::draw_rec(ref::node *n) ref *ref = n->content(); if (ref) { - if (ref->plot) - { - agg::trans_affine mtx(ref->matrix); - this->scale(mtx); - ref->plot->draw(*m_canvas, mtx); - } + draw_slot_by_ref (*ref, false); } } @@ -125,6 +120,26 @@ window::ref* window::ref_lookup (ref::node *p, int slot_id) return NULL; } +void window::draw_slot_by_ref(window::ref& ref, bool dirty) +{ + if (! ref.plot) + return; + + agg::trans_affine mtx(ref.matrix); + this->scale(mtx); + + if (dirty) + { + agg::rect_base<int> r = rect_of_slot_matrix(mtx); + m_canvas->clear_box(r); + ref.plot->draw(*m_canvas, mtx); + platform_support_update_region (this, r); + } + else + { + ref.plot->draw(*m_canvas, mtx); + } +} void window::draw_slot(int slot_id, bool update_req) @@ -132,16 +147,7 @@ window::draw_slot(int slot_id, bool update_req) ref *ref = window::ref_lookup (this->m_tree, slot_id); if (ref && m_canvas) { - agg::trans_affine mtx(ref->matrix); - this->scale(mtx); - - agg::rect_base<int> r = rect_of_slot_matrix(mtx); - m_canvas->clear_box(r); - - ref->plot->draw(*m_canvas, mtx); - - if (update_req) - platform_support_update_region (this, r); + draw_slot_by_ref(*ref, update_req); } } @@ -319,8 +325,6 @@ window_attach (lua_State *L) plot->slot_id = slot_id; win->draw_slot(slot_id, true); - /* win->on_draw(); - win->update_window(); */ win->unlock(); |