Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef GrDataUtils_DEFINED |
| 9 | #define GrDataUtils_DEFINED |
| 10 | |
| 11 | #include "include/core/SkColor.h" |
| 12 | #include "include/private/GrTypesPriv.h" |
Brian Salomon | f30b1c1 | 2019-06-20 12:25:02 -0400 | [diff] [blame] | 13 | #include "src/gpu/GrSwizzle.h" |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 14 | |
Brian Salomon | bb8dde8 | 2019-06-27 10:52:13 -0400 | [diff] [blame] | 15 | size_t GrCompressedDataSize(SkImage::CompressionType, int w, int h); |
Robert Phillips | 28a5a43 | 2019-06-07 12:46:21 -0400 | [diff] [blame] | 16 | |
| 17 | // Compute the size of the buffer required to hold all the mipLevels of the specified type |
| 18 | // of data when all rowBytes are tight. |
| 19 | // Note there may still be padding between the mipLevels to meet alignment requirements. |
Brian Salomon | bb8dde8 | 2019-06-27 10:52:13 -0400 | [diff] [blame] | 20 | size_t GrComputeTightCombinedBufferSize(size_t bytesPerPixel, int baseWidth, int baseHeight, |
| 21 | SkTArray<size_t>* individualMipOffsets, int mipLevelCount); |
Robert Phillips | 28a5a43 | 2019-06-07 12:46:21 -0400 | [diff] [blame] | 22 | |
Brian Salomon | bb8dde8 | 2019-06-27 10:52:13 -0400 | [diff] [blame] | 23 | void GrFillInData(GrPixelConfig, int baseWidth, int baseHeight, |
| 24 | const SkTArray<size_t>& individualMipOffsets, char* dest, const SkColor4f& color); |
| 25 | |
| 26 | void GrFillInCompressedData(SkImage::CompressionType, int width, int height, char* dest, |
| 27 | const SkColor4f& color); |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 28 | |
Brian Salomon | f30b1c1 | 2019-06-20 12:25:02 -0400 | [diff] [blame] | 29 | struct GrColorInfo { |
| 30 | GrColorType fColorType = GrColorType::kUnknown; |
| 31 | SkColorSpace* fColorSpace = nullptr; |
| 32 | SkAlphaType fAlphaType = kPremul_SkAlphaType; |
| 33 | }; |
| 34 | |
| 35 | struct GrPixelInfo { |
| 36 | GrColorInfo fColorInfo = {}; |
| 37 | GrSurfaceOrigin fOrigin = kTopLeft_GrSurfaceOrigin; |
| 38 | int fWidth = 0; |
| 39 | int fHeight = 0; |
| 40 | size_t fRowBytes = 0; |
| 41 | }; |
| 42 | |
| 43 | // Swizzle param is applied after loading and before converting from srcInfo to dstInfo. |
| 44 | bool GrConvertPixels(const GrPixelInfo& dstInfo, void* dst, const GrPixelInfo& srcInfo, |
| 45 | const void* src, GrSwizzle swizzle = GrSwizzle{}); |
| 46 | |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 47 | #endif |