• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 VMWARE 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 #ifndef DRI_DRAWABLE_H
29 #define DRI_DRAWABLE_H
30 
31 #include "util/compiler.h"
32 #include "util/format/u_formats.h"
33 #include "frontend/api.h"
34 #include "dri_util.h"
35 
36 struct dri_context;
37 struct dri_screen;
38 
39 struct dri_drawable
40 {
41    struct pipe_frontend_drawable base;
42    struct st_visual stvis;
43 
44    struct dri_screen *screen;
45 
46    __DRIbuffer old[__DRI_BUFFER_COUNT];
47    unsigned old_num;
48    unsigned old_w;
49    unsigned old_h;
50 
51    struct pipe_box *damage_rects;
52    unsigned int num_damage_rects;
53 
54    struct pipe_resource *textures[ST_ATTACHMENT_COUNT];
55    struct pipe_resource *msaa_textures[ST_ATTACHMENT_COUNT];
56    unsigned int texture_mask, texture_stamp;
57    int swap_interval;
58 
59    struct pipe_fence_handle *throttle_fence;
60    bool flushing; /* prevents recursion in dri_flush */
61 
62    /**
63     * Private data from the loader.  We just hold on to it and pass
64     * it back when calling into loader provided functions.
65     */
66    void *loaderPrivate;
67 
68    /**
69     * Reference count for number of context's currently bound to this
70     * drawable.
71     *
72     * Once it reaches zero, the drawable can be destroyed.
73     *
74     * \note This behavior will change with GLX 1.3.
75     */
76    int refcount;
77 
78    /**
79     * Increased when the loader calls invalidate.
80     *
81     * If this changes, the drawable information (below) should be retrieved
82     * from the loader.
83     */
84    unsigned int lastStamp;
85    int w, h;
86 
87    /* generic for swrast */
88    unsigned buffer_age;
89 
90    /* kopper */
91    struct kopper_loader_info info;
92    struct dri_image   *image; //texture_from_pixmap
93    bool is_window;
94    bool window_valid;
95 
96    /* hooks filled in by dri2 & drisw */
97    void (*allocate_textures)(struct dri_context *ctx,
98                              struct dri_drawable *drawable,
99                              const enum st_attachment_type *statts,
100                              unsigned count);
101 
102    void (*update_drawable_info)(struct dri_drawable *drawable);
103 
104    bool (*flush_frontbuffer)(struct dri_context *ctx,
105                              struct dri_drawable *drawable,
106                              enum st_attachment_type statt);
107 
108    void (*update_tex_buffer)(struct dri_drawable *drawable,
109                              struct dri_context *ctx,
110                              struct pipe_resource *res);
111    void (*flush_swapbuffers)(struct dri_context *ctx,
112                              struct dri_drawable *drawable);
113 
114    void (*swap_buffers)(struct dri_drawable *drawable);
115    void (*swap_buffers_with_damage)(struct dri_drawable *drawable, int nrects, const int *rects);
116 };
117 
118 static inline void
dri_get_drawable(struct dri_drawable * drawable)119 dri_get_drawable(struct dri_drawable *drawable)
120 {
121     drawable->refcount++;
122 }
123 
124 /***********************************************************************
125  * dri_drawable.c
126  */
127 void
128 dri_put_drawable(struct dri_drawable *drawable);
129 
130 void
131 dri_drawable_get_format(struct dri_drawable *drawable,
132                         enum st_attachment_type statt,
133                         enum pipe_format *format,
134                         unsigned *bind);
135 
136 void
137 dri_pipe_blit(struct pipe_context *pipe,
138               struct pipe_resource *dst,
139               struct pipe_resource *src);
140 
141 void
142 dri_flush(struct dri_context *ctx,
143           struct dri_drawable *drawable,
144           unsigned flags,
145           enum __DRI2throttleReason reason);
146 
147 void
148 dri_flush_drawable(struct dri_drawable *dPriv);
149 
150 extern const __DRItexBufferExtension driTexBufferExtension;
151 
152 void
153 drisw_update_tex_buffer(struct dri_drawable *drawable,
154                         struct dri_context *ctx,
155                         struct pipe_resource *res);
156 
157 void
158 kopper_init_drawable(struct dri_drawable *drawable, bool isPixmap, int alphaBits);
159 void
160 drisw_init_drawable(struct dri_drawable *drawable, bool isPixmap, int alphaBits);
161 void
162 dri2_init_drawable(struct dri_drawable *drawable, bool isPixmap, int alphaBits);
163 #endif
164 
165 /* vim: set sw=3 ts=8 sts=3 expandtab: */
166