WIP: image object, first steps

This commit is contained in:
Matthias Koefferlein 2022-05-02 00:26:13 +02:00
parent 0b48cb9020
commit 373f307ae6
4 changed files with 95 additions and 6 deletions

View File

@ -1030,7 +1030,7 @@ public:
}
protected:
#if defined(HAVE_QT)
#if defined(HAVE_QT) // @@@
/**
* @brief Qt focus event handler
*/
@ -1101,7 +1101,7 @@ protected:
void wheelEvent (QWheelEvent *e);
#endif
#if !defined(HAVE_QT)
#if !defined(HAVE_QT) // @@@
void update ();
#endif

View File

@ -0,0 +1,92 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2022 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "layImage.h"
#include "tlUnitTest.h"
#if defined(HAVE_QT)
#include <QImage>
#endif
TEST(1)
{
lay::Image img (15, 25);
EXPECT_EQ (img.width (), 15);
EXPECT_EQ (img.height (), 25);
img.fill (0x112233);
EXPECT_EQ (img.scan_line (5)[10], 0x112233);
lay::Image img2;
img2 = img;
EXPECT_EQ (img2.width (), 15);
EXPECT_EQ (img2.height (), 25);
EXPECT_EQ (img.scan_line (5)[10], 0x112233);
EXPECT_EQ (img2.scan_line (5)[10], 0x112233);
img2.fill (0x332211);
EXPECT_EQ (img.scan_line (5)[10], 0x112233);
EXPECT_EQ (img2.scan_line (5)[10], 0x332211);
img2.swap (img);
EXPECT_EQ (img2.scan_line (5)[10], 0x112233);
EXPECT_EQ (img.scan_line (5)[10], 0x332211);
img2 = img;
EXPECT_EQ (img.scan_line (5)[10], 0x332211);
EXPECT_EQ (img2.scan_line (5)[10], 0x332211);
img2 = lay::Image (10, 16);
EXPECT_EQ (img.width (), 15);
EXPECT_EQ (img.height (), 25);
EXPECT_EQ (img2.width (), 10);
EXPECT_EQ (img2.height (), 16);
img2.fill (0x010203);
EXPECT_EQ (img.scan_line (5)[10], 0x332211);
EXPECT_EQ (img2.scan_line (5)[8], 0x010203);
img = std::move (img2);
EXPECT_EQ (img.width (), 10);
EXPECT_EQ (img.height (), 16);
EXPECT_EQ (img.scan_line (5)[8], 0x010203);
lay::Image img3 (img);
EXPECT_EQ (img3.width (), 10);
EXPECT_EQ (img3.height (), 16);
EXPECT_EQ (img3.scan_line (5)[8], 0x010203);
img.fill (0x102030);
EXPECT_EQ (img3.width (), 10);
EXPECT_EQ (img3.height (), 16);
EXPECT_EQ (img3.scan_line (5)[8], 0x010203);
EXPECT_EQ (img.width (), 10);
EXPECT_EQ (img.height (), 16);
EXPECT_EQ (img.scan_line (5)[8], 0x102030);
lay::Image img4 (std::move (img));
EXPECT_EQ (img4.width (), 10);
EXPECT_EQ (img4.height (), 16);
EXPECT_EQ (img4.scan_line (5)[8], 0x102030);
}

View File

@ -152,9 +152,7 @@ public:
return;
}
tl::MutexLocker locker1 (&ms_lock);
tl::MutexLocker locker2 (&other.ms_lock);
tl::MutexLocker locker (&ms_lock);
std::swap (mp_x, other.mp_x);
std::swap (mp_holder, other.mp_holder);
}

View File

@ -19,7 +19,6 @@ SOURCES = \
tlFileSystemWatcherTests.cc \
tlFileUtilsTests.cc \
tlHttpStreamTests.cc \
tlImageTests.cc \
tlIncludeTests.cc \
tlInt128SupportTests.cc \
tlIntervalMapTests.cc \