Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2232)

Unified Diff: src/gpu/GrClipStackClip.cpp

Issue 2456153003: Fall back on stencil clip when SW mask fails to allocate (Closed)
Patch Set: Fall back on stencil clip when SW mask fails to allocate Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrClipStackClip.cpp
diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp
index 14c2dbe8accdb2250315b58a416493798e2bb796..7afaa92bd315548a11eca08242056f20f2b509a2 100644
--- a/src/gpu/GrClipStackClip.cpp
+++ b/src/gpu/GrClipStackClip.cpp
@@ -298,7 +298,13 @@ bool GrClipStackClip::apply(GrContext* context, GrRenderTargetContext* renderTar
return InitialState::kAllIn == reducedClip.initialState();
}
+#ifdef SK_DEBUG
SkASSERT(reducedClip.hasIBounds());
+ SkIRect rtIBounds = SkIRect::MakeWH(renderTargetContext->width(),
+ renderTargetContext->height());
+ SkIRect clipIBounds = reducedClip.ibounds().makeOffset(-fOrigin.x(), -fOrigin.y());
+ SkASSERT(rtIBounds.contains(clipIBounds)); // Mask shouldn't be larger than the RT.
+#endif
// An element count of 4 was chosen because of the common pattern in Blink of:
// isect RR
@@ -380,8 +386,10 @@ static void GetClipMaskKey(int32_t clipGenID, const SkIRect& bounds, GrUniqueKey
static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
GrUniqueKey::Builder builder(key, kDomain, 3);
builder[0] = clipGenID;
- builder[1] = SkToU16(bounds.fLeft) | (SkToU16(bounds.fRight) << 16);
- builder[2] = SkToU16(bounds.fTop) | (SkToU16(bounds.fBottom) << 16);
+ // SkToS16 because image filters outset layers to a size indicated by the filter, which can
+ // sometimes result in negative coordinates from clip space.
+ builder[1] = SkToS16(bounds.fLeft) | (SkToS16(bounds.fRight) << 16);
+ builder[2] = SkToS16(bounds.fTop) | (SkToS16(bounds.fBottom) << 16);
}
sk_sp<GrTexture> GrClipStackClip::CreateAlphaClipMask(GrContext* context,
@@ -432,7 +440,9 @@ sk_sp<GrTexture> GrClipStackClip::CreateSoftwareClipMask(GrTextureProvider* texP
SkMatrix translate;
translate.setTranslate(SkIntToScalar(-reducedClip.left()), SkIntToScalar(-reducedClip.top()));
- helper.init(maskSpaceIBounds, &translate);
+ if (!helper.init(maskSpaceIBounds, &translate)) {
+ return nullptr;
+ }
helper.clear(InitialState::kAllIn == reducedClip.initialState() ? 0xFF : 0x00);
for (ElementList::Iter iter(reducedClip.elements()); iter.get(); iter.next()) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698