• 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_UNORM: return false;
26     }
27 
28     SkUNREACHABLE;
29 }
30 
31 size_t SkCompressedDataSize(SkImage::CompressionType, SkISize baseDimensions,
32                             SkTArray<size_t>* individualMipOffsets, bool mipMapped);
33 size_t SkCompressedBlockSize(SkImage::CompressionType type);
34 
35 /**
36  * Returns the data size for the given SkImage::CompressionType
37  */
38 size_t SkCompressedFormatDataSize(SkImage::CompressionType compressionType,
39                                   SkISize dimensions, bool mipMapped);
40 
41  /*
42   * This method will decompress the bottommost level in 'data' into 'dst'.
43   */
44 bool SkDecompress(sk_sp<SkData> data,
45                   SkISize dimensions,
46                   SkImage::CompressionType compressionType,
47                   SkBitmap* dst);
48 
49 #endif
50