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

Method ApplyMutation

libs/drape/vertex_array_buffer.cpp:342–387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

340}
341
342void VertexArrayBuffer::ApplyMutation(ref_ptr<GraphicsContext> context, ref_ptr<IndexBufferMutator> indexMutator,
343 ref_ptr<AttributeBufferMutator> attrMutator)
344{
345 // We need to bind current VAO before calling glBindBuffer if OES_vertex_array_object is
346 // supported. Otherwise we risk affecting a previously bound VAO.
347 Bind();
348
349 if (indexMutator != nullptr)
350 {
351 ASSERT(m_indexBuffer != nullptr, ());
352 if (indexMutator->GetCapacity() > m_indexBuffer->GetBuffer()->GetCapacity())
353 {
354 m_indexBuffer = make_unique_dp<IndexBuffer>(indexMutator->GetCapacity());
355 m_indexBuffer->MoveToGPU(context, GPUBuffer::IndexBuffer, m_batcherHash);
356 }
357 m_indexBuffer->UpdateData(context, indexMutator->GetIndexes(), indexMutator->GetIndexCount());
358 }
359
360 if (attrMutator == nullptr)
361 {
362 Unbind();
363 return;
364 }
365
366 auto const & data = attrMutator->GetMutateData();
367 for (auto it = data.begin(); it != data.end(); ++it)
368 {
369 auto const & nodes = it->second;
370 if (nodes.empty())
371 continue;
372
373 auto const offsets = CalculateMappingPart(nodes);
374
375 ref_ptr<DataBuffer> buffer = GetDynamicBuffer(it->first);
376 ASSERT(buffer != nullptr, ());
377 DataBufferMapper mapper(context, buffer, offsets.first, offsets.second);
378 for (size_t i = 0; i < nodes.size(); ++i)
379 {
380 MutateNode const & node = nodes[i];
381 ASSERT_GREATER(node.m_region.m_count, 0, ());
382 mapper.UpdateData(node.m_data.get(), node.m_region.m_offset - offsets.first, node.m_region.m_count);
383 }
384 }
385
386 Unbind();
387}
388
389bool VertexArrayBuffer::Bind() const
390{

Callers 2

RenderMethod · 0.80
RenderMethod · 0.80

Calls 13

ASSERTFunction · 0.85
CalculateMappingPartFunction · 0.85
MoveToGPUMethod · 0.80
GetIndexesMethod · 0.80
getMethod · 0.65
GetCapacityMethod · 0.45
GetBufferMethod · 0.45
UpdateDataMethod · 0.45
GetIndexCountMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected