diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-09-08 05:12:12 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-09-08 05:15:50 +0300 |
commit | 48690d967a7731367cda01ab8dca64e7f4c3f6b5 (patch) | |
tree | 9295cc0ef083fd50eaab2c62785d54545eb004c6 /source/blender/gpu/intern/gpu_state.cc | |
parent | d2e9de93b8d1d6cd45abce8164d0f92af8f636d0 (diff) |
GPUContext: Move GPUContext to gpu::Context for more consistency
This makes the GPUContext follow the same naming convention as the rest
of the module.
Also add a static getter for extra bonus style (no need for casts):
- Context::get()
- GLContext::get()
Diffstat (limited to 'source/blender/gpu/intern/gpu_state.cc')
-rw-r--r-- | source/blender/gpu/intern/gpu_state.cc | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/source/blender/gpu/intern/gpu_state.cc b/source/blender/gpu/intern/gpu_state.cc index 68f0c290bc6..529c8795327 100644 --- a/source/blender/gpu/intern/gpu_state.cc +++ b/source/blender/gpu/intern/gpu_state.cc @@ -41,7 +41,7 @@ using namespace blender::gpu; #define SET_STATE(_prefix, _state, _value) \ do { \ - GPUStateManager *stack = GPU_context_active_get()->state_manager; \ + GPUStateManager *stack = Context::get()->state_manager; \ auto &state_object = stack->_prefix##state; \ state_object._state = (_value); \ } while (0) @@ -105,7 +105,7 @@ void GPU_write_mask(eGPUWriteMask mask) void GPU_color_mask(bool r, bool g, bool b, bool a) { - GPUStateManager *stack = GPU_context_active_get()->state_manager; + GPUStateManager *stack = Context::get()->state_manager; auto &state = stack->state; uint32_t write_mask = state.write_mask; SET_FLAG_FROM_TEST(write_mask, r, (uint32_t)GPU_WRITE_RED); @@ -117,7 +117,7 @@ void GPU_color_mask(bool r, bool g, bool b, bool a) void GPU_depth_mask(bool depth) { - GPUStateManager *stack = GPU_context_active_get()->state_manager; + GPUStateManager *stack = Context::get()->state_manager; auto &state = stack->state; uint32_t write_mask = state.write_mask; SET_FLAG_FROM_TEST(write_mask, depth, (uint32_t)GPU_WRITE_DEPTH); @@ -142,7 +142,7 @@ void GPU_state_set(eGPUWriteMask write_mask, eGPUStencilOp stencil_op, eGPUProvokingVertex provoking_vert) { - GPUStateManager *stack = GPU_context_active_get()->state_manager; + GPUStateManager *stack = Context::get()->state_manager; auto &state = stack->state; state.write_mask = (uint32_t)write_mask; state.blend = (uint32_t)blend; @@ -161,7 +161,7 @@ void GPU_state_set(eGPUWriteMask write_mask, void GPU_depth_range(float near, float far) { - GPUStateManager *stack = GPU_context_active_get()->state_manager; + GPUStateManager *stack = Context::get()->state_manager; auto &state = stack->mutable_state; copy_v2_fl2(state.depth_range, near, far); } @@ -182,7 +182,7 @@ void GPU_point_size(float size) /* TODO remove and use program point size everywhere */ void GPU_program_point_size(bool enable) { - GPUStateManager *stack = GPU_context_active_get()->state_manager; + GPUStateManager *stack = Context::get()->state_manager; auto &state = stack->mutable_state; /* Set point size sign negative to disable. */ state.point_size = fabsf(state.point_size) * (enable ? 1 : -1); @@ -190,19 +190,19 @@ void GPU_program_point_size(bool enable) void GPU_scissor_test(bool enable) { - GPU_context_active_get()->active_fb->scissor_test_set(enable); + Context::get()->active_fb->scissor_test_set(enable); } void GPU_scissor(int x, int y, int width, int height) { int scissor_rect[4] = {x, y, width, height}; - GPU_context_active_get()->active_fb->scissor_set(scissor_rect); + Context::get()->active_fb->scissor_set(scissor_rect); } void GPU_viewport(int x, int y, int width, int height) { int viewport_rect[4] = {x, y, width, height}; - GPU_context_active_get()->active_fb->viewport_set(viewport_rect); + Context::get()->active_fb->viewport_set(viewport_rect); } void GPU_stencil_reference_set(uint reference) @@ -228,43 +228,43 @@ void GPU_stencil_compare_mask_set(uint compare_mask) eGPUBlend GPU_blend_get() { - GPUState &state = GPU_context_active_get()->state_manager->state; + GPUState &state = Context::get()->state_manager->state; return (eGPUBlend)state.blend; } eGPUWriteMask GPU_write_mask_get() { - GPUState &state = GPU_context_active_get()->state_manager->state; + GPUState &state = Context::get()->state_manager->state; return (eGPUWriteMask)state.write_mask; } uint GPU_stencil_mask_get() { - GPUStateMutable &state = GPU_context_active_get()->state_manager->mutable_state; + GPUStateMutable &state = Context::get()->state_manager->mutable_state; return state.stencil_write_mask; } eGPUDepthTest GPU_depth_test_get() { - GPUState &state = GPU_context_active_get()->state_manager->state; + GPUState &state = Context::get()->state_manager->state; return (eGPUDepthTest)state.depth_test; } eGPUStencilTest GPU_stencil_test_get() { - GPUState &state = GPU_context_active_get()->state_manager->state; + GPUState &state = Context::get()->state_manager->state; return (eGPUStencilTest)state.stencil_test; } void GPU_scissor_get(int coords[4]) { - GPU_context_active_get()->active_fb->scissor_get(coords); + Context::get()->active_fb->scissor_get(coords); } void GPU_viewport_size_get_f(float coords[4]) { int viewport[4]; - GPU_context_active_get()->active_fb->viewport_get(viewport); + Context::get()->active_fb->viewport_get(viewport); for (int i = 0; i < 4; i++) { coords[i] = viewport[i]; } @@ -272,12 +272,12 @@ void GPU_viewport_size_get_f(float coords[4]) void GPU_viewport_size_get_i(int coords[4]) { - GPU_context_active_get()->active_fb->viewport_get(coords); + Context::get()->active_fb->viewport_get(coords); } bool GPU_depth_mask_get(void) { - GPUState &state = GPU_context_active_get()->state_manager->state; + GPUState &state = Context::get()->state_manager->state; return (state.write_mask & GPU_WRITE_DEPTH) != 0; } @@ -295,12 +295,12 @@ bool GPU_mipmap_enabled(void) void GPU_flush(void) { - GPU_context_active_get()->flush(); + Context::get()->flush(); } void GPU_finish(void) { - GPU_context_active_get()->finish(); + Context::get()->finish(); } /** \} */ |