OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #include "config.h" | 5 #include "config.h" |
6 #include "platform/graphics/paint/ClipRecorder.h" | 6 #include "platform/graphics/paint/ClipRecorder.h" |
7 | 7 |
8 #include "platform/RuntimeEnabledFeatures.h" | 8 #include "platform/RuntimeEnabledFeatures.h" |
9 #include "platform/graphics/GraphicsContext.h" | 9 #include "platform/graphics/GraphicsContext.h" |
10 #include "platform/graphics/paint/ClipDisplayItem.h" | 10 #include "platform/graphics/paint/ClipDisplayItem.h" |
11 #include "platform/graphics/paint/DisplayItemList.h" | 11 #include "platform/graphics/paint/DisplayItemList.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 ClipRecorder::ClipRecorder(GraphicsContext& context, const DisplayItemClientWrap
per& client, DisplayItem::Type type, const LayoutRect& clipRect) | 15 ClipRecorder::ClipRecorder(GraphicsContext& context, const DisplayItemClientWrap
per& client, DisplayItem::Type type, const LayoutRect& clipRect) |
16 : m_client(client) | 16 : m_client(client) |
17 , m_context(context) | 17 , m_context(context) |
18 , m_type(type) | 18 , m_type(type) |
19 { | 19 { |
20 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { | 20 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { |
21 ASSERT(m_context.displayItemList()); | 21 ASSERT(m_context.displayItemList()); |
22 if (m_context.displayItemList()->displayItemConstructionIsDisabled()) | 22 if (m_context.displayItemList()->displayItemConstructionIsDisabled()) |
23 return; | 23 return; |
24 m_context.displayItemList()->add(ClipDisplayItem::create(m_client, type,
pixelSnappedIntRect(clipRect))); | 24 m_context.displayItemList()->createAndAppend<ClipDisplayItem>(m_client,
type, pixelSnappedIntRect(clipRect)); |
25 } else { | 25 } else { |
26 ClipDisplayItem clipDisplayItem(m_client, type, pixelSnappedIntRect(clip
Rect)); | 26 ClipDisplayItem clipDisplayItem(m_client, type, pixelSnappedIntRect(clip
Rect)); |
27 clipDisplayItem.replay(m_context); | 27 clipDisplayItem.replay(m_context); |
28 } | 28 } |
29 } | 29 } |
30 | 30 |
31 ClipRecorder::~ClipRecorder() | 31 ClipRecorder::~ClipRecorder() |
32 { | 32 { |
33 DisplayItem::Type endType = DisplayItem::clipTypeToEndClipType(m_type); | |
34 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { | 33 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { |
35 ASSERT(m_context.displayItemList()); | 34 ASSERT(m_context.displayItemList()); |
36 if (!m_context.displayItemList()->displayItemConstructionIsDisabled()) { | 35 if (!m_context.displayItemList()->displayItemConstructionIsDisabled()) { |
37 if (m_context.displayItemList()->lastDisplayItemIsNoopBegin()) | 36 if (m_context.displayItemList()->lastDisplayItemIsNoopBegin()) |
38 m_context.displayItemList()->removeLastDisplayItem(); | 37 m_context.displayItemList()->removeLastDisplayItem(); |
39 else | 38 else |
40 m_context.displayItemList()->add(EndClipDisplayItem::create(m_cl
ient, endType)); | 39 m_context.displayItemList()->createAndAppend<EndClipDisplayItem>
(m_client, DisplayItem::clipTypeToEndClipType(m_type)); |
41 } | 40 } |
42 } else { | 41 } else { |
43 EndClipDisplayItem endClipDisplayItem(m_client, endType); | 42 EndClipDisplayItem endClipDisplayItem(m_client, DisplayItem::clipTypeToE
ndClipType(m_type)); |
44 endClipDisplayItem.replay(m_context); | 43 endClipDisplayItem.replay(m_context); |
45 } | 44 } |
46 } | 45 } |
47 | 46 |
48 } // namespace blink | 47 } // namespace blink |
OLD | NEW |