mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-27 08:41:02 +08:00
Material design colors
This commit is contained in:
parent
896662e67d
commit
40a8ee3d16
@ -251,7 +251,7 @@ namespace profiler {
|
|||||||
typedef BlockType block_type_t;
|
typedef BlockType block_type_t;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
PROFILER_API block_id_t registerDescription(const char* _name, const char* _filename, int _line, block_type_t _block_type, color_t _color = DefaultBlockColor);
|
PROFILER_API block_id_t registerDescription(const char* _name, const char* _filename, int _line, block_type_t _block_type, color_t _color = ::profiler::colors::Default);
|
||||||
PROFILER_API void beginBlock(Block& _block);
|
PROFILER_API void beginBlock(Block& _block);
|
||||||
PROFILER_API void endBlock();
|
PROFILER_API void endBlock();
|
||||||
PROFILER_API void setEnabled(bool isEnable);
|
PROFILER_API void setEnabled(bool isEnable);
|
||||||
|
@ -26,77 +26,24 @@ along with this program.If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
namespace profiler {
|
namespace profiler {
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
typedef uint32_t color_t; // Standard four-byte ARGB color format
|
typedef uint32_t color_t; // Standard four-byte ARGB color format
|
||||||
|
|
||||||
//typedef uint8_t color_t; // One-byte RGB color format: RRR-GGG-BB
|
|
||||||
//typedef uint32_t rgb32_t; // Standard four-byte ARGB color format
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
namespace colors {
|
namespace colors {
|
||||||
|
|
||||||
// ///< Extracts [0 .. 224] Red value from one-byte RGB format. Possible values are: [0x0, 0x20, 0x40, 0x60, 0x80, 0xa0, 0xe0].
|
///< Change alpha for color. Only 8 major bytes (0xff000000) used from alpha.
|
||||||
// inline rgb32_t get_red(color_t color) { return color & 0xe0; }
|
inline color_t modify_alpha32(color_t _color, color_t _alpha) {
|
||||||
//
|
return (_alpha & 0xff000000) | (_color & 0x00ffffff);
|
||||||
// ///< Extracts [0 .. 224] Green value from one-byte RGB format. Possible values are: [0x0, 0x20, 0x40, 0x60, 0x80, 0xa0, 0xe0].
|
}
|
||||||
// inline rgb32_t get_green(color_t color) { return (color & 0x1c) << 3; }
|
|
||||||
//
|
|
||||||
// ///< Extracts [0 .. 192] Blue value from one-byte RGB format. Possible values are: [0x0, 0x40, 0x80, 0xc0]
|
|
||||||
// inline rgb32_t get_blue(color_t color) { return (color & 3) << 6; }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// ///< Extracts [0 .. 255] Red value from four-byte RGB format.
|
|
||||||
// inline rgb32_t rgb_red(rgb32_t color) { return (color & 0x00ff0000) >> 16; }
|
|
||||||
//
|
|
||||||
// ///< Extracts [0 .. 255] Green value from four-byte RGB format.
|
|
||||||
// inline rgb32_t rgb_green(rgb32_t color) { return (color & 0x0000ff00) >> 8; }
|
|
||||||
//
|
|
||||||
// ///< Extracts [0 .. 255] Blue value from four-byte RGB format.
|
|
||||||
// inline rgb32_t rgb_blue(rgb32_t color) { return color & 0x000000ff; }
|
|
||||||
//
|
|
||||||
// ///< Unpacks one-byte RGB value into standard four-byte RGB value.
|
|
||||||
// inline rgb32_t convert_to_rgb(color_t color) { return (get_red(color) << 16) | ((color & 0x1c) << 11) | get_blue(color); }
|
|
||||||
//
|
|
||||||
// ///< Packs standard four-byte RGB value into one-byte RGB value. R & G values packed with 0x20 (32) step, B value is packed with 0x40 (64) step.
|
|
||||||
// inline color_t from_rgb(rgb32_t color) { return (rgb_red(color) & 0xe0) | (((color & 0x0000ff00) >> 11) & 0x1c) | (rgb_blue(color) >> 6); }
|
|
||||||
//
|
|
||||||
// ///< Packs standard four-byte RGB value into one-byte RGB value. R & G values packed with 0x20 (32) step, B value is packed with 0x40 (64) step.
|
|
||||||
// inline color_t from_rgb(color_t red, color_t green, color_t blue) { return (red & 0xe0) | ((green >> 3) & 0x1c) | (blue >> 6); }
|
|
||||||
|
|
||||||
|
///< Change alpha for color.
|
||||||
|
inline color_t modify_alpha8(color_t _color, uint8_t _alpha) {
|
||||||
|
return (static_cast<color_t>(_alpha) << 24) | (_color & 0x00ffffff);
|
||||||
|
}
|
||||||
|
|
||||||
// const color_t Black = 0x00; // 0x00000000
|
///< Create color from ARGB components.
|
||||||
// const color_t Random = Black; // Black // Currently GUI interprets Black color as permission to select random color for block
|
inline color_t color(uint8_t _red, uint8_t _green, uint8_t _blue, uint8_t _alpha = 0xff) {
|
||||||
// const color_t Lightgray = 0x6E; // 0x00606080
|
return (static_cast<color_t>(_alpha) << 24) | (static_cast<color_t>(_red) << 16) | (static_cast<color_t>(_green) << 8) | static_cast<color_t>(_blue);
|
||||||
// const color_t Darkgray = 0x25; // 0x00202040
|
}
|
||||||
// const color_t White = 0xFF; // 0x00E0E0C0
|
|
||||||
// const color_t Red = 0xE0; // 0x00E00000
|
|
||||||
// const color_t Green = 0x1C; // 0x0000E000
|
|
||||||
// const color_t Blue = 0x03; // 0x000000C0
|
|
||||||
// const color_t Magenta = (Red | Blue); // 0x00E000C0
|
|
||||||
// const color_t Cyan = (Green | Blue); // 0x0000E0C0
|
|
||||||
// const color_t Yellow = (Red | Green); // 0x00E0E000
|
|
||||||
// const color_t Darkred = 0x60; // 0x00600000
|
|
||||||
// const color_t Darkgreen = 0x0C; // 0x00006000
|
|
||||||
// const color_t Darkblue = 0x01; // 0x00000040
|
|
||||||
// const color_t Darkmagenta = (Darkred | Darkblue); // 0x00600040
|
|
||||||
// const color_t Darkcyan = (Darkgreen | Darkblue); // 0x00006040
|
|
||||||
// const color_t Darkyellow = (Darkred | Darkgreen); // 0x00606000
|
|
||||||
// const color_t Navy = 0x02; // 0x00000080
|
|
||||||
// const color_t Teal = 0x12; // 0x00008080
|
|
||||||
// const color_t Maroon = 0x80; // 0x00800000
|
|
||||||
// const color_t Purple = 0x82; // 0x00800080
|
|
||||||
// const color_t Olive = 0x90; // 0x00808000
|
|
||||||
// const color_t Grey = 0x92; // 0x00808080
|
|
||||||
// const color_t Silver = 0xDB; // 0x00C0C0C0
|
|
||||||
// const color_t Orange = 0xF4; // 0x00E0A000
|
|
||||||
// const color_t Coral = 0xF6; // 0x00E0A080
|
|
||||||
// const color_t Brick = 0xED; // 0x00E06040
|
|
||||||
// const color_t Clay = 0xD6; // 0x00C0A080
|
|
||||||
// const color_t Skin = 0xFA; // 0x00E0C080
|
|
||||||
// const color_t Palegold = 0xFE; // 0x00E0E080
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Google Material Design colors
|
// Google Material Design colors
|
||||||
@ -420,17 +367,17 @@ namespace profiler {
|
|||||||
const color_t Coral = DeepOrange200;
|
const color_t Coral = DeepOrange200;
|
||||||
const color_t Brown = Brown500;
|
const color_t Brown = Brown500;
|
||||||
const color_t DarkBrown = Brown900;
|
const color_t DarkBrown = Brown900;
|
||||||
const color_t CreamWhite = Brown50;
|
const color_t CreamWhite = Orange50;
|
||||||
|
const color_t Wheat = Amber100;
|
||||||
const color_t Grey = Grey500;
|
const color_t Grey = Grey500;
|
||||||
|
const color_t Dark = Grey900;
|
||||||
const color_t Silver = Grey300;
|
const color_t Silver = Grey300;
|
||||||
const color_t BlueGrey = BlueGrey500;
|
const color_t BlueGrey = BlueGrey500;
|
||||||
|
|
||||||
|
const color_t Default = Wheat;
|
||||||
|
|
||||||
} // END of namespace colors.
|
} // END of namespace colors.
|
||||||
|
|
||||||
const color_t DefaultBlockColor = colors::OrangeA100;
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
} // END of namespace profiler.
|
} // END of namespace profiler.
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
@ -101,24 +101,22 @@ struct do_no_hash {
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
const QRgb DEFAULT_COLOR = profiler::DefaultBlockColor;// 0x00d4b494;
|
inline QRgb toRgb(uint32_t _red, uint32_t _green, uint32_t _blue)
|
||||||
|
|
||||||
inline QRgb toRgb(unsigned int _red, unsigned int _green, unsigned int _blue)
|
|
||||||
{
|
{
|
||||||
return (_red << 16) + (_green << 8) + _blue;
|
return (_red << 16) + (_green << 8) + _blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QRgb fromProfilerRgb(unsigned int _red, unsigned int _green, unsigned int _blue)
|
inline QRgb fromProfilerRgb(uint32_t _red, uint32_t _green, uint32_t _blue)
|
||||||
{
|
{
|
||||||
if (_red == 0 && _green == 0 && _blue == 0)
|
if (_red == 0 && _green == 0 && _blue == 0)
|
||||||
return DEFAULT_COLOR;
|
return ::profiler::colors::Default;
|
||||||
return toRgb(_red, _green, _blue) | 0x00141414;
|
return toRgb(_red, _green, _blue) | 0x00141414;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QRgb textColorForRgb(QRgb _color)
|
inline ::profiler::color_t textColorForRgb(::profiler::color_t _color)
|
||||||
{
|
{
|
||||||
const QRgb sum = 0xff - ((_color & 0xff000000) >> 24) + ((_color & 0x00ff0000) >> 16) + ((_color & 0x0000ff00) >> 8) + (_color & 0x000000ff);
|
const auto sum = 255. - (((_color & 0x00ff0000) >> 16) * 0.299 + ((_color & 0x0000ff00) >> 8) * 0.587 + (_color & 0x000000ff) * 0.114);
|
||||||
return sum > 0x215 ? ::profiler::colors::Black : ::profiler::colors::White;
|
return sum < 76.5 || ((_color & 0xff000000) >> 24) < 0x80 ? ::profiler::colors::Dark : ::profiler::colors::CreamWhite;
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -14,7 +14,7 @@ std::mutex cv_m;
|
|||||||
int g_i = 0;
|
int g_i = 0;
|
||||||
|
|
||||||
int OBJECTS = 500;
|
int OBJECTS = 500;
|
||||||
int RENDER_SPEPS = 1600;
|
int RENDER_STEPS = 1600;
|
||||||
int MODELLING_STEPS = 1000;
|
int MODELLING_STEPS = 1000;
|
||||||
int RESOURCE_LOADING_COUNT = 50;
|
int RESOURCE_LOADING_COUNT = 50;
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ void loadingResources(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void prepareMath(){
|
void prepareMath(){
|
||||||
EASY_FUNCTION(profiler::colors::Blue);
|
EASY_FUNCTION(profiler::colors::Green);
|
||||||
int* intarray = new int[OBJECTS];
|
int* intarray = new int[OBJECTS];
|
||||||
for (int i = 0; i < OBJECTS; ++i)
|
for (int i = 0; i < OBJECTS; ++i)
|
||||||
intarray[i] = i * i;
|
intarray[i] = i * i;
|
||||||
@ -41,7 +41,7 @@ void prepareMath(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void calcIntersect(){
|
void calcIntersect(){
|
||||||
EASY_FUNCTION(profiler::colors::Blue);
|
EASY_FUNCTION(profiler::colors::Gold);
|
||||||
//int* intarray = new int[OBJECTS * OBJECTS];
|
//int* intarray = new int[OBJECTS * OBJECTS];
|
||||||
int* intarray = new int[OBJECTS];
|
int* intarray = new int[OBJECTS];
|
||||||
for (int i = 0; i < OBJECTS; ++i)
|
for (int i = 0; i < OBJECTS; ++i)
|
||||||
@ -61,7 +61,7 @@ double multModel(double i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void calcPhys(){
|
void calcPhys(){
|
||||||
EASY_FUNCTION(profiler::colors::Blue);
|
EASY_FUNCTION(profiler::colors::Amber);
|
||||||
double* intarray = new double[OBJECTS];
|
double* intarray = new double[OBJECTS];
|
||||||
for (int i = 0; i < OBJECTS; ++i)
|
for (int i = 0; i < OBJECTS; ++i)
|
||||||
intarray[i] = multModel(double(i)) + double(i / 3) - double((OBJECTS - i) / 2);
|
intarray[i] = multModel(double(i)) + double(i / 3) - double((OBJECTS - i) / 2);
|
||||||
@ -71,12 +71,12 @@ void calcPhys(){
|
|||||||
|
|
||||||
double calcSubbrain(int i)
|
double calcSubbrain(int i)
|
||||||
{
|
{
|
||||||
EASY_FUNCTION(profiler::colors::Blue);
|
EASY_FUNCTION(profiler::colors::Navy);
|
||||||
return i * i * i - i / 10 + (OBJECTS - i) * 7 ;
|
return i * i * i - i / 10 + (OBJECTS - i) * 7 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void calcBrain(){
|
void calcBrain(){
|
||||||
EASY_FUNCTION(profiler::colors::Blue);
|
EASY_FUNCTION(profiler::colors::LightBlue);
|
||||||
double* intarray = new double[OBJECTS];
|
double* intarray = new double[OBJECTS];
|
||||||
for (int i = 0; i < OBJECTS; ++i)
|
for (int i = 0; i < OBJECTS; ++i)
|
||||||
intarray[i] = calcSubbrain(i) + double(i * 180 / 3);
|
intarray[i] = calcSubbrain(i) + double(i * 180 / 3);
|
||||||
@ -85,19 +85,19 @@ void calcBrain(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void calculateBehavior(){
|
void calculateBehavior(){
|
||||||
EASY_FUNCTION(profiler::colors::DarkBlue);
|
EASY_FUNCTION(profiler::colors::Blue);
|
||||||
calcPhys();
|
calcPhys();
|
||||||
calcBrain();
|
calcBrain();
|
||||||
}
|
}
|
||||||
|
|
||||||
void modellingStep(){
|
void modellingStep(){
|
||||||
EASY_FUNCTION(profiler::colors::Navy);
|
EASY_FUNCTION();
|
||||||
prepareMath();
|
prepareMath();
|
||||||
calculateBehavior();
|
calculateBehavior();
|
||||||
}
|
}
|
||||||
|
|
||||||
void prepareRender(){
|
void prepareRender(){
|
||||||
EASY_FUNCTION(profiler::colors::DarkRed);
|
EASY_FUNCTION(profiler::colors::Brick);
|
||||||
localSleep();
|
localSleep();
|
||||||
//std::this_thread::sleep_for(std::chrono::milliseconds(8));
|
//std::this_thread::sleep_for(std::chrono::milliseconds(8));
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ void prepareRender(){
|
|||||||
|
|
||||||
int multPhys(int i)
|
int multPhys(int i)
|
||||||
{
|
{
|
||||||
EASY_FUNCTION(profiler::colors::Red);
|
EASY_FUNCTION(profiler::colors::Red700);
|
||||||
return i * i * i * i / 100;
|
return i * i * i * i / 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ void modellingThread(){
|
|||||||
//std::unique_lock<std::mutex> lk(cv_m);
|
//std::unique_lock<std::mutex> lk(cv_m);
|
||||||
//cv.wait(lk, []{return g_i == 1; });
|
//cv.wait(lk, []{return g_i == 1; });
|
||||||
EASY_THREAD("Modelling");
|
EASY_THREAD("Modelling");
|
||||||
for (int i = 0; i < RENDER_SPEPS; i++){
|
for (int i = 0; i < RENDER_STEPS; i++){
|
||||||
modellingStep();
|
modellingStep();
|
||||||
localSleep(1200000);
|
localSleep(1200000);
|
||||||
//std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
//std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||||
@ -164,60 +164,7 @@ void renderThread(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void four()
|
//////////////////////////////////////////////////////////////////////////
|
||||||
{
|
|
||||||
EASY_FUNCTION(profiler::colors::Red);
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(37));
|
|
||||||
}
|
|
||||||
|
|
||||||
void five()
|
|
||||||
{
|
|
||||||
EASY_FUNCTION(profiler::colors::Red);
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
|
||||||
}
|
|
||||||
void six()
|
|
||||||
{
|
|
||||||
EASY_FUNCTION(profiler::colors::Red);
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(42));
|
|
||||||
}
|
|
||||||
|
|
||||||
void three()
|
|
||||||
{
|
|
||||||
EASY_FUNCTION(profiler::colors::Red);
|
|
||||||
four();
|
|
||||||
five();
|
|
||||||
six();
|
|
||||||
}
|
|
||||||
|
|
||||||
void seven()
|
|
||||||
{
|
|
||||||
EASY_FUNCTION(profiler::colors::Red);
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(147));
|
|
||||||
}
|
|
||||||
|
|
||||||
void two()
|
|
||||||
{
|
|
||||||
EASY_FUNCTION(profiler::colors::Red);
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(26));
|
|
||||||
}
|
|
||||||
|
|
||||||
void one()
|
|
||||||
{
|
|
||||||
EASY_FUNCTION(profiler::colors::Red);
|
|
||||||
two();
|
|
||||||
three();
|
|
||||||
seven();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
one
|
|
||||||
two
|
|
||||||
three
|
|
||||||
four
|
|
||||||
five
|
|
||||||
six
|
|
||||||
seven
|
|
||||||
*/
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
@ -225,7 +172,7 @@ int main(int argc, char* argv[])
|
|||||||
OBJECTS = std::atoi(argv[1]);
|
OBJECTS = std::atoi(argv[1]);
|
||||||
}
|
}
|
||||||
if (argc > 2 && argv[2]){
|
if (argc > 2 && argv[2]){
|
||||||
RENDER_SPEPS = std::atoi(argv[2]);
|
RENDER_STEPS = std::atoi(argv[2]);
|
||||||
}
|
}
|
||||||
if (argc > 3 && argv[3]){
|
if (argc > 3 && argv[3]){
|
||||||
MODELLING_STEPS = std::atoi(argv[3]);
|
MODELLING_STEPS = std::atoi(argv[3]);
|
||||||
@ -235,16 +182,14 @@ int main(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Objects count: " << OBJECTS << std::endl;
|
std::cout << "Objects count: " << OBJECTS << std::endl;
|
||||||
std::cout << "Render steps: " << RENDER_SPEPS << std::endl;
|
std::cout << "Render steps: " << RENDER_STEPS << std::endl;
|
||||||
std::cout << "Modelling steps: " << MODELLING_STEPS << std::endl;
|
std::cout << "Modelling steps: " << MODELLING_STEPS << std::endl;
|
||||||
std::cout << "Resource loading count: " << RESOURCE_LOADING_COUNT << std::endl;
|
std::cout << "Resource loading count: " << RESOURCE_LOADING_COUNT << std::endl;
|
||||||
|
|
||||||
auto start = std::chrono::system_clock::now();
|
auto start = std::chrono::system_clock::now();
|
||||||
EASY_PROFILER_ENABLE;
|
EASY_PROFILER_ENABLE;
|
||||||
EASY_MAIN_THREAD;
|
EASY_MAIN_THREAD;
|
||||||
//one();
|
|
||||||
//one();
|
|
||||||
/**/
|
|
||||||
std::vector<std::thread> threads;
|
std::vector<std::thread> threads;
|
||||||
|
|
||||||
std::thread render = std::thread(renderThread);
|
std::thread render = std::thread(renderThread);
|
||||||
@ -262,7 +207,7 @@ int main(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
cv.notify_all();
|
cv.notify_all();
|
||||||
|
|
||||||
for (int i = 0; i < RENDER_SPEPS; ++i) {
|
for (int i = 0; i < RENDER_STEPS; ++i) {
|
||||||
modellingStep();
|
modellingStep();
|
||||||
localSleep(1200000);
|
localSleep(1200000);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user