From c885e753d2d081354907625f37e1f9047f340b8e Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Mon, 15 Jun 2015 17:48:19 +1000 Subject: [PATCH] image: add stride and size queries --- image.hpp | 2 ++ image.ipp | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/image.hpp b/image.hpp index 63961e02..8d23c812 100644 --- a/image.hpp +++ b/image.hpp @@ -51,6 +51,8 @@ namespace util { namespace image { //--------------------------------------------------------------------- constexpr extent2u extent (void) const; + constexpr extent2u stride (void) const; + constexpr size_t size (void) const; // elements allocated constexpr bool is_packed (void) const; diff --git a/image.ipp b/image.ipp index 4709a1ce..c1018d6b 100644 --- a/image.ipp +++ b/image.ipp @@ -29,11 +29,29 @@ namespace util { namespace image { } + //------------------------------------------------------------------------- + template + constexpr extent2u + buffer::stride (void) const + { + return { 1, s }; + } + + + //------------------------------------------------------------------------- + template + constexpr size_t + buffer::size (void) const + { + return extent ()[1] * stride ()[1]; + } + + //------------------------------------------------------------------------- template constexpr bool buffer::is_packed (void) const { - return s == w; + return stride ()[1] == extent ()[0]; } } }