Compare commits
22 Commits
temp-multi
...
benchmark
Author | SHA1 | Date | |
---|---|---|---|
595251f74f | |||
5280017554 | |||
f1d77737f5 | |||
c522a5a9f9 | |||
22d8135be9 | |||
6d1e650929 | |||
aad16afb56 | |||
dfa2cf6f3d | |||
0cbd605a3d | |||
f9575ce9ea | |||
689ef9543a | |||
226fd36ce2 | |||
b3216ecd68 | |||
84b072d800 | |||
2de0481e1d | |||
c1b18253b3 | |||
86bee87eda | |||
619e362779 | |||
a88a4fecae | |||
1a663e8caf | |||
dbb5a561c8 | |||
80314489f5 |
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -18,3 +18,6 @@
|
||||
url = ../blender-dev-tools.git
|
||||
branch = master
|
||||
ignore = all
|
||||
[submodule "release/scripts/benchmark"]
|
||||
path = release/scripts/benchmark
|
||||
url = ../blender-benchmark-bundle.git
|
||||
|
@@ -71,6 +71,10 @@ ifneq "$(findstring full, $(MAKECMDGOALS))" ""
|
||||
BUILD_DIR:=$(BUILD_DIR)_full
|
||||
BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_full.cmake"
|
||||
endif
|
||||
ifneq "$(findstring benchmark, $(MAKECMDGOALS))" ""
|
||||
BUILD_DIR:=$(BUILD_DIR)_benchmark
|
||||
BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_benchmark.cmake"
|
||||
endif
|
||||
ifneq "$(findstring lite, $(MAKECMDGOALS))" ""
|
||||
BUILD_DIR:=$(BUILD_DIR)_lite
|
||||
BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_lite.cmake"
|
||||
@@ -146,6 +150,7 @@ all: .FORCE
|
||||
debug: all
|
||||
full: all
|
||||
lite: all
|
||||
benchmark: all
|
||||
cycles: all
|
||||
headless: all
|
||||
bpy: all
|
||||
|
7
build_files/cmake/config/blender_benchmark.cmake
Normal file
7
build_files/cmake/config/blender_benchmark.cmake
Normal file
@@ -0,0 +1,7 @@
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/blender_lite.cmake")
|
||||
|
||||
set(WITH_PYTHON_INSTALL_NUMPY OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_SYSTEM_GLEW OFF CACHE BOOL "" FORCE)
|
||||
# Brecht says: KEEP THIS ENABLED. *SOMETHING* breaks otherwise.
|
||||
# Something == DPI. Go figure.
|
||||
set(WITH_GHOST_XDND ON CACHE BOOL "" FORCE)
|
@@ -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
|
||||
|
4
extern/CMakeLists.txt
vendored
4
extern/CMakeLists.txt
vendored
@@ -75,9 +75,9 @@ if(WITH_LZMA)
|
||||
add_subdirectory(lzma)
|
||||
endif()
|
||||
|
||||
if(WITH_CYCLES OR WITH_COMPOSITOR OR WITH_OPENSUBDIV)
|
||||
if(WITH_CYCLES OR WITH_COMPOSITOR OR WITH_OPENSUBDIV OR TRUE)
|
||||
add_subdirectory(clew)
|
||||
if(WITH_CUDA_DYNLOAD)
|
||||
if(WITH_CUDA_DYNLOAD AND FALSE)
|
||||
add_subdirectory(cuew)
|
||||
endif()
|
||||
endif()
|
||||
|
9
extern/clew/CMakeLists.txt
vendored
9
extern/clew/CMakeLists.txt
vendored
@@ -40,3 +40,12 @@ set(SRC
|
||||
add_definitions(-DCL_USE_DEPRECATED_OPENCL_1_1_APIS)
|
||||
|
||||
blender_add_lib(extern_clew "${SRC}" "${INC}" "${INC_SYS}")
|
||||
|
||||
add_executable(cl_query src/cl_query.cc)
|
||||
target_link_libraries(cl_query extern_clew ${CMAKE_DL_LIBS})
|
||||
|
||||
if(APPLE)
|
||||
install(TARGETS cl_query DESTINATION "blender-benchmark.app/Contents/Resources/bin")
|
||||
else()
|
||||
install(TARGETS cl_query DESTINATION "bin")
|
||||
endif()
|
||||
|
119
extern/clew/src/cl_query.cc
vendored
Normal file
119
extern/clew/src/cl_query.cc
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright 2011-2015 Blender Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "clew.h"
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
#define foreach(x, y) for(x : y)
|
||||
|
||||
namespace {
|
||||
|
||||
// Get all platform IDs.
|
||||
bool getPlatformIDs(vector<cl_platform_id>* platform_ids) {
|
||||
cl_uint num_platforms = 0;
|
||||
if (clGetPlatformIDs(0, NULL, &num_platforms) != CL_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
platform_ids->resize(num_platforms);
|
||||
if (clGetPlatformIDs(
|
||||
num_platforms, &(*platform_ids)[0], NULL) != CL_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get device IDs for the given platform.
|
||||
bool getPlatformDeviceIDs(cl_platform_id platform_id,
|
||||
vector<cl_device_id>* device_ids) {
|
||||
cl_uint num_devices = 0;
|
||||
if (clGetDeviceIDs(
|
||||
platform_id, CL_DEVICE_TYPE_GPU, 0, NULL, &num_devices) != CL_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
device_ids->resize(num_devices);
|
||||
if (num_devices == 0) {
|
||||
return true;
|
||||
}
|
||||
if (clGetDeviceIDs(platform_id,
|
||||
CL_DEVICE_TYPE_ALL,
|
||||
num_devices,
|
||||
&(*device_ids)[0],
|
||||
NULL) != CL_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int result = clewInit();
|
||||
if (result != CLEW_SUCCESS) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// Get all platform IDs.
|
||||
vector<cl_platform_id> platform_ids;
|
||||
if (!getPlatformIDs(&platform_ids)) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
foreach (cl_platform_id platform_id, platform_ids) {
|
||||
vector<cl_device_id> device_ids;
|
||||
if (!getPlatformDeviceIDs(platform_id, &device_ids)) {
|
||||
continue;
|
||||
}
|
||||
foreach (cl_device_id device_id, device_ids) {
|
||||
string name;
|
||||
char board_name[1024] = "\0";
|
||||
size_t board_length = 0;
|
||||
if (clGetDeviceInfo(device_id,
|
||||
CL_DEVICE_BOARD_NAME_AMD,
|
||||
sizeof(board_name), board_name,
|
||||
&board_length) == CL_SUCCESS) {
|
||||
if (board_length != 0 && board_name[0] != '\0') {
|
||||
name = board_name;
|
||||
}
|
||||
}
|
||||
if (name.empty()) {
|
||||
char device_name[1024] = "\0";
|
||||
if (clGetDeviceInfo(device_id,
|
||||
CL_DEVICE_NAME,
|
||||
sizeof(device_name), device_name,
|
||||
NULL) == CL_SUCCESS) {
|
||||
name = device_name;
|
||||
}
|
||||
}
|
||||
if (name.empty()) {
|
||||
continue;
|
||||
}
|
||||
cl_int max_compute_units = 0;
|
||||
if (clGetDeviceInfo(device_id,
|
||||
CL_DEVICE_MAX_COMPUTE_UNITS,
|
||||
sizeof(max_compute_units),
|
||||
&max_compute_units,
|
||||
NULL) != CL_SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
printf("%s:%d\n", name.c_str(), max_compute_units);
|
||||
}
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@@ -533,8 +533,9 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
|
||||
rect.size.width = width;
|
||||
rect.size.height = height;
|
||||
|
||||
/* Benchmark: no window resize. */
|
||||
m_window = [[CocoaWindow alloc] initWithContentRect:rect
|
||||
styleMask:NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask | NSMiniaturizableWindowMask
|
||||
styleMask:NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask
|
||||
backing:NSBackingStoreBuffered defer:NO];
|
||||
|
||||
if (m_window == nil) {
|
||||
|
@@ -149,7 +149,8 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system,
|
||||
else if (top < monitor.rcWork.top)
|
||||
top = monitor.rcWork.top;
|
||||
|
||||
int wintype = WS_OVERLAPPEDWINDOW;
|
||||
/* Benchmark: no window resize. */
|
||||
int wintype = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
|
||||
if (m_parentWindowHwnd != 0) {
|
||||
wintype = WS_CHILD;
|
||||
GetWindowRect((HWND)m_parentWindowHwnd, &rect);
|
||||
@@ -547,13 +548,14 @@ GHOST_TSuccess GHOST_WindowWin32::setState(GHOST_TWindowState state)
|
||||
if (state == GHOST_kWindowStateNormal)
|
||||
state = m_normal_state;
|
||||
|
||||
int wintype = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
|
||||
switch (state) {
|
||||
case GHOST_kWindowStateMinimized:
|
||||
wp.showCmd = SW_SHOWMINIMIZED;
|
||||
break;
|
||||
case GHOST_kWindowStateMaximized:
|
||||
wp.showCmd = SW_SHOWMAXIMIZED;
|
||||
::SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW);
|
||||
::SetWindowLongPtr(m_hWnd, GWL_STYLE, wintype);
|
||||
break;
|
||||
case GHOST_kWindowStateFullScreen:
|
||||
if (curstate != state && curstate != GHOST_kWindowStateMinimized)
|
||||
@@ -569,7 +571,7 @@ GHOST_TSuccess GHOST_WindowWin32::setState(GHOST_TWindowState state)
|
||||
case GHOST_kWindowStateNormal:
|
||||
default:
|
||||
wp.showCmd = SW_SHOWNORMAL;
|
||||
::SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW);
|
||||
::SetWindowLongPtr(m_hWnd, GWL_STYLE, wintype);
|
||||
break;
|
||||
}
|
||||
/* Clears window cache for SetWindowLongPtr */
|
||||
|
@@ -484,10 +484,11 @@ GHOST_WindowX11(GHOST_SystemX11 *system,
|
||||
xsizehints->y = top;
|
||||
xsizehints->width = width;
|
||||
xsizehints->height = height;
|
||||
xsizehints->min_width = 320; /* size hints, could be made apart of the ghost api */
|
||||
xsizehints->min_height = 240; /* limits are also arbitrary, but should not allow 1x1 window */
|
||||
xsizehints->max_width = 65535;
|
||||
xsizehints->max_height = 65535;
|
||||
/* Benchmark: fixed window size. */
|
||||
xsizehints->min_width = width; /* size hints, could be made apart of the ghost api */
|
||||
xsizehints->min_height = height; /* limits are also arbitrary, but should not allow 1x1 window */
|
||||
xsizehints->max_width = width;
|
||||
xsizehints->max_height = height;
|
||||
XSetWMNormalHints(m_display, m_window, xsizehints);
|
||||
XFree(xsizehints);
|
||||
}
|
||||
|
@@ -26,17 +26,17 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>blender</string>
|
||||
<string>blender-benchmark</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>${MACOSX_BUNDLE_LONG_VERSION_STRING}, Blender Foundation</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>blender icon.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.blenderfoundation.blender</string>
|
||||
<string>org.blenderfoundation.blender-benchmark</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>Blender</string>
|
||||
<string>Blender Benchmark</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
|
@@ -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),
|
||||
|
Submodule release/scripts/addons updated: 371960484a...1a5f14657e
Submodule release/scripts/addons_contrib updated: 4747021578...15b25a4278
1
release/scripts/benchmark
Submodule
1
release/scripts/benchmark
Submodule
Submodule release/scripts/benchmark added at 57a080c9db
@@ -345,6 +345,8 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non
|
||||
# disable the context, using the context at all is
|
||||
# really bad while loading an addon, don't do it!
|
||||
with RestrictBlend():
|
||||
# Benchmark: disable addons
|
||||
return None
|
||||
|
||||
# 1) try import
|
||||
try:
|
||||
|
@@ -72,6 +72,7 @@ _modules = [
|
||||
"space_toolsystem_common",
|
||||
"space_toolsystem_toolbar",
|
||||
|
||||
"space_benchmark",
|
||||
"space_clip",
|
||||
"space_console",
|
||||
"space_dopesheet",
|
||||
|
28
release/scripts/startup/bl_ui/space_benchmark.py
Normal file
28
release/scripts/startup/bl_ui/space_benchmark.py
Normal file
@@ -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>
|
||||
|
||||
# Defer to release/scripts/benchmark to populate this space
|
||||
import bpy
|
||||
import sys
|
||||
for path in bpy.utils.script_paths('benchmark'):
|
||||
sys.path.insert(0, path)
|
||||
|
||||
import benchmark.space
|
||||
classes = benchmark.space.classes
|
@@ -156,6 +156,10 @@ class FILEBROWSER_PT_system_bookmarks(Panel):
|
||||
class FILEBROWSER_MT_bookmarks_specials(Menu):
|
||||
bl_label = "Bookmarks Specials"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return False
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.operator("file.bookmark_cleanup", icon='X', text="Cleanup")
|
||||
@@ -171,6 +175,10 @@ class FILEBROWSER_PT_bookmarks(Panel):
|
||||
bl_category = "Bookmarks"
|
||||
bl_label = "Bookmarks"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return False
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
space = context.space_data
|
||||
@@ -203,7 +211,8 @@ class FILEBROWSER_PT_recent_folders(Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return not context.user_preferences.filepaths.hide_recent_locations
|
||||
# return not context.user_preferences.filepaths.hide_recent_locations
|
||||
return False
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
@@ -75,9 +75,9 @@ BLI_INLINE void BLI_hash_pointer_to_color(const void *ptr, int *r, int *g, int *
|
||||
const size_t hash_b = BLI_hash_int((uint)((val & 0xffff0000) >> 32));
|
||||
const size_t hash =
|
||||
hash_a ^ (hash_b + 0x9e3779b9 + (hash_a << 6) + (hash_a >> 2));
|
||||
*r = (hash & 0xff0000) >> 16;
|
||||
*g = (hash & 0x00ff00) >> 8;
|
||||
*b = hash & 0x0000ff;
|
||||
*r = (int)((hash & 0xff0000) >> 16);
|
||||
*g = (int)((hash & 0x00ff00) >> 8);
|
||||
*b = (int)(hash & 0x0000ff);
|
||||
}
|
||||
|
||||
#endif // __BLI_HASH_H__
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -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 */
|
||||
|
@@ -103,6 +103,7 @@ enum {
|
||||
UI_EMBOSS_NONE = 1, /* Nothing, only icon and/or text */
|
||||
UI_EMBOSS_PULLDOWN = 2, /* Pulldown menu style */
|
||||
UI_EMBOSS_RADIAL = 3, /* Pie Menu */
|
||||
UI_EMBOSS_LINK = 4, /* Benchmark: special link drawing */
|
||||
|
||||
UI_EMBOSS_UNDEFINED = 255, /* For layout engine, use emboss from block. */
|
||||
};
|
||||
|
@@ -1316,7 +1316,7 @@ static void widget_draw_icon_ex(
|
||||
/* special case - icon_only pie buttons */
|
||||
if (ui_block_is_pie_menu(but->block) && !ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_POPOVER) && but->str && but->str[0] == '\0')
|
||||
xs = rect->xmin + 2.0f * ofs;
|
||||
else if (but->dt == UI_EMBOSS_NONE || but->type == UI_BTYPE_LABEL)
|
||||
else if (ELEM(but->dt, UI_EMBOSS_NONE, UI_EMBOSS_LINK) || but->type == UI_BTYPE_LABEL)
|
||||
xs = rect->xmin + 2.0f * ofs;
|
||||
else
|
||||
xs = rect->xmin + 4.0f * ofs;
|
||||
@@ -1954,6 +1954,17 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
|
||||
UI_fontstyle_draw_ex(fstyle, rect, drawstr + but->ofs, (unsigned char *)wcol->text,
|
||||
drawlen, &font_xofs, &font_yofs);
|
||||
|
||||
if (but->dt == UI_EMBOSS_LINK && (but->flag & UI_ACTIVE)) {
|
||||
float underline_col[4];
|
||||
int underline_width = UI_fontstyle_string_width(fstyle, drawstr + but->ofs);
|
||||
int rect_x = BLI_rcti_size_x(rect);
|
||||
|
||||
rgba_uchar_to_float(underline_col, (unsigned char *)wcol->text);
|
||||
GPU_blend(true);
|
||||
UI_draw_text_underline(rect->xmin + font_xofs, rect->ymin + 8 * U.pixelsize, min_ii(underline_width, rect_x - 2), 1, underline_col);
|
||||
GPU_blend(false);
|
||||
}
|
||||
|
||||
if (but->menu_key != '\0') {
|
||||
char fixedbuf[128];
|
||||
const char *str;
|
||||
@@ -4063,7 +4074,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (but->dt == UI_EMBOSS_NONE) {
|
||||
else if (ELEM(but->dt, UI_EMBOSS_NONE, UI_EMBOSS_LINK)) {
|
||||
/* "nothing" */
|
||||
switch (but->type) {
|
||||
case UI_BTYPE_LABEL:
|
||||
|
@@ -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.
|
||||
*/
|
||||
|
@@ -493,8 +493,6 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
|
||||
/* XXX test: add convention to end regions always in pixel space, for drawing of borders/gestures etc */
|
||||
ED_region_pixelspace(ar);
|
||||
|
||||
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_PIXEL);
|
||||
|
||||
region_draw_azones(sa, ar);
|
||||
|
||||
/* for debugging unneeded area redraws and partial redraw */
|
||||
@@ -2214,6 +2212,10 @@ void ED_region_panels_draw(const bContext *C, ARegion *ar)
|
||||
/* reset line width for drawing tabs */
|
||||
GPU_line_width(1.0f);
|
||||
|
||||
/* Benchmark; draw under panels. */
|
||||
ED_region_pixelspace(ar);
|
||||
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_PIXEL);
|
||||
|
||||
/* set the view */
|
||||
UI_view2d_view_ortho(v2d);
|
||||
|
||||
|
@@ -433,6 +433,9 @@ static void drawscredge_area(ScrArea *sa, int sizex, int sizey, unsigned int pos
|
||||
*/
|
||||
void ED_screen_draw_edges(wmWindow *win)
|
||||
{
|
||||
/* Benchmark: no edges between editors. */
|
||||
return;
|
||||
|
||||
bScreen *screen = WM_window_get_active_screen(win);
|
||||
const int winsize_x = WM_window_pixels_x(win);
|
||||
const int winsize_y = WM_window_pixels_y(win);
|
||||
|
@@ -792,6 +792,9 @@ static void screen_global_statusbar_area_create(wmWindow *win)
|
||||
|
||||
void ED_screen_global_areas_create(wmWindow *win)
|
||||
{
|
||||
/* Benchmark: no global areas. */
|
||||
return;
|
||||
|
||||
/* Don't create global areas for child windows. */
|
||||
if (win->parent) {
|
||||
return;
|
||||
|
@@ -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 */
|
||||
|
48
source/blender/editors/space_benchmark/CMakeLists.txt
Normal file
48
source/blender/editors/space_benchmark/CMakeLists.txt
Normal file
@@ -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}")
|
125
source/blender/editors/space_benchmark/space_benchmark.c
Normal file
125
source/blender/editors/space_benchmark/space_benchmark.c
Normal file
@@ -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);
|
||||
}
|
@@ -90,10 +90,12 @@ static SpaceLink *file_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scen
|
||||
ar->alignment = RGN_ALIGN_LEFT;
|
||||
|
||||
/* Tool props (aka operator) region */
|
||||
#if 0
|
||||
ar = MEM_callocN(sizeof(ARegion), "tool props region for file");
|
||||
BLI_addtail(&sfile->regionbase, ar);
|
||||
ar->regiontype = RGN_TYPE_TOOL_PROPS;
|
||||
ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
|
||||
#endif
|
||||
|
||||
/* ui list region */
|
||||
ar = MEM_callocN(sizeof(ARegion), "ui region for file");
|
||||
@@ -806,6 +808,7 @@ void ED_spacetype_file(void)
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
/* regions: tool properties */
|
||||
#if 0
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype file operator region");
|
||||
art->regionid = RGN_TYPE_TOOL_PROPS;
|
||||
art->prefsizex = 0;
|
||||
@@ -816,6 +819,7 @@ void ED_spacetype_file(void)
|
||||
art->draw = file_tools_region_draw;
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
file_panels_register(art);
|
||||
#endif
|
||||
|
||||
BKE_spacetype_register(st);
|
||||
|
||||
|
@@ -1422,6 +1422,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 */
|
||||
|
@@ -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];
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
@@ -997,6 +997,7 @@ static void rna_def_ui_layout(BlenderRNA *brna)
|
||||
{UI_EMBOSS_NONE, "NONE", 0, "None", "Draw only text and icons"},
|
||||
{UI_EMBOSS_PULLDOWN, "PULLDOWN_MENU", 0, "Pulldown Menu", "Draw pulldown menu style"},
|
||||
{UI_EMBOSS_RADIAL, "RADIAL_MENU", 0, "Radial Menu", "Draw radial menu style"},
|
||||
{UI_EMBOSS_LINK, "LINK", 0, "Link", "Draw button as link"},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -43,6 +43,7 @@ set(INC
|
||||
|
||||
set(INC_SYS
|
||||
${PYTHON_INCLUDE_DIRS}
|
||||
${GLEW_INCLUDE_PATH}
|
||||
)
|
||||
|
||||
set(SRC
|
||||
@@ -83,6 +84,7 @@ set(SRC
|
||||
bpy_utils_previews.c
|
||||
bpy_utils_units.c
|
||||
gpu.c
|
||||
gpu_draw.c
|
||||
gpu_offscreen.c
|
||||
gpu_py_matrix.c
|
||||
gpu_py_select.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;
|
||||
}
|
||||
|
||||
|
@@ -89,6 +89,11 @@ PyObject *GPU_initPython(void)
|
||||
|
||||
module = PyInit_gpu();
|
||||
|
||||
/* gpu.draw */
|
||||
PyModule_AddObject(module, "draw", (submodule = BPyInit_gpu_draw()));
|
||||
PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule);
|
||||
Py_INCREF(submodule);
|
||||
|
||||
/* gpu.offscreen */
|
||||
PyModule_AddObject(module, "offscreen", (submodule = BPyInit_gpu_offscreen()));
|
||||
PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule);
|
||||
|
@@ -36,6 +36,7 @@
|
||||
|
||||
PyObject *GPU_initPython(void);
|
||||
|
||||
PyObject *BPyInit_gpu_draw(void);
|
||||
PyObject *BPyInit_gpu_offscreen(void);
|
||||
PyObject *BPyInit_gpu_matrix(void);
|
||||
PyObject *BPyInit_gpu_select(void);
|
||||
|
167
source/blender/python/intern/gpu_draw.c
Normal file
167
source/blender/python/intern/gpu_draw.c
Normal file
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
* ***** 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.
|
||||
*
|
||||
* Copyright 2015, Blender Foundation.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/** \file blender/python/intern/gpu_draw.c
|
||||
* \ingroup pythonintern
|
||||
*
|
||||
* This file defines the draw functionalities of the 'gpu' module
|
||||
* used for off-screen OpenGL rendering.
|
||||
*/
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "DNA_image_types.h"
|
||||
|
||||
#include "GPU_immediate.h"
|
||||
#include "GPU_texture.h"
|
||||
|
||||
#include "../generic/py_capi_utils.h"
|
||||
|
||||
#include "gpu.h"
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* GPU draw methods */
|
||||
|
||||
PyDoc_STRVAR(pygpu_draw_rect_doc,
|
||||
"rect(x1, y1, x2, y2, r, g, b, a)\n"
|
||||
);
|
||||
static PyObject *pygpu_draw_rect(PyObject *UNUSED(self), PyObject *args, PyObject *kwds)
|
||||
{
|
||||
static const char *kwlist[] = {"x1", "y1", "x2", "y2", "r", "g", "b", "a", NULL};
|
||||
float x1, y1, x2, y2, rgba[4];
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(
|
||||
args, kwds, "ffffffff", (char **)(kwlist),
|
||||
&x1, &y1, &x2, &y2, &rgba[0], &rgba[1], &rgba[2], &rgba[3]))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GPU_blend(true);
|
||||
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
immUniformColor4fv(rgba);
|
||||
immRectf(pos, x1, y1, x2, y2);
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
GPU_blend(false);
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(pygpu_draw_image_doc,
|
||||
"image(image, x1, y1, x2, y2)\n"
|
||||
);
|
||||
static PyObject *pygpu_draw_image(PyObject *UNUSED(self), PyObject *args, PyObject *kwds)
|
||||
{
|
||||
static const char *kwlist[] = {"image", "x1", "y1", "x2", "y2", NULL};
|
||||
PyObject *py_image;
|
||||
Image *image;
|
||||
float x1, y1, x2, y2;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(
|
||||
args, kwds, "Offff", (char **)(kwlist),
|
||||
&py_image, &x1, &y1, &x2, &y2))
|
||||
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(image = PyC_RNA_AsPointer(py_image, "Image"))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GPUTexture *tex = GPU_texture_from_blender(image, NULL, GL_TEXTURE_2D, false, 0.0f);
|
||||
|
||||
if (tex == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GPU_texture_bind(tex, 0);
|
||||
|
||||
GPUVertFormat *format = immVertexFormat();
|
||||
uint texcoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
||||
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_IMAGE);
|
||||
|
||||
immUniform1i("image", 0);
|
||||
|
||||
immBegin(GPU_PRIM_TRI_FAN, 4);
|
||||
|
||||
immAttrib2f(texcoord, 0.0f, 0.0f);
|
||||
immVertex2f(pos, x1, y1);
|
||||
|
||||
immAttrib2f(texcoord, 1.0f, 0.0f);
|
||||
immVertex2f(pos, x2, y1);
|
||||
|
||||
immAttrib2f(texcoord, 1.0f, 1.0f);
|
||||
immVertex2f(pos, x2, y2);
|
||||
|
||||
immAttrib2f(texcoord, 0.0f, 1.0f);
|
||||
immVertex2f(pos, x1, y2);
|
||||
|
||||
immEnd();
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
GPU_texture_unbind(tex);
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static struct PyMethodDef BPy_GPU_draw_methods[] = {
|
||||
{"rect", (PyCFunction)pygpu_draw_rect, METH_VARARGS | METH_KEYWORDS, pygpu_draw_rect_doc},
|
||||
{"image", (PyCFunction)pygpu_draw_image, METH_VARARGS | METH_KEYWORDS, pygpu_draw_image_doc},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(BPy_GPU_draw_doc,
|
||||
"This module provides access to drawing functions."
|
||||
);
|
||||
static PyModuleDef BPy_GPU_draw_module_def = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
"gpu.draw", /* m_name */
|
||||
BPy_GPU_draw_doc, /* m_doc */
|
||||
0, /* m_size */
|
||||
BPy_GPU_draw_methods, /* m_methods */
|
||||
NULL, /* m_reload */
|
||||
NULL, /* m_traverse */
|
||||
NULL, /* m_clear */
|
||||
NULL, /* m_free */
|
||||
};
|
||||
|
||||
PyObject *BPyInit_gpu_draw(void)
|
||||
{
|
||||
PyObject *submodule;
|
||||
|
||||
submodule = PyModule_Create(&BPy_GPU_draw_module_def);
|
||||
|
||||
return submodule;
|
||||
}
|
||||
|
||||
#undef BPY_GPU_OFFSCREEN_CHECK_OBJ
|
@@ -243,8 +243,14 @@ void WM_keymap_init(bContext *C)
|
||||
/* create default key config, only initialize once,
|
||||
* it's persistent across sessions */
|
||||
if (!(wm->defaultconf->flag & KEYCONF_INIT_DEFAULT)) {
|
||||
/* Benchmark: no keymaps. */
|
||||
#if 0
|
||||
wm_window_keymap(wm->defaultconf);
|
||||
ED_spacetypes_keymap(wm->defaultconf);
|
||||
#else
|
||||
SpaceType *st = BKE_spacetype_from_id(SPACE_FILE);
|
||||
st->keymap(wm->defaultconf);
|
||||
#endif
|
||||
|
||||
wm->defaultconf->flag |= KEYCONF_INIT_DEFAULT;
|
||||
}
|
||||
|
@@ -556,6 +556,11 @@ static void wm_file_read_post(bContext *C, const bool is_startup_file, const boo
|
||||
|
||||
/* Ensure tools are registered. */
|
||||
WM_toolsystem_init(C);
|
||||
|
||||
/* Benchmark: fullscreen editor. */
|
||||
CTX_wm_window_set(C, wm->windows.first);
|
||||
ED_screen_full_newspace(C, NULL, SPACE_BENCHMARK);
|
||||
CTX_wm_window_set(C, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -341,6 +341,9 @@ void WM_init(bContext *C, int argc, const char **argv)
|
||||
|
||||
void WM_init_splash(bContext *C)
|
||||
{
|
||||
/* Benchmark: no splash screen. */
|
||||
return;
|
||||
|
||||
if ((U.uiflag & USER_SPLASH_DISABLE) == 0) {
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
wmWindow *prevwin = CTX_wm_window(C);
|
||||
|
@@ -546,8 +546,10 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win)
|
||||
G_MAIN->recovered ? " (Recovered)" : "");
|
||||
GHOST_SetTitle(win->ghostwin, str);
|
||||
}
|
||||
else
|
||||
GHOST_SetTitle(win->ghostwin, "Blender");
|
||||
else {
|
||||
/* Benchmark: title. */
|
||||
GHOST_SetTitle(win->ghostwin, "Blender Benchmark");
|
||||
}
|
||||
|
||||
/* Informs GHOST of unsaved changes, to set window modified visual indicator (MAC OS X)
|
||||
* and to give hint of unsaved changes for a user warning mechanism
|
||||
@@ -691,6 +693,25 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm
|
||||
}
|
||||
}
|
||||
|
||||
/* Benchmark: ugly hack to get DPI before we have opened any windows. */
|
||||
static void wm_window_set_startup_dpi(wmWindow *win, float *native_pixel_size)
|
||||
{
|
||||
GHOST_GLSettings glSettings = {0};
|
||||
|
||||
win->ghostwin = GHOST_CreateWindow(g_system, "Temp",
|
||||
0, 0, 512, 512,
|
||||
GHOST_kWindowStateNormal,
|
||||
GHOST_kDrawingContextTypeOpenGL,
|
||||
glSettings);
|
||||
|
||||
WM_window_set_dpi(win);
|
||||
|
||||
*native_pixel_size = GHOST_GetNativePixelSize(win->ghostwin);
|
||||
|
||||
GHOST_DisposeWindow(g_system, win->ghostwin);
|
||||
win->ghostwin = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize #wmWindow without ghostwin, open these and clear.
|
||||
*
|
||||
@@ -758,7 +779,19 @@ void wm_window_ghostwindows_ensure(wmWindowManager *wm)
|
||||
win->cursor = CURSOR_STD;
|
||||
}
|
||||
|
||||
wm_window_ghostwindow_add(wm, "Blender", win);
|
||||
/* Benchmark: fixed size and centered window. */
|
||||
float native_pixel_size;
|
||||
wm_window_set_startup_dpi(win, &native_pixel_size);
|
||||
win->sizex = 800 * UI_DPI_FAC / native_pixel_size;
|
||||
win->sizey = 570 * UI_DPI_FAC / native_pixel_size;
|
||||
|
||||
int scr_w, scr_h;
|
||||
wm_get_screensize(&scr_w, &scr_h);
|
||||
win->posx = (scr_w - win->sizex) / 2;
|
||||
win->posy = (scr_h - win->sizey) / 2;
|
||||
|
||||
/* Benchmark: title. */
|
||||
wm_window_ghostwindow_add(wm, "Blender Benchmark", win);
|
||||
}
|
||||
/* happens after fileread */
|
||||
wm_window_ensure_eventstate(win);
|
||||
@@ -954,7 +987,7 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i
|
||||
else if (sa->spacetype == SPACE_IPO)
|
||||
title = IFACE_("Blender Drivers Editor");
|
||||
else
|
||||
title = "Blender";
|
||||
title = "Blender Benchmark"; /* Benchmark: title. */
|
||||
|
||||
if (win->ghostwin) {
|
||||
GHOST_SetTitle(win->ghostwin, title);
|
||||
|
@@ -248,6 +248,9 @@ if(WITH_PYTHON_MODULE)
|
||||
else()
|
||||
add_executable(blender ${EXETYPE} ${SRC})
|
||||
WINDOWS_SIGN_TARGET(blender)
|
||||
|
||||
# Benchmark: rename executable
|
||||
SET_TARGET_PROPERTIES(blender PROPERTIES OUTPUT_NAME blender-benchmark)
|
||||
endif()
|
||||
|
||||
if(WITH_BUILDINFO)
|
||||
@@ -316,7 +319,7 @@ elseif(APPLE)
|
||||
if(WITH_PYTHON_MODULE)
|
||||
set(TARGETDIR_VER ${BLENDER_VERSION})
|
||||
else()
|
||||
set(TARGETDIR_VER blender.app/Contents/Resources/${BLENDER_VERSION})
|
||||
set(TARGETDIR_VER blender-benchmark.app/Contents/Resources/${BLENDER_VERSION})
|
||||
endif()
|
||||
# Skip relinking on cpack / install
|
||||
set_target_properties(blender PROPERTIES BUILD_WITH_INSTALL_RPATH true)
|
||||
@@ -336,21 +339,6 @@ install(
|
||||
if(WITH_PYTHON)
|
||||
# install(CODE "message(\"copying blender scripts...\")")
|
||||
|
||||
# exclude addons_contrib if release
|
||||
if("${BLENDER_VERSION_CYCLE}" STREQUAL "release" OR
|
||||
"${BLENDER_VERSION_CYCLE}" STREQUAL "rc")
|
||||
set(ADDON_EXCLUDE_CONDITIONAL "addons_contrib/*")
|
||||
else()
|
||||
set(ADDON_EXCLUDE_CONDITIONAL "_addons_contrib/*") # dummy, wont do anything
|
||||
endif()
|
||||
|
||||
# do not install freestyle dir if disabled
|
||||
if(NOT WITH_FREESTYLE)
|
||||
set(FREESTYLE_EXCLUDE_CONDITIONAL "freestyle/*")
|
||||
else()
|
||||
set(FREESTYLE_EXCLUDE_CONDITIONAL "_freestyle/*") # dummy, wont do anything
|
||||
endif()
|
||||
|
||||
install(
|
||||
DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts
|
||||
DESTINATION ${TARGETDIR_VER}
|
||||
@@ -358,12 +346,13 @@ if(WITH_PYTHON)
|
||||
PATTERN ".gitignore" EXCLUDE
|
||||
PATTERN ".arcconfig" EXCLUDE
|
||||
PATTERN "__pycache__" EXCLUDE
|
||||
PATTERN "${ADDON_EXCLUDE_CONDITIONAL}" EXCLUDE
|
||||
PATTERN "${FREESTYLE_EXCLUDE_CONDITIONAL}" EXCLUDE
|
||||
PATTERN "addons/*" EXCLUDE
|
||||
PATTERN "addons_contrib/*" EXCLUDE
|
||||
PATTERN "freestyle/*" EXCLUDE
|
||||
PATTERN "presets/*" EXCLUDE
|
||||
PATTERN "templates_osl/*" EXCLUDE
|
||||
PATTERN "templates_py/*" EXCLUDE
|
||||
)
|
||||
|
||||
unset(ADDON_EXCLUDE_CONDITIONAL)
|
||||
unset(FREESTYLE_EXCLUDE_CONDITIONAL)
|
||||
endif()
|
||||
|
||||
# localization
|
||||
@@ -423,10 +412,12 @@ if(WITH_OPENCOLORIO)
|
||||
endif()
|
||||
|
||||
# Add default workspaces.blend to build (under [version]/datafiles
|
||||
if (False)
|
||||
install(
|
||||
FILES ${CMAKE_SOURCE_DIR}/release/datafiles/workspaces.blend
|
||||
DESTINATION ${TARGETDIR_VER}/datafiles
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
# helpful tip when using make
|
||||
@@ -457,7 +448,13 @@ if(UNIX AND NOT APPLE)
|
||||
endif()
|
||||
|
||||
# there are a few differences between portable and system install
|
||||
if(WITH_PYTHON_MODULE)
|
||||
if(True)
|
||||
install(
|
||||
TARGETS blender
|
||||
DESTINATION "."
|
||||
)
|
||||
set(BLENDER_TEXT_FILES_DESTINATION "license")
|
||||
elseif(WITH_PYTHON_MODULE)
|
||||
if(WITH_INSTALL_PORTABLE)
|
||||
install(
|
||||
TARGETS blender
|
||||
@@ -653,7 +650,7 @@ if(UNIX AND NOT APPLE)
|
||||
endif()
|
||||
elseif(WIN32)
|
||||
|
||||
set(BLENDER_TEXT_FILES_DESTINATION ".")
|
||||
set(BLENDER_TEXT_FILES_DESTINATION "license")
|
||||
|
||||
if(WITH_PYTHON)
|
||||
string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
|
||||
@@ -891,7 +888,7 @@ elseif(APPLE)
|
||||
|
||||
# Give the bundle actual creation/modification date
|
||||
execute_process(COMMAND SetFile -d ${SETFILE_DATE} -m ${SETFILE_DATE}
|
||||
${EXECUTABLE_OUTPUT_PATH}/blender.app)
|
||||
${EXECUTABLE_OUTPUT_PATH}/blender-benchmark.app)
|
||||
|
||||
install(
|
||||
TARGETS blender
|
||||
@@ -899,22 +896,22 @@ elseif(APPLE)
|
||||
)
|
||||
|
||||
# install release and app files
|
||||
set(BLENDER_TEXT_FILES_DESTINATION ".")
|
||||
set(BLENDER_TEXT_FILES_DESTINATION "license")
|
||||
|
||||
install(
|
||||
FILES ${OSX_APP_SOURCEDIR}/Contents/PkgInfo
|
||||
DESTINATION blender.app/Contents
|
||||
DESTINATION blender-benchmark.app/Contents
|
||||
)
|
||||
|
||||
install_dir(
|
||||
${OSX_APP_SOURCEDIR}/Contents/Resources
|
||||
blender.app/Contents/
|
||||
blender-benchmark.app/Contents/
|
||||
)
|
||||
|
||||
if(WITH_LLVM AND NOT LLVM_STATIC)
|
||||
install(
|
||||
FILES ${LIBDIR}/llvm/lib/libLLVM-3.4.dylib
|
||||
DESTINATION blender.app/Contents/MacOS
|
||||
DESTINATION blender-benchmark.app/Contents/MacOS
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -948,6 +945,8 @@ endif()
|
||||
|
||||
if(DEFINED BLENDER_TEXT_FILES_DESTINATION)
|
||||
|
||||
if (False)
|
||||
|
||||
install(
|
||||
CODE
|
||||
"
|
||||
@@ -962,6 +961,8 @@ if(DEFINED BLENDER_TEXT_FILES_DESTINATION)
|
||||
${CMAKE_BINARY_DIR}/release/text/readme.html
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
install(
|
||||
FILES ${BLENDER_TEXT_FILES}
|
||||
DESTINATION "${BLENDER_TEXT_FILES_DESTINATION}"
|
||||
@@ -978,6 +979,8 @@ unset(BLENDER_TEXT_FILES_DESTINATION)
|
||||
# -----------------------------------------------------------------------------
|
||||
# Geometry Icons
|
||||
|
||||
if(False)
|
||||
|
||||
# Geometry icons.
|
||||
get_property(_icon_names GLOBAL PROPERTY ICON_GEOM_NAMES)
|
||||
set(_icon_files)
|
||||
@@ -995,14 +998,21 @@ unset(_icon_names)
|
||||
unset(_icon_files)
|
||||
unset(_f)
|
||||
|
||||
endif()
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Studio Lights
|
||||
|
||||
if(False)
|
||||
|
||||
install(
|
||||
DIRECTORY
|
||||
${CMAKE_SOURCE_DIR}/release/datafiles/studiolights
|
||||
DESTINATION ${TARGETDIR_VER}/datafiles
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Setup link libs
|
||||
|
||||
|
@@ -390,7 +390,8 @@ int main(
|
||||
/* ensure we free on early exit */
|
||||
app_init_data.ba = ba;
|
||||
|
||||
main_args_setup(C, ba);
|
||||
/* Benchmark: disable arguments
|
||||
main_args_setup(C, ba); */
|
||||
|
||||
BLI_argsParse(ba, 1, NULL, NULL);
|
||||
|
||||
@@ -400,6 +401,9 @@ int main(
|
||||
G.factory_startup = true; /* using preferences or user startup makes no sense for py-as-module */
|
||||
#endif
|
||||
|
||||
/* Benchmark: factory startup. */
|
||||
G.factory_startup = true;
|
||||
|
||||
#ifdef WITH_FFMPEG
|
||||
IMB_ffmpeg_init();
|
||||
#endif
|
||||
@@ -480,7 +484,8 @@ int main(
|
||||
|
||||
/* OK we are ready for it */
|
||||
#ifndef WITH_PYTHON_MODULE
|
||||
main_args_setup_post(C, ba);
|
||||
/* Benchmark: disable arguments
|
||||
main_args_setup_post(C, ba); */
|
||||
|
||||
if (G.background == 0) {
|
||||
if (!G.file_loaded)
|
||||
|
Submodule source/tools updated: 87f7038ee8...11656ebaf7
Reference in New Issue
Block a user