OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrClipStackClip.h" | 8 #include "GrClipStackClip.h" |
9 | 9 |
| 10 #include "GrAppliedClip.h" |
10 #include "GrDrawingManager.h" | 11 #include "GrDrawingManager.h" |
11 #include "GrDrawContextPriv.h" | 12 #include "GrDrawContextPriv.h" |
12 #include "GrGpuResourcePriv.h" | 13 #include "GrGpuResourcePriv.h" |
| 14 #include "GrRenderTargetPriv.h" |
13 #include "GrStencilAttachment.h" | 15 #include "GrStencilAttachment.h" |
14 #include "GrSWMaskHelper.h" | 16 #include "GrSWMaskHelper.h" |
15 #include "effects/GrConvexPolyEffect.h" | 17 #include "effects/GrConvexPolyEffect.h" |
16 #include "effects/GrRRectEffect.h" | 18 #include "effects/GrRRectEffect.h" |
17 #include "effects/GrTextureDomain.h" | 19 #include "effects/GrTextureDomain.h" |
18 | 20 |
19 typedef SkClipStack::Element Element; | 21 typedef SkClipStack::Element Element; |
20 typedef GrReducedClip::InitialState InitialState; | 22 typedef GrReducedClip::InitialState InitialState; |
21 typedef GrReducedClip::ElementList ElementList; | 23 typedef GrReducedClip::ElementList ElementList; |
22 | 24 |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 scissorSpaceIBounds.offset(-fOrigin); | 275 scissorSpaceIBounds.offset(-fOrigin); |
274 out->addScissor(scissorSpaceIBounds); | 276 out->addScissor(scissorSpaceIBounds); |
275 } | 277 } |
276 | 278 |
277 if (reducedClip.elements().isEmpty()) { | 279 if (reducedClip.elements().isEmpty()) { |
278 return InitialState::kAllIn == reducedClip.initialState(); | 280 return InitialState::kAllIn == reducedClip.initialState(); |
279 } | 281 } |
280 | 282 |
281 SkASSERT(reducedClip.hasIBounds()); | 283 SkASSERT(reducedClip.hasIBounds()); |
282 | 284 |
| 285 // Attempt to implement difference clip rects with window rectangles. This w
ill eventually |
| 286 // become more comprehensive. |
| 287 if (drawContext->accessRenderTarget()->renderTargetPriv().supportsWindowRect
angles() && |
| 288 1 == reducedClip.elements().count() && !reducedClip.requiresAA() && |
| 289 InitialState::kAllIn == reducedClip.initialState()) { |
| 290 const Element* element = reducedClip.elements().head(); |
| 291 SkRegion::Op op = element->getOp(); |
| 292 if (Element::kRect_Type == element->getType() && |
| 293 (SkRegion::kDifference_Op == op || SkRegion::kXOR_Op == op)) { |
| 294 SkIRect window; |
| 295 element->getRect().round(&window); |
| 296 window.offset(-fOrigin); |
| 297 out->addWindowRectangle(window); |
| 298 return true; |
| 299 } |
| 300 } |
| 301 |
283 // An element count of 4 was chosen because of the common pattern in Blink o
f: | 302 // An element count of 4 was chosen because of the common pattern in Blink o
f: |
284 // isect RR | 303 // isect RR |
285 // diff RR | 304 // diff RR |
286 // isect convex_poly | 305 // isect convex_poly |
287 // isect convex_poly | 306 // isect convex_poly |
288 // when drawing rounded div borders. This could probably be tuned based on a | 307 // when drawing rounded div borders. This could probably be tuned based on a |
289 // configuration's relative costs of switching RTs to generate a mask vs | 308 // configuration's relative costs of switching RTs to generate a mask vs |
290 // longer shaders. | 309 // longer shaders. |
291 if (reducedClip.elements().count() <= kMaxAnalyticElements) { | 310 if (reducedClip.elements().count() <= kMaxAnalyticElements) { |
292 // When there are multiple samples we want to do per-sample clipping, no
t compute a | 311 // When there are multiple samples we want to do per-sample clipping, no
t compute a |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 sk_sp<GrTexture> result(texProvider->createApproxTexture(desc)); | 782 sk_sp<GrTexture> result(texProvider->createApproxTexture(desc)); |
764 if (!result) { | 783 if (!result) { |
765 return nullptr; | 784 return nullptr; |
766 } | 785 } |
767 result->resourcePriv().setUniqueKey(key); | 786 result->resourcePriv().setUniqueKey(key); |
768 | 787 |
769 helper.toTexture(result.get()); | 788 helper.toTexture(result.get()); |
770 | 789 |
771 return result; | 790 return result; |
772 } | 791 } |
OLD | NEW |