| 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/SkRefCnt.h" |
| 12 |
#include "include/core/SkTextureCompressionType.h" |
| 13 |
#include "include/private/base/SkAssert.h" |
| 14 |
#include "include/private/base/SkTArray.h" |
| 15 |
|
| 16 |
#include <cstddef> |
| 17 |
|
| 18 |
class SkBitmap; |
| 19 |
class SkData; |
| 20 |
struct SkISize; |
| 21 |
|
| 22 |
static constexpr bool SkTextureCompressionTypeIsOpaque(SkTextureCompressionType compression) { |
| 23 |
switch (compression) { |
| 24 |
case SkTextureCompressionType::kNone: return true; |
| 25 |
case SkTextureCompressionType::kETC2_RGB8_UNORM: return true; |
| 26 |
case SkTextureCompressionType::kBC1_RGB8_UNORM: return true; |
| 27 |
case SkTextureCompressionType::kBC1_RGBA8_UNORM: return false; |
| 28 |
} |
| 29 |
|
| 30 |
SkUNREACHABLE; |
| 31 |
} |
| 32 |
|
| 33 |
size_t SkCompressedDataSize(SkTextureCompressionType, SkISize baseDimensions, |
| 34 |
skia_private::TArray<size_t>* individualMipOffsets, bool mipmapped); |
| 35 |
size_t SkCompressedBlockSize(SkTextureCompressionType type); |
| 36 |
|
| 37 |
/** |
| 38 |
* Returns the data size for the given SkTextureCompressionType |
| 39 |
*/ |
| 40 |
size_t SkCompressedFormatDataSize(SkTextureCompressionType 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 |
SkTextureCompressionType compressionType, |
| 49 |
SkBitmap* dst); |
| 50 |
|
| 51 |
#endif |