blob: e0870300097ca8d290c337b322b35ff7a9f153c9 [file] [log] [blame]
Jamie Madilld2b50a02016-06-09 00:13:35 -07001//
2// Copyright 2016 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// renderer_utils:
7// Helper methods pertaining to most or all back-ends.
8//
9
10#ifndef LIBANGLE_RENDERER_RENDERER_UTILS_H_
11#define LIBANGLE_RENDERER_RENDERER_UTILS_H_
12
13#include <cstdint>
14
15#include <map>
16
17#include "libANGLE/angletypes.h"
18
Jamie Madill86e0b7f2016-08-09 11:10:29 -040019namespace angle
20{
21struct Format;
22}
23
Jamie Madilld2b50a02016-06-09 00:13:35 -070024namespace gl
25{
26struct FormatType;
27struct InternalFormat;
28}
29
30namespace rx
31{
32
Jamie Madilla5b15612016-08-09 11:10:27 -040033using MipGenerationFunction = void (*)(size_t sourceWidth,
34 size_t sourceHeight,
35 size_t sourceDepth,
36 const uint8_t *sourceData,
37 size_t sourceRowPitch,
38 size_t sourceDepthPitch,
39 uint8_t *destData,
40 size_t destRowPitch,
41 size_t destDepthPitch);
42
Jamie Madilld2b50a02016-06-09 00:13:35 -070043typedef void (*ColorReadFunction)(const uint8_t *source, uint8_t *dest);
44typedef void (*ColorWriteFunction)(const uint8_t *source, uint8_t *dest);
45typedef void (*ColorCopyFunction)(const uint8_t *source, uint8_t *dest);
46
47typedef std::map<gl::FormatType, ColorCopyFunction> FastCopyFunctionMap;
48
49struct PackPixelsParams
50{
51 PackPixelsParams();
52 PackPixelsParams(const gl::Rectangle &area,
53 GLenum format,
54 GLenum type,
55 GLuint outputPitch,
56 const gl::PixelPackState &pack,
57 ptrdiff_t offset);
58
59 gl::Rectangle area;
60 GLenum format;
61 GLenum type;
62 GLuint outputPitch;
63 gl::Buffer *packBuffer;
64 gl::PixelPackState pack;
65 ptrdiff_t offset;
66};
67
68void PackPixels(const PackPixelsParams &params,
Jamie Madill86e0b7f2016-08-09 11:10:29 -040069 const angle::Format &sourceFormat,
Jamie Madilld2b50a02016-06-09 00:13:35 -070070 int inputPitch,
71 const uint8_t *source,
72 uint8_t *destination);
73
74ColorWriteFunction GetColorWriteFunction(const gl::FormatType &formatType);
75ColorCopyFunction GetFastCopyFunction(const FastCopyFunctionMap &fastCopyFunctions,
76 const gl::FormatType &formatType);
77
Jamie Madillb2e48632016-08-09 18:08:03 -040078using LoadImageFunction = void (*)(size_t width,
79 size_t height,
80 size_t depth,
81 const uint8_t *input,
82 size_t inputRowPitch,
83 size_t inputDepthPitch,
84 uint8_t *output,
85 size_t outputRowPitch,
86 size_t outputDepthPitch);
87
88struct LoadImageFunctionInfo
89{
90 LoadImageFunctionInfo() : loadFunction(nullptr), requiresConversion(false) {}
91 LoadImageFunctionInfo(LoadImageFunction loadFunction, bool requiresConversion)
92 : loadFunction(loadFunction), requiresConversion(requiresConversion)
93 {
94 }
95
96 LoadImageFunction loadFunction;
97 bool requiresConversion;
98};
99
100using LoadFunctionMap = LoadImageFunctionInfo (*)(GLenum);
101
Jamie Madilld2b50a02016-06-09 00:13:35 -0700102} // namespace rx
103
104#endif // LIBANGLE_RENDERER_RENDERER_UTILS_H_