1//
2// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
3// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7// formatutils.h: Queries for GL image formats.
8
9#ifndef LIBGLESV2_FORMATUTILS_H_
10#define LIBGLESV2_FORMATUTILS_H_
11
12#include <GLES3/gl3.h>
13#include <GLES2/gl2.h>
14#include <GLES2/gl2ext.h>
15
16#include "libGLESv2/angletypes.h"
17
18typedef void (*MipGenerationFunction)(unsigned int sourceWidth, unsigned int sourceHeight, unsigned int sourceDepth,
19                                      const unsigned char *sourceData, int sourceRowPitch, int sourceDepthPitch,
20                                      unsigned char *destData, int destRowPitch, int destDepthPitch);
21
22typedef void (*LoadImageFunction)(int width, int height, int depth,
23                                  const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
24                                  void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch);
25
26typedef void (*InitializeTextureDataFunction)(int width, int height, int depth,
27                                              void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch);
28
29typedef void (*ColorReadFunction)(const void *source, void *dest);
30typedef void (*ColorWriteFunction)(const void *source, void *dest);
31typedef void (*ColorCopyFunction)(const void *source, void *dest);
32
33typedef void (*VertexCopyFunction)(const void *input, size_t stride, size_t count, void *output);
34
35namespace rx
36{
37
38class Renderer;
39
40}
41
42namespace gl
43{
44
45class Context;
46
47bool IsValidInternalFormat(GLenum internalFormat, const Context *context);
48bool IsValidFormat(GLenum format, GLuint clientVersion);
49bool IsValidType(GLenum type, GLuint clientVersion);
50
51bool IsValidFormatCombination(GLenum internalFormat, GLenum format, GLenum type, GLuint clientVersion);
52bool IsValidCopyTexImageCombination(GLenum textureInternalFormat, GLenum frameBufferInternalFormat, GLuint readBufferHandle, GLuint clientVersion);
53
54bool IsSizedInternalFormat(GLenum internalFormat, GLuint clientVersion);
55GLenum GetSizedInternalFormat(GLenum format, GLenum type, GLuint clientVersion);
56
57GLuint GetPixelBytes(GLenum internalFormat, GLuint clientVersion);
58GLuint GetAlphaBits(GLenum internalFormat, GLuint clientVersion);
59GLuint GetRedBits(GLenum internalFormat, GLuint clientVersion);
60GLuint GetGreenBits(GLenum internalFormat, GLuint clientVersion);
61GLuint GetBlueBits(GLenum internalFormat, GLuint clientVersion);
62GLuint GetLuminanceBits(GLenum internalFormat, GLuint clientVersion);
63GLuint GetDepthBits(GLenum internalFormat, GLuint clientVersion);
64GLuint GetStencilBits(GLenum internalFormat, GLuint clientVersion);
65
66GLuint GetTypeBytes(GLenum type);
67bool IsSpecialInterpretationType(GLenum type);
68bool IsFloatOrFixedComponentType(GLenum type);
69
70GLenum GetFormat(GLenum internalFormat, GLuint clientVersion);
71GLenum GetType(GLenum internalFormat, GLuint clientVersion);
72
73GLenum GetComponentType(GLenum internalFormat, GLuint clientVersion);
74GLuint GetComponentCount(GLenum internalFormat, GLuint clientVersion);
75GLenum GetColorEncoding(GLenum internalFormat, GLuint clientVersion);
76
77bool IsColorRenderingSupported(GLenum internalFormat, const rx::Renderer *renderer);
78bool IsColorRenderingSupported(GLenum internalFormat, const Context *context);
79bool IsTextureFilteringSupported(GLenum internalFormat, const rx::Renderer *renderer);
80bool IsTextureFilteringSupported(GLenum internalFormat, const Context *context);
81bool IsDepthRenderingSupported(GLenum internalFormat, const rx::Renderer *renderer);
82bool IsDepthRenderingSupported(GLenum internalFormat, const Context *context);
83bool IsStencilRenderingSupported(GLenum internalFormat, const rx::Renderer *renderer);
84bool IsStencilRenderingSupported(GLenum internalFormat, const Context *context);
85
86GLuint GetRowPitch(GLenum internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLint alignment);
87GLuint GetDepthPitch(GLenum internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLsizei height, GLint alignment);
88GLuint GetBlockSize(GLenum internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLsizei height);
89
90bool IsFormatCompressed(GLenum internalFormat, GLuint clientVersion);
91GLuint GetCompressedBlockWidth(GLenum internalFormat, GLuint clientVersion);
92GLuint GetCompressedBlockHeight(GLenum internalFormat, GLuint clientVersion);
93
94ColorWriteFunction GetColorWriteFunction(GLenum format, GLenum type, GLuint clientVersion);
95
96}
97
98#endif LIBGLESV2_FORMATUTILS_H_
99