• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2020 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 SkCompressedDataUtils_DEFINED
9 #define SkCompressedDataUtils_DEFINED
10 
11 #include "include/core/SkImage.h"
12 #include "include/core/SkRefCnt.h"
13 #include "include/core/SkSize.h"
14 #include "include/private/SkTArray.h"
15 
16 class SkBitmap;
17 class SkData;
18 
SkCompressionTypeIsOpaque(SkImage::CompressionType compression)19 static constexpr bool SkCompressionTypeIsOpaque(SkImage::CompressionType compression) {
20     switch (compression) {
21         case SkImage::CompressionType::kNone:             return true;
22         case SkImage::CompressionType::kETC2_RGB8_UNORM:  return true;
23         case SkImage::CompressionType::kBC1_RGB8_UNORM:   return true;
24         case SkImage::CompressionType::kBC1_RGBA8_UNORM:  return false;
25         case SkImage::CompressionType::kASTC_RGBA8_4x4:   return false;
26         case SkImage::CompressionType::kASTC_RGBA8_6x6:   return false;
27         case SkImage::CompressionType::kASTC_RGBA8_8x8:   return false;
28     }
29 
30     SkUNREACHABLE;
31 }
32 
33 size_t SkCompressedDataSize(SkImage::CompressionType, SkISize baseDimensions,
34                             SkTArray<size_t>* individualMipOffsets, bool mipMapped);
35 size_t SkCompressedBlockSize(SkImage::CompressionType type);
36 
37 /**
38  * Returns the data size for the given SkImage::CompressionType
39  */
40 size_t SkCompressedFormatDataSize(SkImage::CompressionType compressionType,
41                                   SkISize dimensions, bool mipMapped);
42 
43  /*
44   * This method will decompress the bottommost level in 'data' into 'dst'.
45   */
46 bool SkDecompress(sk_sp<SkData> data,
47                   SkISize dimensions,
48                   SkImage::CompressionType compressionType,
49                   SkBitmap* dst);
50 
51 #endif
52