#include "include/core/SkRegion.h"
#include "include/private/base/SkMacros.h"
#include "include/private/base/SkMalloc.h"
#include "include/private/base/SkMath.h"
#include "include/private/base/SkTemplates.h"
#include "include/private/base/SkTo.h"
#include "src/base/SkBuffer.h"
#include "src/base/SkSafeMath.h"
#include "src/core/SkRegionPriv.h"
#include <algorithm>
#include <atomic>
#include <cstring>
#include <functional>
usingnamespaceskia_private;
#define SkRegion_gEmptyRunHeadPtr …
#define SkRegion_gRectRunHeadPtr …
constexpr int kRunArrayStackCount = …;
class RunArray { … };
static SkRegionPriv::RunType* skip_intervals(const SkRegionPriv::RunType runs[]) { … }
bool SkRegion::RunsAreARect(const SkRegion::RunType runs[], int count,
SkIRect* bounds) { … }
SkRegion::SkRegion() { … }
SkRegion::SkRegion(const SkRegion& src) { … }
SkRegion::SkRegion(const SkIRect& rect) { … }
SkRegion::~SkRegion() { … }
void SkRegion::freeRuns() { … }
void SkRegion::allocateRuns(int count, int ySpanCount, int intervalCount) { … }
void SkRegion::allocateRuns(int count) { … }
void SkRegion::allocateRuns(const RunHead& head) { … }
SkRegion& SkRegion::operator=(const SkRegion& src) { … }
void SkRegion::swap(SkRegion& other) { … }
int SkRegion::computeRegionComplexity() const { … }
bool SkRegion::setEmpty() { … }
bool SkRegion::setRect(const SkIRect& r) { … }
bool SkRegion::setRegion(const SkRegion& src) { … }
bool SkRegion::op(const SkIRect& rect, const SkRegion& rgn, Op op) { … }
bool SkRegion::op(const SkRegion& rgn, const SkIRect& rect, Op op) { … }
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
#include <stdio.h>
char* SkRegion::toString() {
Iterator iter(*this);
int count = 0;
while (!iter.done()) {
count++;
iter.next();
}
const int max = (count*((11*4)+5))+11+1;
char* result = (char*)sk_malloc_throw(max);
if (result == nullptr) {
return nullptr;
}
count = snprintf(result, max, "SkRegion(");
iter.reset(*this);
while (!iter.done()) {
const SkIRect& r = iter.rect();
count += snprintf(result+count, max - count,
"(%d,%d,%d,%d)", r.fLeft, r.fTop, r.fRight, r.fBottom);
iter.next();
}
count += snprintf(result+count, max - count, ")");
return result;
}
#endif
int SkRegion::count_runtype_values(int* itop, int* ibot) const { … }
static bool isRunCountEmpty(int count) { … }
bool SkRegion::setRuns(RunType runs[], int count) { … }
void SkRegion::BuildRectRuns(const SkIRect& bounds,
RunType runs[kRectRegionRuns]) { … }
bool SkRegion::contains(int32_t x, int32_t y) const { … }
static SkRegionPriv::RunType scanline_bottom(const SkRegionPriv::RunType runs[]) { … }
static const SkRegionPriv::RunType* scanline_next(const SkRegionPriv::RunType runs[]) { … }
static bool scanline_contains(const SkRegionPriv::RunType runs[],
SkRegionPriv::RunType L, SkRegionPriv::RunType R) { … }
bool SkRegion::contains(const SkIRect& r) const { … }
bool SkRegion::contains(const SkRegion& rgn) const { … }
const SkRegion::RunType* SkRegion::getRuns(RunType tmpStorage[],
int* intervals) const { … }
static bool scanline_intersects(const SkRegionPriv::RunType runs[],
SkRegionPriv::RunType L, SkRegionPriv::RunType R) { … }
bool SkRegion::intersects(const SkIRect& r) const { … }
bool SkRegion::intersects(const SkRegion& rgn) const { … }
bool SkRegion::operator==(const SkRegion& b) const { … }
static int32_t pin_offset_s32(int32_t min, int32_t max, int32_t offset) { … }
void SkRegion::translate(int dx, int dy, SkRegion* dst) const { … }
bool SkRegion::setRects(const SkIRect rects[], int count) { … }
#if defined _WIN32
#pragma warning ( push )
#pragma warning ( disable : 4701 )
#endif
#ifdef SK_DEBUG
static void assert_valid_pair(int left, int rite)
{ … }
#else
#define assert_valid_pair …
#endif
struct spanRec { … };
static int distance_to_sentinel(const SkRegionPriv::RunType* runs) { … }
static int operate_on_span(const SkRegionPriv::RunType a_runs[],
const SkRegionPriv::RunType b_runs[],
RunArray* array, int dstOffset,
int min, int max) { … }
#if defined _WIN32
#pragma warning ( pop )
#endif
static const struct { … } gOpMinMax[] = …;
static_assert …;
static_assert …;
static_assert …;
static_assert …;
class RgnOper { … };
#define QUICK_EXIT_TRUE_COUNT …
static int operate(const SkRegionPriv::RunType a_runs[],
const SkRegionPriv::RunType b_runs[],
RunArray* dst,
SkRegion::Op op,
bool quickExit) { … }
#if 0
static int count_to_intervals(int count) {
SkASSERT(count >= 6);
return (count - 4) >> 1;
}
#endif
static bool setEmptyCheck(SkRegion* result) { … }
static bool setRectCheck(SkRegion* result, const SkIRect& rect) { … }
static bool setRegionCheck(SkRegion* result, const SkRegion& rgn) { … }
bool SkRegion::Oper(const SkRegion& rgnaOrig, const SkRegion& rgnbOrig, Op op,
SkRegion* result) { … }
bool SkRegion::op(const SkRegion& rgna, const SkRegion& rgnb, Op op) { … }
size_t SkRegion::writeToMemory(void* storage) const { … }
static bool validate_run_count(int ySpanCount, int intervalCount, int runCount) { … }
static bool validate_run(const int32_t* runs,
int runCount,
const SkIRect& givenBounds,
int32_t ySpanCount,
int32_t intervalCount) { … }
size_t SkRegion::readFromMemory(const void* storage, size_t length) { … }
bool SkRegion::isValid() const { … }
#ifdef SK_DEBUG
void SkRegionPriv::Validate(const SkRegion& rgn) { … }
void SkRegion::dump() const { … }
#endif
SkRegion::Iterator::Iterator(const SkRegion& rgn) { … }
bool SkRegion::Iterator::rewind() { … }
void SkRegion::Iterator::reset(const SkRegion& rgn) { … }
void SkRegion::Iterator::next() { … }
SkRegion::Cliperator::Cliperator(const SkRegion& rgn, const SkIRect& clip)
: … { … }
void SkRegion::Cliperator::next() { … }
SkRegion::Spanerator::Spanerator(const SkRegion& rgn, int y, int left,
int right) { … }
bool SkRegion::Spanerator::next(int* left, int* right) { … }
static void visit_pairs(int pairCount, int y, const int32_t pairs[],
const std::function<void(const SkIRect&)>& visitor) { … }
void SkRegionPriv::VisitSpans(const SkRegion& rgn,
const std::function<void(const SkIRect&)>& visitor) { … }