OSDN Git Service

4588aa45bb44b6ad3ba18c100f75465dfbdb7bcc
[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
56     for (size_t i(0); i < count; ++i) {
57         EXPECT_ID(surfaces[i]);
58     }
59
60     return surfaces;
61 }
62
63 void I965TestFixture::destroySurfaces(Surfaces& surfaces)
64 {
65     EXPECT_STATUS(
66         i965_DestroySurfaces(*this, surfaces.data(), surfaces.size()));
67 }
68
69 VAConfigID I965TestFixture::createConfig(
70     VAProfile profile, VAEntrypoint entrypoint, const ConfigAttribs& attribs)
71 {
72     VAConfigID id = VA_INVALID_ID;
73     EXPECT_STATUS(
74         i965_CreateConfig(
75             *this, profile, entrypoint,
76             const_cast<VAConfigAttrib*>(attribs.data()), attribs.size(), &id));
77     EXPECT_ID(id);
78
79     return id;
80 }
81
82 void I965TestFixture::destroyConfig(VAConfigID id)
83 {
84     EXPECT_STATUS(i965_DestroyConfig(*this, id));
85 }
86
87 VAContextID I965TestFixture::createContext(
88     VAConfigID config, int w, int h, int flags, const Surfaces& targets)
89 {
90     VAContextID id = VA_INVALID_ID;
91     EXPECT_STATUS(
92         i965_CreateContext(
93             *this, config, w, h, flags,
94             const_cast<VASurfaceID*>(targets.data()), targets.size(), &id));
95     EXPECT_ID(id);
96
97     return id;
98 }
99
100 void I965TestFixture::destroyContext(VAContextID id)
101 {
102     EXPECT_STATUS(i965_DestroyContext(*this, id));
103 }
104
105 VABufferID I965TestFixture::createBuffer(
106     VAContextID context, VABufferType type,
107     unsigned size, unsigned num, const void *data)
108 {
109     VABufferID id;
110     EXPECT_STATUS(
111         i965_CreateBuffer(*this, context, type, size, num, (void*)data, &id));
112     EXPECT_ID(id);
113
114     return id;
115 }
116
117 void I965TestFixture::beginPicture(VAContextID context, VASurfaceID target)
118 {
119     EXPECT_STATUS(
120         i965_BeginPicture(*this, context, target));
121 }
122
123 void I965TestFixture::renderPicture(
124     VAContextID context, VABufferID *bufs, int num_bufs)
125 {
126     EXPECT_STATUS(
127         i965_RenderPicture(*this, context, bufs, num_bufs));
128 }
129
130 void I965TestFixture::endPicture(VAContextID context)
131 {
132     EXPECT_STATUS(
133         i965_EndPicture(*this, context));
134 }
135
136 void I965TestFixture::destroyBuffer(VABufferID id)
137 {
138     EXPECT_STATUS(
139         i965_DestroyBuffer(*this, id));
140 }
141
142 void I965TestFixture::deriveImage(VASurfaceID surface, VAImage &image)
143 {
144     EXPECT_STATUS(
145         i965_DeriveImage(*this, surface, &image));
146 }
147
148 void I965TestFixture::destroyImage(VAImage &image)
149 {
150     EXPECT_STATUS(
151         i965_DestroyImage(*this, image.image_id));
152 }
153
154 void I965TestFixture::syncSurface(VASurfaceID surface)
155 {
156     EXPECT_STATUS(
157         i965_SyncSurface(*this, surface));
158 }