| OLD | NEW |
| 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_EAC, // kR11_EAC_Format | 22 GR_GL_COMPRESSED_R11_EAC, // kR11_EAC_Format |
| 23 GR_GL_COMPRESSED_ETC1_RGB8, // kETC1_Format | 23 GR_GL_COMPRESSED_ETC1_RGB8, // kETC1_Format |
| 24 GR_GL_COMPRESSED_RGBA_ASTC_4x4_KHR, // kASTC_4x4_Format | 24 GR_GL_COMPRESSED_RGBA_ASTC_4x4, // kASTC_4x4_Format |
| 25 GR_GL_COMPRESSED_RGBA_ASTC_5x4_KHR, // kASTC_5x4_Format | 25 GR_GL_COMPRESSED_RGBA_ASTC_5x4, // kASTC_5x4_Format |
| 26 GR_GL_COMPRESSED_RGBA_ASTC_5x5_KHR, // kASTC_5x5_Format | 26 GR_GL_COMPRESSED_RGBA_ASTC_5x5, // kASTC_5x5_Format |
| 27 GR_GL_COMPRESSED_RGBA_ASTC_6x5_KHR, // kASTC_6x5_Format | 27 GR_GL_COMPRESSED_RGBA_ASTC_6x5, // kASTC_6x5_Format |
| 28 GR_GL_COMPRESSED_RGBA_ASTC_6x6_KHR, // kASTC_6x6_Format | 28 GR_GL_COMPRESSED_RGBA_ASTC_6x6, // kASTC_6x6_Format |
| 29 GR_GL_COMPRESSED_RGBA_ASTC_8x5_KHR, // kASTC_8x5_Format | 29 GR_GL_COMPRESSED_RGBA_ASTC_8x5, // kASTC_8x5_Format |
| 30 GR_GL_COMPRESSED_RGBA_ASTC_8x6_KHR, // kASTC_8x6_Format | 30 GR_GL_COMPRESSED_RGBA_ASTC_8x6, // kASTC_8x6_Format |
| 31 GR_GL_COMPRESSED_RGBA_ASTC_8x8_KHR, // kASTC_8x8_Format | 31 GR_GL_COMPRESSED_RGBA_ASTC_8x8, // kASTC_8x8_Format |
| 32 GR_GL_COMPRESSED_RGBA_ASTC_10x5_KHR, // kASTC_10x5_Format | 32 GR_GL_COMPRESSED_RGBA_ASTC_10x5, // kASTC_10x5_Format |
| 33 GR_GL_COMPRESSED_RGBA_ASTC_10x6_KHR, // kASTC_10x6_Format | 33 GR_GL_COMPRESSED_RGBA_ASTC_10x6, // kASTC_10x6_Format |
| 34 GR_GL_COMPRESSED_RGBA_ASTC_10x8_KHR, // kASTC_10x8_Format | 34 GR_GL_COMPRESSED_RGBA_ASTC_10x8, // kASTC_10x8_Format |
| 35 GR_GL_COMPRESSED_RGBA_ASTC_10x10_KHR, // kASTC_10x10_Format | 35 GR_GL_COMPRESSED_RGBA_ASTC_10x10, // kASTC_10x10_Format |
| 36 GR_GL_COMPRESSED_RGBA_ASTC_12x10_KHR, // kASTC_12x10_Format | 36 GR_GL_COMPRESSED_RGBA_ASTC_12x10, // kASTC_12x10_Format |
| 37 GR_GL_COMPRESSED_RGBA_ASTC_12x12_KHR, // kASTC_12x12_Format | 37 GR_GL_COMPRESSED_RGBA_ASTC_12x12, // kASTC_12x12_Format |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 GR_STATIC_ASSERT(0 == SkTextureCompressor::kLATC_Format); | 40 GR_STATIC_ASSERT(0 == SkTextureCompressor::kLATC_Format); |
| 41 GR_STATIC_ASSERT(1 == SkTextureCompressor::kR11_EAC_Format); | 41 GR_STATIC_ASSERT(1 == SkTextureCompressor::kR11_EAC_Format); |
| 42 GR_STATIC_ASSERT(2 == SkTextureCompressor::kETC1_Format); | 42 GR_STATIC_ASSERT(2 == SkTextureCompressor::kETC1_Format); |
| 43 GR_STATIC_ASSERT(3 == SkTextureCompressor::kASTC_4x4_Format); | 43 GR_STATIC_ASSERT(3 == SkTextureCompressor::kASTC_4x4_Format); |
| 44 GR_STATIC_ASSERT(4 == SkTextureCompressor::kASTC_5x4_Format); | 44 GR_STATIC_ASSERT(4 == SkTextureCompressor::kASTC_5x4_Format); |
| 45 GR_STATIC_ASSERT(5 == SkTextureCompressor::kASTC_5x5_Format); | 45 GR_STATIC_ASSERT(5 == SkTextureCompressor::kASTC_5x5_Format); |
| 46 GR_STATIC_ASSERT(6 == SkTextureCompressor::kASTC_6x5_Format); | 46 GR_STATIC_ASSERT(6 == SkTextureCompressor::kASTC_6x5_Format); |
| 47 GR_STATIC_ASSERT(7 == SkTextureCompressor::kASTC_6x6_Format); | 47 GR_STATIC_ASSERT(7 == SkTextureCompressor::kASTC_6x6_Format); |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 for (int i = 0; i < height; ++i) { | 550 for (int i = 0; i < height; ++i) { |
| 551 if (!stream->write(rowPtr, bpp*width)) { | 551 if (!stream->write(rowPtr, bpp*width)) { |
| 552 return false; | 552 return false; |
| 553 } | 553 } |
| 554 rowPtr += bitmap.rowBytes(); | 554 rowPtr += bitmap.rowBytes(); |
| 555 } | 555 } |
| 556 } | 556 } |
| 557 | 557 |
| 558 return true; | 558 return true; |
| 559 } | 559 } |
| OLD | NEW |