kRGB_GrColorComponentFlags, // kETC1_GrPixelConfig
kA_GrColorComponentFlag, // kLATC_GrPixelConfig
kA_GrColorComponentFlag, // kR11_EAC_GrPixelConfig
+ kRGBA_GrColorComponentFlags, // kASTC_12x12_GrPixelConfig
kRGBA_GrColorComponentFlags, // kRGBA_float_GrPixelConfig
};
return kFlags[config];
- GR_STATIC_ASSERT(0 == kUnknown_GrPixelConfig);
- GR_STATIC_ASSERT(1 == kAlpha_8_GrPixelConfig);
- GR_STATIC_ASSERT(2 == kIndex_8_GrPixelConfig);
- GR_STATIC_ASSERT(3 == kRGB_565_GrPixelConfig);
- GR_STATIC_ASSERT(4 == kRGBA_4444_GrPixelConfig);
- GR_STATIC_ASSERT(5 == kRGBA_8888_GrPixelConfig);
- GR_STATIC_ASSERT(6 == kBGRA_8888_GrPixelConfig);
- GR_STATIC_ASSERT(7 == kETC1_GrPixelConfig);
- GR_STATIC_ASSERT(8 == kLATC_GrPixelConfig);
- GR_STATIC_ASSERT(9 == kR11_EAC_GrPixelConfig);
- GR_STATIC_ASSERT(10 == kRGBA_float_GrPixelConfig);
+ GR_STATIC_ASSERT(0 == kUnknown_GrPixelConfig);
+ GR_STATIC_ASSERT(1 == kAlpha_8_GrPixelConfig);
+ GR_STATIC_ASSERT(2 == kIndex_8_GrPixelConfig);
+ GR_STATIC_ASSERT(3 == kRGB_565_GrPixelConfig);
+ GR_STATIC_ASSERT(4 == kRGBA_4444_GrPixelConfig);
+ GR_STATIC_ASSERT(5 == kRGBA_8888_GrPixelConfig);
+ GR_STATIC_ASSERT(6 == kBGRA_8888_GrPixelConfig);
+ GR_STATIC_ASSERT(7 == kETC1_GrPixelConfig);
+ GR_STATIC_ASSERT(8 == kLATC_GrPixelConfig);
+ GR_STATIC_ASSERT(9 == kR11_EAC_GrPixelConfig);
+ GR_STATIC_ASSERT(10 == kASTC_12x12_GrPixelConfig);
+ GR_STATIC_ASSERT(11 == kRGBA_float_GrPixelConfig);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kFlags) == kGrPixelConfigCnt);
}
* (Corresponds to section C.3.5 of the OpenGL 4.4 core profile spec)
*/
kR11_EAC_GrPixelConfig,
+
+ /**
+ * 12x12 ASTC Compressed Data
+ * ASTC stands for Adaptive Scalable Texture Compression. It is a technique
+ * that allows for a lot of customization in the compressed representataion
+ * of a block. The only thing fixed in the representation is the block size,
+ * which means that a texture that contains ASTC data must be treated as
+ * having RGBA values. However, there are single-channel encodings which set
+ * the alpha to opaque and all three RGB channels equal effectively making the
+ * compression format a single channel such as R11 EAC and LATC.
+ */
+ kASTC_12x12_GrPixelConfig,
+
/**
* Byte order is r, g, b, a. This color format is 32 bits per channel
*/
case kETC1_GrPixelConfig:
case kLATC_GrPixelConfig:
case kR11_EAC_GrPixelConfig:
+ case kASTC_12x12_GrPixelConfig:
return true;
default:
return false;
SkASSERT((height & 3) == 0);
return (width >> 2) * (height >> 2) * 8;
+ case kASTC_12x12_GrPixelConfig:
+ SkASSERT((width % 12) == 0);
+ SkASSERT((height % 12) == 0);
+ return (width / 12) * (height / 12) * 16;
+
default:
SkFAIL("Unknown compressed pixel config");
return 4 * width * height;
"ETC1", // kETC1_GrPixelConfig,
"LATC", // kLATC_GrPixelConfig,
"R11EAC", // kR11_EAC_GrPixelConfig,
+ "ASTC12x12",// kASTC_12x12_GrPixelConfig,
"RGBAFloat", // kRGBA_float_GrPixelConfig
};
- GR_STATIC_ASSERT(0 == kUnknown_GrPixelConfig);
- GR_STATIC_ASSERT(1 == kAlpha_8_GrPixelConfig);
- GR_STATIC_ASSERT(2 == kIndex_8_GrPixelConfig);
- GR_STATIC_ASSERT(3 == kRGB_565_GrPixelConfig);
- GR_STATIC_ASSERT(4 == kRGBA_4444_GrPixelConfig);
- GR_STATIC_ASSERT(5 == kRGBA_8888_GrPixelConfig);
- GR_STATIC_ASSERT(6 == kBGRA_8888_GrPixelConfig);
- GR_STATIC_ASSERT(7 == kETC1_GrPixelConfig);
- GR_STATIC_ASSERT(8 == kLATC_GrPixelConfig);
- GR_STATIC_ASSERT(9 == kR11_EAC_GrPixelConfig);
- GR_STATIC_ASSERT(10 == kRGBA_float_GrPixelConfig);
+ GR_STATIC_ASSERT(0 == kUnknown_GrPixelConfig);
+ GR_STATIC_ASSERT(1 == kAlpha_8_GrPixelConfig);
+ GR_STATIC_ASSERT(2 == kIndex_8_GrPixelConfig);
+ GR_STATIC_ASSERT(3 == kRGB_565_GrPixelConfig);
+ GR_STATIC_ASSERT(4 == kRGBA_4444_GrPixelConfig);
+ GR_STATIC_ASSERT(5 == kRGBA_8888_GrPixelConfig);
+ GR_STATIC_ASSERT(6 == kBGRA_8888_GrPixelConfig);
+ GR_STATIC_ASSERT(7 == kETC1_GrPixelConfig);
+ GR_STATIC_ASSERT(8 == kLATC_GrPixelConfig);
+ GR_STATIC_ASSERT(9 == kR11_EAC_GrPixelConfig);
+ GR_STATIC_ASSERT(10 == kASTC_12x12_GrPixelConfig);
+ GR_STATIC_ASSERT(11 == kRGBA_float_GrPixelConfig);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kConfigNames) == kGrPixelConfigCnt);
SkASSERT(!fConfigRenderSupport[kUnknown_GrPixelConfig][0]);
GrBytesPerPixel(fDesc.fConfig);
if (GrPixelConfigIsCompressed(fDesc.fConfig)) {
- // Figure out the width and height corresponding to the data...
-
- // Both of the available formats (ETC1 and LATC) have 4x4
- // blocks that compress down to 8 bytes.
- switch(fDesc.fConfig) {
- case kETC1_GrPixelConfig:
- case kLATC_GrPixelConfig:
- case kR11_EAC_GrPixelConfig:
- SkASSERT((fDesc.fWidth & 3) == 0);
- SkASSERT((fDesc.fHeight & 3) == 0);
- textureSize = (fDesc.fWidth >> 2) * (fDesc.fHeight >> 2) * 8;
- break;
-
- default:
- SkFAIL("Unknown compressed config");
- }
+ textureSize = GrCompressedFormatDataSize(fDesc.fConfig, fDesc.fWidth, fDesc.fHeight);
}
if (this->impl()->hasMipMaps()) {
fConfigTextureSupport[kR11_EAC_GrPixelConfig] = version >= GR_GL_VER(3, 0);
}
+ // Check for ASTC
+ fConfigTextureSupport[kASTC_12x12_GrPixelConfig] =
+ ctxInfo.hasExtension("GL_KHR_texture_compression_astc_hdr") ||
+ ctxInfo.hasExtension("GL_KHR_texture_compression_astc_ldr") ||
+ ctxInfo.hasExtension("GL_OES_texture_compression_astc");
+
// Check for floating point texture support
// NOTE: We disallow floating point textures on ES devices if linear
// filtering modes are not supported. This is for simplicity, but a more
case kR11_EAC_GrPixelConfig:
*internalFormat = GR_GL_COMPRESSED_R11;
break;
+
+ case kASTC_12x12_GrPixelConfig:
+ *internalFormat = GR_GL_COMPRESSED_RGBA_ASTC_12x12;
+ break;
+
case kRGBA_float_GrPixelConfig:
*internalFormat = GR_GL_RGBA32F;
*externalFormat = GR_GL_RGBA;
*externalType = GR_GL_FLOAT;
break;
+
default:
return false;
}