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

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

Issue 2289363005: Improve usage of window rectangles (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_drawsinreducedclip
Patch Set: Improve usage of window rectangles 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
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef GrWindowRectsState_DEFINED
9 #define GrWindowRectsState_DEFINED
10
11 #include "GrWindowRectangles.h"
12
13 class GrWindowRectsState {
14 public:
15 enum class Mode : bool {
16 kExclusive,
17 kInclusive
18 };
19
20 GrWindowRectsState() : fMode(Mode::kExclusive) {}
21 GrWindowRectsState(const GrWindowRectangles& windows, const SkIPoint& origin , Mode mode)
22 : fMode(mode)
23 , fOrigin(origin)
24 , fWindows(windows) {
25 }
26
27 Mode mode() const { return fMode; }
28 const SkIPoint& origin() const { return fOrigin; }
29 const GrWindowRectangles& windows() const { return fWindows; }
30 int numWindows() const { return fWindows.count(); }
31 bool disabled() const { return Mode::kExclusive == fMode && !fWindows.count( ); }
32
33 void setDisabled() {
34 fMode = Mode::kExclusive;
35 fWindows.reset();
36 }
37 void setExclusive(const GrWindowRectangles& windows, const SkIPoint& origin) {
38 this->set(windows, origin, Mode::kExclusive);
39 }
40 void setInclusive(const GrWindowRectangles& windows, const SkIPoint& origin) {
41 this->set(windows, origin, Mode::kInclusive);
42 }
43 void set(const GrWindowRectangles& windows, const SkIPoint& origin, Mode mod e) {
44 fMode = mode;
45 fOrigin = origin;
46 fWindows = windows;
47 }
48
49 bool cheapEqualTo(const GrWindowRectsState& that) const {
50 if (fMode != that.fMode) {
51 return false;
52 }
53 if (!fWindows.empty() && fOrigin != that.fOrigin) {
54 return false;
55 }
56 return fWindows == that.fWindows;
57 }
58
59 private:
60 Mode fMode;
61 SkIPoint fOrigin;
62 GrWindowRectangles fWindows;
63 };
64
65 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698