summaryrefslogtreecommitdiffstats
path: root/gfx/skia/skia/src/core/SkCompressedDataUtils.h
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/skia/skia/src/core/SkCompressedDataUtils.h')
-rw-r--r--gfx/skia/skia/src/core/SkCompressedDataUtils.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/gfx/skia/skia/src/core/SkCompressedDataUtils.h b/gfx/skia/skia/src/core/SkCompressedDataUtils.h
new file mode 100644
index 0000000000..45e8246f23
--- /dev/null
+++ b/gfx/skia/skia/src/core/SkCompressedDataUtils.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2020 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkCompressedDataUtils_DEFINED
+#define SkCompressedDataUtils_DEFINED
+
+#include "include/core/SkRefCnt.h"
+#include "include/core/SkTextureCompressionType.h"
+#include "include/private/base/SkAssert.h"
+#include "include/private/base/SkTArray.h"
+
+#include <cstddef>
+
+class SkBitmap;
+class SkData;
+struct SkISize;
+
+static constexpr bool SkTextureCompressionTypeIsOpaque(SkTextureCompressionType compression) {
+ switch (compression) {
+ case SkTextureCompressionType::kNone: return true;
+ case SkTextureCompressionType::kETC2_RGB8_UNORM: return true;
+ case SkTextureCompressionType::kBC1_RGB8_UNORM: return true;
+ case SkTextureCompressionType::kBC1_RGBA8_UNORM: return false;
+ }
+
+ SkUNREACHABLE;
+}
+
+size_t SkCompressedDataSize(SkTextureCompressionType, SkISize baseDimensions,
+ skia_private::TArray<size_t>* individualMipOffsets, bool mipmapped);
+size_t SkCompressedBlockSize(SkTextureCompressionType type);
+
+/**
+ * Returns the data size for the given SkTextureCompressionType
+ */
+size_t SkCompressedFormatDataSize(SkTextureCompressionType compressionType,
+ SkISize dimensions, bool mipmapped);
+
+ /*
+ * This method will decompress the bottommost level in 'data' into 'dst'.
+ */
+bool SkDecompress(sk_sp<SkData> data,
+ SkISize dimensions,
+ SkTextureCompressionType compressionType,
+ SkBitmap* dst);
+
+#endif