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

Method DrawRuler

libs/drape_frontend/gui/ruler.cpp:190–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

188}
189
190void Ruler::DrawRuler(ref_ptr<dp::GraphicsContext> context, ShapeControl & control, ref_ptr<dp::TextureManager> tex,
191 bool isAppearing) const
192{
193 buffer_vector<RulerVertex, 4> data;
194
195 dp::TextureManager::ColorRegion reg;
196 tex->GetColorRegion(DrapeGui::GetGuiTextFont().m_color, reg);
197
198 glsl::vec2 texCoord = glsl::ToVec2(reg.GetTexRect().Center());
199 float const h = RulerHelper::GetRulerHalfHeight();
200
201 glsl::vec2 normals[] = {
202 glsl::vec2(-1.0, 0.0),
203 glsl::vec2(1.0, 0.0),
204 };
205
206 dp::Anchor anchor = m_position.m_anchor;
207 if (anchor & dp::Left)
208 normals[0] = glsl::vec2(0.0, 0.0);
209 else if (anchor & dp::Right)
210 normals[1] = glsl::vec2(0.0, 0.0);
211
212 data.push_back(RulerVertex(glsl::vec2(0.0, h), normals[0], texCoord));
213 data.push_back(RulerVertex(glsl::vec2(0.0, -h), normals[0], texCoord));
214 data.push_back(RulerVertex(glsl::vec2(0.0, h), normals[1], texCoord));
215 data.push_back(RulerVertex(glsl::vec2(0.0, -h), normals[1], texCoord));
216
217 auto state = df::CreateRenderState(gpu::Program::Ruler, df::DepthLayer::GuiLayer);
218 state.SetColorTexture(reg.GetTexture());
219 state.SetDepthTestEnabled(false);
220
221 dp::AttributeProvider provider(1, 4);
222 provider.InitStream(0, GetBindingInfo(), make_ref(data.data()));
223
224 {
225 dp::Batcher batcher(dp::Batcher::IndexPerQuad, dp::Batcher::VertexPerQuad);
226 batcher.SetBatcherHash(static_cast<uint64_t>(df::BatcherBucket::Default));
227 dp::SessionGuard guard(context, batcher, std::bind(&ShapeControl::AddShape, &control, _1, _2));
228 batcher.InsertTriangleStrip(context, state, make_ref(&provider),
229 make_unique_dp<RulerHandle>(EGuiHandle::GuiHandleRuler, m_position.m_anchor,
230 m_position.m_pixelPivot, isAppearing));
231 }
232}
233
234void Ruler::DrawText(ref_ptr<dp::GraphicsContext> context, ShapeControl & control, ref_ptr<dp::TextureManager> tex,
235 bool isAppearing) const

Callers

nothing calls this directly

Calls 15

ToVec2Function · 0.85
vec2Class · 0.85
RulerVertexClass · 0.85
CreateRenderStateFunction · 0.85
GetBindingInfoFunction · 0.85
make_refFunction · 0.85
GetColorRegionMethod · 0.80
SetColorTextureMethod · 0.80
InitStreamMethod · 0.80
SetBatcherHashMethod · 0.80
InsertTriangleStripMethod · 0.80
CenterMethod · 0.45

Tested by

no test coverage detected