Merge "Fix unsafety in SkiaShader storage, and texture unit accounting" into mnc-dev
This commit is contained in:
@ -370,7 +370,11 @@ void SkiaShader::store(Caches& caches, const SkShader& shader, const Matrix4& mo
|
|||||||
if (tryStoreLayer(caches, shader, modelViewMatrix,
|
if (tryStoreLayer(caches, shader, modelViewMatrix,
|
||||||
textureUnit, description, &outData->layerData)) {
|
textureUnit, description, &outData->layerData)) {
|
||||||
outData->skiaShaderType = kLayer_SkiaShaderType;
|
outData->skiaShaderType = kLayer_SkiaShaderType;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unknown/unsupported type, so explicitly ignore shader
|
||||||
|
outData->skiaShaderType = kNone_SkiaShaderType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkiaShader::apply(Caches& caches, const SkiaShaderData& data) {
|
void SkiaShader::apply(Caches& caches, const SkiaShaderData& data) {
|
||||||
|
@ -22,7 +22,8 @@ namespace uirenderer {
|
|||||||
const GLenum kTextureUnits[] = {
|
const GLenum kTextureUnits[] = {
|
||||||
GL_TEXTURE0,
|
GL_TEXTURE0,
|
||||||
GL_TEXTURE1,
|
GL_TEXTURE1,
|
||||||
GL_TEXTURE2
|
GL_TEXTURE2,
|
||||||
|
GL_TEXTURE3
|
||||||
};
|
};
|
||||||
|
|
||||||
TextureState::TextureState()
|
TextureState::TextureState()
|
||||||
@ -33,10 +34,13 @@ TextureState::TextureState()
|
|||||||
GLint maxTextureUnits;
|
GLint maxTextureUnits;
|
||||||
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTextureUnits);
|
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTextureUnits);
|
||||||
LOG_ALWAYS_FATAL_IF(maxTextureUnits < kTextureUnitsCount,
|
LOG_ALWAYS_FATAL_IF(maxTextureUnits < kTextureUnitsCount,
|
||||||
"At least %d texture units are required!", kTextureUnitsCount);
|
"At least %d texture units are required!", kTextureUnitsCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureState::activateTexture(GLuint textureUnit) {
|
void TextureState::activateTexture(GLuint textureUnit) {
|
||||||
|
LOG_ALWAYS_FATAL_IF(textureUnit >= kTextureUnitsCount,
|
||||||
|
"Tried to use texture unit index %d, only %d exist",
|
||||||
|
textureUnit, kTextureUnitsCount);
|
||||||
if (mTextureUnit != textureUnit) {
|
if (mTextureUnit != textureUnit) {
|
||||||
glActiveTexture(kTextureUnits[textureUnit]);
|
glActiveTexture(kTextureUnits[textureUnit]);
|
||||||
mTextureUnit = textureUnit;
|
mTextureUnit = textureUnit;
|
||||||
|
@ -73,7 +73,7 @@ public:
|
|||||||
void unbindTexture(GLuint texture);
|
void unbindTexture(GLuint texture);
|
||||||
private:
|
private:
|
||||||
// total number of texture units available for use
|
// total number of texture units available for use
|
||||||
static const int kTextureUnitsCount = 3;
|
static const int kTextureUnitsCount = 4;
|
||||||
|
|
||||||
TextureState();
|
TextureState();
|
||||||
GLuint mTextureUnit;
|
GLuint mTextureUnit;
|
||||||
|
Reference in New Issue
Block a user