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

Side by Side Diff: command_buffer/service/win/d3d9/d3d9_utils.h

Issue 147237: Adding GetStreamInfo functionality (and passing corresponding unit test). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 11 years, 5 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2009, Google Inc. 2 * Copyright 2009, Google Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 89 }
90 90
91 // Converts a RGBA color into a D3DCOLOR 91 // Converts a RGBA color into a D3DCOLOR
92 inline D3DCOLOR RGBAToD3DCOLOR(const RGBA &color) { 92 inline D3DCOLOR RGBAToD3DCOLOR(const RGBA &color) {
93 return D3DCOLOR_RGBA(FloatToClampedByte(color.red), 93 return D3DCOLOR_RGBA(FloatToClampedByte(color.red),
94 FloatToClampedByte(color.green), 94 FloatToClampedByte(color.green),
95 FloatToClampedByte(color.blue), 95 FloatToClampedByte(color.blue),
96 FloatToClampedByte(color.alpha)); 96 FloatToClampedByte(color.alpha));
97 } 97 }
98 98
99 inline bool VerifyHResult(HRESULT hr, const char* file, int line,
100 const char* call) {
101 if (FAILED(hr)) {
102 DLOG(ERROR) << "DX Error in file " << file
103 << " line " << line << L": "
104 << DXGetErrorStringA(hr) << L": " << call;
105 return false;
106 }
107 return true;
108 }
109
110 static bool D3DSemanticToCBSemantic(
111 D3DDECLUSAGE semantic,
112 unsigned int semantic_index,
113 vertex_struct::Semantic *out_semantic,
114 unsigned int *out_semantic_index) {
115 // TODO: what meaning do we really want to put to our semantics ? How
116 // do they match the semantics that are set in the effect ? What combination
117 // of (semantic, index) are supposed to work ?
118 switch (semantic) {
119 case D3DDECLUSAGE_POSITION:
120 if (semantic_index != 0) return false;
121 *out_semantic = vertex_struct::POSITION;
122 *out_semantic_index = 0;
123 return true;
124 case D3DDECLUSAGE_NORMAL:
125 if (semantic_index != 0) return false;
126 *out_semantic = vertex_struct::NORMAL;
127 *out_semantic_index = 0;
128 return true;
129 case D3DDECLUSAGE_TANGENT:
130 if (semantic_index != 0) return false;
131 *out_semantic = vertex_struct::TEX_COORD;
132 *out_semantic_index = 6;
133 return true;
134 case D3DDECLUSAGE_BINORMAL:
135 if (semantic_index != 0) return false;
136 *out_semantic = vertex_struct::TEX_COORD;
137 *out_semantic_index = 7;
138 return true;
139 case D3DDECLUSAGE_COLOR:
140 if (semantic_index > 1) return false;
141 *out_semantic = vertex_struct::COLOR;
142 *out_semantic_index = semantic_index;
143 return true;
144 case D3DDECLUSAGE_TEXCOORD:
145 *out_semantic = vertex_struct::TEX_COORD;
146 *out_semantic_index = semantic_index;
147 return true;
148 default:
149 return false;
150 }
151 }
99 } // namespace command_buffer 152 } // namespace command_buffer
100 } // namespace o3d 153 } // namespace o3d
101 154
102 #endif // O3D_COMMAND_BUFFER_SERVICE_WIN_D3D9_D3D9_UTILS_H__ 155 #endif // O3D_COMMAND_BUFFER_SERVICE_WIN_D3D9_D3D9_UTILS_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698