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

Side by Side Diff: webrtc/test/gl/gl_renderer.cc

Issue 2535643002: Replace some asserts with DCHECKs (Closed)
Patch Set: Don't use the enum hack Created 4 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 | « webrtc/test/frame_generator.cc ('k') | webrtc/test/win/d3d_renderer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/common_video/libyuv/include/webrtc_libyuv.h" 16 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
16 17
17 namespace webrtc { 18 namespace webrtc {
18 namespace test { 19 namespace test {
19 20
20 GlRenderer::GlRenderer() 21 GlRenderer::GlRenderer()
21 : is_init_(false), buffer_(NULL), width_(0), height_(0) {} 22 : is_init_(false), buffer_(NULL), width_(0), height_(0) {}
22 23
23 void GlRenderer::Init() { 24 void GlRenderer::Init() {
24 assert(!is_init_); 25 RTC_DCHECK(!is_init_);
25 is_init_ = true; 26 is_init_ = true;
26 27
27 glGenTextures(1, &texture_); 28 glGenTextures(1, &texture_);
28 } 29 }
29 30
30 void GlRenderer::Destroy() { 31 void GlRenderer::Destroy() {
31 if (!is_init_) { 32 if (!is_init_) {
32 return; 33 return;
33 } 34 }
34 35
(...skipping 10 matching lines...) Expand all
45 glViewport(0, 0, width, height); 46 glViewport(0, 0, width, height);
46 47
47 glMatrixMode(GL_PROJECTION); 48 glMatrixMode(GL_PROJECTION);
48 glLoadIdentity(); 49 glLoadIdentity();
49 glClearColor(0.0f, 0.0f, 0.0f, 1.0f); 50 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
50 glOrtho(0.0f, 1.0f, 1.0f, 0.0f, -1.0f, 1.0f); 51 glOrtho(0.0f, 1.0f, 1.0f, 0.0f, -1.0f, 1.0f);
51 glMatrixMode(GL_MODELVIEW); 52 glMatrixMode(GL_MODELVIEW);
52 } 53 }
53 54
54 void GlRenderer::ResizeVideo(size_t width, size_t height) { 55 void GlRenderer::ResizeVideo(size_t width, size_t height) {
55 assert(is_init_); 56 RTC_DCHECK(is_init_);
56 width_ = width; 57 width_ = width;
57 height_ = height; 58 height_ = height;
58 59
59 buffer_size_ = width * height * 4; // BGRA 60 buffer_size_ = width * height * 4; // BGRA
60 61
61 delete[] buffer_; 62 delete[] buffer_;
62 buffer_ = new uint8_t[buffer_size_]; 63 buffer_ = new uint8_t[buffer_size_];
63 assert(buffer_ != NULL); 64 RTC_DCHECK(buffer_);
64 memset(buffer_, 0, buffer_size_); 65 memset(buffer_, 0, buffer_size_);
65 glBindTexture(GL_TEXTURE_2D, texture_); 66 glBindTexture(GL_TEXTURE_2D, texture_);
66 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); 67 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
67 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); 68 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
68 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_BGRA, 69 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_BGRA,
69 GL_UNSIGNED_INT_8_8_8_8, static_cast<GLvoid*>(buffer_)); 70 GL_UNSIGNED_INT_8_8_8_8, static_cast<GLvoid*>(buffer_));
70 } 71 }
71 72
72 void GlRenderer::OnFrame(const webrtc::VideoFrame& frame) { 73 void GlRenderer::OnFrame(const webrtc::VideoFrame& frame) {
73 assert(is_init_); 74 RTC_DCHECK(is_init_);
74 75
75 if (static_cast<size_t>(frame.width()) != width_ || 76 if (static_cast<size_t>(frame.width()) != width_ ||
76 static_cast<size_t>(frame.height()) != height_) { 77 static_cast<size_t>(frame.height()) != height_) {
77 ResizeVideo(frame.width(), frame.height()); 78 ResizeVideo(frame.width(), frame.height());
78 } 79 }
79 80
80 webrtc::ConvertFromI420(frame, kBGRA, 0, buffer_); 81 webrtc::ConvertFromI420(frame, kBGRA, 0, buffer_);
81 82
82 glEnable(GL_TEXTURE_2D); 83 glEnable(GL_TEXTURE_2D);
83 glBindTexture(GL_TEXTURE_2D, texture_); 84 glBindTexture(GL_TEXTURE_2D, texture_);
(...skipping 18 matching lines...) Expand all
102 glTexCoord2f(1.0f, 0.0f); 103 glTexCoord2f(1.0f, 0.0f);
103 glVertex3f(1.0f, 0.0f, 0.0f); 104 glVertex3f(1.0f, 0.0f, 0.0f);
104 } 105 }
105 glEnd(); 106 glEnd();
106 107
107 glBindTexture(GL_TEXTURE_2D, 0); 108 glBindTexture(GL_TEXTURE_2D, 0);
108 glFlush(); 109 glFlush();
109 } 110 }
110 } // test 111 } // test
111 } // webrtc 112 } // webrtc
OLDNEW
« no previous file with comments | « webrtc/test/frame_generator.cc ('k') | webrtc/test/win/d3d_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698