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 "GrAAConvexPathRenderer.h" | 9 #include "GrAAConvexPathRenderer.h" |
10 #include "GrAAHairLinePathRenderer.h" | 10 #include "GrAAHairLinePathRenderer.h" |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 GrColor_WHITE, | 482 GrColor_WHITE, |
483 SkMatrix::I(), | 483 SkMatrix::I(), |
484 SkRect::Make(dstBound)); | 484 SkRect::Make(dstBound)); |
485 } | 485 } |
486 | 486 |
487 GrTexture* GrClipMaskManager::createTempMask(int width, int height) { | 487 GrTexture* GrClipMaskManager::createTempMask(int width, int height) { |
488 GrSurfaceDesc desc; | 488 GrSurfaceDesc desc; |
489 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 489 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
490 desc.fWidth = width; | 490 desc.fWidth = width; |
491 desc.fHeight = height; | 491 desc.fHeight = height; |
492 if (this->getContext()->caps()->isConfigRenderable(kAlpha_8_GrPixelConfig, f
alse)) { | 492 if (this->getContext()->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) { |
493 desc.fConfig = kAlpha_8_GrPixelConfig; | 493 desc.fConfig = kAlpha_8_GrPixelConfig; |
494 } else { | 494 } else { |
495 desc.fConfig = kRGBA_8888_GrPixelConfig; | 495 desc.fConfig = kRGBA_8888_GrPixelConfig; |
496 } | 496 } |
497 | 497 |
498 return this->getContext()->textureProvider()->refScratchTexture( | 498 return this->getContext()->textureProvider()->refScratchTexture( |
499 desc, GrTextureProvider::kApprox_ScratchTexMatch); | 499 desc, GrTextureProvider::kApprox_ScratchTexMatch); |
500 } | 500 } |
501 | 501 |
502 //////////////////////////////////////////////////////////////////////////////// | 502 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 16 matching lines...) Expand all Loading... |
519 bool willUpload) { | 519 bool willUpload) { |
520 // Since we are setting up the cache we should free up the | 520 // Since we are setting up the cache we should free up the |
521 // currently cached mask so it can be reused. | 521 // currently cached mask so it can be reused. |
522 fAACache.reset(); | 522 fAACache.reset(); |
523 | 523 |
524 GrSurfaceDesc desc; | 524 GrSurfaceDesc desc; |
525 desc.fFlags = willUpload ? kNone_GrSurfaceFlags : kRenderTarget_GrSurfaceFla
g; | 525 desc.fFlags = willUpload ? kNone_GrSurfaceFlags : kRenderTarget_GrSurfaceFla
g; |
526 desc.fWidth = clipSpaceIBounds.width(); | 526 desc.fWidth = clipSpaceIBounds.width(); |
527 desc.fHeight = clipSpaceIBounds.height(); | 527 desc.fHeight = clipSpaceIBounds.height(); |
528 desc.fConfig = kRGBA_8888_GrPixelConfig; | 528 desc.fConfig = kRGBA_8888_GrPixelConfig; |
529 if (willUpload || | 529 if (willUpload || this->getContext()->isConfigRenderable(kAlpha_8_GrPixelCon
fig, false)) { |
530 this->getContext()->caps()->isConfigRenderable(kAlpha_8_GrPixelConfig, f
alse)) { | |
531 // We would always like A8 but it isn't supported on all platforms | 530 // We would always like A8 but it isn't supported on all platforms |
532 desc.fConfig = kAlpha_8_GrPixelConfig; | 531 desc.fConfig = kAlpha_8_GrPixelConfig; |
533 } | 532 } |
534 | 533 |
535 fAACache.acquireMask(elementsGenID, desc, clipSpaceIBounds); | 534 fAACache.acquireMask(elementsGenID, desc, clipSpaceIBounds); |
536 return fAACache.getLastMask(); | 535 return fAACache.getLastMask(); |
537 } | 536 } |
538 | 537 |
539 //////////////////////////////////////////////////////////////////////////////// | 538 //////////////////////////////////////////////////////////////////////////////// |
540 // Create a 8-bit clip mask in alpha | 539 // Create a 8-bit clip mask in alpha |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1115 fAACache.setContext(clipTarget->getContext()); | 1114 fAACache.setContext(clipTarget->getContext()); |
1116 } | 1115 } |
1117 | 1116 |
1118 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc
ilAttachment, | 1117 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc
ilAttachment, |
1119 GrStencilSettings* settings) { | 1118 GrStencilSettings* settings) { |
1120 if (stencilAttachment) { | 1119 if (stencilAttachment) { |
1121 int stencilBits = stencilAttachment->bits(); | 1120 int stencilBits = stencilAttachment->bits(); |
1122 this->adjustStencilParams(settings, fClipMode, stencilBits); | 1121 this->adjustStencilParams(settings, fClipMode, stencilBits); |
1123 } | 1122 } |
1124 } | 1123 } |
OLD | NEW |