blob: 8058c3b8a49015799f80be77993e36c897402401 [file] [log] [blame]
robertphillips@google.com1e945b72012-04-16 18:03:03 +00001/*
csmartdaltonc6f411e2016-08-05 22:32:12 -07002 * Copyright 2016 Google Inc.
robertphillips@google.com1e945b72012-04-16 18:03:03 +00003 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
csmartdaltonc6f411e2016-08-05 22:32:12 -07007#ifndef GrClipStackClip_DEFINED
8#define GrClipStackClip_DEFINED
9
10#include "GrClip.h"
bsalomon@google.com4c2443e2012-12-06 20:58:57 +000011#include "GrReducedClip.h"
robertphillips@google.com641f8b12012-07-31 19:15:58 +000012#include "SkClipStack.h"
robertphillips@google.com1fcc1b82012-08-29 12:52:05 +000013
csmartdaltonc6f411e2016-08-05 22:32:12 -070014class GrPathRenderer;
Robert Phillips875218e2017-02-24 08:37:13 -050015class GrTextureProxy;
bsalomon0ba8c242015-10-07 09:20:28 -070016
17/**
csmartdaltonc6f411e2016-08-05 22:32:12 -070018 * GrClipStackClip can apply a generic SkClipStack to the draw state. It may need to generate an
19 * 8-bit alpha clip mask and/or modify the stencil buffer during apply().
robertphillips@google.com1e945b72012-04-16 18:03:03 +000020 */
csmartdaltonc6f411e2016-08-05 22:32:12 -070021class GrClipStackClip final : public GrClip {
robertphillips@google.com1e945b72012-04-16 18:03:03 +000022public:
Brian Salomon9a767722017-03-13 17:57:28 -040023 GrClipStackClip(const SkClipStack* stack = nullptr) { this->reset(stack); }
csmartdaltonc6f411e2016-08-05 22:32:12 -070024
Brian Salomon9a767722017-03-13 17:57:28 -040025 void reset(const SkClipStack* stack) { fStack = stack; }
csmartdaltonc6f411e2016-08-05 22:32:12 -070026
27 bool quickContains(const SkRect&) const final;
bsalomon7f0d9f32016-08-15 14:49:10 -070028 bool quickContains(const SkRRect&) const final;
csmartdaltonc6f411e2016-08-05 22:32:12 -070029 void getConservativeBounds(int width, int height, SkIRect* devResult,
30 bool* isIntersectionOfRects) const final;
Brian Osman11052242016-10-27 14:47:55 -040031 bool apply(GrContext*, GrRenderTargetContext*, bool useHWAA, bool hasUserStencilSettings,
Brian Salomon97180af2017-03-14 13:42:58 -040032 GrAppliedClip* out, SkRect* bounds) const final;
robertphillips391395d2016-03-02 09:26:36 -080033
Brian Salomon0e8fc8b2016-12-09 15:10:07 -050034 bool isRRect(const SkRect& rtBounds, SkRRect* rr, GrAA* aa) const override;
bsalomoncb31e512016-08-26 10:48:19 -070035
Robert Phillips875218e2017-02-24 08:37:13 -050036 sk_sp<GrTextureProxy> testingOnly_createClipMask(GrContext*) const;
Brian Salomon19f0ed52017-01-06 13:54:58 -050037 static const char kMaskTestTag[];
38
bsalomon@google.coma3201942012-06-21 19:58:20 +000039private:
robertphillips68737822015-10-29 12:12:21 -070040 static bool PathNeedsSWRenderer(GrContext* context,
cdalton93a379b2016-05-11 13:58:08 -070041 bool hasUserStencilSettings,
Brian Osman11052242016-10-27 14:47:55 -040042 const GrRenderTargetContext*,
robertphillips68737822015-10-29 12:12:21 -070043 const SkMatrix& viewMatrix,
44 const SkClipStack::Element* element,
45 GrPathRenderer** prOut,
46 bool needsStencil);
commit-bot@chromium.orge5a041c2014-03-07 19:43:43 +000047
bsalomon@google.com4c2443e2012-12-06 20:58:57 +000048 // Creates an alpha mask of the clip. The mask is a rasterization of elements through the
49 // rect specified by clipSpaceIBounds.
Robert Phillips875218e2017-02-24 08:37:13 -050050 sk_sp<GrTextureProxy> createAlphaClipMask(GrContext*, const GrReducedClip&) const;
joshualitt9853cce2014-11-17 14:22:48 -080051
bsalomon@google.com4c2443e2012-12-06 20:58:57 +000052 // Similar to createAlphaClipMask but it rasterizes in SW and uploads to the result texture.
Robert Phillips875218e2017-02-24 08:37:13 -050053 sk_sp<GrTextureProxy> createSoftwareClipMask(GrContext*, const GrReducedClip&) const;
robertphillips@google.comf294b772012-04-27 14:29:26 +000054
Brian Salomon19f0ed52017-01-06 13:54:58 -050055 static bool UseSWOnlyPath(GrContext*,
56 bool hasUserStencilSettings,
57 const GrRenderTargetContext*,
58 const GrReducedClip&);
csmartdaltonc6f411e2016-08-05 22:32:12 -070059
Mike Reed7ba4d712017-03-10 00:21:52 -050060 const SkClipStack* fStack;
robertphillips@google.com1e945b72012-04-16 18:03:03 +000061};
robertphillips976f5f02016-06-03 10:59:20 -070062
csmartdaltonc6f411e2016-08-05 22:32:12 -070063#endif // GrClipStackClip_DEFINED