| 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/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" |
| 11 #include "platform/graphics/paint/CachedDisplayItem.h" | 11 #include "platform/graphics/paint/CachedDisplayItem.h" |
| 12 #include "platform/graphics/paint/DisplayItemList.h" | 12 #include "platform/graphics/paint/DisplayItemList.h" |
| 13 #include "platform/graphics/paint/DrawingDisplayItem.h" | |
| 14 #include "third_party/skia/include/core/SkPicture.h" | 13 #include "third_party/skia/include/core/SkPicture.h" |
| 15 | 14 |
| 16 namespace blink { | 15 namespace blink { |
| 17 | 16 |
| 18 DrawingRecorder::DrawingRecorder(GraphicsContext& context, const DisplayItemClie
ntWrapper& displayItemClient, DisplayItem::Type displayItemType, const FloatRect
& cullRect) | 17 DrawingRecorder::DrawingRecorder(GraphicsContext& context, const DisplayItemClie
ntWrapper& displayItemClient, DisplayItem::Type displayItemType, const FloatRect
& cullRect) |
| 19 : m_context(context) | 18 : m_context(context) |
| 20 , m_displayItemClient(displayItemClient) | 19 , m_displayItemClient(displayItemClient) |
| 21 , m_displayItemType(displayItemType) | 20 , m_displayItemType(displayItemType) |
| 22 , m_canUseCachedDrawing(false) | 21 , m_canUseCachedDrawing(false) |
| 23 #if ENABLE(ASSERT) | 22 #if ENABLE(ASSERT) |
| 24 , m_checkedCachedDrawing(false) | 23 , m_checkedCachedDrawing(false) |
| 25 , m_displayItemPosition(RuntimeEnabledFeatures::slimmingPaintEnabled() ? m_c
ontext.displayItemList()->newDisplayItemsSize() : 0) | 24 , m_displayItemPosition(RuntimeEnabledFeatures::slimmingPaintEnabled() ? m_c
ontext.displayItemList()->newDisplayItemsSize() : 0) |
| 26 , m_skipUnderInvalidationChecking(false) | 25 , m_underInvalidationCheckingMode(DrawingDisplayItem::CheckPicture) |
| 27 #endif | 26 #endif |
| 28 { | 27 { |
| 29 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) | 28 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) |
| 30 return; | 29 return; |
| 31 | 30 |
| 32 ASSERT(context.displayItemList()); | 31 ASSERT(context.displayItemList()); |
| 33 if (context.displayItemList()->displayItemConstructionIsDisabled()) | 32 if (context.displayItemList()->displayItemConstructionIsDisabled()) |
| 34 return; | 33 return; |
| 35 | 34 |
| 36 ASSERT(DisplayItem::isDrawingType(displayItemType)); | 35 ASSERT(DisplayItem::isDrawingType(displayItemType)); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 RefPtr<const SkPicture> picture = m_context.endRecording(); | 82 RefPtr<const SkPicture> picture = m_context.endRecording(); |
| 84 if (picture && picture->approximateOpCount()) { | 83 if (picture && picture->approximateOpCount()) { |
| 85 WTF_LOG_ERROR("Unnecessary painting for %s\n. Should check recorder.
canUseCachedDrawing() before painting", | 84 WTF_LOG_ERROR("Unnecessary painting for %s\n. Should check recorder.
canUseCachedDrawing() before painting", |
| 86 m_displayItemClient.debugName().utf8().data()); | 85 m_displayItemClient.debugName().utf8().data()); |
| 87 } | 86 } |
| 88 #endif | 87 #endif |
| 89 m_context.displayItemList()->add(CachedDisplayItem::create(m_displayItem
Client, DisplayItem::drawingTypeToCachedType(m_displayItemType))); | 88 m_context.displayItemList()->add(CachedDisplayItem::create(m_displayItem
Client, DisplayItem::drawingTypeToCachedType(m_displayItemType))); |
| 90 } else { | 89 } else { |
| 91 OwnPtr<DrawingDisplayItem> drawingDisplayItem = DrawingDisplayItem::crea
te(m_displayItemClient, m_displayItemType, m_context.endRecording()); | 90 OwnPtr<DrawingDisplayItem> drawingDisplayItem = DrawingDisplayItem::crea
te(m_displayItemClient, m_displayItemType, m_context.endRecording()); |
| 92 #if ENABLE(ASSERT) | 91 #if ENABLE(ASSERT) |
| 93 if (m_skipUnderInvalidationChecking) | 92 drawingDisplayItem->setUnderInvalidationCheckingMode(m_underInvalidation
CheckingMode); |
| 94 drawingDisplayItem->setSkipUnderInvalidationChecking(); | |
| 95 #endif | 93 #endif |
| 96 m_context.displayItemList()->add(drawingDisplayItem.release()); | 94 m_context.displayItemList()->add(drawingDisplayItem.release()); |
| 97 } | 95 } |
| 98 } | 96 } |
| 99 | 97 |
| 100 } // namespace blink | 98 } // namespace blink |
| OLD | NEW |