Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: Source/platform/graphics/paint/ClipRecorder.cpp

Issue 1144203004: Allow certain SP recorder classes to defer their "begin" operation. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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, SkRegion::Op op eration) 15 ClipRecorder::ClipRecorder(GraphicsContext& context, const DisplayItemClientWrap per& client, DisplayItem::Type type)
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 , m_engaged(false)
19 { 20 {
20 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { 21 }
21 ASSERT(m_context.displayItemList()); 22
22 if (m_context.displayItemList()->displayItemConstructionIsDisabled()) 23 ClipRecorder::ClipRecorder(GraphicsContext& context, const DisplayItemClientWrap per& client, DisplayItem::Type type, const LayoutRect& clipRect, SkRegion::Op op eration)
23 return; 24 : ClipRecorder(context, client, type)
24 m_context.displayItemList()->add(ClipDisplayItem::create(m_client, type, pixelSnappedIntRect(clipRect), operation)); 25 {
25 } else { 26 begin(clipRect, operation);
26 ClipDisplayItem clipDisplayItem(m_client, type, pixelSnappedIntRect(clip Rect), operation);
27 clipDisplayItem.replay(m_context);
28 }
29 } 27 }
30 28
31 ClipRecorder::~ClipRecorder() 29 ClipRecorder::~ClipRecorder()
32 { 30 {
31 if (!m_engaged)
32 return;
33
33 DisplayItem::Type endType = DisplayItem::clipTypeToEndClipType(m_type); 34 DisplayItem::Type endType = DisplayItem::clipTypeToEndClipType(m_type);
34 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { 35 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
35 ASSERT(m_context.displayItemList()); 36 ASSERT(m_context.displayItemList());
36 if (m_context.displayItemList()->displayItemConstructionIsDisabled()) 37 if (m_context.displayItemList()->displayItemConstructionIsDisabled())
37 return; 38 return;
38 m_context.displayItemList()->add(EndClipDisplayItem::create(m_client, en dType)); 39 m_context.displayItemList()->add(EndClipDisplayItem::create(m_client, en dType));
39 } else { 40 } else {
40 EndClipDisplayItem endClipDisplayItem(m_client, endType); 41 EndClipDisplayItem endClipDisplayItem(m_client, endType);
41 endClipDisplayItem.replay(m_context); 42 endClipDisplayItem.replay(m_context);
42 } 43 }
43 } 44 }
44 45
46 void ClipRecorder::begin(const LayoutRect& clipRect, SkRegion::Op operation)
47 {
48 ASSERT(!m_engaged);
49 m_engaged = true;
50
51 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
52 ASSERT(m_context.displayItemList());
53 if (m_context.displayItemList()->displayItemConstructionIsDisabled())
54 return;
55 m_context.displayItemList()->add(ClipDisplayItem::create(m_client, m_typ e, pixelSnappedIntRect(clipRect), operation));
56 } else {
57 ClipDisplayItem clipDisplayItem(m_client, m_type, pixelSnappedIntRect(cl ipRect), operation);
58 clipDisplayItem.replay(m_context);
59 }
60 }
61
45 } // namespace blink 62 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/graphics/paint/ClipRecorder.h ('k') | Source/platform/graphics/paint/DrawingRecorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698