Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Macros | Functions
SkBlitBWMaskTemplate.h File Reference
#include "include/core/SkPixmap.h"
#include "include/core/SkRect.h"
#include "include/private/base/SkAssert.h"
#include "src/core/SkMask.h"
#include <cstddef>
#include <cstdint>

Go to the source code of this file.

Macros

#define ClearLow3Bits(x)   ((unsigned)(x) >> 3 << 3)
 

Functions

static void SK_BLITBWMASK_NAME (const SkPixmap &dstPixmap, const SkMask &srcMask, const SkIRect &clip SK_BLITBWMASK_ARGS)
 

Macro Definition Documentation

◆ ClearLow3Bits

#define ClearLow3Bits (   x)    ((unsigned)(x) >> 3 << 3)

Definition at line 19 of file SkBlitBWMaskTemplate.h.

Function Documentation

◆ SK_BLITBWMASK_NAME()

static void SK_BLITBWMASK_NAME ( const SkPixmap dstPixmap,
const SkMask srcMask,
const SkIRect &clip  SK_BLITBWMASK_ARGS 
)
static

Definition at line 30 of file SkBlitBWMaskTemplate.h.

31 {
32 SkASSERT(clip.fRight <= srcMask.fBounds.fRight);
33
34 int cx = clip.fLeft;
35 int cy = clip.fTop;
36 int maskLeft = srcMask.fBounds.fLeft;
37 unsigned mask_rowBytes = srcMask.fRowBytes;
38 size_t bitmap_rowBytes = dstPixmap.rowBytes();
39 unsigned height = clip.height();
40
41 SkASSERT(mask_rowBytes != 0);
42 SkASSERT(bitmap_rowBytes != 0);
43 SkASSERT(height != 0);
44
45 const uint8_t* bits = srcMask.getAddr1(cx, cy);
46 SK_BLITBWMASK_DEVTYPE* device = dstPixmap.SK_BLITBWMASK_GETADDR(cx, cy);
47
48 if (cx == maskLeft && clip.fRight == srcMask.fBounds.fRight)
49 {
50 do {
52 unsigned rb = mask_rowBytes;
53 do {
54 U8CPU mask = *bits++;
55 SK_BLITBWMASK_BLIT8(mask, dst);
56 dst += 8;
57 } while (--rb != 0);
58 device = (SK_BLITBWMASK_DEVTYPE*)((char*)device + bitmap_rowBytes);
59 } while (--height != 0);
60 }
61 else
62 {
63 int left_edge = cx - maskLeft;
64 SkASSERT(left_edge >= 0);
65 int rite_edge = clip.fRight - maskLeft;
66 SkASSERT(rite_edge > left_edge);
67
68 int left_mask = 0xFF >> (left_edge & 7);
69 int rite_mask = 0xFF << (8 - (rite_edge & 7));
70 rite_mask &= 0xFF; // only want low-8 bits of mask
71 int full_runs = (rite_edge >> 3) - ((left_edge + 7) >> 3);
72
73 // check for empty right mask, so we don't read off the end (or go slower than we need to)
74 if (rite_mask == 0)
75 {
76 SkASSERT(full_runs >= 0);
77 full_runs -= 1;
78 rite_mask = 0xFF;
79 }
80 if (left_mask == 0xFF)
81 full_runs -= 1;
82
83 // back up manually so we can keep in sync with our byte-aligned src
84 // and not trigger an assert from the getAddr## function
85 device -= left_edge & 7;
86
87 if (full_runs < 0)
88 {
89 left_mask &= rite_mask;
90 SkASSERT(left_mask != 0);
91 do {
92 U8CPU mask = *bits & left_mask;
94 bits += mask_rowBytes;
95 device = (SK_BLITBWMASK_DEVTYPE*)((char*)device + bitmap_rowBytes);
96 } while (--height != 0);
97 }
98 else
99 {
100 do {
101 int runs = full_runs;
103 const uint8_t* b = bits;
104 U8CPU mask;
105
106 mask = *b++ & left_mask;
107 SK_BLITBWMASK_BLIT8(mask, dst);
108 dst += 8;
109
110 while (--runs >= 0)
111 {
112 mask = *b++;
113 SK_BLITBWMASK_BLIT8(mask, dst);
114 dst += 8;
115 }
116
117 mask = *b & rite_mask;
118 SK_BLITBWMASK_BLIT8(mask, dst);
119
120 bits += mask_rowBytes;
121 device = (SK_BLITBWMASK_DEVTYPE*)((char*)device + bitmap_rowBytes);
122 } while (--height != 0);
123 }
124 }
125}
#define SkASSERT(cond)
Definition SkAssert.h:116
#define SK_BLITBWMASK_DEVTYPE
#define SK_BLITBWMASK_BLIT8(mask, dst)
unsigned U8CPU
Definition SkCPUTypes.h:18
static SkPoint left_edge(SkPoint pts[4], SkPath::Verb verb, SkScalar weight)
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition SkPath.cpp:3824
size_t rowBytes() const
Definition SkPixmap.h:145
VkDevice device
Definition main.cc:53
static bool b
dst
Definition cp.py:12
int32_t height
int32_t fLeft
smaller x-axis bounds
Definition SkRect.h:33
int32_t fRight
larger x-axis bounds
Definition SkRect.h:35
const uint32_t fRowBytes
Definition SkMask.h:43
const uint8_t * getAddr1(int x, int y) const
Definition SkMask.h:68
const SkIRect fBounds
Definition SkMask.h:42