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

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: Define clear regions in terms of GrFixedClip 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 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
42 private:
43 bool apply(GrContext*, GrDrawContext*, bool useHWAA, bool hasUserStencilSett ings, 37 bool apply(GrContext*, GrDrawContext*, bool useHWAA, bool hasUserStencilSett ings,
44 GrAppliedClip* out) const final; 38 GrAppliedClip* out) const final;
45 39
40 static const GrFixedClip& Disabled();
41
42 private:
46 GrScissorState fScissorState; 43 GrScissorState fScissorState;
47 bool fHasStencilClip;
48 }; 44 };
49 45
50 #endif 46 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698