Files
external_libcamera/src/cam/sdl_texture.cpp
T
Jacopo Mondi e9b6b36282 cam: sdl: Use uint32_t in place of SDL_PixelFormatEnum
The SDL_PixelFormatEnum type has been introduced in libsdl by
1a4c0d4e17e6 ("Fixed bug 4377 - SDL_PIXELFORMAT enum is anonymous, which
prevents its use in a templated function") which is only available after
release 2.0.10 of the library.

Debian 10 ships libsdl at version 2.0.9 and building cam with sdl
support there fails with error:
./src/cam/sdl_texture.h:27:8: error: ‘SDL_PixelFormatEnum’ does not name
a type; did you mean ‘SDL_PixelFormat’?

Fix that by using the base type uint32_t in place of
SDL_PixelFormatEnum.

Reported-by: https://buildbot.libcamera.org/#/builders/6/builds/355
Fixes: 11554a259f ("cam: sdl_sink: Add SDL sink with initial YUYV support")
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Eric Curtin <ecurtin@redhat.com>
2022-07-15 13:43:47 +02:00

37 lines
711 B
C++

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Copyright (C) 2022, Ideas on Board Oy
*
* sdl_texture.cpp - SDL Texture
*/
#include "sdl_texture.h"
#include <iostream>
SDLTexture::SDLTexture(const SDL_Rect &rect, uint32_t pixelFormat,
const int pitch)
: ptr_(nullptr), rect_(rect), pixelFormat_(pixelFormat), pitch_(pitch)
{
}
SDLTexture::~SDLTexture()
{
if (ptr_)
SDL_DestroyTexture(ptr_);
}
int SDLTexture::create(SDL_Renderer *renderer)
{
ptr_ = SDL_CreateTexture(renderer, pixelFormat_,
SDL_TEXTUREACCESS_STREAMING, rect_.w,
rect_.h);
if (!ptr_) {
std::cerr << "Failed to create SDL texture: " << SDL_GetError()
<< std::endl;
return -ENOMEM;
}
return 0;
}