| 1 |
/* |
| 2 |
* Copyright (C) 2005-2018 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#include "RenderBufferPoolOpenGLES.h" |
| 10 |
|
| 11 |
#include "RenderBufferOpenGLES.h" |
| 12 |
#include "cores/RetroPlayer/rendering/RenderContext.h" |
| 13 |
#include "cores/RetroPlayer/rendering/RenderVideoSettings.h" |
| 14 |
#include "cores/RetroPlayer/rendering/VideoRenderers/RPRendererOpenGLES.h" |
| 15 |
#include "utils/GLUtils.h" |
| 16 |
|
| 17 |
using namespace KODI; |
| 18 |
using namespace RETRO; |
| 19 |
|
| 20 |
CRenderBufferPoolOpenGLES::CRenderBufferPoolOpenGLES(CRenderContext& context) : m_context(context) |
| 21 |
{ |
| 22 |
} |
| 23 |
|
| 24 |
bool CRenderBufferPoolOpenGLES::IsCompatible(const CRenderVideoSettings& renderSettings) const |
| 25 |
{ |
| 26 |
return CRPRendererOpenGLES::SupportsScalingMethod(renderSettings.GetScalingMethod()); |
| 27 |
} |
| 28 |
|
| 29 |
IRenderBuffer* CRenderBufferPoolOpenGLES::CreateRenderBuffer(void* header /* = nullptr */) |
| 30 |
{ |
| 31 |
return new CRenderBufferOpenGLES(m_context, m_pixeltype, m_internalformat, m_pixelformat, m_bpp); |
| 32 |
} |
| 33 |
|
| 34 |
bool CRenderBufferPoolOpenGLES::ConfigureInternal() |
| 35 |
{ |
| 36 |
switch (m_format) |
| 37 |
{ |
| 38 |
case AV_PIX_FMT_0RGB32: |
| 39 |
{ |
| 40 |
m_pixeltype = GL_UNSIGNED_BYTE; |
| 41 |
if (m_context.IsExtSupported("GL_EXT_texture_format_BGRA8888") || |
| 42 |
m_context.IsExtSupported("GL_IMG_texture_format_BGRA8888")) |
| 43 |
{ |
| 44 |
m_internalformat = GL_BGRA_EXT; |
| 45 |
m_pixelformat = GL_BGRA_EXT; |
| 46 |
} |
| 47 |
else if (m_context.IsExtSupported("GL_APPLE_texture_format_BGRA8888")) |
| 48 |
{ |
| 49 |
// Apple's implementation does not conform to spec. Instead, they require |
| 50 |
// differing format/internalformat, more like GL. |
| 51 |
m_internalformat = GL_RGBA; |
| 52 |
m_pixelformat = GL_BGRA_EXT; |
| 53 |
} |
| 54 |
else |
| 55 |
{ |
| 56 |
m_internalformat = GL_RGBA; |
| 57 |
m_pixelformat = GL_RGBA; |
| 58 |
} |
| 59 |
m_bpp = sizeof(uint32_t); |
| 60 |
return true; |
| 61 |
} |
| 62 |
case AV_PIX_FMT_RGB555: |
| 63 |
case AV_PIX_FMT_RGB565: |
| 64 |
{ |
| 65 |
m_pixeltype = GL_UNSIGNED_SHORT_5_6_5; |
| 66 |
m_internalformat = GL_RGB; |
| 67 |
m_pixelformat = GL_RGB; |
| 68 |
m_bpp = sizeof(uint16_t); |
| 69 |
return true; |
| 70 |
} |
| 71 |
default: |
| 72 |
break; |
| 73 |
} |
| 74 |
|
| 75 |
return false; |
| 76 |
} |