| 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 #ifndef GrClipMaskManager_DEFINED | 7 #ifndef GrClipMaskManager_DEFINED |
| 8 #define GrClipMaskManager_DEFINED | 8 #define GrClipMaskManager_DEFINED |
| 9 | 9 |
| 10 #include "GrReducedClip.h" | 10 #include "GrReducedClip.h" |
| 11 #include "SkClipStack.h" | 11 #include "SkClipStack.h" |
| 12 #include "SkTypes.h" | 12 #include "SkTypes.h" |
| 13 | 13 |
| 14 class GrAppliedClip; | 14 class GrAppliedClip; |
| 15 class GrClipStackClip; | 15 class GrClipStackClip; |
| 16 class GrContext; | 16 class GrContext; |
| 17 class GrDrawContext; | 17 class GrDrawContext; |
| 18 class GrFixedClip; | |
| 19 class GrPathRenderer; | 18 class GrPathRenderer; |
| 20 class GrPathRendererChain; | |
| 21 class GrPipelineBuilder; | |
| 22 class GrResourceProvider; | |
| 23 class GrTexture; | 19 class GrTexture; |
| 24 class GrTextureProvider; | 20 class GrTextureProvider; |
| 25 class GrUniqueKey; | 21 class GrUniqueKey; |
| 26 struct GrUserStencilSettings; | |
| 27 | 22 |
| 28 | 23 |
| 29 /** | 24 /** |
| 30 * The clip mask creator handles the generation of the clip mask. If anti | 25 * The clip mask creator handles the generation of the clip mask. If anti |
| 31 * aliasing is requested it will (in the future) generate a single channel | 26 * aliasing is requested it will (in the future) generate a single channel |
| 32 * (8bit) mask. If no anti aliasing is requested it will generate a 1-bit | 27 * (8bit) mask. If no anti aliasing is requested it will generate a 1-bit |
| 33 * mask in the stencil buffer. In the non anti-aliasing case, if the clip | 28 * mask in the stencil buffer. In the non anti-aliasing case, if the clip |
| 34 * mask can be represented as a rectangle then scissoring is used. In all | 29 * mask can be represented as a rectangle then scissoring is used. In all |
| 35 * cases scissoring is used to bound the range of the clip mask. | 30 * cases scissoring is used to bound the range of the clip mask. |
| 36 */ | 31 */ |
| 37 // This has to remain a class, for now, so it can be friended (by GrDrawContext
& GrContext) | 32 // This has to remain a class, for now, so it can be friended (by GrDrawContext
& GrContext) |
| 38 class GrClipMaskManager { | 33 class GrClipMaskManager { |
| 39 public: | 34 public: |
| 40 /** | 35 /** |
| 41 * Creates a clip mask if necessary as a stencil buffer or alpha texture | 36 * Creates a clip mask if necessary as a stencil buffer or alpha texture |
| 42 * and sets the GrGpu's scissor and stencil state. If the return is false | 37 * and sets the GrGpu's scissor and stencil state. If the return is false |
| 43 * then the draw can be skipped. devBounds is optional but can help optimize | 38 * then the draw can be skipped. devBounds is optional but can help optimize |
| 44 * clipping. | 39 * clipping. |
| 45 */ | 40 */ |
| 46 static bool SetupClipping(GrContext*, const GrPipelineBuilder&, GrDrawContex
t*, | 41 static bool SetupClipping(GrContext*, |
| 47 const GrClipStackClip&, const SkRect* devBounds, G
rAppliedClip*); | 42 GrDrawContext*, |
| 43 const GrClipStackClip&, |
| 44 const SkRect* devBounds, |
| 45 bool useHWAA, |
| 46 bool hasUserStencilSettings, |
| 47 GrAppliedClip* out); |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 static bool PathNeedsSWRenderer(GrContext* context, | 50 static bool PathNeedsSWRenderer(GrContext* context, |
| 51 bool hasUserStencilSettings, | 51 bool hasUserStencilSettings, |
| 52 const GrDrawContext*, | 52 const GrDrawContext*, |
| 53 const SkMatrix& viewMatrix, | 53 const SkMatrix& viewMatrix, |
| 54 const SkClipStack::Element* element, | 54 const SkClipStack::Element* element, |
| 55 GrPathRenderer** prOut, | 55 GrPathRenderer** prOut, |
| 56 bool needsStencil); | 56 bool needsStencil); |
| 57 | 57 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 75 | 75 |
| 76 // Similar to createAlphaClipMask but it rasterizes in SW and uploads to the
result texture. | 76 // Similar to createAlphaClipMask but it rasterizes in SW and uploads to the
result texture. |
| 77 static sk_sp<GrTexture> CreateSoftwareClipMask(GrTextureProvider*, | 77 static sk_sp<GrTexture> CreateSoftwareClipMask(GrTextureProvider*, |
| 78 int32_t elementsGenID, | 78 int32_t elementsGenID, |
| 79 GrReducedClip::InitialState i
nitialState, | 79 GrReducedClip::InitialState i
nitialState, |
| 80 const GrReducedClip::ElementL
ist& elements, | 80 const GrReducedClip::ElementL
ist& elements, |
| 81 const SkVector& clipToMaskOff
set, | 81 const SkVector& clipToMaskOff
set, |
| 82 const SkIRect& clipSpaceIBoun
ds); | 82 const SkIRect& clipSpaceIBoun
ds); |
| 83 | 83 |
| 84 static bool UseSWOnlyPath(GrContext*, | 84 static bool UseSWOnlyPath(GrContext*, |
| 85 const GrPipelineBuilder&, | 85 bool hasUserStencilSettings, |
| 86 const GrDrawContext*, | 86 const GrDrawContext*, |
| 87 const SkVector& clipToMaskOffset, | 87 const SkVector& clipToMaskOffset, |
| 88 const GrReducedClip::ElementList& elements); | 88 const GrReducedClip::ElementList& elements); |
| 89 | 89 |
| 90 static GrTexture* CreateCachedMask(int width, int height, const GrUniqueKey&
key, | 90 static GrTexture* CreateCachedMask(int width, int height, const GrUniqueKey&
key, |
| 91 bool renderTarget); | 91 bool renderTarget); |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 #endif // GrClipMaskManager_DEFINED | 94 #endif // GrClipMaskManager_DEFINED |
| OLD | NEW |