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

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

Issue 2262473003: Define clear regions in terms of GrFixedClip (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_fixedcliptosrc
Patch Set: rebase Created 4 years, 3 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 | « src/gpu/GrDrawTarget.cpp ('k') | src/gpu/GrFixedClip.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 2016 Google Inc. 2 * Copyright 2016 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 GrFixedClip_DEFINED 8 #ifndef GrFixedClip_DEFINED
9 #define GrFixedClip_DEFINED 9 #define GrFixedClip_DEFINED
10 10
11 #include "GrClip.h" 11 #include "GrClip.h"
12 #include "GrTypesPriv.h" 12 #include "GrTypesPriv.h"
13 13
14 /** 14 /**
15 * GrFixedClip is a clip that can be represented by fixed-function hardware. It never modifies the 15 * GrFixedClip is a clip that gets implemented by fixed-function hardware.
16 * stencil buffer itself, but can be configured to use whatever clip is already there.
17 */ 16 */
18 class GrFixedClip final : public GrClip { 17 class GrFixedClip final : public GrClip {
19 public: 18 public:
20 GrFixedClip() : fHasStencilClip(false) {} 19 GrFixedClip() = default;
21 GrFixedClip(const SkIRect& scissorRect) 20 explicit GrFixedClip(const SkIRect& scissorRect) : fScissorState(scissorRect ) {}
22 : fScissorState(scissorRect)
23 , fHasStencilClip(false) {}
24 21
25 void reset() { 22 const GrScissorState& scissorState() const { return fScissorState; }
26 fScissorState.setDisabled(); 23 bool scissorEnabled() const { return fScissorState.enabled(); }
27 fHasStencilClip = false; 24 const SkIRect& scissorRect() const { SkASSERT(scissorEnabled()); return fSci ssorState.rect(); }
25
26 void disableScissor() { fScissorState.setDisabled(); }
27
28 bool SK_WARN_UNUSED_RESULT intersect(const SkIRect& irect) {
29 return fScissorState.intersect(irect);
28 } 30 }
29 31
30 void reset(const SkIRect& scissorRect) { 32 bool quickContains(const SkRect& rect) const final {
31 fScissorState.set(scissorRect); 33 return !fScissorState.enabled() || GrClip::IsInsideClip(fScissorState.re ct(), rect);
32 fHasStencilClip = false;
33 } 34 }
34
35 void enableStencilClip() { fHasStencilClip = true; }
36 void disableStencilClip() { fHasStencilClip = false; }
37
38 bool quickContains(const SkRect&) const final;
39 void getConservativeBounds(int width, int height, SkIRect* devResult, 35 void getConservativeBounds(int width, int height, SkIRect* devResult,
40 bool* isIntersectionOfRects) const final; 36 bool* isIntersectionOfRects) const final;
41 37
42 bool isRRect(const SkRect& rtBounds, SkRRect* rr, bool* aa) const override { 38 bool isRRect(const SkRect& rtBounds, SkRRect* rr, bool* aa) const override {
43 if (fHasStencilClip) {
44 return false;
45 }
46 if (fScissorState.enabled()) { 39 if (fScissorState.enabled()) {
47 SkRect rect = SkRect::Make(fScissorState.rect()); 40 SkRect rect = SkRect::Make(fScissorState.rect());
48 if (!rect.intersects(rtBounds)) { 41 if (!rect.intersects(rtBounds)) {
49 return false; 42 return false;
50 } 43 }
51 rr->setRect(rect); 44 rr->setRect(rect);
52 *aa = false; 45 *aa = false;
53 return true; 46 return true;
54 } 47 }
55 return false; 48 return false;
56 }; 49 };
57 50
58 private:
59 bool apply(GrContext*, GrDrawContext*, bool useHWAA, bool hasUserStencilSett ings, 51 bool apply(GrContext*, GrDrawContext*, bool useHWAA, bool hasUserStencilSett ings,
60 GrAppliedClip* out) const final; 52 GrAppliedClip* out) const final;
61 53
54 static const GrFixedClip& Disabled();
55
56 private:
62 GrScissorState fScissorState; 57 GrScissorState fScissorState;
63 bool fHasStencilClip;
64 }; 58 };
65 59
66 #endif 60 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrDrawTarget.cpp ('k') | src/gpu/GrFixedClip.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698