| Index: gpu/command_buffer/service/gles2_cmd_srgb_converter.cc
|
| diff --git a/gpu/command_buffer/service/gles2_cmd_srgb_converter.cc b/gpu/command_buffer/service/gles2_cmd_srgb_converter.cc
|
| index 97201e637eee586e2447cf1876a874a21246bb63..bf22d0e40ec698f034b60600f7db59d5bd9c849b 100644
|
| --- a/gpu/command_buffer/service/gles2_cmd_srgb_converter.cc
|
| +++ b/gpu/command_buffer/service/gles2_cmd_srgb_converter.cc
|
| @@ -415,8 +415,13 @@ void SRGBConverter::GenerateMipmap(const gles2::GLES2Decoder* decoder,
|
| tex->GetLevelSize(target, base_level, &width, &height, &depth);
|
| tex->GetLevelType(target, base_level, &type, &internal_format);
|
| format = TextureManager::ExtractFormatFromStorageFormat(internal_format);
|
| - const GLint mipmap_levels =
|
| - TextureManager::ComputeMipMapCount(target, width, height, depth);
|
| + GLint mipmap_levels;
|
| + if (tex->IsImmutable()) {
|
| + mipmap_levels = tex->GetImmutableLevels();
|
| + } else {
|
| + mipmap_levels =
|
| + TextureManager::ComputeMipMapCount(target, width, height, depth);
|
| + }
|
|
|
| glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[1]);
|
| if (feature_info_->ext_color_buffer_float_available() &&
|
| @@ -458,8 +463,9 @@ void SRGBConverter::GenerateMipmap(const gles2::GLES2Decoder* decoder,
|
| glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[1]);
|
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
| GL_NEAREST_MIPMAP_NEAREST);
|
| - width >>= 1;
|
| - height >>= 1;
|
| +
|
| + width = (width == 1) ? 1 : width >> 1;
|
| + height = (height == 1) ? 1 : height >> 1;
|
|
|
| // TODO(yizhou): An optimization. Attach 1 level at a time, once for every
|
| // iteration of the loop.
|
| @@ -468,16 +474,18 @@ void SRGBConverter::GenerateMipmap(const gles2::GLES2Decoder* decoder,
|
| // copy mipmaps level by level from srgb_converter_textures_[1] to tex
|
| // generate mipmap for tex manually
|
| glBindTexture(GL_TEXTURE_2D, tex->service_id());
|
| - glTexImage2D(GL_TEXTURE_2D, level, internal_format, width, height, 0,
|
| - format, type, nullptr);
|
| + if (!tex->IsImmutable()) {
|
| + glTexImage2D(GL_TEXTURE_2D, level, internal_format, width, height, 0,
|
| + format, type, nullptr);
|
| + }
|
| glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
| GL_TEXTURE_2D, tex->service_id(), level);
|
|
|
| glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[1]);
|
| glViewport(0, 0, width, height);
|
| glDrawArrays(GL_TRIANGLES, 0, 6);
|
| - width >>= 1;
|
| - height >>= 1;
|
| + width = (width == 1) ? 1 : width >> 1;
|
| + height = (height == 1) ? 1 : height >> 1;
|
| }
|
|
|
| // Restore state
|
|
|