blob: 35b9b864307405122f1e1d6e9c313b5376f4237a [file] [log] [blame]
krajcevskiae614402014-06-10 14:52:28 -07001/*
2 * Copyright 2014 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 SkTextureCompressor_DEFINED
9#define SkTextureCompressor_DEFINED
10
krajcevskieecc35f2014-06-20 11:43:00 -070011#include "SkImageInfo.h"
12
krajcevskiae614402014-06-10 14:52:28 -070013class SkBitmap;
14class SkData;
15
16namespace SkTextureCompressor {
17 // Various texture compression formats that we support.
18 enum Format {
krajcevskif3d15dc2014-06-30 08:47:33 -070019 // Alpha only formats.
krajcevskiae614402014-06-10 14:52:28 -070020 kLATC_Format,
krajcevskif3d15dc2014-06-30 08:47:33 -070021 kR11_EAC_Format,
krajcevskiae614402014-06-10 14:52:28 -070022
krajcevskif3d15dc2014-06-30 08:47:33 -070023 kLast_Format = kR11_EAC_Format
krajcevskiae614402014-06-10 14:52:28 -070024 };
25 static const int kFormatCnt = kLast_Format + 1;
26
27 // Returns an SkData holding a blob of compressed data that corresponds
28 // to the bitmap. If the bitmap colorType cannot be compressed using the
29 // associated format, then we return NULL. The caller is responsible for
30 // calling unref() on the returned data.
31 SkData* CompressBitmapToFormat(const SkBitmap& bitmap, Format format);
krajcevskieecc35f2014-06-20 11:43:00 -070032
33 // Compresses the given src data into dst. The src data is assumed to be
34 // large enough to hold width*height pixels. The dst data is expected to
35 // be large enough to hold the compressed data according to the format.
36 bool CompressBufferToFormat(uint8_t* dst, const uint8_t* src, SkColorType srcColorType,
37 int width, int height, int rowBytes, Format format);
krajcevskiae614402014-06-10 14:52:28 -070038}
39
40#endif