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

Method UploadResources

libs/drape/texture_of_colors.cpp:73–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73void ColorPalette::UploadResources(ref_ptr<dp::GraphicsContext> context, ref_ptr<Texture> texture)
74{
75 ASSERT(texture->GetFormat() == dp::TextureFormat::RGBA8, ());
76 bool const hasPartialTextureUpdate = context->HasPartialTextureUpdates();
77
78 std::vector<PendingColor> pendingNodes;
79 {
80 std::lock_guard<std::mutex> g(m_lock);
81 if (m_pendingNodes.empty())
82 return;
83
84 if (hasPartialTextureUpdate)
85 {
86 pendingNodes.swap(m_pendingNodes);
87 }
88 else
89 {
90 // Store all colors in m_nodes, because we should update *whole* texture, if partial update is not available.
91 m_nodes.insert(m_nodes.end(), m_pendingNodes.begin(), m_pendingNodes.end());
92 m_pendingNodes.clear();
93 pendingNodes = m_nodes;
94 }
95 }
96
97 if (!hasPartialTextureUpdate)
98 {
99 PendingColor lastPendingColor = pendingNodes.back();
100 lastPendingColor.m_color = Color::Transparent();
101 while (lastPendingColor.m_rect.maxX() < m_textureSize.x)
102 {
103 lastPendingColor.m_rect.Offset(kResourceSize, 0);
104 pendingNodes.push_back(lastPendingColor);
105 }
106 }
107
108 buffer_vector<size_t, 4> ranges;
109 ranges.push_back(0);
110
111 uint32_t minX = pendingNodes[0].m_rect.minX();
112 for (size_t i = 1; i < pendingNodes.size(); ++i)
113 {
114 m2::RectU const & currentRect = pendingNodes[i].m_rect;
115 if (minX > currentRect.minX())
116 {
117 ranges.push_back(i);
118 minX = currentRect.minX();
119 }
120 }
121
122 ASSERT(hasPartialTextureUpdate || ranges.size() == 1, ());
123
124 ranges.push_back(pendingNodes.size());
125 for (size_t i = 1; i < ranges.size(); ++i)
126 {
127 size_t startRange = ranges[i - 1];
128 size_t endRange = ranges[i];
129
130 m2::RectU const & startRect = pendingNodes[startRange].m_rect;

Callers

nothing calls this directly

Calls 15

ASSERTFunction · 0.85
NextPowOf2Function · 0.85
make_refFunction · 0.85
backMethod · 0.80
maxXMethod · 0.80
minXMethod · 0.80
minYMethod · 0.80
maxYMethod · 0.80
SizeXMethod · 0.80
SizeYMethod · 0.80
reserveSharedBufferMethod · 0.80
GetRedMethod · 0.80

Tested by

no test coverage detected