Merge commit 'origin/gallium-master-merge'
[mesa.git] / src / gallium / winsys / xlib / xlib_trace.c
1 /**************************************************************************
2 *
3 * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA
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 SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 * USE OR OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
24 * of the Software.
25 *
26 *
27 **************************************************************************/
28
29 /*
30 * Authors:
31 * Keith Whitwell
32 * Brian Paul
33 */
34
35
36 #include "xlib.h"
37
38 #include "trace/tr_screen.h"
39 #include "trace/tr_context.h"
40
41 #include "pipe/p_screen.h"
42
43
44
45 static struct pipe_screen *
46 xlib_create_trace_screen( void )
47 {
48 struct pipe_screen *screen, *trace_screen;
49
50 screen = xlib_softpipe_driver.create_pipe_screen();
51 if (screen == NULL)
52 goto fail;
53
54 /* Wrap it:
55 */
56 trace_screen = trace_screen_create(screen);
57 if (trace_screen == NULL)
58 goto fail;
59
60 return trace_screen;
61
62 fail:
63 if (screen)
64 screen->destroy( screen );
65 return NULL;
66 }
67
68 static struct pipe_context *
69 xlib_create_trace_context( struct pipe_screen *screen,
70 void *priv )
71 {
72 struct pipe_context *pipe, *trace_pipe;
73
74 pipe = xlib_softpipe_driver.create_pipe_context( screen, priv );
75 if (pipe == NULL)
76 goto fail;
77
78 /* Wrap it:
79 */
80 trace_pipe = trace_context_create(screen, pipe);
81 if (trace_pipe == NULL)
82 goto fail;
83
84 trace_pipe->priv = priv;
85
86 return trace_pipe;
87
88 fail:
89 return NULL;
90 }
91
92 static void
93 xlib_trace_display_surface( struct xmesa_buffer *buffer,
94 struct pipe_surface *surf )
95 {
96 /* ??
97 */
98 xlib_softpipe_driver.display_surface( buffer, surf );
99 }
100
101
102 struct xm_driver xlib_trace_driver =
103 {
104 .create_pipe_screen = xlib_create_trace_screen,
105 .create_pipe_context = xlib_create_trace_context,
106 .display_surface = xlib_trace_display_surface,
107 };