kRGBA_GrColorComponentFlags, // kRGBA_4444_GrPixelConfig
kRGBA_GrColorComponentFlags, // kRGBA_8888_GrPixelConfig
kRGBA_GrColorComponentFlags, // kBGRA_8888_GrPixelConfig
+ kRGB_GrColorComponentFlags, // kETC1_GrPixelConfig
+ kA_GrColorComponentFlag, // kLATC_GrPixelConfig
};
return kFlags[config];
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(SK_ARRAY_COUNT(kFlags) == kGrPixelConfigCnt);
}
* Premultiplied. Byte order is b,g,r,a.
*/
kBGRA_8888_GrPixelConfig,
+ /**
+ * ETC1 Compressed Data
+ */
+ kETC1_GrPixelConfig,
+ /**
+ * LATC/RGTC/3Dc/BC4 Compressed Data
+ */
+ kLATC_GrPixelConfig,
- kLast_GrPixelConfig = kBGRA_8888_GrPixelConfig
+ kLast_GrPixelConfig = kLATC_GrPixelConfig
};
static const int kGrPixelConfigCnt = kLast_GrPixelConfig + 1;
#error "SK_*32_SHIFT values must correspond to GL_BGRA or GL_RGBA format."
#endif
+// Returns true if the pixel config is a GPU-specific compressed format
+// representation.
+static inline bool GrPixelConfigIsCompressed(GrPixelConfig config) {
+ switch (config) {
+ case kETC1_GrPixelConfig:
+ case kLATC_GrPixelConfig:
+ return true;
+ default:
+ return false;
+ }
+}
+
// Returns true if the pixel config is 32 bits per pixel
static inline bool GrPixelConfigIs8888(GrPixelConfig config) {
switch (config) {
static inline bool GrPixelConfigIsOpaque(GrPixelConfig config) {
switch (config) {
+ case kETC1_GrPixelConfig:
case kRGB_565_GrPixelConfig:
return true;
default:
kALL_GrGLBackendState = 0xffff
};
-/**
- * The compressed texture formats that may be supported by the renderer.
- * Make sure to check for the required capabilities using
- * GrDrawTargetCaps::compressedTextureSupport
- */
-enum GrCompressedFormat {
- kETC1_GrCompressedFormat,
- kETC2_GrCompressedFormat,
- kDXT1_GrCompressedFormat,
-
- kLast_GrCompressedFormat = kDXT1_GrCompressedFormat
-};
-static const int kGrCompressedFormatCount = kLast_GrCompressedFormat + 1;
-
/**
* This value translates to reseting all the context state for any backend.
*/
SkASSERT(plotWidth * fNumPlotsX == textureWidth);
SkASSERT(plotHeight * fNumPlotsY == textureHeight);
+ // We currently do not support compressed atlases...
+ SkASSERT(!GrPixelConfigIsCompressed(config));
+
// set up allocated plots
size_t bpp = GrBytesPerPixel(fPixelConfig);
fPlotArray = SkNEW_ARRAY(GrPlot, (fNumPlotsX*fNumPlotsY));
// no longer need to clamp at min RT size.
rtDesc.fWidth = GrNextPow2(desc.fWidth);
rtDesc.fHeight = GrNextPow2(desc.fHeight);
+
+ // We shouldn't be resizing a compressed texture.
+ SkASSERT(!GrPixelConfigIsCompressed(desc.fConfig));
+
size_t bpp = GrBytesPerPixel(desc.fConfig);
SkAutoSMalloc<128*128*4> stretchedPixels(bpp * rtDesc.fWidth * rtDesc.fHeight);
stretch_image(stretchedPixels.get(), rtDesc.fWidth, rtDesc.fHeight,
bool GrContext::supportsIndex8PixelConfig(const GrTextureParams* params,
int width, int height) const {
const GrDrawTargetCaps* caps = fGpu->caps();
- if (!caps->eightBitPaletteSupport()) {
+ if (!caps->isConfigTexturable(kIndex_8_GrPixelConfig)) {
return false;
}
///////////////////////////////////////////////////////////////////////////////
void GrDrawTargetCaps::reset() {
- f8BitPaletteSupport = false;
fMipMapSupport = false;
fNPOTTextureTileSupport = false;
fTwoSidedStencilSupport = false;
fMaxSampleCount = 0;
memset(fConfigRenderSupport, 0, sizeof(fConfigRenderSupport));
- memset(fCompressedFormatSupport, 0, sizeof(fCompressedFormatSupport));
+ memset(fConfigTextureSupport, 0, sizeof(fConfigTextureSupport));
}
GrDrawTargetCaps& GrDrawTargetCaps::operator=(const GrDrawTargetCaps& other) {
- f8BitPaletteSupport = other.f8BitPaletteSupport;
fMipMapSupport = other.fMipMapSupport;
fNPOTTextureTileSupport = other.fNPOTTextureTileSupport;
fTwoSidedStencilSupport = other.fTwoSidedStencilSupport;
fMaxSampleCount = other.fMaxSampleCount;
memcpy(fConfigRenderSupport, other.fConfigRenderSupport, sizeof(fConfigRenderSupport));
- memcpy(fCompressedFormatSupport, other.fCompressedFormatSupport,
- sizeof(fCompressedFormatSupport));
+ memcpy(fConfigTextureSupport, other.fConfigTextureSupport, sizeof(fConfigTextureSupport));
return *this;
}
SkString GrDrawTargetCaps::dump() const {
SkString r;
static const char* gNY[] = {"NO", "YES"};
- r.appendf("8 Bit Palette Support : %s\n", gNY[f8BitPaletteSupport]);
r.appendf("MIP Map Support : %s\n", gNY[fMipMapSupport]);
r.appendf("NPOT Texture Tile Support : %s\n", gNY[fNPOTTextureTileSupport]);
r.appendf("Two Sided Stencil Support : %s\n", gNY[fTwoSidedStencilSupport]);
"RGBA444", // kRGBA_4444_GrPixelConfig,
"RGBA8888", // kRGBA_8888_GrPixelConfig,
"BGRA8888", // kBGRA_8888_GrPixelConfig,
+ "ETC1", // kETC1_GrPixelConfig,
+ "LATC", // kLATC_GrPixelConfig,
};
GR_STATIC_ASSERT(0 == kUnknown_GrPixelConfig);
GR_STATIC_ASSERT(1 == kAlpha_8_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(SK_ARRAY_COUNT(kConfigNames) == kGrPixelConfigCnt);
SkASSERT(!fConfigRenderSupport[kUnknown_GrPixelConfig][0]);
SkASSERT(!fConfigRenderSupport[kUnknown_GrPixelConfig][1]);
- for (size_t i = 0; i < SK_ARRAY_COUNT(kConfigNames); ++i) {
- if (i != kUnknown_GrPixelConfig) {
- r.appendf("%s is renderable: %s, with MSAA: %s\n",
- kConfigNames[i],
- gNY[fConfigRenderSupport[i][0]],
- gNY[fConfigRenderSupport[i][1]]);
- }
+
+ for (size_t i = 1; i < SK_ARRAY_COUNT(kConfigNames); ++i) {
+ r.appendf("%s is renderable: %s, with MSAA: %s\n",
+ kConfigNames[i],
+ gNY[fConfigRenderSupport[i][0]],
+ gNY[fConfigRenderSupport[i][1]]);
}
- static const char* kCompressedFormatNames[] = {
- "ETC1", // kETC1_GrCompressedFormat
- "ETC2", // kETC2_GrCompressedFormat,
- "DXT1", // kDXT1_GrCompressedFormat,
- };
- GR_STATIC_ASSERT(0 == kETC1_GrCompressedFormat);
- GR_STATIC_ASSERT(1 == kETC2_GrCompressedFormat);
- GR_STATIC_ASSERT(2 == kDXT1_GrCompressedFormat);
- GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCompressedFormatNames) == kGrCompressedFormatCount);
-
- for (size_t i = 0; i < SK_ARRAY_COUNT(kCompressedFormatNames); ++i) {
- r.appendf("%s Compressed Texture Support: %s\n",
- kCompressedFormatNames[i],
- gNY[fCompressedFormatSupport[i]]);
+ SkASSERT(!fConfigTextureSupport[kUnknown_GrPixelConfig]);
+
+ for (size_t i = 1; i < SK_ARRAY_COUNT(kConfigNames); ++i) {
+ r.appendf("%s is uploadable to a texture: %s\n",
+ kConfigNames[i],
+ gNY[fConfigTextureSupport[i]]);
}
return r;
virtual void reset();
virtual SkString dump() const;
- bool eightBitPaletteSupport() const { return f8BitPaletteSupport; }
bool npotTextureTileSupport() const { return fNPOTTextureTileSupport; }
/** To avoid as-yet-unnecessary complexity we don't allow any partial support of MIP Maps (e.g.
only for POT textures) */
return fConfigRenderSupport[config][withMSAA];
}
- bool compressedTextureSupport(GrCompressedFormat format) const {
- SkASSERT(kGrCompressedFormatCount > format);
- return fCompressedFormatSupport[format];
+ bool isConfigTexturable(GrPixelConfig config) const {
+ SkASSERT(kGrPixelConfigCnt > config);
+ return fConfigTextureSupport[config];
}
protected:
- bool f8BitPaletteSupport : 1;
bool fNPOTTextureTileSupport : 1;
bool fMipMapSupport : 1;
bool fTwoSidedStencilSupport : 1;
// The first entry for each config is without msaa and the second is with.
bool fConfigRenderSupport[kGrPixelConfigCnt][2];
-
- bool fCompressedFormatSupport[kGrCompressedFormatCount];
+ bool fConfigTextureSupport[kGrPixelConfigCnt];
typedef SkRefCnt INHERITED;
};
size_t textureSize = (size_t) fDesc.fWidth *
fDesc.fHeight *
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:
+ SkASSERT((fDesc.fWidth & 3) == 0);
+ SkASSERT((fDesc.fHeight & 3) == 0);
+ textureSize = (fDesc.fWidth >> 2) * (fDesc.fHeight >> 2) * 8;
+ break;
+
+ default:
+ SkFAIL("Unknown compressed config");
+ }
+ }
+
if (this->impl()->hasMipMaps()) {
// We don't have to worry about the mipmaps being a different size than
// we'd expect because we never change fDesc.fWidth/fHeight.
fMaxFragmentTextureUnits = 0;
fMaxFixedFunctionTextureCoords = 0;
fRGBA8RenderbufferSupport = false;
- fBGRAFormatSupport = false;
fBGRAIsInternalFormat = false;
fTextureSwizzleSupport = false;
fUnpackRowLengthSupport = false;
fInvalidateFBType = caps.fInvalidateFBType;
fMapBufferType = caps.fMapBufferType;
fRGBA8RenderbufferSupport = caps.fRGBA8RenderbufferSupport;
- fBGRAFormatSupport = caps.fBGRAFormatSupport;
fBGRAIsInternalFormat = caps.fBGRAIsInternalFormat;
fTextureSwizzleSupport = caps.fTextureSwizzleSupport;
fUnpackRowLengthSupport = caps.fUnpackRowLengthSupport;
ctxInfo.hasExtension("GL_ARM_rgba8");
}
- if (kGL_GrGLStandard == standard) {
- fBGRAFormatSupport = version >= GR_GL_VER(1,2) ||
- ctxInfo.hasExtension("GL_EXT_bgra");
- } else {
- if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) {
- fBGRAFormatSupport = true;
- } else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) {
- fBGRAFormatSupport = true;
- fBGRAIsInternalFormat = true;
- }
- SkASSERT(fBGRAFormatSupport ||
- kSkia8888_GrPixelConfig != kBGRA_8888_GrPixelConfig);
- }
-
if (kGL_GrGLStandard == standard) {
fTextureSwizzleSupport = version >= GR_GL_VER(3,3) ||
ctxInfo.hasExtension("GL_ARB_texture_swizzle");
/**************************************************************************
* GrDrawTargetCaps fields
**************************************************************************/
- GrGLint numFormats;
- GR_GL_GetIntegerv(gli, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats);
- if (numFormats) {
- SkAutoSTMalloc<10, GrGLint> formats(numFormats);
- GR_GL_GetIntegerv(gli, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats);
- for (int i = 0; i < numFormats; ++i) {
- if (formats[i] == GR_GL_PALETTE8_RGBA8) {
- f8BitPaletteSupport = true;
- break;
- }
- }
- }
-
if (kGL_GrGLStandard == standard) {
// we could also look for GL_ATI_separate_stencil extension or
// GL_EXT_stencil_two_side but they use different function signatures
GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES, &fMaxSampleCount);
}
+ this->initConfigTexturableTable(ctxInfo, gli);
this->initConfigRenderableTable(ctxInfo);
- this->initCompressedTextureSupport(ctxInfo);
-
return true;
}
// Same as ES 2.0 except R8 and RGBA8 are supported without extensions (the functions called
// below already account for this).
+ GrGLStandard standard = ctxInfo.standard();
+
enum {
kNo_MSAA = 0,
kYes_MSAA = 1,
};
- if (kGL_GrGLStandard == ctxInfo.standard()) {
+ if (kGL_GrGLStandard == standard) {
// Post 3.0 we will get R8
// Prior to 3.0 we will get ALPHA8 (with GL_ARB_framebuffer_object)
if (ctxInfo.version() >= GR_GL_VER(3,0) ||
fConfigRenderSupport[kAlpha_8_GrPixelConfig][kYes_MSAA] = fTextureRedSupport;
}
- if (kGL_GrGLStandard != ctxInfo.standard()) {
+ if (kGL_GrGLStandard != standard) {
// only available in ES
fConfigRenderSupport[kRGB_565_GrPixelConfig][kNo_MSAA] = true;
fConfigRenderSupport[kRGB_565_GrPixelConfig][kYes_MSAA] = true;
fConfigRenderSupport[kRGBA_8888_GrPixelConfig][kYes_MSAA] = true;
}
- if (this->fBGRAFormatSupport) {
+ if (this->isConfigTexturable(kBGRA_8888_GrPixelConfig)) {
fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kNo_MSAA] = true;
// The GL_EXT_texture_format_BGRA8888 extension does not add BGRA to the list of
// configs that are color-renderable and can be passed to glRenderBufferStorageMultisample.
}
}
-void GrGLCaps::initCompressedTextureSupport(const GrGLContextInfo &ctxInfo) {
+void GrGLCaps::initConfigTexturableTable(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
GrGLStandard standard = ctxInfo.standard();
GrGLVersion version = ctxInfo.version();
+ // Base texture support
+ fConfigTextureSupport[kAlpha_8_GrPixelConfig] = true;
+ fConfigTextureSupport[kRGB_565_GrPixelConfig] = true;
+ fConfigTextureSupport[kRGBA_4444_GrPixelConfig] = true;
+ fConfigTextureSupport[kRGBA_8888_GrPixelConfig] = true;
+
+ // Check for 8-bit palette..
+ GrGLint numFormats;
+ GR_GL_GetIntegerv(gli, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats);
+ if (numFormats) {
+ SkAutoSTMalloc<10, GrGLint> formats(numFormats);
+ GR_GL_GetIntegerv(gli, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats);
+ for (int i = 0; i < numFormats; ++i) {
+ if (GR_GL_PALETTE8_RGBA8 == formats[i]) {
+ fConfigTextureSupport[kIndex_8_GrPixelConfig] = true;
+ break;
+ }
+ }
+ }
+
+ // Check for BGRA
+ if (kGL_GrGLStandard == standard) {
+ fConfigTextureSupport[kBGRA_8888_GrPixelConfig] =
+ version >= GR_GL_VER(1,2) || ctxInfo.hasExtension("GL_EXT_bgra");
+ } else {
+ if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) {
+ fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true;
+ } else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) {
+ fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true;
+ fBGRAIsInternalFormat = true;
+ }
+ SkASSERT(fConfigTextureSupport[kBGRA_8888_GrPixelConfig] ||
+ kSkia8888_GrPixelConfig != kBGRA_8888_GrPixelConfig);
+ }
+
+ // Compressed texture support
+
// glCompressedTexImage2D is available on all OpenGL ES devices...
// however, it is only available on standard OpenGL after version 1.3
- if (kGL_GrGLStandard == standard && version < GR_GL_VER(1, 3)) {
- return;
- }
+ bool hasCompressTex2D = (kGL_GrGLStandard != standard || version >= GR_GL_VER(1, 3));
// Check for ETC1
bool hasETC1 = false;
// First check version for support
if (kGL_GrGLStandard == standard) {
- hasETC1 =
- version >= GR_GL_VER(4, 3) ||
- ctxInfo.hasExtension("GL_ARB_ES3_compatibility");
+ hasETC1 = hasCompressTex2D &&
+ (version >= GR_GL_VER(4, 3) ||
+ ctxInfo.hasExtension("GL_ARB_ES3_compatibility"));
} else {
- hasETC1 =
- version >= GR_GL_VER(3, 0) ||
- ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") ||
- // ETC2 is a superset of ETC1, so we can just check for that, too.
- (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") &&
- ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture"));
+ hasETC1 = hasCompressTex2D &&
+ (version >= GR_GL_VER(3, 0) ||
+ ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") ||
+ // ETC2 is a superset of ETC1, so we can just check for that, too.
+ (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") &&
+ ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture")));
+ }
+ fConfigTextureSupport[kETC1_GrPixelConfig] = hasETC1;
+
+ // Check for LATC under its various forms
+ LATCAlias alias = kLATC_LATCAlias;
+ bool hasLATC = hasCompressTex2D &&
+ (ctxInfo.hasExtension("GL_EXT_texture_compression_latc") ||
+ ctxInfo.hasExtension("GL_NV_texture_compression_latc"));
+
+ // Check for RGTC
+ if (!hasLATC) {
+ // If we're using OpenGL 3.0 or later, then we have RGTC, an identical compression format.
+ if (kGL_GrGLStandard == standard) {
+ hasLATC = version >= GR_GL_VER(3, 0);
+ }
+
+ if (!hasLATC) {
+ hasLATC =
+ ctxInfo.hasExtension("GL_EXT_texture_compression_rgtc") ||
+ ctxInfo.hasExtension("GL_ARB_texture_compression_rgtc");
+ }
+
+ if (hasLATC) {
+ alias = kRGTC_LATCAlias;
+ }
+ }
+
+ // Check for 3DC
+ if (!hasLATC) {
+ hasLATC = ctxInfo.hasExtension("GL_AMD_compressed_3DC_texture");
+ if (hasLATC) {
+ alias = k3DC_LATCAlias;
+ }
}
- fCompressedFormatSupport[kETC1_GrCompressedFormat] = hasETC1;
- fCompressedFormatSupport[kETC2_GrCompressedFormat] = false;
- fCompressedFormatSupport[kDXT1_GrCompressedFormat] = false;
+ fConfigTextureSupport[kLATC_GrPixelConfig] = hasLATC;
+ fLATCAlias = alias;
}
bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf,
}
r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes);
r.appendf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ? "YES": "NO"));
- r.appendf("BGRA support: %s\n", (fBGRAFormatSupport ? "YES": "NO"));
r.appendf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES": "NO"));
r.appendf("Support texture swizzle: %s\n", (fTextureSwizzleSupport ? "YES": "NO"));
r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES": "NO"));
/// ES requires an extension to support RGBA8 in RenderBufferStorage
bool rgba8RenderbufferSupport() const { return fRGBA8RenderbufferSupport; }
- /// Is GL_BGRA supported
- bool bgraFormatSupport() const { return fBGRAFormatSupport; }
-
/**
* Depending on the ES extensions present the BGRA external format may
* correspond either a BGRA or RGBA internalFormat. On desktop GL it is
*/
virtual SkString dump() const SK_OVERRIDE;
+ /**
+ * LATC can appear under one of three possible names. In order to know
+ * which GL internal format to use, we need to keep track of which name
+ * we found LATC under. The default is LATC.
+ */
+ enum LATCAlias {
+ kLATC_LATCAlias,
+ kRGTC_LATCAlias,
+ k3DC_LATCAlias
+ };
+
+ LATCAlias latcAlias() const { return fLATCAlias; }
+
private:
/**
* Maintains a bit per GrPixelConfig. It is used to avoid redundantly
void initStencilFormats(const GrGLContextInfo&);
// This must be called after initFSAASupport().
void initConfigRenderableTable(const GrGLContextInfo&);
-
- void initCompressedTextureSupport(const GrGLContextInfo &);
+ void initConfigTexturableTable(const GrGLContextInfo&, const GrGLInterface*);
// tracks configs that have been verified to pass the FBO completeness when
// used as a color attachment
FBFetchType fFBFetchType;
InvalidateFBType fInvalidateFBType;
MapBufferType fMapBufferType;
+ LATCAlias fLATCAlias;
bool fRGBA8RenderbufferSupport : 1;
- bool fBGRAFormatSupport : 1;
bool fBGRAIsInternalFormat : 1;
bool fTextureSwizzleSupport : 1;
bool fUnpackRowLengthSupport : 1;
#define GR_GL_COMPRESSED_RGBA8_ETC2 0x9278
#define GR_GL_COMPRESSED_SRGB8_ALPHA8_ETC2 0x9279
+#define GR_GL_COMPRESSED_LUMINANCE_LATC1 0x8C70
+#define GR_GL_COMPRESSED_SIGNED_LUMINANCE_LATC1 0x8C71
+#define GR_GL_COMPRESSED_LUMINANCE_ALPHA_LATC2 0x8C72
+#define GR_GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2 0x8C73
+
+#define GR_GL_COMPRESSED_RED_RGTC1 0x8DBB
+#define GR_GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC
+#define GR_GL_COMPRESSED_RED_GREEN_RGTC2 0x8DBD
+#define GR_GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2 0x8DBE
+
+#define GR_GL_COMPRESSED_3DC_X 0x87F9
+#define GR_GL_COMPRESSED_3DC_XY 0x87FA
+
#define GR_GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C
#define GR_GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D
#define GR_GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E
}
bool GrGpuGL::canWriteTexturePixels(const GrTexture* texture, GrPixelConfig srcConfig) const {
- if (kIndex_8_GrPixelConfig == srcConfig || kIndex_8_GrPixelConfig == texture->config()) {
+ if (kIndex_8_GrPixelConfig == srcConfig || kIndex_8_GrPixelConfig == texture->config() ||
+ GrPixelConfigIsCompressed(srcConfig) || GrPixelConfigIsCompressed(texture->config())) {
return false;
}
if (srcConfig != texture->config() && kGLES_GrGLStandard == this->glStandard()) {
// texture. It depends upon which extension added BGRA. The Apple extension allows it
// (BGRA's internal format is RGBA) while the EXT extension does not (BGRA is its own
// internal format).
- if (this->glCaps().bgraFormatSupport() &&
+ if (this->glCaps().isConfigTexturable(kBGRA_8888_GrPixelConfig) &&
!this->glCaps().bgraIsInternalFormat() &&
kBGRA_8888_GrPixelConfig == srcConfig &&
kRGBA_8888_GrPixelConfig == texture->config()) {
size_t rowBytes) {
SkASSERT(NULL != data || isNewTexture);
+ // If we're uploading compressed data then we should be using uploadCompressedTexData
+ SkASSERT(!GrPixelConfigIsCompressed(dataConfig));
+
size_t bpp = GrBytesPerPixel(dataConfig);
if (!adjust_pixel_ops_params(desc.fWidth, desc.fHeight, bpp, &left, &top,
&width, &height, &data, &rowBytes)) {
// texture storage.
bool useTexStorage = false &&
isNewTexture &&
- desc.fConfig != kIndex_8_GrPixelConfig &&
+ kIndex_8_GrPixelConfig != desc.fConfig &&
this->glCaps().texStorageSupport();
if (useTexStorage && kGL_GrGLStandard == this->glStandard()) {
GrPixelConfig config,
void* buffer,
size_t rowBytes) {
- GrGLenum format;
- GrGLenum type;
+ // We cannot read pixels into a compressed buffer
+ if (GrPixelConfigIsCompressed(config)) {
+ return false;
+ }
+
+ GrGLenum format = 0;
+ GrGLenum type = 0;
bool flipY = kBottomLeft_GrSurfaceOrigin == target->origin();
if (!this->configToGLFormats(config, false, NULL, &format, &type)) {
return false;
newTexParams.fMinFilter = glMinFilterModes[filterMode];
newTexParams.fMagFilter = glMagFilterModes[filterMode];
- if (GrTextureParams::kMipMap_FilterMode == filterMode && texture->mipMapsAreDirty()) {
-// GL_CALL(Hint(GR_GL_GENERATE_MIPMAP_HINT,GR_GL_NICEST));
+ if (GrTextureParams::kMipMap_FilterMode == filterMode &&
+ texture->mipMapsAreDirty() && !GrPixelConfigIsCompressed(texture->config())) {
GL_CALL(GenerateMipmap(GR_GL_TEXTURE_2D));
texture->dirtyMipMaps(false);
}
externalType = &dontCare;
}
+ if(!this->glCaps().isConfigTexturable(config)) {
+ return false;
+ }
+
switch (config) {
case kRGBA_8888_GrPixelConfig:
*internalFormat = GR_GL_RGBA;
*externalType = GR_GL_UNSIGNED_BYTE;
break;
case kBGRA_8888_GrPixelConfig:
- if (!this->glCaps().bgraFormatSupport()) {
- return false;
- }
if (this->glCaps().bgraIsInternalFormat()) {
if (getSizedInternalFormat) {
*internalFormat = GR_GL_BGRA8;
*externalType = GR_GL_UNSIGNED_SHORT_4_4_4_4;
break;
case kIndex_8_GrPixelConfig:
- if (this->caps()->eightBitPaletteSupport()) {
- // glCompressedTexImage doesn't take external params
- *externalFormat = GR_GL_PALETTE8_RGBA8;
- // no sized/unsized internal format distinction here
- *internalFormat = GR_GL_PALETTE8_RGBA8;
- // unused with CompressedTexImage
- *externalType = GR_GL_UNSIGNED_BYTE;
- } else {
- return false;
- }
+ // glCompressedTexImage doesn't take external params
+ *externalFormat = GR_GL_PALETTE8_RGBA8;
+ // no sized/unsized internal format distinction here
+ *internalFormat = GR_GL_PALETTE8_RGBA8;
+ // unused with CompressedTexImage
+ *externalType = GR_GL_UNSIGNED_BYTE;
break;
case kAlpha_8_GrPixelConfig:
if (this->glCaps().textureRedSupport()) {
*externalType = GR_GL_UNSIGNED_BYTE;
}
break;
+ case kETC1_GrPixelConfig:
+ *internalFormat = GR_GL_COMPRESSED_RGB8_ETC1;
+ break;
+ case kLATC_GrPixelConfig:
+ switch(this->glCaps().latcAlias()) {
+ case GrGLCaps::kLATC_LATCAlias:
+ *internalFormat = GR_GL_COMPRESSED_LUMINANCE_LATC1;
+ break;
+ case GrGLCaps::kRGTC_LATCAlias:
+ *internalFormat = GR_GL_COMPRESSED_RED_RGTC1;
+ break;
+ case GrGLCaps::k3DC_LATCAlias:
+ *internalFormat = GR_GL_COMPRESSED_3DC_X;
+ break;
+ }
+ break;
default:
return false;
}
if (gpu->glCaps().isConfigRenderable(src->config(), src->desc().fSampleCnt > 0) &&
NULL != dst->asTexture() &&
dst->origin() == src->origin() &&
- kIndex_8_GrPixelConfig != src->config()) {
+ kIndex_8_GrPixelConfig != src->config() &&
+ !GrPixelConfigIsCompressed(src->config())) {
if (NULL != wouldNeedTempFBO) {
*wouldNeedTempFBO = NULL == src->asRenderTarget();
}