OSDN Git Service

build: autotools: don't check for X11 libraries
[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     const VAStatus expect)
72 {
73     VAConfigID id = VA_INVALID_ID;
74     EXPECT_STATUS_EQ(
75         expect,
76         i965_CreateConfig(
77             *this, profile, entrypoint,
78             const_cast<VAConfigAttrib*>(attribs.data()), attribs.size(), &id));
79     if (expect == VA_STATUS_SUCCESS) {
80         EXPECT_ID(id);
81     } else {
82         EXPECT_INVALID_ID(id);
83     }
84     return id;
85 }
86
87 void I965TestFixture::destroyConfig(VAConfigID id)
88 {
89     EXPECT_STATUS(i965_DestroyConfig(*this, id));
90 }
91
92 VAContextID I965TestFixture::createContext(
93     VAConfigID config, int w, int h, int flags, const Surfaces& targets)
94 {
95     VAContextID id = VA_INVALID_ID;
96     EXPECT_STATUS(
97         i965_CreateContext(
98             *this, config, w, h, flags,
99             const_cast<VASurfaceID*>(targets.data()), targets.size(), &id));
100     EXPECT_ID(id);
101
102     return id;
103 }
104
105 void I965TestFixture::destroyContext(VAContextID id)
106 {
107     EXPECT_STATUS(i965_DestroyContext(*this, id));
108 }
109
110 VABufferID I965TestFixture::createBuffer(
111     VAContextID context, VABufferType type,
112     unsigned size, unsigned num, const void *data)
113 {
114     VABufferID id;
115     EXPECT_STATUS(
116         i965_CreateBuffer(*this, context, type, size, num, (void*)data, &id));
117     EXPECT_ID(id);
118
119     return id;
120 }
121
122 void I965TestFixture::beginPicture(VAContextID context, VASurfaceID target)
123 {
124     EXPECT_STATUS(
125         i965_BeginPicture(*this, context, target));
126 }
127
128 void I965TestFixture::renderPicture(
129     VAContextID context, VABufferID *bufs, int num_bufs)
130 {
131     EXPECT_STATUS(
132         i965_RenderPicture(*this, context, bufs, num_bufs));
133 }
134
135 void I965TestFixture::endPicture(VAContextID context)
136 {
137     EXPECT_STATUS(
138         i965_EndPicture(*this, context));
139 }
140
141 void I965TestFixture::destroyBuffer(VABufferID id)
142 {
143     EXPECT_STATUS(
144         i965_DestroyBuffer(*this, id));
145 }
146
147 void I965TestFixture::deriveImage(VASurfaceID surface, VAImage &image)
148 {
149     EXPECT_STATUS(
150         i965_DeriveImage(*this, surface, &image));
151 }
152
153 void I965TestFixture::destroyImage(VAImage &image)
154 {
155     EXPECT_STATUS(
156         i965_DestroyImage(*this, image.image_id));
157 }
158
159 void I965TestFixture::syncSurface(VASurfaceID surface)
160 {
161     EXPECT_STATUS(
162         i965_SyncSurface(*this, surface));
163 }