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

Side by Side Diff: media/base/video_frame_unittest.cc

Issue 175223003: HW Video: Make media::VideoFrame handle the sync point of the compositor as well as webgl (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: previous patchset has unrelated code by mistake. Created 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "media/base/video_frame.h" 5 #include "media/base/video_frame.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/memory/aligned_memory.h" 10 #include "base/memory/aligned_memory.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 TEST(VideoFrame, CheckFrameExtents) { 205 TEST(VideoFrame, CheckFrameExtents) {
206 // Each call consists of a VideoFrame::Format, # of planes, bytes per pixel, 206 // Each call consists of a VideoFrame::Format, # of planes, bytes per pixel,
207 // and the expected hash of all planes if filled with kFillByte (defined in 207 // and the expected hash of all planes if filled with kFillByte (defined in
208 // ExpectFrameExtents). 208 // ExpectFrameExtents).
209 ExpectFrameExtents( 209 ExpectFrameExtents(
210 VideoFrame::YV12, 3, 1, "71113bdfd4c0de6cf62f48fb74f7a0b1"); 210 VideoFrame::YV12, 3, 1, "71113bdfd4c0de6cf62f48fb74f7a0b1");
211 ExpectFrameExtents( 211 ExpectFrameExtents(
212 VideoFrame::YV16, 3, 1, "9bb99ac3ff350644ebff4d28dc01b461"); 212 VideoFrame::YV16, 3, 1, "9bb99ac3ff350644ebff4d28dc01b461");
213 } 213 }
214 214
215 static void TextureCallback(uint32* called_sync_point, 215 static void TextureCallback(std::vector<uint32>* called_sync_point,
216 scoped_ptr<gpu::MailboxHolder> mailbox_holder) { 216 scoped_ptr<gpu::MailboxHolder> mailbox_holder,
217 *called_sync_point = mailbox_holder->sync_point; 217 const std::vector<uint32>& release_sync_points) {
218 std::vector<uint32> sync_points(release_sync_points);
219 called_sync_point->swap(sync_points);
218 } 220 }
219 221
220 // Verify the gpu::MailboxHolder::ReleaseCallback is called when VideoFrame is 222 // Verify the gpu::MailboxHolder::ReleaseCallback is called when VideoFrame is
221 // destroyed with the original sync point. 223 // destroyed with the default release sync points.
222 TEST(VideoFrame, TextureNoLongerNeededCallbackIsCalled) { 224 TEST(VideoFrame, TextureNoLongerNeededCallbackIsCalled) {
223 uint32 sync_point = 7; 225 std::vector<uint32> called_sync_points;
224 uint32 called_sync_point = 0; 226 called_sync_points.push_back(1);
225 227
226 { 228 {
227 scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTexture( 229 scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTexture(
228 make_scoped_ptr(new gpu::MailboxHolder(gpu::Mailbox(), 5, sync_point)), 230 make_scoped_ptr(
229 base::Bind(&TextureCallback, &called_sync_point), 231 new gpu::MailboxHolder(gpu::Mailbox(), 5, 0 /* sync_point */)),
230 gfx::Size(10, 10), // coded_size 232 base::Bind(&TextureCallback, &called_sync_points),
231 gfx::Rect(10, 10), // visible_rect 233 gfx::Size(10, 10), // coded_size
232 gfx::Size(10, 10), // natural_size 234 gfx::Rect(10, 10), // visible_rect
233 base::TimeDelta(), // timestamp 235 gfx::Size(10, 10), // natural_size
234 base::Callback<void(const SkBitmap&)>()); // read_pixels_cb 236 base::TimeDelta(), // timestamp
237 VideoFrame::ReadPixelsCB()); // read_pixels_cb
235 238
236 EXPECT_EQ(0u, called_sync_point); 239 EXPECT_EQ(1u, called_sync_points.size());
237 } 240 }
238 EXPECT_EQ(sync_point, called_sync_point); 241 EXPECT_TRUE(called_sync_points.empty());
239 } 242 }
240 243
241 // Verify the gpu::MailboxHolder::ReleaseCallback is called when VideoFrame is 244 // Verify the gpu::MailboxHolder::ReleaseCallback is called when VideoFrame is
242 // destroyed with the new sync point, when the mailbox is accessed by a caller. 245 // destroyed with the release sync points, which was updated by clients.
246 // (i.e. the compositor, webgl).
243 TEST(VideoFrame, TextureNoLongerNeededCallbackAfterTakingAndReleasingMailbox) { 247 TEST(VideoFrame, TextureNoLongerNeededCallbackAfterTakingAndReleasingMailbox) {
244 uint32 called_sync_point = 0; 248 std::vector<uint32> called_sync_points;
245 249
246 gpu::Mailbox mailbox; 250 gpu::Mailbox mailbox;
247 mailbox.name[0] = 50; 251 mailbox.name[0] = 50;
248 uint32 sync_point = 7; 252 uint32 sync_point = 7;
249 uint32 target = 9; 253 uint32 target = 9;
254 std::vector<uint32> release_sync_points;
255 release_sync_points.push_back(1);
256 release_sync_points.push_back(2);
257 release_sync_points.push_back(3);
250 258
251 { 259 {
252 scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTexture( 260 scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTexture(
253 make_scoped_ptr(new gpu::MailboxHolder(mailbox, target, sync_point)), 261 make_scoped_ptr(new gpu::MailboxHolder(mailbox, target, sync_point)),
254 base::Bind(&TextureCallback, &called_sync_point), 262 base::Bind(&TextureCallback, &called_sync_points),
255 gfx::Size(10, 10), // coded_size 263 gfx::Size(10, 10), // coded_size
256 gfx::Rect(10, 10), // visible_rect 264 gfx::Rect(10, 10), // visible_rect
257 gfx::Size(10, 10), // natural_size 265 gfx::Size(10, 10), // natural_size
258 base::TimeDelta(), // timestamp 266 base::TimeDelta(), // timestamp
259 base::Callback<void(const SkBitmap&)>()); // read_pixels_cb 267 VideoFrame::ReadPixelsCB()); // read_pixels_cb
268 EXPECT_TRUE(called_sync_points.empty());
260 269
261 gpu::MailboxHolder* mailbox_holder = frame->mailbox_holder(); 270 gpu::MailboxHolder* mailbox_holder = frame->mailbox_holder();
262 271
263 EXPECT_EQ(mailbox.name[0], mailbox_holder->mailbox.name[0]); 272 EXPECT_EQ(mailbox.name[0], mailbox_holder->mailbox.name[0]);
264 EXPECT_EQ(target, mailbox_holder->texture_target); 273 EXPECT_EQ(target, mailbox_holder->texture_target);
265 EXPECT_EQ(sync_point, mailbox_holder->sync_point); 274 EXPECT_EQ(sync_point, mailbox_holder->sync_point);
266 275
267 // Finish using the mailbox_holder and drop our reference. 276 frame->AppendReleaseSyncPoint(release_sync_points[0]);
268 sync_point = 10; 277 frame->AppendReleaseSyncPoint(release_sync_points[1]);
269 mailbox_holder->sync_point = sync_point; 278 frame->AppendReleaseSyncPoint(release_sync_points[2]);
279 EXPECT_EQ(sync_point, mailbox_holder->sync_point);
270 } 280 }
271 EXPECT_EQ(sync_point, called_sync_point); 281 EXPECT_EQ(release_sync_points, called_sync_points);
272 } 282 }
273 283
274 } // namespace media 284 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698