mirror of
https://github.com/KLayout/klayout.git
synced 2026-08-29 17:30:09 +02:00
Merge branch 'master' into wip
This commit is contained in:
@@ -1682,13 +1682,9 @@ CompoundRegionCheckOperationNode::computed_dist () const
|
||||
void
|
||||
CompoundRegionCheckOperationNode::do_compute_local (CompoundRegionOperationCache * /*cache*/, db::Layout *layout, db::Cell *cell, const shape_interactions<db::PolygonWithProperties, db::PolygonWithProperties> &interactions, std::vector<std::unordered_set<db::EdgePairWithProperties> > &results, const db::LocalProcessorBase *proc) const
|
||||
{
|
||||
// consider magnification variants
|
||||
db::EdgeRelationFilter check = m_check;
|
||||
check.set_distance (proc->dist_for_cell (cell, check.distance ()));
|
||||
|
||||
// TODO: needs a concept to deal with merged/non-merged inputs
|
||||
bool is_merged = true;
|
||||
db::check_local_operation<db::PolygonWithProperties, db::PolygonWithProperties> op (check, m_different_polygons, is_merged, m_has_other, m_is_other_merged, m_options);
|
||||
db::check_local_operation<db::PolygonWithProperties, db::PolygonWithProperties> op (m_check, m_different_polygons, is_merged, m_has_other, m_is_other_merged, m_options);
|
||||
|
||||
tl_assert (results.size () == 1);
|
||||
if (results.front ().empty ()) {
|
||||
@@ -1704,13 +1700,9 @@ CompoundRegionCheckOperationNode::do_compute_local (CompoundRegionOperationCache
|
||||
void
|
||||
CompoundRegionCheckOperationNode::do_compute_local (CompoundRegionOperationCache * /*cache*/, db::Layout *layout, db::Cell *cell, const shape_interactions<db::PolygonRefWithProperties, db::PolygonRefWithProperties> &interactions, std::vector<std::unordered_set<db::EdgePairWithProperties> > &results, const db::LocalProcessorBase *proc) const
|
||||
{
|
||||
// consider magnification variants
|
||||
db::EdgeRelationFilter check = m_check;
|
||||
check.set_distance (proc->dist_for_cell (cell, check.distance ()));
|
||||
|
||||
// TODO: needs a concept to deal with merged/non-merged inputs
|
||||
bool is_merged = true;
|
||||
db::check_local_operation<db::PolygonRefWithProperties, db::PolygonRefWithProperties> op (check, m_different_polygons, is_merged, m_has_other, m_is_other_merged, m_options);
|
||||
db::check_local_operation<db::PolygonRefWithProperties, db::PolygonRefWithProperties> op (m_check, m_different_polygons, is_merged, m_has_other, m_is_other_merged, m_options);
|
||||
|
||||
tl_assert (results.size () == 1);
|
||||
if (results.front ().empty ()) {
|
||||
|
||||
@@ -2113,3 +2113,13 @@ TEST(148_sparse_array_limit)
|
||||
run_test (_this, "148", true);
|
||||
}
|
||||
|
||||
// issue 2384
|
||||
TEST(149_compound_drc_with_mag)
|
||||
{
|
||||
run_test (_this, "149", false);
|
||||
}
|
||||
|
||||
TEST(149d_compound_drc_with_mag)
|
||||
{
|
||||
run_test (_this, "149", true);
|
||||
}
|
||||
|
||||
@@ -126,6 +126,40 @@ static std::vector<char> pixel_buffer_to_png (const tl::PixelBuffer *pb)
|
||||
#endif
|
||||
}
|
||||
|
||||
// Returns an 8-byte header (width, height as uint32) followed by the raw ARGB32 pixel data
|
||||
static std::vector<char> pixel_buffer_to_bytes (const tl::PixelBuffer *pb)
|
||||
{
|
||||
uint32_t w = pb->width (), h = pb->height ();
|
||||
size_t n = (size_t) w * (size_t) h * 4;
|
||||
std::vector<char> data (8 + n);
|
||||
memcpy (data.data (), &w, 4);
|
||||
memcpy (data.data () + 4, &h, 4);
|
||||
memcpy (data.data () + 8, pb->data (), n);
|
||||
return data;
|
||||
}
|
||||
|
||||
// Inverse of to_bytes: reads width/height from the header and checks the length
|
||||
static tl::PixelBuffer pixel_buffer_from_bytes (const std::vector<char> &data)
|
||||
{
|
||||
uint32_t w = 0, h = 0;
|
||||
if (data.size () >= 8) {
|
||||
memcpy (&w, data.data (), 4);
|
||||
memcpy (&h, data.data () + 4, 4);
|
||||
}
|
||||
// sanity guard against malformed headers: reader caps dimensions at 64k x 64k
|
||||
// (generous for finely-resolved drawings), writer stays full 32-bit
|
||||
const uint32_t max_dim = 65536;
|
||||
if (w > max_dim || h > max_dim) {
|
||||
throw tl::Exception (tl::to_string (tr ("Invalid PixelBuffer byte stream: width or height exceeds the 65536 x 65536 limit")));
|
||||
}
|
||||
if (data.size () != 8 + (size_t) w * (size_t) h * 4) {
|
||||
throw tl::Exception (tl::to_string (tr ("Invalid PixelBuffer byte stream: length does not match the width and height in the header")));
|
||||
}
|
||||
tl::PixelBuffer pb (w, h, (const tl::color_t *) (data.data () + 8));
|
||||
pb.set_transparent (true);
|
||||
return pb;
|
||||
}
|
||||
|
||||
|
||||
Class<tl::PixelBuffer> decl_PixelBuffer ("lay", "PixelBuffer",
|
||||
gsi::constructor ("new", &create_pixel_buffer, gsi::arg ("width"), gsi::arg ("height"),
|
||||
@@ -188,6 +222,24 @@ Class<tl::PixelBuffer> decl_PixelBuffer ("lay", "PixelBuffer",
|
||||
"\n"
|
||||
"This method may not be available if PNG support is not compiled into KLayout."
|
||||
) +
|
||||
gsi::method_ext ("to_bytes", &pixel_buffer_to_bytes,
|
||||
"@brief Converts the pixel buffer to a raw byte stream\n"
|
||||
"\n"
|
||||
"The stream starts with an 8-byte header (width and height as 32-bit unsigned integers) "
|
||||
"followed by the raw ARGB32 pixel data with 4 bytes per pixel in row-major order, "
|
||||
"top to bottom. Unlike \\to_png_data this method has zero encoding overhead. "
|
||||
"Use \\from_bytes to reconstruct the pixel buffer.\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.30.10."
|
||||
) +
|
||||
gsi::method ("from_bytes", &pixel_buffer_from_bytes, gsi::arg ("data"),
|
||||
"@brief Reconstructs a pixel buffer from a byte stream produced by \\to_bytes\n"
|
||||
"\n"
|
||||
"The width and height are taken from the header and the stream length is checked against them. "
|
||||
"The dimensions are capped at 65536 x 65536; a header exceeding this limit raises an error.\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.30.10."
|
||||
) +
|
||||
gsi::method ("patch", &tl::PixelBuffer::patch, gsi::arg ("other"),
|
||||
"@brief Patches another pixel buffer into this one\n"
|
||||
"\n"
|
||||
|
||||
@@ -855,7 +855,9 @@ LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int l
|
||||
lay::RedrawThread redraw_thread (&rd_canvas, mp_view);
|
||||
|
||||
// render the layout
|
||||
redraw_thread.start (0 /*synchronous*/, m_layers, vp, resolution, font_resolution, true);
|
||||
int workers = mp_view->synchronous () ? 0 : mp_view->drawing_workers ();
|
||||
redraw_thread.start (workers, m_layers, vp, resolution, font_resolution, true);
|
||||
redraw_thread.wait ();
|
||||
redraw_thread.stop (); // safety
|
||||
|
||||
// paint the background objects. It uses "img" to paint on.
|
||||
|
||||
Reference in New Issue
Block a user