r300g: align the height of NPOT textures to POT
[profile/ivi/mesa.git] / src / gallium / auxiliary / util / u_simple_screen.c
1 /**************************************************************************
2  *
3  * Copyright 2009 VMware, Inc.
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 "u_simple_screen.h"
29
30 #include "pipe/p_screen.h"
31 #include "pipe/p_state.h"
32 #include "util/u_simple_screen.h"
33
34
35 static struct pipe_buffer *
36 pass_buffer_create(struct pipe_screen *screen,
37                    unsigned alignment,
38                    unsigned usage,
39                    unsigned size)
40 {
41    struct pipe_buffer *buffer =
42       screen->winsys->buffer_create(screen->winsys, alignment, usage, size);
43
44    buffer->screen = screen;
45
46    return buffer;
47 }
48
49 static struct pipe_buffer *
50 pass_user_buffer_create(struct pipe_screen *screen,
51                         void *ptr,
52                         unsigned bytes)
53 {
54    struct pipe_buffer *buffer =
55       screen->winsys->user_buffer_create(screen->winsys, ptr, bytes);
56
57    buffer->screen = screen;
58
59    return buffer;
60 }
61
62
63
64 static void *
65 pass_buffer_map(struct pipe_screen *screen,
66                 struct pipe_buffer *buf,
67                 unsigned usage)
68 {
69    return screen->winsys->buffer_map(screen->winsys, buf, usage);
70 }
71
72 static void
73 pass_buffer_unmap(struct pipe_screen *screen,
74                   struct pipe_buffer *buf)
75 {
76    screen->winsys->buffer_unmap(screen->winsys, buf);
77 }
78
79 static void
80 pass_buffer_destroy(struct pipe_buffer *buf)
81 {
82    buf->screen->winsys->buffer_destroy(buf);
83 }
84
85
86 static void
87 pass_flush_frontbuffer(struct pipe_screen *screen,
88                        struct pipe_surface *surf,
89                        void *context_private)
90 {
91    screen->winsys->flush_frontbuffer(screen->winsys, surf, context_private);
92 }
93
94 static void
95 pass_fence_reference(struct pipe_screen *screen,
96                      struct pipe_fence_handle **ptr,
97                      struct pipe_fence_handle *fence)
98 {
99    screen->winsys->fence_reference(screen->winsys, ptr, fence);
100 }
101
102 static int
103 pass_fence_signalled(struct pipe_screen *screen,
104                      struct pipe_fence_handle *fence,
105                      unsigned flag)
106 {
107    return screen->winsys->fence_signalled(screen->winsys, fence, flag);
108 }
109
110 static int
111 pass_fence_finish(struct pipe_screen *screen,
112                   struct pipe_fence_handle *fence,
113                   unsigned flag)
114 {
115    return screen->winsys->fence_finish(screen->winsys, fence, flag);
116 }
117
118 void
119 u_simple_screen_init(struct pipe_screen *screen)
120 {
121    screen->buffer_create = pass_buffer_create;
122    screen->user_buffer_create = pass_user_buffer_create;
123
124    screen->buffer_map = pass_buffer_map;
125    screen->buffer_unmap = pass_buffer_unmap;
126    screen->buffer_destroy = pass_buffer_destroy;
127    screen->flush_frontbuffer = pass_flush_frontbuffer;
128    screen->fence_reference = pass_fence_reference;
129    screen->fence_signalled = pass_fence_signalled;
130    screen->fence_finish = pass_fence_finish;
131 }
132
133 const char *
134 u_simple_screen_winsys_name(struct pipe_screen *screen)
135 {
136    return screen->winsys->get_name(screen->winsys);
137 }