-
Notifications
You must be signed in to change notification settings - Fork 4
/
surface_bitmap.c
136 lines (109 loc) · 4.14 KB
/
surface_bitmap.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
* Copyright (c) 2013 Jens Kuske <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "vdpau_private.h"
#include "rgba.h"
VdpStatus vdp_bitmap_surface_create(VdpDevice device,
VdpRGBAFormat rgba_format,
uint32_t width,
uint32_t height,
VdpBool frequently_accessed,
VdpBitmapSurface *surface)
{
int ret = VDP_STATUS_OK;
if (!surface)
return VDP_STATUS_INVALID_POINTER;
device_ctx_t *dev = handle_get(device);
if (!dev)
return VDP_STATUS_INVALID_HANDLE;
bitmap_surface_ctx_t *out = calloc(1, sizeof(bitmap_surface_ctx_t));
if (!out)
return VDP_STATUS_RESOURCES;
out->frequently_accessed = frequently_accessed;
ret = rgba_create(&out->rgba, dev, width, height, rgba_format);
if (ret != VDP_STATUS_OK)
{
free(out);
return ret;
}
int handle = handle_create(out);
if (handle == -1)
{
rgba_destroy(&out->rgba);
free(out);
return VDP_STATUS_RESOURCES;
}
*surface = handle;
return VDP_STATUS_OK;
}
VdpStatus vdp_bitmap_surface_destroy(VdpBitmapSurface surface)
{
bitmap_surface_ctx_t *out = handle_get(surface);
if (!out)
return VDP_STATUS_INVALID_HANDLE;
rgba_destroy(&out->rgba);
handle_destroy(surface);
free(out);
return VDP_STATUS_OK;
}
VdpStatus vdp_bitmap_surface_get_parameters(VdpBitmapSurface surface,
VdpRGBAFormat *rgba_format,
uint32_t *width,
uint32_t *height,
VdpBool *frequently_accessed)
{
bitmap_surface_ctx_t *out = handle_get(surface);
if (!out)
return VDP_STATUS_INVALID_HANDLE;
if (rgba_format)
*rgba_format = out->rgba.format;
if (width)
*width = out->rgba.width;
if (height)
*height = out->rgba.height;
if (frequently_accessed)
*frequently_accessed = out->frequently_accessed;
return VDP_STATUS_OK;
}
VdpStatus vdp_bitmap_surface_put_bits_native(VdpBitmapSurface surface,
void const *const *source_data,
uint32_t const *source_pitches,
VdpRect const *destination_rect)
{
bitmap_surface_ctx_t *out = handle_get(surface);
if (!out)
return VDP_STATUS_INVALID_HANDLE;
rgba_put_bits_native(&out->rgba, source_data, source_pitches, destination_rect);
return VDP_STATUS_OK;
}
VdpStatus vdp_bitmap_surface_query_capabilities(VdpDevice device,
VdpRGBAFormat surface_rgba_format,
VdpBool *is_supported,
uint32_t *max_width,
uint32_t *max_height)
{
if (!is_supported || !max_width || !max_height)
return VDP_STATUS_INVALID_POINTER;
device_ctx_t *dev = handle_get(device);
if (!dev)
return VDP_STATUS_INVALID_HANDLE;
*is_supported = (surface_rgba_format == VDP_RGBA_FORMAT_R8G8B8A8 || surface_rgba_format == VDP_RGBA_FORMAT_B8G8R8A8);
*max_width = 8192;
*max_height = 8192;
return VDP_STATUS_OK;
}