blob: 3a7c173d5ec06ee44267021fcb605f941f1622dc [file] [log] [blame]
bsalomon@google.com170bd792012-12-05 22:26:11 +00001/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
george9eb182a2014-06-20 12:01:06 -07008#ifndef GrReducedClip_DEFINED
9#define GrReducedClip_DEFINED
10
bsalomon@google.com170bd792012-12-05 22:26:11 +000011#include "SkClipStack.h"
12#include "SkTLList.h"
13
tfarinabf54e492014-10-23 17:47:18 -070014class SK_API GrReducedClip {
15public:
bsalomonf045d602015-11-18 19:01:12 -080016 typedef SkTLList<SkClipStack::Element, 16> ElementList;
bsalomon@google.com170bd792012-12-05 22:26:11 +000017
tfarinabf54e492014-10-23 17:47:18 -070018 enum InitialState {
19 kAllIn_InitialState,
20 kAllOut_InitialState,
21 };
bsalomon@google.com170bd792012-12-05 22:26:11 +000022
tfarinabf54e492014-10-23 17:47:18 -070023 /**
24 * This function takes a clip stack and a query rectangle and it produces a
25 * reduced set of SkClipStack::Elements that are equivalent to applying the
26 * full stack to the rectangle. The clip stack generation id that represents
27 * the list of elements is returned in resultGenID. The initial state of the
28 * query rectangle before the first clip element is applied is returned via
29 * initialState. Optionally, the caller can request a tighter bounds on the
halcanary96fcdcc2015-08-27 07:41:13 -070030 * clip be returned via tighterBounds. If not nullptr, tighterBounds will
tfarinabf54e492014-10-23 17:47:18 -070031 * always be contained by queryBounds after return. If tighterBounds is
32 * specified then it is assumed that the caller will implicitly clip against
halcanary96fcdcc2015-08-27 07:41:13 -070033 * it. If the caller specifies non-nullptr for requiresAA then it will indicate
tfarinabf54e492014-10-23 17:47:18 -070034 * whether anti-aliasing is required to process any of the elements in the
35 * result.
36 *
37 * This may become a member function of SkClipStack when its interface is
38 * determined to be stable.
39 */
40 static void ReduceClipStack(const SkClipStack& stack,
41 const SkIRect& queryBounds,
42 ElementList* result,
43 int32_t* resultGenID,
44 InitialState* initialState,
halcanary96fcdcc2015-08-27 07:41:13 -070045 SkIRect* tighterBounds = nullptr,
46 bool* requiresAA = nullptr);
bsalomon@google.com170bd792012-12-05 22:26:11 +000047};
48
george9eb182a2014-06-20 12:01:06 -070049#endif