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.h
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 #ifndef I965_TEST_FIXTURE_H
26 #define I965_TEST_FIXTURE_H
27
28 #include "i965_test_environment.h"
29
30 #include <string>
31 #include <vector>
32
33 typedef std::vector<VASurfaceID> Surfaces;
34 typedef std::vector<VASurfaceAttrib> SurfaceAttribs;
35 typedef std::vector<VAConfigAttrib> ConfigAttribs;
36 typedef std::vector<VABufferID> Buffers;
37
38 /**
39  * This test fixture defines various operators to make it implicitly convertible
40  * to a VADriverContextP, VADisplay, VADisplayContextP, and i965_driver_data*.
41  * Other operators may be defined, too.  These operators allow an instance of
42  * the test fixture to be passed to various driver functions that take one of
43  * those parameter types.  Various driver functions are also wrapped by this
44  * test fixture to simplify writing test cases.
45  *
46  * Test cases that wish to use this fixture should define their own test
47  * fixture class that derives from this one.
48  *
49  * See the "Test Fixtures" section in gtest/docs/Primer.md for more details
50  * on how test fixtures are used.
51  */
52 class I965TestFixture
53     : public ::testing::Test
54 {
55 public:
56     virtual ~I965TestFixture() { }
57
58     const std::string getFullTestName() const;
59
60     /**
61      * Convenience wrapper for i965_CreateSurfaces or i965_CreateSurfaces2.
62      * If SurfaceAttribs are specified then i965_CreateSurfaces2 is used,
63      * otherwise i965_CreateSurfaces is used. May generate a non-fatal test
64      * assertion failure.
65      */
66     Surfaces createSurfaces(int w, int h, int format, size_t count = 1,
67         const SurfaceAttribs& = SurfaceAttribs());
68
69     /**
70      * Convenience wrapper for i965_DestroySurfaces.  May generate a non-fatal
71      * test assertion failure.
72      */
73     void destroySurfaces(Surfaces&);
74
75     /**
76      * Convenience wrapper for i965_CreateConfig.  May generate a non-fatal
77      * test assertion failure.
78      */
79     VAConfigID createConfig(VAProfile, VAEntrypoint,
80         const ConfigAttribs& = ConfigAttribs());
81
82     /**
83      * Convenience wrapper for i965_DestroyConfig.  May generate a non-fatal
84      * test assertion failure.
85      */
86     void destroyConfig(VAConfigID);
87
88     /**
89      * Convenience wrapper for i965_CreateContext.  May generate a non-fatal
90      * test assertion failure.
91      */
92     VAContextID createContext(VAConfigID, int, int, int = 0,
93         const Surfaces& = Surfaces());
94
95     /**
96      * Convenience wrapper for i965_DestroyContext.  May generate a non-fatal
97      * test assertion failure.
98      */
99     void destroyContext(VAContextID);
100
101     /**
102      * Convenience wrapper for i965_CreateBuffer.  May generate a non-fatal
103      * test assertion failure.
104      */
105     VABufferID createBuffer(
106         VAContextID, VABufferType, unsigned, unsigned = 1, const void * = NULL);
107
108     /**
109      * Convenience wrapper for i965_DestroyBuffer.  May generate a non-fatal
110      * test assertion failure.
111      */
112     void destroyBuffer(VABufferID);
113
114     /**
115      * Convenience wrapper for i965_MapBuffer.  May generate a non-fatal
116      * test assertion failure.
117      */
118     template<typename T>
119     T* mapBuffer(VABufferID id)
120     {
121         T* data = NULL;
122         EXPECT_STATUS(
123             i965_MapBuffer(*this, id, (void**)&data));
124         EXPECT_PTR(data);
125         return data;
126     }
127
128     /**
129      * Convenience Wrapper for i965_UnmapBuffer.  May generate a non-fatal
130      * test assertion failure.
131      */
132     void unmapBuffer(VABufferID id)
133     {
134         EXPECT_STATUS(
135             i965_UnmapBuffer(*this, id));
136     }
137
138     /**
139      * Convenience wrapper for i965_BeginPicture.  May generate a non-fatal
140      * test assertion failure.
141      */
142     void beginPicture(VAContextID, VASurfaceID);
143
144     /**
145      * Convenience wrapper for i965_RenderPicture.  May generate a non-fatal
146      * test assertion failure.
147      */
148     void renderPicture(VAContextID, VABufferID *, int = 1);
149
150     /**
151      * Convenience wrapper for i965_EndPicture.  May generate a non-fatal
152      * test assertion failure.
153      */
154     void endPicture(VAContextID);
155
156     /**
157      * Convenience wrapper for i965_DeriveImage.  May generate a non-fatal
158      * test assertion failure.
159      */
160     void deriveImage(VASurfaceID, VAImage &);
161
162     /**
163      * Convenience wrapper for i965_DestroyImage.  May generate a non-fatal
164      * test assertion failure.
165      */
166     void destroyImage(VAImage &);
167
168     /**
169      * Convenience wrapper for i965_SyncSurface.  May generate a non-fatal
170      * test assertion failure.
171      */
172     void syncSurface(VASurfaceID);
173
174     /**
175      * VADisplay implicit and explicit conversion operator.
176      */
177     inline operator VADisplay()
178     { return *I965TestEnvironment::instance(); }
179
180     /**
181      * VADisplayContextP implict and explicit conversion operator.
182      */
183     inline operator VADisplayContextP()
184     { return *I965TestEnvironment::instance(); }
185
186     /**
187      * VADriverContextP implict and explicit conversion operator.
188      */
189     inline operator VADriverContextP()
190     { return *I965TestEnvironment::instance(); }
191
192     /**
193      * i965_driver_data * implict and explicit conversion operator.
194      */
195     inline operator struct i965_driver_data *()
196     { return *I965TestEnvironment::instance(); }
197 };
198
199 #endif