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

Unified Diff: core/cross/command_buffer/states_cb.h

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/cross/command_buffer/sampler_cb.cc ('k') | core/cross/command_buffer/states_cb.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/cross/command_buffer/states_cb.h
===================================================================
--- core/cross/command_buffer/states_cb.h (revision 26638)
+++ core/cross/command_buffer/states_cb.h (working copy)
@@ -59,41 +59,43 @@
// A template helper. This wraps a command sent to set a set of states. It
// keeps all the arguments of a single command, that get modified by the
// various handles, as well as a dirty bit.
- template <command_buffer::CommandId command, unsigned int arg_count>
+ template <typename CommandType>
class StateHelper {
public:
- static const unsigned int kArgCount = arg_count;
-
StateHelper() : dirty_(false) {
- for (unsigned int i = 0; i < kArgCount; ++i) {
- args_[i].value_uint32 = 0;
- }
+ // NOTE: This code assumes the state commands only need their
+ // header set and that the rest will be set by the state handlers.
+ memset(&command_, 0, sizeof(command_));
+ command_.SetHeader();
}
// Sends the command if it is marked as dirty.
void Validate(command_buffer::CommandBufferHelper *helper) {
if (!dirty_) return;
- helper->AddCommand(command, kArgCount, args_);
+ helper->AddTypedCmdData(command_);
dirty_ = false;
}
- command_buffer::CommandBufferEntry *args() { return args_; }
+ CommandType& command() {
+ return command_;
+ }
+
bool *dirty_ptr() { return &dirty_; }
private:
bool dirty_;
- command_buffer::CommandBufferEntry args_[kArgCount];
+ CommandType command_;
DISALLOW_COPY_AND_ASSIGN(StateHelper);
};
- StateHelper<command_buffer::SET_POINT_LINE_RASTER, 2> point_line_helper_;
- StateHelper<command_buffer::SET_POLYGON_OFFSET, 2> poly_offset_helper_;
- StateHelper<command_buffer::SET_POLYGON_RASTER, 1> poly_raster_helper_;
- StateHelper<command_buffer::SET_ALPHA_TEST, 2> alpha_test_helper_;
- StateHelper<command_buffer::SET_DEPTH_TEST, 1> depth_test_helper_;
- StateHelper<command_buffer::SET_STENCIL_TEST, 2> stencil_test_helper_;
- StateHelper<command_buffer::SET_COLOR_WRITE, 1> color_write_helper_;
- StateHelper<command_buffer::SET_BLENDING, 1> blending_helper_;
- StateHelper<command_buffer::SET_BLENDING_COLOR, 4> blending_color_helper_;
+ StateHelper<command_buffer::cmd::SetPointLineRaster> point_line_helper_;
+ StateHelper<command_buffer::cmd::SetPolygonOffset> poly_offset_helper_;
+ StateHelper<command_buffer::cmd::SetPolygonRaster> poly_raster_helper_;
+ StateHelper<command_buffer::cmd::SetAlphaTest> alpha_test_helper_;
+ StateHelper<command_buffer::cmd::SetDepthTest> depth_test_helper_;
+ StateHelper<command_buffer::cmd::SetStencilTest> stencil_test_helper_;
+ StateHelper<command_buffer::cmd::SetColorWrite> color_write_helper_;
+ StateHelper<command_buffer::cmd::SetBlending> blending_helper_;
+ StateHelper<command_buffer::cmd::SetBlendingColor> blending_color_helper_;
DISALLOW_COPY_AND_ASSIGN(StateManager);
};
« no previous file with comments | « core/cross/command_buffer/sampler_cb.cc ('k') | core/cross/command_buffer/states_cb.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698