- The problem with CairoWidget was that it did scale a pixmap of ~100x100

with a *factor* of ~640x480. That means ~64*48*10^6*3 bytes = a ~1.1 Gb RAM pixmap.
The problem didn't show in versions of cairo >= 1.2 because it automagically
clips (yeah, cairo programmers *are* smart :-))
It is temporary fixed for the moment, will be made better asap.


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@892 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-08-17 17:03:42 +00:00
parent 09ad981251
commit f42eea8514
3 changed files with 18 additions and 3 deletions

View File

@ -27,6 +27,7 @@
#include <gdkmm/window.h>
#include <cassert>
#include <iostream>
#include <memory>
using namespace sgpem;
@ -73,6 +74,7 @@ CairoWidget::update(const History& history)
cairo_t* ctx = gdk_cairo_create(_buf->gobj());
// do the drawing...
std::cout << " Dimensions, w : " << _w << ", h : " << _h << std::endl;
cairo_scale(ctx, _w, _h);
draw_widget(ctx);
cairo_destroy(ctx);
@ -133,6 +135,16 @@ CairoWidget::on_size_allocate(const Gtk::Allocation& allocation)
}
void
CairoWidget::on_size_request(Gtk::Requisition* requisition)
{
*requisition = Gtk::Requisition();
requisition->width = _w;
requisition->height = _h;
}
bool
CairoWidget::on_expose_event(GdkEventExpose* event)
{

View File

@ -44,6 +44,7 @@ namespace sgpem
virtual void on_realize();
virtual void on_size_allocate(const Gtk::Allocation& allocation);
virtual void on_size_request(Gtk::Requisition* request);
virtual bool on_expose_event(GdkEventExpose* event);
virtual bool on_button_press_event(GdkEventButton* event);
virtual void draw_widget(cairo_t* ctx) = 0;

View File

@ -46,13 +46,13 @@ SimulationWidget::draw_widget(cairo_t* ctx)
// NOTE: just to try
CairoElements ce(ctx);
Rectangle area = { 30, 30, 100, 100 };
Rectangle area = { 0.3, 0.3, 1.0, 1.0 };
ce.draw_container(area);
Color red = { 1, 0, 0 };
Point center = { 25, 25 };
Point center = { 0.25, 0.25 };
ce.draw_3dsphere(center, 20, red);
ce.draw_3dsphere(center, 0.20, red);
}
@ -63,10 +63,12 @@ SimulationWidget::calc_size(const History& history, size_t& width, size_t& heigh
width = get_allocation().get_width();
height = get_allocation().get_height();
/*
#ifndef NDEBUG
using namespace std;
clog << " [DD] New allocation event on " << hex << this << ": "
<< dec << width << 'x' << height << endl;
#endif
*/
}