OSDN Git Service

Bump intel-vaapi-driver to 1.8.3.pre1 for development
[android-x86/hardware-intel-common-vaapi.git] / test / i965_test_fixture.cpp
1 /*
2  * Copyright (C) 2016 Intel Corporation. All Rights Reserved.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the
6  * "Software"), to deal in the Software without restriction, including
7  * without limitation the rights to use, copy, modify, merge, publish,
8  * distribute, sub license, and/or sell copies of the Software, and to
9  * permit persons to whom the Software is furnished to do so, subject to
10  * the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the
13  * next paragraph) shall be included in all copies or substantial portions
14  * of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24
25 #include "i965_test_fixture.h"
26
27 const std::string I965TestFixture::getFullTestName() const
28 {
29     const ::testing::TestInfo * const info =
30         ::testing::UnitTest::GetInstance()->current_test_info();
31     return std::string(info->test_case_name())
32         + std::string(".")
33         + std::string(info->name());
34 }
35
36 Surfaces I965TestFixture::createSurfaces(int w, int h, int format, size_t count,
37     const SurfaceAttribs& attributes)
38 {
39     Surfaces surfaces(count, VA_INVALID_ID);
40     if (attributes.empty()) {
41         EXPECT_STATUS(
42             i965_CreateSurfaces(
43                 *this, w, h, format, surfaces.size(), surfaces.data()));
44     } else {
45         VADriverContextP ctx(*this);
46         EXPECT_PTR(ctx);
47         if (ctx)
48             EXPECT_STATUS(
49                 ctx->vtable->vaCreateSurfaces2(
50                     *this, format, w, h, surfaces.data(), surfaces.size(),
51                     const_cast<VASurfaceAttrib*>(attributes.data()),
52                     attributes.size()));
53     }
54
55     for (size_t i(0); i < count; ++i) {
56         EXPECT_ID(surfaces[i]);
57     }
58
59     return surfaces;
60 }
61
62 void I965TestFixture::destroySurfaces(Surfaces& surfaces)
63 {
64     EXPECT_STATUS(
65         i965_DestroySurfaces(*this, surfaces.data(), surfaces.size()));
66 }
67
68 VAConfigID I965TestFixture::createConfig(
69     VAProfile profile, VAEntrypoint entrypoint, const ConfigAttribs& attribs)
70 {
71     VAConfigID id = VA_INVALID_ID;
72     EXPECT_STATUS(
73         i965_CreateConfig(
74             *this, profile, entrypoint,
75             const_cast<VAConfigAttrib*>(attribs.data()), attribs.size(), &id));
76     EXPECT_ID(id);
77
78     return id;
79 }
80
81 void I965TestFixture::destroyConfig(VAConfigID id)
82 {
83     EXPECT_STATUS(i965_DestroyConfig(*this, id));
84 }
85
86 VAContextID I965TestFixture::createContext(
87     VAConfigID config, int w, int h, int flags, const Surfaces& targets)
88 {
89     VAContextID id = VA_INVALID_ID;
90     EXPECT_STATUS(
91         i965_CreateContext(
92             *this, config, w, h, flags,
93             const_cast<VASurfaceID*>(targets.data()), targets.size(), &id));
94     EXPECT_ID(id);
95
96     return id;
97 }
98
99 void I965TestFixture::destroyContext(VAContextID id)
100 {
101     EXPECT_STATUS(i965_DestroyContext(*this, id));
102 }
103
104 VABufferID I965TestFixture::createBuffer(
105     VAContextID context, VABufferType type,
106     unsigned size, unsigned num, const void *data)
107 {
108     VABufferID id;
109     EXPECT_STATUS(
110         i965_CreateBuffer(*this, context, type, size, num, (void*)data, &id));
111     EXPECT_ID(id);
112
113     return id;
114 }
115
116 void I965TestFixture::beginPicture(VAContextID context, VASurfaceID target)
117 {
118     EXPECT_STATUS(
119         i965_BeginPicture(*this, context, target));
120 }
121
122 void I965TestFixture::renderPicture(
123     VAContextID context, VABufferID *bufs, int num_bufs)
124 {
125     EXPECT_STATUS(
126         i965_RenderPicture(*this, context, bufs, num_bufs));
127 }
128
129 void I965TestFixture::endPicture(VAContextID context)
130 {
131     EXPECT_STATUS(
132         i965_EndPicture(*this, context));
133 }
134
135 void I965TestFixture::destroyBuffer(VABufferID id)
136 {
137     EXPECT_STATUS(
138         i965_DestroyBuffer(*this, id));
139 }
140
141 void I965TestFixture::deriveImage(VASurfaceID surface, VAImage &image)
142 {
143     EXPECT_STATUS(
144         i965_DeriveImage(*this, surface, &image));
145 }
146
147 void I965TestFixture::destroyImage(VAImage &image)
148 {
149     EXPECT_STATUS(
150         i965_DestroyImage(*this, image.image_id));
151 }
152
153 void I965TestFixture::syncSurface(VASurfaceID surface)
154 {
155     EXPECT_STATUS(
156         i965_SyncSurface(*this, surface));
157 }