blob: 0b79f2c7f56f266c3b9683dc70e678e5ba819b1b [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
9#include "SkClipStack.h"
10#include "SkTLList.h"
11
12namespace GrReducedClip {
13
14typedef SkTLList<SkClipStack::Element> ElementList;
15
16enum InitialState {
17 kAllIn_InitialState,
18 kAllOut_InitialState,
19};
20
21/**
22 * 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 +000023 * SkClipStack::Elements that are equivalent to applying the full stack to the rectangle. The clip
24 * stack generation id that represents the list of elements is returned in resultGenID. The
bsalomon@google.com170bd792012-12-05 22:26:11 +000025 * initial state of the query rectangle before the first clip element is applied is returned via
bsalomon@google.com34cd70a2012-12-06 14:23:20 +000026 * initialState. Optionally, the caller can request a tighter bounds on the clip be returned via
27 * tighterBounds. If not NULL, tighterBounds will always be contained by queryBounds after return.
28 * If tighterBounds is specified then it is assumed that the caller will implicitly clip against it.
29 * If the caller specifies non-NULL for requiresAA then it will indicate whether anti-aliasing is
30 * required to process any of the elements in the result.
31 *
32 * This may become a member function of SkClipStack when its interface is determined to be stable.
bsalomon@google.com170bd792012-12-05 22:26:11 +000033 */
bsalomon@google.com34cd70a2012-12-06 14:23:20 +000034void ReduceClipStack(const SkClipStack& stack,
35 const SkIRect& queryBounds,
36 ElementList* result,
commit-bot@chromium.orgd3e58422013-11-05 15:03:08 +000037 int32_t* resultGenID,
bsalomon@google.com34cd70a2012-12-06 14:23:20 +000038 InitialState* initialState,
39 SkIRect* tighterBounds = NULL,
40 bool* requiresAA = NULL);
bsalomon@google.com170bd792012-12-05 22:26:11 +000041
42} // namespace GrReducedClip