presentation.c revision cae77aa80b3629a147ce3ae4526646014efae595
1/**************************************************************************
2 *
3 * Copyright 2010 Thomas Balling Sørensen.
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 "vdpau_private.h"
29#include <vdpau/vdpau.h>
30#include <util/u_debug.h>
31#include <util/u_memory.h>
32
33VdpStatus
34vlVdpPresentationQueueTargetDestroy(VdpPresentationQueueTarget presentation_queue_target)
35{
36   return VDP_STATUS_NO_IMPLEMENTATION;
37}
38
39VdpStatus
40vlVdpPresentationQueueCreate(VdpDevice device,
41                             VdpPresentationQueueTarget presentation_queue_target,
42                             VdpPresentationQueue *presentation_queue)
43{
44   vlVdpPresentationQueue *pq = NULL;
45   struct pipe_video_context *context;
46   VdpStatus ret;
47
48   _debug_printf("[VDPAU] Creating PresentationQueue\n");
49
50   if (!presentation_queue)
51      return VDP_STATUS_INVALID_POINTER;
52
53   vlVdpDevice *dev = vlGetDataHTAB(device);
54   if (!dev)
55      return VDP_STATUS_INVALID_HANDLE;
56
57   vlVdpPresentationQueueTarget *pqt = vlGetDataHTAB(presentation_queue_target);
58   if (!pqt)
59      return VDP_STATUS_INVALID_HANDLE;
60
61   if (dev != pqt->device)
62      return VDP_STATUS_HANDLE_DEVICE_MISMATCH;
63
64   context = dev->context->vpipe;
65
66   pq = CALLOC(1, sizeof(vlVdpPresentationQueue));
67   if (!pq)
68      return VDP_STATUS_RESOURCES;
69
70   pq->device = dev;
71   pq->compositor = context->create_compositor(context);
72   pq->drawable = pqt->drawable;
73   if (!pq->compositor) {
74      ret = VDP_STATUS_ERROR;
75      goto no_compositor;
76   }
77
78   *presentation_queue = vlAddDataHTAB(pq);
79   if (*presentation_queue == 0) {
80      ret = VDP_STATUS_ERROR;
81      goto no_handle;
82   }
83
84   return VDP_STATUS_OK;
85no_handle:
86no_compositor:
87   FREE(pq);
88   return ret;
89}
90
91VdpStatus
92vlVdpPresentationQueueDestroy(VdpPresentationQueue presentation_queue)
93{
94   return VDP_STATUS_NO_IMPLEMENTATION;
95}
96
97VdpStatus
98vlVdpPresentationQueueSetBackgroundColor(VdpPresentationQueue presentation_queue,
99                                         VdpColor *const background_color)
100{
101   if (!background_color)
102      return VDP_STATUS_INVALID_POINTER;
103
104   return VDP_STATUS_NO_IMPLEMENTATION;
105}
106
107VdpStatus
108vlVdpPresentationQueueGetBackgroundColor(VdpPresentationQueue presentation_queue,
109                                         VdpColor *const background_color)
110{
111   if (!background_color)
112      return VDP_STATUS_INVALID_POINTER;
113
114   return VDP_STATUS_NO_IMPLEMENTATION;
115}
116
117VdpStatus
118vlVdpPresentationQueueGetTime(VdpPresentationQueue presentation_queue,
119                              VdpTime *current_time)
120{
121   if (!current_time)
122      return VDP_STATUS_INVALID_POINTER;
123
124   return VDP_STATUS_NO_IMPLEMENTATION;
125}
126
127VdpStatus
128vlVdpPresentationQueueDisplay(VdpPresentationQueue presentation_queue,
129                              VdpOutputSurface surface,
130                              uint32_t clip_width,
131                              uint32_t clip_height,
132                              VdpTime  earliest_presentation_time)
133{
134   vlVdpPresentationQueue *pq;
135   vlVdpOutputSurface *surf;
136   struct pipe_surface *drawable_surface;
137
138   pq = vlGetDataHTAB(presentation_queue);
139   if (!pq)
140      return VDP_STATUS_INVALID_HANDLE;
141
142   drawable_surface = vl_drawable_surface_get(pq->device->context, pq->drawable);
143   if (!drawable_surface)
144      return VDP_STATUS_INVALID_HANDLE;
145
146   surf = vlGetDataHTAB(surface);
147   if (!surf)
148      return VDP_STATUS_INVALID_HANDLE;
149
150   pq->compositor->clear_layers(pq->compositor);
151   pq->compositor->set_rgba_layer(pq->compositor, 0, surf->sampler_view, NULL, NULL);
152   pq->compositor->render_picture(pq->compositor, PIPE_MPEG12_PICTURE_TYPE_FRAME,
153                                  drawable_surface, NULL, NULL);
154
155   pq->device->context->vpipe->screen->flush_frontbuffer
156   (
157      pq->device->context->vpipe->screen,
158      drawable_surface->texture,
159      0, 0,
160      vl_contextprivate_get(pq->device->context, drawable_surface)
161   );
162
163   return VDP_STATUS_OK;
164}
165
166VdpStatus
167vlVdpPresentationQueueBlockUntilSurfaceIdle(VdpPresentationQueue presentation_queue,
168                                            VdpOutputSurface surface,
169                                            VdpTime *first_presentation_time)
170{
171   if (!first_presentation_time)
172      return VDP_STATUS_INVALID_POINTER;
173
174   //return VDP_STATUS_NO_IMPLEMENTATION;
175   return VDP_STATUS_OK;
176}
177
178VdpStatus
179vlVdpPresentationQueueQuerySurfaceStatus(VdpPresentationQueue presentation_queue,
180                                         VdpOutputSurface surface,
181                                         VdpPresentationQueueStatus *status,
182                                         VdpTime *first_presentation_time)
183{
184   if (!(status && first_presentation_time))
185      return VDP_STATUS_INVALID_POINTER;
186
187   return VDP_STATUS_NO_IMPLEMENTATION;
188}
189