Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(450)

Unified Diff: cc/output/renderer_pixeltest.cc

Issue 1852923002: Enable sampling from DXGI NV12 formats in GLRenderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/output/renderer_pixeltest.cc
diff --git a/cc/output/renderer_pixeltest.cc b/cc/output/renderer_pixeltest.cc
index e7925b2d1f56c68e482f348127366061a5c79ff9..d73c5aee10a42e656f1b81afd7df9cbd68f21c1c 100644
--- a/cc/output/renderer_pixeltest.cc
+++ b/cc/output/renderer_pixeltest.cc
@@ -228,10 +228,13 @@ void CreateTestYUVVideoDrawQuad_FromVideoFrame(
resources.mailboxes[media::VideoFrame::kUPlane],
SingleReleaseCallbackImpl::Create(
resources.release_callbacks[media::VideoFrame::kUPlane]));
- ResourceId v_resource = resource_provider->CreateResourceFromTextureMailbox(
- resources.mailboxes[media::VideoFrame::kVPlane],
- SingleReleaseCallbackImpl::Create(
- resources.release_callbacks[media::VideoFrame::kVPlane]));
+ ResourceId v_resource = u_resource;
+ if (video_frame->format() != media::PIXEL_FORMAT_NV12) {
+ v_resource = resource_provider->CreateResourceFromTextureMailbox(
+ resources.mailboxes[media::VideoFrame::kVPlane],
+ SingleReleaseCallbackImpl::Create(
+ resources.release_callbacks[media::VideoFrame::kVPlane]));
+ }
ResourceId a_resource = 0;
if (with_alpha) {
a_resource = resource_provider->CreateResourceFromTextureMailbox(
@@ -244,9 +247,12 @@ void CreateTestYUVVideoDrawQuad_FromVideoFrame(
const gfx::Size uv_tex_size = media::VideoFrame::PlaneSize(
video_frame->format(), media::VideoFrame::kUPlane,
video_frame->coded_size());
- DCHECK(uv_tex_size == media::VideoFrame::PlaneSize(
- video_frame->format(), media::VideoFrame::kVPlane,
- video_frame->coded_size()));
+ if (media::VideoFrame::NumPlanes(video_frame->format()) >
+ media::VideoFrame::kVPlane) {
+ DCHECK(uv_tex_size == media::VideoFrame::PlaneSize(
+ video_frame->format(), media::VideoFrame::kVPlane,
+ video_frame->coded_size()));
+ }
if (with_alpha) {
DCHECK(ya_tex_size == media::VideoFrame::PlaneSize(
video_frame->format(), media::VideoFrame::kAPlane,
@@ -457,12 +463,28 @@ void CreateTestYUVVideoDrawQuad_Solid(
memset(video_frame->data(media::VideoFrame::kYPlane), y,
video_frame->stride(media::VideoFrame::kYPlane) *
video_frame->rows(media::VideoFrame::kYPlane));
- memset(video_frame->data(media::VideoFrame::kUPlane), u,
- video_frame->stride(media::VideoFrame::kUPlane) *
- video_frame->rows(media::VideoFrame::kUPlane));
- memset(video_frame->data(media::VideoFrame::kVPlane), v,
- video_frame->stride(media::VideoFrame::kVPlane) *
- video_frame->rows(media::VideoFrame::kVPlane));
+ if (format == media::PIXEL_FORMAT_NV12) {
+ uint8_t* data = video_frame->data(media::VideoFrame::kUVPlane);
+ int stride = video_frame->stride(media::VideoFrame::kUVPlane);
+ gfx::Size plane_size = video_frame->PlaneSize(video_frame->format(),
+ media::VideoFrame::kUVPlane,
+ video_frame->coded_size());
+
+ for (int y = 0; y < plane_size.height(); ++y) {
+ for (int x = 0; x < plane_size.width(); ++x) {
+ data[x * 2] = u;
+ data[x * 2 + 1] = v;
+ }
+ data += stride;
+ }
+ } else {
+ memset(video_frame->data(media::VideoFrame::kUPlane), u,
+ video_frame->stride(media::VideoFrame::kUPlane) *
+ video_frame->rows(media::VideoFrame::kUPlane));
+ memset(video_frame->data(media::VideoFrame::kVPlane), v,
+ video_frame->stride(media::VideoFrame::kVPlane) *
+ video_frame->rows(media::VideoFrame::kVPlane));
+ }
uint8_t alpha_value = is_transparent ? 0 : 128;
CreateTestYUVVideoDrawQuad_FromVideoFrame(
@@ -1155,6 +1177,29 @@ TEST_F(VideoGLRendererPixelTest, SimpleYUVJRect) {
FuzzyPixelOffByOneComparator(true)));
}
+TEST_F(VideoGLRendererPixelTest, SimpleNV12JRect) {
+ gfx::Rect rect(this->device_viewport_size_);
+
+ RenderPassId id(1, 1);
+ scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect);
+
+ SharedQuadState* shared_state =
+ CreateTestSharedQuadState(gfx::Transform(), rect, pass.get());
+
+ // YUV of (149,43,21) should be green (0,255,0) in RGB.
+ CreateTestYUVVideoDrawQuad_Solid(
+ shared_state, media::PIXEL_FORMAT_NV12, media::COLOR_SPACE_JPEG, false,
+ gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f), 149, 43, 21, pass.get(),
+ video_resource_updater_.get(), rect, rect, resource_provider_.get());
+
+ RenderPassList pass_list;
+ pass_list.push_back(std::move(pass));
+
+ EXPECT_TRUE(this->RunPixelTest(&pass_list,
+ base::FilePath(FILE_PATH_LITERAL("green.png")),
+ FuzzyPixelOffByOneComparator(true)));
+}
+
// Test that a YUV video doesn't bleed outside of its tex coords when the
// tex coord rect is only a partial subrectangle of the coded contents.
TEST_F(VideoGLRendererPixelTest, YUVEdgeBleed) {

Powered by Google App Engine
This is Rietveld 408576698