Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/utils/SkTextureCompressor.h

Issue 438443004: Revert of Add ETC1 format to SkTextureCompressor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/images/SkImageDecoder_pkm.cpp ('k') | src/utils/SkTextureCompressor.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkTextureCompressor_DEFINED 8 #ifndef SkTextureCompressor_DEFINED
9 #define SkTextureCompressor_DEFINED 9 #define SkTextureCompressor_DEFINED
10 10
11 #include "SkImageInfo.h" 11 #include "SkImageInfo.h"
12 #include "SkBlitter.h" 12 #include "SkBlitter.h"
13 13
14 class SkBitmap; 14 class SkBitmap;
15 class SkData; 15 class SkData;
16 16
17 namespace SkTextureCompressor { 17 namespace SkTextureCompressor {
18 // Various texture compression formats that we support. 18 // Various texture compression formats that we support.
19 enum Format { 19 enum Format {
20 // Alpha only formats. 20 // Alpha only formats.
21 kLATC_Format, // 4x4 blocks, (de)compresses A8 21 kLATC_Format, // 4x4 blocks, compresses A8
22 kR11_EAC_Format, // 4x4 blocks, (de)compresses A8 22 kR11_EAC_Format, // 4x4 blocks, compresses A8
23 23 kASTC_12x12_Format, // 12x12 blocks, compresses A8
24 // RGB only formats
25 kETC1_Format, // 4x4 blocks, compresses RGB 565, decompresses 8-bi t RGB
26 // NOTE: ETC1 supports 8-bit RGB compression, but we
27 // currently don't have any RGB8 SkColorTypes. We could
28 // support 8-bit RGBA but we would have to prepro cess the
29 // bitmap to insert alphas.
30
31 // Multi-purpose formats
32 kASTC_12x12_Format, // 12x12 blocks, compresses A8, decompresses RGBA
33 24
34 kLast_Format = kASTC_12x12_Format 25 kLast_Format = kASTC_12x12_Format
35 }; 26 };
36 static const int kFormatCnt = kLast_Format + 1; 27 static const int kFormatCnt = kLast_Format + 1;
37 28
38 // Returns the size of the compressed data given the width, height, and 29 // Returns the size of the compressed data given the width, height, and
39 // desired compression format. If the width and height are not an appropriat e 30 // desired compression format. If the width and height are not an appropriat e
40 // multiple of the block size, then this function returns an error (-1). 31 // multiple of the block size, then this function returns an error (-1).
41 int GetCompressedDataSize(Format fmt, int width, int height); 32 int GetCompressedDataSize(Format fmt, int width, int height);
42 33
43 // Returns an SkData holding a blob of compressed data that corresponds 34 // Returns an SkData holding a blob of compressed data that corresponds
44 // to the bitmap. If the bitmap colorType cannot be compressed using the 35 // to the bitmap. If the bitmap colorType cannot be compressed using the
45 // associated format, then we return NULL. The caller is responsible for 36 // associated format, then we return NULL. The caller is responsible for
46 // calling unref() on the returned data. 37 // calling unref() on the returned data.
47 SkData* CompressBitmapToFormat(const SkBitmap& bitmap, Format format); 38 SkData* CompressBitmapToFormat(const SkBitmap& bitmap, Format format);
48 39
49 // Compresses the given src data into dst. The src data is assumed to be 40 // Compresses the given src data into dst. The src data is assumed to be
50 // large enough to hold width*height pixels. The dst data is expected to 41 // large enough to hold width*height pixels. The dst data is expected to
51 // be large enough to hold the compressed data according to the format. 42 // be large enough to hold the compressed data according to the format.
52 bool CompressBufferToFormat(uint8_t* dst, const uint8_t* src, SkColorType sr cColorType, 43 bool CompressBufferToFormat(uint8_t* dst, const uint8_t* src, SkColorType sr cColorType,
53 int width, int height, int rowBytes, Format form at, 44 int width, int height, int rowBytes, Format form at,
54 bool opt = true /* Use optimization if available */); 45 bool opt = true /* Use optimization if available */);
55 46
56 // Decompresses the given src data from the format specified into the 47 // Decompresses the given src data from the format specified into the
57 // destination buffer. The width and height of the data passed corresponds 48 // destination buffer. The width and height of the data passed corresponds
58 // to the width and height of the uncompressed image. The destination buffer (dst) 49 // to the width and height of the uncompressed image. The destination buffer (dst)
59 // is assumed to be large enough to hold the entire decompressed image. The 50 // is assumed to be large enough to hold the entire decompressed image. The
60 // decompressed image colors are determined based on the passed format. 51 // decompressed image colors are determined based on the passed format:
52 //
53 // LATC -> Alpha 8
54 // R11_EAC -> Alpha 8
55 // ASTC -> RGBA
61 // 56 //
62 // Note, CompressBufferToFormat compresses A8 data into ASTC. However, 57 // Note, CompressBufferToFormat compresses A8 data into ASTC. However,
63 // general ASTC data encodes RGBA data, so that is what the decompressor 58 // general ASTC data encodes RGBA data, so that is what the decompressor
64 // operates on. 59 // operates on.
65 // 60 //
66 // Returns true if successfully decompresses the src data. 61 // Returns true if successfully decompresses the src data.
67 bool DecompressBufferFromFormat(uint8_t* dst, int dstRowBytes, const uint8_t * src, 62 bool DecompressBufferFromFormat(uint8_t* dst, int dstRowBytes, const uint8_t * src,
68 int width, int height, Format format); 63 int width, int height, Format format);
69 64
70 // This typedef defines what the nominal aspects of a compression function 65 // This typedef defines what the nominal aspects of a compression function
(...skipping 11 matching lines...) Expand all
82 // Returns the desired dimensions of the block size for the given format. Th ese dimensions 77 // Returns the desired dimensions of the block size for the given format. Th ese dimensions
83 // don't necessarily correspond to the specification's dimensions, since the re may 78 // don't necessarily correspond to the specification's dimensions, since the re may
84 // be specialized algorithms that operate on multiple blocks at once. If the 79 // be specialized algorithms that operate on multiple blocks at once. If the
85 // flag 'matchSpec' is true, then the actual dimensions from the specificati on are 80 // flag 'matchSpec' is true, then the actual dimensions from the specificati on are
86 // returned. If the flag is false, then these dimensions reflect the appropr iate operable 81 // returned. If the flag is false, then these dimensions reflect the appropr iate operable
87 // dimensions of the compression functions. 82 // dimensions of the compression functions.
88 void GetBlockDimensions(Format format, int* dimX, int* dimY, bool matchSpec = false); 83 void GetBlockDimensions(Format format, int* dimX, int* dimY, bool matchSpec = false);
89 } 84 }
90 85
91 #endif 86 #endif
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_pkm.cpp ('k') | src/utils/SkTextureCompressor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698