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

Side by Side Diff: cc/output/renderer_pixeltest.cc

Issue 2122573003: media: replace LUMINANCE_F16 by RG_88 for 9/10-bit h264 videos Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase to ToT Created 4 years, 2 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
« no previous file with comments | « cc/output/gl_renderer_unittest.cc ('k') | cc/output/shader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
11 #include "cc/output/gl_renderer.h" 11 #include "cc/output/gl_renderer.h"
12 #include "cc/quads/draw_quad.h" 12 #include "cc/quads/draw_quad.h"
13 #include "cc/quads/picture_draw_quad.h" 13 #include "cc/quads/picture_draw_quad.h"
14 #include "cc/quads/texture_draw_quad.h" 14 #include "cc/quads/texture_draw_quad.h"
15 #include "cc/resources/video_resource_updater.h" 15 #include "cc/resources/video_resource_updater.h"
16 #include "cc/test/fake_raster_source.h" 16 #include "cc/test/fake_raster_source.h"
17 #include "cc/test/fake_recording_source.h" 17 #include "cc/test/fake_recording_source.h"
18 #include "cc/test/pixel_test.h" 18 #include "cc/test/pixel_test.h"
19 #include "cc/test/test_in_process_context_provider.h"
19 #include "gpu/command_buffer/client/gles2_interface.h" 20 #include "gpu/command_buffer/client/gles2_interface.h"
20 #include "media/base/video_frame.h" 21 #include "media/base/video_frame.h"
21 #include "third_party/skia/include/core/SkColorPriv.h" 22 #include "third_party/skia/include/core/SkColorPriv.h"
22 #include "third_party/skia/include/core/SkImageFilter.h" 23 #include "third_party/skia/include/core/SkImageFilter.h"
23 #include "third_party/skia/include/core/SkMatrix.h" 24 #include "third_party/skia/include/core/SkMatrix.h"
24 #include "third_party/skia/include/core/SkRefCnt.h" 25 #include "third_party/skia/include/core/SkRefCnt.h"
25 #include "third_party/skia/include/core/SkSurface.h" 26 #include "third_party/skia/include/core/SkSurface.h"
26 #include "third_party/skia/include/effects/SkColorFilterImageFilter.h" 27 #include "third_party/skia/include/effects/SkColorFilterImageFilter.h"
27 #include "third_party/skia/include/effects/SkColorMatrixFilter.h" 28 #include "third_party/skia/include/effects/SkColorMatrixFilter.h"
28 #include "ui/gfx/geometry/rect_conversions.h" 29 #include "ui/gfx/geometry/rect_conversions.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 gfx::ColorSpace video_color_space = video_frame->ColorSpace(); 211 gfx::ColorSpace video_color_space = video_frame->ColorSpace();
211 212
212 const gfx::Rect opaque_rect(0, 0, 0, 0); 213 const gfx::Rect opaque_rect(0, 0, 0, 0);
213 214
214 if (with_alpha) { 215 if (with_alpha) {
215 memset(video_frame->data(media::VideoFrame::kAPlane), alpha_value, 216 memset(video_frame->data(media::VideoFrame::kAPlane), alpha_value,
216 video_frame->stride(media::VideoFrame::kAPlane) * 217 video_frame->stride(media::VideoFrame::kAPlane) *
217 video_frame->rows(media::VideoFrame::kAPlane)); 218 video_frame->rows(media::VideoFrame::kAPlane));
218 } 219 }
219 220
220 VideoFrameExternalResources resources = 221 VideoFrameExternalResources external_resources =
221 video_resource_updater->CreateExternalResourcesFromVideoFrame( 222 video_resource_updater->CreateExternalResourcesFromVideoFrame(
222 video_frame); 223 video_frame);
223 224
224 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type); 225 ResourceProvider::ResourceIdArray resource_ids;
225 EXPECT_EQ(media::VideoFrame::NumPlanes(video_frame->format()), 226 resource_ids.reserve(external_resources.mailboxes.size());
226 resources.mailboxes.size()); 227 for (size_t i = 0; i < external_resources.mailboxes.size(); ++i) {
227 EXPECT_EQ(media::VideoFrame::NumPlanes(video_frame->format()), 228 ResourceId resource_id =
228 resources.release_callbacks.size()); 229 resource_provider->CreateResourceFromTextureMailbox(
229 230 external_resources.mailboxes[i], external_resources.format,
230 ResourceId y_resource = resource_provider->CreateResourceFromTextureMailbox( 231 SingleReleaseCallbackImpl::Create(
231 resources.mailboxes[media::VideoFrame::kYPlane], 232 external_resources.release_callbacks[i]),
232 SingleReleaseCallbackImpl::Create( 233 external_resources.read_lock_fences_enabled);
233 resources.release_callbacks[media::VideoFrame::kYPlane])); 234 resource_ids.push_back(resource_id);
234 ResourceId u_resource = resource_provider->CreateResourceFromTextureMailbox(
235 resources.mailboxes[media::VideoFrame::kUPlane],
236 SingleReleaseCallbackImpl::Create(
237 resources.release_callbacks[media::VideoFrame::kUPlane]));
238 ResourceId v_resource = resource_provider->CreateResourceFromTextureMailbox(
239 resources.mailboxes[media::VideoFrame::kVPlane],
240 SingleReleaseCallbackImpl::Create(
241 resources.release_callbacks[media::VideoFrame::kVPlane]));
242 ResourceId a_resource = 0;
243 if (with_alpha) {
244 a_resource = resource_provider->CreateResourceFromTextureMailbox(
245 resources.mailboxes[media::VideoFrame::kAPlane],
246 SingleReleaseCallbackImpl::Create(
247 resources.release_callbacks[media::VideoFrame::kAPlane]));
248 } 235 }
249 236
250 const gfx::Size ya_tex_size = video_frame->coded_size(); 237 switch (external_resources.type) {
251 const gfx::Size uv_tex_size = media::VideoFrame::PlaneSize( 238 case VideoFrameExternalResources::YUV_RESOURCE: {
252 video_frame->format(), media::VideoFrame::kUPlane, 239 EXPECT_EQ(media::VideoFrame::NumPlanes(video_frame->format()),
253 video_frame->coded_size()); 240 external_resources.mailboxes.size());
254 DCHECK(uv_tex_size == media::VideoFrame::PlaneSize( 241 EXPECT_EQ(media::VideoFrame::NumPlanes(video_frame->format()),
255 video_frame->format(), media::VideoFrame::kVPlane, 242 external_resources.release_callbacks.size());
256 video_frame->coded_size())); 243 const gfx::Size ya_tex_size = video_frame->coded_size();
257 if (with_alpha) { 244 const gfx::Size uv_tex_size = media::VideoFrame::PlaneSize(
258 DCHECK(ya_tex_size == media::VideoFrame::PlaneSize( 245 video_frame->format(), media::VideoFrame::kUPlane,
259 video_frame->format(), media::VideoFrame::kAPlane, 246 video_frame->coded_size());
260 video_frame->coded_size())); 247 DCHECK(uv_tex_size ==
248 media::VideoFrame::PlaneSize(video_frame->format(),
249 media::VideoFrame::kVPlane,
250 video_frame->coded_size()));
251 if (with_alpha) {
252 DCHECK(ya_tex_size ==
253 media::VideoFrame::PlaneSize(video_frame->format(),
254 media::VideoFrame::kAPlane,
255 video_frame->coded_size()));
256 }
257
258 gfx::RectF ya_tex_coord_rect(
259 tex_coord_rect.x() * ya_tex_size.width(),
260 tex_coord_rect.y() * ya_tex_size.height(),
261 tex_coord_rect.width() * ya_tex_size.width(),
262 tex_coord_rect.height() * ya_tex_size.height());
263 gfx::RectF uv_tex_coord_rect(
264 tex_coord_rect.x() * uv_tex_size.width(),
265 tex_coord_rect.y() * uv_tex_size.height(),
266 tex_coord_rect.width() * uv_tex_size.width(),
267 tex_coord_rect.height() * uv_tex_size.height());
268
269 YUVVideoDrawQuad* yuv_quad =
270 render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>();
271 yuv_quad->SetNew(
272 shared_state, rect, opaque_rect, visible_rect, ya_tex_coord_rect,
273 uv_tex_coord_rect, ya_tex_size, uv_tex_size, resource_ids[0],
274 resource_ids[1],
275 resource_ids.size() > 2 ? resource_ids[2] : resource_ids[1],
276 resource_ids.size() > 3 ? resource_ids[3] : 0, color_space,
277 video_color_space, external_resources.offset,
278 external_resources.multiplier, external_resources.bits_per_channel);
279 break;
280 }
281
282 case VideoFrameExternalResources::RGBA_RESOURCE: {
283 EXPECT_EQ(1u, external_resources.mailboxes.size());
284 EXPECT_EQ(1u, external_resources.release_callbacks.size());
285 gfx::PointF uv_top_left(0.f, 0.f);
286 gfx::Size coded_size = video_frame->coded_size();
287 gfx::Rect visible_sample_rect = video_frame->visible_rect();
288 const float tex_width_scale =
289 static_cast<float>(visible_sample_rect.width()) / coded_size.width();
290 const float tex_height_scale =
291 static_cast<float>(visible_sample_rect.height()) /
292 coded_size.height();
293 gfx::PointF uv_bottom_right(tex_width_scale, tex_height_scale);
294 float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f};
295 TextureDrawQuad* texture_quad =
296 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
297 texture_quad->SetNew(shared_state, rect, opaque_rect, visible_rect,
298 resource_ids[0], false, uv_top_left, uv_bottom_right,
299 SK_ColorTRANSPARENT, opacity, false, false, false);
300 break;
301 }
302 default:
303 NOTREACHED();
261 } 304 }
262
263 gfx::RectF ya_tex_coord_rect(tex_coord_rect.x() * ya_tex_size.width(),
264 tex_coord_rect.y() * ya_tex_size.height(),
265 tex_coord_rect.width() * ya_tex_size.width(),
266 tex_coord_rect.height() * ya_tex_size.height());
267 gfx::RectF uv_tex_coord_rect(tex_coord_rect.x() * uv_tex_size.width(),
268 tex_coord_rect.y() * uv_tex_size.height(),
269 tex_coord_rect.width() * uv_tex_size.width(),
270 tex_coord_rect.height() * uv_tex_size.height());
271
272 YUVVideoDrawQuad* yuv_quad =
273 render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>();
274 uint32_t bits_per_channel = 8;
275 if (video_frame->format() == media::PIXEL_FORMAT_YUV420P10 ||
276 video_frame->format() == media::PIXEL_FORMAT_YUV422P10 ||
277 video_frame->format() == media::PIXEL_FORMAT_YUV444P10) {
278 bits_per_channel = 10;
279 }
280
281 yuv_quad->SetNew(shared_state, rect, opaque_rect, visible_rect,
282 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size,
283 uv_tex_size, y_resource, u_resource, v_resource, a_resource,
284 color_space, video_color_space, 0.0f, 1.0f,
285 bits_per_channel);
286 } 305 }
287 306
288 // Upshift video frame to 10 bit. 307 // Upshift video frame to 10 bit.
289 scoped_refptr<media::VideoFrame> CreateHighbitVideoFrame( 308 scoped_refptr<media::VideoFrame> CreateHighbitVideoFrame(
290 media::VideoFrame* video_frame) { 309 media::VideoFrame* video_frame) {
291 media::VideoPixelFormat format; 310 media::VideoPixelFormat format;
292 switch (video_frame->format()) { 311 switch (video_frame->format()) {
293 case media::PIXEL_FORMAT_I420: 312 case media::PIXEL_FORMAT_I420:
294 case media::PIXEL_FORMAT_YV12: 313 case media::PIXEL_FORMAT_YV12:
295 format = media::PIXEL_FORMAT_YUV420P10; 314 format = media::PIXEL_FORMAT_YUV420P10;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 bool is_transparent, 355 bool is_transparent,
337 bool highbit, 356 bool highbit,
338 const gfx::RectF& tex_coord_rect, 357 const gfx::RectF& tex_coord_rect,
339 RenderPass* render_pass, 358 RenderPass* render_pass,
340 VideoResourceUpdater* video_resource_updater, 359 VideoResourceUpdater* video_resource_updater,
341 const gfx::Rect& rect, 360 const gfx::Rect& rect,
342 const gfx::Rect& visible_rect, 361 const gfx::Rect& visible_rect,
343 ResourceProvider* resource_provider) { 362 ResourceProvider* resource_provider) {
344 scoped_refptr<media::VideoFrame> video_frame = media::VideoFrame::CreateFrame( 363 scoped_refptr<media::VideoFrame> video_frame = media::VideoFrame::CreateFrame(
345 format, rect.size(), rect, rect.size(), base::TimeDelta()); 364 format, rect.size(), rect, rect.size(), base::TimeDelta());
365 video_frame->metadata()->SetInteger(media::VideoFrameMetadata::COLOR_SPACE,
366 YUVVideoDrawQuad::REC_601);
346 367
347 // YUV values representing a striped pattern, for validating texture 368 // YUV values representing a striped pattern, for validating texture
348 // coordinates for sampling. 369 // coordinates for sampling.
349 uint8_t y_value = 0; 370 uint8_t y_value = 0;
350 uint8_t u_value = 0; 371 uint8_t u_value = 0;
351 uint8_t v_value = 0; 372 uint8_t v_value = 0;
352 for (int i = 0; i < video_frame->rows(media::VideoFrame::kYPlane); ++i) { 373 for (int i = 0; i < video_frame->rows(media::VideoFrame::kYPlane); ++i) {
353 uint8_t* y_row = video_frame->data(media::VideoFrame::kYPlane) + 374 uint8_t* y_row = video_frame->data(media::VideoFrame::kYPlane) +
354 video_frame->stride(media::VideoFrame::kYPlane) * i; 375 video_frame->stride(media::VideoFrame::kYPlane) * i;
355 for (int j = 0; j < video_frame->row_bytes(media::VideoFrame::kYPlane); 376 for (int j = 0; j < video_frame->row_bytes(media::VideoFrame::kYPlane);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 500
480 uint8_t alpha_value = is_transparent ? 0 : 128; 501 uint8_t alpha_value = is_transparent ? 0 : 128;
481 CreateTestYUVVideoDrawQuad_FromVideoFrame( 502 CreateTestYUVVideoDrawQuad_FromVideoFrame(
482 shared_state, video_frame, alpha_value, tex_coord_rect, render_pass, 503 shared_state, video_frame, alpha_value, tex_coord_rect, render_pass,
483 video_resource_updater, rect, visible_rect, resource_provider); 504 video_resource_updater, rect, visible_rect, resource_provider);
484 } 505 }
485 506
486 void CreateTestYUVVideoDrawQuad_NV12(const SharedQuadState* shared_state, 507 void CreateTestYUVVideoDrawQuad_NV12(const SharedQuadState* shared_state,
487 media::ColorSpace video_frame_color_space, 508 media::ColorSpace video_frame_color_space,
488 const gfx::ColorSpace& video_color_space, 509 const gfx::ColorSpace& video_color_space,
510 ResourceFormat y_format,
489 const gfx::RectF& tex_coord_rect, 511 const gfx::RectF& tex_coord_rect,
490 uint8_t y, 512 uint8_t y,
491 uint8_t u, 513 uint8_t u,
492 uint8_t v, 514 uint8_t v,
493 RenderPass* render_pass, 515 RenderPass* render_pass,
494 const gfx::Rect& rect, 516 const gfx::Rect& rect,
495 const gfx::Rect& visible_rect, 517 const gfx::Rect& visible_rect,
496 ResourceProvider* resource_provider) { 518 ResourceProvider* resource_provider) {
497 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::REC_601; 519 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::REC_601;
498 if (video_frame_color_space == media::COLOR_SPACE_JPEG) { 520 if (video_frame_color_space == media::COLOR_SPACE_JPEG) {
499 color_space = YUVVideoDrawQuad::JPEG; 521 color_space = YUVVideoDrawQuad::JPEG;
500 } 522 }
501 523
502 const gfx::Rect opaque_rect(0, 0, 0, 0); 524 const gfx::Rect opaque_rect(0, 0, 0, 0);
503 const gfx::Size ya_tex_size = rect.size(); 525 const gfx::Size ya_tex_size = rect.size();
504 const gfx::Size uv_tex_size = media::VideoFrame::PlaneSize( 526 const gfx::Size uv_tex_size = media::VideoFrame::PlaneSize(
505 media::PIXEL_FORMAT_NV12, media::VideoFrame::kUVPlane, rect.size()); 527 media::PIXEL_FORMAT_NV12, media::VideoFrame::kUVPlane, rect.size());
506 528
507 ResourceId y_resource = resource_provider->CreateResource( 529 ResourceId y_resource = resource_provider->CreateResource(
508 rect.size(), ResourceProvider::TEXTURE_HINT_DEFAULT, 530 rect.size(), ResourceProvider::TEXTURE_HINT_DEFAULT, y_format,
509 resource_provider->YuvResourceFormat(8), gfx::ColorSpace()); 531 gfx::ColorSpace());
510 ResourceId u_resource = resource_provider->CreateResource( 532 ResourceId u_resource = resource_provider->CreateResource(
511 uv_tex_size, ResourceProvider::TEXTURE_HINT_DEFAULT, RGBA_8888, 533 uv_tex_size, ResourceProvider::TEXTURE_HINT_DEFAULT, RGBA_8888,
512 gfx::ColorSpace()); 534 gfx::ColorSpace());
513 ResourceId v_resource = u_resource; 535 ResourceId v_resource = u_resource;
514 ResourceId a_resource = 0; 536 ResourceId a_resource = 0;
515 537
516 std::vector<uint8_t> y_pixels(ya_tex_size.GetArea(), y); 538 std::vector<uint8_t> y_pixels(ya_tex_size.GetArea(), y);
517 resource_provider->CopyToResource(y_resource, y_pixels.data(), ya_tex_size); 539 resource_provider->CopyToResource(y_resource, y_pixels.data(), ya_tex_size);
518 540
519 // U goes in the R component and V goes in the G component. 541 // U goes in the R component and V goes in the G component.
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 1112
1091 void SetUp() override { 1113 void SetUp() override {
1092 GLRendererPixelTest::SetUp(); 1114 GLRendererPixelTest::SetUp();
1093 video_resource_updater_.reset(new VideoResourceUpdater( 1115 video_resource_updater_.reset(new VideoResourceUpdater(
1094 output_surface_->context_provider(), resource_provider_.get())); 1116 output_surface_->context_provider(), resource_provider_.get()));
1095 } 1117 }
1096 1118
1097 std::unique_ptr<VideoResourceUpdater> video_resource_updater_; 1119 std::unique_ptr<VideoResourceUpdater> video_resource_updater_;
1098 }; 1120 };
1099 1121
1122 enum class HighbitTexture {
1123 Y8,
1124 RGBA_8888,
1125 LUMINANCE_F16,
1126 RG88,
1127 };
1128
1100 class VideoGLRendererPixelHiLoTest 1129 class VideoGLRendererPixelHiLoTest
1101 : public VideoGLRendererPixelTest, 1130 : public VideoGLRendererPixelTest,
1102 public ::testing::WithParamInterface<bool> {}; 1131 public ::testing::WithParamInterface<
1132 ::testing::tuple<bool, HighbitTexture>> {
1133 public:
1134 void SetSupportHighbitTexture(HighbitTexture texture) {
1135 TestInProcessContextProvider* context_provider =
1136 GetTestInProcessContextProvider();
1137 switch (texture) {
1138 case HighbitTexture::Y8:
1139 context_provider->SetDisableOneComponentTextures(false);
1140 context_provider->SetSupportTextureHalfFloatLinear(false);
1141 break;
1142 case HighbitTexture::RGBA_8888:
1143 context_provider->SetDisableOneComponentTextures(true);
1144 context_provider->SetSupportTextureHalfFloatLinear(false);
1145 break;
1146 case HighbitTexture::LUMINANCE_F16:
1147 context_provider->SetDisableOneComponentTextures(false);
1148 context_provider->SetSupportTextureHalfFloatLinear(true);
1149 break;
1150 case HighbitTexture::RG88:
1151 video_resource_updater_->UseRGForTesting(true);
1152 context_provider->SetDisableOneComponentTextures(false);
1153 context_provider->SetSupportTextureHalfFloatLinear(false);
1154 break;
1155 }
1156 }
1157
1158 private:
1159 TestInProcessContextProvider* GetTestInProcessContextProvider() {
1160 return static_cast<TestInProcessContextProvider*>(
1161 output_surface_->context_provider());
1162 }
1163 };
1103 1164
1104 TEST_P(VideoGLRendererPixelHiLoTest, SimpleYUVRect) { 1165 TEST_P(VideoGLRendererPixelHiLoTest, SimpleYUVRect) {
1105 gfx::Rect rect(this->device_viewport_size_); 1166 gfx::Rect rect(this->device_viewport_size_);
1106 1167
1107 RenderPassId id(1, 1); 1168 RenderPassId id(1, 1);
1108 std::unique_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); 1169 std::unique_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect);
1109 1170
1110 SharedQuadState* shared_state = 1171 SharedQuadState* shared_state =
1111 CreateTestSharedQuadState(gfx::Transform(), rect, pass.get()); 1172 CreateTestSharedQuadState(gfx::Transform(), rect, pass.get());
1112 1173
1113 bool highbit = GetParam(); 1174 const bool highbit = testing::get<0>(GetParam());
1175 const HighbitTexture format = testing::get<1>(GetParam());
1176 SetSupportHighbitTexture(format);
1114 CreateTestYUVVideoDrawQuad_Striped( 1177 CreateTestYUVVideoDrawQuad_Striped(
1115 shared_state, media::PIXEL_FORMAT_YV12, false, highbit, 1178 shared_state, media::PIXEL_FORMAT_YV12, false, highbit,
1116 gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f), pass.get(), 1179 gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f), pass.get(),
1117 video_resource_updater_.get(), rect, rect, resource_provider_.get()); 1180 video_resource_updater_.get(), rect, rect, resource_provider_.get());
1118 1181
1119 RenderPassList pass_list; 1182 RenderPassList pass_list;
1120 pass_list.push_back(std::move(pass)); 1183 pass_list.push_back(std::move(pass));
1121 1184
1122 EXPECT_TRUE( 1185 base::FilePath file_path =
1123 this->RunPixelTest(&pass_list, 1186 base::FilePath(FILE_PATH_LITERAL("yuv_stripes.png"));
1124 base::FilePath(FILE_PATH_LITERAL("yuv_stripes.png")), 1187 // TODO(dshwang): investigate why results per configuraion are so different.
1125 FuzzyPixelOffByOneComparator(true))); 1188 // crbug.com/622133
1189 if (format == HighbitTexture::RGBA_8888) {
1190 // Color space is so different, because this path doesn't respect video
1191 // color profile.
1192 file_path = base::FilePath(FILE_PATH_LITERAL("yuv_stripes_rgba.png"));
1193 }
1194 if (highbit && format == HighbitTexture::RG88) {
1195 // The 2d-linear filter result is different at many pixels. However, the
1196 // result is very similar to "yuv_stripes_rgba.png" in terms of 2d-linear
1197 // filter. The gpu default 2d-linear filter seems to overblur the image.
1198 file_path = base::FilePath(FILE_PATH_LITERAL("yuv_stripes_rg88.png"));
1199 }
1200 EXPECT_TRUE(this->RunPixelTest(&pass_list, file_path,
1201 FuzzyPixelOffByOneComparator(true)));
1126 } 1202 }
1127 1203
1128 TEST_P(VideoGLRendererPixelHiLoTest, ClippedYUVRect) { 1204 TEST_P(VideoGLRendererPixelHiLoTest, ClippedYUVRect) {
1129 gfx::Rect viewport(this->device_viewport_size_); 1205 gfx::Rect viewport(this->device_viewport_size_);
1130 gfx::Rect draw_rect(this->device_viewport_size_.width() * 1.5, 1206 gfx::Rect draw_rect(this->device_viewport_size_.width() * 1.5,
1131 this->device_viewport_size_.height() * 1.5); 1207 this->device_viewport_size_.height() * 1.5);
1132 1208
1133 RenderPassId id(1, 1); 1209 RenderPassId id(1, 1);
1134 std::unique_ptr<RenderPass> pass = CreateTestRootRenderPass(id, viewport); 1210 std::unique_ptr<RenderPass> pass = CreateTestRootRenderPass(id, viewport);
1135 1211
1136 SharedQuadState* shared_state = 1212 SharedQuadState* shared_state =
1137 CreateTestSharedQuadState(gfx::Transform(), viewport, pass.get()); 1213 CreateTestSharedQuadState(gfx::Transform(), viewport, pass.get());
1138 1214
1139 bool highbit = GetParam(); 1215 const bool highbit = testing::get<0>(GetParam());
1216 const HighbitTexture format = testing::get<1>(GetParam());
1217 SetSupportHighbitTexture(format);
1140 CreateTestYUVVideoDrawQuad_Striped( 1218 CreateTestYUVVideoDrawQuad_Striped(
1141 shared_state, media::PIXEL_FORMAT_YV12, false, highbit, 1219 shared_state, media::PIXEL_FORMAT_YV12, false, highbit,
1142 gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f), pass.get(), 1220 gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f), pass.get(),
1143 video_resource_updater_.get(), draw_rect, viewport, 1221 video_resource_updater_.get(), draw_rect, viewport,
1144 resource_provider_.get()); 1222 resource_provider_.get());
1145 RenderPassList pass_list; 1223 RenderPassList pass_list;
1146 pass_list.push_back(std::move(pass)); 1224 pass_list.push_back(std::move(pass));
1147 1225
1148 EXPECT_TRUE(this->RunPixelTest( 1226 base::FilePath file_path =
1149 &pass_list, base::FilePath(FILE_PATH_LITERAL("yuv_stripes_clipped.png")), 1227 base::FilePath(FILE_PATH_LITERAL("yuv_stripes_clipped.png"));
1150 FuzzyPixelOffByOneComparator(true))); 1228 if (format == HighbitTexture::RGBA_8888) {
1229 file_path =
1230 base::FilePath(FILE_PATH_LITERAL("yuv_stripes_clipped_rgba.png"));
1231 }
1232 if (highbit && format == HighbitTexture::RG88) {
1233 file_path =
1234 base::FilePath(FILE_PATH_LITERAL("yuv_stripes_clipped_rg88.png"));
1235 }
1236 EXPECT_TRUE(this->RunPixelTest(&pass_list, file_path,
1237 FuzzyPixelOffByOneComparator(true)));
1151 } 1238 }
1152 1239
1153 TEST_F(VideoGLRendererPixelHiLoTest, OffsetYUVRect) { 1240 TEST_F(VideoGLRendererPixelHiLoTest, OffsetYUVRect) {
1154 gfx::Rect rect(this->device_viewport_size_); 1241 gfx::Rect rect(this->device_viewport_size_);
1155 1242
1156 RenderPassId id(1, 1); 1243 RenderPassId id(1, 1);
1157 std::unique_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); 1244 std::unique_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect);
1158 1245
1159 SharedQuadState* shared_state = 1246 SharedQuadState* shared_state =
1160 CreateTestSharedQuadState(gfx::Transform(), rect, pass.get()); 1247 CreateTestSharedQuadState(gfx::Transform(), rect, pass.get());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 pass_list.push_back(std::move(pass)); 1279 pass_list.push_back(std::move(pass));
1193 1280
1194 // If we didn't get black out of the YUV values above, then we probably have a 1281 // If we didn't get black out of the YUV values above, then we probably have a
1195 // color range issue. 1282 // color range issue.
1196 EXPECT_TRUE(this->RunPixelTest(&pass_list, 1283 EXPECT_TRUE(this->RunPixelTest(&pass_list,
1197 base::FilePath(FILE_PATH_LITERAL("black.png")), 1284 base::FilePath(FILE_PATH_LITERAL("black.png")),
1198 FuzzyPixelOffByOneComparator(true))); 1285 FuzzyPixelOffByOneComparator(true)));
1199 } 1286 }
1200 1287
1201 // First argument (test case prefix) is intentionally left empty. 1288 // First argument (test case prefix) is intentionally left empty.
1202 INSTANTIATE_TEST_CASE_P(, VideoGLRendererPixelHiLoTest, ::testing::Bool()); 1289 INSTANTIATE_TEST_CASE_P(
1290 ,
1291 VideoGLRendererPixelHiLoTest,
1292 ::testing::Combine(
1293 ::testing::Bool(),
1294 ::testing::Values(HighbitTexture::Y8,
1295 HighbitTexture::RGBA_8888,
1296 // LUMINANCE_F16 requires --use-gpu-in-tests
1297 // HighbitTexture::LUMINANCE_F16,
1298 HighbitTexture::RG88)));
1203 1299
1204 TEST_F(VideoGLRendererPixelTest, SimpleYUVJRect) { 1300 TEST_F(VideoGLRendererPixelTest, SimpleYUVJRect) {
1205 gfx::Rect rect(this->device_viewport_size_); 1301 gfx::Rect rect(this->device_viewport_size_);
1206 1302
1207 RenderPassId id(1, 1); 1303 RenderPassId id(1, 1);
1208 std::unique_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); 1304 std::unique_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect);
1209 1305
1210 SharedQuadState* shared_state = 1306 SharedQuadState* shared_state =
1211 CreateTestSharedQuadState(gfx::Transform(), rect, pass.get()); 1307 CreateTestSharedQuadState(gfx::Transform(), rect, pass.get());
1212 1308
(...skipping 13 matching lines...) Expand all
1226 1322
1227 TEST_F(VideoGLRendererPixelTest, SimpleNV12JRect) { 1323 TEST_F(VideoGLRendererPixelTest, SimpleNV12JRect) {
1228 gfx::Rect rect(this->device_viewport_size_); 1324 gfx::Rect rect(this->device_viewport_size_);
1229 1325
1230 RenderPassId id(1, 1); 1326 RenderPassId id(1, 1);
1231 std::unique_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); 1327 std::unique_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect);
1232 1328
1233 SharedQuadState* shared_state = 1329 SharedQuadState* shared_state =
1234 CreateTestSharedQuadState(gfx::Transform(), rect, pass.get()); 1330 CreateTestSharedQuadState(gfx::Transform(), rect, pass.get());
1235 1331
1332 ResourceFormat y_format = video_resource_updater_->YuvResourceFormat(8);
1333
1236 // YUV of (149,43,21) should be green (0,255,0) in RGB. 1334 // YUV of (149,43,21) should be green (0,255,0) in RGB.
1237 CreateTestYUVVideoDrawQuad_NV12( 1335 CreateTestYUVVideoDrawQuad_NV12(
1238 shared_state, media::COLOR_SPACE_JPEG, gfx::ColorSpace::CreateJpeg(), 1336 shared_state, media::COLOR_SPACE_JPEG, gfx::ColorSpace::CreateJpeg(),
1239 gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f), 149, 43, 21, pass.get(), rect, rect, 1337 y_format, gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f), 149, 43, 21, pass.get(),
1240 resource_provider_.get()); 1338 rect, rect, resource_provider_.get());
1241 1339
1242 RenderPassList pass_list; 1340 RenderPassList pass_list;
1243 pass_list.push_back(std::move(pass)); 1341 pass_list.push_back(std::move(pass));
1244 1342
1245 EXPECT_TRUE(this->RunPixelTest(&pass_list, 1343 EXPECT_TRUE(this->RunPixelTest(&pass_list,
1246 base::FilePath(FILE_PATH_LITERAL("green.png")), 1344 base::FilePath(FILE_PATH_LITERAL("green.png")),
1247 FuzzyPixelOffByOneComparator(true))); 1345 FuzzyPixelOffByOneComparator(true)));
1248 } 1346 }
1249 1347
1250 // Test that a YUV video doesn't bleed outside of its tex coords when the 1348 // Test that a YUV video doesn't bleed outside of its tex coords when the
(...skipping 1896 matching lines...) Expand 10 before | Expand all | Expand 10 after
3147 3245
3148 EXPECT_TRUE(this->RunPixelTest( 3246 EXPECT_TRUE(this->RunPixelTest(
3149 &pass_list, base::FilePath(FILE_PATH_LITERAL("spiral.png")), 3247 &pass_list, base::FilePath(FILE_PATH_LITERAL("spiral.png")),
3150 FuzzyPixelOffByOneComparator(true))); 3248 FuzzyPixelOffByOneComparator(true)));
3151 } 3249 }
3152 3250
3153 #endif // !defined(OS_ANDROID) 3251 #endif // !defined(OS_ANDROID)
3154 3252
3155 } // namespace 3253 } // namespace
3156 } // namespace cc 3254 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer_unittest.cc ('k') | cc/output/shader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698