Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkAlphaRuns.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2006 The Android Open Source Project
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
8
9#include "src/core/SkMemset.h"
10
12 SkASSERT(width > 0);
13
14#ifdef SK_DEBUG
15 SkOpts::memset16((uint16_t*)fRuns, (uint16_t)(-42), width);
16#endif
17 fRuns[0] = SkToS16(width);
18 fRuns[width] = 0;
19 fAlpha[0] = 0;
20
21 SkDEBUGCODE(fWidth = width;)
22 SkDEBUGCODE(this->validate();)
23}
24
25#ifdef SK_DEBUG
26 void SkAlphaRuns::assertValid(int y, int maxStep) const {
27 int max = (y + 1) * maxStep - (y == maxStep - 1);
28
29 const int16_t* runs = fRuns;
30 const uint8_t* alpha = fAlpha;
31
32 while (*runs) {
33 SkASSERT(*alpha <= max);
34 alpha += *runs;
35 runs += *runs;
36 }
37 }
38
39 void SkAlphaRuns::dump() const {
40 const int16_t* runs = fRuns;
41 const uint8_t* alpha = fAlpha;
42
43 SkDebugf("Runs");
44 while (*runs) {
45 int n = *runs;
46
47 SkDebugf(" %02x", *alpha);
48 if (n > 1) {
49 SkDebugf(",%d", n);
50 }
51 alpha += n;
52 runs += n;
53 }
54 SkDebugf("\n");
55 }
56
57 void SkAlphaRuns::validate() const {
58 SkASSERT(fWidth > 0);
59
60 int count = 0;
61 const int16_t* runs = fRuns;
62
63 while (*runs) {
64 SkASSERT(*runs > 0);
65 count += *runs;
66 SkASSERT(count <= fWidth);
67 runs += *runs;
68 }
69 SkASSERT(count == fWidth);
70 }
71#endif
int count
#define SkASSERT(cond)
Definition SkAssert.h:116
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
#define SkDEBUGCODE(...)
Definition SkDebug.h:23
constexpr int16_t SkToS16(S x)
Definition SkTo.h:23
uint8_t * fAlpha
Definition SkAlphaRuns.h:27
void reset(int width)
Reinitialize for a new scanline.
int16_t * fRuns
Definition SkAlphaRuns.h:26
static float max(float r, float g, float b)
Definition hsl.cpp:49
double y
void(* memset16)(uint16_t[], uint16_t, int)
int32_t width