mirror of https://github.com/KLayout/klayout.git
Merge remote-tracking branch 'remotes/origin/master' into pymod
This commit is contained in:
commit
967652784e
|
|
@ -386,13 +386,18 @@ render_scanline_cross (const uint32_t *dp, unsigned int ds, const lay::Bitmap *p
|
|||
}
|
||||
}
|
||||
|
||||
static void create_precursor_bitmaps (const std::vector<lay::ViewOp> &view_ops_in, const std::vector<lay::Bitmap *> &pbitmaps_in, const lay::LineStyles &ls, unsigned int width, unsigned int height, std::map<unsigned int, lay::Bitmap> &precursors, QMutex *mutex)
|
||||
static void create_precursor_bitmaps (const std::vector<lay::ViewOp> &view_ops_in, const std::vector <unsigned int> &vo_map, const std::vector<lay::Bitmap *> &pbitmaps_in, const std::vector<unsigned int> &bm_map, const lay::LineStyles &ls, unsigned int width, unsigned int height, std::map<unsigned int, lay::Bitmap> &precursors, QMutex *mutex)
|
||||
{
|
||||
tl_assert (bm_map.size () == vo_map.size ());
|
||||
|
||||
// Styled lines with width > 1 are not rendered directly, but through an intermediate step.
|
||||
// We prepare the necessary precursor bitmaps now
|
||||
for (unsigned int i = 0; i < view_ops_in.size (); ++i) {
|
||||
for (unsigned int i = 0; i < vo_map.size (); ++i) {
|
||||
|
||||
const ViewOp &op = view_ops_in [i];
|
||||
unsigned int vo_index = vo_map [i];
|
||||
unsigned int bm_index = bm_map [i];
|
||||
|
||||
const ViewOp &op = view_ops_in [vo_index];
|
||||
if (op.width () > 1 && ls.style (op.line_style_index ()).width () > 0) {
|
||||
|
||||
// lock bitmaps against change by the redraw thread
|
||||
|
|
@ -400,12 +405,12 @@ static void create_precursor_bitmaps (const std::vector<lay::ViewOp> &view_ops_i
|
|||
mutex->lock ();
|
||||
}
|
||||
|
||||
lay::Bitmap &bp = precursors.insert (std::make_pair (i, lay::Bitmap (width, height, 1.0))).first->second;
|
||||
lay::Bitmap &bp = precursors.insert (std::make_pair (bm_index, lay::Bitmap (width, height, 1.0))).first->second;
|
||||
LineStyleInfo ls_info = ls.style (op.line_style_index ());
|
||||
ls_info.scale_pattern (op.width ());
|
||||
|
||||
for (unsigned int y = 0; y < height; y++) {
|
||||
render_scanline_std_edge (ls_info.pattern (), ls_info.pattern_stride (), pbitmaps_in [i], y, width, height, bp.scanline (y));
|
||||
render_scanline_std_edge (ls_info.pattern (), ls_info.pattern_stride (), pbitmaps_in [bm_index], y, width, height, bp.scanline (y));
|
||||
}
|
||||
|
||||
if (mutex) {
|
||||
|
|
@ -418,7 +423,7 @@ static void create_precursor_bitmaps (const std::vector<lay::ViewOp> &view_ops_i
|
|||
}
|
||||
|
||||
static void
|
||||
bitmaps_to_image_rgb (const std::vector<lay::ViewOp> &view_ops_in,
|
||||
bitmaps_to_image_rgb (const std::vector<lay::ViewOp> &view_ops_in,
|
||||
const std::vector<lay::Bitmap *> &pbitmaps_in,
|
||||
const lay::DitherPattern &dp,
|
||||
const lay::LineStyles &ls,
|
||||
|
|
@ -427,29 +432,33 @@ bitmaps_to_image_rgb (const std::vector<lay::ViewOp> &view_ops_in,
|
|||
bool transparent,
|
||||
QMutex *mutex)
|
||||
{
|
||||
unsigned int n_in = (unsigned int) view_ops_in.size ();
|
||||
|
||||
std::vector<unsigned int> bm_map;
|
||||
std::vector<unsigned int> vo_map;
|
||||
|
||||
vo_map.reserve (n_in);
|
||||
for (unsigned int i = 0; i < n_in; ++i) {
|
||||
vo_map.push_back (i);
|
||||
}
|
||||
vo_map.reserve (view_ops_in.size ());
|
||||
bm_map.reserve (view_ops_in.size ());
|
||||
unsigned int n_in = 0;
|
||||
|
||||
if (! use_bitmap_index) {
|
||||
bm_map = vo_map;
|
||||
} else {
|
||||
bm_map.reserve (n_in);
|
||||
for (unsigned int i = 0; i < n_in; ++i) {
|
||||
bm_map.push_back (view_ops_in [i].bitmap_index () < 0 ? i : view_ops_in [i].bitmap_index ());
|
||||
// drop invisible and empty bitmaps, build bitmap mask
|
||||
for (unsigned int i = 0; i < view_ops_in.size (); ++i) {
|
||||
|
||||
const lay::ViewOp &vop = view_ops_in [i];
|
||||
|
||||
unsigned int bi = (use_bitmap_index && vop.bitmap_index () >= 0) ? (unsigned int) vop.bitmap_index () : i;
|
||||
const lay::Bitmap *pb = bi < pbitmaps_in.size () ? pbitmaps_in [bi] : 0;
|
||||
|
||||
if ((vop.ormask () | ~vop.andmask ()) != 0 && pb && ! pb->empty ()) {
|
||||
vo_map.push_back (i);
|
||||
bm_map.push_back (bi);
|
||||
++n_in;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Styled lines with width > 1 are not rendered directly, but through an intermediate step.
|
||||
// We prepare the necessary precursor bitmaps now
|
||||
std::map<unsigned int, lay::Bitmap> precursors;
|
||||
create_precursor_bitmaps (view_ops_in, pbitmaps_in, ls, width, height, precursors, mutex);
|
||||
create_precursor_bitmaps (view_ops_in, vo_map, pbitmaps_in, bm_map, ls, width, height, precursors, mutex);
|
||||
|
||||
std::vector<lay::ViewOp> view_ops;
|
||||
std::vector<const lay::Bitmap *> pbitmaps;
|
||||
|
|
@ -489,12 +498,13 @@ bitmaps_to_image_rgb (const std::vector<lay::ViewOp> &view_ops_in,
|
|||
unsigned int w = vop.width ();
|
||||
|
||||
const lay::Bitmap *pb = 0;
|
||||
unsigned int bm_index = bm_map[i];
|
||||
if (bm_map [i] < pbitmaps_in.size ()) {
|
||||
if (w > 1 && ls.style (vop.line_style_index ()).width () > 0) {
|
||||
tl_assert (precursors.find (i) != precursors.end ());
|
||||
pb = &precursors [i];
|
||||
tl_assert (precursors.find (bm_index) != precursors.end ());
|
||||
pb = &precursors [bm_index];
|
||||
} else {
|
||||
pb = pbitmaps_in [bm_map[i]];
|
||||
pb = pbitmaps_in [bm_index];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -660,29 +670,33 @@ bitmaps_to_image_mono (const std::vector<lay::ViewOp> &view_ops_in,
|
|||
bool use_bitmap_index,
|
||||
QMutex *mutex)
|
||||
{
|
||||
unsigned int n_in = (unsigned int) view_ops_in.size ();
|
||||
|
||||
std::vector<unsigned int> bm_map;
|
||||
std::vector<unsigned int> vo_map;
|
||||
|
||||
vo_map.reserve (n_in);
|
||||
for (unsigned int i = 0; i < n_in; ++i) {
|
||||
vo_map.push_back (i);
|
||||
}
|
||||
vo_map.reserve (view_ops_in.size ());
|
||||
bm_map.reserve (view_ops_in.size ());
|
||||
unsigned int n_in = 0;
|
||||
|
||||
if (! use_bitmap_index) {
|
||||
bm_map = vo_map;
|
||||
} else {
|
||||
bm_map.reserve (n_in);
|
||||
for (unsigned int i = 0; i < n_in; ++i) {
|
||||
bm_map.push_back (view_ops_in [i].bitmap_index () < 0 ? i : view_ops_in [i].bitmap_index ());
|
||||
// drop invisible and empty bitmaps, build bitmap mask
|
||||
for (unsigned int i = 0; i < view_ops_in.size (); ++i) {
|
||||
|
||||
const lay::ViewOp &vop = view_ops_in [i];
|
||||
|
||||
unsigned int bi = (use_bitmap_index && vop.bitmap_index () >= 0) ? (unsigned int) vop.bitmap_index () : i;
|
||||
const lay::Bitmap *pb = bi < pbitmaps_in.size () ? pbitmaps_in [bi] : 0;
|
||||
|
||||
if ((vop.ormask () | ~vop.andmask ()) != 0 && pb && ! pb->empty ()) {
|
||||
vo_map.push_back (i);
|
||||
bm_map.push_back (bi);
|
||||
++n_in;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Styled lines with width > 1 are not rendered directly, but through an intermediate step.
|
||||
// We prepare the necessary precursor bitmaps now
|
||||
std::map<unsigned int, lay::Bitmap> precursors;
|
||||
create_precursor_bitmaps (view_ops_in, pbitmaps_in, ls, width, height, precursors, mutex);
|
||||
create_precursor_bitmaps (view_ops_in, vo_map, pbitmaps_in, bm_map, ls, width, height, precursors, mutex);
|
||||
|
||||
std::vector<lay::ViewOp> view_ops;
|
||||
std::vector<const lay::Bitmap *> pbitmaps;
|
||||
|
|
@ -722,16 +736,17 @@ bitmaps_to_image_mono (const std::vector<lay::ViewOp> &view_ops_in,
|
|||
unsigned int w = vop.width ();
|
||||
|
||||
const lay::Bitmap *pb = 0;
|
||||
unsigned int bm_index = bm_map[i];
|
||||
if (bm_map [i] < pbitmaps_in.size ()) {
|
||||
if (w > 1 && ls.style (vop.line_style_index ()).width () > 0) {
|
||||
tl_assert (precursors.find (i) != precursors.end ());
|
||||
pb = &precursors [i];
|
||||
tl_assert (precursors.find (bm_index) != precursors.end ());
|
||||
pb = &precursors [bm_index];
|
||||
} else {
|
||||
pb = pbitmaps_in [bm_map[i]];
|
||||
pb = pbitmaps_in [bm_index];
|
||||
}
|
||||
}
|
||||
|
||||
if (pb != 0
|
||||
if (pb != 0
|
||||
&& w > 0
|
||||
&& ((pb->first_scanline () < y + slice && pb->last_scanline () > y) || w > 1)
|
||||
&& (vop.ormask () | ~vop.andmask ()) != 0) {
|
||||
|
|
|
|||
|
|
@ -74,9 +74,10 @@ struct RedrawLayerInfo
|
|||
/**
|
||||
* @brief The layer index
|
||||
*
|
||||
* The logical layer to draw. If this member is <0 and the cellview_index is <0, it is an invalid layer,
|
||||
* which is ignored. If the cellview_index is >=0, it denotes a "cell frame" pseudo
|
||||
* layer. It is set by the constructor.
|
||||
* The logical layer to draw. The layer index can be <0 which indicates a
|
||||
* layer with not layout source (cell_frame may be true to indicate a
|
||||
* pseudo layer then).
|
||||
* This attribute is set by the constructor.
|
||||
*/
|
||||
int layer_index;
|
||||
|
||||
|
|
@ -115,6 +116,14 @@ struct RedrawLayerInfo
|
|||
* This member is set by the constructor.
|
||||
*/
|
||||
bool inverse_prop_sel;
|
||||
|
||||
/**
|
||||
* @brief Returns true, if the layer needs to be drawn
|
||||
*/
|
||||
bool needs_drawing () const
|
||||
{
|
||||
return visible && enabled && (cell_frame || layer_index >= 0) && cellview_index >= 0;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ RedrawThread::do_start (bool clear, const db::Vector *shift_vector, const std::v
|
|||
}
|
||||
|
||||
for (int i = 0; i < m_nlayers; ++i) {
|
||||
if (m_layers [i].visible && m_layers [i].enabled) {
|
||||
if (m_layers [i].needs_drawing ()) {
|
||||
schedule (new RedrawThreadTask (i));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1232,20 +1232,26 @@ RedrawThreadWorker::draw_text_layer (bool drawing_context, db::cell_index_type c
|
|||
vertex = m_planes[3 + plane_group * (planes_per_layer / 3)];
|
||||
|
||||
// do not draw, if there is nothing to draw
|
||||
if (mp_layout->cells () <= ci || vp.empty ()) {
|
||||
if (mp_layout->cells () <= ci || vp.empty () || mp_layout->cell (ci).bbox (m_layer).empty ()) {
|
||||
return;
|
||||
}
|
||||
if (cell_var_cached (ci, trans)) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::auto_ptr<lay::Bitmap> opt_bitmap;
|
||||
lay::Bitmap *vertex_bitmap = dynamic_cast<lay::Bitmap *> (vertex);
|
||||
if (m_text_lazy_rendering && vertex_bitmap) {
|
||||
opt_bitmap.reset (new lay::Bitmap (vertex_bitmap->width (), vertex_bitmap->height (), vertex_bitmap->resolution ()));
|
||||
}
|
||||
|
||||
for (std::vector<db::Box>::const_iterator b = vp.begin (); b != vp.end (); ++b) {
|
||||
draw_text_layer (drawing_context, ci, trans, *b, level, fill, frame, vertex, text);
|
||||
draw_text_layer (drawing_context, ci, trans, *b, level, fill, frame, vertex, text, opt_bitmap.get ());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
RedrawThreadWorker::draw_text_layer (bool drawing_context, db::cell_index_type ci, const db::CplxTrans &trans, const db::Box &vp, int level, CanvasPlane *fill, CanvasPlane *frame, CanvasPlane *vertex, CanvasPlane *text)
|
||||
RedrawThreadWorker::draw_text_layer (bool drawing_context, db::cell_index_type ci, const db::CplxTrans &trans, const db::Box &vp, int level, CanvasPlane *fill, CanvasPlane *frame, CanvasPlane *vertex, CanvasPlane *text, lay::Bitmap *opt_bitmap)
|
||||
{
|
||||
test_snapshot (0);
|
||||
|
||||
|
|
@ -1283,6 +1289,9 @@ RedrawThreadWorker::draw_text_layer (bool drawing_context, db::cell_index_type c
|
|||
// paint the simplified box
|
||||
if (anything) {
|
||||
r.draw (trans * bbox, 0, frame, vertex, 0);
|
||||
if (opt_bitmap) {
|
||||
r.draw (trans * bbox, 0, 0, opt_bitmap, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// do not dive further into hierarchy
|
||||
|
|
@ -1318,6 +1327,9 @@ RedrawThreadWorker::draw_text_layer (bool drawing_context, db::cell_index_type c
|
|||
test_snapshot (0);
|
||||
|
||||
r.draw (*shape, trans, fill, frame, vertex, text);
|
||||
if (opt_bitmap) {
|
||||
r.draw (*shape, trans, 0, 0, opt_bitmap, 0);
|
||||
}
|
||||
++shape;
|
||||
|
||||
--ntexts;
|
||||
|
|
@ -1355,8 +1367,6 @@ RedrawThreadWorker::draw_text_layer (bool drawing_context, db::cell_index_type c
|
|||
// dive down into the hierarchy ..
|
||||
if (need_to_dive) {
|
||||
|
||||
const lay::Bitmap *vertex_bitmap = dynamic_cast<const lay::Bitmap *> (vertex);
|
||||
|
||||
// create a set of boxes to look into
|
||||
std::vector<db::Box> vv = search_regions (cell_bbox, vp, level);
|
||||
|
||||
|
|
@ -1377,7 +1387,7 @@ RedrawThreadWorker::draw_text_layer (bool drawing_context, db::cell_index_type c
|
|||
bool skip = false;
|
||||
if (m_text_lazy_rendering && qid != current_quad_id) {
|
||||
current_quad_id = qid;
|
||||
skip = vertex_bitmap && skip_quad (inst.quad_box () & bbox, vertex_bitmap, trans);
|
||||
skip = opt_bitmap && skip_quad (inst.quad_box () & bbox, opt_bitmap, trans);
|
||||
}
|
||||
|
||||
if (skip) {
|
||||
|
|
@ -1448,7 +1458,7 @@ RedrawThreadWorker::draw_text_layer (bool drawing_context, db::cell_index_type c
|
|||
|
||||
db::ICplxTrans t (cell_inst.complex_trans (*p));
|
||||
db::Box new_vp = db::Box (t.inverted () * *v);
|
||||
draw_text_layer (drawing_context, new_ci, trans * t, new_vp, level + 1, fill, frame, vertex, text);
|
||||
draw_text_layer (drawing_context, new_ci, trans * t, new_vp, level + 1, fill, frame, vertex, text, opt_bitmap);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1648,7 +1658,7 @@ RedrawThreadWorker::draw_layer_wo_cache (int from_level, int to_level, db::cell_
|
|||
// skip this quad if we have drawn something here already
|
||||
size_t qid = inst.quad_id ();
|
||||
bool skip = false;
|
||||
if (m_text_lazy_rendering && qid != current_quad_id) {
|
||||
if (qid != current_quad_id) {
|
||||
current_quad_id = qid;
|
||||
skip = skip_quad (inst.quad_box () & bbox, vertex_bitmap, trans);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ private:
|
|||
void draw_layer (int from_level, int to_level, db::cell_index_type ci, const db::CplxTrans &trans, const db::Box &redraw_box, int level, lay::CanvasPlane *fill, lay::CanvasPlane *frame, lay::CanvasPlane *vertex, lay::CanvasPlane *text, const UpdateSnapshotCallback *update_snapshot);
|
||||
void draw_layer_wo_cache (int from_level, int to_level, db::cell_index_type ci, const db::CplxTrans &trans, const std::vector<db::Box> &vv, int level, lay::CanvasPlane *fill, lay::CanvasPlane *frame, lay::CanvasPlane *vertex, lay::CanvasPlane *text, const UpdateSnapshotCallback *update_snapshot);
|
||||
void draw_text_layer (bool drawing_context, db::cell_index_type ci, const db::CplxTrans &trans, const std::vector <db::Box> &redraw_regions, int level);
|
||||
void draw_text_layer (bool drawing_context, db::cell_index_type ci, const db::CplxTrans &trans, const db::Box &redraw_region, int level, lay::CanvasPlane *fill, lay::CanvasPlane *frame, lay::CanvasPlane *vertex, lay::CanvasPlane *text);
|
||||
void draw_text_layer (bool drawing_context, db::cell_index_type ci, const db::CplxTrans &trans, const db::Box &redraw_region, int level, lay::CanvasPlane *fill, lay::CanvasPlane *frame, lay::CanvasPlane *vertex, lay::CanvasPlane *text, Bitmap *opt_bitmap);
|
||||
void draw_boxes (bool drawing_context, db::cell_index_type ci, const db::CplxTrans &trans, const std::vector <db::Box> &redraw_regions, int level);
|
||||
void draw_boxes (bool drawing_context, db::cell_index_type ci, const db::CplxTrans &trans, const db::Box &redraw_region, int level);
|
||||
void draw_box_properties (bool drawing_context, db::cell_index_type ci, const db::CplxTrans &trans, const std::vector <db::Box> &redraw_regions, int level);
|
||||
|
|
|
|||
Loading…
Reference in New Issue