8#ifndef skgpu_graphite_ClipStack_DEFINED
9#define skgpu_graphite_ClipStack_DEFINED
35 kEmpty, kWideOpen, kDeviceRect, kDeviceRRect, kComplex
60 inline ElementIter
begin()
const;
61 inline ElementIter
end()
const;
91 bool outsetBoundsForAA,
131 enum class SimplifyResult {
137 static SimplifyResult
Simplify(
const TransformedShape&
a,
const TransformedShape&
b);
140 class RawElement :
public Element {
144 RawElement(
const Rect& deviceBounds,
157 RawElement(
const RawElement&) =
default;
158 RawElement&
operator=(
const RawElement&) =
default;
160 operator TransformedShape()
const;
165 const Rect& outerBounds()
const {
return fOuterBounds; }
166 const Rect& innerBounds()
const {
return fInnerBounds; }
173 bool isInvalid()
const {
return fInvalidatedByIndex >= 0; }
174 void markInvalid(
const SaveRecord& current);
175 void restoreValid(
const SaveRecord& current);
189 void updateForElement(RawElement* added,
const SaveRecord& current);
192 enum class DrawInfluence {
197 DrawInfluence testForDraw(
const TransformedShape&
draw)
const;
210 const Rect& drawBounds,
216 void drawClip(Device*);
218 void validate()
const;
226 bool combine(
const RawElement& other,
const SaveRecord& current);
248 int fInvalidatedByIndex;
258 explicit SaveRecord(
const Rect& deviceBounds);
260 SaveRecord(
const SaveRecord& prior,
int startingElementIndex);
262 const SkShader* shader()
const {
return fShader.get(); }
263 const Rect& outerBounds()
const {
return fOuterBounds; }
264 const Rect& innerBounds()
const {
return fInnerBounds; }
265 SkClipOp op()
const {
return fStackOp; }
268 int firstActiveElementIndex()
const {
return fStartingElementIndex; }
269 int oldestElementIndex()
const {
return fOldestValidIndex; }
270 bool canBeUpdated()
const {
return (fDeferredSaveCount == 0); }
272 Rect scissor(
const Rect& deviceBounds,
const Rect& drawBounds)
const;
277 fDeferredSaveCount++;
281 fDeferredSaveCount--;
283 return fDeferredSaveCount >= 0;
288 bool addElement(RawElement&& toAdd, RawElement::Stack* elements, Device*);
295 void removeElements(RawElement::Stack* elements, Device*);
298 void restoreElements(RawElement::Stack* elements);
304 bool appendElement(RawElement&& toAdd, RawElement::Stack* elements, Device*);
305 void replaceWithElement(RawElement&& toAdd, RawElement::Stack* elements, Device*);
315 const int fStartingElementIndex;
316 int fOldestValidIndex;
317 int fDeferredSaveCount;
325 Rect deviceBounds()
const;
327 const SaveRecord& currentSaveRecord()
const {
329 return fSaves.
back();
334 SaveRecord& writableSaveRecord(
bool* wasDeferred);
336 RawElement::Stack fElements;
337 SaveRecord::Stack fSaves;
356 }
while(
fRemaining > 0 && (*fItem).isInvalid());
363 RawElement::Stack::CRIter::Item
fItem;
375 int count = fElements.
count() - this->currentSaveRecord().oldestElementIndex();
bool SK_API Simplify(const SkPath &path, SkPath *result)
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
ElementIter(RawElement::Stack::CRIter::Item item, int r)
ElementIter & operator++()
bool operator!=(const ElementIter &o) const
const Element & operator*() const
RawElement::Stack::CRIter::Item fItem
void clipShader(sk_sp< SkShader > shader)
ClipStack(Device *owningDevice)
ClipState clipState() const
CompressedPaintersOrder updateClipStateForDraw(const Clip &clip, const ElementList &effectiveElements, const BoundsManager *, PaintersDepth z)
Clip visitClipStackForDraw(const Transform &, const Geometry &, const SkStrokeRec &, bool outsetBoundsForAA, ElementList *outEffectiveElements) const
void recordDeferredClipDraws()
ClipStack & operator=(const ClipStack &)=delete
ClipStack(const ClipStack &)=delete
ElementIter begin() const
int maxDeferredClipDraws() const
Rect conservativeBounds() const
void clipShape(const Transform &localToDevice, const Shape &shape, SkClipOp op)
static constexpr CompressedPaintersOrder kNoIntersection
MonotonicValue< PaintersDepthSequence > PaintersDepth
MonotonicValue< CompressedPaintersOrderSequence > CompressedPaintersOrder
skgpu::graphite::Transform Transform