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

Side by Side Diff: core/cross/command_buffer/primitive_cb.cc

Issue 212018: Change command buffer client code to use structures.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 11 years, 3 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 stream_bank_cb, 105 stream_bank_cb,
106 material, 106 material,
107 override)) { 107 override)) {
108 // TODO: should we do this here, or on the service side ? 108 // TODO: should we do this here, or on the service side ?
109 // InsertMissingVertexStreams(); 109 // InsertMissingVertexStreams();
110 } 110 }
111 111
112 IndexBufferCB *index_buffer_cb = 112 IndexBufferCB *index_buffer_cb =
113 down_cast<IndexBufferCB *>(index_buffer()); 113 down_cast<IndexBufferCB *>(index_buffer());
114 if (!index_buffer_cb) { 114 if (!index_buffer_cb) {
115 // TODO: draw non-index in this case ? we don't do it currently on 115 // TODO(gman): draw non-indexed primitives.
116 // other platforms, so keep compatibility.
117 DLOG(INFO) << "Trying to draw with an empty index buffer."; 116 DLOG(INFO) << "Trying to draw with an empty index buffer.";
118 return; 117 return;
119 } 118 }
120 GAPIInterface::PrimitiveType cb_primitive_type = 119 GAPIInterface::PrimitiveType cb_primitive_type =
121 GetCBPrimitiveType(primitive_type_); 120 GetCBPrimitiveType(primitive_type_);
122 if (cb_primitive_type == GAPIInterface::MAX_PRIMITIVE_TYPE) { 121 if (cb_primitive_type == GAPIInterface::MAX_PRIMITIVE_TYPE) {
123 DLOG(INFO) << "Invalid primitive type (" << primitive_type_ << ")."; 122 DLOG(INFO) << "Invalid primitive type (" << primitive_type_ << ").";
124 return; 123 return;
125 } 124 }
126 125
127 // Make sure our streams are up to date (skinned, etc..) 126 // Make sure our streams are up to date (skinned, etc..)
128 stream_bank_cb->UpdateStreams(); 127 stream_bank_cb->UpdateStreams();
129 128
130 stream_bank_cb->BindStreamsForRendering(); 129 stream_bank_cb->BindStreamsForRendering();
131 130
132 CommandBufferHelper *helper = renderer_->helper(); 131 CommandBufferHelper *helper = renderer_->helper();
133 CommandBufferEntry args[6];
134 132
135 // Sets current effect. 133 // Sets current effect.
136 // TODO: cache current effect ? 134 // TODO: cache current effect ?
137 args[0].value_uint32 = effect_cb->resource_id(); 135 helper->SetEffect(effect_cb->resource_id());
138 helper->AddCommand(command_buffer::SET_EFFECT, 1, args);
139 param_cache_cb->RunHandlers(helper); 136 param_cache_cb->RunHandlers(helper);
140 137
141
142 // Draws. 138 // Draws.
143 args[0].value_uint32 = cb_primitive_type; 139 helper->DrawIndexed(cb_primitive_type, index_buffer_cb->resource_id(),
144 args[1].value_uint32 = index_buffer_cb->resource_id(); 140 0, number_primitives_, 0, number_vertices_ - 1);
145 args[2].value_uint32 = 0; // first index.
146 args[3].value_uint32 = number_primitives_; // primitive count.
147 args[4].value_uint32 = 0; // min index.
148 args[5].value_uint32 = number_vertices_ - 1; // max index.
149 helper->AddCommand(command_buffer::DRAW_INDEXED, 6, args);
150 } 141 }
151 142
152 } // namespace o3d 143 } // namespace o3d
OLDNEW
« no previous file with comments | « core/cross/command_buffer/param_cache_cb.cc ('k') | core/cross/command_buffer/render_surface_cb.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698