Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4fb1c24189b9
Choose a base ref
...
head repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 06ff395b51cd
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Oct 28, 2020

  1. ProtocolAnalyzerWindow: now pad partial scanlines out to rest of imag…

    …e width with checkerboard
    azonenberg committed Oct 28, 2020
    Copy the full SHA
    06ff395 View commit details
Showing with 42 additions and 5 deletions.
  1. +40 −5 src/glscopeclient/ProtocolAnalyzerWindow.cpp
  2. +2 −0 src/glscopeclient/ProtocolAnalyzerWindow.h
45 changes: 40 additions & 5 deletions src/glscopeclient/ProtocolAnalyzerWindow.cpp
Original file line number Diff line number Diff line change
@@ -388,6 +388,7 @@ ProtocolAnalyzerWindow::ProtocolAnalyzerWindow(
, m_decoder(decoder)
, m_area(area)
, m_columns(decoder)
, m_imageWidth(0)
, m_updating(false)
{
set_skip_taskbar_hint();
@@ -430,8 +431,12 @@ ProtocolAnalyzerWindow::ProtocolAnalyzerWindow(
vector<Gtk::CellRenderer*> cells = pcol->get_cells();
for(auto c : cells)
{
pcol->add_attribute(*c, "background-gdk", 1); //column 1 is bg color
pcol->add_attribute(*c, "foreground-gdk", 2); //column 2 is fg color
//Pixbuf cells don't have fg/bg attributes
if(dynamic_cast<Gtk::CellRendererPixbuf*>(c) == NULL)
{
pcol->add_attribute(*c, "background-gdk", 1); //column 1 is bg color
pcol->add_attribute(*c, "foreground-gdk", 2); //column 2 is fg color
}

if(decoder->GetShowImageColumn())
pcol->add_attribute(*c, "height", 3); //column 3 is height
@@ -628,6 +633,8 @@ void ProtocolAnalyzerWindow::FillOutRow(
{
size_t rowsize = p->m_data.size();
size_t width = rowsize / 3;
size_t rowsize_rounded = width*3;
m_imageWidth = max(m_imageWidth, width);
if(width > 0)
{
size_t height = 12;
@@ -636,13 +643,41 @@ void ProtocolAnalyzerWindow::FillOutRow(
Gdk::COLORSPACE_RGB,
false,
8,
width,
m_imageWidth,
height);

//Make a 2D image
//Stretch it into a 2D image
uint8_t* pixels = image->get_pixels();
size_t stride = image->get_rowstride();
for(size_t y=0; y<height; y++)
memcpy(pixels + y*rowsize, &p->m_data[0], rowsize);
{
//Copy the pixel data for this row
auto rowpix = pixels + y*stride;
memcpy(rowpix, &p->m_data[0], rowsize_rounded);

//If this scanline is truncated, pad with a light/dark gray checkerboard
if(width < m_imageWidth)
{
uint8_t a = 0x80;
uint8_t b = 0xc0;

for(size_t x=width; x<m_imageWidth; x++)
{
if( (x/6 ^ y/6) & 0x1)
{
rowpix[x*3 + 0] = a;
rowpix[x*3 + 1] = a;
rowpix[x*3 + 2] = a;
}
else
{
rowpix[x*3 + 0] = b;
rowpix[x*3 + 1] = b;
rowpix[x*3 + 2] = b;
}
}
}
}

row[m_columns.m_image] = image;
row[m_columns.m_height] = height;
2 changes: 2 additions & 0 deletions src/glscopeclient/ProtocolAnalyzerWindow.h
Original file line number Diff line number Diff line change
@@ -161,6 +161,8 @@ class ProtocolAnalyzerWindow : public Gtk::Dialog
Glib::RefPtr<Gtk::TreeModelFilter> m_model;
ProtocolAnalyzerColumns m_columns;

size_t m_imageWidth;

void OnSelectionChanged();

void FillOutRow(const Gtk::TreeRow& row, Packet* p, WaveformBase* data, std::vector<std::string>& headers);