[waffle] [PATCH 09/11] waffle: Add public func waffle_window_create2()
Chad Versace
chad.versace at intel.com
Wed Dec 31 17:19:12 PST 2014
On 12/23/2014 04:24 PM, Frank Henigman wrote:
> On Tue, Dec 16, 2014 at 3:18 AM, Chad Versace
> <chad.versace at linux.intel.com> wrote:
>> Today, waffle_window() has only two parameters: width and height.
>>
>> Frank Henigman wants to extend Waffle's GBM backend with the ability to
>> post window contents to the display. Multiple methods exist for posting
>> content to the screen with the drm API, and that method should be
>> configurable per waffle_window. Therefore, we need to be able to pass
>> additional attributes to waffle_window_create().
>>
>> It would also be nice to specify at time of creation that the
>> waffle_window should be full screen. Again, we need to pass additional
>> attributes to waffle_window_create().
>>
>> The new function waffle_window_create2() is conceptually equivalent to
>> the original waffle_window_create() with the addition of an attrib_list
>> parameter. The only supported attributes are currently
>> WAFFLE_WINDOW_WIDTH and WAFFLE_WINDOW_HEIGHT.
>>
>> See the manpage changes for more details.
>> WAFFLE_API struct waffle_window*
>> +waffle_window_create2(
>> + struct waffle_config *config,
>> + const intptr_t attrib_list[])
>> +{
>> + struct wcore_window *wc_self = NULL;
>> + struct wcore_config *wc_config = wcore_config(config);
>> + intptr_t width, height;
>> + intptr_t *filtered_attribs = NULL;
>> +
>> + const struct api_object *obj_list[] = {
>> + wc_config ? &wc_config->api : NULL,
>> + };
>> +
>> + if (!api_check_entry(obj_list, 1)) {
>> + goto done;
>> + }
>> +
>> + filtered_attribs = wcore_attrib_list_copy(attrib_list);
>> +
>> + if (!wcore_attrib_list_pop(filtered_attribs,
>> + WAFFLE_WINDOW_WIDTH, &width)) {
>> + wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
>> + "required attribute WAFFLE_WINDOW_WIDTH is missing");
>> + goto done;
>> + }
>> +
>> + if (!wcore_attrib_list_pop(filtered_attribs,
>> + WAFFLE_WINDOW_HEIGHT, &height)) {
>> + wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
>> + "required attribute WAFFLE_WINDOW_HEIGHT is missing");
>> + goto done;
>> + }
>> +
>> + if (width <= 0) {
>> + wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
>> + "WAFFLE_WINDOW_WIDTH is not positive");
>> + goto done;
>> + } else if (width > INT32_MAX) {
>> + wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
>> + "WAFFLE_WINDOW_WIDTH is greater than INT32_MAX");
>> + goto done;
>> + }
>> +
>> + if (height <= 0) {
>> + wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
>> + "WAFFLE_WINDOW_HEIGHT is not positive");
>> + goto done;
>> + } else if (height > INT32_MAX) {
>> + wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
>> + "WAFFLE_WINDOW_HEIGHT is greater than INT32_MAX");
>> + goto done;
>> + }
>> +
>> + wc_self = api_platform->vtbl->window.create(api_platform,
>> + wc_config,
>> + (int32_t) width,
>> + (int32_t) height,
>> + filtered_attribs);
>
> I think we want the other way around: move the old
> waffle_window_create() code to the new waffle_window_create2()
> function, then have create call create2. The limited/specific
> function calls the more general one.
I agree. But I resorted to this quick hack, wrapping the functions
in the reverse way, to make it faster and easier to write the
patches that add waffle_window_create2(). Though inverted, the
code is still correct because all attrib values are still 32-bit.
But... now I regret taking this quick and easy hack. It's better
to just write the code right the first time, and have the intptr_t
function call the int32_t function. I'll fix that in v2 of the series.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 884 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/waffle/attachments/20141231/1ec4b505/attachment.sig>
More information about the waffle
mailing list