OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 |
11 #include "webrtc/test/gl/gl_renderer.h" | 11 #include "webrtc/test/gl/gl_renderer.h" |
12 | 12 |
13 #include <string.h> | 13 #include <string.h> |
14 | 14 |
15 #include "webrtc/base/checks.h" | 15 #include "webrtc/base/checks.h" |
16 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 16 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
17 | 17 |
18 namespace webrtc { | 18 namespace webrtc { |
19 namespace test { | 19 namespace test { |
20 | 20 |
21 GlRenderer::GlRenderer() | 21 GlRenderer::GlRenderer() |
22 : is_init_(false), buffer_(NULL), width_(0), height_(0) {} | 22 : is_init_(false), buffer_(nullptr), width_(0), height_(0) {} |
23 | 23 |
24 void GlRenderer::Init() { | 24 void GlRenderer::Init() { |
25 RTC_DCHECK(!is_init_); | 25 RTC_DCHECK(!is_init_); |
26 is_init_ = true; | 26 is_init_ = true; |
27 | 27 |
28 glGenTextures(1, &texture_); | 28 glGenTextures(1, &texture_); |
29 } | 29 } |
30 | 30 |
31 void GlRenderer::Destroy() { | 31 void GlRenderer::Destroy() { |
32 if (!is_init_) { | 32 if (!is_init_) { |
33 return; | 33 return; |
34 } | 34 } |
35 | 35 |
36 is_init_ = false; | 36 is_init_ = false; |
37 | 37 |
38 delete[] buffer_; | 38 delete[] buffer_; |
39 buffer_ = NULL; | 39 buffer_ = nullptr; |
40 | 40 |
41 glDeleteTextures(1, &texture_); | 41 glDeleteTextures(1, &texture_); |
42 } | 42 } |
43 | 43 |
44 void GlRenderer::ResizeViewport(size_t width, size_t height) { | 44 void GlRenderer::ResizeViewport(size_t width, size_t height) { |
45 // TODO(pbos): Aspect ratio, letterbox the video. | 45 // TODO(pbos): Aspect ratio, letterbox the video. |
46 glViewport(0, 0, width, height); | 46 glViewport(0, 0, width, height); |
47 | 47 |
48 glMatrixMode(GL_PROJECTION); | 48 glMatrixMode(GL_PROJECTION); |
49 glLoadIdentity(); | 49 glLoadIdentity(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 glTexCoord2f(1.0f, 0.0f); | 103 glTexCoord2f(1.0f, 0.0f); |
104 glVertex3f(1.0f, 0.0f, 0.0f); | 104 glVertex3f(1.0f, 0.0f, 0.0f); |
105 } | 105 } |
106 glEnd(); | 106 glEnd(); |
107 | 107 |
108 glBindTexture(GL_TEXTURE_2D, 0); | 108 glBindTexture(GL_TEXTURE_2D, 0); |
109 glFlush(); | 109 glFlush(); |
110 } | 110 } |
111 } // test | 111 } // test |
112 } // webrtc | 112 } // webrtc |
OLD | NEW |