Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Merge to M46 for BUG=510252
Browse files Browse the repository at this point in the history
Add ycbcr_422 support in image factory.

BUG=524582
[email protected]

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

Cr-Commit-Position: refs/heads/master@{#345959}
(cherry picked from commit 3055ce7)

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 771b5cf)

BUG=510252

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

Cr-Commit-Position: refs/branch-heads/2490@{#201}
Cr-Branched-From: 7790a35-refs/heads/master@{#344925}
  • Loading branch information
ccameron-chromium committed Sep 9, 2015
1 parent 320e32b commit 034ad53
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
8 changes: 5 additions & 3 deletions gpu/command_buffer/service/image_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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;
}

Expand Down
9 changes: 0 additions & 9 deletions media/blink/skcanvas_video_renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,6 @@ skia::RefPtr<SkImage> 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<SkImage> NewSkImageFromVideoFrameNative(
Expand Down Expand Up @@ -388,9 +382,6 @@ void SkCanvasVideoRenderer::Paint(const scoped_refptr<VideoFrame>& 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);
Expand Down

0 comments on commit 034ad53

Please sign in to comment.