| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2004 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 width_ = width; | 78 width_ = width; |
| 79 height_ = height; | 79 height_ = height; |
| 80 return true; | 80 return true; |
| 81 } | 81 } |
| 82 | 82 |
| 83 void GtkVideoRenderer::OnFrame(const VideoFrame& video_frame) { | 83 void GtkVideoRenderer::OnFrame(const VideoFrame& video_frame) { |
| 84 const VideoFrame* frame = video_frame.GetCopyWithRotationApplied(); | 84 const VideoFrame* frame = video_frame.GetCopyWithRotationApplied(); |
| 85 | 85 |
| 86 // Need to set size as the frame might be rotated. | 86 // Need to set size as the frame might be rotated. |
| 87 if (!SetSize(frame->GetWidth(), frame->GetHeight())) { | 87 if (!SetSize(frame->width(), frame->height())) { |
| 88 return; | 88 return; |
| 89 } | 89 } |
| 90 | 90 |
| 91 // convert I420 frame to ABGR format, which is accepted by GTK | 91 // convert I420 frame to ABGR format, which is accepted by GTK |
| 92 frame->ConvertToRgbBuffer(cricket::FOURCC_ABGR, | 92 frame->ConvertToRgbBuffer(cricket::FOURCC_ABGR, |
| 93 image_.get(), | 93 image_.get(), |
| 94 frame->GetWidth() * frame->GetHeight() * 4, | 94 static_cast<size_t>(frame->width()) * |
| 95 frame->GetWidth() * 4); | 95 frame->height() * 4, |
| 96 frame->width() * 4); |
| 96 | 97 |
| 97 ScopedGdkLock lock; | 98 ScopedGdkLock lock; |
| 98 | 99 |
| 99 if (IsClosed()) { | 100 if (IsClosed()) { |
| 100 return; | 101 return; |
| 101 } | 102 } |
| 102 | 103 |
| 103 // draw the ABGR image | 104 // draw the ABGR image |
| 104 gdk_draw_rgb_32_image(draw_area_->window, | 105 gdk_draw_rgb_32_image(draw_area_->window, |
| 105 draw_area_->style->fg_gc[GTK_STATE_NORMAL], | 106 draw_area_->style->fg_gc[GTK_STATE_NORMAL], |
| 106 0, | 107 0, |
| 107 0, | 108 0, |
| 108 frame->GetWidth(), | 109 frame->width(), |
| 109 frame->GetHeight(), | 110 frame->height(), |
| 110 GDK_RGB_DITHER_MAX, | 111 GDK_RGB_DITHER_MAX, |
| 111 image_.get(), | 112 image_.get(), |
| 112 frame->GetWidth() * 4); | 113 frame->width() * 4); |
| 113 | 114 |
| 114 // Run the Gtk main loop to refresh the window. | 115 // Run the Gtk main loop to refresh the window. |
| 115 Pump(); | 116 Pump(); |
| 116 } | 117 } |
| 117 | 118 |
| 118 bool GtkVideoRenderer::Initialize(int width, int height) { | 119 bool GtkVideoRenderer::Initialize(int width, int height) { |
| 119 gtk_init(NULL, NULL); | 120 gtk_init(NULL, NULL); |
| 120 window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL); | 121 window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
| 121 draw_area_ = gtk_drawing_area_new(); | 122 draw_area_ = gtk_drawing_area_new(); |
| 122 if (!window_ || !draw_area_) { | 123 if (!window_ || !draw_area_) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 148 } | 149 } |
| 149 | 150 |
| 150 if (!GTK_IS_WINDOW(window_) || !GTK_IS_DRAWING_AREA(draw_area_)) { | 151 if (!GTK_IS_WINDOW(window_) || !GTK_IS_DRAWING_AREA(draw_area_)) { |
| 151 return true; | 152 return true; |
| 152 } | 153 } |
| 153 | 154 |
| 154 return false; | 155 return false; |
| 155 } | 156 } |
| 156 | 157 |
| 157 } // namespace cricket | 158 } // namespace cricket |
| OLD | NEW |