Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
skia_text_raster_policy.hpp
Go to the documentation of this file.
1#pragma once
2
3// SkSurfaceProps for a TextRasterPolicy. Every Skia surface Pulp creates for
4// drawing goes through surface_props_for(), so the policy cannot reach one
5// creation site and miss another.
6
8
9#ifdef PULP_HAS_SKIA
10
11#include "include/core/SkSurfaceProps.h"
12
13#include <cstdint>
14
15namespace pulp::canvas {
16
20inline SkSurfaceProps surface_props_for(TextRasterPolicy policy, std::uint32_t flags = 0,
21 SkPixelGeometry geometry = kUnknown_SkPixelGeometry) {
22 if (policy == TextRasterPolicy::legacy && flags == 0 && geometry == kUnknown_SkPixelGeometry)
23 return SkSurfaceProps();
24 const TextRasterTuple tuple = text_raster_tuple(policy);
25 return SkSurfaceProps(flags, geometry, tuple.contrast, tuple.gamma);
26}
27
30inline TextRasterPolicy text_raster_policy_of(const SkSurfaceProps& props) {
31 return props.textContrast() == kChromiumTextRaster.contrast &&
32 props.textGamma() == kChromiumTextRaster.gamma
35}
36
37} // namespace pulp::canvas
38
39#endif // PULP_HAS_SKIA
Definition affine_transform.hpp:24
constexpr TextRasterTuple kChromiumTextRaster
Definition text_raster_policy.hpp:56
constexpr TextRasterTuple text_raster_tuple(TextRasterPolicy policy)
Definition text_raster_policy.hpp:58
TextRasterPolicy
Glyph preblend a surface is created with.
Definition text_raster_policy.hpp:33
@ legacy
Definition text_raster_policy.hpp:34
@ chromium
Definition text_raster_policy.hpp:35
Surface text contrast and gamma for a policy, the two values SkSurfaceProps carries.
Definition text_raster_policy.hpp:49