Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
SkPDFGraphicState.cpp File Reference
#include "src/pdf/SkPDFGraphicState.h"
#include "include/core/SkData.h"
#include "include/core/SkPaint.h"
#include "include/docs/SkPDFDocument.h"
#include "include/private/base/SkTo.h"
#include "src/pdf/SkPDFDocumentPriv.h"
#include "src/pdf/SkPDFFormXObject.h"
#include "src/pdf/SkPDFUtils.h"

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 18 of file SkPDFGraphicState.cpp.

18 {
19 const char* name = SkPDFUtils::BlendModeName(mode);
21 return name;
22}
#define SkASSERT(cond)
Definition SkAssert.h:116
const char * name
Definition fuchsia.cc:50
const char * BlendModeName(SkBlendMode)

◆ make_invert_function()

static SkPDFIndirectReference make_invert_function ( SkPDFDocument doc)
static

Definition at line 105 of file SkPDFGraphicState.cpp.

105 {
106 // Acrobat crashes if we use a type 0 function, kpdf crashes if we use
107 // a type 2 function, so we use a type 4 function.
108 static const char psInvert[] = "{1 exch sub}";
109 // Do not copy the trailing '\0' into the SkData.
110 auto invertFunction = SkData::MakeWithoutCopy(psInvert, strlen(psInvert));
111
112 std::unique_ptr<SkPDFDict> dict = SkPDFMakeDict();
113 dict->insertInt("FunctionType", 4);
114 dict->insertObject("Domain", SkPDFMakeArray(0, 1));
115 dict->insertObject("Range", SkPDFMakeArray(0, 1));
116 return SkPDFStreamOut(std::move(dict), SkMemoryStream::Make(std::move(invertFunction)), doc);
117}
SkPDFIndirectReference SkPDFStreamOut(std::unique_ptr< SkPDFDict > dict, std::unique_ptr< SkStreamAsset > content, SkPDFDocument *doc, SkPDFSteamCompressionEnabled compress)
static std::unique_ptr< SkPDFDict > SkPDFMakeDict(const char *type=nullptr)
Definition SkPDFTypes.h:195
static std::unique_ptr< SkPDFArray > SkPDFMakeArray(Args... args)
Definition SkPDFTypes.h:135
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 46 of file SkPDFGraphicState.cpp.

46 {
48 || SkBlendMode::kXor == mode
49 || SkBlendMode::kPlus == mode)
50 {
52 }
53 return SkToU8((unsigned)mode);
54}
@ 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
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

◆ to_stroke_cap()

static int to_stroke_cap ( uint8_t  cap)
static

Definition at line 24 of file SkPDFGraphicState.cpp.

24 {
25 // PDF32000.book section 8.4.3.3 "Line Cap Style"
26 switch ((SkPaint::Cap)cap) {
27 case SkPaint::kButt_Cap: return 0;
28 case SkPaint::kRound_Cap: return 1;
29 case SkPaint::kSquare_Cap: return 2;
30 default: SkASSERT(false); return 0;
31 }
32}
@ 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 34 of file SkPDFGraphicState.cpp.

34 {
35 // PDF32000.book section 8.4.3.4 "Line Join Style"
36 switch ((SkPaint::Join)join) {
37 case SkPaint::kMiter_Join: return 0;
38 case SkPaint::kRound_Join: return 1;
39 case SkPaint::kBevel_Join: return 2;
40 default: SkASSERT(false); return 0;
41 }
42}
@ 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