OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrClipMaskManager.h" | 8 #include "GrClipMaskManager.h" |
9 #include "GrCaps.h" | 9 #include "GrCaps.h" |
10 #include "GrDrawingManager.h" | 10 #include "GrDrawingManager.h" |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 if (GrTexture* texture = resourceProvider->findAndRefTextureByUniqueKey(key)
) { | 455 if (GrTexture* texture = resourceProvider->findAndRefTextureByUniqueKey(key)
) { |
456 return sk_sp<GrTexture>(texture); | 456 return sk_sp<GrTexture>(texture); |
457 } | 457 } |
458 | 458 |
459 // There's no texture in the cache. Let's try to allocate it then. | 459 // There's no texture in the cache. Let's try to allocate it then. |
460 GrPixelConfig config = kRGBA_8888_GrPixelConfig; | 460 GrPixelConfig config = kRGBA_8888_GrPixelConfig; |
461 if (context->caps()->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) { | 461 if (context->caps()->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) { |
462 config = kAlpha_8_GrPixelConfig; | 462 config = kAlpha_8_GrPixelConfig; |
463 } | 463 } |
464 | 464 |
465 sk_sp<GrDrawContext> dc(context->newDrawContext(SkBackingFit::kApprox, | 465 sk_sp<GrDrawContext> dc(context->makeDrawContext(SkBackingFit::kApprox, |
466 clipSpaceIBounds.width(), | 466 clipSpaceIBounds.width(), |
467 clipSpaceIBounds.height(), | 467 clipSpaceIBounds.height(), |
468 config, nullptr)); | 468 config, nullptr)); |
469 if (!dc) { | 469 if (!dc) { |
470 return nullptr; | 470 return nullptr; |
471 } | 471 } |
472 | 472 |
473 // The texture may be larger than necessary, this rect represents the part o
f the texture | 473 // The texture may be larger than necessary, this rect represents the part o
f the texture |
474 // we populate with a rasterization of the clip. | 474 // we populate with a rasterization of the clip. |
475 SkIRect maskSpaceIBounds = SkIRect::MakeWH(clipSpaceIBounds.width(), clipSpa
ceIBounds.height()); | 475 SkIRect maskSpaceIBounds = SkIRect::MakeWH(clipSpaceIBounds.width(), clipSpa
ceIBounds.height()); |
476 | 476 |
477 // The scratch texture that we are drawing into can be substantially larger
than the mask. Only | 477 // The scratch texture that we are drawing into can be substantially larger
than the mask. Only |
478 // clear the part that we care about. | 478 // clear the part that we care about. |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 sk_sp<GrTexture> result(texProvider->createApproxTexture(desc)); | 801 sk_sp<GrTexture> result(texProvider->createApproxTexture(desc)); |
802 if (!result) { | 802 if (!result) { |
803 return nullptr; | 803 return nullptr; |
804 } | 804 } |
805 result->resourcePriv().setUniqueKey(key); | 805 result->resourcePriv().setUniqueKey(key); |
806 | 806 |
807 helper.toTexture(result.get()); | 807 helper.toTexture(result.get()); |
808 | 808 |
809 return result; | 809 return result; |
810 } | 810 } |
OLD | NEW |