bsalomon@google.com | 170bd79 | 2012-12-05 22:26:11 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2012 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
| 8 | |
george | 9eb182a | 2014-06-20 12:01:06 -0700 | [diff] [blame] | 9 | #ifndef GrReducedClip_DEFINED |
| 10 | #define GrReducedClip_DEFINED |
| 11 | |
bsalomon@google.com | 170bd79 | 2012-12-05 22:26:11 +0000 | [diff] [blame] | 12 | #include "SkClipStack.h" |
| 13 | #include "SkTLList.h" |
| 14 | |
| 15 | namespace GrReducedClip { |
| 16 | |
| 17 | typedef SkTLList<SkClipStack::Element> ElementList; |
| 18 | |
| 19 | enum InitialState { |
| 20 | kAllIn_InitialState, |
| 21 | kAllOut_InitialState, |
| 22 | }; |
| 23 | |
| 24 | /** |
| 25 | * This function takes a clip stack and a query rectangle and it produces a reduced set of |
commit-bot@chromium.org | d3e5842 | 2013-11-05 15:03:08 +0000 | [diff] [blame] | 26 | * SkClipStack::Elements that are equivalent to applying the full stack to the rectangle. The clip |
| 27 | * stack generation id that represents the list of elements is returned in resultGenID. The |
bsalomon@google.com | 170bd79 | 2012-12-05 22:26:11 +0000 | [diff] [blame] | 28 | * initial state of the query rectangle before the first clip element is applied is returned via |
bsalomon@google.com | 34cd70a | 2012-12-06 14:23:20 +0000 | [diff] [blame] | 29 | * initialState. Optionally, the caller can request a tighter bounds on the clip be returned via |
| 30 | * tighterBounds. If not NULL, tighterBounds will always be contained by queryBounds after return. |
| 31 | * If tighterBounds is specified then it is assumed that the caller will implicitly clip against it. |
| 32 | * If the caller specifies non-NULL for requiresAA then it will indicate whether anti-aliasing is |
| 33 | * required to process any of the elements in the result. |
| 34 | * |
| 35 | * This may become a member function of SkClipStack when its interface is determined to be stable. |
bsalomon@google.com | 4ebe382 | 2014-02-26 20:22:32 +0000 | [diff] [blame] | 36 | * Marked SK_API so that SkLua can call this in a shared library build. |
bsalomon@google.com | 170bd79 | 2012-12-05 22:26:11 +0000 | [diff] [blame] | 37 | */ |
bsalomon@google.com | 4ebe382 | 2014-02-26 20:22:32 +0000 | [diff] [blame] | 38 | SK_API void ReduceClipStack(const SkClipStack& stack, |
| 39 | const SkIRect& queryBounds, |
| 40 | ElementList* result, |
| 41 | int32_t* resultGenID, |
| 42 | InitialState* initialState, |
| 43 | SkIRect* tighterBounds = NULL, |
| 44 | bool* requiresAA = NULL); |
bsalomon@google.com | 170bd79 | 2012-12-05 22:26:11 +0000 | [diff] [blame] | 45 | |
| 46 | } // namespace GrReducedClip |
george | 9eb182a | 2014-06-20 12:01:06 -0700 | [diff] [blame] | 47 | |
| 48 | #endif |