| 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. | |
| 417 GrPixelConfig config = kRGBA_8888_GrPixelConfig; | |
| 418 if (context->caps()->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) { | |
| 419 config = kAlpha_8_GrPixelConfig; | |
| 420 } | |
| 421 | |
| 422 sk_sp<GrDrawContext> dc(context->makeDrawContext(SkBackingFit::kApprox, | 416 sk_sp<GrDrawContext> dc(context->makeDrawContext(SkBackingFit::kApprox, |
| 423 reducedClip.width(), | 417 reducedClip.width(), |
| 424 reducedClip.height(), | 418 reducedClip.height(), |
| 425 config, nullptr)); | 419 kAlpha_8_GrPixelConfig, nul
lptr)); |
| 426 if (!dc) { | 420 if (!dc) { |
| 427 return nullptr; | 421 return nullptr; |
| 428 } | 422 } |
| 429 | 423 |
| 430 if (!reducedClip.drawAlphaClipMask(dc.get())) { | 424 if (!reducedClip.drawAlphaClipMask(dc.get())) { |
| 431 return nullptr; | 425 return nullptr; |
| 432 } | 426 } |
| 433 | 427 |
| 434 sk_sp<GrTexture> texture(dc->asTexture()); | 428 sk_sp<GrTexture> texture(dc->asTexture()); |
| 435 SkASSERT(texture); | 429 SkASSERT(texture); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 sk_sp<GrTexture> result(texProvider->createApproxTexture(desc)); | 496 sk_sp<GrTexture> result(texProvider->createApproxTexture(desc)); |
| 503 if (!result) { | 497 if (!result) { |
| 504 return nullptr; | 498 return nullptr; |
| 505 } | 499 } |
| 506 result->resourcePriv().setUniqueKey(key); | 500 result->resourcePriv().setUniqueKey(key); |
| 507 | 501 |
| 508 helper.toTexture(result.get()); | 502 helper.toTexture(result.get()); |
| 509 | 503 |
| 510 return result; | 504 return result; |
| 511 } | 505 } |
| OLD | NEW |