@@ -193,10 +193,17 @@ void ControlCenter::process_command() noexcept
193
193
}
194
194
break ;
195
195
196
+ case EIOSCommand::GET_IMAGE_DIMENSIONS:
197
+ {
198
+ image_data.set_image_width (get_image_width ());
199
+ image_data.set_image_height (get_image_height ());
200
+ }
201
+ break ;
202
+
196
203
case EIOSCommand::GET_TARGET_DIMENSIONS:
197
204
{
198
- image_data.set_width ( get_width ());
199
- image_data.set_height ( get_height ());
205
+ image_data.set_target_width ( get_target_width ());
206
+ image_data.set_target_height ( get_target_height ());
200
207
}
201
208
break ;
202
209
@@ -891,15 +898,15 @@ bool ControlCenter::init_maps() noexcept
891
898
memory_map = std::make_unique<MemoryMapStream<ImageData>>(mapName, sizeof (ImageData), MemoryMapStream<ImageData>::open_mode::read );
892
899
if (memory_map && memory_map->is_mapped ())
893
900
{
894
- int width = memory_map->data ().width ();
895
- int height = memory_map->data ().height ();
901
+ int image_width = memory_map->data ().image_width ();
902
+ int image_height = memory_map->data ().image_height ();
896
903
897
- if (width && height )
904
+ if (image_width && image_height )
898
905
{
899
- std::size_t image_size = width * height * 4 * sizeof (std::uint8_t );
900
- std::size_t debug_size = width * height * 4 * sizeof (std::uint8_t );
906
+ std::size_t image_size = image_width * image_height * 4 * sizeof (std::uint8_t );
907
+ std::size_t debug_size = image_width * image_height * 4 * sizeof (std::uint8_t );
901
908
std::size_t extra_size = (1024 * sizeof (std::int32_t ));
902
- std::int32_t map_size = sizeof (EIOSData) + image_size + debug_size + extra_size;
909
+ std::size_t map_size = sizeof (EIOSData) + image_size + debug_size + extra_size;
903
910
904
911
// Open only..
905
912
memory_map = std::make_unique<MemoryMapStream<ImageData>>(mapName, map_size, MemoryMapStream<ImageData>::open_mode::read | MemoryMapStream<ImageData>::open_mode::write );
@@ -909,21 +916,22 @@ bool ControlCenter::init_maps() noexcept
909
916
return false ;
910
917
}
911
918
912
- int width = 0 ;
913
- int height = 0 ;
914
- GetDesktopResolution (width, height); // TODO: Change to Target Window size..
919
+ int image_width = 0 ;
920
+ int image_height = 0 ;
921
+ GetDesktopResolution (image_width, image_height);
915
922
916
- std::size_t image_size = width * height * 4 * sizeof (std::uint8_t );
917
- std::size_t debug_size = width * height * 4 * sizeof (std::uint8_t );
923
+ std::size_t image_size = image_width * image_height * 4 * sizeof (std::uint8_t );
924
+ std::size_t debug_size = image_width * image_height * 4 * sizeof (std::uint8_t );
918
925
std::size_t extra_size = (1024 * sizeof (std::int32_t ));
919
- std::int32_t map_size = sizeof (EIOSData) + image_size + debug_size + extra_size;
926
+ std::size_t map_size = sizeof (EIOSData) + image_size + debug_size + extra_size;
920
927
921
928
// Create only..
922
929
memory_map = std::make_unique<MemoryMapStream<ImageData>>(mapName, map_size, MemoryMapStream<ImageData>::open_mode::read | MemoryMapStream<ImageData>::open_mode::write | MemoryMapStream<ImageData>::open_mode::create);
923
930
bool result = memory_map && memory_map->is_mapped ();
924
931
if (result)
925
932
{
926
- update_dimensions (width, height);
933
+ set_image_dimensions (image_width, image_height);
934
+ set_target_dimensions (image_width, image_height);
927
935
}
928
936
return result;
929
937
}
@@ -1030,14 +1038,24 @@ std::int32_t ControlCenter::parent_thread_id() const noexcept
1030
1038
return memory_map && memory_map->is_mapped () ? get_image_data ()->parent_thread_id () : -1 ;
1031
1039
}
1032
1040
1033
- std::int32_t ControlCenter::get_width () const noexcept
1041
+ std::int32_t ControlCenter::get_image_width () const noexcept
1034
1042
{
1035
- return memory_map && memory_map->is_mapped () ? get_image_data ()->width () : -1 ;
1043
+ return memory_map && memory_map->is_mapped () ? get_image_data ()->image_width () : -1 ;
1036
1044
}
1037
1045
1038
- std::int32_t ControlCenter::get_height () const noexcept
1046
+ std::int32_t ControlCenter::get_image_height () const noexcept
1039
1047
{
1040
- return memory_map && memory_map->is_mapped () ? get_image_data ()->height () : -1 ;
1048
+ return memory_map && memory_map->is_mapped () ? get_image_data ()->image_height () : -1 ;
1049
+ }
1050
+
1051
+ std::int32_t ControlCenter::get_target_width () const noexcept
1052
+ {
1053
+ return memory_map && memory_map->is_mapped () ? get_image_data ()->target_width () : -1 ;
1054
+ }
1055
+
1056
+ std::int32_t ControlCenter::get_target_height () const noexcept
1057
+ {
1058
+ return memory_map && memory_map->is_mapped () ? get_image_data ()->target_height () : -1 ;
1041
1059
}
1042
1060
1043
1061
std::uint8_t * ControlCenter::get_image () const noexcept
@@ -1048,8 +1066,8 @@ std::uint8_t* ControlCenter::get_image() const noexcept
1048
1066
1049
1067
std::uint8_t * ControlCenter::get_debug_image () const noexcept
1050
1068
{
1051
- std:: uint8_t * image = get_image ();
1052
- return image ? image + ( get_width () * get_height () * 4 ) : nullptr ;
1069
+ ImageData* image_data = get_image_data ();
1070
+ return image_data ? image_data-> debug_image_buffer ( ) : nullptr ;
1053
1071
}
1054
1072
1055
1073
bool ControlCenter::get_debug_graphics () const noexcept
@@ -1204,7 +1222,17 @@ void ControlCenter::kill_process(std::int32_t pid) const noexcept
1204
1222
});
1205
1223
}
1206
1224
1207
- void ControlCenter::update_dimensions (std::int32_t width, std::int32_t height) const noexcept
1225
+ void ControlCenter::set_image_dimensions (std::int32_t width, std::int32_t height) const noexcept
1226
+ {
1227
+ if (memory_map && memory_map->is_mapped ())
1228
+ {
1229
+ ImageData* image_data = get_image_data ();
1230
+ image_data->set_image_width (width);
1231
+ image_data->set_image_height (height);
1232
+ }
1233
+ }
1234
+
1235
+ void ControlCenter::set_target_dimensions (std::int32_t width, std::int32_t height) const noexcept
1208
1236
{
1209
1237
if (memory_map && memory_map->is_mapped ())
1210
1238
{
@@ -1220,29 +1248,43 @@ void ControlCenter::update_dimensions(std::int32_t width, std::int32_t height) c
1220
1248
1221
1249
if (w > 0 && h > 0 )
1222
1250
{
1223
- image_data->set_width (w);
1224
- image_data->set_height (h);
1251
+ image_data->set_target_width (w);
1252
+ image_data->set_target_height (h);
1225
1253
}
1226
1254
else
1227
1255
{
1228
- image_data->set_width (width);
1229
- image_data->set_height (height);
1256
+ image_data->set_target_width (width);
1257
+ image_data->set_target_height (height);
1230
1258
}
1231
1259
}
1232
1260
else
1233
1261
{
1234
- image_data->set_width (width);
1235
- image_data->set_height (height);
1262
+ image_data->set_target_width (width);
1263
+ image_data->set_target_height (height);
1236
1264
}
1237
1265
}
1238
1266
}
1239
1267
1268
+ void ControlCenter::get_image_dimensions (std::int32_t * width, std::int32_t * height) const noexcept
1269
+ {
1270
+ if (memory_map && memory_map->is_mapped ())
1271
+ {
1272
+ *width = get_image_width ();
1273
+ *height = get_image_height ();
1274
+ }
1275
+ else
1276
+ {
1277
+ *width = -1 ;
1278
+ *height = -1 ;
1279
+ }
1280
+ }
1281
+
1240
1282
void ControlCenter::get_target_dimensions (std::int32_t * width, std::int32_t * height) const noexcept
1241
1283
{
1242
1284
if (memory_map && memory_map->is_mapped ())
1243
1285
{
1244
- *width = get_width ();
1245
- *height = get_height ();
1286
+ *width = get_target_width ();
1287
+ *height = get_target_height ();
1246
1288
}
1247
1289
else
1248
1290
{
0 commit comments