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 | |
| 47 | typedef std::map<gl::FormatType, ColorCopyFunction> FastCopyFunctionMap; |
| 48 | |
| 49 | struct 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 | |
| 68 | void PackPixels(const PackPixelsParams ¶ms, |
Jamie Madill | 86e0b7f | 2016-08-09 11:10:29 -0400 | [diff] [blame] | 69 | const angle::Format &sourceFormat, |
Jamie Madill | d2b50a0 | 2016-06-09 00:13:35 -0700 | [diff] [blame] | 70 | int inputPitch, |
| 71 | const uint8_t *source, |
| 72 | uint8_t *destination); |
| 73 | |
| 74 | ColorWriteFunction GetColorWriteFunction(const gl::FormatType &formatType); |
| 75 | ColorCopyFunction GetFastCopyFunction(const FastCopyFunctionMap &fastCopyFunctions, |
| 76 | const gl::FormatType &formatType); |
| 77 | |
Jamie Madill | b2e4863 | 2016-08-09 18:08:03 -0400 | [diff] [blame^] | 78 | using 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 | |
| 88 | struct 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 | |
| 100 | using LoadFunctionMap = LoadImageFunctionInfo (*)(GLenum); |
| 101 | |
Jamie Madill | d2b50a0 | 2016-06-09 00:13:35 -0700 | [diff] [blame] | 102 | } // namespace rx |
| 103 | |
| 104 | #endif // LIBANGLE_RENDERER_RENDERER_UTILS_H_ |