| Flutter Impeller |

skia_conversions.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "impeller/display_list/skia_conversions.h"
6 #include "flutter/display_list/dl_blend_mode.h"
7 #include "flutter/display_list/dl_color.h"
8 #include "third_party/skia/modules/skparagraph/include/Paragraph.h"
9
10 namespace impeller {
11 namespace skia_conversions {
12
13 Color ToColor(const flutter::DlColor& color) {
14 FML_DCHECK(color.getColorSpace() == flutter::DlColorSpace::kExtendedSRGB ||
15 color.getColorSpace() == flutter::DlColorSpace::kSRGB);
16 return {
17 static_cast<Scalar>(color.getRedF()), //
18 static_cast<Scalar>(color.getGreenF()), //
19 static_cast<Scalar>(color.getBlueF()), //
20 static_cast<Scalar>(color.getAlphaF()) //
21 };
22 }
23
24 impeller::SamplerDescriptor ToSamplerDescriptor(
25 const flutter::DlImageSampling options) {
26 impeller::SamplerDescriptor desc;
27 switch (options) {
28 case flutter::DlImageSampling::kNearestNeighbor:
29 desc.min_filter = desc.mag_filter = impeller::MinMagFilter::kNearest;
30 desc.mip_filter = impeller::MipFilter::kBase;
31 desc.label = "Nearest Sampler";
32 break;
33 case flutter::DlImageSampling::kLinear:
34 desc.min_filter = desc.mag_filter = impeller::MinMagFilter::kLinear;
35 desc.mip_filter = impeller::MipFilter::kBase;
36 desc.label = "Linear Sampler";
37 break;
38 case flutter::DlImageSampling::kCubic:
39 case flutter::DlImageSampling::kMipmapLinear:
40 desc.min_filter = desc.mag_filter = impeller::MinMagFilter::kLinear;
41 desc.mip_filter = impeller::MipFilter::kLinear;
42 desc.label = "Mipmap Linear Sampler";
43 break;
44 }
45 return desc;
46 }
47
48 } // namespace skia_conversions
49 } // namespace impeller
impeller::skia_conversions::ToSamplerDescriptor
impeller::SamplerDescriptor ToSamplerDescriptor(const flutter::DlImageSampling options)
Definition: skia_conversions.cc:24
impeller::skia_conversions::ToColor
Color ToColor(const flutter::DlColor &color)
Definition: skia_conversions.cc:13
impeller
Definition: allocation.cc:12
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::MipFilter::kLinear
@ kLinear
Sample from the two nearest mip levels and linearly interpolate.
impeller::MipFilter::kBase
@ kBase
The texture is sampled as if it only had a single mipmap level.
impeller::MinMagFilter::kLinear
@ kLinear
impeller::MinMagFilter::kNearest
@ kNearest
Select nearest to the sample point. Most widely supported.
skia_conversions.h
impeller::Color
Definition: color.h:124
impeller::SamplerDescriptor
Definition: sampler_descriptor.h:14
impeller::SamplerDescriptor::mip_filter
MipFilter mip_filter
Definition: sampler_descriptor.h:17
impeller::SamplerDescriptor::mag_filter
MinMagFilter mag_filter
Definition: sampler_descriptor.h:16
impeller::SamplerDescriptor::label
std::string_view label
Definition: sampler_descriptor.h:23
impeller::SamplerDescriptor::min_filter
MinMagFilter min_filter
Definition: sampler_descriptor.h:15