diff options
author | csmartdalton <csmartdalton@google.com> | 2016-08-05 22:32:12 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-05 22:32:12 -0700 |
commit | c6f411e72b1fea6608f540f64a57bcacbe3378cd (patch) | |
tree | 73771d2a0b8b11fbc632879daaaf01cabfde288d /src/gpu/GrClipStackClip.h | |
parent | 4c1abdcd21d65bb34a6b4aea969ef4485e117e67 (diff) |
Merge GrClipMaskManager into GrClipStackClip
TBR=bsalomon@google.com
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2196393007
Review-Url: https://codereview.chromium.org/2196393007
Diffstat (limited to 'src/gpu/GrClipStackClip.h')
-rw-r--r-- | src/gpu/GrClipStackClip.h | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/src/gpu/GrClipStackClip.h b/src/gpu/GrClipStackClip.h new file mode 100644 index 0000000000..38f9e2d671 --- /dev/null +++ b/src/gpu/GrClipStackClip.h @@ -0,0 +1,91 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#ifndef GrClipStackClip_DEFINED +#define GrClipStackClip_DEFINED + +#include "GrClip.h" + +#include "GrReducedClip.h" +#include "SkClipStack.h" + +class GrTextureProvider; +class GrPathRenderer; + +/** + * GrClipStackClip can apply a generic SkClipStack to the draw state. It may need to generate an + * 8-bit alpha clip mask and/or modify the stencil buffer during apply(). + */ +class GrClipStackClip final : public GrClip { +public: + GrClipStackClip(const SkClipStack* stack = nullptr, const SkIPoint* origin = nullptr) { + this->reset(stack, origin); + } + + void reset(const SkClipStack* stack = nullptr, const SkIPoint* origin = nullptr) { + fOrigin = origin ? *origin : SkIPoint::Make(0, 0); + fStack.reset(SkSafeRef(stack)); + } + + bool quickContains(const SkRect&) const final; + void getConservativeBounds(int width, int height, SkIRect* devResult, + bool* isIntersectionOfRects) const final; + bool apply(GrContext*, + GrDrawContext*, + const SkRect* devBounds, + bool useHWAA, + bool hasUserStencilSettings, + GrAppliedClip* out) const final; + +private: + static bool PathNeedsSWRenderer(GrContext* context, + bool hasUserStencilSettings, + const GrDrawContext*, + const SkMatrix& viewMatrix, + const SkClipStack::Element* element, + GrPathRenderer** prOut, + bool needsStencil); + + // Draws the clip into the stencil buffer + static bool CreateStencilClipMask(GrContext*, + GrDrawContext*, + int32_t elementsGenID, + GrReducedClip::InitialState initialState, + const GrReducedClip::ElementList& elements, + const SkIRect& clipSpaceIBounds, + const SkIPoint& clipSpaceToStencilOffset); + + // Creates an alpha mask of the clip. The mask is a rasterization of elements through the + // rect specified by clipSpaceIBounds. + static sk_sp<GrTexture> CreateAlphaClipMask(GrContext*, + int32_t elementsGenID, + GrReducedClip::InitialState initialState, + const GrReducedClip::ElementList& elements, + const SkVector& clipToMaskOffset, + const SkIRect& clipSpaceIBounds); + + // Similar to createAlphaClipMask but it rasterizes in SW and uploads to the result texture. + static sk_sp<GrTexture> CreateSoftwareClipMask(GrTextureProvider*, + int32_t elementsGenID, + GrReducedClip::InitialState initialState, + const GrReducedClip::ElementList& elements, + const SkVector& clipToMaskOffset, + const SkIRect& clipSpaceIBounds); + + static bool UseSWOnlyPath(GrContext*, + bool hasUserStencilSettings, + const GrDrawContext*, + const SkVector& clipToMaskOffset, + const GrReducedClip::ElementList& elements); + + static GrTexture* CreateCachedMask(int width, int height, const GrUniqueKey& key, + bool renderTarget); + + SkIPoint fOrigin; + SkAutoTUnref<const SkClipStack> fStack; +}; + +#endif // GrClipStackClip_DEFINED |