| 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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 | 406 |
| 407 sk_sp<GrTexture> GrClipStackClip::CreateAlphaClipMask(GrContext* context, | 407 sk_sp<GrTexture> GrClipStackClip::CreateAlphaClipMask(GrContext* context, |
| 408 const GrReducedClip& reduc
edClip) { | 408 const GrReducedClip& reduc
edClip) { |
| 409 GrResourceProvider* resourceProvider = context->resourceProvider(); | 409 GrResourceProvider* resourceProvider = context->resourceProvider(); |
| 410 GrUniqueKey key; | 410 GrUniqueKey key; |
| 411 GetClipMaskKey(reducedClip.elementsGenID(), reducedClip.ibounds(), &key); | 411 GetClipMaskKey(reducedClip.elementsGenID(), reducedClip.ibounds(), &key); |
| 412 if (GrTexture* texture = resourceProvider->findAndRefTextureByUniqueKey(key)
) { | 412 if (GrTexture* texture = resourceProvider->findAndRefTextureByUniqueKey(key)
) { |
| 413 return sk_sp<GrTexture>(texture); | 413 return sk_sp<GrTexture>(texture); |
| 414 } | 414 } |
| 415 | 415 |
| 416 // There's no texture in the cache. Let's try to allocate it then. | 416 sk_sp<GrDrawContext> dc(context->makeDrawContextWithFallback(SkBackingFit::k
Approx, |
| 417 GrPixelConfig config = kRGBA_8888_GrPixelConfig; | 417 reducedClip.wid
th(), |
| 418 if (context->caps()->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) { | 418 reducedClip.hei
ght(), |
| 419 config = kAlpha_8_GrPixelConfig; | 419 kAlpha_8_GrPixe
lConfig, |
| 420 } | 420 nullptr)); |
| 421 | |
| 422 sk_sp<GrDrawContext> dc(context->makeDrawContext(SkBackingFit::kApprox, | |
| 423 reducedClip.width(), | |
| 424 reducedClip.height(), | |
| 425 config, nullptr)); | |
| 426 if (!dc) { | 421 if (!dc) { |
| 427 return nullptr; | 422 return nullptr; |
| 428 } | 423 } |
| 429 | 424 |
| 430 if (!reducedClip.drawAlphaClipMask(dc.get())) { | 425 if (!reducedClip.drawAlphaClipMask(dc.get())) { |
| 431 return nullptr; | 426 return nullptr; |
| 432 } | 427 } |
| 433 | 428 |
| 434 sk_sp<GrTexture> texture(dc->asTexture()); | 429 sk_sp<GrTexture> texture(dc->asTexture()); |
| 435 SkASSERT(texture); | 430 SkASSERT(texture); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 sk_sp<GrTexture> result(texProvider->createApproxTexture(desc)); | 497 sk_sp<GrTexture> result(texProvider->createApproxTexture(desc)); |
| 503 if (!result) { | 498 if (!result) { |
| 504 return nullptr; | 499 return nullptr; |
| 505 } | 500 } |
| 506 result->resourcePriv().setUniqueKey(key); | 501 result->resourcePriv().setUniqueKey(key); |
| 507 | 502 |
| 508 helper.toTexture(result.get()); | 503 helper.toTexture(result.get()); |
| 509 | 504 |
| 510 return result; | 505 return result; |
| 511 } | 506 } |
| OLD | NEW |