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