2 #include "vl_surface.h"
5 #include <pipe/p_screen.h>
6 #include <pipe/p_state.h>
7 #include <pipe/p_inlines.h>
8 #include <util/u_memory.h>
10 #include "vl_screen.h"
11 #include "vl_context.h"
12 #include "vl_render.h"
18 struct vlScreen
*screen
,
22 struct vlSurface
**surface
25 struct vlSurface
*sfc
;
26 struct pipe_texture
template;
31 sfc
= CALLOC_STRUCT(vlSurface
);
41 memset(&template, 0, sizeof(struct pipe_texture
));
42 template.target
= PIPE_TEXTURE_2D
;
43 template.format
= PIPE_FORMAT_A8R8G8B8_UNORM
;
44 template.last_level
= 0;
45 template.width
[0] = vlRoundUpPOT(sfc
->width
);
46 template.height
[0] = vlRoundUpPOT(sfc
->height
);
47 template.depth
[0] = 1;
48 pf_get_block(template.format
, &template.block
);
49 template.tex_usage
= PIPE_TEXTURE_USAGE_SAMPLER
| PIPE_TEXTURE_USAGE_RENDER_TARGET
;
51 sfc
->texture
= vlGetPipeScreen(screen
)->texture_create(vlGetPipeScreen(screen
), &template);
66 struct vlSurface
*surface
71 pipe_texture_reference(&surface
->texture
, NULL
);
77 int vlRenderMacroBlocksMpeg2
79 struct vlMpeg2MacroBlockBatch
*batch
,
80 struct vlSurface
*surface
85 assert(surface
->context
);
87 surface
->context
->render
->vlBegin(surface
->context
->render
);
89 surface
->context
->render
->vlRenderMacroBlocksMpeg2
91 surface
->context
->render
,
96 surface
->context
->render
->vlEnd(surface
->context
->render
);
103 struct vlSurface
*surface
,
104 vlNativeDrawable drawable
,
115 enum vlPictureType picture_type
119 struct pipe_context
*pipe
;
122 assert(surface
->context
);
124 surface
->context
->render
->vlFlush(surface
->context
->render
);
126 csc
= surface
->context
->csc
;
127 pipe
= surface
->context
->pipe
;
129 csc
->vlResizeFrameBuffer(csc
, drawable_w
, drawable_h
);
150 pipe
->flush(pipe
, PIPE_FLUSH_RENDER_CACHE
, &surface
->disp_fence
);
152 bind_pipe_drawable(pipe
, drawable
);
154 pipe
->screen
->flush_frontbuffer
157 csc
->vlGetFrameBuffer(csc
),
164 int vlSurfaceGetStatus
166 struct vlSurface
*surface
,
167 enum vlResourceStatus
*status
171 assert(surface
->context
);
174 if (surface
->render_fence
&& !surface
->context
->pipe
->screen
->fence_signalled(surface
->context
->pipe
->screen
, surface
->render_fence
, 0))
176 *status
= vlResourceStatusRendering
;
180 if (surface
->disp_fence
&& !surface
->context
->pipe
->screen
->fence_signalled(surface
->context
->pipe
->screen
, surface
->disp_fence
, 0))
182 *status
= vlResourceStatusDisplaying
;
186 *status
= vlResourceStatusFree
;
193 struct vlSurface
*surface
197 assert(surface
->context
);
199 surface
->context
->render
->vlFlush(surface
->context
->render
);
206 struct vlSurface
*surface
210 assert(surface
->context
);
211 assert(surface
->render_fence
);
213 surface
->context
->pipe
->screen
->fence_finish(surface
->context
->pipe
->screen
, surface
->render_fence
, 0);
218 struct vlScreen
* vlSurfaceGetScreen
220 struct vlSurface
*surface
225 return surface
->screen
;
228 struct vlContext
* vlBindToContext
230 struct vlSurface
*surface
,
231 struct vlContext
*context
234 struct vlContext
*old
;
238 old
= surface
->context
;
239 surface
->context
= context
;