From 034ad53c4f45c36e1e912131daa4de7324d89a9b Mon Sep 17 00:00:00 2001 From: Christopher Cameron Date: Wed, 9 Sep 2015 12:31:23 -0700 Subject: [PATCH] Merge to M46 for BUG=510252 Add ycbcr_422 support in image factory. BUG=524582 TBR=sievers@chromium.org Review URL: https://codereview.chromium.org/1308643003 Cr-Commit-Position: refs/heads/master@{#345959} (cherry picked from commit 3055ce7afdf11650d499378cb62ede310dc16f94) media: Remove SkCanvasVideoRenderer cache invalidation. When VideoFrame carries one native texture, with a GL_TEXTURE_2D target, we assumed we could avoid caching the created SkImage, since we just used the texture directly for drawing. Unfortunately if we're drawing to a software canvas we need to read the pixels back from the texture, and that is expensive. Keeping the same SkImage allows Skia to cache the expensive operation. BUG=521531 Review URL: https://codereview.chromium.org/1320613003 Cr-Commit-Position: refs/heads/master@{#345799} (cherry picked from commit 771b5cf7667def96ba3de5cb4a4bf38cff12c3b4) BUG=510252 Review URL: https://codereview.chromium.org/1327513003 . Cr-Commit-Position: refs/branch-heads/2490@{#201} Cr-Branched-From: 7790a3535f2a81a03685eca31a32cf69ae0c114f-refs/heads/master@{#344925} --- gpu/command_buffer/service/image_factory.cc | 8 +++++--- media/blink/skcanvas_video_renderer.cc | 9 --------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/gpu/command_buffer/service/image_factory.cc b/gpu/command_buffer/service/image_factory.cc index 75e5d2218a967..d8c86b5a53945 100644 --- a/gpu/command_buffer/service/image_factory.cc +++ b/gpu/command_buffer/service/image_factory.cc @@ -39,6 +39,8 @@ gfx::BufferFormat ImageFactory::DefaultBufferFormatForImageFormat( return gfx::BufferFormat::ETC1; case GL_RGB_YUV_420_CHROMIUM: return gfx::BufferFormat::YUV_420; + case GL_RGB_YCBCR_422_CHROMIUM: + return gfx::BufferFormat::UYVY_422; default: NOTREACHED(); return gfx::BufferFormat::RGBA_8888; @@ -74,11 +76,10 @@ bool ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( case gfx::BufferFormat::R_8: case gfx::BufferFormat::RGBA_8888: case gfx::BufferFormat::YUV_420: + case gfx::BufferFormat::UYVY_422: return format == DefaultBufferFormatForImageFormat(internalformat); case gfx::BufferFormat::RGBA_4444: return internalformat == GL_RGBA; - case gfx::BufferFormat::UYVY_422: - return internalformat == GL_RGB; } NOTREACHED(); @@ -103,11 +104,12 @@ bool ImageFactory::IsGpuMemoryBufferFormatSupported( return capabilities.texture_format_etc1; case gfx::BufferFormat::R_8: return capabilities.texture_rg; + case gfx::BufferFormat::UYVY_422: + return capabilities.image_ycbcr_422; case gfx::BufferFormat::RGBA_4444: case gfx::BufferFormat::RGBA_8888: case gfx::BufferFormat::BGRX_8888: case gfx::BufferFormat::YUV_420: - case gfx::BufferFormat::UYVY_422: return true; } diff --git a/media/blink/skcanvas_video_renderer.cc b/media/blink/skcanvas_video_renderer.cc index 6aa863e89b1bc..edbb556e55927 100644 --- a/media/blink/skcanvas_video_renderer.cc +++ b/media/blink/skcanvas_video_renderer.cc @@ -127,12 +127,6 @@ skia::RefPtr NewSkImageFromVideoFrameYUVTextures( return skia::AdoptRef(img); } -bool ShouldCacheVideoFrameSkImage(const VideoFrame* video_frame) { - return !video_frame->HasTextures() || - media::VideoFrame::NumPlanes(video_frame->format()) != 1 || - video_frame->mailbox_holder(0).texture_target != GL_TEXTURE_2D; -} - // Creates a SkImage from a |video_frame| backed by native resources. // The SkImage will take ownership of the underlying resource. skia::RefPtr NewSkImageFromVideoFrameNative( @@ -388,9 +382,6 @@ void SkCanvasVideoRenderer::Paint(const scoped_refptr& video_frame, // Make sure to flush so we can remove the videoframe from the generator. canvas->flush(); - if (!ShouldCacheVideoFrameSkImage(video_frame.get())) - ResetCache(); - if (video_frame->HasTextures()) { DCHECK(gl); SyncPointClientImpl client(gl);