Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "GrScissorState.h" |
| 13 #include "GrWindowRectsState.h" | |
| 13 | 14 |
| 14 /** | 15 /** |
| 15 * GrFixedClip is a clip that gets implemented by fixed-function hardware. | 16 * GrFixedClip is a clip that gets implemented by fixed-function hardware. |
| 16 */ | 17 */ |
| 17 class GrFixedClip final : public GrClip { | 18 class GrFixedClip final : public GrClip { |
| 18 public: | 19 public: |
| 19 GrFixedClip() = default; | 20 GrFixedClip() = default; |
| 20 explicit GrFixedClip(const SkIRect& scissorRect) : fScissorState(scissorRect ) {} | 21 explicit GrFixedClip(const SkIRect& scissorRect) : fScissorState(scissorRect ) {} |
| 21 | 22 |
| 22 const GrScissorState& scissorState() const { return fScissorState; } | 23 const GrScissorState& scissorState() const { return fScissorState; } |
| 23 bool scissorEnabled() const { return fScissorState.enabled(); } | 24 bool scissorEnabled() const { return fScissorState.enabled(); } |
| 24 const SkIRect& scissorRect() const { SkASSERT(scissorEnabled()); return fSci ssorState.rect(); } | 25 const SkIRect& scissorRect() const { SkASSERT(scissorEnabled()); return fSci ssorState.rect(); } |
| 25 | 26 |
| 26 void disableScissor() { fScissorState.setDisabled(); } | 27 void disableScissor() { fScissorState.setDisabled(); } |
| 27 | 28 |
| 28 bool SK_WARN_UNUSED_RESULT intersect(const SkIRect& irect) { | 29 bool SK_WARN_UNUSED_RESULT intersect(const SkIRect& irect) { |
| 29 return fScissorState.intersect(irect); | 30 return fScissorState.intersect(irect); |
| 30 } | 31 } |
| 31 | 32 |
| 32 bool quickContains(const SkRect& rect) const final { | 33 const GrWindowRectsState& windowRectsState() const { return fWindowRectsStat e; } |
| 33 return !fScissorState.enabled() || GrClip::IsInsideClip(fScissorState.re ct(), rect); | 34 GrWindowRectsState& windowRectsState() { return fWindowRectsState; } |
| 34 } | |
| 35 void getConservativeBounds(int width, int height, SkIRect* devResult, | |
| 36 bool* isIntersectionOfRects) const final; | |
| 37 | 35 |
| 38 bool isRRect(const SkRect& rtBounds, SkRRect* rr, bool* aa) const override { | 36 bool quickContains(const SkRect&) const final; |
| 39 if (fScissorState.enabled()) { | 37 void getConservativeBounds(int width, int height, SkIRect* devResult, bool* iior) const final; |
| 40 SkRect rect = SkRect::Make(fScissorState.rect()); | 38 bool isRRect(const SkRect& rtBounds, SkRRect* rr, bool* aa) const final; |
|
bsalomon
2016/08/31 14:00:52
I think I prefer "override" to "final" on these me
csmartdalton
2016/08/31 15:04:34
Done.
| |
| 41 if (!rect.intersects(rtBounds)) { | 39 bool apply(GrContext*, GrDrawContext*, bool, bool, GrAppliedClip* out) const final; |
| 42 return false; | |
| 43 } | |
| 44 rr->setRect(rect); | |
| 45 *aa = false; | |
| 46 return true; | |
| 47 } | |
| 48 return false; | |
| 49 }; | |
| 50 | |
| 51 bool apply(GrContext*, GrDrawContext*, bool useHWAA, bool hasUserStencilSett ings, | |
| 52 GrAppliedClip* out) const final; | |
| 53 | 40 |
| 54 static const GrFixedClip& Disabled(); | 41 static const GrFixedClip& Disabled(); |
| 55 | 42 |
| 56 private: | 43 private: |
| 57 GrScissorState fScissorState; | 44 GrScissorState fScissorState; |
| 45 GrWindowRectsState fWindowRectsState; | |
| 58 }; | 46 }; |
| 59 | 47 |
| 60 #endif | 48 #endif |
| OLD | NEW |