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

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

Issue 1539203002: Switch to standard integer types in cc/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more includes Created 5 years 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/renderer.h ('k') | cc/output/renderer_settings.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>
6 #include <stdint.h>
7
5 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
6 #include "cc/output/gl_renderer.h" 9 #include "cc/output/gl_renderer.h"
7 #include "cc/quads/draw_quad.h" 10 #include "cc/quads/draw_quad.h"
8 #include "cc/quads/picture_draw_quad.h" 11 #include "cc/quads/picture_draw_quad.h"
9 #include "cc/quads/texture_draw_quad.h" 12 #include "cc/quads/texture_draw_quad.h"
10 #include "cc/resources/video_resource_updater.h" 13 #include "cc/resources/video_resource_updater.h"
11 #include "cc/test/fake_display_list_raster_source.h" 14 #include "cc/test/fake_display_list_raster_source.h"
12 #include "cc/test/fake_display_list_recording_source.h" 15 #include "cc/test/fake_display_list_recording_source.h"
13 #include "cc/test/pixel_test.h" 16 #include "cc/test/pixel_test.h"
14 #include "gpu/command_buffer/client/gles2_interface.h" 17 #include "gpu/command_buffer/client/gles2_interface.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 TextureDrawQuad* quad = 179 TextureDrawQuad* quad =
177 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); 180 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
178 quad->SetNew(shared_state, rect, gfx::Rect(), rect, resource, 181 quad->SetNew(shared_state, rect, gfx::Rect(), rect, resource,
179 premultiplied_alpha, uv_top_left, uv_bottom_right, 182 premultiplied_alpha, uv_top_left, uv_bottom_right,
180 background_color, vertex_opacity, flipped, nearest_neighbor); 183 background_color, vertex_opacity, flipped, nearest_neighbor);
181 } 184 }
182 185
183 void CreateTestYUVVideoDrawQuad_FromVideoFrame( 186 void CreateTestYUVVideoDrawQuad_FromVideoFrame(
184 const SharedQuadState* shared_state, 187 const SharedQuadState* shared_state,
185 scoped_refptr<media::VideoFrame> video_frame, 188 scoped_refptr<media::VideoFrame> video_frame,
186 uint8 alpha_value, 189 uint8_t alpha_value,
187 const gfx::RectF& tex_coord_rect, 190 const gfx::RectF& tex_coord_rect,
188 RenderPass* render_pass, 191 RenderPass* render_pass,
189 VideoResourceUpdater* video_resource_updater, 192 VideoResourceUpdater* video_resource_updater,
190 const gfx::Rect& rect, 193 const gfx::Rect& rect,
191 const gfx::Rect& visible_rect, 194 const gfx::Rect& visible_rect,
192 ResourceProvider* resource_provider) { 195 ResourceProvider* resource_provider) {
193 const bool with_alpha = (video_frame->format() == media::PIXEL_FORMAT_YV12A); 196 const bool with_alpha = (video_frame->format() == media::PIXEL_FORMAT_YV12A);
194 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::REC_601; 197 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::REC_601;
195 int video_frame_color_space; 198 int video_frame_color_space;
196 if (video_frame->metadata()->GetInteger( 199 if (video_frame->metadata()->GetInteger(
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 uint8_t* u_row = video_frame->data(media::VideoFrame::kUPlane) + 300 uint8_t* u_row = video_frame->data(media::VideoFrame::kUPlane) +
298 video_frame->stride(media::VideoFrame::kUPlane) * i; 301 video_frame->stride(media::VideoFrame::kUPlane) * i;
299 uint8_t* v_row = video_frame->data(media::VideoFrame::kVPlane) + 302 uint8_t* v_row = video_frame->data(media::VideoFrame::kVPlane) +
300 video_frame->stride(media::VideoFrame::kVPlane) * i; 303 video_frame->stride(media::VideoFrame::kVPlane) * i;
301 for (int j = 0; j < video_frame->row_bytes(media::VideoFrame::kUPlane); 304 for (int j = 0; j < video_frame->row_bytes(media::VideoFrame::kUPlane);
302 ++j) { 305 ++j) {
303 u_row[j] = (u_value += 3); 306 u_row[j] = (u_value += 3);
304 v_row[j] = (v_value += 5); 307 v_row[j] = (v_value += 5);
305 } 308 }
306 } 309 }
307 uint8 alpha_value = is_transparent ? 0 : 128; 310 uint8_t alpha_value = is_transparent ? 0 : 128;
308 CreateTestYUVVideoDrawQuad_FromVideoFrame( 311 CreateTestYUVVideoDrawQuad_FromVideoFrame(
309 shared_state, video_frame, alpha_value, tex_coord_rect, render_pass, 312 shared_state, video_frame, alpha_value, tex_coord_rect, render_pass,
310 video_resource_updater, rect, visible_rect, resource_provider); 313 video_resource_updater, rect, visible_rect, resource_provider);
311 } 314 }
312 315
313 // Creates a video frame of size background_size filled with yuv_background, 316 // Creates a video frame of size background_size filled with yuv_background,
314 // and then draws a foreground rectangle in a different color on top of 317 // and then draws a foreground rectangle in a different color on top of
315 // that. The foreground rectangle must have coordinates that are divisible 318 // that. The foreground rectangle must have coordinates that are divisible
316 // by 2 because YUV is a block format. 319 // by 2 because YUV is a block format.
317 void CreateTestYUVVideoDrawQuad_TwoColor( 320 void CreateTestYUVVideoDrawQuad_TwoColor(
318 const SharedQuadState* shared_state, 321 const SharedQuadState* shared_state,
319 media::VideoPixelFormat format, 322 media::VideoPixelFormat format,
320 media::ColorSpace color_space, 323 media::ColorSpace color_space,
321 bool is_transparent, 324 bool is_transparent,
322 const gfx::RectF& tex_coord_rect, 325 const gfx::RectF& tex_coord_rect,
323 const gfx::Size& background_size, 326 const gfx::Size& background_size,
324 const gfx::Rect& visible_rect, 327 const gfx::Rect& visible_rect,
325 uint8 y_background, 328 uint8_t y_background,
326 uint8 u_background, 329 uint8_t u_background,
327 uint8 v_background, 330 uint8_t v_background,
328 const gfx::Rect& foreground_rect, 331 const gfx::Rect& foreground_rect,
329 uint8 y_foreground, 332 uint8_t y_foreground,
330 uint8 u_foreground, 333 uint8_t u_foreground,
331 uint8 v_foreground, 334 uint8_t v_foreground,
332 RenderPass* render_pass, 335 RenderPass* render_pass,
333 VideoResourceUpdater* video_resource_updater, 336 VideoResourceUpdater* video_resource_updater,
334 ResourceProvider* resource_provider) { 337 ResourceProvider* resource_provider) {
335 const gfx::Rect rect(background_size); 338 const gfx::Rect rect(background_size);
336 339
337 scoped_refptr<media::VideoFrame> video_frame = 340 scoped_refptr<media::VideoFrame> video_frame =
338 media::VideoFrame::CreateFrame(format, background_size, foreground_rect, 341 media::VideoFrame::CreateFrame(format, background_size, foreground_rect,
339 foreground_rect.size(), base::TimeDelta()); 342 foreground_rect.size(), base::TimeDelta());
340 video_frame->metadata()->SetInteger(media::VideoFrameMetadata::COLOR_SPACE, 343 video_frame->metadata()->SetInteger(media::VideoFrameMetadata::COLOR_SPACE,
341 color_space); 344 color_space);
342 345
343 int planes[] = {media::VideoFrame::kYPlane, 346 int planes[] = {media::VideoFrame::kYPlane,
344 media::VideoFrame::kUPlane, 347 media::VideoFrame::kUPlane,
345 media::VideoFrame::kVPlane}; 348 media::VideoFrame::kVPlane};
346 uint8 yuv_background[] = {y_background, u_background, v_background}; 349 uint8_t yuv_background[] = {y_background, u_background, v_background};
347 uint8 yuv_foreground[] = {y_foreground, u_foreground, v_foreground}; 350 uint8_t yuv_foreground[] = {y_foreground, u_foreground, v_foreground};
348 int sample_size[] = {1, 2, 2}; 351 int sample_size[] = {1, 2, 2};
349 352
350 for (int i = 0; i < 3; ++i) { 353 for (int i = 0; i < 3; ++i) {
351 memset(video_frame->data(planes[i]), yuv_background[i], 354 memset(video_frame->data(planes[i]), yuv_background[i],
352 video_frame->stride(planes[i]) * video_frame->rows(planes[i])); 355 video_frame->stride(planes[i]) * video_frame->rows(planes[i]));
353 } 356 }
354 357
355 for (int i = 0; i < 3; ++i) { 358 for (int i = 0; i < 3; ++i) {
356 // Since yuv encoding uses block encoding, widths have to be divisible 359 // Since yuv encoding uses block encoding, widths have to be divisible
357 // by the sample size in order for this function to behave properly. 360 // by the sample size in order for this function to behave properly.
358 DCHECK_EQ(foreground_rect.x() % sample_size[i], 0); 361 DCHECK_EQ(foreground_rect.x() % sample_size[i], 0);
359 DCHECK_EQ(foreground_rect.y() % sample_size[i], 0); 362 DCHECK_EQ(foreground_rect.y() % sample_size[i], 0);
360 DCHECK_EQ(foreground_rect.width() % sample_size[i], 0); 363 DCHECK_EQ(foreground_rect.width() % sample_size[i], 0);
361 DCHECK_EQ(foreground_rect.height() % sample_size[i], 0); 364 DCHECK_EQ(foreground_rect.height() % sample_size[i], 0);
362 365
363 gfx::Rect sample_rect(foreground_rect.x() / sample_size[i], 366 gfx::Rect sample_rect(foreground_rect.x() / sample_size[i],
364 foreground_rect.y() / sample_size[i], 367 foreground_rect.y() / sample_size[i],
365 foreground_rect.width() / sample_size[i], 368 foreground_rect.width() / sample_size[i],
366 foreground_rect.height() / sample_size[i]); 369 foreground_rect.height() / sample_size[i]);
367 for (int y = sample_rect.y(); y < sample_rect.bottom(); ++y) { 370 for (int y = sample_rect.y(); y < sample_rect.bottom(); ++y) {
368 for (int x = sample_rect.x(); x < sample_rect.right(); ++x) { 371 for (int x = sample_rect.x(); x < sample_rect.right(); ++x) {
369 size_t offset = y * video_frame->stride(planes[i]) + x; 372 size_t offset = y * video_frame->stride(planes[i]) + x;
370 video_frame->data(planes[i])[offset] = yuv_foreground[i]; 373 video_frame->data(planes[i])[offset] = yuv_foreground[i];
371 } 374 }
372 } 375 }
373 } 376 }
374 377
375 uint8 alpha_value = 255; 378 uint8_t alpha_value = 255;
376 CreateTestYUVVideoDrawQuad_FromVideoFrame( 379 CreateTestYUVVideoDrawQuad_FromVideoFrame(
377 shared_state, video_frame, alpha_value, tex_coord_rect, render_pass, 380 shared_state, video_frame, alpha_value, tex_coord_rect, render_pass,
378 video_resource_updater, rect, visible_rect, resource_provider); 381 video_resource_updater, rect, visible_rect, resource_provider);
379 } 382 }
380 383
381 void CreateTestYUVVideoDrawQuad_Solid( 384 void CreateTestYUVVideoDrawQuad_Solid(
382 const SharedQuadState* shared_state, 385 const SharedQuadState* shared_state,
383 media::VideoPixelFormat format, 386 media::VideoPixelFormat format,
384 media::ColorSpace color_space, 387 media::ColorSpace color_space,
385 bool is_transparent, 388 bool is_transparent,
386 const gfx::RectF& tex_coord_rect, 389 const gfx::RectF& tex_coord_rect,
387 uint8 y, 390 uint8_t y,
388 uint8 u, 391 uint8_t u,
389 uint8 v, 392 uint8_t v,
390 RenderPass* render_pass, 393 RenderPass* render_pass,
391 VideoResourceUpdater* video_resource_updater, 394 VideoResourceUpdater* video_resource_updater,
392 const gfx::Rect& rect, 395 const gfx::Rect& rect,
393 const gfx::Rect& visible_rect, 396 const gfx::Rect& visible_rect,
394 ResourceProvider* resource_provider) { 397 ResourceProvider* resource_provider) {
395 scoped_refptr<media::VideoFrame> video_frame = media::VideoFrame::CreateFrame( 398 scoped_refptr<media::VideoFrame> video_frame = media::VideoFrame::CreateFrame(
396 format, rect.size(), rect, rect.size(), base::TimeDelta()); 399 format, rect.size(), rect, rect.size(), base::TimeDelta());
397 video_frame->metadata()->SetInteger(media::VideoFrameMetadata::COLOR_SPACE, 400 video_frame->metadata()->SetInteger(media::VideoFrameMetadata::COLOR_SPACE,
398 color_space); 401 color_space);
399 402
400 // YUV values of a solid, constant, color. Useful for testing that color 403 // YUV values of a solid, constant, color. Useful for testing that color
401 // space/color range are being handled properly. 404 // space/color range are being handled properly.
402 memset(video_frame->data(media::VideoFrame::kYPlane), y, 405 memset(video_frame->data(media::VideoFrame::kYPlane), y,
403 video_frame->stride(media::VideoFrame::kYPlane) * 406 video_frame->stride(media::VideoFrame::kYPlane) *
404 video_frame->rows(media::VideoFrame::kYPlane)); 407 video_frame->rows(media::VideoFrame::kYPlane));
405 memset(video_frame->data(media::VideoFrame::kUPlane), u, 408 memset(video_frame->data(media::VideoFrame::kUPlane), u,
406 video_frame->stride(media::VideoFrame::kUPlane) * 409 video_frame->stride(media::VideoFrame::kUPlane) *
407 video_frame->rows(media::VideoFrame::kUPlane)); 410 video_frame->rows(media::VideoFrame::kUPlane));
408 memset(video_frame->data(media::VideoFrame::kVPlane), v, 411 memset(video_frame->data(media::VideoFrame::kVPlane), v,
409 video_frame->stride(media::VideoFrame::kVPlane) * 412 video_frame->stride(media::VideoFrame::kVPlane) *
410 video_frame->rows(media::VideoFrame::kVPlane)); 413 video_frame->rows(media::VideoFrame::kVPlane));
411 414
412 uint8 alpha_value = is_transparent ? 0 : 128; 415 uint8_t alpha_value = is_transparent ? 0 : 128;
413 CreateTestYUVVideoDrawQuad_FromVideoFrame( 416 CreateTestYUVVideoDrawQuad_FromVideoFrame(
414 shared_state, video_frame, alpha_value, tex_coord_rect, render_pass, 417 shared_state, video_frame, alpha_value, tex_coord_rect, render_pass,
415 video_resource_updater, rect, visible_rect, resource_provider); 418 video_resource_updater, rect, visible_rect, resource_provider);
416 } 419 }
417 420
418 typedef ::testing::Types<GLRenderer, 421 typedef ::testing::Types<GLRenderer,
419 SoftwareRenderer, 422 SoftwareRenderer,
420 GLRendererWithExpandedViewport, 423 GLRendererWithExpandedViewport,
421 SoftwareRendererWithExpandedViewport> RendererTypes; 424 SoftwareRendererWithExpandedViewport> RendererTypes;
422 TYPED_TEST_CASE(RendererPixelTest, RendererTypes); 425 TYPED_TEST_CASE(RendererPixelTest, RendererTypes);
(...skipping 2548 matching lines...) Expand 10 before | Expand all | Expand 10 after
2971 2974
2972 EXPECT_TRUE(this->RunPixelTest( 2975 EXPECT_TRUE(this->RunPixelTest(
2973 &pass_list, base::FilePath(FILE_PATH_LITERAL("spiral.png")), 2976 &pass_list, base::FilePath(FILE_PATH_LITERAL("spiral.png")),
2974 FuzzyPixelOffByOneComparator(true))); 2977 FuzzyPixelOffByOneComparator(true)));
2975 } 2978 }
2976 2979
2977 #endif // !defined(OS_ANDROID) 2980 #endif // !defined(OS_ANDROID)
2978 2981
2979 } // namespace 2982 } // namespace
2980 } // namespace cc 2983 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/renderer.h ('k') | cc/output/renderer_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698