MCPcopy Create free account
hub / github.com/comaps/comaps / ApplyState

Function ApplyState

libs/drape/render_state.cpp:286–343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284}
285
286void ApplyState(ref_ptr<GraphicsContext> context, ref_ptr<GpuProgram> program, RenderState const & state)
287{
288 auto const apiVersion = context->GetApiVersion();
289
290 TextureState::ApplyTextures(context, state, program);
291
292 // Apply blending state.
293 if (apiVersion == dp::ApiVersion::Metal)
294 {
295 // For Metal rendering blending state is a part of the pipeline state.
296#if defined(OMIM_METAL_AVAILABLE)
297 ApplyPipelineStateForMetal(context, program, state.GetBlending().m_isEnabled);
298#endif
299 }
300 else if (apiVersion == dp::ApiVersion::Vulkan)
301 {
302 ref_ptr<dp::vulkan::VulkanBaseContext> vulkanContext = context;
303 vulkanContext->SetProgram(program);
304 vulkanContext->SetBlendingEnabled(state.GetBlending().m_isEnabled);
305 }
306 else
307 {
308 state.GetBlending().Apply(context, program);
309 }
310
311 // Apply depth state.
312 context->SetDepthTestEnabled(state.GetDepthTestEnabled());
313 if (state.GetDepthTestEnabled())
314 context->SetDepthTestFunction(state.GetDepthFunction());
315 if (apiVersion == dp::ApiVersion::Metal)
316 {
317 // For Metal rendering we have to apply depth-stencil state after SetX functions calls.
318#if defined(OMIM_METAL_AVAILABLE)
319 ApplyDepthStencilStateForMetal(context);
320#endif
321 }
322
323 if (state.GetDrawAsLine())
324 {
325 if (apiVersion == dp::ApiVersion::OpenGLES3)
326 {
327 ASSERT_GREATER_OR_EQUAL(state.GetLineWidth(), 0, ());
328 GLFunctions::glLineWidth(static_cast<uint32_t>(state.GetLineWidth()));
329 }
330 else if (apiVersion == dp::ApiVersion::Metal)
331 {
332 // Do nothing. Metal does not support line width.
333 }
334 else if (apiVersion == dp::ApiVersion::Vulkan)
335 {
336 ASSERT_GREATER_OR_EQUAL(state.GetLineWidth(), 0, ());
337 ref_ptr<dp::vulkan::VulkanBaseContext> vulkanContext = context;
338 VkCommandBuffer commandBuffer = vulkanContext->GetCurrentRenderingCommandBuffer();
339 CHECK(commandBuffer != nullptr, ());
340 vkCmdSetLineWidth(commandBuffer, static_cast<float>(state.GetLineWidth()));
341 }
342 }
343}

Callers 15

RenderMethod · 0.85
RenderLinesCapsMethod · 0.85
RenderLinesMethod · 0.85
RenderMarkersMethod · 0.85
RenderTextMethod · 0.85
RenderStubsMethod · 0.85
RenderTrafficMethod · 0.85
ApplyMethod · 0.85
RenderMethod · 0.85
RenderTrackMethod · 0.85
RenderMethod · 0.85
RenderSubrouteMethod · 0.85

Calls 11

SetProgramMethod · 0.80
SetBlendingEnabledMethod · 0.80
GetDepthFunctionMethod · 0.80
GetDrawAsLineMethod · 0.80
GetLineWidthMethod · 0.80
GetApiVersionMethod · 0.45
ApplyMethod · 0.45
SetDepthTestEnabledMethod · 0.45
GetDepthTestEnabledMethod · 0.45
SetDepthTestFunctionMethod · 0.45

Tested by

no test coverage detected