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

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

Issue 799563002: Use DrawingRecorder::canUseCachedDrawing (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years 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
« no previous file with comments | « Source/core/rendering/RenderBlockFlow.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/DrawingRecorder.h" 6 #include "platform/graphics/paint/DrawingRecorder.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/GraphicsLayer.h" 10 #include "platform/graphics/GraphicsLayer.h"
(...skipping 17 matching lines...) Expand all
28 { 28 {
29 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) 29 if (!RuntimeEnabledFeatures::slimmingPaintEnabled())
30 return; 30 return;
31 31
32 #if ENABLE(ASSERT) 32 #if ENABLE(ASSERT)
33 ASSERT(!s_inDrawingRecorder); 33 ASSERT(!s_inDrawingRecorder);
34 s_inDrawingRecorder = true; 34 s_inDrawingRecorder = true;
35 #endif 35 #endif
36 36
37 m_canUseCachedDrawing = context->displayItemList()->clientCacheIsValid(displ ayItemClient); 37 m_canUseCachedDrawing = context->displayItemList()->clientCacheIsValid(displ ayItemClient);
38 // FIXME: beginRecording only if !m_canUseCachedDrawing or ENABLE(ASSERT) 38 #if ENABLE(ASSERT)
39 // after all painters call canUseCachedDrawing(). 39 // Enable recording to check if any painter is still doing unnecessary paint ing when we can use cache.
40 m_context->beginRecording(bounds); 40 m_context->beginRecording(bounds);
41 #else
42 if (!m_canUseCachedDrawing)
43 m_context->beginRecording(bounds);
44 #endif
41 } 45 }
42 46
43 DrawingRecorder::~DrawingRecorder() 47 DrawingRecorder::~DrawingRecorder()
44 { 48 {
45 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) 49 if (!RuntimeEnabledFeatures::slimmingPaintEnabled())
46 return; 50 return;
47 51
48 #if ENABLE(ASSERT) 52 #if ENABLE(ASSERT)
49 s_inDrawingRecorder = false; 53 s_inDrawingRecorder = false;
50 #endif 54 #endif
51 55
52 OwnPtr<DisplayItem> displayItem; 56 OwnPtr<DisplayItem> displayItem;
53 57
54 if (m_canUseCachedDrawing) { 58 if (m_canUseCachedDrawing) {
55 // FIXME: endRecording only if ENABLE(ASSERT), and enable the following ASSERT 59 #if ENABLE(ASSERT)
56 // after all painters call canUseCachedDrawing().
57 RefPtr<const SkPicture> picture = m_context->endRecording(); 60 RefPtr<const SkPicture> picture = m_context->endRecording();
58 // ASSERT(!picture || !picture->approximateOpCount()); 61 ASSERT(!picture || !picture->approximateOpCount());
62 #endif
59 displayItem = CachedDisplayItem::create(m_displayItemClient, m_displayIt emType); 63 displayItem = CachedDisplayItem::create(m_displayItemClient, m_displayIt emType);
60 } else { 64 } else {
61 RefPtr<const SkPicture> picture = m_context->endRecording(); 65 RefPtr<const SkPicture> picture = m_context->endRecording();
62 if (!picture || !picture->approximateOpCount()) 66 if (!picture || !picture->approximateOpCount())
63 return; 67 return;
64 displayItem = DrawingDisplayItem::create(m_displayItemClient, m_displayI temType, picture); 68 displayItem = DrawingDisplayItem::create(m_displayItemClient, m_displayI temType, picture);
65 } 69 }
66 70
67 #ifndef NDEBUG 71 #ifndef NDEBUG
68 displayItem->setClientDebugString(m_clientDebugString); 72 displayItem->setClientDebugString(m_clientDebugString);
69 #endif 73 #endif
70 74
71 m_context->displayItemList()->add(displayItem.release()); 75 m_context->displayItemList()->add(displayItem.release());
72 } 76 }
73 77
74 #ifndef NDEBUG 78 #ifndef NDEBUG
75 void DrawingRecorder::setClientDebugString(const WTF::String& clientDebugString) 79 void DrawingRecorder::setClientDebugString(const WTF::String& clientDebugString)
76 { 80 {
77 m_clientDebugString = clientDebugString; 81 m_clientDebugString = clientDebugString;
78 } 82 }
79 #endif 83 #endif
80 84
81 } // namespace blink 85 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBlockFlow.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698