Tizen 2.0 Release
[profile/ivi/osmesa.git] / src / gallium / state_trackers / egl / common / native_helper.h
1 /*
2  * Mesa 3-D graphics library
3  * Version:  7.9
4  *
5  * Copyright (C) 2010 LunarG Inc.
6  * Copyright (C) 2011 VMware Inc. All rights reserved.
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation
11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12  * and/or sell copies of the Software, and to permit persons to whom the
13  * Software is furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included
16  * in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
21  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24  * DEALINGS IN THE SOFTWARE.
25  *
26  * Authors:
27  *    Chia-I Wu <olv@lunarg.com>
28  *    Thomas Hellstrom <thellstrom@vmware.com>
29  */
30
31 #include "native.h"
32
33 struct resource_surface;
34 struct sw_winsys;
35
36 struct resource_surface *
37 resource_surface_create(struct pipe_screen *screen,
38                         enum pipe_format format, uint bind);
39
40 void
41 resource_surface_destroy(struct resource_surface *rsurf);
42
43 boolean
44 resource_surface_set_size(struct resource_surface *rsurf,
45                           uint width, uint height);
46
47 void
48 resource_surface_get_size(struct resource_surface *rsurf,
49                           uint *width, uint *height);
50
51 boolean
52 resource_surface_add_resources(struct resource_surface *rsurf,
53                                uint resource_mask);
54
55 void
56 resource_surface_import_resource(struct resource_surface *rsurf,
57                                  enum native_attachment which,
58                                  struct pipe_resource *pres);
59
60 void
61 resource_surface_get_resources(struct resource_surface *rsurf,
62                                struct pipe_resource **resources,
63                                uint resource_mask);
64
65 struct pipe_resource *
66 resource_surface_get_single_resource(struct resource_surface *rsurf,
67                                      enum native_attachment which);
68
69 void
70 resource_surface_swap_buffers(struct resource_surface *rsurf,
71                               enum native_attachment buf1,
72                               enum native_attachment buf2,
73                               boolean only_if_exist);
74
75 boolean
76 resource_surface_present(struct resource_surface *rsurf,
77                          enum native_attachment which,
78                          void *winsys_drawable_handle);
79
80 /**
81  * Perform a gallium copy blit between the back left and front left
82  * surfaces. Needs to be followed by a call to resource_surface_flush.
83  */
84 boolean
85 resource_surface_copy_swap(struct resource_surface *rsurf,
86                            struct native_display *ndpy);
87
88 /**
89  * Throttle on outstanding rendering using the copy context. For example
90  * copy swaps.
91  */
92 boolean
93 resource_surface_throttle(struct resource_surface *rsurf);
94
95 /**
96  * Flush pending rendering using the copy context. This function saves a
97  * marker for upcoming throttles.
98  */
99 boolean
100 resource_surface_flush(struct resource_surface *rsurf,
101                        struct native_display *ndpy);
102 /**
103  * Wait for all rendering using the copy context to be complete. Frees all
104  * throttle markers saved using resource_surface_flush.
105  */
106 void
107 resource_surface_wait(struct resource_surface *rsurf);
108
109 struct pipe_resource *
110 drm_display_import_native_buffer(struct native_display *ndpy,
111                                  struct native_buffer *nbuf);
112
113 boolean
114 drm_display_export_native_buffer(struct native_display *ndpy,
115                                  struct pipe_resource *res,
116                                  struct native_buffer *nbuf);