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

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

Issue 2088273003: Video Color Managament (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: log color space Created 4 years, 4 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/output_surface.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/output/gl_renderer.h" 10 #include "cc/output/gl_renderer.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 ResourceProvider* resource_provider) { 199 ResourceProvider* resource_provider) {
200 const bool with_alpha = (video_frame->format() == media::PIXEL_FORMAT_YV12A); 200 const bool with_alpha = (video_frame->format() == media::PIXEL_FORMAT_YV12A);
201 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::REC_601; 201 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::REC_601;
202 int video_frame_color_space; 202 int video_frame_color_space;
203 if (video_frame->metadata()->GetInteger( 203 if (video_frame->metadata()->GetInteger(
204 media::VideoFrameMetadata::COLOR_SPACE, &video_frame_color_space) && 204 media::VideoFrameMetadata::COLOR_SPACE, &video_frame_color_space) &&
205 video_frame_color_space == media::COLOR_SPACE_JPEG) { 205 video_frame_color_space == media::COLOR_SPACE_JPEG) {
206 color_space = YUVVideoDrawQuad::JPEG; 206 color_space = YUVVideoDrawQuad::JPEG;
207 } 207 }
208 208
209 gfx::ColorSpace video_color_space = video_frame->ColorSpace();
210
209 const gfx::Rect opaque_rect(0, 0, 0, 0); 211 const gfx::Rect opaque_rect(0, 0, 0, 0);
210 212
211 if (with_alpha) { 213 if (with_alpha) {
212 memset(video_frame->data(media::VideoFrame::kAPlane), alpha_value, 214 memset(video_frame->data(media::VideoFrame::kAPlane), alpha_value,
213 video_frame->stride(media::VideoFrame::kAPlane) * 215 video_frame->stride(media::VideoFrame::kAPlane) *
214 video_frame->rows(media::VideoFrame::kAPlane)); 216 video_frame->rows(media::VideoFrame::kAPlane));
215 } 217 }
216 218
217 VideoFrameExternalResources resources = 219 VideoFrameExternalResources resources =
218 video_resource_updater->CreateExternalResourcesFromVideoFrame( 220 video_resource_updater->CreateExternalResourcesFromVideoFrame(
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 uint32_t bits_per_channel = 8; 273 uint32_t bits_per_channel = 8;
272 if (video_frame->format() == media::PIXEL_FORMAT_YUV420P10 || 274 if (video_frame->format() == media::PIXEL_FORMAT_YUV420P10 ||
273 video_frame->format() == media::PIXEL_FORMAT_YUV422P10 || 275 video_frame->format() == media::PIXEL_FORMAT_YUV422P10 ||
274 video_frame->format() == media::PIXEL_FORMAT_YUV444P10) { 276 video_frame->format() == media::PIXEL_FORMAT_YUV444P10) {
275 bits_per_channel = 10; 277 bits_per_channel = 10;
276 } 278 }
277 279
278 yuv_quad->SetNew(shared_state, rect, opaque_rect, visible_rect, 280 yuv_quad->SetNew(shared_state, rect, opaque_rect, visible_rect,
279 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, 281 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size,
280 uv_tex_size, y_resource, u_resource, v_resource, a_resource, 282 uv_tex_size, y_resource, u_resource, v_resource, a_resource,
281 color_space, 0.0f, 1.0f, bits_per_channel); 283 color_space, video_color_space, 0.0f, 1.0f,
284 bits_per_channel);
282 } 285 }
283 286
284 // Upshift video frame to 10 bit. 287 // Upshift video frame to 10 bit.
285 scoped_refptr<media::VideoFrame> CreateHighbitVideoFrame( 288 scoped_refptr<media::VideoFrame> CreateHighbitVideoFrame(
286 media::VideoFrame* video_frame) { 289 media::VideoFrame* video_frame) {
287 media::VideoPixelFormat format; 290 media::VideoPixelFormat format;
288 switch (video_frame->format()) { 291 switch (video_frame->format()) {
289 case media::PIXEL_FORMAT_I420: 292 case media::PIXEL_FORMAT_I420:
290 case media::PIXEL_FORMAT_YV12: 293 case media::PIXEL_FORMAT_YV12:
291 format = media::PIXEL_FORMAT_YUV420P10; 294 format = media::PIXEL_FORMAT_YUV420P10;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 video_frame->rows(media::VideoFrame::kVPlane)); 479 video_frame->rows(media::VideoFrame::kVPlane));
477 480
478 uint8_t alpha_value = is_transparent ? 0 : 128; 481 uint8_t alpha_value = is_transparent ? 0 : 128;
479 CreateTestYUVVideoDrawQuad_FromVideoFrame( 482 CreateTestYUVVideoDrawQuad_FromVideoFrame(
480 shared_state, video_frame, alpha_value, tex_coord_rect, render_pass, 483 shared_state, video_frame, alpha_value, tex_coord_rect, render_pass,
481 video_resource_updater, rect, visible_rect, resource_provider); 484 video_resource_updater, rect, visible_rect, resource_provider);
482 } 485 }
483 486
484 void CreateTestYUVVideoDrawQuad_NV12(const SharedQuadState* shared_state, 487 void CreateTestYUVVideoDrawQuad_NV12(const SharedQuadState* shared_state,
485 media::ColorSpace video_frame_color_space, 488 media::ColorSpace video_frame_color_space,
489 const gfx::ColorSpace& video_color_space,
486 const gfx::RectF& tex_coord_rect, 490 const gfx::RectF& tex_coord_rect,
487 uint8_t y, 491 uint8_t y,
488 uint8_t u, 492 uint8_t u,
489 uint8_t v, 493 uint8_t v,
490 RenderPass* render_pass, 494 RenderPass* render_pass,
491 const gfx::Rect& rect, 495 const gfx::Rect& rect,
492 const gfx::Rect& visible_rect, 496 const gfx::Rect& visible_rect,
493 ResourceProvider* resource_provider) { 497 ResourceProvider* resource_provider) {
494 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::REC_601; 498 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::REC_601;
495 if (video_frame_color_space == media::COLOR_SPACE_JPEG) { 499 if (video_frame_color_space == media::COLOR_SPACE_JPEG) {
(...skipping 29 matching lines...) Expand all
525 gfx::RectF uv_tex_coord_rect(tex_coord_rect.x() * uv_tex_size.width(), 529 gfx::RectF uv_tex_coord_rect(tex_coord_rect.x() * uv_tex_size.width(),
526 tex_coord_rect.y() * uv_tex_size.height(), 530 tex_coord_rect.y() * uv_tex_size.height(),
527 tex_coord_rect.width() * uv_tex_size.width(), 531 tex_coord_rect.width() * uv_tex_size.width(),
528 tex_coord_rect.height() * uv_tex_size.height()); 532 tex_coord_rect.height() * uv_tex_size.height());
529 533
530 YUVVideoDrawQuad* yuv_quad = 534 YUVVideoDrawQuad* yuv_quad =
531 render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>(); 535 render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>();
532 yuv_quad->SetNew(shared_state, rect, opaque_rect, visible_rect, 536 yuv_quad->SetNew(shared_state, rect, opaque_rect, visible_rect,
533 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, 537 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size,
534 uv_tex_size, y_resource, u_resource, v_resource, a_resource, 538 uv_tex_size, y_resource, u_resource, v_resource, a_resource,
535 color_space, 0.0f, 1.0f, 8); 539 color_space, video_color_space, 0.0f, 1.0f, 8);
536 } 540 }
537 541
538 typedef ::testing::Types<GLRenderer, 542 typedef ::testing::Types<GLRenderer,
539 SoftwareRenderer, 543 SoftwareRenderer,
540 GLRendererWithExpandedViewport, 544 GLRendererWithExpandedViewport,
541 SoftwareRendererWithExpandedViewport> RendererTypes; 545 SoftwareRendererWithExpandedViewport> RendererTypes;
542 TYPED_TEST_CASE(RendererPixelTest, RendererTypes); 546 TYPED_TEST_CASE(RendererPixelTest, RendererTypes);
543 547
544 template <typename RendererType> 548 template <typename RendererType>
545 class SoftwareRendererPixelTest : public RendererPixelTest<RendererType> {}; 549 class SoftwareRendererPixelTest : public RendererPixelTest<RendererType> {};
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 gfx::Rect rect(this->device_viewport_size_); 1228 gfx::Rect rect(this->device_viewport_size_);
1225 1229
1226 RenderPassId id(1, 1); 1230 RenderPassId id(1, 1);
1227 std::unique_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); 1231 std::unique_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect);
1228 1232
1229 SharedQuadState* shared_state = 1233 SharedQuadState* shared_state =
1230 CreateTestSharedQuadState(gfx::Transform(), rect, pass.get()); 1234 CreateTestSharedQuadState(gfx::Transform(), rect, pass.get());
1231 1235
1232 // YUV of (149,43,21) should be green (0,255,0) in RGB. 1236 // YUV of (149,43,21) should be green (0,255,0) in RGB.
1233 CreateTestYUVVideoDrawQuad_NV12( 1237 CreateTestYUVVideoDrawQuad_NV12(
1234 shared_state, media::COLOR_SPACE_JPEG, gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f), 1238 shared_state, media::COLOR_SPACE_JPEG, gfx::ColorSpace::CreateJpeg(),
1235 149, 43, 21, pass.get(), rect, rect, resource_provider_.get()); 1239 gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f), 149, 43, 21, pass.get(), rect, rect,
1240 resource_provider_.get());
1236 1241
1237 RenderPassList pass_list; 1242 RenderPassList pass_list;
1238 pass_list.push_back(std::move(pass)); 1243 pass_list.push_back(std::move(pass));
1239 1244
1240 EXPECT_TRUE(this->RunPixelTest(&pass_list, 1245 EXPECT_TRUE(this->RunPixelTest(&pass_list,
1241 base::FilePath(FILE_PATH_LITERAL("green.png")), 1246 base::FilePath(FILE_PATH_LITERAL("green.png")),
1242 FuzzyPixelOffByOneComparator(true))); 1247 FuzzyPixelOffByOneComparator(true)));
1243 } 1248 }
1244 1249
1245 // Test that a YUV video doesn't bleed outside of its tex coords when the 1250 // Test that a YUV video doesn't bleed outside of its tex coords when the
(...skipping 1935 matching lines...) Expand 10 before | Expand all | Expand 10 after
3181 3186
3182 EXPECT_TRUE(this->RunPixelTest( 3187 EXPECT_TRUE(this->RunPixelTest(
3183 &pass_list, base::FilePath(FILE_PATH_LITERAL("spiral.png")), 3188 &pass_list, base::FilePath(FILE_PATH_LITERAL("spiral.png")),
3184 FuzzyPixelOffByOneComparator(true))); 3189 FuzzyPixelOffByOneComparator(true)));
3185 } 3190 }
3186 3191
3187 #endif // !defined(OS_ANDROID) 3192 #endif // !defined(OS_ANDROID)
3188 3193
3189 } // namespace 3194 } // namespace
3190 } // namespace cc 3195 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/output_surface.cc ('k') | cc/output/shader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698