OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "config.h" |
| 6 |
| 7 #include "modules/webgl/WebGLCompressedTextureASTC.h" |
| 8 |
| 9 #include "modules/webgl/WebGLRenderingContextBase.h" |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 const WebGLCompressedTextureASTC::BlockSizeCompressASTC |
| 14 WebGLCompressedTextureASTC::kBlockSizeCompressASTC[] = { |
| 15 {GL_COMPRESSED_RGBA_ASTC_4x4_KHR, 4, 4}, |
| 16 {GL_COMPRESSED_RGBA_ASTC_5x4_KHR, 5, 4}, |
| 17 {GL_COMPRESSED_RGBA_ASTC_5x5_KHR, 5, 5}, |
| 18 {GL_COMPRESSED_RGBA_ASTC_6x5_KHR, 6, 5}, |
| 19 {GL_COMPRESSED_RGBA_ASTC_6x6_KHR, 6, 6}, |
| 20 {GL_COMPRESSED_RGBA_ASTC_8x5_KHR, 8, 5}, |
| 21 {GL_COMPRESSED_RGBA_ASTC_8x6_KHR, 8, 6}, |
| 22 {GL_COMPRESSED_RGBA_ASTC_8x8_KHR, 8, 8}, |
| 23 {GL_COMPRESSED_RGBA_ASTC_10x5_KHR, 10, 5}, |
| 24 {GL_COMPRESSED_RGBA_ASTC_10x6_KHR, 10, 6}, |
| 25 {GL_COMPRESSED_RGBA_ASTC_10x8_KHR, 10, 8}, |
| 26 {GL_COMPRESSED_RGBA_ASTC_10x10_KHR, 10, 10}, |
| 27 {GL_COMPRESSED_RGBA_ASTC_12x10_KHR, 12, 10}, |
| 28 {GL_COMPRESSED_RGBA_ASTC_12x12_KHR, 12, 12}}; |
| 29 |
| 30 WebGLCompressedTextureASTC::WebGLCompressedTextureASTC(WebGLRenderingContextBase
* context) |
| 31 : WebGLExtension(context) |
| 32 { |
| 33 const int kAlphaFormatGap = |
| 34 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR - GL_COMPRESSED_RGBA_ASTC_4x4_KH
R; |
| 35 |
| 36 for (size_t i = 0; i < arraysize(WebGLCompressedTextureASTC::kBlockSizeCompr
essASTC); i++) { |
| 37 /* GL_COMPRESSED_RGBA_ASTC(0x93B0 ~ 0x93BD) */ |
| 38 context->addCompressedTextureFormat( |
| 39 WebGLCompressedTextureASTC::kBlockSizeCompressASTC[i].CompressType); |
| 40 /* GL_COMPRESSED_SRGB8_ALPHA8_ASTC(0x93D0 ~ 0x93DD) */ |
| 41 context->addCompressedTextureFormat( |
| 42 WebGLCompressedTextureASTC::kBlockSizeCompressASTC[i].CompressType +
kAlphaFormatGap); |
| 43 } |
| 44 } |
| 45 |
| 46 WebGLCompressedTextureASTC::~WebGLCompressedTextureASTC() |
| 47 { |
| 48 } |
| 49 |
| 50 WebGLExtensionName WebGLCompressedTextureASTC::name() const |
| 51 { |
| 52 return WebGLCompressedTextureASTCName; |
| 53 } |
| 54 |
| 55 WebGLCompressedTextureASTC* WebGLCompressedTextureASTC::create(WebGLRenderingCon
textBase* context) |
| 56 { |
| 57 return new WebGLCompressedTextureASTC(context); |
| 58 } |
| 59 |
| 60 bool WebGLCompressedTextureASTC::supported(WebGLRenderingContextBase* context) |
| 61 { |
| 62 Extensions3DUtil* extensionsUtil = context->extensionsUtil(); |
| 63 return extensionsUtil->supportsExtension("GL_KHR_texture_compression_astc_ld
r"); |
| 64 } |
| 65 |
| 66 const char* WebGLCompressedTextureASTC::extensionName() |
| 67 { |
| 68 // TODO(cyzero.kim): implement extension for GL_KHR_texture_compression_astc
_hdr. |
| 69 return "WEBGL_compressed_texture_astc"; |
| 70 } |
| 71 |
| 72 } // namespace blink |
OLD | NEW |