OLD | NEW |
---|---|
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 #include "media/base/video_util.h" | 6 #include "media/base/video_util.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "third_party/skia/include/core/SkCanvas.h" | 8 #include "third_party/skia/include/core/SkCanvas.h" |
9 #include "third_party/skia/include/core/SkDevice.h" | 9 #include "third_party/skia/include/core/SkDevice.h" |
10 #include "webkit/media/skcanvas_video_renderer.h" | 10 #include "webkit/media/skcanvas_video_renderer.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 case kRed: | 102 case kRed: |
103 media::FillYUV(video_frame, 76, 84, 255); | 103 media::FillYUV(video_frame, 76, 84, 255); |
104 break; | 104 break; |
105 case kBlue: | 105 case kBlue: |
106 media::FillYUV(video_frame, 29, 255, 107); | 106 media::FillYUV(video_frame, 29, 255, 107); |
107 break; | 107 break; |
108 } | 108 } |
109 renderer_.Paint(video_frame, canvas, kNaturalRect, 0xFF); | 109 renderer_.Paint(video_frame, canvas, kNaturalRect, 0xFF); |
110 } | 110 } |
111 | 111 |
112 inline uint32_t SetPackedColor(uint8_t a, uint8_t r, uint8_t g, uint8_t b) { | |
113 return (a << SK_A32_SHIFT) | (r << SK_R32_SHIFT) | | |
114 (g << SK_G32_SHIFT) | (b << SK_B32_SHIFT); | |
115 } | |
116 | |
117 #define ColorRed SetPackedColor(0xFF, 0xFF, 0x00, 0x00) | |
118 #define ColorGreen SetPackedColor(0xFF, 0x00, 0xFF, 0x00) | |
119 #define ColorBlue SetPackedColor(0xFF, 0x00, 0x00, 0xFF) | |
120 | |
112 TEST_F(SkCanvasVideoRendererTest, FastPaint_NoFrame) { | 121 TEST_F(SkCanvasVideoRendererTest, FastPaint_NoFrame) { |
113 // Test that black gets painted over canvas. | 122 // Test that black gets painted over canvas. |
114 FillCanvas(fast_path_canvas(), SK_ColorRED); | 123 FillCanvas(fast_path_canvas(), SK_ColorRED); |
115 PaintWithoutFrame(fast_path_canvas()); | 124 PaintWithoutFrame(fast_path_canvas()); |
116 EXPECT_EQ(SK_ColorBLACK, GetColor(fast_path_canvas())); | 125 EXPECT_EQ(SK_ColorBLACK, GetColor(fast_path_canvas())); |
117 } | 126 } |
118 | 127 |
119 TEST_F(SkCanvasVideoRendererTest, SlowPaint_NoFrame) { | 128 TEST_F(SkCanvasVideoRendererTest, SlowPaint_NoFrame) { |
120 // Test that black gets painted over canvas. | 129 // Test that black gets painted over canvas. |
121 FillCanvas(slow_path_canvas(), SK_ColorRED); | 130 FillCanvas(slow_path_canvas(), SK_ColorRED); |
122 PaintWithoutFrame(slow_path_canvas()); | 131 PaintWithoutFrame(slow_path_canvas()); |
123 EXPECT_EQ(SK_ColorBLACK, GetColor(slow_path_canvas())); | 132 EXPECT_EQ(SK_ColorBLACK, GetColor(slow_path_canvas())); |
124 } | 133 } |
125 | 134 |
126 TEST_F(SkCanvasVideoRendererTest, FastPaint_Natural) { | 135 TEST_F(SkCanvasVideoRendererTest, FastPaint_Natural) { |
127 Paint(natural_frame(), fast_path_canvas(), kRed); | 136 Paint(natural_frame(), fast_path_canvas(), kRed); |
128 EXPECT_EQ(SK_ColorRED, GetColor(fast_path_canvas())); | 137 EXPECT_EQ(ColorRed, GetColor(fast_path_canvas())); |
Ami GONE FROM CHROMIUM
2012/07/26 17:20:03
I don't know skia very much at all, but skimming t
yongsheng
2012/08/06 06:37:21
yes, i think you're right after I read the code in
| |
129 } | 138 } |
130 | 139 |
131 TEST_F(SkCanvasVideoRendererTest, SlowPaint_Natural) { | 140 TEST_F(SkCanvasVideoRendererTest, SlowPaint_Natural) { |
132 Paint(natural_frame(), slow_path_canvas(), kRed); | 141 Paint(natural_frame(), slow_path_canvas(), kRed); |
133 EXPECT_EQ(SK_ColorRED, GetColor(slow_path_canvas())); | 142 EXPECT_EQ(ColorRed, GetColor(slow_path_canvas())); |
134 } | 143 } |
135 | 144 |
136 TEST_F(SkCanvasVideoRendererTest, FastPaint_Larger) { | 145 TEST_F(SkCanvasVideoRendererTest, FastPaint_Larger) { |
137 Paint(natural_frame(), fast_path_canvas(), kRed); | 146 Paint(natural_frame(), fast_path_canvas(), kRed); |
138 EXPECT_EQ(SK_ColorRED, GetColor(fast_path_canvas())); | 147 EXPECT_EQ(ColorRed, GetColor(fast_path_canvas())); |
139 | 148 |
140 Paint(larger_frame(), fast_path_canvas(), kBlue); | 149 Paint(larger_frame(), fast_path_canvas(), kBlue); |
141 EXPECT_EQ(SK_ColorBLUE, GetColor(fast_path_canvas())); | 150 EXPECT_EQ(ColorBlue, GetColor(fast_path_canvas())); |
142 } | 151 } |
143 | 152 |
144 TEST_F(SkCanvasVideoRendererTest, SlowPaint_Larger) { | 153 TEST_F(SkCanvasVideoRendererTest, SlowPaint_Larger) { |
145 Paint(natural_frame(), slow_path_canvas(), kRed); | 154 Paint(natural_frame(), slow_path_canvas(), kRed); |
146 EXPECT_EQ(SK_ColorRED, GetColor(slow_path_canvas())); | 155 EXPECT_EQ(ColorRed, GetColor(slow_path_canvas())); |
147 | 156 |
148 Paint(larger_frame(), slow_path_canvas(), kBlue); | 157 Paint(larger_frame(), slow_path_canvas(), kBlue); |
149 EXPECT_EQ(SK_ColorBLUE, GetColor(slow_path_canvas())); | 158 EXPECT_EQ(ColorBlue, GetColor(slow_path_canvas())); |
150 } | 159 } |
151 | 160 |
152 TEST_F(SkCanvasVideoRendererTest, FastPaint_Smaller) { | 161 TEST_F(SkCanvasVideoRendererTest, FastPaint_Smaller) { |
153 Paint(natural_frame(), fast_path_canvas(), kRed); | 162 Paint(natural_frame(), fast_path_canvas(), kRed); |
154 EXPECT_EQ(SK_ColorRED, GetColor(fast_path_canvas())); | 163 EXPECT_EQ(ColorRed, GetColor(fast_path_canvas())); |
155 | 164 |
156 Paint(smaller_frame(), fast_path_canvas(), kBlue); | 165 Paint(smaller_frame(), fast_path_canvas(), kBlue); |
157 EXPECT_EQ(SK_ColorBLUE, GetColor(fast_path_canvas())); | 166 EXPECT_EQ(ColorBlue, GetColor(fast_path_canvas())); |
158 } | 167 } |
159 | 168 |
160 TEST_F(SkCanvasVideoRendererTest, SlowPaint_Smaller) { | 169 TEST_F(SkCanvasVideoRendererTest, SlowPaint_Smaller) { |
161 Paint(natural_frame(), slow_path_canvas(), kRed); | 170 Paint(natural_frame(), slow_path_canvas(), kRed); |
162 EXPECT_EQ(SK_ColorRED, GetColor(slow_path_canvas())); | 171 EXPECT_EQ(ColorRed, GetColor(slow_path_canvas())); |
163 | 172 |
164 Paint(smaller_frame(), slow_path_canvas(), kBlue); | 173 Paint(smaller_frame(), slow_path_canvas(), kBlue); |
165 EXPECT_EQ(SK_ColorBLUE, GetColor(slow_path_canvas())); | 174 EXPECT_EQ(ColorBlue, GetColor(slow_path_canvas())); |
166 } | 175 } |
167 | 176 |
168 TEST_F(SkCanvasVideoRendererTest, FastPaint_NoTimestamp) { | 177 TEST_F(SkCanvasVideoRendererTest, FastPaint_NoTimestamp) { |
169 VideoFrame* video_frame = natural_frame(); | 178 VideoFrame* video_frame = natural_frame(); |
170 video_frame->SetTimestamp(media::kNoTimestamp()); | 179 video_frame->SetTimestamp(media::kNoTimestamp()); |
171 Paint(video_frame, fast_path_canvas(), kRed); | 180 Paint(video_frame, fast_path_canvas(), kRed); |
172 EXPECT_EQ(SK_ColorRED, GetColor(fast_path_canvas())); | 181 EXPECT_EQ(ColorRed, GetColor(fast_path_canvas())); |
173 } | 182 } |
174 | 183 |
175 TEST_F(SkCanvasVideoRendererTest, SlowPaint_NoTimestamp) { | 184 TEST_F(SkCanvasVideoRendererTest, SlowPaint_NoTimestamp) { |
176 VideoFrame* video_frame = natural_frame(); | 185 VideoFrame* video_frame = natural_frame(); |
177 video_frame->SetTimestamp(media::kNoTimestamp()); | 186 video_frame->SetTimestamp(media::kNoTimestamp()); |
178 Paint(video_frame, slow_path_canvas(), kRed); | 187 Paint(video_frame, slow_path_canvas(), kRed); |
179 EXPECT_EQ(SK_ColorRED, GetColor(slow_path_canvas())); | 188 EXPECT_EQ(ColorRed, GetColor(slow_path_canvas())); |
180 } | 189 } |
181 | 190 |
182 TEST_F(SkCanvasVideoRendererTest, FastPaint_SameVideoFrame) { | 191 TEST_F(SkCanvasVideoRendererTest, FastPaint_SameVideoFrame) { |
183 Paint(natural_frame(), fast_path_canvas(), kRed); | 192 Paint(natural_frame(), fast_path_canvas(), kRed); |
184 EXPECT_EQ(SK_ColorRED, GetColor(fast_path_canvas())); | 193 EXPECT_EQ(ColorRed, GetColor(fast_path_canvas())); |
185 | 194 |
186 // Fast paints always get painted to the canvas. | 195 // Fast paints always get painted to the canvas. |
187 Paint(natural_frame(), fast_path_canvas(), kBlue); | 196 Paint(natural_frame(), fast_path_canvas(), kBlue); |
188 EXPECT_EQ(SK_ColorBLUE, GetColor(fast_path_canvas())); | 197 EXPECT_EQ(ColorBlue, GetColor(fast_path_canvas())); |
189 } | 198 } |
190 | 199 |
191 TEST_F(SkCanvasVideoRendererTest, SlowPaint_SameVideoFrame) { | 200 TEST_F(SkCanvasVideoRendererTest, SlowPaint_SameVideoFrame) { |
192 Paint(natural_frame(), slow_path_canvas(), kRed); | 201 Paint(natural_frame(), slow_path_canvas(), kRed); |
193 EXPECT_EQ(SK_ColorRED, GetColor(slow_path_canvas())); | 202 EXPECT_EQ(ColorRed, GetColor(slow_path_canvas())); |
194 | 203 |
195 // Slow paints can get cached, expect the old color value. | 204 // Slow paints can get cached, expect the old color value. |
196 Paint(natural_frame(), slow_path_canvas(), kBlue); | 205 Paint(natural_frame(), slow_path_canvas(), kBlue); |
197 EXPECT_EQ(SK_ColorRED, GetColor(slow_path_canvas())); | 206 EXPECT_EQ(ColorRed, GetColor(slow_path_canvas())); |
198 } | 207 } |
199 | 208 |
200 } // namespace webkit_media | 209 } // namespace webkit_media |
OLD | NEW |