blob: 403333e60d3d5ca70ad94a5792d507d06ce6e474 [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
19namespace gl
20{
21struct FormatType;
22struct InternalFormat;
23}
24
25namespace rx
26{
27
Jamie Madilla5b15612016-08-09 11:10:27 -040028using MipGenerationFunction = void (*)(size_t sourceWidth,
29 size_t sourceHeight,
30 size_t sourceDepth,
31 const uint8_t *sourceData,
32 size_t sourceRowPitch,
33 size_t sourceDepthPitch,
34 uint8_t *destData,
35 size_t destRowPitch,
36 size_t destDepthPitch);
37
Jamie Madilld2b50a02016-06-09 00:13:35 -070038typedef void (*ColorReadFunction)(const uint8_t *source, uint8_t *dest);
39typedef void (*ColorWriteFunction)(const uint8_t *source, uint8_t *dest);
40typedef void (*ColorCopyFunction)(const uint8_t *source, uint8_t *dest);
41
42typedef std::map<gl::FormatType, ColorCopyFunction> FastCopyFunctionMap;
43
44struct PackPixelsParams
45{
46 PackPixelsParams();
47 PackPixelsParams(const gl::Rectangle &area,
48 GLenum format,
49 GLenum type,
50 GLuint outputPitch,
51 const gl::PixelPackState &pack,
52 ptrdiff_t offset);
53
54 gl::Rectangle area;
55 GLenum format;
56 GLenum type;
57 GLuint outputPitch;
58 gl::Buffer *packBuffer;
59 gl::PixelPackState pack;
60 ptrdiff_t offset;
61};
62
63void PackPixels(const PackPixelsParams &params,
64 const gl::InternalFormat &sourceFormatInfo,
65 const FastCopyFunctionMap &fastCopyFunctionsMap,
66 ColorReadFunction colorReadFunction,
67 int inputPitch,
68 const uint8_t *source,
69 uint8_t *destination);
70
71ColorWriteFunction GetColorWriteFunction(const gl::FormatType &formatType);
72ColorCopyFunction GetFastCopyFunction(const FastCopyFunctionMap &fastCopyFunctions,
73 const gl::FormatType &formatType);
74
75} // namespace rx
76
77#endif // LIBANGLE_RENDERER_RENDERER_UTILS_H_