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 | |
| 19 | namespace gl |
| 20 | { |
| 21 | struct FormatType; |
| 22 | struct InternalFormat; |
| 23 | } |
| 24 | |
| 25 | namespace rx |
| 26 | { |
| 27 | |
Jamie Madill | a5b1561 | 2016-08-09 11:10:27 -0400 | [diff] [blame] | 28 | using 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 Madill | d2b50a0 | 2016-06-09 00:13:35 -0700 | [diff] [blame] | 38 | typedef void (*ColorReadFunction)(const uint8_t *source, uint8_t *dest); |
| 39 | typedef void (*ColorWriteFunction)(const uint8_t *source, uint8_t *dest); |
| 40 | typedef void (*ColorCopyFunction)(const uint8_t *source, uint8_t *dest); |
| 41 | |
| 42 | typedef std::map<gl::FormatType, ColorCopyFunction> FastCopyFunctionMap; |
| 43 | |
| 44 | struct 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 | |
| 63 | void PackPixels(const PackPixelsParams ¶ms, |
| 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 | |
| 71 | ColorWriteFunction GetColorWriteFunction(const gl::FormatType &formatType); |
| 72 | ColorCopyFunction GetFastCopyFunction(const FastCopyFunctionMap &fastCopyFunctions, |
| 73 | const gl::FormatType &formatType); |
| 74 | |
| 75 | } // namespace rx |
| 76 | |
| 77 | #endif // LIBANGLE_RENDERER_RENDERER_UTILS_H_ |