Small refactoring of dp::Color usage

This commit is contained in:
r.kuznetsov 2017-02-02 11:54:15 +03:00
parent ff528b073e
commit 2f6f50201a
6 changed files with 31 additions and 14 deletions

View file

@ -445,8 +445,7 @@ void ApplyPointFeature::ProcessRule(Stylist::TRuleWrapper const & rule)
params.m_primaryOptional = false;
params.m_primaryTextFont.m_size *= 1.2;
auto const style = GetStyleReader().GetCurrentStyle();
params.m_primaryTextFont.m_outlineColor = (style == MapStyle::MapStyleDark) ?
dp::Color(0, 0, 0, 153) : dp::Color(255, 255, 255, 153);
params.m_primaryTextFont.m_outlineColor = df::GetColorConstant(style, df::PoiHotelTextOutline);
params.m_secondaryTextFont = params.m_primaryTextFont;
params.m_secondaryText = ExtractHotelInfo();
params.m_secondaryOptional = false;

View file

@ -132,23 +132,26 @@ void Arrow3d::Render(ScreenBase const & screen, ref_ptr<dp::GpuProgramManager> m
m_isInitialized = true;
}
auto const & style = GetStyleReader().GetCurrentStyle();
// Render shadow.
if (screen.isPerspective())
{
ref_ptr<dp::GpuProgram> shadowProgram = mng->GetProgram(gpu::ARROW_3D_SHADOW_PROGRAM);
RenderArrow(screen, shadowProgram, dp::Color(60, 60, 60, 60), 0.05f /* dz */,
RenderArrow(screen, shadowProgram, df::GetColorConstant(style, df::Arrow3DShadow), 0.05f /* dz */,
routingMode ? kOutlineScale : 1.0f /* scaleFactor */, false /* hasNormals */);
}
dp::Color const color = df::GetColorConstant(GetStyleReader().GetCurrentStyle(),
m_obsoletePosition ? df::Arrow3DObsolete : df::Arrow3D);
dp::Color const color = df::GetColorConstant(style, m_obsoletePosition ? df::Arrow3DObsolete : df::Arrow3D);
// Render outline.
if (routingMode)
{
dp::Color const outlineColor = df::GetColorConstant(style, df::Arrow3DOutline);
ref_ptr<dp::GpuProgram> outlineProgram = mng->GetProgram(gpu::ARROW_3D_OUTLINE_PROGRAM);
RenderArrow(screen, outlineProgram, dp::Color(255, 255, 255, color.GetAlfa()), 0.0f /* dz */,
kOutlineScale /* scaleFactor */, false /* hasNormals */);
RenderArrow(screen, outlineProgram,
dp::Color(outlineColor.GetRed(), outlineColor.GetGreen(), outlineColor.GetBlue(), color.GetAlfa()),
0.0f /* dz */, kOutlineScale /* scaleFactor */, false /* hasNormals */);
}
// Render arrow.

View file

@ -25,6 +25,8 @@ unordered_map<int, unordered_map<int, dp::Color>> kColorConstants =
{ RouteBicycle, dp::Color(156, 39, 176, 204) },
{ Arrow3D, dp::Color(80, 170, 255, 255) },
{ Arrow3DObsolete, dp::Color(130, 170, 200, 183) },
{ Arrow3DShadow, dp::Color(60, 60, 60, 60) },
{ Arrow3DOutline, dp::Color(255, 255, 255, 255) },
{ TrackHumanSpeed, dp::Color(29, 51, 158, 255) },
{ TrackCarSpeed, dp::Color(21, 121, 244, 255) },
{ TrackPlaneSpeed, dp::Color(10, 196, 255, 255) },
@ -49,6 +51,8 @@ unordered_map<int, unordered_map<int, dp::Color>> kColorConstants =
{ RoadShieldUKGreenText, dp::Color(255, 204, 102, 255) },
{ RoadShieldBlueBackground, dp::Color(46, 111, 201, 255) },
{ RoadShieldGreenBackground, dp::Color(34, 114, 59, 255) },
{ PoiHotelTextOutline, dp::Color(255, 255, 255, 153) },
{ PoiDeletedMask, dp::Color(255, 255, 255, 76) },
}
},
{ MapStyleDark,
@ -66,6 +70,8 @@ unordered_map<int, unordered_map<int, dp::Color>> kColorConstants =
{ RouteBicycle, dp::Color(255, 75, 140, 180) },
{ Arrow3D, dp::Color(65, 200, 255, 255) },
{ Arrow3DObsolete, dp::Color(130, 170, 200, 183) },
{ Arrow3DShadow, dp::Color(60, 60, 60, 60) },
{ Arrow3DOutline, dp::Color(255, 255, 255, 255) },
{ TrackHumanSpeed, dp::Color(255, 152, 0, 255) },
{ TrackCarSpeed, dp::Color(255, 202, 40, 255) },
{ TrackPlaneSpeed, dp::Color(255, 245, 160, 255) },
@ -90,6 +96,8 @@ unordered_map<int, unordered_map<int, dp::Color>> kColorConstants =
{ RoadShieldUKGreenText, dp::Color(255, 204, 102, 255) },
{ RoadShieldBlueBackground, dp::Color(46, 111, 201, 255) },
{ RoadShieldGreenBackground, dp::Color(34, 114, 59, 255) },
{ PoiHotelTextOutline, dp::Color(0, 0, 0, 153) },
{ PoiDeletedMask, dp::Color(255, 255, 255, 76) },
}
},
};

View file

@ -22,6 +22,8 @@ enum ColorConstant
RouteBicycle,
Arrow3D,
Arrow3DObsolete,
Arrow3DShadow,
Arrow3DOutline,
TrackHumanSpeed,
TrackCarSpeed,
TrackPlaneSpeed,
@ -46,6 +48,8 @@ enum ColorConstant
RoadShieldUKGreenText,
RoadShieldBlueBackground,
RoadShieldGreenBackground,
PoiHotelTextOutline,
PoiDeletedMask
};
dp::Color GetColorConstant(MapStyle style, ColorConstant constant);

View file

@ -1,5 +1,7 @@
#include "drape_frontend/poi_symbol_shape.hpp"
#include "drape_frontend/color_constants.hpp"
#include "drape/utils/vertex_decl.hpp"
#include "drape/attribute_provider.hpp"
#include "drape/batcher.hpp"
@ -8,11 +10,11 @@
#include "drape/shader_def.hpp"
#include "indexer/map_style_reader.hpp"
namespace
{
dp::Color const kDeletedColorMask = dp::Color(255, 255, 255, 76);
using SV = gpu::SolidTexturingVertex;
using MV = gpu::MaskedTexturingVertex;
@ -128,8 +130,9 @@ void PoiSymbolShape::Draw(ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManag
if (m_params.m_obsoleteInEditor)
{
dp::Color const mask = df::GetColorConstant(GetStyleReader().GetCurrentStyle(), df::PoiDeletedMask);
dp::TextureManager::ColorRegion maskColorRegion;
textures->GetColorRegion(kDeletedColorMask, maskColorRegion);
textures->GetColorRegion(mask, maskColorRegion);
Batch<MV>(batcher, move(handle), position, region, maskColorRegion);
}
else

View file

@ -65,8 +65,8 @@ struct TextViewParams : CommonViewParams
dp::FontDecl m_secondaryTextFont;
string m_secondaryText;
dp::Anchor m_anchor;
m2::PointF m_primaryOffset;
m2::PointF m_secondaryOffset;
m2::PointF m_primaryOffset = m2::PointF(0.0f, 0.0f);
m2::PointF m_secondaryOffset = m2::PointF(0.0f, 0.0f);
bool m_primaryOptional = false;
bool m_secondaryOptional = false;
bool m_hasArea = false;
@ -74,7 +74,7 @@ struct TextViewParams : CommonViewParams
uint32_t m_extendingSize = 0;
float m_posZ = 0.0f;
bool m_limitedText = false;
m2::PointF m_limits;
m2::PointF m_limits = m2::PointF(0.0f, 0.0f);
};
struct PathTextViewParams : CommonViewParams
@ -106,7 +106,7 @@ struct ColoredSymbolViewParams : CommonViewParams
dp::Color m_color;
dp::Color m_outlineColor;
float m_radiusInPixels = 0.0f;
m2::PointF m_sizeInPixels;
m2::PointF m_sizeInPixels = m2::PointF(0.0f, 0.0f);
float m_outlineWidth = 0.0f;
};