From 457f9cf8405e98adae318cedd01e0c148b4eab64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Mon, 6 Apr 2009 08:06:05 +0000 Subject: [PATCH] If you had added Benchmark as a target, your build would have been broken, because I forgot to add these files in my last commit... sorry. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29959 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../app/benchmark/DrawingModeToString.cpp | 52 +++++++++++++++++++ .../app/benchmark/DrawingModeToString.h | 15 ++++++ 2 files changed, 67 insertions(+) create mode 100644 src/tests/servers/app/benchmark/DrawingModeToString.cpp create mode 100644 src/tests/servers/app/benchmark/DrawingModeToString.h 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