diff --git a/src/tests/servers/app/benchmark/DrawingModeToString.cpp b/src/tests/servers/app/benchmark/DrawingModeToString.cpp new file mode 100644 index 0000000000..bde5052b39 --- /dev/null +++ b/src/tests/servers/app/benchmark/DrawingModeToString.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2009 Stephan Aßmus + * All rights reserved. Distributed under the terms of the MIT license. + */ + +#include "DrawingModeToString.h" + +struct DrawingModeString { + const char* string; + drawing_mode mode; +}; + + +static const DrawingModeString kDrawingModes[] = { + { "B_OP_COPY", B_OP_COPY }, + { "B_OP_OVER", B_OP_OVER }, + { "B_OP_ERASE", B_OP_ERASE }, + { "B_OP_INVERT", B_OP_INVERT }, + { "B_OP_ADD", B_OP_ADD }, + { "B_OP_SUBTRACT", B_OP_SUBTRACT }, + { "B_OP_BLEND", B_OP_BLEND }, + { "B_OP_MIN", B_OP_MIN }, + { "B_OP_MAX", B_OP_MAX }, + { "B_OP_SELECT", B_OP_SELECT }, + { "B_OP_ALPHA", B_OP_ALPHA } +}; + + +bool ToDrawingMode(const char* string, drawing_mode& mode) +{ + int entries = sizeof(kDrawingModes) / sizeof(DrawingModeString); + for (int32 i = 0; i < entries; i++) { + if (strcmp(kDrawingModes[i].string, string) == 0) { + mode = kDrawingModes[i].mode; + return true; + } + } + return false; +} + + +bool ToString(drawing_mode mode, const char*& string) +{ + int entries = sizeof(kDrawingModes) / sizeof(DrawingModeString); + for (int32 i = 0; i < entries; i++) { + if (kDrawingModes[i].mode == mode) { + string = kDrawingModes[i].string; + return true; + } + } + return false; +} diff --git a/src/tests/servers/app/benchmark/DrawingModeToString.h b/src/tests/servers/app/benchmark/DrawingModeToString.h new file mode 100644 index 0000000000..967f6ffb98 --- /dev/null +++ b/src/tests/servers/app/benchmark/DrawingModeToString.h @@ -0,0 +1,15 @@ +/* + * Copyright (C) 2009 Stephan Aßmus + * All rights reserved. Distributed under the terms of the MIT license. + */ +#ifndef DRAWING_MODE_TO_STRING_H +#define DRAWING_MODE_TO_STRING_H + +#include + + +bool ToDrawingMode(const char* string, drawing_mode& mode); +bool ToString(drawing_mode mode, const char*& string); + + +#endif // DRAWING_MODE_TO_STRING_H