Index: cc/resources/media/skcanvas_video_renderer_unittest.cc |
diff --git a/media/filters/skcanvas_video_renderer_unittest.cc b/cc/resources/media/skcanvas_video_renderer_unittest.cc |
similarity index 71% |
rename from media/filters/skcanvas_video_renderer_unittest.cc |
rename to cc/resources/media/skcanvas_video_renderer_unittest.cc |
index 5db3a34d6cfa260029c62ddd8b4c1ba5b56a8875..e42f658b786ad02cc8b197026d537ca1d5ea3a36 100644 |
--- a/media/filters/skcanvas_video_renderer_unittest.cc |
+++ b/cc/resources/media/skcanvas_video_renderer_unittest.cc |
@@ -2,15 +2,16 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+#include "cc/resources/media/skcanvas_video_renderer.h" |
+#include "media/base/media.h" |
#include "media/base/video_frame.h" |
#include "media/base/video_util.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "third_party/skia/include/core/SkCanvas.h" |
-#include "media/filters/skcanvas_video_renderer.h" |
using media::VideoFrame; |
-namespace media { |
+namespace cc { |
static const int kWidth = 320; |
static const int kHeight = 240; |
@@ -85,17 +86,19 @@ static SkBitmap AllocBitmap(int width, int height) { |
SkCanvasVideoRendererTest::SkCanvasVideoRendererTest() |
: natural_frame_(VideoFrame::CreateBlackFrame(gfx::Size(kWidth, kHeight))), |
- larger_frame_(VideoFrame::CreateBlackFrame( |
- gfx::Size(kWidth * 2, kHeight * 2))), |
- smaller_frame_(VideoFrame::CreateBlackFrame( |
- gfx::Size(kWidth / 2, kHeight / 2))), |
- cropped_frame_(VideoFrame::CreateFrame( |
- VideoFrame::YV12, |
- gfx::Size(16, 16), |
- gfx::Rect(6, 6, 8, 6), |
- gfx::Size(8, 6), |
- base::TimeDelta::FromMilliseconds(4))), |
+ larger_frame_( |
+ VideoFrame::CreateBlackFrame(gfx::Size(kWidth * 2, kHeight * 2))), |
+ smaller_frame_( |
+ VideoFrame::CreateBlackFrame(gfx::Size(kWidth / 2, kHeight / 2))), |
+ cropped_frame_( |
+ VideoFrame::CreateFrame(VideoFrame::YV12, |
+ gfx::Size(16, 16), |
+ gfx::Rect(6, 6, 8, 6), |
+ gfx::Size(8, 6), |
+ base::TimeDelta::FromMilliseconds(4))), |
target_canvas_(AllocBitmap(kWidth, kHeight)) { |
+ media::InitializeMediaLibraryForTesting(); |
+ |
// Give each frame a unique timestamp. |
natural_frame_->set_timestamp(base::TimeDelta::FromMilliseconds(1)); |
larger_frame_->set_timestamp(base::TimeDelta::FromMilliseconds(2)); |
@@ -138,43 +141,37 @@ SkCanvasVideoRendererTest::SkCanvasVideoRendererTest() |
// avoid sharing UV samples between regions. |
static const uint8 cropped_y_plane[] = { |
- 0, 0, 0, 0, 0, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 76, |
- 0, 0, 0, 0, 0, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 76, |
- 0, 0, 0, 0, 0, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 76, |
- 0, 0, 0, 0, 0, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 76, |
- 0, 0, 0, 0, 0, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 76, |
- 0, 0, 0, 0, 0, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 76, |
- 0, 0, 0, 0, 0, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 76, |
- 0, 0, 0, 0, 0, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 76, |
- 149, 149, 149, 149, 149, 149, 149, 149, 29, 29, 29, 29, 29, 29, 29, 29, |
- 149, 149, 149, 149, 149, 149, 149, 149, 29, 29, 29, 29, 29, 29, 29, 29, |
- 149, 149, 149, 149, 149, 149, 149, 149, 29, 29, 29, 29, 29, 29, 29, 29, |
- 149, 149, 149, 149, 149, 149, 149, 149, 29, 29, 29, 29, 29, 29, 29, 29, |
- 149, 149, 149, 149, 149, 149, 149, 149, 29, 29, 29, 29, 29, 29, 29, 29, |
- 149, 149, 149, 149, 149, 149, 149, 149, 29, 29, 29, 29, 29, 29, 29, 29, |
- 149, 149, 149, 149, 149, 149, 149, 149, 29, 29, 29, 29, 29, 29, 29, 29, |
- 149, 149, 149, 149, 149, 149, 149, 149, 29, 29, 29, 29, 29, 29, 29, 29, |
+ 0, 0, 0, 0, 0, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 76, |
+ 0, 0, 0, 0, 0, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 76, |
+ 0, 0, 0, 0, 0, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 76, |
+ 0, 0, 0, 0, 0, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 76, |
+ 0, 0, 0, 0, 0, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 76, |
+ 0, 0, 0, 0, 0, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 76, |
+ 0, 0, 0, 0, 0, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 76, |
+ 0, 0, 0, 0, 0, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 76, |
+ 149, 149, 149, 149, 149, 149, 149, 149, 29, 29, 29, 29, 29, 29, 29, 29, |
+ 149, 149, 149, 149, 149, 149, 149, 149, 29, 29, 29, 29, 29, 29, 29, 29, |
+ 149, 149, 149, 149, 149, 149, 149, 149, 29, 29, 29, 29, 29, 29, 29, 29, |
+ 149, 149, 149, 149, 149, 149, 149, 149, 29, 29, 29, 29, 29, 29, 29, 29, |
+ 149, 149, 149, 149, 149, 149, 149, 149, 29, 29, 29, 29, 29, 29, 29, 29, |
+ 149, 149, 149, 149, 149, 149, 149, 149, 29, 29, 29, 29, 29, 29, 29, 29, |
+ 149, 149, 149, 149, 149, 149, 149, 149, 29, 29, 29, 29, 29, 29, 29, 29, |
+ 149, 149, 149, 149, 149, 149, 149, 149, 29, 29, 29, 29, 29, 29, 29, 29, |
}; |
static const uint8 cropped_u_plane[] = { |
- 128, 128, 128, 128, 84, 84, 84, 84, |
- 128, 128, 128, 128, 84, 84, 84, 84, |
- 128, 128, 128, 128, 84, 84, 84, 84, |
- 128, 128, 128, 128, 84, 84, 84, 84, |
- 43, 43, 43, 43, 255, 255, 255, 255, |
- 43, 43, 43, 43, 255, 255, 255, 255, |
- 43, 43, 43, 43, 255, 255, 255, 255, |
- 43, 43, 43, 43, 255, 255, 255, 255, |
+ 128, 128, 128, 128, 84, 84, 84, 84, 128, 128, 128, 128, 84, |
+ 84, 84, 84, 128, 128, 128, 128, 84, 84, 84, 84, 128, 128, |
+ 128, 128, 84, 84, 84, 84, 43, 43, 43, 43, 255, 255, 255, |
+ 255, 43, 43, 43, 43, 255, 255, 255, 255, 43, 43, 43, 43, |
+ 255, 255, 255, 255, 43, 43, 43, 43, 255, 255, 255, 255, |
}; |
static const uint8 cropped_v_plane[] = { |
- 128, 128, 128, 128, 255, 255, 255, 255, |
- 128, 128, 128, 128, 255, 255, 255, 255, |
- 128, 128, 128, 128, 255, 255, 255, 255, |
- 128, 128, 128, 128, 255, 255, 255, 255, |
- 21, 21, 21, 21, 107, 107, 107, 107, |
- 21, 21, 21, 21, 107, 107, 107, 107, |
- 21, 21, 21, 21, 107, 107, 107, 107, |
- 21, 21, 21, 21, 107, 107, 107, 107, |
+ 128, 128, 128, 128, 255, 255, 255, 255, 128, 128, 128, 128, 255, |
+ 255, 255, 255, 128, 128, 128, 128, 255, 255, 255, 255, 128, 128, |
+ 128, 128, 255, 255, 255, 255, 21, 21, 21, 21, 107, 107, 107, |
+ 107, 21, 21, 21, 21, 107, 107, 107, 107, 21, 21, 21, 21, |
+ 107, 107, 107, 107, 21, 21, 21, 21, 107, 107, 107, 107, |
}; |
media::CopyYPlane(cropped_y_plane, 16, 16, cropped_frame()); |
@@ -182,10 +179,11 @@ SkCanvasVideoRendererTest::SkCanvasVideoRendererTest() |
media::CopyVPlane(cropped_v_plane, 8, 8, cropped_frame()); |
} |
-SkCanvasVideoRendererTest::~SkCanvasVideoRendererTest() {} |
+SkCanvasVideoRendererTest::~SkCanvasVideoRendererTest() { |
+} |
void SkCanvasVideoRendererTest::PaintWithoutFrame(SkCanvas* canvas) { |
- renderer_.Paint(NULL, canvas, kNaturalRect, 0xFF); |
+ renderer_.Paint(NULL, canvas, kNaturalRect, 0xFF, 0); |
} |
void SkCanvasVideoRendererTest::Paint(VideoFrame* video_frame, |
@@ -204,7 +202,7 @@ void SkCanvasVideoRendererTest::Paint(VideoFrame* video_frame, |
media::FillYUV(video_frame, 29, 255, 107); |
break; |
} |
- renderer_.Paint(video_frame, canvas, kNaturalRect, 0xFF); |
+ renderer_.Paint(video_frame, canvas, kNaturalRect, 0xFF, 0); |
} |
TEST_F(SkCanvasVideoRendererTest, NoFrame) { |
@@ -220,8 +218,7 @@ TEST_F(SkCanvasVideoRendererTest, TransparentFrame) { |
Paint(VideoFrame::CreateTransparentFrame(gfx::Size(kWidth, kHeight)), |
target_canvas(), |
kNone); |
- EXPECT_EQ(static_cast<SkColor>(SK_ColorTRANSPARENT), |
- GetColor(target_canvas())); |
+ EXPECT_EQ(static_cast<SkColor>(SK_ColorRED), GetColor(target_canvas())); |
} |
TEST_F(SkCanvasVideoRendererTest, Natural) { |
@@ -265,21 +262,21 @@ TEST_F(SkCanvasVideoRendererTest, CroppedFrame) { |
Paint(cropped_frame(), target_canvas(), kNone); |
// Check the corners. |
EXPECT_EQ(SK_ColorBLACK, GetColorAt(target_canvas(), 0, 0)); |
- EXPECT_EQ(SK_ColorRED, GetColorAt(target_canvas(), kWidth - 1, 0)); |
+ EXPECT_EQ(SK_ColorRED, GetColorAt(target_canvas(), kWidth - 1, 0)); |
EXPECT_EQ(SK_ColorGREEN, GetColorAt(target_canvas(), 0, kHeight - 1)); |
- EXPECT_EQ(SK_ColorBLUE, GetColorAt(target_canvas(), kWidth - 1, |
- kHeight - 1)); |
+ EXPECT_EQ(SK_ColorBLUE, GetColorAt(target_canvas(), kWidth - 1, kHeight - 1)); |
// Check the interior along the border between color regions. Note that we're |
// bilinearly upscaling, so we'll need to take care to pick sample points that |
// are just outside the "zone of resampling". |
- EXPECT_EQ(SK_ColorBLACK, GetColorAt(target_canvas(), kWidth * 1 / 8 - 1, |
- kHeight * 1 / 6 - 1)); |
- EXPECT_EQ(SK_ColorRED, GetColorAt(target_canvas(), kWidth * 3 / 8, |
- kHeight * 1 / 6 - 1)); |
- EXPECT_EQ(SK_ColorGREEN, GetColorAt(target_canvas(), kWidth * 1 / 8 - 1, |
- kHeight * 3 / 6)); |
- EXPECT_EQ(SK_ColorBLUE, GetColorAt(target_canvas(), kWidth * 3 / 8, |
- kHeight * 3 / 6)); |
+ EXPECT_EQ( |
+ SK_ColorBLACK, |
+ GetColorAt(target_canvas(), kWidth * 1 / 8 - 1, kHeight * 1 / 6 - 1)); |
+ EXPECT_EQ(SK_ColorRED, |
+ GetColorAt(target_canvas(), kWidth * 3 / 8, kHeight * 1 / 6 - 1)); |
+ EXPECT_EQ(SK_ColorGREEN, |
+ GetColorAt(target_canvas(), kWidth * 1 / 8 - 1, kHeight * 3 / 6)); |
+ EXPECT_EQ(SK_ColorBLUE, |
+ GetColorAt(target_canvas(), kWidth * 3 / 8, kHeight * 3 / 6)); |
} |
TEST_F(SkCanvasVideoRendererTest, CroppedFrame_NoScaling) { |
@@ -311,4 +308,4 @@ TEST_F(SkCanvasVideoRendererTest, CroppedFrame_NoScaling) { |
offset_y + crop_rect.height() - 1)); |
} |
-} // namespace media |
+} // namespace cc |