LCOV - code coverage report
Current view: top level - source/graphics - Overlay.cpp (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 1 30 3.3 %
Date: 2023-01-19 00:18:29 Functions: 2 5 40.0 %

          Line data    Source code
       1             : /* Copyright (C) 2022 Wildfire Games.
       2             :  * This file is part of 0 A.D.
       3             :  *
       4             :  * 0 A.D. is free software: you can redistribute it and/or modify
       5             :  * it under the terms of the GNU General Public License as published by
       6             :  * the Free Software Foundation, either version 2 of the License, or
       7             :  * (at your option) any later version.
       8             :  *
       9             :  * 0 A.D. is distributed in the hope that it will be useful,
      10             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             :  * GNU General Public License for more details.
      13             :  *
      14             :  * You should have received a copy of the GNU General Public License
      15             :  * along with 0 A.D.  If not, see <http://www.gnu.org/licenses/>.
      16             :  */
      17             : 
      18             : #include "precompiled.h"
      19             : 
      20             : #include "Overlay.h"
      21             : 
      22             : #include "graphics/TextureManager.h"
      23             : #include "ps/CStr.h"
      24             : #include "renderer/Renderer.h"
      25             : #include "renderer/TexturedLineRData.h"
      26             : 
      27           0 : SOverlayTexturedLine::LineCapType SOverlayTexturedLine::StrToLineCapType(const std::wstring& str)
      28             : {
      29           0 :     if (str == L"round")
      30           0 :         return LINECAP_ROUND;
      31           0 :     else if (str == L"sharp")
      32           0 :         return LINECAP_SHARP;
      33           0 :     else if (str == L"square")
      34           0 :         return LINECAP_SQUARE;
      35           0 :     else if (str == L"flat")
      36           0 :         return LINECAP_FLAT;
      37             :     else {
      38           0 :         debug_warn(L"[Overlay] Unrecognized line cap type identifier");
      39           0 :         return LINECAP_FLAT;
      40             :     }
      41             : }
      42             : 
      43           0 : void SOverlayTexturedLine::CreateOverlayTexture(const SOverlayDescriptor* overlayDescriptor)
      44             : {
      45           0 :     CTextureProperties texturePropsBase(overlayDescriptor->m_LineTexture.c_str());
      46           0 :     texturePropsBase.SetAddressMode(
      47             :         Renderer::Backend::Sampler::AddressMode::CLAMP_TO_BORDER,
      48             :         Renderer::Backend::Sampler::AddressMode::CLAMP_TO_EDGE);
      49           0 :     texturePropsBase.SetAnisotropicFilter(true);
      50             : 
      51           0 :     CTextureProperties texturePropsMask(overlayDescriptor->m_LineTextureMask.c_str());
      52           0 :     texturePropsMask.SetAddressMode(
      53             :         Renderer::Backend::Sampler::AddressMode::CLAMP_TO_BORDER,
      54             :         Renderer::Backend::Sampler::AddressMode::CLAMP_TO_EDGE);
      55           0 :     texturePropsMask.SetAnisotropicFilter(true);
      56             : 
      57           0 :     m_AlwaysVisible = false;
      58           0 :     m_Closed = true;
      59           0 :     m_Thickness = overlayDescriptor->m_LineThickness;
      60           0 :     m_TextureBase = g_Renderer.GetTextureManager().CreateTexture(texturePropsBase);
      61           0 :     m_TextureMask = g_Renderer.GetTextureManager().CreateTexture(texturePropsMask);
      62             : 
      63           0 :     ENSURE(m_TextureBase);
      64           0 : }
      65             : 
      66           0 : bool SOverlayTexturedLine::IsVisibleInFrustum(const CFrustum& frustum) const
      67             : {
      68             :     // If we don't have render data, we don't have actual bounds and we need
      69             :     // to calculate them on a prerendering stage.
      70           0 :     if (!m_RenderData)
      71           0 :         return true;
      72           0 :     return m_RenderData->IsVisibleInFrustum(frustum);
      73           3 : }

Generated by: LCOV version 1.13