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

Side by Side Diff: webrtc/examples/peerconnection/client/linux/main_wnd.cc

Issue 1362503003: Use suffixed {uint,int}{8,16,32,64}_t types. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase + revert basictypes.h (to be landed separately just in case of a revert due to unexpected us… Created 5 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
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2012 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 gdk_threads_enter(); 387 gdk_threads_enter();
388 388
389 VideoRenderer* remote_renderer = remote_renderer_.get(); 389 VideoRenderer* remote_renderer = remote_renderer_.get();
390 if (remote_renderer && remote_renderer->image() != NULL && 390 if (remote_renderer && remote_renderer->image() != NULL &&
391 draw_area_ != NULL) { 391 draw_area_ != NULL) {
392 int width = remote_renderer->width(); 392 int width = remote_renderer->width();
393 int height = remote_renderer->height(); 393 int height = remote_renderer->height();
394 394
395 if (!draw_buffer_.get()) { 395 if (!draw_buffer_.get()) {
396 draw_buffer_size_ = (width * height * 4) * 4; 396 draw_buffer_size_ = (width * height * 4) * 4;
397 draw_buffer_.reset(new uint8[draw_buffer_size_]); 397 draw_buffer_.reset(new uint8_t[draw_buffer_size_]);
398 gtk_widget_set_size_request(draw_area_, width * 2, height * 2); 398 gtk_widget_set_size_request(draw_area_, width * 2, height * 2);
399 } 399 }
400 400
401 const uint32* image = reinterpret_cast<const uint32*>( 401 const uint32_t* image =
402 remote_renderer->image()); 402 reinterpret_cast<const uint32_t*>(remote_renderer->image());
403 uint32* scaled = reinterpret_cast<uint32*>(draw_buffer_.get()); 403 uint32_t* scaled = reinterpret_cast<uint32_t*>(draw_buffer_.get());
404 for (int r = 0; r < height; ++r) { 404 for (int r = 0; r < height; ++r) {
405 for (int c = 0; c < width; ++c) { 405 for (int c = 0; c < width; ++c) {
406 int x = c * 2; 406 int x = c * 2;
407 scaled[x] = scaled[x + 1] = image[c]; 407 scaled[x] = scaled[x + 1] = image[c];
408 } 408 }
409 409
410 uint32* prev_line = scaled; 410 uint32_t* prev_line = scaled;
411 scaled += width * 2; 411 scaled += width * 2;
412 memcpy(scaled, prev_line, (width * 2) * 4); 412 memcpy(scaled, prev_line, (width * 2) * 4);
413 413
414 image += width; 414 image += width;
415 scaled += width * 2; 415 scaled += width * 2;
416 } 416 }
417 417
418 VideoRenderer* local_renderer = local_renderer_.get(); 418 VideoRenderer* local_renderer = local_renderer_.get();
419 if (local_renderer && local_renderer->image()) { 419 if (local_renderer && local_renderer->image()) {
420 image = reinterpret_cast<const uint32*>(local_renderer->image()); 420 image = reinterpret_cast<const uint32_t*>(local_renderer->image());
421 scaled = reinterpret_cast<uint32*>(draw_buffer_.get()); 421 scaled = reinterpret_cast<uint32_t*>(draw_buffer_.get());
422 // Position the local preview on the right side. 422 // Position the local preview on the right side.
423 scaled += (width * 2) - (local_renderer->width() / 2); 423 scaled += (width * 2) - (local_renderer->width() / 2);
424 // right margin... 424 // right margin...
425 scaled -= 10; 425 scaled -= 10;
426 // ... towards the bottom. 426 // ... towards the bottom.
427 scaled += (height * width * 4) - 427 scaled += (height * width * 4) -
428 ((local_renderer->height() / 2) * 428 ((local_renderer->height() / 2) *
429 (local_renderer->width() / 2) * 4); 429 (local_renderer->width() / 2) * 4);
430 // bottom margin... 430 // bottom margin...
431 scaled -= (width * 2) * 5; 431 scaled -= (width * 2) * 5;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 467
468 void GtkMainWnd::VideoRenderer::SetSize(int width, int height) { 468 void GtkMainWnd::VideoRenderer::SetSize(int width, int height) {
469 gdk_threads_enter(); 469 gdk_threads_enter();
470 470
471 if (width_ == width && height_ == height) { 471 if (width_ == width && height_ == height) {
472 return; 472 return;
473 } 473 }
474 474
475 width_ = width; 475 width_ = width;
476 height_ = height; 476 height_ = height;
477 image_.reset(new uint8[width * height * 4]); 477 image_.reset(new uint8_t[width * height * 4]);
478 gdk_threads_leave(); 478 gdk_threads_leave();
479 } 479 }
480 480
481 void GtkMainWnd::VideoRenderer::RenderFrame( 481 void GtkMainWnd::VideoRenderer::RenderFrame(
482 const cricket::VideoFrame* video_frame) { 482 const cricket::VideoFrame* video_frame) {
483 gdk_threads_enter(); 483 gdk_threads_enter();
484 484
485 const cricket::VideoFrame* frame = video_frame->GetCopyWithRotationApplied(); 485 const cricket::VideoFrame* frame = video_frame->GetCopyWithRotationApplied();
486 486
487 SetSize(static_cast<int>(frame->GetWidth()), 487 SetSize(static_cast<int>(frame->GetWidth()),
488 static_cast<int>(frame->GetHeight())); 488 static_cast<int>(frame->GetHeight()));
489 489
490 int size = width_ * height_ * 4; 490 int size = width_ * height_ * 4;
491 // TODO: Convert directly to RGBA 491 // TODO: Convert directly to RGBA
492 frame->ConvertToRgbBuffer(cricket::FOURCC_ARGB, 492 frame->ConvertToRgbBuffer(cricket::FOURCC_ARGB,
493 image_.get(), 493 image_.get(),
494 size, 494 size,
495 width_ * 4); 495 width_ * 4);
496 // Convert the B,G,R,A frame to R,G,B,A, which is accepted by GTK. 496 // Convert the B,G,R,A frame to R,G,B,A, which is accepted by GTK.
497 // The 'A' is just padding for GTK, so we can use it as temp. 497 // The 'A' is just padding for GTK, so we can use it as temp.
498 uint8* pix = image_.get(); 498 uint8_t* pix = image_.get();
499 uint8* end = image_.get() + size; 499 uint8_t* end = image_.get() + size;
500 while (pix < end) { 500 while (pix < end) {
501 pix[3] = pix[0]; // Save B to A. 501 pix[3] = pix[0]; // Save B to A.
502 pix[0] = pix[2]; // Set Red. 502 pix[0] = pix[2]; // Set Red.
503 pix[2] = pix[3]; // Set Blue. 503 pix[2] = pix[3]; // Set Blue.
504 pix[3] = 0xFF; // Fixed Alpha. 504 pix[3] = 0xFF; // Fixed Alpha.
505 pix += 4; 505 pix += 4;
506 } 506 }
507 507
508 gdk_threads_leave(); 508 gdk_threads_leave();
509 509
510 g_idle_add(Redraw, main_wnd_); 510 g_idle_add(Redraw, main_wnd_);
511 } 511 }
512 512
513 513
OLDNEW
« no previous file with comments | « webrtc/examples/peerconnection/client/linux/main_wnd.h ('k') | webrtc/examples/peerconnection/client/main_wnd.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698