Flutter Engine
The Flutter Engine
Functions
SkPDFGraphicState.cpp File Reference
#include "src/pdf/SkPDFGraphicState.h"
#include "include/core/SkBlendMode.h"
#include "include/core/SkColor.h"
#include "include/core/SkData.h"
#include "include/core/SkPaint.h"
#include "include/core/SkStream.h"
#include "include/private/base/SkAssert.h"
#include "include/private/base/SkTo.h"
#include "src/core/SkTHash.h"
#include "src/pdf/SkPDFDocumentPriv.h"
#include "src/pdf/SkPDFUtils.h"
#include <memory>
#include <utility>

Go to the source code of this file.

Functions

static const char * as_pdf_blend_mode_name (SkBlendMode mode)
 
static int to_stroke_cap (uint8_t cap)
 
static int to_stroke_join (uint8_t join)
 
static uint8_t pdf_blend_mode (SkBlendMode mode)
 
static SkPDFIndirectReference make_invert_function (SkPDFDocument *doc)
 

Function Documentation

◆ as_pdf_blend_mode_name()

static const char * as_pdf_blend_mode_name ( SkBlendMode  mode)
static

Definition at line 24 of file SkPDFGraphicState.cpp.

24 {
25 const char* name = SkPDFUtils::BlendModeName(mode);
27 return name;
28}
#define SkASSERT(cond)
Definition: SkAssert.h:116
const char * BlendModeName(SkBlendMode)
Definition: SkPDFUtils.cpp:37
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition: switches.h:228

◆ make_invert_function()

static SkPDFIndirectReference make_invert_function ( SkPDFDocument doc)
static

Definition at line 111 of file SkPDFGraphicState.cpp.

111 {
112 // Acrobat crashes if we use a type 0 function, kpdf crashes if we use
113 // a type 2 function, so we use a type 4 function.
114 static const char psInvert[] = "{1 exch sub}";
115 // Do not copy the trailing '\0' into the SkData.
116 auto invertFunction = SkData::MakeWithoutCopy(psInvert, strlen(psInvert));
117
118 std::unique_ptr<SkPDFDict> dict = SkPDFMakeDict();
119 dict->insertInt("FunctionType", 4);
120 dict->insertObject("Domain", SkPDFMakeArray(0, 1));
121 dict->insertObject("Range", SkPDFMakeArray(0, 1));
122 return SkPDFStreamOut(std::move(dict), SkMemoryStream::Make(std::move(invertFunction)), doc);
123}
SkPDFIndirectReference SkPDFStreamOut(std::unique_ptr< SkPDFDict > dict, std::unique_ptr< SkStreamAsset > content, SkPDFDocument *doc, SkPDFSteamCompressionEnabled compress)
Definition: SkPDFTypes.cpp:591
static std::unique_ptr< SkPDFDict > SkPDFMakeDict(const char *type=nullptr)
Definition: SkPDFTypes.h:185
static std::unique_ptr< SkPDFArray > SkPDFMakeArray(Args... args)
Definition: SkPDFTypes.h:125
static sk_sp< SkData > MakeWithoutCopy(const void *data, size_t length)
Definition: SkData.h:116
static std::unique_ptr< SkMemoryStream > Make(sk_sp< SkData > data)
Definition: SkStream.cpp:314

◆ pdf_blend_mode()

static uint8_t pdf_blend_mode ( SkBlendMode  mode)
static

Definition at line 52 of file SkPDFGraphicState.cpp.

52 {
56 {
58 }
59 return SkToU8((unsigned)mode);
60}
@ kPlus
r = min(s + d, 1)
@ kSrcOver
r = s + (1-sa)*d
@ kXor
r = s*(1-da) + d*(1-sa)
constexpr uint8_t SkToU8(S x)
Definition: SkTo.h:22

◆ to_stroke_cap()

static int to_stroke_cap ( uint8_t  cap)
static

Definition at line 30 of file SkPDFGraphicState.cpp.

30 {
31 // PDF32000.book section 8.4.3.3 "Line Cap Style"
32 switch ((SkPaint::Cap)cap) {
33 case SkPaint::kButt_Cap: return 0;
34 case SkPaint::kRound_Cap: return 1;
35 case SkPaint::kSquare_Cap: return 2;
36 default: SkASSERT(false); return 0;
37 }
38}
@ kRound_Cap
adds circle
Definition: SkPaint.h:335
@ kButt_Cap
no stroke extension
Definition: SkPaint.h:334
@ kSquare_Cap
adds square
Definition: SkPaint.h:336

◆ to_stroke_join()

static int to_stroke_join ( uint8_t  join)
static

Definition at line 40 of file SkPDFGraphicState.cpp.

40 {
41 // PDF32000.book section 8.4.3.4 "Line Join Style"
42 switch ((SkPaint::Join)join) {
43 case SkPaint::kMiter_Join: return 0;
44 case SkPaint::kRound_Join: return 1;
45 case SkPaint::kBevel_Join: return 2;
46 default: SkASSERT(false); return 0;
47 }
48}
@ kRound_Join
adds circle
Definition: SkPaint.h:360
@ kMiter_Join
extends to miter limit
Definition: SkPaint.h:359
@ kBevel_Join
connects outside edges
Definition: SkPaint.h:361
static SkString join(const CommandLineFlags::StringArray &)
Definition: skpbench.cpp:741