bugs: Suggest extension and/or implementation approach using identical memory
[libale.git] / src / render.c
blobd7ef96e059f9ca68a4594e3f107defa97b96ac1b
1 /*
2 * Copyright 2009 David Hilvert <dhilvert@gmail.com>
4 * This file is part of libale.
6 * libale is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU Affero General Public License as published by the Free
8 * Software Foundation, either version 3 of the License, or (at your option)
9 * any later version.
11 * libale is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
14 * more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with libale. If not, see <http://www.gnu.org/licenses/>.
20 #include "libale.h"
23 * API types.
26 TYPE(ale_render, \
27 ale_context ac; \
28 ale_image render_data; \
29 double definition_threshold; \
30 double saturation_threshold; \
31 double range_threshold;, \
32 ale_image_release(P(this)->render_data);)
35 * API Implementation.
38 ale_render ale_new_render_incremental(ale_context ac, int type, int invariant) {
39 if (!ale_context_valid(ac))
40 return N(ale_render);
42 if (type != ALE_TYPE_FLOAT_32 && type != ALE_TYPE_FLOAT_64)
43 return N(ale_render);
45 ale_image render_data = ale_new_image(ac, ALE_IMAGE_WEIGHTED_RGB, type);
47 if (!ale_image_valid(render_data))
48 return N(ale_render);
50 ale_render ar = ale_render_alloc(ac);
52 if (!ale_render_valid(ar)) {
53 ale_image_release(render_data);
54 return N(ale_render);
57 Q(ale_render, ar)->ac = ac;
58 Q(ale_render, ar)->render_data = render_data;
60 return ar;
63 int ale_render_resize(ale_render ar, ale_trans at) {
64 #warning function unimplemented
65 return 0;
68 int ale_render_merge(ale_render ar, ale_trans at, ale_image ai) {
69 #warning function unimplemented
70 return 0;
73 ale_image ale_render_retain_image(ale_render ar) {
74 if (!ale_render_valid(ar))
75 return N(ale_image);
77 if (!Q(ale_render, ar))
78 return N(ale_image);
80 ale_image ai = Q(ale_render, ar)->render_data;
82 ale_image_retain(ai);
84 return ai;
87 PARAMETER_RW(ale_render, definition_threshold, double)
88 PARAMETER_RW(ale_render, saturation_threshold, double)
89 PARAMETER_RW(ale_render, range_threshold, double)