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