| 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 "GrAppliedClip.h" |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 // clipSpace bounds. We determine the mask's position WRT to the ren
der target here. | 351 // clipSpace bounds. We determine the mask's position WRT to the ren
der target here. |
| 352 SkIRect rtSpaceMaskBounds = reducedClip.ibounds(); | 352 SkIRect rtSpaceMaskBounds = reducedClip.ibounds(); |
| 353 rtSpaceMaskBounds.offset(-fOrigin); | 353 rtSpaceMaskBounds.offset(-fOrigin); |
| 354 out->addCoverageFP(create_fp_for_mask(result.get(), rtSpaceMaskBound
s)); | 354 out->addCoverageFP(create_fp_for_mask(result.get(), rtSpaceMaskBound
s)); |
| 355 return true; | 355 return true; |
| 356 } | 356 } |
| 357 // if alpha clip mask creation fails fall through to the non-AA code pat
hs | 357 // if alpha clip mask creation fails fall through to the non-AA code pat
hs |
| 358 } | 358 } |
| 359 | 359 |
| 360 // use the stencil clip if we can't represent the clip as a rectangle. | 360 // use the stencil clip if we can't represent the clip as a rectangle. |
| 361 // TODO: these need to be swapped over to using a StencilAttachmentProxy | 361 if (!context->resourceProvider()->attachStencilAttachment(rt)) { |
| 362 GrStencilAttachment* stencilAttachment = | |
| 363 context->resourceProvider()->attachStencilAttachment(rt); | |
| 364 if (nullptr == stencilAttachment) { | |
| 365 SkDebugf("WARNING: failed to attach stencil buffer for clip mask. Clip w
ill be ignored.\n"); | 362 SkDebugf("WARNING: failed to attach stencil buffer for clip mask. Clip w
ill be ignored.\n"); |
| 366 return true; | 363 return true; |
| 367 } | 364 } |
| 368 | 365 |
| 369 // This relies on the property that a reduced sub-rect of the last clip will
contain all the | 366 // This relies on the property that a reduced sub-rect of the last clip will
contain all the |
| 370 // relevant window rectangles that were in the last clip. This subtle requir
ement will go away | 367 // relevant window rectangles that were in the last clip. This subtle requir
ement will go away |
| 371 // after clipping is overhauled. | 368 // after clipping is overhauled. |
| 372 if (stencilAttachment->mustRenderClip(reducedClip.elementsGenID(), reducedCl
ip.ibounds(), | 369 if (renderTargetContext->priv().mustRenderClip(reducedClip.elementsGenID(), |
| 373 fOrigin)) { | 370 reducedClip.ibounds(), fOrigi
n)) { |
| 374 reducedClip.drawStencilClipMask(context, renderTargetContext, fOrigin); | 371 reducedClip.drawStencilClipMask(context, renderTargetContext, fOrigin); |
| 375 stencilAttachment->setLastClip(reducedClip.elementsGenID(), reducedClip.
ibounds(), | 372 renderTargetContext->priv().setLastClip(reducedClip.elementsGenID(), red
ucedClip.ibounds(), |
| 376 fOrigin); | 373 fOrigin); |
| 377 } | 374 } |
| 378 out->addStencilClip(); | 375 out->addStencilClip(); |
| 379 return true; | 376 return true; |
| 380 } | 377 } |
| 381 | 378 |
| 382 //////////////////////////////////////////////////////////////////////////////// | 379 //////////////////////////////////////////////////////////////////////////////// |
| 383 // Create a 8-bit clip mask in alpha | 380 // Create a 8-bit clip mask in alpha |
| 384 | 381 |
| 385 static void GetClipMaskKey(int32_t clipGenID, const SkIRect& bounds, GrUniqueKey
* key) { | 382 static void GetClipMaskKey(int32_t clipGenID, const SkIRect& bounds, GrUniqueKey
* key) { |
| 386 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); | 383 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 sk_sp<GrTexture> result(texProvider->createApproxTexture(desc)); | 485 sk_sp<GrTexture> result(texProvider->createApproxTexture(desc)); |
| 489 if (!result) { | 486 if (!result) { |
| 490 return nullptr; | 487 return nullptr; |
| 491 } | 488 } |
| 492 result->resourcePriv().setUniqueKey(key); | 489 result->resourcePriv().setUniqueKey(key); |
| 493 | 490 |
| 494 helper.toTexture(result.get()); | 491 helper.toTexture(result.get()); |
| 495 | 492 |
| 496 return result; | 493 return result; |
| 497 } | 494 } |
| OLD | NEW |