annotate src/video/bwindow/SDL_sysyuv.cc @ 1336:3692456e7b0f

Use SDL_ prefixed versions of C library functions. FIXME: Change #include <stdlib.h> to #include "SDL_stdlib.h" Change #include <string.h> to #include "SDL_string.h" Make sure nothing else broke because of this...
author Sam Lantinga <slouken@libsdl.org>
date Tue, 07 Feb 2006 06:59:48 +0000
parents c9b51268668f
children 604d73db6802
rev   line source
756
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
756
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
6 modify it under the terms of the GNU Lesser General Public
756
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
756
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
13 Lesser General Public License for more details.
756
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
15 You should have received a copy of the GNU Lesser General Public
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
16 License along with this library; if not, write to the Free Software
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
756
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 /* This is the BeOS version of SDL YUV video overlays */
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 #include <stdlib.h>
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 #include <string.h>
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 #include <errno.h>
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 #include "SDL_error.h"
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 #include "SDL_video.h"
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 #include "SDL_sysyuv.h"
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 #include "SDL_yuvfuncs.h"
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 extern "C" {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 /* The functions used to manipulate software video overlays */
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 static struct private_yuvhwfuncs be_yuvfuncs =
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 BE_LockYUVOverlay,
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 BE_UnlockYUVOverlay,
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 BE_DisplayYUVOverlay,
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 BE_FreeYUVOverlay
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 };
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 BBitmap * BE_GetOverlayBitmap(BRect bounds, color_space cs) {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 BBitmap *bbitmap;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 bbitmap = new BBitmap(bounds,B_BITMAP_WILL_OVERLAY,cs);
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 if (!bbitmap || bbitmap->InitCheck() != B_OK) {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 delete bbitmap;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 return 0;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 overlay_restrictions r;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 bbitmap->GetOverlayRestrictions(&r);
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 uint32 width = bounds.IntegerWidth() + 1;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 uint32 height = bounds.IntegerHeight() + 1;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 uint32 width_padding = 0;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 uint32 height_padding = 0;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 if ((r.source.horizontal_alignment != 0) ||
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 (r.source.vertical_alignment != 0)) {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 delete bbitmap;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 return 0;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 if (r.source.width_alignment != 0) {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 uint32 aligned_width = r.source.width_alignment + 1;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 if (width % aligned_width > 0) {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 width_padding = aligned_width - width % aligned_width;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 if (r.source.height_alignment != 0) {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 uint32 aligned_height = r.source.height_alignment + 1;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 if (height % aligned_height > 0) {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 fprintf(stderr,"GetOverlayBitmap failed height alignment\n");
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 fprintf(stderr,"- height = %lu, aligned_height = %lu\n",height,aligned_height);
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 delete bbitmap;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 return 0;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 if ((r.source.min_width > width) ||
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 (r.source.min_height > height) ||
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 (r.source.max_width < width) ||
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 (r.source.max_height < height)) {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 fprintf(stderr,"GetOverlayBitmap failed bounds tests\n");
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 delete bbitmap;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 return 0;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 if ((width_padding != 0) || (height_padding != 0)) {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 delete bbitmap;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 bounds.Set(bounds.left,bounds.top,bounds.right+width_padding,bounds.bottom+height_padding);
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 bbitmap = new BBitmap(bounds,B_BITMAP_WILL_OVERLAY,cs);
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 if (!bbitmap || bbitmap->InitCheck() != B_OK) {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 fprintf(stderr,"GetOverlayBitmap failed late\n");
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 delete bbitmap;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 return 0;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 return bbitmap;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 // See <GraphicsDefs.h> [btw: Cb=U, Cr=V]
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 // See also http://www.fourcc.org/indexyuv.htm
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 enum color_space convert_color_space(Uint32 format) {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 switch (format) {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 case SDL_YV12_OVERLAY:
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 return B_YUV9;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 case SDL_IYUV_OVERLAY:
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 return B_YUV12;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 case SDL_YUY2_OVERLAY:
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 return B_YCbCr422;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 case SDL_UYVY_OVERLAY:
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 return B_YUV422;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 case SDL_YVYU_OVERLAY: // not supported on beos?
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 return B_NO_COLOR_SPACE;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 default:
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 return B_NO_COLOR_SPACE;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 // See SDL_video.h
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 int count_planes(Uint32 format) {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 switch (format) {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 case SDL_YV12_OVERLAY:
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 case SDL_IYUV_OVERLAY:
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 return 3;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 case SDL_YUY2_OVERLAY:
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 case SDL_UYVY_OVERLAY:
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 case SDL_YVYU_OVERLAY:
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 return 1;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 default:
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 return 0;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 SDL_Overlay *BE_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display) {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 SDL_Overlay* overlay;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 struct private_yuvhwdata* hwdata;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 BBitmap *bbitmap;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 int planes;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 BRect bounds;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 color_space cs;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 /* find the appropriate BeOS colorspace descriptor */
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 cs = convert_color_space(format);
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 if (cs == B_NO_COLOR_SPACE)
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 return NULL;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 /* count planes */
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 planes = count_planes(format);
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 if (planes == 0)
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 return NULL;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 /* TODO: figure out planar modes, if anyone cares */
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 if (planes == 3)
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 return NULL;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 /* Create the overlay structure */
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 overlay = (SDL_Overlay*)calloc(1, sizeof(SDL_Overlay));
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 if (overlay == NULL)
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 SDL_OutOfMemory();
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 return NULL;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 /* Fill in the basic members */
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 overlay->format = format;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 overlay->w = width;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 overlay->h = height;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 overlay->hwdata = NULL;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 /* Set up the YUV surface function structure */
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 overlay->hwfuncs = &be_yuvfuncs;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 /* Create the pixel data and lookup tables */
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 hwdata = (struct private_yuvhwdata*)calloc(1, sizeof(struct private_yuvhwdata));
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 if (hwdata == NULL)
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 SDL_OutOfMemory();
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 SDL_FreeYUVOverlay(overlay);
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185 return NULL;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 overlay->hwdata = hwdata;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 overlay->hwdata->display = display;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 overlay->hwdata->bview = NULL;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 overlay->hwdata->bbitmap = NULL;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 overlay->hwdata->locked = 0;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 /* Create the BBitmap framebuffer */
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195 bounds.top = 0; bounds.left = 0;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 bounds.right = width-1;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 bounds.bottom = height-1;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 BView * bview = new BView(bounds,"overlay",B_FOLLOW_NONE,B_WILL_DRAW);
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 if (!bview) {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 SDL_OutOfMemory();
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 SDL_FreeYUVOverlay(overlay);
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 return NULL;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 overlay->hwdata->bview = bview;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 overlay->hwdata->first_display = true;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 bview->Hide();
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 bbitmap = BE_GetOverlayBitmap(bounds,cs);
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 if (!bbitmap) {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 overlay->hwdata->bbitmap = NULL;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 SDL_FreeYUVOverlay(overlay);
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 return NULL;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 overlay->hwdata->bbitmap = bbitmap;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 overlay->planes = planes;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 overlay->pitches = (Uint16*)calloc(overlay->planes, sizeof(Uint16));
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 overlay->pixels = (Uint8**)calloc(overlay->planes, sizeof(Uint8*));
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 if (!overlay->pitches || !overlay->pixels)
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 SDL_OutOfMemory();
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 SDL_FreeYUVOverlay(overlay);
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 return(NULL);
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227 overlay->pitches[0] = bbitmap->BytesPerRow();
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 overlay->pixels[0] = (Uint8 *)bbitmap->Bits();
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 overlay->hw_overlay = 1;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 if (SDL_Win->LockWithTimeout(1000000) != B_OK) {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 SDL_FreeYUVOverlay(overlay);
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 return(NULL);
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235 BView * view = SDL_Win->View();
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 view->AddChild(bview);
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 rgb_color key;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 bview->SetViewOverlay(bbitmap,bounds,bview->Bounds(),&key,B_FOLLOW_ALL,
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 B_OVERLAY_FILTER_HORIZONTAL|B_OVERLAY_FILTER_VERTICAL);
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 bview->SetViewColor(key);
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 bview->Flush();
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 SDL_Win->Unlock();
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 current_overlay=overlay;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 return overlay;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249 int BE_LockYUVOverlay(_THIS, SDL_Overlay* overlay)
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251 if (overlay == NULL)
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 return 0;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256 overlay->hwdata->locked = 1;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257 return 0;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260 void BE_UnlockYUVOverlay(_THIS, SDL_Overlay* overlay)
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261 {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 if (overlay == NULL)
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263 {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264 return;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267 overlay->hwdata->locked = 0;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270 int BE_DisplayYUVOverlay(_THIS, SDL_Overlay* overlay, SDL_Rect* dstrect)
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271 {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272 if ((overlay == NULL) || (overlay->hwdata==NULL)
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 || (overlay->hwdata->bview==NULL) || (SDL_Win->View() == NULL))
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 return -1;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277 if (SDL_Win->LockWithTimeout(50000) != B_OK) {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 return 0;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 BView * bview = overlay->hwdata->bview;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281 if (SDL_Win->IsFullScreen()) {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 int left,top;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283 SDL_Win->GetXYOffset(left,top);
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284 bview->MoveTo(left+dstrect->x,top+dstrect->y);
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285 } else {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
286 bview->MoveTo(dstrect->x,dstrect->y);
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
287 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288 bview->ResizeTo(dstrect->w,dstrect->h);
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
289 bview->Flush();
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
290 if (overlay->hwdata->first_display) {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 bview->Show();
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
292 overlay->hwdata->first_display = false;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
294 SDL_Win->Unlock();
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296 return 0;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
298
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
299 void BE_FreeYUVOverlay(_THIS, SDL_Overlay *overlay)
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300 {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
301 if (overlay == NULL)
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
302 {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
303 return;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
304 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
305
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
306 if (overlay->hwdata == NULL)
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
307 {
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
308 return;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
309 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
310
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
311 current_overlay=NULL;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
312
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
313 delete overlay->hwdata->bbitmap;
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
314
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
315 SDL_free(overlay->hwdata);
756
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316 }
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317
10332c6fad2e te: Mon, 15 Dec 2003 08:25:14 -0800 PST
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
318 }; // extern "C"