blob: e2ae75f361b8986b1a01ceee7745bb2b17da2a82 [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 const FastCopyFunctionMap &fastCopyFunctionsMap,
Jamie Madilld2b50a02016-06-09 00:13:35 -070071 int inputPitch,
72 const uint8_t *source,
73 uint8_t *destination);
74
75ColorWriteFunction GetColorWriteFunction(const gl::FormatType &formatType);
76ColorCopyFunction GetFastCopyFunction(const FastCopyFunctionMap &fastCopyFunctions,
77 const gl::FormatType &formatType);
78
79} // namespace rx
80
81#endif // LIBANGLE_RENDERER_RENDERER_UTILS_H_