diff options
Diffstat (limited to 'o3d/core/cross/message_commands.h')
-rw-r--r-- | o3d/core/cross/message_commands.h | 312 |
1 files changed, 174 insertions, 138 deletions
diff --git a/o3d/core/cross/message_commands.h b/o3d/core/cross/message_commands.h index bb14f9b..216c837 100644 --- a/o3d/core/cross/message_commands.h +++ b/o3d/core/cross/message_commands.h @@ -62,107 +62,111 @@ O3D_PUSH_STRUCTURE_PACKING_1; OP(UPDATE_TEXTURE2D_RECT, MessageUpdateTexture2DRect) \
-// The base of all IMCMessages
-struct IMCMessage {
- enum MessageId {
- #define O3D_IMC_MESSAGE_OP(id, class_name) id,
- O3D_IMC_MESSAGE_LIST(O3D_IMC_MESSAGE_OP)
- #undef O3D_IMC_MESSAGE_OP
+namespace imc {
+enum MessageId {
+ #define O3D_IMC_MESSAGE_OP(id, class_name) id,
+ O3D_IMC_MESSAGE_LIST(O3D_IMC_MESSAGE_OP)
+ #undef O3D_IMC_MESSAGE_OP
- MAX_NUM_IDS,
+ MAX_NUM_IDS,
- ID_FORCE_DWORD = 0x7fffffff // Forces a 32-bit size enum
- };
-
- explicit IMCMessage(MessageId id) : message_id(id) {
- }
-
- // Returns a string by message ID.
- static const char* GetMessageDescription(MessageId id);
+ ID_FORCE_DWORD = 0x7fffffff // Forces a 32-bit size enum
+};
- int32 message_id;
+// Returns a string by message ID.
+const char* GetMessageDescription(MessageId id);
};
// An invalid message. This is mostly a place holder for id 0.
-struct MessageInvalidId : public IMCMessage {
- static const IMCMessage::MessageId kMessageId = INVALID_ID;
+struct MessageInvalidId {
+ // Message Content.
+ struct Msg {
+ static const imc::MessageId kMessageId = imc::INVALID_ID;
- MessageInvalidId()
- : IMCMessage(kMessageId) {
+ imc::MessageId message_id;
+ };
+
+ MessageInvalidId() {
+ msg.message_id = Msg::kMessageId;
}
+
+ Msg msg;
};
// The first message you send.
-struct MessageHello : public IMCMessage {
- static const IMCMessage::MessageId kMessageId = HELLO;
+struct MessageHello {
+ // Message Content.
+ struct Msg {
+ static const imc::MessageId kMessageId = imc::HELLO;
+
+ imc::MessageId message_id;
+ };
- MessageHello()
- : IMCMessage(kMessageId) {
+ MessageHello() {
+ msg.message_id = Msg::kMessageId;
}
+
+ Msg msg;
};
// A message to allocate shared memory
-struct MessageAllocateSharedMemory : public IMCMessage {
- static const MessageId kMessageId = ALLOCATE_SHARED_MEMORY;
- static const int32 kMaxSharedMemSize = 1024 * 1024 * 128; // 128MB
+struct MessageAllocateSharedMemory {
+ // Message Content.
+ struct Msg {
+ static const imc::MessageId kMessageId = imc::ALLOCATE_SHARED_MEMORY;
+ static const int32 kMaxSharedMemSize = 1024 * 1024 * 128; // 128MB
+
+ imc::MessageId message_id;
+
+ // The amount of memory to allocate.
+ int32 mem_size;
+ };
- MessageAllocateSharedMemory()
- : IMCMessage(kMessageId) {
+ MessageAllocateSharedMemory() {
+ msg.message_id = Msg::kMessageId;
}
// Parameters:
// in_mem_size: The number of bytes to allocate.
- explicit MessageAllocateSharedMemory(int32 in_mem_size)
- : IMCMessage(kMessageId),
- mem_size(in_mem_size) {
+ explicit MessageAllocateSharedMemory(int32 in_mem_size) {
+ msg.message_id = Msg::kMessageId;
+ msg.mem_size = in_mem_size;
}
- // The amount of memory to allocate.
- int32 mem_size;
+ Msg msg;
};
-// A message to register shared memory.
-struct MessageRegisterSharedMemory : public IMCMessage {
- static const MessageId kMessageId = REGISTER_SHARED_MEMORY;
- static const int32 kMaxSharedMemSize = 1024 * 1024 * 128; // 128MB
-
- MessageRegisterSharedMemory()
- : IMCMessage(kMessageId) {
- }
- explicit MessageRegisterSharedMemory(int32 in_mem_size)
- : IMCMessage(kMessageId),
- mem_size(in_mem_size) {
- }
+// A message to update the entire contents of a 2D texture. The number
+// of bytes MUST equal the size of the entire texture to be updated including
+// all mips.
+struct MessageUpdateTexture2D {
+ // Message Content.
+ struct Msg {
+ static const imc::MessageId kMessageId = imc::UPDATE_TEXTURE2D;
- int32 mem_size;
-};
+ imc::MessageId message_id;
-// A message to unregister shared memory.
-struct MessageUnregisterSharedMemory : public IMCMessage {
- static const MessageId kMessageId = UNREGISTER_SHARED_MEMORY;
+ // The id of the texture to set.
+ Id texture_id;
- MessageUnregisterSharedMemory()
- : IMCMessage(kMessageId) {
- }
+ // The mip level of the texture to set.
+ int32 level;
- // Parameters:
- // in_buffer_id: The id of the buffer to unregister.
- explicit MessageUnregisterSharedMemory(int32 in_buffer_id)
- : IMCMessage(kMessageId),
- buffer_id(in_buffer_id) {
- }
+ // The id of the shared memory the contains the data to use to set the
+ // texture.
+ int32 shared_memory_id;
- int32 buffer_id;
-};
+ // The offset inside the shared memory where the texture data starts.
+ int32 offset;
-// A message to update the entire contents of a 2D texture. The number
-// of bytes MUST equal the size of the entire texture to be updated including
-// all mips.
-struct MessageUpdateTexture2D : public IMCMessage {
- static const MessageId kMessageId = UPDATE_TEXTURE2D;
+ // The number of bytes to get out of shared memory.
+ // NOTE: this number MUST match the size of the texture. For example for an
+ // ARGB texture it must be mip_width * mip_height * 4 * sizeof(uint8)
+ int32 number_of_bytes;
+ };
- MessageUpdateTexture2D()
- : IMCMessage(kMessageId) {
+ MessageUpdateTexture2D() {
+ msg.message_id = Msg::kMessageId;
}
// Parameters:
@@ -179,41 +183,105 @@ struct MessageUpdateTexture2D : public IMCMessage { int32 in_level,
int32 in_shared_memory_id,
int32 in_offset,
- int32 in_number_of_bytes)
- : IMCMessage(kMessageId),
- texture_id(in_texture_id),
- level(in_level),
- shared_memory_id(in_shared_memory_id),
- offset(in_offset),
- number_of_bytes(in_number_of_bytes) {
+ int32 in_number_of_bytes) {
+ msg.message_id = Msg::kMessageId;
+ msg.texture_id = in_texture_id;
+ msg.level = in_level;
+ msg.shared_memory_id = in_shared_memory_id;
+ msg.offset = in_offset;
+ msg.number_of_bytes = in_number_of_bytes;
}
- // The id of the texture to set.
- Id texture_id;
+ Msg msg;
+};
- // The mip level of the texture to set.
- int32 level;
+// A message to register shared memory.
+struct MessageRegisterSharedMemory {
+ // Message Content.
+ struct Msg {
+ static const imc::MessageId kMessageId = imc::REGISTER_SHARED_MEMORY;
+ static const int32 kMaxSharedMemSize = 1024 * 1024 * 128; // 128MB
+
+ imc::MessageId message_id;
+ int32 mem_size;
+ };
- // The id of the shared memory the contains the data to use to set the
- // texture.
- int32 shared_memory_id;
+ MessageRegisterSharedMemory() {
+ msg.message_id = Msg::kMessageId;
+ }
- // The offset inside the shared memory where the texture data starts.
- int32 offset;
+ explicit MessageRegisterSharedMemory(int32 in_mem_size) {
+ msg.message_id = Msg::kMessageId;
+ msg.mem_size = in_mem_size;
+ }
- // The number of bytes to get out of shared memory.
- // NOTE: this number MUST match the size of the texture. For example for an
- // ARGB texture it must be mip_width * mip_height * 4 * sizeof(uint8)
- int32 number_of_bytes;
+ Msg msg;
+};
+
+// A message to unregister shared memory.
+struct MessageUnregisterSharedMemory {
+ // Message Content.
+ struct Msg {
+ static const imc::MessageId kMessageId = imc::UNREGISTER_SHARED_MEMORY;
+
+ imc::MessageId message_id;
+ int32 buffer_id;
+ };
+
+ MessageUnregisterSharedMemory() {
+ msg.message_id = Msg::kMessageId;
+ }
+
+ // Parameters:
+ // in_buffer_id: The id of the buffer to unregister.
+ explicit MessageUnregisterSharedMemory(int32 in_buffer_id) {
+ msg.message_id = Msg::kMessageId;
+ msg.buffer_id = in_buffer_id;
+ }
+
+ Msg msg;
};
// A message to update a portion of a 2D texture. The number of bytes MUST equal
// the size of the portion of the texture to be updated.
-struct MessageUpdateTexture2DRect : public IMCMessage {
- static const MessageId kMessageId = UPDATE_TEXTURE2D_RECT;
+struct MessageUpdateTexture2DRect {
+ // Message Content.
+ struct Msg {
+ static const imc::MessageId kMessageId = imc::UPDATE_TEXTURE2D_RECT;
+
+ imc::MessageId message_id;
+
+ // The id of the texture to set.
+ Id texture_id;
+
+ // The mip level of the texture to set.
+ int32 level;
- MessageUpdateTexture2DRect()
- : IMCMessage(kMessageId) {
+ // The left edge of the rectangle to update in the texture.
+ int32 x;
+
+ // The top edge of the rectangle to update in the texture.
+ int32 y;
+
+ // The width of the rectangle to update in the texture.
+ int32 width;
+
+ // The height of the rectangle to update in the texture.
+ int32 height;
+
+ // The id of the shared memory the contains the data to use to set the
+ // texture.
+ int32 shared_memory_id;
+
+ // The offset inside the shared memory where the texture data starts.
+ int32 offset;
+
+ // The number of bytes bytes across 1 row in the source data.
+ int32 pitch;
+ };
+
+ MessageUpdateTexture2DRect() {
+ msg.message_id = Msg::kMessageId;
}
// Parameters:
@@ -227,10 +295,7 @@ struct MessageUpdateTexture2DRect : public IMCMessage { // use to set the texture.
// in_offset: The offset inside the shared memory where the texture data
// starts.
- // in_number_of_bytes: The number of bytes to get out of shared memory.
- // NOTE: this number MUST match the size of the area in the texture to
- // be updated. For example for an ARGB texture it must be
- // width * height 4 * sizeof(uint8)
+ // in_pitch: The number of bytes bytes across 1 row in the source data.
MessageUpdateTexture2DRect(Id in_texture_id,
int32 in_level,
int32 in_x,
@@ -239,49 +304,20 @@ struct MessageUpdateTexture2DRect : public IMCMessage { int32 in_height,
int32 in_shared_memory_id,
int32 in_offset,
- int32 in_number_of_bytes)
- : IMCMessage(kMessageId),
- texture_id(in_texture_id),
- level(in_level),
- x(in_x),
- y(in_y),
- width(in_width),
- height(in_height),
- shared_memory_id(in_shared_memory_id),
- offset(in_offset),
- number_of_bytes(in_number_of_bytes) {
+ int32 in_pitch) {
+ msg.message_id = Msg::kMessageId;
+ msg.texture_id = in_texture_id;
+ msg.level = in_level;
+ msg.x = in_x;
+ msg.y = in_y;
+ msg.width = in_width;
+ msg.height = in_height;
+ msg.shared_memory_id = in_shared_memory_id;
+ msg.offset = in_offset;
+ msg.pitch = in_pitch;
}
- // The id of the texture to set.
- Id texture_id;
-
- // The mip level of the texture to set.
- int32 level;
-
- // The left edge of the rectangle to update in the texture.
- int32 x;
-
- // The top edge of the rectangle to update in the texture.
- int32 y;
-
- // The width of the rectangle to update in the texture.
- int32 width;
-
- // The height of the rectangle to update in the texture.
- int32 height;
-
- // The id of the shared memory the contains the data to use to set the
- // texture.
- int32 shared_memory_id;
-
- // The offset inside the shared memory where the texture data starts.
- int32 offset;
-
- // The number of bytes to get out of shared memory.
- // NOTE: this number MUST match the size of the area in the texture to be
- // updated. For example for an ARGB texture it must be
- // width * height 4 * sizeof(uint8)
- int32 number_of_bytes;
+ Msg msg;
};
O3D_POP_STRUCTURE_PACKING;
|