OLD | NEW |
1 // Copyright (C) 2013 Google Inc. All rights reserved. | 1 // Copyright (C) 2013 Google Inc. All rights reserved. |
2 // | 2 // |
3 // Redistribution and use in source and binary forms, with or without | 3 // Redistribution and use in source and binary forms, with or without |
4 // modification, are permitted provided that the following conditions are | 4 // modification, are permitted provided that the following conditions are |
5 // met: | 5 // met: |
6 // | 6 // |
7 // * Redistributions of source code must retain the above copyright | 7 // * Redistributions of source code must retain the above copyright |
8 // notice, this list of conditions and the following disclaimer. | 8 // notice, this list of conditions and the following disclaimer. |
9 // * Redistributions in binary form must reproduce the above | 9 // * Redistributions in binary form must reproduce the above |
10 // copyright notice, this list of conditions and the following disclaimer | 10 // copyright notice, this list of conditions and the following disclaimer |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 if (save_and_restore_) | 47 if (save_and_restore_) |
48 context_.Save(); | 48 context_.Save(); |
49 } | 49 } |
50 | 50 |
51 ~GraphicsContextStateSaver() { | 51 ~GraphicsContextStateSaver() { |
52 if (save_and_restore_) | 52 if (save_and_restore_) |
53 context_.Restore(); | 53 context_.Restore(); |
54 } | 54 } |
55 | 55 |
56 void Save() { | 56 void Save() { |
57 ASSERT(!save_and_restore_); | 57 DCHECK(!save_and_restore_); |
58 context_.Save(); | 58 context_.Save(); |
59 save_and_restore_ = true; | 59 save_and_restore_ = true; |
60 } | 60 } |
61 | 61 |
62 void SaveIfNeeded() { | 62 void SaveIfNeeded() { |
63 if (Saved()) | 63 if (Saved()) |
64 return; | 64 return; |
65 Save(); | 65 Save(); |
66 } | 66 } |
67 | 67 |
68 void Restore() { | 68 void Restore() { |
69 ASSERT(save_and_restore_); | 69 DCHECK(save_and_restore_); |
70 context_.Restore(); | 70 context_.Restore(); |
71 save_and_restore_ = false; | 71 save_and_restore_ = false; |
72 } | 72 } |
73 | 73 |
74 GraphicsContext& Context() const { return context_; } | 74 GraphicsContext& Context() const { return context_; } |
75 bool Saved() const { return save_and_restore_; } | 75 bool Saved() const { return save_and_restore_; } |
76 | 76 |
77 private: | 77 private: |
78 GraphicsContext& context_; | 78 GraphicsContext& context_; |
79 bool save_and_restore_; | 79 bool save_and_restore_; |
80 }; | 80 }; |
81 | 81 |
82 } // namespace blink | 82 } // namespace blink |
83 | 83 |
84 #endif // GraphicsContextStateSaver_h | 84 #endif // GraphicsContextStateSaver_h |
OLD | NEW |