Commit 410f515e authored by tobiasjs's avatar tobiasjs Committed by Commit bot

Avoid planar YUV resources when one component EGL images are not supported

Some EGL drivers do not support binding one component textures to an
EGL image. One component textures are used for YUV video frames, so
to support those drivers in WebView, we need to do YUV to RGB
conversion in software, and then upload an RGB texture instead of a
set of 3 Y,U,V textures.

BUG=579060, 632461
CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_precise_blink_rel

Review-Url: https://codereview.chromium.org/2242453002
Cr-Commit-Position: refs/heads/master@{#418819}
parent e4795a72
......@@ -448,10 +448,15 @@ ResourceProvider::ResourceProvider(
use_texture_format_bgra_ = caps.texture_format_bgra8888;
use_texture_usage_hint_ = caps.texture_usage;
use_compressed_texture_etc1_ = caps.texture_format_etc1;
yuv_resource_format_ = caps.texture_rg ? RED_8 : LUMINANCE_8;
yuv_highbit_resource_format_ = yuv_resource_format_;
if (caps.texture_half_float_linear)
yuv_highbit_resource_format_ = LUMINANCE_F16;
if (caps.disable_one_component_textures) {
yuv_resource_format_ = yuv_highbit_resource_format_ = RGBA_8888;
} else {
yuv_resource_format_ = caps.texture_rg ? RED_8 : LUMINANCE_8;
yuv_highbit_resource_format_ =
caps.texture_half_float_linear ? LUMINANCE_F16 : yuv_resource_format_;
}
use_sync_query_ = caps.sync_query;
GLES2Interface* gl = ContextGL();
......@@ -819,6 +824,16 @@ GLenum ResourceProvider::GetResourceTextureTarget(ResourceId id) {
return GetResource(id)->target;
}
bool ResourceProvider::IsImmutable(ResourceId id) {
if (IsGpuResourceType(default_resource_type_)) {
return GetTextureHint(id) == TEXTURE_HINT_IMMUTABLE;
} else {
// Software resources are immutable; they cannot change format or be
// resized.
return true;
}
}
ResourceProvider::TextureHint ResourceProvider::GetTextureHint(ResourceId id) {
return GetResource(id)->hint;
}
......
......@@ -131,6 +131,7 @@ class CC_EXPORT ResourceProvider
ResourceType default_resource_type() const { return default_resource_type_; }
ResourceType GetResourceType(ResourceId id);
GLenum GetResourceTextureTarget(ResourceId id);
bool IsImmutable(ResourceId id);
TextureHint GetTextureHint(ResourceId id);
// Creates a resource of the default resource type.
......
This diff is collapsed.
......@@ -136,6 +136,23 @@ class CC_EXPORT VideoResourceUpdater
// This needs to be a container where iterators can be erased without
// invalidating other iterators.
typedef std::list<PlaneResource> ResourceList;
// Obtain a resource of the right format by either recycling an
// unreferenced but appropriately formatted resource, or by
// allocating a new resource.
// Additionally, if the |unique_id| and |plane_index| match, then
// it is assumed that the resource has the right data already and will only be
// used for reading, and so is returned even if it is still referenced.
// Passing -1 for |plane_index| avoids returning referenced
// resources.
ResourceList::iterator RecycleOrAllocateResource(
const gfx::Size& resource_size,
ResourceFormat resource_format,
const gfx::ColorSpace& color_space,
bool software_resource,
bool immutable_hint,
int unique_id,
int plane_index);
ResourceList::iterator AllocateResource(const gfx::Size& plane_size,
ResourceFormat format,
const gfx::ColorSpace& color_space,
......
......@@ -49,9 +49,6 @@
#if defined(OS_WIN)
#include "base/win/windows_version.h"
#endif // OS_WIN
#if defined(OS_ANDROID)
#include "media/base/media_switches.h"
#endif
namespace content {
......@@ -745,13 +742,6 @@ void GpuDataManagerImplPrivate::AppendGpuCommandLine(
}
}
#if defined(OS_ANDROID)
if (command_line->HasSwitch(switches::kEnableThreadedTextureMailboxes) &&
IsDriverBugWorkaroundActive(gpu::AVDA_NO_EGLIMAGE_FOR_LUMINANCE_TEX)) {
command_line->AppendSwitch(switches::kDisableUnifiedMediaPipeline);
}
#endif
#if defined(OS_WIN)
if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VPX_DECODE) &&
gpu_preferences) {
......
......@@ -85,6 +85,7 @@ Capabilities::Capabilities()
surfaceless(false),
flips_vertically(false),
msaa_is_slow(false),
disable_one_component_textures(false),
disable_multisampling_color_mask_usage(false),
disable_webgl_rgb_multisampling_usage(false),
chromium_image_rgb_emulation(false),
......
......@@ -145,6 +145,7 @@ struct GPU_EXPORT Capabilities {
bool surfaceless;
bool flips_vertically;
bool msaa_is_slow;
bool disable_one_component_textures;
bool disable_multisampling_color_mask_usage;
bool disable_webgl_rgb_multisampling_usage;
......
......@@ -3548,6 +3548,11 @@ Capabilities GLES2DecoderImpl::GetCapabilities() {
feature_info_->feature_flags().oes_compressed_etc1_rgb8_texture;
caps.texture_format_etc1_npot =
caps.texture_format_etc1 && !workarounds().etc1_power_of_two_only;
// Whether or not a texture will be bound to an EGLImage is
// dependent on whether we are using the sync mailbox manager.
caps.disable_one_component_textures =
mailbox_manager()->UsesSync() &&
workarounds().avoid_one_component_egl_images;
caps.texture_rectangle = feature_info_->feature_flags().arb_texture_rectangle;
caps.texture_usage = feature_info_->feature_flags().angle_texture_usage;
caps.texture_storage = feature_info_->feature_flags().ext_texture_storage;
......
......@@ -1902,15 +1902,15 @@ LONG_STRING_CONST(
},
{
"id": 180,
"cr_bugs": [632461],
"description": "eglCreateImageKHR fails for L8 textures on PowerVR",
"cr_bugs": [579060,632461],
"description": "eglCreateImageKHR fails for one component textures on PowerVR",
"os": {
"type": "android"
},
"gl_vendor": "Imagination.*",
"gl_renderer": "PowerVR SGX.*",
"gl_renderer": "PowerVR .*",
"features": [
"avda_no_eglimage_for_luminance_tex"
"avoid_one_component_egl_images"
]
},
{
......
......@@ -15,10 +15,10 @@
#define GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP) \
GPU_OP(AVDA_DONT_COPY_PICTURES, \
avda_dont_copy_pictures) \
GPU_OP(AVDA_NO_EGLIMAGE_FOR_LUMINANCE_TEX, \
avda_no_eglimage_for_luminance_tex) \
GPU_OP(AVOID_EGL_IMAGE_TARGET_TEXTURE_REUSE, \
avoid_egl_image_target_texture_reuse) \
GPU_OP(AVOID_ONE_COMPONENT_EGL_IMAGES, \
avoid_one_component_egl_images) \
GPU_OP(BROKEN_EGL_IMAGE_REF_COUNTING, \
broken_egl_image_ref_counting) \
GPU_OP(CLEAR_ALPHA_IN_READPIXELS, \
......
......@@ -121,6 +121,7 @@ IPC_STRUCT_TRAITS_BEGIN(gpu::Capabilities)
IPC_STRUCT_TRAITS_MEMBER(disable_multisampling_color_mask_usage)
IPC_STRUCT_TRAITS_MEMBER(disable_webgl_rgb_multisampling_usage)
IPC_STRUCT_TRAITS_MEMBER(msaa_is_slow)
IPC_STRUCT_TRAITS_MEMBER(disable_one_component_textures)
IPC_STRUCT_TRAITS_MEMBER(chromium_image_rgb_emulation)
IPC_STRUCT_TRAITS_MEMBER(emulate_rgb_buffer_with_rgba)
......
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