Skip to content

Commit

Permalink
Bitmap: Remember the filename, useful for debugging purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghabry committed Sep 9, 2021
1 parent 5a961e9 commit 16d54ea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/bitmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ Bitmap::Bitmap(Filesystem_Stream::InputStream stream, bool transparent, uint32_t
ConvertImage(w, h, pixels, transparent);

CheckPixels(flags);

filename = ToString(stream.GetName());
}

Bitmap::Bitmap(const uint8_t* data, unsigned bytes, bool transparent, uint32_t flags) {
Expand Down
14 changes: 14 additions & 0 deletions src/bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,14 @@ class Bitmap {
*/
Color GetShadowColor() const;

/**
* Gets the filename this bitmap was loaded from.
* This will be empty when the origin was not a file.
*
* @return filename
*/
StringView GetFilename() const;

void CheckPixels(uint32_t flags);

/**
Expand Down Expand Up @@ -578,6 +586,8 @@ class Bitmap {
TileOpacity tile_opacity;
Color bg_color, sh_color;

std::string filename;

/** Bitmap data. */
PixmanImagePtr bitmap;
pixman_format_code_t pixman_format;
Expand Down Expand Up @@ -647,4 +657,8 @@ inline bool Bitmap::GetTransparent() const {
return format.alpha_type != PF::NoAlpha;
}

inline StringView Bitmap::GetFilename() const {
return filename;
}

#endif

0 comments on commit 16d54ea

Please sign in to comment.