Skip to content

Commit

Permalink
apply clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
bfraboni committed Jul 4, 2024
1 parent 3d30e3d commit 9e20cff
Show file tree
Hide file tree
Showing 9 changed files with 425 additions and 4 deletions.
24 changes: 24 additions & 0 deletions src/bmp.imageio/bmpinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <OpenImageIO/filesystem.h>
#include <OpenImageIO/imageio.h>
#include <OpenImageIO/memory.h>

#include "bmp_pvt.h"

Expand All @@ -30,6 +31,8 @@ class BmpInput final : public ImageInput {
bool close(void) override;
bool read_native_scanline(int subimage, int miplevel, int y, int z,
void* data) override;
size_t datasize() const override;
size_t footprint() const override;

private:
int64_t m_padded_scanline_size;
Expand Down Expand Up @@ -553,4 +556,25 @@ BmpInput::color_table_is_all_gray(void)
return true;
}



size_t
BmpInput::datasize() const
{
size_t size = ImageInput::datasize();
size += m_filename.capacity();
size += vector_bytes(m_colortable);
size += vector_bytes(fscanline);
size += vector_bytes(m_uncompressed);
return size;
}



size_t
BmpInput::footprint() const
{
return sizeof(BmpInput) + datasize();
}

OIIO_PLUGIN_NAMESPACE_END
2 changes: 2 additions & 0 deletions src/include/OpenImageIO/imagecache.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ class OIIO_API ImageCache {
/// all files referenced by calls to the ImageCache. (The
/// array is of `ustring` or `char*`.)
///
/// - `int64 stat:cache_footprint` :
/// Total bytes used by image cache.
/// - `int64 stat:cache_memory_used` :
/// Total bytes used by tile cache.
///
Expand Down
8 changes: 8 additions & 0 deletions src/include/OpenImageIO/imageio.h
Original file line number Diff line number Diff line change
Expand Up @@ -1783,6 +1783,14 @@ class OIIO_API ImageInput {
/// `ImageInput*`.
typedef ImageInput* (*Creator)();

/// Return the total heap memory allocated by the ImageInput and its
/// members.
virtual size_t datasize() const;

/// Return the total memory used by the ImageInput, including this
/// object itself and any heap memory allocated data.
virtual size_t footprint() const;

protected:
ImageSpec m_spec; // format spec of the current open subimage/MIPlevel
// BEWARE using m_spec directly -- not thread-safe
Expand Down
2 changes: 1 addition & 1 deletion src/libOpenImageIO/formatspec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
#include <OpenImageIO/fmath.h>
#include <OpenImageIO/imagebuf.h>
#include <OpenImageIO/imageio.h>
#include <OpenImageIO/memory.h>
#include <OpenImageIO/strutil.h>
#include <OpenImageIO/typedesc.h>
#include <OpenImageIO/memory.h>

#include "exif.h"
#include "imageio_pvt.h"
Expand Down
30 changes: 30 additions & 0 deletions src/libOpenImageIO/imageinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ class ImageInput::Impl {
// The "local" proxy that we will create to use if the user didn't
// supply a proxy for us to use.
std::unique_ptr<Filesystem::IOProxy> m_io_local;

size_t datasize() const
{
/// Note: IOPRoxy and inherited classes do not implement datasize() and
/// footprint() yet. We might consider it for a more accurate tracking
/// of the memory.
size_t size = (m_io ? sizeof(Filesystem::IOProxy) : 0);
size += (m_io_local ? sizeof(Filesystem::IOProxy) : 0);
return size;
}

size_t footprint() const { return sizeof(ImageInput::Impl) + datasize(); }
};


Expand Down Expand Up @@ -1337,4 +1349,22 @@ ImageInput::check_open(const ImageSpec& spec, ROI range, uint64_t /*flags*/)
return true; // all is ok
}



size_t
ImageInput::datasize() const
{
size_t size = m_spec.datasize();
size += (m_impl ? m_impl->footprint() : 0);
return size;
}



size_t
ImageInput::footprint() const
{
return sizeof(ImageInput) + datasize();
}

OIIO_NAMESPACE_END
Loading

0 comments on commit 9e20cff

Please sign in to comment.