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

Side by Side Diff: webrtc/test/win/d3d_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/gl/gl_renderer.cc ('k') | no next file » | 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 #include "webrtc/test/win/d3d_renderer.h" 10 #include "webrtc/test/win/d3d_renderer.h"
11 11
12 #include "webrtc/base/checks.h"
12 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" 13 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
13 14
14 namespace webrtc { 15 namespace webrtc {
15 namespace test { 16 namespace test {
16 17
17 #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_TEX1) 18 #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_TEX1)
18 19
19 struct D3dCustomVertex { 20 struct D3dCustomVertex {
20 float x, y, z; 21 float x, y, z;
21 float u, v; 22 float u, v;
22 }; 23 };
23 24
24 const char kD3DClassName[] = "d3d_renderer"; 25 const char kD3DClassName[] = "d3d_renderer";
25 26
26 VideoRenderer* VideoRenderer::CreatePlatformRenderer(const char* window_title, 27 VideoRenderer* VideoRenderer::CreatePlatformRenderer(const char* window_title,
27 size_t width, 28 size_t width,
28 size_t height) { 29 size_t height) {
29 return D3dRenderer::Create(window_title, width, height); 30 return D3dRenderer::Create(window_title, width, height);
30 } 31 }
31 32
32 D3dRenderer::D3dRenderer(size_t width, size_t height) 33 D3dRenderer::D3dRenderer(size_t width, size_t height)
33 : width_(width), 34 : width_(width),
34 height_(height), 35 height_(height),
35 hwnd_(NULL), 36 hwnd_(NULL),
36 d3d_(NULL), 37 d3d_(NULL),
37 d3d_device_(NULL), 38 d3d_device_(NULL),
38 texture_(NULL), 39 texture_(NULL),
39 vertex_buffer_(NULL) { 40 vertex_buffer_(NULL) {
40 assert(width > 0); 41 RTC_DCHECK_GT(width, 0);
41 assert(height > 0); 42 RTC_DCHECK_GT(height, 0);
42 } 43 }
43 44
44 D3dRenderer::~D3dRenderer() { Destroy(); } 45 D3dRenderer::~D3dRenderer() { Destroy(); }
45 46
46 LRESULT WINAPI D3dRenderer::WindowProc(HWND hwnd, UINT msg, WPARAM wparam, 47 LRESULT WINAPI D3dRenderer::WindowProc(HWND hwnd, UINT msg, WPARAM wparam,
47 LPARAM lparam) { 48 LPARAM lparam) {
48 if (msg == WM_DESTROY || (msg == WM_CHAR && wparam == VK_RETURN)) { 49 if (msg == WM_DESTROY || (msg == WM_CHAR && wparam == VK_RETURN)) {
49 PostQuitMessage(0); 50 PostQuitMessage(0);
50 return 0; 51 return 0;
51 } 52 }
52 53
53 return DefWindowProcA(hwnd, msg, wparam, lparam); 54 return DefWindowProcA(hwnd, msg, wparam, lparam);
54 } 55 }
55 56
56 void D3dRenderer::Destroy() { 57 void D3dRenderer::Destroy() {
57 texture_ = NULL; 58 texture_ = NULL;
58 vertex_buffer_ = NULL; 59 vertex_buffer_ = NULL;
59 d3d_device_ = NULL; 60 d3d_device_ = NULL;
60 d3d_ = NULL; 61 d3d_ = NULL;
61 62
62 if (hwnd_ != NULL) { 63 if (hwnd_ != NULL) {
63 DestroyWindow(hwnd_); 64 DestroyWindow(hwnd_);
64 assert(!IsWindow(hwnd_)); 65 RTC_DCHECK(!IsWindow(hwnd_));
65 hwnd_ = NULL; 66 hwnd_ = NULL;
66 } 67 }
67 } 68 }
68 69
69 bool D3dRenderer::Init(const char* window_title) { 70 bool D3dRenderer::Init(const char* window_title) {
70 hwnd_ = CreateWindowA(kD3DClassName, 71 hwnd_ = CreateWindowA(kD3DClassName,
71 window_title, 72 window_title,
72 WS_OVERLAPPEDWINDOW, 73 WS_OVERLAPPEDWINDOW,
73 0, 74 0,
74 0, 75 0,
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 d3d_device_->SetFVF(D3DFVF_CUSTOMVERTEX); 210 d3d_device_->SetFVF(D3DFVF_CUSTOMVERTEX);
210 d3d_device_->SetStreamSource(0, vertex_buffer_, 0, sizeof(D3dCustomVertex)); 211 d3d_device_->SetStreamSource(0, vertex_buffer_, 0, sizeof(D3dCustomVertex));
211 d3d_device_->SetTexture(0, texture_); 212 d3d_device_->SetTexture(0, texture_);
212 d3d_device_->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); 213 d3d_device_->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
213 d3d_device_->EndScene(); 214 d3d_device_->EndScene();
214 215
215 d3d_device_->Present(NULL, NULL, NULL, NULL); 216 d3d_device_->Present(NULL, NULL, NULL, NULL);
216 } 217 }
217 } // namespace test 218 } // namespace test
218 } // namespace webrtc 219 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/test/gl/gl_renderer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698