Fix the Android Mandoline ui build.
[chromium-blink-merge.git] / media / blink / skcanvas_video_renderer_unittest.cc
blob3062d77164c3ab619a25fa15380ecf0b31666457
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
3 // found in the LICENSE file.
5 #include "base/message_loop/message_loop.h"
6 #include "media/base/video_frame.h"
7 #include "media/base/video_util.h"
8 #include "media/blink/skcanvas_video_renderer.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/skia/include/core/SkCanvas.h"
12 using media::VideoFrame;
14 namespace media {
16 static const int kWidth = 320;
17 static const int kHeight = 240;
18 static const gfx::Rect kNaturalRect(0, 0, kWidth, kHeight);
20 // Helper for filling a |canvas| with a solid |color|.
21 void FillCanvas(SkCanvas* canvas, SkColor color) {
22 canvas->clear(color);
25 // Helper for returning the color of a solid |canvas|.
26 SkColor GetColorAt(SkCanvas* canvas, int x, int y) {
27 SkBitmap bitmap;
28 if (!bitmap.tryAllocN32Pixels(1, 1))
29 return 0;
30 if (!canvas->readPixels(&bitmap, x, y))
31 return 0;
32 return bitmap.getColor(0, 0);
35 SkColor GetColor(SkCanvas* canvas) {
36 return GetColorAt(canvas, 0, 0);
39 class SkCanvasVideoRendererTest : public testing::Test {
40 public:
41 enum Color {
42 kNone,
43 kRed,
44 kGreen,
45 kBlue,
48 SkCanvasVideoRendererTest();
49 ~SkCanvasVideoRendererTest() override;
51 // Paints to |canvas| using |renderer_| without any frame data.
52 void PaintWithoutFrame(SkCanvas* canvas);
54 // Paints the |video_frame| to the |canvas| using |renderer_|, setting the
55 // color of |video_frame| to |color| first.
56 void Paint(const scoped_refptr<VideoFrame>& video_frame,
57 SkCanvas* canvas,
58 Color color);
59 void PaintRotated(const scoped_refptr<VideoFrame>& video_frame,
60 SkCanvas* canvas,
61 const gfx::RectF& dest_rect,
62 Color color,
63 SkXfermode::Mode mode,
64 VideoRotation video_rotation);
66 void Copy(const scoped_refptr<VideoFrame>& video_frame, SkCanvas* canvas);
68 // Getters for various frame sizes.
69 scoped_refptr<VideoFrame> natural_frame() { return natural_frame_; }
70 scoped_refptr<VideoFrame> larger_frame() { return larger_frame_; }
71 scoped_refptr<VideoFrame> smaller_frame() { return smaller_frame_; }
72 scoped_refptr<VideoFrame> cropped_frame() { return cropped_frame_; }
74 // Standard canvas.
75 SkCanvas* target_canvas() { return &target_canvas_; }
77 private:
78 SkCanvasVideoRenderer renderer_;
80 scoped_refptr<VideoFrame> natural_frame_;
81 scoped_refptr<VideoFrame> larger_frame_;
82 scoped_refptr<VideoFrame> smaller_frame_;
83 scoped_refptr<VideoFrame> cropped_frame_;
85 SkCanvas target_canvas_;
86 base::MessageLoop message_loop_;
88 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRendererTest);
91 static SkBitmap AllocBitmap(int width, int height) {
92 SkBitmap bitmap;
93 bitmap.allocPixels(SkImageInfo::MakeN32(width, height, kPremul_SkAlphaType));
94 bitmap.eraseColor(0);
95 return bitmap;
98 SkCanvasVideoRendererTest::SkCanvasVideoRendererTest()
99 : natural_frame_(VideoFrame::CreateBlackFrame(gfx::Size(kWidth, kHeight))),
100 larger_frame_(VideoFrame::CreateBlackFrame(
101 gfx::Size(kWidth * 2, kHeight * 2))),
102 smaller_frame_(VideoFrame::CreateBlackFrame(
103 gfx::Size(kWidth / 2, kHeight / 2))),
104 cropped_frame_(VideoFrame::CreateFrame(
105 VideoFrame::YV12,
106 gfx::Size(16, 16),
107 gfx::Rect(6, 6, 8, 6),
108 gfx::Size(8, 6),
109 base::TimeDelta::FromMilliseconds(4))),
110 target_canvas_(AllocBitmap(kWidth, kHeight)) {
111 // Give each frame a unique timestamp.
112 natural_frame_->set_timestamp(base::TimeDelta::FromMilliseconds(1));
113 larger_frame_->set_timestamp(base::TimeDelta::FromMilliseconds(2));
114 smaller_frame_->set_timestamp(base::TimeDelta::FromMilliseconds(3));
116 // Make sure the cropped video frame's aspect ratio matches the output device.
117 // Update cropped_frame_'s crop dimensions if this is not the case.
118 EXPECT_EQ(cropped_frame()->visible_rect().width() * kHeight,
119 cropped_frame()->visible_rect().height() * kWidth);
121 // Fill in the cropped frame's entire data with colors:
123 // Bl Bl Bl Bl Bl Bl Bl Bl R R R R R R R R
124 // Bl Bl Bl Bl Bl Bl Bl Bl R R R R R R R R
125 // Bl Bl Bl Bl Bl Bl Bl Bl R R R R R R R R
126 // Bl Bl Bl Bl Bl Bl Bl Bl R R R R R R R R
127 // Bl Bl Bl Bl Bl Bl Bl Bl R R R R R R R R
128 // Bl Bl Bl Bl Bl Bl Bl Bl R R R R R R R R
129 // Bl Bl Bl Bl Bl Bl Bl Bl R R R R R R R R
130 // Bl Bl Bl Bl Bl Bl Bl Bl R R R R R R R R
131 // G G G G G G G G B B B B B B B B
132 // G G G G G G G G B B B B B B B B
133 // G G G G G G G G B B B B B B B B
134 // G G G G G G G G B B B B B B B B
135 // G G G G G G G G B B B B B B B B
136 // G G G G G G G G B B B B B B B B
137 // G G G G G G G G B B B B B B B B
138 // G G G G G G G G B B B B B B B B
140 // The visible crop of the frame (as set by its visible_rect_) has contents:
142 // Bl Bl R R R R R R
143 // Bl Bl R R R R R R
144 // G G B B B B B B
145 // G G B B B B B B
146 // G G B B B B B B
147 // G G B B B B B B
149 // Each color region in the cropped frame is on a 2x2 block granularity, to
150 // avoid sharing UV samples between regions.
152 static const uint8 cropped_y_plane[] = {
153 0, 0, 0, 0, 0, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 76,
154 0, 0, 0, 0, 0, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 76,
155 0, 0, 0, 0, 0, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 76,
156 0, 0, 0, 0, 0, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 76,
157 0, 0, 0, 0, 0, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 76,
158 0, 0, 0, 0, 0, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 76,
159 0, 0, 0, 0, 0, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 76,
160 0, 0, 0, 0, 0, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 76,
161 149, 149, 149, 149, 149, 149, 149, 149, 29, 29, 29, 29, 29, 29, 29, 29,
162 149, 149, 149, 149, 149, 149, 149, 149, 29, 29, 29, 29, 29, 29, 29, 29,
163 149, 149, 149, 149, 149, 149, 149, 149, 29, 29, 29, 29, 29, 29, 29, 29,
164 149, 149, 149, 149, 149, 149, 149, 149, 29, 29, 29, 29, 29, 29, 29, 29,
165 149, 149, 149, 149, 149, 149, 149, 149, 29, 29, 29, 29, 29, 29, 29, 29,
166 149, 149, 149, 149, 149, 149, 149, 149, 29, 29, 29, 29, 29, 29, 29, 29,
167 149, 149, 149, 149, 149, 149, 149, 149, 29, 29, 29, 29, 29, 29, 29, 29,
168 149, 149, 149, 149, 149, 149, 149, 149, 29, 29, 29, 29, 29, 29, 29, 29,
171 static const uint8 cropped_u_plane[] = {
172 128, 128, 128, 128, 84, 84, 84, 84,
173 128, 128, 128, 128, 84, 84, 84, 84,
174 128, 128, 128, 128, 84, 84, 84, 84,
175 128, 128, 128, 128, 84, 84, 84, 84,
176 43, 43, 43, 43, 255, 255, 255, 255,
177 43, 43, 43, 43, 255, 255, 255, 255,
178 43, 43, 43, 43, 255, 255, 255, 255,
179 43, 43, 43, 43, 255, 255, 255, 255,
181 static const uint8 cropped_v_plane[] = {
182 128, 128, 128, 128, 255, 255, 255, 255,
183 128, 128, 128, 128, 255, 255, 255, 255,
184 128, 128, 128, 128, 255, 255, 255, 255,
185 128, 128, 128, 128, 255, 255, 255, 255,
186 21, 21, 21, 21, 107, 107, 107, 107,
187 21, 21, 21, 21, 107, 107, 107, 107,
188 21, 21, 21, 21, 107, 107, 107, 107,
189 21, 21, 21, 21, 107, 107, 107, 107,
192 media::CopyYPlane(cropped_y_plane, 16, 16, cropped_frame().get());
193 media::CopyUPlane(cropped_u_plane, 8, 8, cropped_frame().get());
194 media::CopyVPlane(cropped_v_plane, 8, 8, cropped_frame().get());
197 SkCanvasVideoRendererTest::~SkCanvasVideoRendererTest() {}
199 void SkCanvasVideoRendererTest::PaintWithoutFrame(SkCanvas* canvas) {
200 renderer_.Paint(nullptr, canvas, kNaturalRect, 0xFF,
201 SkXfermode::kSrcOver_Mode, VIDEO_ROTATION_0, Context3D());
204 void SkCanvasVideoRendererTest::Paint(
205 const scoped_refptr<VideoFrame>& video_frame,
206 SkCanvas* canvas,
207 Color color) {
208 PaintRotated(video_frame,
209 canvas,
210 kNaturalRect,
211 color,
212 SkXfermode::kSrcOver_Mode,
213 VIDEO_ROTATION_0);
216 void SkCanvasVideoRendererTest::PaintRotated(
217 const scoped_refptr<VideoFrame>& video_frame,
218 SkCanvas* canvas,
219 const gfx::RectF& dest_rect,
220 Color color,
221 SkXfermode::Mode mode,
222 VideoRotation video_rotation) {
223 switch (color) {
224 case kNone:
225 break;
226 case kRed:
227 media::FillYUV(video_frame.get(), 76, 84, 255);
228 break;
229 case kGreen:
230 media::FillYUV(video_frame.get(), 149, 43, 21);
231 break;
232 case kBlue:
233 media::FillYUV(video_frame.get(), 29, 255, 107);
234 break;
236 renderer_.Paint(video_frame, canvas, dest_rect, 0xFF, mode, video_rotation,
237 Context3D());
240 void SkCanvasVideoRendererTest::Copy(
241 const scoped_refptr<VideoFrame>& video_frame,
242 SkCanvas* canvas) {
243 renderer_.Copy(video_frame, canvas, Context3D());
246 TEST_F(SkCanvasVideoRendererTest, NoFrame) {
247 // Test that black gets painted over canvas.
248 FillCanvas(target_canvas(), SK_ColorRED);
249 PaintWithoutFrame(target_canvas());
250 EXPECT_EQ(SK_ColorBLACK, GetColor(target_canvas()));
253 TEST_F(SkCanvasVideoRendererTest, TransparentFrame) {
254 FillCanvas(target_canvas(), SK_ColorRED);
255 PaintRotated(
256 VideoFrame::CreateTransparentFrame(gfx::Size(kWidth, kHeight)).get(),
257 target_canvas(),
258 kNaturalRect,
259 kNone,
260 SkXfermode::kSrcOver_Mode,
261 VIDEO_ROTATION_0);
262 EXPECT_EQ(static_cast<SkColor>(SK_ColorRED), GetColor(target_canvas()));
265 TEST_F(SkCanvasVideoRendererTest, TransparentFrameSrcMode) {
266 FillCanvas(target_canvas(), SK_ColorRED);
267 // SRC mode completely overwrites the buffer.
268 PaintRotated(
269 VideoFrame::CreateTransparentFrame(gfx::Size(kWidth, kHeight)).get(),
270 target_canvas(),
271 kNaturalRect,
272 kNone,
273 SkXfermode::kSrc_Mode,
274 VIDEO_ROTATION_0);
275 EXPECT_EQ(static_cast<SkColor>(SK_ColorTRANSPARENT),
276 GetColor(target_canvas()));
279 TEST_F(SkCanvasVideoRendererTest, CopyTransparentFrame) {
280 FillCanvas(target_canvas(), SK_ColorRED);
281 Copy(VideoFrame::CreateTransparentFrame(gfx::Size(kWidth, kHeight)).get(),
282 target_canvas());
283 EXPECT_EQ(static_cast<SkColor>(SK_ColorTRANSPARENT),
284 GetColor(target_canvas()));
287 TEST_F(SkCanvasVideoRendererTest, Natural) {
288 Paint(natural_frame(), target_canvas(), kRed);
289 EXPECT_EQ(SK_ColorRED, GetColor(target_canvas()));
292 TEST_F(SkCanvasVideoRendererTest, Larger) {
293 Paint(natural_frame(), target_canvas(), kRed);
294 EXPECT_EQ(SK_ColorRED, GetColor(target_canvas()));
296 Paint(larger_frame(), target_canvas(), kBlue);
297 EXPECT_EQ(SK_ColorBLUE, GetColor(target_canvas()));
300 TEST_F(SkCanvasVideoRendererTest, Smaller) {
301 Paint(natural_frame(), target_canvas(), kRed);
302 EXPECT_EQ(SK_ColorRED, GetColor(target_canvas()));
304 Paint(smaller_frame(), target_canvas(), kBlue);
305 EXPECT_EQ(SK_ColorBLUE, GetColor(target_canvas()));
308 TEST_F(SkCanvasVideoRendererTest, NoTimestamp) {
309 VideoFrame* video_frame = natural_frame().get();
310 video_frame->set_timestamp(media::kNoTimestamp());
311 Paint(video_frame, target_canvas(), kRed);
312 EXPECT_EQ(SK_ColorRED, GetColor(target_canvas()));
315 TEST_F(SkCanvasVideoRendererTest, SameVideoFrame) {
316 Paint(natural_frame(), target_canvas(), kRed);
317 EXPECT_EQ(SK_ColorRED, GetColor(target_canvas()));
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()));
324 TEST_F(SkCanvasVideoRendererTest, CroppedFrame) {
325 Paint(cropped_frame(), target_canvas(), kNone);
326 // Check the corners.
327 EXPECT_EQ(SK_ColorBLACK, GetColorAt(target_canvas(), 0, 0));
328 EXPECT_EQ(SK_ColorRED, GetColorAt(target_canvas(), kWidth - 1, 0));
329 EXPECT_EQ(SK_ColorGREEN, GetColorAt(target_canvas(), 0, kHeight - 1));
330 EXPECT_EQ(SK_ColorBLUE, GetColorAt(target_canvas(), kWidth - 1,
331 kHeight - 1));
332 // 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
334 // are just outside the "zone of resampling".
335 EXPECT_EQ(SK_ColorBLACK, GetColorAt(target_canvas(), kWidth * 1 / 8 - 1,
336 kHeight * 1 / 6 - 1));
337 EXPECT_EQ(SK_ColorRED, GetColorAt(target_canvas(), kWidth * 3 / 8,
338 kHeight * 1 / 6 - 1));
339 EXPECT_EQ(SK_ColorGREEN, GetColorAt(target_canvas(), kWidth * 1 / 8 - 1,
340 kHeight * 3 / 6));
341 EXPECT_EQ(SK_ColorBLUE, GetColorAt(target_canvas(), kWidth * 3 / 8,
342 kHeight * 3 / 6));
345 TEST_F(SkCanvasVideoRendererTest, CroppedFrame_NoScaling) {
346 SkCanvas canvas(AllocBitmap(kWidth, kHeight));
347 const gfx::Rect crop_rect = cropped_frame()->visible_rect();
349 // Force painting to a non-zero position on the destination bitmap, to check
350 // if the coordinates are calculated properly.
351 const int offset_x = 10;
352 const int offset_y = 15;
353 canvas.translate(offset_x, offset_y);
355 // Create a destination canvas with dimensions and scale which would not
356 // cause scaling.
357 canvas.scale(static_cast<SkScalar>(crop_rect.width()) / kWidth,
358 static_cast<SkScalar>(crop_rect.height()) / kHeight);
360 Paint(cropped_frame(), &canvas, kNone);
362 // Check the corners.
363 EXPECT_EQ(SK_ColorBLACK, GetColorAt(&canvas, offset_x, offset_y));
364 EXPECT_EQ(SK_ColorRED,
365 GetColorAt(&canvas, offset_x + crop_rect.width() - 1, offset_y));
366 EXPECT_EQ(SK_ColorGREEN,
367 GetColorAt(&canvas, offset_x, offset_y + crop_rect.height() - 1));
368 EXPECT_EQ(SK_ColorBLUE,
369 GetColorAt(&canvas,
370 offset_x + crop_rect.width() - 1,
371 offset_y + crop_rect.height() - 1));
374 TEST_F(SkCanvasVideoRendererTest, Video_Rotation_90) {
375 SkCanvas canvas(AllocBitmap(kWidth, kHeight));
376 PaintRotated(cropped_frame(),
377 &canvas,
378 kNaturalRect,
379 kNone,
380 SkXfermode::kSrcOver_Mode,
381 VIDEO_ROTATION_90);
382 // Check the corners.
383 EXPECT_EQ(SK_ColorGREEN, GetColorAt(&canvas, 0, 0));
384 EXPECT_EQ(SK_ColorBLACK, GetColorAt(&canvas, kWidth - 1, 0));
385 EXPECT_EQ(SK_ColorRED, GetColorAt(&canvas, kWidth - 1, kHeight - 1));
386 EXPECT_EQ(SK_ColorBLUE, GetColorAt(&canvas, 0, kHeight - 1));
389 TEST_F(SkCanvasVideoRendererTest, Video_Rotation_180) {
390 SkCanvas canvas(AllocBitmap(kWidth, kHeight));
391 PaintRotated(cropped_frame(),
392 &canvas,
393 kNaturalRect,
394 kNone,
395 SkXfermode::kSrcOver_Mode,
396 VIDEO_ROTATION_180);
397 // Check the corners.
398 EXPECT_EQ(SK_ColorBLUE, GetColorAt(&canvas, 0, 0));
399 EXPECT_EQ(SK_ColorGREEN, GetColorAt(&canvas, kWidth - 1, 0));
400 EXPECT_EQ(SK_ColorBLACK, GetColorAt(&canvas, kWidth - 1, kHeight - 1));
401 EXPECT_EQ(SK_ColorRED, GetColorAt(&canvas, 0, kHeight - 1));
404 TEST_F(SkCanvasVideoRendererTest, Video_Rotation_270) {
405 SkCanvas canvas(AllocBitmap(kWidth, kHeight));
406 PaintRotated(cropped_frame(),
407 &canvas,
408 kNaturalRect,
409 kNone,
410 SkXfermode::kSrcOver_Mode,
411 VIDEO_ROTATION_270);
412 // Check the corners.
413 EXPECT_EQ(SK_ColorRED, GetColorAt(&canvas, 0, 0));
414 EXPECT_EQ(SK_ColorBLUE, GetColorAt(&canvas, kWidth - 1, 0));
415 EXPECT_EQ(SK_ColorGREEN, GetColorAt(&canvas, kWidth - 1, kHeight - 1));
416 EXPECT_EQ(SK_ColorBLACK, GetColorAt(&canvas, 0, kHeight - 1));
419 TEST_F(SkCanvasVideoRendererTest, Video_Translate) {
420 SkCanvas canvas(AllocBitmap(kWidth, kHeight));
421 FillCanvas(&canvas, SK_ColorMAGENTA);
423 PaintRotated(cropped_frame(),
424 &canvas,
425 gfx::Rect(kWidth / 2, kHeight / 2, kWidth / 2, kHeight / 2),
426 kNone,
427 SkXfermode::kSrcOver_Mode,
428 VIDEO_ROTATION_0);
429 // Check the corners of quadrant 2 and 4.
430 EXPECT_EQ(SK_ColorMAGENTA, GetColorAt(&canvas, 0, 0));
431 EXPECT_EQ(SK_ColorMAGENTA, GetColorAt(&canvas, (kWidth / 2) - 1, 0));
432 EXPECT_EQ(SK_ColorMAGENTA,
433 GetColorAt(&canvas, (kWidth / 2) - 1, (kHeight / 2) - 1));
434 EXPECT_EQ(SK_ColorMAGENTA, GetColorAt(&canvas, 0, (kHeight / 2) - 1));
435 EXPECT_EQ(SK_ColorBLACK, GetColorAt(&canvas, kWidth / 2, kHeight / 2));
436 EXPECT_EQ(SK_ColorRED, GetColorAt(&canvas, kWidth - 1, kHeight / 2));
437 EXPECT_EQ(SK_ColorBLUE, GetColorAt(&canvas, kWidth - 1, kHeight - 1));
438 EXPECT_EQ(SK_ColorGREEN, GetColorAt(&canvas, kWidth / 2, kHeight - 1));
441 TEST_F(SkCanvasVideoRendererTest, Video_Translate_Rotation_90) {
442 SkCanvas canvas(AllocBitmap(kWidth, kHeight));
443 FillCanvas(&canvas, SK_ColorMAGENTA);
445 const gfx::Rect crop_rect = cropped_frame()->visible_rect();
446 PaintRotated(cropped_frame(),
447 &canvas,
448 gfx::Rect(kWidth / 2, kHeight / 2, kWidth / 2, kHeight / 2),
449 kNone,
450 SkXfermode::kSrcOver_Mode,
451 VIDEO_ROTATION_90);
452 // Check the corners of quadrant 2 and 4.
453 EXPECT_EQ(SK_ColorMAGENTA, GetColorAt(&canvas, 0, 0));
454 EXPECT_EQ(SK_ColorMAGENTA, GetColorAt(&canvas, (kWidth / 2) - 1, 0));
455 EXPECT_EQ(SK_ColorMAGENTA,
456 GetColorAt(&canvas, (kWidth / 2) - 1, (kHeight / 2) - 1));
457 EXPECT_EQ(SK_ColorMAGENTA, GetColorAt(&canvas, 0, (kHeight / 2) - 1));
458 EXPECT_EQ(SK_ColorGREEN, GetColorAt(&canvas, kWidth / 2, kHeight / 2));
459 EXPECT_EQ(SK_ColorBLACK, GetColorAt(&canvas, kWidth - 1, kHeight / 2));
460 EXPECT_EQ(SK_ColorRED, GetColorAt(&canvas, kWidth - 1, kHeight - 1));
461 EXPECT_EQ(SK_ColorBLUE, GetColorAt(&canvas, kWidth / 2, kHeight - 1));
464 TEST_F(SkCanvasVideoRendererTest, Video_Translate_Rotation_180) {
465 SkCanvas canvas(AllocBitmap(kWidth, kHeight));
466 FillCanvas(&canvas, SK_ColorMAGENTA);
468 PaintRotated(cropped_frame(),
469 &canvas,
470 gfx::Rect(kWidth / 2, kHeight / 2, kWidth / 2, kHeight / 2),
471 kNone,
472 SkXfermode::kSrcOver_Mode,
473 VIDEO_ROTATION_180);
474 // Check the corners of quadrant 2 and 4.
475 EXPECT_EQ(SK_ColorMAGENTA, GetColorAt(&canvas, 0, 0));
476 EXPECT_EQ(SK_ColorMAGENTA, GetColorAt(&canvas, (kWidth / 2) - 1, 0));
477 EXPECT_EQ(SK_ColorMAGENTA,
478 GetColorAt(&canvas, (kWidth / 2) - 1, (kHeight / 2) - 1));
479 EXPECT_EQ(SK_ColorMAGENTA, GetColorAt(&canvas, 0, (kHeight / 2) - 1));
480 EXPECT_EQ(SK_ColorBLUE, GetColorAt(&canvas, kWidth / 2, kHeight / 2));
481 EXPECT_EQ(SK_ColorGREEN, GetColorAt(&canvas, kWidth - 1, kHeight / 2));
482 EXPECT_EQ(SK_ColorBLACK, GetColorAt(&canvas, kWidth - 1, kHeight - 1));
483 EXPECT_EQ(SK_ColorRED, GetColorAt(&canvas, kWidth / 2, kHeight - 1));
486 TEST_F(SkCanvasVideoRendererTest, Video_Translate_Rotation_270) {
487 SkCanvas canvas(AllocBitmap(kWidth, kHeight));
488 FillCanvas(&canvas, SK_ColorMAGENTA);
490 PaintRotated(cropped_frame(),
491 &canvas,
492 gfx::Rect(kWidth / 2, kHeight / 2, kWidth / 2, kHeight / 2),
493 kNone,
494 SkXfermode::kSrcOver_Mode,
495 VIDEO_ROTATION_270);
496 // Check the corners of quadrant 2 and 4.
497 EXPECT_EQ(SK_ColorMAGENTA, GetColorAt(&canvas, 0, 0));
498 EXPECT_EQ(SK_ColorMAGENTA, GetColorAt(&canvas, (kWidth / 2) - 1, 0));
499 EXPECT_EQ(SK_ColorMAGENTA,
500 GetColorAt(&canvas, (kWidth / 2) - 1, (kHeight / 2) - 1));
501 EXPECT_EQ(SK_ColorMAGENTA, GetColorAt(&canvas, 0, (kHeight / 2) - 1));
502 EXPECT_EQ(SK_ColorRED, GetColorAt(&canvas, kWidth / 2, kHeight / 2));
503 EXPECT_EQ(SK_ColorBLUE, GetColorAt(&canvas, kWidth - 1, kHeight / 2));
504 EXPECT_EQ(SK_ColorGREEN, GetColorAt(&canvas, kWidth - 1, kHeight - 1));
505 EXPECT_EQ(SK_ColorBLACK, GetColorAt(&canvas, kWidth / 2, kHeight - 1));
508 } // namespace media