Merge branch 'mesa_7_5_branch'
[mesa.git] / src / gallium / state_trackers / dri / dri_drawable.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 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 * Author: Keith Whitwell <keithw@vmware.com>
29 * Author: Jakob Bornecrantz <wallbraker@gmail.com>
30 */
31
32 #include "dri_screen.h"
33 #include "dri_context.h"
34 #include "dri_drawable.h"
35
36 #include "pipe/p_context.h"
37 #include "pipe/p_screen.h"
38 #include "pipe/p_inlines.h"
39 #include "state_tracker/drm_api.h"
40 #include "state_tracker/dri1_api.h"
41 #include "state_tracker/st_public.h"
42 #include "state_tracker/st_context.h"
43 #include "state_tracker/st_cb_fbo.h"
44
45 #include "util/u_memory.h"
46
47 static void
48 dri_copy_to_front(__DRIdrawablePrivate * dPriv,
49 struct pipe_surface *from,
50 int x, int y, unsigned w, unsigned h)
51 {
52 /* TODO send a message to the Xserver to copy to the real front buffer */
53 }
54
55 static struct pipe_surface *
56 dri_surface_from_handle(struct drm_api *api,
57 struct pipe_screen *screen,
58 unsigned handle,
59 enum pipe_format format,
60 unsigned width, unsigned height, unsigned pitch)
61 {
62 struct pipe_surface *surface = NULL;
63 struct pipe_texture *texture = NULL;
64 struct pipe_texture templat;
65 struct pipe_buffer *buf = NULL;
66
67 buf = api->buffer_from_handle(api, screen, "dri2 buffer", handle);
68 if (!buf)
69 return NULL;
70
71 memset(&templat, 0, sizeof(templat));
72 templat.tex_usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET;
73 templat.target = PIPE_TEXTURE_2D;
74 templat.last_level = 0;
75 templat.depth[0] = 1;
76 templat.format = format;
77 templat.width[0] = width;
78 templat.height[0] = height;
79 pf_get_block(templat.format, &templat.block);
80
81 texture = screen->texture_blanket(screen, &templat, &pitch, buf);
82
83 /* we don't need the buffer from this point on */
84 pipe_buffer_reference(&buf, NULL);
85
86 if (!texture)
87 return NULL;
88
89 surface = screen->get_tex_surface(screen, texture, 0, 0, 0,
90 PIPE_BUFFER_USAGE_GPU_READ |
91 PIPE_BUFFER_USAGE_GPU_WRITE);
92
93 /* we don't need the texture from this point on */
94 pipe_texture_reference(&texture, NULL);
95 return surface;
96 }
97
98 /**
99 * This will be called a drawable is known to have been resized.
100 */
101 void
102 dri_get_buffers(__DRIdrawablePrivate * dPriv)
103 {
104
105 struct dri_drawable *drawable = dri_drawable(dPriv);
106 struct pipe_surface *surface = NULL;
107 struct pipe_screen *screen = dri_screen(drawable->sPriv)->pipe_screen;
108 __DRIbuffer *buffers = NULL;
109 __DRIscreen *dri_screen = drawable->sPriv;
110 __DRIdrawable *dri_drawable = drawable->dPriv;
111 struct drm_api *api = ((struct dri_screen*)(dri_screen->private))->api;
112 boolean have_depth = FALSE;
113 int i, count;
114
115 buffers = (*dri_screen->dri2.loader->getBuffers) (dri_drawable,
116 &dri_drawable->w,
117 &dri_drawable->h,
118 drawable->attachments,
119 drawable->
120 num_attachments, &count,
121 dri_drawable->
122 loaderPrivate);
123
124 if (buffers == NULL) {
125 return;
126 }
127
128 /* set one cliprect to cover the whole dri_drawable */
129 dri_drawable->x = 0;
130 dri_drawable->y = 0;
131 dri_drawable->backX = 0;
132 dri_drawable->backY = 0;
133 dri_drawable->numClipRects = 1;
134 dri_drawable->pClipRects[0].x1 = 0;
135 dri_drawable->pClipRects[0].y1 = 0;
136 dri_drawable->pClipRects[0].x2 = dri_drawable->w;
137 dri_drawable->pClipRects[0].y2 = dri_drawable->h;
138 dri_drawable->numBackClipRects = 1;
139 dri_drawable->pBackClipRects[0].x1 = 0;
140 dri_drawable->pBackClipRects[0].y1 = 0;
141 dri_drawable->pBackClipRects[0].x2 = dri_drawable->w;
142 dri_drawable->pBackClipRects[0].y2 = dri_drawable->h;
143
144 if (drawable->old_num == count &&
145 drawable->old_w == dri_drawable->w &&
146 drawable->old_h == dri_drawable->h &&
147 memcmp(drawable->old, buffers, sizeof(__DRIbuffer) * count) == 0) {
148 return;
149 } else {
150 drawable->old_num = count;
151 drawable->old_w = dri_drawable->w;
152 drawable->old_h = dri_drawable->h;
153 memcpy(drawable->old, buffers, sizeof(__DRIbuffer) * count);
154 }
155
156 for (i = 0; i < count; i++) {
157 enum pipe_format format = 0;
158 int index = 0;
159
160 switch (buffers[i].attachment) {
161 case __DRI_BUFFER_FRONT_LEFT:
162 index = ST_SURFACE_FRONT_LEFT;
163 format = drawable->color_format;
164 break;
165 case __DRI_BUFFER_FAKE_FRONT_LEFT:
166 index = ST_SURFACE_FRONT_LEFT;
167 format = drawable->color_format;
168 break;
169 case __DRI_BUFFER_BACK_LEFT:
170 index = ST_SURFACE_BACK_LEFT;
171 format = drawable->color_format;
172 break;
173 case __DRI_BUFFER_DEPTH:
174 index = ST_SURFACE_DEPTH;
175 format = drawable->depth_format;
176 break;
177 case __DRI_BUFFER_STENCIL:
178 index = ST_SURFACE_DEPTH;
179 format = drawable->stencil_format;
180 break;
181 case __DRI_BUFFER_ACCUM:
182 default:
183 assert(0);
184 }
185
186 if (index == ST_SURFACE_DEPTH) {
187 if (have_depth)
188 continue;
189 else
190 have_depth = TRUE;
191 }
192
193 surface = dri_surface_from_handle(api,
194 screen,
195 buffers[i].name,
196 format,
197 dri_drawable->w,
198 dri_drawable->h, buffers[i].pitch);
199
200 st_set_framebuffer_surface(drawable->stfb, index, surface);
201 pipe_surface_reference(&surface, NULL);
202 }
203 /* this needed, or else the state tracker fails to pick the new buffers */
204 st_resize_framebuffer(drawable->stfb, dri_drawable->w, dri_drawable->h);
205 }
206
207 /**
208 * These are used for GLX_EXT_texture_from_pixmap
209 */
210 void dri2_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target,
211 GLint format, __DRIdrawable *dPriv)
212 {
213 struct dri_drawable *drawable = dri_drawable(dPriv);
214 struct pipe_surface *ps;
215
216 dri_get_buffers(drawable->dPriv);
217 st_get_framebuffer_surface(drawable->stfb, ST_SURFACE_FRONT_LEFT, &ps);
218
219 st_bind_texture_surface(ps, target == GL_TEXTURE_2D ? ST_TEXTURE_2D :
220 ST_TEXTURE_RECT, 0,
221 format == GLX_TEXTURE_FORMAT_RGBA_EXT ?
222 PIPE_FORMAT_R8G8B8A8_UNORM : PIPE_FORMAT_R8G8B8X8_UNORM);
223 }
224
225 void dri2_set_tex_buffer(__DRIcontext *pDRICtx, GLint target,
226 __DRIdrawable *dPriv)
227 {
228 dri2_set_tex_buffer2(pDRICtx, target, GLX_TEXTURE_FORMAT_RGBA_EXT, dPriv);
229 }
230
231 void
232 dri_flush_frontbuffer(struct pipe_screen *screen,
233 struct pipe_surface *surf, void *context_private)
234 {
235 struct dri_context *ctx = (struct dri_context *)context_private;
236
237 dri_copy_to_front(ctx->dPriv, surf, 0, 0, surf->width, surf->height);
238 }
239
240 /**
241 * This is called when we need to set up GL rendering to a new X window.
242 */
243 boolean
244 dri_create_buffer(__DRIscreenPrivate * sPriv,
245 __DRIdrawablePrivate * dPriv,
246 const __GLcontextModes * visual, boolean isPixmap)
247 {
248 struct dri_screen *screen = sPriv->private;
249 struct dri_drawable *drawable = NULL;
250 int i;
251
252 if (isPixmap)
253 goto fail; /* not implemented */
254
255 drawable = CALLOC_STRUCT(dri_drawable);
256 if (drawable == NULL)
257 goto fail;
258
259 drawable->color_format = (visual->redBits == 8) ?
260 PIPE_FORMAT_A8R8G8B8_UNORM : PIPE_FORMAT_R5G6B5_UNORM;
261
262 debug_printf("Red bits is %d\n", visual->redBits);
263
264 switch(visual->depthBits) {
265 default:
266 case 0:
267 debug_printf("Depth buffer 0.\n");
268 drawable->depth_format = PIPE_FORMAT_NONE;
269 break;
270 case 16:
271 debug_printf("Depth buffer 16.\n");
272 drawable->depth_format = PIPE_FORMAT_Z16_UNORM;
273 break;
274 case 24:
275 if (visual->stencilBits == 0) {
276 debug_printf("Depth buffer 24. Stencil 0.\n");
277 drawable->depth_format = (screen->d_depth_bits_last) ?
278 PIPE_FORMAT_X8Z24_UNORM:
279 PIPE_FORMAT_Z24X8_UNORM;
280 } else {
281 debug_printf("Combined depth stencil 24 / 8.\n");
282 drawable->depth_format = (screen->sd_depth_bits_last) ?
283 PIPE_FORMAT_S8Z24_UNORM:
284 PIPE_FORMAT_Z24S8_UNORM;
285 }
286 break;
287 }
288
289 switch(visual->stencilBits) {
290 default:
291 case 0:
292 drawable->stencil_format = PIPE_FORMAT_NONE;
293 break;
294 case 8:
295 drawable->stencil_format = (screen->sd_depth_bits_last) ?
296 PIPE_FORMAT_S8Z24_UNORM:
297 PIPE_FORMAT_Z24S8_UNORM;
298 break;
299 }
300
301 drawable->stfb = st_create_framebuffer(visual,
302 drawable->color_format,
303 drawable->depth_format,
304 drawable->stencil_format,
305 dPriv->w,
306 dPriv->h, (void *)drawable);
307 if (drawable->stfb == NULL)
308 goto fail;
309
310 drawable->sPriv = sPriv;
311 drawable->dPriv = dPriv;
312 dPriv->driverPrivate = (void *)drawable;
313
314 /* setup dri2 buffers information */
315 i = 0;
316 drawable->attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
317 #if 0
318 /* TODO incase of double buffer visual, delay fake creation */
319 drawable->attachments[i++] = __DRI_BUFFER_FAKE_FRONT_LEFT;
320 #endif
321 if (visual->doubleBufferMode)
322 drawable->attachments[i++] = __DRI_BUFFER_BACK_LEFT;
323 if (visual->depthBits)
324 drawable->attachments[i++] = __DRI_BUFFER_DEPTH;
325 if (visual->stencilBits)
326 drawable->attachments[i++] = __DRI_BUFFER_STENCIL;
327 drawable->num_attachments = i;
328
329 drawable->desired_fences = 2;
330
331 return GL_TRUE;
332 fail:
333 FREE(drawable);
334 return GL_FALSE;
335 }
336
337 static struct pipe_fence_handle *
338 dri_swap_fences_pop_front(struct dri_drawable *draw)
339 {
340 struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen;
341 struct pipe_fence_handle *fence = NULL;
342
343 if (draw->cur_fences >= draw->desired_fences) {
344 screen->fence_reference(screen, &fence, draw->swap_fences[draw->tail]);
345 screen->fence_reference(screen, &draw->swap_fences[draw->tail++], NULL);
346 --draw->cur_fences;
347 draw->tail &= DRI_SWAP_FENCES_MASK;
348 }
349 return fence;
350 }
351
352 static void
353 dri_swap_fences_push_back(struct dri_drawable *draw,
354 struct pipe_fence_handle *fence)
355 {
356 struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen;
357
358 if (!fence)
359 return;
360
361 if (draw->cur_fences < DRI_SWAP_FENCES_MAX) {
362 draw->cur_fences++;
363 screen->fence_reference(screen, &draw->swap_fences[draw->head++],
364 fence);
365 draw->head &= DRI_SWAP_FENCES_MASK;
366 }
367 }
368
369 void
370 dri_destroy_buffer(__DRIdrawablePrivate * dPriv)
371 {
372 struct dri_drawable *drawable = dri_drawable(dPriv);
373 struct pipe_fence_handle *fence;
374 struct pipe_screen *screen = dri_screen(drawable->sPriv)->pipe_screen;
375
376 st_unreference_framebuffer(drawable->stfb);
377 drawable->desired_fences = 0;
378 while (drawable->cur_fences) {
379 fence = dri_swap_fences_pop_front(drawable);
380 screen->fence_reference(screen, &fence, NULL);
381 }
382
383 FREE(drawable);
384 }
385
386 static void
387 dri1_update_drawables_locked(struct dri_context *ctx,
388 __DRIdrawablePrivate * driDrawPriv,
389 __DRIdrawablePrivate * driReadPriv)
390 {
391 if (ctx->stLostLock) {
392 ctx->stLostLock = FALSE;
393 if (driDrawPriv == driReadPriv)
394 DRI_VALIDATE_DRAWABLE_INFO(ctx->sPriv, driDrawPriv);
395 else
396 DRI_VALIDATE_TWO_DRAWABLES_INFO(ctx->sPriv, driDrawPriv,
397 driReadPriv);
398 }
399 }
400
401 /**
402 * This ensures all contexts which bind to a drawable pick up the
403 * drawable change and signal new buffer state.
404 * Calling st_resize_framebuffer for each context may seem like overkill,
405 * but no new buffers will actually be allocated if the dimensions don't
406 * change.
407 */
408
409 static void
410 dri1_propagate_drawable_change(struct dri_context *ctx)
411 {
412 __DRIdrawablePrivate *dPriv = ctx->dPriv;
413 __DRIdrawablePrivate *rPriv = ctx->rPriv;
414 boolean flushed = FALSE;
415
416 if (dPriv && ctx->d_stamp != dPriv->lastStamp) {
417
418 st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
419 flushed = TRUE;
420 ctx->d_stamp = dPriv->lastStamp;
421 st_resize_framebuffer(dri_drawable(dPriv)->stfb, dPriv->w, dPriv->h);
422
423 }
424
425 if (rPriv && dPriv != rPriv && ctx->r_stamp != rPriv->lastStamp) {
426
427 if (!flushed)
428 st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
429 ctx->r_stamp = rPriv->lastStamp;
430 st_resize_framebuffer(dri_drawable(rPriv)->stfb, rPriv->w, rPriv->h);
431
432 } else if (rPriv && dPriv == rPriv) {
433
434 ctx->r_stamp = ctx->d_stamp;
435
436 }
437 }
438
439 void
440 dri1_update_drawables(struct dri_context *ctx,
441 struct dri_drawable *draw, struct dri_drawable *read)
442 {
443 dri_lock(ctx);
444 dri1_update_drawables_locked(ctx, draw->dPriv, read->dPriv);
445 dri_unlock(ctx);
446
447 dri1_propagate_drawable_change(ctx);
448 }
449
450 static INLINE boolean
451 dri1_intersect_src_bbox(struct drm_clip_rect *dst,
452 int dst_x,
453 int dst_y,
454 const struct drm_clip_rect *src,
455 const struct drm_clip_rect *bbox)
456 {
457 int xy1;
458 int xy2;
459
460 xy1 = ((int)src->x1 > (int)bbox->x1 + dst_x) ? src->x1 :
461 (int)bbox->x1 + dst_x;
462 xy2 = ((int)src->x2 < (int)bbox->x2 + dst_x) ? src->x2 :
463 (int)bbox->x2 + dst_x;
464 if (xy1 >= xy2 || xy1 < 0)
465 return FALSE;
466
467 dst->x1 = xy1;
468 dst->x2 = xy2;
469
470 xy1 = ((int)src->y1 > (int)bbox->y1 + dst_y) ? src->y1 :
471 (int)bbox->y1 + dst_y;
472 xy2 = ((int)src->y2 < (int)bbox->y2 + dst_y) ? src->y2 :
473 (int)bbox->y2 + dst_y;
474 if (xy1 >= xy2 || xy1 < 0)
475 return FALSE;
476
477 dst->y1 = xy1;
478 dst->y2 = xy2;
479 return TRUE;
480 }
481
482 static void
483 dri1_swap_copy(struct dri_context *ctx,
484 struct pipe_surface *dst,
485 struct pipe_surface *src,
486 __DRIdrawablePrivate * dPriv, const struct drm_clip_rect *bbox)
487 {
488 struct pipe_context *pipe = ctx->pipe;
489 struct drm_clip_rect clip;
490 struct drm_clip_rect *cur;
491 int i;
492
493 cur = dPriv->pClipRects;
494
495 for (i = 0; i < dPriv->numClipRects; ++i) {
496 if (dri1_intersect_src_bbox(&clip, dPriv->x, dPriv->y, cur++, bbox))
497 pipe->surface_copy(pipe, dst, clip.x1, clip.y1,
498 src,
499 (int)clip.x1 - dPriv->x,
500 (int)clip.y1 - dPriv->y,
501 clip.x2 - clip.x1, clip.y2 - clip.y1);
502 }
503 }
504
505 static void
506 dri1_copy_to_front(struct dri_context *ctx,
507 struct pipe_surface *surf,
508 __DRIdrawablePrivate * dPriv,
509 const struct drm_clip_rect *sub_box,
510 struct pipe_fence_handle **fence)
511 {
512 struct pipe_context *pipe = ctx->pipe;
513 boolean save_lost_lock;
514 uint cur_w;
515 uint cur_h;
516 struct drm_clip_rect bbox;
517 boolean visible = TRUE;
518
519 *fence = NULL;
520
521 dri_lock(ctx);
522 save_lost_lock = ctx->stLostLock;
523 dri1_update_drawables_locked(ctx, dPriv, dPriv);
524 st_get_framebuffer_dimensions(dri_drawable(dPriv)->stfb, &cur_w, &cur_h);
525
526 bbox.x1 = 0;
527 bbox.x2 = cur_w;
528 bbox.y1 = 0;
529 bbox.y2 = cur_h;
530
531 if (sub_box)
532 visible = dri1_intersect_src_bbox(&bbox, 0, 0, &bbox, sub_box);
533
534 if (visible && __dri1_api_hooks->present_locked) {
535
536 __dri1_api_hooks->present_locked(pipe,
537 surf,
538 dPriv->pClipRects,
539 dPriv->numClipRects,
540 dPriv->x, dPriv->y, &bbox, fence);
541
542 } else if (visible && __dri1_api_hooks->front_srf_locked) {
543
544 struct pipe_surface *front = __dri1_api_hooks->front_srf_locked(pipe);
545
546 if (front)
547 dri1_swap_copy(ctx, front, surf, dPriv, &bbox);
548
549 st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, fence);
550 }
551
552 ctx->stLostLock = save_lost_lock;
553
554 /**
555 * FIXME: Revisit this: Update drawables on copy_sub_buffer ?
556 */
557
558 if (!sub_box)
559 dri1_update_drawables_locked(ctx, ctx->dPriv, ctx->rPriv);
560
561 dri_unlock(ctx);
562 dri1_propagate_drawable_change(ctx);
563 }
564
565 void
566 dri1_flush_frontbuffer(struct pipe_screen *screen,
567 struct pipe_surface *surf, void *context_private)
568 {
569 struct dri_context *ctx = (struct dri_context *)context_private;
570 struct pipe_fence_handle *dummy_fence;
571
572 dri1_copy_to_front(ctx, surf, ctx->dPriv, NULL, &dummy_fence);
573 screen->fence_reference(screen, &dummy_fence, NULL);
574
575 /**
576 * FIXME: Do we need swap throttling here?
577 */
578 }
579
580 void
581 dri_swap_buffers(__DRIdrawablePrivate * dPriv)
582 {
583 struct dri_context *ctx;
584 struct pipe_surface *back_surf;
585 struct dri_drawable *draw = dri_drawable(dPriv);
586 struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen;
587 struct pipe_fence_handle *fence;
588 struct st_context *st = st_get_current();
589
590 assert(__dri1_api_hooks != NULL);
591
592 if (!st)
593 return; /* For now */
594
595 ctx = (struct dri_context *)st->pipe->priv;
596
597 st_get_framebuffer_surface(draw->stfb, ST_SURFACE_BACK_LEFT, &back_surf);
598 if (back_surf) {
599 st_notify_swapbuffers(draw->stfb);
600 st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
601 fence = dri_swap_fences_pop_front(draw);
602 if (fence) {
603 (void)screen->fence_finish(screen, fence, 0);
604 screen->fence_reference(screen, &fence, NULL);
605 }
606 dri1_copy_to_front(ctx, back_surf, dPriv, NULL, &fence);
607 dri_swap_fences_push_back(draw, fence);
608 screen->fence_reference(screen, &fence, NULL);
609 }
610 }
611
612 void
613 dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h)
614 {
615 struct pipe_screen *screen = dri_screen(dPriv->driScreenPriv)->pipe_screen;
616 struct drm_clip_rect sub_bbox;
617 struct dri_context *ctx;
618 struct pipe_surface *back_surf;
619 struct dri_drawable *draw = dri_drawable(dPriv);
620 struct pipe_fence_handle *dummy_fence;
621 struct st_context *st = st_get_current();
622
623 assert(__dri1_api_hooks != NULL);
624
625 if (!st)
626 return;
627
628 ctx = (struct dri_context *)st->pipe->priv;
629
630 sub_bbox.x1 = x;
631 sub_bbox.x2 = x + w;
632 sub_bbox.y1 = y;
633 sub_bbox.y2 = y + h;
634
635 st_get_framebuffer_surface(draw->stfb, ST_SURFACE_BACK_LEFT, &back_surf);
636 if (back_surf) {
637 st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
638 dri1_copy_to_front(ctx, back_surf, dPriv, &sub_bbox, &dummy_fence);
639 screen->fence_reference(screen, &dummy_fence, NULL);
640 }
641 }
642
643 /* vim: set sw=3 ts=8 sts=3 expandtab: */