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" | |
8 #include "platform/graphics/paint/PaintChunkProperties.h" | 10 #include "platform/graphics/paint/PaintChunkProperties.h" |
9 #include "platform/graphics/paint/PaintController.h" | 11 #include "platform/graphics/paint/PaintController.h" |
10 #include "wtf/Allocator.h" | 12 #include "wtf/Allocator.h" |
11 #include "wtf/Noncopyable.h" | 13 #include "wtf/Noncopyable.h" |
12 | 14 |
13 namespace blink { | 15 namespace blink { |
14 | 16 |
15 class ScopedPaintChunkProperties { | 17 class ScopedPaintChunkProperties { |
16 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 18 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
17 WTF_MAKE_NONCOPYABLE(ScopedPaintChunkProperties); | 19 WTF_MAKE_NONCOPYABLE(ScopedPaintChunkProperties); |
18 public: | 20 public: |
19 ScopedPaintChunkProperties(PaintController& paintController, const PaintChun kProperties& properties) | 21 ScopedPaintChunkProperties(PaintController& paintController, const DisplayIt emClient& client, DisplayItem::Type type, const PaintChunkProperties& properties ) |
20 : m_paintController(paintController) | 22 : m_paintController(paintController) |
21 , m_previousProperties(paintController.currentPaintChunkProperties()) | 23 , m_previousProperties(paintController.currentPaintChunkProperties()) |
22 { | 24 { |
23 m_paintController.updateCurrentPaintChunkProperties(properties); | 25 PaintChunk::Id id(client, type); |
26 m_paintController.updateCurrentPaintChunkProperties(&id, properties); | |
24 } | 27 } |
25 | 28 |
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 | |
26 ~ScopedPaintChunkProperties() | 34 ~ScopedPaintChunkProperties() |
27 { | 35 { |
28 m_paintController.updateCurrentPaintChunkProperties(m_previousProperties ); | 36 // We should not return to the previous id, because that may cause a new chunk to use |
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); | |
chrishtr
2016/07/19 17:27:52
Will this sometimes create extra empty paint chunk
Xianzhu
2016/07/19 21:57:48
PaintChunker checks change of PaintChunkProperties
| |
29 } | 42 } |
30 | 43 |
31 private: | 44 private: |
32 PaintController& m_paintController; | 45 PaintController& m_paintController; |
33 PaintChunkProperties m_previousProperties; | 46 PaintChunkProperties m_previousProperties; |
34 }; | 47 }; |
35 | 48 |
36 } // namespace blink | 49 } // namespace blink |
37 | 50 |
38 #endif // ScopedPaintChunkProperties_h | 51 #endif // ScopedPaintChunkProperties_h |
OLD | NEW |