Commit 47176547 authored by Geoff Lang's avatar Geoff Lang Committed by Commit Bot

Make sure TextureManager is non-null before querying TextureRefs

GpuVideoDecodeAccelerator already handles the texture manager returning
null TextureRefs to support the passthrough command decoder. Now that
we skip allocating the TextureManager entirely, also protect against it
being null.

BUG=1059068

Change-Id: I2d1d2a3fbf8166002379724ab97eca5082621374
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2140674Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Reviewed-by: default avatarFrank Liberato <liberato@chromium.org>
Commit-Queue: Frank Liberato <liberato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757445}
parent f3f0c811
......@@ -466,42 +466,45 @@ void GpuVideoDecodeAccelerator::OnAssignPictureBuffers(
return;
}
gpu::gles2::TextureRef* texture_ref =
texture_manager->GetTexture(buffer_texture_ids[j]);
if (texture_ref) {
gpu::gles2::Texture* info = texture_ref->texture();
if (texture_target_ == GL_TEXTURE_EXTERNAL_OES ||
texture_target_ == GL_TEXTURE_RECTANGLE_ARB) {
// These textures have their dimensions defined by the underlying
// storage.
// Use |texture_dimensions_| for this size.
texture_manager->SetLevelInfo(texture_ref, texture_target_, 0,
GL_RGBA, texture_dimensions_.width(),
texture_dimensions_.height(), 1, 0,
GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect());
} else {
// For other targets, texture dimensions should already be defined.
GLsizei width = 0, height = 0;
info->GetLevelSize(texture_target_, 0, &width, &height, nullptr);
if (width != texture_dimensions_.width() ||
height != texture_dimensions_.height()) {
DLOG(ERROR) << "Size mismatch for texture id "
<< buffer_texture_ids[j];
NotifyError(VideoDecodeAccelerator::INVALID_ARGUMENT);
return;
}
// TODO(dshwang): after moving to D3D11, remove this.
// https://crbug.com/438691
GLenum format = video_decode_accelerator_->GetSurfaceInternalFormat();
if (format != GL_RGBA) {
DCHECK(format == GL_BGRA_EXT);
texture_manager->SetLevelInfo(texture_ref, texture_target_, 0,
format, width, height, 1, 0, format,
GL_UNSIGNED_BYTE, gfx::Rect());
if (texture_manager) {
gpu::gles2::TextureRef* texture_ref =
texture_manager->GetTexture(buffer_texture_ids[j]);
if (texture_ref) {
gpu::gles2::Texture* info = texture_ref->texture();
if (texture_target_ == GL_TEXTURE_EXTERNAL_OES ||
texture_target_ == GL_TEXTURE_RECTANGLE_ARB) {
// These textures have their dimensions defined by the underlying
// storage.
// Use |texture_dimensions_| for this size.
texture_manager->SetLevelInfo(
texture_ref, texture_target_, 0, GL_RGBA,
texture_dimensions_.width(), texture_dimensions_.height(), 1, 0,
GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect());
} else {
// For other targets, texture dimensions should already be defined.
GLsizei width = 0, height = 0;
info->GetLevelSize(texture_target_, 0, &width, &height, nullptr);
if (width != texture_dimensions_.width() ||
height != texture_dimensions_.height()) {
DLOG(ERROR) << "Size mismatch for texture id "
<< buffer_texture_ids[j];
NotifyError(VideoDecodeAccelerator::INVALID_ARGUMENT);
return;
}
// TODO(dshwang): after moving to D3D11, remove this.
// https://crbug.com/438691
GLenum format =
video_decode_accelerator_->GetSurfaceInternalFormat();
if (format != GL_RGBA) {
DCHECK(format == GL_BGRA_EXT);
texture_manager->SetLevelInfo(texture_ref, texture_target_, 0,
format, width, height, 1, 0, format,
GL_UNSIGNED_BYTE, gfx::Rect());
}
}
current_textures.push_back(texture_ref);
}
current_textures.push_back(texture_ref);
}
service_ids.push_back(texture_base->service_id());
}
......
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