Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
SkLatticeIter.cpp File Reference
#include "src/core/SkLatticeIter.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkRect.h"
#include "include/private/base/SkAssert.h"
#include "include/private/base/SkTo.h"
#include <cstdint>

Go to the source code of this file.

Functions

static bool valid_divs (const int *divs, int count, int start, int end)
 
static int count_scalable_pixels (const int32_t *divs, int numDivs, bool firstIsScalable, int start, int end)
 
static void set_points (float *dst, int *src, const int *divs, int divCount, int srcFixed, int srcScalable, int srcStart, int srcEnd, float dstStart, float dstEnd, bool isScalable)
 

Function Documentation

◆ count_scalable_pixels()

static int count_scalable_pixels ( const int32_t *  divs,
int  numDivs,
bool  firstIsScalable,
int  start,
int  end 
)
static

Count the number of pixels that are in "scalable" patches.

Definition at line 55 of file SkLatticeIter.cpp.

56 {
57 if (0 == numDivs) {
58 return firstIsScalable ? end - start : 0;
59 }
60
61 int i;
62 int count;
63 if (firstIsScalable) {
64 count = divs[0] - start;
65 i = 1;
66 } else {
67 count = 0;
68 i = 0;
69 }
70
71 for (; i < numDivs; i += 2) {
72 // Alternatively, we could use |top| and |bottom| as variable names, instead of
73 // |left| and |right|.
74 int left = divs[i];
75 int right = (i + 1 < numDivs) ? divs[i + 1] : end;
76 count += right - left;
77 }
78
79 return count;
80}
int count
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool right(const SkPoint &p0, const SkPoint &p1)
glong glong end

◆ set_points()

static void set_points ( float *  dst,
int src,
const int divs,
int  divCount,
int  srcFixed,
int  srcScalable,
int  srcStart,
int  srcEnd,
float  dstStart,
float  dstEnd,
bool  isScalable 
)
static

Set points for the src and dst rects on subsequent draw calls.

Definition at line 85 of file SkLatticeIter.cpp.

87 {
88 float dstLen = dstEnd - dstStart;
89 float scale;
90 if (srcFixed <= dstLen) {
91 // This is the "normal" case, where we scale the "scalable" patches and leave
92 // the other patches fixed.
93 scale = (dstLen - ((float) srcFixed)) / ((float) srcScalable);
94 } else {
95 // In this case, we eliminate the "scalable" patches and scale the "fixed" patches.
96 scale = dstLen / ((float) srcFixed);
97 }
98
99 src[0] = srcStart;
100 dst[0] = dstStart;
101 for (int i = 0; i < divCount; i++) {
102 src[i + 1] = divs[i];
103 int srcDelta = src[i + 1] - src[i];
104 float dstDelta;
105 if (srcFixed <= dstLen) {
106 dstDelta = isScalable ? scale * srcDelta : srcDelta;
107 } else {
108 dstDelta = isScalable ? 0.0f : scale * srcDelta;
109 }
110 dst[i + 1] = dst[i] + dstDelta;
111
112 // Alternate between "scalable" and "fixed" patches.
113 isScalable = !isScalable;
114 }
115
116 src[divCount + 1] = srcEnd;
117 dst[divCount + 1] = dstEnd;
118}
dst
Definition cp.py:12
const Scalar scale

◆ valid_divs()

static bool valid_divs ( const int divs,
int  count,
int  start,
int  end 
)
static

Divs must be in increasing order with no duplicates.

Definition at line 20 of file SkLatticeIter.cpp.

20 {
21 int prev = start - 1;
22 for (int i = 0; i < count; i++) {
23 if (prev >= divs[i] || divs[i] >= end) {
24 return false;
25 }
26 prev = divs[i];
27 }
28
29 return true;
30}
static float prev(float f)