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" 13 #include "src/gpu/GrColorInfo.h" 14 #include "src/gpu/GrSwizzle.h" 15 16 class GrImageInfo; 17 18 size_t GrCompressedDataSize(SkImage::CompressionType, int w, int h); 19 20 // Returns a value that can be used to set rowBytes for a transfer function. 21 size_t GrCompressedRowBytes(SkImage::CompressionType, int w); 22 23 // Compute the size of the buffer required to hold all the mipLevels of the specified type 24 // of data when all rowBytes are tight. 25 // Note there may still be padding between the mipLevels to meet alignment requirements. 26 size_t GrComputeTightCombinedBufferSize(size_t bytesPerPixel, int baseWidth, int baseHeight, 27 SkTArray<size_t>* individualMipOffsets, int mipLevelCount); 28 29 void GrFillInData(GrColorType, int baseWidth, int baseHeight, 30 const SkTArray<size_t>& individualMipOffsets, char* dest, const SkColor4f& color); 31 32 void GrFillInCompressedData(SkImage::CompressionType, int width, int height, char* dest, 33 const SkColor4f& color); 34 35 // Swizzle param is applied after loading and before converting from srcInfo to dstInfo. 36 bool GrConvertPixels(const GrImageInfo& dstInfo, void* dst, size_t dstRB, 37 const GrImageInfo& srcInfo, const void* src, size_t srcRB, 38 bool flipY = false); 39 40 #endif 41