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

Side by Side Diff: include/gpu/GrClip.h

Issue 2254343003: Move GrFixedClip into src directory (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
« no previous file with comments | « gyp/gpu.gypi ('k') | src/core/SkImageFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "SkRect.h"
12 #include "GrTypesPriv.h" 12 #include "SkRRect.h"
13 13
14 class GrAppliedClip; 14 class GrAppliedClip;
15 class GrContext;
15 class GrDrawContext; 16 class GrDrawContext;
16 17
17 /** 18 /**
18 * GrClip is an abstract base class for applying a clip. It constructs a clip ma sk if necessary, and 19 * GrClip is an abstract base class for applying a clip. It constructs a clip ma sk if necessary, and
19 * fills out a GrAppliedClip instructing the caller on how to set up the draw st ate. 20 * fills out a GrAppliedClip instructing the caller on how to set up the draw st ate.
20 */ 21 */
21 class GrClip { 22 class GrClip {
22 public: 23 public:
23 virtual bool quickContains(const SkRect&) const = 0; 24 virtual bool quickContains(const SkRect&) const = 0;
24 virtual bool quickContains(const SkRRect& rrect) const { 25 virtual bool quickContains(const SkRRect& rrect) const {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 SkScalarAbs(SkScalarRoundToScalar(rect.fRight) - rect.fRight) <= kBoundsTolerance && 102 SkScalarAbs(SkScalarRoundToScalar(rect.fRight) - rect.fRight) <= kBoundsTolerance &&
102 SkScalarAbs(SkScalarRoundToScalar(rect.fBottom) - rect.fBottom) < = kBoundsTolerance; 103 SkScalarAbs(SkScalarRoundToScalar(rect.fBottom) - rect.fBottom) < = kBoundsTolerance;
103 } 104 }
104 }; 105 };
105 106
106 /** 107 /**
107 * Specialized implementation for no clip. 108 * Specialized implementation for no clip.
108 */ 109 */
109 class GrNoClip final : public GrClip { 110 class GrNoClip final : public GrClip {
110 private: 111 private:
111 bool quickContains(const SkRect&) const final { return true; } 112 bool quickContains(const SkRect&) const final {
113 return true;
114 }
112 void getConservativeBounds(int width, int height, SkIRect* devResult, 115 void getConservativeBounds(int width, int height, SkIRect* devResult,
113 bool* isIntersectionOfRects) const final; 116 bool* isIntersectionOfRects) const final {
114 bool apply(GrContext*, GrDrawContext*, bool, bool, GrAppliedClip*) const fin al { return true; } 117 devResult->setXYWH(0, 0, width, height);
115 }; 118 if (isIntersectionOfRects) {
116 119 *isIntersectionOfRects = true;
117 /** 120 }
118 * GrFixedClip is a clip that can be represented by fixed-function hardware. It never modifies the
119 * stencil buffer itself, but can be configured to use whatever clip is already there.
120 */
121 class GrFixedClip final : public GrClip {
122 public:
123 GrFixedClip() : fHasStencilClip(false) {}
124 GrFixedClip(const SkIRect& scissorRect)
125 : fScissorState(scissorRect)
126 , fHasStencilClip(false) {}
127
128 void reset() {
129 fScissorState.setDisabled();
130 fHasStencilClip = false;
131 } 121 }
132 122 bool apply(GrContext*, GrDrawContext*, bool, bool, GrAppliedClip*) const fin al {
133 void reset(const SkIRect& scissorRect) { 123 return true;
134 fScissorState.set(scissorRect);
135 fHasStencilClip = false;
136 } 124 }
137
138 void enableStencilClip() { fHasStencilClip = true; }
139 void disableStencilClip() { fHasStencilClip = false; }
140
141 bool quickContains(const SkRect&) const final;
142 void getConservativeBounds(int width, int height, SkIRect* devResult,
143 bool* isIntersectionOfRects) const final;
144
145 private:
146 bool apply(GrContext*, GrDrawContext*, bool useHWAA, bool hasUserStencilSett ings,
147 GrAppliedClip* out) const final;
148
149 GrScissorState fScissorState;
150 bool fHasStencilClip;
151 }; 125 };
152 126
153 #endif 127 #endif
OLDNEW
« no previous file with comments | « gyp/gpu.gypi ('k') | src/core/SkImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698