| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ScopedPaintChunkProperties_h | 5 #ifndef ScopedPaintChunkProperties_h |
| 6 #define ScopedPaintChunkProperties_h | 6 #define ScopedPaintChunkProperties_h |
| 7 | 7 |
| 8 #include "platform/graphics/paint/DisplayItem.h" | |
| 9 #include "platform/graphics/paint/PaintChunk.h" | |
| 10 #include "platform/graphics/paint/PaintChunkProperties.h" | 8 #include "platform/graphics/paint/PaintChunkProperties.h" |
| 11 #include "platform/graphics/paint/PaintController.h" | 9 #include "platform/graphics/paint/PaintController.h" |
| 12 #include "wtf/Allocator.h" | 10 #include "wtf/Allocator.h" |
| 13 #include "wtf/Noncopyable.h" | 11 #include "wtf/Noncopyable.h" |
| 14 | 12 |
| 15 namespace blink { | 13 namespace blink { |
| 16 | 14 |
| 17 class ScopedPaintChunkProperties { | 15 class ScopedPaintChunkProperties { |
| 18 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 16 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 19 WTF_MAKE_NONCOPYABLE(ScopedPaintChunkProperties); | 17 WTF_MAKE_NONCOPYABLE(ScopedPaintChunkProperties); |
| 20 public: | 18 public: |
| 21 ScopedPaintChunkProperties(PaintController& paintController, const DisplayIt
emClient& client, DisplayItem::Type type, const PaintChunkProperties& properties
) | 19 ScopedPaintChunkProperties(PaintController& paintController, const PaintChun
kProperties& properties) |
| 22 : m_paintController(paintController) | 20 : m_paintController(paintController) |
| 23 , m_previousProperties(paintController.currentPaintChunkProperties()) | 21 , m_previousProperties(paintController.currentPaintChunkProperties()) |
| 24 { | 22 { |
| 25 PaintChunk::Id id(client, type); | 23 m_paintController.updateCurrentPaintChunkProperties(properties); |
| 26 m_paintController.updateCurrentPaintChunkProperties(&id, properties); | |
| 27 } | 24 } |
| 28 | 25 |
| 29 // Omits the type parameter, in case that the client creates only one PaintC
hunkProperties node during each painting. | |
| 30 ScopedPaintChunkProperties(PaintController& paintController, const DisplayIt
emClient& client, const PaintChunkProperties& properties) | |
| 31 : ScopedPaintChunkProperties(paintController, client, DisplayItem::Unini
tializedType, properties) | |
| 32 { } | |
| 33 | |
| 34 ~ScopedPaintChunkProperties() | 26 ~ScopedPaintChunkProperties() |
| 35 { | 27 { |
| 36 // We should not return to the previous id, because that may cause a new
chunk to use | 28 m_paintController.updateCurrentPaintChunkProperties(m_previousProperties
); |
| 37 // the same id as that of the previous chunk before this ScopedPaintChun
kProperties. | |
| 38 // The painter should create another scope of paint properties with new
id, or the | |
| 39 // new chunk will have no id and will not match any old chunk and will b
e treated as | |
| 40 // fully invalidated for rasterization. | |
| 41 m_paintController.updateCurrentPaintChunkProperties(nullptr, m_previousP
roperties); | |
| 42 } | 29 } |
| 43 | 30 |
| 44 private: | 31 private: |
| 45 PaintController& m_paintController; | 32 PaintController& m_paintController; |
| 46 PaintChunkProperties m_previousProperties; | 33 PaintChunkProperties m_previousProperties; |
| 47 }; | 34 }; |
| 48 | 35 |
| 49 } // namespace blink | 36 } // namespace blink |
| 50 | 37 |
| 51 #endif // ScopedPaintChunkProperties_h | 38 #endif // ScopedPaintChunkProperties_h |
| OLD | NEW |