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

Side by Side Diff: third_party/ktx/ktx.cpp

Issue 444093002: - Add astcbitmap to gm slides (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Decode trits/quints into temp buffers 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "ktx.h" 9 #include "ktx.h"
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
11 #include "SkStream.h" 11 #include "SkStream.h"
12 #include "SkEndian.h" 12 #include "SkEndian.h"
13 13
14 #include "gl/GrGLDefines.h" 14 #include "gl/GrGLDefines.h"
15 #include "GrConfig.h" 15 #include "GrConfig.h"
16 16
17 #include "etc1.h" 17 #include "etc1.h"
18 18
19 static inline uint32_t compressed_fmt_to_gl_define(SkTextureCompressor::Format f mt) { 19 static inline uint32_t compressed_fmt_to_gl_define(SkTextureCompressor::Format f mt) {
20 static const uint32_t kGLDefineMap[SkTextureCompressor::kFormatCnt] = { 20 static const uint32_t kGLDefineMap[SkTextureCompressor::kFormatCnt] = {
21 GR_GL_COMPRESSED_LUMINANCE_LATC1, // kLATC_Format 21 GR_GL_COMPRESSED_LUMINANCE_LATC1, // kLATC_Format
22 GR_GL_COMPRESSED_R11, // kR11_EAC_Format 22 GR_GL_COMPRESSED_R11, // kR11_EAC_Format
23 GR_GL_COMPRESSED_RGB8_ETC1, // kETC1_Format 23 GR_GL_COMPRESSED_RGB8_ETC1, // kETC1_Format
24 GR_GL_COMPRESSED_RGBA_ASTC_4x4, // kASTC_4x4_Format
25 GR_GL_COMPRESSED_RGBA_ASTC_5x4, // kASTC_5x4_Format
26 GR_GL_COMPRESSED_RGBA_ASTC_5x5, // kASTC_5x5_Format
27 GR_GL_COMPRESSED_RGBA_ASTC_6x5, // kASTC_6x5_Format
28 GR_GL_COMPRESSED_RGBA_ASTC_6x6, // kASTC_6x6_Format
29 GR_GL_COMPRESSED_RGBA_ASTC_8x5, // kASTC_8x5_Format
30 GR_GL_COMPRESSED_RGBA_ASTC_8x6, // kASTC_8x6_Format
31 GR_GL_COMPRESSED_RGBA_ASTC_8x8, // kASTC_8x8_Format
32 GR_GL_COMPRESSED_RGBA_ASTC_10x5, // kASTC_10x5_Format
33 GR_GL_COMPRESSED_RGBA_ASTC_10x6, // kASTC_10x6_Format
34 GR_GL_COMPRESSED_RGBA_ASTC_10x8, // kASTC_10x8_Format
35 GR_GL_COMPRESSED_RGBA_ASTC_10x10, // kASTC_10x10_Format
36 GR_GL_COMPRESSED_RGBA_ASTC_12x10, // kASTC_12x10_Format
24 GR_GL_COMPRESSED_RGBA_ASTC_12x12, // kASTC_12x12_Format 37 GR_GL_COMPRESSED_RGBA_ASTC_12x12, // kASTC_12x12_Format
25 }; 38 };
26 39
27 GR_STATIC_ASSERT(0 == SkTextureCompressor::kLATC_Format); 40 GR_STATIC_ASSERT(0 == SkTextureCompressor::kLATC_Format);
28 GR_STATIC_ASSERT(1 == SkTextureCompressor::kR11_EAC_Format); 41 GR_STATIC_ASSERT(1 == SkTextureCompressor::kR11_EAC_Format);
29 GR_STATIC_ASSERT(2 == SkTextureCompressor::kETC1_Format); 42 GR_STATIC_ASSERT(2 == SkTextureCompressor::kETC1_Format);
30 GR_STATIC_ASSERT(3 == SkTextureCompressor::kASTC_12x12_Format); 43 GR_STATIC_ASSERT(3 == SkTextureCompressor::kASTC_4x4_Format);
44 GR_STATIC_ASSERT(4 == SkTextureCompressor::kASTC_5x4_Format);
45 GR_STATIC_ASSERT(5 == SkTextureCompressor::kASTC_5x5_Format);
46 GR_STATIC_ASSERT(6 == SkTextureCompressor::kASTC_6x5_Format);
47 GR_STATIC_ASSERT(7 == SkTextureCompressor::kASTC_6x6_Format);
48 GR_STATIC_ASSERT(8 == SkTextureCompressor::kASTC_8x5_Format);
49 GR_STATIC_ASSERT(9 == SkTextureCompressor::kASTC_8x6_Format);
50 GR_STATIC_ASSERT(10 == SkTextureCompressor::kASTC_8x8_Format);
51 GR_STATIC_ASSERT(11 == SkTextureCompressor::kASTC_10x5_Format);
52 GR_STATIC_ASSERT(12 == SkTextureCompressor::kASTC_10x6_Format);
53 GR_STATIC_ASSERT(13 == SkTextureCompressor::kASTC_10x8_Format);
54 GR_STATIC_ASSERT(14 == SkTextureCompressor::kASTC_10x10_Format);
55 GR_STATIC_ASSERT(15 == SkTextureCompressor::kASTC_12x10_Format);
56 GR_STATIC_ASSERT(16 == SkTextureCompressor::kASTC_12x12_Format);
31 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kGLDefineMap) == SkTextureCompressor::kForma tCnt); 57 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kGLDefineMap) == SkTextureCompressor::kForma tCnt);
32 58
33 return kGLDefineMap[fmt]; 59 return kGLDefineMap[fmt];
34 } 60 }
35 61
36 #define KTX_FILE_IDENTIFIER_SIZE 12 62 #define KTX_FILE_IDENTIFIER_SIZE 12
37 static const uint8_t KTX_FILE_IDENTIFIER[KTX_FILE_IDENTIFIER_SIZE] = { 63 static const uint8_t KTX_FILE_IDENTIFIER[KTX_FILE_IDENTIFIER_SIZE] = {
38 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A 64 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
39 }; 65 };
40 66
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 for (int i = 0; i < height; ++i) { 545 for (int i = 0; i < height; ++i) {
520 if (!stream->write(rowPtr, bpp*width)) { 546 if (!stream->write(rowPtr, bpp*width)) {
521 return false; 547 return false;
522 } 548 }
523 rowPtr += bitmap.rowBytes(); 549 rowPtr += bitmap.rowBytes();
524 } 550 }
525 } 551 }
526 552
527 return true; 553 return true;
528 } 554 }
OLDNEW
« src/images/SkImageDecoder_astc.cpp ('K') | « tests/TextureCompressionTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698