#include "src/gpu/ganesh/ClipStack.h"
#include "include/core/SkAlphaType.h"
#include "include/core/SkBlendMode.h"
#include "include/core/SkClipOp.h"
#include "include/core/SkColorSpace.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPath.h"
#include "include/core/SkRRect.h"
#include "include/core/SkRegion.h"
#include "include/core/SkSamplingOptions.h"
#include "include/core/SkScalar.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/ganesh/GrBackendSurface.h"
#include "include/gpu/ganesh/GrDirectContext.h"
#include "include/gpu/ganesh/GrRecordingContext.h"
#include "include/gpu/ganesh/GrTypes.h"
#include "include/private/base/SkPoint_impl.h"
#include "include/private/base/SkTArray.h"
#include "include/private/base/SkTo.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/base/SkVx.h"
#include "src/core/SkPathPriv.h"
#include "src/core/SkRRectPriv.h"
#include "src/core/SkRectPriv.h"
#include "src/core/SkTaskGroup.h"
#include "src/core/SkTraceEvent.h"
#include "src/gpu/SkBackingFit.h"
#include "src/gpu/Swizzle.h"
#include "src/gpu/ganesh/GrAppliedClip.h"
#include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrClip.h"
#include "src/gpu/ganesh/GrColorInfo.h"
#include "src/gpu/ganesh/GrDeferredProxyUploader.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/GrDrawingManager.h"
#include "src/gpu/ganesh/GrFPArgs.h"
#include "src/gpu/ganesh/GrFragmentProcessor.h"
#include "src/gpu/ganesh/GrFragmentProcessors.h"
#include "src/gpu/ganesh/GrProxyProvider.h"
#include "src/gpu/ganesh/GrRecordingContextPriv.h"
#include "src/gpu/ganesh/GrRenderTargetProxy.h"
#include "src/gpu/ganesh/GrSWMaskHelper.h"
#include "src/gpu/ganesh/GrSamplerState.h"
#include "src/gpu/ganesh/GrSurfaceProxy.h"
#include "src/gpu/ganesh/GrSurfaceProxyView.h"
#include "src/gpu/ganesh/GrTextureProxy.h"
#include "src/gpu/ganesh/GrTextureProxyPriv.h"
#include "src/gpu/ganesh/GrWindowRectangles.h"
#include "src/gpu/ganesh/GrWindowRectsState.h"
#include "src/gpu/ganesh/StencilMaskHelper.h"
#include "src/gpu/ganesh/SurfaceDrawContext.h"
#include "src/gpu/ganesh/effects/GrBlendFragmentProcessor.h"
#include "src/gpu/ganesh/effects/GrConvexPolyEffect.h"
#include "src/gpu/ganesh/effects/GrRRectEffect.h"
#include "src/gpu/ganesh/effects/GrTextureEffect.h"
#include "src/gpu/ganesh/geometry/GrQuad.h"
#include "src/gpu/ganesh/geometry/GrQuadUtils.h"
#include "src/gpu/ganesh/ops/AtlasPathRenderer.h"
#include "src/gpu/ganesh/ops/GrDrawOp.h"
#include <algorithm>
#include <atomic>
#include <functional>
#include <tuple>
#include <utility>
class GrOp;
struct GrShaderCaps;
usingnamespaceskia_private;
namespace {
enum class ClipGeometry { … };
template<typename A, typename B>
ClipGeometry get_clip_geometry(const A& a, const B& b) { … }
bool shape_contains_rect(const GrShape& a, const SkMatrix& aToDevice, const SkMatrix& deviceToA,
const SkRect& b, const SkMatrix& bToDevice, bool mixedAAMode) { … }
SkIRect subtract(const SkIRect& a, const SkIRect& b, bool exact) { … }
GrClipEdgeType get_clip_edge_type(SkClipOp op, GrAA aa) { … }
static uint32_t kInvalidGenID = …;
static uint32_t kEmptyGenID = …;
static uint32_t kWideOpenGenID = …;
uint32_t next_gen_id() { … }
static constexpr GrSurfaceOrigin kMaskOrigin = …;
GrFPResult analytic_clip_fp(const skgpu::ganesh::ClipStack::Element& e,
const GrShaderCaps& caps,
std::unique_ptr<GrFragmentProcessor> fp) { … }
GrFPResult clip_atlas_fp(const skgpu::ganesh::SurfaceDrawContext* sdc,
const GrOp* opBeingClipped,
skgpu::ganesh::AtlasPathRenderer* atlasPathRenderer,
const SkIRect& scissorBounds,
const skgpu::ganesh::ClipStack::Element& e,
std::unique_ptr<GrFragmentProcessor> inputFP) { … }
void draw_to_sw_mask(GrSWMaskHelper* helper,
const skgpu::ganesh::ClipStack::Element& e,
bool clearMask) { … }
GrSurfaceProxyView render_sw_mask(GrRecordingContext* context,
const SkIRect& bounds,
const skgpu::ganesh::ClipStack::Element** elements,
int count) { … }
void render_stencil_mask(GrRecordingContext* rContext,
skgpu::ganesh::SurfaceDrawContext* sdc,
uint32_t genID,
const SkIRect& bounds,
const skgpu::ganesh::ClipStack::Element** elements,
int count,
GrAppliedClip* out) { … }
}
namespace skgpu::ganesh {
class ClipStack::Draw { … };
ClipStack::RawElement::RawElement(const SkMatrix& localToDevice, const GrShape& shape,
GrAA aa, SkClipOp op)
: … { … }
void ClipStack::RawElement::markInvalid(const SaveRecord& current) { … }
void ClipStack::RawElement::restoreValid(const SaveRecord& current) { … }
bool ClipStack::RawElement::contains(const Draw& d) const { … }
bool ClipStack::RawElement::contains(const SaveRecord& s) const { … }
bool ClipStack::RawElement::contains(const RawElement& e) const { … }
void ClipStack::RawElement::simplify(const SkIRect& deviceBounds, bool forceAA) { … }
bool ClipStack::RawElement::combine(const RawElement& other, const SaveRecord& current) { … }
void ClipStack::RawElement::updateForElement(RawElement* added, const SaveRecord& current) { … }
ClipStack::ClipState ClipStack::RawElement::clipType() const { … }
ClipStack::Mask::Mask(const SaveRecord& current, const SkIRect& drawBounds)
: … { … }
bool ClipStack::Mask::appliesToDraw(const SaveRecord& current, const SkIRect& drawBounds) const { … }
void ClipStack::Mask::invalidate(GrProxyProvider* proxyProvider) { … }
ClipStack::SaveRecord::SaveRecord(const SkIRect& deviceBounds)
: … { … }
ClipStack::SaveRecord::SaveRecord(const SaveRecord& prior,
int startingMaskIndex,
int startingElementIndex)
: … { … }
uint32_t ClipStack::SaveRecord::genID() const { … }
ClipStack::ClipState ClipStack::SaveRecord::state() const { … }
bool ClipStack::SaveRecord::contains(const ClipStack::Draw& draw) const { … }
bool ClipStack::SaveRecord::contains(const ClipStack::RawElement& element) const { … }
void ClipStack::SaveRecord::removeElements(RawElement::Stack* elements) { … }
void ClipStack::SaveRecord::restoreElements(RawElement::Stack* elements) { … }
void ClipStack::SaveRecord::invalidateMasks(GrProxyProvider* proxyProvider,
Mask::Stack* masks) { … }
void ClipStack::SaveRecord::reset(const SkIRect& bounds) { … }
void ClipStack::SaveRecord::addShader(sk_sp<SkShader> shader) { … }
bool ClipStack::SaveRecord::addElement(RawElement&& toAdd, RawElement::Stack* elements) { … }
bool ClipStack::SaveRecord::appendElement(RawElement&& toAdd, RawElement::Stack* elements) { … }
void ClipStack::SaveRecord::replaceWithElement(RawElement&& toAdd, RawElement::Stack* elements) { … }
static constexpr int kElementStackIncrement = …;
static constexpr int kSaveStackIncrement = …;
static constexpr int kMaskStackIncrement = …;
static constexpr int kMaxAnalyticFPs = …;
static constexpr int kNumStackMasks = …;
ClipStack::ClipStack(const SkIRect& deviceBounds, const SkMatrix* ctm, bool forceAA)
: … { … }
ClipStack::~ClipStack() { … }
void ClipStack::save() { … }
void ClipStack::restore() { … }
SkIRect ClipStack::getConservativeBounds() const { … }
GrClip::PreClipResult ClipStack::preApply(const SkRect& bounds, GrAA aa) const { … }
GrClip::Effect ClipStack::apply(GrRecordingContext* rContext,
SurfaceDrawContext* sdc,
GrDrawOp* op,
GrAAType aa,
GrAppliedClip* out,
SkRect* bounds) const { … }
ClipStack::SaveRecord& ClipStack::writableSaveRecord(bool* wasDeferred) { … }
void ClipStack::clipShader(sk_sp<SkShader> shader) { … }
void ClipStack::replaceClip(const SkIRect& rect) { … }
void ClipStack::clip(RawElement&& element) { … }
GrFPResult ClipStack::GetSWMaskFP(GrRecordingContext* context, Mask::Stack* masks,
const SaveRecord& current, const SkIRect& bounds,
const Element** elements, int count,
std::unique_ptr<GrFragmentProcessor> clipFP) { … }
}