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

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

Issue 2684993005: (NotForReview) Enable YUV video overlay on Skylake ChromeOS.
Patch Set: rebase to ToT (Mar/27) Created 3 years, 9 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
« no previous file with comments | « cc/resources/video_resource_updater.cc ('k') | cc/test/render_pass_test_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 scoped_refptr<media::VideoFrame> video_frame(media::VideoFrame::CreateFrame( 170 scoped_refptr<media::VideoFrame> video_frame(media::VideoFrame::CreateFrame(
171 media::PIXEL_FORMAT_YUV420P10, size, gfx::Rect(size), size, 171 media::PIXEL_FORMAT_YUV420P10, size, gfx::Rect(size), size,
172 base::TimeDelta())); 172 base::TimeDelta()));
173 EXPECT_TRUE(video_frame); 173 EXPECT_TRUE(video_frame);
174 return video_frame; 174 return video_frame;
175 } 175 }
176 176
177 static void ReleaseMailboxCB(const gpu::SyncToken& sync_token) {} 177 static void ReleaseMailboxCB(const gpu::SyncToken& sync_token) {}
178 178
179 scoped_refptr<media::VideoFrame> CreateTestHardwareVideoFrame( 179 scoped_refptr<media::VideoFrame> CreateTestHardwareVideoFrame(
180 unsigned target) { 180 unsigned target,
181 media::VideoPixelFormat format) {
181 const int kDimension = 10; 182 const int kDimension = 10;
182 gfx::Size size(kDimension, kDimension); 183 gfx::Size size(kDimension, kDimension);
183 184
184 gpu::Mailbox mailbox; 185 gpu::Mailbox mailbox;
185 mailbox.name[0] = 51; 186 mailbox.name[0] = 51;
186 187
187 const gpu::SyncToken sync_token( 188 const gpu::SyncToken sync_token(
188 gpu::CommandBufferNamespace::GPU_IO, 0, 189 gpu::CommandBufferNamespace::GPU_IO, 0,
189 gpu::CommandBufferId::FromUnsafeValue(0x123), 7); 190 gpu::CommandBufferId::FromUnsafeValue(0x123), 7);
190 gpu::MailboxHolder mailbox_holders[media::VideoFrame::kMaxPlanes] = { 191 gpu::MailboxHolder mailbox_holders[media::VideoFrame::kMaxPlanes] = {
191 gpu::MailboxHolder(mailbox, sync_token, target)}; 192 gpu::MailboxHolder(mailbox, sync_token, target)};
192 scoped_refptr<media::VideoFrame> video_frame = 193 scoped_refptr<media::VideoFrame> video_frame =
193 media::VideoFrame::WrapNativeTextures(media::PIXEL_FORMAT_ARGB, 194 media::VideoFrame::WrapNativeTextures(format, mailbox_holders,
194 mailbox_holders,
195 base::Bind(&ReleaseMailboxCB), 195 base::Bind(&ReleaseMailboxCB),
196 size, // coded_size 196 size, // coded_size
197 gfx::Rect(size), // visible_rect 197 gfx::Rect(size), // visible_rect
198 size, // natural_size 198 size, // natural_size
199 base::TimeDelta()); // timestamp 199 base::TimeDelta()); // timestamp
200 EXPECT_TRUE(video_frame); 200 EXPECT_TRUE(video_frame);
201 return video_frame; 201 return video_frame;
202 } 202 }
203 203
204 scoped_refptr<media::VideoFrame> CreateTestRGBAHardwareVideoFrame() { 204 scoped_refptr<media::VideoFrame> CreateTestRGBAHardwareVideoFrame() {
205 return CreateTestHardwareVideoFrame(GL_TEXTURE_2D); 205 return CreateTestHardwareVideoFrame(GL_TEXTURE_2D,
206 media::PIXEL_FORMAT_ARGB);
206 } 207 }
207 208
208 scoped_refptr<media::VideoFrame> CreateTestStreamTextureHardwareVideoFrame( 209 scoped_refptr<media::VideoFrame> CreateTestStreamTextureHardwareVideoFrame(
209 bool needs_copy) { 210 bool needs_copy) {
210 scoped_refptr<media::VideoFrame> video_frame = 211 scoped_refptr<media::VideoFrame> video_frame = CreateTestHardwareVideoFrame(
211 CreateTestHardwareVideoFrame(GL_TEXTURE_EXTERNAL_OES); 212 GL_TEXTURE_EXTERNAL_OES, media::PIXEL_FORMAT_ARGB);
212 video_frame->metadata()->SetBoolean( 213 video_frame->metadata()->SetBoolean(
213 media::VideoFrameMetadata::COPY_REQUIRED, needs_copy); 214 media::VideoFrameMetadata::COPY_REQUIRED, needs_copy);
214 return video_frame; 215 return video_frame;
215 } 216 }
216 217
218 scoped_refptr<media::VideoFrame> CreateTestYUV422TextureHardwareVideoFrame(
219 unsigned target,
220 media::VideoPixelFormat format) {
221 scoped_refptr<media::VideoFrame> video_frame =
222 CreateTestHardwareVideoFrame(target, format);
223 video_frame->metadata()->SetBoolean(
224 media::VideoFrameMetadata::COPY_REQUIRED, false);
225 return video_frame;
226 }
227
217 scoped_refptr<media::VideoFrame> CreateTestYuvHardwareVideoFrame() { 228 scoped_refptr<media::VideoFrame> CreateTestYuvHardwareVideoFrame() {
218 const int kDimension = 10; 229 const int kDimension = 10;
219 gfx::Size size(kDimension, kDimension); 230 gfx::Size size(kDimension, kDimension);
220 231
221 const gpu::SyncToken sync_token( 232 const gpu::SyncToken sync_token(
222 gpu::CommandBufferNamespace::GPU_IO, 0, 233 gpu::CommandBufferNamespace::GPU_IO, 0,
223 gpu::CommandBufferId::FromUnsafeValue(0x123), 7); 234 gpu::CommandBufferId::FromUnsafeValue(0x123), 7);
224 const unsigned target = GL_TEXTURE_RECTANGLE_ARB; 235 const unsigned target = GL_TEXTURE_RECTANGLE_ARB;
225 const int kPlanesNum = 3; 236 const int kPlanesNum = 3;
226 gpu::MailboxHolder mailbox_holders[media::VideoFrame::kMaxPlanes]; 237 gpu::MailboxHolder mailbox_holders[media::VideoFrame::kMaxPlanes];
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 EXPECT_EQ(1, context3d_->TextureCreationCount()); 523 EXPECT_EQ(1, context3d_->TextureCreationCount());
513 524
514 // The texture copy path requires the use of CopyTextureCHROMIUM, which 525 // The texture copy path requires the use of CopyTextureCHROMIUM, which
515 // enforces that the target texture not be immutable, as it may need 526 // enforces that the target texture not be immutable, as it may need
516 // to alter the storage of the texture. Therefore, this test asserts 527 // to alter the storage of the texture. Therefore, this test asserts
517 // that an immutable texture wasn't created by glTexStorage2DEXT, when 528 // that an immutable texture wasn't created by glTexStorage2DEXT, when
518 // that extension is supported. 529 // that extension is supported.
519 EXPECT_FALSE(context3d_->WasImmutableTextureCreated()); 530 EXPECT_FALSE(context3d_->WasImmutableTextureCreated());
520 } 531 }
521 532
533 TEST_F(VideoResourceUpdaterTest, CreateForHardwarePlanes_YUV422Texture) {
534 VideoResourceUpdater updater(context_provider_.get(),
535 resource_provider3d_.get());
536
537 scoped_refptr<media::VideoFrame> video_frame =
538 CreateTestYUV422TextureHardwareVideoFrame(GL_TEXTURE_2D,
539 media::PIXEL_FORMAT_UYVY);
540
541 VideoFrameExternalResources resources =
542 updater.CreateExternalResourcesFromVideoFrame(video_frame);
543 EXPECT_EQ(VideoFrameExternalResources::RGB_RESOURCE, resources.type);
544 EXPECT_EQ(1u, resources.mailboxes.size());
545 EXPECT_EQ(1u, resources.release_callbacks.size());
546 EXPECT_EQ(0u, resources.software_resources.size());
547
548 video_frame = CreateTestYUV422TextureHardwareVideoFrame(
549 GL_TEXTURE_EXTERNAL_OES, media::PIXEL_FORMAT_UYVY);
550 resources = updater.CreateExternalResourcesFromVideoFrame(video_frame);
551 EXPECT_EQ(VideoFrameExternalResources::STREAM_TEXTURE_RESOURCE,
552 resources.type);
553 EXPECT_EQ(1u, resources.mailboxes.size());
554 EXPECT_EQ(1u, resources.release_callbacks.size());
555 EXPECT_EQ(0u, resources.software_resources.size());
556
557 video_frame = CreateTestYUV422TextureHardwareVideoFrame(
558 GL_TEXTURE_2D, media::PIXEL_FORMAT_YUY2);
559 resources = updater.CreateExternalResourcesFromVideoFrame(video_frame);
560 EXPECT_EQ(VideoFrameExternalResources::RGB_RESOURCE, resources.type);
561
562 video_frame = CreateTestYUV422TextureHardwareVideoFrame(
563 GL_TEXTURE_EXTERNAL_OES, media::PIXEL_FORMAT_YUY2);
564 resources = updater.CreateExternalResourcesFromVideoFrame(video_frame);
565 EXPECT_EQ(VideoFrameExternalResources::STREAM_TEXTURE_RESOURCE,
566 resources.type);
567 }
568
522 } // namespace 569 } // namespace
523 } // namespace cc 570 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/video_resource_updater.cc ('k') | cc/test/render_pass_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698