OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrClipMaskManager.h" | 9 #include "GrClipMaskManager.h" |
10 #include "GrAAConvexPathRenderer.h" | 10 #include "GrAAConvexPathRenderer.h" |
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 SkASSERT(!drawState.isStateFlagEnabled( | 802 SkASSERT(!drawState.isStateFlagEnabled( |
803 GrGpu::kModifyStencilClip_StateBit)); | 803 GrGpu::kModifyStencilClip_StateBit)); |
804 } else if (drawState.isStateFlagEnabled( | 804 } else if (drawState.isStateFlagEnabled( |
805 GrGpu::kModifyStencilClip_StateBit)) { | 805 GrGpu::kModifyStencilClip_StateBit)) { |
806 clipMode = GrClipMaskManager::kModifyClip_StencilClipMode; | 806 clipMode = GrClipMaskManager::kModifyClip_StencilClipMode; |
807 } else { | 807 } else { |
808 clipMode = GrClipMaskManager::kIgnoreClip_StencilClipMode; | 808 clipMode = GrClipMaskManager::kIgnoreClip_StencilClipMode; |
809 } | 809 } |
810 | 810 |
811 GrStencilSettings settings; | 811 GrStencilSettings settings; |
| 812 |
| 813 // TODO: dynamically attach a stencil buffer |
| 814 int stencilBits = 0; |
| 815 GrStencilBuffer* stencilBuffer = |
| 816 drawState.getRenderTarget()->getStencilBuffer(); |
| 817 if (NULL != stencilBuffer) { |
| 818 stencilBits = stencilBuffer->bits(); |
| 819 if (fGpu->caps()->pathRenderingSupport()) { |
| 820 settings = fGpu->getPathStencilSettingsForFillType(drawState.getPath
StencilFillType()); |
| 821 this->adjustStencilParams(&settings, clipMode, stencilBits); |
| 822 fGpu->setPathStencilSettings(settings); |
| 823 } |
| 824 } |
| 825 |
812 // The GrGpu client may not be using the stencil buffer but we may need to | 826 // The GrGpu client may not be using the stencil buffer but we may need to |
813 // enable it in order to respect a stencil clip. | 827 // enable it in order to respect a stencil clip. |
814 if (drawState.getStencil().isDisabled()) { | 828 if (drawState.getStencil().isDisabled()) { |
815 if (GrClipMaskManager::kRespectClip_StencilClipMode == clipMode) { | 829 if (GrClipMaskManager::kRespectClip_StencilClipMode == clipMode) { |
816 settings = basic_apply_stencil_clip_settings(); | 830 settings = basic_apply_stencil_clip_settings(); |
817 } else { | 831 } else { |
818 fGpu->disableStencil(); | 832 fGpu->disableStencil(); |
819 return; | 833 return; |
820 } | 834 } |
821 } else { | 835 } else { |
822 settings = drawState.getStencil(); | 836 settings = drawState.getStencil(); |
823 } | 837 } |
824 | 838 |
825 // TODO: dynamically attach a stencil buffer | |
826 int stencilBits = 0; | |
827 GrStencilBuffer* stencilBuffer = | |
828 drawState.getRenderTarget()->getStencilBuffer(); | |
829 if (NULL != stencilBuffer) { | |
830 stencilBits = stencilBuffer->bits(); | |
831 } | |
832 | |
833 SkASSERT(fGpu->caps()->stencilWrapOpsSupport() || !settings.usesWrapOp()); | 839 SkASSERT(fGpu->caps()->stencilWrapOpsSupport() || !settings.usesWrapOp()); |
834 SkASSERT(fGpu->caps()->twoSidedStencilSupport() || !settings.isTwoSided()); | 840 SkASSERT(fGpu->caps()->twoSidedStencilSupport() || !settings.isTwoSided()); |
835 this->adjustStencilParams(&settings, clipMode, stencilBits); | 841 this->adjustStencilParams(&settings, clipMode, stencilBits); |
836 fGpu->setStencilSettings(settings); | 842 fGpu->setStencilSettings(settings); |
837 } | 843 } |
838 | 844 |
839 void GrClipMaskManager::adjustStencilParams(GrStencilSettings* settings, | 845 void GrClipMaskManager::adjustStencilParams(GrStencilSettings* settings, |
840 StencilClipMode mode, | 846 StencilClipMode mode, |
841 int stencilBitCnt) { | 847 int stencilBitCnt) { |
842 SkASSERT(stencilBitCnt > 0); | 848 SkASSERT(stencilBitCnt > 0); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 | 1011 |
1006 //////////////////////////////////////////////////////////////////////////////// | 1012 //////////////////////////////////////////////////////////////////////////////// |
1007 void GrClipMaskManager::releaseResources() { | 1013 void GrClipMaskManager::releaseResources() { |
1008 fAACache.releaseResources(); | 1014 fAACache.releaseResources(); |
1009 } | 1015 } |
1010 | 1016 |
1011 void GrClipMaskManager::setGpu(GrGpu* gpu) { | 1017 void GrClipMaskManager::setGpu(GrGpu* gpu) { |
1012 fGpu = gpu; | 1018 fGpu = gpu; |
1013 fAACache.setContext(gpu->getContext()); | 1019 fAACache.setContext(gpu->getContext()); |
1014 } | 1020 } |
OLD | NEW |