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

Side by Side Diff: include/gpu/GrClip.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
1 /* 1 /*
2 * Copyright 2010 Google Inc. 2 * Copyright 2010 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrClip_DEFINED 8 #ifndef GrClip_DEFINED
9 #define GrClip_DEFINED 9 #define GrClip_DEFINED
10 10
11 #include "GrFragmentProcessor.h" 11 #include "GrFragmentProcessor.h"
12 #include "GrTypesPriv.h" 12 #include "GrTypesPriv.h"
13 13
14 class GrAppliedClip;
14 class GrDrawContext; 15 class GrDrawContext;
15 16
16 /** 17 /**
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 GrFragmentProcessor* clipCoverageFragmentProcessor() const { return fClipCov erageFP.get(); }
29 bool hasStencilClip() const { return fHasStencilClip; }
30
31 /**
32 * Intersects the applied clip with the provided rect. Returns false if the draw became empty.
33 */
34 bool addScissor(const SkIRect& irect) {
35 return fScissorState.intersect(irect) && fClippedDrawBounds.intersect(Sk Rect::Make(irect));
36 }
37
38 void addCoverageFP(sk_sp<GrFragmentProcessor> fp) {
39 SkASSERT(!fClipCoverageFP);
40 fClipCoverageFP = fp;
41 }
42
43 void addStencilClip() {
44 SkASSERT(!fHasStencilClip);
45 fHasStencilClip = true;
46 }
47
48 /**
49 * Returns the device bounds of the draw after clip has been applied. TODO: Ideally this would
50 * consider the combined effect of all clipping techniques in play (scissor, stencil, fp, etc.).
51 */
52 const SkRect& clippedDrawBounds() const { return fClippedDrawBounds; }
53
54 private:
55 GrScissorState fScissorState;
56 sk_sp<GrFragmentProcessor> fClipCoverageFP;
57 bool fHasStencilClip;
58 SkRect fClippedDrawBounds;
59 typedef SkNoncopyable INHERITED;
60 };
61
62 /**
63 * GrClip is an abstract base class for applying a clip. It constructs a clip ma sk if necessary, and 18 * GrClip is an abstract base class for applying a clip. It constructs a clip ma sk if necessary, and
64 * fills out a GrAppliedClip instructing the caller on how to set up the draw st ate. 19 * fills out a GrAppliedClip instructing the caller on how to set up the draw st ate.
65 */ 20 */
66 class GrClip { 21 class GrClip {
67 public: 22 public:
68 virtual bool quickContains(const SkRect&) const = 0; 23 virtual bool quickContains(const SkRect&) const = 0;
69 virtual bool quickContains(const SkRRect& rrect) const { 24 virtual bool quickContains(const SkRRect& rrect) const {
70 return this->quickContains(rrect.getBounds()); 25 return this->quickContains(rrect.getBounds());
71 } 26 }
72 virtual void getConservativeBounds(int width, int height, SkIRect* devResult , 27 virtual void getConservativeBounds(int width, int height, SkIRect* devResult ,
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 144
190 private: 145 private:
191 bool apply(GrContext*, GrDrawContext*, bool useHWAA, bool hasUserStencilSett ings, 146 bool apply(GrContext*, GrDrawContext*, bool useHWAA, bool hasUserStencilSett ings,
192 GrAppliedClip* out) const final; 147 GrAppliedClip* out) const final;
193 148
194 GrScissorState fScissorState; 149 GrScissorState fScissorState;
195 bool fHasStencilClip; 150 bool fHasStencilClip;
196 }; 151 };
197 152
198 #endif 153 #endif
OLDNEW
« no previous file with comments | « gyp/gpu.gypi ('k') | src/gpu/GrAppliedClip.h » ('j') | src/gpu/GrCaps.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698