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 (m_saveAndRestore) | 47 if (m_saveAndRestore) |
48 m_context.save(); | 48 m_context.save(); |
49 } | 49 } |
50 | 50 |
51 ~GraphicsContextStateSaver() { | 51 ~GraphicsContextStateSaver() { |
52 if (m_saveAndRestore) | 52 if (m_saveAndRestore) |
53 m_context.restore(); | 53 m_context.restore(); |
54 } | 54 } |
55 | 55 |
56 void save() { | 56 void save() { |
57 ASSERT(!m_saveAndRestore); | 57 DCHECK(!m_saveAndRestore); |
58 m_context.save(); | 58 m_context.save(); |
59 m_saveAndRestore = true; | 59 m_saveAndRestore = 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(m_saveAndRestore); | 69 DCHECK(m_saveAndRestore); |
70 m_context.restore(); | 70 m_context.restore(); |
71 m_saveAndRestore = false; | 71 m_saveAndRestore = false; |
72 } | 72 } |
73 | 73 |
74 GraphicsContext& context() const { return m_context; } | 74 GraphicsContext& context() const { return m_context; } |
75 bool saved() const { return m_saveAndRestore; } | 75 bool saved() const { return m_saveAndRestore; } |
76 | 76 |
77 private: | 77 private: |
78 GraphicsContext& m_context; | 78 GraphicsContext& m_context; |
79 bool m_saveAndRestore; | 79 bool m_saveAndRestore; |
80 }; | 80 }; |
81 | 81 |
82 } // namespace blink | 82 } // namespace blink |
83 | 83 |
84 #endif // GraphicsContextStateSaver_h | 84 #endif // GraphicsContextStateSaver_h |
OLD | NEW |