summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorU. Artie Eoff <ullysses.a.eoff@intel.com>2016-09-28 13:36:06 -0700
committerSean V Kelley <seanvk@posteo.de>2016-10-03 11:30:48 -0700
commitf6ee6933a9d1e7d922817dd1ef770e8939bdedb9 (patch)
treeacad26400615dfd09f3d4ec9b9c2f5843cc3c999
parentb3a8049d5cd9e44daa255173f9783cd4f4b2fa55 (diff)
downloadlibva-intel-driver-f6ee6933a9d1e7d922817dd1ef770e8939bdedb9.tar.gz
test: jpeg/enc: enable shared_from_this on TestInput
...and make the constructor private so that only Shared instances can be created. Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com> Reviewed-by: Sean V Kelley <seanvk@posteo.de>
-rw-r--r--test/i965_jpeg_encode_test.cpp2
-rw-r--r--test/i965_jpeg_test_data.cpp8
-rw-r--r--test/i965_jpeg_test_data.h6
3 files changed, 13 insertions, 3 deletions
diff --git a/test/i965_jpeg_encode_test.cpp b/test/i965_jpeg_encode_test.cpp
index c794bf93..25302888 100644
--- a/test/i965_jpeg_encode_test.cpp
+++ b/test/i965_jpeg_encode_test.cpp
@@ -85,7 +85,7 @@ TEST_F(JPEGEncodeTest, Entrypoint)
const TestInput::Shared NV12toI420(const TestInput::SharedConst& nv12)
{
TestInput::Shared i420(
- new TestInput(VA_FOURCC_I420, nv12->width(), nv12->height()));
+ TestInput::create(VA_FOURCC_I420, nv12->width(), nv12->height()));
i420->bytes = nv12->bytes;
diff --git a/test/i965_jpeg_test_data.cpp b/test/i965_jpeg_test_data.cpp
index 0c1f0d3e..0cf3d23f 100644
--- a/test/i965_jpeg_test_data.cpp
+++ b/test/i965_jpeg_test_data.cpp
@@ -773,6 +773,12 @@ namespace Decode {
namespace JPEG {
namespace Encode {
+ TestInput::Shared TestInput::create(
+ const unsigned fourcc, const unsigned w, const unsigned h)
+ {
+ return Shared(new TestInput(fourcc, w, h));
+ }
+
TestInput::TestInput(
const unsigned fourcc, const unsigned w, const unsigned h)
: bytes() // caller must fill this in after instantiation
@@ -858,7 +864,7 @@ namespace Encode {
{
const std::array<unsigned, 2> res = getResolution();
- TestInput::Shared input(new TestInput(fourcc, res[0], res[1]));
+ TestInput::Shared input(TestInput::create(fourcc, res[0], res[1]));
ByteData& bytes = input->bytes;
RandomValueGenerator<uint8_t> rg(0x00, 0xff);
diff --git a/test/i965_jpeg_test_data.h b/test/i965_jpeg_test_data.h
index cde0cfe8..698385ae 100644
--- a/test/i965_jpeg_test_data.h
+++ b/test/i965_jpeg_test_data.h
@@ -392,12 +392,13 @@ namespace Encode {
};
class TestInput
+ : public std::enable_shared_from_this<TestInput>
{
public:
typedef std::shared_ptr<TestInput> Shared;
typedef std::shared_ptr<const TestInput> SharedConst;
- TestInput(const unsigned, const unsigned, const unsigned);
+ static Shared create(const unsigned, const unsigned, const unsigned);
const unsigned width() const;
const unsigned height() const;
@@ -420,6 +421,9 @@ namespace Encode {
std::array<size_t, 3> heights;
std::array<size_t, 3> offsets;
std::array<size_t, 3> sizes;
+
+ private:
+ TestInput(const unsigned, const unsigned, const unsigned);
};
class TestInputCreator