diff options
-rw-r--r-- | gm/windowrectangles.cpp | 2 | ||||
-rw-r--r-- | src/core/SkClipStack.cpp | 11 | ||||
-rw-r--r-- | src/core/SkClipStack.h | 18 | ||||
-rw-r--r-- | src/gpu/GrAppliedClip.h | 4 | ||||
-rw-r--r-- | src/gpu/GrClipStackClip.cpp | 4 | ||||
-rw-r--r-- | src/gpu/GrReducedClip.cpp | 4 | ||||
-rw-r--r-- | src/gpu/GrReducedClip.h | 4 | ||||
-rw-r--r-- | src/gpu/GrRenderTargetContextPriv.h | 4 | ||||
-rw-r--r-- | src/gpu/GrRenderTargetOpList.h | 2 | ||||
-rw-r--r-- | tests/ClipStackTest.cpp | 10 |
10 files changed, 33 insertions, 30 deletions
diff --git a/gm/windowrectangles.cpp b/gm/windowrectangles.cpp index ecc9304ef2..dc5b93dbe0 100644 --- a/gm/windowrectangles.cpp +++ b/gm/windowrectangles.cpp @@ -243,7 +243,7 @@ void WindowRectanglesMaskGM::visualizeStencilMask(GrContext* ctx, GrRenderTarget reducedClip.drawStencilClipMask(ctx, rtc); // Now visualize the stencil mask by covering the entire render target. The regions inside - // window rectangless or outside the scissor should still have the initial checkerboard intact. + // window rectangles or outside the scissor should still have the initial checkerboard intact. // (This verifies we didn't spend any time modifying those pixels in the mask.) rtc->drawPaint(StencilOnlyClip(), std::move(paint), SkMatrix::I()); } diff --git a/src/core/SkClipStack.cpp b/src/core/SkClipStack.cpp index 8da54e1ca3..d4a9867f65 100644 --- a/src/core/SkClipStack.cpp +++ b/src/core/SkClipStack.cpp @@ -924,12 +924,15 @@ bool SkClipStack::isRRect(const SkRect& bounds, SkRRect* rrect, bool* aa) const return false; } -int32_t SkClipStack::GetNextGenID() { - // TODO: handle overflow. - return sk_atomic_inc(&gGenID); +uint32_t SkClipStack::GetNextGenID() { + uint32_t id; + do { + id = static_cast<uint32_t>(sk_atomic_inc(&gGenID)); + } while (id < kFirstUnreservedGenID); + return id; } -int32_t SkClipStack::getTopmostGenID() const { +uint32_t SkClipStack::getTopmostGenID() const { if (fDeque.empty()) { return kWideOpenGenID; } diff --git a/src/core/SkClipStack.h b/src/core/SkClipStack.h index 4502ecdb5f..70f812a825 100644 --- a/src/core/SkClipStack.h +++ b/src/core/SkClipStack.h @@ -129,7 +129,7 @@ public: stack not to the element itself. That is the same clip path in different stacks will have a different ID since the elements produce different clip result in the context of their stacks. */ - int32_t getGenID() const { SkASSERT(kInvalidGenID != fGenID); return fGenID; } + uint32_t getGenID() const { SkASSERT(kInvalidGenID != fGenID); return fGenID; } /** * Gets the bounds of the clip element, either the rect or path bounds. (Whether the shape @@ -241,7 +241,7 @@ public: // equivalent to a single rect intersection? IIOW, is the clip effectively a rectangle. bool fIsIntersectionOfRects; - int fGenID; + uint32_t fGenID; #if SK_SUPPORT_GPU mutable SkTArray<std::unique_ptr<GrUniqueKeyInvalidatedMessage>> fMessages; #endif @@ -430,13 +430,13 @@ public: * The generation ID has three reserved values to indicate special * (potentially ignorable) cases */ - static const int32_t kInvalidGenID = 0; //!< Invalid id that is never returned by - //!< SkClipStack. Useful when caching clips - //!< based on GenID. - static const int32_t kEmptyGenID = 1; // no pixels writeable - static const int32_t kWideOpenGenID = 2; // all pixels writeable + static const uint32_t kInvalidGenID = 0; //!< Invalid id that is never returned by + //!< SkClipStack. Useful when caching clips + //!< based on GenID. + static const uint32_t kEmptyGenID = 1; // no pixels writeable + static const uint32_t kWideOpenGenID = 2; // all pixels writeable - int32_t getTopmostGenID() const; + uint32_t getTopmostGenID() const; #ifdef SK_DEBUG /** @@ -567,7 +567,7 @@ private: /** * Return the next unique generation ID. */ - static int32_t GetNextGenID(); + static uint32_t GetNextGenID(); }; #endif diff --git a/src/gpu/GrAppliedClip.h b/src/gpu/GrAppliedClip.h index 4181f43a00..a389d749fa 100644 --- a/src/gpu/GrAppliedClip.h +++ b/src/gpu/GrAppliedClip.h @@ -53,7 +53,7 @@ public: fClipCoverageFP = fp; } - void addStencilClip(int32_t clipStackID) { + void addStencilClip(uint32_t clipStackID) { SkASSERT(SkClipStack::kInvalidGenID == fClipStackID); fClipStackID = clipStackID; } @@ -83,7 +83,7 @@ private: GrScissorState fScissorState; GrWindowRectsState fWindowRectsState; sk_sp<GrFragmentProcessor> fClipCoverageFP; - int32_t fClipStackID = SkClipStack::kInvalidGenID; + uint32_t fClipStackID = SkClipStack::kInvalidGenID; }; #endif diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp index ecc6252dcb..9a93687e50 100644 --- a/src/gpu/GrClipStackClip.cpp +++ b/src/gpu/GrClipStackClip.cpp @@ -364,7 +364,7 @@ bool GrClipStackClip::apply(GrContext* context, GrRenderTargetContext* renderTar //////////////////////////////////////////////////////////////////////////////// // Create a 8-bit clip mask in alpha -static void create_clip_mask_key(int32_t clipGenID, const SkIRect& bounds, GrUniqueKey* key) { +static void create_clip_mask_key(uint32_t clipGenID, const SkIRect& bounds, GrUniqueKey* key) { static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); GrUniqueKey::Builder builder(key, kDomain, 3, GrClipStackClip::kMaskTestTag); builder[0] = clipGenID; @@ -374,7 +374,7 @@ static void create_clip_mask_key(int32_t clipGenID, const SkIRect& bounds, GrUni builder[2] = SkToS16(bounds.fTop) | (SkToS16(bounds.fBottom) << 16); } -static void add_invalidate_on_pop_message(const SkClipStack& stack, int32_t clipGenID, +static void add_invalidate_on_pop_message(const SkClipStack& stack, uint32_t clipGenID, const GrUniqueKey& clipMaskKey) { SkClipStack::Iter iter(stack, SkClipStack::Iter::kTop_IterStart); while (const Element* element = iter.prev()) { diff --git a/src/gpu/GrReducedClip.cpp b/src/gpu/GrReducedClip.cpp index dfa41668d4..e6cea3e654 100644 --- a/src/gpu/GrReducedClip.cpp +++ b/src/gpu/GrReducedClip.cpp @@ -662,7 +662,7 @@ bool GrReducedClip::drawAlphaClipMask(GrRenderTargetContext* rtc) const { class StencilClip final : public GrClip { public: - StencilClip(const SkIRect& scissorRect, int32_t clipStackID) + StencilClip(const SkIRect& scissorRect, uint32_t clipStackID) : fFixedClip(scissorRect) , fClipStackID(clipStackID) { } @@ -694,7 +694,7 @@ private: } GrFixedClip fFixedClip; - int32_t fClipStackID; + uint32_t fClipStackID; typedef GrClip INHERITED; }; diff --git a/src/gpu/GrReducedClip.h b/src/gpu/GrReducedClip.h index 6dceb004c2..c9cce361ec 100644 --- a/src/gpu/GrReducedClip.h +++ b/src/gpu/GrReducedClip.h @@ -56,7 +56,7 @@ public: * If elements() are nonempty, uniquely identifies the list of elements within ibounds(). * Otherwise undefined. */ - int32_t elementsGenID() const { SkASSERT(!fElements.isEmpty()); return fElementsGenID; } + uint32_t elementsGenID() const { SkASSERT(!fElements.isEmpty()); return fElementsGenID; } /** * Indicates whether antialiasing is required to process any of the clip elements. @@ -83,7 +83,7 @@ private: bool fHasIBounds; GrWindowRectangles fWindowRects; ElementList fElements; - int32_t fElementsGenID; + uint32_t fElementsGenID; bool fRequiresAA; InitialState fInitialState; }; diff --git a/src/gpu/GrRenderTargetContextPriv.h b/src/gpu/GrRenderTargetContextPriv.h index 3312a8fb2d..ed1b40bf96 100644 --- a/src/gpu/GrRenderTargetContextPriv.h +++ b/src/gpu/GrRenderTargetContextPriv.h @@ -27,7 +27,7 @@ public: // called to note the last clip drawn to the stencil buffer. // TODO: remove after clipping overhaul. - void setLastClip(int32_t clipStackGenID, const SkIRect& devClipBounds) { + void setLastClip(uint32_t clipStackGenID, const SkIRect& devClipBounds) { GrRenderTargetOpList* opList = fRenderTargetContext->getRTOpList(); opList->fLastClipStackGenID = clipStackGenID; opList->fLastDevClipBounds = devClipBounds; @@ -35,7 +35,7 @@ public: // called to determine if we have to render the clip into SB. // TODO: remove after clipping overhaul. - bool mustRenderClip(int32_t clipStackGenID, const SkIRect& devClipBounds) const { + bool mustRenderClip(uint32_t clipStackGenID, const SkIRect& devClipBounds) const { GrRenderTargetOpList* opList = fRenderTargetContext->getRTOpList(); return opList->fLastClipStackGenID != clipStackGenID || !opList->fLastDevClipBounds.contains(devClipBounds); diff --git a/src/gpu/GrRenderTargetOpList.h b/src/gpu/GrRenderTargetOpList.h index 668e94d4cd..7a26a0500a 100644 --- a/src/gpu/GrRenderTargetOpList.h +++ b/src/gpu/GrRenderTargetOpList.h @@ -143,7 +143,7 @@ private: std::unique_ptr<gr_instanced::InstancedRendering> fInstancedRendering; - int32_t fLastClipStackGenID; + uint32_t fLastClipStackGenID; SkIRect fLastDevClipBounds; // For ops/opList we have mean: 5 stdDev: 28 diff --git a/tests/ClipStackTest.cpp b/tests/ClipStackTest.cpp index af57f9e5c2..e1aa148b3f 100644 --- a/tests/ClipStackTest.cpp +++ b/tests/ClipStackTest.cpp @@ -1107,16 +1107,16 @@ static void test_reduced_clip_stack_genid(skiatest::Reporter* reporter) { stack.clipRect(SkRect::MakeXYWH(0, 0, SkScalar(25.3), SkScalar(25.3)), SkMatrix::I(), kReplace_SkClipOp, true); - int32_t genIDA = stack.getTopmostGenID(); + uint32_t genIDA = stack.getTopmostGenID(); stack.clipRect(SkRect::MakeXYWH(50, 0, SkScalar(25.3), SkScalar(25.3)), SkMatrix::I(), kUnion_SkClipOp, true); - int32_t genIDB = stack.getTopmostGenID(); + uint32_t genIDB = stack.getTopmostGenID(); stack.clipRect(SkRect::MakeXYWH(0, 50, SkScalar(25.3), SkScalar(25.3)), SkMatrix::I(), kUnion_SkClipOp, true); - int32_t genIDC = stack.getTopmostGenID(); + uint32_t genIDC = stack.getTopmostGenID(); stack.clipRect(SkRect::MakeXYWH(50, 50, SkScalar(25.3), SkScalar(25.3)), SkMatrix::I(), kUnion_SkClipOp, true); - int32_t genIDD = stack.getTopmostGenID(); + uint32_t genIDD = stack.getTopmostGenID(); #define IXYWH SkIRect::MakeXYWH @@ -1135,7 +1135,7 @@ static void test_reduced_clip_stack_genid(skiatest::Reporter* reporter) { static const struct SUPPRESS_VISIBILITY_WARNING { SkRect testBounds; int reducedClipCount; - int32_t reducedGenID; + uint32_t reducedGenID; InitialState initialState; SkIRect clipIRect; // parameter. |