r300g: align the height of NPOT textures to POT
[profile/ivi/mesa.git] / src / gallium / state_trackers / xorg / xvmc / subpicture.c
1 /**************************************************************************
2  * 
3  * Copyright 2009 Younes Manton.
4  * All Rights Reserved.
5  * 
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sub license, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  * 
14  * The above copyright notice and this permission notice (including the
15  * next paragraph) shall be included in all copies or substantial portions
16  * of the Software.
17  * 
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  * 
26  **************************************************************************/
27
28 #include <assert.h>
29 #include <X11/Xlibint.h>
30 #include <X11/extensions/XvMClib.h>
31
32 Status XvMCCreateSubpicture(Display *dpy, XvMCContext *context, XvMCSubpicture *subpicture,
33                             unsigned short width, unsigned short height, int xvimage_id)
34 {
35    assert(dpy);
36
37    if (!context)
38       return XvMCBadContext;
39
40    assert(subpicture);
41
42    /*if (width > || height > )
43       return BadValue;*/
44
45    /*if (xvimage_id != )
46       return BadMatch;*/
47
48    subpicture->subpicture_id = XAllocID(dpy);
49    subpicture->context_id = context->context_id;
50    subpicture->xvimage_id = xvimage_id;
51    subpicture->width = width;
52    subpicture->height = height;
53    subpicture->num_palette_entries = 0;
54    subpicture->entry_bytes = 0;
55    subpicture->component_order[0] = 0;
56    subpicture->component_order[1] = 0;
57    subpicture->component_order[2] = 0;
58    subpicture->component_order[3] = 0;
59    /* TODO: subpicture->privData = ;*/
60
61    SyncHandle();
62
63    return Success;
64 }
65
66 Status XvMCClearSubpicture(Display *dpy, XvMCSubpicture *subpicture, short x, short y,
67                            unsigned short width, unsigned short height, unsigned int color)
68 {
69    assert(dpy);
70
71    if (!subpicture)
72       return XvMCBadSubpicture;
73
74    /* TODO: Assert clear rect is within bounds? Or clip? */
75
76    return Success;
77 }
78
79 Status XvMCCompositeSubpicture(Display *dpy, XvMCSubpicture *subpicture, XvImage *image,
80                                short srcx, short srcy, unsigned short width, unsigned short height,
81                                short dstx, short dsty)
82 {
83    assert(dpy);
84
85    if (!subpicture)
86       return XvMCBadSubpicture;
87
88    assert(image);
89
90    if (subpicture->xvimage_id != image->id)
91       return BadMatch;
92
93    /* TODO: Assert rects are within bounds? Or clip? */
94
95    return Success;
96 }
97
98 Status XvMCDestroySubpicture(Display *dpy, XvMCSubpicture *subpicture)
99 {
100    assert(dpy);
101
102    if (!subpicture)
103       return XvMCBadSubpicture;
104
105    return BadImplementation;
106 }
107
108 Status XvMCSetSubpicturePalette(Display *dpy, XvMCSubpicture *subpicture, unsigned char *palette)
109 {
110    assert(dpy);
111
112    if (!subpicture)
113       return XvMCBadSubpicture;
114
115    assert(palette);
116
117    /* We don't support paletted subpictures */
118    return BadMatch;
119 }
120
121 Status XvMCBlendSubpicture(Display *dpy, XvMCSurface *target_surface, XvMCSubpicture *subpicture,
122                            short subx, short suby, unsigned short subw, unsigned short subh,
123                            short surfx, short surfy, unsigned short surfw, unsigned short surfh)
124 {
125    assert(dpy);
126
127    if (!target_surface)
128       return XvMCBadSurface;
129
130    if (!subpicture)
131       return XvMCBadSubpicture;
132
133    if (target_surface->context_id != subpicture->context_id)
134       return BadMatch;
135
136    /* TODO: Assert rects are within bounds? Or clip? */
137    return Success;
138 }
139
140 Status XvMCBlendSubpicture2(Display *dpy, XvMCSurface *source_surface, XvMCSurface *target_surface,
141                             XvMCSubpicture *subpicture, short subx, short suby, unsigned short subw, unsigned short subh,
142                             short surfx, short surfy, unsigned short surfw, unsigned short surfh)
143 {
144    assert(dpy);
145
146    if (!source_surface || !target_surface)
147       return XvMCBadSurface;
148
149    if (!subpicture)
150       return XvMCBadSubpicture;
151
152    if (source_surface->context_id != subpicture->context_id)
153       return BadMatch;
154
155    if (source_surface->context_id != subpicture->context_id)
156       return BadMatch;
157
158    /* TODO: Assert rects are within bounds? Or clip? */
159    return Success;
160 }
161
162 Status XvMCSyncSubpicture(Display *dpy, XvMCSubpicture *subpicture)
163 {
164    assert(dpy);
165
166    if (!subpicture)
167       return XvMCBadSubpicture;
168
169    return Success;
170 }
171
172 Status XvMCFlushSubpicture(Display *dpy, XvMCSubpicture *subpicture)
173 {
174    assert(dpy);
175
176    if (!subpicture)
177       return XvMCBadSubpicture;
178
179    return Success;
180 }
181
182 Status XvMCGetSubpictureStatus(Display *dpy, XvMCSubpicture *subpicture, int *status)
183 {
184    assert(dpy);
185
186    if (!subpicture)
187       return XvMCBadSubpicture;
188
189    assert(status);
190
191    /* TODO */
192    *status = 0;
193
194    return Success;
195 }