blob: e3a28cc0c573810db13522c3397aa34aaae41248 [file] [log] [blame]
bsalomon@google.com170bd792012-12-05 22:26:11 +00001
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
george9eb182a2014-06-20 12:01:06 -07009#ifndef GrReducedClip_DEFINED
10#define GrReducedClip_DEFINED
11
bsalomon@google.com170bd792012-12-05 22:26:11 +000012#include "SkClipStack.h"
13#include "SkTLList.h"
14
15namespace GrReducedClip {
16
17typedef SkTLList<SkClipStack::Element> ElementList;
18
19enum 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.orgd3e58422013-11-05 15:03:08 +000026 * 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.com170bd792012-12-05 22:26:11 +000028 * initial state of the query rectangle before the first clip element is applied is returned via
bsalomon@google.com34cd70a2012-12-06 14:23:20 +000029 * 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.com4ebe3822014-02-26 20:22:32 +000036 * Marked SK_API so that SkLua can call this in a shared library build.
bsalomon@google.com170bd792012-12-05 22:26:11 +000037 */
bsalomon@google.com4ebe3822014-02-26 20:22:32 +000038SK_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.com170bd792012-12-05 22:26:11 +000045
46} // namespace GrReducedClip
george9eb182a2014-06-20 12:01:06 -070047
48#endif