OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef GraphicsContextRecorder_h |
| 6 #define GraphicsContextRecorder_h |
| 7 |
| 8 #include "core/paint/ClipRecorder.h" |
| 9 #include "platform/RuntimeEnabledFeatures.h" |
| 10 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 class GraphicsContextRecorder { |
| 15 STACK_ALLOCATED(); |
| 16 public: |
| 17 static GraphicsContextRecorder& currentRecorder() { return *s_currentRecorde
r; } |
| 18 |
| 19 GraphicsContextRecorder(GraphicsContext& context, bool saveAndRestore = true
) |
| 20 : m_stateSaver(context, saveAndRestore) |
| 21 , m_parent(s_currentRecorder) |
| 22 { |
| 23 s_currentRecorder = this; |
| 24 } |
| 25 |
| 26 ~GraphicsContextRecorder() |
| 27 { |
| 28 ASSERT(s_currentRecorder == this); |
| 29 s_currentRecorder = m_parent; |
| 30 } |
| 31 |
| 32 void addClipRecorder(PassOwnPtr<ClipRecorder> clipRecorder) |
| 33 { |
| 34 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
| 35 m_clipRecorders.append(clipRecorder); |
| 36 } |
| 37 private: |
| 38 GraphicsContextStateSaver m_stateSaver; |
| 39 GraphicsContextRecorder* m_parent; |
| 40 Vector<OwnPtr<ClipRecorder>> m_clipRecorders; |
| 41 |
| 42 static GraphicsContextRecorder* s_currentRecorder; |
| 43 }; |
| 44 |
| 45 } // namespace blink |
| 46 |
| 47 #endif // GraphicsContextRecorder_h |
OLD | NEW |