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

Side by Side Diff: cc/resources/video_resource_updater_unittest.cc

Issue 2678343011: chromeos: decode video into NV12 format instead of RGBA in vaapi decoder (Closed)
Patch Set: fix redtint with --disable-accelerated-video-decode --enable-native-gpu-memory-buffers Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/resources/video_resource_updater.h" 5 #include "cc/resources/video_resource_updater.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 207
208 scoped_refptr<media::VideoFrame> CreateTestStreamTextureHardwareVideoFrame( 208 scoped_refptr<media::VideoFrame> CreateTestStreamTextureHardwareVideoFrame(
209 bool needs_copy) { 209 bool needs_copy) {
210 scoped_refptr<media::VideoFrame> video_frame = 210 scoped_refptr<media::VideoFrame> video_frame =
211 CreateTestHardwareVideoFrame(GL_TEXTURE_EXTERNAL_OES); 211 CreateTestHardwareVideoFrame(GL_TEXTURE_EXTERNAL_OES);
212 video_frame->metadata()->SetBoolean( 212 video_frame->metadata()->SetBoolean(
213 media::VideoFrameMetadata::COPY_REQUIRED, needs_copy); 213 media::VideoFrameMetadata::COPY_REQUIRED, needs_copy);
214 return video_frame; 214 return video_frame;
215 } 215 }
216 216
217 scoped_refptr<media::VideoFrame> CreateTestYuvHardwareVideoFrame() { 217 scoped_refptr<media::VideoFrame> CreateTestYuvHardwareVideoFrame(
218 media::VideoPixelFormat format,
219 unsigned target,
220 bool is_single_gmb) {
218 const int kDimension = 10; 221 const int kDimension = 10;
219 gfx::Size size(kDimension, kDimension); 222 gfx::Size size(kDimension, kDimension);
220 223
221 const gpu::SyncToken sync_token( 224 const gpu::SyncToken sync_token(
222 gpu::CommandBufferNamespace::GPU_IO, 0, 225 gpu::CommandBufferNamespace::GPU_IO, 0,
223 gpu::CommandBufferId::FromUnsafeValue(0x123), 7); 226 gpu::CommandBufferId::FromUnsafeValue(0x123), 7);
224 const unsigned target = GL_TEXTURE_RECTANGLE_ARB;
225 const int kPlanesNum = 3;
226 gpu::MailboxHolder mailbox_holders[media::VideoFrame::kMaxPlanes]; 227 gpu::MailboxHolder mailbox_holders[media::VideoFrame::kMaxPlanes];
227 for (int i = 0; i < kPlanesNum; ++i) { 228 size_t num_plane = is_single_gmb ? 1 : media::VideoFrame::NumPlanes(format);
229 for (size_t i = 0; i < num_plane; ++i) {
228 gpu::Mailbox mailbox; 230 gpu::Mailbox mailbox;
229 mailbox.name[0] = 50 + 1; 231 mailbox.name[0] = 50 + 1;
230 mailbox_holders[i] = gpu::MailboxHolder(mailbox, sync_token, target); 232 mailbox_holders[i] = gpu::MailboxHolder(mailbox, sync_token, target);
231 } 233 }
232 scoped_refptr<media::VideoFrame> video_frame = 234 scoped_refptr<media::VideoFrame> video_frame =
233 media::VideoFrame::WrapNativeTextures(media::PIXEL_FORMAT_I420, 235 media::VideoFrame::WrapNativeTextures(format, mailbox_holders,
234 mailbox_holders,
235 base::Bind(&ReleaseMailboxCB), 236 base::Bind(&ReleaseMailboxCB),
236 size, // coded_size 237 size, // coded_size
237 gfx::Rect(size), // visible_rect 238 gfx::Rect(size), // visible_rect
238 size, // natural_size 239 size, // natural_size
239 base::TimeDelta()); // timestamp 240 base::TimeDelta()); // timestamp
240 EXPECT_TRUE(video_frame); 241 EXPECT_TRUE(video_frame);
241 return video_frame; 242 return video_frame;
242 } 243 }
243 244
244 WebGraphicsContext3DUploadCounter* context3d_; 245 WebGraphicsContext3DUploadCounter* context3d_;
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 CreateTestRGBAHardwareVideoFrame(); 458 CreateTestRGBAHardwareVideoFrame();
458 459
459 VideoFrameExternalResources resources = 460 VideoFrameExternalResources resources =
460 updater.CreateExternalResourcesFromVideoFrame(video_frame); 461 updater.CreateExternalResourcesFromVideoFrame(video_frame);
461 EXPECT_EQ(VideoFrameExternalResources::RGBA_PREMULTIPLIED_RESOURCE, 462 EXPECT_EQ(VideoFrameExternalResources::RGBA_PREMULTIPLIED_RESOURCE,
462 resources.type); 463 resources.type);
463 EXPECT_EQ(1u, resources.mailboxes.size()); 464 EXPECT_EQ(1u, resources.mailboxes.size());
464 EXPECT_EQ(1u, resources.release_callbacks.size()); 465 EXPECT_EQ(1u, resources.release_callbacks.size());
465 EXPECT_EQ(0u, resources.software_resources.size()); 466 EXPECT_EQ(0u, resources.software_resources.size());
466 467
467 video_frame = CreateTestYuvHardwareVideoFrame(); 468 video_frame = CreateTestYuvHardwareVideoFrame(
469 media::PIXEL_FORMAT_I420, GL_TEXTURE_RECTANGLE_ARB, false);
468 470
469 resources = updater.CreateExternalResourcesFromVideoFrame(video_frame); 471 resources = updater.CreateExternalResourcesFromVideoFrame(video_frame);
470 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type); 472 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type);
471 EXPECT_EQ(3u, resources.mailboxes.size()); 473 EXPECT_EQ(3u, resources.mailboxes.size());
472 EXPECT_EQ(3u, resources.release_callbacks.size()); 474 EXPECT_EQ(3u, resources.release_callbacks.size());
473 EXPECT_EQ(0u, resources.software_resources.size()); 475 EXPECT_EQ(0u, resources.software_resources.size());
474 EXPECT_FALSE(resources.read_lock_fences_enabled); 476 EXPECT_FALSE(resources.read_lock_fences_enabled);
475 477
476 video_frame = CreateTestYuvHardwareVideoFrame(); 478 video_frame = CreateTestYuvHardwareVideoFrame(
479 media::PIXEL_FORMAT_I420, GL_TEXTURE_RECTANGLE_ARB, false);
477 video_frame->metadata()->SetBoolean( 480 video_frame->metadata()->SetBoolean(
478 media::VideoFrameMetadata::READ_LOCK_FENCES_ENABLED, true); 481 media::VideoFrameMetadata::READ_LOCK_FENCES_ENABLED, true);
479 482
483 resources = updater.CreateExternalResourcesFromVideoFrame(video_frame);
484 EXPECT_TRUE(resources.read_lock_fences_enabled);
485 }
486
487 TEST_F(VideoResourceUpdaterTest, CreateForNV12HardwarePlanes) {
488 VideoResourceUpdater updater(context_provider_.get(),
489 resource_provider3d_.get());
490
491 scoped_refptr<media::VideoFrame> video_frame =
492 CreateTestYuvHardwareVideoFrame(media::PIXEL_FORMAT_NV12,
493 GL_TEXTURE_EXTERNAL_OES, false);
494
495 VideoFrameExternalResources resources =
496 updater.CreateExternalResourcesFromVideoFrame(video_frame);
497
498 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type);
499 EXPECT_EQ(2u, resources.mailboxes.size());
500 EXPECT_EQ(2u, resources.release_callbacks.size());
501 EXPECT_EQ(0u, resources.software_resources.size());
502 EXPECT_FALSE(resources.read_lock_fences_enabled);
503
504 video_frame = CreateTestYuvHardwareVideoFrame(media::PIXEL_FORMAT_NV12,
505 GL_TEXTURE_EXTERNAL_OES, true);
506 resources = updater.CreateExternalResourcesFromVideoFrame(video_frame);
507 EXPECT_EQ(VideoFrameExternalResources::RGB_RESOURCE, resources.type);
508
509 video_frame = CreateTestYuvHardwareVideoFrame(media::PIXEL_FORMAT_NV12,
510 GL_TEXTURE_EXTERNAL_OES, false);
511 video_frame->metadata()->SetBoolean(
512 media::VideoFrameMetadata::READ_LOCK_FENCES_ENABLED, true);
513
480 resources = updater.CreateExternalResourcesFromVideoFrame(video_frame); 514 resources = updater.CreateExternalResourcesFromVideoFrame(video_frame);
481 EXPECT_TRUE(resources.read_lock_fences_enabled); 515 EXPECT_TRUE(resources.read_lock_fences_enabled);
482 } 516 }
483 517
484 TEST_F(VideoResourceUpdaterTest, CreateForHardwarePlanes_StreamTexture) { 518 TEST_F(VideoResourceUpdaterTest, CreateForHardwarePlanes_StreamTexture) {
485 VideoResourceUpdater updater(context_provider_.get(), 519 VideoResourceUpdater updater(context_provider_.get(),
486 resource_provider3d_.get()); 520 resource_provider3d_.get());
487 context3d_->ResetTextureCreationCount(); 521 context3d_->ResetTextureCreationCount();
488 scoped_refptr<media::VideoFrame> video_frame = 522 scoped_refptr<media::VideoFrame> video_frame =
489 CreateTestStreamTextureHardwareVideoFrame(false); 523 CreateTestStreamTextureHardwareVideoFrame(false);
(...skipping 24 matching lines...) Expand all
514 // The texture copy path requires the use of CopyTextureCHROMIUM, which 548 // The texture copy path requires the use of CopyTextureCHROMIUM, which
515 // enforces that the target texture not be immutable, as it may need 549 // enforces that the target texture not be immutable, as it may need
516 // to alter the storage of the texture. Therefore, this test asserts 550 // to alter the storage of the texture. Therefore, this test asserts
517 // that an immutable texture wasn't created by glTexStorage2DEXT, when 551 // that an immutable texture wasn't created by glTexStorage2DEXT, when
518 // that extension is supported. 552 // that extension is supported.
519 EXPECT_FALSE(context3d_->WasImmutableTextureCreated()); 553 EXPECT_FALSE(context3d_->WasImmutableTextureCreated());
520 } 554 }
521 555
522 } // namespace 556 } // namespace
523 } // namespace cc 557 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698