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

Side by Side Diff: media/blink/skcanvas_video_renderer_unittest.cc

Issue 1144323003: media: Refactor SkCanvasVideoRenderer to use SkImages and not SkBitmaps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address reveman's comments. Created 5 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 (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 "base/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "media/base/video_frame.h" 6 #include "media/base/video_frame.h"
7 #include "media/base/video_util.h" 7 #include "media/base/video_util.h"
8 #include "media/blink/skcanvas_video_renderer.h" 8 #include "media/blink/skcanvas_video_renderer.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/skia/include/core/SkCanvas.h" 10 #include "third_party/skia/include/core/SkCanvas.h"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 EXPECT_EQ(SK_ColorBLUE, GetColor(target_canvas())); 305 EXPECT_EQ(SK_ColorBLUE, GetColor(target_canvas()));
306 } 306 }
307 307
308 TEST_F(SkCanvasVideoRendererTest, NoTimestamp) { 308 TEST_F(SkCanvasVideoRendererTest, NoTimestamp) {
309 VideoFrame* video_frame = natural_frame().get(); 309 VideoFrame* video_frame = natural_frame().get();
310 video_frame->set_timestamp(media::kNoTimestamp()); 310 video_frame->set_timestamp(media::kNoTimestamp());
311 Paint(video_frame, target_canvas(), kRed); 311 Paint(video_frame, target_canvas(), kRed);
312 EXPECT_EQ(SK_ColorRED, GetColor(target_canvas())); 312 EXPECT_EQ(SK_ColorRED, GetColor(target_canvas()));
313 } 313 }
314 314
315 TEST_F(SkCanvasVideoRendererTest, SameVideoFrame) {
316 Paint(natural_frame(), target_canvas(), kRed);
317 EXPECT_EQ(SK_ColorRED, GetColor(target_canvas()));
318
319 // Slow paints can get cached, expect the old color value.
320 Paint(natural_frame(), target_canvas(), kBlue);
321 EXPECT_EQ(SK_ColorRED, GetColor(target_canvas()));
322 }
323
324 TEST_F(SkCanvasVideoRendererTest, CroppedFrame) { 315 TEST_F(SkCanvasVideoRendererTest, CroppedFrame) {
325 Paint(cropped_frame(), target_canvas(), kNone); 316 Paint(cropped_frame(), target_canvas(), kNone);
326 // Check the corners. 317 // Check the corners.
327 EXPECT_EQ(SK_ColorBLACK, GetColorAt(target_canvas(), 0, 0)); 318 EXPECT_EQ(SK_ColorBLACK, GetColorAt(target_canvas(), 0, 0));
328 EXPECT_EQ(SK_ColorRED, GetColorAt(target_canvas(), kWidth - 1, 0)); 319 EXPECT_EQ(SK_ColorRED, GetColorAt(target_canvas(), kWidth - 1, 0));
329 EXPECT_EQ(SK_ColorGREEN, GetColorAt(target_canvas(), 0, kHeight - 1)); 320 EXPECT_EQ(SK_ColorGREEN, GetColorAt(target_canvas(), 0, kHeight - 1));
330 EXPECT_EQ(SK_ColorBLUE, GetColorAt(target_canvas(), kWidth - 1, 321 EXPECT_EQ(SK_ColorBLUE, GetColorAt(target_canvas(), kWidth - 1,
331 kHeight - 1)); 322 kHeight - 1));
332 // Check the interior along the border between color regions. Note that we're 323 // Check the interior along the border between color regions. Note that we're
333 // bilinearly upscaling, so we'll need to take care to pick sample points that 324 // bilinearly upscaling, so we'll need to take care to pick sample points that
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 EXPECT_EQ(SK_ColorMAGENTA, 490 EXPECT_EQ(SK_ColorMAGENTA,
500 GetColorAt(&canvas, (kWidth / 2) - 1, (kHeight / 2) - 1)); 491 GetColorAt(&canvas, (kWidth / 2) - 1, (kHeight / 2) - 1));
501 EXPECT_EQ(SK_ColorMAGENTA, GetColorAt(&canvas, 0, (kHeight / 2) - 1)); 492 EXPECT_EQ(SK_ColorMAGENTA, GetColorAt(&canvas, 0, (kHeight / 2) - 1));
502 EXPECT_EQ(SK_ColorRED, GetColorAt(&canvas, kWidth / 2, kHeight / 2)); 493 EXPECT_EQ(SK_ColorRED, GetColorAt(&canvas, kWidth / 2, kHeight / 2));
503 EXPECT_EQ(SK_ColorBLUE, GetColorAt(&canvas, kWidth - 1, kHeight / 2)); 494 EXPECT_EQ(SK_ColorBLUE, GetColorAt(&canvas, kWidth - 1, kHeight / 2));
504 EXPECT_EQ(SK_ColorGREEN, GetColorAt(&canvas, kWidth - 1, kHeight - 1)); 495 EXPECT_EQ(SK_ColorGREEN, GetColorAt(&canvas, kWidth - 1, kHeight - 1));
505 EXPECT_EQ(SK_ColorBLACK, GetColorAt(&canvas, kWidth / 2, kHeight - 1)); 496 EXPECT_EQ(SK_ColorBLACK, GetColorAt(&canvas, kWidth / 2, kHeight - 1));
506 } 497 }
507 498
508 } // namespace media 499 } // namespace media
OLDNEW
« media/blink/skcanvas_video_renderer.cc ('K') | « media/blink/skcanvas_video_renderer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698