diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-07-20 13:33:20 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-08-02 15:56:15 +0300 |
commit | 80314489f5e5011132acc0275e0b49a83705a944 (patch) | |
tree | 0fc336a2ac038eeebac6f2225263e3581fe42152 | |
parent | d3c387d605470838e8f8349fa37c4b123e3e0471 (diff) |
Benchmark: add space type for drawing benchmark in.
Once we have custom space types, this could be removed. For now all code
is in a branch so some hacks don't matter too much.
-rw-r--r-- | build_files/cmake/macros.cmake | 1 | ||||
-rw-r--r-- | release/datafiles/userdef/userdef_default_theme.c | 25 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/__init__.py | 1 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/space_benchmark.py | 28 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 3 | ||||
-rw-r--r-- | source/blender/editors/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/editors/include/ED_space_api.h | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/resources.c | 13 | ||||
-rw-r--r-- | source/blender/editors/space_api/spacetypes.c | 1 | ||||
-rw-r--r-- | source/blender/editors/space_benchmark/CMakeLists.txt | 48 | ||||
-rw-r--r-- | source/blender/editors/space_benchmark/space_benchmark.c | 125 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_space_types.h | 18 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_userdef_types.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/RNA_access.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 12 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_userdef.c | 21 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna_callback.c | 1 |
17 files changed, 300 insertions, 1 deletions
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 65f962d2dd9..5f2abb76e0e 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -574,6 +574,7 @@ function(SETUP_BLENDER_SORTED_LIBS) bf_editor_space_api bf_editor_space_action + bf_editor_space_benchmark bf_editor_space_buttons bf_editor_space_console bf_editor_space_file diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index 69ad58ea1c5..882b6d4f91c 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -939,6 +939,31 @@ const bTheme U_theme_default = { .facedot_size = 4, .gp_vertex_size = 3, }, + .tbenchmark = { + .back = RGBA(0x42424200), + .title = RGBA(0xd4d4d4ff), + .text = RGBA(0xe5e5e5ff), + .text_hi = RGBA(0xffffffff), + .header = RGBA(0x424242ff), + .header_text = RGBA(0xeeeeeeff), + .header_text_hi = RGBA(0xffffffff), + .tab_active = RGBA(0x5680c2ff), + .tab_inactive = RGBA(0x424242ff), + .tab_back = RGBA(0x232323ff), + .tab_outline = RGBA(0x2d2d2dff), + .button = RGBA(0x424242ff), + .button_title = RGBA(0xffffffff), + .button_text = RGBA(0xe5e5e5ff), + .button_text_hi = RGBA(0xffffffff), + .panelcolors = { + .header = RGBA(0x42424200), + .back = RGBA(0x00000028), + .sub_back = RGBA(0x00000024), + }, + .vertex_size = 3, + .outline_width = 1, + .facedot_size = 4, + }, .tarm = { { .solid = RGBA(0x9a0000ff), diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py index 89aed37f055..b21e702a99d 100644 --- a/release/scripts/startup/bl_ui/__init__.py +++ b/release/scripts/startup/bl_ui/__init__.py @@ -72,6 +72,7 @@ _modules = [ "space_toolsystem_common", "space_toolsystem_toolbar", + "space_benchmark", "space_clip", "space_console", "space_dopesheet", diff --git a/release/scripts/startup/bl_ui/space_benchmark.py b/release/scripts/startup/bl_ui/space_benchmark.py new file mode 100644 index 00000000000..b8e47804e80 --- /dev/null +++ b/release/scripts/startup/bl_ui/space_benchmark.py @@ -0,0 +1,28 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +# <pep8 compliant> +import bpy + +classes = ( +) + +if __name__ == "__main__": # only for live edit. + from bpy.utils import register_class + for cls in classes: + register_class(cls) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 3883e024ab7..e32f0732906 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2952,6 +2952,9 @@ static void write_area_regions(WriteData *wd, ScrArea *area) else if (sl->spacetype == SPACE_INFO) { writestruct(wd, DATA, SpaceInfo, 1, sl); } + else if (sl->spacetype == SPACE_BENCHMARK) { + writestruct(wd, DATA, SpaceBenchmark, 1, sl); + } } } diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt index cf1db751c85..d45f0548037 100644 --- a/source/blender/editors/CMakeLists.txt +++ b/source/blender/editors/CMakeLists.txt @@ -42,6 +42,7 @@ if(WITH_BLENDER) add_subdirectory(sound) add_subdirectory(space_action) add_subdirectory(space_api) + add_subdirectory(space_benchmark) add_subdirectory(space_buttons) add_subdirectory(space_clip) add_subdirectory(space_console) diff --git a/source/blender/editors/include/ED_space_api.h b/source/blender/editors/include/ED_space_api.h index ddd8b59c264..f5e6a3e68ae 100644 --- a/source/blender/editors/include/ED_space_api.h +++ b/source/blender/editors/include/ED_space_api.h @@ -59,6 +59,7 @@ void ED_spacetype_userpref(void); void ED_spacetype_clip(void); void ED_spacetype_statusbar(void); void ED_spacetype_topbar(void); +void ED_spacetype_benchmark(void); /* calls for instancing and freeing spacetype static data * called in WM_init_exit */ diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 72023ebf2ae..b8dd9b085d5 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -175,6 +175,9 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo case SPACE_STATUSBAR: ts = &btheme->tstatusbar; break; + case SPACE_BENCHMARK: + ts = &btheme->tbenchmark; + break; default: ts = &btheme->tv3d; break; @@ -1586,6 +1589,16 @@ void init_userdef_do_versions(Main *bmain) } } + if (!USER_VERSION_ATLEAST(280, 16)) { + for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) { + btheme->tstatusbar = btheme->tv3d; + } + } + + for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) { + btheme->tbenchmark = btheme->tima; + } + /** * Include next version bump. */ diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index 7246812dc82..70803993d21 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -99,6 +99,7 @@ void ED_spacetypes_init(void) ED_spacetype_clip(); ED_spacetype_statusbar(); ED_spacetype_topbar(); + ED_spacetype_benchmark(); // ... /* register operator types for screen and all spaces */ diff --git a/source/blender/editors/space_benchmark/CMakeLists.txt b/source/blender/editors/space_benchmark/CMakeLists.txt new file mode 100644 index 00000000000..e820415f5ce --- /dev/null +++ b/source/blender/editors/space_benchmark/CMakeLists.txt @@ -0,0 +1,48 @@ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributor(s): Jacques Beaurain. +# +# ***** END GPL LICENSE BLOCK ***** + +set(INC + ../include + ../../blenfont + ../../blenkernel + ../../blenlib + ../../gpu + ../../makesdna + ../../makesrna + ../../windowmanager + ../../../../intern/guardedalloc + ../../../../intern/glew-mx +) + +set(INC_SYS + ${GLEW_INCLUDE_PATH} +) + +set(SRC + space_benchmark.c +) + +if(WITH_PYTHON) + add_definitions(-DWITH_PYTHON) +endif() + +add_definitions(${GL_DEFINITIONS}) + +blender_add_lib(bf_editor_space_benchmark "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/space_benchmark/space_benchmark.c b/source/blender/editors/space_benchmark/space_benchmark.c new file mode 100644 index 00000000000..62c9dfbb752 --- /dev/null +++ b/source/blender/editors/space_benchmark/space_benchmark.c @@ -0,0 +1,125 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_benchmark/space_benchmark.c + * \ingroup spbenchmark + */ + +#include <string.h> + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" + +#include "BKE_context.h" +#include "BKE_screen.h" + +#include "ED_space_api.h" +#include "ED_screen.h" + +#include "WM_api.h" +#include "WM_types.h" + +/* ******************** default callbacks for benchmark space ***************** */ + +static SpaceLink *benchmark_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene)) +{ + SpaceBenchmark *sbenchmark = MEM_callocN(sizeof(SpaceBenchmark), "initbenchmark"); + sbenchmark->spacetype = SPACE_BENCHMARK; + + // TODO sbenchmark->lheight = 14; + + /* main region */ + ARegion *ar = MEM_callocN(sizeof(ARegion), "main region for text"); + BLI_addtail(&sbenchmark->regionbase, ar); + ar->regiontype = RGN_TYPE_WINDOW; + + return (SpaceLink *)sbenchmark; +} + +/* not spacelink itself */ +static void benchmark_free(SpaceLink *UNUSED(sl)) +{ +} + +/* spacetype; init callback */ +static void benchmark_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) +{ +} + +static SpaceLink *benchmark_duplicate(SpaceLink *sl) +{ + SpaceBenchmark *sbenchmarkn = MEM_dupallocN(sl); + return (SpaceLink *)sbenchmarkn; +} + +/* add handlers, stuff you only do once or on area/region changes */ +static void benchmark_main_region_init(wmWindowManager *wm, ARegion *ar) +{ + ED_region_panels_init(wm, ar); +} + +static void benchmark_main_region_draw(const bContext *C, ARegion *ar) +{ + ED_region_panels(C, ar); +} + +static void benchmark_main_region_listener( + wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *UNUSED(ar), + wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene)) +{ +} + +static void benchmark_keymap(struct wmKeyConfig *UNUSED(keyconf)) +{ + // wmKeyMap *keymap = WM_keymap_find(keyconf, "Benchmark", SPACE_BENCHMARK, 0); +} + +/* only called once, from space/spacetypes.c */ +void ED_spacetype_benchmark(void) +{ + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype benchmark"); + ARegionType *art; + + st->spaceid = SPACE_BENCHMARK; + strncpy(st->name, "Benchmark", BKE_ST_MAXNAME); + + st->new = benchmark_new; + st->free = benchmark_free; + st->init = benchmark_init; + st->duplicate = benchmark_duplicate; + st->keymap = benchmark_keymap; + + /* regions: main window */ + art = MEM_callocN(sizeof(ARegionType), "spacetype benchmark region"); + art->regionid = RGN_TYPE_WINDOW; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; + + art->init = benchmark_main_region_init; + art->draw = benchmark_main_region_draw; + art->listener = benchmark_main_region_listener; + + BLI_addhead(&st->regiontypes, art); + + BKE_spacetype_register(st); +} diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 5404f4160fd..f9119f63025 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -1423,6 +1423,21 @@ typedef struct SpaceStatusBar { /** \} */ /* -------------------------------------------------------------------- */ +/** \name Benchmark + * \{ */ + +typedef struct SpaceBenchmark { + SpaceLink *next, *prev; + ListBase regionbase; /* storage of regions for inactive spaces */ + char spacetype; + char link_flag; + char _pad0[6]; + /* End 'SpaceLink' header. */ +} SpaceBenchmark; + +/** \} */ + +/* -------------------------------------------------------------------- */ /** \name Space Defines (eSpace_Type) * \{ */ @@ -1455,8 +1470,9 @@ typedef enum eSpace_Type { SPACE_CLIP = 20, SPACE_TOPBAR = 21, SPACE_STATUSBAR = 22, + SPACE_BENCHMARK = 23, - SPACE_TYPE_LAST = SPACE_STATUSBAR + SPACE_TYPE_LAST = SPACE_BENCHMARK } eSpace_Type; /* use for function args */ diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index cb2c69e2fa1..b9c626abb90 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -411,6 +411,7 @@ typedef struct bTheme { ThemeSpace tclip; ThemeSpace ttopbar; ThemeSpace tstatusbar; + ThemeSpace tbenchmark; /* 20 sets of bone colors for this theme */ ThemeWireColor tarm[20]; diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 16194c9b419..8da3afbc25e 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -565,6 +565,7 @@ extern StructRNA RNA_SolidifyModifier; extern StructRNA RNA_Sound; extern StructRNA RNA_SoundSequence; extern StructRNA RNA_Space; +extern StructRNA RNA_SpaceBenchmark; extern StructRNA RNA_SpaceConsole; extern StructRNA RNA_SpaceDopeSheetEditor; extern StructRNA RNA_SpaceFileBrowser; diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index d7563f13dc2..e4ba386aa07 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -96,6 +96,7 @@ const EnumPropertyItem rna_enum_space_type_items[] = { "global per-window settings"}, {SPACE_STATUSBAR, "STATUSBAR", ICON_NONE, "Status Bar", "Global bar at the bottom of the " "screen for general status information"}, + {SPACE_BENCHMARK, "BENCHMARK", ICON_NONE, "Benchmark", ""}, /* Data */ {0, "", ICON_NONE, "Data", ""}, @@ -397,6 +398,8 @@ static StructRNA *rna_Space_refine(struct PointerRNA *ptr) return &RNA_SpaceUserPreferences; case SPACE_CLIP: return &RNA_SpaceClipEditor; + case SPACE_BENCHMARK: + return &RNA_SpaceBenchmark; default: return &RNA_Space; } @@ -5153,6 +5156,14 @@ static void rna_def_space_clip(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL); } +static void rna_def_space_benchmark(BlenderRNA *brna) +{ + StructRNA *srna; + + srna = RNA_def_struct(brna, "SpaceBenchmark", "Space"); + RNA_def_struct_sdna(srna, "SpaceBenchmark"); + RNA_def_struct_ui_text(srna, "Space Benchmark", "Benchmark tool"); +} void RNA_def_space(BlenderRNA *brna) { @@ -5176,6 +5187,7 @@ void RNA_def_space(BlenderRNA *brna) rna_def_node_tree_path(brna); rna_def_space_node(brna); rna_def_space_clip(brna); + rna_def_space_benchmark(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 4c3074bba4f..3f68a3087a5 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -3065,6 +3065,20 @@ static void rna_def_userdef_theme_space_statusbar(BlenderRNA *brna) rna_def_userdef_theme_spaces_main(srna); } +static void rna_def_userdef_theme_space_benchmark(BlenderRNA *brna) +{ + StructRNA *srna; + + /* space_benchmark */ + + srna = RNA_def_struct(brna, "ThemeBenchmark", NULL); + RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); + RNA_def_struct_ui_text(srna, "Theme Benchmark", "Theme settings for the Benchmark"); + + rna_def_userdef_theme_spaces_main(srna); +} + static void rna_def_userdef_themes(BlenderRNA *brna) { StructRNA *srna; @@ -3224,6 +3238,12 @@ static void rna_def_userdef_themes(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "tstatusbar"); RNA_def_property_struct_type(prop, "ThemeStatusBar"); RNA_def_property_ui_text(prop, "Status Bar", ""); + + prop = RNA_def_property(srna, "benchmark", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "tbenchmark"); + RNA_def_property_struct_type(prop, "ThemeBenchmark"); + RNA_def_property_ui_text(prop, "Benchmark", ""); } static void rna_def_userdef_addon(BlenderRNA *brna) @@ -3399,6 +3419,7 @@ static void rna_def_userdef_dothemes(BlenderRNA *brna) rna_def_userdef_theme_space_clip(brna); rna_def_userdef_theme_space_topbar(brna); rna_def_userdef_theme_space_statusbar(brna); + rna_def_userdef_theme_space_benchmark(brna); rna_def_userdef_theme_colorset(brna); rna_def_userdef_themes(brna); } diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.c index 7adb1d40fcc..68128fafaa7 100644 --- a/source/blender/python/intern/bpy_rna_callback.c +++ b/source/blender/python/intern/bpy_rna_callback.c @@ -175,6 +175,7 @@ static eSpace_Type rna_Space_refine_reverse(StructRNA *srna) if (srna == &RNA_SpaceConsole) return SPACE_CONSOLE; if (srna == &RNA_SpaceUserPreferences) return SPACE_USERPREF; if (srna == &RNA_SpaceClipEditor) return SPACE_CLIP; + if (srna == &RNA_SpaceBenchmark) return SPACE_BENCHMARK; return SPACE_EMPTY; } |