Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: src/gpu/GrAppliedClip.h

Issue 2251573002: Implement difference clip rects with window rectangles (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: return type Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 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
8 #ifndef GrAppliedClip_DEFINED
9 #define GrAppliedClip_DEFINED
10
11 #include "GrTypesPriv.h"
12 #include "GrWindowRectangles.h"
13
14 class GrFragmentProcessor;
15
16 /**
17 * Produced by GrClip. It provides a set of modifications to the drawing state t hat are used to
18 * create the final GrPipeline for a GrBatch.
19 */
20 class GrAppliedClip : public SkNoncopyable {
21 public:
22 GrAppliedClip(const SkRect& drawBounds)
23 : fHasStencilClip(false)
24 , fClippedDrawBounds(drawBounds) {
25 }
26
27 const GrScissorState& scissorState() const { return fScissorState; }
28 const GrWindowRectangles& windowRects() const { return fWindowRects; }
29 GrFragmentProcessor* clipCoverageFragmentProcessor() const { return fClipCov erageFP.get(); }
30 bool hasStencilClip() const { return fHasStencilClip; }
31
32 /**
33 * Intersects the applied clip with the provided rect. Returns false if the draw became empty.
34 */
35 bool addScissor(const SkIRect& irect) {
36 return fScissorState.intersect(irect) && fClippedDrawBounds.intersect(Sk Rect::Make(irect));
37 }
38
39 /**
40 * Adds an exclusive window rectangle to the clip. It is not currently suppo rted to switch the
41 * windows to inclusive mode.
42 */
43 void addWindowRectangle(const SkIRect& window) {
44 fWindowRects.addWindow(window);
45 }
46
47 void addCoverageFP(sk_sp<GrFragmentProcessor> fp) {
48 SkASSERT(!fClipCoverageFP);
49 fClipCoverageFP = fp;
50 }
51
52 void addStencilClip() {
53 SkASSERT(!fHasStencilClip);
54 fHasStencilClip = true;
55 }
56
57 /**
58 * Returns the device bounds of the draw after clip has been applied. TODO: Ideally this would
59 * consider the combined effect of all clipping techniques in play (scissor, stencil, fp, etc.).
60 */
61 const SkRect& clippedDrawBounds() const { return fClippedDrawBounds; }
62
63 private:
64 GrScissorState fScissorState;
65 GrWindowRectangles fWindowRects;
66 sk_sp<GrFragmentProcessor> fClipCoverageFP;
67 bool fHasStencilClip;
68 SkRect fClippedDrawBounds;
69 typedef SkNoncopyable INHERITED;
70 };
71
72 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrClip.h ('k') | src/gpu/GrCaps.cpp » ('j') | src/gpu/GrCaps.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698