Jamie Madill | d2b50a0 | 2016-06-09 00:13:35 -0700 | [diff] [blame] | 1 | // |
| 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 Madill | 86e0b7f | 2016-08-09 11:10:29 -0400 | [diff] [blame] | 19 | namespace angle |
| 20 | { |
| 21 | struct Format; |
| 22 | } |
| 23 | |
Jamie Madill | d2b50a0 | 2016-06-09 00:13:35 -0700 | [diff] [blame] | 24 | namespace gl |
| 25 | { |
| 26 | struct FormatType; |
| 27 | struct InternalFormat; |
| 28 | } |
| 29 | |
| 30 | namespace rx |
| 31 | { |
| 32 | |
Jamie Madill | a5b1561 | 2016-08-09 11:10:27 -0400 | [diff] [blame] | 33 | using 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 Madill | d2b50a0 | 2016-06-09 00:13:35 -0700 | [diff] [blame] | 43 | typedef void (*ColorReadFunction)(const uint8_t *source, uint8_t *dest); |
| 44 | typedef void (*ColorWriteFunction)(const uint8_t *source, uint8_t *dest); |
| 45 | typedef void (*ColorCopyFunction)(const uint8_t *source, uint8_t *dest); |
| 46 | |
Jamie Madill | 4f57e5f | 2016-10-27 17:36:53 -0400 | [diff] [blame] | 47 | class FastCopyFunctionMap |
| 48 | { |
| 49 | public: |
| 50 | struct Entry |
| 51 | { |
| 52 | GLenum format; |
| 53 | GLenum type; |
| 54 | ColorCopyFunction func; |
| 55 | }; |
| 56 | |
| 57 | constexpr FastCopyFunctionMap() : FastCopyFunctionMap(nullptr, 0) {} |
| 58 | |
| 59 | constexpr FastCopyFunctionMap(const Entry *data, size_t size) : mSize(size), mData(data) {} |
| 60 | |
| 61 | bool has(const gl::FormatType &formatType) const; |
| 62 | ColorCopyFunction get(const gl::FormatType &formatType) const; |
| 63 | |
| 64 | private: |
| 65 | size_t mSize; |
| 66 | const Entry *mData; |
| 67 | }; |
Jamie Madill | d2b50a0 | 2016-06-09 00:13:35 -0700 | [diff] [blame] | 68 | |
| 69 | struct PackPixelsParams |
| 70 | { |
| 71 | PackPixelsParams(); |
| 72 | PackPixelsParams(const gl::Rectangle &area, |
| 73 | GLenum format, |
| 74 | GLenum type, |
| 75 | GLuint outputPitch, |
| 76 | const gl::PixelPackState &pack, |
| 77 | ptrdiff_t offset); |
| 78 | |
| 79 | gl::Rectangle area; |
| 80 | GLenum format; |
| 81 | GLenum type; |
| 82 | GLuint outputPitch; |
| 83 | gl::Buffer *packBuffer; |
| 84 | gl::PixelPackState pack; |
| 85 | ptrdiff_t offset; |
| 86 | }; |
| 87 | |
| 88 | void PackPixels(const PackPixelsParams ¶ms, |
Jamie Madill | 86e0b7f | 2016-08-09 11:10:29 -0400 | [diff] [blame] | 89 | const angle::Format &sourceFormat, |
Jamie Madill | d2b50a0 | 2016-06-09 00:13:35 -0700 | [diff] [blame] | 90 | int inputPitch, |
| 91 | const uint8_t *source, |
| 92 | uint8_t *destination); |
| 93 | |
| 94 | ColorWriteFunction GetColorWriteFunction(const gl::FormatType &formatType); |
| 95 | ColorCopyFunction GetFastCopyFunction(const FastCopyFunctionMap &fastCopyFunctions, |
| 96 | const gl::FormatType &formatType); |
| 97 | |
Jamie Madill | abaab23 | 2017-01-10 12:37:37 -0500 | [diff] [blame] | 98 | using InitializeTextureDataFunction = void (*)(size_t width, |
| 99 | size_t height, |
| 100 | size_t depth, |
| 101 | uint8_t *output, |
| 102 | size_t outputRowPitch, |
| 103 | size_t outputDepthPitch); |
| 104 | |
Jamie Madill | b2e4863 | 2016-08-09 18:08:03 -0400 | [diff] [blame] | 105 | using LoadImageFunction = void (*)(size_t width, |
| 106 | size_t height, |
| 107 | size_t depth, |
| 108 | const uint8_t *input, |
| 109 | size_t inputRowPitch, |
| 110 | size_t inputDepthPitch, |
| 111 | uint8_t *output, |
| 112 | size_t outputRowPitch, |
| 113 | size_t outputDepthPitch); |
| 114 | |
| 115 | struct LoadImageFunctionInfo |
| 116 | { |
| 117 | LoadImageFunctionInfo() : loadFunction(nullptr), requiresConversion(false) {} |
| 118 | LoadImageFunctionInfo(LoadImageFunction loadFunction, bool requiresConversion) |
| 119 | : loadFunction(loadFunction), requiresConversion(requiresConversion) |
| 120 | { |
| 121 | } |
| 122 | |
| 123 | LoadImageFunction loadFunction; |
| 124 | bool requiresConversion; |
| 125 | }; |
| 126 | |
| 127 | using LoadFunctionMap = LoadImageFunctionInfo (*)(GLenum); |
| 128 | |
Jamie Madill | d2b50a0 | 2016-06-09 00:13:35 -0700 | [diff] [blame] | 129 | } // namespace rx |
| 130 | |
| 131 | #endif // LIBANGLE_RENDERER_RENDERER_UTILS_H_ |