Flutter Engine
The Flutter Engine
SDFMaskFilter.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2018 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
9
12#include "include/core/SkRect.h"
14#include "src/core/SkMask.h"
16
17class SkMatrix;
18class SkReadBuffer;
19
20#if !defined(SK_DISABLE_SDF_TEXT)
21
22namespace sktext::gpu {
23
25public:
27
28 // overrides from SkMaskFilterBase
29 // This method is not exported to java.
30 SkMask::Format getFormat() const override;
31 // This method is not exported to java.
32 bool filterMask(SkMaskBuilder* dst, const SkMask& src, const SkMatrix&,
33 SkIPoint* margin) const override;
35 void computeFastBounds(const SkRect&, SkRect*) const override;
36
37private:
39};
40
41///////////////////////////////////////////////////////////////////////////////
42
44
47}
48
50 const SkMatrix& matrix, SkIPoint* margin) const {
51 if (src.fFormat != SkMask::kA8_Format
52 && src.fFormat != SkMask::kBW_Format
53 && src.fFormat != SkMask::kLCD16_Format) {
54 return false;
55 }
56
58 dst->format() = SkMask::kSDF_Format;
59
60 if (margin) {
62 }
63
64 if (src.fImage == nullptr) {
65 return true;
66 }
67 if (dst->fImage == nullptr) {
68 dst->bounds().setEmpty();
69 return false;
70 }
71
72 if (src.fFormat == SkMask::kA8_Format) {
73 return SkGenerateDistanceFieldFromA8Image(dst->image(), src.fImage,
74 src.fBounds.width(), src.fBounds.height(),
75 src.fRowBytes);
76 } else if (src.fFormat == SkMask::kLCD16_Format) {
77 return SkGenerateDistanceFieldFromLCD16Mask(dst->image(), src.fImage,
78 src.fBounds.width(), src.fBounds.height(),
79 src.fRowBytes);
80 } else {
81 return SkGenerateDistanceFieldFromBWImage(dst->image(), src.fImage,
82 src.fBounds.width(), src.fBounds.height(),
83 src.fRowBytes);
84 }
85}
86
88 SkRect* dst) const {
89 dst->setLTRB(src.fLeft - SK_DistanceFieldPad, src.fTop - SK_DistanceFieldPad,
91}
92
93sk_sp<SkFlattenable> SDFMaskFilterImpl::CreateProc(SkReadBuffer& buffer) {
94 return SDFMaskFilter::Make();
95}
96
97///////////////////////////////////////////////////////////////////////////////
98
101}
102
103} // namespace sktext::gpu
104
105#endif // !defined(SK_DISABLE_SDF_TEXT)
bool SkGenerateDistanceFieldFromBWImage(unsigned char *distanceField, const unsigned char *image, int width, int height, size_t rowBytes)
bool SkGenerateDistanceFieldFromA8Image(unsigned char *distanceField, const unsigned char *image, int width, int height, size_t rowBytes)
bool SkGenerateDistanceFieldFromLCD16Mask(unsigned char *distanceField, const unsigned char *image, int w, int h, size_t rowBytes)
#define SK_DistanceFieldPad
#define SK_FLATTENABLE_HOOKS(type)
void computeFastBounds(const SkRect &, SkRect *) const override
SkMask::Format getFormat() const override
bool filterMask(SkMaskBuilder *dst, const SkMask &src, const SkMatrix &, SkIPoint *margin) const override
SkMaskFilterBase::Type type() const override
static sk_sp< SkMaskFilter > Make()
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
dst
Definition: cp.py:12
void set(int32_t x, int32_t y)
Definition: SkPoint_impl.h:65
static SkMaskBuilder PrepareDestination(int radiusX, int radiusY, const SkMask &src)
Definition: SkMask.cpp:61
Definition: SkMask.h:25
Format
Definition: SkMask.h:26
@ kA8_Format
8bits per pixel mask (e.g. antialiasing)
Definition: SkMask.h:28
@ kLCD16_Format
565 alpha for r/g/b
Definition: SkMask.h:31
@ kSDF_Format
8bits representing signed distance field
Definition: SkMask.h:32
@ kBW_Format
1bit per pixel mask (e.g. monochrome)
Definition: SkMask.h:27