OLD | NEW |
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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 // Converts an unsigned int RGBA color into an unsigned int ARGB (DirectX) | 210 // Converts an unsigned int RGBA color into an unsigned int ARGB (DirectX) |
211 // color. | 211 // color. |
212 static unsigned int RGBAToARGB(unsigned int rgba) { | 212 static unsigned int RGBAToARGB(unsigned int rgba) { |
213 return (rgba >> 8) | (rgba << 24); | 213 return (rgba >> 8) | (rgba << 24); |
214 } | 214 } |
215 | 215 |
216 // Sets the current VertexStruct. Just keep track of the ID. | 216 // Sets the current VertexStruct. Just keep track of the ID. |
217 BufferSyncInterface::ParseError GAPID3D9::SetVertexStruct(ResourceID id) { | 217 BufferSyncInterface::ParseError GAPID3D9::SetVertexStruct(ResourceID id) { |
218 current_vertex_struct_ = id; | 218 current_vertex_struct_ = id; |
219 validate_streams_ = true; | 219 validate_streams_ = true; |
220 return BufferSyncInterface::PARSE_NO_ERROR; | 220 return BufferSyncInterface::kParseNoError; |
221 } | 221 } |
222 | 222 |
223 // Sets in D3D the input streams of the current vertex struct. | 223 // Sets in D3D the input streams of the current vertex struct. |
224 bool GAPID3D9::ValidateStreams() { | 224 bool GAPID3D9::ValidateStreams() { |
225 DCHECK(validate_streams_); | 225 DCHECK(validate_streams_); |
226 VertexStructD3D9 *vertex_struct = vertex_structs_.Get(current_vertex_struct_); | 226 VertexStructD3D9 *vertex_struct = vertex_structs_.Get(current_vertex_struct_); |
227 if (!vertex_struct) { | 227 if (!vertex_struct) { |
228 LOG(ERROR) << "Drawing with invalid streams."; | 228 LOG(ERROR) << "Drawing with invalid streams."; |
229 return false; | 229 return false; |
230 } | 230 } |
(...skipping 23 matching lines...) Expand all Loading... |
254 } | 254 } |
255 } | 255 } |
256 | 256 |
257 // Draws with the current vertex struct. | 257 // Draws with the current vertex struct. |
258 BufferSyncInterface::ParseError GAPID3D9::Draw( | 258 BufferSyncInterface::ParseError GAPID3D9::Draw( |
259 PrimitiveType primitive_type, | 259 PrimitiveType primitive_type, |
260 unsigned int first, | 260 unsigned int first, |
261 unsigned int count) { | 261 unsigned int count) { |
262 if (validate_streams_ && !ValidateStreams()) { | 262 if (validate_streams_ && !ValidateStreams()) { |
263 // TODO: add proper error management | 263 // TODO: add proper error management |
264 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 264 return BufferSyncInterface::kParseInvalidArguments; |
265 } | 265 } |
266 if (validate_effect_ && !ValidateEffect()) { | 266 if (validate_effect_ && !ValidateEffect()) { |
267 // TODO: add proper error management | 267 // TODO: add proper error management |
268 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 268 return BufferSyncInterface::kParseInvalidArguments; |
269 } | 269 } |
270 DCHECK(current_effect_); | 270 DCHECK(current_effect_); |
271 if (!current_effect_->CommitParameters(this)) { | 271 if (!current_effect_->CommitParameters(this)) { |
272 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 272 return BufferSyncInterface::kParseInvalidArguments; |
273 } | 273 } |
274 if (first + count > max_vertices_) { | 274 if (first + count > max_vertices_) { |
275 // TODO: add proper error management | 275 // TODO: add proper error management |
276 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 276 return BufferSyncInterface::kParseInvalidArguments; |
277 } | 277 } |
278 HR(d3d_device_->DrawPrimitive(D3DPrimitive(primitive_type), first, count)); | 278 HR(d3d_device_->DrawPrimitive(D3DPrimitive(primitive_type), first, count)); |
279 return BufferSyncInterface::PARSE_NO_ERROR; | 279 return BufferSyncInterface::kParseNoError; |
280 } | 280 } |
281 | 281 |
282 // Draws with the current vertex struct. | 282 // Draws with the current vertex struct. |
283 BufferSyncInterface::ParseError GAPID3D9::DrawIndexed( | 283 BufferSyncInterface::ParseError GAPID3D9::DrawIndexed( |
284 PrimitiveType primitive_type, | 284 PrimitiveType primitive_type, |
285 ResourceID index_buffer_id, | 285 ResourceID index_buffer_id, |
286 unsigned int first, | 286 unsigned int first, |
287 unsigned int count, | 287 unsigned int count, |
288 unsigned int min_index, | 288 unsigned int min_index, |
289 unsigned int max_index) { | 289 unsigned int max_index) { |
290 IndexBufferD3D9 *index_buffer = index_buffers_.Get(index_buffer_id); | 290 IndexBufferD3D9 *index_buffer = index_buffers_.Get(index_buffer_id); |
291 if (!index_buffer) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 291 if (!index_buffer) return BufferSyncInterface::kParseInvalidArguments; |
292 if (validate_streams_ && !ValidateStreams()) { | 292 if (validate_streams_ && !ValidateStreams()) { |
293 // TODO: add proper error management | 293 // TODO: add proper error management |
294 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 294 return BufferSyncInterface::kParseInvalidArguments; |
295 } | 295 } |
296 if (validate_effect_ && !ValidateEffect()) { | 296 if (validate_effect_ && !ValidateEffect()) { |
297 // TODO: add proper error management | 297 // TODO: add proper error management |
298 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 298 return BufferSyncInterface::kParseInvalidArguments; |
299 } | 299 } |
300 DCHECK(current_effect_); | 300 DCHECK(current_effect_); |
301 if (!current_effect_->CommitParameters(this)) { | 301 if (!current_effect_->CommitParameters(this)) { |
302 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 302 return BufferSyncInterface::kParseInvalidArguments; |
303 } | 303 } |
304 if ((min_index >= max_vertices_) || (max_index > max_vertices_)) { | 304 if ((min_index >= max_vertices_) || (max_index > max_vertices_)) { |
305 // TODO: add proper error management | 305 // TODO: add proper error management |
306 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 306 return BufferSyncInterface::kParseInvalidArguments; |
307 } | 307 } |
308 | 308 |
309 HR(d3d_device_->SetIndices(index_buffer->d3d_index_buffer())); | 309 HR(d3d_device_->SetIndices(index_buffer->d3d_index_buffer())); |
310 HR(d3d_device_->DrawIndexedPrimitive(D3DPrimitive(primitive_type), 0, | 310 HR(d3d_device_->DrawIndexedPrimitive(D3DPrimitive(primitive_type), 0, |
311 min_index, max_index - min_index + 1, | 311 min_index, max_index - min_index + 1, |
312 first, count)); | 312 first, count)); |
313 return BufferSyncInterface::PARSE_NO_ERROR; | 313 return BufferSyncInterface::kParseNoError; |
314 } | 314 } |
315 | 315 |
316 } // namespace command_buffer | 316 } // namespace command_buffer |
317 } // namespace o3d | 317 } // namespace o3d |
OLD | NEW |