image: add stride and size queries

This commit is contained in:
Danny Robson 2015-06-15 17:48:19 +10:00
parent ca59c95c26
commit c885e753d2
2 changed files with 21 additions and 1 deletions

View File

@ -51,6 +51,8 @@ namespace util { namespace image {
//--------------------------------------------------------------------- //---------------------------------------------------------------------
constexpr extent2u extent (void) const; constexpr extent2u extent (void) const;
constexpr extent2u stride (void) const;
constexpr size_t size (void) const; // elements allocated
constexpr bool is_packed (void) const; constexpr bool is_packed (void) const;

View File

@ -29,11 +29,29 @@ namespace util { namespace image {
} }
//-------------------------------------------------------------------------
template <typename T>
constexpr extent2u
buffer<T>::stride (void) const
{
return { 1, s };
}
//-------------------------------------------------------------------------
template <typename T>
constexpr size_t
buffer<T>::size (void) const
{
return extent ()[1] * stride ()[1];
}
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
template <typename T> template <typename T>
constexpr bool constexpr bool
buffer<T>::is_packed (void) const buffer<T>::is_packed (void) const
{ {
return s == w; return stride ()[1] == extent ()[0];
} }
} } } }