Commit 3d944a84 authored by kbr@chromium.org's avatar kbr@chromium.org

Added temporary #ifdefs to support incompatible ANGLE API upgrade.

BUG=174821

Review URL: https://codereview.chromium.org/12210057

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181964 0039d316-1c4b-4281-b951-d872f2087c98
parent b4dcf955
......@@ -74,10 +74,12 @@ namespace {
static const char kOESDerivativeExtension[] = "GL_OES_standard_derivatives";
#if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108
khronos_uint64_t CityHashForAngle(const char* name, unsigned int len) {
return static_cast<khronos_uint64_t>(
CityHash64(name, static_cast<size_t>(len)));
}
#endif
} // namespace
......@@ -2500,7 +2502,11 @@ bool GLES2DecoderImpl::InitializeShaderTranslator() {
ShShaderSpec shader_spec = force_webgl_glsl_validation_ ||
force_webgl_glsl_validation_ ? SH_WEBGL_SPEC : SH_GLES2_SPEC;
if (shader_spec == SH_WEBGL_SPEC && features().enable_shader_name_hashing)
#if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108
resources.HashFunction = &CityHashForAngle;
#else
resources.HashFunction = &CityHash64;
#endif
else
resources.HashFunction = NULL;
ShaderTranslatorInterface::GlslImplementationType implementation_type =
......
......@@ -27,9 +27,15 @@ bool InitializeShaderTranslator() {
return initialized;
}
#if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108
typedef int ANGLEGetInfoType;
#else
typedef size_t ANGLEGetInfoType;
#endif
void GetVariableInfo(ShHandle compiler, ShShaderInfo var_type,
ShaderTranslator::VariableMap* var_map) {
int name_len = 0, mapped_name_len = 0;
ANGLEGetInfoType name_len = 0, mapped_name_len = 0;
switch (var_type) {
case SH_ACTIVE_ATTRIBUTES:
ShGetInfo(compiler, SH_ACTIVE_ATTRIBUTE_MAX_LENGTH, &name_len);
......@@ -44,10 +50,10 @@ void GetVariableInfo(ShHandle compiler, ShShaderInfo var_type,
scoped_array<char> name(new char[name_len]);
scoped_array<char> mapped_name(new char[mapped_name_len]);
int num_vars = 0;
ANGLEGetInfoType num_vars = 0;
ShGetInfo(compiler, var_type, &num_vars);
for (int i = 0; i < num_vars; ++i) {
int len = 0;
for (ANGLEGetInfoType i = 0; i < num_vars; ++i) {
ANGLEGetInfoType len = 0;
int size = 0;
ShDataType type = SH_NONE;
......@@ -77,19 +83,19 @@ void GetVariableInfo(ShHandle compiler, ShShaderInfo var_type,
void GetNameHashingInfo(
ShHandle compiler, ShaderTranslator::NameMap* name_map) {
int hashed_names_count = 0;
ANGLEGetInfoType hashed_names_count = 0;
ShGetInfo(compiler, SH_HASHED_NAMES_COUNT, &hashed_names_count);
if (hashed_names_count == 0)
return;
int name_max_len = 0, hashed_name_max_len = 0;
ANGLEGetInfoType name_max_len = 0, hashed_name_max_len = 0;
ShGetInfo(compiler, SH_NAME_MAX_LENGTH, &name_max_len);
ShGetInfo(compiler, SH_HASHED_NAME_MAX_LENGTH, &hashed_name_max_len);
scoped_array<char> name(new char[name_max_len]);
scoped_array<char> hashed_name(new char[hashed_name_max_len]);
for (int i = 0; i < hashed_names_count; ++i) {
for (ANGLEGetInfoType i = 0; i < hashed_names_count; ++i) {
ShGetNameHashingEntry(compiler, i, name.get(), hashed_name.get());
(*name_map)[hashed_name.get()] = name.get();
}
......@@ -157,7 +163,7 @@ bool ShaderTranslator::Translate(const char* shader) {
if (ShCompile(compiler_, &shader, 1, compile_options)) {
success = true;
// Get translated shader.
int obj_code_len = 0;
ANGLEGetInfoType obj_code_len = 0;
ShGetInfo(compiler_, SH_OBJECT_CODE_LENGTH, &obj_code_len);
if (obj_code_len > 1) {
translated_shader_.reset(new char[obj_code_len]);
......@@ -171,7 +177,7 @@ bool ShaderTranslator::Translate(const char* shader) {
}
// Get info log.
int info_log_len = 0;
ANGLEGetInfoType info_log_len = 0;
ShGetInfo(compiler_, SH_INFO_LOG_LENGTH, &info_log_len);
if (info_log_len > 1) {
info_log_.reset(new char[info_log_len]);
......
......@@ -1797,7 +1797,11 @@ bool WebGraphicsContext3DInProcessImpl::AngleValidateShaderSource(
char* source = entry->source.get();
if (!ShCompile(compiler, &source, 1, SH_OBJECT_CODE)) {
#if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108
int logSize = 0;
#else
size_t logSize = 0;
#endif
ShGetInfo(compiler, SH_INFO_LOG_LENGTH, &logSize);
if (logSize > 1) {
entry->log.reset(new char[logSize]);
......@@ -1806,7 +1810,11 @@ bool WebGraphicsContext3DInProcessImpl::AngleValidateShaderSource(
return false;
}
#if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108
int length = 0;
#else
size_t length = 0;
#endif
ShGetInfo(compiler, SH_OBJECT_CODE_LENGTH, &length);
if (length > 1) {
entry->translated_source.reset(new char[length]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment