gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/agg-plot
diff options
context:
space:
mode:
Diffstat (limited to 'agg-plot')
-rw-r--r--agg-plot/lua-plot.cpp 2
-rw-r--r--agg-plot/plot.h 2
-rw-r--r--agg-plot/window-cpp.h 24
-rw-r--r--agg-plot/window.cpp 39
4 files changed, 49 insertions, 18 deletions
diff --git a/agg-plot/lua-plot.cpp b/agg-plot/lua-plot.cpp
index 72f00ba0..735bd8ba 100644
--- a/agg-plot/lua-plot.cpp
+++ b/agg-plot/lua-plot.cpp
@@ -125,6 +125,8 @@ canvas_new (lua_State *L)
{
lua_plot *p = push_new_object<lua_plot>(L, GS_PLOT);
+ p->sync_mode(false);
+
if (lua_isstring (L, 1))
{
const char *title = lua_tostring (L, 1);
diff --git a/agg-plot/plot.h b/agg-plot/plot.h
index 0e23f3e3..6bd54480 100644
--- a/agg-plot/plot.h
+++ b/agg-plot/plot.h
@@ -162,7 +162,7 @@ private:
static double
compute_scale(agg::trans_affine& m) {
- return min(m.sy, m.sx) / 400.0;
+ return min(m.sy, m.sx) / 480.0;
}
template <class VS, class RM>
diff --git a/agg-plot/window-cpp.h b/agg-plot/window-cpp.h
index 359520eb..5f636357 100644
--- a/agg-plot/window-cpp.h
+++ b/agg-plot/window-cpp.h
@@ -16,6 +16,25 @@ extern "C" {
#include "agg_trans_affine.h"
#include "split-parser.h"
+class opt_rect {
+ typedef agg::rect_base<int> rect_type;
+
+ bool m_defined;
+ rect_type m_rect;
+
+public:
+ opt_rect() : m_defined(false) {};
+
+ void clear() { m_defined = false; };
+ void set(const rect_type& r) { m_defined = true; m_rect = r; };
+ const rect_type& box() const { return m_rect; };
+
+ void compose(rect_type& dst, const rect_type& r)
+ {
+ dst = (m_defined ? agg::unite_rectangles(m_rect, r) : r);
+ };
+};
+
class window : public canvas_window {
public:
typedef plot<drawable, lua_management> plot_type;
@@ -33,8 +52,9 @@ public:
unsigned char *layer_buf;
agg::rendering_buffer layer_img;
- ref() : plot(0), matrix(), layer_buf(0) {};
- ref(plot_type *p) : plot(p), matrix(), layer_buf(0) {};
+ opt_rect dirty_rect;
+
+ ref(plot_type *p = 0) : plot(p), matrix(), layer_buf(0), dirty_rect() {};
~ref() { if (layer_buf) delete layer_buf; };
diff --git a/agg-plot/window.cpp b/agg-plot/window.cpp
index 51fe18d3..2a01999a 100644
--- a/agg-plot/window.cpp
+++ b/agg-plot/window.cpp
@@ -36,6 +36,17 @@ static const struct luaL_Reg window_methods[] = {
__END_DECLS
+struct dispose_buffer {
+ static void func (window::ref& ref)
+ {
+ if (ref.layer_buf)
+ {
+ delete [] ref.layer_buf;
+ ref.layer_buf = 0;
+ }
+ }
+};
+
agg::rect_base<int> rect_of_slot_matrix (const agg::trans_affine& mtx)
{
return agg::rect_base<int>(mtx.tx, mtx.ty, mtx.sx + mtx.tx, mtx.sy + mtx.ty);
@@ -163,7 +174,9 @@ void window::draw_slot_by_ref(window::ref& ref, bool update_req)
AGG_UNLOCK();
if (update_req)
- platform_support_update_region (this, r);
+ {
+ platform_support_update_region (this, r);
+ }
}
void
@@ -173,7 +186,10 @@ window::draw_slot(int slot_id, bool clean_req)
if (ref && m_canvas)
{
if (clean_req || ref->plot->need_redraw())
- draw_slot_by_ref(*ref, true);
+ {
+ draw_slot_by_ref(*ref, true);
+ dispose_buffer::func(*ref);
+ }
refresh_slot_by_ref(*ref);
}
@@ -209,6 +225,7 @@ window::restore_slot_image(int slot_id)
m_canvas->clear_box(r);
draw_slot_by_ref (*ref, false);
ref->save_image(this->rbuf_window(), r, this->bpp(), this->flip_y());
+ ref->dirty_rect.clear();
}
else
{
@@ -231,9 +248,12 @@ window::refresh_slot_by_ref(ref& ref)
if (ref.plot->draw_queue(*m_canvas, mtx, bb))
{
agg::rect_base<int> bbw(bb.x1 - 4, bb.y1 - 4, bb.x2 + 4, bb.y2 + 4);
- platform_support_update_region (this, bbw);
+ agg::rect_base<int> dbox;
+ ref.dirty_rect.compose(dbox, bbw);
+ platform_support_update_region (this, dbox);
+ ref.dirty_rect.set(bbw);
}
- }
+ }
catch (std::bad_alloc&) { }
AGG_UNLOCK();
}
@@ -248,17 +268,6 @@ window::on_draw()
draw_rec(m_tree);
}
-struct dispose_buffer {
- static void func (window::ref& ref)
- {
- if (ref.layer_buf)
- {
- delete [] ref.layer_buf;
- ref.layer_buf = 0;
- }
- }
-};
-
void
window::on_resize(int sx, int sy)
{
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月14日 09:40:22 +0000

AltStyle によって変換されたページ (->オリジナル) /