Blender V4.5
DRWContext Struct Reference

#include <DRW_render.hh>

Public Types

enum  Mode {
  VIEWPORT = 0 , VIEWPORT_XR , VIEWPORT_OFFSCREEN , VIEWPORT_RENDER ,
  SELECT_OBJECT , SELECT_OBJECT_MATERIAL , SELECT_EDIT_MESH , DEPTH ,
  DEPTH_ACTIVE_OBJECT , RENDER , CUSTOM
}
 
using iter_callback_t
 

Public Member Functions

GPUFrameBuffer * default_framebuffer ()
 
DefaultFramebufferListviewport_framebuffer_list_get () const
 
DefaultTextureListviewport_texture_list_get () const
 
 DRWContext (Mode mode, Depsgraph *depsgraph, GPUViewport *viewport, const bContext *C=nullptr, ARegion *region=nullptr, View3D *v3d=nullptr)
 
 DRWContext (Mode mode, Depsgraph *depsgraph, const blender::int2 size={1, 1}, const bContext *C=nullptr, ARegion *region=nullptr, View3D *v3d=nullptr)
 
 ~DRWContext ()
 
blender::float2 viewport_size_get () const
 
bool is_select () const
 
bool is_material_select () const
 
bool is_depth () const
 
bool is_image_render () const
 
bool is_scene_render () const
 
bool is_viewport_image_render () const
 
Viewport (DRW_viewport)
void acquire_data ()
 
void release_data ()
 
Rendering (DRW_engines)
void enable_engines (bool gpencil_engine_needed=false, RenderEngineType *render_engine_type=nullptr)
 
void engines_data_validate ()
 
void sync (iter_callback_t iter_callback)
 
void engines_init_and_sync (iter_callback_t iter_callback)
 
void engines_draw_scene ()
 
Draw Manager State
bool is_playback () const
 
bool is_navigating () const
 
bool is_painting () const
 
bool is_transforming () const
 
bool is_viewport_compositor_enabled () const
 

Static Public Member Functions

static DRWContextget_active ()
 
static bool is_active ()
 

Public Attributes

DRWDatadata = nullptr
 
DRWViewDataview_data_active = nullptr
 
GPUViewportviewport = nullptr
 
blender::float2 size = {0, 0}
 
blender::float2 inv_size = {0, 0}
 
enum DRWContext::Mode mode
 
struct { 
 
   bool   draw_background = false 
 
   bool   draw_text = false 
 
options 
 
DRWTextStore ** text_store_p = nullptr
 
GSetdelayed_extraction = nullptr
 
Depsgraph * depsgraph = nullptr
 
Scenescene = nullptr
 
ViewLayerview_layer = nullptr
 
const bContextevil_C = nullptr
 
ARegionregion = nullptr
 
SpaceLinkspace_data = nullptr
 
RegionView3Drv3d = nullptr
 
View3Dv3d = nullptr
 
Objectobact = nullptr
 
Objectobject_pose = nullptr
 
Objectobject_edit = nullptr
 
eObjectMode object_mode = OB_MODE_OBJECT
 

Detailed Description

Definition at line 209 of file DRW_render.hh.

Member Typedef Documentation

◆ iter_callback_t

Initial value:

Definition at line 354 of file DRW_render.hh.

Member Enumeration Documentation

◆ Mode

Enumerator
VIEWPORT 

Render for display of 2D or 3D area. Runs on main thread.

VIEWPORT_XR 

Render for a 3D viewport in XR. Runs on main thread.

VIEWPORT_OFFSCREEN 

Render for a 3D viewport offscreen render (python). Runs on main thread.

VIEWPORT_RENDER 

Render for a 3D viewport image render (render preview). Runs on main thread.

SELECT_OBJECT 

Render for object mode selection. Runs on main thread.

SELECT_OBJECT_MATERIAL 

Render for object material selection. Runs on main thread.

SELECT_EDIT_MESH 

Render for edit mesh selection. Runs on main thread.

DEPTH 

Render for depth picking (auto-depth). Runs on main thread.

DEPTH_ACTIVE_OBJECT 
RENDER 

Render for F12 final render. Can run in any thread.

CUSTOM 

Used by custom pipeline. Can run in any thread.

Definition at line 235 of file DRW_render.hh.

Constructor & Destructor Documentation

◆ DRWContext() [1/2]

DRWContext::DRWContext ( Mode mode,
Depsgraph * depsgraph,
GPUViewport * viewport,
const bContext * C = nullptr,
ARegion * region = nullptr,
View3D * v3d = nullptr )

If viewport is not specified, DRWData will be considered temporary and discarded on exit. If C is nullptr, it means that the context is not associated with any UI or operator. If region is nullptr, it will be sourced from the context C or left as nullptr otherwise. If v3d is nullptr, it will be sourced from the context C or left as nullptr otherwise.

Definition at line 174 of file draw_context.cc.

References viewport, and blender::draw::color_management::viewport_color_management_set().

◆ DRWContext() [2/2]

DRWContext::DRWContext ( Mode mode,
Depsgraph * depsgraph,
const blender::int2 size = {1, 1},
const bContext * C = nullptr,
ARegion * region = nullptr,
View3D * v3d = nullptr )

◆ ~DRWContext()

DRWContext::~DRWContext ( )

Definition at line 193 of file draw_context.cc.

References BLI_assert.

Member Function Documentation

◆ acquire_data()

◆ default_framebuffer()

GPUFrameBuffer * DRWContext::default_framebuffer ( )

Returns the viewport's default frame-buffer.

Definition at line 199 of file draw_context.cc.

References DefaultFramebufferList::default_fb, DRWViewData::dfbl, and view_data_active.

Referenced by drw_draw_render_loop_2d(), and drw_draw_render_loop_3d().

◆ enable_engines()

◆ engines_data_validate()

void DRWContext::engines_data_validate ( )

Free unused engine data.

Definition at line 949 of file draw_context.cc.

References DRW_view_data_free_unused().

Referenced by drw_draw_render_loop_2d(), drw_draw_render_loop_3d(), and DRW_draw_select_loop().

◆ engines_draw_scene()

◆ engines_init_and_sync()

void DRWContext::engines_init_and_sync ( iter_callback_t iter_callback)

Run enabled engine init and sync callbacks. iter_callback defines which object to sync.

Definition at line 788 of file draw_context.cc.

References DrawEngine::begin_sync(), DrawEngine::end_sync(), if(), DrawEngine::init(), and DrawEngine::text_draw_cache.

Referenced by DRW_draw_depth_loop(), drw_draw_render_loop_2d(), drw_draw_render_loop_3d(), DRW_draw_select_id(), and DRW_draw_select_loop().

◆ get_active()

static DRWContext & DRWContext::get_active ( )
inlinestatic

Definition at line 364 of file DRW_render.hh.

Referenced by drw_get().

◆ is_active()

static bool DRWContext::is_active ( )
inlinestatic

Return true if any DRWContext is active on this thread.

Definition at line 375 of file DRW_render.hh.

Referenced by DRW_draw_in_progress().

◆ is_depth()

bool DRWContext::is_depth ( ) const
inline

Definition at line 388 of file DRW_render.hh.

References DEPTH, DEPTH_ACTIVE_OBJECT, ELEM, and mode.

Referenced by blender::draw::overlay::Instance::init().

◆ is_image_render()

◆ is_material_select()

bool DRWContext::is_material_select ( ) const
inline

Definition at line 384 of file DRW_render.hh.

References ELEM, mode, and SELECT_OBJECT_MATERIAL.

Referenced by blender::draw::overlay::Instance::init().

◆ is_navigating()

bool DRWContext::is_navigating ( ) const

True if current viewport is drawn during navigation operator.

Definition at line 1983 of file draw_context.cc.

References RV3D_NAVIGATING, and RV3D_PAINTING.

Referenced by blender::eevee::Instance::init().

◆ is_painting()

bool DRWContext::is_painting ( ) const

True if current viewport is drawn during painting operator.

Definition at line 1988 of file draw_context.cc.

References RV3D_PAINTING.

Referenced by blender::eevee::Instance::init().

◆ is_playback()

bool DRWContext::is_playback ( ) const

True if current viewport is drawn during playback.

Definition at line 1974 of file draw_context.cc.

References CTX_wm_manager(), and ED_screen_animation_playing().

Referenced by blender::eevee::Instance::init().

◆ is_scene_render()

◆ is_select()

bool DRWContext::is_select ( ) const
inline

Definition at line 380 of file DRW_render.hh.

References ELEM, mode, SELECT_EDIT_MESH, SELECT_OBJECT, and SELECT_OBJECT_MATERIAL.

◆ is_transforming()

bool DRWContext::is_transforming ( ) const

True if current viewport is drawn during transforming operator.

Definition at line 1993 of file draw_context.cc.

References G, G_TRANSFORM_EDIT, and G_TRANSFORM_OBJ.

Referenced by blender::eevee::Instance::init().

◆ is_viewport_compositor_enabled()

bool DRWContext::is_viewport_compositor_enabled ( ) const

◆ is_viewport_image_render()

◆ release_data()

void DRWContext::release_data ( )

Make sure to release acquired DRWData. If created on the fly, make sure to destroy them. IMPORTANT: This needs to be called with the same active GPUContext acquire_data() was called with.

Definition at line 526 of file draw_context.cc.

References BLI_assert, data, DRW_view_data_reset(), DRW_viewport_data_free(), GPU_context_active_get(), DRWData::modules_exit(), blender::draw::command::StateSet::set(), view_data_active, and viewport.

Referenced by DRW_custom_pipeline_end(), DRW_draw_depth_loop(), DRW_draw_render_loop_offscreen(), DRW_draw_select_id(), DRW_draw_select_loop(), and DRW_draw_view().

◆ sync()

void DRWContext::sync ( iter_callback_t iter_callback)

Run the sync phase with data extraction. iter_callback defines which object to sync.

Definition at line 771 of file draw_context.cc.

References data, DupliCacheManager::extract_all(), and ExtractionGraph::work_and_wait().

Referenced by DRW_render_object_iter().

◆ viewport_framebuffer_list_get()

◆ viewport_size_get()

◆ viewport_texture_list_get()

Member Data Documentation

◆ data

◆ delayed_extraction

GSet* DRWContext::delayed_extraction = nullptr

Contains list of objects that needs to be extracted from other objects.

Definition at line 274 of file DRW_render.hh.

Referenced by blender::draw::drw_batch_cache_generate_requested_delayed().

◆ depsgraph

◆ draw_background

bool DRWContext::draw_background = false

◆ draw_text

bool DRWContext::draw_text = false

Definition at line 267 of file DRW_render.hh.

Referenced by blender::draw::overlay::Instance::init().

◆ evil_C

const bContext* DRWContext::evil_C = nullptr

Last resort (some functions take this as an arg so we can't easily avoid). May be nullptr when used for selection or depth buffer.

Definition at line 289 of file DRW_render.hh.

Referenced by blender::draw::gpencil::Instance::begin_sync(), drw_callbacks_post_scene(), drw_callbacks_post_scene_2D(), drw_callbacks_pre_scene(), drw_callbacks_pre_scene_2D(), blender::image_engine::Instance::init(), blender::workbench::ObjectState::ObjectState(), and blender::draw::sculpt_batches_get_ex().

◆ inv_size

blender::float2 DRWContext::inv_size = {0, 0}

Definition at line 226 of file DRW_render.hh.

◆ mode

◆ obact

◆ object_edit

◆ object_mode

◆ object_pose

◆ [struct]

struct { ... } DRWContext::options

◆ region

◆ rv3d

◆ scene

◆ size

blender::float2 DRWContext::size = {0, 0}

Size of the viewport or the final render frame.

Definition at line 225 of file DRW_render.hh.

Referenced by viewport_size_get().

◆ space_data

◆ text_store_p

DRWTextStore** DRWContext::text_store_p = nullptr

Convenience pointer to text_store owned by the viewport

Definition at line 271 of file DRW_render.hh.

Referenced by DRW_text_cache_ensure().

◆ v3d

◆ view_data_active

◆ view_layer

◆ viewport

GPUViewport* DRWContext::viewport = nullptr

Optional associated viewport. Can be nullptr.

Definition at line 223 of file DRW_render.hh.

Referenced by acquire_data(), DRWContext(), and release_data().


The documentation for this struct was generated from the following files: