• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "libGLESv2/Caps.h"
13 #include "libGLESv2/angletypes.h"
14 
15 #include "angle_gl.h"
16 
17 #include <cstddef>
18 #include <cstdint>
19 
20 typedef void (*MipGenerationFunction)(size_t sourceWidth, size_t sourceHeight, size_t sourceDepth,
21                                       const uint8_t *sourceData, size_t sourceRowPitch, size_t sourceDepthPitch,
22                                       uint8_t *destData, size_t destRowPitch, size_t destDepthPitch);
23 
24 typedef void (*LoadImageFunction)(size_t width, size_t height, size_t depth,
25                                   const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
26                                   uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
27 
28 typedef void (*InitializeTextureDataFunction)(size_t width, size_t height, size_t depth,
29                                               uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
30 
31 typedef void (*ColorReadFunction)(const uint8_t *source, uint8_t *dest);
32 typedef void (*ColorWriteFunction)(const uint8_t *source, uint8_t *dest);
33 typedef void (*ColorCopyFunction)(const uint8_t *source, uint8_t *dest);
34 
35 typedef void (*VertexCopyFunction)(const uint8_t *input, size_t stride, size_t count, uint8_t *output);
36 
37 namespace gl
38 {
39 
40 struct FormatType
41 {
42     FormatType();
43 
44     GLenum internalFormat;
45     ColorWriteFunction colorWriteFunction;
46 };
47 const FormatType &GetFormatTypeInfo(GLenum format, GLenum type);
48 
49 struct Type
50 {
51     Type();
52 
53     GLuint bytes;
54     bool specialInterpretation;
55 };
56 const Type &GetTypeInfo(GLenum type);
57 
58 struct InternalFormat
59 {
60     InternalFormat();
61 
62     GLuint redBits;
63     GLuint greenBits;
64     GLuint blueBits;
65 
66     GLuint luminanceBits;
67 
68     GLuint alphaBits;
69     GLuint sharedBits;
70 
71     GLuint depthBits;
72     GLuint stencilBits;
73 
74     GLuint pixelBytes;
75 
76     GLuint componentCount;
77 
78     bool compressed;
79     GLuint compressedBlockWidth;
80     GLuint compressedBlockHeight;
81 
82     GLenum format;
83     GLenum type;
84 
85     GLenum componentType;
86     GLenum colorEncoding;
87 
88     typedef bool (*SupportCheckFunction)(GLuint, const Extensions &);
89     SupportCheckFunction textureSupport;
90     SupportCheckFunction renderSupport;
91     SupportCheckFunction filterSupport;
92 
93     GLuint computeRowPitch(GLenum type, GLsizei width, GLint alignment) const;
94     GLuint computeDepthPitch(GLenum type, GLsizei width, GLsizei height, GLint alignment) const;
95     GLuint computeBlockSize(GLenum type, GLsizei width, GLsizei height) const;
96 };
97 const InternalFormat &GetInternalFormatInfo(GLenum internalFormat);
98 
99 GLenum GetSizedInternalFormat(GLenum internalFormat, GLenum type);
100 
101 typedef std::set<GLenum> FormatSet;
102 const FormatSet &GetAllSizedInternalFormats();
103 
104 }
105 
106 #endif // LIBGLESV2_FORMATUTILS_H_
107